@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
|
@@ -46,29 +46,29 @@ function empty(value) {
|
|
|
46
46
|
);
|
|
47
47
|
}
|
|
48
48
|
|
|
49
|
-
function validateInput(returnValue, status, graphServiceTag,
|
|
49
|
+
function validateInput(returnValue, status, graphServiceTag, foundErrors) {
|
|
50
50
|
if (!returnValue?.queryResult)
|
|
51
|
-
|
|
51
|
+
foundErrors.push(
|
|
52
52
|
'message is not have property queryResult, should be not happen'
|
|
53
53
|
);
|
|
54
54
|
if (!returnValue?.requestParams?.objType)
|
|
55
|
-
|
|
55
|
+
foundErrors.push(
|
|
56
56
|
'message is not have property objType, should be not happen'
|
|
57
57
|
);
|
|
58
58
|
if (!returnValue?.requestParams?.objInstanceFull)
|
|
59
|
-
|
|
59
|
+
foundErrors.push(
|
|
60
60
|
'message is not have property objInstance, should be not objInstance'
|
|
61
61
|
);
|
|
62
|
-
if (status === 'error' &&
|
|
63
|
-
|
|
64
|
-
'[invalid]status is error not have
|
|
62
|
+
if (status === 'error' && foundErrors.length === 0)
|
|
63
|
+
foundErrors.push(
|
|
64
|
+
'[invalid]status is error not have foundErrors form graphService'
|
|
65
65
|
);
|
|
66
|
-
if (status === 'complete' &&
|
|
67
|
-
|
|
68
|
-
'[Invalid] status is complete should be not have
|
|
66
|
+
if (status === 'complete' && foundErrors.length > 0)
|
|
67
|
+
foundErrors.push(
|
|
68
|
+
'[Invalid] status is complete should be not have foundErrors'
|
|
69
69
|
);
|
|
70
70
|
if (graphServiceTag == null)
|
|
71
|
-
|
|
71
|
+
foundErrors.push('[Invalid] graphServerTag is not empty string');
|
|
72
72
|
}
|
|
73
73
|
|
|
74
74
|
/**
|
|
@@ -93,14 +93,14 @@ export default async function CreateNodeCallbackMain(
|
|
|
93
93
|
const {
|
|
94
94
|
returnValue,
|
|
95
95
|
status,
|
|
96
|
-
|
|
96
|
+
foundErrors = [],
|
|
97
97
|
graphServiceTag,
|
|
98
98
|
parentFlowId
|
|
99
99
|
} = requestParams;
|
|
100
100
|
if (empty(returnValue?.requestParams))
|
|
101
101
|
throw new NoRetryError('message not an object');
|
|
102
|
-
validateInput(returnValue, status, graphServiceTag,
|
|
103
|
-
if (
|
|
102
|
+
validateInput(returnValue, status, graphServiceTag, foundErrors);
|
|
103
|
+
if (foundErrors.length > 0) foundErrors.push(foundErrors.join(','));
|
|
104
104
|
|
|
105
105
|
const awaitingStepId = await asyncFlowSharedLib.createAwaitingStepId(
|
|
106
106
|
parentFlowId,
|
|
@@ -119,14 +119,14 @@ export default async function CreateNodeCallbackMain(
|
|
|
119
119
|
_izContext.logger.warn(
|
|
120
120
|
`No pending step found for awaitingStepId: ${awaitingStepId}`
|
|
121
121
|
);
|
|
122
|
-
return { returnValue, status,
|
|
122
|
+
return { returnValue, status, foundErrors };
|
|
123
123
|
}
|
|
124
124
|
const result =
|
|
125
125
|
await asyncFlowSharedLib.checkAllAwaitingStepsFinishedWithReturnParams(
|
|
126
126
|
_izContext,
|
|
127
127
|
pending.pendingStepId,
|
|
128
128
|
awaitingStepId,
|
|
129
|
-
|
|
129
|
+
foundErrors
|
|
130
130
|
);
|
|
131
131
|
_izContext.logger.debug(
|
|
132
132
|
'[CreateNodeCallback] all awaiting steps result',
|
|
@@ -154,7 +154,7 @@ export default async function CreateNodeCallbackMain(
|
|
|
154
154
|
: null;
|
|
155
155
|
|
|
156
156
|
// ── Step 1: Persist DynamoDB records ──────────────────────────────────
|
|
157
|
-
if (status === 'complete' &&
|
|
157
|
+
if (status === 'complete' && foundErrors.length === 0) {
|
|
158
158
|
const listOfRecords = result?.additionalAttributes?.listOfRecords ?? [];
|
|
159
159
|
await saveDynamoDbRecords(_izContext, listOfRecords);
|
|
160
160
|
|
|
@@ -208,12 +208,12 @@ export default async function CreateNodeCallbackMain(
|
|
|
208
208
|
callingFlowConfig
|
|
209
209
|
}
|
|
210
210
|
);
|
|
211
|
-
if (hookResult?.
|
|
212
|
-
|
|
211
|
+
if (hookResult?.foundErrors?.length > 0 || hookResult?.status === 'error') {
|
|
212
|
+
foundErrors.push(...(hookResult.foundErrors || ['Hook <%= hook.flowTag %> failed']));
|
|
213
213
|
}
|
|
214
214
|
} catch (hookErr) {
|
|
215
215
|
_izContext.logger.error('[CreateNodeCallback] Sync hook <%= hook.flowTag %> error:', hookErr);
|
|
216
|
-
|
|
216
|
+
foundErrors.push(hookErr.message || 'Hook <%= hook.flowTag %> failed');
|
|
217
217
|
}
|
|
218
218
|
<%_ if (hook.targetObjectTypes && hook.targetObjectTypes.length > 0) { _%>
|
|
219
219
|
}
|
|
@@ -235,7 +235,7 @@ export default async function CreateNodeCallbackMain(
|
|
|
235
235
|
parentFlowId: parentFlowId || returnValue?.parentFlowId,
|
|
236
236
|
existsNode,
|
|
237
237
|
status,
|
|
238
|
-
|
|
238
|
+
foundErrors
|
|
239
239
|
};
|
|
240
240
|
|
|
241
241
|
// ── Step 3: Resolve Quota deduction keys and forward confirmation ─────
|
|
@@ -296,7 +296,7 @@ export default async function CreateNodeCallbackMain(
|
|
|
296
296
|
<%_ } else { _%>
|
|
297
297
|
await forwardToQuotaConfirmation(_izContext, {
|
|
298
298
|
status,
|
|
299
|
-
|
|
299
|
+
foundErrors,
|
|
300
300
|
quotaKeys,
|
|
301
301
|
actionData,
|
|
302
302
|
callingFlowConfig
|
|
@@ -308,9 +308,9 @@ export default async function CreateNodeCallbackMain(
|
|
|
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('[CreateNodeCallback] error:', error);
|
|
316
316
|
throw error;
|
|
@@ -48,12 +48,12 @@ export default async function DeleteAfterHookCallbackMain(
|
|
|
48
48
|
|
|
49
49
|
const {
|
|
50
50
|
status,
|
|
51
|
-
|
|
51
|
+
foundErrors = [],
|
|
52
52
|
returnValue,
|
|
53
53
|
parentFlowId
|
|
54
54
|
} = requestParams;
|
|
55
55
|
|
|
56
|
-
const mergedErrors = Array.isArray(
|
|
56
|
+
const mergedErrors = Array.isArray(foundErrors) ? [...foundErrors] : [];
|
|
57
57
|
if (status === 'error' && mergedErrors.length === 0) {
|
|
58
58
|
mergedErrors.push('AfterHook execution reported error');
|
|
59
59
|
}
|
|
@@ -73,7 +73,7 @@ export default async function DeleteAfterHookCallbackMain(
|
|
|
73
73
|
targetIdentifiers: requestParams?.targetIdentifiers,
|
|
74
74
|
parentFlowId: parentFlowId || returnValue?.parentFlowId,
|
|
75
75
|
status: mergedErrors.length > 0 ? 'error' : 'complete',
|
|
76
|
-
|
|
76
|
+
foundErrors: mergedErrors
|
|
77
77
|
};
|
|
78
78
|
|
|
79
79
|
const topicArn = snsSharedLib.snsTopicArnByFlowSchema(
|
|
@@ -87,7 +87,7 @@ export default async function DeleteAfterHookCallbackMain(
|
|
|
87
87
|
{
|
|
88
88
|
...actionData,
|
|
89
89
|
status: mergedErrors.length > 0 ? 'error' : 'complete',
|
|
90
|
-
|
|
90
|
+
foundErrors: mergedErrors
|
|
91
91
|
}
|
|
92
92
|
);
|
|
93
93
|
|
|
@@ -109,7 +109,7 @@ export default async function DeleteAfterHookCallbackMain(
|
|
|
109
109
|
return {
|
|
110
110
|
returnValue,
|
|
111
111
|
status: mergedErrors.length > 0 ? 'error' : 'complete',
|
|
112
|
-
|
|
112
|
+
foundErrors: mergedErrors
|
|
113
113
|
};
|
|
114
114
|
} catch (error) {
|
|
115
115
|
_izContext.logger.error('[DeleteAfterHookCallback] 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
|
}
|
|
@@ -76,7 +76,7 @@ export default async function <%- upperCaseFlowTag %>BeforeHookCallbackMain(
|
|
|
76
76
|
identifiers: originalRequestParams?.identifiers || {},
|
|
77
77
|
targetIdentifiers: originalRequestParams?.targetIdentifiers,
|
|
78
78
|
callingFlowConfig,
|
|
79
|
-
|
|
79
|
+
foundErrors: mergedErrors
|
|
80
80
|
});
|
|
81
81
|
}
|
|
82
82
|
|
|
@@ -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 DeleteComplete(
|
|
@@ -62,14 +62,14 @@ export default async function DeleteComplete(
|
|
|
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 DeleteComplete(
|
|
|
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
|
'[DeleteComplete] all awaiting steps result',
|
|
@@ -157,7 +157,7 @@ export default async function DeleteComplete(
|
|
|
157
157
|
parentFlowId: parentFlowId || returnValue?.parentFlowId,
|
|
158
158
|
existsNode,
|
|
159
159
|
status,
|
|
160
|
-
|
|
160
|
+
foundErrors
|
|
161
161
|
};
|
|
162
162
|
|
|
163
163
|
<%_ if (plan?.hasAfterHookSync) { _%>
|
|
@@ -193,11 +193,11 @@ export default async function DeleteComplete(
|
|
|
193
193
|
}
|
|
194
194
|
);
|
|
195
195
|
if (
|
|
196
|
-
hookResult?.
|
|
196
|
+
hookResult?.foundErrors?.length > 0 ||
|
|
197
197
|
hookResult?.status === 'error'
|
|
198
198
|
) {
|
|
199
|
-
|
|
200
|
-
...(hookResult.
|
|
199
|
+
foundErrors.push(
|
|
200
|
+
...(hookResult.foundErrors || ['Hook <%= hook.flowTag %> failed'])
|
|
201
201
|
);
|
|
202
202
|
}
|
|
203
203
|
} catch (hookErr) {
|
|
@@ -205,7 +205,7 @@ export default async function DeleteComplete(
|
|
|
205
205
|
'[DeleteComplete] Sync hook <%= hook.flowTag %> error:',
|
|
206
206
|
hookErr
|
|
207
207
|
);
|
|
208
|
-
|
|
208
|
+
foundErrors.push(hookErr.message || 'Hook <%= hook.flowTag %> failed');
|
|
209
209
|
}
|
|
210
210
|
<%_ if (hook.targetObjectTypes && hook.targetObjectTypes.length > 0) { _%>
|
|
211
211
|
}
|
|
@@ -297,9 +297,9 @@ export default async function DeleteComplete(
|
|
|
297
297
|
_izContext,
|
|
298
298
|
awaitingStepId,
|
|
299
299
|
pending.pendingStepId,
|
|
300
|
-
|
|
300
|
+
foundErrors
|
|
301
301
|
);
|
|
302
|
-
return { returnValue, status,
|
|
302
|
+
return { returnValue, status, foundErrors };
|
|
303
303
|
} catch (error) {
|
|
304
304
|
_izContext.logger.error('[DeleteComplete] error:', error);
|
|
305
305
|
throw error;
|
|
@@ -62,14 +62,14 @@ export default async function <%- flowTag %>(
|
|
|
62
62
|
callingFlowConfig
|
|
63
63
|
});
|
|
64
64
|
|
|
65
|
-
const
|
|
65
|
+
const foundErrors = [];
|
|
66
66
|
|
|
67
67
|
//(<beforeDelete>)
|
|
68
68
|
//(</beforeDelete>)
|
|
69
69
|
|
|
70
70
|
// ── Resolve Schema & Identity ─────────────────────────────────────────────
|
|
71
71
|
const { objType, objectSchema, targetIdentifiers } =
|
|
72
|
-
await resolveSchemaAndIdentity(_izContext, requestParams,
|
|
72
|
+
await resolveSchemaAndIdentity(_izContext, requestParams, foundErrors);
|
|
73
73
|
|
|
74
74
|
//(<beforeQuery>)
|
|
75
75
|
//(</beforeQuery>)
|
|
@@ -101,19 +101,19 @@ export default async function <%- flowTag %>(
|
|
|
101
101
|
// value !== undefined &&
|
|
102
102
|
// targetIdentifiers[key] !== value
|
|
103
103
|
// ) {
|
|
104
|
-
//
|
|
104
|
+
// foundErrors.push(
|
|
105
105
|
// `targetIdentifiers.${key} must match identifiers.${key}`
|
|
106
106
|
// );
|
|
107
107
|
// }
|
|
108
108
|
// }
|
|
109
109
|
// }
|
|
110
110
|
|
|
111
|
-
if (
|
|
111
|
+
if (foundErrors.length > 0)
|
|
112
112
|
return await <%- flowTag %>LogicalLib(
|
|
113
113
|
_izContext,
|
|
114
114
|
requestParams,
|
|
115
115
|
callingFlowConfig,
|
|
116
|
-
|
|
116
|
+
foundErrors
|
|
117
117
|
);
|
|
118
118
|
|
|
119
119
|
<%_
|
|
@@ -172,12 +172,12 @@ export default async function <%- flowTag %>(
|
|
|
172
172
|
);
|
|
173
173
|
|
|
174
174
|
if (resultPermissionCheck && resultPermissionCheck.permission !== true) {
|
|
175
|
-
|
|
175
|
+
foundErrors.push('Permission denied');
|
|
176
176
|
return await <%- flowTag %>LogicalLib(
|
|
177
177
|
_izContext,
|
|
178
178
|
requestParams,
|
|
179
179
|
callingFlowConfig,
|
|
180
|
-
|
|
180
|
+
foundErrors
|
|
181
181
|
);
|
|
182
182
|
}
|
|
183
183
|
|
|
@@ -233,10 +233,10 @@ export default async function <%- flowTag %>(
|
|
|
233
233
|
flowTag: '<%= config.flowTag %>',
|
|
234
234
|
returnValue
|
|
235
235
|
});
|
|
236
|
-
if (returnValue?.
|
|
237
|
-
|
|
236
|
+
if (returnValue?.foundErrors?.length > 0) {
|
|
237
|
+
foundErrors.push(...returnValue.foundErrors);
|
|
238
238
|
} else if (returnValue?.status === 'error') {
|
|
239
|
-
|
|
239
|
+
foundErrors.push('Error from <%= config.flowTag %>');
|
|
240
240
|
} else {
|
|
241
241
|
if (returnValue?.identifiers && requestParams?.identifiers) {
|
|
242
242
|
Object.assign(requestParams.identifiers, returnValue.identifiers);
|
|
@@ -247,16 +247,16 @@ export default async function <%- flowTag %>(
|
|
|
247
247
|
'[<%- flowTag %>] Sync hook <%= config.flowTag %> error:',
|
|
248
248
|
hookErr
|
|
249
249
|
);
|
|
250
|
-
|
|
250
|
+
foundErrors.push(hookErr.message || 'Hook <%= config.flowTag %> failed');
|
|
251
251
|
}
|
|
252
252
|
<%_ } _%>
|
|
253
253
|
|
|
254
|
-
if (
|
|
254
|
+
if (foundErrors.length > 0) {
|
|
255
255
|
return await <%- flowTag %>LogicalLib(
|
|
256
256
|
_izContext,
|
|
257
257
|
requestParams,
|
|
258
258
|
callingFlowConfig,
|
|
259
|
-
|
|
259
|
+
foundErrors
|
|
260
260
|
);
|
|
261
261
|
}
|
|
262
262
|
<%_ } _%>
|
|
@@ -335,7 +335,7 @@ export default async function <%- flowTag %>(
|
|
|
335
335
|
_izContext,
|
|
336
336
|
requestParams,
|
|
337
337
|
callingFlowConfig,
|
|
338
|
-
|
|
338
|
+
foundErrors
|
|
339
339
|
);
|
|
340
340
|
<%_ } _%>
|
|
341
341
|
}
|
|
@@ -349,7 +349,7 @@ export default async function <%- flowTag %>(
|
|
|
349
349
|
_izContext,
|
|
350
350
|
requestParams,
|
|
351
351
|
callingFlowConfig,
|
|
352
|
-
|
|
352
|
+
foundErrors
|
|
353
353
|
);
|
|
354
354
|
} catch (err) {
|
|
355
355
|
_izContext.logger.error(`[${process.env.iz_serviceTag}:<%- flowTag %>] error:`, err);
|
|
@@ -52,13 +52,13 @@ const { TOPIC_NAME_GENERATE_CODE } = consts;
|
|
|
52
52
|
* Loads ObjectSchema and resolves submittedByUserId and targetIdentifiers
|
|
53
53
|
* @param {Object} _izContext - Izara context object
|
|
54
54
|
* @param {Object} requestParams - Incoming request parameters
|
|
55
|
-
* @param {Array<string>}
|
|
55
|
+
* @param {Array<string>} foundErrors - Array to collect validation errors
|
|
56
56
|
* @returns {Promise<{ objType: string, objectSchema: Object, targetIdentifiers?: Object }>}
|
|
57
57
|
*/
|
|
58
58
|
export async function resolveSchemaAndIdentity(
|
|
59
59
|
_izContext,
|
|
60
60
|
requestParams,
|
|
61
|
-
|
|
61
|
+
foundErrors
|
|
62
62
|
) {
|
|
63
63
|
const objType = createObjType(requestParams.objectType);
|
|
64
64
|
const objectSchema = await getObjectSchema.getObjSchemaS3WithHierarchy(
|
|
@@ -92,10 +92,10 @@ export async function resolveSchemaAndIdentity(
|
|
|
92
92
|
}
|
|
93
93
|
|
|
94
94
|
if (!submittedByUserId) {
|
|
95
|
-
|
|
95
|
+
foundErrors.push('Not have submittedByUserId');
|
|
96
96
|
}
|
|
97
97
|
if (objectSchema.hasOwnProperty('belongTo') && !targetIdentifiers) {
|
|
98
|
-
|
|
98
|
+
foundErrors.push('not have targetIdentifiers');
|
|
99
99
|
}
|
|
100
100
|
|
|
101
101
|
requestParams.submittedByUserId = submittedByUserId;
|
|
@@ -130,7 +130,7 @@ export async function handleDeleteError(
|
|
|
130
130
|
identifiers,
|
|
131
131
|
targetIdentifiers,
|
|
132
132
|
callingFlowConfig,
|
|
133
|
-
|
|
133
|
+
foundErrors
|
|
134
134
|
}
|
|
135
135
|
) {
|
|
136
136
|
const deleteNodeCompleteMessage =
|
|
@@ -141,7 +141,7 @@ export async function handleDeleteError(
|
|
|
141
141
|
identifiers,
|
|
142
142
|
targetIdentifiers,
|
|
143
143
|
status: 'error',
|
|
144
|
-
|
|
144
|
+
foundErrors
|
|
145
145
|
}
|
|
146
146
|
);
|
|
147
147
|
|
|
@@ -169,7 +169,7 @@ export async function handleDeleteError(
|
|
|
169
169
|
identifiers,
|
|
170
170
|
targetIdentifiers,
|
|
171
171
|
status: 'error',
|
|
172
|
-
|
|
172
|
+
foundErrors
|
|
173
173
|
};
|
|
174
174
|
}
|
|
175
175
|
|
|
@@ -185,7 +185,7 @@ export async function <%- flowTag %>LogicalLib(
|
|
|
185
185
|
_izContext,
|
|
186
186
|
requestParams,
|
|
187
187
|
callingFlowConfig = {},
|
|
188
|
-
|
|
188
|
+
foundErrors = [],
|
|
189
189
|
phaseResults = {}
|
|
190
190
|
) {
|
|
191
191
|
try {
|
|
@@ -215,17 +215,17 @@ export async function <%- flowTag %>LogicalLib(
|
|
|
215
215
|
_izContext.logger.debug(`[${process.env.iz_serviceTag}:<%- flowTag %>LogicalLib] deleteDataDetails:`, deleteDataDetails);
|
|
216
216
|
|
|
217
217
|
if (objectSchema.canDelete === false || objectSchema.canDelete == null) {
|
|
218
|
-
|
|
218
|
+
foundErrors.push("this objectSchema can't delete");
|
|
219
219
|
}
|
|
220
220
|
|
|
221
221
|
// ── Early exit on errors ──────────────────────────────────────────────────
|
|
222
|
-
if (
|
|
222
|
+
if (foundErrors.length) {
|
|
223
223
|
return await handleDeleteError(_izContext, {
|
|
224
224
|
objType,
|
|
225
225
|
identifiers: requestParams.identifiers,
|
|
226
226
|
targetIdentifiers: requestParams.targetIdentifiers,
|
|
227
227
|
callingFlowConfig,
|
|
228
|
-
|
|
228
|
+
foundErrors
|
|
229
229
|
});
|
|
230
230
|
}
|
|
231
231
|
|
|
@@ -302,11 +302,11 @@ export async function <%- flowTag %>LogicalLib(
|
|
|
302
302
|
}
|
|
303
303
|
);
|
|
304
304
|
if (
|
|
305
|
-
hookResult?.
|
|
305
|
+
hookResult?.foundErrors?.length > 0 ||
|
|
306
306
|
hookResult?.status === 'error'
|
|
307
307
|
) {
|
|
308
|
-
|
|
309
|
-
...(hookResult.
|
|
308
|
+
foundErrors.push(
|
|
309
|
+
...(hookResult.foundErrors || ['Hook <%= hook.flowTag %> failed'])
|
|
310
310
|
);
|
|
311
311
|
}
|
|
312
312
|
} catch (hookErr) {
|
|
@@ -314,7 +314,7 @@ export async function <%- flowTag %>LogicalLib(
|
|
|
314
314
|
'[<%- flowTag %>LogicalLib] Sync hook <%= hook.flowTag %> error:',
|
|
315
315
|
hookErr
|
|
316
316
|
);
|
|
317
|
-
|
|
317
|
+
foundErrors.push(hookErr.message || 'Hook <%= hook.flowTag %> failed');
|
|
318
318
|
}
|
|
319
319
|
<%_ if (hook.targetObjectTypes && hook.targetObjectTypes.length > 0) { _%>
|
|
320
320
|
}
|
|
@@ -357,7 +357,7 @@ export async function <%- flowTag %>LogicalLib(
|
|
|
357
357
|
targetIdentifiers: requestParams.targetIdentifiers,
|
|
358
358
|
parentFlowId: requestParams.parentFlowId,
|
|
359
359
|
status: 'complete',
|
|
360
|
-
|
|
360
|
+
foundErrors
|
|
361
361
|
}
|
|
362
362
|
}
|
|
363
363
|
)
|
|
@@ -384,7 +384,7 @@ export async function <%- flowTag %>LogicalLib(
|
|
|
384
384
|
objType,
|
|
385
385
|
identifiers: requestParams.identifiers,
|
|
386
386
|
status: 'complete',
|
|
387
|
-
|
|
387
|
+
foundErrors
|
|
388
388
|
}
|
|
389
389
|
);
|
|
390
390
|
|
|
@@ -410,7 +410,7 @@ export async function <%- flowTag %>LogicalLib(
|
|
|
410
410
|
<%_ } _%>
|
|
411
411
|
|
|
412
412
|
let resultStatus = 'complete';
|
|
413
|
-
if (
|
|
413
|
+
if (foundErrors.length > 0) {
|
|
414
414
|
resultStatus = 'error';
|
|
415
415
|
}
|
|
416
416
|
|
|
@@ -419,7 +419,7 @@ export async function <%- flowTag %>LogicalLib(
|
|
|
419
419
|
identifiers: requestParams.identifiers,
|
|
420
420
|
targetIdentifiers: requestParams.targetIdentifiers,
|
|
421
421
|
status: resultStatus,
|
|
422
|
-
|
|
422
|
+
foundErrors
|
|
423
423
|
};
|
|
424
424
|
} catch (err) {
|
|
425
425
|
_izContext.logger.error(`[${process.env.iz_serviceTag}:<%- flowTag %>LogicalLib] error:`, err);
|
|
@@ -72,7 +72,7 @@ export default async function <%- flowTag %>RbacCallbackMain(
|
|
|
72
72
|
return 'all task not completed';
|
|
73
73
|
}
|
|
74
74
|
|
|
75
|
-
const
|
|
75
|
+
const foundErrors = [...collectedErrors];
|
|
76
76
|
|
|
77
77
|
// 2. Validate RBAC permission results
|
|
78
78
|
const { hasError, errorResult, rbacCallbackResults } = await assertRbacPermission(
|
|
@@ -80,7 +80,7 @@ export default async function <%- flowTag %>RbacCallbackMain(
|
|
|
80
80
|
{
|
|
81
81
|
rbacResults,
|
|
82
82
|
originalRequestParams,
|
|
83
|
-
|
|
83
|
+
foundErrors
|
|
84
84
|
}
|
|
85
85
|
);
|
|
86
86
|
|
|
@@ -96,7 +96,7 @@ export default async function <%- flowTag %>RbacCallbackMain(
|
|
|
96
96
|
_izContext,
|
|
97
97
|
originalRequestParams,
|
|
98
98
|
callingFlowConfig,
|
|
99
|
-
|
|
99
|
+
foundErrors,
|
|
100
100
|
rbacCallbackResults
|
|
101
101
|
);
|
|
102
102
|
|
|
@@ -48,12 +48,12 @@ export default async function UpdateAfterHookCallbackMain(
|
|
|
48
48
|
|
|
49
49
|
const {
|
|
50
50
|
status,
|
|
51
|
-
|
|
51
|
+
foundErrors = [],
|
|
52
52
|
returnValue,
|
|
53
53
|
parentFlowId
|
|
54
54
|
} = requestParams;
|
|
55
55
|
|
|
56
|
-
const mergedErrors = Array.isArray(
|
|
56
|
+
const mergedErrors = Array.isArray(foundErrors) ? [...foundErrors] : [];
|
|
57
57
|
if (status === 'error' && mergedErrors.length === 0) {
|
|
58
58
|
mergedErrors.push('AfterHook execution reported error');
|
|
59
59
|
}
|
|
@@ -75,7 +75,7 @@ export default async function UpdateAfterHookCallbackMain(
|
|
|
75
75
|
targetIdentifiers: requestParams?.targetIdentifiers,
|
|
76
76
|
parentFlowId: parentFlowId || returnValue?.parentFlowId,
|
|
77
77
|
status: mergedErrors.length > 0 ? 'error' : 'complete',
|
|
78
|
-
|
|
78
|
+
foundErrors: mergedErrors
|
|
79
79
|
};
|
|
80
80
|
|
|
81
81
|
const topicArn = snsSharedLib.snsTopicArnByFlowSchema(
|
|
@@ -89,7 +89,7 @@ export default async function UpdateAfterHookCallbackMain(
|
|
|
89
89
|
{
|
|
90
90
|
...actionData,
|
|
91
91
|
status: mergedErrors.length > 0 ? 'error' : 'complete',
|
|
92
|
-
|
|
92
|
+
foundErrors: mergedErrors
|
|
93
93
|
}
|
|
94
94
|
);
|
|
95
95
|
|
|
@@ -111,7 +111,7 @@ export default async function UpdateAfterHookCallbackMain(
|
|
|
111
111
|
return {
|
|
112
112
|
returnValue,
|
|
113
113
|
status: mergedErrors.length > 0 ? 'error' : 'complete',
|
|
114
|
-
|
|
114
|
+
foundErrors: mergedErrors
|
|
115
115
|
};
|
|
116
116
|
} catch (error) {
|
|
117
117
|
_izContext.logger.error('[UpdateAfterHookCallback] 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
|
versionedDataIds: originalRequestParams?.versionedDataIds,
|
|
84
84
|
callingFlowConfig,
|
|
85
|
-
|
|
85
|
+
foundErrors: mergedErrors
|
|
86
86
|
});
|
|
87
87
|
}
|
|
88
88
|
|