@izara_project/izara-market-library-service-schemas 1.0.35 → 1.0.36

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 (111) hide show
  1. package/package.json +1 -1
  2. package/src/GenerateCodeLibs/src/GenerateCodeLibs.js +2 -1
  3. package/src/MainLibs/src/Consts.js +8 -8
  4. package/src/MainLibs/src/GenerateCodeUtils.js +2 -0
  5. package/src/{reStructure/TemplateData → TemplateManager/src}/attributeTreeSchema/generateTemplateData.js +35 -20
  6. package/src/TemplateManager/src/attributeTreeSchema/referenceRelationshipSchema/data.js +84 -0
  7. package/src/TemplateManager/src/attributeTreeSchema/referenceRelationshipSchema/tempReferenceRelationshipSchema.ejs +9 -0
  8. package/src/{reStructure/TemplateData → TemplateManager/src}/attributeTreeSchema/relationshipSchema/data.js +1 -1
  9. package/src/reStructure/SchemaConfig.js +1 -4
  10. package/src/reStructure/TemplateData/EndpointPerService/mainFunction/create/backupTemplate.ejs +701 -0
  11. package/src/reStructure/TemplateData/EndpointPerService/mainFunction/create/template.ejs +34 -162
  12. package/src/reStructure/TemplateData/EndpointPerService/mainFunction/delete/template.ejs +2 -0
  13. package/src/reStructure/TemplateData/EndpointPerService/mainFunction/get/template.ejs +3 -4
  14. package/src/reStructure/TemplateData/EndpointPerService/mainFunction/update/template.ejs +2 -0
  15. package/src/reStructure/TemplateData/externalService/lambdaRole/data.js +38 -12
  16. package/src/reStructure/TemplateData/externalService/lambdaRole/template.ejs +5 -2
  17. package/src/reStructure/TemplateData/externalService/snsTopicSubscriptions/data.js +22 -14
  18. package/src/reStructure/TemplateData/externalService/snsTopicSubscriptions/template.ejs +4 -1
  19. package/src/reStructure/TemplateData/flowSchema/CreateRecordComplete/mainFunction/template.ejs +68 -33
  20. package/src/reStructure/TemplateData/flowSchema/components/upload/createObject/handler/template.ejs +1 -1
  21. package/src/reStructure/TemplateData/flowSchema/components/upload/createObjectComplete/mainFunction/template.ejs +1 -1
  22. package/src/reStructure/TemplateData/flowSchema/components/upload/preSignUrl/createPresignUrl/mainFunction/template.ejs +1 -1
  23. package/src/reStructure/TemplateData/flowSchema/components/upload/relate/libs/data.js +12 -4
  24. package/src/reStructure/TemplateData/flowSchema/components/upload/relate/libs/template.ejs +13 -8
  25. package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/complete/functionYaml/data.js +16 -13
  26. package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/complete/functionYaml/template.ejs +9 -9
  27. package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/complete/handler/data.js +1 -1
  28. package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/complete/mainFunction/template.ejs +7 -9
  29. package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/dynamoDB/register.js +82 -0
  30. package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/sns-in/data.js +1 -1
  31. package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/sns-in/template.ejs +34 -1
  32. package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/storedCacheTemplate.ejs +10 -33
  33. package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/subscriptionOutAll/data.js +5 -5
  34. package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/subscriptionOutAll/template.ejs +6 -6
  35. package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/wbs/functionYaml/data.js +26 -4
  36. package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/wbs/functionYaml/template.ejs +5 -5
  37. package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/wbs/handler/template.ejs +7 -8
  38. package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/wbs/mainFunction/template.ejs +118 -16
  39. package/src/reStructure/TemplateData/flowSchema/dynamoDb/data.js +83 -44
  40. package/src/reStructure/TemplateData/flowSchema/externalTopic/sns-in-sqs/data.js +4 -5
  41. package/src/reStructure/TemplateData/flowSchema/externalTopic/sns-in-sqs/template.ejs +1 -7
  42. package/src/reStructure/TemplateData/flowSchema/externalTopic/sns-out/data.js +2 -3
  43. package/src/reStructure/TemplateData/flowSchema/externalTopic/sns-out/template.ejs +2 -4
  44. package/src/reStructure/TemplateData/flowSchema/externalTopic/sqs/functionYaml/data.js +31 -3
  45. package/src/reStructure/TemplateData/flowSchema/externalTopic/sqs/functionYaml/template.ejs +4 -4
  46. package/src/reStructure/TemplateData/flowSchema/externalTopic/sqs/handler/data.js +7 -8
  47. package/src/reStructure/TemplateData/flowSchema/externalTopic/sqs/handler/template.ejs +13 -13
  48. package/src/reStructure/TemplateData/flowSchema/externalTopic/sqs/mainFunction/data.js +4 -4
  49. package/src/reStructure/TemplateData/flowSchema/externalTopic/sqs/mainFunction/template.ejs +44 -69
  50. package/src/reStructure/TemplateData/flowSchema/externalTopic/websocket/functionYaml/data.js +4 -6
  51. package/src/reStructure/TemplateData/flowSchema/externalTopic/websocket/functionYaml/template.ejs +2 -2
  52. package/src/reStructure/TemplateData/flowSchema/externalTopic/websocket/handler/data.js +2 -9
  53. package/src/reStructure/TemplateData/flowSchema/externalTopic/websocket/handler/template.ejs +40 -87
  54. package/src/reStructure/TemplateData/flowSchema/externalTopic/websocket/mainFunction/data.js +5 -4
  55. package/src/reStructure/TemplateData/flowSchema/externalTopic/websocket/mainFunction/template.ejs +2 -10
  56. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComplete/functionYaml/data.js +17 -3
  57. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComplete/functionYaml/template.ejs +2 -2
  58. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComplete/mainFunction/data.js +6 -2
  59. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComplete/mainFunction/template.ejs +49 -84
  60. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComponent/functionYaml/data.js +55 -10
  61. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComponent/functionYaml/template.ejs +1 -1
  62. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComponent/handler/data.js +2 -2
  63. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComponent/handler/template.ejs +1 -1
  64. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComponent/mainFunction/data.js +20 -7
  65. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComponent/mainFunction/template.ejs +24 -33
  66. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/FlowSchemaCompleteComponent/functionYaml/data.js +20 -5
  67. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/FlowSchemaCompleteComponent/functionYaml/template.ejs +1 -3
  68. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/FlowSchemaCompleteComponent/handler/data.js +2 -2
  69. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/FlowSchemaCompleteComponent/handler/template.ejs +5 -5
  70. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/FlowSchemaCompleteComponent/mainFunction/data.js +5 -3
  71. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/FlowSchemaCompleteComponent/mainFunction/template.ejs +7 -5
  72. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/FlowSchemaComponent/functionYaml/data.js +6 -3
  73. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/FlowSchemaComponent/functionYaml/template.ejs +0 -2
  74. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/FlowSchemaComponent/handler/data.js +2 -2
  75. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/FlowSchemaComponent/handler/template.ejs +3 -3
  76. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/FlowSchemaComponent/mainFunction/data.js +8 -3
  77. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/FlowSchemaComponent/mainFunction/template.ejs +17 -11
  78. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/sns-in/data.js +14 -8
  79. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/sns-out/data.js +4 -1
  80. package/src/reStructure/TemplateData/flowSchema/generateTemplateData.js +50 -42
  81. package/src/reStructure/TemplateData/generateRole/createSharedResource.js +3 -2
  82. package/src/reStructure/TemplateData/generateRole/sharedResourceTemplate.ejs +3 -0
  83. package/src/reStructure/TemplateData/perActionComplete/create/mainFunction/template.ejs +9 -8
  84. package/src/reStructure/TemplateData/perActionComplete/delete/mainFunction/template.ejs +5 -1
  85. package/src/reStructure/TemplateData/perActionComplete/get/mainFunction/template.ejs +2 -1
  86. package/src/reStructure/TemplateData/processLogical/mainFunction/template.ejs +1 -0
  87. package/src/reStructure/TemplateData/{propertyNodeSchema → propertyValueSchema}/generateTemplateData.js +4 -4
  88. package/src/reStructure/TemplateData/propertyValueSchema/objectPropertyValueSchema/data.js +131 -0
  89. package/src/reStructure/TemplateData/{propertyNodeSchema/relationshipPropertyNodeSchema → propertyValueSchema/relationshipPropertyValueSchema}/data.js +32 -55
  90. package/src/reStructure/TemplateData/propertyValueSchema/relationshipPropertyValueSchema/tempRelationship.ejs +13 -0
  91. package/src/reStructure/TemplateData/propertyValueSchema/relationshipPropertyValueSchema/templateRelationshipPropertyValueSchema.ejs +7 -0
  92. package/src/reStructure/TemplateData/relationshipPerAction/create/action/mainFunction/template.ejs +2 -1
  93. package/src/reStructure/TemplateData/relationshipPerAction/create/complete/mainFunction/template.ejs +2 -1
  94. package/src/reStructure/TemplateData/relationshipPerAction/delete/action/mainFunction/template.ejs +2 -1
  95. package/src/reStructure/TemplateData/relationshipPerAction/delete/complete/handler/sqs/template.ejs +5 -5
  96. package/src/reStructure/TemplateData/relationshipPerAction/delete/complete/mainFunction/template.ejs +5 -4
  97. package/src/reStructure/TemplateData/relationshipPerAction/get/action/mainFunction/template.ejs +2 -1
  98. package/src/reStructure/TemplateData/relationshipPerAction/get/complete/handler/sqs/template.ejs +4 -4
  99. package/src/reStructure/TemplateData/relationshipPerAction/get/complete/mainFunction/template.ejs +4 -3
  100. package/src/reStructure/TemplateData/relationshipPerAction/update/action/mainFunction/template.ejs +2 -1
  101. package/src/reStructure/TemplateData/relationshipPerAction/update/complete/mainFunction/template.ejs +2 -1
  102. package/src/reStructure/TemplateData/resourceYaml/dynamodb/template.ejs +1 -3
  103. package/src/reStructure/TemplateData/resourceYaml/filterGenerateResource/data.js +61 -0
  104. package/src/reStructure/TemplateData/resourceYaml/generateTemplateData.js +13 -4
  105. package/src/reStructure/TemplateData/propertyNodeSchema/objectPropertyNodeSchema/data.js +0 -151
  106. package/src/reStructure/TemplateData/propertyNodeSchema/relationshipPropertyNodeSchema/templateRelationshipPropertyNodeSchema.ejs +0 -7
  107. /package/src/{reStructure/TemplateData → TemplateManager/src}/attributeTreeSchema/mainAttributeTree/attributeLinkTemplate.ejs +0 -0
  108. /package/src/{reStructure/TemplateData → TemplateManager/src}/attributeTreeSchema/mainAttributeTree/data.js +0 -0
  109. /package/src/{reStructure/TemplateData → TemplateManager/src}/attributeTreeSchema/mainAttributeTree/request.json +0 -0
  110. /package/src/{reStructure/TemplateData → TemplateManager/src}/attributeTreeSchema/relationshipSchema/template.ejs +0 -0
  111. /package/src/reStructure/TemplateData/{propertyNodeSchema/objectPropertyNodeSchema/templateObjectPropertyNodeSchema.ejs → propertyValueSchema/objectPropertyValueSchema/templateObjectPropertyValueSchema.ejs} +0 -0
@@ -62,22 +62,11 @@ const { createDataDetailsLib } = require('@izara_project/izara-market-library-se
62
62
  const { createLinkTypeId, createObjType } = require('@izara_project/izara-core-library-service-schemas/src/Utils');
63
63
  const { findLinksByObjTypes } = require("@izara_project/izara-core-library-service-schemas/src/libs/RelSchemaLib")
64
64
  const lodash = require("lodash")
65
+ const { createRelTypeConcat } = require('@izara_project/izara-core-library-service-schemas').utils
66
+ const createNodeLib = require('@izara_project/izara-core-library-service-schemas').createNodeLib
67
+ //(<optionalRequire>)
68
+ //(</optionalRequire>)
65
69
 
66
- /**
67
- - all storageType( DB and Graph) use objInstance({identifiers,fields})
68
- - storageType[DB] async
69
- - storageType[Graph] sync (should be have lambda complete)
70
- -- before DB and Graph have boolend check (allStorageTagComplete = true) if storageType == graph set allStorageTagComplete = false,
71
- and save awaitingMultiplastep prefix(serviceTag_CreateObject{identifierId})
72
-
73
- >>> in lambdaComplete resive message from GrapHandler
74
- 1.1 check have returnValue.errorsFould.length > 0
75
- -- Delete all awitingMultiplestep and senf message to callingFlow have errorFound.
76
- 1.2 check awaitingmultipleStepall finish
77
- -- Delete awaitingStep in come if have other multiplestep(not finish)== not send message.
78
- --- if check awaitingmultipleStepall finish not have record ===> sendmessage to callingFlow.
79
- */
80
- //=========================================================================================
81
70
  /**
82
71
  *
83
72
  * @param {*} _izContext
@@ -128,156 +117,23 @@ module.exports.createMain = async (
128
117
  let createDataDetails = await createDataDetailsLib(_izContext, objectSchemas);
129
118
  _izContext.logger.debug("createDataDetails is =", createDataDetails);
130
119
 
131
- let checkCorrectLinks = [];
132
-
133
- //validate linkType
134
120
  if ((requestParams.hasOwnProperty("relationships")) && (requestParams.relationships.length > 0)) {
121
+ //(<beforeValidateRelationships>)
122
+ //(</beforeValidateRelationships>)
135
123
 
136
- for (let relationshipProperties of requestParams.relationships) {
137
- _izContext.logger.debug("relationshipProperties", relationshipProperties);
138
- _izContext.logger.debug("relType", relationshipProperties.relType);
139
- let getObjectRelationship = await getObjectSchema.getRelationshipSchemaWithCache(
140
- _izContext,
141
- relationshipProperties.relType
142
- )
143
- _izContext.logger.debug("getObjectRelationship", getObjectRelationship)
144
-
145
- for (const relationshipLink of Object.values(getObjectRelationship.links)) {
146
- if (relationshipLink.from.linkType === "many" && relationshipLink.to.linkType === "many") {
147
- if (relationshipLink.from.requiredOnCreate === true || relationshipLink.to.requiredOnCreate === true) {
148
- errorsFound.push("error many to many linkType can't have requireOnCreate === true")
149
- }
150
- }
151
- }
152
- const links = await findLinksByObjTypes(_izContext, [objType, relationshipProperties.targetObjType], getObjectRelationship.links);
153
- _izContext.logger.debug("links", links)
154
-
155
- if (!links.length) {
156
- errorsFound.push(`not found link between ${JSON.stringify({ mainObjType: objType })} and ${JSON.stringify({ toObjType: relationshipProperties.targetObjType })} `)
157
- }
158
-
159
- for (let link of links) {
160
- const { serviceTag: fromServiceTag, objectType: fromObjectType } = objType;
161
- const { serviceTag: toServiceTag, objectType: toObjectType } = relationshipProperties.targetObjType
162
-
163
- const { serviceTag: firstServiceTag, objectType: firstObjectType } = link.from.objType;
164
- const { serviceTag: secondServiceTag, objectType: secondObjectType } = link.to.objType
165
-
166
- const matchesFromTo =
167
- fromServiceTag === firstServiceTag && fromObjectType === firstObjectType &&
168
- toServiceTag === secondServiceTag && toObjectType === secondObjectType;
169
-
170
- const matchesToFrom =
171
- fromServiceTag === secondServiceTag && fromObjectType === secondObjectType &&
172
- toServiceTag === firstServiceTag && toObjectType === firstObjectType
173
-
174
- if ((relationshipProperties.relationshipDirection === "from" && matchesFromTo) ||
175
- (relationshipProperties.relationshipDirection === "to" && matchesToFrom)) {
176
- checkCorrectLinks.push(true)
177
- } else {
178
- checkCorrectLinks.push(false)
179
- }
180
- }
181
- }
182
- }
183
- for (const [index, checkCorrectLink] of checkCorrectLinks.entries()) {
184
- if (checkCorrectLink === false) {
185
- errorsFound.push(`relationship direction ${JSON.stringify(requestParams.relationships[index])} is invalid`)
186
- }
124
+ errorsFound.push(...await createNodeLib.validateRequiredOnCreateLinks(_izContext, objType, requestParams.relationships))
187
125
  }
188
- _izContext.logger.debug("finish validate Relationships from RequestParams")
189
- let requiredOnCreateLinks = {};
190
- let createLinkTypeIds = [];
191
- // validate relationships link
192
- let objectRelationshipSchema = await getObjectSchema.getRequiredOnCreateLinksWithCache(_izContext, objType);
193
- _izContext.logger.debug("objectRelationshipSchema", objectRelationshipSchema);
194
-
195
- // validate requiredOnCreateLinks
196
- let filteredRequiredOnCreatedLinks = [];
197
-
198
- await Promise.all(
199
- objectRelationshipSchema.map(async (requiredLink) => {
200
- const serviceTag = await Promise.all(
201
- requiredLink.storageResourceTags.map(async (storageTag) => {
202
- let storageResource = requiredLink.storageResources[storageTag];
203
- if (storageResource.storageType === consts.STORAGE_TYPES.graph) {
204
- return await getGraphServiceTagWithCache(_izContext, storageResource.graphServerTag);
205
- }
206
- })
207
- );
208
- if (serviceTag) {
209
- filteredRequiredOnCreatedLinks.push(requiredLink);
210
- }
211
- })
212
- )
213
- _izContext.logger.debug("filteredRequiredOnCreatedLinks", filteredRequiredOnCreatedLinks);
214
-
215
- if (filteredRequiredOnCreatedLinks.length) {
216
- if (!requestParams.relationships || !requestParams.relationships.length) {
217
- // in case not send relationship to create with
218
- for (const requireLink of filteredRequiredOnCreatedLinks) {
219
- errorsFound.push(`missing required relationship of relType ${JSON.stringify(requireLink.relType)} when create`)
220
- }
221
- }
126
+ _izContext.logger.debug("errorsFound", errorsFound)
222
127
 
223
- for (const requireLink of filteredRequiredOnCreatedLinks) {
224
- const requiredOnCreateLinkTypeId = createLinkTypeId(
225
- _izContext,
226
- objType,
227
- requireLink.other.objType,
228
- requireLink.relType,
229
- requireLink.base.direction
230
- );
231
-
232
- Object.assign(requiredOnCreateLinks, {
233
- [requiredOnCreateLinkTypeId]: requireLink
234
- })
235
- }
236
-
237
- if (requestParams.hasOwnProperty("relationships") && requestParams.relationships.length) {
238
- for (const createRelationship of requestParams.relationships) {
239
- const onCreateLinkTypeId = createLinkTypeId(
240
- _izContext,
241
- objType,
242
- createRelationship.targetObjType,
243
- createRelationship.relType,
244
- createRelationship.relationshipDirection
245
- );
246
-
247
- if (!requiredOnCreateLinks.hasOwnProperty(onCreateLinkTypeId)) {
248
- errorsFound.push(`relType:${JSON.stringify(createRelationship.relType)} not allow to create when use create action`)
249
- continue;
250
- } else {
251
- createLinkTypeIds.push(onCreateLinkTypeId);
252
- }
253
- }
254
- }
255
- }
256
-
257
-
258
- // validate missing relType when create that should create
259
- const remainRequiredOnCreateLinkTypeIds = Object.keys(requiredOnCreateLinks)
260
- .filter(requiredInCreateLinkTypeId => !createLinkTypeIds.includes(requiredInCreateLinkTypeId))
261
-
262
- if (remainRequiredOnCreateLinkTypeIds.length) {
263
- for (const remainRequiredOnCreateLinkTypeId of remainRequiredOnCreateLinkTypeIds) {
264
- const missingLink = {
265
- relType: requiredOnCreateLinks[remainRequiredOnCreateLinkTypeId].relType,
266
- base: requiredOnCreateLinks[remainRequiredOnCreateLinkTypeId].base.objType,
267
- other: requiredOnCreateLinks[remainRequiredOnCreateLinkTypeId].other.objType
268
- };
269
- errorsFound.push(`Missing Link:: ${JSON.stringify(missingLink)} when create`)
270
- }
271
- }
272
- _izContext.logger.debug("createLinkTypeIds", createLinkTypeIds);
273
- _izContext.logger.debug("requiredOnCreateLinks", requiredOnCreateLinks);
274
128
  // end validate
275
-
276
129
  let objInstanceFull = {
277
130
  identifiers: {},
278
131
  fields: {}
279
132
  };
280
133
 
134
+ //(<optionalObjInstanceFull>)
135
+ //(</optionalObjInstanceFull>)
136
+
281
137
  let listOfRequiredOnCreate = [];
282
138
  let listOfOptionalOnCreate = [];
283
139
 
@@ -404,8 +260,11 @@ module.exports.createMain = async (
404
260
  if (errorsFound.length == 0) {
405
261
 
406
262
  for (let [storageTag, createDataDetail] of Object.entries(createDataDetails)) {
407
-
263
+ //(<beforeCreate>)
264
+ //(</beforeCreate>)
408
265
  if (createDataDetail.storageType == consts.STORAGE_TYPES.dynamoDB) {
266
+ //(<beforeCreateRecordDynamo>)
267
+ //(</beforeCreateRecordDynamo>)
409
268
  _izContext.logger.debug("::::::DynamoDB::::::", { storageTag, objInstanceFull });
410
269
 
411
270
 
@@ -432,6 +291,8 @@ module.exports.createMain = async (
432
291
  }
433
292
  );
434
293
  } else if (createDataDetail.storageType == consts.STORAGE_TYPES.graph) {
294
+ //(<beforeCreateNode>)
295
+ //(</beforeCreateNode>)
435
296
  _izContext.logger.debug("::::::Graph::::::", { storageTag, objInstanceFull });
436
297
 
437
298
  Object.assign(objInstanceFullForGraph.fields, createObjInstanceFullFieldsByStorageTag(_izContext, storageTag, createDataDetail))
@@ -500,7 +361,8 @@ module.exports.createMain = async (
500
361
  });
501
362
 
502
363
  if (objecForCreate.allStorageTagComplete == false) { // needless check because in listOfObjectForCreates push case graph only!
503
-
364
+ //(<beforeSendMessageToGraph>)
365
+ //(</beforeSendMessageToGraph>)
504
366
  messageObject = {
505
367
  objType: objType,
506
368
  objInstanceFull: objecForCreate.objInstanceFull,
@@ -534,6 +396,16 @@ module.exports.createMain = async (
534
396
  };
535
397
  _izContext.logger.debug("RequestParams before send to sqs messageToCreateObject ::::::: ", messageToCreateObject);
536
398
  await sns.publishAsync(_izContext, messageToCreateObject);
399
+
400
+ //(<afterSendMessageToGraph>)
401
+ //(</afterSendMessageToGraph>)
402
+ return {
403
+ objType: objType,
404
+ objInstanceFull: objInstanceFullForGraph,
405
+ relationships: requestParams.relationships || [],
406
+ status: "complete",
407
+ errorsFound: errorsFound
408
+ }
537
409
  };
538
410
  }; // end loop of objectCreate.
539
411
  if (errorsFound.length > 0) {
@@ -574,8 +446,8 @@ module.exports.createMain = async (
574
446
 
575
447
  return {
576
448
  objType: objType,
577
- fieldNames: requestParams.fieldNames,
578
- relationship: requestParams.relationships,
449
+ objInstanceFull: objInstanceFull,
450
+ relationships: requestParams.relationships || [],
579
451
  status: "error",
580
452
  errorsFound: errorsFound
581
453
  }
@@ -612,8 +484,8 @@ module.exports.createMain = async (
612
484
  }
613
485
  return {
614
486
  objType: objType,
615
- fieldNames: requestParams.fieldNames,
616
- relationship: requestParams.relationships,
487
+ objInstanceFull: objInstanceFullForDynamoDb,
488
+ relationships: requestParams.relationships || [],
617
489
  status: "complete",
618
490
  errorsFound: errorsFound
619
491
  }
@@ -621,4 +493,4 @@ module.exports.createMain = async (
621
493
  } catch (err) {
622
494
  throw (err)
623
495
  }
624
- }
496
+ }
@@ -50,6 +50,8 @@ const { TOPIC_NAME_GENERATE_CODE, TOPIC_NAME_GRAPH_HANDLER } = require('@izara_p
50
50
  const { createDeleteDataDetail } = require('@izara_project/izara-market-library-service-schemas/src/GenerateCodeLibs/src/GenerateCodeLibs')
51
51
  const { createObjType } = require("@izara_project/izara-core-library-service-schemas/src/Utils");
52
52
 
53
+ //(<optionalRequire>)
54
+ //(</optionalRequire>)
53
55
  /**
54
56
  *
55
57
  * @param {*} _izContext
@@ -53,6 +53,8 @@ const sns = externalRequest.sns
53
53
  const NoRetryError = require('@izara_project/izara-core-library-core/src/NoRetryError');
54
54
  const { TOPIC_NAME_GENERATE_CODE } = require('@izara_project/izara-market-library-service-schemas/src/GenerateCodeLibs/src/Consts');
55
55
  const coreConsts = require("@izara_project/izara-core-library-core/src/Consts");
56
+ //(<optionalRequire>)
57
+ //(</optionalRequire>)
56
58
  /**
57
59
  *
58
60
  *
@@ -149,10 +151,7 @@ module.exports.getMain = async (
149
151
  if (callingFlowConfig[callingFlowSharedLib.consts.CALLINGFLOW_PROPERTYNAME]) {
150
152
 
151
153
  let messageObject = {
152
- objType: {
153
- objectType: OBJECT_TYPE,
154
- serviceTag: SERVICE_TAG
155
- },
154
+ objType: objType,
156
155
  objInstanceFull: dataFromGraph.objInstanceFull
157
156
  }
158
157
  // send message to SNS ProcessFindRequiredData
@@ -40,6 +40,8 @@ const { createUpdateDataDetail } = require("@izara_project/izara-market-library-
40
40
  const { PREFIX, TOPIC_NAME_GENERATE_CODE, TOPIC_NAME_GRAPH_HANDLER } = require('@izara_project/izara-market-library-service-schemas/src/GenerateCodeLibs/src/Consts');
41
41
  const coreConsts = require('@izara_project/izara-core-library-core/src/Consts')
42
42
  const { createObjType } = require("@izara_project/izara-core-library-service-schemas/src/Utils")
43
+ //(<optionalRequire>)
44
+ //(</optionalRequire>)
43
45
  /**
44
46
  *
45
47
  *
@@ -75,23 +75,26 @@ const createExternalLambdaRole = async (_izContext, allObjSchemas, allRelSchemas
75
75
  if (event.includes("s3")) {
76
76
  const externalLambdaIamRoleGetPresignUrl = await externalLambdaIamRoleUploadS3(_izContext);
77
77
  externalLambdaIamRoleGetPresignUrl && externalLambdaIamRoleArray.push(externalLambdaIamRoleGetPresignUrl);
78
+ } else if (event.includes("extTopic")) {
79
+ const externalSnsPublish = await externalRoleSnsPublish(_izContext, localFlowSchema);
80
+ externalSnsPublish && externalLambdaIamRoleArray.push(externalSnsPublish);
78
81
  }
79
82
  }
80
83
  }
81
- }
82
84
 
83
- // console.log("externalLambdaIamRoleArray", externalLambdaIamRoleArray)
84
- // console.log("createSourceArrayIamRole", JSON.stringify(externalLambdaIamRoleArray))
85
- // return externalLambdaIamRoleArray
85
+ // console.log("externalLambdaIamRoleArray", externalLambdaIamRoleArray)
86
+ // console.log("createSourceArrayIamRole", JSON.stringify(externalLambdaIamRoleArray))
87
+ // return externalLambdaIamRoleArray
86
88
 
87
- return {
88
- templatePath: templatePath,
89
- templateData: { datas: externalLambdaIamRoleArray },
90
- setting: {
91
- savePath: path.join(srcPath, SOURCE_PATH.externalService),
92
- saveFileName: SAVE_FILE_NAME.externalLambdaRole,
93
- fileExtension: ".js",
94
- isAppend: false
89
+ return {
90
+ templatePath: templatePath,
91
+ templateData: { datas: externalLambdaIamRoleArray },
92
+ setting: {
93
+ savePath: path.join(srcPath, SOURCE_PATH.externalService),
94
+ saveFileName: SAVE_FILE_NAME.externalLambdaRole,
95
+ fileExtension: ".js",
96
+ isAppend: false
97
+ }
95
98
  }
96
99
  }
97
100
  }
@@ -274,4 +277,27 @@ function externalLambdaIamRoleUploadS3(_izContext) {
274
277
  }
275
278
  }
276
279
 
280
+ async function externalRoleSnsPublish(_izContext, localFlowSchema) {
281
+
282
+ const additionalResourcePermission = [];
283
+ const flowStepInSplitKey = Object.keys(localFlowSchema.flowSteps)[0].split('_')
284
+ const serviceTag = flowStepInSplitKey[0]
285
+
286
+ additionalResourcePermission.push(
287
+ createIamRole(
288
+ {
289
+ [RESOURCE_CLASSES.sns]: [SNS_RESOURCE.publish]
290
+ },
291
+ [
292
+ externalResourceName(RESOURCE_CLASSES.sns, `${flowStepInSplitKey[2]}_${flowStepInSplitKey[3]}`, serviceTag)
293
+ ]
294
+ )
295
+ )
296
+
297
+ return {
298
+ additionalResourcePermission,
299
+ objectType: SOURCE_GENERATE_IAM_ROLE.ExternalTopicRole,
300
+ };
301
+ }
302
+
277
303
  module.exports = createExternalLambdaRole;
@@ -47,10 +47,13 @@ module.exports.generatedLambdaRole = async () => {
47
47
  ]
48
48
  <%_ }) _%>
49
49
  <%_ }) _%>
50
- }<% if(resourceIdx < data.additionalResourcePermission.length-1) {_%>, <%_} %>
50
+ },<% if(resourceIdx < data.additionalResourcePermission.length-1) {_%>, <%_ } %>
51
51
  <%_ }) _%>
52
+ //(<create<%- data.objectType%>Role>)
53
+ //(</create<%- data.objectType%>Role>)
52
54
  ]
53
- }, <%_ }) %>
55
+ },
56
+ <%_ }) %>
54
57
  ]
55
58
  return externalLambdaRole
56
59
  }
@@ -79,6 +79,8 @@ const createExternalSnsSubscriptions = async (_izContext, allObjSchemas, allRelS
79
79
  const snsServiceConfigForExtTopic = await snsSubscriptionFlowSchemaExternalTopic(_izContext, localFlowSchema);
80
80
  snsServiceConfigForExtTopic && snsServiceConfigArray.push(snsServiceConfigForExtTopic);
81
81
  }
82
+ const snsServiceConfigForCreateRecordByStatusType = await createFlowSchemaRegisterSnsTopicSubscriptions(_izContext, localFlowSchema);
83
+ snsServiceConfigForCreateRecordByStatusType && snsServiceConfigArray.push(snsServiceConfigForCreateRecordByStatusType);
82
84
  }
83
85
  }
84
86
  }
@@ -181,21 +183,27 @@ function snsSubscriptionConfirmReserved(_izContext) {
181
183
  }
182
184
 
183
185
  function snsSubscriptionFlowSchemaExternalTopic(_izContext, localFlowSchema) {
184
- const flowSteps = Object.keys(localFlowSchema.flowSteps || {});
185
- const lastIndex = flowSteps.length - 1;
186
-
187
- if (lastIndex >= 0) {
188
- const flowStep = flowSteps[lastIndex];
189
- const splitFlowStepKey = flowStep.split("_");
190
-
191
- return {
192
- serviceTag: [splitFlowStepKey[0]],
193
- topicName: splitFlowStepKey[2],
194
- sqsEndpoint: splitFlowStepKey[3]
195
- };
196
- }
186
+ const flowStepOut = Object.keys(localFlowSchema.flowSteps)[1]
187
+ const splitFlowStepOutKey = flowStepOut.split("_");
188
+ const queueNameExtTopic = upperCase(FUNCTION_NAME.flowSchemaExternalTopic)
189
+
190
+ return {
191
+ serviceTag: [splitFlowStepOutKey[0]],
192
+ topicName: splitFlowStepOutKey[2] + '_' + splitFlowStepOutKey[3],
193
+ sqsEndpoint: queueNameExtTopic
194
+ };
195
+ }
197
196
 
198
- return null;
197
+ function createFlowSchemaRegisterSnsTopicSubscriptions(_izContext, localFlowSchema) {
198
+ const flowStepKeys = Object.keys(localFlowSchema.flowSteps)[1];
199
+ const flowStepKeySplit = flowStepKeys.split("_");
200
+ const registerCompleteSqs = upperCase(FUNCTION_NAME.flowSchemaRegister);
201
+
202
+ return {
203
+ serviceTag: [flowStepKeySplit[0]],
204
+ topicName: flowStepKeySplit[2],
205
+ sqsEndpoint: registerCompleteSqs,
206
+ }
199
207
  }
200
208
 
201
209
  module.exports = createExternalSnsSubscriptions;
@@ -25,4 +25,7 @@ module.exports.generatedSnsTopicSubscription = [ <% datas.forEach(data => { -%>
25
25
  sqsEndpoint: "<%- data.sqsEndpoint %>"
26
26
  },
27
27
  <% }) _%>
28
- <% }) _%>]
28
+ <% }) _%>
29
+ //(<optionalSubscription>)
30
+ //(</optionalSubscription>)
31
+ ]
@@ -19,7 +19,7 @@ along with this program. If not, see
19
19
  'use strict';
20
20
 
21
21
  const hash = require("object-hash");
22
- const getObjectSchema = require('@izara_project/izara-core-library-service-schemas/src/GetObjectSchema');
22
+ const { getObjectSchema } = require('@izara_project/izara-core-library-service-schemas');
23
23
 
24
24
  const dynamodbSharedLib = require('@izara_project/izara-core-library-dynamodb');
25
25
  const snsSharedLib = require('@izara_project/izara-core-library-sns');
@@ -29,15 +29,16 @@ const lambdaSharedLib = require('@izara_project/izara-core-library-lambda');
29
29
 
30
30
  const externalRequest = require('@izara_project/izara-core-library-external-request');
31
31
  const sns = externalRequest.sns
32
- const { postToConnection } = require("../../../../libs/source/GenerateCodeLibs");
32
+ const { postToConnection } = require("../../../libs/source/GenerateCodeLibs");
33
+
33
34
  const utils = require('@izara_project/izara-market-library-service-schemas/src/MainLibs/src/Utils')
34
- const NoRetryError = require('@izara_project/izara-core-library-core').NoRetryError
35
+ const { NoRetryError } = require('@izara_project/izara-core-library-core')
35
36
  const { v4: uuidv4 } = require('uuid')
36
37
  const coreConsts = require("@izara_project/izara-core-library-core/src/Consts");
37
- const { TOPIC_NAME_GENERATE_CODE } = require('@izara_project/izara-market-library-service-schemas/src/GenerateCodeLibs/src/Consts')
38
+ // const { TOPIC_NAME_GENERATE_CODE } = require('@izara_project/izara-market-library-service-schemas/src/GenerateCodeLibs/src/Consts')
39
+ const { generateCodeLibs: { consts: TOPIC_NAME_GENERATE_CODE } } = require('@izara_project/izara-market-library-service-schemas')
40
+
38
41
  /**
39
- *
40
- *
41
42
  * description of function.
42
43
  * @param {Object} _izContext
43
44
  * @param {CorrelationIds} _izContext.correlationIds - property of _izContext
@@ -46,51 +47,85 @@ const { TOPIC_NAME_GENERATE_CODE } = require('@izara_project/izara-market-librar
46
47
  * @param {Object} requestParams.identifiers - identifiers for get data
47
48
  * @param {Object} requestParams.additionalRequest - additionalRequest
48
49
  *
49
- *
50
50
  * @returns {object} description of return value
51
51
  */
52
-
53
- module.exports.createRecordComplete = async (
52
+ module.exports.<%- functionMain%> = async (
54
53
  _izContext,
55
54
  requestParams,
56
55
  callingFlowConfig = {},
57
56
  //(<additionalParams>)
58
57
  //(</additionalParams>)
59
58
  ) => {
60
-
61
59
  try {
62
- _izContext.logger.debug("createRecordComplete _izContext", _izContext)
63
- _izContext.logger.debug("createRecordComplete requestParams", requestParams)
64
- _izContext.logger.debug("createRecordComplete callingFlowConfig", callingFlowConfig)
60
+ _izContext.logger.debug("WebSocketInvoke _izContext", _izContext)
61
+ _izContext.logger.debug("WebSocketInvoke requestParams", requestParams)
62
+ _izContext.logger.debug("WebSocketInvoke callingFlowConfig", callingFlowConfig)
65
63
 
66
- //(<endpointCompleteHookMainFunction>)
67
- //(</endpointCompleteHookMainFunction>)
64
+ const connectionId = requestContext.connectionId;
65
+ let correlationId = _izContext.correlationIds.get(consts.X_CORRELATION_ID);
68
66
 
69
- await dynamodbSharedLib.updateItem(_izContext,
70
- await dynamodbSharedLib.tableName(_izContext, "WebSocketTask"),
71
- {
72
- taskKey: _izContext.correlationIds.get(coreConsts.X_CORRELATION_ID),
73
- connectionId: _izContext.correlationIds.get(coreConsts.CONNECTION_ID)
74
- },
67
+ const getRegisterRecords = await dynamodbSharedLib.getItem(
68
+ _izContext,
69
+ await dynamodbSharedLib.tableName(_izContext, "RegisterRecords"),
75
70
  {
76
- identifiersTask: requestParams.objInstaceFull.identifiers
71
+ taskKey: correlationId,
72
+ connectionId: connectionId,
77
73
  }
78
- )
74
+ );
75
+ _izContext.logger.debug("getRegisterRecords", getRegisterRecords)
76
+ if (!getRegisterRecords) {
77
+ throw new NoRetryError(`connectionId not found ${connectionId}`)
78
+ }
79
79
 
80
- let messageObject = {
81
- //(<messageObjectHook>)
82
- //(</messageObjectHook>)
80
+ const flowType = getRegisterRecords.flowType;
81
+ const flowTag = flowType.split('_')[0];
82
+ const getFlowSchema = await getObjectSchema.getFlowSchemaS3WithCache(_izContext, {
83
+ flowTag: flowTag,
84
+ serviceTag: process.env.iz_serviceTag
85
+ })
86
+ _izContext.logger.debug("getFlowSchema", getFlowSchema)
87
+ if (!getFlowSchema) {
88
+ throw new NoRetryError(`flowTag not found ${flowTag}`)
83
89
  }
84
90
 
85
- let sendMessageToOutFlowSchema = {
86
- Message: JSON.stringify(messageObject),
87
- TopicArn: await snsSharedLib.snsTopicArnByFlowSchema(_izContext, "<%- topicArn %>", <% if (serviceTag) { %> "<%- serviceTag %>" <% } %> %>)
88
- };
89
- _izContext.logger.debug("before sendMessageToOutFlowSchema::", sendMessageToOutFlowSchema);
90
- await sns.publishAsync(_izContext, sendMessageToOutFlowSchema)
91
+ switch (flowSchema.statusType) {
92
+ case "statusField":
93
+ let payload = {
94
+ identifiers: requestParams.identifiers,
95
+ objectType: flowSchema.objType.objectType
96
+ }
97
+ let result = await externalRequest.lambda.invokeSync(
98
+ _izContext,
99
+ await lambdaSharedLib.lambdaFunctionName(_izContext, "GetHdrInv", flowSchema.objType.serviceTag),
100
+ payload
101
+ )
102
+ if (!result) {
103
+ throw new NoRetryError(`statusField not found ${requestParams.identifiers}`)
104
+ }
105
+ return result
106
+ case "storedCache":
107
+ // if statusType=storedCache then query storedCache > post message to client -> remove connectionId if status = error || complete
108
+ const getStoredCache = await dynamodbSharedLib.getItem(
109
+ _izContext,
110
+ await dynamodbSharedLib.tableName(_izContext, flowSchema.flowTag + "Main"),
111
+ {
112
+ taskKey: requestParams.identifiers,
113
+ connectionId: requestParams.connectionId
114
+ }
115
+ )
116
+ if (!getStoredCache) {
117
+ throw new NoRetryError(`storedCache not found ${requestParams.identifiers}`)
118
+ }
119
+ return getStoredCache
120
+ case "none":
121
+ // if statusType=none -> post message to client ---- not remove connectionId when post message, can remove connectionId when cannot use connectionId only(user disconnect)
122
+ break
123
+ default:
124
+ throw new NoRetryError(`statusType not found ${flowSchema.statusType}`)
125
+ }
91
126
 
92
127
  } catch (err) {
93
- _izContext.logger.error('error FlowSchemaOwnTopicEndpointComplete: ', err)
128
+ _izContext.logger.error('error WebSocketInvoke: ', err)
94
129
  throw (err)
95
130
  }
96
131
  }
@@ -26,7 +26,7 @@ const callingFlowSharedLib = require('@izara_project/izara-core-library-calling-
26
26
  const hash = require('object-hash')
27
27
  // const coreConsts = require("@izara_project/izara-core-library-core/src/Consts");
28
28
  const consts = require('@izara_project/izara-middleware/src/MiddlewareCore/Consts')
29
- const { postToConnection } = require("../../libs/source/GenerateCodeLibs");
29
+ const { postToConnection } = require('../../../libs/source/GenerateCodeLibs')
30
30
  const createObject = require('./CreateObjectS3_Main');
31
31
  module.exports.main = middleware.wrap(async (event, context, callback) => {
32
32
 
@@ -21,7 +21,7 @@ const snsSharedLib = require('@izara_project/izara-core-library-sns');
21
21
  const asyncFlowSharedLib = require('@izara_project/izara-core-library-asynchronous-flow');
22
22
  let coreConsts = require('@izara_project/izara-middleware/src/MiddlewareCore/Consts')
23
23
 
24
- const { postToConnection } = require('../../libs/source/GenerateCodeLibs')
24
+ const { postToConnection } = require('../../../libs/source/GenerateCodeLibs')
25
25
  module.exports.webSocketTaskComplete = async (
26
26
  _izContext,
27
27
  objType,
@@ -32,7 +32,7 @@ const client = new S3Client({ region: 'us-east-2' });
32
32
  const { createPresignedPost } = require('@aws-sdk/s3-presigned-post');
33
33
  const consts = require('@izara_project/izara-middleware/src/MiddlewareCore/Consts')
34
34
 
35
- const { postToConnection,getNestObject } = require("../../libs/source/GenerateCodeLibs");
35
+ const { postToConnection,getNestObject } = require('../../../../libs/source/GenerateCodeLibs')
36
36
  const hash = require('object-hash');
37
37
  const utils = require('@izara_project/izara-market-library-service-schemas/src/MainLibs/src/Utils');
38
38
  const coreConsts = require('@izara_project/izara-core-library-core/src/Consts');
@@ -22,14 +22,22 @@ const { SOURCE_PATH, SAVE_FILE_NAME } = require('../../../../../../../MainLibs/s
22
22
 
23
23
  const templatePath = path.join(__dirname, "./template.ejs")
24
24
 
25
- function data(_izContext, srcPath) {
26
- return [createSourceParams(_izContext, srcPath)]
25
+ function data(_izContext, flowSchema, srcPath) {
26
+ return [createSourceParams(_izContext,flowSchema, srcPath)]
27
27
  };
28
28
 
29
- function createSourceParams(_izContext, srcPath) {
29
+ function createSourceParams(_izContext, flowSchema, srcPath) {
30
+ let uploadS3 = false;
31
+ for (const event of flowSchema.event) {
32
+ if (event.includes("s3")) {
33
+ uploadS3 = true
34
+ }
35
+ }
30
36
  return {
31
37
  templatePath: templatePath,
32
- templateData: {},
38
+ templateData: {
39
+ uploadS3
40
+ },
33
41
  setting: {
34
42
  saveFileName: "GenerateCodeLibs",
35
43
  savePath: path.join(srcPath, SOURCE_PATH.generateCodeLib),