@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.
Files changed (82) hide show
  1. package/package.json +7 -10
  2. package/src/compile/flowValidator.js +6 -0
  3. package/src/compile/loadSchemas.js +177 -69
  4. package/src/emit/crud/emitDynamicCrudFlowSchemas.js +2 -2
  5. package/src/emit/crud/generateCrudApplicationArtifacts.js +15 -17
  6. package/src/emit/crud/generateDynamicCrudFlowSchemas.js +16 -21
  7. package/src/emit/crud/loadLocalSchemaArrays.js +4 -8
  8. package/src/emit/crud/templates/CreateAfterHookCallback_Main.ejs +6 -6
  9. package/src/emit/crud/templates/CreateBeforeHookCallback_Main.ejs +3 -3
  10. package/src/emit/crud/templates/CreateComplete_Main.ejs +22 -22
  11. package/src/emit/crud/templates/CreateEndpoint_Main.ejs +18 -18
  12. package/src/emit/crud/templates/CreateLogicalLib.ejs +47 -47
  13. package/src/emit/crud/templates/CreateNodeCallback_Main.ejs +24 -24
  14. package/src/emit/crud/templates/DeleteAfterHookCallback_Main.ejs +5 -5
  15. package/src/emit/crud/templates/DeleteBeforeHookCallback_Main.ejs +3 -3
  16. package/src/emit/crud/templates/DeleteComplete_Main.ejs +23 -23
  17. package/src/emit/crud/templates/DeleteEndpoint_Main.ejs +15 -15
  18. package/src/emit/crud/templates/DeleteLogicalLib.ejs +19 -19
  19. package/src/emit/crud/templates/FlowEndpointRbacCallback_Main.ejs +3 -3
  20. package/src/emit/crud/templates/UpdateAfterHookCallback_Main.ejs +5 -5
  21. package/src/emit/crud/templates/UpdateBeforeHookCallback_Main.ejs +3 -3
  22. package/src/emit/crud/templates/UpdateComplete_Main.ejs +22 -22
  23. package/src/emit/crud/templates/UpdateEndpoint_Main.ejs +15 -15
  24. package/src/emit/crud/templates/UpdateLogicalLib.ejs +33 -33
  25. package/src/emit/custom/customFlowPaths.js +149 -0
  26. package/src/emit/custom/customFlowS3.js +156 -0
  27. package/src/emit/custom/customFlowSteps.js +385 -0
  28. package/src/emit/custom/customFlowTemplates.js +28 -0
  29. package/src/emit/custom/customFlows.js +48 -19
  30. package/src/emit/custom/emitCustomFlowApplicationArtifacts.js +57 -692
  31. package/src/emit/custom/generateCustomFlowApplicationArtifacts.js +27 -25
  32. package/src/emit/custom/templates/FlowEndpointRbacCallback_Main.ejs +7 -7
  33. package/src/emit/custom/templates/s3/ConfirmReserved_HdrSqs.ejs +3 -3
  34. package/src/emit/custom/templates/s3/ConfirmReserved_Main.ejs +3 -3
  35. package/src/emit/custom/templates/s3/CreatePreSignUrl_HdrSqs.ejs +3 -3
  36. package/src/emit/custom/templates/s3/CreatePreSignUrl_Main.ejs +4 -4
  37. package/src/emit/rbac/emitDynamicRbacFlowSchemas.js +26 -6
  38. package/src/emit/rbac/emitRbacApplicationArtifacts.js +40 -13
  39. package/src/emit/rbac/generateCreateTargetRoleHandler.js +11 -13
  40. package/src/emit/rbac/generateDynamicRbacFlowSchemas.js +14 -18
  41. package/src/emit/rbac/templates/UserRbacFlow_Main.ejs +13 -7
  42. package/src/emit/relationship/emitDynamicRelationshipFlowSchemas.js +1 -1
  43. package/src/emit/relationship/generateDynamicRelationshipFlowSchemas.js +16 -19
  44. package/src/emit/relationship/generateRelationshipApplicationArtifacts.js +19 -19
  45. package/src/emit/relationship/templates/ChangeRelationshipComplete_HdrSqs.ejs +2 -2
  46. package/src/emit/relationship/templates/ChangeRelationshipComplete_Main.ejs +6 -6
  47. package/src/emit/relationship/templates/ChangeRelationship_Main.ejs +17 -17
  48. package/src/emit/relationship/templates/CreateRelationshipComplete_HdrSqs.ejs +2 -2
  49. package/src/emit/relationship/templates/CreateRelationshipComplete_Main.ejs +6 -6
  50. package/src/emit/relationship/templates/CreateRelationship_Main.ejs +14 -14
  51. package/src/emit/relationship/templates/DeleteRelationshipComplete_HdrSqs.ejs +2 -2
  52. package/src/emit/relationship/templates/DeleteRelationshipComplete_Main.ejs +6 -6
  53. package/src/emit/relationship/templates/DeleteRelationship_Main.ejs +10 -10
  54. package/src/emit/relationship/templates/GetRelationshipComplete_HdrSqs.ejs +2 -2
  55. package/src/emit/relationship/templates/GetRelationshipComplete_Main.ejs +5 -5
  56. package/src/emit/relationship/templates/GetRelationship_Main.ejs +9 -9
  57. package/src/emit/relationship/templates/MoveRelationshipComplete_HdrSqs.ejs +2 -2
  58. package/src/emit/relationship/templates/MoveRelationshipComplete_Main.ejs +6 -6
  59. package/src/emit/relationship/templates/MoveRelationship_Main.ejs +15 -15
  60. package/src/emit/relationship/templates/UpdateRelationshipComplete_HdrSqs.ejs +2 -2
  61. package/src/emit/relationship/templates/UpdateRelationshipComplete_Main.ejs +6 -6
  62. package/src/emit/relationship/templates/UpdateRelationship_Main.ejs +11 -11
  63. package/src/emit/resource/dynamoResourceArtifacts.js +18 -0
  64. package/src/emit/resource/emitResourceArtifacts.js +13 -1251
  65. package/src/emit/resource/generateResourceArtifacts.js +20 -20
  66. package/src/emit/resource/iamResourceArtifacts.js +612 -0
  67. package/src/emit/resource/resourceState.js +564 -0
  68. package/src/emit/resource/resourceTemplate.js +30 -0
  69. package/src/emit/resource/s3ResourceArtifacts.js +14 -0
  70. package/src/emit/resource/sqsResourceArtifacts.js +113 -0
  71. package/src/emit/shared/runSubsystemGeneration.js +55 -0
  72. package/src/emit/shared/templates/FindData_Main.ejs +19 -19
  73. package/src/emit/shared/templates/PaginateProcessLogical_Main.ejs +3 -3
  74. package/src/emit/shared/templates/ProcessLogical_Main.ejs +15 -15
  75. package/src/emit/system/emitSystemWebSocketArtifacts.js +2 -1
  76. package/test/createTargetRoleHandler.test.js +62 -4
  77. package/test/crudApplicationArtifacts.test.js +75 -3
  78. package/test/customFlowApplicationArtifacts.test.js +98 -0
  79. package/test/dynamicCrudFlowSchemas.test.js +2 -2
  80. package/test/dynamicRbacFlowSchemas.test.js +32 -4
  81. package/test/relationshipApplicationArtifacts.test.js +1 -1
  82. package/test/resourceArtifacts.test.js +99 -0
@@ -23,29 +23,29 @@ function empty(value) {
23
23
  );
24
24
  }
25
25
 
26
- function validateInput(returnValue, status, graphServiceTag, errorsFound) {
26
+ function validateInput(returnValue, status, graphServiceTag, foundErrors) {
27
27
  if (!returnValue?.queryResult)
28
- errorsFound.push(
28
+ foundErrors.push(
29
29
  'message is not have property queryResult, should be not happen'
30
30
  );
31
31
  if (!returnValue?.requestParams?.objType)
32
- errorsFound.push(
32
+ foundErrors.push(
33
33
  'message is not have property objType, should be not happen'
34
34
  );
35
35
  if (!returnValue?.requestParams?.objInstanceFull)
36
- errorsFound.push(
36
+ foundErrors.push(
37
37
  'message is not have property objInstance, should be not objInstance'
38
38
  );
39
- if (status === 'error' && errorsFound.length === 0)
40
- errorsFound.push(
41
- '[invalid]status is error not have errorsFound form graphService'
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' && errorsFound.length > 0)
44
- errorsFound.push(
45
- '[Invalid] status is complete should be not have errorsFound'
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
- errorsFound.push('[Invalid] graphServerTag is not empty string');
48
+ foundErrors.push('[Invalid] graphServerTag is not empty string');
49
49
  }
50
50
 
51
51
  export default async function UpdateComplete(
@@ -62,14 +62,14 @@ export default async function UpdateComplete(
62
62
  const {
63
63
  returnValue,
64
64
  status,
65
- errorsFound = [],
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, errorsFound);
72
- if (errorsFound.length > 0) errorsFound.push(errorsFound.join(','));
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 UpdateComplete(
88
88
  _izContext.logger.warn(
89
89
  `No pending step found for awaitingStepId: ${awaitingStepId}`
90
90
  );
91
- return { returnValue, status, errorsFound };
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
- errorsFound
98
+ foundErrors
99
99
  );
100
100
  _izContext.logger.debug(
101
101
  '[UpdateComplete] all awaiting steps result',
@@ -154,7 +154,7 @@ export default async function UpdateComplete(
154
154
  parentFlowId: parentFlowId || returnValue?.parentFlowId,
155
155
  existsNode,
156
156
  status,
157
- errorsFound
157
+ foundErrors
158
158
  };
159
159
 
160
160
  <%_ if (plan?.hasAfterHookSync) { _%>
@@ -185,12 +185,12 @@ export default async function UpdateComplete(
185
185
  callingFlowConfig
186
186
  }
187
187
  );
188
- if (hookResult?.errorsFound?.length > 0 || hookResult?.status === 'error') {
189
- errorsFound.push(...(hookResult.errorsFound || ['Hook <%= hook.flowTag %> failed']));
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('[UpdateComplete] Sync hook <%= hook.flowTag %> error:', hookErr);
193
- errorsFound.push(hookErr.message || 'Hook <%= hook.flowTag %> failed');
193
+ foundErrors.push(hookErr.message || 'Hook <%= hook.flowTag %> failed');
194
194
  }
195
195
  <%_ if (hook.targetObjectTypes && hook.targetObjectTypes.length > 0) { _%>
196
196
  }
@@ -277,9 +277,9 @@ export default async function UpdateComplete(
277
277
  _izContext,
278
278
  awaitingStepId,
279
279
  pending.pendingStepId,
280
- errorsFound
280
+ foundErrors
281
281
  );
282
- return { returnValue, status, errorsFound };
282
+ return { returnValue, status, foundErrors };
283
283
  } catch (error) {
284
284
  _izContext.logger.error('[UpdateComplete] error:', error);
285
285
  throw error;
@@ -77,11 +77,11 @@ export default async function <%- flowTag %>(
77
77
  callingFlowConfig
78
78
  });
79
79
 
80
- const errorsFound = [];
80
+ const foundErrors = [];
81
81
 
82
82
  // ── Resolve Schema & Identity ─────────────────────────────────────────────
83
83
  const { objType, objectSchema, targetIdentifiers } =
84
- await resolveSchemaAndIdentity(_izContext, requestParams, errorsFound);
84
+ await resolveSchemaAndIdentity(_izContext, requestParams, foundErrors);
85
85
 
86
86
  // ── Build identifiers used by asynchronous processing ────────────────────
87
87
  const identifiers = requestParams.objInstanceFull?.identifiers;
@@ -110,7 +110,7 @@ export default async function <%- flowTag %>(
110
110
  // value !== undefined &&
111
111
  // targetIdentifiers[key] !== value
112
112
  // ) {
113
- // errorsFound.push(
113
+ // foundErrors.push(
114
114
  // `targetIdentifiers.${key} must match objInstanceFull.identifiers.${key}`
115
115
  // );
116
116
  // }
@@ -120,12 +120,12 @@ export default async function <%- flowTag %>(
120
120
  //(<validateBeforeUpdate>)
121
121
  //(</validateBeforeUpdate>)
122
122
 
123
- if (errorsFound.length > 0)
123
+ if (foundErrors.length > 0)
124
124
  return await <%- flowTag %>LogicalLib(
125
125
  _izContext,
126
126
  requestParams,
127
127
  callingFlowConfig,
128
- errorsFound
128
+ foundErrors
129
129
  );
130
130
 
131
131
  <%_
@@ -184,12 +184,12 @@ export default async function <%- flowTag %>(
184
184
  );
185
185
 
186
186
  if (resultPermissionCheck && resultPermissionCheck.permission !== true) {
187
- errorsFound.push('Permission denied');
187
+ foundErrors.push('Permission denied');
188
188
  return await <%- flowTag %>LogicalLib(
189
189
  _izContext,
190
190
  requestParams,
191
191
  callingFlowConfig,
192
- errorsFound
192
+ foundErrors
193
193
  );
194
194
  }
195
195
 
@@ -249,10 +249,10 @@ export default async function <%- flowTag %>(
249
249
  flowTag: '<%= config.flowTag %>',
250
250
  returnValue
251
251
  });
252
- if (returnValue?.errorsFound?.length > 0) {
253
- errorsFound.push(...returnValue.errorsFound);
252
+ if (returnValue?.foundErrors?.length > 0) {
253
+ foundErrors.push(...returnValue.foundErrors);
254
254
  } else if (returnValue?.status === 'error') {
255
- errorsFound.push('Error from <%= config.flowTag %>');
255
+ foundErrors.push('Error from <%= config.flowTag %>');
256
256
  } else {
257
257
  if (returnValue?.fields && requestParams?.objInstanceFull?.fields) {
258
258
  Object.assign(requestParams.objInstanceFull.fields, returnValue.fields);
@@ -270,16 +270,16 @@ export default async function <%- flowTag %>(
270
270
  '[<%- flowTag %>] Sync hook <%= config.flowTag %> error:',
271
271
  hookErr
272
272
  );
273
- errorsFound.push(hookErr.message || 'Hook <%= config.flowTag %> failed');
273
+ foundErrors.push(hookErr.message || 'Hook <%= config.flowTag %> failed');
274
274
  }
275
275
  <%_ } _%>
276
276
 
277
- if (errorsFound.length > 0) {
277
+ if (foundErrors.length > 0) {
278
278
  return await <%- flowTag %>LogicalLib(
279
279
  _izContext,
280
280
  requestParams,
281
281
  callingFlowConfig,
282
- errorsFound
282
+ foundErrors
283
283
  );
284
284
  }
285
285
  <%_ } _%>
@@ -362,7 +362,7 @@ export default async function <%- flowTag %>(
362
362
  _izContext,
363
363
  requestParams,
364
364
  callingFlowConfig,
365
- errorsFound
365
+ foundErrors
366
366
  );
367
367
  <%_ } _%>
368
368
  }
@@ -376,7 +376,7 @@ export default async function <%- flowTag %>(
376
376
  _izContext,
377
377
  requestParams,
378
378
  callingFlowConfig,
379
- errorsFound
379
+ foundErrors
380
380
  );
381
381
  } catch (err) {
382
382
  _izContext.logger.error(`[${process.env.iz_serviceTag}:<%- flowTag %>] error:`, err);
@@ -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>} errorsFound - Array to collect validation errors
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, errorsFound) {
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,10 +97,10 @@ export async function resolveSchemaAndIdentity(_izContext, requestParams, errors
97
97
  }
98
98
 
99
99
  if (!submittedByUserId) {
100
- errorsFound.push('Not have submittedByUserId');
100
+ foundErrors.push('Not have submittedByUserId');
101
101
  }
102
102
  if (objectSchema.hasOwnProperty('belongTo') && !targetIdentifiers) {
103
- errorsFound.push('not have targetIdentifiers');
103
+ foundErrors.push('not have targetIdentifiers');
104
104
  }
105
105
 
106
106
  requestParams.submittedByUserId = submittedByUserId;
@@ -153,7 +153,7 @@ export async function collectRbacAwaitingResults(_izContext, requestParams) {
153
153
  _izContext,
154
154
  rbacPendingStepId,
155
155
  currentAwaitingStepId,
156
- requestParams.errorsFound,
156
+ requestParams.foundErrors,
157
157
  {
158
158
  returnValue: requestParams.returnValue,
159
159
  rbacType
@@ -170,7 +170,7 @@ export async function collectRbacAwaitingResults(_izContext, requestParams) {
170
170
  const {
171
171
  isComplete,
172
172
  collectedReturnValueByAwaitingStepId,
173
- collectedErrors: errorsFound = [],
173
+ collectedErrors: foundErrors = [],
174
174
  additionalAttributes
175
175
  } = rbacAwaitingStepsResult;
176
176
 
@@ -214,7 +214,7 @@ export async function collectRbacAwaitingResults(_izContext, requestParams) {
214
214
  isComplete: true,
215
215
  rbacResults,
216
216
  originalRequestParams,
217
- collectedErrors: errorsFound
217
+ collectedErrors: foundErrors
218
218
  };
219
219
  }
220
220
 
@@ -224,13 +224,13 @@ export async function collectRbacAwaitingResults(_izContext, requestParams) {
224
224
  * @param {Object} options - Validation options
225
225
  * @returns {Promise<{ hasError: boolean, errorResult?: Object, rbacCallbackResults: Object }>}
226
226
  */
227
- export async function assertRbacPermission(_izContext, { rbacResults, originalRequestParams, errorsFound }) {
227
+ export async function assertRbacPermission(_izContext, { rbacResults, originalRequestParams, foundErrors }) {
228
228
  const rbacCallbackResults = {};
229
229
  let hasError = false;
230
230
 
231
231
  for (const [type, result] of Object.entries(rbacResults || {})) {
232
232
  if (result && result.error) {
233
- errorsFound.push(result.error);
233
+ foundErrors.push(result.error);
234
234
  hasError = true;
235
235
  } else {
236
236
  rbacCallbackResults[type] = result;
@@ -246,7 +246,7 @@ export async function assertRbacPermission(_izContext, { rbacResults, originalRe
246
246
  }
247
247
 
248
248
  if (!isAllowed) {
249
- errorsFound.push('Permission denied');
249
+ foundErrors.push('Permission denied');
250
250
  }
251
251
 
252
252
  _izContext.logger.debug(
@@ -254,13 +254,13 @@ export async function assertRbacPermission(_izContext, { rbacResults, originalRe
254
254
  {
255
255
  rbacCallbackResults,
256
256
  isAllowed,
257
- errorsFound
257
+ foundErrors
258
258
  }
259
259
  );
260
260
 
261
- if (hasError || errorsFound.length > 0) {
261
+ if (hasError || foundErrors.length > 0) {
262
262
  const errorResult = {
263
- errorsFound,
263
+ foundErrors,
264
264
  status: 'rejected',
265
265
  requestParams: originalRequestParams
266
266
  };
@@ -322,13 +322,13 @@ export async function resolveObjectSchemas(_izContext, objectType) {
322
322
  * @param {Object} requestParams - Request parameters
323
323
  * @param {Object} objectSchema - Object schema
324
324
  * @param {Object} versionedDataIds - Versioned data IDs map
325
- * @param {Array<string>} errorsFound - Array to collect validation errors
325
+ * @param {Array<string>} foundErrors - Array to collect validation errors
326
326
  */
327
327
  export function validateVersionedDataIds(
328
328
  requestParams,
329
329
  objectSchema,
330
330
  versionedDataIds,
331
- errorsFound
331
+ foundErrors
332
332
  ) {
333
333
  const versionedDataIdsKeys = Object.keys(versionedDataIds || {});
334
334
  if (versionedDataIdsKeys.length === 0) {
@@ -364,17 +364,17 @@ export function validateVersionedDataIds(
364
364
  );
365
365
 
366
366
  if (missingVersionedDataIdLabels.length > 0) {
367
- errorsFound.push(
367
+ foundErrors.push(
368
368
  `missing versionedDataIds of versionedDataLabel '${missingVersionedDataIdLabels.join(', ')}'`
369
369
  );
370
370
  }
371
371
  if (missingDataVersionedDataLabels.length > 0) {
372
- errorsFound.push(
372
+ foundErrors.push(
373
373
  `missing data of versionedDataLabels '${missingDataVersionedDataLabels.join(', ')}'`
374
374
  );
375
375
  }
376
376
  if (Object.keys(updateMainNodeData).length > 0) {
377
- errorsFound.push('cannot update mainNode if have versionedDataIds');
377
+ foundErrors.push('cannot update mainNode if have versionedDataIds');
378
378
  }
379
379
  }
380
380
 
@@ -598,7 +598,7 @@ export async function handleUpdateError(
598
598
  fields,
599
599
  versionedDataIds,
600
600
  callingFlowConfig,
601
- errorsFound
601
+ foundErrors
602
602
  }
603
603
  ) {
604
604
  const updateNodeCompleteMessage =
@@ -609,7 +609,7 @@ export async function handleUpdateError(
609
609
  objInstanceFull: { identifiers, fields },
610
610
  versionedDataIds,
611
611
  status: 'error',
612
- errorsFound
612
+ foundErrors
613
613
  }
614
614
  );
615
615
 
@@ -671,15 +671,15 @@ export async function publishCompletionMessage(_izContext, message, messageAttri
671
671
  * @param {Object} _izContext - Context object with logger
672
672
  * @param {Object} requestParams - { objectType, objInstanceFull, versionedDataIds, additionalParams }
673
673
  * @param {Object} callingFlowConfig - Calling flow configuration
674
- * @param {Array<string>} errorsFound - Array of preceding errors
674
+ * @param {Array<string>} foundErrors - Array of preceding errors
675
675
  * @param {Object} phaseResults - Results from preceding phases
676
- * @returns {Promise<Object>} Result with objType, objInstanceFull, versionedDataIds, status, errorsFound
676
+ * @returns {Promise<Object>} Result with objType, objInstanceFull, versionedDataIds, status, foundErrors
677
677
  */
678
678
  export async function <%- flowTag %>LogicalLib(
679
679
  _izContext,
680
680
  requestParams,
681
681
  callingFlowConfig = {},
682
- errorsFound = [],
682
+ foundErrors = [],
683
683
  phaseResults = {}
684
684
  ) {
685
685
  try {
@@ -725,21 +725,21 @@ export async function <%- flowTag %>LogicalLib(
725
725
  requestParams,
726
726
  objectSchema,
727
727
  versionedDataIds,
728
- errorsFound
728
+ foundErrors
729
729
  );
730
730
 
731
731
  //(<validateBeforeUpdate>)
732
732
  //(</validateBeforeUpdate>)
733
733
 
734
734
  // 3. Early exit on errors
735
- if (errorsFound.length > 0) {
735
+ if (foundErrors.length > 0) {
736
736
  return await handleUpdateError(_izContext, {
737
737
  objType,
738
738
  identifiers,
739
739
  fields,
740
740
  versionedDataIds,
741
741
  callingFlowConfig,
742
- errorsFound
742
+ foundErrors
743
743
  });
744
744
  }
745
745
 
@@ -882,11 +882,11 @@ export async function <%- flowTag %>LogicalLib(
882
882
  }
883
883
  );
884
884
  if (
885
- hookResult?.errorsFound?.length > 0 ||
885
+ hookResult?.foundErrors?.length > 0 ||
886
886
  hookResult?.status === 'error'
887
887
  ) {
888
- errorsFound.push(
889
- ...(hookResult.errorsFound || ['Hook <%= hook.flowTag %> failed'])
888
+ foundErrors.push(
889
+ ...(hookResult.foundErrors || ['Hook <%= hook.flowTag %> failed'])
890
890
  );
891
891
  }
892
892
  } catch (hookErr) {
@@ -894,7 +894,7 @@ export async function <%- flowTag %>LogicalLib(
894
894
  '[<%- flowTag %>LogicalLib] Sync hook <%= hook.flowTag %> error:',
895
895
  hookErr
896
896
  );
897
- errorsFound.push(hookErr.message || 'Hook <%= hook.flowTag %> failed');
897
+ foundErrors.push(hookErr.message || 'Hook <%= hook.flowTag %> failed');
898
898
  }
899
899
  <%_ if (hook.targetObjectTypes && hook.targetObjectTypes.length > 0) { _%>
900
900
  }
@@ -943,7 +943,7 @@ export async function <%- flowTag %>LogicalLib(
943
943
  targetIdentifiers: requestParams.targetIdentifiers,
944
944
  parentFlowId: requestParams.parentFlowId,
945
945
  status: 'complete',
946
- errorsFound
946
+ foundErrors
947
947
  }
948
948
  }
949
949
  )
@@ -973,7 +973,7 @@ export async function <%- flowTag %>LogicalLib(
973
973
  }
974
974
 
975
975
  let resultStatus = 'complete';
976
- if (errorsFound.length > 0) {
976
+ if (foundErrors.length > 0) {
977
977
  resultStatus = 'error';
978
978
  }
979
979
 
@@ -984,7 +984,7 @@ export async function <%- flowTag %>LogicalLib(
984
984
  versionedDataIds
985
985
  },
986
986
  status: resultStatus,
987
- errorsFound
987
+ foundErrors
988
988
  };
989
989
  } catch (err) {
990
990
  _izContext.logger.error(`[${process.env.iz_serviceTag}:<%- flowTag %>LogicalLib] error:`, err);
@@ -0,0 +1,149 @@
1
+ import {
2
+ flowDsqSteps,
3
+ flowExtTopicSteps,
4
+ generatedDsqFlows,
5
+ generatedOwnTopicFlows,
6
+ supportedCustomFlows,
7
+ upperFirst,
8
+ flowHasRbac
9
+ } from './customFlows.js';
10
+
11
+ export const YAML_PATH = 'app/sls_yaml/generatedCode/source/flow-schema.yml';
12
+
13
+ export function isS3Only(flow) {
14
+ return flow.event.length === 1 && flow.event[0] === 's3';
15
+ }
16
+
17
+ export function needsProcessMain(flow) {
18
+ const isOwnTopicTransport =
19
+ flow.event.includes('ownTopic') ||
20
+ (flow.event.includes('generateCode') &&
21
+ flow.generatedCodeConfig?.invocationType === 'ownTopic');
22
+ return (
23
+ !isS3Only(flow) &&
24
+ !isOwnTopicTransport &&
25
+ flow.event.some((event) => event !== 'ownTopic' && event !== 's3')
26
+ );
27
+ }
28
+
29
+ export function ownTopicRootPaths(flow, objects = []) {
30
+ const tag = upperFirst(flow.flowTag);
31
+ const source = `app/src/generatedCode/FlowSchemas/${tag}/source`;
32
+ const paths = [
33
+ `${source}/${tag}_Main.js`,
34
+ `${source}/${tag}_HdrSqs.js`,
35
+ `${source}/${tag}_WbsMain.js`,
36
+ `${source}/${tag}_HdrWbs.js`
37
+ ];
38
+ if (flowHasRbac(flow, objects)) {
39
+ paths.push(
40
+ `${source}/${tag}RbacCallback_Main.js`,
41
+ `${source}/${tag}RbacCallback_HdrSqs.js`
42
+ );
43
+ }
44
+ return paths;
45
+ }
46
+
47
+ export function flowPaths(flow, objects = []) {
48
+ const tag = upperFirst(flow.flowTag);
49
+ const process = tag;
50
+ const source = `app/src/generatedCode/FlowSchemas/${tag}/source`;
51
+ const paths = [];
52
+ if (needsProcessMain(flow)) {
53
+ paths.push(`${source}/${process}_Main.js`);
54
+ }
55
+ if (flowHasRbac(flow, objects)) {
56
+ paths.push(
57
+ `${source}/${tag}RbacCallback_Main.js`,
58
+ `${source}/${tag}RbacCallback_HdrSqs.js`
59
+ );
60
+ }
61
+ if (flow.event.includes('extTopic') && !flow.event.includes('ownTopic')) {
62
+ paths.push(`${source}/${process}_HdrSqs.js`);
63
+ }
64
+ if (flow.event.includes('dsq')) {
65
+ paths.push(`${source}/${process}_HdrDsq.js`);
66
+ }
67
+ if (
68
+ flow.event.includes('lambdaSyncInv') ||
69
+ flow.event.includes('eventBridge') ||
70
+ (flow.event.includes('generateCode') &&
71
+ flow.generatedCodeConfig?.invocationType === 'lambdaSyncInv')
72
+ ) {
73
+ paths.push(`${source}/${process}_HdrInv.js`);
74
+ }
75
+ if (flow.event.includes('lambdaSyncApi')) {
76
+ paths.push(`${source}/${process}_HdrApi.js`);
77
+ }
78
+ if (
79
+ flow.event.includes('ownTopic') ||
80
+ (flow.event.includes('generateCode') &&
81
+ flow.generatedCodeConfig?.invocationType === 'ownTopic')
82
+ ) {
83
+ paths.push(...ownTopicRootPaths(flow, objects));
84
+ }
85
+ if (flow.event.includes('s3')) {
86
+ const s3Actions = [
87
+ 'ConfirmAfterUpload',
88
+ 'CreateObject',
89
+ 'CreatePreSignUrl',
90
+ 'ProcessAfterUpload',
91
+ 'ReservedLimit'
92
+ ];
93
+ for (const action of s3Actions) {
94
+ let handler = 'HdrSqs';
95
+ if (action === 'CreateObject') {
96
+ handler = 'HdrWbs';
97
+ } else if (action === 'ProcessAfterUpload') {
98
+ handler = 'HdrS3';
99
+ }
100
+ paths.push(
101
+ `${source}/${tag}${action}_Main.js`,
102
+ `${source}/${tag}${action}_${handler}.js`
103
+ );
104
+ }
105
+ }
106
+ return paths;
107
+ }
108
+
109
+ export function customFlowApplicationManagedPaths(
110
+ flows,
111
+ { objects = [] } = {}
112
+ ) {
113
+ const customFlowList = supportedCustomFlows(flows);
114
+ const generatedRoots = generatedOwnTopicFlows(flows);
115
+ const generatedDsqs = generatedDsqFlows(flows);
116
+ const extSteps = flowExtTopicSteps(flows);
117
+ const dsqSteps = flowDsqSteps(flows);
118
+
119
+ return [
120
+ ...customFlowList.flatMap((flow) => flowPaths(flow, objects)),
121
+ ...generatedRoots.flatMap((flow) => ownTopicRootPaths(flow, objects)),
122
+ ...extSteps.flatMap(({ flowTag, stepName }) => {
123
+ const source = `app/src/generatedCode/FlowSchemas/${flowTag}/source`;
124
+ return [
125
+ `${source}/${flowTag}${stepName}_Main.js`,
126
+ `${source}/${flowTag}${stepName}_HdrSqs.js`
127
+ ];
128
+ }),
129
+ ...dsqSteps.flatMap(({ flowTag, stepName, step }) => {
130
+ const source = `app/src/generatedCode/FlowSchemas/${flowTag}/source`;
131
+ let stepEvents = [];
132
+ if (Array.isArray(step.event)) {
133
+ stepEvents = step.event;
134
+ }
135
+ const files = [`${source}/${flowTag}${stepName}_HdrDsq.js`];
136
+ if (!stepEvents.includes('extTopic')) {
137
+ files.unshift(`${source}/${flowTag}${stepName}_Main.js`);
138
+ }
139
+ return files;
140
+ }),
141
+ ...(customFlowList.length > 0 ||
142
+ generatedRoots.length > 0 ||
143
+ generatedDsqs.length > 0 ||
144
+ extSteps.length > 0 ||
145
+ dsqSteps.length > 0
146
+ ? [YAML_PATH]
147
+ : [])
148
+ ];
149
+ }