@lafken/state-machine 0.11.3 → 0.11.5

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.
@@ -1,8 +1,46 @@
1
1
  import type { AllowedTypes, ArrayField, BooleanField, GetResourceProps, NumberField, ObjectField, StringField } from '@lafken/common';
2
+ /**
3
+ * A JSONata expression string enclosed in `{%` ... `%}` delimiters.
4
+ *
5
+ * Used as the value for a `jsonata` param context to perform dynamic
6
+ * data transformations inside a Step Functions state machine.
7
+ *
8
+ * @example
9
+ * '{%$states.input.userId%}'
10
+ */
2
11
  export type JsonAtaString = `{%${string}%}`;
12
+ /**
13
+ * Execution-level attributes available as parameter sources in Step Functions.
14
+ *
15
+ * - `id` — ARN of the execution.
16
+ * - `` input.{string} `` — Dot-notation path into the execution input JSON.
17
+ * - `name` — Name of the execution.
18
+ * - `role_arn` — IAM role ARN used by the execution.
19
+ * - `start_time` — ISO-8601 timestamp when the execution started.
20
+ * - `redrive_count` — Number of times the execution has been redriven.
21
+ * - `redrive_time` — ISO-8601 timestamp of the last redrive.
22
+ */
3
23
  export type ExecutionSource = 'id' | `input.${string}` | 'name' | 'role_arn' | 'start_time' | 'redrive_count' | 'redrive_time';
24
+ /**
25
+ * State-machine-level attributes available as parameter sources.
26
+ *
27
+ * - `id` — ARN of the state machine definition.
28
+ * - `name` — Name of the state machine.
29
+ */
4
30
  export type StateMachineSource = 'id' | 'name';
31
+ /**
32
+ * State-level attributes available as parameter sources.
33
+ *
34
+ * - `entered_time` — ISO-8601 timestamp when the current state was entered.
35
+ * - `name` — Name of the current state.
36
+ * - `retry_count` — Number of retry attempts for the current state.
37
+ */
5
38
  export type StateSource = 'entered_time' | 'name' | 'retry_count';
39
+ /**
40
+ * Task-level attributes available as parameter sources.
41
+ *
42
+ * - `token` — Unique task token used for `.waitForTaskToken` integration patterns.
43
+ */
6
44
  export type TaskSource = 'token';
7
45
  type ParamContextBase<C, T> = {
8
46
  /**
@@ -25,11 +63,63 @@ type ParamContextBase<C, T> = {
25
63
  */
26
64
  type?: AllowedTypes;
27
65
  };
66
+ /**
67
+ * Parameter context that references a field from the state's input JSON.
68
+ *
69
+ * Use a dot-notation string as `source` to target a nested property.
70
+ *
71
+ * @example
72
+ * { context: 'input', source: 'user.id' }
73
+ */
28
74
  export type InputParamContext = ParamContextBase<'input', string>;
75
+ /**
76
+ * Parameter context that references data from the current Step Functions execution.
77
+ *
78
+ * Use this to bind a parameter to a specific execution-level attribute, such as the
79
+ * execution ID, name, IAM role ARN, start time, input path, or redrive metadata.
80
+ *
81
+ * @example
82
+ * // Bind a parameter to the execution ID
83
+ * { context: 'execution', source: 'id' }
84
+ *
85
+ * @example
86
+ * // Bind a parameter to a nested input field
87
+ * { context: 'execution', source: 'input.userId' }
88
+ *
89
+ * @see {@link ExecutionSource} for all available source values.
90
+ */
29
91
  export type ExecutionParamContext = ParamContextBase<'execution', ExecutionSource>;
92
+ /**
93
+ * Parameter context that references data from the currently executing state.
94
+ *
95
+ * @example
96
+ * { context: 'state', source: 'name' }
97
+ *
98
+ * @see {@link StateSource} for all available source values.
99
+ */
30
100
  export type StateParamContext = ParamContextBase<'state', StateSource>;
101
+ /**
102
+ * Parameter context that references a top-level attribute of the state machine definition.
103
+ *
104
+ * @example
105
+ * { context: 'state_machine', source: 'id' }
106
+ *
107
+ * @see {@link StateMachineSource} for all available source values.
108
+ */
31
109
  export type StateMachineParamContext = ParamContextBase<'state_machine', StateMachineSource>;
110
+ /**
111
+ * Parameter context that exposes task-level attributes, primarily used for
112
+ * `.waitForTaskToken` integration patterns where a callback token must be
113
+ * forwarded to an external system.
114
+ *
115
+ * @example
116
+ * { context: 'task', source: 'token' }
117
+ */
32
118
  export type TaskParamContext = ParamContextBase<'task', TaskSource>;
119
+ /**
120
+ * Parameter context for supplying an arbitrary static or computed value
121
+ * that does not originate from execution, state, or task runtime data.
122
+ */
33
123
  export type CustomParamContext = {
34
124
  context: 'custom';
35
125
  /**
@@ -41,6 +131,14 @@ export type CustomParamContext = {
41
131
  */
42
132
  type?: String | Number | Boolean | Function;
43
133
  };
134
+ /**
135
+ * Parameter context for evaluating a JSONata expression at runtime.
136
+ *
137
+ * The `value` must be a {@link JsonAtaString} — a template enclosed in `{%` ... `%}`.
138
+ *
139
+ * @example
140
+ * { context: 'jsonata', value: '{%$states.input.price * 1.2%}' }
141
+ */
44
142
  export type JsonAtaParamContext = {
45
143
  context: 'jsonata';
46
144
  /**
@@ -48,7 +146,15 @@ export type JsonAtaParamContext = {
48
146
  */
49
147
  value: JsonAtaString;
50
148
  };
149
+ /**
150
+ * Union of all supported parameter context types that can be used with the
151
+ * `@Param` decorator to bind a state machine parameter to a runtime value source.
152
+ */
51
153
  export type ParamContext = ExecutionParamContext | InputParamContext | StateParamContext | StateMachineParamContext | TaskParamContext | CustomParamContext | JsonAtaParamContext;
154
+ /**
155
+ * Props accepted by the `@Param` decorator. Combines an optional display name
156
+ * with one of the supported {@link ParamContext} variants.
157
+ */
52
158
  export type ParamProps = {
53
159
  /**
54
160
  * Name of property
@@ -57,21 +163,50 @@ export type ParamProps = {
57
163
  */
58
164
  name?: string;
59
165
  } & ParamContext;
166
+ /**
167
+ * Internal base shape for all resolved state machine parameter metadata.
168
+ * Produced by the resolver after processing `@Param` decorator metadata.
169
+ */
60
170
  export type StateMachineParamBase = {
171
+ /** Context type discriminant (e.g. `'execution'`, `'input'`, `'custom'`). */
61
172
  context: ParamContext['context'];
173
+ /** Resolved static value (used by `custom` and `jsonata` contexts). */
62
174
  value: any;
175
+ /** Runtime source path within the chosen context. */
63
176
  source: any;
177
+ /** Parameter name as it will appear in the Step Functions parameter map. */
64
178
  name: string;
65
179
  };
180
+ /** Resolved metadata for a string-typed state machine parameter. */
66
181
  export type StateMachineStringParam = StringField & StateMachineParamBase;
182
+ /** Resolved metadata for a number-typed state machine parameter. */
67
183
  export type StateMachineNumberParam = NumberField & StateMachineParamBase;
184
+ /** Resolved metadata for a boolean-typed state machine parameter. */
68
185
  export type StateMachineBooleanParam = BooleanField & StateMachineParamBase;
186
+ /**
187
+ * Resolved metadata for an object-typed state machine parameter.
188
+ * Nested `properties` are recursively described as {@link StateMachineParamMetadata}.
189
+ */
69
190
  export type StateMachineObjectParam = Omit<ObjectField, 'properties'> & StateMachineParamBase & {
70
191
  properties: StateMachineParamMetadata[];
71
192
  };
193
+ /**
194
+ * Resolved metadata for an array-typed state machine parameter.
195
+ * The element schema is described by a single {@link StateMachineParamMetadata} entry.
196
+ */
72
197
  export type StateMachineArrayParam = Omit<ArrayField, 'items'> & StateMachineParamBase & {
73
198
  items: StateMachineParamMetadata;
74
199
  };
200
+ /**
201
+ * Discriminated union of all resolved parameter metadata shapes.
202
+ * Used by the resolver to build the Step Functions parameter map for a state.
203
+ */
75
204
  export type StateMachineParamMetadata = StateMachineStringParam | StateMachineNumberParam | StateMachineBooleanParam | StateMachineObjectParam | StateMachineArrayParam;
205
+ /**
206
+ * Parameters passed to integration options when configuring a state machine
207
+ * task integration (e.g. Lambda, SQS, DynamoDB).
208
+ *
209
+ * Alias of {@link GetResourceProps} from `@lafken/common`.
210
+ */
76
211
  export type IntegrationOptionsParams = GetResourceProps;
77
212
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lafken/state-machine",
3
- "version": "0.11.3",
3
+ "version": "0.11.5",
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.11.3"
53
+ "@lafken/resolver": "0.11.5"
54
54
  },
55
55
  "devDependencies": {
56
56
  "@cdktn/provider-aws": "^23.5.0",
@@ -63,13 +63,13 @@
63
63
  "typescript": "6.0.2",
64
64
  "unplugin-swc": "^1.5.9",
65
65
  "vitest": "^4.1.2",
66
- "@lafken/common": "0.11.3"
66
+ "@lafken/common": "0.11.5"
67
67
  },
68
68
  "peerDependencies": {
69
69
  "@cdktn/provider-aws": ">=23.0.0",
70
70
  "cdktn": ">=0.22.0",
71
71
  "constructs": "^10.4.5",
72
- "@lafken/common": "0.11.3"
72
+ "@lafken/common": "0.11.5"
73
73
  },
74
74
  "engines": {
75
75
  "node": ">=20.19"