@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,65 @@
1
+ import { createHash as e } from "node:crypto";
2
+ //#region src/changeIdentity.ts
3
+ var t = (e) => e == null ? "null" : e instanceof Date ? JSON.stringify(e.toISOString()) : typeof e == "bigint" ? JSON.stringify(e.toString()) : Array.isArray(e) ? `[${e.map(t).join(",")}]` : typeof e == "object" ? `{${Object.entries(e).filter(([, e]) => e !== void 0).sort(([e], [t]) => e < t ? -1 : +(e > t)).map(([e, n]) => `${JSON.stringify(e)}:${t(n)}`).join(",")}}` : JSON.stringify(e) ?? "null", n = (n) => e("sha256").update([
4
+ n.pipe,
5
+ n.op,
6
+ n.key,
7
+ t(n.next),
8
+ t(n.prev)
9
+ ].join("\0")).digest("hex").slice(0, 32), r = (e, t) => `${e}:${t}`, i = (e) => {
10
+ let t = e.lastIndexOf(":");
11
+ if (t <= 0) return null;
12
+ let n = Number(e.slice(t + 1));
13
+ return !Number.isInteger(n) || n < 0 ? null : {
14
+ digest: e.slice(0, t),
15
+ occurrence: n
16
+ };
17
+ }, a = class {
18
+ #e = /* @__PURE__ */ new Map();
19
+ #t;
20
+ #n;
21
+ constructor(e) {
22
+ this.#t = e.windowMs, this.#n = Math.max(1, e.maxEntries);
23
+ }
24
+ get size() {
25
+ return this.#e.size;
26
+ }
27
+ next(e, t) {
28
+ let n = this.#e.get(e);
29
+ if (n === void 0) return this.#e.set(e, {
30
+ count: 1,
31
+ lastMs: t
32
+ }), this.#r(), 0;
33
+ n.lastMs = t;
34
+ let r = n.count;
35
+ return n.count += 1, this.#e.delete(e), this.#e.set(e, n), r;
36
+ }
37
+ seedFromChangeKeys(e, t) {
38
+ for (let n of e) {
39
+ let e = i(n);
40
+ if (e === null) continue;
41
+ let r = this.#e.get(e.digest), a = Math.max(r?.count ?? 0, e.occurrence + 1);
42
+ this.#e.set(e.digest, {
43
+ count: a,
44
+ lastMs: r?.lastMs ?? t
45
+ });
46
+ }
47
+ this.#r();
48
+ }
49
+ prune(e) {
50
+ let t = e - this.#t;
51
+ for (let [e, n] of this.#e) n.lastMs < t && this.#e.delete(e);
52
+ }
53
+ #r() {
54
+ for (; this.#e.size > this.#n;) {
55
+ let e = this.#e.keys().next();
56
+ if (e.done === !0) return;
57
+ this.#e.delete(e.value);
58
+ }
59
+ }
60
+ }, o = "VOLTRO_CHANGE_CLAIMS_TTL_HOURS", s = 1, c = (e = process.env) => {
61
+ let t = Number(e[o]);
62
+ return (Number.isFinite(t) && t > 0 ? t : 1) * 2 * 36e5;
63
+ };
64
+ //#endregion
65
+ export { o as CHANGE_CLAIM_TTL_ENV, s as DEFAULT_CHANGE_CLAIM_TTL_HOURS, a as OccurrenceCounter, t as canonicalJson, n as changeDigest, r as composeChangeKey, c as occurrenceWindowMs, i as parseChangeKey };
@@ -0,0 +1,6 @@
1
+ //#region src/changeListenerCeiling.ts
2
+ var e = 512, t = (e) => {
3
+ e.setMaxListeners(512);
4
+ };
5
+ //#endregion
6
+ export { e as CHANGE_LISTENER_CEILING, t as raiseChangeListenerCeiling };
@@ -0,0 +1,17 @@
1
+ //#region src/columnReference.ts
2
+ var e = (e) => {
3
+ if (e.length === 0) throw RangeError("Column reference must not be empty");
4
+ return {
5
+ _tag: "ColumnReference",
6
+ column: e
7
+ };
8
+ }, t = (e) => typeof e == "object" && !!e && "_tag" in e && e._tag === "ColumnReference" && "column" in e && typeof e.column == "string", n = [
9
+ "eq",
10
+ "neq",
11
+ "gt",
12
+ "gte",
13
+ "lt",
14
+ "lte"
15
+ ];
16
+ //#endregion
17
+ export { n as columnComparisonOperators, e as columnRef, t as isColumnReference };
@@ -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,23 @@
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
+ fieldKeyIds: r().nullable()
18
+ }).renamedFrom("_voltro_data_imports").nonReactive(), c = (e) => {
19
+ 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)";
20
+ return `${t} · ${r} · via ${e.via}${i}` + (e.bundle === null ? "" : ` · from ${e.bundle}`) + (e.sourceFingerprint === null ? "" : ` · source schema ${e.sourceFingerprint}`);
21
+ };
22
+ //#endregion
23
+ export { o as DATA_TRANSFERS_TABLE, s as _voltroDataTransfersTable, c as describeTransferRun };