@voltro/database 0.84.0 → 0.86.0
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/CHANGELOG.md +1215 -0
- package/THIRD-PARTY-NOTICES.md +5 -89
- package/dist/actorSnapshot.js +24 -0
- package/dist/arrayCodec.js +32 -0
- package/dist/branchExecute.js +92 -0
- package/dist/branching.js +106 -0
- package/dist/bulkInsertLimits.js +25 -0
- package/dist/cdcOffsetsTables.js +19 -0
- package/dist/changeEvent.js +41 -0
- package/dist/changeIdentity.js +65 -0
- package/dist/changeListenerCeiling.js +6 -0
- package/dist/columnReference.js +17 -0
- package/dist/columns.js +326 -0
- package/dist/committedChanges.js +12 -0
- package/dist/connectionIdentity.js +36 -0
- package/dist/coreTables.js +16 -0
- package/dist/coreTablesRegistry.js +10 -0
- package/dist/dataTransfers.js +22 -0
- package/dist/dbCause.js +222 -0
- package/dist/dbMetrics.js +65 -0
- package/dist/decimalComparison.js +27 -0
- package/dist/derivedRowId.js +5 -0
- package/dist/dialect.js +13 -0
- package/dist/enumRenames.js +14 -0
- package/dist/expiresMixin.js +10 -0
- package/dist/fieldEncryption.js +98 -0
- package/dist/frameworkTables.js +130 -0
- package/dist/ginIndex.js +10 -0
- package/dist/hybridSearch.js +32 -0
- package/dist/idGenerator.js +57 -0
- package/dist/identifierLimits.js +32 -0
- package/dist/index.d.ts +122 -64
- package/dist/index.js +81 -2080
- package/dist/indexAudit.js +61 -0
- package/dist/indexStorage.js +58 -0
- package/dist/joinCompiler.js +160 -0
- package/dist/jsonEagerCompiler.js +436 -0
- package/dist/jsonPatch.js +78 -0
- package/dist/jsonPatchAssignments.js +13 -0
- package/dist/jsonPath.js +31 -0
- package/dist/localFirstMixin.js +12 -0
- package/dist/migrate.js +624 -0
- package/dist/migration.js +18 -0
- package/dist/migrations/appliedAtValue.js +8 -0
- package/dist/migrations/applier.js +1085 -0
- package/dist/migrations/boot.js +196 -0
- package/dist/migrations/branchRehearsal.js +122 -0
- package/dist/migrations/columnEquivalence.js +85 -0
- package/dist/migrations/ddlError.js +63 -0
- package/dist/migrations/declaredSchema.js +162 -0
- package/dist/migrations/deployLedger.js +19 -0
- package/dist/migrations/fileBased.js +57 -0
- package/dist/migrations/fileContext.js +482 -0
- package/dist/migrations/fileDiscovery.js +318 -0
- package/dist/migrations/fileSkipProbes.js +117 -0
- package/dist/migrations/fingerprint.js +46 -0
- package/dist/migrations/fkCycles.js +13 -0
- package/dist/migrations/frameworkLiveTables.js +25 -0
- package/dist/migrations/idempotentDdl.js +37 -0
- package/dist/migrations/indexPredicate.js +50 -0
- package/dist/migrations/introspect.js +799 -0
- package/dist/migrations/ledgerRows.js +4 -0
- package/dist/migrations/lock.js +91 -0
- package/dist/migrations/migrationTableExists.js +9 -0
- package/dist/migrations/mssqlColumnDependencies.js +76 -0
- package/dist/migrations/mysqlEngine.js +11 -0
- package/dist/migrations/namespaceCharset.js +51 -0
- package/dist/migrations/planner.js +775 -0
- package/dist/migrations/postgresEnumCheck.js +19 -0
- package/dist/migrations/reactiveTriggerDrift.js +58 -0
- package/dist/migrations/reactiveTriggerName.js +7 -0
- package/dist/migrations/renameMssqlCheck.js +21 -0
- package/dist/migrations/restoreSnapshots.js +206 -0
- package/dist/migrations/resumeLedger.js +86 -0
- package/dist/migrations/rollingDeploy.js +106 -0
- package/dist/migrations/schemaOwner.js +46 -0
- package/dist/migrations/schemaOwnerTable.js +4 -0
- package/dist/migrations/softDropSnapshot.js +20 -0
- package/dist/migrations/sqlLimit.js +8 -0
- package/dist/migrations/sqliteConstraintIdentity.js +97 -0
- package/dist/migrations/sqliteDecimalBoot.js +22 -0
- package/dist/migrations/sqliteDecimalPublication.js +257 -0
- package/dist/migrations/sqliteDecimalReview.js +30 -0
- package/dist/migrations/sqliteDecimalReviewStore.js +188 -0
- package/dist/migrations/sqliteDecimalReviewWitness.js +38 -0
- package/dist/migrations/sqliteDecimalSource.js +69 -0
- package/dist/migrations/sqliteDecimalStage.js +135 -0
- package/dist/migrations/sqliteForeignKeys.js +38 -0
- package/dist/migrations/sqliteMigrationBatch.js +37 -0
- package/dist/migrations/sqliteRetainedSource.js +106 -0
- package/dist/migrations/sqliteRowIdentity.js +63 -0
- package/dist/migrations/sqliteSchemaEpoch.js +12 -0
- package/dist/migrations/sqliteSnapshotGuard.js +10 -0
- package/dist/migrations/sqliteTableContents.js +34 -0
- package/dist/migrations/sqliteTableCopy.js +25 -0
- package/dist/migrations/sqliteTableSchema.js +19 -0
- package/dist/migrations/sqliteWitnessProtection.js +8 -0
- package/dist/migrations/squash.js +81 -0
- package/dist/migrations/storeCharset.js +66 -0
- package/dist/migrations/transactionCause.js +10 -0
- package/dist/migrations/undeclaredCharset.js +40 -0
- package/dist/migrations/uniqueActiveLowering.js +39 -0
- package/dist/mixins.js +22 -0
- package/dist/mssqlDecimalDistinct.js +51 -0
- package/dist/mssqlJsonValueCheck.js +42 -0
- package/dist/mssqlTextStorage.js +9 -0
- package/dist/namespace.js +21 -0
- package/dist/{wire-B28cPjEp.js → optimisticVersion.js} +2 -2
- package/dist/pendingAttribution.js +79 -0
- package/dist/pluginRef.js +17 -0
- package/dist/predicate.js +266 -0
- package/dist/predicateCoercion.js +13 -0
- package/dist/projectedColumn.js +37 -0
- package/dist/queryBuilder.js +382 -0
- package/dist/rawSql.js +8 -0
- package/dist/relations.js +69 -0
- package/dist/relationsRegistry.js +38 -0
- package/dist/replaceInProgress.js +53 -0
- package/dist/requiredColumns.js +26 -0
- package/dist/residency.js +52 -0
- package/dist/retention.js +62 -0
- package/dist/rowDecoder.js +123 -0
- package/dist/rowKey.js +8 -0
- package/dist/rowSchema.js +31 -0
- package/dist/scopeKey.js +8 -0
- package/dist/seed.js +33 -0
- package/dist/snowflake.js +26 -0
- package/dist/sql.d.ts +58 -29
- package/dist/sql.js +41 -6661
- package/dist/sqlCompiler.js +343 -0
- package/dist/sqlError.js +8 -0
- package/dist/sqlPoolCapacity.js +12 -0
- package/dist/sqliteDecimal.js +22 -0
- package/dist/sqliteDecimalAggregateSql.js +61 -0
- package/dist/sqliteDecimalColumnSql.js +108 -0
- package/dist/sqliteDecimalConversion.js +15 -0
- package/dist/sqliteDecimalCte.js +154 -0
- package/dist/sqliteDecimalEncodeSql.js +32 -0
- package/dist/sqliteDecimalOutputs.js +74 -0
- package/dist/sqliteDecimalPredicate.js +66 -0
- package/dist/sqliteDecimalQuery.js +183 -0
- package/dist/sqliteDecimalQueryPlan.js +37 -0
- package/dist/sqliteDecimalResultSql.js +44 -0
- package/dist/sqliteDecimalRowQuery.js +63 -0
- package/dist/sqliteDecimalSetQuery.js +50 -0
- package/dist/sqliteDecimalSource.js +63 -0
- package/dist/sqliteDecimalStorage.js +29 -0
- package/dist/sqliteDecimalSubquery.js +19 -0
- package/dist/sqliteDecimalWindowQuery.js +196 -0
- package/dist/sqliteValueCoercion.js +4 -0
- package/dist/stampId.js +21 -0
- package/dist/storeErrors.js +9 -0
- package/dist/storeRefusal.js +20 -0
- package/dist/stream.js +36 -0
- package/dist/subjectGraph.js +175 -0
- package/dist/table.js +394 -0
- package/dist/tableRegistry.js +16 -0
- package/dist/tenantSelection.js +27 -0
- package/dist/transactionOutcome.js +97 -0
- package/dist/transientContention.js +36 -0
- package/dist/typedStore.js +16 -0
- package/dist/upsertUpdate.js +20 -0
- package/dist/vectorEmbedding.js +31 -0
- package/dist/view.js +39 -0
- package/dist/wire.d.ts +9 -10
- package/dist/wire.js +6 -2
- package/dist/writeAttribution.js +16 -0
- package/dist/writeRecorder.js +37 -0
- package/package.json +4 -6
- package/dist/replaceInProgress-DUHl5JEz.js +0 -3557
package/dist/columns.js
ADDED
|
@@ -0,0 +1,326 @@
|
|
|
1
|
+
//#region src/columns.ts
|
|
2
|
+
var e = (e) => {
|
|
3
|
+
let t = [];
|
|
4
|
+
for (let [n, r] of Object.entries(e.fields)) r.serverOnly === !0 && t.push(n);
|
|
5
|
+
return t;
|
|
6
|
+
}, t = (e) => {
|
|
7
|
+
let t = [];
|
|
8
|
+
for (let [n, r] of Object.entries(e.fields)) r.crdtManaged === !0 && t.push(n);
|
|
9
|
+
return t;
|
|
10
|
+
}, n = (e) => {
|
|
11
|
+
let t = [];
|
|
12
|
+
for (let [n, r] of Object.entries(e.fields)) {
|
|
13
|
+
let e = r.readableBy;
|
|
14
|
+
e !== void 0 && e.length > 0 && t.push({
|
|
15
|
+
column: n,
|
|
16
|
+
scopes: e
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
return t;
|
|
20
|
+
}, r = (e) => {
|
|
21
|
+
let t = [];
|
|
22
|
+
for (let [n, r] of Object.entries(e.fields)) r.crdtManaged === !0 && t.push(n);
|
|
23
|
+
return t;
|
|
24
|
+
}, i = class e {
|
|
25
|
+
definition;
|
|
26
|
+
constructor(e) {
|
|
27
|
+
this.definition = e;
|
|
28
|
+
}
|
|
29
|
+
rejectIfRaw(e) {
|
|
30
|
+
if (this.definition.type === "raw") throw Error(`raw(...) column rejects .${e}() — the DDL fragment is the single source of truth for type/nullability/default. Encode ${e === "nullable" ? "NULL" : e === "unique" ? "UNIQUE" : "DEFAULT"} directly in the raw fragment instead.`);
|
|
31
|
+
}
|
|
32
|
+
nullable() {
|
|
33
|
+
return this.rejectIfRaw("nullable"), new e({
|
|
34
|
+
...this.definition,
|
|
35
|
+
nullable: !0
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
externalId() {
|
|
39
|
+
if (this.rejectIfRaw("externalId"), this.definition.type === "reference" || this.definition.type === "id") throw Error(`.externalId() requires a scalar non-primary-key column (got ${this.definition.type}) — \`reference()\` is local by definition and \`id()\` identifies this row.`);
|
|
40
|
+
return new e({
|
|
41
|
+
...this.definition,
|
|
42
|
+
externalId: !0
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
encrypted() {
|
|
46
|
+
return this.rejectIfRaw("encrypted"), new e({
|
|
47
|
+
...this.definition,
|
|
48
|
+
encrypted: !0
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
serverOnly() {
|
|
52
|
+
if (this.rejectIfRaw("serverOnly"), this.definition.crdtManaged === !0) throw Error("serverOnly() on a CRDT column (crdtText()/crdtDoc()) is a contradiction: clients write CRDT updates and must read the merged state back. Remove serverOnly(), or use a plain bytes() column if only the server touches it.");
|
|
53
|
+
return new e({
|
|
54
|
+
...this.definition,
|
|
55
|
+
serverOnly: !0
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
readableBy(...t) {
|
|
59
|
+
if (this.rejectIfRaw("readableBy"), t.length === 0) throw Error(".readableBy() needs at least one scope — a column readable by nobody is .serverOnly(). List the scopes that may read it, e.g. .readableBy('billing:read').");
|
|
60
|
+
if (t.find((e) => typeof e != "string" || e.trim() === "") !== void 0) throw Error(`.readableBy(...) rejects a blank scope — every scope must be a non-empty string (a blank scope can never be held, so it would hide the column from everyone). Got: ${JSON.stringify(t)}.`);
|
|
61
|
+
let n = [...new Set(t)];
|
|
62
|
+
return new e({
|
|
63
|
+
...this.definition,
|
|
64
|
+
readableBy: n
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
version() {
|
|
68
|
+
if (this.rejectIfRaw("version"), this.definition.type !== "integer") throw Error(`.version() requires an integer() column (got ${this.definition.type}). The store increments it, so it has to be a number — and a timestamp version reintroduces exactly the clock problem optimistic locking exists to avoid: two writes in the same millisecond are indistinguishable, and replica clocks disagree.`);
|
|
69
|
+
return new e({
|
|
70
|
+
...this.definition,
|
|
71
|
+
versionColumn: !0,
|
|
72
|
+
hasDefault: !0,
|
|
73
|
+
defaultValue: 1
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
sensitive(t) {
|
|
77
|
+
return new e({
|
|
78
|
+
...this.definition,
|
|
79
|
+
sensitive: { class: t }
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
safe() {
|
|
83
|
+
return new e({
|
|
84
|
+
...this.definition,
|
|
85
|
+
safe: !0
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
unique(t) {
|
|
89
|
+
return this.rejectIfRaw("unique"), t?.dedup === void 0 ? new e({
|
|
90
|
+
...this.definition,
|
|
91
|
+
unique: !0
|
|
92
|
+
}) : new e({
|
|
93
|
+
...this.definition,
|
|
94
|
+
unique: !0,
|
|
95
|
+
uniqueSpec: { dedup: t.dedup }
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
default(t) {
|
|
99
|
+
return this.rejectIfRaw("default"), typeof t == "function" ? new e({
|
|
100
|
+
...this.definition,
|
|
101
|
+
hasDefault: !0,
|
|
102
|
+
defaultFactory: t
|
|
103
|
+
}) : new e({
|
|
104
|
+
...this.definition,
|
|
105
|
+
hasDefault: !0,
|
|
106
|
+
defaultValue: t
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
computed(t) {
|
|
110
|
+
return new e({
|
|
111
|
+
...this.definition,
|
|
112
|
+
computed: t
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
onUpdate(t) {
|
|
116
|
+
return new e({
|
|
117
|
+
...this.definition,
|
|
118
|
+
onUpdate: t
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
generatedAs(t, n) {
|
|
122
|
+
return new e({
|
|
123
|
+
...this.definition,
|
|
124
|
+
generatedAs: {
|
|
125
|
+
expr: t,
|
|
126
|
+
stored: n?.stored ?? !1
|
|
127
|
+
}
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
backfill(t, n) {
|
|
131
|
+
let r = typeof t == "function" ? {
|
|
132
|
+
kind: "js",
|
|
133
|
+
fn: t,
|
|
134
|
+
...n?.batchSize === void 0 ? {} : { batchSize: n.batchSize },
|
|
135
|
+
...n?.sleepMs === void 0 ? {} : { sleepMs: n.sleepMs }
|
|
136
|
+
} : {
|
|
137
|
+
kind: "sql",
|
|
138
|
+
sql: t,
|
|
139
|
+
...n?.batchSize === void 0 ? {} : { batchSize: n.batchSize },
|
|
140
|
+
...n?.sleepMs === void 0 ? {} : { sleepMs: n.sleepMs }
|
|
141
|
+
};
|
|
142
|
+
return new e({
|
|
143
|
+
...this.definition,
|
|
144
|
+
backfill: r
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
renamedFrom(t) {
|
|
148
|
+
return new e({
|
|
149
|
+
...this.definition,
|
|
150
|
+
renamedFrom: t
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
narrowedFrom(t, n) {
|
|
154
|
+
let r = n?.using === void 0 ? { from: t } : {
|
|
155
|
+
from: t,
|
|
156
|
+
using: n.using
|
|
157
|
+
};
|
|
158
|
+
return new e({
|
|
159
|
+
...this.definition,
|
|
160
|
+
narrowedFrom: r
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
oneOf(t) {
|
|
164
|
+
return new e({
|
|
165
|
+
...this.definition,
|
|
166
|
+
oneOf: t
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
maxLength(t) {
|
|
170
|
+
return new e({
|
|
171
|
+
...this.definition,
|
|
172
|
+
maxLength: t
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
check(t) {
|
|
176
|
+
let n = this.definition.checks ? [...this.definition.checks, t] : [t];
|
|
177
|
+
return new e({
|
|
178
|
+
...this.definition,
|
|
179
|
+
checks: n
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
__definition() {
|
|
183
|
+
return this.definition;
|
|
184
|
+
}
|
|
185
|
+
}, a = (e) => new i({
|
|
186
|
+
type: e,
|
|
187
|
+
nullable: !1,
|
|
188
|
+
unique: !1,
|
|
189
|
+
hasDefault: !1
|
|
190
|
+
});
|
|
191
|
+
function o(e) {
|
|
192
|
+
return new i({
|
|
193
|
+
type: "id",
|
|
194
|
+
nullable: !1,
|
|
195
|
+
unique: !0,
|
|
196
|
+
hasDefault: !1,
|
|
197
|
+
idSchemeInput: e
|
|
198
|
+
});
|
|
199
|
+
}
|
|
200
|
+
var s = () => a("text"), c = () => a("integer"), l = () => a("real"), u = (e, t = 0) => {
|
|
201
|
+
if (!Number.isInteger(e) || e <= 0) throw Error(`decimal(${String(e)}, ${String(t)}): precision must be a positive integer (the total number of significant digits, e.g. decimal(12, 2)).`);
|
|
202
|
+
if (!Number.isInteger(t) || t < 0 || t > e) throw Error(`decimal(${String(e)}, ${String(t)}): scale must be an integer between 0 and precision (${e}).`);
|
|
203
|
+
return new i({
|
|
204
|
+
type: "decimal",
|
|
205
|
+
nullable: !1,
|
|
206
|
+
unique: !1,
|
|
207
|
+
hasDefault: !1,
|
|
208
|
+
precision: e,
|
|
209
|
+
scale: t,
|
|
210
|
+
sqliteDecimalEncoding: "sortable-v1"
|
|
211
|
+
});
|
|
212
|
+
}, d = u, f = () => a("bigint"), p = (e, t) => {
|
|
213
|
+
if (t.length === 0) throw Error(`dbEnum('${e}', []): enum must have at least one value`);
|
|
214
|
+
return {
|
|
215
|
+
name: e,
|
|
216
|
+
values: t,
|
|
217
|
+
column: () => new i({
|
|
218
|
+
type: "enum",
|
|
219
|
+
nullable: !1,
|
|
220
|
+
unique: !1,
|
|
221
|
+
hasDefault: !1,
|
|
222
|
+
enumName: e,
|
|
223
|
+
enumValues: t
|
|
224
|
+
})
|
|
225
|
+
};
|
|
226
|
+
}, m = () => a("boolean"), h = () => a("timestamp"), g = () => a("date"), _ = () => a("json"), v = () => a("bytes"), y = () => new i({
|
|
227
|
+
type: "bytes",
|
|
228
|
+
nullable: !0,
|
|
229
|
+
unique: !1,
|
|
230
|
+
hasDefault: !1,
|
|
231
|
+
crdtManaged: !0
|
|
232
|
+
}), b = () => new i({
|
|
233
|
+
type: "bytes",
|
|
234
|
+
nullable: !0,
|
|
235
|
+
unique: !1,
|
|
236
|
+
hasDefault: !1,
|
|
237
|
+
crdtManaged: !0
|
|
238
|
+
}), x = () => new i({
|
|
239
|
+
type: "bytes",
|
|
240
|
+
nullable: !0,
|
|
241
|
+
unique: !1,
|
|
242
|
+
hasDefault: !1,
|
|
243
|
+
crdtSealed: !0
|
|
244
|
+
}), S = () => new i({
|
|
245
|
+
type: "bytes",
|
|
246
|
+
nullable: !0,
|
|
247
|
+
unique: !1,
|
|
248
|
+
hasDefault: !1,
|
|
249
|
+
crdtManaged: !0
|
|
250
|
+
}), C = () => {
|
|
251
|
+
throw Error("selfReference(): the target is resolved by table() — a column built with selfReference() must be declared inside a table({ … }) literal, not read before the table exists");
|
|
252
|
+
};
|
|
253
|
+
function w(e) {
|
|
254
|
+
return T(C, e);
|
|
255
|
+
}
|
|
256
|
+
function T(e, t) {
|
|
257
|
+
return new i({
|
|
258
|
+
type: "reference",
|
|
259
|
+
nullable: !1,
|
|
260
|
+
unique: !1,
|
|
261
|
+
hasDefault: !1,
|
|
262
|
+
references: e,
|
|
263
|
+
referenceStorage: t?.storage ?? "text",
|
|
264
|
+
referenceColumn: t?.column ?? "id",
|
|
265
|
+
onDelete: t?.onDelete ?? "restrict",
|
|
266
|
+
refOnUpdate: t?.onUpdate ?? "noAction",
|
|
267
|
+
...t?.onSoftDelete === void 0 ? {} : { refOnSoftDelete: t.onSoftDelete },
|
|
268
|
+
fkAutoIndex: t?.index ?? !0,
|
|
269
|
+
...t?.orphanPolicy ? { orphanPolicy: t.orphanPolicy } : {}
|
|
270
|
+
});
|
|
271
|
+
}
|
|
272
|
+
var E = () => new i({
|
|
273
|
+
type: "text",
|
|
274
|
+
nullable: !0,
|
|
275
|
+
unique: !1,
|
|
276
|
+
hasDefault: !1,
|
|
277
|
+
dropped: !0
|
|
278
|
+
}), D = (e) => Object.keys(e.fields).filter((t) => e.fields[t]?.dropped !== !0), O = (e, t) => {
|
|
279
|
+
if (!Number.isInteger(e) || e <= 0) throw Error(`vector(${String(e)}): dimension must be a positive integer (the embedding length, e.g. vector(1536)).`);
|
|
280
|
+
return new i({
|
|
281
|
+
type: "vector",
|
|
282
|
+
nullable: !1,
|
|
283
|
+
unique: !1,
|
|
284
|
+
hasDefault: !1,
|
|
285
|
+
vectorDim: e,
|
|
286
|
+
vectorPrecision: t?.precision ?? "float32"
|
|
287
|
+
});
|
|
288
|
+
}, k = (e) => new i({
|
|
289
|
+
type: "array",
|
|
290
|
+
nullable: !1,
|
|
291
|
+
unique: !1,
|
|
292
|
+
hasDefault: !1,
|
|
293
|
+
arrayElement: e.__definition().type
|
|
294
|
+
}), A = () => a("interval"), j = (e, t = 4326) => new i({
|
|
295
|
+
type: "text",
|
|
296
|
+
nullable: !1,
|
|
297
|
+
unique: !1,
|
|
298
|
+
hasDefault: !1,
|
|
299
|
+
spatial: {
|
|
300
|
+
kind: "geography",
|
|
301
|
+
geomKind: e,
|
|
302
|
+
srid: t
|
|
303
|
+
}
|
|
304
|
+
}), M = (e, t = 4326) => new i({
|
|
305
|
+
type: "text",
|
|
306
|
+
nullable: !1,
|
|
307
|
+
unique: !1,
|
|
308
|
+
hasDefault: !1,
|
|
309
|
+
spatial: {
|
|
310
|
+
kind: "geometry",
|
|
311
|
+
geomKind: e,
|
|
312
|
+
srid: t
|
|
313
|
+
}
|
|
314
|
+
}), N = (e) => new i({
|
|
315
|
+
type: "raw",
|
|
316
|
+
nullable: !1,
|
|
317
|
+
unique: !1,
|
|
318
|
+
hasDefault: !1,
|
|
319
|
+
rawDdl: e
|
|
320
|
+
}), P = (e) => {
|
|
321
|
+
let t = {};
|
|
322
|
+
for (let [n, r] of Object.entries(e)) t[n] = r.__definition();
|
|
323
|
+
return t;
|
|
324
|
+
};
|
|
325
|
+
//#endregion
|
|
326
|
+
export { i as ColumnBuilder, C as SELF_REFERENCE_TARGET, k as array, f as bigint, m as boolean, v as bytes, b as crdtCounter, S as crdtDoc, r as crdtManagedColumns, t as crdtManagedColumnsOf, x as crdtSealed, y as crdtText, g as date, p as dbEnum, u as decimal, E as dropped, j as geography, M as geometry, o as id, c as integer, A as interval, _ as json, P as materializeFields, d as numeric, D as persistedColumns, N as raw, n as readableByColumns, l as real, T as reference, w as selfReference, e as serverOnlyColumns, s as text, h as timestamp, O as vector };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
//#region src/committedChanges.ts
|
|
2
|
+
var e = Symbol.for("voltro.database.committedChanges"), t = globalThis, n = t[e] ??= /* @__PURE__ */ new WeakMap(), r = (e, t) => {
|
|
3
|
+
let r = {};
|
|
4
|
+
for (let t of e) n.set(t, r);
|
|
5
|
+
try {
|
|
6
|
+
for (let n of e) t(n);
|
|
7
|
+
} finally {
|
|
8
|
+
for (let t of e) n.delete(t);
|
|
9
|
+
}
|
|
10
|
+
}, i = (e) => n.get(e);
|
|
11
|
+
//#endregion
|
|
12
|
+
export { i as committedChangeBatchOf, r as emitCommittedChanges };
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { createHash as e } from "node:crypto";
|
|
2
|
+
//#region src/connectionIdentity.ts
|
|
3
|
+
var t = {
|
|
4
|
+
postgres: 5432,
|
|
5
|
+
mysql: 3306,
|
|
6
|
+
mariadb: 3306,
|
|
7
|
+
mssql: 1433
|
|
8
|
+
}, n = /* @__PURE__ */ new Set([
|
|
9
|
+
"localhost",
|
|
10
|
+
"127.0.0.1",
|
|
11
|
+
"::1",
|
|
12
|
+
"[::1]",
|
|
13
|
+
"0.0.0.0"
|
|
14
|
+
]), r = (e) => {
|
|
15
|
+
let r = e.host, i = e.port, a = e.database;
|
|
16
|
+
if (e.url !== void 0 && e.url !== "") try {
|
|
17
|
+
let t = new URL(e.url);
|
|
18
|
+
r ??= decodeURIComponent(t.hostname), i === void 0 && t.port !== "" && (i = Number(t.port)), a ??= decodeURIComponent(t.pathname.replace(/^\//, ""));
|
|
19
|
+
} catch {
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
if (r === void 0 || r === "" || a === void 0 || a === "") return;
|
|
23
|
+
let o = i ?? t[(e.dialect ?? "").toLowerCase()];
|
|
24
|
+
if (o === void 0 || !Number.isFinite(o)) return;
|
|
25
|
+
let s = r.toLowerCase();
|
|
26
|
+
return {
|
|
27
|
+
host: n.has(s) ? "localhost" : s,
|
|
28
|
+
port: o,
|
|
29
|
+
database: a.toLowerCase()
|
|
30
|
+
};
|
|
31
|
+
}, i = (t) => {
|
|
32
|
+
let n = r(t);
|
|
33
|
+
if (n !== void 0) return e("sha256").update(`${n.host}\u0000${n.port}\u0000${n.database}`).digest("hex").slice(0, 32);
|
|
34
|
+
}, a = (e, t) => e === void 0 || t === void 0 ? "unknown" : e === t ? "same" : "different";
|
|
35
|
+
//#endregion
|
|
36
|
+
export { i as connectionIdentity, r as normaliseTarget, a as sameDatabase };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { id as e, text as t, timestamp as n } from "./columns.js";
|
|
2
|
+
import { table as r } from "./table.js";
|
|
3
|
+
//#region src/coreTables.ts
|
|
4
|
+
var i = r("actors", {
|
|
5
|
+
id: e(),
|
|
6
|
+
kind: t().oneOf([
|
|
7
|
+
"user",
|
|
8
|
+
"serviceAccount",
|
|
9
|
+
"apiKey",
|
|
10
|
+
"system"
|
|
11
|
+
]).safe(),
|
|
12
|
+
displayName: t().nullable().sensitive("fullName"),
|
|
13
|
+
createdAt: n().default("now")
|
|
14
|
+
});
|
|
15
|
+
//#endregion
|
|
16
|
+
export { i as actorsTable };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
//#region src/coreTablesRegistry.ts
|
|
2
|
+
var e = Symbol.for("@voltro/database/coreTablesRegistry"), t = globalThis, n = t[e] ?? (t[e] = {}), r = (e) => {
|
|
3
|
+
e.actors !== void 0 && (n.actors = e.actors), e.tenants !== void 0 && (n.tenants = e.tenants);
|
|
4
|
+
}, i = (e, t) => () => {
|
|
5
|
+
let n = e();
|
|
6
|
+
if (n === void 0) throw Error(`core '${t}' table not registered; expected the framework CLI or your migrate step to call registerCoreTables({ ${t}: () => ${t}Table }) before the database handle is constructed`);
|
|
7
|
+
return n();
|
|
8
|
+
}, a = () => i(() => n.actors, "actors"), o = () => i(() => n.tenants, "tenants");
|
|
9
|
+
//#endregion
|
|
10
|
+
export { r as registerCoreTables, a as requireActors, o as requireTenants };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { boolean as e, id as t, integer as n, text as r, timestamp as i } from "./columns.js";
|
|
2
|
+
import { table as a } from "./table.js";
|
|
3
|
+
//#region src/dataTransfers.ts
|
|
4
|
+
var o = "_voltro_data_transfers", s = a(o, {
|
|
5
|
+
id: t({ prefix: "dimp" }),
|
|
6
|
+
startedAt: i().default("now"),
|
|
7
|
+
finishedAt: i().nullable(),
|
|
8
|
+
direction: r().default("import"),
|
|
9
|
+
mode: r(),
|
|
10
|
+
via: r(),
|
|
11
|
+
bundle: r().nullable(),
|
|
12
|
+
sourceFingerprint: r().nullable(),
|
|
13
|
+
tablesWritten: n().default(0),
|
|
14
|
+
rowsWritten: n().default(0),
|
|
15
|
+
failure: r().nullable(),
|
|
16
|
+
staged: e().nullable()
|
|
17
|
+
}).renamedFrom("_voltro_data_imports").nonReactive(), c = (e) => {
|
|
18
|
+
let t = Number.isFinite(e.startedAt.getTime()) ? e.startedAt.toISOString() : "an unknown time", n = e.direction === "import" ? e.mode : `${e.direction} ${e.mode}`, r = e.failure === null ? e.finishedAt === null ? `${n} — started and never reported finishing` : e.direction === "backup" || e.direction === "restore" ? `${n} — finished${e.rowsWritten > 0 ? ` (${e.rowsWritten} blob(s))` : ""}` : `${n} — ${e.rowsWritten} row(s) across ${e.tablesWritten} table(s)` : `FAILED ${n} — ${e.failure}`, i = e.staged === null ? "" : e.staged ? " · staged (target untouched until the swap)" : " · NOT staged (target emptied first)";
|
|
19
|
+
return `${t} · ${r} · via ${e.via}${i}` + (e.bundle === null ? "" : ` · from ${e.bundle}`) + (e.sourceFingerprint === null ? "" : ` · source schema ${e.sourceFingerprint}`);
|
|
20
|
+
};
|
|
21
|
+
//#endregion
|
|
22
|
+
export { o as DATA_TRANSFERS_TABLE, s as _voltroDataTransfersTable, c as describeTransferRun };
|
package/dist/dbCause.js
ADDED
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
import { Cause as e, Exit as t } from "effect";
|
|
2
|
+
//#region src/dbCause.ts
|
|
3
|
+
var n = (n) => e.isCause(n) ? n : t.isExit(n) && t.isFailure(n) ? n.cause : typeof n == "object" && n && e.isCause(n.voltroCause) ? n.voltroCause : void 0, r = (t) => {
|
|
4
|
+
let r = n(t);
|
|
5
|
+
return r === void 0 ? t : e.squash(r);
|
|
6
|
+
}, i = (t, r = 0) => {
|
|
7
|
+
let a = r >= 4 ? void 0 : n(t);
|
|
8
|
+
if (a === void 0) return [t];
|
|
9
|
+
let o = a.reasons.flatMap((t) => e.isFailReason(t) ? [t.error] : e.isDieReason(t) ? [t.defect] : []);
|
|
10
|
+
if (o.length === 0) return [e.squash(a)];
|
|
11
|
+
let s = [];
|
|
12
|
+
for (let e of o.slice(0, 8)) s.push(...i(e, r + 1));
|
|
13
|
+
return s;
|
|
14
|
+
}, a = (e) => e.dbCode !== void 0 || e.dbErrno !== void 0 || e.dbNumber !== void 0 || e.dbSqlState !== void 0 || e.dbConstraint !== void 0, o = {
|
|
15
|
+
9: "SQLITE_INTERRUPT",
|
|
16
|
+
275: "SQLITE_CONSTRAINT_CHECK",
|
|
17
|
+
787: "SQLITE_CONSTRAINT_FOREIGNKEY",
|
|
18
|
+
1299: "SQLITE_CONSTRAINT_NOTNULL",
|
|
19
|
+
1555: "SQLITE_CONSTRAINT_PRIMARYKEY",
|
|
20
|
+
2067: "SQLITE_CONSTRAINT_UNIQUE"
|
|
21
|
+
}, s = (e) => {
|
|
22
|
+
let t = {}, n = [], i = r(e);
|
|
23
|
+
for (let e = 0; e < 8 && typeof i == "object" && i; e++) {
|
|
24
|
+
let e = i;
|
|
25
|
+
t.dbCode === void 0 && (typeof e.code == "string" || typeof e.code == "number") && (t.dbCode = e.code), t.dbErrno === void 0 && typeof e.errno == "number" && (t.dbErrno = e.errno), t.dbErrno === void 0 && typeof e.errcode == "number" && (t.dbErrno = e.errcode), t.dbCode === "ERR_SQLITE_ERROR" && typeof t.dbErrno == "number" && (t.dbCode = o[t.dbErrno] ?? t.dbCode), t.dbNumber === void 0 && typeof e.number == "number" && (t.dbNumber = e.number), t.dbSqlState === void 0 && typeof e.sqlState == "string" && (t.dbSqlState = e.sqlState), t.dbBindings === void 0 && typeof e.voltroBindings == "string" && (t.dbBindings = e.voltroBindings), t.dbStatement === void 0 && typeof e.sql == "string" && e.sql.includes("?") && (t.dbStatement = e.sql, t.dbPlaceholders = (e.sql.match(/\?/g) ?? []).length), t.dbFatal === void 0 && typeof e.fatal == "boolean" && (t.dbFatal = e.fatal), t.dbConstraint === void 0 && typeof e.constraint == "string" && (t.dbConstraint = e.constraint), t.dbTable === void 0 && typeof e.table == "string" && (t.dbTable = e.table), t.dbColumn === void 0 && typeof e.column == "string" && (t.dbColumn = e.column), t.dbSchema === void 0 && typeof e.schema == "string" && (t.dbSchema = e.schema);
|
|
26
|
+
let a = e.sqlMessage ?? e.detail;
|
|
27
|
+
t.dbMessage === void 0 && typeof a == "string" && (t.dbMessage = a);
|
|
28
|
+
let s = typeof e.constructor == "function" ? e.constructor.name : void 0, c = typeof e._tag == "string" && e._tag || typeof e.name == "string" && e.name || (typeof s == "string" && s !== "Object" ? s : void 0), l = typeof e.message == "string" ? e.message : void 0;
|
|
29
|
+
(c || l) && n.push(`${c || "Error"}${l ? `: ${l.slice(0, 200)}` : ""}`), i = r(e.reason ?? e.cause);
|
|
30
|
+
}
|
|
31
|
+
return n.length > 0 && (t.dbCauseChain = n.join(" ← "), t.dbMessage === void 0 && (t.dbMessage = n[n.length - 1])), t;
|
|
32
|
+
}, c = (e) => {
|
|
33
|
+
let t = i(e).map(s);
|
|
34
|
+
if (t.length <= 1) return t[0] ?? {};
|
|
35
|
+
let n = t.find(a) ?? t[0], r = t.filter((e) => e !== n).map((e) => e.dbCauseChain).filter((e) => typeof e == "string");
|
|
36
|
+
if (r.length === 0) return n;
|
|
37
|
+
let o = typeof n.dbCauseChain == "string" ? n.dbCauseChain : void 0;
|
|
38
|
+
return {
|
|
39
|
+
...n,
|
|
40
|
+
dbCauseChain: [o, ...r].filter(Boolean).join(" ‖ ")
|
|
41
|
+
};
|
|
42
|
+
}, l = (e, t) => {
|
|
43
|
+
let n = f(e);
|
|
44
|
+
if (n !== void 0) return n;
|
|
45
|
+
let r = c(e), i = b(r, t);
|
|
46
|
+
if (i !== void 0) {
|
|
47
|
+
let e = i.constraint ?? i.column;
|
|
48
|
+
return e === void 0 ? i.kind : `${i.kind}: ${e}`;
|
|
49
|
+
}
|
|
50
|
+
let a = r.dbCode ?? r.dbSqlState ?? r.dbErrno ?? r.dbNumber, o = h(e);
|
|
51
|
+
return a !== void 0 && p.test(String(a)) ? `${o} (${String(a)})` : o;
|
|
52
|
+
}, u = Symbol.for("@voltro/database/authoredMessage"), d = (e, t) => {
|
|
53
|
+
let n = t === void 0 ? Error(e) : Error(e, t);
|
|
54
|
+
return Object.defineProperty(n, u, {
|
|
55
|
+
value: !0,
|
|
56
|
+
enumerable: !1
|
|
57
|
+
}), n;
|
|
58
|
+
}, f = (e) => {
|
|
59
|
+
for (let t of i(e)) {
|
|
60
|
+
let e = t;
|
|
61
|
+
for (let t = 0; typeof e == "object" && e && t < 8; t += 1) {
|
|
62
|
+
if (e[u] === !0) {
|
|
63
|
+
let t = e.message;
|
|
64
|
+
if (typeof t == "string" && t.length > 0) return t;
|
|
65
|
+
}
|
|
66
|
+
e = e.cause;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}, p = /^[A-Za-z0-9_]{1,32}$/, m = /^[A-Za-z_][A-Za-z0-9_]{0,63}$/, h = (e) => {
|
|
70
|
+
let t = e?._tag, n = e?.name, r = (typeof t == "string" ? t : typeof n == "string" ? n : "").split(/[^A-Za-z0-9_]+/).filter(Boolean).pop();
|
|
71
|
+
return r !== void 0 && m.test(r) ? r : "unknown";
|
|
72
|
+
}, g = /^[A-Za-z_][A-Za-z0-9_$]*$/, _ = (e) => e !== void 0 && e.length <= 128 && g.test(e) ? e : void 0, v = (e) => e === void 0 ? void 0 : e.split(".").pop() ?? e, y = (e, ...t) => {
|
|
73
|
+
for (let n of t) {
|
|
74
|
+
let t = n.exec(e);
|
|
75
|
+
if (t?.[1] !== void 0) return t[1];
|
|
76
|
+
}
|
|
77
|
+
}, b = (e, t) => {
|
|
78
|
+
let n = e.dbCode, r = e.dbErrno, i = e.dbNumber, a = typeof e.dbMessage == "string" ? e.dbMessage : "", o = `${typeof e.dbCauseChain == "string" ? e.dbCauseChain : ""} ${a}`;
|
|
79
|
+
if (n === "23503") {
|
|
80
|
+
let t = _(e.dbConstraint);
|
|
81
|
+
return {
|
|
82
|
+
kind: /is still referenced from table/i.test(o) ? "foreignKeyInUse" : "foreignKey",
|
|
83
|
+
...t === void 0 ? {} : { constraint: t }
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
if (n === "23505") {
|
|
87
|
+
let t = _(e.dbConstraint);
|
|
88
|
+
return {
|
|
89
|
+
kind: "unique",
|
|
90
|
+
...t === void 0 ? {} : { constraint: t }
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
if (n === "23502") {
|
|
94
|
+
let t = _(e.dbColumn);
|
|
95
|
+
return {
|
|
96
|
+
kind: "notNull",
|
|
97
|
+
...t === void 0 ? {} : { column: t }
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
if (n === "23514") {
|
|
101
|
+
let t = _(e.dbConstraint);
|
|
102
|
+
return {
|
|
103
|
+
kind: "check",
|
|
104
|
+
...t === void 0 ? {} : { constraint: t }
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
if (r === 1452 || r === 1451) {
|
|
108
|
+
let e = _(y(o, /CONSTRAINT `([^`]+)`/));
|
|
109
|
+
return {
|
|
110
|
+
kind: r === 1451 ? "foreignKeyInUse" : "foreignKey",
|
|
111
|
+
...e === void 0 ? {} : { constraint: e }
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
if (r === 1062) {
|
|
115
|
+
let e = _(v(y(o, /for key '([^']+)'/)));
|
|
116
|
+
return {
|
|
117
|
+
kind: "unique",
|
|
118
|
+
...e === void 0 ? {} : { constraint: e }
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
if (r === 1048 || r === 1364) {
|
|
122
|
+
let e = _(y(o, /Column '([^']+)' cannot be null/, /Field '([^']+)' doesn't have a default value/));
|
|
123
|
+
return {
|
|
124
|
+
kind: "notNull",
|
|
125
|
+
...e === void 0 ? {} : { column: e }
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
if (r === 3819 || r === 4025) {
|
|
129
|
+
let e = _(y(o, /Check constraint '([^']+)'/, /CONSTRAINT `([^`]+)` failed/));
|
|
130
|
+
return {
|
|
131
|
+
kind: "check",
|
|
132
|
+
...e === void 0 ? {} : { constraint: e }
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
if (i === 547) {
|
|
136
|
+
let e = y(o, /(?:FOREIGN KEY|REFERENCE) constraint "([^"]+)"/), t = y(o, /CHECK constraint "([^"]+)"/);
|
|
137
|
+
if (t !== void 0 && e === void 0) {
|
|
138
|
+
let e = _(t);
|
|
139
|
+
return {
|
|
140
|
+
kind: "check",
|
|
141
|
+
...e === void 0 ? {} : { constraint: e }
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
let n = /REFERENCE constraint/.test(o), r = _(e);
|
|
145
|
+
return {
|
|
146
|
+
kind: n ? "foreignKeyInUse" : "foreignKey",
|
|
147
|
+
...r === void 0 ? {} : { constraint: r }
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
if (i === 2627 || i === 2601) {
|
|
151
|
+
let e = _(y(o, /(?:UNIQUE KEY|PRIMARY KEY) constraint '([^']+)'/, /index '([^']+)'/));
|
|
152
|
+
return {
|
|
153
|
+
kind: "unique",
|
|
154
|
+
...e === void 0 ? {} : { constraint: e }
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
if (i === 515) {
|
|
158
|
+
let e = _(y(o, /Cannot insert the value NULL into column '([^']+)'/));
|
|
159
|
+
return {
|
|
160
|
+
kind: "notNull",
|
|
161
|
+
...e === void 0 ? {} : { column: e }
|
|
162
|
+
};
|
|
163
|
+
}
|
|
164
|
+
if (n === "SQLITE_CONSTRAINT_FOREIGNKEY") return { kind: t === "delete" || t === "deleteMany" || t === "hardDelete" ? "foreignKeyInUse" : "foreignKey" };
|
|
165
|
+
if (n === "SQLITE_CONSTRAINT_UNIQUE" || n === "SQLITE_CONSTRAINT_PRIMARYKEY") {
|
|
166
|
+
let e = _(v(y(o, /UNIQUE constraint failed: ([^,\s]+)/)));
|
|
167
|
+
return {
|
|
168
|
+
kind: "unique",
|
|
169
|
+
...e === void 0 ? {} : { column: e }
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
if (n === "SQLITE_CONSTRAINT_NOTNULL") {
|
|
173
|
+
let e = _(v(y(o, /NOT NULL constraint failed: ([^,\s]+)/)));
|
|
174
|
+
return {
|
|
175
|
+
kind: "notNull",
|
|
176
|
+
...e === void 0 ? {} : { column: e }
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
if (n === "SQLITE_CONSTRAINT_CHECK") {
|
|
180
|
+
let e = _(y(a, /CHECK constraint failed: (.+)$/));
|
|
181
|
+
return {
|
|
182
|
+
kind: "check",
|
|
183
|
+
...e === void 0 ? {} : { constraint: e }
|
|
184
|
+
};
|
|
185
|
+
}
|
|
186
|
+
}, x = (e) => {
|
|
187
|
+
let t = b(e)?.kind;
|
|
188
|
+
return t === "foreignKey" || t === "foreignKeyInUse";
|
|
189
|
+
}, S = (e) => {
|
|
190
|
+
let t = e.dbCode, n = e.dbErrno;
|
|
191
|
+
return t === "57014" || n === 3024 || n === 1969 || t === "ETIMEOUT" || t === "SQLITE_INTERRUPT";
|
|
192
|
+
}, C = (e) => {
|
|
193
|
+
if (e.dbErrno !== 1366) return;
|
|
194
|
+
let t = `${typeof e.dbCauseChain == "string" ? e.dbCauseChain : ""} ${typeof e.dbMessage == "string" ? e.dbMessage : ""}`;
|
|
195
|
+
if (/Incorrect string value: '\\x(F[0-4])/i.exec(t) === null) return;
|
|
196
|
+
let n = y(t, /for column [`']?(?:[^`'.]+[`']?\.[`']?)*([^`'.]+)[`']? at row/);
|
|
197
|
+
return `${n === void 0 ? "the column" : `column '${n}'`} is stored in a character set that cannot hold a 4-byte character (utf8mb3). Declare the store's character set in app.config.ts — store: { dialect: 'mariadb' | 'mysql', charset: 'utf8mb4' } — and run \`voltro db plan\`: every declared table is created with it and converted to it.`;
|
|
198
|
+
}, w = (e) => {
|
|
199
|
+
let t = c(e), n = [
|
|
200
|
+
t.dbCode === void 0 ? void 0 : `code=${String(t.dbCode)}`,
|
|
201
|
+
t.dbErrno === void 0 ? void 0 : `errno=${String(t.dbErrno)}`,
|
|
202
|
+
t.dbNumber === void 0 ? void 0 : `number=${String(t.dbNumber)}`,
|
|
203
|
+
t.dbSqlState === void 0 ? void 0 : `sqlState=${String(t.dbSqlState)}`,
|
|
204
|
+
t.dbConstraint === void 0 ? void 0 : `constraint=${String(t.dbConstraint)}`,
|
|
205
|
+
t.dbPlaceholders === void 0 ? void 0 : `placeholders=${String(t.dbPlaceholders)}`
|
|
206
|
+
].filter((e) => e !== void 0), r = typeof e?.message == "string" ? e.message : void 0, i = typeof t.dbMessage == "string" ? t.dbMessage : void 0, a = i === void 0 ? void 0 : n.length > 0 || i !== r && i !== `Error: ${String(r)}` ? i : void 0, o = typeof t.dbBindings == "string" ? `\n bindings: ${t.dbBindings}` : "", s = typeof t.dbStatement == "string" ? `\n statement: ${t.dbStatement.length <= 400 ? t.dbStatement : `${t.dbStatement.slice(0, 400)}…`}` : "";
|
|
207
|
+
if (a === void 0 && n.length === 0) return;
|
|
208
|
+
let l = C(t), u = l === void 0 ? "" : `\n hint: ${l}`;
|
|
209
|
+
return [a, n.length > 0 ? `[${n.join(" ")}]` : void 0].filter((e) => e !== void 0 && e !== "").join(" ") + u + s + o;
|
|
210
|
+
}, T = (e) => Object.entries(e).map(([e, t]) => `${e}:${E(t)}`).join(" "), E = (e) => {
|
|
211
|
+
if (e === null) return "null";
|
|
212
|
+
if (e === void 0) return "undefined";
|
|
213
|
+
if (typeof e == "bigint") return "bigint";
|
|
214
|
+
if (typeof e != "object") return typeof e;
|
|
215
|
+
if (e instanceof Date) return Number.isNaN(e.getTime()) ? "Date(Invalid)" : "Date";
|
|
216
|
+
if (Array.isArray(e)) return "Array";
|
|
217
|
+
if (globalThis.Buffer !== void 0 && globalThis.Buffer.isBuffer(e)) return "Buffer";
|
|
218
|
+
let t = e.constructor?.name;
|
|
219
|
+
return typeof t == "string" && t !== "" ? t : "Object";
|
|
220
|
+
};
|
|
221
|
+
//#endregion
|
|
222
|
+
export { d as authoredError, f as authoredMessageOf, i as causeBranches, b as classifyConstraintViolation, C as describeCharsetRefusal, w as describeDriverError, T as describeRowBindings, c as extractDbCause, x as isForeignKeyViolation, S as isQueryTimeout, l as wireSafeCause };
|