@prisma-next/contract 0.11.0-dev.6 → 0.11.0-dev.61

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 (45) hide show
  1. package/dist/canonicalization-C3dTO0j1.d.mts +69 -0
  2. package/dist/canonicalization-C3dTO0j1.d.mts.map +1 -0
  3. package/dist/{contract-types-Bt2uyqs3.d.mts → contract-types-CZPm4Ooy.d.mts} +27 -6
  4. package/dist/contract-types-CZPm4Ooy.d.mts.map +1 -0
  5. package/dist/contract-validation-error-Dp2vHZt5.mjs.map +1 -1
  6. package/dist/cross-reference-t0TDbBTP.d.mts +18 -0
  7. package/dist/cross-reference-t0TDbBTP.d.mts.map +1 -0
  8. package/dist/{hashing-rZiqFOlc.mjs → hashing-C25nwocN.mjs} +23 -76
  9. package/dist/hashing-C25nwocN.mjs.map +1 -0
  10. package/dist/hashing-utils.d.mts +19 -0
  11. package/dist/hashing-utils.d.mts.map +1 -0
  12. package/dist/hashing-utils.mjs +71 -0
  13. package/dist/hashing-utils.mjs.map +1 -0
  14. package/dist/hashing.d.mts +8 -37
  15. package/dist/hashing.d.mts.map +1 -1
  16. package/dist/hashing.mjs +1 -1
  17. package/dist/testing.d.mts +6 -2
  18. package/dist/testing.d.mts.map +1 -1
  19. package/dist/testing.mjs +4 -2
  20. package/dist/testing.mjs.map +1 -1
  21. package/dist/types-CVGwkRLa.mjs.map +1 -1
  22. package/dist/types.d.mts +3 -2
  23. package/dist/types.mjs +24 -1
  24. package/dist/types.mjs.map +1 -0
  25. package/dist/validate-domain.d.mts +5 -3
  26. package/dist/validate-domain.d.mts.map +1 -1
  27. package/dist/validate-domain.mjs +16 -10
  28. package/dist/validate-domain.mjs.map +1 -1
  29. package/package.json +6 -5
  30. package/src/canonicalization-path-match.ts +44 -0
  31. package/src/canonicalization-storage-sort.ts +88 -0
  32. package/src/canonicalization.ts +57 -142
  33. package/src/contract-types.ts +2 -1
  34. package/src/cross-reference.ts +28 -0
  35. package/src/domain-types.ts +5 -3
  36. package/src/exports/hashing-utils.ts +12 -0
  37. package/src/exports/hashing.ts +2 -0
  38. package/src/exports/types.ts +6 -0
  39. package/src/hashing.ts +27 -10
  40. package/src/namespace-id.ts +10 -0
  41. package/src/testing-factories.ts +7 -1
  42. package/src/types.ts +21 -0
  43. package/src/validate-domain.ts +23 -16
  44. package/dist/contract-types-Bt2uyqs3.d.mts.map +0 -1
  45. package/dist/hashing-rZiqFOlc.mjs.map +0 -1
@@ -0,0 +1,69 @@
1
+ import { t as Contract } from "./contract-types-CZPm4Ooy.mjs";
2
+ import { JsonObject } from "@prisma-next/utils/json";
3
+
4
+ //#region src/canonicalization.d.ts
5
+ /**
6
+ * Per-target contract serializer hook. The framework canonicalizer uses
7
+ * this to convert an in-memory contract (which may carry class-instance
8
+ * IR nodes whose runtime-only fields must not appear in the on-disk
9
+ * envelope) into a plain JsonObject before applying the family-agnostic
10
+ * canonical-key ordering / default-omission / sort steps. Targets whose
11
+ * contract is JSON-clean by construction return the contract unchanged.
12
+ */
13
+ type SerializeContract = (contract: Contract) => JsonObject;
14
+ /**
15
+ * Family-contributed predicate for the default-omission walk. Called when
16
+ * a value at `path` is a default (empty object/array or `false`); if this
17
+ * returns `true` the value is kept rather than stripped.
18
+ *
19
+ * The framework only calls the predicate inside the `isDefaultValue` branch,
20
+ * so there is no need to guard against non-default values.
21
+ */
22
+ type PreserveEmptyPredicate = (path: readonly string[]) => boolean;
23
+ /**
24
+ * Family-contributed storage sort. Applied to the serialized `storage`
25
+ * subtree after the default-omission walk; the result replaces the
26
+ * `storage` field before the final key sort. Use to establish a
27
+ * deterministic order for storage arrays (indexes, uniques) that the
28
+ * family-agnostic `sortObjectKeys` pass cannot handle.
29
+ */
30
+ type StorageSort = (storage: unknown) => unknown;
31
+ interface CanonicalizeContractOptions {
32
+ readonly schemaVersion?: string;
33
+ /**
34
+ * Per-target hook that converts the in-memory contract (which may
35
+ * carry class-instance IR nodes) into a plain JsonObject before the
36
+ * family-agnostic canonicalization steps run.
37
+ *
38
+ * Routing through the hook is what lets each target decide which
39
+ * fields appear in the on-disk envelope; runtime-only class API
40
+ * fields stay invisible to the canonicalization walk by virtue of
41
+ * the per-target serializer not putting them in the JSON shape.
42
+ */
43
+ readonly serializeContract: SerializeContract;
44
+ /**
45
+ * Family-contributed preserve-empty predicate. When the walk encounters a
46
+ * default value (empty object/array or `false`) at `path`, calling this
47
+ * with the full path allows the family to veto the omission. If absent,
48
+ * only the framework's family-agnostic required-slot rules apply.
49
+ */
50
+ readonly shouldPreserveEmpty?: PreserveEmptyPredicate;
51
+ /**
52
+ * Family-contributed storage sort. Applied to the serialized `storage`
53
+ * subtree after the default-omission walk, before the final key sort.
54
+ * SQL family uses this to impose a deterministic order on `indexes` and
55
+ * `uniques` arrays within each namespace table. Families that require no
56
+ * special storage ordering omit this hook.
57
+ */
58
+ readonly sortStorage?: StorageSort;
59
+ }
60
+ /**
61
+ * Object-form variant of {@link canonicalizeContract}. Exported because the
62
+ * emitter writes the canonical contract through a separate JSON-stringify
63
+ * pass and consumes the structured object directly.
64
+ */
65
+ declare function canonicalizeContractToObject(contract: Contract, options: CanonicalizeContractOptions): Record<string, unknown>;
66
+ declare function canonicalizeContract(contract: Contract, options: CanonicalizeContractOptions): string;
67
+ //#endregion
68
+ export { canonicalizeContract as a, StorageSort as i, PreserveEmptyPredicate as n, canonicalizeContractToObject as o, SerializeContract as r, CanonicalizeContractOptions as t };
69
+ //# sourceMappingURL=canonicalization-C3dTO0j1.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"canonicalization-C3dTO0j1.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;AA2J3C;;;;KA3JY,WAAA,IAAe,OAAgB;AAAA,UA2J1B,2BAAA;EAAA,SACN,aAAA;EAAA;;;;;;;;AA0ByB;AAQpC;EAlCW,SAWA,iBAAA,EAAmB,iBAAA;;;;;;;WAOnB,mBAAA,GAAsB,sBAAA;EAiB/B;;;;;AAEO;AA4BT;EA9BE,SATS,WAAA,GAAc,WAAA;AAAA;;;;;;iBAQT,4BAAA,CACd,QAAA,EAAU,QAAA,EACV,OAAA,EAAS,2BAAA,GACR,MAAA;AAAA,iBA4Ba,oBAAA,CACd,QAAA,EAAU,QAAA,EACV,OAAA,EAAS,2BAA2B"}
@@ -1,3 +1,5 @@
1
+ import { t as CrossReference } from "./cross-reference-t0TDbBTP.mjs";
2
+
1
3
  //#region src/domain-types.d.ts
2
4
  type ScalarFieldType = {
3
5
  readonly kind: 'scalar';
@@ -24,12 +26,12 @@ type ContractRelationOn = {
24
26
  readonly targetFields: readonly string[];
25
27
  };
26
28
  type ContractReferenceRelation = {
27
- readonly to: string;
29
+ readonly to: CrossReference;
28
30
  readonly cardinality: '1:1' | '1:N' | 'N:1';
29
31
  readonly on: ContractRelationOn;
30
32
  };
31
33
  type ContractEmbedRelation = {
32
- readonly to: string;
34
+ readonly to: CrossReference;
33
35
  readonly cardinality: '1:1' | '1:N';
34
36
  };
35
37
  type ContractRelation = ContractReferenceRelation | ContractEmbedRelation;
@@ -49,7 +51,7 @@ interface ContractModelBase<TModelStorage extends ModelStorageBase = ModelStorag
49
51
  readonly storage: TModelStorage;
50
52
  readonly discriminator?: ContractDiscriminator;
51
53
  readonly variants?: Record<string, ContractVariantEntry>;
52
- readonly base?: string;
54
+ readonly base?: CrossReference;
53
55
  readonly owner?: string;
54
56
  }
55
57
  interface ContractModel<TModelStorage extends ModelStorageBase = ModelStorageBase> extends ContractModelBase<TModelStorage> {
@@ -98,13 +100,32 @@ declare function coreHash<const T extends string>(value: T): StorageHashBase<T>;
98
100
  */
99
101
  type ProfileHashBase<THash extends string> = THash & Brand<'ProfileHash'>;
100
102
  declare function profileHash<const T extends string>(value: T): ProfileHashBase<T>;
103
+ /**
104
+ * One entity-kind slot in a namespace — a map of entity name to entry.
105
+ * Values are opaque at the foundation layer; family and target concretions
106
+ * refine them to typed IR classes.
107
+ */
108
+ type StorageEntitySlot = Readonly<Record<string, unknown>>;
109
+ /**
110
+ * Plain-data namespace entry in a storage block. Every hydrated contract
111
+ * carries at least `id` plus zero or more entity-kind slot maps (`tables`,
112
+ * `collections`, …). Foundation declares only this shape — no IR machinery.
113
+ */
114
+ interface StorageNamespace {
115
+ readonly id: string;
116
+ }
101
117
  /**
102
118
  * Base type for family-specific storage blocks.
103
119
  * Family storage types (SqlStorage, MongoStorage, etc.) extend this to carry the
104
120
  * storage hash alongside family-specific data (tables, collections, etc.).
121
+ *
122
+ * The `namespaces` map is carried by every hydrated storage block. Serialized
123
+ * envelope shape is target-owned; this types the in-memory contract after
124
+ * `deserializeContract`.
105
125
  */
106
126
  interface StorageBase<THash extends string = string> {
107
127
  readonly storageHash: StorageHashBase<THash>;
128
+ readonly namespaces: Readonly<Record<string, StorageNamespace>>;
108
129
  }
109
130
  interface FieldType {
110
131
  readonly type: string;
@@ -252,7 +273,7 @@ type ContractExecutionSection<THash extends string = string> = {
252
273
  interface Contract<TStorage extends StorageBase = StorageBase, TModels extends Record<string, ContractModelBase> = Record<string, ContractModelBase>> {
253
274
  readonly target: string;
254
275
  readonly targetFamily: string;
255
- readonly roots: Record<string, string>;
276
+ readonly roots: Record<string, CrossReference>;
256
277
  readonly models: TModels;
257
278
  readonly valueObjects?: Record<string, ContractValueObject>;
258
279
  /**
@@ -269,5 +290,5 @@ interface Contract<TStorage extends StorageBase = StorageBase, TModels extends R
269
290
  readonly meta: Record<string, unknown>;
270
291
  }
271
292
  //#endregion
272
- export { isExecutionMutationDefaultValue as A, ContractRelationOn as B, Source as C, executionHash as D, coreHash as E, ContractFieldType as F, ReferenceRelationKeys as G, ContractVariantEntry as H, ContractModel as I, ValueObjectFieldType as J, ScalarFieldType as K, ContractModelBase as L, ContractDiscriminator as M, ContractEmbedRelation as N, isColumnDefault as O, ContractField as P, ContractReferenceRelation as R, ProfileHashBase as S, StorageHashBase as T, EmbedRelationKeys as U, ContractValueObject as V, ModelStorageBase as W, FieldType as _, ColumnDefault as a, JsonValue as b, ContractMarkerRecord as c, ExecutionHashBase as d, ExecutionMutationDefault as f, Expr as g, ExecutionSection as h, Brand as i, profileHash as j, isColumnDefaultLiteralInputValue as k, DocCollection as l, ExecutionMutationDefaultValue as m, ContractExecutionSection as n, ColumnDefaultLiteralInputValue as o, ExecutionMutationDefaultPhases as p, UnionFieldType as q, $ as r, ColumnDefaultLiteralValue as s, Contract as t, DocIndex as u, GeneratedValueSpec as v, StorageBase as w, PlanMeta as x, JsonPrimitive as y, ContractRelation as z };
273
- //# sourceMappingURL=contract-types-Bt2uyqs3.d.mts.map
293
+ export { isColumnDefault as A, ContractReferenceRelation as B, Source as C, StorageNamespace as D, StorageHashBase as E, ContractEmbedRelation as F, EmbedRelationKeys as G, ContractRelationOn as H, ContractField as I, ScalarFieldType as J, ModelStorageBase as K, ContractFieldType as L, isExecutionMutationDefaultValue as M, profileHash as N, coreHash as O, ContractDiscriminator as P, ContractModel as R, ProfileHashBase as S, StorageEntitySlot as T, ContractValueObject as U, ContractRelation as V, ContractVariantEntry as W, ValueObjectFieldType as X, UnionFieldType as Y, FieldType as _, ColumnDefault as a, JsonValue as b, ContractMarkerRecord as c, ExecutionHashBase as d, ExecutionMutationDefault as f, Expr as g, ExecutionSection as h, Brand as i, isColumnDefaultLiteralInputValue as j, executionHash as k, DocCollection as l, ExecutionMutationDefaultValue as m, ContractExecutionSection as n, ColumnDefaultLiteralInputValue as o, ExecutionMutationDefaultPhases as p, ReferenceRelationKeys as q, $ as r, ColumnDefaultLiteralValue as s, Contract as t, DocIndex as u, GeneratedValueSpec as v, StorageBase as w, PlanMeta as x, JsonPrimitive as y, ContractModelBase as z };
294
+ //# sourceMappingURL=contract-types-CZPm4Ooy.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"contract-types-C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AAA;EAAA,SACA,YAAA;EAAA,SACA,KAAA,EAAO,MAAA,SAAe,cAAA;EAAA,SACtB,MAAA,EAAQ,OAAA;EAAA,SACR,YAAA,GAAe,MAAA,SAAe,mBAAA;EF9B8C;;;;;EAAA,SEoC5E,MAAA,GAAS,MAAA,SAAe,MAAA,SAAe,MAAA;EAAA,SACvC,OAAA,EAAS,QAAA;EAAA,SACT,YAAA,EAAc,MAAA,SAAe,MAAA;EAAA,SAC7B,cAAA,EAAgB,MAAA;EAAA,SAChB,SAAA,GAAY,wBAAA;EAAA,SACZ,WAAA,EAAa,eAAA;EAAA,SACb,IAAA,EAAM,MAAA;AAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"contract-validation-error-Dp2vHZt5.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"],"mappings":";AAEA,IAAa,0BAAb,cAA6C,MAAM;CACjD,OAAgB;CAChB;CAEA,YAAY,SAAiB,OAAgC;EAC3D,MAAM,QAAQ;EACd,KAAK,OAAO;EACZ,KAAK,QAAQ"}
1
+ {"version":3,"file":"contract-validation-error-Dp2vHZt5.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"],"mappings":";AAEA,IAAa,0BAAb,cAA6C,MAAM;CACjD,OAAgB;CAChB;CAEA,YAAY,SAAiB,OAAgC;EAC3D,MAAM,OAAO;EACb,KAAK,OAAO;EACZ,KAAK,QAAQ;CACf;AACF"}
@@ -0,0 +1,18 @@
1
+ import * as _$arktype_internal_variants_object_ts0 from "arktype/internal/variants/object.ts";
2
+
3
+ //#region src/namespace-id.d.ts
4
+ type NamespaceId = string & {
5
+ readonly __brand: 'NamespaceId';
6
+ };
7
+ declare function asNamespaceId(value: string): NamespaceId;
8
+ //#endregion
9
+ //#region src/cross-reference.d.ts
10
+ interface CrossReference {
11
+ readonly namespace: NamespaceId;
12
+ readonly model: string;
13
+ }
14
+ declare const CrossReferenceSchema: _$arktype_internal_variants_object_ts0.ObjectType<CrossReference, {}>;
15
+ declare function crossRef(model: string, namespace?: string): CrossReference;
16
+ //#endregion
17
+ export { asNamespaceId as a, NamespaceId as i, CrossReferenceSchema as n, crossRef as r, CrossReference as t };
18
+ //# sourceMappingURL=cross-reference-t0TDbBTP.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cross-reference-t0TDbBTP.d.mts","names":[],"sources":["../src/namespace-id.ts","../src/cross-reference.ts"],"mappings":";;;KAEY,WAAA;EAAA,SAAkC,OAAO;AAAA;AAAA,iBAErC,aAAA,CAAc,KAAA,WAAgB,WAAW;;;UCAxC,cAAA;EAAA,SACN,SAAA,EAAW,WAAW;EAAA,SACtB,KAAA;AAAA;AAAA,cAGE,oBAAA,EAAoB,sCAAA,CAAA,UAAA,CAAA,cAAA;AAAA,iBAajB,QAAA,CACd,KAAA,UACA,SAAA,YACC,cAAc"}
@@ -25,9 +25,9 @@ function isDefaultValue(value) {
25
25
  if (typeof value === "object" && value !== null) return Object.keys(value).length === 0;
26
26
  return false;
27
27
  }
28
- function omitDefaults(obj, path) {
28
+ function omitDefaults(obj, path, shouldPreserveEmpty) {
29
29
  if (obj === null || typeof obj !== "object") return obj;
30
- if (Array.isArray(obj)) return obj.map((item) => omitDefaults(item, path));
30
+ if (Array.isArray(obj)) return obj.map((item) => omitDefaults(item, path, shouldPreserveEmpty));
31
31
  const result = {};
32
32
  for (const [key, value] of Object.entries(obj)) {
33
33
  const currentPath = [...path, key];
@@ -38,8 +38,6 @@ function omitDefaults(obj, path) {
38
38
  const isRequiredModels = isArrayEqual(currentPath, ["models"]);
39
39
  const isRequiredNamespaces = isArrayEqual(currentPath, ["storage", "namespaces"]);
40
40
  const isNamespaceSlot = currentPath.length === 3 && isArrayEqual([currentPath[0], currentPath[1]], ["storage", "namespaces"]);
41
- const isRequiredNamespaceTables = currentPath.length === 4 && currentPath[0] === "storage" && currentPath[1] === "namespaces" && currentPath[3] === "tables";
42
- const isNamespaceTableEntry = currentPath.length === 5 && currentPath[0] === "storage" && currentPath[1] === "namespaces" && currentPath[3] === "tables";
43
41
  const isRequiredRoots = isArrayEqual(currentPath, ["roots"]);
44
42
  const isRequiredExtensionPacks = isArrayEqual(currentPath, ["extensionPacks"]);
45
43
  const isRequiredCapabilities = isArrayEqual(currentPath, ["capabilities"]);
@@ -52,14 +50,12 @@ function omitDefaults(obj, path) {
52
50
  const isExtensionNamespace = currentPath.length === 2 && currentPath[0] === "extensionPacks";
53
51
  const isModelRelations = currentPath.length === 3 && isArrayEqual([currentPath[0], currentPath[2]], ["models", "relations"]);
54
52
  const isModelStorage = currentPath.length === 3 && isArrayEqual([currentPath[0], currentPath[2]], ["models", "storage"]);
55
- const isNamespaceTableUniques = currentPath.length === 6 && currentPath[0] === "storage" && currentPath[1] === "namespaces" && currentPath[3] === "tables" && currentPath[5] === "uniques";
56
- const isNamespaceTableIndexes = currentPath.length === 6 && currentPath[0] === "storage" && currentPath[1] === "namespaces" && currentPath[3] === "tables" && currentPath[5] === "indexes";
57
- const isNamespaceTableForeignKeys = currentPath.length === 6 && currentPath[0] === "storage" && currentPath[1] === "namespaces" && currentPath[3] === "tables" && currentPath[5] === "foreignKeys";
58
- const isStorageTypeTypeParams = currentPath.length === 4 && currentPath[0] === "storage" && currentPath[1] === "types" && key === "typeParams";
59
- const isFkBooleanField = currentPath.length === 7 && currentPath[0] === "storage" && currentPath[1] === "namespaces" && currentPath[3] === "tables" && currentPath[5] === "foreignKeys" && (key === "constraint" || key === "index");
60
- if (!isRequiredModels && !isRequiredNamespaces && !isNamespaceSlot && !isRequiredNamespaceTables && !isNamespaceTableEntry && !isRequiredRoots && !isRequiredExtensionPacks && !isRequiredCapabilities && !isRequiredMeta && !isRequiredExecutionDefaults && !isExtensionNamespace && !isModelRelations && !isModelStorage && !isNamespaceTableUniques && !isNamespaceTableIndexes && !isNamespaceTableForeignKeys && !isFkBooleanField && !(key === "nullable") && !isStorageTypeTypeParams) continue;
53
+ const isDomainUnboundTypeParams = currentPath.length === 5 && currentPath[0] === "domain" && currentPath[2] === "types" && key === "typeParams";
54
+ const isNullableField = key === "nullable";
55
+ const isFamilyPreserved = shouldPreserveEmpty?.(currentPath) ?? false;
56
+ if (!isRequiredModels && !isRequiredNamespaces && !isNamespaceSlot && !isRequiredRoots && !isRequiredExtensionPacks && !isRequiredCapabilities && !isRequiredMeta && !isRequiredExecutionDefaults && !isExtensionNamespace && !isModelRelations && !isModelStorage && !isNullableField && !isDomainUnboundTypeParams && !isFamilyPreserved) continue;
61
57
  }
62
- result[key] = omitDefaults(value, currentPath);
58
+ result[key] = omitDefaults(value, currentPath, shouldPreserveEmpty);
63
59
  }
64
60
  return result;
65
61
  }
@@ -71,58 +67,6 @@ function sortObjectKeys(obj) {
71
67
  for (const key of keys) sorted[key] = sortObjectKeys(obj[key]);
72
68
  return sorted;
73
69
  }
74
- function sortTableArrays(tableObj) {
75
- const sortedTable = { ...tableObj };
76
- if (Array.isArray(tableObj.indexes)) sortedTable.indexes = [...tableObj.indexes].sort((a, b) => {
77
- const nameA = a?.name || "";
78
- const nameB = b?.name || "";
79
- return nameA.localeCompare(nameB);
80
- });
81
- if (Array.isArray(tableObj.uniques)) sortedTable.uniques = [...tableObj.uniques].sort((a, b) => {
82
- const nameA = a?.name || "";
83
- const nameB = b?.name || "";
84
- return nameA.localeCompare(nameB);
85
- });
86
- return sortedTable;
87
- }
88
- function sortIndexesAndUniques(storage) {
89
- if (!storage || typeof storage !== "object") return storage;
90
- const storageObj = storage;
91
- if (!storageObj.namespaces || typeof storageObj.namespaces !== "object") return storage;
92
- const namespaces = storageObj.namespaces;
93
- const result = {
94
- ...storageObj,
95
- namespaces: {}
96
- };
97
- const resultNamespaces = result.namespaces;
98
- for (const nsId of Object.keys(namespaces)) {
99
- const ns = namespaces[nsId];
100
- if (!ns || typeof ns !== "object") {
101
- resultNamespaces[nsId] = ns;
102
- continue;
103
- }
104
- const nsObj = ns;
105
- if (!nsObj.tables || typeof nsObj.tables !== "object") {
106
- resultNamespaces[nsId] = ns;
107
- continue;
108
- }
109
- const sortedTables = {};
110
- const sortedTableNames = Object.keys(nsObj.tables).sort();
111
- for (const tableName of sortedTableNames) {
112
- const table = nsObj.tables[tableName];
113
- if (!table || typeof table !== "object") {
114
- sortedTables[tableName] = table;
115
- continue;
116
- }
117
- sortedTables[tableName] = sortTableArrays(table);
118
- }
119
- resultNamespaces[nsId] = {
120
- ...nsObj,
121
- tables: sortedTables
122
- };
123
- }
124
- return result;
125
- }
126
70
  function orderTopLevel(obj) {
127
71
  const ordered = {};
128
72
  const remaining = new Set(Object.keys(obj));
@@ -148,17 +92,17 @@ function canonicalizeContractToObject(contract, options) {
148
92
  roots: serialized["roots"],
149
93
  models: serialized["models"],
150
94
  ...ifDefined("valueObjects", serialized["valueObjects"]),
95
+ ...ifDefined("domain", serialized["domain"]),
151
96
  storage: serialized["storage"],
152
97
  ...ifDefined("execution", serialized["execution"]),
153
98
  extensionPacks: serialized["extensionPacks"],
154
99
  capabilities: serialized["capabilities"],
155
100
  meta: serialized["meta"]
156
- }, []);
157
- const withSortedIndexes = sortIndexesAndUniques(withDefaultsOmitted["storage"]);
158
- return orderTopLevel(sortObjectKeys({
101
+ }, [], options.shouldPreserveEmpty);
102
+ return orderTopLevel(sortObjectKeys(options.sortStorage ? {
159
103
  ...withDefaultsOmitted,
160
- storage: withSortedIndexes
161
- }));
104
+ storage: options.sortStorage(withDefaultsOmitted["storage"])
105
+ } : withDefaultsOmitted));
162
106
  }
163
107
  function canonicalizeContract(contract, options) {
164
108
  return JSON.stringify(canonicalizeContractToObject(contract, options), null, 2);
@@ -172,21 +116,24 @@ function sha256(content) {
172
116
  return `sha256:${hash.digest("hex")}`;
173
117
  }
174
118
  function hashContract(section) {
119
+ const { shouldPreserveEmpty, sortStorage, ...sectionData } = section;
175
120
  return canonicalizeContract({
176
- targetFamily: section["targetFamily"],
177
- target: section["target"],
121
+ targetFamily: sectionData["targetFamily"],
122
+ target: sectionData["target"],
178
123
  roots: {},
179
124
  models: {},
180
- storage: section["storage"] ?? {},
181
- execution: section["execution"],
125
+ storage: sectionData["storage"] ?? {},
126
+ execution: sectionData["execution"],
182
127
  extensionPacks: {},
183
- capabilities: section["capabilities"] ?? {},
128
+ capabilities: sectionData["capabilities"] ?? {},
184
129
  meta: {},
185
130
  profileHash: "",
186
- ...section
131
+ ...sectionData
187
132
  }, {
188
133
  schemaVersion: SCHEMA_VERSION,
189
- serializeContract: (c) => JSON.parse(JSON.stringify(c))
134
+ serializeContract: (c) => JSON.parse(JSON.stringify(c)),
135
+ ...ifDefined("shouldPreserveEmpty", shouldPreserveEmpty),
136
+ ...ifDefined("sortStorage", sortStorage)
190
137
  });
191
138
  }
192
139
  function computeStorageHash(args) {
@@ -201,4 +148,4 @@ function computeProfileHash(args) {
201
148
  //#endregion
202
149
  export { canonicalizeContractToObject as a, canonicalizeContract as i, computeProfileHash as n, computeStorageHash as r, computeExecutionHash as t };
203
150
 
204
- //# sourceMappingURL=hashing-rZiqFOlc.mjs.map
151
+ //# sourceMappingURL=hashing-C25nwocN.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hashing-C25nwocN.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';\n\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 TOP_LEVEL_ORDER = [\n 'schemaVersion',\n 'canonicalVersion',\n 'targetFamily',\n 'target',\n 'profileHash',\n 'roots',\n 'models',\n 'valueObjects',\n 'domain',\n 'storage',\n 'execution',\n 'capabilities',\n 'extensionPacks',\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 isRequiredModels = isArrayEqual(currentPath, ['models']);\n const isRequiredNamespaces = isArrayEqual(currentPath, ['storage', 'namespaces']);\n const isNamespaceSlot =\n currentPath.length === 3 &&\n isArrayEqual([currentPath[0], currentPath[1]], ['storage', 'namespaces']);\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 =\n currentPath.length === 3 &&\n isArrayEqual([currentPath[0], currentPath[2]], ['models', 'relations']);\n const isModelStorage =\n currentPath.length === 3 &&\n isArrayEqual([currentPath[0], currentPath[2]], ['models', 'storage']);\n\n const isDomainUnboundTypeParams =\n currentPath.length === 5 &&\n currentPath[0] === 'domain' &&\n currentPath[2] === 'types' &&\n key === 'typeParams';\n\n const isNullableField = key === 'nullable';\n\n const isFamilyPreserved = shouldPreserveEmpty?.(currentPath) ?? false;\n\n if (\n !isRequiredModels &&\n !isRequiredNamespaces &&\n !isNamespaceSlot &&\n !isRequiredRoots &&\n !isRequiredExtensionPacks &&\n !isRequiredCapabilities &&\n !isRequiredMeta &&\n !isRequiredExecutionDefaults &&\n !isExtensionNamespace &&\n !isModelRelations &&\n !isModelStorage &&\n !isNullableField &&\n !isDomainUnboundTypeParams &&\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 models: serialized['models'],\n ...ifDefined('valueObjects', serialized['valueObjects']),\n ...ifDefined('domain', serialized['domain']),\n storage: serialized['storage'],\n ...ifDefined('execution', serialized['execution']),\n extensionPacks: serialized['extensionPacks'],\n capabilities: serialized['capabilities'],\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 { 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 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 // Blind cast: the synthesised object is a hash-only stand-in\n // — never returned to callers, never executed as a Contract.\n // `canonicalizeContract` only walks the storage / execution /\n // capabilities slices, all of which are populated above, so the\n // missing precise Contract typing on the other slots is\n // immaterial for the hash result.\n const contract = {\n targetFamily: sectionData['targetFamily'],\n target: sectionData['target'],\n roots: {},\n models: {},\n storage: sectionData['storage'] ?? {},\n execution: sectionData['execution'],\n extensionPacks: {},\n capabilities: sectionData['capabilities'] ?? {},\n meta: {},\n profileHash: '',\n ...sectionData,\n } as unknown as Contract;\n return canonicalizeContract(contract, {\n schemaVersion: SCHEMA_VERSION,\n serializeContract: (c) => JSON.parse(JSON.stringify(c)) as JsonObject,\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 sha256(hashContract(args)) as StorageHashBase<string>;\n}\n\nexport function computeExecutionHash(args: {\n target: string;\n targetFamily: string;\n execution: Record<string, unknown>;\n}): ExecutionHashBase<string> {\n return sha256(hashContract(args)) as ExecutionHashBase<string>;\n}\n\nexport function computeProfileHash(args: {\n target: string;\n targetFamily: string;\n capabilities: Record<string, Record<string, boolean>>;\n}): ProfileHashBase<string> {\n return sha256(hashContract(args)) as ProfileHashBase<string>;\n}\n"],"mappings":";;;;AAmCA,MAAM,kBAAkB;CACtB;CACA;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,EAAE,WAAW;CAEzB,OAAO;AACT;AAEA,SAAS,aACP,KACA,MACA,qBACS;CACT,IAAI,QAAQ,QAAQ,OAAO,QAAQ,UACjC,OAAO;CAGT,IA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
+ import { i as StorageSort, n as PreserveEmptyPredicate } from "./canonicalization-C3dTO0j1.mjs";
2
+
3
+ //#region src/canonicalization-path-match.d.ts
4
+ type PathSegment = string | '*' | readonly string[];
5
+ type PathPattern = readonly PathSegment[];
6
+ declare function matchesPathPattern(path: readonly string[], pattern: PathPattern): boolean;
7
+ declare function createPreserveEmptyPredicate(patterns: readonly PathPattern[]): PreserveEmptyPredicate;
8
+ //#endregion
9
+ //#region src/canonicalization-storage-sort.d.ts
10
+ type PathSegment$1 = string | '*';
11
+ interface NamedArraySortTarget {
12
+ readonly path: readonly PathSegment$1[];
13
+ readonly arrayKeys: readonly string[];
14
+ }
15
+ declare function compareByNameProperty(a: unknown, b: unknown): number;
16
+ declare function createStorageSort(targets: readonly NamedArraySortTarget[], compare?: (a: unknown, b: unknown) => number): StorageSort;
17
+ //#endregion
18
+ export { type NamedArraySortTarget, type PathPattern, type PathSegment as PreserveEmptyPathSegment, type PathSegment$1 as StorageSortPathSegment, compareByNameProperty, createPreserveEmptyPredicate, createStorageSort, matchesPathPattern };
19
+ //# sourceMappingURL=hashing-utils.d.mts.map
@@ -0,0 +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,iBAOK,qBAAA,CAAsB,CAAA,WAAY,CAAU;AAAA,iBA2D5C,iBAAA,CACd,OAAA,WAAkB,oBAAA,IAClB,OAAA,IAAU,CAAA,WAAY,CAAA,uBACrB,WAAW"}
@@ -0,0 +1,71 @@
1
+ //#region src/canonicalization-path-match.ts
2
+ function matchesPathPattern(path, pattern) {
3
+ if (path.length !== pattern.length) return false;
4
+ for (let i = 0; i < pattern.length; i++) {
5
+ const segment = pattern[i];
6
+ const value = path[i];
7
+ if (segment === void 0 || value === void 0) return false;
8
+ if (segment === "*") continue;
9
+ if (typeof segment === "string") {
10
+ if (value !== segment) return false;
11
+ continue;
12
+ }
13
+ if (Array.isArray(segment)) {
14
+ if (!segment.includes(value)) return false;
15
+ }
16
+ }
17
+ return true;
18
+ }
19
+ function createPreserveEmptyPredicate(patterns) {
20
+ return (path) => patterns.some((pattern) => matchesPathPattern(path, pattern));
21
+ }
22
+ //#endregion
23
+ //#region src/canonicalization-storage-sort.ts
24
+ function isPlainRecord(value) {
25
+ return typeof value === "object" && value !== null && !Array.isArray(value);
26
+ }
27
+ function compareByNameProperty(a, b) {
28
+ const nameA = isPlainRecord(a) && typeof a["name"] === "string" ? a["name"] : "";
29
+ const nameB = isPlainRecord(b) && typeof b["name"] === "string" ? b["name"] : "";
30
+ return nameA.localeCompare(nameB);
31
+ }
32
+ function sortArrayKeysOnRecord(record, arrayKeys, compare) {
33
+ const sorted = { ...record };
34
+ for (const key of arrayKeys) {
35
+ const value = record[key];
36
+ if (Array.isArray(value)) sorted[key] = [...value].sort(compare);
37
+ }
38
+ return sorted;
39
+ }
40
+ function walkAndSort(node, pathSegments, arrayKeys, compare) {
41
+ if (pathSegments.length === 0) {
42
+ if (!isPlainRecord(node)) return node;
43
+ return sortArrayKeysOnRecord(node, arrayKeys, compare);
44
+ }
45
+ if (!isPlainRecord(node)) return node;
46
+ const [head, ...rest] = pathSegments;
47
+ if (head === void 0) return node;
48
+ if (head === "*") {
49
+ const sorted = { ...node };
50
+ for (const key of Object.keys(node)) sorted[key] = walkAndSort(node[key], rest, arrayKeys, compare);
51
+ return sorted;
52
+ }
53
+ const child = node[head];
54
+ if (child === void 0) return node;
55
+ return {
56
+ ...node,
57
+ [head]: walkAndSort(child, rest, arrayKeys, compare)
58
+ };
59
+ }
60
+ function createStorageSort(targets, compare = compareByNameProperty) {
61
+ return (storage) => {
62
+ if (!isPlainRecord(storage)) return storage;
63
+ let result = storage;
64
+ for (const target of targets) result = walkAndSort(result, target.path, target.arrayKeys, compare);
65
+ return result;
66
+ };
67
+ }
68
+ //#endregion
69
+ export { compareByNameProperty, createPreserveEmptyPredicate, createStorageSort, matchesPathPattern };
70
+
71
+ //# sourceMappingURL=hashing-utils.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hashing-utils.mjs","names":[],"sources":["../src/canonicalization-path-match.ts","../src/canonicalization-storage-sort.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","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\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 nameA.localeCompare(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":";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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AAQ,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,44 +1,15 @@
1
- import { S as ProfileHashBase, T as StorageHashBase, d as ExecutionHashBase, t as Contract } from "./contract-types-Bt2uyqs3.mjs";
2
- import { JsonObject } from "@prisma-next/utils/json";
1
+ import { E as StorageHashBase, S as ProfileHashBase, d as ExecutionHashBase } from "./contract-types-CZPm4Ooy.mjs";
2
+ import { a as canonicalizeContract, i as StorageSort, n as PreserveEmptyPredicate, o as canonicalizeContractToObject, r as SerializeContract, t as CanonicalizeContractOptions } from "./canonicalization-C3dTO0j1.mjs";
3
3
 
4
- //#region src/canonicalization.d.ts
5
- /**
6
- * Per-target contract serializer hook. The framework canonicalizer uses
7
- * this to convert an in-memory contract (which may carry class-instance
8
- * IR nodes whose runtime-only fields must not appear in the on-disk
9
- * envelope) into a plain JsonObject before applying the family-agnostic
10
- * canonical-key ordering / default-omission / sort steps. Targets whose
11
- * contract is JSON-clean by construction return the contract unchanged.
12
- */
13
- type SerializeContract = (contract: Contract) => JsonObject;
14
- interface CanonicalizeContractOptions {
15
- readonly schemaVersion?: string;
16
- /**
17
- * Per-target hook that converts the in-memory contract (which may
18
- * carry class-instance IR nodes) into a plain JsonObject before the
19
- * family-agnostic canonicalization steps run.
20
- *
21
- * Routing through the hook is what lets each target decide which
22
- * fields appear in the on-disk envelope; runtime-only class API
23
- * fields stay invisible to the canonicalization walk by virtue of
24
- * the per-target serializer not putting them in the JSON shape.
25
- */
26
- readonly serializeContract: SerializeContract;
27
- }
28
- /**
29
- * Object-form variant of {@link canonicalizeContract}. Exported because the
30
- * emitter writes the canonical contract through a separate JSON-stringify
31
- * pass and consumes the structured object directly.
32
- */
33
- declare function canonicalizeContractToObject(contract: Contract, options: CanonicalizeContractOptions): Record<string, unknown>;
34
- declare function canonicalizeContract(contract: Contract, options: CanonicalizeContractOptions): string;
35
- //#endregion
36
4
  //#region src/hashing.d.ts
37
- declare function computeStorageHash(args: {
5
+ type ComputeStorageHashArgs = {
38
6
  target: string;
39
7
  targetFamily: string;
40
8
  storage: Record<string, unknown>;
41
- }): StorageHashBase<string>;
9
+ readonly shouldPreserveEmpty?: PreserveEmptyPredicate;
10
+ readonly sortStorage?: StorageSort;
11
+ };
12
+ declare function computeStorageHash(args: ComputeStorageHashArgs): StorageHashBase<string>;
42
13
  declare function computeExecutionHash(args: {
43
14
  target: string;
44
15
  targetFamily: string;
@@ -50,5 +21,5 @@ declare function computeProfileHash(args: {
50
21
  capabilities: Record<string, Record<string, boolean>>;
51
22
  }): ProfileHashBase<string>;
52
23
  //#endregion
53
- export { type CanonicalizeContractOptions, type SerializeContract, canonicalizeContract, canonicalizeContractToObject, computeExecutionHash, computeProfileHash, computeStorageHash };
24
+ export { type CanonicalizeContractOptions, type PreserveEmptyPredicate, type SerializeContract, type StorageSort, canonicalizeContract, canonicalizeContractToObject, computeExecutionHash, computeProfileHash, computeStorageHash };
54
25
  //# sourceMappingURL=hashing.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"hashing.d.mts","names":[],"sources":["../src/canonicalization.ts","../src/hashing.ts"],"mappings":";;;;;;AAcA;;;;;;KAAY,iBAAA,IAAqB,QAAA,EAAU,QAAA,KAAa,UAAA;AAAA,UAuRvC,2BAAA;EAAA,SACN,aAAA;EADiC;;;;;;;;AAoB5C;;EApB4C,SAYjC,iBAAA,EAAmB,iBAAA;AAAA;;;;;;iBAQd,4BAAA,CACd,QAAA,EAAU,QAAA,EACV,OAAA,EAAS,2BAAA,GACR,MAAA;AAAA,iBAuBa,oBAAA,CACd,QAAA,EAAU,QAAA,EACV,OAAA,EAAS,2BAAA;;;iBC7SK,kBAAA,CAAmB,IAAA;EACjC,MAAA;EACA,YAAA;EACA,OAAA,EAAS,MAAA;AAAA,IACP,eAAA;AAAA,iBAIY,oBAAA,CAAqB,IAAA;EACnC,MAAA;EACA,YAAA;EACA,SAAA,EAAW,MAAA;AAAA,IACT,iBAAA;AAAA,iBAIY,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":";;;;KAqDY,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,iBAIjE,oBAAA,CAAqB,IAAA;EACnC,MAAA;EACA,YAAA;EACA,SAAA,EAAW,MAAA;AAAA,IACT,iBAAiB;AAAA,iBAIL,kBAAA,CAAmB,IAAA;EACjC,MAAA;EACA,YAAA;EACA,YAAA,EAAc,MAAA,SAAe,MAAA;AAAA,IAC3B,eAAA"}
package/dist/hashing.mjs CHANGED
@@ -1,2 +1,2 @@
1
- import { a as canonicalizeContractToObject, i as canonicalizeContract, n as computeProfileHash, r as computeStorageHash, t as computeExecutionHash } from "./hashing-rZiqFOlc.mjs";
1
+ import { a as canonicalizeContractToObject, i as canonicalizeContract, n as computeProfileHash, r as computeStorageHash, t as computeExecutionHash } from "./hashing-C25nwocN.mjs";
2
2
  export { canonicalizeContract, canonicalizeContractToObject, computeExecutionHash, computeProfileHash, computeStorageHash };
@@ -1,10 +1,12 @@
1
- import { I as ContractModel, L as ContractModelBase, S as ProfileHashBase, T as StorageHashBase, V as ContractValueObject, W as ModelStorageBase, h as ExecutionSection, t as Contract, w as StorageBase } from "./contract-types-Bt2uyqs3.mjs";
1
+ import { t as CrossReference } from "./cross-reference-t0TDbBTP.mjs";
2
+ import { E as StorageHashBase, K as ModelStorageBase, R as ContractModel, S as ProfileHashBase, U as ContractValueObject, h as ExecutionSection, t as Contract, w as StorageBase, z as ContractModelBase } from "./contract-types-CZPm4Ooy.mjs";
3
+ import { i as StorageSort, n as PreserveEmptyPredicate } from "./canonicalization-C3dTO0j1.mjs";
2
4
 
3
5
  //#region src/testing-factories.d.ts
4
6
  type ContractOverrides<TStorage extends StorageBase = StorageBase, TModels extends Record<string, ContractModelBase> = Record<string, ContractModel>> = {
5
7
  target?: string;
6
8
  targetFamily?: string;
7
- roots?: Record<string, string>;
9
+ roots?: Record<string, CrossReference>;
8
10
  models?: TModels;
9
11
  storage?: Omit<TStorage, 'storageHash'>;
10
12
  valueObjects?: Record<string, ContractValueObject>;
@@ -13,6 +15,8 @@ type ContractOverrides<TStorage extends StorageBase = StorageBase, TModels exten
13
15
  execution?: Omit<ExecutionSection, 'executionHash'>;
14
16
  profileHash?: ProfileHashBase<string>;
15
17
  meta?: Record<string, unknown>;
18
+ shouldPreserveEmpty?: PreserveEmptyPredicate;
19
+ sortStorage?: StorageSort;
16
20
  };
17
21
  declare const DUMMY_HASH: StorageHashBase<"sha256:test">;
18
22
  declare function createContract<TStorage extends StorageBase = StorageBase, TModels extends Record<string, ContractModelBase> = Record<string, ContractModel>>(overrides?: ContractOverrides<TStorage, TModels>): Contract<TStorage, TModels>;
@@ -1 +1 @@
1
- {"version":3,"file":"testing.d.mts","names":[],"sources":["../src/testing-factories.ts"],"mappings":";;;KAYK,iBAAA,kBACc,WAAA,GAAc,WAAA,kBACf,MAAA,SAAe,iBAAA,IAAqB,MAAA,SAAe,aAAA;EAEnE,MAAA;EACA,YAAA;EACA,KAAA,GAAQ,MAAA;EACR,MAAA,GAAS,OAAA;EACT,OAAA,GAAU,IAAA,CAAK,QAAA;EACf,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