@justworkflowit/cdk-constructs 0.0.200 → 0.0.202

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.
@@ -203,4 +203,220 @@ describe('JustWorkflowItConstructs', () => {
203
203
  });
204
204
  }).toThrow(/Invalid workflow definition at index 0.*items\[0\]/);
205
205
  });
206
+ test('should accept workflow with workflowInput definition', () => {
207
+ const app = new aws_cdk_lib_1.App();
208
+ const stack = new aws_cdk_lib_1.Stack(app, 'TestStack');
209
+ const workflowWithInput = JSON.stringify({
210
+ workflowName: 'workflowWithInput',
211
+ steps: [
212
+ {
213
+ name: 'step1',
214
+ retries: 2,
215
+ timeoutSeconds: 1000,
216
+ transitionToStep: null,
217
+ integrationDetails: {
218
+ type: 'testIntegration',
219
+ inputTransformer: {
220
+ fieldset: [
221
+ {
222
+ from: 'workflowInput.businessId',
223
+ to: 'businessId',
224
+ },
225
+ ],
226
+ },
227
+ inputDefinition: {
228
+ $ref: '#/definitions/step1Input',
229
+ },
230
+ outputDefinition: {
231
+ $ref: '#/definitions/step1Output',
232
+ },
233
+ },
234
+ },
235
+ ],
236
+ definitions: {
237
+ workflowInput: {
238
+ type: 'object',
239
+ properties: {
240
+ businessId: {
241
+ type: 'string',
242
+ },
243
+ },
244
+ required: ['businessId'],
245
+ additionalProperties: false,
246
+ },
247
+ step1Input: {
248
+ type: 'object',
249
+ properties: {
250
+ businessId: {
251
+ type: 'string',
252
+ },
253
+ },
254
+ required: ['businessId'],
255
+ additionalProperties: false,
256
+ },
257
+ step1Output: {
258
+ type: 'object',
259
+ properties: {
260
+ result: {
261
+ type: 'string',
262
+ },
263
+ },
264
+ required: ['result'],
265
+ additionalProperties: false,
266
+ },
267
+ },
268
+ });
269
+ expect(() => {
270
+ new justWorkflowItConstructs_1.JustWorkflowItConstructs(stack, {
271
+ disambiguator: 'test',
272
+ organizationId: 'org123',
273
+ workflowDefinitions: [workflowWithInput],
274
+ });
275
+ }).not.toThrow();
276
+ });
277
+ test('should accept workflow with complex workflowInput and nested definitions', () => {
278
+ const app = new aws_cdk_lib_1.App();
279
+ const stack = new aws_cdk_lib_1.Stack(app, 'TestStack');
280
+ const workflowWithComplexInput = JSON.stringify({
281
+ workflowName: 'complexInputWorkflow',
282
+ steps: [
283
+ {
284
+ name: 'step1',
285
+ retries: 2,
286
+ timeoutSeconds: 1000,
287
+ transitionToStep: null,
288
+ integrationDetails: {
289
+ type: 'testIntegration',
290
+ inputTransformer: {
291
+ fieldset: [
292
+ {
293
+ from: 'workflowInput.businessId',
294
+ to: 'businessId',
295
+ },
296
+ {
297
+ from: 'workflowInput.metadata.location',
298
+ to: 'location',
299
+ },
300
+ ],
301
+ },
302
+ inputDefinition: {
303
+ $ref: '#/definitions/step1Input',
304
+ },
305
+ outputDefinition: {
306
+ $ref: '#/definitions/step1Output',
307
+ },
308
+ },
309
+ },
310
+ ],
311
+ definitions: {
312
+ workflowInput: {
313
+ type: 'object',
314
+ properties: {
315
+ businessId: {
316
+ type: 'string',
317
+ },
318
+ metadata: {
319
+ $ref: '#/definitions/metadataType',
320
+ },
321
+ },
322
+ required: ['businessId'],
323
+ additionalProperties: false,
324
+ },
325
+ metadataType: {
326
+ type: 'object',
327
+ properties: {
328
+ location: {
329
+ type: 'string',
330
+ },
331
+ tags: {
332
+ type: 'array',
333
+ items: {
334
+ type: 'string',
335
+ },
336
+ },
337
+ },
338
+ required: ['location'],
339
+ additionalProperties: false,
340
+ },
341
+ step1Input: {
342
+ type: 'object',
343
+ properties: {
344
+ businessId: {
345
+ type: 'string',
346
+ },
347
+ location: {
348
+ type: 'string',
349
+ },
350
+ },
351
+ required: ['businessId', 'location'],
352
+ additionalProperties: false,
353
+ },
354
+ step1Output: {
355
+ type: 'object',
356
+ properties: {
357
+ result: {
358
+ type: 'string',
359
+ },
360
+ },
361
+ required: ['result'],
362
+ additionalProperties: false,
363
+ },
364
+ },
365
+ });
366
+ expect(() => {
367
+ new justWorkflowItConstructs_1.JustWorkflowItConstructs(stack, {
368
+ disambiguator: 'test',
369
+ organizationId: 'org123',
370
+ workflowDefinitions: [workflowWithComplexInput],
371
+ });
372
+ }).not.toThrow();
373
+ });
374
+ test('should accept workflow without workflowInput definition (backward compatibility)', () => {
375
+ const app = new aws_cdk_lib_1.App();
376
+ const stack = new aws_cdk_lib_1.Stack(app, 'TestStack');
377
+ const workflowWithoutInput = JSON.stringify({
378
+ workflowName: 'noInputWorkflow',
379
+ steps: [
380
+ {
381
+ name: 'step1',
382
+ retries: 2,
383
+ timeoutSeconds: 1000,
384
+ transitionToStep: null,
385
+ integrationDetails: {
386
+ type: 'testIntegration',
387
+ inputDefinition: {
388
+ $ref: '#/definitions/step1Input',
389
+ },
390
+ outputDefinition: {
391
+ $ref: '#/definitions/step1Output',
392
+ },
393
+ },
394
+ },
395
+ ],
396
+ definitions: {
397
+ step1Input: {
398
+ type: 'object',
399
+ properties: {},
400
+ additionalProperties: false,
401
+ },
402
+ step1Output: {
403
+ type: 'object',
404
+ properties: {
405
+ result: {
406
+ type: 'string',
407
+ },
408
+ },
409
+ required: ['result'],
410
+ additionalProperties: false,
411
+ },
412
+ },
413
+ });
414
+ expect(() => {
415
+ new justWorkflowItConstructs_1.JustWorkflowItConstructs(stack, {
416
+ disambiguator: 'test',
417
+ organizationId: 'org123',
418
+ workflowDefinitions: [workflowWithoutInput],
419
+ });
420
+ }).not.toThrow();
421
+ });
206
422
  });
@@ -75,6 +75,10 @@ class JustWorkflowItConstructs extends constructs_1.Construct {
75
75
  acc[`#/definitions/${key}`] = value;
76
76
  return acc;
77
77
  }, {});
78
+ // Configure json-schema-faker to always generate optional fields for thorough validation
79
+ json_schema_faker_1.JSONSchemaFaker.option({
80
+ alwaysFakeOptionals: true,
81
+ });
78
82
  fakeWorkflowInputForTypeValidation = json_schema_faker_1.JSONSchemaFaker.generate(parsedWorkflow.definitions.workflowInput, jsonSchemaFakerRefs);
79
83
  }
80
84
  // This will throw if the workflow definition is invalid
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@justworkflowit/cdk-constructs",
3
3
  "description": "",
4
- "version": "0.0.200",
4
+ "version": "0.0.202",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
7
7
  "publishConfig": {