@izara_project/izara-core-generate-service-code 1.0.24 → 1.0.25

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 (16) hide show
  1. package/package.json +1 -1
  2. package/src/generateCode/generateFlowSchema/event/eventBridgeComponent/handler/inv/template.ejs +3 -1
  3. package/src/generateCode/generateFlowSchema/event/extTopicComponent/process/handler/template.ejs +2 -2
  4. package/src/generateCode/generateFlowSchema/event/lambdaSyncApiComponent/handler/template.ejs +1 -3
  5. package/src/generateCode/generateFlowSchema/event/lambdaSyncInvComponent/handler/template.ejs +1 -1
  6. package/src/generateCode/generateFlowSchema/event/ownTopicComponent/endpointComponent/handler/DsqHandlerTemplate.ejs +2 -2
  7. package/src/generateCode/generateFlowSchema/event/ownTopicComponent/endpointComponent/handler/SqsHandlerTemplate.ejs +2 -2
  8. package/src/generateCode/generateFlowSchema/event/s3Component/flowSchemaMainFunction/template.ejs +1 -1
  9. package/src/generateCode/generateFlowSchema/flowSchemaMainFunction/template.ejs +1 -1
  10. package/src/generateCode/generateSchema/actionEndpointCompleteComponent/create/mainFunction/template.ejs +1 -1
  11. package/src/generateCode/generateSchema/actionEndpointCompleteComponent/update/mainFunction/template.ejs +1 -1
  12. package/src/generateCode/generateSchema/actionEndpointComponent/mainFunction/beforeLogical/template.ejs +14 -6
  13. package/src/generateCode/generateSchema/actionEndpointComponent/mainFunction/create/main/template.ejs +21 -3
  14. package/src/generateCode/generateSchema/actionEndpointComponent/mainFunction/delete/main/template.ejs +24 -4
  15. package/src/generateCode/generateSchema/actionEndpointComponent/mainFunction/update/main/template.ejs +25 -4
  16. package/src/generateCode/generateSchema/relationshipPerActionComponent/update/complete/mainFunction/template.ejs +1 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@izara_project/izara-core-generate-service-code",
3
- "version": "1.0.24",
3
+ "version": "1.0.25",
4
4
  "description": "Code for locally generating per service files",
5
5
  "author": "Sven Mason <thebarbariansven@gmail.com>",
6
6
  "license": "AGPL-3.0-or-later",
@@ -41,7 +41,9 @@ export const main = middlewareHandler.wrap(async (event, context) => {
41
41
  return await <%- functionName %> Main(
42
42
  event._izContext, // correlationId/logger/integrationTestDetail/uniqueRequestId
43
43
  event,
44
- callingFlowSharedLib.addCallingFlowToPassOnProperties(event)
44
+ callingFlowSharedLib.addCallingFlowToPassOnProperties(event),
45
+ //(<additionalParams>)
46
+ //(</additionalParams>)
45
47
  );
46
48
 
47
49
  } catch (err) {
@@ -65,10 +65,10 @@ export const main = middleware.wrap(async (event, context) => {
65
65
  );
66
66
 
67
67
  // add argument (to invoke lambda) to passOnProperties[]
68
- passOnProperties.push(record.body.Message)
68
+ passOnProperties.push(record.body.Message);
69
+ passOnProperties.push(callingFlowSharedLib.addCallingFlowToPassOnProperties(record.body.Message));
69
70
  //(<additionalParams>)
70
71
  //(</additionalParams>)
71
- passOnProperties.push(callingFlowSharedLib.addCallingFlowToPassOnProperties(record.body.Message));
72
72
  record._izContext.logger.debug('passOnProperties in handler', passOnProperties);
73
73
 
74
74
  // call recordHandlerSharedLib.recordHandler with 3 parameters and return promise(resolve)
@@ -15,8 +15,6 @@ 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
-
19
-
20
18
  const RBAC_TARGET_ID = process.env.iz_rbacTargetIdUser // iz_rbacTargetIdUser | iz_rbacDeliveryMethodId
21
19
 
22
20
  import { middlewareHandler as middleware } from "@izara_project/izara-middleware";
@@ -66,9 +64,9 @@ export const main = middleware.wrap(async (event, context, callback) => {
66
64
  let lambdaFunctionResponse = await <%- functionName %>.<%- functionName %>(
67
65
  event._izContext, // correlationId/logger/integrationTestDetail/uniqueRequestId/userId
68
66
  event.body,
67
+ callingFlowSharedLib.addCallingFlowToPassOnProperties(event)
69
68
  //(<additionalParams>)
70
69
  //(</additionalParams>)
71
- callingFlowSharedLib.addCallingFlowToPassOnProperties(event)
72
70
  );
73
71
 
74
72
  // return error to client
@@ -40,9 +40,9 @@ export const main = middleware.wrap(async (event, context, callback) => {
40
40
  return await <%- functionName %>.<%- functionName %>(
41
41
  event._izContext, // correlationId/logger/integrationTestDetail/uniqueRequestId
42
42
  event,
43
+ callingFlowSharedLib.addCallingFlowToPassOnProperties(event)
43
44
  //(<additionalParams>)
44
45
  //(</additionalParams>)
45
- callingFlowSharedLib.addCallingFlowToPassOnProperties(event)
46
46
  );
47
47
 
48
48
  } catch (err) {
@@ -69,10 +69,10 @@ export const main = middleware.wrap(async (event, context) => {
69
69
  );
70
70
 
71
71
  // add argument (to invoke lambda) to passOnProperties[]
72
- passOnProperties.push(record.body.Message)
72
+ passOnProperties.push(record.body.Message);
73
+ passOnProperties.push(callingFlowSharedLib.addCallingFlowToPassOnProperties(record.body.Message));
73
74
  //(<additionalParams>)
74
75
  //(</additionalParams>)
75
- passOnProperties.push(callingFlowSharedLib.addCallingFlowToPassOnProperties(record.body.Message));
76
76
  record._izContext.logger.debug('passOnProperties in handler', passOnProperties);
77
77
 
78
78
  // call recordHandlerSharedLib.recordHandler with 3 parameters and return promise(resolve)
@@ -51,10 +51,10 @@ export const main = middleware.wrap(async (event, context) => {
51
51
  );
52
52
 
53
53
  // add argument (to invoke lambda) to passOnProperties[]
54
- passOnProperties.push(record.body.Message)
54
+ passOnProperties.push(record.body.Message);
55
+ passOnProperties.push(callingFlowSharedLib.addCallingFlowToPassOnProperties(record.body.Message));
55
56
  //(<additionalParams>)
56
57
  //(</additionalParams>)
57
- passOnProperties.push(callingFlowSharedLib.addCallingFlowToPassOnProperties(record.body.Message));
58
58
  record._izContext.logger.debug('passOnProperties in handler', passOnProperties);
59
59
 
60
60
  // call recordHandlerSharedLib.recordHandler with 3 parameters and return promise(resolve)
@@ -55,9 +55,9 @@ import storedCacheSharedLib from '@izara_project/izara-core-library-stored-cache
55
55
  export default async function <%- functionName %> (
56
56
  _izContext,
57
57
  requestParams,
58
+ callingFlowConfig = {},
58
59
  //(<additionalParams>)
59
60
  //(</additionalParams>)
60
- callingFlowConfig = {},
61
61
  ) {
62
62
 
63
63
  try {
@@ -56,9 +56,9 @@ import storedCacheSharedLib from '@izara_project/izara-core-library-stored-cache
56
56
  export default async function <%- functionName %> (
57
57
  _izContext,
58
58
  requestParams,
59
+ callingFlowConfig = {},
59
60
  //(<additionalParams>)
60
61
  //(</additionalParams>)
61
- callingFlowConfig = {},
62
62
  ) {
63
63
 
64
64
  try {
@@ -225,7 +225,7 @@ export default async function createObjectComplete(
225
225
  await Promise.all(
226
226
  recordAwaitingSteps.Items.map(async ({ pendingStepId }) => {
227
227
  if (
228
- await asyncFlowSharedLib.checkAllAwaitingStepsFinishedWithError(
228
+ await asyncFlowSharedLib.checkAllAwaitingStepsFinished(
229
229
  _izContext,
230
230
  pendingStepId,
231
231
  awaitingStepId,
@@ -153,7 +153,7 @@ export default async function updateNodeComplete(
153
153
  await Promise.all(
154
154
  updateNodePendingObjects.Items.map(async ({ pendingStepId }) => {
155
155
  if (
156
- await asyncFlowSharedLib.checkAllAwaitingStepsFinishedWithError(
156
+ await asyncFlowSharedLib.checkAllAwaitingStepsFinished(
157
157
  _izContext,
158
158
  pendingStepId,
159
159
  awaitingStepId,
@@ -76,8 +76,7 @@ import { <%= action %>MainLogical } from './<%= functionName %>_Main.js';
76
76
  }
77
77
  <%_ } _%>
78
78
  }
79
-
80
- console.debug('identifiers:::: ', identifiers);
79
+ _izContext.logger.debug('identifiers:::: ', identifiers);
81
80
 
82
81
  // ── Verify + remove awaitingStep ──────────────────────────────────────────
83
82
  const awaitingStepId = asyncFlowSharedLib.createAwaitingStepId(
@@ -90,9 +89,12 @@ import { <%= action %>MainLogical } from './<%= functionName %>_Main.js';
90
89
  `beforeLogical_${requestParams.returnRequestParams.objectType}`
91
90
  );
92
91
 
93
- _izContext.logger.debug('createBeforeLogicalMain: checking awaitingStep', { awaitingStepId, pendingStepId });
92
+ _izContext.logger.debug('createBeforeLogicalMain: checking awaitingStep', {
93
+ awaitingStepId,
94
+ pendingStepId
95
+ });
94
96
 
95
- const [allComplete, collectedAttributes] =
97
+ const [allComplete, collectedAttributes, errorsFound] =
96
98
  await asyncFlowSharedLib.syncAndCheckStepsCompletion(
97
99
  _izContext,
98
100
  pendingStepId,
@@ -103,6 +105,12 @@ import { <%= action %>MainLogical } from './<%= functionName %>_Main.js';
103
105
  }
104
106
  );
105
107
 
108
+ _izContext.logger.debug('validate step::: ', {
109
+ allComplete,
110
+ collectedAttributes,
111
+ errorsFound
112
+ });
113
+
106
114
  if (allComplete === false) {
107
115
  _izContext.logger.debug(
108
116
  'createBeforeLogicalMain: pendingStepId not completed',
@@ -130,13 +138,13 @@ import { <%= action %>MainLogical } from './<%= functionName %>_Main.js';
130
138
  //(<beforeLogicalMain>)
131
139
  //(</beforeLogicalMain>)
132
140
 
133
- return await <%- action %>MainLogical(
141
+ return await createMainLogical(
134
142
  _izContext,
135
143
  requestParams.returnRequestParams,
136
144
  callingFlowConfig,
145
+ errorsFound,
137
146
  beforeLogicalResults
138
147
  );
139
-
140
148
  } catch (err) {
141
149
  throw err;
142
150
  }
@@ -60,6 +60,7 @@ const PREFIX = {
60
60
  _izContext,
61
61
  requestParams,
62
62
  callingFlowConfig = {},
63
+ errorsFound = [],
63
64
  beforeLogicalResults = {}
64
65
  ) {
65
66
  try {
@@ -69,7 +70,9 @@ const PREFIX = {
69
70
  beforeLogicalResults
70
71
  });
71
72
 
72
- const errorsFound = [];
73
+ //(<beforeCreateMainLogical>)
74
+ //(</beforeCreateMainLogical>)
75
+
73
76
  const objType = createObjType(requestParams.objectType);
74
77
 
75
78
  // ── Load schema ───────────────────────────────────────────────────────────
@@ -443,6 +446,14 @@ export default async function createMain(
443
446
  errorsFound.push(...errors);
444
447
  _izContext.logger.debug('errorsFound::', errorsFound);
445
448
 
449
+ if (errorsFound.length > 0)
450
+ return await createMainLogical(
451
+ _izContext,
452
+ requestParams,
453
+ callingFlowConfig,
454
+ errorsFound
455
+ );
456
+
446
457
  // ── Validate fieldNames ───────────────────────────────────────────────────
447
458
  const objInstanceFull = { identifiers: {}, fields: {} };
448
459
 
@@ -468,7 +479,6 @@ export default async function createMain(
468
479
  }
469
480
 
470
481
  // ── beforeLogical phase check ─────────────────────────────────────────────
471
- //(<beforeLogical>)
472
482
  <%_
473
483
  const groupedByObjType = generatedCodeConfig
474
484
  .filter(c => c.codeHookTag === 'beforeLogical')
@@ -504,6 +514,9 @@ export default async function createMain(
504
514
 
505
515
  <%_ } _%>
506
516
 
517
+ //(<afterBeforeLogical_<%= objectType %>>)
518
+ //(</afterBeforeLogical_<%= objectType %>>)
519
+
507
520
  <%_ if (hasOwnTopic) { _%>
508
521
  // ── ownTopic (async — create awaitingSteps and then publish) ──────────────
509
522
  const awaitingMultipleStepIds = [];
@@ -565,6 +578,9 @@ export default async function createMain(
565
578
  )
566
579
  );
567
580
 
581
+ //(<beforePublish_<%= objectType %>>)
582
+ //(</beforePublish_<%= objectType %>>)
583
+
568
584
  for (const recordMsg of recordMsgs) {
569
585
  const messageAttributes = sns.createStringMessageAttributes(
570
586
  _izContext,
@@ -604,7 +620,9 @@ export default async function createMain(
604
620
  <%_ } _%>
605
621
  }
606
622
  <%_ }) _%>
607
- //(</beforeLogical>)
623
+
624
+ //(<beforeCreateMainLogical>)
625
+ //(</beforeCreateMainLogical>)
608
626
 
609
627
  // ── No beforeLogical → proceed directly to logical ────────────────────────
610
628
  return await createMainLogical(
@@ -49,12 +49,15 @@ export async function deleteMainLogical(
49
49
  _izContext,
50
50
  requestParams,
51
51
  callingFlowConfig = {},
52
+ errorsFound = [],
52
53
  beforeLogicalResults = {}
53
54
  ) {
54
55
  try {
55
56
  _izContext.logger.debug('deleteMainLogical:', { requestParams, callingFlowConfig, beforeLogicalResults });
56
57
 
57
- const errorsFound = [];
58
+ //(<beforeDeleteMainLogical>)
59
+ //(</beforeDeleteMainLogical>)
60
+
58
61
  const objType = createObjType(requestParams.objectType);
59
62
 
60
63
  // ── Load schema ───────────────────────────────────────────────────────────
@@ -159,6 +162,9 @@ export default async function deleteMain(
159
162
  const errorsFound = [];
160
163
  const objType = createObjType(requestParams.objectType);
161
164
 
165
+ //(<beforeDelete>)
166
+ //(</beforeDelete>)
167
+
162
168
  // ── Load schema ───────────────────────────────────────────────────────────
163
169
  const objectSchema = await getObjectSchema.getObjSchemaS3WithHierarchy(_izContext, objType);
164
170
  _izContext.logger.debug('objectSchema', objectSchema);
@@ -177,8 +183,15 @@ export default async function deleteMain(
177
183
  // ── Build identifiers (used for hash in beforeLogical) ──────────────────
178
184
  const identifiers = requestParams.identifiers;
179
185
 
186
+ if (errorsFound.length > 0)
187
+ return await createMainLogical(
188
+ _izContext,
189
+ requestParams,
190
+ callingFlowConfig,
191
+ errorsFound
192
+ );
193
+
180
194
  // ── beforeLogical phase check ─────────────────────────────────────────────
181
- //(<beforeLogical>)
182
195
  <%_
183
196
  const groupedByObjType = generatedCodeConfig
184
197
  .filter(c => c.codeHookTag === 'beforeLogical')
@@ -211,9 +224,11 @@ export default async function deleteMain(
211
224
  // lambdaSyncInv <%= config.flowTag %>
212
225
  <%_ }) _%>
213
226
  ]);
214
-
215
227
  <%_ } _%>
216
228
 
229
+ //(<afterBeforeLogical_<%= objectType %>>)
230
+ //(</afterBeforeLogical_<%= objectType %>>)
231
+
217
232
  <%_ if (hasOwnTopic) { _%>
218
233
  // ── ownTopic (async — create awaitingSteps and then publish) ──────────
219
234
  const awaitingMultipleStepIds = [];
@@ -275,6 +290,9 @@ export default async function deleteMain(
275
290
  )
276
291
  );
277
292
 
293
+ //(<beforePublish_<%= objectType %>>)
294
+ //(</beforePublish_<%= objectType %>>)
295
+
278
296
  for (const recordMsg of recordMsgs) {
279
297
  const messageAttributes = sns.createStringMessageAttributes(
280
298
  _izContext,
@@ -314,7 +332,9 @@ export default async function deleteMain(
314
332
  <%_ } _%>
315
333
  }
316
334
  <%_ }) _%>
317
- //(</beforeLogical>)
335
+
336
+ //(<beforeDeleteMainLogical>)
337
+ //(</beforeDeleteMainLogical>)
318
338
 
319
339
  // ── No beforeLogical → proceed directly to logical ────────────────────────
320
340
  return await deleteMainLogical(
@@ -53,17 +53,20 @@ export async function updateMainLogical(
53
53
  _izContext,
54
54
  requestParams,
55
55
  callingFlowConfig = {},
56
+ errorsFound = [],
56
57
  beforeLogicalResults = {}
57
58
  ) {
58
59
  try {
59
60
  _izContext.logger.debug('updateMainLogical:', { requestParams, callingFlowConfig, beforeLogicalResults });
60
61
 
62
+ //(<beforeUpdateMainLogical>)
63
+ //(</beforeUpdateMainLogical>)
64
+
61
65
  // ── Settings ──────────────────────────────────────────────────────────────
62
66
  const settings = requestParams.additionalParams?.settings ?? {};
63
67
  const returnSystemFieldsName = settings.returnSystemFieldsName === true;
64
68
  const returnOldData = settings.returnOldData === true;
65
69
 
66
- const errorsFound = [];
67
70
  const objType = createObjType(requestParams.objectType);
68
71
  const identifiers = requestParams.objInstanceFull.identifiers;
69
72
  const fields = requestParams.objInstanceFull.fields;
@@ -311,9 +314,20 @@ export default async function updateMain(
311
314
 
312
315
  // ── Build identifiers (used for hash in beforeLogical) ──────────────────
313
316
  const identifiers = requestParams.objInstanceFull.identifiers;
317
+ const errorsFound = [];
318
+
319
+ //(<validateBeforeUpdate>)
320
+ //(</validateBeforeUpdate>)
321
+
322
+ if (errorsFound.length > 0)
323
+ return await createMainLogical(
324
+ _izContext,
325
+ requestParams,
326
+ callingFlowConfig,
327
+ errorsFound
328
+ );
314
329
 
315
330
  // ── beforeLogical phase check ─────────────────────────────────────────────
316
- //(<beforeLogical>)
317
331
  <%_
318
332
  const groupedByObjType = generatedCodeConfig
319
333
  .filter(c => c.codeHookTag === 'beforeLogical')
@@ -346,9 +360,11 @@ export default async function updateMain(
346
360
  // lambdaSyncInv <%= config.flowTag %>
347
361
  <%_ }) _%>
348
362
  ]);
349
-
350
363
  <%_ } _%>
351
364
 
365
+ //(<afterBeforeLogical_<%= objectType %>>)
366
+ //(</afterBeforeLogical_<%= objectType %>>)
367
+
352
368
  <%_ if (hasOwnTopic) { _%>
353
369
  // ── ownTopic (async — create awaitingSteps and then publish) ──────────
354
370
  const awaitingMultipleStepIds = [];
@@ -410,6 +426,9 @@ export default async function updateMain(
410
426
  )
411
427
  );
412
428
 
429
+ //(<beforePublish_<%= objectType %>>)
430
+ //(</beforePublish_<%= objectType %>>)
431
+
413
432
  for (const recordMsg of recordMsgs) {
414
433
  const messageAttributes = sns.createStringMessageAttributes(
415
434
  _izContext,
@@ -449,7 +468,9 @@ export default async function updateMain(
449
468
  <%_ } _%>
450
469
  }
451
470
  <%_ }) _%>
452
- //(</beforeLogical>)
471
+
472
+ //(<beforeUpdateMainLogical>)
473
+ //(</beforeUpdateMainLogical>)
453
474
 
454
475
  // ── No beforeLogical → proceed directly to logical ────────────────────────
455
476
  return await updateMainLogical(
@@ -75,7 +75,7 @@ export default async function updateRelationshipComplete(
75
75
  hash({
76
76
  linkTypeId,
77
77
  relId: returnValue.requestParams.relId,
78
- relationshipProperties: returnValue.requestParams.updatePropertiesParam,
78
+ relationshipProperties: returnValue.requestParams.relationshipProperties
79
79
  graphServiceTag: graphServiceTag
80
80
  }), // hash id
81
81
  PREFIX.updateRel // prefix, use constant further