@izara_project/izara-core-generate-service-code 1.0.90 → 1.0.91
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/emit/crud/emitDynamicCrudFlowSchemas.js +2 -2
- 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/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/templates/UserRbacFlow_Main.ejs +13 -7
- package/src/emit/relationship/emitDynamicRelationshipFlowSchemas.js +1 -1
- 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/emitResourceArtifacts.js +3 -7
- 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/test/createTargetRoleHandler.test.js +62 -4
- package/test/crudApplicationArtifacts.test.js +3 -3
- package/test/dynamicCrudFlowSchemas.test.js +2 -2
- package/test/dynamicRbacFlowSchemas.test.js +32 -4
- package/test/relationshipApplicationArtifacts.test.js +1 -1
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.91",
|
|
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": {
|
|
@@ -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
|
: [],
|
|
@@ -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
|
|
|
@@ -23,29 +23,29 @@ function empty(value) {
|
|
|
23
23
|
);
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
-
function validateInput(returnValue, status, graphServiceTag,
|
|
26
|
+
function validateInput(returnValue, status, graphServiceTag, foundErrors) {
|
|
27
27
|
if (!returnValue?.queryResult)
|
|
28
|
-
|
|
28
|
+
foundErrors.push(
|
|
29
29
|
'message is not have property queryResult, should be not happen'
|
|
30
30
|
);
|
|
31
31
|
if (!returnValue?.requestParams?.objType)
|
|
32
|
-
|
|
32
|
+
foundErrors.push(
|
|
33
33
|
'message is not have property objType, should be not happen'
|
|
34
34
|
);
|
|
35
35
|
if (!returnValue?.requestParams?.objInstanceFull)
|
|
36
|
-
|
|
36
|
+
foundErrors.push(
|
|
37
37
|
'message is not have property objInstance, should be not objInstance'
|
|
38
38
|
);
|
|
39
|
-
if (status === 'error' &&
|
|
40
|
-
|
|
41
|
-
'[invalid]status is error not have
|
|
39
|
+
if (status === 'error' && foundErrors.length === 0)
|
|
40
|
+
foundErrors.push(
|
|
41
|
+
'[invalid]status is error not have foundErrors form graphService'
|
|
42
42
|
);
|
|
43
|
-
if (status === 'complete' &&
|
|
44
|
-
|
|
45
|
-
'[Invalid] status is complete should be not have
|
|
43
|
+
if (status === 'complete' && foundErrors.length > 0)
|
|
44
|
+
foundErrors.push(
|
|
45
|
+
'[Invalid] status is complete should be not have foundErrors'
|
|
46
46
|
);
|
|
47
47
|
if (graphServiceTag == null)
|
|
48
|
-
|
|
48
|
+
foundErrors.push('[Invalid] graphServerTag is not empty string');
|
|
49
49
|
}
|
|
50
50
|
|
|
51
51
|
export default async function CreateComplete(
|
|
@@ -62,14 +62,14 @@ export default async function CreateComplete(
|
|
|
62
62
|
const {
|
|
63
63
|
returnValue,
|
|
64
64
|
status,
|
|
65
|
-
|
|
65
|
+
foundErrors = [],
|
|
66
66
|
graphServiceTag,
|
|
67
67
|
parentFlowId
|
|
68
68
|
} = requestParams;
|
|
69
69
|
if (empty(returnValue?.requestParams))
|
|
70
70
|
throw new NoRetryError('message not an object');
|
|
71
|
-
validateInput(returnValue, status, graphServiceTag,
|
|
72
|
-
if (
|
|
71
|
+
validateInput(returnValue, status, graphServiceTag, foundErrors);
|
|
72
|
+
if (foundErrors.length > 0) foundErrors.push(foundErrors.join(','));
|
|
73
73
|
|
|
74
74
|
const awaitingStepId = await asyncFlowSharedLib.createAwaitingStepId(
|
|
75
75
|
parentFlowId,
|
|
@@ -88,14 +88,14 @@ export default async function CreateComplete(
|
|
|
88
88
|
_izContext.logger.warn(
|
|
89
89
|
`No pending step found for awaitingStepId: ${awaitingStepId}`
|
|
90
90
|
);
|
|
91
|
-
return { returnValue, status,
|
|
91
|
+
return { returnValue, status, foundErrors };
|
|
92
92
|
}
|
|
93
93
|
const result =
|
|
94
94
|
await asyncFlowSharedLib.checkAllAwaitingStepsFinishedWithReturnParams(
|
|
95
95
|
_izContext,
|
|
96
96
|
pending.pendingStepId,
|
|
97
97
|
awaitingStepId,
|
|
98
|
-
|
|
98
|
+
foundErrors
|
|
99
99
|
);
|
|
100
100
|
_izContext.logger.debug(
|
|
101
101
|
'[CreateComplete] all awaiting steps result',
|
|
@@ -153,7 +153,7 @@ export default async function CreateComplete(
|
|
|
153
153
|
parentFlowId: parentFlowId || returnValue?.parentFlowId,
|
|
154
154
|
existsNode,
|
|
155
155
|
status,
|
|
156
|
-
|
|
156
|
+
foundErrors
|
|
157
157
|
};
|
|
158
158
|
|
|
159
159
|
<%_ if (plan?.hasAfterHookSync) { _%>
|
|
@@ -185,12 +185,12 @@ export default async function CreateComplete(
|
|
|
185
185
|
callingFlowConfig
|
|
186
186
|
}
|
|
187
187
|
);
|
|
188
|
-
if (hookResult?.
|
|
189
|
-
|
|
188
|
+
if (hookResult?.foundErrors?.length > 0 || hookResult?.status === 'error') {
|
|
189
|
+
foundErrors.push(...(hookResult.foundErrors || ['Hook <%= hook.flowTag %> failed']));
|
|
190
190
|
}
|
|
191
191
|
} catch (hookErr) {
|
|
192
192
|
_izContext.logger.error('[CreateComplete] Sync hook <%= hook.flowTag %> error:', hookErr);
|
|
193
|
-
|
|
193
|
+
foundErrors.push(hookErr.message || 'Hook <%= hook.flowTag %> failed');
|
|
194
194
|
}
|
|
195
195
|
<%_ if (hook.targetObjectTypes && hook.targetObjectTypes.length > 0) { _%>
|
|
196
196
|
}
|
|
@@ -308,9 +308,9 @@ export default async function CreateComplete(
|
|
|
308
308
|
_izContext,
|
|
309
309
|
awaitingStepId,
|
|
310
310
|
pending.pendingStepId,
|
|
311
|
-
|
|
311
|
+
foundErrors
|
|
312
312
|
);
|
|
313
|
-
return { returnValue, status,
|
|
313
|
+
return { returnValue, status, foundErrors };
|
|
314
314
|
} catch (error) {
|
|
315
315
|
_izContext.logger.error('[CreateComplete] error:', error);
|
|
316
316
|
throw error;
|
|
@@ -76,11 +76,11 @@ export default async function <%- flowTag %>(
|
|
|
76
76
|
}
|
|
77
77
|
);
|
|
78
78
|
|
|
79
|
-
const
|
|
79
|
+
const foundErrors = [];
|
|
80
80
|
|
|
81
81
|
// Step 1: Resolve Schema & Identity
|
|
82
82
|
const { objType, objectSchema } =
|
|
83
|
-
await resolveSchemaAndIdentity(_izContext, requestParams,
|
|
83
|
+
await resolveSchemaAndIdentity(_izContext, requestParams, foundErrors);
|
|
84
84
|
|
|
85
85
|
//(<beforeQuery>)
|
|
86
86
|
//(</beforeQuery>)
|
|
@@ -90,27 +90,27 @@ export default async function <%- flowTag %>(
|
|
|
90
90
|
_izContext,
|
|
91
91
|
requestParams,
|
|
92
92
|
objectSchema,
|
|
93
|
-
|
|
93
|
+
foundErrors
|
|
94
94
|
);
|
|
95
95
|
|
|
96
|
-
if (
|
|
96
|
+
if (foundErrors.length > 0) {
|
|
97
97
|
return await <%- flowTag %>LogicalLib(
|
|
98
98
|
_izContext,
|
|
99
99
|
requestParams,
|
|
100
100
|
callingFlowConfig,
|
|
101
|
-
|
|
101
|
+
foundErrors
|
|
102
102
|
);
|
|
103
103
|
}
|
|
104
104
|
|
|
105
105
|
// Step 3: Validate FieldNames
|
|
106
|
-
validateFieldNames(_izContext, requestParams, objectSchemas,
|
|
106
|
+
validateFieldNames(_izContext, requestParams, objectSchemas, foundErrors);
|
|
107
107
|
|
|
108
|
-
if (
|
|
108
|
+
if (foundErrors.length > 0) {
|
|
109
109
|
return await <%- flowTag %>LogicalLib(
|
|
110
110
|
_izContext,
|
|
111
111
|
requestParams,
|
|
112
112
|
callingFlowConfig,
|
|
113
|
-
|
|
113
|
+
foundErrors
|
|
114
114
|
);
|
|
115
115
|
}
|
|
116
116
|
|
|
@@ -178,12 +178,12 @@ export default async function <%- flowTag %>(
|
|
|
178
178
|
);
|
|
179
179
|
|
|
180
180
|
if (resultPermissionCheck && resultPermissionCheck.permission !== true) {
|
|
181
|
-
|
|
181
|
+
foundErrors.push('Permission denied');
|
|
182
182
|
return await <%- flowTag %>LogicalLib(
|
|
183
183
|
_izContext,
|
|
184
184
|
requestParams,
|
|
185
185
|
callingFlowConfig,
|
|
186
|
-
|
|
186
|
+
foundErrors
|
|
187
187
|
);
|
|
188
188
|
}
|
|
189
189
|
|
|
@@ -240,10 +240,10 @@ export default async function <%- flowTag %>(
|
|
|
240
240
|
flowTag: '<%= config.flowTag %>',
|
|
241
241
|
returnValue
|
|
242
242
|
});
|
|
243
|
-
if (returnValue?.
|
|
244
|
-
|
|
243
|
+
if (returnValue?.foundErrors?.length > 0) {
|
|
244
|
+
foundErrors.push(...returnValue.foundErrors);
|
|
245
245
|
} else if (returnValue?.status === 'error') {
|
|
246
|
-
|
|
246
|
+
foundErrors.push('Error from <%= config.flowTag %>');
|
|
247
247
|
} else {
|
|
248
248
|
if (returnValue?.fieldNames && requestParams?.fieldNames) {
|
|
249
249
|
Object.assign(requestParams.fieldNames, returnValue.fieldNames);
|
|
@@ -257,16 +257,16 @@ export default async function <%- flowTag %>(
|
|
|
257
257
|
'[<%- flowTag %>] Sync hook <%= config.flowTag %> error:',
|
|
258
258
|
hookErr
|
|
259
259
|
);
|
|
260
|
-
|
|
260
|
+
foundErrors.push(hookErr.message || 'Hook <%= config.flowTag %> failed');
|
|
261
261
|
}
|
|
262
262
|
<%_ } _%>
|
|
263
263
|
|
|
264
|
-
if (
|
|
264
|
+
if (foundErrors.length > 0) {
|
|
265
265
|
return await <%- flowTag %>LogicalLib(
|
|
266
266
|
_izContext,
|
|
267
267
|
requestParams,
|
|
268
268
|
callingFlowConfig,
|
|
269
|
-
|
|
269
|
+
foundErrors
|
|
270
270
|
);
|
|
271
271
|
}
|
|
272
272
|
<%_ } _%>
|
|
@@ -346,7 +346,7 @@ export default async function <%- flowTag %>(
|
|
|
346
346
|
_izContext,
|
|
347
347
|
requestParams,
|
|
348
348
|
callingFlowConfig,
|
|
349
|
-
|
|
349
|
+
foundErrors
|
|
350
350
|
);
|
|
351
351
|
<%_ } _%>
|
|
352
352
|
}
|
|
@@ -359,7 +359,7 @@ export default async function <%- flowTag %>(
|
|
|
359
359
|
_izContext,
|
|
360
360
|
requestParams,
|
|
361
361
|
callingFlowConfig,
|
|
362
|
-
|
|
362
|
+
foundErrors
|
|
363
363
|
);
|
|
364
364
|
} catch (err) {
|
|
365
365
|
_izContext.logger.error(
|
|
@@ -67,10 +67,10 @@ const PREFIX = {
|
|
|
67
67
|
* Loads ObjectSchema and resolves submittedByUserId and targetIdentifiers
|
|
68
68
|
* @param {Object} _izContext - Izara context object
|
|
69
69
|
* @param {Object} requestParams - Incoming request parameters
|
|
70
|
-
* @param {Array<string>}
|
|
70
|
+
* @param {Array<string>} foundErrors - Array to collect validation errors
|
|
71
71
|
* @returns {Promise<{ objType: string, objectSchema: Object }>}
|
|
72
72
|
*/
|
|
73
|
-
export async function resolveSchemaAndIdentity(_izContext, requestParams,
|
|
73
|
+
export async function resolveSchemaAndIdentity(_izContext, requestParams, foundErrors) {
|
|
74
74
|
const objType = createObjType(requestParams.objectType);
|
|
75
75
|
const objectSchema = await getObjectSchema.getObjSchemaS3WithHierarchy(
|
|
76
76
|
_izContext,
|
|
@@ -97,9 +97,9 @@ export async function resolveSchemaAndIdentity(_izContext, requestParams, errors
|
|
|
97
97
|
targetIdentifiers = { submittedByUserId };
|
|
98
98
|
}
|
|
99
99
|
|
|
100
|
-
if (!submittedByUserId)
|
|
100
|
+
if (!submittedByUserId) foundErrors.push('Not have submittedByUserId');
|
|
101
101
|
if (objectSchema.hasOwnProperty('belongTo') && !targetIdentifiers)
|
|
102
|
-
|
|
102
|
+
foundErrors.push('not have targetIdentifiers');
|
|
103
103
|
|
|
104
104
|
if (targetIdentifiers) {
|
|
105
105
|
// if (Array.isArray(objectSchema.identifiers)) {
|
|
@@ -148,14 +148,14 @@ export async function resolveSchemaAndIdentity(_izContext, requestParams, errors
|
|
|
148
148
|
* @param {Object} _izContext - Izara context object
|
|
149
149
|
* @param {Object} requestParams - Request parameters
|
|
150
150
|
* @param {Object} objectSchema - Base object schema
|
|
151
|
-
* @param {Array<string>}
|
|
151
|
+
* @param {Array<string>} foundErrors - Error list
|
|
152
152
|
* @returns {Promise<{ objectSchemas: Object }>}
|
|
153
153
|
*/
|
|
154
154
|
export async function resolveAndGenerateIdentifiers(
|
|
155
155
|
_izContext,
|
|
156
156
|
requestParams,
|
|
157
157
|
objectSchema,
|
|
158
|
-
|
|
158
|
+
foundErrors
|
|
159
159
|
) {
|
|
160
160
|
const objType = createObjType(requestParams.objectType);
|
|
161
161
|
const targetIdentifiers = requestParams.targetIdentifiers;
|
|
@@ -170,7 +170,7 @@ export async function resolveAndGenerateIdentifiers(
|
|
|
170
170
|
objectSchemas
|
|
171
171
|
);
|
|
172
172
|
|
|
173
|
-
|
|
173
|
+
foundErrors.push(
|
|
174
174
|
...(await createNodeLib.validateRequiredOnCreateLinks(
|
|
175
175
|
_izContext,
|
|
176
176
|
objType,
|
|
@@ -178,8 +178,8 @@ export async function resolveAndGenerateIdentifiers(
|
|
|
178
178
|
))
|
|
179
179
|
);
|
|
180
180
|
_izContext.logger.debug(
|
|
181
|
-
`[${process.env.iz_serviceTag}:<%- flowTag %>]
|
|
182
|
-
|
|
181
|
+
`[${process.env.iz_serviceTag}:<%- flowTag %>] foundErrors:`,
|
|
182
|
+
foundErrors
|
|
183
183
|
);
|
|
184
184
|
|
|
185
185
|
// ── Resolve fromRequiredOnCreate fields ──────────────────────────────────
|
|
@@ -235,7 +235,7 @@ export async function resolveAndGenerateIdentifiers(
|
|
|
235
235
|
optionalOnCreateIdentifiers
|
|
236
236
|
);
|
|
237
237
|
if (errors?.length > 0) {
|
|
238
|
-
|
|
238
|
+
foundErrors.push(...errors);
|
|
239
239
|
}
|
|
240
240
|
} else if (identifiers?.length > 1) {
|
|
241
241
|
for (const identifier of identifiers) {
|
|
@@ -247,7 +247,7 @@ export async function resolveAndGenerateIdentifiers(
|
|
|
247
247
|
optionalOnCreateIdentifiers
|
|
248
248
|
);
|
|
249
249
|
if (errors?.length > 0) {
|
|
250
|
-
|
|
250
|
+
foundErrors.push(...errors);
|
|
251
251
|
}
|
|
252
252
|
}
|
|
253
253
|
}
|
|
@@ -260,13 +260,13 @@ export async function resolveAndGenerateIdentifiers(
|
|
|
260
260
|
* @param {Object} _izContext - Izara context object
|
|
261
261
|
* @param {Object} requestParams - Incoming request parameters
|
|
262
262
|
* @param {Object} objectSchemas - Combined object schema
|
|
263
|
-
* @param {Array<string>}
|
|
263
|
+
* @param {Array<string>} foundErrors - Array to collect validation errors
|
|
264
264
|
*/
|
|
265
265
|
export function validateFieldNames(
|
|
266
266
|
_izContext,
|
|
267
267
|
requestParams,
|
|
268
268
|
objectSchemas,
|
|
269
|
-
|
|
269
|
+
foundErrors
|
|
270
270
|
) {
|
|
271
271
|
const listOfRequiredOnCreate = [];
|
|
272
272
|
const listOfOptionalOnCreate = [];
|
|
@@ -290,12 +290,12 @@ export function validateFieldNames(
|
|
|
290
290
|
!listOfRequiredOnCreate.includes(fieldName) &&
|
|
291
291
|
!listOfOptionalOnCreate.includes(fieldName)
|
|
292
292
|
) {
|
|
293
|
-
|
|
293
|
+
foundErrors.push('[invalid] over fieldNames create object');
|
|
294
294
|
}
|
|
295
|
-
if (
|
|
295
|
+
if (foundErrors.length > 0) {
|
|
296
296
|
_izContext.logger.debug(
|
|
297
297
|
`[${process.env.iz_serviceTag}:<%- flowTag %>] HaveError:`,
|
|
298
|
-
|
|
298
|
+
foundErrors
|
|
299
299
|
);
|
|
300
300
|
break;
|
|
301
301
|
}
|
|
@@ -331,7 +331,7 @@ export async function collectRbacAwaitingResults(_izContext, requestParams) {
|
|
|
331
331
|
_izContext,
|
|
332
332
|
rbacPendingStepId,
|
|
333
333
|
currentAwaitingStepId,
|
|
334
|
-
requestParams.
|
|
334
|
+
requestParams.foundErrors,
|
|
335
335
|
{
|
|
336
336
|
returnValue: requestParams.returnValue,
|
|
337
337
|
rbacType
|
|
@@ -348,7 +348,7 @@ export async function collectRbacAwaitingResults(_izContext, requestParams) {
|
|
|
348
348
|
const {
|
|
349
349
|
isComplete,
|
|
350
350
|
collectedReturnValueByAwaitingStepId,
|
|
351
|
-
collectedErrors:
|
|
351
|
+
collectedErrors: foundErrors = [],
|
|
352
352
|
additionalAttributes
|
|
353
353
|
} = rbacAwaitingStepsResult;
|
|
354
354
|
|
|
@@ -389,7 +389,7 @@ export async function collectRbacAwaitingResults(_izContext, requestParams) {
|
|
|
389
389
|
isComplete: true,
|
|
390
390
|
rbacResults,
|
|
391
391
|
originalRequestParams,
|
|
392
|
-
collectedErrors:
|
|
392
|
+
collectedErrors: foundErrors
|
|
393
393
|
};
|
|
394
394
|
}
|
|
395
395
|
|
|
@@ -399,11 +399,11 @@ export async function collectRbacAwaitingResults(_izContext, requestParams) {
|
|
|
399
399
|
* @param {Object} options - Validation options
|
|
400
400
|
* @returns {Promise<{ hasError: boolean, errorResult?: Object, rbacCallbackResults: Object }>}
|
|
401
401
|
*/
|
|
402
|
-
export async function assertRbacPermission(_izContext, { rbacResults, originalRequestParams,
|
|
402
|
+
export async function assertRbacPermission(_izContext, { rbacResults, originalRequestParams, foundErrors }) {
|
|
403
403
|
const rbacCallbackResults = {};
|
|
404
404
|
const hasError = Object.entries(rbacResults).some(([type, result]) => {
|
|
405
405
|
if (result && result.error) {
|
|
406
|
-
|
|
406
|
+
foundErrors.push(result.error);
|
|
407
407
|
return true;
|
|
408
408
|
}
|
|
409
409
|
rbacCallbackResults[type] = result;
|
|
@@ -415,7 +415,7 @@ export async function assertRbacPermission(_izContext, { rbacResults, originalRe
|
|
|
415
415
|
);
|
|
416
416
|
|
|
417
417
|
if (!isAllowed) {
|
|
418
|
-
|
|
418
|
+
foundErrors.push('Permission denied');
|
|
419
419
|
}
|
|
420
420
|
|
|
421
421
|
_izContext.logger.debug(
|
|
@@ -423,13 +423,13 @@ export async function assertRbacPermission(_izContext, { rbacResults, originalRe
|
|
|
423
423
|
{
|
|
424
424
|
rbacCallbackResults,
|
|
425
425
|
isAllowed,
|
|
426
|
-
|
|
426
|
+
foundErrors
|
|
427
427
|
}
|
|
428
428
|
);
|
|
429
429
|
|
|
430
|
-
if (hasError ||
|
|
430
|
+
if (hasError || foundErrors.length > 0) {
|
|
431
431
|
const errorResult = {
|
|
432
|
-
|
|
432
|
+
foundErrors,
|
|
433
433
|
status: 'rejected',
|
|
434
434
|
requestParams: originalRequestParams
|
|
435
435
|
};
|
|
@@ -795,7 +795,7 @@ export async function forwardToQuotaConfirmation(
|
|
|
795
795
|
_izContext,
|
|
796
796
|
{
|
|
797
797
|
status,
|
|
798
|
-
|
|
798
|
+
foundErrors = [],
|
|
799
799
|
quotaKeys,
|
|
800
800
|
actionData,
|
|
801
801
|
callingFlowConfig
|
|
@@ -804,7 +804,7 @@ export async function forwardToQuotaConfirmation(
|
|
|
804
804
|
let quotaResult = null;
|
|
805
805
|
if (quotaKeys && (quotaKeys.limitTag || quotaKeys.flowTypeConcat)) {
|
|
806
806
|
let targetFunction = 'CancelUsageHdrInv';
|
|
807
|
-
if (status === 'complete' &&
|
|
807
|
+
if (status === 'complete' && foundErrors.length === 0) {
|
|
808
808
|
targetFunction = 'ConfirmUsageHdrInv';
|
|
809
809
|
}
|
|
810
810
|
|
|
@@ -856,10 +856,10 @@ export async function forwardToQuotaConfirmation(
|
|
|
856
856
|
);
|
|
857
857
|
}
|
|
858
858
|
}
|
|
859
|
-
|
|
859
|
+
foundErrors.push(err.message || 'Quota confirmation failed');
|
|
860
860
|
if (actionData) {
|
|
861
861
|
actionData.status = 'error';
|
|
862
|
-
actionData.
|
|
862
|
+
actionData.foundErrors = foundErrors;
|
|
863
863
|
}
|
|
864
864
|
}
|
|
865
865
|
}
|
|
@@ -1287,10 +1287,10 @@ export async function handleCreateError(
|
|
|
1287
1287
|
objInstanceFull,
|
|
1288
1288
|
requestParams,
|
|
1289
1289
|
callingFlowConfig,
|
|
1290
|
-
|
|
1290
|
+
foundErrors
|
|
1291
1291
|
}
|
|
1292
1292
|
) {
|
|
1293
|
-
_izContext.logger.debug(`[${process.env.iz_serviceTag}:<%- flowTag %>LogicalLib]
|
|
1293
|
+
_izContext.logger.debug(`[${process.env.iz_serviceTag}:<%- flowTag %>LogicalLib] foundErrors:`, foundErrors);
|
|
1294
1294
|
|
|
1295
1295
|
await asyncFlowSharedLib.clearAllAwaitingSteps(
|
|
1296
1296
|
_izContext,
|
|
@@ -1303,7 +1303,7 @@ export async function handleCreateError(
|
|
|
1303
1303
|
const messageObject =
|
|
1304
1304
|
callingFlowSharedLib.addPassBackPropertiesToSnsResponseMessageObject(
|
|
1305
1305
|
callingFlowConfig,
|
|
1306
|
-
{ objType, identifiers: null,
|
|
1306
|
+
{ objType, identifiers: null, foundErrors }
|
|
1307
1307
|
);
|
|
1308
1308
|
|
|
1309
1309
|
await sns.publishAsync(_izContext, {
|
|
@@ -1327,7 +1327,7 @@ export async function handleCreateError(
|
|
|
1327
1327
|
relationships: requestParams.relationships || [],
|
|
1328
1328
|
targetIdentifiers: requestParams.targetIdentifiers,
|
|
1329
1329
|
status: 'error',
|
|
1330
|
-
|
|
1330
|
+
foundErrors
|
|
1331
1331
|
};
|
|
1332
1332
|
}
|
|
1333
1333
|
|
|
@@ -1385,15 +1385,15 @@ export async function handleDynamoDbOnlyComplete(
|
|
|
1385
1385
|
* @param {Object} _izContext - Context object with logger
|
|
1386
1386
|
* @param {Object} requestParams - Request parameters { fieldNames, relationships[] }
|
|
1387
1387
|
* @param {Object} callingFlowConfig - Calling flow configuration
|
|
1388
|
-
* @param {Array<string>}
|
|
1388
|
+
* @param {Array<string>} foundErrors - Array of preceding errors
|
|
1389
1389
|
* @param {Object} phaseResults - Results from preceding phases
|
|
1390
|
-
* @returns {Promise<Object>} Result with objType, objInstanceFull, relationships, status,
|
|
1390
|
+
* @returns {Promise<Object>} Result with objType, objInstanceFull, relationships, status, foundErrors
|
|
1391
1391
|
*/
|
|
1392
1392
|
export async function <%- flowTag %>LogicalLib(
|
|
1393
1393
|
_izContext,
|
|
1394
1394
|
requestParams,
|
|
1395
1395
|
callingFlowConfig = {},
|
|
1396
|
-
|
|
1396
|
+
foundErrors = [],
|
|
1397
1397
|
phaseResults = {}
|
|
1398
1398
|
) {
|
|
1399
1399
|
try {
|
|
@@ -1440,7 +1440,7 @@ export async function <%- flowTag %>LogicalLib(
|
|
|
1440
1440
|
const listOfRecords = [];
|
|
1441
1441
|
|
|
1442
1442
|
// 3. Process storage resources
|
|
1443
|
-
if (
|
|
1443
|
+
if (foundErrors.length === 0) {
|
|
1444
1444
|
//(<validateBeforeCreate>)
|
|
1445
1445
|
//(</validateBeforeCreate>)
|
|
1446
1446
|
|
|
@@ -1563,12 +1563,12 @@ export async function <%- flowTag %>LogicalLib(
|
|
|
1563
1563
|
callingFlowConfig
|
|
1564
1564
|
}
|
|
1565
1565
|
);
|
|
1566
|
-
if (hookResult?.
|
|
1567
|
-
|
|
1566
|
+
if (hookResult?.foundErrors?.length > 0 || hookResult?.status === 'error') {
|
|
1567
|
+
foundErrors.push(...(hookResult.foundErrors || ['Hook <%= hook.flowTag %> failed']));
|
|
1568
1568
|
}
|
|
1569
1569
|
} catch (hookErr) {
|
|
1570
1570
|
_izContext.logger.error('[<%- flowTag %>LogicalLib] Sync hook <%= hook.flowTag %> error:', hookErr);
|
|
1571
|
-
|
|
1571
|
+
foundErrors.push(hookErr.message || 'Hook <%= hook.flowTag %> failed');
|
|
1572
1572
|
}
|
|
1573
1573
|
<%_ if (hook.targetObjectTypes && hook.targetObjectTypes.length > 0) { _%>
|
|
1574
1574
|
}
|
|
@@ -1615,7 +1615,7 @@ export async function <%- flowTag %>LogicalLib(
|
|
|
1615
1615
|
relationships: requestParams.relationships || [],
|
|
1616
1616
|
targetIdentifiers: requestParams.targetIdentifiers,
|
|
1617
1617
|
status: 'complete',
|
|
1618
|
-
|
|
1618
|
+
foundErrors
|
|
1619
1619
|
}
|
|
1620
1620
|
}
|
|
1621
1621
|
)
|
|
@@ -1745,7 +1745,7 @@ export async function <%- flowTag %>LogicalLib(
|
|
|
1745
1745
|
// 5. Dispatch to Graph Service
|
|
1746
1746
|
for (const objectCreate of listOfObjectForCreates) {
|
|
1747
1747
|
for (const [graphServiceName, objectForCreate] of Object.entries(objectCreate)) {
|
|
1748
|
-
if (!objectForCreate.allStorageTagComplete &&
|
|
1748
|
+
if (!objectForCreate.allStorageTagComplete && foundErrors.length === 0) {
|
|
1749
1749
|
//(<beforeSendMessageToGraph>)
|
|
1750
1750
|
//(</beforeSendMessageToGraph>)
|
|
1751
1751
|
|
|
@@ -1768,21 +1768,21 @@ export async function <%- flowTag %>LogicalLib(
|
|
|
1768
1768
|
relationships: requestParams.relationships || [],
|
|
1769
1769
|
targetIdentifiers: requestParams.targetIdentifiers,
|
|
1770
1770
|
status: 'complete',
|
|
1771
|
-
|
|
1771
|
+
foundErrors
|
|
1772
1772
|
};
|
|
1773
1773
|
}
|
|
1774
1774
|
}
|
|
1775
|
-
if (
|
|
1775
|
+
if (foundErrors.length > 0) break;
|
|
1776
1776
|
}
|
|
1777
1777
|
|
|
1778
1778
|
// 6. Handle Errors
|
|
1779
|
-
if (
|
|
1779
|
+
if (foundErrors.length > 0) {
|
|
1780
1780
|
return await handleCreateError(_izContext, {
|
|
1781
1781
|
objType,
|
|
1782
1782
|
objInstanceFull,
|
|
1783
1783
|
requestParams,
|
|
1784
1784
|
callingFlowConfig,
|
|
1785
|
-
|
|
1785
|
+
foundErrors
|
|
1786
1786
|
});
|
|
1787
1787
|
}
|
|
1788
1788
|
|
|
@@ -1806,7 +1806,7 @@ export async function <%- flowTag %>LogicalLib(
|
|
|
1806
1806
|
relationships: requestParams.relationships || [],
|
|
1807
1807
|
targetIdentifiers: requestParams.targetIdentifiers,
|
|
1808
1808
|
status: 'complete',
|
|
1809
|
-
|
|
1809
|
+
foundErrors
|
|
1810
1810
|
};
|
|
1811
1811
|
} catch (err) {
|
|
1812
1812
|
_izContext.logger.error(`[${process.env.iz_serviceTag}:<%- flowTag %>LogicalLib] error:`, err);
|