@izara_project/izara-core-generate-service-code 1.0.67 → 1.0.69
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/.prettierrc +11 -0
- package/package.json +16 -12
- package/scripts/format-ejs.js +104 -0
- package/src/compile/compileProject.js +40 -9
- package/src/compile/loadSchemas.js +120 -11
- package/src/emit/crud/emitCrudApplicationArtifacts.js +188 -41
- package/src/emit/crud/emitDynamicCrudFlowSchemas.js +34 -18
- package/src/emit/crud/generateCrudApplicationArtifacts.js +14 -6
- package/src/emit/crud/generateDynamicCrudFlowSchemas.js +4 -1
- package/src/emit/crud/templates/CreateEndpoint_Main.ejs +296 -105
- package/src/emit/crud/templates/DeleteEndpoint_Main.ejs +222 -144
- package/src/emit/crud/templates/FlowEndpointBeforeLogical_Main.ejs +22 -6
- package/src/emit/crud/templates/FlowEndpointComplete_Main.ejs +134 -43
- package/src/emit/crud/templates/FlowEndpoint_HdrWbs.ejs +51 -31
- package/src/emit/crud/templates/FlowHandler_HdrApi.ejs +53 -45
- package/src/emit/crud/templates/FlowHandler_HdrInv.ejs +28 -26
- package/src/emit/crud/templates/FlowHandler_HdrSqs.ejs +15 -11
- package/src/emit/crud/templates/FlowMain_Wbs.ejs +53 -38
- package/src/emit/crud/templates/GetEndpoint_Main.ejs +6 -3
- package/src/emit/crud/templates/GetRangeEndpoint_Main.ejs +2 -2
- package/src/emit/crud/templates/UpdateEndpoint_Main.ejs +402 -249
- package/src/emit/custom/customFlows.js +68 -28
- package/src/emit/custom/emitCustomFlowApplicationArtifacts.js +520 -123
- package/src/emit/custom/generateCustomFlowApplicationArtifacts.js +28 -8
- package/src/emit/custom/templates/FlowEndpoint_Main.ejs +48 -36
- package/src/emit/custom/templates/FlowStep_Main.ejs +7 -9
- package/src/emit/custom/templates/s3/ConfirmReserved_HdrSqs.ejs +59 -54
- package/src/emit/custom/templates/s3/ConfirmReserved_Main.ejs +33 -23
- package/src/emit/custom/templates/s3/CreateObject_HdrWbs.ejs +30 -23
- package/src/emit/custom/templates/s3/CreateObject_Main.ejs +56 -39
- package/src/emit/custom/templates/s3/CreatePreSignUrl_HdrSqs.ejs +56 -51
- package/src/emit/custom/templates/s3/CreatePreSignUrl_Main.ejs +112 -75
- package/src/emit/custom/templates/s3/FlowHandler_HdrS3.ejs +14 -9
- package/src/emit/custom/templates/s3/ProcessS3File_Main.ejs +11 -8
- package/src/emit/custom/templates/s3/ReservedLimit_HdrSqs.ejs +65 -56
- package/src/emit/custom/templates/s3/ReservedLimit_Main.ejs +74 -52
- package/src/emit/custom/templates/triggerCache/CheckTriggerCache_HdrSqs.ejs +58 -14
- package/src/emit/custom/templates/triggerCache/CheckTriggerCache_Main.ejs +12 -17
- package/src/emit/custom/templates/triggerCache/TriggerCacheComplete_Main.ejs +20 -13
- package/src/emit/custom/templates/triggerCache/TriggerCache_Main.ejs +4 -1
- package/src/emit/function/functionYamlArtifact.js +272 -79
- package/src/emit/function/templates/ApiFunction_Yaml.ejs +7 -0
- package/src/emit/function/templates/EventBridgeFunction_Yaml.ejs +6 -0
- package/src/emit/function/templates/InvFunction_Yaml.ejs +5 -0
- package/src/emit/function/templates/S3Function_Yaml.ejs +16 -0
- package/src/emit/function/templates/SqsFunction_Yaml.ejs +10 -0
- package/src/emit/function/templates/WbsFunction_Yaml.ejs +10 -0
- package/src/emit/rbac/emitDynamicRbacFlowSchemas.js +40 -29
- package/src/emit/rbac/emitRbacApplicationArtifacts.js +171 -72
- package/src/emit/rbac/generateCreateTargetRoleHandler.js +6 -4
- package/src/emit/rbac/generateDynamicRbacFlowSchemas.js +8 -2
- package/src/emit/rbac/rbacFlowTag.js +3 -1
- package/src/emit/rbac/templates/CreateTargetRole_HdrSqs.ejs +41 -18
- package/src/emit/rbac/templates/CreateTargetRole_Main.ejs +23 -3
- package/src/emit/rbac/templates/ListRbac_HdrApi.ejs +27 -5
- package/src/emit/rbac/templates/ListRbac_HdrSqs.ejs +41 -8
- package/src/emit/rbac/templates/ListRbac_Main.ejs +26 -6
- package/src/emit/rbac/templates/RbacMutation_Main.ejs +23 -3
- package/src/emit/rbac/templates/UserRbacFlow_HdrSqs.ejs +46 -0
- package/src/emit/rbac/templates/UserRbacFlow_Main.ejs +152 -33
- package/src/emit/rbac/templates/UserRoleMutation_Main.ejs +24 -4
- package/src/emit/relationship/emitDynamicRelationshipFlowSchemas.js +26 -11
- package/src/emit/relationship/emitRelationshipApplicationArtifacts.js +179 -37
- package/src/emit/relationship/generateDynamicRelationshipFlowSchemas.js +8 -2
- package/src/emit/relationship/generateRelationshipApplicationArtifacts.js +15 -6
- package/src/emit/relationship/templates/ChangeRelationshipComplete_Main.ejs +64 -37
- package/src/emit/relationship/templates/ChangeRelationship_Main.ejs +258 -142
- package/src/emit/relationship/templates/CreateRelationshipComplete_Main.ejs +68 -43
- package/src/emit/relationship/templates/CreateRelationship_Main.ejs +315 -171
- package/src/emit/relationship/templates/DeleteRelationshipComplete_Main.ejs +67 -41
- package/src/emit/relationship/templates/DeleteRelationship_Main.ejs +226 -115
- package/src/emit/relationship/templates/FlowHandler_HdrApi.ejs +41 -33
- package/src/emit/relationship/templates/FlowHandler_HdrDsq.ejs +15 -11
- package/src/emit/relationship/templates/FlowHandler_HdrInv.ejs +28 -26
- package/src/emit/relationship/templates/FlowHandler_HdrSqs.ejs +15 -11
- package/src/emit/relationship/templates/GetRelationshipComplete_Main.ejs +46 -26
- package/src/emit/relationship/templates/GetRelationship_Main.ejs +233 -126
- package/src/emit/relationship/templates/MoveRelationshipComplete_Main.ejs +72 -44
- package/src/emit/relationship/templates/MoveRelationship_Main.ejs +266 -150
- package/src/emit/relationship/templates/UpdateRelationshipComplete_Main.ejs +74 -45
- package/src/emit/relationship/templates/UpdateRelationship_Main.ejs +285 -152
- package/src/emit/resource/emitResourceArtifacts.js +274 -105
- package/src/emit/resource/generateResourceArtifacts.js +15 -6
- package/src/emit/resource/templates/GeneratedLambdaRoleServiceConfig.ejs +139 -0
- package/src/emit/resource/templates/S3Bucket_Yaml.ejs +19 -0
- package/src/emit/resource/templates/S3Subscription_Yaml.ejs +7 -0
- package/src/emit/resource/templates/WebSocketSubscription_Yaml.ejs +7 -0
- package/src/emit/system/emitSystemWebSocketArtifacts.js +61 -165
- package/src/emit/system/templates/WebSocketComplete_HdrSqs.ejs +32 -0
- package/src/emit/system/templates/WebSocketComplete_Main.ejs +46 -0
- package/src/emit/system/templates/WebSocketComplete_Yaml.ejs +19 -0
- package/src/emit/system/templates/WebSocketConnect.ejs +25 -0
- package/src/emit/system/templates/WebSocketConnect_Yaml.ejs +11 -0
- package/src/generate.js +141 -34
- package/src/generateIntTest.js +76 -28
- package/src/generateResourceIntTest.js +35 -12
- package/src/generateResources/IntTest/generateResources/generateResources.js +5 -2
- package/src/generateResources/IntTest/generateResources/templateResources.ejs +18 -30
- package/src/generateResources/IntTest/generateTests/events/events.js +1 -1
- package/src/generateResources/IntTest/generateTests/events/templateEvents.ejs +13 -10
- package/src/generateResources/IntTest/generateTests/generateTemplate.js +2 -2
- package/src/generateResources/IntTest/generateTests/pathIntTest/pathIntTest.js +2 -1
- package/src/generateResources/IntTest/generateTests/pathIntTest/template.ejs +1 -3
- package/src/generateResources/IntTest/generateTests/tests/templateTests.ejs +1 -1
- package/src/generateResources/IntTest/generateTests/tests/tests.js +7 -3
- package/src/generateResources/IntTest/libs/{libs.js → IntTestGenerateLib.js} +34 -23
- package/src/generateResources/IntTest/upload/uploadIntTest.js +33 -19
- package/src/intTestGeneratorShared.js +15 -10
- package/src/output/commitArtifacts.js +99 -39
- package/src/output/mergeHooks.js +24 -10
- package/src/output/validateArtifacts.js +37 -27
- package/src/plan/buildGenerationPlan.js +24 -13
- package/test/core.test.js +116 -49
- package/test/createTargetRoleHandler.test.js +63 -14
- package/test/crudApplicationArtifacts.test.js +128 -23
- package/test/customFlowApplicationArtifacts.test.js +391 -84
- package/test/dynamicCrudFlowSchemas.test.js +74 -26
- package/test/dynamicRbacFlowSchemas.test.js +63 -20
- package/test/dynamicRelationshipFlowSchemas.test.js +65 -18
- package/test/functionYamlArtifact.test.js +67 -10
- package/test/intTestApi.test.js +9 -10
- package/test/publicApi.test.js +184 -44
- package/test/relationshipApplicationArtifacts.test.js +90 -19
- package/test/resourceArtifacts.test.js +183 -33
- package/docs/test.png +0 -0
- package/src/emit/rbac/templates/UserRbacFlow_HdrInv.ejs +0 -10
- package/src/emit/relationship/dynamicRelationshipFlowSchemaTemplate.js +0 -11
- /package/docs/{test.mmd → TriggeredCacheFlow.mmd} +0 -0
package/test/publicApi.test.js
CHANGED
|
@@ -5,6 +5,8 @@ import { tmpdir } from 'node:os';
|
|
|
5
5
|
import { join } from 'node:path';
|
|
6
6
|
import test from 'node:test';
|
|
7
7
|
|
|
8
|
+
process.env.NODE_ENV = 'test';
|
|
9
|
+
|
|
8
10
|
import * as publicApi from '../index.js';
|
|
9
11
|
|
|
10
12
|
const { generate } = publicApi;
|
|
@@ -21,14 +23,26 @@ test('generate commits schemas, application artifacts, and resources in one publ
|
|
|
21
23
|
const rootPath = await createCrudProject();
|
|
22
24
|
const result = await generate(rootPath);
|
|
23
25
|
|
|
24
|
-
assert.strictEqual(result.files.length,
|
|
26
|
+
assert.strictEqual(result.files.length, 39);
|
|
25
27
|
assert.equal(result.project.rootPath, rootPath);
|
|
26
28
|
assert.match(
|
|
27
|
-
await readFile(
|
|
29
|
+
await readFile(
|
|
30
|
+
join(
|
|
31
|
+
rootPath,
|
|
32
|
+
'app/src/generatedCode/FlowObjects/Create/source/Create_Main.js'
|
|
33
|
+
),
|
|
34
|
+
'utf8'
|
|
35
|
+
),
|
|
28
36
|
/CreateMainLogical/
|
|
29
37
|
);
|
|
30
38
|
assert.match(
|
|
31
|
-
await readFile(
|
|
39
|
+
await readFile(
|
|
40
|
+
join(
|
|
41
|
+
rootPath,
|
|
42
|
+
'resource/sls_yaml/generatedCode/source/generated-dynamoDB-table.yml'
|
|
43
|
+
),
|
|
44
|
+
'utf8'
|
|
45
|
+
),
|
|
32
46
|
/Resources:/
|
|
33
47
|
);
|
|
34
48
|
});
|
|
@@ -36,13 +50,20 @@ test('generate commits schemas, application artifacts, and resources in one publ
|
|
|
36
50
|
test('generate logs its lifecycle through the supplied logger', async () => {
|
|
37
51
|
const rootPath = await createCrudProject();
|
|
38
52
|
const messages = [];
|
|
39
|
-
const logger = Object.fromEntries(
|
|
53
|
+
const logger = Object.fromEntries(
|
|
54
|
+
['info', 'debug', 'error'].map((level) => [
|
|
55
|
+
level,
|
|
56
|
+
(message) => messages.push(message)
|
|
57
|
+
])
|
|
58
|
+
);
|
|
40
59
|
|
|
41
60
|
await generate(rootPath, { logger });
|
|
42
61
|
|
|
43
62
|
assert.match(messages[0], /STATUS=STARTED/);
|
|
44
|
-
assert.ok(messages.some(message => /STATUS=SCHEMAS_LOADED/.test(message)));
|
|
45
|
-
assert.ok(
|
|
63
|
+
assert.ok(messages.some((message) => /STATUS=SCHEMAS_LOADED/.test(message)));
|
|
64
|
+
assert.ok(
|
|
65
|
+
messages.some((message) => /STATUS=ARTIFACTS_EMITTED/.test(message))
|
|
66
|
+
);
|
|
46
67
|
assert.match(messages.at(-1), /STATUS=FINISHED/);
|
|
47
68
|
});
|
|
48
69
|
|
|
@@ -51,9 +72,18 @@ test('generate commits RBAC WebSocket entries for own-topic mutation flows', asy
|
|
|
51
72
|
|
|
52
73
|
const result = await generate(rootPath, { serviceTag: 'UserAccount' });
|
|
53
74
|
|
|
54
|
-
assert.ok(
|
|
75
|
+
assert.ok(
|
|
76
|
+
result.files.some(
|
|
77
|
+
(file) =>
|
|
78
|
+
file.path ===
|
|
79
|
+
'app/src/generatedCode/FlowRbac/CreateTargetRole/source/CreateTargetRole_HdrWbs.js'
|
|
80
|
+
)
|
|
81
|
+
);
|
|
55
82
|
assert.match(
|
|
56
|
-
await readFile(
|
|
83
|
+
await readFile(
|
|
84
|
+
join(rootPath, 'app/sls_yaml/generatedCode/source/flow-rbac.yml'),
|
|
85
|
+
'utf8'
|
|
86
|
+
),
|
|
57
87
|
/CreateTargetRoleHdrWbs:\n[\s\S]*websocket:/
|
|
58
88
|
);
|
|
59
89
|
});
|
|
@@ -62,22 +92,52 @@ test('generate commits the system WebSocket completion path for own-topic flows'
|
|
|
62
92
|
const rootPath = await createOwnTopicProject();
|
|
63
93
|
const result = await generate(rootPath);
|
|
64
94
|
|
|
65
|
-
assert.ok(
|
|
66
|
-
|
|
95
|
+
assert.ok(
|
|
96
|
+
result.files.some(
|
|
97
|
+
(file) =>
|
|
98
|
+
file.path ===
|
|
99
|
+
'app/src/generatedCode/SystemFlowSchemas/WebSocketMain/source/WebSocketComplete_HdrSqs.js'
|
|
100
|
+
)
|
|
101
|
+
);
|
|
102
|
+
assert.ok(
|
|
103
|
+
result.files.some(
|
|
104
|
+
(file) =>
|
|
105
|
+
file.path ===
|
|
106
|
+
'app/src/generatedCode/FlowSchemas/Track/source/Track_HdrWbs.js'
|
|
107
|
+
)
|
|
108
|
+
);
|
|
67
109
|
assert.match(
|
|
68
|
-
await readFile(
|
|
110
|
+
await readFile(
|
|
111
|
+
join(rootPath, 'app/sls_yaml/generatedCode/source/flow-schema.yml'),
|
|
112
|
+
'utf8'
|
|
113
|
+
),
|
|
69
114
|
/WebSocketConnect:[\s\S]*route: \$connect[\s\S]*WebSocketCompleteHdrSqs:/
|
|
70
115
|
);
|
|
71
116
|
assert.match(
|
|
72
|
-
await readFile(
|
|
117
|
+
await readFile(
|
|
118
|
+
join(rootPath, 'app/sls_yaml/generatedCode/source/flow-schema.yml'),
|
|
119
|
+
'utf8'
|
|
120
|
+
),
|
|
73
121
|
/filterPatterns:[\s\S]*WebSocketCompleteHdrSqs/
|
|
74
122
|
);
|
|
75
123
|
assert.match(
|
|
76
|
-
await readFile(
|
|
124
|
+
await readFile(
|
|
125
|
+
join(
|
|
126
|
+
rootPath,
|
|
127
|
+
'resource/sls_yaml/generatedCode/source/generated-sns-in-sqs.yml'
|
|
128
|
+
),
|
|
129
|
+
'utf8'
|
|
130
|
+
),
|
|
77
131
|
/WebSocketCompleteHdrSqs:[\s\S]*SubscriptionToOutTrackWebSocketComplete:/
|
|
78
132
|
);
|
|
79
133
|
assert.match(
|
|
80
|
-
await readFile(
|
|
134
|
+
await readFile(
|
|
135
|
+
join(
|
|
136
|
+
rootPath,
|
|
137
|
+
'app/sls_yaml/generatedCode/source/generate-shared-resource.yml'
|
|
138
|
+
),
|
|
139
|
+
'utf8'
|
|
140
|
+
),
|
|
81
141
|
/WebSocketMainRole:/
|
|
82
142
|
);
|
|
83
143
|
for (const path of [
|
|
@@ -89,60 +149,112 @@ test('generate commits the system WebSocket completion path for own-topic flows'
|
|
|
89
149
|
'app/src/generatedCode/FlowSchemas/Track/source/Track_WbsMain.js',
|
|
90
150
|
'app/src/generatedCode/FlowSchemas/Track/source/Track_HdrWbs.js'
|
|
91
151
|
]) {
|
|
92
|
-
execFileSync(process.execPath, ['--check', join(rootPath, path)], {
|
|
152
|
+
execFileSync(process.execPath, ['--check', join(rootPath, path)], {
|
|
153
|
+
stdio: 'inherit'
|
|
154
|
+
});
|
|
93
155
|
}
|
|
94
|
-
const webSocketComplete = await readFile(
|
|
156
|
+
const webSocketComplete = await readFile(
|
|
157
|
+
join(
|
|
158
|
+
rootPath,
|
|
159
|
+
'app/src/generatedCode/SystemFlowSchemas/WebSocketMain/source/WebSocketComplete_Main.js'
|
|
160
|
+
),
|
|
161
|
+
'utf8'
|
|
162
|
+
);
|
|
95
163
|
assert.match(webSocketComplete, /\(\<createIdentifiersFlow\>\)/);
|
|
96
164
|
assert.match(webSocketComplete, /\(\<beforePostMessage\>\)/);
|
|
97
|
-
const webSocketHandler = await readFile(
|
|
165
|
+
const webSocketHandler = await readFile(
|
|
166
|
+
join(
|
|
167
|
+
rootPath,
|
|
168
|
+
'app/src/generatedCode/SystemFlowSchemas/WebSocketMain/source/WebSocketComplete_HdrSqs.js'
|
|
169
|
+
),
|
|
170
|
+
'utf8'
|
|
171
|
+
);
|
|
98
172
|
assert.match(webSocketHandler, /record\.body\.TopicArn/);
|
|
99
173
|
assert.match(webSocketHandler, /addCallingFlowToPassOnProperties/);
|
|
100
174
|
});
|
|
101
175
|
|
|
102
|
-
test('generate commits the
|
|
176
|
+
test('generate commits the trigger-cache suite with its queues when triggerFlowTypes is set', async () => {
|
|
103
177
|
const rootPath = await createTriggerCacheProject();
|
|
104
178
|
const result = await generate(rootPath);
|
|
105
179
|
|
|
106
180
|
for (const path of [
|
|
107
|
-
'app/src/generatedCode/FlowSchemas/Cart/source/
|
|
108
|
-
'app/src/generatedCode/FlowSchemas/Cart/source/
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
]) assert.ok(result.files.some(file => file.path === path));
|
|
181
|
+
'app/src/generatedCode/FlowSchemas/Cart/source/CartCheckTriggerFlows_HdrSqs.js',
|
|
182
|
+
'app/src/generatedCode/FlowSchemas/Cart/source/CartCheckTriggerFlows_Main.js'
|
|
183
|
+
])
|
|
184
|
+
assert.ok(result.files.some((file) => file.path === path));
|
|
112
185
|
assert.match(
|
|
113
|
-
await readFile(
|
|
114
|
-
|
|
186
|
+
await readFile(
|
|
187
|
+
join(rootPath, 'app/sls_yaml/generatedCode/source/flow-schema.yml'),
|
|
188
|
+
'utf8'
|
|
189
|
+
),
|
|
190
|
+
/CartCheckTriggerFlowsHdrSqs:/
|
|
115
191
|
);
|
|
116
192
|
assert.match(
|
|
117
|
-
await readFile(
|
|
118
|
-
|
|
193
|
+
await readFile(
|
|
194
|
+
join(
|
|
195
|
+
rootPath,
|
|
196
|
+
'resource/sls_yaml/generatedCode/source/generated-sns-in-sqs.yml'
|
|
197
|
+
),
|
|
198
|
+
'utf8'
|
|
199
|
+
),
|
|
200
|
+
/CartCheckTriggerFlowsHdrSqs/
|
|
119
201
|
);
|
|
120
202
|
});
|
|
121
203
|
|
|
122
204
|
test('generate removes the system WebSocket path when the last own-topic flow is removed', async () => {
|
|
123
205
|
const rootPath = await createOwnTopicProject();
|
|
124
206
|
await generate(rootPath);
|
|
125
|
-
await writeFile(
|
|
207
|
+
await writeFile(
|
|
208
|
+
join(rootPath, 'app/src/schemas/FlowSchemas/Track.js'),
|
|
209
|
+
"export default { flowTag: 'track', event: ['dsq'] };\n"
|
|
210
|
+
);
|
|
126
211
|
|
|
127
212
|
await generate(rootPath);
|
|
128
213
|
|
|
129
|
-
await assert.rejects(
|
|
130
|
-
|
|
214
|
+
await assert.rejects(
|
|
215
|
+
readFile(
|
|
216
|
+
join(
|
|
217
|
+
rootPath,
|
|
218
|
+
'app/src/generatedCode/SystemFlowSchemas/WebSocketMain/source/WebSocketComplete_HdrSqs.js'
|
|
219
|
+
)
|
|
220
|
+
)
|
|
221
|
+
);
|
|
222
|
+
await assert.rejects(
|
|
223
|
+
readFile(
|
|
224
|
+
join(
|
|
225
|
+
rootPath,
|
|
226
|
+
'app/src/generatedCode/FlowSchemas/Track/source/Track_HdrWbs.js'
|
|
227
|
+
)
|
|
228
|
+
)
|
|
229
|
+
);
|
|
131
230
|
assert.doesNotMatch(
|
|
132
|
-
await readFile(
|
|
231
|
+
await readFile(
|
|
232
|
+
join(
|
|
233
|
+
rootPath,
|
|
234
|
+
'resource/sls_yaml/generatedCode/source/generated-sns-in-sqs.yml'
|
|
235
|
+
),
|
|
236
|
+
'utf8'
|
|
237
|
+
),
|
|
133
238
|
/WebSocketCompleteHdrSqs/
|
|
134
239
|
);
|
|
135
240
|
});
|
|
136
241
|
|
|
137
242
|
test('generate rolls back every slice when one output target conflicts', async () => {
|
|
138
243
|
const rootPath = await createCrudProject();
|
|
139
|
-
await mkdir(
|
|
244
|
+
await mkdir(
|
|
245
|
+
join(rootPath, 'app/sls_yaml/generatedCode/source/flow-objects.yml'),
|
|
246
|
+
{ recursive: true }
|
|
247
|
+
);
|
|
140
248
|
|
|
249
|
+
await assert.rejects(generate(rootPath), /not a file/);
|
|
141
250
|
await assert.rejects(
|
|
142
|
-
|
|
143
|
-
|
|
251
|
+
readFile(
|
|
252
|
+
join(
|
|
253
|
+
rootPath,
|
|
254
|
+
'app/src/schemas/FlowSchemas/generateCode/FlowObjects/Create.js'
|
|
255
|
+
)
|
|
256
|
+
)
|
|
144
257
|
);
|
|
145
|
-
await assert.rejects(readFile(join(rootPath, 'app/src/schemas/FlowSchemas/generateCode/Create.js')));
|
|
146
258
|
});
|
|
147
259
|
|
|
148
260
|
test('generate removes stale CRUD schemas and application artifacts', async () => {
|
|
@@ -155,17 +267,39 @@ test('generate removes stale CRUD schemas and application artifacts', async () =
|
|
|
155
267
|
|
|
156
268
|
const result = await generate(rootPath);
|
|
157
269
|
|
|
158
|
-
assert.equal(result.files.length,
|
|
159
|
-
await assert.rejects(
|
|
160
|
-
|
|
270
|
+
assert.equal(result.files.length, 11);
|
|
271
|
+
await assert.rejects(
|
|
272
|
+
readFile(
|
|
273
|
+
join(
|
|
274
|
+
rootPath,
|
|
275
|
+
'app/src/schemas/FlowSchemas/generateCode/FlowObjects/Create.js'
|
|
276
|
+
)
|
|
277
|
+
)
|
|
278
|
+
);
|
|
279
|
+
await assert.rejects(
|
|
280
|
+
readFile(
|
|
281
|
+
join(
|
|
282
|
+
rootPath,
|
|
283
|
+
'app/src/generatedCode/FlowObjects/Create/source/Create_Main.js'
|
|
284
|
+
)
|
|
285
|
+
)
|
|
286
|
+
);
|
|
161
287
|
assert.match(
|
|
162
|
-
await readFile(
|
|
288
|
+
await readFile(
|
|
289
|
+
join(
|
|
290
|
+
rootPath,
|
|
291
|
+
'resource/sls_yaml/generatedCode/source/generated-dynamoDB-table.yml'
|
|
292
|
+
),
|
|
293
|
+
'utf8'
|
|
294
|
+
),
|
|
163
295
|
/WebSocketTask/
|
|
164
296
|
);
|
|
165
297
|
});
|
|
166
298
|
|
|
167
299
|
async function createCrudProject() {
|
|
168
|
-
const rootPath = await mkdtemp(
|
|
300
|
+
const rootPath = await mkdtemp(
|
|
301
|
+
join(tmpdir(), 'generate-service-code-v2-public-')
|
|
302
|
+
);
|
|
169
303
|
const objectDirectory = join(rootPath, 'app/src/schemas/ObjectSchemas');
|
|
170
304
|
await mkdir(objectDirectory, { recursive: true });
|
|
171
305
|
await writeFile(
|
|
@@ -176,7 +310,9 @@ async function createCrudProject() {
|
|
|
176
310
|
}
|
|
177
311
|
|
|
178
312
|
async function createRbacProject() {
|
|
179
|
-
const rootPath = await mkdtemp(
|
|
313
|
+
const rootPath = await mkdtemp(
|
|
314
|
+
join(tmpdir(), 'generate-service-code-v2-public-rbac-')
|
|
315
|
+
);
|
|
180
316
|
const objectDirectory = join(rootPath, 'app/src/schemas/ObjectSchemas');
|
|
181
317
|
await mkdir(objectDirectory, { recursive: true });
|
|
182
318
|
await writeFile(
|
|
@@ -187,7 +323,9 @@ async function createRbacProject() {
|
|
|
187
323
|
}
|
|
188
324
|
|
|
189
325
|
async function createOwnTopicProject() {
|
|
190
|
-
const rootPath = await mkdtemp(
|
|
326
|
+
const rootPath = await mkdtemp(
|
|
327
|
+
join(tmpdir(), 'generate-service-code-v2-public-websocket-')
|
|
328
|
+
);
|
|
191
329
|
const flowDirectory = join(rootPath, 'app/src/schemas/FlowSchemas');
|
|
192
330
|
await mkdir(flowDirectory, { recursive: true });
|
|
193
331
|
await writeFile(
|
|
@@ -198,12 +336,14 @@ async function createOwnTopicProject() {
|
|
|
198
336
|
}
|
|
199
337
|
|
|
200
338
|
async function createTriggerCacheProject() {
|
|
201
|
-
const rootPath = await mkdtemp(
|
|
339
|
+
const rootPath = await mkdtemp(
|
|
340
|
+
join(tmpdir(), 'generate-service-code-v2-public-trigger-cache-')
|
|
341
|
+
);
|
|
202
342
|
const flowDirectory = join(rootPath, 'app/src/schemas/FlowSchemas');
|
|
203
343
|
await mkdir(flowDirectory, { recursive: true });
|
|
204
344
|
await writeFile(
|
|
205
345
|
join(flowDirectory, 'Cart.js'),
|
|
206
|
-
"export default { flowTag: 'cart', event: ['ownTopic'], statusType: 'triggerCache', objType: { serviceTag: 'Order' }, flowSteps: [{ stepName: '
|
|
346
|
+
"export default { flowTag: 'cart', event: ['ownTopic'], statusType: 'triggerCache', triggerFlowTypes: ['OrderCheckout'], objType: { serviceTag: 'Order' }, flowSteps: [{ stepName: 'start' }] };\n"
|
|
207
347
|
);
|
|
208
348
|
return rootPath;
|
|
209
349
|
}
|
|
@@ -7,37 +7,85 @@ import test, { after } from 'node:test';
|
|
|
7
7
|
import { generateRelationshipApplicationArtifacts } from '../src/emit/relationship/generateRelationshipApplicationArtifacts.js';
|
|
8
8
|
|
|
9
9
|
const roots = new Set();
|
|
10
|
-
after(() =>
|
|
10
|
+
after(() =>
|
|
11
|
+
Promise.all(
|
|
12
|
+
[...roots].map((root) => rm(root, { recursive: true, force: true }))
|
|
13
|
+
)
|
|
14
|
+
);
|
|
11
15
|
|
|
12
16
|
test('emits relationship action and complete handlers with data-first function YAML', async () => {
|
|
13
17
|
const rootPath = await createProject(true);
|
|
14
|
-
const result = await generateRelationshipApplicationArtifacts(rootPath, {
|
|
18
|
+
const result = await generateRelationshipApplicationArtifacts(rootPath, {
|
|
19
|
+
serviceTag: 'orders'
|
|
20
|
+
});
|
|
15
21
|
|
|
16
22
|
assert.equal(result.files.length, 40);
|
|
17
|
-
assert.ok(result.files.every(file => !file.path.includes('/Process')));
|
|
23
|
+
assert.ok(result.files.every((file) => !file.path.includes('/Process')));
|
|
18
24
|
assert.match(
|
|
19
|
-
await readFile(
|
|
25
|
+
await readFile(
|
|
26
|
+
join(
|
|
27
|
+
rootPath,
|
|
28
|
+
'app/src/generatedCode/FlowRelationships/GetRelationship/source/GetRelationship_HdrDsq.js'
|
|
29
|
+
),
|
|
30
|
+
'utf8'
|
|
31
|
+
),
|
|
20
32
|
/import GetRelationship/
|
|
21
33
|
);
|
|
22
34
|
assert.match(
|
|
23
|
-
await readFile(
|
|
35
|
+
await readFile(
|
|
36
|
+
join(
|
|
37
|
+
rootPath,
|
|
38
|
+
'app/src/generatedCode/FlowRelationships/CreateRelationship/source/CreateRelationshipComplete_HdrSqs.js'
|
|
39
|
+
),
|
|
40
|
+
'utf8'
|
|
41
|
+
),
|
|
24
42
|
/import CreateRelationshipComplete/
|
|
25
43
|
);
|
|
26
|
-
const yaml = await readFile(
|
|
44
|
+
const yaml = await readFile(
|
|
45
|
+
join(rootPath, 'app/sls_yaml/generatedCode/source/flow-relationships.yml'),
|
|
46
|
+
'utf8'
|
|
47
|
+
);
|
|
27
48
|
assert.match(yaml, /GetRelHdrApi:/);
|
|
28
49
|
assert.doesNotMatch(yaml, /handler: .*\/Process/);
|
|
29
|
-
assert.match(
|
|
30
|
-
|
|
50
|
+
assert.match(
|
|
51
|
+
yaml,
|
|
52
|
+
/CreateRelHdrSqs:[\s\S]*?iz_resourcePrefix}CreateRelationshipHdrSqs\n/
|
|
53
|
+
);
|
|
54
|
+
assert.doesNotMatch(
|
|
55
|
+
yaml,
|
|
56
|
+
/Process(?:Create|Update|Delete|Get|Change|Move)Relationship/
|
|
57
|
+
);
|
|
31
58
|
assert.match(yaml, /path: \/orders\/orderCustomer\/get/);
|
|
32
59
|
assert.match(yaml, /CreateRelationshipHdrWbs:[\s\S]*websocket:/);
|
|
33
|
-
assert.ok(
|
|
60
|
+
assert.ok(
|
|
61
|
+
yaml.indexOf('CreateRelationshipHdrWbs:') < yaml.indexOf('CreateRelHdrSqs:')
|
|
62
|
+
);
|
|
34
63
|
assert.match(
|
|
35
|
-
await readFile(
|
|
64
|
+
await readFile(
|
|
65
|
+
join(
|
|
66
|
+
rootPath,
|
|
67
|
+
'app/src/generatedCode/FlowRelationships/CreateRelationship/source/CreateRelationship_HdrWbs.js'
|
|
68
|
+
),
|
|
69
|
+
'utf8'
|
|
70
|
+
),
|
|
36
71
|
/import CreateRelationship from '\.\/CreateRelationship_WbsMain\.js'/
|
|
37
72
|
);
|
|
38
|
-
await assert.rejects(
|
|
73
|
+
await assert.rejects(
|
|
74
|
+
readFile(
|
|
75
|
+
join(
|
|
76
|
+
rootPath,
|
|
77
|
+
'app/src/generatedCode/FlowRelationships/CreateRelationship/source/ProcessCreateRelationship_Main.js'
|
|
78
|
+
)
|
|
79
|
+
)
|
|
80
|
+
);
|
|
39
81
|
assert.match(
|
|
40
|
-
await readFile(
|
|
82
|
+
await readFile(
|
|
83
|
+
join(
|
|
84
|
+
rootPath,
|
|
85
|
+
'app/src/generatedCode/FlowRelationships/CreateRelationship/source/CreateRelationship_Main.js'
|
|
86
|
+
),
|
|
87
|
+
'utf8'
|
|
88
|
+
),
|
|
41
89
|
/export default async function createRelationship/
|
|
42
90
|
);
|
|
43
91
|
assert.match(yaml, /CreateRelationshipCompleteHdrSqs:/);
|
|
@@ -45,18 +93,41 @@ test('emits relationship action and complete handlers with data-first function Y
|
|
|
45
93
|
|
|
46
94
|
test('removes managed relationship artifacts after relationships are removed', async () => {
|
|
47
95
|
const rootPath = await createProject(true);
|
|
48
|
-
await generateRelationshipApplicationArtifacts(rootPath, {
|
|
49
|
-
|
|
96
|
+
await generateRelationshipApplicationArtifacts(rootPath, {
|
|
97
|
+
serviceTag: 'orders'
|
|
98
|
+
});
|
|
99
|
+
await rm(
|
|
100
|
+
join(rootPath, 'app/src/schemas/RelationshipSchemas/OrderCustomer.js')
|
|
101
|
+
);
|
|
50
102
|
|
|
51
|
-
assert.deepEqual(
|
|
52
|
-
|
|
53
|
-
|
|
103
|
+
assert.deepEqual(
|
|
104
|
+
(await generateRelationshipApplicationArtifacts(rootPath)).files,
|
|
105
|
+
[]
|
|
106
|
+
);
|
|
107
|
+
await assert.rejects(
|
|
108
|
+
readFile(
|
|
109
|
+
join(
|
|
110
|
+
rootPath,
|
|
111
|
+
'app/src/generatedCode/FlowRelationships/CreateRelationship/source/CreateRelationship_Main.js'
|
|
112
|
+
)
|
|
113
|
+
)
|
|
114
|
+
);
|
|
115
|
+
await assert.rejects(
|
|
116
|
+
readFile(
|
|
117
|
+
join(rootPath, 'app/sls_yaml/generatedCode/source/flow-relationships.yml')
|
|
118
|
+
)
|
|
119
|
+
);
|
|
54
120
|
});
|
|
55
121
|
|
|
56
122
|
async function createProject(withRelationship) {
|
|
57
|
-
const rootPath = await mkdtemp(
|
|
123
|
+
const rootPath = await mkdtemp(
|
|
124
|
+
join(tmpdir(), 'generate-service-code-v2-relationship-application-')
|
|
125
|
+
);
|
|
58
126
|
roots.add(rootPath);
|
|
59
|
-
const relationshipDirectory = join(
|
|
127
|
+
const relationshipDirectory = join(
|
|
128
|
+
rootPath,
|
|
129
|
+
'app/src/schemas/RelationshipSchemas'
|
|
130
|
+
);
|
|
60
131
|
await mkdir(relationshipDirectory, { recursive: true });
|
|
61
132
|
if (withRelationship) {
|
|
62
133
|
await writeFile(
|