@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/view.js
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { materializeFields as e } from "./columns.js";
|
|
2
|
+
import { validateColumnName as t, validateTableName as n } from "./identifierLimits.js";
|
|
3
|
+
import { quoteIdent as r } from "./dialect.js";
|
|
4
|
+
import { queryFor as i } from "./queryBuilder.js";
|
|
5
|
+
//#region src/view.ts
|
|
6
|
+
var a = (e) => e.isView === !0, o = (r, i, a) => {
|
|
7
|
+
if (n(r), a.trim().length === 0) throw Error(`view('${r}', …): the SELECT body is empty — a view must define a query.`);
|
|
8
|
+
let o = e(i);
|
|
9
|
+
for (let e of Object.keys(o)) t(r, e);
|
|
10
|
+
return {
|
|
11
|
+
tableName: r,
|
|
12
|
+
fields: o,
|
|
13
|
+
isView: !0,
|
|
14
|
+
viewSelect: a
|
|
15
|
+
};
|
|
16
|
+
}, s = (e) => {
|
|
17
|
+
let t = {
|
|
18
|
+
...e,
|
|
19
|
+
isReactive: !1,
|
|
20
|
+
appliedMixins: [],
|
|
21
|
+
appliedIndexes: [],
|
|
22
|
+
appliedUniques: [],
|
|
23
|
+
appliedFullText: [],
|
|
24
|
+
appliedChecks: []
|
|
25
|
+
};
|
|
26
|
+
return i(t);
|
|
27
|
+
}, c = (e, t, n = null) => {
|
|
28
|
+
let i = n === null ? r(e.tableName, t) : `${r(n, t)}.${r(e.tableName, t)}`, a = e.viewSelect.trim();
|
|
29
|
+
switch (t) {
|
|
30
|
+
case "postgres":
|
|
31
|
+
case "mysql":
|
|
32
|
+
case "mariadb": return `CREATE OR REPLACE VIEW ${i} AS ${a};`;
|
|
33
|
+
case "mssql": return `CREATE OR ALTER VIEW ${i} AS ${a};`;
|
|
34
|
+
case "sqlite":
|
|
35
|
+
case "turso": return `DROP VIEW IF EXISTS ${i};\nCREATE VIEW ${i} AS ${a};`;
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
//#endregion
|
|
39
|
+
export { a as isView, s as queryForView, o as view, c as viewSql };
|
package/dist/wire.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Schema } from 'effect';
|
|
2
|
+
import { YieldableError } from 'effect/Cause';
|
|
2
3
|
|
|
3
4
|
/**
|
|
4
5
|
* The timestamp mapping as a STANDALONE field schema: `Date` in the
|
|
@@ -27,7 +28,7 @@ import { Schema } from 'effect';
|
|
|
27
28
|
* There is deliberately no `timestampMsOptional`: an absent field is
|
|
28
29
|
* `Schema.optional(timestampMs)`, which composes without a third export.
|
|
29
30
|
*/
|
|
30
|
-
export declare const timestampMs: Schema.
|
|
31
|
+
export declare const timestampMs: Schema.Codec<Date, number>;
|
|
31
32
|
|
|
32
33
|
/**
|
|
33
34
|
* `timestampMs` for a NULLABLE timestamp column — `Date | null` in the
|
|
@@ -39,7 +40,7 @@ export declare const timestampMs: Schema.Schema<Date, number>;
|
|
|
39
40
|
* instead of as nothing. Mirrors what `columnSchema` does for a
|
|
40
41
|
* `.nullable()` timestamp.
|
|
41
42
|
*/
|
|
42
|
-
export declare const timestampMsOrNull: Schema.
|
|
43
|
+
export declare const timestampMsOrNull: Schema.Codec<Date | null, number | null>;
|
|
43
44
|
|
|
44
45
|
/**
|
|
45
46
|
* A write lost the race.
|
|
@@ -51,15 +52,13 @@ export declare const timestampMsOrNull: Schema.Schema<Date | null, number | null
|
|
|
51
52
|
export declare class VersionConflict extends VersionConflict_base {
|
|
52
53
|
}
|
|
53
54
|
|
|
54
|
-
declare const VersionConflict_base: Schema.
|
|
55
|
-
readonly
|
|
56
|
-
|
|
57
|
-
table: typeof Schema.String;
|
|
58
|
-
id: typeof Schema.String;
|
|
55
|
+
declare const VersionConflict_base: Schema.Class<VersionConflict, Schema.TaggedStruct<"VersionConflict", {
|
|
56
|
+
readonly table: Schema.String;
|
|
57
|
+
readonly id: Schema.String;
|
|
59
58
|
/** What the caller believed the row was at. */
|
|
60
|
-
expected:
|
|
59
|
+
readonly expected: Schema.Number;
|
|
61
60
|
/** What it is actually at. `null` when the row is gone entirely. */
|
|
62
|
-
actual: Schema.NullOr<
|
|
63
|
-
}>;
|
|
61
|
+
readonly actual: Schema.NullOr<Schema.Number>;
|
|
62
|
+
}>, YieldableError>;
|
|
64
63
|
|
|
65
64
|
export { }
|
package/dist/wire.js
CHANGED
|
@@ -1,2 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { VersionConflict as e } from "./optimisticVersion.js";
|
|
2
|
+
import { Schema as t } from "effect";
|
|
3
|
+
//#region src/wire.ts
|
|
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
|
+
export { e as VersionConflict, n as timestampMs, r as timestampMsOrNull };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { AsyncLocalStorage as e } from "node:async_hooks";
|
|
2
|
+
//#region src/writeAttribution.ts
|
|
3
|
+
var t = new e(), n = (e, n) => t.run(e, n), r = () => t.getStore(), i = (e) => {
|
|
4
|
+
let n = e ?? t.getStore();
|
|
5
|
+
return n === void 0 ? {} : {
|
|
6
|
+
...n.traceId === void 0 ? {} : { traceId: n.traceId },
|
|
7
|
+
...n.subjectId === void 0 ? {} : { subjectId: n.subjectId },
|
|
8
|
+
...n.procedure === void 0 ? {} : { procedure: n.procedure },
|
|
9
|
+
...n.via === void 0 ? {} : { via: n.via }
|
|
10
|
+
};
|
|
11
|
+
}, a = (e) => {
|
|
12
|
+
let n = t.getStore();
|
|
13
|
+
return n === void 0 ? e(void 0) : t.run(n, () => e(n));
|
|
14
|
+
};
|
|
15
|
+
//#endregion
|
|
16
|
+
export { i as attributionFields, r as currentWriteAttribution, n as runWithWriteAttribution, a as withCapturedAttribution };
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { describeDriverError as e } from "./dbCause.js";
|
|
2
|
+
import { Effect as t } from "effect";
|
|
3
|
+
import { AsyncLocalStorage as n } from "node:async_hooks";
|
|
4
|
+
//#region src/writeRecorder.ts
|
|
5
|
+
var r = /* @__PURE__ */ new Map(), i = (e, t) => {
|
|
6
|
+
r.set(e, {
|
|
7
|
+
recorder: t.recorder,
|
|
8
|
+
tables: new Set(t.tables),
|
|
9
|
+
ownTables: new Set(t.ownTables)
|
|
10
|
+
});
|
|
11
|
+
}, a = (e) => {
|
|
12
|
+
r.delete(e);
|
|
13
|
+
}, o = () => r.clear(), s = new n(), c = (e) => s.run({ n: 1 }, e), l = (e) => t.suspend(() => {
|
|
14
|
+
let n = s.getStore();
|
|
15
|
+
if (n !== void 0) return n.n += 1, t.ensuring(e, t.sync(() => {
|
|
16
|
+
--n.n;
|
|
17
|
+
}));
|
|
18
|
+
let r = { n: 1 };
|
|
19
|
+
return s.enterWith(r), t.ensuring(e, t.sync(() => {
|
|
20
|
+
--r.n;
|
|
21
|
+
}));
|
|
22
|
+
}), u = () => (s.getStore()?.n ?? 0) > 0, d = (e) => {
|
|
23
|
+
if (r.size === 0 || (s.getStore()?.n ?? 0) > 0) return !1;
|
|
24
|
+
for (let t of r.values()) if (!t.ownTables.has(e) && t.tables.has(e)) return !0;
|
|
25
|
+
return !1;
|
|
26
|
+
}, f = async (t, n) => {
|
|
27
|
+
if (r.size !== 0) {
|
|
28
|
+
for (let [i, a] of r.entries()) if (!a.ownTables.has(n.table) && a.tables.has(n.table)) try {
|
|
29
|
+
await a.recorder(t, n);
|
|
30
|
+
} catch (t) {
|
|
31
|
+
let r = e(t);
|
|
32
|
+
throw r === void 0 ? t : Error(`write recorder '${i}' failed while recording a ${n.op} on '${n.table}': ${r}`, { cause: t });
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
//#endregion
|
|
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 };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@voltro/database",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.86.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,14 +43,12 @@
|
|
|
43
43
|
"node": ">=24.0.0"
|
|
44
44
|
},
|
|
45
45
|
"dependencies": {
|
|
46
|
-
"@
|
|
47
|
-
"@effect/sql": "^0.52.1",
|
|
48
|
-
"@voltro/logger": "0.84.0",
|
|
46
|
+
"@voltro/logger": "0.86.0",
|
|
49
47
|
"typeid-js": "^1.2.0",
|
|
50
|
-
"
|
|
48
|
+
"ulid": "^3.0.2"
|
|
51
49
|
},
|
|
52
50
|
"peerDependencies": {
|
|
53
|
-
"effect": "
|
|
51
|
+
"effect": "4.0.1"
|
|
54
52
|
},
|
|
55
53
|
"publishConfig": {
|
|
56
54
|
"access": "public"
|