@prisma-next/contract 0.12.0-dev.16 → 0.12.0-dev.2

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.
Files changed (47) hide show
  1. package/dist/{canonicalization-EMnO-Kv4.d.mts → canonicalization-DFE0HJkI.d.mts} +2 -2
  2. package/dist/{canonicalization-EMnO-Kv4.d.mts.map → canonicalization-DFE0HJkI.d.mts.map} +1 -1
  3. package/dist/{canonicalization-path-match-Czn4Vds5.mjs → canonicalization-path-match-b2jFuEso.mjs} +1 -1
  4. package/dist/{canonicalization-path-match-Czn4Vds5.mjs.map → canonicalization-path-match-b2jFuEso.mjs.map} +1 -1
  5. package/dist/{contract-types-BYCjqnPw.d.mts → contract-types-xgwKtd7y.d.mts} +7 -43
  6. package/dist/contract-types-xgwKtd7y.d.mts.map +1 -0
  7. package/dist/{contract-validation-error-DSzyT6W7.d.mts → contract-validation-error-T5LH4DW-.d.mts} +1 -1
  8. package/dist/{contract-validation-error-DSzyT6W7.d.mts.map → contract-validation-error-T5LH4DW-.d.mts.map} +1 -1
  9. package/dist/contract-validation-error.d.mts +1 -1
  10. package/dist/{domain-envelope-Bq5uPLLm.d.mts → domain-envelope-4hyFtJ4_.d.mts} +10 -2
  11. package/dist/{domain-envelope-Bq5uPLLm.d.mts.map → domain-envelope-4hyFtJ4_.d.mts.map} +1 -1
  12. package/dist/hashing-utils.d.mts +1 -1
  13. package/dist/hashing-utils.mjs +1 -1
  14. package/dist/hashing.d.mts +2 -2
  15. package/dist/hashing.mjs +1 -1
  16. package/dist/{namespace-id-BSCer2Vd.mjs → namespace-id-CVpkSFUK.mjs} +1 -1
  17. package/dist/{namespace-id-BSCer2Vd.mjs.map → namespace-id-CVpkSFUK.mjs.map} +1 -1
  18. package/dist/types.d.mts +4 -21
  19. package/dist/types.mjs +25 -33
  20. package/dist/types.mjs.map +1 -1
  21. package/dist/validate-domain.d.mts +1 -1
  22. package/dist/validate-domain.mjs +1 -1
  23. package/package.json +4 -6
  24. package/src/contract-types.ts +5 -9
  25. package/src/domain-envelope.ts +60 -1
  26. package/src/exports/types.ts +7 -11
  27. package/src/types.ts +0 -14
  28. package/dist/contract-types-BYCjqnPw.d.mts.map +0 -1
  29. package/dist/default-namespace-Bhu0oN8U.mjs +0 -33
  30. package/dist/default-namespace-Bhu0oN8U.mjs.map +0 -1
  31. package/dist/default-namespace-CprxWqjF.d.mts +0 -25
  32. package/dist/default-namespace-CprxWqjF.d.mts.map +0 -1
  33. package/dist/default-namespace.d.mts +0 -2
  34. package/dist/default-namespace.mjs +0 -2
  35. package/dist/resolve-domain-model-R4txseVc.mjs +0 -20
  36. package/dist/resolve-domain-model-R4txseVc.mjs.map +0 -1
  37. package/dist/resolve-domain-model-V7axlWB2.d.mts +0 -17
  38. package/dist/resolve-domain-model-V7axlWB2.d.mts.map +0 -1
  39. package/dist/resolve-domain-model.d.mts +0 -2
  40. package/dist/resolve-domain-model.mjs +0 -2
  41. package/dist/types.d.mts.map +0 -1
  42. package/src/control-policy.ts +0 -25
  43. package/src/default-namespace.ts +0 -36
  44. package/src/domain-namespace-access.ts +0 -32
  45. package/src/exports/default-namespace.ts +0 -1
  46. package/src/exports/resolve-domain-model.ts +0 -1
  47. package/src/resolve-domain-model.ts +0 -27
@@ -1,4 +1,4 @@
1
- import { t as Contract } from "./contract-types-BYCjqnPw.mjs";
1
+ import { t as Contract } from "./contract-types-xgwKtd7y.mjs";
2
2
  import { JsonObject } from "@prisma-next/utils/json";
3
3
 
4
4
  //#region src/canonicalization.d.ts
@@ -66,4 +66,4 @@ declare function canonicalizeContractToObject(contract: Contract, options: Canon
66
66
  declare function canonicalizeContract(contract: Contract, options: CanonicalizeContractOptions): string;
67
67
  //#endregion
68
68
  export { canonicalizeContract as a, StorageSort as i, PreserveEmptyPredicate as n, canonicalizeContractToObject as o, SerializeContract as r, CanonicalizeContractOptions as t };
69
- //# sourceMappingURL=canonicalization-EMnO-Kv4.d.mts.map
69
+ //# sourceMappingURL=canonicalization-DFE0HJkI.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"canonicalization-EMnO-Kv4.d.mts","names":[],"sources":["../src/canonicalization.ts"],"mappings":";;;;;;AAcA;;;;;;KAAY,iBAAA,IAAqB,QAAA,EAAU,QAAA,KAAa,UAAU;;AAAA;AAUlE;;;;AAA6D;AAS7D;KATY,sBAAA,IAA0B,IAAuB;;;AASlB;AA6K3C;;;;KA7KY,WAAA,IAAe,OAAgB;AAAA,UA6K1B,2BAAA;EAAA,SACN,aAAA;EAAA;;;;;;;;AA0ByB;AAQpC;EAlCW,SAWA,iBAAA,EAAmB,iBAAA;;;;;;;WAOnB,mBAAA,GAAsB,sBAAA;EAiB/B;;;;;AAEO;AA0BT;EA5BE,SATS,WAAA,GAAc,WAAA;AAAA;;;;;;iBAQT,4BAAA,CACd,QAAA,EAAU,QAAA,EACV,OAAA,EAAS,2BAAA,GACR,MAAA;AAAA,iBA0Ba,oBAAA,CACd,QAAA,EAAU,QAAA,EACV,OAAA,EAAS,2BAA2B"}
1
+ {"version":3,"file":"canonicalization-DFE0HJkI.d.mts","names":[],"sources":["../src/canonicalization.ts"],"mappings":";;;;;;AAcA;;;;;;KAAY,iBAAA,IAAqB,QAAA,EAAU,QAAA,KAAa,UAAU;;AAAA;AAUlE;;;;AAA6D;AAS7D;KATY,sBAAA,IAA0B,IAAuB;;;AASlB;AA6K3C;;;;KA7KY,WAAA,IAAe,OAAgB;AAAA,UA6K1B,2BAAA;EAAA,SACN,aAAA;EAAA;;;;;;;;AA0ByB;AAQpC;EAlCW,SAWA,iBAAA,EAAmB,iBAAA;;;;;;;WAOnB,mBAAA,GAAsB,sBAAA;EAiB/B;;;;;AAEO;AA0BT;EA5BE,SATS,WAAA,GAAc,WAAA;AAAA;;;;;;iBAQT,4BAAA,CACd,QAAA,EAAU,QAAA,EACV,OAAA,EAAS,2BAAA,GACR,MAAA;AAAA,iBA0Ba,oBAAA,CACd,QAAA,EAAU,QAAA,EACV,OAAA,EAAS,2BAA2B"}
@@ -22,4 +22,4 @@ function createPreserveEmptyPredicate(patterns) {
22
22
  //#endregion
23
23
  export { matchesPathPattern as n, createPreserveEmptyPredicate as t };
24
24
 
25
- //# sourceMappingURL=canonicalization-path-match-Czn4Vds5.mjs.map
25
+ //# sourceMappingURL=canonicalization-path-match-b2jFuEso.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"canonicalization-path-match-Czn4Vds5.mjs","names":[],"sources":["../src/canonicalization-path-match.ts"],"sourcesContent":["import type { PreserveEmptyPredicate } from './canonicalization';\n\nexport type PathSegment = string | '*' | readonly string[];\n\nexport type PathPattern = readonly PathSegment[];\n\nexport function matchesPathPattern(path: readonly string[], pattern: PathPattern): boolean {\n if (path.length !== pattern.length) {\n return false;\n }\n\n for (let i = 0; i < pattern.length; i++) {\n const segment = pattern[i];\n const value = path[i];\n if (segment === undefined || value === undefined) {\n return false;\n }\n\n if (segment === '*') {\n continue;\n }\n\n if (typeof segment === 'string') {\n if (value !== segment) {\n return false;\n }\n continue;\n }\n\n if (Array.isArray(segment)) {\n if (!segment.includes(value)) {\n return false;\n }\n }\n }\n\n return true;\n}\n\nexport function createPreserveEmptyPredicate(\n patterns: readonly PathPattern[],\n): PreserveEmptyPredicate {\n return (path) => patterns.some((pattern) => matchesPathPattern(path, pattern));\n}\n"],"mappings":";AAMA,SAAgB,mBAAmB,MAAyB,SAA+B;CACzF,IAAI,KAAK,WAAW,QAAQ,QAC1B,OAAO;CAGT,KAAK,IAAI,IAAI,GAAG,IAAI,QAAQ,QAAQ,KAAK;EACvC,MAAM,UAAU,QAAQ;EACxB,MAAM,QAAQ,KAAK;EACnB,IAAI,YAAY,KAAA,KAAa,UAAU,KAAA,GACrC,OAAO;EAGT,IAAI,YAAY,KACd;EAGF,IAAI,OAAO,YAAY,UAAU;GAC/B,IAAI,UAAU,SACZ,OAAO;GAET;EACF;EAEA,IAAI,MAAM,QAAQ,OAAO;OACnB,CAAC,QAAQ,SAAS,KAAK,GACzB,OAAO;EAAA;CAGb;CAEA,OAAO;AACT;AAEA,SAAgB,6BACd,UACwB;CACxB,QAAQ,SAAS,SAAS,MAAM,YAAY,mBAAmB,MAAM,OAAO,CAAC;AAC/E"}
1
+ {"version":3,"file":"canonicalization-path-match-b2jFuEso.mjs","names":[],"sources":["../src/canonicalization-path-match.ts"],"sourcesContent":["import type { PreserveEmptyPredicate } from './canonicalization';\n\nexport type PathSegment = string | '*' | readonly string[];\n\nexport type PathPattern = readonly PathSegment[];\n\nexport function matchesPathPattern(path: readonly string[], pattern: PathPattern): boolean {\n if (path.length !== pattern.length) {\n return false;\n }\n\n for (let i = 0; i < pattern.length; i++) {\n const segment = pattern[i];\n const value = path[i];\n if (segment === undefined || value === undefined) {\n return false;\n }\n\n if (segment === '*') {\n continue;\n }\n\n if (typeof segment === 'string') {\n if (value !== segment) {\n return false;\n }\n continue;\n }\n\n if (Array.isArray(segment)) {\n if (!segment.includes(value)) {\n return false;\n }\n }\n }\n\n return true;\n}\n\nexport function createPreserveEmptyPredicate(\n patterns: readonly PathPattern[],\n): PreserveEmptyPredicate {\n return (path) => patterns.some((pattern) => matchesPathPattern(path, pattern));\n}\n"],"mappings":";AAMA,SAAgB,mBAAmB,MAAyB,SAA+B;CACzF,IAAI,KAAK,WAAW,QAAQ,QAC1B,OAAO;CAGT,KAAK,IAAI,IAAI,GAAG,IAAI,QAAQ,QAAQ,KAAK;EACvC,MAAM,UAAU,QAAQ;EACxB,MAAM,QAAQ,KAAK;EACnB,IAAI,YAAY,KAAA,KAAa,UAAU,KAAA,GACrC,OAAO;EAGT,IAAI,YAAY,KACd;EAGF,IAAI,OAAO,YAAY,UAAU;GAC/B,IAAI,UAAU,SACZ,OAAO;GAET;EACF;EAEA,IAAI,MAAM,QAAQ,OAAO;OACnB,CAAC,QAAQ,SAAS,KAAK,GACzB,OAAO;EAAA;CAGb;CAEA,OAAO;AACT;AAEA,SAAgB,6BACd,UACwB;CACxB,QAAQ,SAAS,SAAS,MAAM,YAAY,mBAAmB,MAAM,OAAO,CAAC;AAC/E"}
@@ -1,26 +1,5 @@
1
- import { l as ContractModelBase, p as ContractValueObject, t as ApplicationDomain, x as CrossReference } from "./domain-envelope-Bq5uPLLm.mjs";
1
+ import { T as CrossReference, _ as ContractValueObject, p as ContractModelBase, t as ApplicationDomain } from "./domain-envelope-4hyFtJ4_.mjs";
2
2
 
3
- //#region src/control-policy.d.ts
4
- /**
5
- * Governance posture for a storage-plane node or for the contract as a whole.
6
- *
7
- * - `managed` — Prisma Next owns the full lifecycle (DDL, migrations, verification).
8
- * - `tolerated` — node was found in the database but is not schema-managed; Prisma Next
9
- * leaves it untouched while tracking its existence.
10
- * - `external` — node is owned by an external system; Prisma Next never emits DDL for it.
11
- * - `observed` — read-only access; Prisma Next does not write to or migrate the node.
12
- */
13
- type ControlPolicy = 'managed' | 'tolerated' | 'external' | 'observed';
14
- /**
15
- * Resolves the effective control policy for a storage-plane node.
16
- *
17
- * Precedence: node-level value → contract default → `'managed'`.
18
- *
19
- * Both parameters are optional raw values so this function stays node-type-agnostic
20
- * and can be called by any consumer (verifier, planner, etc.) without importing IR classes.
21
- */
22
- declare function effectiveControlPolicy(nodeControl: ControlPolicy | undefined, defaultControl: ControlPolicy | undefined): ControlPolicy;
23
- //#endregion
24
3
  //#region src/types.d.ts
25
4
  /**
26
5
  * Unique symbol used as the key for branding types.
@@ -194,19 +173,6 @@ interface ContractMarkerRecord {
194
173
  readonly meta: Record<string, unknown>;
195
174
  readonly invariants: readonly string[];
196
175
  }
197
- /**
198
- * One applied migration edge from the per-space ledger journal.
199
- * Returned by `readLedger` in append (apply) order.
200
- */
201
- interface LedgerEntryRecord {
202
- readonly space: string;
203
- readonly migrationName: string;
204
- readonly migrationHash: string;
205
- readonly from: string | null;
206
- readonly to: string;
207
- readonly appliedAt: Date;
208
- readonly operationCount: number;
209
- }
210
176
  //#endregion
211
177
  //#region src/contract-types.d.ts
212
178
  /**
@@ -254,16 +220,14 @@ interface Contract<TStorage extends StorageBase = StorageBase, TModels extends R
254
220
  readonly execution?: ContractExecutionSection;
255
221
  readonly profileHash: ProfileHashBase<string>;
256
222
  readonly meta: Record<string, unknown>;
257
- readonly defaultControl?: ControlPolicy;
258
223
  }
259
- /** Model definitions union carried on a {@link Contract}'s `TModels` type parameter. */
260
- type ContractModelDefinitions<TContract extends Contract> = TContract extends Contract<StorageBase, infer TModels> ? TModels : never;
261
- type ExactlyOneNamespace<T extends Record<string, unknown>> = keyof T extends infer Only extends keyof T ? [keyof T] extends [Only] ? Only : never : never;
224
+ type ContractModelsMap<TContract extends Contract> = TContract extends Contract<StorageBase, infer TModels> ? TModels : never;
225
+ type ExactlyOneKey<T extends Record<string, unknown>> = keyof T extends infer Only extends keyof T ? [keyof T] extends [Only] ? Only : never : never;
262
226
  type NamespaceValueObjectsOf<TNamespace> = TNamespace extends {
263
227
  readonly valueObjects?: infer VO;
264
228
  } ? VO extends Record<string, ContractValueObject> ? VO : Record<never, never> : Record<never, never>;
265
- /** Value-object map when the contract declares exactly one domain namespace. */
266
- type ContractValueObjectDefinitions<TContract extends Contract> = NamespaceValueObjectsOf<TContract['domain']['namespaces'][ExactlyOneNamespace<TContract['domain']['namespaces']>]> extends infer Projected ? Projected extends Record<string, ContractValueObject> ? Projected : Record<never, never> : Record<never, never>;
229
+ /** Value-object map for the contract's sole domain namespace (type-level single-namespace projection). */
230
+ type ContractValueObjectsMap<TContract extends Contract> = NamespaceValueObjectsOf<TContract['domain']['namespaces'][ExactlyOneKey<TContract['domain']['namespaces']>]> extends infer Projected ? Projected extends Record<string, ContractValueObject> ? Projected : Record<never, never> : Record<never, never>;
267
231
  //#endregion
268
- export { StorageNamespace as A, LedgerEntryRecord as C, StorageBase as D, Source as E, isExecutionMutationDefaultValue as F, profileHash as I, ControlPolicy as L, executionHash as M, isColumnDefault as N, StorageEntitySlot as O, isColumnDefaultLiteralInputValue as P, effectiveControlPolicy as R, JsonValue as S, ProfileHashBase as T, ExecutionSection as _, $ as a, GeneratedValueSpec as b, ColumnDefaultLiteralInputValue as c, DocCollection as d, DocIndex as f, ExecutionMutationDefaultValue as g, ExecutionMutationDefaultPhases as h, ContractValueObjectDefinitions as i, coreHash as j, StorageHashBase as k, ColumnDefaultLiteralValue as l, ExecutionMutationDefault as m, ContractExecutionSection as n, Brand as o, ExecutionHashBase as p, ContractModelDefinitions as r, ColumnDefault as s, Contract as t, ContractMarkerRecord as u, Expr as v, PlanMeta as w, JsonPrimitive as x, FieldType as y };
269
- //# sourceMappingURL=contract-types-BYCjqnPw.d.mts.map
232
+ export { coreHash as A, PlanMeta as C, StorageEntitySlot as D, StorageBase as E, profileHash as F, isColumnDefault as M, isColumnDefaultLiteralInputValue as N, StorageHashBase as O, isExecutionMutationDefaultValue as P, JsonValue as S, Source as T, ExecutionSection as _, $ as a, GeneratedValueSpec as b, ColumnDefaultLiteralInputValue as c, DocCollection as d, DocIndex as f, ExecutionMutationDefaultValue as g, ExecutionMutationDefaultPhases as h, ContractValueObjectsMap as i, executionHash as j, StorageNamespace as k, ColumnDefaultLiteralValue as l, ExecutionMutationDefault as m, ContractExecutionSection as n, Brand as o, ExecutionHashBase as p, ContractModelsMap as r, ColumnDefault as s, Contract as t, ContractMarkerRecord as u, Expr as v, ProfileHashBase as w, JsonPrimitive as x, FieldType as y };
233
+ //# sourceMappingURL=contract-types-xgwKtd7y.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"contract-types-xgwKtd7y.d.mts","names":[],"sources":["../src/types.ts","../src/contract-types.ts"],"mappings":";;;;;;cAGa,CAAA;;;;AAAkD;AAQ/D;;KAAY,KAAA;EAAA,CACT,CAAA,WACO,IAAA,GAAO,MAAA;AAAA;;;;;;KASL,eAAA,yBAAwC,KAAA,GAAQ,KAAK;;;AAT1C;AASvB;;KAOY,iBAAA,yBAA0C,KAAA,GAAQ,KAAK;AAAA,iBAEnD,aAAA,wBAAA,CAAsC,KAAA,EAAO,CAAA,GAAI,iBAAA,CAAkB,CAAA;AAAA,iBAInE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AAM;EAAA,SACZ,UAAA;AAAA;;;;;;AAhPoD;AAQ/D;;;;;KCQY,wBAAA;EAAA,SACD,aAAA,EAAe,iBAAA,CAAkB,KAAA;EAAA,SACjC,SAAA;IAAA,SACE,QAAA,EAAU,aAAA,CAAc,wBAAA;EAAA;AAAA;;;;;ADTd;AASvB;;;;;;;;AAAiE;AAOjE;UCYiB,QAAA,kBACE,WAAA,GAAc,WAAA,kBACf,MAAA,SAAe,iBAAA,IAAqB,MAAA,SAAe,iBAAA;EAAA,SAE1D,MAAA;EAAA,SACA,YAAA;EAAA,SACA,KAAA,EAAO,MAAA,SAAe,cAAA;EDlBqB;;;AAAa;EAAb,SCuB3C,MAAA,EAAQ,iBAAA,CAAkB,OAAA;EAAA,SAC1B,OAAA,EAAS,QAAA;EAAA,SACT,YAAA,EAAc,MAAA,SAAe,MAAA;EAAA,SAC7B,cAAA,EAAgB,MAAA;EAAA,SAChB,SAAA,GAAY,wBAAA;EAAA,SACZ,WAAA,EAAa,eAAA;EAAA,SACb,IAAA,EAAM,MAAA;AAAA;AAAA,KAGL,iBAAA,mBAAoC,QAAA,IAC9C,SAAA,SAAkB,QAAA,CAAS,WAAA,mBAA8B,OAAA;AAAA,KAEtD,aAAA,WAAwB,MAAA,2BAAiC,CAAA,kCAAmC,CAAA,UACtF,CAAA,WAAY,IAAA,IACjB,IAAA;AAAA,KAID,uBAAA,eAAsC,UAAA;EAAA,SAChC,YAAA;AAAA,IAEP,EAAA,SAAW,MAAA,SAAe,mBAAA,IACxB,EAAA,GACA,MAAA,iBACF,MAAA;;KAGQ,uBAAA,mBAA0C,QAAA,IACpD,uBAAA,CACE,SAAA,yBAAkC,aAAA,CAAc,SAAA,sDAE9C,SAAA,SAAkB,MAAA,SAAe,mBAAA,IAC/B,SAAA,GACA,MAAA,iBACF,MAAA"}
@@ -10,4 +10,4 @@ declare class DomainNamespaceResolutionError extends Error {
10
10
  }
11
11
  //#endregion
12
12
  export { ContractValidationPhase as n, DomainNamespaceResolutionError as r, ContractValidationError as t };
13
- //# sourceMappingURL=contract-validation-error-DSzyT6W7.d.mts.map
13
+ //# sourceMappingURL=contract-validation-error-T5LH4DW-.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"contract-validation-error-DSzyT6W7.d.mts","names":[],"sources":["../src/contract-validation-error.ts"],"mappings":";KAAY,uBAAA;AAAA,cAEC,uBAAA,SAAgC,KAAA;EAAA,SAClC,IAAA;EAAA,SACA,KAAA,EAAO,uBAAA;cAEJ,OAAA,UAAiB,KAAA,EAAO,uBAAA;AAAA;AAAA,cAOzB,8BAAA,SAAuC,KAAK;cAC3C,OAAA;AAAA"}
1
+ {"version":3,"file":"contract-validation-error-T5LH4DW-.d.mts","names":[],"sources":["../src/contract-validation-error.ts"],"mappings":";KAAY,uBAAA;AAAA,cAEC,uBAAA,SAAgC,KAAA;EAAA,SAClC,IAAA;EAAA,SACA,KAAA,EAAO,uBAAA;cAEJ,OAAA,UAAiB,KAAA,EAAO,uBAAA;AAAA;AAAA,cAOzB,8BAAA,SAAuC,KAAK;cAC3C,OAAA;AAAA"}
@@ -1,2 +1,2 @@
1
- import { n as ContractValidationPhase, r as DomainNamespaceResolutionError, t as ContractValidationError } from "./contract-validation-error-DSzyT6W7.mjs";
1
+ import { n as ContractValidationPhase, r as DomainNamespaceResolutionError, t as ContractValidationError } from "./contract-validation-error-T5LH4DW-.mjs";
2
2
  export { ContractValidationError, type ContractValidationPhase, DomainNamespaceResolutionError };
@@ -79,6 +79,7 @@ type EmbedRelationKeys<TModels extends Record<string, {
79
79
  }>, ModelName extends string & keyof TModels> = { [K in keyof TModels[ModelName]['relations']]: TModels[ModelName]['relations'][K] extends ContractReferenceRelation ? never : K }[keyof TModels[ModelName]['relations']];
80
80
  //#endregion
81
81
  //#region src/domain-envelope.d.ts
82
+ declare const UNBOUND_DOMAIN_NAMESPACE_ID: "__unbound__";
82
83
  /**
83
84
  * One namespace's application-domain entities — models and optional value
84
85
  * objects keyed by entity name within that namespace coordinate.
@@ -97,6 +98,13 @@ interface ApplicationDomain<TModels extends Record<string, ContractModelBase> =
97
98
  type ContractWithDomain = {
98
99
  readonly domain: ApplicationDomain;
99
100
  };
101
+ declare function resolveSingleDomainNamespaceId(domain: ApplicationDomain, namespaceId?: string): string;
102
+ declare function contractModels<TModels extends Record<string, ContractModelBase>>(contract: {
103
+ readonly domain: ApplicationDomain<TModels>;
104
+ }, namespaceId?: string): TModels;
105
+ declare function contractValueObjects<TModels extends Record<string, ContractModelBase>>(contract: {
106
+ readonly domain: ApplicationDomain<TModels>;
107
+ }, namespaceId?: string): Record<string, ContractValueObject> | undefined;
100
108
  //#endregion
101
- export { crossRef as C, CrossReferenceSchema as S, asNamespaceId as T, ReferenceRelationKeys as _, ContractEmbedRelation as a, ValueObjectFieldType as b, ContractModel as c, ContractRelation as d, ContractRelationOn as f, ModelStorageBase as g, EmbedRelationKeys as h, ContractDiscriminator as i, ContractModelBase as l, ContractVariantEntry as m, ApplicationDomainNamespace as n, ContractField as o, ContractValueObject as p, ContractWithDomain as r, ContractFieldType as s, ApplicationDomain as t, ContractReferenceRelation as u, ScalarFieldType as v, NamespaceId as w, CrossReference as x, UnionFieldType as y };
102
- //# sourceMappingURL=domain-envelope-Bq5uPLLm.d.mts.map
109
+ export { UnionFieldType as C, crossRef as D, CrossReferenceSchema as E, NamespaceId as O, ScalarFieldType as S, CrossReference as T, ContractValueObject as _, contractModels as a, ModelStorageBase as b, ContractDiscriminator as c, ContractFieldType as d, ContractModel as f, ContractRelationOn as g, ContractRelation as h, UNBOUND_DOMAIN_NAMESPACE_ID as i, asNamespaceId as k, ContractEmbedRelation as l, ContractReferenceRelation as m, ApplicationDomainNamespace as n, contractValueObjects as o, ContractModelBase as p, ContractWithDomain as r, resolveSingleDomainNamespaceId as s, ApplicationDomain as t, ContractField as u, ContractVariantEntry as v, ValueObjectFieldType as w, ReferenceRelationKeys as x, EmbedRelationKeys as y };
110
+ //# sourceMappingURL=domain-envelope-4hyFtJ4_.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"domain-envelope-Bq5uPLLm.d.mts","names":[],"sources":["../src/namespace-id.ts","../src/cross-reference.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;AAAA;AAAA,cAGE,oBAAA,EAAoB,sCAAA,CAAA,UAAA,CAAA,cAAA;AAAA,iBAajB,QAAA,CACd,KAAA,UACA,SAAA,YACC,cAAc;;;KCvBL,eAAA;EAAA,SACD,IAAA;EAAA,SACA,OAAA;EAAA,SACA,UAAA,GAAa,MAAM;AAAA;AAAA,KAGlB,oBAAA;EAAA,SACD,IAAA;EAAA,SACA,IAAI;AAAA;AAAA,KAGH,cAAA;EAAA,SACD,IAAA;EAAA,SACA,OAAA,EAAS,aAAA,CAAc,eAAA,GAAkB,oBAAA;AAAA;AAAA,KAGxC,iBAAA,GAAoB,eAAA,GAAkB,oBAAA,GAAuB,cAAA;AAAA,KAE7D,aAAA;EAAA,SACD,QAAA;EAAA,SACA,IAAA,EAAM,iBAAiB;EAAA,SACvB,IAAA;EAAA,SACA,IAAA;AAAA;AAAA,KAGC,kBAAA;EAAA,SACD,WAAA;EAAA,SACA,YAAY;AAAA;AAAA,KAGX,yBAAA;EAAA,SACD,EAAA,EAAI,cAAA;EAAA,SACJ,WAAA;EAAA,SACA,EAAA,EAAI,kBAAkB;AAAA;AAAA,KAGrB,qBAAA;EAAA,SACD,EAAA,EAAI,cAAc;EAAA,SAClB,WAAA;AAAA;AAAA,KAGC,gBAAA,GAAmB,yBAAA,GAA4B,qBAAqB;AAAA,KAEpE,qBAAA;EAAA,SACD,KAAK;AAAA;AAAA,KAGJ,oBAAA;EAAA,SACD,KAAK;AAAA;AAAA,KAGJ,mBAAA;EAAA,SACD,MAAA,EAAQ,MAAM,SA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KAG9D,kBAAA;EAAA,SACD,MAAA,EAAQ,iBAAiB;AAAA"}
1
+ {"version":3,"file":"domain-envelope-4hyFtJ4_.d.mts","names":[],"sources":["../src/namespace-id.ts","../src/cross-reference.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;AAAA;AAAA,cAGE,oBAAA,EAAoB,sCAAA,CAAA,UAAA,CAAA,cAAA;AAAA,iBAajB,QAAA,CACd,KAAA,UACA,SAAA,YACC,cAAc;;;KCvBL,eAAA;EAAA,SACD,IAAA;EAAA,SACA,OAAA;EAAA,SACA,UAAA,GAAa,MAAM;AAAA;AAAA,KAGlB,oBAAA;EAAA,SACD,IAAA;EAAA,SACA,IAAI;AAAA;AAAA,KAGH,cAAA;EAAA,SACD,IAAA;EAAA,SACA,OAAA,EAAS,aAAA,CAAc,eAAA,GAAkB,oBAAA;AAAA;AAAA,KAGxC,iBAAA,GAAoB,eAAA,GAAkB,oBAAA,GAAuB,cAAA;AAAA,KAE7D,aAAA;EAAA,SACD,QAAA;EAAA,SACA,IAAA,EAAM,iBAAiB;EAAA,SACvB,IAAA;EAAA,SACA,IAAA;AAAA;AAAA,KAGC,kBAAA;EAAA,SACD,WAAA;EAAA,SACA,YAAY;AAAA;AAAA,KAGX,yBAAA;EAAA,SACD,EAAA,EAAI,cAAA;EAAA,SACJ,WAAA;EAAA,SACA,EAAA,EAAI,kBAAkB;AAAA;AAAA,KAGrB,qBAAA;EAAA,SACD,EAAA,EAAI,cAAc;EAAA,SAClB,WAAA;AAAA;AAAA,KAGC,gBAAA,GAAmB,yBAAA,GAA4B,qBAAqB;AAAA,KAEpE,qBAAA;EAAA,SACD,KAAK;AAAA;AAAA,KAGJ,oBAAA;EAAA,SACD,KAAK;AAAA;AAAA,KAGJ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AAA,CAAS,MAAA,SAAe,0BAAA,CAA2B,OAAA;AAAA;AAAA,KAG9D,kBAAA;EAAA,SACD,MAAA,EAAQ,iBAAiB;AAAA;AAAA,iBAGpB,8BAAA,CACd,MAAA,EAAQ,iBAAiB,EACzB,WAAA;AAAA,iBA4Bc,cAAA,iBAA+B,MAAA,SAAe,iBAAA,EAAA,CAC5D,QAAA;EAAA,SAAqB,MAAA,EAAQ,iBAAA,CAAkB,OAAA;AAAA,GAC/C,WAAA,YACC,OAAA;AAAA,iBAWa,oBAAA,iBAAqC,MAAA,SAAe,iBAAA,EAAA,CAClE,QAAA;EAAA,SAAqB,MAAA,EAAQ,iBAAA,CAAkB,OAAA;AAAA,GAC/C,WAAA,YACC,MAAA,SAAe,mBAAA"}
@@ -1,4 +1,4 @@
1
- import { i as StorageSort, n as PreserveEmptyPredicate } from "./canonicalization-EMnO-Kv4.mjs";
1
+ import { i as StorageSort, n as PreserveEmptyPredicate } from "./canonicalization-DFE0HJkI.mjs";
2
2
 
3
3
  //#region src/canonicalization-path-match.d.ts
4
4
  type PathSegment = string | '*' | readonly string[];
@@ -1,4 +1,4 @@
1
- import { n as matchesPathPattern, t as createPreserveEmptyPredicate } from "./canonicalization-path-match-Czn4Vds5.mjs";
1
+ import { n as matchesPathPattern, t as createPreserveEmptyPredicate } from "./canonicalization-path-match-b2jFuEso.mjs";
2
2
  //#region src/canonicalization-storage-sort.ts
3
3
  function isPlainRecord(value) {
4
4
  return typeof value === "object" && value !== null && !Array.isArray(value);
@@ -1,5 +1,5 @@
1
- import { T as ProfileHashBase, k as StorageHashBase, p as ExecutionHashBase } from "./contract-types-BYCjqnPw.mjs";
2
- import { a as canonicalizeContract, i as StorageSort, n as PreserveEmptyPredicate, o as canonicalizeContractToObject, r as SerializeContract, t as CanonicalizeContractOptions } from "./canonicalization-EMnO-Kv4.mjs";
1
+ import { O as StorageHashBase, p as ExecutionHashBase, w as ProfileHashBase } from "./contract-types-xgwKtd7y.mjs";
2
+ import { a as canonicalizeContract, i as StorageSort, n as PreserveEmptyPredicate, o as canonicalizeContractToObject, r as SerializeContract, t as CanonicalizeContractOptions } from "./canonicalization-DFE0HJkI.mjs";
3
3
 
4
4
  //#region src/hashing.d.ts
5
5
  type ComputeStorageHashArgs = {
package/dist/hashing.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { n as matchesPathPattern } from "./canonicalization-path-match-Czn4Vds5.mjs";
1
+ import { n as matchesPathPattern } from "./canonicalization-path-match-b2jFuEso.mjs";
2
2
  import { isArrayEqual } from "@prisma-next/utils/array-equal";
3
3
  import { ifDefined } from "@prisma-next/utils/defined";
4
4
  import { createHash } from "node:crypto";
@@ -6,4 +6,4 @@ function asNamespaceId(value) {
6
6
  //#endregion
7
7
  export { asNamespaceId as t };
8
8
 
9
- //# sourceMappingURL=namespace-id-BSCer2Vd.mjs.map
9
+ //# sourceMappingURL=namespace-id-CVpkSFUK.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"namespace-id-BSCer2Vd.mjs","names":[],"sources":["../src/namespace-id.ts"],"sourcesContent":["import { blindCast } from '@prisma-next/utils/casts';\n\nexport type NamespaceId = string & { readonly __brand: 'NamespaceId' };\n\nexport function asNamespaceId(value: string): NamespaceId {\n return blindCast<\n NamespaceId,\n 'NamespaceId is a compile-time-only brand on string; this factory is the sole assertion site'\n >(value);\n}\n"],"mappings":";;AAIA,SAAgB,cAAc,OAA4B;CACxD,OAAO,UAGL,KAAK;AACT"}
1
+ {"version":3,"file":"namespace-id-CVpkSFUK.mjs","names":[],"sources":["../src/namespace-id.ts"],"sourcesContent":["import { blindCast } from '@prisma-next/utils/casts';\n\nexport type NamespaceId = string & { readonly __brand: 'NamespaceId' };\n\nexport function asNamespaceId(value: string): NamespaceId {\n return blindCast<\n NamespaceId,\n 'NamespaceId is a compile-time-only brand on string; this factory is the sole assertion site'\n >(value);\n}\n"],"mappings":";;AAIA,SAAgB,cAAc,OAA4B;CACxD,OAAO,UAGL,KAAK;AACT"}
package/dist/types.d.mts CHANGED
@@ -1,21 +1,4 @@
1
- import { r as DomainNamespaceResolutionError } from "./contract-validation-error-DSzyT6W7.mjs";
2
- import { n as soleDomainNamespaceId, t as UNBOUND_DOMAIN_NAMESPACE_ID } from "./default-namespace-CprxWqjF.mjs";
3
- import { A as StorageNamespace, C as LedgerEntryRecord, D as StorageBase, E as Source, F as isExecutionMutationDefaultValue, I as profileHash, L as ControlPolicy, M as executionHash, N as isColumnDefault, O as StorageEntitySlot, P as isColumnDefaultLiteralInputValue, R as effectiveControlPolicy, S as JsonValue, T as ProfileHashBase, _ as ExecutionSection, a as $, b as GeneratedValueSpec, c as ColumnDefaultLiteralInputValue, d as DocCollection, f as DocIndex, g as ExecutionMutationDefaultValue, h as ExecutionMutationDefaultPhases, i as ContractValueObjectDefinitions, j as coreHash, k as StorageHashBase, l as ColumnDefaultLiteralValue, m as ExecutionMutationDefault, n as ContractExecutionSection, o as Brand, p as ExecutionHashBase, r as ContractModelDefinitions, s as ColumnDefault, t as Contract, u as ContractMarkerRecord, v as Expr, w as PlanMeta, x as JsonPrimitive, y as FieldType } from "./contract-types-BYCjqnPw.mjs";
4
- import { C as crossRef, S as CrossReferenceSchema, T as asNamespaceId, _ as ReferenceRelationKeys, a as ContractEmbedRelation, b as ValueObjectFieldType, c as ContractModel, d as ContractRelation, f as ContractRelationOn, g as ModelStorageBase, h as EmbedRelationKeys, i as ContractDiscriminator, l as ContractModelBase, m as ContractVariantEntry, n as ApplicationDomainNamespace, o as ContractField, p as ContractValueObject, r as ContractWithDomain, s as ContractFieldType, t as ApplicationDomain, u as ContractReferenceRelation, v as ScalarFieldType, w as NamespaceId, x as CrossReference, y as UnionFieldType } from "./domain-envelope-Bq5uPLLm.mjs";
5
- import { n as resolveDomainModel, t as ResolvedDomainModel } from "./resolve-domain-model-V7axlWB2.mjs";
6
-
7
- //#region src/domain-namespace-access.d.ts
8
- /**
9
- * Models map for the contract's single domain namespace. Throws when the
10
- * contract does not declare exactly one namespace — bare-name access is
11
- * ambiguous across namespaces and must be qualified explicitly (TML-2550).
12
- */
13
- declare function domainModelsAtDefaultNamespace<TModels extends Record<string, ContractModelBase>>(domain: ApplicationDomain<TModels>): TModels;
14
- /**
15
- * Value objects for the contract's single domain namespace, when present.
16
- * Throws when the contract does not declare exactly one namespace.
17
- */
18
- declare function domainValueObjectsAtDefaultNamespace<TModels extends Record<string, ContractModelBase>>(domain: ApplicationDomain<TModels>): Record<string, ContractValueObject> | undefined;
19
- //#endregion
20
- export { type $, type ApplicationDomain, type ApplicationDomainNamespace, type Brand, type ColumnDefault, type ColumnDefaultLiteralInputValue, type ColumnDefaultLiteralValue, type Contract, type ContractDiscriminator, type ContractEmbedRelation, type ContractExecutionSection, type ContractField, type ContractFieldType, type ContractMarkerRecord, type ContractModel, type ContractModelBase, type ContractModelDefinitions, type ContractReferenceRelation, type ContractRelation, type ContractRelationOn, type ContractValueObject, type ContractValueObjectDefinitions, type ContractVariantEntry, type ContractWithDomain, type ControlPolicy, type CrossReference, CrossReferenceSchema, type DocCollection, type DocIndex, DomainNamespaceResolutionError, type EmbedRelationKeys, type ExecutionHashBase, type ExecutionMutationDefault, type ExecutionMutationDefaultPhases, type ExecutionMutationDefaultValue, type ExecutionSection, type Expr, type FieldType, type GeneratedValueSpec, type JsonPrimitive, type JsonValue, type LedgerEntryRecord, type ModelStorageBase, type NamespaceId, type PlanMeta, type ProfileHashBase, type ReferenceRelationKeys, type ResolvedDomainModel, type ScalarFieldType, type Source, type StorageBase, type StorageEntitySlot, type StorageHashBase, type StorageNamespace, UNBOUND_DOMAIN_NAMESPACE_ID, type UnionFieldType, type ValueObjectFieldType, asNamespaceId, coreHash, crossRef, domainModelsAtDefaultNamespace, domainValueObjectsAtDefaultNamespace, effectiveControlPolicy, executionHash, isColumnDefault, isColumnDefaultLiteralInputValue, isExecutionMutationDefaultValue, profileHash, resolveDomainModel, soleDomainNamespaceId };
21
- //# sourceMappingURL=types.d.mts.map
1
+ import { r as DomainNamespaceResolutionError } from "./contract-validation-error-T5LH4DW-.mjs";
2
+ import { C as UnionFieldType, D as crossRef, E as CrossReferenceSchema, O as NamespaceId, S as ScalarFieldType, T as CrossReference, _ as ContractValueObject, a as contractModels, b as ModelStorageBase, c as ContractDiscriminator, d as ContractFieldType, f as ContractModel, g as ContractRelationOn, h as ContractRelation, i as UNBOUND_DOMAIN_NAMESPACE_ID, k as asNamespaceId, l as ContractEmbedRelation, m as ContractReferenceRelation, n as ApplicationDomainNamespace, o as contractValueObjects, p as ContractModelBase, r as ContractWithDomain, s as resolveSingleDomainNamespaceId, t as ApplicationDomain, u as ContractField, v as ContractVariantEntry, w as ValueObjectFieldType, x as ReferenceRelationKeys, y as EmbedRelationKeys } from "./domain-envelope-4hyFtJ4_.mjs";
3
+ import { A as coreHash, C as PlanMeta, D as StorageEntitySlot, E as StorageBase, F as profileHash, M as isColumnDefault, N as isColumnDefaultLiteralInputValue, O as StorageHashBase, P as isExecutionMutationDefaultValue, S as JsonValue, T as Source, _ as ExecutionSection, a as $, b as GeneratedValueSpec, c as ColumnDefaultLiteralInputValue, d as DocCollection, f as DocIndex, g as ExecutionMutationDefaultValue, h as ExecutionMutationDefaultPhases, i as ContractValueObjectsMap, j as executionHash, k as StorageNamespace, l as ColumnDefaultLiteralValue, m as ExecutionMutationDefault, n as ContractExecutionSection, o as Brand, p as ExecutionHashBase, r as ContractModelsMap, s as ColumnDefault, t as Contract, u as ContractMarkerRecord, v as Expr, w as ProfileHashBase, x as JsonPrimitive, y as FieldType } from "./contract-types-xgwKtd7y.mjs";
4
+ export { type $, type ApplicationDomain, type ApplicationDomainNamespace, type Brand, type ColumnDefault, type ColumnDefaultLiteralInputValue, type ColumnDefaultLiteralValue, type Contract, type ContractDiscriminator, type ContractEmbedRelation, type ContractExecutionSection, type ContractField, type ContractFieldType, type ContractMarkerRecord, type ContractModel, type ContractModelBase, type ContractModelsMap, type ContractReferenceRelation, type ContractRelation, type ContractRelationOn, type ContractValueObject, type ContractValueObjectsMap, type ContractVariantEntry, type ContractWithDomain, type CrossReference, CrossReferenceSchema, type DocCollection, type DocIndex, DomainNamespaceResolutionError, type EmbedRelationKeys, type ExecutionHashBase, type ExecutionMutationDefault, type ExecutionMutationDefaultPhases, type ExecutionMutationDefaultValue, type ExecutionSection, type Expr, type FieldType, type GeneratedValueSpec, type JsonPrimitive, type JsonValue, type ModelStorageBase, type NamespaceId, type PlanMeta, type ProfileHashBase, type ReferenceRelationKeys, type ScalarFieldType, type Source, type StorageBase, type StorageEntitySlot, type StorageHashBase, type StorageNamespace, UNBOUND_DOMAIN_NAMESPACE_ID, type UnionFieldType, type ValueObjectFieldType, asNamespaceId, contractModels, contractValueObjects, coreHash, crossRef, executionHash, isColumnDefault, isColumnDefaultLiteralInputValue, isExecutionMutationDefaultValue, profileHash, resolveSingleDomainNamespaceId };
package/dist/types.mjs CHANGED
@@ -1,22 +1,7 @@
1
1
  import { n as DomainNamespaceResolutionError } from "./contract-validation-error-ClZaKqMW.mjs";
2
- import { n as soleDomainNamespaceId, t as UNBOUND_DOMAIN_NAMESPACE_ID } from "./default-namespace-Bhu0oN8U.mjs";
3
- import { t as resolveDomainModel } from "./resolve-domain-model-R4txseVc.mjs";
4
- import { t as asNamespaceId } from "./namespace-id-BSCer2Vd.mjs";
2
+ import { t as asNamespaceId } from "./namespace-id-CVpkSFUK.mjs";
5
3
  import { blindCast } from "@prisma-next/utils/casts";
6
4
  import { type } from "arktype";
7
- //#region src/control-policy.ts
8
- /**
9
- * Resolves the effective control policy for a storage-plane node.
10
- *
11
- * Precedence: node-level value → contract default → `'managed'`.
12
- *
13
- * Both parameters are optional raw values so this function stays node-type-agnostic
14
- * and can be called by any consumer (verifier, planner, etc.) without importing IR classes.
15
- */
16
- function effectiveControlPolicy(nodeControl, defaultControl) {
17
- return nodeControl ?? defaultControl ?? "managed";
18
- }
19
- //#endregion
20
5
  //#region src/cross-reference.ts
21
6
  const CrossReferenceSchema = /* @__PURE__ */ blindCast(/* @__PURE__ */ type({
22
7
  "+": "reject",
@@ -31,24 +16,31 @@ function crossRef(model, namespace = DEFAULT_CROSS_REF_NAMESPACE) {
31
16
  };
32
17
  }
33
18
  //#endregion
34
- //#region src/domain-namespace-access.ts
35
- /**
36
- * Models map for the contract's single domain namespace. Throws when the
37
- * contract does not declare exactly one namespace — bare-name access is
38
- * ambiguous across namespaces and must be qualified explicitly (TML-2550).
39
- */
40
- function domainModelsAtDefaultNamespace(domain) {
41
- const namespaceId = soleDomainNamespaceId(domain);
42
- const domainNamespace = domain.namespaces[namespaceId];
43
- if (domainNamespace === void 0) throw new DomainNamespaceResolutionError(`domain namespace "${namespaceId}" is not present on the contract`);
19
+ //#region src/domain-envelope.ts
20
+ const UNBOUND_DOMAIN_NAMESPACE_ID = "__unbound__";
21
+ function resolveSingleDomainNamespaceId(domain, namespaceId) {
22
+ if (namespaceId !== void 0) {
23
+ if (!Object.hasOwn(domain.namespaces, namespaceId)) throw new DomainNamespaceResolutionError(`domain namespace "${namespaceId}" is not present on the contract`);
24
+ return namespaceId;
25
+ }
26
+ const namespaceIds = Object.keys(domain.namespaces);
27
+ if (namespaceIds.length === 0) throw new DomainNamespaceResolutionError("domain has no namespaces");
28
+ if (namespaceIds.length > 1) throw new DomainNamespaceResolutionError(`expected exactly one domain namespace, found ${namespaceIds.length} (${namespaceIds.join(", ")})`);
29
+ const [soleNamespaceId] = namespaceIds;
30
+ if (soleNamespaceId === void 0) throw new DomainNamespaceResolutionError("domain has no namespaces");
31
+ return soleNamespaceId;
32
+ }
33
+ function contractModels(contract, namespaceId) {
34
+ const resolved = resolveSingleDomainNamespaceId(contract.domain, namespaceId);
35
+ const domainNamespace = contract.domain.namespaces[resolved];
36
+ if (domainNamespace === void 0) throw new DomainNamespaceResolutionError(`domain namespace "${resolved}" is not present on the contract`);
44
37
  return domainNamespace.models;
45
38
  }
46
- /**
47
- * Value objects for the contract's single domain namespace, when present.
48
- * Throws when the contract does not declare exactly one namespace.
49
- */
50
- function domainValueObjectsAtDefaultNamespace(domain) {
51
- return domain.namespaces[soleDomainNamespaceId(domain)]?.valueObjects;
39
+ function contractValueObjects(contract, namespaceId) {
40
+ const resolved = resolveSingleDomainNamespaceId(contract.domain, namespaceId);
41
+ const domainNamespace = contract.domain.namespaces[resolved];
42
+ if (domainNamespace === void 0) throw new DomainNamespaceResolutionError(`domain namespace "${resolved}" is not present on the contract`);
43
+ return domainNamespace.valueObjects;
52
44
  }
53
45
  //#endregion
54
46
  //#region src/types.ts
@@ -94,6 +86,6 @@ function isExecutionMutationDefaultValue(value) {
94
86
  return true;
95
87
  }
96
88
  //#endregion
97
- export { CrossReferenceSchema, DomainNamespaceResolutionError, UNBOUND_DOMAIN_NAMESPACE_ID, asNamespaceId, coreHash, crossRef, domainModelsAtDefaultNamespace, domainValueObjectsAtDefaultNamespace, effectiveControlPolicy, executionHash, isColumnDefault, isColumnDefaultLiteralInputValue, isExecutionMutationDefaultValue, profileHash, resolveDomainModel, soleDomainNamespaceId };
89
+ export { CrossReferenceSchema, DomainNamespaceResolutionError, UNBOUND_DOMAIN_NAMESPACE_ID, asNamespaceId, contractModels, contractValueObjects, coreHash, crossRef, executionHash, isColumnDefault, isColumnDefaultLiteralInputValue, isExecutionMutationDefaultValue, profileHash, resolveSingleDomainNamespaceId };
98
90
 
99
91
  //# sourceMappingURL=types.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.mjs","names":[],"sources":["../src/control-policy.ts","../src/cross-reference.ts","../src/domain-namespace-access.ts","../src/types.ts"],"sourcesContent":["/**\n * Governance posture for a storage-plane node or for the contract as a whole.\n *\n * - `managed` — Prisma Next owns the full lifecycle (DDL, migrations, verification).\n * - `tolerated` — node was found in the database but is not schema-managed; Prisma Next\n * leaves it untouched while tracking its existence.\n * - `external` — node is owned by an external system; Prisma Next never emits DDL for it.\n * - `observed` — read-only access; Prisma Next does not write to or migrate the node.\n */\nexport type ControlPolicy = 'managed' | 'tolerated' | 'external' | 'observed';\n\n/**\n * Resolves the effective control policy for a storage-plane node.\n *\n * Precedence: node-level value → contract default → `'managed'`.\n *\n * Both parameters are optional raw values so this function stays node-type-agnostic\n * and can be called by any consumer (verifier, planner, etc.) without importing IR classes.\n */\nexport function effectiveControlPolicy(\n nodeControl: ControlPolicy | undefined,\n defaultControl: ControlPolicy | undefined,\n): ControlPolicy {\n return nodeControl ?? defaultControl ?? 'managed';\n}\n","import { blindCast } from '@prisma-next/utils/casts';\nimport { type Type, type } from 'arktype';\nimport { asNamespaceId, type NamespaceId } from './namespace-id';\n\nexport interface CrossReference {\n readonly namespace: NamespaceId;\n readonly model: string;\n}\n\nexport const CrossReferenceSchema = /* @__PURE__ */ blindCast<\n Type<CrossReference>,\n 'namespace is validated as string at runtime and branded to NamespaceId by asNamespaceId in crossRef(); the schema accepts plain strings but the public type reflects the branded shape'\n>(\n /* @__PURE__ */ type({\n '+': 'reject',\n namespace: 'string',\n model: 'string',\n }),\n);\n\nconst DEFAULT_CROSS_REF_NAMESPACE = '__unbound__';\n\nexport function crossRef(\n model: string,\n namespace: string = DEFAULT_CROSS_REF_NAMESPACE,\n): CrossReference {\n return { namespace: asNamespaceId(namespace), model };\n}\n","import { DomainNamespaceResolutionError } from './contract-validation-error';\nimport { soleDomainNamespaceId } from './default-namespace';\nimport type { ApplicationDomain } from './domain-envelope';\nimport type { ContractModelBase, ContractValueObject } from './domain-types';\n\n/**\n * Models map for the contract's single domain namespace. Throws when the\n * contract does not declare exactly one namespace — bare-name access is\n * ambiguous across namespaces and must be qualified explicitly (TML-2550).\n */\nexport function domainModelsAtDefaultNamespace<TModels extends Record<string, ContractModelBase>>(\n domain: ApplicationDomain<TModels>,\n): TModels {\n const namespaceId = soleDomainNamespaceId(domain);\n const domainNamespace = domain.namespaces[namespaceId];\n if (domainNamespace === undefined) {\n throw new DomainNamespaceResolutionError(\n `domain namespace \"${namespaceId}\" is not present on the contract`,\n );\n }\n return domainNamespace.models;\n}\n\n/**\n * Value objects for the contract's single domain namespace, when present.\n * Throws when the contract does not declare exactly one namespace.\n */\nexport function domainValueObjectsAtDefaultNamespace<\n TModels extends Record<string, ContractModelBase>,\n>(domain: ApplicationDomain<TModels>): Record<string, ContractValueObject> | undefined {\n return domain.namespaces[soleDomainNamespaceId(domain)]?.valueObjects;\n}\n","/**\n * Unique symbol used as the key for branding types.\n */\nexport const $: unique symbol = Symbol('__prisma_next_brand__');\n\n/**\n * A helper type to brand a given type with a unique identifier.\n *\n * @template TKey Text used as the brand key.\n * @template TValue Optional value associated with the brand key. Defaults to `true`.\n */\nexport type Brand<TKey extends string | number | symbol, TValue = true> = {\n [$]: {\n [K in TKey]: TValue;\n };\n};\n\n/**\n * Base type for storage contract hashes.\n * Emitted contract.d.ts files use this with the hash value as a type parameter:\n * `type StorageHash = StorageHashBase<'sha256:abc123...'>`\n */\nexport type StorageHashBase<THash extends string> = THash & Brand<'StorageHash'>;\n\n/**\n * Base type for execution contract hashes.\n * Emitted contract.d.ts files use this with the hash value as a type parameter:\n * `type ExecutionHash = ExecutionHashBase<'sha256:def456...'>`\n */\nexport type ExecutionHashBase<THash extends string> = THash & Brand<'ExecutionHash'>;\n\nexport function executionHash<const T extends string>(value: T): ExecutionHashBase<T> {\n return value as ExecutionHashBase<T>;\n}\n\nexport function coreHash<const T extends string>(value: T): StorageHashBase<T> {\n return value as StorageHashBase<T>;\n}\n\n/**\n * Base type for profile contract hashes.\n * Emitted contract.d.ts files use this with the hash value as a type parameter:\n * `type ProfileHash = ProfileHashBase<'sha256:def456...'>`\n */\nexport type ProfileHashBase<THash extends string> = THash & Brand<'ProfileHash'>;\n\nexport function profileHash<const T extends string>(value: T): ProfileHashBase<T> {\n return value as ProfileHashBase<T>;\n}\n\n/**\n * One entity-kind slot in a namespace — a map of entity name to entry.\n * Values are opaque at the foundation layer; family and target concretions\n * refine them to typed IR classes.\n */\nexport type StorageEntitySlot = Readonly<Record<string, unknown>>;\n\n/**\n * Plain-data namespace entry in a storage block. Every hydrated contract\n * carries at least `id` plus zero or more entity-kind slot maps (`tables`,\n * `collections`, …). Foundation declares only this shape — no IR machinery.\n */\nexport interface StorageNamespace {\n readonly id: string;\n}\n\n/**\n * Base type for family-specific storage blocks.\n * Family storage types (SqlStorage, MongoStorage, etc.) extend this to carry the\n * storage hash alongside family-specific data (tables, collections, etc.).\n *\n * The `namespaces` map is carried by every hydrated storage block. Serialized\n * envelope shape is target-owned; this types the in-memory contract after\n * `deserializeContract`.\n */\nexport interface StorageBase<THash extends string = string> {\n readonly storageHash: StorageHashBase<THash>;\n readonly namespaces: Readonly<Record<string, StorageNamespace>>;\n}\n\nexport interface FieldType {\n readonly type: string;\n readonly nullable: boolean;\n readonly items?: FieldType;\n readonly properties?: Record<string, FieldType>;\n}\n\nexport type GeneratedValueSpec = {\n readonly id: string;\n readonly params?: Record<string, unknown>;\n};\n\nexport type JsonPrimitive = string | number | boolean | null;\n\nexport type JsonValue =\n | JsonPrimitive\n | { readonly [key: string]: JsonValue }\n | readonly JsonValue[];\n\nexport type ColumnDefaultLiteralValue = JsonValue;\n\nexport type ColumnDefaultLiteralInputValue = ColumnDefaultLiteralValue | Date;\n\n/**\n * Runtime predicate for `ColumnDefaultLiteralInputValue`. Authoring layers\n * resolve template values from caller-supplied args (typed `unknown` at the\n * boundary) and need to validate before constructing a `ColumnDefault`.\n * Accepts JSON primitives, plain arrays/objects of JSON values, and `Date`\n * instances. Rejects functions, class instances (other than `Date`),\n * `undefined`, `bigint`, `symbol`, and arrays/objects containing those.\n */\nexport function isColumnDefaultLiteralInputValue(\n value: unknown,\n): value is ColumnDefaultLiteralInputValue {\n if (value === null) return true;\n const t = typeof value;\n if (t === 'string' || t === 'number' || t === 'boolean') return true;\n if (value instanceof Date) return true;\n if (Array.isArray(value)) return value.every(isColumnDefaultLiteralInputValue);\n if (t === 'object' && Object.getPrototypeOf(value) === Object.prototype) {\n return Object.values(value as Record<string, unknown>).every(isColumnDefaultLiteralInputValue);\n }\n return false;\n}\n\nexport type ColumnDefault =\n | {\n readonly kind: 'literal';\n readonly value: ColumnDefaultLiteralInputValue;\n }\n | { readonly kind: 'function'; readonly expression: string };\n\nexport function isColumnDefault(value: unknown): value is ColumnDefault {\n if (typeof value !== 'object' || value === null) return false;\n const kind = (value as { kind?: unknown }).kind;\n if (kind === 'literal') {\n return 'value' in value;\n }\n if (kind === 'function') {\n return typeof (value as { expression?: unknown }).expression === 'string';\n }\n return false;\n}\n\nexport type ExecutionMutationDefaultValue = {\n readonly kind: 'generator';\n readonly id: GeneratedValueSpec['id'];\n readonly params?: Record<string, unknown>;\n};\n\nexport function isExecutionMutationDefaultValue(\n value: unknown,\n): value is ExecutionMutationDefaultValue {\n if (typeof value !== 'object' || value === null) return false;\n const candidate = value as {\n kind?: unknown;\n id?: unknown;\n params?: unknown;\n };\n if (candidate.kind !== 'generator') return false;\n if (typeof candidate.id !== 'string') return false;\n if (\n candidate.params !== undefined &&\n (typeof candidate.params !== 'object' ||\n candidate.params === null ||\n Array.isArray(candidate.params))\n ) {\n return false;\n }\n return true;\n}\n\nexport type ExecutionMutationDefault = {\n readonly ref: { readonly table: string; readonly column: string };\n readonly onCreate?: ExecutionMutationDefaultValue;\n readonly onUpdate?: ExecutionMutationDefaultValue;\n};\n\n/**\n * `ExecutionMutationDefault` minus its `ref` — the per-field phases value\n * authoring layers attach to a column before the column ref is known.\n */\nexport type ExecutionMutationDefaultPhases = Omit<ExecutionMutationDefault, 'ref'>;\n\nexport type ExecutionSection<THash extends string = string> = {\n readonly executionHash: ExecutionHashBase<THash>;\n readonly mutations: {\n readonly defaults: ReadonlyArray<ExecutionMutationDefault>;\n };\n};\n\nexport interface Source {\n readonly readOnly: boolean;\n readonly projection: Record<string, FieldType>;\n readonly origin?: Record<string, unknown>;\n readonly capabilities?: Record<string, boolean>;\n}\n\n// Document family types\nexport interface DocIndex {\n readonly name: string;\n readonly keys: Record<string, 'asc' | 'desc'>;\n readonly unique?: boolean;\n readonly where?: Expr;\n}\n\nexport type Expr =\n | { readonly kind: 'eq'; readonly path: ReadonlyArray<string>; readonly value: unknown }\n | { readonly kind: 'exists'; readonly path: ReadonlyArray<string> };\n\nexport interface DocCollection {\n readonly name: string;\n readonly id?: {\n readonly strategy: 'auto' | 'client' | 'uuid' | 'objectId';\n };\n readonly fields: Record<string, FieldType>;\n readonly indexes?: ReadonlyArray<DocIndex>;\n readonly readOnly?: boolean;\n}\n\nexport interface PlanMeta {\n readonly target: string;\n readonly targetFamily?: string;\n readonly storageHash: string;\n readonly profileHash?: string;\n readonly lane: string;\n readonly annotations?: {\n readonly [key: string]: unknown;\n };\n}\n\n/**\n * Contract marker record stored in the database.\n * Represents the current contract identity for a database.\n */\nexport interface ContractMarkerRecord {\n readonly storageHash: string;\n readonly profileHash: string;\n readonly contractJson: unknown | null;\n readonly canonicalVersion: number | null;\n readonly updatedAt: Date;\n readonly appTag: string | null;\n readonly meta: Record<string, unknown>;\n readonly invariants: readonly string[];\n}\n\n/**\n * One applied migration edge from the per-space ledger journal.\n * Returned by `readLedger` in append (apply) order.\n */\nexport interface LedgerEntryRecord {\n readonly space: string;\n readonly migrationName: string;\n readonly migrationHash: string;\n readonly from: string | null;\n readonly to: string;\n readonly appliedAt: Date;\n readonly operationCount: number;\n}\n"],"mappings":";;;;;;;;;;;;;;;AAmBA,SAAgB,uBACd,aACA,gBACe;CACf,OAAO,eAAe,kBAAkB;AAC1C;;;ACfA,MAAa,uBAAuC,0BAIlC,qBAAK;CACnB,KAAK;CACL,WAAW;CACX,OAAO;AACT,CAAC,CACH;AAEA,MAAM,8BAA8B;AAEpC,SAAgB,SACd,OACA,YAAoB,6BACJ;CAChB,OAAO;EAAE,WAAW,cAAc,SAAS;EAAG;CAAM;AACtD;;;;;;;;ACjBA,SAAgB,+BACd,QACS;CACT,MAAM,cAAc,sBAAsB,MAAM;CAChD,MAAM,kBAAkB,OAAO,WAAW;CAC1C,IAAI,oBAAoB,KAAA,GACtB,MAAM,IAAI,+BACR,qBAAqB,YAAY,iCACnC;CAEF,OAAO,gBAAgB;AACzB;;;;;AAMA,SAAgB,qCAEd,QAAqF;CACrF,OAAO,OAAO,WAAW,sBAAsB,MAAM,IAAI;AAC3D;;;ACAA,SAAgB,cAAsC,OAAgC;CACpF,OAAO;AACT;AAEA,SAAgB,SAAiC,OAA8B;CAC7E,OAAO;AACT;AASA,SAAgB,YAAoC,OAA8B;CAChF,OAAO;AACT;;;;;;;;;AA+DA,SAAgB,iCACd,OACyC;CACzC,IAAI,UAAU,MAAM,OAAO;CAC3B,MAAM,IAAI,OAAO;CACjB,IAAI,MAAM,YAAY,MAAM,YAAY,MAAM,WAAW,OAAO;CAChE,IAAI,iBAAiB,MAAM,OAAO;CAClC,IAAI,MAAM,QAAQ,KAAK,GAAG,OAAO,MAAM,MAAM,gCAAgC;CAC7E,IAAI,MAAM,YAAY,OAAO,eAAe,KAAK,MAAM,OAAO,WAC5D,OAAO,OAAO,OAAO,KAAgC,EAAE,MAAM,gCAAgC;CAE/F,OAAO;AACT;AASA,SAAgB,gBAAgB,OAAwC;CACtE,IAAI,OAAO,UAAU,YAAY,UAAU,MAAM,OAAO;CACxD,MAAM,OAAQ,MAA6B;CAC3C,IAAI,SAAS,WACX,OAAO,WAAW;CAEpB,IAAI,SAAS,YACX,OAAO,OAAQ,MAAmC,eAAe;CAEnE,OAAO;AACT;AAQA,SAAgB,gCACd,OACwC;CACxC,IAAI,OAAO,UAAU,YAAY,UAAU,MAAM,OAAO;CACxD,MAAM,YAAY;CAKlB,IAAI,UAAU,SAAS,aAAa,OAAO;CAC3C,IAAI,OAAO,UAAU,OAAO,UAAU,OAAO;CAC7C,IACE,UAAU,WAAW,KAAA,MACpB,OAAO,UAAU,WAAW,YAC3B,UAAU,WAAW,QACrB,MAAM,QAAQ,UAAU,MAAM,IAEhC,OAAO;CAET,OAAO;AACT"}
1
+ {"version":3,"file":"types.mjs","names":[],"sources":["../src/cross-reference.ts","../src/domain-envelope.ts","../src/types.ts"],"sourcesContent":["import { blindCast } from '@prisma-next/utils/casts';\nimport { type Type, type } from 'arktype';\nimport { asNamespaceId, type NamespaceId } from './namespace-id';\n\nexport interface CrossReference {\n readonly namespace: NamespaceId;\n readonly model: string;\n}\n\nexport const CrossReferenceSchema = /* @__PURE__ */ blindCast<\n Type<CrossReference>,\n 'namespace is validated as string at runtime and branded to NamespaceId by asNamespaceId in crossRef(); the schema accepts plain strings but the public type reflects the branded shape'\n>(\n /* @__PURE__ */ type({\n '+': 'reject',\n namespace: 'string',\n model: 'string',\n }),\n);\n\nconst DEFAULT_CROSS_REF_NAMESPACE = '__unbound__';\n\nexport function crossRef(\n model: string,\n namespace: string = DEFAULT_CROSS_REF_NAMESPACE,\n): CrossReference {\n return { namespace: asNamespaceId(namespace), model };\n}\n","import { DomainNamespaceResolutionError } from './contract-validation-error';\nimport type { ContractModelBase, ContractValueObject } from './domain-types';\n\nexport const UNBOUND_DOMAIN_NAMESPACE_ID = '__unbound__' as const;\n\n/**\n * One namespace's application-domain entities — models and optional value\n * objects keyed by entity name within that namespace coordinate.\n */\nexport interface ApplicationDomainNamespace<\n TModels extends Record<string, ContractModelBase> = Record<string, ContractModelBase>,\n> {\n readonly models: TModels;\n readonly valueObjects?: Record<string, ContractValueObject>;\n}\n\n/**\n * Application-domain envelope: entity content keyed by namespace id.\n * Mirrors the storage plane's `namespaces` segment (ADR 221).\n */\nexport interface ApplicationDomain<\n TModels extends Record<string, ContractModelBase> = Record<string, ContractModelBase>,\n> {\n readonly namespaces: Readonly<Record<string, ApplicationDomainNamespace<TModels>>>;\n}\n\nexport type ContractWithDomain = {\n readonly domain: ApplicationDomain;\n};\n\nexport function resolveSingleDomainNamespaceId(\n domain: ApplicationDomain,\n namespaceId?: string,\n): string {\n if (namespaceId !== undefined) {\n if (!Object.hasOwn(domain.namespaces, namespaceId)) {\n throw new DomainNamespaceResolutionError(\n `domain namespace \"${namespaceId}\" is not present on the contract`,\n );\n }\n return namespaceId;\n }\n\n const namespaceIds = Object.keys(domain.namespaces);\n if (namespaceIds.length === 0) {\n throw new DomainNamespaceResolutionError('domain has no namespaces');\n }\n if (namespaceIds.length > 1) {\n throw new DomainNamespaceResolutionError(\n `expected exactly one domain namespace, found ${namespaceIds.length} (${namespaceIds.join(', ')})`,\n );\n }\n const [soleNamespaceId] = namespaceIds;\n if (soleNamespaceId === undefined) {\n throw new DomainNamespaceResolutionError('domain has no namespaces');\n }\n return soleNamespaceId;\n}\n\n// Transitional single-namespace projection; pending runtime-qualification slice.\nexport function contractModels<TModels extends Record<string, ContractModelBase>>(\n contract: { readonly domain: ApplicationDomain<TModels> },\n namespaceId?: string,\n): TModels {\n const resolved = resolveSingleDomainNamespaceId(contract.domain, namespaceId);\n const domainNamespace = contract.domain.namespaces[resolved];\n if (domainNamespace === undefined) {\n throw new DomainNamespaceResolutionError(\n `domain namespace \"${resolved}\" is not present on the contract`,\n );\n }\n return domainNamespace.models;\n}\n\nexport function contractValueObjects<TModels extends Record<string, ContractModelBase>>(\n contract: { readonly domain: ApplicationDomain<TModels> },\n namespaceId?: string,\n): Record<string, ContractValueObject> | undefined {\n const resolved = resolveSingleDomainNamespaceId(contract.domain, namespaceId);\n const domainNamespace = contract.domain.namespaces[resolved];\n if (domainNamespace === undefined) {\n throw new DomainNamespaceResolutionError(\n `domain namespace \"${resolved}\" is not present on the contract`,\n );\n }\n return domainNamespace.valueObjects;\n}\n","/**\n * Unique symbol used as the key for branding types.\n */\nexport const $: unique symbol = Symbol('__prisma_next_brand__');\n\n/**\n * A helper type to brand a given type with a unique identifier.\n *\n * @template TKey Text used as the brand key.\n * @template TValue Optional value associated with the brand key. Defaults to `true`.\n */\nexport type Brand<TKey extends string | number | symbol, TValue = true> = {\n [$]: {\n [K in TKey]: TValue;\n };\n};\n\n/**\n * Base type for storage contract hashes.\n * Emitted contract.d.ts files use this with the hash value as a type parameter:\n * `type StorageHash = StorageHashBase<'sha256:abc123...'>`\n */\nexport type StorageHashBase<THash extends string> = THash & Brand<'StorageHash'>;\n\n/**\n * Base type for execution contract hashes.\n * Emitted contract.d.ts files use this with the hash value as a type parameter:\n * `type ExecutionHash = ExecutionHashBase<'sha256:def456...'>`\n */\nexport type ExecutionHashBase<THash extends string> = THash & Brand<'ExecutionHash'>;\n\nexport function executionHash<const T extends string>(value: T): ExecutionHashBase<T> {\n return value as ExecutionHashBase<T>;\n}\n\nexport function coreHash<const T extends string>(value: T): StorageHashBase<T> {\n return value as StorageHashBase<T>;\n}\n\n/**\n * Base type for profile contract hashes.\n * Emitted contract.d.ts files use this with the hash value as a type parameter:\n * `type ProfileHash = ProfileHashBase<'sha256:def456...'>`\n */\nexport type ProfileHashBase<THash extends string> = THash & Brand<'ProfileHash'>;\n\nexport function profileHash<const T extends string>(value: T): ProfileHashBase<T> {\n return value as ProfileHashBase<T>;\n}\n\n/**\n * One entity-kind slot in a namespace — a map of entity name to entry.\n * Values are opaque at the foundation layer; family and target concretions\n * refine them to typed IR classes.\n */\nexport type StorageEntitySlot = Readonly<Record<string, unknown>>;\n\n/**\n * Plain-data namespace entry in a storage block. Every hydrated contract\n * carries at least `id` plus zero or more entity-kind slot maps (`tables`,\n * `collections`, …). Foundation declares only this shape — no IR machinery.\n */\nexport interface StorageNamespace {\n readonly id: string;\n}\n\n/**\n * Base type for family-specific storage blocks.\n * Family storage types (SqlStorage, MongoStorage, etc.) extend this to carry the\n * storage hash alongside family-specific data (tables, collections, etc.).\n *\n * The `namespaces` map is carried by every hydrated storage block. Serialized\n * envelope shape is target-owned; this types the in-memory contract after\n * `deserializeContract`.\n */\nexport interface StorageBase<THash extends string = string> {\n readonly storageHash: StorageHashBase<THash>;\n readonly namespaces: Readonly<Record<string, StorageNamespace>>;\n}\n\nexport interface FieldType {\n readonly type: string;\n readonly nullable: boolean;\n readonly items?: FieldType;\n readonly properties?: Record<string, FieldType>;\n}\n\nexport type GeneratedValueSpec = {\n readonly id: string;\n readonly params?: Record<string, unknown>;\n};\n\nexport type JsonPrimitive = string | number | boolean | null;\n\nexport type JsonValue =\n | JsonPrimitive\n | { readonly [key: string]: JsonValue }\n | readonly JsonValue[];\n\nexport type ColumnDefaultLiteralValue = JsonValue;\n\nexport type ColumnDefaultLiteralInputValue = ColumnDefaultLiteralValue | Date;\n\n/**\n * Runtime predicate for `ColumnDefaultLiteralInputValue`. Authoring layers\n * resolve template values from caller-supplied args (typed `unknown` at the\n * boundary) and need to validate before constructing a `ColumnDefault`.\n * Accepts JSON primitives, plain arrays/objects of JSON values, and `Date`\n * instances. Rejects functions, class instances (other than `Date`),\n * `undefined`, `bigint`, `symbol`, and arrays/objects containing those.\n */\nexport function isColumnDefaultLiteralInputValue(\n value: unknown,\n): value is ColumnDefaultLiteralInputValue {\n if (value === null) return true;\n const t = typeof value;\n if (t === 'string' || t === 'number' || t === 'boolean') return true;\n if (value instanceof Date) return true;\n if (Array.isArray(value)) return value.every(isColumnDefaultLiteralInputValue);\n if (t === 'object' && Object.getPrototypeOf(value) === Object.prototype) {\n return Object.values(value as Record<string, unknown>).every(isColumnDefaultLiteralInputValue);\n }\n return false;\n}\n\nexport type ColumnDefault =\n | {\n readonly kind: 'literal';\n readonly value: ColumnDefaultLiteralInputValue;\n }\n | { readonly kind: 'function'; readonly expression: string };\n\nexport function isColumnDefault(value: unknown): value is ColumnDefault {\n if (typeof value !== 'object' || value === null) return false;\n const kind = (value as { kind?: unknown }).kind;\n if (kind === 'literal') {\n return 'value' in value;\n }\n if (kind === 'function') {\n return typeof (value as { expression?: unknown }).expression === 'string';\n }\n return false;\n}\n\nexport type ExecutionMutationDefaultValue = {\n readonly kind: 'generator';\n readonly id: GeneratedValueSpec['id'];\n readonly params?: Record<string, unknown>;\n};\n\nexport function isExecutionMutationDefaultValue(\n value: unknown,\n): value is ExecutionMutationDefaultValue {\n if (typeof value !== 'object' || value === null) return false;\n const candidate = value as {\n kind?: unknown;\n id?: unknown;\n params?: unknown;\n };\n if (candidate.kind !== 'generator') return false;\n if (typeof candidate.id !== 'string') return false;\n if (\n candidate.params !== undefined &&\n (typeof candidate.params !== 'object' ||\n candidate.params === null ||\n Array.isArray(candidate.params))\n ) {\n return false;\n }\n return true;\n}\n\nexport type ExecutionMutationDefault = {\n readonly ref: { readonly table: string; readonly column: string };\n readonly onCreate?: ExecutionMutationDefaultValue;\n readonly onUpdate?: ExecutionMutationDefaultValue;\n};\n\n/**\n * `ExecutionMutationDefault` minus its `ref` — the per-field phases value\n * authoring layers attach to a column before the column ref is known.\n */\nexport type ExecutionMutationDefaultPhases = Omit<ExecutionMutationDefault, 'ref'>;\n\nexport type ExecutionSection<THash extends string = string> = {\n readonly executionHash: ExecutionHashBase<THash>;\n readonly mutations: {\n readonly defaults: ReadonlyArray<ExecutionMutationDefault>;\n };\n};\n\nexport interface Source {\n readonly readOnly: boolean;\n readonly projection: Record<string, FieldType>;\n readonly origin?: Record<string, unknown>;\n readonly capabilities?: Record<string, boolean>;\n}\n\n// Document family types\nexport interface DocIndex {\n readonly name: string;\n readonly keys: Record<string, 'asc' | 'desc'>;\n readonly unique?: boolean;\n readonly where?: Expr;\n}\n\nexport type Expr =\n | { readonly kind: 'eq'; readonly path: ReadonlyArray<string>; readonly value: unknown }\n | { readonly kind: 'exists'; readonly path: ReadonlyArray<string> };\n\nexport interface DocCollection {\n readonly name: string;\n readonly id?: {\n readonly strategy: 'auto' | 'client' | 'uuid' | 'objectId';\n };\n readonly fields: Record<string, FieldType>;\n readonly indexes?: ReadonlyArray<DocIndex>;\n readonly readOnly?: boolean;\n}\n\nexport interface PlanMeta {\n readonly target: string;\n readonly targetFamily?: string;\n readonly storageHash: string;\n readonly profileHash?: string;\n readonly lane: string;\n readonly annotations?: {\n readonly [key: string]: unknown;\n };\n}\n\n/**\n * Contract marker record stored in the database.\n * Represents the current contract identity for a database.\n */\nexport interface ContractMarkerRecord {\n readonly storageHash: string;\n readonly profileHash: string;\n readonly contractJson: unknown | null;\n readonly canonicalVersion: number | null;\n readonly updatedAt: Date;\n readonly appTag: string | null;\n readonly meta: Record<string, unknown>;\n readonly invariants: readonly string[];\n}\n"],"mappings":";;;;;AASA,MAAa,uBAAuC,0BAIlC,qBAAK;CACnB,KAAK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;;;;AA+DA,SAAgB,iCACd,OACyC;CACzC,IAAI,UAAU,MAAM,OAAO;CAC3B,MAAM,IAAI,OAAO;CACjB,IAAI,MAAM,YAAY,MAAM,YAAY,MAAM,WAAW,OAAO;CAChE,IAAI,iBAAiB,MAAM,OAAO;CAClC,IAAI,MAAM,QAAQ,KAAK,GAAG,OAAO,MAAM,MAAM,gCAAgC;CAC7E,IAAI,MAAM,YAAY,OAAO,eAAe,KAAK,MAAM,OAAO,WAC5D,OAAO,OAAO,OAAO,KAAgC,EAAE,MAAM,gCAAgC;CAE/F,OAAO;AACT;AASA,SAAgB,gBAAgB,OAAwC;CACtE,IAAI,OAAO,UAAU,YAAY,UAAU,MAAM,OAAO;CACxD,MAAM,OAAQ,MAA6B;CAC3C,IAAI,SAAS,WACX,OAAO,WAAW;CAEpB,IAAI,SAAS,YACX,OAAO,OAAQ,MAAmC,eAAe;CAEnE,OAAO;AACT;AAQA,SAAgB,gCACd,OACwC;CACxC,IAAI,OAAO,UAAU,YAAY,UAAU,MAAM,OAAO;CACxD,MAAM,YAAY;CAKlB,IAAI,UAAU,SAAS,aAAa,OAAO;CAC3C,IAAI,OAAO,UAAU,OAAO,UAAU,OAAO;CAC7C,IACE,UAAU,WAAW,KAAA,MACpB,OAAO,UAAU,WAAW,YAC3B,UAAU,WAAW,QACrB,MAAM,QAAQ,UAAU,MAAM,IAEhC,OAAO;CAET,OAAO;AACT"}
@@ -1,4 +1,4 @@
1
- import { r as ContractWithDomain, x as CrossReference } from "./domain-envelope-Bq5uPLLm.mjs";
1
+ import { T as CrossReference, r as ContractWithDomain } from "./domain-envelope-4hyFtJ4_.mjs";
2
2
 
3
3
  //#region src/validate-domain.d.ts
4
4
  interface DomainModelShape {
@@ -1,5 +1,5 @@
1
1
  import { t as ContractValidationError } from "./contract-validation-error-ClZaKqMW.mjs";
2
- import { t as asNamespaceId } from "./namespace-id-BSCer2Vd.mjs";
2
+ import { t as asNamespaceId } from "./namespace-id-CVpkSFUK.mjs";
3
3
  //#region src/validate-domain.ts
4
4
  function indexDomainModels(contract) {
5
5
  const index = /* @__PURE__ */ new Map();
package/package.json CHANGED
@@ -1,18 +1,18 @@
1
1
  {
2
2
  "name": "@prisma-next/contract",
3
- "version": "0.12.0-dev.16",
3
+ "version": "0.12.0-dev.2",
4
4
  "license": "Apache-2.0",
5
5
  "type": "module",
6
6
  "sideEffects": false,
7
7
  "description": "Data contract type definitions and JSON schema for Prisma Next",
8
8
  "dependencies": {
9
- "@prisma-next/utils": "0.12.0-dev.16",
9
+ "@prisma-next/utils": "0.12.0-dev.2",
10
10
  "@standard-schema/spec": "^1.1.0",
11
11
  "arktype": "^2.2.0"
12
12
  },
13
13
  "devDependencies": {
14
- "@prisma-next/tsconfig": "0.12.0-dev.16",
15
- "@prisma-next/tsdown": "0.12.0-dev.16",
14
+ "@prisma-next/tsconfig": "0.12.0-dev.2",
15
+ "@prisma-next/tsdown": "0.12.0-dev.2",
16
16
  "tsdown": "0.22.0",
17
17
  "typescript": "5.9.3",
18
18
  "vitest": "4.1.6"
@@ -32,10 +32,8 @@
32
32
  ],
33
33
  "exports": {
34
34
  "./contract-validation-error": "./dist/contract-validation-error.mjs",
35
- "./default-namespace": "./dist/default-namespace.mjs",
36
35
  "./hashing": "./dist/hashing.mjs",
37
36
  "./hashing-utils": "./dist/hashing-utils.mjs",
38
- "./resolve-domain-model": "./dist/resolve-domain-model.mjs",
39
37
  "./types": "./dist/types.mjs",
40
38
  "./validate-domain": "./dist/validate-domain.mjs",
41
39
  "./package.json": "./package.json"
@@ -1,4 +1,3 @@
1
- import type { ControlPolicy } from './control-policy';
2
1
  import type { CrossReference } from './cross-reference';
3
2
  import type { ApplicationDomain } from './domain-envelope';
4
3
  import type { ContractModelBase, ContractValueObject } from './domain-types';
@@ -58,15 +57,12 @@ export interface Contract<
58
57
  readonly execution?: ContractExecutionSection;
59
58
  readonly profileHash: ProfileHashBase<string>;
60
59
  readonly meta: Record<string, unknown>;
61
- readonly defaultControl?: ControlPolicy;
62
60
  }
63
61
 
64
- /** Model definitions union carried on a {@link Contract}'s `TModels` type parameter. */
65
- export type ContractModelDefinitions<TContract extends Contract> =
62
+ export type ContractModelsMap<TContract extends Contract> =
66
63
  TContract extends Contract<StorageBase, infer TModels> ? TModels : never;
67
64
 
68
- type ExactlyOneNamespace<T extends Record<string, unknown>> = keyof T extends infer Only extends
69
- keyof T
65
+ type ExactlyOneKey<T extends Record<string, unknown>> = keyof T extends infer Only extends keyof T
70
66
  ? [keyof T] extends [Only]
71
67
  ? Only
72
68
  : never
@@ -80,10 +76,10 @@ type NamespaceValueObjectsOf<TNamespace> = TNamespace extends {
80
76
  : Record<never, never>
81
77
  : Record<never, never>;
82
78
 
83
- /** Value-object map when the contract declares exactly one domain namespace. */
84
- export type ContractValueObjectDefinitions<TContract extends Contract> =
79
+ /** Value-object map for the contract's sole domain namespace (type-level single-namespace projection). */
80
+ export type ContractValueObjectsMap<TContract extends Contract> =
85
81
  NamespaceValueObjectsOf<
86
- TContract['domain']['namespaces'][ExactlyOneNamespace<TContract['domain']['namespaces']>]
82
+ TContract['domain']['namespaces'][ExactlyOneKey<TContract['domain']['namespaces']>]
87
83
  > extends infer Projected
88
84
  ? Projected extends Record<string, ContractValueObject>
89
85
  ? Projected
@@ -1,6 +1,7 @@
1
+ import { DomainNamespaceResolutionError } from './contract-validation-error';
1
2
  import type { ContractModelBase, ContractValueObject } from './domain-types';
2
3
 
3
- export { UNBOUND_DOMAIN_NAMESPACE_ID } from './default-namespace';
4
+ export const UNBOUND_DOMAIN_NAMESPACE_ID = '__unbound__' as const;
4
5
 
5
6
  /**
6
7
  * One namespace's application-domain entities — models and optional value
@@ -26,3 +27,61 @@ export interface ApplicationDomain<
26
27
  export type ContractWithDomain = {
27
28
  readonly domain: ApplicationDomain;
28
29
  };
30
+
31
+ export function resolveSingleDomainNamespaceId(
32
+ domain: ApplicationDomain,
33
+ namespaceId?: string,
34
+ ): string {
35
+ if (namespaceId !== undefined) {
36
+ if (!Object.hasOwn(domain.namespaces, namespaceId)) {
37
+ throw new DomainNamespaceResolutionError(
38
+ `domain namespace "${namespaceId}" is not present on the contract`,
39
+ );
40
+ }
41
+ return namespaceId;
42
+ }
43
+
44
+ const namespaceIds = Object.keys(domain.namespaces);
45
+ if (namespaceIds.length === 0) {
46
+ throw new DomainNamespaceResolutionError('domain has no namespaces');
47
+ }
48
+ if (namespaceIds.length > 1) {
49
+ throw new DomainNamespaceResolutionError(
50
+ `expected exactly one domain namespace, found ${namespaceIds.length} (${namespaceIds.join(', ')})`,
51
+ );
52
+ }
53
+ const [soleNamespaceId] = namespaceIds;
54
+ if (soleNamespaceId === undefined) {
55
+ throw new DomainNamespaceResolutionError('domain has no namespaces');
56
+ }
57
+ return soleNamespaceId;
58
+ }
59
+
60
+ // Transitional single-namespace projection; pending runtime-qualification slice.
61
+ export function contractModels<TModels extends Record<string, ContractModelBase>>(
62
+ contract: { readonly domain: ApplicationDomain<TModels> },
63
+ namespaceId?: string,
64
+ ): TModels {
65
+ const resolved = resolveSingleDomainNamespaceId(contract.domain, namespaceId);
66
+ const domainNamespace = contract.domain.namespaces[resolved];
67
+ if (domainNamespace === undefined) {
68
+ throw new DomainNamespaceResolutionError(
69
+ `domain namespace "${resolved}" is not present on the contract`,
70
+ );
71
+ }
72
+ return domainNamespace.models;
73
+ }
74
+
75
+ export function contractValueObjects<TModels extends Record<string, ContractModelBase>>(
76
+ contract: { readonly domain: ApplicationDomain<TModels> },
77
+ namespaceId?: string,
78
+ ): Record<string, ContractValueObject> | undefined {
79
+ const resolved = resolveSingleDomainNamespaceId(contract.domain, namespaceId);
80
+ const domainNamespace = contract.domain.namespaces[resolved];
81
+ if (domainNamespace === undefined) {
82
+ throw new DomainNamespaceResolutionError(
83
+ `domain namespace "${resolved}" is not present on the contract`,
84
+ );
85
+ }
86
+ return domainNamespace.valueObjects;
87
+ }
@@ -1,25 +1,23 @@
1
1
  export type {
2
2
  Contract,
3
3
  ContractExecutionSection,
4
- ContractModelDefinitions,
5
- ContractValueObjectDefinitions,
4
+ ContractModelsMap,
5
+ ContractValueObjectsMap,
6
6
  } from '../contract-types';
7
7
  export { DomainNamespaceResolutionError } from '../contract-validation-error';
8
- export type { ControlPolicy } from '../control-policy';
9
- export { effectiveControlPolicy } from '../control-policy';
10
8
  export type { CrossReference } from '../cross-reference';
11
9
  export { CrossReferenceSchema, crossRef } from '../cross-reference';
12
- export { soleDomainNamespaceId } from '../default-namespace';
13
10
  export type {
14
11
  ApplicationDomain,
15
12
  ApplicationDomainNamespace,
16
13
  ContractWithDomain,
17
14
  } from '../domain-envelope';
18
- export { UNBOUND_DOMAIN_NAMESPACE_ID } from '../domain-envelope';
19
15
  export {
20
- domainModelsAtDefaultNamespace,
21
- domainValueObjectsAtDefaultNamespace,
22
- } from '../domain-namespace-access';
16
+ contractModels,
17
+ contractValueObjects,
18
+ resolveSingleDomainNamespaceId,
19
+ UNBOUND_DOMAIN_NAMESPACE_ID,
20
+ } from '../domain-envelope';
23
21
  export type {
24
22
  ContractDiscriminator,
25
23
  ContractEmbedRelation,
@@ -41,7 +39,6 @@ export type {
41
39
  } from '../domain-types';
42
40
  export type { NamespaceId } from '../namespace-id';
43
41
  export { asNamespaceId } from '../namespace-id';
44
- export { type ResolvedDomainModel, resolveDomainModel } from '../resolve-domain-model';
45
42
  export type {
46
43
  $,
47
44
  Brand,
@@ -61,7 +58,6 @@ export type {
61
58
  GeneratedValueSpec,
62
59
  JsonPrimitive,
63
60
  JsonValue,
64
- LedgerEntryRecord,
65
61
  PlanMeta,
66
62
  ProfileHashBase,
67
63
  Source,
package/src/types.ts CHANGED
@@ -243,17 +243,3 @@ export interface ContractMarkerRecord {
243
243
  readonly meta: Record<string, unknown>;
244
244
  readonly invariants: readonly string[];
245
245
  }
246
-
247
- /**
248
- * One applied migration edge from the per-space ledger journal.
249
- * Returned by `readLedger` in append (apply) order.
250
- */
251
- export interface LedgerEntryRecord {
252
- readonly space: string;
253
- readonly migrationName: string;
254
- readonly migrationHash: string;
255
- readonly from: string | null;
256
- readonly to: string;
257
- readonly appliedAt: Date;
258
- readonly operationCount: number;
259
- }
@@ -1 +0,0 @@
1
- {"version":3,"file":"contract-types-BYCjqnPw.d.mts","names":[],"sources":["../src/control-policy.ts","../src/types.ts","../src/contract-types.ts"],"mappings":";;;;;;AASA;;;;AAAyB;AAUzB;KAVY,aAAA;;;;;;;;;iBAUI,sBAAA,CACd,WAAA,EAAa,aAAA,cACb,cAAA,EAAgB,aAAA,eACf,aAAA;;;;;;cCnBU,CAAA;;;;ADMY;AAUzB;;KCRY,KAAA;EAAA,CACT,CAAA,WACO,IAAA,GAAO,MAAA;AAAA;;;;;;KASL,eAAA,yBAAwC,KAAA,GAAQ,KAAK;;ADAjD;;;;KCOJ,iBAAA,yBAA0C,KAAA,GAAQ,KAAK;AAAA,iBAEnD,aAAA,wBAAA,CAAsC,KAAA,EAAO,CAAA,GAAI,iBAAA,CAAkB,CAAA;AAAA,iBAInE,QAAA,wBAAA,CAAiC,KAAA,EAAO,CAAA,GAAI,eAAA,CAAgB,CAAA;;AAhCb;AAQ/D;;;KAiCY,eAAA,yBAAwC,KAAA,GAAQ,KAAK;AAAA,iBAEjD,WAAA,wBAAA,CAAoC,KAAA,EAAO,CAAA,GAAI,eAAA,CAAgB,CAAA;;;;;;KASnE,iBAAA,GAAoB,QAAQ,CAAC,MAAA;;;;;AA1ClB;UAiDN,gBAAA;EAAA,SACN,EAAE;AAAA;;;;;;AAzCoD;AAOjE;;;UA8CiB,WAAA;EAAA,SACN,WAAA,EAAa,eAAA,CAAgB,KAAA;EAAA,SAC7B,UAAA,EAAY,QAAA,CAAS,MAAA,SAAe,gBAAA;AAAA;AAAA,UAG9B,SAAA;EAAA,SACN,IAAA;EAAA,SACA,QAAA;EAAA,SACA,KAAA,GAAQ,SAAA;EAAA,SACR,UAAA,GAAa,MAAA,SAAe,SAAA;AAAA;AAAA,KAG3B,kBAAA;EAAA,SACD,EAAA;EAAA,SACA,MAAA,GAAS,MAAM;A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,OAAA,EAAS,QAAA;EAAA,SACT,YAAA,EAAc,MAAA,SAAe,MAAA;EAAA,SAC7B,cAAA,EAAgB,MAAA;EAAA,SAChB,SAAA,GAAY,wBAAA;EAAA,SACZ,WAAA,EAAa,eAAA;EAAA,SACb,IAAA,EAAM,MAAA;EAAA,SACN,cAAA,GAAiB,aAAA;AAAA;;KAIhB,wBAAA,mBAA2C,QAAA,IACrD,SAAA,SAAkB,QAAA,CAAS,WAAA,mBAA8B,OAAA;AAAA,KAEtD,mBAAA,WAA8B,MAAA,2BAAiC,CAAA,kCAC5D,CAAA,UACG,CAAA,WAAY,IAAA,IACjB,IAAA;AAAA,KAID,uBAAA,eAAsC,UAAA;EAAA,SAChC,YAAA;AAAA,IAEP,EAAA,SAAW,MAAA,SAAe,mBAAA,IACxB,EAAA,GACA,MAAA,iBACF,MAAA;;KAGQ,8BAAA,mBAAiD,QAAA,IAC3D,uBAAA,CACE,SAAA,yBAAkC,mBAAA,CAAoB,SAAA,sDAEpD,SAAA,SAAkB,MAAA,SAAe,mBAAA,IAC/B,SAAA,GACA,MAAA,iBACF,MAAA"}
@@ -1,33 +0,0 @@
1
- import { n as DomainNamespaceResolutionError } from "./contract-validation-error-ClZaKqMW.mjs";
2
- //#region src/default-namespace.ts
3
- /**
4
- * Reserved sentinel domain namespace id for the late-bound application-domain
5
- * slot — the namespace a model lands in when it is authored without an explicit
6
- * namespace. This is target-agnostic: targets that allow un-namespaced
7
- * authoring (e.g. Mongo, SQLite) declare this id as their default on the target
8
- * descriptor; the framework names the sentinel, never a target. Mirrors
9
- * storage's `UNBOUND_NAMESPACE_ID` on the domain plane.
10
- */
11
- const UNBOUND_DOMAIN_NAMESPACE_ID = "__unbound__";
12
- /**
13
- * Resolve the single domain namespace of a single-namespace contract.
14
- *
15
- * Bare-name access (`db.User`) reads "the contract's one namespace". Every
16
- * contract in scope today declares exactly one domain namespace, so this is
17
- * exact — there is nothing to infer. A contract that declares more than one
18
- * namespace is ambiguous for a bare name, so rather than silently pick one this
19
- * throws; cross-namespace selection is made explicit (TML-2550).
20
- */
21
- function soleDomainNamespaceId(domain) {
22
- const [soleNamespaceId, ...rest] = Object.keys(domain.namespaces);
23
- if (soleNamespaceId === void 0) throw new DomainNamespaceResolutionError("domain has no namespaces");
24
- if (rest.length > 0) {
25
- const all = [soleNamespaceId, ...rest];
26
- throw new DomainNamespaceResolutionError(`bare-name resolution requires exactly one domain namespace, found ${all.length} (${all.join(", ")}); select a namespace explicitly`);
27
- }
28
- return soleNamespaceId;
29
- }
30
- //#endregion
31
- export { soleDomainNamespaceId as n, UNBOUND_DOMAIN_NAMESPACE_ID as t };
32
-
33
- //# sourceMappingURL=default-namespace-Bhu0oN8U.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"default-namespace-Bhu0oN8U.mjs","names":[],"sources":["../src/default-namespace.ts"],"sourcesContent":["import { DomainNamespaceResolutionError } from './contract-validation-error';\n\n/**\n * Reserved sentinel domain namespace id for the late-bound application-domain\n * slot — the namespace a model lands in when it is authored without an explicit\n * namespace. This is target-agnostic: targets that allow un-namespaced\n * authoring (e.g. Mongo, SQLite) declare this id as their default on the target\n * descriptor; the framework names the sentinel, never a target. Mirrors\n * storage's `UNBOUND_NAMESPACE_ID` on the domain plane.\n */\nexport const UNBOUND_DOMAIN_NAMESPACE_ID = '__unbound__' as const;\n\n/**\n * Resolve the single domain namespace of a single-namespace contract.\n *\n * Bare-name access (`db.User`) reads \"the contract's one namespace\". Every\n * contract in scope today declares exactly one domain namespace, so this is\n * exact — there is nothing to infer. A contract that declares more than one\n * namespace is ambiguous for a bare name, so rather than silently pick one this\n * throws; cross-namespace selection is made explicit (TML-2550).\n */\nexport function soleDomainNamespaceId(domain: {\n readonly namespaces: Readonly<Record<string, unknown>>;\n}): string {\n const [soleNamespaceId, ...rest] = Object.keys(domain.namespaces);\n if (soleNamespaceId === undefined) {\n throw new DomainNamespaceResolutionError('domain has no namespaces');\n }\n if (rest.length > 0) {\n const all = [soleNamespaceId, ...rest];\n throw new DomainNamespaceResolutionError(\n `bare-name resolution requires exactly one domain namespace, found ${all.length} (${all.join(', ')}); select a namespace explicitly`,\n );\n }\n return soleNamespaceId;\n}\n"],"mappings":";;;;;;;;;;AAUA,MAAa,8BAA8B;;;;;;;;;;AAW3C,SAAgB,sBAAsB,QAE3B;CACT,MAAM,CAAC,iBAAiB,GAAG,QAAQ,OAAO,KAAK,OAAO,UAAU;CAChE,IAAI,oBAAoB,KAAA,GACtB,MAAM,IAAI,+BAA+B,0BAA0B;CAErE,IAAI,KAAK,SAAS,GAAG;EACnB,MAAM,MAAM,CAAC,iBAAiB,GAAG,IAAI;EACrC,MAAM,IAAI,+BACR,qEAAqE,IAAI,OAAO,IAAI,IAAI,KAAK,IAAI,EAAE,iCACrG;CACF;CACA,OAAO;AACT"}
@@ -1,25 +0,0 @@
1
- //#region src/default-namespace.d.ts
2
- /**
3
- * Reserved sentinel domain namespace id for the late-bound application-domain
4
- * slot — the namespace a model lands in when it is authored without an explicit
5
- * namespace. This is target-agnostic: targets that allow un-namespaced
6
- * authoring (e.g. Mongo, SQLite) declare this id as their default on the target
7
- * descriptor; the framework names the sentinel, never a target. Mirrors
8
- * storage's `UNBOUND_NAMESPACE_ID` on the domain plane.
9
- */
10
- declare const UNBOUND_DOMAIN_NAMESPACE_ID: "__unbound__";
11
- /**
12
- * Resolve the single domain namespace of a single-namespace contract.
13
- *
14
- * Bare-name access (`db.User`) reads "the contract's one namespace". Every
15
- * contract in scope today declares exactly one domain namespace, so this is
16
- * exact — there is nothing to infer. A contract that declares more than one
17
- * namespace is ambiguous for a bare name, so rather than silently pick one this
18
- * throws; cross-namespace selection is made explicit (TML-2550).
19
- */
20
- declare function soleDomainNamespaceId(domain: {
21
- readonly namespaces: Readonly<Record<string, unknown>>;
22
- }): string;
23
- //#endregion
24
- export { soleDomainNamespaceId as n, UNBOUND_DOMAIN_NAMESPACE_ID as t };
25
- //# sourceMappingURL=default-namespace-CprxWqjF.d.mts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"default-namespace-CprxWqjF.d.mts","names":[],"sources":["../src/default-namespace.ts"],"mappings":";;AAUA;;;;AAAiE;AAWjE;;cAXa,2BAAA;;;;;;;AAaZ;;;iBAFe,qBAAA,CAAsB,MAAA;EAAA,SAC3B,UAAA,EAAY,QAAQ,CAAC,MAAA;AAAA"}
@@ -1,2 +0,0 @@
1
- import { n as soleDomainNamespaceId, t as UNBOUND_DOMAIN_NAMESPACE_ID } from "./default-namespace-CprxWqjF.mjs";
2
- export { UNBOUND_DOMAIN_NAMESPACE_ID, soleDomainNamespaceId };
@@ -1,2 +0,0 @@
1
- import { n as soleDomainNamespaceId, t as UNBOUND_DOMAIN_NAMESPACE_ID } from "./default-namespace-Bhu0oN8U.mjs";
2
- export { UNBOUND_DOMAIN_NAMESPACE_ID, soleDomainNamespaceId };
@@ -1,20 +0,0 @@
1
- //#region src/resolve-domain-model.ts
2
- /**
3
- * Resolve a bare domain model name to its namespace coordinate and model IR by
4
- * scanning the contract's namespaces. For the single-namespace contracts in
5
- * scope the scan is exact; cross-namespace bare-name collisions are selected
6
- * explicitly (TML-2550).
7
- */
8
- function resolveDomainModel(domain, modelName) {
9
- for (const namespaceId of Object.keys(domain.namespaces)) {
10
- const model = domain.namespaces[namespaceId]?.models[modelName];
11
- if (model !== void 0) return {
12
- namespaceId,
13
- model
14
- };
15
- }
16
- }
17
- //#endregion
18
- export { resolveDomainModel as t };
19
-
20
- //# sourceMappingURL=resolve-domain-model-R4txseVc.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"resolve-domain-model-R4txseVc.mjs","names":[],"sources":["../src/resolve-domain-model.ts"],"sourcesContent":["import type { ApplicationDomain } from './domain-envelope';\nimport type { ContractModelBase } from './domain-types';\n\nexport interface ResolvedDomainModel {\n readonly namespaceId: string;\n readonly model: ContractModelBase;\n}\n\n/**\n * Resolve a bare domain model name to its namespace coordinate and model IR by\n * scanning the contract's namespaces. For the single-namespace contracts in\n * scope the scan is exact; cross-namespace bare-name collisions are selected\n * explicitly (TML-2550).\n */\nexport function resolveDomainModel(\n domain: ApplicationDomain,\n modelName: string,\n): ResolvedDomainModel | undefined {\n for (const namespaceId of Object.keys(domain.namespaces)) {\n const model = domain.namespaces[namespaceId]?.models[modelName];\n if (model !== undefined) {\n return { namespaceId, model };\n }\n }\n\n return undefined;\n}\n"],"mappings":";;;;;;;AAcA,SAAgB,mBACd,QACA,WACiC;CACjC,KAAK,MAAM,eAAe,OAAO,KAAK,OAAO,UAAU,GAAG;EACxD,MAAM,QAAQ,OAAO,WAAW,cAAc,OAAO;EACrD,IAAI,UAAU,KAAA,GACZ,OAAO;GAAE;GAAa;EAAM;CAEhC;AAGF"}
@@ -1,17 +0,0 @@
1
- import { l as ContractModelBase, t as ApplicationDomain } from "./domain-envelope-Bq5uPLLm.mjs";
2
-
3
- //#region src/resolve-domain-model.d.ts
4
- interface ResolvedDomainModel {
5
- readonly namespaceId: string;
6
- readonly model: ContractModelBase;
7
- }
8
- /**
9
- * Resolve a bare domain model name to its namespace coordinate and model IR by
10
- * scanning the contract's namespaces. For the single-namespace contracts in
11
- * scope the scan is exact; cross-namespace bare-name collisions are selected
12
- * explicitly (TML-2550).
13
- */
14
- declare function resolveDomainModel(domain: ApplicationDomain, modelName: string): ResolvedDomainModel | undefined;
15
- //#endregion
16
- export { resolveDomainModel as n, ResolvedDomainModel as t };
17
- //# sourceMappingURL=resolve-domain-model-V7axlWB2.d.mts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"resolve-domain-model-V7axlWB2.d.mts","names":[],"sources":["../src/resolve-domain-model.ts"],"mappings":";;;UAGiB,mBAAA;EAAA,SACN,WAAA;EAAA,SACA,KAAA,EAAO,iBAAiB;AAAA;;;;;;AAAA;iBASnB,kBAAA,CACd,MAAA,EAAQ,iBAAA,EACR,SAAA,WACC,mBAAmB"}
@@ -1,2 +0,0 @@
1
- import { n as resolveDomainModel, t as ResolvedDomainModel } from "./resolve-domain-model-V7axlWB2.mjs";
2
- export { type ResolvedDomainModel, resolveDomainModel };
@@ -1,2 +0,0 @@
1
- import { t as resolveDomainModel } from "./resolve-domain-model-R4txseVc.mjs";
2
- export { resolveDomainModel };
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.d.mts","names":[],"sources":["../src/domain-namespace-access.ts"],"mappings":";;;;;;;;;;;;iBAUgB,8BAAA,iBAA+C,MAAA,SAAe,iBAAA,EAAA,CAC5E,MAAA,EAAQ,iBAAA,CAAkB,OAAA,IACzB,OAAA;;;;;iBAea,oCAAA,iBACE,MAAA,SAAe,iBAAA,EAAA,CAC/B,MAAA,EAAQ,iBAAA,CAAkB,OAAA,IAAW,MAAA,SAAe,mBAAA"}
@@ -1,25 +0,0 @@
1
- /**
2
- * Governance posture for a storage-plane node or for the contract as a whole.
3
- *
4
- * - `managed` — Prisma Next owns the full lifecycle (DDL, migrations, verification).
5
- * - `tolerated` — node was found in the database but is not schema-managed; Prisma Next
6
- * leaves it untouched while tracking its existence.
7
- * - `external` — node is owned by an external system; Prisma Next never emits DDL for it.
8
- * - `observed` — read-only access; Prisma Next does not write to or migrate the node.
9
- */
10
- export type ControlPolicy = 'managed' | 'tolerated' | 'external' | 'observed';
11
-
12
- /**
13
- * Resolves the effective control policy for a storage-plane node.
14
- *
15
- * Precedence: node-level value → contract default → `'managed'`.
16
- *
17
- * Both parameters are optional raw values so this function stays node-type-agnostic
18
- * and can be called by any consumer (verifier, planner, etc.) without importing IR classes.
19
- */
20
- export function effectiveControlPolicy(
21
- nodeControl: ControlPolicy | undefined,
22
- defaultControl: ControlPolicy | undefined,
23
- ): ControlPolicy {
24
- return nodeControl ?? defaultControl ?? 'managed';
25
- }
@@ -1,36 +0,0 @@
1
- import { DomainNamespaceResolutionError } from './contract-validation-error';
2
-
3
- /**
4
- * Reserved sentinel domain namespace id for the late-bound application-domain
5
- * slot — the namespace a model lands in when it is authored without an explicit
6
- * namespace. This is target-agnostic: targets that allow un-namespaced
7
- * authoring (e.g. Mongo, SQLite) declare this id as their default on the target
8
- * descriptor; the framework names the sentinel, never a target. Mirrors
9
- * storage's `UNBOUND_NAMESPACE_ID` on the domain plane.
10
- */
11
- export const UNBOUND_DOMAIN_NAMESPACE_ID = '__unbound__' as const;
12
-
13
- /**
14
- * Resolve the single domain namespace of a single-namespace contract.
15
- *
16
- * Bare-name access (`db.User`) reads "the contract's one namespace". Every
17
- * contract in scope today declares exactly one domain namespace, so this is
18
- * exact — there is nothing to infer. A contract that declares more than one
19
- * namespace is ambiguous for a bare name, so rather than silently pick one this
20
- * throws; cross-namespace selection is made explicit (TML-2550).
21
- */
22
- export function soleDomainNamespaceId(domain: {
23
- readonly namespaces: Readonly<Record<string, unknown>>;
24
- }): string {
25
- const [soleNamespaceId, ...rest] = Object.keys(domain.namespaces);
26
- if (soleNamespaceId === undefined) {
27
- throw new DomainNamespaceResolutionError('domain has no namespaces');
28
- }
29
- if (rest.length > 0) {
30
- const all = [soleNamespaceId, ...rest];
31
- throw new DomainNamespaceResolutionError(
32
- `bare-name resolution requires exactly one domain namespace, found ${all.length} (${all.join(', ')}); select a namespace explicitly`,
33
- );
34
- }
35
- return soleNamespaceId;
36
- }
@@ -1,32 +0,0 @@
1
- import { DomainNamespaceResolutionError } from './contract-validation-error';
2
- import { soleDomainNamespaceId } from './default-namespace';
3
- import type { ApplicationDomain } from './domain-envelope';
4
- import type { ContractModelBase, ContractValueObject } from './domain-types';
5
-
6
- /**
7
- * Models map for the contract's single domain namespace. Throws when the
8
- * contract does not declare exactly one namespace — bare-name access is
9
- * ambiguous across namespaces and must be qualified explicitly (TML-2550).
10
- */
11
- export function domainModelsAtDefaultNamespace<TModels extends Record<string, ContractModelBase>>(
12
- domain: ApplicationDomain<TModels>,
13
- ): TModels {
14
- const namespaceId = soleDomainNamespaceId(domain);
15
- const domainNamespace = domain.namespaces[namespaceId];
16
- if (domainNamespace === undefined) {
17
- throw new DomainNamespaceResolutionError(
18
- `domain namespace "${namespaceId}" is not present on the contract`,
19
- );
20
- }
21
- return domainNamespace.models;
22
- }
23
-
24
- /**
25
- * Value objects for the contract's single domain namespace, when present.
26
- * Throws when the contract does not declare exactly one namespace.
27
- */
28
- export function domainValueObjectsAtDefaultNamespace<
29
- TModels extends Record<string, ContractModelBase>,
30
- >(domain: ApplicationDomain<TModels>): Record<string, ContractValueObject> | undefined {
31
- return domain.namespaces[soleDomainNamespaceId(domain)]?.valueObjects;
32
- }
@@ -1 +0,0 @@
1
- export { soleDomainNamespaceId, UNBOUND_DOMAIN_NAMESPACE_ID } from '../default-namespace';
@@ -1 +0,0 @@
1
- export { type ResolvedDomainModel, resolveDomainModel } from '../resolve-domain-model';
@@ -1,27 +0,0 @@
1
- import type { ApplicationDomain } from './domain-envelope';
2
- import type { ContractModelBase } from './domain-types';
3
-
4
- export interface ResolvedDomainModel {
5
- readonly namespaceId: string;
6
- readonly model: ContractModelBase;
7
- }
8
-
9
- /**
10
- * Resolve a bare domain model name to its namespace coordinate and model IR by
11
- * scanning the contract's namespaces. For the single-namespace contracts in
12
- * scope the scan is exact; cross-namespace bare-name collisions are selected
13
- * explicitly (TML-2550).
14
- */
15
- export function resolveDomainModel(
16
- domain: ApplicationDomain,
17
- modelName: string,
18
- ): ResolvedDomainModel | undefined {
19
- for (const namespaceId of Object.keys(domain.namespaces)) {
20
- const model = domain.namespaces[namespaceId]?.models[modelName];
21
- if (model !== undefined) {
22
- return { namespaceId, model };
23
- }
24
- }
25
-
26
- return undefined;
27
- }