@izara_project/izara-market-library-service-schemas 1.0.17 → 1.0.19

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 (114) hide show
  1. package/package.json +4 -4
  2. package/src/GenerateCodeLibs/src/Consts.js +32 -2
  3. package/src/GenerateCodeLibs/src/GenerateCodeLibs.js +27 -61
  4. package/src/SourceManager/src/Utils.js +16 -1
  5. package/src/TemplateManager/src/FindData/FindDataYaml/data.js +0 -9
  6. package/src/TemplateManager/src/GenerateCode.js +133 -33
  7. package/src/TemplateManager/src/OutPerActionComplete/OutCreateComplete/functionYaml/data.js +1 -1
  8. package/src/TemplateManager/src/OutPerActionComplete/OutDeleteComplete/functionYaml/data.js +1 -1
  9. package/src/TemplateManager/src/OutPerActionComplete/OutUpdateComplete/functionYaml/data.js +1 -1
  10. package/src/TemplateManager/src/OutPerActionComplete/OutUpdateComplete/mainFunction/template.ejs +1 -1
  11. package/src/TemplateManager/src/PerActionEndpoint/Handler/HdrDsq/template.ejs +2 -2
  12. package/src/TemplateManager/src/PerActionEndpoint/Handler/HdrSqs/template.ejs +2 -2
  13. package/src/TemplateManager/src/PerActionEndpoint/MainFunction/Create/template.ejs +78 -47
  14. package/src/TemplateManager/src/PerActionEndpoint/MainFunction/Delete/template.ejs +0 -1
  15. package/src/TemplateManager/src/PerActionEndpoint/MainFunction/Get/template.ejs +13 -11
  16. package/src/TemplateManager/src/PerActionEndpoint/MainFunction/Update/template.ejs +57 -13
  17. package/src/TemplateManager/src/{flowTag/webSocket/websocketHandler/lambda → PerActionEndpoint/libs}/data.js +12 -21
  18. package/src/TemplateManager/src/PerActionEndpoint/libs/template.ejs +46 -0
  19. package/src/TemplateManager/src/RelationshipPerAction/CreateRelationship/createRelationshipComplete/mainFunction/template.ejs +1 -1
  20. package/src/TemplateManager/src/RelationshipPerAction/DeleteRelationship/DeleteRelationshipComplete/mainFunction/template.ejs +1 -1
  21. package/src/TemplateManager/src/RelationshipPerAction/UpdateRelationshipSchema/updateRalationshipComplete/mainFunction/template.ejs +1 -1
  22. package/src/TemplateManager/src/ResourceYaml/dynamodb/defaultDynamoDbTable.js +15 -0
  23. package/src/TemplateManager/src/externalService/LambdaRole/data.js +120 -23
  24. package/src/TemplateManager/src/externalService/LambdaRole/template.ejs +3 -4
  25. package/src/TemplateManager/src/externalService/SnsTopicSubscriotions/data.js +31 -6
  26. package/src/TemplateManager/src/flowSchema/DefaultWebSocketResource/dynamoDb/ReservedTableData.js +65 -0
  27. package/src/TemplateManager/src/{flowTag/webSocket → flowSchema/DefaultWebSocketResource}/webSocketConnect/functionYaml/data.js +23 -5
  28. package/src/TemplateManager/src/flowSchema/DefaultWebSocketResource/webSocketConnect/functionYaml/template.ejs +29 -0
  29. package/src/TemplateManager/src/{flowTag/webSocket → flowSchema/DefaultWebSocketResource}/webSocketConnect/handler/data.js +3 -3
  30. package/src/TemplateManager/src/{flowTag/webSocket → flowSchema/DefaultWebSocketResource}/webSocketConnect/handler/template.ejs +19 -14
  31. package/src/TemplateManager/src/{flowTag/webSocket/websocketHandler → flowSchema/FlowSchemaEndpoint/InProcessFlowSchema}/functionYaml/data.js +29 -27
  32. package/src/TemplateManager/src/flowSchema/FlowSchemaEndpoint/InProcessFlowSchema/functionYaml/template.ejs +37 -0
  33. package/src/TemplateManager/src/flowSchema/FlowSchemaEndpoint/InProcessFlowSchema/handler/data.js +47 -0
  34. package/src/TemplateManager/src/flowSchema/FlowSchemaEndpoint/InProcessFlowSchema/handler/template.ejs +103 -0
  35. package/src/TemplateManager/src/flowSchema/FlowSchemaEndpoint/InProcessFlowSchema/mainFunction/data.js +46 -0
  36. package/src/TemplateManager/src/flowSchema/FlowSchemaEndpoint/InProcessFlowSchema/mainFunction/template.ejs +0 -0
  37. package/src/TemplateManager/src/flowSchema/FlowSchemaEndpoint/InProcessFlowSchema/sns-sqs/data.js +36 -0
  38. package/src/TemplateManager/src/flowSchema/FlowSchemaEndpoint/InProcessFlowSchema/sns-sqs/template.ejs +0 -0
  39. package/src/TemplateManager/src/flowSchema/FlowSchemaEndpoint/OutComplete/functionYaml/data.js +35 -0
  40. package/src/TemplateManager/src/flowSchema/FlowSchemaEndpoint/OutComplete/functionYaml/template.ejs +0 -0
  41. package/src/TemplateManager/src/flowSchema/FlowSchemaEndpoint/OutComplete/handler/data.js +35 -0
  42. package/src/TemplateManager/src/flowSchema/FlowSchemaEndpoint/OutComplete/handler/template.ejs +0 -0
  43. package/src/TemplateManager/src/flowSchema/FlowSchemaEndpoint/OutComplete/mainFunction/data.js +35 -0
  44. package/src/TemplateManager/src/flowSchema/FlowSchemaEndpoint/OutComplete/mainFunction/template.ejs +0 -0
  45. package/src/TemplateManager/src/flowSchema/FlowSchemaEndpoint/OutComplete/sns-sqs/data.js +35 -0
  46. package/src/TemplateManager/src/flowSchema/FlowSchemaEndpoint/OutComplete/sns-sqs/template.ejs +0 -0
  47. package/src/TemplateManager/src/flowSchema/UploadS3Case/confirmReservedAfterUpload/functionYaml/data.js +102 -0
  48. package/src/TemplateManager/src/flowSchema/UploadS3Case/confirmReservedAfterUpload/functionYaml/template.ejs +30 -0
  49. package/src/TemplateManager/src/flowSchema/UploadS3Case/confirmReservedAfterUpload/handler/data.js +58 -0
  50. package/src/TemplateManager/src/flowSchema/UploadS3Case/confirmReservedAfterUpload/handler/template.ejs +126 -0
  51. package/src/TemplateManager/src/flowSchema/UploadS3Case/confirmReservedAfterUpload/mainFunction/data.js +51 -0
  52. package/src/TemplateManager/src/flowSchema/UploadS3Case/confirmReservedAfterUpload/mainFunction/template.ejs +121 -0
  53. package/src/TemplateManager/src/flowSchema/UploadS3Case/confirmReservedAfterUpload/queue/data.js +64 -0
  54. package/src/TemplateManager/src/flowSchema/UploadS3Case/confirmReservedAfterUpload/queue/template.ejs +45 -0
  55. package/src/TemplateManager/src/flowSchema/UploadS3Case/createObject/functionYaml/data.js +122 -0
  56. package/src/TemplateManager/src/flowSchema/UploadS3Case/createObject/functionYaml/template.ejs +37 -0
  57. package/src/TemplateManager/src/flowSchema/UploadS3Case/createObject/handler/data.js +72 -0
  58. package/src/TemplateManager/src/flowSchema/UploadS3Case/createObject/handler/template.ejs +107 -0
  59. package/src/TemplateManager/src/flowSchema/UploadS3Case/createObject/mainFunction/data.js +55 -0
  60. package/src/TemplateManager/src/flowSchema/UploadS3Case/createObject/mainFunction/template.ejs +133 -0
  61. package/src/TemplateManager/src/flowSchema/UploadS3Case/createObjectComplete/functionYaml/data.js +102 -0
  62. package/src/TemplateManager/src/flowSchema/UploadS3Case/createObjectComplete/functionYaml/template.ejs +30 -0
  63. package/src/TemplateManager/src/flowSchema/UploadS3Case/createObjectComplete/handler/data.js +58 -0
  64. package/src/TemplateManager/src/flowSchema/UploadS3Case/createObjectComplete/handler/template.ejs +103 -0
  65. package/src/TemplateManager/src/flowSchema/UploadS3Case/createObjectComplete/mainFunction/data.js +55 -0
  66. package/src/TemplateManager/src/flowSchema/UploadS3Case/createObjectComplete/mainFunction/template.ejs +86 -0
  67. package/src/TemplateManager/src/flowSchema/UploadS3Case/createObjectComplete/sns-sqs/data.js +72 -0
  68. package/src/TemplateManager/src/flowSchema/UploadS3Case/createObjectComplete/sns-sqs/template.ejs +49 -0
  69. package/src/TemplateManager/src/flowSchema/UploadS3Case/createPresignUrl/getsignUrlsAcc/functionYaml/data.js +85 -0
  70. package/src/TemplateManager/src/flowSchema/UploadS3Case/createPresignUrl/getsignUrlsAcc/functionYaml/template.ejs +27 -0
  71. package/src/TemplateManager/src/flowSchema/UploadS3Case/createPresignUrl/getsignUrlsAcc/handler/data.js +57 -0
  72. package/src/TemplateManager/src/flowSchema/UploadS3Case/createPresignUrl/getsignUrlsAcc/handler/template.ejs +120 -0
  73. package/src/TemplateManager/src/flowSchema/UploadS3Case/createPresignUrl/getsignUrlsAcc/mainFunction/data.js +51 -0
  74. package/src/TemplateManager/src/flowSchema/UploadS3Case/createPresignUrl/getsignUrlsAcc/mainFunction/template.ejs +164 -0
  75. package/src/TemplateManager/src/flowSchema/UploadS3Case/createPresignUrl/getsignUrlsAcc/sqs/data.js +65 -0
  76. package/src/TemplateManager/src/flowSchema/UploadS3Case/createPresignUrl/getsignUrlsAcc/sqs/template.ejs +53 -0
  77. package/src/TemplateManager/src/flowSchema/UploadS3Case/createPresignUrl/reservedLimitComplete/functionYaml/data.js +112 -0
  78. package/src/TemplateManager/src/flowSchema/UploadS3Case/createPresignUrl/reservedLimitComplete/functionYaml/template.ejs +30 -0
  79. package/src/TemplateManager/src/flowSchema/UploadS3Case/createPresignUrl/reservedLimitComplete/handler/data.js +57 -0
  80. package/src/TemplateManager/src/flowSchema/UploadS3Case/createPresignUrl/reservedLimitComplete/handler/template.ejs +126 -0
  81. package/src/TemplateManager/src/flowSchema/UploadS3Case/createPresignUrl/reservedLimitComplete/mainFunction/data.js +54 -0
  82. package/src/TemplateManager/src/flowSchema/UploadS3Case/createPresignUrl/reservedLimitComplete/mainFunction/template.ejs +254 -0
  83. package/src/TemplateManager/src/flowSchema/UploadS3Case/createPresignUrl/reservedLimitComplete/queue/data.js +64 -0
  84. package/src/TemplateManager/src/flowSchema/UploadS3Case/createPresignUrl/reservedLimitComplete/queue/template.ejs +45 -0
  85. package/src/TemplateManager/src/flowSchema/UploadS3Case/hookCode/handler/data.js +94 -0
  86. package/src/TemplateManager/src/flowSchema/UploadS3Case/hookCode/handler/templateAsyncHandler.ejs +110 -0
  87. package/src/TemplateManager/src/flowSchema/UploadS3Case/hookCode/handler/templateSyncHandler.ejs +49 -0
  88. package/src/TemplateManager/src/flowSchema/UploadS3Case/hookCode/hookLogic/data.js +44 -0
  89. package/src/TemplateManager/src/flowSchema/UploadS3Case/hookCode/mainFunction/data.js +66 -0
  90. package/src/TemplateManager/src/flowSchema/UploadS3Case/hookCode/mainFunction/template.ejs +7 -0
  91. package/src/TemplateManager/src/flowSchema/UploadS3Case/hookCode/queue/data.js +73 -0
  92. package/src/TemplateManager/src/flowSchema/UploadS3Case/hookCode/queue/snsTemplate.ejs +59 -0
  93. package/src/TemplateManager/src/flowSchema/UploadS3Case/hookCode/queue/sqsTemplate.ejs +43 -0
  94. package/src/TemplateManager/src/flowSchema/UploadS3Case/processFileS3AfterUpload/functionYml/HdrDsq/data.js +87 -0
  95. package/src/TemplateManager/src/flowSchema/UploadS3Case/processFileS3AfterUpload/functionYml/HdrDsq/template.ejs +30 -0
  96. package/src/TemplateManager/src/flowSchema/UploadS3Case/processFileS3AfterUpload/functionYml/HdrS3/data.js +112 -0
  97. package/src/TemplateManager/src/{flowTag/webSocket/websocketHandler/functionYaml → flowSchema/UploadS3Case/processFileS3AfterUpload/functionYml/HdrS3}/template.ejs +10 -5
  98. package/src/TemplateManager/src/flowSchema/UploadS3Case/processFileS3AfterUpload/handler/handlerDsq/data.js +45 -0
  99. package/src/TemplateManager/src/flowSchema/UploadS3Case/processFileS3AfterUpload/handler/handlerDsq/template.ejs +151 -0
  100. package/src/TemplateManager/src/flowSchema/UploadS3Case/processFileS3AfterUpload/handler/handlerS3/data.js +43 -0
  101. package/src/TemplateManager/src/flowSchema/UploadS3Case/processFileS3AfterUpload/handler/handlerS3/template.ejs +68 -0
  102. package/src/TemplateManager/src/flowSchema/UploadS3Case/processFileS3AfterUpload/mainFunction/data.js +43 -0
  103. package/src/TemplateManager/src/flowSchema/UploadS3Case/processFileS3AfterUpload/mainFunction/template.ejs +392 -0
  104. package/src/TemplateManager/src/flowSchema/UploadS3Case/processFileS3AfterUpload/queue/data.js +77 -0
  105. package/src/TemplateManager/src/flowSchema/UploadS3Case/processFileS3AfterUpload/queue/dsqTemplatePath.ejs +32 -0
  106. package/src/TemplateManager/src/flowSchema/UploadS3Case/processFileS3AfterUpload/queue/s3Template.ejs +59 -0
  107. package/src/TemplateManager/src/flowSchema/UploadS3Case/relate/S3/data.js +51 -0
  108. package/src/TemplateManager/src/flowSchema/UploadS3Case/relate/S3/template.ejs +13 -0
  109. package/src/TemplateManager/src/flowSchema/UploadS3Case/relate/libs/data.js +42 -0
  110. package/src/TemplateManager/src/flowSchema/UploadS3Case/relate/libs/template.ejs +137 -0
  111. package/src/TemplateManager/src/libs/Consts.js +60 -28
  112. package/src/TemplateManager/src/flowTag/webSocket/webSocketConnect/functionYaml/template.ejs +0 -10
  113. package/src/TemplateManager/src/flowTag/webSocket/websocketHandler/lambda/template.ejs +0 -131
  114. /package/src/TemplateManager/src/{flowTag/resources/dynamoDb/data.js → flowSchema/DefaultWebSocketResource/dynamoDb/WebSocketTaskData.js} +0 -0
@@ -16,19 +16,22 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
16
16
  */
17
17
 
18
18
  'use strict';
19
- const asyncFlowSharedLib = require('@izara_project/izara-shared/src/AsyncFlowSharedLib');
20
- const dynamodbSharedLib = require('@izara_project/izara-shared/src/DynamodbSharedLib');
21
- const lambdaSharedLib = require('@izara_project/izara-shared/src/LambdaSharedLib')
22
- const callingFlowSharedLib = require('@izara_project/izara-shared/src/CallingFlowSharedLib');
23
-
24
- const sns = require('@izara_project/izara-core-library-external-request/src/resources/Sns');
19
+ const izaraShared = require('@izara_project/izara-shared');
20
+ const asyncFlowSharedLib = izaraShared.asyncFlowSharedLib;
21
+ const dynamodbSharedLib = izaraShared.dynamodbSharedLib;
22
+ const lambdaSharedLib = izaraShared.lambdaSharedLib;
23
+ const callingFlowSharedLib = izaraShared.callingFlowSharedLib;
25
24
  const snsSharedLib = require('@izara_project/izara-shared/src/SnsSharedLib');
25
+
26
+ const externalRequest = require('@izara_project/izara-core-library-external-request');
27
+ const sns = externalRequest.sns;
28
+ const lambda = externalRequest.lambda
29
+
26
30
  const getObjectSchema = require('@izara_project/izara-core-library-service-schemas/src/GetObjectSchema');
27
31
  const serviceConfigLib = require('@izara_project/izara-core-library-service-schemas/src/ServiceConfig')
28
32
 
29
33
  const uploadUseCase = require('@izara_project/izara-core-library-service-schemas/src/libs/UploadUseCase')
30
34
 
31
-
32
35
  const hash = require("object-hash")
33
36
  const NoRetryError = require('@izara_project/izara-core-library-core/src/NoRetryError');
34
37
  const path = require('path')
@@ -61,6 +64,7 @@ const { createLinkTypeId } = require('@izara_project/izara-core-library-service-
61
64
  const { findLinksByObjTypes } = require("@izara_project/izara-core-library-service-schemas/src/libs/RelSchemaLib")
62
65
  const lodash = require("lodash")
63
66
 
67
+
64
68
  /**
65
69
  - all storageType( DB and Graph) use objInstance({identifiers,fields})
66
70
  - storageType[DB] async
@@ -97,6 +101,7 @@ module.exports.<%- functionName %>Main = async (
97
101
  let errorsFound = [];
98
102
 
99
103
  const userId = _izContext.correlationIds.get(coreConsts.BASE_USER_ID);
104
+ const targetId = _izContext.correlationIds.get(coreConsts.TARGET_ID)
100
105
  if (!userId) {
101
106
  errorsFound.push("Not have userId")
102
107
  }
@@ -105,12 +110,10 @@ module.exports.<%- functionName %>Main = async (
105
110
  const SERVICE_TAG = process.env.iz_serviceTag;
106
111
  //(<beforeQuery>)
107
112
  //(</beforeQuery>)
108
-
109
113
  const MAIN_OBJTYPE = {
110
114
  objectType: OBJECT_TYPE,
111
115
  serviceTag: SERVICE_TAG
112
116
  }
113
- //test npm install from local
114
117
  let objectSchema = await getObjectSchema.getObjSchemaS3WithCache(
115
118
  _izContext,
116
119
  MAIN_OBJTYPE
@@ -123,6 +126,10 @@ module.exports.<%- functionName %>Main = async (
123
126
  );
124
127
  _izContext.logger.debug("objectSchemas", objectSchemas);
125
128
 
129
+ if (objectSchema.hasOwnProperty("belongTo") && !targetId) {
130
+ errorsFound.push('not have targetId')
131
+ }
132
+
126
133
  let createDataDetails = await createDataDetailsLib(_izContext, objectSchemas);
127
134
  _izContext.logger.debug("createDataDetails is =", createDataDetails);
128
135
 
@@ -183,7 +190,7 @@ module.exports.<%- functionName %>Main = async (
183
190
  errorsFound.push(`relationship direction ${JSON.stringify(requestParams.relationships[index])} is invalid`)
184
191
  }
185
192
  }
186
-
193
+ _izContext.logger.debug("finish validate Relationships from RequestParams")
187
194
  let requiredOnCreateLinks = {};
188
195
  let createLinkTypeIds = [];
189
196
  // validate relationships link
@@ -232,24 +239,27 @@ module.exports.<%- functionName %>Main = async (
232
239
  })
233
240
  }
234
241
 
235
- for (const createRelationship of requestParams.relationships) {
236
- const onCreateLinkTypeId = createLinkTypeId(
237
- _izContext,
238
- MAIN_OBJTYPE,
239
- createRelationship.targetObjType,
240
- createRelationship.relType,
241
- createRelationship.relationshipDirection
242
- );
242
+ if (requestParams.hasOwnProperty("relationships") && requestParams.relationships.length) {
243
+ for (const createRelationship of requestParams.relationships) {
244
+ const onCreateLinkTypeId = createLinkTypeId(
245
+ _izContext,
246
+ MAIN_OBJTYPE,
247
+ createRelationship.targetObjType,
248
+ createRelationship.relType,
249
+ createRelationship.relationshipDirection
250
+ );
243
251
 
244
- if (!requiredOnCreateLinks.hasOwnProperty(onCreateLinkTypeId)) {
245
- errorsFound.push(`relType:${JSON.stringify(createRelationship.relType)} not allow to create when use create action`)
246
- continue;
247
- } else {
248
- createLinkTypeIds.push(onCreateLinkTypeId);
252
+ if (!requiredOnCreateLinks.hasOwnProperty(onCreateLinkTypeId)) {
253
+ errorsFound.push(`relType:${JSON.stringify(createRelationship.relType)} not allow to create when use create action`)
254
+ continue;
255
+ } else {
256
+ createLinkTypeIds.push(onCreateLinkTypeId);
257
+ }
249
258
  }
250
259
  }
251
260
  }
252
261
 
262
+
253
263
  // validate missing relType when create that should create
254
264
  const remainRequiredOnCreateLinkTypeIds = Object.keys(requiredOnCreateLinks)
255
265
  .filter(requiredInCreateLinkTypeId => !createLinkTypeIds.includes(requiredInCreateLinkTypeId))
@@ -285,28 +295,20 @@ module.exports.<%- functionName %>Main = async (
285
295
  _izContext.logger.debug(":::::case single identifer:::::", identifier);
286
296
 
287
297
  if (objectSchemas.fieldNames[identifier.fieldName].hasOwnProperty("randomOnCreate")) {
288
-
289
298
  if ((objectSchemas.fieldNames[identifier.fieldName].randomOnCreate == true)) {
290
- if ((objectSchemas.fieldNames[identifier.fieldName].requiredOnCreate == false) &&
291
- (objectSchemas.fieldNames[identifier.fieldName].optionalOnCreate == false) &&
292
- (objectSchemas.fieldNames[identifier.fieldName].canUpdate == false)
293
- ) {
294
-
295
- Object.assign(requestParams.fieldNames, {
296
- [identifier.fieldName]: hash({
297
- fieldNames: identifier, //
298
- uniqueRequestId: _izContext.uniqueRequestId,
299
- callingFlowConfig: callingFlowConfig
300
- })
301
- });
302
- _izContext.logger.debug("Assign requestParams", requestParams)
303
- }
299
+ Object.assign(requestParams.fieldNames, {
300
+ [identifier.fieldName]: hash({
301
+ fieldNames: identifier, //
302
+ uniqueRequestId: _izContext.uniqueRequestId,
303
+ callingFlowConfig: callingFlowConfig
304
+ })
305
+ });
306
+ _izContext.logger.debug("Assign requestParams", requestParams)
304
307
 
305
308
  } else if ((objectSchemas.fieldNames[identifier.fieldName].randomOnCreate == false) ||
306
309
  (objectSchemas.fieldNames[identifier.fieldName].randomOnCreate == null)) {
307
310
 
308
311
  if ((objectSchemas.fieldNames[identifier.fieldName].requiredOnCreate == true) &&
309
- ((objectSchemas.fieldNames[identifier.fieldName].optionalOnCreate == false) || objectSchemas.fieldNames[identifier.fieldName].optionalOnCreate == true) &&
310
312
  (objectSchemas.fieldNames[identifier.fieldName].canUpdate == false)) {
311
313
  // check Fns have resive
312
314
 
@@ -329,7 +331,6 @@ module.exports.<%- functionName %>Main = async (
329
331
  };
330
332
  }
331
333
 
332
-
333
334
  _izContext.logger.debug("requestParams is:", requestParams);
334
335
 
335
336
  // check settingObjSchemas
@@ -381,6 +382,10 @@ module.exports.<%- functionName %>Main = async (
381
382
  }; // end loop
382
383
 
383
384
  let listOfObjectForCreates = [];
385
+
386
+ let objInstanceFullForDynamoDb = lodash.cloneDeep(objInstanceFull)
387
+ let objInstanceFullForGraph = lodash.cloneDeep(objInstanceFull)
388
+
384
389
  if (errorsFound.length == 0) {
385
390
 
386
391
  for (let [storageTag, createDataDetail] of Object.entries(createDataDetails)) {
@@ -388,7 +393,6 @@ module.exports.<%- functionName %>Main = async (
388
393
  if (createDataDetail.storageType == consts.STORAGE_TYPES.dynamoDB) {
389
394
  _izContext.logger.debug("::::::DynamoDB::::::", { storageTag, objInstanceFull });
390
395
 
391
- let objInstanceFullForDynamoDb = lodash.cloneDeep(objInstanceFull)
392
396
 
393
397
  Object.assign(objInstanceFullForDynamoDb.fields, createObjInstanceFullFieldsByStorageTag(_izContext, storageTag, createDataDetail))
394
398
  _izContext.logger.debug("objInstanceFull before create item in dynamoDB", objInstanceFullForDynamoDb)
@@ -412,12 +416,9 @@ module.exports.<%- functionName %>Main = async (
412
416
  ...objInstanceFullForDynamoDb.fields
413
417
  }
414
418
  );
415
-
416
419
  } else if (createDataDetail.storageType == consts.STORAGE_TYPES.graph) {
417
420
  _izContext.logger.debug("::::::Graph::::::", { storageTag, objInstanceFull });
418
421
 
419
- let objInstanceFullForGraph = lodash.cloneDeep(objInstanceFull)
420
-
421
422
  Object.assign(objInstanceFullForGraph.fields, createObjInstanceFullFieldsByStorageTag(_izContext, storageTag, createDataDetail))
422
423
  _izContext.logger.debug("objInstanceFull before send to Graph", objInstanceFullForGraph)
423
424
 
@@ -488,7 +489,7 @@ module.exports.<%- functionName %>Main = async (
488
489
  messageObject = {
489
490
  objType: MAIN_OBJTYPE,
490
491
  objInstanceFull: objecForCreate.objInstanceFull,
491
- relationships: requestParams.relationships
492
+ relationships: requestParams.relationships || []
492
493
  };
493
494
  };
494
495
 
@@ -564,14 +565,44 @@ module.exports.<%- functionName %>Main = async (
564
565
  errorsFound: errorsFound
565
566
  }
566
567
  } else {
568
+
569
+ if (allAwaitingStepsId.length == 0 && listOfObjectForCreates.length == 0) {
570
+ let messageObject = {
571
+ objType: {
572
+ objectType: OBJECT_TYPE,
573
+ serviceTag: SERVICE_TAG
574
+ },
575
+ objInstanceFull: {
576
+ identifiers: objInstanceFullForDynamoDb.identifiers,
577
+ fields: objInstanceFullForDynamoDb.fields
578
+ }
579
+ }
580
+
581
+ if (callingFlowConfig[callingFlowSharedLib.consts.CALLINGFLOW_PROPERTYNAME]) {
582
+ // send message to SNS OutCreateNodeComplete
583
+ _izContext.logger.debug("HAVE CallingFlow");
584
+ messageObject = callingFlowSharedLib.addPassBackPropertiesToSnsResponseMessageObject(callingFlowConfig, messageObject);
585
+
586
+ let messageAttributes = callingFlowSharedLib.addCallingFlowToSnsResponseMessageAttributes(callingFlowConfig, {});
587
+ let outCreateNodeCompleteTopic = await snsSharedLib.snsTopicArn(_izContext, TOPIC_NAME_GENERATE_CODE.outCreateNodeComplete)
588
+ let messageParams = {
589
+ Message: JSON.stringify(messageObject),
590
+ MessageAttributes: sns.createStringMessageAttributes(_izContext, messageAttributes),
591
+ TopicArn: outCreateNodeCompleteTopic,
592
+ };
593
+
594
+ _izContext.logger.debug("messageParams OutCreateNode ::::::: ", messageParams);
595
+ await sns.publishAsync(_izContext, messageParams);
596
+ }
597
+ }
567
598
  return {
568
599
  objType: MAIN_OBJTYPE,
569
600
  fieldNames: requestParams.fieldNames,
570
- relationships: requestParams.relationships,
601
+ relationship: requestParams.relationships,
571
602
  status: "complete",
603
+ errorsFound: errorsFound
572
604
  }
573
605
  }
574
-
575
606
  } catch (err) {
576
607
  throw (err)
577
608
  }
@@ -28,7 +28,6 @@ const serviceConfigLib = require('@izara_project/izara-core-library-service-sche
28
28
 
29
29
  const uploadUseCase = require('@izara_project/izara-core-library-service-schemas/src/libs/UploadUseCase')
30
30
 
31
-
32
31
  const hash = require("object-hash")
33
32
  const NoRetryError = require('@izara_project/izara-core-library-core/src/NoRetryError');
34
33
  const path = require('path')
@@ -38,18 +38,21 @@ const {
38
38
  createGetDataDetails,
39
39
  } = require('@izara_project/izara-market-library-service-schemas/src/GenerateCodeLibs/src/GenerateCodeLibs');
40
40
 
41
+ const { createObjTypeConcat } = require('@izara_project/izara-core-library-service-schemas/src/Utils');
41
42
 
42
43
  const izaraShared = require('@izara_project/izara-shared');
43
44
  const dynamodbSharedLib = izaraShared.dynamodbSharedLib;
44
45
  const graphSharedLib = izaraShared.graphSharedLib;
45
46
  const callingFlowSharedLib = izaraShared.callingFlowSharedLib;
46
47
  const snsSharedLib = izaraShared.snsSharedLib;
48
+ const lambdaSharedLib = izaraShared.lambdaSharedLib;
47
49
 
48
50
  const externalRequest = require('@izara_project/izara-core-library-external-request');
49
51
  const sns = externalRequest.sns
50
52
 
51
53
  const NoRetryError = require('@izara_project/izara-core-library-core/src/NoRetryError');
52
54
  const { TOPIC_NAME_GENERATE_CODE } = require('@izara_project/izara-market-library-service-schemas/src/GenerateCodeLibs/src/Consts');
55
+ const coreConsts = require("@izara_project/izara-core-library-core/src/Consts");
53
56
 
54
57
  /**
55
58
  *
@@ -82,25 +85,24 @@ module.exports.<%- functionName %>Main = async (
82
85
  const returnSystemFieldsName = requestParams.additionalRequest?.setting?.returnSystemFieldsName || false;
83
86
  const throwWhenNotFoundSomeRecord = requestParams.additionalRequest?.setting?.throwWhenNotFoundSomeRecord || true;
84
87
 
85
-
86
88
  const OBJECT_TYPE = "<%- objectType %>";
87
89
  const SERVICE_TAG = process.env.iz_serviceTag;
88
90
 
89
91
  //(<beforeQuery>)
90
92
  //(</beforeQuery>)
91
93
 
92
- let objectSchema = await getObjSchemaS3WithHierarchy(
93
- _izContext,
94
- {
95
- objectType: OBJECT_TYPE,
96
- serviceTag: SERVICE_TAG
97
- }
98
- );
94
+ let objectSchema = await getObjSchemaS3WithHierarchy(
95
+ _izContext,
96
+ {
97
+ objectType: OBJECT_TYPE,
98
+ serviceTag: SERVICE_TAG
99
+ }
100
+ );
99
101
 
100
- _izContext.logger.debug("objectSchema: ", objectSchema);
102
+ _izContext.logger.debug("objectSchema: ", objectSchema);
101
103
 
102
- let getDataDetails = await createGetDataDetails(_izContext, objectSchema);
103
- _izContext.logger.debug("getDataDetails:", getDataDetails)
104
+ let getDataDetails = await createGetDataDetails(_izContext, objectSchema);
105
+ _izContext.logger.debug("getDataDetails:", getDataDetails)
104
106
 
105
107
  // start to get data
106
108
  let getResults = []; // for collect result data from
@@ -28,7 +28,8 @@ const consts = require('@izara_project/izara-core-library-service-schemas/src/Co
28
28
 
29
29
 
30
30
  const {
31
- dynamoDbIdentifiersByStorageResource, createFieldForUpdateDynamoDb
31
+ dynamoDbIdentifiersByStorageResource,
32
+ createFieldForUpdateDynamoDb
32
33
  } = require('@izara_project/izara-market-library-service-schemas/src/GenerateCodeLibs/src/GenerateCodeLibs');
33
34
 
34
35
  const izaraShared = require('@izara_project/izara-shared');
@@ -74,9 +75,11 @@ module.exports.<%- functionName %>Main = async (
74
75
  _izContext.logger.debug("<%- functionName %> callingFlowConfig", callingFlowConfig)
75
76
 
76
77
  let errorFounds = [];
77
- const userId = _izContext.correlationIds.get(coreConsts.BASE_USER_ID)
78
+ const userId = _izContext.correlationIds.get(coreConsts.BASE_USER_ID);
79
+ const targetId = _izContext.correlationIds.get(coreConsts.TARGET_ID);
80
+
78
81
  if (!userId) {
79
- errorFounds.push("Not Have UserId")
82
+ errorFounds.push("Not have userId")
80
83
  }
81
84
 
82
85
  const OBJECT_TYPE = "<%- objectType %>"
@@ -102,6 +105,10 @@ module.exports.<%- functionName %>Main = async (
102
105
  )
103
106
  _izContext.logger.debug("objectSchema", objectSchema);
104
107
 
108
+ if (objectSchema.hasOwnProperty("belongTo") && !targetId) {
109
+ errorFounds.push('not have targetId')
110
+ }
111
+
105
112
  let updateDataDetails = await createUpdateDataDetail(_izContext, objectSchema);
106
113
 
107
114
  _izContext.logger.debug("updateDataDetails", updateDataDetails);
@@ -121,9 +128,13 @@ module.exports.<%- functionName %>Main = async (
121
128
  if (!updateVersionedData.hasOwnProperty(fieldSetting.versionedDataLabel)) {
122
129
  updateVersionedData[fieldSetting.versionedDataLabel] = {};
123
130
  }
124
- Object.assign(updateVersionedData[fieldSetting.versionedDataLabel], { [fieldProp]: requestParams.objInstanceFull.fields[fieldProp] })
131
+ Object.assign(updateVersionedData[fieldSetting.versionedDataLabel], {
132
+ [fieldProp]: requestParams.objInstanceFull.fields[fieldProp]
133
+ })
125
134
  } else {
126
- Object.assign(updateMainNodeData, { [fieldProp]: requestParams.objInstanceFull.fields[fieldProp] })
135
+ Object.assign(updateMainNodeData, {
136
+ [fieldProp]: requestParams.objInstanceFull.fields[fieldProp]
137
+ })
127
138
  }
128
139
  }
129
140
  _izContext.logger.debug("updateMainNodeData::", updateMainNodeData);
@@ -149,7 +160,7 @@ module.exports.<%- functionName %>Main = async (
149
160
  }
150
161
  // check mainNode Data should not exists
151
162
  if (Object.keys(updateMainNodeData).length) {
152
- errorsFound.push("cannot update mainNode if have versionedDataIds");
163
+ errorFounds.push("cannot update mainNode if have versionedDataIds");
153
164
  }
154
165
  }
155
166
 
@@ -215,10 +226,10 @@ module.exports.<%- functionName %>Main = async (
215
226
  awaitingStepIds,
216
227
  asyncFlowSharedLib.createPendingStepId(
217
228
  hash(
218
- {
219
- identifiers,
220
- fields,
221
- })
229
+ {
230
+ identifiers,
231
+ fields,
232
+ })
222
233
  )
223
234
  )
224
235
  _izContext.logger.debug("awaitingMultipleStep", awaitingMultipleStep)
@@ -253,7 +264,7 @@ module.exports.<%- functionName %>Main = async (
253
264
  let updateNodeMessageBody = {
254
265
  Message: JSON.stringify(updateNodeParams),
255
266
  MessageAttributes: sns.createStringMessageAttributes(_izContext, messageAttributes),
256
- TopicArn: await snsSharedLib.snsTopicArn(_izContext, TOPIC_NAME_GRAPH_HANDLER.inUpdateNode, storageTag,)
267
+ TopicArn: await snsSharedLib.snsTopicArn(_izContext, TOPIC_NAME_GRAPH_HANDLER.inUpdateNode, storageTag, )
257
268
  }
258
269
 
259
270
  _izContext.logger.debug('requset param before send to topic InUpdateNode:::', updateNodeMessageBody);
@@ -275,12 +286,45 @@ module.exports.<%- functionName %>Main = async (
275
286
  _izContext.logger.debug("identifiersForUpdateData", identifiersForUpdateData)
276
287
  _izContext.logger.debug("fieldForUpdateTableDynamo", fieldForUpdateTableDynamo)
277
288
 
278
- await dynamodbSharedLib.updateItem(
289
+ let updateItem = await dynamodbSharedLib.updateItem(
279
290
  _izContext,
280
291
  await dynamodbSharedLib.tableName(_izContext, updateDataDetail.tableName),
281
292
  identifiersForUpdateData,
282
- fieldForUpdateTableDynamo
293
+ fieldForUpdateTableDynamo,
294
+ {
295
+ returnValues: "ALL_NEW"
296
+ }
283
297
  )
298
+ _izContext.logger.debug("updateItem:", updateItem);
299
+
300
+ if (awaitingStepIds.length == 0) {
301
+ let messageObject = {
302
+ objType: {
303
+ objectType: OBJECT_TYPE,
304
+ serviceTag: SERVICE_TAG
305
+ },
306
+ updateItem
307
+ }
308
+
309
+ if (callingFlowConfig[callingFlowSharedLib.consts.CALLINGFLOWPROPERTIES_PROPERTYNAME]) {
310
+ _izContext.logger.debug("HAVE CALLINGFLOW");
311
+
312
+ messageObject = callingFlowSharedLib.addPassBackPropertiesToSnsResponseMessageObject(callingFlowConfig, messageObject);
313
+ let messageAttributes = callingFlowSharedLib.addCallingFlowToSnsResponseMessageAttributes(callingFlowConfig, {});
314
+
315
+ _izContext.logger.debug("after create callingFlow", messageObject)
316
+ let outUpdateNodeCompleteTopic = await snsSharedLib.snsTopicArn(_izContext, TOPIC_NAME_GENERATE_CODE.outUpdateNodeComplete);
317
+ let messageParams = {
318
+ Message: JSON.stringify(messageObject),
319
+ MessageAttributes: sns.createStringMessageAttributes(_izContext, messageAttributes),
320
+ TopicArn: outUpdateNodeCompleteTopic
321
+ }
322
+
323
+ _izContext.logger.debug("message params OutUpdateNodeComplete :::", messageParams);
324
+ await sns.publishAsync(_izContext, messageParams);
325
+
326
+ }
327
+ }
284
328
  }
285
329
  }
286
330
  )
@@ -16,42 +16,33 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
16
16
  */
17
17
 
18
18
  'use strict';
19
+
19
20
  const path = require('path');
20
21
  const fs = require('fs');
21
22
 
22
23
  const { ACTIONS, HANDLER } = require('@izara_project/izara-core-library-service-schemas/src/Consts')
23
24
 
24
- const { firstLetterLowerCase: lowerCase, firstLetterUpperCase: upperCase, firstLetterUpperCase, checkOverWriteGenerateMainFunction } = require("../../../../../../MainLibs/src/Utils")
25
- const { DEFAULT_HANDLER_PER_ACTION, SOURCE_PATH } = require("../../../../libs/Consts");
26
-
27
- const templatePath = path.join(__dirname, "template.ejs")
28
-
29
- /**
30
- * receive objectSchema
31
- * create data for WebScoket handler template
32
- *
33
- * @param {Object} objectSchema
34
- * @return {{templatePath, templateData,setting}}
35
- */
25
+ const { firstLetterLowerCase: lowerCase, firstLetterUpperCase: upperCase } = require("../../../../MainLibs/src/Utils")
26
+ const { DEFAULT_HANDLER_PER_ACTION, SOURCE_PATH } = require("../../libs/Consts");
36
27
 
28
+ const templatePath = path.join(__dirname, "./template.ejs")
37
29
 
38
30
  function data(_izContext, srcPath) {
31
+ return [createSourceParams(_izContext, srcPath)]
32
+ };
39
33
 
40
- return [createParamsForCreateSource(_izContext, srcPath)]
34
+ function createSourceParams(_izContext, srcPath) {
41
35
 
42
-
43
- }
44
-
45
- function createParamsForCreateSource(_izContext, srcPath) {
46
36
  return {
47
37
  templatePath: templatePath,
48
38
  templateData: {},
49
39
  setting: {
50
- savePath: path.join(srcPath, SOURCE_PATH.lambdaPerAction),
51
- saveFileName: "FlowSchemaInvoke",
40
+ saveFileName: "GenerateCodeLibs",
41
+ savePath: path.join(srcPath, SOURCE_PATH.generateCodeLib),
52
42
  fileExtension: ".js",
53
43
  isAppend: false
54
44
  }
55
45
  }
56
- }
57
- module.exports = data
46
+ };
47
+
48
+ module.exports = data;
@@ -0,0 +1,46 @@
1
+ /*
2
+ Copyright (C) 2020 Sven Mason <http://izara.io>
3
+
4
+ This program is free software: you can redistribute it and/or modify
5
+ it under the terms of the GNU Affero General Public License as
6
+ published by the Free Software Foundation, either version 3 of the
7
+ License, or (at your option) any later version.
8
+
9
+ This program is distributed in the hope that it will be useful,
10
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
+ GNU Affero General Public License for more details.
13
+
14
+ You should have received a copy of the GNU Affero General Public License
15
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
16
+ */
17
+
18
+ 'use strict';
19
+
20
+ const externalRequest = require('@izara_project/izara-core-library-external-request');
21
+ const lambda = externalRequest.lambda;
22
+
23
+ const inMemoryCacheLib = require('@izara_project/izara-shared/src/InMemoryCacheLib');
24
+ const hash = require('object-hash')
25
+
26
+ async function checkPermission(_izContext, functionName, payload) {
27
+ return await lambda.invokeSync(_izContext, functionName, payload)
28
+ }
29
+
30
+ const checkPermissionWithCache = inMemoryCacheLib.inMemoryCacheLib(
31
+ checkPermission, // fn
32
+ { // setting
33
+ max: 100,
34
+ maxAge: 86400000,
35
+ promise: true,
36
+ profileName: 'checkPermission',
37
+ normalizer: function (args) {
38
+ return hash([args[1], args[2]])
39
+ }
40
+ }
41
+ )
42
+
43
+ module.exports = {
44
+ checkPermission,
45
+ checkPermissionWithCache
46
+ }
@@ -59,7 +59,7 @@ module.exports.createRelationshipComplete = async (
59
59
  returnValue.firstObject.objType,
60
60
  returnValue.secondObject.objType,
61
61
  returnValue.relType,
62
- returnValue.direction
62
+ returnValue.relationshipDirection
63
63
  );
64
64
 
65
65
  let awaitingStepId = asyncFlowSharedLib.createAwaitingStepId(
@@ -59,7 +59,7 @@ module.exports.createRelationshipComplete = async (
59
59
  returnValue.firstObject.objType,
60
60
  returnValue.secondObject.objType,
61
61
  returnValue.relType,
62
- returnValue.direction
62
+ returnValue.relationshipDirection
63
63
  );
64
64
 
65
65
  let awaitingStepId = asyncFlowSharedLib.createAwaitingStepId(
@@ -60,7 +60,7 @@ module.exports.updateRelationshipComplete = async (
60
60
  returnValue.firstObject.objType,
61
61
  returnValue.secondObject.objType,
62
62
  returnValue.relType,
63
- returnValue.direction
63
+ returnValue.relationshipDirection
64
64
  );
65
65
 
66
66
  let awaitingStepId = asyncFlowSharedLib.createAwaitingStepId(
@@ -109,6 +109,21 @@ const createAwaitingMultipleStepDynamoDbData = (_izContext, srcPath) => {
109
109
  "AttributeType": "S"
110
110
  }
111
111
  ]
112
+ },
113
+ {
114
+ "tableName": "AwaitingStep",
115
+ "attributes": [
116
+ {
117
+ "keyType": "partitionKey",
118
+ "AttributeName": "awaitingStepId",
119
+ "AttributeType": "S"
120
+ },
121
+ {
122
+ "keyType": "sortKey",
123
+ "AttributeName": "pendingStepId",
124
+ "AttributeType": "S"
125
+ }
126
+ ]
112
127
  }
113
128
  )
114
129