@xtr-dev/payload-automation 0.0.38 → 0.0.39
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/README.md +6 -1
- package/dist/collections/Workflow.js +2 -4
- package/dist/collections/Workflow.js.map +1 -1
- package/dist/components/WorkflowBuilder/StepConfigurationForm.js +316 -0
- package/dist/components/WorkflowBuilder/StepConfigurationForm.js.map +1 -0
- package/dist/components/WorkflowBuilder/WorkflowBuilder.js +211 -0
- package/dist/components/WorkflowBuilder/WorkflowBuilder.js.map +1 -0
- package/dist/components/WorkflowBuilder/WorkflowToolbar.js +107 -0
- package/dist/components/WorkflowBuilder/WorkflowToolbar.js.map +1 -0
- package/dist/components/WorkflowBuilder/index.js +6 -0
- package/dist/components/WorkflowBuilder/index.js.map +1 -0
- package/dist/components/WorkflowBuilder/nodes/StepNode.js +139 -0
- package/dist/components/WorkflowBuilder/nodes/StepNode.js.map +1 -0
- package/dist/core/workflow-executor.js +150 -116
- package/dist/core/workflow-executor.js.map +1 -1
- package/dist/fields/WorkflowBuilderField.js +119 -0
- package/dist/fields/WorkflowBuilderField.js.map +1 -0
- package/dist/plugin/collection-hook.js +34 -0
- package/dist/plugin/collection-hook.js.map +1 -1
- package/package.json +4 -3
- package/dist/collections/Workflow.d.ts +0 -3
- package/dist/collections/WorkflowRuns.d.ts +0 -2
- package/dist/components/ErrorDisplay.d.ts +0 -9
- package/dist/components/StatusCell.d.ts +0 -6
- package/dist/core/trigger-custom-workflow.d.ts +0 -52
- package/dist/core/workflow-executor.d.ts +0 -90
- package/dist/exports/client.d.ts +0 -2
- package/dist/exports/fields.d.ts +0 -1
- package/dist/exports/rsc.d.ts +0 -1
- package/dist/exports/server.d.ts +0 -5
- package/dist/exports/views.d.ts +0 -1
- package/dist/fields/parameter.d.ts +0 -4
- package/dist/index.d.ts +0 -2
- package/dist/plugin/collection-hook.d.ts +0 -1
- package/dist/plugin/config-types.d.ts +0 -18
- package/dist/plugin/global-hook.d.ts +0 -1
- package/dist/plugin/index.d.ts +0 -4
- package/dist/plugin/logger.d.ts +0 -20
- package/dist/steps/create-document-handler.d.ts +0 -2
- package/dist/steps/create-document.d.ts +0 -46
- package/dist/steps/delete-document-handler.d.ts +0 -2
- package/dist/steps/delete-document.d.ts +0 -39
- package/dist/steps/http-request-handler.d.ts +0 -2
- package/dist/steps/http-request.d.ts +0 -155
- package/dist/steps/index.d.ts +0 -12
- package/dist/steps/read-document-handler.d.ts +0 -2
- package/dist/steps/read-document.d.ts +0 -46
- package/dist/steps/send-email-handler.d.ts +0 -2
- package/dist/steps/send-email.d.ts +0 -44
- package/dist/steps/update-document-handler.d.ts +0 -2
- package/dist/steps/update-document.d.ts +0 -46
- package/dist/test/basic.test.js +0 -14
- package/dist/test/basic.test.js.map +0 -1
- package/dist/test/create-document-step.test.js +0 -378
- package/dist/test/create-document-step.test.js.map +0 -1
- package/dist/test/http-request-step.test.js +0 -361
- package/dist/test/http-request-step.test.js.map +0 -1
- package/dist/test/workflow-executor.test.js +0 -530
- package/dist/test/workflow-executor.test.js.map +0 -1
- package/dist/triggers/collection-trigger.d.ts +0 -2
- package/dist/triggers/global-trigger.d.ts +0 -2
- package/dist/triggers/index.d.ts +0 -2
- package/dist/triggers/types.d.ts +0 -5
- package/dist/types/index.d.ts +0 -31
|
@@ -1,530 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect, beforeEach, vi } from 'vitest';
|
|
2
|
-
import { WorkflowExecutor } from '../core/workflow-executor.js';
|
|
3
|
-
describe('WorkflowExecutor', ()=>{
|
|
4
|
-
let mockPayload;
|
|
5
|
-
let mockLogger;
|
|
6
|
-
let executor;
|
|
7
|
-
beforeEach(()=>{
|
|
8
|
-
mockLogger = {
|
|
9
|
-
info: vi.fn(),
|
|
10
|
-
debug: vi.fn(),
|
|
11
|
-
warn: vi.fn(),
|
|
12
|
-
error: vi.fn()
|
|
13
|
-
};
|
|
14
|
-
mockPayload = {
|
|
15
|
-
jobs: {
|
|
16
|
-
queue: vi.fn().mockResolvedValue({
|
|
17
|
-
id: 'job-123'
|
|
18
|
-
}),
|
|
19
|
-
run: vi.fn().mockResolvedValue(undefined)
|
|
20
|
-
},
|
|
21
|
-
create: vi.fn(),
|
|
22
|
-
update: vi.fn(),
|
|
23
|
-
find: vi.fn()
|
|
24
|
-
};
|
|
25
|
-
executor = new WorkflowExecutor(mockPayload, mockLogger);
|
|
26
|
-
});
|
|
27
|
-
describe('resolveJSONPathValue', ()=>{
|
|
28
|
-
it('should resolve simple JSONPath expressions', ()=>{
|
|
29
|
-
const context = {
|
|
30
|
-
trigger: {
|
|
31
|
-
doc: {
|
|
32
|
-
id: 'test-id',
|
|
33
|
-
title: 'Test Title'
|
|
34
|
-
}
|
|
35
|
-
},
|
|
36
|
-
steps: {}
|
|
37
|
-
};
|
|
38
|
-
const result = executor.resolveJSONPathValue('$.trigger.doc.id', context);
|
|
39
|
-
expect(result).toBe('test-id');
|
|
40
|
-
});
|
|
41
|
-
it('should resolve nested JSONPath expressions', ()=>{
|
|
42
|
-
const context = {
|
|
43
|
-
trigger: {
|
|
44
|
-
doc: {
|
|
45
|
-
id: 'test-id',
|
|
46
|
-
nested: {
|
|
47
|
-
value: 'nested-value'
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
},
|
|
51
|
-
steps: {}
|
|
52
|
-
};
|
|
53
|
-
const result = executor.resolveJSONPathValue('$.trigger.doc.nested.value', context);
|
|
54
|
-
expect(result).toBe('nested-value');
|
|
55
|
-
});
|
|
56
|
-
it('should return original value for non-JSONPath strings', ()=>{
|
|
57
|
-
const context = {
|
|
58
|
-
trigger: {},
|
|
59
|
-
steps: {}
|
|
60
|
-
};
|
|
61
|
-
const result = executor.resolveJSONPathValue('plain-string', context);
|
|
62
|
-
expect(result).toBe('plain-string');
|
|
63
|
-
});
|
|
64
|
-
it('should handle missing JSONPath gracefully', ()=>{
|
|
65
|
-
const context = {
|
|
66
|
-
trigger: {},
|
|
67
|
-
steps: {}
|
|
68
|
-
};
|
|
69
|
-
const result = executor.resolveJSONPathValue('$.trigger.missing.field', context);
|
|
70
|
-
expect(result).toBe('$.trigger.missing.field'); // Should return original if resolution fails
|
|
71
|
-
});
|
|
72
|
-
});
|
|
73
|
-
describe('resolveStepInput', ()=>{
|
|
74
|
-
it('should resolve all JSONPath expressions in step config', ()=>{
|
|
75
|
-
const config = {
|
|
76
|
-
url: '$.trigger.data.url',
|
|
77
|
-
message: 'Static message',
|
|
78
|
-
data: {
|
|
79
|
-
id: '$.trigger.doc.id',
|
|
80
|
-
title: '$.trigger.doc.title'
|
|
81
|
-
}
|
|
82
|
-
};
|
|
83
|
-
const context = {
|
|
84
|
-
trigger: {
|
|
85
|
-
doc: {
|
|
86
|
-
id: 'doc-123',
|
|
87
|
-
title: 'Doc Title'
|
|
88
|
-
},
|
|
89
|
-
data: {
|
|
90
|
-
url: 'https://example.com/webhook'
|
|
91
|
-
}
|
|
92
|
-
},
|
|
93
|
-
steps: {}
|
|
94
|
-
};
|
|
95
|
-
const result = executor.resolveStepInput(config, context);
|
|
96
|
-
expect(result).toEqual({
|
|
97
|
-
url: 'https://example.com/webhook',
|
|
98
|
-
message: 'Static message',
|
|
99
|
-
data: {
|
|
100
|
-
id: 'doc-123',
|
|
101
|
-
title: 'Doc Title'
|
|
102
|
-
}
|
|
103
|
-
});
|
|
104
|
-
});
|
|
105
|
-
it('should handle arrays with JSONPath expressions', ()=>{
|
|
106
|
-
const config = {
|
|
107
|
-
items: [
|
|
108
|
-
'$.trigger.doc.id',
|
|
109
|
-
'static-value',
|
|
110
|
-
'$.trigger.doc.title'
|
|
111
|
-
]
|
|
112
|
-
};
|
|
113
|
-
const context = {
|
|
114
|
-
trigger: {
|
|
115
|
-
doc: {
|
|
116
|
-
id: 'doc-123',
|
|
117
|
-
title: 'Doc Title'
|
|
118
|
-
}
|
|
119
|
-
},
|
|
120
|
-
steps: {}
|
|
121
|
-
};
|
|
122
|
-
const result = executor.resolveStepInput(config, context);
|
|
123
|
-
expect(result).toEqual({
|
|
124
|
-
items: [
|
|
125
|
-
'doc-123',
|
|
126
|
-
'static-value',
|
|
127
|
-
'Doc Title'
|
|
128
|
-
]
|
|
129
|
-
});
|
|
130
|
-
});
|
|
131
|
-
});
|
|
132
|
-
describe('resolveExecutionOrder', ()=>{
|
|
133
|
-
it('should handle steps without dependencies', ()=>{
|
|
134
|
-
const steps = [
|
|
135
|
-
{
|
|
136
|
-
name: 'step1',
|
|
137
|
-
step: 'http-request'
|
|
138
|
-
},
|
|
139
|
-
{
|
|
140
|
-
name: 'step2',
|
|
141
|
-
step: 'create-document'
|
|
142
|
-
},
|
|
143
|
-
{
|
|
144
|
-
name: 'step3',
|
|
145
|
-
step: 'http-request'
|
|
146
|
-
}
|
|
147
|
-
];
|
|
148
|
-
const result = executor.resolveExecutionOrder(steps);
|
|
149
|
-
expect(result).toHaveLength(1); // All in one batch
|
|
150
|
-
expect(result[0]).toHaveLength(3); // All steps in first batch
|
|
151
|
-
});
|
|
152
|
-
it('should handle steps with dependencies', ()=>{
|
|
153
|
-
const steps = [
|
|
154
|
-
{
|
|
155
|
-
name: 'step1',
|
|
156
|
-
step: 'http-request'
|
|
157
|
-
},
|
|
158
|
-
{
|
|
159
|
-
name: 'step2',
|
|
160
|
-
step: 'create-document',
|
|
161
|
-
dependencies: [
|
|
162
|
-
'step1'
|
|
163
|
-
]
|
|
164
|
-
},
|
|
165
|
-
{
|
|
166
|
-
name: 'step3',
|
|
167
|
-
step: 'http-request',
|
|
168
|
-
dependencies: [
|
|
169
|
-
'step2'
|
|
170
|
-
]
|
|
171
|
-
}
|
|
172
|
-
];
|
|
173
|
-
const result = executor.resolveExecutionOrder(steps);
|
|
174
|
-
expect(result).toHaveLength(3); // Three batches
|
|
175
|
-
expect(result[0]).toHaveLength(1); // step1 first
|
|
176
|
-
expect(result[1]).toHaveLength(1); // step2 second
|
|
177
|
-
expect(result[2]).toHaveLength(1); // step3 third
|
|
178
|
-
});
|
|
179
|
-
it('should handle parallel execution with partial dependencies', ()=>{
|
|
180
|
-
const steps = [
|
|
181
|
-
{
|
|
182
|
-
name: 'step1',
|
|
183
|
-
step: 'http-request'
|
|
184
|
-
},
|
|
185
|
-
{
|
|
186
|
-
name: 'step2',
|
|
187
|
-
step: 'create-document'
|
|
188
|
-
},
|
|
189
|
-
{
|
|
190
|
-
name: 'step3',
|
|
191
|
-
step: 'http-request',
|
|
192
|
-
dependencies: [
|
|
193
|
-
'step1'
|
|
194
|
-
]
|
|
195
|
-
},
|
|
196
|
-
{
|
|
197
|
-
name: 'step4',
|
|
198
|
-
step: 'create-document',
|
|
199
|
-
dependencies: [
|
|
200
|
-
'step1'
|
|
201
|
-
]
|
|
202
|
-
}
|
|
203
|
-
];
|
|
204
|
-
const result = executor.resolveExecutionOrder(steps);
|
|
205
|
-
expect(result).toHaveLength(2); // Two batches
|
|
206
|
-
expect(result[0]).toHaveLength(2); // step1 and step2 in parallel
|
|
207
|
-
expect(result[1]).toHaveLength(2); // step3 and step4 in parallel
|
|
208
|
-
});
|
|
209
|
-
it('should detect circular dependencies', ()=>{
|
|
210
|
-
const steps = [
|
|
211
|
-
{
|
|
212
|
-
name: 'step1',
|
|
213
|
-
step: 'http-request',
|
|
214
|
-
dependencies: [
|
|
215
|
-
'step2'
|
|
216
|
-
]
|
|
217
|
-
},
|
|
218
|
-
{
|
|
219
|
-
name: 'step2',
|
|
220
|
-
step: 'create-document',
|
|
221
|
-
dependencies: [
|
|
222
|
-
'step1'
|
|
223
|
-
]
|
|
224
|
-
}
|
|
225
|
-
];
|
|
226
|
-
expect(()=>{
|
|
227
|
-
executor.resolveExecutionOrder(steps);
|
|
228
|
-
}).toThrow('Circular dependency detected');
|
|
229
|
-
});
|
|
230
|
-
});
|
|
231
|
-
describe('evaluateCondition', ()=>{
|
|
232
|
-
it('should evaluate simple equality conditions', ()=>{
|
|
233
|
-
const context = {
|
|
234
|
-
trigger: {
|
|
235
|
-
doc: {
|
|
236
|
-
status: 'published'
|
|
237
|
-
}
|
|
238
|
-
},
|
|
239
|
-
steps: {}
|
|
240
|
-
};
|
|
241
|
-
const result = executor.evaluateCondition('$.trigger.doc.status == "published"', context);
|
|
242
|
-
expect(result).toBe(true);
|
|
243
|
-
});
|
|
244
|
-
it('should evaluate inequality conditions', ()=>{
|
|
245
|
-
const context = {
|
|
246
|
-
trigger: {
|
|
247
|
-
doc: {
|
|
248
|
-
count: 5
|
|
249
|
-
}
|
|
250
|
-
},
|
|
251
|
-
steps: {}
|
|
252
|
-
};
|
|
253
|
-
const result = executor.evaluateCondition('$.trigger.doc.count > 3', context);
|
|
254
|
-
expect(result).toBe(true);
|
|
255
|
-
});
|
|
256
|
-
it('should return false for invalid conditions', ()=>{
|
|
257
|
-
const context = {
|
|
258
|
-
trigger: {},
|
|
259
|
-
steps: {}
|
|
260
|
-
};
|
|
261
|
-
const result = executor.evaluateCondition('invalid condition syntax', context);
|
|
262
|
-
expect(result).toBe(false);
|
|
263
|
-
});
|
|
264
|
-
it('should handle missing context gracefully', ()=>{
|
|
265
|
-
const context = {
|
|
266
|
-
trigger: {},
|
|
267
|
-
steps: {}
|
|
268
|
-
};
|
|
269
|
-
const result = executor.evaluateCondition('$.trigger.doc.status == "published"', context);
|
|
270
|
-
expect(result).toBe(false); // Missing values should fail condition
|
|
271
|
-
});
|
|
272
|
-
});
|
|
273
|
-
describe('safeSerialize', ()=>{
|
|
274
|
-
it('should serialize simple objects', ()=>{
|
|
275
|
-
const obj = {
|
|
276
|
-
name: 'test',
|
|
277
|
-
value: 123
|
|
278
|
-
};
|
|
279
|
-
const result = executor.safeSerialize(obj);
|
|
280
|
-
expect(result).toBe('{"name":"test","value":123}');
|
|
281
|
-
});
|
|
282
|
-
it('should handle circular references', ()=>{
|
|
283
|
-
const obj = {
|
|
284
|
-
name: 'test'
|
|
285
|
-
};
|
|
286
|
-
obj.self = obj; // Create circular reference
|
|
287
|
-
const result = executor.safeSerialize(obj);
|
|
288
|
-
expect(result).toContain('"name":"test"');
|
|
289
|
-
expect(result).toContain('"self":"[Circular]"');
|
|
290
|
-
});
|
|
291
|
-
it('should handle undefined and null values', ()=>{
|
|
292
|
-
const obj = {
|
|
293
|
-
defined: 'value',
|
|
294
|
-
undefined: undefined,
|
|
295
|
-
null: null
|
|
296
|
-
};
|
|
297
|
-
const result = executor.safeSerialize(obj);
|
|
298
|
-
const parsed = JSON.parse(result);
|
|
299
|
-
expect(parsed.defined).toBe('value');
|
|
300
|
-
expect(parsed.null).toBe(null);
|
|
301
|
-
expect(parsed).not.toHaveProperty('undefined'); // undefined props are omitted
|
|
302
|
-
});
|
|
303
|
-
});
|
|
304
|
-
describe('executeWorkflow', ()=>{
|
|
305
|
-
it('should execute workflow with single step', async ()=>{
|
|
306
|
-
const workflow = {
|
|
307
|
-
id: 'test-workflow',
|
|
308
|
-
steps: [
|
|
309
|
-
{
|
|
310
|
-
name: 'test-step',
|
|
311
|
-
step: 'http-request-step',
|
|
312
|
-
url: 'https://example.com',
|
|
313
|
-
method: 'GET'
|
|
314
|
-
}
|
|
315
|
-
]
|
|
316
|
-
};
|
|
317
|
-
const context = {
|
|
318
|
-
trigger: {
|
|
319
|
-
doc: {
|
|
320
|
-
id: 'test-doc'
|
|
321
|
-
}
|
|
322
|
-
},
|
|
323
|
-
steps: {}
|
|
324
|
-
};
|
|
325
|
-
// Mock step task
|
|
326
|
-
const mockStepTask = {
|
|
327
|
-
taskSlug: 'http-request-step',
|
|
328
|
-
handler: vi.fn().mockResolvedValue({
|
|
329
|
-
output: {
|
|
330
|
-
status: 200,
|
|
331
|
-
body: 'success'
|
|
332
|
-
},
|
|
333
|
-
state: 'succeeded'
|
|
334
|
-
})
|
|
335
|
-
};
|
|
336
|
-
// Mock the step tasks registry
|
|
337
|
-
const originalStepTasks = executor.stepTasks;
|
|
338
|
-
executor.stepTasks = [
|
|
339
|
-
mockStepTask
|
|
340
|
-
];
|
|
341
|
-
const result = await executor.executeWorkflow(workflow, context);
|
|
342
|
-
expect(result.status).toBe('completed');
|
|
343
|
-
expect(result.context.steps['test-step']).toBeDefined();
|
|
344
|
-
expect(result.context.steps['test-step'].state).toBe('succeeded');
|
|
345
|
-
expect(mockStepTask.handler).toHaveBeenCalledOnce();
|
|
346
|
-
executor.stepTasks = originalStepTasks;
|
|
347
|
-
});
|
|
348
|
-
it('should handle step execution failures', async ()=>{
|
|
349
|
-
const workflow = {
|
|
350
|
-
id: 'test-workflow',
|
|
351
|
-
steps: [
|
|
352
|
-
{
|
|
353
|
-
name: 'failing-step',
|
|
354
|
-
step: 'http-request-step',
|
|
355
|
-
url: 'https://invalid-url',
|
|
356
|
-
method: 'GET'
|
|
357
|
-
}
|
|
358
|
-
]
|
|
359
|
-
};
|
|
360
|
-
const context = {
|
|
361
|
-
trigger: {
|
|
362
|
-
doc: {
|
|
363
|
-
id: 'test-doc'
|
|
364
|
-
}
|
|
365
|
-
},
|
|
366
|
-
steps: {}
|
|
367
|
-
};
|
|
368
|
-
// Mock failing step task
|
|
369
|
-
const mockStepTask = {
|
|
370
|
-
taskSlug: 'http-request-step',
|
|
371
|
-
handler: vi.fn().mockRejectedValue(new Error('Network error'))
|
|
372
|
-
};
|
|
373
|
-
const originalStepTasks = executor.stepTasks;
|
|
374
|
-
executor.stepTasks = [
|
|
375
|
-
mockStepTask
|
|
376
|
-
];
|
|
377
|
-
const result = await executor.executeWorkflow(workflow, context);
|
|
378
|
-
expect(result.status).toBe('failed');
|
|
379
|
-
expect(result.error).toContain('Network error');
|
|
380
|
-
expect(result.context.steps['failing-step']).toBeDefined();
|
|
381
|
-
expect(result.context.steps['failing-step'].state).toBe('failed');
|
|
382
|
-
executor.stepTasks = originalStepTasks;
|
|
383
|
-
});
|
|
384
|
-
it('should execute steps with dependencies in correct order', async ()=>{
|
|
385
|
-
const workflow = {
|
|
386
|
-
id: 'test-workflow',
|
|
387
|
-
steps: [
|
|
388
|
-
{
|
|
389
|
-
name: 'step1',
|
|
390
|
-
step: 'http-request-step',
|
|
391
|
-
url: 'https://example.com/1',
|
|
392
|
-
method: 'GET'
|
|
393
|
-
},
|
|
394
|
-
{
|
|
395
|
-
name: 'step2',
|
|
396
|
-
step: 'http-request-step',
|
|
397
|
-
url: 'https://example.com/2',
|
|
398
|
-
method: 'GET',
|
|
399
|
-
dependencies: [
|
|
400
|
-
'step1'
|
|
401
|
-
]
|
|
402
|
-
},
|
|
403
|
-
{
|
|
404
|
-
name: 'step3',
|
|
405
|
-
step: 'http-request-step',
|
|
406
|
-
url: 'https://example.com/3',
|
|
407
|
-
method: 'GET',
|
|
408
|
-
dependencies: [
|
|
409
|
-
'step1'
|
|
410
|
-
]
|
|
411
|
-
}
|
|
412
|
-
]
|
|
413
|
-
};
|
|
414
|
-
const context = {
|
|
415
|
-
trigger: {
|
|
416
|
-
doc: {
|
|
417
|
-
id: 'test-doc'
|
|
418
|
-
}
|
|
419
|
-
},
|
|
420
|
-
steps: {}
|
|
421
|
-
};
|
|
422
|
-
const executionOrder = [];
|
|
423
|
-
const mockStepTask = {
|
|
424
|
-
taskSlug: 'http-request-step',
|
|
425
|
-
handler: vi.fn().mockImplementation(async ({ input })=>{
|
|
426
|
-
executionOrder.push(input.stepName);
|
|
427
|
-
return {
|
|
428
|
-
output: {
|
|
429
|
-
status: 200,
|
|
430
|
-
body: 'success'
|
|
431
|
-
},
|
|
432
|
-
state: 'succeeded'
|
|
433
|
-
};
|
|
434
|
-
})
|
|
435
|
-
};
|
|
436
|
-
const originalStepTasks = executor.stepTasks;
|
|
437
|
-
executor.stepTasks = [
|
|
438
|
-
mockStepTask
|
|
439
|
-
];
|
|
440
|
-
const result = await executor.executeWorkflow(workflow, context);
|
|
441
|
-
expect(result.status).toBe('completed');
|
|
442
|
-
expect(executionOrder[0]).toBe('step1'); // First step executed first
|
|
443
|
-
expect(executionOrder.slice(1)).toContain('step2'); // Dependent steps after
|
|
444
|
-
expect(executionOrder.slice(1)).toContain('step3');
|
|
445
|
-
executor.stepTasks = originalStepTasks;
|
|
446
|
-
});
|
|
447
|
-
});
|
|
448
|
-
describe('findStepTask', ()=>{
|
|
449
|
-
it('should find registered step task by slug', ()=>{
|
|
450
|
-
const mockStepTask = {
|
|
451
|
-
taskSlug: 'test-step',
|
|
452
|
-
handler: vi.fn()
|
|
453
|
-
};
|
|
454
|
-
const originalStepTasks = executor.stepTasks;
|
|
455
|
-
executor.stepTasks = [
|
|
456
|
-
mockStepTask
|
|
457
|
-
];
|
|
458
|
-
const result = executor.findStepTask('test-step');
|
|
459
|
-
expect(result).toBe(mockStepTask);
|
|
460
|
-
executor.stepTasks = originalStepTasks;
|
|
461
|
-
});
|
|
462
|
-
it('should return undefined for unknown step type', ()=>{
|
|
463
|
-
const result = executor.findStepTask('unknown-step');
|
|
464
|
-
expect(result).toBeUndefined();
|
|
465
|
-
});
|
|
466
|
-
});
|
|
467
|
-
describe('validateStepConfiguration', ()=>{
|
|
468
|
-
it('should validate step with required fields', ()=>{
|
|
469
|
-
const step = {
|
|
470
|
-
name: 'valid-step',
|
|
471
|
-
step: 'http-request-step',
|
|
472
|
-
url: 'https://example.com',
|
|
473
|
-
method: 'GET'
|
|
474
|
-
};
|
|
475
|
-
expect(()=>{
|
|
476
|
-
executor.validateStepConfiguration(step);
|
|
477
|
-
}).not.toThrow();
|
|
478
|
-
});
|
|
479
|
-
it('should throw error for step without name', ()=>{
|
|
480
|
-
const step = {
|
|
481
|
-
step: 'http-request-step',
|
|
482
|
-
url: 'https://example.com',
|
|
483
|
-
method: 'GET'
|
|
484
|
-
};
|
|
485
|
-
expect(()=>{
|
|
486
|
-
executor.validateStepConfiguration(step);
|
|
487
|
-
}).toThrow('Step name is required');
|
|
488
|
-
});
|
|
489
|
-
it('should throw error for step without type', ()=>{
|
|
490
|
-
const step = {
|
|
491
|
-
name: 'test-step',
|
|
492
|
-
url: 'https://example.com',
|
|
493
|
-
method: 'GET'
|
|
494
|
-
};
|
|
495
|
-
expect(()=>{
|
|
496
|
-
executor.validateStepConfiguration(step);
|
|
497
|
-
}).toThrow('Step type is required');
|
|
498
|
-
});
|
|
499
|
-
});
|
|
500
|
-
describe('createExecutionContext', ()=>{
|
|
501
|
-
it('should create context with trigger data', ()=>{
|
|
502
|
-
const triggerContext = {
|
|
503
|
-
operation: 'create',
|
|
504
|
-
doc: {
|
|
505
|
-
id: 'test-id',
|
|
506
|
-
title: 'Test Doc'
|
|
507
|
-
},
|
|
508
|
-
collection: 'posts'
|
|
509
|
-
};
|
|
510
|
-
const result = executor.createExecutionContext(triggerContext);
|
|
511
|
-
expect(result.trigger).toEqual(triggerContext);
|
|
512
|
-
expect(result.steps).toEqual({});
|
|
513
|
-
expect(result.metadata).toBeDefined();
|
|
514
|
-
expect(result.metadata.startedAt).toBeDefined();
|
|
515
|
-
});
|
|
516
|
-
it('should include metadata in context', ()=>{
|
|
517
|
-
const triggerContext = {
|
|
518
|
-
doc: {
|
|
519
|
-
id: 'test'
|
|
520
|
-
}
|
|
521
|
-
};
|
|
522
|
-
const result = executor.createExecutionContext(triggerContext);
|
|
523
|
-
expect(result.metadata).toHaveProperty('startedAt');
|
|
524
|
-
expect(result.metadata).toHaveProperty('executionId');
|
|
525
|
-
expect(typeof result.metadata.executionId).toBe('string');
|
|
526
|
-
});
|
|
527
|
-
});
|
|
528
|
-
});
|
|
529
|
-
|
|
530
|
-
//# sourceMappingURL=workflow-executor.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/test/workflow-executor.test.ts"],"sourcesContent":["import { describe, it, expect, beforeEach, vi } from 'vitest'\nimport { WorkflowExecutor } from '../core/workflow-executor.js'\nimport type { Payload } from 'payload'\n\ndescribe('WorkflowExecutor', () => {\n let mockPayload: Payload\n let mockLogger: any\n let executor: WorkflowExecutor\n\n beforeEach(() => {\n mockLogger = {\n info: vi.fn(),\n debug: vi.fn(),\n warn: vi.fn(),\n error: vi.fn()\n }\n\n mockPayload = {\n jobs: {\n queue: vi.fn().mockResolvedValue({ id: 'job-123' }),\n run: vi.fn().mockResolvedValue(undefined)\n },\n create: vi.fn(),\n update: vi.fn(),\n find: vi.fn()\n } as any\n\n executor = new WorkflowExecutor(mockPayload, mockLogger)\n })\n\n describe('resolveJSONPathValue', () => {\n it('should resolve simple JSONPath expressions', () => {\n const context = {\n trigger: {\n doc: { id: 'test-id', title: 'Test Title' }\n },\n steps: {}\n }\n\n const result = (executor as any).resolveJSONPathValue('$.trigger.doc.id', context)\n expect(result).toBe('test-id')\n })\n\n it('should resolve nested JSONPath expressions', () => {\n const context = {\n trigger: {\n doc: { \n id: 'test-id',\n nested: { value: 'nested-value' }\n }\n },\n steps: {}\n }\n\n const result = (executor as any).resolveJSONPathValue('$.trigger.doc.nested.value', context)\n expect(result).toBe('nested-value')\n })\n\n it('should return original value for non-JSONPath strings', () => {\n const context = { trigger: {}, steps: {} }\n const result = (executor as any).resolveJSONPathValue('plain-string', context)\n expect(result).toBe('plain-string')\n })\n\n it('should handle missing JSONPath gracefully', () => {\n const context = { trigger: {}, steps: {} }\n const result = (executor as any).resolveJSONPathValue('$.trigger.missing.field', context)\n expect(result).toBe('$.trigger.missing.field') // Should return original if resolution fails\n })\n })\n\n describe('resolveStepInput', () => {\n it('should resolve all JSONPath expressions in step config', () => {\n const config = {\n url: '$.trigger.data.url',\n message: 'Static message',\n data: {\n id: '$.trigger.doc.id',\n title: '$.trigger.doc.title'\n }\n }\n\n const context = {\n trigger: {\n doc: { id: 'doc-123', title: 'Doc Title' },\n data: { url: 'https://example.com/webhook' }\n },\n steps: {}\n }\n\n const result = (executor as any).resolveStepInput(config, context)\n \n expect(result).toEqual({\n url: 'https://example.com/webhook',\n message: 'Static message',\n data: {\n id: 'doc-123',\n title: 'Doc Title'\n }\n })\n })\n\n it('should handle arrays with JSONPath expressions', () => {\n const config = {\n items: ['$.trigger.doc.id', 'static-value', '$.trigger.doc.title']\n }\n\n const context = {\n trigger: {\n doc: { id: 'doc-123', title: 'Doc Title' }\n },\n steps: {}\n }\n\n const result = (executor as any).resolveStepInput(config, context)\n \n expect(result).toEqual({\n items: ['doc-123', 'static-value', 'Doc Title']\n })\n })\n })\n\n describe('resolveExecutionOrder', () => {\n it('should handle steps without dependencies', () => {\n const steps = [\n { name: 'step1', step: 'http-request' },\n { name: 'step2', step: 'create-document' },\n { name: 'step3', step: 'http-request' }\n ]\n\n const result = (executor as any).resolveExecutionOrder(steps)\n \n expect(result).toHaveLength(1) // All in one batch\n expect(result[0]).toHaveLength(3) // All steps in first batch\n })\n\n it('should handle steps with dependencies', () => {\n const steps = [\n { name: 'step1', step: 'http-request' },\n { name: 'step2', step: 'create-document', dependencies: ['step1'] },\n { name: 'step3', step: 'http-request', dependencies: ['step2'] }\n ]\n\n const result = (executor as any).resolveExecutionOrder(steps)\n \n expect(result).toHaveLength(3) // Three batches\n expect(result[0]).toHaveLength(1) // step1 first\n expect(result[1]).toHaveLength(1) // step2 second\n expect(result[2]).toHaveLength(1) // step3 third\n })\n\n it('should handle parallel execution with partial dependencies', () => {\n const steps = [\n { name: 'step1', step: 'http-request' },\n { name: 'step2', step: 'create-document' },\n { name: 'step3', step: 'http-request', dependencies: ['step1'] },\n { name: 'step4', step: 'create-document', dependencies: ['step1'] }\n ]\n\n const result = (executor as any).resolveExecutionOrder(steps)\n \n expect(result).toHaveLength(2) // Two batches\n expect(result[0]).toHaveLength(2) // step1 and step2 in parallel\n expect(result[1]).toHaveLength(2) // step3 and step4 in parallel\n })\n\n it('should detect circular dependencies', () => {\n const steps = [\n { name: 'step1', step: 'http-request', dependencies: ['step2'] },\n { name: 'step2', step: 'create-document', dependencies: ['step1'] }\n ]\n\n expect(() => {\n (executor as any).resolveExecutionOrder(steps)\n }).toThrow('Circular dependency detected')\n })\n })\n\n describe('evaluateCondition', () => {\n it('should evaluate simple equality conditions', () => {\n const context = {\n trigger: {\n doc: { status: 'published' }\n },\n steps: {}\n }\n\n const result = (executor as any).evaluateCondition('$.trigger.doc.status == \"published\"', context)\n expect(result).toBe(true)\n })\n\n it('should evaluate inequality conditions', () => {\n const context = {\n trigger: {\n doc: { count: 5 }\n },\n steps: {}\n }\n\n const result = (executor as any).evaluateCondition('$.trigger.doc.count > 3', context)\n expect(result).toBe(true)\n })\n\n it('should return false for invalid conditions', () => {\n const context = { trigger: {}, steps: {} }\n const result = (executor as any).evaluateCondition('invalid condition syntax', context)\n expect(result).toBe(false)\n })\n\n it('should handle missing context gracefully', () => {\n const context = { trigger: {}, steps: {} }\n const result = (executor as any).evaluateCondition('$.trigger.doc.status == \"published\"', context)\n expect(result).toBe(false) // Missing values should fail condition\n })\n })\n\n describe('safeSerialize', () => {\n it('should serialize simple objects', () => {\n const obj = { name: 'test', value: 123 }\n const result = (executor as any).safeSerialize(obj)\n expect(result).toBe('{\"name\":\"test\",\"value\":123}')\n })\n\n it('should handle circular references', () => {\n const obj: any = { name: 'test' }\n obj.self = obj // Create circular reference\n\n const result = (executor as any).safeSerialize(obj)\n expect(result).toContain('\"name\":\"test\"')\n expect(result).toContain('\"self\":\"[Circular]\"')\n })\n\n it('should handle undefined and null values', () => {\n const obj = { \n defined: 'value',\n undefined: undefined,\n null: null\n }\n \n const result = (executor as any).safeSerialize(obj)\n const parsed = JSON.parse(result)\n expect(parsed.defined).toBe('value')\n expect(parsed.null).toBe(null)\n expect(parsed).not.toHaveProperty('undefined') // undefined props are omitted\n })\n })\n\n describe('executeWorkflow', () => {\n it('should execute workflow with single step', async () => {\n const workflow = {\n id: 'test-workflow',\n steps: [\n {\n name: 'test-step',\n step: 'http-request-step',\n url: 'https://example.com',\n method: 'GET'\n }\n ]\n }\n \n const context = {\n trigger: { doc: { id: 'test-doc' } },\n steps: {}\n }\n\n // Mock step task\n const mockStepTask = {\n taskSlug: 'http-request-step',\n handler: vi.fn().mockResolvedValue({\n output: { status: 200, body: 'success' },\n state: 'succeeded'\n })\n }\n\n // Mock the step tasks registry\n const originalStepTasks = (executor as any).stepTasks\n ;(executor as any).stepTasks = [mockStepTask]\n\n const result = await (executor as any).executeWorkflow(workflow, context)\n\n expect(result.status).toBe('completed')\n expect(result.context.steps['test-step']).toBeDefined()\n expect(result.context.steps['test-step'].state).toBe('succeeded')\n expect(mockStepTask.handler).toHaveBeenCalledOnce()\n\n // Restore original step tasks\n ;(executor as any).stepTasks = originalStepTasks\n })\n\n it('should handle step execution failures', async () => {\n const workflow = {\n id: 'test-workflow',\n steps: [\n {\n name: 'failing-step',\n step: 'http-request-step',\n url: 'https://invalid-url',\n method: 'GET'\n }\n ]\n }\n \n const context = {\n trigger: { doc: { id: 'test-doc' } },\n steps: {}\n }\n\n // Mock failing step task\n const mockStepTask = {\n taskSlug: 'http-request-step',\n handler: vi.fn().mockRejectedValue(new Error('Network error'))\n }\n\n const originalStepTasks = (executor as any).stepTasks\n ;(executor as any).stepTasks = [mockStepTask]\n\n const result = await (executor as any).executeWorkflow(workflow, context)\n\n expect(result.status).toBe('failed')\n expect(result.error).toContain('Network error')\n expect(result.context.steps['failing-step']).toBeDefined()\n expect(result.context.steps['failing-step'].state).toBe('failed')\n\n ;(executor as any).stepTasks = originalStepTasks\n })\n\n it('should execute steps with dependencies in correct order', async () => {\n const workflow = {\n id: 'test-workflow',\n steps: [\n {\n name: 'step1',\n step: 'http-request-step',\n url: 'https://example.com/1',\n method: 'GET'\n },\n {\n name: 'step2',\n step: 'http-request-step',\n url: 'https://example.com/2',\n method: 'GET',\n dependencies: ['step1']\n },\n {\n name: 'step3',\n step: 'http-request-step',\n url: 'https://example.com/3',\n method: 'GET',\n dependencies: ['step1']\n }\n ]\n }\n \n const context = {\n trigger: { doc: { id: 'test-doc' } },\n steps: {}\n }\n\n const executionOrder: string[] = []\n const mockStepTask = {\n taskSlug: 'http-request-step',\n handler: vi.fn().mockImplementation(async ({ input }) => {\n executionOrder.push(input.stepName)\n return {\n output: { status: 200, body: 'success' },\n state: 'succeeded'\n }\n })\n }\n\n const originalStepTasks = (executor as any).stepTasks\n ;(executor as any).stepTasks = [mockStepTask]\n\n const result = await (executor as any).executeWorkflow(workflow, context)\n\n expect(result.status).toBe('completed')\n expect(executionOrder[0]).toBe('step1') // First step executed first\n expect(executionOrder.slice(1)).toContain('step2') // Dependent steps after\n expect(executionOrder.slice(1)).toContain('step3')\n\n ;(executor as any).stepTasks = originalStepTasks\n })\n })\n\n describe('findStepTask', () => {\n it('should find registered step task by slug', () => {\n const mockStepTask = {\n taskSlug: 'test-step',\n handler: vi.fn()\n }\n\n const originalStepTasks = (executor as any).stepTasks\n ;(executor as any).stepTasks = [mockStepTask]\n\n const result = (executor as any).findStepTask('test-step')\n expect(result).toBe(mockStepTask)\n\n ;(executor as any).stepTasks = originalStepTasks\n })\n\n it('should return undefined for unknown step type', () => {\n const result = (executor as any).findStepTask('unknown-step')\n expect(result).toBeUndefined()\n })\n })\n\n describe('validateStepConfiguration', () => {\n it('should validate step with required fields', () => {\n const step = {\n name: 'valid-step',\n step: 'http-request-step',\n url: 'https://example.com',\n method: 'GET'\n }\n\n expect(() => {\n (executor as any).validateStepConfiguration(step)\n }).not.toThrow()\n })\n\n it('should throw error for step without name', () => {\n const step = {\n step: 'http-request-step',\n url: 'https://example.com',\n method: 'GET'\n }\n\n expect(() => {\n (executor as any).validateStepConfiguration(step)\n }).toThrow('Step name is required')\n })\n\n it('should throw error for step without type', () => {\n const step = {\n name: 'test-step',\n url: 'https://example.com',\n method: 'GET'\n }\n\n expect(() => {\n (executor as any).validateStepConfiguration(step)\n }).toThrow('Step type is required')\n })\n })\n\n describe('createExecutionContext', () => {\n it('should create context with trigger data', () => {\n const triggerContext = {\n operation: 'create',\n doc: { id: 'test-id', title: 'Test Doc' },\n collection: 'posts'\n }\n\n const result = (executor as any).createExecutionContext(triggerContext)\n\n expect(result.trigger).toEqual(triggerContext)\n expect(result.steps).toEqual({})\n expect(result.metadata).toBeDefined()\n expect(result.metadata.startedAt).toBeDefined()\n })\n\n it('should include metadata in context', () => {\n const triggerContext = { doc: { id: 'test' } }\n const result = (executor as any).createExecutionContext(triggerContext)\n\n expect(result.metadata).toHaveProperty('startedAt')\n expect(result.metadata).toHaveProperty('executionId')\n expect(typeof result.metadata.executionId).toBe('string')\n })\n })\n})"],"names":["describe","it","expect","beforeEach","vi","WorkflowExecutor","mockPayload","mockLogger","executor","info","fn","debug","warn","error","jobs","queue","mockResolvedValue","id","run","undefined","create","update","find","context","trigger","doc","title","steps","result","resolveJSONPathValue","toBe","nested","value","config","url","message","data","resolveStepInput","toEqual","items","name","step","resolveExecutionOrder","toHaveLength","dependencies","toThrow","status","evaluateCondition","count","obj","safeSerialize","self","toContain","defined","null","parsed","JSON","parse","not","toHaveProperty","workflow","method","mockStepTask","taskSlug","handler","output","body","state","originalStepTasks","stepTasks","executeWorkflow","toBeDefined","toHaveBeenCalledOnce","mockRejectedValue","Error","executionOrder","mockImplementation","input","push","stepName","slice","findStepTask","toBeUndefined","validateStepConfiguration","triggerContext","operation","collection","createExecutionContext","metadata","startedAt","executionId"],"mappings":"AAAA,SAASA,QAAQ,EAAEC,EAAE,EAAEC,MAAM,EAAEC,UAAU,EAAEC,EAAE,QAAQ,SAAQ;AAC7D,SAASC,gBAAgB,QAAQ,+BAA8B;AAG/DL,SAAS,oBAAoB;IAC3B,IAAIM;IACJ,IAAIC;IACJ,IAAIC;IAEJL,WAAW;QACTI,aAAa;YACXE,MAAML,GAAGM,EAAE;YACXC,OAAOP,GAAGM,EAAE;YACZE,MAAMR,GAAGM,EAAE;YACXG,OAAOT,GAAGM,EAAE;QACd;QAEAJ,cAAc;YACZQ,MAAM;gBACJC,OAAOX,GAAGM,EAAE,GAAGM,iBAAiB,CAAC;oBAAEC,IAAI;gBAAU;gBACjDC,KAAKd,GAAGM,EAAE,GAAGM,iBAAiB,CAACG;YACjC;YACAC,QAAQhB,GAAGM,EAAE;YACbW,QAAQjB,GAAGM,EAAE;YACbY,MAAMlB,GAAGM,EAAE;QACb;QAEAF,WAAW,IAAIH,iBAAiBC,aAAaC;IAC/C;IAEAP,SAAS,wBAAwB;QAC/BC,GAAG,8CAA8C;YAC/C,MAAMsB,UAAU;gBACdC,SAAS;oBACPC,KAAK;wBAAER,IAAI;wBA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@ -1,31 +0,0 @@
|
|
|
1
|
-
export interface CustomTriggerOptions {
|
|
2
|
-
workflowId: string;
|
|
3
|
-
triggerData?: any;
|
|
4
|
-
req?: any;
|
|
5
|
-
}
|
|
6
|
-
export interface TriggerResult {
|
|
7
|
-
success: boolean;
|
|
8
|
-
runId?: string;
|
|
9
|
-
error?: string;
|
|
10
|
-
}
|
|
11
|
-
export interface ExecutionContext {
|
|
12
|
-
trigger: {
|
|
13
|
-
type: string;
|
|
14
|
-
doc?: any;
|
|
15
|
-
data?: any;
|
|
16
|
-
};
|
|
17
|
-
steps: Record<string, {
|
|
18
|
-
output?: any;
|
|
19
|
-
state: 'pending' | 'running' | 'succeeded' | 'failed';
|
|
20
|
-
}>;
|
|
21
|
-
payload: any;
|
|
22
|
-
req: any;
|
|
23
|
-
}
|
|
24
|
-
export interface WorkflowsPluginConfig {
|
|
25
|
-
collections?: string[];
|
|
26
|
-
globals?: string[];
|
|
27
|
-
logging?: {
|
|
28
|
-
level?: 'debug' | 'info' | 'warn' | 'error';
|
|
29
|
-
enabled?: boolean;
|
|
30
|
-
};
|
|
31
|
-
}
|