@izara_project/izara-core-generate-service-code 1.0.89 → 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.
Files changed (56) hide show
  1. package/package.json +1 -1
  2. package/src/emit/crud/emitDynamicCrudFlowSchemas.js +2 -2
  3. package/src/emit/crud/templates/CreateAfterHookCallback_Main.ejs +6 -6
  4. package/src/emit/crud/templates/CreateBeforeHookCallback_Main.ejs +3 -3
  5. package/src/emit/crud/templates/CreateComplete_Main.ejs +153 -28
  6. package/src/emit/crud/templates/CreateEndpoint_Main.ejs +18 -18
  7. package/src/emit/crud/templates/CreateLogicalLib.ejs +83 -54
  8. package/src/emit/crud/templates/CreateNodeCallback_Main.ejs +32 -25
  9. package/src/emit/crud/templates/DeleteAfterHookCallback_Main.ejs +5 -5
  10. package/src/emit/crud/templates/DeleteBeforeHookCallback_Main.ejs +3 -3
  11. package/src/emit/crud/templates/DeleteComplete_Main.ejs +23 -23
  12. package/src/emit/crud/templates/DeleteEndpoint_Main.ejs +15 -15
  13. package/src/emit/crud/templates/DeleteLogicalLib.ejs +20 -22
  14. package/src/emit/crud/templates/FlowEndpointRbacCallback_Main.ejs +3 -3
  15. package/src/emit/crud/templates/UpdateAfterHookCallback_Main.ejs +5 -5
  16. package/src/emit/crud/templates/UpdateBeforeHookCallback_Main.ejs +3 -3
  17. package/src/emit/crud/templates/UpdateComplete_Main.ejs +22 -22
  18. package/src/emit/crud/templates/UpdateEndpoint_Main.ejs +15 -15
  19. package/src/emit/crud/templates/UpdateLogicalLib.ejs +33 -36
  20. package/src/emit/custom/templates/FlowEndpointRbacCallback_Main.ejs +7 -7
  21. package/src/emit/custom/templates/s3/ConfirmReserved_HdrSqs.ejs +3 -3
  22. package/src/emit/custom/templates/s3/ConfirmReserved_Main.ejs +3 -3
  23. package/src/emit/custom/templates/s3/CreatePreSignUrl_HdrSqs.ejs +3 -3
  24. package/src/emit/custom/templates/s3/CreatePreSignUrl_Main.ejs +4 -4
  25. package/src/emit/rbac/emitDynamicRbacFlowSchemas.js +26 -6
  26. package/src/emit/rbac/emitRbacApplicationArtifacts.js +40 -13
  27. package/src/emit/rbac/templates/UserRbacFlow_Main.ejs +33 -20
  28. package/src/emit/relationship/emitDynamicRelationshipFlowSchemas.js +1 -1
  29. package/src/emit/relationship/templates/ChangeRelationshipComplete_HdrSqs.ejs +2 -2
  30. package/src/emit/relationship/templates/ChangeRelationshipComplete_Main.ejs +6 -6
  31. package/src/emit/relationship/templates/ChangeRelationship_Main.ejs +17 -17
  32. package/src/emit/relationship/templates/CreateRelationshipComplete_HdrSqs.ejs +2 -2
  33. package/src/emit/relationship/templates/CreateRelationshipComplete_Main.ejs +6 -6
  34. package/src/emit/relationship/templates/CreateRelationship_Main.ejs +14 -14
  35. package/src/emit/relationship/templates/DeleteRelationshipComplete_HdrSqs.ejs +2 -2
  36. package/src/emit/relationship/templates/DeleteRelationshipComplete_Main.ejs +6 -6
  37. package/src/emit/relationship/templates/DeleteRelationship_Main.ejs +10 -10
  38. package/src/emit/relationship/templates/GetRelationshipComplete_HdrSqs.ejs +2 -2
  39. package/src/emit/relationship/templates/GetRelationshipComplete_Main.ejs +5 -5
  40. package/src/emit/relationship/templates/GetRelationship_Main.ejs +9 -9
  41. package/src/emit/relationship/templates/MoveRelationshipComplete_HdrSqs.ejs +2 -2
  42. package/src/emit/relationship/templates/MoveRelationshipComplete_Main.ejs +6 -6
  43. package/src/emit/relationship/templates/MoveRelationship_Main.ejs +15 -15
  44. package/src/emit/relationship/templates/UpdateRelationshipComplete_HdrSqs.ejs +2 -2
  45. package/src/emit/relationship/templates/UpdateRelationshipComplete_Main.ejs +6 -6
  46. package/src/emit/relationship/templates/UpdateRelationship_Main.ejs +11 -11
  47. package/src/emit/resource/emitResourceArtifacts.js +48 -18
  48. package/src/emit/shared/templates/FindData_Main.ejs +19 -19
  49. package/src/emit/shared/templates/PaginateProcessLogical_Main.ejs +3 -3
  50. package/src/emit/shared/templates/ProcessLogical_Main.ejs +15 -15
  51. package/test/createTargetRoleHandler.test.js +70 -9
  52. package/test/crudApplicationArtifacts.test.js +98 -3
  53. package/test/dynamicCrudFlowSchemas.test.js +2 -2
  54. package/test/dynamicRbacFlowSchemas.test.js +32 -4
  55. package/test/relationshipApplicationArtifacts.test.js +1 -1
  56. package/test/resourceArtifacts.test.js +42 -0
@@ -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,17 +97,14 @@ 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;
107
107
  if (targetIdentifiers) {
108
- if (!targetIdentifiers.submittedByUserId && submittedByUserId) {
109
- targetIdentifiers.submittedByUserId = submittedByUserId;
110
- }
111
108
  // requestParams.targetIdentifiers = targetIdentifiers;
112
109
  }
113
110
 
@@ -156,7 +153,7 @@ export async function collectRbacAwaitingResults(_izContext, requestParams) {
156
153
  _izContext,
157
154
  rbacPendingStepId,
158
155
  currentAwaitingStepId,
159
- requestParams.errorsFound,
156
+ requestParams.foundErrors,
160
157
  {
161
158
  returnValue: requestParams.returnValue,
162
159
  rbacType
@@ -173,7 +170,7 @@ export async function collectRbacAwaitingResults(_izContext, requestParams) {
173
170
  const {
174
171
  isComplete,
175
172
  collectedReturnValueByAwaitingStepId,
176
- collectedErrors: errorsFound = [],
173
+ collectedErrors: foundErrors = [],
177
174
  additionalAttributes
178
175
  } = rbacAwaitingStepsResult;
179
176
 
@@ -217,7 +214,7 @@ export async function collectRbacAwaitingResults(_izContext, requestParams) {
217
214
  isComplete: true,
218
215
  rbacResults,
219
216
  originalRequestParams,
220
- collectedErrors: errorsFound
217
+ collectedErrors: foundErrors
221
218
  };
222
219
  }
223
220
 
@@ -227,13 +224,13 @@ export async function collectRbacAwaitingResults(_izContext, requestParams) {
227
224
  * @param {Object} options - Validation options
228
225
  * @returns {Promise<{ hasError: boolean, errorResult?: Object, rbacCallbackResults: Object }>}
229
226
  */
230
- export async function assertRbacPermission(_izContext, { rbacResults, originalRequestParams, errorsFound }) {
227
+ export async function assertRbacPermission(_izContext, { rbacResults, originalRequestParams, foundErrors }) {
231
228
  const rbacCallbackResults = {};
232
229
  let hasError = false;
233
230
 
234
231
  for (const [type, result] of Object.entries(rbacResults || {})) {
235
232
  if (result && result.error) {
236
- errorsFound.push(result.error);
233
+ foundErrors.push(result.error);
237
234
  hasError = true;
238
235
  } else {
239
236
  rbacCallbackResults[type] = result;
@@ -249,7 +246,7 @@ export async function assertRbacPermission(_izContext, { rbacResults, originalRe
249
246
  }
250
247
 
251
248
  if (!isAllowed) {
252
- errorsFound.push('Permission denied');
249
+ foundErrors.push('Permission denied');
253
250
  }
254
251
 
255
252
  _izContext.logger.debug(
@@ -257,13 +254,13 @@ export async function assertRbacPermission(_izContext, { rbacResults, originalRe
257
254
  {
258
255
  rbacCallbackResults,
259
256
  isAllowed,
260
- errorsFound
257
+ foundErrors
261
258
  }
262
259
  );
263
260
 
264
- if (hasError || errorsFound.length > 0) {
261
+ if (hasError || foundErrors.length > 0) {
265
262
  const errorResult = {
266
- errorsFound,
263
+ foundErrors,
267
264
  status: 'rejected',
268
265
  requestParams: originalRequestParams
269
266
  };
@@ -325,13 +322,13 @@ export async function resolveObjectSchemas(_izContext, objectType) {
325
322
  * @param {Object} requestParams - Request parameters
326
323
  * @param {Object} objectSchema - Object schema
327
324
  * @param {Object} versionedDataIds - Versioned data IDs map
328
- * @param {Array<string>} errorsFound - Array to collect validation errors
325
+ * @param {Array<string>} foundErrors - Array to collect validation errors
329
326
  */
330
327
  export function validateVersionedDataIds(
331
328
  requestParams,
332
329
  objectSchema,
333
330
  versionedDataIds,
334
- errorsFound
331
+ foundErrors
335
332
  ) {
336
333
  const versionedDataIdsKeys = Object.keys(versionedDataIds || {});
337
334
  if (versionedDataIdsKeys.length === 0) {
@@ -367,17 +364,17 @@ export function validateVersionedDataIds(
367
364
  );
368
365
 
369
366
  if (missingVersionedDataIdLabels.length > 0) {
370
- errorsFound.push(
367
+ foundErrors.push(
371
368
  `missing versionedDataIds of versionedDataLabel '${missingVersionedDataIdLabels.join(', ')}'`
372
369
  );
373
370
  }
374
371
  if (missingDataVersionedDataLabels.length > 0) {
375
- errorsFound.push(
372
+ foundErrors.push(
376
373
  `missing data of versionedDataLabels '${missingDataVersionedDataLabels.join(', ')}'`
377
374
  );
378
375
  }
379
376
  if (Object.keys(updateMainNodeData).length > 0) {
380
- errorsFound.push('cannot update mainNode if have versionedDataIds');
377
+ foundErrors.push('cannot update mainNode if have versionedDataIds');
381
378
  }
382
379
  }
383
380
 
@@ -601,7 +598,7 @@ export async function handleUpdateError(
601
598
  fields,
602
599
  versionedDataIds,
603
600
  callingFlowConfig,
604
- errorsFound
601
+ foundErrors
605
602
  }
606
603
  ) {
607
604
  const updateNodeCompleteMessage =
@@ -612,7 +609,7 @@ export async function handleUpdateError(
612
609
  objInstanceFull: { identifiers, fields },
613
610
  versionedDataIds,
614
611
  status: 'error',
615
- errorsFound
612
+ foundErrors
616
613
  }
617
614
  );
618
615
 
@@ -674,15 +671,15 @@ export async function publishCompletionMessage(_izContext, message, messageAttri
674
671
  * @param {Object} _izContext - Context object with logger
675
672
  * @param {Object} requestParams - { objectType, objInstanceFull, versionedDataIds, additionalParams }
676
673
  * @param {Object} callingFlowConfig - Calling flow configuration
677
- * @param {Array<string>} errorsFound - Array of preceding errors
674
+ * @param {Array<string>} foundErrors - Array of preceding errors
678
675
  * @param {Object} phaseResults - Results from preceding phases
679
- * @returns {Promise<Object>} Result with objType, objInstanceFull, versionedDataIds, status, errorsFound
676
+ * @returns {Promise<Object>} Result with objType, objInstanceFull, versionedDataIds, status, foundErrors
680
677
  */
681
678
  export async function <%- flowTag %>LogicalLib(
682
679
  _izContext,
683
680
  requestParams,
684
681
  callingFlowConfig = {},
685
- errorsFound = [],
682
+ foundErrors = [],
686
683
  phaseResults = {}
687
684
  ) {
688
685
  try {
@@ -728,21 +725,21 @@ export async function <%- flowTag %>LogicalLib(
728
725
  requestParams,
729
726
  objectSchema,
730
727
  versionedDataIds,
731
- errorsFound
728
+ foundErrors
732
729
  );
733
730
 
734
731
  //(<validateBeforeUpdate>)
735
732
  //(</validateBeforeUpdate>)
736
733
 
737
734
  // 3. Early exit on errors
738
- if (errorsFound.length > 0) {
735
+ if (foundErrors.length > 0) {
739
736
  return await handleUpdateError(_izContext, {
740
737
  objType,
741
738
  identifiers,
742
739
  fields,
743
740
  versionedDataIds,
744
741
  callingFlowConfig,
745
- errorsFound
742
+ foundErrors
746
743
  });
747
744
  }
748
745
 
@@ -885,11 +882,11 @@ export async function <%- flowTag %>LogicalLib(
885
882
  }
886
883
  );
887
884
  if (
888
- hookResult?.errorsFound?.length > 0 ||
885
+ hookResult?.foundErrors?.length > 0 ||
889
886
  hookResult?.status === 'error'
890
887
  ) {
891
- errorsFound.push(
892
- ...(hookResult.errorsFound || ['Hook <%= hook.flowTag %> failed'])
888
+ foundErrors.push(
889
+ ...(hookResult.foundErrors || ['Hook <%= hook.flowTag %> failed'])
893
890
  );
894
891
  }
895
892
  } catch (hookErr) {
@@ -897,7 +894,7 @@ export async function <%- flowTag %>LogicalLib(
897
894
  '[<%- flowTag %>LogicalLib] Sync hook <%= hook.flowTag %> error:',
898
895
  hookErr
899
896
  );
900
- errorsFound.push(hookErr.message || 'Hook <%= hook.flowTag %> failed');
897
+ foundErrors.push(hookErr.message || 'Hook <%= hook.flowTag %> failed');
901
898
  }
902
899
  <%_ if (hook.targetObjectTypes && hook.targetObjectTypes.length > 0) { _%>
903
900
  }
@@ -946,7 +943,7 @@ export async function <%- flowTag %>LogicalLib(
946
943
  targetIdentifiers: requestParams.targetIdentifiers,
947
944
  parentFlowId: requestParams.parentFlowId,
948
945
  status: 'complete',
949
- errorsFound
946
+ foundErrors
950
947
  }
951
948
  }
952
949
  )
@@ -976,7 +973,7 @@ export async function <%- flowTag %>LogicalLib(
976
973
  }
977
974
 
978
975
  let resultStatus = 'complete';
979
- if (errorsFound.length > 0) {
976
+ if (foundErrors.length > 0) {
980
977
  resultStatus = 'error';
981
978
  }
982
979
 
@@ -987,7 +984,7 @@ export async function <%- flowTag %>LogicalLib(
987
984
  versionedDataIds
988
985
  },
989
986
  status: resultStatus,
990
- errorsFound
987
+ foundErrors
991
988
  };
992
989
  } catch (err) {
993
990
  _izContext.logger.error(`[${process.env.iz_serviceTag}:<%- flowTag %>LogicalLib] error:`, err);
@@ -63,7 +63,7 @@ export default async function <%- functionName %>(
63
63
  _izContext,
64
64
  rbacPendingStepId,
65
65
  currentAwaitingStepId,
66
- requestParams.errorsFound,
66
+ requestParams.foundErrors,
67
67
  {
68
68
  returnValue: requestParams.returnValue,
69
69
  rbacType
@@ -80,7 +80,7 @@ export default async function <%- functionName %>(
80
80
  const {
81
81
  isComplete,
82
82
  collectedReturnValueByAwaitingStepId,
83
- collectedErrors: errorsFound = [],
83
+ collectedErrors: foundErrors = [],
84
84
  additionalAttributes
85
85
  } = rbacAwaitingStepsResult;
86
86
 
@@ -129,7 +129,7 @@ export default async function <%- functionName %>(
129
129
  const rbacCallbackResults = {};
130
130
  const hasError = Object.entries(rbacResults).some(([type, result]) => {
131
131
  if (result && result.error) {
132
- errorsFound.push(result.error);
132
+ foundErrors.push(result.error);
133
133
  return true;
134
134
  }
135
135
  rbacCallbackResults[type] = result;
@@ -141,7 +141,7 @@ export default async function <%- functionName %>(
141
141
  );
142
142
 
143
143
  if (!isAllowed) {
144
- errorsFound.push('Permission denied');
144
+ foundErrors.push('Permission denied');
145
145
  }
146
146
 
147
147
  _izContext.logger.debug(
@@ -149,13 +149,13 @@ export default async function <%- functionName %>(
149
149
  {
150
150
  rbacCallbackResults,
151
151
  isAllowed,
152
- errorsFound
152
+ foundErrors
153
153
  }
154
154
  );
155
155
 
156
- if (hasError || errorsFound.length > 0) {
156
+ if (hasError || foundErrors.length > 0) {
157
157
  const errorResult = {
158
- errorsFound,
158
+ foundErrors,
159
159
  status: 'rejected',
160
160
  requestParams: originalRequestParams
161
161
  };
@@ -28,12 +28,12 @@ middleware.setValidatorSchema(recordHandlerSharedLib.baseValidatorSchema());
28
28
  // set schema for record.body.Message
29
29
  let perRecordsValidatorSchema = {
30
30
  type: 'object',
31
- required: ['returnMessage', 'errorsFound', 'passStatus'],
31
+ required: ['returnMessage', 'foundErrors', 'passStatus'],
32
32
  properties: {
33
33
  returnMessage: {
34
34
  type: 'object'
35
35
  },
36
- errorsFound: {
36
+ foundErrors: {
37
37
  type: 'array'
38
38
  },
39
39
  passStatus: {
@@ -83,7 +83,7 @@ export const main = middleware.wrap(async (event, context) => {
83
83
 
84
84
  // add argument (to invoke lambda) to passOnProperties[]
85
85
  passOnProperties.push(record.body.Message.returnMessage);
86
- passOnProperties.push(record.body.Message.errorsFound);
86
+ passOnProperties.push(record.body.Message.foundErrors);
87
87
  passOnProperties.push(record.body.Message.passStatus);
88
88
  //(<additionalProperties>)
89
89
  //(</additionalProperties>)
@@ -30,7 +30,7 @@ import { getNestObject } from '../../../libs/source/GenerateCodeLibs.js';
30
30
  * @param {Logger} _izContext.logger - property of _izContext
31
31
  * @param {Logger} _izContext.logger - property of _izContext
32
32
  * @param {Object} returnMessage - limitValue or limitFound
33
- * @param {Array} errorsFound - array
33
+ * @param {Array} foundErrors - array
34
34
  * @param {boolean} passStatus - true || false
35
35
  * @param {Object} passBackProperties - identifier
36
36
 
@@ -41,7 +41,7 @@ import { getNestObject } from '../../../libs/source/GenerateCodeLibs.js';
41
41
  export default async function confirmNewReserved(
42
42
  _izContext,
43
43
  returnMessage,
44
- errorsFound,
44
+ foundErrors,
45
45
  passStatus,
46
46
  //(<additionalProperties>)
47
47
  //(</additionalProperties>)
@@ -51,7 +51,7 @@ export default async function confirmNewReserved(
51
51
  _izContext.logger.debug('----- confirmNewReserved event params', {
52
52
  _izContext: _izContext,
53
53
  returnMessage: returnMessage,
54
- errorsFound: errorsFound,
54
+ foundErrors: foundErrors,
55
55
  passStatus: passStatus,
56
56
  passBackProperties: passBackProperties
57
57
  });
@@ -28,12 +28,12 @@ middleware.setValidatorSchema(recordHandlerSharedLib.baseValidatorSchema());
28
28
  // set schema for record.body.Message
29
29
  let perRecordsValidatorSchema = {
30
30
  type: 'object',
31
- required: ['returnMessage', 'errorsFound', 'passStatus'],
31
+ required: ['returnMessage', 'foundErrors', 'passStatus'],
32
32
  properties: {
33
33
  returnMessage: {
34
34
  type: 'object'
35
35
  },
36
- errorsFound: {
36
+ foundErrors: {
37
37
  type: 'array'
38
38
  },
39
39
  passStatus: {
@@ -83,7 +83,7 @@ export const main = middleware.wrap(async (event, context) => {
83
83
 
84
84
  // add argument (to invoke lambda) to passOnProperties[]
85
85
  passOnProperties.push(record.body.Message.returnMessage);
86
- passOnProperties.push(record.body.Message.errorsFound);
86
+ passOnProperties.push(record.body.Message.foundErrors);
87
87
  passOnProperties.push(record.body.Message.passStatus);
88
88
  //(<additionalProperties>)
89
89
  //(</additionalProperties>)
@@ -51,7 +51,7 @@ const { createFlowTypeConcat } = utils;
51
51
  * @param {Logger} _izContext.logger - property of _izContext
52
52
  * @param {Logger} _izContext.logger - property of _izContext
53
53
  * @param {Object} returnMessage - limitValue or limitFound
54
- * @param {Array} errorsFound - array
54
+ * @param {Array} foundErrors - array
55
55
  * @param {boolean} passStatus - true || false
56
56
  * @param {Object} passBackProperties - identifier
57
57
  *
@@ -61,7 +61,7 @@ const { createFlowTypeConcat } = utils;
61
61
  export default async function createPreSignUrl(
62
62
  _izContext,
63
63
  returnMessage,
64
- errorsFound,
64
+ foundErrors,
65
65
  passStatus,
66
66
  //(<additionalProperties>)
67
67
  //(</additionalProperties>)
@@ -70,7 +70,7 @@ export default async function createPreSignUrl(
70
70
  try {
71
71
  _izContext.logger.debug('----- createPreSignUrl event params -----', {
72
72
  returnMessage: returnMessage,
73
- errorsFound: errorsFound,
73
+ foundErrors: foundErrors,
74
74
  passStatus: passStatus,
75
75
  passBackProperties: passBackProperties
76
76
  });
@@ -122,7 +122,7 @@ export default async function createPreSignUrl(
122
122
 
123
123
  _izContext.logger.debug('reserved has reach limit');
124
124
 
125
- errorsFound.push('reserved has reach limit');
125
+ foundErrors.push('reserved has reach limit');
126
126
  // update status
127
127
  let updateStatusField = {
128
128
  objInstanceFull: {
@@ -149,19 +149,39 @@ function _createUserRbacFlow(flowTag, serviceTag, objectType) {
149
149
  return {
150
150
  flowTag,
151
151
  objType: { serviceTag, objectType },
152
- event: ['ownTopic'],
153
- initiateBy: 'systemNoUser',
152
+ event: ['lambdaSyncInv', 'lambdaSyncApi'],
153
+ initiateBy: 'systemWithUser',
154
154
  handleObj: 'one',
155
155
  statusType: 'none',
156
- outputTopic: true,
156
+ stepProperties: {
157
+ parentFlowId: {
158
+ propertyName: 'parentFlowId',
159
+ type: 'string'
160
+ },
161
+ flowTypeConcat: {
162
+ propertyName: 'flowTypeConcat',
163
+ type: 'string'
164
+ },
165
+ parameterGroups: {
166
+ propertyName: 'parameterGroups',
167
+ type: 'object'
168
+ }
169
+ },
157
170
  stepMessageAttributes: {
158
- userId: { propertyName: 'x-correlation-base-user-id', type: 'string' },
159
- correlationId: { propertyName: 'x-correlation-id', type: 'string' }
171
+ submittedByUserId: {
172
+ propertyName: 'x-correlation-submitted-by-user-id',
173
+ type: 'string'
174
+ }
160
175
  },
161
176
  flowSteps: [
162
177
  {
163
178
  stepName: 'Start',
164
- messageAttributes: ['userId', 'correlationId']
179
+ properties: [
180
+ { key: 'parentFlowId', required: false },
181
+ { key: 'flowTypeConcat', required: true },
182
+ { key: 'parameterGroups', default: {} }
183
+ ],
184
+ messageAttributes: [{ key: 'submittedByUserId', required: false }]
165
185
  }
166
186
  ]
167
187
  };
@@ -13,6 +13,7 @@ const FLOW_RBAC_YAML_PATH = 'app/sls_yaml/generatedCode/source/flow-rbac.yml';
13
13
  const FLOW_LIMITS_YAML_PATH = 'app/sls_yaml/generatedCode/source/flow-limits.yml';
14
14
  const CRUD_TEMPLATE_URL = new URL('../crud/templates/', import.meta.url);
15
15
  const RBAC_TEMPLATE_URL = new URL('./templates/', import.meta.url);
16
+ const SHARED_TEMPLATE_URL = new URL('../shared/templates/', import.meta.url);
16
17
 
17
18
  export async function emitRbacApplicationArtifacts(objects) {
18
19
  if (!Array.isArray(objects)) {
@@ -146,9 +147,8 @@ const STATIC_RBAC_APPLICATION_PATHS = [
146
147
  'app/src/generatedCode/FlowRbac/GetMyPermissions/source/GetMyPermissions_HdrSqs.js',
147
148
  'app/src/generatedCode/FlowRbac/GetMyPermissions/source/GetMyPermissions_HdrApi.js',
148
149
  'app/src/generatedCode/FlowRbac/ValidatorRbac/source/ValidatorRbac_Main.js',
149
- 'app/src/generatedCode/FlowRbac/ValidatorRbac/source/ValidatorRbac_HdrSqs.js',
150
- 'app/src/generatedCode/FlowRbac/ValidatorRbac/source/ValidatorRbac_WbsMain.js',
151
- 'app/src/generatedCode/FlowRbac/ValidatorRbac/source/ValidatorRbac_HdrWbs.js',
150
+ 'app/src/generatedCode/FlowRbac/ValidatorRbac/source/ValidatorRbac_HdrInv.js',
151
+ 'app/src/generatedCode/FlowRbac/ValidatorRbac/source/ValidatorRbac_HdrApi.js',
152
152
  ...LIST_DEFINITIONS.flatMap(({ flowTag }) => [
153
153
  `app/src/generatedCode/FlowRbac/${flowTag}/source/${flowTag}_Main.js`,
154
154
  `app/src/generatedCode/FlowRbac/${flowTag}/source/${flowTag}_HdrSqs.js`,
@@ -189,7 +189,8 @@ export function rbacApplicationManagedPaths(objects = []) {
189
189
  const sourcePath = `app/src/generatedCode/FlowRbac/${flowTag}/source`;
190
190
  return [
191
191
  `${sourcePath}/${flowTag}_Main.js`,
192
- `${sourcePath}/${flowTag}_HdrSqs.js`
192
+ `${sourcePath}/${flowTag}_HdrInv.js`,
193
+ `${sourcePath}/${flowTag}_HdrApi.js`
193
194
  ];
194
195
  });
195
196
  return [
@@ -469,6 +470,19 @@ async function createUserRbacFlowHandler(flowTagOrObject) {
469
470
  : rbacFlowTag(flowTagOrObject);
470
471
  const sourcePath = `app/src/generatedCode/FlowRbac/${flowTag}/source`;
471
472
  const handlerPath = `src/generatedCode/FlowRbac/${flowTag}/source`;
473
+ const shared = {
474
+ flowTag,
475
+ flowStepName: '',
476
+ mainFileName: `${flowTag}_Main`,
477
+ functionName: flowTag,
478
+ startConfig: {
479
+ properties: [
480
+ { propertyName: 'parentFlowId', type: 'string', required: false },
481
+ { propertyName: 'flowTypeConcat', type: 'string', required: true },
482
+ { propertyName: 'parameterGroups', type: 'object', default: {} }
483
+ ]
484
+ }
485
+ };
472
486
  return {
473
487
  artifacts: [
474
488
  {
@@ -476,20 +490,29 @@ async function createUserRbacFlowHandler(flowTagOrObject) {
476
490
  content: await renderRbacTemplate('UserRbacFlow_Main.ejs', { flowTag })
477
491
  },
478
492
  {
479
- path: `${sourcePath}/${flowTag}_HdrSqs.js`,
480
- content: await renderRbacTemplate('UserRbacFlow_HdrSqs.ejs', {
481
- flowTag
482
- })
493
+ path: `${sourcePath}/${flowTag}_HdrInv.js`,
494
+ content: await renderSharedTemplate('FlowHandler_HdrInv.ejs', shared)
495
+ },
496
+ {
497
+ path: `${sourcePath}/${flowTag}_HdrApi.js`,
498
+ content: await renderSharedTemplate('FlowHandler_HdrApi.ejs', shared)
483
499
  }
484
500
  ],
485
501
  functions: [
486
502
  {
487
- type: 'sqs',
488
- functionName: `${flowTag}HdrSqs`,
489
- handlerPath: `${handlerPath}/${flowTag}_HdrSqs.main`,
503
+ type: 'inv',
504
+ functionName: `${flowTag}HdrInv`,
505
+ handlerPath: `${handlerPath}/${flowTag}_HdrInv.main`,
490
506
  roleName: 'FlowRbacRole',
491
- queueName: `${flowTag}HdrSqs`,
492
- flowTag: flowTag,
507
+ flowTag,
508
+ flowStepName: ''
509
+ },
510
+ {
511
+ type: 'api',
512
+ functionName: `${flowTag}HdrApi`,
513
+ handlerPath: `${handlerPath}/${flowTag}_HdrApi.main`,
514
+ roleName: 'FlowRbacRole',
515
+ flowTag,
493
516
  flowStepName: ''
494
517
  }
495
518
  ]
@@ -548,6 +571,10 @@ function renderRbacTemplate(templateName, data = {}) {
548
571
  return renderTemplate(RBAC_TEMPLATE_URL, templateName, data);
549
572
  }
550
573
 
574
+ function renderSharedTemplate(templateName, data = {}) {
575
+ return renderTemplate(SHARED_TEMPLATE_URL, templateName, data);
576
+ }
577
+
551
578
  async function renderTemplate(templateUrl, templateName, data) {
552
579
  return ejsLib.render(
553
580
  await readFile(new URL(templateName, templateUrl), 'utf8'),