@prisma-next/sql-contract 0.15.0 → 0.16.0-dev.2

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 (77) hide show
  1. package/dist/canonicalization-hooks.d.mts +0 -1
  2. package/dist/canonicalization-hooks.d.mts.map +1 -1
  3. package/dist/canonicalization-hooks.mjs +0 -10
  4. package/dist/canonicalization-hooks.mjs.map +1 -1
  5. package/dist/contract-view.d.mts +1 -2
  6. package/dist/contract-view.d.mts.map +1 -1
  7. package/dist/entity-handle-lowering-hook.d.mts.map +1 -1
  8. package/dist/{entity-kinds-BEPZdFBN.mjs → entity-kinds-CVg6HzG2.mjs} +4 -6
  9. package/dist/entity-kinds-CVg6HzG2.mjs.map +1 -0
  10. package/dist/entity-kinds.d.mts +2 -3
  11. package/dist/entity-kinds.d.mts.map +1 -1
  12. package/dist/entity-kinds.mjs +1 -1
  13. package/dist/factories.d.mts +4 -6
  14. package/dist/factories.d.mts.map +1 -1
  15. package/dist/factories.mjs +2 -9
  16. package/dist/factories.mjs.map +1 -1
  17. package/dist/{foreign-key-DM1UTydh.d.mts → foreign-key-CWCEM2IT.d.mts} +11 -10
  18. package/dist/foreign-key-CWCEM2IT.d.mts.map +1 -0
  19. package/dist/foreign-key-materialization.d.mts +63 -0
  20. package/dist/foreign-key-materialization.d.mts.map +1 -0
  21. package/dist/foreign-key-materialization.mjs +67 -0
  22. package/dist/foreign-key-materialization.mjs.map +1 -0
  23. package/dist/index-type-validation.d.mts +3 -3
  24. package/dist/index-type-validation.d.mts.map +1 -1
  25. package/dist/{index-types-Czsyu7Iw.d.mts → index-types-DPVhsW0v.d.mts} +2 -3
  26. package/dist/index-types-DPVhsW0v.d.mts.map +1 -0
  27. package/dist/index-types.d.mts +1 -1
  28. package/dist/pack-types.d.mts.map +1 -1
  29. package/dist/referential-action-sql.d.mts +1 -2
  30. package/dist/referential-action-sql.d.mts.map +1 -1
  31. package/dist/resolve-storage-table.d.mts +2 -3
  32. package/dist/resolve-storage-table.d.mts.map +1 -1
  33. package/dist/{sql-node-V214WXQD.d.mts → sql-node-QXu33IeX.d.mts} +1 -2
  34. package/dist/sql-node-QXu33IeX.d.mts.map +1 -0
  35. package/dist/{sql-storage-Dt5ipcRl.d.mts → sql-storage-BIErcfFA.d.mts} +4 -5
  36. package/dist/sql-storage-BIErcfFA.d.mts.map +1 -0
  37. package/dist/{storage-table-y6R6pxyI.mjs → storage-table-DBpYBmty.mjs} +10 -6
  38. package/dist/storage-table-DBpYBmty.mjs.map +1 -0
  39. package/dist/{storage-table-Bj1ZN1P7.d.mts → storage-table-mNGckl3_.d.mts} +5 -56
  40. package/dist/storage-table-mNGckl3_.d.mts.map +1 -0
  41. package/dist/{storage-value-set-Tx3CFoS_.mjs → storage-value-set-3BKuha5q.mjs} +2 -2
  42. package/dist/{storage-value-set-Tx3CFoS_.mjs.map → storage-value-set-3BKuha5q.mjs.map} +1 -1
  43. package/dist/{storage-value-set-D-jww77l.d.mts → storage-value-set-DPHvvSdB.d.mts} +2 -3
  44. package/dist/storage-value-set-DPHvvSdB.d.mts.map +1 -0
  45. package/dist/{types-zBvpNCmg.d.mts → types-lpzJtKpv.d.mts} +8 -4
  46. package/dist/types-lpzJtKpv.d.mts.map +1 -0
  47. package/dist/types.d.mts +8 -8
  48. package/dist/types.d.mts.map +1 -1
  49. package/dist/types.mjs +12 -3
  50. package/dist/types.mjs.map +1 -1
  51. package/dist/unique-constraint-WHfanEUq.d.mts +54 -0
  52. package/dist/unique-constraint-WHfanEUq.d.mts.map +1 -0
  53. package/dist/validators.d.mts +4 -4
  54. package/dist/validators.d.mts.map +1 -1
  55. package/dist/validators.mjs +2 -4
  56. package/dist/validators.mjs.map +1 -1
  57. package/dist/value-set-derivation-hook.d.mts +1 -2
  58. package/dist/value-set-derivation-hook.d.mts.map +1 -1
  59. package/package.json +10 -8
  60. package/src/canonicalization-hooks.ts +1 -2
  61. package/src/exports/foreign-key-materialization.ts +8 -0
  62. package/src/factories.ts +1 -5
  63. package/src/foreign-key-materialization.ts +107 -0
  64. package/src/ir/foreign-key.ts +9 -9
  65. package/src/ir/storage-entry-schemas.ts +0 -2
  66. package/src/validators.ts +0 -2
  67. package/dist/entity-kinds-BEPZdFBN.mjs.map +0 -1
  68. package/dist/foreign-key-DM1UTydh.d.mts.map +0 -1
  69. package/dist/index-types-Czsyu7Iw.d.mts.map +0 -1
  70. package/dist/sql-node-V214WXQD.d.mts.map +0 -1
  71. package/dist/sql-storage-Dt5ipcRl.d.mts.map +0 -1
  72. package/dist/storage-table-Bj1ZN1P7.d.mts.map +0 -1
  73. package/dist/storage-table-y6R6pxyI.mjs.map +0 -1
  74. package/dist/storage-value-set-D-jww77l.d.mts.map +0 -1
  75. package/dist/types-Hkxybhdj.mjs +0 -13
  76. package/dist/types-Hkxybhdj.mjs.map +0 -1
  77. package/dist/types-zBvpNCmg.d.mts.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"storage-table-DBpYBmty.mjs","names":[],"sources":["../src/ir/sql-node.ts","../src/ir/check-constraint.ts","../src/ir/foreign-key-reference.ts","../src/ir/foreign-key.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"],"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. StorageValueSet)\n // 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 type { ValueSetRef } 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 CheckConstraint}.\n * Mirrors the on-disk storage JSON envelope so the serializer hydration\n * walker can hand a validated literal straight to `new`.\n */\nexport interface CheckConstraintInput {\n readonly name: string;\n readonly column: string;\n readonly valueSet: ValueSetRef;\n}\n\n/**\n * SQL Contract IR node for a table-level check constraint that restricts\n * a column to the permitted values of a value-set.\n *\n * The constraint is **structured** (names a column and a value-set\n * reference), not a raw SQL expression. Each target renders its own DDL\n * from the structured form, keeping the contract target-agnostic.\n *\n * Construction is idempotent: passing an existing `CheckConstraint`\n * instance as input produces a new instance with identical fields.\n * The constructor does not use `instanceof` for input discrimination —\n * it reads plain named properties, which is sufficient since\n * `CheckConstraintInput` is a structural type.\n */\nexport class CheckConstraint extends SqlNode {\n readonly name: string;\n readonly column: string;\n readonly valueSet: ValueSetRef;\n\n constructor(input: CheckConstraintInput) {\n super();\n this.name = input.name;\n this.column = input.column;\n this.valueSet = input.valueSet;\n freezeNode(this);\n }\n}\n","import { asNamespaceId, type NamespaceId } from '@prisma-next/contract/types';\nimport { freezeNode } from '@prisma-next/framework-components/ir';\nimport { SqlNode } from './sql-node';\n\n/**\n * Input for a foreign-key reference (one side of a foreign-key declaration).\n *\n * When `spaceId` is absent the reference is local — the referenced table lives\n * in the same contract-space. When `spaceId` is present the reference is\n * cross-space — the referenced table lives in a different contract-space\n * identified by `spaceId`.\n *\n * Presence-based discrimination keeps local FK JSON byte-identical to\n * contracts authored before cross-space support was added.\n */\nexport interface ForeignKeyReferenceInput {\n readonly namespaceId: string;\n readonly tableName: string;\n readonly columns: readonly string[];\n readonly spaceId?: 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 * Cross-space discrimination is based on `spaceId` presence: absent means\n * local (same contract-space); present means cross-space (the referenced\n * table lives in the contract-space identified by `spaceId`).\n *\n * For local references `spaceId` is absent from JSON, keeping the serialized\n * shape byte-identical to contracts authored before cross-space support was\n * added. For cross-space references `spaceId` appears in JSON so round-trips\n * are lossless.\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: NamespaceId;\n readonly tableName: string;\n readonly columns: readonly string[];\n declare readonly spaceId?: string;\n\n constructor(input: ForeignKeyReferenceInput) {\n super();\n this.namespaceId = asNamespaceId(input.namespaceId);\n this.tableName = input.tableName;\n this.columns = input.columns;\n if (input.spaceId !== undefined) this.spaceId = input.spaceId;\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}\n\n/**\n * SQL Contract IR node for a table-level foreign-key declaration — the\n * referential constraint only (source, target, `onDelete`/`onUpdate`).\n *\n * A persisted `foreignKeys[]` entry always denotes a real constraint: whether\n * to emit the constraint at all, and whether to back it with an index, are\n * authoring-time decisions (PSL `@relation(index:)`, TS `fk({ constraint,\n * index })`) resolved once at `contract emit` — a `constraint: false` FK\n * simply has no entry here, and a backing index (if any) is its own discrete,\n * named entry in the table's `indexes[]`.\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 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 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 { 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 type { ColumnDefault, ControlPolicy, ValueSetRef } 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 many?: boolean;\n readonly typeParams?: Record<string, unknown>;\n readonly typeRef?: string;\n readonly default?: ColumnDefault;\n readonly control?: ControlPolicy;\n readonly valueSet?: ValueSetRef;\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 many?: boolean;\n declare readonly typeParams?: Record<string, unknown>;\n declare readonly typeRef?: string;\n declare readonly default?: ColumnDefault;\n declare readonly control?: ControlPolicy;\n declare readonly valueSet?: ValueSetRef;\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.many !== undefined) this.many = input.many;\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 if (input.control !== undefined) this.control = input.control;\n if (input.valueSet !== undefined) this.valueSet = input.valueSet;\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 type { ControlPolicy } from '@prisma-next/contract/types';\nimport { freezeNode } from '@prisma-next/framework-components/ir';\nimport { CheckConstraint, type CheckConstraintInput } from './check-constraint';\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 readonly control?: ControlPolicy;\n readonly checks?: ReadonlyArray<CheckConstraint | CheckConstraintInput>;\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 declare readonly control?: ControlPolicy;\n declare readonly checks?: ReadonlyArray<CheckConstraint>;\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 if (input.control !== undefined) this.control = input.control;\n if (input.checks !== undefined && input.checks.length > 0) {\n this.checks = Object.freeze(input.checks.map((cc) => new CheckConstraint(cc)));\n }\n freezeNode(this);\n }\n\n /**\n * Runtime guard that a namespace `table` entry is really a `StorageTable`.\n * The compiler already types the entry as `StorageTable`, but a\n * freshly-deserialized contract may carry plain JSON at that slot until\n * hydration; this duck-types the structural shape. Accepts `undefined` so\n * optional-chained entry lookups pass straight through.\n */\n static is(value: StorageTable | undefined): value is StorageTable {\n if (typeof value !== 'object' || value === null) return false;\n return 'columns' in value && 'uniques' in value && 'indexes' in value && 'foreignKeys' in value;\n }\n\n static assert(\n value: StorageTable | undefined,\n coordinate: string,\n ): asserts value is StorageTable {\n if (!StorageTable.is(value)) {\n throw new Error(`Expected a StorageTable at ${coordinate}`);\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkCA,IAAsB,UAAtB,cAAsC,WAAW;CAC/C;CAEA,cAAc;EACZ,MAAM;EACN,OAAO,eAAe,MAAM,QAAQ;GAClC,OAAO;GACP,UAAU;GACV,YAAY;GAMZ,cAAc;EAChB,CAAC;CACH;AACF;;;;;;;;;;;;;;;;;ACtBA,IAAa,kBAAb,cAAqC,QAAQ;CAC3C;CACA;CACA;CAEA,YAAY,OAA6B;EACvC,MAAM;EACN,KAAK,OAAO,MAAM;EAClB,KAAK,SAAS,MAAM;EACpB,KAAK,WAAW,MAAM;EACtB,WAAW,IAAI;CACjB;AACF;;;;;;;;;;;;;;;;;;;ACHA,IAAa,sBAAb,cAAyC,QAAQ;CAC/C;CACA;CACA;CAGA,YAAY,OAAiC;EAC3C,MAAM;EACN,KAAK,cAAc,cAAc,MAAM,WAAW;EAClD,KAAK,YAAY,MAAM;EACvB,KAAK,UAAU,MAAM;EACrB,IAAI,MAAM,YAAY,KAAA,GAAW,KAAK,UAAU,MAAM;EACtD,WAAW,IAAI;CACjB;AACF;;;;;;;;;;;;;;;;;;;;;;;AClBA,IAAa,aAAb,cAAgC,QAAQ;CACtC;CACA;CAKA,YAAY,OAAwB;EAClC,MAAM;EACN,KAAK,SACH,MAAM,kBAAkB,sBACpB,MAAM,SACN,IAAI,oBAAoB,MAAM,MAAM;EAC1C,KAAK,SACH,MAAM,kBAAkB,sBACpB,MAAM,SACN,IAAI,oBAAoB,MAAM,MAAM;EAC1C,IAAI,MAAM,SAAS,KAAA,GAAW,KAAK,OAAO,MAAM;EAChD,IAAI,MAAM,aAAa,KAAA,GAAW,KAAK,WAAW,MAAM;EACxD,IAAI,MAAM,aAAa,KAAA,GAAW,KAAK,WAAW,MAAM;EACxD,WAAW,IAAI;CACjB;AACF;;;;;;AC7CA,IAAa,aAAb,cAAgC,QAAQ;CACtC;CAGA,YAAY,OAAwB;EAClC,MAAM;EACN,KAAK,UAAU,MAAM;EACrB,IAAI,MAAM,SAAS,KAAA,GAAW,KAAK,OAAO,MAAM;EAChD,WAAW,IAAI;CACjB;AACF;;;;;;;;;;;ACHA,IAAa,QAAb,cAA2B,QAAQ;CACjC;CAKA,YAAY,OAAmB;EAC7B,MAAM;EACN,KAAK,UAAU,MAAM;EACrB,IAAI,MAAM,SAAS,KAAA,GAAW,KAAK,OAAO,MAAM;EAChD,IAAI,MAAM,SAAS,KAAA,GAAW,KAAK,OAAO,MAAM;EAChD,IAAI,MAAM,YAAY,KAAA,GAAW,KAAK,UAAU,MAAM;EACtD,WAAW,IAAI;CACjB;AACF;;;;;;;;;;;;;;;;ACOA,IAAa,gBAAb,cAAmC,QAAQ;CACzC;CACA;CACA;CAQA,YAAY,OAA2B;EACrC,MAAM;EACN,KAAK,aAAa,MAAM;EACxB,KAAK,UAAU,MAAM;EACrB,KAAK,WAAW,MAAM;EACtB,IAAI,MAAM,SAAS,KAAA,GAAW,KAAK,OAAO,MAAM;EAChD,IAAI,MAAM,eAAe,KAAA,GAAW,KAAK,aAAa,MAAM;EAC5D,IAAI,MAAM,YAAY,KAAA,GAAW,KAAK,UAAU,MAAM;EACtD,IAAI,MAAM,YAAY,KAAA,GAAW,KAAK,UAAU,MAAM;EACtD,IAAI,MAAM,YAAY,KAAA,GAAW,KAAK,UAAU,MAAM;EACtD,IAAI,MAAM,aAAa,KAAA,GAAW,KAAK,WAAW,MAAM;EACxD,WAAW,IAAI;CACjB;AACF;;;;;;ACpDA,IAAa,mBAAb,cAAsC,QAAQ;CAC5C;CAGA,YAAY,OAA8B;EACxC,MAAM;EACN,KAAK,UAAU,MAAM;EACrB,IAAI,MAAM,SAAS,KAAA,GAAW,KAAK,OAAO,MAAM;EAChD,WAAW,IAAI;CACjB;AACF;;;;;;;;;;;;;;;ACWA,IAAa,eAAb,MAAa,qBAAqB,QAAQ;CACxC;CACA;CACA;CACA;CAKA,YAAY,OAA0B;EACpC,MAAM;EACN,KAAK,UAAU,OAAO,OACpB,OAAO,YACL,OAAO,QAAQ,MAAM,OAAO,CAAC,CAAC,KAAK,CAAC,MAAM,SAAS,CACjD,MACA,eAAe,gBAAgB,MAAM,IAAI,cAAc,GAAG,CAC5D,CAAC,CACH,CACF;EACA,IAAI,MAAM,eAAe,KAAA,GACvB,KAAK,aACH,MAAM,sBAAsB,aACxB,MAAM,aACN,IAAI,WAAW,MAAM,UAAU;EAEvC,KAAK,UAAU,OAAO,OACpB,MAAM,QAAQ,KAAK,MAAO,aAAa,mBAAmB,IAAI,IAAI,iBAAiB,CAAC,CAAE,CACxF;EACA,KAAK,UAAU,OAAO,OAAO,MAAM,QAAQ,KAAK,MAAO,aAAa,QAAQ,IAAI,IAAI,MAAM,CAAC,CAAE,CAAC;EAC9F,KAAK,cAAc,OAAO,OACxB,MAAM,YAAY,KAAK,OAAQ,cAAc,aAAa,KAAK,IAAI,WAAW,EAAE,CAAE,CACpF;EACA,IAAI,MAAM,YAAY,KAAA,GAAW,KAAK,UAAU,MAAM;EACtD,IAAI,MAAM,WAAW,KAAA,KAAa,MAAM,OAAO,SAAS,GACtD,KAAK,SAAS,OAAO,OAAO,MAAM,OAAO,KAAK,OAAO,IAAI,gBAAgB,EAAE,CAAC,CAAC;EAE/E,WAAW,IAAI;CACjB;;;;;;;;CASA,OAAO,GAAG,OAAwD;EAChE,IAAI,OAAO,UAAU,YAAY,UAAU,MAAM,OAAO;EACxD,OAAO,aAAa,SAAS,aAAa,SAAS,aAAa,SAAS,iBAAiB;CAC5F;CAEA,OAAO,OACL,OACA,YAC+B;EAC/B,IAAI,CAAC,aAAa,GAAG,KAAK,GACxB,MAAM,IAAI,MAAM,8BAA8B,YAAY;CAE9D;AACF"}
@@ -1,7 +1,7 @@
1
- import { t as SqlNode } from "./sql-node-V214WXQD.mjs";
2
- import { n as ForeignKeyInput, t as ForeignKey } from "./foreign-key-DM1UTydh.mjs";
1
+ import { t as SqlNode } from "./sql-node-QXu33IeX.mjs";
2
+ import { n as ForeignKeyInput, t as ForeignKey } from "./foreign-key-CWCEM2IT.mjs";
3
+ import { a as PrimaryKey, i as IndexInput, n as UniqueConstraintInput, o as PrimaryKeyInput, r as Index, t as UniqueConstraint } from "./unique-constraint-WHfanEUq.mjs";
3
4
  import { ColumnDefault, ControlPolicy, ValueSetRef } from "@prisma-next/contract/types";
4
-
5
5
  //#region src/ir/check-constraint.d.ts
6
6
  /**
7
7
  * Hydration / construction input shape for {@link CheckConstraint}.
@@ -34,43 +34,6 @@ declare class CheckConstraint extends SqlNode {
34
34
  constructor(input: CheckConstraintInput);
35
35
  }
36
36
  //#endregion
37
- //#region src/ir/primary-key.d.ts
38
- interface PrimaryKeyInput {
39
- readonly columns: readonly string[];
40
- readonly name?: string;
41
- }
42
- /**
43
- * SQL Contract IR node for a table's primary-key constraint.
44
- */
45
- declare class PrimaryKey extends SqlNode {
46
- readonly columns: readonly string[];
47
- readonly name?: string;
48
- constructor(input: PrimaryKeyInput);
49
- }
50
- //#endregion
51
- //#region src/ir/sql-index.d.ts
52
- interface IndexInput {
53
- readonly columns: readonly string[];
54
- readonly name?: string;
55
- readonly type?: string;
56
- readonly options?: Record<string, unknown>;
57
- }
58
- /**
59
- * SQL Contract IR node for a table-level secondary index.
60
- *
61
- * Note that this class shadows the global TypeScript `Index` lib type
62
- * at the family-shared name; consumer files that need both should
63
- * alias one (e.g.
64
- * `import { Index as SqlIndexNode } from '@prisma-next/sql-contract/types'`).
65
- */
66
- declare class Index extends SqlNode {
67
- readonly columns: readonly string[];
68
- readonly name?: string;
69
- readonly type?: string;
70
- readonly options?: Record<string, unknown>;
71
- constructor(input: IndexInput);
72
- }
73
- //#endregion
74
37
  //#region src/ir/storage-column.d.ts
75
38
  /**
76
39
  * Hydration / construction input shape for {@link StorageColumn}. Mirrors
@@ -119,20 +82,6 @@ declare class StorageColumn extends SqlNode {
119
82
  constructor(input: StorageColumnInput);
120
83
  }
121
84
  //#endregion
122
- //#region src/ir/unique-constraint.d.ts
123
- interface UniqueConstraintInput {
124
- readonly columns: readonly string[];
125
- readonly name?: string;
126
- }
127
- /**
128
- * SQL Contract IR node for a table-level unique constraint.
129
- */
130
- declare class UniqueConstraint extends SqlNode {
131
- readonly columns: readonly string[];
132
- readonly name?: string;
133
- constructor(input: UniqueConstraintInput);
134
- }
135
- //#endregion
136
85
  //#region src/ir/storage-table.d.ts
137
86
  interface StorageTableInput {
138
87
  readonly columns: Record<string, StorageColumn | StorageColumnInput>;
@@ -175,5 +124,5 @@ declare class StorageTable extends SqlNode {
175
124
  static assert(value: StorageTable | undefined, coordinate: string): asserts value is StorageTable;
176
125
  }
177
126
  //#endregion
178
- export { StorageColumn as a, IndexInput as c, CheckConstraint as d, CheckConstraintInput as f, UniqueConstraintInput as i, PrimaryKey as l, StorageTableInput as n, StorageColumnInput as o, UniqueConstraint as r, Index as s, StorageTable as t, PrimaryKeyInput as u };
179
- //# sourceMappingURL=storage-table-Bj1ZN1P7.d.mts.map
127
+ export { CheckConstraint as a, StorageColumnInput as i, StorageTableInput as n, CheckConstraintInput as o, StorageColumn as r, StorageTable as t };
128
+ //# sourceMappingURL=storage-table-mNGckl3_.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"storage-table-mNGckl3_.d.mts","names":[],"sources":["../src/ir/check-constraint.ts","../src/ir/storage-column.ts","../src/ir/storage-table.ts"],"mappings":";;;;;;;;;;UASiB;WACN;WACA;WACA,UAAU;;;;;;;;;;;;;;;;cAiBR,wBAAwB;WAC1B;WACA;WACA,UAAU;cAEP,OAAO;;;;;;;;;;;;;;UCpBJ;WACN;WACA;WACA;WACA;WACA,aAAa;WACb;WACA,UAAU;WACV,UAAU;WACV,WAAW;;;;;;;;;;;;;;;cAgBT,sBAAsB;WACxB;WACA;WACA;WACQ;WACA,aAAa;WACb;WACA,UAAU;WACV,UAAU;WACV,WAAW;cAEhB,OAAO;;;;UCxCJ;WACN,SAAS,eAAe,gBAAgB;WACxC,aAAa,aAAa;WAC1B,SAAS,cAAc,mBAAmB;WAC1C,SAAS,cAAc,QAAQ;WAC/B,aAAa,cAAc,aAAa;WACxC,UAAU;WACV,SAAS,cAAc,kBAAkB;;;;;;;;;;;;;;cAevC,qBAAqB;WACvB,SAAS,SAAS,eAAe;WACjC,SAAS,cAAc;WACvB,SAAS,cAAc;WACvB,aAAa,cAAc;WACnB,aAAa;WACb,UAAU;WACV,SAAS,cAAc;cAE5B,OAAO;;;;;;;;SAqCZ,GAAG,OAAO,2BAA2B,SAAS;SAK9C,OACL,OAAO,0BACP,6BACS,SAAS"}
@@ -1,4 +1,4 @@
1
- import { l as SqlNode } from "./storage-table-y6R6pxyI.mjs";
1
+ import { l as SqlNode } from "./storage-table-DBpYBmty.mjs";
2
2
  import { freezeNode } from "@prisma-next/framework-components/ir";
3
3
  //#region src/ir/storage-value-set.ts
4
4
  /**
@@ -35,4 +35,4 @@ function isStorageValueSet(value) {
35
35
  //#endregion
36
36
  export { isStorageValueSet as n, StorageValueSet as t };
37
37
 
38
- //# sourceMappingURL=storage-value-set-Tx3CFoS_.mjs.map
38
+ //# sourceMappingURL=storage-value-set-3BKuha5q.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"storage-value-set-Tx3CFoS_.mjs","names":[],"sources":["../src/ir/storage-value-set.ts"],"sourcesContent":["import type { JsonValue } 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 StorageValueSet}.\n * Mirrors the on-disk storage JSON envelope so the serializer hydration\n * walker can hand a validated literal straight to `new`.\n */\nexport interface StorageValueSetInput {\n readonly kind: 'valueSet';\n /** Ordered permitted values, codec-encoded. Declaration order is preserved. */\n readonly values: readonly JsonValue[];\n}\n\n/**\n * SQL Contract IR node for a value-set entry in a namespace's `valueSet`\n * map (`SqlNamespace.entries.valueSet`).\n *\n * A value-set records the ordered set of permitted codec-encoded values for\n * an enum-like column restriction. It does not carry a `codecId` — the\n * column that references it already holds the codec; the value-set holds\n * only the permitted values.\n *\n * The node's `kind` is enumerable (`'valueSet'`) so the JSON envelope\n * carries the discriminator and the serializer hydration walker can\n * dispatch on it. This follows the per-leaf enumerable-kind convention\n * established in the SQL-node comment (future polymorphic dispatch on\n * namespace entries needs the discriminator in JSON).\n *\n * The entry's name is not on the class — value-sets are keyed by name in\n * the parent namespace's `valueSet: Record<string, StorageValueSet>` map.\n */\nexport class StorageValueSet extends SqlNode {\n override readonly kind = 'valueSet' as const;\n readonly values: readonly JsonValue[];\n\n constructor(input: StorageValueSetInput) {\n super();\n this.values = Object.freeze([...input.values]);\n freezeNode(this);\n }\n}\n\nexport function isStorageValueSet(value: unknown): value is StorageValueSet {\n if (typeof value !== 'object' || value === null) return false;\n return 'kind' in value && value.kind === 'valueSet' && 'values' in value;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAiCA,IAAa,kBAAb,cAAqC,QAAQ;CAC3C,OAAyB;CACzB;CAEA,YAAY,OAA6B;EACvC,MAAM;EACN,KAAK,SAAS,OAAO,OAAO,CAAC,GAAG,MAAM,MAAM,CAAC;EAC7C,WAAW,IAAI;CACjB;AACF;AAEA,SAAgB,kBAAkB,OAA0C;CAC1E,IAAI,OAAO,UAAU,YAAY,UAAU,MAAM,OAAO;CACxD,OAAO,UAAU,SAAS,MAAM,SAAS,cAAc,YAAY;AACrE"}
1
+ {"version":3,"file":"storage-value-set-3BKuha5q.mjs","names":[],"sources":["../src/ir/storage-value-set.ts"],"sourcesContent":["import type { JsonValue } 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 StorageValueSet}.\n * Mirrors the on-disk storage JSON envelope so the serializer hydration\n * walker can hand a validated literal straight to `new`.\n */\nexport interface StorageValueSetInput {\n readonly kind: 'valueSet';\n /** Ordered permitted values, codec-encoded. Declaration order is preserved. */\n readonly values: readonly JsonValue[];\n}\n\n/**\n * SQL Contract IR node for a value-set entry in a namespace's `valueSet`\n * map (`SqlNamespace.entries.valueSet`).\n *\n * A value-set records the ordered set of permitted codec-encoded values for\n * an enum-like column restriction. It does not carry a `codecId` — the\n * column that references it already holds the codec; the value-set holds\n * only the permitted values.\n *\n * The node's `kind` is enumerable (`'valueSet'`) so the JSON envelope\n * carries the discriminator and the serializer hydration walker can\n * dispatch on it. This follows the per-leaf enumerable-kind convention\n * established in the SQL-node comment (future polymorphic dispatch on\n * namespace entries needs the discriminator in JSON).\n *\n * The entry's name is not on the class — value-sets are keyed by name in\n * the parent namespace's `valueSet: Record<string, StorageValueSet>` map.\n */\nexport class StorageValueSet extends SqlNode {\n override readonly kind = 'valueSet' as const;\n readonly values: readonly JsonValue[];\n\n constructor(input: StorageValueSetInput) {\n super();\n this.values = Object.freeze([...input.values]);\n freezeNode(this);\n }\n}\n\nexport function isStorageValueSet(value: unknown): value is StorageValueSet {\n if (typeof value !== 'object' || value === null) return false;\n return 'kind' in value && value.kind === 'valueSet' && 'values' in value;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAiCA,IAAa,kBAAb,cAAqC,QAAQ;CAC3C,OAAyB;CACzB;CAEA,YAAY,OAA6B;EACvC,MAAM;EACN,KAAK,SAAS,OAAO,OAAO,CAAC,GAAG,MAAM,MAAM,CAAC;EAC7C,WAAW,IAAI;CACjB;AACF;AAEA,SAAgB,kBAAkB,OAA0C;CAC1E,IAAI,OAAO,UAAU,YAAY,UAAU,MAAM,OAAO;CACxD,OAAO,UAAU,SAAS,MAAM,SAAS,cAAc,YAAY;AACrE"}
@@ -1,6 +1,5 @@
1
- import { t as SqlNode } from "./sql-node-V214WXQD.mjs";
1
+ import { t as SqlNode } from "./sql-node-QXu33IeX.mjs";
2
2
  import { JsonValue } from "@prisma-next/contract/types";
3
-
4
3
  //#region src/ir/storage-value-set.d.ts
5
4
  /**
6
5
  * Hydration / construction input shape for {@link StorageValueSet}.
@@ -38,4 +37,4 @@ declare class StorageValueSet extends SqlNode {
38
37
  declare function isStorageValueSet(value: unknown): value is StorageValueSet;
39
38
  //#endregion
40
39
  export { StorageValueSetInput as n, isStorageValueSet as r, StorageValueSet as t };
41
- //# sourceMappingURL=storage-value-set-D-jww77l.d.mts.map
40
+ //# sourceMappingURL=storage-value-set-DPHvvSdB.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"storage-value-set-DPHvvSdB.d.mts","names":[],"sources":["../src/ir/storage-value-set.ts"],"mappings":";;;;;;;;UASiB;WACN;;WAEA,iBAAiB;;;;;;;;;;;;;;;;;;;;cAqBf,wBAAwB;WACjB;WACT,iBAAiB;cAEd,OAAO;;iBAOL,kBAAkB,iBAAiB,SAAS"}
@@ -1,7 +1,11 @@
1
- import { r as ReferentialAction } from "./foreign-key-DM1UTydh.mjs";
1
+ import "./sql-node-QXu33IeX.mjs";
2
+ import "./storage-table-mNGckl3_.mjs";
3
+ import { r as ReferentialAction } from "./foreign-key-CWCEM2IT.mjs";
4
+ import "./unique-constraint-WHfanEUq.mjs";
5
+ import "./sql-storage-BIErcfFA.mjs";
6
+ import "./storage-value-set-DPHvvSdB.mjs";
2
7
  import { CodecTrait } from "@prisma-next/framework-components/codec";
3
8
  import { ControlDriverInstance } from "@prisma-next/framework-components/control";
4
-
5
9
  //#region src/types.d.ts
6
10
  interface SqlControlDriverInstance<T extends string = string> extends ControlDriverInstance<'sql', T> {
7
11
  query<Row = Record<string, unknown>>(sql: string, params?: readonly unknown[]): Promise<{
@@ -101,7 +105,7 @@ type QueryOperationTypesOf<T> = [T] extends [never] ? Record<string, never> : T
101
105
  readonly queryOperationTypes: infer Q;
102
106
  } ? Q extends Record<string, unknown> ? Q : Record<string, never> : Record<string, never>;
103
107
  type TypeMapsPhantomKey = '__@prisma-next/sql-contract/typeMaps@__';
104
- type ContractWithTypeMaps<TContract, TTypeMaps> = TContract & { readonly [K in TypeMapsPhantomKey]?: TTypeMaps };
108
+ type ContractWithTypeMaps<TContract, TTypeMaps> = TContract & { readonly [K in TypeMapsPhantomKey]?: TTypeMaps; };
105
109
  type ExtractTypeMapsFromContract<T> = TypeMapsPhantomKey extends keyof T ? NonNullable<T[TypeMapsPhantomKey & keyof T]> : never;
106
110
  type FieldOutputTypesOf<T> = [T] extends [never] ? Record<string, never> : T extends {
107
111
  readonly fieldOutputTypes: infer F;
@@ -124,4 +128,4 @@ type ExtractStorageColumnInputTypes<T> = StorageColumnInputTypesOf<ExtractTypeMa
124
128
  type ResolveCodecTypes<TContract, TTypeMaps> = [TTypeMaps] extends [never] ? ExtractCodecTypes<TContract> : CodecTypesOf<TTypeMaps>;
125
129
  //#endregion
126
130
  export { TypeMapsPhantomKey as A, SqlControlDriverInstance as C, StorageColumnInputTypesOf as D, SqlQueryOperationTypes as E, StorageColumnTypesOf as O, ResolveCodecTypes as S, SqlModelStorage as T, QueryOperationReturn as _, ExtractCodecTypes as a, QueryOperationTypesBase as b, ExtractQueryOperationTypes as c, ExtractTypeMapsFromContract as d, FieldInputTypesOf as f, NamespacedStorageColumnTypeMap as g, NamespacedFieldTypeMap as h, DEFAULT_FK_INDEX as i, applyFkDefaults as j, TypeMaps as k, ExtractStorageColumnInputTypes as l, ForeignKeyOptions as m, ContractWithTypeMaps as n, ExtractFieldInputTypes as o, FieldOutputTypesOf as p, DEFAULT_FK_CONSTRAINT as r, ExtractFieldOutputTypes as s, CodecTypesOf as t, ExtractStorageColumnTypes as u, QueryOperationSelfSpec as v, SqlModelFieldStorage as w, QueryOperationTypesOf as x, QueryOperationTypeEntry as y };
127
- //# sourceMappingURL=types-zBvpNCmg.d.mts.map
131
+ //# sourceMappingURL=types-lpzJtKpv.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types-lpzJtKpv.d.mts","names":[],"sources":["../src/types.ts"],"mappings":";;;;;;;;;UAIiB,yBAAyB,mCAChC,6BAA6B;EACrC,MAAM,MAAM,yBACV,aACA,8BACC;aAAmB,MAAM;;;KAgDlB;WACD;WACA,WAAW;WACX,WAAW;;KAGV;WACD;WACA;WACA;;KAGC;WACD;WACA;WACA,QAAQ,eAAe;;cAGrB;cACA;iBAEG,gBACd;EAAM;EAAkC;GACxC;EAAqB;EAAkC;;EACpD;EAAqB;;KASd,yBAAyB,eAAe,eAAe;KAEvD,iCAAiC,eAE3C,eAAe;KAGL,SACV,oBAAoB;EAAiB;KAAqB,uBAC1D,6BAA6B,0BAA0B,uBACvD,0BAA0B,yBAAyB,uBACnD,yBAAyB,yBAAyB,uBAClD,4BAA4B,iCAAiC,uBAC7D,iCAAiC,iCAAiC;WAEzD,YAAY;WACZ,qBAAqB;WACrB,kBAAkB;WAClB,iBAAiB;WACjB,oBAAoB;WACpB,yBAAyB;;KAGxB,aAAa,MAAM,qBAC3B,wBACA;WAAqB,kBAAkB;IACrC,UAAU;EAAiB;KACzB,IACA,wBACF;;;;;;;;;KAUM;WACG;WAA0B;WAAyB;;WACnD,iBAAiB;WAAuB;WAA0B;;WAElE;WACA,yBAAyB;WACzB;WACA;;;;;;;;;;KAWH;WACD;aAAuB;aAA0B;;;KAGhD;WACD,OAAO;WACP,UAAU,kBAAkB;;KAG3B,uBACV,YAAY;WAA0B;WAAyB;IAC/D,UAAU,eAAe,4BACvB;KAEQ,0BAA0B,eAAe;KAEzC,sBAAsB,MAAM,qBACpC,wBACA;WAAqB,2BAA2B;IAC9C,UAAU,0BACR,IACA,wBACF;KAEM;KAEA,qBAAqB,WAAW,aAAa,wBAC7C,KAAK,sBAAsB;KAG3B,4BAA4B,KAAK,iCAAiC,IAC1E,YAAY,EAAE,2BAA2B;KAGjC,mBAAmB,MAAM,qBACjC,wBACA;WAAqB,wBAAwB;IAC3C,UAAU,yBACR,IACA,wBACF;KAEM,kBAAkB,MAAM,qBAChC,wBACA;WAAqB,uBAAuB;IAC1C,UAAU,yBACR,IACA,wBACF;KAEM,qBAAqB,MAAM,qBACnC,wBACA;WAAqB,0BAA0B;IAC7C,UAAU,iCACR,IACA,wBACF;KAEM,0BAA0B,MAAM,qBACxC,wBACA;WAAqB,+BAA+B;IAClD,UAAU,iCACR,IACA,wBACF;KAEM,kBAAkB,KAAK,aAAa,4BAA4B;KAChE,2BAA2B,KAAK,sBAAsB,4BAA4B;KAClF,wBAAwB,KAAK,mBAAmB,4BAA4B;KAC5E,uBAAuB,KAAK,kBAAkB,4BAA4B;KAC1E,0BAA0B,KAAK,qBAAqB,4BAA4B;KAChF,+BAA+B,KAAK,0BAC9C,4BAA4B;KAGlB,kBAAkB,WAAW,cAAc,6BACnD,kBAAkB,aAClB,aAAa"}
package/dist/types.d.mts CHANGED
@@ -1,13 +1,13 @@
1
- import { t as SqlNode } from "./sql-node-V214WXQD.mjs";
2
- import { a as StorageColumn, c as IndexInput, d as CheckConstraint, f as CheckConstraintInput, i as UniqueConstraintInput, l as PrimaryKey, n as StorageTableInput, o as StorageColumnInput, r as UniqueConstraint, s as Index, t as StorageTable, u as PrimaryKeyInput } from "./storage-table-Bj1ZN1P7.mjs";
3
- import { a as ForeignKeyReferenceInput, i as ForeignKeyReference, n as ForeignKeyInput, r as ReferentialAction, t as ForeignKey } from "./foreign-key-DM1UTydh.mjs";
4
- import { a as SqlNamespaceFactory, c as SqlStorageInput, d as isSqlAuthoringContributions, f as CODEC_INSTANCE_KIND, g as toStorageTypeInstance, h as isStorageTypeInstance, i as SqlNamespaceEntries, l as SqlStorageTypeEntry, m as StorageTypeInstanceInput, n as SqlNamespace, o as SqlNamespaceInput, p as StorageTypeInstance, r as SqlNamespaceBase, s as SqlStorage, t as SqlAuthoringContributions, u as isMaterializedSqlNamespace } from "./sql-storage-Dt5ipcRl.mjs";
5
- import { n as StorageValueSetInput, r as isStorageValueSet, t as StorageValueSet } from "./storage-value-set-D-jww77l.mjs";
6
- import { A as TypeMapsPhantomKey, C as SqlControlDriverInstance, D as StorageColumnInputTypesOf, E as SqlQueryOperationTypes, O as StorageColumnTypesOf, S as ResolveCodecTypes, T as SqlModelStorage, _ as QueryOperationReturn, a as ExtractCodecTypes, b as QueryOperationTypesBase, c as ExtractQueryOperationTypes, d as ExtractTypeMapsFromContract, f as FieldInputTypesOf, g as NamespacedStorageColumnTypeMap, h as NamespacedFieldTypeMap, i as DEFAULT_FK_INDEX, j as applyFkDefaults, k as TypeMaps, l as ExtractStorageColumnInputTypes, m as ForeignKeyOptions, n as ContractWithTypeMaps, o as ExtractFieldInputTypes, p as FieldOutputTypesOf, r as DEFAULT_FK_CONSTRAINT, s as ExtractFieldOutputTypes, t as CodecTypesOf, u as ExtractStorageColumnTypes, v as QueryOperationSelfSpec, w as SqlModelFieldStorage, x as QueryOperationTypesOf, y as QueryOperationTypeEntry } from "./types-zBvpNCmg.mjs";
7
-
1
+ import { t as SqlNode } from "./sql-node-QXu33IeX.mjs";
2
+ import { a as CheckConstraint, i as StorageColumnInput, n as StorageTableInput, o as CheckConstraintInput, r as StorageColumn, t as StorageTable } from "./storage-table-mNGckl3_.mjs";
3
+ import { a as ForeignKeyReferenceInput, i as ForeignKeyReference, n as ForeignKeyInput, r as ReferentialAction, t as ForeignKey } from "./foreign-key-CWCEM2IT.mjs";
4
+ import { a as PrimaryKey, i as IndexInput, n as UniqueConstraintInput, o as PrimaryKeyInput, r as Index, t as UniqueConstraint } from "./unique-constraint-WHfanEUq.mjs";
5
+ import { a as SqlNamespaceFactory, c as SqlStorageInput, d as isSqlAuthoringContributions, f as CODEC_INSTANCE_KIND, g as toStorageTypeInstance, h as isStorageTypeInstance, i as SqlNamespaceEntries, l as SqlStorageTypeEntry, m as StorageTypeInstanceInput, n as SqlNamespace, o as SqlNamespaceInput, p as StorageTypeInstance, r as SqlNamespaceBase, s as SqlStorage, t as SqlAuthoringContributions, u as isMaterializedSqlNamespace } from "./sql-storage-BIErcfFA.mjs";
6
+ import { n as StorageValueSetInput, r as isStorageValueSet, t as StorageValueSet } from "./storage-value-set-DPHvvSdB.mjs";
7
+ import { A as TypeMapsPhantomKey, C as SqlControlDriverInstance, D as StorageColumnInputTypesOf, E as SqlQueryOperationTypes, O as StorageColumnTypesOf, S as ResolveCodecTypes, T as SqlModelStorage, _ as QueryOperationReturn, a as ExtractCodecTypes, b as QueryOperationTypesBase, c as ExtractQueryOperationTypes, d as ExtractTypeMapsFromContract, f as FieldInputTypesOf, g as NamespacedStorageColumnTypeMap, h as NamespacedFieldTypeMap, i as DEFAULT_FK_INDEX, j as applyFkDefaults, k as TypeMaps, l as ExtractStorageColumnInputTypes, m as ForeignKeyOptions, n as ContractWithTypeMaps, o as ExtractFieldInputTypes, p as FieldOutputTypesOf, r as DEFAULT_FK_CONSTRAINT, s as ExtractFieldOutputTypes, t as CodecTypesOf, u as ExtractStorageColumnTypes, v as QueryOperationSelfSpec, w as SqlModelFieldStorage, x as QueryOperationTypesOf, y as QueryOperationTypeEntry } from "./types-lpzJtKpv.mjs";
8
8
  //#region src/column-type-resolution.d.ts
9
9
  type StorageColumnMapAt<SCT, NsId extends string, TableName extends string> = string extends keyof SCT ? never : NsId extends keyof SCT ? string extends keyof SCT[NsId] ? never : TableName extends keyof SCT[NsId] ? SCT[NsId][TableName] : never : never;
10
- type StorageColumnTypeAcrossNamespaces<SCT, TableName extends string, ColumnName extends string> = { [Ns in keyof SCT]: TableName extends keyof SCT[Ns] ? ColumnName extends keyof SCT[Ns][TableName] ? SCT[Ns][TableName][ColumnName] : never : never }[keyof SCT];
10
+ type StorageColumnTypeAcrossNamespaces<SCT, TableName extends string, ColumnName extends string> = { [Ns in keyof SCT]: TableName extends keyof SCT[Ns] ? ColumnName extends keyof SCT[Ns][TableName] ? SCT[Ns][TableName][ColumnName] : never : never; }[keyof SCT];
11
11
  //#endregion
12
12
  export { CODEC_INSTANCE_KIND, CheckConstraint, type CheckConstraintInput, type CodecTypesOf, type ContractWithTypeMaps, DEFAULT_FK_CONSTRAINT, DEFAULT_FK_INDEX, type ExtractCodecTypes, type ExtractFieldInputTypes, type ExtractFieldOutputTypes, type ExtractQueryOperationTypes, type ExtractStorageColumnInputTypes, type ExtractStorageColumnTypes, type ExtractTypeMapsFromContract, type FieldInputTypesOf, type FieldOutputTypesOf, ForeignKey, type ForeignKeyInput, type ForeignKeyOptions, ForeignKeyReference, type ForeignKeyReferenceInput, Index, type IndexInput, type NamespacedFieldTypeMap, type NamespacedStorageColumnTypeMap, PrimaryKey, type PrimaryKeyInput, type QueryOperationReturn, type QueryOperationSelfSpec, type QueryOperationTypeEntry, type QueryOperationTypesBase, type QueryOperationTypesOf, type ReferentialAction, type ResolveCodecTypes, type SqlAuthoringContributions, type SqlControlDriverInstance, type SqlModelFieldStorage, type SqlModelStorage, type SqlNamespace, SqlNamespaceBase, type SqlNamespaceEntries, type SqlNamespaceFactory, type SqlNamespaceInput, SqlNode, type SqlQueryOperationTypes, SqlStorage, type SqlStorageInput, type SqlStorageTypeEntry, StorageColumn, type StorageColumnInput, type StorageColumnInputTypesOf, type StorageColumnMapAt, type StorageColumnTypeAcrossNamespaces, type StorageColumnTypesOf, StorageTable, type StorageTableInput, type StorageTypeInstance, type StorageTypeInstanceInput, StorageValueSet, type StorageValueSetInput, type TypeMaps, type TypeMapsPhantomKey, UniqueConstraint, type UniqueConstraintInput, applyFkDefaults, isMaterializedSqlNamespace, isSqlAuthoringContributions, isStorageTypeInstance, isStorageValueSet, toStorageTypeInstance };
13
13
  //# sourceMappingURL=types.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.mts","names":[],"sources":["../src/column-type-resolution.ts"],"mappings":";;;;;;;;KACY,kBAAA,4EAIa,GAAA,WAErB,IAAA,eAAmB,GAAA,wBACI,GAAA,CAAI,IAAA,YAEvB,SAAA,eAAwB,GAAA,CAAI,IAAA,IAC1B,GAAA,CAAI,IAAA,EAAM,SAAA;AAAA,KAIR,iCAAA,4EAKG,GAAA,GAAM,SAAA,eAAwB,GAAA,CAAI,EAAA,IAC3C,UAAA,eAAyB,GAAA,CAAI,EAAA,EAAI,SAAA,IAC/B,GAAA,CAAI,EAAA,EAAI,SAAA,EAAW,UAAA,0BAGnB,GAAA"}
1
+ {"version":3,"file":"types.d.mts","names":[],"sources":["../src/column-type-resolution.ts"],"mappings":";;;;;;;;KACY,mBACV,KACA,qBACA,iDACuB,cAErB,mBAAmB,2BACI,IAAI,gBAEvB,wBAAwB,IAAI,QAC1B,IAAI,MAAM;KAIR,kCACV,KACA,0BACA,gCAEC,YAAY,MAAM,wBAAwB,IAAI,MAC3C,yBAAyB,IAAI,IAAI,aAC/B,IAAI,IAAI,WAAW,qCAGnB"}
package/dist/types.mjs CHANGED
@@ -1,6 +1,5 @@
1
- import { a as PrimaryKey, c as CheckConstraint, i as Index, l as SqlNode, n as UniqueConstraint, o as ForeignKey, r as StorageColumn, s as ForeignKeyReference, t as StorageTable } from "./storage-table-y6R6pxyI.mjs";
2
- import { n as isStorageValueSet, t as StorageValueSet } from "./storage-value-set-Tx3CFoS_.mjs";
3
- import { n as DEFAULT_FK_INDEX, r as applyFkDefaults, t as DEFAULT_FK_CONSTRAINT } from "./types-Hkxybhdj.mjs";
1
+ import { a as PrimaryKey, c as CheckConstraint, i as Index, l as SqlNode, n as UniqueConstraint, o as ForeignKey, r as StorageColumn, s as ForeignKeyReference, t as StorageTable } from "./storage-table-DBpYBmty.mjs";
2
+ import { n as isStorageValueSet, t as StorageValueSet } from "./storage-value-set-3BKuha5q.mjs";
4
3
  import { NamespaceBase, freezeNode, isPlainRecord } from "@prisma-next/framework-components/ir";
5
4
  //#region src/ir/storage-type-instance.ts
6
5
  /**
@@ -101,6 +100,16 @@ function normaliseTypeEntry(name, entry) {
101
100
  throw new Error(`storage.types[${JSON.stringify(name)}] has ${kindDescription}; expected ${JSON.stringify("codec-instance")}. Untagged codec triples should be wrapped with toStorageTypeInstance(...) before construction.`);
102
101
  }
103
102
  //#endregion
103
+ //#region src/types.ts
104
+ const DEFAULT_FK_CONSTRAINT = true;
105
+ const DEFAULT_FK_INDEX = true;
106
+ function applyFkDefaults(fk, overrideDefaults) {
107
+ return {
108
+ constraint: fk.constraint ?? overrideDefaults?.constraint ?? true,
109
+ index: fk.index ?? overrideDefaults?.index ?? true
110
+ };
111
+ }
112
+ //#endregion
104
113
  export { CODEC_INSTANCE_KIND, CheckConstraint, DEFAULT_FK_CONSTRAINT, DEFAULT_FK_INDEX, ForeignKey, ForeignKeyReference, Index, PrimaryKey, SqlNamespaceBase, SqlNode, SqlStorage, StorageColumn, StorageTable, StorageValueSet, UniqueConstraint, applyFkDefaults, isMaterializedSqlNamespace, isSqlAuthoringContributions, isStorageTypeInstance, isStorageValueSet, toStorageTypeInstance };
105
114
 
106
115
  //# sourceMappingURL=types.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.mjs","names":[],"sources":["../src/ir/storage-type-instance.ts","../src/ir/sql-storage.ts"],"sourcesContent":["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 any class-instance\n * kinds a target pack contributes to 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 * `typeParams` may be omitted on input; the constructor normalises a\n * missing value to `{}` so the in-memory shape is always present.\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. Missing `typeParams` is normalised to `{}`.\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 * any class-instance kinds a target pack contributes.\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 type { AuthoringContributions } from '@prisma-next/framework-components/authoring';\nimport {\n freezeNode,\n isPlainRecord,\n type Namespace,\n NamespaceBase,\n type Storage,\n} from '@prisma-next/framework-components/ir';\nimport { SqlNode } from './sql-node';\nimport type { StorageTable } from './storage-table';\nimport {\n isStorageTypeInstance,\n type StorageTypeInstance,\n type StorageTypeInstanceInput,\n toStorageTypeInstance,\n} from './storage-type-instance';\nimport type { StorageValueSet } from './storage-value-set';\n\n/**\n * Polymorphic value type for document-scoped `SqlStorage.types` entries\n * (codec aliases / parameterised native type registrations).\n *\n * Postgres native enum registrations live under the postgres-specific\n * `entries.type` slot on `PostgresSchema` (target layer), not here.\n */\nexport type SqlStorageTypeEntry = StorageTypeInstance | StorageTypeInstanceInput;\n\nexport interface SqlNamespaceInput {\n readonly id: string;\n readonly entries: Readonly<Record<string, Readonly<Record<string, unknown>>>>;\n}\n\n/**\n * Target-supplied factory that materializes a `Namespace` from a SQL\n * `SqlNamespaceInput` (used to populate `SqlStorage.namespaces`).\n */\nexport type SqlNamespaceFactory = (input: SqlNamespaceInput) => Namespace;\n\n/**\n * SQL-family extension of the framework `AuthoringContributions`. SQL target\n * packs add a `createNamespace` factory so the PSL/TS authoring paths can\n * materialize namespaces (and merge lowered extension-block entities) without\n * each consumer re-specifying it. The factory is SQL-specific, so it lives here\n * rather than on the framework `AuthoringContributions` base.\n */\nexport interface SqlAuthoringContributions extends AuthoringContributions {\n readonly createNamespace?: SqlNamespaceFactory;\n}\n\n/**\n * Narrows framework `AuthoringContributions` to the SQL-family shape by testing\n * for the SQL-specific `createNamespace` capability.\n */\nexport function isSqlAuthoringContributions(\n authoring: AuthoringContributions | undefined,\n): authoring is SqlAuthoringContributions {\n if (authoring === undefined || !Object.hasOwn(authoring, 'createNamespace')) {\n return false;\n }\n return typeof Reflect.get(authoring, 'createNamespace') === 'function';\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, SqlNamespaceBase>>;\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. Callers must supply fully\n * constructed `Namespace` instances — construction discipline lives\n * in the authoring builders and deserializer hydration paths.\n *\n * The constructor normalises optional `types` into class instances.\n * `types` is polymorphic per Decision 18 Option B: codec-triple inputs\n * are stamped with `kind: 'codec-instance'`; hydration of raw JSON\n * class-instance entries (carrying their narrower `kind` literal) is\n * the per-target serializer's responsibility (so the family base does\n * not import target-specific subclasses).\n */\n/**\n * The typed `entries` shape for SQL family namespaces. The open dictionary\n * is intersected with optional known-kind maps so that `ns.entries.table`\n * and `ns.entries.valueSet` resolve without a cast, while unknown pack-\n * contributed kinds remain valid (the `Record` part allows any string key).\n */\nexport type SqlNamespaceEntries = Readonly<Record<string, Readonly<Record<string, unknown>>>> & {\n readonly table?: Readonly<Record<string, StorageTable>>;\n readonly valueSet?: Readonly<Record<string, StorageValueSet>>;\n};\n\n/**\n * Structural interface for SQL family namespaces. Generated `.d.ts` contract\n * types satisfy this structurally (no prototype methods). The runtime\n * abstract class `SqlNamespaceBase` extends this.\n *\n * `qualifyTable` and `isUnbound` are optional so JSON-shaped contract types\n * (which carry no methods) are accepted where `SqlNamespace` is required.\n * Hydrated `SqlNamespaceBase` instances always have both.\n */\nexport interface SqlNamespace {\n readonly kind: string;\n readonly id: string;\n readonly entries: SqlNamespaceEntries;\n readonly isUnbound?: boolean;\n qualifyTable?(tableName: string): string;\n}\n\n/**\n * Abstract SQL family namespace base class. Target concretions (`PostgresSchema`,\n * `SqliteDatabase`, …) extend this — it is never instantiated directly.\n * `entries` is the open ADR 224 dictionary: `entries[entityKind][entityName]`\n * addresses any entity.\n */\nexport abstract class SqlNamespaceBase extends NamespaceBase implements SqlNamespace {\n abstract override readonly id: string;\n abstract override readonly entries: SqlNamespaceEntries;\n\n abstract qualifyTable(tableName: string): string;\n}\n\n/**\n * Realm-safe guard for hydrated `SqlNamespaceBase` concretions. Checks\n * `qualifyTable` structurally instead of `instanceof NamespaceBase`, so it\n * survives duplicate-module boundaries (e.g. dist e2e where the target and\n * the family carry separate copies of `@prisma-next/framework-components`).\n *\n * Every concrete `SqlNamespaceBase` subclass (`PostgresSchema`, `SqliteDatabase`,\n * `TestSqlNamespace`, …) implements `qualifyTable`. Raw `SqlNamespaceInput`\n * objects (`{ id, entries }`) do not.\n */\nexport function isMaterializedSqlNamespace(x: unknown): x is SqlNamespaceBase {\n if (typeof x !== 'object' || x === null || !('qualifyTable' in x)) return false;\n return typeof x.qualifyTable === 'function';\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 declare readonly types?: Readonly<Record<string, StorageTypeInstance>>;\n\n constructor(input: SqlStorageInput<THash>) {\n super();\n this.storageHash = input.storageHash;\n this.namespaces = Object.freeze(input.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 * Every entry must carry a `kind: 'codec-instance'` discriminator or\n * be an already-constructed `StorageTypeInstance`. 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(name: string, entry: SqlStorageTypeEntry): StorageTypeInstance {\n if (isStorageTypeInstance(entry)) {\n // Normalise on-disk objects that omit `typeParams` (the canonical on-disk\n // form strips empty typeParams to keep JSON compact). The in-memory invariant\n // is always `typeParams: {}` when empty — never `undefined`. Only create a\n // new object when necessary to preserve identity-equality for callers that\n // hold a reference to an already-correct in-memory entry.\n if ('typeParams' in entry) {\n return entry;\n }\n return toStorageTypeInstance(entry);\n }\n const rawKind = isPlainRecord(entry) ? entry['kind'] : undefined;\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')}. Untagged codec triples should be wrapped with toStorageTypeInstance(...) before construction.`,\n );\n}\n"],"mappings":";;;;;;;;;;;;AASA,MAAa,sBAAsB;;;;;;AAmCnC,SAAgB,sBAAsB,OAAsD;CAC1F,OAAO;EACL,MAAM;EACN,SAAS,MAAM;EACf,YAAY,MAAM;EAClB,YAAY,MAAM,cAAc,CAAC;CACnC;AACF;;;;;;AAOA,SAAgB,sBAAsB,OAA8C;CAClF,IAAI,OAAO,UAAU,YAAY,UAAU,MAAM,OAAO;CACxD,OAAQ,MAA6B,SAAS;AAChD;;;;;;;ACPA,SAAgB,4BACd,WACwC;CACxC,IAAI,cAAc,KAAA,KAAa,CAAC,OAAO,OAAO,WAAW,iBAAiB,GACxE,OAAO;CAET,OAAO,OAAO,QAAQ,IAAI,WAAW,iBAAiB,MAAM;AAC9D;;;;;;;AA+DA,IAAsB,mBAAtB,cAA+C,cAAsC,CAKrF;;;;;;;;;;;AAYA,SAAgB,2BAA2B,GAAmC;CAC5E,IAAI,OAAO,MAAM,YAAY,MAAM,QAAQ,EAAE,kBAAkB,IAAI,OAAO;CAC1E,OAAO,OAAO,EAAE,iBAAiB;AACnC;AAEA,IAAa,aAAb,cAA+D,QAA2B;CACxF;CACA;CAGA,YAAY,OAA+B;EACzC,MAAM;EACN,KAAK,cAAc,MAAM;EACzB,KAAK,aAAa,OAAO,OAAO,MAAM,UAAU;EAChD,IAAI,MAAM,UAAU,KAAA,GAClB,KAAK,QAAQ,OAAO,OAClB,OAAO,YACL,OAAO,QAAQ,MAAM,KAAK,CAAC,CAAC,KAAK,CAAC,MAAM,QAAQ,CAAC,MAAM,mBAAmB,MAAM,EAAE,CAAC,CAAC,CACtF,CACF;EAEF,WAAW,IAAI;CACjB;AACF;;;;;;;;;;;;;;;;;AAkBA,SAAS,mBAAmB,MAAc,OAAiD;CACzF,IAAI,sBAAsB,KAAK,GAAG;EAMhC,IAAI,gBAAgB,OAClB,OAAO;EAET,OAAO,sBAAsB,KAAK;CACpC;CACA,MAAM,UAAU,cAAc,KAAK,IAAI,MAAM,UAAU,KAAA;CACvD,MAAM,kBACJ,YAAY,KAAA,IACR,iCACA,uCAAuC,KAAK,UAAU,OAAO;CACnE,MAAM,IAAI,MACR,iBAAiB,KAAK,UAAU,IAAI,EAAE,QAAQ,gBAAgB,aAAa,KAAK,UAAU,gBAAgB,EAAE,gGAC9G;AACF"}
1
+ {"version":3,"file":"types.mjs","names":[],"sources":["../src/ir/storage-type-instance.ts","../src/ir/sql-storage.ts","../src/types.ts"],"sourcesContent":["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 any class-instance\n * kinds a target pack contributes to 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 * `typeParams` may be omitted on input; the constructor normalises a\n * missing value to `{}` so the in-memory shape is always present.\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. Missing `typeParams` is normalised to `{}`.\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 * any class-instance kinds a target pack contributes.\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 type { AuthoringContributions } from '@prisma-next/framework-components/authoring';\nimport {\n freezeNode,\n isPlainRecord,\n type Namespace,\n NamespaceBase,\n type Storage,\n} from '@prisma-next/framework-components/ir';\nimport { SqlNode } from './sql-node';\nimport type { StorageTable } from './storage-table';\nimport {\n isStorageTypeInstance,\n type StorageTypeInstance,\n type StorageTypeInstanceInput,\n toStorageTypeInstance,\n} from './storage-type-instance';\nimport type { StorageValueSet } from './storage-value-set';\n\n/**\n * Polymorphic value type for document-scoped `SqlStorage.types` entries\n * (codec aliases / parameterised native type registrations).\n *\n * Postgres native enum registrations live under the postgres-specific\n * `entries.type` slot on `PostgresSchema` (target layer), not here.\n */\nexport type SqlStorageTypeEntry = StorageTypeInstance | StorageTypeInstanceInput;\n\nexport interface SqlNamespaceInput {\n readonly id: string;\n readonly entries: Readonly<Record<string, Readonly<Record<string, unknown>>>>;\n}\n\n/**\n * Target-supplied factory that materializes a `Namespace` from a SQL\n * `SqlNamespaceInput` (used to populate `SqlStorage.namespaces`).\n */\nexport type SqlNamespaceFactory = (input: SqlNamespaceInput) => Namespace;\n\n/**\n * SQL-family extension of the framework `AuthoringContributions`. SQL target\n * packs add a `createNamespace` factory so the PSL/TS authoring paths can\n * materialize namespaces (and merge lowered extension-block entities) without\n * each consumer re-specifying it. The factory is SQL-specific, so it lives here\n * rather than on the framework `AuthoringContributions` base.\n */\nexport interface SqlAuthoringContributions extends AuthoringContributions {\n readonly createNamespace?: SqlNamespaceFactory;\n}\n\n/**\n * Narrows framework `AuthoringContributions` to the SQL-family shape by testing\n * for the SQL-specific `createNamespace` capability.\n */\nexport function isSqlAuthoringContributions(\n authoring: AuthoringContributions | undefined,\n): authoring is SqlAuthoringContributions {\n if (authoring === undefined || !Object.hasOwn(authoring, 'createNamespace')) {\n return false;\n }\n return typeof Reflect.get(authoring, 'createNamespace') === 'function';\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, SqlNamespaceBase>>;\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. Callers must supply fully\n * constructed `Namespace` instances — construction discipline lives\n * in the authoring builders and deserializer hydration paths.\n *\n * The constructor normalises optional `types` into class instances.\n * `types` is polymorphic per Decision 18 Option B: codec-triple inputs\n * are stamped with `kind: 'codec-instance'`; hydration of raw JSON\n * class-instance entries (carrying their narrower `kind` literal) is\n * the per-target serializer's responsibility (so the family base does\n * not import target-specific subclasses).\n */\n/**\n * The typed `entries` shape for SQL family namespaces. The open dictionary\n * is intersected with optional known-kind maps so that `ns.entries.table`\n * and `ns.entries.valueSet` resolve without a cast, while unknown pack-\n * contributed kinds remain valid (the `Record` part allows any string key).\n */\nexport type SqlNamespaceEntries = Readonly<Record<string, Readonly<Record<string, unknown>>>> & {\n readonly table?: Readonly<Record<string, StorageTable>>;\n readonly valueSet?: Readonly<Record<string, StorageValueSet>>;\n};\n\n/**\n * Structural interface for SQL family namespaces. Generated `.d.ts` contract\n * types satisfy this structurally (no prototype methods). The runtime\n * abstract class `SqlNamespaceBase` extends this.\n *\n * `qualifyTable` and `isUnbound` are optional so JSON-shaped contract types\n * (which carry no methods) are accepted where `SqlNamespace` is required.\n * Hydrated `SqlNamespaceBase` instances always have both.\n */\nexport interface SqlNamespace {\n readonly kind: string;\n readonly id: string;\n readonly entries: SqlNamespaceEntries;\n readonly isUnbound?: boolean;\n qualifyTable?(tableName: string): string;\n}\n\n/**\n * Abstract SQL family namespace base class. Target concretions (`PostgresSchema`,\n * `SqliteDatabase`, …) extend this — it is never instantiated directly.\n * `entries` is the open ADR 224 dictionary: `entries[entityKind][entityName]`\n * addresses any entity.\n */\nexport abstract class SqlNamespaceBase extends NamespaceBase implements SqlNamespace {\n abstract override readonly id: string;\n abstract override readonly entries: SqlNamespaceEntries;\n\n abstract qualifyTable(tableName: string): string;\n}\n\n/**\n * Realm-safe guard for hydrated `SqlNamespaceBase` concretions. Checks\n * `qualifyTable` structurally instead of `instanceof NamespaceBase`, so it\n * survives duplicate-module boundaries (e.g. dist e2e where the target and\n * the family carry separate copies of `@prisma-next/framework-components`).\n *\n * Every concrete `SqlNamespaceBase` subclass (`PostgresSchema`, `SqliteDatabase`,\n * `TestSqlNamespace`, …) implements `qualifyTable`. Raw `SqlNamespaceInput`\n * objects (`{ id, entries }`) do not.\n */\nexport function isMaterializedSqlNamespace(x: unknown): x is SqlNamespaceBase {\n if (typeof x !== 'object' || x === null || !('qualifyTable' in x)) return false;\n return typeof x.qualifyTable === 'function';\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 declare readonly types?: Readonly<Record<string, StorageTypeInstance>>;\n\n constructor(input: SqlStorageInput<THash>) {\n super();\n this.storageHash = input.storageHash;\n this.namespaces = Object.freeze(input.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 * Every entry must carry a `kind: 'codec-instance'` discriminator or\n * be an already-constructed `StorageTypeInstance`. 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(name: string, entry: SqlStorageTypeEntry): StorageTypeInstance {\n if (isStorageTypeInstance(entry)) {\n // Normalise on-disk objects that omit `typeParams` (the canonical on-disk\n // form strips empty typeParams to keep JSON compact). The in-memory invariant\n // is always `typeParams: {}` when empty — never `undefined`. Only create a\n // new object when necessary to preserve identity-equality for callers that\n // hold a reference to an already-correct in-memory entry.\n if ('typeParams' in entry) {\n return entry;\n }\n return toStorageTypeInstance(entry);\n }\n const rawKind = isPlainRecord(entry) ? entry['kind'] : undefined;\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')}. Untagged codec triples should be wrapped with toStorageTypeInstance(...) before construction.`,\n );\n}\n","import type { CodecTrait } from '@prisma-next/framework-components/codec';\nimport type { ControlDriverInstance } from '@prisma-next/framework-components/control';\nimport type { ReferentialAction } from './ir/foreign-key';\n\nexport interface SqlControlDriverInstance<T extends string = string>\n extends ControlDriverInstance<'sql', T> {\n query<Row = Record<string, unknown>>(\n sql: string,\n params?: readonly unknown[],\n ): Promise<{ readonly rows: Row[] }>;\n}\n\nexport { CheckConstraint, type CheckConstraintInput } from './ir/check-constraint';\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 { PrimaryKey, type PrimaryKeyInput } from './ir/primary-key';\nexport { Index, type IndexInput } from './ir/sql-index';\nexport { SqlNode } from './ir/sql-node';\nexport {\n isMaterializedSqlNamespace,\n isSqlAuthoringContributions,\n type SqlAuthoringContributions,\n type SqlNamespace,\n SqlNamespaceBase,\n type SqlNamespaceEntries,\n type SqlNamespaceFactory,\n type SqlNamespaceInput,\n SqlStorage,\n type SqlStorageInput,\n type SqlStorageTypeEntry,\n} from './ir/sql-storage';\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 isStorageValueSet,\n StorageValueSet,\n type StorageValueSetInput,\n} from './ir/storage-value-set';\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 namespaceId: 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\n// Field-type maps nested by namespace coordinate: `[namespaceId][model][field]`.\n// Shared by the output and input field-type maps and their extractors.\nexport type NamespacedFieldTypeMap = Record<string, Record<string, Record<string, unknown>>>;\n\nexport type NamespacedStorageColumnTypeMap = Record<\n string,\n Record<string, Record<string, unknown>>\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 NamespacedFieldTypeMap = Record<string, never>,\n TFieldInputTypes extends NamespacedFieldTypeMap = Record<string, never>,\n TStorageColumnTypes extends NamespacedStorageColumnTypeMap = Record<string, never>,\n TStorageColumnInputTypes extends NamespacedStorageColumnTypeMap = Record<string, never>,\n> = {\n readonly codecTypes: TCodecTypes;\n readonly queryOperationTypes: TQueryOperationTypes;\n readonly fieldOutputTypes: TFieldOutputTypes;\n readonly fieldInputTypes: TFieldInputTypes;\n readonly storageColumnTypes: TStorageColumnTypes;\n readonly storageColumnInputTypes: TStorageColumnInputTypes;\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. Names a concrete codec identity, a set of capability traits the\n * field's codec must carry, or targets list-typed (`many`) fields. Element\n * capability gating for list ops travels in `elementTraits`.\n */\nexport type QueryOperationSelfSpec =\n | { readonly codecId: string; readonly traits?: never; readonly many?: never }\n | { readonly traits: readonly CodecTrait[]; readonly codecId?: never; readonly many?: never }\n | {\n readonly many: true;\n readonly elementTraits?: readonly CodecTrait[];\n readonly codecId?: never;\n readonly traits?: never;\n };\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 NamespacedFieldTypeMap\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 NamespacedFieldTypeMap\n ? F\n : Record<string, never>\n : Record<string, never>;\n\nexport type StorageColumnTypesOf<T> = [T] extends [never]\n ? Record<string, never>\n : T extends { readonly storageColumnTypes: infer F }\n ? F extends NamespacedStorageColumnTypeMap\n ? F\n : Record<string, never>\n : Record<string, never>;\n\nexport type StorageColumnInputTypesOf<T> = [T] extends [never]\n ? Record<string, never>\n : T extends { readonly storageColumnInputTypes: infer F }\n ? F extends NamespacedStorageColumnTypeMap\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>>;\nexport type ExtractStorageColumnTypes<T> = StorageColumnTypesOf<ExtractTypeMapsFromContract<T>>;\nexport type ExtractStorageColumnInputTypes<T> = StorageColumnInputTypesOf<\n ExtractTypeMapsFromContract<T>\n>;\n\nexport type ResolveCodecTypes<TContract, TTypeMaps> = [TTypeMaps] extends [never]\n ? ExtractCodecTypes<TContract>\n : CodecTypesOf<TTypeMaps>;\n"],"mappings":";;;;;;;;;;;AASA,MAAa,sBAAsB;;;;;;AAmCnC,SAAgB,sBAAsB,OAAsD;CAC1F,OAAO;EACL,MAAM;EACN,SAAS,MAAM;EACf,YAAY,MAAM;EAClB,YAAY,MAAM,cAAc,CAAC;CACnC;AACF;;;;;;AAOA,SAAgB,sBAAsB,OAA8C;CAClF,IAAI,OAAO,UAAU,YAAY,UAAU,MAAM,OAAO;CACxD,OAAQ,MAA6B,SAAS;AAChD;;;;;;;ACPA,SAAgB,4BACd,WACwC;CACxC,IAAI,cAAc,KAAA,KAAa,CAAC,OAAO,OAAO,WAAW,iBAAiB,GACxE,OAAO;CAET,OAAO,OAAO,QAAQ,IAAI,WAAW,iBAAiB,MAAM;AAC9D;;;;;;;AA+DA,IAAsB,mBAAtB,cAA+C,cAAsC,CAKrF;;;;;;;;;;;AAYA,SAAgB,2BAA2B,GAAmC;CAC5E,IAAI,OAAO,MAAM,YAAY,MAAM,QAAQ,EAAE,kBAAkB,IAAI,OAAO;CAC1E,OAAO,OAAO,EAAE,iBAAiB;AACnC;AAEA,IAAa,aAAb,cAA+D,QAA2B;CACxF;CACA;CAGA,YAAY,OAA+B;EACzC,MAAM;EACN,KAAK,cAAc,MAAM;EACzB,KAAK,aAAa,OAAO,OAAO,MAAM,UAAU;EAChD,IAAI,MAAM,UAAU,KAAA,GAClB,KAAK,QAAQ,OAAO,OAClB,OAAO,YACL,OAAO,QAAQ,MAAM,KAAK,CAAC,CAAC,KAAK,CAAC,MAAM,QAAQ,CAAC,MAAM,mBAAmB,MAAM,EAAE,CAAC,CAAC,CACtF,CACF;EAEF,WAAW,IAAI;CACjB;AACF;;;;;;;;;;;;;;;;;AAkBA,SAAS,mBAAmB,MAAc,OAAiD;CACzF,IAAI,sBAAsB,KAAK,GAAG;EAMhC,IAAI,gBAAgB,OAClB,OAAO;EAET,OAAO,sBAAsB,KAAK;CACpC;CACA,MAAM,UAAU,cAAc,KAAK,IAAI,MAAM,UAAU,KAAA;CACvD,MAAM,kBACJ,YAAY,KAAA,IACR,iCACA,uCAAuC,KAAK,UAAU,OAAO;CACnE,MAAM,IAAI,MACR,iBAAiB,KAAK,UAAU,IAAI,EAAE,QAAQ,gBAAgB,aAAa,KAAK,UAAU,gBAAgB,EAAE,gGAC9G;AACF;;;AC/HA,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;CACvC;AACF"}
@@ -0,0 +1,54 @@
1
+ import { t as SqlNode } from "./sql-node-QXu33IeX.mjs";
2
+ //#region src/ir/primary-key.d.ts
3
+ interface PrimaryKeyInput {
4
+ readonly columns: readonly string[];
5
+ readonly name?: string;
6
+ }
7
+ /**
8
+ * SQL Contract IR node for a table's primary-key constraint.
9
+ */
10
+ declare class PrimaryKey extends SqlNode {
11
+ readonly columns: readonly string[];
12
+ readonly name?: string;
13
+ constructor(input: PrimaryKeyInput);
14
+ }
15
+ //#endregion
16
+ //#region src/ir/sql-index.d.ts
17
+ interface IndexInput {
18
+ readonly columns: readonly string[];
19
+ readonly name?: string;
20
+ readonly type?: string;
21
+ readonly options?: Record<string, unknown>;
22
+ }
23
+ /**
24
+ * SQL Contract IR node for a table-level secondary index.
25
+ *
26
+ * Note that this class shadows the global TypeScript `Index` lib type
27
+ * at the family-shared name; consumer files that need both should
28
+ * alias one (e.g.
29
+ * `import { Index as SqlIndexNode } from '@prisma-next/sql-contract/types'`).
30
+ */
31
+ declare class Index extends SqlNode {
32
+ readonly columns: readonly string[];
33
+ readonly name?: string;
34
+ readonly type?: string;
35
+ readonly options?: Record<string, unknown>;
36
+ constructor(input: IndexInput);
37
+ }
38
+ //#endregion
39
+ //#region src/ir/unique-constraint.d.ts
40
+ interface UniqueConstraintInput {
41
+ readonly columns: readonly string[];
42
+ readonly name?: string;
43
+ }
44
+ /**
45
+ * SQL Contract IR node for a table-level unique constraint.
46
+ */
47
+ declare class UniqueConstraint extends SqlNode {
48
+ readonly columns: readonly string[];
49
+ readonly name?: string;
50
+ constructor(input: UniqueConstraintInput);
51
+ }
52
+ //#endregion
53
+ export { PrimaryKey as a, IndexInput as i, UniqueConstraintInput as n, PrimaryKeyInput as o, Index as r, UniqueConstraint as t };
54
+ //# sourceMappingURL=unique-constraint-WHfanEUq.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"unique-constraint-WHfanEUq.d.mts","names":[],"sources":["../src/ir/primary-key.ts","../src/ir/sql-index.ts","../src/ir/unique-constraint.ts"],"mappings":";;UAGiB;WACN;WACA;;;;;cAME,mBAAmB;WACrB;WACQ;cAEL,OAAO;;;;UCZJ;WACN;WACA;WACA;WACA,UAAU;;;;;;;;;;cAWR,cAAc;WAChB;WACQ;WACA;WACA,UAAU;cAEf,OAAO;;;;UCrBJ;WACN;WACA;;;;;cAME,yBAAyB;WAC3B;WACQ;cAEL,OAAO"}
@@ -1,10 +1,10 @@
1
- import { i as UniqueConstraintInput, u as PrimaryKeyInput } from "./storage-table-Bj1ZN1P7.mjs";
2
- import { n as ForeignKeyInput, r as ReferentialAction } from "./foreign-key-DM1UTydh.mjs";
3
- import { s as SqlStorage } from "./sql-storage-Dt5ipcRl.mjs";
1
+ import { n as ForeignKeyInput, r as ReferentialAction } from "./foreign-key-CWCEM2IT.mjs";
2
+ import { n as UniqueConstraintInput, o as PrimaryKeyInput } from "./unique-constraint-WHfanEUq.mjs";
3
+ import { s as SqlStorage } from "./sql-storage-BIErcfFA.mjs";
4
+ import "./types-lpzJtKpv.mjs";
4
5
  import { AnyEntityKindDescriptor } from "@prisma-next/framework-components/ir";
5
6
  import { Type } from "arktype";
6
7
  import { Contract } from "@prisma-next/contract/types";
7
-
8
8
  //#region src/ir/storage-entry-schemas.d.ts
9
9
  type ColumnDefaultLiteral = {
10
10
  readonly kind: 'literal';
@@ -1 +1 @@
1
- {"version":3,"file":"validators.d.mts","names":[],"sources":["../src/ir/storage-entry-schemas.ts","../src/validators.ts"],"mappings":";;;;;;;;KAMK,oBAAA;EAAA,SACM,IAAA;EAAA,SACA,KAAA,8BAAmC,MAAM;AAAA;AAAA,KAE/C,qBAAA;EAAA,SAAmC,IAAA;EAAA,SAA2B,UAAU;AAAA;AAAA,cAMhE,0BAAA,gDAA0B,UAAA,CAAA,oBAAA;AAAA,cAK1B,2BAAA,gDAA2B,UAAA,CAAA,qBAAA;AAAA,cAK3B,mBAAA,gDAAmB,UAAA,CAAA,oBAAA,GAAA,qBAAA;;;;AAlBoB;AAAA;cAmDvC,qBAAA,gDAAqB,UAAA;;gDAKhC,MAAA;AAAA;AAAA,cAYW,WAAA,gDAAW,UAAA;;;;YAKtB,MAAA;AAAA;AAAA,cAEW,yBAAA,gDAAyB,UAAA;;;;;;cAQzB,sBAAA,gDAAsB,UAAA;;;;;cAOtB,uBAAA,gDAAuB,UAAA,CAAA,iBAAA;AAAA,cAIvB,gBAAA,gDAAgB,UAAA,CAAA,eAAA;AAAA,cAUhB,qBAAA,gDAAqB,UAAA;;;;;;;;;;;cAOrB,kBAAA,gDAAkB,UAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cCflB,kBAAA,gDAAkB,UAAA;;;;mDAS7B,MAAA;EAAA;AAAA;;ADzGkD;AAAA;;;;AAEyB;AAM7E;iBCuHgB,0BAAA,CACd,KAAA,EAAO,WAAA,SAAoB,uBAAA,IAC1B,IAAA;;;ADzHoC;AAKvC;;;iBCgKgB,sBAAA,CACd,KAAA,EAAO,WAAA,SAAoB,uBAAA,IAC1B,IAAA;ADlKqC;AAKxC;;;;AALwC,iBC0TxB,uBAAA,CACd,KAAA,EAAO,WAAA,SAAoB,uBAAA,IAC1B,IAAA;;;;ADvT6B;AAiChC;;;;;iBC4TgB,eAAA,CAAgB,KAAc;AAAA,iBAQ9B,aAAA,CAAc,KAAc;;;;ADnT5C;;;;;;;;;;iBCiXgB,wBAAA,CAAyB,OAAmB,EAAV,UAAU;;AD1W5D;;;;;iBC+gBgB,8BAAA,CAA+B,QAAA,EAAU,QAAQ,CAAC,UAAA;;;;;;ADvgBlE;iBCmkBgB,6BAAA,CAA8B,QAAA,EAAU,QAAQ,CAAC,UAAA;AAAA,UAwGhD,+BAAA;EDtqB0B;;;;;;;AAE3C;EAF2C,SC+qBhC,cAAA,GAAiB,IAAI;AAAA;;AD7qBI;AAIpC;;;;AAA6B;AAU7B;iBC0qBgB,wBAAA,WAAmC,QAAA,CAAS,UAAA,GAC1D,KAAA,WACA,OAAA,GAAU,+BAAA,GACT,CAAA"}
1
+ {"version":3,"file":"validators.d.mts","names":[],"sources":["../src/ir/storage-entry-schemas.ts","../src/validators.ts"],"mappings":";;;;;;;;KAMK;WACM;WACA,mCAAmC;;KAEzC;WAAmC;WAA2B;;cAMtD,0EAA0B,WAAA;cAK1B,2EAA2B,WAAA;cAK3B,mEAAmB,WAAA,uBAAA;;;;;;cAiCnB,qEAAqB;;gDAArB;;cAiBA,2DAAW;;;;YAAX;;cAOA,yEAAyB;;;;;;cAQzB,sEAAsB;;;;;cAOtB,uEAAuB,WAAA;cAIvB,gEAAgB,WAAA;cAQhB,qEAAqB;;;;;;;;;;;cAOrB,kEAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cCblB,kEAAkB;;;;mDAAlB;;;;;;;;;;;iBA+BG,2BACd,OAAO,oBAAoB,2BAC1B;;;;;;;iBA4Ca,uBACd,OAAO,oBAAoB,2BAC1B;;;;;;iBAwJa,wBACd,OAAO,oBAAoB,2BAC1B;;;;;;;;;;iBAsCa,gBAAgB;iBAQhB,cAAc;;;;;;;;;;;;;;iBA8Dd,yBAAyB,SAAS;;;;;;;iBAmKlC,+BAA+B,UAAU,SAAS;;;;;;;iBA4DlD,8BAA8B,UAAU,SAAS;UAwGhD;;;;;;;;;WASN,iBAAiB;;;;;;;;;;iBAWZ,yBAAyB,UAAU,SAAS,aAC1D,gBACA,UAAU,kCACT"}
@@ -1,4 +1,4 @@
1
- import { a as ColumnDefaultFunctionSchema, c as ForeignKeyReferenceSchema, d as IndexSchema, f as ReferentialActionSchema, i as CheckConstraintSchema, l as ForeignKeySchema, m as StorageValueSetSchema, o as ColumnDefaultLiteralSchema, p as StorageTableSchema, s as ColumnDefaultSchema, t as composeSqlEntityKinds, u as ForeignKeySourceSchema } from "./entity-kinds-BEPZdFBN.mjs";
1
+ import { a as ColumnDefaultFunctionSchema, c as ForeignKeyReferenceSchema, d as IndexSchema, f as ReferentialActionSchema, i as CheckConstraintSchema, l as ForeignKeySchema, m as StorageValueSetSchema, o as ColumnDefaultLiteralSchema, p as StorageTableSchema, s as ColumnDefaultSchema, t as composeSqlEntityKinds, u as ForeignKeySourceSchema } from "./entity-kinds-CVg6HzG2.mjs";
2
2
  import { isPlainRecord } from "@prisma-next/framework-components/ir";
3
3
  import { type } from "arktype";
4
4
  import { CrossReferenceSchema } from "@prisma-next/contract/types";
@@ -338,9 +338,7 @@ function validateStorageSemantics(storage) {
338
338
  source: fk.source,
339
339
  target: fk.target,
340
340
  onDelete: fk.onDelete ?? null,
341
- onUpdate: fk.onUpdate ?? null,
342
- constraint: fk.constraint,
343
- index: fk.index
341
+ onUpdate: fk.onUpdate ?? null
344
342
  });
345
343
  if (seenForeignKeyDefinitions.has(signature)) {
346
344
  errors.push(`Namespace "${namespaceId}" table "${tableName}": duplicate foreign key definition on columns [${fk.source.columns.join(", ")}]`);