aws-local-stepfunctions 0.2.0 → 0.3.1

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 CHANGED
@@ -6,6 +6,19 @@ This package lets you run AWS Step Functions locally on your machine!
6
6
 
7
7
  > NOTE: This is a work in progress. Some features defined in the specification might not be supported at all yet or might have limited support.
8
8
 
9
+ ## Table of Contents
10
+
11
+ - [Features](#features)
12
+ - [Installation](#installation)
13
+ - [Importing](#importing)
14
+ - [Node.js](#nodejs)
15
+ - [CommonJS](#commonjs)
16
+ - [ES Module](#es-module)
17
+ - [API](#api)
18
+ - [Constructor](#constructor-new-statemachinedefinition-validationoptions)
19
+ - [StateMachine.run](#statemachineruninput-options)
20
+ - [License](#license)
21
+
9
22
  ## Features
10
23
 
11
24
  To see a list of features that have full support, partial support, or no support, refer to [this document](/docs/feature-support.md).
@@ -38,6 +51,8 @@ import { StateMachine } from 'aws-local-stepfunctions';
38
51
 
39
52
  ### Constructor: `new StateMachine(definition[, validationOptions])`
40
53
 
54
+ #### Parameters
55
+
41
56
  The constructor takes the following parameters:
42
57
 
43
58
  - `definition`: The Amazon States Language definition of the state machine.
@@ -47,7 +62,7 @@ The constructor takes the following parameters:
47
62
 
48
63
  The constructor will attempt to validate the definition by default, unless the `validationOptions` param is specified. If the definition is not valid, an error will be thrown.
49
64
 
50
- Example:
65
+ #### Example
51
66
 
52
67
  ```js
53
68
  import { StateMachine } from 'aws-local-stepfunctions';
@@ -68,19 +83,27 @@ const machineDefinition = {
68
83
  const stateMachine = new StateMachine(machineDefinition, { checkPaths: false });
69
84
  ```
70
85
 
71
- ### `async StateMachine.run(input[, options])`
86
+ ### `StateMachine.run(input[, options])`
87
+
88
+ Runs the state machine with the given `input` parameter and returns an object with the following properties:
89
+
90
+ - `abort`: A function that takes no parameters and doesn't return any value. If called, aborts the execution and throws an `ExecutionAbortedError`, unless the `noThrowOnAbort` option is set.
91
+ - `result`: A `Promise` that resolves with the execution result once it finishes.
72
92
 
73
- Executes the state machine with the given `input` parameter and returns the result of the execution.
93
+ Each execution is independent of all others, meaning that you can concurrently call this method as many times as needed, without worrying about race conditions.
74
94
 
75
- It takes the following parameters:
95
+ #### Parameters
76
96
 
77
97
  - `input`: The initial input to pass to the state machine. This can be any valid JSON value.
78
98
  - `options` (optional):
79
- - `overrides`: An object to overrides the behavior of certain states:
99
+ - `overrides`: An object to override the behavior of certain states:
80
100
  - `taskResourceLocalHandlers`: Overrides the resource of the specified `Task` states to run a local function.
81
101
  - `waitTimeOverrides`: Overrides the wait duration of the specified `Wait` states. The specifed override duration should be in milliseconds.
102
+ - `noThrowOnAbort`: If this option is set to `true`, aborting the execution will simply return `null` as result instead of throwing.
82
103
 
83
- Example without `options`:
104
+ #### Examples
105
+
106
+ ##### Example without `options`:
84
107
 
85
108
  ```js
86
109
  import { StateMachine } from 'aws-local-stepfunctions';
@@ -96,14 +119,15 @@ const machineDefinition = {
96
119
  },
97
120
  };
98
121
 
99
- const stateMachine = new StateMachine(machineDefinition, { checkPaths: false });
122
+ const stateMachine = new StateMachine(machineDefinition);
100
123
  const myInput = { value1: 'hello', value2: 123, value3: true };
101
- const result = await stateMachine.run(myInput); // execute the state machine
124
+ const execution = stateMachine.run(myInput); // execute the state machine
102
125
 
126
+ const result = await execution.result; // wait until the execution finishes to get the result
103
127
  console.log(result); // log the result of the execution
104
128
  ```
105
129
 
106
- Example with `options`:
130
+ ##### Example with `options`:
107
131
 
108
132
  ```js
109
133
  import { StateMachine } from 'aws-local-stepfunctions';
@@ -133,9 +157,9 @@ function addNumbersLocal(input) {
133
157
  return input.num1 + input.num2;
134
158
  }
135
159
 
136
- const stateMachine = new StateMachine(machineDefinition, { checkPaths: false });
160
+ const stateMachine = new StateMachine(machineDefinition);
137
161
  const myInput = { value1: 'hello', value2: 123, value3: true };
138
- const result = await stateMachine.run(myInput, {
162
+ const execution = stateMachine.run(myInput, {
139
163
  overrides: {
140
164
  taskResourceLocalHandlers: {
141
165
  AddNumbers: addNumbersLocal, // call the `addNumbersLocal` function instead of invoking the Lambda function specified for the `AddNumbers` state
@@ -146,7 +170,46 @@ const result = await stateMachine.run(myInput, {
146
170
  },
147
171
  });
148
172
 
149
- console.log(result); // log the result of the execution
173
+ const result = await execution.result;
174
+ console.log(result);
175
+ ```
176
+
177
+ ##### Aborting an execution
178
+
179
+ ```js
180
+ import { StateMachine, ExecutionAbortedError } from 'aws-local-stepfunctions';
181
+
182
+ const machineDefinition = {
183
+ StartAt: 'Hello World',
184
+ States: {
185
+ 'Hello World': {
186
+ Type: 'Task',
187
+ Resource: 'arn:aws:lambda:us-east-1:123456789012:function:HelloWorld',
188
+ End: true,
189
+ },
190
+ },
191
+ };
192
+
193
+ const stateMachine = new StateMachine(machineDefinition);
194
+ const myInput = { value1: 'hello', value2: 123, value3: true };
195
+ const execution = stateMachine.run(myInput);
196
+
197
+ // abort the execution after 3 seconds
198
+ setTimeout(() => {
199
+ execution.abort();
200
+ }, 3000);
201
+
202
+ try {
203
+ const result = await execution.result;
204
+ console.log(result);
205
+ } catch (e) {
206
+ if (e instanceof ExecutionAbortedError) {
207
+ // since execution was aborted, type of error is `ExecutionAbortedError`
208
+ console.log('Execution was aborted');
209
+ } else {
210
+ console.error('Some other error', e);
211
+ }
212
+ }
150
213
  ```
151
214
 
152
215
  ## License
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aws-local-stepfunctions",
3
- "version": "0.2.0",
3
+ "version": "0.3.1",
4
4
  "description": "Execute an AWS Step Function locally",
5
5
  "keywords": [
6
6
  "aws",
@@ -34,7 +34,7 @@
34
34
  },
35
35
  "scripts": {
36
36
  "test": "jest",
37
- "build": "bunchee --minify src/main.ts",
37
+ "build": "tsup",
38
38
  "prettier": "prettier --write src/**/*.ts",
39
39
  "lint": "eslint src/**/*.ts",
40
40
  "lint:fix": "eslint src/**/*.ts --fix"
@@ -43,16 +43,16 @@
43
43
  "@tsconfig/node16-strictest": "^1.0.4",
44
44
  "@types/jest": "^29.0.3",
45
45
  "@types/lodash": "^4.14.184",
46
- "@types/node": "^17.0.31",
46
+ "@types/node": "^18.14.0",
47
47
  "@types/picomatch": "^2.3.0",
48
48
  "@typescript-eslint/eslint-plugin": "^5.22.0",
49
49
  "@typescript-eslint/parser": "^5.22.0",
50
- "bunchee": "^2.2.0",
51
50
  "eslint": "^8.14.0",
52
51
  "eslint-config-prettier": "^8.5.0",
53
52
  "eslint-plugin-prettier": "^4.0.0",
54
53
  "prettier": "^2.6.2",
55
54
  "ts-jest": "^29.0.3",
55
+ "tsup": "^6.6.3",
56
56
  "typescript": "^4.6.4"
57
57
  },
58
58
  "dependencies": {
package/build/main.cjs DELETED
@@ -1,3 +0,0 @@
1
- Object.defineProperty(exports,"__esModule",{value:!0});var jsonpathPlus=require("jsonpath-plus"),clientLambda=require("@aws-sdk/client-lambda"),wcmatch=require("wildcard-match"),aslValidator=require("asl-validator"),set=require("lodash/set.js"),cloneDeep=require("lodash/cloneDeep.js"),pLimit=require("p-limit");function _interopDefaultLegacy(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var wcmatch__default=_interopDefaultLegacy(wcmatch),aslValidator__default=_interopDefaultLegacy(aslValidator),set__default=_interopDefaultLegacy(set),cloneDeep__default=_interopDefaultLegacy(cloneDeep),pLimit__default=_interopDefaultLegacy(pLimit);function isPlainObj(e){return!!e&&Object.getPrototypeOf(e)===Object.prototype}function sleep(e){return new Promise(t=>{setTimeout(t,e)})}class CustomError extends Error{constructor(e){super(e)}}class LambdaExecutionError extends CustomError{toString(){return`${this.name}: ${this.message}. The error thrown by the Lambda was:
2
- ${this.wrappedError.stack}`}constructor(e,t){super(`Execution of Lambda function "${t}" failed`),this.name="LambdaExecutionError",this.wrappedError=Error(e.errorMessage),this.wrappedError.stack=e.trace.join("\n")}}function asyncGeneratorStep$1(e,t,r,a,n,i,s){try{var u=e[i](s),l=u.value}catch(c){r(c);return}u.done?t(l):Promise.resolve(l).then(a,n)}function _asyncToGenerator$1(e){return function(){var t=this,r=arguments;return new Promise(function(a,n){var i=e.apply(t,r);function s(e){asyncGeneratorStep$1(i,a,n,s,u,"next",e)}function u(e){asyncGeneratorStep$1(i,a,n,s,u,"throw",e)}s(void 0)})}}class LambdaClient{invokeFunction(e,t){var r=this;return _asyncToGenerator$1(function*(){let a=Buffer.from(JSON.stringify(t)),n=new clientLambda.InvokeCommand({FunctionName:e,Payload:a}),i=yield r.client.send(n),s=null;if(i.Payload&&(s=JSON.parse(s=Buffer.from(i.Payload).toString())),i.FunctionError)throw new LambdaExecutionError(s,e);return s})()}constructor(e){this.client=new clientLambda.LambdaClient(null!=e?e:{})}}function testChoiceRule(e,t,r){if("And"in e)return e.And.every(e=>testChoiceRule(e,t,r));if("Or"in e)return e.Or.some(e=>testChoiceRule(e,t,r));if("Not"in e)return!testChoiceRule(e.Not,t,r);if("StringEquals"in e){let a=r(e.Variable,t);return a===e.StringEquals}if("StringEqualsPath"in e){let n=r(e.Variable,t),i=r(e.StringEqualsPath,t);return n===i}if("StringLessThan"in e){let s=r(e.Variable,t);return s<e.StringLessThan}if("StringLessThanPath"in e){let u=r(e.Variable,t),l=r(e.StringLessThanPath,t);return u<l}if("StringGreaterThan"in e){let c=r(e.Variable,t);return c>e.StringGreaterThan}if("StringGreaterThanPath"in e){let o=r(e.Variable,t),h=r(e.StringGreaterThanPath,t);return o>h}if("StringLessThanEquals"in e){let p=r(e.Variable,t);return p<=e.StringLessThanEquals}if("StringLessThanEqualsPath"in e){let m=r(e.Variable,t),d=r(e.StringLessThanEqualsPath,t);return m<=d}if("StringGreaterThanEquals"in e){let f=r(e.Variable,t);return f>=e.StringGreaterThanEquals}if("StringGreaterThanEqualsPath"in e){let T=r(e.Variable,t),S=r(e.StringGreaterThanEqualsPath,t);return T>=S}if("StringMatches"in e){let P=r(e.Variable,t),y=wcmatch__default.default(e.StringMatches,{separator:!1});return y(P)}if("NumericEquals"in e){let b=r(e.Variable,t);return b===e.NumericEquals}if("NumericEqualsPath"in e){let w=r(e.Variable,t),E=r(e.NumericEqualsPath,t);return w===E}if("NumericLessThan"in e){let I=r(e.Variable,t);return I<e.NumericLessThan}if("NumericLessThanPath"in e){let g=r(e.Variable,t),q=r(e.NumericLessThanPath,t);return g<q}if("NumericGreaterThan"in e){let L=r(e.Variable,t);return L>e.NumericGreaterThan}if("NumericGreaterThanPath"in e){let v=r(e.Variable,t),V=r(e.NumericGreaterThanPath,t);return v>V}if("NumericLessThanEquals"in e){let N=r(e.Variable,t);return N<=e.NumericLessThanEquals}if("NumericLessThanEqualsPath"in e){let _=r(e.Variable,t),G=r(e.NumericLessThanEqualsPath,t);return _<=G}if("NumericGreaterThanEquals"in e){let R=r(e.Variable,t);return R>=e.NumericGreaterThanEquals}if("NumericGreaterThanEqualsPath"in e){let D=r(e.Variable,t),j=r(e.NumericGreaterThanEqualsPath,t);return D>=j}if("BooleanEquals"in e){let O=r(e.Variable,t);return O===e.BooleanEquals}if("BooleanEqualsPath"in e){let x=r(e.Variable,t),C=r(e.BooleanEqualsPath,t);return x===C}if("TimestampEquals"in e){let M=new Date(r(e.Variable,t)),$=new Date(e.TimestampEquals);return M.getTime()===$.getTime()}if("TimestampEqualsPath"in e){let k=new Date(r(e.Variable,t)),B=new Date(r(e.TimestampEqualsPath,t));return k.getTime()===B.getTime()}if("TimestampLessThan"in e){let F=new Date(r(e.Variable,t)),Q=new Date(e.TimestampLessThan);return F<Q}if("TimestampLessThanPath"in e){let A=new Date(r(e.Variable,t)),W=new Date(r(e.TimestampLessThanPath,t));return A<W}if("TimestampGreaterThan"in e){let J=new Date(r(e.Variable,t)),H=new Date(e.TimestampGreaterThan);return J>H}if("TimestampGreaterThanPath"in e){let Z=new Date(r(e.Variable,t)),z=new Date(r(e.TimestampGreaterThanPath,t));return Z>z}if("TimestampLessThanEquals"in e){let K=new Date(r(e.Variable,t)),U=new Date(e.TimestampLessThanEquals);return K<=U}if("TimestampLessThanEqualsPath"in e){let X=new Date(r(e.Variable,t)),Y=new Date(r(e.TimestampLessThanEqualsPath,t));return X<=Y}if("TimestampGreaterThanEquals"in e){let ee=new Date(r(e.Variable,t)),et=new Date(e.TimestampGreaterThanEquals);return ee>=et}if("TimestampGreaterThanEqualsPath"in e){let er=new Date(r(e.Variable,t)),ea=new Date(r(e.TimestampGreaterThanEqualsPath,t));return er>=ea}if("IsNull"in e){let en=r(e.Variable,t),ei=e.IsNull;return ei&&null===en}if("IsPresent"in e){let es=r(e.Variable,t),eu=e.IsPresent;return eu&&!!es}if("IsNumeric"in e){let el=r(e.Variable,t),ec=e.IsNumeric;return ec&&"number"==typeof el}if("IsString"in e){let eo=r(e.Variable,t),eh=e.IsString;return eh&&"string"==typeof eo}if("IsBoolean"in e){let ep=r(e.Variable,t),em=e.IsBoolean;return em&&"boolean"==typeof ep}if("IsTimestamp"in e){let ed=r(e.Variable,t),ef=e.IsTimestamp;return ef&&/\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(Z|(\+|-)\d{2}:\d{2})/.test(ed)}return!1}function asyncGeneratorStep(e,t,r,a,n,i,s){try{var u=e[i](s),l=u.value}catch(c){r(c);return}u.done?t(l):Promise.resolve(l).then(a,n)}function _asyncToGenerator(e){return function(){var t=this,r=arguments;return new Promise(function(a,n){var i=e.apply(t,r);function s(e){asyncGeneratorStep(i,a,n,s,u,"next",e)}function u(e){asyncGeneratorStep(i,a,n,s,u,"throw",e)}s(void 0)})}}function _extends(){return(_extends=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var a in r)Object.prototype.hasOwnProperty.call(r,a)&&(e[a]=r[a])}return e}).apply(this,arguments)}class StateMachine{run(e,t){var r=this;return _asyncToGenerator(function*(){r.rawInput=e,r.currInput=e;let a=!1;do r.currState=r.states[r.currStateName],r.processInput(),yield r.stateHandlers[r.currState.Type](t),r.processResult(),r.rawInput=r.currResult,r.currInput=r.currResult,"Next"in r.currState&&(r.currStateName=r.currState.Next),("End"in r.currState||"Succeed"===r.currState.Type||"Fail"===r.currState.Type)&&(a=!0);while(!a);return r.currResult})()}processInputPath(){return"InputPath"in this.currState?null===this.currState.InputPath?{}:this.jsonQuery(this.currState.InputPath,this.currInput):this.currInput}processPayloadTemplate(e,t){let r=Object.entries(e).map(([e,r])=>{let a=e,n=r;return isPlainObj(r)&&(n=this.processPayloadTemplate(r,t)),e.endsWith(".$")&&"string"==typeof r&&(a=e.replace(".$",""),n=this.jsonQuery(r,t)),[a,n]});return Object.fromEntries(r)}processInput(){this.currInput=this.processInputPath(),"Parameters"in this.currState&&"Map"!==this.currState.Type&&(this.currInput=this.processPayloadTemplate(this.currState.Parameters,this.currInput))}processResultPath(){if("ResultPath"in this.currState){if(null===this.currState.ResultPath)return this.rawInput;let e=this.currState.ResultPath.replace("$.","");if(isPlainObj(this.rawInput)){let t=cloneDeep__default.default(this.rawInput);return set__default.default(t,e,this.currResult)}}return this.currResult}processOutputPath(){return"OutputPath"in this.currState?null===this.currState.OutputPath?{}:this.jsonQuery(this.currState.OutputPath,this.currResult):this.currResult}processResult(){"ResultSelector"in this.currState&&(this.currResult=this.processPayloadTemplate(this.currState.ResultSelector,this.currResult)),this.currResult=this.processResultPath(),this.currResult=this.processOutputPath()}handleTaskState(e){var t=this;return _asyncToGenerator(function*(){var r,a;let n=t.currState,i=new LambdaClient,s=null==e?void 0:null==(r=e.overrides)?void 0:null==(a=r.taskResourceLocalHandlers)?void 0:a[t.currStateName];try{if(s){let u=yield s(t.currInput);t.currResult=u;return}let l=yield i.invokeFunction(n.Resource,t.currInput);t.currResult=l}catch(c){throw c instanceof LambdaExecutionError?console.error(c.toString()):console.error(c),c}})()}handleMapState(e){var t=this;return _asyncToGenerator(function*(){let r=t.currState,a=t.currInput;if(r.ItemsPath&&(a=t.jsonQuery(r.ItemsPath,t.currInput)),!Array.isArray(a))return;let n=(a,n)=>{let i;t.context.Map={Item:{Index:n,Value:a}},r.Parameters&&(i=t.processPayloadTemplate(r.Parameters,t.currInput));let s=new StateMachine(r.Iterator,t.validationOptions);return s.run(null!=i?i:a,e)},i=pLimit__default.default(r.MaxConcurrency||40),s=a.map((e,t)=>i(()=>n(e,t))),u=yield Promise.all(s);delete t.context.Map,t.currResult=u})()}handlePassState(e){var t=this;return _asyncToGenerator(function*(){let e=t.currState;e.Result?t.currResult=e.Result:t.currResult=t.currInput})()}handleWaitState(e){var t=this;return _asyncToGenerator(function*(){var r,a;let n=t.currState,i=null==e?void 0:null==(r=e.overrides)?void 0:null==(a=r.waitTimeOverrides)?void 0:a[t.currStateName];if(i){yield sleep(i),t.currResult=t.currInput;return}if(n.Seconds)yield sleep(1e3*n.Seconds);else if(n.Timestamp){let s=new Date(n.Timestamp),u=Date.now(),l=s.getTime()-u;yield sleep(l)}else if(n.SecondsPath){let c=t.jsonQuery(n.SecondsPath,t.currInput);yield sleep(1e3*c)}else if(n.TimestampPath){let o=t.jsonQuery(n.TimestampPath,t.currInput),h=new Date(o),p=Date.now(),m=h.getTime()-p;yield sleep(m)}t.currResult=t.currInput})()}handleChoiceState(e){var t=this;return _asyncToGenerator(function*(){let e=t.currState;for(let r of e.Choices){let a=testChoiceRule(r,t.currInput,t.jsonQuery);if(a){t.currStateName=r.Next,t.currResult=t.currInput;return}}if(e.Default){t.currStateName=e.Default,t.currResult=t.currInput;return}})()}handleSucceedState(e){var t=this;return _asyncToGenerator(function*(){t.currResult=t.currInput})()}handleFailState(e){return _asyncToGenerator(function*(){})()}jsonQuery(e,t){return e.startsWith("$$")?jsonpathPlus.JSONPath({path:e.slice(1),json:this.context,wrap:!1}):jsonpathPlus.JSONPath({path:e,json:t,wrap:!1})}constructor(e,t){let{isValid:r,errorsText:a}=aslValidator__default.default(e,_extends({checkArn:!0,checkPaths:!0},t));if(!r)throw Error(`State machine definition is invalid, see error(s) below:
3
- ${a("\n")}`);this.states=e.States,this.currStateName=e.StartAt,this.currState=this.states[this.currStateName],this.rawInput={},this.currInput={},this.currResult=null,this.context={},this.stateHandlers={Task:this.handleTaskState.bind(this),Map:this.handleMapState.bind(this),Pass:this.handlePassState.bind(this),Wait:this.handleWaitState.bind(this),Choice:this.handleChoiceState.bind(this),Succeed:this.handleSucceedState.bind(this),Fail:this.handleFailState.bind(this)},this.validationOptions=t}}exports.StateMachine=StateMachine;
package/build/main.d.ts DELETED
@@ -1,323 +0,0 @@
1
- declare type StateType = 'Task' | 'Map' | 'Pass' | 'Wait' | 'Choice' | 'Succeed' | 'Fail';
2
-
3
- interface BaseState {
4
- Type: StateType;
5
- Comment?: string;
6
- }
7
-
8
- declare type PayloadTemplate = object;
9
- interface CanHaveInputPath {
10
- InputPath?: string | null;
11
- }
12
- interface CanHaveParameters {
13
- Parameters?: PayloadTemplate;
14
- }
15
- interface CanHaveResultSelector {
16
- ResultSelector?: PayloadTemplate;
17
- }
18
- interface CanHaveResultPath {
19
- ResultPath?: string | null;
20
- }
21
- interface CanHaveOutputPath {
22
- OutputPath?: string | null;
23
- }
24
-
25
- declare type StringOperatorNames = 'StringEquals' | 'StringLessThan' | 'StringGreaterThan' | 'StringLessThanEquals' | 'StringGreaterThanEquals' | 'StringMatches';
26
- declare type StringPathOperatorNames = 'StringEqualsPath' | 'StringLessThanPath' | 'StringGreaterThanPath' | 'StringLessThanEqualsPath' | 'StringGreaterThanEqualsPath';
27
- declare type NumericOperatorNames = 'NumericEquals' | 'NumericLessThan' | 'NumericGreaterThan' | 'NumericLessThanEquals' | 'NumericGreaterThanEquals';
28
- declare type NumericPathOperatorNames = 'NumericEqualsPath' | 'NumericLessThanPath' | 'NumericGreaterThanPath' | 'NumericLessThanEqualsPath' | 'NumericGreaterThanEqualsPath';
29
- declare type BooleanOperatorNames = 'BooleanEquals';
30
- declare type BooleanPathOperatorNames = 'BooleanEqualsPath';
31
- declare type TimestampOperatorNames = 'TimestampEquals' | 'TimestampLessThan' | 'TimestampGreaterThan' | 'TimestampLessThanEquals' | 'TimestampGreaterThanEquals';
32
- declare type TimestampPathOperatorNames = 'TimestampEqualsPath' | 'TimestampLessThanPath' | 'TimestampGreaterThanPath' | 'TimestampLessThanEqualsPath' | 'TimestampGreaterThanEqualsPath';
33
- declare type TypeTestOperatorNames = 'IsNull' | 'IsPresent' | 'IsNumeric' | 'IsString' | 'IsBoolean' | 'IsTimestamp';
34
- declare type StringComparisonOperator = {
35
- [P in StringOperatorNames]?: string;
36
- };
37
- declare type StringPathComparisonOperator = {
38
- [P in StringPathOperatorNames]?: string;
39
- };
40
- declare type NumericComparisonOperator = {
41
- [P in NumericOperatorNames]?: number;
42
- };
43
- declare type NumericPathComparisonOperator = {
44
- [P in NumericPathOperatorNames]?: string;
45
- };
46
- declare type BooleanComparisonOperator = {
47
- [P in BooleanOperatorNames]?: boolean;
48
- };
49
- declare type BooleanPathComparisonOperator = {
50
- [P in BooleanPathOperatorNames]?: string;
51
- };
52
- declare type TimestampComparisonOperator = {
53
- [P in TimestampOperatorNames]?: string;
54
- };
55
- declare type TimestampPathComparisonOperator = {
56
- [P in TimestampPathOperatorNames]?: string;
57
- };
58
- declare type TypeTestComparisonOperator = {
59
- [P in TypeTestOperatorNames]?: true;
60
- };
61
- declare type ComparisonOperator = StringComparisonOperator | StringPathComparisonOperator | NumericComparisonOperator | NumericPathComparisonOperator | BooleanComparisonOperator | BooleanPathComparisonOperator | TimestampComparisonOperator | TimestampPathComparisonOperator | TypeTestComparisonOperator;
62
- declare type BaseDataTestExpression = {
63
- Variable: string;
64
- };
65
- declare type DataTestExpression = BaseDataTestExpression & ComparisonOperator;
66
- declare type BooleanExpression = {
67
- And?: ChoiceRuleWithoutNext[];
68
- Or?: ChoiceRuleWithoutNext[];
69
- Not?: ChoiceRuleWithoutNext;
70
- };
71
- declare type ChoiceRuleWithoutNext = DataTestExpression | BooleanExpression;
72
- declare type ChoiceRule = (DataTestExpression | BooleanExpression) & {
73
- Next: string;
74
- };
75
- interface BaseChoiceState extends BaseState, CanHaveInputPath, CanHaveOutputPath {
76
- Type: 'Choice';
77
- Choices: ChoiceRule[];
78
- Default?: string;
79
- }
80
- declare type ChoiceState = BaseChoiceState;
81
-
82
- interface EndableState extends BaseState {
83
- Type: Exclude<StateType, 'Choice' | 'Succeed' | 'Fail'>;
84
- End: true;
85
- }
86
- interface SucceedOrFailState extends BaseState {
87
- Type: Extract<StateType, 'Succeed' | 'Fail'>;
88
- }
89
- declare type TerminalState = EndableState | SucceedOrFailState;
90
-
91
- interface BaseFailState extends BaseState {
92
- Type: 'Fail';
93
- Cause?: string;
94
- Error?: string;
95
- }
96
- declare type FailState = TerminalState & BaseFailState;
97
-
98
- interface NextableState extends BaseState {
99
- Type: Exclude<StateType, 'Choice' | 'Succeed' | 'Fail'>;
100
- Next: string;
101
- }
102
- declare type IntermediateState = NextableState;
103
-
104
- interface BaseMapState extends BaseState, CanHaveInputPath, CanHaveParameters, CanHaveResultSelector, CanHaveResultPath, CanHaveOutputPath {
105
- Type: 'Map';
106
- Iterator: Omit<StateMachineDefinition, 'Version' | 'TimeoutSeconds'>;
107
- ItemsPath?: string;
108
- MaxConcurrency?: number;
109
- }
110
- declare type MapState = (IntermediateState | TerminalState) & BaseMapState;
111
-
112
- declare type JSONValue = null | boolean | number | string | object | any[];
113
-
114
- interface BasePassState extends BaseState, CanHaveInputPath, CanHaveParameters, CanHaveResultPath, CanHaveOutputPath {
115
- Type: 'Pass';
116
- Result?: JSONValue;
117
- }
118
- declare type PassState = (IntermediateState | TerminalState) & BasePassState;
119
-
120
- interface BaseSucceedState extends BaseState, CanHaveInputPath, CanHaveOutputPath {
121
- Type: 'Succeed';
122
- }
123
- declare type SucceedState = TerminalState & BaseSucceedState;
124
-
125
- interface BaseTaskState extends BaseState, CanHaveInputPath, CanHaveParameters, CanHaveResultSelector, CanHaveResultPath, CanHaveOutputPath {
126
- Type: 'Task';
127
- Resource: string;
128
- }
129
- declare type TaskState = (IntermediateState | TerminalState) & BaseTaskState;
130
-
131
- interface BaseWaitState extends BaseState, CanHaveInputPath, CanHaveOutputPath {
132
- Type: 'Wait';
133
- Seconds?: number;
134
- Timestamp?: string;
135
- SecondsPath?: string;
136
- TimestampPath?: string;
137
- }
138
- declare type WaitState = (IntermediateState | TerminalState) & BaseWaitState;
139
-
140
- declare type AllStates = TaskState | MapState | PassState | WaitState | ChoiceState | SucceedState | FailState;
141
-
142
- interface StateMachineDefinition {
143
- States: Record<string, AllStates>;
144
- StartAt: string;
145
- Comment?: string;
146
- Version?: string;
147
- TimeoutSeconds?: number;
148
- }
149
-
150
- declare type TaskStateResourceLocalHandler = {
151
- [taskStateName: string]: (...args: any) => any;
152
- };
153
- declare type WaitStateTimeOverride = {
154
- [waitStateName: string]: number;
155
- };
156
- interface Overrides {
157
- taskResourceLocalHandlers?: TaskStateResourceLocalHandler;
158
- waitTimeOverrides?: WaitStateTimeOverride;
159
- }
160
- interface RunOptions {
161
- overrides?: Overrides;
162
- }
163
- interface ValidationOptions {
164
- readonly checkPaths?: boolean;
165
- readonly checkArn?: boolean;
166
- }
167
-
168
- declare class StateMachine {
169
- /**
170
- * The name of the state currently being executed.
171
- */
172
- private currStateName;
173
- /**
174
- * The current state being executed.
175
- */
176
- private currState;
177
- /**
178
- * The unmodified input to the current state.
179
- */
180
- private rawInput;
181
- /**
182
- * The input that can be modified according to the `InputPath` and `Parameters` fields of the current state.
183
- */
184
- private currInput;
185
- /**
186
- * The result that can be modified according to the `ResultSelector`, `ResultPath` and `OutputPath` fields of the current state.
187
- */
188
- private currResult;
189
- /**
190
- * The context object of the state machine.
191
- */
192
- private context;
193
- /**
194
- * A map of all states defined in the state machine.
195
- */
196
- private readonly states;
197
- /**
198
- * A map of functions to handle each type of state.
199
- */
200
- private readonly stateHandlers;
201
- /**
202
- * Options to control whether to apply certain validations to the state machine definition.
203
- */
204
- private readonly validationOptions;
205
- /**
206
- * Constructs a new state machine.
207
- * @param definition The state machine definition defined using the Amazon States Language (https://states-language.net/spec.html).
208
- * @param validationOptions Options to control whether to apply certain validations to the definition.
209
- * These options also apply to state machines defined in the `Iterator` field of `Map` states.
210
- */
211
- constructor(definition: StateMachineDefinition, validationOptions?: ValidationOptions);
212
- /**
213
- * Executes the state machine, running through the states specified in the definiton.
214
- * @param input The input to pass to this state machine execution.
215
- * @param options Miscellaneous options to control certain behaviors of the execution.
216
- */
217
- run(input: JSONValue, options?: RunOptions): Promise<JSONValue>;
218
- /**
219
- * Process the current input according to the path defined in the `InputPath` field, if specified in the current state.
220
- * @returns
221
- * * If `InputPath` is not specified, returns the current input unmodified.
222
- * * If `InputPath` is `null`, returns an empty object (`{}`).
223
- * * If `InputPath` is a string, it's considered a JSONPath and the selected portion of the current input is returned.
224
- */
225
- private processInputPath;
226
- /**
227
- * Recursively process a payload template to resolve the properties that are JSONPaths.
228
- * @param payloadTemplate The payload template to process.
229
- * @param json The object to evaluate with JSONPath (whether of null, boolean, number, string, object, or array type).
230
- * @returns The processed payload template.
231
- */
232
- private processPayloadTemplate;
233
- /**
234
- * Process the current input according to the `InputPath` and `Parameters` fields.
235
- */
236
- private processInput;
237
- /**
238
- * Process the current result according to the path defined in the `ResultPath` field, if specified in the current state.
239
- * @returns
240
- * * If `ResultPath` is not specified, returns the current result unmodified.
241
- * * If `ResultPath` is `null`, returns the raw input (i.e. the input passed to current state).
242
- * * If `ResultPath` is a string, it's considered a JSONPath and returns a combination of the raw input with the current result,
243
- * by placing the current result in the specified path.
244
- */
245
- private processResultPath;
246
- /**
247
- * Process the current result according to the path defined in the `OutputPath` field, if specified in the current state.
248
- * @returns
249
- * * If `OutputPath` is not specified, returns the current result unmodified.
250
- * * If `OutputPath` is `null`, returns an empty object (`{}`).
251
- * * If `OutputPath` is a string, it's considered a JSONPath and the selected portion of the current result is returned.
252
- */
253
- private processOutputPath;
254
- /**
255
- * Process the current result according to the `ResultSelector`, `ResultPath` and `OutputPath` fields.
256
- */
257
- private processResult;
258
- /**
259
- * Handler for task states.
260
- *
261
- * Invokes the Lambda function specified in the `Resource` field
262
- * and sets the current result of the state machine to the value returned by the Lambda.
263
- */
264
- private handleTaskState;
265
- /**
266
- * Handler for map states.
267
- *
268
- * Iterates over the current input items or the items of an array specified
269
- * by the `ItemsPath` field, and then processes each item by passing it
270
- * as the input to the state machine specified in the `Iterator` field.
271
- */
272
- private handleMapState;
273
- /**
274
- * Handler for pass states.
275
- *
276
- * If the `Result` field is specified, copies `Result` into the current result.
277
- * Else, copies the current input into the current result.
278
- */
279
- private handlePassState;
280
- /**
281
- * Handler for wait states.
282
- *
283
- * Pauses the state machine execution for a certain amount of time
284
- * based on one of the `Seconds`, `Timestamp`, `SecondsPath` or `TimestampPath` fields.
285
- */
286
- private handleWaitState;
287
- /**
288
- * Handler for choice states.
289
- *
290
- * Evaluates each choice rule specified in the `Choices` field.
291
- *
292
- * If one of the rules matches, then the state machine transitions to the
293
- * state specified in the `Next` field for that choice rule.
294
- *
295
- * If no rule matches but the `Default` field is specified,
296
- * then the next state will be the state specified in said field.
297
- *
298
- * If no rule matches and the `Default` field is not specified, throws a
299
- * States.NoChoiceMatched error.
300
- */
301
- private handleChoiceState;
302
- /**
303
- * Handler for succeed states.
304
- *
305
- * Ends the state machine execution successfully.
306
- */
307
- private handleSucceedState;
308
- /**
309
- * Handler for fail states.
310
- *
311
- * Ends the state machine execution and marks it as a failure.
312
- */
313
- private handleFailState;
314
- /**
315
- * Queries for a property in an object using a JSONPath expression.
316
- * @param pathExpression The JSONPath expression to query for.
317
- * @param json The object to evaluate (whether of null, boolean, number, string, object, or array type).
318
- * @returns The value of the property that was queried for, if found. Otherwise returns `undefined`.
319
- */
320
- private jsonQuery;
321
- }
322
-
323
- export { StateMachine };
package/build/main.esm.js DELETED
@@ -1,3 +0,0 @@
1
- import{JSONPath as e}from"jsonpath-plus";import{LambdaClient as t,InvokeCommand as r}from"@aws-sdk/client-lambda";import a from"wildcard-match";import n from"asl-validator";import i from"lodash/set.js";import s from"lodash/cloneDeep.js";import u from"p-limit";function isPlainObj(e){return!!e&&Object.getPrototypeOf(e)===Object.prototype}function sleep(e){return new Promise(t=>{setTimeout(t,e)})}class CustomError extends Error{constructor(e){super(e)}}class LambdaExecutionError extends CustomError{toString(){return`${this.name}: ${this.message}. The error thrown by the Lambda was:
2
- ${this.wrappedError.stack}`}constructor(e,t){super(`Execution of Lambda function "${t}" failed`),this.name="LambdaExecutionError",this.wrappedError=Error(e.errorMessage),this.wrappedError.stack=e.trace.join("\n")}}function asyncGeneratorStep$1(e,t,r,a,n,i,s){try{var u=e[i](s),l=u.value}catch(o){r(o);return}u.done?t(l):Promise.resolve(l).then(a,n)}function _asyncToGenerator$1(e){return function(){var t=this,r=arguments;return new Promise(function(a,n){var i=e.apply(t,r);function s(e){asyncGeneratorStep$1(i,a,n,s,u,"next",e)}function u(e){asyncGeneratorStep$1(i,a,n,s,u,"throw",e)}s(void 0)})}}class LambdaClient{invokeFunction(e,t){var a=this;return _asyncToGenerator$1(function*(){let n=Buffer.from(JSON.stringify(t)),i=new r({FunctionName:e,Payload:n}),s=yield a.client.send(i),u=null;if(s.Payload&&(u=JSON.parse(u=Buffer.from(s.Payload).toString())),s.FunctionError)throw new LambdaExecutionError(u,e);return u})()}constructor(e){this.client=new t(null!=e?e:{})}}function testChoiceRule(e,t,r){if("And"in e)return e.And.every(e=>testChoiceRule(e,t,r));if("Or"in e)return e.Or.some(e=>testChoiceRule(e,t,r));if("Not"in e)return!testChoiceRule(e.Not,t,r);if("StringEquals"in e){let n=r(e.Variable,t);return n===e.StringEquals}if("StringEqualsPath"in e){let i=r(e.Variable,t),s=r(e.StringEqualsPath,t);return i===s}if("StringLessThan"in e){let u=r(e.Variable,t);return u<e.StringLessThan}if("StringLessThanPath"in e){let l=r(e.Variable,t),o=r(e.StringLessThanPath,t);return l<o}if("StringGreaterThan"in e){let c=r(e.Variable,t);return c>e.StringGreaterThan}if("StringGreaterThanPath"in e){let h=r(e.Variable,t),p=r(e.StringGreaterThanPath,t);return h>p}if("StringLessThanEquals"in e){let m=r(e.Variable,t);return m<=e.StringLessThanEquals}if("StringLessThanEqualsPath"in e){let f=r(e.Variable,t),d=r(e.StringLessThanEqualsPath,t);return f<=d}if("StringGreaterThanEquals"in e){let T=r(e.Variable,t);return T>=e.StringGreaterThanEquals}if("StringGreaterThanEqualsPath"in e){let S=r(e.Variable,t),P=r(e.StringGreaterThanEqualsPath,t);return S>=P}if("StringMatches"in e){let b=r(e.Variable,t),y=a(e.StringMatches,{separator:!1});return y(b)}if("NumericEquals"in e){let E=r(e.Variable,t);return E===e.NumericEquals}if("NumericEqualsPath"in e){let w=r(e.Variable,t),I=r(e.NumericEqualsPath,t);return w===I}if("NumericLessThan"in e){let g=r(e.Variable,t);return g<e.NumericLessThan}if("NumericLessThanPath"in e){let v=r(e.Variable,t),G=r(e.NumericLessThanPath,t);return v<G}if("NumericGreaterThan"in e){let q=r(e.Variable,t);return q>e.NumericGreaterThan}if("NumericGreaterThanPath"in e){let N=r(e.Variable,t),R=r(e.NumericGreaterThanPath,t);return N>R}if("NumericLessThanEquals"in e){let V=r(e.Variable,t);return V<=e.NumericLessThanEquals}if("NumericLessThanEqualsPath"in e){let L=r(e.Variable,t),D=r(e.NumericLessThanEqualsPath,t);return L<=D}if("NumericGreaterThanEquals"in e){let O=r(e.Variable,t);return O>=e.NumericGreaterThanEquals}if("NumericGreaterThanEqualsPath"in e){let j=r(e.Variable,t),x=r(e.NumericGreaterThanEqualsPath,t);return j>=x}if("BooleanEquals"in e){let C=r(e.Variable,t);return C===e.BooleanEquals}if("BooleanEqualsPath"in e){let $=r(e.Variable,t),_=r(e.BooleanEqualsPath,t);return $===_}if("TimestampEquals"in e){let M=new Date(r(e.Variable,t)),k=new Date(e.TimestampEquals);return M.getTime()===k.getTime()}if("TimestampEqualsPath"in e){let B=new Date(r(e.Variable,t)),F=new Date(r(e.TimestampEqualsPath,t));return B.getTime()===F.getTime()}if("TimestampLessThan"in e){let Q=new Date(r(e.Variable,t)),A=new Date(e.TimestampLessThan);return Q<A}if("TimestampLessThanPath"in e){let W=new Date(r(e.Variable,t)),H=new Date(r(e.TimestampLessThanPath,t));return W<H}if("TimestampGreaterThan"in e){let J=new Date(r(e.Variable,t)),Z=new Date(e.TimestampGreaterThan);return J>Z}if("TimestampGreaterThanPath"in e){let z=new Date(r(e.Variable,t)),K=new Date(r(e.TimestampGreaterThanPath,t));return z>K}if("TimestampLessThanEquals"in e){let U=new Date(r(e.Variable,t)),X=new Date(e.TimestampLessThanEquals);return U<=X}if("TimestampLessThanEqualsPath"in e){let Y=new Date(r(e.Variable,t)),ee=new Date(r(e.TimestampLessThanEqualsPath,t));return Y<=ee}if("TimestampGreaterThanEquals"in e){let et=new Date(r(e.Variable,t)),er=new Date(e.TimestampGreaterThanEquals);return et>=er}if("TimestampGreaterThanEqualsPath"in e){let ea=new Date(r(e.Variable,t)),en=new Date(r(e.TimestampGreaterThanEqualsPath,t));return ea>=en}if("IsNull"in e){let ei=r(e.Variable,t),es=e.IsNull;return es&&null===ei}if("IsPresent"in e){let eu=r(e.Variable,t),el=e.IsPresent;return el&&!!eu}if("IsNumeric"in e){let eo=r(e.Variable,t),ec=e.IsNumeric;return ec&&"number"==typeof eo}if("IsString"in e){let eh=r(e.Variable,t),ep=e.IsString;return ep&&"string"==typeof eh}if("IsBoolean"in e){let em=r(e.Variable,t),ef=e.IsBoolean;return ef&&"boolean"==typeof em}if("IsTimestamp"in e){let ed=r(e.Variable,t),eT=e.IsTimestamp;return eT&&/\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(Z|(\+|-)\d{2}:\d{2})/.test(ed)}return!1}function asyncGeneratorStep(e,t,r,a,n,i,s){try{var u=e[i](s),l=u.value}catch(o){r(o);return}u.done?t(l):Promise.resolve(l).then(a,n)}function _asyncToGenerator(e){return function(){var t=this,r=arguments;return new Promise(function(a,n){var i=e.apply(t,r);function s(e){asyncGeneratorStep(i,a,n,s,u,"next",e)}function u(e){asyncGeneratorStep(i,a,n,s,u,"throw",e)}s(void 0)})}}function _extends(){return(_extends=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var a in r)Object.prototype.hasOwnProperty.call(r,a)&&(e[a]=r[a])}return e}).apply(this,arguments)}class StateMachine{run(e,t){var r=this;return _asyncToGenerator(function*(){r.rawInput=e,r.currInput=e;let a=!1;do r.currState=r.states[r.currStateName],r.processInput(),yield r.stateHandlers[r.currState.Type](t),r.processResult(),r.rawInput=r.currResult,r.currInput=r.currResult,"Next"in r.currState&&(r.currStateName=r.currState.Next),("End"in r.currState||"Succeed"===r.currState.Type||"Fail"===r.currState.Type)&&(a=!0);while(!a);return r.currResult})()}processInputPath(){return"InputPath"in this.currState?null===this.currState.InputPath?{}:this.jsonQuery(this.currState.InputPath,this.currInput):this.currInput}processPayloadTemplate(e,t){let r=Object.entries(e).map(([e,r])=>{let a=e,n=r;return isPlainObj(r)&&(n=this.processPayloadTemplate(r,t)),e.endsWith(".$")&&"string"==typeof r&&(a=e.replace(".$",""),n=this.jsonQuery(r,t)),[a,n]});return Object.fromEntries(r)}processInput(){this.currInput=this.processInputPath(),"Parameters"in this.currState&&"Map"!==this.currState.Type&&(this.currInput=this.processPayloadTemplate(this.currState.Parameters,this.currInput))}processResultPath(){if("ResultPath"in this.currState){if(null===this.currState.ResultPath)return this.rawInput;let e=this.currState.ResultPath.replace("$.","");if(isPlainObj(this.rawInput)){let t=s(this.rawInput);return i(t,e,this.currResult)}}return this.currResult}processOutputPath(){return"OutputPath"in this.currState?null===this.currState.OutputPath?{}:this.jsonQuery(this.currState.OutputPath,this.currResult):this.currResult}processResult(){"ResultSelector"in this.currState&&(this.currResult=this.processPayloadTemplate(this.currState.ResultSelector,this.currResult)),this.currResult=this.processResultPath(),this.currResult=this.processOutputPath()}handleTaskState(e){var t=this;return _asyncToGenerator(function*(){var r,a;let n=t.currState,i=new LambdaClient,s=null==e?void 0:null==(r=e.overrides)?void 0:null==(a=r.taskResourceLocalHandlers)?void 0:a[t.currStateName];try{if(s){let u=yield s(t.currInput);t.currResult=u;return}let l=yield i.invokeFunction(n.Resource,t.currInput);t.currResult=l}catch(o){throw o instanceof LambdaExecutionError?console.error(o.toString()):console.error(o),o}})()}handleMapState(e){var t=this;return _asyncToGenerator(function*(){let r=t.currState,a=t.currInput;if(r.ItemsPath&&(a=t.jsonQuery(r.ItemsPath,t.currInput)),!Array.isArray(a))return;let n=(a,n)=>{let i;t.context.Map={Item:{Index:n,Value:a}},r.Parameters&&(i=t.processPayloadTemplate(r.Parameters,t.currInput));let s=new StateMachine(r.Iterator,t.validationOptions);return s.run(null!=i?i:a,e)},i=u(r.MaxConcurrency||40),s=a.map((e,t)=>i(()=>n(e,t))),l=yield Promise.all(s);delete t.context.Map,t.currResult=l})()}handlePassState(e){var t=this;return _asyncToGenerator(function*(){let e=t.currState;e.Result?t.currResult=e.Result:t.currResult=t.currInput})()}handleWaitState(e){var t=this;return _asyncToGenerator(function*(){var r,a;let n=t.currState,i=null==e?void 0:null==(r=e.overrides)?void 0:null==(a=r.waitTimeOverrides)?void 0:a[t.currStateName];if(i){yield sleep(i),t.currResult=t.currInput;return}if(n.Seconds)yield sleep(1e3*n.Seconds);else if(n.Timestamp){let s=new Date(n.Timestamp),u=Date.now(),l=s.getTime()-u;yield sleep(l)}else if(n.SecondsPath){let o=t.jsonQuery(n.SecondsPath,t.currInput);yield sleep(1e3*o)}else if(n.TimestampPath){let c=t.jsonQuery(n.TimestampPath,t.currInput),h=new Date(c),p=Date.now(),m=h.getTime()-p;yield sleep(m)}t.currResult=t.currInput})()}handleChoiceState(e){var t=this;return _asyncToGenerator(function*(){let e=t.currState;for(let r of e.Choices){let a=testChoiceRule(r,t.currInput,t.jsonQuery);if(a){t.currStateName=r.Next,t.currResult=t.currInput;return}}if(e.Default){t.currStateName=e.Default,t.currResult=t.currInput;return}})()}handleSucceedState(e){var t=this;return _asyncToGenerator(function*(){t.currResult=t.currInput})()}handleFailState(e){return _asyncToGenerator(function*(){})()}jsonQuery(t,r){return t.startsWith("$$")?e({path:t.slice(1),json:this.context,wrap:!1}):e({path:t,json:r,wrap:!1})}constructor(e,t){let{isValid:r,errorsText:a}=n(e,_extends({checkArn:!0,checkPaths:!0},t));if(!r)throw Error(`State machine definition is invalid, see error(s) below:
3
- ${a("\n")}`);this.states=e.States,this.currStateName=e.StartAt,this.currState=this.states[this.currStateName],this.rawInput={},this.currInput={},this.currResult=null,this.context={},this.stateHandlers={Task:this.handleTaskState.bind(this),Map:this.handleMapState.bind(this),Pass:this.handlePassState.bind(this),Wait:this.handleWaitState.bind(this),Choice:this.handleChoiceState.bind(this),Succeed:this.handleSucceedState.bind(this),Fail:this.handleFailState.bind(this)},this.validationOptions=t}}export{StateMachine};