@izara_project/izara-core-generate-service-code 1.0.68 → 1.0.70
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/package.json +1 -1
- package/scripts/format-ejs.js +36 -32
- package/src/compile/compileProject.js +26 -10
- package/src/compile/loadSchemas.js +122 -59
- package/src/emit/coreFunction/emitCoreFunctionArtifacts.js +163 -0
- package/src/emit/coreFunction/templates/CoreFunction_Yaml.ejs +38 -0
- package/src/emit/coreFunction/templates/CoreResource_Yaml.ejs +235 -0
- package/src/emit/coreFunction/templates/GenerateSeedDataDynamo_HdrInv.ejs +16 -0
- package/src/emit/coreFunction/templates/GenerateSeedDataDynamo_Main.ejs +38 -0
- package/src/emit/coreFunction/templates/GenerateSeedDataGraphData_HdrInv.ejs +16 -0
- package/src/emit/coreFunction/templates/GenerateSeedDataGraphData_Main.ejs +32 -0
- package/src/emit/coreFunction/templates/GenerateSeedDataGraphSchema_HdrInv.ejs +16 -0
- package/src/emit/coreFunction/templates/GenerateSeedDataGraphSchema_Main.ejs +71 -0
- package/src/emit/coreFunction/templates/GeneratedGraphNodeSchemas.ejs +47 -0
- package/src/emit/coreFunction/templates/GeneratedGraphRelSchemas.ejs +27 -0
- package/src/emit/coreFunction/templates/GeneratedTableConfigs.ejs +34 -0
- package/src/emit/coreFunction/templates/InitialSetupConfig.ejs +108 -0
- package/src/emit/coreFunction/templates/InitialSetup_HdrInv.ejs +12 -0
- package/src/emit/coreFunction/templates/InitialSetup_Main.ejs +51 -0
- package/src/emit/coreFunction/templates/RemoveSeedDataDynamo_HdrInv.ejs +16 -0
- package/src/emit/coreFunction/templates/RemoveSeedDataDynamo_Main.ejs +31 -0
- package/src/emit/coreFunction/templates/UploadSchema_HdrInv.ejs +37 -0
- package/src/emit/coreFunction/templates/UploadSchema_Main.ejs +52 -0
- package/src/emit/crud/emitCrudApplicationArtifacts.js +194 -41
- package/src/emit/crud/emitDynamicCrudFlowSchemas.js +34 -17
- package/src/emit/crud/generateCrudApplicationArtifacts.js +14 -6
- package/src/emit/crud/generateDynamicCrudFlowSchemas.js +4 -1
- package/src/emit/crud/templates/CreateEndpoint_Main.ejs +1 -1
- package/src/emit/crud/templates/DeleteEndpoint_Main.ejs +1 -1
- package/src/emit/crud/templates/GetEndpoint_Main.ejs +2 -2
- package/src/emit/crud/templates/GetRangeEndpoint_Main.ejs +1 -1
- package/src/emit/crud/templates/UpdateEndpoint_Main.ejs +1 -1
- package/src/emit/custom/customFlows.js +23 -13
- package/src/emit/custom/emitCustomFlowApplicationArtifacts.js +535 -114
- package/src/emit/custom/generateCustomFlowApplicationArtifacts.js +28 -8
- package/src/emit/custom/templates/FlowEndpoint_Main.ejs +2 -2
- package/src/emit/custom/templates/FlowStep_Main.ejs +1 -1
- package/src/emit/custom/templates/s3/CreateObject_Main.ejs +1 -1
- package/src/emit/custom/templates/s3/FlowHandler_HdrS3.ejs +2 -2
- package/src/emit/custom/templates/s3/ReservedLimit_HdrSqs.ejs +1 -1
- package/src/emit/custom/templates/s3/ReservedLimit_Main.ejs +1 -1
- package/src/emit/custom/templates/triggerCache/CheckTriggerCache_HdrSqs.ejs +4 -4
- package/src/emit/function/functionYamlArtifact.js +273 -97
- 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 +28 -30
- package/src/emit/rbac/emitRbacApplicationArtifacts.js +6 -6
- 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/UserRbacFlow_Main.ejs +1 -1
- package/src/emit/relationship/emitDynamicRelationshipFlowSchemas.js +26 -10
- package/src/emit/relationship/emitRelationshipApplicationArtifacts.js +189 -37
- package/src/emit/relationship/generateDynamicRelationshipFlowSchemas.js +8 -2
- package/src/emit/relationship/generateRelationshipApplicationArtifacts.js +15 -6
- package/src/emit/relationship/templates/ChangeRelationship_Main.ejs +1 -1
- package/src/emit/relationship/templates/CreateRelationship_Main.ejs +1 -1
- package/src/emit/relationship/templates/DeleteRelationship_Main.ejs +1 -1
- package/src/emit/relationship/templates/GetRelationship_Main.ejs +1 -1
- package/src/emit/relationship/templates/MoveRelationship_Main.ejs +1 -1
- package/src/emit/relationship/templates/UpdateRelationship_Main.ejs +1 -1
- package/src/emit/resource/emitResourceArtifacts.js +249 -123
- package/src/emit/resource/generateResourceArtifacts.js +15 -6
- package/src/emit/resource/templates/DynamoDBTable_Yaml.ejs +18 -18
- package/src/emit/resource/templates/FlowOut_Yaml.ejs +5 -5
- package/src/emit/resource/templates/GeneratedLambdaRoleServiceConfig.ejs +10 -9
- package/src/emit/resource/templates/ResourceBeforeLogicalYaml.ejs +44 -44
- package/src/emit/resource/templates/ResourceSqsYaml.ejs +36 -36
- package/src/emit/resource/templates/ResourceYaml.ejs +48 -48
- package/src/emit/resource/templates/S3Subscription_Yaml.ejs +7 -0
- package/src/emit/resource/templates/SharedResource_Yaml.ejs +11 -11
- package/src/emit/resource/templates/SystemDynamoDB_Yaml.ejs +122 -105
- package/src/emit/resource/templates/WebSocketSubscription_Yaml.ejs +7 -0
- package/src/emit/shared/templates/FindData_HdrSqs.ejs +120 -0
- package/src/emit/shared/templates/FindData_Main.ejs +345 -0
- package/src/emit/{crud → shared}/templates/FlowHandler_HdrApi.ejs +1 -1
- package/src/emit/{relationship → shared}/templates/FlowHandler_HdrDsq.ejs +4 -4
- package/src/emit/{crud → shared}/templates/FlowHandler_HdrInv.ejs +1 -1
- package/src/emit/{crud → shared}/templates/FlowHandler_HdrSqs.ejs +4 -4
- package/src/emit/shared/templates/PaginateProcessLogical_HdrDsq.ejs +162 -0
- package/src/emit/shared/templates/PaginateProcessLogical_HdrSqs.ejs +140 -0
- package/src/emit/shared/templates/PaginateProcessLogical_Main.ejs +268 -0
- package/src/emit/{relationship/templates/FlowHandler_HdrSqs.ejs → shared/templates/ProcessLogical_HdrSqs.ejs} +40 -55
- package/src/emit/shared/templates/ProcessLogical_Main.ejs +448 -0
- package/src/emit/system/emitSystemFindDataArtifacts.js +266 -0
- package/src/emit/system/emitSystemWebSocketArtifacts.js +61 -165
- package/src/emit/system/templates/WebSocketComplete_HdrSqs.ejs +48 -0
- package/src/emit/system/templates/WebSocketComplete_Main.ejs +91 -0
- package/src/emit/system/templates/WebSocketComplete_Yaml.ejs +19 -0
- package/src/emit/system/templates/WebSocketConnect.ejs +45 -0
- package/src/emit/system/templates/WebSocketConnect_Yaml.ejs +11 -0
- package/src/generate.js +166 -36
- 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 +34 -21
- package/src/output/validateArtifacts.js +37 -27
- package/src/plan/buildGenerationPlan.js +24 -13
- package/test/core.test.js +117 -58
- package/test/createTargetRoleHandler.test.js +1 -1
- package/test/crudApplicationArtifacts.test.js +132 -31
- package/test/customFlowApplicationArtifacts.test.js +353 -71
- package/test/dynamicCrudFlowSchemas.test.js +74 -26
- package/test/dynamicRbacFlowSchemas.test.js +61 -14
- 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 +178 -36
- package/test/relationshipApplicationArtifacts.test.js +90 -19
- package/test/resourceArtifacts.test.js +173 -33
- package/src/emit/relationship/dynamicRelationshipFlowSchemaTemplate.js +0 -11
- package/src/emit/relationship/templates/FlowHandler_HdrApi.ejs +0 -59
- package/src/emit/relationship/templates/FlowHandler_HdrInv.ejs +0 -47
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, 41);
|
|
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,12 +149,26 @@ 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
|
});
|
|
@@ -106,13 +180,23 @@ test('generate commits the trigger-cache suite with its queues when triggerFlowT
|
|
|
106
180
|
for (const path of [
|
|
107
181
|
'app/src/generatedCode/FlowSchemas/Cart/source/CartCheckTriggerFlows_HdrSqs.js',
|
|
108
182
|
'app/src/generatedCode/FlowSchemas/Cart/source/CartCheckTriggerFlows_Main.js'
|
|
109
|
-
])
|
|
183
|
+
])
|
|
184
|
+
assert.ok(result.files.some((file) => file.path === path));
|
|
110
185
|
assert.match(
|
|
111
|
-
await readFile(
|
|
186
|
+
await readFile(
|
|
187
|
+
join(rootPath, 'app/sls_yaml/generatedCode/source/flow-schema.yml'),
|
|
188
|
+
'utf8'
|
|
189
|
+
),
|
|
112
190
|
/CartCheckTriggerFlowsHdrSqs:/
|
|
113
191
|
);
|
|
114
192
|
assert.match(
|
|
115
|
-
await readFile(
|
|
193
|
+
await readFile(
|
|
194
|
+
join(
|
|
195
|
+
rootPath,
|
|
196
|
+
'resource/sls_yaml/generatedCode/source/generated-sns-in-sqs.yml'
|
|
197
|
+
),
|
|
198
|
+
'utf8'
|
|
199
|
+
),
|
|
116
200
|
/CartCheckTriggerFlowsHdrSqs/
|
|
117
201
|
);
|
|
118
202
|
});
|
|
@@ -120,27 +204,57 @@ test('generate commits the trigger-cache suite with its queues when triggerFlowT
|
|
|
120
204
|
test('generate removes the system WebSocket path when the last own-topic flow is removed', async () => {
|
|
121
205
|
const rootPath = await createOwnTopicProject();
|
|
122
206
|
await generate(rootPath);
|
|
123
|
-
await writeFile(
|
|
207
|
+
await writeFile(
|
|
208
|
+
join(rootPath, 'app/src/schemas/FlowSchemas/Track.js'),
|
|
209
|
+
"export default { flowTag: 'track', event: ['dsq'] };\n"
|
|
210
|
+
);
|
|
124
211
|
|
|
125
212
|
await generate(rootPath);
|
|
126
213
|
|
|
127
|
-
await assert.rejects(
|
|
128
|
-
|
|
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
|
+
);
|
|
129
230
|
assert.doesNotMatch(
|
|
130
|
-
await readFile(
|
|
231
|
+
await readFile(
|
|
232
|
+
join(
|
|
233
|
+
rootPath,
|
|
234
|
+
'resource/sls_yaml/generatedCode/source/generated-sns-in-sqs.yml'
|
|
235
|
+
),
|
|
236
|
+
'utf8'
|
|
237
|
+
),
|
|
131
238
|
/WebSocketCompleteHdrSqs/
|
|
132
239
|
);
|
|
133
240
|
});
|
|
134
241
|
|
|
135
242
|
test('generate rolls back every slice when one output target conflicts', async () => {
|
|
136
243
|
const rootPath = await createCrudProject();
|
|
137
|
-
await mkdir(
|
|
244
|
+
await mkdir(
|
|
245
|
+
join(rootPath, 'app/sls_yaml/generatedCode/source/flow-objects.yml'),
|
|
246
|
+
{ recursive: true }
|
|
247
|
+
);
|
|
138
248
|
|
|
249
|
+
await assert.rejects(generate(rootPath), /not a file/);
|
|
139
250
|
await assert.rejects(
|
|
140
|
-
|
|
141
|
-
|
|
251
|
+
readFile(
|
|
252
|
+
join(
|
|
253
|
+
rootPath,
|
|
254
|
+
'app/src/schemas/FlowSchemas/generateCode/FlowObjects/Create.js'
|
|
255
|
+
)
|
|
256
|
+
)
|
|
142
257
|
);
|
|
143
|
-
await assert.rejects(readFile(join(rootPath, 'app/src/schemas/FlowSchemas/generateCode/FlowObjects/Create.js')));
|
|
144
258
|
});
|
|
145
259
|
|
|
146
260
|
test('generate removes stale CRUD schemas and application artifacts', async () => {
|
|
@@ -153,17 +267,39 @@ test('generate removes stale CRUD schemas and application artifacts', async () =
|
|
|
153
267
|
|
|
154
268
|
const result = await generate(rootPath);
|
|
155
269
|
|
|
156
|
-
assert.equal(result.files.length,
|
|
157
|
-
await assert.rejects(
|
|
158
|
-
|
|
270
|
+
assert.equal(result.files.length, 12);
|
|
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
|
+
);
|
|
159
287
|
assert.match(
|
|
160
|
-
await readFile(
|
|
288
|
+
await readFile(
|
|
289
|
+
join(
|
|
290
|
+
rootPath,
|
|
291
|
+
'resource/sls_yaml/generatedCode/source/generated-dynamoDB-table.yml'
|
|
292
|
+
),
|
|
293
|
+
'utf8'
|
|
294
|
+
),
|
|
161
295
|
/WebSocketTask/
|
|
162
296
|
);
|
|
163
297
|
});
|
|
164
298
|
|
|
165
299
|
async function createCrudProject() {
|
|
166
|
-
const rootPath = await mkdtemp(
|
|
300
|
+
const rootPath = await mkdtemp(
|
|
301
|
+
join(tmpdir(), 'generate-service-code-v2-public-')
|
|
302
|
+
);
|
|
167
303
|
const objectDirectory = join(rootPath, 'app/src/schemas/ObjectSchemas');
|
|
168
304
|
await mkdir(objectDirectory, { recursive: true });
|
|
169
305
|
await writeFile(
|
|
@@ -174,7 +310,9 @@ async function createCrudProject() {
|
|
|
174
310
|
}
|
|
175
311
|
|
|
176
312
|
async function createRbacProject() {
|
|
177
|
-
const rootPath = await mkdtemp(
|
|
313
|
+
const rootPath = await mkdtemp(
|
|
314
|
+
join(tmpdir(), 'generate-service-code-v2-public-rbac-')
|
|
315
|
+
);
|
|
178
316
|
const objectDirectory = join(rootPath, 'app/src/schemas/ObjectSchemas');
|
|
179
317
|
await mkdir(objectDirectory, { recursive: true });
|
|
180
318
|
await writeFile(
|
|
@@ -185,7 +323,9 @@ async function createRbacProject() {
|
|
|
185
323
|
}
|
|
186
324
|
|
|
187
325
|
async function createOwnTopicProject() {
|
|
188
|
-
const rootPath = await mkdtemp(
|
|
326
|
+
const rootPath = await mkdtemp(
|
|
327
|
+
join(tmpdir(), 'generate-service-code-v2-public-websocket-')
|
|
328
|
+
);
|
|
189
329
|
const flowDirectory = join(rootPath, 'app/src/schemas/FlowSchemas');
|
|
190
330
|
await mkdir(flowDirectory, { recursive: true });
|
|
191
331
|
await writeFile(
|
|
@@ -196,7 +336,9 @@ async function createOwnTopicProject() {
|
|
|
196
336
|
}
|
|
197
337
|
|
|
198
338
|
async function createTriggerCacheProject() {
|
|
199
|
-
const rootPath = await mkdtemp(
|
|
339
|
+
const rootPath = await mkdtemp(
|
|
340
|
+
join(tmpdir(), 'generate-service-code-v2-public-trigger-cache-')
|
|
341
|
+
);
|
|
200
342
|
const flowDirectory = join(rootPath, 'app/src/schemas/FlowSchemas');
|
|
201
343
|
await mkdir(flowDirectory, { recursive: true });
|
|
202
344
|
await writeFile(
|
|
@@ -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(
|