@auto-engineer/pipeline 1.2.0 → 1.3.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.
Files changed (155) hide show
  1. package/.turbo/turbo-build.log +1 -1
  2. package/.turbo/turbo-test.log +7 -7
  3. package/.turbo/turbo-type-check.log +1 -1
  4. package/CHANGELOG.md +15 -0
  5. package/dist/src/builder/define.specs.d.ts +2 -0
  6. package/dist/src/builder/define.specs.d.ts.map +1 -0
  7. package/dist/src/builder/define.specs.js +435 -0
  8. package/dist/src/builder/define.specs.js.map +1 -0
  9. package/dist/src/core/descriptors.specs.d.ts +2 -0
  10. package/dist/src/core/descriptors.specs.d.ts.map +1 -0
  11. package/dist/src/core/descriptors.specs.js +24 -0
  12. package/dist/src/core/descriptors.specs.js.map +1 -0
  13. package/dist/src/core/types.specs.d.ts +2 -0
  14. package/dist/src/core/types.specs.d.ts.map +1 -0
  15. package/dist/src/core/types.specs.js +40 -0
  16. package/dist/src/core/types.specs.js.map +1 -0
  17. package/dist/src/graph/filter-graph.specs.d.ts +2 -0
  18. package/dist/src/graph/filter-graph.specs.d.ts.map +1 -0
  19. package/dist/src/graph/filter-graph.specs.js +204 -0
  20. package/dist/src/graph/filter-graph.specs.js.map +1 -0
  21. package/dist/src/graph/types.specs.d.ts +2 -0
  22. package/dist/src/graph/types.specs.d.ts.map +1 -0
  23. package/dist/src/graph/types.specs.js +148 -0
  24. package/dist/src/graph/types.specs.js.map +1 -0
  25. package/dist/src/logging/event-logger.specs.d.ts +2 -0
  26. package/dist/src/logging/event-logger.specs.d.ts.map +1 -0
  27. package/dist/src/logging/event-logger.specs.js +81 -0
  28. package/dist/src/logging/event-logger.specs.js.map +1 -0
  29. package/dist/src/plugins/handler-adapter.specs.d.ts +2 -0
  30. package/dist/src/plugins/handler-adapter.specs.d.ts.map +1 -0
  31. package/dist/src/plugins/handler-adapter.specs.js +129 -0
  32. package/dist/src/plugins/handler-adapter.specs.js.map +1 -0
  33. package/dist/src/plugins/plugin-loader.specs.d.ts +2 -0
  34. package/dist/src/plugins/plugin-loader.specs.d.ts.map +1 -0
  35. package/dist/src/plugins/plugin-loader.specs.js +246 -0
  36. package/dist/src/plugins/plugin-loader.specs.js.map +1 -0
  37. package/dist/src/projections/item-status-projection.specs.d.ts +2 -0
  38. package/dist/src/projections/item-status-projection.specs.d.ts.map +1 -0
  39. package/dist/src/projections/item-status-projection.specs.js +119 -0
  40. package/dist/src/projections/item-status-projection.specs.js.map +1 -0
  41. package/dist/src/projections/latest-run-projection.specs.d.ts +2 -0
  42. package/dist/src/projections/latest-run-projection.specs.d.ts.map +1 -0
  43. package/dist/src/projections/latest-run-projection.specs.js +33 -0
  44. package/dist/src/projections/latest-run-projection.specs.js.map +1 -0
  45. package/dist/src/projections/message-log-projection.specs.d.ts +2 -0
  46. package/dist/src/projections/message-log-projection.specs.d.ts.map +1 -0
  47. package/dist/src/projections/message-log-projection.specs.js +101 -0
  48. package/dist/src/projections/message-log-projection.specs.js.map +1 -0
  49. package/dist/src/projections/node-status-projection.specs.d.ts +2 -0
  50. package/dist/src/projections/node-status-projection.specs.d.ts.map +1 -0
  51. package/dist/src/projections/node-status-projection.specs.js +116 -0
  52. package/dist/src/projections/node-status-projection.specs.js.map +1 -0
  53. package/dist/src/projections/phased-execution-projection.specs.d.ts +2 -0
  54. package/dist/src/projections/phased-execution-projection.specs.d.ts.map +1 -0
  55. package/dist/src/projections/phased-execution-projection.specs.js +171 -0
  56. package/dist/src/projections/phased-execution-projection.specs.js.map +1 -0
  57. package/dist/src/projections/settled-instance-projection.specs.d.ts +2 -0
  58. package/dist/src/projections/settled-instance-projection.specs.d.ts.map +1 -0
  59. package/dist/src/projections/settled-instance-projection.specs.js +217 -0
  60. package/dist/src/projections/settled-instance-projection.specs.js.map +1 -0
  61. package/dist/src/projections/stats-projection.specs.d.ts +2 -0
  62. package/dist/src/projections/stats-projection.specs.d.ts.map +1 -0
  63. package/dist/src/projections/stats-projection.specs.js +91 -0
  64. package/dist/src/projections/stats-projection.specs.js.map +1 -0
  65. package/dist/src/runtime/await-tracker.specs.d.ts +2 -0
  66. package/dist/src/runtime/await-tracker.specs.d.ts.map +1 -0
  67. package/dist/src/runtime/await-tracker.specs.js +64 -0
  68. package/dist/src/runtime/await-tracker.specs.js.map +1 -0
  69. package/dist/src/runtime/context.specs.d.ts +2 -0
  70. package/dist/src/runtime/context.specs.d.ts.map +1 -0
  71. package/dist/src/runtime/context.specs.js +26 -0
  72. package/dist/src/runtime/context.specs.js.map +1 -0
  73. package/dist/src/runtime/event-command-map.specs.d.ts +2 -0
  74. package/dist/src/runtime/event-command-map.specs.d.ts.map +1 -0
  75. package/dist/src/runtime/event-command-map.specs.js +108 -0
  76. package/dist/src/runtime/event-command-map.specs.js.map +1 -0
  77. package/dist/src/runtime/phased-executor.specs.d.ts +2 -0
  78. package/dist/src/runtime/phased-executor.specs.d.ts.map +1 -0
  79. package/dist/src/runtime/phased-executor.specs.js +418 -0
  80. package/dist/src/runtime/phased-executor.specs.js.map +1 -0
  81. package/dist/src/runtime/pipeline-runtime.specs.d.ts +2 -0
  82. package/dist/src/runtime/pipeline-runtime.specs.d.ts.map +1 -0
  83. package/dist/src/runtime/pipeline-runtime.specs.js +227 -0
  84. package/dist/src/runtime/pipeline-runtime.specs.js.map +1 -0
  85. package/dist/src/runtime/settled-tracker.specs.d.ts +2 -0
  86. package/dist/src/runtime/settled-tracker.specs.d.ts.map +1 -0
  87. package/dist/src/runtime/settled-tracker.specs.js +811 -0
  88. package/dist/src/runtime/settled-tracker.specs.js.map +1 -0
  89. package/dist/src/server/full-orchestration.e2e.specs.d.ts +2 -0
  90. package/dist/src/server/full-orchestration.e2e.specs.d.ts.map +1 -0
  91. package/dist/src/server/full-orchestration.e2e.specs.js +561 -0
  92. package/dist/src/server/full-orchestration.e2e.specs.js.map +1 -0
  93. package/dist/src/server/pipeline-server.e2e.specs.d.ts +2 -0
  94. package/dist/src/server/pipeline-server.e2e.specs.d.ts.map +1 -0
  95. package/dist/src/server/pipeline-server.e2e.specs.js +373 -0
  96. package/dist/src/server/pipeline-server.e2e.specs.js.map +1 -0
  97. package/dist/src/server/pipeline-server.specs.d.ts +2 -0
  98. package/dist/src/server/pipeline-server.specs.d.ts.map +1 -0
  99. package/dist/src/server/pipeline-server.specs.js +1407 -0
  100. package/dist/src/server/pipeline-server.specs.js.map +1 -0
  101. package/dist/src/server/sse-manager.specs.d.ts +2 -0
  102. package/dist/src/server/sse-manager.specs.d.ts.map +1 -0
  103. package/dist/src/server/sse-manager.specs.js +178 -0
  104. package/dist/src/server/sse-manager.specs.js.map +1 -0
  105. package/dist/src/store/pipeline-event-store.specs.d.ts +2 -0
  106. package/dist/src/store/pipeline-event-store.specs.d.ts.map +1 -0
  107. package/dist/src/store/pipeline-event-store.specs.js +287 -0
  108. package/dist/src/store/pipeline-event-store.specs.js.map +1 -0
  109. package/dist/src/store/pipeline-read-model.specs.d.ts +2 -0
  110. package/dist/src/store/pipeline-read-model.specs.d.ts.map +1 -0
  111. package/dist/src/store/pipeline-read-model.specs.js +830 -0
  112. package/dist/src/store/pipeline-read-model.specs.js.map +1 -0
  113. package/dist/src/testing/event-capture.specs.d.ts +2 -0
  114. package/dist/src/testing/event-capture.specs.d.ts.map +1 -0
  115. package/dist/src/testing/event-capture.specs.js +114 -0
  116. package/dist/src/testing/event-capture.specs.js.map +1 -0
  117. package/dist/src/testing/fixtures/kanban-full.pipeline.specs.d.ts +2 -0
  118. package/dist/src/testing/fixtures/kanban-full.pipeline.specs.d.ts.map +1 -0
  119. package/dist/src/testing/fixtures/kanban-full.pipeline.specs.js +263 -0
  120. package/dist/src/testing/fixtures/kanban-full.pipeline.specs.js.map +1 -0
  121. package/dist/src/testing/fixtures/kanban.pipeline.specs.d.ts +2 -0
  122. package/dist/src/testing/fixtures/kanban.pipeline.specs.d.ts.map +1 -0
  123. package/dist/src/testing/fixtures/kanban.pipeline.specs.js +29 -0
  124. package/dist/src/testing/fixtures/kanban.pipeline.specs.js.map +1 -0
  125. package/dist/src/testing/kanban-todo.e2e.specs.d.ts +2 -0
  126. package/dist/src/testing/kanban-todo.e2e.specs.d.ts.map +1 -0
  127. package/dist/src/testing/kanban-todo.e2e.specs.js +160 -0
  128. package/dist/src/testing/kanban-todo.e2e.specs.js.map +1 -0
  129. package/dist/src/testing/mock-handlers.specs.d.ts +2 -0
  130. package/dist/src/testing/mock-handlers.specs.d.ts.map +1 -0
  131. package/dist/src/testing/mock-handlers.specs.js +193 -0
  132. package/dist/src/testing/mock-handlers.specs.js.map +1 -0
  133. package/dist/src/testing/real-execution.e2e.specs.d.ts +2 -0
  134. package/dist/src/testing/real-execution.e2e.specs.d.ts.map +1 -0
  135. package/dist/src/testing/real-execution.e2e.specs.js +140 -0
  136. package/dist/src/testing/real-execution.e2e.specs.js.map +1 -0
  137. package/dist/src/testing/real-plugin.e2e.specs.d.ts +2 -0
  138. package/dist/src/testing/real-plugin.e2e.specs.d.ts.map +1 -0
  139. package/dist/src/testing/real-plugin.e2e.specs.js +65 -0
  140. package/dist/src/testing/real-plugin.e2e.specs.js.map +1 -0
  141. package/dist/src/testing/server-startup.e2e.specs.d.ts +2 -0
  142. package/dist/src/testing/server-startup.e2e.specs.d.ts.map +1 -0
  143. package/dist/src/testing/server-startup.e2e.specs.js +104 -0
  144. package/dist/src/testing/server-startup.e2e.specs.js.map +1 -0
  145. package/dist/src/testing/snapshot-compare.specs.d.ts +2 -0
  146. package/dist/src/testing/snapshot-compare.specs.d.ts.map +1 -0
  147. package/dist/src/testing/snapshot-compare.specs.js +112 -0
  148. package/dist/src/testing/snapshot-compare.specs.js.map +1 -0
  149. package/dist/src/testing/snapshot-sanitize.specs.d.ts +2 -0
  150. package/dist/src/testing/snapshot-sanitize.specs.d.ts.map +1 -0
  151. package/dist/src/testing/snapshot-sanitize.specs.js +104 -0
  152. package/dist/src/testing/snapshot-sanitize.specs.js.map +1 -0
  153. package/dist/tsconfig.tsbuildinfo +1 -1
  154. package/package.json +15 -14
  155. package/LICENSE +0 -10
@@ -0,0 +1,101 @@
1
+ import { describe, expect, it } from 'vitest';
2
+ import { evolve, } from './message-log-projection.js';
3
+ describe('MessageLogProjection', () => {
4
+ describe('CommandDispatched', () => {
5
+ it('creates message log entry for dispatched command', () => {
6
+ const event = {
7
+ type: 'CommandDispatched',
8
+ data: {
9
+ correlationId: 'c1',
10
+ requestId: 'r1',
11
+ commandType: 'CreateUser',
12
+ commandData: { name: 'Alice' },
13
+ timestamp: new Date('2025-01-01T00:00:00Z'),
14
+ },
15
+ };
16
+ const result = evolve(null, event);
17
+ expect(result).toEqual({
18
+ correlationId: 'c1',
19
+ requestId: 'r1',
20
+ messageType: 'command',
21
+ messageName: 'CreateUser',
22
+ messageData: { name: 'Alice' },
23
+ timestamp: new Date('2025-01-01T00:00:00Z'),
24
+ });
25
+ });
26
+ });
27
+ describe('DomainEventEmitted', () => {
28
+ it('creates message log entry for emitted domain event', () => {
29
+ const event = {
30
+ type: 'DomainEventEmitted',
31
+ data: {
32
+ correlationId: 'c1',
33
+ requestId: 'r2',
34
+ eventType: 'UserCreated',
35
+ eventData: { userId: '123', name: 'Alice' },
36
+ timestamp: new Date('2025-01-01T00:00:01Z'),
37
+ },
38
+ };
39
+ const result = evolve(null, event);
40
+ expect(result).toEqual({
41
+ correlationId: 'c1',
42
+ requestId: 'r2',
43
+ messageType: 'event',
44
+ messageName: 'UserCreated',
45
+ messageData: { userId: '123', name: 'Alice' },
46
+ timestamp: new Date('2025-01-01T00:00:01Z'),
47
+ });
48
+ });
49
+ });
50
+ describe('PipelineRunStarted', () => {
51
+ it('creates message log entry for pipeline run started', () => {
52
+ const event = {
53
+ type: 'PipelineRunStarted',
54
+ data: {
55
+ correlationId: 'c1',
56
+ triggerCommand: 'CreateUser',
57
+ },
58
+ };
59
+ const result = evolve(null, event);
60
+ expect(result).toEqual({
61
+ correlationId: 'c1',
62
+ requestId: 'c1',
63
+ messageType: 'event',
64
+ messageName: 'PipelineRunStarted',
65
+ messageData: { correlationId: 'c1', triggerCommand: 'CreateUser' },
66
+ timestamp: expect.any(Date),
67
+ });
68
+ });
69
+ });
70
+ describe('NodeStatusChanged', () => {
71
+ it('creates message log entry for node status changed', () => {
72
+ const event = {
73
+ type: 'NodeStatusChanged',
74
+ data: {
75
+ correlationId: 'c1',
76
+ commandName: 'CreateUser',
77
+ status: 'running',
78
+ previousStatus: 'idle',
79
+ pendingCount: 1,
80
+ endedCount: 0,
81
+ },
82
+ };
83
+ const result = evolve(null, event);
84
+ expect(result).toEqual({
85
+ correlationId: 'c1',
86
+ requestId: expect.any(String),
87
+ messageType: 'event',
88
+ messageName: 'NodeStatusChanged',
89
+ messageData: {
90
+ nodeId: 'cmd:CreateUser',
91
+ status: 'running',
92
+ previousStatus: 'idle',
93
+ pendingCount: 1,
94
+ endedCount: 0,
95
+ },
96
+ timestamp: expect.any(Date),
97
+ });
98
+ });
99
+ });
100
+ });
101
+ //# sourceMappingURL=message-log-projection.specs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"message-log-projection.specs.js","sourceRoot":"","sources":["../../../src/projections/message-log-projection.specs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAC9C,OAAO,EAGL,MAAM,GAGP,MAAM,0BAA0B,CAAC;AAElC,QAAQ,CAAC,sBAAsB,EAAE,GAAG,EAAE;IACpC,QAAQ,CAAC,mBAAmB,EAAE,GAAG,EAAE;QACjC,EAAE,CAAC,kDAAkD,EAAE,GAAG,EAAE;YAC1D,MAAM,KAAK,GAA2B;gBACpC,IAAI,EAAE,mBAAmB;gBACzB,IAAI,EAAE;oBACJ,aAAa,EAAE,IAAI;oBACnB,SAAS,EAAE,IAAI;oBACf,WAAW,EAAE,YAAY;oBACzB,WAAW,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE;oBAC9B,SAAS,EAAE,IAAI,IAAI,CAAC,sBAAsB,CAAC;iBAC5C;aAC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MAAM,EAAE,SAAS;oBACjB,cAAc,EAAE,MAAM;oBACtB,YAAY,EAAE,CAAC;oBACf,UAAU,EAAE,CAAC;iBACd;gBACD,SAAS,EAAE,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC;aAC5B,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=node-status-projection.specs.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"node-status-projection.specs.d.ts","sourceRoot":"","sources":["../../../src/projections/node-status-projection.specs.ts"],"names":[],"mappings":""}
@@ -0,0 +1,116 @@
1
+ import { describe, expect, it } from 'vitest';
2
+ import { evolve } from './node-status-projection.js';
3
+ describe('NodeStatusProjection', () => {
4
+ describe('evolve', () => {
5
+ it('creates node document with running status when command starts', () => {
6
+ const event = {
7
+ type: 'NodeStatusChanged',
8
+ data: {
9
+ correlationId: 'c1',
10
+ commandName: 'ProcessItem',
11
+ nodeId: 'cmd:ProcessItem',
12
+ status: 'running',
13
+ previousStatus: 'idle',
14
+ pendingCount: 1,
15
+ endedCount: 0,
16
+ },
17
+ };
18
+ const result = evolve(null, event);
19
+ expect(result).toEqual({
20
+ correlationId: 'c1',
21
+ commandName: 'ProcessItem',
22
+ status: 'running',
23
+ pendingCount: 1,
24
+ endedCount: 0,
25
+ });
26
+ });
27
+ it('updates node document to success status when command completes', () => {
28
+ const existing = {
29
+ correlationId: 'c1',
30
+ commandName: 'ProcessItem',
31
+ status: 'running',
32
+ pendingCount: 1,
33
+ endedCount: 0,
34
+ };
35
+ const event = {
36
+ type: 'NodeStatusChanged',
37
+ data: {
38
+ correlationId: 'c1',
39
+ commandName: 'ProcessItem',
40
+ nodeId: 'cmd:ProcessItem',
41
+ status: 'success',
42
+ previousStatus: 'running',
43
+ pendingCount: 0,
44
+ endedCount: 1,
45
+ },
46
+ };
47
+ const result = evolve(existing, event);
48
+ expect(result).toEqual({
49
+ correlationId: 'c1',
50
+ commandName: 'ProcessItem',
51
+ status: 'success',
52
+ pendingCount: 0,
53
+ endedCount: 1,
54
+ });
55
+ });
56
+ it('updates node document to error status when command fails', () => {
57
+ const existing = {
58
+ correlationId: 'c1',
59
+ commandName: 'ProcessItem',
60
+ status: 'running',
61
+ pendingCount: 1,
62
+ endedCount: 0,
63
+ };
64
+ const event = {
65
+ type: 'NodeStatusChanged',
66
+ data: {
67
+ correlationId: 'c1',
68
+ commandName: 'ProcessItem',
69
+ nodeId: 'cmd:ProcessItem',
70
+ status: 'error',
71
+ previousStatus: 'running',
72
+ pendingCount: 0,
73
+ endedCount: 1,
74
+ },
75
+ };
76
+ const result = evolve(existing, event);
77
+ expect(result).toEqual({
78
+ correlationId: 'c1',
79
+ commandName: 'ProcessItem',
80
+ status: 'error',
81
+ pendingCount: 0,
82
+ endedCount: 1,
83
+ });
84
+ });
85
+ it('tracks pending and ended counts for parallel items', () => {
86
+ const existing = {
87
+ correlationId: 'c1',
88
+ commandName: 'ProcessItem',
89
+ status: 'running',
90
+ pendingCount: 3,
91
+ endedCount: 2,
92
+ };
93
+ const event = {
94
+ type: 'NodeStatusChanged',
95
+ data: {
96
+ correlationId: 'c1',
97
+ commandName: 'ProcessItem',
98
+ nodeId: 'cmd:ProcessItem',
99
+ status: 'running',
100
+ previousStatus: 'running',
101
+ pendingCount: 2,
102
+ endedCount: 3,
103
+ },
104
+ };
105
+ const result = evolve(existing, event);
106
+ expect(result).toEqual({
107
+ correlationId: 'c1',
108
+ commandName: 'ProcessItem',
109
+ status: 'running',
110
+ pendingCount: 2,
111
+ endedCount: 3,
112
+ });
113
+ });
114
+ });
115
+ });
116
+ //# sourceMappingURL=node-status-projection.specs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"node-status-projection.specs.js","sourceRoot":"","sources":["../../../src/projections/node-status-projection.specs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE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UAAU,EAAE,CAAC;aACd,CAAC;YACF,MAAM,KAAK,GAA2B;gBACpC,IAAI,EAAE,mBAAmB;gBACzB,IAAI,EAAE;oBACJ,aAAa,EAAE,IAAI;oBACnB,WAAW,EAAE,aAAa;oBAC1B,MAAM,EAAE,iBAAiB;oBACzB,MAAM,EAAE,SAAS;oBACjB,cAAc,EAAE,SAAS;oBACzB,YAAY,EAAE,CAAC;oBACf,UAAU,EAAE,CAAC;iBACd;aACF,CAAC;YAEF,MAAM,MAAM,GAAG,MAAM,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;YAEvC,MAAM,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC;gBACrB,aAAa,EAAE,IAAI;gBACnB,WAAW,EAAE,aAAa;gBAC1B,MAAM,EAAE,SAAS;gBACjB,YAAY,EAAE,CAAC;gBACf,UAAU,EAAE,CAAC;aACd,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=phased-execution-projection.specs.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"phased-execution-projection.specs.d.ts","sourceRoot":"","sources":["../../../src/projections/phased-execution-projection.specs.ts"],"names":[],"mappings":""}
@@ -0,0 +1,171 @@
1
+ import { describe, expect, it } from 'vitest';
2
+ import { evolve } from './phased-execution-projection.js';
3
+ describe('PhasedExecutionProjection', () => {
4
+ const triggerEvent = { type: 'TestEvent', correlationId: 'c1', data: { items: ['a', 'b'] } };
5
+ describe('PhasedExecutionStarted', () => {
6
+ it('should create initial document with items and phases', () => {
7
+ const event = {
8
+ type: 'PhasedExecutionStarted',
9
+ data: {
10
+ executionId: 'exec-1',
11
+ correlationId: 'c1',
12
+ handlerId: 'handler-1',
13
+ triggerEvent,
14
+ items: [
15
+ { key: 'a', phase: 'prepare', dispatched: false, completed: false },
16
+ { key: 'b', phase: 'execute', dispatched: false, completed: false },
17
+ ],
18
+ phases: ['prepare', 'execute'],
19
+ },
20
+ };
21
+ const result = evolve(null, event);
22
+ expect(result.executionId).toBe('exec-1');
23
+ expect(result.correlationId).toBe('c1');
24
+ expect(result.handlerId).toBe('handler-1');
25
+ expect(result.status).toBe('active');
26
+ expect(result.currentPhaseIndex).toBe(0);
27
+ expect(result.items).toHaveLength(2);
28
+ expect(result.phases).toEqual(['prepare', 'execute']);
29
+ expect(result.failedItems).toEqual([]);
30
+ });
31
+ });
32
+ describe('PhasedItemDispatched', () => {
33
+ it('should mark item as dispatched', () => {
34
+ const doc = {
35
+ executionId: 'exec-1',
36
+ correlationId: 'c1',
37
+ handlerId: 'handler-1',
38
+ triggerEvent,
39
+ items: [
40
+ { key: 'a', phase: 'prepare', dispatched: false, completed: false },
41
+ { key: 'b', phase: 'execute', dispatched: false, completed: false },
42
+ ],
43
+ phases: ['prepare', 'execute'],
44
+ currentPhaseIndex: 0,
45
+ status: 'active',
46
+ failedItems: [],
47
+ };
48
+ const event = {
49
+ type: 'PhasedItemDispatched',
50
+ data: { executionId: 'exec-1', itemKey: 'a', phase: 'prepare' },
51
+ };
52
+ const result = evolve(doc, event);
53
+ expect(result.items.find((i) => i.key === 'a')?.dispatched).toBe(true);
54
+ expect(result.items.find((i) => i.key === 'b')?.dispatched).toBe(false);
55
+ });
56
+ it('should throw when document is null', () => {
57
+ const event = {
58
+ type: 'PhasedItemDispatched',
59
+ data: { executionId: 'exec-1', itemKey: 'a', phase: 'prepare' },
60
+ };
61
+ expect(() => evolve(null, event)).toThrow('Cannot apply PhasedItemDispatched to null document');
62
+ });
63
+ });
64
+ describe('PhasedItemCompleted', () => {
65
+ it('should mark item as completed', () => {
66
+ const doc = {
67
+ executionId: 'exec-1',
68
+ correlationId: 'c1',
69
+ handlerId: 'handler-1',
70
+ triggerEvent,
71
+ items: [{ key: 'a', phase: 'prepare', dispatched: true, completed: false }],
72
+ phases: ['prepare'],
73
+ currentPhaseIndex: 0,
74
+ status: 'active',
75
+ failedItems: [],
76
+ };
77
+ const resultEvent = { type: 'ItemDone', correlationId: 'c1', data: {} };
78
+ const event = {
79
+ type: 'PhasedItemCompleted',
80
+ data: { executionId: 'exec-1', itemKey: 'a', resultEvent },
81
+ };
82
+ const result = evolve(doc, event);
83
+ expect(result.items.find((i) => i.key === 'a')?.completed).toBe(true);
84
+ });
85
+ });
86
+ describe('PhasedItemFailed', () => {
87
+ it('should add item to failedItems', () => {
88
+ const doc = {
89
+ executionId: 'exec-1',
90
+ correlationId: 'c1',
91
+ handlerId: 'handler-1',
92
+ triggerEvent,
93
+ items: [{ key: 'a', phase: 'prepare', dispatched: true, completed: false }],
94
+ phases: ['prepare'],
95
+ currentPhaseIndex: 0,
96
+ status: 'active',
97
+ failedItems: [],
98
+ };
99
+ const event = {
100
+ type: 'PhasedItemFailed',
101
+ data: { executionId: 'exec-1', itemKey: 'a', error: { message: 'Failed' } },
102
+ };
103
+ const result = evolve(doc, event);
104
+ expect(result.failedItems).toHaveLength(1);
105
+ expect(result.failedItems[0].key).toBe('a');
106
+ expect(result.failedItems[0].error).toEqual({ message: 'Failed' });
107
+ });
108
+ });
109
+ describe('PhasedPhaseAdvanced', () => {
110
+ it('should update currentPhaseIndex', () => {
111
+ const doc = {
112
+ executionId: 'exec-1',
113
+ correlationId: 'c1',
114
+ handlerId: 'handler-1',
115
+ triggerEvent,
116
+ items: [{ key: 'a', phase: 'prepare', dispatched: true, completed: true }],
117
+ phases: ['prepare', 'execute'],
118
+ currentPhaseIndex: 0,
119
+ status: 'active',
120
+ failedItems: [],
121
+ };
122
+ const event = {
123
+ type: 'PhasedPhaseAdvanced',
124
+ data: { executionId: 'exec-1', fromPhase: 0, toPhase: 1 },
125
+ };
126
+ const result = evolve(doc, event);
127
+ expect(result.currentPhaseIndex).toBe(1);
128
+ });
129
+ });
130
+ describe('PhasedExecutionCompleted', () => {
131
+ it('should set status to completed on success', () => {
132
+ const doc = {
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'],
139
+ currentPhaseIndex: 1,
140
+ status: 'active',
141
+ failedItems: [],
142
+ };
143
+ const event = {
144
+ type: 'PhasedExecutionCompleted',
145
+ data: { executionId: 'exec-1', success: true, results: ['a'] },
146
+ };
147
+ const result = evolve(doc, event);
148
+ expect(result.status).toBe('completed');
149
+ });
150
+ it('should set status to failed on failure', () => {
151
+ const doc = {
152
+ executionId: 'exec-1',
153
+ correlationId: 'c1',
154
+ handlerId: 'handler-1',
155
+ triggerEvent,
156
+ items: [{ key: 'a', phase: 'prepare', dispatched: true, completed: false }],
157
+ phases: ['prepare'],
158
+ currentPhaseIndex: 0,
159
+ status: 'active',
160
+ failedItems: [{ key: 'a', error: { message: 'Failed' } }],
161
+ };
162
+ const event = {
163
+ type: 'PhasedExecutionCompleted',
164
+ data: { executionId: 'exec-1', success: false, results: [] },
165
+ };
166
+ const result = evolve(doc, event);
167
+ expect(result.status).toBe('failed');
168
+ });
169
+ });
170
+ });
171
+ //# sourceMappingURL=phased-execution-projection.specs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"phased-execution-projection.specs.js","sourceRoot":"","sources":["../../../src/projections/phased-execution-projection.specs.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAE9C,OAAO,EAAE,MAAM,EAAE,MAAM,+BAA+B,CAAC;AAEvD,QAAQ,CAAC,2BAA2B,EAAE,GAAG,EAAE;IACzC,MAAM,YAAY,GAAU,EAAE,IAAI,EAAE,WAAW,EAAE,aAAa,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE,KAAK,EAAE,CAAC,GAAG,EAAE,GAAG,CAAC,EAAE,EAAE,CAAC;IAEpG,QAAQ,CAAC,wBAAwB,EAAE,GAAG,EAAE;QACtC,EAAE,CAAC,sDAAsD,EAA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AC,IAAI,CAAC,QAAQ,CAAC,CAAC;QACvC,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=settled-instance-projection.specs.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"settled-instance-projection.specs.d.ts","sourceRoot":"","sources":["../../../src/projections/settled-instance-projection.specs.ts"],"names":[],"mappings":""}
@@ -0,0 +1,217 @@
1
+ import { describe, expect, it } from 'vitest';
2
+ import { evolve, } from './settled-instance-projection.js';
3
+ describe('SettledInstanceProjection', () => {
4
+ describe('evolve', () => {
5
+ describe('SettledInstanceCreated', () => {
6
+ it('creates document with initial command trackers', () => {
7
+ const event = {
8
+ type: 'SettledInstanceCreated',
9
+ data: {
10
+ templateId: 'template-CmdA,CmdB',
11
+ correlationId: 'c1',
12
+ commandTypes: ['CmdA', 'CmdB'],
13
+ },
14
+ };
15
+ const result = evolve(null, event);
16
+ expect(result).toEqual({
17
+ instanceId: 'template-CmdA,CmdB-c1',
18
+ templateId: 'template-CmdA,CmdB',
19
+ correlationId: 'c1',
20
+ commandTrackers: [
21
+ { commandType: 'CmdA', hasStarted: false, hasCompleted: false, events: [] },
22
+ { commandType: 'CmdB', hasStarted: false, hasCompleted: false, events: [] },
23
+ ],
24
+ status: 'active',
25
+ firedCount: 0,
26
+ });
27
+ });
28
+ });
29
+ describe('SettledCommandStarted', () => {
30
+ it('sets hasStarted true for the specified command', () => {
31
+ const existing = {
32
+ instanceId: 'template-CmdA,CmdB-c1',
33
+ templateId: 'template-CmdA,CmdB',
34
+ correlationId: 'c1',
35
+ commandTrackers: [
36
+ { commandType: 'CmdA', hasStarted: false, hasCompleted: false, events: [] },
37
+ { commandType: 'CmdB', hasStarted: false, hasCompleted: false, events: [] },
38
+ ],
39
+ status: 'active',
40
+ firedCount: 0,
41
+ };
42
+ const event = {
43
+ type: 'SettledCommandStarted',
44
+ data: {
45
+ templateId: 'template-CmdA,CmdB',
46
+ correlationId: 'c1',
47
+ commandType: 'CmdA',
48
+ },
49
+ };
50
+ const result = evolve(existing, event);
51
+ expect(result.commandTrackers[0]).toEqual({
52
+ commandType: 'CmdA',
53
+ hasStarted: true,
54
+ hasCompleted: false,
55
+ events: [],
56
+ });
57
+ expect(result.commandTrackers[1]).toEqual({
58
+ commandType: 'CmdB',
59
+ hasStarted: false,
60
+ hasCompleted: false,
61
+ events: [],
62
+ });
63
+ });
64
+ it('preserves hasCompleted when command restarts (supports concurrent commands)', () => {
65
+ const existing = {
66
+ instanceId: 'template-CmdA-c1',
67
+ templateId: 'template-CmdA',
68
+ correlationId: 'c1',
69
+ commandTrackers: [{ commandType: 'CmdA', hasStarted: true, hasCompleted: true, events: [] }],
70
+ status: 'active',
71
+ firedCount: 0,
72
+ };
73
+ const event = {
74
+ type: 'SettledCommandStarted',
75
+ data: {
76
+ templateId: 'template-CmdA',
77
+ correlationId: 'c1',
78
+ commandType: 'CmdA',
79
+ },
80
+ };
81
+ const result = evolve(existing, event);
82
+ expect(result.commandTrackers[0]).toEqual({
83
+ commandType: 'CmdA',
84
+ hasStarted: true,
85
+ hasCompleted: true,
86
+ events: [],
87
+ });
88
+ });
89
+ });
90
+ describe('SettledEventReceived', () => {
91
+ it('adds event to tracker and sets hasCompleted true', () => {
92
+ const existing = {
93
+ instanceId: 'template-CmdA-c1',
94
+ templateId: 'template-CmdA',
95
+ correlationId: 'c1',
96
+ commandTrackers: [{ commandType: 'CmdA', hasStarted: true, hasCompleted: false, events: [] }],
97
+ status: 'active',
98
+ firedCount: 0,
99
+ };
100
+ const domainEvent = { type: 'UserCreated', correlationId: 'c1', data: { userId: 'u1' } };
101
+ const event = {
102
+ type: 'SettledEventReceived',
103
+ data: {
104
+ templateId: 'template-CmdA',
105
+ correlationId: 'c1',
106
+ commandType: 'CmdA',
107
+ event: domainEvent,
108
+ },
109
+ };
110
+ const result = evolve(existing, event);
111
+ expect(result.commandTrackers[0]).toEqual({
112
+ commandType: 'CmdA',
113
+ hasStarted: true,
114
+ hasCompleted: true,
115
+ events: [domainEvent],
116
+ });
117
+ });
118
+ it('appends multiple events to tracker', () => {
119
+ const event1 = { type: 'Event1', correlationId: 'c1', data: {} };
120
+ const existing = {
121
+ instanceId: 'template-CmdA-c1',
122
+ templateId: 'template-CmdA',
123
+ correlationId: 'c1',
124
+ commandTrackers: [{ commandType: 'CmdA', hasStarted: true, hasCompleted: true, events: [event1] }],
125
+ status: 'active',
126
+ firedCount: 0,
127
+ };
128
+ const event2 = { type: 'Event2', correlationId: 'c1', data: {} };
129
+ const event = {
130
+ type: 'SettledEventReceived',
131
+ data: {
132
+ templateId: 'template-CmdA',
133
+ correlationId: 'c1',
134
+ commandType: 'CmdA',
135
+ event: event2,
136
+ },
137
+ };
138
+ const result = evolve(existing, event);
139
+ expect(result.commandTrackers[0].events).toEqual([event1, event2]);
140
+ });
141
+ });
142
+ describe('SettledHandlerFired', () => {
143
+ it('sets status to fired and increments firedCount', () => {
144
+ const existing = {
145
+ instanceId: 'template-CmdA-c1',
146
+ templateId: 'template-CmdA',
147
+ correlationId: 'c1',
148
+ commandTrackers: [{ commandType: 'CmdA', hasStarted: true, hasCompleted: true, events: [] }],
149
+ status: 'active',
150
+ firedCount: 0,
151
+ };
152
+ const event = {
153
+ type: 'SettledHandlerFired',
154
+ data: {
155
+ templateId: 'template-CmdA',
156
+ correlationId: 'c1',
157
+ persist: false,
158
+ },
159
+ };
160
+ const result = evolve(existing, event);
161
+ expect(result.status).toBe('fired');
162
+ expect(result.firedCount).toBe(1);
163
+ });
164
+ });
165
+ describe('SettledInstanceReset', () => {
166
+ it('clears trackers and sets status back to active', () => {
167
+ const domainEvent = { type: 'Event1', correlationId: 'c1', data: {} };
168
+ const existing = {
169
+ instanceId: 'template-CmdA,CmdB-c1',
170
+ templateId: 'template-CmdA,CmdB',
171
+ correlationId: 'c1',
172
+ commandTrackers: [
173
+ { commandType: 'CmdA', hasStarted: true, hasCompleted: true, events: [domainEvent] },
174
+ { commandType: 'CmdB', hasStarted: true, hasCompleted: true, events: [domainEvent] },
175
+ ],
176
+ status: 'fired',
177
+ firedCount: 1,
178
+ };
179
+ const event = {
180
+ type: 'SettledInstanceReset',
181
+ data: {
182
+ templateId: 'template-CmdA,CmdB',
183
+ correlationId: 'c1',
184
+ },
185
+ };
186
+ const result = evolve(existing, event);
187
+ expect(result.status).toBe('active');
188
+ expect(result.commandTrackers).toEqual([
189
+ { commandType: 'CmdA', hasStarted: true, hasCompleted: false, events: [] },
190
+ { commandType: 'CmdB', hasStarted: true, hasCompleted: false, events: [] },
191
+ ]);
192
+ });
193
+ });
194
+ describe('SettledInstanceCleaned', () => {
195
+ it('sets status to cleaned', () => {
196
+ const existing = {
197
+ instanceId: 'template-CmdA-c1',
198
+ templateId: 'template-CmdA',
199
+ correlationId: 'c1',
200
+ commandTrackers: [{ commandType: 'CmdA', hasStarted: true, hasCompleted: true, events: [] }],
201
+ status: 'fired',
202
+ firedCount: 1,
203
+ };
204
+ const event = {
205
+ type: 'SettledInstanceCleaned',
206
+ data: {
207
+ templateId: 'template-CmdA',
208
+ correlationId: 'c1',
209
+ },
210
+ };
211
+ const result = evolve(existing, event);
212
+ expect(result.status).toBe('cleaned');
213
+ });
214
+ });
215
+ });
216
+ });
217
+ //# sourceMappingURL=settled-instance-projection.specs.js.map