@voltro/database 0.85.0 → 0.87.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.
Files changed (173) hide show
  1. package/CHANGELOG.md +5987 -0
  2. package/THIRD-PARTY-NOTICES.md +5 -257
  3. package/dist/actorSnapshot.js +24 -0
  4. package/dist/arrayCodec.js +32 -0
  5. package/dist/branchExecute.js +92 -0
  6. package/dist/branching.js +106 -0
  7. package/dist/bulkInsertLimits.js +25 -0
  8. package/dist/cdcOffsetsTables.js +19 -0
  9. package/dist/changeEvent.js +41 -0
  10. package/dist/changeIdentity.js +65 -0
  11. package/dist/changeListenerCeiling.js +6 -0
  12. package/dist/columnReference.js +17 -0
  13. package/dist/columns.js +326 -0
  14. package/dist/committedChanges.js +12 -0
  15. package/dist/connectionIdentity.js +36 -0
  16. package/dist/coreTables.js +16 -0
  17. package/dist/coreTablesRegistry.js +10 -0
  18. package/dist/dataTransfers.js +23 -0
  19. package/dist/dbCause.js +222 -0
  20. package/dist/dbMetrics.js +65 -0
  21. package/dist/decimalComparison.js +27 -0
  22. package/dist/derivedRowId.js +5 -0
  23. package/dist/dialect.js +13 -0
  24. package/dist/enumRenames.js +14 -0
  25. package/dist/expiresMixin.js +10 -0
  26. package/dist/fieldEncryption.js +121 -0
  27. package/dist/frameworkTables.js +143 -0
  28. package/dist/ginIndex.js +10 -0
  29. package/dist/hybridSearch.js +32 -0
  30. package/dist/idGenerator.js +57 -0
  31. package/dist/identifierLimits.js +32 -0
  32. package/dist/index.d.ts +166 -22
  33. package/dist/index.js +82 -2183
  34. package/dist/indexAudit.js +61 -0
  35. package/dist/indexStorage.js +58 -0
  36. package/dist/joinCompiler.js +160 -0
  37. package/dist/jsonEagerCompiler.js +436 -0
  38. package/dist/jsonPatch.js +78 -0
  39. package/dist/jsonPatchAssignments.js +13 -0
  40. package/dist/jsonPath.js +31 -0
  41. package/dist/localFirstMixin.js +12 -0
  42. package/dist/migrate.js +644 -0
  43. package/dist/migration.js +18 -0
  44. package/dist/migrations/appliedAtValue.js +8 -0
  45. package/dist/migrations/applier.js +1100 -0
  46. package/dist/migrations/boot.js +196 -0
  47. package/dist/migrations/branchRehearsal.js +122 -0
  48. package/dist/migrations/columnEquivalence.js +85 -0
  49. package/dist/migrations/ddlError.js +63 -0
  50. package/dist/migrations/ddlStatements.js +9 -0
  51. package/dist/migrations/declaredSchema.js +162 -0
  52. package/dist/migrations/deployLedger.js +19 -0
  53. package/dist/migrations/fileBased.js +57 -0
  54. package/dist/migrations/fileContext.js +482 -0
  55. package/dist/migrations/fileDiscovery.js +332 -0
  56. package/dist/migrations/fileSkipProbes.js +117 -0
  57. package/dist/migrations/fingerprint.js +46 -0
  58. package/dist/migrations/fkCycles.js +13 -0
  59. package/dist/migrations/frameworkLiveTables.js +25 -0
  60. package/dist/migrations/idempotentDdl.js +37 -0
  61. package/dist/migrations/indexPredicate.js +50 -0
  62. package/dist/migrations/introspect.js +801 -0
  63. package/dist/migrations/ledgerRows.js +4 -0
  64. package/dist/migrations/lock.js +91 -0
  65. package/dist/migrations/migrationTableExists.js +9 -0
  66. package/dist/migrations/mssqlColumnDependencies.js +76 -0
  67. package/dist/migrations/mysqlEngine.js +11 -0
  68. package/dist/migrations/namespaceCharset.js +51 -0
  69. package/dist/migrations/planner.js +785 -0
  70. package/dist/migrations/postgresEnumCheck.js +22 -0
  71. package/dist/migrations/reactiveTriggerDrift.js +58 -0
  72. package/dist/migrations/reactiveTriggerName.js +7 -0
  73. package/dist/migrations/renameMssqlCheck.js +21 -0
  74. package/dist/migrations/restoreSnapshots.js +206 -0
  75. package/dist/migrations/resumeLedger.js +86 -0
  76. package/dist/migrations/rollingDeploy.js +106 -0
  77. package/dist/migrations/schemaOwner.js +46 -0
  78. package/dist/migrations/schemaOwnerTable.js +4 -0
  79. package/dist/migrations/softDropSnapshot.js +20 -0
  80. package/dist/migrations/sqlLimit.js +8 -0
  81. package/dist/migrations/sqliteCatalogName.js +13 -0
  82. package/dist/migrations/sqliteConstraintIdentity.js +97 -0
  83. package/dist/migrations/sqliteDecimalBoot.js +22 -0
  84. package/dist/migrations/sqliteDecimalPublication.js +257 -0
  85. package/dist/migrations/sqliteDecimalReview.js +30 -0
  86. package/dist/migrations/sqliteDecimalReviewStore.js +188 -0
  87. package/dist/migrations/sqliteDecimalReviewWitness.js +38 -0
  88. package/dist/migrations/sqliteDecimalSource.js +69 -0
  89. package/dist/migrations/sqliteDecimalStage.js +135 -0
  90. package/dist/migrations/sqliteForeignKeys.js +38 -0
  91. package/dist/migrations/sqliteMigrationBatch.js +37 -0
  92. package/dist/migrations/sqliteRetainedSource.js +106 -0
  93. package/dist/migrations/sqliteRowIdentity.js +63 -0
  94. package/dist/migrations/sqliteSchemaEpoch.js +12 -0
  95. package/dist/migrations/sqliteSnapshotGuard.js +10 -0
  96. package/dist/migrations/sqliteTableContents.js +34 -0
  97. package/dist/migrations/sqliteTableCopy.js +25 -0
  98. package/dist/migrations/sqliteTableSchema.js +19 -0
  99. package/dist/migrations/sqliteWitnessProtection.js +8 -0
  100. package/dist/migrations/squash.js +81 -0
  101. package/dist/migrations/storeCharset.js +66 -0
  102. package/dist/migrations/transactionCause.js +10 -0
  103. package/dist/migrations/undeclaredCharset.js +40 -0
  104. package/dist/migrations/uniqueActiveLowering.js +39 -0
  105. package/dist/mixins.js +22 -0
  106. package/dist/mssqlDecimalDistinct.js +51 -0
  107. package/dist/mssqlJsonValueCheck.js +42 -0
  108. package/dist/mssqlTextStorage.js +9 -0
  109. package/dist/namespace.js +21 -0
  110. package/dist/{wire-CG2j7J3f.js → optimisticVersion.js} +2 -2
  111. package/dist/pendingAttribution.js +79 -0
  112. package/dist/pluginRef.js +17 -0
  113. package/dist/predicate.js +273 -0
  114. package/dist/predicateCoercion.js +13 -0
  115. package/dist/projectedColumn.js +37 -0
  116. package/dist/queryBuilder.js +388 -0
  117. package/dist/rawSql.js +8 -0
  118. package/dist/relations.js +69 -0
  119. package/dist/relationsRegistry.js +38 -0
  120. package/dist/replaceInProgress.js +53 -0
  121. package/dist/requiredColumns.js +26 -0
  122. package/dist/residency.js +52 -0
  123. package/dist/retention.js +62 -0
  124. package/dist/rowDecoder.js +173 -0
  125. package/dist/rowKey.js +8 -0
  126. package/dist/rowSchema.js +31 -0
  127. package/dist/scopeKey.js +8 -0
  128. package/dist/seed.js +33 -0
  129. package/dist/snowflake.js +26 -0
  130. package/dist/sql.d.ts +2792 -3773
  131. package/dist/sql.js +42 -6905
  132. package/dist/sqlCompiler.js +360 -0
  133. package/dist/sqlError.js +8 -0
  134. package/dist/sqlMutation.js +55 -0
  135. package/dist/sqlPoolCapacity.js +12 -0
  136. package/dist/sqliteDecimal.js +22 -0
  137. package/dist/sqliteDecimalAggregateSql.js +61 -0
  138. package/dist/sqliteDecimalColumnSql.js +108 -0
  139. package/dist/sqliteDecimalConversion.js +15 -0
  140. package/dist/sqliteDecimalCte.js +154 -0
  141. package/dist/sqliteDecimalEncodeSql.js +32 -0
  142. package/dist/sqliteDecimalOutputs.js +74 -0
  143. package/dist/sqliteDecimalPredicate.js +66 -0
  144. package/dist/sqliteDecimalQuery.js +183 -0
  145. package/dist/sqliteDecimalQueryPlan.js +37 -0
  146. package/dist/sqliteDecimalResultSql.js +44 -0
  147. package/dist/sqliteDecimalRowQuery.js +63 -0
  148. package/dist/sqliteDecimalSetQuery.js +50 -0
  149. package/dist/sqliteDecimalSource.js +63 -0
  150. package/dist/sqliteDecimalStorage.js +29 -0
  151. package/dist/sqliteDecimalSubquery.js +19 -0
  152. package/dist/sqliteDecimalWindowQuery.js +196 -0
  153. package/dist/sqliteValueCoercion.js +4 -0
  154. package/dist/stampId.js +21 -0
  155. package/dist/storeErrors.js +9 -0
  156. package/dist/storeRefusal.js +20 -0
  157. package/dist/stream.js +36 -0
  158. package/dist/subjectGraph.js +175 -0
  159. package/dist/table.js +394 -0
  160. package/dist/tableRegistry.js +16 -0
  161. package/dist/tenantSelection.js +27 -0
  162. package/dist/transactionOutcome.js +100 -0
  163. package/dist/transientContention.js +36 -0
  164. package/dist/typeId.js +51 -0
  165. package/dist/typedStore.js +16 -0
  166. package/dist/upsertUpdate.js +20 -0
  167. package/dist/vectorEmbedding.js +31 -0
  168. package/dist/view.js +39 -0
  169. package/dist/wire.js +6 -2
  170. package/dist/writeAttribution.js +16 -0
  171. package/dist/writeRecorder.js +38 -0
  172. package/package.json +3 -4
  173. package/dist/replaceInProgress-DC88Pdiy.js +0 -3735
@@ -0,0 +1,31 @@
1
+ import { vector as e } from "./columns.js";
2
+ import { defineMixin as t } from "./mixins.js";
3
+ //#region src/vectorEmbedding.ts
4
+ var n = async (e, t) => {
5
+ let n = e.as ?? "embedding", r = t.row[e.from];
6
+ if (typeof r != "string" || r.length === 0) return {};
7
+ let i = await t.embed(r);
8
+ return { [n]: i };
9
+ }, r = (r) => {
10
+ if (!Number.isInteger(r.dimensions) || r.dimensions <= 0) throw Error(`vectorEmbedding: dimensions must be a positive integer, got ${String(r.dimensions)}.`);
11
+ let i = r.as ?? "embedding", a = (e) => n(r, e);
12
+ return t({
13
+ id: "voltro/vectorEmbedding",
14
+ fields: { [i]: e(r.dimensions) },
15
+ ...r.index === !1 ? {} : { indexes: [{
16
+ fields: [i],
17
+ kind: "hnsw",
18
+ kindOptions: { hnsw: {
19
+ ...r.index?.m === void 0 ? {} : { m: r.index.m },
20
+ ...r.index?.efConstruction === void 0 ? {} : { efConstruction: r.index.efConstruction },
21
+ distance: r.distance ?? "cosine"
22
+ } }
23
+ }] },
24
+ behaviors: {
25
+ beforeInsert: a,
26
+ beforeUpdate: a
27
+ }
28
+ });
29
+ };
30
+ //#endregion
31
+ export { n as computeEmbedding, r as vectorEmbedding };
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.js CHANGED
@@ -1,2 +1,6 @@
1
- import { i as e, n as t, t as n } from "./wire-CG2j7J3f.js";
2
- export { e as VersionConflict, n as timestampMs, t as timestampMsOrNull };
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,38 @@
1
+ import { describeDriverError as e } from "./dbCause.js";
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
+ //#region src/writeRecorder.ts
6
+ var i = /* @__PURE__ */ new Map(), a = (e, t) => {
7
+ i.set(e, {
8
+ recorder: t.recorder,
9
+ tables: new Set(t.tables),
10
+ ownTables: new Set(t.ownTables)
11
+ });
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;
18
+ }));
19
+ let r = { n: 1 };
20
+ return c.enterWith(r), n.ensuring(e, n.sync(() => {
21
+ --r.n;
22
+ }));
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;
26
+ return !1;
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 {
30
+ await a.recorder(t, n);
31
+ } catch (t) {
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 });
34
+ }
35
+ }
36
+ };
37
+ //#endregion
38
+ 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.85.0",
3
+ "version": "0.87.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,9 +43,8 @@
43
43
  "node": ">=24.0.0"
44
44
  },
45
45
  "dependencies": {
46
- "@voltro/logger": "0.85.0",
47
- "typeid-js": "^1.2.0",
48
- "ulidx": "^2.4.1"
46
+ "@voltro/logger": "0.87.0",
47
+ "ulid": "^3.0.2"
49
48
  },
50
49
  "peerDependencies": {
51
50
  "effect": "4.0.1"