aws-local-stepfunctions 0.1.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.
- package/LICENSE +21 -0
- package/README.md +7 -0
- package/build/main.cjs +3 -0
- package/build/main.d.ts +323 -0
- package/build/main.esm.js +3 -0
- package/package.json +65 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2022 Luis De Anda
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
package/build/main.cjs
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
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");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);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),b=wcmatch__default.default(e.StringMatches,{separator:!1});return b(P)}if("NumericEquals"in e){let y=r(e.Variable,t);return y===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 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 V=r(e.Variable,t),L=r(e.NumericGreaterThanPath,t);return V>L}if("NumericLessThanEquals"in e){let N=r(e.Variable,t);return N<=e.NumericLessThanEquals}if("NumericLessThanEqualsPath"in e){let G=r(e.Variable,t),R=r(e.NumericLessThanEqualsPath,t);return G<=R}if("NumericGreaterThanEquals"in e){let _=r(e.Variable,t);return _>=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 $=new Date(r(e.Variable,t)),M=new Date(e.TimestampEquals);return $.getTime()===M.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 H=new Date(r(e.Variable,t)),J=new Date(e.TimestampGreaterThan);return H>J}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*(){let r=t.currState,a=new LambdaClient;try{var n,i,s,u;if(null==e?void 0:null==(n=e.overrides)?void 0:null==(i=n.taskResourceLocalHandlers)?void 0:i[t.currStateName]){let l=null==e?void 0:null==(s=e.overrides)?void 0:null==(u=s.taskResourceLocalHandlers)?void 0:u[t.currStateName],c=yield l(t.currInput);t.currResult=c;return}let o=yield a.invokeFunction(r.Resource,t.currInput);t.currResult=o}catch(h){throw h instanceof LambdaExecutionError?console.error(h.toString()):console.error(h),h}})()}handleMapState(e){var t=this;return _asyncToGenerator(function*(){let r;let a=t.currState,n=t.currInput;if(a.ItemsPath&&(n=t.jsonQuery(a.ItemsPath,t.currInput)),!Array.isArray(n))return;let i=Array(n.length);for(let s=0;s<n.length;s++){let u=n[s];t.context.Map={Item:{Index:s,Value:u}},a.Parameters&&(r=t.processPayloadTemplate(a.Parameters,t.currInput));let l=new StateMachine(a.Iterator,t.validationOptions);i[s]=yield l.run(null!=r?r:u,e)}delete t.context.Map,t.currResult=i})()}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("number"==typeof 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
ADDED
|
@@ -0,0 +1,323 @@
|
|
|
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 };
|
|
@@ -0,0 +1,3 @@
|
|
|
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";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 v=r(e.Variable,t);return v<e.NumericLessThan}if("NumericLessThanPath"in e){let g=r(e.Variable,t),G=r(e.NumericLessThanPath,t);return g<G}if("NumericGreaterThan"in e){let N=r(e.Variable,t);return N>e.NumericGreaterThan}if("NumericGreaterThanPath"in e){let R=r(e.Variable,t),q=r(e.NumericGreaterThanPath,t);return R>q}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 $=r(e.Variable,t);return $===e.BooleanEquals}if("BooleanEqualsPath"in e){let C=r(e.Variable,t),_=r(e.BooleanEqualsPath,t);return C===_}if("TimestampEquals"in e){let k=new Date(r(e.Variable,t)),M=new Date(e.TimestampEquals);return k.getTime()===M.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*(){let r=t.currState,a=new LambdaClient;try{var n,i,s,u;if(null==e?void 0:null==(n=e.overrides)?void 0:null==(i=n.taskResourceLocalHandlers)?void 0:i[t.currStateName]){let l=null==e?void 0:null==(s=e.overrides)?void 0:null==(u=s.taskResourceLocalHandlers)?void 0:u[t.currStateName],o=yield l(t.currInput);t.currResult=o;return}let c=yield a.invokeFunction(r.Resource,t.currInput);t.currResult=c}catch(h){throw h instanceof LambdaExecutionError?console.error(h.toString()):console.error(h),h}})()}handleMapState(e){var t=this;return _asyncToGenerator(function*(){let r;let a=t.currState,n=t.currInput;if(a.ItemsPath&&(n=t.jsonQuery(a.ItemsPath,t.currInput)),!Array.isArray(n))return;let i=Array(n.length);for(let s=0;s<n.length;s++){let u=n[s];t.context.Map={Item:{Index:s,Value:u}},a.Parameters&&(r=t.processPayloadTemplate(a.Parameters,t.currInput));let l=new StateMachine(a.Iterator,t.validationOptions);i[s]=yield l.run(null!=r?r:u,e)}delete t.context.Map,t.currResult=i})()}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("number"==typeof 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};
|
package/package.json
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "aws-local-stepfunctions",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Execute an AWS Step Function locally",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"aws",
|
|
7
|
+
"local",
|
|
8
|
+
"stepfunctions",
|
|
9
|
+
"asl",
|
|
10
|
+
"amazon states language",
|
|
11
|
+
"state machine"
|
|
12
|
+
],
|
|
13
|
+
"author": {
|
|
14
|
+
"name": "Luis De Anda",
|
|
15
|
+
"email": "ldeandac16@gmail.com",
|
|
16
|
+
"url": "https://github.com/nibble-4bits"
|
|
17
|
+
},
|
|
18
|
+
"homepage": "https://github.com/nibble-4bits/aws-local-stepfunctions",
|
|
19
|
+
"repository": {
|
|
20
|
+
"type": "git",
|
|
21
|
+
"url": "https://github.com/nibble-4bits/aws-local-stepfunctions.git"
|
|
22
|
+
},
|
|
23
|
+
"license": "MIT",
|
|
24
|
+
"files": [
|
|
25
|
+
"build"
|
|
26
|
+
],
|
|
27
|
+
"type": "module",
|
|
28
|
+
"main": "build/main.cjs",
|
|
29
|
+
"types": "build/main.d.ts",
|
|
30
|
+
"exports": {
|
|
31
|
+
"require": "./build/main.cjs",
|
|
32
|
+
"import": "./build/main.esm.js",
|
|
33
|
+
"default": "./build/main.esm.js"
|
|
34
|
+
},
|
|
35
|
+
"scripts": {
|
|
36
|
+
"test": "jest",
|
|
37
|
+
"build": "bunchee --target es2015 --minify src/main.ts",
|
|
38
|
+
"prettier": "prettier --write src/**/*.ts",
|
|
39
|
+
"lint": "eslint src/**/*.ts",
|
|
40
|
+
"lint:fix": "eslint src/**/*.ts --fix"
|
|
41
|
+
},
|
|
42
|
+
"devDependencies": {
|
|
43
|
+
"@tsconfig/node16-strictest": "^1.0.4",
|
|
44
|
+
"@types/jest": "^29.0.3",
|
|
45
|
+
"@types/lodash": "^4.14.184",
|
|
46
|
+
"@types/node": "^17.0.31",
|
|
47
|
+
"@types/picomatch": "^2.3.0",
|
|
48
|
+
"@typescript-eslint/eslint-plugin": "^5.22.0",
|
|
49
|
+
"@typescript-eslint/parser": "^5.22.0",
|
|
50
|
+
"bunchee": "^2.1.7",
|
|
51
|
+
"eslint": "^8.14.0",
|
|
52
|
+
"eslint-config-prettier": "^8.5.0",
|
|
53
|
+
"eslint-plugin-prettier": "^4.0.0",
|
|
54
|
+
"prettier": "^2.6.2",
|
|
55
|
+
"ts-jest": "^29.0.3",
|
|
56
|
+
"typescript": "^4.6.4"
|
|
57
|
+
},
|
|
58
|
+
"dependencies": {
|
|
59
|
+
"@aws-sdk/client-lambda": "^3.165.0",
|
|
60
|
+
"asl-validator": "^3.0.8",
|
|
61
|
+
"jsonpath-plus": "^6.0.1",
|
|
62
|
+
"lodash": "^4.17.21",
|
|
63
|
+
"wildcard-match": "^5.1.2"
|
|
64
|
+
}
|
|
65
|
+
}
|