@izara_project/izara-core-generate-service-code 1.0.90 → 1.0.92
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 +7 -10
- package/src/compile/flowValidator.js +6 -0
- package/src/compile/loadSchemas.js +177 -69
- package/src/emit/crud/emitDynamicCrudFlowSchemas.js +2 -2
- package/src/emit/crud/generateCrudApplicationArtifacts.js +15 -17
- package/src/emit/crud/generateDynamicCrudFlowSchemas.js +16 -21
- package/src/emit/crud/loadLocalSchemaArrays.js +4 -8
- package/src/emit/crud/templates/CreateAfterHookCallback_Main.ejs +6 -6
- package/src/emit/crud/templates/CreateBeforeHookCallback_Main.ejs +3 -3
- package/src/emit/crud/templates/CreateComplete_Main.ejs +22 -22
- package/src/emit/crud/templates/CreateEndpoint_Main.ejs +18 -18
- package/src/emit/crud/templates/CreateLogicalLib.ejs +47 -47
- package/src/emit/crud/templates/CreateNodeCallback_Main.ejs +24 -24
- package/src/emit/crud/templates/DeleteAfterHookCallback_Main.ejs +5 -5
- package/src/emit/crud/templates/DeleteBeforeHookCallback_Main.ejs +3 -3
- package/src/emit/crud/templates/DeleteComplete_Main.ejs +23 -23
- package/src/emit/crud/templates/DeleteEndpoint_Main.ejs +15 -15
- package/src/emit/crud/templates/DeleteLogicalLib.ejs +19 -19
- package/src/emit/crud/templates/FlowEndpointRbacCallback_Main.ejs +3 -3
- package/src/emit/crud/templates/UpdateAfterHookCallback_Main.ejs +5 -5
- package/src/emit/crud/templates/UpdateBeforeHookCallback_Main.ejs +3 -3
- package/src/emit/crud/templates/UpdateComplete_Main.ejs +22 -22
- package/src/emit/crud/templates/UpdateEndpoint_Main.ejs +15 -15
- package/src/emit/crud/templates/UpdateLogicalLib.ejs +33 -33
- package/src/emit/custom/customFlowPaths.js +149 -0
- package/src/emit/custom/customFlowS3.js +156 -0
- package/src/emit/custom/customFlowSteps.js +385 -0
- package/src/emit/custom/customFlowTemplates.js +28 -0
- package/src/emit/custom/customFlows.js +48 -19
- package/src/emit/custom/emitCustomFlowApplicationArtifacts.js +57 -692
- package/src/emit/custom/generateCustomFlowApplicationArtifacts.js +27 -25
- package/src/emit/custom/templates/FlowEndpointRbacCallback_Main.ejs +7 -7
- package/src/emit/custom/templates/s3/ConfirmReserved_HdrSqs.ejs +3 -3
- package/src/emit/custom/templates/s3/ConfirmReserved_Main.ejs +3 -3
- package/src/emit/custom/templates/s3/CreatePreSignUrl_HdrSqs.ejs +3 -3
- package/src/emit/custom/templates/s3/CreatePreSignUrl_Main.ejs +4 -4
- package/src/emit/rbac/emitDynamicRbacFlowSchemas.js +26 -6
- package/src/emit/rbac/emitRbacApplicationArtifacts.js +40 -13
- package/src/emit/rbac/generateCreateTargetRoleHandler.js +11 -13
- package/src/emit/rbac/generateDynamicRbacFlowSchemas.js +14 -18
- package/src/emit/rbac/templates/UserRbacFlow_Main.ejs +13 -7
- package/src/emit/relationship/emitDynamicRelationshipFlowSchemas.js +1 -1
- package/src/emit/relationship/generateDynamicRelationshipFlowSchemas.js +16 -19
- package/src/emit/relationship/generateRelationshipApplicationArtifacts.js +19 -19
- package/src/emit/relationship/templates/ChangeRelationshipComplete_HdrSqs.ejs +2 -2
- package/src/emit/relationship/templates/ChangeRelationshipComplete_Main.ejs +6 -6
- package/src/emit/relationship/templates/ChangeRelationship_Main.ejs +17 -17
- package/src/emit/relationship/templates/CreateRelationshipComplete_HdrSqs.ejs +2 -2
- package/src/emit/relationship/templates/CreateRelationshipComplete_Main.ejs +6 -6
- package/src/emit/relationship/templates/CreateRelationship_Main.ejs +14 -14
- package/src/emit/relationship/templates/DeleteRelationshipComplete_HdrSqs.ejs +2 -2
- package/src/emit/relationship/templates/DeleteRelationshipComplete_Main.ejs +6 -6
- package/src/emit/relationship/templates/DeleteRelationship_Main.ejs +10 -10
- package/src/emit/relationship/templates/GetRelationshipComplete_HdrSqs.ejs +2 -2
- package/src/emit/relationship/templates/GetRelationshipComplete_Main.ejs +5 -5
- package/src/emit/relationship/templates/GetRelationship_Main.ejs +9 -9
- package/src/emit/relationship/templates/MoveRelationshipComplete_HdrSqs.ejs +2 -2
- package/src/emit/relationship/templates/MoveRelationshipComplete_Main.ejs +6 -6
- package/src/emit/relationship/templates/MoveRelationship_Main.ejs +15 -15
- package/src/emit/relationship/templates/UpdateRelationshipComplete_HdrSqs.ejs +2 -2
- package/src/emit/relationship/templates/UpdateRelationshipComplete_Main.ejs +6 -6
- package/src/emit/relationship/templates/UpdateRelationship_Main.ejs +11 -11
- package/src/emit/resource/dynamoResourceArtifacts.js +18 -0
- package/src/emit/resource/emitResourceArtifacts.js +13 -1251
- package/src/emit/resource/generateResourceArtifacts.js +20 -20
- package/src/emit/resource/iamResourceArtifacts.js +612 -0
- package/src/emit/resource/resourceState.js +564 -0
- package/src/emit/resource/resourceTemplate.js +30 -0
- package/src/emit/resource/s3ResourceArtifacts.js +14 -0
- package/src/emit/resource/sqsResourceArtifacts.js +113 -0
- package/src/emit/shared/runSubsystemGeneration.js +55 -0
- package/src/emit/shared/templates/FindData_Main.ejs +19 -19
- package/src/emit/shared/templates/PaginateProcessLogical_Main.ejs +3 -3
- package/src/emit/shared/templates/ProcessLogical_Main.ejs +15 -15
- package/src/emit/system/emitSystemWebSocketArtifacts.js +2 -1
- package/test/createTargetRoleHandler.test.js +62 -4
- package/test/crudApplicationArtifacts.test.js +75 -3
- package/test/customFlowApplicationArtifacts.test.js +98 -0
- package/test/dynamicCrudFlowSchemas.test.js +2 -2
- package/test/dynamicRbacFlowSchemas.test.js +32 -4
- package/test/relationshipApplicationArtifacts.test.js +1 -1
- package/test/resourceArtifacts.test.js +99 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@izara_project/izara-core-generate-service-code",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.92",
|
|
4
4
|
"description": "Code for locally generating per service files",
|
|
5
5
|
"homepage": "https://bitbucket.org/izara-core-support-services/izara-core-support-services-generate-service-code#readme",
|
|
6
6
|
"repository": {
|
|
@@ -13,28 +13,25 @@
|
|
|
13
13
|
"exports": "./index.js",
|
|
14
14
|
"main": "index.js",
|
|
15
15
|
"scripts": {
|
|
16
|
-
"
|
|
17
|
-
"
|
|
18
|
-
},
|
|
19
|
-
"jest": {
|
|
20
|
-
"testEnvironment": "node"
|
|
16
|
+
"format:ejs": "node scripts/format-ejs.js",
|
|
17
|
+
"test": "node --test"
|
|
21
18
|
},
|
|
22
19
|
"dependencies": {
|
|
23
20
|
"@izara_project/izara-attribute-tree": "^1.0.15",
|
|
24
|
-
"@izara_project/izara-core-library-core": "^1.0.
|
|
21
|
+
"@izara_project/izara-core-library-core": "^1.0.37",
|
|
22
|
+
"@izara_project/izara-core-library-s3": "^1.0.12",
|
|
25
23
|
"@izara_project/izara-property-nodes": "^1.0.16",
|
|
26
24
|
"@izara_project/izara-shared-core": "^1.0.13",
|
|
27
25
|
"ejs": "^6.0.1",
|
|
28
26
|
"js-beautify": "^2.0.3",
|
|
29
27
|
"ws": "^8.21.3",
|
|
30
|
-
"yaml": "^2.9.
|
|
28
|
+
"yaml": "^2.9.1"
|
|
31
29
|
},
|
|
32
30
|
"devDependencies": {
|
|
33
31
|
"@izara_project/izara-core-library-logger": "^1.0.11",
|
|
34
32
|
"@izara_project/izara-core-library-service-schemas": "1.0.166",
|
|
35
33
|
"@izara_project/izara-shared-service-schemas": "^1.0.74",
|
|
36
|
-
"
|
|
37
|
-
"prettier": "^3.9.6",
|
|
34
|
+
"prettier": "^3.9.8",
|
|
38
35
|
"prettier-plugin-ejs": "^1.0.3"
|
|
39
36
|
},
|
|
40
37
|
"peerDependencies": {
|
|
@@ -44,6 +44,12 @@ export function validateFlowSchema(flowSchema) {
|
|
|
44
44
|
break;
|
|
45
45
|
}
|
|
46
46
|
}
|
|
47
|
+
if (
|
|
48
|
+
flowEvents.includes('generateCode') &&
|
|
49
|
+
flowSchema?.generatedCodeConfig?.invocationType === 'lambdaSyncInv'
|
|
50
|
+
) {
|
|
51
|
+
hasSyncEvent = true;
|
|
52
|
+
}
|
|
47
53
|
|
|
48
54
|
if (hasSyncEvent && steps.length > 1) {
|
|
49
55
|
let flowTag = 'unknown';
|
|
@@ -16,20 +16,31 @@ const consoleLogger = {
|
|
|
16
16
|
error: console.error
|
|
17
17
|
};
|
|
18
18
|
|
|
19
|
-
const VALID_INITIATE_BY_ENUM = [
|
|
20
|
-
|
|
21
|
-
'
|
|
22
|
-
'
|
|
19
|
+
const VALID_INITIATE_BY_ENUM = ['user', 'systemWithUser', 'systemNoUser'];
|
|
20
|
+
const VALID_EVENT_ENUM = [
|
|
21
|
+
'ownTopic',
|
|
22
|
+
'extTopic',
|
|
23
|
+
's3',
|
|
24
|
+
'eventBridge',
|
|
25
|
+
'lambdaSyncInv',
|
|
26
|
+
'lambdaSyncApi',
|
|
27
|
+
'dsq',
|
|
28
|
+
'generateCode'
|
|
23
29
|
];
|
|
24
|
-
|
|
25
30
|
const VALID_CODE_HOOK_TAG_ENUM = ['before', 'after'];
|
|
26
31
|
const VALID_GENERATE_CODE_TAG_ENUM = ['create', 'update', 'delete'];
|
|
32
|
+
const VALID_INVOCATION_TYPE_ENUM = ['ownTopic', 'lambdaSyncInv'];
|
|
27
33
|
|
|
28
34
|
if (basicValidatorSchema?.basicFlowSchema?.properties?.initiateBy) {
|
|
29
35
|
basicValidatorSchema.basicFlowSchema.properties.initiateBy.enum =
|
|
30
36
|
VALID_INITIATE_BY_ENUM;
|
|
31
37
|
}
|
|
32
38
|
|
|
39
|
+
if (basicValidatorSchema?.basicFlowSchema?.properties?.event?.items) {
|
|
40
|
+
basicValidatorSchema.basicFlowSchema.properties.event.items.enum =
|
|
41
|
+
VALID_EVENT_ENUM;
|
|
42
|
+
}
|
|
43
|
+
|
|
33
44
|
if (
|
|
34
45
|
basicValidatorSchema?.basicFlowSchema?.properties?.generatedCodeConfig
|
|
35
46
|
?.properties?.codeHookTag
|
|
@@ -38,48 +49,58 @@ if (
|
|
|
38
49
|
VALID_CODE_HOOK_TAG_ENUM;
|
|
39
50
|
}
|
|
40
51
|
|
|
52
|
+
if (
|
|
53
|
+
basicValidatorSchema?.basicFlowSchema?.properties?.generatedCodeConfig
|
|
54
|
+
?.properties?.invocationType
|
|
55
|
+
) {
|
|
56
|
+
basicValidatorSchema.basicFlowSchema.properties.generatedCodeConfig.properties.invocationType.enum =
|
|
57
|
+
VALID_INVOCATION_TYPE_ENUM;
|
|
58
|
+
}
|
|
59
|
+
|
|
41
60
|
if (
|
|
42
61
|
basicValidatorSchema?.basicFlowSchema?.properties?.generatedCodeConfig
|
|
43
62
|
?.properties?.generateCodeTag
|
|
44
63
|
) {
|
|
45
|
-
basicValidatorSchema.basicFlowSchema.properties.generatedCodeConfig.properties.generateCodeTag =
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
64
|
+
basicValidatorSchema.basicFlowSchema.properties.generatedCodeConfig.properties.generateCodeTag =
|
|
65
|
+
{
|
|
66
|
+
anyOf: [
|
|
67
|
+
{
|
|
68
|
+
type: 'array',
|
|
69
|
+
items: {
|
|
70
|
+
type: 'string',
|
|
71
|
+
enum: VALID_GENERATE_CODE_TAG_ENUM
|
|
72
|
+
}
|
|
73
|
+
},
|
|
74
|
+
{
|
|
50
75
|
type: 'string',
|
|
51
76
|
enum: VALID_GENERATE_CODE_TAG_ENUM
|
|
52
77
|
}
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
type: 'string',
|
|
56
|
-
enum: VALID_GENERATE_CODE_TAG_ENUM
|
|
57
|
-
}
|
|
58
|
-
]
|
|
59
|
-
};
|
|
78
|
+
]
|
|
79
|
+
};
|
|
60
80
|
}
|
|
61
81
|
|
|
62
82
|
if (
|
|
63
83
|
basicValidatorSchema?.basicFlowSchema?.properties?.generatedCodeConfig
|
|
64
84
|
?.properties
|
|
65
85
|
) {
|
|
66
|
-
basicValidatorSchema.basicFlowSchema.properties.generatedCodeConfig.properties.objType =
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
{
|
|
74
|
-
type: 'object',
|
|
75
|
-
properties: {
|
|
76
|
-
objectType: { type: 'string' },
|
|
77
|
-
serviceTag: { type: 'string' }
|
|
86
|
+
basicValidatorSchema.basicFlowSchema.properties.generatedCodeConfig.properties.objType =
|
|
87
|
+
{
|
|
88
|
+
anyOf: [
|
|
89
|
+
{ type: 'string' },
|
|
90
|
+
{
|
|
91
|
+
type: 'array',
|
|
92
|
+
items: { type: 'string' }
|
|
78
93
|
},
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
94
|
+
{
|
|
95
|
+
type: 'object',
|
|
96
|
+
properties: {
|
|
97
|
+
objectType: { type: 'string' },
|
|
98
|
+
serviceTag: { type: 'string' }
|
|
99
|
+
},
|
|
100
|
+
required: ['objectType']
|
|
101
|
+
}
|
|
102
|
+
]
|
|
103
|
+
};
|
|
83
104
|
}
|
|
84
105
|
|
|
85
106
|
const VALID_GENERATED_BY_ENUM = [
|
|
@@ -167,7 +188,40 @@ export async function loadLocalSchemaDirectory(
|
|
|
167
188
|
|
|
168
189
|
if (directoryName === 'FlowSchemas') {
|
|
169
190
|
for (const schema of loadedSchemas) {
|
|
170
|
-
if (
|
|
191
|
+
if (
|
|
192
|
+
Array.isArray(schema?.event) &&
|
|
193
|
+
schema.event.includes('generateCode') &&
|
|
194
|
+
!schema.generatedCodeConfig
|
|
195
|
+
) {
|
|
196
|
+
throw new Error(
|
|
197
|
+
`Unsupported FlowHook configuration in ${entry.name}: ` +
|
|
198
|
+
`flow with event 'generateCode' requires generatedCodeConfig`
|
|
199
|
+
);
|
|
200
|
+
}
|
|
201
|
+
if (
|
|
202
|
+
Object.prototype.hasOwnProperty.call(
|
|
203
|
+
schema?.generatedCodeConfig ?? {},
|
|
204
|
+
'invocationType'
|
|
205
|
+
)
|
|
206
|
+
) {
|
|
207
|
+
const invType = schema.generatedCodeConfig.invocationType;
|
|
208
|
+
if (
|
|
209
|
+
typeof invType !== 'string' ||
|
|
210
|
+
!VALID_INVOCATION_TYPE_ENUM.includes(invType)
|
|
211
|
+
) {
|
|
212
|
+
throw new Error(
|
|
213
|
+
`Unsupported FlowHook configuration in ${entry.name}: ` +
|
|
214
|
+
`generatedCodeConfig.invocationType '${invType}' is invalid. ` +
|
|
215
|
+
`Must be 'ownTopic' or 'lambdaSyncInv'`
|
|
216
|
+
);
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
if (
|
|
220
|
+
Object.prototype.hasOwnProperty.call(
|
|
221
|
+
schema?.generatedCodeConfig ?? {},
|
|
222
|
+
'codeHookTag'
|
|
223
|
+
)
|
|
224
|
+
) {
|
|
171
225
|
const hookTag = schema.generatedCodeConfig.codeHookTag;
|
|
172
226
|
if (hookTag === 'beforeLogical') {
|
|
173
227
|
throw new Error(
|
|
@@ -191,7 +245,7 @@ export async function loadLocalSchemaDirectory(
|
|
|
191
245
|
if (codeTag.length === 0) {
|
|
192
246
|
throw new Error(
|
|
193
247
|
`Unsupported FlowHook configuration in ${entry.name}: ` +
|
|
194
|
-
|
|
248
|
+
`generatedCodeConfig.generateCodeTag array must not be empty`
|
|
195
249
|
);
|
|
196
250
|
}
|
|
197
251
|
for (const tag of codeTag) {
|
|
@@ -201,8 +255,8 @@ export async function loadLocalSchemaDirectory(
|
|
|
201
255
|
) {
|
|
202
256
|
throw new Error(
|
|
203
257
|
`Unsupported FlowHook configuration in ${entry.name}: ` +
|
|
204
|
-
|
|
205
|
-
|
|
258
|
+
`generatedCodeConfig.generateCodeTag contains invalid ` +
|
|
259
|
+
`tag '${tag}'. Must be 'create', 'update', or 'delete'`
|
|
206
260
|
);
|
|
207
261
|
}
|
|
208
262
|
}
|
|
@@ -210,14 +264,14 @@ export async function loadLocalSchemaDirectory(
|
|
|
210
264
|
if (!VALID_GENERATE_CODE_TAG_ENUM.includes(codeTag.toLowerCase())) {
|
|
211
265
|
throw new Error(
|
|
212
266
|
`Unsupported FlowHook configuration in ${entry.name}: ` +
|
|
213
|
-
|
|
214
|
-
|
|
267
|
+
`generatedCodeConfig.generateCodeTag '${codeTag}' ` +
|
|
268
|
+
`is invalid. Must be 'create', 'update', or 'delete'`
|
|
215
269
|
);
|
|
216
270
|
}
|
|
217
271
|
} else {
|
|
218
272
|
throw new Error(
|
|
219
273
|
`Unsupported FlowHook configuration in ${entry.name}: ` +
|
|
220
|
-
|
|
274
|
+
`generatedCodeConfig.generateCodeTag must be an array or string`
|
|
221
275
|
);
|
|
222
276
|
}
|
|
223
277
|
}
|
|
@@ -232,7 +286,7 @@ export async function loadLocalSchemaDirectory(
|
|
|
232
286
|
if (hookObjType.length === 0) {
|
|
233
287
|
throw new Error(
|
|
234
288
|
`Unsupported FlowHook configuration in ${entry.name}: ` +
|
|
235
|
-
|
|
289
|
+
`generatedCodeConfig.objType array must not be empty`
|
|
236
290
|
);
|
|
237
291
|
}
|
|
238
292
|
for (const item of hookObjType) {
|
|
@@ -240,7 +294,7 @@ export async function loadLocalSchemaDirectory(
|
|
|
240
294
|
if (!strVal || typeof strVal !== 'string') {
|
|
241
295
|
throw new Error(
|
|
242
296
|
`Unsupported FlowHook configuration in ${entry.name}: ` +
|
|
243
|
-
|
|
297
|
+
`generatedCodeConfig.objType array items must be non-empty strings or objects with objectType`
|
|
244
298
|
);
|
|
245
299
|
}
|
|
246
300
|
}
|
|
@@ -251,7 +305,7 @@ export async function loadLocalSchemaDirectory(
|
|
|
251
305
|
) {
|
|
252
306
|
throw new Error(
|
|
253
307
|
`Unsupported FlowHook configuration in ${entry.name}: ` +
|
|
254
|
-
|
|
308
|
+
`generatedCodeConfig.objType object must have string property objectType`
|
|
255
309
|
);
|
|
256
310
|
}
|
|
257
311
|
} else if (
|
|
@@ -260,7 +314,7 @@ export async function loadLocalSchemaDirectory(
|
|
|
260
314
|
) {
|
|
261
315
|
throw new Error(
|
|
262
316
|
`Unsupported FlowHook configuration in ${entry.name}: ` +
|
|
263
|
-
|
|
317
|
+
`generatedCodeConfig.objType must be a non-empty string, array, or object`
|
|
264
318
|
);
|
|
265
319
|
}
|
|
266
320
|
}
|
|
@@ -276,20 +330,20 @@ export async function loadLocalSchemaDirectory(
|
|
|
276
330
|
let errors = [];
|
|
277
331
|
|
|
278
332
|
if (directoryName === 'ObjectSchemas') {
|
|
279
|
-
[status, errors] = utils.validateObjectSchema(
|
|
280
|
-
{ logger },
|
|
281
|
-
schema
|
|
282
|
-
);
|
|
333
|
+
[status, errors] = utils.validateObjectSchema({ logger }, schema);
|
|
283
334
|
if (!status && Array.isArray(errors)) {
|
|
284
|
-
errors = errors.filter(
|
|
285
|
-
(err) => !err.includes('billalble')
|
|
286
|
-
);
|
|
335
|
+
errors = errors.filter((err) => !err.includes('billalble'));
|
|
287
336
|
if (VALID_GENERATED_BY_ENUM.includes(schema?.generatedBy)) {
|
|
288
337
|
errors = errors.filter(
|
|
289
338
|
(err) =>
|
|
290
339
|
!err.includes('generatedBy') &&
|
|
291
|
-
!err.includes(
|
|
292
|
-
|
|
340
|
+
!err.includes(
|
|
341
|
+
'must be equal to one of the allowed values (enum)'
|
|
342
|
+
) &&
|
|
343
|
+
!(
|
|
344
|
+
err.includes('should be one of enum') &&
|
|
345
|
+
err.includes(schema?.generatedBy)
|
|
346
|
+
)
|
|
293
347
|
);
|
|
294
348
|
}
|
|
295
349
|
if (errors.length === 0) {
|
|
@@ -308,29 +362,73 @@ export async function loadLocalSchemaDirectory(
|
|
|
308
362
|
schema
|
|
309
363
|
);
|
|
310
364
|
}
|
|
311
|
-
if (
|
|
365
|
+
if (
|
|
366
|
+
!status &&
|
|
367
|
+
Array.isArray(errors) &&
|
|
368
|
+
VALID_GENERATED_BY_ENUM.includes(schema?.generatedBy)
|
|
369
|
+
) {
|
|
312
370
|
errors = errors.filter(
|
|
313
371
|
(err) =>
|
|
314
372
|
!err.includes('generatedBy') &&
|
|
315
|
-
!err.includes(
|
|
316
|
-
|
|
373
|
+
!err.includes(
|
|
374
|
+
'must be equal to one of the allowed values (enum)'
|
|
375
|
+
) &&
|
|
376
|
+
!(
|
|
377
|
+
err.includes('should be one of enum') &&
|
|
378
|
+
err.includes(schema?.generatedBy)
|
|
379
|
+
)
|
|
317
380
|
);
|
|
318
381
|
if (errors.length === 0) {
|
|
319
382
|
status = true;
|
|
320
383
|
}
|
|
321
384
|
}
|
|
322
385
|
} else if (directoryName === 'FlowSchemas') {
|
|
323
|
-
[status, errors] = utils.validateBasicFlowSchema(
|
|
324
|
-
{ logger },
|
|
325
|
-
schema
|
|
326
|
-
);
|
|
386
|
+
[status, errors] = utils.validateBasicFlowSchema({ logger }, schema);
|
|
327
387
|
if (!status && Array.isArray(errors)) {
|
|
328
388
|
if (VALID_INITIATE_BY_ENUM.includes(schema?.initiateBy)) {
|
|
329
389
|
errors = errors.filter(
|
|
330
390
|
(err) =>
|
|
331
391
|
!err.includes('initiateBy') &&
|
|
332
|
-
!err.includes(
|
|
333
|
-
|
|
392
|
+
!err.includes(
|
|
393
|
+
'must be equal to one of the allowed values (enum)'
|
|
394
|
+
) &&
|
|
395
|
+
!(
|
|
396
|
+
err.includes('should be one of enum') &&
|
|
397
|
+
err.includes(schema?.initiateBy)
|
|
398
|
+
)
|
|
399
|
+
);
|
|
400
|
+
}
|
|
401
|
+
if (
|
|
402
|
+
Array.isArray(schema?.event) &&
|
|
403
|
+
schema.event.every((e) => VALID_EVENT_ENUM.includes(e))
|
|
404
|
+
) {
|
|
405
|
+
errors = errors.filter(
|
|
406
|
+
(err) =>
|
|
407
|
+
!err.includes('event') &&
|
|
408
|
+
!err.includes(
|
|
409
|
+
'must be equal to one of the allowed values (enum)'
|
|
410
|
+
) &&
|
|
411
|
+
!(
|
|
412
|
+
err.includes('should be one of enum') &&
|
|
413
|
+
schema.event.some((e) => err.includes(e))
|
|
414
|
+
)
|
|
415
|
+
);
|
|
416
|
+
}
|
|
417
|
+
if (
|
|
418
|
+
VALID_INVOCATION_TYPE_ENUM.includes(
|
|
419
|
+
schema?.generatedCodeConfig?.invocationType
|
|
420
|
+
)
|
|
421
|
+
) {
|
|
422
|
+
errors = errors.filter(
|
|
423
|
+
(err) =>
|
|
424
|
+
!err.includes('invocationType') &&
|
|
425
|
+
!err.includes(
|
|
426
|
+
'must be equal to one of the allowed values (enum)'
|
|
427
|
+
) &&
|
|
428
|
+
!(
|
|
429
|
+
err.includes('should be one of enum') &&
|
|
430
|
+
err.includes(schema?.generatedCodeConfig?.invocationType)
|
|
431
|
+
)
|
|
334
432
|
);
|
|
335
433
|
}
|
|
336
434
|
if (
|
|
@@ -341,7 +439,9 @@ export async function loadLocalSchemaDirectory(
|
|
|
341
439
|
errors = errors.filter(
|
|
342
440
|
(err) =>
|
|
343
441
|
!err.includes('codeHookTag') &&
|
|
344
|
-
!err.includes(
|
|
442
|
+
!err.includes(
|
|
443
|
+
'must be equal to one of the allowed values (enum)'
|
|
444
|
+
) &&
|
|
345
445
|
!(
|
|
346
446
|
err.includes('should be one of enum') &&
|
|
347
447
|
err.includes(schema?.generatedCodeConfig?.codeHookTag)
|
|
@@ -398,6 +498,14 @@ export async function loadLocalSchemaDirectory(
|
|
|
398
498
|
return schemas;
|
|
399
499
|
}
|
|
400
500
|
|
|
501
|
+
export async function loadLocalSchemaArrays(project, options = {}) {
|
|
502
|
+
const [objects, flows] = await Promise.all([
|
|
503
|
+
loadLocalSchemaDirectory(project, 'ObjectSchemas', options),
|
|
504
|
+
loadLocalSchemaDirectory(project, 'FlowSchemas', options)
|
|
505
|
+
]);
|
|
506
|
+
return { objects, flows };
|
|
507
|
+
}
|
|
508
|
+
|
|
401
509
|
/**
|
|
402
510
|
* Resolves extendObjType for ObjectSchemas by fetching the parent schema
|
|
403
511
|
* from S3 and merging its storageResources into the child schema.
|
|
@@ -426,7 +534,7 @@ export async function resolveExtendedObjectSchemas(
|
|
|
426
534
|
try {
|
|
427
535
|
console.log(
|
|
428
536
|
`[DEBUG] [resolveExtendedObjectSchemas] Merging extendObjType ` +
|
|
429
|
-
|
|
537
|
+
`for objectType=${currentSchema.objectType}`,
|
|
430
538
|
{ extendObjType: currentSchema.extendObjType }
|
|
431
539
|
);
|
|
432
540
|
const initialResources = currentSchema.storageResources || {};
|
|
@@ -468,7 +576,7 @@ export async function resolveExtendedObjectSchemas(
|
|
|
468
576
|
} catch (error) {
|
|
469
577
|
console.log(
|
|
470
578
|
`[ERROR] [resolveExtendedObjectSchemas] Failed to merge ` +
|
|
471
|
-
|
|
579
|
+
`extendObjType for objectType=${currentSchema.objectType}`,
|
|
472
580
|
{ error }
|
|
473
581
|
);
|
|
474
582
|
throw error;
|
|
@@ -488,7 +596,7 @@ export async function resolveExtendedObjectSchemas(
|
|
|
488
596
|
try {
|
|
489
597
|
console.log(
|
|
490
598
|
`[DEBUG] [resolveExtendedObjectSchemas] Fetching belongTo ` +
|
|
491
|
-
|
|
599
|
+
`schema for objectType=${currentSchema.objectType}`,
|
|
492
600
|
{ belongTo: belongToTarget }
|
|
493
601
|
);
|
|
494
602
|
const belongToObjType = {
|
|
@@ -504,13 +612,13 @@ export async function resolveExtendedObjectSchemas(
|
|
|
504
612
|
currentSchema.belongToSchema = belongToSchema;
|
|
505
613
|
console.log(
|
|
506
614
|
`[DEBUG] [resolveExtendedObjectSchemas] Successfully fetched ` +
|
|
507
|
-
|
|
615
|
+
`belongTo schema for objectType=${currentSchema.objectType}`,
|
|
508
616
|
{ belongToObjectType: belongToSchema?.objectType }
|
|
509
617
|
);
|
|
510
618
|
} catch (error) {
|
|
511
619
|
console.log(
|
|
512
620
|
`[WARN] [resolveExtendedObjectSchemas] Failed to fetch ` +
|
|
513
|
-
|
|
621
|
+
`belongTo schema for objectType=${currentSchema.objectType}`,
|
|
514
622
|
{ error }
|
|
515
623
|
);
|
|
516
624
|
}
|
|
@@ -572,7 +680,7 @@ export async function resolveGraphServiceTags(
|
|
|
572
680
|
} catch (error) {
|
|
573
681
|
console.log(
|
|
574
682
|
`[DEBUG] [resolveGraphServiceTags] Could not fetch ` +
|
|
575
|
-
|
|
683
|
+
`GraphServerTags.json from bucket=${bucketName}`,
|
|
576
684
|
error
|
|
577
685
|
);
|
|
578
686
|
}
|
|
@@ -175,7 +175,7 @@ function _createDynamicFlow(action, plan, serviceTag = '', initiateBy = 'user')
|
|
|
175
175
|
'returnValue',
|
|
176
176
|
'parentFlowId',
|
|
177
177
|
'status',
|
|
178
|
-
'
|
|
178
|
+
'foundErrors',
|
|
179
179
|
'graphServiceTag'
|
|
180
180
|
],
|
|
181
181
|
messageAttributes: MESSAGE_ATTRIBUTES
|
|
@@ -210,7 +210,7 @@ function _createDynamicFlow(action, plan, serviceTag = '', initiateBy = 'user')
|
|
|
210
210
|
'returnValue',
|
|
211
211
|
'parentFlowId',
|
|
212
212
|
'status',
|
|
213
|
-
'
|
|
213
|
+
'foundErrors',
|
|
214
214
|
'graphServiceTag'
|
|
215
215
|
]
|
|
216
216
|
: [],
|
|
@@ -1,25 +1,23 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { compileProject } from '../../compile/compileProject.js';
|
|
4
|
-
import { loadLocalSchemaArrays } from './loadLocalSchemaArrays.js';
|
|
1
|
+
import { loadLocalSchemaArrays } from '../../compile/loadSchemas.js';
|
|
2
|
+
import { runSubsystemGeneration } from '../shared/runSubsystemGeneration.js';
|
|
5
3
|
import {
|
|
6
4
|
crudApplicationManagedPaths,
|
|
7
5
|
emitCrudApplicationArtifacts
|
|
8
6
|
} from './emitCrudApplicationArtifacts.js';
|
|
9
7
|
|
|
10
8
|
export async function generateCrudApplicationArtifacts(rootPath, options = {}) {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
9
|
+
return await runSubsystemGeneration({
|
|
10
|
+
rootPath,
|
|
11
|
+
options,
|
|
12
|
+
loadInputs: (project, opt) => loadLocalSchemaArrays(project, opt),
|
|
13
|
+
emitArtifacts: ({ objects, flows, project, options: opt }) =>
|
|
14
|
+
emitCrudApplicationArtifacts({
|
|
15
|
+
objects,
|
|
16
|
+
flows,
|
|
17
|
+
serviceTag: project.serviceTag,
|
|
18
|
+
logger: opt.logger
|
|
19
|
+
}),
|
|
20
|
+
managedScope: 'crud-application',
|
|
21
|
+
resolveManagedPaths: () => crudApplicationManagedPaths()
|
|
17
22
|
});
|
|
18
|
-
const files = await commitArtifacts(
|
|
19
|
-
buildGenerationPlan(project, artifacts, {
|
|
20
|
-
managedPaths: crudApplicationManagedPaths(),
|
|
21
|
-
managedScope: 'crud-application'
|
|
22
|
-
})
|
|
23
|
-
);
|
|
24
|
-
return { project, files };
|
|
25
23
|
}
|
|
@@ -1,28 +1,23 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { compileProject } from '../../compile/compileProject.js';
|
|
1
|
+
import { loadLocalSchemaArrays } from '../../compile/loadSchemas.js';
|
|
2
|
+
import { runSubsystemGeneration } from '../shared/runSubsystemGeneration.js';
|
|
4
3
|
import {
|
|
5
4
|
dynamicCrudFlowSchemaPaths,
|
|
6
5
|
emitDynamicCrudFlowSchemas
|
|
7
6
|
} from './emitDynamicCrudFlowSchemas.js';
|
|
8
|
-
import { loadLocalSchemaArrays } from './loadLocalSchemaArrays.js';
|
|
9
7
|
|
|
10
8
|
export async function generateDynamicCrudFlowSchemas(rootPath, options = {}) {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
project,
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
);
|
|
25
|
-
const files = await commitArtifacts(plan);
|
|
26
|
-
|
|
27
|
-
return { project, files };
|
|
9
|
+
return await runSubsystemGeneration({
|
|
10
|
+
rootPath,
|
|
11
|
+
options,
|
|
12
|
+
loadInputs: (project, opt) => loadLocalSchemaArrays(project, opt),
|
|
13
|
+
emitArtifacts: ({ objects, flows, project, options: opt }) =>
|
|
14
|
+
emitDynamicCrudFlowSchemas({
|
|
15
|
+
objects,
|
|
16
|
+
flows,
|
|
17
|
+
serviceTag: project.serviceTag,
|
|
18
|
+
logger: opt.logger
|
|
19
|
+
}),
|
|
20
|
+
managedScope: 'crud-flow-schemas',
|
|
21
|
+
resolveManagedPaths: dynamicCrudFlowSchemaPaths
|
|
22
|
+
});
|
|
28
23
|
}
|
|
@@ -1,8 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
objects: await loadLocalSchemaDirectory(project, 'ObjectSchemas', options),
|
|
6
|
-
flows: await loadLocalSchemaDirectory(project, 'FlowSchemas', options)
|
|
7
|
-
};
|
|
8
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* @deprecated Use `loadLocalSchemaArrays` from `../../compile/loadSchemas.js` instead.
|
|
3
|
+
*/
|
|
4
|
+
export { loadLocalSchemaArrays } from '../../compile/loadSchemas.js';
|
|
@@ -49,12 +49,12 @@ export default async function CreateAfterHookCallbackMain(
|
|
|
49
49
|
|
|
50
50
|
const {
|
|
51
51
|
status,
|
|
52
|
-
|
|
52
|
+
foundErrors = [],
|
|
53
53
|
returnValue,
|
|
54
54
|
parentFlowId
|
|
55
55
|
} = requestParams;
|
|
56
56
|
|
|
57
|
-
const mergedErrors = Array.isArray(
|
|
57
|
+
const mergedErrors = Array.isArray(foundErrors) ? [...foundErrors] : [];
|
|
58
58
|
if (status === 'error' && mergedErrors.length === 0) {
|
|
59
59
|
mergedErrors.push('AfterHook execution reported error');
|
|
60
60
|
}
|
|
@@ -78,13 +78,13 @@ export default async function CreateAfterHookCallbackMain(
|
|
|
78
78
|
targetIdentifiers: requestParams?.targetIdentifiers,
|
|
79
79
|
parentFlowId: parentFlowId || returnValue?.parentFlowId,
|
|
80
80
|
status: mergedErrors.length > 0 ? 'error' : 'complete',
|
|
81
|
-
|
|
81
|
+
foundErrors: mergedErrors
|
|
82
82
|
};
|
|
83
83
|
|
|
84
84
|
if (quotaKeys) {
|
|
85
85
|
await forwardToQuotaConfirmation(_izContext, {
|
|
86
86
|
status: mergedErrors.length > 0 ? 'error' : 'complete',
|
|
87
|
-
|
|
87
|
+
foundErrors: mergedErrors,
|
|
88
88
|
quotaKeys,
|
|
89
89
|
actionData,
|
|
90
90
|
callingFlowConfig
|
|
@@ -97,7 +97,7 @@ export default async function CreateAfterHookCallbackMain(
|
|
|
97
97
|
const completionPayload = {
|
|
98
98
|
...actionData,
|
|
99
99
|
status: mergedErrors.length > 0 ? 'error' : 'complete',
|
|
100
|
-
|
|
100
|
+
foundErrors: mergedErrors
|
|
101
101
|
};
|
|
102
102
|
await sns.publishAsync(_izContext, {
|
|
103
103
|
TopicArn: topicArn,
|
|
@@ -112,7 +112,7 @@ export default async function CreateAfterHookCallbackMain(
|
|
|
112
112
|
return {
|
|
113
113
|
returnValue,
|
|
114
114
|
status: mergedErrors.length > 0 ? 'error' : 'complete',
|
|
115
|
-
|
|
115
|
+
foundErrors: mergedErrors
|
|
116
116
|
};
|
|
117
117
|
} catch (error) {
|
|
118
118
|
_izContext.logger.error('[CreateAfterHookCallback] error:', error);
|
|
@@ -45,12 +45,12 @@ export default async function <%- upperCaseFlowTag %>BeforeHookCallbackMain(
|
|
|
45
45
|
|
|
46
46
|
const {
|
|
47
47
|
status,
|
|
48
|
-
|
|
48
|
+
foundErrors = [],
|
|
49
49
|
returnValue,
|
|
50
50
|
parentFlowId
|
|
51
51
|
} = requestParams;
|
|
52
52
|
|
|
53
|
-
const mergedErrors = Array.isArray(
|
|
53
|
+
const mergedErrors = Array.isArray(foundErrors) ? [...foundErrors] : [];
|
|
54
54
|
if (status === 'error' && mergedErrors.length === 0) {
|
|
55
55
|
mergedErrors.push('BeforeHook execution reported error');
|
|
56
56
|
}
|
|
@@ -82,7 +82,7 @@ export default async function <%- upperCaseFlowTag %>BeforeHookCallbackMain(
|
|
|
82
82
|
},
|
|
83
83
|
requestParams: originalRequestParams || {},
|
|
84
84
|
callingFlowConfig,
|
|
85
|
-
|
|
85
|
+
foundErrors: mergedErrors
|
|
86
86
|
});
|
|
87
87
|
}
|
|
88
88
|
|