@powerhousedao/reactor 6.2.1 → 6.2.2-dev.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/dist/{build-worker-executor-DeJ2DW16.js → build-worker-executor-BDrPlCJl.js} +3 -3
- package/dist/{build-worker-executor-DeJ2DW16.js.map → build-worker-executor-BDrPlCJl.js.map} +1 -1
- package/dist/{document-indexer-DLEyUQxU.js → document-indexer-FGJmRAdX.js} +12 -17
- package/dist/document-indexer-FGJmRAdX.js.map +1 -0
- package/dist/{drive-container-types-BxnXaOAp.js → drive-container-types-DpJp2AmE.js} +14 -18
- package/dist/drive-container-types-DpJp2AmE.js.map +1 -0
- package/dist/entry.js +2 -2
- package/dist/index.d.ts +61 -36
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +79 -45
- package/dist/index.js.map +1 -1
- package/dist/projection-entry.js +4 -4
- package/dist/{projection-shard-manager-_c7orNo5.js → projection-shard-manager-BnQKFqQd.js} +2 -2
- package/dist/{projection-shard-manager-_c7orNo5.js.map → projection-shard-manager-BnQKFqQd.js.map} +1 -1
- package/dist/{types-CxSpmNGK.js → types-DMKLa0Ok.js} +3 -2
- package/dist/types-DMKLa0Ok.js.map +1 -0
- package/dist/{worker-XYrQaEmt.js → worker-DBJOv8Gp.js} +2 -2
- package/dist/{worker-XYrQaEmt.js.map → worker-DBJOv8Gp.js.map} +1 -1
- package/package.json +4 -4
- package/dist/document-indexer-DLEyUQxU.js.map +0 -1
- package/dist/drive-container-types-BxnXaOAp.js.map +0 -1
- package/dist/types-CxSpmNGK.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { A as parsePagingOptions, C as DuplicateManifestError, D as DocumentDeletedError, E as ModuleNotFoundError, O as DocumentNotFoundError, S as CollectionMembershipCache, T as InvalidModuleError, _ as KyselyWriteCache, a as createForwardingPoolInstrumentation, b as createConsistencyToken, c as DuplicateOperationError, d as KyselyKeyframeStore, f as DocumentModelRegistry, g as EventBus, h as KyselyExecutionScope, i as runMigrations, j as throwIfAborted, k as matchesScope, l as OptimisticLockError, m as DriveCollectionId, n as REACTOR_SCHEMA, o as instrumentPgPool, p as SimpleJobExecutor, r as getMigrationStatus, s as KyselyOperationStore, t as DEFAULT_DRIVE_CONTAINER_TYPES, u as RevisionMismatchError, v as KyselyOperationIndex, w as DuplicateModuleError, x as createEmptyConsistencyToken, y as DocumentMetaCache } from "./drive-container-types-
|
|
2
|
-
import { n as ReactorEventTypes, t as EventBusAggregateError } from "./types-
|
|
1
|
+
import { A as parsePagingOptions, C as DuplicateManifestError, D as DocumentDeletedError, E as ModuleNotFoundError, O as DocumentNotFoundError, S as CollectionMembershipCache, T as InvalidModuleError, _ as KyselyWriteCache, a as createForwardingPoolInstrumentation, b as createConsistencyToken, c as DuplicateOperationError, d as KyselyKeyframeStore, f as DocumentModelRegistry, g as EventBus, h as KyselyExecutionScope, i as runMigrations, j as throwIfAborted, k as matchesScope, l as OptimisticLockError, m as DriveCollectionId, n as REACTOR_SCHEMA, o as instrumentPgPool, p as SimpleJobExecutor, r as getMigrationStatus, s as KyselyOperationStore, t as DEFAULT_DRIVE_CONTAINER_TYPES, u as RevisionMismatchError, v as KyselyOperationIndex, w as DuplicateModuleError, x as createEmptyConsistencyToken, y as DocumentMetaCache } from "./drive-container-types-DpJp2AmE.js";
|
|
2
|
+
import { n as ReactorEventTypes, t as EventBusAggregateError } from "./types-DMKLa0Ok.js";
|
|
3
3
|
import { i as WorkerInitFailedError, r as WorkerExitedError, t as WorkerAbortTimeoutError } from "./errors-D3S6Eysd.js";
|
|
4
|
-
import { a as ReadModelCoordinator, i as KyselyDocumentView, n as ConsistencyTracker, o as BaseReadModel, r as makeConsistencyKey, t as KyselyDocumentIndexer } from "./document-indexer-
|
|
4
|
+
import { a as ReadModelCoordinator, i as KyselyDocumentView, n as ConsistencyTracker, o as BaseReadModel, r as makeConsistencyKey, t as KyselyDocumentIndexer } from "./document-indexer-FGJmRAdX.js";
|
|
5
5
|
import { n as errorToInfo, r as sanitizeArg, t as createForwardingLogger } from "./forwarding-logger-BBkMSxuJ.js";
|
|
6
|
-
import { t as workerEntryPath } from "./worker-
|
|
6
|
+
import { t as workerEntryPath } from "./worker-DBJOv8Gp.js";
|
|
7
7
|
import { actions, actions as documentActions, createPresignedHeader, generateId, hashDocumentStateForScope, replayDocument } from "@powerhousedao/shared/document-model";
|
|
8
8
|
import { addFile, addFolder, copyNode, deleteNode, driveCreateDocument, generateNodesCopy, getDescendants, handleTargetNameCollisions, isFileNode, isFolderNode, moveNode, updateNode } from "@powerhousedao/shared/document-drive";
|
|
9
9
|
import { v4 } from "uuid";
|
|
10
|
-
import { ConsoleLogger } from "document-model";
|
|
10
|
+
import { ConsoleLogger, childLogger } from "document-model";
|
|
11
11
|
import { sql } from "kysely";
|
|
12
12
|
import { RelationalDbProcessor, createRelationalDb } from "@powerhousedao/shared/processors";
|
|
13
13
|
//#region src/actions/index.ts
|
|
@@ -2128,7 +2128,7 @@ var ProcessorManager = class extends BaseReadModel {
|
|
|
2128
2128
|
this.logger.error("Processor '@ProcessorId' failed during backfill at ordinal @Ordinal: @Error", tracked.processorId, tracked.lastOrdinal, error);
|
|
2129
2129
|
return;
|
|
2130
2130
|
}
|
|
2131
|
-
tracked.lastOrdinal =
|
|
2131
|
+
tracked.lastOrdinal = page.results[page.results.length - 1].context.ordinal;
|
|
2132
2132
|
await this.safeSaveProcessorCursor(tracked);
|
|
2133
2133
|
if (!page.next) break;
|
|
2134
2134
|
page = await page.next();
|
|
@@ -2158,7 +2158,8 @@ var ProcessorManager = class extends BaseReadModel {
|
|
|
2158
2158
|
}
|
|
2159
2159
|
}
|
|
2160
2160
|
async routeOperationsToProcessors(operations) {
|
|
2161
|
-
|
|
2161
|
+
let maxOrdinal = 0;
|
|
2162
|
+
for (const op of operations) maxOrdinal = Math.max(maxOrdinal, op.context.ordinal);
|
|
2162
2163
|
const allTracked = Array.from(this.allTrackedProcessors());
|
|
2163
2164
|
await Promise.all(allTracked.map(async (tracked) => {
|
|
2164
2165
|
if (tracked.status !== "active") return;
|
|
@@ -2696,6 +2697,8 @@ var DocumentModelResolver = class {
|
|
|
2696
2697
|
loadingModels = /* @__PURE__ */ new Map();
|
|
2697
2698
|
failedModelTypes = /* @__PURE__ */ new Set();
|
|
2698
2699
|
broadcastHook = null;
|
|
2700
|
+
modelLoadedHook = null;
|
|
2701
|
+
logger = childLogger(["reactor", "document-model-resolver"]);
|
|
2699
2702
|
constructor(registry, loader) {
|
|
2700
2703
|
this.registry = registry;
|
|
2701
2704
|
this.loader = loader;
|
|
@@ -2708,6 +2711,13 @@ var DocumentModelResolver = class {
|
|
|
2708
2711
|
setBroadcastHook(hook) {
|
|
2709
2712
|
this.broadcastHook = hook;
|
|
2710
2713
|
}
|
|
2714
|
+
/**
|
|
2715
|
+
* Post-success hook called with the document type after a model loads, so
|
|
2716
|
+
* peers (tabs) can load the same type via the event bus.
|
|
2717
|
+
*/
|
|
2718
|
+
setModelLoadedHook(hook) {
|
|
2719
|
+
this.modelLoadedHook = hook;
|
|
2720
|
+
}
|
|
2711
2721
|
async ensureModelLoaded(documentType) {
|
|
2712
2722
|
try {
|
|
2713
2723
|
this.registry.getModule(documentType);
|
|
@@ -2720,20 +2730,32 @@ var DocumentModelResolver = class {
|
|
|
2720
2730
|
if (existing) return existing;
|
|
2721
2731
|
const loadPromise = (async () => {
|
|
2722
2732
|
try {
|
|
2723
|
-
|
|
2724
|
-
const [result] = this.registry.registerModules(module);
|
|
2725
|
-
if (result.status === "error" && !DuplicateModuleError.isError(result.error)) throw result.error;
|
|
2726
|
-
await this.broadcastIfPossible(documentType);
|
|
2733
|
+
await this.loadRegisterAndBroadcast(documentType);
|
|
2727
2734
|
} catch (error) {
|
|
2728
2735
|
this.failedModelTypes.add(documentType);
|
|
2729
2736
|
throw error;
|
|
2730
2737
|
} finally {
|
|
2731
2738
|
this.loadingModels.delete(documentType);
|
|
2732
2739
|
}
|
|
2740
|
+
await this.notifyPeersModelLoaded(documentType);
|
|
2733
2741
|
})();
|
|
2734
2742
|
this.loadingModels.set(documentType, loadPromise);
|
|
2735
2743
|
return loadPromise;
|
|
2736
2744
|
}
|
|
2745
|
+
async loadRegisterAndBroadcast(documentType) {
|
|
2746
|
+
const module = await this.loader.load(documentType);
|
|
2747
|
+
const [result] = this.registry.registerModules(module);
|
|
2748
|
+
if (result.status === "error" && !DuplicateModuleError.isError(result.error)) throw result.error;
|
|
2749
|
+
await this.broadcastIfPossible(documentType);
|
|
2750
|
+
}
|
|
2751
|
+
async notifyPeersModelLoaded(documentType) {
|
|
2752
|
+
if (!this.modelLoadedHook) return;
|
|
2753
|
+
try {
|
|
2754
|
+
await this.modelLoadedHook(documentType);
|
|
2755
|
+
} catch (error) {
|
|
2756
|
+
this.logger.warn(`MODEL_LOADED hook failed: ${documentType}`, error);
|
|
2757
|
+
}
|
|
2758
|
+
}
|
|
2737
2759
|
async broadcastIfPossible(documentType) {
|
|
2738
2760
|
if (!this.broadcastHook || !this.loader.resolveSpec) return;
|
|
2739
2761
|
const entry = await this.loader.resolveSpec(documentType);
|
|
@@ -4909,6 +4931,11 @@ function rowToRemoteRecord(row) {
|
|
|
4909
4931
|
}
|
|
4910
4932
|
};
|
|
4911
4933
|
}
|
|
4934
|
+
/**
|
|
4935
|
+
* Maps a RemoteRecord to a row. jsonb array columns are JSON-encoded because the
|
|
4936
|
+
* pg driver would otherwise emit a Postgres array literal ("{a,b}"), which jsonb
|
|
4937
|
+
* rejects (matches sync-dead-letter-storage).
|
|
4938
|
+
*/
|
|
4912
4939
|
function remoteRecordToRow(remote) {
|
|
4913
4940
|
return {
|
|
4914
4941
|
name: remote.name,
|
|
@@ -5355,11 +5382,14 @@ var SyncManager = class {
|
|
|
5355
5382
|
for (const record of remoteRecords) {
|
|
5356
5383
|
const channel = this.channelFactory.instance(record.id, record.name, record.channelConfig, this.cursorStorage, record.collectionId, record.filter, this.operationIndex, record.options);
|
|
5357
5384
|
const remote = {
|
|
5358
|
-
|
|
5359
|
-
|
|
5360
|
-
|
|
5361
|
-
|
|
5362
|
-
|
|
5385
|
+
meta: {
|
|
5386
|
+
id: record.id,
|
|
5387
|
+
name: record.name,
|
|
5388
|
+
collectionId: record.collectionId,
|
|
5389
|
+
channelConfig: record.channelConfig,
|
|
5390
|
+
filter: record.filter,
|
|
5391
|
+
options: record.options
|
|
5392
|
+
},
|
|
5363
5393
|
channel
|
|
5364
5394
|
};
|
|
5365
5395
|
this.remotes.set(record.name, remote);
|
|
@@ -5378,7 +5408,7 @@ var SyncManager = class {
|
|
|
5378
5408
|
this.backfillAbortControllers.set(record.name, backfillController);
|
|
5379
5409
|
this.updateOutbox(remote, outboxAckOrdinal, OutboxMode.Backfill, backfillController.signal).catch((error) => {
|
|
5380
5410
|
if (backfillController.signal.aborted) return;
|
|
5381
|
-
this.logger.error("Backfill failed for remote @RemoteName: @Error", remote.name, error instanceof Error ? error : new Error(String(error)));
|
|
5411
|
+
this.logger.error("Backfill failed for remote @RemoteName: @Error", remote.meta.name, error instanceof Error ? error : new Error(String(error)));
|
|
5382
5412
|
}).finally(() => {
|
|
5383
5413
|
this.backfillAbortControllers.delete(record.name);
|
|
5384
5414
|
});
|
|
@@ -5422,7 +5452,7 @@ var SyncManager = class {
|
|
|
5422
5452
|
return remote;
|
|
5423
5453
|
}
|
|
5424
5454
|
getById(id) {
|
|
5425
|
-
for (const remote of this.remotes.values()) if (remote.id === id) return remote;
|
|
5455
|
+
for (const remote of this.remotes.values()) if (remote.meta.id === id) return remote;
|
|
5426
5456
|
throw new Error(`Remote with id '${id}' does not exist`);
|
|
5427
5457
|
}
|
|
5428
5458
|
async add(name, collectionId, channelConfig, filter = {
|
|
@@ -5449,11 +5479,14 @@ var SyncManager = class {
|
|
|
5449
5479
|
await this.remoteStorage.upsert(remoteRecord);
|
|
5450
5480
|
const channel = this.channelFactory.instance(remoteId, name, channelConfig, this.cursorStorage, collectionId, filter, this.operationIndex, options);
|
|
5451
5481
|
const remote = {
|
|
5452
|
-
|
|
5453
|
-
|
|
5454
|
-
|
|
5455
|
-
|
|
5456
|
-
|
|
5482
|
+
meta: {
|
|
5483
|
+
id: remoteId,
|
|
5484
|
+
name,
|
|
5485
|
+
collectionId,
|
|
5486
|
+
channelConfig,
|
|
5487
|
+
filter,
|
|
5488
|
+
options
|
|
5489
|
+
},
|
|
5457
5490
|
channel
|
|
5458
5491
|
};
|
|
5459
5492
|
this.remotes.set(name, remote);
|
|
@@ -5470,7 +5503,7 @@ var SyncManager = class {
|
|
|
5470
5503
|
this.backfillAbortControllers.set(name, backfillController);
|
|
5471
5504
|
this.updateOutbox(remote, 0, OutboxMode.Backfill, backfillController.signal).catch((error) => {
|
|
5472
5505
|
if (backfillController.signal.aborted) return;
|
|
5473
|
-
this.logger.error("Backfill failed for remote @RemoteName: @Error", remote.name, error instanceof Error ? error : new Error(String(error)));
|
|
5506
|
+
this.logger.error("Backfill failed for remote @RemoteName: @Error", remote.meta.name, error instanceof Error ? error : new Error(String(error)));
|
|
5474
5507
|
}).finally(() => {
|
|
5475
5508
|
this.backfillAbortControllers.delete(name);
|
|
5476
5509
|
});
|
|
@@ -5521,20 +5554,20 @@ var SyncManager = class {
|
|
|
5521
5554
|
}
|
|
5522
5555
|
wireChannelCallbacks(remote) {
|
|
5523
5556
|
remote.channel.inbox.onAdded((syncOps) => this.handleInboxAdded(remote, syncOps));
|
|
5524
|
-
this.syncStatusTracker.trackRemote(remote.name, remote.channel);
|
|
5557
|
+
this.syncStatusTracker.trackRemote(remote.meta.name, remote.channel);
|
|
5525
5558
|
const unsubscribe = remote.channel.onConnectionStateChange((snapshot) => {
|
|
5526
5559
|
this.eventBus.emit(SyncEventTypes.CONNECTION_STATE_CHANGED, {
|
|
5527
|
-
remoteName: remote.name,
|
|
5528
|
-
remoteId: remote.id,
|
|
5560
|
+
remoteName: remote.meta.name,
|
|
5561
|
+
remoteId: remote.meta.id,
|
|
5529
5562
|
previous: snapshot.state,
|
|
5530
5563
|
current: snapshot.state,
|
|
5531
5564
|
snapshot
|
|
5532
5565
|
}).catch(() => {});
|
|
5533
5566
|
});
|
|
5534
|
-
this.connectionStateUnsubscribes.set(remote.name, unsubscribe);
|
|
5567
|
+
this.connectionStateUnsubscribes.set(remote.meta.name, unsubscribe);
|
|
5535
5568
|
remote.channel.deadLetter.onAdded((syncOps) => {
|
|
5536
5569
|
for (const syncOp of syncOps) {
|
|
5537
|
-
this.logger.error("Dead letter (@remote, @documentId, @jobId, @error, @dependencies)", remote.name, syncOp.documentId, syncOp.jobId, syncOp.error?.message ?? "unknown", syncOp.jobDependencies);
|
|
5570
|
+
this.logger.error("Dead letter (@remote, @documentId, @jobId, @error, @dependencies)", remote.meta.name, syncOp.documentId, syncOp.jobId, syncOp.error?.message ?? "unknown", syncOp.jobDependencies);
|
|
5538
5571
|
this.quarantinedDocumentIds.add(syncOp.documentId);
|
|
5539
5572
|
const record = {
|
|
5540
5573
|
id: syncOp.id,
|
|
@@ -5570,12 +5603,12 @@ var SyncManager = class {
|
|
|
5570
5603
|
async loadDeadLetters(remote) {
|
|
5571
5604
|
let records;
|
|
5572
5605
|
try {
|
|
5573
|
-
records = (await this.deadLetterStorage.list(remote.name, {
|
|
5606
|
+
records = (await this.deadLetterStorage.list(remote.meta.name, {
|
|
5574
5607
|
cursor: "0",
|
|
5575
5608
|
limit: this.config.maxDeadLettersPerRemote
|
|
5576
5609
|
})).results;
|
|
5577
5610
|
} catch (error) {
|
|
5578
|
-
this.logger.error("Failed to load dead letters for remote (@name, @error)", remote.name, error instanceof Error ? error.message : String(error));
|
|
5611
|
+
this.logger.error("Failed to load dead letters for remote (@name, @error)", remote.meta.name, error instanceof Error ? error.message : String(error));
|
|
5579
5612
|
return;
|
|
5580
5613
|
}
|
|
5581
5614
|
if (records.length === 0) return;
|
|
@@ -5587,10 +5620,10 @@ var SyncManager = class {
|
|
|
5587
5620
|
syncOps.push(syncOp);
|
|
5588
5621
|
}
|
|
5589
5622
|
remote.channel.deadLetter.add(...syncOps);
|
|
5590
|
-
this.logger.debug("Loaded @count persisted dead letters for remote @name", records.length, remote.name);
|
|
5623
|
+
this.logger.debug("Loaded @count persisted dead letters for remote @name", records.length, remote.meta.name);
|
|
5591
5624
|
}
|
|
5592
5625
|
getRemotesForCollection(collectionId) {
|
|
5593
|
-
return Array.from(this.remotes.values()).filter((remote) => remote.collectionId.key === collectionId);
|
|
5626
|
+
return Array.from(this.remotes.values()).filter((remote) => remote.meta.collectionId.key === collectionId);
|
|
5594
5627
|
}
|
|
5595
5628
|
async processCompleteBatch(batch) {
|
|
5596
5629
|
if (this.isShutdown) return;
|
|
@@ -5636,11 +5669,11 @@ var SyncManager = class {
|
|
|
5636
5669
|
const operations = syncOp.operations.map((op) => op.operation);
|
|
5637
5670
|
let jobInfo;
|
|
5638
5671
|
try {
|
|
5639
|
-
jobInfo = await this.reactor.load(syncOp.documentId, syncOp.branch, operations, this.abortController.signal, { sourceRemote: remote.name });
|
|
5672
|
+
jobInfo = await this.reactor.load(syncOp.documentId, syncOp.branch, operations, this.abortController.signal, { sourceRemote: remote.meta.name });
|
|
5640
5673
|
} catch (error) {
|
|
5641
5674
|
if (this.isShutdown) return;
|
|
5642
5675
|
const err = error instanceof Error ? error : new Error(String(error));
|
|
5643
|
-
this.logger.error("Failed to load operations from inbox (@remote, @documentId, @error)", remote.name, syncOp.documentId, err.message);
|
|
5676
|
+
this.logger.error("Failed to load operations from inbox (@remote, @documentId, @error)", remote.meta.name, syncOp.documentId, err.message);
|
|
5644
5677
|
const channelError = new ChannelError(ChannelErrorSource.Inbox, err);
|
|
5645
5678
|
syncOp.failed(channelError);
|
|
5646
5679
|
remote.channel.deadLetter.add(syncOp);
|
|
@@ -5653,7 +5686,7 @@ var SyncManager = class {
|
|
|
5653
5686
|
} catch (error) {
|
|
5654
5687
|
if (this.isShutdown) return;
|
|
5655
5688
|
const err = error instanceof Error ? error : new Error(String(error));
|
|
5656
|
-
this.logger.error("Failed to wait for job completion (@remote, @documentId, @jobId, @error)", remote.name, syncOp.documentId, jobInfo.id, err.message);
|
|
5689
|
+
this.logger.error("Failed to wait for job completion (@remote, @documentId, @jobId, @error)", remote.meta.name, syncOp.documentId, jobInfo.id, err.message);
|
|
5657
5690
|
const channelError = new ChannelError(ChannelErrorSource.Inbox, err);
|
|
5658
5691
|
syncOp.failed(channelError);
|
|
5659
5692
|
remote.channel.deadLetter.add(syncOp);
|
|
@@ -5663,7 +5696,7 @@ var SyncManager = class {
|
|
|
5663
5696
|
if (this.isShutdown) return;
|
|
5664
5697
|
if (completedJobInfo.status === JobStatus.FAILED) {
|
|
5665
5698
|
const errorMessage = completedJobInfo.error?.message || "Unknown error";
|
|
5666
|
-
this.logger.error("Failed to apply operations from inbox (@remote, @documentId, @jobId, @error)", remote.name, syncOp.documentId, completedJobInfo.id, errorMessage);
|
|
5699
|
+
this.logger.error("Failed to apply operations from inbox (@remote, @documentId, @jobId, @error)", remote.meta.name, syncOp.documentId, completedJobInfo.id, errorMessage);
|
|
5667
5700
|
const error = new ChannelError(ChannelErrorSource.Inbox, /* @__PURE__ */ new Error(`Failed to apply operations: ${errorMessage}`));
|
|
5668
5701
|
syncOp.failed(error);
|
|
5669
5702
|
remote.channel.deadLetter.add(syncOp);
|
|
@@ -5671,7 +5704,7 @@ var SyncManager = class {
|
|
|
5671
5704
|
remote.channel.inbox.remove(syncOp);
|
|
5672
5705
|
}
|
|
5673
5706
|
async applyInboxBatch(items) {
|
|
5674
|
-
const sourceRemote = items[0].remote.name;
|
|
5707
|
+
const sourceRemote = items[0].remote.meta.name;
|
|
5675
5708
|
const chunkKeys = new Set(items.map(({ syncOp }) => syncOp.jobId));
|
|
5676
5709
|
const jobs = items.map(({ syncOp }) => {
|
|
5677
5710
|
const dependsOn = [];
|
|
@@ -5721,7 +5754,7 @@ var SyncManager = class {
|
|
|
5721
5754
|
}
|
|
5722
5755
|
for (const { remote, syncOp } of items) {
|
|
5723
5756
|
if (!(syncOp.jobId in result.jobs)) {
|
|
5724
|
-
this.logger.error("Job key missing from batch load result (@remote, @documentId, @jobId)", remote.name, syncOp.documentId, syncOp.jobId);
|
|
5757
|
+
this.logger.error("Job key missing from batch load result (@remote, @documentId, @jobId)", remote.meta.name, syncOp.documentId, syncOp.jobId);
|
|
5725
5758
|
const error = new ChannelError(ChannelErrorSource.Inbox, /* @__PURE__ */ new Error(`Job key '${syncOp.jobId}' missing from batch load result`));
|
|
5726
5759
|
syncOp.failed(error);
|
|
5727
5760
|
remote.channel.deadLetter.add(syncOp);
|
|
@@ -5755,7 +5788,7 @@ var SyncManager = class {
|
|
|
5755
5788
|
let maxOrdinal = ackOrdinal;
|
|
5756
5789
|
const lastJobByDoc = /* @__PURE__ */ new Map();
|
|
5757
5790
|
let prevChainJobId;
|
|
5758
|
-
const sinceTimestamp = remote.options.sinceTimestampUtcMs;
|
|
5791
|
+
const sinceTimestamp = remote.meta.options.sinceTimestampUtcMs;
|
|
5759
5792
|
const emitBatches = (operations) => {
|
|
5760
5793
|
if (operations.length === 0) return;
|
|
5761
5794
|
const batches = batchOperationsByDocument(operations);
|
|
@@ -5766,14 +5799,14 @@ var SyncManager = class {
|
|
|
5766
5799
|
const deps = [];
|
|
5767
5800
|
if (prevJobId) deps.push(prevJobId);
|
|
5768
5801
|
if (mode === OutboxMode.BatchTriggered && prevChainJobId && prevChainJobId !== prevJobId) deps.push(prevChainJobId);
|
|
5769
|
-
const syncOp = new SyncOperation(crypto.randomUUID(), jobId, deps, remote.name, batch.documentId, [batch.scope], batch.branch, batch.operations);
|
|
5802
|
+
const syncOp = new SyncOperation(crypto.randomUUID(), jobId, deps, remote.meta.name, batch.documentId, [batch.scope], batch.branch, batch.operations);
|
|
5770
5803
|
syncOps.push(syncOp);
|
|
5771
5804
|
lastJobByDoc.set(batch.documentId, jobId);
|
|
5772
5805
|
if (mode === OutboxMode.BatchTriggered) prevChainJobId = jobId;
|
|
5773
5806
|
}
|
|
5774
5807
|
remote.channel.outbox.add(...syncOps);
|
|
5775
5808
|
};
|
|
5776
|
-
let page = await this.operationIndex.find(remote.collectionId.key, ackOrdinal, { excludeSourceRemote: remote.name }, void 0, composedSignal);
|
|
5809
|
+
let page = await this.operationIndex.find(remote.meta.collectionId.key, ackOrdinal, { excludeSourceRemote: remote.meta.name }, void 0, composedSignal);
|
|
5777
5810
|
let carry = [];
|
|
5778
5811
|
let hasMore;
|
|
5779
5812
|
do {
|
|
@@ -5785,7 +5818,7 @@ var SyncManager = class {
|
|
|
5785
5818
|
carry = [];
|
|
5786
5819
|
}
|
|
5787
5820
|
if (sinceTimestamp && sinceTimestamp !== "0") operations = operations.filter((op) => op.operation.timestampUtcMs >= sinceTimestamp);
|
|
5788
|
-
operations = filterOperations(operations, remote.filter);
|
|
5821
|
+
operations = filterOperations(operations, remote.meta.filter);
|
|
5789
5822
|
operations = operations.filter((op) => !this.quarantinedDocumentIds.has(op.context.documentId));
|
|
5790
5823
|
hasMore = !!page.next;
|
|
5791
5824
|
if (operations.length > 0) {
|
|
@@ -6715,6 +6748,7 @@ var ReactorBuilder = class {
|
|
|
6715
6748
|
const keyframeStore = new KyselyKeyframeStore(database);
|
|
6716
6749
|
const eventBus = this.eventBus || new EventBus();
|
|
6717
6750
|
const resolver = this.documentModelLoader ? new DocumentModelResolver(documentModelRegistry, this.documentModelLoader) : new NullDocumentModelResolver(documentModelRegistry);
|
|
6751
|
+
if (resolver instanceof DocumentModelResolver) resolver.setModelLoadedHook((documentType) => eventBus.emit(ReactorEventTypes.MODEL_LOADED, { documentType }));
|
|
6718
6752
|
const queue = this.queueInstance ?? new InMemoryQueue(eventBus, resolver);
|
|
6719
6753
|
const jobTracker = new InMemoryJobTracker(eventBus);
|
|
6720
6754
|
const writeCache = new KyselyWriteCache(keyframeStore, operationStore, documentModelRegistry, {
|
|
@@ -6830,7 +6864,7 @@ var ReactorBuilder = class {
|
|
|
6830
6864
|
poolInstrumentations.push(forwarder);
|
|
6831
6865
|
this.instrumentedPools.push(forwarder);
|
|
6832
6866
|
}
|
|
6833
|
-
const { ProjectionShardManager } = await import("./projection-shard-manager-
|
|
6867
|
+
const { ProjectionShardManager } = await import("./projection-shard-manager-BnQKFqQd.js");
|
|
6834
6868
|
const manager = new ProjectionShardManager({
|
|
6835
6869
|
shardCount: config.shardCount,
|
|
6836
6870
|
db,
|
|
@@ -6863,7 +6897,7 @@ var ReactorBuilder = class {
|
|
|
6863
6897
|
const [{ WorkerHandle }, { createThreadTransport }, { workerEntryPath }] = await Promise.all([
|
|
6864
6898
|
import("./worker-handle-B1w03nRA.js"),
|
|
6865
6899
|
import("./transport-ByGviWdZ.js"),
|
|
6866
|
-
import("./worker-
|
|
6900
|
+
import("./worker-DBJOv8Gp.js").then((n) => n.n)
|
|
6867
6901
|
]);
|
|
6868
6902
|
const db = this.workerDbConfig;
|
|
6869
6903
|
const signatureVerifier = this.workerSignatureVerifierSpec;
|