@lafken/state-machine 0.10.1

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.
Files changed (33) hide show
  1. package/LICENCE +21 -0
  2. package/README.md +383 -0
  3. package/lib/index.d.ts +2 -0
  4. package/lib/index.js +18 -0
  5. package/lib/main/index.d.ts +2 -0
  6. package/lib/main/index.js +18 -0
  7. package/lib/main/param/index.d.ts +2 -0
  8. package/lib/main/param/index.js +18 -0
  9. package/lib/main/param/param.d.ts +105 -0
  10. package/lib/main/param/param.js +115 -0
  11. package/lib/main/param/param.types.d.ts +77 -0
  12. package/lib/main/param/param.types.js +2 -0
  13. package/lib/main/state-machine/index.d.ts +2 -0
  14. package/lib/main/state-machine/index.js +18 -0
  15. package/lib/main/state-machine/state-machine.d.ts +113 -0
  16. package/lib/main/state-machine/state-machine.js +133 -0
  17. package/lib/main/state-machine/state-machine.types.d.ts +977 -0
  18. package/lib/main/state-machine/state-machine.types.js +7 -0
  19. package/lib/resolver/index.d.ts +1 -0
  20. package/lib/resolver/index.js +17 -0
  21. package/lib/resolver/resolver.d.ts +6 -0
  22. package/lib/resolver/resolver.js +28 -0
  23. package/lib/resolver/state-machine/schema/schema.d.ts +34 -0
  24. package/lib/resolver/state-machine/schema/schema.js +431 -0
  25. package/lib/resolver/state-machine/schema/schema.types.d.ts +149 -0
  26. package/lib/resolver/state-machine/schema/schema.types.js +2 -0
  27. package/lib/resolver/state-machine/schema/schema.utils.d.ts +15 -0
  28. package/lib/resolver/state-machine/schema/schema.utils.js +53 -0
  29. package/lib/resolver/state-machine/state-machine.d.ts +19 -0
  30. package/lib/resolver/state-machine/state-machine.js +96 -0
  31. package/lib/resolver/state-machine/state-machine.types.d.ts +7 -0
  32. package/lib/resolver/state-machine/state-machine.types.js +2 -0
  33. package/package.json +87 -0
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.StateMachineReflectKeys = void 0;
4
+ var StateMachineReflectKeys;
5
+ (function (StateMachineReflectKeys) {
6
+ StateMachineReflectKeys["nested"] = "state_machine:nested";
7
+ })(StateMachineReflectKeys || (exports.StateMachineReflectKeys = StateMachineReflectKeys = {}));
@@ -0,0 +1 @@
1
+ export * from './resolver';
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./resolver"), exports);
@@ -0,0 +1,6 @@
1
+ import { type ClassResource } from '@lafken/common';
2
+ import { type AppModule, type ResolverType } from '@lafken/resolver';
3
+ export declare class StateMachineResolver implements ResolverType {
4
+ type: "STATE_MACHINE";
5
+ create(module: AppModule, resource: ClassResource): Promise<void>;
6
+ }
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.StateMachineResolver = void 0;
4
+ const common_1 = require("@lafken/common");
5
+ const resolver_1 = require("@lafken/resolver");
6
+ const main_1 = require("../main");
7
+ const state_machine_1 = require("./state-machine/state-machine");
8
+ class StateMachineResolver {
9
+ type = main_1.RESOURCE_TYPE;
10
+ async create(module, resource) {
11
+ const metadata = (0, common_1.getResourceMetadata)(resource);
12
+ const handlers = (0, common_1.getResourceHandlerMetadata)(resource);
13
+ resolver_1.lambdaAssets.initializeMetadata({
14
+ foldername: metadata.foldername,
15
+ filename: metadata.filename,
16
+ className: metadata.originalName,
17
+ methods: handlers.map((handler) => handler.name),
18
+ minify: metadata.minify,
19
+ });
20
+ const stateMachine = new state_machine_1.StateMachine(module, metadata.name, {
21
+ classResource: resource,
22
+ resourceMetadata: metadata,
23
+ moduleName: module.id,
24
+ });
25
+ await stateMachine.attachDefinition();
26
+ }
27
+ }
28
+ exports.StateMachineResolver = StateMachineResolver;
@@ -0,0 +1,34 @@
1
+ import { type ClassResource } from '@lafken/common';
2
+ import type { Construct } from 'constructs';
3
+ import type { BucketPermission, DefinitionSchema, SchemaProps } from './schema.types';
4
+ export declare class Schema {
5
+ private scope;
6
+ private resource;
7
+ private states;
8
+ private resourceMetadata;
9
+ private handlers;
10
+ private stateNames;
11
+ private lambdaStates;
12
+ private unresolvedDependency;
13
+ private bucketPermissions;
14
+ constructor(scope: Construct, resource: ClassResource, props?: SchemaProps);
15
+ getDefinition(): DefinitionSchema;
16
+ resolveArguments(definition: DefinitionSchema): Promise<DefinitionSchema>;
17
+ get hasUnresolvedDependency(): boolean;
18
+ get buckets(): BucketPermission;
19
+ private getMetadata;
20
+ private getNextState;
21
+ private getStateName;
22
+ private getIntegrationTask;
23
+ private getLambdaTask;
24
+ private addTaskState;
25
+ private getLambdaPayload;
26
+ private parseArgumentParam;
27
+ private getParallelArguments;
28
+ private addRetry;
29
+ private addCatch;
30
+ private addRetryAndCatch;
31
+ private setUnresolvedDependency;
32
+ private mergeBucketPermissions;
33
+ private addBucketPermission;
34
+ }
@@ -0,0 +1,431 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Schema = void 0;
4
+ const common_1 = require("@lafken/common");
5
+ const resolver_1 = require("@lafken/resolver");
6
+ const main_1 = require("../../../main");
7
+ const schema_utils_1 = require("./schema.utils");
8
+ class Schema {
9
+ scope;
10
+ resource;
11
+ states = {};
12
+ resourceMetadata;
13
+ handlers = {};
14
+ stateNames;
15
+ lambdaStates;
16
+ unresolvedDependency = false;
17
+ bucketPermissions = {};
18
+ constructor(scope, resource, props = {}) {
19
+ this.scope = scope;
20
+ this.resource = resource;
21
+ this.stateNames = props.stateNames || new schema_utils_1.StateNames();
22
+ this.lambdaStates = props.lambdas || new schema_utils_1.LambdaStates();
23
+ this.getMetadata(props.initializeAssets ?? false);
24
+ }
25
+ getDefinition() {
26
+ const startName = this.getNextState(this.resourceMetadata.startAt);
27
+ return {
28
+ StartAt: startName,
29
+ States: this.states,
30
+ };
31
+ }
32
+ async resolveArguments(definition) {
33
+ for (const key in definition.States) {
34
+ const state = definition.States[key];
35
+ if (state.Type === 'Task' && typeof state.Arguments === 'function') {
36
+ state.Arguments = await state.Arguments();
37
+ }
38
+ if (state.Type === 'Map') {
39
+ await this.resolveArguments(state.ItemProcessor);
40
+ }
41
+ if (state.Type === 'Parallel') {
42
+ for (const branch of state.Branches) {
43
+ await this.resolveArguments(branch);
44
+ }
45
+ }
46
+ }
47
+ return definition;
48
+ }
49
+ get hasUnresolvedDependency() {
50
+ return this.unresolvedDependency;
51
+ }
52
+ get buckets() {
53
+ return this.bucketPermissions;
54
+ }
55
+ getMetadata(initializeAssets) {
56
+ this.resourceMetadata = (0, common_1.getResourceMetadata)(this.resource);
57
+ const handlers = (0, common_1.getResourceHandlerMetadata)(this.resource);
58
+ this.handlers = handlers.reduce((acc, handler) => {
59
+ acc[handler.name] = handler;
60
+ return acc;
61
+ }, {});
62
+ if (initializeAssets) {
63
+ resolver_1.lambdaAssets.initializeMetadata({
64
+ foldername: this.resourceMetadata.foldername,
65
+ filename: this.resourceMetadata.filename,
66
+ className: this.resourceMetadata.originalName,
67
+ methods: handlers.map((handler) => handler.name),
68
+ minify: this.resourceMetadata.minify,
69
+ });
70
+ }
71
+ }
72
+ getNextState(currentState, end = false) {
73
+ if (!currentState || end) {
74
+ return;
75
+ }
76
+ if (typeof currentState === 'string') {
77
+ return this.addTaskState(this.handlers[currentState]);
78
+ }
79
+ const stateName = this.getStateName(currentState);
80
+ switch (currentState.type) {
81
+ case 'wait': {
82
+ this.states[stateName] = {
83
+ Type: 'Wait',
84
+ Seconds: currentState.seconds,
85
+ Timestamp: currentState.timestamp,
86
+ Next: this.getNextState(currentState.next),
87
+ };
88
+ break;
89
+ }
90
+ case 'choice': {
91
+ const choices = [];
92
+ for (const choice of currentState.choices) {
93
+ choices.push({
94
+ Condition: choice.condition,
95
+ Next: this.getNextState(choice.next),
96
+ });
97
+ }
98
+ this.states[stateName] = {
99
+ Type: 'Choice',
100
+ Choices: choices,
101
+ Default: this.getNextState(currentState.default),
102
+ };
103
+ break;
104
+ }
105
+ case 'fail': {
106
+ this.states[stateName] = {
107
+ Type: 'Fail',
108
+ Cause: currentState.cause,
109
+ Error: currentState.error,
110
+ };
111
+ break;
112
+ }
113
+ case 'succeed': {
114
+ this.states[stateName] = {
115
+ Type: 'Succeed',
116
+ Output: currentState.output,
117
+ };
118
+ break;
119
+ }
120
+ case 'pass': {
121
+ this.states[stateName] = {
122
+ Type: 'Pass',
123
+ Assign: currentState.assign,
124
+ Output: currentState.output,
125
+ End: currentState.end,
126
+ Next: this.getNextState(currentState.next, currentState.end),
127
+ };
128
+ break;
129
+ }
130
+ case 'parallel': {
131
+ const branchStates = [];
132
+ for (let i = 0; i < currentState.branches.length; i++) {
133
+ const branch = currentState.branches[i];
134
+ const branchSchema = new Schema(this.scope, branch, {
135
+ initializeAssets: true,
136
+ lambdas: this.lambdaStates,
137
+ stateNames: this.stateNames,
138
+ });
139
+ branchStates.push(branchSchema.getDefinition());
140
+ this.mergeBucketPermissions(branchSchema.buckets);
141
+ this.setUnresolvedDependency(branchSchema.unresolvedDependency);
142
+ }
143
+ this.states[stateName] = {
144
+ Type: 'Parallel',
145
+ Arguments: this.getParallelArguments(currentState.arguments),
146
+ Output: currentState.output,
147
+ Assign: currentState.assign,
148
+ End: currentState.end ?? currentState.next === undefined,
149
+ Next: this.getNextState(currentState.next, currentState.end),
150
+ Branches: branchStates,
151
+ };
152
+ this.addRetryAndCatch(currentState, stateName);
153
+ break;
154
+ }
155
+ case 'map': {
156
+ const mapSchema = new Schema(this.scope, currentState.states, {
157
+ initializeAssets: true,
158
+ lambdas: this.lambdaStates,
159
+ stateNames: this.stateNames,
160
+ });
161
+ this.mergeBucketPermissions(mapSchema.buckets);
162
+ const mapState = mapSchema.getDefinition();
163
+ this.setUnresolvedDependency(mapSchema.hasUnresolvedDependency);
164
+ const itemProcessor = {
165
+ ...mapState,
166
+ ProcessorConfig: {
167
+ Mode: 'INLINE',
168
+ },
169
+ };
170
+ const mapTask = {
171
+ Type: 'Map',
172
+ Items: currentState.items,
173
+ ItemProcessor: itemProcessor,
174
+ End: currentState.end ?? currentState.next === undefined,
175
+ Next: this.getNextState(currentState.next, currentState.end),
176
+ Output: currentState.output,
177
+ Assign: currentState.assign,
178
+ };
179
+ if (currentState.mode === 'distributed') {
180
+ itemProcessor.ProcessorConfig = {
181
+ Mode: 'DISTRIBUTED',
182
+ ExecutionType: (currentState.executionType || 'STANDARD').toUpperCase(),
183
+ };
184
+ mapTask.ItemProcessor = itemProcessor;
185
+ if (currentState.itemReader) {
186
+ this.addBucketPermission(currentState.itemReader.bucket, 'read');
187
+ const readerConfig = {
188
+ Resource: 'arn:aws:states:::s3:getObject',
189
+ Arguments: {
190
+ Bucket: currentState.itemReader.bucket,
191
+ Key: currentState.itemReader.key,
192
+ },
193
+ ReaderConfig: {
194
+ InputType: currentState.itemReader.source.toUpperCase(),
195
+ },
196
+ };
197
+ if (currentState.itemReader.source === 'csv') {
198
+ readerConfig.ReaderConfig.CSVDelimiter = currentState.itemReader.delimiter;
199
+ readerConfig.ReaderConfig.CSVHeaderLocation =
200
+ currentState.itemReader.headers?.location;
201
+ readerConfig.ReaderConfig.CSVHeaders =
202
+ currentState.itemReader.headers?.titles;
203
+ readerConfig.ReaderConfig.MaxItems = currentState.itemReader.maxItems;
204
+ }
205
+ mapTask.ItemReader = readerConfig;
206
+ }
207
+ if (currentState.resultWriter) {
208
+ this.addBucketPermission(currentState.resultWriter.bucket, 'write');
209
+ mapTask.ResultWriter = {
210
+ Resource: 'arn:aws:states:::s3:putObject',
211
+ Arguments: {
212
+ Bucket: currentState.resultWriter.bucket,
213
+ Prefix: currentState.resultWriter.prefix,
214
+ },
215
+ WriterConfig: currentState.resultWriter.config
216
+ ? {
217
+ OutputType: currentState.resultWriter.config.outputType,
218
+ Transformation: currentState.resultWriter.config?.transformation,
219
+ }
220
+ : undefined,
221
+ };
222
+ }
223
+ if (currentState.maxItemsPerBatch) {
224
+ mapTask.ItemBatcher = {
225
+ MaxItemsPerBatch: currentState.maxItemsPerBatch,
226
+ };
227
+ }
228
+ if (currentState.toleratedFailureCount) {
229
+ mapTask.ToleratedFailureCount = currentState.toleratedFailureCount;
230
+ }
231
+ if (currentState.toleratedFailurePercentage) {
232
+ mapTask.ToleratedFailurePercentage =
233
+ currentState.toleratedFailurePercentage.toString();
234
+ }
235
+ }
236
+ this.states[stateName] = mapTask;
237
+ this.addRetryAndCatch(currentState, stateName);
238
+ break;
239
+ }
240
+ }
241
+ return stateName;
242
+ }
243
+ getStateName(currentState) {
244
+ if (typeof currentState === 'string') {
245
+ return '';
246
+ }
247
+ return this.stateNames.createName(currentState.type);
248
+ }
249
+ getIntegrationTask(handler) {
250
+ const task = {
251
+ Resource: handler.integrationResource,
252
+ Output: handler.output,
253
+ };
254
+ const resource = new this.resource();
255
+ this.unresolvedDependency = true;
256
+ task.Arguments = async () => {
257
+ const argumentValues = await (0, resolver_1.resolveCallbackResource)(this.scope, (props) => resource[handler.name]({}, props));
258
+ if (!argumentValues) {
259
+ throw new Error('The schema has a unresolved dependency');
260
+ }
261
+ return argumentValues;
262
+ };
263
+ return task;
264
+ }
265
+ getLambdaTask(handler) {
266
+ const id = `${handler.name}-${this.resourceMetadata.name}`;
267
+ const lambdaHandler = this.lambdaStates.createLambda([
268
+ this.scope,
269
+ id,
270
+ {
271
+ ...handler,
272
+ originalName: this.resourceMetadata.originalName,
273
+ filename: this.resourceMetadata.filename,
274
+ foldername: this.resourceMetadata.foldername,
275
+ suffix: 'states',
276
+ },
277
+ ]);
278
+ return {
279
+ Resource: 'arn:aws:states:::lambda:invoke',
280
+ Arguments: {
281
+ Payload: this.getLambdaPayload(handler.name),
282
+ FunctionName: lambdaHandler.functionName,
283
+ },
284
+ Output: handler.output ||
285
+ '{% $exists($states.result.Payload) ? $states.result.Payload : {} %}',
286
+ };
287
+ }
288
+ addTaskState(handler) {
289
+ const stateName = this.stateNames.createName(handler.name);
290
+ if (this.states[stateName]) {
291
+ return handler.name;
292
+ }
293
+ const task = {
294
+ Type: 'Task',
295
+ Resource: '',
296
+ Arguments: {},
297
+ Next: this.getNextState(handler.next, handler.end),
298
+ End: handler.end,
299
+ Assign: handler.assign,
300
+ ...(handler.integrationResource !== undefined
301
+ ? this.getIntegrationTask(handler)
302
+ : this.getLambdaTask(handler)),
303
+ };
304
+ this.states[stateName] = task;
305
+ this.addRetryAndCatch(handler, stateName);
306
+ return stateName;
307
+ }
308
+ getLambdaPayload(stateName) {
309
+ const params = (0, common_1.getMetadataPrototypeByKey)(this.resource, common_1.LambdaReflectKeys.event_param) || {};
310
+ const paramsByMethod = params[stateName];
311
+ if (!paramsByMethod) {
312
+ return {};
313
+ }
314
+ if (paramsByMethod.type === 'String') {
315
+ return paramsByMethod.initialValue || '';
316
+ }
317
+ const stateParameters = {};
318
+ for (const param of paramsByMethod.properties) {
319
+ stateParameters[param.name] = this.parseArgumentParam(param);
320
+ }
321
+ return stateParameters;
322
+ }
323
+ parseArgumentParam = (field) => {
324
+ const { context } = field;
325
+ switch (context) {
326
+ case 'custom': {
327
+ if (field.type !== 'Object') {
328
+ return field.value;
329
+ }
330
+ const params = {};
331
+ if (field.type === 'Object') {
332
+ for (const property of field.properties) {
333
+ params[property.destinationName] = this.parseArgumentParam(property);
334
+ }
335
+ }
336
+ return params;
337
+ }
338
+ case 'input': {
339
+ return `{% $states.input.${field.source} %}`;
340
+ }
341
+ case 'execution': {
342
+ const source = schema_utils_1.mapSourceExecution[field.source];
343
+ return `{% $states.context.Execution.${field.source.startsWith('input.') ? field.source.replace('input.', 'Input.') : source} %}`;
344
+ }
345
+ case 'state_machine': {
346
+ const source = schema_utils_1.mapSourceStateMachine[field.source];
347
+ return `{% $states.context.StateMachine.${source} %}`;
348
+ }
349
+ case 'state': {
350
+ const source = schema_utils_1.mapSourceState[field.source];
351
+ return `{% $states.context.State.${source} %}`;
352
+ }
353
+ case 'task': {
354
+ const source = schema_utils_1.mapSourceTask[field.source];
355
+ return `{% $states.context.Task.${source} %}`;
356
+ }
357
+ case 'jsonata': {
358
+ return field.value;
359
+ }
360
+ }
361
+ };
362
+ getParallelArguments(args) {
363
+ if (!args || typeof args === 'object') {
364
+ return args;
365
+ }
366
+ const params = (0, common_1.getMetadataPrototypeByKey)(args, main_1.stateMachineFieldKey);
367
+ const parallelArguments = {};
368
+ for (const param of params) {
369
+ parallelArguments[param.destinationName] = this.parseArgumentParam(param);
370
+ }
371
+ return parallelArguments;
372
+ }
373
+ addRetry(state, stateName) {
374
+ if (!state.retry || state.retry.length === 0) {
375
+ return;
376
+ }
377
+ const retries = [];
378
+ for (const retry of state.retry || []) {
379
+ retries.push({
380
+ ErrorEquals: retry.errorEquals,
381
+ BackoffRate: retry.backoffRate,
382
+ IntervalSeconds: retry.intervalSeconds,
383
+ MaxAttempts: retry.maxAttempt,
384
+ MaxDelaySeconds: retry.maxDelaySeconds,
385
+ });
386
+ }
387
+ const currentState = this.states[stateName];
388
+ currentState.Retry = retries;
389
+ this.states[stateName] = currentState;
390
+ }
391
+ addCatch(state, stateName) {
392
+ if (!state.catch || state.catch.length === 0) {
393
+ return;
394
+ }
395
+ const catches = [];
396
+ for (const catchValue of state.catch || []) {
397
+ catches.push({
398
+ ErrorEquals: catchValue.errorEquals,
399
+ Next: this.getNextState(catchValue.next),
400
+ });
401
+ }
402
+ const currentState = this.states[stateName];
403
+ currentState.Catch = catches;
404
+ this.states[stateName] = currentState;
405
+ }
406
+ addRetryAndCatch(state, stateName) {
407
+ this.addCatch(state, stateName);
408
+ this.addRetry(state, stateName);
409
+ }
410
+ setUnresolvedDependency(unresolved) {
411
+ if (!this.unresolvedDependency || !unresolved) {
412
+ return;
413
+ }
414
+ this.unresolvedDependency = true;
415
+ }
416
+ mergeBucketPermissions(bucketPermissions) {
417
+ for (const bucket in bucketPermissions) {
418
+ this.addBucketPermission(bucket, bucketPermissions[bucket]);
419
+ }
420
+ }
421
+ addBucketPermission(bucketName, permission) {
422
+ if (!this.bucketPermissions[bucketName]) {
423
+ this.bucketPermissions[bucketName] = permission;
424
+ return;
425
+ }
426
+ if (this.bucketPermissions[bucketName] === 'read' && permission === 'write') {
427
+ this.bucketPermissions[bucketName] = permission;
428
+ }
429
+ }
430
+ }
431
+ exports.Schema = Schema;
@@ -0,0 +1,149 @@
1
+ import type { CsvDelimiter, HeaderLocation, ResultOutputType, ResultTransformation } from '../../../main';
2
+ import type { LambdaStates, StateNames } from './schema.utils';
3
+ export interface Retry {
4
+ ErrorEquals: string[];
5
+ IntervalSeconds?: number;
6
+ MaxAttempts?: number;
7
+ BackoffRate?: number;
8
+ MaxDelaySeconds?: number;
9
+ }
10
+ export interface Catch {
11
+ ErrorEquals: string[];
12
+ Next: string;
13
+ }
14
+ export interface StateTask {
15
+ Type: 'Task';
16
+ Resource: string;
17
+ Arguments: any;
18
+ Output?: string | Record<string, any>;
19
+ Assign?: Record<string, any>;
20
+ Next?: string;
21
+ End?: boolean;
22
+ Retry?: Retry[];
23
+ Catch?: Catch[];
24
+ }
25
+ export interface ParallelBranch {
26
+ StartAt: string;
27
+ States: Record<string, States>;
28
+ }
29
+ export interface ParallelTask {
30
+ Type: 'Parallel';
31
+ Branches: ParallelBranch[];
32
+ Arguments?: Record<string, any>;
33
+ Output?: string | Record<string, any>;
34
+ Assign?: Record<string, any>;
35
+ Next?: string;
36
+ End?: boolean;
37
+ Retry?: Retry[];
38
+ Catch?: Catch[];
39
+ }
40
+ export type ExecutionType = 'EXPRESS' | 'STANDARD';
41
+ export interface DistributedProcessorConfig {
42
+ Mode: 'DISTRIBUTED';
43
+ ExecutionType: ExecutionType;
44
+ }
45
+ export interface InlineProcessorConfig {
46
+ Mode: 'INLINE';
47
+ }
48
+ export interface ItemProcessor extends ParallelBranch {
49
+ ProcessorConfig: DistributedProcessorConfig | InlineProcessorConfig;
50
+ }
51
+ export type ItemReaderTypes = 'CSV' | 'JSON' | 'JSONL' | 'PARQUET' | 'MANIFEST';
52
+ export interface ItemReader {
53
+ Resource: 'arn:aws:states:::s3:getObject';
54
+ ReaderConfig: {
55
+ InputType: ItemReaderTypes;
56
+ CSVHeaderLocation?: HeaderLocation;
57
+ CSVHeaders?: string[];
58
+ Transformation?: 'NONE' | 'LOAD_AND_FLATTEN';
59
+ ManifestType?: 'ATHENA_DATA' | 'S3_INVENTORY';
60
+ CSVDelimiter?: CsvDelimiter;
61
+ MaxItems?: number;
62
+ };
63
+ Arguments: {
64
+ Bucket: string;
65
+ Key: string;
66
+ VersionId?: string;
67
+ };
68
+ }
69
+ interface ResultWriter {
70
+ Resource: 'arn:aws:states:::s3:putObject';
71
+ WriterConfig?: {
72
+ Transformation?: ResultTransformation;
73
+ OutputType?: ResultOutputType;
74
+ };
75
+ Arguments: {
76
+ Bucket: string;
77
+ Prefix?: string;
78
+ };
79
+ }
80
+ interface ItemBatcher {
81
+ MaxItemsPerBatch?: number | string;
82
+ }
83
+ export interface MapTask {
84
+ Type: 'Map';
85
+ ItemProcessor: ItemProcessor;
86
+ ItemReader?: ItemReader;
87
+ ResultWriter?: ResultWriter;
88
+ ItemBatcher?: ItemBatcher;
89
+ Items?: any[] | string;
90
+ MaxConcurrency?: number;
91
+ ToleratedFailurePercentage?: string;
92
+ ToleratedFailureCount?: number;
93
+ Output?: string | Record<string, any>;
94
+ Assign?: Record<string, any>;
95
+ Next?: string;
96
+ End?: boolean;
97
+ Retry?: Retry[];
98
+ Catch?: Catch[];
99
+ }
100
+ export interface PassTask {
101
+ Type: 'Pass';
102
+ Output?: string | Record<string, any>;
103
+ Assign?: Record<string, any>;
104
+ Next?: string;
105
+ End?: boolean;
106
+ }
107
+ export interface WaitTask {
108
+ Type: 'Wait';
109
+ Seconds?: string | number;
110
+ Timestamp?: string;
111
+ Output?: string | Record<string, any>;
112
+ Assign?: Record<string, any>;
113
+ Next?: string;
114
+ End?: boolean;
115
+ }
116
+ export interface ChoiceCondition {
117
+ Condition: string;
118
+ Next: string;
119
+ }
120
+ export interface ChoiceTask {
121
+ Type: 'Choice';
122
+ Choices: ChoiceCondition[];
123
+ Default?: string;
124
+ Output?: string | Record<string, any>;
125
+ Assign?: Record<string, any>;
126
+ }
127
+ export interface SucceedTask {
128
+ Type: 'Succeed';
129
+ Output?: string | Record<string, any>;
130
+ }
131
+ export interface FailTask {
132
+ Type: 'Fail';
133
+ Error?: string;
134
+ Cause?: string;
135
+ }
136
+ export type States = StateTask | ParallelTask | MapTask | ChoiceTask | WaitTask | PassTask | SucceedTask | FailTask;
137
+ export type StatesWithCatchErrors = StateTask | ParallelTask | MapTask;
138
+ export interface SchemaProps {
139
+ initializeAssets?: boolean;
140
+ stateNames?: StateNames | undefined;
141
+ lambdas?: LambdaStates | undefined;
142
+ }
143
+ export interface DefinitionSchema {
144
+ StartAt: string;
145
+ States: Record<string, States>;
146
+ }
147
+ export type PermissionType = 'read' | 'write';
148
+ export type BucketPermission = Record<string, PermissionType>;
149
+ export {};
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });