@auto-engineer/pipeline 0.14.0 → 0.16.0
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/.turbo/turbo-build.log +5 -6
- package/CHANGELOG.md +24 -0
- package/README.md +279 -0
- package/dist/src/builder/define.d.ts +6 -2
- package/dist/src/builder/define.d.ts.map +1 -1
- package/dist/src/builder/define.js +17 -7
- package/dist/src/builder/define.js.map +1 -1
- package/dist/src/core/descriptors.d.ts +6 -2
- package/dist/src/core/descriptors.d.ts.map +1 -1
- package/dist/src/graph/filter-graph.d.ts +3 -0
- package/dist/src/graph/filter-graph.d.ts.map +1 -0
- package/dist/src/graph/filter-graph.js +80 -0
- package/dist/src/graph/filter-graph.js.map +1 -0
- package/dist/src/graph/types.d.ts +8 -0
- package/dist/src/graph/types.d.ts.map +1 -1
- package/dist/src/index.d.ts +1 -0
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js.map +1 -1
- package/dist/src/projections/await-tracker-projection.d.ts +31 -0
- package/dist/src/projections/await-tracker-projection.d.ts.map +1 -0
- package/dist/src/projections/await-tracker-projection.js +35 -0
- package/dist/src/projections/await-tracker-projection.js.map +1 -0
- package/dist/src/projections/index.d.ts +4 -0
- package/dist/src/projections/index.d.ts.map +1 -0
- package/dist/src/projections/index.js +4 -0
- package/dist/src/projections/index.js.map +1 -0
- package/dist/src/projections/item-status-projection.d.ts +22 -0
- package/dist/src/projections/item-status-projection.d.ts.map +1 -0
- package/dist/src/projections/item-status-projection.js +11 -0
- package/dist/src/projections/item-status-projection.js.map +1 -0
- package/dist/src/projections/latest-run-projection.d.ts +15 -0
- package/dist/src/projections/latest-run-projection.d.ts.map +1 -0
- package/dist/src/projections/latest-run-projection.js +7 -0
- package/dist/src/projections/latest-run-projection.js.map +1 -0
- package/dist/src/projections/message-log-projection.d.ts +51 -0
- package/dist/src/projections/message-log-projection.d.ts.map +1 -0
- package/dist/src/projections/message-log-projection.js +51 -0
- package/dist/src/projections/message-log-projection.js.map +1 -0
- package/dist/src/projections/node-status-projection.d.ts +23 -0
- package/dist/src/projections/node-status-projection.d.ts.map +1 -0
- package/dist/src/projections/node-status-projection.js +10 -0
- package/dist/src/projections/node-status-projection.js.map +1 -0
- package/dist/src/projections/phased-execution-projection.d.ts +77 -0
- package/dist/src/projections/phased-execution-projection.d.ts.map +1 -0
- package/dist/src/projections/phased-execution-projection.js +54 -0
- package/dist/src/projections/phased-execution-projection.js.map +1 -0
- package/dist/src/projections/settled-instance-projection.d.ts +67 -0
- package/dist/src/projections/settled-instance-projection.d.ts.map +1 -0
- package/dist/src/projections/settled-instance-projection.js +66 -0
- package/dist/src/projections/settled-instance-projection.js.map +1 -0
- package/dist/src/projections/stats-projection.d.ts +9 -0
- package/dist/src/projections/stats-projection.d.ts.map +1 -0
- package/dist/src/projections/stats-projection.js +16 -0
- package/dist/src/projections/stats-projection.js.map +1 -0
- package/dist/src/runtime/await-tracker.d.ts +17 -7
- package/dist/src/runtime/await-tracker.d.ts.map +1 -1
- package/dist/src/runtime/await-tracker.js +32 -29
- package/dist/src/runtime/await-tracker.js.map +1 -1
- package/dist/src/runtime/context.d.ts +1 -1
- package/dist/src/runtime/context.d.ts.map +1 -1
- package/dist/src/runtime/event-command-map.d.ts +3 -3
- package/dist/src/runtime/event-command-map.d.ts.map +1 -1
- package/dist/src/runtime/event-command-map.js +6 -2
- package/dist/src/runtime/event-command-map.js.map +1 -1
- package/dist/src/runtime/phased-executor.d.ts +14 -9
- package/dist/src/runtime/phased-executor.d.ts.map +1 -1
- package/dist/src/runtime/phased-executor.js +113 -105
- package/dist/src/runtime/phased-executor.js.map +1 -1
- package/dist/src/runtime/pipeline-runtime.d.ts.map +1 -1
- package/dist/src/runtime/pipeline-runtime.js +2 -2
- package/dist/src/runtime/pipeline-runtime.js.map +1 -1
- package/dist/src/runtime/settled-tracker.d.ts +12 -10
- package/dist/src/runtime/settled-tracker.d.ts.map +1 -1
- package/dist/src/runtime/settled-tracker.js +89 -80
- package/dist/src/runtime/settled-tracker.js.map +1 -1
- package/dist/src/server/pipeline-server.d.ts +31 -9
- package/dist/src/server/pipeline-server.d.ts.map +1 -1
- package/dist/src/server/pipeline-server.js +424 -123
- package/dist/src/server/pipeline-server.js.map +1 -1
- package/dist/src/server/sse-manager.d.ts +0 -1
- package/dist/src/server/sse-manager.d.ts.map +1 -1
- package/dist/src/server/sse-manager.js +0 -3
- package/dist/src/server/sse-manager.js.map +1 -1
- package/dist/src/store/index.d.ts +3 -0
- package/dist/src/store/index.d.ts.map +1 -0
- package/dist/src/store/index.js +3 -0
- package/dist/src/store/index.js.map +1 -0
- package/dist/src/store/pipeline-event-store.d.ts +10 -0
- package/dist/src/store/pipeline-event-store.d.ts.map +1 -0
- package/dist/src/store/pipeline-event-store.js +112 -0
- package/dist/src/store/pipeline-event-store.js.map +1 -0
- package/dist/src/store/pipeline-read-model.d.ts +49 -0
- package/dist/src/store/pipeline-read-model.d.ts.map +1 -0
- package/dist/src/store/pipeline-read-model.js +156 -0
- package/dist/src/store/pipeline-read-model.js.map +1 -0
- package/dist/src/store/sqlite-pipeline-event-store.d.ts +14 -0
- package/dist/src/store/sqlite-pipeline-event-store.d.ts.map +1 -0
- package/dist/src/store/sqlite-pipeline-event-store.js +20 -0
- package/dist/src/store/sqlite-pipeline-event-store.js.map +1 -0
- package/dist/src/testing/fixtures/kanban-full.pipeline.js +2 -2
- package/dist/src/testing/fixtures/kanban-full.pipeline.js.map +1 -1
- package/dist/src/testing/fixtures/kanban.pipeline.js +2 -2
- package/dist/src/testing/fixtures/kanban.pipeline.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/ketchup-plan.md +1216 -0
- package/package.json +6 -4
- package/src/builder/define.specs.ts +5 -4
- package/src/builder/define.ts +24 -11
- package/src/config/pipeline-config.specs.ts +32 -0
- package/src/core/descriptors.ts +7 -2
- package/src/graph/filter-graph.specs.ts +267 -0
- package/src/graph/filter-graph.ts +111 -0
- package/src/graph/types.specs.ts +0 -14
- package/src/graph/types.ts +10 -0
- package/src/index.ts +1 -0
- package/src/projections/await-tracker-projection.specs.ts +24 -0
- package/src/projections/await-tracker-projection.ts +68 -0
- package/src/projections/index.ts +11 -0
- package/src/projections/item-status-projection.specs.ts +130 -0
- package/src/projections/item-status-projection.ts +32 -0
- package/src/projections/latest-run-projection.ts +20 -0
- package/src/projections/message-log-projection.ts +113 -0
- package/src/projections/node-status-projection.ts +33 -0
- package/src/projections/phased-execution-projection.specs.ts +202 -0
- package/src/projections/phased-execution-projection.ts +146 -0
- package/src/projections/settled-instance-projection.specs.ts +296 -0
- package/src/projections/settled-instance-projection.ts +160 -0
- package/src/projections/stats-projection.ts +26 -0
- package/src/runtime/await-tracker.specs.ts +57 -34
- package/src/runtime/await-tracker.ts +43 -31
- package/src/runtime/context.ts +1 -1
- package/src/runtime/event-command-map.ts +11 -4
- package/src/runtime/phased-executor.specs.ts +357 -81
- package/src/runtime/phased-executor.ts +134 -128
- package/src/runtime/pipeline-runtime.specs.ts +65 -0
- package/src/runtime/pipeline-runtime.ts +6 -4
- package/src/runtime/settled-tracker.specs.ts +716 -120
- package/src/runtime/settled-tracker.ts +100 -102
- package/src/server/pipeline-server.e2e.specs.ts +10 -16
- package/src/server/pipeline-server.specs.ts +1441 -211
- package/src/server/pipeline-server.ts +535 -144
- package/src/server/sse-manager.specs.ts +67 -36
- package/src/server/sse-manager.ts +0 -4
- package/src/store/index.ts +2 -0
- package/src/store/pipeline-event-store.specs.ts +357 -0
- package/src/store/pipeline-event-store.ts +156 -0
- package/src/store/pipeline-read-model.specs.ts +1170 -0
- package/src/store/pipeline-read-model.ts +223 -0
- package/src/store/sqlite-pipeline-event-store.specs.ts +13 -0
- package/src/store/sqlite-pipeline-event-store.ts +36 -0
- package/src/testing/fixtures/kanban-full.pipeline.ts +2 -2
- package/src/testing/fixtures/kanban.pipeline.ts +2 -2
- package/tsconfig.json +1 -1
- package/vitest.config.ts +1 -8
- package/claude.md +0 -160
- package/dist/src/__tests__/e2e/helpers.d.ts +0 -48
- package/dist/src/__tests__/e2e/helpers.d.ts.map +0 -1
- package/dist/src/__tests__/e2e/helpers.js +0 -253
- package/dist/src/__tests__/e2e/helpers.js.map +0 -1
- package/dist/src/__tests__/e2e/kanban-migration.e2e.specs.d.ts +0 -2
- package/dist/src/__tests__/e2e/kanban-migration.e2e.specs.d.ts.map +0 -1
- package/dist/src/__tests__/e2e/kanban-migration.e2e.specs.js +0 -195
- package/dist/src/__tests__/e2e/kanban-migration.e2e.specs.js.map +0 -1
- package/dist/src/__tests__/e2e/types.d.ts +0 -107
- package/dist/src/__tests__/e2e/types.d.ts.map +0 -1
- package/dist/src/__tests__/e2e/types.js +0 -2
- package/dist/src/__tests__/e2e/types.js.map +0 -1
- package/dist/src/builder/define.specs.d.ts +0 -2
- package/dist/src/builder/define.specs.d.ts.map +0 -1
- package/dist/src/builder/define.specs.js +0 -435
- package/dist/src/builder/define.specs.js.map +0 -1
- package/dist/src/core/descriptors.specs.d.ts +0 -2
- package/dist/src/core/descriptors.specs.d.ts.map +0 -1
- package/dist/src/core/descriptors.specs.js +0 -24
- package/dist/src/core/descriptors.specs.js.map +0 -1
- package/dist/src/core/types.specs.d.ts +0 -2
- package/dist/src/core/types.specs.d.ts.map +0 -1
- package/dist/src/core/types.specs.js +0 -40
- package/dist/src/core/types.specs.js.map +0 -1
- package/dist/src/file-syncer/crypto/jwe-encryptor.d.ts +0 -15
- package/dist/src/file-syncer/crypto/jwe-encryptor.d.ts.map +0 -1
- package/dist/src/file-syncer/crypto/jwe-encryptor.js +0 -64
- package/dist/src/file-syncer/crypto/jwe-encryptor.js.map +0 -1
- package/dist/src/file-syncer/crypto/provider-resolver.d.ts +0 -24
- package/dist/src/file-syncer/crypto/provider-resolver.d.ts.map +0 -1
- package/dist/src/file-syncer/crypto/provider-resolver.js +0 -71
- package/dist/src/file-syncer/crypto/provider-resolver.js.map +0 -1
- package/dist/src/file-syncer/discovery/bareImports.d.ts +0 -3
- package/dist/src/file-syncer/discovery/bareImports.d.ts.map +0 -1
- package/dist/src/file-syncer/discovery/bareImports.js +0 -36
- package/dist/src/file-syncer/discovery/bareImports.js.map +0 -1
- package/dist/src/file-syncer/discovery/dts.d.ts +0 -8
- package/dist/src/file-syncer/discovery/dts.d.ts.map +0 -1
- package/dist/src/file-syncer/discovery/dts.js +0 -99
- package/dist/src/file-syncer/discovery/dts.js.map +0 -1
- package/dist/src/file-syncer/index.d.ts +0 -46
- package/dist/src/file-syncer/index.d.ts.map +0 -1
- package/dist/src/file-syncer/index.js +0 -392
- package/dist/src/file-syncer/index.js.map +0 -1
- package/dist/src/file-syncer/sync/resolveSyncFileSet.d.ts +0 -7
- package/dist/src/file-syncer/sync/resolveSyncFileSet.d.ts.map +0 -1
- package/dist/src/file-syncer/sync/resolveSyncFileSet.js +0 -86
- package/dist/src/file-syncer/sync/resolveSyncFileSet.js.map +0 -1
- package/dist/src/file-syncer/types/wire.d.ts +0 -14
- package/dist/src/file-syncer/types/wire.d.ts.map +0 -1
- package/dist/src/file-syncer/types/wire.js +0 -2
- package/dist/src/file-syncer/types/wire.js.map +0 -1
- package/dist/src/file-syncer/utils/hash.d.ts +0 -5
- package/dist/src/file-syncer/utils/hash.d.ts.map +0 -1
- package/dist/src/file-syncer/utils/hash.js +0 -19
- package/dist/src/file-syncer/utils/hash.js.map +0 -1
- package/dist/src/file-syncer/utils/path.d.ts +0 -13
- package/dist/src/file-syncer/utils/path.d.ts.map +0 -1
- package/dist/src/file-syncer/utils/path.js +0 -74
- package/dist/src/file-syncer/utils/path.js.map +0 -1
- package/dist/src/graph/types.specs.d.ts +0 -2
- package/dist/src/graph/types.specs.d.ts.map +0 -1
- package/dist/src/graph/types.specs.js +0 -148
- package/dist/src/graph/types.specs.js.map +0 -1
- package/dist/src/logging/event-logger.specs.d.ts +0 -2
- package/dist/src/logging/event-logger.specs.d.ts.map +0 -1
- package/dist/src/logging/event-logger.specs.js +0 -81
- package/dist/src/logging/event-logger.specs.js.map +0 -1
- package/dist/src/plugins/handler-adapter.specs.d.ts +0 -2
- package/dist/src/plugins/handler-adapter.specs.d.ts.map +0 -1
- package/dist/src/plugins/handler-adapter.specs.js +0 -129
- package/dist/src/plugins/handler-adapter.specs.js.map +0 -1
- package/dist/src/plugins/plugin-loader.specs.d.ts +0 -2
- package/dist/src/plugins/plugin-loader.specs.d.ts.map +0 -1
- package/dist/src/plugins/plugin-loader.specs.js +0 -246
- package/dist/src/plugins/plugin-loader.specs.js.map +0 -1
- package/dist/src/runtime/await-tracker.specs.d.ts +0 -2
- package/dist/src/runtime/await-tracker.specs.d.ts.map +0 -1
- package/dist/src/runtime/await-tracker.specs.js +0 -46
- package/dist/src/runtime/await-tracker.specs.js.map +0 -1
- package/dist/src/runtime/context.specs.d.ts +0 -2
- package/dist/src/runtime/context.specs.d.ts.map +0 -1
- package/dist/src/runtime/context.specs.js +0 -26
- package/dist/src/runtime/context.specs.js.map +0 -1
- package/dist/src/runtime/event-command-map.specs.d.ts +0 -2
- package/dist/src/runtime/event-command-map.specs.d.ts.map +0 -1
- package/dist/src/runtime/event-command-map.specs.js +0 -108
- package/dist/src/runtime/event-command-map.specs.js.map +0 -1
- package/dist/src/runtime/phased-executor.specs.d.ts +0 -2
- package/dist/src/runtime/phased-executor.specs.d.ts.map +0 -1
- package/dist/src/runtime/phased-executor.specs.js +0 -256
- package/dist/src/runtime/phased-executor.specs.js.map +0 -1
- package/dist/src/runtime/pipeline-runtime.specs.d.ts +0 -2
- package/dist/src/runtime/pipeline-runtime.specs.d.ts.map +0 -1
- package/dist/src/runtime/pipeline-runtime.specs.js +0 -192
- package/dist/src/runtime/pipeline-runtime.specs.js.map +0 -1
- package/dist/src/runtime/settled-tracker.specs.d.ts +0 -2
- package/dist/src/runtime/settled-tracker.specs.d.ts.map +0 -1
- package/dist/src/runtime/settled-tracker.specs.js +0 -361
- package/dist/src/runtime/settled-tracker.specs.js.map +0 -1
- package/dist/src/server/full-orchestration.e2e.specs.d.ts +0 -2
- package/dist/src/server/full-orchestration.e2e.specs.d.ts.map +0 -1
- package/dist/src/server/full-orchestration.e2e.specs.js +0 -561
- package/dist/src/server/full-orchestration.e2e.specs.js.map +0 -1
- package/dist/src/server/pipeline-server.e2e.specs.d.ts +0 -2
- package/dist/src/server/pipeline-server.e2e.specs.d.ts.map +0 -1
- package/dist/src/server/pipeline-server.e2e.specs.js +0 -381
- package/dist/src/server/pipeline-server.e2e.specs.js.map +0 -1
- package/dist/src/server/pipeline-server.specs.d.ts +0 -2
- package/dist/src/server/pipeline-server.specs.d.ts.map +0 -1
- package/dist/src/server/pipeline-server.specs.js +0 -662
- package/dist/src/server/pipeline-server.specs.js.map +0 -1
- package/dist/src/server/sse-manager.specs.d.ts +0 -2
- package/dist/src/server/sse-manager.specs.d.ts.map +0 -1
- package/dist/src/server/sse-manager.specs.js +0 -158
- package/dist/src/server/sse-manager.specs.js.map +0 -1
- package/dist/src/testing/event-capture.specs.d.ts +0 -2
- package/dist/src/testing/event-capture.specs.d.ts.map +0 -1
- package/dist/src/testing/event-capture.specs.js +0 -114
- package/dist/src/testing/event-capture.specs.js.map +0 -1
- package/dist/src/testing/fixtures/kanban-full.pipeline.specs.d.ts +0 -2
- package/dist/src/testing/fixtures/kanban-full.pipeline.specs.d.ts.map +0 -1
- package/dist/src/testing/fixtures/kanban-full.pipeline.specs.js +0 -263
- package/dist/src/testing/fixtures/kanban-full.pipeline.specs.js.map +0 -1
- package/dist/src/testing/fixtures/kanban.pipeline.specs.d.ts +0 -2
- package/dist/src/testing/fixtures/kanban.pipeline.specs.d.ts.map +0 -1
- package/dist/src/testing/fixtures/kanban.pipeline.specs.js +0 -29
- package/dist/src/testing/fixtures/kanban.pipeline.specs.js.map +0 -1
- package/dist/src/testing/kanban-todo.e2e.specs.d.ts +0 -2
- package/dist/src/testing/kanban-todo.e2e.specs.d.ts.map +0 -1
- package/dist/src/testing/kanban-todo.e2e.specs.js +0 -160
- package/dist/src/testing/kanban-todo.e2e.specs.js.map +0 -1
- package/dist/src/testing/mock-handlers.specs.d.ts +0 -2
- package/dist/src/testing/mock-handlers.specs.d.ts.map +0 -1
- package/dist/src/testing/mock-handlers.specs.js +0 -193
- package/dist/src/testing/mock-handlers.specs.js.map +0 -1
- package/dist/src/testing/real-execution.e2e.specs.d.ts +0 -2
- package/dist/src/testing/real-execution.e2e.specs.d.ts.map +0 -1
- package/dist/src/testing/real-execution.e2e.specs.js +0 -140
- package/dist/src/testing/real-execution.e2e.specs.js.map +0 -1
- package/dist/src/testing/real-plugin.e2e.specs.d.ts +0 -2
- package/dist/src/testing/real-plugin.e2e.specs.d.ts.map +0 -1
- package/dist/src/testing/real-plugin.e2e.specs.js +0 -65
- package/dist/src/testing/real-plugin.e2e.specs.js.map +0 -1
- package/dist/src/testing/server-startup.e2e.specs.d.ts +0 -2
- package/dist/src/testing/server-startup.e2e.specs.d.ts.map +0 -1
- package/dist/src/testing/server-startup.e2e.specs.js +0 -104
- package/dist/src/testing/server-startup.e2e.specs.js.map +0 -1
- package/dist/src/testing/snapshot-compare.specs.d.ts +0 -2
- package/dist/src/testing/snapshot-compare.specs.d.ts.map +0 -1
- package/dist/src/testing/snapshot-compare.specs.js +0 -112
- package/dist/src/testing/snapshot-compare.specs.js.map +0 -1
- package/dist/src/testing/snapshot-sanitize.specs.d.ts +0 -2
- package/dist/src/testing/snapshot-sanitize.specs.d.ts.map +0 -1
- package/dist/src/testing/snapshot-sanitize.specs.js +0 -104
- package/dist/src/testing/snapshot-sanitize.specs.js.map +0 -1
- package/docs/testing-analysis.md +0 -395
- package/pomodoro-plan.md +0 -651
- package/src/core/descriptors.specs.ts +0 -28
- package/src/core/types.specs.ts +0 -44
- package/src/runtime/context.specs.ts +0 -28
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
export interface AwaitTrackerDocument {
|
|
2
|
+
[key: string]: unknown;
|
|
3
|
+
correlationId: string;
|
|
4
|
+
pendingKeys: string[];
|
|
5
|
+
results: Record<string, unknown>;
|
|
6
|
+
status: 'pending' | 'completed';
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export interface AwaitStartedEvent {
|
|
10
|
+
type: 'AwaitStarted';
|
|
11
|
+
data: {
|
|
12
|
+
correlationId: string;
|
|
13
|
+
keys: string[];
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export interface AwaitItemCompletedEvent {
|
|
18
|
+
type: 'AwaitItemCompleted';
|
|
19
|
+
data: {
|
|
20
|
+
correlationId: string;
|
|
21
|
+
key: string;
|
|
22
|
+
result: unknown;
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export interface AwaitCompletedEvent {
|
|
27
|
+
type: 'AwaitCompleted';
|
|
28
|
+
data: {
|
|
29
|
+
correlationId: string;
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export type AwaitEvent = AwaitStartedEvent | AwaitItemCompletedEvent | AwaitCompletedEvent;
|
|
34
|
+
|
|
35
|
+
export function evolve(document: AwaitTrackerDocument | null, event: AwaitEvent): AwaitTrackerDocument {
|
|
36
|
+
switch (event.type) {
|
|
37
|
+
case 'AwaitStarted': {
|
|
38
|
+
const { correlationId, keys } = event.data;
|
|
39
|
+
return {
|
|
40
|
+
correlationId,
|
|
41
|
+
pendingKeys: [...keys],
|
|
42
|
+
results: {},
|
|
43
|
+
status: 'pending',
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
case 'AwaitItemCompleted': {
|
|
47
|
+
if (document === null) {
|
|
48
|
+
throw new Error('Cannot apply AwaitItemCompleted to null document');
|
|
49
|
+
}
|
|
50
|
+
const { key, result } = event.data;
|
|
51
|
+
const newPendingKeys = document.pendingKeys.filter((k) => k !== key);
|
|
52
|
+
return {
|
|
53
|
+
...document,
|
|
54
|
+
pendingKeys: newPendingKeys,
|
|
55
|
+
results: { ...document.results, [key]: result },
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
case 'AwaitCompleted': {
|
|
59
|
+
if (document === null) {
|
|
60
|
+
throw new Error('Cannot apply AwaitCompleted to null document');
|
|
61
|
+
}
|
|
62
|
+
return {
|
|
63
|
+
...document,
|
|
64
|
+
status: 'completed',
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export {
|
|
2
|
+
evolve as evolveItemStatus,
|
|
3
|
+
type ItemStatusChangedEvent,
|
|
4
|
+
type ItemStatusDocument,
|
|
5
|
+
} from './item-status-projection';
|
|
6
|
+
export { evolve as evolveLatestRun, type LatestRunDocument } from './latest-run-projection';
|
|
7
|
+
export {
|
|
8
|
+
evolve as evolveNodeStatus,
|
|
9
|
+
type NodeStatusChangedEvent,
|
|
10
|
+
type NodeStatusDocument,
|
|
11
|
+
} from './node-status-projection';
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import { describe, expect, it } from 'vitest';
|
|
2
|
+
import { evolve, type ItemStatusChangedEvent, type ItemStatusDocument } from './item-status-projection';
|
|
3
|
+
|
|
4
|
+
describe('ItemStatusProjection', () => {
|
|
5
|
+
describe('evolve', () => {
|
|
6
|
+
it('creates item document with running status when item starts', () => {
|
|
7
|
+
const event: ItemStatusChangedEvent = {
|
|
8
|
+
type: 'ItemStatusChanged',
|
|
9
|
+
data: {
|
|
10
|
+
correlationId: 'c1',
|
|
11
|
+
commandType: 'ProcessItem',
|
|
12
|
+
itemKey: 'item-1',
|
|
13
|
+
requestId: 'req-1',
|
|
14
|
+
status: 'running',
|
|
15
|
+
attemptCount: 1,
|
|
16
|
+
},
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
const result = evolve(null, event);
|
|
20
|
+
|
|
21
|
+
expect(result).toEqual({
|
|
22
|
+
correlationId: 'c1',
|
|
23
|
+
commandType: 'ProcessItem',
|
|
24
|
+
itemKey: 'item-1',
|
|
25
|
+
currentRequestId: 'req-1',
|
|
26
|
+
status: 'running',
|
|
27
|
+
attemptCount: 1,
|
|
28
|
+
});
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
it('updates item document to success status when item completes', () => {
|
|
32
|
+
const existing: ItemStatusDocument = {
|
|
33
|
+
correlationId: 'c1',
|
|
34
|
+
commandType: 'ProcessItem',
|
|
35
|
+
itemKey: 'item-1',
|
|
36
|
+
currentRequestId: 'req-1',
|
|
37
|
+
status: 'running',
|
|
38
|
+
attemptCount: 1,
|
|
39
|
+
};
|
|
40
|
+
const event: ItemStatusChangedEvent = {
|
|
41
|
+
type: 'ItemStatusChanged',
|
|
42
|
+
data: {
|
|
43
|
+
correlationId: 'c1',
|
|
44
|
+
commandType: 'ProcessItem',
|
|
45
|
+
itemKey: 'item-1',
|
|
46
|
+
requestId: 'req-1',
|
|
47
|
+
status: 'success',
|
|
48
|
+
attemptCount: 1,
|
|
49
|
+
},
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
const result = evolve(existing, event);
|
|
53
|
+
|
|
54
|
+
expect(result).toEqual({
|
|
55
|
+
correlationId: 'c1',
|
|
56
|
+
commandType: 'ProcessItem',
|
|
57
|
+
itemKey: 'item-1',
|
|
58
|
+
currentRequestId: 'req-1',
|
|
59
|
+
status: 'success',
|
|
60
|
+
attemptCount: 1,
|
|
61
|
+
});
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
it('updates item document to error status when item fails', () => {
|
|
65
|
+
const existing: ItemStatusDocument = {
|
|
66
|
+
correlationId: 'c1',
|
|
67
|
+
commandType: 'ProcessItem',
|
|
68
|
+
itemKey: 'item-1',
|
|
69
|
+
currentRequestId: 'req-1',
|
|
70
|
+
status: 'running',
|
|
71
|
+
attemptCount: 1,
|
|
72
|
+
};
|
|
73
|
+
const event: ItemStatusChangedEvent = {
|
|
74
|
+
type: 'ItemStatusChanged',
|
|
75
|
+
data: {
|
|
76
|
+
correlationId: 'c1',
|
|
77
|
+
commandType: 'ProcessItem',
|
|
78
|
+
itemKey: 'item-1',
|
|
79
|
+
requestId: 'req-1',
|
|
80
|
+
status: 'error',
|
|
81
|
+
attemptCount: 1,
|
|
82
|
+
},
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
const result = evolve(existing, event);
|
|
86
|
+
|
|
87
|
+
expect(result).toEqual({
|
|
88
|
+
correlationId: 'c1',
|
|
89
|
+
commandType: 'ProcessItem',
|
|
90
|
+
itemKey: 'item-1',
|
|
91
|
+
currentRequestId: 'req-1',
|
|
92
|
+
status: 'error',
|
|
93
|
+
attemptCount: 1,
|
|
94
|
+
});
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
it('increments attempt count on retry', () => {
|
|
98
|
+
const existing: ItemStatusDocument = {
|
|
99
|
+
correlationId: 'c1',
|
|
100
|
+
commandType: 'ProcessItem',
|
|
101
|
+
itemKey: 'item-1',
|
|
102
|
+
currentRequestId: 'req-1',
|
|
103
|
+
status: 'error',
|
|
104
|
+
attemptCount: 1,
|
|
105
|
+
};
|
|
106
|
+
const event: ItemStatusChangedEvent = {
|
|
107
|
+
type: 'ItemStatusChanged',
|
|
108
|
+
data: {
|
|
109
|
+
correlationId: 'c1',
|
|
110
|
+
commandType: 'ProcessItem',
|
|
111
|
+
itemKey: 'item-1',
|
|
112
|
+
requestId: 'req-2',
|
|
113
|
+
status: 'running',
|
|
114
|
+
attemptCount: 2,
|
|
115
|
+
},
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
const result = evolve(existing, event);
|
|
119
|
+
|
|
120
|
+
expect(result).toEqual({
|
|
121
|
+
correlationId: 'c1',
|
|
122
|
+
commandType: 'ProcessItem',
|
|
123
|
+
itemKey: 'item-1',
|
|
124
|
+
currentRequestId: 'req-2',
|
|
125
|
+
status: 'running',
|
|
126
|
+
attemptCount: 2,
|
|
127
|
+
});
|
|
128
|
+
});
|
|
129
|
+
});
|
|
130
|
+
});
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
export interface ItemStatusDocument {
|
|
2
|
+
[key: string]: unknown;
|
|
3
|
+
correlationId: string;
|
|
4
|
+
commandType: string;
|
|
5
|
+
itemKey: string;
|
|
6
|
+
currentRequestId: string;
|
|
7
|
+
status: 'running' | 'success' | 'error';
|
|
8
|
+
attemptCount: number;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export interface ItemStatusChangedEvent {
|
|
12
|
+
type: 'ItemStatusChanged';
|
|
13
|
+
data: {
|
|
14
|
+
correlationId: string;
|
|
15
|
+
commandType: string;
|
|
16
|
+
itemKey: string;
|
|
17
|
+
requestId: string;
|
|
18
|
+
status: 'running' | 'success' | 'error';
|
|
19
|
+
attemptCount: number;
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export function evolve(_document: ItemStatusDocument | null, event: ItemStatusChangedEvent): ItemStatusDocument {
|
|
24
|
+
return {
|
|
25
|
+
correlationId: event.data.correlationId,
|
|
26
|
+
commandType: event.data.commandType,
|
|
27
|
+
itemKey: event.data.itemKey,
|
|
28
|
+
currentRequestId: event.data.requestId,
|
|
29
|
+
status: event.data.status,
|
|
30
|
+
attemptCount: event.data.attemptCount,
|
|
31
|
+
};
|
|
32
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export interface LatestRunDocument {
|
|
2
|
+
[key: string]: unknown;
|
|
3
|
+
latestCorrelationId: string;
|
|
4
|
+
triggerCommand: string;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
interface PipelineRunStartedEvent {
|
|
8
|
+
type: 'PipelineRunStarted';
|
|
9
|
+
data: {
|
|
10
|
+
correlationId: string;
|
|
11
|
+
triggerCommand: string;
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export function evolve(_document: LatestRunDocument | null, event: PipelineRunStartedEvent): LatestRunDocument {
|
|
16
|
+
return {
|
|
17
|
+
latestCorrelationId: event.data.correlationId,
|
|
18
|
+
triggerCommand: event.data.triggerCommand,
|
|
19
|
+
};
|
|
20
|
+
}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import { nanoid } from 'nanoid';
|
|
2
|
+
import type { NodeStatus } from '../graph/types';
|
|
3
|
+
|
|
4
|
+
export interface MessageLogDocument {
|
|
5
|
+
[key: string]: unknown;
|
|
6
|
+
correlationId: string;
|
|
7
|
+
requestId: string;
|
|
8
|
+
messageType: 'command' | 'event';
|
|
9
|
+
messageName: string;
|
|
10
|
+
messageData: Record<string, unknown>;
|
|
11
|
+
timestamp: Date;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export interface CommandDispatchedEvent {
|
|
15
|
+
type: 'CommandDispatched';
|
|
16
|
+
data: {
|
|
17
|
+
correlationId: string;
|
|
18
|
+
requestId: string;
|
|
19
|
+
commandType: string;
|
|
20
|
+
commandData: Record<string, unknown>;
|
|
21
|
+
timestamp: Date;
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export interface DomainEventEmittedEvent {
|
|
26
|
+
type: 'DomainEventEmitted';
|
|
27
|
+
data: {
|
|
28
|
+
correlationId: string;
|
|
29
|
+
requestId: string;
|
|
30
|
+
eventType: string;
|
|
31
|
+
eventData: Record<string, unknown>;
|
|
32
|
+
timestamp: Date;
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export interface PipelineRunStartedLogEvent {
|
|
37
|
+
type: 'PipelineRunStarted';
|
|
38
|
+
data: {
|
|
39
|
+
correlationId: string;
|
|
40
|
+
triggerCommand: string;
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export interface NodeStatusChangedLogEvent {
|
|
45
|
+
type: 'NodeStatusChanged';
|
|
46
|
+
data: {
|
|
47
|
+
correlationId: string;
|
|
48
|
+
commandName: string;
|
|
49
|
+
status: NodeStatus;
|
|
50
|
+
previousStatus: NodeStatus;
|
|
51
|
+
pendingCount: number;
|
|
52
|
+
endedCount: number;
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export type MessageLogEvent =
|
|
57
|
+
| CommandDispatchedEvent
|
|
58
|
+
| DomainEventEmittedEvent
|
|
59
|
+
| PipelineRunStartedLogEvent
|
|
60
|
+
| NodeStatusChangedLogEvent;
|
|
61
|
+
|
|
62
|
+
export function evolve(_document: MessageLogDocument | null, event: MessageLogEvent): MessageLogDocument {
|
|
63
|
+
if (event.type === 'CommandDispatched') {
|
|
64
|
+
return {
|
|
65
|
+
correlationId: event.data.correlationId,
|
|
66
|
+
requestId: event.data.requestId,
|
|
67
|
+
messageType: 'command',
|
|
68
|
+
messageName: event.data.commandType,
|
|
69
|
+
messageData: event.data.commandData,
|
|
70
|
+
timestamp: event.data.timestamp,
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
if (event.type === 'DomainEventEmitted') {
|
|
75
|
+
return {
|
|
76
|
+
correlationId: event.data.correlationId,
|
|
77
|
+
requestId: event.data.requestId,
|
|
78
|
+
messageType: 'event',
|
|
79
|
+
messageName: event.data.eventType,
|
|
80
|
+
messageData: event.data.eventData,
|
|
81
|
+
timestamp: event.data.timestamp,
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
if (event.type === 'PipelineRunStarted') {
|
|
86
|
+
return {
|
|
87
|
+
correlationId: event.data.correlationId,
|
|
88
|
+
requestId: event.data.correlationId,
|
|
89
|
+
messageType: 'event',
|
|
90
|
+
messageName: 'PipelineRunStarted',
|
|
91
|
+
messageData: {
|
|
92
|
+
correlationId: event.data.correlationId,
|
|
93
|
+
triggerCommand: event.data.triggerCommand,
|
|
94
|
+
},
|
|
95
|
+
timestamp: new Date(),
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
return {
|
|
100
|
+
correlationId: event.data.correlationId,
|
|
101
|
+
requestId: nanoid(),
|
|
102
|
+
messageType: 'event',
|
|
103
|
+
messageName: 'NodeStatusChanged',
|
|
104
|
+
messageData: {
|
|
105
|
+
nodeId: `cmd:${event.data.commandName}`,
|
|
106
|
+
status: event.data.status,
|
|
107
|
+
previousStatus: event.data.previousStatus,
|
|
108
|
+
pendingCount: event.data.pendingCount,
|
|
109
|
+
endedCount: event.data.endedCount,
|
|
110
|
+
},
|
|
111
|
+
timestamp: new Date(),
|
|
112
|
+
};
|
|
113
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { NodeStatus } from '../graph/types';
|
|
2
|
+
|
|
3
|
+
export interface NodeStatusDocument {
|
|
4
|
+
[key: string]: unknown;
|
|
5
|
+
correlationId: string;
|
|
6
|
+
commandName: string;
|
|
7
|
+
status: NodeStatus;
|
|
8
|
+
pendingCount: number;
|
|
9
|
+
endedCount: number;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export interface NodeStatusChangedEvent {
|
|
13
|
+
type: 'NodeStatusChanged';
|
|
14
|
+
data: {
|
|
15
|
+
correlationId: string;
|
|
16
|
+
commandName: string;
|
|
17
|
+
nodeId: string;
|
|
18
|
+
status: NodeStatus;
|
|
19
|
+
previousStatus: NodeStatus;
|
|
20
|
+
pendingCount: number;
|
|
21
|
+
endedCount: number;
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export function evolve(_document: NodeStatusDocument | null, event: NodeStatusChangedEvent): NodeStatusDocument {
|
|
26
|
+
return {
|
|
27
|
+
correlationId: event.data.correlationId,
|
|
28
|
+
commandName: event.data.commandName,
|
|
29
|
+
status: event.data.status,
|
|
30
|
+
pendingCount: event.data.pendingCount,
|
|
31
|
+
endedCount: event.data.endedCount,
|
|
32
|
+
};
|
|
33
|
+
}
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
import type { Event } from '@auto-engineer/message-bus';
|
|
2
|
+
import { describe, expect, it } from 'vitest';
|
|
3
|
+
import type { PhasedExecutionDocument, PhasedExecutionEvent } from './phased-execution-projection';
|
|
4
|
+
import { evolve } from './phased-execution-projection';
|
|
5
|
+
|
|
6
|
+
describe('PhasedExecutionProjection', () => {
|
|
7
|
+
const triggerEvent: Event = { type: 'TestEvent', correlationId: 'c1', data: { items: ['a', 'b'] } };
|
|
8
|
+
|
|
9
|
+
describe('PhasedExecutionStarted', () => {
|
|
10
|
+
it('should create initial document with items and phases', () => {
|
|
11
|
+
const event: PhasedExecutionEvent = {
|
|
12
|
+
type: 'PhasedExecutionStarted',
|
|
13
|
+
data: {
|
|
14
|
+
executionId: 'exec-1',
|
|
15
|
+
correlationId: 'c1',
|
|
16
|
+
handlerId: 'handler-1',
|
|
17
|
+
triggerEvent,
|
|
18
|
+
items: [
|
|
19
|
+
{ key: 'a', phase: 'prepare', dispatched: false, completed: false },
|
|
20
|
+
{ key: 'b', phase: 'execute', dispatched: false, completed: false },
|
|
21
|
+
],
|
|
22
|
+
phases: ['prepare', 'execute'],
|
|
23
|
+
},
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
const result = evolve(null, event);
|
|
27
|
+
|
|
28
|
+
expect(result.executionId).toBe('exec-1');
|
|
29
|
+
expect(result.correlationId).toBe('c1');
|
|
30
|
+
expect(result.handlerId).toBe('handler-1');
|
|
31
|
+
expect(result.status).toBe('active');
|
|
32
|
+
expect(result.currentPhaseIndex).toBe(0);
|
|
33
|
+
expect(result.items).toHaveLength(2);
|
|
34
|
+
expect(result.phases).toEqual(['prepare', 'execute']);
|
|
35
|
+
expect(result.failedItems).toEqual([]);
|
|
36
|
+
});
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
describe('PhasedItemDispatched', () => {
|
|
40
|
+
it('should mark item as dispatched', () => {
|
|
41
|
+
const doc: PhasedExecutionDocument = {
|
|
42
|
+
executionId: 'exec-1',
|
|
43
|
+
correlationId: 'c1',
|
|
44
|
+
handlerId: 'handler-1',
|
|
45
|
+
triggerEvent,
|
|
46
|
+
items: [
|
|
47
|
+
{ key: 'a', phase: 'prepare', dispatched: false, completed: false },
|
|
48
|
+
{ key: 'b', phase: 'execute', dispatched: false, completed: false },
|
|
49
|
+
],
|
|
50
|
+
phases: ['prepare', 'execute'],
|
|
51
|
+
currentPhaseIndex: 0,
|
|
52
|
+
status: 'active',
|
|
53
|
+
failedItems: [],
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
const event: PhasedExecutionEvent = {
|
|
57
|
+
type: 'PhasedItemDispatched',
|
|
58
|
+
data: { executionId: 'exec-1', itemKey: 'a', phase: 'prepare' },
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
const result = evolve(doc, event);
|
|
62
|
+
|
|
63
|
+
expect(result.items.find((i) => i.key === 'a')?.dispatched).toBe(true);
|
|
64
|
+
expect(result.items.find((i) => i.key === 'b')?.dispatched).toBe(false);
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
it('should throw when document is null', () => {
|
|
68
|
+
const event: PhasedExecutionEvent = {
|
|
69
|
+
type: 'PhasedItemDispatched',
|
|
70
|
+
data: { executionId: 'exec-1', itemKey: 'a', phase: 'prepare' },
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
expect(() => evolve(null, event)).toThrow('Cannot apply PhasedItemDispatched to null document');
|
|
74
|
+
});
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
describe('PhasedItemCompleted', () => {
|
|
78
|
+
it('should mark item as completed', () => {
|
|
79
|
+
const doc: PhasedExecutionDocument = {
|
|
80
|
+
executionId: 'exec-1',
|
|
81
|
+
correlationId: 'c1',
|
|
82
|
+
handlerId: 'handler-1',
|
|
83
|
+
triggerEvent,
|
|
84
|
+
items: [{ key: 'a', phase: 'prepare', dispatched: true, completed: false }],
|
|
85
|
+
phases: ['prepare'],
|
|
86
|
+
currentPhaseIndex: 0,
|
|
87
|
+
status: 'active',
|
|
88
|
+
failedItems: [],
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
const resultEvent: Event = { type: 'ItemDone', correlationId: 'c1', data: {} };
|
|
92
|
+
const event: PhasedExecutionEvent = {
|
|
93
|
+
type: 'PhasedItemCompleted',
|
|
94
|
+
data: { executionId: 'exec-1', itemKey: 'a', resultEvent },
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
const result = evolve(doc, event);
|
|
98
|
+
|
|
99
|
+
expect(result.items.find((i) => i.key === 'a')?.completed).toBe(true);
|
|
100
|
+
});
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
describe('PhasedItemFailed', () => {
|
|
104
|
+
it('should add item to failedItems', () => {
|
|
105
|
+
const doc: PhasedExecutionDocument = {
|
|
106
|
+
executionId: 'exec-1',
|
|
107
|
+
correlationId: 'c1',
|
|
108
|
+
handlerId: 'handler-1',
|
|
109
|
+
triggerEvent,
|
|
110
|
+
items: [{ key: 'a', phase: 'prepare', dispatched: true, completed: false }],
|
|
111
|
+
phases: ['prepare'],
|
|
112
|
+
currentPhaseIndex: 0,
|
|
113
|
+
status: 'active',
|
|
114
|
+
failedItems: [],
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
const event: PhasedExecutionEvent = {
|
|
118
|
+
type: 'PhasedItemFailed',
|
|
119
|
+
data: { executionId: 'exec-1', itemKey: 'a', error: { message: 'Failed' } },
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
const result = evolve(doc, event);
|
|
123
|
+
|
|
124
|
+
expect(result.failedItems).toHaveLength(1);
|
|
125
|
+
expect(result.failedItems[0].key).toBe('a');
|
|
126
|
+
expect(result.failedItems[0].error).toEqual({ message: 'Failed' });
|
|
127
|
+
});
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
describe('PhasedPhaseAdvanced', () => {
|
|
131
|
+
it('should update currentPhaseIndex', () => {
|
|
132
|
+
const doc: PhasedExecutionDocument = {
|
|
133
|
+
executionId: 'exec-1',
|
|
134
|
+
correlationId: 'c1',
|
|
135
|
+
handlerId: 'handler-1',
|
|
136
|
+
triggerEvent,
|
|
137
|
+
items: [{ key: 'a', phase: 'prepare', dispatched: true, completed: true }],
|
|
138
|
+
phases: ['prepare', 'execute'],
|
|
139
|
+
currentPhaseIndex: 0,
|
|
140
|
+
status: 'active',
|
|
141
|
+
failedItems: [],
|
|
142
|
+
};
|
|
143
|
+
|
|
144
|
+
const event: PhasedExecutionEvent = {
|
|
145
|
+
type: 'PhasedPhaseAdvanced',
|
|
146
|
+
data: { executionId: 'exec-1', fromPhase: 0, toPhase: 1 },
|
|
147
|
+
};
|
|
148
|
+
|
|
149
|
+
const result = evolve(doc, event);
|
|
150
|
+
|
|
151
|
+
expect(result.currentPhaseIndex).toBe(1);
|
|
152
|
+
});
|
|
153
|
+
});
|
|
154
|
+
|
|
155
|
+
describe('PhasedExecutionCompleted', () => {
|
|
156
|
+
it('should set status to completed on success', () => {
|
|
157
|
+
const doc: PhasedExecutionDocument = {
|
|
158
|
+
executionId: 'exec-1',
|
|
159
|
+
correlationId: 'c1',
|
|
160
|
+
handlerId: 'handler-1',
|
|
161
|
+
triggerEvent,
|
|
162
|
+
items: [{ key: 'a', phase: 'prepare', dispatched: true, completed: true }],
|
|
163
|
+
phases: ['prepare'],
|
|
164
|
+
currentPhaseIndex: 1,
|
|
165
|
+
status: 'active',
|
|
166
|
+
failedItems: [],
|
|
167
|
+
};
|
|
168
|
+
|
|
169
|
+
const event: PhasedExecutionEvent = {
|
|
170
|
+
type: 'PhasedExecutionCompleted',
|
|
171
|
+
data: { executionId: 'exec-1', success: true, results: ['a'] },
|
|
172
|
+
};
|
|
173
|
+
|
|
174
|
+
const result = evolve(doc, event);
|
|
175
|
+
|
|
176
|
+
expect(result.status).toBe('completed');
|
|
177
|
+
});
|
|
178
|
+
|
|
179
|
+
it('should set status to failed on failure', () => {
|
|
180
|
+
const doc: PhasedExecutionDocument = {
|
|
181
|
+
executionId: 'exec-1',
|
|
182
|
+
correlationId: 'c1',
|
|
183
|
+
handlerId: 'handler-1',
|
|
184
|
+
triggerEvent,
|
|
185
|
+
items: [{ key: 'a', phase: 'prepare', dispatched: true, completed: false }],
|
|
186
|
+
phases: ['prepare'],
|
|
187
|
+
currentPhaseIndex: 0,
|
|
188
|
+
status: 'active',
|
|
189
|
+
failedItems: [{ key: 'a', error: { message: 'Failed' } }],
|
|
190
|
+
};
|
|
191
|
+
|
|
192
|
+
const event: PhasedExecutionEvent = {
|
|
193
|
+
type: 'PhasedExecutionCompleted',
|
|
194
|
+
data: { executionId: 'exec-1', success: false, results: [] },
|
|
195
|
+
};
|
|
196
|
+
|
|
197
|
+
const result = evolve(doc, event);
|
|
198
|
+
|
|
199
|
+
expect(result.status).toBe('failed');
|
|
200
|
+
});
|
|
201
|
+
});
|
|
202
|
+
});
|