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

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 (49) hide show
  1. package/dist/apply-specifier-default-control-policy.d.mts +1 -1
  2. package/dist/{canonicalization-ChdV0ueh.d.mts → canonicalization-05YMFrf7.d.mts} +2 -2
  3. package/dist/{canonicalization-ChdV0ueh.d.mts.map → canonicalization-05YMFrf7.d.mts.map} +1 -1
  4. package/dist/contract-types-DrjCtVOs.d.mts +77 -0
  5. package/dist/contract-types-DrjCtVOs.d.mts.map +1 -0
  6. package/dist/domain-envelope-Bj-zQbVU.d.mts +358 -0
  7. package/dist/domain-envelope-Bj-zQbVU.d.mts.map +1 -0
  8. package/dist/enum-accessor.d.mts +93 -0
  9. package/dist/enum-accessor.d.mts.map +1 -0
  10. package/dist/enum-accessor.mjs +47 -0
  11. package/dist/enum-accessor.mjs.map +1 -0
  12. package/dist/hashing-utils.d.mts +1 -1
  13. package/dist/hashing-utils.d.mts.map +1 -1
  14. package/dist/hashing-utils.mjs +1 -3
  15. package/dist/hashing-utils.mjs.map +1 -1
  16. package/dist/hashing.d.mts +2 -2
  17. package/dist/hashing.d.mts.map +1 -1
  18. package/dist/hashing.mjs +1 -3
  19. package/dist/hashing.mjs.map +1 -1
  20. package/dist/is-plain-record-CUofyVQ7.mjs +16 -0
  21. package/dist/is-plain-record-CUofyVQ7.mjs.map +1 -0
  22. package/dist/is-plain-record.d.mts +11 -0
  23. package/dist/is-plain-record.d.mts.map +1 -0
  24. package/dist/is-plain-record.mjs +2 -0
  25. package/dist/{resolve-domain-model-BhAr8VRJ.d.mts → resolve-domain-model-5aHgzqTD.d.mts} +2 -2
  26. package/dist/{resolve-domain-model-BhAr8VRJ.d.mts.map → resolve-domain-model-5aHgzqTD.d.mts.map} +1 -1
  27. package/dist/resolve-domain-model.d.mts +1 -1
  28. package/dist/types.d.mts +6 -6
  29. package/dist/types.d.mts.map +1 -1
  30. package/dist/types.mjs.map +1 -1
  31. package/dist/validate-domain.d.mts +1 -1
  32. package/package.json +6 -4
  33. package/src/canonicalization-storage-sort.ts +1 -4
  34. package/src/contract-types.ts +3 -13
  35. package/src/domain-envelope.ts +4 -8
  36. package/src/domain-namespace-access.ts +6 -6
  37. package/src/domain-types.ts +2 -1
  38. package/src/enum-accessor.ts +191 -0
  39. package/src/exports/enum-accessor.ts +13 -0
  40. package/src/exports/is-plain-record.ts +1 -0
  41. package/src/exports/types.ts +0 -1
  42. package/src/hashing.ts +1 -4
  43. package/src/is-plain-record.ts +11 -0
  44. package/src/types.ts +1 -1
  45. package/src/value-set-ref.ts +20 -15
  46. package/dist/contract-types-CBbD-VV1.d.mts +0 -271
  47. package/dist/contract-types-CBbD-VV1.d.mts.map +0 -1
  48. package/dist/domain-envelope-OkWsysCY.d.mts +0 -163
  49. package/dist/domain-envelope-OkWsysCY.d.mts.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"hashing-utils.d.mts","names":[],"sources":["../src/canonicalization-path-match.ts","../src/canonicalization-storage-sort.ts"],"mappings":";;;KAEY,WAAA;AAAA,KAEA,WAAA,YAAuB,WAAW;AAAA,iBAE9B,kBAAA,CAAmB,IAAA,qBAAyB,OAAA,EAAS,WAAW;AAAA,iBAiChE,4BAAA,CACd,QAAA,WAAmB,WAAA,KAClB,sBAAsB;;;KCvCb,aAAA;AAAA,UAEK,oBAAA;EAAA,SACN,IAAA,WAAe,aAAW;EAAA,SAC1B,SAAA;AAAA;AAAA,iBAcK,qBAAA,CAAsB,CAAA,WAAY,CAAU;AAAA,iBA2D5C,iBAAA,CACd,OAAA,WAAkB,oBAAA,IAClB,OAAA,IAAU,CAAA,WAAY,CAAA,uBACrB,WAAW"}
1
+ {"version":3,"file":"hashing-utils.d.mts","names":[],"sources":["../src/canonicalization-path-match.ts","../src/canonicalization-storage-sort.ts"],"mappings":";;;KAEY,WAAA;AAAA,KAEA,WAAA,YAAuB,WAAW;AAAA,iBAE9B,kBAAA,CAAmB,IAAA,qBAAyB,OAAA,EAAS,WAAW;AAAA,iBAiChE,4BAAA,CACd,QAAA,WAAmB,WAAA,KAClB,sBAAsB;;;KCtCb,aAAA;AAAA,UAEK,oBAAA;EAAA,SACN,IAAA,WAAe,aAAW;EAAA,SAC1B,SAAA;AAAA;AAAA,iBAUK,qBAAA,CAAsB,CAAA,WAAY,CAAU;AAAA,iBA2D5C,iBAAA,CACd,OAAA,WAAkB,oBAAA,IAClB,OAAA,IAAU,CAAA,WAAY,CAAA,uBACrB,WAAW"}
@@ -1,8 +1,6 @@
1
1
  import { n as matchesPathPattern, t as createPreserveEmptyPredicate } from "./canonicalization-path-match-CNgHuwM_.mjs";
2
+ import { t as isPlainRecord } from "./is-plain-record-CUofyVQ7.mjs";
2
3
  //#region src/canonicalization-storage-sort.ts
3
- function isPlainRecord(value) {
4
- return typeof value === "object" && value !== null && !Array.isArray(value);
5
- }
6
4
  function compareCodeUnits(a, b) {
7
5
  return a < b ? -1 : a > b ? 1 : 0;
8
6
  }
@@ -1 +1 @@
1
- {"version":3,"file":"hashing-utils.mjs","names":[],"sources":["../src/canonicalization-storage-sort.ts"],"sourcesContent":["import type { StorageSort } from './canonicalization';\n\nexport type PathSegment = string | '*';\n\nexport interface NamedArraySortTarget {\n readonly path: readonly PathSegment[];\n readonly arrayKeys: readonly string[];\n}\n\nfunction isPlainRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null && !Array.isArray(value);\n}\n\n// Order by UTF-16 code unit, not locale collation: canonicalization feeds\n// storageHash, which must be byte-identical across hosts, and locale\n// collation (localeCompare/Intl) varies by the engine's ICU build.\nfunction compareCodeUnits(a: string, b: string): number {\n return a < b ? -1 : a > b ? 1 : 0;\n}\n\nexport function compareByNameProperty(a: unknown, b: unknown): number {\n const nameA = isPlainRecord(a) && typeof a['name'] === 'string' ? a['name'] : '';\n const nameB = isPlainRecord(b) && typeof b['name'] === 'string' ? b['name'] : '';\n return compareCodeUnits(nameA, nameB);\n}\n\nfunction sortArrayKeysOnRecord(\n record: Record<string, unknown>,\n arrayKeys: readonly string[],\n compare: (a: unknown, b: unknown) => number,\n): Record<string, unknown> {\n const sorted: Record<string, unknown> = { ...record };\n for (const key of arrayKeys) {\n const value = record[key];\n if (Array.isArray(value)) {\n sorted[key] = [...value].sort(compare);\n }\n }\n return sorted;\n}\n\nfunction walkAndSort(\n node: unknown,\n pathSegments: readonly PathSegment[],\n arrayKeys: readonly string[],\n compare: (a: unknown, b: unknown) => number,\n): unknown {\n if (pathSegments.length === 0) {\n if (!isPlainRecord(node)) {\n return node;\n }\n return sortArrayKeysOnRecord(node, arrayKeys, compare);\n }\n\n if (!isPlainRecord(node)) {\n return node;\n }\n\n const [head, ...rest] = pathSegments;\n if (head === undefined) {\n return node;\n }\n\n if (head === '*') {\n const sorted: Record<string, unknown> = { ...node };\n for (const key of Object.keys(node)) {\n sorted[key] = walkAndSort(node[key], rest, arrayKeys, compare);\n }\n return sorted;\n }\n\n const child = node[head];\n if (child === undefined) {\n return node;\n }\n\n return { ...node, [head]: walkAndSort(child, rest, arrayKeys, compare) };\n}\n\nexport function createStorageSort(\n targets: readonly NamedArraySortTarget[],\n compare: (a: unknown, b: unknown) => number = compareByNameProperty,\n): StorageSort {\n return (storage) => {\n if (!isPlainRecord(storage)) {\n return storage;\n }\n\n let result: unknown = storage;\n for (const target of targets) {\n result = walkAndSort(result, target.path, target.arrayKeys, compare);\n }\n return result;\n };\n}\n"],"mappings":";;AASA,SAAS,cAAc,OAAkD;CACvE,OAAO,OAAO,UAAU,YAAY,UAAU,QAAQ,CAAC,MAAM,QAAQ,KAAK;AAC5E;AAKA,SAAS,iBAAiB,GAAW,GAAmB;CACtD,OAAO,IAAI,IAAI,KAAK,IAAI,IAAI,IAAI;AAClC;AAEA,SAAgB,sBAAsB,GAAY,GAAoB;CAGpE,OAAO,iBAFO,cAAc,CAAC,KAAK,OAAO,EAAE,YAAY,WAAW,EAAE,UAAU,IAChE,cAAc,CAAC,KAAK,OAAO,EAAE,YAAY,WAAW,EAAE,UAAU,EAC1C;AACtC;AAEA,SAAS,sBACP,QACA,WACA,SACyB;CACzB,MAAM,SAAkC,EAAE,GAAG,OAAO;CACpD,KAAK,MAAM,OAAO,WAAW;EAC3B,MAAM,QAAQ,OAAO;EACrB,IAAI,MAAM,QAAQ,KAAK,GACrB,OAAO,OAAO,CAAC,GAAG,KAAK,CAAC,CAAC,KAAK,OAAO;CAEzC;CACA,OAAO;AACT;AAEA,SAAS,YACP,MACA,cACA,WACA,SACS;CACT,IAAI,aAAa,WAAW,GAAG;EAC7B,IAAI,CAAC,cAAc,IAAI,GACrB,OAAO;EAET,OAAO,sBAAsB,MAAM,WAAW,OAAO;CACvD;CAEA,IAAI,CAAC,cAAc,IAAI,GACrB,OAAO;CAGT,MAAM,CAAC,MAAM,GAAG,QAAQ;CACxB,IAAI,SAAS,KAAA,GACX,OAAO;CAGT,IAAI,SAAS,KAAK;EAChB,MAAM,SAAkC,EAAE,GAAG,KAAK;EAClD,KAAK,MAAM,OAAO,OAAO,KAAK,IAAI,GAChC,OAAO,OAAO,YAAY,KAAK,MAAM,MAAM,WAAW,OAAO;EAE/D,OAAO;CACT;CAEA,MAAM,QAAQ,KAAK;CACnB,IAAI,UAAU,KAAA,GACZ,OAAO;CAGT,OAAO;EAAE,GAAG;GAAO,OAAO,YAAY,OAAO,MAAM,WAAW,OAAO;CAAE;AACzE;AAEA,SAAgB,kBACd,SACA,UAA8C,uBACjC;CACb,QAAQ,YAAY;EAClB,IAAI,CAAC,cAAc,OAAO,GACxB,OAAO;EAGT,IAAI,SAAkB;EACtB,KAAK,MAAM,UAAU,SACnB,SAAS,YAAY,QAAQ,OAAO,MAAM,OAAO,WAAW,OAAO;EAErE,OAAO;CACT;AACF"}
1
+ {"version":3,"file":"hashing-utils.mjs","names":[],"sources":["../src/canonicalization-storage-sort.ts"],"sourcesContent":["import type { StorageSort } from './canonicalization';\nimport { isPlainRecord } from './is-plain-record';\n\nexport type PathSegment = string | '*';\n\nexport interface NamedArraySortTarget {\n readonly path: readonly PathSegment[];\n readonly arrayKeys: readonly string[];\n}\n\n// Order by UTF-16 code unit, not locale collation: canonicalization feeds\n// storageHash, which must be byte-identical across hosts, and locale\n// collation (localeCompare/Intl) varies by the engine's ICU build.\nfunction compareCodeUnits(a: string, b: string): number {\n return a < b ? -1 : a > b ? 1 : 0;\n}\n\nexport function compareByNameProperty(a: unknown, b: unknown): number {\n const nameA = isPlainRecord(a) && typeof a['name'] === 'string' ? a['name'] : '';\n const nameB = isPlainRecord(b) && typeof b['name'] === 'string' ? b['name'] : '';\n return compareCodeUnits(nameA, nameB);\n}\n\nfunction sortArrayKeysOnRecord(\n record: Record<string, unknown>,\n arrayKeys: readonly string[],\n compare: (a: unknown, b: unknown) => number,\n): Record<string, unknown> {\n const sorted: Record<string, unknown> = { ...record };\n for (const key of arrayKeys) {\n const value = record[key];\n if (Array.isArray(value)) {\n sorted[key] = [...value].sort(compare);\n }\n }\n return sorted;\n}\n\nfunction walkAndSort(\n node: unknown,\n pathSegments: readonly PathSegment[],\n arrayKeys: readonly string[],\n compare: (a: unknown, b: unknown) => number,\n): unknown {\n if (pathSegments.length === 0) {\n if (!isPlainRecord(node)) {\n return node;\n }\n return sortArrayKeysOnRecord(node, arrayKeys, compare);\n }\n\n if (!isPlainRecord(node)) {\n return node;\n }\n\n const [head, ...rest] = pathSegments;\n if (head === undefined) {\n return node;\n }\n\n if (head === '*') {\n const sorted: Record<string, unknown> = { ...node };\n for (const key of Object.keys(node)) {\n sorted[key] = walkAndSort(node[key], rest, arrayKeys, compare);\n }\n return sorted;\n }\n\n const child = node[head];\n if (child === undefined) {\n return node;\n }\n\n return { ...node, [head]: walkAndSort(child, rest, arrayKeys, compare) };\n}\n\nexport function createStorageSort(\n targets: readonly NamedArraySortTarget[],\n compare: (a: unknown, b: unknown) => number = compareByNameProperty,\n): StorageSort {\n return (storage) => {\n if (!isPlainRecord(storage)) {\n return storage;\n }\n\n let result: unknown = storage;\n for (const target of targets) {\n result = walkAndSort(result, target.path, target.arrayKeys, compare);\n }\n return result;\n };\n}\n"],"mappings":";;;AAaA,SAAS,iBAAiB,GAAW,GAAmB;CACtD,OAAO,IAAI,IAAI,KAAK,IAAI,IAAI,IAAI;AAClC;AAEA,SAAgB,sBAAsB,GAAY,GAAoB;CAGpE,OAAO,iBAFO,cAAc,CAAC,KAAK,OAAO,EAAE,YAAY,WAAW,EAAE,UAAU,IAChE,cAAc,CAAC,KAAK,OAAO,EAAE,YAAY,WAAW,EAAE,UAAU,EAC1C;AACtC;AAEA,SAAS,sBACP,QACA,WACA,SACyB;CACzB,MAAM,SAAkC,EAAE,GAAG,OAAO;CACpD,KAAK,MAAM,OAAO,WAAW;EAC3B,MAAM,QAAQ,OAAO;EACrB,IAAI,MAAM,QAAQ,KAAK,GACrB,OAAO,OAAO,CAAC,GAAG,KAAK,CAAC,CAAC,KAAK,OAAO;CAEzC;CACA,OAAO;AACT;AAEA,SAAS,YACP,MACA,cACA,WACA,SACS;CACT,IAAI,aAAa,WAAW,GAAG;EAC7B,IAAI,CAAC,cAAc,IAAI,GACrB,OAAO;EAET,OAAO,sBAAsB,MAAM,WAAW,OAAO;CACvD;CAEA,IAAI,CAAC,cAAc,IAAI,GACrB,OAAO;CAGT,MAAM,CAAC,MAAM,GAAG,QAAQ;CACxB,IAAI,SAAS,KAAA,GACX,OAAO;CAGT,IAAI,SAAS,KAAK;EAChB,MAAM,SAAkC,EAAE,GAAG,KAAK;EAClD,KAAK,MAAM,OAAO,OAAO,KAAK,IAAI,GAChC,OAAO,OAAO,YAAY,KAAK,MAAM,MAAM,WAAW,OAAO;EAE/D,OAAO;CACT;CAEA,MAAM,QAAQ,KAAK;CACnB,IAAI,UAAU,KAAA,GACZ,OAAO;CAGT,OAAO;EAAE,GAAG;GAAO,OAAO,YAAY,OAAO,MAAM,WAAW,OAAO;CAAE;AACzE;AAEA,SAAgB,kBACd,SACA,UAA8C,uBACjC;CACb,QAAQ,YAAY;EAClB,IAAI,CAAC,cAAc,OAAO,GACxB,OAAO;EAGT,IAAI,SAAkB;EACtB,KAAK,MAAM,UAAU,SACnB,SAAS,YAAY,QAAQ,OAAO,MAAM,OAAO,WAAW,OAAO;EAErE,OAAO;CACT;AACF"}
@@ -1,5 +1,5 @@
1
- import { T as ProfileHashBase, k as StorageHashBase, p as ExecutionHashBase } from "./contract-types-CBbD-VV1.mjs";
2
- import { a as canonicalizeContract, i as StorageSort, n as PreserveEmptyPredicate, o as canonicalizeContractToObject, r as SerializeContract, t as CanonicalizeContractOptions } from "./canonicalization-ChdV0ueh.mjs";
1
+ import { K as ProfileHashBase, P as ExecutionHashBase, X as StorageHashBase } from "./domain-envelope-Bj-zQbVU.mjs";
2
+ import { a as canonicalizeContract, i as StorageSort, n as PreserveEmptyPredicate, o as canonicalizeContractToObject, r as SerializeContract, t as CanonicalizeContractOptions } from "./canonicalization-05YMFrf7.mjs";
3
3
 
4
4
  //#region src/hashing.d.ts
5
5
  type ComputeStorageHashArgs = {
@@ -1 +1 @@
1
- {"version":3,"file":"hashing.d.mts","names":[],"sources":["../src/hashing.ts"],"mappings":";;;;KA4EY,sBAAA;EACV,MAAA;EACA,YAAA;EACA,OAAA,EAAS,MAAA;EAAA,SACA,mBAAA,GAAsB,sBAAA;EAAA,SACtB,WAAA,GAAc,WAAA;AAAA;AAAA,iBAGT,kBAAA,CAAmB,IAAA,EAAM,sBAAA,GAAyB,eAAe;AAAA,iBAMjE,oBAAA,CAAqB,IAAA;EACnC,MAAA;EACA,YAAA;EACA,SAAA,EAAW,MAAA;AAAA,IACT,iBAAiB;AAAA,iBAML,kBAAA,CAAmB,IAAA;EACjC,MAAA;EACA,YAAA;EACA,YAAA,EAAc,MAAA,SAAe,MAAA;AAAA,IAC3B,eAAA"}
1
+ {"version":3,"file":"hashing.d.mts","names":[],"sources":["../src/hashing.ts"],"mappings":";;;;KAyEY,sBAAA;EACV,MAAA;EACA,YAAA;EACA,OAAA,EAAS,MAAA;EAAA,SACA,mBAAA,GAAsB,sBAAA;EAAA,SACtB,WAAA,GAAc,WAAA;AAAA;AAAA,iBAGT,kBAAA,CAAmB,IAAA,EAAM,sBAAA,GAAyB,eAAe;AAAA,iBAMjE,oBAAA,CAAqB,IAAA;EACnC,MAAA;EACA,YAAA;EACA,SAAA,EAAW,MAAA;AAAA,IACT,iBAAiB;AAAA,iBAML,kBAAA,CAAmB,IAAA;EACjC,MAAA;EACA,YAAA;EACA,YAAA,EAAc,MAAA,SAAe,MAAA;AAAA,IAC3B,eAAA"}
package/dist/hashing.mjs CHANGED
@@ -1,4 +1,5 @@
1
1
  import { n as matchesPathPattern } from "./canonicalization-path-match-CNgHuwM_.mjs";
2
+ import { t as isPlainRecord } from "./is-plain-record-CUofyVQ7.mjs";
2
3
  import { blindCast, castAs } from "@prisma-next/utils/casts";
3
4
  import { isArrayEqual } from "@prisma-next/utils/array-equal";
4
5
  import { ifDefined } from "@prisma-next/utils/defined";
@@ -144,9 +145,6 @@ function canonicalizeContract(contract, options) {
144
145
  //#endregion
145
146
  //#region src/hashing.ts
146
147
  const SCHEMA_VERSION = "1";
147
- function isPlainRecord(value) {
148
- return value !== null && typeof value === "object" && !Array.isArray(value);
149
- }
150
148
  function omitNamespaceKindsForHash(storage) {
151
149
  if (!isPlainRecord(storage)) return storage;
152
150
  const namespaces = storage["namespaces"];
@@ -1 +1 @@
1
- {"version":3,"file":"hashing.mjs","names":[],"sources":["../src/canonicalization.ts","../src/hashing.ts"],"sourcesContent":["import { isArrayEqual } from '@prisma-next/utils/array-equal';\nimport { ifDefined } from '@prisma-next/utils/defined';\nimport type { JsonObject } from '@prisma-next/utils/json';\nimport { matchesPathPattern, type PathPattern } from './canonicalization-path-match';\nimport type { Contract } from './contract-types';\n\n/**\n * Per-target contract serializer hook. The framework canonicalizer uses\n * this to convert an in-memory contract (which may carry class-instance\n * IR nodes whose runtime-only fields must not appear in the on-disk\n * envelope) into a plain JsonObject before applying the family-agnostic\n * canonical-key ordering / default-omission / sort steps. Targets whose\n * contract is JSON-clean by construction return the contract unchanged.\n */\nexport type SerializeContract = (contract: Contract) => JsonObject;\n\n/**\n * Family-contributed predicate for the default-omission walk. Called when\n * a value at `path` is a default (empty object/array or `false`); if this\n * returns `true` the value is kept rather than stripped.\n *\n * The framework only calls the predicate inside the `isDefaultValue` branch,\n * so there is no need to guard against non-default values.\n */\nexport type PreserveEmptyPredicate = (path: readonly string[]) => boolean;\n\n/**\n * Family-contributed storage sort. Applied to the serialized `storage`\n * subtree after the default-omission walk; the result replaces the\n * `storage` field before the final key sort. Use to establish a\n * deterministic order for storage arrays (indexes, uniques) that the\n * family-agnostic `sortObjectKeys` pass cannot handle.\n */\nexport type StorageSort = (storage: unknown) => unknown;\n\nconst DOMAIN_NAMESPACE_SLOT_PATTERN = ['domain', 'namespaces', '*'] as const satisfies PathPattern;\nconst DOMAIN_MODELS_CONTAINER_PATTERN = [\n 'domain',\n 'namespaces',\n '*',\n 'models',\n] as const satisfies PathPattern;\nconst DOMAIN_MODEL_RELATIONS_PATTERN = [\n 'domain',\n 'namespaces',\n '*',\n 'models',\n '*',\n 'relations',\n] as const satisfies PathPattern;\nconst DOMAIN_MODEL_STORAGE_PATTERN = [\n 'domain',\n 'namespaces',\n '*',\n 'models',\n '*',\n 'storage',\n] as const satisfies PathPattern;\nconst STORAGE_NAMESPACE_ENTRIES_PATTERN = [\n 'storage',\n 'namespaces',\n '*',\n 'entries',\n] as const satisfies PathPattern;\n\nconst TOP_LEVEL_ORDER = [\n 'schemaVersion',\n 'canonicalVersion',\n 'targetFamily',\n 'target',\n 'profileHash',\n 'roots',\n 'domain',\n 'storage',\n 'execution',\n 'capabilities',\n 'extensionPacks',\n 'defaultControlPolicy',\n 'meta',\n] as const;\n\nfunction isDefaultValue(value: unknown): boolean {\n if (value === false) return true;\n if (value === null) return false;\n if (Array.isArray(value) && value.length === 0) return true;\n if (typeof value === 'object' && value !== null) {\n const keys = Object.keys(value);\n return keys.length === 0;\n }\n return false;\n}\n\nfunction omitDefaults(\n obj: unknown,\n path: readonly string[],\n shouldPreserveEmpty: PreserveEmptyPredicate | undefined,\n): unknown {\n if (obj === null || typeof obj !== 'object') {\n return obj;\n }\n\n if (Array.isArray(obj)) {\n return obj.map((item) => omitDefaults(item, path, shouldPreserveEmpty));\n }\n\n const result: Record<string, unknown> = {};\n\n for (const [key, value] of Object.entries(obj)) {\n const currentPath = [...path, key];\n\n if (key === '_generated') {\n continue;\n }\n\n if (key === 'generated' && value === false) {\n continue;\n }\n\n if ((key === 'onDelete' || key === 'onUpdate') && value === 'noAction') {\n continue;\n }\n\n if (isDefaultValue(value)) {\n const isRequiredDomainNamespaces = isArrayEqual(currentPath, ['domain', 'namespaces']);\n const isDomainNamespaceSlot = matchesPathPattern(currentPath, DOMAIN_NAMESPACE_SLOT_PATTERN);\n const isRequiredDomainModels = matchesPathPattern(\n currentPath,\n DOMAIN_MODELS_CONTAINER_PATTERN,\n );\n const isRequiredStorageNamespaces = isArrayEqual(currentPath, ['storage', 'namespaces']);\n const isStorageNamespaceEntries = matchesPathPattern(\n currentPath,\n STORAGE_NAMESPACE_ENTRIES_PATTERN,\n );\n const isRequiredRoots = isArrayEqual(currentPath, ['roots']);\n const isRequiredExtensionPacks = isArrayEqual(currentPath, ['extensionPacks']);\n const isRequiredCapabilities = isArrayEqual(currentPath, ['capabilities']);\n const isRequiredMeta = isArrayEqual(currentPath, ['meta']);\n const isRequiredExecutionDefaults = isArrayEqual(currentPath, [\n 'execution',\n 'mutations',\n 'defaults',\n ]);\n const isExtensionNamespace = currentPath.length === 2 && currentPath[0] === 'extensionPacks';\n const isModelRelations = matchesPathPattern(currentPath, DOMAIN_MODEL_RELATIONS_PATTERN);\n const isModelStorage = matchesPathPattern(currentPath, DOMAIN_MODEL_STORAGE_PATTERN);\n\n const isNullableField = key === 'nullable';\n\n const isFamilyPreserved = shouldPreserveEmpty?.(currentPath) ?? false;\n\n if (\n !isRequiredDomainNamespaces &&\n !isDomainNamespaceSlot &&\n !isRequiredDomainModels &&\n !isRequiredStorageNamespaces &&\n !isStorageNamespaceEntries &&\n !isRequiredRoots &&\n !isRequiredExtensionPacks &&\n !isRequiredCapabilities &&\n !isRequiredMeta &&\n !isRequiredExecutionDefaults &&\n !isExtensionNamespace &&\n !isModelRelations &&\n !isModelStorage &&\n !isNullableField &&\n !isFamilyPreserved\n ) {\n continue;\n }\n }\n\n result[key] = omitDefaults(value, currentPath, shouldPreserveEmpty);\n }\n\n return result;\n}\n\nfunction sortObjectKeys(obj: unknown): unknown {\n if (obj === null || typeof obj !== 'object') {\n return obj;\n }\n\n if (Array.isArray(obj)) {\n return obj.map((item) => sortObjectKeys(item));\n }\n\n const sorted: Record<string, unknown> = {};\n const keys = Object.keys(obj).sort();\n for (const key of keys) {\n sorted[key] = sortObjectKeys((obj as Record<string, unknown>)[key]);\n }\n\n return sorted;\n}\n\nexport function orderTopLevel(obj: Record<string, unknown>): Record<string, unknown> {\n const ordered: Record<string, unknown> = {};\n const remaining = new Set(Object.keys(obj));\n\n for (const key of TOP_LEVEL_ORDER) {\n if (remaining.has(key)) {\n ordered[key] = obj[key];\n remaining.delete(key);\n }\n }\n\n for (const key of Array.from(remaining).sort()) {\n ordered[key] = obj[key];\n }\n\n return ordered;\n}\n\nexport interface CanonicalizeContractOptions {\n readonly schemaVersion?: string;\n /**\n * Per-target hook that converts the in-memory contract (which may\n * carry class-instance IR nodes) into a plain JsonObject before the\n * family-agnostic canonicalization steps run.\n *\n * Routing through the hook is what lets each target decide which\n * fields appear in the on-disk envelope; runtime-only class API\n * fields stay invisible to the canonicalization walk by virtue of\n * the per-target serializer not putting them in the JSON shape.\n */\n readonly serializeContract: SerializeContract;\n /**\n * Family-contributed preserve-empty predicate. When the walk encounters a\n * default value (empty object/array or `false`) at `path`, calling this\n * with the full path allows the family to veto the omission. If absent,\n * only the framework's family-agnostic required-slot rules apply.\n */\n readonly shouldPreserveEmpty?: PreserveEmptyPredicate;\n /**\n * Family-contributed storage sort. Applied to the serialized `storage`\n * subtree after the default-omission walk, before the final key sort.\n * SQL family uses this to impose a deterministic order on `indexes` and\n * `uniques` arrays within each namespace table. Families that require no\n * special storage ordering omit this hook.\n */\n readonly sortStorage?: StorageSort;\n}\n\n/**\n * Object-form variant of {@link canonicalizeContract}. Exported because the\n * emitter writes the canonical contract through a separate JSON-stringify\n * pass and consumes the structured object directly.\n */\nexport function canonicalizeContractToObject(\n contract: Contract,\n options: CanonicalizeContractOptions,\n): Record<string, unknown> {\n const serialized = options.serializeContract(contract);\n const normalized: Record<string, unknown> = {\n ...ifDefined('schemaVersion', options.schemaVersion),\n targetFamily: serialized['targetFamily'],\n target: serialized['target'],\n profileHash: serialized['profileHash'],\n roots: serialized['roots'],\n domain: serialized['domain'],\n storage: serialized['storage'],\n ...ifDefined('execution', serialized['execution']),\n extensionPacks: serialized['extensionPacks'],\n capabilities: serialized['capabilities'],\n ...ifDefined('defaultControlPolicy', serialized['defaultControlPolicy']),\n meta: serialized['meta'],\n };\n const withDefaultsOmitted = omitDefaults(normalized, [], options.shouldPreserveEmpty) as Record<\n string,\n unknown\n >;\n const withSortedStorage = options.sortStorage\n ? { ...withDefaultsOmitted, storage: options.sortStorage(withDefaultsOmitted['storage']) }\n : withDefaultsOmitted;\n const withSortedKeys = sortObjectKeys(withSortedStorage) as Record<string, unknown>;\n return orderTopLevel(withSortedKeys);\n}\n\nexport function canonicalizeContract(\n contract: Contract,\n options: CanonicalizeContractOptions,\n): string {\n return JSON.stringify(canonicalizeContractToObject(contract, options), null, 2);\n}\n","import { createHash } from 'node:crypto';\nimport { blindCast, castAs } from '@prisma-next/utils/casts';\nimport { ifDefined } from '@prisma-next/utils/defined';\nimport type { JsonObject } from '@prisma-next/utils/json';\nimport {\n canonicalizeContract,\n type PreserveEmptyPredicate,\n type StorageSort,\n} from './canonicalization';\nimport type { Contract } from './contract-types';\nimport type { ExecutionHashBase, ProfileHashBase, StorageHashBase } from './types';\n\nconst SCHEMA_VERSION = '1';\n\nfunction isPlainRecord(value: unknown): value is Record<string, unknown> {\n return value !== null && typeof value === 'object' && !Array.isArray(value);\n}\n\n// Storage hashes fingerprint table/column layout, not which target pack emitted a\n// namespace. Persisted contract.json carries namespace `kind` discriminators;\n// authoring-time hashes never included them (IR `kind` is non-enumerable).\nfunction omitNamespaceKindsForHash(storage: unknown): unknown {\n if (!isPlainRecord(storage)) {\n return storage;\n }\n const namespaces = storage['namespaces'];\n if (!isPlainRecord(namespaces)) {\n return storage;\n }\n const stripped: Record<string, unknown> = {};\n for (const [nsId, ns] of Object.entries(namespaces)) {\n if (isPlainRecord(ns)) {\n const { kind: _kind, ...rest } = ns;\n stripped[nsId] = rest;\n } else {\n stripped[nsId] = ns;\n }\n }\n return { ...storage, namespaces: stripped };\n}\n\nfunction sha256(content: string): string {\n const hash = createHash('sha256');\n hash.update(content);\n return `sha256:${hash.digest('hex')}`;\n}\n\ntype HashContractSection = Record<string, unknown> & {\n readonly shouldPreserveEmpty?: PreserveEmptyPredicate;\n readonly sortStorage?: StorageSort;\n};\n\nfunction hashContract(section: HashContractSection): string {\n const { shouldPreserveEmpty, sortStorage, ...sectionData } = section;\n const storageForHash = omitNamespaceKindsForHash(sectionData['storage'] ?? {});\n const contract = blindCast<Contract, 'hash-only partial contract for canonicalizeContract'>({\n targetFamily: sectionData['targetFamily'],\n target: sectionData['target'],\n roots: {},\n domain: { namespaces: {} },\n execution: sectionData['execution'],\n extensionPacks: {},\n capabilities: sectionData['capabilities'] ?? {},\n meta: {},\n profileHash: '',\n ...sectionData,\n storage: storageForHash,\n });\n return canonicalizeContract(contract, {\n schemaVersion: SCHEMA_VERSION,\n serializeContract: (c) => castAs<JsonObject>(JSON.parse(JSON.stringify(c))),\n ...ifDefined('shouldPreserveEmpty', shouldPreserveEmpty),\n ...ifDefined('sortStorage', sortStorage),\n });\n}\n\nexport type ComputeStorageHashArgs = {\n target: string;\n targetFamily: string;\n storage: Record<string, unknown>;\n readonly shouldPreserveEmpty?: PreserveEmptyPredicate;\n readonly sortStorage?: StorageSort;\n};\n\nexport function computeStorageHash(args: ComputeStorageHashArgs): StorageHashBase<string> {\n return blindCast<StorageHashBase<string>, 'sha256 digest of canonicalized storage'>(\n sha256(hashContract(args)),\n );\n}\n\nexport function computeExecutionHash(args: {\n target: string;\n targetFamily: string;\n execution: Record<string, unknown>;\n}): ExecutionHashBase<string> {\n return blindCast<ExecutionHashBase<string>, 'sha256 digest of canonicalized execution'>(\n sha256(hashContract(args)),\n );\n}\n\nexport function computeProfileHash(args: {\n target: string;\n targetFamily: string;\n capabilities: Record<string, Record<string, boolean>>;\n}): ProfileHashBase<string> {\n return blindCast<ProfileHashBase<string>, 'sha256 digest of canonicalized profile'>(\n sha256(hashContract(args)),\n );\n}\n"],"mappings":";;;;;;AAmCA,MAAM,gCAAgC;CAAC;CAAU;CAAc;AAAG;AAClE,MAAM,kCAAkC;CACtC;CACA;CACA;CACA;AACF;AACA,MAAM,iCAAiC;CACrC;CACA;CACA;CACA;CACA;CACA;AACF;AACA,MAAM,+BAA+B;CACnC;CACA;CACA;CACA;CACA;CACA;AACF;AACA,MAAM,oCAAoC;CACxC;CACA;CACA;CACA;AACF;AAEA,MAAM,kBAAkB;CACtB;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;AAEA,SAAS,eAAe,OAAyB;CAC/C,IAAI,UAAU,OAAO,OAAO;CAC5B,IAAI,UAAU,MAAM,OAAO;CAC3B,IAAI,MAAM,QAAQ,KAAK,KAAK,MAAM,WAAW,GAAG,OAAO;CACvD,IAAI,OAAO,UAAU,YAAY,UAAU,MAEzC,OADa,OAAO,KAAK,KACf,CAAC,CAAC,WAAW;CAEzB,OAAO;AACT;AAEA,SAAS,aACP,KACA,MACA,qBACS;CACT,IAAI,QAAQ,QAAQ,OAAO,QAAQ,UACjC,OAAO;CAGT,IAAI,MAAM,QAAQ,GAAG,GACnB,OAAO,IAAI,KAAK,SAAS,aAAa,MAAM,MAAM,mBAAmB,CAA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;EACvD,GAAG,UAAU,eAAe,WAAW;CACzC,CAAC;AACH;AAUA,SAAgB,mBAAmB,MAAuD;CACxF,OAAO,UACL,OAAO,aAAa,IAAI,CAAC,CAC3B;AACF;AAEA,SAAgB,qBAAqB,MAIP;CAC5B,OAAO,UACL,OAAO,aAAa,IAAI,CAAC,CAC3B;AACF;AAEA,SAAgB,mBAAmB,MAIP;CAC1B,OAAO,UACL,OAAO,aAAa,IAAI,CAAC,CAC3B;AACF"}
1
+ {"version":3,"file":"hashing.mjs","names":[],"sources":["../src/canonicalization.ts","../src/hashing.ts"],"sourcesContent":["import { isArrayEqual } from '@prisma-next/utils/array-equal';\nimport { ifDefined } from '@prisma-next/utils/defined';\nimport type { JsonObject } from '@prisma-next/utils/json';\nimport { matchesPathPattern, type PathPattern } from './canonicalization-path-match';\nimport type { Contract } from './contract-types';\n\n/**\n * Per-target contract serializer hook. The framework canonicalizer uses\n * this to convert an in-memory contract (which may carry class-instance\n * IR nodes whose runtime-only fields must not appear in the on-disk\n * envelope) into a plain JsonObject before applying the family-agnostic\n * canonical-key ordering / default-omission / sort steps. Targets whose\n * contract is JSON-clean by construction return the contract unchanged.\n */\nexport type SerializeContract = (contract: Contract) => JsonObject;\n\n/**\n * Family-contributed predicate for the default-omission walk. Called when\n * a value at `path` is a default (empty object/array or `false`); if this\n * returns `true` the value is kept rather than stripped.\n *\n * The framework only calls the predicate inside the `isDefaultValue` branch,\n * so there is no need to guard against non-default values.\n */\nexport type PreserveEmptyPredicate = (path: readonly string[]) => boolean;\n\n/**\n * Family-contributed storage sort. Applied to the serialized `storage`\n * subtree after the default-omission walk; the result replaces the\n * `storage` field before the final key sort. Use to establish a\n * deterministic order for storage arrays (indexes, uniques) that the\n * family-agnostic `sortObjectKeys` pass cannot handle.\n */\nexport type StorageSort = (storage: unknown) => unknown;\n\nconst DOMAIN_NAMESPACE_SLOT_PATTERN = ['domain', 'namespaces', '*'] as const satisfies PathPattern;\nconst DOMAIN_MODELS_CONTAINER_PATTERN = [\n 'domain',\n 'namespaces',\n '*',\n 'models',\n] as const satisfies PathPattern;\nconst DOMAIN_MODEL_RELATIONS_PATTERN = [\n 'domain',\n 'namespaces',\n '*',\n 'models',\n '*',\n 'relations',\n] as const satisfies PathPattern;\nconst DOMAIN_MODEL_STORAGE_PATTERN = [\n 'domain',\n 'namespaces',\n '*',\n 'models',\n '*',\n 'storage',\n] as const satisfies PathPattern;\nconst STORAGE_NAMESPACE_ENTRIES_PATTERN = [\n 'storage',\n 'namespaces',\n '*',\n 'entries',\n] as const satisfies PathPattern;\n\nconst TOP_LEVEL_ORDER = [\n 'schemaVersion',\n 'canonicalVersion',\n 'targetFamily',\n 'target',\n 'profileHash',\n 'roots',\n 'domain',\n 'storage',\n 'execution',\n 'capabilities',\n 'extensionPacks',\n 'defaultControlPolicy',\n 'meta',\n] as const;\n\nfunction isDefaultValue(value: unknown): boolean {\n if (value === false) return true;\n if (value === null) return false;\n if (Array.isArray(value) && value.length === 0) return true;\n if (typeof value === 'object' && value !== null) {\n const keys = Object.keys(value);\n return keys.length === 0;\n }\n return false;\n}\n\nfunction omitDefaults(\n obj: unknown,\n path: readonly string[],\n shouldPreserveEmpty: PreserveEmptyPredicate | undefined,\n): unknown {\n if (obj === null || typeof obj !== 'object') {\n return obj;\n }\n\n if (Array.isArray(obj)) {\n return obj.map((item) => omitDefaults(item, path, shouldPreserveEmpty));\n }\n\n const result: Record<string, unknown> = {};\n\n for (const [key, value] of Object.entries(obj)) {\n const currentPath = [...path, key];\n\n if (key === '_generated') {\n continue;\n }\n\n if (key === 'generated' && value === false) {\n continue;\n }\n\n if ((key === 'onDelete' || key === 'onUpdate') && value === 'noAction') {\n continue;\n }\n\n if (isDefaultValue(value)) {\n const isRequiredDomainNamespaces = isArrayEqual(currentPath, ['domain', 'namespaces']);\n const isDomainNamespaceSlot = matchesPathPattern(currentPath, DOMAIN_NAMESPACE_SLOT_PATTERN);\n const isRequiredDomainModels = matchesPathPattern(\n currentPath,\n DOMAIN_MODELS_CONTAINER_PATTERN,\n );\n const isRequiredStorageNamespaces = isArrayEqual(currentPath, ['storage', 'namespaces']);\n const isStorageNamespaceEntries = matchesPathPattern(\n currentPath,\n STORAGE_NAMESPACE_ENTRIES_PATTERN,\n );\n const isRequiredRoots = isArrayEqual(currentPath, ['roots']);\n const isRequiredExtensionPacks = isArrayEqual(currentPath, ['extensionPacks']);\n const isRequiredCapabilities = isArrayEqual(currentPath, ['capabilities']);\n const isRequiredMeta = isArrayEqual(currentPath, ['meta']);\n const isRequiredExecutionDefaults = isArrayEqual(currentPath, [\n 'execution',\n 'mutations',\n 'defaults',\n ]);\n const isExtensionNamespace = currentPath.length === 2 && currentPath[0] === 'extensionPacks';\n const isModelRelations = matchesPathPattern(currentPath, DOMAIN_MODEL_RELATIONS_PATTERN);\n const isModelStorage = matchesPathPattern(currentPath, DOMAIN_MODEL_STORAGE_PATTERN);\n\n const isNullableField = key === 'nullable';\n\n const isFamilyPreserved = shouldPreserveEmpty?.(currentPath) ?? false;\n\n if (\n !isRequiredDomainNamespaces &&\n !isDomainNamespaceSlot &&\n !isRequiredDomainModels &&\n !isRequiredStorageNamespaces &&\n !isStorageNamespaceEntries &&\n !isRequiredRoots &&\n !isRequiredExtensionPacks &&\n !isRequiredCapabilities &&\n !isRequiredMeta &&\n !isRequiredExecutionDefaults &&\n !isExtensionNamespace &&\n !isModelRelations &&\n !isModelStorage &&\n !isNullableField &&\n !isFamilyPreserved\n ) {\n continue;\n }\n }\n\n result[key] = omitDefaults(value, currentPath, shouldPreserveEmpty);\n }\n\n return result;\n}\n\nfunction sortObjectKeys(obj: unknown): unknown {\n if (obj === null || typeof obj !== 'object') {\n return obj;\n }\n\n if (Array.isArray(obj)) {\n return obj.map((item) => sortObjectKeys(item));\n }\n\n const sorted: Record<string, unknown> = {};\n const keys = Object.keys(obj).sort();\n for (const key of keys) {\n sorted[key] = sortObjectKeys((obj as Record<string, unknown>)[key]);\n }\n\n return sorted;\n}\n\nexport function orderTopLevel(obj: Record<string, unknown>): Record<string, unknown> {\n const ordered: Record<string, unknown> = {};\n const remaining = new Set(Object.keys(obj));\n\n for (const key of TOP_LEVEL_ORDER) {\n if (remaining.has(key)) {\n ordered[key] = obj[key];\n remaining.delete(key);\n }\n }\n\n for (const key of Array.from(remaining).sort()) {\n ordered[key] = obj[key];\n }\n\n return ordered;\n}\n\nexport interface CanonicalizeContractOptions {\n readonly schemaVersion?: string;\n /**\n * Per-target hook that converts the in-memory contract (which may\n * carry class-instance IR nodes) into a plain JsonObject before the\n * family-agnostic canonicalization steps run.\n *\n * Routing through the hook is what lets each target decide which\n * fields appear in the on-disk envelope; runtime-only class API\n * fields stay invisible to the canonicalization walk by virtue of\n * the per-target serializer not putting them in the JSON shape.\n */\n readonly serializeContract: SerializeContract;\n /**\n * Family-contributed preserve-empty predicate. When the walk encounters a\n * default value (empty object/array or `false`) at `path`, calling this\n * with the full path allows the family to veto the omission. If absent,\n * only the framework's family-agnostic required-slot rules apply.\n */\n readonly shouldPreserveEmpty?: PreserveEmptyPredicate;\n /**\n * Family-contributed storage sort. Applied to the serialized `storage`\n * subtree after the default-omission walk, before the final key sort.\n * SQL family uses this to impose a deterministic order on `indexes` and\n * `uniques` arrays within each namespace table. Families that require no\n * special storage ordering omit this hook.\n */\n readonly sortStorage?: StorageSort;\n}\n\n/**\n * Object-form variant of {@link canonicalizeContract}. Exported because the\n * emitter writes the canonical contract through a separate JSON-stringify\n * pass and consumes the structured object directly.\n */\nexport function canonicalizeContractToObject(\n contract: Contract,\n options: CanonicalizeContractOptions,\n): Record<string, unknown> {\n const serialized = options.serializeContract(contract);\n const normalized: Record<string, unknown> = {\n ...ifDefined('schemaVersion', options.schemaVersion),\n targetFamily: serialized['targetFamily'],\n target: serialized['target'],\n profileHash: serialized['profileHash'],\n roots: serialized['roots'],\n domain: serialized['domain'],\n storage: serialized['storage'],\n ...ifDefined('execution', serialized['execution']),\n extensionPacks: serialized['extensionPacks'],\n capabilities: serialized['capabilities'],\n ...ifDefined('defaultControlPolicy', serialized['defaultControlPolicy']),\n meta: serialized['meta'],\n };\n const withDefaultsOmitted = omitDefaults(normalized, [], options.shouldPreserveEmpty) as Record<\n string,\n unknown\n >;\n const withSortedStorage = options.sortStorage\n ? { ...withDefaultsOmitted, storage: options.sortStorage(withDefaultsOmitted['storage']) }\n : withDefaultsOmitted;\n const withSortedKeys = sortObjectKeys(withSortedStorage) as Record<string, unknown>;\n return orderTopLevel(withSortedKeys);\n}\n\nexport function canonicalizeContract(\n contract: Contract,\n options: CanonicalizeContractOptions,\n): string {\n return JSON.stringify(canonicalizeContractToObject(contract, options), null, 2);\n}\n","import { createHash } from 'node:crypto';\nimport { blindCast, castAs } from '@prisma-next/utils/casts';\nimport { ifDefined } from '@prisma-next/utils/defined';\nimport type { JsonObject } from '@prisma-next/utils/json';\nimport {\n canonicalizeContract,\n type PreserveEmptyPredicate,\n type StorageSort,\n} from './canonicalization';\nimport type { Contract } from './contract-types';\nimport { isPlainRecord } from './is-plain-record';\nimport type { ExecutionHashBase, ProfileHashBase, StorageHashBase } from './types';\n\nconst SCHEMA_VERSION = '1';\n\n// Storage hashes fingerprint table/column layout, not which target pack emitted a\n// namespace. Persisted contract.json carries namespace `kind` discriminators;\n// authoring-time hashes never included them (IR `kind` is non-enumerable).\nfunction omitNamespaceKindsForHash(storage: unknown): unknown {\n if (!isPlainRecord(storage)) {\n return storage;\n }\n const namespaces = storage['namespaces'];\n if (!isPlainRecord(namespaces)) {\n return storage;\n }\n const stripped: Record<string, unknown> = {};\n for (const [nsId, ns] of Object.entries(namespaces)) {\n if (isPlainRecord(ns)) {\n const { kind: _kind, ...rest } = ns;\n stripped[nsId] = rest;\n } else {\n stripped[nsId] = ns;\n }\n }\n return { ...storage, namespaces: stripped };\n}\n\nfunction sha256(content: string): string {\n const hash = createHash('sha256');\n hash.update(content);\n return `sha256:${hash.digest('hex')}`;\n}\n\ntype HashContractSection = Record<string, unknown> & {\n readonly shouldPreserveEmpty?: PreserveEmptyPredicate;\n readonly sortStorage?: StorageSort;\n};\n\nfunction hashContract(section: HashContractSection): string {\n const { shouldPreserveEmpty, sortStorage, ...sectionData } = section;\n const storageForHash = omitNamespaceKindsForHash(sectionData['storage'] ?? {});\n const contract = blindCast<Contract, 'hash-only partial contract for canonicalizeContract'>({\n targetFamily: sectionData['targetFamily'],\n target: sectionData['target'],\n roots: {},\n domain: { namespaces: {} },\n execution: sectionData['execution'],\n extensionPacks: {},\n capabilities: sectionData['capabilities'] ?? {},\n meta: {},\n profileHash: '',\n ...sectionData,\n storage: storageForHash,\n });\n return canonicalizeContract(contract, {\n schemaVersion: SCHEMA_VERSION,\n serializeContract: (c) => castAs<JsonObject>(JSON.parse(JSON.stringify(c))),\n ...ifDefined('shouldPreserveEmpty', shouldPreserveEmpty),\n ...ifDefined('sortStorage', sortStorage),\n });\n}\n\nexport type ComputeStorageHashArgs = {\n target: string;\n targetFamily: string;\n storage: Record<string, unknown>;\n readonly shouldPreserveEmpty?: PreserveEmptyPredicate;\n readonly sortStorage?: StorageSort;\n};\n\nexport function computeStorageHash(args: ComputeStorageHashArgs): StorageHashBase<string> {\n return blindCast<StorageHashBase<string>, 'sha256 digest of canonicalized storage'>(\n sha256(hashContract(args)),\n );\n}\n\nexport function computeExecutionHash(args: {\n target: string;\n targetFamily: string;\n execution: Record<string, unknown>;\n}): ExecutionHashBase<string> {\n return blindCast<ExecutionHashBase<string>, 'sha256 digest of canonicalized execution'>(\n sha256(hashContract(args)),\n );\n}\n\nexport function computeProfileHash(args: {\n target: string;\n targetFamily: string;\n capabilities: Record<string, Record<string, boolean>>;\n}): ProfileHashBase<string> {\n return blindCast<ProfileHashBase<string>, 'sha256 digest of canonicalized profile'>(\n sha256(hashContract(args)),\n );\n}\n"],"mappings":";;;;;;;AAmCA,MAAM,gCAAgC;CAAC;CAAU;CAAc;AAAG;AAClE,MAAM,kCAAkC;CACtC;CACA;CACA;CACA;AACF;AACA,MAAM,iCAAiC;CACrC;CACA;CACA;CACA;CACA;CAC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AAO,KAAK;AACpC;AAOA,SAAS,aAAa,SAAsC;CAC1D,MAAM,EAAE,qBAAqB,aAAa,GAAG,gBAAgB;CAC7D,MAAM,iBAAiB,0BAA0B,YAAY,cAAc,CAAC,CAAC;CAc7E,OAAO,qBAbU,UAA2E;EAC1F,cAAc,YAAY;EAC1B,QAAQ,YAAY;EACpB,OAAO,CAAC;EACR,QAAQ,EAAE,YAAY,CAAC,EAAE;EACzB,WAAW,YAAY;EACvB,gBAAgB,CAAC;EACjB,cAAc,YAAY,mBAAmB,CAAC;EAC9C,MAAM,CAAC;EACP,aAAa;EACb,GAAG;EACH,SAAS;CACX,CACmC,GAAG;EACpC,eAAe;EACf,oBAAoB,MAAM,OAAmB,KAAK,MAAM,KAAK,UAAU,CAAC,CAAC,CAAC;EAC1E,GAAG,UAAU,uBAAuB,mBAAmB;EACvD,GAAG,UAAU,eAAe,WAAW;CACzC,CAAC;AACH;AAUA,SAAgB,mBAAmB,MAAuD;CACxF,OAAO,UACL,OAAO,aAAa,IAAI,CAAC,CAC3B;AACF;AAEA,SAAgB,qBAAqB,MAIP;CAC5B,OAAO,UACL,OAAO,aAAa,IAAI,CAAC,CAC3B;AACF;AAEA,SAAgB,mBAAmB,MAIP;CAC1B,OAAO,UACL,OAAO,aAAa,IAAI,CAAC,CAC3B;AACF"}
@@ -0,0 +1,16 @@
1
+ //#region src/is-plain-record.ts
2
+ /**
3
+ * Strict plain-object guard: accepts only objects with `Object.prototype`
4
+ * or `null` as their prototype. Rejects arrays, class instances, and other
5
+ * non-plain objects. Used to distinguish raw-data records from IR class
6
+ * instances in validation and hydration paths.
7
+ */
8
+ function isPlainRecord(value) {
9
+ if (typeof value !== "object" || value === null || Array.isArray(value)) return false;
10
+ const proto = Object.getPrototypeOf(value);
11
+ return proto === Object.prototype || proto === null;
12
+ }
13
+ //#endregion
14
+ export { isPlainRecord as t };
15
+
16
+ //# sourceMappingURL=is-plain-record-CUofyVQ7.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"is-plain-record-CUofyVQ7.mjs","names":[],"sources":["../src/is-plain-record.ts"],"sourcesContent":["/**\n * Strict plain-object guard: accepts only objects with `Object.prototype`\n * or `null` as their prototype. Rejects arrays, class instances, and other\n * non-plain objects. Used to distinguish raw-data records from IR class\n * instances in validation and hydration paths.\n */\nexport function isPlainRecord(value: unknown): value is Readonly<Record<string, unknown>> {\n if (typeof value !== 'object' || value === null || Array.isArray(value)) return false;\n const proto: unknown = Object.getPrototypeOf(value);\n return proto === Object.prototype || proto === null;\n}\n"],"mappings":";;;;;;;AAMA,SAAgB,cAAc,OAA4D;CACxF,IAAI,OAAO,UAAU,YAAY,UAAU,QAAQ,MAAM,QAAQ,KAAK,GAAG,OAAO;CAChF,MAAM,QAAiB,OAAO,eAAe,KAAK;CAClD,OAAO,UAAU,OAAO,aAAa,UAAU;AACjD"}
@@ -0,0 +1,11 @@
1
+ //#region src/is-plain-record.d.ts
2
+ /**
3
+ * Strict plain-object guard: accepts only objects with `Object.prototype`
4
+ * or `null` as their prototype. Rejects arrays, class instances, and other
5
+ * non-plain objects. Used to distinguish raw-data records from IR class
6
+ * instances in validation and hydration paths.
7
+ */
8
+ declare function isPlainRecord(value: unknown): value is Readonly<Record<string, unknown>>;
9
+ //#endregion
10
+ export { isPlainRecord };
11
+ //# sourceMappingURL=is-plain-record.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"is-plain-record.d.mts","names":[],"sources":["../src/is-plain-record.ts"],"mappings":";;AAMA;;;;;iBAAgB,aAAA,CAAc,KAAA,YAAiB,KAAA,IAAS,QAAQ,CAAC,MAAA"}
@@ -0,0 +1,2 @@
1
+ import { t as isPlainRecord } from "./is-plain-record-CUofyVQ7.mjs";
2
+ export { isPlainRecord };
@@ -1,4 +1,4 @@
1
- import { d as ContractModelBase, t as ApplicationDomain } from "./domain-envelope-OkWsysCY.mjs";
1
+ import { d as ContractModelBase, t as ApplicationDomain } from "./domain-envelope-Bj-zQbVU.mjs";
2
2
 
3
3
  //#region src/resolve-domain-model.d.ts
4
4
  interface ResolvedDomainModel {
@@ -14,4 +14,4 @@ interface ResolvedDomainModel {
14
14
  declare function resolveDomainModel(domain: ApplicationDomain, modelName: string): ResolvedDomainModel | undefined;
15
15
  //#endregion
16
16
  export { resolveDomainModel as n, ResolvedDomainModel as t };
17
- //# sourceMappingURL=resolve-domain-model-BhAr8VRJ.d.mts.map
17
+ //# sourceMappingURL=resolve-domain-model-5aHgzqTD.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"resolve-domain-model-BhAr8VRJ.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
+ {"version":3,"file":"resolve-domain-model-5aHgzqTD.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 +1,2 @@
1
- import { n as resolveDomainModel, t as ResolvedDomainModel } from "./resolve-domain-model-BhAr8VRJ.mjs";
1
+ import { n as resolveDomainModel, t as ResolvedDomainModel } from "./resolve-domain-model-5aHgzqTD.mjs";
2
2
  export { type ResolvedDomainModel, resolveDomainModel };
package/dist/types.d.mts CHANGED
@@ -1,8 +1,8 @@
1
- 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-CBbD-VV1.mjs";
2
- import { A as asNamespaceId, C as UnionFieldType, D as CrossReferenceSchema, E as CrossReference, O as crossRef, S as ScalarFieldType, T as ValueSetRef, _ as ContractValueObject, a as ContractEmbedRelation, b as ModelStorageBase, c as ContractFieldType, d as ContractModelBase, f as ContractNonJunctionRelation, g as ContractRelationThrough, h as ContractRelationOn, i as ContractDiscriminator, k as NamespaceId, l as ContractManyToManyRelation, m as ContractRelation, n as ApplicationDomainNamespace, o as ContractEnum, p as ContractReferenceRelation, r as ContractWithDomain, s as ContractField, t as ApplicationDomain, u as ContractModel, v as ContractVariantEntry, w as ValueObjectFieldType, x as ReferenceRelationKeys, y as EmbedRelationKeys } from "./domain-envelope-OkWsysCY.mjs";
1
+ import { a as effectiveControlPolicy, i as ControlPolicy, n as ContractExecutionSection, r as ContractValueObjectDefinitions, t as Contract } from "./contract-types-DrjCtVOs.mjs";
2
+ import { $ as executionHash, A as ColumnDefaultLiteralValue, B as FieldType, C as UnionFieldType, D as Brand, E as $, F as ExecutionMutationDefault, G as PlanMeta, H as JsonPrimitive, I as ExecutionMutationDefaultPhases, J as StorageBase, K as ProfileHashBase, L as ExecutionMutationDefaultValue, M as DocCollection, N as DocIndex, O as ColumnDefault, P as ExecutionHashBase, Q as coreHash, R as ExecutionSection, S as ScalarFieldType, T as ValueSetRef, U as JsonValue, V as GeneratedValueSpec, W as LedgerEntryRecord, X as StorageHashBase, Y as StorageEntitySlot, Z as StorageNamespace, _ as ContractValueObject, a as ContractEmbedRelation, at as CrossReferenceSchema, b as ModelStorageBase, c as ContractFieldType, ct as asNamespaceId, d as ContractModelBase, et as isColumnDefault, f as ContractNonJunctionRelation, g as ContractRelationThrough, h as ContractRelationOn, i as ContractDiscriminator, it as CrossReference, j as ContractMarkerRecord, k as ColumnDefaultLiteralInputValue, l as ContractManyToManyRelation, m as ContractRelation, n as ApplicationDomainNamespace, nt as isExecutionMutationDefaultValue, o as ContractEnum, ot as crossRef, p as ContractReferenceRelation, q as Source, r as ContractWithDomain, rt as profileHash, s as ContractField, st as NamespaceId, t as ApplicationDomain, tt as isColumnDefaultLiteralInputValue, u as ContractModel, v as ContractVariantEntry, w as ValueObjectFieldType, x as ReferenceRelationKeys, y as EmbedRelationKeys, z as Expr } from "./domain-envelope-Bj-zQbVU.mjs";
3
3
  import { n as soleDomainNamespaceId, t as UNBOUND_DOMAIN_NAMESPACE_ID } from "./default-namespace-D5X_k6hJ.mjs";
4
4
  import { r as DomainNamespaceResolutionError } from "./contract-validation-error-D7g0kmcc.mjs";
5
- import { n as resolveDomainModel, t as ResolvedDomainModel } from "./resolve-domain-model-BhAr8VRJ.mjs";
5
+ import { n as resolveDomainModel, t as ResolvedDomainModel } from "./resolve-domain-model-5aHgzqTD.mjs";
6
6
 
7
7
  //#region src/domain-namespace-access.d.ts
8
8
  /**
@@ -10,12 +10,12 @@ import { n as resolveDomainModel, t as ResolvedDomainModel } from "./resolve-dom
10
10
  * contract does not declare exactly one namespace — bare-name access is
11
11
  * ambiguous across namespaces and must be qualified explicitly (TML-2550).
12
12
  */
13
- declare function domainModelsAtDefaultNamespace<TModels extends Record<string, ContractModelBase>>(domain: ApplicationDomain<TModels>): TModels;
13
+ declare function domainModelsAtDefaultNamespace(domain: ApplicationDomain): Record<string, ContractModelBase>;
14
14
  /**
15
15
  * Value objects for the contract's single domain namespace, when present.
16
16
  * Throws when the contract does not declare exactly one namespace.
17
17
  */
18
- declare function domainValueObjectsAtDefaultNamespace<TModels extends Record<string, ContractModelBase>>(domain: ApplicationDomain<TModels>): Record<string, ContractValueObject> | undefined;
18
+ declare function domainValueObjectsAtDefaultNamespace(domain: ApplicationDomain): Record<string, ContractValueObject> | undefined;
19
19
  //#endregion
20
- export { type $, type ApplicationDomain, type ApplicationDomainNamespace, type Brand, type ColumnDefault, type ColumnDefaultLiteralInputValue, type ColumnDefaultLiteralValue, type Contract, type ContractDiscriminator, type ContractEmbedRelation, type ContractEnum, type ContractExecutionSection, type ContractField, type ContractFieldType, type ContractManyToManyRelation, type ContractMarkerRecord, type ContractModel, type ContractModelBase, type ContractModelDefinitions, type ContractNonJunctionRelation, type ContractReferenceRelation, type ContractRelation, type ContractRelationOn, type ContractRelationThrough, 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, type ValueSetRef, asNamespaceId, coreHash, crossRef, domainModelsAtDefaultNamespace, domainValueObjectsAtDefaultNamespace, effectiveControlPolicy, executionHash, isColumnDefault, isColumnDefaultLiteralInputValue, isExecutionMutationDefaultValue, profileHash, resolveDomainModel, soleDomainNamespaceId };
20
+ export { type $, type ApplicationDomain, type ApplicationDomainNamespace, type Brand, type ColumnDefault, type ColumnDefaultLiteralInputValue, type ColumnDefaultLiteralValue, type Contract, type ContractDiscriminator, type ContractEmbedRelation, type ContractEnum, type ContractExecutionSection, type ContractField, type ContractFieldType, type ContractManyToManyRelation, type ContractMarkerRecord, type ContractModel, type ContractModelBase, type ContractNonJunctionRelation, type ContractReferenceRelation, type ContractRelation, type ContractRelationOn, type ContractRelationThrough, 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, type ValueSetRef, asNamespaceId, coreHash, crossRef, domainModelsAtDefaultNamespace, domainValueObjectsAtDefaultNamespace, effectiveControlPolicy, executionHash, isColumnDefault, isColumnDefaultLiteralInputValue, isExecutionMutationDefaultValue, profileHash, resolveDomainModel, soleDomainNamespaceId };
21
21
  //# sourceMappingURL=types.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.mts","names":[],"sources":["../src/domain-namespace-access.ts"],"mappings":";;;;;;;;;;;;iBAUgB,8BAAA,iBAA+C,MAAA,SAAe,iBAAA,GAC5E,MAAA,EAAQ,iBAAA,CAAkB,OAAA,IACzB,OAAA;;;;;iBAea,oCAAA,iBACE,MAAA,SAAe,iBAAA,GAC/B,MAAA,EAAQ,iBAAA,CAAkB,OAAA,IAAW,MAAA,SAAe,mBAAA"}
1
+ {"version":3,"file":"types.d.mts","names":[],"sources":["../src/domain-namespace-access.ts"],"mappings":";;;;;;;;;;;;iBAUgB,8BAAA,CACd,MAAA,EAAQ,iBAAA,GACP,MAAA,SAAe,iBAAA;;;;;iBAeF,oCAAA,CACd,MAAA,EAAQ,iBAAA,GACP,MAAA,SAAe,mBAAA"}
@@ -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 defaultControlPolicy: ControlPolicy | undefined,\n): ControlPolicy {\n return nodeControl ?? defaultControlPolicy ?? '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 * Contract-space identity for cross-space relations. When present, the\n * referenced model lives in a different contract space. Absent for local\n * (same-space) relations.\n */\n readonly space?: 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 'space?': '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 space?: string,\n): CrossReference {\n return {\n namespace: asNamespaceId(namespace),\n model,\n ...(space !== undefined ? { space } : {}),\n };\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 entity-kind slot maps under `entries`\n * (`table`, `collection`, …). Foundation declares only this shape — no IR\n * machinery.\n */\nexport interface StorageNamespace {\n readonly id: string;\n readonly entries: Readonly<Record<string, StorageEntitySlot>>;\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,sBACe;CACf,OAAO,eAAe,wBAAwB;AAChD;;;ACTA,MAAa,uBAAuC,0BAIlC,qBAAK;CACnB,KAAK;CACL,WAAW;CACX,OAAO;CACP,UAAU;AACZ,CAAC,CACH;AAEA,MAAM,8BAA8B;AAEpC,SAAgB,SACd,OACA,YAAoB,6BACpB,OACgB;CAChB,OAAO;EACL,WAAW,cAAc,SAAS;EAClC;EACA,GAAI,UAAU,KAAA,IAAY,EAAE,MAAM,IAAI,CAAC;CACzC;AACF;;;;;;;;AC7BA,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,EAAE,EAAE;AAC3D;;;ACAA,SAAgB,cAAsC,OAAgC;CACpF,OAAO;AACT;AAEA,SAAgB,SAAiC,OAA8B;CAC7E,OAAO;AACT;AASA,SAAgB,YAAoC,OAA8B;CAChF,OAAO;AACT;;;;;;;;;AAiEA,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,CAAC,CAAC,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/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 defaultControlPolicy: ControlPolicy | undefined,\n): ControlPolicy {\n return nodeControl ?? defaultControlPolicy ?? '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 * Contract-space identity for cross-space relations. When present, the\n * referenced model lives in a different contract space. Absent for local\n * (same-space) relations.\n */\n readonly space?: 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 'space?': '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 space?: string,\n): CrossReference {\n return {\n namespace: asNamespaceId(namespace),\n model,\n ...(space !== undefined ? { space } : {}),\n };\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(\n domain: ApplicationDomain,\n): Record<string, ContractModelBase> {\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 domain: ApplicationDomain,\n): 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 entity-kind slot maps under `entries`\n * (`table`, `collection`, …). Foundation declares only this shape — no IR\n * machinery.\n */\nexport interface StorageNamespace {\n readonly id: string;\n readonly entries: Readonly<Record<string, StorageEntitySlot>>;\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 namespace: string; 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,sBACe;CACf,OAAO,eAAe,wBAAwB;AAChD;;;ACTA,MAAa,uBAAuC,0BAIlC,qBAAK;CACnB,KAAK;CACL,WAAW;CACX,OAAO;CACP,UAAU;AACZ,CAAC,CACH;AAEA,MAAM,8BAA8B;AAEpC,SAAgB,SACd,OACA,YAAoB,6BACpB,OACgB;CAChB,OAAO;EACL,WAAW,cAAc,SAAS;EAClC;EACA,GAAI,UAAU,KAAA,IAAY,EAAE,MAAM,IAAI,CAAC;CACzC;AACF;;;;;;;;AC7BA,SAAgB,+BACd,QACmC;CACnC,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,qCACd,QACiD;CACjD,OAAO,OAAO,WAAW,sBAAsB,MAAM,EAAE,EAAE;AAC3D;;;ACAA,SAAgB,cAAsC,OAAgC;CACpF,OAAO;AACT;AAEA,SAAgB,SAAiC,OAA8B;CAC7E,OAAO;AACT;AASA,SAAgB,YAAoC,OAA8B;CAChF,OAAO;AACT;;;;;;;;;AAiEA,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,CAAC,CAAC,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 { E as CrossReference, r as ContractWithDomain } from "./domain-envelope-OkWsysCY.mjs";
1
+ import { it as CrossReference, r as ContractWithDomain } from "./domain-envelope-Bj-zQbVU.mjs";
2
2
 
3
3
  //#region src/validate-domain.d.ts
4
4
  interface DomainModelShape {
package/package.json CHANGED
@@ -1,18 +1,18 @@
1
1
  {
2
2
  "name": "@prisma-next/contract",
3
- "version": "0.13.0",
3
+ "version": "0.14.0-dev.1",
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.13.0",
9
+ "@prisma-next/utils": "0.14.0-dev.1",
10
10
  "@standard-schema/spec": "^1.1.0",
11
11
  "arktype": "^2.2.0"
12
12
  },
13
13
  "devDependencies": {
14
- "@prisma-next/tsconfig": "0.13.0",
15
- "@prisma-next/tsdown": "0.13.0",
14
+ "@prisma-next/tsconfig": "0.14.0-dev.1",
15
+ "@prisma-next/tsdown": "0.14.0-dev.1",
16
16
  "tsdown": "0.22.1",
17
17
  "typescript": "5.9.3",
18
18
  "vitest": "4.1.8"
@@ -34,8 +34,10 @@
34
34
  "./apply-specifier-default-control-policy": "./dist/apply-specifier-default-control-policy.mjs",
35
35
  "./contract-validation-error": "./dist/contract-validation-error.mjs",
36
36
  "./default-namespace": "./dist/default-namespace.mjs",
37
+ "./enum-accessor": "./dist/enum-accessor.mjs",
37
38
  "./hashing": "./dist/hashing.mjs",
38
39
  "./hashing-utils": "./dist/hashing-utils.mjs",
40
+ "./is-plain-record": "./dist/is-plain-record.mjs",
39
41
  "./resolve-domain-model": "./dist/resolve-domain-model.mjs",
40
42
  "./types": "./dist/types.mjs",
41
43
  "./validate-domain": "./dist/validate-domain.mjs",
@@ -1,4 +1,5 @@
1
1
  import type { StorageSort } from './canonicalization';
2
+ import { isPlainRecord } from './is-plain-record';
2
3
 
3
4
  export type PathSegment = string | '*';
4
5
 
@@ -7,10 +8,6 @@ export interface NamedArraySortTarget {
7
8
  readonly arrayKeys: readonly string[];
8
9
  }
9
10
 
10
- function isPlainRecord(value: unknown): value is Record<string, unknown> {
11
- return typeof value === 'object' && value !== null && !Array.isArray(value);
12
- }
13
-
14
11
  // Order by UTF-16 code unit, not locale collation: canonicalization feeds
15
12
  // storageHash, which must be byte-identical across hosts, and locale
16
13
  // collation (localeCompare/Intl) varies by the engine's ICU build.
@@ -1,7 +1,7 @@
1
1
  import type { ControlPolicy } from './control-policy';
2
2
  import type { CrossReference } from './cross-reference';
3
3
  import type { ApplicationDomain } from './domain-envelope';
4
- import type { ContractModelBase, ContractValueObject } from './domain-types';
4
+ import type { ContractValueObject } from './domain-types';
5
5
  import type {
6
6
  ExecutionHashBase,
7
7
  ExecutionMutationDefault,
@@ -37,21 +37,15 @@ export type ContractExecutionSection<THash extends string = string> = {
37
37
  * here — they are handled at the serialization boundary.
38
38
  *
39
39
  * @template TStorage Family-specific storage block (extends {@link StorageBase}).
40
- * @template TModels Record of model name → {@link ContractModel} with
41
- * family-specific model storage.
42
40
  */
43
- export interface Contract<
44
- TStorage extends StorageBase = StorageBase,
45
- TModels extends Record<string, ContractModelBase> = Record<string, ContractModelBase>,
46
- > {
41
+ export interface Contract<TStorage extends StorageBase = StorageBase> {
47
42
  readonly target: string;
48
43
  readonly targetFamily: string;
49
44
  readonly roots: Record<string, CrossReference>;
50
45
  /**
51
46
  * Application plane (ADR 221): `domain.namespaces.<nsId>.{ models, valueObjects }`.
52
- * `TModels` types the union of model entries across namespaces for family DSL inference.
53
47
  */
54
- readonly domain: ApplicationDomain<TModels>;
48
+ readonly domain: ApplicationDomain;
55
49
  readonly storage: TStorage;
56
50
  readonly capabilities: Record<string, Record<string, boolean>>;
57
51
  readonly extensionPacks: Record<string, unknown>;
@@ -61,10 +55,6 @@ export interface Contract<
61
55
  readonly defaultControlPolicy?: ControlPolicy;
62
56
  }
63
57
 
64
- /** Model definitions union carried on a {@link Contract}'s `TModels` type parameter. */
65
- export type ContractModelDefinitions<TContract extends Contract> =
66
- TContract extends Contract<StorageBase, infer TModels> ? TModels : never;
67
-
68
58
  type ExactlyOneNamespace<T extends Record<string, unknown>> = keyof T extends infer Only extends
69
59
  keyof T
70
60
  ? [keyof T] extends [Only]
@@ -6,10 +6,8 @@ export { UNBOUND_DOMAIN_NAMESPACE_ID } from './default-namespace';
6
6
  * One namespace's application-domain entities — models and optional value
7
7
  * objects keyed by entity name within that namespace coordinate.
8
8
  */
9
- export interface ApplicationDomainNamespace<
10
- TModels extends Record<string, ContractModelBase> = Record<string, ContractModelBase>,
11
- > {
12
- readonly models: TModels;
9
+ export interface ApplicationDomainNamespace {
10
+ readonly models: Record<string, ContractModelBase>;
13
11
  readonly valueObjects?: Record<string, ContractValueObject>;
14
12
  readonly enum?: Record<string, ContractEnum>;
15
13
  }
@@ -18,10 +16,8 @@ export interface ApplicationDomainNamespace<
18
16
  * Application-domain envelope: entity content keyed by namespace id.
19
17
  * Mirrors the storage plane's `namespaces` segment (ADR 221).
20
18
  */
21
- export interface ApplicationDomain<
22
- TModels extends Record<string, ContractModelBase> = Record<string, ContractModelBase>,
23
- > {
24
- readonly namespaces: Readonly<Record<string, ApplicationDomainNamespace<TModels>>>;
19
+ export interface ApplicationDomain {
20
+ readonly namespaces: Readonly<Record<string, ApplicationDomainNamespace>>;
25
21
  }
26
22
 
27
23
  export type ContractWithDomain = {
@@ -8,9 +8,9 @@ import type { ContractModelBase, ContractValueObject } from './domain-types';
8
8
  * contract does not declare exactly one namespace — bare-name access is
9
9
  * ambiguous across namespaces and must be qualified explicitly (TML-2550).
10
10
  */
11
- export function domainModelsAtDefaultNamespace<TModels extends Record<string, ContractModelBase>>(
12
- domain: ApplicationDomain<TModels>,
13
- ): TModels {
11
+ export function domainModelsAtDefaultNamespace(
12
+ domain: ApplicationDomain,
13
+ ): Record<string, ContractModelBase> {
14
14
  const namespaceId = soleDomainNamespaceId(domain);
15
15
  const domainNamespace = domain.namespaces[namespaceId];
16
16
  if (domainNamespace === undefined) {
@@ -25,8 +25,8 @@ export function domainModelsAtDefaultNamespace<TModels extends Record<string, Co
25
25
  * Value objects for the contract's single domain namespace, when present.
26
26
  * Throws when the contract does not declare exactly one namespace.
27
27
  */
28
- export function domainValueObjectsAtDefaultNamespace<
29
- TModels extends Record<string, ContractModelBase>,
30
- >(domain: ApplicationDomain<TModels>): Record<string, ContractValueObject> | undefined {
28
+ export function domainValueObjectsAtDefaultNamespace(
29
+ domain: ApplicationDomain,
30
+ ): Record<string, ContractValueObject> | undefined {
31
31
  return domain.namespaces[soleDomainNamespaceId(domain)]?.valueObjects;
32
32
  }
@@ -1,4 +1,5 @@
1
1
  import type { CrossReference } from './cross-reference';
2
+ import type { JsonValue } from './types';
2
3
  import type { ValueSetRef } from './value-set-ref';
3
4
 
4
5
  export type ScalarFieldType = {
@@ -34,7 +35,7 @@ export type ContractField = {
34
35
  */
35
36
  export type ContractEnum = {
36
37
  readonly codecId: string;
37
- readonly members: readonly { readonly name: string; readonly value: string }[];
38
+ readonly members: readonly { readonly name: string; readonly value: JsonValue }[];
38
39
  };
39
40
 
40
41
  export type ContractRelationOn = {