@gradientedge/cdk-utils 8.58.0 → 8.60.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.
@@ -129,6 +129,13 @@ export declare class SfnManager {
129
129
  * @param {apig.IRestApi} api
130
130
  */
131
131
  createApiStep(id: string, scope: common.CommonConstruct, props: types.SfnCallApiGatewayRestApiEndpointProps, api: apig.IRestApi): cdk.aws_stepfunctions_tasks.CallApiGatewayRestApiEndpoint;
132
+ /**
133
+ * @summary Method to create a step function map state
134
+ * @param {string} id scoped id of the resource
135
+ * @param {common.CommonConstruct} scope scope in which this resource is defined
136
+ * @param {types.SfnMapProps} props props for the map state
137
+ */
138
+ createMapState(id: string, scope: common.CommonConstruct, props: types.SfnMapProps): cdk.aws_stepfunctions.Map;
132
139
  /**
133
140
  * @summary Method to create a state machine
134
141
  * @param {string} id scoped id of the resource
@@ -28,6 +28,14 @@ const cdk = __importStar(require("aws-cdk-lib"));
28
28
  const sfn = __importStar(require("aws-cdk-lib/aws-stepfunctions"));
29
29
  const tasks = __importStar(require("aws-cdk-lib/aws-stepfunctions-tasks"));
30
30
  const utils = __importStar(require("../../utils"));
31
+ const DEFAULT_RETRY_CONFIG = [
32
+ {
33
+ errors: ['States.ALL'],
34
+ intervalInSecs: 30,
35
+ maxAttempts: 6,
36
+ backoffRate: 2,
37
+ },
38
+ ];
31
39
  /**
32
40
  * @stability stable
33
41
  * @category cdk-utils.step-functions-manager
@@ -112,12 +120,14 @@ class SfnManager {
112
120
  comment: `Parallel step for ${props.name} - ${scope.props.stage} stage`,
113
121
  },
114
122
  });
115
- if (props.retries && props.retries.length > 0) {
116
- props.retries.forEach(retry => step.addRetry({
117
- ...retry,
118
- ...{ interval: retry.intervalInSecs ? cdk.Duration.seconds(retry.intervalInSecs) : retry.interval },
119
- }));
123
+ let retries = props.retries;
124
+ if (!retries || retries.length === 0) {
125
+ retries = DEFAULT_RETRY_CONFIG;
120
126
  }
127
+ retries.forEach(retry => step.addRetry({
128
+ ...retry,
129
+ ...{ interval: retry.intervalInSecs ? cdk.Duration.seconds(retry.intervalInSecs) : retry.interval },
130
+ }));
121
131
  return step;
122
132
  }
123
133
  /**
@@ -181,12 +191,14 @@ class SfnManager {
181
191
  comment: `DynamoDB GetItem step for ${props.name} - ${scope.props.stage} stage`,
182
192
  },
183
193
  });
184
- if (props.retries && props.retries.length > 0) {
185
- props.retries.forEach(retry => step.addRetry({
186
- ...retry,
187
- ...{ interval: retry.intervalInSecs ? cdk.Duration.seconds(retry.intervalInSecs) : retry.interval },
188
- }));
194
+ let retries = props.retries;
195
+ if (!retries || retries.length === 0) {
196
+ retries = DEFAULT_RETRY_CONFIG;
189
197
  }
198
+ retries.forEach(retry => step.addRetry({
199
+ ...retry,
200
+ ...{ interval: retry.intervalInSecs ? cdk.Duration.seconds(retry.intervalInSecs) : retry.interval },
201
+ }));
190
202
  return step;
191
203
  }
192
204
  /**
@@ -221,12 +233,14 @@ class SfnManager {
221
233
  comment: `DynamoDB PutItem step for ${props.name} - ${scope.props.stage} stage`,
222
234
  },
223
235
  });
224
- if (props.retries && props.retries.length > 0) {
225
- props.retries.forEach(retry => step.addRetry({
226
- ...retry,
227
- ...{ interval: retry.intervalInSecs ? cdk.Duration.seconds(retry.intervalInSecs) : retry.interval },
228
- }));
236
+ let retries = props.retries;
237
+ if (!retries || retries.length === 0) {
238
+ retries = DEFAULT_RETRY_CONFIG;
229
239
  }
240
+ retries.forEach(retry => step.addRetry({
241
+ ...retry,
242
+ ...{ interval: retry.intervalInSecs ? cdk.Duration.seconds(retry.intervalInSecs) : retry.interval },
243
+ }));
230
244
  return step;
231
245
  }
232
246
  /**
@@ -261,12 +275,14 @@ class SfnManager {
261
275
  comment: `DynamoDB DeleteItem step for ${props.name} - ${scope.props.stage} stage`,
262
276
  },
263
277
  });
264
- if (props.retries && props.retries.length > 0) {
265
- props.retries.forEach(retry => step.addRetry({
266
- ...retry,
267
- ...{ interval: retry.intervalInSecs ? cdk.Duration.seconds(retry.intervalInSecs) : retry.interval },
268
- }));
278
+ let retries = props.retries;
279
+ if (!retries || retries.length === 0) {
280
+ retries = DEFAULT_RETRY_CONFIG;
269
281
  }
282
+ retries.forEach(retry => step.addRetry({
283
+ ...retry,
284
+ ...{ interval: retry.intervalInSecs ? cdk.Duration.seconds(retry.intervalInSecs) : retry.interval },
285
+ }));
270
286
  return step;
271
287
  }
272
288
  /**
@@ -299,12 +315,14 @@ class SfnManager {
299
315
  comment: `DynamoDB PutItem step for ${props.name} - ${scope.props.stage} stage`,
300
316
  },
301
317
  });
302
- if (props.retries && props.retries.length > 0) {
303
- props.retries.forEach(retry => step.addRetry({
304
- ...retry,
305
- ...{ interval: retry.intervalInSecs ? cdk.Duration.seconds(retry.intervalInSecs) : retry.interval },
306
- }));
318
+ let retries = props.retries;
319
+ if (!retries || retries.length === 0) {
320
+ retries = DEFAULT_RETRY_CONFIG;
307
321
  }
322
+ retries.forEach(retry => step.addRetry({
323
+ ...retry,
324
+ ...{ interval: retry.intervalInSecs ? cdk.Duration.seconds(retry.intervalInSecs) : retry.interval },
325
+ }));
308
326
  return step;
309
327
  }
310
328
  /**
@@ -324,12 +342,14 @@ class SfnManager {
324
342
  comment: `Lambda step for ${props.name} - ${scope.props.stage} stage`,
325
343
  },
326
344
  });
327
- if (props.retries && props.retries.length > 0) {
328
- props.retries.forEach(retry => step.addRetry({
329
- ...retry,
330
- ...{ interval: retry.intervalInSecs ? cdk.Duration.seconds(retry.intervalInSecs) : retry.interval },
331
- }));
345
+ let retries = props.retries;
346
+ if (!retries || retries.length === 0) {
347
+ retries = DEFAULT_RETRY_CONFIG;
332
348
  }
349
+ retries.forEach(retry => step.addRetry({
350
+ ...retry,
351
+ ...{ interval: retry.intervalInSecs ? cdk.Duration.seconds(retry.intervalInSecs) : retry.interval },
352
+ }));
333
353
  return step;
334
354
  }
335
355
  /**
@@ -350,14 +370,25 @@ class SfnManager {
350
370
  comment: `API step for ${props.name} - ${scope.props.stage} stage`,
351
371
  },
352
372
  });
353
- if (props.retries && props.retries.length > 0) {
354
- props.retries.forEach(retry => step.addRetry({
355
- ...retry,
356
- ...{ interval: retry.intervalInSecs ? cdk.Duration.seconds(retry.intervalInSecs) : retry.interval },
357
- }));
373
+ let retries = props.retries;
374
+ if (!retries || retries.length === 0) {
375
+ retries = DEFAULT_RETRY_CONFIG;
358
376
  }
377
+ retries.forEach(retry => step.addRetry({
378
+ ...retry,
379
+ ...{ interval: retry.intervalInSecs ? cdk.Duration.seconds(retry.intervalInSecs) : retry.interval },
380
+ }));
359
381
  return step;
360
382
  }
383
+ /**
384
+ * @summary Method to create a step function map state
385
+ * @param {string} id scoped id of the resource
386
+ * @param {common.CommonConstruct} scope scope in which this resource is defined
387
+ * @param {types.SfnMapProps} props props for the map state
388
+ */
389
+ createMapState(id, scope, props) {
390
+ return new sfn.Map(scope, `${id}`, props);
391
+ }
361
392
  /**
362
393
  * @summary Method to create a state machine
363
394
  * @param {string} id scoped id of the resource
@@ -662,6 +662,13 @@ export interface RuleProps extends events.CfnRuleProps {
662
662
  input?: string;
663
663
  }
664
664
  /**
665
+ * @category cdk-utils.sfn-manager
666
+ * @subcategory Properties
667
+ */
668
+ export interface SfnMapProps extends sfn.MapProps {
669
+ }
670
+ /**
671
+ }
665
672
  * @category cdk-utils.event-manager
666
673
  * @subcategory Properties
667
674
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gradientedge/cdk-utils",
3
- "version": "8.58.0",
3
+ "version": "8.60.0",
4
4
  "description": "Utilities for AWS CDK provisioning",
5
5
  "main": "dist/index.js",
6
6
  "engines": {
@@ -10,6 +10,16 @@ import * as tasks from 'aws-cdk-lib/aws-stepfunctions-tasks'
10
10
  import * as common from '../../common'
11
11
  import * as types from '../../types'
12
12
  import * as utils from '../../utils'
13
+ import { SfnMapProps } from '../../types'
14
+
15
+ const DEFAULT_RETRY_CONFIG = [
16
+ {
17
+ errors: ['States.ALL'],
18
+ intervalInSecs: 30,
19
+ maxAttempts: 6,
20
+ backoffRate: 2,
21
+ },
22
+ ]
13
23
 
14
24
  /**
15
25
  * @stability stable
@@ -95,15 +105,18 @@ export class SfnManager {
95
105
  },
96
106
  })
97
107
 
98
- if (props.retries && props.retries.length > 0) {
99
- props.retries.forEach(retry =>
100
- step.addRetry({
101
- ...retry,
102
- ...{ interval: retry.intervalInSecs ? cdk.Duration.seconds(retry.intervalInSecs) : retry.interval },
103
- })
104
- )
108
+ let retries = props.retries
109
+ if (!retries || retries.length === 0) {
110
+ retries = DEFAULT_RETRY_CONFIG
105
111
  }
106
112
 
113
+ retries.forEach(retry =>
114
+ step.addRetry({
115
+ ...retry,
116
+ ...{ interval: retry.intervalInSecs ? cdk.Duration.seconds(retry.intervalInSecs) : retry.interval },
117
+ })
118
+ )
119
+
107
120
  return step
108
121
  }
109
122
 
@@ -175,15 +188,18 @@ export class SfnManager {
175
188
  },
176
189
  })
177
190
 
178
- if (props.retries && props.retries.length > 0) {
179
- props.retries.forEach(retry =>
180
- step.addRetry({
181
- ...retry,
182
- ...{ interval: retry.intervalInSecs ? cdk.Duration.seconds(retry.intervalInSecs) : retry.interval },
183
- })
184
- )
191
+ let retries = props.retries
192
+ if (!retries || retries.length === 0) {
193
+ retries = DEFAULT_RETRY_CONFIG
185
194
  }
186
195
 
196
+ retries.forEach(retry =>
197
+ step.addRetry({
198
+ ...retry,
199
+ ...{ interval: retry.intervalInSecs ? cdk.Duration.seconds(retry.intervalInSecs) : retry.interval },
200
+ })
201
+ )
202
+
187
203
  return step
188
204
  }
189
205
 
@@ -225,15 +241,18 @@ export class SfnManager {
225
241
  },
226
242
  })
227
243
 
228
- if (props.retries && props.retries.length > 0) {
229
- props.retries.forEach(retry =>
230
- step.addRetry({
231
- ...retry,
232
- ...{ interval: retry.intervalInSecs ? cdk.Duration.seconds(retry.intervalInSecs) : retry.interval },
233
- })
234
- )
244
+ let retries = props.retries
245
+ if (!retries || retries.length === 0) {
246
+ retries = DEFAULT_RETRY_CONFIG
235
247
  }
236
248
 
249
+ retries.forEach(retry =>
250
+ step.addRetry({
251
+ ...retry,
252
+ ...{ interval: retry.intervalInSecs ? cdk.Duration.seconds(retry.intervalInSecs) : retry.interval },
253
+ })
254
+ )
255
+
237
256
  return step
238
257
  }
239
258
 
@@ -275,15 +294,18 @@ export class SfnManager {
275
294
  },
276
295
  })
277
296
 
278
- if (props.retries && props.retries.length > 0) {
279
- props.retries.forEach(retry =>
280
- step.addRetry({
281
- ...retry,
282
- ...{ interval: retry.intervalInSecs ? cdk.Duration.seconds(retry.intervalInSecs) : retry.interval },
283
- })
284
- )
297
+ let retries = props.retries
298
+ if (!retries || retries.length === 0) {
299
+ retries = DEFAULT_RETRY_CONFIG
285
300
  }
286
301
 
302
+ retries.forEach(retry =>
303
+ step.addRetry({
304
+ ...retry,
305
+ ...{ interval: retry.intervalInSecs ? cdk.Duration.seconds(retry.intervalInSecs) : retry.interval },
306
+ })
307
+ )
308
+
287
309
  return step
288
310
  }
289
311
 
@@ -321,15 +343,18 @@ export class SfnManager {
321
343
  },
322
344
  })
323
345
 
324
- if (props.retries && props.retries.length > 0) {
325
- props.retries.forEach(retry =>
326
- step.addRetry({
327
- ...retry,
328
- ...{ interval: retry.intervalInSecs ? cdk.Duration.seconds(retry.intervalInSecs) : retry.interval },
329
- })
330
- )
346
+ let retries = props.retries
347
+ if (!retries || retries.length === 0) {
348
+ retries = DEFAULT_RETRY_CONFIG
331
349
  }
332
350
 
351
+ retries.forEach(retry =>
352
+ step.addRetry({
353
+ ...retry,
354
+ ...{ interval: retry.intervalInSecs ? cdk.Duration.seconds(retry.intervalInSecs) : retry.interval },
355
+ })
356
+ )
357
+
333
358
  return step
334
359
  }
335
360
 
@@ -355,15 +380,18 @@ export class SfnManager {
355
380
  },
356
381
  })
357
382
 
358
- if (props.retries && props.retries.length > 0) {
359
- props.retries.forEach(retry =>
360
- step.addRetry({
361
- ...retry,
362
- ...{ interval: retry.intervalInSecs ? cdk.Duration.seconds(retry.intervalInSecs) : retry.interval },
363
- })
364
- )
383
+ let retries = props.retries
384
+ if (!retries || retries.length === 0) {
385
+ retries = DEFAULT_RETRY_CONFIG
365
386
  }
366
387
 
388
+ retries.forEach(retry =>
389
+ step.addRetry({
390
+ ...retry,
391
+ ...{ interval: retry.intervalInSecs ? cdk.Duration.seconds(retry.intervalInSecs) : retry.interval },
392
+ })
393
+ )
394
+
367
395
  return step
368
396
  }
369
397
 
@@ -390,18 +418,31 @@ export class SfnManager {
390
418
  },
391
419
  })
392
420
 
393
- if (props.retries && props.retries.length > 0) {
394
- props.retries.forEach(retry =>
395
- step.addRetry({
396
- ...retry,
397
- ...{ interval: retry.intervalInSecs ? cdk.Duration.seconds(retry.intervalInSecs) : retry.interval },
398
- })
399
- )
421
+ let retries = props.retries
422
+ if (!retries || retries.length === 0) {
423
+ retries = DEFAULT_RETRY_CONFIG
400
424
  }
401
425
 
426
+ retries.forEach(retry =>
427
+ step.addRetry({
428
+ ...retry,
429
+ ...{ interval: retry.intervalInSecs ? cdk.Duration.seconds(retry.intervalInSecs) : retry.interval },
430
+ })
431
+ )
432
+
402
433
  return step
403
434
  }
404
435
 
436
+ /**
437
+ * @summary Method to create a step function map state
438
+ * @param {string} id scoped id of the resource
439
+ * @param {common.CommonConstruct} scope scope in which this resource is defined
440
+ * @param {types.SfnMapProps} props props for the map state
441
+ */
442
+ public createMapState(id: string, scope: common.CommonConstruct, props: types.SfnMapProps) {
443
+ return new sfn.Map(scope, `${id}`, props)
444
+ }
445
+
405
446
  /**
406
447
  * @summary Method to create a state machine
407
448
  * @param {string} id scoped id of the resource
@@ -708,6 +708,13 @@ export interface RuleProps extends events.CfnRuleProps {
708
708
  }
709
709
 
710
710
  /**
711
+ * @category cdk-utils.sfn-manager
712
+ * @subcategory Properties
713
+ */
714
+ export interface SfnMapProps extends sfn.MapProps {}
715
+
716
+ /**
717
+ }
711
718
  * @category cdk-utils.event-manager
712
719
  * @subcategory Properties
713
720
  */