@prisma-next/sql-contract 0.9.0 → 0.10.0

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.
package/src/validators.ts CHANGED
@@ -1,15 +1,17 @@
1
1
  import { ContractValidationError } from '@prisma-next/contract/contract-validation-error';
2
2
  import type { Contract, ContractField, ContractModel } from '@prisma-next/contract/types';
3
3
  import { validateContractDomain } from '@prisma-next/contract/validate-domain';
4
+ import type { Namespace } from '@prisma-next/framework-components/ir';
4
5
  import { type } from 'arktype';
5
6
  import {
6
7
  type ForeignKeyInput,
7
- type ForeignKeyReferencesInput,
8
+ type ForeignKeyReferenceInput,
8
9
  type PrimaryKeyInput,
9
10
  type ReferentialAction,
10
11
  type SqlModelStorage,
11
12
  SqlStorage,
12
13
  type SqlStorageInput,
14
+ type StorageTable,
13
15
  type StorageTypeInstanceInput,
14
16
  type UniqueConstraintInput,
15
17
  } from './types';
@@ -96,43 +98,19 @@ const StorageTypeInstanceSchema = type
96
98
  });
97
99
 
98
100
  /**
99
- * Polymorphic enum-type entry under `storage.types[name]`. Carries an
100
- * enumerable literal `kind: 'postgres-enum'` discriminator so the
101
- * per-target hydration walker can dispatch cleanly back to a typed
102
- * IR-class instance during `deserializeContract`. The discriminator
103
- * reflects target-level behaviour (Postgres-native enums versus
104
- * family-layer codec triples) — not the family abstract altitude alone.
105
- *
106
- * The schema literal lives at the family layer today because
107
- * registry-driven validation for arbitrary slot shapes is not wired
108
- * yet; once a second polymorphic kind ships through the slot, this
109
- * structural enumeration can move to the registry-dispatch site and
110
- * per-target schemas can live in their target packages.
101
+ * Postgres native enum entry under `storage.namespaces[namespaceId].types[name]`.
102
+ * Document-scoped `storage.types` carries codec aliases only
103
+ * (`DocumentScopedStorageTypeSchema`).
111
104
  */
112
105
  const PostgresEnumTypeSchema = type({
113
106
  kind: "'postgres-enum'",
114
- name: 'string',
115
- nativeType: 'string',
107
+ 'name?': 'string',
108
+ 'nativeType?': 'string',
116
109
  values: type.string.array().readonly(),
117
110
  });
118
111
 
119
- /**
120
- * Family-layer arktype validation enumerates the polymorphic shapes the
121
- * SQL family ships today (codec-instance + Postgres-enum). Pack-contributed
122
- * entity types ship a parallel arktype schema entry here when they
123
- * introduce a new persisted shape; the registry-driven hydration seam at
124
- * `SqlContractSerializerBase.hydrateStorageTypeEntry` is open, but the
125
- * family-layer structural validator is closed by design — extension
126
- * packs cannot inject arbitrary persisted shapes through the slot
127
- * without their structural shape being known at the family layer.
128
- *
129
- * A future refinement is to lift `StorageTypeEntrySchema` toward an
130
- * `unknown` fallback and move structural diagnostics to the
131
- * registry-dispatch site at hydration time, earned once a non-enum
132
- * storage shape needs to flow through the slot without growing another
133
- * closed union arm here first.
134
- */
135
- const StorageTypeEntrySchema = PostgresEnumTypeSchema.or(StorageTypeInstanceSchema);
112
+ /** Document-scoped `storage.types`: codec triples only. */
113
+ const DocumentScopedStorageTypeSchema = StorageTypeInstanceSchema;
136
114
 
137
115
  const PrimaryKeySchema = type.declare<PrimaryKeyInput>().type({
138
116
  columns: type.string.array().readonly(),
@@ -151,8 +129,9 @@ export const IndexSchema = type({
151
129
  'options?': 'Record<string, unknown>',
152
130
  });
153
131
 
154
- export const ForeignKeyReferencesSchema = type.declare<ForeignKeyReferencesInput>().type({
155
- table: 'string',
132
+ export const ForeignKeyReferenceSchema = type.declare<ForeignKeyReferenceInput>().type({
133
+ namespaceId: 'string',
134
+ tableName: 'string',
156
135
  columns: type.string.array().readonly(),
157
136
  });
158
137
 
@@ -161,8 +140,8 @@ export const ReferentialActionSchema = type
161
140
  .type("'noAction' | 'restrict' | 'cascade' | 'setNull' | 'setDefault'");
162
141
 
163
142
  export const ForeignKeySchema = type.declare<ForeignKeyInput>().type({
164
- columns: type.string.array().readonly(),
165
- references: ForeignKeyReferencesSchema,
143
+ source: ForeignKeyReferenceSchema,
144
+ target: ForeignKeyReferenceSchema,
166
145
  'name?': 'string',
167
146
  'onDelete?': ReferentialActionSchema,
168
147
  'onUpdate?': ReferentialActionSchema,
@@ -180,26 +159,58 @@ const StorageTableSchema = type({
180
159
  });
181
160
 
182
161
  /**
183
- * Namespace entry under `storage.namespaces[id]`. SQL contracts honour
184
- * the framework `Storage.namespaces` invariant from PR1; today every
185
- * contract binds to the singleton placeholder
186
- * (`SqlUnspecifiedNamespace.instance`) and the persisted shape carries
187
- * just the namespace id. Per-target namespace concretions
188
- * (`PostgresSchema`, `SqliteUnspecifiedDatabase`) can additively grow
189
- * the persisted shape when they earn their slots.
162
+ * Namespace entry under `storage.namespaces[id]`. Tables live on each
163
+ * namespace; the unbound sentinel may appear as a plain `{ id }`
164
+ * envelope (normalised to `SqlUnboundNamespace.instance` by
165
+ * {@link SqlStorage}'s constructor) or carry a `tables` map when the
166
+ * late-bound slot holds authored tables.
190
167
  */
191
168
  const NamespaceEntrySchema = type({
169
+ '+': 'reject',
192
170
  id: 'string',
171
+ 'kind?': 'string',
172
+ 'tables?': type({ '[string]': StorageTableSchema }),
173
+ 'types?': type({ '[string]': PostgresEnumTypeSchema }),
193
174
  });
194
175
 
195
176
  const StorageSchema = type({
196
177
  '+': 'reject',
197
178
  storageHash: 'string',
198
- tables: type({ '[string]': StorageTableSchema }),
199
- 'types?': type({ '[string]': StorageTypeEntrySchema }),
179
+ 'types?': type({ '[string]': DocumentScopedStorageTypeSchema }),
200
180
  'namespaces?': type({ '[string]': NamespaceEntrySchema }),
201
181
  });
202
182
 
183
+ // SQL-specific namespace walk shape (`tables` is the SQL family's idiom —
184
+ // the framework `Namespace` interface no longer carries it). The wider
185
+ // `object` table value keeps this helper structurally compatible with
186
+ // `SqlNamespace` (whose tables narrow to `StorageTable`) and the JSON
187
+ // envelope variants that lose class identity.
188
+ type NamespacedStorageWalk = {
189
+ readonly namespaces: Readonly<
190
+ Record<string, Namespace & { readonly tables?: Readonly<Record<string, object>> }>
191
+ >;
192
+ };
193
+
194
+ function eachStorageTable(storage: NamespacedStorageWalk) {
195
+ return Object.entries(storage.namespaces).flatMap(([namespaceId, ns]) =>
196
+ Object.entries(ns.tables ?? {}).map(([tableName, table]) => ({
197
+ namespaceId,
198
+ tableName,
199
+ table,
200
+ })),
201
+ );
202
+ }
203
+
204
+ function findStorageTableByTableName(storage: NamespacedStorageWalk, tableName: string): unknown {
205
+ for (const ns of Object.values(storage.namespaces)) {
206
+ const t = ns.tables?.[tableName];
207
+ if (t !== undefined) {
208
+ return t;
209
+ }
210
+ }
211
+ return undefined;
212
+ }
213
+
203
214
  function isPlainRecord(value: unknown): value is Record<string, unknown> {
204
215
  return typeof value === 'object' && value !== null && !Array.isArray(value);
205
216
  }
@@ -309,7 +320,7 @@ export function validateStorage(value: unknown): SqlStorage {
309
320
  }
310
321
  // The arktype-validated shape matches `SqlStorageInput`
311
322
  // structurally. Funnel through the constructor so nested IR fields
312
- // (`tables`, `types`) are normalised into class instances and the
323
+ // (`types`) are normalised into class instances and the
313
324
  // branded `storageHash` is preserved on the returned `SqlStorage`.
314
325
  return new SqlStorage(result as SqlStorageInput);
315
326
  }
@@ -376,7 +387,8 @@ function validateSqlContractStructure<T extends Contract<SqlStorage>>(value: unk
376
387
  export function validateStorageSemantics(storage: SqlStorage): string[] {
377
388
  const errors: string[] = [];
378
389
 
379
- for (const [tableName, table] of Object.entries(storage.tables)) {
390
+ for (const { namespaceId, tableName, table: rawTable } of eachStorageTable(storage)) {
391
+ const table = rawTable as StorageTable;
380
392
  const namedObjects = new Map<string, string[]>();
381
393
  const registerNamedObject = (kind: string, name: string | undefined) => {
382
394
  if (!name) return;
@@ -397,7 +409,7 @@ export function validateStorageSemantics(storage: SqlStorage): string[] {
397
409
  for (const [name, kinds] of namedObjects) {
398
410
  if (kinds.length > 1) {
399
411
  errors.push(
400
- `Table "${tableName}": named object "${name}" is declared multiple times (${kinds.join(', ')})`,
412
+ `Namespace "${namespaceId}" table "${tableName}": named object "${name}" is declared multiple times (${kinds.join(', ')})`,
401
413
  );
402
414
  }
403
415
  }
@@ -406,7 +418,7 @@ export function validateStorageSemantics(storage: SqlStorage): string[] {
406
418
  const duplicateColumn = findDuplicateValue(table.primaryKey.columns);
407
419
  if (duplicateColumn !== undefined) {
408
420
  errors.push(
409
- `Table "${tableName}": primary key contains duplicate column "${duplicateColumn}"`,
421
+ `Namespace "${namespaceId}" table "${tableName}": primary key contains duplicate column "${duplicateColumn}"`,
410
422
  );
411
423
  }
412
424
 
@@ -414,7 +426,7 @@ export function validateStorageSemantics(storage: SqlStorage): string[] {
414
426
  const column = table.columns[columnName];
415
427
  if (column?.nullable === true) {
416
428
  errors.push(
417
- `Table "${tableName}": primary key column "${columnName}" is nullable; primary key columns must be NOT NULL`,
429
+ `Namespace "${namespaceId}" table "${tableName}": primary key column "${columnName}" is nullable; primary key columns must be NOT NULL`,
418
430
  );
419
431
  }
420
432
  }
@@ -425,14 +437,14 @@ export function validateStorageSemantics(storage: SqlStorage): string[] {
425
437
  const duplicateColumn = findDuplicateValue(unique.columns);
426
438
  if (duplicateColumn !== undefined) {
427
439
  errors.push(
428
- `Table "${tableName}": unique constraint contains duplicate column "${duplicateColumn}"`,
440
+ `Namespace "${namespaceId}" table "${tableName}": unique constraint contains duplicate column "${duplicateColumn}"`,
429
441
  );
430
442
  }
431
443
 
432
444
  const signature = JSON.stringify({ columns: unique.columns });
433
445
  if (seenUniqueDefinitions.has(signature)) {
434
446
  errors.push(
435
- `Table "${tableName}": duplicate unique constraint definition on columns [${unique.columns.join(', ')}]`,
447
+ `Namespace "${namespaceId}" table "${tableName}": duplicate unique constraint definition on columns [${unique.columns.join(', ')}]`,
436
448
  );
437
449
  continue;
438
450
  }
@@ -446,7 +458,9 @@ export function validateStorageSemantics(storage: SqlStorage): string[] {
446
458
  for (const index of table.indexes) {
447
459
  const duplicateColumn = findDuplicateValue(index.columns);
448
460
  if (duplicateColumn !== undefined) {
449
- errors.push(`Table "${tableName}": index contains duplicate column "${duplicateColumn}"`);
461
+ errors.push(
462
+ `Namespace "${namespaceId}" table "${tableName}": index contains duplicate column "${duplicateColumn}"`,
463
+ );
450
464
  }
451
465
 
452
466
  const signature = JSON.stringify({
@@ -456,7 +470,7 @@ export function validateStorageSemantics(storage: SqlStorage): string[] {
456
470
  });
457
471
  if (seenIndexDefinitions.has(signature)) {
458
472
  errors.push(
459
- `Table "${tableName}": duplicate index definition on columns [${index.columns.join(', ')}]`,
473
+ `Namespace "${namespaceId}" table "${tableName}": duplicate index definition on columns [${index.columns.join(', ')}]`,
460
474
  );
461
475
  continue;
462
476
  }
@@ -466,8 +480,8 @@ export function validateStorageSemantics(storage: SqlStorage): string[] {
466
480
  const seenForeignKeyDefinitions = new Set<string>();
467
481
  for (const fk of table.foreignKeys) {
468
482
  const signature = JSON.stringify({
469
- columns: fk.columns,
470
- references: fk.references,
483
+ source: fk.source,
484
+ target: fk.target,
471
485
  onDelete: fk.onDelete ?? null,
472
486
  onUpdate: fk.onUpdate ?? null,
473
487
  constraint: fk.constraint,
@@ -475,7 +489,7 @@ export function validateStorageSemantics(storage: SqlStorage): string[] {
475
489
  });
476
490
  if (seenForeignKeyDefinitions.has(signature)) {
477
491
  errors.push(
478
- `Table "${tableName}": duplicate foreign key definition on columns [${fk.columns.join(', ')}]`,
492
+ `Namespace "${namespaceId}" table "${tableName}": duplicate foreign key definition on columns [${fk.source.columns.join(', ')}]`,
479
493
  );
480
494
  continue;
481
495
  }
@@ -483,28 +497,28 @@ export function validateStorageSemantics(storage: SqlStorage): string[] {
483
497
  }
484
498
 
485
499
  for (const fk of table.foreignKeys) {
486
- for (const colName of fk.columns) {
500
+ for (const colName of fk.source.columns) {
487
501
  const column = table.columns[colName];
488
502
  if (!column) continue;
489
503
 
490
504
  if (fk.onDelete === 'setNull' && !column.nullable) {
491
505
  errors.push(
492
- `Table "${tableName}": onDelete setNull on foreign key column "${colName}" which is NOT NULL`,
506
+ `Namespace "${namespaceId}" table "${tableName}": onDelete setNull on foreign key column "${colName}" which is NOT NULL`,
493
507
  );
494
508
  }
495
509
  if (fk.onUpdate === 'setNull' && !column.nullable) {
496
510
  errors.push(
497
- `Table "${tableName}": onUpdate setNull on foreign key column "${colName}" which is NOT NULL`,
511
+ `Namespace "${namespaceId}" table "${tableName}": onUpdate setNull on foreign key column "${colName}" which is NOT NULL`,
498
512
  );
499
513
  }
500
514
  if (fk.onDelete === 'setDefault' && !column.nullable && column.default === undefined) {
501
515
  errors.push(
502
- `Table "${tableName}": onDelete setDefault on foreign key column "${colName}" which is NOT NULL and has no DEFAULT`,
516
+ `Namespace "${namespaceId}" table "${tableName}": onDelete setDefault on foreign key column "${colName}" which is NOT NULL and has no DEFAULT`,
503
517
  );
504
518
  }
505
519
  if (fk.onUpdate === 'setDefault' && !column.nullable && column.default === undefined) {
506
520
  errors.push(
507
- `Table "${tableName}": onUpdate setDefault on foreign key column "${colName}" which is NOT NULL and has no DEFAULT`,
521
+ `Namespace "${namespaceId}" table "${tableName}": onUpdate setDefault on foreign key column "${colName}" which is NOT NULL and has no DEFAULT`,
508
522
  );
509
523
  }
510
524
  }
@@ -525,16 +539,16 @@ export function validateModelStorageReferences(contract: Contract<SqlStorage>):
525
539
  for (const [modelName, model] of Object.entries(models)) {
526
540
  const storageTable = model.storage.table;
527
541
 
528
- const table = contract.storage.tables[storageTable] as
529
- | (typeof contract.storage.tables)[string]
530
- | undefined;
531
- if (!table) {
542
+ const rawTable = findStorageTableByTableName(contract.storage, storageTable);
543
+ if (rawTable === undefined) {
532
544
  throw new ContractValidationError(
533
545
  `Model "${modelName}" references non-existent table "${storageTable}"`,
534
546
  'storage',
535
547
  );
536
548
  }
537
549
 
550
+ const table = rawTable as StorageTable;
551
+
538
552
  const columnNames = new Set(Object.keys(table.columns));
539
553
  for (const [fieldName, field] of Object.entries(model.storage.fields)) {
540
554
  if (!columnNames.has(field.column)) {
@@ -570,16 +584,15 @@ export function validateModelStorageReferences(contract: Contract<SqlStorage>):
570
584
  * counts match their referenced columns. Throws on the first mismatch.
571
585
  */
572
586
  export function validateSqlStorageConsistency(contract: Contract<SqlStorage>): void {
573
- const tableNames = new Set(Object.keys(contract.storage.tables));
574
-
575
- for (const [tableName, table] of Object.entries(contract.storage.tables)) {
587
+ for (const { namespaceId, tableName, table: rawTable } of eachStorageTable(contract.storage)) {
588
+ const table = rawTable as StorageTable;
576
589
  const columnNames = new Set(Object.keys(table.columns));
577
590
 
578
591
  if (table.primaryKey) {
579
592
  for (const colName of table.primaryKey.columns) {
580
593
  if (!columnNames.has(colName)) {
581
594
  throw new ContractValidationError(
582
- `Table "${tableName}" primaryKey references non-existent column "${colName}"`,
595
+ `Namespace "${namespaceId}" table "${tableName}" primaryKey references non-existent column "${colName}"`,
583
596
  'storage',
584
597
  );
585
598
  }
@@ -590,7 +603,7 @@ export function validateSqlStorageConsistency(contract: Contract<SqlStorage>): v
590
603
  for (const colName of unique.columns) {
591
604
  if (!columnNames.has(colName)) {
592
605
  throw new ContractValidationError(
593
- `Table "${tableName}" unique constraint references non-existent column "${colName}"`,
606
+ `Namespace "${namespaceId}" table "${tableName}" unique constraint references non-existent column "${colName}"`,
594
607
  'storage',
595
608
  );
596
609
  }
@@ -601,7 +614,7 @@ export function validateSqlStorageConsistency(contract: Contract<SqlStorage>): v
601
614
  for (const colName of index.columns) {
602
615
  if (!columnNames.has(colName)) {
603
616
  throw new ContractValidationError(
604
- `Table "${tableName}" index references non-existent column "${colName}"`,
617
+ `Namespace "${namespaceId}" table "${tableName}" index references non-existent column "${colName}"`,
605
618
  'storage',
606
619
  );
607
620
  }
@@ -611,44 +624,51 @@ export function validateSqlStorageConsistency(contract: Contract<SqlStorage>): v
611
624
  for (const [colName, column] of Object.entries(table.columns)) {
612
625
  if (!column.nullable && column.default?.kind === 'literal' && column.default.value === null) {
613
626
  throw new ContractValidationError(
614
- `Table "${tableName}" column "${colName}" is NOT NULL but has a literal null default`,
627
+ `Namespace "${namespaceId}" table "${tableName}" column "${colName}" is NOT NULL but has a literal null default`,
615
628
  'storage',
616
629
  );
617
630
  }
618
631
  }
619
632
 
620
633
  for (const fk of table.foreignKeys) {
621
- for (const colName of fk.columns) {
634
+ if (fk.source.namespaceId !== namespaceId || fk.source.tableName !== tableName) {
635
+ throw new ContractValidationError(
636
+ `Namespace "${namespaceId}" table "${tableName}" contains foreignKey with mismatched source coordinates (${fk.source.namespaceId}.${fk.source.tableName})`,
637
+ 'storage',
638
+ );
639
+ }
640
+
641
+ for (const colName of fk.source.columns) {
622
642
  if (!columnNames.has(colName)) {
623
643
  throw new ContractValidationError(
624
- `Table "${tableName}" foreignKey references non-existent column "${colName}"`,
644
+ `Namespace "${namespaceId}" table "${tableName}" foreignKey references non-existent column "${colName}"`,
625
645
  'storage',
626
646
  );
627
647
  }
628
648
  }
629
649
 
630
- if (!tableNames.has(fk.references.table)) {
650
+ const targetNamespace = contract.storage.namespaces[fk.target.namespaceId];
651
+ const referencedRaw = targetNamespace?.tables?.[fk.target.tableName];
652
+ if (referencedRaw === undefined) {
631
653
  throw new ContractValidationError(
632
- `Table "${tableName}" foreignKey references non-existent table "${fk.references.table}"`,
654
+ `Namespace "${namespaceId}" table "${tableName}" foreignKey references non-existent table "${fk.target.namespaceId}.${fk.target.tableName}"`,
633
655
  'storage',
634
656
  );
635
657
  }
636
-
637
- const referencedTable = contract.storage.tables[fk.references.table];
638
- if (!referencedTable) continue;
658
+ const referencedTable = referencedRaw as StorageTable;
639
659
  const referencedColumnNames = new Set(Object.keys(referencedTable.columns));
640
- for (const colName of fk.references.columns) {
660
+ for (const colName of fk.target.columns) {
641
661
  if (!referencedColumnNames.has(colName)) {
642
662
  throw new ContractValidationError(
643
- `Table "${tableName}" foreignKey references non-existent column "${colName}" in table "${fk.references.table}"`,
663
+ `Namespace "${namespaceId}" table "${tableName}" foreignKey references non-existent column "${colName}" in table "${fk.target.tableName}"`,
644
664
  'storage',
645
665
  );
646
666
  }
647
667
  }
648
668
 
649
- if (fk.columns.length !== fk.references.columns.length) {
669
+ if (fk.source.columns.length !== fk.target.columns.length) {
650
670
  throw new ContractValidationError(
651
- `Table "${tableName}" foreignKey column count (${fk.columns.length}) does not match referenced column count (${fk.references.columns.length})`,
671
+ `Namespace "${namespaceId}" table "${tableName}" foreignKey column count (${fk.source.columns.length}) does not match referenced column count (${fk.target.columns.length})`,
652
672
  'storage',
653
673
  );
654
674
  }
@@ -1 +0,0 @@
1
- {"version":3,"file":"types-B0lbr9cb.d.mts","names":[],"sources":["../src/ir/sql-node.ts","../src/ir/foreign-key-references.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-unspecified-namespace.ts","../src/types.ts"],"mappings":";;;;;;;;;AAkCA;;;;;;;;;;;;AC/BA;;;;;AAYA;;;;;;;;;;;uBDmBsB,OAAA,SAAgB,UAAA;EAAA,SAC3B,IAAA;;;;;UChCM,yBAAA;EAAA,SACN,KAAA;EAAA,SACA,OAAA;AAAA;AD6BX;;;;;;;AAAA,cCnBa,oBAAA,SAA6B,OAAA;EAAA,SAC/B,KAAA;EAAA,SACA,OAAA;cAEG,KAAA,EAAO,yBAAA;AAAA;;;KCfT,iBAAA;AAAA,UAEK,eAAA;EAAA,SACN,OAAA;EAAA,SACA,UAAA,EAAY,oBAAA,GAAuB,yBAAA;EAAA,SACnC,IAAA;EAAA,SACA,QAAA,GAAW,iBAAA;EAAA,SACX,QAAA,GAAW,iBAAA;EFuBgB;EAAA,SErB3B,UAAA;;WAEA,KAAA;AAAA;;;;ADZX;;;;;cCuBa,UAAA,SAAmB,OAAA;EAAA,SACrB,OAAA;EAAA,SACA,UAAA,EAAY,oBAAA;EAAA,SACZ,UAAA;EAAA,SACA,KAAA;EAAA,SACQ,IAAA;EAAA,SACA,QAAA,GAAW,iBAAA;EAAA,SACX,QAAA,GAAW,iBAAA;cAEhB,KAAA,EAAO,eAAA;AAAA;;;;;;;AFDrB;;;;;;;;;;;cGjBa,kBAAA;AFdb;;;;;A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A,IACnB,CAAA,SAAU,MAAA,SAAe,MAAA,qBACvB,CAAA,GACA,MAAA,kBACF,MAAA;AAAA,KAEM,iBAAA,MAAuB,YAAA,CAAa,2BAAA,CAA4B,CAAA;AAAA,KAChE,0BAAA,MAAgC,qBAAA,CAAsB,2BAAA,CAA4B,CAAA;AAAA,KAClF,uBAAA,MAA6B,kBAAA,CAAmB,2BAAA,CAA4B,CAAA;AAAA,KAC5E,sBAAA,MAA4B,iBAAA,CAAkB,2BAAA,CAA4B,CAAA;AAAA,KAE1E,iBAAA,0BAA2C,SAAA,oBACnD,iBAAA,CAAkB,SAAA,IAClB,YAAA,CAAa,SAAA"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"types-iqFGDcJp.mjs","names":[],"sources":["../src/ir/sql-node.ts","../src/ir/foreign-key-references.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-unspecified-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 ForeignKeyReferencesInput {\n readonly table: string;\n readonly columns: readonly string[];\n}\n\n/**\n * SQL Contract IR node for the referenced side of a foreign key.\n *\n * The class is shaped around single-namespace references today; a\n * future milestone introduces a cross-namespace coordinate on top of\n * `(table, columns)` when namespace-keyed storage lands.\n */\nexport class ForeignKeyReferences extends SqlNode {\n readonly table: string;\n readonly columns: readonly string[];\n\n constructor(input: ForeignKeyReferencesInput) {\n super();\n this.table = input.table;\n this.columns = input.columns;\n freezeNode(this);\n }\n}\n","import { freezeNode } from '@prisma-next/framework-components/ir';\nimport { ForeignKeyReferences, type ForeignKeyReferencesInput } from './foreign-key-references';\nimport { SqlNode } from './sql-node';\n\nexport type ReferentialAction = 'noAction' | 'restrict' | 'cascade' | 'setNull' | 'setDefault';\n\nexport interface ForeignKeyInput {\n readonly columns: readonly string[];\n readonly references: ForeignKeyReferences | ForeignKeyReferencesInput;\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 * The nested `references` field is normalised to a\n * {@link ForeignKeyReferences} instance inside the constructor so\n * downstream walks see a uniform AST regardless of whether the input\n * was a JSON literal or an already-constructed class instance.\n */\nexport class ForeignKey extends SqlNode {\n readonly columns: readonly string[];\n readonly references: ForeignKeyReferences;\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.columns = input.columns;\n this.references =\n input.references instanceof ForeignKeyReferences\n ? input.references\n : new ForeignKeyReferences(input.references);\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 UNSPECIFIED_NAMESPACE_ID,\n} from '@prisma-next/framework-components/ir';\n\n/**\n * Family-layer placeholder for the SQL unspecified-namespace singleton.\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.unspecified`, `SqliteUnspecifiedDatabase.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\": \"__unspecified__\" }` — 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 SqlUnspecifiedNamespace extends NamespaceBase {\n static readonly instance: SqlUnspecifiedNamespace = new SqlUnspecifiedNamespace();\n\n readonly id = UNSPECIFIED_NAMESPACE_ID;\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 `SqlStorage.tables`.\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 `SqlStorage.tables: Record<string, StorageTable>` map.\n * A future namespace-aware milestone will add a `namespaceId` field\n * when namespace-keyed storage lands; today's single-namespace shape\n * needs neither field.\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 type Storage,\n UNSPECIFIED_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 { SqlUnspecifiedNamespace } from './sql-unspecified-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 `SqlStorage.types` entries (Decision 18,\n * Option B). The slot's framework alphabet is `StorageType` — codec\n * triples (`StorageTypeInstance` with `kind: 'codec-instance'`) and\n * target-specific IR class instances structurally satisfying\n * `PostgresEnumStorageEntry` (with `kind: 'postgres-enum'`) are the\n * two variants the SQL family ships today. The construction side also\n * accepts {@link StorageTypeInstanceInput} so callers can pass raw\n * codec triples; the constructor stamps the discriminator.\n */\nexport type SqlStorageTypeEntry =\n | StorageTypeInstance\n | PostgresEnumStorageEntry\n | StorageTypeInstanceInput;\n\nconst DEFAULT_NAMESPACES: Readonly<Record<string, Namespace>> = Object.freeze({\n [UNSPECIFIED_NAMESPACE_ID]: SqlUnspecifiedNamespace.instance,\n});\n\nexport interface SqlStorageInput<THash extends string = string> {\n readonly storageHash: StorageHashBase<THash>;\n readonly tables: Record<string, StorageTable | StorageTableInput>;\n readonly types?: Record<string, SqlStorageTypeEntry>;\n readonly namespaces?: Readonly<Record<string, Namespace>>;\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 same 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 * (`{ [UNSPECIFIED_NAMESPACE_ID]: SqlUnspecifiedNamespace.instance }`)\n * binds every contract authored before per-target namespace concretions\n * land; per-target namespace classes (`PostgresSchema.unspecified`,\n * `SqliteUnspecifiedDatabase.instance`) earn their slots when each\n * target's namespace shape lands.\n *\n * The constructor normalises nested IR-class fields (`tables`, optional\n * `types`) into class 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 */\nexport class SqlStorage<THash extends string = string> extends SqlNode implements Storage {\n readonly storageHash: StorageHashBase<THash>;\n readonly tables: Readonly<Record<string, StorageTable>>;\n readonly namespaces: Readonly<Record<string, Namespace>>;\n // SQL-family slot view: the two structural variants the family ships\n // today (codec triples + Postgres-enum structural entries). Each\n // variant extends the framework `StorageType` alphabet; the SQL\n // narrowing keeps cross-domain layering clean — SQL-family consumers\n // dispatch via `isStorageTypeInstance` / `isPostgresEnumStorageEntry`\n // type guards rather than importing the target's concrete IR class\n // (cross-domain rule: SQL may not import `target-*`).\n declare readonly types?: Readonly<Record<string, StorageTypeInstance | PostgresEnumStorageEntry>>;\n\n constructor(input: SqlStorageInput<THash>) {\n super();\n this.storageHash = input.storageHash;\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 this.namespaces = input.namespaces ?? DEFAULT_NAMESPACES;\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 * (TML-2536). Every entry must carry a recognised `kind` discriminator\n * — either `'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 ForeignKeyReferences,\n type ForeignKeyReferencesInput,\n} from './ir/foreign-key-references';\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 SqlStorage,\n type SqlStorageInput,\n type SqlStorageTypeEntry,\n} from './ir/sql-storage';\nexport { SqlUnspecifiedNamespace } from './ir/sql-unspecified-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;;;;;;;;;;;;AClCN,IAAa,uBAAb,cAA0C,QAAQ;CAChD;CACA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,kHAC7E;;CAEH,IAAI,sBAAsB,MAAM,EAC9B,OAAO;CAET,MAAM,UAAW,MAA6B;CAC9C,MAAM,kBACJ,YAAY,KAAA,IACR,iCACA,uCAAuC,KAAK,UAAU,QAAQ;CACpE,MAAM,IAAI,MACR,iBAAiB,KAAK,UAAU,KAAK,CAAC,QAAQ,gBAAgB,aAAa,KAAK,UAAU,iBAAiB,CAAC,MAAM,KAAK,UAAU,gBAAgB,CAAC,iGACnJ;;;;AC/FH,MAAa,wBAAwB;AACrC,MAAa,mBAAmB;AAEhC,SAAgB,gBACd,IACA,kBACyC;CACzC,OAAO;EACL,YAAY,GAAG,cAAc,kBAAkB,cAAA;EAC/C,OAAO,GAAG,SAAS,kBAAkB,SAAA;EACtC"}
@@ -1,26 +0,0 @@
1
- import { freezeNode } from '@prisma-next/framework-components/ir';
2
- import { SqlNode } from './sql-node';
3
-
4
- export interface ForeignKeyReferencesInput {
5
- readonly table: string;
6
- readonly columns: readonly string[];
7
- }
8
-
9
- /**
10
- * SQL Contract IR node for the referenced side of a foreign key.
11
- *
12
- * The class is shaped around single-namespace references today; a
13
- * future milestone introduces a cross-namespace coordinate on top of
14
- * `(table, columns)` when namespace-keyed storage lands.
15
- */
16
- export class ForeignKeyReferences extends SqlNode {
17
- readonly table: string;
18
- readonly columns: readonly string[];
19
-
20
- constructor(input: ForeignKeyReferencesInput) {
21
- super();
22
- this.table = input.table;
23
- this.columns = input.columns;
24
- freezeNode(this);
25
- }
26
- }