@lafken/state-machine 0.11.0 → 0.11.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.
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { type ClassResource } from '@lafken/common';
|
|
2
|
+
import type { TerraformResource } from 'cdktn';
|
|
2
3
|
import type { Construct } from 'constructs';
|
|
3
4
|
import type { BucketPermission, DefinitionSchema, SchemaProps } from './schema.types';
|
|
4
5
|
export declare class Schema {
|
|
@@ -12,8 +13,10 @@ export declare class Schema {
|
|
|
12
13
|
private lambdaStates;
|
|
13
14
|
private unresolvedDependency;
|
|
14
15
|
private bucketPermissions;
|
|
16
|
+
private lambdaResources;
|
|
15
17
|
constructor(scope: Construct, resource: ClassResource, props?: SchemaProps);
|
|
16
|
-
|
|
18
|
+
get definition(): DefinitionSchema;
|
|
19
|
+
get resources(): TerraformResource[];
|
|
17
20
|
resolveArguments(definition: DefinitionSchema): Promise<DefinitionSchema>;
|
|
18
21
|
get hasUnresolvedDependency(): boolean;
|
|
19
22
|
get buckets(): BucketPermission;
|
|
@@ -16,6 +16,7 @@ class Schema {
|
|
|
16
16
|
lambdaStates;
|
|
17
17
|
unresolvedDependency = false;
|
|
18
18
|
bucketPermissions = {};
|
|
19
|
+
lambdaResources = [];
|
|
19
20
|
constructor(scope, resource, props = {}) {
|
|
20
21
|
this.scope = scope;
|
|
21
22
|
this.resource = resource;
|
|
@@ -24,13 +25,16 @@ class Schema {
|
|
|
24
25
|
this.lambdaStates = props.lambdas || new schema_utils_1.LambdaStates();
|
|
25
26
|
this.getMetadata(props.initializeAssets ?? false);
|
|
26
27
|
}
|
|
27
|
-
|
|
28
|
+
get definition() {
|
|
28
29
|
const startName = this.getNextState(this.resourceMetadata.startAt);
|
|
29
30
|
return {
|
|
30
31
|
StartAt: startName,
|
|
31
32
|
States: this.states,
|
|
32
33
|
};
|
|
33
34
|
}
|
|
35
|
+
get resources() {
|
|
36
|
+
return this.lambdaResources;
|
|
37
|
+
}
|
|
34
38
|
async resolveArguments(definition) {
|
|
35
39
|
for (const key in definition.States) {
|
|
36
40
|
const state = definition.States[key];
|
|
@@ -139,7 +143,8 @@ class Schema {
|
|
|
139
143
|
stateNames: this.stateNames,
|
|
140
144
|
minify: this.props.minify,
|
|
141
145
|
});
|
|
142
|
-
|
|
146
|
+
this.resources.push(...this.resources);
|
|
147
|
+
branchStates.push(branchSchema.definition);
|
|
143
148
|
this.mergeBucketPermissions(branchSchema.buckets);
|
|
144
149
|
this.setUnresolvedDependency(branchSchema.unresolvedDependency);
|
|
145
150
|
}
|
|
@@ -162,8 +167,9 @@ class Schema {
|
|
|
162
167
|
stateNames: this.stateNames,
|
|
163
168
|
minify: this.props.minify,
|
|
164
169
|
});
|
|
170
|
+
this.resources.push(...this.resources);
|
|
165
171
|
this.mergeBucketPermissions(mapSchema.buckets);
|
|
166
|
-
const mapState = mapSchema.
|
|
172
|
+
const mapState = mapSchema.definition;
|
|
167
173
|
this.setUnresolvedDependency(mapSchema.hasUnresolvedDependency);
|
|
168
174
|
const itemProcessor = {
|
|
169
175
|
...mapState,
|
|
@@ -279,6 +285,7 @@ class Schema {
|
|
|
279
285
|
suffix: 'states',
|
|
280
286
|
},
|
|
281
287
|
]);
|
|
288
|
+
this.resources.push(lambdaHandler);
|
|
282
289
|
return {
|
|
283
290
|
Resource: 'arn:aws:states:::lambda:invoke',
|
|
284
291
|
Arguments: {
|
|
@@ -4,6 +4,7 @@ exports.StateMachine = void 0;
|
|
|
4
4
|
const cloudwatch_log_group_1 = require("@cdktn/provider-aws/lib/cloudwatch-log-group");
|
|
5
5
|
const sfn_state_machine_1 = require("@cdktn/provider-aws/lib/sfn-state-machine");
|
|
6
6
|
const resolver_1 = require("@lafken/resolver");
|
|
7
|
+
const cdktn_1 = require("cdktn");
|
|
7
8
|
const schema_1 = require("./schema/schema");
|
|
8
9
|
class StateMachine extends resolver_1.lafkenResource.make(sfn_state_machine_1.SfnStateMachine) {
|
|
9
10
|
props;
|
|
@@ -27,14 +28,16 @@ class StateMachine extends resolver_1.lafkenResource.make(sfn_state_machine_1.Sf
|
|
|
27
28
|
async attachDefinition() {
|
|
28
29
|
const { classResource } = this.props;
|
|
29
30
|
const schema = new schema_1.Schema(this, classResource, { minify: this.props.minify });
|
|
30
|
-
const definition = await schema.
|
|
31
|
+
const definition = await schema.definition;
|
|
31
32
|
this.overrideRole(schema);
|
|
32
33
|
if (!schema.hasUnresolvedDependency) {
|
|
33
34
|
this.overrideDefinition(definition);
|
|
35
|
+
this.addDependency(...schema.resources);
|
|
34
36
|
}
|
|
35
|
-
|
|
37
|
+
else {
|
|
36
38
|
this.isDependent(async () => {
|
|
37
39
|
this.overrideDefinition(await schema.resolveArguments(definition));
|
|
40
|
+
this.addDependency(...schema.resources);
|
|
38
41
|
});
|
|
39
42
|
}
|
|
40
43
|
}
|
|
@@ -76,6 +79,7 @@ class StateMachine extends resolver_1.lafkenResource.make(sfn_state_machine_1.Sf
|
|
|
76
79
|
},
|
|
77
80
|
principal: 'states.amazonaws.com',
|
|
78
81
|
});
|
|
82
|
+
this.addDependency(role, role.policy);
|
|
79
83
|
this.addOverride('role_arn', role.arn);
|
|
80
84
|
}
|
|
81
85
|
addLoggingConfiguration(resourceMetadata) {
|
|
@@ -91,6 +95,13 @@ class StateMachine extends resolver_1.lafkenResource.make(sfn_state_machine_1.Sf
|
|
|
91
95
|
level: resourceMetadata.loggingConfiguration.level?.toUpperCase(),
|
|
92
96
|
logDestination: `${logGroup.arn}:*`,
|
|
93
97
|
});
|
|
98
|
+
this.addDependency(logGroup);
|
|
99
|
+
}
|
|
100
|
+
addDependency(...resource) {
|
|
101
|
+
this.dependsOn = [
|
|
102
|
+
...(this.dependsOn || []),
|
|
103
|
+
...resource.map((res) => (0, cdktn_1.dependable)(res)),
|
|
104
|
+
];
|
|
94
105
|
}
|
|
95
106
|
}
|
|
96
107
|
exports.StateMachine = StateMachine;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lafken/state-machine",
|
|
3
|
-
"version": "0.11.
|
|
3
|
+
"version": "0.11.1",
|
|
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.
|
|
53
|
+
"@lafken/resolver": "0.11.1"
|
|
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.
|
|
66
|
+
"@lafken/common": "0.11.1"
|
|
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.
|
|
72
|
+
"@lafken/common": "0.11.1"
|
|
73
73
|
},
|
|
74
74
|
"engines": {
|
|
75
75
|
"node": ">=20.19"
|