aws-local-stepfunctions 0.4.0 → 0.5.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 CHANGED
@@ -2,7 +2,7 @@
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 on your machine!
5
+ This package lets you run AWS Step Functions locally, both in Node.js and in the browser!
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
 
@@ -14,8 +14,9 @@ This package lets you run AWS Step Functions locally on your machine!
14
14
  - [Node.js](#nodejs)
15
15
  - [CommonJS](#commonjs)
16
16
  - [ES Module](#es-module)
17
+ - [Browser](#browser)
17
18
  - [API](#api)
18
- - [Constructor](#constructor-new-statemachinedefinition-validationoptions)
19
+ - [Constructor](#constructor-new-statemachinedefinition-statemachineoptions)
19
20
  - [StateMachine.run](#statemachineruninput-options)
20
21
  - [Examples](#examples)
21
22
  - [License](#license)
@@ -32,8 +33,6 @@ npm install aws-local-stepfunctions
32
33
 
33
34
  ## Importing
34
35
 
35
- Currently, the only supported environment to import the package is Node.js. Browser support is not available yet.
36
-
37
36
  ### Node.js
38
37
 
39
38
  #### CommonJS
@@ -48,20 +47,44 @@ const { StateMachine } = require('aws-local-stepfunctions');
48
47
  import { StateMachine } from 'aws-local-stepfunctions';
49
48
  ```
50
49
 
50
+ ### Browser
51
+
52
+ You can import the bundled package directly into a browser script as an ES module, from one of the following CDNs:
53
+
54
+ > 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).
55
+
56
+ #### [unpkg](https://unpkg.com/)
57
+
58
+ ```js
59
+ import { StateMachine } from 'https://unpkg.com/aws-local-stepfunctions';
60
+ ```
61
+
62
+ #### [jsDelivr](https://www.jsdelivr.com/)
63
+
64
+ ```js
65
+ import { StateMachine } from 'https://cdn.jsdelivr.net/npm/aws-local-stepfunctions/build/main.browser.esm.js';
66
+ ```
67
+
51
68
  ## API
52
69
 
53
- ### Constructor: `new StateMachine(definition[, validationOptions])`
70
+ ### Constructor: `new StateMachine(definition[, stateMachineOptions])`
54
71
 
55
72
  #### Parameters
56
73
 
57
74
  The constructor takes the following parameters:
58
75
 
59
76
  - `definition`: The Amazon States Language definition of the state machine.
60
- - `validationOptions` (optional): An object that specifies how the definition should be validated.
61
- - `checkPaths`: If set to `false`, won't validate JSONPaths.
62
- - `checkArn`: If set to `false`, won't validate ARN syntax in `Task` states.
63
-
64
- 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.
77
+ - `stateMachineOptions?`:
78
+ - `validationOptions?`: An object that specifies how the definition should be validated.
79
+ - `checkPaths`: If set to `false`, won't validate JSONPaths.
80
+ - `checkArn`: If set to `false`, won't validate ARN syntax in `Task` states.
81
+ - `awsConfig?`: An object that specifies the AWS region and credentials 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.
82
+ - `region`: The AWS region where the Lambda functions are created.
83
+ - `credentials`: An object that specifies which type of credentials to use.
84
+ - `cognitoIdentityPool`: An object that specifies the Cognito Identity Pool to use for requesting credentials.
85
+ - `accessKeys`: An object that specifies the [Access Key ID and Secret Access Key](https://docs.aws.amazon.com/IAM/latest/UserGuide/security-creds.html#sec-access-keys-and-secret-access-keys) to use as credentials.
86
+
87
+ 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
88
 
66
89
  #### Example
67
90
 
@@ -81,7 +104,9 @@ const machineDefinition = {
81
104
  };
82
105
 
83
106
  // Instantiate a new state machine with the given definition and don't validate JSONPaths.
84
- const stateMachine = new StateMachine(machineDefinition, { checkPaths: false });
107
+ const stateMachine = new StateMachine(machineDefinition, {
108
+ validationOptions: { checkPaths: false },
109
+ });
85
110
  ```
86
111
 
87
112
  ### `StateMachine.run(input[, options])`
@@ -96,11 +121,11 @@ Each execution is independent of all others, meaning that you can concurrently c
96
121
  #### Parameters
97
122
 
98
123
  - `input`: The initial input to pass to the state machine. This can be any valid JSON value.
99
- - `options` (optional):
100
- - `overrides`: An object to override the behavior of certain states:
101
- - `taskResourceLocalHandlers`: Overrides the resource of the specified `Task` states to run a local function.
102
- - `waitTimeOverrides`: Overrides the wait duration of the specified `Wait` states. The specifed override duration should be in milliseconds.
103
- - `noThrowOnAbort`: If this option is set to `true`, aborting the execution will simply return `null` as result instead of throwing.
124
+ - `options?`:
125
+ - `overrides?`: An object to override the behavior of certain states:
126
+ - `taskResourceLocalHandlers?`: Overrides the resource of the specified `Task` states to run a local function.
127
+ - `waitTimeOverrides?`: Overrides the wait duration of the specified `Wait` states. The specifed override duration should be in milliseconds.
128
+ - `noThrowOnAbort?`: If this option is set to `true`, aborting the execution will simply return `null` as result instead of throwing.
104
129
 
105
130
  #### Basic example:
106
131