@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.
Files changed (170) hide show
  1. package/CHANGELOG.md +1215 -0
  2. package/THIRD-PARTY-NOTICES.md +5 -89
  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 +22 -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 +98 -0
  27. package/dist/frameworkTables.js +130 -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 +122 -64
  33. package/dist/index.js +81 -2080
  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 +624 -0
  43. package/dist/migration.js +18 -0
  44. package/dist/migrations/appliedAtValue.js +8 -0
  45. package/dist/migrations/applier.js +1085 -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/declaredSchema.js +162 -0
  51. package/dist/migrations/deployLedger.js +19 -0
  52. package/dist/migrations/fileBased.js +57 -0
  53. package/dist/migrations/fileContext.js +482 -0
  54. package/dist/migrations/fileDiscovery.js +318 -0
  55. package/dist/migrations/fileSkipProbes.js +117 -0
  56. package/dist/migrations/fingerprint.js +46 -0
  57. package/dist/migrations/fkCycles.js +13 -0
  58. package/dist/migrations/frameworkLiveTables.js +25 -0
  59. package/dist/migrations/idempotentDdl.js +37 -0
  60. package/dist/migrations/indexPredicate.js +50 -0
  61. package/dist/migrations/introspect.js +799 -0
  62. package/dist/migrations/ledgerRows.js +4 -0
  63. package/dist/migrations/lock.js +91 -0
  64. package/dist/migrations/migrationTableExists.js +9 -0
  65. package/dist/migrations/mssqlColumnDependencies.js +76 -0
  66. package/dist/migrations/mysqlEngine.js +11 -0
  67. package/dist/migrations/namespaceCharset.js +51 -0
  68. package/dist/migrations/planner.js +775 -0
  69. package/dist/migrations/postgresEnumCheck.js +19 -0
  70. package/dist/migrations/reactiveTriggerDrift.js +58 -0
  71. package/dist/migrations/reactiveTriggerName.js +7 -0
  72. package/dist/migrations/renameMssqlCheck.js +21 -0
  73. package/dist/migrations/restoreSnapshots.js +206 -0
  74. package/dist/migrations/resumeLedger.js +86 -0
  75. package/dist/migrations/rollingDeploy.js +106 -0
  76. package/dist/migrations/schemaOwner.js +46 -0
  77. package/dist/migrations/schemaOwnerTable.js +4 -0
  78. package/dist/migrations/softDropSnapshot.js +20 -0
  79. package/dist/migrations/sqlLimit.js +8 -0
  80. package/dist/migrations/sqliteConstraintIdentity.js +97 -0
  81. package/dist/migrations/sqliteDecimalBoot.js +22 -0
  82. package/dist/migrations/sqliteDecimalPublication.js +257 -0
  83. package/dist/migrations/sqliteDecimalReview.js +30 -0
  84. package/dist/migrations/sqliteDecimalReviewStore.js +188 -0
  85. package/dist/migrations/sqliteDecimalReviewWitness.js +38 -0
  86. package/dist/migrations/sqliteDecimalSource.js +69 -0
  87. package/dist/migrations/sqliteDecimalStage.js +135 -0
  88. package/dist/migrations/sqliteForeignKeys.js +38 -0
  89. package/dist/migrations/sqliteMigrationBatch.js +37 -0
  90. package/dist/migrations/sqliteRetainedSource.js +106 -0
  91. package/dist/migrations/sqliteRowIdentity.js +63 -0
  92. package/dist/migrations/sqliteSchemaEpoch.js +12 -0
  93. package/dist/migrations/sqliteSnapshotGuard.js +10 -0
  94. package/dist/migrations/sqliteTableContents.js +34 -0
  95. package/dist/migrations/sqliteTableCopy.js +25 -0
  96. package/dist/migrations/sqliteTableSchema.js +19 -0
  97. package/dist/migrations/sqliteWitnessProtection.js +8 -0
  98. package/dist/migrations/squash.js +81 -0
  99. package/dist/migrations/storeCharset.js +66 -0
  100. package/dist/migrations/transactionCause.js +10 -0
  101. package/dist/migrations/undeclaredCharset.js +40 -0
  102. package/dist/migrations/uniqueActiveLowering.js +39 -0
  103. package/dist/mixins.js +22 -0
  104. package/dist/mssqlDecimalDistinct.js +51 -0
  105. package/dist/mssqlJsonValueCheck.js +42 -0
  106. package/dist/mssqlTextStorage.js +9 -0
  107. package/dist/namespace.js +21 -0
  108. package/dist/{wire-B28cPjEp.js → optimisticVersion.js} +2 -2
  109. package/dist/pendingAttribution.js +79 -0
  110. package/dist/pluginRef.js +17 -0
  111. package/dist/predicate.js +266 -0
  112. package/dist/predicateCoercion.js +13 -0
  113. package/dist/projectedColumn.js +37 -0
  114. package/dist/queryBuilder.js +382 -0
  115. package/dist/rawSql.js +8 -0
  116. package/dist/relations.js +69 -0
  117. package/dist/relationsRegistry.js +38 -0
  118. package/dist/replaceInProgress.js +53 -0
  119. package/dist/requiredColumns.js +26 -0
  120. package/dist/residency.js +52 -0
  121. package/dist/retention.js +62 -0
  122. package/dist/rowDecoder.js +123 -0
  123. package/dist/rowKey.js +8 -0
  124. package/dist/rowSchema.js +31 -0
  125. package/dist/scopeKey.js +8 -0
  126. package/dist/seed.js +33 -0
  127. package/dist/snowflake.js +26 -0
  128. package/dist/sql.d.ts +58 -29
  129. package/dist/sql.js +41 -6661
  130. package/dist/sqlCompiler.js +343 -0
  131. package/dist/sqlError.js +8 -0
  132. package/dist/sqlPoolCapacity.js +12 -0
  133. package/dist/sqliteDecimal.js +22 -0
  134. package/dist/sqliteDecimalAggregateSql.js +61 -0
  135. package/dist/sqliteDecimalColumnSql.js +108 -0
  136. package/dist/sqliteDecimalConversion.js +15 -0
  137. package/dist/sqliteDecimalCte.js +154 -0
  138. package/dist/sqliteDecimalEncodeSql.js +32 -0
  139. package/dist/sqliteDecimalOutputs.js +74 -0
  140. package/dist/sqliteDecimalPredicate.js +66 -0
  141. package/dist/sqliteDecimalQuery.js +183 -0
  142. package/dist/sqliteDecimalQueryPlan.js +37 -0
  143. package/dist/sqliteDecimalResultSql.js +44 -0
  144. package/dist/sqliteDecimalRowQuery.js +63 -0
  145. package/dist/sqliteDecimalSetQuery.js +50 -0
  146. package/dist/sqliteDecimalSource.js +63 -0
  147. package/dist/sqliteDecimalStorage.js +29 -0
  148. package/dist/sqliteDecimalSubquery.js +19 -0
  149. package/dist/sqliteDecimalWindowQuery.js +196 -0
  150. package/dist/sqliteValueCoercion.js +4 -0
  151. package/dist/stampId.js +21 -0
  152. package/dist/storeErrors.js +9 -0
  153. package/dist/storeRefusal.js +20 -0
  154. package/dist/stream.js +36 -0
  155. package/dist/subjectGraph.js +175 -0
  156. package/dist/table.js +394 -0
  157. package/dist/tableRegistry.js +16 -0
  158. package/dist/tenantSelection.js +27 -0
  159. package/dist/transactionOutcome.js +97 -0
  160. package/dist/transientContention.js +36 -0
  161. package/dist/typedStore.js +16 -0
  162. package/dist/upsertUpdate.js +20 -0
  163. package/dist/vectorEmbedding.js +31 -0
  164. package/dist/view.js +39 -0
  165. package/dist/wire.d.ts +9 -10
  166. package/dist/wire.js +6 -2
  167. package/dist/writeAttribution.js +16 -0
  168. package/dist/writeRecorder.js +37 -0
  169. package/package.json +4 -6
  170. 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.Schema<Date, number>;
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.Schema<Date | null, number | null>;
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.TaggedErrorClass<VersionConflict, "VersionConflict", {
55
- readonly _tag: Schema.tag<"VersionConflict">;
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: typeof Schema.Number;
59
+ readonly expected: Schema.Number;
61
60
  /** What it is actually at. `null` when the row is gone entirely. */
62
- actual: Schema.NullOr<typeof Schema.Number>;
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 { i as e, n as t, t as n } from "./wire-B28cPjEp.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,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.84.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
- "@effect/experimental": "^0.61.1",
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
- "ulidx": "^2.4.1"
48
+ "ulid": "^3.0.2"
51
49
  },
52
50
  "peerDependencies": {
53
- "effect": "^3.22.2"
51
+ "effect": "4.0.1"
54
52
  },
55
53
  "publishConfig": {
56
54
  "access": "public"