@prisma-next/sql-contract 0.11.0 → 0.12.0-dev.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. package/dist/canonicalization-hooks.d.mts +10 -0
  2. package/dist/canonicalization-hooks.d.mts.map +1 -0
  3. package/dist/canonicalization-hooks.mjs +58 -0
  4. package/dist/canonicalization-hooks.mjs.map +1 -0
  5. package/dist/factories.d.mts +1 -1
  6. package/dist/factories.d.mts.map +1 -1
  7. package/dist/factories.mjs +3 -2
  8. package/dist/factories.mjs.map +1 -1
  9. package/dist/index-type-validation.d.mts +1 -1
  10. package/dist/index-type-validation.mjs.map +1 -1
  11. package/dist/index-types-B1cf5N0F.d.mts.map +1 -1
  12. package/dist/index-types.mjs.map +1 -1
  13. package/dist/{types-DZpIXwK4.d.mts → types-Cx_5A_L0.d.mts} +22 -20
  14. package/dist/types-Cx_5A_L0.d.mts.map +1 -0
  15. package/dist/{types-L8p7B1dP.mjs → types-YQrDHy-b.mjs} +125 -112
  16. package/dist/types-YQrDHy-b.mjs.map +1 -0
  17. package/dist/types.d.mts +2 -2
  18. package/dist/types.mjs +2 -2
  19. package/dist/validators.d.mts +10 -9
  20. package/dist/validators.d.mts.map +1 -1
  21. package/dist/validators.mjs +81 -45
  22. package/dist/validators.mjs.map +1 -1
  23. package/package.json +19 -6
  24. package/src/canonicalization-hooks.ts +32 -0
  25. package/src/exports/canonicalization-hooks.ts +1 -0
  26. package/src/exports/types.ts +2 -0
  27. package/src/factories.ts +2 -2
  28. package/src/ir/build-sql-namespace.ts +89 -0
  29. package/src/ir/foreign-key-reference.ts +3 -2
  30. package/src/ir/postgres-enum-storage-entry.ts +2 -0
  31. package/src/ir/sql-storage.ts +13 -95
  32. package/src/ir/storage-column.ts +4 -1
  33. package/src/ir/storage-table.ts +4 -0
  34. package/src/types.ts +1 -0
  35. package/src/validators.ts +113 -56
  36. package/dist/types-DZpIXwK4.d.mts.map +0 -1
  37. package/dist/types-L8p7B1dP.mjs.map +0 -1
@@ -1,4 +1,4 @@
1
- import type { ColumnDefault } from '@prisma-next/contract/types';
1
+ import type { ColumnDefault, ControlPolicy } from '@prisma-next/contract/types';
2
2
  import { freezeNode } from '@prisma-next/framework-components/ir';
3
3
  import { SqlNode } from './sql-node';
4
4
 
@@ -19,6 +19,7 @@ export interface StorageColumnInput {
19
19
  readonly typeParams?: Record<string, unknown>;
20
20
  readonly typeRef?: string;
21
21
  readonly default?: ColumnDefault;
22
+ readonly control?: ControlPolicy;
22
23
  }
23
24
 
24
25
  /**
@@ -41,6 +42,7 @@ export class StorageColumn extends SqlNode {
41
42
  declare readonly typeParams?: Record<string, unknown>;
42
43
  declare readonly typeRef?: string;
43
44
  declare readonly default?: ColumnDefault;
45
+ declare readonly control?: ControlPolicy;
44
46
 
45
47
  constructor(input: StorageColumnInput) {
46
48
  super();
@@ -50,6 +52,7 @@ export class StorageColumn extends SqlNode {
50
52
  if (input.typeParams !== undefined) this.typeParams = input.typeParams;
51
53
  if (input.typeRef !== undefined) this.typeRef = input.typeRef;
52
54
  if (input.default !== undefined) this.default = input.default;
55
+ if (input.control !== undefined) this.control = input.control;
53
56
  freezeNode(this);
54
57
  }
55
58
  }
@@ -1,3 +1,4 @@
1
+ import type { ControlPolicy } from '@prisma-next/contract/types';
1
2
  import { freezeNode } from '@prisma-next/framework-components/ir';
2
3
  import { ForeignKey, type ForeignKeyInput } from './foreign-key';
3
4
  import { PrimaryKey, type PrimaryKeyInput } from './primary-key';
@@ -12,6 +13,7 @@ export interface StorageTableInput {
12
13
  readonly uniques: ReadonlyArray<UniqueConstraint | UniqueConstraintInput>;
13
14
  readonly indexes: ReadonlyArray<Index | IndexInput>;
14
15
  readonly foreignKeys: ReadonlyArray<ForeignKey | ForeignKeyInput>;
16
+ readonly control?: ControlPolicy;
15
17
  }
16
18
 
17
19
  /**
@@ -32,6 +34,7 @@ export class StorageTable extends SqlNode {
32
34
  readonly indexes: ReadonlyArray<Index>;
33
35
  readonly foreignKeys: ReadonlyArray<ForeignKey>;
34
36
  declare readonly primaryKey?: PrimaryKey;
37
+ declare readonly control?: ControlPolicy;
35
38
 
36
39
  constructor(input: StorageTableInput) {
37
40
  super();
@@ -56,6 +59,7 @@ export class StorageTable extends SqlNode {
56
59
  this.foreignKeys = Object.freeze(
57
60
  input.foreignKeys.map((fk) => (fk instanceof ForeignKey ? fk : new ForeignKey(fk))),
58
61
  );
62
+ if (input.control !== undefined) this.control = input.control;
59
63
  freezeNode(this);
60
64
  }
61
65
  }
package/src/types.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import type { CodecTrait } from '@prisma-next/framework-components/codec';
2
2
  import type { ReferentialAction } from './ir/foreign-key';
3
3
 
4
+ export { buildSqlNamespace, buildSqlNamespaceMap } from './ir/build-sql-namespace';
4
5
  export {
5
6
  ForeignKey,
6
7
  type ForeignKeyInput,
package/src/validators.ts CHANGED
@@ -1,8 +1,17 @@
1
1
  import { ContractValidationError } from '@prisma-next/contract/contract-validation-error';
2
- import type { Contract, ContractField, ContractModel } from '@prisma-next/contract/types';
2
+ import {
3
+ type Contract,
4
+ type ContractField,
5
+ type ContractModel,
6
+ CrossReferenceSchema,
7
+ } from '@prisma-next/contract/types';
3
8
  import { validateContractDomain } from '@prisma-next/contract/validate-domain';
4
- import type { Namespace } from '@prisma-next/framework-components/ir';
9
+ import { type Namespace, UNBOUND_NAMESPACE_ID } from '@prisma-next/framework-components/ir';
10
+ import { blindCast } from '@prisma-next/utils/casts';
11
+ import { ifDefined } from '@prisma-next/utils/defined';
5
12
  import { type Type, type } from 'arktype';
13
+ import { buildSqlNamespaceMap } from './ir/build-sql-namespace';
14
+ import { SqlUnboundNamespace } from './ir/sql-unbound-namespace';
6
15
  import {
7
16
  type ForeignKeyInput,
8
17
  type ForeignKeyReferenceInput,
@@ -24,6 +33,7 @@ type ColumnDefaultFunction = { readonly kind: 'function'; readonly expression: s
24
33
  const literalKindSchema = type("'literal'");
25
34
  const functionKindSchema = type("'function'");
26
35
  const generatorKindSchema = type("'generator'");
36
+ const ControlPolicySchema = type("'managed' | 'tolerated' | 'external' | 'observed'");
27
37
  const generatorIdSchema = type('string').narrow((value, ctx) => {
28
38
  return /^[A-Za-z0-9][A-Za-z0-9_-]*$/.test(value) ? true : ctx.mustBe('a flat generator id');
29
39
  });
@@ -75,6 +85,7 @@ const StorageColumnSchema = type({
75
85
  'typeParams?': 'Record<string, unknown>',
76
86
  'typeRef?': 'string',
77
87
  'default?': ColumnDefaultSchema,
88
+ 'control?': ControlPolicySchema,
78
89
  }).narrow((col, ctx) => {
79
90
  if (col.typeParams !== undefined && col.typeRef !== undefined) {
80
91
  return ctx.mustBe('a column with either typeParams or typeRef, not both');
@@ -98,7 +109,7 @@ const StorageTypeInstanceSchema = type
98
109
  });
99
110
 
100
111
  /**
101
- * Postgres native enum entry under `storage.namespaces[namespaceId].types[name]`.
112
+ * Postgres native enum entry under `storage.namespaces[namespaceId].enum[name]`.
102
113
  * Document-scoped `storage.types` carries codec aliases only
103
114
  * (`DocumentScopedStorageTypeSchema`).
104
115
  */
@@ -107,6 +118,7 @@ const PostgresEnumTypeSchema = type({
107
118
  'name?': 'string',
108
119
  'nativeType?': 'string',
109
120
  values: type.string.array().readonly(),
121
+ 'control?': ControlPolicySchema,
110
122
  });
111
123
 
112
124
  /** Document-scoped `storage.types`: codec triples only. */
@@ -129,11 +141,12 @@ export const IndexSchema = type({
129
141
  'options?': 'Record<string, unknown>',
130
142
  });
131
143
 
132
- export const ForeignKeyReferenceSchema = type.declare<ForeignKeyReferenceInput>().type({
144
+ export const ForeignKeyReferenceSchema = type({
145
+ '+': 'reject',
133
146
  namespaceId: 'string',
134
147
  tableName: 'string',
135
148
  columns: type.string.array().readonly(),
136
- });
149
+ }) satisfies Type<ForeignKeyReferenceInput>;
137
150
 
138
151
  export const ReferentialActionSchema = type
139
152
  .declare<ReferentialAction>()
@@ -156,6 +169,7 @@ const StorageTableSchema = type({
156
169
  uniques: UniqueConstraintSchema.array().readonly(),
157
170
  indexes: IndexSchema.array().readonly(),
158
171
  foreignKeys: ForeignKeySchema.array().readonly(),
172
+ 'control?': ControlPolicySchema,
159
173
  });
160
174
 
161
175
  /**
@@ -226,11 +240,7 @@ function namespaceSlotEntrySchema(
226
240
  * Builds the per-namespace entry schema for `storage.namespaces[id]`.
227
241
  * Pack-contributed `validatorSchema` fragments — keyed by the
228
242
  * descriptor's `discriminator` — validate each entry by matching the
229
- * entry's `kind` field. The hardcoded `'types?'` slot is preserved
230
- * unconditionally: it coexists additively with any contributed fragment
231
- * that validates the same shape today. The full rename of `types` →
232
- * `postgresEnums` lands later; until then, the redundancy is the F1 cure
233
- * (no relocated dual-shape probe).
243
+ * entry's `kind` field on the `'enum?'` slot.
234
244
  */
235
245
  export function createNamespaceEntrySchema(
236
246
  fragments?: ReadonlyMap<string, Type<unknown>>,
@@ -240,7 +250,7 @@ export function createNamespaceEntrySchema(
240
250
  id: 'string',
241
251
  'kind?': 'string',
242
252
  'tables?': type({ '[string]': StorageTableSchema }),
243
- 'types?': type({
253
+ 'enum?': type({
244
254
  '[string]': namespaceSlotEntrySchema(PostgresEnumTypeSchema, 'postgres-enum', fragments),
245
255
  }),
246
256
  }) as Type<unknown>;
@@ -260,6 +270,11 @@ export function createSqlStorageSchema(
260
270
  '+': 'reject',
261
271
  storageHash: 'string',
262
272
  'types?': type({ '[string]': DocumentScopedStorageTypeSchema }),
273
+ // `__unbound__` is NOT required here: cross-namespace contracts can
274
+ // declare only named namespaces (see cross-namespace FK fixtures). The
275
+ // `__unbound__` brand on `SqlStorageInput['namespaces']` is kept sound at
276
+ // construction time by injecting the unbound singleton when absent
277
+ // (see `validateStorage` / `hydrateSqlStorage`), not by structural require.
263
278
  'namespaces?': type({ '[string]': namespaceEntry }),
264
279
  }) as Type<unknown>;
265
280
  }
@@ -355,13 +370,32 @@ const ModelStorageSchema = type({
355
370
  fields: type({ '[string]': ModelStorageFieldSchema }),
356
371
  });
357
372
 
373
+ const ContractReferenceRelationSchema = type({
374
+ '+': 'reject',
375
+ to: CrossReferenceSchema,
376
+ cardinality: "'1:1' | '1:N' | 'N:1'",
377
+ on: type({
378
+ '+': 'reject',
379
+ localFields: type.string.array().readonly(),
380
+ targetFields: type.string.array().readonly(),
381
+ }),
382
+ });
383
+
384
+ const ContractEmbedRelationSchema = type({
385
+ '+': 'reject',
386
+ to: CrossReferenceSchema,
387
+ cardinality: "'1:1' | '1:N'",
388
+ });
389
+
390
+ const ContractRelationSchema = ContractReferenceRelationSchema.or(ContractEmbedRelationSchema);
391
+
358
392
  const ModelSchema = type({
359
393
  storage: ModelStorageSchema,
360
394
  'fields?': type({ '[string]': ModelFieldSchema }),
361
- 'relations?': type({ '[string]': 'unknown' }),
395
+ 'relations?': type({ '[string]': ContractRelationSchema }),
362
396
  'discriminator?': 'unknown',
363
397
  'variants?': 'unknown',
364
- 'base?': 'string',
398
+ 'base?': CrossReferenceSchema,
365
399
  'owner?': 'string',
366
400
  });
367
401
 
@@ -387,10 +421,16 @@ export function createSqlContractSchema(
387
421
  'capabilities?': 'Record<string, Record<string, boolean>>',
388
422
  'extensionPacks?': 'Record<string, unknown>',
389
423
  'meta?': ContractMetaSchema,
390
- 'roots?': 'Record<string, string>',
391
- models: type({ '[string]': ModelSchema }),
392
- 'valueObjects?': 'Record<string, unknown>',
393
- 'domain?': 'unknown',
424
+ 'defaultControl?': ControlPolicySchema,
425
+ 'roots?': type({ '[string]': CrossReferenceSchema }),
426
+ domain: type({
427
+ namespaces: type({
428
+ '[string]': type({
429
+ models: type({ '[string]': ModelSchema }),
430
+ 'valueObjects?': 'Record<string, unknown>',
431
+ }),
432
+ }),
433
+ }),
394
434
  storage,
395
435
  'execution?': ExecutionSchema,
396
436
  }) as Type<unknown>;
@@ -417,11 +457,26 @@ export function validateStorage(value: unknown): SqlStorage {
417
457
  const messages = result.map((p: { message: string }) => p.message).join('; ');
418
458
  throw new Error(`Storage validation failed: ${messages}`);
419
459
  }
420
- // The arktype-validated shape matches `SqlStorageInput`
421
- // structurally. Funnel through the constructor so nested IR fields
422
- // (`types`) are normalised into class instances and the
423
- // branded `storageHash` is preserved on the returned `SqlStorage`.
424
- return new SqlStorage(result as SqlStorageInput);
460
+ // Arktype validates the JSON-safe envelope, but the `ColumnDefault`
461
+ // union carries runtime-only `bigint | Date` that the validation DSL
462
+ // can't express (see NOTE above), so bridge the validated shape to the
463
+ // input type. Construction below re-materialises nested IR fields.
464
+ const validated = blindCast<
465
+ SqlStorageInput & { readonly namespaces?: SqlStorageInput['namespaces'] },
466
+ 'arktype validated the JSON envelope but its output type is unknown (ColumnDefault carries runtime-only bigint|Date); bridge to the input shape'
467
+ >(result);
468
+ const namespaces = buildSqlNamespaceMap(validated.namespaces ?? {});
469
+ // Compatibility shim: inject the empty unbound singleton when absent so that
470
+ // production code paths which address __unbound__ for table metadata have a
471
+ // slot to read or write into. The `SqlStorageInput['namespaces']` type no
472
+ // longer requires __unbound__, so this is a runtime convenience, not a type
473
+ // invariant.
474
+ const unbound = namespaces[UNBOUND_NAMESPACE_ID] ?? SqlUnboundNamespace.instance;
475
+ return new SqlStorage({
476
+ storageHash: validated.storageHash,
477
+ ...ifDefined('types', validated.types),
478
+ namespaces: { ...namespaces, [UNBOUND_NAMESPACE_ID]: unbound },
479
+ });
425
480
  }
426
481
 
427
482
  export function validateModel(value: unknown): unknown {
@@ -637,43 +692,46 @@ export function validateStorageSemantics(storage: SqlStorage): string[] {
637
692
  * columns. Throws `ContractValidationError` on the first mismatch.
638
693
  */
639
694
  export function validateModelStorageReferences(contract: Contract<SqlStorage>): void {
640
- const models = contract.models as Record<string, ContractModel<SqlModelStorage>>;
641
- for (const [modelName, model] of Object.entries(models)) {
642
- const storageTable = model.storage.table;
643
-
644
- const rawTable = findStorageTableByTableName(contract.storage, storageTable);
645
- if (rawTable === undefined) {
646
- throw new ContractValidationError(
647
- `Model "${modelName}" references non-existent table "${storageTable}"`,
648
- 'storage',
649
- );
650
- }
651
-
652
- const table = rawTable as StorageTable;
653
-
654
- const columnNames = new Set(Object.keys(table.columns));
655
- for (const [fieldName, field] of Object.entries(model.storage.fields)) {
656
- if (!columnNames.has(field.column)) {
695
+ for (const [namespaceId, namespace] of Object.entries(contract.domain.namespaces)) {
696
+ const models = namespace.models as Record<string, ContractModel<SqlModelStorage>>;
697
+ for (const [modelName, model] of Object.entries(models)) {
698
+ const qualifiedName = `${namespaceId}:${modelName}`;
699
+ const storageTable = model.storage.table;
700
+
701
+ const rawTable = findStorageTableByTableName(contract.storage, storageTable);
702
+ if (rawTable === undefined) {
657
703
  throw new ContractValidationError(
658
- `Model "${modelName}" field "${fieldName}" references non-existent column "${field.column}" in table "${storageTable}"`,
704
+ `Model "${qualifiedName}" references non-existent table "${storageTable}"`,
659
705
  'storage',
660
706
  );
661
707
  }
662
- }
663
708
 
664
- const JSON_NATIVE_TYPES = new Set(['json', 'jsonb']);
665
- for (const [fieldName, domainField] of Object.entries(model.fields ?? {})) {
666
- const f = domainField as ContractField;
667
- if (f.type?.kind !== 'valueObject') continue;
668
- const storageField = model.storage.fields[fieldName];
669
- if (!storageField) continue;
670
- const column = table.columns[storageField.column];
671
- if (!column) continue;
672
- if (!JSON_NATIVE_TYPES.has(column.nativeType)) {
673
- throw new ContractValidationError(
674
- `Model "${modelName}" field "${fieldName}" is a value object but storage column "${storageField.column}" has nativeType "${column.nativeType}" (expected json or jsonb)`,
675
- 'storage',
676
- );
709
+ const table = rawTable as StorageTable;
710
+
711
+ const columnNames = new Set(Object.keys(table.columns));
712
+ for (const [fieldName, field] of Object.entries(model.storage.fields)) {
713
+ if (!columnNames.has(field.column)) {
714
+ throw new ContractValidationError(
715
+ `Model "${qualifiedName}" field "${fieldName}" references non-existent column "${field.column}" in table "${storageTable}"`,
716
+ 'storage',
717
+ );
718
+ }
719
+ }
720
+
721
+ const JSON_NATIVE_TYPES = new Set(['json', 'jsonb']);
722
+ for (const [fieldName, domainField] of Object.entries(model.fields ?? {})) {
723
+ const f = domainField as ContractField;
724
+ if (f.type?.kind !== 'valueObject') continue;
725
+ const storageField = model.storage.fields[fieldName];
726
+ if (!storageField) continue;
727
+ const column = table.columns[storageField.column];
728
+ if (!column) continue;
729
+ if (!JSON_NATIVE_TYPES.has(column.nativeType)) {
730
+ throw new ContractValidationError(
731
+ `Model "${qualifiedName}" field "${fieldName}" is a value object but storage column "${storageField.column}" has nativeType "${column.nativeType}" (expected json or jsonb)`,
732
+ 'storage',
733
+ );
734
+ }
677
735
  }
678
736
  }
679
737
  }
@@ -813,8 +871,7 @@ export function validateSqlContractFully<T extends Contract<SqlStorage>>(
813
871
  const validated = validateSqlContractStructure<T>(stripped, schema);
814
872
  validateContractDomain({
815
873
  roots: validated.roots,
816
- models: validated.models,
817
- ...(validated.valueObjects ? { valueObjects: validated.valueObjects } : {}),
874
+ domain: validated.domain,
818
875
  });
819
876
  validateSqlStorageConsistency(validated);
820
877
  const semanticErrors = validateStorageSemantics(validated.storage);
@@ -1 +0,0 @@
1
- {"version":3,"file":"types-DZpIXwK4.d.mts","names":[],"sources":["../src/ir/sql-node.ts","../src/ir/foreign-key-reference.ts","../src/ir/foreign-key.ts","../src/ir/postgres-enum-storage-entry.ts","../src/ir/primary-key.ts","../src/ir/sql-index.ts","../src/ir/storage-column.ts","../src/ir/unique-constraint.ts","../src/ir/storage-table.ts","../src/ir/storage-type-instance.ts","../src/ir/sql-storage.ts","../src/ir/sql-unbound-namespace.ts","../src/types.ts"],"mappings":";;;;;;;;;AAkCA;;;;;;;;;;;;AC/BA;;;;;;;;;AAaA;;;;;;;uBDkBsB,OAAA,SAAgB,UAAA;EAAA,SAC3B,IAAA;;;;;UChCM,wBAAA;EAAA,SACN,WAAA;EAAA,SACA,SAAA;EAAA,SACA,OAAA;AAAA;;;;;;;;cAUE,mBAAA,SAA4B,OAAA;EAAA,SAC9B,WAAA;EAAA,SACA,SAAA;EAAA,SACA,OAAA;cAEG,KAAA,EAAO,wBAAA;AAAA;;;KCjBT,iBAAA;AAAA,UAEK,eAA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,0 @@
1
- {"version":3,"file":"types-L8p7B1dP.mjs","names":[],"sources":["../src/ir/sql-node.ts","../src/ir/foreign-key-reference.ts","../src/ir/foreign-key.ts","../src/ir/postgres-enum-storage-entry.ts","../src/ir/primary-key.ts","../src/ir/sql-index.ts","../src/ir/sql-unbound-namespace.ts","../src/ir/storage-column.ts","../src/ir/unique-constraint.ts","../src/ir/storage-table.ts","../src/ir/storage-type-instance.ts","../src/ir/sql-storage.ts","../src/types.ts"],"sourcesContent":["import { IRNodeBase } from '@prisma-next/framework-components/ir';\n\n/**\n * SQL family IR node base. Carries the family-level `kind` discriminator\n * `'sql'` and inherits the framework's `freezeNode` affordance.\n *\n * Single family-level discriminator (not per-leaf) reflects the fact that\n * SQL IR has no polymorphic dispatch today — verifiers and serializers\n * walk by structural position (`storage.tables[name].columns[name]`),\n * not by inspecting `kind`. The abstract bar for per-leaf discriminators\n * isn't earned until a future polymorphic consumer arrives.\n *\n * `kind` is installed as a non-enumerable own property on every instance,\n * which keeps three things clean simultaneously:\n *\n * - `JSON.stringify(node)` produces the canonical pre-lift JSON envelope\n * shape (no `kind` field), so emitted contract.json files and the\n * `validateSqlContractFully` arktype schemas stay unchanged.\n * - Test assertions that use `toEqual({...})` against the pre-lift flat\n * shape continue to pass — only enumerable own properties are\n * compared.\n * - Direct access (`node.kind`) and runtime narrowing\n * (`if (node.kind === 'sql')`) still work, so future polymorphic\n * dispatch can begin reading `kind` without a runtime change.\n *\n * Future per-leaf overrides land cleanly: a class that gains a\n * polymorphic-dispatch consumer (e.g. an enum type instance walked\n * alongside other types) overrides `kind` with its narrower literal\n * at that leaf level. Per-leaf overrides will use enumerable kind\n * (matching the Mongo per-class-discriminator precedent) because they\n * encode dispatch-relevant information that callers need to see in\n * JSON envelopes; the family-level `'sql'` is uniform across all SQL\n * IR and carries no dispatch-relevant information.\n */\nexport abstract class SqlNode extends IRNodeBase {\n readonly kind?: string;\n\n constructor() {\n super();\n Object.defineProperty(this, 'kind', {\n value: 'sql',\n writable: false,\n enumerable: false,\n // configurable so per-leaf subclasses (e.g. PostgresEnumType in\n // target-postgres) can override `kind` with their narrower\n // enumerable literal via a class-field initializer. SqlNode\n // itself never needs to mutate the property again, so\n // configurability has no surface impact at this layer.\n configurable: true,\n });\n }\n}\n","import { freezeNode } from '@prisma-next/framework-components/ir';\nimport { SqlNode } from './sql-node';\n\nexport interface ForeignKeyReferenceInput {\n readonly namespaceId: string;\n readonly tableName: string;\n readonly columns: readonly string[];\n}\n\n/**\n * SQL Contract IR node for one side (source or target) of a foreign-key\n * declaration. Carries the full coordinate: namespace, table, and columns.\n *\n * Use `UNBOUND_NAMESPACE_ID` from `@prisma-next/framework-components/ir`\n * as the sentinel `namespaceId` for single-namespace (unbound) references.\n */\nexport class ForeignKeyReference extends SqlNode {\n readonly namespaceId: string;\n readonly tableName: string;\n readonly columns: readonly string[];\n\n constructor(input: ForeignKeyReferenceInput) {\n super();\n this.namespaceId = input.namespaceId;\n this.tableName = input.tableName;\n this.columns = input.columns;\n freezeNode(this);\n }\n}\n","import { freezeNode } from '@prisma-next/framework-components/ir';\nimport { ForeignKeyReference, type ForeignKeyReferenceInput } from './foreign-key-reference';\nimport { SqlNode } from './sql-node';\n\nexport type ReferentialAction = 'noAction' | 'restrict' | 'cascade' | 'setNull' | 'setDefault';\n\nexport interface ForeignKeyInput {\n readonly source: ForeignKeyReference | ForeignKeyReferenceInput;\n readonly target: ForeignKeyReference | ForeignKeyReferenceInput;\n readonly name?: string;\n readonly onDelete?: ReferentialAction;\n readonly onUpdate?: ReferentialAction;\n /** Whether to emit FK constraint DDL (ALTER TABLE … ADD CONSTRAINT … FOREIGN KEY). */\n readonly constraint: boolean;\n /** Whether to emit a backing index for the FK columns. */\n readonly index: boolean;\n}\n\n/**\n * SQL Contract IR node for a table-level foreign-key declaration.\n *\n * Each FK carries explicit `source` and `target` {@link ForeignKeyReference}\n * coordinates (namespace, table, columns). For single-namespace contracts the\n * sentinel `UNBOUND_NAMESPACE_ID` appears on both sides.\n *\n * The nested references are normalised to {@link ForeignKeyReference}\n * instances inside the constructor so downstream walks see a uniform AST\n * regardless of whether the input was a JSON literal or an already-constructed\n * class instance.\n */\nexport class ForeignKey extends SqlNode {\n readonly source: ForeignKeyReference;\n readonly target: ForeignKeyReference;\n readonly constraint: boolean;\n readonly index: boolean;\n declare readonly name?: string;\n declare readonly onDelete?: ReferentialAction;\n declare readonly onUpdate?: ReferentialAction;\n\n constructor(input: ForeignKeyInput) {\n super();\n this.source =\n input.source instanceof ForeignKeyReference\n ? input.source\n : new ForeignKeyReference(input.source);\n this.target =\n input.target instanceof ForeignKeyReference\n ? input.target\n : new ForeignKeyReference(input.target);\n this.constraint = input.constraint;\n this.index = input.index;\n if (input.name !== undefined) this.name = input.name;\n if (input.onDelete !== undefined) this.onDelete = input.onDelete;\n if (input.onUpdate !== undefined) this.onUpdate = input.onUpdate;\n freezeNode(this);\n }\n}\n","import type { StorageType } from '@prisma-next/framework-components/ir';\n\n/**\n * Discriminator literal for the Postgres-enum variant on the polymorphic\n * `SqlStorage.types` slot.\n *\n * Enums are a target-level concept: Postgres ships native\n * `CREATE TYPE … AS ENUM` while other SQL targets approximate enums via\n * constraints. The literal lives at the SQL family layer because every\n * SQL-family consumer (verifier, planner, lowering, …) needs to\n * discriminate enum-typed slot entries from codec-typed ones. The\n * concrete IR class (`PostgresEnumType`) lives in the target-postgres\n * package and implements this structural contract; cross-domain\n * layering rules forbid the SQL family from importing the concrete\n * target class directly, so the discriminator and structural interface\n * carry the dispatch.\n */\nexport const POSTGRES_ENUM_KIND = 'postgres-enum' as const;\n\n/**\n * Structural contract every Postgres-enum slot entry honours — both\n * the live `PostgresEnumType` IR-class instance and the raw JSON\n * envelope shape that survives `JSON.stringify` round-trips. SQL\n * family-layer dispatch narrows polymorphic `StorageType` slot\n * entries to this shape via `isPostgresEnumStorageEntry`.\n *\n * The `codecBinding` field is accessor-shaped (live class instance) on\n * the IR class and undefined on the raw JSON envelope; consumers that\n * need it must guard for its presence (the JSON path synthesises an\n * equivalent shape from `codecId` + `values`).\n */\nexport interface PostgresEnumStorageEntry extends StorageType {\n readonly kind: typeof POSTGRES_ENUM_KIND;\n readonly name: string;\n readonly nativeType: string;\n readonly values: readonly string[];\n /**\n * Enumerable own property on the persisted JSON envelope; the live\n * IR-class instance carries it too. Family-shared dispatch sites\n * read `codecId` directly rather than going through the IR-class\n * `codecBinding` accessor (which lives on the prototype and isn't\n * present on raw JSON envelopes).\n */\n readonly codecId: string;\n}\n\n/**\n * Narrow a polymorphic `StorageType` entry to the Postgres-enum shape\n * via its enumerable `kind` discriminator. Type guard returns true for\n * both live `PostgresEnumType` instances and raw JSON envelopes.\n */\nexport function isPostgresEnumStorageEntry(value: unknown): value is PostgresEnumStorageEntry {\n if (typeof value !== 'object' || value === null) return false;\n return (value as { kind?: unknown }).kind === POSTGRES_ENUM_KIND;\n}\n","import { freezeNode } from '@prisma-next/framework-components/ir';\nimport { SqlNode } from './sql-node';\n\nexport interface PrimaryKeyInput {\n readonly columns: readonly string[];\n readonly name?: string;\n}\n\n/**\n * SQL Contract IR node for a table's primary-key constraint.\n */\nexport class PrimaryKey extends SqlNode {\n readonly columns: readonly string[];\n declare readonly name?: string;\n\n constructor(input: PrimaryKeyInput) {\n super();\n this.columns = input.columns;\n if (input.name !== undefined) this.name = input.name;\n freezeNode(this);\n }\n}\n","import { freezeNode } from '@prisma-next/framework-components/ir';\nimport { SqlNode } from './sql-node';\n\nexport interface IndexInput {\n readonly columns: readonly string[];\n readonly name?: string;\n readonly type?: string;\n readonly options?: Record<string, unknown>;\n}\n\n/**\n * SQL Contract IR node for a table-level secondary index.\n *\n * Note that this class shadows the global TypeScript `Index` lib type\n * at the family-shared name; consumer files that need both should\n * alias one (e.g.\n * `import { Index as SqlIndexNode } from '@prisma-next/sql-contract/types'`).\n */\nexport class Index extends SqlNode {\n readonly columns: readonly string[];\n declare readonly name?: string;\n declare readonly type?: string;\n declare readonly options?: Record<string, unknown>;\n\n constructor(input: IndexInput) {\n super();\n this.columns = input.columns;\n if (input.name !== undefined) this.name = input.name;\n if (input.type !== undefined) this.type = input.type;\n if (input.options !== undefined) this.options = input.options;\n freezeNode(this);\n }\n}\n","import {\n freezeNode,\n NamespaceBase,\n UNBOUND_NAMESPACE_ID,\n} from '@prisma-next/framework-components/ir';\nimport type { StorageTable } from './storage-table';\n\n/**\n * Family-layer placeholder for the SQL unbound-namespace singleton —\n * the late-bound slot whose binding the target resolves at connection\n * time rather than at authoring time.\n *\n * SQL contracts honour the framework `Storage.namespaces` invariant from\n * the moment they appear in the IR. Today `SqlStorage` is family-shared\n * (Postgres + SQLite consume the same class); a per-target namespace\n * concretion (`PostgresSchema.unbound`, `SqliteUnboundDatabase.instance`)\n * earns its existence when each target's namespace shape lands. Until\n * then the family ships a single placeholder singleton so the JSON\n * envelope and runtime walk are honest at every layer.\n *\n * The `kind` discriminator is installed as a non-enumerable own property\n * so the JSON envelope reads `{ \"id\": \"__unbound__\" }` — symmetric\n * with the family-level non-enumerable `kind` on `SqlNode` and bounded\n * to the minimum data the framework `Namespace` interface promises.\n *\n * **Freeze-trap warning.** The leaf constructor calls\n * `freezeNode(this)` after installing `kind`. The leaf-class shape\n * works today only because `NamespaceBase` does NOT freeze in its\n * constructor — the `Object.defineProperty(this, 'kind', …)` call after\n * `super()` succeeds because the instance is still mutable at that\n * point. Subclasses that add instance fields will still hit the freeze\n * trap once leaf-class `freezeNode(this)` runs; and if a future\n * framework change lifts the freeze to `NamespaceBase`, even the\n * `defineProperty` here would silently fail. To add subclass instance\n * fields safely, lift `freezeNode` to a leaf-class `seal()` hook each\n * leaf calls explicitly at the end of its own constructor.\n */\nexport class SqlUnboundNamespace extends NamespaceBase {\n static readonly instance: SqlUnboundNamespace = new SqlUnboundNamespace();\n\n readonly id = UNBOUND_NAMESPACE_ID;\n readonly tables: Readonly<Record<string, StorageTable>> = Object.freeze({});\n declare readonly kind: string;\n\n private constructor() {\n super();\n Object.defineProperty(this, 'kind', {\n value: 'sql-namespace',\n writable: false,\n enumerable: false,\n configurable: true,\n });\n freezeNode(this);\n }\n}\n","import type { ColumnDefault } from '@prisma-next/contract/types';\nimport { freezeNode } from '@prisma-next/framework-components/ir';\nimport { SqlNode } from './sql-node';\n\n/**\n * Hydration / construction input shape for {@link StorageColumn}. Mirrors\n * the on-disk storage JSON envelope exactly so the family-base\n * serializer's hydration walker can hand an arktype-validated literal\n * straight to `new`.\n *\n * `typeParams` and `typeRef` remain mutually exclusive (one or the\n * other, not both); the constructor preserves whichever caller-side\n * choice the input encodes.\n */\nexport interface StorageColumnInput {\n readonly nativeType: string;\n readonly codecId: string;\n readonly nullable: boolean;\n readonly typeParams?: Record<string, unknown>;\n readonly typeRef?: string;\n readonly default?: ColumnDefault;\n}\n\n/**\n * SQL Contract IR node for a single column entry in `StorageTable.columns`.\n *\n * Single concrete family-shared class — every SQL target reads the\n * same column shape today, so there is no per-target subclass. The\n * class type accepts any caller that constructs via\n * `new StorageColumn(input)`; literal construction sites must pass\n * through the constructor or the family-base hydration walker.\n *\n * The column's `name` is not on the class — columns are keyed by name\n * in the parent `StorageTable.columns: Record<string, StorageColumn>`\n * map, so a `name` field would be redundant with the key.\n */\nexport class StorageColumn extends SqlNode {\n readonly nativeType: string;\n readonly codecId: string;\n readonly nullable: boolean;\n declare readonly typeParams?: Record<string, unknown>;\n declare readonly typeRef?: string;\n declare readonly default?: ColumnDefault;\n\n constructor(input: StorageColumnInput) {\n super();\n this.nativeType = input.nativeType;\n this.codecId = input.codecId;\n this.nullable = input.nullable;\n if (input.typeParams !== undefined) this.typeParams = input.typeParams;\n if (input.typeRef !== undefined) this.typeRef = input.typeRef;\n if (input.default !== undefined) this.default = input.default;\n freezeNode(this);\n }\n}\n","import { freezeNode } from '@prisma-next/framework-components/ir';\nimport { SqlNode } from './sql-node';\n\nexport interface UniqueConstraintInput {\n readonly columns: readonly string[];\n readonly name?: string;\n}\n\n/**\n * SQL Contract IR node for a table-level unique constraint.\n */\nexport class UniqueConstraint extends SqlNode {\n readonly columns: readonly string[];\n declare readonly name?: string;\n\n constructor(input: UniqueConstraintInput) {\n super();\n this.columns = input.columns;\n if (input.name !== undefined) this.name = input.name;\n freezeNode(this);\n }\n}\n","import { freezeNode } from '@prisma-next/framework-components/ir';\nimport { ForeignKey, type ForeignKeyInput } from './foreign-key';\nimport { PrimaryKey, type PrimaryKeyInput } from './primary-key';\nimport { Index, type IndexInput } from './sql-index';\nimport { SqlNode } from './sql-node';\nimport { StorageColumn, type StorageColumnInput } from './storage-column';\nimport { UniqueConstraint, type UniqueConstraintInput } from './unique-constraint';\n\nexport interface StorageTableInput {\n readonly columns: Record<string, StorageColumn | StorageColumnInput>;\n readonly primaryKey?: PrimaryKey | PrimaryKeyInput;\n readonly uniques: ReadonlyArray<UniqueConstraint | UniqueConstraintInput>;\n readonly indexes: ReadonlyArray<Index | IndexInput>;\n readonly foreignKeys: ReadonlyArray<ForeignKey | ForeignKeyInput>;\n}\n\n/**\n * SQL Contract IR node for a single table entry in a namespace's\n * `tables` map.\n *\n * The constructor normalises nested IR-class fields (columns, primary\n * key, uniques, indexes, foreign keys) into the appropriate class\n * instances so downstream walks see a uniform AST regardless of whether\n * the input was a JSON literal or an already-constructed class.\n *\n * The table's `name` is not on the class — tables are keyed by name in\n * the parent namespace's `tables: Record<string, StorageTable>` map.\n */\nexport class StorageTable extends SqlNode {\n readonly columns: Readonly<Record<string, StorageColumn>>;\n readonly uniques: ReadonlyArray<UniqueConstraint>;\n readonly indexes: ReadonlyArray<Index>;\n readonly foreignKeys: ReadonlyArray<ForeignKey>;\n declare readonly primaryKey?: PrimaryKey;\n\n constructor(input: StorageTableInput) {\n super();\n this.columns = Object.freeze(\n Object.fromEntries(\n Object.entries(input.columns).map(([name, col]) => [\n name,\n col instanceof StorageColumn ? col : new StorageColumn(col),\n ]),\n ),\n );\n if (input.primaryKey !== undefined) {\n this.primaryKey =\n input.primaryKey instanceof PrimaryKey\n ? input.primaryKey\n : new PrimaryKey(input.primaryKey);\n }\n this.uniques = Object.freeze(\n input.uniques.map((u) => (u instanceof UniqueConstraint ? u : new UniqueConstraint(u))),\n );\n this.indexes = Object.freeze(input.indexes.map((i) => (i instanceof Index ? i : new Index(i))));\n this.foreignKeys = Object.freeze(\n input.foreignKeys.map((fk) => (fk instanceof ForeignKey ? fk : new ForeignKey(fk))),\n );\n freezeNode(this);\n }\n}\n","import type { StorageType } from '@prisma-next/framework-components/ir';\n\n/**\n * Sentinel kind for the legacy codec-triple shape persisted under\n * `SqlStorage.types`. Plain JSON-clean object literals carry this\n * discriminator so the polymorphic slot dispatch can route them down\n * the codec path while target-specific IR class instances (e.g. the\n * Postgres enum class) keep their own narrower `kind` literal.\n */\nexport const CODEC_INSTANCE_KIND = 'codec-instance' as const;\n\n/**\n * Structural sub-interface of {@link StorageType} for codec-typed entries\n * in `SqlStorage.types`. These are plain object literals — there is no\n * runtime IR class, the JSON envelope round-trips through the slot\n * unchanged. The `kind: 'codec-instance'` discriminator is the dispatch\n * key that distinguishes codec-typed entries from class-instance entries\n * (e.g. `PostgresEnumType`) sharing the polymorphic slot.\n */\nexport interface StorageTypeInstance extends StorageType {\n readonly kind: typeof CODEC_INSTANCE_KIND;\n readonly codecId: string;\n readonly nativeType: string;\n readonly typeParams: Record<string, unknown>;\n}\n\n/**\n * Construction-time input for a codec-triple entry. Symmetric with the\n * structural runtime shape minus the `kind` discriminator — callers may\n * omit `kind`; the helper {@link toStorageTypeInstance} stamps it on.\n */\nexport interface StorageTypeInstanceInput {\n readonly codecId: string;\n readonly nativeType: string;\n readonly typeParams: Record<string, unknown>;\n}\n\n/**\n * Stamp the codec-instance `kind` discriminator on a caller-supplied\n * codec triple. Idempotent: input that already carries the discriminator\n * passes through unchanged.\n */\nexport function toStorageTypeInstance(input: StorageTypeInstanceInput): StorageTypeInstance {\n return {\n kind: CODEC_INSTANCE_KIND,\n codecId: input.codecId,\n nativeType: input.nativeType,\n typeParams: input.typeParams,\n };\n}\n\n/**\n * Type-guard for codec-typed entries on the polymorphic\n * `SqlStorage.types` slot. Distinguishes `StorageTypeInstance` from\n * class-instance kinds (e.g. `PostgresEnumType`).\n */\nexport function isStorageTypeInstance(value: unknown): value is StorageTypeInstance {\n if (typeof value !== 'object' || value === null) return false;\n return (value as { kind?: unknown }).kind === CODEC_INSTANCE_KIND;\n}\n","import type { StorageHashBase } from '@prisma-next/contract/types';\nimport {\n freezeNode,\n type Namespace,\n NamespaceBase,\n type Storage,\n UNBOUND_NAMESPACE_ID,\n} from '@prisma-next/framework-components/ir';\nimport {\n isPostgresEnumStorageEntry,\n type PostgresEnumStorageEntry,\n} from './postgres-enum-storage-entry';\nimport { SqlNode } from './sql-node';\nimport { SqlUnboundNamespace } from './sql-unbound-namespace';\nimport { StorageTable, type StorageTableInput } from './storage-table';\nimport {\n isStorageTypeInstance,\n type StorageTypeInstance,\n type StorageTypeInstanceInput,\n} from './storage-type-instance';\n\n/**\n * Polymorphic value type for document-scoped `SqlStorage.types` entries\n * (codec aliases / parameterised native type registrations). Postgres\n * native enum registrations live under\n * `storage.namespaces[namespaceId].types` instead.\n */\nexport type SqlStorageTypeEntry =\n | StorageTypeInstance\n | StorageTypeInstanceInput\n | PostgresEnumStorageEntry;\n\nconst DEFAULT_NAMESPACES: Readonly<Record<string, Namespace>> = Object.freeze({\n [UNBOUND_NAMESPACE_ID]: SqlUnboundNamespace.instance,\n});\n\nexport interface SqlNamespaceTablesInput {\n readonly id: string;\n readonly tables?: Record<string, StorageTable | StorageTableInput>;\n readonly types?: Record<string, PostgresEnumStorageEntry>;\n}\n\nexport interface SqlStorageInput<THash extends string = string> {\n readonly storageHash: StorageHashBase<THash>;\n readonly types?: Record<string, SqlStorageTypeEntry>;\n readonly namespaces?: Readonly<Record<string, Namespace | SqlNamespaceTablesInput>>;\n}\n\nclass SqlNamespacePayload extends NamespaceBase {\n declare readonly kind: string;\n declare readonly types?: Readonly<Record<string, PostgresEnumStorageEntry>>;\n\n readonly id: string;\n readonly tables: Readonly<Record<string, StorageTable>>;\n\n constructor(input: SqlNamespaceTablesInput) {\n super();\n this.id = input.id;\n this.tables = Object.freeze(\n Object.fromEntries(\n Object.entries(input.tables ?? {}).map(([name, t]) => [\n name,\n t instanceof StorageTable ? t : new StorageTable(t),\n ]),\n ),\n );\n if (input.types !== undefined && Object.keys(input.types).length > 0) {\n Object.defineProperty(this, 'types', {\n value: Object.freeze({ ...input.types }),\n writable: false,\n enumerable: true,\n configurable: false,\n });\n }\n Object.defineProperty(this, 'kind', {\n value: 'sql-namespace',\n writable: false,\n enumerable: false,\n configurable: true,\n });\n freezeNode(this);\n }\n}\n\nfunction normaliseNamespaceEntry(\n nsKey: string,\n ns: Namespace | SqlNamespaceTablesInput,\n): Namespace {\n if (ns instanceof NamespaceBase) {\n return ns;\n }\n const input = ns as SqlNamespaceTablesInput; // JSON namespace payloads match SqlNamespaceTablesInput before SqlNamespacePayload materialises StorageTable instances.\n const tableCount = Object.keys(input.tables ?? {}).length;\n const typeCount = Object.keys(input.types ?? {}).length;\n if (nsKey === UNBOUND_NAMESPACE_ID && tableCount === 0 && typeCount === 0) {\n return SqlUnboundNamespace.instance;\n }\n return new SqlNamespacePayload(input);\n}\n\n/**\n * SQL Contract IR root node for the `storage` field.\n *\n * Single concrete family-shared class — both Postgres and SQLite\n * consume this class today. Per-target storage subclasses are\n * introduced when each target's namespace shape earns its\n * target-specific concretion (target-specific derived fields,\n * target-specific storage extensions).\n *\n * Honours the framework `Storage` interface: every SQL IR carries a\n * `namespaces` map keyed by namespace id. The default singleton\n * (`{ [UNBOUND_NAMESPACE_ID]: SqlUnboundNamespace.instance }`)\n * binds every contract authored before per-target namespace concretions\n * land; per-target namespace classes (`PostgresSchema.unbound`,\n * `SqliteUnboundDatabase.instance`) earn their slots when each\n * target's namespace shape lands.\n *\n * The constructor normalises optional `types` into class instances and\n * materialises plain namespace envelope objects into `Namespace` class\n * instances so downstream walks see a uniform AST.\n * `types` is polymorphic per Decision 18 Option B: codec-triple inputs\n * are stamped with `kind: 'codec-instance'`; class-instance kinds\n * (e.g. Postgres-enum entries satisfying `PostgresEnumStorageEntry`)\n * pass through; hydration of raw JSON class-instance entries (carrying\n * their narrower `kind` literal) is the per-target serializer's\n * responsibility (so the family base does not import target-specific\n * subclasses).\n */\n// SQL concretions always store `StorageTable`-shaped values in `tables`.\n// `tables` is a SQL-family idiom — the framework `Namespace` contract no\n// longer mandates this field; Mongo namespaces carry `collections`\n// instead. The `__unbound__` slot uses the same narrowing as every other\n// SQL namespace; the wider `Record<string, object>` on `StorageTable` is\n// only there so emitted `contract.d.ts` table literals (which lack the\n// runtime `kind` discriminator on `StorageTable`) structurally satisfy\n// the slot without a class-instance check.\nexport type SqlNamespace = Namespace & {\n readonly tables: Readonly<Record<string, StorageTable>>;\n readonly types?: Readonly<Record<string, PostgresEnumStorageEntry>>;\n};\n\nexport class SqlStorage<THash extends string = string> extends SqlNode implements Storage {\n readonly storageHash: StorageHashBase<THash>;\n readonly namespaces: Readonly<Record<string, SqlNamespace>> & {\n readonly __unbound__: SqlNamespace;\n };\n declare readonly types?: Readonly<Record<string, StorageTypeInstance | PostgresEnumStorageEntry>>;\n\n constructor(input: SqlStorageInput<THash>) {\n super();\n this.storageHash = input.storageHash;\n const inputNamespaces = input.namespaces ?? DEFAULT_NAMESPACES;\n const normalised: Record<string, SqlNamespace> = Object.fromEntries(\n Object.entries(inputNamespaces).map(([nsKey, ns]) => [\n nsKey,\n normaliseNamespaceEntry(nsKey, ns) as SqlNamespace,\n ]),\n );\n if (!normalised[UNBOUND_NAMESPACE_ID]) {\n normalised[UNBOUND_NAMESPACE_ID] = SqlUnboundNamespace.instance as SqlNamespace;\n }\n this.namespaces = Object.freeze(normalised) as Readonly<Record<string, SqlNamespace>> & {\n readonly __unbound__: SqlNamespace;\n };\n if (input.types !== undefined) {\n this.types = Object.freeze(\n Object.fromEntries(\n Object.entries(input.types).map(([name, ti]) => [name, normaliseTypeEntry(name, ti)]),\n ),\n );\n }\n freezeNode(this);\n }\n}\n\n/**\n * Strict polymorphic-slot dispatch for `SqlStorage.types` entries.\n * Every entry must carry a recognised `kind` discriminator — either\n * `'codec-instance'` (codec triple, family-shared) or\n * `'postgres-enum'` (target-specific IR class). Untagged or\n * unrecognised inputs throw a diagnostic naming the entry and its\n * `kind`, so format drift surfaces loudly at the deserializer\n * boundary instead of slipping past the seam and corrupting\n * downstream IR walks.\n *\n * Codec-triple authors that have an untagged shape on hand can call\n * `toStorageTypeInstance(...)` (which stamps the `'codec-instance'`\n * discriminator) before constructing `SqlStorage`. On-disk reads\n * cross `familyInstance.deserializeContract` first; the structural\n * arktype schema rejects untagged entries earlier, so this throw\n * only fires for in-memory authoring bugs.\n */\nfunction normaliseTypeEntry(\n name: string,\n entry: SqlStorageTypeEntry,\n): StorageTypeInstance | PostgresEnumStorageEntry {\n if (isPostgresEnumStorageEntry(entry)) {\n // Live class instances pass through unchanged; raw JSON envelopes\n // (e.g. `kind: 'postgres-enum'` without the class identity) are\n // rejected so the target serializer's hydration path is the only\n // way IR class instances enter the slot.\n if (entry instanceof SqlNode) {\n return entry;\n }\n throw new Error(\n `Encountered raw postgres-enum JSON in storage.types[${JSON.stringify(name)}] without serializer hydration; use a target ContractSerializer that registers the matching entity-type factory.`,\n );\n }\n if (isStorageTypeInstance(entry)) {\n return entry;\n }\n const rawKind = (entry as { kind?: unknown }).kind;\n const kindDescription =\n rawKind === undefined\n ? 'missing `kind` discriminator'\n : `unrecognised \\`kind\\` discriminator ${JSON.stringify(rawKind)}`;\n throw new Error(\n `storage.types[${JSON.stringify(name)}] has ${kindDescription}; expected ${JSON.stringify('codec-instance')} or ${JSON.stringify('postgres-enum')}. Untagged codec triples should be wrapped with toStorageTypeInstance(...) before construction.`,\n );\n}\n","import type { CodecTrait } from '@prisma-next/framework-components/codec';\nimport type { ReferentialAction } from './ir/foreign-key';\n\nexport {\n ForeignKey,\n type ForeignKeyInput,\n type ReferentialAction,\n} from './ir/foreign-key';\nexport {\n ForeignKeyReference,\n type ForeignKeyReferenceInput,\n} from './ir/foreign-key-reference';\nexport {\n isPostgresEnumStorageEntry,\n POSTGRES_ENUM_KIND,\n type PostgresEnumStorageEntry,\n} from './ir/postgres-enum-storage-entry';\nexport { PrimaryKey, type PrimaryKeyInput } from './ir/primary-key';\nexport { Index, type IndexInput } from './ir/sql-index';\nexport { SqlNode } from './ir/sql-node';\nexport {\n type SqlNamespaceTablesInput,\n SqlStorage,\n type SqlStorageInput,\n type SqlStorageTypeEntry,\n} from './ir/sql-storage';\nexport { SqlUnboundNamespace } from './ir/sql-unbound-namespace';\nexport { StorageColumn, type StorageColumnInput } from './ir/storage-column';\nexport { StorageTable, type StorageTableInput } from './ir/storage-table';\nexport {\n CODEC_INSTANCE_KIND,\n isStorageTypeInstance,\n type StorageTypeInstance,\n type StorageTypeInstanceInput,\n toStorageTypeInstance,\n} from './ir/storage-type-instance';\nexport {\n UniqueConstraint,\n type UniqueConstraintInput,\n} from './ir/unique-constraint';\n\nexport type ForeignKeyOptions = {\n readonly name?: string;\n readonly onDelete?: ReferentialAction;\n readonly onUpdate?: ReferentialAction;\n};\n\nexport type SqlModelFieldStorage = {\n readonly column: string;\n readonly codecId?: string;\n readonly nullable?: boolean;\n};\n\nexport type SqlModelStorage = {\n readonly table: string;\n readonly fields: Record<string, SqlModelFieldStorage>;\n};\n\nexport const DEFAULT_FK_CONSTRAINT = true;\nexport const DEFAULT_FK_INDEX = true;\n\nexport function applyFkDefaults(\n fk: { constraint?: boolean | undefined; index?: boolean | undefined },\n overrideDefaults?: { constraint?: boolean | undefined; index?: boolean | undefined },\n): { constraint: boolean; index: boolean } {\n return {\n constraint: fk.constraint ?? overrideDefaults?.constraint ?? DEFAULT_FK_CONSTRAINT,\n index: fk.index ?? overrideDefaults?.index ?? DEFAULT_FK_INDEX,\n };\n}\n\nexport type TypeMaps<\n TCodecTypes extends Record<string, { output: unknown }> = Record<string, never>,\n TQueryOperationTypes extends Record<string, unknown> = Record<string, never>,\n TFieldOutputTypes extends Record<string, Record<string, unknown>> = Record<string, never>,\n TFieldInputTypes extends Record<string, Record<string, unknown>> = Record<string, never>,\n> = {\n readonly codecTypes: TCodecTypes;\n readonly queryOperationTypes: TQueryOperationTypes;\n readonly fieldOutputTypes: TFieldOutputTypes;\n readonly fieldInputTypes: TFieldInputTypes;\n};\n\nexport type CodecTypesOf<T> = [T] extends [never]\n ? Record<string, never>\n : T extends { readonly codecTypes: infer C }\n ? C extends Record<string, { output: unknown }>\n ? C\n : Record<string, never>\n : Record<string, never>;\n\n/**\n * Dispatch hint identifying the first-argument target of an operation.\n *\n * Used by ORM column helpers to decide whether an operation is reachable on a\n * field. Either names a concrete codec identity or a set of capability traits\n * that the field's codec must carry.\n */\nexport type QueryOperationSelfSpec =\n | { readonly codecId: string; readonly traits?: never }\n | { readonly traits: readonly CodecTrait[]; readonly codecId?: never };\n\n/**\n * Structural shape an operation's impl must return: any value carrying a\n * codec-exact `returnType` descriptor. `Expression<T>` (from\n * `@prisma-next/sql-relational-core/expression`, with `T extends ScopeField`)\n * extends this. Trait-targeted returns are deliberately excluded — predicate\n * detection and result decoding both depend on knowing the concrete return\n * codec.\n */\nexport type QueryOperationReturn = {\n readonly returnType: { readonly codecId: string; readonly nullable: boolean };\n};\n\nexport type QueryOperationTypeEntry = {\n readonly self?: QueryOperationSelfSpec;\n readonly impl: (...args: never[]) => QueryOperationReturn;\n};\n\nexport type SqlQueryOperationTypes<\n _CT extends Record<string, { readonly input: unknown; readonly output: unknown }>,\n T extends Record<string, QueryOperationTypeEntry>,\n> = T;\n\nexport type QueryOperationTypesBase = Record<string, QueryOperationTypeEntry>;\n\nexport type QueryOperationTypesOf<T> = [T] extends [never]\n ? Record<string, never>\n : T extends { readonly queryOperationTypes: infer Q }\n ? Q extends Record<string, unknown>\n ? Q\n : Record<string, never>\n : Record<string, never>;\n\nexport type TypeMapsPhantomKey = '__@prisma-next/sql-contract/typeMaps@__';\n\nexport type ContractWithTypeMaps<TContract, TTypeMaps> = TContract & {\n readonly [K in TypeMapsPhantomKey]?: TTypeMaps;\n};\n\nexport type ExtractTypeMapsFromContract<T> = TypeMapsPhantomKey extends keyof T\n ? NonNullable<T[TypeMapsPhantomKey & keyof T]>\n : never;\n\nexport type FieldOutputTypesOf<T> = [T] extends [never]\n ? Record<string, never>\n : T extends { readonly fieldOutputTypes: infer F }\n ? F extends Record<string, Record<string, unknown>>\n ? F\n : Record<string, never>\n : Record<string, never>;\n\nexport type FieldInputTypesOf<T> = [T] extends [never]\n ? Record<string, never>\n : T extends { readonly fieldInputTypes: infer F }\n ? F extends Record<string, Record<string, unknown>>\n ? F\n : Record<string, never>\n : Record<string, never>;\n\nexport type ExtractCodecTypes<T> = CodecTypesOf<ExtractTypeMapsFromContract<T>>;\nexport type ExtractQueryOperationTypes<T> = QueryOperationTypesOf<ExtractTypeMapsFromContract<T>>;\nexport type ExtractFieldOutputTypes<T> = FieldOutputTypesOf<ExtractTypeMapsFromContract<T>>;\nexport type ExtractFieldInputTypes<T> = FieldInputTypesOf<ExtractTypeMapsFromContract<T>>;\n\nexport type ResolveCodecTypes<TContract, TTypeMaps> = [TTypeMaps] extends [never]\n ? ExtractCodecTypes<TContract>\n : CodecTypesOf<TTypeMaps>;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkCA,IAAsB,UAAtB,cAAsC,WAAW;CAC/C;CAEA,cAAc;EACZ,OAAO;EACP,OAAO,eAAe,MAAM,QAAQ;GAClC,OAAO;GACP,UAAU;GACV,YAAY;GAMZ,cAAc;GACf,CAAC;;;;;;;;;;;;ACjCN,IAAa,sBAAb,cAAyC,QAAQ;CAC/C;CACA;CACA;CAEA,YAAY,OAAiC;EAC3C,OAAO;EACP,KAAK,cAAc,MAAM;EACzB,KAAK,YAAY,MAAM;EACvB,KAAK,UAAU,MAAM;EACrB,WAAW,KAAK;;;;;;;;;;;;;;;;;ACIpB,IAAa,aAAb,cAAgC,QAAQ;CACtC;CACA;CACA;CACA;CAKA,YAAY,OAAwB;EAClC,OAAO;EACP,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