@powerhousedao/reactor 5.2.0-staging.9 → 6.0.0-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/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 +18 -5
- 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 +100 -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 +64 -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 +327 -230
- 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 +39 -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,39 @@ 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,
|
|
328
|
+
protocolVersions: document.header.protocolVersions ?? {
|
|
329
|
+
"base-reducer": 2,
|
|
330
|
+
},
|
|
306
331
|
};
|
|
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
|
|
332
|
+
const createAction = createDocumentAction(createInput);
|
|
333
|
+
const upgradeAction = upgradeDocumentAction({
|
|
332
334
|
documentId: document.header.id,
|
|
335
|
+
model: document.header.documentType,
|
|
336
|
+
fromVersion: 0,
|
|
337
|
+
toVersion: 1,
|
|
333
338
|
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
|
-
};
|
|
339
|
+
});
|
|
342
340
|
// Sign actions if signer is provided
|
|
343
341
|
let actions = [createAction, upgradeAction];
|
|
344
342
|
if (signer) {
|
|
@@ -357,6 +355,7 @@ export class Reactor {
|
|
|
357
355
|
queueHint: [],
|
|
358
356
|
maxRetries: 3,
|
|
359
357
|
errorHistory: [],
|
|
358
|
+
meta,
|
|
360
359
|
};
|
|
361
360
|
// Create job info and register with tracker
|
|
362
361
|
const jobInfo = {
|
|
@@ -368,6 +367,7 @@ export class Reactor {
|
|
|
368
367
|
createdAtUtcIso,
|
|
369
368
|
coordinates: [],
|
|
370
369
|
},
|
|
370
|
+
meta,
|
|
371
371
|
};
|
|
372
372
|
this.jobTracker.registerJob(jobInfo);
|
|
373
373
|
// Enqueue the job
|
|
@@ -377,21 +377,13 @@ export class Reactor {
|
|
|
377
377
|
/**
|
|
378
378
|
* Deletes a document
|
|
379
379
|
*/
|
|
380
|
-
async deleteDocument(id, signer, signal) {
|
|
380
|
+
async deleteDocument(id, signer, signal, meta) {
|
|
381
|
+
this.logger.verbose("deleteDocument(@id)", id);
|
|
381
382
|
const createdAtUtcIso = new Date().toISOString();
|
|
382
383
|
if (signal?.aborted) {
|
|
383
384
|
throw new AbortError();
|
|
384
385
|
}
|
|
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
|
-
};
|
|
386
|
+
let action = deleteDocumentAction(id);
|
|
395
387
|
// Sign action if signer is provided
|
|
396
388
|
if (signer) {
|
|
397
389
|
action = await signAction(action, signer, signal);
|
|
@@ -408,6 +400,7 @@ export class Reactor {
|
|
|
408
400
|
queueHint: [],
|
|
409
401
|
maxRetries: 3,
|
|
410
402
|
errorHistory: [],
|
|
403
|
+
meta,
|
|
411
404
|
};
|
|
412
405
|
const jobInfo = {
|
|
413
406
|
id: job.id,
|
|
@@ -418,6 +411,7 @@ export class Reactor {
|
|
|
418
411
|
createdAtUtcIso,
|
|
419
412
|
coordinates: [],
|
|
420
413
|
},
|
|
414
|
+
meta,
|
|
421
415
|
};
|
|
422
416
|
this.jobTracker.registerJob(jobInfo);
|
|
423
417
|
await this.queue.enqueue(job);
|
|
@@ -426,7 +420,8 @@ export class Reactor {
|
|
|
426
420
|
/**
|
|
427
421
|
* Applies a list of actions to a document
|
|
428
422
|
*/
|
|
429
|
-
async execute(docId, branch, actions, signal) {
|
|
423
|
+
async execute(docId, branch, actions, signal, meta) {
|
|
424
|
+
this.logger.verbose("execute(@docId, @branch, @actions)", docId, branch, actions);
|
|
430
425
|
if (signal?.aborted) {
|
|
431
426
|
throw new AbortError();
|
|
432
427
|
}
|
|
@@ -446,6 +441,7 @@ export class Reactor {
|
|
|
446
441
|
queueHint: [],
|
|
447
442
|
maxRetries: 3,
|
|
448
443
|
errorHistory: [],
|
|
444
|
+
meta,
|
|
449
445
|
};
|
|
450
446
|
// Create job info and register with tracker
|
|
451
447
|
const jobInfo = {
|
|
@@ -457,6 +453,7 @@ export class Reactor {
|
|
|
457
453
|
createdAtUtcIso,
|
|
458
454
|
coordinates: [],
|
|
459
455
|
},
|
|
456
|
+
meta,
|
|
460
457
|
};
|
|
461
458
|
this.jobTracker.registerJob(jobInfo);
|
|
462
459
|
// Enqueue the job
|
|
@@ -471,7 +468,8 @@ export class Reactor {
|
|
|
471
468
|
* This function may cause a reshuffle, which will generate additional
|
|
472
469
|
* operations.
|
|
473
470
|
*/
|
|
474
|
-
async load(docId, branch, operations, signal) {
|
|
471
|
+
async load(docId, branch, operations, signal, meta) {
|
|
472
|
+
this.logger.verbose("load(@docId, @branch, @count, @operations)", docId, branch, operations.length, operations);
|
|
475
473
|
if (signal?.aborted) {
|
|
476
474
|
throw new AbortError();
|
|
477
475
|
}
|
|
@@ -498,6 +496,7 @@ export class Reactor {
|
|
|
498
496
|
queueHint: [],
|
|
499
497
|
maxRetries: 3,
|
|
500
498
|
errorHistory: [],
|
|
499
|
+
meta,
|
|
501
500
|
};
|
|
502
501
|
const jobInfo = {
|
|
503
502
|
id: job.id,
|
|
@@ -508,6 +507,7 @@ export class Reactor {
|
|
|
508
507
|
createdAtUtcIso,
|
|
509
508
|
coordinates: [],
|
|
510
509
|
},
|
|
510
|
+
meta,
|
|
511
511
|
};
|
|
512
512
|
this.jobTracker.registerJob(jobInfo);
|
|
513
513
|
await this.queue.enqueue(job);
|
|
@@ -519,7 +519,8 @@ export class Reactor {
|
|
|
519
519
|
/**
|
|
520
520
|
* Applies multiple mutations across documents with dependency management
|
|
521
521
|
*/
|
|
522
|
-
async executeBatch(request, signal) {
|
|
522
|
+
async executeBatch(request, signal, meta) {
|
|
523
|
+
this.logger.verbose("executeBatch(@count jobs)", request.jobs.length);
|
|
523
524
|
if (signal?.aborted) {
|
|
524
525
|
throw new AbortError();
|
|
525
526
|
}
|
|
@@ -544,6 +545,7 @@ export class Reactor {
|
|
|
544
545
|
createdAtUtcIso,
|
|
545
546
|
coordinates: [],
|
|
546
547
|
},
|
|
548
|
+
meta,
|
|
547
549
|
};
|
|
548
550
|
this.jobTracker.registerJob(jobInfo);
|
|
549
551
|
jobInfos.set(jobPlan.key, jobInfo);
|
|
@@ -570,6 +572,7 @@ export class Reactor {
|
|
|
570
572
|
queueHint,
|
|
571
573
|
maxRetries: 3,
|
|
572
574
|
errorHistory: [],
|
|
575
|
+
meta,
|
|
573
576
|
};
|
|
574
577
|
await this.queue.enqueue(job);
|
|
575
578
|
enqueuedKeys.push(key);
|
|
@@ -599,20 +602,11 @@ export class Reactor {
|
|
|
599
602
|
* Adds multiple documents as children to another
|
|
600
603
|
*/
|
|
601
604
|
async addChildren(parentId, documentIds, branch = "main", signer, signal) {
|
|
605
|
+
this.logger.verbose("addChildren(@parentId, @count children, @branch)", parentId, documentIds.length, branch);
|
|
602
606
|
if (signal?.aborted) {
|
|
603
607
|
throw new AbortError();
|
|
604
608
|
}
|
|
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
|
-
}));
|
|
609
|
+
let actions = documentIds.map((childId) => addRelationshipAction(parentId, childId, "child"));
|
|
616
610
|
// Sign actions if signer is provided
|
|
617
611
|
if (signer) {
|
|
618
612
|
actions = await signActions(actions, signer, signal);
|
|
@@ -623,20 +617,11 @@ export class Reactor {
|
|
|
623
617
|
* Removes multiple documents as children from another
|
|
624
618
|
*/
|
|
625
619
|
async removeChildren(parentId, documentIds, branch = "main", signer, signal) {
|
|
620
|
+
this.logger.verbose("removeChildren(@parentId, @count children, @branch)", parentId, documentIds.length, branch);
|
|
626
621
|
if (signal?.aborted) {
|
|
627
622
|
throw new AbortError();
|
|
628
623
|
}
|
|
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
|
-
}));
|
|
624
|
+
let actions = documentIds.map((childId) => removeRelationshipAction(parentId, childId, "child"));
|
|
640
625
|
// Sign actions if signer is provided
|
|
641
626
|
if (signer) {
|
|
642
627
|
actions = await signActions(actions, signer, signal);
|
|
@@ -647,6 +632,7 @@ export class Reactor {
|
|
|
647
632
|
* Retrieves the status of a job
|
|
648
633
|
*/
|
|
649
634
|
getJobStatus(jobId, signal) {
|
|
635
|
+
this.logger.verbose("getJobStatus(@jobId)", jobId);
|
|
650
636
|
if (signal?.aborted) {
|
|
651
637
|
throw new AbortError();
|
|
652
638
|
}
|
|
@@ -673,6 +659,7 @@ export class Reactor {
|
|
|
673
659
|
* Finds documents by their IDs
|
|
674
660
|
*/
|
|
675
661
|
async findByIds(ids, view, paging, consistencyToken, signal) {
|
|
662
|
+
this.logger.verbose("findByIds(@count ids)", ids.length);
|
|
676
663
|
if (consistencyToken) {
|
|
677
664
|
await this.documentView.waitForConsistency(consistencyToken, undefined, signal);
|
|
678
665
|
}
|
|
@@ -760,6 +747,7 @@ export class Reactor {
|
|
|
760
747
|
* Finds documents by their slugs
|
|
761
748
|
*/
|
|
762
749
|
async findBySlugs(slugs, view, paging, consistencyToken, signal) {
|
|
750
|
+
this.logger.verbose("findBySlugs(@count slugs)", slugs.length);
|
|
763
751
|
if (consistencyToken) {
|
|
764
752
|
await this.documentView.waitForConsistency(consistencyToken, undefined, signal);
|
|
765
753
|
}
|
|
@@ -868,6 +856,7 @@ export class Reactor {
|
|
|
868
856
|
* Finds documents by parent ID
|
|
869
857
|
*/
|
|
870
858
|
async findByParentId(parentId, view, paging, signal) {
|
|
859
|
+
this.logger.verbose("findByParentId(@parentId)", parentId);
|
|
871
860
|
// Get child relationships from indexer
|
|
872
861
|
const relationships = await this._documentIndexer.getOutgoing(parentId, ["child"], undefined, signal);
|
|
873
862
|
if (signal?.aborted) {
|
|
@@ -923,6 +912,7 @@ export class Reactor {
|
|
|
923
912
|
* Finds documents by type
|
|
924
913
|
*/
|
|
925
914
|
async findByType(type, view, paging, consistencyToken, signal) {
|
|
915
|
+
this.logger.verbose("findByType(@type)", type);
|
|
926
916
|
if (consistencyToken) {
|
|
927
917
|
await this.documentView.waitForConsistency(consistencyToken, undefined, signal);
|
|
928
918
|
}
|