@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,38 +15,40 @@ 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";
26
-
27
- import { sns, lambda } from "@izara_project/izara-core-library-external-request";
28
-
29
- import { getObjectSchema, utils, serviceConfig, consts, relSchemaLib, identifiersObject } from '@izara_project/izara-core-library-service-schemas'
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';
28
+
29
+ import {
30
+ sns,
31
+ lambda
32
+ } from '@izara_project/izara-core-library-external-request';
33
+
34
+ import {
35
+ getObjectSchema,
36
+ utils,
37
+ serviceConfig,
38
+ consts,
39
+ relSchemaLib,
40
+ identifiersObject
41
+ } from '@izara_project/izara-core-library-service-schemas';
30
42
  const { findLinksByObjTypes } = relSchemaLib;
31
43
 
32
- const {
33
- getRelationshipSchemaWithCache,
34
- getObjSchemaS3WithHierarchy
35
- } = getObjectSchema
44
+ const { getRelationshipSchemaWithCache, getObjSchemaS3WithHierarchy } =
45
+ getObjectSchema;
36
46
 
37
- const {
38
- createLinkTypeId
39
- } = utils;
47
+ const { createLinkTypeId } = utils;
40
48
 
41
- const {
42
- getGraphServiceTagWithCache
43
- } = serviceConfig;
49
+ const { getGraphServiceTagWithCache } = serviceConfig;
44
50
 
45
- const {
46
- PREFIX,
47
- TOPIC_NAME_GENERATE_CODE,
48
- TOPIC_NAME_GRAPH_HANDLER
49
- } = consts;
51
+ const { PREFIX, TOPIC_NAME_GENERATE_CODE, TOPIC_NAME_GRAPH_HANDLER } = consts;
50
52
 
51
53
  import { consts as coreConsts } from '@izara_project/izara-core-library-core';
52
54
 
@@ -67,14 +69,17 @@ import { consts as coreConsts } from '@izara_project/izara-core-library-core';
67
69
  export default async function moveRelationship(
68
70
  _izContext,
69
71
  requestParams,
70
- callingFlowConfig = {},
72
+ callingFlowConfig = {}
71
73
  //(<additionalParams>)
72
74
  //(</additionalParams>)
73
75
  ) {
74
76
  try {
75
77
  _izContext.logger.debug('moveRelationship _izContext: ', _izContext);
76
78
  _izContext.logger.debug('moveRelationship requestParams: ', requestParams);
77
- _izContext.logger.debug('moveRelationship callingFlowConfig: ', callingFlowConfig);
79
+ _izContext.logger.debug(
80
+ 'moveRelationship callingFlowConfig: ',
81
+ callingFlowConfig
82
+ );
78
83
 
79
84
  const {
80
85
  firstObject,
@@ -93,43 +98,71 @@ export default async function moveRelationship(
93
98
  //(<beforeValidateMoveRel>)
94
99
  //(</beforeValidateMoveRel>).
95
100
  // validate object and identifiers
96
- async function validateIdentifiersExists(_izContext, objType, identifiersObject) {
97
-
101
+ async function validateIdentifiersExists(
102
+ _izContext,
103
+ objType,
104
+ identifiersObject
105
+ ) {
98
106
  const objTypeString = `objType:{ serviceTag:${objType.serviceTag}, objectType:${objType.objectType} }`;
99
- const objectSchema = await getObjSchemaS3WithHierarchy(_izContext, objType);
107
+ const objectSchema = await getObjSchemaS3WithHierarchy(
108
+ _izContext,
109
+ objType
110
+ );
100
111
 
101
112
  if (!objectSchema) {
102
- errorsFound.push(`validateIdentifiers, not found schema of ${objTypeString}`);
113
+ errorsFound.push(
114
+ `validateIdentifiers, not found schema of ${objTypeString}`
115
+ );
103
116
  }
104
117
 
105
118
  for (const schemaIdentifier of objectSchema.identifiers) {
106
- let identifierNames = schemaIdentifier.fieldNames || [schemaIdentifier.fieldName];
119
+ let identifierNames = schemaIdentifier.fieldNames || [
120
+ schemaIdentifier.fieldName
121
+ ];
107
122
  for (const identifierName of identifierNames) {
108
123
  if (!identifiersObject.hasOwnProperty(identifierName)) {
109
- errorsFound.push(`validateIdentifiers, ${objTypeString} property:${identifierName} not exists`);
124
+ errorsFound.push(
125
+ `validateIdentifiers, ${objTypeString} property:${identifierName} not exists`
126
+ );
110
127
  } else {
111
128
  if (
112
- typeof (identifiersObject[identifierName]) !== "string" &&
113
- typeof (identifiersObject[identifierName]) !== "number"
129
+ typeof identifiersObject[identifierName] !== 'string' &&
130
+ typeof identifiersObject[identifierName] !== 'number'
114
131
  ) {
115
- errorsFound.push(`validateIdentifiers, ${objTypeString} property:${identifierName} should be string or number`);
132
+ errorsFound.push(
133
+ `validateIdentifiers, ${objTypeString} property:${identifierName} should be string or number`
134
+ );
116
135
  }
117
136
  }
118
137
  }
119
138
  }
120
139
  }
121
140
 
122
- await validateIdentifiersExists(_izContext, firstObject.objType, firstObject.identifiers);
123
- await validateIdentifiersExists(_izContext, secondObject.objType, secondObject.identifiers);
141
+ await validateIdentifiersExists(
142
+ _izContext,
143
+ firstObject.objType,
144
+ firstObject.identifiers
145
+ );
146
+ await validateIdentifiersExists(
147
+ _izContext,
148
+ secondObject.objType,
149
+ secondObject.identifiers
150
+ );
124
151
  // finished validate object and identifiers
125
152
 
126
153
  //(<afterValidateMoveRel>)
127
154
  //(</afterValidateMoveRel>)
128
155
 
129
- const relationshipSchema = await getRelationshipSchemaWithCache(_izContext, relType);
130
- _izContext.logger.debug("relationshipSchema: ", relationshipSchema);
156
+ const relationshipSchema = await getRelationshipSchemaWithCache(
157
+ _izContext,
158
+ relType
159
+ );
160
+ _izContext.logger.debug('relationshipSchema: ', relationshipSchema);
131
161
 
132
- if (!relationshipSchema.hasOwnProperty("moveBy") || relationshipSchema.moveBy === "none") {
162
+ if (
163
+ !relationshipSchema.hasOwnProperty('moveBy') ||
164
+ relationshipSchema.moveBy === 'none'
165
+ ) {
133
166
  errorsFound.push(`relationship: ${relType.relationshipTag} can't move`);
134
167
  // ? Legacy Code:
135
168
  /*
@@ -141,116 +174,161 @@ export default async function moveRelationship(
141
174
  }
142
175
  }
143
176
  */
144
- // ? [Fix]: The legacy logic incorrectly blocked "user" from regular execution and allowed non-user values.
145
- // ? It has been corrected to require moveBy === "user" for normal execution.
146
- } else if (relationshipSchema.moveBy !== "user") {
147
- errorsFound.push(`relationship: ${relType.relationshipTag} moveBy is not user`);
177
+ // ? [Fix]: The legacy logic incorrectly blocked "user" from regular execution and allowed non-user values.
178
+ // ? It has been corrected to require moveBy === "user" for normal execution.
179
+ } else if (relationshipSchema.moveBy !== 'user') {
180
+ errorsFound.push(
181
+ `relationship: ${relType.relationshipTag} moveBy is not user`
182
+ );
148
183
  }
149
184
 
150
- const links = await findLinksByObjTypes(_izContext, [firstObject.objType, secondObject.objType], relationshipSchema.links)
151
- _izContext.logger.debug("links", links)
152
-
153
- const firstObjectHie = await getObjectSchema.getObjSchemaS3WithHierarchy(_izContext, firstObject.objType);
154
- const secondObjectHie = await getObjectSchema.getObjSchemaS3WithHierarchy(_izContext, secondObject.objType);
185
+ const links = await findLinksByObjTypes(
186
+ _izContext,
187
+ [firstObject.objType, secondObject.objType],
188
+ relationshipSchema.links
189
+ );
190
+ _izContext.logger.debug('links', links);
191
+
192
+ const firstObjectHie = await getObjectSchema.getObjSchemaS3WithHierarchy(
193
+ _izContext,
194
+ firstObject.objType
195
+ );
196
+ const secondObjectHie = await getObjectSchema.getObjSchemaS3WithHierarchy(
197
+ _izContext,
198
+ secondObject.objType
199
+ );
155
200
 
156
201
  if (!links.length) {
157
- errorsFound.push(`not found link between ${JSON.stringify({ firstObject: firstObject.objType })} ${JSON.stringify({ secondObject: secondObject.objType })}`)
158
- };
202
+ errorsFound.push(
203
+ `not found link between ${JSON.stringify({ firstObject: firstObject.objType })} ${JSON.stringify({ secondObject: secondObject.objType })}`
204
+ );
205
+ }
159
206
 
160
207
  let checkCorrectLink = false;
161
208
  for (let link of links) {
162
- const { serviceTag: fromServiceTag, objectType: fromObjectType } = link.from.objType;
163
- const { serviceTag: toServiceTag, objectType: toObjType } = link.to.objType;
164
-
165
- const { serviceTag: firstServiceTag, objectType: firstObjectType } = firstObjectHie.extendObjType || firstObject.objType
166
- const { serviceTag: secondServiceTag, objectType: secondObjectType } = secondObjectHie.extendObjType || secondObject.objType
167
-
168
- const matchFromTo = fromServiceTag === firstServiceTag && fromObjectType === firstObjectType &&
169
- toServiceTag === secondServiceTag && toObjType === secondObjectType;
170
-
171
- const matchToFrom = fromServiceTag === secondServiceTag && fromObjectType === secondObjectType &&
172
- toServiceTag === firstServiceTag && toObjType === firstObjectType;
173
-
174
- if ((relationshipDirection === "from" && matchFromTo) ||
175
- (relationshipDirection === "to" && matchToFrom)) {
176
- checkCorrectLink = true
209
+ const { serviceTag: fromServiceTag, objectType: fromObjectType } =
210
+ link.from.objType;
211
+ const { serviceTag: toServiceTag, objectType: toObjType } =
212
+ link.to.objType;
213
+
214
+ const { serviceTag: firstServiceTag, objectType: firstObjectType } =
215
+ firstObjectHie.extendObjType || firstObject.objType;
216
+ const { serviceTag: secondServiceTag, objectType: secondObjectType } =
217
+ secondObjectHie.extendObjType || secondObject.objType;
218
+
219
+ const matchFromTo =
220
+ fromServiceTag === firstServiceTag &&
221
+ fromObjectType === firstObjectType &&
222
+ toServiceTag === secondServiceTag &&
223
+ toObjType === secondObjectType;
224
+
225
+ const matchToFrom =
226
+ fromServiceTag === secondServiceTag &&
227
+ fromObjectType === secondObjectType &&
228
+ toServiceTag === firstServiceTag &&
229
+ toObjType === firstObjectType;
230
+
231
+ if (
232
+ (relationshipDirection === 'from' && matchFromTo) ||
233
+ (relationshipDirection === 'to' && matchToFrom)
234
+ ) {
235
+ checkCorrectLink = true;
177
236
  break;
178
237
  }
179
- };
238
+ }
180
239
 
181
240
  if (checkCorrectLink == false) {
182
- errorsFound.push(`Wrong Relationship Direction`)
183
- };
241
+ errorsFound.push(`Wrong Relationship Direction`);
242
+ }
184
243
 
185
244
  let targetStorageResources = [];
186
245
 
187
246
  if (relationshipSchema) {
188
247
  // find targetStorageResources and validate each storageResources
189
248
  await Promise.all(
190
- relationshipSchema.links.map(async ({ from, to, storageResourceTags }) => {
191
- const { serviceTag: fromServiceTag, objectType: fromObjectType } = from.objType
192
- const { serviceTag: toServiceTag, objectType: toObjectType } = to.objType
193
-
194
- const { serviceTag: firstServiceTag, objectType: firstObjectType } = firstObjectHie.extendObjType || firstObject.objType;
195
- const { serviceTag: secondServiceTag, objectType: secondObjectType } = secondObjectHie.extendObjType || secondObject.objType;
196
-
197
- // find exists link
198
- if (
199
- (
200
- (firstServiceTag === fromServiceTag && firstObjectType === fromObjectType) &&
201
- (secondServiceTag === toServiceTag && secondObjectType === toObjectType)
202
- ) ||
203
- (
204
- (firstServiceTag === toServiceTag && firstObjectType === toObjectType) &&
205
- (secondServiceTag === fromServiceTag && secondObjectType === fromObjectType)
206
- )
207
- ) {
208
-
209
- // check founded storageResource of link and collect used storageResources
210
- await Promise.all(storageResourceTags.map(async storageResourceTag => {
211
- const usedStorageResource = relationshipSchema.storageResources[storageResourceTag];
212
-
213
- if (usedStorageResource.storageType === consts.STORAGE_TYPES.graph) {
214
- const graphServiceTag = await getGraphServiceTagWithCache(_izContext, usedStorageResource.graphServerTag);
215
- if (!graphServiceTag) {
216
- errorsFound.push(`storageResourceTag: ${storageResourceTag} invalid, not found graph serviceTag from graphServerTag: ${usedStorageResource.graphServerTag}`)
217
- }
218
-
219
- targetStorageResources.push({
220
- ...usedStorageResource,
221
- graphServiceTag: graphServiceTag
222
- });
223
- } else {
224
- targetStorageResources.push(usedStorageResource);
225
- }
226
- }));
249
+ relationshipSchema.links.map(
250
+ async ({ from, to, storageResourceTags }) => {
251
+ const { serviceTag: fromServiceTag, objectType: fromObjectType } =
252
+ from.objType;
253
+ const { serviceTag: toServiceTag, objectType: toObjectType } =
254
+ to.objType;
255
+
256
+ const { serviceTag: firstServiceTag, objectType: firstObjectType } =
257
+ firstObjectHie.extendObjType || firstObject.objType;
258
+ const {
259
+ serviceTag: secondServiceTag,
260
+ objectType: secondObjectType
261
+ } = secondObjectHie.extendObjType || secondObject.objType;
262
+
263
+ // find exists link
264
+ if (
265
+ (firstServiceTag === fromServiceTag &&
266
+ firstObjectType === fromObjectType &&
267
+ secondServiceTag === toServiceTag &&
268
+ secondObjectType === toObjectType) ||
269
+ (firstServiceTag === toServiceTag &&
270
+ firstObjectType === toObjectType &&
271
+ secondServiceTag === fromServiceTag &&
272
+ secondObjectType === fromObjectType)
273
+ ) {
274
+ // check founded storageResource of link and collect used storageResources
275
+ await Promise.all(
276
+ storageResourceTags.map(async (storageResourceTag) => {
277
+ const usedStorageResource =
278
+ relationshipSchema.storageResources[storageResourceTag];
279
+
280
+ if (
281
+ usedStorageResource.storageType ===
282
+ consts.STORAGE_TYPES.graph
283
+ ) {
284
+ const graphServiceTag = await getGraphServiceTagWithCache(
285
+ _izContext,
286
+ usedStorageResource.graphServerTag
287
+ );
288
+ if (!graphServiceTag) {
289
+ errorsFound.push(
290
+ `storageResourceTag: ${storageResourceTag} invalid, not found graph serviceTag from graphServerTag: ${usedStorageResource.graphServerTag}`
291
+ );
292
+ }
293
+
294
+ targetStorageResources.push({
295
+ ...usedStorageResource,
296
+ graphServiceTag: graphServiceTag
297
+ });
298
+ } else {
299
+ targetStorageResources.push(usedStorageResource);
300
+ }
301
+ })
302
+ );
303
+ }
227
304
  }
228
- })
305
+ )
229
306
  );
230
307
  //(<afterGetRelMoveRel>)
231
308
  //(</afterGetRelMoveRel>)
232
- _izContext.logger.debug("targetStorageResources: ", targetStorageResources);
309
+ _izContext.logger.debug(
310
+ 'targetStorageResources: ',
311
+ targetStorageResources
312
+ );
233
313
 
234
314
  if (!targetStorageResources.length) {
235
315
  errorsFound.push(`Not found link from relationship schema`);
236
316
  }
237
317
 
238
-
239
318
  // validate properties exists with schema
240
319
  for (const propKey in relationshipProperties) {
241
320
  if (!relationshipSchema.fieldNames.hasOwnProperty(propKey)) {
242
- errorsFound.push(`property: ${propKey} not exists in relationshipSchema`);
321
+ errorsFound.push(
322
+ `property: ${propKey} not exists in relationshipSchema`
323
+ );
243
324
  }
244
325
  }
245
-
246
326
  } else {
247
327
  errorsFound.push(`relationshipSchema not exists`);
248
328
  }
249
329
 
250
-
251
330
  // if found errors will stop processing
252
331
  if (errorsFound.length) {
253
-
254
332
  let moveRelCompleteMsg = {
255
333
  firstObject,
256
334
  secondObject,
@@ -266,35 +344,60 @@ export default async function moveRelationship(
266
344
  };
267
345
 
268
346
  // if have callingFlow will send to message complete
269
- if (callingFlowConfig[callingFlowSharedLib.consts.CALLINGFLOW_PROPERTYNAME]) {
270
- _izContext.logger.debug("HAVE CallingFlow");
271
-
272
- moveRelCompleteMsg = callingFlowSharedLib.addPassBackPropertiesToSnsResponseMessageObject(callingFlowConfig, moveRelCompleteMsg);
273
- let messageAttributes = callingFlowSharedLib.addCallingFlowToSnsResponseMessageAttributes(callingFlowConfig, {});
347
+ if (
348
+ callingFlowConfig[callingFlowSharedLib.consts.CALLINGFLOW_PROPERTYNAME]
349
+ ) {
350
+ _izContext.logger.debug('HAVE CallingFlow');
351
+
352
+ moveRelCompleteMsg =
353
+ callingFlowSharedLib.addPassBackPropertiesToSnsResponseMessageObject(
354
+ callingFlowConfig,
355
+ moveRelCompleteMsg
356
+ );
357
+ let messageAttributes =
358
+ callingFlowSharedLib.addCallingFlowToSnsResponseMessageAttributes(
359
+ callingFlowConfig,
360
+ {}
361
+ );
274
362
 
275
363
  let messageParams = {
276
364
  Message: JSON.stringify(moveRelCompleteMsg),
277
- MessageAttributes: sns.createStringMessageAttributes(_izContext, messageAttributes),
278
- TopicArn: await snsSharedLib.snsTopicArnByFlowSchema(_izContext, TOPIC_NAME_GENERATE_CODE.outMoveRelationshipComplete),
365
+ MessageAttributes: sns.createStringMessageAttributes(
366
+ _izContext,
367
+ messageAttributes
368
+ ),
369
+ TopicArn: snsSharedLib.snsTopicArnByFlowSchema(
370
+ _izContext,
371
+ TOPIC_NAME_GENERATE_CODE.outMoveRelationshipComplete
372
+ )
279
373
  };
280
374
 
281
- _izContext.logger.debug("messageParams OutCreateRelationshipComplete ::::::: ", messageParams);
375
+ _izContext.logger.debug(
376
+ 'messageParams OutCreateRelationshipComplete ::::::: ',
377
+ messageParams
378
+ );
282
379
  await sns.publishAsync(_izContext, messageParams);
283
380
  }
284
381
 
285
382
  return moveRelCompleteMsg;
286
383
  }
287
384
 
288
-
289
385
  // before create awaitingStepId per graph storageResource
290
- const linkTypeId = createLinkTypeId(_izContext, firstObject.objType, secondObject.objType, relType, relationshipDirection);
386
+ const linkTypeId = createLinkTypeId(
387
+ _izContext,
388
+ firstObject.objType,
389
+ secondObject.objType,
390
+ relType,
391
+ relationshipDirection
392
+ );
291
393
 
292
394
  let usedGraphServiceTag = []; // collect used graph serviceTag, use to check duplicate graph serviceTag across graph serverTag
293
395
  let targetGraphStorageResources = []; // collect used graph storageResources, filtered duplicate graphServiceTag from graphServerTag out
294
396
  let awaitingStepIds = [];
295
397
 
296
398
  for (const targetStorageResource of targetStorageResources) {
297
- if (targetStorageResource.storageType === consts.STORAGE_TYPES.graph &&
399
+ if (
400
+ targetStorageResource.storageType === consts.STORAGE_TYPES.graph &&
298
401
  !usedGraphServiceTag.includes(targetStorageResource.graphServiceTag)
299
402
  ) {
300
403
  usedGraphServiceTag.push(targetStorageResource.graphServiceTag);
@@ -315,7 +418,8 @@ export default async function moveRelationship(
315
418
  await asyncFlowSharedLib.createAwaitingMultipleSteps(
316
419
  _izContext,
317
420
  awaitingStepIds, // awaitingStepIds
318
- asyncFlowSharedLib.createPendingStepId( // pendingStepId
421
+ asyncFlowSharedLib.createPendingStepId(
422
+ // pendingStepId
319
423
  _izContext.uniqueRequestId, // hash id
320
424
  PREFIX.changeRel // prefix, use constant further
321
425
  )
@@ -329,43 +433,57 @@ export default async function moveRelationship(
329
433
  relationshipDirection,
330
434
  relationshipProperties,
331
435
  moveObject,
332
- parentFlowId: parentFlowId,
436
+ parentFlowId: parentFlowId
333
437
  //(<messageBodyMoveRel>)
334
438
  //(</messageBodyMoveRel>)
335
439
 
336
440
  // assign originTimestamp if not exists in relationshipProperties
337
- }
441
+ };
338
442
  _izContext.logger.debug('changeRelMessageBody: ', moveRelMessageBody);
339
443
 
340
444
  await Promise.all(
341
445
  targetGraphStorageResources.map(async (storageResource) => {
342
446
  if (storageResource.storageType === consts.STORAGE_TYPES.graph) {
343
-
344
- moveRelMessageBody = callingFlowSharedLib.addCallingFlowToSnsRequestMessageObject(
345
- moveRelMessageBody,
346
- callingFlowSharedLib.addParentCallingFlowConfig(
347
- callingFlowConfig, // receive parent callingFlowConfig.
348
- callingFlowSharedLib.createCallingFlowConfig( // calling flow own service
349
- //(<callingFlowProperties>)
350
- await lambdaSharedLib.lambdaFunctionName(_izContext, TOPIC_NAME_GENERATE_CODE.moveRelationshipComplete),
351
- //(</callingFlowProperties>)
352
- {
353
- graphServiceTag: storageResource.graphServiceTag
354
- }
447
+ moveRelMessageBody =
448
+ callingFlowSharedLib.addCallingFlowToSnsRequestMessageObject(
449
+ moveRelMessageBody,
450
+ callingFlowSharedLib.addParentCallingFlowConfig(
451
+ callingFlowConfig, // receive parent callingFlowConfig.
452
+ callingFlowSharedLib.createCallingFlowConfig(
453
+ // calling flow own service
454
+ //(<callingFlowProperties>)
455
+ await lambdaSharedLib.lambdaFunctionName(
456
+ _izContext,
457
+ TOPIC_NAME_GENERATE_CODE.moveRelationshipComplete
458
+ ),
459
+ //(</callingFlowProperties>)
460
+ {
461
+ graphServiceTag: storageResource.graphServiceTag
462
+ }
463
+ )
355
464
  )
356
- )
465
+ );
466
+ _izContext.logger.debug(
467
+ 'messageObject before send message:',
468
+ moveRelMessageBody
357
469
  );
358
- _izContext.logger.debug("messageObject before send message:", moveRelMessageBody)
359
470
 
360
471
  let messageToInChangeRelationship = {
361
472
  Message: JSON.stringify(moveRelMessageBody),
362
- TopicArn: await snsSharedLib.snsTopicArnByFlowSchema(_izContext, TOPIC_NAME_GRAPH_HANDLER.inMoveRelationship, storageResource.graphServiceTag),
473
+ TopicArn: snsSharedLib.snsTopicArnByFlowSchema(
474
+ _izContext,
475
+ TOPIC_NAME_GRAPH_HANDLER.inMoveRelationship,
476
+ storageResource.graphServiceTag
477
+ )
363
478
  };
364
- _izContext.logger.debug("RequestParams before send to sqs messageToInUpdateRelationship ::::::: ", messageToInChangeRelationship);
479
+ _izContext.logger.debug(
480
+ 'RequestParams before send to sqs messageToInUpdateRelationship ::::::: ',
481
+ messageToInChangeRelationship
482
+ );
365
483
  await sns.publishAsync(_izContext, messageToInChangeRelationship);
366
484
  }
367
485
  })
368
- )
486
+ );
369
487
  }
370
488
 
371
489
  return {
@@ -375,12 +493,10 @@ export default async function moveRelationship(
375
493
  relationshipDirection,
376
494
  relationshipProperties,
377
495
  moveObject,
378
- status: "complete"
496
+ status: 'complete'
379
497
  };
380
-
381
-
382
498
  } catch (err) {
383
- _izContext.logger.error('error ChangeRelationship: ', err)
384
- throw (err)
499
+ _izContext.logger.error('error ChangeRelationship: ', err);
500
+ throw err;
385
501
  }
386
502
  }