@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,36 +15,34 @@ 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
- 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';
20
22
 
21
23
  import callingFlowSharedLib from '@izara_project/izara-core-library-calling-flow';
22
- import lambdaSharedLib from "@izara_project/izara-core-library-lambda";
23
- import snsSharedLib from "@izara_project/izara-core-library-sns";
24
- import asyncFlowSharedLib from "@izara_project/izara-core-library-asynchronous-flow";
25
- import dynamodbSharedLib from "@izara_project/izara-core-library-dynamodb";
24
+ import lambdaSharedLib from '@izara_project/izara-core-library-lambda';
25
+ import snsSharedLib from '@izara_project/izara-core-library-sns';
26
+ import asyncFlowSharedLib from '@izara_project/izara-core-library-asynchronous-flow';
27
+ import dynamodbSharedLib from '@izara_project/izara-core-library-dynamodb';
26
28
 
27
- import { sns } from "@izara_project/izara-core-library-external-request";
28
- import { getObjectSchema, utils, serviceConfig, consts, identifiersObject } from '@izara_project/izara-core-library-service-schemas'
29
+ import { sns } from '@izara_project/izara-core-library-external-request';
30
+ import {
31
+ getObjectSchema,
32
+ utils,
33
+ serviceConfig,
34
+ consts,
35
+ identifiersObject
36
+ } from '@izara_project/izara-core-library-service-schemas';
29
37
 
30
- const {
31
- getRelationshipSchemaWithCache,
32
- getObjSchemaS3WithHierarchy
33
- } = getObjectSchema
38
+ const { getRelationshipSchemaWithCache, getObjSchemaS3WithHierarchy } =
39
+ getObjectSchema;
34
40
 
35
- const {
36
- createLinkTypeId
37
- } = utils;
41
+ const { createLinkTypeId } = utils;
38
42
 
39
- const {
40
- getGraphServiceTagWithCache
41
- } = serviceConfig;
43
+ const { getGraphServiceTagWithCache } = serviceConfig;
42
44
 
43
- const {
44
- PREFIX,
45
- TOPIC_NAME_GENERATE_CODE,
46
- TOPIC_NAME_GRAPH_HANDLER
47
- } = consts;
45
+ const { PREFIX, TOPIC_NAME_GENERATE_CODE, TOPIC_NAME_GRAPH_HANDLER } = consts;
48
46
 
49
47
  //(<optionalRequire>)
50
48
  //(</optionalRequire>)
@@ -63,17 +61,20 @@ const {
63
61
  export default async function deleteRelationship(
64
62
  _izContext,
65
63
  requestParams,
66
- callingFlowConfig = {},
64
+ callingFlowConfig = {}
67
65
  //(<additionalParams>)
68
66
  //(</additionalParams>)
69
67
  ) {
70
-
71
-
72
68
  try {
73
69
  _izContext.logger.debug('deleteRelationship _izContext: ', _izContext);
74
- _izContext.logger.debug('deleteRelationship requestParams: ', requestParams);
75
- _izContext.logger.debug('deleteRelationship callingFlowConfig: ', callingFlowConfig);
76
-
70
+ _izContext.logger.debug(
71
+ 'deleteRelationship requestParams: ',
72
+ requestParams
73
+ );
74
+ _izContext.logger.debug(
75
+ 'deleteRelationship callingFlowConfig: ',
76
+ callingFlowConfig
77
+ );
77
78
 
78
79
  const {
79
80
  firstObject,
@@ -91,35 +92,57 @@ export default async function deleteRelationship(
91
92
  //(<beforeValidateDeleteRel>)
92
93
  //(</beforeValidateDeleteRel>)
93
94
  // validate object and identifiers
94
- async function validateIdentifiersExists(_izContext, objType, identifiersObject) {
95
-
95
+ async function validateIdentifiersExists(
96
+ _izContext,
97
+ objType,
98
+ identifiersObject
99
+ ) {
96
100
  const objTypeString = `objType:{ serviceTag:${objType.serviceTag}, objectType:${objType.objectType} }`;
97
- const objectSchema = await getObjSchemaS3WithHierarchy(_izContext, objType);
101
+ const objectSchema = await getObjSchemaS3WithHierarchy(
102
+ _izContext,
103
+ objType
104
+ );
98
105
 
99
106
  if (!objectSchema) {
100
- errorsFound.push(`validateIdentifiers, not found schema of ${objTypeString}`);
107
+ errorsFound.push(
108
+ `validateIdentifiers, not found schema of ${objTypeString}`
109
+ );
101
110
  }
102
111
 
103
112
  for (const schemaIdentifier of objectSchema.identifiers) {
104
- let identifierNames = schemaIdentifier.fieldNames || [schemaIdentifier.fieldName];
113
+ let identifierNames = schemaIdentifier.fieldNames || [
114
+ schemaIdentifier.fieldName
115
+ ];
105
116
  for (const identifierName of identifierNames) {
106
117
  if (!identifiersObject.hasOwnProperty(identifierName)) {
107
- errorsFound.push(`validateIdentifiers, ${objTypeString} property:${identifierName} not exists`);
118
+ errorsFound.push(
119
+ `validateIdentifiers, ${objTypeString} property:${identifierName} not exists`
120
+ );
108
121
  } else {
109
122
  if (
110
- typeof (identifiersObject[identifierName]) !== "string" &&
111
- typeof (identifiersObject[identifierName]) !== "number"
123
+ typeof identifiersObject[identifierName] !== 'string' &&
124
+ typeof identifiersObject[identifierName] !== 'number'
112
125
  ) {
113
- errorsFound.push(`validateIdentifiers, ${objTypeString} property:${identifierName} should be string or number`);
126
+ errorsFound.push(
127
+ `validateIdentifiers, ${objTypeString} property:${identifierName} should be string or number`
128
+ );
114
129
  }
115
130
  }
116
131
  }
117
132
  }
118
133
  }
119
134
 
120
- await validateIdentifiersExists(_izContext, firstObject.objType, firstObject.identifiers);
135
+ await validateIdentifiersExists(
136
+ _izContext,
137
+ firstObject.objType,
138
+ firstObject.identifiers
139
+ );
121
140
  if (Object.values(secondObject).length > 0) {
122
- await validateIdentifiersExists(_izContext, secondObject.objType, secondObject.identifiers);
141
+ await validateIdentifiersExists(
142
+ _izContext,
143
+ secondObject.objType,
144
+ secondObject.identifiers
145
+ );
123
146
  }
124
147
  // finished validate object and identifiers
125
148
 
@@ -129,8 +152,11 @@ export default async function deleteRelationship(
129
152
  //(<beforeDeleteRel>)
130
153
  //(</beforeDeleteRel>)
131
154
 
132
- const relationshipSchema = await getRelationshipSchemaWithCache(_izContext, relType);
133
- _izContext.logger.debug("relationshipSchema: ", relationshipSchema);
155
+ const relationshipSchema = await getRelationshipSchemaWithCache(
156
+ _izContext,
157
+ relType
158
+ );
159
+ _izContext.logger.debug('relationshipSchema: ', relationshipSchema);
134
160
 
135
161
  let targetStorageResources = [];
136
162
 
@@ -139,28 +165,41 @@ export default async function deleteRelationship(
139
165
  await Promise.all(
140
166
  relationshipSchema.links.map(async ({ storageResourceTags }) => {
141
167
  // check founded storageResource of link and collect used storageResources
142
- await Promise.all(storageResourceTags.map(async storageResourceTag => {
143
- const usedStorageResource = relationshipSchema.storageResources[storageResourceTag];
144
-
145
- if (usedStorageResource.storageType === consts.STORAGE_TYPES.graph) {
146
- const graphServiceTag = await getGraphServiceTagWithCache(_izContext, usedStorageResource.graphServerTag);
147
- if (!graphServiceTag) {
148
- errorsFound.push(`storageResourceTag:${storageResourceTag} invalid, not found graph serviceTag from graphServerTag:${usedStorageResource.graphServerTag}`)
168
+ await Promise.all(
169
+ storageResourceTags.map(async (storageResourceTag) => {
170
+ const usedStorageResource =
171
+ relationshipSchema.storageResources[storageResourceTag];
172
+
173
+ if (
174
+ usedStorageResource.storageType === consts.STORAGE_TYPES.graph
175
+ ) {
176
+ const graphServiceTag = await getGraphServiceTagWithCache(
177
+ _izContext,
178
+ usedStorageResource.graphServerTag
179
+ );
180
+ if (!graphServiceTag) {
181
+ errorsFound.push(
182
+ `storageResourceTag:${storageResourceTag} invalid, not found graph serviceTag from graphServerTag:${usedStorageResource.graphServerTag}`
183
+ );
184
+ }
185
+
186
+ targetStorageResources.push({
187
+ ...usedStorageResource,
188
+ graphServiceTag: graphServiceTag
189
+ });
190
+ } else {
191
+ targetStorageResources.push(usedStorageResource);
149
192
  }
150
-
151
- targetStorageResources.push({
152
- ...usedStorageResource,
153
- graphServiceTag: graphServiceTag
154
- });
155
- } else {
156
- targetStorageResources.push(usedStorageResource);
157
- }
158
- }));
193
+ })
194
+ );
159
195
  })
160
196
  );
161
197
  //(<afterDeleteRel>)
162
198
  //(</afterDeleteRel>)
163
- _izContext.logger.debug("targetStorageResources: ", targetStorageResources);
199
+ _izContext.logger.debug(
200
+ 'targetStorageResources: ',
201
+ targetStorageResources
202
+ );
164
203
 
165
204
  if (!targetStorageResources.length) {
166
205
  errorsFound.push(`Not found link from relationship schema`);
@@ -169,10 +208,8 @@ export default async function deleteRelationship(
169
208
  errorsFound.push(`relationshipSchema not exists`);
170
209
  }
171
210
 
172
-
173
211
  // if found errors will stop processing
174
212
  if (errorsFound.length) {
175
-
176
213
  let deleteRelCompleteMsg = {
177
214
  firstObject: firstObject,
178
215
  secondObject: secondObject,
@@ -187,41 +224,69 @@ export default async function deleteRelationship(
187
224
  };
188
225
 
189
226
  // if have callingFlow will send to message complete
190
- if (callingFlowConfig[callingFlowSharedLib.consts.CALLINGFLOW_PROPERTYNAME]) {
191
- _izContext.logger.debug("HAVE CallingFlow");
192
-
193
- deleteRelCompleteMsg = callingFlowSharedLib.addPassBackPropertiesToSnsResponseMessageObject(callingFlowConfig, deleteRelCompleteMsg);
194
- let messageAttributes = callingFlowSharedLib.addCallingFlowToSnsResponseMessageAttributes(callingFlowConfig, {});
227
+ if (
228
+ callingFlowConfig[callingFlowSharedLib.consts.CALLINGFLOW_PROPERTYNAME]
229
+ ) {
230
+ _izContext.logger.debug('HAVE CallingFlow');
231
+
232
+ deleteRelCompleteMsg =
233
+ callingFlowSharedLib.addPassBackPropertiesToSnsResponseMessageObject(
234
+ callingFlowConfig,
235
+ deleteRelCompleteMsg
236
+ );
237
+ let messageAttributes =
238
+ callingFlowSharedLib.addCallingFlowToSnsResponseMessageAttributes(
239
+ callingFlowConfig,
240
+ {}
241
+ );
195
242
 
196
243
  let messageParams = {
197
244
  Message: JSON.stringify(deleteRelCompleteMsg),
198
- MessageAttributes: sns.createStringMessageAttributes(_izContext, messageAttributes),
199
- TopicArn: await snsSharedLib.snsTopicArnByFlowSchema(_izContext, TOPIC_NAME_GENERATE_CODE.outDeleteRelComplete),
245
+ MessageAttributes: sns.createStringMessageAttributes(
246
+ _izContext,
247
+ messageAttributes
248
+ ),
249
+ TopicArn: snsSharedLib.snsTopicArnByFlowSchema(
250
+ _izContext,
251
+ TOPIC_NAME_GENERATE_CODE.outDeleteRelComplete
252
+ )
200
253
  };
201
254
 
202
- _izContext.logger.debug("messageParams OutCreateRelationshipComplete ::::::: ", messageParams);
255
+ _izContext.logger.debug(
256
+ 'messageParams OutCreateRelationshipComplete ::::::: ',
257
+ messageParams
258
+ );
203
259
  await sns.publishAsync(_izContext, messageParams);
204
260
  }
205
261
 
206
262
  return deleteRelCompleteMsg;
207
263
  }
208
264
 
209
-
210
265
  // before create awaitingStepId per graph storageResource
211
266
  let linkTypeId;
212
- if (secondObject && secondObject.hasOwnProperty("objType") && Object.values(secondObject.objType).length > 0) {
213
- linkTypeId = createLinkTypeId(_izContext, firstObject.objType, secondObject.objType, relType, relationshipDirection);
267
+ if (
268
+ secondObject &&
269
+ secondObject.hasOwnProperty('objType') &&
270
+ Object.values(secondObject.objType).length > 0
271
+ ) {
272
+ linkTypeId = createLinkTypeId(
273
+ _izContext,
274
+ firstObject.objType,
275
+ secondObject.objType,
276
+ relType,
277
+ relationshipDirection
278
+ );
214
279
  } else {
215
- linkTypeId = hash({ objType: firstObject.objType, relType: relType })
280
+ linkTypeId = hash({ objType: firstObject.objType, relType: relType });
216
281
  }
217
282
 
218
-
219
283
  let usedGraphServiceTag = []; // collect used graph serviceTag, use to check duplicate graph serviceTag across graph serverTag
220
284
  let targetGraphStorageResources = []; // collect used graph storageResources, filtered duplicate graphServiceTag from graphServerTag out
221
285
  let awaitingStepIds = [];
222
286
 
223
287
  for (const targetStorageResource of targetStorageResources) {
224
- if (targetStorageResource.storageType === consts.STORAGE_TYPES.graph &&
288
+ if (
289
+ targetStorageResource.storageType === consts.STORAGE_TYPES.graph &&
225
290
  !usedGraphServiceTag.includes(targetStorageResource.graphServiceTag)
226
291
  ) {
227
292
  usedGraphServiceTag.push(targetStorageResource.graphServiceTag);
@@ -234,31 +299,45 @@ export default async function deleteRelationship(
234
299
  PREFIX.deleteRel // prefix, use constant further
235
300
  )
236
301
  );
237
- } else if (targetStorageResource.storageType === consts.STORAGE_TYPES.dynamoDB) {
302
+ } else if (
303
+ targetStorageResource.storageType === consts.STORAGE_TYPES.dynamoDB
304
+ ) {
238
305
  let tableNameFrom = `${firstObject.objType.serviceTag}_${firstObject.objType.objectType}__${relType.relationshipTag}__${secondObject.objType.serviceTag}_${secondObject.objType.objectType}`;
239
306
  let tableNameTo = `${secondObject.objType.serviceTag}_${secondObject.objType.objectType}__${relType.relationshipTag}__${firstObject.objType.serviceTag}_${firstObject.objType.objectType}`;
240
307
 
241
- let identifiersConcatFirstObject = await identifiersObject.identifiersConcatFromIdentifiers(_izContext, firstObject.objType, firstObject.identifiers);
242
- let identifiersConcatSecondObject = await identifiersObject.identifiersConcatFromIdentifiers(_izContext, secondObject.objType, secondObject.identifiers);
308
+ let identifiersConcatFirstObject =
309
+ await identifiersObject.identifiersConcatFromIdentifiers(
310
+ _izContext,
311
+ firstObject.objType,
312
+ firstObject.identifiers
313
+ );
314
+ let identifiersConcatSecondObject =
315
+ await identifiersObject.identifiersConcatFromIdentifiers(
316
+ _izContext,
317
+ secondObject.objType,
318
+ secondObject.identifiers
319
+ );
243
320
  const firstObjectIdentifiersConcat = `${firstObject.objType.serviceTag}_${firstObject.objType.objectType}__identifiersConcat`;
244
321
  const secondObjectIdentifiersConcat = `${secondObject.objType.serviceTag}_${secondObject.objType.objectType}__identifiersConcat`;
245
322
  // putItem first Object DynamoDb
246
- await dynamodbSharedLib.deleteItem(_izContext,
323
+ await dynamodbSharedLib.deleteItem(
324
+ _izContext,
247
325
  await dynamodbSharedLib.tableName(_izContext, tableNameFrom),
248
326
  {
249
327
  [firstObjectIdentifiersConcat]: identifiersConcatFirstObject,
250
328
  [secondObjectIdentifiersConcat]: identifiersConcatSecondObject
251
329
  }
252
- )
330
+ );
253
331
 
254
332
  // put item second Object DynamoDb
255
- await dynamodbSharedLib.deleteItem(_izContext,
333
+ await dynamodbSharedLib.deleteItem(
334
+ _izContext,
256
335
  await dynamodbSharedLib.tableName(_izContext, tableNameTo),
257
336
  {
258
337
  [secondObjectIdentifiersConcat]: identifiersConcatSecondObject,
259
338
  [firstObjectIdentifiersConcat]: identifiersConcatFirstObject
260
339
  }
261
- )
340
+ );
262
341
  }
263
342
  }
264
343
 
@@ -267,7 +346,8 @@ export default async function deleteRelationship(
267
346
  await asyncFlowSharedLib.createAwaitingMultipleSteps(
268
347
  _izContext,
269
348
  awaitingStepIds, // awaitingStepIds
270
- asyncFlowSharedLib.createPendingStepId( // pendingStepId
349
+ asyncFlowSharedLib.createPendingStepId(
350
+ // pendingStepId
271
351
  _izContext.uniqueRequestId, // hash id
272
352
  PREFIX.deleteRel // prefix, use constant further
273
353
  )
@@ -280,61 +360,94 @@ export default async function deleteRelationship(
280
360
  relType: relType,
281
361
  relId: relId,
282
362
  relationshipDirection: relationshipDirection,
283
- parentFlowId: parentFlowId,
363
+ parentFlowId: parentFlowId
284
364
  //(<inDeleteRelMessageBody>)
285
365
  //(</inDeleteRelMessageBody>)
286
- }
366
+ };
287
367
  _izContext.logger.debug('deleteRelMessageBody: ', deleteRelMessageBody);
288
368
 
289
369
  await Promise.all(
290
370
  targetGraphStorageResources.map(async (storageResource) => {
291
371
  if (storageResource.storageType === consts.STORAGE_TYPES.graph) {
292
-
293
- deleteRelMessageBody = callingFlowSharedLib.addCallingFlowToSnsRequestMessageObject(
294
- deleteRelMessageBody,
295
- callingFlowSharedLib.addParentCallingFlowConfig(
296
- callingFlowConfig, // receive parent callingFlowConfig.
297
- callingFlowSharedLib.createCallingFlowConfig( // calling flow own service
298
- //(<callingFlowProperties>)
299
- await lambdaSharedLib.lambdaFunctionName(_izContext, TOPIC_NAME_GENERATE_CODE.deleteRelComplete), {}
300
- //(</callingFlowProperties>)
372
+ deleteRelMessageBody =
373
+ callingFlowSharedLib.addCallingFlowToSnsRequestMessageObject(
374
+ deleteRelMessageBody,
375
+ callingFlowSharedLib.addParentCallingFlowConfig(
376
+ callingFlowConfig, // receive parent callingFlowConfig.
377
+ callingFlowSharedLib.createCallingFlowConfig(
378
+ // calling flow own service
379
+ //(<callingFlowProperties>)
380
+ await lambdaSharedLib.lambdaFunctionName(
381
+ _izContext,
382
+ TOPIC_NAME_GENERATE_CODE.deleteRelComplete
383
+ ),
384
+ {}
385
+ //(</callingFlowProperties>)
386
+ )
301
387
  )
302
- )
388
+ );
389
+ _izContext.logger.debug(
390
+ 'messageObject before send message:',
391
+ deleteRelMessageBody
303
392
  );
304
- _izContext.logger.debug("messageObject before send message:", deleteRelMessageBody)
305
393
 
306
394
  let messageToInUpdateRelationship = {
307
395
  Message: JSON.stringify(deleteRelMessageBody),
308
- TopicArn: await snsSharedLib.snsTopicArnByFlowSchema(_izContext, TOPIC_NAME_GRAPH_HANDLER.inDeleteRel, storageResource.graphServiceTag),
396
+ TopicArn: snsSharedLib.snsTopicArnByFlowSchema(
397
+ _izContext,
398
+ TOPIC_NAME_GRAPH_HANDLER.inDeleteRel,
399
+ storageResource.graphServiceTag
400
+ )
309
401
  };
310
- _izContext.logger.debug("RequestParams before send to sqs messageToInUpdateRelationship ::::::: ", messageToInUpdateRelationship);
402
+ _izContext.logger.debug(
403
+ 'RequestParams before send to sqs messageToInUpdateRelationship ::::::: ',
404
+ messageToInUpdateRelationship
405
+ );
311
406
  await sns.publishAsync(_izContext, messageToInUpdateRelationship);
312
407
  }
313
408
  })
314
- )
315
-
409
+ );
316
410
  } else if (!awaitingStepIds.length) {
317
- _izContext.logger.debug("dynamoDb storageResourceTag")
411
+ _izContext.logger.debug('dynamoDb storageResourceTag');
318
412
  // if relationshipSchema stored in dynamoDB only will send message to outComplete
319
413
  let messageObject = {
320
414
  firstObject: firstObject,
321
415
  secondObject: secondObject,
322
416
  relType: relType,
323
417
  relId: relId,
324
- relationshipDirection,
418
+ relationshipDirection
325
419
  };
326
420
 
327
- if (callingFlowConfig[callingFlowSharedLib.consts.CALLINGFLOW_PROPERTYNAME]) {
328
- _izContext.logger.debug("have callingFlow");
329
- messageObject = callingFlowSharedLib.addPassBackPropertiesToSnsResponseMessageObject(callingFlowConfig, messageObject);
330
-
331
- let messageAttributes = callingFlowSharedLib.addCallingFlowToSnsResponseMessageAttributes(callingFlowConfig, {});
421
+ if (
422
+ callingFlowConfig[callingFlowSharedLib.consts.CALLINGFLOW_PROPERTYNAME]
423
+ ) {
424
+ _izContext.logger.debug('have callingFlow');
425
+ messageObject =
426
+ callingFlowSharedLib.addPassBackPropertiesToSnsResponseMessageObject(
427
+ callingFlowConfig,
428
+ messageObject
429
+ );
430
+
431
+ let messageAttributes =
432
+ callingFlowSharedLib.addCallingFlowToSnsResponseMessageAttributes(
433
+ callingFlowConfig,
434
+ {}
435
+ );
332
436
  let sendMessageToOutDeleteRelComplete = {
333
437
  Message: JSON.stringify(messageObject),
334
- MessageAttributes: sns.createStringMessageAttributes(_izContext, messageAttributes),
335
- TopicArn: await snsSharedLib.snsTopicArnByFlowSchema(_izContext, TOPIC_NAME_GENERATE_CODE.outDeleteRelComplete)
336
- }
337
- _izContext.logger.debug("send Message to outCreateRelationshipComplete :::", sendMessageToOutDeleteRelComplete);
438
+ MessageAttributes: sns.createStringMessageAttributes(
439
+ _izContext,
440
+ messageAttributes
441
+ ),
442
+ TopicArn: snsSharedLib.snsTopicArnByFlowSchema(
443
+ _izContext,
444
+ TOPIC_NAME_GENERATE_CODE.outDeleteRelComplete
445
+ )
446
+ };
447
+ _izContext.logger.debug(
448
+ 'send Message to outCreateRelationshipComplete :::',
449
+ sendMessageToOutDeleteRelComplete
450
+ );
338
451
  await sns.publishAsync(_izContext, sendMessageToOutDeleteRelComplete);
339
452
  }
340
453
  }
@@ -347,10 +460,8 @@ export default async function deleteRelationship(
347
460
  relationshipDirection,
348
461
  errorsFound
349
462
  };
350
-
351
-
352
463
  } catch (err) {
353
- _izContext.logger.error('error deleteRelationship: ', err)
354
- throw (err)
464
+ _izContext.logger.error('error deleteRelationship: ', err);
465
+ throw err;
355
466
  }
356
467
  }
@@ -1,20 +1,23 @@
1
- import { middlewareHandler as middleware, response } from "@izara_project/izara-middleware";
1
+ import {
2
+ middlewareHandler as middleware,
3
+ response
4
+ } from '@izara_project/izara-middleware';
2
5
  import callingFlowSharedLib from '@izara_project/izara-core-library-calling-flow';
3
6
 
4
7
  import <%= functionName %> from './<%= mainFileName %>.js';
5
8
 
6
9
  const validatorSchema = {
7
- //(<validatorSchema>)
8
- <% if (typeof startConfig !== 'undefined' && startConfig !== null && startConfig.properties && startConfig.properties.length > 0) { -%>
9
- type: 'object',
10
- properties: {
10
+ //(<validatorSchema>)
11
+ <% if (typeof startConfig !== 'undefined' && startConfig !== null && startConfig.properties && startConfig.properties.length > 0) { -%>
12
+ type: 'object',
13
+ properties: {
11
14
  <% startConfig.properties.forEach(prop => { -%>
12
- <%- prop.propertyName %>: { type: '<%- prop.type || 'string' %>' },
15
+ <%- prop.propertyName %>: { type: '<%- prop.type || 'string' %>' }
13
16
  <% }) -%>
14
- },
15
- required: [ <%- startConfig.properties.filter(p => p.required !== false).map(p => `'${p.propertyName}'`).join(', ') %> ]
16
- <% } -%>
17
- //(</validatorSchema>)
17
+ },
18
+ required: [<%- startConfig.properties.filter(p => p.required !== false).map(p => `'${p.propertyName}'`).join(', ') %>]
19
+ <% } -%>
20
+ //(</validatorSchema>)
18
21
  };
19
22
 
20
23
  middleware.setValidatorSchema(validatorSchema, { noAuthorizer: true });
@@ -24,28 +27,33 @@ middleware.setValidatorSchema(validatorSchema, { noAuthorizer: true });
24
27
  * Triggered by: API Gateway
25
28
  */
26
29
  export const main = middleware.wrap(async (event, context) => {
27
- event._izContext?.logger?.debug(`[${context.awsRequestId}] Received API request in <%= flowStepName %>`);
28
-
29
- try {
30
- const passOnProperties = [
31
- event.body,
32
- //(<additionalParams>)
33
- //(</additionalParams>)
34
- callingFlowSharedLib.addCallingFlowToPassOnProperties(event)
35
- ];
36
-
37
- const lambdaFunctionResponse = await <%= functionName %>(
38
- event._izContext,
39
- ...passOnProperties
40
- );
41
-
42
- if (lambdaFunctionResponse instanceof Error) {
43
- return response.failure(lambdaFunctionResponse);
44
- }
45
-
46
- return response.success(lambdaFunctionResponse);
47
- } catch (err) {
48
- event._izContext?.logger?.error('Unhandled Error in <%= flowStepName %> API:', err);
49
- return response.failure(err);
30
+ event._izContext?.logger?.debug(
31
+ `[${context.awsRequestId}] Received API request in <%= flowStepName %>`
32
+ );
33
+
34
+ try {
35
+ const passOnProperties = [
36
+ event.body,
37
+ //(<additionalParams>)
38
+ //(</additionalParams>)
39
+ callingFlowSharedLib.addCallingFlowToPassOnProperties(event)
40
+ ];
41
+
42
+ const lambdaFunctionResponse = await <%= functionName %>(
43
+ event._izContext,
44
+ ...passOnProperties
45
+ );
46
+
47
+ if (lambdaFunctionResponse instanceof Error) {
48
+ return response.failure(lambdaFunctionResponse);
50
49
  }
50
+
51
+ return response.success(lambdaFunctionResponse);
52
+ } catch (err) {
53
+ event._izContext?.logger?.error(
54
+ 'Unhandled Error in <%= flowStepName %> API:',
55
+ err
56
+ );
57
+ return response.failure(err);
58
+ }
51
59
  });