@izara_project/izara-core-generate-service-code 1.0.67 → 1.0.68

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 (86) hide show
  1. package/.prettierrc +11 -0
  2. package/package.json +16 -12
  3. package/scripts/format-ejs.js +105 -0
  4. package/src/compile/compileProject.js +16 -1
  5. package/src/compile/loadSchemas.js +89 -4
  6. package/src/emit/crud/emitDynamicCrudFlowSchemas.js +1 -2
  7. package/src/emit/crud/templates/CreateEndpoint_Main.ejs +296 -105
  8. package/src/emit/crud/templates/DeleteEndpoint_Main.ejs +222 -144
  9. package/src/emit/crud/templates/FlowEndpointBeforeLogical_Main.ejs +22 -6
  10. package/src/emit/crud/templates/FlowEndpointComplete_Main.ejs +134 -43
  11. package/src/emit/crud/templates/FlowEndpoint_HdrWbs.ejs +51 -31
  12. package/src/emit/crud/templates/FlowHandler_HdrApi.ejs +53 -45
  13. package/src/emit/crud/templates/FlowHandler_HdrInv.ejs +28 -26
  14. package/src/emit/crud/templates/FlowHandler_HdrSqs.ejs +15 -11
  15. package/src/emit/crud/templates/FlowMain_Wbs.ejs +53 -38
  16. package/src/emit/crud/templates/GetEndpoint_Main.ejs +5 -2
  17. package/src/emit/crud/templates/GetRangeEndpoint_Main.ejs +2 -2
  18. package/src/emit/crud/templates/UpdateEndpoint_Main.ejs +402 -249
  19. package/src/emit/custom/customFlows.js +51 -21
  20. package/src/emit/custom/emitCustomFlowApplicationArtifacts.js +13 -18
  21. package/src/emit/custom/templates/FlowEndpoint_Main.ejs +48 -36
  22. package/src/emit/custom/templates/FlowStep_Main.ejs +7 -9
  23. package/src/emit/custom/templates/s3/ConfirmReserved_HdrSqs.ejs +59 -54
  24. package/src/emit/custom/templates/s3/ConfirmReserved_Main.ejs +33 -23
  25. package/src/emit/custom/templates/s3/CreateObject_HdrWbs.ejs +30 -23
  26. package/src/emit/custom/templates/s3/CreateObject_Main.ejs +56 -39
  27. package/src/emit/custom/templates/s3/CreatePreSignUrl_HdrSqs.ejs +56 -51
  28. package/src/emit/custom/templates/s3/CreatePreSignUrl_Main.ejs +112 -75
  29. package/src/emit/custom/templates/s3/FlowHandler_HdrS3.ejs +12 -7
  30. package/src/emit/custom/templates/s3/ProcessS3File_Main.ejs +11 -8
  31. package/src/emit/custom/templates/s3/ReservedLimit_HdrSqs.ejs +64 -55
  32. package/src/emit/custom/templates/s3/ReservedLimit_Main.ejs +74 -52
  33. package/src/emit/custom/templates/triggerCache/CheckTriggerCache_HdrSqs.ejs +58 -14
  34. package/src/emit/custom/templates/triggerCache/CheckTriggerCache_Main.ejs +12 -17
  35. package/src/emit/custom/templates/triggerCache/TriggerCacheComplete_Main.ejs +20 -13
  36. package/src/emit/custom/templates/triggerCache/TriggerCache_Main.ejs +4 -1
  37. package/src/emit/function/functionYamlArtifact.js +20 -0
  38. package/src/emit/rbac/emitDynamicRbacFlowSchemas.js +28 -15
  39. package/src/emit/rbac/emitRbacApplicationArtifacts.js +168 -69
  40. package/src/emit/rbac/templates/CreateTargetRole_HdrSqs.ejs +41 -18
  41. package/src/emit/rbac/templates/CreateTargetRole_Main.ejs +23 -3
  42. package/src/emit/rbac/templates/ListRbac_HdrApi.ejs +27 -5
  43. package/src/emit/rbac/templates/ListRbac_HdrSqs.ejs +41 -8
  44. package/src/emit/rbac/templates/ListRbac_Main.ejs +26 -6
  45. package/src/emit/rbac/templates/RbacMutation_Main.ejs +23 -3
  46. package/src/emit/rbac/templates/UserRbacFlow_HdrSqs.ejs +46 -0
  47. package/src/emit/rbac/templates/UserRbacFlow_Main.ejs +152 -33
  48. package/src/emit/rbac/templates/UserRoleMutation_Main.ejs +24 -4
  49. package/src/emit/relationship/emitDynamicRelationshipFlowSchemas.js +1 -2
  50. package/src/emit/relationship/templates/ChangeRelationshipComplete_Main.ejs +64 -37
  51. package/src/emit/relationship/templates/ChangeRelationship_Main.ejs +258 -142
  52. package/src/emit/relationship/templates/CreateRelationshipComplete_Main.ejs +68 -43
  53. package/src/emit/relationship/templates/CreateRelationship_Main.ejs +315 -171
  54. package/src/emit/relationship/templates/DeleteRelationshipComplete_Main.ejs +67 -41
  55. package/src/emit/relationship/templates/DeleteRelationship_Main.ejs +226 -115
  56. package/src/emit/relationship/templates/FlowHandler_HdrApi.ejs +41 -33
  57. package/src/emit/relationship/templates/FlowHandler_HdrDsq.ejs +15 -11
  58. package/src/emit/relationship/templates/FlowHandler_HdrInv.ejs +28 -26
  59. package/src/emit/relationship/templates/FlowHandler_HdrSqs.ejs +15 -11
  60. package/src/emit/relationship/templates/GetRelationshipComplete_Main.ejs +46 -26
  61. package/src/emit/relationship/templates/GetRelationship_Main.ejs +233 -126
  62. package/src/emit/relationship/templates/MoveRelationshipComplete_Main.ejs +72 -44
  63. package/src/emit/relationship/templates/MoveRelationship_Main.ejs +266 -150
  64. package/src/emit/relationship/templates/UpdateRelationshipComplete_Main.ejs +74 -45
  65. package/src/emit/relationship/templates/UpdateRelationship_Main.ejs +285 -152
  66. package/src/emit/resource/emitResourceArtifacts.js +107 -11
  67. package/src/emit/resource/templates/DynamoDBTable_Yaml.ejs +18 -18
  68. package/src/emit/resource/templates/FlowOut_Yaml.ejs +5 -5
  69. package/src/emit/resource/templates/GeneratedLambdaRoleServiceConfig.ejs +138 -0
  70. package/src/emit/resource/templates/ResourceBeforeLogicalYaml.ejs +44 -44
  71. package/src/emit/resource/templates/ResourceSqsYaml.ejs +36 -36
  72. package/src/emit/resource/templates/ResourceYaml.ejs +48 -48
  73. package/src/emit/resource/templates/S3Bucket_Yaml.ejs +19 -0
  74. package/src/emit/resource/templates/SharedResource_Yaml.ejs +11 -11
  75. package/src/emit/resource/templates/SystemDynamoDB_Yaml.ejs +105 -105
  76. package/src/generate.js +6 -2
  77. package/test/createTargetRoleHandler.test.js +63 -14
  78. package/test/customFlowApplicationArtifacts.test.js +48 -23
  79. package/test/dynamicCrudFlowSchemas.test.js +6 -6
  80. package/test/dynamicRbacFlowSchemas.test.js +8 -12
  81. package/test/dynamicRelationshipFlowSchemas.test.js +3 -3
  82. package/test/publicApi.test.js +10 -12
  83. package/test/resourceArtifacts.test.js +12 -2
  84. package/docs/test.png +0 -0
  85. package/src/emit/rbac/templates/UserRbacFlow_HdrInv.ejs +0 -10
  86. /package/docs/{test.mmd → TriggeredCacheFlow.mmd} +0 -0
@@ -15,17 +15,27 @@ You should have received a copy of the GNU Affero General Public License
15
15
  along with this program. If not, see <http://www.gnu.org/licenses/>.
16
16
  */
17
17
 
18
- import { objectHash as hash, identifierUuid } from '@izara_project/izara-shared-core';
18
+ import {
19
+ objectHash as hash,
20
+ identifierUuid
21
+ } from '@izara_project/izara-shared-core';
19
22
  import { consts as coreConsts } from '@izara_project/izara-core-library-core';
20
23
  import { consts as middlewareConsts } from '@izara_project/izara-middleware';
21
- import { sns, lambda } from '@izara_project/izara-core-library-external-request';
24
+ import {
25
+ sns,
26
+ lambda
27
+ } from '@izara_project/izara-core-library-external-request';
22
28
  import dynamodbSharedLib from '@izara_project/izara-core-library-dynamodb';
23
29
  import snsSharedLib from '@izara_project/izara-core-library-sns';
24
30
  import asyncFlowSharedLib from '@izara_project/izara-core-library-asynchronous-flow';
25
31
  import callingFlowSharedLib from '@izara_project/izara-core-library-calling-flow';
26
32
  import lambdaSharedLib from '@izara_project/izara-core-library-lambda';
27
33
  import {
28
- consts, getObjectSchema, dataDetailsLib, identifiersObject, utils
34
+ consts,
35
+ getObjectSchema,
36
+ dataDetailsLib,
37
+ identifiersObject,
38
+ utils
29
39
  } from '@izara_project/izara-core-library-service-schemas';
30
40
 
31
41
  const { createObjType } = utils;
@@ -53,7 +63,11 @@ export async function <%- flowTag %>MainLogical(
53
63
  beforeLogicalResults = {}
54
64
  ) {
55
65
  try {
56
- _izContext.logger.debug('[<%- flowTag %>MainLogical] started', { requestParams, callingFlowConfig, beforeLogicalResults });
66
+ _izContext.logger.debug('[<%- flowTag %>MainLogical] started', {
67
+ requestParams,
68
+ callingFlowConfig,
69
+ beforeLogicalResults
70
+ });
57
71
 
58
72
  //(<beforeDeleteMainLogical>)
59
73
  //(</beforeDeleteMainLogical>)
@@ -61,11 +75,17 @@ export async function <%- flowTag %>MainLogical(
61
75
  const objType = createObjType(requestParams.objectType);
62
76
 
63
77
  // ── Load schema ───────────────────────────────────────────────────────────
64
- const objectSchema = await getObjectSchema.getObjSchemaS3WithHierarchy(_izContext, objType);
78
+ const objectSchema = await getObjectSchema.getObjSchemaS3WithHierarchy(
79
+ _izContext,
80
+ objType
81
+ );
65
82
  _izContext.logger.debug('objectSchema', objectSchema);
66
83
 
67
84
  // ── Build deleteDataDetails ───────────────────────────────────────────────
68
- const deleteDataDetails = await createDeleteDataDetail(_izContext, objectSchema);
85
+ const deleteDataDetails = await createDeleteDataDetail(
86
+ _izContext,
87
+ objectSchema
88
+ );
69
89
  _izContext.logger.debug('deleteDataDetails', deleteDataDetails);
70
90
 
71
91
  if (objectSchema.canDelete === false || objectSchema.canDelete == null) {
@@ -74,25 +94,44 @@ export async function <%- flowTag %>MainLogical(
74
94
 
75
95
  // ── Early exit on errors ──────────────────────────────────────────────────
76
96
  if (errorsFound.length) {
77
- const deleteNodeCompleteMessage = callingFlowSharedLib.addPassBackPropertiesToSnsResponseMessageObject(
78
- callingFlowConfig,
79
- { objType, identifiers: requestParams.identifiers, status: 'error', errorsFound }
80
- );
97
+ const deleteNodeCompleteMessage =
98
+ callingFlowSharedLib.addPassBackPropertiesToSnsResponseMessageObject(
99
+ callingFlowConfig,
100
+ {
101
+ objType,
102
+ identifiers: requestParams.identifiers,
103
+ status: 'error',
104
+ errorsFound
105
+ }
106
+ );
81
107
 
82
- _izContext.logger.debug('messageParams OutDeleteNodeComplete::', deleteNodeCompleteMessage);
108
+ _izContext.logger.debug(
109
+ 'messageParams OutDeleteNodeComplete::',
110
+ deleteNodeCompleteMessage
111
+ );
83
112
  await sns.publishAsync(_izContext, {
84
- Message: JSON.stringify(deleteNodeCompleteMessage),
85
- TopicArn: await snsSharedLib.snsTopicArnByFlowSchema(_izContext, TOPIC_NAME_GENERATE_CODE.outDeleteNodeComplete)
113
+ Message: JSON.stringify(deleteNodeCompleteMessage),
114
+ TopicArn: snsSharedLib.snsTopicArnByFlowSchema(
115
+ _izContext,
116
+ TOPIC_NAME_GENERATE_CODE.outDeleteNodeComplete
117
+ )
86
118
  });
87
119
 
88
- return { objType, identifiers: requestParams.identifiers, status: 'error', errorsFound };
120
+ return {
121
+ objType,
122
+ identifiers: requestParams.identifiers,
123
+ status: 'error',
124
+ errorsFound
125
+ };
89
126
  }
90
127
 
91
128
  //(<validateBeforeDelete>)
92
129
  //(</validateBeforeDelete>)
93
130
 
94
131
  // ── Process storage resources ─────────────────────────────────────────────
95
- for (const [storageTag, deleteDataDetail] of Object.entries(deleteDataDetails)) {
132
+ for (const [storageTag, deleteDataDetail] of Object.entries(
133
+ deleteDataDetails
134
+ )) {
96
135
  //(<beforeDelete>)
97
136
  //(</beforeDelete>)
98
137
 
@@ -101,14 +140,25 @@ export async function <%- flowTag %>MainLogical(
101
140
  //(</beforeDeleteRecordDynamo>)
102
141
  _izContext.logger.debug('::::::DynamoDB::::::', { storageTag });
103
142
 
104
- const identifiersForDeleteData = await dynamoDbIdentifiersByStorageResource(
105
- _izContext, objectSchema, deleteDataDetail, requestParams.identifiers
143
+ const identifiersForDeleteData =
144
+ await dynamoDbIdentifiersByStorageResource(
145
+ _izContext,
146
+ objectSchema,
147
+ deleteDataDetail,
148
+ requestParams.identifiers
149
+ );
150
+ _izContext.logger.debug(
151
+ 'identifiersForDeleteData',
152
+ identifiersForDeleteData
106
153
  );
107
- _izContext.logger.debug('identifiersForDeleteData', identifiersForDeleteData);
108
154
 
109
155
  await dynamodbSharedLib.deleteItem(
110
156
  _izContext,
111
- await dynamodbSharedLib.tableName(_izContext, deleteDataDetail.tableName, deleteDataDetail.serviceTag),
157
+ await dynamodbSharedLib.tableName(
158
+ _izContext,
159
+ deleteDataDetail.tableName,
160
+ deleteDataDetail.serviceTag
161
+ ),
112
162
  identifiersForDeleteData
113
163
  );
114
164
 
@@ -118,25 +168,43 @@ export async function <%- flowTag %>MainLogical(
118
168
  }
119
169
 
120
170
  // ── Complete ──────────────────────────────────────────────────────────────
121
- const outMessage = callingFlowSharedLib.addPassBackPropertiesToSnsResponseMessageObject(
122
- callingFlowConfig,
123
- { objType, identifiers: requestParams.identifiers, status: 'complete', errorsFound }
124
- );
171
+ const outMessage =
172
+ callingFlowSharedLib.addPassBackPropertiesToSnsResponseMessageObject(
173
+ callingFlowConfig,
174
+ {
175
+ objType,
176
+ identifiers: requestParams.identifiers,
177
+ status: 'complete',
178
+ errorsFound
179
+ }
180
+ );
125
181
 
126
- if (callingFlowConfig[callingFlowSharedLib.consts.CALLINGFLOW_PROPERTYNAME]) {
182
+ if (
183
+ callingFlowConfig[callingFlowSharedLib.consts.CALLINGFLOW_PROPERTYNAME]
184
+ ) {
127
185
  _izContext.logger.debug('HAVE CallingFlow');
128
186
  await sns.publishAsync(_izContext, {
129
- Message: JSON.stringify(outMessage),
187
+ Message: JSON.stringify(outMessage),
130
188
  MessageAttributes: sns.createStringMessageAttributes(
131
189
  _izContext,
132
- callingFlowSharedLib.addCallingFlowToSnsResponseMessageAttributes(callingFlowConfig, {})
190
+ callingFlowSharedLib.addCallingFlowToSnsResponseMessageAttributes(
191
+ callingFlowConfig,
192
+ {}
193
+ )
133
194
  ),
134
- TopicArn: await snsSharedLib.snsTopicArnByFlowSchema(_izContext, TOPIC_NAME_GENERATE_CODE.outDeleteNodeComplete)
195
+ TopicArn: snsSharedLib.snsTopicArnByFlowSchema(
196
+ _izContext,
197
+ TOPIC_NAME_GENERATE_CODE.outDeleteNodeComplete
198
+ )
135
199
  });
136
200
  }
137
201
 
138
- return { objType, identifiers: requestParams.identifiers, status: 'complete', errorsFound };
139
-
202
+ return {
203
+ objType,
204
+ identifiers: requestParams.identifiers,
205
+ status: 'complete',
206
+ errorsFound
207
+ };
140
208
  } catch (err) {
141
209
  throw err;
142
210
  }
@@ -157,7 +225,10 @@ export default async function <%- flowTag %>(
157
225
  //(</additionalParams>)
158
226
  ) {
159
227
  try {
160
- _izContext.logger.debug('[<%- flowTag %>]', { requestParams, callingFlowConfig });
228
+ _izContext.logger.debug('[<%- flowTag %>]', {
229
+ requestParams,
230
+ callingFlowConfig
231
+ });
161
232
 
162
233
  const errorsFound = [];
163
234
  const objType = createObjType(requestParams.objectType);
@@ -166,15 +237,19 @@ export default async function <%- flowTag %>(
166
237
  //(</beforeDelete>)
167
238
 
168
239
  // ── Load schema ───────────────────────────────────────────────────────────
169
- const objectSchema = await getObjectSchema.getObjSchemaS3WithHierarchy(_izContext, objType);
240
+ const objectSchema = await getObjectSchema.getObjSchemaS3WithHierarchy(
241
+ _izContext,
242
+ objType
243
+ );
170
244
  _izContext.logger.debug('objectSchema', objectSchema);
171
245
 
172
246
  // ── Resolve userId / targetId ─────────────────────────────────────────────
173
247
  if (objectSchema.generatedBy === 'userGenerated') {
174
- const userId = _izContext.correlationIds.get(coreConsts.BASE_USER_ID);
248
+ const userId = _izContext.correlationIds.get(coreConsts.BASE_USER_ID);
175
249
  const targetId = _izContext.correlationIds.get(coreConsts.TARGET_ID);
176
250
  if (!userId) errorsFound.push('Not have userId');
177
- if (objectSchema.hasOwnProperty('belongTo') && !targetId) errorsFound.push('not have targetId');
251
+ if (objectSchema.hasOwnProperty('belongTo') && !targetId)
252
+ errorsFound.push('not have targetId');
178
253
  }
179
254
 
180
255
  //(<beforeQuery>)
@@ -184,12 +259,12 @@ export default async function <%- flowTag %>(
184
259
  const identifiers = requestParams.identifiers;
185
260
 
186
261
  if (errorsFound.length > 0)
187
- return await createMainLogical(
188
- _izContext,
189
- requestParams,
190
- callingFlowConfig,
191
- errorsFound
192
- );
262
+ return await createMainLogical(
263
+ _izContext,
264
+ requestParams,
265
+ callingFlowConfig,
266
+ errorsFound
267
+ );
193
268
 
194
269
  // ── beforeLogical phase check ─────────────────────────────────────────────
195
270
  <%_
@@ -203,134 +278,138 @@ export default async function <%- flowTag %>(
203
278
  }, {});
204
279
  _%>
205
280
  <%_ Object.entries(groupedByObjType).forEach(([objectType, configs]) => { _%>
206
- <%_
281
+ <%_
207
282
  const hasOwnTopic = configs.some(c => c.invocationType === 'ownTopic');
208
283
  const hasLambdaSyncInv = configs.some(c => c.invocationType === 'lambdaSyncInv');
209
284
  _%>
210
- if (requestParams.objectType === '<%= objectType %>') {
211
-
212
- <%_ if (hasLambdaSyncInv) { _%>
213
- const lambdaSyncInvResults = await Promise.all([
214
- <%_ configs.filter(c => c.invocationType === 'lambdaSyncInv').forEach((config, index, arr) => { _%>
215
- // lambdaSyncInv <%= config.flowTag %>
216
- lambda.invokeSync(
285
+ if (requestParams.objectType === '<%= objectType %>') {
286
+ <%_ if (hasLambdaSyncInv) { _%>
287
+ const lambdaSyncInvResults = await Promise.all([
288
+ <%_ configs.filter(c => c.invocationType === 'lambdaSyncInv').forEach((config, index, arr) => { _%>
289
+ // lambdaSyncInv <%= config.flowTag %>
290
+ lambda
291
+ .invokeSync(
217
292
  _izContext,
218
293
  await lambdaSharedLib.lambdaFunctionName(
219
294
  _izContext,
220
295
  'Process<%= config.flowTag %>HdrInv'
221
296
  ),
222
297
  { requestParams, callingFlowConfig }
223
- ).then(returnValue => ({ flowTag: '<%= config.flowTag %>', returnValue }))<%= index < arr.length - 1 ? ',' : '' %>
224
- // lambdaSyncInv <%= config.flowTag %>
225
- <%_ }) _%>
226
- ]);
227
- <%_ } _%>
228
-
229
- //(<afterBeforeLogical_<%= objectType %>>)
230
- //(</afterBeforeLogical_<%= objectType %>>)
231
-
232
- <%_ if (hasOwnTopic) { _%>
233
- // ── ownTopic (async — create awaitingSteps and then publish) ──────────
234
- const awaitingMultipleStepIds = [];
235
- const recordMsgs = [];
236
-
237
- <%_ configs.filter(c => c.invocationType === 'ownTopic').forEach(config => { _%>
238
- // ownTopic <%= config.flowTag %>
298
+ )
299
+ .then((returnValue) => ({
300
+ flowTag: '<%= config.flowTag %>',
301
+ returnValue
302
+ })) /*__EJS_COMMA_13__*/
303
+ // lambdaSyncInv <%= config.flowTag %>
304
+ <%_ }) _%>
305
+ ]);
306
+ <%_ } _%>
307
+
308
+ //(<afterBeforeLogical_<%= objectType %>>)
309
+ //(</afterBeforeLogical_<%= objectType %>>)
310
+
311
+ <%_ if (hasOwnTopic) { _%>
312
+ // ── ownTopic (async — create awaitingSteps and then publish) ──────────
313
+ const awaitingMultipleStepIds = [];
314
+ const recordMsgs = [];
315
+
316
+ <%_ configs.filter(c => c.invocationType === 'ownTopic').forEach(config => { _%>
317
+ // ownTopic <%= config.flowTag %>
318
+ awaitingMultipleStepIds.push({
319
+ awaitingStepId: await asyncFlowSharedLib.createAwaitingStepId(
320
+ hash(identifiers),
321
+ '<%= config.codeHookTag %>_<%= objectType %>_<%= config.flowTag.charAt(0).toUpperCase() + config.flowTag.slice(1) %>'
322
+ ),
323
+ additionalAttributes: {}
324
+ });
325
+
326
+ recordMsgs.push({
327
+ msg: callingFlowSharedLib.addCallingFlowToSnsRequestMessageObject(
328
+ requestParams,
329
+ callingFlowSharedLib.addParentCallingFlowConfig(
330
+ callingFlowConfig,
331
+ callingFlowSharedLib.createCallingFlowConfig(
332
+ //(<callingFlowProperties_<%= config.flowTag %>>)
333
+ await lambdaSharedLib.lambdaFunctionName(
334
+ _izContext,
335
+ '<%= config.generatedCodeTag %><%= config.codeHookTag.charAt(0).toUpperCase() + config.codeHookTag.slice(1) %>'
336
+ ),
337
+ {}
338
+ //(</callingFlowProperties_<%= config.flowTag %>>)
339
+ )
340
+ )
341
+ ),
342
+ flowTag: '<%= config.flowTag.charAt(0).toUpperCase() + config.flowTag.slice(1) %>'
343
+ });
344
+ <%_ }) _%>
345
+
346
+ <%_ if (hasLambdaSyncInv) { _%>
347
+ // ── Add lambdaSyncInv results to awaitingSteps ────────────────────────
348
+ for (const syncResult of lambdaSyncInvResults) {
239
349
  awaitingMultipleStepIds.push({
240
350
  awaitingStepId: await asyncFlowSharedLib.createAwaitingStepId(
241
351
  hash(identifiers),
242
- '<%= config.codeHookTag %>_<%= objectType %>_<%= config.flowTag.charAt(0).toUpperCase() + config.flowTag.slice(1) %>'
352
+ '<%= configs[0].codeHookTag %>_<%= objectType %>_' + syncResult.flowTag
243
353
  ),
244
- additionalAttributes: {}
354
+ additionalAttributes: {
355
+ complete: true,
356
+ errorsFound: [],
357
+ returnValue: syncResult.returnValue
358
+ }
245
359
  });
360
+ }
361
+ <%_ } _%>
246
362
 
247
- recordMsgs.push({
248
- msg: callingFlowSharedLib.addCallingFlowToSnsRequestMessageObject(
249
- requestParams,
250
- callingFlowSharedLib.addParentCallingFlowConfig(
251
- callingFlowConfig,
252
- callingFlowSharedLib.createCallingFlowConfig(
253
- //(<callingFlowProperties_<%= config.flowTag %>>)
254
- await lambdaSharedLib.lambdaFunctionName(
255
- _izContext,
256
- '<%= config.generatedCodeTag %><%= config.codeHookTag.charAt(0).toUpperCase() + config.codeHookTag.slice(1) %>'
257
- ),
258
- {}
259
- //(</callingFlowProperties_<%= config.flowTag %>>)
260
- )
261
- )
262
- ),
263
- flowTag: '<%= config.flowTag.charAt(0).toUpperCase() + config.flowTag.slice(1) %>'
264
- });
265
- <%_ }) _%>
363
+ await asyncFlowSharedLib.createAwaitingMultipleSteps(
364
+ _izContext,
365
+ asyncFlowSharedLib.createPendingStepId(
366
+ hash(identifiers),
367
+ 'beforeLogical_<%= objectType %>'
368
+ ),
369
+ awaitingMultipleStepIds
370
+ );
266
371
 
267
- <%_ if (hasLambdaSyncInv) { _%>
268
- // ── Add lambdaSyncInv results to awaitingSteps ────────────────────────
269
- for (const syncResult of lambdaSyncInvResults) {
270
- awaitingMultipleStepIds.push({
271
- awaitingStepId: await asyncFlowSharedLib.createAwaitingStepId(
272
- hash(identifiers),
273
- '<%= configs[0].codeHookTag %>_<%= objectType %>_' + syncResult.flowTag
274
- ),
275
- additionalAttributes: {
276
- complete: true,
277
- errorsFound: [],
278
- returnValue: syncResult.returnValue
279
- }
280
- });
281
- }
282
- <%_ } _%>
372
+ //(<beforePublish_<%= objectType %>>)
373
+ //(</beforePublish_<%= objectType %>>)
283
374
 
284
- await asyncFlowSharedLib.createAwaitingMultipleSteps(
375
+ for (const recordMsg of recordMsgs) {
376
+ const messageAttributes = sns.createStringMessageAttributes(
285
377
  _izContext,
286
- asyncFlowSharedLib.createPendingStepId(
287
- hash(identifiers),
288
- 'beforeLogical_<%= objectType %>'
289
- ),
290
- awaitingMultipleStepIds
378
+ callingFlowSharedLib.addCallingFlowToSnsResponseMessageAttributes(
379
+ callingFlowConfig,
380
+ {}
381
+ )
291
382
  );
292
383
 
293
- //(<beforePublish_<%= objectType %>>)
294
- //(</beforePublish_<%= objectType %>>)
295
-
296
- for (const recordMsg of recordMsgs) {
297
- const messageAttributes = sns.createStringMessageAttributes(
298
- _izContext,
299
- callingFlowSharedLib.addCallingFlowToSnsResponseMessageAttributes(
300
- callingFlowConfig,
301
- {}
302
- )
303
- );
304
-
305
- const topicArn = snsSharedLib.snsTopicArnByFlowSchema(
306
- _izContext,
307
- `${recordMsg.flowTag}_In`
308
- );
384
+ const topicArn = snsSharedLib.snsTopicArnByFlowSchema(
385
+ _izContext,
386
+ `${recordMsg.flowTag}_In`
387
+ );
309
388
 
310
- await sns.publishAsync(_izContext, {
311
- Message: JSON.stringify(recordMsg.msg),
312
- MessageAttributes: messageAttributes,
313
- TopicArn: topicArn
314
- });
315
- }
389
+ await sns.publishAsync(_izContext, {
390
+ Message: JSON.stringify(recordMsg.msg),
391
+ MessageAttributes: messageAttributes,
392
+ TopicArn: topicArn
393
+ });
394
+ }
316
395
 
317
- return 'complete beforeLogical <%= objectType %>';
396
+ return 'complete beforeLogical <%= objectType %>';
318
397
 
319
- <%_ } else { _%>
320
- // ── lambdaSyncInv only — collect results and proceed to deleteMainLogical
321
- const beforeLogicalResults = lambdaSyncInvResults.reduce((acc, r) => {
322
- acc[r.flowTag] = r.returnValue;
323
- return acc;
324
- }, {});
398
+ <%_ } else { _%>
399
+ // ── lambdaSyncInv only — collect results and proceed to deleteMainLogical
400
+ const beforeLogicalResults = lambdaSyncInvResults.reduce((acc, r) => {
401
+ acc[r.flowTag] = r.returnValue;
402
+ return acc;
403
+ }, {});
325
404
 
326
- return await <%- flowTag %>MainLogical(
327
- _izContext,
328
- requestParams,
329
- callingFlowConfig,
330
- beforeLogicalResults
331
- );
332
- <%_ } _%>
333
- }
405
+ return await <%- flowTag %>MainLogical(
406
+ _izContext,
407
+ requestParams,
408
+ callingFlowConfig,
409
+ beforeLogicalResults
410
+ );
411
+ <%_ } _%>
412
+ }
334
413
  <%_ }) _%>
335
414
 
336
415
  //(<beforeDeleteMainLogical>)
@@ -342,7 +421,6 @@ export default async function <%- flowTag %>(
342
421
  requestParams,
343
422
  callingFlowConfig
344
423
  );
345
-
346
424
  } catch (err) {
347
425
  throw err;
348
426
  }
@@ -15,7 +15,10 @@ You should have received a copy of the GNU Affero General Public License
15
15
  along with this program. If not, see <http://www.gnu.org/licenses/>.
16
16
  */
17
17
 
18
- import { objectHash as hash, identifierUuid } from '@izara_project/izara-shared-core';
18
+ import {
19
+ objectHash as hash,
20
+ identifierUuid
21
+ } from '@izara_project/izara-shared-core';
19
22
  import dynamodbSharedLib from '@izara_project/izara-core-library-dynamodb';
20
23
  import asyncFlowSharedLib from '@izara_project/izara-core-library-asynchronous-flow';
21
24
  import {
@@ -57,13 +60,23 @@ export default async function <%- flowTag %>BeforeLogicalMain(
57
60
 
58
61
  // ── Build identifiers ──
59
62
  const objType = createObjType(requestParams.returnRequestParams.objectType);
60
- const objectSchema = await getObjectSchema.getObjSchemaS3WithHierarchy(_izContext, objType);
61
- const objectSchemas = uploadUseCase.generateObjectSchemaForCombineFieldNames(_izContext, objectSchema);
63
+ const objectSchema = await getObjectSchema.getObjSchemaS3WithHierarchy(
64
+ _izContext,
65
+ objType
66
+ );
67
+ const objectSchemas =
68
+ uploadUseCase.generateObjectSchemaForCombineFieldNames(
69
+ _izContext,
70
+ objectSchema
71
+ );
62
72
 
63
73
  const identifiers = {};
64
74
  for (const fieldName of objectSchemas.identifierFieldNames) {
65
- if (requestParams.returnRequestParams.fieldNames?.hasOwnProperty(fieldName)) {
66
- identifiers[fieldName] = requestParams.returnRequestParams.fieldNames[fieldName];
75
+ if (
76
+ requestParams.returnRequestParams.fieldNames?.hasOwnProperty(fieldName)
77
+ ) {
78
+ identifiers[fieldName] =
79
+ requestParams.returnRequestParams.fieldNames[fieldName];
67
80
  }
68
81
  }
69
82
  _izContext.logger.debug('identifiers:::: ', identifiers);
@@ -132,7 +145,10 @@ export default async function <%- flowTag %>BeforeLogicalMain(
132
145
  })
133
146
  );
134
147
 
135
- if (callingFlowConfig.callingFlow === `${process.env.iz_resourcePrefix}CreateBeforeLogical`) {
148
+ if (
149
+ callingFlowConfig.callingFlow ===
150
+ `${process.env.iz_resourcePrefix}CreateBeforeLogical`
151
+ ) {
136
152
  callingFlowConfig =
137
153
  callingFlowConfig.callingFlowProperties.parentPassBackProperties;
138
154
  }