@prisma-next/family-sql 0.14.0-dev.49 → 0.14.0-dev.50
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/{control-adapter-DHYFuOBy.d.mts → control-adapter-BVOj4gXI.d.mts} +34 -5
- package/dist/control-adapter-BVOj4gXI.d.mts.map +1 -0
- package/dist/control-adapter.d.mts +1 -1
- package/dist/control.d.mts +65 -50
- package/dist/control.d.mts.map +1 -1
- package/dist/control.mjs +308 -56
- package/dist/control.mjs.map +1 -1
- package/dist/diff.d.mts +141 -30
- package/dist/diff.d.mts.map +1 -1
- package/dist/diff.mjs +155 -1384
- package/dist/diff.mjs.map +1 -1
- package/dist/ir.d.mts +5 -5
- package/dist/ir.d.mts.map +1 -1
- package/dist/ir.mjs +2 -2
- package/dist/ir.mjs.map +1 -1
- package/dist/migration.d.mts +1 -1
- package/dist/schema-differ-DnoopSXm.d.mts +45 -0
- package/dist/schema-differ-DnoopSXm.d.mts.map +1 -0
- package/dist/schema-verify-W3r631Jh.mjs +226 -0
- package/dist/schema-verify-W3r631Jh.mjs.map +1 -0
- package/dist/{sql-contract-serializer-DwUSJ4PO.mjs → sql-contract-serializer-C75cfMSS.mjs} +2 -2
- package/dist/{sql-contract-serializer-DwUSJ4PO.mjs.map → sql-contract-serializer-C75cfMSS.mjs.map} +1 -1
- package/dist/{types-DBxrwN1d.d.mts → types-BW7pzb2j.d.mts} +24 -15
- package/dist/types-BW7pzb2j.d.mts.map +1 -0
- package/package.json +21 -21
- package/src/core/control-instance.ts +99 -80
- package/src/core/control-target-descriptor.ts +29 -14
- package/src/core/diff/diff-tree-normalization.ts +211 -0
- package/src/core/diff/schema-verify.ts +324 -0
- package/src/core/diff/sql-schema-diff.ts +40 -1466
- package/src/core/diff/verifier-disposition.ts +14 -42
- package/src/core/ir/sql-schema-verifier-base.ts +5 -5
- package/src/core/migrations/contract-to-schema-ir.ts +63 -20
- package/src/core/migrations/native-type-expander.ts +28 -0
- package/src/core/migrations/schema-differ.ts +30 -29
- package/src/core/migrations/types.ts +23 -14
- package/src/exports/control.ts +6 -0
- package/src/exports/diff.ts +28 -8
- package/dist/contract-to-schema-ir-S-evq8E6.mjs +0 -264
- package/dist/contract-to-schema-ir-S-evq8E6.mjs.map +0 -1
- package/dist/control-adapter-DHYFuOBy.d.mts.map +0 -1
- package/dist/sql-schema-diff-6z36dZt6.d.mts +0 -105
- package/dist/sql-schema-diff-6z36dZt6.d.mts.map +0 -1
- package/dist/types-DBxrwN1d.d.mts.map +0 -1
- package/src/core/diff/control-verify-emit.ts +0 -46
- package/src/core/diff/verify-helpers.ts +0 -832
|
@@ -1,264 +0,0 @@
|
|
|
1
|
-
import { assertUniqueCodecOwner } from "@prisma-next/framework-components/control";
|
|
2
|
-
import { defaultIndexName } from "@prisma-next/sql-schema-ir/naming";
|
|
3
|
-
import { ifDefined } from "@prisma-next/utils/defined";
|
|
4
|
-
import { StorageTable, isStorageTypeInstance } from "@prisma-next/sql-contract/types";
|
|
5
|
-
//#region src/core/assembly.ts
|
|
6
|
-
function hasCodecControlHooks(descriptor) {
|
|
7
|
-
if (typeof descriptor !== "object" || descriptor === null) return false;
|
|
8
|
-
const hooks = descriptor.types?.codecTypes?.controlPlaneHooks;
|
|
9
|
-
return hooks !== null && hooks !== void 0 && typeof hooks === "object";
|
|
10
|
-
}
|
|
11
|
-
function extractCodecControlHooks(descriptors) {
|
|
12
|
-
const hooks = /* @__PURE__ */ new Map();
|
|
13
|
-
const owners = /* @__PURE__ */ new Map();
|
|
14
|
-
for (const descriptor of descriptors) {
|
|
15
|
-
if (typeof descriptor !== "object" || descriptor === null) continue;
|
|
16
|
-
if (!hasCodecControlHooks(descriptor)) continue;
|
|
17
|
-
const controlPlaneHooks = descriptor.types.codecTypes.controlPlaneHooks;
|
|
18
|
-
for (const [codecId, hook] of Object.entries(controlPlaneHooks)) {
|
|
19
|
-
assertUniqueCodecOwner({
|
|
20
|
-
codecId,
|
|
21
|
-
owners,
|
|
22
|
-
descriptorId: descriptor.id,
|
|
23
|
-
entityLabel: "control hooks",
|
|
24
|
-
entityOwnershipLabel: "owner"
|
|
25
|
-
});
|
|
26
|
-
hooks.set(codecId, hook);
|
|
27
|
-
owners.set(codecId, descriptor.id);
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
return hooks;
|
|
31
|
-
}
|
|
32
|
-
//#endregion
|
|
33
|
-
//#region src/core/migrations/contract-to-schema-ir.ts
|
|
34
|
-
function convertColumn(name, column, storageTypes, expandNativeType, renderDefault) {
|
|
35
|
-
const resolved = resolveColumnTypeMetadata(column, storageTypes);
|
|
36
|
-
const baseNativeType = expandNativeType ? expandNativeType({
|
|
37
|
-
nativeType: resolved.nativeType,
|
|
38
|
-
codecId: resolved.codecId,
|
|
39
|
-
...ifDefined("typeParams", resolved.typeParams)
|
|
40
|
-
}) : resolved.nativeType;
|
|
41
|
-
return {
|
|
42
|
-
name,
|
|
43
|
-
nativeType: column.many ? `${baseNativeType}[]` : baseNativeType,
|
|
44
|
-
nullable: column.nullable,
|
|
45
|
-
...ifDefined("default", column.default != null && renderDefault ? renderDefault(column.default, column) : void 0)
|
|
46
|
-
};
|
|
47
|
-
}
|
|
48
|
-
function resolveColumnTypeMetadata(column, storageTypes) {
|
|
49
|
-
if (!column.typeRef) return column;
|
|
50
|
-
const referenced = storageTypes[column.typeRef];
|
|
51
|
-
if (!referenced) throw new Error(`Column references storage type "${column.typeRef}" but it is not defined in storage.types.`);
|
|
52
|
-
if (isStorageTypeInstance(referenced)) return {
|
|
53
|
-
codecId: referenced.codecId,
|
|
54
|
-
nativeType: referenced.nativeType,
|
|
55
|
-
typeParams: referenced.typeParams
|
|
56
|
-
};
|
|
57
|
-
throw new Error(`Storage type "${column.typeRef}" has an unknown polymorphic kind; expected a codec-typed StorageTypeInstance.`);
|
|
58
|
-
}
|
|
59
|
-
/**
|
|
60
|
-
* Resolves a `ValueSetRef` to its permitted values from the contract storage.
|
|
61
|
-
*
|
|
62
|
-
* Throws when the referenced namespace or value-set is absent — this indicates
|
|
63
|
-
* the contract was built incorrectly (the check and the value-set must be
|
|
64
|
-
* co-emitted by the lowering step). Used by `convertCheck` (schema-IR
|
|
65
|
-
* projection), `verifyCheckConstraints` (verification), and
|
|
66
|
-
* `checkConstraintPlanCallStrategy` (migration planning) so all three agree on
|
|
67
|
-
* the resolved values and the error behavior on a missing reference.
|
|
68
|
-
*/
|
|
69
|
-
function allStrings(values) {
|
|
70
|
-
return values.every((value) => typeof value === "string");
|
|
71
|
-
}
|
|
72
|
-
function resolveValueSetValues(ref, storage, contextLabel) {
|
|
73
|
-
const ns = storage.namespaces[ref.namespaceId];
|
|
74
|
-
if (!ns) throw new Error(`resolveValueSetValues: namespace "${ref.namespaceId}" not found in storage (${contextLabel})`);
|
|
75
|
-
const valueSet = ns.entries.valueSet?.[ref.entityName];
|
|
76
|
-
if (!valueSet) throw new Error(`resolveValueSetValues: value-set "${ref.entityName}" not found in namespace "${ref.namespaceId}" (${contextLabel})`);
|
|
77
|
-
const values = valueSet.values;
|
|
78
|
-
if (!allStrings(values)) throw new Error(`resolveValueSetValues: value-set "${ref.entityName}" in namespace "${ref.namespaceId}" has a non-string value; numeric-enum CHECK constraints are not yet supported (${contextLabel})`);
|
|
79
|
-
return values;
|
|
80
|
-
}
|
|
81
|
-
/**
|
|
82
|
-
* Projects a `CheckConstraint` IR into an `SqlCheckConstraintIRInput` by
|
|
83
|
-
* resolving the permitted values from the storage value-set it references.
|
|
84
|
-
*
|
|
85
|
-
* The `CheckConstraint.valueSet` ref points to
|
|
86
|
-
* `storage.namespaces[namespaceId].entries.valueSet[name]`. The resolved
|
|
87
|
-
* values are lifted directly from `StorageValueSet.values` so verification
|
|
88
|
-
* compares value sets, not SQL predicate strings.
|
|
89
|
-
*
|
|
90
|
-
* Throws if the referenced namespace or value-set is absent — this
|
|
91
|
-
* indicates the contract was built incorrectly (the check and the
|
|
92
|
-
* value-set must be co-emitted by the lowering step).
|
|
93
|
-
*/
|
|
94
|
-
function convertCheck(check, storage) {
|
|
95
|
-
const permittedValues = resolveValueSetValues(check.valueSet, storage, `check "${check.name}"`);
|
|
96
|
-
return {
|
|
97
|
-
name: check.name,
|
|
98
|
-
column: check.column,
|
|
99
|
-
permittedValues
|
|
100
|
-
};
|
|
101
|
-
}
|
|
102
|
-
function convertUnique(unique) {
|
|
103
|
-
return {
|
|
104
|
-
columns: unique.columns,
|
|
105
|
-
...ifDefined("name", unique.name)
|
|
106
|
-
};
|
|
107
|
-
}
|
|
108
|
-
function convertIndex(index) {
|
|
109
|
-
return {
|
|
110
|
-
columns: index.columns,
|
|
111
|
-
unique: false,
|
|
112
|
-
...ifDefined("name", index.name)
|
|
113
|
-
};
|
|
114
|
-
}
|
|
115
|
-
function convertForeignKey(fk) {
|
|
116
|
-
return {
|
|
117
|
-
columns: fk.source.columns,
|
|
118
|
-
referencedTable: fk.target.tableName,
|
|
119
|
-
referencedSchema: fk.target.namespaceId,
|
|
120
|
-
referencedColumns: fk.target.columns,
|
|
121
|
-
...ifDefined("name", fk.name),
|
|
122
|
-
...ifDefined("onDelete", fk.onDelete),
|
|
123
|
-
...ifDefined("onUpdate", fk.onUpdate)
|
|
124
|
-
};
|
|
125
|
-
}
|
|
126
|
-
function convertTable(name, table, storageTypes, expandNativeType, renderDefault, storage) {
|
|
127
|
-
const columns = {};
|
|
128
|
-
for (const [colName, colDef] of Object.entries(table.columns)) columns[colName] = convertColumn(colName, colDef, storageTypes, expandNativeType, renderDefault);
|
|
129
|
-
const satisfiedIndexColumns = new Set([
|
|
130
|
-
...table.indexes.map((idx) => idx.columns.join(",")),
|
|
131
|
-
...table.uniques.map((unique) => unique.columns.join(",")),
|
|
132
|
-
...table.primaryKey ? [table.primaryKey.columns.join(",")] : []
|
|
133
|
-
]);
|
|
134
|
-
const fkBackingIndexes = [];
|
|
135
|
-
for (const fk of table.foreignKeys) {
|
|
136
|
-
if (fk.index === false) continue;
|
|
137
|
-
const key = fk.source.columns.join(",");
|
|
138
|
-
if (satisfiedIndexColumns.has(key)) continue;
|
|
139
|
-
fkBackingIndexes.push({
|
|
140
|
-
columns: fk.source.columns,
|
|
141
|
-
unique: false,
|
|
142
|
-
name: defaultIndexName(name, fk.source.columns)
|
|
143
|
-
});
|
|
144
|
-
satisfiedIndexColumns.add(key);
|
|
145
|
-
}
|
|
146
|
-
const checks = table.checks && table.checks.length > 0 ? table.checks.map((c) => convertCheck(c, storage)) : void 0;
|
|
147
|
-
return {
|
|
148
|
-
name,
|
|
149
|
-
columns,
|
|
150
|
-
...ifDefined("primaryKey", table.primaryKey),
|
|
151
|
-
foreignKeys: table.foreignKeys.filter((fk) => fk.constraint !== false).map(convertForeignKey),
|
|
152
|
-
uniques: table.uniques.map(convertUnique),
|
|
153
|
-
indexes: [...table.indexes.map(convertIndex), ...fkBackingIndexes],
|
|
154
|
-
...ifDefined("checks", checks)
|
|
155
|
-
};
|
|
156
|
-
}
|
|
157
|
-
/**
|
|
158
|
-
* Detects destructive changes between two contract storages.
|
|
159
|
-
*
|
|
160
|
-
* The additive-only planner silently ignores removals (tables, columns).
|
|
161
|
-
* This function detects those removals so callers can report them as conflicts
|
|
162
|
-
* rather than silently producing an empty plan.
|
|
163
|
-
*
|
|
164
|
-
* Returns an empty array if no destructive changes are found.
|
|
165
|
-
*/
|
|
166
|
-
function detectDestructiveChanges(from, to) {
|
|
167
|
-
if (!from) return [];
|
|
168
|
-
const hasOwn = (value, key) => Object.hasOwn(value, key);
|
|
169
|
-
const conflicts = [];
|
|
170
|
-
const namespaceIds = [...new Set([...Object.keys(from.namespaces), ...Object.keys(to.namespaces)])].sort((a, b) => a < b ? -1 : a > b ? 1 : 0);
|
|
171
|
-
for (const namespaceId of namespaceIds) {
|
|
172
|
-
const fromNs = from.namespaces[namespaceId];
|
|
173
|
-
const toNs = to.namespaces[namespaceId];
|
|
174
|
-
const fromTables = fromNs?.entries.table;
|
|
175
|
-
if (!fromTables) continue;
|
|
176
|
-
for (const tableName of Object.keys(fromTables)) {
|
|
177
|
-
const toTableRaw = toNs?.entries.table?.[tableName];
|
|
178
|
-
if (!StorageTable.is(toTableRaw)) {
|
|
179
|
-
conflicts.push({
|
|
180
|
-
kind: "tableRemoved",
|
|
181
|
-
summary: `Table "${tableName}" was removed`
|
|
182
|
-
});
|
|
183
|
-
continue;
|
|
184
|
-
}
|
|
185
|
-
const toTable = toTableRaw;
|
|
186
|
-
const fromTableRaw = fromTables[tableName];
|
|
187
|
-
if (!StorageTable.is(fromTableRaw)) continue;
|
|
188
|
-
const fromTable = fromTableRaw;
|
|
189
|
-
for (const columnName of Object.keys(fromTable.columns)) if (!hasOwn(toTable.columns, columnName)) conflicts.push({
|
|
190
|
-
kind: "columnRemoved",
|
|
191
|
-
summary: `Column "${tableName}"."${columnName}" was removed`
|
|
192
|
-
});
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
return conflicts;
|
|
196
|
-
}
|
|
197
|
-
/**
|
|
198
|
-
* Converts a `Contract` to `SqlSchemaIR`.
|
|
199
|
-
*
|
|
200
|
-
* Reads `contract.storage` for tables and `contract.storage.types` for type
|
|
201
|
-
* annotations. Storage-type annotations are written under
|
|
202
|
-
* `options.annotationNamespace`.
|
|
203
|
-
*
|
|
204
|
-
* Drops codec metadata (`codecId`, `typeRef`) since the schema IR only represents
|
|
205
|
-
* structural information. When `expandNativeType` is provided, parameterized types
|
|
206
|
-
* are expanded (e.g. `character` + `{ length: 36 }` → `character(36)`) so the
|
|
207
|
-
* resulting IR compares correctly against the "to" contract during planning.
|
|
208
|
-
*
|
|
209
|
-
* Returns an empty schema IR when `contract` is `null` (new project).
|
|
210
|
-
*/
|
|
211
|
-
/**
|
|
212
|
-
* Converts the tables of a single namespace into a `SqlSchemaIR`, keyed by
|
|
213
|
-
* table name within that namespace. Unlike {@link contractToSchemaIR}, which
|
|
214
|
-
* flattens every namespace's tables into one bare-keyed record (and throws on a
|
|
215
|
-
* cross-namespace name collision), this scopes the table iteration to one
|
|
216
|
-
* namespace so the same table name can exist in two schemas.
|
|
217
|
-
*
|
|
218
|
-
* The full `storage` is still passed to `convertTable`, so value-set / enum /
|
|
219
|
-
* type resolution that legitimately spans namespaces is unaffected. Foreign
|
|
220
|
-
* keys are built purely from the FK descriptor (`fk.target`), so cross-namespace
|
|
221
|
-
* FKs survive per-namespace conversion. The `annotations` block (storage-type
|
|
222
|
-
* derived) is omitted here — the per-namespace tree consumer reads only the
|
|
223
|
-
* per-table fields.
|
|
224
|
-
*/
|
|
225
|
-
function contractNamespaceToSchemaIR(storage, namespaceId, options) {
|
|
226
|
-
if (options.annotationNamespace.length === 0) throw new Error("annotationNamespace must be a non-empty string");
|
|
227
|
-
const namespace = storage.namespaces[namespaceId];
|
|
228
|
-
if (!namespace) return { tables: {} };
|
|
229
|
-
const storageTypes = { ...storage.types ?? {} };
|
|
230
|
-
const tables = {};
|
|
231
|
-
for (const [tableName, tableDefRaw] of Object.entries(namespace.entries.table ?? {})) {
|
|
232
|
-
StorageTable.assert(tableDefRaw, `namespaces.${namespaceId}.entries.table.${tableName}`);
|
|
233
|
-
tables[tableName] = convertTable(tableName, tableDefRaw, storageTypes, options.expandNativeType, options.renderDefault, storage);
|
|
234
|
-
}
|
|
235
|
-
return { tables };
|
|
236
|
-
}
|
|
237
|
-
function contractToSchemaIR(contract, options) {
|
|
238
|
-
if (options.annotationNamespace.length === 0) throw new Error("annotationNamespace must be a non-empty string");
|
|
239
|
-
if (!contract) return { tables: {} };
|
|
240
|
-
const storage = contract.storage;
|
|
241
|
-
const storageTypes = { ...storage.types ?? {} };
|
|
242
|
-
const tables = {};
|
|
243
|
-
for (const ns of Object.values(storage.namespaces)) for (const [tableName, tableDefRaw] of Object.entries(ns.entries.table ?? {})) {
|
|
244
|
-
StorageTable.assert(tableDefRaw, `namespaces.${ns.id}.entries.table.${tableName}`);
|
|
245
|
-
const tableDef = tableDefRaw;
|
|
246
|
-
if (tables[tableName] !== void 0) throw new Error(`contractToSchemaIR: duplicate SQL table name "${tableName}" across namespaces (ambiguous for flat SqlSchemaIR.tables).`);
|
|
247
|
-
tables[tableName] = convertTable(tableName, tableDef, storageTypes, options.expandNativeType, options.renderDefault, storage);
|
|
248
|
-
}
|
|
249
|
-
return {
|
|
250
|
-
tables,
|
|
251
|
-
...ifDefined("annotations", deriveAnnotations(storage, options.annotationNamespace, options.resolveEnumNamespaceSchema))
|
|
252
|
-
};
|
|
253
|
-
}
|
|
254
|
-
function deriveAnnotations(storage, annotationNamespace, _resolveEnumNamespaceSchema) {
|
|
255
|
-
const storageTypes = {};
|
|
256
|
-
for (const typeInstance of Object.values(storage.types ?? {})) if (isStorageTypeInstance(typeInstance)) storageTypes[typeInstance.nativeType] = typeInstance;
|
|
257
|
-
const envelope = { ...Object.keys(storageTypes).length > 0 ? { storageTypes } : {} };
|
|
258
|
-
if (Object.keys(envelope).length === 0) return void 0;
|
|
259
|
-
return { [annotationNamespace]: envelope };
|
|
260
|
-
}
|
|
261
|
-
//#endregion
|
|
262
|
-
export { extractCodecControlHooks as a, resolveValueSetValues as i, contractToSchemaIR as n, detectDestructiveChanges as r, contractNamespaceToSchemaIR as t };
|
|
263
|
-
|
|
264
|
-
//# sourceMappingURL=contract-to-schema-ir-S-evq8E6.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"contract-to-schema-ir-S-evq8E6.mjs","names":["d"],"sources":["../src/core/assembly.ts","../src/core/migrations/contract-to-schema-ir.ts"],"sourcesContent":["import type { TargetBoundComponentDescriptor } from '@prisma-next/framework-components/components';\nimport { assertUniqueCodecOwner } from '@prisma-next/framework-components/control';\nimport type { CodecControlHooks } from './migrations/types';\n\ntype CodecControlHooksMap = Record<string, CodecControlHooks>;\n\nfunction hasCodecControlHooks(descriptor: unknown): descriptor is {\n readonly id: string;\n readonly types: {\n readonly codecTypes: {\n readonly controlPlaneHooks: CodecControlHooksMap;\n };\n };\n} {\n if (typeof descriptor !== 'object' || descriptor === null) {\n return false;\n }\n const d = descriptor as { types?: { codecTypes?: { controlPlaneHooks?: unknown } } };\n const hooks = d.types?.codecTypes?.controlPlaneHooks;\n return hooks !== null && hooks !== undefined && typeof hooks === 'object';\n}\n\nexport function extractCodecControlHooks(\n descriptors: ReadonlyArray<TargetBoundComponentDescriptor<'sql', string>>,\n): Map<string, CodecControlHooks> {\n const hooks = new Map<string, CodecControlHooks>();\n const owners = new Map<string, string>();\n\n for (const descriptor of descriptors) {\n if (typeof descriptor !== 'object' || descriptor === null) {\n continue;\n }\n if (!hasCodecControlHooks(descriptor)) {\n continue;\n }\n const controlPlaneHooks = descriptor.types.codecTypes.controlPlaneHooks;\n for (const [codecId, hook] of Object.entries(controlPlaneHooks)) {\n assertUniqueCodecOwner({\n codecId,\n owners,\n descriptorId: descriptor.id,\n entityLabel: 'control hooks',\n entityOwnershipLabel: 'owner',\n });\n hooks.set(codecId, hook);\n owners.set(codecId, descriptor.id);\n }\n }\n\n return hooks;\n}\n","import type { ColumnDefault, Contract, JsonValue } from '@prisma-next/contract/types';\nimport type { MigrationPlannerConflict } from '@prisma-next/framework-components/control';\nimport {\n type CheckConstraint,\n type ForeignKey,\n type Index,\n isStorageTypeInstance,\n type SqlStorage,\n type StorageColumn,\n StorageTable,\n type StorageTypeInstance,\n type UniqueConstraint,\n} from '@prisma-next/sql-contract/types';\nimport { defaultIndexName } from '@prisma-next/sql-schema-ir/naming';\nimport type {\n SqlAnnotations,\n SqlCheckConstraintIRInput,\n SqlColumnIR,\n SqlForeignKeyIR,\n SqlIndexIR,\n SqlSchemaIR,\n SqlTableIR,\n SqlUniqueIR,\n} from '@prisma-next/sql-schema-ir/types';\nimport { ifDefined } from '@prisma-next/utils/defined';\n\n/**\n * Target-specific callback that expands a column's base `nativeType` and optional\n * `typeParams` into the fully-qualified type string used by the database\n * (e.g. `character` + `{ length: 36 }` → `character(36)`).\n *\n * This lives in the family layer as a callback rather than importing a concrete\n * implementation because each target (Postgres, MySQL, SQLite, …) has its own\n * parameterization syntax. The target wires its expander when calling\n * `contractToSchemaIR`, keeping the family layer target-agnostic.\n */\nexport type NativeTypeExpander = (input: {\n readonly nativeType: string;\n readonly codecId?: string;\n readonly typeParams?: Record<string, unknown>;\n}) => string;\n\n/**\n * Target-specific callback that renders a `ColumnDefault` into the raw SQL literal\n * string stored in `SqlColumnIR.default`.\n *\n * Default value serialization is target-specific (quoting, casting, type syntax vary\n * between Postgres, MySQL, SQLite, …). This callback follows the same IoC pattern as\n * `NativeTypeExpander`: the target provides its renderer when calling\n * `contractToSchemaIR`, keeping the family layer target-agnostic.\n */\nexport type DefaultRenderer = (def: ColumnDefault, column: StorageColumn) => string;\n\n/**\n * Target-supplied callback that resolves a contract namespace to the live\n * database schema its enums are stored under.\n *\n * The projected enum annotations are nested by schema\n * (`storageTypes[schema][nativeType]`) so two namespaces holding an enum with\n * the same native type resolve to distinct live-database types. Mapping a\n * namespace to its DDL schema is target-specific (Postgres schemas;\n * SQLite/MySQL differ), so the target injects it here rather than the family\n * importing a concrete `ddlSchemaName`. This keeps the family layer\n * target-agnostic while the projection nests under the same schema the\n * target's read side (`readExistingEnumValues`) looks up.\n */\nexport type EnumNamespaceSchemaResolver = (storage: SqlStorage, namespaceId: string) => string;\n\nfunction convertColumn(\n name: string,\n column: StorageColumn,\n storageTypes: ResolvedStorageTypes,\n expandNativeType: NativeTypeExpander | undefined,\n renderDefault: DefaultRenderer | undefined,\n): SqlColumnIR {\n // Resolve `typeRef` so columns that delegate their `nativeType`/`codecId`/\n // `typeParams` to a named `storage.types` entry expand the same way as\n // columns that inline those fields. Without this resolution, a\n // `typeRef`-based column like `post.embedding → Embedding1536` would\n // render as the bare `\"vector\"` (dropping the `length` parameter), while\n // `verify-sql-schema.ts`'s `renderExpectedNativeType` resolves the\n // typeRef and produces `\"vector(1536)\"` — making diffs on the same\n // contract falsely report a `type_mismatch`.\n const resolved = resolveColumnTypeMetadata(column, storageTypes);\n const baseNativeType = expandNativeType\n ? expandNativeType({\n nativeType: resolved.nativeType,\n codecId: resolved.codecId,\n ...ifDefined('typeParams', resolved.typeParams),\n })\n : resolved.nativeType;\n const nativeType = column.many ? `${baseNativeType}[]` : baseNativeType;\n return {\n name,\n nativeType,\n nullable: column.nullable,\n ...ifDefined(\n 'default',\n column.default != null && renderDefault ? renderDefault(column.default, column) : undefined,\n ),\n };\n}\n\ntype ResolvedStorageTypes = Readonly<Record<string, StorageTypeInstance>>;\n\nfunction resolveColumnTypeMetadata(\n column: StorageColumn,\n storageTypes: ResolvedStorageTypes,\n): Pick<StorageColumn, 'codecId' | 'nativeType' | 'typeParams'> {\n if (!column.typeRef) {\n return column;\n }\n const referenced = storageTypes[column.typeRef];\n if (!referenced) {\n throw new Error(\n `Column references storage type \"${column.typeRef}\" but it is not defined in storage.types.`,\n );\n }\n if (isStorageTypeInstance(referenced)) {\n return {\n codecId: referenced.codecId,\n nativeType: referenced.nativeType,\n typeParams: referenced.typeParams,\n };\n }\n throw new Error(\n `Storage type \"${column.typeRef}\" has an unknown polymorphic kind; expected a codec-typed StorageTypeInstance.`,\n );\n}\n\n/**\n * Resolves a `ValueSetRef` to its permitted values from the contract storage.\n *\n * Throws when the referenced namespace or value-set is absent — this indicates\n * the contract was built incorrectly (the check and the value-set must be\n * co-emitted by the lowering step). Used by `convertCheck` (schema-IR\n * projection), `verifyCheckConstraints` (verification), and\n * `checkConstraintPlanCallStrategy` (migration planning) so all three agree on\n * the resolved values and the error behavior on a missing reference.\n */\nfunction allStrings(values: readonly JsonValue[]): values is readonly string[] {\n return values.every((value) => typeof value === 'string');\n}\n\nexport function resolveValueSetValues(\n ref: { readonly namespaceId: string; readonly entityName: string },\n storage: SqlStorage,\n contextLabel: string,\n): readonly string[] {\n const ns = storage.namespaces[ref.namespaceId];\n if (!ns) {\n throw new Error(\n `resolveValueSetValues: namespace \"${ref.namespaceId}\" not found in storage (${contextLabel})`,\n );\n }\n const valueSet = ns.entries.valueSet?.[ref.entityName];\n if (!valueSet) {\n throw new Error(\n `resolveValueSetValues: value-set \"${ref.entityName}\" not found in namespace \"${ref.namespaceId}\" (${contextLabel})`,\n );\n }\n // Only TEXT enums ship a CHECK-constraint round-trip in this slice. A\n // non-string value-set is a numeric enum, whose CHECK rendering/verification\n // is future work; fail loudly rather than emit a wrong numeric-as-text check.\n const values = valueSet.values;\n if (!allStrings(values)) {\n throw new Error(\n `resolveValueSetValues: value-set \"${ref.entityName}\" in namespace \"${ref.namespaceId}\" has a non-string value; numeric-enum CHECK constraints are not yet supported (${contextLabel})`,\n );\n }\n return values;\n}\n\n/**\n * Projects a `CheckConstraint` IR into an `SqlCheckConstraintIRInput` by\n * resolving the permitted values from the storage value-set it references.\n *\n * The `CheckConstraint.valueSet` ref points to\n * `storage.namespaces[namespaceId].entries.valueSet[name]`. The resolved\n * values are lifted directly from `StorageValueSet.values` so verification\n * compares value sets, not SQL predicate strings.\n *\n * Throws if the referenced namespace or value-set is absent — this\n * indicates the contract was built incorrectly (the check and the\n * value-set must be co-emitted by the lowering step).\n */\nfunction convertCheck(check: CheckConstraint, storage: SqlStorage): SqlCheckConstraintIRInput {\n const permittedValues = resolveValueSetValues(check.valueSet, storage, `check \"${check.name}\"`);\n return {\n name: check.name,\n column: check.column,\n permittedValues,\n };\n}\n\nfunction convertUnique(unique: UniqueConstraint): SqlUniqueIR {\n return {\n columns: unique.columns,\n ...ifDefined('name', unique.name),\n };\n}\n\nfunction convertIndex(index: Index): SqlIndexIR {\n return {\n columns: index.columns,\n unique: false,\n ...ifDefined('name', index.name),\n };\n}\n\nfunction convertForeignKey(fk: ForeignKey): SqlForeignKeyIR {\n return {\n columns: fk.source.columns,\n referencedTable: fk.target.tableName,\n referencedSchema: fk.target.namespaceId,\n referencedColumns: fk.target.columns,\n ...ifDefined('name', fk.name),\n ...ifDefined('onDelete', fk.onDelete),\n ...ifDefined('onUpdate', fk.onUpdate),\n };\n}\n\nfunction convertTable(\n name: string,\n table: StorageTable,\n storageTypes: ResolvedStorageTypes,\n expandNativeType: NativeTypeExpander | undefined,\n renderDefault: DefaultRenderer | undefined,\n storage: SqlStorage,\n): SqlTableIR {\n const columns: Record<string, SqlColumnIR> = {};\n for (const [colName, colDef] of Object.entries(table.columns)) {\n columns[colName] = convertColumn(\n colName,\n colDef,\n storageTypes,\n expandNativeType,\n renderDefault,\n );\n }\n\n const satisfiedIndexColumns = new Set([\n ...table.indexes.map((idx) => idx.columns.join(',')),\n ...table.uniques.map((unique) => unique.columns.join(',')),\n ...(table.primaryKey ? [table.primaryKey.columns.join(',')] : []),\n ]);\n const fkBackingIndexes: SqlIndexIR[] = [];\n for (const fk of table.foreignKeys) {\n if (fk.index === false) continue;\n const key = fk.source.columns.join(',');\n if (satisfiedIndexColumns.has(key)) continue;\n fkBackingIndexes.push({\n columns: fk.source.columns,\n unique: false,\n name: defaultIndexName(name, fk.source.columns),\n });\n satisfiedIndexColumns.add(key);\n }\n\n const checks: SqlCheckConstraintIRInput[] | undefined =\n table.checks && table.checks.length > 0\n ? table.checks.map((c) => convertCheck(c, storage))\n : undefined;\n\n return {\n name,\n columns,\n ...ifDefined('primaryKey', table.primaryKey),\n foreignKeys: table.foreignKeys.filter((fk) => fk.constraint !== false).map(convertForeignKey),\n uniques: table.uniques.map(convertUnique),\n indexes: [...table.indexes.map(convertIndex), ...fkBackingIndexes],\n ...ifDefined('checks', checks),\n };\n}\n\n/**\n * Detects destructive changes between two contract storages.\n *\n * The additive-only planner silently ignores removals (tables, columns).\n * This function detects those removals so callers can report them as conflicts\n * rather than silently producing an empty plan.\n *\n * Returns an empty array if no destructive changes are found.\n */\nexport function detectDestructiveChanges(\n from: SqlStorage | null,\n to: SqlStorage,\n): readonly MigrationPlannerConflict[] {\n if (!from) return [];\n\n const hasOwn = (value: object, key: string): boolean => Object.hasOwn(value, key);\n\n const conflicts: MigrationPlannerConflict[] = [];\n\n const namespaceIds = [\n ...new Set([...Object.keys(from.namespaces), ...Object.keys(to.namespaces)]),\n ].sort((a, b) => (a < b ? -1 : a > b ? 1 : 0));\n\n for (const namespaceId of namespaceIds) {\n const fromNs = from.namespaces[namespaceId];\n const toNs = to.namespaces[namespaceId];\n const fromTables = fromNs?.entries.table;\n if (!fromTables) continue;\n\n for (const tableName of Object.keys(fromTables)) {\n const toTableRaw = toNs?.entries.table?.[tableName];\n if (!StorageTable.is(toTableRaw)) {\n conflicts.push({\n kind: 'tableRemoved',\n summary: `Table \"${tableName}\" was removed`,\n });\n continue;\n }\n const toTable = toTableRaw;\n\n const fromTableRaw = fromTables[tableName];\n if (!StorageTable.is(fromTableRaw)) continue;\n const fromTable = fromTableRaw;\n\n for (const columnName of Object.keys(fromTable.columns)) {\n if (!hasOwn(toTable.columns, columnName)) {\n conflicts.push({\n kind: 'columnRemoved',\n summary: `Column \"${tableName}\".\"${columnName}\" was removed`,\n });\n }\n }\n }\n }\n\n return conflicts;\n}\n\nexport interface ContractToSchemaIROptions {\n readonly annotationNamespace: string;\n readonly expandNativeType?: NativeTypeExpander;\n readonly renderDefault?: DefaultRenderer;\n /**\n * Target-supplied resolver mapping a namespace to the live database schema\n * its enums are stored under. When provided (Postgres), namespace-scoped\n * enums are nested by that schema in `enumTypes` so the projection matches\n * the target's `readExistingEnumValues` lookup. Targets without\n * schema-scoped enum storage (SQLite) omit it; enums are absent there.\n */\n readonly resolveEnumNamespaceSchema?: EnumNamespaceSchemaResolver;\n}\n\n/**\n * Converts a `Contract` to `SqlSchemaIR`.\n *\n * Reads `contract.storage` for tables and `contract.storage.types` for type\n * annotations. Storage-type annotations are written under\n * `options.annotationNamespace`.\n *\n * Drops codec metadata (`codecId`, `typeRef`) since the schema IR only represents\n * structural information. When `expandNativeType` is provided, parameterized types\n * are expanded (e.g. `character` + `{ length: 36 }` → `character(36)`) so the\n * resulting IR compares correctly against the \"to\" contract during planning.\n *\n * Returns an empty schema IR when `contract` is `null` (new project).\n */\n/**\n * Converts the tables of a single namespace into a `SqlSchemaIR`, keyed by\n * table name within that namespace. Unlike {@link contractToSchemaIR}, which\n * flattens every namespace's tables into one bare-keyed record (and throws on a\n * cross-namespace name collision), this scopes the table iteration to one\n * namespace so the same table name can exist in two schemas.\n *\n * The full `storage` is still passed to `convertTable`, so value-set / enum /\n * type resolution that legitimately spans namespaces is unaffected. Foreign\n * keys are built purely from the FK descriptor (`fk.target`), so cross-namespace\n * FKs survive per-namespace conversion. The `annotations` block (storage-type\n * derived) is omitted here — the per-namespace tree consumer reads only the\n * per-table fields.\n */\nexport function contractNamespaceToSchemaIR(\n storage: SqlStorage,\n namespaceId: string,\n options: ContractToSchemaIROptions,\n): SqlSchemaIR {\n if (options.annotationNamespace.length === 0) {\n throw new Error('annotationNamespace must be a non-empty string');\n }\n const namespace = storage.namespaces[namespaceId];\n if (!namespace) {\n return { tables: {} };\n }\n const storageTypes: ResolvedStorageTypes = { ...(storage.types ?? {}) };\n const tables: Record<string, SqlTableIR> = {};\n for (const [tableName, tableDefRaw] of Object.entries(namespace.entries.table ?? {})) {\n StorageTable.assert(tableDefRaw, `namespaces.${namespaceId}.entries.table.${tableName}`);\n tables[tableName] = convertTable(\n tableName,\n tableDefRaw,\n storageTypes,\n options.expandNativeType,\n options.renderDefault,\n storage,\n );\n }\n return { tables };\n}\n\nexport function contractToSchemaIR(\n contract: Contract<SqlStorage> | null,\n options: ContractToSchemaIROptions,\n): SqlSchemaIR {\n if (options.annotationNamespace.length === 0) {\n throw new Error('annotationNamespace must be a non-empty string');\n }\n\n if (!contract) {\n return { tables: {} };\n }\n\n const storage = contract.storage;\n const storageTypes: ResolvedStorageTypes = { ...(storage.types ?? {}) };\n const tables: Record<string, SqlTableIR> = {};\n for (const ns of Object.values(storage.namespaces)) {\n for (const [tableName, tableDefRaw] of Object.entries(ns.entries.table ?? {})) {\n StorageTable.assert(tableDefRaw, `namespaces.${ns.id}.entries.table.${tableName}`);\n const tableDef = tableDefRaw;\n if (tables[tableName] !== undefined) {\n throw new Error(\n `contractToSchemaIR: duplicate SQL table name \"${tableName}\" across namespaces (ambiguous for flat SqlSchemaIR.tables).`,\n );\n }\n tables[tableName] = convertTable(\n tableName,\n tableDef,\n storageTypes,\n options.expandNativeType,\n options.renderDefault,\n storage,\n );\n }\n }\n\n const annotations = deriveAnnotations(\n storage,\n options.annotationNamespace,\n options.resolveEnumNamespaceSchema,\n );\n\n return {\n tables,\n ...ifDefined('annotations', annotations),\n };\n}\n\nfunction deriveAnnotations(\n storage: SqlStorage,\n annotationNamespace: string,\n _resolveEnumNamespaceSchema: EnumNamespaceSchemaResolver | undefined,\n): SqlAnnotations | undefined {\n const storageTypes: Record<string, StorageTypeInstance> = {};\n\n for (const typeInstance of Object.values(storage.types ?? {})) {\n if (isStorageTypeInstance(typeInstance)) {\n storageTypes[typeInstance.nativeType] = typeInstance;\n }\n }\n\n const envelope = {\n ...(Object.keys(storageTypes).length > 0 ? { storageTypes } : {}),\n };\n if (Object.keys(envelope).length === 0) return undefined;\n return { [annotationNamespace]: envelope };\n}\n"],"mappings":";;;;;AAMA,SAAS,qBAAqB,YAO5B;CACA,IAAI,OAAO,eAAe,YAAY,eAAe,MACnD,OAAO;CAGT,MAAM,QAAQA,WAAE,OAAO,YAAY;CACnC,OAAO,UAAU,QAAQ,UAAU,KAAA,KAAa,OAAO,UAAU;AACnE;AAEA,SAAgB,yBACd,aACgC;CAChC,MAAM,wBAAQ,IAAI,IAA+B;CACjD,MAAM,yBAAS,IAAI,IAAoB;CAEvC,KAAK,MAAM,cAAc,aAAa;EACpC,IAAI,OAAO,eAAe,YAAY,eAAe,MACnD;EAEF,IAAI,CAAC,qBAAqB,UAAU,GAClC;EAEF,MAAM,oBAAoB,WAAW,MAAM,WAAW;EACtD,KAAK,MAAM,CAAC,SAAS,SAAS,OAAO,QAAQ,iBAAiB,GAAG;GAC/D,uBAAuB;IACrB;IACA;IACA,cAAc,WAAW;IACzB,aAAa;IACb,sBAAsB;GACxB,CAAC;GACD,MAAM,IAAI,SAAS,IAAI;GACvB,OAAO,IAAI,SAAS,WAAW,EAAE;EACnC;CACF;CAEA,OAAO;AACT;;;ACkBA,SAAS,cACP,MACA,QACA,cACA,kB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;;;EAAA,SA0EM,mBAAA,GAAsB,oBAAA;EA9D7B;;;;EAoEF,4BAAA,aAAyC,OAAA;EA9DtC;;;;EAoEH,0BAAA,aAAuC,OAAA;AAAA;;;;;;;UASxB,2BAAA;EA1DZ;;;;;;EAiEH,MAAA,CAAO,KAAA,EAAO,YAAA,QAAoB,OAAA,IAAW,iBAAA,CAAkB,OAAA;AAAA"}
|
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
import { ColumnDefault, Contract } from "@prisma-next/contract/types";
|
|
2
|
-
import { OperationContext, VerifyDatabaseSchemaResult } from "@prisma-next/framework-components/control";
|
|
3
|
-
import { SqlStorage } from "@prisma-next/sql-contract/types";
|
|
4
|
-
import { SqlSchemaIR, SqlSchemaIRNode } from "@prisma-next/sql-schema-ir/types";
|
|
5
|
-
import { TargetBoundComponentDescriptor } from "@prisma-next/framework-components/components";
|
|
6
|
-
|
|
7
|
-
//#region src/core/diff/sql-schema-diff.d.ts
|
|
8
|
-
/**
|
|
9
|
-
* Function type for normalizing raw database default expressions into ColumnDefault.
|
|
10
|
-
* Target-specific implementations handle database dialect differences.
|
|
11
|
-
*/
|
|
12
|
-
type DefaultNormalizer = (rawDefault: string, nativeType: string) => ColumnDefault | undefined;
|
|
13
|
-
/**
|
|
14
|
-
* Function type for normalizing schema native types to canonical form for comparison.
|
|
15
|
-
* Target-specific implementations handle dialect-specific type name variations
|
|
16
|
-
* (e.g., Postgres 'varchar' → 'character varying', 'timestamptz' normalization).
|
|
17
|
-
*/
|
|
18
|
-
type NativeTypeNormalizer = (nativeType: string) => string;
|
|
19
|
-
/**
|
|
20
|
-
* Options for the pure schema verification function.
|
|
21
|
-
*/
|
|
22
|
-
interface VerifySqlSchemaOptions {
|
|
23
|
-
/** The validated SQL contract to verify against */
|
|
24
|
-
readonly contract: Contract<SqlStorage>;
|
|
25
|
-
/** The schema IR from introspection (or another source) */
|
|
26
|
-
readonly schema: SqlSchemaIR;
|
|
27
|
-
/** Whether to run in strict mode (detects extra tables/columns) */
|
|
28
|
-
readonly strict: boolean;
|
|
29
|
-
/** Optional operation context for metadata */
|
|
30
|
-
readonly context?: OperationContext;
|
|
31
|
-
/** Type metadata registry for codec consistency warnings */
|
|
32
|
-
readonly typeMetadataRegistry: ReadonlyMap<string, {
|
|
33
|
-
nativeType?: string;
|
|
34
|
-
}>;
|
|
35
|
-
/**
|
|
36
|
-
* Active framework components participating in this composition.
|
|
37
|
-
* All components must have matching familyId ('sql') and targetId.
|
|
38
|
-
*/
|
|
39
|
-
readonly frameworkComponents: ReadonlyArray<TargetBoundComponentDescriptor<'sql', string>>;
|
|
40
|
-
/**
|
|
41
|
-
* Optional target-specific normalizer for raw database default expressions.
|
|
42
|
-
* When provided, schema defaults (raw strings) are normalized before comparison
|
|
43
|
-
* with contract defaults (ColumnDefault objects).
|
|
44
|
-
*/
|
|
45
|
-
readonly normalizeDefault?: DefaultNormalizer;
|
|
46
|
-
/**
|
|
47
|
-
* Optional target-specific normalizer for schema native type names.
|
|
48
|
-
* When provided, schema native types are normalized before comparison
|
|
49
|
-
* with contract native types (e.g., Postgres 'varchar' → 'character varying').
|
|
50
|
-
*/
|
|
51
|
-
readonly normalizeNativeType?: NativeTypeNormalizer;
|
|
52
|
-
/**
|
|
53
|
-
* When set, only the contract tables in these namespace ids are checked
|
|
54
|
-
* against `schema` (the matching actual namespace node). The full contract is
|
|
55
|
-
* still consulted for cross-namespace value-set / control-policy resolution.
|
|
56
|
-
* Used by the multi-schema verify, which pairs each contract namespace to its
|
|
57
|
-
* own actual node. Absent ⇒ all contract namespaces are checked against the
|
|
58
|
-
* single (flat) `schema` — the single-schema / SQLite path.
|
|
59
|
-
*/
|
|
60
|
-
readonly restrictToNamespaceIds?: ReadonlySet<string>;
|
|
61
|
-
}
|
|
62
|
-
/**
|
|
63
|
-
* Verifies that a SqlSchemaIR matches a Contract.
|
|
64
|
-
*
|
|
65
|
-
* This is a pure function that does NOT perform any database I/O.
|
|
66
|
-
* It takes an already-introspected schema IR and compares it against
|
|
67
|
-
* the contract requirements.
|
|
68
|
-
*
|
|
69
|
-
* @param options - Verification options
|
|
70
|
-
* @returns VerifyDatabaseSchemaResult with verification tree and issues
|
|
71
|
-
*/
|
|
72
|
-
declare function verifySqlSchema(options: VerifySqlSchemaOptions): VerifyDatabaseSchemaResult;
|
|
73
|
-
/**
|
|
74
|
-
* The single per-namespace-paired relational verify shared by the migration
|
|
75
|
-
* planner and the family schema verify — there is exactly one such operation.
|
|
76
|
-
*
|
|
77
|
-
* Each contract namespace is paired to the introspected namespace node holding
|
|
78
|
-
* the same DDL schema, then `verifySqlSchema` checks that namespace's tables
|
|
79
|
-
* against the matching actual node (a contract table under `auth` is only ever
|
|
80
|
-
* looked up in the `auth` actual node, so a multi-schema database no longer
|
|
81
|
-
* reports tables in other schemas as missing). The full contract is passed every
|
|
82
|
-
* time — `restrictToNamespaceIds` scopes only which tables are checked, so
|
|
83
|
-
* cross-namespace value-set / control-policy resolution is unaffected.
|
|
84
|
-
*
|
|
85
|
-
* The DDL schema of each contract namespace is read from a single-namespace
|
|
86
|
-
* expected projection (`buildExpectedSchema`), which both callers already build
|
|
87
|
-
* the same way. Empty contract namespaces verify nothing and are skipped.
|
|
88
|
-
* Single-schema (one namespace) and SQLite's flat schema are one pairing —
|
|
89
|
-
* byte-identical to the prior per-node verify.
|
|
90
|
-
*/
|
|
91
|
-
declare function verifySqlSchemaTree(options: {
|
|
92
|
-
readonly contract: Contract<SqlStorage>;
|
|
93
|
-
readonly actualSchema: SqlSchemaIRNode;
|
|
94
|
-
readonly buildExpectedSchema: (contract: Contract<SqlStorage>) => SqlSchemaIRNode;
|
|
95
|
-
readonly strict: boolean;
|
|
96
|
-
readonly typeMetadataRegistry: ReadonlyMap<string, {
|
|
97
|
-
nativeType?: string;
|
|
98
|
-
}>;
|
|
99
|
-
readonly frameworkComponents: ReadonlyArray<TargetBoundComponentDescriptor<'sql', string>>;
|
|
100
|
-
readonly normalizeDefault?: DefaultNormalizer;
|
|
101
|
-
readonly normalizeNativeType?: NativeTypeNormalizer;
|
|
102
|
-
}): VerifyDatabaseSchemaResult;
|
|
103
|
-
//#endregion
|
|
104
|
-
export { verifySqlSchemaTree as a, verifySqlSchema as i, NativeTypeNormalizer as n, VerifySqlSchemaOptions as r, DefaultNormalizer as t };
|
|
105
|
-
//# sourceMappingURL=sql-schema-diff-6z36dZt6.d.mts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"sql-schema-diff-6z36dZt6.d.mts","names":[],"sources":["../src/core/diff/sql-schema-diff.ts"],"mappings":";;;;;;;;;;AA4EkB;KAHN,iBAAA,IACV,UAAA,UACA,UAAA,aACG,aAAa;;;;AAOoC;AAKtD;KALY,oBAAA,IAAwB,UAAkB;;;;UAKrC,sBAAA;EAQI;EAAA,SANV,QAAA,EAAU,QAAA,CAAS,UAAA;EAagB;EAAA,SAXnC,MAAA,EAAQ,WAAA;EAiBW;EAAA,SAfnB,MAAA;EA8ByB;EAAA,SA5BzB,OAAA,GAAU,gBAAA;EA4B0B;EAAA,SA1BpC,oBAAA,EAAsB,WAAA;IAAsB,UAAA;EAAA;EAN5C;;;;EAAA,SAWA,mBAAA,EAAqB,aAAA,CAAc,8BAAA;EALnC;;;;;EAAA,SAWA,gBAAA,GAAmB,iBAAA;EAAnB;;;;;EAAA,SAMA,mBAAA,GAAsB,oBAAA;EASc;AAAA;AAa/C;;;;;;EAb+C,SAApC,sBAAA,GAAyB,WAAA;AAAA;AAawD;AAkyC5F;;;;;;;;;AAlyC4F,iBAA5E,eAAA,CAAgB,OAAA,EAAS,sBAAA,GAAyB,0BAA0B;;;;;;;;;;;;;;;;;;;iBAkyC5E,mBAAA,CAAoB,OAAA;EAAA,SACzB,QAAA,EAAU,QAAA,CAAS,UAAA;EAAA,SACnB,YAAA,EAAc,eAAA;EAAA,SACd,mBAAA,GAAsB,QAAA,EAAU,QAAA,CAAS,UAAA,MAAgB,eAAA;EAAA,SACzD,MAAA;EAAA,SACA,oBAAA,E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AiC,cAAA,IACzC,OAAA,CAAQ,wBAAA;AAAA;AAAA,UAGI,6BAAA;EAAA,SACN,QAAA;EAnHA;;;EAAA,SAuHA,OAAA;EAAA,SACA,MAAA,GAAS,4BAAA;EAAA,SACT,WAAA,EAAa,4BAAA;EAAA,SACb,UAAA,WAAqB,yBAAA,CAA0B,cAAA;EAvHtB;;;;;EAAA,SA6HzB,kBAAA;EAAA,SACA,IAAA,GAAO,SAAA;AAAA"}
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import type { ControlPolicy } from '@prisma-next/contract/types';
|
|
2
|
-
import type {
|
|
3
|
-
SchemaIssue,
|
|
4
|
-
SchemaVerificationNode,
|
|
5
|
-
VerifierOutcome,
|
|
6
|
-
} from '@prisma-next/framework-components/control';
|
|
7
|
-
import { verifierDisposition } from './verifier-disposition';
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Grades `issue` under `controlPolicy` and, unless suppressed, pushes both the
|
|
11
|
-
* issue and a status-stamped verification node. Returns the resolved outcome so
|
|
12
|
-
* the caller never re-grades the same issue.
|
|
13
|
-
*/
|
|
14
|
-
export function emitIssueAndNodeUnderControlPolicy(
|
|
15
|
-
controlPolicy: ControlPolicy,
|
|
16
|
-
issue: SchemaIssue,
|
|
17
|
-
node: SchemaVerificationNode,
|
|
18
|
-
issues: SchemaIssue[],
|
|
19
|
-
nodes: SchemaVerificationNode[],
|
|
20
|
-
): VerifierOutcome {
|
|
21
|
-
const disposition = verifierDisposition(controlPolicy, issue.kind);
|
|
22
|
-
if (disposition === 'suppress') {
|
|
23
|
-
return disposition;
|
|
24
|
-
}
|
|
25
|
-
issues.push(issue);
|
|
26
|
-
nodes.push({ ...node, status: disposition });
|
|
27
|
-
return disposition;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* Grades `issue` under `controlPolicy` and, unless suppressed, pushes the issue
|
|
32
|
-
* (no verification node). Returns the resolved outcome so the caller maps it to
|
|
33
|
-
* a node status itself without re-grading.
|
|
34
|
-
*/
|
|
35
|
-
export function emitIssueUnderControlPolicy(
|
|
36
|
-
controlPolicy: ControlPolicy,
|
|
37
|
-
issue: SchemaIssue,
|
|
38
|
-
issues: SchemaIssue[],
|
|
39
|
-
): VerifierOutcome {
|
|
40
|
-
const disposition = verifierDisposition(controlPolicy, issue.kind);
|
|
41
|
-
if (disposition === 'suppress') {
|
|
42
|
-
return disposition;
|
|
43
|
-
}
|
|
44
|
-
issues.push(issue);
|
|
45
|
-
return disposition;
|
|
46
|
-
}
|