qubu 0.6.0 → 0.6.2
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/README.md +112 -0
- package/dist/{complete-DP7pliuY.mjs → canonical-B5_ouh-c.mjs} +466 -241
- package/dist/codegen.d.mts +2 -2
- package/dist/codegen.mjs +180 -90
- package/dist/column-Cyc2CMnG.mjs +116 -0
- package/dist/column-DDRvD7SF.mjs +721 -0
- package/dist/{constraints-YGyNPQ_z.mjs → constraints-CAmi18Uk.mjs} +8 -3
- package/dist/core.d.mts +3 -3
- package/dist/core.mjs +4 -5
- package/dist/diagnostics-I9vVtXkc.mjs +40 -0
- package/dist/diff.d.mts +9 -9
- package/dist/diff.mjs +152 -102
- package/dist/{explain-CkIK13L_.mjs → explain-BIqEmZha.mjs} +1 -1
- package/dist/expressions-_6JF_J77.mjs +130 -0
- package/dist/index-CaxrMD1A.d.mts +1 -0
- package/dist/index.d.mts +2 -2
- package/dist/index.mjs +414 -77
- package/dist/introspection/mysql.d.mts +26 -0
- package/dist/introspection/mysql.mjs +1278 -0
- package/dist/introspection/postgres.d.mts +43 -0
- package/dist/introspection/postgres.mjs +1889 -0
- package/dist/introspection/sqlite.d.mts +15 -0
- package/dist/introspection/sqlite.mjs +1172 -0
- package/dist/introspection.d.mts +26 -87
- package/dist/introspection.mjs +3 -4351
- package/dist/mysql.d.mts +3 -3
- package/dist/mysql.mjs +8 -7
- package/dist/{errors-Dxv73YJu.mjs → omit-VEr9Ydux.mjs} +5 -1
- package/dist/{on-conflict-DZQ85f1t.mjs → on-conflict-B2rFyHGF.mjs} +78 -8
- package/dist/on-duplicate-key-update-Czsw1Yq-.mjs +95 -0
- package/dist/postgres-hFhd0I9n.mjs +68 -0
- package/dist/postgres.d.mts +3 -3
- package/dist/postgres.mjs +3 -52
- package/dist/registry-BXE_4M9P.mjs +127 -0
- package/dist/{relational-CxnLCqZQ.mjs → relational-CoPBETjI.mjs} +3 -3
- package/dist/schema.d.mts +2 -2
- package/dist/schema.mjs +8 -7
- package/dist/{serialize-BN07IK0v.mjs → serialize-CyobNEx-.mjs} +174 -30
- package/dist/serialize-Du2UPZMt.d.mts +92 -0
- package/dist/snapshot/mysql.d.mts +5 -5
- package/dist/snapshot/mysql.mjs +32 -32
- package/dist/snapshot/postgres.d.mts +5 -5
- package/dist/snapshot/postgres.mjs +25 -25
- package/dist/snapshot/sqlite.d.mts +5 -5
- package/dist/snapshot/sqlite.mjs +30 -30
- package/dist/snapshot-mIb-Zzb5.mjs +1489 -0
- package/dist/snapshot.d.mts +4 -5
- package/dist/snapshot.mjs +3 -4
- package/dist/{source-SqrKWjFJ.mjs → source-DYSUqzvb.mjs} +2 -2
- package/dist/sqlite.d.mts +2 -2
- package/dist/sqlite.mjs +10 -10
- package/dist/{table-BwflqeAj.mjs → table-B8zEq0az.mjs} +4 -4
- package/dist/{types-BIJsj2fJ.mjs → types-CYHpSPwj.mjs} +10 -7
- package/dist/{types-CTCqtFlS.d.mts → types-CiMvKi5V.d.mts} +14 -4
- package/dist/{types-C0VkiwpR.d.mts → types-Dqr4o2I1.d.mts} +640 -189
- package/dist/value-CpaUFtjw.mjs +45 -0
- package/dist/vite/ambient.d.ts +2 -0
- package/dist/vite.d.mts +1 -1
- package/dist/vite.mjs +2 -0
- package/docs/dialects-and-execution.md +61 -11
- package/docs/getting-started.md +1 -1
- package/docs/guides/compose-queries.md +22 -0
- package/docs/guides/drizzle.md +11 -11
- package/docs/guides/extensions/typed-expressions.md +5 -3
- package/docs/guides/json.md +95 -2
- package/docs/guides/mutations.md +125 -0
- package/docs/guides/valtio-sync.md +113 -0
- package/docs/index.md +1 -1
- package/docs/migrations/adapters.md +58 -21
- package/docs/migrations/index.md +50 -12
- package/docs/migrations/operations.md +20 -6
- package/docs/migrations/recovery.md +7 -1
- package/docs/query-model/fragments.md +21 -1
- package/docs/reference/introspection-support.md +16 -18
- package/docs/reference/supported-surface.md +23 -11
- package/docs/schema/catalog-model.md +20 -7
- package/docs/schema/code-generation.md +4 -3
- package/docs/schema/diff.md +2 -2
- package/docs/schema/introspection.md +24 -16
- package/docs/schema/snapshots.md +18 -8
- package/docs/schema/storage-and-schema-sql.md +7 -2
- package/docs/sql-semantic-types.md +8 -0
- package/package.json +14 -1
- package/dist/canonical-DMvR9yBe.mjs +0 -972
- package/dist/column-Da37jYSD.mjs +0 -309
- package/dist/column-r1Y4ivwt.mjs +0 -327
- package/dist/complete-types-CY0KbzNw.d.mts +0 -371
- package/dist/index-B2rZf3-2.d.mts +0 -32
- package/dist/json-Db7XRD91.mjs +0 -169
- package/dist/omit-OxV58AwX.mjs +0 -5
- package/dist/registry-BRcUuazJ.mjs +0 -256
- package/dist/serialize-CEIIlWhC.d.mts +0 -66
- package/dist/snapshot-Xam8-q0j.mjs +0 -392
- package/dist/standard-DfcZEVOj.mjs +0 -12
- package/dist/value-D14I_XgL.mjs +0 -29
|
@@ -1,392 +0,0 @@
|
|
|
1
|
-
import { s as assertSchemaSnapshot } from "./canonical-DMvR9yBe.mjs";
|
|
2
|
-
import { sqliteStorageAffinity } from "./snapshot/sqlite.mjs";
|
|
3
|
-
//#region src/introspection/diagnostics.ts
|
|
4
|
-
/**
|
|
5
|
-
* Create one immutable diagnostic without interpreting catalog text or copying driver error details
|
|
6
|
-
* into the structured fields.
|
|
7
|
-
*/
|
|
8
|
-
function createIntrospectionDiagnostic(diagnostic) {
|
|
9
|
-
return freezeDiagnostic(diagnostic);
|
|
10
|
-
}
|
|
11
|
-
/** Return whether a diagnostic list prevents strict introspection output. */
|
|
12
|
-
function hasIntrospectionErrors(diagnostics) {
|
|
13
|
-
return diagnostics.some((diagnostic) => diagnostic.severity === "error");
|
|
14
|
-
}
|
|
15
|
-
/** Error raised by a throwing introspection operation after collecting findings. */
|
|
16
|
-
var IntrospectionError = class extends Error {
|
|
17
|
-
name = "IntrospectionError";
|
|
18
|
-
diagnostics;
|
|
19
|
-
issues;
|
|
20
|
-
constructor(diagnostics) {
|
|
21
|
-
const frozenDiagnostics = Object.freeze(diagnostics.map((diagnostic) => freezeDiagnostic(diagnostic)));
|
|
22
|
-
super(frozenDiagnostics.map((diagnostic) => diagnostic.message).join("\n"));
|
|
23
|
-
this.diagnostics = frozenDiagnostics;
|
|
24
|
-
this.issues = frozenDiagnostics;
|
|
25
|
-
}
|
|
26
|
-
};
|
|
27
|
-
function freezeDiagnostic(diagnostic) {
|
|
28
|
-
return Object.freeze({
|
|
29
|
-
...diagnostic,
|
|
30
|
-
path: Object.freeze([...diagnostic.path]),
|
|
31
|
-
physicalReference: diagnostic.physicalReference ? freezeReference(diagnostic.physicalReference) : void 0,
|
|
32
|
-
relatedReferences: diagnostic.relatedReferences ? Object.freeze(diagnostic.relatedReferences.map((reference) => freezeReference(reference))) : void 0
|
|
33
|
-
});
|
|
34
|
-
}
|
|
35
|
-
function freezeReference(reference) {
|
|
36
|
-
return Object.freeze({
|
|
37
|
-
...reference,
|
|
38
|
-
catalog: reference.catalog ? Object.freeze({ ...reference.catalog }) : void 0
|
|
39
|
-
});
|
|
40
|
-
}
|
|
41
|
-
//#endregion
|
|
42
|
-
//#region src/introspection/identity.ts
|
|
43
|
-
/** The naming policy used by the first introspection snapshot mapper. */
|
|
44
|
-
const introspectedPhysicalIdentityPolicy = Object.freeze({
|
|
45
|
-
name: "introspected-physical",
|
|
46
|
-
version: 1,
|
|
47
|
-
fallback: "escaped",
|
|
48
|
-
precedence: Object.freeze([
|
|
49
|
-
"explicit-hint",
|
|
50
|
-
"previous-snapshot",
|
|
51
|
-
"physical-name",
|
|
52
|
-
"deterministic-fallback"
|
|
53
|
-
])
|
|
54
|
-
});
|
|
55
|
-
//#endregion
|
|
56
|
-
//#region src/introspection/snapshot.ts
|
|
57
|
-
/** Construct and validate a canonical Snapshot v1 from a normalized catalog. */
|
|
58
|
-
function mapCatalogToSnapshot(catalog, options) {
|
|
59
|
-
const mode = options.mode ?? "strict";
|
|
60
|
-
const diagnostics = [...catalog.diagnostics];
|
|
61
|
-
const tables = catalog.tables.map((table) => mapTable(catalog, table, options, mode, diagnostics)).sort(compareById);
|
|
62
|
-
const snapshot = {
|
|
63
|
-
format: "qubu-schema",
|
|
64
|
-
version: 1,
|
|
65
|
-
dialect: {
|
|
66
|
-
name: catalog.dialect,
|
|
67
|
-
version: 1
|
|
68
|
-
},
|
|
69
|
-
namingPolicy: {
|
|
70
|
-
name: introspectedPhysicalIdentityPolicy.name,
|
|
71
|
-
version: introspectedPhysicalIdentityPolicy.version
|
|
72
|
-
},
|
|
73
|
-
namespace: catalog.namespace.name,
|
|
74
|
-
tables
|
|
75
|
-
};
|
|
76
|
-
if (mode === "strict" && diagnostics.some(isError)) return failure(catalog, diagnostics);
|
|
77
|
-
try {
|
|
78
|
-
const value = assertSchemaSnapshot(snapshot);
|
|
79
|
-
const lossy = mode === "lossy" && diagnostics.some((diagnostic) => diagnostic.severity === "warning");
|
|
80
|
-
const result = {
|
|
81
|
-
ok: true,
|
|
82
|
-
catalog,
|
|
83
|
-
snapshot: value,
|
|
84
|
-
diagnostics: Object.freeze(diagnostics),
|
|
85
|
-
lossy
|
|
86
|
-
};
|
|
87
|
-
return Object.freeze(result);
|
|
88
|
-
} catch (error) {
|
|
89
|
-
const severity = mode === "strict" ? "error" : "warning";
|
|
90
|
-
diagnostics.push(createIntrospectionDiagnostic({
|
|
91
|
-
severity,
|
|
92
|
-
code: "invalid-catalog-row",
|
|
93
|
-
message: error instanceof Error ? `Catalog facts could not form Snapshot v1: ${error.message}` : "Catalog facts could not form Snapshot v1",
|
|
94
|
-
path: [],
|
|
95
|
-
remediation: "Inspect the catalog diagnostics and unsupported features."
|
|
96
|
-
}));
|
|
97
|
-
return failure(catalog, diagnostics);
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
function mapTable(catalog, table, options, mode, diagnostics) {
|
|
101
|
-
const tableId = resolveId("table", table.id, table.physicalName, void 0, options);
|
|
102
|
-
const columnIds = new Map(table.columns.map((column) => [column.physicalName, resolveId("column", column.id, column.physicalName, table.physicalName, options)]));
|
|
103
|
-
const columns = [...table.columns].sort((left, right) => left.ordinalPosition - right.ordinalPosition).map((column) => mapColumn(catalog.dialect, table, column, options, diagnostics)).sort(compareById);
|
|
104
|
-
const constraints = [...table.constraints].map((constraint) => mapConstraint(catalog, table, constraint, columnIds, options, mode, diagnostics)).filter((value) => value !== void 0).sort(compareById);
|
|
105
|
-
const indexes = [...table.indexes].map((index) => mapIndex(table, index, columnIds, options, mode, diagnostics)).filter((value) => value !== void 0).sort(compareById);
|
|
106
|
-
return {
|
|
107
|
-
id: tableId,
|
|
108
|
-
physicalName: table.physicalName,
|
|
109
|
-
columns,
|
|
110
|
-
constraints,
|
|
111
|
-
indexes
|
|
112
|
-
};
|
|
113
|
-
}
|
|
114
|
-
function mapColumn(dialect, table, column, options, diagnostics) {
|
|
115
|
-
const defaultValue = column.default ? mapDefault(column.default, column, diagnostics) : void 0;
|
|
116
|
-
const generated = column.generated ? mapGenerated(column.generated, column, options.mode ?? "strict", diagnostics) : void 0;
|
|
117
|
-
const identity = column.identity ? mapIdentity(column.identity, column, diagnostics) : void 0;
|
|
118
|
-
const storage = {
|
|
119
|
-
kind: "native",
|
|
120
|
-
dialect,
|
|
121
|
-
type: column.storage.nativeType,
|
|
122
|
-
...dialect === "sqlite" ? { affinity: sqliteStorageAffinity(column.storage.nativeType) } : {}
|
|
123
|
-
};
|
|
124
|
-
return {
|
|
125
|
-
id: resolveId("column", column.id, column.physicalName, table.physicalName, options),
|
|
126
|
-
physicalName: column.physicalName,
|
|
127
|
-
nullable: column.nullable,
|
|
128
|
-
hasDefault: defaultValue !== void 0,
|
|
129
|
-
generated: generated !== void 0 || identity !== void 0,
|
|
130
|
-
storage,
|
|
131
|
-
default: defaultValue,
|
|
132
|
-
generatedColumn: generated,
|
|
133
|
-
identity,
|
|
134
|
-
onUpdate: column.onUpdate ? mapExpression(column.onUpdate) : void 0
|
|
135
|
-
};
|
|
136
|
-
}
|
|
137
|
-
function mapConstraint(catalog, table, constraint, columnIds, options, mode, diagnostics) {
|
|
138
|
-
const physicalName = constraint.physicalName ?? constraint.id;
|
|
139
|
-
const id = resolveId("constraint", constraint.id, physicalName, table.physicalName, options);
|
|
140
|
-
if (constraint.kind === "check") return {
|
|
141
|
-
id,
|
|
142
|
-
kind: "check",
|
|
143
|
-
physicalName,
|
|
144
|
-
expression: mapExpression(constraint.expression),
|
|
145
|
-
deferrable: constraint.deferrable,
|
|
146
|
-
initially: constraint.initially,
|
|
147
|
-
dialect: mapExtension(constraint.dialect)
|
|
148
|
-
};
|
|
149
|
-
const columns = constraint.columns.map((column) => {
|
|
150
|
-
const value = columnIds.get(column);
|
|
151
|
-
if (value) return value;
|
|
152
|
-
addIssue(mode, diagnostics, "unresolved-reference", `Constraint column ${column} was not found`, constraint);
|
|
153
|
-
return column;
|
|
154
|
-
});
|
|
155
|
-
if (constraint.kind === "primary-key") return {
|
|
156
|
-
id,
|
|
157
|
-
kind: "primary-key",
|
|
158
|
-
physicalName,
|
|
159
|
-
columns,
|
|
160
|
-
deferrable: constraint.deferrable,
|
|
161
|
-
initially: constraint.initially,
|
|
162
|
-
dialect: mapExtension(constraint.dialect)
|
|
163
|
-
};
|
|
164
|
-
if (constraint.kind === "unique") {
|
|
165
|
-
if (constraint.columns.some((column) => table.columns.find((candidate) => candidate.physicalName === column)?.nullable) || constraint.nulls === "not-distinct") return {
|
|
166
|
-
id,
|
|
167
|
-
kind: "unique-constraint",
|
|
168
|
-
physicalName,
|
|
169
|
-
columns,
|
|
170
|
-
nulls: constraint.nulls,
|
|
171
|
-
deferrable: constraint.deferrable,
|
|
172
|
-
initially: constraint.initially,
|
|
173
|
-
dialect: mapExtension(constraint.dialect)
|
|
174
|
-
};
|
|
175
|
-
return {
|
|
176
|
-
id,
|
|
177
|
-
kind: "unique",
|
|
178
|
-
physicalName,
|
|
179
|
-
columns,
|
|
180
|
-
deferrable: constraint.deferrable,
|
|
181
|
-
initially: constraint.initially,
|
|
182
|
-
dialect: mapExtension(constraint.dialect)
|
|
183
|
-
};
|
|
184
|
-
}
|
|
185
|
-
const targetTable = catalog.tables.find((candidate) => candidate.physicalName === constraint.target.table);
|
|
186
|
-
if (!targetTable) {
|
|
187
|
-
addIssue(mode, diagnostics, "unresolved-reference", `Foreign key target table ${constraint.target.table} was not found`, constraint);
|
|
188
|
-
return;
|
|
189
|
-
}
|
|
190
|
-
return {
|
|
191
|
-
id,
|
|
192
|
-
kind: "foreign-key",
|
|
193
|
-
physicalName,
|
|
194
|
-
columns,
|
|
195
|
-
target: {
|
|
196
|
-
table: resolveId("table", targetTable.id, targetTable.physicalName, void 0, options),
|
|
197
|
-
columns: constraint.target.columns.map((column) => {
|
|
198
|
-
const target = targetTable.columns.find((candidate) => candidate.physicalName === column);
|
|
199
|
-
if (target) return resolveId("column", target.id, target.physicalName, targetTable.physicalName, options);
|
|
200
|
-
addIssue(mode, diagnostics, "unresolved-reference", `Foreign key target column ${column} was not found`, constraint);
|
|
201
|
-
return column;
|
|
202
|
-
})
|
|
203
|
-
},
|
|
204
|
-
onUpdate: constraint.onUpdate,
|
|
205
|
-
onDelete: constraint.onDelete,
|
|
206
|
-
match: constraint.match,
|
|
207
|
-
deferrable: constraint.deferrable,
|
|
208
|
-
initially: constraint.initially,
|
|
209
|
-
dialect: mapExtension(constraint.dialect)
|
|
210
|
-
};
|
|
211
|
-
}
|
|
212
|
-
function mapIndex(table, index, columnIds, options, mode, diagnostics) {
|
|
213
|
-
const physicalName = index.physicalName ?? index.id;
|
|
214
|
-
const id = resolveId("index", index.id, physicalName, table.physicalName, options);
|
|
215
|
-
const terms = [...index.terms].sort((left, right) => left.position - right.position).map((term) => mapIndexTerm(term, columnIds, index, mode, diagnostics)).filter((value) => value !== void 0);
|
|
216
|
-
const includedColumns = index.includedColumns?.map((column) => {
|
|
217
|
-
const value = columnIds.get(column);
|
|
218
|
-
if (value) return value;
|
|
219
|
-
addIssue(mode, diagnostics, "unresolved-reference", `Index column ${column} was not found`, index);
|
|
220
|
-
return column;
|
|
221
|
-
});
|
|
222
|
-
const candidateKey = index.unique && index.predicate === void 0 && index.terms.every((term) => term.kind === "column" && table.columns.find((column) => column.physicalName === term.column)?.nullable === false);
|
|
223
|
-
return {
|
|
224
|
-
id,
|
|
225
|
-
kind: "index",
|
|
226
|
-
physicalName,
|
|
227
|
-
terms,
|
|
228
|
-
unique: index.unique,
|
|
229
|
-
candidateKey,
|
|
230
|
-
predicate: index.predicate ? mapExpression(index.predicate) : void 0,
|
|
231
|
-
includedColumns,
|
|
232
|
-
dialect: mapExtension(index.dialect)
|
|
233
|
-
};
|
|
234
|
-
}
|
|
235
|
-
function mapIndexTerm(term, columnIds, index, mode, diagnostics) {
|
|
236
|
-
let expression;
|
|
237
|
-
if (term.kind === "column") {
|
|
238
|
-
const column = columnIds.get(term.column);
|
|
239
|
-
if (!column) {
|
|
240
|
-
addIssue(mode, diagnostics, "unresolved-reference", `Index column ${term.column} was not found`, index);
|
|
241
|
-
return;
|
|
242
|
-
}
|
|
243
|
-
expression = {
|
|
244
|
-
kind: "column",
|
|
245
|
-
column
|
|
246
|
-
};
|
|
247
|
-
if (term.prefixLength !== void 0 || term.operatorClass !== void 0) addIssue(mode, diagnostics, "unsupported-feature", "Index term metadata is not represented by Snapshot v1", index);
|
|
248
|
-
} else {
|
|
249
|
-
expression = {
|
|
250
|
-
kind: "expression",
|
|
251
|
-
expression: mapExpression(term.expression)
|
|
252
|
-
};
|
|
253
|
-
if (term.operatorClass !== void 0) addIssue(mode, diagnostics, "unsupported-feature", "Index operator classes are not represented by Snapshot v1", index);
|
|
254
|
-
}
|
|
255
|
-
if (term.direction === void 0 && term.nulls === void 0) return expression;
|
|
256
|
-
return {
|
|
257
|
-
kind: "order",
|
|
258
|
-
expression,
|
|
259
|
-
direction: term.direction,
|
|
260
|
-
nulls: term.nulls
|
|
261
|
-
};
|
|
262
|
-
}
|
|
263
|
-
function mapDefault(value, owner, diagnostics) {
|
|
264
|
-
if (value.kind === "literal") return {
|
|
265
|
-
kind: "literal",
|
|
266
|
-
value: mapLiteral(value)
|
|
267
|
-
};
|
|
268
|
-
if (value.expression.text.trim().length === 0) diagnostics.push(createIntrospectionDiagnostic({
|
|
269
|
-
severity: "error",
|
|
270
|
-
code: "invalid-catalog-row",
|
|
271
|
-
message: "A default expression was empty",
|
|
272
|
-
path: [owner.id, "default"],
|
|
273
|
-
remediation: "Return the database expression or omit the default fact."
|
|
274
|
-
}));
|
|
275
|
-
return {
|
|
276
|
-
kind: "expression",
|
|
277
|
-
expression: mapExpression(value.expression)
|
|
278
|
-
};
|
|
279
|
-
}
|
|
280
|
-
function mapGenerated(value, owner, mode, diagnostics) {
|
|
281
|
-
if (value.mode === "unknown") {
|
|
282
|
-
addIssue(mode, diagnostics, "unsupported-feature", "Generated-column storage mode was not recovered", owner);
|
|
283
|
-
return { kind: "external" };
|
|
284
|
-
}
|
|
285
|
-
return {
|
|
286
|
-
kind: "expression",
|
|
287
|
-
expression: mapExpression(value.expression),
|
|
288
|
-
mode: value.mode
|
|
289
|
-
};
|
|
290
|
-
}
|
|
291
|
-
function mapIdentity(value, owner, diagnostics) {
|
|
292
|
-
if (Object.keys(value.options).length > 0) diagnostics.push(createIntrospectionDiagnostic({
|
|
293
|
-
severity: "warning",
|
|
294
|
-
code: "lossy-mapping",
|
|
295
|
-
message: "Identity sequence options are not represented by Snapshot v1",
|
|
296
|
-
path: [owner.id, "identity"],
|
|
297
|
-
remediation: "Use the normalized catalog for options or add a typed dialect extension."
|
|
298
|
-
}));
|
|
299
|
-
return {
|
|
300
|
-
kind: "identity",
|
|
301
|
-
generation: value.generation,
|
|
302
|
-
dialect: mapExtension(value.dialect)
|
|
303
|
-
};
|
|
304
|
-
}
|
|
305
|
-
function mapExpression(value) {
|
|
306
|
-
return {
|
|
307
|
-
kind: "expression",
|
|
308
|
-
expressionKind: "unsafe",
|
|
309
|
-
sql: value.text.replace(/\r\n?/g, "\n").trim(),
|
|
310
|
-
dialect: value.dialect
|
|
311
|
-
};
|
|
312
|
-
}
|
|
313
|
-
function mapLiteral(value) {
|
|
314
|
-
if (value.value === null) return { kind: "null" };
|
|
315
|
-
if (typeof value.value === "boolean") return {
|
|
316
|
-
kind: "boolean",
|
|
317
|
-
value: value.value
|
|
318
|
-
};
|
|
319
|
-
if (typeof value.value === "bigint") return {
|
|
320
|
-
kind: "bigint",
|
|
321
|
-
value: value.value.toString()
|
|
322
|
-
};
|
|
323
|
-
if (typeof value.value === "number") return {
|
|
324
|
-
kind: "number",
|
|
325
|
-
value: String(value.value)
|
|
326
|
-
};
|
|
327
|
-
return {
|
|
328
|
-
kind: "string",
|
|
329
|
-
value: value.value
|
|
330
|
-
};
|
|
331
|
-
}
|
|
332
|
-
function mapExtension(value) {
|
|
333
|
-
if (!value) return;
|
|
334
|
-
return {
|
|
335
|
-
dialect: value.dialect,
|
|
336
|
-
version: value.version,
|
|
337
|
-
data: toSnapshotData(value.data)
|
|
338
|
-
};
|
|
339
|
-
}
|
|
340
|
-
function toSnapshotData(value) {
|
|
341
|
-
if (typeof value === "bigint") return { $bigint: value.toString() };
|
|
342
|
-
if (Array.isArray(value)) return value.map(toSnapshotData);
|
|
343
|
-
if (value !== null && typeof value === "object") return Object.fromEntries(Object.entries(value).map(([key, child]) => [key, toSnapshotData(child)]));
|
|
344
|
-
return value;
|
|
345
|
-
}
|
|
346
|
-
function resolveId(kind, currentId, physicalName, tablePhysicalName, options) {
|
|
347
|
-
const hint = options.identityHints?.find((candidate) => candidate.kind === kind && candidate.physicalName === physicalName && candidate.tablePhysicalName === tablePhysicalName);
|
|
348
|
-
if (hint) return hint.logicalId;
|
|
349
|
-
const previous = options.previousSnapshot;
|
|
350
|
-
if (previous) {
|
|
351
|
-
const table = tablePhysicalName ? previous.tables.find((candidate) => candidate.physicalName === tablePhysicalName) : previous.tables.find((candidate) => candidate.physicalName === physicalName);
|
|
352
|
-
if (kind === "table" && table) return table.id;
|
|
353
|
-
if (table && kind === "column") {
|
|
354
|
-
const column = table.columns.find((candidate) => candidate.physicalName === physicalName);
|
|
355
|
-
if (column) return column.id;
|
|
356
|
-
}
|
|
357
|
-
if (table && kind === "constraint") {
|
|
358
|
-
const constraint = table.constraints.find((candidate) => candidate.physicalName === physicalName);
|
|
359
|
-
if (constraint) return constraint.id;
|
|
360
|
-
}
|
|
361
|
-
if (table && kind === "index") {
|
|
362
|
-
const index = table.indexes.find((candidate) => candidate.physicalName === physicalName);
|
|
363
|
-
if (index) return index.id;
|
|
364
|
-
}
|
|
365
|
-
}
|
|
366
|
-
return currentId || physicalName;
|
|
367
|
-
}
|
|
368
|
-
function addIssue(mode, diagnostics, code, message, owner) {
|
|
369
|
-
diagnostics.push(createIntrospectionDiagnostic({
|
|
370
|
-
severity: mode === "strict" ? "error" : "warning",
|
|
371
|
-
code,
|
|
372
|
-
message,
|
|
373
|
-
path: owner.id ? [owner.id] : [],
|
|
374
|
-
remediation: "Use lossy mode or add a typed dialect mapping for this feature."
|
|
375
|
-
}));
|
|
376
|
-
}
|
|
377
|
-
function failure(catalog, diagnostics) {
|
|
378
|
-
return Object.freeze({
|
|
379
|
-
ok: false,
|
|
380
|
-
catalog,
|
|
381
|
-
diagnostics: Object.freeze([...diagnostics]),
|
|
382
|
-
lossy: false
|
|
383
|
-
});
|
|
384
|
-
}
|
|
385
|
-
function compareById(left, right) {
|
|
386
|
-
return left.id.localeCompare(right.id);
|
|
387
|
-
}
|
|
388
|
-
function isError(value) {
|
|
389
|
-
return value.severity === "error";
|
|
390
|
-
}
|
|
391
|
-
//#endregion
|
|
392
|
-
export { hasIntrospectionErrors as a, createIntrospectionDiagnostic as i, introspectedPhysicalIdentityPolicy as n, IntrospectionError as r, mapCatalogToSnapshot as t };
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { i as standardJson, o as createDialect } from "./json-Db7XRD91.mjs";
|
|
2
|
-
//#region src/dialects/standard.ts
|
|
3
|
-
/** SQL:2008-style rendering defaults used by the core builder. */
|
|
4
|
-
function standardDialect() {
|
|
5
|
-
return createDialect({
|
|
6
|
-
name: "standard-sql",
|
|
7
|
-
placeholder: () => "?",
|
|
8
|
-
json: standardJson
|
|
9
|
-
});
|
|
10
|
-
}
|
|
11
|
-
//#endregion
|
|
12
|
-
export { standardDialect as t };
|
package/dist/value-D14I_XgL.mjs
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { C as fragment, y as makeSchemaExpression } from "./column-r1Y4ivwt.mjs";
|
|
2
|
-
//#region src/core/primitives/parameter.ts
|
|
3
|
-
function parameter(_value) {
|
|
4
|
-
return fragment((context) => context.parameter(_value));
|
|
5
|
-
}
|
|
6
|
-
//#endregion
|
|
7
|
-
//#region src/expressions/value.ts
|
|
8
|
-
function value(input) {
|
|
9
|
-
const expression = makeSchemaExpression("value", (context) => context.render(parameter(input)));
|
|
10
|
-
return Object.freeze({
|
|
11
|
-
...expression,
|
|
12
|
-
value: input
|
|
13
|
-
});
|
|
14
|
-
}
|
|
15
|
-
/** Bind a value while declaring its SQL semantic domain. */
|
|
16
|
-
function typedValue(input) {
|
|
17
|
-
return value(input);
|
|
18
|
-
}
|
|
19
|
-
function isExpressionValue(valueToCheck) {
|
|
20
|
-
return typeof valueToCheck === "object" && valueToCheck !== null && "expressionKind" in valueToCheck && "render" in valueToCheck && typeof valueToCheck.render === "function";
|
|
21
|
-
}
|
|
22
|
-
function isValueExpression(valueToCheck) {
|
|
23
|
-
return isExpressionValue(valueToCheck) && valueToCheck.expressionKind === "value" && "value" in valueToCheck;
|
|
24
|
-
}
|
|
25
|
-
function asValue(input) {
|
|
26
|
-
return isExpressionValue(input) ? input : value(input);
|
|
27
|
-
}
|
|
28
|
-
//#endregion
|
|
29
|
-
export { parameter as a, value as i, isValueExpression as n, typedValue as r, asValue as t };
|