@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 { isMysqlFamily as e } from "../dialect.js";
|
|
2
2
|
import { isSoftDropSnapshotName as t } from "./frameworkLiveTables.js";
|
|
3
|
-
|
|
3
|
+
// src/migrations/storeCharset.ts
|
|
4
4
|
var n = ["utf8mb3", "utf8mb4"], r = (e) => e === "utf8mb3" || e === "utf8mb4", i = (e) => {
|
|
5
5
|
switch (e.type) {
|
|
6
6
|
case "text":
|
|
@@ -62,5 +62,4 @@ var n = ["utf8mb3", "utf8mb4"], r = (e) => e === "utf8mb3" || e === "utf8mb4", i
|
|
|
62
62
|
case "mixed": return `${e.table}: its string columns are not in one character set — ${t}`;
|
|
63
63
|
}
|
|
64
64
|
}, d = "declare the store's character set in app.config.ts — store: { dialect: 'mariadb' | 'mysql', charset: 'utf8mb4' } — and run `voltro db plan`: every table the app declares is created with it and converted to it (a table rewrite; foreign keys are re-created around it). `utf8mb3` is accepted too, for a database that must stay there.";
|
|
65
|
-
//#endregion
|
|
66
65
|
export { n as MYSQL_CHARSETS, d as STORE_CHARSET_REMEDY, o as charsetColumnsOf, i as columnTakesCharset, u as describeStoreCharsetFinding, r as isMysqlCharset, a as stampDeclaredCharset, l as storeCharsetFindings };
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import { Cause as e, Effect as t, Equal as n } from "effect";
|
|
2
|
-
|
|
2
|
+
// src/migrations/transactionCause.ts
|
|
3
3
|
var r = (r, i) => t.suspend(() => {
|
|
4
4
|
let a;
|
|
5
5
|
return r.withTransaction(i.pipe(t.tapCause((e) => t.sync(() => {
|
|
6
6
|
a = e;
|
|
7
7
|
})))).pipe(t.catchCause((r) => t.failCause(a !== void 0 && !n.equals(a, r) ? e.combine(a, r) : r)));
|
|
8
8
|
});
|
|
9
|
-
//#endregion
|
|
10
9
|
export { r as withMigrationTransaction };
|
|
@@ -2,7 +2,7 @@ import { isFrameworkOwnedLiveTable as e, isSoftDropSnapshotName as t, isStagingT
|
|
|
2
2
|
import { withMigrationLock as r } from "./lock.js";
|
|
3
3
|
import { columnLevelChecksMysql as i } from "./applier.js";
|
|
4
4
|
import { Effect as a } from "effect";
|
|
5
|
-
|
|
5
|
+
// src/migrations/undeclaredCharset.ts
|
|
6
6
|
var o = "utf8mb4", s = (r, i) => e(r) && !i.has(r) && !r.startsWith("_cloud_") && !r.startsWith("__turso_internal_") && !t(r) && !n(r), c = (e) => e.columnDefault !== null && e.columnDefault.toUpperCase() !== "NULL", l = (e, t, n, r) => {
|
|
7
7
|
if (n !== o) return {
|
|
8
8
|
tables: [],
|
|
@@ -36,5 +36,4 @@ var o = "utf8mb4", s = (r, i) => e(r) && !i.has(r) && !r.startsWith("_cloud_") &
|
|
|
36
36
|
let n = l(yield* p(e), t.declaredNames, t.charset);
|
|
37
37
|
return yield* g(e, n), n;
|
|
38
38
|
}), { schema: t.lockSchema });
|
|
39
|
-
//#endregion
|
|
40
39
|
export { g as applyUndeclaredCharsetWork, _ as convergeUndeclaredCharset, d as describeUndeclaredCharsetWork, s as isUndeclaredCharsetTable, u as isUndeclaredCharsetWorkEmpty, p as readUndeclaredCharsetColumns, h as undeclaredCharsetStatements, l as undeclaredCharsetWork };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/migrations/uniqueActiveLowering.ts
|
|
2
2
|
var e = (e) => e.unique === !0 && typeof e.where == "string" && e.where.length > 0, t = (e) => e.replace(/"/g, "`"), n = (e) => typeof e == "string" ? e : e.name ?? String(e), r = (e, t) => `_ua_${t}_${e}`.slice(0, 64), i = (i, a) => {
|
|
3
3
|
if (a !== "mysql" && a !== "mariadb" || !i.appliedIndexes.some(e)) return i;
|
|
4
4
|
let o = { ...i.fields }, s = [], c = [];
|
|
@@ -35,5 +35,4 @@ var e = (e) => e.unique === !0 && typeof e.where == "string" && e.where.length >
|
|
|
35
35
|
appliedUniques: [...i.appliedUniques ?? [], ...c]
|
|
36
36
|
};
|
|
37
37
|
};
|
|
38
|
-
//#endregion
|
|
39
38
|
export { i as lowerUniqueActive };
|
package/dist/mixins.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { materializeFields as e } from "./columns.js";
|
|
2
|
-
|
|
2
|
+
// src/mixins.ts
|
|
3
3
|
var t = (t) => ({
|
|
4
4
|
fields: e(t.fields),
|
|
5
5
|
...t.id === void 0 ? {} : { id: t.id },
|
|
@@ -18,5 +18,4 @@ var t = (t) => ({
|
|
|
18
18
|
for (let t of e) r(t);
|
|
19
19
|
return n;
|
|
20
20
|
};
|
|
21
|
-
//#endregion
|
|
22
21
|
export { n as defineMixin, t as mixin, r as resolveMixinGraph };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { getTable as e } from "./tableRegistry.js";
|
|
2
2
|
import { prepareProjectedColumn as t } from "./projectedColumn.js";
|
|
3
|
-
|
|
3
|
+
// src/mssqlDecimalDistinct.ts
|
|
4
4
|
var n = (n) => {
|
|
5
5
|
if (!n.distinct && !n.distinctOn?.length || n.aggregations?.length || n.setOp) return;
|
|
6
6
|
let r = t(n), i = n.sourceTable?.tableName === n.table ? n.sourceTable : e(n.table), a = n.joinedProjection ?? (n.projection?.length ? n.projection : Object.keys(i?.fields ?? {})).map((e) => ({
|
|
@@ -47,5 +47,4 @@ var n = (n) => {
|
|
|
47
47
|
}]
|
|
48
48
|
};
|
|
49
49
|
};
|
|
50
|
-
//#endregion
|
|
51
50
|
export { n as mssqlDecimalDistinct };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/mssqlJsonValueCheck.ts
|
|
2
2
|
var e = (e) => {
|
|
3
3
|
let t = `(N'{"v":' + ${e} + N'}')`, n = `ISJSON(${t}) = 1`, r = `JSON_MODIFY(CASE WHEN ${n} THEN ${t} ELSE N'{}' END, '$.v', NULL)`;
|
|
4
4
|
return `(${e} IS NULL OR (${n} AND ${[
|
|
@@ -38,5 +38,4 @@ var e = (e) => {
|
|
|
38
38
|
let t = e.filter((e) => e.enabled);
|
|
39
39
|
return t.some((e) => e.validation === "container") ? t.some((e) => e.validation === "container" && e.trusted) ? "container" : "unverified" : t.some((e) => e.validation === "value" && e.trusted) ? "value" : "unverified";
|
|
40
40
|
};
|
|
41
|
-
//#endregion
|
|
42
41
|
export { n as classifyMssqlJsonCheck, r as mssqlJsonValidation, e as mssqlJsonValueCheck };
|
package/dist/mssqlTextStorage.js
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
// src/mssqlTextStorage.ts
|
|
2
2
|
var e = (e, t) => {
|
|
3
3
|
if (e.type === "text" && e.generatedAs === void 0) {
|
|
4
4
|
if (e.maxLength !== void 0) return e.maxLength;
|
|
5
5
|
if (t || e.hasDefault && e.defaultFactory === void 0 || e.oneOf !== void 0 && e.oneOf.length > 0) return 450;
|
|
6
6
|
}
|
|
7
7
|
};
|
|
8
|
-
//#endregion
|
|
9
8
|
export { e as mssqlTextStorageLength };
|
package/dist/namespace.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/namespace.ts
|
|
2
2
|
var e = class extends Error {
|
|
3
3
|
_tag = "TenantNamespaceUnresolved";
|
|
4
4
|
constructor(e) {
|
|
@@ -17,5 +17,4 @@ var e = class extends Error {
|
|
|
17
17
|
if (s.length > n) throw new t(`namespace '${s}' for tenant '${a}' exceeds the ${n}-byte identifier limit. Use a shorter tenant id.`);
|
|
18
18
|
return s;
|
|
19
19
|
}, o = (e, t) => e === null ? t : `${e}.${t}`;
|
|
20
|
-
//#endregion
|
|
21
20
|
export { t as TenantNamespaceInvalid, e as TenantNamespaceUnresolved, o as qualifyTable, a as resolveTenantNamespace, i as sanitizeIdentifierFragment };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Schema as e } from "effect";
|
|
2
|
-
|
|
2
|
+
// src/optimisticVersion.ts
|
|
3
3
|
var t = class extends e.TaggedError()("VersionConflict", {
|
|
4
4
|
table: e.String,
|
|
5
5
|
id: e.String,
|
|
@@ -28,5 +28,4 @@ var t = class extends e.TaggedError()("VersionConflict", {
|
|
|
28
28
|
actual: e.current
|
|
29
29
|
});
|
|
30
30
|
}, a = 1;
|
|
31
|
-
//#endregion
|
|
32
31
|
export { a as INITIAL_VERSION, t as VersionConflict, r as planVersionedUpdate, i as settleVersionedUpdate, n as versionColumnOf };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/pendingAttribution.ts
|
|
2
2
|
var e = 3e4, t = 1e4, n = /* @__PURE__ */ new Map(), r = [], i = (e, t) => {
|
|
3
3
|
let n = r[e];
|
|
4
4
|
r[e] = r[t], r[t] = n, r[e].heapIndex = e, n.heapIndex = t;
|
|
@@ -75,5 +75,4 @@ var e = 3e4, t = 1e4, n = /* @__PURE__ */ new Map(), r = [], i = (e, t) => {
|
|
|
75
75
|
for (let e of h.values()) clearTimeout(e);
|
|
76
76
|
h.clear(), m.clear();
|
|
77
77
|
}, S = () => r.length;
|
|
78
|
-
//#endregion
|
|
79
78
|
export { c as attributionKey, v as beginLocalWrite, d as claimPendingAttribution, x as clearPendingAttribution, y as endLocalWrite, S as pendingAttributionCount, u as registerPendingAttribution, b as resolveEchoAttribution };
|
package/dist/pluginRef.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ColumnBuilder as e, text as t } from "./columns.js";
|
|
2
|
-
|
|
2
|
+
// src/pluginRef.ts
|
|
3
3
|
var n = Symbol.for("@voltro/database/pluginRefSpec"), r = (e) => {
|
|
4
4
|
if (typeof e == "object" && e) return ("__definition" in e && typeof e.__definition == "function" ? e.__definition() : e)[n];
|
|
5
5
|
}, i = (r, i = {}) => {
|
|
@@ -13,5 +13,4 @@ var n = Symbol.for("@voltro/database/pluginRefSpec"), r = (e) => {
|
|
|
13
13
|
};
|
|
14
14
|
return new e(o);
|
|
15
15
|
};
|
|
16
|
-
//#endregion
|
|
17
16
|
export { i as pluginRef, r as pluginRefSpecOf };
|
package/dist/predicate.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { columnComparisonOperators as e, columnRef as t, isColumnReference as n } from "./columnReference.js";
|
|
2
2
|
import { authoredError as r } from "./dbCause.js";
|
|
3
3
|
import { compareDecimal as i } from "./decimalComparison.js";
|
|
4
|
-
|
|
4
|
+
// src/predicate.ts
|
|
5
5
|
var a = (e, t) => ({
|
|
6
6
|
column: e,
|
|
7
7
|
op: "eq",
|
|
@@ -129,7 +129,14 @@ var a = (e, t) => ({
|
|
|
129
129
|
if (n !== void 0) return n[0] === n[1] ? 0 : n[0] > n[1] ? 1 : -1;
|
|
130
130
|
let r = e instanceof Date ? e.getTime() : e, i = t instanceof Date ? t.getTime() : t;
|
|
131
131
|
return typeof r == typeof i ? r === i ? 0 : r > i ? 1 : -1 : null;
|
|
132
|
-
}, I = (e, t
|
|
132
|
+
}, I = (e, t) => {
|
|
133
|
+
let n = e;
|
|
134
|
+
for (let e of t) {
|
|
135
|
+
if (n == null) return;
|
|
136
|
+
n = typeof e == "number" ? Array.isArray(n) ? n[e] : void 0 : typeof n == "object" && !Array.isArray(n) && Object.hasOwn(n, e) ? n[e] : void 0;
|
|
137
|
+
}
|
|
138
|
+
return n;
|
|
139
|
+
}, L = (e, t) => e != null && t != null ? i(e, t) === 0 : P(e, t), R = (e, t, n = null, r = {}) => V(e, t, n, r) === !0, z = (e, t = null, n = {}) => {
|
|
133
140
|
let r = /* @__PURE__ */ new Map(), i = (e) => {
|
|
134
141
|
if ("not" in e) {
|
|
135
142
|
i(e.not);
|
|
@@ -158,8 +165,8 @@ var a = (e, t) => ({
|
|
|
158
165
|
let s = Array.prototype.filter.call(a, (e) => !(typeof e == "number" && Number.isNaN(e)));
|
|
159
166
|
r.set(e, new Set(s));
|
|
160
167
|
};
|
|
161
|
-
return i(e), (i) =>
|
|
162
|
-
},
|
|
168
|
+
return i(e), (i) => V(e, i, t, n, r) === !0;
|
|
169
|
+
}, B = (e, t, n) => {
|
|
163
170
|
if (e.length < 128 || t.length < 16 || Object.getPrototypeOf(e) !== Array.prototype || Object.getPrototypeOf(t) !== Array.prototype || Object.getOwnPropertyDescriptor(e, "includes") !== void 0 || Object.getOwnPropertyDescriptor(t, n) !== void 0) return;
|
|
164
171
|
for (let n of [e, t]) for (let e = 0; e < n.length; e += 1) {
|
|
165
172
|
let t = Object.getOwnPropertyDescriptor(n, String(e));
|
|
@@ -168,16 +175,16 @@ var a = (e, t) => ({
|
|
|
168
175
|
let r = /* @__PURE__ */ new Set();
|
|
169
176
|
for (let t = 0; t < e.length; t += 1) r.add(e[t]);
|
|
170
177
|
return r;
|
|
171
|
-
},
|
|
178
|
+
}, V = (t, a, o = null, s = {}, c) => {
|
|
172
179
|
if (!a) return !1;
|
|
173
180
|
if ("not" in t) {
|
|
174
|
-
let e =
|
|
181
|
+
let e = V(t.not, a, o, s, c);
|
|
175
182
|
return e === null ? null : !e;
|
|
176
183
|
}
|
|
177
184
|
if ("and" in t) {
|
|
178
185
|
let e = !1;
|
|
179
186
|
for (let n of t.and) {
|
|
180
|
-
let t =
|
|
187
|
+
let t = V(n, a, o, s, c);
|
|
181
188
|
if (t === !1) return !1;
|
|
182
189
|
t === null && (e = !0);
|
|
183
190
|
}
|
|
@@ -186,7 +193,7 @@ var a = (e, t) => ({
|
|
|
186
193
|
if ("or" in t) {
|
|
187
194
|
let e = !1;
|
|
188
195
|
for (let n of t.or) {
|
|
189
|
-
let t =
|
|
196
|
+
let t = V(n, a, o, s, c);
|
|
190
197
|
if (t === !0) return !0;
|
|
191
198
|
t === null && (e = !0);
|
|
192
199
|
}
|
|
@@ -204,7 +211,7 @@ var a = (e, t) => ({
|
|
|
204
211
|
let e = o.get(t.subquery), n = typeof e == "number" ? e > 0 : e instanceof Set && e.size > 0;
|
|
205
212
|
return t.op === "exists" ? n : !n;
|
|
206
213
|
}
|
|
207
|
-
let l = t, u = a[l.column], d = n(l.value) ? l.value : void 0;
|
|
214
|
+
let l = t, u = l.path === void 0 ? a[l.column] : I(a[l.column], l.path), d = n(l.value) ? l.value : void 0;
|
|
208
215
|
if (d !== void 0 && (!e.some((e) => e === l.op) || l.path !== void 0)) throw r("Column references require a scalar comparison without a JSON path");
|
|
209
216
|
let f = d === void 0 ? l.value : a[d.column];
|
|
210
217
|
if (d !== void 0 && (u == null || f == null)) return null;
|
|
@@ -213,7 +220,7 @@ var a = (e, t) => ({
|
|
|
213
220
|
let e = typeof u == "number" && Number.isNaN(u) ? !1 : m.has(u);
|
|
214
221
|
return l.op === "in" ? e : !e;
|
|
215
222
|
}
|
|
216
|
-
let h =
|
|
223
|
+
let h = p ? L : P, g = p ? i : F;
|
|
217
224
|
switch (l.op) {
|
|
218
225
|
case "eq": return h(u, f);
|
|
219
226
|
case "neq": return !h(u, f);
|
|
@@ -229,23 +236,23 @@ var a = (e, t) => ({
|
|
|
229
236
|
let e = Array.isArray(u) ? u : [], t = Array.isArray(f) ? f : [];
|
|
230
237
|
if (e.length < 128 || t.length < 16) return t.every((t) => e.includes(t));
|
|
231
238
|
let n, r = 0;
|
|
232
|
-
return t.every((i) => (++r === 5 && (n =
|
|
239
|
+
return t.every((i) => (++r === 5 && (n = B(e, t, "every")), n === void 0 ? e.includes(i) : n.has(i)));
|
|
233
240
|
}
|
|
234
241
|
case "arrayOverlaps": {
|
|
235
242
|
let e = Array.isArray(u) ? u : [], t = Array.isArray(f) ? f : [];
|
|
236
243
|
if (e.length < 128 || t.length < 16) return t.some((t) => e.includes(t));
|
|
237
244
|
let n, r = 0;
|
|
238
|
-
return t.some((i) => (++r === 5 && (n =
|
|
245
|
+
return t.some((i) => (++r === 5 && (n = B(e, t, "some")), n === void 0 ? e.includes(i) : n.has(i)));
|
|
239
246
|
}
|
|
240
247
|
case "arrayHas": return Array.isArray(u) && u.includes(f);
|
|
241
248
|
case "isNull": return u == null;
|
|
242
249
|
case "isNotNull": return u != null;
|
|
243
250
|
case "spatial": throw r("@voltro/plugin-postgis: spatial predicates (ST_DWithin / ST_Contains / ST_Within / ST_Intersects / bbox &&) are not evaluable in-memory — use them in one-shot ctx.store.query reads, not reactive subscriptions.");
|
|
244
251
|
}
|
|
245
|
-
},
|
|
246
|
-
if ("not" in e) yield*
|
|
247
|
-
else if ("and" in e) for (let t of e.and) yield*
|
|
248
|
-
else if ("or" in e) for (let t of e.or) yield*
|
|
252
|
+
}, H = function* (e) {
|
|
253
|
+
if ("not" in e) yield* H(e.not);
|
|
254
|
+
else if ("and" in e) for (let t of e.and) yield* H(t);
|
|
255
|
+
else if ("or" in e) for (let t of e.or) yield* H(t);
|
|
249
256
|
else e.op === "subquery-in" || e.op === "subquery-not-in" ? yield {
|
|
250
257
|
kind: "in",
|
|
251
258
|
descriptor: e.subquery
|
|
@@ -253,14 +260,13 @@ var a = (e, t) => ({
|
|
|
253
260
|
kind: "exists",
|
|
254
261
|
descriptor: e.subquery
|
|
255
262
|
});
|
|
256
|
-
},
|
|
257
|
-
if ("not" in e) yield*
|
|
258
|
-
else if ("and" in e) for (let n of e.and) yield*
|
|
259
|
-
else if ("or" in e) for (let t of e.or) yield*
|
|
263
|
+
}, U = function* (e, t = !0) {
|
|
264
|
+
if ("not" in e) yield* U(e.not, !1);
|
|
265
|
+
else if ("and" in e) for (let n of e.and) yield* U(n, t);
|
|
266
|
+
else if ("or" in e) for (let t of e.or) yield* U(t, !1);
|
|
260
267
|
else e.op !== "subquery-in" && e.op !== "subquery-not-in" && e.op !== "exists" && e.op !== "not-exists" && (yield {
|
|
261
268
|
...e,
|
|
262
269
|
conjunctive: t && !n(e.value)
|
|
263
270
|
});
|
|
264
271
|
};
|
|
265
|
-
|
|
266
|
-
export { v as MATCHES_NO_ROWS, S as and, h as arrayContains, _ as arrayHas, g as arrayOverlaps, B as collectSubqueries, t as columnRef, p as contains, a as eq, I as evaluatePredicate, k as exists, s as gt, c as gte, d as inSet, D as inSubquery, n as isColumnReference, b as isNotNull, y as isNull, T as jsonField, l as lt, u as lte, o as neq, w as not, A as notExists, f as notInSet, O as notInSubquery, C as or, L as preparePredicate, x as spatialPredicate, m as startsWith, V as walkLeaves };
|
|
272
|
+
export { v as MATCHES_NO_ROWS, S as and, h as arrayContains, _ as arrayHas, g as arrayOverlaps, H as collectSubqueries, t as columnRef, p as contains, a as eq, R as evaluatePredicate, k as exists, s as gt, c as gte, d as inSet, D as inSubquery, n as isColumnReference, b as isNotNull, y as isNull, T as jsonField, l as lt, u as lte, o as neq, w as not, A as notExists, f as notInSet, O as notInSubquery, C as or, z as preparePredicate, x as spatialPredicate, m as startsWith, U as walkLeaves };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/predicateCoercion.ts
|
|
2
2
|
var e = /* @__PURE__ */ new Set(["timestamp", "date"]), t = /^\d{4}-\d{2}-\d{2}([T ]\d{2}:\d{2})?/, n = (n, r) => {
|
|
3
3
|
if (n === void 0 || r == null || !e.has(n) || r instanceof Date) return r;
|
|
4
4
|
if (typeof r == "number" && Number.isFinite(r)) return new Date(r);
|
|
@@ -9,5 +9,4 @@ var e = /* @__PURE__ */ new Set(["timestamp", "date"]), t = /^\d{4}-\d{2}-\d{2}(
|
|
|
9
9
|
}
|
|
10
10
|
return r;
|
|
11
11
|
}, r = (t, r) => t === void 0 || !e.has(t) ? r : r.map((e) => n(t, e));
|
|
12
|
-
//#endregion
|
|
13
12
|
export { n as coercePredicateValue, r as coercePredicateValues };
|
package/dist/projectedColumn.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { getTable as e } from "./tableRegistry.js";
|
|
2
|
-
|
|
2
|
+
// src/projectedColumn.ts
|
|
3
3
|
var t = (t, n) => {
|
|
4
4
|
let r = t.lastIndexOf("."), i = r < 0 ? t : t.slice(r + 1), a = r < 0 ? void 0 : t.slice(0, r), o = a === void 0 || a === n.alias || a === n.table, s = o ? void 0 : n.joins?.find((e) => e.alias === a), c = o ? n.table : s?.table, l = o ? n.sourceTable : s?.sourceTable;
|
|
5
5
|
return (l?.tableName === c ? l : c === void 0 ? void 0 : e(c))?.fields[i];
|
|
@@ -33,5 +33,4 @@ var t = (t, n) => {
|
|
|
33
33
|
return (u?.tableName === l ? u : l === void 0 ? void 0 : e(l))?.fields[a];
|
|
34
34
|
};
|
|
35
35
|
};
|
|
36
|
-
//#endregion
|
|
37
36
|
export { n as prepareProjectedColumn, t as projectedColumn };
|
package/dist/queryBuilder.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { getTable as e, registerTable as t } from "./tableRegistry.js";
|
|
2
|
-
|
|
2
|
+
// src/queryBuilder.ts
|
|
3
3
|
var n = (e) => e.order ?? [], r = (e) => ({
|
|
4
4
|
op: "count",
|
|
5
5
|
alias: e ?? "count"
|
|
@@ -133,6 +133,12 @@ var n = (e) => e.order ?? [], r = (e) => ({
|
|
|
133
133
|
lock: "update"
|
|
134
134
|
});
|
|
135
135
|
},
|
|
136
|
+
forShare() {
|
|
137
|
+
return w({
|
|
138
|
+
...e,
|
|
139
|
+
lock: "share"
|
|
140
|
+
});
|
|
141
|
+
},
|
|
136
142
|
unscoped() {
|
|
137
143
|
return w({
|
|
138
144
|
...e,
|
|
@@ -378,5 +384,4 @@ var E = (e, t, n) => D(e, "id", t, n), D = (e, t, n, r, i = "asc") => {
|
|
|
378
384
|
for (let [r, i] of Object.entries(e)) t(i), n[r] = T(i);
|
|
379
385
|
return n;
|
|
380
386
|
};
|
|
381
|
-
//#endregion
|
|
382
387
|
export { o as avg, S as avgOver, l as column, r as count, i as countDistinct, O as databaseHandle, v as denseRank, m as except, p as intersect, y as lag, b as lead, c as max, s as min, n as orderClausesOf, D as paginateBy, E as paginateById, T as queryFor, _ as rank, C as resolveFullTextIndex, g as rowNumber, a as sum, x as sumOver, d as union, f as unionAll };
|
package/dist/rawSql.js
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
// src/rawSql.ts
|
|
2
2
|
var e = (e, ...t) => ({
|
|
3
3
|
_tag: "RawSqlFragment",
|
|
4
4
|
strings: [...e],
|
|
5
5
|
values: [...t]
|
|
6
6
|
}), t = (e) => typeof e == "object" && !!e && e._tag === "RawSqlFragment";
|
|
7
|
-
//#endregion
|
|
8
7
|
export { t as isRawSqlFragment, e as sql };
|
package/dist/relations.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { authoredError as e } from "./dbCause.js";
|
|
2
|
-
|
|
2
|
+
// src/relations.ts
|
|
3
3
|
var t = (e) => typeof e == "function" ? e : () => e, n = (e, n) => ({
|
|
4
4
|
kind: "one",
|
|
5
5
|
target: t(e),
|
|
@@ -65,5 +65,4 @@ var t = (e) => typeof e == "function" ? e : () => e, n = (e, n) => ({
|
|
|
65
65
|
}
|
|
66
66
|
}
|
|
67
67
|
};
|
|
68
|
-
//#endregion
|
|
69
68
|
export { f as inferForeignKey, s as isEmptyRelationsSpec, c as isRelationsSpec, u as many, d as manyToMany, l as one, o as relations, g as validateRelationConfig };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { getTable as e } from "./tableRegistry.js";
|
|
2
2
|
import { isRelationsSpec as t, validateRelationConfig as n } from "./relations.js";
|
|
3
|
-
|
|
3
|
+
// src/relationsRegistry.ts
|
|
4
4
|
var r = Symbol.for("@voltro/database/relationsRegistry"), i = globalThis, a = i[r] ?? (i[r] = /* @__PURE__ */ new Map()), o = (e) => {
|
|
5
5
|
let t = e.source(), n = a.get(t.tableName);
|
|
6
6
|
if (n === void 0) a.set(t.tableName, new Map(Object.entries(e.relations)));
|
|
@@ -34,5 +34,4 @@ var r = Symbol.for("@voltro/database/relationsRegistry"), i = globalThis, a = i[
|
|
|
34
34
|
}, f = () => {
|
|
35
35
|
a.clear();
|
|
36
36
|
};
|
|
37
|
-
//#endregion
|
|
38
37
|
export { u as allRegisteredRelations, f as clearRelationsRegistry, l as getRelation, c as getRelations, s as registerDiscoveredRelations, o as registerRelations, d as validateRegisteredRelations };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { boolean as e, id as t, text as n, timestamp as r } from "./columns.js";
|
|
2
2
|
import { table as i } from "./table.js";
|
|
3
|
-
|
|
3
|
+
// src/replaceInProgress.ts
|
|
4
4
|
var a = "_voltro_replace_in_progress", o = i(a, {
|
|
5
5
|
id: t({ prefix: "repl" }),
|
|
6
6
|
startedAt: r().default("now"),
|
|
@@ -49,5 +49,4 @@ ${e.all.map((e) => {
|
|
|
49
49
|
}).join("\n")}\n The target of a staged \`replace\` is untouched until one short swap at the end, so none of this is
|
|
50
50
|
a reason to refuse the boot — it is a reason to know the disk is holding a copy of a bundle.`;
|
|
51
51
|
};
|
|
52
|
-
//#endregion
|
|
53
52
|
export { a as REPLACE_IN_PROGRESS_TABLE, s as STAGING_STALE_MINUTES, o as _voltroReplaceInProgressTable, u as interruptedReplaceRefusal, f as stagingLeftoverReport, d as stagingLeftovers, l as stagingNamesOf, c as stagingStaleAfterMs };
|
package/dist/requiredColumns.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/requiredColumns.ts
|
|
2
2
|
var e = (e, t) => {
|
|
3
3
|
let n = [], r = t;
|
|
4
4
|
for (let [t, i] of Object.entries(e.fields)) {
|
|
@@ -22,5 +22,4 @@ var e = (e, t) => {
|
|
|
22
22
|
}));
|
|
23
23
|
return a;
|
|
24
24
|
};
|
|
25
|
-
//#endregion
|
|
26
25
|
export { t as missingConflictColumns, e as missingRequiredColumns };
|
package/dist/residency.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { resolveTenantNamespace as e } from "./namespace.js";
|
|
2
|
-
|
|
2
|
+
// src/residency.ts
|
|
3
3
|
var t = class extends Error {
|
|
4
4
|
_tag = "TenantResidencyUnresolved";
|
|
5
5
|
constructor(e) {
|
|
@@ -48,5 +48,4 @@ var t = class extends Error {
|
|
|
48
48
|
let { store: i, placement: a } = u(e, t, n);
|
|
49
49
|
return await r(i, a), a;
|
|
50
50
|
};
|
|
51
|
-
//#endregion
|
|
52
51
|
export { n as TenantRegionUnavailable, t as TenantResidencyUnresolved, u as bindResidentStore, o as clearResidencyConfig, a as getResidencyConfig, c as isRegionServable, d as provisionResidentTenant, l as residentPlacement, s as resolveTenantHome, i as setResidencyConfig };
|
package/dist/retention.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { and as e, isNull as t, lt as n, or as r } from "./predicate.js";
|
|
2
2
|
import { Effect as i, Metric as a } from "effect";
|
|
3
|
-
|
|
3
|
+
// src/retention.ts
|
|
4
4
|
var o = {
|
|
5
5
|
app: 3,
|
|
6
6
|
plugin: 2,
|
|
@@ -58,5 +58,4 @@ var o = {
|
|
|
58
58
|
let n = Number(e ?? String(t));
|
|
59
59
|
return (Number.isFinite(n) && n > 0 ? n : t) * 36e5;
|
|
60
60
|
};
|
|
61
|
-
//#endregion
|
|
62
61
|
export { f as clearRetentions, l as listRetentionConflicts, d as listRetentions, u as registerRetention, g as retentionTtlMsFromEnv, p as sweepRetention };
|
package/dist/rowDecoder.js
CHANGED
|
@@ -5,7 +5,7 @@ import { projectedColumn as i } from "./projectedColumn.js";
|
|
|
5
5
|
import { hasEncodedSqliteDecimalSource as a } from "./sqliteDecimalQueryPlan.js";
|
|
6
6
|
import { sqliteDecimalOutputs as o } from "./sqliteDecimalOutputs.js";
|
|
7
7
|
import { resolveSqliteDecimalSources as s } from "./sqliteDecimalCte.js";
|
|
8
|
-
|
|
8
|
+
// src/rowDecoder.ts
|
|
9
9
|
var c = (e) => e == null || typeof e == "boolean" ? e : typeof e == "number" ? e !== 0 : typeof e == "bigint" ? e !== 0n : typeof e == "string" ? e === "1" || e.toLowerCase() === "true" : e, l = (e) => {
|
|
10
10
|
if (e == null || typeof e != "string") return e;
|
|
11
11
|
let t = e.trim();
|
|
@@ -58,17 +58,25 @@ var c = (e) => e == null || typeof e == "boolean" ? e : typeof e == "number" ? e
|
|
|
58
58
|
}
|
|
59
59
|
}, g = (t, n, r, c) => {
|
|
60
60
|
if (t.length === 0) return t;
|
|
61
|
+
let l = c;
|
|
62
|
+
for (; l?.setOp !== void 0;) {
|
|
63
|
+
if (l.setOp.queries.length < 2) throw Error("A set operation requires at least two inputs");
|
|
64
|
+
l = l.setOp.queries[0];
|
|
65
|
+
}
|
|
66
|
+
if (c?.setOp && l) return g(t, l.table, r, l);
|
|
61
67
|
if (c && (r === "sqlite" || r === "turso") && a(c)) {
|
|
62
|
-
let e = o(s(c, void 0), void 0);
|
|
68
|
+
let e = o(s(c, void 0), void 0), n = (c.aggregations ?? []).filter((e) => v.has(e.op)).map((e) => e.alias);
|
|
63
69
|
return t.map((t) => {
|
|
64
|
-
let
|
|
70
|
+
let i = { ...t };
|
|
65
71
|
for (let t of e) {
|
|
66
72
|
let e = t.decimal ? "decimal" : t.definition?.type;
|
|
67
|
-
e && t.name in
|
|
73
|
+
e && t.name in i && (i[t.name] = m(i[t.name], e, r));
|
|
68
74
|
}
|
|
69
|
-
|
|
75
|
+
for (let e of n) e in i && (i[e] = S(i[e]));
|
|
76
|
+
return i;
|
|
70
77
|
});
|
|
71
78
|
}
|
|
79
|
+
if (c?.aggregations?.length) return C(t, c, r);
|
|
72
80
|
if (c?.joinedProjection?.length) {
|
|
73
81
|
let e = c.joinedProjection.map((e) => ({
|
|
74
82
|
outputKey: e.outputKey,
|
|
@@ -80,9 +88,51 @@ var c = (e) => e == null || typeof e == "boolean" ? e : typeof e == "number" ? e
|
|
|
80
88
|
return n;
|
|
81
89
|
});
|
|
82
90
|
}
|
|
83
|
-
let
|
|
84
|
-
return
|
|
85
|
-
}, _ = (e,
|
|
91
|
+
let u = c?.sourceTable?.tableName === n ? c.sourceTable : e(n);
|
|
92
|
+
return u === void 0 ? t : w(t, u, r);
|
|
93
|
+
}, _ = (e, t, n) => g(e, t.table, n, t), v = /* @__PURE__ */ new Set([
|
|
94
|
+
"count",
|
|
95
|
+
"count-distinct",
|
|
96
|
+
"window-row-number",
|
|
97
|
+
"window-rank",
|
|
98
|
+
"window-dense-rank"
|
|
99
|
+
]), y = /* @__PURE__ */ new Set(["sum", "window-sum-over"]), b = /* @__PURE__ */ new Set(["avg", "window-avg-over"]), x = (e) => e == null ? e : Number(e), S = (e) => {
|
|
100
|
+
if (e == null) return e;
|
|
101
|
+
let t = typeof e == "number" ? e : typeof e == "bigint" ? e <= BigInt(2 ** 53 - 1) ? Number(e) : NaN : typeof e == "string" && /^\d+$/.test(e) ? Number(e) : NaN;
|
|
102
|
+
if (!Number.isSafeInteger(t) || t < 0) throw RangeError(`aggregate counter ${String(e)} is not a non-negative safe integer`);
|
|
103
|
+
return t;
|
|
104
|
+
}, C = (e, t, n) => {
|
|
105
|
+
let r = (t.aggregations ?? []).map((e) => {
|
|
106
|
+
let r = e.column === void 0 ? void 0 : i(e.column, t);
|
|
107
|
+
if (v.has(e.op)) return {
|
|
108
|
+
alias: e.alias,
|
|
109
|
+
decode: S
|
|
110
|
+
};
|
|
111
|
+
if (b.has(e.op)) return {
|
|
112
|
+
alias: e.alias,
|
|
113
|
+
decode: x
|
|
114
|
+
};
|
|
115
|
+
if (y.has(e.op)) {
|
|
116
|
+
let t = r?.type === "decimal" || r?.type === "bigint";
|
|
117
|
+
return {
|
|
118
|
+
alias: e.alias,
|
|
119
|
+
decode: t ? (e) => m(e, r.type, n) : x
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
return r === void 0 ? {
|
|
123
|
+
alias: e.alias,
|
|
124
|
+
decode: (e) => e
|
|
125
|
+
} : {
|
|
126
|
+
alias: e.alias,
|
|
127
|
+
decode: f(r) ? d : (e) => m(e, r.type, n)
|
|
128
|
+
};
|
|
129
|
+
});
|
|
130
|
+
return e.map((e) => {
|
|
131
|
+
let t = { ...e };
|
|
132
|
+
for (let { alias: e, decode: n } of r) e in t && (t[e] = n(t[e]));
|
|
133
|
+
return t;
|
|
134
|
+
});
|
|
135
|
+
}, w = (e, n, i) => {
|
|
86
136
|
if (e.length === 0) return e;
|
|
87
137
|
let a = n.fields, o = [];
|
|
88
138
|
for (let [e, t] of Object.entries(a)) {
|
|
@@ -99,7 +149,7 @@ var c = (e) => e == null || typeof e == "boolean" ? e : typeof e == "number" ? e
|
|
|
99
149
|
for (let { key: e, type: r, decimalShape: a, numericId: s } of o) e in n && (n[e] = s ? d(n[e]) : a && n[e] !== null && n[e] !== void 0 ? t(n[e], a) : m(n[e], r, i));
|
|
100
150
|
return n;
|
|
101
151
|
});
|
|
102
|
-
},
|
|
152
|
+
}, T = (e, t) => {
|
|
103
153
|
if (e == null) return e;
|
|
104
154
|
switch (t) {
|
|
105
155
|
case "json": return JSON.stringify(e);
|
|
@@ -107,17 +157,16 @@ var c = (e) => e == null || typeof e == "boolean" ? e : typeof e == "number" ? e
|
|
|
107
157
|
case "vector": return typeof e == "string" ? e : JSON.stringify(e);
|
|
108
158
|
default: return e;
|
|
109
159
|
}
|
|
110
|
-
},
|
|
160
|
+
}, E = (t, i, a = ["json", "array"]) => {
|
|
111
161
|
let o = e(i);
|
|
112
162
|
if (o === void 0) return t;
|
|
113
163
|
let s = o.fields, c = null;
|
|
114
164
|
for (let [e, i] of Object.entries(s)) if (a.includes(i.type) && e in t) {
|
|
115
165
|
let a = i.type === "decimal" ? r(i) : void 0, o = t[e];
|
|
116
166
|
if (a && o != null && typeof o != "string") throw TypeError("Encoded decimal writes require exact decimal strings");
|
|
117
|
-
let s = a && typeof o == "string" ? n(o, a) :
|
|
167
|
+
let s = a && typeof o == "string" ? n(o, a) : T(o, i.type);
|
|
118
168
|
s !== t[e] && (c === null && (c = { ...t }), c[e] = s);
|
|
119
169
|
}
|
|
120
170
|
return c ?? t;
|
|
121
171
|
};
|
|
122
|
-
|
|
123
|
-
export { m as decodeCell, _ as decodeRowsForTable, g as decodeRowsFromSchema, y as encodeRowForSchema };
|
|
172
|
+
export { m as decodeCell, w as decodeRowsForTable, g as decodeRowsFromSchema, _ as decodeSelectRows, E as encodeRowForSchema };
|
package/dist/rowKey.js
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
// src/rowKey.ts
|
|
2
2
|
var e = (e) => typeof e == "string" || typeof e == "number" ? [["id", e]] : Object.entries(e).map(([e, t]) => [e, t]), t = (e) => {
|
|
3
3
|
if (typeof e == "string" || typeof e == "number") return String(e);
|
|
4
4
|
let t = Object.entries(e);
|
|
5
5
|
return t.length === 1 ? String(t[0][1]) : t.slice().sort(([e], [t]) => e < t ? -1 : +(e > t)).map(([e, t]) => `${e}=${String(t)}`).join("\0");
|
|
6
6
|
}, n = (e) => typeof e == "object";
|
|
7
|
-
//#endregion
|
|
8
7
|
export { n as isCompositeRowKey, e as rowKeyColumns, t as rowKeyIdentity };
|
package/dist/rowSchema.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { timestampMs as e } from "./wire.js";
|
|
2
2
|
import { Schema as t } from "effect";
|
|
3
|
-
|
|
3
|
+
// src/rowSchema.ts
|
|
4
4
|
var n = (n) => {
|
|
5
5
|
let r = (() => {
|
|
6
6
|
switch (n.type) {
|
|
@@ -27,5 +27,4 @@ var n = (n) => {
|
|
|
27
27
|
for (let [t, r] of Object.entries(e.fields)) i.has(t) || (a[t] = n(r));
|
|
28
28
|
return t.Struct(a);
|
|
29
29
|
};
|
|
30
|
-
//#endregion
|
|
31
30
|
export { n as columnSchema, r as rowSchema };
|
package/dist/scopeKey.js
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
// src/scopeKey.ts
|
|
2
2
|
var e = 255, t = (e) => e == null ? "null" : typeof e == "string" || typeof e == "number" || typeof e == "boolean" ? JSON.stringify(e) : 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(String(e)), n = (e) => {
|
|
3
3
|
if (e == null) return null;
|
|
4
4
|
let n = typeof e == "string" ? e : t(e);
|
|
5
5
|
return n.length > 255 ? n.slice(0, 255) : n;
|
|
6
6
|
};
|
|
7
|
-
//#endregion
|
|
8
7
|
export { e as SCOPE_KEY_MAX_LENGTH, n as scopeKeyOf };
|
package/dist/seed.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/seed.ts
|
|
2
2
|
var e = (e, t) => ({
|
|
3
3
|
name: e,
|
|
4
4
|
body: t
|
|
@@ -29,5 +29,4 @@ var e = (e, t) => ({
|
|
|
29
29
|
let t = i;
|
|
30
30
|
t !== null && e.changedTables.length !== 0 && await t(e);
|
|
31
31
|
};
|
|
32
|
-
//#endregion
|
|
33
32
|
export { t as defineSeed, c as fireSchemaChangeSeeds, s as fireTenantCreateSeeds, n as isSeedDefinition, o as setSchemaChangeSeedHook, a as setTenantCreateSeedHook };
|
package/dist/snowflake.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/snowflake.ts
|
|
2
2
|
var e = 10n, t = 12n, n = (1n << e) - 1n, r = (1n << t) - 1n, i = t, a = 22n, o = () => {
|
|
3
3
|
let e = process.env.SNOWFLAKE_MACHINE_ID;
|
|
4
4
|
if (e === void 0 || e === "") return 0n;
|
|
@@ -22,5 +22,4 @@ var e = 10n, t = 12n, n = (1n << e) - 1n, r = (1n << t) - 1n, i = t, a = 22n, o
|
|
|
22
22
|
if (n < 0n) throw Error("Snowflake timestamp before configured epoch (2024-01-01). System clock is wrong.");
|
|
23
23
|
return (n << a | e.machineId << i | e.sequence).toString();
|
|
24
24
|
};
|
|
25
|
-
//#endregion
|
|
26
25
|
export { p as generateSnowflake, u as resetSnowflake };
|