@prisma-next/contract 0.13.0-dev.1 → 0.13.0-dev.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,163 +0,0 @@
1
- //#region src/namespace-id.d.ts
2
- type NamespaceId = string & {
3
- readonly __brand: 'NamespaceId';
4
- };
5
- declare function asNamespaceId(value: string): NamespaceId;
6
- //#endregion
7
- //#region src/cross-reference.d.ts
8
- interface CrossReference {
9
- readonly namespace: NamespaceId;
10
- readonly model: string;
11
- /**
12
- * Contract-space identity for cross-space relations. When present, the
13
- * referenced model lives in a different contract space. Absent for local
14
- * (same-space) relations.
15
- */
16
- readonly space?: string;
17
- }
18
- declare const CrossReferenceSchema: import("arktype/internal/variants/object.ts").ObjectType<CrossReference, {}>;
19
- declare function crossRef(model: string, namespace?: string, space?: string): CrossReference;
20
- //#endregion
21
- //#region src/value-set-ref.d.ts
22
- /**
23
- * Space-aware reference coordinate for a domain enum or storage value-set.
24
- *
25
- * `plane` names the contract plane the referenced entity lives in:
26
- * - `'domain'` — the entity lives in the domain plane's `enum` slot.
27
- * - `'storage'` — the entity lives in the storage plane's `valueSet` slot.
28
- *
29
- * `entityKind` names the source entity-kind:
30
- * - `'enum'` — the referenced entity is a domain enum.
31
- * - `'value-set'` — the referenced entity is a storage value-set.
32
- *
33
- * `namespaceId` admits the `UNBOUND_NAMESPACE_ID` (`__unbound__`) sentinel for
34
- * single-namespace (unbound) references.
35
- *
36
- * Cross-space discrimination is presence-based: when `spaceId` is absent the
37
- * reference is local (same contract-space); when `spaceId` is present the
38
- * reference is cross-space. This mirrors the `ForeignKeyReference` carrier
39
- * convention — no separate tag field — so local refs are JSON-minimal.
40
- */
41
- interface ValueSetRef {
42
- readonly plane: 'domain' | 'storage';
43
- readonly namespaceId: string;
44
- readonly entityKind: 'enum' | 'value-set';
45
- readonly name: string;
46
- readonly spaceId?: string;
47
- }
48
- //#endregion
49
- //#region src/domain-types.d.ts
50
- type ScalarFieldType = {
51
- readonly kind: 'scalar';
52
- readonly codecId: string;
53
- readonly typeParams?: Record<string, unknown>;
54
- };
55
- type ValueObjectFieldType = {
56
- readonly kind: 'valueObject';
57
- readonly name: string;
58
- };
59
- type UnionFieldType = {
60
- readonly kind: 'union';
61
- readonly members: ReadonlyArray<ScalarFieldType | ValueObjectFieldType>;
62
- };
63
- type ContractFieldType = ScalarFieldType | ValueObjectFieldType | UnionFieldType;
64
- type ContractField = {
65
- readonly nullable: boolean;
66
- readonly type: ContractFieldType;
67
- readonly many?: true;
68
- readonly dict?: true;
69
- readonly valueSet?: ValueSetRef;
70
- };
71
- /**
72
- * A domain enum: an ordered set of named members, each with a codec-encoded
73
- * value. The `codecId` identifies the codec used to encode member values in
74
- * storage. The `members` array is ordered (declaration order is preserved).
75
- */
76
- type ContractEnum = {
77
- readonly codecId: string;
78
- readonly members: readonly {
79
- readonly name: string;
80
- readonly value: string;
81
- }[];
82
- };
83
- type ContractRelationOn = {
84
- readonly localFields: readonly string[];
85
- readonly targetFields: readonly string[];
86
- };
87
- type ContractRelationThrough = {
88
- readonly table: string;
89
- readonly namespaceId: string;
90
- readonly parentColumns: readonly string[];
91
- readonly childColumns: readonly string[];
92
- readonly targetColumns: readonly string[];
93
- };
94
- type ContractManyToManyRelation = {
95
- readonly to: CrossReference;
96
- readonly cardinality: 'N:M';
97
- readonly on: ContractRelationOn;
98
- readonly through: ContractRelationThrough;
99
- };
100
- type ContractNonJunctionRelation = {
101
- readonly to: CrossReference;
102
- readonly cardinality: '1:1' | '1:N' | 'N:1';
103
- readonly on: ContractRelationOn;
104
- readonly through?: never;
105
- };
106
- type ContractReferenceRelation = ContractManyToManyRelation | ContractNonJunctionRelation;
107
- type ContractEmbedRelation = {
108
- readonly to: CrossReference;
109
- readonly cardinality: '1:1' | '1:N';
110
- };
111
- type ContractRelation = ContractReferenceRelation | ContractEmbedRelation;
112
- type ContractDiscriminator = {
113
- readonly field: string;
114
- };
115
- type ContractVariantEntry = {
116
- readonly value: string;
117
- };
118
- type ContractValueObject = {
119
- readonly fields: Record<string, ContractField>;
120
- };
121
- type ModelStorageBase = Readonly<Record<string, unknown>>;
122
- interface ContractModelBase<TModelStorage extends ModelStorageBase = ModelStorageBase> {
123
- readonly fields: Record<string, ContractField>;
124
- readonly relations: Record<string, ContractRelation>;
125
- readonly storage: TModelStorage;
126
- readonly discriminator?: ContractDiscriminator;
127
- readonly variants?: Record<string, ContractVariantEntry>;
128
- readonly base?: CrossReference;
129
- readonly owner?: string;
130
- }
131
- interface ContractModel<TModelStorage extends ModelStorageBase = ModelStorageBase> extends ContractModelBase<TModelStorage> {
132
- readonly fields: Record<string, ContractField>;
133
- }
134
- type ReferenceRelationKeys<TModels extends Record<string, {
135
- readonly relations: Record<string, ContractRelation>;
136
- }>, ModelName extends string & keyof TModels> = { [K in keyof TModels[ModelName]['relations']]: TModels[ModelName]['relations'][K] extends ContractReferenceRelation ? K : never }[keyof TModels[ModelName]['relations']];
137
- type EmbedRelationKeys<TModels extends Record<string, {
138
- readonly relations: Record<string, ContractRelation>;
139
- }>, ModelName extends string & keyof TModels> = { [K in keyof TModels[ModelName]['relations']]: TModels[ModelName]['relations'][K] extends ContractReferenceRelation ? never : K }[keyof TModels[ModelName]['relations']];
140
- //#endregion
141
- //#region src/domain-envelope.d.ts
142
- /**
143
- * One namespace's application-domain entities — models and optional value
144
- * objects keyed by entity name within that namespace coordinate.
145
- */
146
- interface ApplicationDomainNamespace<TModels extends Record<string, ContractModelBase> = Record<string, ContractModelBase>> {
147
- readonly models: TModels;
148
- readonly valueObjects?: Record<string, ContractValueObject>;
149
- readonly enum?: Record<string, ContractEnum>;
150
- }
151
- /**
152
- * Application-domain envelope: entity content keyed by namespace id.
153
- * Mirrors the storage plane's `namespaces` segment (ADR 221).
154
- */
155
- interface ApplicationDomain<TModels extends Record<string, ContractModelBase> = Record<string, ContractModelBase>> {
156
- readonly namespaces: Readonly<Record<string, ApplicationDomainNamespace<TModels>>>;
157
- }
158
- type ContractWithDomain = {
159
- readonly domain: ApplicationDomain;
160
- };
161
- //#endregion
162
- export { asNamespaceId as A, UnionFieldType as C, CrossReferenceSchema as D, CrossReference as E, crossRef as O, ScalarFieldType as S, ValueSetRef as T, ContractValueObject as _, ContractEmbedRelation as a, ModelStorageBase as b, ContractFieldType as c, ContractModelBase as d, ContractNonJunctionRelation as f, ContractRelationThrough as g, ContractRelationOn as h, ContractDiscriminator as i, NamespaceId as k, ContractManyToManyRelation as l, ContractRelation as m, ApplicationDomainNamespace as n, ContractEnum as o, ContractReferenceRelation as p, ContractWithDomain as r, ContractField as s, ApplicationDomain as t, ContractModel as u, ContractVariantEntry as v, ValueObjectFieldType as w, ReferenceRelationKeys as x, EmbedRelationKeys as y };
163
- //# sourceMappingURL=domain-envelope-OkWsysCY.d.mts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"domain-envelope-OkWsysCY.d.mts","names":[],"sources":["../src/namespace-id.ts","../src/cross-reference.ts","../src/value-set-ref.ts","../src/domain-types.ts","../src/domain-envelope.ts"],"mappings":";KAEY,WAAA;EAAA,SAAkC,OAAO;AAAA;AAAA,iBAErC,aAAA,CAAc,KAAA,WAAgB,WAAW;;;UCAxC,cAAA;EAAA,SACN,SAAA,EAAW,WAAW;EAAA,SACtB,KAAA;EDJ0C;AAAA;AAErD;;;EAFqD,SCU1C,KAAA;AAAA;AAAA,cAGE,oBAAA,gDAAoB,UAAA,CAAA,cAAA;AAAA,iBAcjB,QAAA,CACd,KAAA,UACA,SAAA,WACA,KAAA,YACC,cAAc;;;;AD/BjB;;;;AAAqD;AAErD;;;;AAAyD;;;;ACAzD;;;;;UCeiB,WAAA;EAAA,SACN,KAAA;EAAA,SACA,WAAA;EAAA,SACA,UAAA;EAAA,SACA,IAAA;EAAA,SACA,OAAA;AAAA;;;KCrBC,eAAA;EAAA,SACD,IAAA;EAAA,SACA,OAAA;EAAA,SACA,UAAA,GAAa,MAAM;AAAA;AAAA,KAGlB,oBAAA;EAAA,SACD,IAAA;E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