@cleya/domain
v1.0.0
Published
Type-only contracts for graph regions, helpers and labels
Downloads
49
Readme
@cleya/domain
Public, type-only graph contracts. The package contains the graph label registry and the common region contract. It provides no runtime implementation.
Packages extending the registry must declare @cleya/domain as a
peerDependency so all augmentations resolve to the same module identity.
Their declarations must be included in the consumer's TypeScript program (for
example through the declaring package's public type entry point).
import type { Domain, LabelsOf } from "@cleya/domain";
export interface ScreenNode extends Domain.Node.Base {
_label: "Screen";
}
declare module "@cleya/domain" {
export namespace Domain.Registry {
export interface Node {
"@example/navigation": ScreenNode;
}
}
}
type NodeLabels = LabelsOf<Domain.Node>; // "Screen"Without registrations, nodes carry only _label: string and edges accept string
labels for from and to. Once registered, the unions contain the declared types
and edge defaults restrict endpoints to all registered node labels. Node columns
and graph lifecycle remain the declaring packages' responsibility.
Region, helper and database contracts
Everything lives under the Domain namespace:
Domain.Region<Id, N, E>— a region's literal id, its node and edge unions, the regions itdependsOn(objects, not ids), itshelpers, andmigrateUp/migrateDownover aDomain.Db.Client.Domain.Region.Payload<R>is the{ nodes, edges }shape a contributor hands the engine; payload edges carryfromId/toId.Domain.Helper<I, O>— a named read operation with Standard Schemainput/output, run against aDomain.Db.ReadClient. Helpers are found through the resolved regions, not through the registry.Domain.Db— thequerytagged template (every${}is a prepared-statement parameter),fragment, and theNode<>/Edge<>shapes lbug returns.
bun run typecheck checks the source and three isolated compiler projects: an
empty registry, a registry augmented independently by two packages, and the
region, helper and database contracts.
