@prisma-next/contract 0.3.0-dev.142 → 0.3.0-dev.144

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 (40) hide show
  1. package/dist/{types-DmKtoEd-.d.mts → contract-types-Cd9ic3zL.d.mts} +46 -46
  2. package/dist/contract-types-Cd9ic3zL.d.mts.map +1 -0
  3. package/dist/{hashing-D1EPxYRl.mjs → hashing-BHjb-IPM.mjs} +34 -51
  4. package/dist/hashing-BHjb-IPM.mjs.map +1 -0
  5. package/dist/hashing.d.mts +8 -17
  6. package/dist/hashing.d.mts.map +1 -1
  7. package/dist/hashing.mjs +1 -1
  8. package/dist/testing.d.mts +1 -2
  9. package/dist/testing.d.mts.map +1 -1
  10. package/dist/testing.mjs +2 -2
  11. package/dist/{types-DYikGC04.mjs → types-BP4dqfP-.mjs} +2 -8
  12. package/dist/types-BP4dqfP-.mjs.map +1 -0
  13. package/dist/types.d.mts +2 -3
  14. package/dist/types.mjs +2 -2
  15. package/dist/validate-contract.d.mts +10 -8
  16. package/dist/validate-contract.d.mts.map +1 -1
  17. package/dist/validate-contract.mjs +2 -60
  18. package/dist/{validate-domain-CTQiBiei.mjs → validate-domain-BlwWyv01.mjs} +70 -17
  19. package/dist/validate-domain-BlwWyv01.mjs.map +1 -0
  20. package/dist/validate-domain.d.mts +2 -5
  21. package/dist/validate-domain.d.mts.map +1 -1
  22. package/dist/validate-domain.mjs +1 -1
  23. package/package.json +2 -2
  24. package/src/canonicalization.ts +25 -40
  25. package/src/domain-types.ts +0 -17
  26. package/src/exports/hashing.ts +1 -5
  27. package/src/exports/types.ts +0 -12
  28. package/src/exports/validate-contract.ts +2 -1
  29. package/src/exports/validate-domain.ts +0 -1
  30. package/src/hashing.ts +21 -37
  31. package/src/types.ts +0 -50
  32. package/src/validate-contract.ts +25 -19
  33. package/src/validate-domain.ts +7 -47
  34. package/dist/contract-types-x89nqTli.d.mts +0 -49
  35. package/dist/contract-types-x89nqTli.d.mts.map +0 -1
  36. package/dist/hashing-D1EPxYRl.mjs.map +0 -1
  37. package/dist/types-DYikGC04.mjs.map +0 -1
  38. package/dist/types-DmKtoEd-.d.mts.map +0 -1
  39. package/dist/validate-contract.mjs.map +0 -1
  40. package/dist/validate-domain-CTQiBiei.mjs.map +0 -1
@@ -33,22 +33,6 @@ interface ContractModel<TModelStorage extends ModelStorageBase = ModelStorageBas
33
33
  readonly base?: string;
34
34
  readonly owner?: string;
35
35
  }
36
- /** @deprecated Use {@link ContractField} */
37
- type DomainField = ContractField;
38
- /** @deprecated Use {@link ContractRelationOn} */
39
- type DomainRelationOn = ContractRelationOn;
40
- /** @deprecated Use {@link ContractReferenceRelation} */
41
- type DomainReferenceRelation = ContractReferenceRelation;
42
- /** @deprecated Use {@link ContractEmbedRelation} */
43
- type DomainEmbedRelation = ContractEmbedRelation;
44
- /** @deprecated Use {@link ContractRelation} */
45
- type DomainRelation = ContractRelation;
46
- /** @deprecated Use {@link ContractDiscriminator} */
47
- type DomainDiscriminator = ContractDiscriminator;
48
- /** @deprecated Use {@link ContractVariantEntry} */
49
- type DomainVariantEntry = ContractVariantEntry;
50
- /** @deprecated Use {@link ContractModel} */
51
- type DomainModel = ContractModel;
52
36
  type HasModelsWithRelations = {
53
37
  readonly models: Record<string, {
54
38
  readonly relations: Record<string, ContractRelation>;
@@ -100,21 +84,6 @@ declare function profileHash<const T extends string>(value: T): ProfileHashBase<
100
84
  interface StorageBase<THash extends string = string> {
101
85
  readonly storageHash: StorageHashBase<THash>;
102
86
  }
103
- interface ContractBase<TStorageHash extends StorageHashBase<string> = StorageHashBase<string>, TExecutionHash extends ExecutionHashBase<string> = ExecutionHashBase<string>, TProfileHash extends ProfileHashBase<string> = ProfileHashBase<string>> {
104
- readonly schemaVersion: string;
105
- readonly target: string;
106
- readonly targetFamily: string;
107
- readonly storageHash: TStorageHash;
108
- readonly executionHash?: TExecutionHash | undefined;
109
- readonly profileHash?: TProfileHash | undefined;
110
- readonly capabilities: Record<string, Record<string, boolean>>;
111
- readonly extensionPacks: Record<string, unknown>;
112
- readonly meta: Record<string, unknown>;
113
- readonly sources: Record<string, Source>;
114
- readonly execution?: ExecutionSection;
115
- readonly roots: Record<string, string>;
116
- readonly models: Record<string, DomainModel>;
117
- }
118
87
  interface FieldType {
119
88
  readonly type: string;
120
89
  readonly nullable: boolean;
@@ -198,15 +167,6 @@ interface DocCollection {
198
167
  readonly indexes?: ReadonlyArray<DocIndex>;
199
168
  readonly readOnly?: boolean;
200
169
  }
201
- interface DocumentStorage {
202
- readonly document: {
203
- readonly collections: Record<string, DocCollection>;
204
- };
205
- }
206
- interface DocumentContract<TStorageHash extends StorageHashBase<string> = StorageHashBase<string>, TExecutionHash extends ExecutionHashBase<string> = ExecutionHashBase<string>, TProfileHash extends ProfileHashBase<string> = ProfileHashBase<string>> extends ContractBase<TStorageHash, TExecutionHash, TProfileHash> {
207
- readonly targetFamily: string;
208
- readonly storage: DocumentStorage;
209
- }
210
170
  interface ParamDescriptor {
211
171
  readonly index?: number;
212
172
  readonly name?: string;
@@ -281,10 +241,6 @@ interface ExecutionPlan<Row = unknown, Ast = unknown> {
281
241
  type ResultType<P> = P extends ExecutionPlan<infer R, unknown> ? R : P extends {
282
242
  readonly _Row?: infer R;
283
243
  } ? R : never;
284
- /**
285
- * Type guard to check if a contract is a Document contract
286
- */
287
- declare function isDocumentContract(contract: unknown): contract is DocumentContract;
288
244
  /**
289
245
  * Contract marker record stored in the database.
290
246
  * Represents the current contract identity for a database.
@@ -299,5 +255,49 @@ interface ContractMarkerRecord {
299
255
  readonly meta: Record<string, unknown>;
300
256
  }
301
257
  //#endregion
302
- export { DomainRelation as $, TaggedBigInt as A, ContractDiscriminator as B, PlanMeta as C, Source as D, ResultType as E, executionHash as F, ContractRelation as G, ContractField as H, isDocumentContract as I, DomainDiscriminator as J, ContractRelationOn as K, isTaggedBigInt as L, TaggedRaw as M, bigintJsonReplacer as N, StorageBase as O, coreHash as P, DomainReferenceRelation as Q, isTaggedRaw as R, ParamDescriptor as S, ProfileHashBase as T, ContractModel as U, ContractEmbedRelation as V, ContractReferenceRelation as W, DomainField as X, DomainEmbedRelation as Y, DomainModel as Z, Expr as _, ColumnDefaultLiteralValue as a, JsonPrimitive as b, DocCollection as c, DocumentStorage as d, DomainRelationOn as et, ExecutionHashBase as f, ExecutionSection as g, ExecutionPlan as h, ColumnDefaultLiteralInputValue as i, ReferenceRelationKeys as it, TaggedLiteralValue as j, StorageHashBase as k, DocIndex as l, ExecutionMutationDefaultValue as m, Brand as n, EmbedRelationKeys as nt, ContractBase as o, ExecutionMutationDefault as p, ContractVariantEntry as q, ColumnDefault as r, ModelStorageBase as rt, ContractMarkerRecord as s, $ as t, DomainVariantEntry as tt, DocumentContract as u, FieldType as v, PlanRefs as w, JsonValue as x, GeneratedValueSpec as y, profileHash as z };
303
- //# sourceMappingURL=types-DmKtoEd-.d.mts.map
258
+ //#region src/contract-types.d.ts
259
+ /**
260
+ * Execution section for the unified contract (ADR 182).
261
+ *
262
+ * Unlike the legacy {@link import('./types').ExecutionSection}, this type
263
+ * requires `executionHash` — when an execution section is present, its
264
+ * hash must be too (consistent with `StorageBase.storageHash`).
265
+ *
266
+ * @template THash Literal hash string type for type-safe hash tracking.
267
+ */
268
+ type ContractExecutionSection<THash extends string = string> = {
269
+ readonly executionHash: ExecutionHashBase<THash>;
270
+ readonly mutations: {
271
+ readonly defaults: ReadonlyArray<ExecutionMutationDefault>;
272
+ };
273
+ };
274
+ /**
275
+ * Unified contract representation (ADR 182).
276
+ *
277
+ * A `Contract` is the canonical in-memory representation of a data contract.
278
+ * It is model-first (domain models carry their own storage bridge) and
279
+ * family-parameterized (SQL, Mongo, etc. specialize via `TStorage` and model
280
+ * storage generics on `ContractModel`).
281
+ *
282
+ * JSON persistence fields (`schemaVersion`, `sources`) are not represented
283
+ * here — they are handled at the serialization boundary.
284
+ *
285
+ * @template TStorage Family-specific storage block (extends {@link StorageBase}).
286
+ * @template TModels Record of model name → {@link ContractModel} with
287
+ * family-specific model storage.
288
+ */
289
+ interface Contract<TStorage extends StorageBase = StorageBase, TModels extends Record<string, ContractModel> = Record<string, ContractModel>> {
290
+ readonly target: string;
291
+ readonly targetFamily: string;
292
+ readonly roots: Record<string, string>;
293
+ readonly models: TModels;
294
+ readonly storage: TStorage;
295
+ readonly capabilities: Record<string, Record<string, boolean>>;
296
+ readonly extensionPacks: Record<string, unknown>;
297
+ readonly execution?: ContractExecutionSection;
298
+ readonly profileHash: ProfileHashBase<string>;
299
+ readonly meta: Record<string, unknown>;
300
+ }
301
+ //#endregion
302
+ export { TaggedLiteralValue as A, ContractField as B, PlanRefs as C, StorageBase as D, Source as E, isTaggedBigInt as F, ContractVariantEntry as G, ContractReferenceRelation as H, isTaggedRaw as I, ReferenceRelationKeys as J, EmbedRelationKeys as K, profileHash as L, bigintJsonReplacer as M, coreHash as N, StorageHashBase as O, executionHash as P, ContractDiscriminator as R, PlanMeta as S, ResultType as T, ContractRelation as U, ContractModel as V, ContractRelationOn 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, TaggedRaw as j, TaggedBigInt as k, DocCollection as l, ExecutionPlan as m, ContractExecutionSection as n, ColumnDefaultLiteralInputValue as o, ExecutionMutationDefaultValue as p, ModelStorageBase as q, $ as r, ColumnDefaultLiteralValue as s, Contract as t, DocIndex as u, GeneratedValueSpec as v, ProfileHashBase as w, ParamDescriptor as x, JsonPrimitive as y, ContractEmbedRelation as z };
303
+ //# sourceMappingURL=contract-types-Cd9ic3zL.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"contract-types-Cd9ic3zL.d.mts","names":[],"sources":["../src/domain-types.ts","../src/types.ts","../src/contract-types.ts"],"sourcesContent":[],"mappings":";KAAY,aAAA;EAAA,SAAA,QAAa,EAAA,OAAA;EAKb,SAAA,OAAA,EAAA,MAAkB;AAK9B,CAAA;AAMY,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;UAMjC,oBAAA;;;;;sBAKK;;iBAEL;;;;ADvPjB;AAKA;AAMA;AAKA;AAEA;AAIA;AAIA;AAEA;;AAAwE,KEhB5D,wBFgB4D,CAAA,cAAA,MAAA,GAAA,MAAA,CAAA,GAAA;EACtC,SAAA,aAAA,EEhBR,iBFgBQ,CEhBU,KFgBV,CAAA;EAAf,SAAA,SAAA,EAAA;IACkB,SAAA,QAAA,EEfd,aFec,CEfA,wBFeA,CAAA;EAAf,CAAA;CACF;;;;;AAKnB;;;;;AAUD;;;;;;AAIgF,UEhB/D,QFgB+D,CAAA,iBEf7D,WFe6D,GEf/C,WFe+C,EAAA,gBEd9D,MFc8D,CAAA,MAAA,EEd/C,aFc+C,CAAA,GEd9B,MFc8B,CAAA,MAAA,EEdf,aFce,CAAA,CAAA,CAAA;EAAwB,SAAA,MAAA,EAAA,MAAA;EAAW,SAAA,YAAA,EAAA,MAAA;EAC7G,SAAA,KAAA,EEXY,MFWZ,CAAA,MAAA,EAAA,MAAA,CAAA;EAEE,SAAA,MAAA,EEZW,OFYX;EAAoB,SAAA,OAAA,EEXR,QFWQ;EAAS,SAAA,YAAA,EEVZ,MFUY,CAAA,MAAA,EEVG,MFUH,CAAA,MAAA,EAAA,OAAA,CAAA,CAAA;EAEzB,SAAA,cAAiB,EEXF,MFWE,CAAA,MAAA,EAAA,OAAA,CAAA;EACT,SAAA,SAAA,CAAA,EEXG,wBFWH;EACe,SAAA,WAAA,EEXX,eFWW,CAAA,MAAA,CAAA;EAErB,SAAA,IAAA,EEZG,MFYH,CAAA,MAAA,EAAA,OAAA,CAAA"}
@@ -1,5 +1,6 @@
1
- import { t as bigintJsonReplacer } from "./types-DYikGC04.mjs";
1
+ import { t as bigintJsonReplacer } from "./types-BP4dqfP-.mjs";
2
2
  import { isArrayEqual } from "@prisma-next/utils/array-equal";
3
+ import { ifDefined } from "@prisma-next/utils/defined";
3
4
  import { createHash } from "node:crypto";
4
5
 
5
6
  //#region src/canonicalization.ts
@@ -33,7 +34,6 @@ function omitDefaults(obj, path) {
33
34
  for (const [key, value] of Object.entries(obj)) {
34
35
  const currentPath = [...path, key];
35
36
  if (key === "_generated") continue;
36
- if (key === "nullable" && value === false) continue;
37
37
  if (key === "generated" && value === false) continue;
38
38
  if ((key === "onDelete" || key === "onUpdate") && value === "noAction") continue;
39
39
  if (isDefaultValue(value)) {
@@ -81,7 +81,7 @@ function omitDefaults(obj, path) {
81
81
  "foreignKeys"
82
82
  ]);
83
83
  const isFkBooleanField = currentPath.length === 5 && currentPath[0] === "storage" && currentPath[1] === "tables" && currentPath[3] === "foreignKeys" && (key === "constraint" || key === "index");
84
- if (!isRequiredModels && !isRequiredTables && !isRequiredCollections && !isCollectionEntry && !isRequiredRoots && !isRequiredExtensionPacks && !isRequiredCapabilities && !isRequiredMeta && !isRequiredExecutionDefaults && !isExtensionNamespace && !isModelRelations && !isModelStorage && !isTableUniques && !isTableIndexes && !isTableForeignKeys && !isFkBooleanField) continue;
84
+ if (!isRequiredModels && !isRequiredTables && !isRequiredCollections && !isCollectionEntry && !isRequiredRoots && !isRequiredExtensionPacks && !isRequiredCapabilities && !isRequiredMeta && !isRequiredExecutionDefaults && !isExtensionNamespace && !isModelRelations && !isModelStorage && !isTableUniques && !isTableIndexes && !isTableForeignKeys && !isFkBooleanField && !(key === "nullable")) continue;
85
85
  }
86
86
  result[key] = omitDefaults(value, currentPath);
87
87
  }
@@ -136,20 +136,19 @@ function orderTopLevel(obj) {
136
136
  for (const key of Array.from(remaining).sort()) ordered[key] = obj[key];
137
137
  return ordered;
138
138
  }
139
- function canonicalizeContractToObject(input) {
140
- const i = input;
139
+ function canonicalizeContractToObject(contract, options) {
141
140
  const withDefaultsOmitted = omitDefaults({
142
- ...i["schemaVersion"] !== void 0 ? { schemaVersion: i["schemaVersion"] } : {},
143
- targetFamily: i["targetFamily"],
144
- target: i["target"],
145
- ...i["profileHash"] !== void 0 ? { profileHash: i["profileHash"] } : {},
146
- roots: i["roots"],
147
- models: i["models"],
148
- storage: i["storage"],
149
- ...i["execution"] !== void 0 ? { execution: i["execution"] } : {},
150
- extensionPacks: i["extensionPacks"],
151
- capabilities: i["capabilities"],
152
- meta: i["meta"]
141
+ ...ifDefined("schemaVersion", options?.schemaVersion),
142
+ targetFamily: contract.targetFamily,
143
+ target: contract.target,
144
+ profileHash: contract.profileHash,
145
+ roots: contract.roots,
146
+ models: contract.models,
147
+ storage: contract.storage,
148
+ ...ifDefined("execution", contract.execution),
149
+ extensionPacks: contract.extensionPacks,
150
+ capabilities: contract.capabilities,
151
+ meta: contract.meta
153
152
  }, []);
154
153
  const withSortedIndexes = sortIndexesAndUniques(withDefaultsOmitted["storage"]);
155
154
  return orderTopLevel(sortObjectKeys({
@@ -157,8 +156,8 @@ function canonicalizeContractToObject(input) {
157
156
  storage: withSortedIndexes
158
157
  }));
159
158
  }
160
- function canonicalizeContract(input) {
161
- return JSON.stringify(canonicalizeContractToObject(input), bigintJsonReplacer, 2);
159
+ function canonicalizeContract(contract, options) {
160
+ return JSON.stringify(canonicalizeContractToObject(contract, options), bigintJsonReplacer, 2);
162
161
  }
163
162
 
164
163
  //#endregion
@@ -169,47 +168,31 @@ function sha256(content) {
169
168
  hash.update(content);
170
169
  return `sha256:${hash.digest("hex")}`;
171
170
  }
172
- function computeStorageHash(args) {
173
- return sha256(canonicalizeContract({
174
- schemaVersion: SCHEMA_VERSION,
175
- targetFamily: args.targetFamily,
176
- target: args.target,
177
- storage: args.storage,
171
+ function hashContract(section) {
172
+ return canonicalizeContract({
173
+ targetFamily: section["targetFamily"],
174
+ target: section["target"],
178
175
  roots: {},
179
176
  models: {},
177
+ storage: section["storage"] ?? {},
178
+ execution: section["execution"],
180
179
  extensionPacks: {},
181
- capabilities: {},
182
- meta: {}
183
- }));
180
+ capabilities: section["capabilities"] ?? {},
181
+ meta: {},
182
+ profileHash: "",
183
+ ...section
184
+ }, { schemaVersion: SCHEMA_VERSION });
185
+ }
186
+ function computeStorageHash(args) {
187
+ return sha256(hashContract(args));
184
188
  }
185
189
  function computeExecutionHash(args) {
186
- return sha256(canonicalizeContract({
187
- schemaVersion: SCHEMA_VERSION,
188
- targetFamily: args.targetFamily,
189
- target: args.target,
190
- execution: args.execution,
191
- roots: {},
192
- models: {},
193
- storage: {},
194
- extensionPacks: {},
195
- capabilities: {},
196
- meta: {}
197
- }));
190
+ return sha256(hashContract(args));
198
191
  }
199
192
  function computeProfileHash(args) {
200
- return sha256(canonicalizeContract({
201
- schemaVersion: SCHEMA_VERSION,
202
- targetFamily: args.targetFamily,
203
- target: args.target,
204
- capabilities: args.capabilities,
205
- roots: {},
206
- models: {},
207
- storage: {},
208
- extensionPacks: {},
209
- meta: {}
210
- }));
193
+ return sha256(hashContract(args));
211
194
  }
212
195
 
213
196
  //#endregion
214
197
  export { canonicalizeContractToObject as a, canonicalizeContract as i, computeProfileHash as n, computeStorageHash as r, computeExecutionHash as t };
215
- //# sourceMappingURL=hashing-D1EPxYRl.mjs.map
198
+ //# sourceMappingURL=hashing-BHjb-IPM.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hashing-BHjb-IPM.mjs","names":["result: Record<string, unknown>","sorted: Record<string, unknown>","result: StorageObject","sortedTable: TableObject","ordered: Record<string, unknown>"],"sources":["../src/canonicalization.ts","../src/hashing.ts"],"sourcesContent":["import { isArrayEqual } from '@prisma-next/utils/array-equal';\nimport { ifDefined } from '@prisma-next/utils/defined';\n\nimport type { Contract } from './contract-types';\nimport { bigintJsonReplacer } from './types';\n\nconst TOP_LEVEL_ORDER = [\n 'schemaVersion',\n 'canonicalVersion',\n 'targetFamily',\n 'target',\n 'profileHash',\n 'roots',\n 'models',\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 (value instanceof Date) 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(obj: unknown, path: readonly string[]): unknown {\n if (obj === null || typeof obj !== 'object') {\n return obj;\n }\n\n if (obj instanceof Date) {\n return obj;\n }\n\n if (Array.isArray(obj)) {\n return obj.map((item) => omitDefaults(item, path));\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 isRequiredTables = isArrayEqual(currentPath, ['storage', 'tables']);\n const isRequiredCollections = isArrayEqual(currentPath, ['storage', 'collections']);\n const isCollectionEntry =\n currentPath.length === 3 &&\n isArrayEqual([currentPath[0], currentPath[1]], ['storage', 'collections']);\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 const isTableUniques =\n currentPath.length === 4 &&\n isArrayEqual(\n [currentPath[0], currentPath[1], currentPath[3]],\n ['storage', 'tables', 'uniques'],\n );\n const isTableIndexes =\n currentPath.length === 4 &&\n isArrayEqual(\n [currentPath[0], currentPath[1], currentPath[3]],\n ['storage', 'tables', 'indexes'],\n );\n const isTableForeignKeys =\n currentPath.length === 4 &&\n isArrayEqual(\n [currentPath[0], currentPath[1], currentPath[3]],\n ['storage', 'tables', 'foreignKeys'],\n );\n\n const isFkBooleanField =\n currentPath.length === 5 &&\n currentPath[0] === 'storage' &&\n currentPath[1] === 'tables' &&\n currentPath[3] === 'foreignKeys' &&\n (key === 'constraint' || key === 'index');\n\n const isNullableField = key === 'nullable';\n\n if (\n !isRequiredModels &&\n !isRequiredTables &&\n !isRequiredCollections &&\n !isCollectionEntry &&\n !isRequiredRoots &&\n !isRequiredExtensionPacks &&\n !isRequiredCapabilities &&\n !isRequiredMeta &&\n !isRequiredExecutionDefaults &&\n !isExtensionNamespace &&\n !isModelRelations &&\n !isModelStorage &&\n !isTableUniques &&\n !isTableIndexes &&\n !isTableForeignKeys &&\n !isFkBooleanField &&\n !isNullableField\n ) {\n continue;\n }\n }\n\n result[key] = omitDefaults(value, currentPath);\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 (obj instanceof Date) {\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\ntype StorageObject = {\n tables?: Record<string, unknown>;\n [key: string]: unknown;\n};\n\ntype TableObject = {\n indexes?: unknown[];\n uniques?: unknown[];\n [key: string]: unknown;\n};\n\nfunction sortIndexesAndUniques(storage: unknown): unknown {\n if (!storage || typeof storage !== 'object') {\n return storage;\n }\n\n const storageObj = storage as StorageObject;\n if (!storageObj.tables || typeof storageObj.tables !== 'object') {\n return storage;\n }\n\n const tables = storageObj.tables;\n const result: StorageObject = { ...storageObj };\n\n result.tables = {};\n const sortedTableNames = Object.keys(tables).sort();\n for (const tableName of sortedTableNames) {\n const table = tables[tableName];\n if (!table || typeof table !== 'object') {\n result.tables[tableName] = table;\n continue;\n }\n\n const tableObj = table as TableObject;\n const sortedTable: TableObject = { ...tableObj };\n\n if (Array.isArray(tableObj.indexes)) {\n sortedTable.indexes = [...tableObj.indexes].sort((a, b) => {\n const nameA = (a as { name?: string })?.name || '';\n const nameB = (b as { name?: string })?.name || '';\n return nameA.localeCompare(nameB);\n });\n }\n\n if (Array.isArray(tableObj.uniques)) {\n sortedTable.uniques = [...tableObj.uniques].sort((a, b) => {\n const nameA = (a as { name?: string })?.name || '';\n const nameB = (b as { name?: string })?.name || '';\n return nameA.localeCompare(nameB);\n });\n }\n\n result.tables[tableName] = sortedTable;\n }\n\n return result;\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 function canonicalizeContractToObject(\n contract: Contract,\n options?: { schemaVersion?: string },\n): Record<string, unknown> {\n const normalized: Record<string, unknown> = {\n ...ifDefined('schemaVersion', options?.schemaVersion),\n targetFamily: contract.targetFamily,\n target: contract.target,\n profileHash: contract.profileHash,\n roots: contract.roots,\n models: contract.models,\n storage: contract.storage,\n ...ifDefined('execution', contract.execution),\n extensionPacks: contract.extensionPacks,\n capabilities: contract.capabilities,\n meta: contract.meta,\n };\n const withDefaultsOmitted = omitDefaults(normalized, []) as Record<string, unknown>;\n const withSortedIndexes = sortIndexesAndUniques(withDefaultsOmitted['storage']);\n const withSortedStorage = { ...withDefaultsOmitted, storage: withSortedIndexes };\n const withSortedKeys = sortObjectKeys(withSortedStorage) as Record<string, unknown>;\n return orderTopLevel(withSortedKeys);\n}\n\nexport function canonicalizeContract(\n contract: Contract,\n options?: { schemaVersion?: string },\n): string {\n return JSON.stringify(canonicalizeContractToObject(contract, options), bigintJsonReplacer, 2);\n}\n","import { createHash } from 'node:crypto';\nimport { canonicalizeContract } 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\nfunction hashContract(section: Record<string, unknown>): string {\n const contract = {\n targetFamily: section['targetFamily'],\n target: section['target'],\n roots: {},\n models: {},\n storage: section['storage'] ?? {},\n execution: section['execution'],\n extensionPacks: {},\n capabilities: section['capabilities'] ?? {},\n meta: {},\n profileHash: '',\n ...section,\n } as Contract;\n return canonicalizeContract(contract, { schemaVersion: SCHEMA_VERSION });\n}\n\nexport function computeStorageHash(args: {\n target: string;\n targetFamily: string;\n storage: Record<string, unknown>;\n}): 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":";;;;;;AAMA,MAAM,kBAAkB;CACtB;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACD;AAED,SAAS,eAAe,OAAyB;AAC/C,KAAI,UAAU,MAAO,QAAO;AAC5B,KAAI,UAAU,KAAM,QAAO;AAC3B,KAAI,iBAAiB,KAAM,QAAO;AAClC,KAAI,MAAM,QAAQ,MAAM,IAAI,MAAM,WAAW,EAAG,QAAO;AACvD,KAAI,OAAO,UAAU,YAAY,UAAU,KAEzC,QADa,OAAO,KAAK,MAAM,CACnB,WAAW;AAEzB,QAAO;;AAGT,SAAS,aAAa,KAAc,MAAkC;AACpE,KA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,SAAS;EACvB,QAAQ,SAAS;EACjB,aAAa,SAAS;EACtB,OAAO,SAAS;EAChB,QAAQ,SAAS;EACjB,SAAS,SAAS;EAClB,GAAG,UAAU,aAAa,SAAS,UAAU;EAC7C,gBAAgB,SAAS;EACzB,cAAc,SAAS;EACvB,MAAM,SAAS;EAChB,EACoD,EAAE,CAAC;CACxD,MAAM,oBAAoB,sBAAsB,oBAAoB,WAAW;AAG/E,QAAO,cADgB,eADG;EAAE,GAAG;EAAqB,SAAS;EAAmB,CACxB,CACpB;;AAGtC,SAAgB,qBACd,UACA,SACQ;AACR,QAAO,KAAK,UAAU,6BAA6B,UAAU,QAAQ,EAAE,oBAAoB,EAAE;;;;;ACxQ/F,MAAM,iBAAiB;AAEvB,SAAS,OAAO,SAAyB;CACvC,MAAM,OAAO,WAAW,SAAS;AACjC,MAAK,OAAO,QAAQ;AACpB,QAAO,UAAU,KAAK,OAAO,MAAM;;AAGrC,SAAS,aAAa,SAA0C;AAc9D,QAAO,qBAbU;EACf,cAAc,QAAQ;EACtB,QAAQ,QAAQ;EAChB,OAAO,EAAE;EACT,QAAQ,EAAE;EACV,SAAS,QAAQ,cAAc,EAAE;EACjC,WAAW,QAAQ;EACnB,gBAAgB,EAAE;EAClB,cAAc,QAAQ,mBAAmB,EAAE;EAC3C,MAAM,EAAE;EACR,aAAa;EACb,GAAG;EACJ,EACqC,EAAE,eAAe,gBAAgB,CAAC;;AAG1E,SAAgB,mBAAmB,MAIP;AAC1B,QAAO,OAAO,aAAa,KAAK,CAAC;;AAGnC,SAAgB,qBAAqB,MAIP;AAC5B,QAAO,OAAO,aAAa,KAAK,CAAC;;AAGnC,SAAgB,mBAAmB,MAIP;AAC1B,QAAO,OAAO,aAAa,KAAK,CAAC"}
@@ -1,21 +1,12 @@
1
- import { O as StorageBase, T as ProfileHashBase, f as ExecutionHashBase, k as StorageHashBase } from "./types-DmKtoEd-.mjs";
1
+ import { O as StorageHashBase, d as ExecutionHashBase, t as Contract, w as ProfileHashBase } from "./contract-types-Cd9ic3zL.mjs";
2
2
 
3
3
  //#region src/canonicalization.d.ts
4
- type CanonicalContractInput = {
5
- readonly schemaVersion?: string | undefined;
6
- readonly targetFamily: string;
7
- readonly target: string;
8
- readonly profileHash?: string | undefined;
9
- readonly roots: Record<string, string>;
10
- readonly models: Record<string, unknown>;
11
- readonly storage: StorageBase | Record<string, unknown>;
12
- readonly execution?: Record<string, unknown> | undefined;
13
- readonly extensionPacks: Record<string, unknown>;
14
- readonly capabilities: Record<string, Record<string, boolean>>;
15
- readonly meta: Record<string, unknown>;
16
- };
17
- declare function canonicalizeContractToObject(input: CanonicalContractInput): Record<string, unknown>;
18
- declare function canonicalizeContract(input: CanonicalContractInput): string;
4
+ declare function canonicalizeContractToObject(contract: Contract, options?: {
5
+ schemaVersion?: string;
6
+ }): Record<string, unknown>;
7
+ declare function canonicalizeContract(contract: Contract, options?: {
8
+ schemaVersion?: string;
9
+ }): string;
19
10
  //#endregion
20
11
  //#region src/hashing.d.ts
21
12
  declare function computeStorageHash(args: {
@@ -34,5 +25,5 @@ declare function computeProfileHash(args: {
34
25
  capabilities: Record<string, Record<string, boolean>>;
35
26
  }): ProfileHashBase<string>;
36
27
  //#endregion
37
- export { type CanonicalContractInput, canonicalizeContract, canonicalizeContractToObject, computeExecutionHash, computeProfileHash, computeStorageHash };
28
+ export { canonicalizeContract, canonicalizeContractToObject, computeExecutionHash, computeProfileHash, computeStorageHash };
38
29
  //# sourceMappingURL=hashing.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"hashing.d.mts","names":[],"sources":["../src/canonicalization.ts","../src/hashing.ts"],"sourcesContent":[],"mappings":";;;KAiPY,sBAAA;;EAAA,SAAA,YAAA,EAAA,MAAsB;EAKhB,SAAA,MAAA,EAAA,MAAA;EACC,SAAA,WAAA,CAAA,EAAA,MAAA,GAAA,SAAA;EAIC,SAAA,KAAA,EALF,MAKE,CAAA,MAAA,EAAA,MAAA,CAAA;EAAc,SAAA,MAAA,EAJf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,iBAuBZ;EAxBgB,aAAA,CAAA,EAAA,MAAA;AAwBhB,CAAA,CAAA,EArBG,MAqBa,CAAA,MAAA,EAAA,OAAA,CAAoB;iBAApB,oBAAA,WACJ;;;;;iBC5OI,kBAAA;;EDmNA,YAAA,EAAA,MAAA;EAwBA,OAAA,ECxOL,MDwOK,CAAA,MAAA,EAAoB,OAAA,CAAA;ICvOhC;iBAIY,oBAAA;;EARA,YAAA,EAAA,MAAA;EAQA,SAAA,EAGH,MAHG,CAAA,MAAoB,EAAA,OAAA,CAAA;AAQpC,CAAA,CAAA,EAJI,iBAIY,CAAA,MAAkB,CAAA;AAGH,iBAHf,kBAAA,CAGe,IAAA,EAAA;EAAf,MAAA,EAAA,MAAA;EACZ,YAAA,EAAA,MAAA;EAAe,YAAA,EADH,MACG,CAAA,MAAA,EADY,MACZ,CAAA,MAAA,EAAA,OAAA,CAAA,CAAA;IAAf"}
package/dist/hashing.mjs CHANGED
@@ -1,3 +1,3 @@
1
- import { a as canonicalizeContractToObject, i as canonicalizeContract, n as computeProfileHash, r as computeStorageHash, t as computeExecutionHash } from "./hashing-D1EPxYRl.mjs";
1
+ import { a as canonicalizeContractToObject, i as canonicalizeContract, n as computeProfileHash, r as computeStorageHash, t as computeExecutionHash } from "./hashing-BHjb-IPM.mjs";
2
2
 
3
3
  export { canonicalizeContract, canonicalizeContractToObject, computeExecutionHash, computeProfileHash, computeStorageHash };
@@ -1,5 +1,4 @@
1
- import { O as StorageBase, T as ProfileHashBase, U as ContractModel, g as ExecutionSection, k as StorageHashBase, rt as ModelStorageBase } from "./types-DmKtoEd-.mjs";
2
- import { t as Contract } from "./contract-types-x89nqTli.mjs";
1
+ import { D as StorageBase, O as StorageHashBase, V as ContractModel, h as ExecutionSection, q as ModelStorageBase, t as Contract, w as ProfileHashBase } from "./contract-types-Cd9ic3zL.mjs";
3
2
 
4
3
  //#region src/testing-factories.d.ts
5
4
  type ContractOverrides<TStorage extends StorageBase = StorageBase, TModels extends Record<string, ContractModel> = Record<string, ContractModel>> = {
@@ -1 +1 @@
1
- {"version":3,"file":"testing.d.mts","names":[],"sources":["../src/testing-factories.ts"],"sourcesContent":[],"mappings":";;;;KAMK,mCACc,cAAc,6BACf,eAAe,iBAAiB,eAAe;EAF5D,MAAA,CAAA,EAAA,MAAA;EACc,YAAA,CAAA,EAAA,MAAA;EAAc,KAAA,CAAA,EAKvB,MALuB,CAAA,MAAA,EAAA,MAAA,CAAA;EACA,MAAA,CAAA,EAKtB,OALsB;EAAf,OAAA,CAAA,EAMN,IANM,CAMD,QANC,EAAA,aAAA,CAAA;EAA+C,YAAA,CAAA,EAOhD,MAPgD,CAAA,MAAA,EAOjC,MAPiC,CAAA,MAAA,EAAA,OAAA,CAAA,CAAA;EAAf,cAAA,CAAA,EAQ/B,MAR+B,CAAA,MAAA,EAAA,OAAA,CAAA;EAIxC,SAAA,CAAA,EAKI,IALJ,CAKS,gBALT,EAAA,eAAA,CAAA;EACC,WAAA,CAAA,EAKK,eALL,CAAA,MAAA,CAAA;EACM,IAAA,CAAA,EAKR,MALQ,CAAA,MAAA,EAAA,OAAA,CAAA;CAAL;cAQN,UAP0B,EAOU,eAPV,CAAA,aAAA,CAAA;AAAf,iBASD,cATC,CAAA,iBAUE,WAVF,GAUgB,WAVhB,EAAA,gBAWC,MAXD,CAAA,MAAA,EAWgB,aAXhB,CAAA,GAWiC,MAXjC,CAAA,MAAA,EAWgD,aAXhD,CAAA,CAAA,CAAA,SAAA,CAAA,EAYJ,iBAZI,CAYc,QAZd,EAYwB,OAZxB,CAAA,CAAA,EAYwC,QAZxC,CAYiD,QAZjD,EAY2D,OAZ3D,CAAA;KA2DZ,cAAA,GAAiB,WA1DH,GAAA;EACA,SAAA,MAAA,EA0DA,MA1DA,CAAA,MAAA,EAAA,OAAA,CAAA;EAAL,SAAA,KAAA,CAAA,EA2DK,MA3DL,CAAA,MAAA,EAAA,OAAA,CAAA;CACE;KA6DX,YAAA,GAAe,aA5DX,CA4DyB,gBA5DzB,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,CAAA,CAAA,SAAA,CAAA,EAWN,iBAXM,CAWY,QAXZ,EAWsB,OAXtB,CAAA,CAAA,EAWsC,QAXtC,CAW+C,QAX/C,EAWyD,OAXzD,CAAA;KA0Dd,cAAA,GAAiB,WAzDH,GAAA;EAAL,SAAA,MAAA,EA0DK,MA1DL,CAAA,MAAA,EAAA,OAAA,CAAA;EACE,SAAA,KAAA,CAAA,EA0DG,MA1DH,CAAA,MAAA,EAAA,OAAA,CAAA;CACP;KA4DJ,YAAA,GAAe,aA5DL,CA4DmB,gBA5DnB,GAAA;EAGT,KAAA,EAAA,MAAoC;AAE1C,CAAA,CAAA;AACmB,iBAwDH,iBAAA,CAxDG,SAAA,CAAA,EAyDN,iBAzDM,CAyDY,cAzDZ,EAyD4B,MAzD5B,CAAA,MAAA,EAyD2C,YAzD3C,CAAA,CAAA,CAAA,EA0DhB,QA1DgB,CA0DP,cA1DO,EA0DS,MA1DT,CAAA,MAAA,EA0DwB,YA1DxB,CAAA,CAAA"}
package/dist/testing.mjs CHANGED
@@ -1,5 +1,5 @@
1
- import { n as coreHash } from "./types-DYikGC04.mjs";
2
- import { n as computeProfileHash, r as computeStorageHash, t as computeExecutionHash } from "./hashing-D1EPxYRl.mjs";
1
+ import { n as coreHash } from "./types-BP4dqfP-.mjs";
2
+ import { n as computeProfileHash, r as computeStorageHash, t as computeExecutionHash } from "./hashing-BHjb-IPM.mjs";
3
3
 
4
4
  //#region src/testing-factories.ts
5
5
  const DUMMY_HASH = coreHash("sha256:test");
@@ -21,13 +21,7 @@ function bigintJsonReplacer(_key, value) {
21
21
  function isTaggedRaw(value) {
22
22
  return typeof value === "object" && value !== null && value.$type === "raw" && "value" in value;
23
23
  }
24
- /**
25
- * Type guard to check if a contract is a Document contract
26
- */
27
- function isDocumentContract(contract) {
28
- return typeof contract === "object" && contract !== null && "targetFamily" in contract && contract.targetFamily === "document";
29
- }
30
24
 
31
25
  //#endregion
32
- export { isTaggedBigInt as a, isDocumentContract as i, coreHash as n, isTaggedRaw as o, executionHash as r, profileHash as s, bigintJsonReplacer as t };
33
- //# sourceMappingURL=types-DYikGC04.mjs.map
26
+ export { isTaggedRaw as a, isTaggedBigInt as i, coreHash as n, profileHash as o, executionHash as r, bigintJsonReplacer as t };
27
+ //# sourceMappingURL=types-BP4dqfP-.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types-BP4dqfP-.mjs","names":[],"sources":["../src/types.ts"],"sourcesContent":["/**\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 * 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 */\nexport interface StorageBase<THash extends string = string> {\n readonly storageHash: StorageHashBase<THash>;\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 TaggedBigInt = { readonly $type: 'bigint'; readonly value: string };\n\nexport function isTaggedBigInt(value: unknown): value is TaggedBigInt {\n return (\n typeof value === 'object' &&\n value !== null &&\n (value as { $type?: unknown }).$type === 'bigint' &&\n typeof (value as { value?: unknown }).value === 'string'\n );\n}\n\nexport function bigintJsonReplacer(_key: string, value: unknown): unknown {\n if (typeof value === 'bigint') {\n return { $type: 'bigint', value: value.toString() } satisfies TaggedBigInt;\n }\n return value;\n}\n\nexport type TaggedRaw = { readonly $type: 'raw'; readonly value: JsonValue };\n\nexport function isTaggedRaw(value: unknown): value is TaggedRaw {\n return (\n typeof value === 'object' &&\n value !== null &&\n (value as { $type?: unknown }).$type === 'raw' &&\n 'value' in (value as object)\n );\n}\n\nexport type TaggedLiteralValue = TaggedBigInt | TaggedRaw;\n\nexport type ColumnDefaultLiteralValue = JsonValue | TaggedLiteralValue;\n\nexport type ColumnDefaultLiteralInputValue = ColumnDefaultLiteralValue | bigint | Date;\n\nexport type ColumnDefault =\n | {\n readonly kind: 'literal';\n readonly value: ColumnDefaultLiteralInputValue;\n }\n | { readonly kind: 'function'; readonly expression: string };\n\nexport type ExecutionMutationDefaultValue = {\n readonly kind: 'generator';\n readonly id: GeneratedValueSpec['id'];\n readonly params?: Record<string, unknown>;\n};\n\nexport type ExecutionMutationDefault = {\n readonly ref: { readonly table: string; readonly column: string };\n readonly onCreate?: ExecutionMutationDefaultValue;\n readonly onUpdate?: ExecutionMutationDefaultValue;\n};\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\n// Plan types - target-family agnostic execution types\nexport interface ParamDescriptor {\n readonly index?: number;\n readonly name?: string;\n readonly codecId?: string;\n readonly nativeType?: string;\n readonly nullable?: boolean;\n readonly source: 'dsl' | 'raw' | 'lane';\n readonly refs?: { table: string; column: string };\n}\n\nexport interface PlanRefs {\n readonly tables?: readonly string[];\n readonly columns?: ReadonlyArray<{ table: string; column: string }>;\n readonly indexes?: ReadonlyArray<{\n readonly table: string;\n readonly columns: ReadonlyArray<string>;\n readonly name?: string;\n }>;\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 codecs?: Record<string, string>; // alias/param → codec id ('ns/name@v')\n [key: string]: unknown;\n };\n readonly paramDescriptors: ReadonlyArray<ParamDescriptor>;\n readonly refs?: PlanRefs;\n readonly projection?: Record<string, string> | ReadonlyArray<string>;\n /**\n * Optional mapping of projection alias → column type ID (fully qualified ns/name@version).\n * Used for codec resolution when AST+refs don't provide enough type info.\n */\n readonly projectionTypes?: Record<string, string>;\n}\n\n/**\n * Canonical execution plan shape used by runtimes.\n *\n * - Row is the inferred result row type (TypeScript-only).\n * - Ast is the optional, family-specific AST type (e.g. SQL QueryAst).\n *\n * The payload executed by the runtime is represented by the sql + params pair\n * for now; future families can specialize this via Ast or additional metadata.\n */\nexport interface ExecutionPlan<Row = unknown, Ast = unknown> {\n readonly sql: string;\n readonly params: readonly unknown[];\n readonly ast?: Ast;\n readonly meta: PlanMeta;\n /**\n * Phantom property to carry the Row generic for type-level utilities.\n * Not set at runtime; used only for ResultType extraction.\n */\n readonly _row?: Row;\n}\n\n/**\n * Utility type to extract the Row type from an ExecutionPlan.\n * Example: `type Row = ResultType<typeof plan>`\n *\n * Works with both ExecutionPlan and SqlQueryPlan (SQL query plans before lowering).\n * SqlQueryPlan includes a phantom `_Row` property to preserve the generic parameter\n * for type extraction.\n */\nexport type ResultType<P> =\n P extends ExecutionPlan<infer R, unknown> ? R : P extends { readonly _Row?: infer R } ? R : never;\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}\n"],"mappings":";AA+BA,SAAgB,cAAsC,OAAgC;AACpF,QAAO;;AAGT,SAAgB,SAAiC,OAA8B;AAC7E,QAAO;;AAUT,SAAgB,YAAoC,OAA8B;AAChF,QAAO;;AAiCT,SAAgB,eAAe,OAAuC;AACpE,QACE,OAAO,UAAU,YACjB,UAAU,QACT,MAA8B,UAAU,YACzC,OAAQ,MAA8B,UAAU;;AAIpD,SAAgB,mBAAmB,MAAc,OAAyB;AACxE,KAAI,OAAO,UAAU,SACnB,QAAO;EAAE,OAAO;EAAU,OAAO,MAAM,UAAU;EAAE;AAErD,QAAO;;AAKT,SAAgB,YAAY,OAAoC;AAC9D,QACE,OAAO,UAAU,YACjB,UAAU,QACT,MAA8B,UAAU,SACzC,WAAY"}
package/dist/types.d.mts CHANGED
@@ -1,3 +1,2 @@
1
- import { $ as DomainRelation, A as TaggedBigInt, B as ContractDiscriminator, C as PlanMeta, D as Source, E as ResultType, F as executionHash, G as ContractRelation, H as ContractField, I as isDocumentContract, J as DomainDiscriminator, K as ContractRelationOn, L as isTaggedBigInt, M as TaggedRaw, N as bigintJsonReplacer, O as StorageBase, P as coreHash, Q as DomainReferenceRelation, R as isTaggedRaw, S as ParamDescriptor, T as ProfileHashBase, U as ContractModel, V as ContractEmbedRelation, W as ContractReferenceRelation, X as DomainField, Y as DomainEmbedRelation, Z as DomainModel, _ as Expr, a as ColumnDefaultLiteralValue, b as JsonPrimitive, c as DocCollection, d as DocumentStorage, et as DomainRelationOn, f as ExecutionHashBase, g as ExecutionSection, h as ExecutionPlan, i as ColumnDefaultLiteralInputValue, it as ReferenceRelationKeys, j as TaggedLiteralValue, k as StorageHashBase, l as DocIndex, m as ExecutionMutationDefaultValue, n as Brand, nt as EmbedRelationKeys, o as ContractBase, p as ExecutionMutationDefault, q as ContractVariantEntry, r as ColumnDefault, rt as ModelStorageBase, s as ContractMarkerRecord, t as $, tt as DomainVariantEntry, u as DocumentContract, v as FieldType, w as PlanRefs, x as JsonValue, y as GeneratedValueSpec, z as profileHash } from "./types-DmKtoEd-.mjs";
2
- import { n as ContractExecutionSection, t as Contract } from "./contract-types-x89nqTli.mjs";
3
- export { type $, type Brand, type ColumnDefault, type ColumnDefaultLiteralInputValue, type ColumnDefaultLiteralValue, type Contract, type ContractBase, type ContractDiscriminator, type ContractEmbedRelation, type ContractExecutionSection, type ContractField, type ContractMarkerRecord, type ContractModel, type ContractReferenceRelation, type ContractRelation, type ContractRelationOn, type ContractVariantEntry, type DocCollection, type DocIndex, type DocumentContract, type DocumentStorage, type DomainDiscriminator, type DomainEmbedRelation, type DomainField, type DomainModel, type DomainReferenceRelation, type DomainRelation, type DomainRelationOn, type DomainVariantEntry, type EmbedRelationKeys, type ExecutionHashBase, type ExecutionMutationDefault, type ExecutionMutationDefaultValue, type ExecutionPlan, type ExecutionSection, type Expr, type FieldType, type GeneratedValueSpec, type JsonPrimitive, type JsonValue, type ModelStorageBase, type ParamDescriptor, type PlanMeta, type PlanRefs, type ProfileHashBase, type ReferenceRelationKeys, type ResultType, type Source, type StorageBase, type StorageHashBase, type TaggedBigInt, type TaggedLiteralValue, type TaggedRaw, bigintJsonReplacer, coreHash, executionHash, isDocumentContract, isTaggedBigInt, isTaggedRaw, profileHash };
1
+ import { A as TaggedLiteralValue, B as ContractField, C as PlanRefs, D as StorageBase, E as Source, F as isTaggedBigInt, G as ContractVariantEntry, H as ContractReferenceRelation, I as isTaggedRaw, J as ReferenceRelationKeys, K as EmbedRelationKeys, L as profileHash, M as bigintJsonReplacer, N as coreHash, O as StorageHashBase, P as executionHash, R as ContractDiscriminator, S as PlanMeta, T as ResultType, U as ContractRelation, V as ContractModel, W as ContractRelationOn, _ as FieldType, a as ColumnDefault, b as JsonValue, c as ContractMarkerRecord, d as ExecutionHashBase, f as ExecutionMutationDefault, g as Expr, h as ExecutionSection, i as Brand, j as TaggedRaw, k as TaggedBigInt, l as DocCollection, m as ExecutionPlan, n as ContractExecutionSection, o as ColumnDefaultLiteralInputValue, p as ExecutionMutationDefaultValue, q as ModelStorageBase, r as $, s as ColumnDefaultLiteralValue, t as Contract, u as DocIndex, v as GeneratedValueSpec, w as ProfileHashBase, x as ParamDescriptor, y as JsonPrimitive, z as ContractEmbedRelation } from "./contract-types-Cd9ic3zL.mjs";
2
+ export { type $, type Brand, type ColumnDefault, type ColumnDefaultLiteralInputValue, type ColumnDefaultLiteralValue, type Contract, type ContractDiscriminator, type ContractEmbedRelation, type ContractExecutionSection, type ContractField, type ContractMarkerRecord, type ContractModel, type ContractReferenceRelation, type ContractRelation, type ContractRelationOn, type ContractVariantEntry, type DocCollection, type DocIndex, type EmbedRelationKeys, type ExecutionHashBase, type ExecutionMutationDefault, type ExecutionMutationDefaultValue, type ExecutionPlan, type ExecutionSection, type Expr, type FieldType, type GeneratedValueSpec, type JsonPrimitive, type JsonValue, type ModelStorageBase, type ParamDescriptor, type PlanMeta, type PlanRefs, type ProfileHashBase, type ReferenceRelationKeys, type ResultType, type Source, type StorageBase, type StorageHashBase, type TaggedBigInt, type TaggedLiteralValue, type TaggedRaw, bigintJsonReplacer, coreHash, executionHash, isTaggedBigInt, isTaggedRaw, profileHash };
package/dist/types.mjs CHANGED
@@ -1,3 +1,3 @@
1
- import { a as isTaggedBigInt, i as isDocumentContract, n as coreHash, o as isTaggedRaw, r as executionHash, s as profileHash, t as bigintJsonReplacer } from "./types-DYikGC04.mjs";
1
+ import { a as isTaggedRaw, i as isTaggedBigInt, n as coreHash, o as profileHash, r as executionHash, t as bigintJsonReplacer } from "./types-BP4dqfP-.mjs";
2
2
 
3
- export { bigintJsonReplacer, coreHash, executionHash, isDocumentContract, isTaggedBigInt, isTaggedRaw, profileHash };
3
+ export { bigintJsonReplacer, coreHash, executionHash, isTaggedBigInt, isTaggedRaw, profileHash };
@@ -1,15 +1,17 @@
1
- import { t as Contract } from "./contract-types-x89nqTli.mjs";
1
+ import { t as Contract } from "./contract-types-Cd9ic3zL.mjs";
2
2
 
3
3
  //#region src/validate-contract.d.ts
4
-
4
+ type ContractValidationPhase = 'structural' | 'domain' | 'storage';
5
+ declare class ContractValidationError extends Error {
6
+ readonly code = "CONTRACT.VALIDATION_FAILED";
7
+ readonly phase: ContractValidationPhase;
8
+ constructor(message: string, phase: ContractValidationPhase);
9
+ }
5
10
  /**
6
11
  * Family-provided storage validator.
7
12
  * SQL validates tables/columns/FKs; Mongo validates collections/embedding.
8
13
  */
9
14
  type StorageValidator = (contract: Contract) => void;
10
- interface ValidateContractResult {
11
- readonly warnings: string[];
12
- }
13
15
  /**
14
16
  * Framework-level contract validation (ADR 182).
15
17
  *
@@ -21,7 +23,7 @@ interface ValidateContractResult {
21
23
  * 3. **Storage validation** (family-provided): SQL validates tables/columns/FKs;
22
24
  * Mongo validates collections/embedding.
23
25
  *
24
- * JSON persistence fields (`schemaVersion`, `sources`) are stripped before
26
+ * JSON persistence fields (`schemaVersion`, `_generated`) are stripped before
25
27
  * validation — they are not part of the in-memory contract representation.
26
28
  *
27
29
  * @template TContract The fully-typed contract type (preserves literal types).
@@ -29,7 +31,7 @@ interface ValidateContractResult {
29
31
  * @param storageValidator Family-specific storage validation function.
30
32
  * @returns The validated contract with full literal types.
31
33
  */
32
- declare function validateContract<TContract extends Contract>(value: unknown, storageValidator: StorageValidator): TContract & ValidateContractResult;
34
+ declare function validateContract<TContract extends Contract>(value: unknown, storageValidator: StorageValidator): TContract;
33
35
  //#endregion
34
- export { type StorageValidator, type ValidateContractResult, validateContract };
36
+ export { ContractValidationError, type ContractValidationPhase, type StorageValidator, validateContract };
35
37
  //# sourceMappingURL=validate-contract.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"validate-contract.d.mts","names":[],"sources":["../src/validate-contract.ts"],"sourcesContent":[],"mappings":";;;;;;AASA;AAEA;AAqDgB,KAvDJ,gBAAA,GAuDoB,CAAA,QAAA,EAvDU,QAuDV,EAAA,GAAA,IAAA;AAAmB,UArDlC,sBAAA,CAqDkC;EAE/B,SAAA,QAAA,EAAA,MAAA,EAAA;;;;;;;;;;;;;;;;;;;;;iBAFJ,mCAAmC,4CAE/B,mBACjB,YAAY"}
1
+ {"version":3,"file":"validate-contract.d.mts","names":[],"sources":["../src/validate-contract.ts"],"sourcesContent":[],"mappings":";;;KAKY,uBAAA;cAEC,uBAAA,SAAgC,KAAA;EAFjC,SAAA,IAAA,GAAA,4BAAuB;EAEtB,SAAA,KAAA,EAEK,uBAFmB;EAEnB,WAAA,CAAA,OAAA,EAAA,MAAA,EAAA,KAAA,EAEoB,uBAFpB;;;;AAalB;AAmDA;AAAmD,KAnDvC,gBAAA,GAmDuC,CAAA,QAAA,EAnDT,QAmDS,EAAA,GAAA,IAAA;;;;;;;;;;;;;;;;;;;;iBAAnC,mCAAmC,4CAE/B,mBACjB"}
@@ -1,61 +1,3 @@
1
- import { t as validateContractDomain } from "./validate-domain-CTQiBiei.mjs";
2
- import { type } from "arktype";
1
+ import { n as ContractValidationError, r as validateContract } from "./validate-domain-BlwWyv01.mjs";
3
2
 
4
- //#region src/validate-contract.ts
5
- const ContractSchema = type({
6
- target: "string",
7
- targetFamily: "string",
8
- roots: "Record<string, string>",
9
- models: "Record<string, unknown>",
10
- storage: "Record<string, unknown>",
11
- capabilities: "Record<string, Record<string, boolean>>",
12
- extensionPacks: "Record<string, unknown>",
13
- meta: "Record<string, unknown>",
14
- "execution?": {
15
- "executionHash?": "string",
16
- mutations: { defaults: "unknown[]" }
17
- },
18
- "profileHash?": "string"
19
- });
20
- function stripPersistenceFields(raw) {
21
- const { schemaVersion: _, sources: _s, ...rest } = raw;
22
- return rest;
23
- }
24
- function extractDomainShape(contract) {
25
- return {
26
- roots: contract.roots,
27
- models: contract.models
28
- };
29
- }
30
- /**
31
- * Framework-level contract validation (ADR 182).
32
- *
33
- * Three-pass validation:
34
- * 1. **Structural validation** (arktype): verifies required fields exist with
35
- * correct base types.
36
- * 2. **Domain validation** (framework-owned): roots, relation targets,
37
- * variant/base consistency, discriminators, ownership, orphans.
38
- * 3. **Storage validation** (family-provided): SQL validates tables/columns/FKs;
39
- * Mongo validates collections/embedding.
40
- *
41
- * JSON persistence fields (`schemaVersion`, `sources`) are stripped before
42
- * validation — they are not part of the in-memory contract representation.
43
- *
44
- * @template TContract The fully-typed contract type (preserves literal types).
45
- * @param value Raw contract value (e.g. parsed from JSON).
46
- * @param storageValidator Family-specific storage validation function.
47
- * @returns The validated contract with full literal types.
48
- */
49
- function validateContract(value, storageValidator) {
50
- if (typeof value !== "object" || value === null) throw new Error("Contract must be a non-null object");
51
- const parsed = ContractSchema(stripPersistenceFields(value));
52
- if (parsed instanceof type.errors) throw new Error(`Invalid contract structure: ${parsed.summary}`);
53
- const contract = parsed;
54
- const domainResult = validateContractDomain(extractDomainShape(contract));
55
- storageValidator(contract);
56
- return Object.assign(contract, { warnings: domainResult.warnings });
57
- }
58
-
59
- //#endregion
60
- export { validateContract };
61
- //# sourceMappingURL=validate-contract.mjs.map
3
+ export { ContractValidationError, validateContract };