@prisma-next/sql-schema-ir 0.16.0-dev.30 → 0.16.0-dev.32
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/dist/exports/types.d.mts +1 -1
- package/dist/exports/types.mjs +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.mjs +1 -1
- package/dist/{types-Btj35AIt.mjs → types-ClrlsJJY.mjs} +17 -11
- package/dist/types-ClrlsJJY.mjs.map +1 -0
- package/dist/{types-DzLk5eOU.d.mts → types-Cnl67qhJ.d.mts} +4 -3
- package/dist/types-Cnl67qhJ.d.mts.map +1 -0
- package/package.json +7 -7
- package/src/ir/schema-node-kinds.ts +4 -1
- package/src/ir/sql-index-ir.ts +16 -9
- package/src/ir/sql-schema-ir-node.ts +4 -1
- package/dist/types-Btj35AIt.mjs.map +0 -1
- package/dist/types-DzLk5eOU.d.mts.map +0 -1
package/dist/exports/types.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { C as relationalNodeGranularity, D as assertNode, E as SqlSchemaIRNode, O as defineNonEnumerable, S as relationalNodeEntityKind, T as PrimaryKeyInput, _ as SqlColumnDefaultIR, a as SqlTableIR, b as SqlCheckConstraintIRInput, c as SqlUniqueIRInput, d as SqlForeignKeyIR, f as SqlForeignKeyIRInput, g as SqlColumnIRInput, h as SqlColumnIR, i as SqlSchemaIRInput, l as SqlIndexIR, m as SqlAnnotations, n as SqlTypeMetadataRegistry, o as SqlTableIRInput, p as SqlReferentialAction, r as SqlSchemaIR, s as SqlUniqueIR, t as SqlTypeMetadata, u as SqlIndexIRInput, v as SqlColumnDefaultIRInput, w as PrimaryKey, x as RelationalSchemaNodeKind, y as SqlCheckConstraintIR } from "../types-
|
|
1
|
+
import { C as relationalNodeGranularity, D as assertNode, E as SqlSchemaIRNode, O as defineNonEnumerable, S as relationalNodeEntityKind, T as PrimaryKeyInput, _ as SqlColumnDefaultIR, a as SqlTableIR, b as SqlCheckConstraintIRInput, c as SqlUniqueIRInput, d as SqlForeignKeyIR, f as SqlForeignKeyIRInput, g as SqlColumnIRInput, h as SqlColumnIR, i as SqlSchemaIRInput, l as SqlIndexIR, m as SqlAnnotations, n as SqlTypeMetadataRegistry, o as SqlTableIRInput, p as SqlReferentialAction, r as SqlSchemaIR, s as SqlUniqueIR, t as SqlTypeMetadata, u as SqlIndexIRInput, v as SqlColumnDefaultIRInput, w as PrimaryKey, x as RelationalSchemaNodeKind, y as SqlCheckConstraintIR } from "../types-Cnl67qhJ.mjs";
|
|
2
2
|
export { PrimaryKey, type PrimaryKeyInput, RelationalSchemaNodeKind, type SqlAnnotations, SqlCheckConstraintIR, type SqlCheckConstraintIRInput, SqlColumnDefaultIR, type SqlColumnDefaultIRInput, SqlColumnIR, type SqlColumnIRInput, SqlForeignKeyIR, type SqlForeignKeyIRInput, SqlIndexIR, type SqlIndexIRInput, type SqlReferentialAction, SqlSchemaIR, type SqlSchemaIRInput, SqlSchemaIRNode, SqlTableIR, type SqlTableIRInput, type SqlTypeMetadata, type SqlTypeMetadataRegistry, SqlUniqueIR, type SqlUniqueIRInput, assertNode, defineNonEnumerable, relationalNodeEntityKind, relationalNodeGranularity };
|
package/dist/exports/types.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as SqlForeignKeyIR, c as SqlCheckConstraintIR, d as assertNode, f as defineNonEnumerable, h as relationalNodeGranularity, i as SqlIndexIR, l as PrimaryKey, m as relationalNodeEntityKind, n as SqlTableIR, o as SqlColumnIR, p as RelationalSchemaNodeKind, r as SqlUniqueIR, s as SqlColumnDefaultIR, t as SqlSchemaIR, u as SqlSchemaIRNode } from "../types-
|
|
1
|
+
import { a as SqlForeignKeyIR, c as SqlCheckConstraintIR, d as assertNode, f as defineNonEnumerable, h as relationalNodeGranularity, i as SqlIndexIR, l as PrimaryKey, m as relationalNodeEntityKind, n as SqlTableIR, o as SqlColumnIR, p as RelationalSchemaNodeKind, r as SqlUniqueIR, s as SqlColumnDefaultIR, t as SqlSchemaIR, u as SqlSchemaIRNode } from "../types-ClrlsJJY.mjs";
|
|
2
2
|
export { PrimaryKey, RelationalSchemaNodeKind, SqlCheckConstraintIR, SqlColumnDefaultIR, SqlColumnIR, SqlForeignKeyIR, SqlIndexIR, SqlSchemaIR, SqlSchemaIRNode, SqlTableIR, SqlUniqueIR, assertNode, defineNonEnumerable, relationalNodeEntityKind, relationalNodeGranularity };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { C as relationalNodeGranularity, D as assertNode, E as SqlSchemaIRNode, O as defineNonEnumerable, S as relationalNodeEntityKind, T as PrimaryKeyInput, _ as SqlColumnDefaultIR, a as SqlTableIR, b as SqlCheckConstraintIRInput, c as SqlUniqueIRInput, d as SqlForeignKeyIR, f as SqlForeignKeyIRInput, g as SqlColumnIRInput, h as SqlColumnIR, i as SqlSchemaIRInput, l as SqlIndexIR, m as SqlAnnotations, n as SqlTypeMetadataRegistry, o as SqlTableIRInput, p as SqlReferentialAction, r as SqlSchemaIR, s as SqlUniqueIR, t as SqlTypeMetadata, u as SqlIndexIRInput, v as SqlColumnDefaultIRInput, w as PrimaryKey, x as RelationalSchemaNodeKind, y as SqlCheckConstraintIR } from "./types-
|
|
1
|
+
import { C as relationalNodeGranularity, D as assertNode, E as SqlSchemaIRNode, O as defineNonEnumerable, S as relationalNodeEntityKind, T as PrimaryKeyInput, _ as SqlColumnDefaultIR, a as SqlTableIR, b as SqlCheckConstraintIRInput, c as SqlUniqueIRInput, d as SqlForeignKeyIR, f as SqlForeignKeyIRInput, g as SqlColumnIRInput, h as SqlColumnIR, i as SqlSchemaIRInput, l as SqlIndexIR, m as SqlAnnotations, n as SqlTypeMetadataRegistry, o as SqlTableIRInput, p as SqlReferentialAction, r as SqlSchemaIR, s as SqlUniqueIR, t as SqlTypeMetadata, u as SqlIndexIRInput, v as SqlColumnDefaultIRInput, w as PrimaryKey, x as RelationalSchemaNodeKind, y as SqlCheckConstraintIR } from "./types-Cnl67qhJ.mjs";
|
|
2
2
|
export { PrimaryKey, type PrimaryKeyInput, RelationalSchemaNodeKind, type SqlAnnotations, SqlCheckConstraintIR, type SqlCheckConstraintIRInput, SqlColumnDefaultIR, type SqlColumnDefaultIRInput, SqlColumnIR, type SqlColumnIRInput, SqlForeignKeyIR, type SqlForeignKeyIRInput, SqlIndexIR, type SqlIndexIRInput, type SqlReferentialAction, SqlSchemaIR, type SqlSchemaIRInput, SqlSchemaIRNode, SqlTableIR, type SqlTableIRInput, type SqlTypeMetadata, type SqlTypeMetadataRegistry, SqlUniqueIR, type SqlUniqueIRInput, assertNode, defineNonEnumerable, relationalNodeEntityKind, relationalNodeGranularity };
|
package/dist/index.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as SqlForeignKeyIR, c as SqlCheckConstraintIR, d as assertNode, f as defineNonEnumerable, h as relationalNodeGranularity, i as SqlIndexIR, l as PrimaryKey, m as relationalNodeEntityKind, n as SqlTableIR, o as SqlColumnIR, p as RelationalSchemaNodeKind, r as SqlUniqueIR, s as SqlColumnDefaultIR, t as SqlSchemaIR, u as SqlSchemaIRNode } from "./types-
|
|
1
|
+
import { a as SqlForeignKeyIR, c as SqlCheckConstraintIR, d as assertNode, f as defineNonEnumerable, h as relationalNodeGranularity, i as SqlIndexIR, l as PrimaryKey, m as relationalNodeEntityKind, n as SqlTableIR, o as SqlColumnIR, p as RelationalSchemaNodeKind, r as SqlUniqueIR, s as SqlColumnDefaultIR, t as SqlSchemaIR, u as SqlSchemaIRNode } from "./types-ClrlsJJY.mjs";
|
|
2
2
|
export { PrimaryKey, RelationalSchemaNodeKind, SqlCheckConstraintIR, SqlColumnDefaultIR, SqlColumnIR, SqlForeignKeyIR, SqlIndexIR, SqlSchemaIR, SqlSchemaIRNode, SqlTableIR, SqlUniqueIR, assertNode, defineNonEnumerable, relationalNodeEntityKind, relationalNodeGranularity };
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { o as normalizeIndexOptionValue } from "./naming-BD7Y-Fq1.mjs";
|
|
2
2
|
import { IRNodeBase, freezeNode } from "@prisma-next/framework-components/ir";
|
|
3
3
|
import { blindCast } from "@prisma-next/utils/casts";
|
|
4
|
+
import { InternalError } from "@prisma-next/utils/internal-error";
|
|
4
5
|
import { canonicalStringify } from "@prisma-next/utils/canonical-stringify";
|
|
5
6
|
import { ifDefined } from "@prisma-next/utils/defined";
|
|
6
7
|
import { isArrayEqual } from "@prisma-next/utils/array-equal";
|
|
7
|
-
import { InternalError } from "@prisma-next/utils/internal-error";
|
|
8
8
|
//#region src/ir/schema-node-kinds.ts
|
|
9
9
|
/**
|
|
10
10
|
* The `nodeKind` discriminant for each relational schema-diff leaf node.
|
|
@@ -55,7 +55,7 @@ function isRelationalSchemaNodeKind(nodeKind) {
|
|
|
55
55
|
* than through this family-level map.
|
|
56
56
|
*/
|
|
57
57
|
function relationalNodeGranularity(nodeKind) {
|
|
58
|
-
if (!isRelationalSchemaNodeKind(nodeKind)) throw new
|
|
58
|
+
if (!isRelationalSchemaNodeKind(nodeKind)) throw new InternalError(`relationalNodeGranularity: unrecognized relational node kind "${nodeKind}"`);
|
|
59
59
|
return RELATIONAL_NODE_GRANULARITY[nodeKind];
|
|
60
60
|
}
|
|
61
61
|
/**
|
|
@@ -117,7 +117,7 @@ var SqlSchemaIRNode = class extends IRNodeBase {
|
|
|
117
117
|
* the class the caller expected.
|
|
118
118
|
*/
|
|
119
119
|
function assertNode(node, className, predicate) {
|
|
120
|
-
if (node === void 0 || !predicate(node)) throw new
|
|
120
|
+
if (node === void 0 || !predicate(node)) throw new InternalError(`Expected a ${className} but got nodeKind=${node?.nodeKind ?? "undefined"}`);
|
|
121
121
|
}
|
|
122
122
|
/**
|
|
123
123
|
* Defines a non-enumerable own property, the same treatment `kind` gets
|
|
@@ -509,7 +509,8 @@ var SqlIndexIR = class SqlIndexIR extends SqlSchemaIRNode {
|
|
|
509
509
|
if (input.columns !== void 0) this.columns = input.columns;
|
|
510
510
|
if (input.expression !== void 0) this.expression = input.expression;
|
|
511
511
|
if (input.where !== void 0) this.where = input.where;
|
|
512
|
-
|
|
512
|
+
const normalizedType = normalizeIndexType(input.type);
|
|
513
|
+
if (normalizedType !== void 0) this.type = normalizedType;
|
|
513
514
|
if (input.options !== void 0) this.options = input.options;
|
|
514
515
|
if (input.annotations !== void 0) this.annotations = input.annotations;
|
|
515
516
|
defineNonEnumerable(this, "dependsOn", input.dependsOn);
|
|
@@ -569,12 +570,17 @@ var SqlIndexIR = class SqlIndexIR extends SqlSchemaIRNode {
|
|
|
569
570
|
}
|
|
570
571
|
};
|
|
571
572
|
/**
|
|
572
|
-
*
|
|
573
|
-
* every supported SQL target)
|
|
574
|
-
*
|
|
575
|
-
*
|
|
576
|
-
*
|
|
577
|
-
*
|
|
573
|
+
* The btree-default normalization seam: the default access method (`btree`
|
|
574
|
+
* in every supported SQL target) normalizes to absent. Applied at
|
|
575
|
+
* construction — every derivation path (contract tree, introspection, flat
|
|
576
|
+
* family tree) builds through the class, so both compare sides are
|
|
577
|
+
* symmetric by definition — and again inside
|
|
578
|
+
* {@link SqlIndexIR.contentEquals} so the relation holds for any input.
|
|
579
|
+
* The contract JSON and the wire-name content hash keep the authored
|
|
580
|
+
* spelling: `@@index([a], type: "btree")` and `@@index([a])` are distinct
|
|
581
|
+
* wire names — but content-equal after normalization, so a spelling change
|
|
582
|
+
* between them converges as a rename via the planner's phase-2 content
|
|
583
|
+
* pairing (the hashes differ, so phase-1 never pairs them).
|
|
578
584
|
*/
|
|
579
585
|
function normalizeIndexType(type) {
|
|
580
586
|
return type === "btree" ? void 0 : type;
|
|
@@ -731,4 +737,4 @@ var SqlSchemaIR = class extends SqlSchemaIRNode {
|
|
|
731
737
|
//#endregion
|
|
732
738
|
export { SqlForeignKeyIR as a, SqlCheckConstraintIR as c, assertNode as d, defineNonEnumerable as f, relationalNodeGranularity as h, SqlIndexIR as i, PrimaryKey as l, relationalNodeEntityKind as m, SqlTableIR as n, SqlColumnIR as o, RelationalSchemaNodeKind as p, SqlUniqueIR as r, SqlColumnDefaultIR as s, SqlSchemaIR as t, SqlSchemaIRNode as u };
|
|
733
739
|
|
|
734
|
-
//# sourceMappingURL=types-
|
|
740
|
+
//# sourceMappingURL=types-ClrlsJJY.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types-ClrlsJJY.mjs","names":[],"sources":["../src/ir/schema-node-kinds.ts","../src/ir/sql-schema-ir-node.ts","../src/ir/primary-key.ts","../src/ir/sql-check-constraint-ir.ts","../src/ir/resolved-default-equality.ts","../src/ir/sql-column-default-ir.ts","../src/ir/sql-column-ir.ts","../src/ir/sql-foreign-key-ir.ts","../src/ir/sql-index-ir.ts","../src/ir/sql-unique-ir.ts","../src/ir/sql-table-ir.ts","../src/ir/sql-schema-ir.ts"],"sourcesContent":["import type { DiffSubjectGranularity } from '@prisma-next/framework-components/control';\nimport { InternalError } from '@prisma-next/utils/internal-error';\n\n/**\n * The `nodeKind` discriminant for each relational schema-diff leaf node.\n * Each node carries a unique value; the differ pairs siblings by `id`, and\n * these kinds distinguish the node types that appear as `PostgresTableSchemaNode`\n * children (columns, primary key, foreign keys, uniques, indexes, checks) from\n * each other and from the RLS policy/role kinds a target defines separately.\n */\nexport const RelationalSchemaNodeKind = {\n schema: 'sql-schema',\n table: 'sql-table',\n column: 'sql-column',\n columnDefault: 'sql-column-default',\n primaryKey: 'sql-primary-key',\n foreignKey: 'sql-foreign-key',\n unique: 'sql-unique',\n index: 'sql-index',\n check: 'sql-check-constraint',\n} as const;\n\nexport type RelationalSchemaNodeKind =\n (typeof RelationalSchemaNodeKind)[keyof typeof RelationalSchemaNodeKind];\n\n/**\n * The one real map from a relational `nodeKind` to the framework-neutral\n * {@link DiffSubjectGranularity} its diff issues carry — the SQL family's\n * post-diff filters (issue category, strict-mode gating) and the framework\n * aggregate's unclaimed-elements sweep key on the granularity, never on the\n * `nodeKind` spelling and never on anything stamped on the node. Resolution\n * is by `nodeKind` equality against this map, not a suffix string match.\n * Target-specific node kinds (Postgres namespace/table/policy/role) are\n * outside this family layer's vocabulary and map their own kinds directly.\n */\nconst RELATIONAL_NODE_GRANULARITY: Readonly<\n Record<RelationalSchemaNodeKind, DiffSubjectGranularity>\n> = {\n [RelationalSchemaNodeKind.schema]: 'structural',\n [RelationalSchemaNodeKind.table]: 'entity',\n [RelationalSchemaNodeKind.column]: 'field',\n [RelationalSchemaNodeKind.columnDefault]: 'auxiliary',\n [RelationalSchemaNodeKind.primaryKey]: 'auxiliary',\n [RelationalSchemaNodeKind.foreignKey]: 'auxiliary',\n [RelationalSchemaNodeKind.unique]: 'auxiliary',\n [RelationalSchemaNodeKind.index]: 'auxiliary',\n [RelationalSchemaNodeKind.check]: 'auxiliary',\n};\n\nfunction isRelationalSchemaNodeKind(nodeKind: string): nodeKind is RelationalSchemaNodeKind {\n return Object.hasOwn(RELATIONAL_NODE_GRANULARITY, nodeKind);\n}\n\n/**\n * Looks up the subject granularity for a relational `nodeKind`. Throws for a\n * `nodeKind` outside this map (a target-specific kind, e.g. Postgres's\n * namespace/table/policy/role) — those map their own kinds directly rather\n * than through this family-level map.\n */\nexport function relationalNodeGranularity(nodeKind: string): DiffSubjectGranularity {\n if (!isRelationalSchemaNodeKind(nodeKind)) {\n throw new InternalError(\n `relationalNodeGranularity: unrecognized relational node kind \"${nodeKind}\"`,\n );\n }\n return RELATIONAL_NODE_GRANULARITY[nodeKind];\n}\n\n/**\n * The one real map from a relational `nodeKind` to its storage `entityKind`\n * — the same vocabulary the contract storage's `entries` dictionary keys use\n * (`elementCoordinates` walks it). Only the whole-table kind has an entity of\n * its own; every other relational node (a column, an index, …) is nested\n * under one and maps to nothing here.\n */\nconst RELATIONAL_NODE_ENTITY_KIND: Partial<Readonly<Record<RelationalSchemaNodeKind, string>>> = {\n [RelationalSchemaNodeKind.table]: 'table',\n};\n\n/**\n * Looks up the storage `entityKind` for a relational `nodeKind` — sibling of\n * {@link relationalNodeGranularity}, resolved by `nodeKind` equality against\n * {@link RELATIONAL_NODE_ENTITY_KIND}. `undefined` for a target-specific kind\n * (targets map their own kinds directly) or a relational kind with no entity\n * of its own.\n */\nexport function relationalNodeEntityKind(nodeKind: string): string | undefined {\n return isRelationalSchemaNodeKind(nodeKind) ? RELATIONAL_NODE_ENTITY_KIND[nodeKind] : undefined;\n}\n","import { IRNodeBase } from '@prisma-next/framework-components/ir';\nimport { InternalError } from '@prisma-next/utils/internal-error';\n\n/**\n * SQL Schema IR node base. Carries the family-level\n * `kind = 'sql-schema-ir'` discriminator and inherits the framework's\n * `freezeNode` affordance.\n *\n * SQL Schema IR represents the actual database state as discovered by\n * introspection (the parallel to SQL Contract IR, which represents the\n * desired state).\n *\n * The discriminator is installed as a non-enumerable own property,\n * matching the SqlNode pattern. This keeps `JSON.stringify(node)`\n * canonical (no `kind` field), keeps `toEqual({...})` test assertions\n * against pre-lift flat shapes passing, and keeps `node.kind` readable\n * for dispatch.\n *\n * Both `kind` and `nodeKind` are required: every concrete leaf is a node\n * the generic differ can pair and compare, so every leaf must declare which\n * node it is. `nodeKind` has no default here — every direct subclass sets its\n * own literal value (the relational leaves via `RelationalSchemaNodeKind`,\n * target concretions via their own vocabulary, e.g. `PostgresSchemaNodeKind`).\n */\nexport abstract class SqlSchemaIRNode extends IRNodeBase {\n declare readonly kind: string;\n\n /**\n * Enumerable discriminant identifying which node this is (column / primary\n * key / foreign key / unique / index / check / database / namespace /\n * table / policy / role / …). Concretions set a unique value; the\n * `.is`/`.assert` guards compare against it. Unlike `kind`, it is\n * enumerable, so it survives a spread that flattens a node into a plain\n * object.\n */\n abstract readonly nodeKind: string;\n\n constructor() {\n super();\n Object.defineProperty(this, 'kind', {\n value: 'sql-schema-ir',\n writable: false,\n enumerable: false,\n configurable: false,\n });\n }\n}\n\n/**\n * Asserts `node` matches `predicate`, narrowing its type to `T`. The one\n * shared implementation every node class's `static assert` and `isEqualTo`\n * reach for, instead of each hand-writing its own throw: the message names\n * the class the caller expected.\n */\nexport function assertNode<T extends SqlSchemaIRNode>(\n node: SqlSchemaIRNode | undefined,\n className: string,\n predicate: (node: SqlSchemaIRNode) => node is T,\n): asserts node is T {\n if (node === undefined || !predicate(node)) {\n throw new InternalError(\n `Expected a ${className} but got nodeKind=${node?.nodeKind ?? 'undefined'}`,\n );\n }\n}\n\n/**\n * Defines a non-enumerable own property, the same treatment `kind` gets\n * above: a derivation-time render-support field stays out of\n * `JSON.stringify`, `toEqual({...})` structural assertions, and spreads,\n * while remaining directly readable (`node.field`) for the one consumer\n * that resolves it at plan time. A no-op when `value` is `undefined` — the\n * property is simply absent, matching every other optional field on these\n * nodes.\n */\nexport function defineNonEnumerable<T extends object>(\n target: T,\n key: string,\n value: unknown,\n): void {\n if (value === undefined) return;\n Object.defineProperty(target, key, {\n value,\n enumerable: false,\n writable: false,\n configurable: false,\n });\n}\n","import type { DiffableNode, SchemaNodeRef } from '@prisma-next/framework-components/control';\nimport { freezeNode } from '@prisma-next/framework-components/ir';\nimport { blindCast } from '@prisma-next/utils/casts';\nimport { RelationalSchemaNodeKind } from './schema-node-kinds';\nimport { assertNode, defineNonEnumerable, SqlSchemaIRNode } from './sql-schema-ir-node';\n\nexport interface PrimaryKeyInput {\n readonly columns: readonly string[];\n readonly name?: string;\n /**\n * The key's own column nodes, as root-anchored chains. The derivation\n * stamps them so the primary key is dropped before the columns it is built\n * on. Never compared by `isEqualTo`.\n */\n readonly dependsOn?: readonly SchemaNodeRef[];\n}\n\n/**\n * Primary-key Schema IR node. Mirrors the Contract IR `PrimaryKey`\n * shape (same `columns` + optional `name`) so verification can compare\n * intent and actual structurally. Defined here independently to avoid\n * a sql-schema-ir -> sql-contract dependency.\n *\n * Implements `DiffableNode` so a primary key is directly a table's diff-tree\n * child. `id` is a fixed sentinel — a table has at most one primary key, so\n * there is never a sibling to disambiguate against. `isEqualTo` compares the\n * column tuple; the PK's own `name` is a database-assigned label with no\n * semantic weight, so it is not compared (mirrors the policy node's\n * name-insensitivity to non-identifying detail).\n */\nexport class PrimaryKey extends SqlSchemaIRNode implements DiffableNode {\n override readonly nodeKind = RelationalSchemaNodeKind.primaryKey;\n\n readonly columns: readonly string[];\n declare readonly name?: string;\n /** See {@link PrimaryKeyInput.dependsOn}. Non-enumerable so it stays out of JSON and structural equality, matching `SqlColumnIR.codecRef`. */\n declare readonly dependsOn?: readonly SchemaNodeRef[];\n\n constructor(input: PrimaryKeyInput) {\n super();\n this.columns = input.columns;\n if (input.name !== undefined) this.name = input.name;\n defineNonEnumerable(this, 'dependsOn', input.dependsOn);\n freezeNode(this);\n }\n\n get id(): string {\n return 'primary-key';\n }\n\n children(): readonly DiffableNode[] {\n return [];\n }\n\n static is(node: SqlSchemaIRNode): node is PrimaryKey {\n return node.nodeKind === RelationalSchemaNodeKind.primaryKey;\n }\n\n isEqualTo(other: DiffableNode): boolean {\n const node = blindCast<\n SqlSchemaIRNode,\n 'every diff-tree node the differ pairs is a SqlSchemaIRNode'\n >(other);\n assertNode(node, 'PrimaryKey', PrimaryKey.is);\n return (\n this.columns.length === node.columns.length &&\n this.columns.every((c, i) => c === node.columns[i])\n );\n }\n}\n","import type { DiffableNode } from '@prisma-next/framework-components/control';\nimport { freezeNode } from '@prisma-next/framework-components/ir';\nimport { blindCast } from '@prisma-next/utils/casts';\nimport { RelationalSchemaNodeKind } from './schema-node-kinds';\nimport { assertNode, SqlSchemaIRNode } from './sql-schema-ir-node';\n\nexport interface SqlCheckConstraintIRInput {\n /** Constraint name as stored in the database catalog. */\n readonly name: string;\n /** Column the check restricts. */\n readonly column: string;\n /** Permitted values the column must be IN. */\n readonly permittedValues: readonly string[];\n}\n\n/**\n * Schema IR node for a table-level check constraint that restricts a\n * column to a set of permitted values (an enum-style `IN (...)` check).\n *\n * Carries the **resolved values** rather than a raw SQL predicate so\n * callers can compare value-sets without parsing SQL.\n *\n * Implements `DiffableNode` so a check constraint is directly a table's\n * diff-tree child: `id` is the constraint name. `isEqualTo` compares\n * `column` and the permitted-value set (order-insensitive — the database\n * does not guarantee `IN (...)` ordering).\n */\nexport class SqlCheckConstraintIR extends SqlSchemaIRNode implements DiffableNode {\n override readonly nodeKind = RelationalSchemaNodeKind.check;\n\n readonly name: string;\n readonly column: string;\n readonly permittedValues: readonly string[];\n\n constructor(input: SqlCheckConstraintIRInput) {\n super();\n this.name = input.name;\n this.column = input.column;\n this.permittedValues = Object.freeze([...input.permittedValues]);\n freezeNode(this);\n }\n\n get id(): string {\n return `check:${this.name}`;\n }\n\n children(): readonly DiffableNode[] {\n return [];\n }\n\n static is(node: SqlSchemaIRNode): node is SqlCheckConstraintIR {\n return node.nodeKind === RelationalSchemaNodeKind.check;\n }\n\n /**\n * Compares the permitted-value sets only (unordered), matching the\n * relational walk's `verifyCheckConstraints`: two checks pairing by name\n * compare their value sets — the `column` field is descriptive, not part\n * of the comparison, so a name-paired check with equal values verifies\n * regardless of which column carries it.\n */\n isEqualTo(other: DiffableNode): boolean {\n const node = blindCast<\n SqlSchemaIRNode,\n 'every diff-tree node the differ pairs is a SqlSchemaIRNode'\n >(other);\n assertNode(node, 'SqlCheckConstraintIR', SqlCheckConstraintIR.is);\n const thisValues = new Set(this.permittedValues);\n const otherValues = new Set(node.permittedValues);\n if (thisValues.size !== otherValues.size) return false;\n return [...thisValues].every((v) => otherValues.has(v));\n }\n}\n","import type { ColumnDefault } from '@prisma-next/contract/types';\nimport { canonicalStringify } from '@prisma-next/utils/canonical-stringify';\n\n/**\n * Structural equality for two resolved column defaults, ported from the\n * relational walk's `columnDefaultsEqual` normalized branch: kinds must\n * match; literal values are normalized (Date and temporal-typed strings to\n * ISO instants) then compared canonically (JSON objects match their\n * canonical string form); function expressions compare case- and\n * whitespace-insensitively.\n *\n * `nativeType` provides the temporal-normalization context (the actual\n * side's resolved native type in a diff comparison).\n */\nexport function resolvedDefaultsEqual(\n expected: ColumnDefault,\n actual: ColumnDefault,\n nativeType?: string,\n): boolean {\n if (expected.kind !== actual.kind) return false;\n if (expected.kind === 'literal' && actual.kind === 'literal') {\n return literalValuesEqual(\n normalizeLiteralValue(expected.value, nativeType),\n normalizeLiteralValue(actual.value, nativeType),\n );\n }\n if (expected.kind === 'function' && actual.kind === 'function') {\n return (\n normalizeFunctionExpression(expected.expression) ===\n normalizeFunctionExpression(actual.expression)\n );\n }\n return false;\n}\n\nfunction normalizeFunctionExpression(expression: string): string {\n return expression.toLowerCase().replace(/\\s+/g, '');\n}\n\nfunction isTemporalNativeType(nativeType?: string): boolean {\n if (!nativeType) return false;\n const normalized = nativeType.toLowerCase();\n return normalized.includes('timestamp') || normalized === 'date';\n}\n\nfunction normalizeLiteralValue(value: unknown, nativeType?: string): unknown {\n if (value instanceof Date) {\n return value.toISOString();\n }\n if (typeof value === 'string' && isTemporalNativeType(nativeType)) {\n const parsed = new Date(value);\n if (!Number.isNaN(parsed.getTime())) {\n return parsed.toISOString();\n }\n }\n return value;\n}\n\nfunction literalValuesEqual(a: unknown, b: unknown): boolean {\n if (a === b) return true;\n if (typeof a === 'object' && a !== null && typeof b === 'object' && b !== null) {\n return canonicalStringify(a) === canonicalStringify(b);\n }\n if (typeof a === 'object' && a !== null && typeof b === 'string') {\n try {\n return canonicalStringify(a) === canonicalStringify(JSON.parse(b));\n } catch {\n return false;\n }\n }\n if (typeof a === 'string' && typeof b === 'object' && b !== null) {\n try {\n return canonicalStringify(JSON.parse(a)) === canonicalStringify(b);\n } catch {\n return false;\n }\n }\n return false;\n}\n","import type { ColumnDefault } from '@prisma-next/contract/types';\nimport type { DiffableNode } from '@prisma-next/framework-components/control';\nimport { freezeNode } from '@prisma-next/framework-components/ir';\nimport { blindCast } from '@prisma-next/utils/casts';\nimport { resolvedDefaultsEqual } from './resolved-default-equality';\nimport { RelationalSchemaNodeKind } from './schema-node-kinds';\nimport { assertNode, defineNonEnumerable, SqlSchemaIRNode } from './sql-schema-ir-node';\n\nexport interface SqlColumnDefaultIRInput {\n /** Structured resolved default (contract-declared or normalizer-parsed). */\n readonly resolved?: ColumnDefault;\n /** Raw database default expression, when known (introspected side). */\n readonly raw?: string;\n /**\n * Native-type context for temporal literal normalization — the owning\n * column's resolved native type.\n */\n readonly nativeTypeContext?: string;\n /**\n * The owning column's array-ness, threaded through so the planner's\n * set-default op-builder can render an array-literal default (e.g.\n * `ARRAY[...]`) the same way the pre-`plan(start, end)` op-path did. See\n * {@link import('./sql-column-ir').SqlColumnIRInput.many}.\n */\n readonly many?: boolean;\n}\n\n/**\n * Schema-diff node for a column's default value. The default is the one\n * column attribute with an extra/missing/drift lifecycle of its own, so it\n * is a child node of the column rather than a compared attribute: an\n * undeclared live default surfaces as `not-expected`, a declared default the\n * database lacks as `not-found`, and a divergent value as `not-equal` — the\n * three reasons cover the legacy `extra_default` / `default_missing` /\n * `default_mismatch` vocabulary with no attribute inspection.\n *\n * `id` is a fixed sentinel — a column has at most one default. Built\n * transiently by `SqlColumnIR.children()` from the column's own fields;\n * never constructed by derivation or introspection directly.\n */\nexport class SqlColumnDefaultIR extends SqlSchemaIRNode implements DiffableNode {\n override readonly nodeKind = RelationalSchemaNodeKind.columnDefault;\n\n declare readonly resolved?: ColumnDefault;\n declare readonly raw?: string;\n declare readonly nativeTypeContext?: string;\n /** See {@link SqlColumnDefaultIRInput.many}. Non-enumerable so it stays out of JSON and structural equality. */\n declare readonly many?: boolean;\n\n constructor(input: SqlColumnDefaultIRInput) {\n super();\n if (input.resolved !== undefined) this.resolved = input.resolved;\n if (input.raw !== undefined) this.raw = input.raw;\n if (input.nativeTypeContext !== undefined) this.nativeTypeContext = input.nativeTypeContext;\n defineNonEnumerable(this, 'many', input.many);\n freezeNode(this);\n }\n\n get id(): string {\n return 'default';\n }\n\n children(): readonly DiffableNode[] {\n return [];\n }\n\n static is(node: SqlSchemaIRNode): node is SqlColumnDefaultIR {\n return node.nodeKind === RelationalSchemaNodeKind.columnDefault;\n }\n\n /**\n * Structured comparison with `this` as the expected side: both sides\n * resolved compare per the relational walk's `columnDefaultsEqual`\n * semantics; a declared expected default against an unparseable actual\n * (raw present, no resolved parse) is a mismatch; two raw-only nodes fall\n * back to raw string equality.\n */\n isEqualTo(other: DiffableNode): boolean {\n const node = blindCast<\n SqlSchemaIRNode,\n 'every diff-tree node the differ pairs is a SqlSchemaIRNode'\n >(other);\n assertNode(node, 'SqlColumnDefaultIR', SqlColumnDefaultIR.is);\n if (this.resolved !== undefined && node.resolved !== undefined) {\n return resolvedDefaultsEqual(\n this.resolved,\n node.resolved,\n node.nativeTypeContext ?? this.nativeTypeContext,\n );\n }\n if (this.resolved !== undefined || node.resolved !== undefined) {\n return false;\n }\n return this.raw === node.raw;\n }\n}\n","import type { ColumnDefault } from '@prisma-next/contract/types';\nimport type { CodecRef } from '@prisma-next/framework-components/codec';\nimport type { DiffableNode } from '@prisma-next/framework-components/control';\nimport { freezeNode } from '@prisma-next/framework-components/ir';\nimport { blindCast } from '@prisma-next/utils/casts';\nimport { ifDefined } from '@prisma-next/utils/defined';\nimport { RelationalSchemaNodeKind } from './schema-node-kinds';\nimport { SqlColumnDefaultIR } from './sql-column-default-ir';\nimport { assertNode, defineNonEnumerable, SqlSchemaIRNode } from './sql-schema-ir-node';\n\n/**\n * Namespaced annotations for extensibility. Each namespace\n * (e.g. `pg`, `pgvector`) owns its annotations subtree.\n */\nexport type SqlAnnotations = {\n readonly [namespace: string]: unknown;\n};\n\nexport interface SqlColumnIRInput {\n readonly name: string;\n readonly nativeType: string;\n readonly nullable: boolean;\n /** Raw database default expression (e.g. `'hello'::text`, `nextval('seq')`). */\n readonly default?: string;\n readonly annotations?: SqlAnnotations;\n /** True when the column is a native array (e.g. `text[]`, `int4[]`). The `nativeType` carries the element type only (e.g. `text`, `int4`). */\n readonly many?: boolean;\n /**\n * Fully resolved native type, comparable across the two diff sides:\n * the contract-derived side stamps the codec-expanded type (typeRef\n * resolved, parameterized types expanded, `[]` appended for arrays);\n * the introspected side stamps the target-normalized type with the same\n * `[]` convention. Stamped at construction by derivation/introspection;\n * absent on raw hand-built nodes.\n */\n readonly resolvedNativeType?: string;\n /**\n * Structured default, comparable across the two diff sides: the\n * contract-derived side stamps the contract's `ColumnDefault`; the\n * introspected side stamps the target default-normalizer's parse of the\n * raw expression. Absent when the column declares no default, or when\n * the introspected raw default could not be parsed.\n */\n readonly resolvedDefault?: ColumnDefault;\n /**\n * The column's resolved codec reference — the identity the migration\n * planner's op-builders resolve DDL type rendering against at plan time\n * (parameterized type expansion, e.g. `character` + `{ length: 36 }` →\n * `character(36)`), calling the same codec hooks the pre-`plan(start,\n * end)` op-path called. Carried the same way the query AST carries\n * `CodecRef` (TML-2456) and the migration DDL renderer (TML-2918).\n * Stamped on the EXPECTED (contract-derived) column at derivation,\n * post-`typeRef` resolution (the referenced storage type's own\n * codec/params, not the column's `typeRef` pointer). Absent on\n * introspected/hand-built nodes — the actual side never renders DDL —\n * and never compared by `isEqualTo`.\n */\n readonly codecRef?: CodecRef;\n /**\n * The column's resolved BASE native type: pre-parameter-expansion,\n * pre-array-suffix (e.g. `character`, not `character(36)` or\n * `character[]`). Distinct from {@link resolvedNativeType} (the EXPANDED\n * comparison value) — DDL rendering re-expands a parameterized type at\n * plan time from this base, so it must not already carry the expansion.\n * Stamped alongside {@link codecRef}.\n */\n readonly codecBaseNativeType?: string;\n /**\n * True when the contract column declared its type via a named\n * `storage.types` reference (`typeRef`) rather than inline fields — the\n * migration planner quotes the base native type as an identifier in this\n * case (e.g. a native enum's type name), matching the pre-`plan(start,\n * end)` rendering exactly.\n */\n readonly codecNamedType?: boolean;\n}\n\n/**\n * Schema IR node for a single column on a table, as observed by\n * introspection. Unlike the Contract IR `StorageColumn`, this carries\n * the column's `name` (Schema IR columns are returned as arrays from\n * introspection queries; the parent table re-keys them into a record\n * for downstream consumers).\n *\n * Implements `DiffableNode` so a column is directly a table's diff-tree\n * child: `id` is the column name (unique among a table's columns); `isEqualTo`\n * compares this column's own attributes only — never children, since a\n * column is a leaf. When both sides carry `resolvedNativeType` (stamped at\n * derivation/introspection), the comparison uses the resolved values —\n * resolved native type, nullability, and structured default equality per\n * the relational walk's `columnDefaultsEqual` semantics, with `this` as the\n * expected side. Otherwise it falls back to comparing raw fields.\n */\nexport class SqlColumnIR extends SqlSchemaIRNode implements DiffableNode {\n override readonly nodeKind = RelationalSchemaNodeKind.column;\n\n readonly name: string;\n readonly nativeType: string;\n readonly nullable: boolean;\n declare readonly default?: string;\n declare readonly annotations?: SqlAnnotations;\n /** True when the column is a native array (e.g. `text[]`, `int4[]`). The `nativeType` carries the element type only (e.g. `text`, `int4`). */\n declare readonly many?: boolean;\n declare readonly resolvedNativeType?: string;\n declare readonly resolvedDefault?: ColumnDefault;\n /** See {@link SqlColumnIRInput.codecRef}. Non-enumerable so it stays out of JSON and structural equality. */\n declare readonly codecRef?: CodecRef;\n /** See {@link SqlColumnIRInput.codecBaseNativeType}. Non-enumerable, same reason as {@link codecRef}. */\n declare readonly codecBaseNativeType?: string;\n /** See {@link SqlColumnIRInput.codecNamedType}. Non-enumerable, same reason as {@link codecRef}. */\n declare readonly codecNamedType?: boolean;\n\n constructor(input: SqlColumnIRInput) {\n super();\n this.name = input.name;\n this.nativeType = input.nativeType;\n this.nullable = input.nullable;\n if (input.default !== undefined) this.default = input.default;\n if (input.annotations !== undefined) this.annotations = input.annotations;\n if (input.many !== undefined) this.many = input.many;\n if (input.resolvedNativeType !== undefined) this.resolvedNativeType = input.resolvedNativeType;\n if (input.resolvedDefault !== undefined) this.resolvedDefault = input.resolvedDefault;\n defineNonEnumerable(this, 'codecRef', input.codecRef);\n defineNonEnumerable(this, 'codecBaseNativeType', input.codecBaseNativeType);\n defineNonEnumerable(this, 'codecNamedType', input.codecNamedType);\n freezeNode(this);\n }\n\n get id(): string {\n return `column:${this.name}`;\n }\n\n /**\n * The column's default, when declared/present, is the column's one child\n * node — it has an extra/missing/drift lifecycle of its own, so the differ\n * recurses to it rather than `isEqualTo` comparing it. Built transiently\n * from this column's own fields.\n */\n children(): readonly DiffableNode[] {\n if (this.resolvedDefault === undefined && this.default === undefined) {\n return [];\n }\n return [\n new SqlColumnDefaultIR({\n ...ifDefined('resolved', this.resolvedDefault),\n ...ifDefined('raw', this.default),\n ...ifDefined('nativeTypeContext', this.resolvedNativeType),\n // Contract-derived and introspected columns both set `this.many`\n // directly (with `nativeType` as the bare element type; array-ness\n // never rides on a `[]` suffix). `codecRef.many` is a fallback for\n // hand-built nodes that carry a codec ref without the column-level\n // flag. Either source works for the default node's array-literal\n // rendering.\n ...ifDefined('many', this.many ?? this.codecRef?.many),\n }),\n ];\n }\n\n static is(node: SqlSchemaIRNode): node is SqlColumnIR {\n return node.nodeKind === RelationalSchemaNodeKind.column;\n }\n\n /**\n * Compares the column's own attributes only — the default lives on the\n * child node. When both sides carry `resolvedNativeType`, the resolved\n * value governs (array-ness rides on its `[]` suffix); otherwise raw\n * fields compare.\n */\n isEqualTo(other: DiffableNode): boolean {\n const node = blindCast<\n SqlSchemaIRNode,\n 'every diff-tree node the differ pairs is a SqlSchemaIRNode'\n >(other);\n assertNode(node, 'SqlColumnIR', SqlColumnIR.is);\n if (this.resolvedNativeType !== undefined && node.resolvedNativeType !== undefined) {\n return this.resolvedNativeType === node.resolvedNativeType && this.nullable === node.nullable;\n }\n return (\n this.nativeType === node.nativeType &&\n this.nullable === node.nullable &&\n Boolean(this.many) === Boolean(node.many)\n );\n }\n}\n","import type { DiffableNode, SchemaNodeRef } from '@prisma-next/framework-components/control';\nimport { freezeNode } from '@prisma-next/framework-components/ir';\nimport { blindCast } from '@prisma-next/utils/casts';\nimport { RelationalSchemaNodeKind } from './schema-node-kinds';\nimport type { SqlAnnotations } from './sql-column-ir';\nimport { assertNode, defineNonEnumerable, SqlSchemaIRNode } from './sql-schema-ir-node';\n\nexport type SqlReferentialAction = 'noAction' | 'restrict' | 'cascade' | 'setNull' | 'setDefault';\n\nexport interface SqlForeignKeyIRInput {\n readonly columns: readonly string[];\n readonly referencedTable: string;\n readonly referencedColumns: readonly string[];\n /** Schema (namespace) of the referenced table — populated by adapters that introspect cross-schema FKs. */\n readonly referencedSchema?: string;\n readonly name?: string;\n readonly onDelete?: SqlReferentialAction;\n readonly onUpdate?: SqlReferentialAction;\n readonly annotations?: SqlAnnotations;\n /**\n * The real live DDL namespace of the referenced table, comparable across\n * the two diff sides. Contract-derived trees stamp it explicitly (resolving\n * namespace ids — including the unbound sentinel — to the DDL namespace);\n * introspected FKs default it to `referencedSchema`, whose value already\n * is the live namespace. Folded into `id` in place of the raw value so an\n * unbound-namespace contract FK pairs with its introspected counterpart.\n */\n readonly resolvedReferencedNamespace?: string;\n /**\n * The referenced table's node, as the root-anchored chain the differ pairs\n * siblings with. Stamped by the derivation, which holds the parent\n * (database/namespace) context the chain's shape depends on. Never\n * compared by `isEqualTo`.\n */\n readonly dependsOn?: readonly SchemaNodeRef[];\n}\n\n/**\n * Schema IR node for a foreign-key constraint as observed by\n * introspection. The `referencedTable` / `referencedColumns` field\n * names match the introspection vocabulary (`pg_constraint.confkey`,\n * etc.) and intentionally differ from the Contract IR's nested\n * `references: { table, columns }` shape so that the verifier's\n * structural comparison stays explicit about which side it's reading.\n *\n * Implements `DiffableNode` so a foreign key is directly a table's diff-tree\n * child. Foreign keys are frequently unnamed (introspection may not carry a\n * constraint name, and the contract side never invents one), so `id` is\n * derived from the referencing/referenced coordinates rather than `name` —\n * the same tuple that makes two FK constraints the same constraint. This\n * also serves as the comparison key: two FKs with the same coordinates are\n * paired by the differ, and `isEqualTo` then compares the remaining\n * attribute — the referential actions.\n */\nexport class SqlForeignKeyIR extends SqlSchemaIRNode implements DiffableNode {\n override readonly nodeKind = RelationalSchemaNodeKind.foreignKey;\n\n readonly columns: readonly string[];\n readonly referencedTable: string;\n readonly referencedColumns: readonly string[];\n declare readonly referencedSchema?: string;\n declare readonly name?: string;\n declare readonly onDelete?: SqlReferentialAction;\n declare readonly onUpdate?: SqlReferentialAction;\n declare readonly annotations?: SqlAnnotations;\n declare readonly resolvedReferencedNamespace?: string;\n /** See {@link SqlForeignKeyIRInput.dependsOn}. Non-enumerable so it stays out of JSON and structural equality, matching `SqlColumnIR.codecRef`. */\n declare readonly dependsOn?: readonly SchemaNodeRef[];\n\n constructor(input: SqlForeignKeyIRInput) {\n super();\n this.columns = input.columns;\n this.referencedTable = input.referencedTable;\n this.referencedColumns = input.referencedColumns;\n if (input.referencedSchema !== undefined) this.referencedSchema = input.referencedSchema;\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 if (input.annotations !== undefined) this.annotations = input.annotations;\n const resolvedReferencedNamespace = input.resolvedReferencedNamespace ?? input.referencedSchema;\n if (resolvedReferencedNamespace !== undefined) {\n this.resolvedReferencedNamespace = resolvedReferencedNamespace;\n }\n defineNonEnumerable(this, 'dependsOn', input.dependsOn);\n freezeNode(this);\n }\n\n get id(): string {\n const referencedNamespace = this.resolvedReferencedNamespace ?? '';\n return `foreign-key:${this.columns.join(',')}->${referencedNamespace}.${this.referencedTable}(${this.referencedColumns.join(',')})`;\n }\n\n children(): readonly DiffableNode[] {\n return [];\n }\n\n static is(node: SqlSchemaIRNode): node is SqlForeignKeyIR {\n return node.nodeKind === RelationalSchemaNodeKind.foreignKey;\n }\n\n /**\n * Referential-action comparison with `this` as the expected side, matching\n * the relational walk's `getReferentialActionMismatches`: `noAction` is the\n * database default and equivalent to an undeclared action, and drift is\n * flagged only when the expected side declares a (normalized) action.\n */\n isEqualTo(other: DiffableNode): boolean {\n const node = blindCast<\n SqlSchemaIRNode,\n 'every diff-tree node the differ pairs is a SqlSchemaIRNode'\n >(other);\n assertNode(node, 'SqlForeignKeyIR', SqlForeignKeyIR.is);\n return (\n referentialActionMatches(this.onDelete, node.onDelete) &&\n referentialActionMatches(this.onUpdate, node.onUpdate)\n );\n }\n}\n\nfunction referentialActionMatches(\n expected: SqlReferentialAction | undefined,\n actual: SqlReferentialAction | undefined,\n): boolean {\n const normalizedExpected = expected === 'noAction' ? undefined : expected;\n if (normalizedExpected === undefined) return true;\n const normalizedActual = actual === 'noAction' ? undefined : actual;\n return normalizedExpected === normalizedActual;\n}\n","import type { DiffableNode, SchemaNodeRef } from '@prisma-next/framework-components/control';\nimport { freezeNode } from '@prisma-next/framework-components/ir';\nimport { isArrayEqual } from '@prisma-next/utils/array-equal';\nimport { blindCast } from '@prisma-next/utils/casts';\nimport { InternalError } from '@prisma-next/utils/internal-error';\nimport { normalizeIndexOptionValue } from '../naming';\nimport { RelationalSchemaNodeKind } from './schema-node-kinds';\nimport type { SqlAnnotations } from './sql-column-ir';\nimport { assertNode, defineNonEnumerable, SqlSchemaIRNode } from './sql-schema-ir-node';\n\n/**\n * An index's element structure — exactly one of a column tuple or an opaque\n * expression, unrepresentable-otherwise at the type level. No discriminant\n * is stored (the node keeps flat readonly accessors); the constructor's xor\n * throw stays as the backstop for introspection rows and JSON-derived\n * inputs that bypass this union.\n */\nexport type SqlIndexElements =\n | {\n /** Column-tuple elements. */\n readonly columns: readonly string[];\n readonly expression?: never;\n }\n | {\n readonly columns?: never;\n /**\n * Opaque SQL: the entire element list between the parens of CREATE\n * INDEX — one string, never parsed.\n */\n readonly expression: string;\n };\n\n/**\n * Every non-element field is a required key. Values that may legitimately\n * be absent (an exact-named index's prefix, the btree→undefined type\n * normalization) are typed `| undefined` instead of optional, so each\n * construction site\n * states the absence explicitly rather than omitting the key silently.\n * Undefined values still produce an instance without the property.\n */\nexport type SqlIndexIRInput = SqlIndexElements & {\n /** Full physical name — the node's identity. */\n readonly name: string;\n /**\n * The managed-mode name prefix — its PRESENCE is the naming-mode\n * discriminator (there is no stored enum). Present ⇔ managed: the\n * toolchain owns the physical name and `name === formatWireName(prefix,\n * <8hex content hash>)`. Absent ⇔ exact: `name` is an adopted verbatim\n * physical name whose identity the author owns entirely.\n */\n readonly prefix: string | undefined;\n /** Opaque SQL: partial-index predicate (WHERE body, without the keyword). */\n readonly where: string | undefined;\n readonly unique: boolean;\n readonly type: string | undefined;\n readonly options: Record<string, unknown> | undefined;\n readonly annotations: SqlAnnotations | undefined;\n /**\n * The index's own column nodes, as root-anchored chains. The derivation\n * stamps them so an index is dropped before the columns it is built on\n * (Postgres auto-drops the index when a covered column goes). An expression\n * index stamps chains to every column of its table — a deterministic\n * over-approximation, since the opaque expression is never parsed. Never\n * compared by `isEqualTo`.\n */\n readonly dependsOn: readonly SchemaNodeRef[] | undefined;\n /**\n * Whether the index is partial (has a row predicate). Required: every\n * producer must assert partiality explicitly, because a partial unique\n * index does not guarantee at-most-one row per key and so cannot back a\n * 1:1 relation — \"unknown\" must not silently default to \"total\". Never\n * compared by `isEqualTo` and never serialized.\n */\n readonly partial: boolean;\n};\n\n/**\n * Schema IR node for a secondary index as observed by introspection.\n * Unlike the Contract IR `Index`, the Schema IR carries an explicit\n * `unique` field — introspection sees the underlying index regardless\n * of whether the user expressed it as `@@index` or `@@unique`, and the\n * verifier needs to distinguish them when comparing to the Contract.\n *\n * Implements `DiffableNode` so an index is directly a table's diff-tree\n * child. Indexes are name-identified: every index — contract-derived or\n * introspected — carries its full physical name, and `id` is that name.\n * Names are catalog-unique per schema, so two indexes legitimately sharing\n * one column tuple (a unique index beside a redundant plain index) are two\n * distinct siblings, and expression indexes need no column tuple at all.\n *\n * `isEqualTo` is selected by the receiver (the differ always calls\n * `expected.isEqualTo(actual)`) and delegates to {@link contentEquals} —\n * the single node-owned content relation: both modes compare `unique`\n * strict, `type` and option values through the named normalization seams,\n * and `columns` ordered-strict when both sides carry them; an exact-named\n * receiver (`prefix === undefined`) additionally byte-compares\n * `expression`/`where` (both sides are reprints in the supported flow —\n * normalizing would only mask real drift); a managed receiver never\n * compares bodies (the wire-name hash already commits to them).\n *\n * `expression`, `where`, and `unique` are genuine SQL-family attributes —\n * functional and partial indexes are standard SQL that any SQL target may\n * introspect, so the family node must represent them; a target declining\n * to author them is a capability decision, not target-specificity.\n */\nexport class SqlIndexIR extends SqlSchemaIRNode implements DiffableNode {\n override readonly nodeKind = RelationalSchemaNodeKind.index;\n\n readonly name: string;\n readonly unique: boolean;\n declare readonly prefix?: string;\n declare readonly columns?: readonly string[];\n declare readonly expression?: string;\n declare readonly where?: string;\n declare readonly type?: string;\n declare readonly options?: Record<string, unknown>;\n declare readonly annotations?: SqlAnnotations;\n /** See {@link SqlIndexIRInput.dependsOn}. Non-enumerable so it stays out of JSON and structural equality, matching `SqlColumnIR.codecRef`. */\n declare readonly dependsOn?: readonly SchemaNodeRef[];\n /** See {@link SqlIndexIRInput.partial}. Non-enumerable so it stays out of JSON and structural equality, matching `dependsOn`. */\n declare readonly partial: boolean;\n\n constructor(input: SqlIndexIRInput) {\n super();\n if ((input.columns === undefined) === (input.expression === undefined)) {\n throw new InternalError(\n `SqlIndexIR \"${input.name}\": exactly one of columns or expression must be set.`,\n );\n }\n this.name = input.name;\n this.unique = input.unique;\n if (input.prefix !== undefined) this.prefix = input.prefix;\n if (input.columns !== undefined) this.columns = input.columns;\n if (input.expression !== undefined) this.expression = input.expression;\n if (input.where !== undefined) this.where = input.where;\n const normalizedType = normalizeIndexType(input.type);\n if (normalizedType !== undefined) this.type = normalizedType;\n if (input.options !== undefined) this.options = input.options;\n if (input.annotations !== undefined) this.annotations = input.annotations;\n defineNonEnumerable(this, 'dependsOn', input.dependsOn);\n defineNonEnumerable(this, 'partial', input.partial);\n freezeNode(this);\n }\n\n get id(): string {\n return `index:${this.name}`;\n }\n\n children(): readonly DiffableNode[] {\n return [];\n }\n\n static is(node: SqlSchemaIRNode): node is SqlIndexIR {\n return node.nodeKind === RelationalSchemaNodeKind.index;\n }\n\n /**\n * Mode-selected structural equality — see the class doc. Delegates to the\n * single node-owned relation: `columns` compare ordered-strict when both\n * sides carry them; an exact receiver (`prefix === undefined`)\n * byte-compares `expression ?? ''` and `where ?? ''`; a managed receiver\n * never compares bodies (the wire-name hash already commits to them).\n */\n isEqualTo(other: DiffableNode): boolean {\n const node = blindCast<\n SqlSchemaIRNode,\n 'every diff-tree node the differ pairs is a SqlSchemaIRNode'\n >(other);\n assertNode(node, 'SqlIndexIR', SqlIndexIR.is);\n return this.contentEquals(node, {\n columnPresence: 'when-both-defined',\n bodies: this.prefix !== undefined ? 'ignored' : 'verbatim',\n });\n }\n\n /**\n * The single index content-equality relation — every comparer (the differ\n * via {@link isEqualTo}, the planner's rename content-pairing) calls this\n * with its mode-appropriate strictness rather than growing a parallel\n * relation:\n *\n * - `columnPresence: 'when-both-defined'` (the differ's rule) compares\n * the tuples ordered-strict only when both sides carry them — a paired\n * node's identity already agreed, so a column node meeting an\n * expression node skips the tuple.\n * - `columnPresence: 'matching'` (the rename-pairing rule) additionally\n * requires presence to agree: a column index never pairs an expression\n * index.\n * - `bodies: 'verbatim'` byte-compares `expression ?? ''` / `where ?? ''`\n * (absent ≡ empty, no normalization — both sides are reprints in the\n * supported flow); `bodies: 'ignored'` skips them (managed identity —\n * the wire-name hash commits to the content).\n *\n * `unique` compares strictly; `type` and option VALUES compare through\n * the named normalization seams below.\n */\n contentEquals(\n other: SqlIndexIR,\n strictness: {\n readonly columnPresence: 'when-both-defined' | 'matching';\n readonly bodies: 'verbatim' | 'ignored';\n },\n ): boolean {\n const columnsEqual =\n strictness.columnPresence === 'matching'\n ? (this.columns === undefined) === (other.columns === undefined) &&\n (this.columns === undefined || isArrayEqual(this.columns, other.columns ?? []))\n : this.columns === undefined ||\n other.columns === undefined ||\n isArrayEqual(this.columns, other.columns);\n const structurallyEqual =\n this.unique === other.unique &&\n normalizeIndexType(this.type) === normalizeIndexType(other.type) &&\n indexOptionsEqual(this.options, other.options) &&\n columnsEqual;\n if (!structurallyEqual) return false;\n if (strictness.bodies === 'ignored') return true;\n return (\n (this.expression ?? '') === (other.expression ?? '') &&\n (this.where ?? '') === (other.where ?? '')\n );\n }\n}\n\n/**\n * The btree-default normalization seam: the default access method (`btree`\n * in every supported SQL target) normalizes to absent. Applied at\n * construction — every derivation path (contract tree, introspection, flat\n * family tree) builds through the class, so both compare sides are\n * symmetric by definition — and again inside\n * {@link SqlIndexIR.contentEquals} so the relation holds for any input.\n * The contract JSON and the wire-name content hash keep the authored\n * spelling: `@@index([a], type: \"btree\")` and `@@index([a])` are distinct\n * wire names — but content-equal after normalization, so a spelling change\n * between them converges as a rename via the planner's phase-2 content\n * pairing (the hashes differ, so phase-1 never pairs them).\n */\nfunction normalizeIndexType(type: string | undefined): string | undefined {\n return type === 'btree' ? undefined : type;\n}\n\n/**\n * Option-bag equality: same key set, values compared through\n * {@link normalizeIndexOptionValue} — Postgres introspection returns\n * reloptions values as catalog-reprint strings (`'70'`, `'on'`) while\n * contract option leaves are typed (number, boolean, string).\n */\nfunction indexOptionsEqual(\n a: Record<string, unknown> | undefined,\n b: Record<string, unknown> | undefined,\n): boolean {\n const aKeys = a ? Object.keys(a).sort() : [];\n const bKeys = b ? Object.keys(b).sort() : [];\n if (aKeys.length !== bKeys.length) return false;\n for (let i = 0; i < aKeys.length; i += 1) {\n if (aKeys[i] !== bKeys[i]) return false;\n }\n if (aKeys.length === 0) return true;\n for (const key of aKeys) {\n if (normalizeIndexOptionValue(a?.[key]) !== normalizeIndexOptionValue(b?.[key])) {\n return false;\n }\n }\n return true;\n}\n","import type { DiffableNode, SchemaNodeRef } from '@prisma-next/framework-components/control';\nimport { freezeNode } from '@prisma-next/framework-components/ir';\nimport { blindCast } from '@prisma-next/utils/casts';\nimport { RelationalSchemaNodeKind } from './schema-node-kinds';\nimport type { SqlAnnotations } from './sql-column-ir';\nimport { assertNode, defineNonEnumerable, SqlSchemaIRNode } from './sql-schema-ir-node';\n\nexport interface SqlUniqueIRInput {\n readonly columns: readonly string[];\n readonly name?: string;\n readonly annotations?: SqlAnnotations;\n /**\n * The constraint's own column nodes, as root-anchored chains. The\n * derivation stamps them so a unique constraint is dropped before the\n * columns it is built on. Never compared by `isEqualTo`.\n */\n readonly dependsOn?: readonly SchemaNodeRef[];\n}\n\n/**\n * Schema IR node for a table-level unique constraint as observed by\n * introspection.\n *\n * Implements `DiffableNode` so a unique constraint is directly a table's\n * diff-tree child. Unique constraints are frequently unnamed, so `id` is\n * derived from the column tuple rather than `name` — the column tuple is\n * also what makes two unique constraints the same constraint, so it doubles\n * as the pairing key. There are no further attributes to compare once\n * columns are equal (the differ pairs on `id`), so `isEqualTo` is identity.\n */\nexport class SqlUniqueIR extends SqlSchemaIRNode implements DiffableNode {\n override readonly nodeKind = RelationalSchemaNodeKind.unique;\n\n readonly columns: readonly string[];\n declare readonly name?: string;\n declare readonly annotations?: SqlAnnotations;\n /** See {@link SqlUniqueIRInput.dependsOn}. Non-enumerable so it stays out of JSON and structural equality, matching `SqlColumnIR.codecRef`. */\n declare readonly dependsOn?: readonly SchemaNodeRef[];\n\n constructor(input: SqlUniqueIRInput) {\n super();\n this.columns = [...input.columns];\n if (input.name !== undefined) this.name = input.name;\n if (input.annotations !== undefined) this.annotations = input.annotations;\n defineNonEnumerable(this, 'dependsOn', input.dependsOn);\n freezeNode(this);\n }\n\n get id(): string {\n return `unique:${this.columns.join(',')}`;\n }\n\n children(): readonly DiffableNode[] {\n return [];\n }\n\n static is(node: SqlSchemaIRNode): node is SqlUniqueIR {\n return node.nodeKind === RelationalSchemaNodeKind.unique;\n }\n\n isEqualTo(other: DiffableNode): boolean {\n const node = blindCast<\n SqlSchemaIRNode,\n 'every diff-tree node the differ pairs is a SqlSchemaIRNode'\n >(other);\n assertNode(node, 'SqlUniqueIR', SqlUniqueIR.is);\n return this.id === node.id;\n }\n}\n","import type { DiffableNode } from '@prisma-next/framework-components/control';\nimport { freezeNode } from '@prisma-next/framework-components/ir';\nimport { PrimaryKey, type PrimaryKeyInput } from './primary-key';\nimport { RelationalSchemaNodeKind } from './schema-node-kinds';\nimport { SqlCheckConstraintIR, type SqlCheckConstraintIRInput } from './sql-check-constraint-ir';\nimport { type SqlAnnotations, SqlColumnIR, type SqlColumnIRInput } from './sql-column-ir';\nimport { SqlForeignKeyIR, type SqlForeignKeyIRInput } from './sql-foreign-key-ir';\nimport { SqlIndexIR, type SqlIndexIRInput } from './sql-index-ir';\nimport { SqlSchemaIRNode } from './sql-schema-ir-node';\nimport { SqlUniqueIR, type SqlUniqueIRInput } from './sql-unique-ir';\n\nexport interface SqlTableIRInput {\n readonly name: string;\n readonly columns: Record<string, SqlColumnIR | SqlColumnIRInput>;\n readonly foreignKeys: ReadonlyArray<SqlForeignKeyIR | SqlForeignKeyIRInput>;\n readonly uniques: ReadonlyArray<SqlUniqueIR | SqlUniqueIRInput>;\n readonly indexes: ReadonlyArray<SqlIndexIR | SqlIndexIRInput>;\n readonly primaryKey?: PrimaryKey | PrimaryKeyInput;\n readonly annotations?: SqlAnnotations;\n /** Optional check constraints for enum-restricted columns. Omitted when none present. */\n readonly checks?: ReadonlyArray<SqlCheckConstraintIR | SqlCheckConstraintIRInput>;\n}\n\n/**\n * Schema IR node for a single table as observed by introspection.\n *\n * Unlike the Contract IR `StorageTable`, this carries the table's\n * `name` — introspection queries return tables as arrays and the\n * verifier keys them into `SqlSchemaIR.tables` afterwards, so the name\n * stays on the table object for downstream call sites that walk\n * `Object.values(schema.tables)`.\n *\n * The constructor normalises nested IR-class fields so downstream\n * walks see a uniform AST regardless of whether the input was a\n * plain-data literal (from introspection) or already-constructed\n * class instances.\n *\n * Implements `DiffableNode` so a flat (single-schema) tree is directly\n * diffable: `id` is the table name; `isEqualTo` is identity (the table's\n * structural drift is entirely expressed by its children); `children()`\n * yields every column, the primary key (when present), every foreign key,\n * unique, index, and check constraint — the same composition and order as\n * the Postgres table node, minus policies.\n */\nexport class SqlTableIR extends SqlSchemaIRNode implements DiffableNode {\n override readonly nodeKind = RelationalSchemaNodeKind.table;\n\n readonly name: string;\n readonly columns: Readonly<Record<string, SqlColumnIR>>;\n readonly foreignKeys: ReadonlyArray<SqlForeignKeyIR>;\n readonly uniques: ReadonlyArray<SqlUniqueIR>;\n readonly indexes: ReadonlyArray<SqlIndexIR>;\n declare readonly primaryKey?: PrimaryKey;\n declare readonly annotations?: SqlAnnotations;\n declare readonly checks?: ReadonlyArray<SqlCheckConstraintIR>;\n\n constructor(input: SqlTableIRInput) {\n super();\n this.name = input.name;\n this.columns = Object.freeze(\n Object.fromEntries(\n Object.entries(input.columns).map(([key, col]) => [\n key,\n col instanceof SqlColumnIR ? col : new SqlColumnIR(col),\n ]),\n ),\n );\n this.foreignKeys = Object.freeze(\n input.foreignKeys.map((fk) => (fk instanceof SqlForeignKeyIR ? fk : new SqlForeignKeyIR(fk))),\n );\n this.uniques = Object.freeze(\n input.uniques.map((u) => (u instanceof SqlUniqueIR ? u : new SqlUniqueIR(u))),\n );\n this.indexes = Object.freeze(\n input.indexes.map((i) => (i instanceof SqlIndexIR ? i : new SqlIndexIR(i))),\n );\n if (input.primaryKey !== undefined) {\n this.primaryKey =\n input.primaryKey instanceof PrimaryKey\n ? input.primaryKey\n : new PrimaryKey(input.primaryKey);\n }\n if (input.annotations !== undefined) this.annotations = input.annotations;\n if (input.checks !== undefined && input.checks.length > 0) {\n this.checks = Object.freeze(\n input.checks.map((c) =>\n c instanceof SqlCheckConstraintIR ? c : new SqlCheckConstraintIR(c),\n ),\n );\n }\n freezeNode(this);\n }\n\n get id(): string {\n return this.name;\n }\n\n isEqualTo(other: DiffableNode): boolean {\n return this.id === other.id;\n }\n\n children(): readonly DiffableNode[] {\n return [\n ...Object.values(this.columns),\n ...(this.primaryKey ? [this.primaryKey] : []),\n ...this.foreignKeys,\n ...this.uniques,\n ...this.indexes,\n ...(this.checks ?? []),\n ];\n }\n}\n","import type { DiffableNode } from '@prisma-next/framework-components/control';\nimport { freezeNode } from '@prisma-next/framework-components/ir';\nimport { RelationalSchemaNodeKind } from './schema-node-kinds';\nimport type { SqlAnnotations } from './sql-column-ir';\nimport { SqlSchemaIRNode } from './sql-schema-ir-node';\nimport { SqlTableIR, type SqlTableIRInput } from './sql-table-ir';\n\nexport interface SqlSchemaIRInput {\n readonly tables: Record<string, SqlTableIR | SqlTableIRInput>;\n readonly annotations?: SqlAnnotations;\n}\n\n/**\n * Root Schema IR node representing the complete database schema as\n * observed by introspection. Target-agnostic; used by both verifiers\n * (compare against intended Contract storage) and migration planners\n * (derive operations needed to reconcile).\n *\n * The constructor normalises nested `SqlTableIR` instances so\n * downstream walks see a uniform AST regardless of whether the input\n * was a plain-data literal or already-constructed class instances.\n *\n * Implements `DiffableNode` as the root of a flat (single-schema) diff\n * tree: `id` is the fixed sentinel `'database'` (roots have no siblings),\n * `isEqualTo` is identity (a container has no own attributes), and\n * `children()` yields the table nodes.\n */\nexport class SqlSchemaIR extends SqlSchemaIRNode implements DiffableNode {\n override readonly nodeKind = RelationalSchemaNodeKind.schema;\n\n readonly tables: Readonly<Record<string, SqlTableIR>>;\n declare readonly annotations?: SqlAnnotations;\n\n constructor(input: SqlSchemaIRInput) {\n super();\n this.tables = Object.freeze(\n Object.fromEntries(\n Object.entries(input.tables).map(([key, t]) => [\n key,\n t instanceof SqlTableIR ? t : new SqlTableIR(t),\n ]),\n ),\n );\n if (input.annotations !== undefined) this.annotations = input.annotations;\n freezeNode(this);\n }\n\n get id(): string {\n return 'database';\n }\n\n isEqualTo(other: DiffableNode): boolean {\n return this.id === other.id;\n }\n\n children(): readonly DiffableNode[] {\n return Object.values(this.tables);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;AAUA,MAAa,2BAA2B;CACtC,QAAQ;CACR,OAAO;CACP,QAAQ;CACR,eAAe;CACf,YAAY;CACZ,YAAY;CACZ,QAAQ;CACR,OAAO;CACP,OAAO;AACT;;;;;;;;;;;AAeA,MAAM,8BAEF;EACD,yBAAyB,SAAS;EAClC,yBAAyB,QAAQ;EACjC,yBAAyB,SAAS;EAClC,yBAAyB,gBAAgB;EACzC,yBAAyB,aAAa;EACtC,yBAAyB,aAAa;EACtC,yBAAyB,SAAS;EAClC,yBAAyB,QAAQ;EACjC,yBAAyB,QAAQ;AACpC;AAEA,SAAS,2BAA2B,UAAwD;CAC1F,OAAO,OAAO,OAAO,6BAA6B,QAAQ;AAC5D;;;;;;;AAQA,SAAgB,0BAA0B,UAA0C;CAClF,IAAI,CAAC,2BAA2B,QAAQ,GACtC,MAAM,IAAI,cAC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;;;;;;;;;;;;;;;;;;ACpFA,IAAa,cAAb,cAAiC,gBAAwC;CACvE,WAA6B,yBAAyB;CAEtD;CAGA,YAAY,OAAyB;EACnC,MAAM;EACN,KAAK,SAAS,OAAO,OACnB,OAAO,YACL,OAAO,QAAQ,MAAM,MAAM,CAAC,CAAC,KAAK,CAAC,KAAK,OAAO,CAC7C,KACA,aAAa,aAAa,IAAI,IAAI,WAAW,CAAC,CAChD,CAAC,CACH,CACF;EACA,IAAI,MAAM,gBAAgB,KAAA,GAAW,KAAK,cAAc,MAAM;EAC9D,WAAW,IAAI;CACjB;CAEA,IAAI,KAAa;EACf,OAAO;CACT;CAEA,UAAU,OAA8B;EACtC,OAAO,KAAK,OAAO,MAAM;CAC3B;CAEA,WAAoC;EAClC,OAAO,OAAO,OAAO,KAAK,MAAM;CAClC;AACF"}
|
|
@@ -433,8 +433,9 @@ type SqlIndexElements = {
|
|
|
433
433
|
};
|
|
434
434
|
/**
|
|
435
435
|
* Every non-element field is a required key. Values that may legitimately
|
|
436
|
-
* be absent (an exact-named index's prefix,
|
|
437
|
-
* typed `| undefined` instead of optional, so each
|
|
436
|
+
* be absent (an exact-named index's prefix, the btree→undefined type
|
|
437
|
+
* normalization) are typed `| undefined` instead of optional, so each
|
|
438
|
+
* construction site
|
|
438
439
|
* states the absence explicitly rather than omitting the key silently.
|
|
439
440
|
* Undefined values still produce an instance without the property.
|
|
440
441
|
*/
|
|
@@ -698,4 +699,4 @@ interface SqlTypeMetadataRegistry {
|
|
|
698
699
|
}
|
|
699
700
|
//#endregion
|
|
700
701
|
export { relationalNodeGranularity as C, assertNode as D, SqlSchemaIRNode as E, defineNonEnumerable as O, relationalNodeEntityKind as S, PrimaryKeyInput as T, SqlColumnDefaultIR as _, SqlTableIR as a, SqlCheckConstraintIRInput as b, SqlUniqueIRInput as c, SqlForeignKeyIR as d, SqlForeignKeyIRInput as f, SqlColumnIRInput as g, SqlColumnIR as h, SqlSchemaIRInput as i, SqlIndexIR as l, SqlAnnotations as m, SqlTypeMetadataRegistry as n, SqlTableIRInput as o, SqlReferentialAction as p, SqlSchemaIR as r, SqlUniqueIR as s, SqlTypeMetadata as t, SqlIndexIRInput as u, SqlColumnDefaultIRInput as v, PrimaryKey as w, RelationalSchemaNodeKind as x, SqlCheckConstraintIR as y };
|
|
701
|
-
//# sourceMappingURL=types-
|
|
702
|
+
//# sourceMappingURL=types-Cnl67qhJ.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types-Cnl67qhJ.d.mts","names":[],"sources":["../src/ir/sql-schema-ir-node.ts","../src/ir/primary-key.ts","../src/ir/schema-node-kinds.ts","../src/ir/sql-check-constraint-ir.ts","../src/ir/sql-column-default-ir.ts","../src/ir/sql-column-ir.ts","../src/ir/sql-foreign-key-ir.ts","../src/ir/sql-index-ir.ts","../src/ir/sql-unique-ir.ts","../src/ir/sql-table-ir.ts","../src/ir/sql-schema-ir.ts","../src/types.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;uBAwBsB,wBAAwB;WAC3B;;;;;;;;;oBAUC;;;;;;;;;iBAmBJ,WAAW,UAAU,iBACnC,MAAM,6BACN,mBACA,YAAY,MAAM,oBAAoB,QAAQ,YACrC,QAAQ;;;;;;;;;;iBAiBH,oBAAoB,kBAClC,QAAQ,GACR,aACA;;;UCxEe;WACN;WACA;;;;;;WAMA,qBAAqB;;;;;;;;;;;;;;;cAgBnB,mBAAmB,2BAA2B;WACvC;WAET;WACQ;;WAEA,qBAAqB;cAE1B,OAAO;MAQf;EAIJ,qBAAqB;SAId,GAAG,MAAM,kBAAkB,QAAQ;EAI1C,UAAU,OAAO;;;;;;;;;;;cChDN;;;;;;;;;;;KAYD,mCACF,uCAAuC;;;;;;;iBAoCjC,0BAA0B,mBAAmB;;;;;;;;iBA2B7C,yBAAyB;;;UChFxB;;WAEN;;WAEA;;WAEA;;;;;;;;;;;;;;cAeE,6BAA6B,2BAA2B;WACjD;WAET;WACA;WACA;cAEG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
|
{
|
|
2
2
|
"name": "@prisma-next/sql-schema-ir",
|
|
3
|
-
"version": "0.16.0-dev.
|
|
3
|
+
"version": "0.16.0-dev.32",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
7
7
|
"description": "SQL Schema IR types for schema introspection and verification",
|
|
8
8
|
"dependencies": {
|
|
9
|
-
"@prisma-next/contract": "0.16.0-dev.
|
|
10
|
-
"@prisma-next/framework-components": "0.16.0-dev.
|
|
11
|
-
"@prisma-next/utils": "0.16.0-dev.
|
|
9
|
+
"@prisma-next/contract": "0.16.0-dev.32",
|
|
10
|
+
"@prisma-next/framework-components": "0.16.0-dev.32",
|
|
11
|
+
"@prisma-next/utils": "0.16.0-dev.32"
|
|
12
12
|
},
|
|
13
13
|
"devDependencies": {
|
|
14
|
-
"@prisma-next/test-utils": "0.16.0-dev.
|
|
15
|
-
"@prisma-next/tsconfig": "0.16.0-dev.
|
|
16
|
-
"@prisma-next/tsdown": "0.16.0-dev.
|
|
14
|
+
"@prisma-next/test-utils": "0.16.0-dev.32",
|
|
15
|
+
"@prisma-next/tsconfig": "0.16.0-dev.32",
|
|
16
|
+
"@prisma-next/tsdown": "0.16.0-dev.32",
|
|
17
17
|
"tsdown": "0.22.8",
|
|
18
18
|
"typescript": "5.9.3",
|
|
19
19
|
"vitest": "4.1.10"
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { DiffSubjectGranularity } from '@prisma-next/framework-components/control';
|
|
2
|
+
import { InternalError } from '@prisma-next/utils/internal-error';
|
|
2
3
|
|
|
3
4
|
/**
|
|
4
5
|
* The `nodeKind` discriminant for each relational schema-diff leaf node.
|
|
@@ -58,7 +59,9 @@ function isRelationalSchemaNodeKind(nodeKind: string): nodeKind is RelationalSch
|
|
|
58
59
|
*/
|
|
59
60
|
export function relationalNodeGranularity(nodeKind: string): DiffSubjectGranularity {
|
|
60
61
|
if (!isRelationalSchemaNodeKind(nodeKind)) {
|
|
61
|
-
throw new
|
|
62
|
+
throw new InternalError(
|
|
63
|
+
`relationalNodeGranularity: unrecognized relational node kind "${nodeKind}"`,
|
|
64
|
+
);
|
|
62
65
|
}
|
|
63
66
|
return RELATIONAL_NODE_GRANULARITY[nodeKind];
|
|
64
67
|
}
|
package/src/ir/sql-index-ir.ts
CHANGED
|
@@ -32,8 +32,9 @@ export type SqlIndexElements =
|
|
|
32
32
|
|
|
33
33
|
/**
|
|
34
34
|
* Every non-element field is a required key. Values that may legitimately
|
|
35
|
-
* be absent (an exact-named index's prefix,
|
|
36
|
-
* typed `| undefined` instead of optional, so each
|
|
35
|
+
* be absent (an exact-named index's prefix, the btree→undefined type
|
|
36
|
+
* normalization) are typed `| undefined` instead of optional, so each
|
|
37
|
+
* construction site
|
|
37
38
|
* states the absence explicitly rather than omitting the key silently.
|
|
38
39
|
* Undefined values still produce an instance without the property.
|
|
39
40
|
*/
|
|
@@ -132,7 +133,8 @@ export class SqlIndexIR extends SqlSchemaIRNode implements DiffableNode {
|
|
|
132
133
|
if (input.columns !== undefined) this.columns = input.columns;
|
|
133
134
|
if (input.expression !== undefined) this.expression = input.expression;
|
|
134
135
|
if (input.where !== undefined) this.where = input.where;
|
|
135
|
-
|
|
136
|
+
const normalizedType = normalizeIndexType(input.type);
|
|
137
|
+
if (normalizedType !== undefined) this.type = normalizedType;
|
|
136
138
|
if (input.options !== undefined) this.options = input.options;
|
|
137
139
|
if (input.annotations !== undefined) this.annotations = input.annotations;
|
|
138
140
|
defineNonEnumerable(this, 'dependsOn', input.dependsOn);
|
|
@@ -221,12 +223,17 @@ export class SqlIndexIR extends SqlSchemaIRNode implements DiffableNode {
|
|
|
221
223
|
}
|
|
222
224
|
|
|
223
225
|
/**
|
|
224
|
-
*
|
|
225
|
-
* every supported SQL target)
|
|
226
|
-
*
|
|
227
|
-
*
|
|
228
|
-
*
|
|
229
|
-
*
|
|
226
|
+
* The btree-default normalization seam: the default access method (`btree`
|
|
227
|
+
* in every supported SQL target) normalizes to absent. Applied at
|
|
228
|
+
* construction — every derivation path (contract tree, introspection, flat
|
|
229
|
+
* family tree) builds through the class, so both compare sides are
|
|
230
|
+
* symmetric by definition — and again inside
|
|
231
|
+
* {@link SqlIndexIR.contentEquals} so the relation holds for any input.
|
|
232
|
+
* The contract JSON and the wire-name content hash keep the authored
|
|
233
|
+
* spelling: `@@index([a], type: "btree")` and `@@index([a])` are distinct
|
|
234
|
+
* wire names — but content-equal after normalization, so a spelling change
|
|
235
|
+
* between them converges as a rename via the planner's phase-2 content
|
|
236
|
+
* pairing (the hashes differ, so phase-1 never pairs them).
|
|
230
237
|
*/
|
|
231
238
|
function normalizeIndexType(type: string | undefined): string | undefined {
|
|
232
239
|
return type === 'btree' ? undefined : type;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { IRNodeBase } from '@prisma-next/framework-components/ir';
|
|
2
|
+
import { InternalError } from '@prisma-next/utils/internal-error';
|
|
2
3
|
|
|
3
4
|
/**
|
|
4
5
|
* SQL Schema IR node base. Carries the family-level
|
|
@@ -57,7 +58,9 @@ export function assertNode<T extends SqlSchemaIRNode>(
|
|
|
57
58
|
predicate: (node: SqlSchemaIRNode) => node is T,
|
|
58
59
|
): asserts node is T {
|
|
59
60
|
if (node === undefined || !predicate(node)) {
|
|
60
|
-
throw new
|
|
61
|
+
throw new InternalError(
|
|
62
|
+
`Expected a ${className} but got nodeKind=${node?.nodeKind ?? 'undefined'}`,
|
|
63
|
+
);
|
|
61
64
|
}
|
|
62
65
|
}
|
|
63
66
|
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types-Btj35AIt.mjs","names":[],"sources":["../src/ir/schema-node-kinds.ts","../src/ir/sql-schema-ir-node.ts","../src/ir/primary-key.ts","../src/ir/sql-check-constraint-ir.ts","../src/ir/resolved-default-equality.ts","../src/ir/sql-column-default-ir.ts","../src/ir/sql-column-ir.ts","../src/ir/sql-foreign-key-ir.ts","../src/ir/sql-index-ir.ts","../src/ir/sql-unique-ir.ts","../src/ir/sql-table-ir.ts","../src/ir/sql-schema-ir.ts"],"sourcesContent":["import type { DiffSubjectGranularity } from '@prisma-next/framework-components/control';\n\n/**\n * The `nodeKind` discriminant for each relational schema-diff leaf node.\n * Each node carries a unique value; the differ pairs siblings by `id`, and\n * these kinds distinguish the node types that appear as `PostgresTableSchemaNode`\n * children (columns, primary key, foreign keys, uniques, indexes, checks) from\n * each other and from the RLS policy/role kinds a target defines separately.\n */\nexport const RelationalSchemaNodeKind = {\n schema: 'sql-schema',\n table: 'sql-table',\n column: 'sql-column',\n columnDefault: 'sql-column-default',\n primaryKey: 'sql-primary-key',\n foreignKey: 'sql-foreign-key',\n unique: 'sql-unique',\n index: 'sql-index',\n check: 'sql-check-constraint',\n} as const;\n\nexport type RelationalSchemaNodeKind =\n (typeof RelationalSchemaNodeKind)[keyof typeof RelationalSchemaNodeKind];\n\n/**\n * The one real map from a relational `nodeKind` to the framework-neutral\n * {@link DiffSubjectGranularity} its diff issues carry — the SQL family's\n * post-diff filters (issue category, strict-mode gating) and the framework\n * aggregate's unclaimed-elements sweep key on the granularity, never on the\n * `nodeKind` spelling and never on anything stamped on the node. Resolution\n * is by `nodeKind` equality against this map, not a suffix string match.\n * Target-specific node kinds (Postgres namespace/table/policy/role) are\n * outside this family layer's vocabulary and map their own kinds directly.\n */\nconst RELATIONAL_NODE_GRANULARITY: Readonly<\n Record<RelationalSchemaNodeKind, DiffSubjectGranularity>\n> = {\n [RelationalSchemaNodeKind.schema]: 'structural',\n [RelationalSchemaNodeKind.table]: 'entity',\n [RelationalSchemaNodeKind.column]: 'field',\n [RelationalSchemaNodeKind.columnDefault]: 'auxiliary',\n [RelationalSchemaNodeKind.primaryKey]: 'auxiliary',\n [RelationalSchemaNodeKind.foreignKey]: 'auxiliary',\n [RelationalSchemaNodeKind.unique]: 'auxiliary',\n [RelationalSchemaNodeKind.index]: 'auxiliary',\n [RelationalSchemaNodeKind.check]: 'auxiliary',\n};\n\nfunction isRelationalSchemaNodeKind(nodeKind: string): nodeKind is RelationalSchemaNodeKind {\n return Object.hasOwn(RELATIONAL_NODE_GRANULARITY, nodeKind);\n}\n\n/**\n * Looks up the subject granularity for a relational `nodeKind`. Throws for a\n * `nodeKind` outside this map (a target-specific kind, e.g. Postgres's\n * namespace/table/policy/role) — those map their own kinds directly rather\n * than through this family-level map.\n */\nexport function relationalNodeGranularity(nodeKind: string): DiffSubjectGranularity {\n if (!isRelationalSchemaNodeKind(nodeKind)) {\n throw new Error(`relationalNodeGranularity: unrecognized relational node kind \"${nodeKind}\"`);\n }\n return RELATIONAL_NODE_GRANULARITY[nodeKind];\n}\n\n/**\n * The one real map from a relational `nodeKind` to its storage `entityKind`\n * — the same vocabulary the contract storage's `entries` dictionary keys use\n * (`elementCoordinates` walks it). Only the whole-table kind has an entity of\n * its own; every other relational node (a column, an index, …) is nested\n * under one and maps to nothing here.\n */\nconst RELATIONAL_NODE_ENTITY_KIND: Partial<Readonly<Record<RelationalSchemaNodeKind, string>>> = {\n [RelationalSchemaNodeKind.table]: 'table',\n};\n\n/**\n * Looks up the storage `entityKind` for a relational `nodeKind` — sibling of\n * {@link relationalNodeGranularity}, resolved by `nodeKind` equality against\n * {@link RELATIONAL_NODE_ENTITY_KIND}. `undefined` for a target-specific kind\n * (targets map their own kinds directly) or a relational kind with no entity\n * of its own.\n */\nexport function relationalNodeEntityKind(nodeKind: string): string | undefined {\n return isRelationalSchemaNodeKind(nodeKind) ? RELATIONAL_NODE_ENTITY_KIND[nodeKind] : undefined;\n}\n","import { IRNodeBase } from '@prisma-next/framework-components/ir';\n\n/**\n * SQL Schema IR node base. Carries the family-level\n * `kind = 'sql-schema-ir'` discriminator and inherits the framework's\n * `freezeNode` affordance.\n *\n * SQL Schema IR represents the actual database state as discovered by\n * introspection (the parallel to SQL Contract IR, which represents the\n * desired state).\n *\n * The discriminator is installed as a non-enumerable own property,\n * matching the SqlNode pattern. This keeps `JSON.stringify(node)`\n * canonical (no `kind` field), keeps `toEqual({...})` test assertions\n * against pre-lift flat shapes passing, and keeps `node.kind` readable\n * for dispatch.\n *\n * Both `kind` and `nodeKind` are required: every concrete leaf is a node\n * the generic differ can pair and compare, so every leaf must declare which\n * node it is. `nodeKind` has no default here — every direct subclass sets its\n * own literal value (the relational leaves via `RelationalSchemaNodeKind`,\n * target concretions via their own vocabulary, e.g. `PostgresSchemaNodeKind`).\n */\nexport abstract class SqlSchemaIRNode extends IRNodeBase {\n declare readonly kind: string;\n\n /**\n * Enumerable discriminant identifying which node this is (column / primary\n * key / foreign key / unique / index / check / database / namespace /\n * table / policy / role / …). Concretions set a unique value; the\n * `.is`/`.assert` guards compare against it. Unlike `kind`, it is\n * enumerable, so it survives a spread that flattens a node into a plain\n * object.\n */\n abstract readonly nodeKind: string;\n\n constructor() {\n super();\n Object.defineProperty(this, 'kind', {\n value: 'sql-schema-ir',\n writable: false,\n enumerable: false,\n configurable: false,\n });\n }\n}\n\n/**\n * Asserts `node` matches `predicate`, narrowing its type to `T`. The one\n * shared implementation every node class's `static assert` and `isEqualTo`\n * reach for, instead of each hand-writing its own throw: the message names\n * the class the caller expected.\n */\nexport function assertNode<T extends SqlSchemaIRNode>(\n node: SqlSchemaIRNode | undefined,\n className: string,\n predicate: (node: SqlSchemaIRNode) => node is T,\n): asserts node is T {\n if (node === undefined || !predicate(node)) {\n throw new Error(`Expected a ${className} but got nodeKind=${node?.nodeKind ?? 'undefined'}`);\n }\n}\n\n/**\n * Defines a non-enumerable own property, the same treatment `kind` gets\n * above: a derivation-time render-support field stays out of\n * `JSON.stringify`, `toEqual({...})` structural assertions, and spreads,\n * while remaining directly readable (`node.field`) for the one consumer\n * that resolves it at plan time. A no-op when `value` is `undefined` — the\n * property is simply absent, matching every other optional field on these\n * nodes.\n */\nexport function defineNonEnumerable<T extends object>(\n target: T,\n key: string,\n value: unknown,\n): void {\n if (value === undefined) return;\n Object.defineProperty(target, key, {\n value,\n enumerable: false,\n writable: false,\n configurable: false,\n });\n}\n","import type { DiffableNode, SchemaNodeRef } from '@prisma-next/framework-components/control';\nimport { freezeNode } from '@prisma-next/framework-components/ir';\nimport { blindCast } from '@prisma-next/utils/casts';\nimport { RelationalSchemaNodeKind } from './schema-node-kinds';\nimport { assertNode, defineNonEnumerable, SqlSchemaIRNode } from './sql-schema-ir-node';\n\nexport interface PrimaryKeyInput {\n readonly columns: readonly string[];\n readonly name?: string;\n /**\n * The key's own column nodes, as root-anchored chains. The derivation\n * stamps them so the primary key is dropped before the columns it is built\n * on. Never compared by `isEqualTo`.\n */\n readonly dependsOn?: readonly SchemaNodeRef[];\n}\n\n/**\n * Primary-key Schema IR node. Mirrors the Contract IR `PrimaryKey`\n * shape (same `columns` + optional `name`) so verification can compare\n * intent and actual structurally. Defined here independently to avoid\n * a sql-schema-ir -> sql-contract dependency.\n *\n * Implements `DiffableNode` so a primary key is directly a table's diff-tree\n * child. `id` is a fixed sentinel — a table has at most one primary key, so\n * there is never a sibling to disambiguate against. `isEqualTo` compares the\n * column tuple; the PK's own `name` is a database-assigned label with no\n * semantic weight, so it is not compared (mirrors the policy node's\n * name-insensitivity to non-identifying detail).\n */\nexport class PrimaryKey extends SqlSchemaIRNode implements DiffableNode {\n override readonly nodeKind = RelationalSchemaNodeKind.primaryKey;\n\n readonly columns: readonly string[];\n declare readonly name?: string;\n /** See {@link PrimaryKeyInput.dependsOn}. Non-enumerable so it stays out of JSON and structural equality, matching `SqlColumnIR.codecRef`. */\n declare readonly dependsOn?: readonly SchemaNodeRef[];\n\n constructor(input: PrimaryKeyInput) {\n super();\n this.columns = input.columns;\n if (input.name !== undefined) this.name = input.name;\n defineNonEnumerable(this, 'dependsOn', input.dependsOn);\n freezeNode(this);\n }\n\n get id(): string {\n return 'primary-key';\n }\n\n children(): readonly DiffableNode[] {\n return [];\n }\n\n static is(node: SqlSchemaIRNode): node is PrimaryKey {\n return node.nodeKind === RelationalSchemaNodeKind.primaryKey;\n }\n\n isEqualTo(other: DiffableNode): boolean {\n const node = blindCast<\n SqlSchemaIRNode,\n 'every diff-tree node the differ pairs is a SqlSchemaIRNode'\n >(other);\n assertNode(node, 'PrimaryKey', PrimaryKey.is);\n return (\n this.columns.length === node.columns.length &&\n this.columns.every((c, i) => c === node.columns[i])\n );\n }\n}\n","import type { DiffableNode } from '@prisma-next/framework-components/control';\nimport { freezeNode } from '@prisma-next/framework-components/ir';\nimport { blindCast } from '@prisma-next/utils/casts';\nimport { RelationalSchemaNodeKind } from './schema-node-kinds';\nimport { assertNode, SqlSchemaIRNode } from './sql-schema-ir-node';\n\nexport interface SqlCheckConstraintIRInput {\n /** Constraint name as stored in the database catalog. */\n readonly name: string;\n /** Column the check restricts. */\n readonly column: string;\n /** Permitted values the column must be IN. */\n readonly permittedValues: readonly string[];\n}\n\n/**\n * Schema IR node for a table-level check constraint that restricts a\n * column to a set of permitted values (an enum-style `IN (...)` check).\n *\n * Carries the **resolved values** rather than a raw SQL predicate so\n * callers can compare value-sets without parsing SQL.\n *\n * Implements `DiffableNode` so a check constraint is directly a table's\n * diff-tree child: `id` is the constraint name. `isEqualTo` compares\n * `column` and the permitted-value set (order-insensitive — the database\n * does not guarantee `IN (...)` ordering).\n */\nexport class SqlCheckConstraintIR extends SqlSchemaIRNode implements DiffableNode {\n override readonly nodeKind = RelationalSchemaNodeKind.check;\n\n readonly name: string;\n readonly column: string;\n readonly permittedValues: readonly string[];\n\n constructor(input: SqlCheckConstraintIRInput) {\n super();\n this.name = input.name;\n this.column = input.column;\n this.permittedValues = Object.freeze([...input.permittedValues]);\n freezeNode(this);\n }\n\n get id(): string {\n return `check:${this.name}`;\n }\n\n children(): readonly DiffableNode[] {\n return [];\n }\n\n static is(node: SqlSchemaIRNode): node is SqlCheckConstraintIR {\n return node.nodeKind === RelationalSchemaNodeKind.check;\n }\n\n /**\n * Compares the permitted-value sets only (unordered), matching the\n * relational walk's `verifyCheckConstraints`: two checks pairing by name\n * compare their value sets — the `column` field is descriptive, not part\n * of the comparison, so a name-paired check with equal values verifies\n * regardless of which column carries it.\n */\n isEqualTo(other: DiffableNode): boolean {\n const node = blindCast<\n SqlSchemaIRNode,\n 'every diff-tree node the differ pairs is a SqlSchemaIRNode'\n >(other);\n assertNode(node, 'SqlCheckConstraintIR', SqlCheckConstraintIR.is);\n const thisValues = new Set(this.permittedValues);\n const otherValues = new Set(node.permittedValues);\n if (thisValues.size !== otherValues.size) return false;\n return [...thisValues].every((v) => otherValues.has(v));\n }\n}\n","import type { ColumnDefault } from '@prisma-next/contract/types';\nimport { canonicalStringify } from '@prisma-next/utils/canonical-stringify';\n\n/**\n * Structural equality for two resolved column defaults, ported from the\n * relational walk's `columnDefaultsEqual` normalized branch: kinds must\n * match; literal values are normalized (Date and temporal-typed strings to\n * ISO instants) then compared canonically (JSON objects match their\n * canonical string form); function expressions compare case- and\n * whitespace-insensitively.\n *\n * `nativeType` provides the temporal-normalization context (the actual\n * side's resolved native type in a diff comparison).\n */\nexport function resolvedDefaultsEqual(\n expected: ColumnDefault,\n actual: ColumnDefault,\n nativeType?: string,\n): boolean {\n if (expected.kind !== actual.kind) return false;\n if (expected.kind === 'literal' && actual.kind === 'literal') {\n return literalValuesEqual(\n normalizeLiteralValue(expected.value, nativeType),\n normalizeLiteralValue(actual.value, nativeType),\n );\n }\n if (expected.kind === 'function' && actual.kind === 'function') {\n return (\n normalizeFunctionExpression(expected.expression) ===\n normalizeFunctionExpression(actual.expression)\n );\n }\n return false;\n}\n\nfunction normalizeFunctionExpression(expression: string): string {\n return expression.toLowerCase().replace(/\\s+/g, '');\n}\n\nfunction isTemporalNativeType(nativeType?: string): boolean {\n if (!nativeType) return false;\n const normalized = nativeType.toLowerCase();\n return normalized.includes('timestamp') || normalized === 'date';\n}\n\nfunction normalizeLiteralValue(value: unknown, nativeType?: string): unknown {\n if (value instanceof Date) {\n return value.toISOString();\n }\n if (typeof value === 'string' && isTemporalNativeType(nativeType)) {\n const parsed = new Date(value);\n if (!Number.isNaN(parsed.getTime())) {\n return parsed.toISOString();\n }\n }\n return value;\n}\n\nfunction literalValuesEqual(a: unknown, b: unknown): boolean {\n if (a === b) return true;\n if (typeof a === 'object' && a !== null && typeof b === 'object' && b !== null) {\n return canonicalStringify(a) === canonicalStringify(b);\n }\n if (typeof a === 'object' && a !== null && typeof b === 'string') {\n try {\n return canonicalStringify(a) === canonicalStringify(JSON.parse(b));\n } catch {\n return false;\n }\n }\n if (typeof a === 'string' && typeof b === 'object' && b !== null) {\n try {\n return canonicalStringify(JSON.parse(a)) === canonicalStringify(b);\n } catch {\n return false;\n }\n }\n return false;\n}\n","import type { ColumnDefault } from '@prisma-next/contract/types';\nimport type { DiffableNode } from '@prisma-next/framework-components/control';\nimport { freezeNode } from '@prisma-next/framework-components/ir';\nimport { blindCast } from '@prisma-next/utils/casts';\nimport { resolvedDefaultsEqual } from './resolved-default-equality';\nimport { RelationalSchemaNodeKind } from './schema-node-kinds';\nimport { assertNode, defineNonEnumerable, SqlSchemaIRNode } from './sql-schema-ir-node';\n\nexport interface SqlColumnDefaultIRInput {\n /** Structured resolved default (contract-declared or normalizer-parsed). */\n readonly resolved?: ColumnDefault;\n /** Raw database default expression, when known (introspected side). */\n readonly raw?: string;\n /**\n * Native-type context for temporal literal normalization — the owning\n * column's resolved native type.\n */\n readonly nativeTypeContext?: string;\n /**\n * The owning column's array-ness, threaded through so the planner's\n * set-default op-builder can render an array-literal default (e.g.\n * `ARRAY[...]`) the same way the pre-`plan(start, end)` op-path did. See\n * {@link import('./sql-column-ir').SqlColumnIRInput.many}.\n */\n readonly many?: boolean;\n}\n\n/**\n * Schema-diff node for a column's default value. The default is the one\n * column attribute with an extra/missing/drift lifecycle of its own, so it\n * is a child node of the column rather than a compared attribute: an\n * undeclared live default surfaces as `not-expected`, a declared default the\n * database lacks as `not-found`, and a divergent value as `not-equal` — the\n * three reasons cover the legacy `extra_default` / `default_missing` /\n * `default_mismatch` vocabulary with no attribute inspection.\n *\n * `id` is a fixed sentinel — a column has at most one default. Built\n * transiently by `SqlColumnIR.children()` from the column's own fields;\n * never constructed by derivation or introspection directly.\n */\nexport class SqlColumnDefaultIR extends SqlSchemaIRNode implements DiffableNode {\n override readonly nodeKind = RelationalSchemaNodeKind.columnDefault;\n\n declare readonly resolved?: ColumnDefault;\n declare readonly raw?: string;\n declare readonly nativeTypeContext?: string;\n /** See {@link SqlColumnDefaultIRInput.many}. Non-enumerable so it stays out of JSON and structural equality. */\n declare readonly many?: boolean;\n\n constructor(input: SqlColumnDefaultIRInput) {\n super();\n if (input.resolved !== undefined) this.resolved = input.resolved;\n if (input.raw !== undefined) this.raw = input.raw;\n if (input.nativeTypeContext !== undefined) this.nativeTypeContext = input.nativeTypeContext;\n defineNonEnumerable(this, 'many', input.many);\n freezeNode(this);\n }\n\n get id(): string {\n return 'default';\n }\n\n children(): readonly DiffableNode[] {\n return [];\n }\n\n static is(node: SqlSchemaIRNode): node is SqlColumnDefaultIR {\n return node.nodeKind === RelationalSchemaNodeKind.columnDefault;\n }\n\n /**\n * Structured comparison with `this` as the expected side: both sides\n * resolved compare per the relational walk's `columnDefaultsEqual`\n * semantics; a declared expected default against an unparseable actual\n * (raw present, no resolved parse) is a mismatch; two raw-only nodes fall\n * back to raw string equality.\n */\n isEqualTo(other: DiffableNode): boolean {\n const node = blindCast<\n SqlSchemaIRNode,\n 'every diff-tree node the differ pairs is a SqlSchemaIRNode'\n >(other);\n assertNode(node, 'SqlColumnDefaultIR', SqlColumnDefaultIR.is);\n if (this.resolved !== undefined && node.resolved !== undefined) {\n return resolvedDefaultsEqual(\n this.resolved,\n node.resolved,\n node.nativeTypeContext ?? this.nativeTypeContext,\n );\n }\n if (this.resolved !== undefined || node.resolved !== undefined) {\n return false;\n }\n return this.raw === node.raw;\n }\n}\n","import type { ColumnDefault } from '@prisma-next/contract/types';\nimport type { CodecRef } from '@prisma-next/framework-components/codec';\nimport type { DiffableNode } from '@prisma-next/framework-components/control';\nimport { freezeNode } from '@prisma-next/framework-components/ir';\nimport { blindCast } from '@prisma-next/utils/casts';\nimport { ifDefined } from '@prisma-next/utils/defined';\nimport { RelationalSchemaNodeKind } from './schema-node-kinds';\nimport { SqlColumnDefaultIR } from './sql-column-default-ir';\nimport { assertNode, defineNonEnumerable, SqlSchemaIRNode } from './sql-schema-ir-node';\n\n/**\n * Namespaced annotations for extensibility. Each namespace\n * (e.g. `pg`, `pgvector`) owns its annotations subtree.\n */\nexport type SqlAnnotations = {\n readonly [namespace: string]: unknown;\n};\n\nexport interface SqlColumnIRInput {\n readonly name: string;\n readonly nativeType: string;\n readonly nullable: boolean;\n /** Raw database default expression (e.g. `'hello'::text`, `nextval('seq')`). */\n readonly default?: string;\n readonly annotations?: SqlAnnotations;\n /** True when the column is a native array (e.g. `text[]`, `int4[]`). The `nativeType` carries the element type only (e.g. `text`, `int4`). */\n readonly many?: boolean;\n /**\n * Fully resolved native type, comparable across the two diff sides:\n * the contract-derived side stamps the codec-expanded type (typeRef\n * resolved, parameterized types expanded, `[]` appended for arrays);\n * the introspected side stamps the target-normalized type with the same\n * `[]` convention. Stamped at construction by derivation/introspection;\n * absent on raw hand-built nodes.\n */\n readonly resolvedNativeType?: string;\n /**\n * Structured default, comparable across the two diff sides: the\n * contract-derived side stamps the contract's `ColumnDefault`; the\n * introspected side stamps the target default-normalizer's parse of the\n * raw expression. Absent when the column declares no default, or when\n * the introspected raw default could not be parsed.\n */\n readonly resolvedDefault?: ColumnDefault;\n /**\n * The column's resolved codec reference — the identity the migration\n * planner's op-builders resolve DDL type rendering against at plan time\n * (parameterized type expansion, e.g. `character` + `{ length: 36 }` →\n * `character(36)`), calling the same codec hooks the pre-`plan(start,\n * end)` op-path called. Carried the same way the query AST carries\n * `CodecRef` (TML-2456) and the migration DDL renderer (TML-2918).\n * Stamped on the EXPECTED (contract-derived) column at derivation,\n * post-`typeRef` resolution (the referenced storage type's own\n * codec/params, not the column's `typeRef` pointer). Absent on\n * introspected/hand-built nodes — the actual side never renders DDL —\n * and never compared by `isEqualTo`.\n */\n readonly codecRef?: CodecRef;\n /**\n * The column's resolved BASE native type: pre-parameter-expansion,\n * pre-array-suffix (e.g. `character`, not `character(36)` or\n * `character[]`). Distinct from {@link resolvedNativeType} (the EXPANDED\n * comparison value) — DDL rendering re-expands a parameterized type at\n * plan time from this base, so it must not already carry the expansion.\n * Stamped alongside {@link codecRef}.\n */\n readonly codecBaseNativeType?: string;\n /**\n * True when the contract column declared its type via a named\n * `storage.types` reference (`typeRef`) rather than inline fields — the\n * migration planner quotes the base native type as an identifier in this\n * case (e.g. a native enum's type name), matching the pre-`plan(start,\n * end)` rendering exactly.\n */\n readonly codecNamedType?: boolean;\n}\n\n/**\n * Schema IR node for a single column on a table, as observed by\n * introspection. Unlike the Contract IR `StorageColumn`, this carries\n * the column's `name` (Schema IR columns are returned as arrays from\n * introspection queries; the parent table re-keys them into a record\n * for downstream consumers).\n *\n * Implements `DiffableNode` so a column is directly a table's diff-tree\n * child: `id` is the column name (unique among a table's columns); `isEqualTo`\n * compares this column's own attributes only — never children, since a\n * column is a leaf. When both sides carry `resolvedNativeType` (stamped at\n * derivation/introspection), the comparison uses the resolved values —\n * resolved native type, nullability, and structured default equality per\n * the relational walk's `columnDefaultsEqual` semantics, with `this` as the\n * expected side. Otherwise it falls back to comparing raw fields.\n */\nexport class SqlColumnIR extends SqlSchemaIRNode implements DiffableNode {\n override readonly nodeKind = RelationalSchemaNodeKind.column;\n\n readonly name: string;\n readonly nativeType: string;\n readonly nullable: boolean;\n declare readonly default?: string;\n declare readonly annotations?: SqlAnnotations;\n /** True when the column is a native array (e.g. `text[]`, `int4[]`). The `nativeType` carries the element type only (e.g. `text`, `int4`). */\n declare readonly many?: boolean;\n declare readonly resolvedNativeType?: string;\n declare readonly resolvedDefault?: ColumnDefault;\n /** See {@link SqlColumnIRInput.codecRef}. Non-enumerable so it stays out of JSON and structural equality. */\n declare readonly codecRef?: CodecRef;\n /** See {@link SqlColumnIRInput.codecBaseNativeType}. Non-enumerable, same reason as {@link codecRef}. */\n declare readonly codecBaseNativeType?: string;\n /** See {@link SqlColumnIRInput.codecNamedType}. Non-enumerable, same reason as {@link codecRef}. */\n declare readonly codecNamedType?: boolean;\n\n constructor(input: SqlColumnIRInput) {\n super();\n this.name = input.name;\n this.nativeType = input.nativeType;\n this.nullable = input.nullable;\n if (input.default !== undefined) this.default = input.default;\n if (input.annotations !== undefined) this.annotations = input.annotations;\n if (input.many !== undefined) this.many = input.many;\n if (input.resolvedNativeType !== undefined) this.resolvedNativeType = input.resolvedNativeType;\n if (input.resolvedDefault !== undefined) this.resolvedDefault = input.resolvedDefault;\n defineNonEnumerable(this, 'codecRef', input.codecRef);\n defineNonEnumerable(this, 'codecBaseNativeType', input.codecBaseNativeType);\n defineNonEnumerable(this, 'codecNamedType', input.codecNamedType);\n freezeNode(this);\n }\n\n get id(): string {\n return `column:${this.name}`;\n }\n\n /**\n * The column's default, when declared/present, is the column's one child\n * node — it has an extra/missing/drift lifecycle of its own, so the differ\n * recurses to it rather than `isEqualTo` comparing it. Built transiently\n * from this column's own fields.\n */\n children(): readonly DiffableNode[] {\n if (this.resolvedDefault === undefined && this.default === undefined) {\n return [];\n }\n return [\n new SqlColumnDefaultIR({\n ...ifDefined('resolved', this.resolvedDefault),\n ...ifDefined('raw', this.default),\n ...ifDefined('nativeTypeContext', this.resolvedNativeType),\n // Contract-derived and introspected columns both set `this.many`\n // directly (with `nativeType` as the bare element type; array-ness\n // never rides on a `[]` suffix). `codecRef.many` is a fallback for\n // hand-built nodes that carry a codec ref without the column-level\n // flag. Either source works for the default node's array-literal\n // rendering.\n ...ifDefined('many', this.many ?? this.codecRef?.many),\n }),\n ];\n }\n\n static is(node: SqlSchemaIRNode): node is SqlColumnIR {\n return node.nodeKind === RelationalSchemaNodeKind.column;\n }\n\n /**\n * Compares the column's own attributes only — the default lives on the\n * child node. When both sides carry `resolvedNativeType`, the resolved\n * value governs (array-ness rides on its `[]` suffix); otherwise raw\n * fields compare.\n */\n isEqualTo(other: DiffableNode): boolean {\n const node = blindCast<\n SqlSchemaIRNode,\n 'every diff-tree node the differ pairs is a SqlSchemaIRNode'\n >(other);\n assertNode(node, 'SqlColumnIR', SqlColumnIR.is);\n if (this.resolvedNativeType !== undefined && node.resolvedNativeType !== undefined) {\n return this.resolvedNativeType === node.resolvedNativeType && this.nullable === node.nullable;\n }\n return (\n this.nativeType === node.nativeType &&\n this.nullable === node.nullable &&\n Boolean(this.many) === Boolean(node.many)\n );\n }\n}\n","import type { DiffableNode, SchemaNodeRef } from '@prisma-next/framework-components/control';\nimport { freezeNode } from '@prisma-next/framework-components/ir';\nimport { blindCast } from '@prisma-next/utils/casts';\nimport { RelationalSchemaNodeKind } from './schema-node-kinds';\nimport type { SqlAnnotations } from './sql-column-ir';\nimport { assertNode, defineNonEnumerable, SqlSchemaIRNode } from './sql-schema-ir-node';\n\nexport type SqlReferentialAction = 'noAction' | 'restrict' | 'cascade' | 'setNull' | 'setDefault';\n\nexport interface SqlForeignKeyIRInput {\n readonly columns: readonly string[];\n readonly referencedTable: string;\n readonly referencedColumns: readonly string[];\n /** Schema (namespace) of the referenced table — populated by adapters that introspect cross-schema FKs. */\n readonly referencedSchema?: string;\n readonly name?: string;\n readonly onDelete?: SqlReferentialAction;\n readonly onUpdate?: SqlReferentialAction;\n readonly annotations?: SqlAnnotations;\n /**\n * The real live DDL namespace of the referenced table, comparable across\n * the two diff sides. Contract-derived trees stamp it explicitly (resolving\n * namespace ids — including the unbound sentinel — to the DDL namespace);\n * introspected FKs default it to `referencedSchema`, whose value already\n * is the live namespace. Folded into `id` in place of the raw value so an\n * unbound-namespace contract FK pairs with its introspected counterpart.\n */\n readonly resolvedReferencedNamespace?: string;\n /**\n * The referenced table's node, as the root-anchored chain the differ pairs\n * siblings with. Stamped by the derivation, which holds the parent\n * (database/namespace) context the chain's shape depends on. Never\n * compared by `isEqualTo`.\n */\n readonly dependsOn?: readonly SchemaNodeRef[];\n}\n\n/**\n * Schema IR node for a foreign-key constraint as observed by\n * introspection. The `referencedTable` / `referencedColumns` field\n * names match the introspection vocabulary (`pg_constraint.confkey`,\n * etc.) and intentionally differ from the Contract IR's nested\n * `references: { table, columns }` shape so that the verifier's\n * structural comparison stays explicit about which side it's reading.\n *\n * Implements `DiffableNode` so a foreign key is directly a table's diff-tree\n * child. Foreign keys are frequently unnamed (introspection may not carry a\n * constraint name, and the contract side never invents one), so `id` is\n * derived from the referencing/referenced coordinates rather than `name` —\n * the same tuple that makes two FK constraints the same constraint. This\n * also serves as the comparison key: two FKs with the same coordinates are\n * paired by the differ, and `isEqualTo` then compares the remaining\n * attribute — the referential actions.\n */\nexport class SqlForeignKeyIR extends SqlSchemaIRNode implements DiffableNode {\n override readonly nodeKind = RelationalSchemaNodeKind.foreignKey;\n\n readonly columns: readonly string[];\n readonly referencedTable: string;\n readonly referencedColumns: readonly string[];\n declare readonly referencedSchema?: string;\n declare readonly name?: string;\n declare readonly onDelete?: SqlReferentialAction;\n declare readonly onUpdate?: SqlReferentialAction;\n declare readonly annotations?: SqlAnnotations;\n declare readonly resolvedReferencedNamespace?: string;\n /** See {@link SqlForeignKeyIRInput.dependsOn}. Non-enumerable so it stays out of JSON and structural equality, matching `SqlColumnIR.codecRef`. */\n declare readonly dependsOn?: readonly SchemaNodeRef[];\n\n constructor(input: SqlForeignKeyIRInput) {\n super();\n this.columns = input.columns;\n this.referencedTable = input.referencedTable;\n this.referencedColumns = input.referencedColumns;\n if (input.referencedSchema !== undefined) this.referencedSchema = input.referencedSchema;\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 if (input.annotations !== undefined) this.annotations = input.annotations;\n const resolvedReferencedNamespace = input.resolvedReferencedNamespace ?? input.referencedSchema;\n if (resolvedReferencedNamespace !== undefined) {\n this.resolvedReferencedNamespace = resolvedReferencedNamespace;\n }\n defineNonEnumerable(this, 'dependsOn', input.dependsOn);\n freezeNode(this);\n }\n\n get id(): string {\n const referencedNamespace = this.resolvedReferencedNamespace ?? '';\n return `foreign-key:${this.columns.join(',')}->${referencedNamespace}.${this.referencedTable}(${this.referencedColumns.join(',')})`;\n }\n\n children(): readonly DiffableNode[] {\n return [];\n }\n\n static is(node: SqlSchemaIRNode): node is SqlForeignKeyIR {\n return node.nodeKind === RelationalSchemaNodeKind.foreignKey;\n }\n\n /**\n * Referential-action comparison with `this` as the expected side, matching\n * the relational walk's `getReferentialActionMismatches`: `noAction` is the\n * database default and equivalent to an undeclared action, and drift is\n * flagged only when the expected side declares a (normalized) action.\n */\n isEqualTo(other: DiffableNode): boolean {\n const node = blindCast<\n SqlSchemaIRNode,\n 'every diff-tree node the differ pairs is a SqlSchemaIRNode'\n >(other);\n assertNode(node, 'SqlForeignKeyIR', SqlForeignKeyIR.is);\n return (\n referentialActionMatches(this.onDelete, node.onDelete) &&\n referentialActionMatches(this.onUpdate, node.onUpdate)\n );\n }\n}\n\nfunction referentialActionMatches(\n expected: SqlReferentialAction | undefined,\n actual: SqlReferentialAction | undefined,\n): boolean {\n const normalizedExpected = expected === 'noAction' ? undefined : expected;\n if (normalizedExpected === undefined) return true;\n const normalizedActual = actual === 'noAction' ? undefined : actual;\n return normalizedExpected === normalizedActual;\n}\n","import type { DiffableNode, SchemaNodeRef } from '@prisma-next/framework-components/control';\nimport { freezeNode } from '@prisma-next/framework-components/ir';\nimport { isArrayEqual } from '@prisma-next/utils/array-equal';\nimport { blindCast } from '@prisma-next/utils/casts';\nimport { InternalError } from '@prisma-next/utils/internal-error';\nimport { normalizeIndexOptionValue } from '../naming';\nimport { RelationalSchemaNodeKind } from './schema-node-kinds';\nimport type { SqlAnnotations } from './sql-column-ir';\nimport { assertNode, defineNonEnumerable, SqlSchemaIRNode } from './sql-schema-ir-node';\n\n/**\n * An index's element structure — exactly one of a column tuple or an opaque\n * expression, unrepresentable-otherwise at the type level. No discriminant\n * is stored (the node keeps flat readonly accessors); the constructor's xor\n * throw stays as the backstop for introspection rows and JSON-derived\n * inputs that bypass this union.\n */\nexport type SqlIndexElements =\n | {\n /** Column-tuple elements. */\n readonly columns: readonly string[];\n readonly expression?: never;\n }\n | {\n readonly columns?: never;\n /**\n * Opaque SQL: the entire element list between the parens of CREATE\n * INDEX — one string, never parsed.\n */\n readonly expression: string;\n };\n\n/**\n * Every non-element field is a required key. Values that may legitimately\n * be absent (an exact-named index's prefix, a default-method type) are\n * typed `| undefined` instead of optional, so each construction site\n * states the absence explicitly rather than omitting the key silently.\n * Undefined values still produce an instance without the property.\n */\nexport type SqlIndexIRInput = SqlIndexElements & {\n /** Full physical name — the node's identity. */\n readonly name: string;\n /**\n * The managed-mode name prefix — its PRESENCE is the naming-mode\n * discriminator (there is no stored enum). Present ⇔ managed: the\n * toolchain owns the physical name and `name === formatWireName(prefix,\n * <8hex content hash>)`. Absent ⇔ exact: `name` is an adopted verbatim\n * physical name whose identity the author owns entirely.\n */\n readonly prefix: string | undefined;\n /** Opaque SQL: partial-index predicate (WHERE body, without the keyword). */\n readonly where: string | undefined;\n readonly unique: boolean;\n readonly type: string | undefined;\n readonly options: Record<string, unknown> | undefined;\n readonly annotations: SqlAnnotations | undefined;\n /**\n * The index's own column nodes, as root-anchored chains. The derivation\n * stamps them so an index is dropped before the columns it is built on\n * (Postgres auto-drops the index when a covered column goes). An expression\n * index stamps chains to every column of its table — a deterministic\n * over-approximation, since the opaque expression is never parsed. Never\n * compared by `isEqualTo`.\n */\n readonly dependsOn: readonly SchemaNodeRef[] | undefined;\n /**\n * Whether the index is partial (has a row predicate). Required: every\n * producer must assert partiality explicitly, because a partial unique\n * index does not guarantee at-most-one row per key and so cannot back a\n * 1:1 relation — \"unknown\" must not silently default to \"total\". Never\n * compared by `isEqualTo` and never serialized.\n */\n readonly partial: boolean;\n};\n\n/**\n * Schema IR node for a secondary index as observed by introspection.\n * Unlike the Contract IR `Index`, the Schema IR carries an explicit\n * `unique` field — introspection sees the underlying index regardless\n * of whether the user expressed it as `@@index` or `@@unique`, and the\n * verifier needs to distinguish them when comparing to the Contract.\n *\n * Implements `DiffableNode` so an index is directly a table's diff-tree\n * child. Indexes are name-identified: every index — contract-derived or\n * introspected — carries its full physical name, and `id` is that name.\n * Names are catalog-unique per schema, so two indexes legitimately sharing\n * one column tuple (a unique index beside a redundant plain index) are two\n * distinct siblings, and expression indexes need no column tuple at all.\n *\n * `isEqualTo` is selected by the receiver (the differ always calls\n * `expected.isEqualTo(actual)`) and delegates to {@link contentEquals} —\n * the single node-owned content relation: both modes compare `unique`\n * strict, `type` and option values through the named normalization seams,\n * and `columns` ordered-strict when both sides carry them; an exact-named\n * receiver (`prefix === undefined`) additionally byte-compares\n * `expression`/`where` (both sides are reprints in the supported flow —\n * normalizing would only mask real drift); a managed receiver never\n * compares bodies (the wire-name hash already commits to them).\n *\n * `expression`, `where`, and `unique` are genuine SQL-family attributes —\n * functional and partial indexes are standard SQL that any SQL target may\n * introspect, so the family node must represent them; a target declining\n * to author them is a capability decision, not target-specificity.\n */\nexport class SqlIndexIR extends SqlSchemaIRNode implements DiffableNode {\n override readonly nodeKind = RelationalSchemaNodeKind.index;\n\n readonly name: string;\n readonly unique: boolean;\n declare readonly prefix?: string;\n declare readonly columns?: readonly string[];\n declare readonly expression?: string;\n declare readonly where?: string;\n declare readonly type?: string;\n declare readonly options?: Record<string, unknown>;\n declare readonly annotations?: SqlAnnotations;\n /** See {@link SqlIndexIRInput.dependsOn}. Non-enumerable so it stays out of JSON and structural equality, matching `SqlColumnIR.codecRef`. */\n declare readonly dependsOn?: readonly SchemaNodeRef[];\n /** See {@link SqlIndexIRInput.partial}. Non-enumerable so it stays out of JSON and structural equality, matching `dependsOn`. */\n declare readonly partial: boolean;\n\n constructor(input: SqlIndexIRInput) {\n super();\n if ((input.columns === undefined) === (input.expression === undefined)) {\n throw new InternalError(\n `SqlIndexIR \"${input.name}\": exactly one of columns or expression must be set.`,\n );\n }\n this.name = input.name;\n this.unique = input.unique;\n if (input.prefix !== undefined) this.prefix = input.prefix;\n if (input.columns !== undefined) this.columns = input.columns;\n if (input.expression !== undefined) this.expression = input.expression;\n if (input.where !== undefined) this.where = input.where;\n if (input.type !== undefined) this.type = input.type;\n if (input.options !== undefined) this.options = input.options;\n if (input.annotations !== undefined) this.annotations = input.annotations;\n defineNonEnumerable(this, 'dependsOn', input.dependsOn);\n defineNonEnumerable(this, 'partial', input.partial);\n freezeNode(this);\n }\n\n get id(): string {\n return `index:${this.name}`;\n }\n\n children(): readonly DiffableNode[] {\n return [];\n }\n\n static is(node: SqlSchemaIRNode): node is SqlIndexIR {\n return node.nodeKind === RelationalSchemaNodeKind.index;\n }\n\n /**\n * Mode-selected structural equality — see the class doc. Delegates to the\n * single node-owned relation: `columns` compare ordered-strict when both\n * sides carry them; an exact receiver (`prefix === undefined`)\n * byte-compares `expression ?? ''` and `where ?? ''`; a managed receiver\n * never compares bodies (the wire-name hash already commits to them).\n */\n isEqualTo(other: DiffableNode): boolean {\n const node = blindCast<\n SqlSchemaIRNode,\n 'every diff-tree node the differ pairs is a SqlSchemaIRNode'\n >(other);\n assertNode(node, 'SqlIndexIR', SqlIndexIR.is);\n return this.contentEquals(node, {\n columnPresence: 'when-both-defined',\n bodies: this.prefix !== undefined ? 'ignored' : 'verbatim',\n });\n }\n\n /**\n * The single index content-equality relation — every comparer (the differ\n * via {@link isEqualTo}, the planner's rename content-pairing) calls this\n * with its mode-appropriate strictness rather than growing a parallel\n * relation:\n *\n * - `columnPresence: 'when-both-defined'` (the differ's rule) compares\n * the tuples ordered-strict only when both sides carry them — a paired\n * node's identity already agreed, so a column node meeting an\n * expression node skips the tuple.\n * - `columnPresence: 'matching'` (the rename-pairing rule) additionally\n * requires presence to agree: a column index never pairs an expression\n * index.\n * - `bodies: 'verbatim'` byte-compares `expression ?? ''` / `where ?? ''`\n * (absent ≡ empty, no normalization — both sides are reprints in the\n * supported flow); `bodies: 'ignored'` skips them (managed identity —\n * the wire-name hash commits to the content).\n *\n * `unique` compares strictly; `type` and option VALUES compare through\n * the named normalization seams below.\n */\n contentEquals(\n other: SqlIndexIR,\n strictness: {\n readonly columnPresence: 'when-both-defined' | 'matching';\n readonly bodies: 'verbatim' | 'ignored';\n },\n ): boolean {\n const columnsEqual =\n strictness.columnPresence === 'matching'\n ? (this.columns === undefined) === (other.columns === undefined) &&\n (this.columns === undefined || isArrayEqual(this.columns, other.columns ?? []))\n : this.columns === undefined ||\n other.columns === undefined ||\n isArrayEqual(this.columns, other.columns);\n const structurallyEqual =\n this.unique === other.unique &&\n normalizeIndexType(this.type) === normalizeIndexType(other.type) &&\n indexOptionsEqual(this.options, other.options) &&\n columnsEqual;\n if (!structurallyEqual) return false;\n if (strictness.bodies === 'ignored') return true;\n return (\n (this.expression ?? '') === (other.expression ?? '') &&\n (this.where ?? '') === (other.where ?? '')\n );\n }\n}\n\n/**\n * Comparison-side normalization seam: the default access method (`btree` in\n * every supported SQL target) compares as absent, so an authored\n * `type: \"btree\"` and a default-method introspected index (whose type the\n * adapter or constructor normalized away) are equal. Applied by\n * {@link SqlIndexIR.contentEquals} only — the wire-name hash keeps the\n * authored spelling.\n */\nfunction normalizeIndexType(type: string | undefined): string | undefined {\n return type === 'btree' ? undefined : type;\n}\n\n/**\n * Option-bag equality: same key set, values compared through\n * {@link normalizeIndexOptionValue} — Postgres introspection returns\n * reloptions values as catalog-reprint strings (`'70'`, `'on'`) while\n * contract option leaves are typed (number, boolean, string).\n */\nfunction indexOptionsEqual(\n a: Record<string, unknown> | undefined,\n b: Record<string, unknown> | undefined,\n): boolean {\n const aKeys = a ? Object.keys(a).sort() : [];\n const bKeys = b ? Object.keys(b).sort() : [];\n if (aKeys.length !== bKeys.length) return false;\n for (let i = 0; i < aKeys.length; i += 1) {\n if (aKeys[i] !== bKeys[i]) return false;\n }\n if (aKeys.length === 0) return true;\n for (const key of aKeys) {\n if (normalizeIndexOptionValue(a?.[key]) !== normalizeIndexOptionValue(b?.[key])) {\n return false;\n }\n }\n return true;\n}\n","import type { DiffableNode, SchemaNodeRef } from '@prisma-next/framework-components/control';\nimport { freezeNode } from '@prisma-next/framework-components/ir';\nimport { blindCast } from '@prisma-next/utils/casts';\nimport { RelationalSchemaNodeKind } from './schema-node-kinds';\nimport type { SqlAnnotations } from './sql-column-ir';\nimport { assertNode, defineNonEnumerable, SqlSchemaIRNode } from './sql-schema-ir-node';\n\nexport interface SqlUniqueIRInput {\n readonly columns: readonly string[];\n readonly name?: string;\n readonly annotations?: SqlAnnotations;\n /**\n * The constraint's own column nodes, as root-anchored chains. The\n * derivation stamps them so a unique constraint is dropped before the\n * columns it is built on. Never compared by `isEqualTo`.\n */\n readonly dependsOn?: readonly SchemaNodeRef[];\n}\n\n/**\n * Schema IR node for a table-level unique constraint as observed by\n * introspection.\n *\n * Implements `DiffableNode` so a unique constraint is directly a table's\n * diff-tree child. Unique constraints are frequently unnamed, so `id` is\n * derived from the column tuple rather than `name` — the column tuple is\n * also what makes two unique constraints the same constraint, so it doubles\n * as the pairing key. There are no further attributes to compare once\n * columns are equal (the differ pairs on `id`), so `isEqualTo` is identity.\n */\nexport class SqlUniqueIR extends SqlSchemaIRNode implements DiffableNode {\n override readonly nodeKind = RelationalSchemaNodeKind.unique;\n\n readonly columns: readonly string[];\n declare readonly name?: string;\n declare readonly annotations?: SqlAnnotations;\n /** See {@link SqlUniqueIRInput.dependsOn}. Non-enumerable so it stays out of JSON and structural equality, matching `SqlColumnIR.codecRef`. */\n declare readonly dependsOn?: readonly SchemaNodeRef[];\n\n constructor(input: SqlUniqueIRInput) {\n super();\n this.columns = [...input.columns];\n if (input.name !== undefined) this.name = input.name;\n if (input.annotations !== undefined) this.annotations = input.annotations;\n defineNonEnumerable(this, 'dependsOn', input.dependsOn);\n freezeNode(this);\n }\n\n get id(): string {\n return `unique:${this.columns.join(',')}`;\n }\n\n children(): readonly DiffableNode[] {\n return [];\n }\n\n static is(node: SqlSchemaIRNode): node is SqlUniqueIR {\n return node.nodeKind === RelationalSchemaNodeKind.unique;\n }\n\n isEqualTo(other: DiffableNode): boolean {\n const node = blindCast<\n SqlSchemaIRNode,\n 'every diff-tree node the differ pairs is a SqlSchemaIRNode'\n >(other);\n assertNode(node, 'SqlUniqueIR', SqlUniqueIR.is);\n return this.id === node.id;\n }\n}\n","import type { DiffableNode } from '@prisma-next/framework-components/control';\nimport { freezeNode } from '@prisma-next/framework-components/ir';\nimport { PrimaryKey, type PrimaryKeyInput } from './primary-key';\nimport { RelationalSchemaNodeKind } from './schema-node-kinds';\nimport { SqlCheckConstraintIR, type SqlCheckConstraintIRInput } from './sql-check-constraint-ir';\nimport { type SqlAnnotations, SqlColumnIR, type SqlColumnIRInput } from './sql-column-ir';\nimport { SqlForeignKeyIR, type SqlForeignKeyIRInput } from './sql-foreign-key-ir';\nimport { SqlIndexIR, type SqlIndexIRInput } from './sql-index-ir';\nimport { SqlSchemaIRNode } from './sql-schema-ir-node';\nimport { SqlUniqueIR, type SqlUniqueIRInput } from './sql-unique-ir';\n\nexport interface SqlTableIRInput {\n readonly name: string;\n readonly columns: Record<string, SqlColumnIR | SqlColumnIRInput>;\n readonly foreignKeys: ReadonlyArray<SqlForeignKeyIR | SqlForeignKeyIRInput>;\n readonly uniques: ReadonlyArray<SqlUniqueIR | SqlUniqueIRInput>;\n readonly indexes: ReadonlyArray<SqlIndexIR | SqlIndexIRInput>;\n readonly primaryKey?: PrimaryKey | PrimaryKeyInput;\n readonly annotations?: SqlAnnotations;\n /** Optional check constraints for enum-restricted columns. Omitted when none present. */\n readonly checks?: ReadonlyArray<SqlCheckConstraintIR | SqlCheckConstraintIRInput>;\n}\n\n/**\n * Schema IR node for a single table as observed by introspection.\n *\n * Unlike the Contract IR `StorageTable`, this carries the table's\n * `name` — introspection queries return tables as arrays and the\n * verifier keys them into `SqlSchemaIR.tables` afterwards, so the name\n * stays on the table object for downstream call sites that walk\n * `Object.values(schema.tables)`.\n *\n * The constructor normalises nested IR-class fields so downstream\n * walks see a uniform AST regardless of whether the input was a\n * plain-data literal (from introspection) or already-constructed\n * class instances.\n *\n * Implements `DiffableNode` so a flat (single-schema) tree is directly\n * diffable: `id` is the table name; `isEqualTo` is identity (the table's\n * structural drift is entirely expressed by its children); `children()`\n * yields every column, the primary key (when present), every foreign key,\n * unique, index, and check constraint — the same composition and order as\n * the Postgres table node, minus policies.\n */\nexport class SqlTableIR extends SqlSchemaIRNode implements DiffableNode {\n override readonly nodeKind = RelationalSchemaNodeKind.table;\n\n readonly name: string;\n readonly columns: Readonly<Record<string, SqlColumnIR>>;\n readonly foreignKeys: ReadonlyArray<SqlForeignKeyIR>;\n readonly uniques: ReadonlyArray<SqlUniqueIR>;\n readonly indexes: ReadonlyArray<SqlIndexIR>;\n declare readonly primaryKey?: PrimaryKey;\n declare readonly annotations?: SqlAnnotations;\n declare readonly checks?: ReadonlyArray<SqlCheckConstraintIR>;\n\n constructor(input: SqlTableIRInput) {\n super();\n this.name = input.name;\n this.columns = Object.freeze(\n Object.fromEntries(\n Object.entries(input.columns).map(([key, col]) => [\n key,\n col instanceof SqlColumnIR ? col : new SqlColumnIR(col),\n ]),\n ),\n );\n this.foreignKeys = Object.freeze(\n input.foreignKeys.map((fk) => (fk instanceof SqlForeignKeyIR ? fk : new SqlForeignKeyIR(fk))),\n );\n this.uniques = Object.freeze(\n input.uniques.map((u) => (u instanceof SqlUniqueIR ? u : new SqlUniqueIR(u))),\n );\n this.indexes = Object.freeze(\n input.indexes.map((i) => (i instanceof SqlIndexIR ? i : new SqlIndexIR(i))),\n );\n if (input.primaryKey !== undefined) {\n this.primaryKey =\n input.primaryKey instanceof PrimaryKey\n ? input.primaryKey\n : new PrimaryKey(input.primaryKey);\n }\n if (input.annotations !== undefined) this.annotations = input.annotations;\n if (input.checks !== undefined && input.checks.length > 0) {\n this.checks = Object.freeze(\n input.checks.map((c) =>\n c instanceof SqlCheckConstraintIR ? c : new SqlCheckConstraintIR(c),\n ),\n );\n }\n freezeNode(this);\n }\n\n get id(): string {\n return this.name;\n }\n\n isEqualTo(other: DiffableNode): boolean {\n return this.id === other.id;\n }\n\n children(): readonly DiffableNode[] {\n return [\n ...Object.values(this.columns),\n ...(this.primaryKey ? [this.primaryKey] : []),\n ...this.foreignKeys,\n ...this.uniques,\n ...this.indexes,\n ...(this.checks ?? []),\n ];\n }\n}\n","import type { DiffableNode } from '@prisma-next/framework-components/control';\nimport { freezeNode } from '@prisma-next/framework-components/ir';\nimport { RelationalSchemaNodeKind } from './schema-node-kinds';\nimport type { SqlAnnotations } from './sql-column-ir';\nimport { SqlSchemaIRNode } from './sql-schema-ir-node';\nimport { SqlTableIR, type SqlTableIRInput } from './sql-table-ir';\n\nexport interface SqlSchemaIRInput {\n readonly tables: Record<string, SqlTableIR | SqlTableIRInput>;\n readonly annotations?: SqlAnnotations;\n}\n\n/**\n * Root Schema IR node representing the complete database schema as\n * observed by introspection. Target-agnostic; used by both verifiers\n * (compare against intended Contract storage) and migration planners\n * (derive operations needed to reconcile).\n *\n * The constructor normalises nested `SqlTableIR` instances so\n * downstream walks see a uniform AST regardless of whether the input\n * was a plain-data literal or already-constructed class instances.\n *\n * Implements `DiffableNode` as the root of a flat (single-schema) diff\n * tree: `id` is the fixed sentinel `'database'` (roots have no siblings),\n * `isEqualTo` is identity (a container has no own attributes), and\n * `children()` yields the table nodes.\n */\nexport class SqlSchemaIR extends SqlSchemaIRNode implements DiffableNode {\n override readonly nodeKind = RelationalSchemaNodeKind.schema;\n\n readonly tables: Readonly<Record<string, SqlTableIR>>;\n declare readonly annotations?: SqlAnnotations;\n\n constructor(input: SqlSchemaIRInput) {\n super();\n this.tables = Object.freeze(\n Object.fromEntries(\n Object.entries(input.tables).map(([key, t]) => [\n key,\n t instanceof SqlTableIR ? t : new SqlTableIR(t),\n ]),\n ),\n );\n if (input.annotations !== undefined) this.annotations = input.annotations;\n freezeNode(this);\n }\n\n get id(): string {\n return 'database';\n }\n\n isEqualTo(other: DiffableNode): boolean {\n return this.id === other.id;\n }\n\n children(): readonly DiffableNode[] {\n return Object.values(this.tables);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;AASA,MAAa,2BAA2B;CACtC,QAAQ;CACR,OAAO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SAAS,GACtD,KAAK,SAAS,OAAO,OACnB,MAAM,OAAO,KAAK,MAChB,aAAa,uBAAuB,IAAI,IAAI,qBAAqB,CAAC,CACpE,CACF;EAEF,WAAW,IAAI;CACjB;CAEA,IAAI,KAAa;EACf,OAAO,KAAK;CACd;CAEA,UAAU,OAA8B;EACtC,OAAO,KAAK,OAAO,MAAM;CAC3B;CAEA,WAAoC;EAClC,OAAO;GACL,GAAG,OAAO,OAAO,KAAK,OAAO;GAC7B,GAAI,KAAK,aAAa,CAAC,KAAK,UAAU,IAAI,CAAC;GAC3C,GAAG,KAAK;GACR,GAAG,KAAK;GACR,GAAG,KAAK;GACR,GAAI,KAAK,UAAU,CAAC;EACtB;CACF;AACF;;;;;;;;;;;;;;;;;;ACpFA,IAAa,cAAb,cAAiC,gBAAwC;CACvE,WAA6B,yBAAyB;CAEtD;CAGA,YAAY,OAAyB;EACnC,MAAM;EACN,KAAK,SAAS,OAAO,OACnB,OAAO,YACL,OAAO,QAAQ,MAAM,MAAM,CAAC,CAAC,KAAK,CAAC,KAAK,OAAO,CAC7C,KACA,aAAa,aAAa,IAAI,IAAI,WAAW,CAAC,CAChD,CAAC,CACH,CACF;EACA,IAAI,MAAM,gBAAgB,KAAA,GAAW,KAAK,cAAc,MAAM;EAC9D,WAAW,IAAI;CACjB;CAEA,IAAI,KAAa;EACf,OAAO;CACT;CAEA,UAAU,OAA8B;EACtC,OAAO,KAAK,OAAO,MAAM;CAC3B;CAEA,WAAoC;EAClC,OAAO,OAAO,OAAO,KAAK,MAAM;CAClC;AACF"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types-DzLk5eOU.d.mts","names":[],"sources":["../src/ir/sql-schema-ir-node.ts","../src/ir/primary-key.ts","../src/ir/schema-node-kinds.ts","../src/ir/sql-check-constraint-ir.ts","../src/ir/sql-column-default-ir.ts","../src/ir/sql-column-ir.ts","../src/ir/sql-foreign-key-ir.ts","../src/ir/sql-index-ir.ts","../src/ir/sql-un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