@prisma-next/sql-schema-ir 0.14.0 → 0.15.0-dev.10
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 +2 -2
- package/dist/exports/types.mjs +2 -2
- package/dist/index.d.mts +2 -2
- package/dist/index.mjs +2 -2
- package/dist/types-CeJhPT7f.d.mts +624 -0
- package/dist/types-CeJhPT7f.d.mts.map +1 -0
- package/dist/types-pxgoVAJq.mjs +683 -0
- package/dist/types-pxgoVAJq.mjs.map +1 -0
- package/package.json +9 -8
- package/src/exports/types.ts +7 -0
- package/src/ir/primary-key.ts +47 -2
- package/src/ir/resolved-default-equality.ts +79 -0
- package/src/ir/schema-node-kinds.ts +86 -0
- package/src/ir/sql-check-constraint-ir.ts +43 -2
- package/src/ir/sql-column-default-ir.ts +96 -0
- package/src/ir/sql-column-ir.ts +142 -2
- package/src/ir/sql-foreign-key-ir.ts +81 -2
- package/src/ir/sql-index-ir.ts +94 -2
- package/src/ir/sql-schema-ir-node.ts +58 -7
- package/src/ir/sql-schema-ir.ts +22 -1
- package/src/ir/sql-table-ir.ts +31 -1
- package/src/ir/sql-unique-ir.ts +44 -2
- package/src/types.ts +10 -1
- package/dist/types-C0WFfEkA.mjs +0 -220
- package/dist/types-C0WFfEkA.mjs.map +0 -1
- package/dist/types-Du44_nsJ.d.mts +0 -261
- package/dist/types-Du44_nsJ.d.mts.map +0 -1
package/src/types.ts
CHANGED
|
@@ -10,10 +10,19 @@
|
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
12
|
export { PrimaryKey, type PrimaryKeyInput } from './ir/primary-key';
|
|
13
|
+
export {
|
|
14
|
+
RelationalSchemaNodeKind,
|
|
15
|
+
relationalNodeEntityKind,
|
|
16
|
+
relationalNodeGranularity,
|
|
17
|
+
} from './ir/schema-node-kinds';
|
|
13
18
|
export {
|
|
14
19
|
SqlCheckConstraintIR,
|
|
15
20
|
type SqlCheckConstraintIRInput,
|
|
16
21
|
} from './ir/sql-check-constraint-ir';
|
|
22
|
+
export {
|
|
23
|
+
SqlColumnDefaultIR,
|
|
24
|
+
type SqlColumnDefaultIRInput,
|
|
25
|
+
} from './ir/sql-column-default-ir';
|
|
17
26
|
export {
|
|
18
27
|
type SqlAnnotations,
|
|
19
28
|
SqlColumnIR,
|
|
@@ -26,7 +35,7 @@ export {
|
|
|
26
35
|
} from './ir/sql-foreign-key-ir';
|
|
27
36
|
export { SqlIndexIR, type SqlIndexIRInput } from './ir/sql-index-ir';
|
|
28
37
|
export { SqlSchemaIR, type SqlSchemaIRInput } from './ir/sql-schema-ir';
|
|
29
|
-
export { SqlSchemaIRNode } from './ir/sql-schema-ir-node';
|
|
38
|
+
export { assertNode, defineNonEnumerable, SqlSchemaIRNode } from './ir/sql-schema-ir-node';
|
|
30
39
|
export { SqlTableIR, type SqlTableIRInput } from './ir/sql-table-ir';
|
|
31
40
|
export { SqlUniqueIR, type SqlUniqueIRInput } from './ir/sql-unique-ir';
|
|
32
41
|
|
package/dist/types-C0WFfEkA.mjs
DELETED
|
@@ -1,220 +0,0 @@
|
|
|
1
|
-
import { IRNodeBase, freezeNode } from "@prisma-next/framework-components/ir";
|
|
2
|
-
//#region src/ir/sql-schema-ir-node.ts
|
|
3
|
-
/**
|
|
4
|
-
* SQL Schema IR node base. Carries the family-level
|
|
5
|
-
* `kind = 'sql-schema-ir'` discriminator and inherits the framework's
|
|
6
|
-
* `freezeNode` affordance.
|
|
7
|
-
*
|
|
8
|
-
* SQL Schema IR represents the actual database state as discovered by
|
|
9
|
-
* introspection (the parallel to SQL Contract IR, which represents the
|
|
10
|
-
* desired state). Like the Contract side, today's Schema IR has no
|
|
11
|
-
* polymorphic dispatch — verifiers and planners walk by structural
|
|
12
|
-
* position, not by inspecting `kind` — so a single family-level
|
|
13
|
-
* discriminator is sufficient. Future per-leaf overrides land cleanly
|
|
14
|
-
* the same way as on the Contract side.
|
|
15
|
-
*
|
|
16
|
-
* The discriminator is installed as a non-enumerable own property,
|
|
17
|
-
* matching the SqlNode pattern. This keeps `JSON.stringify(node)`
|
|
18
|
-
* canonical (no `kind` field), keeps `toEqual({...})` test assertions
|
|
19
|
-
* against pre-lift flat shapes passing, and keeps `node.kind` readable
|
|
20
|
-
* for future polymorphic dispatch.
|
|
21
|
-
*/
|
|
22
|
-
var SqlSchemaIRNode = class extends IRNodeBase {
|
|
23
|
-
kind;
|
|
24
|
-
constructor() {
|
|
25
|
-
super();
|
|
26
|
-
Object.defineProperty(this, "kind", {
|
|
27
|
-
value: "sql-schema-ir",
|
|
28
|
-
writable: false,
|
|
29
|
-
enumerable: false,
|
|
30
|
-
configurable: false
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
|
-
};
|
|
34
|
-
//#endregion
|
|
35
|
-
//#region src/ir/primary-key.ts
|
|
36
|
-
/**
|
|
37
|
-
* Primary-key Schema IR node. Mirrors the Contract IR `PrimaryKey`
|
|
38
|
-
* shape (same `columns` + optional `name`) so verification can compare
|
|
39
|
-
* intent and actual structurally. Defined here independently to avoid
|
|
40
|
-
* a sql-schema-ir -> sql-contract dependency.
|
|
41
|
-
*/
|
|
42
|
-
var PrimaryKey = class extends SqlSchemaIRNode {
|
|
43
|
-
columns;
|
|
44
|
-
constructor(input) {
|
|
45
|
-
super();
|
|
46
|
-
this.columns = input.columns;
|
|
47
|
-
if (input.name !== void 0) this.name = input.name;
|
|
48
|
-
freezeNode(this);
|
|
49
|
-
}
|
|
50
|
-
};
|
|
51
|
-
//#endregion
|
|
52
|
-
//#region src/ir/sql-check-constraint-ir.ts
|
|
53
|
-
/**
|
|
54
|
-
* Schema IR node for a table-level check constraint that restricts a
|
|
55
|
-
* column to a set of permitted values (an enum-style `IN (...)` check).
|
|
56
|
-
*
|
|
57
|
-
* Carries the **resolved values** rather than a raw SQL predicate so
|
|
58
|
-
* callers can compare value-sets without parsing SQL.
|
|
59
|
-
*/
|
|
60
|
-
var SqlCheckConstraintIR = class extends SqlSchemaIRNode {
|
|
61
|
-
name;
|
|
62
|
-
column;
|
|
63
|
-
permittedValues;
|
|
64
|
-
constructor(input) {
|
|
65
|
-
super();
|
|
66
|
-
this.name = input.name;
|
|
67
|
-
this.column = input.column;
|
|
68
|
-
this.permittedValues = Object.freeze([...input.permittedValues]);
|
|
69
|
-
freezeNode(this);
|
|
70
|
-
}
|
|
71
|
-
};
|
|
72
|
-
//#endregion
|
|
73
|
-
//#region src/ir/sql-column-ir.ts
|
|
74
|
-
/**
|
|
75
|
-
* Schema IR node for a single column on a table, as observed by
|
|
76
|
-
* introspection. Unlike the Contract IR `StorageColumn`, this carries
|
|
77
|
-
* the column's `name` (Schema IR columns are returned as arrays from
|
|
78
|
-
* introspection queries; the parent table re-keys them into a record
|
|
79
|
-
* for downstream consumers).
|
|
80
|
-
*/
|
|
81
|
-
var SqlColumnIR = class extends SqlSchemaIRNode {
|
|
82
|
-
name;
|
|
83
|
-
nativeType;
|
|
84
|
-
nullable;
|
|
85
|
-
constructor(input) {
|
|
86
|
-
super();
|
|
87
|
-
this.name = input.name;
|
|
88
|
-
this.nativeType = input.nativeType;
|
|
89
|
-
this.nullable = input.nullable;
|
|
90
|
-
if (input.default !== void 0) this.default = input.default;
|
|
91
|
-
if (input.annotations !== void 0) this.annotations = input.annotations;
|
|
92
|
-
freezeNode(this);
|
|
93
|
-
}
|
|
94
|
-
};
|
|
95
|
-
//#endregion
|
|
96
|
-
//#region src/ir/sql-foreign-key-ir.ts
|
|
97
|
-
/**
|
|
98
|
-
* Schema IR node for a foreign-key constraint as observed by
|
|
99
|
-
* introspection. The `referencedTable` / `referencedColumns` field
|
|
100
|
-
* names match the introspection vocabulary (`pg_constraint.confkey`,
|
|
101
|
-
* etc.) and intentionally differ from the Contract IR's nested
|
|
102
|
-
* `references: { table, columns }` shape so that the verifier's
|
|
103
|
-
* structural comparison stays explicit about which side it's reading.
|
|
104
|
-
*/
|
|
105
|
-
var SqlForeignKeyIR = class extends SqlSchemaIRNode {
|
|
106
|
-
columns;
|
|
107
|
-
referencedTable;
|
|
108
|
-
referencedColumns;
|
|
109
|
-
constructor(input) {
|
|
110
|
-
super();
|
|
111
|
-
this.columns = input.columns;
|
|
112
|
-
this.referencedTable = input.referencedTable;
|
|
113
|
-
this.referencedColumns = input.referencedColumns;
|
|
114
|
-
if (input.referencedSchema !== void 0) this.referencedSchema = input.referencedSchema;
|
|
115
|
-
if (input.name !== void 0) this.name = input.name;
|
|
116
|
-
if (input.onDelete !== void 0) this.onDelete = input.onDelete;
|
|
117
|
-
if (input.onUpdate !== void 0) this.onUpdate = input.onUpdate;
|
|
118
|
-
if (input.annotations !== void 0) this.annotations = input.annotations;
|
|
119
|
-
freezeNode(this);
|
|
120
|
-
}
|
|
121
|
-
};
|
|
122
|
-
//#endregion
|
|
123
|
-
//#region src/ir/sql-index-ir.ts
|
|
124
|
-
/**
|
|
125
|
-
* Schema IR node for a secondary index as observed by introspection.
|
|
126
|
-
* Unlike the Contract IR `Index`, the Schema IR carries an explicit
|
|
127
|
-
* `unique` field — introspection sees the underlying index regardless
|
|
128
|
-
* of whether the user expressed it as `@@index` or `@@unique`, and the
|
|
129
|
-
* verifier needs to distinguish them when comparing to the Contract.
|
|
130
|
-
*/
|
|
131
|
-
var SqlIndexIR = class extends SqlSchemaIRNode {
|
|
132
|
-
columns;
|
|
133
|
-
unique;
|
|
134
|
-
constructor(input) {
|
|
135
|
-
super();
|
|
136
|
-
this.columns = input.columns;
|
|
137
|
-
this.unique = input.unique;
|
|
138
|
-
if (input.name !== void 0) this.name = input.name;
|
|
139
|
-
if (input.type !== void 0) this.type = input.type;
|
|
140
|
-
if (input.options !== void 0) this.options = input.options;
|
|
141
|
-
if (input.annotations !== void 0) this.annotations = input.annotations;
|
|
142
|
-
freezeNode(this);
|
|
143
|
-
}
|
|
144
|
-
};
|
|
145
|
-
//#endregion
|
|
146
|
-
//#region src/ir/sql-unique-ir.ts
|
|
147
|
-
/**
|
|
148
|
-
* Schema IR node for a table-level unique constraint as observed by
|
|
149
|
-
* introspection.
|
|
150
|
-
*/
|
|
151
|
-
var SqlUniqueIR = class extends SqlSchemaIRNode {
|
|
152
|
-
columns;
|
|
153
|
-
constructor(input) {
|
|
154
|
-
super();
|
|
155
|
-
this.columns = [...input.columns];
|
|
156
|
-
if (input.name !== void 0) this.name = input.name;
|
|
157
|
-
if (input.annotations !== void 0) this.annotations = input.annotations;
|
|
158
|
-
freezeNode(this);
|
|
159
|
-
}
|
|
160
|
-
};
|
|
161
|
-
//#endregion
|
|
162
|
-
//#region src/ir/sql-table-ir.ts
|
|
163
|
-
/**
|
|
164
|
-
* Schema IR node for a single table as observed by introspection.
|
|
165
|
-
*
|
|
166
|
-
* Unlike the Contract IR `StorageTable`, this carries the table's
|
|
167
|
-
* `name` — introspection queries return tables as arrays and the
|
|
168
|
-
* verifier keys them into `SqlSchemaIR.tables` afterwards, so the name
|
|
169
|
-
* stays on the table object for downstream call sites that walk
|
|
170
|
-
* `Object.values(schema.tables)`.
|
|
171
|
-
*
|
|
172
|
-
* The constructor normalises nested IR-class fields so downstream
|
|
173
|
-
* walks see a uniform AST regardless of whether the input was a
|
|
174
|
-
* plain-data literal (from introspection) or already-constructed
|
|
175
|
-
* class instances.
|
|
176
|
-
*/
|
|
177
|
-
var SqlTableIR = class extends SqlSchemaIRNode {
|
|
178
|
-
name;
|
|
179
|
-
columns;
|
|
180
|
-
foreignKeys;
|
|
181
|
-
uniques;
|
|
182
|
-
indexes;
|
|
183
|
-
constructor(input) {
|
|
184
|
-
super();
|
|
185
|
-
this.name = input.name;
|
|
186
|
-
this.columns = Object.freeze(Object.fromEntries(Object.entries(input.columns).map(([key, col]) => [key, col instanceof SqlColumnIR ? col : new SqlColumnIR(col)])));
|
|
187
|
-
this.foreignKeys = Object.freeze(input.foreignKeys.map((fk) => fk instanceof SqlForeignKeyIR ? fk : new SqlForeignKeyIR(fk)));
|
|
188
|
-
this.uniques = Object.freeze(input.uniques.map((u) => u instanceof SqlUniqueIR ? u : new SqlUniqueIR(u)));
|
|
189
|
-
this.indexes = Object.freeze(input.indexes.map((i) => i instanceof SqlIndexIR ? i : new SqlIndexIR(i)));
|
|
190
|
-
if (input.primaryKey !== void 0) this.primaryKey = input.primaryKey instanceof PrimaryKey ? input.primaryKey : new PrimaryKey(input.primaryKey);
|
|
191
|
-
if (input.annotations !== void 0) this.annotations = input.annotations;
|
|
192
|
-
if (input.checks !== void 0 && input.checks.length > 0) this.checks = Object.freeze(input.checks.map((c) => c instanceof SqlCheckConstraintIR ? c : new SqlCheckConstraintIR(c)));
|
|
193
|
-
freezeNode(this);
|
|
194
|
-
}
|
|
195
|
-
};
|
|
196
|
-
//#endregion
|
|
197
|
-
//#region src/ir/sql-schema-ir.ts
|
|
198
|
-
/**
|
|
199
|
-
* Root Schema IR node representing the complete database schema as
|
|
200
|
-
* observed by introspection. Target-agnostic; used by both verifiers
|
|
201
|
-
* (compare against intended Contract storage) and migration planners
|
|
202
|
-
* (derive operations needed to reconcile).
|
|
203
|
-
*
|
|
204
|
-
* The constructor normalises nested `SqlTableIR` instances so
|
|
205
|
-
* downstream walks see a uniform AST regardless of whether the input
|
|
206
|
-
* was a plain-data literal or already-constructed class instances.
|
|
207
|
-
*/
|
|
208
|
-
var SqlSchemaIR = class extends SqlSchemaIRNode {
|
|
209
|
-
tables;
|
|
210
|
-
constructor(input) {
|
|
211
|
-
super();
|
|
212
|
-
this.tables = Object.freeze(Object.fromEntries(Object.entries(input.tables).map(([key, t]) => [key, t instanceof SqlTableIR ? t : new SqlTableIR(t)])));
|
|
213
|
-
if (input.annotations !== void 0) this.annotations = input.annotations;
|
|
214
|
-
freezeNode(this);
|
|
215
|
-
}
|
|
216
|
-
};
|
|
217
|
-
//#endregion
|
|
218
|
-
export { SqlForeignKeyIR as a, PrimaryKey as c, SqlIndexIR as i, SqlSchemaIRNode as l, SqlTableIR as n, SqlColumnIR as o, SqlUniqueIR as r, SqlCheckConstraintIR as s, SqlSchemaIR as t };
|
|
219
|
-
|
|
220
|
-
//# sourceMappingURL=types-C0WFfEkA.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types-C0WFfEkA.mjs","names":[],"sources":["../src/ir/sql-schema-ir-node.ts","../src/ir/primary-key.ts","../src/ir/sql-check-constraint-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 { 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). Like the Contract side, today's Schema IR has no\n * polymorphic dispatch — verifiers and planners walk by structural\n * position, not by inspecting `kind` — so a single family-level\n * discriminator is sufficient. Future per-leaf overrides land cleanly\n * the same way as on the Contract side.\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 future polymorphic dispatch.\n */\nexport abstract class SqlSchemaIRNode extends IRNodeBase {\n readonly kind?: 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","import { freezeNode } from '@prisma-next/framework-components/ir';\nimport { SqlSchemaIRNode } from './sql-schema-ir-node';\n\nexport interface PrimaryKeyInput {\n readonly columns: readonly string[];\n readonly name?: string;\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 */\nexport class PrimaryKey extends SqlSchemaIRNode {\n readonly columns: readonly string[];\n declare readonly name?: string;\n\n constructor(input: PrimaryKeyInput) {\n super();\n this.columns = input.columns;\n if (input.name !== undefined) this.name = input.name;\n freezeNode(this);\n }\n}\n","import { freezeNode } from '@prisma-next/framework-components/ir';\nimport { 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 */\nexport class SqlCheckConstraintIR extends SqlSchemaIRNode {\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","import { freezeNode } from '@prisma-next/framework-components/ir';\nimport { 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}\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 */\nexport class SqlColumnIR extends SqlSchemaIRNode {\n readonly name: string;\n readonly nativeType: string;\n readonly nullable: boolean;\n declare readonly default?: string;\n declare readonly annotations?: SqlAnnotations;\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 freezeNode(this);\n }\n}\n","import { freezeNode } from '@prisma-next/framework-components/ir';\nimport type { SqlAnnotations } from './sql-column-ir';\nimport { 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\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 */\nexport class SqlForeignKeyIR extends SqlSchemaIRNode {\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\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 freezeNode(this);\n }\n}\n","import { freezeNode } from '@prisma-next/framework-components/ir';\nimport type { SqlAnnotations } from './sql-column-ir';\nimport { SqlSchemaIRNode } from './sql-schema-ir-node';\n\nexport interface SqlIndexIRInput {\n readonly columns: readonly string[];\n readonly unique: boolean;\n readonly name?: string;\n readonly type?: string;\n readonly options?: Record<string, unknown>;\n readonly annotations?: SqlAnnotations;\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 */\nexport class SqlIndexIR extends SqlSchemaIRNode {\n readonly columns: readonly string[];\n readonly unique: boolean;\n declare readonly name?: string;\n declare readonly type?: string;\n declare readonly options?: Record<string, unknown>;\n declare readonly annotations?: SqlAnnotations;\n\n constructor(input: SqlIndexIRInput) {\n super();\n this.columns = input.columns;\n this.unique = input.unique;\n if (input.name !== undefined) this.name = input.name;\n if (input.type !== undefined) this.type = input.type;\n if (input.options !== undefined) this.options = input.options;\n if (input.annotations !== undefined) this.annotations = input.annotations;\n freezeNode(this);\n }\n}\n","import { freezeNode } from '@prisma-next/framework-components/ir';\nimport type { SqlAnnotations } from './sql-column-ir';\nimport { 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\n/**\n * Schema IR node for a table-level unique constraint as observed by\n * introspection.\n */\nexport class SqlUniqueIR extends SqlSchemaIRNode {\n readonly columns: readonly string[];\n declare readonly name?: string;\n declare readonly annotations?: SqlAnnotations;\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 freezeNode(this);\n }\n}\n","import { freezeNode } from '@prisma-next/framework-components/ir';\nimport { PrimaryKey, type PrimaryKeyInput } from './primary-key';\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 */\nexport class SqlTableIR extends SqlSchemaIRNode {\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","import { freezeNode } from '@prisma-next/framework-components/ir';\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 */\nexport class SqlSchemaIR extends SqlSchemaIRNode {\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"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAqBA,IAAsB,kBAAtB,cAA8C,WAAW;CACvD;CAEA,cAAc;EACZ,MAAM;EACN,OAAO,eAAe,MAAM,QAAQ;GAClC,OAAO;GACP,UAAU;GACV,YAAY;GACZ,cAAc;EAChB,CAAC;CACH;AACF;;;;;;;;;ACnBA,IAAa,aAAb,cAAgC,gBAAgB;CAC9C;CAGA,YAAY,OAAwB;EAClC,MAAM;EACN,KAAK,UAAU,MAAM;EACrB,IAAI,MAAM,SAAS,KAAA,GAAW,KAAK,OAAO,MAAM;EAChD,WAAW,IAAI;CACjB;AACF;;;;;;;;;;ACLA,IAAa,uBAAb,cAA0C,gBAAgB;CACxD;CACA;CACA;CAEA,YAAY,OAAkC;EAC5C,MAAM;EACN,KAAK,OAAO,MAAM;EAClB,KAAK,SAAS,MAAM;EACpB,KAAK,kBAAkB,OAAO,OAAO,CAAC,GAAG,MAAM,eAAe,CAAC;EAC/D,WAAW,IAAI;CACjB;AACF;;;;;;;;;;ACJA,IAAa,cAAb,cAAiC,gBAAgB;CAC/C;CACA;CACA;CAIA,YAAY,OAAyB;EACnC,MAAM;EACN,KAAK,OAAO,MAAM;EAClB,KAAK,aAAa,MAAM;EACxB,KAAK,WAAW,MAAM;EACtB,IAAI,MAAM,YAAY,KAAA,GAAW,KAAK,UAAU,MAAM;EACtD,IAAI,MAAM,gBAAgB,KAAA,GAAW,KAAK,cAAc,MAAM;EAC9D,WAAW,IAAI;CACjB;AACF;;;;;;;;;;;ACjBA,IAAa,kBAAb,cAAqC,gBAAgB;CACnD;CACA;CACA;CAOA,YAAY,OAA6B;EACvC,MAAM;EACN,KAAK,UAAU,MAAM;EACrB,KAAK,kBAAkB,MAAM;EAC7B,KAAK,oBAAoB,M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YAAY,GAAG,CACxD,CAAC,CACH,CACF;EACA,KAAK,cAAc,OAAO,OACxB,MAAM,YAAY,KAAK,OAAQ,cAAc,kBAAkB,KAAK,IAAI,gBAAgB,EAAE,CAAE,CAC9F;EACA,KAAK,UAAU,OAAO,OACpB,MAAM,QAAQ,KAAK,MAAO,aAAa,cAAc,IAAI,IAAI,YAAY,CAAC,CAAE,CAC9E;EACA,KAAK,UAAU,OAAO,OACpB,MAAM,QAAQ,KAAK,MAAO,aAAa,aAAa,IAAI,IAAI,WAAW,CAAC,CAAE,CAC5E;EACA,IAAI,MAAM,eAAe,KAAA,GACvB,KAAK,aACH,MAAM,sBAAsB,aACxB,MAAM,aACN,IAAI,WAAW,MAAM,UAAU;EAEvC,IAAI,MAAM,gBAAgB,KAAA,GAAW,KAAK,cAAc,MAAM;EAC9D,IAAI,MAAM,WAAW,KAAA,KAAa,MAAM,OAAO,SAAS,GACtD,KAAK,SAAS,OAAO,OACnB,MAAM,OAAO,KAAK,MAChB,aAAa,uBAAuB,IAAI,IAAI,qBAAqB,CAAC,CACpE,CACF;EAEF,WAAW,IAAI;CACjB;AACF;;;;;;;;;;;;;AC7DA,IAAa,cAAb,cAAiC,gBAAgB;CAC/C;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;AACF"}
|
|
@@ -1,261 +0,0 @@
|
|
|
1
|
-
import { IRNodeBase } from "@prisma-next/framework-components/ir";
|
|
2
|
-
|
|
3
|
-
//#region src/ir/sql-schema-ir-node.d.ts
|
|
4
|
-
/**
|
|
5
|
-
* SQL Schema IR node base. Carries the family-level
|
|
6
|
-
* `kind = 'sql-schema-ir'` discriminator and inherits the framework's
|
|
7
|
-
* `freezeNode` affordance.
|
|
8
|
-
*
|
|
9
|
-
* SQL Schema IR represents the actual database state as discovered by
|
|
10
|
-
* introspection (the parallel to SQL Contract IR, which represents the
|
|
11
|
-
* desired state). Like the Contract side, today's Schema IR has no
|
|
12
|
-
* polymorphic dispatch — verifiers and planners walk by structural
|
|
13
|
-
* position, not by inspecting `kind` — so a single family-level
|
|
14
|
-
* discriminator is sufficient. Future per-leaf overrides land cleanly
|
|
15
|
-
* the same way as on the Contract side.
|
|
16
|
-
*
|
|
17
|
-
* The discriminator is installed as a non-enumerable own property,
|
|
18
|
-
* matching the SqlNode pattern. This keeps `JSON.stringify(node)`
|
|
19
|
-
* canonical (no `kind` field), keeps `toEqual({...})` test assertions
|
|
20
|
-
* against pre-lift flat shapes passing, and keeps `node.kind` readable
|
|
21
|
-
* for future polymorphic dispatch.
|
|
22
|
-
*/
|
|
23
|
-
declare abstract class SqlSchemaIRNode extends IRNodeBase {
|
|
24
|
-
readonly kind?: string;
|
|
25
|
-
constructor();
|
|
26
|
-
}
|
|
27
|
-
//#endregion
|
|
28
|
-
//#region src/ir/primary-key.d.ts
|
|
29
|
-
interface PrimaryKeyInput {
|
|
30
|
-
readonly columns: readonly string[];
|
|
31
|
-
readonly name?: string;
|
|
32
|
-
}
|
|
33
|
-
/**
|
|
34
|
-
* Primary-key Schema IR node. Mirrors the Contract IR `PrimaryKey`
|
|
35
|
-
* shape (same `columns` + optional `name`) so verification can compare
|
|
36
|
-
* intent and actual structurally. Defined here independently to avoid
|
|
37
|
-
* a sql-schema-ir -> sql-contract dependency.
|
|
38
|
-
*/
|
|
39
|
-
declare class PrimaryKey extends SqlSchemaIRNode {
|
|
40
|
-
readonly columns: readonly string[];
|
|
41
|
-
readonly name?: string;
|
|
42
|
-
constructor(input: PrimaryKeyInput);
|
|
43
|
-
}
|
|
44
|
-
//#endregion
|
|
45
|
-
//#region src/ir/sql-check-constraint-ir.d.ts
|
|
46
|
-
interface SqlCheckConstraintIRInput {
|
|
47
|
-
/** Constraint name as stored in the database catalog. */
|
|
48
|
-
readonly name: string;
|
|
49
|
-
/** Column the check restricts. */
|
|
50
|
-
readonly column: string;
|
|
51
|
-
/** Permitted values the column must be IN. */
|
|
52
|
-
readonly permittedValues: readonly string[];
|
|
53
|
-
}
|
|
54
|
-
/**
|
|
55
|
-
* Schema IR node for a table-level check constraint that restricts a
|
|
56
|
-
* column to a set of permitted values (an enum-style `IN (...)` check).
|
|
57
|
-
*
|
|
58
|
-
* Carries the **resolved values** rather than a raw SQL predicate so
|
|
59
|
-
* callers can compare value-sets without parsing SQL.
|
|
60
|
-
*/
|
|
61
|
-
declare class SqlCheckConstraintIR extends SqlSchemaIRNode {
|
|
62
|
-
readonly name: string;
|
|
63
|
-
readonly column: string;
|
|
64
|
-
readonly permittedValues: readonly string[];
|
|
65
|
-
constructor(input: SqlCheckConstraintIRInput);
|
|
66
|
-
}
|
|
67
|
-
//#endregion
|
|
68
|
-
//#region src/ir/sql-column-ir.d.ts
|
|
69
|
-
/**
|
|
70
|
-
* Namespaced annotations for extensibility. Each namespace
|
|
71
|
-
* (e.g. `pg`, `pgvector`) owns its annotations subtree.
|
|
72
|
-
*/
|
|
73
|
-
type SqlAnnotations = {
|
|
74
|
-
readonly [namespace: string]: unknown;
|
|
75
|
-
};
|
|
76
|
-
interface SqlColumnIRInput {
|
|
77
|
-
readonly name: string;
|
|
78
|
-
readonly nativeType: string;
|
|
79
|
-
readonly nullable: boolean;
|
|
80
|
-
/** Raw database default expression (e.g. `'hello'::text`, `nextval('seq')`). */
|
|
81
|
-
readonly default?: string;
|
|
82
|
-
readonly annotations?: SqlAnnotations;
|
|
83
|
-
}
|
|
84
|
-
/**
|
|
85
|
-
* Schema IR node for a single column on a table, as observed by
|
|
86
|
-
* introspection. Unlike the Contract IR `StorageColumn`, this carries
|
|
87
|
-
* the column's `name` (Schema IR columns are returned as arrays from
|
|
88
|
-
* introspection queries; the parent table re-keys them into a record
|
|
89
|
-
* for downstream consumers).
|
|
90
|
-
*/
|
|
91
|
-
declare class SqlColumnIR extends SqlSchemaIRNode {
|
|
92
|
-
readonly name: string;
|
|
93
|
-
readonly nativeType: string;
|
|
94
|
-
readonly nullable: boolean;
|
|
95
|
-
readonly default?: string;
|
|
96
|
-
readonly annotations?: SqlAnnotations;
|
|
97
|
-
constructor(input: SqlColumnIRInput);
|
|
98
|
-
}
|
|
99
|
-
//#endregion
|
|
100
|
-
//#region src/ir/sql-foreign-key-ir.d.ts
|
|
101
|
-
type SqlReferentialAction = 'noAction' | 'restrict' | 'cascade' | 'setNull' | 'setDefault';
|
|
102
|
-
interface SqlForeignKeyIRInput {
|
|
103
|
-
readonly columns: readonly string[];
|
|
104
|
-
readonly referencedTable: string;
|
|
105
|
-
readonly referencedColumns: readonly string[];
|
|
106
|
-
/** Schema (namespace) of the referenced table — populated by adapters that introspect cross-schema FKs. */
|
|
107
|
-
readonly referencedSchema?: string;
|
|
108
|
-
readonly name?: string;
|
|
109
|
-
readonly onDelete?: SqlReferentialAction;
|
|
110
|
-
readonly onUpdate?: SqlReferentialAction;
|
|
111
|
-
readonly annotations?: SqlAnnotations;
|
|
112
|
-
}
|
|
113
|
-
/**
|
|
114
|
-
* Schema IR node for a foreign-key constraint as observed by
|
|
115
|
-
* introspection. The `referencedTable` / `referencedColumns` field
|
|
116
|
-
* names match the introspection vocabulary (`pg_constraint.confkey`,
|
|
117
|
-
* etc.) and intentionally differ from the Contract IR's nested
|
|
118
|
-
* `references: { table, columns }` shape so that the verifier's
|
|
119
|
-
* structural comparison stays explicit about which side it's reading.
|
|
120
|
-
*/
|
|
121
|
-
declare class SqlForeignKeyIR extends SqlSchemaIRNode {
|
|
122
|
-
readonly columns: readonly string[];
|
|
123
|
-
readonly referencedTable: string;
|
|
124
|
-
readonly referencedColumns: readonly string[];
|
|
125
|
-
readonly referencedSchema?: string;
|
|
126
|
-
readonly name?: string;
|
|
127
|
-
readonly onDelete?: SqlReferentialAction;
|
|
128
|
-
readonly onUpdate?: SqlReferentialAction;
|
|
129
|
-
readonly annotations?: SqlAnnotations;
|
|
130
|
-
constructor(input: SqlForeignKeyIRInput);
|
|
131
|
-
}
|
|
132
|
-
//#endregion
|
|
133
|
-
//#region src/ir/sql-index-ir.d.ts
|
|
134
|
-
interface SqlIndexIRInput {
|
|
135
|
-
readonly columns: readonly string[];
|
|
136
|
-
readonly unique: boolean;
|
|
137
|
-
readonly name?: string;
|
|
138
|
-
readonly type?: string;
|
|
139
|
-
readonly options?: Record<string, unknown>;
|
|
140
|
-
readonly annotations?: SqlAnnotations;
|
|
141
|
-
}
|
|
142
|
-
/**
|
|
143
|
-
* Schema IR node for a secondary index as observed by introspection.
|
|
144
|
-
* Unlike the Contract IR `Index`, the Schema IR carries an explicit
|
|
145
|
-
* `unique` field — introspection sees the underlying index regardless
|
|
146
|
-
* of whether the user expressed it as `@@index` or `@@unique`, and the
|
|
147
|
-
* verifier needs to distinguish them when comparing to the Contract.
|
|
148
|
-
*/
|
|
149
|
-
declare class SqlIndexIR extends SqlSchemaIRNode {
|
|
150
|
-
readonly columns: readonly string[];
|
|
151
|
-
readonly unique: boolean;
|
|
152
|
-
readonly name?: string;
|
|
153
|
-
readonly type?: string;
|
|
154
|
-
readonly options?: Record<string, unknown>;
|
|
155
|
-
readonly annotations?: SqlAnnotations;
|
|
156
|
-
constructor(input: SqlIndexIRInput);
|
|
157
|
-
}
|
|
158
|
-
//#endregion
|
|
159
|
-
//#region src/ir/sql-unique-ir.d.ts
|
|
160
|
-
interface SqlUniqueIRInput {
|
|
161
|
-
readonly columns: readonly string[];
|
|
162
|
-
readonly name?: string;
|
|
163
|
-
readonly annotations?: SqlAnnotations;
|
|
164
|
-
}
|
|
165
|
-
/**
|
|
166
|
-
* Schema IR node for a table-level unique constraint as observed by
|
|
167
|
-
* introspection.
|
|
168
|
-
*/
|
|
169
|
-
declare class SqlUniqueIR extends SqlSchemaIRNode {
|
|
170
|
-
readonly columns: readonly string[];
|
|
171
|
-
readonly name?: string;
|
|
172
|
-
readonly annotations?: SqlAnnotations;
|
|
173
|
-
constructor(input: SqlUniqueIRInput);
|
|
174
|
-
}
|
|
175
|
-
//#endregion
|
|
176
|
-
//#region src/ir/sql-table-ir.d.ts
|
|
177
|
-
interface SqlTableIRInput {
|
|
178
|
-
readonly name: string;
|
|
179
|
-
readonly columns: Record<string, SqlColumnIR | SqlColumnIRInput>;
|
|
180
|
-
readonly foreignKeys: ReadonlyArray<SqlForeignKeyIR | SqlForeignKeyIRInput>;
|
|
181
|
-
readonly uniques: ReadonlyArray<SqlUniqueIR | SqlUniqueIRInput>;
|
|
182
|
-
readonly indexes: ReadonlyArray<SqlIndexIR | SqlIndexIRInput>;
|
|
183
|
-
readonly primaryKey?: PrimaryKey | PrimaryKeyInput;
|
|
184
|
-
readonly annotations?: SqlAnnotations;
|
|
185
|
-
/** Optional check constraints for enum-restricted columns. Omitted when none present. */
|
|
186
|
-
readonly checks?: ReadonlyArray<SqlCheckConstraintIR | SqlCheckConstraintIRInput>;
|
|
187
|
-
}
|
|
188
|
-
/**
|
|
189
|
-
* Schema IR node for a single table as observed by introspection.
|
|
190
|
-
*
|
|
191
|
-
* Unlike the Contract IR `StorageTable`, this carries the table's
|
|
192
|
-
* `name` — introspection queries return tables as arrays and the
|
|
193
|
-
* verifier keys them into `SqlSchemaIR.tables` afterwards, so the name
|
|
194
|
-
* stays on the table object for downstream call sites that walk
|
|
195
|
-
* `Object.values(schema.tables)`.
|
|
196
|
-
*
|
|
197
|
-
* The constructor normalises nested IR-class fields so downstream
|
|
198
|
-
* walks see a uniform AST regardless of whether the input was a
|
|
199
|
-
* plain-data literal (from introspection) or already-constructed
|
|
200
|
-
* class instances.
|
|
201
|
-
*/
|
|
202
|
-
declare class SqlTableIR extends SqlSchemaIRNode {
|
|
203
|
-
readonly name: string;
|
|
204
|
-
readonly columns: Readonly<Record<string, SqlColumnIR>>;
|
|
205
|
-
readonly foreignKeys: ReadonlyArray<SqlForeignKeyIR>;
|
|
206
|
-
readonly uniques: ReadonlyArray<SqlUniqueIR>;
|
|
207
|
-
readonly indexes: ReadonlyArray<SqlIndexIR>;
|
|
208
|
-
readonly primaryKey?: PrimaryKey;
|
|
209
|
-
readonly annotations?: SqlAnnotations;
|
|
210
|
-
readonly checks?: ReadonlyArray<SqlCheckConstraintIR>;
|
|
211
|
-
constructor(input: SqlTableIRInput);
|
|
212
|
-
}
|
|
213
|
-
//#endregion
|
|
214
|
-
//#region src/ir/sql-schema-ir.d.ts
|
|
215
|
-
interface SqlSchemaIRInput {
|
|
216
|
-
readonly tables: Record<string, SqlTableIR | SqlTableIRInput>;
|
|
217
|
-
readonly annotations?: SqlAnnotations;
|
|
218
|
-
}
|
|
219
|
-
/**
|
|
220
|
-
* Root Schema IR node representing the complete database schema as
|
|
221
|
-
* observed by introspection. Target-agnostic; used by both verifiers
|
|
222
|
-
* (compare against intended Contract storage) and migration planners
|
|
223
|
-
* (derive operations needed to reconcile).
|
|
224
|
-
*
|
|
225
|
-
* The constructor normalises nested `SqlTableIR` instances so
|
|
226
|
-
* downstream walks see a uniform AST regardless of whether the input
|
|
227
|
-
* was a plain-data literal or already-constructed class instances.
|
|
228
|
-
*/
|
|
229
|
-
declare class SqlSchemaIR extends SqlSchemaIRNode {
|
|
230
|
-
readonly tables: Readonly<Record<string, SqlTableIR>>;
|
|
231
|
-
readonly annotations?: SqlAnnotations;
|
|
232
|
-
constructor(input: SqlSchemaIRInput);
|
|
233
|
-
}
|
|
234
|
-
//#endregion
|
|
235
|
-
//#region src/types.d.ts
|
|
236
|
-
/**
|
|
237
|
-
* SQL type metadata for control-plane and execution-plane type
|
|
238
|
-
* availability and mapping. Read-only view of type information
|
|
239
|
-
* without encode/decode behavior.
|
|
240
|
-
*/
|
|
241
|
-
interface SqlTypeMetadata {
|
|
242
|
-
/** Namespaced type identifier, e.g. `pg/int4@1`, `pg/text@1`. */
|
|
243
|
-
readonly typeId: string;
|
|
244
|
-
/** Contract scalar type IDs this type can handle. */
|
|
245
|
-
readonly targetTypes: readonly string[];
|
|
246
|
-
/**
|
|
247
|
-
* Native database type name (target-specific). Optional because
|
|
248
|
-
* not all types have a native database representation.
|
|
249
|
-
*/
|
|
250
|
-
readonly nativeType?: string;
|
|
251
|
-
}
|
|
252
|
-
/**
|
|
253
|
-
* Registry interface for SQL type metadata. Provides read-only
|
|
254
|
-
* iteration over type metadata entries.
|
|
255
|
-
*/
|
|
256
|
-
interface SqlTypeMetadataRegistry {
|
|
257
|
-
values(): IterableIterator<SqlTypeMetadata>;
|
|
258
|
-
}
|
|
259
|
-
//#endregion
|
|
260
|
-
export { SqlCheckConstraintIR as _, SqlTableIR as a, PrimaryKeyInput 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, SqlCheckConstraintIRInput as v, SqlSchemaIRNode as x, PrimaryKey as y };
|
|
261
|
-
//# sourceMappingURL=types-Du44_nsJ.d.mts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types-Du44_nsJ.d.mts","names":[],"sources":["../src/ir/sql-schema-ir-node.ts","../src/ir/primary-key.ts","../src/ir/sql-check-constraint-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":";;;;;AAqBA;;;;;;;;;;;;AClBA;;;;AAEe;uBDgBO,eAAA,SAAwB,UAAU;EAAA,SAC7C,IAAA;;;;;UCnBM,eAAA;EAAA,SACN,OAAA;EAAA,SACA,IAAI;AAAA;;;;;;;cASF,UA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