@prisma-next/contract 0.12.0 → 0.13.0-dev.10

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 (78) hide show
  1. package/dist/apply-specifier-default-control-policy.d.mts +7 -0
  2. package/dist/apply-specifier-default-control-policy.d.mts.map +1 -0
  3. package/dist/apply-specifier-default-control-policy.mjs +12 -0
  4. package/dist/apply-specifier-default-control-policy.mjs.map +1 -0
  5. package/dist/{canonicalization-DFE0HJkI.d.mts → canonicalization-BqYzAeWE.d.mts} +2 -2
  6. package/dist/canonicalization-BqYzAeWE.d.mts.map +1 -0
  7. package/dist/{canonicalization-path-match-b2jFuEso.mjs → canonicalization-path-match-CNgHuwM_.mjs} +1 -1
  8. package/dist/{canonicalization-path-match-b2jFuEso.mjs.map → canonicalization-path-match-CNgHuwM_.mjs.map} +1 -1
  9. package/dist/contract-types-CtIh62PH.d.mts +82 -0
  10. package/dist/contract-types-CtIh62PH.d.mts.map +1 -0
  11. package/dist/{contract-validation-error-ClZaKqMW.mjs → contract-validation-error-BFA66rwU.mjs} +1 -1
  12. package/dist/{contract-validation-error-ClZaKqMW.mjs.map → contract-validation-error-BFA66rwU.mjs.map} +1 -1
  13. package/dist/{contract-validation-error-T5LH4DW-.d.mts → contract-validation-error-D7g0kmcc.d.mts} +1 -1
  14. package/dist/{contract-validation-error-T5LH4DW-.d.mts.map → contract-validation-error-D7g0kmcc.d.mts.map} +1 -1
  15. package/dist/contract-validation-error.d.mts +1 -1
  16. package/dist/contract-validation-error.mjs +1 -1
  17. package/dist/default-namespace-D5X_k6hJ.d.mts +25 -0
  18. package/dist/default-namespace-D5X_k6hJ.d.mts.map +1 -0
  19. package/dist/default-namespace-rpdJeUMq.mjs +33 -0
  20. package/dist/default-namespace-rpdJeUMq.mjs.map +1 -0
  21. package/dist/default-namespace.d.mts +2 -0
  22. package/dist/default-namespace.mjs +2 -0
  23. package/dist/domain-envelope-DKOnhO5d.d.mts +352 -0
  24. package/dist/domain-envelope-DKOnhO5d.d.mts.map +1 -0
  25. package/dist/enum-accessor.d.mts +77 -0
  26. package/dist/enum-accessor.d.mts.map +1 -0
  27. package/dist/enum-accessor.mjs +45 -0
  28. package/dist/enum-accessor.mjs.map +1 -0
  29. package/dist/hashing-utils.d.mts +1 -1
  30. package/dist/hashing-utils.d.mts.map +1 -1
  31. package/dist/hashing-utils.mjs +5 -4
  32. package/dist/hashing-utils.mjs.map +1 -1
  33. package/dist/hashing.d.mts +2 -2
  34. package/dist/hashing.d.mts.map +1 -1
  35. package/dist/hashing.mjs +38 -11
  36. package/dist/hashing.mjs.map +1 -1
  37. package/dist/{namespace-id-CVpkSFUK.mjs → namespace-id-CUxYd4KL.mjs} +1 -1
  38. package/dist/{namespace-id-CVpkSFUK.mjs.map → namespace-id-CUxYd4KL.mjs.map} +1 -1
  39. package/dist/resolve-domain-model-BovPAsW2.mjs +20 -0
  40. package/dist/resolve-domain-model-BovPAsW2.mjs.map +1 -0
  41. package/dist/resolve-domain-model-CSEqpByI.d.mts +17 -0
  42. package/dist/resolve-domain-model-CSEqpByI.d.mts.map +1 -0
  43. package/dist/resolve-domain-model.d.mts +2 -0
  44. package/dist/resolve-domain-model.mjs +2 -0
  45. package/dist/types.d.mts +21 -4
  46. package/dist/types.d.mts.map +1 -0
  47. package/dist/types.mjs +40 -30
  48. package/dist/types.mjs.map +1 -1
  49. package/dist/validate-domain.d.mts +1 -1
  50. package/dist/validate-domain.mjs +6 -3
  51. package/dist/validate-domain.mjs.map +1 -1
  52. package/package.json +10 -6
  53. package/src/apply-specifier-default-control-policy.ts +12 -0
  54. package/src/canonicalization-storage-sort.ts +8 -1
  55. package/src/canonicalization.ts +13 -4
  56. package/src/contract-types.ts +9 -5
  57. package/src/control-policy.ts +25 -0
  58. package/src/cross-reference.ts +15 -3
  59. package/src/default-namespace.ts +36 -0
  60. package/src/domain-envelope.ts +3 -61
  61. package/src/domain-namespace-access.ts +32 -0
  62. package/src/domain-types.ts +32 -1
  63. package/src/enum-accessor.ts +173 -0
  64. package/src/exports/apply-specifier-default-control-policy.ts +1 -0
  65. package/src/exports/default-namespace.ts +1 -0
  66. package/src/exports/enum-accessor.ts +11 -0
  67. package/src/exports/resolve-domain-model.ts +1 -0
  68. package/src/exports/types.ts +16 -7
  69. package/src/hashing.ts +42 -13
  70. package/src/resolve-domain-model.ts +27 -0
  71. package/src/types.ts +18 -2
  72. package/src/validate-domain.ts +6 -0
  73. package/src/value-set-ref.ts +26 -0
  74. package/dist/canonicalization-DFE0HJkI.d.mts.map +0 -1
  75. package/dist/contract-types-xgwKtd7y.d.mts +0 -233
  76. package/dist/contract-types-xgwKtd7y.d.mts.map +0 -1
  77. package/dist/domain-envelope-4hyFtJ4_.d.mts +0 -110
  78. package/dist/domain-envelope-4hyFtJ4_.d.mts.map +0 -1
@@ -0,0 +1,7 @@
1
+ import { a as ControlPolicy, t as Contract } from "./contract-types-CtIh62PH.mjs";
2
+
3
+ //#region src/apply-specifier-default-control-policy.d.ts
4
+ declare function applySpecifierDefaultControlPolicy(contract: Contract, specifierDefault: ControlPolicy | undefined): Contract;
5
+ //#endregion
6
+ export { applySpecifierDefaultControlPolicy };
7
+ //# sourceMappingURL=apply-specifier-default-control-policy.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"apply-specifier-default-control-policy.d.mts","names":[],"sources":["../src/apply-specifier-default-control-policy.ts"],"mappings":";;;iBAGgB,kCAAA,CACd,QAAA,EAAU,QAAA,EACV,gBAAA,EAAkB,aAAA,eACjB,QAAA"}
@@ -0,0 +1,12 @@
1
+ //#region src/apply-specifier-default-control-policy.ts
2
+ function applySpecifierDefaultControlPolicy(contract, specifierDefault) {
3
+ if (specifierDefault === void 0 || contract.defaultControlPolicy !== void 0) return contract;
4
+ return {
5
+ ...contract,
6
+ defaultControlPolicy: specifierDefault
7
+ };
8
+ }
9
+ //#endregion
10
+ export { applySpecifierDefaultControlPolicy };
11
+
12
+ //# sourceMappingURL=apply-specifier-default-control-policy.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"apply-specifier-default-control-policy.mjs","names":[],"sources":["../src/apply-specifier-default-control-policy.ts"],"sourcesContent":["import type { Contract } from './contract-types';\nimport type { ControlPolicy } from './control-policy';\n\nexport function applySpecifierDefaultControlPolicy(\n contract: Contract,\n specifierDefault: ControlPolicy | undefined,\n): Contract {\n if (specifierDefault === undefined || contract.defaultControlPolicy !== undefined) {\n return contract;\n }\n return { ...contract, defaultControlPolicy: specifierDefault };\n}\n"],"mappings":";AAGA,SAAgB,mCACd,UACA,kBACU;CACV,IAAI,qBAAqB,KAAA,KAAa,SAAS,yBAAyB,KAAA,GACtE,OAAO;CAET,OAAO;EAAE,GAAG;EAAU,sBAAsB;CAAiB;AAC/D"}
@@ -1,4 +1,4 @@
1
- import { t as Contract } from "./contract-types-xgwKtd7y.mjs";
1
+ import { t as Contract } from "./contract-types-CtIh62PH.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-DFE0HJkI.d.mts.map
69
+ //# sourceMappingURL=canonicalization-BqYzAeWE.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"canonicalization-BqYzAeWE.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;AAqL3C;;;;KArLY,WAAA,IAAe,OAAgB;AAAA,UAqL1B,2BAAA;EAAA,SACN,aAAA;EAAA;;;;;;;;AA0ByB;AAQpC;EAlCW,SAWA,iBAAA,EAAmB,iBAAA;;;;;;;WAOnB,mBAAA,GAAsB,sBAAA;EAiB/B;;;;;AAEO;AA2BT;EA7BE,SATS,WAAA,GAAc,WAAA;AAAA;;;;;;iBAQT,4BAAA,CACd,QAAA,EAAU,QAAA,EACV,OAAA,EAAS,2BAAA,GACR,MAAA;AAAA,iBA2Ba,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-b2jFuEso.mjs.map
25
+ //# sourceMappingURL=canonicalization-path-match-CNgHuwM_.mjs.map
@@ -1 +1 @@
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
+ {"version":3,"file":"canonicalization-path-match-CNgHuwM_.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"}
@@ -0,0 +1,82 @@
1
+ import { F as ExecutionMutationDefault, J as StorageBase, K as ProfileHashBase, P as ExecutionHashBase, _ as ContractValueObject, d as ContractModelBase, it as CrossReference, t as ApplicationDomain } from "./domain-envelope-DKOnhO5d.mjs";
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, defaultControlPolicy: ControlPolicy | undefined): ControlPolicy;
23
+ //#endregion
24
+ //#region src/contract-types.d.ts
25
+ /**
26
+ * Execution section for the unified contract (ADR 182).
27
+ *
28
+ * Unlike the legacy {@link import('./types').ExecutionSection}, this type
29
+ * requires `executionHash` — when an execution section is present, its
30
+ * hash must be too (consistent with `StorageBase.storageHash`).
31
+ *
32
+ * @template THash Literal hash string type for type-safe hash tracking.
33
+ */
34
+ type ContractExecutionSection<THash extends string = string> = {
35
+ readonly executionHash: ExecutionHashBase<THash>;
36
+ readonly mutations: {
37
+ readonly defaults: ReadonlyArray<ExecutionMutationDefault>;
38
+ };
39
+ };
40
+ /**
41
+ * Unified contract representation (ADR 182).
42
+ *
43
+ * A `Contract` is the canonical in-memory representation of a data contract.
44
+ * It is model-first (domain models carry their own storage bridge) and
45
+ * family-parameterized (SQL, Mongo, etc. specialize via `TStorage` and model
46
+ * storage generics on `ContractModel`).
47
+ *
48
+ * JSON persistence fields (`schemaVersion`, `sources`) are not represented
49
+ * here — they are handled at the serialization boundary.
50
+ *
51
+ * @template TStorage Family-specific storage block (extends {@link StorageBase}).
52
+ * @template TModels Record of model name → {@link ContractModel} with
53
+ * family-specific model storage.
54
+ */
55
+ interface Contract<TStorage extends StorageBase = StorageBase, TModels extends Record<string, ContractModelBase> = Record<string, ContractModelBase>> {
56
+ readonly target: string;
57
+ readonly targetFamily: string;
58
+ readonly roots: Record<string, CrossReference>;
59
+ /**
60
+ * Application plane (ADR 221): `domain.namespaces.<nsId>.{ models, valueObjects }`.
61
+ * `TModels` types the union of model entries across namespaces for family DSL inference.
62
+ */
63
+ readonly domain: ApplicationDomain<TModels>;
64
+ readonly storage: TStorage;
65
+ readonly capabilities: Record<string, Record<string, boolean>>;
66
+ readonly extensionPacks: Record<string, unknown>;
67
+ readonly execution?: ContractExecutionSection;
68
+ readonly profileHash: ProfileHashBase<string>;
69
+ readonly meta: Record<string, unknown>;
70
+ readonly defaultControlPolicy?: ControlPolicy;
71
+ }
72
+ /** Model definitions union carried on a {@link Contract}'s `TModels` type parameter. */
73
+ type ContractModelDefinitions<TContract extends Contract> = TContract extends Contract<StorageBase, infer TModels> ? TModels : never;
74
+ type ExactlyOneNamespace<T extends Record<string, unknown>> = keyof T extends infer Only extends keyof T ? [keyof T] extends [Only] ? Only : never : never;
75
+ type NamespaceValueObjectsOf<TNamespace> = TNamespace extends {
76
+ readonly valueObjects?: infer VO;
77
+ } ? VO extends Record<string, ContractValueObject> ? VO : Record<never, never> : Record<never, never>;
78
+ /** Value-object map when the contract declares exactly one domain namespace. */
79
+ 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>;
80
+ //#endregion
81
+ export { ControlPolicy as a, ContractValueObjectDefinitions as i, ContractExecutionSection as n, effectiveControlPolicy as o, ContractModelDefinitions as r, Contract as t };
82
+ //# sourceMappingURL=contract-types-CtIh62PH.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"contract-types-CtIh62PH.d.mts","names":[],"sources":["../src/control-policy.ts","../src/contract-types.ts"],"mappings":";;;;;;AASA;;;;AAAyB;AAUzB;KAVY,aAAA;;;;;;;;;iBAUI,sBAAA,CACd,WAAA,EAAa,aAAA,cACb,oBAAA,EAAsB,aAAA,eACrB,aAAA;;;;;AAbsB;AAUzB;;;;;;KCCY,wBAAA;EAAA,SACD,aAAA,EAAe,iBAAA,CAAkB,KAAA;EAAA,SACjC,SAAA;IAAA,SACE,QAAA,EAAU,aAAA,CAAc,wBAAA;EAAA;AAAA;;;ADDrB;;;;ACFhB;;;;;;;;;UAsBiB,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;EA1BtB;;;;EAAA,SA+BA,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;EAAA,SACN,oBAAA,GAAuB,aAAA;AAAA;;KAItB,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"}
@@ -17,4 +17,4 @@ var DomainNamespaceResolutionError = class extends Error {
17
17
  //#endregion
18
18
  export { DomainNamespaceResolutionError as n, ContractValidationError as t };
19
19
 
20
- //# sourceMappingURL=contract-validation-error-ClZaKqMW.mjs.map
20
+ //# sourceMappingURL=contract-validation-error-BFA66rwU.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"contract-validation-error-ClZaKqMW.mjs","names":[],"sources":["../src/contract-validation-error.ts"],"sourcesContent":["export type ContractValidationPhase = 'structural' | 'domain' | 'storage';\n\nexport class ContractValidationError extends Error {\n readonly code = 'CONTRACT.VALIDATION_FAILED';\n readonly phase: ContractValidationPhase;\n\n constructor(message: string, phase: ContractValidationPhase) {\n super(message);\n this.name = 'ContractValidationError';\n this.phase = phase;\n }\n}\n\nexport class DomainNamespaceResolutionError extends Error {\n constructor(message: string) {\n super(message);\n this.name = 'DomainNamespaceResolutionError';\n }\n}\n"],"mappings":";AAEA,IAAa,0BAAb,cAA6C,MAAM;CACjD,OAAgB;CAChB;CAEA,YAAY,SAAiB,OAAgC;EAC3D,MAAM,OAAO;EACb,KAAK,OAAO;EACZ,KAAK,QAAQ;CACf;AACF;AAEA,IAAa,iCAAb,cAAoD,MAAM;CACxD,YAAY,SAAiB;EAC3B,MAAM,OAAO;EACb,KAAK,OAAO;CACd;AACF"}
1
+ {"version":3,"file":"contract-validation-error-BFA66rwU.mjs","names":[],"sources":["../src/contract-validation-error.ts"],"sourcesContent":["export type ContractValidationPhase = 'structural' | 'domain' | 'storage';\n\nexport class ContractValidationError extends Error {\n readonly code = 'CONTRACT.VALIDATION_FAILED';\n readonly phase: ContractValidationPhase;\n\n constructor(message: string, phase: ContractValidationPhase) {\n super(message);\n this.name = 'ContractValidationError';\n this.phase = phase;\n }\n}\n\nexport class DomainNamespaceResolutionError extends Error {\n constructor(message: string) {\n super(message);\n this.name = 'DomainNamespaceResolutionError';\n }\n}\n"],"mappings":";AAEA,IAAa,0BAAb,cAA6C,MAAM;CACjD,OAAgB;CAChB;CAEA,YAAY,SAAiB,OAAgC;EAC3D,MAAM,OAAO;EACb,KAAK,OAAO;EACZ,KAAK,QAAQ;CACf;AACF;AAEA,IAAa,iCAAb,cAAoD,MAAM;CACxD,YAAY,SAAiB;EAC3B,MAAM,OAAO;EACb,KAAK,OAAO;CACd;AACF"}
@@ -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-T5LH4DW-.d.mts.map
13
+ //# sourceMappingURL=contract-validation-error-D7g0kmcc.d.mts.map
@@ -1 +1 @@
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
+ {"version":3,"file":"contract-validation-error-D7g0kmcc.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-T5LH4DW-.mjs";
1
+ import { n as ContractValidationPhase, r as DomainNamespaceResolutionError, t as ContractValidationError } from "./contract-validation-error-D7g0kmcc.mjs";
2
2
  export { ContractValidationError, type ContractValidationPhase, DomainNamespaceResolutionError };
@@ -1,2 +1,2 @@
1
- import { n as DomainNamespaceResolutionError, t as ContractValidationError } from "./contract-validation-error-ClZaKqMW.mjs";
1
+ import { n as DomainNamespaceResolutionError, t as ContractValidationError } from "./contract-validation-error-BFA66rwU.mjs";
2
2
  export { ContractValidationError, DomainNamespaceResolutionError };
@@ -0,0 +1,25 @@
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-D5X_k6hJ.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"default-namespace-D5X_k6hJ.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"}
@@ -0,0 +1,33 @@
1
+ import { n as DomainNamespaceResolutionError } from "./contract-validation-error-BFA66rwU.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-rpdJeUMq.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"default-namespace-rpdJeUMq.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"}
@@ -0,0 +1,2 @@
1
+ import { n as soleDomainNamespaceId, t as UNBOUND_DOMAIN_NAMESPACE_ID } from "./default-namespace-D5X_k6hJ.mjs";
2
+ export { UNBOUND_DOMAIN_NAMESPACE_ID, soleDomainNamespaceId };
@@ -0,0 +1,2 @@
1
+ import { n as soleDomainNamespaceId, t as UNBOUND_DOMAIN_NAMESPACE_ID } from "./default-namespace-rpdJeUMq.mjs";
2
+ export { UNBOUND_DOMAIN_NAMESPACE_ID, soleDomainNamespaceId };
@@ -0,0 +1,352 @@
1
+ //#region src/namespace-id.d.ts
2
+ type NamespaceId = string & {
3
+ readonly __brand: 'NamespaceId';
4
+ };
5
+ declare function asNamespaceId(value: string): NamespaceId;
6
+ //#endregion
7
+ //#region src/cross-reference.d.ts
8
+ interface CrossReference {
9
+ readonly namespace: NamespaceId;
10
+ readonly model: string;
11
+ /**
12
+ * Contract-space identity for cross-space relations. When present, the
13
+ * referenced model lives in a different contract space. Absent for local
14
+ * (same-space) relations.
15
+ */
16
+ readonly space?: string;
17
+ }
18
+ declare const CrossReferenceSchema: import("arktype/internal/variants/object.ts").ObjectType<CrossReference, {}>;
19
+ declare function crossRef(model: string, namespace?: string, space?: string): CrossReference;
20
+ //#endregion
21
+ //#region src/types.d.ts
22
+ /**
23
+ * Unique symbol used as the key for branding types.
24
+ */
25
+ declare const $: unique symbol;
26
+ /**
27
+ * A helper type to brand a given type with a unique identifier.
28
+ *
29
+ * @template TKey Text used as the brand key.
30
+ * @template TValue Optional value associated with the brand key. Defaults to `true`.
31
+ */
32
+ type Brand<TKey extends string | number | symbol, TValue = true> = {
33
+ [$]: { [K in TKey]: TValue };
34
+ };
35
+ /**
36
+ * Base type for storage contract hashes.
37
+ * Emitted contract.d.ts files use this with the hash value as a type parameter:
38
+ * `type StorageHash = StorageHashBase<'sha256:abc123...'>`
39
+ */
40
+ type StorageHashBase<THash extends string> = THash & Brand<'StorageHash'>;
41
+ /**
42
+ * Base type for execution contract hashes.
43
+ * Emitted contract.d.ts files use this with the hash value as a type parameter:
44
+ * `type ExecutionHash = ExecutionHashBase<'sha256:def456...'>`
45
+ */
46
+ type ExecutionHashBase<THash extends string> = THash & Brand<'ExecutionHash'>;
47
+ declare function executionHash<const T extends string>(value: T): ExecutionHashBase<T>;
48
+ declare function coreHash<const T extends string>(value: T): StorageHashBase<T>;
49
+ /**
50
+ * Base type for profile contract hashes.
51
+ * Emitted contract.d.ts files use this with the hash value as a type parameter:
52
+ * `type ProfileHash = ProfileHashBase<'sha256:def456...'>`
53
+ */
54
+ type ProfileHashBase<THash extends string> = THash & Brand<'ProfileHash'>;
55
+ declare function profileHash<const T extends string>(value: T): ProfileHashBase<T>;
56
+ /**
57
+ * One entity-kind slot in a namespace — a map of entity name to entry.
58
+ * Values are opaque at the foundation layer; family and target concretions
59
+ * refine them to typed IR classes.
60
+ */
61
+ type StorageEntitySlot = Readonly<Record<string, unknown>>;
62
+ /**
63
+ * Plain-data namespace entry in a storage block. Every hydrated contract
64
+ * carries at least `id` plus entity-kind slot maps under `entries`
65
+ * (`table`, `collection`, …). Foundation declares only this shape — no IR
66
+ * machinery.
67
+ */
68
+ interface StorageNamespace {
69
+ readonly id: string;
70
+ readonly entries: Readonly<Record<string, StorageEntitySlot>>;
71
+ }
72
+ /**
73
+ * Base type for family-specific storage blocks.
74
+ * Family storage types (SqlStorage, MongoStorage, etc.) extend this to carry the
75
+ * storage hash alongside family-specific data (tables, collections, etc.).
76
+ *
77
+ * The `namespaces` map is carried by every hydrated storage block. Serialized
78
+ * envelope shape is target-owned; this types the in-memory contract after
79
+ * `deserializeContract`.
80
+ */
81
+ interface StorageBase<THash extends string = string> {
82
+ readonly storageHash: StorageHashBase<THash>;
83
+ readonly namespaces: Readonly<Record<string, StorageNamespace>>;
84
+ }
85
+ interface FieldType {
86
+ readonly type: string;
87
+ readonly nullable: boolean;
88
+ readonly items?: FieldType;
89
+ readonly properties?: Record<string, FieldType>;
90
+ }
91
+ type GeneratedValueSpec = {
92
+ readonly id: string;
93
+ readonly params?: Record<string, unknown>;
94
+ };
95
+ type JsonPrimitive = string | number | boolean | null;
96
+ type JsonValue = JsonPrimitive | {
97
+ readonly [key: string]: JsonValue;
98
+ } | readonly JsonValue[];
99
+ type ColumnDefaultLiteralValue = JsonValue;
100
+ type ColumnDefaultLiteralInputValue = ColumnDefaultLiteralValue | Date;
101
+ /**
102
+ * Runtime predicate for `ColumnDefaultLiteralInputValue`. Authoring layers
103
+ * resolve template values from caller-supplied args (typed `unknown` at the
104
+ * boundary) and need to validate before constructing a `ColumnDefault`.
105
+ * Accepts JSON primitives, plain arrays/objects of JSON values, and `Date`
106
+ * instances. Rejects functions, class instances (other than `Date`),
107
+ * `undefined`, `bigint`, `symbol`, and arrays/objects containing those.
108
+ */
109
+ declare function isColumnDefaultLiteralInputValue(value: unknown): value is ColumnDefaultLiteralInputValue;
110
+ type ColumnDefault = {
111
+ readonly kind: 'literal';
112
+ readonly value: ColumnDefaultLiteralInputValue;
113
+ } | {
114
+ readonly kind: 'function';
115
+ readonly expression: string;
116
+ };
117
+ declare function isColumnDefault(value: unknown): value is ColumnDefault;
118
+ type ExecutionMutationDefaultValue = {
119
+ readonly kind: 'generator';
120
+ readonly id: GeneratedValueSpec['id'];
121
+ readonly params?: Record<string, unknown>;
122
+ };
123
+ declare function isExecutionMutationDefaultValue(value: unknown): value is ExecutionMutationDefaultValue;
124
+ type ExecutionMutationDefault = {
125
+ readonly ref: {
126
+ readonly table: string;
127
+ readonly column: string;
128
+ };
129
+ readonly onCreate?: ExecutionMutationDefaultValue;
130
+ readonly onUpdate?: ExecutionMutationDefaultValue;
131
+ };
132
+ /**
133
+ * `ExecutionMutationDefault` minus its `ref` — the per-field phases value
134
+ * authoring layers attach to a column before the column ref is known.
135
+ */
136
+ type ExecutionMutationDefaultPhases = Omit<ExecutionMutationDefault, 'ref'>;
137
+ type ExecutionSection<THash extends string = string> = {
138
+ readonly executionHash: ExecutionHashBase<THash>;
139
+ readonly mutations: {
140
+ readonly defaults: ReadonlyArray<ExecutionMutationDefault>;
141
+ };
142
+ };
143
+ interface Source {
144
+ readonly readOnly: boolean;
145
+ readonly projection: Record<string, FieldType>;
146
+ readonly origin?: Record<string, unknown>;
147
+ readonly capabilities?: Record<string, boolean>;
148
+ }
149
+ interface DocIndex {
150
+ readonly name: string;
151
+ readonly keys: Record<string, 'asc' | 'desc'>;
152
+ readonly unique?: boolean;
153
+ readonly where?: Expr;
154
+ }
155
+ type Expr = {
156
+ readonly kind: 'eq';
157
+ readonly path: ReadonlyArray<string>;
158
+ readonly value: unknown;
159
+ } | {
160
+ readonly kind: 'exists';
161
+ readonly path: ReadonlyArray<string>;
162
+ };
163
+ interface DocCollection {
164
+ readonly name: string;
165
+ readonly id?: {
166
+ readonly strategy: 'auto' | 'client' | 'uuid' | 'objectId';
167
+ };
168
+ readonly fields: Record<string, FieldType>;
169
+ readonly indexes?: ReadonlyArray<DocIndex>;
170
+ readonly readOnly?: boolean;
171
+ }
172
+ interface PlanMeta {
173
+ readonly target: string;
174
+ readonly targetFamily?: string;
175
+ readonly storageHash: string;
176
+ readonly profileHash?: string;
177
+ readonly lane: string;
178
+ readonly annotations?: {
179
+ readonly [key: string]: unknown;
180
+ };
181
+ }
182
+ /**
183
+ * Contract marker record stored in the database.
184
+ * Represents the current contract identity for a database.
185
+ */
186
+ interface ContractMarkerRecord {
187
+ readonly storageHash: string;
188
+ readonly profileHash: string;
189
+ readonly contractJson: unknown | null;
190
+ readonly canonicalVersion: number | null;
191
+ readonly updatedAt: Date;
192
+ readonly appTag: string | null;
193
+ readonly meta: Record<string, unknown>;
194
+ readonly invariants: readonly string[];
195
+ }
196
+ /**
197
+ * One applied migration edge from the per-space ledger journal.
198
+ * Returned by `readLedger` in append (apply) order.
199
+ */
200
+ interface LedgerEntryRecord {
201
+ readonly space: string;
202
+ readonly migrationName: string;
203
+ readonly migrationHash: string;
204
+ readonly from: string | null;
205
+ readonly to: string;
206
+ readonly appliedAt: Date;
207
+ readonly operationCount: number;
208
+ }
209
+ //#endregion
210
+ //#region src/value-set-ref.d.ts
211
+ /**
212
+ * Space-aware reference coordinate for a domain enum or storage value-set.
213
+ *
214
+ * `plane` names the contract plane the referenced entity lives in:
215
+ * - `'domain'` — the entity lives in the domain plane's `enum` slot.
216
+ * - `'storage'` — the entity lives in the storage plane's `valueSet` slot.
217
+ *
218
+ * `entityKind` names the source entity-kind:
219
+ * - `'enum'` — the referenced entity is a domain enum.
220
+ * - `'value-set'` — the referenced entity is a storage value-set.
221
+ *
222
+ * `namespaceId` admits the `UNBOUND_NAMESPACE_ID` (`__unbound__`) sentinel for
223
+ * single-namespace (unbound) references.
224
+ *
225
+ * Cross-space discrimination is presence-based: when `spaceId` is absent the
226
+ * reference is local (same contract-space); when `spaceId` is present the
227
+ * reference is cross-space. This mirrors the `ForeignKeyReference` carrier
228
+ * convention — no separate tag field — so local refs are JSON-minimal.
229
+ */
230
+ interface ValueSetRef {
231
+ readonly plane: 'domain' | 'storage';
232
+ readonly namespaceId: string;
233
+ readonly entityKind: 'enum' | 'value-set';
234
+ readonly name: string;
235
+ readonly spaceId?: string;
236
+ }
237
+ //#endregion
238
+ //#region src/domain-types.d.ts
239
+ type ScalarFieldType = {
240
+ readonly kind: 'scalar';
241
+ readonly codecId: string;
242
+ readonly typeParams?: Record<string, unknown>;
243
+ };
244
+ type ValueObjectFieldType = {
245
+ readonly kind: 'valueObject';
246
+ readonly name: string;
247
+ };
248
+ type UnionFieldType = {
249
+ readonly kind: 'union';
250
+ readonly members: ReadonlyArray<ScalarFieldType | ValueObjectFieldType>;
251
+ };
252
+ type ContractFieldType = ScalarFieldType | ValueObjectFieldType | UnionFieldType;
253
+ type ContractField = {
254
+ readonly nullable: boolean;
255
+ readonly type: ContractFieldType;
256
+ readonly many?: true;
257
+ readonly dict?: true;
258
+ readonly valueSet?: ValueSetRef;
259
+ };
260
+ /**
261
+ * A domain enum: an ordered set of named members, each with a codec-encoded
262
+ * value. The `codecId` identifies the codec used to encode member values in
263
+ * storage. The `members` array is ordered (declaration order is preserved).
264
+ */
265
+ type ContractEnum = {
266
+ readonly codecId: string;
267
+ readonly members: readonly {
268
+ readonly name: string;
269
+ readonly value: JsonValue;
270
+ }[];
271
+ };
272
+ type ContractRelationOn = {
273
+ readonly localFields: readonly string[];
274
+ readonly targetFields: readonly string[];
275
+ };
276
+ type ContractRelationThrough = {
277
+ readonly table: string;
278
+ readonly namespaceId: string;
279
+ readonly parentColumns: readonly string[];
280
+ readonly childColumns: readonly string[];
281
+ readonly targetColumns: readonly string[];
282
+ };
283
+ type ContractManyToManyRelation = {
284
+ readonly to: CrossReference;
285
+ readonly cardinality: 'N:M';
286
+ readonly on: ContractRelationOn;
287
+ readonly through: ContractRelationThrough;
288
+ };
289
+ type ContractNonJunctionRelation = {
290
+ readonly to: CrossReference;
291
+ readonly cardinality: '1:1' | '1:N' | 'N:1';
292
+ readonly on: ContractRelationOn;
293
+ readonly through?: never;
294
+ };
295
+ type ContractReferenceRelation = ContractManyToManyRelation | ContractNonJunctionRelation;
296
+ type ContractEmbedRelation = {
297
+ readonly to: CrossReference;
298
+ readonly cardinality: '1:1' | '1:N';
299
+ };
300
+ type ContractRelation = ContractReferenceRelation | ContractEmbedRelation;
301
+ type ContractDiscriminator = {
302
+ readonly field: string;
303
+ };
304
+ type ContractVariantEntry = {
305
+ readonly value: string;
306
+ };
307
+ type ContractValueObject = {
308
+ readonly fields: Record<string, ContractField>;
309
+ };
310
+ type ModelStorageBase = Readonly<Record<string, unknown>>;
311
+ interface ContractModelBase<TModelStorage extends ModelStorageBase = ModelStorageBase> {
312
+ readonly fields: Record<string, ContractField>;
313
+ readonly relations: Record<string, ContractRelation>;
314
+ readonly storage: TModelStorage;
315
+ readonly discriminator?: ContractDiscriminator;
316
+ readonly variants?: Record<string, ContractVariantEntry>;
317
+ readonly base?: CrossReference;
318
+ readonly owner?: string;
319
+ }
320
+ interface ContractModel<TModelStorage extends ModelStorageBase = ModelStorageBase> extends ContractModelBase<TModelStorage> {
321
+ readonly fields: Record<string, ContractField>;
322
+ }
323
+ type ReferenceRelationKeys<TModels extends Record<string, {
324
+ readonly relations: Record<string, ContractRelation>;
325
+ }>, ModelName extends string & keyof TModels> = { [K in keyof TModels[ModelName]['relations']]: TModels[ModelName]['relations'][K] extends ContractReferenceRelation ? K : never }[keyof TModels[ModelName]['relations']];
326
+ type EmbedRelationKeys<TModels extends Record<string, {
327
+ readonly relations: Record<string, ContractRelation>;
328
+ }>, ModelName extends string & keyof TModels> = { [K in keyof TModels[ModelName]['relations']]: TModels[ModelName]['relations'][K] extends ContractReferenceRelation ? never : K }[keyof TModels[ModelName]['relations']];
329
+ //#endregion
330
+ //#region src/domain-envelope.d.ts
331
+ /**
332
+ * One namespace's application-domain entities — models and optional value
333
+ * objects keyed by entity name within that namespace coordinate.
334
+ */
335
+ interface ApplicationDomainNamespace<TModels extends Record<string, ContractModelBase> = Record<string, ContractModelBase>> {
336
+ readonly models: TModels;
337
+ readonly valueObjects?: Record<string, ContractValueObject>;
338
+ readonly enum?: Record<string, ContractEnum>;
339
+ }
340
+ /**
341
+ * Application-domain envelope: entity content keyed by namespace id.
342
+ * Mirrors the storage plane's `namespaces` segment (ADR 221).
343
+ */
344
+ interface ApplicationDomain<TModels extends Record<string, ContractModelBase> = Record<string, ContractModelBase>> {
345
+ readonly namespaces: Readonly<Record<string, ApplicationDomainNamespace<TModels>>>;
346
+ }
347
+ type ContractWithDomain = {
348
+ readonly domain: ApplicationDomain;
349
+ };
350
+ //#endregion
351
+ export { executionHash as $, ColumnDefaultLiteralValue as A, FieldType as B, UnionFieldType as C, Brand as D, $ as E, ExecutionMutationDefault as F, PlanMeta as G, JsonPrimitive as H, ExecutionMutationDefaultPhases as I, StorageBase as J, ProfileHashBase as K, ExecutionMutationDefaultValue as L, DocCollection as M, DocIndex as N, ColumnDefault as O, ExecutionHashBase as P, coreHash as Q, ExecutionSection as R, ScalarFieldType as S, ValueSetRef as T, JsonValue as U, GeneratedValueSpec as V, LedgerEntryRecord as W, StorageHashBase as X, StorageEntitySlot as Y, StorageNamespace as Z, ContractValueObject as _, ContractEmbedRelation as a, CrossReferenceSchema as at, ModelStorageBase as b, ContractFieldType as c, asNamespaceId as ct, ContractModelBase as d, isColumnDefault as et, ContractNonJunctionRelation as f, ContractRelationThrough as g, ContractRelationOn as h, ContractDiscriminator as i, CrossReference as it, ContractMarkerRecord as j, ColumnDefaultLiteralInputValue as k, ContractManyToManyRelation as l, ContractRelation as m, ApplicationDomainNamespace as n, isExecutionMutationDefaultValue as nt, ContractEnum as o, crossRef as ot, ContractReferenceRelation as p, Source as q, ContractWithDomain as r, profileHash as rt, ContractField as s, NamespaceId as st, ApplicationDomain as t, isColumnDefaultLiteralInputValue as tt, ContractModel as u, ContractVariantEntry as v, ValueObjectFieldType as w, ReferenceRelationKeys as x, EmbedRelationKeys as y, Expr as z };
352
+ //# sourceMappingURL=domain-envelope-DKOnhO5d.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"domain-envelope-DKOnhO5d.d.mts","names":[],"sources":["../src/namespace-id.ts","../src/cross-reference.ts","../src/types.ts","../src/value-set-ref.ts","../src/domain-types.ts","../src/domain-envelope.ts"],"mappings":";KAEY,WAAA;EAAA,SAAkC,OAAO;AAAA;AAAA,iBAErC,aAAA,CAAc,KAAA,WAAgB,WAAW;;;UCAxC,cAAA;EAAA,SACN,SAAA,EAAW,WAAW;EAAA,SACtB,KAA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