@izara_project/izara-core-generate-service-code 1.0.66 → 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 (90) hide show
  1. package/.prettierrc +11 -0
  2. package/docs/TriggeredCache Flow.drawio +193 -0
  3. package/docs/TriggeredCacheFlow.mmd +47 -0
  4. package/package.json +16 -12
  5. package/scripts/format-ejs.js +105 -0
  6. package/src/compile/compileProject.js +16 -1
  7. package/src/compile/loadSchemas.js +108 -1
  8. package/src/emit/crud/emitCrudApplicationArtifacts.js +9 -5
  9. package/src/emit/crud/emitDynamicCrudFlowSchemas.js +1 -2
  10. package/src/emit/crud/templates/CreateEndpoint_Main.ejs +300 -109
  11. package/src/emit/crud/templates/DeleteEndpoint_Main.ejs +221 -143
  12. package/src/emit/crud/templates/FlowEndpointBeforeLogical_Main.ejs +22 -6
  13. package/src/emit/crud/templates/FlowEndpointComplete_Main.ejs +150 -38
  14. package/src/emit/crud/templates/FlowEndpoint_HdrWbs.ejs +51 -31
  15. package/src/emit/crud/templates/FlowHandler_HdrApi.ejs +57 -31
  16. package/src/emit/crud/templates/FlowHandler_HdrInv.ejs +28 -26
  17. package/src/emit/crud/templates/FlowHandler_HdrSqs.ejs +15 -11
  18. package/src/emit/crud/templates/FlowMain_Wbs.ejs +53 -38
  19. package/src/emit/crud/templates/GetEndpoint_Main.ejs +6 -3
  20. package/src/emit/crud/templates/GetRangeEndpoint_Main.ejs +2 -2
  21. package/src/emit/crud/templates/UpdateEndpoint_Main.ejs +407 -252
  22. package/src/emit/custom/customFlows.js +112 -31
  23. package/src/emit/custom/emitCustomFlowApplicationArtifacts.js +89 -77
  24. package/src/emit/custom/templates/FlowEndpoint_Main.ejs +49 -37
  25. package/src/emit/custom/templates/FlowStep_Main.ejs +7 -9
  26. package/src/emit/custom/templates/s3/ConfirmReserved_HdrSqs.ejs +59 -54
  27. package/src/emit/custom/templates/s3/ConfirmReserved_Main.ejs +33 -23
  28. package/src/emit/custom/templates/s3/CreateObject_HdrWbs.ejs +30 -23
  29. package/src/emit/custom/templates/s3/CreateObject_Main.ejs +56 -39
  30. package/src/emit/custom/templates/s3/CreatePreSignUrl_HdrSqs.ejs +56 -51
  31. package/src/emit/custom/templates/s3/CreatePreSignUrl_Main.ejs +112 -75
  32. package/src/emit/custom/templates/s3/FlowHandler_HdrS3.ejs +12 -7
  33. package/src/emit/custom/templates/s3/ProcessS3File_Main.ejs +11 -8
  34. package/src/emit/custom/templates/s3/ReservedLimit_HdrSqs.ejs +64 -55
  35. package/src/emit/custom/templates/s3/ReservedLimit_Main.ejs +74 -52
  36. package/src/emit/custom/templates/triggerCache/CheckTriggerCache_HdrSqs.ejs +58 -14
  37. package/src/emit/custom/templates/triggerCache/CheckTriggerCache_Main.ejs +12 -17
  38. package/src/emit/custom/templates/triggerCache/TriggerCacheComplete_Main.ejs +20 -13
  39. package/src/emit/custom/templates/triggerCache/TriggerCache_Main.ejs +4 -1
  40. package/src/emit/function/functionYamlArtifact.js +46 -12
  41. package/src/emit/rbac/emitDynamicRbacFlowSchemas.js +28 -15
  42. package/src/emit/rbac/emitRbacApplicationArtifacts.js +179 -66
  43. package/src/emit/rbac/templates/CreateTargetRole_HdrSqs.ejs +41 -18
  44. package/src/emit/rbac/templates/CreateTargetRole_Main.ejs +23 -3
  45. package/src/emit/rbac/templates/ListRbac_HdrApi.ejs +27 -5
  46. package/src/emit/rbac/templates/ListRbac_HdrSqs.ejs +41 -8
  47. package/src/emit/rbac/templates/ListRbac_Main.ejs +26 -6
  48. package/src/emit/rbac/templates/RbacMutation_Main.ejs +23 -3
  49. package/src/emit/rbac/templates/UserRbacFlow_HdrSqs.ejs +46 -0
  50. package/src/emit/rbac/templates/UserRbacFlow_Main.ejs +152 -33
  51. package/src/emit/rbac/templates/UserRoleMutation_Main.ejs +24 -4
  52. package/src/emit/relationship/emitDynamicRelationshipFlowSchemas.js +1 -2
  53. package/src/emit/relationship/emitRelationshipApplicationArtifacts.js +6 -5
  54. package/src/emit/relationship/templates/ChangeRelationshipComplete_Main.ejs +64 -37
  55. package/src/emit/relationship/templates/ChangeRelationship_Main.ejs +260 -144
  56. package/src/emit/relationship/templates/CreateRelationshipComplete_Main.ejs +68 -43
  57. package/src/emit/relationship/templates/CreateRelationship_Main.ejs +315 -171
  58. package/src/emit/relationship/templates/DeleteRelationshipComplete_Main.ejs +67 -41
  59. package/src/emit/relationship/templates/DeleteRelationship_Main.ejs +226 -115
  60. package/src/emit/relationship/templates/FlowHandler_HdrApi.ejs +41 -33
  61. package/src/emit/relationship/templates/FlowHandler_HdrDsq.ejs +15 -11
  62. package/src/emit/relationship/templates/FlowHandler_HdrInv.ejs +28 -26
  63. package/src/emit/relationship/templates/FlowHandler_HdrSqs.ejs +15 -11
  64. package/src/emit/relationship/templates/GetRelationshipComplete_Main.ejs +46 -26
  65. package/src/emit/relationship/templates/GetRelationship_Main.ejs +233 -126
  66. package/src/emit/relationship/templates/MoveRelationshipComplete_Main.ejs +72 -44
  67. package/src/emit/relationship/templates/MoveRelationship_Main.ejs +266 -150
  68. package/src/emit/relationship/templates/UpdateRelationshipComplete_Main.ejs +74 -45
  69. package/src/emit/relationship/templates/UpdateRelationship_Main.ejs +285 -152
  70. package/src/emit/resource/emitResourceArtifacts.js +499 -108
  71. package/src/emit/resource/templates/DynamoDBTable_Yaml.ejs +18 -18
  72. package/src/emit/resource/templates/FlowOut_Yaml.ejs +5 -5
  73. package/src/emit/resource/templates/GeneratedLambdaRoleServiceConfig.ejs +138 -0
  74. package/src/emit/resource/templates/ResourceBeforeLogicalYaml.ejs +44 -44
  75. package/src/emit/resource/templates/ResourceSqsYaml.ejs +36 -36
  76. package/src/emit/resource/templates/ResourceYaml.ejs +48 -48
  77. package/src/emit/resource/templates/S3Bucket_Yaml.ejs +19 -0
  78. package/src/emit/resource/templates/SharedResource_Yaml.ejs +11 -11
  79. package/src/emit/resource/templates/SystemDynamoDB_Yaml.ejs +105 -105
  80. package/src/emit/system/emitSystemWebSocketArtifacts.js +2 -1
  81. package/src/generate.js +8 -4
  82. package/test/createTargetRoleHandler.test.js +63 -14
  83. package/test/crudApplicationArtifacts.test.js +1 -1
  84. package/test/customFlowApplicationArtifacts.test.js +71 -43
  85. package/test/dynamicCrudFlowSchemas.test.js +6 -6
  86. package/test/dynamicRbacFlowSchemas.test.js +8 -12
  87. package/test/dynamicRelationshipFlowSchemas.test.js +3 -3
  88. package/test/publicApi.test.js +11 -13
  89. package/test/resourceArtifacts.test.js +13 -3
  90. package/src/emit/rbac/templates/UserRbacFlow_HdrInv.ejs +0 -10
@@ -15,18 +15,32 @@ 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 snsSharedLib from '@izara_project/izara-core-library-sns';
21
24
  import asyncFlowSharedLib from '@izara_project/izara-core-library-asynchronous-flow';
22
25
  import callingFlowSharedLib from '@izara_project/izara-core-library-calling-flow';
23
26
  import lambdaSharedLib from '@izara_project/izara-core-library-lambda';
24
- import { consts as coreConsts, NoRetryError } from '@izara_project/izara-core-library-core';
27
+ import {
28
+ consts as coreConsts,
29
+ NoRetryError
30
+ } from '@izara_project/izara-core-library-core';
25
31
  import { consts as middlewareConsts } from '@izara_project/izara-middleware';
26
- import { sns, lambda } from '@izara_project/izara-core-library-external-request';
27
32
  import {
28
- utils, createNodeLib, uploadUseCase, consts, getObjectSchema,
29
- identifiersObject, dataDetailsLib
33
+ sns,
34
+ lambda
35
+ } from '@izara_project/izara-core-library-external-request';
36
+ import {
37
+ utils,
38
+ createNodeLib,
39
+ uploadUseCase,
40
+ consts,
41
+ getObjectSchema,
42
+ identifiersObject,
43
+ dataDetailsLib
30
44
  } from '@izara_project/izara-core-library-service-schemas';
31
45
  import graphSharedLibs from '@izara_project/izara-core-library-graph-service';
32
46
 
@@ -35,7 +49,8 @@ import graphSharedLibs from '@izara_project/izara-core-library-graph-service';
35
49
 
36
50
  const { createObjType, firstLetterUpperCase } = utils;
37
51
  const { createDataDetailsLib } = dataDetailsLib;
38
- const { dynamoDbIdentifiersByStorageResource, createIdentifiersByUseCase } = identifiersObject;
52
+ const { dynamoDbIdentifiersByStorageResource, createIdentifiersByUseCase } =
53
+ identifiersObject;
39
54
  const { TOPIC_NAME_GENERATE_CODE, TOPIC_NAME_GRAPH_HANDLER } = consts;
40
55
 
41
56
  const PREFIX = {
@@ -63,7 +78,7 @@ export async function <%- flowTag %>MainLogical(
63
78
  beforeLogicalResults = {}
64
79
  ) {
65
80
  try {
66
- _izContext.logger.debug('createMainLogical:', {
81
+ _izContext.logger.debug('[<%- flowTag %>MainLogical] started', {
67
82
  requestParams,
68
83
  callingFlowConfig,
69
84
  beforeLogicalResults
@@ -75,24 +90,38 @@ export async function <%- flowTag %>MainLogical(
75
90
  const objType = createObjType(requestParams.objectType);
76
91
 
77
92
  // ── Load schema ───────────────────────────────────────────────────────────
78
- const objectSchema = await getObjectSchema.getObjSchemaS3WithHierarchy(_izContext, objType);
93
+ const objectSchema = await getObjectSchema.getObjSchemaS3WithHierarchy(
94
+ _izContext,
95
+ objType
96
+ );
79
97
  _izContext.logger.debug('objectSchema', objectSchema);
80
98
 
81
- const objectSchemas = uploadUseCase.generateObjectSchemaForCombineFieldNames(_izContext, objectSchema);
99
+ const objectSchemas =
100
+ uploadUseCase.generateObjectSchemaForCombineFieldNames(
101
+ _izContext,
102
+ objectSchema
103
+ );
82
104
  _izContext.logger.debug('objectSchemas', objectSchemas);
83
105
 
84
106
  // ── Parent object ─────────────────────────────────────────────────────────
85
107
  let parentObject;
86
108
  if (objectSchemas.hasOwnProperty('extendObjType')) {
87
- parentObject = await getObjectSchema.getObjSchemaS3WithHierarchy(_izContext, objectSchema.extendObjType);
109
+ parentObject = await getObjectSchema.getObjSchemaS3WithHierarchy(
110
+ _izContext,
111
+ objectSchema.extendObjType
112
+ );
88
113
  }
89
114
 
90
115
  // ── Detect invocation type ────────────────────────────────────────────────
91
- const directInvoke = requestParams.hasOwnProperty('__context__') &&
116
+ const directInvoke =
117
+ requestParams.hasOwnProperty('__context__') &&
92
118
  requestParams.izEventSource?.eventSourceTag === 'DirectInvoke';
93
119
 
94
120
  // ── Build createDataDetails ───────────────────────────────────────────────
95
- const createDataDetails = await createDataDetailsLib(_izContext, objectSchemas);
121
+ const createDataDetails = await createDataDetailsLib(
122
+ _izContext,
123
+ objectSchemas
124
+ );
96
125
  _izContext.logger.debug('createDataDetails:', createDataDetails);
97
126
 
98
127
  // ── Build objInstanceFull identifiers ─────────────────────────────────────
@@ -100,12 +129,18 @@ export async function <%- flowTag %>MainLogical(
100
129
 
101
130
  for (const fieldName of Object.keys(requestParams.fieldNames)) {
102
131
  if (objectSchemas.identifierFieldNames.includes(fieldName)) {
103
- Object.assign(objInstanceFull.identifiers, { [fieldName]: requestParams.fieldNames[fieldName] });
132
+ Object.assign(objInstanceFull.identifiers, {
133
+ [fieldName]: requestParams.fieldNames[fieldName]
134
+ });
104
135
  }
105
136
  }
106
137
 
107
138
  // ── Helper: extract fields per storageTag ─────────────────────────────────
108
- function createObjInstanceFullFieldsByStorageTag(_izContext, storageTag, createDataDetail) {
139
+ function createObjInstanceFullFieldsByStorageTag(
140
+ _izContext,
141
+ storageTag,
142
+ createDataDetail
143
+ ) {
109
144
  const fields = {};
110
145
  for (const fieldName of Object.keys(requestParams.fieldNames)) {
111
146
  if (
@@ -114,7 +149,9 @@ export async function <%- flowTag %>MainLogical(
114
149
  !objInstanceFull.identifiers.hasOwnProperty(fieldName) &&
115
150
  !fields.hasOwnProperty(fieldName)
116
151
  ) {
117
- Object.assign(fields, { [fieldName]: requestParams.fieldNames[fieldName] });
152
+ Object.assign(fields, {
153
+ [fieldName]: requestParams.fieldNames[fieldName]
154
+ });
118
155
  }
119
156
  }
120
157
  return fields;
@@ -133,36 +170,66 @@ export async function <%- flowTag %>MainLogical(
133
170
  //(<validateBeforeCreate>)
134
171
  //(</validateBeforeCreate>)
135
172
 
136
- for (const [storageTag, createDataDetail] of Object.entries(createDataDetails)) {
173
+ for (const [storageTag, createDataDetail] of Object.entries(
174
+ createDataDetails
175
+ )) {
137
176
  //(<beforeCreate>)
138
177
  //(</beforeCreate>)
139
178
 
140
179
  // ── DynamoDB ──────────────────────────────────────────────────────────
141
180
  if (createDataDetail.storageType === consts.STORAGE_TYPES.dynamoDB) {
142
- _izContext.logger.debug('::::::DynamoDB::::::', { storageTag, objInstanceFull });
181
+ _izContext.logger.debug('::::::DynamoDB::::::', {
182
+ storageTag,
183
+ objInstanceFull
184
+ });
143
185
 
144
- if (parentObject && createDataDetail.tableName.includes(firstLetterUpperCase(`${parentObject.objectType}Records`))) {
145
- Object.assign(objInstanceFullForDynamoDb.fields, { [`${parentObject.objectType}HandlerServiceTag`]: process.env.iz_serviceTag });
186
+ if (
187
+ parentObject &&
188
+ createDataDetail.tableName.includes(
189
+ firstLetterUpperCase(`${parentObject.objectType}Records`)
190
+ )
191
+ ) {
192
+ Object.assign(objInstanceFullForDynamoDb.fields, {
193
+ [`${parentObject.objectType}HandlerServiceTag`]:
194
+ process.env.iz_serviceTag
195
+ });
146
196
  }
147
197
 
148
- Object.assign(objInstanceFullForDynamoDb.fields,
149
- createObjInstanceFullFieldsByStorageTag(_izContext, storageTag, createDataDetail));
198
+ Object.assign(
199
+ objInstanceFullForDynamoDb.fields,
200
+ createObjInstanceFullFieldsByStorageTag(
201
+ _izContext,
202
+ storageTag,
203
+ createDataDetail
204
+ )
205
+ );
150
206
 
151
- _izContext.logger.debug('objInstanceFull before create item in dynamoDB', objInstanceFullForDynamoDb);
207
+ _izContext.logger.debug(
208
+ 'objInstanceFull before create item in dynamoDB',
209
+ objInstanceFullForDynamoDb
210
+ );
152
211
 
153
- const identifiersForCreateData = await dynamoDbIdentifiersByStorageResource(
154
- _izContext,
155
- objectSchema,
156
- createDataDetails,
157
- objInstanceFullForDynamoDb.identifiers
212
+ const identifiersForCreateData =
213
+ await dynamoDbIdentifiersByStorageResource(
214
+ _izContext,
215
+ objectSchema,
216
+ createDataDetails,
217
+ objInstanceFullForDynamoDb.identifiers
218
+ );
219
+ _izContext.logger.debug(
220
+ 'identifiersForCreateData',
221
+ identifiersForCreateData
158
222
  );
159
- _izContext.logger.debug('identifiersForCreateData', identifiersForCreateData);
160
223
 
161
224
  //(<beforeCreateRecordDynamo>)
162
225
  //(</beforeCreateRecordDynamo>)
163
226
 
164
- if (Object.values(createDataDetails).some(
165
- createDataDetail => createDataDetail.storageType === consts.STORAGE_TYPES.graph)) {
227
+ if (
228
+ Object.values(createDataDetails).some(
229
+ (createDataDetail) =>
230
+ createDataDetail.storageType === consts.STORAGE_TYPES.graph
231
+ )
232
+ ) {
166
233
  _izContext.logger.debug('must process graph first');
167
234
  listOfRecords.push({
168
235
  [storageTag]: {
@@ -173,12 +240,13 @@ export async function <%- flowTag %>MainLogical(
173
240
  fields: objInstanceFullForDynamoDb.fields
174
241
  }
175
242
  }
176
- })
243
+ });
177
244
  } else {
178
- _izContext.logger.debug('can process record dynamo')
245
+ _izContext.logger.debug('can process record dynamo');
179
246
  await dynamodbSharedLib.putItem(
180
247
  _izContext,
181
- dynamodbSharedLib.tableName(_izContext,
248
+ dynamodbSharedLib.tableName(
249
+ _izContext,
182
250
  createDataDetail.tableName,
183
251
  createDataDetail.serviceTag
184
252
  ),
@@ -188,25 +256,39 @@ export async function <%- flowTag %>MainLogical(
188
256
  }
189
257
  );
190
258
 
191
- objInstanceFullForDynamoDb.fields = {}
259
+ objInstanceFullForDynamoDb.fields = {};
192
260
  }
193
261
 
194
262
  //(<afterCreateRecordDynamo>)
195
263
  //(</afterCreateRecordDynamo>)
196
264
 
197
265
  // ── Graph ─────────────────────────────────────────────────────────────
198
- } else if (createDataDetail.storageType === consts.STORAGE_TYPES.graph) {
266
+ } else if (
267
+ createDataDetail.storageType === consts.STORAGE_TYPES.graph
268
+ ) {
199
269
  //(<beforeCreateNode>)
200
270
  //(</beforeCreateNode>)
201
- _izContext.logger.debug('::::::Graph::::::', { storageTag, objInstanceFull });
271
+ _izContext.logger.debug('::::::Graph::::::', {
272
+ storageTag,
273
+ objInstanceFull
274
+ });
202
275
 
203
- Object.assign(objInstanceFullForGraph.fields,
204
- createObjInstanceFullFieldsByStorageTag(_izContext, storageTag, createDataDetail));
205
- _izContext.logger.debug('objInstanceFull before send to Graph', objInstanceFullForGraph);
276
+ Object.assign(
277
+ objInstanceFullForGraph.fields,
278
+ createObjInstanceFullFieldsByStorageTag(
279
+ _izContext,
280
+ storageTag,
281
+ createDataDetail
282
+ )
283
+ );
284
+ _izContext.logger.debug(
285
+ 'objInstanceFull before send to Graph',
286
+ objInstanceFullForGraph
287
+ );
206
288
 
207
- //(<additionalAttributeCreateNode>)
208
- const additionalAttributes = {};
209
- //(</additionalAttributeCreateNode>)
289
+ //(<additionalAttributeCreateNode>)
290
+ const additionalAttributes = {};
291
+ //(</additionalAttributeCreateNode>)
210
292
 
211
293
  const records = allAwaitingStepsId.length === 0 ? listOfRecords : [];
212
294
  allAwaitingStepsId.push({
@@ -214,7 +296,10 @@ export async function <%- flowTag %>MainLogical(
214
296
  parentFlowId,
215
297
  PREFIX.CREATE_OBJECT_ASYNC
216
298
  ),
217
- additionalAttributes: { listOfRecords: records ,additionalAttributes: additionalAttributes}
299
+ additionalAttributes: {
300
+ listOfRecords: records,
301
+ additionalAttributes: additionalAttributes
302
+ }
218
303
  });
219
304
 
220
305
  listOfObjectForCreates.push({
@@ -228,13 +313,28 @@ export async function <%- flowTag %>MainLogical(
228
313
  });
229
314
 
230
315
  // ── External Topic ────────────────────────────────────────────────────
231
- } else if (createDataDetail.storageType === consts.STORAGE_TYPES.externalTopic) {
232
- _izContext.logger.debug('::::::externalTopic::::::', { storageTag, createDataDetail });
316
+ } else if (
317
+ createDataDetail.storageType === consts.STORAGE_TYPES.externalTopic
318
+ ) {
319
+ _izContext.logger.debug('::::::externalTopic::::::', {
320
+ storageTag,
321
+ createDataDetail
322
+ });
233
323
  //(<beforeSendMessageToExternalTopic>)
234
324
  //(</beforeSendMessageToExternalTopic>)
235
325
 
236
- Object.assign(objInstanceFullForExternalTopic.fields, createObjInstanceFullFieldsByStorageTag(_izContext, storageTag, createDataDetail));
237
- _izContext.logger.debug('objInstanceFull before send to external topic', objInstanceFullForExternalTopic);
326
+ Object.assign(
327
+ objInstanceFullForExternalTopic.fields,
328
+ createObjInstanceFullFieldsByStorageTag(
329
+ _izContext,
330
+ storageTag,
331
+ createDataDetail
332
+ )
333
+ );
334
+ _izContext.logger.debug(
335
+ 'objInstanceFull before send to external topic',
336
+ objInstanceFullForExternalTopic
337
+ );
238
338
 
239
339
  allAwaitingStepsId.push({
240
340
  awaitingStepId: await asyncFlowSharedLib.createAwaitingStepId(
@@ -244,7 +344,9 @@ export async function <%- flowTag %>MainLogical(
244
344
  additionalAttributes: {}
245
345
  });
246
346
 
247
- Object.assign(objInstanceFullForExternalTopic, { parentFlowId: parentFlowId });
347
+ Object.assign(objInstanceFullForExternalTopic, {
348
+ parentFlowId: parentFlowId
349
+ });
248
350
 
249
351
  await sns.publishAsync(_izContext, {
250
352
  Message: JSON.stringify(objInstanceFullForExternalTopic),
@@ -262,14 +364,18 @@ export async function <%- flowTag %>MainLogical(
262
364
  _izContext.uniqueRequestId,
263
365
  PREFIX.CREATE_OBJECT_ASYNC_COMPLETE
264
366
  ),
265
- allAwaitingStepsId,
367
+ allAwaitingStepsId
266
368
  );
267
369
 
268
370
  // ── Process graph objects ─────────────────────────────────────────────────
269
371
  let messageObject = {};
270
372
  for (const objectCreate of listOfObjectForCreates) {
271
- for (const [graphServiceName, objectForCreate] of Object.entries(objectCreate)) {
272
- _izContext.logger.debug('Loop each graph:', { [graphServiceName]: objectForCreate });
373
+ for (const [graphServiceName, objectForCreate] of Object.entries(
374
+ objectCreate
375
+ )) {
376
+ _izContext.logger.debug('Loop each graph:', {
377
+ [graphServiceName]: objectForCreate
378
+ });
273
379
 
274
380
  if (!objectForCreate.allStorageTagComplete) {
275
381
  //(<beforeSendMessageToGraph>)
@@ -286,24 +392,35 @@ export async function <%- flowTag %>MainLogical(
286
392
 
287
393
  if (errorsFound.length > 0) break;
288
394
 
289
- Object.assign(messageObject, { settings: { updatePropertiesOnMatch: false }, originTimestamp: Date.now() });
395
+ Object.assign(messageObject, {
396
+ settings: { updatePropertiesOnMatch: false },
397
+ originTimestamp: Date.now()
398
+ });
290
399
 
291
- messageObject = callingFlowSharedLib.addCallingFlowToSnsRequestMessageObject(
292
- messageObject,
293
- callingFlowSharedLib.addParentCallingFlowConfig(
294
- callingFlowConfig,
295
- callingFlowSharedLib.createCallingFlowConfig(
296
- //(<callingFlowProperties>)
297
- await lambdaSharedLib.lambdaFunctionName(_izContext, TOPIC_NAME_GENERATE_CODE.createNodeComplete),
298
- {}
299
- //(</callingFlowProperties>)
400
+ messageObject =
401
+ callingFlowSharedLib.addCallingFlowToSnsRequestMessageObject(
402
+ messageObject,
403
+ callingFlowSharedLib.addParentCallingFlowConfig(
404
+ callingFlowConfig,
405
+ callingFlowSharedLib.createCallingFlowConfig(
406
+ //(<callingFlowProperties>)
407
+ await lambdaSharedLib.lambdaFunctionName(
408
+ _izContext,
409
+ TOPIC_NAME_GENERATE_CODE.createNodeComplete
410
+ ),
411
+ {}
412
+ //(</callingFlowProperties>)
413
+ )
300
414
  )
301
- )
302
- );
415
+ );
303
416
 
304
417
  await sns.publishAsync(_izContext, {
305
418
  Message: JSON.stringify(messageObject),
306
- TopicArn: await snsSharedLib.snsTopicArnByFlowSchema(_izContext, TOPIC_NAME_GRAPH_HANDLER.inCreateNode, graphServiceName)
419
+ TopicArn: snsSharedLib.snsTopicArnByFlowSchema(
420
+ _izContext,
421
+ TOPIC_NAME_GRAPH_HANDLER.inCreateNode,
422
+ graphServiceName
423
+ )
307
424
  });
308
425
 
309
426
  //(<afterSendMessageToGraph>)
@@ -331,25 +448,41 @@ export async function <%- flowTag %>MainLogical(
331
448
  )
332
449
  );
333
450
 
334
- messageObject = callingFlowSharedLib.addPassBackPropertiesToSnsResponseMessageObject(
335
- callingFlowConfig,
336
- { objType, identifiers: null, errorsFound }
337
- );
451
+ messageObject =
452
+ callingFlowSharedLib.addPassBackPropertiesToSnsResponseMessageObject(
453
+ callingFlowConfig,
454
+ { objType, identifiers: null, errorsFound }
455
+ );
338
456
 
339
457
  await sns.publishAsync(_izContext, {
340
458
  Message: JSON.stringify(messageObject),
341
459
  MessageAttributes: sns.createStringMessageAttributes(
342
460
  _izContext,
343
- callingFlowSharedLib.addCallingFlowToSnsResponseMessageAttributes(callingFlowConfig, {})
461
+ callingFlowSharedLib.addCallingFlowToSnsResponseMessageAttributes(
462
+ callingFlowConfig,
463
+ {}
464
+ )
344
465
  ),
345
- TopicArn: await snsSharedLib.snsTopicArnByFlowSchema(_izContext, TOPIC_NAME_GENERATE_CODE.outCreateNodeComplete)
466
+ TopicArn: snsSharedLib.snsTopicArnByFlowSchema(
467
+ _izContext,
468
+ TOPIC_NAME_GENERATE_CODE.outCreateNodeComplete
469
+ )
346
470
  });
347
471
 
348
- return { objType, objInstanceFull, relationships: requestParams.relationships || [], status: 'error', errorsFound };
472
+ return {
473
+ objType,
474
+ objInstanceFull,
475
+ relationships: requestParams.relationships || [],
476
+ status: 'error',
477
+ errorsFound
478
+ };
349
479
  }
350
480
 
351
481
  // ── DynamoDB-only complete path ───────────────────────────────────────────
352
- if (allAwaitingStepsId.length === 0 && listOfObjectForCreates.length === 0) {
482
+ if (
483
+ allAwaitingStepsId.length === 0 &&
484
+ listOfObjectForCreates.length === 0
485
+ ) {
353
486
  const outMessage =
354
487
  callingFlowSharedLib.addPassBackPropertiesToSnsResponseMessageObject(
355
488
  callingFlowConfig,
@@ -362,15 +495,23 @@ export async function <%- flowTag %>MainLogical(
362
495
  }
363
496
  );
364
497
 
365
- if (callingFlowConfig[callingFlowSharedLib.consts.CALLINGFLOW_PROPERTYNAME]) {
498
+ if (
499
+ callingFlowConfig[callingFlowSharedLib.consts.CALLINGFLOW_PROPERTYNAME]
500
+ ) {
366
501
  _izContext.logger.debug('HAVE CallingFlow');
367
502
  await sns.publishAsync(_izContext, {
368
503
  Message: JSON.stringify(outMessage),
369
504
  MessageAttributes: sns.createStringMessageAttributes(
370
505
  _izContext,
371
- callingFlowSharedLib.addCallingFlowToSnsResponseMessageAttributes(callingFlowConfig, {})
506
+ callingFlowSharedLib.addCallingFlowToSnsResponseMessageAttributes(
507
+ callingFlowConfig,
508
+ {}
509
+ )
372
510
  ),
373
- TopicArn: await snsSharedLib.snsTopicArnByFlowSchema(_izContext, TOPIC_NAME_GENERATE_CODE.outCreateNodeComplete)
511
+ TopicArn: snsSharedLib.snsTopicArnByFlowSchema(
512
+ _izContext,
513
+ TOPIC_NAME_GENERATE_CODE.outCreateNodeComplete
514
+ )
374
515
  });
375
516
  }
376
517
  }
@@ -385,7 +526,6 @@ export async function <%- flowTag %>MainLogical(
385
526
  status: 'complete',
386
527
  errorsFound
387
528
  };
388
-
389
529
  } catch (err) {
390
530
  throw err;
391
531
  }
@@ -406,13 +546,19 @@ export default async function <%- flowTag %>(
406
546
  //(</additionalParams>)
407
547
  ) {
408
548
  try {
409
- _izContext.logger.debug('createMain:', { requestParams, callingFlowConfig });
549
+ _izContext.logger.debug('[<%- flowTag %>] createMain:', {
550
+ requestParams,
551
+ callingFlowConfig
552
+ });
410
553
 
411
554
  const errorsFound = [];
412
555
  const objType = createObjType(requestParams.objectType);
413
556
 
414
557
  // ── Load schema ───────────────────────────────────────────────────────────
415
- const objectSchema = await getObjectSchema.getObjSchemaS3WithHierarchy(_izContext, objType);
558
+ const objectSchema = await getObjectSchema.getObjSchemaS3WithHierarchy(
559
+ _izContext,
560
+ objType
561
+ );
416
562
  _izContext.logger.debug('objectSchema', objectSchema);
417
563
 
418
564
  // ── Resolve userId / targetId ─────────────────────────────────────────────
@@ -421,20 +567,30 @@ export default async function <%- flowTag %>(
421
567
  userId = _izContext.correlationIds.get(coreConsts.BASE_USER_ID);
422
568
  targetId = _izContext.correlationIds.get(coreConsts.TARGET_ID);
423
569
  if (!userId) errorsFound.push('Not have userId');
424
- if (objectSchema.hasOwnProperty('belongTo') && !targetId) errorsFound.push('not have targetId');
570
+ if (objectSchema.hasOwnProperty('belongTo') && !targetId)
571
+ errorsFound.push('not have targetId');
425
572
  } else if (objectSchema.generatedBy === 'searchResultGenerated') {
426
- throw new NoRetryError('error searchResultGenerated should not happen here');
573
+ throw new NoRetryError(
574
+ 'error searchResultGenerated should not happen here'
575
+ );
427
576
  }
428
577
 
429
578
  //(<beforeQuery>)
430
579
  //(</beforeQuery>)
431
580
 
432
581
  // ── Build objectSchemas ───────────────────────────────────────────────────
433
- const objectSchemas = uploadUseCase.generateObjectSchemaForCombineFieldNames(_izContext, objectSchema);
582
+ const objectSchemas =
583
+ uploadUseCase.generateObjectSchemaForCombineFieldNames(
584
+ _izContext,
585
+ objectSchema
586
+ );
434
587
  _izContext.logger.debug('objectSchemas', objectSchemas);
435
588
 
436
589
  // ── Build createDataDetails ───────────────────────────────────────────────
437
- const createDataDetails = await createDataDetailsLib(_izContext, objectSchemas);
590
+ const createDataDetails = await createDataDetailsLib(
591
+ _izContext,
592
+ objectSchemas
593
+ );
438
594
  _izContext.logger.debug('createDataDetails:', createDataDetails);
439
595
 
440
596
  if (requestParams.relationships?.length > 0) {
@@ -443,7 +599,11 @@ export default async function <%- flowTag %>(
443
599
  }
444
600
 
445
601
  errorsFound.push(
446
- ...(await createNodeLib.validateRequiredOnCreateLinks(_izContext, objType, requestParams.relationships))
602
+ ...(await createNodeLib.validateRequiredOnCreateLinks(
603
+ _izContext,
604
+ objType,
605
+ requestParams.relationships
606
+ ))
447
607
  );
448
608
  _izContext.logger.debug('errorsFound', errorsFound);
449
609
 
@@ -452,7 +612,11 @@ export default async function <%- flowTag %>(
452
612
  const listOfOptionalOnCreate = [];
453
613
 
454
614
  for (const [key, val] of Object.entries(objectSchemas.fieldNames)) {
455
- if (val.randomOnCreate === true || val.requiredOnCreate === true || val.hashOnCreate?.length) {
615
+ if (
616
+ val.randomOnCreate === true ||
617
+ val.requiredOnCreate === true ||
618
+ val.hashOnCreate?.length
619
+ ) {
456
620
  listOfRequiredOnCreate.push(key);
457
621
  }
458
622
  if (val.requiredOnCreate === false && val.optionalOnCreate === true) {
@@ -471,11 +635,26 @@ export default async function <%- flowTag %>(
471
635
  let optionalOnCreateIdentifiers;
472
636
  //(</createOptionalOnCreateIdentifiers>)
473
637
 
474
- if (identifiers.length === 1 && !identifiers[0].hasOwnProperty('fieldNames')) {
475
- [requestParams, errors] = await createIdentifiersByUseCase(_izContext, requestParams, objectSchemas, identifiers[0], optionalOnCreateIdentifiers);
638
+ if (
639
+ identifiers.length === 1 &&
640
+ !identifiers[0].hasOwnProperty('fieldNames')
641
+ ) {
642
+ [requestParams, errors] = await createIdentifiersByUseCase(
643
+ _izContext,
644
+ requestParams,
645
+ objectSchemas,
646
+ identifiers[0],
647
+ optionalOnCreateIdentifiers
648
+ );
476
649
  } else if (identifiers.length > 1) {
477
650
  for (const identifier of identifiers) {
478
- [requestParams, errors] = await createIdentifiersByUseCase(_izContext, requestParams, objectSchemas, identifier, optionalOnCreateIdentifiers);
651
+ [requestParams, errors] = await createIdentifiersByUseCase(
652
+ _izContext,
653
+ requestParams,
654
+ objectSchemas,
655
+ identifier,
656
+ optionalOnCreateIdentifiers
657
+ );
479
658
  }
480
659
  }
481
660
 
@@ -498,16 +677,24 @@ export default async function <%- flowTag %>(
498
677
  //(</optionalObjInstanceFull>)
499
678
 
500
679
  for (const fieldName of Object.keys(requestParams.fieldNames)) {
501
- if (!listOfRequiredOnCreate.includes(fieldName) && !listOfOptionalOnCreate.includes(fieldName)) {
680
+ if (
681
+ !listOfRequiredOnCreate.includes(fieldName) &&
682
+ !listOfOptionalOnCreate.includes(fieldName)
683
+ ) {
502
684
  errorsFound.push('[invalid] over fieldNames create object');
503
685
  }
504
- if (listOfOptionalOnCreate.length > 0 && listOfRequiredOnCreate.includes(fieldName)) {
686
+ if (
687
+ listOfOptionalOnCreate.length > 0 &&
688
+ listOfRequiredOnCreate.includes(fieldName)
689
+ ) {
505
690
  //(<optionalParams>)
506
691
  //(</optionalParams>)
507
692
  }
508
693
  if (objectSchemas.identifierFieldNames.includes(fieldName)) {
509
694
  _izContext.logger.debug('identifiers is', fieldName);
510
- Object.assign(objInstanceFull.identifiers, { [fieldName]: requestParams.fieldNames[fieldName] });
695
+ Object.assign(objInstanceFull.identifiers, {
696
+ [fieldName]: requestParams.fieldNames[fieldName]
697
+ });
511
698
  }
512
699
  if (errorsFound.length > 0) {
513
700
  _izContext.logger.debug('HaveError::', errorsFound);
@@ -527,32 +714,36 @@ export default async function <%- flowTag %>(
527
714
  }, {});
528
715
  _%>
529
716
  <%_ Object.entries(groupedByObjType).forEach(([objectType, configs]) => { _%>
530
- <%_
717
+ <%_
531
718
  const hasOwnTopic = configs.some(c => c.invocationType === 'ownTopic');
532
719
  const hasLambdaSyncInv = configs.some(c => c.invocationType === 'lambdaSyncInv');
533
720
  _%>
534
- if (requestParams.objectType === '<%= objectType %>') {
535
-
536
- <%_ if (hasLambdaSyncInv) { _%>
537
- const lambdaSyncInvResults = await Promise.all([
538
- <%_ configs.filter(c => c.invocationType === 'lambdaSyncInv').forEach((config, index, arr) => { _%>
539
- // lambdaSyncInv <%= config.flowTag %>
540
- lambda.invokeSync(
721
+ if (requestParams.objectType === '<%= objectType %>') {
722
+ <%_ if (hasLambdaSyncInv) { _%>
723
+ const lambdaSyncInvResults = await Promise.all([
724
+ <%_ configs.filter(c => c.invocationType === 'lambdaSyncInv').forEach((config, index, arr) => { _%>
725
+ // lambdaSyncInv <%= config.flowTag %>
726
+ lambda
727
+ .invokeSync(
541
728
  _izContext,
542
729
  await lambdaSharedLib.lambdaFunctionName(
543
730
  _izContext,
544
731
  'Process<%= config.flowTag %>HdrInv'
545
732
  ),
546
733
  { requestParams, callingFlowConfig }
547
- ).then(returnValue => ({ flowTag: '<%= config.flowTag %>', returnValue }))<%= index < arr.length - 1 ? ',' : '' %>
548
- // lambdaSyncInv <%= config.flowTag %>
549
- <%_ }) _%>
550
- ]);
734
+ )
735
+ .then((returnValue) => ({
736
+ flowTag: '<%= config.flowTag %>',
737
+ returnValue
738
+ })) /*__EJS_COMMA_14__*/
739
+ // lambdaSyncInv <%= config.flowTag %>
740
+ <%_ }) _%>
741
+ ]);
551
742
 
552
- <%_ } _%>
743
+ <%_ } _%>
553
744
 
554
- //(<afterBeforeLogical_<%= objectType %>>)
555
- //(</afterBeforeLogical_<%= objectType %>>)
745
+ //(<afterBeforeLogical_<%= objectType %>>)
746
+ //(</afterBeforeLogical_<%= objectType %>>)
556
747
 
557
748
  <%_ if (hasOwnTopic) { _%>
558
749
  // ── ownTopic (async — create awaitingSteps and then publish) ──────────────
@@ -598,7 +789,7 @@ export default async function <%- flowTag %>(
598
789
  '<%= configs[0].codeHookTag %>_<%= objectType %>_' + syncResult.flowTag
599
790
  ),
600
791
  additionalAttributes: {
601
- complete: true,
792
+ complete: true,
602
793
  errorsFound: [],
603
794
  returnValue: syncResult.returnValue
604
795
  }
@@ -606,13 +797,13 @@ export default async function <%- flowTag %>(
606
797
  }
607
798
  <%_ } _%>
608
799
 
609
- await asyncFlowSharedLib.initAwaitingStepsWithAttrs(
800
+ await asyncFlowSharedLib.createAwaitingMultipleSteps(
610
801
  _izContext,
611
- awaitingMultipleStepIds,
612
802
  asyncFlowSharedLib.createPendingStepId(
613
803
  _izContext.uniqueRequestId,
614
804
  'beforeLogical_<%= objectType %>'
615
- )
805
+ ),
806
+ awaitingMultipleStepIds
616
807
  );
617
808
 
618
809
  //(<beforePublish_<%= objectType %>>)