@prisma-next/family-sql 0.14.0-dev.57 → 0.14.0-dev.59

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/diff.d.mts CHANGED
@@ -1,60 +1,12 @@
1
- import { a as NativeTypeNormalizer, c as isUniqueConstraintSatisfied, o as arraysEqual, s as isIndexSatisfied } from "./control-adapter-BVOj4gXI.mjs";
2
- import { n as CodecControlHooks } from "./types-BW7pzb2j.mjs";
1
+ import { a as NativeTypeNormalizer, o as arraysEqual } from "./control-adapter-BeN8TDZ5.mjs";
2
+ import { n as CodecControlHooks } from "./types-COTsneBU.mjs";
3
3
  import { t as SqlSchemaDiffFn } from "./schema-differ-DnoopSXm.mjs";
4
4
  import { DiffSubjectGranularity, SchemaDiffIssue, VerifierIssueCategory, VerifyDatabaseSchemaResult } from "@prisma-next/framework-components/control";
5
5
  import { Contract, ControlPolicy } from "@prisma-next/contract/types";
6
6
  import { SqlStorage } from "@prisma-next/sql-contract/types";
7
- import { SqlIndexIR, SqlSchemaIR, SqlSchemaIRNode, SqlUniqueIR } from "@prisma-next/sql-schema-ir/types";
7
+ import { SqlSchemaIRNode } from "@prisma-next/sql-schema-ir/types";
8
8
  import { TargetBoundComponentDescriptor } from "@prisma-next/framework-components/components";
9
9
 
10
- //#region src/core/diff/diff-tree-normalization.d.ts
11
- interface SemanticSatisfactionInput {
12
- readonly expectedUniques: readonly SqlUniqueIR[];
13
- readonly expectedIndexes: readonly SqlIndexIR[];
14
- readonly actualUniques: readonly SqlUniqueIR[];
15
- readonly actualIndexes: readonly SqlIndexIR[];
16
- }
17
- interface SemanticSatisfactionResult {
18
- readonly actualUniques: readonly SqlUniqueIR[];
19
- readonly actualIndexes: readonly SqlIndexIR[];
20
- }
21
- /**
22
- * Adjusts a table pair's ACTUAL unique/index child lists so the legacy
23
- * walk's cross-kind semantic satisfaction materializes as same-kind node
24
- * pairs for the differ (the differ pairs strictly by id, so a `unique:`
25
- * node can never pair with an `index:` node). Three legacy rules, ported
26
- * from `isUniqueConstraintSatisfied` / `isIndexSatisfied` and the
27
- * strict-extras loops of the retired relational walk:
28
- *
29
- * 1. A contract unique satisfied by a live unique INDEX: the actual index
30
- * node is reclassified as a unique node (it pairs with the expected
31
- * unique and stops being a candidate extra).
32
- * 2. A contract index (with no type/options demands) satisfied by a live
33
- * unique CONSTRAINT: a same-kind actual index node is synthesized so
34
- * the expected index pairs — the unique constraint itself stays (the
35
- * legacy strict-extras loop still reports it as an undeclared unique).
36
- * 3. Live unique indexes are never extras in the legacy walk (its
37
- * strict-extras loop skips `unique: true` rows), so any remaining
38
- * actual unique-index node with no expected index counterpart is
39
- * dropped rather than surfacing as `not-expected`.
40
- */
41
- declare function resolveSemanticSatisfaction(input: SemanticSatisfactionInput): SemanticSatisfactionResult;
42
- /**
43
- * Applies {@link resolveSemanticSatisfaction} across a flat table pair set:
44
- * every actual table with an expected counterpart gets its unique/index
45
- * child lists adjusted; unpaired tables pass through untouched.
46
- */
47
- declare function normalizeFlatActualForDiff(expected: SqlSchemaIR, actual: SqlSchemaIR): SqlSchemaIR;
48
- /**
49
- * Neutralizes the FK schema segment on a flat expected tree so its FK diff
50
- * nodes pair with introspected FKs on single-schema targets: the family
51
- * converter stamps `referencedSchema` with the contract namespace id
52
- * verbatim (the unbound sentinel on non-namespaced targets), while a
53
- * single-schema introspection stamps none — resolving both sides to the
54
- * empty segment makes the ids meet.
55
- */
56
- declare function neutralizeFlatExpectedFkSchemas(expected: SqlSchemaIR): SqlSchemaIR;
57
- //#endregion
58
10
  //#region src/core/diff/schema-verify.d.ts
59
11
  /**
60
12
  * Resolves an issue's framework-neutral {@link DiffSubjectGranularity} on
@@ -146,5 +98,5 @@ interface VerifySqlSchemaByDiffInput {
146
98
  */
147
99
  declare function verifySqlSchemaByDiff(input: VerifySqlSchemaByDiffInput): VerifyDatabaseSchemaResult;
148
100
  //#endregion
149
- export { type NativeTypeNormalizer, type SemanticSatisfactionInput, type SemanticSatisfactionResult, type SqlDiffVerdict, type SqlDiffVerdictInput, type StorageTypeVerdict, type StorageTypeVerdictInput, type VerifySqlSchemaByDiffInput, arraysEqual, classifyDiffSubjectGranularity, classifySqlDiffIssue, computeSqlDiffVerdict, computeStorageTypeVerdict, isIndexSatisfied, isUniqueConstraintSatisfied, neutralizeFlatExpectedFkSchemas, normalizeFlatActualForDiff, resolveSemanticSatisfaction, verifySqlSchemaByDiff };
101
+ export { type NativeTypeNormalizer, type SqlDiffVerdict, type SqlDiffVerdictInput, type StorageTypeVerdict, type StorageTypeVerdictInput, type VerifySqlSchemaByDiffInput, arraysEqual, classifyDiffSubjectGranularity, classifySqlDiffIssue, computeSqlDiffVerdict, computeStorageTypeVerdict, verifySqlSchemaByDiff };
150
102
  //# sourceMappingURL=diff.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"diff.d.mts","names":[],"sources":["../src/core/diff/diff-tree-normalization.ts","../src/core/diff/schema-verify.ts"],"mappings":";;;;;;;;;;UAqCiB,yBAAA;EAAA,SACN,eAAA,WAA0B,WAAA;EAAA,SAC1B,eAAA,WAA0B,UAAA;EAAA,SAC1B,aAAA,WAAwB,WAAA;EAAA,SACxB,aAAA,WAAwB,UAAA;AAAA;AAAA,UAGlB,0BAAA;EAAA,SACN,aAAA,WAAwB,WAAA;EAAA,SACxB,aAAA,WAAwB,UAAU;AAAA;;;;;AAAA;AA2B7C;;;;;;;;AAE6B;AAyD7B;;;;;;iBA3DgB,2BAAA,CACd,KAAA,EAAO,yBAAA,GACN,0BAA0B;;;;;;iBAyDb,0BAAA,CACd,QAAA,EAAU,WAAA,EACV,MAAA,EAAQ,WAAA,GACP,WAAA;;AAAW;AAuCd;;;;;;iBAAgB,+BAAA,CAAgC,QAAA,EAAU,WAAA,GAAc,WAAW;;;;;;;;;;AArItC;AAG7C;;iBCcgB,8BAAA,CACd,KAAA,EAAO,eAAA,EACP,aAAA,GAAgB,QAAA,aAAqB,sBAAA,GACpC,sBAAA;;;;;;ADc0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AAA,GAAgB,QAAA,aAAqB,sBAAA;AAAA;;;;;;AAxCH;AAG7C;iBA+CgB,qBAAA,CACd,KAAA,EAAO,0BAAA,GACN,0BAA0B"}
package/dist/diff.mjs CHANGED
@@ -1,159 +1,4 @@
1
1
  import { a as computeStorageTypeVerdict, i as computeSqlDiffVerdict, n as classifyDiffSubjectGranularity, o as verifySqlSchemaByDiff, r as classifySqlDiffIssue } from "./schema-verify-W3r631Jh.mjs";
2
- import { SqlForeignKeyIR, SqlIndexIR, SqlSchemaIR, SqlTableIR, SqlUniqueIR } from "@prisma-next/sql-schema-ir/types";
3
- //#region src/core/diff/diff-tree-normalization.ts
4
- /**
5
- * ⚠️ ACCEPTED-UNDER-PROTEST DEBT — DELETE IN SLICE 2.6 (`unify-unique-and-index-nodes`).
6
- *
7
- * A unique constraint IS a unique index. This slice modeled uniques and indexes
8
- * as two separate node kinds (`SqlUniqueIR` vs `SqlIndexIR` — even though
9
- * `SqlIndexIR` already carries `unique: boolean`), so the strict-by-kind differ
10
- * cannot pair a contract unique with a live unique index. This whole file
11
- * exists only to reconcile those two representations after the fact — it
12
- * should not exist.
13
- *
14
- * The fix — delete `SqlUniqueIR`, model unique enforcement as
15
- * `SqlIndexIR { unique: true }` on both derivation and introspection, and
16
- * delete `diff-tree-normalization.ts` — is specified in
17
- * `projects/postgres-rls/slices/unify-unique-and-index-nodes/spec.md` and
18
- * scheduled as the very next slice. Do NOT extend this.
19
- */
20
- /**
21
- * Pre-diff tree normalization: adjustments to the actual/expected trees the
22
- * generic differ (`diffSchemas`) runs over, so legacy semantic-equivalence
23
- * rules (a unique constraint satisfied by a unique index, an FK schema
24
- * segment that differs only in spelling) surface as same-kind node pairs
25
- * instead of spurious drift.
26
- */
27
- function sameColumns(a, b) {
28
- return a.length === b.length && a.every((c, i) => c === b[i]);
29
- }
30
- /**
31
- * Adjusts a table pair's ACTUAL unique/index child lists so the legacy
32
- * walk's cross-kind semantic satisfaction materializes as same-kind node
33
- * pairs for the differ (the differ pairs strictly by id, so a `unique:`
34
- * node can never pair with an `index:` node). Three legacy rules, ported
35
- * from `isUniqueConstraintSatisfied` / `isIndexSatisfied` and the
36
- * strict-extras loops of the retired relational walk:
37
- *
38
- * 1. A contract unique satisfied by a live unique INDEX: the actual index
39
- * node is reclassified as a unique node (it pairs with the expected
40
- * unique and stops being a candidate extra).
41
- * 2. A contract index (with no type/options demands) satisfied by a live
42
- * unique CONSTRAINT: a same-kind actual index node is synthesized so
43
- * the expected index pairs — the unique constraint itself stays (the
44
- * legacy strict-extras loop still reports it as an undeclared unique).
45
- * 3. Live unique indexes are never extras in the legacy walk (its
46
- * strict-extras loop skips `unique: true` rows), so any remaining
47
- * actual unique-index node with no expected index counterpart is
48
- * dropped rather than surfacing as `not-expected`.
49
- */
50
- function resolveSemanticSatisfaction(input) {
51
- let actualIndexes = [...input.actualIndexes];
52
- const actualUniques = [...input.actualUniques];
53
- for (const expectedUnique of input.expectedUniques) {
54
- if (actualUniques.some((u) => sameColumns(u.columns, expectedUnique.columns))) continue;
55
- const satisfyingIndex = actualIndexes.find((idx) => idx.unique && sameColumns(idx.columns, expectedUnique.columns));
56
- if (satisfyingIndex) {
57
- actualIndexes = actualIndexes.filter((idx) => idx !== satisfyingIndex);
58
- actualUniques.push(new SqlUniqueIR({
59
- columns: satisfyingIndex.columns,
60
- ...satisfyingIndex.name !== void 0 ? { name: satisfyingIndex.name } : {}
61
- }));
62
- }
63
- }
64
- for (const expectedIndex of input.expectedIndexes) {
65
- if (expectedIndex.type !== void 0 || expectedIndex.options !== void 0) continue;
66
- if (actualIndexes.some((idx) => sameColumns(idx.columns, expectedIndex.columns))) continue;
67
- const satisfyingUnique = actualUniques.find((u) => sameColumns(u.columns, expectedIndex.columns));
68
- if (satisfyingUnique) actualIndexes.push(new SqlIndexIR({
69
- columns: satisfyingUnique.columns,
70
- unique: false
71
- }));
72
- }
73
- actualIndexes = actualIndexes.filter((idx) => !idx.unique || input.expectedIndexes.some((exp) => sameColumns(exp.columns, idx.columns)));
74
- return {
75
- actualUniques,
76
- actualIndexes
77
- };
78
- }
79
- /**
80
- * Applies {@link resolveSemanticSatisfaction} across a flat table pair set:
81
- * every actual table with an expected counterpart gets its unique/index
82
- * child lists adjusted; unpaired tables pass through untouched.
83
- */
84
- function normalizeFlatActualForDiff(expected, actual) {
85
- const tables = {};
86
- for (const [name, actualTable] of Object.entries(actual.tables)) {
87
- const expectedTable = expected.tables[name];
88
- if (expectedTable === void 0) {
89
- tables[name] = actualTable;
90
- continue;
91
- }
92
- const adjusted = resolveSemanticSatisfaction({
93
- expectedUniques: expectedTable.uniques,
94
- expectedIndexes: expectedTable.indexes,
95
- actualUniques: actualTable.uniques,
96
- actualIndexes: actualTable.indexes
97
- });
98
- tables[name] = new SqlTableIR({
99
- name: actualTable.name,
100
- columns: actualTable.columns,
101
- foreignKeys: actualTable.foreignKeys,
102
- uniques: adjusted.actualUniques,
103
- indexes: adjusted.actualIndexes,
104
- ...actualTable.primaryKey !== void 0 ? { primaryKey: actualTable.primaryKey } : {},
105
- ...actualTable.annotations !== void 0 ? { annotations: actualTable.annotations } : {},
106
- ...actualTable.checks !== void 0 ? { checks: actualTable.checks } : {}
107
- });
108
- }
109
- return new SqlSchemaIR({
110
- tables,
111
- ...actual.annotations !== void 0 ? { annotations: actual.annotations } : {}
112
- });
113
- }
114
- /**
115
- * Neutralizes the FK schema segment on a flat expected tree so its FK diff
116
- * nodes pair with introspected FKs on single-schema targets: the family
117
- * converter stamps `referencedSchema` with the contract namespace id
118
- * verbatim (the unbound sentinel on non-namespaced targets), while a
119
- * single-schema introspection stamps none — resolving both sides to the
120
- * empty segment makes the ids meet.
121
- */
122
- function neutralizeFlatExpectedFkSchemas(expected) {
123
- const tables = {};
124
- for (const [name, table] of Object.entries(expected.tables)) {
125
- if (table.foreignKeys.length === 0) {
126
- tables[name] = table;
127
- continue;
128
- }
129
- const foreignKeys = table.foreignKeys.map((fk) => new SqlForeignKeyIR({
130
- columns: fk.columns,
131
- referencedTable: fk.referencedTable,
132
- referencedColumns: fk.referencedColumns,
133
- ...fk.referencedSchema !== void 0 ? { referencedSchema: fk.referencedSchema } : {},
134
- ...fk.name !== void 0 ? { name: fk.name } : {},
135
- ...fk.onDelete !== void 0 ? { onDelete: fk.onDelete } : {},
136
- ...fk.onUpdate !== void 0 ? { onUpdate: fk.onUpdate } : {},
137
- ...fk.annotations !== void 0 ? { annotations: fk.annotations } : {},
138
- resolvedReferencedNamespace: ""
139
- }));
140
- tables[name] = new SqlTableIR({
141
- name: table.name,
142
- columns: table.columns,
143
- foreignKeys,
144
- uniques: table.uniques,
145
- indexes: table.indexes,
146
- ...table.primaryKey !== void 0 ? { primaryKey: table.primaryKey } : {},
147
- ...table.annotations !== void 0 ? { annotations: table.annotations } : {},
148
- ...table.checks !== void 0 ? { checks: table.checks } : {}
149
- });
150
- }
151
- return new SqlSchemaIR({
152
- tables,
153
- ...expected.annotations !== void 0 ? { annotations: expected.annotations } : {}
154
- });
155
- }
156
- //#endregion
157
2
  //#region src/core/diff/sql-schema-diff.ts
158
3
  /**
159
4
  * Compares two arrays of strings for equality (order-sensitive).
@@ -163,26 +8,7 @@ function arraysEqual(a, b) {
163
8
  for (let i = 0; i < a.length; i++) if (a[i] !== b[i]) return false;
164
9
  return true;
165
10
  }
166
- /**
167
- * Checks if a unique constraint requirement is satisfied by the given columns:
168
- * a unique constraint with the same columns, or a unique index with the same
169
- * columns (semantic satisfaction). Used by the planners to keep the
170
- * "stronger satisfies weaker" behavior consistent across the control plane.
171
- */
172
- function isUniqueConstraintSatisfied(uniques, indexes, columns) {
173
- if (uniques.some((unique) => arraysEqual(unique.columns, columns))) return true;
174
- return indexes.some((index) => index.unique && arraysEqual(index.columns, columns));
175
- }
176
- /**
177
- * Checks if an index requirement is satisfied by the given columns: any index
178
- * (unique or non-unique) with the same columns, or a unique constraint with
179
- * the same columns (stronger satisfies weaker).
180
- */
181
- function isIndexSatisfied(indexes, uniques, columns) {
182
- if (indexes.some((index) => arraysEqual(index.columns, columns))) return true;
183
- return uniques.some((unique) => arraysEqual(unique.columns, columns));
184
- }
185
11
  //#endregion
186
- export { arraysEqual, classifyDiffSubjectGranularity, classifySqlDiffIssue, computeSqlDiffVerdict, computeStorageTypeVerdict, isIndexSatisfied, isUniqueConstraintSatisfied, neutralizeFlatExpectedFkSchemas, normalizeFlatActualForDiff, resolveSemanticSatisfaction, verifySqlSchemaByDiff };
12
+ export { arraysEqual, classifyDiffSubjectGranularity, classifySqlDiffIssue, computeSqlDiffVerdict, computeStorageTypeVerdict, verifySqlSchemaByDiff };
187
13
 
188
14
  //# sourceMappingURL=diff.mjs.map
package/dist/diff.mjs.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"diff.mjs","names":[],"sources":["../src/core/diff/diff-tree-normalization.ts","../src/core/diff/sql-schema-diff.ts"],"sourcesContent":["/**\n * ⚠️ ACCEPTED-UNDER-PROTEST DEBT — DELETE IN SLICE 2.6 (`unify-unique-and-index-nodes`).\n *\n * A unique constraint IS a unique index. This slice modeled uniques and indexes\n * as two separate node kinds (`SqlUniqueIR` vs `SqlIndexIR` — even though\n * `SqlIndexIR` already carries `unique: boolean`), so the strict-by-kind differ\n * cannot pair a contract unique with a live unique index. This whole file\n * exists only to reconcile those two representations after the fact — it\n * should not exist.\n *\n * The fix — delete `SqlUniqueIR`, model unique enforcement as\n * `SqlIndexIR { unique: true }` on both derivation and introspection, and\n * delete `diff-tree-normalization.ts` — is specified in\n * `projects/postgres-rls/slices/unify-unique-and-index-nodes/spec.md` and\n * scheduled as the very next slice. Do NOT extend this.\n */\n\n/**\n * Pre-diff tree normalization: adjustments to the actual/expected trees the\n * generic differ (`diffSchemas`) runs over, so legacy semantic-equivalence\n * rules (a unique constraint satisfied by a unique index, an FK schema\n * segment that differs only in spelling) surface as same-kind node pairs\n * instead of spurious drift.\n */\n\nimport {\n SqlForeignKeyIR,\n SqlIndexIR,\n SqlSchemaIR,\n SqlTableIR,\n SqlUniqueIR,\n} from '@prisma-next/sql-schema-ir/types';\n\n// ============================================================================\n// Semantic satisfaction — derivation-side normalization of the actual tree\n// ============================================================================\n\nexport interface SemanticSatisfactionInput {\n readonly expectedUniques: readonly SqlUniqueIR[];\n readonly expectedIndexes: readonly SqlIndexIR[];\n readonly actualUniques: readonly SqlUniqueIR[];\n readonly actualIndexes: readonly SqlIndexIR[];\n}\n\nexport interface SemanticSatisfactionResult {\n readonly actualUniques: readonly SqlUniqueIR[];\n readonly actualIndexes: readonly SqlIndexIR[];\n}\n\nfunction sameColumns(a: readonly string[], b: readonly string[]): boolean {\n return a.length === b.length && a.every((c, i) => c === b[i]);\n}\n\n/**\n * Adjusts a table pair's ACTUAL unique/index child lists so the legacy\n * walk's cross-kind semantic satisfaction materializes as same-kind node\n * pairs for the differ (the differ pairs strictly by id, so a `unique:`\n * node can never pair with an `index:` node). Three legacy rules, ported\n * from `isUniqueConstraintSatisfied` / `isIndexSatisfied` and the\n * strict-extras loops of the retired relational walk:\n *\n * 1. A contract unique satisfied by a live unique INDEX: the actual index\n * node is reclassified as a unique node (it pairs with the expected\n * unique and stops being a candidate extra).\n * 2. A contract index (with no type/options demands) satisfied by a live\n * unique CONSTRAINT: a same-kind actual index node is synthesized so\n * the expected index pairs — the unique constraint itself stays (the\n * legacy strict-extras loop still reports it as an undeclared unique).\n * 3. Live unique indexes are never extras in the legacy walk (its\n * strict-extras loop skips `unique: true` rows), so any remaining\n * actual unique-index node with no expected index counterpart is\n * dropped rather than surfacing as `not-expected`.\n */\nexport function resolveSemanticSatisfaction(\n input: SemanticSatisfactionInput,\n): SemanticSatisfactionResult {\n let actualIndexes = [...input.actualIndexes];\n const actualUniques = [...input.actualUniques];\n\n // Rule 1: reclassify a satisfying unique index as the unique constraint\n // the contract declared.\n for (const expectedUnique of input.expectedUniques) {\n const alreadyPaired = actualUniques.some((u) => sameColumns(u.columns, expectedUnique.columns));\n if (alreadyPaired) continue;\n const satisfyingIndex = actualIndexes.find(\n (idx) => idx.unique && sameColumns(idx.columns, expectedUnique.columns),\n );\n if (satisfyingIndex) {\n actualIndexes = actualIndexes.filter((idx) => idx !== satisfyingIndex);\n actualUniques.push(\n new SqlUniqueIR({\n columns: satisfyingIndex.columns,\n ...(satisfyingIndex.name !== undefined ? { name: satisfyingIndex.name } : {}),\n }),\n );\n }\n }\n\n // Rule 2: synthesize an index node from a satisfying unique constraint.\n for (const expectedIndex of input.expectedIndexes) {\n if (expectedIndex.type !== undefined || expectedIndex.options !== undefined) continue;\n const alreadyPaired = actualIndexes.some((idx) =>\n sameColumns(idx.columns, expectedIndex.columns),\n );\n if (alreadyPaired) continue;\n const satisfyingUnique = actualUniques.find((u) =>\n sameColumns(u.columns, expectedIndex.columns),\n );\n if (satisfyingUnique) {\n actualIndexes.push(new SqlIndexIR({ columns: satisfyingUnique.columns, unique: false }));\n }\n }\n\n // Rule 3: remaining unique indexes with no expected counterpart are\n // invisible to the legacy extras loop — drop them.\n actualIndexes = actualIndexes.filter(\n (idx) =>\n !idx.unique || input.expectedIndexes.some((exp) => sameColumns(exp.columns, idx.columns)),\n );\n\n return { actualUniques, actualIndexes };\n}\n\n// ============================================================================\n// Flat-tree helpers (single-schema targets)\n// ============================================================================\n\n/**\n * Applies {@link resolveSemanticSatisfaction} across a flat table pair set:\n * every actual table with an expected counterpart gets its unique/index\n * child lists adjusted; unpaired tables pass through untouched.\n */\nexport function normalizeFlatActualForDiff(\n expected: SqlSchemaIR,\n actual: SqlSchemaIR,\n): SqlSchemaIR {\n const tables: Record<string, SqlTableIR> = {};\n for (const [name, actualTable] of Object.entries(actual.tables)) {\n const expectedTable = expected.tables[name];\n if (expectedTable === undefined) {\n tables[name] = actualTable;\n continue;\n }\n const adjusted = resolveSemanticSatisfaction({\n expectedUniques: expectedTable.uniques,\n expectedIndexes: expectedTable.indexes,\n actualUniques: actualTable.uniques,\n actualIndexes: actualTable.indexes,\n });\n tables[name] = new SqlTableIR({\n name: actualTable.name,\n columns: actualTable.columns,\n foreignKeys: actualTable.foreignKeys,\n uniques: adjusted.actualUniques,\n indexes: adjusted.actualIndexes,\n ...(actualTable.primaryKey !== undefined ? { primaryKey: actualTable.primaryKey } : {}),\n ...(actualTable.annotations !== undefined ? { annotations: actualTable.annotations } : {}),\n ...(actualTable.checks !== undefined ? { checks: actualTable.checks } : {}),\n });\n }\n return new SqlSchemaIR({\n tables,\n ...(actual.annotations !== undefined ? { annotations: actual.annotations } : {}),\n });\n}\n\n/**\n * Neutralizes the FK schema segment on a flat expected tree so its FK diff\n * nodes pair with introspected FKs on single-schema targets: the family\n * converter stamps `referencedSchema` with the contract namespace id\n * verbatim (the unbound sentinel on non-namespaced targets), while a\n * single-schema introspection stamps none — resolving both sides to the\n * empty segment makes the ids meet.\n */\nexport function neutralizeFlatExpectedFkSchemas(expected: SqlSchemaIR): SqlSchemaIR {\n const tables: Record<string, SqlTableIR> = {};\n for (const [name, table] of Object.entries(expected.tables)) {\n if (table.foreignKeys.length === 0) {\n tables[name] = table;\n continue;\n }\n const foreignKeys = table.foreignKeys.map(\n (fk) =>\n new SqlForeignKeyIR({\n columns: fk.columns,\n referencedTable: fk.referencedTable,\n referencedColumns: fk.referencedColumns,\n ...(fk.referencedSchema !== undefined ? { referencedSchema: fk.referencedSchema } : {}),\n ...(fk.name !== undefined ? { name: fk.name } : {}),\n ...(fk.onDelete !== undefined ? { onDelete: fk.onDelete } : {}),\n ...(fk.onUpdate !== undefined ? { onUpdate: fk.onUpdate } : {}),\n ...(fk.annotations !== undefined ? { annotations: fk.annotations } : {}),\n resolvedReferencedNamespace: '',\n }),\n );\n tables[name] = new SqlTableIR({\n name: table.name,\n columns: table.columns,\n foreignKeys,\n uniques: table.uniques,\n indexes: table.indexes,\n ...(table.primaryKey !== undefined ? { primaryKey: table.primaryKey } : {}),\n ...(table.annotations !== undefined ? { annotations: table.annotations } : {}),\n ...(table.checks !== undefined ? { checks: table.checks } : {}),\n });\n }\n return new SqlSchemaIR({\n tables,\n ...(expected.annotations !== undefined ? { annotations: expected.annotations } : {}),\n });\n}\n","/**\n * Shared relational-diff types and semantic-satisfaction predicates. The\n * coordinate-based issue diff this module used to house (`collectSqlSchemaIssues`\n * / `collectSqlSchemaIssuesPerNamespace`) retired once the migration planner\n * took `plan(start, end)` over the one differ (`buildPostgresPlanDiff` /\n * `buildSqlitePlanDiff`); what remains here is consumed by the surviving\n * verify verdict (`schema-verify.ts`) and the control adapters.\n */\n\nimport type { ColumnDefault } from '@prisma-next/contract/types';\nimport type { SqlIndexIR, SqlUniqueIR } from '@prisma-next/sql-schema-ir/types';\n\n/**\n * Function type for normalizing raw database default expressions into ColumnDefault.\n * Target-specific implementations handle database dialect differences.\n */\nexport type DefaultNormalizer = (\n rawDefault: string,\n nativeType: string,\n) => ColumnDefault | undefined;\n\n/**\n * Function type for normalizing schema native types to canonical form for comparison.\n * Target-specific implementations handle dialect-specific type name variations\n * (e.g., Postgres 'varchar' → 'character varying', 'timestamptz' normalization).\n */\nexport type NativeTypeNormalizer = (nativeType: string) => string;\n\n/**\n * Compares two arrays of strings for equality (order-sensitive).\n */\nexport function arraysEqual(a: readonly string[], b: readonly string[]): boolean {\n if (a.length !== b.length) {\n return false;\n }\n for (let i = 0; i < a.length; i++) {\n if (a[i] !== b[i]) {\n return false;\n }\n }\n return true;\n}\n\n/**\n * Checks if a unique constraint requirement is satisfied by the given columns:\n * a unique constraint with the same columns, or a unique index with the same\n * columns (semantic satisfaction). Used by the planners to keep the\n * \"stronger satisfies weaker\" behavior consistent across the control plane.\n */\nexport function isUniqueConstraintSatisfied(\n uniques: readonly SqlUniqueIR[],\n indexes: readonly SqlIndexIR[],\n columns: readonly string[],\n): boolean {\n const hasConstraint = uniques.some((unique) => arraysEqual(unique.columns, columns));\n if (hasConstraint) {\n return true;\n }\n return indexes.some((index) => index.unique && arraysEqual(index.columns, columns));\n}\n\n/**\n * Checks if an index requirement is satisfied by the given columns: any index\n * (unique or non-unique) with the same columns, or a unique constraint with\n * the same columns (stronger satisfies weaker).\n */\nexport function isIndexSatisfied(\n indexes: readonly SqlIndexIR[],\n uniques: readonly SqlUniqueIR[],\n columns: readonly string[],\n): boolean {\n const hasMatchingIndex = indexes.some((index) => arraysEqual(index.columns, columns));\n if (hasMatchingIndex) {\n return true;\n }\n return uniques.some((unique) => arraysEqual(unique.columns, columns));\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAiDA,SAAS,YAAY,GAAsB,GAA+B;CACxE,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,OAAO,GAAG,MAAM,MAAM,EAAE,EAAE;AAC9D;;;;;;;;;;;;;;;;;;;;;AAsBA,SAAgB,4BACd,OAC4B;CAC5B,IAAI,gBAAgB,CAAC,GAAG,MAAM,aAAa;CAC3C,MAAM,gBAAgB,CAAC,GAAG,MAAM,aAAa;CAI7C,KAAK,MAAM,kBAAkB,MAAM,iBAAiB;EAElD,IADsB,cAAc,MAAM,MAAM,YAAY,EAAE,SAAS,eAAe,OAAO,CAC7E,GAAG;EACnB,MAAM,kBAAkB,cAAc,MACnC,QAAQ,IAAI,UAAU,YAAY,IAAI,SAAS,eAAe,OAAO,CACxE;EACA,IAAI,iBAAiB;GACnB,gBAAgB,cAAc,QAAQ,QAAQ,QAAQ,eAAe;GACrE,cAAc,KACZ,IAAI,YAAY;IACd,SAAS,gBAAgB;IACzB,GAAI,gBAAgB,SAAS,KAAA,IAAY,EAAE,MAAM,gBAAgB,KAAK,IAAI,CAAC;GAC7E,CAAC,CACH;EACF;CACF;CAGA,KAAK,MAAM,iBAAiB,MAAM,iBAAiB;EACjD,IAAI,cAAc,SAAS,KAAA,KAAa,cAAc,YAAY,KAAA,GAAW;EAI7E,IAHsB,cAAc,MAAM,QACxC,YAAY,IAAI,SAAS,cAAc,OAAO,CAEhC,GAAG;EACnB,MAAM,mBAAmB,cAAc,MAAM,MAC3C,YAAY,EAAE,SAAS,cAAc,OAAO,CAC9C;EACA,IAAI,kBACF,cAAc,KAAK,IAAI,WAAW;GAAE,SAAS,iBAAiB;GAAS,QAAQ;E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AS,OAAO,CAClE,GACd,OAAO;CAET,OAAO,QAAQ,MAAM,UAAU,MAAM,UAAU,YAAY,MAAM,SAAS,OAAO,CAAC;AACpF;;;;;;AAOA,SAAgB,iBACd,SACA,SACA,SACS;CAET,IADyB,QAAQ,MAAM,UAAU,YAAY,MAAM,SAAS,OAAO,CAChE,GACjB,OAAO;CAET,OAAO,QAAQ,MAAM,WAAW,YAAY,OAAO,SAAS,OAAO,CAAC;AACtE"}
1
+ {"version":3,"file":"diff.mjs","names":[],"sources":["../src/core/diff/sql-schema-diff.ts"],"sourcesContent":["/**\n * Shared relational-diff types and helpers. The coordinate-based issue diff\n * this module used to house (`collectSqlSchemaIssues` /\n * `collectSqlSchemaIssuesPerNamespace`) retired once the migration planner\n * took `plan(start, end)` over the one differ (`buildPostgresPlanDiff` /\n * `buildSqlitePlanDiff`); what remains here is consumed by the surviving\n * verify verdict (`schema-verify.ts`) and the control adapters.\n */\n\nimport type { ColumnDefault } from '@prisma-next/contract/types';\n\n/**\n * Function type for normalizing raw database default expressions into ColumnDefault.\n * Target-specific implementations handle database dialect differences.\n */\nexport type DefaultNormalizer = (\n rawDefault: string,\n nativeType: string,\n) => ColumnDefault | undefined;\n\n/**\n * Function type for normalizing schema native types to canonical form for comparison.\n * Target-specific implementations handle dialect-specific type name variations\n * (e.g., Postgres 'varchar' → 'character varying', 'timestamptz' normalization).\n */\nexport type NativeTypeNormalizer = (nativeType: string) => string;\n\n/**\n * Compares two arrays of strings for equality (order-sensitive).\n */\nexport function arraysEqual(a: readonly string[], b: readonly string[]): boolean {\n if (a.length !== b.length) {\n return false;\n }\n for (let i = 0; i < a.length; i++) {\n if (a[i] !== b[i]) {\n return false;\n }\n }\n return true;\n}\n"],"mappings":";;;;;AA8BA,SAAgB,YAAY,GAAsB,GAA+B;CAC/E,IAAI,EAAE,WAAW,EAAE,QACjB,OAAO;CAET,KAAK,IAAI,IAAI,GAAG,IAAI,EAAE,QAAQ,KAC5B,IAAI,EAAE,OAAO,EAAE,IACb,OAAO;CAGX,OAAO;AACT"}
@@ -1,4 +1,4 @@
1
- import { f as SqlMigrationPlanOperation, w as SqlPlanTargetDetails } from "./types-BW7pzb2j.mjs";
1
+ import { f as SqlMigrationPlanOperation, w as SqlPlanTargetDetails } from "./types-COTsneBU.mjs";
2
2
  import { Contract } from "@prisma-next/contract/types";
3
3
  import { SqlStorage } from "@prisma-next/sql-contract/types";
4
4
  import { Migration } from "@prisma-next/migration-tools/migration";
@@ -1,4 +1,4 @@
1
- import { r as SqlControlAdapter } from "./control-adapter-BVOj4gXI.mjs";
1
+ import { r as SqlControlAdapter } from "./control-adapter-BeN8TDZ5.mjs";
2
2
  import { ContractSpace, ControlAdapterDescriptor, ControlExtensionDescriptor, MigrationOperationPolicy, MigrationPlan, MigrationPlanOperation, MigrationPlannerConflict, MigrationPlannerFailureResult, MigrationPlannerSuccessResult, MigrationRunnerExecutionChecks, MigrationRunnerFailure, MigrationRunnerPerSpaceSuccessValue, MigrationRunnerResult, OpFactoryCall, OperationContext, SchemaDiffIssue, SchemaOwnership } from "@prisma-next/framework-components/control";
3
3
  import { Contract } from "@prisma-next/contract/types";
4
4
  import { SqlControlDriverInstance, SqlStorage, StorageColumn, StorageTable, StorageTypeInstance } from "@prisma-next/sql-contract/types";
@@ -412,4 +412,4 @@ interface CreateSqlMigrationPlanOptions<TTargetDetails> {
412
412
  }
413
413
  //#endregion
414
414
  export { SqlPlannerSuccessResult as A, SqlMigrationRunnerSuccessValue as C, SqlPlannerConflictLocation as D, SqlPlannerConflictKind as E, SqlPlannerFailureResult as O, SqlMigrationRunnerResult as S, SqlPlannerConflict as T, SqlMigrationRunner as _, FieldEvent as a, SqlMigrationRunnerExecuteOptions as b, SqlControlAdapterDescriptor as c, SqlMigrationPlanContractInfo as d, SqlMigrationPlanOperation as f, SqlMigrationPlannerPlanOptions as g, SqlMigrationPlanner as h, ExpandNativeTypeInput as i, StorageTypePlanResult as j, SqlPlannerResult as k, SqlControlExtensionDescriptor as l, SqlMigrationPlanOperationTarget as m, CodecControlHooks as n, FieldEventContext as o, SqlMigrationPlanOperationStep as p, CreateSqlMigrationPlanOptions as r, ResolveIdentityValueInput as s, AnyRecord as t, SqlMigrationPlan as u, SqlMigrationRunnerErrorCode as v, SqlPlanTargetDetails as w, SqlMigrationRunnerFailure as x, SqlMigrationRunnerExecuteCallbacks as y };
415
- //# sourceMappingURL=types-BW7pzb2j.d.mts.map
415
+ //# sourceMappingURL=types-COTsneBU.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types-BW7pzb2j.d.mts","names":[],"sources":["../src/core/migrations/types.ts"],"mappings":";;;;;;;;;;;KAkCY,SAAA,GAAY,QAAQ,CAAC,MAAA;AAAA,UAEhB,qBAAA;EAAA,SACN,UAAA,WAAqB,yBAAyB,CAAC,cAAA;AAAA;;;AAHnB;UAStB,qBAAA;EAAA,SACN,UAAA;EAAA,SACA,OAAA;EAAA,SACA,UAAA,GAAa,MAAM;AAAA;;;;;AAT0C;AAMxE;;UAaiB,yBAAA;EAAA,SACN,UAAA;EAAA,SACA,OAAA;EAAA,SACA,UAAA,GAAa,MAAM;AAAA;;;AAbA;AAU9B;;;;;;;;;AAG8B;AAiB9B;KAAY,UAAA;;;AAAU;AActB;;;;;;;;;UAAiB,iBAAA;EAAA,SACN,WAAA;EAAA,SACA,SAAA;EAAA,SACA,SAAA;EAAA,SACA,UAAA,GAAa,YAAA;EAAA,SACb,QAAA,GAAW,YAAA;EAAA,SACX,UAAA,GAAa,aAAA;EAAA,SACb,QAAA,GAAW,aAAA;AAAA;AAAA,UAGL,iBAAA;EAHK;;AAAa;AAGnC;;;;;;EAUE,kBAAA,IAAsB,OAAA;IAAA,SACX,QAAA;IAAA,SACA,YAAA,EAAc,mBAAA;IAAA,SACd,QAAA,EAAU,QAAA,CAAS,UAAA;IAAA,SACnB,MAAA,EAAQ,eAAA;IAAA,SACR,UAAA;IAAA,SACA,MAAA,EAAQ,wBAAA;EAAA,MACb,qBAAA,CAAsB,cAA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A;AAAA,UAGe,kBAAA;EAjGiB;;;;;;;;;;;;;EA+GhC,OAAA,CAAQ,OAAA;IAAA,SACG,MAAA,EAAQ,wBAAA;IAAA,SACR,eAAA,EAAiB,aAAA,CAAc,gCAAA,CAAiC,cAAA;EAAA,IACvE,OAAA,CAAQ,qBAAA;EAlHW;;;;;;;;AAiBa;AAGtC;EA0GE,mBAAA,CACE,OAAA,EAAS,gCAAA,CAAiC,cAAA,IACzC,OAAA,CAAQ,wBAAA;AAAA;AAAA,UAGI,6BAAA;EAAA,SACN,QAAA;EA/GsC;;;EAAA,SAmHtC,OAAA;EAAA,SACA,MAAA,GAAS,4BAAA;EAAA,SACT,WAAA,EAAa,4BAAA;EAAA,SACb,UAAA,WAAqB,yBAAA,CAA0B,cAAA;EAtHT;;;AAA+B;AAGhF;EAHiD,SA4HtC,kBAAA;EAAA,SACA,IAAA,GAAO,SAAA;AAAA"}
package/package.json CHANGED
@@ -1,34 +1,34 @@
1
1
  {
2
2
  "name": "@prisma-next/family-sql",
3
- "version": "0.14.0-dev.57",
3
+ "version": "0.14.0-dev.59",
4
4
  "license": "Apache-2.0",
5
5
  "type": "module",
6
6
  "sideEffects": false,
7
7
  "description": "SQL family descriptor for Prisma Next",
8
8
  "dependencies": {
9
- "@prisma-next/contract": "0.14.0-dev.57",
10
- "@prisma-next/emitter": "0.14.0-dev.57",
11
- "@prisma-next/framework-components": "0.14.0-dev.57",
12
- "@prisma-next/migration-tools": "0.14.0-dev.57",
13
- "@prisma-next/operations": "0.14.0-dev.57",
14
- "@prisma-next/sql-contract": "0.14.0-dev.57",
15
- "@prisma-next/sql-contract-emitter": "0.14.0-dev.57",
16
- "@prisma-next/sql-contract-ts": "0.14.0-dev.57",
17
- "@prisma-next/sql-operations": "0.14.0-dev.57",
18
- "@prisma-next/sql-relational-core": "0.14.0-dev.57",
19
- "@prisma-next/sql-runtime": "0.14.0-dev.57",
20
- "@prisma-next/sql-schema-ir": "0.14.0-dev.57",
21
- "@prisma-next/utils": "0.14.0-dev.57",
9
+ "@prisma-next/contract": "0.14.0-dev.59",
10
+ "@prisma-next/emitter": "0.14.0-dev.59",
11
+ "@prisma-next/framework-components": "0.14.0-dev.59",
12
+ "@prisma-next/migration-tools": "0.14.0-dev.59",
13
+ "@prisma-next/operations": "0.14.0-dev.59",
14
+ "@prisma-next/sql-contract": "0.14.0-dev.59",
15
+ "@prisma-next/sql-contract-emitter": "0.14.0-dev.59",
16
+ "@prisma-next/sql-contract-ts": "0.14.0-dev.59",
17
+ "@prisma-next/sql-operations": "0.14.0-dev.59",
18
+ "@prisma-next/sql-relational-core": "0.14.0-dev.59",
19
+ "@prisma-next/sql-runtime": "0.14.0-dev.59",
20
+ "@prisma-next/sql-schema-ir": "0.14.0-dev.59",
21
+ "@prisma-next/utils": "0.14.0-dev.59",
22
22
  "arktype": "^2.2.0"
23
23
  },
24
24
  "devDependencies": {
25
- "@prisma-next/driver-postgres": "0.14.0-dev.57",
26
- "@prisma-next/psl-parser": "0.14.0-dev.57",
27
- "@prisma-next/psl-printer": "0.14.0-dev.57",
28
- "@prisma-next/sql-contract-psl": "0.14.0-dev.57",
29
- "@prisma-next/test-utils": "0.14.0-dev.57",
30
- "@prisma-next/tsconfig": "0.14.0-dev.57",
31
- "@prisma-next/tsdown": "0.14.0-dev.57",
25
+ "@prisma-next/driver-postgres": "0.14.0-dev.59",
26
+ "@prisma-next/psl-parser": "0.14.0-dev.59",
27
+ "@prisma-next/psl-printer": "0.14.0-dev.59",
28
+ "@prisma-next/sql-contract-psl": "0.14.0-dev.59",
29
+ "@prisma-next/test-utils": "0.14.0-dev.59",
30
+ "@prisma-next/tsconfig": "0.14.0-dev.59",
31
+ "@prisma-next/tsdown": "0.14.0-dev.59",
32
32
  "tsdown": "0.22.1",
33
33
  "typescript": "5.9.3",
34
34
  "vitest": "4.1.8"
@@ -1,14 +1,13 @@
1
1
  /**
2
- * Shared relational-diff types and semantic-satisfaction predicates. The
3
- * coordinate-based issue diff this module used to house (`collectSqlSchemaIssues`
4
- * / `collectSqlSchemaIssuesPerNamespace`) retired once the migration planner
2
+ * Shared relational-diff types and helpers. The coordinate-based issue diff
3
+ * this module used to house (`collectSqlSchemaIssues` /
4
+ * `collectSqlSchemaIssuesPerNamespace`) retired once the migration planner
5
5
  * took `plan(start, end)` over the one differ (`buildPostgresPlanDiff` /
6
6
  * `buildSqlitePlanDiff`); what remains here is consumed by the surviving
7
7
  * verify verdict (`schema-verify.ts`) and the control adapters.
8
8
  */
9
9
 
10
10
  import type { ColumnDefault } from '@prisma-next/contract/types';
11
- import type { SqlIndexIR, SqlUniqueIR } from '@prisma-next/sql-schema-ir/types';
12
11
 
13
12
  /**
14
13
  * Function type for normalizing raw database default expressions into ColumnDefault.
@@ -40,38 +39,3 @@ export function arraysEqual(a: readonly string[], b: readonly string[]): boolean
40
39
  }
41
40
  return true;
42
41
  }
43
-
44
- /**
45
- * Checks if a unique constraint requirement is satisfied by the given columns:
46
- * a unique constraint with the same columns, or a unique index with the same
47
- * columns (semantic satisfaction). Used by the planners to keep the
48
- * "stronger satisfies weaker" behavior consistent across the control plane.
49
- */
50
- export function isUniqueConstraintSatisfied(
51
- uniques: readonly SqlUniqueIR[],
52
- indexes: readonly SqlIndexIR[],
53
- columns: readonly string[],
54
- ): boolean {
55
- const hasConstraint = uniques.some((unique) => arraysEqual(unique.columns, columns));
56
- if (hasConstraint) {
57
- return true;
58
- }
59
- return indexes.some((index) => index.unique && arraysEqual(index.columns, columns));
60
- }
61
-
62
- /**
63
- * Checks if an index requirement is satisfied by the given columns: any index
64
- * (unique or non-unique) with the same columns, or a unique constraint with
65
- * the same columns (stronger satisfies weaker).
66
- */
67
- export function isIndexSatisfied(
68
- indexes: readonly SqlIndexIR[],
69
- uniques: readonly SqlUniqueIR[],
70
- columns: readonly string[],
71
- ): boolean {
72
- const hasMatchingIndex = indexes.some((index) => arraysEqual(index.columns, columns));
73
- if (hasMatchingIndex) {
74
- return true;
75
- }
76
- return uniques.some((unique) => arraysEqual(unique.columns, columns));
77
- }
@@ -251,11 +251,23 @@ function convertIndex(index: Index): SqlIndexIRInput {
251
251
  };
252
252
  }
253
253
 
254
- function convertForeignKey(fk: ForeignKey): SqlForeignKeyIRInput {
254
+ /**
255
+ * The FK's referenced-namespace identity comes from the target's namespace
256
+ * node, not the raw namespace-id string. An unbound target namespace stamps
257
+ * no `referencedSchema` at all — the FK node's id renders the absence as the
258
+ * empty segment, which is what flat (single-schema) introspection produces,
259
+ * so both diff sides' FK ids meet by construction. A bound namespace (or a
260
+ * cross-space target whose namespace lives in another contract's storage)
261
+ * stamps its coordinate verbatim; namespaced targets (Postgres) resolve the
262
+ * real DDL schema downstream.
263
+ */
264
+ function convertForeignKey(fk: ForeignKey, storage: SqlStorage): SqlForeignKeyIRInput {
265
+ const targetNamespace = storage.namespaces[fk.target.namespaceId];
266
+ const targetIsUnbound = targetNamespace?.isUnbound === true;
255
267
  return {
256
268
  columns: fk.source.columns,
257
269
  referencedTable: fk.target.tableName,
258
- referencedSchema: fk.target.namespaceId,
270
+ ...(targetIsUnbound ? {} : { referencedSchema: fk.target.namespaceId }),
259
271
  referencedColumns: fk.target.columns,
260
272
  ...ifDefined('name', fk.name),
261
273
  ...ifDefined('onDelete', fk.onDelete),
@@ -309,7 +321,9 @@ function convertTable(
309
321
  name,
310
322
  columns,
311
323
  ...ifDefined('primaryKey', table.primaryKey),
312
- foreignKeys: table.foreignKeys.filter((fk) => fk.constraint !== false).map(convertForeignKey),
324
+ foreignKeys: table.foreignKeys
325
+ .filter((fk) => fk.constraint !== false)
326
+ .map((fk) => convertForeignKey(fk, storage)),
313
327
  uniques: table.uniques.map(convertUnique),
314
328
  indexes: [...table.indexes.map(convertIndex), ...fkBackingIndexes],
315
329
  ...ifDefined('checks', checks),
@@ -2,20 +2,11 @@
2
2
  * SQL relational schema-diff exports.
3
3
  *
4
4
  * The generic node differ (`buildPostgresPlanDiff` / `buildSqlitePlanDiff`)
5
- * drives both plan and verify; this module surfaces the shared
6
- * semantic-satisfaction predicates and verify-verdict machinery that survive
7
- * it. Pure — no database connection required.
5
+ * drives both plan and verify over the trees as derived — no pre-diff
6
+ * transformation. This module surfaces the verify-verdict machinery. Pure
7
+ * no database connection required.
8
8
  */
9
9
 
10
- export type {
11
- SemanticSatisfactionInput,
12
- SemanticSatisfactionResult,
13
- } from '../core/diff/diff-tree-normalization';
14
- export {
15
- neutralizeFlatExpectedFkSchemas,
16
- normalizeFlatActualForDiff,
17
- resolveSemanticSatisfaction,
18
- } from '../core/diff/diff-tree-normalization';
19
10
  export type {
20
11
  SqlDiffVerdict,
21
12
  SqlDiffVerdictInput,
@@ -31,8 +22,4 @@ export {
31
22
  verifySqlSchemaByDiff,
32
23
  } from '../core/diff/schema-verify';
33
24
  export type { NativeTypeNormalizer } from '../core/diff/sql-schema-diff';
34
- export {
35
- arraysEqual,
36
- isIndexSatisfied,
37
- isUniqueConstraintSatisfied,
38
- } from '../core/diff/sql-schema-diff';
25
+ export { arraysEqual } from '../core/diff/sql-schema-diff';
@@ -1 +0,0 @@
1
- {"version":3,"file":"control-adapter-BVOj4gXI.d.mts","names":[],"sources":["../src/core/diff/sql-schema-diff.ts","../src/core/control-adapter.ts"],"mappings":";;;;;;;;;;;KAgBY,iBAAA,IACV,UAAA,UACA,UAAA,aACG,aAAa;AAAA;AAOlB;;;;AAPkB,KAON,oBAAA,IAAwB,UAAkB;AAKtD;;;AAAA,iBAAgB,WAAA,CAAY,CAAA,qBAAsB,CAAoB;AAAA;AAkBtE;;;;;AAlBsE,iBAkBtD,2BAAA,CACd,OAAA,WAAkB,WAAA,IAClB,OAAA,WAAkB,UAAU,IAC5B,OAAA;;;;;AAA0B;iBAcZ,gBAAA,CACd,OAAA,WAAkB,UAAA,IAClB,OAAA,WAAkB,WAAW,IAC7B,OAAA;;;;AArDF;;;;;;UCOiB,OAAA;EACf,KAAA,CAAM,GAAA,EAAK,WAAA,GAAc,OAAA,EAAS,OAAA,EAAS,cAAA,YAA0B,gBAAA;AAAA;ADEv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