@voltro/database 0.86.0 → 0.88.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 +5484 -0
- package/THIRD-PARTY-NOTICES.md +2 -226
- package/dist/actorSnapshot.js +1 -2
- package/dist/arrayCodec.js +1 -2
- package/dist/branchExecute.js +1 -2
- package/dist/branching.js +1 -2
- package/dist/bulkInsertLimits.js +16 -12
- package/dist/cdcOffsetsTables.js +1 -2
- package/dist/changeEvent.js +1 -2
- package/dist/changeIdentity.js +1 -2
- package/dist/changeListenerCeiling.js +1 -2
- package/dist/columnReference.js +1 -2
- package/dist/columns.js +1 -2
- package/dist/committedChanges.js +1 -2
- package/dist/connectionIdentity.js +1 -2
- package/dist/coreTables.js +1 -2
- package/dist/coreTablesRegistry.js +1 -2
- package/dist/dataTransfers.js +3 -3
- package/dist/dbCause.js +1 -2
- package/dist/dbMetrics.js +1 -2
- package/dist/decimalComparison.js +1 -2
- package/dist/derivedRowId.js +1 -2
- package/dist/dialect.js +1 -2
- package/dist/enumRenames.js +1 -2
- package/dist/expiresMixin.js +1 -2
- package/dist/fieldEncryption.js +65 -43
- package/dist/frameworkTables.js +16 -4
- package/dist/ginIndex.js +1 -2
- package/dist/hybridSearch.js +1 -2
- package/dist/idGenerator.js +5 -6
- package/dist/identifierLimits.js +1 -2
- package/dist/index.d.ts +153 -22
- package/dist/index.js +78 -78
- package/dist/indexAudit.js +45 -44
- package/dist/indexStorage.js +1 -2
- package/dist/joinCompiler.js +1 -2
- package/dist/jsonEagerCompiler.js +1 -2
- package/dist/jsonPatch.js +1 -2
- package/dist/jsonPatchAssignments.js +1 -2
- package/dist/jsonPath.js +1 -2
- package/dist/localFirstMixin.js +1 -2
- package/dist/migrate.js +52 -33
- package/dist/migration.js +1 -2
- package/dist/migrations/appliedAtValue.js +1 -2
- package/dist/migrations/applier.js +400 -386
- package/dist/migrations/boot.js +2 -3
- package/dist/migrations/branchRehearsal.js +1 -2
- package/dist/migrations/columnEquivalence.js +1 -2
- package/dist/migrations/ddlError.js +1 -2
- package/dist/migrations/ddlStatements.js +8 -0
- package/dist/migrations/declaredSchema.js +2 -3
- package/dist/migrations/deployLedger.js +1 -2
- package/dist/migrations/fileBased.js +1 -2
- package/dist/migrations/fileContext.js +1 -2
- package/dist/migrations/fileDiscovery.js +146 -133
- package/dist/migrations/fileSkipProbes.js +1 -2
- package/dist/migrations/fingerprint.js +1 -2
- package/dist/migrations/fkCycles.js +1 -2
- package/dist/migrations/frameworkLiveTables.js +1 -2
- package/dist/migrations/idempotentDdl.js +1 -2
- package/dist/migrations/indexPredicate.js +1 -2
- package/dist/migrations/introspect.js +188 -187
- package/dist/migrations/ledgerRows.js +1 -2
- package/dist/migrations/lock.js +1 -2
- package/dist/migrations/migrationTableExists.js +1 -2
- package/dist/migrations/mssqlColumnDependencies.js +1 -2
- package/dist/migrations/mysqlEngine.js +1 -2
- package/dist/migrations/namespaceCharset.js +1 -2
- package/dist/migrations/planner.js +25 -16
- package/dist/migrations/postgresEnumCheck.js +5 -3
- package/dist/migrations/reactiveTriggerDrift.js +1 -2
- package/dist/migrations/reactiveTriggerName.js +1 -2
- package/dist/migrations/renameMssqlCheck.js +1 -2
- package/dist/migrations/restoreSnapshots.js +1 -2
- package/dist/migrations/resumeLedger.js +1 -2
- package/dist/migrations/rollingDeploy.js +1 -2
- package/dist/migrations/schemaOwner.js +1 -2
- package/dist/migrations/schemaOwnerTable.js +1 -2
- package/dist/migrations/softDropSnapshot.js +1 -2
- package/dist/migrations/sqlLimit.js +1 -2
- package/dist/migrations/sqliteCatalogName.js +12 -0
- package/dist/migrations/sqliteConstraintIdentity.js +1 -2
- package/dist/migrations/sqliteDecimalBoot.js +1 -2
- package/dist/migrations/sqliteDecimalPublication.js +1 -2
- package/dist/migrations/sqliteDecimalReview.js +1 -2
- package/dist/migrations/sqliteDecimalReviewStore.js +1 -2
- package/dist/migrations/sqliteDecimalReviewWitness.js +1 -2
- package/dist/migrations/sqliteDecimalSource.js +1 -2
- package/dist/migrations/sqliteDecimalStage.js +1 -2
- package/dist/migrations/sqliteForeignKeys.js +1 -2
- package/dist/migrations/sqliteMigrationBatch.js +1 -2
- package/dist/migrations/sqliteRetainedSource.js +1 -2
- package/dist/migrations/sqliteRowIdentity.js +1 -2
- package/dist/migrations/sqliteSchemaEpoch.js +1 -2
- package/dist/migrations/sqliteSnapshotGuard.js +1 -2
- package/dist/migrations/sqliteTableContents.js +1 -2
- package/dist/migrations/sqliteTableCopy.js +1 -2
- package/dist/migrations/sqliteTableSchema.js +1 -2
- package/dist/migrations/sqliteWitnessProtection.js +1 -2
- package/dist/migrations/squash.js +1 -2
- package/dist/migrations/storeCharset.js +1 -2
- package/dist/migrations/transactionCause.js +1 -2
- package/dist/migrations/undeclaredCharset.js +1 -2
- package/dist/migrations/uniqueActiveLowering.js +1 -2
- package/dist/mixins.js +1 -2
- package/dist/mssqlDecimalDistinct.js +1 -2
- package/dist/mssqlJsonValueCheck.js +1 -2
- package/dist/mssqlTextStorage.js +1 -2
- package/dist/namespace.js +1 -2
- package/dist/optimisticVersion.js +1 -2
- package/dist/pendingAttribution.js +1 -2
- package/dist/pluginRef.js +1 -2
- package/dist/predicate.js +28 -22
- package/dist/predicateCoercion.js +1 -2
- package/dist/projectedColumn.js +1 -2
- package/dist/queryBuilder.js +7 -2
- package/dist/rawSql.js +1 -2
- package/dist/relations.js +1 -2
- package/dist/relationsRegistry.js +1 -2
- package/dist/replaceInProgress.js +1 -2
- package/dist/requiredColumns.js +1 -2
- package/dist/residency.js +1 -2
- package/dist/retention.js +1 -2
- package/dist/rowDecoder.js +62 -13
- package/dist/rowKey.js +1 -2
- package/dist/rowSchema.js +1 -2
- package/dist/scopeKey.js +1 -2
- package/dist/seed.js +1 -2
- package/dist/snowflake.js +1 -2
- package/dist/sql.d.ts +2746 -3748
- package/dist/sql.js +15 -14
- package/dist/sqlCompiler.js +89 -73
- package/dist/sqlError.js +1 -2
- package/dist/sqlMutation.js +54 -0
- package/dist/sqlPoolCapacity.js +1 -2
- package/dist/sqliteDecimal.js +1 -2
- package/dist/sqliteDecimalAggregateSql.js +1 -2
- package/dist/sqliteDecimalColumnSql.js +1 -2
- package/dist/sqliteDecimalConversion.js +1 -2
- package/dist/sqliteDecimalCte.js +1 -2
- package/dist/sqliteDecimalEncodeSql.js +1 -2
- package/dist/sqliteDecimalOutputs.js +1 -2
- package/dist/sqliteDecimalPredicate.js +1 -2
- package/dist/sqliteDecimalQuery.js +1 -2
- package/dist/sqliteDecimalQueryPlan.js +1 -2
- package/dist/sqliteDecimalResultSql.js +1 -2
- package/dist/sqliteDecimalRowQuery.js +1 -2
- package/dist/sqliteDecimalSetQuery.js +1 -2
- package/dist/sqliteDecimalSource.js +1 -2
- package/dist/sqliteDecimalStorage.js +1 -2
- package/dist/sqliteDecimalSubquery.js +1 -2
- package/dist/sqliteDecimalWindowQuery.js +1 -2
- package/dist/sqliteValueCoercion.js +1 -2
- package/dist/stampId.js +1 -2
- package/dist/storeErrors.js +1 -2
- package/dist/storeRefusal.js +1 -2
- package/dist/stream.js +1 -2
- package/dist/subjectGraph.js +1 -2
- package/dist/table.js +1 -2
- package/dist/tableRegistry.js +1 -2
- package/dist/tenantSelection.js +1 -2
- package/dist/transactionOutcome.js +5 -3
- package/dist/transientContention.js +1 -2
- package/dist/typeId.js +50 -0
- package/dist/typedStore.js +2 -3
- package/dist/upsertUpdate.js +1 -2
- package/dist/vectorEmbedding.js +1 -2
- package/dist/view.js +1 -2
- package/dist/wire.js +1 -2
- package/dist/writeAttribution.js +1 -2
- package/dist/writeRecorder.js +22 -22
- package/package.json +3 -4
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { getTable as e } from "./tableRegistry.js";
|
|
2
2
|
import { isSqliteDecimalEncodedColumn as t } from "./sqliteDecimalStorage.js";
|
|
3
|
-
|
|
3
|
+
// src/sqliteDecimalQueryPlan.ts
|
|
4
4
|
var n = (e) => e.replace(/[A-Z]/g, (e) => e.toLowerCase()), r = (e) => {
|
|
5
5
|
if (Object.getPrototypeOf(e) !== Object.prototype) return !1;
|
|
6
6
|
for (let t of Object.values(Object.getOwnPropertyDescriptors(e))) {
|
|
@@ -33,5 +33,4 @@ var n = (e) => e.replace(/[A-Z]/g, (e) => e.toLowerCase()), r = (e) => {
|
|
|
33
33
|
};
|
|
34
34
|
return l(i, /* @__PURE__ */ new Set());
|
|
35
35
|
};
|
|
36
|
-
//#endregion
|
|
37
36
|
export { i as hasEncodedSqliteDecimalSource };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/sqliteDecimalResultSql.ts
|
|
2
2
|
var e = (e, t) => {
|
|
3
3
|
if (!Number.isSafeInteger(e) || e < 1 || !Number.isSafeInteger(t) || t < 0 || t > e) throw RangeError("Invalid decimal result shape");
|
|
4
4
|
}, t = (t, n) => {
|
|
@@ -40,5 +40,4 @@ var e = (e, t) => {
|
|
|
40
40
|
};
|
|
41
41
|
return `(${s(t)} ${i} ${s(r)})`;
|
|
42
42
|
};
|
|
43
|
-
//#endregion
|
|
44
43
|
export { n as compileSqliteDecimalResult, r as compileSqliteDecimalResultComparison, t as sqliteDecimalResultKey };
|
|
@@ -3,7 +3,7 @@ import { isSqliteDecimalEncodedColumn as t } from "./sqliteDecimalStorage.js";
|
|
|
3
3
|
import { prepareProjectedColumn as n } from "./projectedColumn.js";
|
|
4
4
|
import { compileSqliteDecimalDecodedRows as r } from "./sqliteDecimalColumnSql.js";
|
|
5
5
|
import { compileSqliteDecimalSource as i } from "./sqliteDecimalSource.js";
|
|
6
|
-
|
|
6
|
+
// src/sqliteDecimalRowQuery.ts
|
|
7
7
|
var a = (a, o, s, c, l) => {
|
|
8
8
|
if (a.groupBy?.length || a.having) throw Error("Row queries cannot contain aggregate clauses");
|
|
9
9
|
let u = n(a), d = a.sourceTable?.tableName === a.table ? a.sourceTable : e(a.table), f = a.joinedProjection ?? (a.projection?.length ? a.projection : Object.keys(d?.fields ?? {})).map((e) => ({
|
|
@@ -59,5 +59,4 @@ var a = (a, o, s, c, l) => {
|
|
|
59
59
|
}))}` : o``, A = a.take === void 0 ? a.skip === void 0 ? o`` : o` LIMIT -1` : o` LIMIT ${a.take}`, j = a.skip === void 0 ? o`` : o` OFFSET ${a.skip}`, M = C.length ? `WITH ${C.join(",")} ` : "", N = o`SELECT ${a.distinct ? o`DISTINCT ` : o``}${o.join(", ", !1)(O)} FROM ${o(T)}${k}${A}${j}`.compile();
|
|
60
60
|
return o.unsafe(M + N[0], [...b, ...N[1]]);
|
|
61
61
|
};
|
|
62
|
-
//#endregion
|
|
63
62
|
export { a as compileSqliteDecimalRowQuery };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { sqliteDecimalOutputs as e } from "./sqliteDecimalOutputs.js";
|
|
2
|
-
|
|
2
|
+
// src/sqliteDecimalSetQuery.ts
|
|
3
3
|
var t = (t, n, r, i) => {
|
|
4
4
|
let a = (e) => [
|
|
5
5
|
e.table,
|
|
@@ -46,5 +46,4 @@ var t = (t, n, r, i) => {
|
|
|
46
46
|
}, u = l(t);
|
|
47
47
|
return n`WITH ${n.join(", ", !1)(s)} ${u}`;
|
|
48
48
|
};
|
|
49
|
-
//#endregion
|
|
50
49
|
export { t as compileSqliteDecimalSetQuery };
|
|
@@ -5,7 +5,7 @@ import { compileSqliteDecimalSubquery as i } from "./sqliteDecimalSubquery.js";
|
|
|
5
5
|
import { compileSqliteDecimalColumnComparison as a, compileSqliteDecimalColumnValue as o } from "./sqliteDecimalColumnSql.js";
|
|
6
6
|
import { lowerSqliteDecimalPredicate as s } from "./sqliteDecimalPredicate.js";
|
|
7
7
|
import { compileStoragePredicate as c } from "./sqlCompiler.js";
|
|
8
|
-
|
|
8
|
+
// src/sqliteDecimalSource.ts
|
|
9
9
|
var l = (l, u, d, f) => {
|
|
10
10
|
let p = (f) => {
|
|
11
11
|
if ("not" in f) return u`NOT (${p(f.not)})`;
|
|
@@ -59,5 +59,4 @@ var l = (l, u, d, f) => {
|
|
|
59
59
|
where: e.predicate === void 0 ? t`` : t` WHERE ${r(e.predicate)}`
|
|
60
60
|
};
|
|
61
61
|
};
|
|
62
|
-
//#endregion
|
|
63
62
|
export { u as compileSqliteDecimalSource, l as compileSqliteDecimalSourcePredicate };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { encodeSqliteDecimal as e } from "./sqliteDecimal.js";
|
|
2
|
-
|
|
2
|
+
// src/sqliteDecimalStorage.ts
|
|
3
3
|
var t = (e) => e?.type === "decimal" && n(e) !== void 0, n = (t) => {
|
|
4
4
|
if (t.sqliteDecimalEncoding === void 0) return;
|
|
5
5
|
if (t.precision === void 0 || t.scale === void 0) throw Error("Encoded SQLite decimal metadata requires precision and scale");
|
|
@@ -25,5 +25,4 @@ var t = (e) => e?.type === "decimal" && n(e) !== void 0, n = (t) => {
|
|
|
25
25
|
if (typeof t != "string") throw TypeError("SQLite decimal defaults require exact strings");
|
|
26
26
|
return e(t, n);
|
|
27
27
|
};
|
|
28
|
-
//#endregion
|
|
29
28
|
export { o as encodeSqliteDecimalDefault, t as isSqliteDecimalEncodedColumn, i as parseSqliteDecimalStorageType, a as sqliteDecimalStorageCheck, n as sqliteDecimalStorageShape, r as sqliteDecimalStorageType };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { sqliteDecimalOutputs as e } from "./sqliteDecimalOutputs.js";
|
|
2
|
-
|
|
2
|
+
// src/sqliteDecimalSubquery.ts
|
|
3
3
|
var t = (t, n, r, i) => {
|
|
4
4
|
let a = r.compile(t.subquery);
|
|
5
5
|
if (t.op === "exists") return n`EXISTS (${a})`;
|
|
@@ -15,5 +15,4 @@ var t = (t, n, r, i) => {
|
|
|
15
15
|
}, d = u(s.value, s.scale ?? 0), f = n`SELECT ${u(n`${n(c.name)}`, c.decimal?.scale ?? 0)} FROM (${a})`;
|
|
16
16
|
return t.op === "subquery-in" ? n`${d} IN (${f})` : n`${d} NOT IN (${f})`;
|
|
17
17
|
};
|
|
18
|
-
//#endregion
|
|
19
18
|
export { t as compileSqliteDecimalSubquery };
|
|
@@ -5,7 +5,7 @@ import { compileSqliteDecimalDecodedRows as r } from "./sqliteDecimalColumnSql.j
|
|
|
5
5
|
import { compileSqliteDecimalResult as i } from "./sqliteDecimalResultSql.js";
|
|
6
6
|
import { compileSqliteDecimalSource as a } from "./sqliteDecimalSource.js";
|
|
7
7
|
import { compileSqliteDecimalAvg as o, compileSqliteDecimalSum as s } from "./sqliteDecimalAggregateSql.js";
|
|
8
|
-
|
|
8
|
+
// src/sqliteDecimalWindowQuery.ts
|
|
9
9
|
var c = (c, l, u, d, f, p) => {
|
|
10
10
|
let m = t(c), h = c.aggregations ?? [], g = {
|
|
11
11
|
"window-row-number": "ROW_NUMBER",
|
|
@@ -192,5 +192,4 @@ var c = (c, l, u, d, f, p) => {
|
|
|
192
192
|
let B = c.take === void 0 ? c.skip === void 0 ? "" : " LIMIT -1" : ` LIMIT ${c.take}`, V = c.skip === void 0 ? "" : ` OFFSET ${c.skip}`;
|
|
193
193
|
return l.unsafe(`${T ? "" : `WITH ${O.join(",")} `}SELECT ${c.distinct ? "DISTINCT " : ""}${R.join(",")} FROM ${L.source} AS window_output${z}${B}${V}`, w);
|
|
194
194
|
};
|
|
195
|
-
//#endregion
|
|
196
195
|
export { c as compileSqliteDecimalWindowQuery };
|
package/dist/stampId.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { generateId as e } from "./idGenerator.js";
|
|
2
2
|
import { getTable as t } from "./tableRegistry.js";
|
|
3
|
-
|
|
3
|
+
// src/stampId.ts
|
|
4
4
|
var n = "id", r = (r, i) => {
|
|
5
5
|
let a = t(r);
|
|
6
6
|
if (a === void 0) return i;
|
|
@@ -17,5 +17,4 @@ var n = "id", r = (r, i) => {
|
|
|
17
17
|
[n]: s
|
|
18
18
|
};
|
|
19
19
|
}, i = (e, t) => t.map((t) => r(e, t));
|
|
20
|
-
//#endregion
|
|
21
20
|
export { r as stampGeneratedId, i as stampGeneratedIds };
|
package/dist/storeErrors.js
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
// src/storeErrors.ts
|
|
2
2
|
var e = (e, t, n) => ({
|
|
3
3
|
_tag: "PrimaryKeyConflictError",
|
|
4
4
|
table: e,
|
|
5
5
|
key: t,
|
|
6
6
|
cause: n
|
|
7
7
|
}), t = (e) => typeof e == "object" && !!e && e._tag === "PrimaryKeyConflictError";
|
|
8
|
-
//#endregion
|
|
9
8
|
export { t as isPrimaryKeyConflictError, e as primaryKeyConflictError };
|
package/dist/storeRefusal.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { authoredError as e, causeBranches as t } from "./dbCause.js";
|
|
2
|
-
|
|
2
|
+
// src/storeRefusal.ts
|
|
3
3
|
var n = Symbol.for("@voltro/database/storeRefusal"), r = (t) => {
|
|
4
4
|
let r = e(t.detail);
|
|
5
5
|
return Object.defineProperty(r, n, {
|
|
@@ -16,5 +16,4 @@ var n = Symbol.for("@voltro/database/storeRefusal"), r = (t) => {
|
|
|
16
16
|
}
|
|
17
17
|
}
|
|
18
18
|
};
|
|
19
|
-
//#endregion
|
|
20
19
|
export { r as refuseWrite, i as storeRefusalOf };
|
package/dist/stream.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { and as e, gt as t } from "./predicate.js";
|
|
2
2
|
import { Data as n, Effect as r, Option as i, Stream as a } from "effect";
|
|
3
|
-
|
|
3
|
+
// src/stream.ts
|
|
4
4
|
var o = class extends n.TaggedError("TableStreamError") {}, s = 1e3, c = (n, r, a, o) => {
|
|
5
5
|
let s = i.match(o, {
|
|
6
6
|
onNone: () => n.where,
|
|
@@ -32,5 +32,4 @@ var o = class extends n.TaggedError("TableStreamError") {}, s = 1e3, c = (n, r,
|
|
|
32
32
|
return (t.retry ? s.pipe(r.retry(t.retry)) : s).pipe(r.map((e) => [e, e.length === l && e.length > 0 ? i.some(i.some(e[e.length - 1][n])) : i.none()]));
|
|
33
33
|
});
|
|
34
34
|
};
|
|
35
|
-
//#endregion
|
|
36
35
|
export { o as TableStreamError, l as streamTable };
|
package/dist/subjectGraph.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { allRegisteredTables as e } from "./tableRegistry.js";
|
|
2
2
|
import { allRegisteredRelations as t } from "./relationsRegistry.js";
|
|
3
3
|
import { types as n } from "node:util";
|
|
4
|
-
|
|
4
|
+
// src/subjectGraph.ts
|
|
5
5
|
var r = 4, i = (e) => Object.keys(e.fields), a = (e, t) => Object.prototype.hasOwnProperty.call(e.fields, t), o = (e, t) => {
|
|
6
6
|
let n = [];
|
|
7
7
|
for (let [r, i] of Object.entries(e.fields)) i.type === "reference" && i.references?.()?.tableName === t && n.push(r);
|
|
@@ -171,5 +171,4 @@ var r = 4, i = (e) => Object.keys(e.fields), a = (e, t) => Object.prototype.hasO
|
|
|
171
171
|
let n = e.limitations.filter((e) => e.kind === "depth-truncated"), r = e.limitations.filter((e) => e.kind === "unreachable"), i = e.limitations.filter((e) => e.kind === "excluded");
|
|
172
172
|
return t.push(""), t.push(" WHAT THIS CANNOT SEE — a DSAR is only as complete as this list is short:"), n.length > 0 && t.push(` depth-truncated (${n.length}): ${n.map((e) => e.table).join(", ")}`), i.length > 0 && t.push(` excluded (${i.length}): ${[...new Set(i.map((e) => e.table))].join(", ")}`), t.push(r.length === 0 ? " unreachable: none — every registered table is linked to the subject." : ` unreachable (${r.length}): ${r.map((e) => e.table).join(", ")}`), t.push(" Always outside this graph: object storage / uploaded files, external processors,"), t.push(" log and metric sinks, backups, and any subject id embedded in JSON or free text."), t.join("\n");
|
|
173
173
|
};
|
|
174
|
-
//#endregion
|
|
175
174
|
export { r as DEFAULT_SUBJECT_GRAPH_DEPTH, m as deriveSubjectGraph, h as formatSubjectGraph };
|
package/dist/table.js
CHANGED
|
@@ -5,7 +5,7 @@ import { resolveIdScheme as o } from "./idGenerator.js";
|
|
|
5
5
|
import { resolveMixinGraph as s } from "./mixins.js";
|
|
6
6
|
import { resolveGinOpclass as c } from "./ginIndex.js";
|
|
7
7
|
import { Schema as l, Struct as u } from "effect";
|
|
8
|
-
|
|
8
|
+
// src/table.ts
|
|
9
9
|
var d = (e, ...t) => {
|
|
10
10
|
if (t.length === 0) throw Error(`jsonIndex("${e}"): at least one path segment is required`);
|
|
11
11
|
let n = (r) => ({
|
|
@@ -390,5 +390,4 @@ var d = (e, ...t) => {
|
|
|
390
390
|
appliedRules: []
|
|
391
391
|
}), s;
|
|
392
392
|
};
|
|
393
|
-
//#endregion
|
|
394
393
|
export { p as AUTO_FILLED_COLUMNS, d as jsonIndex, x as table, f as vectorDistanceToOpclass };
|
package/dist/tableRegistry.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/tableRegistry.ts
|
|
2
2
|
var e = Symbol.for("@voltro/database/tableRegistry"), t = globalThis, n = t[e] ?? (t[e] = /* @__PURE__ */ new Map()), r = (e) => {
|
|
3
3
|
let t = n.get(e.tableName);
|
|
4
4
|
if (t === void 0) n.set(e.tableName, e);
|
|
@@ -12,5 +12,4 @@ var e = Symbol.for("@voltro/database/tableRegistry"), t = globalThis, n = t[e] ?
|
|
|
12
12
|
}, s = () => [...n.values()], c = (e) => n.delete(e), l = () => {
|
|
13
13
|
n.clear();
|
|
14
14
|
}, u = (e) => n.get(e)?.isReactive !== !1;
|
|
15
|
-
//#endregion
|
|
16
15
|
export { s as allRegisteredTables, l as clearTableRegistry, i as ensureTableRegistered, a as getTable, u as isTableReactive, r as registerTable, o as requireTable, c as unregisterTable };
|
package/dist/tenantSelection.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { eq as e } from "./predicate.js";
|
|
2
2
|
import { _voltroTenantSelectionsTable as t } from "./frameworkTables.js";
|
|
3
3
|
import { createHash as n } from "node:crypto";
|
|
4
|
-
|
|
4
|
+
// src/tenantSelection.ts
|
|
5
5
|
var r = t.tableName, i = (e) => n("sha256").update(`${e.type}\u0000${e.id}`, "utf8").digest("hex"), a = async (t, n) => {
|
|
6
6
|
let [a] = await t.query({
|
|
7
7
|
table: r,
|
|
@@ -23,5 +23,4 @@ var r = t.tableName, i = (e) => n("sha256").update(`${e.type}\u0000${e.id}`, "ut
|
|
|
23
23
|
}, s = async (e, t) => {
|
|
24
24
|
await e.delete(r, i(t));
|
|
25
25
|
};
|
|
26
|
-
//#endregion
|
|
27
26
|
export { r as TENANT_SELECTIONS_TABLE, s as deleteTenantSelection, a as readTenantSelection, i as tenantSelectionId, o as writeTenantSelection };
|
|
@@ -3,7 +3,7 @@ import { currentWriteAttribution as t, runWithWriteAttribution as n } from "./wr
|
|
|
3
3
|
import { observeDbOp as r } from "./dbMetrics.js";
|
|
4
4
|
import { Cause as i, Effect as a, Exit as o, Option as s, Schedule as c } from "effect";
|
|
5
5
|
import { SqlClient as l } from "effect/sql";
|
|
6
|
-
|
|
6
|
+
// src/transactionOutcome.ts
|
|
7
7
|
var u = (e) => {
|
|
8
8
|
if (o.isSuccess(e)) return e.value;
|
|
9
9
|
let t = i.squash(e.cause);
|
|
@@ -25,7 +25,10 @@ var u = (e) => {
|
|
|
25
25
|
catch: (e) => e
|
|
26
26
|
});
|
|
27
27
|
return a.flatMap(a.context(), (t) => (h.set(r, t), e.prepare === void 0 ? i : a.flatMap(e.prepare(r), () => i)));
|
|
28
|
-
})).pipe(a.
|
|
28
|
+
})).pipe(a.catchCause((t) => {
|
|
29
|
+
let n = t.reasons.flatMap((e) => i.isFailReason(e) ? [e.error] : i.isDieReason(e) ? [e.defect] : []).find((t) => e.isRetryable(t));
|
|
30
|
+
return n === void 0 ? a.failCause(t) : a.fail(n);
|
|
31
|
+
}));
|
|
29
32
|
}).pipe(a.retry(p(e.isRetryable)), a.withSpan(e.span.name, { attributes: { ...e.span.attributes } }));
|
|
30
33
|
return r(e.dialect, "transaction", async () => u(await e.runPromiseExit(e.wrapProgram === void 0 ? n : e.wrapProgram(n))));
|
|
31
34
|
}, v = class extends Error {
|
|
@@ -93,5 +96,4 @@ var u = (e) => {
|
|
|
93
96
|
});
|
|
94
97
|
return a.view.commitEvents(), a.result;
|
|
95
98
|
};
|
|
96
|
-
//#endregion
|
|
97
99
|
export { m as SHARED_TRANSACTION_SERVICE, v as TransactionAbortedError, x as isTransactionAbortedError, y as makeTransactionAbortTracker, g as onTransaction, _ as runRetryingTransaction, b as runSavepoint, C as runStoreTransaction, u as settleTransactionExit, p as transactionRetrySchedule };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { causeBranches as e } from "./dbCause.js";
|
|
2
|
-
|
|
2
|
+
// src/transientContention.ts
|
|
3
3
|
var t = /* @__PURE__ */ new Set([
|
|
4
4
|
"1213",
|
|
5
5
|
"ER_LOCK_DEADLOCK",
|
|
@@ -32,5 +32,4 @@ var t = /* @__PURE__ */ new Set([
|
|
|
32
32
|
}
|
|
33
33
|
return !1;
|
|
34
34
|
};
|
|
35
|
-
//#endregion
|
|
36
35
|
export { r as MSSQL_TRANSIENT_NUMBERS, t as MYSQL_TRANSIENT_CODES, n as POSTGRES_TRANSIENT_STATES, i as SQLITE_TRANSIENT_CODES, a as TURSO_TRANSIENT_MESSAGE, c as isTransientContention };
|
package/dist/typeId.js
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
// src/typeId.ts
|
|
2
|
+
var e = /^[a-z][a-z0-9_]*$/, t = 0, n = 0, r = /* @__PURE__ */ new Uint8Array(4096), i = r.length, a = (e) => {
|
|
3
|
+
i + e > r.length && (globalThis.crypto.getRandomValues(r), i = 0);
|
|
4
|
+
let t = r.slice(i, i + e);
|
|
5
|
+
return i += e, t;
|
|
6
|
+
}, o = (e = Date.now()) => {
|
|
7
|
+
let r = Math.max(e, t);
|
|
8
|
+
r === t ? (n += 1, n > 4095 && (r += 1, n = a(2)[0] & 2047)) : n = a(2)[0] & 2047, t = r;
|
|
9
|
+
let i = /* @__PURE__ */ new Uint8Array(16);
|
|
10
|
+
i[0] = r / 2 ** 40 & 255, i[1] = r / 2 ** 32 & 255, i[2] = r >>> 24 & 255, i[3] = r >>> 16 & 255, i[4] = r >>> 8 & 255, i[5] = r & 255, i[6] = 112 | n >>> 8 & 15, i[7] = n & 255;
|
|
11
|
+
let o = a(8);
|
|
12
|
+
return i.set(o, 8), i[8] = 128 | i[8] & 63, i;
|
|
13
|
+
}, s = (e) => {
|
|
14
|
+
if (e.length !== 16) throw Error(`typeid suffix needs 16 bytes, got ${e.length}`);
|
|
15
|
+
let t = (t) => e[t], n = [
|
|
16
|
+
(t(0) & 224) >> 5,
|
|
17
|
+
t(0) & 31,
|
|
18
|
+
(t(1) & 248) >> 3,
|
|
19
|
+
(t(1) & 7) << 2 | (t(2) & 192) >> 6,
|
|
20
|
+
(t(2) & 62) >> 1,
|
|
21
|
+
(t(2) & 1) << 4 | (t(3) & 240) >> 4,
|
|
22
|
+
(t(3) & 15) << 1 | (t(4) & 128) >> 7,
|
|
23
|
+
(t(4) & 124) >> 2,
|
|
24
|
+
(t(4) & 3) << 3 | (t(5) & 224) >> 5,
|
|
25
|
+
t(5) & 31,
|
|
26
|
+
(t(6) & 248) >> 3,
|
|
27
|
+
(t(6) & 7) << 2 | (t(7) & 192) >> 6,
|
|
28
|
+
(t(7) & 62) >> 1,
|
|
29
|
+
(t(7) & 1) << 4 | (t(8) & 240) >> 4,
|
|
30
|
+
(t(8) & 15) << 1 | (t(9) & 128) >> 7,
|
|
31
|
+
(t(9) & 124) >> 2,
|
|
32
|
+
(t(9) & 3) << 3 | (t(10) & 224) >> 5,
|
|
33
|
+
t(10) & 31,
|
|
34
|
+
(t(11) & 248) >> 3,
|
|
35
|
+
(t(11) & 7) << 2 | (t(12) & 192) >> 6,
|
|
36
|
+
(t(12) & 62) >> 1,
|
|
37
|
+
(t(12) & 1) << 4 | (t(13) & 240) >> 4,
|
|
38
|
+
(t(13) & 15) << 1 | (t(14) & 128) >> 7,
|
|
39
|
+
(t(14) & 124) >> 2,
|
|
40
|
+
(t(14) & 3) << 3 | (t(15) & 224) >> 5,
|
|
41
|
+
t(15) & 31
|
|
42
|
+
], r = "";
|
|
43
|
+
for (let e of n) r += "0123456789abcdefghjkmnpqrstvwxyz"[e];
|
|
44
|
+
return r;
|
|
45
|
+
}, c = (t) => {
|
|
46
|
+
if (!e.test(t)) throw Error(`typeid prefix '${t}' must match /^[a-z][a-z0-9_]*$/`);
|
|
47
|
+
if (t.length > 63) throw Error(`typeid prefix '${t}' is longer than 63 characters`);
|
|
48
|
+
return `${t}_${s(o())}`;
|
|
49
|
+
};
|
|
50
|
+
export { s as encodeTypeIdSuffix, c as typeId, o as uuidV7Bytes };
|
package/dist/typedStore.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { authoredError as e } from "./dbCause.js";
|
|
2
|
-
|
|
3
|
-
var t = (e, t, n) => e.insert(t.tableName, n), n = (e, t, n) => e.insertMany(t.tableName, n), r = (e, t, n, r) => e.upsert(t.tableName, n, {
|
|
2
|
+
// src/typedStore.ts
|
|
3
|
+
var t = (e, t, n) => e.insert(t.tableName, n), n = (e, t, n, r) => e.insertMany(t.tableName, n, r), r = (e, t, n, r) => e.upsert(t.tableName, n, {
|
|
4
4
|
conflictColumns: r.conflictColumns,
|
|
5
5
|
...r.update === void 0 ? {} : { update: r.update },
|
|
6
6
|
...r.updateValues === void 0 ? {} : { updateValues: r.updateValues }
|
|
@@ -12,5 +12,4 @@ var t = (e, t, n) => e.insert(t.tableName, n), n = (e, t, n) => e.insertMany(t.t
|
|
|
12
12
|
...i.updateValues === void 0 ? {} : { updateValues: i.updateValues }
|
|
13
13
|
});
|
|
14
14
|
}, a = async (e, t, n, r) => e.insertIgnoreWithOutcome(t.tableName, n, { conflictColumns: r.conflictColumns }), o = (e, t, n, r) => e.updateMany(t.tableName, n, { where: r.where });
|
|
15
|
-
//#endregion
|
|
16
15
|
export { a as insertIgnoreRowOutcome, n as insertManyRows, t as insertRow, o as updateManyRow, r as upsertRow, i as upsertRowOutcome };
|
package/dist/upsertUpdate.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { authoredError as e } from "./dbCause.js";
|
|
2
|
-
|
|
2
|
+
// src/upsertUpdate.ts
|
|
3
3
|
var t = (t) => Object.fromEntries(Object.entries(t.updateValues ?? {}).filter(([n, r]) => {
|
|
4
4
|
if (r === void 0) return !1;
|
|
5
5
|
if (n === "id" || t.conflictColumns.includes(n)) throw e(`upsert: updateValues cannot rewrite row identity column '${n}'`);
|
|
@@ -16,5 +16,4 @@ var t = (t) => Object.fromEntries(Object.entries(t.updateValues ?? {}).filter(([
|
|
|
16
16
|
...i
|
|
17
17
|
};
|
|
18
18
|
};
|
|
19
|
-
//#endregion
|
|
20
19
|
export { n as upsertUpdatePatch, t as upsertUpdateValues };
|
package/dist/vectorEmbedding.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { vector as e } from "./columns.js";
|
|
2
2
|
import { defineMixin as t } from "./mixins.js";
|
|
3
|
-
|
|
3
|
+
// src/vectorEmbedding.ts
|
|
4
4
|
var n = async (e, t) => {
|
|
5
5
|
let n = e.as ?? "embedding", r = t.row[e.from];
|
|
6
6
|
if (typeof r != "string" || r.length === 0) return {};
|
|
@@ -27,5 +27,4 @@ var n = async (e, t) => {
|
|
|
27
27
|
}
|
|
28
28
|
});
|
|
29
29
|
};
|
|
30
|
-
//#endregion
|
|
31
30
|
export { n as computeEmbedding, r as vectorEmbedding };
|
package/dist/view.js
CHANGED
|
@@ -2,7 +2,7 @@ import { materializeFields as e } from "./columns.js";
|
|
|
2
2
|
import { validateColumnName as t, validateTableName as n } from "./identifierLimits.js";
|
|
3
3
|
import { quoteIdent as r } from "./dialect.js";
|
|
4
4
|
import { queryFor as i } from "./queryBuilder.js";
|
|
5
|
-
|
|
5
|
+
// src/view.ts
|
|
6
6
|
var a = (e) => e.isView === !0, o = (r, i, a) => {
|
|
7
7
|
if (n(r), a.trim().length === 0) throw Error(`view('${r}', …): the SELECT body is empty — a view must define a query.`);
|
|
8
8
|
let o = e(i);
|
|
@@ -35,5 +35,4 @@ var a = (e) => e.isView === !0, o = (r, i, a) => {
|
|
|
35
35
|
case "turso": return `DROP VIEW IF EXISTS ${i};\nCREATE VIEW ${i} AS ${a};`;
|
|
36
36
|
}
|
|
37
37
|
};
|
|
38
|
-
//#endregion
|
|
39
38
|
export { a as isView, s as queryForView, o as view, c as viewSql };
|
package/dist/wire.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { VersionConflict as e } from "./optimisticVersion.js";
|
|
2
2
|
import { Schema as t } from "effect";
|
|
3
|
-
|
|
3
|
+
// src/wire.ts
|
|
4
4
|
var n = t.DateFromMillis.annotate({ description: "A point in time: a Date in the handler, epoch milliseconds on the wire." }), r = t.NullOr(n);
|
|
5
|
-
//#endregion
|
|
6
5
|
export { e as VersionConflict, n as timestampMs, r as timestampMsOrNull };
|
package/dist/writeAttribution.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AsyncLocalStorage as e } from "node:async_hooks";
|
|
2
|
-
|
|
2
|
+
// src/writeAttribution.ts
|
|
3
3
|
var t = new e(), n = (e, n) => t.run(e, n), r = () => t.getStore(), i = (e) => {
|
|
4
4
|
let n = e ?? t.getStore();
|
|
5
5
|
return n === void 0 ? {} : {
|
|
@@ -12,5 +12,4 @@ var t = new e(), n = (e, n) => t.run(e, n), r = () => t.getStore(), i = (e) => {
|
|
|
12
12
|
let n = t.getStore();
|
|
13
13
|
return n === void 0 ? e(void 0) : t.run(n, () => e(n));
|
|
14
14
|
};
|
|
15
|
-
//#endregion
|
|
16
15
|
export { i as attributionFields, r as currentWriteAttribution, n as runWithWriteAttribution, a as withCapturedAttribution };
|
package/dist/writeRecorder.js
CHANGED
|
@@ -1,37 +1,37 @@
|
|
|
1
1
|
import { describeDriverError as e } from "./dbCause.js";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
import { isTableReactive as t } from "./tableRegistry.js";
|
|
3
|
+
import { Effect as n } from "effect";
|
|
4
|
+
import { AsyncLocalStorage as r } from "node:async_hooks";
|
|
5
|
+
// src/writeRecorder.ts
|
|
6
|
+
var i = /* @__PURE__ */ new Map(), a = (e, t) => {
|
|
7
|
+
i.set(e, {
|
|
7
8
|
recorder: t.recorder,
|
|
8
9
|
tables: new Set(t.tables),
|
|
9
10
|
ownTables: new Set(t.ownTables)
|
|
10
11
|
});
|
|
11
|
-
},
|
|
12
|
-
|
|
13
|
-
},
|
|
14
|
-
let
|
|
15
|
-
if (
|
|
16
|
-
--
|
|
12
|
+
}, o = (e) => {
|
|
13
|
+
i.delete(e);
|
|
14
|
+
}, s = () => i.clear(), c = new r(), l = (e) => c.run({ n: 1 }, e), u = (e) => n.suspend(() => {
|
|
15
|
+
let t = c.getStore();
|
|
16
|
+
if (t !== void 0) return t.n += 1, n.ensuring(e, n.sync(() => {
|
|
17
|
+
--t.n;
|
|
17
18
|
}));
|
|
18
19
|
let r = { n: 1 };
|
|
19
|
-
return
|
|
20
|
+
return c.enterWith(r), n.ensuring(e, n.sync(() => {
|
|
20
21
|
--r.n;
|
|
21
22
|
}));
|
|
22
|
-
}),
|
|
23
|
-
if (
|
|
24
|
-
for (let t of
|
|
23
|
+
}), d = () => (c.getStore()?.n ?? 0) > 0, f = (e) => {
|
|
24
|
+
if (i.size === 0 || (c.getStore()?.n ?? 0) > 0) return !1;
|
|
25
|
+
for (let t of i.values()) if (!t.ownTables.has(e) && t.tables.has(e)) return !0;
|
|
25
26
|
return !1;
|
|
26
|
-
}, f = async (t, n) => {
|
|
27
|
-
if (
|
|
28
|
-
for (let [
|
|
27
|
+
}, p = (e) => t(e) || f(e), m = async (t, n) => {
|
|
28
|
+
if (i.size !== 0) {
|
|
29
|
+
for (let [r, a] of i.entries()) if (!a.ownTables.has(n.table) && a.tables.has(n.table)) try {
|
|
29
30
|
await a.recorder(t, n);
|
|
30
31
|
} catch (t) {
|
|
31
|
-
let
|
|
32
|
-
throw
|
|
32
|
+
let i = e(t);
|
|
33
|
+
throw i === void 0 ? t : Error(`write recorder '${r}' failed while recording a ${n.op} on '${n.table}': ${i}`, { cause: t });
|
|
33
34
|
}
|
|
34
35
|
}
|
|
35
36
|
};
|
|
36
|
-
|
|
37
|
-
export { o as clearWriteRecorders, d as recordsTable, i as registerWriteRecorder, f as runWriteRecorders, c as suspendWriteRecorders, l as suspendWriteRecordersEffect, a as unregisterWriteRecorder, u as writeRecordersSuspended };
|
|
37
|
+
export { s as clearWriteRecorders, f as recordsTable, a as registerWriteRecorder, m as runWriteRecorders, l as suspendWriteRecorders, u as suspendWriteRecordersEffect, o as unregisterWriteRecorder, p as writeImagesObserved, d as writeRecordersSuspended };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@voltro/database",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.88.0",
|
|
4
4
|
"description": "Browser-safe schema DSL, query builder, and cross-dialect migration planner for Voltro — one schema, every SQL backend.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"voltro",
|
|
@@ -43,12 +43,11 @@
|
|
|
43
43
|
"node": ">=24.0.0"
|
|
44
44
|
},
|
|
45
45
|
"dependencies": {
|
|
46
|
-
"@voltro/logger": "0.
|
|
47
|
-
"typeid-js": "^1.2.0",
|
|
46
|
+
"@voltro/logger": "0.88.0",
|
|
48
47
|
"ulid": "^3.0.2"
|
|
49
48
|
},
|
|
50
49
|
"peerDependencies": {
|
|
51
|
-
"effect": "4.0
|
|
50
|
+
"effect": "4.1.0"
|
|
52
51
|
},
|
|
53
52
|
"publishConfig": {
|
|
54
53
|
"access": "public"
|