@klum-db/lobby 0.2.0-pre.32 → 0.3.0-pre.1
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/README.md +18 -0
- package/dist/bin/klum.cjs.map +1 -1
- package/dist/bin/klum.d.cts +2 -3
- package/dist/bin/klum.d.ts +2 -3
- package/dist/bin/klum.js.map +1 -1
- package/dist/index.cjs +168 -117
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +11 -11
- package/dist/index.d.ts +11 -11
- package/dist/index.js +97 -47
- package/dist/index.js.map +1 -1
- package/dist/{vault-group-BchRCDm5.d.cts → vault-group-D0EC-D5c.d.cts} +32 -11
- package/dist/{vault-group-BchRCDm5.d.ts → vault-group-D0EC-D5c.d.ts} +32 -11
- package/package.json +15 -14
package/dist/index.cjs
CHANGED
|
@@ -129,13 +129,13 @@ async function writeMultiVaultBundle(compartments, opts = {}) {
|
|
|
129
129
|
const inner = [];
|
|
130
130
|
const entries = [];
|
|
131
131
|
for (const c of compartments) {
|
|
132
|
-
const innerBytes = await (0,
|
|
133
|
-
const header = (0,
|
|
132
|
+
const innerBytes = await (0, import_pod.writePod)(c.vault, c.bundleOptions ?? {});
|
|
133
|
+
const header = (0, import_pod.readPodHeader)(innerBytes);
|
|
134
134
|
const entry = {
|
|
135
135
|
handle: header.handle,
|
|
136
136
|
exportedAt: c.exportedAt ?? (/* @__PURE__ */ new Date()).toISOString(),
|
|
137
137
|
innerBytes: innerBytes.length,
|
|
138
|
-
innerSha256: await (0,
|
|
138
|
+
innerSha256: await (0, import_cargo.sha256Hex)(innerBytes)
|
|
139
139
|
};
|
|
140
140
|
if (c.roleTag !== void 0) entry.roleTag = c.roleTag;
|
|
141
141
|
if (c.disclose?.name !== void 0 && c.disclose.name !== false) {
|
|
@@ -158,7 +158,7 @@ async function writeMultiVaultBundle(compartments, opts = {}) {
|
|
|
158
158
|
}
|
|
159
159
|
const manifest = {
|
|
160
160
|
multiFormatVersion: NOYDB_MULTI_BUNDLE_VERSION,
|
|
161
|
-
handle: opts.handle ?? (0,
|
|
161
|
+
handle: opts.handle ?? (0, import_cargo.generateULID)(),
|
|
162
162
|
compartments: entries
|
|
163
163
|
};
|
|
164
164
|
return encodeMultiBundle(manifest, inner);
|
|
@@ -166,12 +166,12 @@ async function writeMultiVaultBundle(compartments, opts = {}) {
|
|
|
166
166
|
async function readNoydbBundleManifest(bytes) {
|
|
167
167
|
if (hasMultiMagic(bytes)) return [...decodeMultiBundle(bytes).manifest.compartments];
|
|
168
168
|
if ((0, import_hub.hasNoydbBundleMagic)(bytes)) {
|
|
169
|
-
const header = (0,
|
|
169
|
+
const header = (0, import_pod.readPodHeader)(bytes);
|
|
170
170
|
const env = (0, import_hub.readNoydbBundlePublicEnvelope)(bytes);
|
|
171
171
|
const entry = {
|
|
172
172
|
handle: header.handle,
|
|
173
173
|
innerBytes: bytes.length,
|
|
174
|
-
innerSha256: await (0,
|
|
174
|
+
innerSha256: await (0, import_cargo.sha256Hex)(bytes)
|
|
175
175
|
};
|
|
176
176
|
if (env !== void 0) entry.publicEnvelope = env;
|
|
177
177
|
return [entry];
|
|
@@ -183,7 +183,7 @@ function readMultiVaultBundleCompartment(bytes, selector) {
|
|
|
183
183
|
throw new Error(`readMultiVaultBundleCompartment: numeric selector must be an integer, got ${selector}.`);
|
|
184
184
|
}
|
|
185
185
|
if ((0, import_hub.hasNoydbBundleMagic)(bytes) && !hasMultiMagic(bytes)) {
|
|
186
|
-
const header = (0,
|
|
186
|
+
const header = (0, import_pod.readPodHeader)(bytes);
|
|
187
187
|
if (selector === 0 || selector === header.handle) return bytes;
|
|
188
188
|
throw new Error(`readMultiVaultBundleCompartment: single v1 bundle has only compartment "${header.handle}".`);
|
|
189
189
|
}
|
|
@@ -192,12 +192,12 @@ function readMultiVaultBundleCompartment(bytes, selector) {
|
|
|
192
192
|
if (idx < 0 || idx >= inner.length) throw new Error(`readMultiVaultBundleCompartment: no compartment ${typeof selector === "number" ? `at index ${selector}` : `"${selector}"`}.`);
|
|
193
193
|
return inner[idx];
|
|
194
194
|
}
|
|
195
|
-
var
|
|
195
|
+
var import_cargo, import_pod, import_hub, NOYDB_MULTI_BUNDLE_MAGIC, NOYDB_MULTI_BUNDLE_PREFIX_BYTES, NOYDB_MULTI_BUNDLE_VERSION;
|
|
196
196
|
var init_multi_bundle = __esm({
|
|
197
197
|
"src/bundle/multi-bundle.ts"() {
|
|
198
198
|
"use strict";
|
|
199
|
-
|
|
200
|
-
|
|
199
|
+
import_cargo = require("@noy-db/hub/cargo");
|
|
200
|
+
import_pod = require("@noy-db/hub/pod");
|
|
201
201
|
import_hub = require("@noy-db/hub");
|
|
202
202
|
init_uint32();
|
|
203
203
|
NOYDB_MULTI_BUNDLE_MAGIC = new Uint8Array([78, 68, 66, 77]);
|
|
@@ -271,7 +271,7 @@ async function walkCrossVaultClosure(openVault, opts) {
|
|
|
271
271
|
for (const vaultName of batch) {
|
|
272
272
|
const seeds = perVaultSeeds.get(vaultName);
|
|
273
273
|
const v = await openVault(vaultName);
|
|
274
|
-
const { closure } = await (0,
|
|
274
|
+
const { closure } = await (0, import_bundle.walkClosure)(v, {
|
|
275
275
|
seeds,
|
|
276
276
|
...opts.maxDepth !== void 0 ? { maxDepth: opts.maxDepth } : {}
|
|
277
277
|
});
|
|
@@ -323,20 +323,20 @@ async function extractCrossVaultPartition(openVault, opts) {
|
|
|
323
323
|
const sealIds = {};
|
|
324
324
|
for (const [vaultName, seeds] of plan.perVaultSeeds) {
|
|
325
325
|
const v = await openVault(vaultName);
|
|
326
|
-
const { bundleBytes, transferKey, sealId } = await (0,
|
|
326
|
+
const { bundleBytes, transferKey, sealId } = await (0, import_bundle.extractPartition)(v, {
|
|
327
327
|
seeds,
|
|
328
328
|
...opts.maxDepth !== void 0 ? { maxDepth: opts.maxDepth } : {},
|
|
329
329
|
carrySchemas: opts.carrySchemas ?? true,
|
|
330
330
|
carryLedger: opts.carryLedger ?? false,
|
|
331
331
|
...opts.compression !== void 0 ? { compression: opts.compression } : {}
|
|
332
332
|
});
|
|
333
|
-
const header = (0,
|
|
333
|
+
const header = (0, import_pod2.readPodHeader)(bundleBytes);
|
|
334
334
|
const meta = opts.compartmentMeta?.[vaultName];
|
|
335
335
|
const entry = {
|
|
336
336
|
handle: header.handle,
|
|
337
337
|
exportedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
338
338
|
innerBytes: bundleBytes.length,
|
|
339
|
-
innerSha256: await (0,
|
|
339
|
+
innerSha256: await (0, import_cargo2.sha256Hex)(bundleBytes)
|
|
340
340
|
};
|
|
341
341
|
if (meta?.roleTag !== void 0) entry.roleTag = meta.roleTag;
|
|
342
342
|
if (meta?.disclose?.name !== void 0 && meta.disclose.name !== false) {
|
|
@@ -355,7 +355,7 @@ async function extractCrossVaultPartition(openVault, opts) {
|
|
|
355
355
|
}
|
|
356
356
|
const manifest = {
|
|
357
357
|
multiFormatVersion: NOYDB_MULTI_BUNDLE_VERSION,
|
|
358
|
-
handle: (0,
|
|
358
|
+
handle: (0, import_cargo2.generateULID)(),
|
|
359
359
|
compartments
|
|
360
360
|
};
|
|
361
361
|
return { bundle: encodeMultiBundle(manifest, inner), transferKeys, sealIds };
|
|
@@ -365,7 +365,7 @@ async function describeCrossVaultExtraction(openVault, opts) {
|
|
|
365
365
|
const compartments = [];
|
|
366
366
|
for (const [vaultName, seeds] of plan.perVaultSeeds) {
|
|
367
367
|
const v = await openVault(vaultName);
|
|
368
|
-
const preview = await (0,
|
|
368
|
+
const preview = await (0, import_bundle.describeExtraction)(v, {
|
|
369
369
|
seeds,
|
|
370
370
|
...opts.maxDepth !== void 0 ? { maxDepth: opts.maxDepth } : {}
|
|
371
371
|
});
|
|
@@ -373,12 +373,13 @@ async function describeCrossVaultExtraction(openVault, opts) {
|
|
|
373
373
|
}
|
|
374
374
|
return { compartments, dangling: plan.dangling };
|
|
375
375
|
}
|
|
376
|
-
var
|
|
376
|
+
var import_bundle, import_pod2, import_cargo2, CrossVaultDanglingRefError;
|
|
377
377
|
var init_extract_cross_vault = __esm({
|
|
378
378
|
"src/interchange/extract-cross-vault.ts"() {
|
|
379
379
|
"use strict";
|
|
380
|
-
|
|
381
|
-
|
|
380
|
+
import_bundle = require("@noy-db/hub/bundle");
|
|
381
|
+
import_pod2 = require("@noy-db/hub/pod");
|
|
382
|
+
import_cargo2 = require("@noy-db/hub/cargo");
|
|
382
383
|
init_multi_bundle();
|
|
383
384
|
CrossVaultDanglingRefError = class extends Error {
|
|
384
385
|
constructor(dangling) {
|
|
@@ -464,7 +465,7 @@ async function mergeDecryptedRecords(receiver, decrypted, opts) {
|
|
|
464
465
|
incomingSource.set(coll, srcMap);
|
|
465
466
|
incomingSourceTs.set(coll, stsMap);
|
|
466
467
|
}
|
|
467
|
-
const diff = await (0,
|
|
468
|
+
const diff = await (0, import_cargo3.diffVault)(receiver, candidate);
|
|
468
469
|
const byCollection = {};
|
|
469
470
|
const conflicts = [];
|
|
470
471
|
const writes = [];
|
|
@@ -580,15 +581,15 @@ async function mergeDecryptedRecords(receiver, decrypted, opts) {
|
|
|
580
581
|
};
|
|
581
582
|
}
|
|
582
583
|
async function mergeCompartment(receiver, compartmentBytes, opts) {
|
|
583
|
-
const incoming = await (0,
|
|
584
|
+
const incoming = await (0, import_bundle2.decryptExtractedPartition)(compartmentBytes, opts.transferKey);
|
|
584
585
|
return mergeDecryptedRecords(receiver, incoming, opts);
|
|
585
586
|
}
|
|
586
|
-
var
|
|
587
|
+
var import_cargo3, import_bundle2, FieldLevelDeferredError;
|
|
587
588
|
var init_merge_compartment = __esm({
|
|
588
589
|
"src/interchange/merge-compartment.ts"() {
|
|
589
590
|
"use strict";
|
|
590
|
-
|
|
591
|
-
|
|
591
|
+
import_cargo3 = require("@noy-db/hub/cargo");
|
|
592
|
+
import_bundle2 = require("@noy-db/hub/bundle");
|
|
592
593
|
init_field_authority();
|
|
593
594
|
FieldLevelDeferredError = class extends Error {
|
|
594
595
|
constructor(collection) {
|
|
@@ -684,7 +685,7 @@ async function graduate(noydb, docked, opts) {
|
|
|
684
685
|
await mergeDecryptedRecords(vault, staged, { strategy: "take-incoming", reason: "dock:graduate" });
|
|
685
686
|
let deedSealed = false;
|
|
686
687
|
if (opts.deed) {
|
|
687
|
-
await (0,
|
|
688
|
+
await (0, import_cargo4.createDeedOwner)(noydb._store, opts.vaultName, opts.deed.ownerId, opts.deed.sealingProvider);
|
|
688
689
|
deedSealed = true;
|
|
689
690
|
}
|
|
690
691
|
if (opts.stateVault) {
|
|
@@ -704,11 +705,11 @@ async function graduate(noydb, docked, opts) {
|
|
|
704
705
|
event: { type: "unit-graduated", unitId: docked.unitId, vault: opts.vaultName }
|
|
705
706
|
};
|
|
706
707
|
}
|
|
707
|
-
var
|
|
708
|
+
var import_cargo4, UnitGraduationError, ISO_EPOCH;
|
|
708
709
|
var init_graduate = __esm({
|
|
709
710
|
"src/dock/graduate.ts"() {
|
|
710
711
|
"use strict";
|
|
711
|
-
|
|
712
|
+
import_cargo4 = require("@noy-db/hub/cargo");
|
|
712
713
|
init_merge_compartment();
|
|
713
714
|
init_stage_records();
|
|
714
715
|
UnitGraduationError = class extends Error {
|
|
@@ -738,7 +739,7 @@ __export(surface_exports, {
|
|
|
738
739
|
async function proposeSurface(smv, def, proposedBy, now) {
|
|
739
740
|
const row = {
|
|
740
741
|
...def,
|
|
741
|
-
id: def.id ?? (0,
|
|
742
|
+
id: def.id ?? (0, import_cargo5.generateULID)(),
|
|
742
743
|
status: "proposed",
|
|
743
744
|
proposedBy,
|
|
744
745
|
createdAt: now
|
|
@@ -759,7 +760,7 @@ async function exportSurface(source, surface) {
|
|
|
759
760
|
throw new SurfaceStateError(surface.id, surface.status, "agreed");
|
|
760
761
|
}
|
|
761
762
|
const seeds = Object.fromEntries(surface.collections.map((c) => [c, () => true]));
|
|
762
|
-
const { bundleBytes, transferKey } = await (0,
|
|
763
|
+
const { bundleBytes, transferKey } = await (0, import_bundle4.extractPartition)(source, {
|
|
763
764
|
seeds,
|
|
764
765
|
maxDepth: 0,
|
|
765
766
|
...surface.fields ? { fieldProjection: surface.fields } : {},
|
|
@@ -797,12 +798,12 @@ async function markSynced(smv, id, now) {
|
|
|
797
798
|
nextSyncDueAt: now + cadenceMs
|
|
798
799
|
});
|
|
799
800
|
}
|
|
800
|
-
var
|
|
801
|
+
var import_cargo5, import_bundle4, SurfaceNotFoundError, SurfaceStateError, SurfaceCadenceScheduler;
|
|
801
802
|
var init_surface = __esm({
|
|
802
803
|
"src/interchange/surface.ts"() {
|
|
803
804
|
"use strict";
|
|
804
|
-
|
|
805
|
-
|
|
805
|
+
import_cargo5 = require("@noy-db/hub/cargo");
|
|
806
|
+
import_bundle4 = require("@noy-db/hub/bundle");
|
|
806
807
|
init_merge_compartment();
|
|
807
808
|
SurfaceNotFoundError = class extends Error {
|
|
808
809
|
name = "SurfaceNotFoundError";
|
|
@@ -907,38 +908,38 @@ function canonical(value) {
|
|
|
907
908
|
return `{${keys.map((k) => `${JSON.stringify(k)}:${canonical(obj[k])}`).join(",")}}`;
|
|
908
909
|
}
|
|
909
910
|
async function fingerprintBlueprint(bp) {
|
|
910
|
-
return (0,
|
|
911
|
+
return (0, import_cargo6.sha256Hex)(new TextEncoder().encode(canonical(bp)));
|
|
911
912
|
}
|
|
912
|
-
var
|
|
913
|
+
var import_cargo6;
|
|
913
914
|
var init_schema_manifest = __esm({
|
|
914
915
|
"src/federation/schema-manifest.ts"() {
|
|
915
916
|
"use strict";
|
|
916
|
-
|
|
917
|
+
import_cargo6 = require("@noy-db/hub/cargo");
|
|
917
918
|
}
|
|
918
919
|
});
|
|
919
920
|
|
|
920
921
|
// src/federation/constants.ts
|
|
921
|
-
var
|
|
922
|
+
var import_cargo7;
|
|
922
923
|
var init_constants = __esm({
|
|
923
924
|
"src/federation/constants.ts"() {
|
|
924
925
|
"use strict";
|
|
925
|
-
|
|
926
|
+
import_cargo7 = require("@noy-db/hub/cargo");
|
|
926
927
|
}
|
|
927
928
|
});
|
|
928
929
|
|
|
929
930
|
// src/federation/state-vault.ts
|
|
930
931
|
var state_vault_exports = {};
|
|
931
932
|
__export(state_vault_exports, {
|
|
932
|
-
STATE_VAULT_NAME: () =>
|
|
933
|
+
STATE_VAULT_NAME: () => import_cargo7.STATE_VAULT_NAME,
|
|
933
934
|
StateManagementVault: () => StateManagementVault
|
|
934
935
|
});
|
|
935
|
-
var
|
|
936
|
+
var import_cargo8, REGISTRY, MANIFEST, EVENTS, MIGRATION_STATUS, SURFACES, StateManagementVault;
|
|
936
937
|
var init_state_vault = __esm({
|
|
937
938
|
"src/federation/state-vault.ts"() {
|
|
938
939
|
"use strict";
|
|
939
940
|
init_schema_manifest();
|
|
940
941
|
init_constants();
|
|
941
|
-
|
|
942
|
+
import_cargo8 = require("@noy-db/hub/cargo");
|
|
942
943
|
init_constants();
|
|
943
944
|
REGISTRY = "vaultRegistry";
|
|
944
945
|
MANIFEST = "schemaManifest";
|
|
@@ -968,7 +969,7 @@ var init_state_vault = __esm({
|
|
|
968
969
|
#surfaces;
|
|
969
970
|
/** Idempotently open the reserved state vault and bind the control-plane collections. */
|
|
970
971
|
static async open(db) {
|
|
971
|
-
const vault = await db.openVault(
|
|
972
|
+
const vault = await db.openVault(import_cargo7.STATE_VAULT_NAME);
|
|
972
973
|
return new _StateManagementVault(
|
|
973
974
|
vault.collection(REGISTRY),
|
|
974
975
|
vault.collection(MANIFEST),
|
|
@@ -1028,7 +1029,7 @@ var init_state_vault = __esm({
|
|
|
1028
1029
|
*/
|
|
1029
1030
|
async appendEvent(event) {
|
|
1030
1031
|
const ts = event.ts ?? Date.now();
|
|
1031
|
-
const id = (0,
|
|
1032
|
+
const id = (0, import_cargo8.generateULID)();
|
|
1032
1033
|
await this.#events.put(id, { ...event, id, ts });
|
|
1033
1034
|
}
|
|
1034
1035
|
/**
|
|
@@ -1070,13 +1071,13 @@ var init_state_vault = __esm({
|
|
|
1070
1071
|
|
|
1071
1072
|
// src/federation/classify-skip.ts
|
|
1072
1073
|
function classifyShardSkip(err) {
|
|
1073
|
-
return err instanceof
|
|
1074
|
+
return err instanceof import_cargo9.NoAccessError ? "no-grant" : "error";
|
|
1074
1075
|
}
|
|
1075
|
-
var
|
|
1076
|
+
var import_cargo9;
|
|
1076
1077
|
var init_classify_skip = __esm({
|
|
1077
1078
|
"src/federation/classify-skip.ts"() {
|
|
1078
1079
|
"use strict";
|
|
1079
|
-
|
|
1080
|
+
import_cargo9 = require("@noy-db/hub/cargo");
|
|
1080
1081
|
}
|
|
1081
1082
|
});
|
|
1082
1083
|
|
|
@@ -1101,7 +1102,7 @@ async function applyBroadcastLegs(rows, legs) {
|
|
|
1101
1102
|
for (const leg of legs) {
|
|
1102
1103
|
const map = /* @__PURE__ */ new Map();
|
|
1103
1104
|
for (const rec of await leg.from.list()) {
|
|
1104
|
-
const k = coerceKey((0,
|
|
1105
|
+
const k = coerceKey((0, import_cargo10.readPath)(rec, leg.on));
|
|
1105
1106
|
if (k !== null && !map.has(k)) map.set(k, rec);
|
|
1106
1107
|
}
|
|
1107
1108
|
indexes.push({ leg, map });
|
|
@@ -1109,7 +1110,7 @@ async function applyBroadcastLegs(rows, legs) {
|
|
|
1109
1110
|
return rows.map((row) => {
|
|
1110
1111
|
const out = { ...row };
|
|
1111
1112
|
for (const { leg, map } of indexes) {
|
|
1112
|
-
const key = coerceKey((0,
|
|
1113
|
+
const key = coerceKey((0, import_cargo10.readPath)(row, leg.field));
|
|
1113
1114
|
const match = key === null ? null : map.get(key) ?? null;
|
|
1114
1115
|
if (match === null && leg.mode === "warn") {
|
|
1115
1116
|
warnOnceBroadcastMiss(leg.field, leg.as, key ?? "<null>");
|
|
@@ -1119,11 +1120,11 @@ async function applyBroadcastLegs(rows, legs) {
|
|
|
1119
1120
|
return out;
|
|
1120
1121
|
});
|
|
1121
1122
|
}
|
|
1122
|
-
var
|
|
1123
|
+
var import_cargo10, warnedBroadcastKeys;
|
|
1123
1124
|
var init_cross_shard_join = __esm({
|
|
1124
1125
|
"src/federation/cross-shard-join.ts"() {
|
|
1125
1126
|
"use strict";
|
|
1126
|
-
|
|
1127
|
+
import_cargo10 = require("@noy-db/hub/cargo");
|
|
1127
1128
|
warnedBroadcastKeys = /* @__PURE__ */ new Set();
|
|
1128
1129
|
}
|
|
1129
1130
|
});
|
|
@@ -1223,28 +1224,33 @@ var init_insight_auto_push = __esm({
|
|
|
1223
1224
|
"src/federation/insight-auto-push.ts"() {
|
|
1224
1225
|
"use strict";
|
|
1225
1226
|
InsightAutoPush = class {
|
|
1226
|
-
constructor(recompute, isSource, onError = (err, pk) => console.warn(`[klum-db] insight auto-push failed for shard "${pk}":`, err)) {
|
|
1227
|
+
constructor(recompute, isSource, onError = (err, pk) => console.warn(`[klum-db] insight auto-push failed for shard "${pk}":`, err), debounceMs) {
|
|
1227
1228
|
this.recompute = recompute;
|
|
1228
1229
|
this.isSource = isSource;
|
|
1229
1230
|
this.onError = onError;
|
|
1231
|
+
this.debounceMs = debounceMs;
|
|
1230
1232
|
}
|
|
1231
1233
|
recompute;
|
|
1232
1234
|
isSource;
|
|
1233
1235
|
onError;
|
|
1234
|
-
|
|
1236
|
+
debounceMs;
|
|
1235
1237
|
dirty = /* @__PURE__ */ new Set();
|
|
1236
|
-
/** The in-flight flush, or null when idle. */
|
|
1237
1238
|
pending = null;
|
|
1239
|
+
timer = null;
|
|
1240
|
+
resolvePending = null;
|
|
1241
|
+
flushing = false;
|
|
1238
1242
|
/** Called from a shard's onAfterWrite hook. Marks the shard dirty + schedules a flush. */
|
|
1239
1243
|
noteWrite(partitionKey, collection) {
|
|
1240
1244
|
if (!this.isSource(collection)) return;
|
|
1241
1245
|
this.dirty.add(partitionKey);
|
|
1242
|
-
this.
|
|
1246
|
+
if (this.debounceMs !== void 0) this.scheduleDebounced();
|
|
1247
|
+
else this.schedule();
|
|
1243
1248
|
}
|
|
1244
1249
|
/** Resolve once no flush is pending (drains rescheduled flushes too). */
|
|
1245
1250
|
async whenSettled() {
|
|
1246
1251
|
while (this.pending) await this.pending;
|
|
1247
1252
|
}
|
|
1253
|
+
// ── microtask path (unchanged default) ──
|
|
1248
1254
|
schedule() {
|
|
1249
1255
|
if (this.pending) return;
|
|
1250
1256
|
this.pending = this.runFlush().finally(() => {
|
|
@@ -1252,6 +1258,29 @@ var init_insight_auto_push = __esm({
|
|
|
1252
1258
|
if (this.dirty.size > 0) this.schedule();
|
|
1253
1259
|
});
|
|
1254
1260
|
}
|
|
1261
|
+
// ── debounce path (#13) ──
|
|
1262
|
+
scheduleDebounced() {
|
|
1263
|
+
if (!this.pending) this.pending = new Promise((r) => {
|
|
1264
|
+
this.resolvePending = r;
|
|
1265
|
+
});
|
|
1266
|
+
if (this.timer) clearTimeout(this.timer);
|
|
1267
|
+
this.timer = setTimeout(() => {
|
|
1268
|
+
this.timer = null;
|
|
1269
|
+
if (this.flushing) return;
|
|
1270
|
+
this.flushing = true;
|
|
1271
|
+
void this.runFlush().finally(() => {
|
|
1272
|
+
this.flushing = false;
|
|
1273
|
+
if (this.dirty.size > 0) {
|
|
1274
|
+
this.scheduleDebounced();
|
|
1275
|
+
} else {
|
|
1276
|
+
const resolve = this.resolvePending;
|
|
1277
|
+
this.resolvePending = null;
|
|
1278
|
+
this.pending = null;
|
|
1279
|
+
resolve?.();
|
|
1280
|
+
}
|
|
1281
|
+
});
|
|
1282
|
+
}, this.debounceMs);
|
|
1283
|
+
}
|
|
1255
1284
|
async runFlush() {
|
|
1256
1285
|
await Promise.resolve();
|
|
1257
1286
|
const pks = [...this.dirty];
|
|
@@ -1306,12 +1335,12 @@ var init_partial_reduce = __esm({
|
|
|
1306
1335
|
});
|
|
1307
1336
|
|
|
1308
1337
|
// src/federation/aggregate-across.ts
|
|
1309
|
-
var
|
|
1338
|
+
var import_cargo11, import_cargo12, CrossVaultAggregation, CrossVaultGroupedAggregation;
|
|
1310
1339
|
var init_aggregate_across = __esm({
|
|
1311
1340
|
"src/federation/aggregate-across.ts"() {
|
|
1312
1341
|
"use strict";
|
|
1313
|
-
|
|
1314
|
-
|
|
1342
|
+
import_cargo11 = require("@noy-db/hub/cargo");
|
|
1343
|
+
import_cargo12 = require("@noy-db/hub/cargo");
|
|
1315
1344
|
init_cross_vault_live();
|
|
1316
1345
|
init_partial_reduce();
|
|
1317
1346
|
CrossVaultAggregation = class {
|
|
@@ -1329,7 +1358,7 @@ var init_aggregate_across = __esm({
|
|
|
1329
1358
|
return { result: finalizePartial(this.spec, mergePartials(this.spec, partials)), skippedVaults: skippedVaults2 };
|
|
1330
1359
|
}
|
|
1331
1360
|
const { records, skippedVaults } = await this.src.fanoutRecords(options);
|
|
1332
|
-
return { result: (0,
|
|
1361
|
+
return { result: (0, import_cargo11.reduceRecords)(records, this.spec), skippedVaults };
|
|
1333
1362
|
}
|
|
1334
1363
|
live(options = {}) {
|
|
1335
1364
|
if (!this.bind) throw new Error("CrossVaultAggregation: live() requires a LiveBinding \u2014 use ShardedQuery.aggregate()");
|
|
@@ -1340,7 +1369,7 @@ var init_aggregate_across = __esm({
|
|
|
1340
1369
|
isRelevant: this.bind.isRelevant,
|
|
1341
1370
|
compute: async () => {
|
|
1342
1371
|
const { records, skippedVaults } = await src.fanoutRecords(options);
|
|
1343
|
-
return { value: (0,
|
|
1372
|
+
return { value: (0, import_cargo11.reduceRecords)(records, spec), skipped: skippedVaults };
|
|
1344
1373
|
},
|
|
1345
1374
|
initialSnapshot: { value: void 0, skipped: [] },
|
|
1346
1375
|
...options.debounceMs !== void 0 ? { debounceMs: options.debounceMs } : {}
|
|
@@ -1375,7 +1404,7 @@ var init_aggregate_across = __esm({
|
|
|
1375
1404
|
async run(options = {}) {
|
|
1376
1405
|
const { records, skippedVaults } = await this.src.fanoutRecords(options);
|
|
1377
1406
|
return {
|
|
1378
|
-
results: (0,
|
|
1407
|
+
results: (0, import_cargo12.groupAndReduce)(records, this.field, this.spec),
|
|
1379
1408
|
skippedVaults
|
|
1380
1409
|
};
|
|
1381
1410
|
}
|
|
@@ -1390,7 +1419,7 @@ var init_aggregate_across = __esm({
|
|
|
1390
1419
|
compute: async () => {
|
|
1391
1420
|
const { records, skippedVaults } = await src.fanoutRecords(options);
|
|
1392
1421
|
return {
|
|
1393
|
-
records: (0,
|
|
1422
|
+
records: (0, import_cargo12.groupAndReduce)(records, field, spec),
|
|
1394
1423
|
skipped: skippedVaults
|
|
1395
1424
|
};
|
|
1396
1425
|
},
|
|
@@ -1463,7 +1492,7 @@ async function retrieveAcross(group, collectionName, query, opts = {}) {
|
|
|
1463
1492
|
}
|
|
1464
1493
|
return pv.hits.map((h) => ({ ...h, id: pv.vault + SEP + h.id }));
|
|
1465
1494
|
});
|
|
1466
|
-
const fused = (0,
|
|
1495
|
+
const fused = (0, import_cargo13.fuseRetrieval)(lists, {
|
|
1467
1496
|
...opts.limit !== void 0 ? { limit: opts.limit } : {},
|
|
1468
1497
|
...opts.rrfK !== void 0 ? { k: opts.rrfK } : {}
|
|
1469
1498
|
});
|
|
@@ -1473,11 +1502,11 @@ async function retrieveAcross(group, collectionName, query, opts = {}) {
|
|
|
1473
1502
|
});
|
|
1474
1503
|
return { hits, skippedVaults };
|
|
1475
1504
|
}
|
|
1476
|
-
var
|
|
1505
|
+
var import_cargo13, SEP;
|
|
1477
1506
|
var init_retrieve_across = __esm({
|
|
1478
1507
|
"src/federation/retrieve-across.ts"() {
|
|
1479
1508
|
"use strict";
|
|
1480
|
-
|
|
1509
|
+
import_cargo13 = require("@noy-db/hub/cargo");
|
|
1481
1510
|
init_classify_skip();
|
|
1482
1511
|
SEP = "\0";
|
|
1483
1512
|
}
|
|
@@ -1491,30 +1520,34 @@ __export(vault_group_exports, {
|
|
|
1491
1520
|
ShardedQuery: () => ShardedQuery,
|
|
1492
1521
|
VaultGroup: () => VaultGroup
|
|
1493
1522
|
});
|
|
1523
|
+
function autoPushConfig(spec) {
|
|
1524
|
+
if (!spec.autoPush) return null;
|
|
1525
|
+
return spec.autoPush === true ? {} : spec.autoPush;
|
|
1526
|
+
}
|
|
1494
1527
|
function assertSafePartitionKey(partitionKey) {
|
|
1495
1528
|
if (partitionKey.length === 0) {
|
|
1496
|
-
throw new
|
|
1529
|
+
throw new import_cargo14.ValidationError("partitionKey must be a non-empty string");
|
|
1497
1530
|
}
|
|
1498
|
-
if (partitionKey ===
|
|
1499
|
-
throw new
|
|
1531
|
+
if (partitionKey === import_cargo7.STATE_VAULT_NAME) {
|
|
1532
|
+
throw new import_cargo14.ReservedVaultNameError(partitionKey);
|
|
1500
1533
|
}
|
|
1501
1534
|
if (!SAFE_PARTITION_KEY.test(partitionKey)) {
|
|
1502
|
-
throw new
|
|
1535
|
+
throw new import_cargo14.ValidationError(
|
|
1503
1536
|
`partitionKey "${partitionKey}" contains characters outside [A-Za-z0-9._-]. Map your records to a store-safe key in sharding.keyOf.`
|
|
1504
1537
|
);
|
|
1505
1538
|
}
|
|
1506
1539
|
if (partitionKey.includes(SHARD_SEPARATOR)) {
|
|
1507
|
-
throw new
|
|
1540
|
+
throw new import_cargo14.ValidationError(
|
|
1508
1541
|
`partitionKey "${partitionKey}" must not contain "--" \u2014 it is reserved as the shard vault-id separator and would risk shard-id collisions.`
|
|
1509
1542
|
);
|
|
1510
1543
|
}
|
|
1511
1544
|
}
|
|
1512
|
-
var
|
|
1545
|
+
var import_cargo14, SHARD_SEPARATOR, SAFE_PARTITION_KEY, VaultGroup, ShardedCollection, ShardedQuery, ShardedGroupedQuery;
|
|
1513
1546
|
var init_vault_group = __esm({
|
|
1514
1547
|
"src/federation/vault-group.ts"() {
|
|
1515
1548
|
"use strict";
|
|
1516
1549
|
init_state_vault();
|
|
1517
|
-
|
|
1550
|
+
import_cargo14 = require("@noy-db/hub/cargo");
|
|
1518
1551
|
init_constants();
|
|
1519
1552
|
init_classify_skip();
|
|
1520
1553
|
init_cross_shard_join();
|
|
@@ -1535,7 +1568,7 @@ var init_vault_group = __esm({
|
|
|
1535
1568
|
this.cutoverOnOpen = cutoverOnOpen;
|
|
1536
1569
|
this.meta = meta;
|
|
1537
1570
|
if (name.includes(SHARD_SEPARATOR)) {
|
|
1538
|
-
throw new
|
|
1571
|
+
throw new import_cargo14.ValidationError(
|
|
1539
1572
|
`VaultGroup name "${name}" must not contain "--" (reserved shard vault-id separator).`
|
|
1540
1573
|
);
|
|
1541
1574
|
}
|
|
@@ -1640,11 +1673,11 @@ var init_vault_group = __esm({
|
|
|
1640
1673
|
const vaultId = this.shardVaultId(partitionKey);
|
|
1641
1674
|
const row = await this.registry.get(this.registryId(partitionKey));
|
|
1642
1675
|
const provisioned = await this.db._shardVaultProvisioned(vaultId);
|
|
1643
|
-
if (row && !provisioned) throw new
|
|
1676
|
+
if (row && !provisioned) throw new import_cargo14.ShardProvisioningError(vaultId, partitionKey);
|
|
1644
1677
|
if (row && provisioned) return this.openShard(partitionKey);
|
|
1645
1678
|
if (region !== void 0) {
|
|
1646
1679
|
const backendRegion = this.db._resolveBackend(vaultId).capabilities?.region;
|
|
1647
|
-
if (backendRegion !== region) throw new
|
|
1680
|
+
if (backendRegion !== region) throw new import_cargo14.DataResidencyError(vaultId, region, backendRegion);
|
|
1648
1681
|
}
|
|
1649
1682
|
const vault = await this.db.openVault(vaultId);
|
|
1650
1683
|
this.template.configure(vault);
|
|
@@ -1678,9 +1711,9 @@ var init_vault_group = __esm({
|
|
|
1678
1711
|
async shard(partitionKey) {
|
|
1679
1712
|
const vaultId = this.shardVaultId(partitionKey);
|
|
1680
1713
|
const row = await this.registry.get(this.registryId(partitionKey));
|
|
1681
|
-
if (!row) throw new
|
|
1714
|
+
if (!row) throw new import_cargo14.UnknownShardError(partitionKey, this.name);
|
|
1682
1715
|
const provisioned = await this.db._shardVaultProvisioned(vaultId);
|
|
1683
|
-
if (!provisioned) throw new
|
|
1716
|
+
if (!provisioned) throw new import_cargo14.ShardProvisioningError(vaultId, partitionKey);
|
|
1684
1717
|
return this.openShard(partitionKey);
|
|
1685
1718
|
}
|
|
1686
1719
|
/** A sharded view over one logical collection across all shards. */
|
|
@@ -1712,7 +1745,7 @@ var init_vault_group = __esm({
|
|
|
1712
1745
|
for (const p of probes) {
|
|
1713
1746
|
if ("error" in p) skipped.push({ vaultId: p.row.vaultId, reason: "error", error: p.error });
|
|
1714
1747
|
else if (p.provisioned) eligible.push(p.row);
|
|
1715
|
-
else skipped.push({ vaultId: p.row.vaultId, reason: "error", error: new
|
|
1748
|
+
else skipped.push({ vaultId: p.row.vaultId, reason: "error", error: new import_cargo14.ShardProvisioningError(p.row.vaultId, p.row.partitionKey) });
|
|
1716
1749
|
}
|
|
1717
1750
|
return { eligible, skipped };
|
|
1718
1751
|
}
|
|
@@ -1749,15 +1782,18 @@ var init_vault_group = __esm({
|
|
|
1749
1782
|
withCrossVaultDerivation(spec) {
|
|
1750
1783
|
const target = spec.target.vault;
|
|
1751
1784
|
if (target === this.name || target.startsWith(`${this.name}${SHARD_SEPARATOR}`)) {
|
|
1752
|
-
throw new
|
|
1785
|
+
throw new import_cargo14.ValidationError(
|
|
1753
1786
|
`withCrossVaultDerivation: target.vault "${target}" is the "${this.name}" group itself or one of its shards \u2014 an Insight summary must target a SEPARATE analytics vault, never write back into client-shard data (it would breach the per-shard DEK boundary). Use a distinct vault name.`
|
|
1754
1787
|
);
|
|
1755
1788
|
}
|
|
1756
1789
|
this.crossVaultDerivations.push(spec);
|
|
1757
1790
|
if (spec.autoPush && !this.insightAutoPush) {
|
|
1791
|
+
const cfg = autoPushConfig(spec);
|
|
1758
1792
|
const controller = new InsightAutoPush(
|
|
1759
1793
|
(pk) => this._recomputeShardInsights(pk),
|
|
1760
|
-
(collection) => this.crossVaultDerivations.some((s) => s.autoPush && s.source === collection)
|
|
1794
|
+
(collection) => this.crossVaultDerivations.some((s) => s.autoPush && s.source === collection),
|
|
1795
|
+
void 0,
|
|
1796
|
+
cfg?.debounceMs
|
|
1761
1797
|
);
|
|
1762
1798
|
this.insightAutoPush = controller;
|
|
1763
1799
|
const prefix = `${this.name}${SHARD_SEPARATOR}`;
|
|
@@ -1838,6 +1874,8 @@ var init_vault_group = __esm({
|
|
|
1838
1874
|
};
|
|
1839
1875
|
for (const spec of this.crossVaultDerivations) {
|
|
1840
1876
|
if (!spec.autoPush) continue;
|
|
1877
|
+
const min = autoPushConfig(spec)?.minVersion;
|
|
1878
|
+
if (min !== void 0 && row.schemaVersion < min) continue;
|
|
1841
1879
|
const records = await shard.collection(spec.source).list();
|
|
1842
1880
|
const summary = spec.derive(records, ctx);
|
|
1843
1881
|
const insight = await this.db.openVault(spec.target.vault);
|
|
@@ -1870,7 +1908,7 @@ var init_vault_group = __esm({
|
|
|
1870
1908
|
async cutoverShard(partitionKey) {
|
|
1871
1909
|
const vaultId = this.shardVaultId(partitionKey);
|
|
1872
1910
|
const row = await this.registry.get(this.registryId(partitionKey));
|
|
1873
|
-
if (!row) throw new
|
|
1911
|
+
if (!row) throw new import_cargo14.UnknownShardError(partitionKey, this.name);
|
|
1874
1912
|
const target = this.template.version;
|
|
1875
1913
|
const sv = await this.ensureStateVault();
|
|
1876
1914
|
const base = { vaultId, group: this.name, currentVersion: row.schemaVersion, targetVersion: target };
|
|
@@ -1953,7 +1991,7 @@ var init_vault_group = __esm({
|
|
|
1953
1991
|
let vault;
|
|
1954
1992
|
if (!row) {
|
|
1955
1993
|
if (this.group.sharding.autoCreate === false) {
|
|
1956
|
-
throw new
|
|
1994
|
+
throw new import_cargo14.UnknownShardError(key, this.group.name);
|
|
1957
1995
|
}
|
|
1958
1996
|
vault = await this.group.createShard(key, this.group.sharding.regionOf?.(record));
|
|
1959
1997
|
} else {
|
|
@@ -2036,7 +2074,7 @@ var init_vault_group = __esm({
|
|
|
2036
2074
|
this.group.template.configure(probe);
|
|
2037
2075
|
for (const leg of this.coPartitionedLegs) {
|
|
2038
2076
|
if (!probe.resolveRef(this.collectionName, leg.field)) {
|
|
2039
|
-
throw new
|
|
2077
|
+
throw new import_cargo14.CrossShardJoinError(
|
|
2040
2078
|
`crossShardJoin("${leg.field}"): no ref() declared for "${leg.field}" on collection "${this.collectionName}" in template "${this.group.sharding.vaultTemplate}". Add refs: { ${leg.field}: ref('<target>') } to the template's collection options.`
|
|
2041
2079
|
);
|
|
2042
2080
|
}
|
|
@@ -2118,23 +2156,23 @@ var init_vault_group = __esm({
|
|
|
2118
2156
|
isRelevant: (e) => e.collection === collectionName && e.vault.startsWith(`${group.name}--`)
|
|
2119
2157
|
};
|
|
2120
2158
|
}
|
|
2121
|
-
/**
|
|
2122
|
-
|
|
2123
|
-
|
|
2124
|
-
|
|
2125
|
-
|
|
2126
|
-
|
|
2127
|
-
|
|
2128
|
-
|
|
2129
|
-
|
|
2159
|
+
/**
|
|
2160
|
+
* Returns a reactive cross-shard live query — a facade over CrossVaultLive.
|
|
2161
|
+
*
|
|
2162
|
+
* Joined queries (crossShardJoin / broadcastJoin) are supported (#14): the live
|
|
2163
|
+
* value reflects the fully-joined rows. **v1 limitation:** recomputes only on
|
|
2164
|
+
* writes to the primary (left) collection; writes to a co-partitioned right
|
|
2165
|
+
* collection or a broadcast-dimension collection do NOT trigger a recompute —
|
|
2166
|
+
* re-run the query to pick those up.
|
|
2167
|
+
*/
|
|
2130
2168
|
live(options = {}) {
|
|
2131
|
-
this.assertNoJoinLegs("live");
|
|
2132
2169
|
const bind = this.liveBinding();
|
|
2133
2170
|
const core = new CrossVaultLive({
|
|
2134
2171
|
...bind,
|
|
2135
2172
|
compute: async () => {
|
|
2136
2173
|
const { records, skippedVaults } = await this.fanoutRecords(options);
|
|
2137
|
-
|
|
2174
|
+
const joined = await applyBroadcastLegs(records, this.broadcastLegs);
|
|
2175
|
+
return { records: joined, skipped: skippedVaults };
|
|
2138
2176
|
},
|
|
2139
2177
|
initialSnapshot: { records: [], skipped: [] },
|
|
2140
2178
|
...options.debounceMs !== void 0 ? { debounceMs: options.debounceMs } : {}
|
|
@@ -2154,14 +2192,28 @@ var init_vault_group = __esm({
|
|
|
2154
2192
|
stop: () => core.stop()
|
|
2155
2193
|
};
|
|
2156
2194
|
}
|
|
2195
|
+
/**
|
|
2196
|
+
* @internal — the FanoutRecordSource for aggregate surfaces. With no join legs,
|
|
2197
|
+
* returns `this` (partial-reduce-eligible, #8). With join legs, returns a
|
|
2198
|
+
* toArray-backed source (fully-joined rows) and NO fanoutReduce, forcing
|
|
2199
|
+
* central-reduce over the joined rows (partial-reduce can't span the central
|
|
2200
|
+
* broadcast join). Used by scalar `aggregate()` and `ShardedGroupedQuery`.
|
|
2201
|
+
*/
|
|
2202
|
+
aggregateSource() {
|
|
2203
|
+
if (!this.coPartitionedLegs.length && !this.broadcastLegs.length) return this;
|
|
2204
|
+
return {
|
|
2205
|
+
fanoutRecords: async (o) => {
|
|
2206
|
+
const { results, skippedVaults } = await this.toArray(o);
|
|
2207
|
+
return { records: results, skippedVaults };
|
|
2208
|
+
}
|
|
2209
|
+
};
|
|
2210
|
+
}
|
|
2157
2211
|
/** One-shot distributed aggregate — central reduce over all shard records. */
|
|
2158
2212
|
aggregate(spec) {
|
|
2159
|
-
this.
|
|
2160
|
-
return new CrossVaultAggregation(this, spec, this.liveBinding());
|
|
2213
|
+
return new CrossVaultAggregation(this.aggregateSource(), spec, this.liveBinding());
|
|
2161
2214
|
}
|
|
2162
2215
|
/** Begin a grouped cross-shard aggregate. */
|
|
2163
2216
|
groupBy(field) {
|
|
2164
|
-
this.assertNoJoinLegs("groupBy");
|
|
2165
2217
|
return new ShardedGroupedQuery(this, field);
|
|
2166
2218
|
}
|
|
2167
2219
|
};
|
|
@@ -2174,7 +2226,7 @@ var init_vault_group = __esm({
|
|
|
2174
2226
|
field;
|
|
2175
2227
|
aggregate(spec) {
|
|
2176
2228
|
return new CrossVaultGroupedAggregation(
|
|
2177
|
-
|
|
2229
|
+
this.query.aggregateSource(),
|
|
2178
2230
|
this.field,
|
|
2179
2231
|
spec,
|
|
2180
2232
|
this.query.liveBinding()
|
|
@@ -2187,10 +2239,10 @@ var init_vault_group = __esm({
|
|
|
2187
2239
|
// src/index.ts
|
|
2188
2240
|
var index_exports = {};
|
|
2189
2241
|
__export(index_exports, {
|
|
2190
|
-
CrossShardJoinError: () =>
|
|
2242
|
+
CrossShardJoinError: () => import_cargo16.CrossShardJoinError,
|
|
2191
2243
|
CrossVaultDanglingRefError: () => CrossVaultDanglingRefError,
|
|
2192
|
-
CustodyApi: () =>
|
|
2193
|
-
DataResidencyError: () =>
|
|
2244
|
+
CustodyApi: () => import_cargo17.CustodyApi,
|
|
2245
|
+
DataResidencyError: () => import_cargo16.DataResidencyError,
|
|
2194
2246
|
DockedUnit: () => DockedUnit,
|
|
2195
2247
|
FieldAuthorityPolicyMissingError: () => FieldAuthorityPolicyMissingError,
|
|
2196
2248
|
FieldLevelDeferredError: () => FieldLevelDeferredError,
|
|
@@ -2201,17 +2253,17 @@ __export(index_exports, {
|
|
|
2201
2253
|
NOYDB_MULTI_BUNDLE_MAGIC: () => NOYDB_MULTI_BUNDLE_MAGIC,
|
|
2202
2254
|
NOYDB_MULTI_BUNDLE_PREFIX_BYTES: () => NOYDB_MULTI_BUNDLE_PREFIX_BYTES,
|
|
2203
2255
|
NOYDB_MULTI_BUNDLE_VERSION: () => NOYDB_MULTI_BUNDLE_VERSION,
|
|
2204
|
-
ReservedVaultNameError: () =>
|
|
2205
|
-
ShardProvisioningError: () =>
|
|
2256
|
+
ReservedVaultNameError: () => import_cargo16.ReservedVaultNameError,
|
|
2257
|
+
ShardProvisioningError: () => import_cargo16.ShardProvisioningError,
|
|
2206
2258
|
SurfaceCadenceScheduler: () => SurfaceCadenceScheduler,
|
|
2207
2259
|
SurfaceNotFoundError: () => SurfaceNotFoundError,
|
|
2208
2260
|
SurfaceStateError: () => SurfaceStateError,
|
|
2209
2261
|
UnitGraduationError: () => UnitGraduationError,
|
|
2210
|
-
UnknownShardError: () =>
|
|
2211
|
-
VaultTemplateNotFoundError: () =>
|
|
2262
|
+
UnknownShardError: () => import_cargo16.UnknownShardError,
|
|
2263
|
+
VaultTemplateNotFoundError: () => import_cargo16.VaultTemplateNotFoundError,
|
|
2212
2264
|
agreeSurface: () => agreeSurface,
|
|
2213
2265
|
applySurface: () => applySurface,
|
|
2214
|
-
createDeedOwner: () =>
|
|
2266
|
+
createDeedOwner: () => import_cargo17.createDeedOwner,
|
|
2215
2267
|
createLobby: () => createLobby,
|
|
2216
2268
|
decodeMultiBundle: () => decodeMultiBundle,
|
|
2217
2269
|
describeCrossVaultExtraction: () => describeCrossVaultExtraction,
|
|
@@ -2219,11 +2271,11 @@ __export(index_exports, {
|
|
|
2219
2271
|
exportSurface: () => exportSurface,
|
|
2220
2272
|
extractCrossVaultPartition: () => extractCrossVaultPartition,
|
|
2221
2273
|
groupInspector: () => groupInspector,
|
|
2222
|
-
isDeedVault: () =>
|
|
2274
|
+
isDeedVault: () => import_cargo17.isDeedVault,
|
|
2223
2275
|
isSurfaceDue: () => isSurfaceDue,
|
|
2224
|
-
liberateVault: () =>
|
|
2276
|
+
liberateVault: () => import_cargo17.liberateVault,
|
|
2225
2277
|
listDueSurfaces: () => listDueSurfaces,
|
|
2226
|
-
loadDeedMarker: () =>
|
|
2278
|
+
loadDeedMarker: () => import_cargo17.loadDeedMarker,
|
|
2227
2279
|
markSynced: () => markSynced,
|
|
2228
2280
|
mergeCompartment: () => mergeCompartment,
|
|
2229
2281
|
mergeDecryptedRecords: () => mergeDecryptedRecords,
|
|
@@ -2238,8 +2290,7 @@ __export(index_exports, {
|
|
|
2238
2290
|
writeMultiVaultBundle: () => writeMultiVaultBundle
|
|
2239
2291
|
});
|
|
2240
2292
|
module.exports = __toCommonJS(index_exports);
|
|
2241
|
-
var
|
|
2242
|
-
var import_hub5 = require("@noy-db/hub");
|
|
2293
|
+
var import_cargo15 = require("@noy-db/hub/cargo");
|
|
2243
2294
|
|
|
2244
2295
|
// src/dock/docked-unit.ts
|
|
2245
2296
|
var DockedUnit = class {
|
|
@@ -2321,13 +2372,13 @@ async function meterGroup(group, opts = {}) {
|
|
|
2321
2372
|
}
|
|
2322
2373
|
|
|
2323
2374
|
// src/index.ts
|
|
2324
|
-
var
|
|
2375
|
+
var import_cargo16 = require("@noy-db/hub/cargo");
|
|
2325
2376
|
init_multi_bundle();
|
|
2326
2377
|
init_extract_cross_vault();
|
|
2327
2378
|
init_merge_compartment();
|
|
2328
2379
|
|
|
2329
2380
|
// src/interchange/migrate-then-merge.ts
|
|
2330
|
-
var
|
|
2381
|
+
var import_bundle3 = require("@noy-db/hub/bundle");
|
|
2331
2382
|
init_merge_compartment();
|
|
2332
2383
|
init_stage_records();
|
|
2333
2384
|
init_stage_records();
|
|
@@ -2352,7 +2403,7 @@ async function migrateThenMerge(receiver, compartmentBytes, opts) {
|
|
|
2352
2403
|
);
|
|
2353
2404
|
}
|
|
2354
2405
|
if (fromVersion > toVersion) throw new MinVersionError(fromVersion, toVersion);
|
|
2355
|
-
const incoming = await (0,
|
|
2406
|
+
const incoming = await (0, import_bundle3.decryptExtractedPartition)(compartmentBytes, opts.transferKey);
|
|
2356
2407
|
const transformsByCollection = {};
|
|
2357
2408
|
const migrationByCollection = {};
|
|
2358
2409
|
for (const [coll, recs] of Object.entries(incoming)) {
|
|
@@ -2375,7 +2426,7 @@ async function migrateThenMerge(receiver, compartmentBytes, opts) {
|
|
|
2375
2426
|
|
|
2376
2427
|
// src/index.ts
|
|
2377
2428
|
init_field_authority();
|
|
2378
|
-
var
|
|
2429
|
+
var import_cargo17 = require("@noy-db/hub/cargo");
|
|
2379
2430
|
|
|
2380
2431
|
// src/dock/unit-driver.ts
|
|
2381
2432
|
var InMemoryUnitDriver = class {
|
|
@@ -2409,10 +2460,10 @@ var Lobby = class {
|
|
|
2409
2460
|
}
|
|
2410
2461
|
async openVaultGroup(name, opts) {
|
|
2411
2462
|
const db = this.noydb;
|
|
2412
|
-
if (db.isClosed) throw new
|
|
2413
|
-
if (name ===
|
|
2463
|
+
if (db.isClosed) throw new import_cargo15.ValidationError("Instance is closed");
|
|
2464
|
+
if (name === import_cargo15.STATE_VAULT_NAME) throw new import_cargo15.ReservedVaultNameError(name);
|
|
2414
2465
|
const template = this.vaultTemplates.get(opts.sharding.vaultTemplate);
|
|
2415
|
-
if (!template) throw new
|
|
2466
|
+
if (!template) throw new import_cargo15.VaultTemplateNotFoundError(opts.sharding.vaultTemplate);
|
|
2416
2467
|
const { VaultGroup: VaultGroup2 } = await Promise.resolve().then(() => (init_vault_group(), vault_group_exports));
|
|
2417
2468
|
const { StateManagementVault: StateManagementVault2 } = await Promise.resolve().then(() => (init_state_vault(), state_vault_exports));
|
|
2418
2469
|
const stateVault = opts.registry ? void 0 : await StateManagementVault2.open(db);
|
|
@@ -2431,7 +2482,7 @@ var Lobby = class {
|
|
|
2431
2482
|
}
|
|
2432
2483
|
async openStateManagementVault() {
|
|
2433
2484
|
const db = this.noydb;
|
|
2434
|
-
if (db.isClosed) throw new
|
|
2485
|
+
if (db.isClosed) throw new import_cargo15.ValidationError("Instance is closed");
|
|
2435
2486
|
const { StateManagementVault: StateManagementVault2 } = await Promise.resolve().then(() => (init_state_vault(), state_vault_exports));
|
|
2436
2487
|
return StateManagementVault2.open(db);
|
|
2437
2488
|
}
|