aws-local-stepfunctions 0.4.0 → 0.6.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/README.md +44 -21
- package/build/main.browser.esm.js +27574 -0
- package/build/main.d.ts +91 -50
- package/build/{main.cjs → main.node.cjs} +846 -49
- package/build/{main.esm.js → main.node.esm.js} +845 -49
- package/package.json +30 -23
package/README.md
CHANGED
|
@@ -2,11 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
A TypeScript implementation of the [Amazon States Language specification](https://states-language.net/spec.html).
|
|
4
4
|
|
|
5
|
-
This package lets you run AWS Step Functions locally
|
|
5
|
+
This package lets you run AWS Step Functions completely locally, both in Node.js and in the browser!
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
## Table of Contents
|
|
7
|
+
## Table of contents
|
|
10
8
|
|
|
11
9
|
- [Features](#features)
|
|
12
10
|
- [Installation](#installation)
|
|
@@ -14,15 +12,16 @@ This package lets you run AWS Step Functions locally on your machine!
|
|
|
14
12
|
- [Node.js](#nodejs)
|
|
15
13
|
- [CommonJS](#commonjs)
|
|
16
14
|
- [ES Module](#es-module)
|
|
15
|
+
- [Browser](#browser)
|
|
17
16
|
- [API](#api)
|
|
18
|
-
- [Constructor](#constructor-new-statemachinedefinition-
|
|
17
|
+
- [Constructor](#constructor-new-statemachinedefinition-statemachineoptions)
|
|
19
18
|
- [StateMachine.run](#statemachineruninput-options)
|
|
20
19
|
- [Examples](#examples)
|
|
21
20
|
- [License](#license)
|
|
22
21
|
|
|
23
22
|
## Features
|
|
24
23
|
|
|
25
|
-
To see
|
|
24
|
+
To see the list of features defined in the specification that have full support, partial support, or no support, refer to [this document](/docs/feature-support.md).
|
|
26
25
|
|
|
27
26
|
## Installation
|
|
28
27
|
|
|
@@ -32,8 +31,6 @@ npm install aws-local-stepfunctions
|
|
|
32
31
|
|
|
33
32
|
## Importing
|
|
34
33
|
|
|
35
|
-
Currently, the only supported environment to import the package is Node.js. Browser support is not available yet.
|
|
36
|
-
|
|
37
34
|
### Node.js
|
|
38
35
|
|
|
39
36
|
#### CommonJS
|
|
@@ -48,20 +45,44 @@ const { StateMachine } = require('aws-local-stepfunctions');
|
|
|
48
45
|
import { StateMachine } from 'aws-local-stepfunctions';
|
|
49
46
|
```
|
|
50
47
|
|
|
48
|
+
### Browser
|
|
49
|
+
|
|
50
|
+
You can import the bundled package directly into a browser script as an ES module, from one of the following CDNs:
|
|
51
|
+
|
|
52
|
+
> NOTE: The following examples will import the latest package version. Refer to the CDNs websites to know about other ways in which you can specify the package URL (for example, to import a specific version).
|
|
53
|
+
|
|
54
|
+
#### [unpkg](https://unpkg.com/)
|
|
55
|
+
|
|
56
|
+
```js
|
|
57
|
+
import { StateMachine } from 'https://unpkg.com/aws-local-stepfunctions';
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
#### [jsDelivr](https://www.jsdelivr.com/)
|
|
61
|
+
|
|
62
|
+
```js
|
|
63
|
+
import { StateMachine } from 'https://cdn.jsdelivr.net/npm/aws-local-stepfunctions/build/main.browser.esm.js';
|
|
64
|
+
```
|
|
65
|
+
|
|
51
66
|
## API
|
|
52
67
|
|
|
53
|
-
### Constructor: `new StateMachine(definition[,
|
|
68
|
+
### Constructor: `new StateMachine(definition[, stateMachineOptions])`
|
|
54
69
|
|
|
55
70
|
#### Parameters
|
|
56
71
|
|
|
57
72
|
The constructor takes the following parameters:
|
|
58
73
|
|
|
59
74
|
- `definition`: The Amazon States Language definition of the state machine.
|
|
60
|
-
- `
|
|
61
|
-
- `
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
75
|
+
- `stateMachineOptions?`:
|
|
76
|
+
- `validationOptions?`: An object that specifies how the definition should be validated.
|
|
77
|
+
- `checkPaths`: If set to `false`, won't validate JSONPaths.
|
|
78
|
+
- `checkArn`: If set to `false`, won't validate ARN syntax in `Task` states.
|
|
79
|
+
- `awsConfig?`: An object that specifies the [AWS region and credentials](/docs/feature-support.md#providing-aws-credentials-and-region-to-execute-lambda-functions-specified-in-task-states) to use when invoking a Lambda function in a `Task` state. If not set, the AWS config will be resolved based on the [credentials provider chain](https://docs.aws.amazon.com/sdk-for-javascript/v3/developer-guide/setting-credentials-node.html) of the AWS SDK for JavaScript V3. You don't need to use this option if you have a [shared config/credentials file](https://docs.aws.amazon.com/sdkref/latest/guide/file-format.html) (for example, if you have the [AWS CLI](https://aws.amazon.com/cli/) installed) or if you use a local override for all of your `Task` states.
|
|
80
|
+
- `region`: The AWS region where the Lambda functions are created.
|
|
81
|
+
- `credentials`: An object that specifies which type of credentials to use.
|
|
82
|
+
- `cognitoIdentityPool`: An object that specifies the Cognito Identity Pool ID to use for requesting credentials.
|
|
83
|
+
- `accessKeys`: An object that specifies the Access Key ID and Secret Access Key to use as credentials.
|
|
84
|
+
|
|
85
|
+
The constructor will attempt to validate the definition by default, unless the `validationOptions` property is specified. If the definition is not valid, an error will be thrown.
|
|
65
86
|
|
|
66
87
|
#### Example
|
|
67
88
|
|
|
@@ -81,14 +102,16 @@ const machineDefinition = {
|
|
|
81
102
|
};
|
|
82
103
|
|
|
83
104
|
// Instantiate a new state machine with the given definition and don't validate JSONPaths.
|
|
84
|
-
const stateMachine = new StateMachine(machineDefinition, {
|
|
105
|
+
const stateMachine = new StateMachine(machineDefinition, {
|
|
106
|
+
validationOptions: { checkPaths: false },
|
|
107
|
+
});
|
|
85
108
|
```
|
|
86
109
|
|
|
87
110
|
### `StateMachine.run(input[, options])`
|
|
88
111
|
|
|
89
112
|
Runs the state machine with the given `input` parameter and returns an object with the following properties:
|
|
90
113
|
|
|
91
|
-
- `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.
|
|
114
|
+
- `abort`: A function that takes no parameters and doesn't return any value. If called, [aborts the execution](/docs/feature-support.md#abort-a-running-execution) and throws an `ExecutionAbortedError`, unless the `noThrowOnAbort` option is set.
|
|
92
115
|
- `result`: A `Promise` that resolves with the execution result once it finishes.
|
|
93
116
|
|
|
94
117
|
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.
|
|
@@ -96,11 +119,11 @@ Each execution is independent of all others, meaning that you can concurrently c
|
|
|
96
119
|
#### Parameters
|
|
97
120
|
|
|
98
121
|
- `input`: The initial input to pass to the state machine. This can be any valid JSON value.
|
|
99
|
-
- `options
|
|
100
|
-
- `overrides
|
|
101
|
-
- `taskResourceLocalHandlers
|
|
102
|
-
- `waitTimeOverrides
|
|
103
|
-
- `noThrowOnAbort
|
|
122
|
+
- `options?`:
|
|
123
|
+
- `overrides?`: An object to override the behavior of certain states:
|
|
124
|
+
- `taskResourceLocalHandlers?`: An [object that overrides](/docs/feature-support.md#task-state-resource-override) the resource of the specified `Task` states to run a local function.
|
|
125
|
+
- `waitTimeOverrides?`: An [object that overrides](/docs/feature-support.md#wait-state-duration-override) the wait duration of the specified `Wait` states. The specifed override duration should be in milliseconds.
|
|
126
|
+
- `noThrowOnAbort?`: If this option is set to `true`, aborting the execution will simply return `null` as result instead of throwing.
|
|
104
127
|
|
|
105
128
|
#### Basic example:
|
|
106
129
|
|