aws-local-stepfunctions 0.7.0 → 1.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/README.md +105 -8
- package/{build → bin}/CLI.cjs +56 -6
- package/build/main.browser.esm.js +8508 -7571
- package/build/main.d.ts +193 -24
- package/build/main.node.cjs +679 -183
- package/build/main.node.esm.js +679 -183
- package/package.json +23 -18
package/build/main.d.ts
CHANGED
|
@@ -179,34 +179,215 @@ interface StateMachineDefinition {
|
|
|
179
179
|
TimeoutSeconds?: number;
|
|
180
180
|
}
|
|
181
181
|
|
|
182
|
+
type Context = Record<string, unknown>;
|
|
183
|
+
|
|
184
|
+
declare class ErrorWithCause extends Error {
|
|
185
|
+
#private;
|
|
186
|
+
constructor(message: string, options?: {
|
|
187
|
+
cause: unknown;
|
|
188
|
+
});
|
|
189
|
+
get cause(): unknown;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
/**
|
|
193
|
+
* Base class for all internal errors that can be thrown during the state machine execution.
|
|
194
|
+
*/
|
|
195
|
+
declare abstract class RuntimeError extends ErrorWithCause {
|
|
196
|
+
/**
|
|
197
|
+
* Whether this runtime error can be matched in a `Retry` field
|
|
198
|
+
*/
|
|
199
|
+
protected retryable: boolean;
|
|
200
|
+
/**
|
|
201
|
+
* Whether this runtime error can be caught in a `Catch` field
|
|
202
|
+
*/
|
|
203
|
+
protected catchable: boolean;
|
|
204
|
+
constructor(message: string, cause?: unknown);
|
|
205
|
+
get isRetryable(): boolean;
|
|
206
|
+
get isCatchable(): boolean;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
type ExecutionStartedEventType = 'ExecutionStarted';
|
|
210
|
+
type ExecutionSucceededEventType = 'ExecutionSucceeded';
|
|
211
|
+
type ExecutionFailedEventType = 'ExecutionFailed';
|
|
212
|
+
type ExecutionTerminatedEventType = 'ExecutionAborted' | 'ExecutionTimeout';
|
|
213
|
+
type ExecutionEventType = ExecutionStartedEventType | ExecutionSucceededEventType | ExecutionFailedEventType | ExecutionTerminatedEventType;
|
|
214
|
+
type MapIterationStartedEventType = 'MapIterationStarted';
|
|
215
|
+
type MapIterationSucceededEventType = 'MapIterationSucceeded';
|
|
216
|
+
type MapIterationFailedEventType = 'MapIterationFailed';
|
|
217
|
+
type MapIterationEventType = MapIterationStartedEventType | MapIterationSucceededEventType | MapIterationFailedEventType;
|
|
218
|
+
type ParallelBranchStartedEventType = 'ParallelBranchStarted';
|
|
219
|
+
type ParallelBranchSucceededEventType = 'ParallelBranchSucceeded';
|
|
220
|
+
type ParallelBranchFailedEventType = 'ParallelBranchFailed';
|
|
221
|
+
type ParallelBranchEventType = ParallelBranchStartedEventType | ParallelBranchSucceededEventType | ParallelBranchFailedEventType;
|
|
222
|
+
type StateEnteredEventType = 'StateEntered';
|
|
223
|
+
type StateExitedEventType = 'StateExited';
|
|
224
|
+
type StateFailedEventType = 'StateFailed';
|
|
225
|
+
type StateRetriedEventType = 'StateRetried';
|
|
226
|
+
type StateCaughtEventType = 'StateCaught';
|
|
227
|
+
type StateEventType = StateEnteredEventType | StateExitedEventType | StateFailedEventType | StateRetriedEventType | StateCaughtEventType;
|
|
228
|
+
type AllEventTypes = ExecutionEventType | MapIterationEventType | ParallelBranchEventType | StateEventType;
|
|
229
|
+
interface StateData {
|
|
230
|
+
name: string;
|
|
231
|
+
type: StateType;
|
|
232
|
+
input: JSONValue;
|
|
233
|
+
output?: JSONValue;
|
|
234
|
+
}
|
|
235
|
+
interface RetryData {
|
|
236
|
+
retrier: Retrier;
|
|
237
|
+
attempt: number;
|
|
238
|
+
}
|
|
239
|
+
interface CatchData {
|
|
240
|
+
catcher: Catcher;
|
|
241
|
+
}
|
|
242
|
+
interface ErrorInfo {
|
|
243
|
+
Error: string;
|
|
244
|
+
Cause: unknown;
|
|
245
|
+
}
|
|
246
|
+
interface BaseEvent {
|
|
247
|
+
type: AllEventTypes;
|
|
248
|
+
timestamp: number;
|
|
249
|
+
}
|
|
250
|
+
interface ExecutionStartedEvent extends BaseEvent {
|
|
251
|
+
type: ExecutionStartedEventType;
|
|
252
|
+
input: JSONValue;
|
|
253
|
+
}
|
|
254
|
+
interface ExecutionSucceededEvent extends BaseEvent {
|
|
255
|
+
type: ExecutionSucceededEventType;
|
|
256
|
+
output: JSONValue;
|
|
257
|
+
}
|
|
258
|
+
interface ExecutionFailedEvent extends BaseEvent, ErrorInfo {
|
|
259
|
+
type: ExecutionFailedEventType;
|
|
260
|
+
}
|
|
261
|
+
interface ExecutionTerminatedEvent extends BaseEvent {
|
|
262
|
+
type: ExecutionTerminatedEventType;
|
|
263
|
+
}
|
|
264
|
+
interface BaseMapIterationEvent extends BaseEvent {
|
|
265
|
+
type: MapIterationEventType;
|
|
266
|
+
parentState: StateData;
|
|
267
|
+
index: number;
|
|
268
|
+
}
|
|
269
|
+
interface MapIterationStartedEvent extends BaseMapIterationEvent {
|
|
270
|
+
type: MapIterationStartedEventType;
|
|
271
|
+
}
|
|
272
|
+
interface MapIterationSucceededEvent extends BaseMapIterationEvent {
|
|
273
|
+
type: MapIterationSucceededEventType;
|
|
274
|
+
}
|
|
275
|
+
interface MapIterationFailedEvent extends BaseMapIterationEvent, ErrorInfo {
|
|
276
|
+
type: MapIterationFailedEventType;
|
|
277
|
+
}
|
|
278
|
+
interface BaseParallelBranchEvent extends BaseEvent {
|
|
279
|
+
type: ParallelBranchEventType;
|
|
280
|
+
parentState: StateData;
|
|
281
|
+
}
|
|
282
|
+
interface ParallelBranchStartedEvent extends BaseParallelBranchEvent {
|
|
283
|
+
type: ParallelBranchStartedEventType;
|
|
284
|
+
}
|
|
285
|
+
interface ParallelBranchSucceededEvent extends BaseParallelBranchEvent {
|
|
286
|
+
type: ParallelBranchSucceededEventType;
|
|
287
|
+
}
|
|
288
|
+
interface ParallelBranchFailedEvent extends BaseParallelBranchEvent, ErrorInfo {
|
|
289
|
+
type: ParallelBranchFailedEventType;
|
|
290
|
+
}
|
|
291
|
+
interface BaseStateEvent extends BaseEvent {
|
|
292
|
+
type: StateEventType;
|
|
293
|
+
state: StateData;
|
|
294
|
+
index?: number;
|
|
295
|
+
}
|
|
296
|
+
interface StateEnteredEvent extends BaseStateEvent {
|
|
297
|
+
type: StateEnteredEventType;
|
|
298
|
+
}
|
|
299
|
+
interface StateExitedEvent extends BaseStateEvent {
|
|
300
|
+
type: StateExitedEventType;
|
|
301
|
+
}
|
|
302
|
+
interface StateFailedEvent extends BaseStateEvent, ErrorInfo {
|
|
303
|
+
type: StateFailedEventType;
|
|
304
|
+
}
|
|
305
|
+
interface StateRetriedEvent extends BaseStateEvent {
|
|
306
|
+
type: StateRetriedEventType;
|
|
307
|
+
retry: RetryData;
|
|
308
|
+
}
|
|
309
|
+
interface StateRetriedEvent extends BaseStateEvent {
|
|
310
|
+
type: StateRetriedEventType;
|
|
311
|
+
retry: RetryData;
|
|
312
|
+
}
|
|
313
|
+
interface StateCaughtEvent extends BaseStateEvent {
|
|
314
|
+
type: StateCaughtEventType;
|
|
315
|
+
catch: CatchData;
|
|
316
|
+
}
|
|
317
|
+
type EventLog = ExecutionStartedEvent | ExecutionSucceededEvent | ExecutionFailedEvent | ExecutionTerminatedEvent | MapIterationStartedEvent | MapIterationSucceededEvent | MapIterationFailedEvent | ParallelBranchStartedEvent | ParallelBranchSucceededEvent | ParallelBranchFailedEvent | StateEnteredEvent | StateExitedEvent | StateFailedEvent | StateRetriedEvent | StateCaughtEvent;
|
|
318
|
+
|
|
182
319
|
type TaskStateResourceLocalHandler = {
|
|
183
|
-
[taskStateName: string]: (input: JSONValue) => Promise<JSONValue
|
|
320
|
+
[taskStateName: string]: (input: JSONValue) => Promise<JSONValue> | JSONValue;
|
|
184
321
|
};
|
|
185
322
|
type WaitStateTimeOverride = {
|
|
186
323
|
[waitStateName: string]: number;
|
|
187
324
|
};
|
|
188
325
|
interface Overrides {
|
|
326
|
+
/**
|
|
327
|
+
* Pass an object to this option to override a `Task` state to run a local function,
|
|
328
|
+
* instead of calling the service specified in the `Resource` field.
|
|
329
|
+
*/
|
|
189
330
|
taskResourceLocalHandlers?: TaskStateResourceLocalHandler;
|
|
331
|
+
/**
|
|
332
|
+
* Pass an object to this option to override a `Wait` state to pause for the specified number of milliseconds,
|
|
333
|
+
* instead of pausing for the duration specified by the `Seconds`, `Timestamp`, `SecondsPath`, or `TimestampPath` fields.
|
|
334
|
+
*/
|
|
190
335
|
waitTimeOverrides?: WaitStateTimeOverride;
|
|
191
336
|
}
|
|
192
337
|
interface ValidationOptions {
|
|
338
|
+
/**
|
|
339
|
+
* Disables validation of the state machine definition entirely.
|
|
340
|
+
*
|
|
341
|
+
* Use this option at your own risk, there are no guarantees when passing an invalid or non-standard definition to the state machine.
|
|
342
|
+
* Running it might result in undefined/unsupported behavior.
|
|
343
|
+
*/
|
|
344
|
+
readonly noValidate?: boolean;
|
|
345
|
+
/**
|
|
346
|
+
* Disables validation of JSONPath expressions in the state machine definition.
|
|
347
|
+
*/
|
|
193
348
|
readonly checkPaths?: boolean;
|
|
349
|
+
/**
|
|
350
|
+
* Disables validation of ARNs in the state machine definition.
|
|
351
|
+
*/
|
|
194
352
|
readonly checkArn?: boolean;
|
|
195
353
|
}
|
|
196
354
|
interface AWSConfig {
|
|
355
|
+
/**
|
|
356
|
+
* AWS Region where your Task resources are located.
|
|
357
|
+
*/
|
|
197
358
|
region: string;
|
|
359
|
+
/**
|
|
360
|
+
* AWS credentials needed to be able to call Task resources.
|
|
361
|
+
*/
|
|
198
362
|
credentials?: {
|
|
199
363
|
cognitoIdentityPool?: FromCognitoIdentityPoolParameters;
|
|
200
|
-
accessKeys?:
|
|
364
|
+
accessKeys?: AwsCredentialIdentity;
|
|
201
365
|
};
|
|
202
366
|
}
|
|
203
367
|
interface StateMachineOptions {
|
|
368
|
+
/**
|
|
369
|
+
* Options that allow changing certain rules when validating the state machine definition.
|
|
370
|
+
*/
|
|
204
371
|
validationOptions?: ValidationOptions;
|
|
372
|
+
/**
|
|
373
|
+
* Config options related to AWS resources.
|
|
374
|
+
*/
|
|
205
375
|
awsConfig?: AWSConfig;
|
|
206
376
|
}
|
|
207
377
|
interface RunOptions {
|
|
378
|
+
/**
|
|
379
|
+
* This option allows overriding the behavior of certain states.
|
|
380
|
+
*/
|
|
208
381
|
overrides?: Overrides;
|
|
382
|
+
/**
|
|
383
|
+
* If set to `true`, aborting the execution will simply return `null` as result instead of throwing
|
|
384
|
+
*/
|
|
209
385
|
noThrowOnAbort?: boolean;
|
|
386
|
+
/**
|
|
387
|
+
* Pass an object to this option to mock the [Context Object](https://states-language.net/#context-object) that will be used in the execution.
|
|
388
|
+
* @see https://docs.aws.amazon.com/step-functions/latest/dg/input-output-contextobject.html
|
|
389
|
+
*/
|
|
390
|
+
context?: Context;
|
|
210
391
|
}
|
|
211
392
|
|
|
212
393
|
declare class StateMachine {
|
|
@@ -230,6 +411,9 @@ declare class StateMachine {
|
|
|
230
411
|
* If the execution fails, the result will throw an `ExecutionError` explaining why the
|
|
231
412
|
* execution failed.
|
|
232
413
|
*
|
|
414
|
+
* If the execution times out because the number of seconds specified in
|
|
415
|
+
* the `TimeoutSeconds` top-level field has elapsed, the result will throw an `ExecutionTimeoutError`.
|
|
416
|
+
*
|
|
233
417
|
* By default, if the execution is aborted, the result will throw an `ExecutionAbortedError`. This behavior can be changed by setting
|
|
234
418
|
* the `noThrowOnAbort` option to `true`, in which case the result will be `null`.
|
|
235
419
|
*
|
|
@@ -239,6 +423,7 @@ declare class StateMachine {
|
|
|
239
423
|
run(input: JSONValue, options?: RunOptions): {
|
|
240
424
|
abort: () => void;
|
|
241
425
|
result: Promise<JSONValue>;
|
|
426
|
+
eventLogs: AsyncGenerator<EventLog>;
|
|
242
427
|
};
|
|
243
428
|
/**
|
|
244
429
|
* Helper method that handles the execution of the machine states and the transitions between them.
|
|
@@ -249,38 +434,22 @@ declare class StateMachine {
|
|
|
249
434
|
/**
|
|
250
435
|
* Represents the failure of a state machine execution.
|
|
251
436
|
*/
|
|
252
|
-
declare class ExecutionError extends
|
|
253
|
-
|
|
254
|
-
constructor(caughtError: Error);
|
|
255
|
-
get getWrappedError(): Error;
|
|
437
|
+
declare class ExecutionError extends ErrorWithCause {
|
|
438
|
+
constructor(caughtError: RuntimeError);
|
|
256
439
|
}
|
|
257
440
|
|
|
258
441
|
/**
|
|
259
|
-
* Represents the
|
|
442
|
+
* Represents the abort of a state machine execution.
|
|
260
443
|
*/
|
|
261
444
|
declare class ExecutionAbortedError extends Error {
|
|
262
445
|
constructor();
|
|
263
446
|
}
|
|
264
447
|
|
|
265
448
|
/**
|
|
266
|
-
*
|
|
449
|
+
* Represents the timeout of a state machine execution.
|
|
267
450
|
*/
|
|
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 {
|
|
451
|
+
declare class ExecutionTimeoutError extends Error {
|
|
283
452
|
constructor();
|
|
284
453
|
}
|
|
285
454
|
|
|
286
|
-
export { ExecutionAbortedError, ExecutionError,
|
|
455
|
+
export { ExecutionAbortedError, ExecutionError, ExecutionTimeoutError, RunOptions, StateMachine, StateMachineDefinition, StateMachineOptions };
|