@prisma-next/sql-contract 0.14.0 → 0.15.0-dev.1
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/canonicalization-hooks.d.mts.map +1 -1
- package/dist/canonicalization-hooks.mjs +70 -50
- package/dist/canonicalization-hooks.mjs.map +1 -1
- package/dist/contract-view.d.mts +61 -0
- package/dist/contract-view.d.mts.map +1 -0
- package/dist/contract-view.mjs +39 -0
- package/dist/contract-view.mjs.map +1 -0
- package/dist/entity-handle-lowering-hook.d.mts +91 -0
- package/dist/entity-handle-lowering-hook.d.mts.map +1 -0
- package/dist/entity-handle-lowering-hook.mjs +11 -0
- package/dist/entity-handle-lowering-hook.mjs.map +1 -0
- package/dist/entity-kinds-CVg6HzG2.mjs +130 -0
- package/dist/entity-kinds-CVg6HzG2.mjs.map +1 -0
- package/dist/entity-kinds.d.mts +2 -1
- package/dist/entity-kinds.d.mts.map +1 -1
- package/dist/entity-kinds.mjs +1 -1
- package/dist/factories.d.mts +7 -6
- package/dist/factories.d.mts.map +1 -1
- package/dist/factories.mjs +5 -11
- package/dist/factories.mjs.map +1 -1
- package/dist/{foreign-key-BATxB95l.d.mts → foreign-key-DuCoGJCf.d.mts} +12 -48
- package/dist/foreign-key-DuCoGJCf.d.mts.map +1 -0
- package/dist/foreign-key-materialization.d.mts +64 -0
- package/dist/foreign-key-materialization.d.mts.map +1 -0
- package/dist/foreign-key-materialization.mjs +67 -0
- package/dist/foreign-key-materialization.mjs.map +1 -0
- package/dist/index-type-validation.d.mts +1 -1
- package/dist/referential-action-sql.d.mts +1 -1
- package/dist/resolve-storage-table.d.mts +2 -2
- package/dist/sql-node-V214WXQD.d.mts +42 -0
- package/dist/sql-node-V214WXQD.d.mts.map +1 -0
- package/dist/{sql-storage-Dga0jwP2.d.mts → sql-storage-p-Wzt_MO.d.mts} +63 -20
- package/dist/sql-storage-p-Wzt_MO.d.mts.map +1 -0
- package/dist/{storage-value-set-WnYsIFM8.d.mts → storage-table-CE-Ns6wa.d.mts} +17 -90
- package/dist/storage-table-CE-Ns6wa.d.mts.map +1 -0
- package/dist/{entity-kinds-Cl36zL5j.mjs → storage-table-DBpYBmty.mjs} +26 -162
- package/dist/storage-table-DBpYBmty.mjs.map +1 -0
- package/dist/storage-value-set-3BKuha5q.mjs +38 -0
- package/dist/storage-value-set-3BKuha5q.mjs.map +1 -0
- package/dist/storage-value-set-D-jww77l.d.mts +41 -0
- package/dist/storage-value-set-D-jww77l.d.mts.map +1 -0
- package/dist/{types-B1N8w0I2.d.mts → types-3vOIrnvp.d.mts} +25 -55
- package/dist/types-3vOIrnvp.d.mts.map +1 -0
- package/dist/types.d.mts +14 -5
- package/dist/types.d.mts.map +1 -0
- package/dist/types.mjs +115 -3
- package/dist/types.mjs.map +1 -0
- package/dist/unique-constraint-C0De4sLU.d.mts +55 -0
- package/dist/unique-constraint-C0De4sLU.d.mts.map +1 -0
- package/dist/validators.d.mts +10 -7
- package/dist/validators.d.mts.map +1 -1
- package/dist/validators.mjs +111 -21
- package/dist/validators.mjs.map +1 -1
- package/dist/value-set-derivation-hook.d.mts +35 -0
- package/dist/value-set-derivation-hook.d.mts.map +1 -0
- package/dist/value-set-derivation-hook.mjs +22 -0
- package/dist/value-set-derivation-hook.mjs.map +1 -0
- package/package.json +15 -10
- package/src/canonicalization-hooks.ts +31 -3
- package/src/column-type-resolution.ts +26 -0
- package/src/contract-view.ts +98 -0
- package/src/entity-handle-lowering-hook.ts +104 -0
- package/src/exports/contract-view.ts +11 -0
- package/src/exports/entity-handle-lowering-hook.ts +10 -0
- package/src/exports/foreign-key-materialization.ts +8 -0
- package/src/exports/types.ts +17 -4
- package/src/exports/value-set-derivation-hook.ts +2 -0
- package/src/factories.ts +13 -7
- package/src/foreign-key-materialization.ts +107 -0
- package/src/ir/foreign-key.ts +9 -9
- package/src/ir/sql-storage.ts +81 -17
- package/src/ir/storage-column.ts +3 -0
- package/src/ir/storage-entry-schemas.ts +1 -2
- package/src/ir/storage-table.ts +21 -0
- package/src/ir/storage-value-set.ts +5 -0
- package/src/types.ts +51 -8
- package/src/validators.ts +215 -42
- package/src/value-set-derivation-hook.ts +47 -0
- package/dist/entity-kinds-Cl36zL5j.mjs.map +0 -1
- package/dist/foreign-key-BATxB95l.d.mts.map +0 -1
- package/dist/sql-storage-Dga0jwP2.d.mts.map +0 -1
- package/dist/storage-value-set-WnYsIFM8.d.mts.map +0 -1
- package/dist/types-B-eiQXff.mjs +0 -191
- package/dist/types-B-eiQXff.mjs.map +0 -1
- package/dist/types-B1N8w0I2.d.mts.map +0 -1
- package/src/ir/build-sql-namespace.ts +0 -110
- package/src/ir/sql-unbound-namespace.ts +0 -74
|
@@ -1,103 +1,5 @@
|
|
|
1
|
-
import { type } from "arktype";
|
|
2
1
|
import { IRNodeBase, freezeNode } from "@prisma-next/framework-components/ir";
|
|
3
2
|
import { asNamespaceId } from "@prisma-next/contract/types";
|
|
4
|
-
//#region src/ir/storage-entry-schemas.ts
|
|
5
|
-
const literalKindSchema = type("'literal'");
|
|
6
|
-
const functionKindSchema = type("'function'");
|
|
7
|
-
const ControlPolicySchema = type("'managed' | 'tolerated' | 'external' | 'observed'");
|
|
8
|
-
const ColumnDefaultLiteralSchema = type.declare().type({
|
|
9
|
-
kind: literalKindSchema,
|
|
10
|
-
value: "string | number | boolean | null | unknown[] | Record<string, unknown>"
|
|
11
|
-
});
|
|
12
|
-
const ColumnDefaultFunctionSchema = type.declare().type({
|
|
13
|
-
kind: functionKindSchema,
|
|
14
|
-
expression: "string"
|
|
15
|
-
});
|
|
16
|
-
const ColumnDefaultSchema = ColumnDefaultLiteralSchema.or(ColumnDefaultFunctionSchema);
|
|
17
|
-
const StorageValueSetRefSchema = type({
|
|
18
|
-
plane: "'storage'",
|
|
19
|
-
namespaceId: "string",
|
|
20
|
-
entityKind: "'valueSet'",
|
|
21
|
-
entityName: "string",
|
|
22
|
-
"spaceId?": "string"
|
|
23
|
-
});
|
|
24
|
-
const StorageColumnSchema = type({
|
|
25
|
-
"+": "reject",
|
|
26
|
-
nativeType: "string",
|
|
27
|
-
codecId: "string",
|
|
28
|
-
nullable: "boolean",
|
|
29
|
-
"typeParams?": "Record<string, unknown>",
|
|
30
|
-
"typeRef?": "string",
|
|
31
|
-
"default?": ColumnDefaultSchema,
|
|
32
|
-
"control?": ControlPolicySchema,
|
|
33
|
-
"valueSet?": StorageValueSetRefSchema
|
|
34
|
-
}).narrow((col, ctx) => {
|
|
35
|
-
if (col.typeParams !== void 0 && col.typeRef !== void 0) return ctx.mustBe("a column with either typeParams or typeRef, not both");
|
|
36
|
-
return true;
|
|
37
|
-
});
|
|
38
|
-
/**
|
|
39
|
-
* Storage value-set entry under `storage.namespaces[id].entries.valueSet[name]`.
|
|
40
|
-
* Carries a `kind: 'valueSet'` discriminator (enumerable, survives JSON) and an
|
|
41
|
-
* ordered `values` array of codec-encoded permitted values.
|
|
42
|
-
*/
|
|
43
|
-
const StorageValueSetSchema = type({
|
|
44
|
-
kind: "'valueSet'",
|
|
45
|
-
values: type("string | number | boolean | null | unknown[] | Record<string, unknown>").array().readonly()
|
|
46
|
-
});
|
|
47
|
-
const PrimaryKeySchema = type.declare().type({
|
|
48
|
-
columns: type.string.array().readonly(),
|
|
49
|
-
"name?": "string"
|
|
50
|
-
});
|
|
51
|
-
const UniqueConstraintSchema = type.declare().type({
|
|
52
|
-
columns: type.string.array().readonly(),
|
|
53
|
-
"name?": "string"
|
|
54
|
-
});
|
|
55
|
-
const IndexSchema = type({
|
|
56
|
-
columns: type.string.array().readonly(),
|
|
57
|
-
"name?": "string",
|
|
58
|
-
"type?": "string",
|
|
59
|
-
"options?": "Record<string, unknown>"
|
|
60
|
-
});
|
|
61
|
-
const ForeignKeyReferenceSchema = type({
|
|
62
|
-
"+": "reject",
|
|
63
|
-
namespaceId: "string",
|
|
64
|
-
tableName: "string",
|
|
65
|
-
columns: type.string.array().readonly(),
|
|
66
|
-
"spaceId?": "string"
|
|
67
|
-
});
|
|
68
|
-
const ForeignKeySourceSchema = type({
|
|
69
|
-
"+": "reject",
|
|
70
|
-
namespaceId: "string",
|
|
71
|
-
tableName: "string",
|
|
72
|
-
columns: type.string.array().readonly()
|
|
73
|
-
});
|
|
74
|
-
const ReferentialActionSchema = type.declare().type("'noAction' | 'restrict' | 'cascade' | 'setNull' | 'setDefault'");
|
|
75
|
-
const ForeignKeySchema = type.declare().type({
|
|
76
|
-
source: ForeignKeySourceSchema,
|
|
77
|
-
target: ForeignKeyReferenceSchema,
|
|
78
|
-
"name?": "string",
|
|
79
|
-
"onDelete?": ReferentialActionSchema,
|
|
80
|
-
"onUpdate?": ReferentialActionSchema,
|
|
81
|
-
constraint: "boolean",
|
|
82
|
-
index: "boolean"
|
|
83
|
-
});
|
|
84
|
-
const CheckConstraintSchema = type({
|
|
85
|
-
"+": "reject",
|
|
86
|
-
name: "string",
|
|
87
|
-
column: "string",
|
|
88
|
-
valueSet: StorageValueSetRefSchema
|
|
89
|
-
});
|
|
90
|
-
const StorageTableSchema = type({
|
|
91
|
-
"+": "reject",
|
|
92
|
-
columns: type({ "[string]": StorageColumnSchema }),
|
|
93
|
-
"primaryKey?": PrimaryKeySchema,
|
|
94
|
-
uniques: UniqueConstraintSchema.array().readonly(),
|
|
95
|
-
indexes: IndexSchema.array().readonly(),
|
|
96
|
-
foreignKeys: ForeignKeySchema.array().readonly(),
|
|
97
|
-
"control?": ControlPolicySchema,
|
|
98
|
-
"checks?": CheckConstraintSchema.array().readonly()
|
|
99
|
-
});
|
|
100
|
-
//#endregion
|
|
101
3
|
//#region src/ir/sql-node.ts
|
|
102
4
|
/**
|
|
103
5
|
* SQL family IR node base. Carries the family-level `kind` discriminator
|
|
@@ -205,7 +107,15 @@ var ForeignKeyReference = class extends SqlNode {
|
|
|
205
107
|
//#endregion
|
|
206
108
|
//#region src/ir/foreign-key.ts
|
|
207
109
|
/**
|
|
208
|
-
* SQL Contract IR node for a table-level foreign-key declaration
|
|
110
|
+
* SQL Contract IR node for a table-level foreign-key declaration — the
|
|
111
|
+
* referential constraint only (source, target, `onDelete`/`onUpdate`).
|
|
112
|
+
*
|
|
113
|
+
* A persisted `foreignKeys[]` entry always denotes a real constraint: whether
|
|
114
|
+
* to emit the constraint at all, and whether to back it with an index, are
|
|
115
|
+
* authoring-time decisions (PSL `@relation(index:)`, TS `fk({ constraint,
|
|
116
|
+
* index })`) resolved once at `contract emit` — a `constraint: false` FK
|
|
117
|
+
* simply has no entry here, and a backing index (if any) is its own discrete,
|
|
118
|
+
* named entry in the table's `indexes[]`.
|
|
209
119
|
*
|
|
210
120
|
* Each FK carries explicit `source` and `target` {@link ForeignKeyReference}
|
|
211
121
|
* coordinates (namespace, table, columns). For single-namespace contracts the
|
|
@@ -219,14 +129,10 @@ var ForeignKeyReference = class extends SqlNode {
|
|
|
219
129
|
var ForeignKey = class extends SqlNode {
|
|
220
130
|
source;
|
|
221
131
|
target;
|
|
222
|
-
constraint;
|
|
223
|
-
index;
|
|
224
132
|
constructor(input) {
|
|
225
133
|
super();
|
|
226
134
|
this.source = input.source instanceof ForeignKeyReference ? input.source : new ForeignKeyReference(input.source);
|
|
227
135
|
this.target = input.target instanceof ForeignKeyReference ? input.target : new ForeignKeyReference(input.target);
|
|
228
|
-
this.constraint = input.constraint;
|
|
229
|
-
this.index = input.index;
|
|
230
136
|
if (input.name !== void 0) this.name = input.name;
|
|
231
137
|
if (input.onDelete !== void 0) this.onDelete = input.onDelete;
|
|
232
138
|
if (input.onUpdate !== void 0) this.onUpdate = input.onUpdate;
|
|
@@ -292,6 +198,7 @@ var StorageColumn = class extends SqlNode {
|
|
|
292
198
|
this.nativeType = input.nativeType;
|
|
293
199
|
this.codecId = input.codecId;
|
|
294
200
|
this.nullable = input.nullable;
|
|
201
|
+
if (input.many !== void 0) this.many = input.many;
|
|
295
202
|
if (input.typeParams !== void 0) this.typeParams = input.typeParams;
|
|
296
203
|
if (input.typeRef !== void 0) this.typeRef = input.typeRef;
|
|
297
204
|
if (input.default !== void 0) this.default = input.default;
|
|
@@ -328,7 +235,7 @@ var UniqueConstraint = class extends SqlNode {
|
|
|
328
235
|
* The table's `name` is not on the class — tables are keyed by name in
|
|
329
236
|
* the parent namespace's `tables: Record<string, StorageTable>` map.
|
|
330
237
|
*/
|
|
331
|
-
var StorageTable = class extends SqlNode {
|
|
238
|
+
var StorageTable = class StorageTable extends SqlNode {
|
|
332
239
|
columns;
|
|
333
240
|
uniques;
|
|
334
241
|
indexes;
|
|
@@ -344,65 +251,22 @@ var StorageTable = class extends SqlNode {
|
|
|
344
251
|
if (input.checks !== void 0 && input.checks.length > 0) this.checks = Object.freeze(input.checks.map((cc) => new CheckConstraint(cc)));
|
|
345
252
|
freezeNode(this);
|
|
346
253
|
}
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
*
|
|
352
|
-
*
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
* only the permitted values.
|
|
358
|
-
*
|
|
359
|
-
* The node's `kind` is enumerable (`'valueSet'`) so the JSON envelope
|
|
360
|
-
* carries the discriminator and the serializer hydration walker can
|
|
361
|
-
* dispatch on it. This follows the per-leaf enumerable-kind convention
|
|
362
|
-
* established in the SQL-node comment (future polymorphic dispatch on
|
|
363
|
-
* namespace entries needs the discriminator in JSON).
|
|
364
|
-
*
|
|
365
|
-
* The entry's name is not on the class — value-sets are keyed by name in
|
|
366
|
-
* the parent namespace's `valueSet: Record<string, StorageValueSet>` map.
|
|
367
|
-
*/
|
|
368
|
-
var StorageValueSet = class extends SqlNode {
|
|
369
|
-
kind = "valueSet";
|
|
370
|
-
values;
|
|
371
|
-
constructor(input) {
|
|
372
|
-
super();
|
|
373
|
-
this.values = Object.freeze([...input.values]);
|
|
374
|
-
freezeNode(this);
|
|
254
|
+
/**
|
|
255
|
+
* Runtime guard that a namespace `table` entry is really a `StorageTable`.
|
|
256
|
+
* The compiler already types the entry as `StorageTable`, but a
|
|
257
|
+
* freshly-deserialized contract may carry plain JSON at that slot until
|
|
258
|
+
* hydration; this duck-types the structural shape. Accepts `undefined` so
|
|
259
|
+
* optional-chained entry lookups pass straight through.
|
|
260
|
+
*/
|
|
261
|
+
static is(value) {
|
|
262
|
+
if (typeof value !== "object" || value === null) return false;
|
|
263
|
+
return "columns" in value && "uniques" in value && "indexes" in value && "foreignKeys" in value;
|
|
375
264
|
}
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
//#region src/entity-kinds.ts
|
|
379
|
-
const tableEntityKind = {
|
|
380
|
-
kind: "table",
|
|
381
|
-
schema: StorageTableSchema,
|
|
382
|
-
construct: (input) => new StorageTable(input)
|
|
383
|
-
};
|
|
384
|
-
const valueSetEntityKind = {
|
|
385
|
-
kind: "valueSet",
|
|
386
|
-
schema: StorageValueSetSchema,
|
|
387
|
-
construct: (input) => new StorageValueSet(input)
|
|
388
|
-
};
|
|
389
|
-
/**
|
|
390
|
-
* Assembles the `kind → descriptor` registry for SQL namespaces: the built-in
|
|
391
|
-
* `table` and `valueSet` kinds plus any target `packKinds`. This builds the
|
|
392
|
-
* lookup table — it does not touch contract data. `hydrateNamespaceEntities`
|
|
393
|
-
* later consumes this registry to turn a namespace's raw entries into IR
|
|
394
|
-
* instances, and `createSqlContractSchema` derives validation from the same
|
|
395
|
-
* registry. Throws on a duplicate kind.
|
|
396
|
-
*/
|
|
397
|
-
function composeSqlEntityKinds(packKinds = []) {
|
|
398
|
-
const kinds = new Map([["table", tableEntityKind], ["valueSet", valueSetEntityKind]]);
|
|
399
|
-
for (const descriptor of packKinds) {
|
|
400
|
-
if (kinds.has(descriptor.kind)) throw new Error(`composeSqlEntityKinds: duplicate entity kind "${descriptor.kind}" — each kind may be registered only once`);
|
|
401
|
-
kinds.set(descriptor.kind, descriptor);
|
|
265
|
+
static assert(value, coordinate) {
|
|
266
|
+
if (!StorageTable.is(value)) throw new Error(`Expected a StorageTable at ${coordinate}`);
|
|
402
267
|
}
|
|
403
|
-
|
|
404
|
-
}
|
|
268
|
+
};
|
|
405
269
|
//#endregion
|
|
406
|
-
export {
|
|
270
|
+
export { PrimaryKey as a, CheckConstraint as c, Index as i, SqlNode as l, UniqueConstraint as n, ForeignKey as o, StorageColumn as r, ForeignKeyReference as s, StorageTable as t };
|
|
407
271
|
|
|
408
|
-
//# sourceMappingURL=
|
|
272
|
+
//# sourceMappingURL=storage-table-DBpYBmty.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"storage-table-DBpYBmty.mjs","names":[],"sources":["../src/ir/sql-node.ts","../src/ir/check-constraint.ts","../src/ir/foreign-key-reference.ts","../src/ir/foreign-key.ts","../src/ir/primary-key.ts","../src/ir/sql-index.ts","../src/ir/storage-column.ts","../src/ir/unique-constraint.ts","../src/ir/storage-table.ts"],"sourcesContent":["import { IRNodeBase } from '@prisma-next/framework-components/ir';\n\n/**\n * SQL family IR node base. Carries the family-level `kind` discriminator\n * `'sql'` and inherits the framework's `freezeNode` affordance.\n *\n * Single family-level discriminator (not per-leaf) reflects the fact that\n * SQL IR has no polymorphic dispatch today — verifiers and serializers\n * walk by structural position (`storage.tables[name].columns[name]`),\n * not by inspecting `kind`. The abstract bar for per-leaf discriminators\n * isn't earned until a future polymorphic consumer arrives.\n *\n * `kind` is installed as a non-enumerable own property on every instance,\n * which keeps three things clean simultaneously:\n *\n * - `JSON.stringify(node)` produces the canonical pre-lift JSON envelope\n * shape (no `kind` field), so emitted contract.json files and the\n * `validateSqlContractFully` arktype schemas stay unchanged.\n * - Test assertions that use `toEqual({...})` against the pre-lift flat\n * shape continue to pass — only enumerable own properties are\n * compared.\n * - Direct access (`node.kind`) and runtime narrowing\n * (`if (node.kind === 'sql')`) still work, so future polymorphic\n * dispatch can begin reading `kind` without a runtime change.\n *\n * Future per-leaf overrides land cleanly: a class that gains a\n * polymorphic-dispatch consumer (e.g. an enum type instance walked\n * alongside other types) overrides `kind` with its narrower literal\n * at that leaf level. Per-leaf overrides will use enumerable kind\n * (matching the Mongo per-class-discriminator precedent) because they\n * encode dispatch-relevant information that callers need to see in\n * JSON envelopes; the family-level `'sql'` is uniform across all SQL\n * IR and carries no dispatch-relevant information.\n */\nexport abstract class SqlNode extends IRNodeBase {\n readonly kind?: string;\n\n constructor() {\n super();\n Object.defineProperty(this, 'kind', {\n value: 'sql',\n writable: false,\n enumerable: false,\n // configurable so per-leaf subclasses (e.g. StorageValueSet)\n // can override `kind` with their narrower\n // enumerable literal via a class-field initializer. SqlNode\n // itself never needs to mutate the property again, so\n // configurability has no surface impact at this layer.\n configurable: true,\n });\n }\n}\n","import type { ValueSetRef } from '@prisma-next/contract/types';\nimport { freezeNode } from '@prisma-next/framework-components/ir';\nimport { SqlNode } from './sql-node';\n\n/**\n * Hydration / construction input shape for {@link CheckConstraint}.\n * Mirrors the on-disk storage JSON envelope so the serializer hydration\n * walker can hand a validated literal straight to `new`.\n */\nexport interface CheckConstraintInput {\n readonly name: string;\n readonly column: string;\n readonly valueSet: ValueSetRef;\n}\n\n/**\n * SQL Contract IR node for a table-level check constraint that restricts\n * a column to the permitted values of a value-set.\n *\n * The constraint is **structured** (names a column and a value-set\n * reference), not a raw SQL expression. Each target renders its own DDL\n * from the structured form, keeping the contract target-agnostic.\n *\n * Construction is idempotent: passing an existing `CheckConstraint`\n * instance as input produces a new instance with identical fields.\n * The constructor does not use `instanceof` for input discrimination —\n * it reads plain named properties, which is sufficient since\n * `CheckConstraintInput` is a structural type.\n */\nexport class CheckConstraint extends SqlNode {\n readonly name: string;\n readonly column: string;\n readonly valueSet: ValueSetRef;\n\n constructor(input: CheckConstraintInput) {\n super();\n this.name = input.name;\n this.column = input.column;\n this.valueSet = input.valueSet;\n freezeNode(this);\n }\n}\n","import { asNamespaceId, type NamespaceId } from '@prisma-next/contract/types';\nimport { freezeNode } from '@prisma-next/framework-components/ir';\nimport { SqlNode } from './sql-node';\n\n/**\n * Input for a foreign-key reference (one side of a foreign-key declaration).\n *\n * When `spaceId` is absent the reference is local — the referenced table lives\n * in the same contract-space. When `spaceId` is present the reference is\n * cross-space — the referenced table lives in a different contract-space\n * identified by `spaceId`.\n *\n * Presence-based discrimination keeps local FK JSON byte-identical to\n * contracts authored before cross-space support was added.\n */\nexport interface ForeignKeyReferenceInput {\n readonly namespaceId: string;\n readonly tableName: string;\n readonly columns: readonly string[];\n readonly spaceId?: string;\n}\n\n/**\n * SQL Contract IR node for one side (source or target) of a foreign-key\n * declaration. Carries the full coordinate: namespace, table, and columns.\n *\n * Cross-space discrimination is based on `spaceId` presence: absent means\n * local (same contract-space); present means cross-space (the referenced\n * table lives in the contract-space identified by `spaceId`).\n *\n * For local references `spaceId` is absent from JSON, keeping the serialized\n * shape byte-identical to contracts authored before cross-space support was\n * added. For cross-space references `spaceId` appears in JSON so round-trips\n * are lossless.\n *\n * Use `UNBOUND_NAMESPACE_ID` from `@prisma-next/framework-components/ir`\n * as the sentinel `namespaceId` for single-namespace (unbound) references.\n */\nexport class ForeignKeyReference extends SqlNode {\n readonly namespaceId: NamespaceId;\n readonly tableName: string;\n readonly columns: readonly string[];\n declare readonly spaceId?: string;\n\n constructor(input: ForeignKeyReferenceInput) {\n super();\n this.namespaceId = asNamespaceId(input.namespaceId);\n this.tableName = input.tableName;\n this.columns = input.columns;\n if (input.spaceId !== undefined) this.spaceId = input.spaceId;\n freezeNode(this);\n }\n}\n","import { freezeNode } from '@prisma-next/framework-components/ir';\nimport { ForeignKeyReference, type ForeignKeyReferenceInput } from './foreign-key-reference';\nimport { SqlNode } from './sql-node';\n\nexport type ReferentialAction = 'noAction' | 'restrict' | 'cascade' | 'setNull' | 'setDefault';\n\nexport interface ForeignKeyInput {\n readonly source: ForeignKeyReference | ForeignKeyReferenceInput;\n readonly target: ForeignKeyReference | ForeignKeyReferenceInput;\n readonly name?: string;\n readonly onDelete?: ReferentialAction;\n readonly onUpdate?: ReferentialAction;\n}\n\n/**\n * SQL Contract IR node for a table-level foreign-key declaration — the\n * referential constraint only (source, target, `onDelete`/`onUpdate`).\n *\n * A persisted `foreignKeys[]` entry always denotes a real constraint: whether\n * to emit the constraint at all, and whether to back it with an index, are\n * authoring-time decisions (PSL `@relation(index:)`, TS `fk({ constraint,\n * index })`) resolved once at `contract emit` — a `constraint: false` FK\n * simply has no entry here, and a backing index (if any) is its own discrete,\n * named entry in the table's `indexes[]`.\n *\n * Each FK carries explicit `source` and `target` {@link ForeignKeyReference}\n * coordinates (namespace, table, columns). For single-namespace contracts the\n * sentinel `UNBOUND_NAMESPACE_ID` appears on both sides.\n *\n * The nested references are normalised to {@link ForeignKeyReference}\n * instances inside the constructor so downstream walks see a uniform AST\n * regardless of whether the input was a JSON literal or an already-constructed\n * class instance.\n */\nexport class ForeignKey extends SqlNode {\n readonly source: ForeignKeyReference;\n readonly target: ForeignKeyReference;\n declare readonly name?: string;\n declare readonly onDelete?: ReferentialAction;\n declare readonly onUpdate?: ReferentialAction;\n\n constructor(input: ForeignKeyInput) {\n super();\n this.source =\n input.source instanceof ForeignKeyReference\n ? input.source\n : new ForeignKeyReference(input.source);\n this.target =\n input.target instanceof ForeignKeyReference\n ? input.target\n : new ForeignKeyReference(input.target);\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 freezeNode(this);\n }\n}\n","import { freezeNode } from '@prisma-next/framework-components/ir';\nimport { SqlNode } from './sql-node';\n\nexport interface PrimaryKeyInput {\n readonly columns: readonly string[];\n readonly name?: string;\n}\n\n/**\n * SQL Contract IR node for a table's primary-key constraint.\n */\nexport class PrimaryKey extends SqlNode {\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 { SqlNode } from './sql-node';\n\nexport interface IndexInput {\n readonly columns: readonly string[];\n readonly name?: string;\n readonly type?: string;\n readonly options?: Record<string, unknown>;\n}\n\n/**\n * SQL Contract IR node for a table-level secondary index.\n *\n * Note that this class shadows the global TypeScript `Index` lib type\n * at the family-shared name; consumer files that need both should\n * alias one (e.g.\n * `import { Index as SqlIndexNode } from '@prisma-next/sql-contract/types'`).\n */\nexport class Index extends SqlNode {\n readonly columns: readonly string[];\n declare readonly name?: string;\n declare readonly type?: string;\n declare readonly options?: Record<string, unknown>;\n\n constructor(input: IndexInput) {\n super();\n this.columns = input.columns;\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 freezeNode(this);\n }\n}\n","import type { ColumnDefault, ControlPolicy, ValueSetRef } from '@prisma-next/contract/types';\nimport { freezeNode } from '@prisma-next/framework-components/ir';\nimport { SqlNode } from './sql-node';\n\n/**\n * Hydration / construction input shape for {@link StorageColumn}. Mirrors\n * the on-disk storage JSON envelope exactly so the family-base\n * serializer's hydration walker can hand an arktype-validated literal\n * straight to `new`.\n *\n * `typeParams` and `typeRef` remain mutually exclusive (one or the\n * other, not both); the constructor preserves whichever caller-side\n * choice the input encodes.\n */\nexport interface StorageColumnInput {\n readonly nativeType: string;\n readonly codecId: string;\n readonly nullable: boolean;\n readonly many?: boolean;\n readonly typeParams?: Record<string, unknown>;\n readonly typeRef?: string;\n readonly default?: ColumnDefault;\n readonly control?: ControlPolicy;\n readonly valueSet?: ValueSetRef;\n}\n\n/**\n * SQL Contract IR node for a single column entry in `StorageTable.columns`.\n *\n * Single concrete family-shared class — every SQL target reads the\n * same column shape today, so there is no per-target subclass. The\n * class type accepts any caller that constructs via\n * `new StorageColumn(input)`; literal construction sites must pass\n * through the constructor or the family-base hydration walker.\n *\n * The column's `name` is not on the class — columns are keyed by name\n * in the parent `StorageTable.columns: Record<string, StorageColumn>`\n * map, so a `name` field would be redundant with the key.\n */\nexport class StorageColumn extends SqlNode {\n readonly nativeType: string;\n readonly codecId: string;\n readonly nullable: boolean;\n declare readonly many?: boolean;\n declare readonly typeParams?: Record<string, unknown>;\n declare readonly typeRef?: string;\n declare readonly default?: ColumnDefault;\n declare readonly control?: ControlPolicy;\n declare readonly valueSet?: ValueSetRef;\n\n constructor(input: StorageColumnInput) {\n super();\n this.nativeType = input.nativeType;\n this.codecId = input.codecId;\n this.nullable = input.nullable;\n if (input.many !== undefined) this.many = input.many;\n if (input.typeParams !== undefined) this.typeParams = input.typeParams;\n if (input.typeRef !== undefined) this.typeRef = input.typeRef;\n if (input.default !== undefined) this.default = input.default;\n if (input.control !== undefined) this.control = input.control;\n if (input.valueSet !== undefined) this.valueSet = input.valueSet;\n freezeNode(this);\n }\n}\n","import { freezeNode } from '@prisma-next/framework-components/ir';\nimport { SqlNode } from './sql-node';\n\nexport interface UniqueConstraintInput {\n readonly columns: readonly string[];\n readonly name?: string;\n}\n\n/**\n * SQL Contract IR node for a table-level unique constraint.\n */\nexport class UniqueConstraint extends SqlNode {\n readonly columns: readonly string[];\n declare readonly name?: string;\n\n constructor(input: UniqueConstraintInput) {\n super();\n this.columns = input.columns;\n if (input.name !== undefined) this.name = input.name;\n freezeNode(this);\n }\n}\n","import type { ControlPolicy } from '@prisma-next/contract/types';\nimport { freezeNode } from '@prisma-next/framework-components/ir';\nimport { CheckConstraint, type CheckConstraintInput } from './check-constraint';\nimport { ForeignKey, type ForeignKeyInput } from './foreign-key';\nimport { PrimaryKey, type PrimaryKeyInput } from './primary-key';\nimport { Index, type IndexInput } from './sql-index';\nimport { SqlNode } from './sql-node';\nimport { StorageColumn, type StorageColumnInput } from './storage-column';\nimport { UniqueConstraint, type UniqueConstraintInput } from './unique-constraint';\n\nexport interface StorageTableInput {\n readonly columns: Record<string, StorageColumn | StorageColumnInput>;\n readonly primaryKey?: PrimaryKey | PrimaryKeyInput;\n readonly uniques: ReadonlyArray<UniqueConstraint | UniqueConstraintInput>;\n readonly indexes: ReadonlyArray<Index | IndexInput>;\n readonly foreignKeys: ReadonlyArray<ForeignKey | ForeignKeyInput>;\n readonly control?: ControlPolicy;\n readonly checks?: ReadonlyArray<CheckConstraint | CheckConstraintInput>;\n}\n\n/**\n * SQL Contract IR node for a single table entry in a namespace's\n * `tables` map.\n *\n * The constructor normalises nested IR-class fields (columns, primary\n * key, uniques, indexes, foreign keys) into the appropriate class\n * instances so downstream walks see a uniform AST regardless of whether\n * the input was a JSON literal or an already-constructed class.\n *\n * The table's `name` is not on the class — tables are keyed by name in\n * the parent namespace's `tables: Record<string, StorageTable>` map.\n */\nexport class StorageTable extends SqlNode {\n readonly columns: Readonly<Record<string, StorageColumn>>;\n readonly uniques: ReadonlyArray<UniqueConstraint>;\n readonly indexes: ReadonlyArray<Index>;\n readonly foreignKeys: ReadonlyArray<ForeignKey>;\n declare readonly primaryKey?: PrimaryKey;\n declare readonly control?: ControlPolicy;\n declare readonly checks?: ReadonlyArray<CheckConstraint>;\n\n constructor(input: StorageTableInput) {\n super();\n this.columns = Object.freeze(\n Object.fromEntries(\n Object.entries(input.columns).map(([name, col]) => [\n name,\n col instanceof StorageColumn ? col : new StorageColumn(col),\n ]),\n ),\n );\n if (input.primaryKey !== undefined) {\n this.primaryKey =\n input.primaryKey instanceof PrimaryKey\n ? input.primaryKey\n : new PrimaryKey(input.primaryKey);\n }\n this.uniques = Object.freeze(\n input.uniques.map((u) => (u instanceof UniqueConstraint ? u : new UniqueConstraint(u))),\n );\n this.indexes = Object.freeze(input.indexes.map((i) => (i instanceof Index ? i : new Index(i))));\n this.foreignKeys = Object.freeze(\n input.foreignKeys.map((fk) => (fk instanceof ForeignKey ? fk : new ForeignKey(fk))),\n );\n if (input.control !== undefined) this.control = input.control;\n if (input.checks !== undefined && input.checks.length > 0) {\n this.checks = Object.freeze(input.checks.map((cc) => new CheckConstraint(cc)));\n }\n freezeNode(this);\n }\n\n /**\n * Runtime guard that a namespace `table` entry is really a `StorageTable`.\n * The compiler already types the entry as `StorageTable`, but a\n * freshly-deserialized contract may carry plain JSON at that slot until\n * hydration; this duck-types the structural shape. Accepts `undefined` so\n * optional-chained entry lookups pass straight through.\n */\n static is(value: StorageTable | undefined): value is StorageTable {\n if (typeof value !== 'object' || value === null) return false;\n return 'columns' in value && 'uniques' in value && 'indexes' in value && 'foreignKeys' in value;\n }\n\n static assert(\n value: StorageTable | undefined,\n coordinate: string,\n ): asserts value is StorageTable {\n if (!StorageTable.is(value)) {\n throw new Error(`Expected a StorageTable at ${coordinate}`);\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkCA,IAAsB,UAAtB,cAAsC,WAAW;CAC/C;CAEA,cAAc;EACZ,MAAM;EACN,OAAO,eAAe,MAAM,QAAQ;GAClC,OAAO;GACP,UAAU;GACV,YAAY;GAMZ,cAAc;EAChB,CAAC;CACH;AACF;;;;;;;;;;;;;;;;;ACtBA,IAAa,kBAAb,cAAqC,QAAQ;CAC3C;CACA;CACA;CAEA,YAAY,OAA6B;EACvC,MAAM;EACN,KAAK,OAAO,MAAM;EAClB,KAAK,SAAS,MAAM;EACpB,KAAK,WAAW,MAAM;EACtB,WAAW,IAAI;CACjB;AACF;;;;;;;;;;;;;;;;;;;ACHA,IAAa,sBAAb,cAAyC,QAAQ;CAC/C;CACA;CACA;CAGA,YAAY,OAAiC;EAC3C,MAAM;EACN,KAAK,cAAc,cAAc,MAAM,WAAW;EAClD,KAAK,YAAY,MAAM;EACvB,KAAK,UAAU,MAAM;EACrB,IAAI,MAAM,YAAY,KAAA,GAAW,KAAK,UAAU,MAAM;EACtD,WAAW,IAAI;CACjB;AACF;;;;;;;;;;;;;;;;;;;;;;;AClBA,IAAa,aAAb,cAAgC,QAAQ;CACtC;CACA;CAKA,YAAY,OAAwB;EAClC,MAAM;EACN,KAAK,SACH,MAAM,kBAAkB,sBACpB,MAAM,SACN,IAAI,oBAAoB,MAAM,MAAM;EAC1C,KAAK,SACH,MAAM,kBAAkB,sBACpB,MAAM,SACN,IAAI,oBAAoB,MAAM,MAAM;EAC1C,IAAI,MAAM,SAAS,KAAA,GAAW,KAAK,OAAO,MAAM;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AAM,IAAI,MAAM,8BAA8B,YAAY;CAE9D;AACF"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { l as SqlNode } from "./storage-table-DBpYBmty.mjs";
|
|
2
|
+
import { freezeNode } from "@prisma-next/framework-components/ir";
|
|
3
|
+
//#region src/ir/storage-value-set.ts
|
|
4
|
+
/**
|
|
5
|
+
* SQL Contract IR node for a value-set entry in a namespace's `valueSet`
|
|
6
|
+
* map (`SqlNamespace.entries.valueSet`).
|
|
7
|
+
*
|
|
8
|
+
* A value-set records the ordered set of permitted codec-encoded values for
|
|
9
|
+
* an enum-like column restriction. It does not carry a `codecId` — the
|
|
10
|
+
* column that references it already holds the codec; the value-set holds
|
|
11
|
+
* only the permitted values.
|
|
12
|
+
*
|
|
13
|
+
* The node's `kind` is enumerable (`'valueSet'`) so the JSON envelope
|
|
14
|
+
* carries the discriminator and the serializer hydration walker can
|
|
15
|
+
* dispatch on it. This follows the per-leaf enumerable-kind convention
|
|
16
|
+
* established in the SQL-node comment (future polymorphic dispatch on
|
|
17
|
+
* namespace entries needs the discriminator in JSON).
|
|
18
|
+
*
|
|
19
|
+
* The entry's name is not on the class — value-sets are keyed by name in
|
|
20
|
+
* the parent namespace's `valueSet: Record<string, StorageValueSet>` map.
|
|
21
|
+
*/
|
|
22
|
+
var StorageValueSet = class extends SqlNode {
|
|
23
|
+
kind = "valueSet";
|
|
24
|
+
values;
|
|
25
|
+
constructor(input) {
|
|
26
|
+
super();
|
|
27
|
+
this.values = Object.freeze([...input.values]);
|
|
28
|
+
freezeNode(this);
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
function isStorageValueSet(value) {
|
|
32
|
+
if (typeof value !== "object" || value === null) return false;
|
|
33
|
+
return "kind" in value && value.kind === "valueSet" && "values" in value;
|
|
34
|
+
}
|
|
35
|
+
//#endregion
|
|
36
|
+
export { isStorageValueSet as n, StorageValueSet as t };
|
|
37
|
+
|
|
38
|
+
//# sourceMappingURL=storage-value-set-3BKuha5q.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"storage-value-set-3BKuha5q.mjs","names":[],"sources":["../src/ir/storage-value-set.ts"],"sourcesContent":["import type { JsonValue } from '@prisma-next/contract/types';\nimport { freezeNode } from '@prisma-next/framework-components/ir';\nimport { SqlNode } from './sql-node';\n\n/**\n * Hydration / construction input shape for {@link StorageValueSet}.\n * Mirrors the on-disk storage JSON envelope so the serializer hydration\n * walker can hand a validated literal straight to `new`.\n */\nexport interface StorageValueSetInput {\n readonly kind: 'valueSet';\n /** Ordered permitted values, codec-encoded. Declaration order is preserved. */\n readonly values: readonly JsonValue[];\n}\n\n/**\n * SQL Contract IR node for a value-set entry in a namespace's `valueSet`\n * map (`SqlNamespace.entries.valueSet`).\n *\n * A value-set records the ordered set of permitted codec-encoded values for\n * an enum-like column restriction. It does not carry a `codecId` — the\n * column that references it already holds the codec; the value-set holds\n * only the permitted values.\n *\n * The node's `kind` is enumerable (`'valueSet'`) so the JSON envelope\n * carries the discriminator and the serializer hydration walker can\n * dispatch on it. This follows the per-leaf enumerable-kind convention\n * established in the SQL-node comment (future polymorphic dispatch on\n * namespace entries needs the discriminator in JSON).\n *\n * The entry's name is not on the class — value-sets are keyed by name in\n * the parent namespace's `valueSet: Record<string, StorageValueSet>` map.\n */\nexport class StorageValueSet extends SqlNode {\n override readonly kind = 'valueSet' as const;\n readonly values: readonly JsonValue[];\n\n constructor(input: StorageValueSetInput) {\n super();\n this.values = Object.freeze([...input.values]);\n freezeNode(this);\n }\n}\n\nexport function isStorageValueSet(value: unknown): value is StorageValueSet {\n if (typeof value !== 'object' || value === null) return false;\n return 'kind' in value && value.kind === 'valueSet' && 'values' in value;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAiCA,IAAa,kBAAb,cAAqC,QAAQ;CAC3C,OAAyB;CACzB;CAEA,YAAY,OAA6B;EACvC,MAAM;EACN,KAAK,SAAS,OAAO,OAAO,CAAC,GAAG,MAAM,MAAM,CAAC;EAC7C,WAAW,IAAI;CACjB;AACF;AAEA,SAAgB,kBAAkB,OAA0C;CAC1E,IAAI,OAAO,UAAU,YAAY,UAAU,MAAM,OAAO;CACxD,OAAO,UAAU,SAAS,MAAM,SAAS,cAAc,YAAY;AACrE"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { t as SqlNode } from "./sql-node-V214WXQD.mjs";
|
|
2
|
+
import { JsonValue } from "@prisma-next/contract/types";
|
|
3
|
+
|
|
4
|
+
//#region src/ir/storage-value-set.d.ts
|
|
5
|
+
/**
|
|
6
|
+
* Hydration / construction input shape for {@link StorageValueSet}.
|
|
7
|
+
* Mirrors the on-disk storage JSON envelope so the serializer hydration
|
|
8
|
+
* walker can hand a validated literal straight to `new`.
|
|
9
|
+
*/
|
|
10
|
+
interface StorageValueSetInput {
|
|
11
|
+
readonly kind: 'valueSet';
|
|
12
|
+
/** Ordered permitted values, codec-encoded. Declaration order is preserved. */
|
|
13
|
+
readonly values: readonly JsonValue[];
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* SQL Contract IR node for a value-set entry in a namespace's `valueSet`
|
|
17
|
+
* map (`SqlNamespace.entries.valueSet`).
|
|
18
|
+
*
|
|
19
|
+
* A value-set records the ordered set of permitted codec-encoded values for
|
|
20
|
+
* an enum-like column restriction. It does not carry a `codecId` — the
|
|
21
|
+
* column that references it already holds the codec; the value-set holds
|
|
22
|
+
* only the permitted values.
|
|
23
|
+
*
|
|
24
|
+
* The node's `kind` is enumerable (`'valueSet'`) so the JSON envelope
|
|
25
|
+
* carries the discriminator and the serializer hydration walker can
|
|
26
|
+
* dispatch on it. This follows the per-leaf enumerable-kind convention
|
|
27
|
+
* established in the SQL-node comment (future polymorphic dispatch on
|
|
28
|
+
* namespace entries needs the discriminator in JSON).
|
|
29
|
+
*
|
|
30
|
+
* The entry's name is not on the class — value-sets are keyed by name in
|
|
31
|
+
* the parent namespace's `valueSet: Record<string, StorageValueSet>` map.
|
|
32
|
+
*/
|
|
33
|
+
declare class StorageValueSet extends SqlNode {
|
|
34
|
+
readonly kind: "valueSet";
|
|
35
|
+
readonly values: readonly JsonValue[];
|
|
36
|
+
constructor(input: StorageValueSetInput);
|
|
37
|
+
}
|
|
38
|
+
declare function isStorageValueSet(value: unknown): value is StorageValueSet;
|
|
39
|
+
//#endregion
|
|
40
|
+
export { StorageValueSetInput as n, isStorageValueSet as r, StorageValueSet as t };
|
|
41
|
+
//# sourceMappingURL=storage-value-set-D-jww77l.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"storage-value-set-D-jww77l.d.mts","names":[],"sources":["../src/ir/storage-value-set.ts"],"mappings":";;;;;;AASA;;;UAAiB,oBAAA;EAAA,SACN,IAAA;EAEA;EAAA,SAAA,MAAA,WAAiB,SAAS;AAAA;AAAA;AAqBrC;;;;;;;;;;;;;;;;AAIyC;AAzBJ,cAqBxB,eAAA,SAAwB,OAAA;EAAA,SACjB,IAAA;EAAA,SACT,MAAA,WAAiB,SAAA;cAEd,KAAA,EAAO,oBAAA;AAAA;AAAA,iBAOL,iBAAA,CAAkB,KAAA,YAAiB,KAAA,IAAS,eAAe"}
|
|
@@ -1,56 +1,7 @@
|
|
|
1
|
-
import { r as ReferentialAction } from "./foreign-key-
|
|
2
|
-
import { r as StorageTable } from "./storage-value-set-WnYsIFM8.mjs";
|
|
3
|
-
import { n as SqlNamespaceEntries, r as SqlNamespaceTablesInput, t as SqlNamespace } from "./sql-storage-Dga0jwP2.mjs";
|
|
4
|
-
import { Namespace, NamespaceBase } from "@prisma-next/framework-components/ir";
|
|
1
|
+
import { r as ReferentialAction } from "./foreign-key-DuCoGJCf.mjs";
|
|
5
2
|
import { CodecTrait } from "@prisma-next/framework-components/codec";
|
|
6
3
|
import { ControlDriverInstance } from "@prisma-next/framework-components/control";
|
|
7
4
|
|
|
8
|
-
//#region src/ir/build-sql-namespace.d.ts
|
|
9
|
-
declare function buildSqlNamespace(input: SqlNamespaceTablesInput): SqlNamespace;
|
|
10
|
-
declare function buildSqlNamespaceMap(namespaces: Readonly<Record<string, Namespace | SqlNamespaceTablesInput>>): Readonly<Record<string, SqlNamespace>>;
|
|
11
|
-
//#endregion
|
|
12
|
-
//#region src/ir/sql-unbound-namespace.d.ts
|
|
13
|
-
/**
|
|
14
|
-
* Family-layer placeholder for the SQL unbound-namespace singleton —
|
|
15
|
-
* the late-bound slot whose binding the target resolves at connection
|
|
16
|
-
* time rather than at authoring time.
|
|
17
|
-
*
|
|
18
|
-
* SQL contracts honour the framework `Storage.namespaces` invariant from
|
|
19
|
-
* the moment they appear in the IR. Today `SqlStorage` is family-shared
|
|
20
|
-
* (Postgres + SQLite consume the same class); a per-target namespace
|
|
21
|
-
* concretion (`PostgresSchema.unbound`, `SqliteUnboundDatabase.instance`)
|
|
22
|
-
* earns its existence when each target's namespace shape lands. Until
|
|
23
|
-
* then the family ships a single placeholder singleton so the JSON
|
|
24
|
-
* envelope and runtime walk are honest at every layer.
|
|
25
|
-
*
|
|
26
|
-
* The `kind` discriminator is installed as a non-enumerable own property
|
|
27
|
-
* so the JSON envelope reads `{ "id": "__unbound__", "entries": { … } }`
|
|
28
|
-
* — symmetric with the family-level non-enumerable `kind` on `SqlNode`
|
|
29
|
-
* and bounded to the minimum data the framework `Namespace` interface
|
|
30
|
-
* promises.
|
|
31
|
-
*
|
|
32
|
-
* **Freeze-trap warning.** The leaf constructor calls
|
|
33
|
-
* `freezeNode(this)` after installing `kind`. The leaf-class shape
|
|
34
|
-
* works today only because `NamespaceBase` does NOT freeze in its
|
|
35
|
-
* constructor — the `Object.defineProperty(this, 'kind', …)` call after
|
|
36
|
-
* `super()` succeeds because the instance is still mutable at that
|
|
37
|
-
* point. Subclasses that add instance fields will still hit the freeze
|
|
38
|
-
* trap once leaf-class `freezeNode(this)` runs; and if a future
|
|
39
|
-
* framework change lifts the freeze to `NamespaceBase`, even the
|
|
40
|
-
* `defineProperty` here would silently fail. To add subclass instance
|
|
41
|
-
* fields safely, lift `freezeNode` to a leaf-class `seal()` hook each
|
|
42
|
-
* leaf calls explicitly at the end of its own constructor.
|
|
43
|
-
*/
|
|
44
|
-
declare class SqlUnboundNamespace extends NamespaceBase {
|
|
45
|
-
static readonly instance: SqlUnboundNamespace;
|
|
46
|
-
readonly id: "__unbound__";
|
|
47
|
-
readonly entries: SqlNamespaceEntries;
|
|
48
|
-
readonly kind: string;
|
|
49
|
-
private constructor();
|
|
50
|
-
get table(): Readonly<Record<string, StorageTable>>;
|
|
51
|
-
qualifyTable(tableName: string): string;
|
|
52
|
-
}
|
|
53
|
-
//#endregion
|
|
54
5
|
//#region src/types.d.ts
|
|
55
6
|
interface SqlControlDriverInstance<T extends string = string> extends ControlDriverInstance<'sql', T> {
|
|
56
7
|
query<Row = Record<string, unknown>>(sql: string, params?: readonly unknown[]): Promise<{
|
|
@@ -85,13 +36,16 @@ declare function applyFkDefaults(fk: {
|
|
|
85
36
|
index: boolean;
|
|
86
37
|
};
|
|
87
38
|
type NamespacedFieldTypeMap = Record<string, Record<string, Record<string, unknown>>>;
|
|
39
|
+
type NamespacedStorageColumnTypeMap = Record<string, Record<string, Record<string, unknown>>>;
|
|
88
40
|
type TypeMaps<TCodecTypes extends Record<string, {
|
|
89
41
|
output: unknown;
|
|
90
|
-
}> = Record<string, never>, TQueryOperationTypes extends Record<string, unknown> = Record<string, never>, TFieldOutputTypes extends NamespacedFieldTypeMap = Record<string, never>, TFieldInputTypes extends NamespacedFieldTypeMap = Record<string, never>> = {
|
|
42
|
+
}> = Record<string, never>, TQueryOperationTypes extends Record<string, unknown> = Record<string, never>, TFieldOutputTypes extends NamespacedFieldTypeMap = Record<string, never>, TFieldInputTypes extends NamespacedFieldTypeMap = Record<string, never>, TStorageColumnTypes extends NamespacedStorageColumnTypeMap = Record<string, never>, TStorageColumnInputTypes extends NamespacedStorageColumnTypeMap = Record<string, never>> = {
|
|
91
43
|
readonly codecTypes: TCodecTypes;
|
|
92
44
|
readonly queryOperationTypes: TQueryOperationTypes;
|
|
93
45
|
readonly fieldOutputTypes: TFieldOutputTypes;
|
|
94
46
|
readonly fieldInputTypes: TFieldInputTypes;
|
|
47
|
+
readonly storageColumnTypes: TStorageColumnTypes;
|
|
48
|
+
readonly storageColumnInputTypes: TStorageColumnInputTypes;
|
|
95
49
|
};
|
|
96
50
|
type CodecTypesOf<T> = [T] extends [never] ? Record<string, never> : T extends {
|
|
97
51
|
readonly codecTypes: infer C;
|
|
@@ -102,15 +56,23 @@ type CodecTypesOf<T> = [T] extends [never] ? Record<string, never> : T extends {
|
|
|
102
56
|
* Dispatch hint identifying the first-argument target of an operation.
|
|
103
57
|
*
|
|
104
58
|
* Used by ORM column helpers to decide whether an operation is reachable on a
|
|
105
|
-
* field.
|
|
106
|
-
*
|
|
59
|
+
* field. Names a concrete codec identity, a set of capability traits the
|
|
60
|
+
* field's codec must carry, or targets list-typed (`many`) fields. Element
|
|
61
|
+
* capability gating for list ops travels in `elementTraits`.
|
|
107
62
|
*/
|
|
108
63
|
type QueryOperationSelfSpec = {
|
|
109
64
|
readonly codecId: string;
|
|
110
65
|
readonly traits?: never;
|
|
66
|
+
readonly many?: never;
|
|
111
67
|
} | {
|
|
112
68
|
readonly traits: readonly CodecTrait[];
|
|
113
69
|
readonly codecId?: never;
|
|
70
|
+
readonly many?: never;
|
|
71
|
+
} | {
|
|
72
|
+
readonly many: true;
|
|
73
|
+
readonly elementTraits?: readonly CodecTrait[];
|
|
74
|
+
readonly codecId?: never;
|
|
75
|
+
readonly traits?: never;
|
|
114
76
|
};
|
|
115
77
|
/**
|
|
116
78
|
* Structural shape an operation's impl must return: any value carrying a
|
|
@@ -147,11 +109,19 @@ type FieldOutputTypesOf<T> = [T] extends [never] ? Record<string, never> : T ext
|
|
|
147
109
|
type FieldInputTypesOf<T> = [T] extends [never] ? Record<string, never> : T extends {
|
|
148
110
|
readonly fieldInputTypes: infer F;
|
|
149
111
|
} ? F extends NamespacedFieldTypeMap ? F : Record<string, never> : Record<string, never>;
|
|
112
|
+
type StorageColumnTypesOf<T> = [T] extends [never] ? Record<string, never> : T extends {
|
|
113
|
+
readonly storageColumnTypes: infer F;
|
|
114
|
+
} ? F extends NamespacedStorageColumnTypeMap ? F : Record<string, never> : Record<string, never>;
|
|
115
|
+
type StorageColumnInputTypesOf<T> = [T] extends [never] ? Record<string, never> : T extends {
|
|
116
|
+
readonly storageColumnInputTypes: infer F;
|
|
117
|
+
} ? F extends NamespacedStorageColumnTypeMap ? F : Record<string, never> : Record<string, never>;
|
|
150
118
|
type ExtractCodecTypes<T> = CodecTypesOf<ExtractTypeMapsFromContract<T>>;
|
|
151
119
|
type ExtractQueryOperationTypes<T> = QueryOperationTypesOf<ExtractTypeMapsFromContract<T>>;
|
|
152
120
|
type ExtractFieldOutputTypes<T> = FieldOutputTypesOf<ExtractTypeMapsFromContract<T>>;
|
|
153
121
|
type ExtractFieldInputTypes<T> = FieldInputTypesOf<ExtractTypeMapsFromContract<T>>;
|
|
122
|
+
type ExtractStorageColumnTypes<T> = StorageColumnTypesOf<ExtractTypeMapsFromContract<T>>;
|
|
123
|
+
type ExtractStorageColumnInputTypes<T> = StorageColumnInputTypesOf<ExtractTypeMapsFromContract<T>>;
|
|
154
124
|
type ResolveCodecTypes<TContract, TTypeMaps> = [TTypeMaps] extends [never] ? ExtractCodecTypes<TContract> : CodecTypesOf<TTypeMaps>;
|
|
155
125
|
//#endregion
|
|
156
|
-
export {
|
|
157
|
-
//# sourceMappingURL=types-
|
|
126
|
+
export { TypeMapsPhantomKey as A, SqlControlDriverInstance as C, StorageColumnInputTypesOf as D, SqlQueryOperationTypes as E, StorageColumnTypesOf as O, ResolveCodecTypes as S, SqlModelStorage as T, QueryOperationReturn as _, ExtractCodecTypes as a, QueryOperationTypesBase as b, ExtractQueryOperationTypes as c, ExtractTypeMapsFromContract as d, FieldInputTypesOf as f, NamespacedStorageColumnTypeMap as g, NamespacedFieldTypeMap as h, DEFAULT_FK_INDEX as i, applyFkDefaults as j, TypeMaps as k, ExtractStorageColumnInputTypes as l, ForeignKeyOptions as m, ContractWithTypeMaps as n, ExtractFieldInputTypes as o, FieldOutputTypesOf as p, DEFAULT_FK_CONSTRAINT as r, ExtractFieldOutputTypes as s, CodecTypesOf as t, ExtractStorageColumnTypes as u, QueryOperationSelfSpec as v, SqlModelFieldStorage as w, QueryOperationTypesOf as x, QueryOperationTypeEntry as y };
|
|
127
|
+
//# sourceMappingURL=types-3vOIrnvp.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types-3vOIrnvp.d.mts","names":[],"sources":["../src/types.ts"],"mappings":";;;;;UAIiB,wBAAA,oCACP,qBAAA,QAA6B,CAAA;EACrC,KAAA,OAAY,MAAA,mBACV,GAAA,UACA,MAAA,wBACC,OAAA;IAAA,SAAmB,IAAA,EAAM,GAAA;EAAA;AAAA;AAAA,KAgDlB,iBAAA;EAAA,SACD,IAAA;EAAA,SACA,QAAA,GAAW,iBAAA;EAAA,SACX,QAAA,GAAW,iBAAiB;AAAA;AAAA,KAG3B,oBAAA;EAAA,SACD,MAAA;EAAA,SACA,OAAA;EAAA,SACA,QAAA;AAAA;AAAA,KAGC,eAAA;EAAA,SACD,KAAA;EAAA,SACA,WAAA;EAAA,SACA,MAAA,EAAQ,MAAM,SAAS,oBAAA;AAAA;AAAA,cAGrB,qBAAA;AAAA,cACA,gBAAA;AAAA,iBAEG,eAAA,CACd,EAAA;EAAM,UAAA;EAAkC,KAAA;AAAA,GACxC,gBAAA;EAAqB,UAAA;EAAkC,KAAA;AAAA;EACpD,UAAA;EAAqB,KAAA;AAAA;AAAA,KASd,sBAAA,GAAyB,MAAA,SAAe,MAAA,SAAe,MAAA;AAAA,KAEvD,8BAAA,GAAiC,MAAA,SAE3C,MAAA,SAAe,MAAA;AAAA,KAGL,QAAA,qBACU,MAAA;EAAiB,MAAA;AAAA,KAAqB,MAAA,8CAC7B,MAAA,oBAA0B,MAAA,2CAC7B,sBAAA,GAAyB,MAAA,0CAC1B,sB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-1,5 +1,14 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { a as
|
|
3
|
-
import { a as
|
|
4
|
-
import {
|
|
5
|
-
|
|
1
|
+
import { t as SqlNode } from "./sql-node-V214WXQD.mjs";
|
|
2
|
+
import { a as CheckConstraint, i as StorageColumnInput, n as StorageTableInput, o as CheckConstraintInput, r as StorageColumn, t as StorageTable } from "./storage-table-CE-Ns6wa.mjs";
|
|
3
|
+
import { a as ForeignKeyReferenceInput, i as ForeignKeyReference, n as ForeignKeyInput, r as ReferentialAction, t as ForeignKey } from "./foreign-key-DuCoGJCf.mjs";
|
|
4
|
+
import { a as PrimaryKey, i as IndexInput, n as UniqueConstraintInput, o as PrimaryKeyInput, r as Index, t as UniqueConstraint } from "./unique-constraint-C0De4sLU.mjs";
|
|
5
|
+
import { a as SqlNamespaceFactory, c as SqlStorageInput, d as isSqlAuthoringContributions, f as CODEC_INSTANCE_KIND, g as toStorageTypeInstance, h as isStorageTypeInstance, i as SqlNamespaceEntries, l as SqlStorageTypeEntry, m as StorageTypeInstanceInput, n as SqlNamespace, o as SqlNamespaceInput, p as StorageTypeInstance, r as SqlNamespaceBase, s as SqlStorage, t as SqlAuthoringContributions, u as isMaterializedSqlNamespace } from "./sql-storage-p-Wzt_MO.mjs";
|
|
6
|
+
import { n as StorageValueSetInput, r as isStorageValueSet, t as StorageValueSet } from "./storage-value-set-D-jww77l.mjs";
|
|
7
|
+
import { A as TypeMapsPhantomKey, C as SqlControlDriverInstance, D as StorageColumnInputTypesOf, E as SqlQueryOperationTypes, O as StorageColumnTypesOf, S as ResolveCodecTypes, T as SqlModelStorage, _ as QueryOperationReturn, a as ExtractCodecTypes, b as QueryOperationTypesBase, c as ExtractQueryOperationTypes, d as ExtractTypeMapsFromContract, f as FieldInputTypesOf, g as NamespacedStorageColumnTypeMap, h as NamespacedFieldTypeMap, i as DEFAULT_FK_INDEX, j as applyFkDefaults, k as TypeMaps, l as ExtractStorageColumnInputTypes, m as ForeignKeyOptions, n as ContractWithTypeMaps, o as ExtractFieldInputTypes, p as FieldOutputTypesOf, r as DEFAULT_FK_CONSTRAINT, s as ExtractFieldOutputTypes, t as CodecTypesOf, u as ExtractStorageColumnTypes, v as QueryOperationSelfSpec, w as SqlModelFieldStorage, x as QueryOperationTypesOf, y as QueryOperationTypeEntry } from "./types-3vOIrnvp.mjs";
|
|
8
|
+
|
|
9
|
+
//#region src/column-type-resolution.d.ts
|
|
10
|
+
type StorageColumnMapAt<SCT, NsId extends string, TableName extends string> = string extends keyof SCT ? never : NsId extends keyof SCT ? string extends keyof SCT[NsId] ? never : TableName extends keyof SCT[NsId] ? SCT[NsId][TableName] : never : never;
|
|
11
|
+
type StorageColumnTypeAcrossNamespaces<SCT, TableName extends string, ColumnName extends string> = { [Ns in keyof SCT]: TableName extends keyof SCT[Ns] ? ColumnName extends keyof SCT[Ns][TableName] ? SCT[Ns][TableName][ColumnName] : never : never }[keyof SCT];
|
|
12
|
+
//#endregion
|
|
13
|
+
export { CODEC_INSTANCE_KIND, CheckConstraint, type CheckConstraintInput, type CodecTypesOf, type ContractWithTypeMaps, DEFAULT_FK_CONSTRAINT, DEFAULT_FK_INDEX, type ExtractCodecTypes, type ExtractFieldInputTypes, type ExtractFieldOutputTypes, type ExtractQueryOperationTypes, type ExtractStorageColumnInputTypes, type ExtractStorageColumnTypes, type ExtractTypeMapsFromContract, type FieldInputTypesOf, type FieldOutputTypesOf, ForeignKey, type ForeignKeyInput, type ForeignKeyOptions, ForeignKeyReference, type ForeignKeyReferenceInput, Index, type IndexInput, type NamespacedFieldTypeMap, type NamespacedStorageColumnTypeMap, PrimaryKey, type PrimaryKeyInput, type QueryOperationReturn, type QueryOperationSelfSpec, type QueryOperationTypeEntry, type QueryOperationTypesBase, type QueryOperationTypesOf, type ReferentialAction, type ResolveCodecTypes, type SqlAuthoringContributions, type SqlControlDriverInstance, type SqlModelFieldStorage, type SqlModelStorage, type SqlNamespace, SqlNamespaceBase, type SqlNamespaceEntries, type SqlNamespaceFactory, type SqlNamespaceInput, SqlNode, type SqlQueryOperationTypes, SqlStorage, type SqlStorageInput, type SqlStorageTypeEntry, StorageColumn, type StorageColumnInput, type StorageColumnInputTypesOf, type StorageColumnMapAt, type StorageColumnTypeAcrossNamespaces, type StorageColumnTypesOf, StorageTable, type StorageTableInput, type StorageTypeInstance, type StorageTypeInstanceInput, StorageValueSet, type StorageValueSetInput, type TypeMaps, type TypeMapsPhantomKey, UniqueConstraint, type UniqueConstraintInput, applyFkDefaults, isMaterializedSqlNamespace, isSqlAuthoringContributions, isStorageTypeInstance, isStorageValueSet, toStorageTypeInstance };
|
|
14
|
+
//# sourceMappingURL=types.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.mts","names":[],"sources":["../src/column-type-resolution.ts"],"mappings":";;;;;;;;;KACY,kBAAA,4EAIa,GAAA,WAErB,IAAA,eAAmB,GAAA,wBACI,GAAA,CAAI,IAAA,YAEvB,SAAA,eAAwB,GAAA,CAAI,IAAA,IAC1B,GAAA,CAAI,IAAA,EAAM,SAAA;AAAA,KAIR,iCAAA,4EAKG,GAAA,GAAM,SAAA,eAAwB,GAAA,CAAI,EAAA,IAC3C,UAAA,eAAyB,GAAA,CAAI,EAAA,EAAI,SAAA,IAC/B,GAAA,CAAI,EAAA,EAAI,SAAA,EAAW,UAAA,0BAGnB,GAAA"}
|