@lafken/state-machine 0.14.1 → 0.14.3

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,6 +1,8 @@
1
1
  import { type ClassResource } from '@lafken/common';
2
2
  import type { JsonAtaString, ParamProps } from './param.types';
3
+ /** Reflect-metadata key prefix for state machine field metadata. */
3
4
  export declare const stateMachineFieldKey: string;
5
+ /** Reflect-metadata key prefix for state machine payload metadata. */
4
6
  export declare const stateMachinePayloadKey: string;
5
7
  /**
6
8
  * Parameter decorator that binds the incoming Step Functions state
@@ -3,7 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Param = exports.IntegrationOptions = exports.Payload = exports.Event = exports.stateMachinePayloadKey = exports.stateMachineFieldKey = void 0;
4
4
  const common_1 = require("@lafken/common");
5
5
  const state_machine_1 = require("../state-machine");
6
+ /** Reflect-metadata key prefix for state machine field metadata. */
6
7
  exports.stateMachineFieldKey = (0, common_1.createFieldName)(state_machine_1.RESOURCE_TYPE, common_1.FieldProperties.field);
8
+ /** Reflect-metadata key prefix for state machine payload metadata. */
7
9
  exports.stateMachinePayloadKey = (0, common_1.createFieldName)(state_machine_1.RESOURCE_TYPE, common_1.FieldProperties.payload);
8
10
  /**
9
11
  * Parameter decorator that binds the incoming Step Functions state
@@ -116,6 +116,10 @@ export type StateMachineParamContext = ParamContextBase<'state_machine', StateMa
116
116
  * { context: 'task', source: 'token' }
117
117
  */
118
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
+ */
119
123
  /**
120
124
  * Parameter context for supplying an arbitrary static or computed value
121
125
  * that does not originate from execution, state, or task runtime data.
@@ -123,11 +127,14 @@ export type TaskParamContext = ParamContextBase<'task', TaskSource>;
123
127
  export type CustomParamContext = {
124
128
  context: 'custom';
125
129
  /**
126
- * A simple value
130
+ * Static value to inject as the parameter.
131
+ * Can be a string, number, boolean, or any other JSON-serializable value.
127
132
  */
128
133
  value?: any;
129
134
  /**
130
- * You can extend this value with other
135
+ * Optional type constructor used to cast or transform the value at runtime.
136
+ * When provided, the raw value is converted to the specified type
137
+ * (e.g. `String`, `Number`, `Boolean`, or a custom transformer function).
131
138
  */
132
139
  type?: String | Number | Boolean | Function;
133
140
  };
@@ -3,13 +3,52 @@ import type { JsonAtaString } from '../param';
3
3
  export declare enum StateMachineReflectKeys {
4
4
  nested = "state_machine:nested"
5
5
  }
6
+ /** Generic method signature for any Lambda handler. */
6
7
  export type DefaultMethod = (...args: any) => any;
8
+ /**
9
+ * Step Functions execution type.
10
+ *
11
+ * - `'STANDARD'` — Long-running workflows with exactly-once processing.
12
+ * - `'EXPRESS'` — High-throughput, short-duration workflows with at-least-once processing.
13
+ */
7
14
  export type ProcessorExecutionType = 'STANDARD' | 'EXPRESS';
15
+ /**
16
+ * Map state execution mode.
17
+ *
18
+ * - `'INLINE'` — All iterations run within the same state machine execution.
19
+ * - `'DISTRIBUTED'` — Each iteration can be a separate execution for higher scalability.
20
+ */
8
21
  export type ProcessorMode = 'INLINE' | 'DISTRIBUTED';
22
+ /**
23
+ * CSV delimiter character for distributed map item readers.
24
+ */
9
25
  export type CsvDelimiter = 'COMMA' | 'PIPE' | 'SEMICOLON' | 'SPACE' | 'TAB';
26
+ /**
27
+ * Header location in CSV files for distributed map item readers.
28
+ *
29
+ * - `'FIRST_ROW'` — Headers are in the first row of the CSV.
30
+ * - `'GIVEN'` — Headers are provided explicitly via `titles`.
31
+ */
10
32
  export type HeaderLocation = 'FIRST_ROW' | 'GIVEN';
33
+ /**
34
+ * Output format for distributed map result writers.
35
+ */
11
36
  export type ResultOutputType = 'JSON' | 'JSONL';
37
+ /**
38
+ * Transformation applied to distributed map results before writing.
39
+ *
40
+ * - `'NONE'` — No transformation.
41
+ * - `'COMPACT'` — Compact the JSON output.
42
+ * - `'FLATTEN'` — Flatten nested objects.
43
+ */
12
44
  export type ResultTransformation = 'NONE' | 'COMPACT' | 'FLATTEN';
45
+ /**
46
+ * Integration invocation mode for Step Functions service integrations.
47
+ *
48
+ * - `'sync'` — Wait for the service to complete before proceeding.
49
+ * - `'async'` — Fire-and-forget; the state machine continues immediately.
50
+ * - `'token'` — Use a task token for callback-based integrations.
51
+ */
13
52
  export type IntegrationMode = 'sync' | 'async' | 'token';
14
53
  type ObjectOrJsonAta = Record<string, any> | JsonAtaString;
15
54
  export interface StateName {
@@ -456,6 +495,7 @@ interface ParallelState<T> extends CatchAndRetry<T>, StateName {
456
495
  next?: StateTypes<T>;
457
496
  }
458
497
  interface FailState extends StateName {
498
+ /** State type: Fail. Terminates execution with an error. */
459
499
  type: 'fail';
460
500
  /**
461
501
  * Description about error cause, you can use an jsonata expression
@@ -486,6 +526,7 @@ interface FailState extends StateName {
486
526
  error?: string;
487
527
  }
488
528
  interface SucceedState extends StateName {
529
+ /** State type: Succeed. Terminates execution successfully. */
489
530
  type: 'succeed';
490
531
  /**
491
532
  * State output transformation.
@@ -510,6 +551,7 @@ interface SucceedState extends StateName {
510
551
  output?: ObjectOrJsonAta;
511
552
  }
512
553
  interface PassState<T> extends StateName {
554
+ /** State type: Pass. Passes its input to its output or injects fixed data. */
513
555
  type: 'pass';
514
556
  /**
515
557
  * Next state to execute.
@@ -729,28 +771,55 @@ interface MapInline<T> extends MapStateBase<T> {
729
771
  */
730
772
  mode: 'inline';
731
773
  }
774
+ /**
775
+ * Base configuration for a distributed map item reader.
776
+ */
732
777
  interface MapReaderItemBase {
778
+ /** S3 bucket containing the input data file. */
733
779
  bucket: BucketNames;
780
+ /** S3 object key of the input data file. */
734
781
  key: string;
782
+ /** Maximum number of items to read from the file. */
735
783
  maxItems?: number;
736
784
  }
785
+ /**
786
+ * Item reader for JSON, JSONL, or manifest files.
787
+ */
737
788
  interface MapReaderJSONItem extends MapReaderItemBase {
789
+ /** Input file format. */
738
790
  source: 'json' | 'jsonl' | 'manifest';
791
+ /** JSON pointer expression to locate the array of items within the file. */
739
792
  itemsPointer?: string;
740
793
  }
794
+ /**
795
+ * Item reader for CSV files.
796
+ */
741
797
  interface MapReaderCSVItem extends MapReaderItemBase {
798
+ /** Must be `'csv'` to indicate CSV input. */
742
799
  source: 'csv';
800
+ /** Header configuration for the CSV file. */
743
801
  headers: {
802
+ /** Where the header row is located. */
744
803
  location: HeaderLocation;
804
+ /** Explicit column titles (used when `location` is `'GIVEN'`). */
745
805
  titles?: string[];
746
806
  };
807
+ /** Delimiter character between CSV fields. */
747
808
  delimiter?: CsvDelimiter;
748
809
  }
810
+ /**
811
+ * Configuration for writing distributed map results to S3.
812
+ */
749
813
  interface MapWriteResult {
814
+ /** S3 bucket where results are written. */
750
815
  bucket: BucketNames;
816
+ /** S3 key prefix for the result files. */
751
817
  prefix: string;
818
+ /** Output format and transformation settings. */
752
819
  config?: {
820
+ /** Output file format. */
753
821
  outputType: 'JSON' | 'JSONL';
822
+ /** Transformation applied to the output. */
754
823
  transformation?: 'NONE' | 'COMPACT' | 'FLATTEN';
755
824
  };
756
825
  }
@@ -823,12 +892,21 @@ export interface MapDistributed<T> extends MapStateBase<T> {
823
892
  }
824
893
  type MapState<T> = MapInline<T> | MapDistributed<T>;
825
894
  export type ErrorType = 'States.ALL' | 'States.HeartbeatTimeout' | 'States.Timeout' | 'States.TaskFailed' | 'States.Permissions' | 'States.ResultPathMatchFailure' | 'States.ParameterPathFailure' | 'States.QueryEvaluationError' | 'States.BranchFailed' | 'States.NoChoiceMatched' | 'States.IntrinsicFailure' | 'States.ExceedToleratedFailureThreshold' | 'States.ItemReaderFailed' | 'States.ResultWriterFailed' | (string & {});
895
+ /**
896
+ * Retry configuration for a state in case of failure.
897
+ */
826
898
  interface StateRetry {
899
+ /** Error types that trigger this retry configuration. */
827
900
  errorEquals: ErrorType[];
901
+ /** Seconds to wait before the first retry attempt. */
828
902
  intervalSeconds?: number;
903
+ /** Maximum number of retry attempts. */
829
904
  maxAttempt?: number;
905
+ /** Multiplier applied to `intervalSeconds` after each retry. */
830
906
  backoffRate?: number;
907
+ /** Maximum delay in seconds between retries (caps exponential backoff). */
831
908
  maxDelaySeconds?: number;
909
+ /** Random jitter strategy: `'FULL'` adds up to 100% jitter, `'NONE'` disables it. */
832
910
  jitterStrategy?: 'FULL' | 'NONE';
833
911
  }
834
912
  interface StateCatch<T> {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lafken/state-machine",
3
- "version": "0.14.1",
3
+ "version": "0.14.3",
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.1"
53
+ "@lafken/resolver": "0.14.3"
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.1"
66
+ "@lafken/common": "0.14.3"
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.1"
72
+ "@lafken/common": "0.14.3"
73
73
  },
74
74
  "engines": {
75
75
  "node": ">=20.19"