@izara_project/izara-market-library-service-schemas 1.0.8 → 1.0.10

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 (123) hide show
  1. package/package.json +2 -2
  2. package/src/GenerateCodeLibs/src/GenerateCodeLibs.js +64 -19
  3. package/src/MainLibs/src/Utils.js +13 -0
  4. package/src/TemplateManager/src/FindData/FindDataYaml/data.js +3 -2
  5. package/src/TemplateManager/src/FindData/FindDataYaml/template.ejs +1 -1
  6. package/src/TemplateManager/src/FindData/Handler/data.js +1 -6
  7. package/src/TemplateManager/src/FindData/mainFunction/template.ejs +0 -7
  8. package/src/TemplateManager/src/GenerateCode.js +3 -5
  9. package/src/TemplateManager/src/OutPerActionComplete/OutCreateComplete/functionYaml/data.js +4 -3
  10. package/src/TemplateManager/src/OutPerActionComplete/OutCreateComplete/functionYaml/template.ejs +1 -1
  11. package/src/TemplateManager/src/OutPerActionComplete/OutCreateComplete/handler/data.js +1 -3
  12. package/src/TemplateManager/src/OutPerActionComplete/OutCreateComplete/handler/template.ejs +11 -11
  13. package/src/TemplateManager/src/OutPerActionComplete/OutCreateComplete/mainFunction/data.js +1 -1
  14. package/src/TemplateManager/src/OutPerActionComplete/OutCreateComplete/mainFunction/template.ejs +13 -13
  15. package/src/TemplateManager/src/OutPerActionComplete/OutDeleteComplete/functionYaml/data.js +4 -3
  16. package/src/TemplateManager/src/OutPerActionComplete/OutDeleteComplete/functionYaml/template.ejs +1 -1
  17. package/src/TemplateManager/src/OutPerActionComplete/OutDeleteComplete/handler/data.js +1 -3
  18. package/src/TemplateManager/src/OutPerActionComplete/OutDeleteComplete/mainFunction/data.js +1 -1
  19. package/src/TemplateManager/src/OutPerActionComplete/OutDeleteComplete/mainFunction/template.ejs +8 -5
  20. package/src/TemplateManager/src/OutPerActionComplete/OutUpdateComplete/functionYaml/data.js +4 -2
  21. package/src/TemplateManager/src/OutPerActionComplete/OutUpdateComplete/functionYaml/template.ejs +1 -1
  22. package/src/TemplateManager/src/OutPerActionComplete/OutUpdateComplete/handler/data.js +1 -3
  23. package/src/TemplateManager/src/OutPerActionComplete/OutUpdateComplete/mainFunction/data.js +1 -1
  24. package/src/TemplateManager/src/OutPerActionComplete/OutUpdateComplete/mainFunction/template.ejs +5 -1
  25. package/src/TemplateManager/src/PerActionEndpoint/FunctionYaml/HdrApi/data.js +13 -7
  26. package/src/TemplateManager/src/PerActionEndpoint/FunctionYaml/HdrApi/template.ejs +1 -1
  27. package/src/TemplateManager/src/PerActionEndpoint/FunctionYaml/HdrDsq/data.js +12 -8
  28. package/src/TemplateManager/src/PerActionEndpoint/FunctionYaml/HdrDsq/template.ejs +1 -1
  29. package/src/TemplateManager/src/PerActionEndpoint/FunctionYaml/HdrInv/data.js +10 -12
  30. package/src/TemplateManager/src/PerActionEndpoint/FunctionYaml/HdrInv/template.ejs +1 -1
  31. package/src/TemplateManager/src/PerActionEndpoint/FunctionYaml/HdrSqs/data.js +13 -8
  32. package/src/TemplateManager/src/PerActionEndpoint/FunctionYaml/HdrSqs/template.ejs +1 -1
  33. package/src/TemplateManager/src/PerActionEndpoint/Handler/HdrApi/data.js +0 -2
  34. package/src/TemplateManager/src/PerActionEndpoint/Handler/HdrDsq/data.js +1 -2
  35. package/src/TemplateManager/src/PerActionEndpoint/Handler/HdrDsq/template.ejs +78 -62
  36. package/src/TemplateManager/src/PerActionEndpoint/Handler/HdrInv/data.js +0 -2
  37. package/src/TemplateManager/src/PerActionEndpoint/Handler/HdrInv/template.ejs +1 -2
  38. package/src/TemplateManager/src/PerActionEndpoint/Handler/HdrSqs/data.js +2 -3
  39. package/src/TemplateManager/src/PerActionEndpoint/Handler/HdrSqs/template.ejs +62 -53
  40. package/src/TemplateManager/src/PerActionEndpoint/MainFunction/Create/template.ejs +47 -8
  41. package/src/TemplateManager/src/ProcessLogical/Handler/data.js +0 -1
  42. package/src/TemplateManager/src/ProcessLogical/ProcessLogicalYaml/data.js +3 -2
  43. package/src/TemplateManager/src/ProcessLogical/ProcessLogicalYaml/template.ejs +1 -1
  44. package/src/TemplateManager/src/ProcessLogicalPagination/FunctionYaml/HdrDsq/data.js +3 -2
  45. package/src/TemplateManager/src/ProcessLogicalPagination/FunctionYaml/HdrDsq/template.ejs +1 -1
  46. package/src/TemplateManager/src/ProcessLogicalPagination/FunctionYaml/HdrSqs/data.js +3 -2
  47. package/src/TemplateManager/src/ProcessLogicalPagination/FunctionYaml/HdrSqs/template.ejs +1 -1
  48. package/src/TemplateManager/src/ProcessLogicalPagination/Handler/HdrDsq/data.js +1 -3
  49. package/src/TemplateManager/src/ProcessLogicalPagination/Handler/HdrSqs/data.js +1 -3
  50. package/src/TemplateManager/src/RelationshipPerAction/CreateRelationship/createRelationship/functionYaml/HdrApi/data.js +3 -2
  51. package/src/TemplateManager/src/RelationshipPerAction/CreateRelationship/createRelationship/functionYaml/HdrApi/template.ejs +1 -1
  52. package/src/TemplateManager/src/RelationshipPerAction/CreateRelationship/createRelationship/functionYaml/HdrDsq/data.js +3 -2
  53. package/src/TemplateManager/src/RelationshipPerAction/CreateRelationship/createRelationship/functionYaml/HdrDsq/template.ejs +1 -1
  54. package/src/TemplateManager/src/RelationshipPerAction/CreateRelationship/createRelationship/functionYaml/HdrInv/data.js +3 -2
  55. package/src/TemplateManager/src/RelationshipPerAction/CreateRelationship/createRelationship/functionYaml/HdrInv/template.ejs +1 -1
  56. package/src/TemplateManager/src/RelationshipPerAction/CreateRelationship/createRelationship/functionYaml/HdrSqs/data.js +3 -3
  57. package/src/TemplateManager/src/RelationshipPerAction/CreateRelationship/createRelationship/functionYaml/HdrSqs/template.ejs +1 -1
  58. package/src/TemplateManager/src/RelationshipPerAction/CreateRelationship/createRelationship/mainFunction/data.js +2 -0
  59. package/src/TemplateManager/src/RelationshipPerAction/CreateRelationship/createRelationship/mainFunction/template.ejs +63 -23
  60. package/src/TemplateManager/src/RelationshipPerAction/CreateRelationship/createRelationship/perAction/HdrApi/data.js +0 -2
  61. package/src/TemplateManager/src/RelationshipPerAction/CreateRelationship/createRelationship/perAction/HdrApi/template.ejs +45 -28
  62. package/src/TemplateManager/src/RelationshipPerAction/CreateRelationship/createRelationship/perAction/HdrDsq/data.js +0 -2
  63. package/src/TemplateManager/src/RelationshipPerAction/CreateRelationship/createRelationship/perAction/HdrDsq/template.ejs +42 -21
  64. package/src/TemplateManager/src/RelationshipPerAction/CreateRelationship/createRelationship/perAction/HdrInv/data.js +0 -2
  65. package/src/TemplateManager/src/RelationshipPerAction/CreateRelationship/createRelationship/perAction/HdrInv/template.ejs +41 -22
  66. package/src/TemplateManager/src/RelationshipPerAction/CreateRelationship/createRelationship/perAction/HdrSqs/data.js +0 -2
  67. package/src/TemplateManager/src/RelationshipPerAction/CreateRelationship/createRelationship/perAction/HdrSqs/template.ejs +42 -21
  68. package/src/TemplateManager/src/RelationshipPerAction/CreateRelationship/createRelationshipComplete/functionYaml/data.js +3 -2
  69. package/src/TemplateManager/src/RelationshipPerAction/CreateRelationship/createRelationshipComplete/functionYaml/template.ejs +1 -1
  70. package/src/TemplateManager/src/RelationshipPerAction/CreateRelationship/createRelationshipComplete/handler/HdrSqs/data.js +0 -2
  71. package/src/TemplateManager/src/RelationshipPerAction/DeleteRelationship/DeleteRelationship/functionYaml/HdrApi/data.js +3 -2
  72. package/src/TemplateManager/src/RelationshipPerAction/DeleteRelationship/DeleteRelationship/functionYaml/HdrApi/template.ejs +1 -1
  73. package/src/TemplateManager/src/RelationshipPerAction/DeleteRelationship/DeleteRelationship/functionYaml/HdrDsq/data.js +3 -2
  74. package/src/TemplateManager/src/RelationshipPerAction/DeleteRelationship/DeleteRelationship/functionYaml/HdrDsq/template.ejs +1 -1
  75. package/src/TemplateManager/src/RelationshipPerAction/DeleteRelationship/DeleteRelationship/functionYaml/HdrInv/data.js +3 -2
  76. package/src/TemplateManager/src/RelationshipPerAction/DeleteRelationship/DeleteRelationship/functionYaml/HdrInv/template.ejs +1 -1
  77. package/src/TemplateManager/src/RelationshipPerAction/DeleteRelationship/DeleteRelationship/functionYaml/HdrSqs/data.js +3 -2
  78. package/src/TemplateManager/src/RelationshipPerAction/DeleteRelationship/DeleteRelationship/functionYaml/HdrSqs/template.ejs +1 -1
  79. package/src/TemplateManager/src/RelationshipPerAction/DeleteRelationship/DeleteRelationship/mainFunction/data.js +2 -0
  80. package/src/TemplateManager/src/RelationshipPerAction/DeleteRelationship/DeleteRelationship/mainFunction/template.ejs +1 -1
  81. package/src/TemplateManager/src/RelationshipPerAction/DeleteRelationship/DeleteRelationship/perAction/HdrApi/data.js +0 -2
  82. package/src/TemplateManager/src/RelationshipPerAction/DeleteRelationship/DeleteRelationship/perAction/HdrDsq/data.js +0 -2
  83. package/src/TemplateManager/src/RelationshipPerAction/DeleteRelationship/DeleteRelationship/perAction/HdrInv/data.js +0 -2
  84. package/src/TemplateManager/src/RelationshipPerAction/DeleteRelationship/DeleteRelationship/perAction/HdrSqs/data.js +0 -2
  85. package/src/TemplateManager/src/RelationshipPerAction/DeleteRelationship/DeleteRelationshipComplete/functionYaml/data.js +3 -2
  86. package/src/TemplateManager/src/RelationshipPerAction/DeleteRelationship/DeleteRelationshipComplete/functionYaml/template.ejs +1 -1
  87. package/src/TemplateManager/src/RelationshipPerAction/DeleteRelationship/DeleteRelationshipComplete/handler/HdrSqs/data.js +0 -2
  88. package/src/TemplateManager/src/RelationshipPerAction/UpdateRelationshipSchema/updateRalationshipComplete/functionYaml/data.js +3 -2
  89. package/src/TemplateManager/src/RelationshipPerAction/UpdateRelationshipSchema/updateRalationshipComplete/functionYaml/template.ejs +1 -1
  90. package/src/TemplateManager/src/RelationshipPerAction/UpdateRelationshipSchema/updateRalationshipComplete/handler/HdrSqs/data.js +0 -2
  91. package/src/TemplateManager/src/RelationshipPerAction/UpdateRelationshipSchema/updateRelationship/functionYaml/HdrApi/data.js +3 -2
  92. package/src/TemplateManager/src/RelationshipPerAction/UpdateRelationshipSchema/updateRelationship/functionYaml/HdrApi/template.ejs +1 -1
  93. package/src/TemplateManager/src/RelationshipPerAction/UpdateRelationshipSchema/updateRelationship/functionYaml/HdrDsq/data.js +3 -2
  94. package/src/TemplateManager/src/RelationshipPerAction/UpdateRelationshipSchema/updateRelationship/functionYaml/HdrDsq/template.ejs +1 -1
  95. package/src/TemplateManager/src/RelationshipPerAction/UpdateRelationshipSchema/updateRelationship/functionYaml/HdrInv/data.js +4 -2
  96. package/src/TemplateManager/src/RelationshipPerAction/UpdateRelationshipSchema/updateRelationship/functionYaml/HdrInv/template.ejs +1 -1
  97. package/src/TemplateManager/src/RelationshipPerAction/UpdateRelationshipSchema/updateRelationship/functionYaml/HdrSqs/data.js +3 -2
  98. package/src/TemplateManager/src/RelationshipPerAction/UpdateRelationshipSchema/updateRelationship/functionYaml/HdrSqs/template.ejs +1 -1
  99. package/src/TemplateManager/src/RelationshipPerAction/UpdateRelationshipSchema/updateRelationship/mainFunction/data.js +1 -1
  100. package/src/TemplateManager/src/RelationshipPerAction/UpdateRelationshipSchema/updateRelationship/mainFunction/template.ejs +1 -1
  101. package/src/TemplateManager/src/RelationshipPerAction/UpdateRelationshipSchema/updateRelationship/perAction/HdrApi/data.js +0 -2
  102. package/src/TemplateManager/src/RelationshipPerAction/UpdateRelationshipSchema/updateRelationship/perAction/HdrDsq/data.js +0 -2
  103. package/src/TemplateManager/src/RelationshipPerAction/UpdateRelationshipSchema/updateRelationship/perAction/HdrDsq/template.ejs +1 -1
  104. package/src/TemplateManager/src/RelationshipPerAction/UpdateRelationshipSchema/updateRelationship/perAction/HdrInv/data.js +0 -2
  105. package/src/TemplateManager/src/RelationshipPerAction/UpdateRelationshipSchema/updateRelationship/perAction/HdrSqs/data.js +0 -2
  106. package/src/TemplateManager/src/RelationshipPerAction/UpdateRelationshipSchema/updateRelationship/perAction/HdrSqs/template.ejs +1 -1
  107. package/src/TemplateManager/src/ResourceYaml/dynamodb/mainResourcePerObjectSchemaData.js +3 -3
  108. package/src/TemplateManager/src/ResourceYaml/sns-in-sqs/defaultSnsInSqsForFindDataAndProcessLogical.js +6 -6
  109. package/src/TemplateManager/src/ResourceYaml/sns-out/defaultSnsOutForFindDataAndProcessLogical.js +2 -2
  110. package/src/TemplateManager/src/TranslateIdReq/ProcessingTranslateIds/functionYaml/data.js +3 -2
  111. package/src/TemplateManager/src/TranslateIdReq/ProcessingTranslateIds/functionYaml/template.ejs +1 -1
  112. package/src/TemplateManager/src/TranslateIdReq/ProcessingTranslateIds/handler/dataHdrDsq.js +0 -2
  113. package/src/TemplateManager/src/TranslateIdReq/TranslateIds/functionYaml/HdrDsq/data.js +4 -3
  114. package/src/TemplateManager/src/TranslateIdReq/TranslateIds/functionYaml/HdrDsq/template.ejs +30 -0
  115. package/src/TemplateManager/src/TranslateIdReq/TranslateIds/functionYaml/HdrSqs/data.js +4 -3
  116. package/src/TemplateManager/src/TranslateIdReq/TranslateIds/functionYaml/HdrSqs/template.ejs +30 -0
  117. package/src/TemplateManager/src/TranslateIdReq/TranslateIds/handler/HdrDsq/data.js +0 -2
  118. package/src/TemplateManager/src/TranslateIdReq/TranslateIds/handler/HdrSqs/data.js +0 -2
  119. package/src/TemplateManager/src/externalService/FunctionNameConfig/template.ejs +13 -2
  120. package/src/TemplateManager/src/externalService/LambdaRole/data.js +39 -38
  121. package/src/TemplateManager/src/externalService/SnsTopicSubscriotions/template.ejs +19 -0
  122. package/src/TemplateManager/src/libs/Consts.js +28 -5
  123. package/src/TemplateManager/src/CreateRelationship/createRelationship/functionYaml/HdrApi/data.js +0 -119
@@ -29,6 +29,7 @@ const asyncFlowSharedLib = require('@izara_project/izara-shared/src/AsyncFlowSha
29
29
 
30
30
  // const NoRetryError = require('@izara_project/izara-core-library-core/src/NoRetryError');
31
31
 
32
+ const { findLinksByObjTypes } = require("@izara_project/izara-core-library-service-schemas/src/libs/RelSchemaLib");
32
33
 
33
34
 
34
35
 
@@ -63,7 +64,7 @@ const {
63
64
  *
64
65
  * @returns {object} description of return value
65
66
  */
66
- module.exports.createRelationship = async (
67
+ module.exports.<%- functionName %> = async (
67
68
  _izContext,
68
69
  requestParams,
69
70
  callingFlowConfig = {},
@@ -79,8 +80,10 @@ module.exports.createRelationship = async (
79
80
 
80
81
 
81
82
  const {
82
- objects,
83
+ firstObject,
84
+ secondObject,
83
85
  relType,
86
+ relationshipDirection,
84
87
  relationshipProperties
85
88
  //(<requestparamCreateRel>)
86
89
  //(</requestparamCreateRel>)
@@ -117,8 +120,8 @@ module.exports.createRelationship = async (
117
120
  }
118
121
  }
119
122
 
120
- await validateIdentifiersExists(_izContext, objects[0].objType, objects[0].identifiers);
121
- await validateIdentifiersExists(_izContext, objects[1].objType, objects[1].identifiers);
123
+ await validateIdentifiersExists(_izContext, firstObject.objType, firstObject.identifiers);
124
+ await validateIdentifiersExists(_izContext, secondObject.objType, secondObject.identifiers);
122
125
  // finished validate object and identifiers
123
126
 
124
127
  //(<afterValidateCreateRel>)
@@ -130,6 +133,37 @@ module.exports.createRelationship = async (
130
133
  const relationshipSchema = await getRelationshipSchemaWithCache(_izContext, relType);
131
134
  _izContext.logger.debug("relationshipSchema: ", relationshipSchema);
132
135
 
136
+ const links = await findLinksByObjTypes(_izContext, [firstObject.objType, secondObject.objType], relationshipSchema.links)
137
+ _izContext.logger.debug("links", links)
138
+ if (!links.length) {
139
+ errorsFound.push(`not found link between ${JSON.stringify({ firstObject: firstObject.objType })} ${JSON.stringify({ secondObject: secondObject.objType })}`)
140
+ };
141
+
142
+ let checkCorrectLink = false;
143
+ for (let link of links) {
144
+ const { serviceTag: fromServiceTag, objectType: fromObjectType } = link.from.objType;
145
+ const { serviceTag: toServiceTag, objectType: toObjType } = link.to.objType;
146
+
147
+ const { serviceTag: firstServiceTag, objectType: firstObjectType } = firstObject.objType
148
+ const { serviceTag: secondServiceTag, objectType: secondObjectType } = secondObject.objType
149
+
150
+ const matchFromTo = fromServiceTag === firstServiceTag && fromObjectType === firstObjectType &&
151
+ toServiceTag === secondServiceTag && toObjType === secondObjectType;
152
+
153
+ const matchToFrom = fromServiceTag === secondServiceTag && fromObjectType === secondObjectType &&
154
+ toServiceTag === firstServiceTag && toObjType === firstObjectType;
155
+
156
+ if ((relationshipDirection === "from" && matchFromTo)
157
+ || (relationshipDirection === "to" && matchToFrom)) {
158
+ checkCorrectLink = true
159
+ break;
160
+ }
161
+ };
162
+
163
+ if (checkCorrectLink == false) {
164
+ errorsFound.push(`Wrong Relationship Direction`)
165
+ };
166
+
133
167
  let targetStorageResources = [];
134
168
 
135
169
  if (relationshipSchema) {
@@ -139,8 +173,8 @@ module.exports.createRelationship = async (
139
173
  const { serviceTag: fromServiceTag, objectType: fromObjectType } = from.objType
140
174
  const { serviceTag: toServiceTag, objectType: toObjectType } = to.objType
141
175
 
142
- const { serviceTag: firstServiceTag, objectType: firstObjectType } = objects[0].objType;
143
- const { serviceTag: secondServiceTag, objectType: secondObjectType } = objects[1].objType;
176
+ const { serviceTag: firstServiceTag, objectType: firstObjectType } = firstObject.objType;
177
+ const { serviceTag: secondServiceTag, objectType: secondObjectType } = secondObject.objType;
144
178
 
145
179
  // find exists link
146
180
  if (
@@ -161,7 +195,7 @@ module.exports.createRelationship = async (
161
195
  if (usedStorageResource.storageType === consts.STORAGE_TYPES.graph) {
162
196
  const graphServiceTag = await getGraphServiceTagWithCache(_izContext, usedStorageResource.graphServerTag);
163
197
  if (!graphServiceTag) {
164
- errorsFound.push(`storageResourceTag:${storageResourceTag} invalid, not found graph serviceTag from graphServerTag:${usedStorageResource.graphServerTag}`)
198
+ errorsFound.push(`storageResourceTag: ${storageResourceTag} invalid, not found graph serviceTag from graphServerTag: ${usedStorageResource.graphServerTag}`)
165
199
  }
166
200
 
167
201
  targetStorageResources.push({
@@ -187,7 +221,7 @@ module.exports.createRelationship = async (
187
221
  // validate properties exists with schema
188
222
  for (const propKey in relationshipProperties) {
189
223
  if (!relationshipSchema.fieldNames.hasOwnProperty(propKey)) {
190
- errorsFound.push(`property:${propKey} not exists in relationshipSchema`);
224
+ errorsFound.push(`property: ${propKey} not exists in relationshipSchema`);
191
225
  }
192
226
  }
193
227
 
@@ -195,12 +229,12 @@ module.exports.createRelationship = async (
195
229
  for (const [propName, propSetting] of Object.entries(relationshipSchema.fieldNames)) {
196
230
  if (propSetting.requiredOnCreate === true) {
197
231
  if (!relationshipProperties.hasOwnProperty(propName)) {
198
- errorsFound.push(`Missing requiredOnCreate property:${propKey}`);
232
+ errorsFound.push(`Missing requiredOnCreate property: ${propKey}`);
199
233
  }
200
234
  }
201
235
 
202
236
  if (!propSetting.optionalOnCreate && !propSetting.requiredOnCreate && relationshipProperties.hasOwnProperty(propName)) {
203
- errorsFound.push(`property:${propName} cannot create`);
237
+ errorsFound.push(`property: ${propName} cannot create`);
204
238
  }
205
239
  }
206
240
 
@@ -213,9 +247,11 @@ module.exports.createRelationship = async (
213
247
  if (errorsFound.length) {
214
248
 
215
249
  let createRelCompleteMsg = {
216
- objects: objects,
250
+ firstObject: firstObject,
251
+ secondObject: secondObject,
217
252
  relType: relType,
218
- relationshipProperties: relationshipProperties,
253
+ relationshipDirection,
254
+ relationshipProperties,
219
255
  //(<inCreateRelCompleteMsgCrateRel>)
220
256
  //(</inCreateRelCompleteMsgCrateRel>)
221
257
  status: 'error',
@@ -244,7 +280,7 @@ module.exports.createRelationship = async (
244
280
 
245
281
 
246
282
  // before create awaitingStepId per graph storageResource
247
- const linkTypeId = createLinkTypeId(_izContext, [objects[0].objType, objects[1].objType], relType);
283
+ const linkTypeId = createLinkTypeId(_izContext, firstObject.objType, secondObject.objType, relType);
248
284
 
249
285
  let usedGraphServiceTag = []; // collect used graph serviceTag, use to check duplicate graph serviceTag across graph serverTag
250
286
  let targetGraphStorageResources = []; // collect used graph storageResources, filtered duplicate graphServiceTag from graphServerTag out
@@ -284,21 +320,23 @@ module.exports.createRelationship = async (
284
320
  );
285
321
 
286
322
  // prepare message body
287
- let updateRelMessageBody = {
288
- objects: objects,
323
+ let createRelMessageBody = {
324
+ firstObject: firstObject,
325
+ secondObject: secondObject,
289
326
  relType: relType,
327
+ relationshipDirection,
290
328
  relationshipProperties
291
329
  //(<inUpdateRelMessageBodyCreateRel>)
292
330
  //(</inUpdateRelMessageBodyCreateRel>)
293
331
  }
294
- _izContext.logger.debug('createRelMessageBody: ', updateRelMessageBody);
332
+ _izContext.logger.debug('createRelMessageBody: ', createRelMessageBody);
295
333
 
296
334
  await Promise.all(
297
335
  targetGraphStorageResources.map(async (storageResource) => {
298
336
  if (storageResource.storageType === consts.STORAGE_TYPES.graph) {
299
337
 
300
- updateRelMessageBody = callingFlowSharedLib.addCallingFlowToSnsRequestMessageObject(
301
- updateRelMessageBody,
338
+ createRelMessageBody = callingFlowSharedLib.addCallingFlowToSnsRequestMessageObject(
339
+ createRelMessageBody,
302
340
  callingFlowSharedLib.addParentCallingFlowConfig(
303
341
  callingFlowConfig, // receive parent callingFlowConfig.
304
342
  callingFlowSharedLib.createCallingFlowConfig( // callinfflow own service
@@ -309,10 +347,10 @@ module.exports.createRelationship = async (
309
347
  )
310
348
  )
311
349
  );
312
- _izContext.logger.debug("messageObject before send message:", updateRelMessageBody)
350
+ _izContext.logger.debug("messageObject before send message:", createRelMessageBody)
313
351
 
314
352
  let messageToInUpdateRelationship = {
315
- Message: JSON.stringify(updateRelMessageBody),
353
+ Message: JSON.stringify(createRelMessageBody),
316
354
  TopicArn: await snsSharedLib.snsTopicArn(_izContext, TOPIC_NAME_GRAPH_HANDLER.inCreateRel, storageResource.graphServiceTag),
317
355
  };
318
356
  _izContext.logger.debug("RequestParams before send to sqs messageToInUpdateRelationship ::::::: ", messageToInUpdateRelationship);
@@ -326,10 +364,12 @@ module.exports.createRelationship = async (
326
364
  }
327
365
 
328
366
  return {
329
- objects,
330
- relType,
367
+ firstObject: firstObject,
368
+ secondObject: secondObject,
369
+ relType: relType,
370
+ relationshipDirection,
331
371
  relationshipProperties,
332
- errorFounds: errorsFound
372
+ status: "complete"
333
373
  };
334
374
 
335
375
 
@@ -40,12 +40,10 @@ function data(_izContext, srcPath) {
40
40
 
41
41
  function createParamForCreateSource(srcPath) {
42
42
  let functionName = FUNCTION_NAME.createRel;
43
- let functionNameConfig = upperCase(functionName) + upperCase(HANDLER.hdrApi)
44
43
  return {
45
44
  templatePath: templatePath,
46
45
  templateData: {
47
46
  functionName,
48
- functionNameConfig
49
47
  },
50
48
  setting: {
51
49
  savePath: path.join(srcPath, SOURCE_PATH.relationshipPerAction),
@@ -27,28 +27,41 @@ const <%- functionName %> = require('./<%- firstLetterUpperCase(functionName) %>
27
27
  // validate event params in middleware before into function
28
28
  let validatorSchema = {
29
29
  type: "object",
30
- required: ["objects", "relId", "relType", "relationshipProperties"],
30
+ required: ["firstObject", "secondObject", "relType", "relationshipDirection"],
31
31
  properties: {
32
- objects: {
33
- type: "array",
34
- minItems: 2,
35
- maxItems: 2,
36
- Items: {
37
- type: "object",
38
- required: ["objType", "identifiers"],
39
- properties: {
40
- objType: {
41
- type: "object",
42
- required: ["serviceTag", "objectType"],
43
- properties: {
44
- serviceTag: izara.validatorSchema.stringNotEmpty(),
45
- objectType: izara.validatorSchema.stringNotEmpty()
46
- }
47
- },
48
- identifiers: {
49
- type: "object",
50
- minproperties: 1
32
+ firstObject: {
33
+ type: "object",
34
+ required: ["objType", "identifiers"],
35
+ properties: {
36
+ objType: {
37
+ type: "object",
38
+ required: ["serviceTag", "objectType"],
39
+ properties: {
40
+ serviceTag: izara.validatorSchema.stringNotEmpty(),
41
+ objectType: izara.validatorSchema.stringNotEmpty()
51
42
  }
43
+ },
44
+ identifiers: {
45
+ type: "object",
46
+ minProperties: 1
47
+ }
48
+ }
49
+ },
50
+ secondObject: {
51
+ type: "object",
52
+ required: ["objType", "identifiers"],
53
+ properties: {
54
+ objType: {
55
+ type: "object",
56
+ required: ["serviceTag", "objectType"],
57
+ properties: {
58
+ serviceTag: izara.validatorSchema.stringNotEmpty(),
59
+ objectType: izara.validatorSchema.stringNotEmpty()
60
+ }
61
+ },
62
+ identifiers: {
63
+ type: "object",
64
+ minProperties: 1
52
65
  }
53
66
  }
54
67
  },
@@ -61,14 +74,17 @@ let validatorSchema = {
61
74
  type: 'string',
62
75
  pattern: "^[a-zA-Z0-9_-]+$",
63
76
  enum: [process.env.iz_serviceTag]
64
- }
77
+ },
65
78
  }
66
79
  },
67
- relId: izara.validatorSchema.stringNotEmpty(),
80
+ relationshipDirection: {
81
+ type: "string",
82
+ enum: ['from', "to"]
83
+ },
68
84
  relationshipProperties: {
69
- type: "object",
70
- minProperties: 1
71
- }
85
+ type: 'object',
86
+ default: {}
87
+ },
72
88
  }
73
89
  };
74
90
 
@@ -92,10 +108,11 @@ module.exports.main = middleware.wrap(async (event, context, callback) => {
92
108
  let lambdaFunctionResponse = await <%- functionName %>.<%- functionName %>(
93
109
  event._izContext, // correlationId/logger/integrationTestDetail/uniqueRequestId/userId
94
110
  {
95
- objects: event.objects,
111
+ firstObject: event.firstObject,
112
+ secondObject: event.secondObject,
96
113
  relType: event.relType,
97
- relId: event.relId,
98
- relationshipProperties: event.relationshipProperties
114
+ relationshipDirection: event.relationshipDirection,
115
+ relationshipProperties: event.relationshipProperties,
99
116
  }
100
117
  );
101
118
 
@@ -40,13 +40,11 @@ function data(_izContext, srcPath) {
40
40
  function createParamForCreateSource(srcPath) {
41
41
  let functionName = FUNCTION_NAME.createRel
42
42
  let queueName = functionName + upperCase(HANDLER.hdrDsq)
43
- let functionNameConfig = upperCase(functionName) + upperCase(HANDLER.hdrDsq)
44
43
  return {
45
44
  templatePath: templatePath,
46
45
  templateData: {
47
46
  functionName,
48
47
  queueName,
49
- functionNameConfig
50
48
  },
51
49
  setting: {
52
50
  savePath: path.join(srcPath, SOURCE_PATH.relationshipPerAction),
@@ -48,28 +48,41 @@ middleware.setValidatorSchema(recordHandlerSharedLib.baseValidatorSchema(
48
48
  // validate event params in middlewware before into function.
49
49
  let validatorSchema = {
50
50
  type: "object",
51
- required: ["objects", "relType"],
51
+ required: ["firstObject", "secondObject", "relType", "relationshipDirection"],
52
52
  properties: {
53
- objects: {
54
- type: "array",
55
- minItems: 2,
56
- maxItems: 2,
57
- items: {
58
- type: 'object',
59
- required: ["objType", "identifiers"],
60
- properties: {
61
- objType: {
62
- type: "object",
63
- required: ["serviceTag", "objectType"],
64
- properties: {
65
- serviceTag: izara.validatorSchema.stringNotEmpty(),
66
- objectType: izara.validatorSchema.stringNotEmpty()
67
- }
68
- },
69
- identifiers: {
70
- type: "object",
71
- minProperties: 1
53
+ firstObject: {
54
+ type: "object",
55
+ required: ["objType", "identifiers"],
56
+ properties: {
57
+ objType: {
58
+ type: "object",
59
+ required: ["serviceTag", "objectType"],
60
+ properties: {
61
+ serviceTag: izara.validatorSchema.stringNotEmpty(),
62
+ objectType: izara.validatorSchema.stringNotEmpty()
63
+ }
64
+ },
65
+ identifiers: {
66
+ type: "object",
67
+ minProperties: 1
68
+ }
69
+ }
70
+ },
71
+ secondObject: {
72
+ type: "object",
73
+ required: ["objType", "identifiers"],
74
+ properties: {
75
+ objType: {
76
+ type: "object",
77
+ required: ["serviceTag", "objectType"],
78
+ properties: {
79
+ serviceTag: izara.validatorSchema.stringNotEmpty(),
80
+ objectType: izara.validatorSchema.stringNotEmpty()
72
81
  }
82
+ },
83
+ identifiers: {
84
+ type: "object",
85
+ minProperties: 1
73
86
  }
74
87
  }
75
88
  },
@@ -85,6 +98,10 @@ let validatorSchema = {
85
98
  },
86
99
  }
87
100
  },
101
+ relationshipDirection: {
102
+ type: "string",
103
+ enum: ['from', "to"]
104
+ },
88
105
  relationshipProperties: {
89
106
  type: 'object',
90
107
  default: {}
@@ -129,7 +146,11 @@ let validatorSchema = {
129
146
  );
130
147
 
131
148
  // add argument (to invoke lambda) to passOnProperties[]
132
- passOnProperties.push(record.body.Message)
149
+ passOnProperties.push(record.body.Message.firstObject)
150
+ passOnProperties.push(record.body.Message.secondObject)
151
+ passOnProperties.push(record.body.Message.relType)
152
+ passOnProperties.push(record.body.Message.relationshipDirection)
153
+ passOnProperties.push(record.body.Message.relationshipProperties)
133
154
  passOnProperties.push(callingFlowSharedLib.addCallingFlowToPassOnProperties(record.body.Message));
134
155
  //(<afterPutParamIntoMainFunction>)
135
156
  //(</afterPutParamIntoMainFunction>)
@@ -41,13 +41,11 @@ function data(_izContext, srcPath) {
41
41
  function createParamForCreateSource(srcPath) {
42
42
  let functionName = FUNCTION_NAME.createRel;
43
43
  let handler = HANDLER.hdrInv
44
- let functionNameConfig = upperCase(functionName) + upperCase(handler)
45
44
  return {
46
45
  templatePath: templatePath,
47
46
  templateData: {
48
47
  functionName,
49
48
  handler,
50
- functionNameConfig
51
49
  },
52
50
  setting: {
53
51
  savePath: path.join(srcPath, SOURCE_PATH.relationshipPerAction),
@@ -31,28 +31,41 @@ const <%- functionName %> = require('./<%- firstLetterUpperCase(functionName) %>
31
31
  // validate event params in middlewware before into function.
32
32
  let validatorSchema = {
33
33
  type: "object",
34
- required: ["objects", "relType"],
34
+ required: ["firstObject", "secondObject", "relType", "relationshipDirection"],
35
35
  properties: {
36
- objects: {
37
- type: "array",
38
- minItems: 2,
39
- maxItems: 2,
40
- items: {
41
- type: 'object',
42
- required: ["objType", "identifiers"],
43
- properties: {
44
- objType: {
45
- type: "object",
46
- required: ["serviceTag", "objectType"],
47
- properties: {
48
- serviceTag: izara.validatorSchema.stringNotEmpty(),
49
- objectType: izara.validatorSchema.stringNotEmpty()
50
- }
51
- },
52
- identifiers: {
53
- type: "object",
54
- minProperties: 1
36
+ firstObject: {
37
+ type: "object",
38
+ required: ["objType", "identifiers"],
39
+ properties: {
40
+ objType: {
41
+ type: "object",
42
+ required: ["serviceTag", "objectType"],
43
+ properties: {
44
+ serviceTag: izara.validatorSchema.stringNotEmpty(),
45
+ objectType: izara.validatorSchema.stringNotEmpty()
55
46
  }
47
+ },
48
+ identifiers: {
49
+ type: "object",
50
+ minProperties: 1
51
+ }
52
+ }
53
+ },
54
+ secondObject: {
55
+ type: "object",
56
+ required: ["objType", "identifiers"],
57
+ properties: {
58
+ objType: {
59
+ type: "object",
60
+ required: ["serviceTag", "objectType"],
61
+ properties: {
62
+ serviceTag: izara.validatorSchema.stringNotEmpty(),
63
+ objectType: izara.validatorSchema.stringNotEmpty()
64
+ }
65
+ },
66
+ identifiers: {
67
+ type: "object",
68
+ minProperties: 1
56
69
  }
57
70
  }
58
71
  },
@@ -68,6 +81,10 @@ let validatorSchema = {
68
81
  },
69
82
  }
70
83
  },
84
+ relationshipDirection: {
85
+ type: "string",
86
+ enum: ['from', "to"]
87
+ },
71
88
  relationshipProperties: {
72
89
  type: 'object',
73
90
  default: {}
@@ -84,11 +101,13 @@ module.exports.main = middleware.wrap(async (event, context, callback) => {
84
101
 
85
102
  try {
86
103
  // invoke LambdaFunction
87
- return await createRelationship.createRelationship(
104
+ return await <%- functionName %>.<%- functionName %>(
88
105
  event._izContext, // correlationId/logger/integrationTestDetail/uniqueRequestId
89
106
  {
90
- objects: event.objects,
107
+ firstObject: event.firstObject,
108
+ secondObject: event.secondObject,
91
109
  relType: event.relType,
110
+ relationshipDirection: event.relationshipDirection,
92
111
  relationshipProperties: event.relationshipProperties,
93
112
  },
94
113
  callingFlowSharedLib.addCallingFlowToPassOnProperties(event)
@@ -41,13 +41,11 @@ function data(_izContext, srcPath) {
41
41
  function createParamForCreateSource(srcPath) {
42
42
  let functionName = FUNCTION_NAME.createRel;
43
43
  let queueName = functionName + upperCase(HANDLER.hdrSqs)
44
- let functionNameConfig = upperCase(functionName) + upperCase(HANDLER.hdrSqs)
45
44
  return {
46
45
  templatePath: templatePath,
47
46
  templateData: {
48
47
  functionName,
49
48
  queueName,
50
- functionNameConfig
51
49
  },
52
50
  setting: {
53
51
  savePath: path.join(srcPath, SOURCE_PATH.relationshipPerAction),
@@ -32,28 +32,41 @@ middleware.setValidatorSchema(recordHandlerSharedLib.baseValidatorSchema());
32
32
  // validate event params in middleware before into function
33
33
  let validatorSchema = {
34
34
  type: "object",
35
- required: ["objects", "relType"],
35
+ required: ["firstObject", "secondObject", "relType", "relationshipDirection"],
36
36
  properties: {
37
- objects: {
38
- type: "array",
39
- minItems: 2,
40
- maxItems: 2,
41
- items: {
42
- type: 'object',
43
- required: ["objType", "identifiers"],
44
- properties: {
45
- objType: {
46
- type: "object",
47
- required: ["serviceTag", "objectType"],
48
- properties: {
49
- serviceTag: izara.validatorSchema.stringNotEmpty(),
50
- objectType: izara.validatorSchema.stringNotEmpty()
51
- }
52
- },
53
- identifiers: {
54
- type: "object",
55
- minProperties: 1
37
+ firstObject: {
38
+ type: "object",
39
+ required: ["objType", "identifiers"],
40
+ properties: {
41
+ objType: {
42
+ type: "object",
43
+ required: ["serviceTag", "objectType"],
44
+ properties: {
45
+ serviceTag: izara.validatorSchema.stringNotEmpty(),
46
+ objectType: izara.validatorSchema.stringNotEmpty()
56
47
  }
48
+ },
49
+ identifiers: {
50
+ type: "object",
51
+ minProperties: 1
52
+ }
53
+ }
54
+ },
55
+ secondObject: {
56
+ type: "object",
57
+ required: ["objType", "identifiers"],
58
+ properties: {
59
+ objType: {
60
+ type: "object",
61
+ required: ["serviceTag", "objectType"],
62
+ properties: {
63
+ serviceTag: izara.validatorSchema.stringNotEmpty(),
64
+ objectType: izara.validatorSchema.stringNotEmpty()
65
+ }
66
+ },
67
+ identifiers: {
68
+ type: "object",
69
+ minProperties: 1
57
70
  }
58
71
  }
59
72
  },
@@ -69,6 +82,10 @@ let validatorSchema = {
69
82
  },
70
83
  }
71
84
  },
85
+ relationshipDirection: {
86
+ type: "string",
87
+ enum: ['from', "to"]
88
+ },
72
89
  relationshipProperties: {
73
90
  type: 'object',
74
91
  default: {}
@@ -107,7 +124,11 @@ let validatorSchema = {
107
124
  );
108
125
 
109
126
  // add argument (to invoke lambda) to passOnProperties[]
110
- passOnProperties.push(record.body.Message)
127
+ passOnProperties.push(record.body.Message.firstObject)
128
+ passOnProperties.push(record.body.Message.secondObject)
129
+ passOnProperties.push(record.body.Message.relType)
130
+ passOnProperties.push(record.body.Message.relationshipDirection)
131
+ passOnProperties.push(record.body.Message.relationshipProperties)
111
132
  passOnProperties.push(callingFlowSharedLib.addCallingFlowToPassOnProperties(record.body.Message));
112
133
  //(<afterPutParamIntoMainFunction>)
113
134
  //(</afterPutParamIntoMainFunction>)
@@ -22,7 +22,7 @@ const fs = require('fs');
22
22
  const { ACTIONS, HANDLER, STORAGE_TYPES } = require('@izara_project/izara-core-library-service-schemas/src/Consts')
23
23
 
24
24
  const { firstLetterLowerCase: lowerCase, firstLetterUpperCase: upperCase } = require("../../../../../../MainLibs/src/Utils")
25
- const { createIamRole, resourceNames, RESOURCE_CLASSES, SQS_RESOURCE, SOURCE_PATH, SAVE_FILE_NAME, FUNCTION_NAME, defaultIamRolePerAction, awaitingMultipleStepsRole, SNS_RESOURCE } = require("../../../../libs/Consts");
25
+ const { createIamRole, resourceNames, RESOURCE_CLASSES, SQS_RESOURCE, SOURCE_PATH, SAVE_FILE_NAME, FUNCTION_NAME, defaultIamRolePerAction, awaitingMultipleStepsRole, SNS_RESOURCE, shortNameHandler, SHORT_FUNCTION_NAME } = require("../../../../libs/Consts");
26
26
 
27
27
  const templatePath = path.join(__dirname, "./template.ejs")
28
28
 
@@ -79,7 +79,8 @@ function createParamForCreateSource(srcPath) {
79
79
  functionName,
80
80
  handlerType,
81
81
  additionalResourcePermission,
82
- resourceLocation: SOURCE_PATH.resourceLocationRelationshipPerAction
82
+ resourceLocation: SOURCE_PATH.resourceLocationRelationshipPerAction,
83
+ functionNameConfig: upperCase(SHORT_FUNCTION_NAME.createRelComplete)
83
84
  },
84
85
  setting: {
85
86
  savePath: path.join(srcPath, SOURCE_PATH.appYaml),
@@ -1,5 +1,5 @@
1
1
  <%_ const join = require('path').join; _%>
2
- <%- firstLetterUpperCase(functionName) %>:
2
+ <%- firstLetterUpperCase(functionNameConfig) %>:
3
3
  handler: <%- join(resourceLocation, `${firstLetterUpperCase(functionName)}_${firstLetterUpperCase(handlerType)}.main`)%>
4
4
  name: ${self:custom.iz_resourcePrefix}<%- firstLetterUpperCase(functionName) %>
5
5
  events:
@@ -41,14 +41,12 @@ function data(_izContext, srcPath) {
41
41
  function createParamForCreateSource(srcPath) {
42
42
  const functionName = FUNCTION_NAME.createRelComplete;
43
43
  const handler = HANDLER.hdrSqs
44
- let functionNameConfig = upperCase(functionName) + upperCase(handler)
45
44
 
46
45
  return {
47
46
  templatePath: templatePath,
48
47
  templateData: {
49
48
  functionName: upperCase(functionName),
50
49
  queueName: upperCase(functionName) + upperCase(handler),
51
- functionNameConfig
52
50
  },
53
51
  setting: {
54
52
  savePath: path.join(srcPath, SOURCE_PATH.relationshipPerAction),