@powerhousedao/reactor 5.2.0-staging.9 → 5.3.0-staging.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/src/actions/index.d.ts +24 -0
- package/dist/src/actions/index.d.ts.map +1 -0
- package/dist/src/actions/index.js +76 -0
- package/dist/src/actions/index.js.map +1 -0
- package/dist/src/cache/document-meta-cache.d.ts.map +1 -1
- package/dist/src/cache/document-meta-cache.js +2 -1
- package/dist/src/cache/document-meta-cache.js.map +1 -1
- package/dist/src/cache/kysely-operation-index.d.ts.map +1 -1
- package/dist/src/cache/kysely-operation-index.js +14 -25
- package/dist/src/cache/kysely-operation-index.js.map +1 -1
- package/dist/src/cache/kysely-write-cache.d.ts.map +1 -1
- package/dist/src/cache/kysely-write-cache.js +3 -2
- package/dist/src/cache/kysely-write-cache.js.map +1 -1
- package/dist/src/cache/operation-index-types.d.ts +1 -1
- package/dist/src/client/reactor-client.d.ts +16 -4
- package/dist/src/client/reactor-client.d.ts.map +1 -1
- package/dist/src/client/reactor-client.js +97 -3
- package/dist/src/client/reactor-client.js.map +1 -1
- package/dist/src/client/types.d.ts +22 -3
- package/dist/src/client/types.d.ts.map +1 -1
- package/dist/src/core/reactor-builder.d.ts +10 -9
- package/dist/src/core/reactor-builder.d.ts.map +1 -1
- package/dist/src/core/reactor-builder.js +52 -14
- package/dist/src/core/reactor-builder.js.map +1 -1
- package/dist/src/core/reactor-client-builder.d.ts +10 -1
- package/dist/src/core/reactor-client-builder.d.ts.map +1 -1
- package/dist/src/core/reactor-client-builder.js +16 -1
- package/dist/src/core/reactor-client-builder.js.map +1 -1
- package/dist/src/core/reactor.d.ts +9 -8
- package/dist/src/core/reactor.d.ts.map +1 -1
- package/dist/src/core/reactor.js +61 -74
- package/dist/src/core/reactor.js.map +1 -1
- package/dist/src/core/types.d.ts +22 -7
- package/dist/src/core/types.d.ts.map +1 -1
- package/dist/src/core/utils.d.ts +1 -2
- package/dist/src/core/utils.d.ts.map +1 -1
- package/dist/src/core/utils.js +1 -1
- package/dist/src/core/utils.js.map +1 -1
- package/dist/src/events/types.d.ts +1 -0
- package/dist/src/events/types.d.ts.map +1 -1
- package/dist/src/executor/simple-job-executor-manager.d.ts +3 -1
- package/dist/src/executor/simple-job-executor-manager.d.ts.map +1 -1
- package/dist/src/executor/simple-job-executor-manager.js +10 -8
- package/dist/src/executor/simple-job-executor-manager.js.map +1 -1
- package/dist/src/executor/simple-job-executor.d.ts +15 -3
- package/dist/src/executor/simple-job-executor.d.ts.map +1 -1
- package/dist/src/executor/simple-job-executor.js +288 -228
- package/dist/src/executor/simple-job-executor.js.map +1 -1
- package/dist/src/executor/types.d.ts +2 -0
- package/dist/src/executor/types.d.ts.map +1 -1
- package/dist/src/executor/types.js.map +1 -1
- package/dist/src/executor/util.d.ts +14 -5
- package/dist/src/executor/util.d.ts.map +1 -1
- package/dist/src/executor/util.js +36 -9
- package/dist/src/executor/util.js.map +1 -1
- package/dist/src/index.d.ts +6 -2
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +7 -1
- package/dist/src/index.js.map +1 -1
- package/dist/src/logging/console.d.ts +11 -1
- package/dist/src/logging/console.d.ts.map +1 -1
- package/dist/src/logging/console.js +45 -14
- package/dist/src/logging/console.js.map +1 -1
- package/dist/src/logging/types.d.ts +1 -0
- package/dist/src/logging/types.d.ts.map +1 -1
- package/dist/src/processors/index.d.ts +3 -0
- package/dist/src/processors/index.d.ts.map +1 -0
- package/dist/src/processors/index.js +2 -0
- package/dist/src/processors/index.js.map +1 -0
- package/dist/src/processors/processor-manager.d.ts +38 -0
- package/dist/src/processors/processor-manager.d.ts.map +1 -0
- package/dist/src/processors/processor-manager.js +165 -0
- package/dist/src/processors/processor-manager.js.map +1 -0
- package/dist/src/processors/types.d.ts +63 -0
- package/dist/src/processors/types.d.ts.map +1 -0
- package/dist/src/processors/types.js +2 -0
- package/dist/src/processors/types.js.map +1 -0
- package/dist/src/processors/utils.d.ts +10 -0
- package/dist/src/processors/utils.d.ts.map +1 -0
- package/dist/src/processors/utils.js +58 -0
- package/dist/src/processors/utils.js.map +1 -0
- package/dist/src/queue/types.d.ts +2 -0
- package/dist/src/queue/types.d.ts.map +1 -1
- package/dist/src/queue/types.js.map +1 -1
- package/dist/src/read-models/coordinator.d.ts +3 -2
- package/dist/src/read-models/coordinator.d.ts.map +1 -1
- package/dist/src/read-models/coordinator.js +12 -13
- package/dist/src/read-models/coordinator.js.map +1 -1
- package/dist/src/read-models/document-view.d.ts.map +1 -1
- package/dist/src/read-models/document-view.js +2 -0
- package/dist/src/read-models/document-view.js.map +1 -1
- package/dist/src/registry/implementation.d.ts +42 -34
- package/dist/src/registry/implementation.d.ts.map +1 -1
- package/dist/src/registry/implementation.js +168 -48
- package/dist/src/registry/implementation.js.map +1 -1
- package/dist/src/registry/interfaces.d.ts +69 -8
- package/dist/src/registry/interfaces.d.ts.map +1 -1
- package/dist/src/shared/errors.d.ts +16 -0
- package/dist/src/shared/errors.d.ts.map +1 -1
- package/dist/src/shared/errors.js +28 -0
- package/dist/src/shared/errors.js.map +1 -1
- package/dist/src/shared/types.d.ts +4 -0
- package/dist/src/shared/types.d.ts.map +1 -1
- package/dist/src/shared/types.js.map +1 -1
- package/dist/src/signer/passthrough-signer.d.ts +9 -3
- package/dist/src/signer/passthrough-signer.d.ts.map +1 -1
- package/dist/src/signer/passthrough-signer.js +13 -0
- package/dist/src/signer/passthrough-signer.js.map +1 -1
- package/dist/src/signer/types.d.ts +2 -22
- package/dist/src/signer/types.d.ts.map +1 -1
- package/dist/src/storage/interfaces.d.ts +13 -1
- package/dist/src/storage/interfaces.d.ts.map +1 -1
- package/dist/src/storage/interfaces.js +2 -2
- package/dist/src/storage/interfaces.js.map +1 -1
- package/dist/src/storage/kysely/store.d.ts +1 -0
- package/dist/src/storage/kysely/store.d.ts.map +1 -1
- package/dist/src/storage/kysely/store.js +40 -4
- package/dist/src/storage/kysely/store.js.map +1 -1
- package/dist/src/storage/kysely/sync-cursor-storage.js +2 -2
- package/dist/src/storage/kysely/sync-cursor-storage.js.map +1 -1
- package/dist/src/storage/kysely/sync-remote-storage.js +8 -8
- package/dist/src/storage/kysely/sync-remote-storage.js.map +1 -1
- package/dist/src/storage/kysely/types.d.ts +6 -6
- package/dist/src/storage/migrations/001_create_operation_table.d.ts.map +1 -1
- package/dist/src/storage/migrations/001_create_operation_table.js +2 -1
- package/dist/src/storage/migrations/001_create_operation_table.js.map +1 -1
- package/dist/src/storage/migrations/009_create_operation_index_tables.js +1 -1
- package/dist/src/storage/migrations/009_create_operation_index_tables.js.map +1 -1
- package/dist/src/storage/migrations/010_create_sync_tables.js +5 -5
- package/dist/src/storage/migrations/010_create_sync_tables.js.map +1 -1
- package/dist/src/storage/migrations/migrator.d.ts +3 -2
- package/dist/src/storage/migrations/migrator.d.ts.map +1 -1
- package/dist/src/storage/migrations/migrator.js +29 -6
- package/dist/src/storage/migrations/migrator.js.map +1 -1
- package/dist/src/storage/txn.d.ts.map +1 -1
- package/dist/src/storage/txn.js +2 -3
- package/dist/src/storage/txn.js.map +1 -1
- package/dist/src/subs/subscription-notification-read-model.d.ts +17 -0
- package/dist/src/subs/subscription-notification-read-model.d.ts.map +1 -0
- package/dist/src/subs/subscription-notification-read-model.js +62 -0
- package/dist/src/subs/subscription-notification-read-model.js.map +1 -0
- package/dist/src/sync/channels/composite-channel-factory.d.ts +3 -0
- package/dist/src/sync/channels/composite-channel-factory.d.ts.map +1 -1
- package/dist/src/sync/channels/composite-channel-factory.js +5 -1
- package/dist/src/sync/channels/composite-channel-factory.js.map +1 -1
- package/dist/src/sync/channels/gql-channel-factory.d.ts +3 -0
- package/dist/src/sync/channels/gql-channel-factory.d.ts.map +1 -1
- package/dist/src/sync/channels/gql-channel-factory.js +5 -1
- package/dist/src/sync/channels/gql-channel-factory.js.map +1 -1
- package/dist/src/sync/channels/gql-channel.d.ts +15 -1
- package/dist/src/sync/channels/gql-channel.d.ts.map +1 -1
- package/dist/src/sync/channels/gql-channel.js +77 -16
- package/dist/src/sync/channels/gql-channel.js.map +1 -1
- package/dist/src/sync/channels/polling-channel.d.ts.map +1 -1
- package/dist/src/sync/channels/polling-channel.js +7 -5
- package/dist/src/sync/channels/polling-channel.js.map +1 -1
- package/dist/src/sync/channels/utils.d.ts +17 -2
- package/dist/src/sync/channels/utils.d.ts.map +1 -1
- package/dist/src/sync/channels/utils.js +76 -6
- package/dist/src/sync/channels/utils.js.map +1 -1
- package/dist/src/sync/sync-builder.d.ts +3 -2
- package/dist/src/sync/sync-builder.d.ts.map +1 -1
- package/dist/src/sync/sync-builder.js +4 -4
- package/dist/src/sync/sync-builder.js.map +1 -1
- package/dist/src/sync/sync-manager.d.ts +3 -2
- package/dist/src/sync/sync-manager.d.ts.map +1 -1
- package/dist/src/sync/sync-manager.js +17 -13
- package/dist/src/sync/sync-manager.js.map +1 -1
- package/dist/src/sync/utils.d.ts +19 -0
- package/dist/src/sync/utils.d.ts.map +1 -1
- package/dist/src/sync/utils.js +44 -0
- package/dist/src/sync/utils.js.map +1 -1
- package/package.json +3 -3
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import type { IEventBus } from "#events/interfaces.js";
|
|
2
|
+
import type { ILogger } from "#logging/types.js";
|
|
3
|
+
import type { ISigner } from "document-model";
|
|
2
4
|
import { ReactorClient } from "../client/reactor-client.js";
|
|
3
5
|
import { type IJobAwaiter } from "../shared/awaiter.js";
|
|
4
|
-
import type {
|
|
6
|
+
import type { SignerConfig } from "../signer/types.js";
|
|
5
7
|
import type { IDocumentIndexer } from "../storage/interfaces.js";
|
|
6
8
|
import type { IReactorSubscriptionManager } from "../subs/types.js";
|
|
7
9
|
import type { ReactorBuilder } from "./reactor-builder.js";
|
|
@@ -10,6 +12,7 @@ import type { IReactor, ReactorClientModule } from "./types.js";
|
|
|
10
12
|
* Builder class for constructing ReactorClient instances with proper configuration
|
|
11
13
|
*/
|
|
12
14
|
export declare class ReactorClientBuilder {
|
|
15
|
+
private logger?;
|
|
13
16
|
private reactorBuilder?;
|
|
14
17
|
private reactor?;
|
|
15
18
|
private eventBus?;
|
|
@@ -18,6 +21,12 @@ export declare class ReactorClientBuilder {
|
|
|
18
21
|
private signatureVerifier?;
|
|
19
22
|
private subscriptionManager?;
|
|
20
23
|
private jobAwaiter?;
|
|
24
|
+
/**
|
|
25
|
+
* Sets the logger for the ReactorClient.
|
|
26
|
+
* @param logger - The logger to use.
|
|
27
|
+
* @returns The ReactorClientBuilder instance.
|
|
28
|
+
*/
|
|
29
|
+
withLogger(logger: ILogger): this;
|
|
21
30
|
/**
|
|
22
31
|
* Either this or withReactor must be set.
|
|
23
32
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reactor-client-builder.d.ts","sourceRoot":"","sources":["../../../src/core/reactor-client-builder.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"reactor-client-builder.d.ts","sourceRoot":"","sources":["../../../src/core/reactor-client-builder.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAEvD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAC5D,OAAO,EAAc,KAAK,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAEpE,OAAO,KAAK,EAEV,YAAY,EACb,MAAM,oBAAoB,CAAC;AAC5B,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAGjE,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,kBAAkB,CAAC;AACpE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAC3D,OAAO,KAAK,EAAE,QAAQ,EAAE,mBAAmB,EAAiB,MAAM,YAAY,CAAC;AAE/E;;GAEG;AACH,qBAAa,oBAAoB;IAC/B,OAAO,CAAC,MAAM,CAAC,CAAU;IACzB,OAAO,CAAC,cAAc,CAAC,CAAiB;IACxC,OAAO,CAAC,OAAO,CAAC,CAAW;IAC3B,OAAO,CAAC,QAAQ,CAAC,CAAY;IAC7B,OAAO,CAAC,eAAe,CAAC,CAAmB;IAC3C,OAAO,CAAC,MAAM,CAAC,CAAU;IACzB,OAAO,CAAC,iBAAiB,CAAC,CAA+B;IACzD,OAAO,CAAC,mBAAmB,CAAC,CAA8B;IAC1D,OAAO,CAAC,UAAU,CAAC,CAAc;IAEjC;;;;OAIG;IACI,UAAU,CAAC,MAAM,EAAE,OAAO,GAAG,IAAI;IAKxC;;OAEG;IACI,kBAAkB,CAAC,cAAc,EAAE,cAAc,GAAG,IAAI;IAS/D;;OAEG;IACI,WAAW,CAChB,OAAO,EAAE,QAAQ,EACjB,QAAQ,EAAE,SAAS,EACnB,eAAe,EAAE,gBAAgB,GAChC,IAAI;IAWP;;;;OAIG;IACI,UAAU,CAAC,MAAM,EAAE,OAAO,GAAG,YAAY,GAAG,IAAI;IAUhD,uBAAuB,CAC5B,mBAAmB,EAAE,2BAA2B,GAC/C,IAAI;IAKA,cAAc,CAAC,UAAU,EAAE,WAAW,GAAG,IAAI;IAKvC,KAAK,IAAI,OAAO,CAAC,aAAa,CAAC;IAK/B,WAAW,IAAI,OAAO,CAAC,mBAAmB,CAAC;CA8DzD"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ConsoleLogger } from "#logging/console.js";
|
|
1
2
|
import { ReactorClient } from "../client/reactor-client.js";
|
|
2
3
|
import { JobAwaiter } from "../shared/awaiter.js";
|
|
3
4
|
import { PassthroughSigner } from "../signer/passthrough-signer.js";
|
|
@@ -7,6 +8,7 @@ import { ReactorSubscriptionManager } from "../subs/react-subscription-manager.j
|
|
|
7
8
|
* Builder class for constructing ReactorClient instances with proper configuration
|
|
8
9
|
*/
|
|
9
10
|
export class ReactorClientBuilder {
|
|
11
|
+
logger;
|
|
10
12
|
reactorBuilder;
|
|
11
13
|
reactor;
|
|
12
14
|
eventBus;
|
|
@@ -15,6 +17,15 @@ export class ReactorClientBuilder {
|
|
|
15
17
|
signatureVerifier;
|
|
16
18
|
subscriptionManager;
|
|
17
19
|
jobAwaiter;
|
|
20
|
+
/**
|
|
21
|
+
* Sets the logger for the ReactorClient.
|
|
22
|
+
* @param logger - The logger to use.
|
|
23
|
+
* @returns The ReactorClientBuilder instance.
|
|
24
|
+
*/
|
|
25
|
+
withLogger(logger) {
|
|
26
|
+
this.logger = logger;
|
|
27
|
+
return this;
|
|
28
|
+
}
|
|
18
29
|
/**
|
|
19
30
|
* Either this or withReactor must be set.
|
|
20
31
|
*/
|
|
@@ -65,6 +76,9 @@ export class ReactorClientBuilder {
|
|
|
65
76
|
return module.client;
|
|
66
77
|
}
|
|
67
78
|
async buildModule() {
|
|
79
|
+
if (!this.logger) {
|
|
80
|
+
this.logger = new ConsoleLogger(["reactor-client"]);
|
|
81
|
+
}
|
|
68
82
|
let reactor;
|
|
69
83
|
let eventBus;
|
|
70
84
|
let documentIndexer;
|
|
@@ -89,10 +103,11 @@ export class ReactorClientBuilder {
|
|
|
89
103
|
}
|
|
90
104
|
const signer = this.signer ?? new PassthroughSigner();
|
|
91
105
|
const subscriptionManager = this.subscriptionManager ??
|
|
106
|
+
reactorModule?.subscriptionManager ??
|
|
92
107
|
new ReactorSubscriptionManager(new DefaultSubscriptionErrorHandler());
|
|
93
108
|
const jobAwaiter = this.jobAwaiter ??
|
|
94
109
|
new JobAwaiter(eventBus, (jobId, signal) => reactor.getJobStatus(jobId, signal));
|
|
95
|
-
const client = new ReactorClient(reactor, signer, subscriptionManager, jobAwaiter, documentIndexer);
|
|
110
|
+
const client = new ReactorClient(this.logger, reactor, signer, subscriptionManager, jobAwaiter, documentIndexer);
|
|
96
111
|
return {
|
|
97
112
|
client,
|
|
98
113
|
reactor,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reactor-client-builder.js","sourceRoot":"","sources":["../../../src/core/reactor-client-builder.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAC5D,OAAO,EAAE,UAAU,EAAoB,MAAM,sBAAsB,CAAC;AACpE,OAAO,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAC;
|
|
1
|
+
{"version":3,"file":"reactor-client-builder.js","sourceRoot":"","sources":["../../../src/core/reactor-client-builder.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAGpD,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAC5D,OAAO,EAAE,UAAU,EAAoB,MAAM,sBAAsB,CAAC;AACpE,OAAO,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAC;AAMpE,OAAO,EAAE,+BAA+B,EAAE,MAAM,kCAAkC,CAAC;AACnF,OAAO,EAAE,0BAA0B,EAAE,MAAM,uCAAuC,CAAC;AAKnF;;GAEG;AACH,MAAM,OAAO,oBAAoB;IACvB,MAAM,CAAW;IACjB,cAAc,CAAkB;IAChC,OAAO,CAAY;IACnB,QAAQ,CAAa;IACrB,eAAe,CAAoB;IACnC,MAAM,CAAW;IACjB,iBAAiB,CAAgC;IACjD,mBAAmB,CAA+B;IAClD,UAAU,CAAe;IAEjC;;;;OAIG;IACI,UAAU,CAAC,MAAe;QAC/B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;OAEG;IACI,kBAAkB,CAAC,cAA8B;QACtD,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;YACjB,MAAM,IAAI,KAAK,CAAC,wBAAwB,CAAC,CAAC;QAC5C,CAAC;QAED,IAAI,CAAC,cAAc,GAAG,cAAc,CAAC;QACrC,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;OAE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ACV,eAAe,CAChB,CAAC;QAEF,OAAO;YACL,MAAM;YACN,OAAO;YACP,QAAQ;YACR,eAAe;YACf,MAAM;YACN,mBAAmB;YACnB,UAAU;YACV,aAAa;SACd,CAAC;IACJ,CAAC;CACF"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
+
import type { ILogger } from "#logging/types.js";
|
|
1
2
|
import type { BaseDocumentDriveServer } from "document-drive";
|
|
2
|
-
import type { Action, DocumentModelModule, Operation, PHDocument } from "document-model";
|
|
3
|
+
import type { Action, DocumentModelModule, ISigner, Operation, PHDocument } from "document-model";
|
|
3
4
|
import type { IJobTracker } from "../job-tracker/interfaces.js";
|
|
4
5
|
import type { IQueue } from "../queue/interfaces.js";
|
|
5
6
|
import type { IReadModelCoordinator } from "../read-models/interfaces.js";
|
|
6
7
|
import type { ConsistencyToken, JobInfo, PagedResults, PagingOptions, SearchFilter, ShutdownStatus, ViewFilter } from "../shared/types.js";
|
|
7
|
-
import type { ISigner } from "../signer/types.js";
|
|
8
8
|
import type { IConsistencyAwareStorage, IDocumentIndexer, IDocumentView, IOperationStore } from "../storage/interfaces.js";
|
|
9
9
|
import type { BatchExecutionRequest, BatchExecutionResult, IReactor, ReactorFeatures } from "./types.js";
|
|
10
10
|
/**
|
|
@@ -12,6 +12,7 @@ import type { BatchExecutionRequest, BatchExecutionResult, IReactor, ReactorFeat
|
|
|
12
12
|
* for the new Reactor architecture.
|
|
13
13
|
*/
|
|
14
14
|
export declare class Reactor implements IReactor {
|
|
15
|
+
private logger;
|
|
15
16
|
private driveServer;
|
|
16
17
|
private documentStorage;
|
|
17
18
|
private shutdownStatus;
|
|
@@ -23,7 +24,7 @@ export declare class Reactor implements IReactor {
|
|
|
23
24
|
private documentView;
|
|
24
25
|
private _documentIndexer;
|
|
25
26
|
private operationStore;
|
|
26
|
-
constructor(driveServer: BaseDocumentDriveServer, documentStorage: IConsistencyAwareStorage, queue: IQueue, jobTracker: IJobTracker, readModelCoordinator: IReadModelCoordinator, features: ReactorFeatures, documentView: IDocumentView, documentIndexer: IDocumentIndexer, operationStore: IOperationStore);
|
|
27
|
+
constructor(logger: ILogger, driveServer: BaseDocumentDriveServer, documentStorage: IConsistencyAwareStorage, queue: IQueue, jobTracker: IJobTracker, readModelCoordinator: IReadModelCoordinator, features: ReactorFeatures, documentView: IDocumentView, documentIndexer: IDocumentIndexer, operationStore: IOperationStore);
|
|
27
28
|
/**
|
|
28
29
|
* Signals that the reactor should shutdown.
|
|
29
30
|
*/
|
|
@@ -64,25 +65,25 @@ export declare class Reactor implements IReactor {
|
|
|
64
65
|
/**
|
|
65
66
|
* Creates a document
|
|
66
67
|
*/
|
|
67
|
-
create(document: PHDocument, signer?: ISigner, signal?: AbortSignal): Promise<JobInfo>;
|
|
68
|
+
create(document: PHDocument, signer?: ISigner, signal?: AbortSignal, meta?: Record<string, unknown>): Promise<JobInfo>;
|
|
68
69
|
/**
|
|
69
70
|
* Deletes a document
|
|
70
71
|
*/
|
|
71
|
-
deleteDocument(id: string, signer?: ISigner, signal?: AbortSignal): Promise<JobInfo>;
|
|
72
|
+
deleteDocument(id: string, signer?: ISigner, signal?: AbortSignal, meta?: Record<string, unknown>): Promise<JobInfo>;
|
|
72
73
|
/**
|
|
73
74
|
* Applies a list of actions to a document
|
|
74
75
|
*/
|
|
75
|
-
execute(docId: string, branch: string, actions: Action[], signal?: AbortSignal): Promise<JobInfo>;
|
|
76
|
+
execute(docId: string, branch: string, actions: Action[], signal?: AbortSignal, meta?: Record<string, unknown>): Promise<JobInfo>;
|
|
76
77
|
/**
|
|
77
78
|
* Imports pre-existing operations that were produced by another reactor.
|
|
78
79
|
* This function may cause a reshuffle, which will generate additional
|
|
79
80
|
* operations.
|
|
80
81
|
*/
|
|
81
|
-
load(docId: string, branch: string, operations: Operation[], signal?: AbortSignal): Promise<JobInfo>;
|
|
82
|
+
load(docId: string, branch: string, operations: Operation[], signal?: AbortSignal, meta?: Record<string, unknown>): Promise<JobInfo>;
|
|
82
83
|
/**
|
|
83
84
|
* Applies multiple mutations across documents with dependency management
|
|
84
85
|
*/
|
|
85
|
-
executeBatch(request: BatchExecutionRequest, signal?: AbortSignal): Promise<BatchExecutionResult>;
|
|
86
|
+
executeBatch(request: BatchExecutionRequest, signal?: AbortSignal, meta?: Record<string, unknown>): Promise<BatchExecutionResult>;
|
|
86
87
|
/**
|
|
87
88
|
* Adds multiple documents as children to another
|
|
88
89
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reactor.d.ts","sourceRoot":"","sources":["../../../src/core/reactor.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"reactor.d.ts","sourceRoot":"","sources":["../../../src/core/reactor.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,gBAAgB,CAAC;AAE9D,OAAO,KAAK,EACV,MAAM,EAEN,mBAAmB,EACnB,OAAO,EACP,SAAS,EAET,UAAU,EACX,MAAM,gBAAgB,CAAC;AAExB,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAChE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAErD,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AAE1E,OAAO,KAAK,EACV,gBAAgB,EAChB,OAAO,EACP,YAAY,EACZ,aAAa,EACb,YAAY,EACZ,cAAc,EACd,UAAU,EACX,MAAM,oBAAoB,CAAC;AAG5B,OAAO,KAAK,EACV,wBAAwB,EACxB,gBAAgB,EAChB,aAAa,EACb,eAAe,EAChB,MAAM,0BAA0B,CAAC;AAClC,OAAO,KAAK,EACV,qBAAqB,EACrB,oBAAoB,EACpB,QAAQ,EACR,eAAe,EAChB,MAAM,YAAY,CAAC;AAYpB;;;GAGG;AACH,qBAAa,OAAQ,YAAW,QAAQ;IACtC,OAAO,CAAC,MAAM,CAAU;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;IAqF5B;;OAEG;YACW,UAAU;CAsHzB"}
|
package/dist/src/core/reactor.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { addRelationshipAction, createDocumentAction, deleteDocumentAction, removeRelationshipAction, upgradeDocumentAction, } from "#actions/index.js";
|
|
1
2
|
import { AbortError } from "document-drive";
|
|
2
3
|
import { v4 as uuidv4 } from "uuid";
|
|
3
4
|
import { createMutableShutdownStatus } from "../shared/factories.js";
|
|
@@ -9,6 +10,7 @@ import { filterByType, getSharedScope, signAction, signActions, toErrorInfo, top
|
|
|
9
10
|
* for the new Reactor architecture.
|
|
10
11
|
*/
|
|
11
12
|
export class Reactor {
|
|
13
|
+
logger;
|
|
12
14
|
driveServer;
|
|
13
15
|
documentStorage;
|
|
14
16
|
shutdownStatus;
|
|
@@ -20,8 +22,9 @@ export class Reactor {
|
|
|
20
22
|
documentView;
|
|
21
23
|
_documentIndexer;
|
|
22
24
|
operationStore;
|
|
23
|
-
constructor(driveServer, documentStorage, queue, jobTracker, readModelCoordinator, features, documentView, documentIndexer, operationStore) {
|
|
25
|
+
constructor(logger, driveServer, documentStorage, queue, jobTracker, readModelCoordinator, features, documentView, documentIndexer, operationStore) {
|
|
24
26
|
// Store required dependencies
|
|
27
|
+
this.logger = logger;
|
|
25
28
|
this.driveServer = driveServer;
|
|
26
29
|
this.documentStorage = documentStorage;
|
|
27
30
|
this.queue = queue;
|
|
@@ -35,12 +38,14 @@ export class Reactor {
|
|
|
35
38
|
const [status, setter] = createMutableShutdownStatus(false);
|
|
36
39
|
this.shutdownStatus = status;
|
|
37
40
|
this.setShutdown = setter;
|
|
41
|
+
this.logger.verbose("Reactor({ legacyStorage: @legacy })", features.legacyStorageEnabled);
|
|
38
42
|
this.readModelCoordinator.start();
|
|
39
43
|
}
|
|
40
44
|
/**
|
|
41
45
|
* Signals that the reactor should shutdown.
|
|
42
46
|
*/
|
|
43
47
|
kill() {
|
|
48
|
+
this.logger.verbose("kill()");
|
|
44
49
|
// Mark the reactor as shutdown
|
|
45
50
|
this.setShutdown(true);
|
|
46
51
|
// Stop the read model coordinator
|
|
@@ -53,6 +58,7 @@ export class Reactor {
|
|
|
53
58
|
* Retrieves a list of document model specifications
|
|
54
59
|
*/
|
|
55
60
|
getDocumentModels(namespace, paging, signal) {
|
|
61
|
+
this.logger.verbose("getDocumentModels(@namespace, @paging)", namespace, paging);
|
|
56
62
|
// Get document model modules from the drive server + filter
|
|
57
63
|
const modules = this.driveServer.getDocumentModelModules();
|
|
58
64
|
const filteredModels = modules.filter((module) => !namespace || module.documentModel.global.id.startsWith(namespace));
|
|
@@ -80,6 +86,7 @@ export class Reactor {
|
|
|
80
86
|
* Retrieves a specific PHDocument by id
|
|
81
87
|
*/
|
|
82
88
|
async get(id, view, consistencyToken, signal) {
|
|
89
|
+
this.logger.verbose("get(@id, @view)", id, view);
|
|
83
90
|
if (this.features.legacyStorageEnabled) {
|
|
84
91
|
const document = await this.documentStorage.get(id, consistencyToken, signal);
|
|
85
92
|
if (signal?.aborted) {
|
|
@@ -119,6 +126,7 @@ export class Reactor {
|
|
|
119
126
|
* Retrieves a specific PHDocument by slug
|
|
120
127
|
*/
|
|
121
128
|
async getBySlug(slug, view, consistencyToken, signal) {
|
|
129
|
+
this.logger.verbose("getBySlug(@slug, @view)", slug, view);
|
|
122
130
|
if (this.features.legacyStorageEnabled) {
|
|
123
131
|
let ids;
|
|
124
132
|
try {
|
|
@@ -147,6 +155,7 @@ export class Reactor {
|
|
|
147
155
|
* Retrieves a specific PHDocument by identifier (either id or slug)
|
|
148
156
|
*/
|
|
149
157
|
async getByIdOrSlug(identifier, view, consistencyToken, signal) {
|
|
158
|
+
this.logger.verbose("getByIdOrSlug(@identifier, @view)", identifier, view);
|
|
150
159
|
if (this.features.legacyStorageEnabled) {
|
|
151
160
|
try {
|
|
152
161
|
return await this.get(identifier, view, consistencyToken, signal);
|
|
@@ -184,6 +193,7 @@ export class Reactor {
|
|
|
184
193
|
* Retrieves the operations for a document
|
|
185
194
|
*/
|
|
186
195
|
async getOperations(documentId, view, paging, consistencyToken, signal) {
|
|
196
|
+
this.logger.verbose("getOperations(@documentId, @view, @paging)", documentId, view, paging);
|
|
187
197
|
if (this.features.legacyStorageEnabled) {
|
|
188
198
|
// Use storage directly to get the document
|
|
189
199
|
const document = await this.documentStorage.get(documentId, consistencyToken, signal);
|
|
@@ -257,6 +267,7 @@ export class Reactor {
|
|
|
257
267
|
* Filters documents by criteria and returns a list of them
|
|
258
268
|
*/
|
|
259
269
|
async find(search, view, paging, consistencyToken, signal) {
|
|
270
|
+
this.logger.verbose("find(@search, @view, @paging)", search, view, paging);
|
|
260
271
|
let results;
|
|
261
272
|
if (search.ids) {
|
|
262
273
|
if (search.slugs && search.slugs.length > 0) {
|
|
@@ -293,52 +304,36 @@ export class Reactor {
|
|
|
293
304
|
/**
|
|
294
305
|
* Creates a document
|
|
295
306
|
*/
|
|
296
|
-
async create(document, signer, signal) {
|
|
307
|
+
async create(document, signer, signal, meta) {
|
|
308
|
+
this.logger.verbose("create(@id, @type, @slug)", document.header.id, document.header.documentType, document.header.slug);
|
|
297
309
|
const createdAtUtcIso = new Date().toISOString();
|
|
298
310
|
if (signal?.aborted) {
|
|
299
311
|
throw new AbortError();
|
|
300
312
|
}
|
|
301
|
-
|
|
302
|
-
const input = {
|
|
313
|
+
const createInput = {
|
|
303
314
|
model: document.header.documentType,
|
|
304
|
-
version:
|
|
315
|
+
version: 0,
|
|
305
316
|
documentId: document.header.id,
|
|
317
|
+
signing: {
|
|
318
|
+
signature: document.header.id,
|
|
319
|
+
publicKey: document.header.sig.publicKey,
|
|
320
|
+
nonce: document.header.sig.nonce,
|
|
321
|
+
createdAtUtcIso: document.header.createdAtUtcIso,
|
|
322
|
+
documentType: document.header.documentType,
|
|
323
|
+
},
|
|
324
|
+
slug: document.header.slug,
|
|
325
|
+
name: document.header.name,
|
|
326
|
+
branch: document.header.branch,
|
|
327
|
+
meta: document.header.meta,
|
|
306
328
|
};
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
signature: document.header.id,
|
|
310
|
-
publicKey: document.header.sig.publicKey,
|
|
311
|
-
nonce: document.header.sig.nonce,
|
|
312
|
-
createdAtUtcIso: document.header.createdAtUtcIso,
|
|
313
|
-
documentType: document.header.documentType,
|
|
314
|
-
};
|
|
315
|
-
// Add optional mutable header fields (always include even if empty/undefined)
|
|
316
|
-
input.slug = document.header.slug;
|
|
317
|
-
input.name = document.header.name;
|
|
318
|
-
input.branch = document.header.branch;
|
|
319
|
-
input.meta = document.header.meta;
|
|
320
|
-
const createAction = {
|
|
321
|
-
id: `${document.header.id}-create`,
|
|
322
|
-
type: "CREATE_DOCUMENT",
|
|
323
|
-
scope: "document",
|
|
324
|
-
timestampUtcMs: new Date().toISOString(),
|
|
325
|
-
input,
|
|
326
|
-
};
|
|
327
|
-
// Create an UPGRADE_DOCUMENT action to set the initial state
|
|
328
|
-
const upgradeInput = {
|
|
329
|
-
model: document.header.documentType,
|
|
330
|
-
fromVersion: "0.0.0",
|
|
331
|
-
toVersion: "0.0.0", // Same version since we're just setting initial state
|
|
329
|
+
const createAction = createDocumentAction(createInput);
|
|
330
|
+
const upgradeAction = upgradeDocumentAction({
|
|
332
331
|
documentId: document.header.id,
|
|
332
|
+
model: document.header.documentType,
|
|
333
|
+
fromVersion: 0,
|
|
334
|
+
toVersion: 1,
|
|
333
335
|
initialState: document.state,
|
|
334
|
-
};
|
|
335
|
-
const upgradeAction = {
|
|
336
|
-
id: `${document.header.id}-upgrade`,
|
|
337
|
-
type: "UPGRADE_DOCUMENT",
|
|
338
|
-
scope: "document",
|
|
339
|
-
timestampUtcMs: new Date().toISOString(),
|
|
340
|
-
input: upgradeInput,
|
|
341
|
-
};
|
|
336
|
+
});
|
|
342
337
|
// Sign actions if signer is provided
|
|
343
338
|
let actions = [createAction, upgradeAction];
|
|
344
339
|
if (signer) {
|
|
@@ -357,6 +352,7 @@ export class Reactor {
|
|
|
357
352
|
queueHint: [],
|
|
358
353
|
maxRetries: 3,
|
|
359
354
|
errorHistory: [],
|
|
355
|
+
meta,
|
|
360
356
|
};
|
|
361
357
|
// Create job info and register with tracker
|
|
362
358
|
const jobInfo = {
|
|
@@ -368,6 +364,7 @@ export class Reactor {
|
|
|
368
364
|
createdAtUtcIso,
|
|
369
365
|
coordinates: [],
|
|
370
366
|
},
|
|
367
|
+
meta,
|
|
371
368
|
};
|
|
372
369
|
this.jobTracker.registerJob(jobInfo);
|
|
373
370
|
// Enqueue the job
|
|
@@ -377,21 +374,13 @@ export class Reactor {
|
|
|
377
374
|
/**
|
|
378
375
|
* Deletes a document
|
|
379
376
|
*/
|
|
380
|
-
async deleteDocument(id, signer, signal) {
|
|
377
|
+
async deleteDocument(id, signer, signal, meta) {
|
|
378
|
+
this.logger.verbose("deleteDocument(@id)", id);
|
|
381
379
|
const createdAtUtcIso = new Date().toISOString();
|
|
382
380
|
if (signal?.aborted) {
|
|
383
381
|
throw new AbortError();
|
|
384
382
|
}
|
|
385
|
-
|
|
386
|
-
documentId: id,
|
|
387
|
-
};
|
|
388
|
-
let action = {
|
|
389
|
-
id: `${id}-delete`,
|
|
390
|
-
type: "DELETE_DOCUMENT",
|
|
391
|
-
scope: "document",
|
|
392
|
-
timestampUtcMs: new Date().toISOString(),
|
|
393
|
-
input: deleteInput,
|
|
394
|
-
};
|
|
383
|
+
let action = deleteDocumentAction(id);
|
|
395
384
|
// Sign action if signer is provided
|
|
396
385
|
if (signer) {
|
|
397
386
|
action = await signAction(action, signer, signal);
|
|
@@ -408,6 +397,7 @@ export class Reactor {
|
|
|
408
397
|
queueHint: [],
|
|
409
398
|
maxRetries: 3,
|
|
410
399
|
errorHistory: [],
|
|
400
|
+
meta,
|
|
411
401
|
};
|
|
412
402
|
const jobInfo = {
|
|
413
403
|
id: job.id,
|
|
@@ -418,6 +408,7 @@ export class Reactor {
|
|
|
418
408
|
createdAtUtcIso,
|
|
419
409
|
coordinates: [],
|
|
420
410
|
},
|
|
411
|
+
meta,
|
|
421
412
|
};
|
|
422
413
|
this.jobTracker.registerJob(jobInfo);
|
|
423
414
|
await this.queue.enqueue(job);
|
|
@@ -426,7 +417,8 @@ export class Reactor {
|
|
|
426
417
|
/**
|
|
427
418
|
* Applies a list of actions to a document
|
|
428
419
|
*/
|
|
429
|
-
async execute(docId, branch, actions, signal) {
|
|
420
|
+
async execute(docId, branch, actions, signal, meta) {
|
|
421
|
+
this.logger.verbose("execute(@docId, @branch, @actions)", docId, branch, actions);
|
|
430
422
|
if (signal?.aborted) {
|
|
431
423
|
throw new AbortError();
|
|
432
424
|
}
|
|
@@ -446,6 +438,7 @@ export class Reactor {
|
|
|
446
438
|
queueHint: [],
|
|
447
439
|
maxRetries: 3,
|
|
448
440
|
errorHistory: [],
|
|
441
|
+
meta,
|
|
449
442
|
};
|
|
450
443
|
// Create job info and register with tracker
|
|
451
444
|
const jobInfo = {
|
|
@@ -457,6 +450,7 @@ export class Reactor {
|
|
|
457
450
|
createdAtUtcIso,
|
|
458
451
|
coordinates: [],
|
|
459
452
|
},
|
|
453
|
+
meta,
|
|
460
454
|
};
|
|
461
455
|
this.jobTracker.registerJob(jobInfo);
|
|
462
456
|
// Enqueue the job
|
|
@@ -471,7 +465,8 @@ export class Reactor {
|
|
|
471
465
|
* This function may cause a reshuffle, which will generate additional
|
|
472
466
|
* operations.
|
|
473
467
|
*/
|
|
474
|
-
async load(docId, branch, operations, signal) {
|
|
468
|
+
async load(docId, branch, operations, signal, meta) {
|
|
469
|
+
this.logger.verbose("load(@docId, @branch, @count, @operations)", docId, branch, operations.length, operations);
|
|
475
470
|
if (signal?.aborted) {
|
|
476
471
|
throw new AbortError();
|
|
477
472
|
}
|
|
@@ -498,6 +493,7 @@ export class Reactor {
|
|
|
498
493
|
queueHint: [],
|
|
499
494
|
maxRetries: 3,
|
|
500
495
|
errorHistory: [],
|
|
496
|
+
meta,
|
|
501
497
|
};
|
|
502
498
|
const jobInfo = {
|
|
503
499
|
id: job.id,
|
|
@@ -508,6 +504,7 @@ export class Reactor {
|
|
|
508
504
|
createdAtUtcIso,
|
|
509
505
|
coordinates: [],
|
|
510
506
|
},
|
|
507
|
+
meta,
|
|
511
508
|
};
|
|
512
509
|
this.jobTracker.registerJob(jobInfo);
|
|
513
510
|
await this.queue.enqueue(job);
|
|
@@ -519,7 +516,8 @@ export class Reactor {
|
|
|
519
516
|
/**
|
|
520
517
|
* Applies multiple mutations across documents with dependency management
|
|
521
518
|
*/
|
|
522
|
-
async executeBatch(request, signal) {
|
|
519
|
+
async executeBatch(request, signal, meta) {
|
|
520
|
+
this.logger.verbose("executeBatch(@count jobs)", request.jobs.length);
|
|
523
521
|
if (signal?.aborted) {
|
|
524
522
|
throw new AbortError();
|
|
525
523
|
}
|
|
@@ -544,6 +542,7 @@ export class Reactor {
|
|
|
544
542
|
createdAtUtcIso,
|
|
545
543
|
coordinates: [],
|
|
546
544
|
},
|
|
545
|
+
meta,
|
|
547
546
|
};
|
|
548
547
|
this.jobTracker.registerJob(jobInfo);
|
|
549
548
|
jobInfos.set(jobPlan.key, jobInfo);
|
|
@@ -570,6 +569,7 @@ export class Reactor {
|
|
|
570
569
|
queueHint,
|
|
571
570
|
maxRetries: 3,
|
|
572
571
|
errorHistory: [],
|
|
572
|
+
meta,
|
|
573
573
|
};
|
|
574
574
|
await this.queue.enqueue(job);
|
|
575
575
|
enqueuedKeys.push(key);
|
|
@@ -599,20 +599,11 @@ export class Reactor {
|
|
|
599
599
|
* Adds multiple documents as children to another
|
|
600
600
|
*/
|
|
601
601
|
async addChildren(parentId, documentIds, branch = "main", signer, signal) {
|
|
602
|
+
this.logger.verbose("addChildren(@parentId, @count children, @branch)", parentId, documentIds.length, branch);
|
|
602
603
|
if (signal?.aborted) {
|
|
603
604
|
throw new AbortError();
|
|
604
605
|
}
|
|
605
|
-
let actions = documentIds.map((childId) => (
|
|
606
|
-
id: uuidv4(),
|
|
607
|
-
type: "ADD_RELATIONSHIP",
|
|
608
|
-
scope: "document",
|
|
609
|
-
timestampUtcMs: new Date().toISOString(),
|
|
610
|
-
input: {
|
|
611
|
-
sourceId: parentId,
|
|
612
|
-
targetId: childId,
|
|
613
|
-
relationshipType: "child",
|
|
614
|
-
},
|
|
615
|
-
}));
|
|
606
|
+
let actions = documentIds.map((childId) => addRelationshipAction(parentId, childId, "child"));
|
|
616
607
|
// Sign actions if signer is provided
|
|
617
608
|
if (signer) {
|
|
618
609
|
actions = await signActions(actions, signer, signal);
|
|
@@ -623,20 +614,11 @@ export class Reactor {
|
|
|
623
614
|
* Removes multiple documents as children from another
|
|
624
615
|
*/
|
|
625
616
|
async removeChildren(parentId, documentIds, branch = "main", signer, signal) {
|
|
617
|
+
this.logger.verbose("removeChildren(@parentId, @count children, @branch)", parentId, documentIds.length, branch);
|
|
626
618
|
if (signal?.aborted) {
|
|
627
619
|
throw new AbortError();
|
|
628
620
|
}
|
|
629
|
-
let actions = documentIds.map((childId) => (
|
|
630
|
-
id: uuidv4(),
|
|
631
|
-
type: "REMOVE_RELATIONSHIP",
|
|
632
|
-
scope: "document",
|
|
633
|
-
timestampUtcMs: new Date().toISOString(),
|
|
634
|
-
input: {
|
|
635
|
-
sourceId: parentId,
|
|
636
|
-
targetId: childId,
|
|
637
|
-
relationshipType: "child",
|
|
638
|
-
},
|
|
639
|
-
}));
|
|
621
|
+
let actions = documentIds.map((childId) => removeRelationshipAction(parentId, childId, "child"));
|
|
640
622
|
// Sign actions if signer is provided
|
|
641
623
|
if (signer) {
|
|
642
624
|
actions = await signActions(actions, signer, signal);
|
|
@@ -647,6 +629,7 @@ export class Reactor {
|
|
|
647
629
|
* Retrieves the status of a job
|
|
648
630
|
*/
|
|
649
631
|
getJobStatus(jobId, signal) {
|
|
632
|
+
this.logger.verbose("getJobStatus(@jobId)", jobId);
|
|
650
633
|
if (signal?.aborted) {
|
|
651
634
|
throw new AbortError();
|
|
652
635
|
}
|
|
@@ -673,6 +656,7 @@ export class Reactor {
|
|
|
673
656
|
* Finds documents by their IDs
|
|
674
657
|
*/
|
|
675
658
|
async findByIds(ids, view, paging, consistencyToken, signal) {
|
|
659
|
+
this.logger.verbose("findByIds(@count ids)", ids.length);
|
|
676
660
|
if (consistencyToken) {
|
|
677
661
|
await this.documentView.waitForConsistency(consistencyToken, undefined, signal);
|
|
678
662
|
}
|
|
@@ -760,6 +744,7 @@ export class Reactor {
|
|
|
760
744
|
* Finds documents by their slugs
|
|
761
745
|
*/
|
|
762
746
|
async findBySlugs(slugs, view, paging, consistencyToken, signal) {
|
|
747
|
+
this.logger.verbose("findBySlugs(@count slugs)", slugs.length);
|
|
763
748
|
if (consistencyToken) {
|
|
764
749
|
await this.documentView.waitForConsistency(consistencyToken, undefined, signal);
|
|
765
750
|
}
|
|
@@ -868,6 +853,7 @@ export class Reactor {
|
|
|
868
853
|
* Finds documents by parent ID
|
|
869
854
|
*/
|
|
870
855
|
async findByParentId(parentId, view, paging, signal) {
|
|
856
|
+
this.logger.verbose("findByParentId(@parentId)", parentId);
|
|
871
857
|
// Get child relationships from indexer
|
|
872
858
|
const relationships = await this._documentIndexer.getOutgoing(parentId, ["child"], undefined, signal);
|
|
873
859
|
if (signal?.aborted) {
|
|
@@ -923,6 +909,7 @@ export class Reactor {
|
|
|
923
909
|
* Finds documents by type
|
|
924
910
|
*/
|
|
925
911
|
async findByType(type, view, paging, consistencyToken, signal) {
|
|
912
|
+
this.logger.verbose("findByType(@type)", type);
|
|
926
913
|
if (consistencyToken) {
|
|
927
914
|
await this.documentView.waitForConsistency(consistencyToken, undefined, signal);
|
|
928
915
|
}
|