qubu 0.5.1 → 0.6.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/README.md +112 -0
- package/dist/codegen.d.mts +1 -1
- package/dist/codegen.mjs +1 -1
- package/dist/column-BzN8KFJa.mjs +364 -0
- package/dist/column-CFvSbil0.mjs +309 -0
- package/dist/{complete-types-CY0KbzNw.d.mts → complete-types-CNMWBWap.d.mts} +1 -1
- package/dist/constraints-DM_tarXc.mjs +208 -0
- package/dist/core.d.mts +1 -1
- package/dist/core.mjs +2 -3
- package/dist/diagnostics-I9vVtXkc.mjs +40 -0
- package/dist/diff.d.mts +2 -2
- package/dist/expressions-BCjc08zw.mjs +129 -0
- package/dist/index-CGui70hi.d.mts +32 -0
- package/dist/index.d.mts +2 -2
- package/dist/index.mjs +58 -13
- package/dist/introspection/mysql.d.mts +26 -0
- package/dist/introspection/mysql.mjs +1145 -0
- package/dist/introspection/postgres.d.mts +40 -0
- package/dist/introspection/postgres.mjs +1554 -0
- package/dist/introspection/sqlite.d.mts +15 -0
- package/dist/introspection/sqlite.mjs +986 -0
- package/dist/introspection.d.mts +3 -78
- package/dist/introspection.mjs +5 -3683
- package/dist/mysql.d.mts +1 -1
- package/dist/mysql.mjs +2 -2
- package/dist/{on-conflict-jPsl9l0K.mjs → on-conflict-CnaY5qso.mjs} +76 -3
- package/dist/postgres-Dey7QXPL.mjs +69 -0
- package/dist/postgres.d.mts +3 -3
- package/dist/postgres.mjs +3 -52
- package/dist/registry-oWDiqD7i.mjs +127 -0
- package/dist/{relational-x3BDVX9e.mjs → relational-DSAJ-l58.mjs} +1 -2
- package/dist/schema.d.mts +1 -1
- package/dist/schema.mjs +7 -4
- package/dist/{sqlite-CsIUtZ2Q.mjs → serialize-CE-gw5_s.mjs} +4 -318
- package/dist/serialize-OvXCLzjm.d.mts +66 -0
- package/dist/snapshot/mysql.d.mts +17 -0
- package/dist/snapshot/mysql.mjs +356 -0
- package/dist/snapshot/postgres.d.mts +17 -0
- package/dist/snapshot/postgres.mjs +237 -0
- package/dist/snapshot/sqlite.d.mts +25 -0
- package/dist/snapshot/sqlite.mjs +321 -0
- package/dist/{snapshot-BSraiLtH.mjs → snapshot-DgsOhf_8.mjs} +4 -42
- package/dist/snapshot.d.mts +5 -4
- package/dist/snapshot.mjs +2 -583
- package/dist/{source-C4Vmu5bb.mjs → source-BDuUXmAk.mjs} +2 -1
- package/dist/sqlite.d.mts +1 -1
- package/dist/sqlite.mjs +6 -6
- package/dist/{table-DLQ7YWth.mjs → table-C1QGNe4P.mjs} +3 -2
- package/dist/{types-CTCqtFlS.d.mts → types-BEn0N_al.d.mts} +1 -1
- package/dist/{types-CTENnDh9.mjs → types-BLNRatG_.mjs} +2 -3
- package/dist/{types-C0VkiwpR.d.mts → types-DUe6eeI0.d.mts} +57 -28
- package/docs/guides/compose-queries.md +22 -0
- package/docs/guides/drizzle.md +11 -11
- package/docs/guides/mutations.md +89 -0
- package/docs/guides/valtio-sync.md +113 -0
- package/docs/migrations/index.md +57 -19
- package/docs/migrations/operations.md +20 -6
- package/docs/reference/mysql-snapshot.md +5 -5
- package/docs/reference/postgres-snapshot.md +7 -7
- package/docs/reference/sqlite-snapshot.md +5 -5
- package/docs/reference/supported-surface.md +20 -6
- package/docs/schema/code-generation.md +5 -4
- package/docs/schema/ddl-emission.md +1 -1
- package/docs/schema/introspection.md +3 -2
- package/docs/schema/snapshots.md +12 -0
- package/docs/sql-semantic-types.md +8 -0
- package/package.json +25 -1
- package/dist/column-DmazTL67.mjs +0 -633
- package/dist/index-C-480HmV.d.mts +0 -146
- package/dist/registry-BGqa05et.mjs +0 -461
- package/dist/standard-DfcZEVOj.mjs +0 -12
- package/dist/value-BEEj_Ayd.mjs +0 -29
|
@@ -0,0 +1,321 @@
|
|
|
1
|
+
import { g as isValidSchemaObjectName, r as isColumnReference } from "../column-BzN8KFJa.mjs";
|
|
2
|
+
import { d as validateIndexDialect, l as validateConstraintDialect } from "../constraints-DM_tarXc.mjs";
|
|
3
|
+
import { a as renderSchemaExpression, r as isUnsafeSchemaSql } from "../expressions-BCjc08zw.mjs";
|
|
4
|
+
import { t as createSchemaDialect } from "../dialect-wUKrnPMB.mjs";
|
|
5
|
+
import { a as toSnapshotJsonValue } from "../canonical-DMvR9yBe.mjs";
|
|
6
|
+
import { sqliteDialect } from "../sqlite.mjs";
|
|
7
|
+
import { n as createSchemaSnapshot$1, s as tryCreateSchemaSnapshot$1 } from "../serialize-CE-gw5_s.mjs";
|
|
8
|
+
//#region src/snapshot/sqlite.ts
|
|
9
|
+
/** SQLite's v1 snapshot extension identity. */
|
|
10
|
+
const sqliteSnapshotDialect = Object.freeze({
|
|
11
|
+
name: "sqlite",
|
|
12
|
+
version: 1
|
|
13
|
+
});
|
|
14
|
+
var SqliteSnapshotDialectError = class extends TypeError {
|
|
15
|
+
code = "dialect-mismatch";
|
|
16
|
+
};
|
|
17
|
+
const sqliteStorageTypes = Object.freeze({
|
|
18
|
+
integer: "INTEGER",
|
|
19
|
+
numeric: "NUMERIC",
|
|
20
|
+
text: "TEXT",
|
|
21
|
+
boolean: "INTEGER",
|
|
22
|
+
date: "TEXT",
|
|
23
|
+
timestamp: "TEXT",
|
|
24
|
+
uuid: "TEXT",
|
|
25
|
+
json: "TEXT",
|
|
26
|
+
bigint: "INTEGER",
|
|
27
|
+
binary: "BLOB"
|
|
28
|
+
});
|
|
29
|
+
/**
|
|
30
|
+
* Resolve SQLite's declared-type affinity without changing the declaration. SQLite applies these
|
|
31
|
+
* ordered substring rules at table creation time; the returned affinity is useful metadata, not a
|
|
32
|
+
* replacement for the exact type.
|
|
33
|
+
*/
|
|
34
|
+
function storageAffinity(declaration) {
|
|
35
|
+
const upper = declaration.toUpperCase();
|
|
36
|
+
if (upper.includes("INT")) return "integer";
|
|
37
|
+
if (upper.includes("CHAR") || upper.includes("CLOB") || upper.includes("TEXT")) return "text";
|
|
38
|
+
if (upper.includes("BLOB") || upper.trim().length === 0) return "blob";
|
|
39
|
+
if (upper.includes("REAL") || upper.includes("FLOA") || upper.includes("DOUB")) return "real";
|
|
40
|
+
return "numeric";
|
|
41
|
+
}
|
|
42
|
+
/** SQLite's query dialect plus its schema metadata behavior. */
|
|
43
|
+
const sqliteSchemaDialect = createSchemaDialect(sqliteDialect(), {
|
|
44
|
+
version: 1,
|
|
45
|
+
validate: validateSchema,
|
|
46
|
+
encodeStorage(storage, context) {
|
|
47
|
+
return encodeStorage(storage, context.dialect);
|
|
48
|
+
},
|
|
49
|
+
encodeExpression(expression, context) {
|
|
50
|
+
return encodeExpression(expression, context.mode, context.dialect);
|
|
51
|
+
},
|
|
52
|
+
encodeDialectExtension(extension, context) {
|
|
53
|
+
return encodeExtension(extension, context.dialect);
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
/** Snapshot adapter retaining the historical adapter-shaped entry point. */
|
|
57
|
+
const sqliteSnapshotAdapter = Object.freeze({ dialect: sqliteSchemaDialect });
|
|
58
|
+
/** Create a canonical SQLite schema snapshot. */
|
|
59
|
+
function createSchemaSnapshot(schema, options = {}) {
|
|
60
|
+
return createSchemaSnapshot$1(schema, {
|
|
61
|
+
...options,
|
|
62
|
+
adapter: sqliteSnapshotAdapter
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
/** Return SQLite capability diagnostics without throwing. */
|
|
66
|
+
function tryCreateSchemaSnapshot(schema, options = {}) {
|
|
67
|
+
return tryCreateSchemaSnapshot$1(schema, {
|
|
68
|
+
...options,
|
|
69
|
+
adapter: sqliteSnapshotAdapter
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
function encodeStorage(storage, dialect) {
|
|
73
|
+
if (storage.kind === "native") {
|
|
74
|
+
if (storage.dialect !== dialect.name) throw new SqliteSnapshotDialectError(`SQLite storage cannot encode a native declaration owned by "${storage.dialect}"`);
|
|
75
|
+
if (storage.type.trim().length === 0) throw new TypeError("SQLite native storage declarations cannot be empty");
|
|
76
|
+
return {
|
|
77
|
+
kind: "native",
|
|
78
|
+
dialect: dialect.name,
|
|
79
|
+
type: storage.type,
|
|
80
|
+
affinity: storageAffinity(storage.type)
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
const type = sqliteStorageTypes[storage.type];
|
|
84
|
+
if (type === void 0) throw new TypeError(`Unsupported portable storage type for SQLite: ${String(storage.type)}`);
|
|
85
|
+
return {
|
|
86
|
+
kind: "native",
|
|
87
|
+
dialect: dialect.name,
|
|
88
|
+
type,
|
|
89
|
+
affinity: storageAffinity(type)
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
function encodeExpression(expression, mode, dialect) {
|
|
93
|
+
if (isUnsafeSchemaSql(expression) && expression.schemaSqlDialect !== dialect.name) throw new SqliteSnapshotDialectError(`Schema SQL is tagged for "${expression.schemaSqlDialect}" but the SQLite schema dialect is "${dialect.name}"`);
|
|
94
|
+
const rendered = renderSchemaExpression(expression, {
|
|
95
|
+
mode,
|
|
96
|
+
dialect
|
|
97
|
+
});
|
|
98
|
+
if (rendered.parameters.length !== 0) throw new TypeError("SQLite schema expressions must be parameter-free");
|
|
99
|
+
return {
|
|
100
|
+
kind: "expression",
|
|
101
|
+
expressionKind: expression.expressionKind,
|
|
102
|
+
sql: rendered.text,
|
|
103
|
+
...isUnsafeSchemaSql(expression) ? { dialect: dialect.name } : {}
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
function encodeExtension(extension, dialect) {
|
|
107
|
+
if (extension.dialect !== dialect.name) throw new TypeError(`SQLite schema extensions require dialect "${dialect.name}"`);
|
|
108
|
+
const data = Object.fromEntries(Object.entries(extension).filter(([key]) => key !== "dialect").sort(([left], [right]) => left.localeCompare(right)));
|
|
109
|
+
return {
|
|
110
|
+
dialect: dialect.name,
|
|
111
|
+
version: dialect.schema.version,
|
|
112
|
+
data: sortSnapshotJson(toSnapshotJsonValue(data))
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
function sortSnapshotJson(value) {
|
|
116
|
+
if (Array.isArray(value)) return value.map(sortSnapshotJson);
|
|
117
|
+
if (typeof value !== "object" || value === null) return value;
|
|
118
|
+
return Object.fromEntries(Object.entries(value).sort(([left], [right]) => left.localeCompare(right)).map(([key, child]) => [key, sortSnapshotJson(child)]));
|
|
119
|
+
}
|
|
120
|
+
function validateSchema(schema, context) {
|
|
121
|
+
const diagnostics = [];
|
|
122
|
+
const tableEntries = Object.entries(schema.registry).sort(([left], [right]) => compareIds(left, right));
|
|
123
|
+
const relationNames = /* @__PURE__ */ new Map();
|
|
124
|
+
if (schema.namespace !== void 0) validateName(schema.namespace, ["namespace"], "SQLite namespace", diagnostics);
|
|
125
|
+
for (const [id, entry] of tableEntries) {
|
|
126
|
+
const tablePath = ["tables", id];
|
|
127
|
+
validateName(entry.physicalName, [...tablePath, "physicalName"], "SQLite table", diagnostics);
|
|
128
|
+
addRelationName(relationNames, entry.physicalName, [...tablePath, "physicalName"], "table", diagnostics);
|
|
129
|
+
}
|
|
130
|
+
for (const [id, entry] of tableEntries) validateTable(id, entry, context, relationNames, diagnostics);
|
|
131
|
+
return Object.freeze(diagnostics);
|
|
132
|
+
}
|
|
133
|
+
function validateTable(tableId, entry, context, relationNames, diagnostics) {
|
|
134
|
+
const table = entry.table;
|
|
135
|
+
const tablePath = ["tables", tableId];
|
|
136
|
+
const definitions = table.definitions;
|
|
137
|
+
const metadata = table;
|
|
138
|
+
for (const [columnId, definition] of Object.entries(definitions).sort(([left], [right]) => compareIds(left, right))) {
|
|
139
|
+
validateName(table.sqlNames[columnId] ?? columnId, [
|
|
140
|
+
...tablePath,
|
|
141
|
+
"columns",
|
|
142
|
+
columnId,
|
|
143
|
+
"physicalName"
|
|
144
|
+
], "SQLite column", diagnostics);
|
|
145
|
+
if (definition.onUpdate !== void 0) diagnostics.push({
|
|
146
|
+
code: "unsupported-dialect-option",
|
|
147
|
+
message: "MySQL ON UPDATE expressions are not supported by SQLite",
|
|
148
|
+
path: [
|
|
149
|
+
...tablePath,
|
|
150
|
+
"columns",
|
|
151
|
+
columnId,
|
|
152
|
+
"onUpdate"
|
|
153
|
+
]
|
|
154
|
+
});
|
|
155
|
+
const storage = definition.storage;
|
|
156
|
+
const identity = definition.identity;
|
|
157
|
+
if (identity !== void 0) {
|
|
158
|
+
const identityPath = [
|
|
159
|
+
...tablePath,
|
|
160
|
+
"columns",
|
|
161
|
+
columnId,
|
|
162
|
+
"identity"
|
|
163
|
+
];
|
|
164
|
+
const extension = identity.dialect;
|
|
165
|
+
if (extension !== void 0 && extension.dialect === "sqlite" && extension.autoIncrement !== void 0 && typeof extension.autoIncrement !== "boolean") diagnostics.push({
|
|
166
|
+
code: "unsupported-dialect-option",
|
|
167
|
+
message: "SQLite identity autoIncrement must be boolean",
|
|
168
|
+
path: [
|
|
169
|
+
...identityPath,
|
|
170
|
+
"dialect",
|
|
171
|
+
"autoIncrement"
|
|
172
|
+
]
|
|
173
|
+
});
|
|
174
|
+
const primary = primaryKeyForColumn(metadata.constraints, columnId);
|
|
175
|
+
const declaration = declarationFor(storage);
|
|
176
|
+
if ((declaration === void 0 ? void 0 : storageAffinity(declaration)) !== "integer") diagnostics.push({
|
|
177
|
+
code: "unsupported-dialect-option",
|
|
178
|
+
message: "SQLite identity columns must use INTEGER affinity so they can be rowid aliases",
|
|
179
|
+
path: [...identityPath, "generation"]
|
|
180
|
+
});
|
|
181
|
+
if (primary === void 0 || primary.length !== 1) diagnostics.push({
|
|
182
|
+
code: "unsupported-dialect-option",
|
|
183
|
+
message: "SQLite identity columns must be the sole column of a PRIMARY KEY constraint",
|
|
184
|
+
path: [...identityPath, "generation"]
|
|
185
|
+
});
|
|
186
|
+
if (extension?.dialect === "sqlite" && extension.autoIncrement === true && declaration?.trim().toUpperCase() !== "INTEGER") diagnostics.push({
|
|
187
|
+
code: "unsupported-dialect-option",
|
|
188
|
+
message: "SQLite AUTOINCREMENT requires an exact INTEGER PRIMARY KEY declaration",
|
|
189
|
+
path: [
|
|
190
|
+
...identityPath,
|
|
191
|
+
"dialect",
|
|
192
|
+
"autoIncrement"
|
|
193
|
+
]
|
|
194
|
+
});
|
|
195
|
+
}
|
|
196
|
+
if (definition.generatedColumn?.kind === "expression" && primaryKeyForColumn(metadata.constraints, columnId) !== void 0) diagnostics.push({
|
|
197
|
+
code: "unsupported-dialect-option",
|
|
198
|
+
message: "SQLite generated columns cannot be part of a PRIMARY KEY",
|
|
199
|
+
path: [
|
|
200
|
+
...tablePath,
|
|
201
|
+
"columns",
|
|
202
|
+
columnId,
|
|
203
|
+
"generatedColumn"
|
|
204
|
+
]
|
|
205
|
+
});
|
|
206
|
+
}
|
|
207
|
+
const constraintNames = /* @__PURE__ */ new Map();
|
|
208
|
+
const constraints = Object.entries(metadata.constraints);
|
|
209
|
+
for (const [constraintId, constraint] of constraints.sort(([left], [right]) => compareIds(left, right))) {
|
|
210
|
+
const constraintPath = [
|
|
211
|
+
...tablePath,
|
|
212
|
+
"constraints",
|
|
213
|
+
constraintId
|
|
214
|
+
];
|
|
215
|
+
const physicalName = constraint.physicalName ?? constraintId;
|
|
216
|
+
validateName(physicalName, [...constraintPath, "physicalName"], "SQLite constraint", diagnostics);
|
|
217
|
+
addScopedName(constraintNames, physicalName, [...constraintPath, "physicalName"], "constraint", diagnostics);
|
|
218
|
+
appendMetadataDiagnostics(diagnostics, validateConstraintDialect(constraint, context.dialect.name, constraintPath));
|
|
219
|
+
if ((constraint.kind === "primary-key" || constraint.kind === "unique" || constraint.kind === "unique-constraint" || constraint.kind === "check") && (constraint.deferrable === true || constraint.initially !== void 0)) diagnostics.push({
|
|
220
|
+
code: "unsupported-dialect-option",
|
|
221
|
+
message: "SQLite only supports DEFERRABLE timing on foreign-key constraints",
|
|
222
|
+
path: [...constraintPath, constraint.deferrable ? "deferrable" : "initially"]
|
|
223
|
+
});
|
|
224
|
+
if (constraint.kind === "foreign-key" && constraint.match !== void 0 && constraint.match !== "simple") diagnostics.push({
|
|
225
|
+
code: "unsupported-dialect-option",
|
|
226
|
+
message: "SQLite supports MATCH SIMPLE foreign keys only",
|
|
227
|
+
path: [...constraintPath, "match"]
|
|
228
|
+
});
|
|
229
|
+
if (constraint.kind === "unique-constraint" && constraint.nulls === "not-distinct") diagnostics.push({
|
|
230
|
+
code: "unsupported-dialect-option",
|
|
231
|
+
message: "SQLite UNIQUE constraints always use distinct NULL semantics in v1",
|
|
232
|
+
path: [...constraintPath, "nulls"]
|
|
233
|
+
});
|
|
234
|
+
if (constraint.dialect?.dialect === "sqlite" && "onConflict" in constraint.dialect && constraint.dialect.onConflict !== void 0 && ![
|
|
235
|
+
"rollback",
|
|
236
|
+
"abort",
|
|
237
|
+
"fail",
|
|
238
|
+
"ignore",
|
|
239
|
+
"replace"
|
|
240
|
+
].includes(String(constraint.dialect.onConflict))) diagnostics.push({
|
|
241
|
+
code: "unsupported-dialect-option",
|
|
242
|
+
message: "SQLite constraint onConflict has an unsupported value",
|
|
243
|
+
path: [
|
|
244
|
+
...constraintPath,
|
|
245
|
+
"dialect",
|
|
246
|
+
"onConflict"
|
|
247
|
+
]
|
|
248
|
+
});
|
|
249
|
+
}
|
|
250
|
+
const indexes = Object.entries(metadata.indexes);
|
|
251
|
+
for (const [indexId, index] of indexes.sort(([left], [right]) => compareIds(left, right))) {
|
|
252
|
+
const indexPath = [
|
|
253
|
+
...tablePath,
|
|
254
|
+
"indexes",
|
|
255
|
+
indexId
|
|
256
|
+
];
|
|
257
|
+
const physicalName = index.physicalName ?? indexId;
|
|
258
|
+
validateName(physicalName, [...indexPath, "physicalName"], "SQLite index", diagnostics);
|
|
259
|
+
addRelationName(relationNames, physicalName, [...indexPath, "physicalName"], "index", diagnostics);
|
|
260
|
+
appendMetadataDiagnostics(diagnostics, validateIndexDialect(index, context.dialect.name, indexPath));
|
|
261
|
+
if (index.dialect?.dialect === "sqlite" && "auto" in index.dialect && index.dialect.auto !== void 0 && typeof index.dialect.auto !== "boolean") diagnostics.push({
|
|
262
|
+
code: "unsupported-dialect-option",
|
|
263
|
+
message: "SQLite index auto must be boolean",
|
|
264
|
+
path: [
|
|
265
|
+
...indexPath,
|
|
266
|
+
"dialect",
|
|
267
|
+
"auto"
|
|
268
|
+
]
|
|
269
|
+
});
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
function declarationFor(storage) {
|
|
273
|
+
if (storage === void 0) return;
|
|
274
|
+
if (storage.kind === "native") return storage.type;
|
|
275
|
+
return sqliteStorageTypes[storage.type];
|
|
276
|
+
}
|
|
277
|
+
function primaryKeyForColumn(constraints, columnId) {
|
|
278
|
+
for (const constraint of Object.values(constraints)) {
|
|
279
|
+
if (constraint.kind !== "primary-key") continue;
|
|
280
|
+
if (constraint.columns.some((column) => isColumnReference(column) && column.fieldName === columnId)) return constraint.columns;
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
function validateName(name, path, kind, diagnostics) {
|
|
284
|
+
if (!isValidSchemaObjectName(name) || name.length === 0) diagnostics.push({
|
|
285
|
+
code: "invalid-schema",
|
|
286
|
+
message: `${kind} name "${name}" is not a valid unqualified identifier`,
|
|
287
|
+
path
|
|
288
|
+
});
|
|
289
|
+
}
|
|
290
|
+
function addRelationName(names, name, path, kind, diagnostics) {
|
|
291
|
+
addScopedName(names, name, path, kind, diagnostics);
|
|
292
|
+
}
|
|
293
|
+
function addScopedName(names, name, path, kind, diagnostics) {
|
|
294
|
+
const previousPath = names.get(name);
|
|
295
|
+
if (previousPath !== void 0) {
|
|
296
|
+
diagnostics.push({
|
|
297
|
+
code: "invalid-schema",
|
|
298
|
+
message: `SQLite ${kind} name "${name}" collides with another table or index`,
|
|
299
|
+
path,
|
|
300
|
+
relatedPaths: [previousPath]
|
|
301
|
+
});
|
|
302
|
+
return;
|
|
303
|
+
}
|
|
304
|
+
names.set(name, path);
|
|
305
|
+
}
|
|
306
|
+
function appendMetadataDiagnostics(diagnostics, issues) {
|
|
307
|
+
for (const issue of issues) {
|
|
308
|
+
if (issue.code === "dialect-mismatch") continue;
|
|
309
|
+
diagnostics.push({
|
|
310
|
+
code: issue.code === "unsupported-dialect-option" ? "unsupported-dialect-option" : "invalid-schema",
|
|
311
|
+
message: issue.message,
|
|
312
|
+
path: issue.path,
|
|
313
|
+
...issue.relatedPaths === void 0 ? {} : { relatedPaths: issue.relatedPaths }
|
|
314
|
+
});
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
function compareIds(left, right) {
|
|
318
|
+
return left < right ? -1 : left > right ? 1 : 0;
|
|
319
|
+
}
|
|
320
|
+
//#endregion
|
|
321
|
+
export { createSchemaSnapshot, sqliteSchemaDialect, sqliteSnapshotAdapter, sqliteSnapshotDialect, storageAffinity, tryCreateSchemaSnapshot };
|
|
@@ -1,44 +1,6 @@
|
|
|
1
1
|
import { s as assertSchemaSnapshot } from "./canonical-DMvR9yBe.mjs";
|
|
2
|
-
import {
|
|
3
|
-
|
|
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
|
|
2
|
+
import { storageAffinity } from "./snapshot/sqlite.mjs";
|
|
3
|
+
import { n as createIntrospectionDiagnostic } from "./diagnostics-I9vVtXkc.mjs";
|
|
42
4
|
//#region src/introspection/identity.ts
|
|
43
5
|
/** The naming policy used by the first introspection snapshot mapper. */
|
|
44
6
|
const introspectedPhysicalIdentityPolicy = Object.freeze({
|
|
@@ -119,7 +81,7 @@ function mapColumn(dialect, table, column, options, diagnostics) {
|
|
|
119
81
|
kind: "native",
|
|
120
82
|
dialect,
|
|
121
83
|
type: column.storage.nativeType,
|
|
122
|
-
...dialect === "sqlite" ? { affinity:
|
|
84
|
+
...dialect === "sqlite" ? { affinity: storageAffinity(column.storage.nativeType) } : {}
|
|
123
85
|
};
|
|
124
86
|
return {
|
|
125
87
|
id: resolveId("column", column.id, column.physicalName, table.physicalName, options),
|
|
@@ -389,4 +351,4 @@ function isError(value) {
|
|
|
389
351
|
return value.severity === "error";
|
|
390
352
|
}
|
|
391
353
|
//#endregion
|
|
392
|
-
export {
|
|
354
|
+
export { introspectedPhysicalIdentityPolicy as n, mapCatalogToSnapshot as t };
|
package/dist/snapshot.d.mts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { A as SnapshotStorage,
|
|
2
|
-
import { A as CompleteSnapshotProvenance, B as SchemaSnapshotV2Input, C as CompleteSnapshotObjectMetadata, D as CompleteSnapshotPartition, E as CompleteSnapshotOwnership, F as CompleteSnapshotTrigger, G as schemaSnapshotVersion2, H as completeSchemaSnapshotVersion, I as CompleteSnapshotValueFact, L as CompleteSnapshotView, M as CompleteSnapshotRoutineParameter, N as CompleteSnapshotSequence, O as CompleteSnapshotPhysicalReference, P as CompleteSnapshotTable, R as SchemaSnapshotV2, S as CompleteSnapshotObjectKind, T as CompleteSnapshotOpaqueObject, U as schemaSnapshotCompleteVersion, V as completeSchemaSnapshotFormat, W as schemaSnapshotV2Version, _ as CompleteSnapshotIndex, a as CompleteSnapshotCollation, b as CompleteSnapshotNamespace, c as CompleteSnapshotConstraint, d as CompleteSnapshotDeferredObject, f as CompleteSnapshotDomain, g as CompleteSnapshotIdentity, h as CompleteSnapshotForeignKey, i as CompleteSnapshotCheckConstraint, j as CompleteSnapshotRoutine, k as CompleteSnapshotPolicy, l as CompleteSnapshotCreateResult, m as CompleteSnapshotExtension, n as CompleteSchemaSnapshotInput, o as CompleteSnapshotColumn, p as CompleteSnapshotEnum, r as CompleteSnapshotCapabilities, s as CompleteSnapshotComment, t as CompleteSchemaSnapshot, u as CompleteSnapshotDecodeResult, v as CompleteSnapshotIndexTerm, w as CompleteSnapshotObjectReference, x as CompleteSnapshotObject, y as CompleteSnapshotKeyConstraint, z as SchemaSnapshotV2DecodeResult } from "./complete-types-
|
|
3
|
-
import {
|
|
4
|
-
|
|
1
|
+
import { A as SnapshotStorage, Ar as SchemaDialect, C as SnapshotIndexTerm, D as SnapshotLiteral, E as SnapshotKeyConstraint, F as neutralSnapshotDialect, I as schemaSnapshotDialectVersion, L as schemaSnapshotFormat, M as SnapshotTable, Mr as createSchemaDialect, N as SnapshotUniqueConstraint, O as SnapshotNamingPolicy, P as SnapshotValidationContext, R as schemaSnapshotNamingPolicyVersion, S as SnapshotIndex, T as SnapshotJsonValue, _ as SnapshotExpressionContext, a as SnapshotBigInt, b as SnapshotGeneratedColumn, c as SnapshotConstraint, d as SnapshotDefault, ds as NativeColumnStorage, f as SnapshotDiagnostic, g as SnapshotExpression, h as SnapshotDialectExtension, i as SchemaSnapshotInput, j as SnapshotStorageContext, jr as SchemaDialectHooks, k as SnapshotSpecialNumber, l as SnapshotCreateResult, m as SnapshotDialect, ms as PortableColumnStorage, n as SchemaSnapshot, o as SnapshotCheckConstraint, p as SnapshotDiagnosticCode, r as SchemaSnapshotAdapter, s as SnapshotColumn, t as AnySchema, u as SnapshotDecodeResult, v as SnapshotExtensionContext, w as SnapshotIndexTermExpression, x as SnapshotIdentity, y as SnapshotForeignKey, z as schemaSnapshotVersion } from "./types-DUe6eeI0.mjs";
|
|
2
|
+
import { A as CompleteSnapshotProvenance, B as SchemaSnapshotV2Input, C as CompleteSnapshotObjectMetadata, D as CompleteSnapshotPartition, E as CompleteSnapshotOwnership, F as CompleteSnapshotTrigger, G as schemaSnapshotVersion2, H as completeSchemaSnapshotVersion, I as CompleteSnapshotValueFact, L as CompleteSnapshotView, M as CompleteSnapshotRoutineParameter, N as CompleteSnapshotSequence, O as CompleteSnapshotPhysicalReference, P as CompleteSnapshotTable, R as SchemaSnapshotV2, S as CompleteSnapshotObjectKind, T as CompleteSnapshotOpaqueObject, U as schemaSnapshotCompleteVersion, V as completeSchemaSnapshotFormat, W as schemaSnapshotV2Version, _ as CompleteSnapshotIndex, a as CompleteSnapshotCollation, b as CompleteSnapshotNamespace, c as CompleteSnapshotConstraint, d as CompleteSnapshotDeferredObject, f as CompleteSnapshotDomain, g as CompleteSnapshotIdentity, h as CompleteSnapshotForeignKey, i as CompleteSnapshotCheckConstraint, j as CompleteSnapshotRoutine, k as CompleteSnapshotPolicy, l as CompleteSnapshotCreateResult, m as CompleteSnapshotExtension, n as CompleteSchemaSnapshotInput, o as CompleteSnapshotColumn, p as CompleteSnapshotEnum, r as CompleteSnapshotCapabilities, s as CompleteSnapshotComment, t as CompleteSchemaSnapshot, u as CompleteSnapshotDecodeResult, v as CompleteSnapshotIndexTerm, w as CompleteSnapshotObjectReference, x as CompleteSnapshotObject, y as CompleteSnapshotKeyConstraint, z as SchemaSnapshotV2DecodeResult } from "./complete-types-CNMWBWap.mjs";
|
|
3
|
+
import { _ as toSnapshotJsonValue, a as encodeSnapshot, c as tryCreateSchemaSnapshot, d as canonicalizeSchemaSnapshot, f as decodeSchemaSnapshot, g as schemaSnapshotFingerprint, h as encodeCanonicalSnapshot, i as encodeSchemaSnapshot, l as SnapshotValidationError, m as canonicalJson, n as SnapshotSerializationError, o as fingerprintSchemaSnapshot, p as SnapshotCanonicalError, r as createSchemaSnapshot, s as serializeSchema, t as SchemaSnapshotOptions, u as assertSchemaSnapshot } from "./serialize-OvXCLzjm.mjs";
|
|
4
|
+
import { a as canonicalizeCompleteSchemaSnapshot, c as decodeCompleteSchemaSnapshot, d as encodeCompleteSchemaSnapshot, f as encodeCompleteSnapshot, h as schemaSnapshotV2Fingerprint, i as assertSchemaSnapshotV2, l as decodeCompleteSnapshot, m as fingerprintCompleteSchemaSnapshot, n as assertCompleteSchemaSnapshot, o as canonicalizeSchemaSnapshotV2, p as encodeSchemaSnapshotV2, r as assertCompleteSnapshot, s as completeSchemaSnapshotFingerprint, t as CompleteSnapshotValidationError, u as decodeSchemaSnapshotV2 } from "./index-CGui70hi.mjs";
|
|
5
|
+
export { AnySchema, CompleteSchemaSnapshot, CompleteSchemaSnapshotInput, CompleteSnapshotCapabilities, CompleteSnapshotCheckConstraint, CompleteSnapshotCollation, CompleteSnapshotColumn, CompleteSnapshotComment, CompleteSnapshotConstraint, CompleteSnapshotCreateResult, CompleteSnapshotDecodeResult, CompleteSnapshotDeferredObject, CompleteSnapshotDomain, CompleteSnapshotEnum, CompleteSnapshotExtension, CompleteSnapshotForeignKey, CompleteSnapshotIdentity, CompleteSnapshotIndex, CompleteSnapshotIndexTerm, CompleteSnapshotKeyConstraint, CompleteSnapshotNamespace, CompleteSnapshotObject, CompleteSnapshotObjectKind, CompleteSnapshotObjectMetadata, CompleteSnapshotObjectReference, CompleteSnapshotOpaqueObject, CompleteSnapshotOwnership, CompleteSnapshotPartition, CompleteSnapshotPhysicalReference, CompleteSnapshotPolicy, CompleteSnapshotProvenance, CompleteSnapshotRoutine, CompleteSnapshotRoutineParameter, CompleteSnapshotSequence, CompleteSnapshotTable, CompleteSnapshotTrigger, CompleteSnapshotValidationError, CompleteSnapshotValueFact, CompleteSnapshotView, type NativeColumnStorage, type PortableColumnStorage, type SchemaDialect, type SchemaDialectHooks, SchemaSnapshot, SchemaSnapshotAdapter, SchemaSnapshotInput, SchemaSnapshotOptions, SchemaSnapshotV2, SchemaSnapshotV2DecodeResult, SchemaSnapshotV2Input, SnapshotBigInt, SnapshotCanonicalError, SnapshotCheckConstraint, SnapshotColumn, SnapshotConstraint, SnapshotCreateResult, SnapshotDecodeResult, SnapshotDefault, SnapshotDiagnostic, SnapshotDiagnosticCode, SnapshotDialect, SnapshotDialectExtension, SnapshotExpression, SnapshotExpressionContext, SnapshotExtensionContext, SnapshotForeignKey, SnapshotGeneratedColumn, SnapshotIdentity, SnapshotIndex, SnapshotIndexTerm, SnapshotIndexTermExpression, SnapshotJsonValue, SnapshotKeyConstraint, SnapshotLiteral, SnapshotNamingPolicy, SnapshotSerializationError, SnapshotSpecialNumber, SnapshotStorage, SnapshotStorageContext, SnapshotTable, SnapshotUniqueConstraint, SnapshotValidationContext, SnapshotValidationError, assertCompleteSchemaSnapshot, assertCompleteSnapshot, assertSchemaSnapshot, assertSchemaSnapshotV2, canonicalJson, canonicalizeCompleteSchemaSnapshot, canonicalizeSchemaSnapshot, canonicalizeSchemaSnapshotV2, completeSchemaSnapshotFingerprint, completeSchemaSnapshotFormat, completeSchemaSnapshotVersion, createSchemaDialect, createSchemaSnapshot, decodeCompleteSchemaSnapshot, decodeCompleteSnapshot, decodeSchemaSnapshot, decodeSchemaSnapshotV2, encodeCanonicalSnapshot, encodeCompleteSchemaSnapshot, encodeCompleteSnapshot, encodeSchemaSnapshot, encodeSchemaSnapshotV2, encodeSnapshot, fingerprintCompleteSchemaSnapshot, fingerprintSchemaSnapshot, neutralSnapshotDialect, schemaSnapshotCompleteVersion, schemaSnapshotDialectVersion, schemaSnapshotFingerprint, schemaSnapshotFormat, schemaSnapshotNamingPolicyVersion, schemaSnapshotV2Fingerprint, schemaSnapshotV2Version, schemaSnapshotVersion, schemaSnapshotVersion2, serializeSchema, toSnapshotJsonValue, tryCreateSchemaSnapshot };
|