aws-local-stepfunctions 0.6.0 → 1.0.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 +249 -4
- package/build/CLI.cjs +279 -0
- package/build/main.browser.esm.js +349 -98
- package/build/main.d.ts +97 -21
- package/build/main.node.cjs +349 -98
- package/build/main.node.esm.js +349 -98
- package/package.json +9 -2
package/build/main.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { FromCognitoIdentityPoolParameters } from '@aws-sdk/credential-provider-cognito-identity/dist-types/fromCognitoIdentityPool';
|
|
2
|
-
import {
|
|
2
|
+
import { AwsCredentialIdentity } from '@aws-sdk/types/dist-types/identity/AwsCredentialIdentity';
|
|
3
3
|
|
|
4
4
|
type StateType = 'Task' | 'Parallel' | 'Map' | 'Pass' | 'Wait' | 'Choice' | 'Succeed' | 'Fail';
|
|
5
5
|
|
|
@@ -122,6 +122,10 @@ type Catcher = {
|
|
|
122
122
|
interface CatchableState {
|
|
123
123
|
Catch?: Catcher[];
|
|
124
124
|
}
|
|
125
|
+
type ErrorOutput = {
|
|
126
|
+
Error: string;
|
|
127
|
+
Cause?: string;
|
|
128
|
+
};
|
|
125
129
|
|
|
126
130
|
interface NextableState extends BaseState {
|
|
127
131
|
Type: Exclude<StateType, 'Choice' | 'Succeed' | 'Fail'>;
|
|
@@ -179,6 +183,87 @@ interface StateMachineDefinition {
|
|
|
179
183
|
TimeoutSeconds?: number;
|
|
180
184
|
}
|
|
181
185
|
|
|
186
|
+
type ExecutionStartedEventType = 'ExecutionStarted';
|
|
187
|
+
type ExecutionSucceededEventType = 'ExecutionSucceeded';
|
|
188
|
+
type ExecutionFailedEventType = 'ExecutionFailed';
|
|
189
|
+
type ExecutionTerminatedEventType = 'ExecutionAborted' | 'ExecutionTimeout';
|
|
190
|
+
type MapIterationEventType = 'MapIterationStarted' | 'MapIterationSucceeded';
|
|
191
|
+
type MapIterationFailedEventType = 'MapIterationFailed';
|
|
192
|
+
type ParallelBranchEventType = 'ParallelBranchStarted' | 'ParallelBranchSucceeded';
|
|
193
|
+
type ParallelBranchFailedEventType = 'ParallelBranchFailed';
|
|
194
|
+
type StateEventType = 'StateEntered' | 'StateExited';
|
|
195
|
+
type AllEventTypes = ExecutionStartedEventType | ExecutionSucceededEventType | ExecutionFailedEventType | ExecutionTerminatedEventType | MapIterationEventType | MapIterationFailedEventType | ParallelBranchEventType | ParallelBranchFailedEventType | StateEventType;
|
|
196
|
+
interface StateData {
|
|
197
|
+
name: string;
|
|
198
|
+
type: StateType;
|
|
199
|
+
input: JSONValue;
|
|
200
|
+
output?: JSONValue;
|
|
201
|
+
}
|
|
202
|
+
interface BaseEvent {
|
|
203
|
+
type: AllEventTypes;
|
|
204
|
+
timestamp: number;
|
|
205
|
+
}
|
|
206
|
+
interface ExecutionStartedEvent extends BaseEvent {
|
|
207
|
+
type: ExecutionStartedEventType;
|
|
208
|
+
input: JSONValue;
|
|
209
|
+
}
|
|
210
|
+
interface ExecutionSucceededEvent extends BaseEvent {
|
|
211
|
+
type: ExecutionSucceededEventType;
|
|
212
|
+
output: JSONValue;
|
|
213
|
+
}
|
|
214
|
+
interface ExecutionFailedEvent extends BaseEvent, ErrorOutput {
|
|
215
|
+
type: ExecutionFailedEventType;
|
|
216
|
+
}
|
|
217
|
+
interface ExecutionTerminatedEvent extends BaseEvent {
|
|
218
|
+
type: ExecutionTerminatedEventType;
|
|
219
|
+
}
|
|
220
|
+
interface BaseMapIterationEvent extends BaseEvent {
|
|
221
|
+
type: MapIterationEventType | MapIterationFailedEventType;
|
|
222
|
+
parentState: StateData;
|
|
223
|
+
index: number;
|
|
224
|
+
}
|
|
225
|
+
interface MapIterationEvent extends BaseMapIterationEvent {
|
|
226
|
+
type: MapIterationEventType;
|
|
227
|
+
}
|
|
228
|
+
interface MapIterationFailedEvent extends BaseMapIterationEvent, ErrorOutput {
|
|
229
|
+
type: MapIterationFailedEventType;
|
|
230
|
+
}
|
|
231
|
+
interface BaseParallelBranchEvent extends BaseEvent {
|
|
232
|
+
type: ParallelBranchEventType | ParallelBranchFailedEventType;
|
|
233
|
+
parentState: StateData;
|
|
234
|
+
}
|
|
235
|
+
interface ParallelBranchEvent extends BaseParallelBranchEvent {
|
|
236
|
+
type: ParallelBranchEventType;
|
|
237
|
+
}
|
|
238
|
+
interface ParallelBranchFailedEvent extends BaseParallelBranchEvent, ErrorOutput {
|
|
239
|
+
type: ParallelBranchFailedEventType;
|
|
240
|
+
}
|
|
241
|
+
interface StateEvent extends BaseEvent {
|
|
242
|
+
type: StateEventType;
|
|
243
|
+
state: StateData;
|
|
244
|
+
index?: number;
|
|
245
|
+
}
|
|
246
|
+
type EventLog = ExecutionStartedEvent | ExecutionSucceededEvent | ExecutionFailedEvent | ExecutionTerminatedEvent | MapIterationEvent | MapIterationFailedEvent | ParallelBranchEvent | ParallelBranchFailedEvent | StateEvent;
|
|
247
|
+
|
|
248
|
+
type Context = Record<string, unknown>;
|
|
249
|
+
|
|
250
|
+
/**
|
|
251
|
+
* Base class for all internal errors that can be thrown during the state machine execution.
|
|
252
|
+
*/
|
|
253
|
+
declare abstract class RuntimeError extends Error {
|
|
254
|
+
/**
|
|
255
|
+
* Whether this runtime error can be matched in a `Retry` field
|
|
256
|
+
*/
|
|
257
|
+
protected retryable: boolean;
|
|
258
|
+
/**
|
|
259
|
+
* Whether this runtime error can be caught in a `Catch` field
|
|
260
|
+
*/
|
|
261
|
+
protected catchable: boolean;
|
|
262
|
+
constructor(message: string);
|
|
263
|
+
get isRetryable(): boolean;
|
|
264
|
+
get isCatchable(): boolean;
|
|
265
|
+
}
|
|
266
|
+
|
|
182
267
|
type TaskStateResourceLocalHandler = {
|
|
183
268
|
[taskStateName: string]: (input: JSONValue) => Promise<JSONValue>;
|
|
184
269
|
};
|
|
@@ -197,7 +282,7 @@ interface AWSConfig {
|
|
|
197
282
|
region: string;
|
|
198
283
|
credentials?: {
|
|
199
284
|
cognitoIdentityPool?: FromCognitoIdentityPoolParameters;
|
|
200
|
-
accessKeys?: Omit<
|
|
285
|
+
accessKeys?: Omit<AwsCredentialIdentity, 'expiration'>;
|
|
201
286
|
};
|
|
202
287
|
}
|
|
203
288
|
interface StateMachineOptions {
|
|
@@ -207,6 +292,7 @@ interface StateMachineOptions {
|
|
|
207
292
|
interface RunOptions {
|
|
208
293
|
overrides?: Overrides;
|
|
209
294
|
noThrowOnAbort?: boolean;
|
|
295
|
+
context?: Context;
|
|
210
296
|
}
|
|
211
297
|
|
|
212
298
|
declare class StateMachine {
|
|
@@ -230,6 +316,9 @@ declare class StateMachine {
|
|
|
230
316
|
* If the execution fails, the result will throw an `ExecutionError` explaining why the
|
|
231
317
|
* execution failed.
|
|
232
318
|
*
|
|
319
|
+
* If the execution times out because the number of seconds specified in
|
|
320
|
+
* the `TimeoutSeconds` top-level field has elapsed, the result will throw an `ExecutionTimeoutError`.
|
|
321
|
+
*
|
|
233
322
|
* By default, if the execution is aborted, the result will throw an `ExecutionAbortedError`. This behavior can be changed by setting
|
|
234
323
|
* the `noThrowOnAbort` option to `true`, in which case the result will be `null`.
|
|
235
324
|
*
|
|
@@ -239,6 +328,7 @@ declare class StateMachine {
|
|
|
239
328
|
run(input: JSONValue, options?: RunOptions): {
|
|
240
329
|
abort: () => void;
|
|
241
330
|
result: Promise<JSONValue>;
|
|
331
|
+
eventLogs: AsyncGenerator<EventLog>;
|
|
242
332
|
};
|
|
243
333
|
/**
|
|
244
334
|
* Helper method that handles the execution of the machine states and the transitions between them.
|
|
@@ -251,8 +341,8 @@ declare class StateMachine {
|
|
|
251
341
|
*/
|
|
252
342
|
declare class ExecutionError extends Error {
|
|
253
343
|
#private;
|
|
254
|
-
constructor(caughtError:
|
|
255
|
-
get getWrappedError():
|
|
344
|
+
constructor(caughtError: RuntimeError);
|
|
345
|
+
get getWrappedError(): RuntimeError;
|
|
256
346
|
}
|
|
257
347
|
|
|
258
348
|
/**
|
|
@@ -263,24 +353,10 @@ declare class ExecutionAbortedError extends Error {
|
|
|
263
353
|
}
|
|
264
354
|
|
|
265
355
|
/**
|
|
266
|
-
*
|
|
356
|
+
* Represents the timeout of a state machine execution.
|
|
267
357
|
*/
|
|
268
|
-
declare class
|
|
269
|
-
/**
|
|
270
|
-
* Whether this runtime error can be matched in a `Retry` field
|
|
271
|
-
*/
|
|
272
|
-
protected retryable: boolean;
|
|
273
|
-
/**
|
|
274
|
-
* Whether this runtime error can be caught in a `Catch` field
|
|
275
|
-
*/
|
|
276
|
-
protected catchable: boolean;
|
|
277
|
-
constructor(message: string);
|
|
278
|
-
get isRetryable(): boolean;
|
|
279
|
-
get isCatchable(): boolean;
|
|
280
|
-
}
|
|
281
|
-
|
|
282
|
-
declare class StatesTimeoutError extends RuntimeError {
|
|
358
|
+
declare class ExecutionTimeoutError extends Error {
|
|
283
359
|
constructor();
|
|
284
360
|
}
|
|
285
361
|
|
|
286
|
-
export { ExecutionAbortedError, ExecutionError,
|
|
362
|
+
export { ExecutionAbortedError, ExecutionError, ExecutionTimeoutError, StateMachine };
|