@lafken/state-machine 0.14.0 → 0.14.2
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
|
@@ -88,6 +88,22 @@ You can also start with a declarative state instead of a Lambda task:
|
|
|
88
88
|
export class DelayedWorkflow {}
|
|
89
89
|
```
|
|
90
90
|
|
|
91
|
+
Declarative states receive a generated name based on their type (e.g. `pass`, `wait`, `wait-2`).
|
|
92
|
+
You can provide a custom name with the `name` option, which is used as the state name in the
|
|
93
|
+
Step Functions definition while keeping names unique within the state machine:
|
|
94
|
+
|
|
95
|
+
```typescript
|
|
96
|
+
@StateMachine({
|
|
97
|
+
startAt: {
|
|
98
|
+
type: 'wait',
|
|
99
|
+
name: 'initial-delay',
|
|
100
|
+
seconds: 5,
|
|
101
|
+
next: { type: 'succeed', name: 'done' },
|
|
102
|
+
},
|
|
103
|
+
})
|
|
104
|
+
export class DelayedWorkflow {}
|
|
105
|
+
```
|
|
106
|
+
|
|
91
107
|
### Lambda Tasks
|
|
92
108
|
|
|
93
109
|
The `@State` decorator turns a method into a Lambda-backed task within the state machine. Step Functions will invoke the Lambda automatically during execution.
|
|
@@ -148,9 +164,9 @@ import {
|
|
|
148
164
|
StateMachine,
|
|
149
165
|
State,
|
|
150
166
|
Event,
|
|
167
|
+
IntegrationOptions,
|
|
151
168
|
type IntegrationOptionsParams,
|
|
152
169
|
} from '@lafken/state-machine/main';
|
|
153
|
-
import { IntegrationOptions } from '@lafken/api/main';
|
|
154
170
|
|
|
155
171
|
@StateMachine({
|
|
156
172
|
startAt: 'saveItem',
|
|
@@ -12,6 +12,23 @@ export type ResultOutputType = 'JSON' | 'JSONL';
|
|
|
12
12
|
export type ResultTransformation = 'NONE' | 'COMPACT' | 'FLATTEN';
|
|
13
13
|
export type IntegrationMode = 'sync' | 'async' | 'token';
|
|
14
14
|
type ObjectOrJsonAta = Record<string, any> | JsonAtaString;
|
|
15
|
+
export interface StateName {
|
|
16
|
+
/**
|
|
17
|
+
* Custom state name.
|
|
18
|
+
*
|
|
19
|
+
* Specifies a custom name for the state in the state machine definition.
|
|
20
|
+
* If not provided, a name is generated automatically based on the state
|
|
21
|
+
* type (e.g. `pass`, `pass-2`, `wait`). Names are kept unique within the
|
|
22
|
+
* state machine, appending a numeric suffix when duplicated.
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* {
|
|
26
|
+
* type: 'pass',
|
|
27
|
+
* name: 'my-pass-state',
|
|
28
|
+
* }
|
|
29
|
+
*/
|
|
30
|
+
name?: string;
|
|
31
|
+
}
|
|
15
32
|
/**
|
|
16
33
|
* Attributes that can be exported from a Step Functions state machine resource.
|
|
17
34
|
*
|
|
@@ -189,7 +206,7 @@ interface StateMachineProps<T> extends StateMachineBaseProps<T> {
|
|
|
189
206
|
*/
|
|
190
207
|
ref?: StateMachineReferenceNames;
|
|
191
208
|
}
|
|
192
|
-
interface WaitStateBase<T> {
|
|
209
|
+
interface WaitStateBase<T> extends StateName {
|
|
193
210
|
/**
|
|
194
211
|
* State type: Wait.
|
|
195
212
|
*
|
|
@@ -303,7 +320,7 @@ interface ChoiceCondition<T> {
|
|
|
303
320
|
*/
|
|
304
321
|
next: StateTypes<T>;
|
|
305
322
|
}
|
|
306
|
-
export interface ChoiceState<T> {
|
|
323
|
+
export interface ChoiceState<T> extends StateName {
|
|
307
324
|
/**
|
|
308
325
|
* State type: Choice.
|
|
309
326
|
*
|
|
@@ -348,7 +365,7 @@ export interface ChoiceState<T> {
|
|
|
348
365
|
*/
|
|
349
366
|
default?: StateTypes<T>;
|
|
350
367
|
}
|
|
351
|
-
interface ParallelState<T> extends CatchAndRetry<T
|
|
368
|
+
interface ParallelState<T> extends CatchAndRetry<T>, StateName {
|
|
352
369
|
/**
|
|
353
370
|
* State type: Parallel.
|
|
354
371
|
*
|
|
@@ -438,7 +455,7 @@ interface ParallelState<T> extends CatchAndRetry<T> {
|
|
|
438
455
|
*/
|
|
439
456
|
next?: StateTypes<T>;
|
|
440
457
|
}
|
|
441
|
-
interface FailState {
|
|
458
|
+
interface FailState extends StateName {
|
|
442
459
|
type: 'fail';
|
|
443
460
|
/**
|
|
444
461
|
* Description about error cause, you can use an jsonata expression
|
|
@@ -468,7 +485,7 @@ interface FailState {
|
|
|
468
485
|
*/
|
|
469
486
|
error?: string;
|
|
470
487
|
}
|
|
471
|
-
interface SucceedState {
|
|
488
|
+
interface SucceedState extends StateName {
|
|
472
489
|
type: 'succeed';
|
|
473
490
|
/**
|
|
474
491
|
* State output transformation.
|
|
@@ -492,7 +509,7 @@ interface SucceedState {
|
|
|
492
509
|
*/
|
|
493
510
|
output?: ObjectOrJsonAta;
|
|
494
511
|
}
|
|
495
|
-
interface PassState<T> {
|
|
512
|
+
interface PassState<T> extends StateName {
|
|
496
513
|
type: 'pass';
|
|
497
514
|
/**
|
|
498
515
|
* Next state to execute.
|
|
@@ -552,7 +569,7 @@ interface PassState<T> {
|
|
|
552
569
|
*/
|
|
553
570
|
assign?: Record<string, any>;
|
|
554
571
|
}
|
|
555
|
-
export interface MapStateBase<T> extends CatchAndRetry<T
|
|
572
|
+
export interface MapStateBase<T> extends CatchAndRetry<T>, StateName {
|
|
556
573
|
/**
|
|
557
574
|
* State type: Map.
|
|
558
575
|
*
|
|
@@ -258,7 +258,7 @@ class Schema {
|
|
|
258
258
|
if (typeof currentState === 'string') {
|
|
259
259
|
return '';
|
|
260
260
|
}
|
|
261
|
-
return this.stateNames.createName(currentState.type);
|
|
261
|
+
return this.stateNames.createName(currentState.name ?? currentState.type);
|
|
262
262
|
}
|
|
263
263
|
getIntegrationTask(handler) {
|
|
264
264
|
const task = {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lafken/state-machine",
|
|
3
|
-
"version": "0.14.
|
|
3
|
+
"version": "0.14.2",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Build Step Functions workflows with TypeScript decorators - declarative orchestration with Lafken",
|
|
6
6
|
"keywords": [
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
],
|
|
51
51
|
"dependencies": {
|
|
52
52
|
"reflect-metadata": "^0.2.2",
|
|
53
|
-
"@lafken/resolver": "0.14.
|
|
53
|
+
"@lafken/resolver": "0.14.2"
|
|
54
54
|
},
|
|
55
55
|
"devDependencies": {
|
|
56
56
|
"@cdktn/provider-aws": "^25.0.0",
|
|
@@ -63,13 +63,13 @@
|
|
|
63
63
|
"typescript": "7.0.2",
|
|
64
64
|
"unplugin-swc": "^1.5.10",
|
|
65
65
|
"vitest": "^4.1.10",
|
|
66
|
-
"@lafken/common": "0.14.
|
|
66
|
+
"@lafken/common": "0.14.2"
|
|
67
67
|
},
|
|
68
68
|
"peerDependencies": {
|
|
69
69
|
"@cdktn/provider-aws": ">=23.0.0",
|
|
70
70
|
"cdktn": ">=0.22.0",
|
|
71
71
|
"constructs": ">=10.7.0",
|
|
72
|
-
"@lafken/common": "0.14.
|
|
72
|
+
"@lafken/common": "0.14.2"
|
|
73
73
|
},
|
|
74
74
|
"engines": {
|
|
75
75
|
"node": ">=20.19"
|