@prisma-next/sql-schema-ir 0.14.0-dev.8 → 0.14.0-dev.81

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.
@@ -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,UAAA,SAAmB,eAAe;EAAA,SACpC,OAAA;EAAA,SACQ,IAAA;cAEL,KAAA,EAAO,eAAA;AAAA;;;UCfJ,yBAAA;;WAEN,IAAA;EFgB2B;EAAA,SEd3B,MAAA;EFc6C;EAAA,SEZ7C,eAAA;AAAA;;;;;;;ADNX;cCgBa,oBAAA,SAA6B,eAAe;EAAA,SAC9C,IAAA;EAAA,SACA,MAAA;EAAA,SACA,eAAA;cAEG,KAAA,EAAO,yBAAA;AAAA;;;;;AFHrB;;KGdY,cAAA;EAAA,UACA,SAAiB;AAAA;AAAA,UAGZ,gBAAA;EAAA,SACN,IAAA;EAAA,SACA,UAAA;EAAA,SACA,QAAA;;WAEA,OAAA;EAAA,SACA,WAAA,GAAc,cAAc;AAAA;;;;AFZxB;AASf;;;cEaa,WAAA,SAAoB,eAAA;EAAA,SACtB,IAAA;EAAA,SACA,UAAA;EAAA,SACA,QAAA;EAAA,SACQ,OAAA;EAAA,SACA,WAAA,GAAc,cAAA;cAEnB,KAAA,EAAO,gBAAA;AAAA;;;KC9BT,oBAAA;AAAA,UAEK,oBAAA;EAAA,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