@powerhousedao/reactor 4.1.0-dev.9 → 4.1.0-dev.90
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/cache/buffer/ring-buffer.d.ts +37 -0
- package/dist/src/cache/buffer/ring-buffer.d.ts.map +1 -0
- package/dist/src/cache/buffer/ring-buffer.js +69 -0
- package/dist/src/cache/buffer/ring-buffer.js.map +1 -0
- package/dist/src/cache/kysely-write-cache.d.ts +133 -0
- package/dist/src/cache/kysely-write-cache.d.ts.map +1 -0
- package/dist/src/cache/kysely-write-cache.js +375 -0
- package/dist/src/cache/kysely-write-cache.js.map +1 -0
- package/dist/src/cache/lru/lru-tracker.d.ts +15 -0
- package/dist/src/cache/lru/lru-tracker.d.ts.map +1 -0
- package/dist/src/cache/lru/lru-tracker.js +96 -0
- package/dist/src/cache/lru/lru-tracker.js.map +1 -0
- package/dist/src/cache/types.d.ts +42 -0
- package/dist/src/cache/types.d.ts.map +1 -0
- package/dist/src/cache/types.js +2 -0
- package/dist/src/cache/types.js.map +1 -0
- package/dist/src/cache/write/interfaces.d.ts +83 -0
- package/dist/src/cache/write/interfaces.d.ts.map +1 -0
- package/dist/src/cache/write/interfaces.js +2 -0
- package/dist/src/cache/write/interfaces.js.map +1 -0
- package/dist/src/client/reactor-client.d.ts +103 -0
- package/dist/src/client/reactor-client.d.ts.map +1 -0
- package/dist/src/client/reactor-client.js +184 -0
- package/dist/src/client/reactor-client.js.map +1 -0
- package/dist/src/client/types.d.ts +213 -0
- package/dist/src/client/types.d.ts.map +1 -0
- package/dist/src/client/types.js +14 -0
- package/dist/src/client/types.js.map +1 -0
- package/dist/src/core/builder.d.ts +20 -0
- package/dist/src/core/builder.d.ts.map +1 -0
- package/dist/src/core/builder.js +47 -0
- package/dist/src/core/builder.js.map +1 -0
- package/dist/src/core/reactor.d.ts +92 -0
- package/dist/src/core/reactor.d.ts.map +1 -0
- package/dist/src/core/reactor.js +646 -0
- package/dist/src/core/reactor.js.map +1 -0
- package/dist/src/core/types.d.ts +121 -0
- package/dist/src/core/types.d.ts.map +1 -0
- package/dist/src/core/types.js +2 -0
- package/dist/src/core/types.js.map +1 -0
- package/dist/src/core/utils.d.ts +11 -0
- package/dist/src/core/utils.d.ts.map +1 -0
- package/dist/src/core/utils.js +31 -0
- package/dist/src/core/utils.js.map +1 -0
- package/dist/src/events/event-bus.d.ts +3 -3
- package/dist/src/events/event-bus.d.ts.map +1 -1
- package/dist/src/events/event-bus.js.map +1 -1
- package/dist/src/events/interfaces.d.ts +1 -1
- package/dist/src/events/interfaces.d.ts.map +1 -1
- package/dist/src/events/types.d.ts +15 -1
- package/dist/src/events/types.d.ts.map +1 -1
- package/dist/src/events/types.js +6 -0
- package/dist/src/events/types.js.map +1 -1
- package/dist/src/executor/interfaces.d.ts +31 -54
- package/dist/src/executor/interfaces.d.ts.map +1 -1
- package/dist/src/executor/simple-job-executor-manager.d.ts +31 -0
- package/dist/src/executor/simple-job-executor-manager.d.ts.map +1 -0
- package/dist/src/executor/simple-job-executor-manager.js +190 -0
- package/dist/src/executor/simple-job-executor-manager.js.map +1 -0
- package/dist/src/executor/simple-job-executor.d.ts +48 -0
- package/dist/src/executor/simple-job-executor.d.ts.map +1 -0
- package/dist/src/executor/simple-job-executor.js +488 -0
- package/dist/src/executor/simple-job-executor.js.map +1 -0
- package/dist/src/executor/types.d.ts +30 -8
- 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 +47 -0
- package/dist/src/executor/util.d.ts.map +1 -0
- package/dist/src/executor/util.js +113 -0
- package/dist/src/executor/util.js.map +1 -0
- package/dist/src/index.d.ts +30 -3
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +36 -2
- package/dist/src/index.js.map +1 -1
- package/dist/src/job-tracker/in-memory-job-tracker.d.ts +15 -0
- package/dist/src/job-tracker/in-memory-job-tracker.d.ts.map +1 -0
- package/dist/src/job-tracker/in-memory-job-tracker.js +78 -0
- package/dist/src/job-tracker/in-memory-job-tracker.js.map +1 -0
- package/dist/src/job-tracker/index.d.ts +3 -0
- package/dist/src/job-tracker/index.d.ts.map +1 -0
- package/dist/src/job-tracker/index.js +2 -0
- package/dist/src/job-tracker/index.js.map +1 -0
- package/dist/src/job-tracker/interfaces.d.ts +41 -0
- package/dist/src/job-tracker/interfaces.d.ts.map +1 -0
- package/dist/src/job-tracker/interfaces.js +2 -0
- package/dist/src/job-tracker/interfaces.js.map +1 -0
- package/dist/src/queue/interfaces.d.ts +45 -5
- package/dist/src/queue/interfaces.d.ts.map +1 -1
- package/dist/src/queue/job-execution-handle.d.ts +24 -0
- package/dist/src/queue/job-execution-handle.d.ts.map +1 -0
- package/dist/src/queue/job-execution-handle.js +62 -0
- package/dist/src/queue/job-execution-handle.js.map +1 -0
- package/dist/src/queue/queue.d.ts +54 -5
- package/dist/src/queue/queue.d.ts.map +1 -1
- package/dist/src/queue/queue.js +272 -36
- package/dist/src/queue/queue.js.map +1 -1
- package/dist/src/queue/types.d.ts +32 -5
- package/dist/src/queue/types.d.ts.map +1 -1
- package/dist/src/queue/types.js +12 -0
- package/dist/src/queue/types.js.map +1 -1
- package/dist/src/read-models/coordinator.d.ts +38 -0
- package/dist/src/read-models/coordinator.d.ts.map +1 -0
- package/dist/src/read-models/coordinator.js +62 -0
- package/dist/src/read-models/coordinator.js.map +1 -0
- package/dist/src/read-models/document-view.d.ts +20 -0
- package/dist/src/read-models/document-view.d.ts.map +1 -0
- package/dist/src/read-models/document-view.js +365 -0
- package/dist/src/read-models/document-view.js.map +1 -0
- package/dist/src/read-models/interfaces.d.ts +29 -0
- package/dist/src/read-models/interfaces.d.ts.map +1 -0
- package/dist/src/read-models/interfaces.js +2 -0
- package/dist/src/read-models/interfaces.js.map +1 -0
- package/dist/src/read-models/types.d.ts +46 -0
- package/dist/src/read-models/types.d.ts.map +1 -0
- package/dist/src/read-models/types.js +2 -0
- package/dist/src/read-models/types.js.map +1 -0
- package/dist/src/registry/implementation.d.ts +62 -0
- package/dist/src/registry/implementation.d.ts.map +1 -0
- package/dist/src/registry/implementation.js +96 -0
- package/dist/src/registry/implementation.js.map +1 -0
- package/dist/src/registry/index.d.ts +3 -0
- package/dist/src/registry/index.d.ts.map +1 -0
- package/dist/src/registry/index.js +2 -0
- package/dist/src/registry/index.js.map +1 -0
- package/dist/src/registry/interfaces.d.ts +39 -0
- package/dist/src/registry/interfaces.d.ts.map +1 -0
- package/dist/src/registry/interfaces.js +2 -0
- package/dist/src/registry/interfaces.js.map +1 -0
- package/dist/src/shared/awaiter.d.ts +32 -0
- package/dist/src/shared/awaiter.d.ts.map +1 -0
- package/dist/src/shared/awaiter.js +132 -0
- package/dist/src/shared/awaiter.js.map +1 -0
- package/dist/src/shared/errors.d.ts +17 -0
- package/dist/src/shared/errors.d.ts.map +1 -0
- package/dist/src/shared/errors.js +33 -0
- package/dist/src/shared/errors.js.map +1 -0
- package/dist/src/shared/factories.d.ts +16 -0
- package/dist/src/shared/factories.d.ts.map +1 -0
- package/dist/src/shared/factories.js +33 -0
- package/dist/src/shared/factories.js.map +1 -0
- package/dist/src/shared/types.d.ts +91 -19
- package/dist/src/shared/types.d.ts.map +1 -1
- package/dist/src/shared/types.js +35 -1
- package/dist/src/shared/types.js.map +1 -1
- package/dist/src/shared/utils.d.ts +3 -0
- package/dist/src/shared/utils.d.ts.map +1 -0
- package/dist/src/shared/utils.js +8 -0
- package/dist/src/shared/utils.js.map +1 -0
- package/dist/src/signer/passthrough-signer.d.ts +6 -0
- package/dist/src/signer/passthrough-signer.d.ts.map +1 -0
- package/dist/src/signer/passthrough-signer.js +6 -0
- package/dist/src/signer/passthrough-signer.js.map +1 -0
- package/dist/src/signer/types.d.ts +15 -0
- package/dist/src/signer/types.d.ts.map +1 -0
- package/dist/src/signer/types.js +2 -0
- package/dist/src/signer/types.js.map +1 -0
- package/dist/src/storage/interfaces.d.ts +121 -0
- package/dist/src/storage/interfaces.d.ts.map +1 -0
- package/dist/src/storage/interfaces.js +19 -0
- package/dist/src/storage/interfaces.js.map +1 -0
- package/dist/src/storage/kysely/keyframe-store.d.ts +15 -0
- package/dist/src/storage/kysely/keyframe-store.d.ts.map +1 -0
- package/dist/src/storage/kysely/keyframe-store.js +71 -0
- package/dist/src/storage/kysely/keyframe-store.js.map +1 -0
- package/dist/src/storage/kysely/store.d.ts +15 -0
- package/dist/src/storage/kysely/store.d.ts.map +1 -0
- package/dist/src/storage/kysely/store.js +196 -0
- package/dist/src/storage/kysely/store.js.map +1 -0
- package/dist/src/storage/kysely/types.d.ts +39 -0
- package/dist/src/storage/kysely/types.d.ts.map +1 -0
- package/dist/src/storage/kysely/types.js +2 -0
- package/dist/src/storage/kysely/types.js.map +1 -0
- package/dist/src/storage/txn.d.ts +15 -0
- package/dist/src/storage/txn.d.ts.map +1 -0
- package/dist/src/storage/txn.js +41 -0
- package/dist/src/storage/txn.js.map +1 -0
- package/dist/src/subs/default-error-handler.d.ts +13 -0
- package/dist/src/subs/default-error-handler.d.ts.map +1 -0
- package/dist/src/subs/default-error-handler.js +27 -0
- package/dist/src/subs/default-error-handler.js.map +1 -0
- package/dist/src/subs/react-subscription-manager.d.ts +45 -0
- package/dist/src/subs/react-subscription-manager.d.ts.map +1 -0
- package/dist/src/subs/react-subscription-manager.js +185 -0
- package/dist/src/subs/react-subscription-manager.js.map +1 -0
- package/dist/src/subs/types.d.ts +64 -0
- package/dist/src/subs/types.d.ts.map +1 -0
- package/dist/src/subs/types.js +2 -0
- package/dist/src/subs/types.js.map +1 -0
- package/dist/src/utils/reshuffle.d.ts +30 -0
- package/dist/src/utils/reshuffle.d.ts.map +1 -0
- package/dist/src/utils/reshuffle.js +47 -0
- package/dist/src/utils/reshuffle.js.map +1 -0
- package/package.json +18 -7
- package/dist/bench/end-to-end-flow.bench.d.ts +0 -2
- package/dist/bench/end-to-end-flow.bench.d.ts.map +0 -1
- package/dist/bench/end-to-end-flow.bench.js +0 -256
- package/dist/bench/end-to-end-flow.bench.js.map +0 -1
- package/dist/bench/event-bus.bench.d.ts +0 -2
- package/dist/bench/event-bus.bench.d.ts.map +0 -1
- package/dist/bench/event-bus.bench.js +0 -238
- package/dist/bench/event-bus.bench.js.map +0 -1
- package/dist/bench/queue-only.bench.d.ts +0 -2
- package/dist/bench/queue-only.bench.d.ts.map +0 -1
- package/dist/bench/queue-only.bench.js +0 -40
- package/dist/bench/queue-only.bench.js.map +0 -1
- package/dist/bench/reactor-throughput.bench.d.ts +0 -2
- package/dist/bench/reactor-throughput.bench.d.ts.map +0 -1
- package/dist/bench/reactor-throughput.bench.js +0 -137
- package/dist/bench/reactor-throughput.bench.js.map +0 -1
- package/dist/src/executor/job-executor.d.ts +0 -62
- package/dist/src/executor/job-executor.d.ts.map +0 -1
- package/dist/src/executor/job-executor.js +0 -325
- package/dist/src/executor/job-executor.js.map +0 -1
- package/dist/test/event-bus.test.d.ts +0 -2
- package/dist/test/event-bus.test.d.ts.map +0 -1
- package/dist/test/event-bus.test.js +0 -532
- package/dist/test/event-bus.test.js.map +0 -1
- package/dist/test/job-executor.test.d.ts +0 -2
- package/dist/test/job-executor.test.d.ts.map +0 -1
- package/dist/test/job-executor.test.js +0 -581
- package/dist/test/job-executor.test.js.map +0 -1
- package/dist/test/queue.test.d.ts +0 -2
- package/dist/test/queue.test.d.ts.map +0 -1
- package/dist/test/queue.test.js +0 -396
- package/dist/test/queue.test.js.map +0 -1
- package/dist/tsconfig.tsbuildinfo +0 -1
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import type { IDocumentOperationStorage, IDocumentStorage } from "document-drive";
|
|
2
|
+
import type { IWriteCache } from "../cache/write/interfaces.js";
|
|
3
|
+
import type { IEventBus } from "../events/interfaces.js";
|
|
4
|
+
import type { Job } from "../queue/types.js";
|
|
5
|
+
import type { IDocumentModelRegistry } from "../registry/interfaces.js";
|
|
6
|
+
import type { IOperationStore } from "../storage/interfaces.js";
|
|
7
|
+
import type { IJobExecutor } from "./interfaces.js";
|
|
8
|
+
import type { JobResult } from "./types.js";
|
|
9
|
+
/**
|
|
10
|
+
* Simple job executor that processes a job by applying actions through document model reducers.
|
|
11
|
+
*
|
|
12
|
+
* @see docs/planning/Storage/IOperationStore.md for storage schema
|
|
13
|
+
* @see docs/planning/Operations/index.md for operation structure
|
|
14
|
+
* @see docs/planning/Jobs/reshuffle.md for skip mechanism details
|
|
15
|
+
*/
|
|
16
|
+
export declare class SimpleJobExecutor implements IJobExecutor {
|
|
17
|
+
private registry;
|
|
18
|
+
private documentStorage;
|
|
19
|
+
private operationStorage;
|
|
20
|
+
private operationStore;
|
|
21
|
+
private eventBus;
|
|
22
|
+
private writeCache;
|
|
23
|
+
constructor(registry: IDocumentModelRegistry, documentStorage: IDocumentStorage, operationStorage: IDocumentOperationStorage, operationStore: IOperationStore, eventBus: IEventBus, writeCache: IWriteCache);
|
|
24
|
+
/**
|
|
25
|
+
* Execute a single job by applying all its actions through the appropriate reducers.
|
|
26
|
+
* Actions are processed sequentially in order.
|
|
27
|
+
*/
|
|
28
|
+
executeJob(job: Job): Promise<JobResult>;
|
|
29
|
+
/**
|
|
30
|
+
* Execute a CREATE_DOCUMENT system action.
|
|
31
|
+
* This creates a new document in storage along with its initial operation.
|
|
32
|
+
* For a new document, the operation index is always 0.
|
|
33
|
+
*/
|
|
34
|
+
private executeCreateDocumentAction;
|
|
35
|
+
/**
|
|
36
|
+
* Execute a DELETE_DOCUMENT system action.
|
|
37
|
+
* This deletes a document from legacy storage and writes the operation to IOperationStore.
|
|
38
|
+
* The operation index is determined from the document's current operation count.
|
|
39
|
+
*/
|
|
40
|
+
private executeDeleteDocumentAction;
|
|
41
|
+
/**
|
|
42
|
+
* Execute an UPGRADE_DOCUMENT system action.
|
|
43
|
+
* This sets the document's initial state from the upgrade action.
|
|
44
|
+
* The operation index is determined from the document's current operation count.
|
|
45
|
+
*/
|
|
46
|
+
private executeUpgradeDocumentAction;
|
|
47
|
+
}
|
|
48
|
+
//# sourceMappingURL=simple-job-executor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"simple-job-executor.d.ts","sourceRoot":"","sources":["../../../src/executor/simple-job-executor.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,yBAAyB,EACzB,gBAAgB,EACjB,MAAM,gBAAgB,CAAC;AAUxB,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAChE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAEzD,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,2BAA2B,CAAC;AAExE,OAAO,KAAK,EACV,eAAe,EAEhB,MAAM,0BAA0B,CAAC;AAClC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AACpD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAQ5C;;;;;;GAMG;AACH,qBAAa,iBAAkB,YAAW,YAAY;IAElD,OAAO,CAAC,QAAQ;IAChB,OAAO,CAAC,eAAe;IACvB,OAAO,CAAC,gBAAgB;IACxB,OAAO,CAAC,cAAc;IACtB,OAAO,CAAC,QAAQ;IAChB,OAAO,CAAC,UAAU;gBALV,QAAQ,EAAE,sBAAsB,EAChC,eAAe,EAAE,gBAAgB,EACjC,gBAAgB,EAAE,yBAAyB,EAC3C,cAAc,EAAE,eAAe,EAC/B,QAAQ,EAAE,SAAS,EACnB,UAAU,EAAE,WAAW;IAGjC;;;OAGG;IACG,UAAU,CAAC,GAAG,EAAE,GAAG,GAAG,OAAO,CAAC,SAAS,CAAC;IA2M9C;;;;OAIG;YACW,2BAA2B;IAyIzC;;;;OAIG;YACW,2BAA2B;IAgJzC;;;;OAIG;YACW,4BAA4B;CAmK3C"}
|
|
@@ -0,0 +1,488 @@
|
|
|
1
|
+
import { OperationEventTypes } from "../events/types.js";
|
|
2
|
+
import { DocumentDeletedError } from "../shared/errors.js";
|
|
3
|
+
import { applyDeleteDocumentAction, applyUpgradeDocumentAction, createDocumentFromAction, getNextIndexForScope, } from "./util.js";
|
|
4
|
+
/**
|
|
5
|
+
* Simple job executor that processes a job by applying actions through document model reducers.
|
|
6
|
+
*
|
|
7
|
+
* @see docs/planning/Storage/IOperationStore.md for storage schema
|
|
8
|
+
* @see docs/planning/Operations/index.md for operation structure
|
|
9
|
+
* @see docs/planning/Jobs/reshuffle.md for skip mechanism details
|
|
10
|
+
*/
|
|
11
|
+
export class SimpleJobExecutor {
|
|
12
|
+
registry;
|
|
13
|
+
documentStorage;
|
|
14
|
+
operationStorage;
|
|
15
|
+
operationStore;
|
|
16
|
+
eventBus;
|
|
17
|
+
writeCache;
|
|
18
|
+
constructor(registry, documentStorage, operationStorage, operationStore, eventBus, writeCache) {
|
|
19
|
+
this.registry = registry;
|
|
20
|
+
this.documentStorage = documentStorage;
|
|
21
|
+
this.operationStorage = operationStorage;
|
|
22
|
+
this.operationStore = operationStore;
|
|
23
|
+
this.eventBus = eventBus;
|
|
24
|
+
this.writeCache = writeCache;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Execute a single job by applying all its actions through the appropriate reducers.
|
|
28
|
+
* Actions are processed sequentially in order.
|
|
29
|
+
*/
|
|
30
|
+
async executeJob(job) {
|
|
31
|
+
const startTime = Date.now();
|
|
32
|
+
const generatedOperations = [];
|
|
33
|
+
const operationsWithContext = [];
|
|
34
|
+
// Process each action in the job sequentially
|
|
35
|
+
for (const action of job.actions) {
|
|
36
|
+
// Handle system actions specially (CREATE_DOCUMENT, DELETE_DOCUMENT, etc.)
|
|
37
|
+
if (action.type === "CREATE_DOCUMENT") {
|
|
38
|
+
const result = await this.executeCreateDocumentAction(job, action, startTime);
|
|
39
|
+
if (!result.success) {
|
|
40
|
+
return result;
|
|
41
|
+
}
|
|
42
|
+
if (result.operations && result.operations.length > 0) {
|
|
43
|
+
generatedOperations.push(...result.operations);
|
|
44
|
+
}
|
|
45
|
+
if (result.operationsWithContext) {
|
|
46
|
+
operationsWithContext.push(...result.operationsWithContext);
|
|
47
|
+
}
|
|
48
|
+
continue;
|
|
49
|
+
}
|
|
50
|
+
if (action.type === "DELETE_DOCUMENT") {
|
|
51
|
+
const result = await this.executeDeleteDocumentAction(job, action, startTime);
|
|
52
|
+
if (!result.success) {
|
|
53
|
+
return result;
|
|
54
|
+
}
|
|
55
|
+
if (result.operations && result.operations.length > 0) {
|
|
56
|
+
generatedOperations.push(...result.operations);
|
|
57
|
+
}
|
|
58
|
+
if (result.operationsWithContext) {
|
|
59
|
+
operationsWithContext.push(...result.operationsWithContext);
|
|
60
|
+
}
|
|
61
|
+
continue;
|
|
62
|
+
}
|
|
63
|
+
if (action.type === "UPGRADE_DOCUMENT") {
|
|
64
|
+
const result = await this.executeUpgradeDocumentAction(job, action, startTime);
|
|
65
|
+
if (!result.success) {
|
|
66
|
+
return result;
|
|
67
|
+
}
|
|
68
|
+
if (result.operations && result.operations.length > 0) {
|
|
69
|
+
generatedOperations.push(...result.operations);
|
|
70
|
+
}
|
|
71
|
+
if (result.operationsWithContext) {
|
|
72
|
+
operationsWithContext.push(...result.operationsWithContext);
|
|
73
|
+
}
|
|
74
|
+
continue;
|
|
75
|
+
}
|
|
76
|
+
// For regular actions, load the document and apply through reducer
|
|
77
|
+
let document;
|
|
78
|
+
try {
|
|
79
|
+
document = await this.writeCache.getState(job.documentId, job.scope, job.branch);
|
|
80
|
+
}
|
|
81
|
+
catch (error) {
|
|
82
|
+
return {
|
|
83
|
+
job,
|
|
84
|
+
success: false,
|
|
85
|
+
error: error instanceof Error ? error : new Error(String(error)),
|
|
86
|
+
duration: Date.now() - startTime,
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
// Check if document is deleted
|
|
90
|
+
const documentState = document.state.document;
|
|
91
|
+
if (documentState.isDeleted) {
|
|
92
|
+
return {
|
|
93
|
+
job,
|
|
94
|
+
success: false,
|
|
95
|
+
error: new DocumentDeletedError(job.documentId, documentState.deletedAtUtcIso),
|
|
96
|
+
duration: Date.now() - startTime,
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
let module;
|
|
100
|
+
try {
|
|
101
|
+
module = this.registry.getModule(document.header.documentType);
|
|
102
|
+
}
|
|
103
|
+
catch (error) {
|
|
104
|
+
return {
|
|
105
|
+
job,
|
|
106
|
+
success: false,
|
|
107
|
+
error: error instanceof Error ? error : new Error(String(error)),
|
|
108
|
+
duration: Date.now() - startTime,
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
// Reducer assigns index based on document's current operation count
|
|
112
|
+
const updatedDocument = module.reducer(document, action);
|
|
113
|
+
const scope = job.scope;
|
|
114
|
+
const operations = updatedDocument.operations[scope];
|
|
115
|
+
if (operations.length === 0) {
|
|
116
|
+
throw new Error("No operation generated from action");
|
|
117
|
+
}
|
|
118
|
+
const newOperation = operations[operations.length - 1];
|
|
119
|
+
generatedOperations.push(newOperation);
|
|
120
|
+
// Write the operation to legacy storage
|
|
121
|
+
try {
|
|
122
|
+
await this.operationStorage.addDocumentOperations(job.documentId, [newOperation], updatedDocument);
|
|
123
|
+
}
|
|
124
|
+
catch (error) {
|
|
125
|
+
return {
|
|
126
|
+
job,
|
|
127
|
+
success: false,
|
|
128
|
+
error: error instanceof Error ? error : new Error(String(error)),
|
|
129
|
+
duration: Date.now() - startTime,
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
// Compute resultingState for passing via context (not persisted)
|
|
133
|
+
const resultingState = JSON.stringify(updatedDocument.state);
|
|
134
|
+
// Write the operation to new IOperationStore (dual-writing)
|
|
135
|
+
try {
|
|
136
|
+
await this.operationStore.apply(job.documentId, document.header.documentType, scope, job.branch, newOperation.index, (txn) => {
|
|
137
|
+
txn.addOperations(newOperation);
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
catch (error) {
|
|
141
|
+
return {
|
|
142
|
+
job,
|
|
143
|
+
success: false,
|
|
144
|
+
error: new Error(`Failed to write operation to IOperationStore: ${error instanceof Error ? error.message : String(error)}`),
|
|
145
|
+
duration: Date.now() - startTime,
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
updatedDocument.header.revision = {
|
|
149
|
+
...updatedDocument.header.revision,
|
|
150
|
+
[scope]: newOperation.index + 1,
|
|
151
|
+
};
|
|
152
|
+
this.writeCache.putState(job.documentId, scope, job.branch, newOperation.index, updatedDocument);
|
|
153
|
+
operationsWithContext.push({
|
|
154
|
+
operation: newOperation,
|
|
155
|
+
context: {
|
|
156
|
+
documentId: job.documentId,
|
|
157
|
+
scope,
|
|
158
|
+
branch: job.branch,
|
|
159
|
+
documentType: document.header.documentType,
|
|
160
|
+
resultingState, // Ephemeral, passed via events only
|
|
161
|
+
},
|
|
162
|
+
});
|
|
163
|
+
}
|
|
164
|
+
// Emit event for read models with all operations - non-blocking
|
|
165
|
+
if (operationsWithContext.length > 0) {
|
|
166
|
+
this.eventBus
|
|
167
|
+
.emit(OperationEventTypes.OPERATION_WRITTEN, {
|
|
168
|
+
operations: operationsWithContext,
|
|
169
|
+
})
|
|
170
|
+
.catch(() => {
|
|
171
|
+
// TODO: Log error
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
return {
|
|
175
|
+
job,
|
|
176
|
+
success: true,
|
|
177
|
+
operations: generatedOperations,
|
|
178
|
+
duration: Date.now() - startTime,
|
|
179
|
+
};
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* Execute a CREATE_DOCUMENT system action.
|
|
183
|
+
* This creates a new document in storage along with its initial operation.
|
|
184
|
+
* For a new document, the operation index is always 0.
|
|
185
|
+
*/
|
|
186
|
+
async executeCreateDocumentAction(job, action, startTime) {
|
|
187
|
+
if (job.scope !== "document") {
|
|
188
|
+
return {
|
|
189
|
+
job,
|
|
190
|
+
success: false,
|
|
191
|
+
error: new Error(`CREATE_DOCUMENT must be in "document" scope, got "${job.scope}"`),
|
|
192
|
+
duration: Date.now() - startTime,
|
|
193
|
+
};
|
|
194
|
+
}
|
|
195
|
+
const document = createDocumentFromAction(action);
|
|
196
|
+
// Legacy: Store the document in storage
|
|
197
|
+
try {
|
|
198
|
+
await this.documentStorage.create(document);
|
|
199
|
+
}
|
|
200
|
+
catch (error) {
|
|
201
|
+
return {
|
|
202
|
+
job,
|
|
203
|
+
success: false,
|
|
204
|
+
error: new Error(`Failed to create document in storage: ${error instanceof Error ? error.message : String(error)}`),
|
|
205
|
+
duration: Date.now() - startTime,
|
|
206
|
+
};
|
|
207
|
+
}
|
|
208
|
+
// Create the operation with index 0 (first operation for a new document)
|
|
209
|
+
const operation = {
|
|
210
|
+
index: 0,
|
|
211
|
+
timestampUtcMs: action.timestampUtcMs || new Date().toISOString(),
|
|
212
|
+
hash: "", // Will be computed later
|
|
213
|
+
skip: 0, // Always 0 for new operations; skip > 0 only during reshuffle
|
|
214
|
+
action: action,
|
|
215
|
+
};
|
|
216
|
+
// Legacy: Write the CREATE_DOCUMENT operation to legacy storage
|
|
217
|
+
try {
|
|
218
|
+
await this.operationStorage.addDocumentOperations(document.header.id, [operation], document);
|
|
219
|
+
}
|
|
220
|
+
catch (error) {
|
|
221
|
+
return {
|
|
222
|
+
job,
|
|
223
|
+
success: false,
|
|
224
|
+
error: new Error(`Failed to write CREATE_DOCUMENT operation to legacy storage: ${error instanceof Error ? error.message : String(error)}`),
|
|
225
|
+
duration: Date.now() - startTime,
|
|
226
|
+
};
|
|
227
|
+
}
|
|
228
|
+
// Compute resultingState for passing via context (not persisted)
|
|
229
|
+
// Include header and all scopes present in the document state (auth, document, etc.)
|
|
230
|
+
// but not global/local which aren't initialized by CREATE_DOCUMENT
|
|
231
|
+
const resultingStateObj = {
|
|
232
|
+
header: document.header,
|
|
233
|
+
...document.state,
|
|
234
|
+
};
|
|
235
|
+
const resultingState = JSON.stringify(resultingStateObj);
|
|
236
|
+
// Write the operation to new IOperationStore (dual-writing)
|
|
237
|
+
// Note: resultingState is NOT persisted in IOperationStore
|
|
238
|
+
try {
|
|
239
|
+
await this.operationStore.apply(document.header.id, document.header.documentType, job.scope, job.branch, operation.index, (txn) => {
|
|
240
|
+
txn.addOperations(operation);
|
|
241
|
+
});
|
|
242
|
+
}
|
|
243
|
+
catch (error) {
|
|
244
|
+
return {
|
|
245
|
+
job,
|
|
246
|
+
success: false,
|
|
247
|
+
error: new Error(`Failed to write CREATE_DOCUMENT operation to IOperationStore: ${error instanceof Error ? error.message : String(error)}`),
|
|
248
|
+
duration: Date.now() - startTime,
|
|
249
|
+
};
|
|
250
|
+
}
|
|
251
|
+
document.header.revision = {
|
|
252
|
+
...document.header.revision,
|
|
253
|
+
[job.scope]: operation.index + 1,
|
|
254
|
+
};
|
|
255
|
+
this.writeCache.putState(document.header.id, job.scope, job.branch, operation.index, document);
|
|
256
|
+
return {
|
|
257
|
+
job,
|
|
258
|
+
success: true,
|
|
259
|
+
operations: [operation],
|
|
260
|
+
operationsWithContext: [
|
|
261
|
+
{
|
|
262
|
+
operation,
|
|
263
|
+
context: {
|
|
264
|
+
documentId: document.header.id,
|
|
265
|
+
scope: job.scope,
|
|
266
|
+
branch: job.branch,
|
|
267
|
+
documentType: document.header.documentType,
|
|
268
|
+
resultingState,
|
|
269
|
+
},
|
|
270
|
+
},
|
|
271
|
+
],
|
|
272
|
+
duration: Date.now() - startTime,
|
|
273
|
+
};
|
|
274
|
+
}
|
|
275
|
+
/**
|
|
276
|
+
* Execute a DELETE_DOCUMENT system action.
|
|
277
|
+
* This deletes a document from legacy storage and writes the operation to IOperationStore.
|
|
278
|
+
* The operation index is determined from the document's current operation count.
|
|
279
|
+
*/
|
|
280
|
+
async executeDeleteDocumentAction(job, action, startTime) {
|
|
281
|
+
const input = action.input;
|
|
282
|
+
if (!input.documentId) {
|
|
283
|
+
return {
|
|
284
|
+
job,
|
|
285
|
+
success: false,
|
|
286
|
+
error: new Error("DELETE_DOCUMENT action requires a documentId in input"),
|
|
287
|
+
duration: Date.now() - startTime,
|
|
288
|
+
};
|
|
289
|
+
}
|
|
290
|
+
const documentId = input.documentId;
|
|
291
|
+
let document;
|
|
292
|
+
try {
|
|
293
|
+
document = await this.writeCache.getState(documentId, job.scope, job.branch);
|
|
294
|
+
}
|
|
295
|
+
catch (error) {
|
|
296
|
+
return {
|
|
297
|
+
job,
|
|
298
|
+
success: false,
|
|
299
|
+
error: new Error(`Failed to fetch document before deletion: ${error instanceof Error ? error.message : String(error)}`),
|
|
300
|
+
duration: Date.now() - startTime,
|
|
301
|
+
};
|
|
302
|
+
}
|
|
303
|
+
// Check if document is already deleted
|
|
304
|
+
const documentState = document.state.document;
|
|
305
|
+
if (documentState.isDeleted) {
|
|
306
|
+
return {
|
|
307
|
+
job,
|
|
308
|
+
success: false,
|
|
309
|
+
error: new DocumentDeletedError(documentId, documentState.deletedAtUtcIso),
|
|
310
|
+
duration: Date.now() - startTime,
|
|
311
|
+
};
|
|
312
|
+
}
|
|
313
|
+
// Determine the next operation index for this scope only (per-scope indexing)
|
|
314
|
+
const nextIndex = getNextIndexForScope(document, job.scope);
|
|
315
|
+
// Create the DELETE_DOCUMENT operation
|
|
316
|
+
const operation = {
|
|
317
|
+
index: nextIndex,
|
|
318
|
+
timestampUtcMs: action.timestampUtcMs || new Date().toISOString(),
|
|
319
|
+
hash: "", // Will be computed later
|
|
320
|
+
skip: 0, // Always 0 for new operations; skip > 0 only during reshuffle
|
|
321
|
+
action: action,
|
|
322
|
+
};
|
|
323
|
+
try {
|
|
324
|
+
await this.documentStorage.delete(documentId);
|
|
325
|
+
}
|
|
326
|
+
catch (error) {
|
|
327
|
+
return {
|
|
328
|
+
job,
|
|
329
|
+
success: false,
|
|
330
|
+
error: new Error(`Failed to delete document from legacy storage: ${error instanceof Error ? error.message : String(error)}`),
|
|
331
|
+
duration: Date.now() - startTime,
|
|
332
|
+
};
|
|
333
|
+
}
|
|
334
|
+
// Mark the document as deleted in the state for read model indexing
|
|
335
|
+
applyDeleteDocumentAction(document, action);
|
|
336
|
+
// Compute resultingState for passing via context (not persisted)
|
|
337
|
+
// DELETE_DOCUMENT only affects header and document scopes
|
|
338
|
+
const resultingStateObj = {
|
|
339
|
+
header: document.header,
|
|
340
|
+
document: document.state.document,
|
|
341
|
+
};
|
|
342
|
+
const resultingState = JSON.stringify(resultingStateObj);
|
|
343
|
+
// Write the DELETE_DOCUMENT operation to IOperationStore
|
|
344
|
+
// Note: resultingState is NOT persisted in IOperationStore
|
|
345
|
+
try {
|
|
346
|
+
await this.operationStore.apply(documentId, document.header.documentType, job.scope, job.branch, operation.index, (txn) => {
|
|
347
|
+
txn.addOperations(operation);
|
|
348
|
+
});
|
|
349
|
+
}
|
|
350
|
+
catch (error) {
|
|
351
|
+
return {
|
|
352
|
+
job,
|
|
353
|
+
success: false,
|
|
354
|
+
error: new Error(`Failed to write DELETE_DOCUMENT operation to IOperationStore: ${error instanceof Error ? error.message : String(error)}`),
|
|
355
|
+
duration: Date.now() - startTime,
|
|
356
|
+
};
|
|
357
|
+
}
|
|
358
|
+
return {
|
|
359
|
+
job,
|
|
360
|
+
success: true,
|
|
361
|
+
operations: [operation],
|
|
362
|
+
operationsWithContext: [
|
|
363
|
+
{
|
|
364
|
+
operation,
|
|
365
|
+
context: {
|
|
366
|
+
documentId,
|
|
367
|
+
scope: job.scope,
|
|
368
|
+
branch: job.branch,
|
|
369
|
+
documentType: document.header.documentType,
|
|
370
|
+
resultingState,
|
|
371
|
+
},
|
|
372
|
+
},
|
|
373
|
+
],
|
|
374
|
+
duration: Date.now() - startTime,
|
|
375
|
+
};
|
|
376
|
+
}
|
|
377
|
+
/**
|
|
378
|
+
* Execute an UPGRADE_DOCUMENT system action.
|
|
379
|
+
* This sets the document's initial state from the upgrade action.
|
|
380
|
+
* The operation index is determined from the document's current operation count.
|
|
381
|
+
*/
|
|
382
|
+
async executeUpgradeDocumentAction(job, action, startTime) {
|
|
383
|
+
const input = action.input;
|
|
384
|
+
if (!input.documentId) {
|
|
385
|
+
return {
|
|
386
|
+
job,
|
|
387
|
+
success: false,
|
|
388
|
+
error: new Error("UPGRADE_DOCUMENT action requires a documentId in input"),
|
|
389
|
+
duration: Date.now() - startTime,
|
|
390
|
+
};
|
|
391
|
+
}
|
|
392
|
+
const documentId = input.documentId;
|
|
393
|
+
// Load the document from write cache
|
|
394
|
+
let document;
|
|
395
|
+
try {
|
|
396
|
+
document = await this.writeCache.getState(documentId, job.scope, job.branch);
|
|
397
|
+
}
|
|
398
|
+
catch (error) {
|
|
399
|
+
return {
|
|
400
|
+
job,
|
|
401
|
+
success: false,
|
|
402
|
+
error: new Error(`Failed to fetch document for upgrade: ${error instanceof Error ? error.message : String(error)}`),
|
|
403
|
+
duration: Date.now() - startTime,
|
|
404
|
+
};
|
|
405
|
+
}
|
|
406
|
+
// Check if document is deleted
|
|
407
|
+
const documentState = document.state.document;
|
|
408
|
+
if (documentState.isDeleted) {
|
|
409
|
+
return {
|
|
410
|
+
job,
|
|
411
|
+
success: false,
|
|
412
|
+
error: new DocumentDeletedError(documentId, documentState.deletedAtUtcIso),
|
|
413
|
+
duration: Date.now() - startTime,
|
|
414
|
+
};
|
|
415
|
+
}
|
|
416
|
+
// Determine the next operation index for this scope only (per-scope indexing)
|
|
417
|
+
const nextIndex = getNextIndexForScope(document, job.scope);
|
|
418
|
+
// Apply the initialState from the upgrade action
|
|
419
|
+
// The initialState from UPGRADE_DOCUMENT should be merged with the existing base state
|
|
420
|
+
// to preserve auth and document scopes while adding model-specific scopes (global, local, etc.)
|
|
421
|
+
applyUpgradeDocumentAction(document, action);
|
|
422
|
+
// Create the UPGRADE_DOCUMENT operation with calculated index
|
|
423
|
+
const operation = {
|
|
424
|
+
index: nextIndex,
|
|
425
|
+
timestampUtcMs: action.timestampUtcMs || new Date().toISOString(),
|
|
426
|
+
hash: "", // Will be computed later
|
|
427
|
+
skip: 0, // Always 0 for new operations; skip > 0 only during reshuffle
|
|
428
|
+
action: action,
|
|
429
|
+
};
|
|
430
|
+
// Write the updated document to legacy storage
|
|
431
|
+
try {
|
|
432
|
+
await this.operationStorage.addDocumentOperations(documentId, [operation], document);
|
|
433
|
+
}
|
|
434
|
+
catch (error) {
|
|
435
|
+
return {
|
|
436
|
+
job,
|
|
437
|
+
success: false,
|
|
438
|
+
error: new Error(`Failed to write UPGRADE_DOCUMENT operation to legacy storage: ${error instanceof Error ? error.message : String(error)}`),
|
|
439
|
+
duration: Date.now() - startTime,
|
|
440
|
+
};
|
|
441
|
+
}
|
|
442
|
+
// Compute resultingState for passing via context (not persisted)
|
|
443
|
+
const resultingStateObj = {
|
|
444
|
+
header: document.header,
|
|
445
|
+
...document.state,
|
|
446
|
+
};
|
|
447
|
+
const resultingState = JSON.stringify(resultingStateObj);
|
|
448
|
+
// Write the operation to new IOperationStore (dual-writing)
|
|
449
|
+
// Note: resultingState is NOT persisted in IOperationStore
|
|
450
|
+
try {
|
|
451
|
+
await this.operationStore.apply(documentId, document.header.documentType, job.scope, job.branch, operation.index, (txn) => {
|
|
452
|
+
txn.addOperations(operation);
|
|
453
|
+
});
|
|
454
|
+
}
|
|
455
|
+
catch (error) {
|
|
456
|
+
return {
|
|
457
|
+
job,
|
|
458
|
+
success: false,
|
|
459
|
+
error: new Error(`Failed to write UPGRADE_DOCUMENT operation to IOperationStore: ${error instanceof Error ? error.message : String(error)}`),
|
|
460
|
+
duration: Date.now() - startTime,
|
|
461
|
+
};
|
|
462
|
+
}
|
|
463
|
+
document.header.revision = {
|
|
464
|
+
...document.header.revision,
|
|
465
|
+
[job.scope]: operation.index + 1,
|
|
466
|
+
};
|
|
467
|
+
this.writeCache.putState(documentId, job.scope, job.branch, operation.index, document);
|
|
468
|
+
return {
|
|
469
|
+
job,
|
|
470
|
+
success: true,
|
|
471
|
+
operations: [operation],
|
|
472
|
+
operationsWithContext: [
|
|
473
|
+
{
|
|
474
|
+
operation,
|
|
475
|
+
context: {
|
|
476
|
+
documentId,
|
|
477
|
+
scope: job.scope,
|
|
478
|
+
branch: job.branch,
|
|
479
|
+
documentType: document.header.documentType,
|
|
480
|
+
resultingState,
|
|
481
|
+
},
|
|
482
|
+
},
|
|
483
|
+
],
|
|
484
|
+
duration: Date.now() - startTime,
|
|
485
|
+
};
|
|
486
|
+
}
|
|
487
|
+
}
|
|
488
|
+
//# sourceMappingURL=simple-job-executor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"simple-job-executor.js","sourceRoot":"","sources":["../../../src/executor/simple-job-executor.ts"],"names":[],"mappings":"AAeA,OAAO,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAGzD,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAO3D,OAAO,EACL,yBAAyB,EACzB,0BAA0B,EAC1B,wBAAwB,EACxB,oBAAoB,GACrB,MAAM,WAAW,CAAC;AAEnB;;;;;;GAMG;AACH,MAAM,OAAO,iBAAiB;IAElB;IACA;IACA;IACA;IACA;IACA;IANV,YACU,QAAgC,EAChC,eAAiC,EACjC,gBAA2C,EAC3C,cAA+B,EAC/B,QAAmB,EACnB,UAAuB;QALvB,aAAQ,GAAR,QAAQ,CAAwB;QAChC,oBAAe,GAAf,eAAe,CAAkB;QACjC,qBAAgB,GAAhB,gBAAgB,CAA2B;QAC3C,mBAAc,GAAd,cAAc,CAAiB;QAC/B,aAAQ,GAAR,QAAQ,CAAW;QACnB,eAAU,GAAV,UAAU,CAAa;IAC9B,CAAC;IAEJ;;;OAGG;IACH,KAAK,CAAC,UAAU,CAAC,GAAQ;QACvB,MAAM,SAAS,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;QAC7B,MAAM,mBAAmB,GAAgB,EAAE,CAAC;QAC5C,MAAM,qBAAqB,GAA2B,EAAE,CAAC;QAEzD,8CAA8C;QAC9C,KAAK,MAAM,MAAM,IAAI,GAAG,CAAC,OAAO,EAAE,CAAC;YACjC,2EAA2E;YAC3E,IAAI,MAAM,CAAC,IAAI,KAAK,iBAAiB,EAAE,CAAC;gBACtC,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,2BAA2B,CACnD,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AK,CAAC,EAAE,CAC3H;gBACD,QAAQ,EAAE,IAAI,CAAC,GAAG,EAAE,GAAG,SAAS;aACjC,CAAC;QACJ,CAAC;QAED,QAAQ,CAAC,MAAM,CAAC,QAAQ,GAAG;YACzB,GAAG,QAAQ,CAAC,MAAM,CAAC,QAAQ;YAC3B,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,SAAS,CAAC,KAAK,GAAG,CAAC;SACjC,CAAC;QAEF,IAAI,CAAC,UAAU,CAAC,QAAQ,CACtB,UAAU,EACV,GAAG,CAAC,KAAK,EACT,GAAG,CAAC,MAAM,EACV,SAAS,CAAC,KAAK,EACf,QAAQ,CACT,CAAC;QAEF,OAAO;YACL,GAAG;YACH,OAAO,EAAE,IAAI;YACb,UAAU,EAAE,CAAC,SAAS,CAAC;YACvB,qBAAqB,EAAE;gBACrB;oBACE,SAAS;oBACT,OAAO,EAAE;wBACP,UAAU;wBACV,KAAK,EAAE,GAAG,CAAC,KAAK;wBAChB,MAAM,EAAE,GAAG,CAAC,MAAM;wBAClB,YAAY,EAAE,QAAQ,CAAC,MAAM,CAAC,YAAY;wBAC1C,cAAc;qBACf;iBACF;aACF;YACD,QAAQ,EAAE,IAAI,CAAC,GAAG,EAAE,GAAG,SAAS;SACjC,CAAC;IACJ,CAAC;CACF"}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { Operation } from "document-model";
|
|
2
|
+
import type { Job } from "../queue/types.js";
|
|
3
|
+
import type { OperationWithContext } from "../storage/interfaces.js";
|
|
2
4
|
/**
|
|
3
5
|
* Represents the result of a job execution
|
|
4
6
|
*/
|
|
@@ -7,12 +9,19 @@ export type JobResult = {
|
|
|
7
9
|
job: Job;
|
|
8
10
|
/** Whether the job executed successfully */
|
|
9
11
|
success: boolean;
|
|
10
|
-
/** Error
|
|
11
|
-
error?:
|
|
12
|
+
/** Error if the job failed */
|
|
13
|
+
error?: Error;
|
|
14
|
+
/** The operations generated from the actions (if successful) */
|
|
15
|
+
operations?: Operation[];
|
|
16
|
+
/**
|
|
17
|
+
* Operations with context (includes ephemeral resultingState).
|
|
18
|
+
* Used for emitting to IDocumentView via event bus.
|
|
19
|
+
*/
|
|
20
|
+
operationsWithContext?: OperationWithContext[];
|
|
12
21
|
/** Timestamp when the job execution completed */
|
|
13
|
-
completedAt
|
|
22
|
+
completedAt?: string;
|
|
14
23
|
/** Duration of job execution in milliseconds */
|
|
15
|
-
duration
|
|
24
|
+
duration?: number;
|
|
16
25
|
/** Any additional metadata from the execution */
|
|
17
26
|
metadata?: Record<string, any>;
|
|
18
27
|
};
|
|
@@ -23,11 +32,11 @@ export type JobExecutorConfig = {
|
|
|
23
32
|
/** Maximum number of concurrent jobs to execute */
|
|
24
33
|
maxConcurrency?: number;
|
|
25
34
|
/** Maximum time in milliseconds a job can run before being considered timed out */
|
|
26
|
-
|
|
35
|
+
jobTimeoutMs?: number;
|
|
27
36
|
/** Base delay in milliseconds for exponential backoff retries */
|
|
28
|
-
|
|
37
|
+
retryBaseDelayMs?: number;
|
|
29
38
|
/** Maximum delay in milliseconds for exponential backoff retries */
|
|
30
|
-
|
|
39
|
+
retryMaxDelayMs?: number;
|
|
31
40
|
};
|
|
32
41
|
/**
|
|
33
42
|
* Event types for the job executor
|
|
@@ -64,4 +73,17 @@ export type ExecutorStoppedEvent = {
|
|
|
64
73
|
stoppedAt: string;
|
|
65
74
|
graceful: boolean;
|
|
66
75
|
};
|
|
76
|
+
/**
|
|
77
|
+
* Status information for the job executor manager
|
|
78
|
+
*/
|
|
79
|
+
export type ExecutorManagerStatus = {
|
|
80
|
+
/** Whether the manager is currently running */
|
|
81
|
+
isRunning: boolean;
|
|
82
|
+
/** Number of executor instances managed */
|
|
83
|
+
numExecutors: number;
|
|
84
|
+
/** Number of jobs currently being processed */
|
|
85
|
+
activeJobs: number;
|
|
86
|
+
/** Total number of jobs processed since start */
|
|
87
|
+
totalJobsProcessed: number;
|
|
88
|
+
};
|
|
67
89
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/executor/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/executor/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAErE;;GAEG;AACH,MAAM,MAAM,SAAS,GAAG;IACtB,gCAAgC;IAChC,GAAG,EAAE,GAAG,CAAC;IAET,4CAA4C;IAC5C,OAAO,EAAE,OAAO,CAAC;IAEjB,8BAA8B;IAC9B,KAAK,CAAC,EAAE,KAAK,CAAC;IAEd,gEAAgE;IAChE,UAAU,CAAC,EAAE,SAAS,EAAE,CAAC;IAEzB;;;OAGG;IACH,qBAAqB,CAAC,EAAE,oBAAoB,EAAE,CAAC;IAE/C,iDAAiD;IACjD,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB,gDAAgD;IAChD,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB,iDAAiD;IACjD,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CAChC,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,iBAAiB,GAAG;IAC9B,mDAAmD;IACnD,cAAc,CAAC,EAAE,MAAM,CAAC;IAExB,mFAAmF;IACnF,YAAY,CAAC,EAAE,MAAM,CAAC;IAEtB,iEAAiE;IACjE,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAE1B,oEAAoE;IACpE,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,qBAAqB;;;;;;CAMxB,CAAC;AAEX;;GAEG;AACH,MAAM,MAAM,eAAe,GAAG;IAC5B,GAAG,EAAE,GAAG,CAAC;IACT,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG;IAC9B,GAAG,EAAE,GAAG,CAAC;IACT,MAAM,EAAE,SAAS,CAAC;CACnB,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG;IAC3B,GAAG,EAAE,GAAG,CAAC;IACT,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,OAAO,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,oBAAoB,GAAG;IACjC,MAAM,EAAE,iBAAiB,CAAC;IAC1B,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,MAAM,MAAM,oBAAoB,GAAG;IACjC,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,OAAO,CAAC;CACnB,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,qBAAqB,GAAG;IAClC,+CAA+C;IAC/C,SAAS,EAAE,OAAO,CAAC;IAEnB,2CAA2C;IAC3C,YAAY,EAAE,MAAM,CAAC;IAErB,+CAA+C;IAC/C,UAAU,EAAE,MAAM,CAAC;IAEnB,iDAAiD;IACjD,kBAAkB,EAAE,MAAM,CAAC;CAC5B,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/executor/types.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/executor/types.ts"],"names":[],"mappings":"AAqDA;;GAEG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG;IACnC,WAAW,EAAE,KAAK;IAClB,aAAa,EAAE,KAAK;IACpB,UAAU,EAAE,KAAK;IACjB,gBAAgB,EAAE,KAAK;IACvB,gBAAgB,EAAE,KAAK;CACf,CAAC"}
|