@gradientedge/cdk-utils 8.62.0 → 8.63.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,14 @@ 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 execution step
134
+ * @param {string} id scoped id of the resource
135
+ * @param {common.CommonConstruct} scope scope in which this resource is defined
136
+ * @param {types.SfnStartExecutionProps} props props for the step
137
+ * @param {sfn.IStateMachine} stateMachine the state machine to execute
138
+ */
139
+ createSfnExecutionStep(id: string, scope: common.CommonConstruct, props: types.SfnStartExecutionProps, stateMachine: sfn.IStateMachine): cdk.aws_stepfunctions_tasks.StepFunctionsStartExecution;
132
140
  /**
133
141
  * @summary Method to create a step function map state
134
142
  * @param {string} id scoped id of the resource
@@ -28,6 +28,7 @@ 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 uuid_1 = require("uuid");
31
32
  const DEFAULT_RETRY_CONFIG = [
32
33
  {
33
34
  errors: ['States.ALL'],
@@ -380,6 +381,31 @@ class SfnManager {
380
381
  }));
381
382
  return step;
382
383
  }
384
+ /**
385
+ * @summary Method to create a step function execution step
386
+ * @param {string} id scoped id of the resource
387
+ * @param {common.CommonConstruct} scope scope in which this resource is defined
388
+ * @param {types.SfnStartExecutionProps} props props for the step
389
+ * @param {sfn.IStateMachine} stateMachine the state machine to execute
390
+ */
391
+ createSfnExecutionStep(id, scope, props, stateMachine) {
392
+ const step = new tasks.StepFunctionsStartExecution(scope, `${id}`, {
393
+ ...props,
394
+ associateWithParent: props.associateWithParent ?? true,
395
+ inputPath: props.inputPath,
396
+ name: props.name ?? (0, uuid_1.v4)(),
397
+ stateMachine: stateMachine,
398
+ });
399
+ let retries = props.retries;
400
+ if (!retries || retries.length === 0) {
401
+ retries = DEFAULT_RETRY_CONFIG;
402
+ }
403
+ retries.forEach(retry => step.addRetry({
404
+ ...retry,
405
+ ...{ interval: retry.intervalInSecs ? cdk.Duration.seconds(retry.intervalInSecs) : retry.interval },
406
+ }));
407
+ return step;
408
+ }
383
409
  /**
384
410
  * @summary Method to create a step function map state
385
411
  * @param {string} id scoped id of the resource
@@ -668,6 +668,13 @@ export interface RuleProps extends events.CfnRuleProps {
668
668
  */
669
669
  export interface SfnMapProps extends sfn.MapProps {
670
670
  }
671
+ /**
672
+ * @category cdk-utils.sfn-manager
673
+ * @subcategory Properties
674
+ */
675
+ export interface SfnStartExecutionProps extends tasks.StepFunctionsStartExecutionProps {
676
+ retries?: SfnRetryProps[];
677
+ }
671
678
  /**
672
679
  }
673
680
  * @category cdk-utils.event-manager
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gradientedge/cdk-utils",
3
- "version": "8.62.0",
3
+ "version": "8.63.0",
4
4
  "description": "Utilities for AWS CDK provisioning",
5
5
  "main": "dist/index.js",
6
6
  "engines": {
@@ -46,17 +46,19 @@
46
46
  }
47
47
  },
48
48
  "dependencies": {
49
+ "@aws-sdk/client-secrets-manager": "^3.334.0",
49
50
  "@types/lodash": "^4.14.194",
50
51
  "@types/node": "^20.2.0",
52
+ "@types/uuid": "^9.0.1",
51
53
  "app-root-path": "^3.1.0",
52
54
  "aws-cdk-lib": "^2.79.1",
53
- "@aws-sdk/client-secrets-manager": "^3.334.0",
54
55
  "constructs": "^10.2.27",
55
56
  "lodash": "^4.17.21",
56
57
  "moment": "^2.29.4",
57
58
  "nconf": "^0.12.0",
58
59
  "pluralize": "^8.0.0",
59
- "ts-node": "^10.9.1"
60
+ "ts-node": "^10.9.1",
61
+ "uuid": "^9.0.0"
60
62
  },
61
63
  "devDependencies": {
62
64
  "@babel/core": "^7.21.8",
@@ -11,6 +11,7 @@ import * as common from '../../common'
11
11
  import * as types from '../../types'
12
12
  import * as utils from '../../utils'
13
13
  import { SfnMapProps } from '../../types'
14
+ import { v4 as uuidv4 } from 'uuid'
14
15
 
15
16
  const DEFAULT_RETRY_CONFIG = [
16
17
  {
@@ -433,6 +434,42 @@ export class SfnManager {
433
434
  return step
434
435
  }
435
436
 
437
+ /**
438
+ * @summary Method to create a step function execution step
439
+ * @param {string} id scoped id of the resource
440
+ * @param {common.CommonConstruct} scope scope in which this resource is defined
441
+ * @param {types.SfnStartExecutionProps} props props for the step
442
+ * @param {sfn.IStateMachine} stateMachine the state machine to execute
443
+ */
444
+ public createSfnExecutionStep(
445
+ id: string,
446
+ scope: common.CommonConstruct,
447
+ props: types.SfnStartExecutionProps,
448
+ stateMachine: sfn.IStateMachine
449
+ ) {
450
+ const step = new tasks.StepFunctionsStartExecution(scope, `${id}`, {
451
+ ...props,
452
+ associateWithParent: props.associateWithParent ?? true,
453
+ inputPath: props.inputPath,
454
+ name: props.name ?? uuidv4(),
455
+ stateMachine: stateMachine,
456
+ })
457
+
458
+ let retries = props.retries
459
+ if (!retries || retries.length === 0) {
460
+ retries = DEFAULT_RETRY_CONFIG
461
+ }
462
+
463
+ retries.forEach(retry =>
464
+ step.addRetry({
465
+ ...retry,
466
+ ...{ interval: retry.intervalInSecs ? cdk.Duration.seconds(retry.intervalInSecs) : retry.interval },
467
+ })
468
+ )
469
+
470
+ return step
471
+ }
472
+
436
473
  /**
437
474
  * @summary Method to create a step function map state
438
475
  * @param {string} id scoped id of the resource
@@ -714,6 +714,14 @@ export interface RuleProps extends events.CfnRuleProps {
714
714
  */
715
715
  export interface SfnMapProps extends sfn.MapProps {}
716
716
 
717
+ /**
718
+ * @category cdk-utils.sfn-manager
719
+ * @subcategory Properties
720
+ */
721
+ export interface SfnStartExecutionProps extends tasks.StepFunctionsStartExecutionProps {
722
+ retries?: SfnRetryProps[]
723
+ }
724
+
717
725
  /**
718
726
  }
719
727
  * @category cdk-utils.event-manager