@justworkflowit/cdk-constructs 0.0.190 → 0.0.191
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.
|
@@ -336,4 +336,107 @@ describe('Workflow Engine Integration Tests', () => {
|
|
|
336
336
|
});
|
|
337
337
|
}).toThrow();
|
|
338
338
|
});
|
|
339
|
+
test('should reject workflow with array index reference that may not exist', () => {
|
|
340
|
+
const emptyArrayExecutor = {
|
|
341
|
+
type: 'emptyArrayExecutor',
|
|
342
|
+
execute: (_args) => Promise.resolve({
|
|
343
|
+
status: 'success',
|
|
344
|
+
payload: { items: [] },
|
|
345
|
+
}),
|
|
346
|
+
};
|
|
347
|
+
const secondStepExecutor = {
|
|
348
|
+
type: 'secondStepExecutor',
|
|
349
|
+
execute: (_args) => Promise.resolve({
|
|
350
|
+
status: 'success',
|
|
351
|
+
payload: {},
|
|
352
|
+
}),
|
|
353
|
+
};
|
|
354
|
+
const workflowWithArrayReference = {
|
|
355
|
+
workflowName: 'arrayReferenceWorkflow',
|
|
356
|
+
steps: [
|
|
357
|
+
{
|
|
358
|
+
name: 'getItems',
|
|
359
|
+
retries: 2,
|
|
360
|
+
timeoutSeconds: 1000,
|
|
361
|
+
transitionToStep: 'processItem',
|
|
362
|
+
integrationDetails: {
|
|
363
|
+
type: 'emptyArrayExecutor',
|
|
364
|
+
inputDefinition: {
|
|
365
|
+
$ref: '#/definitions/getItemsInput',
|
|
366
|
+
},
|
|
367
|
+
outputDefinition: {
|
|
368
|
+
$ref: '#/definitions/getItemsOutput',
|
|
369
|
+
},
|
|
370
|
+
},
|
|
371
|
+
},
|
|
372
|
+
{
|
|
373
|
+
name: 'processItem',
|
|
374
|
+
retries: 2,
|
|
375
|
+
timeoutSeconds: 1000,
|
|
376
|
+
transitionToStep: null,
|
|
377
|
+
integrationDetails: {
|
|
378
|
+
type: 'secondStepExecutor',
|
|
379
|
+
inputDefinition: {
|
|
380
|
+
$ref: '#/definitions/processItemInput',
|
|
381
|
+
},
|
|
382
|
+
outputDefinition: {
|
|
383
|
+
$ref: '#/definitions/processItemOutput',
|
|
384
|
+
},
|
|
385
|
+
inputTransformer: {
|
|
386
|
+
fieldset: [
|
|
387
|
+
{
|
|
388
|
+
// This references an array element that may not exist
|
|
389
|
+
from: 'getItemsOutput.items[0].id',
|
|
390
|
+
to: 'itemId',
|
|
391
|
+
},
|
|
392
|
+
],
|
|
393
|
+
},
|
|
394
|
+
},
|
|
395
|
+
},
|
|
396
|
+
],
|
|
397
|
+
definitions: {
|
|
398
|
+
getItemsInput: {
|
|
399
|
+
type: 'object',
|
|
400
|
+
properties: {},
|
|
401
|
+
additionalProperties: false,
|
|
402
|
+
},
|
|
403
|
+
getItemsOutput: {
|
|
404
|
+
type: 'object',
|
|
405
|
+
properties: {
|
|
406
|
+
items: {
|
|
407
|
+
type: 'array',
|
|
408
|
+
items: {
|
|
409
|
+
type: 'object',
|
|
410
|
+
properties: {
|
|
411
|
+
id: { type: 'string' },
|
|
412
|
+
},
|
|
413
|
+
},
|
|
414
|
+
},
|
|
415
|
+
},
|
|
416
|
+
required: ['items'],
|
|
417
|
+
additionalProperties: false,
|
|
418
|
+
},
|
|
419
|
+
processItemInput: {
|
|
420
|
+
type: 'object',
|
|
421
|
+
properties: {
|
|
422
|
+
itemId: { type: 'string' },
|
|
423
|
+
},
|
|
424
|
+
required: ['itemId'],
|
|
425
|
+
additionalProperties: false,
|
|
426
|
+
},
|
|
427
|
+
processItemOutput: {
|
|
428
|
+
type: 'object',
|
|
429
|
+
properties: {},
|
|
430
|
+
additionalProperties: false,
|
|
431
|
+
},
|
|
432
|
+
},
|
|
433
|
+
};
|
|
434
|
+
// Engine performs static type analysis and catches this at definition time
|
|
435
|
+
expect(() => {
|
|
436
|
+
new engine_1.JustWorkflowItEngine({
|
|
437
|
+
workflowDefinition: JSON.stringify(workflowWithArrayReference),
|
|
438
|
+
stepExecutors: [emptyArrayExecutor, secondStepExecutor],
|
|
439
|
+
});
|
|
440
|
+
}).toThrow(/Missing expected field.*items\[0\]/);
|
|
441
|
+
});
|
|
339
442
|
});
|