@izara_project/izara-core-generate-service-code 1.0.98 → 1.0.100
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/src/compile/compileProject.js +16 -5
- package/src/compile/flowValidator.js +47 -8
- package/src/compile/loadSchemas.js +18 -7
- package/src/compile/schemaValidatorSetup.js +16 -0
- package/src/emit/application/coreFunction/emitCoreFunctionArtifacts.js +123 -109
- package/src/emit/application/coreFunction/templates/InitialSetupConfig.ejs +8 -4
- package/src/emit/application/coreFunction/templates/InitialSetupRunner.ejs +2 -2
- package/src/emit/application/crud/templates/CreateComplete_Main.ejs +2 -0
- package/src/emit/application/crud/templates/CreateEndpoint_Main.ejs +4 -4
- package/src/emit/application/crud/templates/CreateLogicalLib.ejs +74 -15
- package/src/emit/application/crud/templates/DeleteComplete_Main.ejs +2 -0
- package/src/emit/application/crud/templates/DeleteEndpoint_Main.ejs +4 -4
- package/src/emit/application/crud/templates/FlowEndpoint_HdrWbs.ejs +7 -5
- package/src/emit/application/crud/templates/UpdateComplete_Main.ejs +2 -0
- package/src/emit/application/crud/templates/UpdateEndpoint_Main.ejs +4 -4
- package/src/emit/application/custom/customFlowPaths.js +13 -16
- package/src/emit/application/custom/customFlowS3.js +277 -66
- package/src/emit/application/custom/customFlows.js +131 -0
- package/src/emit/application/custom/emitCustomFlowApplicationArtifacts.js +3 -1
- package/src/emit/application/custom/templates/FlowEndpoint_Main.ejs +2 -2
- package/src/emit/application/custom/templates/s3/ConfirmAfterUpload_HdrSqs.ejs +110 -0
- package/src/emit/application/custom/templates/s3/ConfirmAfterUpload_Main.ejs +89 -0
- package/src/emit/application/custom/templates/s3/ConfirmComplete_HdrSqs.ejs +110 -0
- package/src/emit/application/custom/templates/s3/ConfirmComplete_Main.ejs +89 -0
- package/src/emit/application/custom/templates/s3/CreateObject_HdrWbs.ejs +2 -1
- package/src/emit/application/custom/templates/s3/CreateObject_Main.ejs +4 -0
- package/src/emit/application/custom/templates/s3/CreatePreSignUrl_HdrSqs.ejs +42 -0
- package/src/emit/application/custom/templates/s3/CreatePreSignUrl_Main.ejs +23 -0
- package/src/emit/application/custom/templates/s3/ProcessS3File_Main.ejs +135 -27
- package/src/emit/application/custom/templates/s3/Start_Main.ejs +197 -0
- package/src/emit/application/rbac/emitDynamicRbacFlowSchemas.js +8 -1
- package/src/emit/application/rbac/emitRbacApplicationArtifacts.js +107 -25
- package/src/emit/application/rbac/templates/ReservedDynamicUsage_Main.ejs +29 -9
- package/src/emit/application/rbac/templates/ReservedUsageTtlExpired_HdrDss.ejs +176 -0
- package/src/emit/application/rbac/templates/UserRbacFlow_Main.ejs +4 -3
- package/src/emit/application/system/templates/Register_HdrWbs.ejs +2 -1
- package/src/emit/infrastructure/functions/functionYamlArtifact.js +31 -8
- package/src/emit/infrastructure/functions/templates/DssFunction_Yaml.ejs +21 -0
- package/src/emit/infrastructure/functions/templates/S3Function_Yaml.ejs +2 -3
- package/src/emit/infrastructure/resources/iamResourceArtifacts.js +67 -5
- package/src/emit/infrastructure/resources/resourceState.js +15 -5
- package/src/emit/infrastructure/resources/s3ResourceArtifacts.js +19 -3
- package/src/emit/infrastructure/resources/templates/GeneratedLambdaRoleServiceConfig.ejs +5 -3
- package/src/emit/infrastructure/resources/templates/S3Bucket_Yaml.ejs +1 -1
- package/src/emit/infrastructure/resources/templates/SystemDynamoDB_Yaml.ejs +2 -2
- package/src/emit/schemas/attributeTree/emitAttributeTreeSchemas.js +62 -1
- package/src/emit/schemas/error/emitErrorSchemas.js +120 -10
- package/src/emit/schemas/error/templates/errorConsts.ejs +12 -0
- package/src/generate.js +32 -34
- package/src/output/mergeHooks.js +105 -5
- package/src/plan/domainRegistry.js +0 -10
- package/task.md +40 -96
- package/test/integration/graphDrivenFlowSchema.test.js +58 -0
- package/test/integration/publicApi.test.js +33 -24
- package/test/unit/application/createTargetRoleHandler.test.js +101 -9
- package/test/unit/application/crudApplicationArtifacts.test.js +4 -0
- package/test/unit/application/customFlowApplicationArtifacts.test.js +6 -6
- package/test/unit/application/customFlowS3.test.js +730 -0
- package/test/unit/infrastructure/functionYamlArtifact.test.js +6 -4
- package/test/unit/infrastructure/resourceArtifacts.test.js +103 -0
- package/test/unit/output/mergeHooks.test.js +137 -0
- package/test/unit/schemas/attributeTreeSchemas.test.js +32 -3
- package/test/unit/schemas/attributeTreeSingleService.test.js +175 -0
- package/test/unit/schemas/dynamicRbacFlowSchemas.test.js +8 -6
- package/test/unit/schemas/dynamicRelationshipFlowSchemas.test.js +51 -0
- package/test/unit/schemas/errorSchemas.test.js +84 -5
- package/test/unit/templates/hookTagsValidation.test.js +83 -0
- package/src/emit/schemas/attributeTree/emitAttributeTreeTargetValueStandard.js +0 -132
- package/test/unit/schemas/attributeTreeDirectives.test.js +0 -177
|
@@ -14,10 +14,7 @@ const OWN_TOPIC_FLOWS = [
|
|
|
14
14
|
'DeleteRolePermissions',
|
|
15
15
|
'DeleteTargetRole',
|
|
16
16
|
'CreateUserRole',
|
|
17
|
-
'DeleteUserFromRole'
|
|
18
|
-
'ReservedDynamicUsage',
|
|
19
|
-
'ConfirmUsage',
|
|
20
|
-
'CancelUsage'
|
|
17
|
+
'DeleteUserFromRole'
|
|
21
18
|
];
|
|
22
19
|
|
|
23
20
|
const LIMIT_FLOWS = [
|
|
@@ -167,6 +164,15 @@ test('generates RBAC own-topic WebSocket entries alongside their SQS handlers',
|
|
|
167
164
|
)
|
|
168
165
|
);
|
|
169
166
|
|
|
167
|
+
await assert.rejects(
|
|
168
|
+
readFile(
|
|
169
|
+
join(
|
|
170
|
+
rootPath,
|
|
171
|
+
'app/src/generatedCode/FlowLimit/ReservedDynamicUsage/source/ReservedDynamicUsage_HdrSqs.js'
|
|
172
|
+
)
|
|
173
|
+
)
|
|
174
|
+
);
|
|
175
|
+
|
|
170
176
|
assert.match(
|
|
171
177
|
await readFile(
|
|
172
178
|
join(
|
|
@@ -196,21 +202,48 @@ test('generates RBAC own-topic WebSocket entries alongside their SQS handlers',
|
|
|
196
202
|
'utf8'
|
|
197
203
|
);
|
|
198
204
|
for (const flowTag of OWN_TOPIC_FLOWS) {
|
|
199
|
-
const isLimit = LIMIT_FLOWS.includes(flowTag);
|
|
200
|
-
const folder = isLimit ? 'FlowLimit' : 'FlowRbac';
|
|
201
|
-
const yaml = isLimit ? limitYaml : rbacYaml;
|
|
202
205
|
assert.match(
|
|
203
206
|
await readFile(
|
|
204
207
|
join(
|
|
205
208
|
rootPath,
|
|
206
|
-
`app/src/generatedCode/${
|
|
209
|
+
`app/src/generatedCode/FlowRbac/${flowTag}/source/${flowTag}_HdrWbs.js`
|
|
207
210
|
),
|
|
208
211
|
'utf8'
|
|
209
212
|
),
|
|
210
213
|
new RegExp(`import ${flowTag}`)
|
|
211
214
|
);
|
|
212
|
-
assert.match(
|
|
215
|
+
assert.match(rbacYaml, new RegExp(`${flowTag}HdrWbs:\\n[\\s\\S]*websocket:`));
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
for (const flowTag of LIMIT_FLOWS) {
|
|
219
|
+
await assert.rejects(
|
|
220
|
+
readFile(
|
|
221
|
+
join(
|
|
222
|
+
rootPath,
|
|
223
|
+
`app/src/generatedCode/FlowLimit/${flowTag}/source/${flowTag}_HdrWbs.js`
|
|
224
|
+
)
|
|
225
|
+
)
|
|
226
|
+
);
|
|
227
|
+
await assert.rejects(
|
|
228
|
+
readFile(
|
|
229
|
+
join(
|
|
230
|
+
rootPath,
|
|
231
|
+
`app/src/generatedCode/FlowLimit/${flowTag}/source/${flowTag}_WbsMain.js`
|
|
232
|
+
)
|
|
233
|
+
)
|
|
234
|
+
);
|
|
235
|
+
assert.doesNotMatch(limitYaml, new RegExp(`${flowTag}HdrWbs:`));
|
|
213
236
|
}
|
|
237
|
+
|
|
238
|
+
const ttlExpiredFile = await readFile(
|
|
239
|
+
join(
|
|
240
|
+
rootPath,
|
|
241
|
+
'app/src/generatedCode/FlowLimit/ReservedUsageTtlExpired/source/ReservedUsageTtlExpired_HdrDss.js'
|
|
242
|
+
),
|
|
243
|
+
'utf8'
|
|
244
|
+
);
|
|
245
|
+
assert.match(ttlExpiredFile, /Auto-refunded expired reservation/);
|
|
246
|
+
assert.match(ttlExpiredFile, /RunningTotalUsage/);
|
|
214
247
|
});
|
|
215
248
|
|
|
216
249
|
test('removes CreateTargetRole handler when RBAC is removed', async () => {
|
|
@@ -244,6 +277,65 @@ test('removes CreateTargetRole handler when RBAC is removed', async () => {
|
|
|
244
277
|
);
|
|
245
278
|
});
|
|
246
279
|
|
|
280
|
+
test('generates synchronous HdrInv and HdrApi handlers for FlowLimit flows', async () => {
|
|
281
|
+
const rootPath = await createProject(true);
|
|
282
|
+
await generateCreateTargetRoleHandler(rootPath);
|
|
283
|
+
|
|
284
|
+
const limitYaml = await readFile(
|
|
285
|
+
join(rootPath, 'app/sls_yaml/generatedCode/source/flow-limits.yml'),
|
|
286
|
+
'utf8'
|
|
287
|
+
);
|
|
288
|
+
|
|
289
|
+
for (const flowTag of ['ReservedDynamicUsage', 'ConfirmUsage', 'CancelUsage']) {
|
|
290
|
+
assert.match(
|
|
291
|
+
limitYaml,
|
|
292
|
+
new RegExp(
|
|
293
|
+
`${flowTag}HdrInv:\\n\\s+handler: src/generatedCode/FlowLimit/${flowTag}/source/${flowTag}_HdrInv\\.main`
|
|
294
|
+
)
|
|
295
|
+
);
|
|
296
|
+
assert.match(
|
|
297
|
+
limitYaml,
|
|
298
|
+
new RegExp(
|
|
299
|
+
`${flowTag}HdrApi:\\n\\s+handler: src/generatedCode/FlowLimit/${flowTag}/source/${flowTag}_HdrApi\\.main`
|
|
300
|
+
)
|
|
301
|
+
);
|
|
302
|
+
|
|
303
|
+
const invFile = await readFile(
|
|
304
|
+
join(
|
|
305
|
+
rootPath,
|
|
306
|
+
`app/src/generatedCode/FlowLimit/${flowTag}/source/${flowTag}_HdrInv.js`
|
|
307
|
+
),
|
|
308
|
+
'utf8'
|
|
309
|
+
);
|
|
310
|
+
assert.match(invFile, /export const main = middleware\.wrap/);
|
|
311
|
+
assert.match(
|
|
312
|
+
invFile,
|
|
313
|
+
new RegExp(`import ${flowTag} from '\\./${flowTag}_Main\\.js'`)
|
|
314
|
+
);
|
|
315
|
+
|
|
316
|
+
const apiFile = await readFile(
|
|
317
|
+
join(
|
|
318
|
+
rootPath,
|
|
319
|
+
`app/src/generatedCode/FlowLimit/${flowTag}/source/${flowTag}_HdrApi.js`
|
|
320
|
+
),
|
|
321
|
+
'utf8'
|
|
322
|
+
);
|
|
323
|
+
assert.match(apiFile, /export const main = middleware\.wrap/);
|
|
324
|
+
assert.match(
|
|
325
|
+
apiFile,
|
|
326
|
+
new RegExp(`import ${flowTag} from '\\./${flowTag}_Main\\.js'`)
|
|
327
|
+
);
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
assert.match(
|
|
331
|
+
limitYaml,
|
|
332
|
+
/ReservedUsageTtlExpiredHdrDss:\n\s+handler: src\/generatedCode\/FlowLimit\/ReservedUsageTtlExpired\/source\/ReservedUsageTtlExpired_HdrDss\.main/
|
|
333
|
+
);
|
|
334
|
+
assert.match(limitYaml, /type: dynamodb/);
|
|
335
|
+
assert.match(limitYaml, /RunningTotalReservedUsageTable/);
|
|
336
|
+
assert.match(limitYaml, /eventName: \["REMOVE"\]/);
|
|
337
|
+
});
|
|
338
|
+
|
|
247
339
|
async function createProject(hasRbac) {
|
|
248
340
|
const rootPath = await mkdtemp(
|
|
249
341
|
join(tmpdir(), 'generate-service-code-v2-rbac-handler-')
|
|
@@ -1119,6 +1119,10 @@ test('emits synchronous ConfirmUsage and CancelUsage invocation in CreateLogical
|
|
|
1119
1119
|
assert.match(createLogicalLib, /CancelUsageHdrInv/);
|
|
1120
1120
|
assert.match(createLogicalLib, /lambda\.invokeSync\(/);
|
|
1121
1121
|
assert.match(createLogicalLib, /publishCompletionMessage\(/);
|
|
1122
|
+
assert.match(createLogicalLib, /OBJECT_QUOTA_SERVICE_TAGS/);
|
|
1123
|
+
assert.match(createLogicalLib, /"order":"UserAccount"/);
|
|
1124
|
+
assert.match(createLogicalLib, /targetFunction,\s*quotaServiceTag/);
|
|
1125
|
+
assert.doesNotMatch(createLogicalLib, /targetFunction,\s*['"]Rbac['"]/);
|
|
1122
1126
|
});
|
|
1123
1127
|
|
|
1124
1128
|
test('emits synchronous AfterHook invocation in Update and Delete handlers', async () => {
|
|
@@ -924,7 +924,7 @@ test('renders nextSteps IAM permissions in InitialSetupConfig', async () => {
|
|
|
924
924
|
const initialSetupConfigContent = await readFile(
|
|
925
925
|
join(
|
|
926
926
|
rootPath,
|
|
927
|
-
'app/
|
|
927
|
+
'app/initial_setup/generatedCode/source/InitialSetupConfig.js'
|
|
928
928
|
),
|
|
929
929
|
'utf8'
|
|
930
930
|
);
|
|
@@ -997,7 +997,7 @@ test('registers SQS queue, SNS subscription, and SNS out topic for custom flowSc
|
|
|
997
997
|
const initialSetupConfigContent = await readFile(
|
|
998
998
|
join(
|
|
999
999
|
rootPath,
|
|
1000
|
-
'app/
|
|
1000
|
+
'app/initial_setup/generatedCode/source/InitialSetupConfig.js'
|
|
1001
1001
|
),
|
|
1002
1002
|
'utf8'
|
|
1003
1003
|
);
|
|
@@ -1030,7 +1030,7 @@ test('uses synchronous RBAC without obsolete callback SQS subscriptions in Initi
|
|
|
1030
1030
|
const initialSetupConfigContent = await readFile(
|
|
1031
1031
|
join(
|
|
1032
1032
|
rootPath,
|
|
1033
|
-
'app/
|
|
1033
|
+
'app/initial_setup/generatedCode/source/InitialSetupConfig.js'
|
|
1034
1034
|
),
|
|
1035
1035
|
'utf8'
|
|
1036
1036
|
);
|
|
@@ -1096,7 +1096,7 @@ test('deduplicates duplicate nextSteps topics across flowSteps in InitialSetupCo
|
|
|
1096
1096
|
const initialSetupConfigContent = await readFile(
|
|
1097
1097
|
join(
|
|
1098
1098
|
rootPath,
|
|
1099
|
-
'app/
|
|
1099
|
+
'app/initial_setup/generatedCode/source/InitialSetupConfig.js'
|
|
1100
1100
|
),
|
|
1101
1101
|
'utf8'
|
|
1102
1102
|
);
|
|
@@ -1275,7 +1275,7 @@ test('renders previousSteps extTopic subscriptions in InitialSetupConfig', async
|
|
|
1275
1275
|
const initialSetupConfigContent = await readFile(
|
|
1276
1276
|
join(
|
|
1277
1277
|
rootPath,
|
|
1278
|
-
'app/
|
|
1278
|
+
'app/initial_setup/generatedCode/source/InitialSetupConfig.js'
|
|
1279
1279
|
),
|
|
1280
1280
|
'utf8'
|
|
1281
1281
|
);
|
|
@@ -1537,7 +1537,7 @@ test('does not emit RbacCallback artifacts or duplicate artifact paths for custo
|
|
|
1537
1537
|
const initialSetupConfigContent = await readFile(
|
|
1538
1538
|
join(
|
|
1539
1539
|
rootPath,
|
|
1540
|
-
'app/
|
|
1540
|
+
'app/initial_setup/generatedCode/source/InitialSetupConfig.js'
|
|
1541
1541
|
),
|
|
1542
1542
|
'utf8'
|
|
1543
1543
|
);
|