@izara_project/izara-market-library-service-schemas 1.0.37 → 1.0.38

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 (107) hide show
  1. package/package.json +1 -1
  2. package/src/GenerateCodeLibs/src/GenerateCodeLibs.js +35 -5
  3. package/src/MainLibs/src/Consts.js +5 -2
  4. package/src/MainLibs/src/GenerateCodeUtils.js +2 -0
  5. package/src/MainLibs/src/Utils.js +12 -0
  6. package/src/reStructure/GenerateCode.js +2 -2
  7. package/src/reStructure/TemplateData/EndpointPerService/mainFunction/create/template.ejs +36 -11
  8. package/src/reStructure/TemplateData/EndpointPerService/mainFunction/delete/template.ejs +24 -1
  9. package/src/reStructure/TemplateData/EndpointPerService/mainFunction/get/template.ejs +26 -0
  10. package/src/reStructure/TemplateData/EndpointPerService/mainFunction/update/template.ejs +22 -0
  11. package/src/reStructure/TemplateData/EndpointPerService/yaml/data.js +37 -7
  12. package/src/reStructure/TemplateData/findData/handler/template.ejs +2 -2
  13. package/src/reStructure/TemplateData/flowSchema/components/upload/confirmReserved/mainFunction/template.ejs +2 -0
  14. package/src/reStructure/TemplateData/flowSchema/components/upload/createObject/mainFunction/template.ejs +5 -1
  15. package/src/reStructure/TemplateData/flowSchema/components/upload/createObjectComplete/sns-sqs/data.js +1 -1
  16. package/src/reStructure/TemplateData/flowSchema/components/upload/preSignUrl/reservedLimit/sqs/data.js +3 -3
  17. package/src/reStructure/TemplateData/flowSchema/components/upload/preSignUrl/reservedLimit/sqs/template.ejs +1 -1
  18. package/src/reStructure/TemplateData/flowSchema/components/upload/relate/libs/template.ejs +1 -1
  19. package/src/reStructure/TemplateData/flowSchema/components/websocket/connect/functionYaml/data.js +1 -1
  20. package/src/reStructure/TemplateData/flowSchema/components/websocket/connect/handler/data.js +1 -1
  21. package/src/reStructure/TemplateData/flowSchema/externalTopic/functionYaml/data.js +127 -0
  22. package/src/reStructure/TemplateData/flowSchema/externalTopic/handler/data.js +121 -0
  23. package/src/reStructure/TemplateData/flowSchema/externalTopic/{sqs/handler → handler}/template.ejs +16 -61
  24. package/src/reStructure/TemplateData/flowSchema/externalTopic/mainFunction/data.js +74 -0
  25. package/src/reStructure/TemplateData/flowSchema/externalTopic/mainFunction/template.ejs +131 -0
  26. package/src/reStructure/TemplateData/flowSchema/externalTopic/sns-in-sqs/data.js +61 -34
  27. package/src/reStructure/TemplateData/flowSchema/externalTopic/sns-in-sqs/template.ejs +1 -1
  28. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComponent/functionYaml/data.js +3 -7
  29. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComponent/handler/data.js +2 -5
  30. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComponent/mainFunction/data.js +13 -4
  31. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComponent/mainFunction/template.ejs +15 -23
  32. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/FlowSchemaComponent/functionYaml/data.js +2 -4
  33. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/FlowSchemaComponent/mainFunction/data.js +2 -5
  34. package/src/reStructure/TemplateData/flowSchema/{externalTopic/sqs → flowSchemaOwnTopic/flowStep}/functionYaml/data.js +43 -38
  35. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/flowStep/functionYaml/template.ejs +20 -0
  36. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/flowStep/handler/data.js +80 -0
  37. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/flowStep/handler/template.ejs +85 -0
  38. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/flowStep/mainFunction/data.js +92 -0
  39. package/src/reStructure/TemplateData/flowSchema/{externalTopic/websocket → flowSchemaOwnTopic/flowStep}/mainFunction/template.ejs +11 -13
  40. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/sns-in/data.js +46 -37
  41. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/sns-out/data.js +14 -19
  42. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/{FlowSchemaCompleteComponent → webSocketComplete}/functionYaml/data.js +5 -21
  43. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/webSocketComplete/functionYaml/template.ejs +20 -0
  44. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/{FlowSchemaCompleteComponent → webSocketComplete}/handler/data.js +2 -2
  45. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/{FlowSchemaCompleteComponent → webSocketComplete}/mainFunction/data.js +2 -2
  46. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/{FlowSchemaCompleteComponent → webSocketComplete}/mainFunction/template.ejs +24 -10
  47. package/src/reStructure/TemplateData/flowSchema/generateTemplateData.js +23 -25
  48. package/src/reStructure/TemplateData/flowSchema/{createRecordByStatusType → register}/complete/handler/template.ejs +1 -1
  49. package/src/reStructure/TemplateData/flowSchema/register/complete/mainFunction/template.ejs +172 -0
  50. package/src/reStructure/TemplateData/flowSchema/register/wbs/mainFunction/template.ejs +165 -0
  51. package/src/reStructure/TemplateData/flowSchema/templateBystatusType/storedCacheTemplate.ejs +38 -0
  52. package/src/reStructure/TemplateData/flowSchema/templateBystatusType/triggerCacheTemplate.ejs +39 -0
  53. package/src/reStructure/TemplateData/perActionComplete/get/mainFunction/template.ejs +3 -0
  54. package/src/reStructure/TemplateData/perActionComplete/update/mainFunction/template.ejs +3 -0
  55. package/src/reStructure/TemplateData/propertyValueSchema/relationshipPropertyValueSchema/data.js +2 -7
  56. package/src/reStructure/TemplateData/relationshipPerAction/create/action/functionYaml/api/data.js +22 -3
  57. package/src/reStructure/TemplateData/relationshipPerAction/create/action/functionYaml/dsq/data.js +14 -9
  58. package/src/reStructure/TemplateData/relationshipPerAction/create/action/functionYaml/inv/data.js +26 -6
  59. package/src/reStructure/TemplateData/relationshipPerAction/create/action/functionYaml/sqs/data.js +11 -7
  60. package/src/reStructure/TemplateData/relationshipPerAction/create/complete/functionYaml/data.js +17 -7
  61. package/src/reStructure/TemplateData/relationshipPerAction/delete/action/functionYaml/api/data.js +23 -4
  62. package/src/reStructure/TemplateData/relationshipPerAction/delete/action/functionYaml/dsq/data.js +14 -9
  63. package/src/reStructure/TemplateData/relationshipPerAction/delete/action/functionYaml/inv/data.js +26 -6
  64. package/src/reStructure/TemplateData/relationshipPerAction/delete/action/functionYaml/sqs/data.js +10 -7
  65. package/src/reStructure/TemplateData/relationshipPerAction/delete/complete/functionYaml/data.js +11 -7
  66. package/src/reStructure/TemplateData/relationshipPerAction/get/action/functionYaml/api/data.js +23 -4
  67. package/src/reStructure/TemplateData/relationshipPerAction/get/action/functionYaml/dsq/data.js +14 -9
  68. package/src/reStructure/TemplateData/relationshipPerAction/get/action/functionYaml/inv/data.js +26 -7
  69. package/src/reStructure/TemplateData/relationshipPerAction/get/action/functionYaml/sqs/data.js +10 -7
  70. package/src/reStructure/TemplateData/relationshipPerAction/get/complete/functionYaml/data.js +12 -7
  71. package/src/reStructure/TemplateData/relationshipPerAction/update/action/functionYaml/api/data.js +22 -3
  72. package/src/reStructure/TemplateData/relationshipPerAction/update/action/functionYaml/dsq/data.js +14 -6
  73. package/src/reStructure/TemplateData/relationshipPerAction/update/action/functionYaml/inv/data.js +20 -3
  74. package/src/reStructure/TemplateData/relationshipPerAction/update/action/functionYaml/sqs/data.js +9 -3
  75. package/src/reStructure/TemplateData/relationshipPerAction/update/complete/functionYaml/data.js +12 -6
  76. package/src/reStructure/TemplateData/resourceYaml/dynamodb/mainResourcePerObjectSchemaData.js +6 -2
  77. package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/complete/mainFunction/template.ejs +0 -184
  78. package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/storedCacheTemplate.ejs +0 -11
  79. package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/wbs/mainFunction/template.ejs +0 -210
  80. package/src/reStructure/TemplateData/flowSchema/externalTopic/sns-out/data.js +0 -77
  81. package/src/reStructure/TemplateData/flowSchema/externalTopic/sns-out/template.ejs +0 -8
  82. package/src/reStructure/TemplateData/flowSchema/externalTopic/sqs/functionYaml/template.ejs +0 -17
  83. package/src/reStructure/TemplateData/flowSchema/externalTopic/sqs/handler/data.js +0 -64
  84. package/src/reStructure/TemplateData/flowSchema/externalTopic/sqs/mainFunction/data.js +0 -61
  85. package/src/reStructure/TemplateData/flowSchema/externalTopic/sqs/mainFunction/template.ejs +0 -74
  86. package/src/reStructure/TemplateData/flowSchema/externalTopic/websocket/functionYaml/data.js +0 -110
  87. package/src/reStructure/TemplateData/flowSchema/externalTopic/websocket/functionYaml/template.ejs +0 -18
  88. package/src/reStructure/TemplateData/flowSchema/externalTopic/websocket/handler/data.js +0 -57
  89. package/src/reStructure/TemplateData/flowSchema/externalTopic/websocket/handler/template.ejs +0 -85
  90. package/src/reStructure/TemplateData/flowSchema/externalTopic/websocket/mainFunction/data.js +0 -67
  91. /package/src/reStructure/TemplateData/flowSchema/{flowSchemaOwnTopic/FlowSchemaCompleteComponent → externalTopic}/functionYaml/template.ejs +0 -0
  92. /package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/{FlowSchemaCompleteComponent → webSocketComplete}/handler/template.ejs +0 -0
  93. /package/src/reStructure/TemplateData/flowSchema/{createRecordByStatusType → register}/complete/functionYaml/data.js +0 -0
  94. /package/src/reStructure/TemplateData/flowSchema/{createRecordByStatusType → register}/complete/functionYaml/template.ejs +0 -0
  95. /package/src/reStructure/TemplateData/flowSchema/{createRecordByStatusType → register}/complete/handler/data.js +0 -0
  96. /package/src/reStructure/TemplateData/flowSchema/{createRecordByStatusType → register}/complete/mainFunction/data.js +0 -0
  97. /package/src/reStructure/TemplateData/flowSchema/{createRecordByStatusType → register}/dynamoDB/register.js +0 -0
  98. /package/src/reStructure/TemplateData/flowSchema/{createRecordByStatusType → register}/sns-in/data.js +0 -0
  99. /package/src/reStructure/TemplateData/flowSchema/{createRecordByStatusType → register}/sns-in/template.ejs +0 -0
  100. /package/src/reStructure/TemplateData/flowSchema/{createRecordByStatusType → register}/subscriptionOutAll/data.js +0 -0
  101. /package/src/reStructure/TemplateData/flowSchema/{createRecordByStatusType → register}/subscriptionOutAll/template.ejs +0 -0
  102. /package/src/reStructure/TemplateData/flowSchema/{createRecordByStatusType → register}/wbs/functionYaml/data.js +0 -0
  103. /package/src/reStructure/TemplateData/flowSchema/{createRecordByStatusType → register}/wbs/functionYaml/template.ejs +0 -0
  104. /package/src/reStructure/TemplateData/flowSchema/{createRecordByStatusType → register}/wbs/handler/data.js +0 -0
  105. /package/src/reStructure/TemplateData/flowSchema/{createRecordByStatusType → register}/wbs/handler/template.ejs +0 -0
  106. /package/src/reStructure/TemplateData/flowSchema/{createRecordByStatusType → register}/wbs/mainFunction/data.js +0 -0
  107. /package/src/reStructure/TemplateData/flowSchema/{createRecordByStatusType → templateBystatusType}/statusFieldTemplate.ejs +0 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@izara_project/izara-market-library-service-schemas",
3
- "version": "1.0.37",
3
+ "version": "1.0.38",
4
4
  "description": "Schemas for Izara Market project",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -438,11 +438,12 @@ async function createGetDataDetails(_izContext, objectSchema) {
438
438
  }
439
439
 
440
440
  } else if (storageData.storageType === consts.STORAGE_TYPES.dynamoDB) {
441
-
441
+ let serviceTag = storageData.serviceTag || process.env.iz_serviceTag
442
442
  Object.assign(getDynamoDbDataDetails, {
443
443
  [storageTag]: {
444
444
  storageType: storageData.storageType,
445
445
  tableName: storageData.tableName,
446
+ serviceTag: serviceTag,
446
447
  fieldNames: storageTagFieldNames
447
448
  }
448
449
  })
@@ -796,11 +797,12 @@ async function createUpdateDataDetail(_izContext, objectSchema) {
796
797
  getGraphDataDetails[graphServiceName].fieldNames = [...new Set(getGraphDataDetails[useStorageTag].fieldNames.concat(storageFieldNames))]
797
798
  }
798
799
  } else if (storageProperties.storageType === consts.STORAGE_TYPES.dynamoDB) {
799
-
800
+ let serviceTag = storageProperties.serviceTag || process.env.iz_serviceTag;
800
801
  Object.assign(getDynamoDbDataDetails, {
801
802
  [storageTag]: {
802
803
  storageType: storageProperties.storageType,
803
804
  tableName: storageProperties.tableName,
805
+ serviceTag: serviceTag,
804
806
  fieldNames: storageFieldNames
805
807
  }
806
808
  })
@@ -828,6 +830,10 @@ async function createDataDetailsLib(
828
830
  objectSchemas
829
831
  ) {
830
832
  _izContext.logger.debug("Lib: createDataDetailsLib:", { objectSchemas: objectSchemas });
833
+ /**
834
+ * TODO: crate DataDetail now will get parnet objectSchema if have extendObjType
835
+ * will split fieldNames for each serviceTag and storageREsourceTags
836
+ * */
831
837
 
832
838
  let createDataDetails = {};
833
839
 
@@ -849,7 +855,6 @@ async function createDataDetailsLib(
849
855
  createDataDetails[eachStorageResourceTag].fieldNames.push(keyFieldName);
850
856
 
851
857
  } else {
852
- // _izContext.logger.debug("NEW STG DB", eachStorageResourceTag);
853
858
  Object.assign(createDataDetails, {
854
859
  [eachStorageResourceTag]: {
855
860
  storageType: consts.STORAGE_TYPES.dynamoDB,
@@ -864,7 +869,6 @@ async function createDataDetailsLib(
864
869
  });
865
870
  }
866
871
  }
867
-
868
872
  } else if (storageResources[eachStorageResourceTag].storageType == consts.STORAGE_TYPES.graph) {
869
873
  let checkGraphServerTags = await serviceConfig.getGraphServiceTagWithCache(
870
874
  _izContext,
@@ -888,8 +892,32 @@ async function createDataDetailsLib(
888
892
  };
889
893
  };
890
894
  }; // end loop storageResourceTags
891
-
892
895
  }; // end loop
896
+
897
+ if (objectSchemas.hasOwnProperty("extendObjType")) {
898
+ if (objectSchemas.extendObjType.serviceTag !== process.env.iz_serviceTag) {
899
+ let parentObjectSchema = await getObjectSchema.getObjSchemaS3WithHierarchy(_izContext, objectSchemas.extendObjType);
900
+ _izContext.logger.debug("parentObjectSchema", parentObjectSchema);
901
+ for (const [fieldName, fieldNameSetting] of Object.entries(parentObjectSchema.fieldNames)) {
902
+ for (let eachParentStorageResourceTag of fieldNameSetting.storageResourceTags) {
903
+ let parentStorageResourceTag = objectSchemas.extendObjType.serviceTag + eachParentStorageResourceTag
904
+ if (storageResources[eachParentStorageResourceTag].storageType === consts.STORAGE_TYPES.dynamoDB) {
905
+ if (!createDataDetails.hasOwnProperty(parentStorageResourceTag)) {
906
+ createDataDetails[parentStorageResourceTag] = {
907
+ storageType: consts.STORAGE_TYPES.dynamoDB,
908
+ tableName: storageResources[eachParentStorageResourceTag].tableName,
909
+ serviceTag: objectSchemas.extendObjType.serviceTag,
910
+ fieldNames: [fieldName]
911
+ }
912
+ } else {
913
+ createDataDetails[parentStorageResourceTag].fieldNames.push(fieldName)
914
+ }
915
+ }
916
+ }
917
+ }
918
+ }
919
+ }
920
+
893
921
  return createDataDetails;
894
922
  };
895
923
 
@@ -900,9 +928,11 @@ async function createDeleteDataDetail(_izContext, objectSchema) {
900
928
 
901
929
  for (let [storageTag, storageProperties] of Object.entries(objectSchema.storageResources)) {
902
930
  if (storageProperties.storageType === consts.STORAGE_TYPES.dynamoDB) {
931
+ let serviceTag = storageProperties.serviceTag || process.env.iz_serviceTag;
903
932
  Object.assign(deleteDynamoDataDetail, {
904
933
  [storageTag]: {
905
934
  storageType: storageProperties.storageType,
935
+ serviceTag: serviceTag,
906
936
  tableName: storageProperties.tableName
907
937
  }
908
938
  })
@@ -129,9 +129,11 @@ const SOURCE_PATH = {
129
129
  flowSchemaRegister: "../src/generatedCode/FlowSchema/Register/",
130
130
  resourceLocationFlowSchemaRegister: "src/generatedCode/FlowSchema/Register/",
131
131
 
132
+ //* WebSocket Main
133
+ WebSocketMain: "../src/generatedCode/FlowSchema/WebSocketMain/source/",
134
+ resourceLocationWebSocketMain: "src/generatedCode/FlowSchema/WebSocketMain/source/",
135
+
132
136
  generateCodeLib: "../src/generatedCode/libs/source/",
133
- logicalFunctionHook: "../src/generatedCode/WebSocket/source/FlowSchemaHook/HookLogicFunction/source/",
134
- resourceLocationLogicalFunctionHook: "src/generatedCode/WebSocket/source/FlowSchemaHook/HookLogicFunction/source",
135
137
  generatedCodeHookFunction: "../src/generatedCode/WebSocket/source/FlowSchemaHook/HookFunctionGeneratedCode/source/",
136
138
  resourceLocationGeneratedCodeHookFunction: "src/generatedCode/WebSocket/source/FlowSchemaHook/HookFunctionGeneratedCode/source/",
137
139
  generatedAttributeTree: "../src/schemas/generatedCode/attributeTree/",
@@ -376,6 +378,7 @@ function awaitingMultipleStepsRole() {
376
378
  [
377
379
  resourceNames(RESOURCE_CLASSES.dynamoDbTable, "AwaitingMultipleSteps"),
378
380
  resourceNames(RESOURCE_CLASSES.dynamoDbTable, "AwaitingMultipleStepByPending"),
381
+ resourceNames(RESOURCE_CLASSES.dynamoDbTable, "AwaitingStep"),
379
382
  ]
380
383
  )
381
384
  return awaitingMultipleStepsRole
@@ -21,6 +21,7 @@ const hash = require('@izara_project/izara-shared-core').objectHash;
21
21
 
22
22
 
23
23
  function checkValidTableYaml(_izContext, currentTableSetting, existsTableSetting) {
24
+ // console.log("checkValidTableYaml", JSON.stringify(currentTableSetting, null, 2), JSON.stringify(existsTableSetting, null, 2))
24
25
  /*
25
26
  return table yml setting that already filter duplicate tableName that have same table setting
26
27
  throw error when found duplicate table name but not have same table setting
@@ -30,6 +31,7 @@ function checkValidTableYaml(_izContext, currentTableSetting, existsTableSetting
30
31
 
31
32
  for (let i = 0, length = currentTableSetting.length; i < length; i++) {
32
33
  let dynamoDbYamlSetting = currentTableSetting[i];
34
+ console.log("dynamoDbYamlSetting", dynamoDbYamlSetting)
33
35
  if (existsTableSetting.hasOwnProperty(dynamoDbYamlSetting.templateData.tableName)) {
34
36
 
35
37
  // exists table
@@ -19,6 +19,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
19
19
 
20
20
  const lodash = require("lodash")
21
21
  const ACTIONS = require("../../TemplateManager/src/libs/Consts");
22
+ const yaml = require('yaml')
23
+ const path = require("path");
24
+ const fs = require("fs")
22
25
 
23
26
  module.exports.firstLetterUpperCase = (text) => {
24
27
  return text.charAt(0).toUpperCase() + text.slice(1)
@@ -38,6 +41,15 @@ module.exports.checkOverWriteGenerateMainFunction = (objectSchema, action) => {
38
41
  return overWriteStatus
39
42
  }
40
43
 
44
+ module.exports.getLocalServiceTag = (srcPath) => {
45
+ const configPath = path.join(srcPath, '../../config/serverless.config.yml');
46
+ const serverlessConfig = fs.readFileSync(configPath, 'utf8');
47
+ const config = yaml.parse(serverlessConfig);
48
+ const serviceTag = config.main_config.iz_serviceTag;
49
+
50
+ return serviceTag
51
+ }
52
+
41
53
  // module.exports.renameObjectType = (objectSchema, srcPath) => {
42
54
  // const shortNamePath = path.join(srcPath, "./schemas/ShortNameObjectType.js");
43
55
  // const shortName = fs.existsSync(shortNamePath) ? require(shortNamePath) : {};
@@ -54,7 +54,7 @@ async function generateCodeWithTemplate(_izContext, objSchemaPath) {
54
54
  // webSocketEndpoint: join(saveFilePath, SOURCE_PATH.webSocket),
55
55
  // generateCodeLib: join(saveFilePath, SOURCE_PATH.generateCodeLib),
56
56
  // generatedMainFunctionPerService: join(saveFilePath, SOURCE_PATH.endpointPerService),
57
- // flowSchema: join(saveFilePath,'../src/generatedCode/flowSchema')
57
+ // flowSchema: join(saveFilePath, '../src/generatedCode/flowSchema')
58
58
  // };
59
59
 
60
60
  //------ Start Create Source ------
@@ -115,8 +115,8 @@ async function generateCodeWithTemplate(_izContext, objSchemaPath) {
115
115
  // empty file by savePath
116
116
  // validate path before empty folder
117
117
  validatePathWithRootServicePath(localServicePath, setting.savePath)
118
-
119
118
  await deleteFileInDir(setting.savePath);
119
+
120
120
  }
121
121
 
122
122
  // generate all source
@@ -44,10 +44,7 @@ const {
44
44
  collectGetData
45
45
  } = require('@izara_project/izara-market-library-service-schemas/src/GenerateCodeLibs/src/GenerateCodeLibs');
46
46
 
47
- const {
48
- getGraphServiceTagWithCache,
49
- getServiceNameWithCache
50
- } = require('@izara_project/izara-core-library-service-schemas/src/ServiceConfig');
47
+
51
48
 
52
49
  //-----------------------------------------------------------------------------------------------------------
53
50
  const PREFIX = {
@@ -117,6 +114,7 @@ module.exports.createMain = async (
117
114
  let createDataDetails = await createDataDetailsLib(_izContext, objectSchemas);
118
115
  _izContext.logger.debug("createDataDetails is =", createDataDetails);
119
116
 
117
+
120
118
  if ((requestParams.hasOwnProperty("relationships")) && (requestParams.relationships.length > 0)) {
121
119
  //(<beforeValidateRelationships>)
122
120
  //(</beforeValidateRelationships>)
@@ -258,7 +256,8 @@ module.exports.createMain = async (
258
256
  let objInstanceFullForGraph = lodash.cloneDeep(objInstanceFull)
259
257
 
260
258
  if (errorsFound.length == 0) {
261
-
259
+ //(<validateBeforeCreate>)
260
+ //(</validateBeforeCreate>)
262
261
  for (let [storageTag, createDataDetail] of Object.entries(createDataDetails)) {
263
262
  //(<beforeCreate>)
264
263
  //(</beforeCreate>)
@@ -319,9 +318,38 @@ module.exports.createMain = async (
319
318
 
320
319
  _izContext.logger.debug("FIRST", listOfObjectForCreates)
321
320
 
322
- };
323
- _izContext.logger.debug("[1]listOfObjectForCreates:::", listOfObjectForCreates);
321
+ }
322
+
323
+ if (objectSchema.hasOwnProperty("extendObjType")) {
324
+ if (createDataDetail.storageType === consts.STORAGE_TYPES.dynamoDB && createDataDetail.serviceTag !== process.env.iz_serviceTag) {
325
+ let objInstanceFullForParentDynamoDb = lodash.cloneDeep(objInstanceFull)
326
+ Object.assign(objInstanceFullForParentDynamoDb.fields, createObjInstanceFullFieldsByStorageTag(_izContext, storageTag, createDataDetail))
327
+ _izContext.logger.debug("objInstanceFull before create item in dynamoDB in parent", objInstanceFullForParentDynamoDb)
328
+
329
+ let identifiersForCreateData = await dynamoDbIdentifiersByStorageResource(
330
+ _izContext,
331
+ objectSchema,
332
+ createDataDetails,
333
+ objInstanceFullForParentDynamoDb.identifiers
334
+ )
335
+ _izContext.logger.debug("identifiersForCreateData", identifiersForCreateData);
336
+
337
+ await dynamodbSharedLib.putItem(
338
+ _izContext,
339
+ await dynamodbSharedLib.tableName(
340
+ _izContext,
341
+ createDataDetail.tableName,
342
+ createDataDetail.serviceTag
343
+ ),
344
+ {
345
+ ...identifiersForCreateData,
346
+ ...objInstanceFullForParentDynamoDb.fields
347
+ }
348
+ );
349
+ }
350
+ }
324
351
  };
352
+ _izContext.logger.debug("[1]listOfObjectForCreates:::", listOfObjectForCreates);
325
353
  };
326
354
 
327
355
  function createObjInstanceFullFieldsByStorageTag(_izContext, storageTag, createDataDetail) {
@@ -455,10 +483,7 @@ module.exports.createMain = async (
455
483
 
456
484
  if (allAwaitingStepsId.length == 0 && listOfObjectForCreates.length == 0) {
457
485
  let messageObject = {
458
- objType: {
459
- objectType: OBJECT_TYPE,
460
- serviceTag: SERVICE_TAG
461
- },
486
+ objType: objType,
462
487
  objInstanceFull: {
463
488
  identifiers: objInstanceFullForDynamoDb.identifiers,
464
489
  fields: objInstanceFullForDynamoDb.fields
@@ -169,7 +169,30 @@ module.exports.deleteMain = async (
169
169
  let resSns = await sns.publishAsync(_izContext, deleteNodeMessageBody)
170
170
  _izContext.logger.debug('reSNS send to topic InDeleteNode finish', resSns)
171
171
  }
172
- }
172
+
173
+ if (objectSchema.hasOwnProperty("extendObjType")) {
174
+ if (deleteDataDetail.storageType === consts.STORAGE_TYPES.dynamoDB && deleteDataDetail.serviceTag !== process.env.iz_serviceTag) {
175
+
176
+ let identifiersForDeleteData = await dynamoDbIdentifiersByStorageResource(
177
+ _izContext,
178
+ objectSchema,
179
+ deleteDataDetail,
180
+ requestParams.identifiers
181
+ )
182
+ _izContext.logger.debug("identifiersForDeleteData", identifiersForDeleteData);
183
+
184
+ await dynamodbSharedLib.deleteItem(
185
+ _izContext,
186
+ await dynamodbSharedLib.tableName(
187
+ _izContext,
188
+ deleteDataDetail.tableName,
189
+ deleteDataDetail.serviceTag
190
+ ),
191
+ identifiersForDeleteData
192
+ );
193
+ }
194
+ }
195
+ };
173
196
 
174
197
 
175
198
  } catch (err) {
@@ -214,6 +214,32 @@ module.exports.getMain = async (
214
214
  getResults.push([dataFromDynamoDb, getDataDetail]);
215
215
 
216
216
  }
217
+
218
+ if (objectSchema.hasOwnProperty("extendObjType")) {
219
+ if (getDataDetail.storageType === consts.STORAGE_TYPES.dynamoDB && getDataDetail.serviceTag !== process.env.iz_serviceTag) {
220
+
221
+ let identifiersForGetData = await dynamoDbIdentifiersByStorageResource(
222
+ _izContext,
223
+ objectSchema,
224
+ createDataDetails,
225
+ requestParams.identifiers
226
+ )
227
+ _izContext.logger.debug("identifiersForGetData", identifiersForGetData);
228
+
229
+ let getParent = await dynamodbSharedLib.getItem(
230
+ _izContext,
231
+ await dynamodbSharedLib.tableName(
232
+ _izContext,
233
+ getDataDetail.tableName,
234
+ getDataDetail.serviceTag
235
+ ),
236
+ identifiersForGetData
237
+ );
238
+ }
239
+
240
+ getResults.push([getParent, getDataDetail]);
241
+
242
+ }
217
243
  })
218
244
  );
219
245
 
@@ -310,6 +310,28 @@ module.exports.updateMain = async (
310
310
  }
311
311
  }
312
312
  }
313
+ if (objectSchema.hasOwnProperty("extendObjType")) {
314
+ if (updateDataDetail.storageType === consts.STORAGE_TYPES.dynamoDB && updateDataDetail.serviceTag !== process.env.iz_serviceTag) {
315
+
316
+ let fieldForUpdateTableDynamo = createFieldForUpdateDynamoDb(_izContext, objectSchema, updateDataDetail, fields)
317
+
318
+
319
+ let identifiersForUpdateData = await dynamoDbIdentifiersByStorageResource(
320
+ _izContext,
321
+ objectSchema,
322
+ updateDataDetail,
323
+ identifiers
324
+ )
325
+ _izContext.logger.debug("identifiersForUpdateData", identifiersForUpdateData);
326
+
327
+ await dynamodbSharedLib.updateItem(
328
+ _izContext,
329
+ await dynamodbSharedLib.tableName(_izContext, updateDataDetail.tableName, updateDataDetail.serviceTag),
330
+ identifiersForUpdateData,
331
+ fieldForUpdateTableDynamo
332
+ );
333
+ }
334
+ }
313
335
  }
314
336
  )
315
337
  )
@@ -18,13 +18,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
18
18
  'use strict';
19
19
 
20
20
  const path = require('path');
21
-
21
+ const fs = require('fs');
22
+ const yaml = require('yaml');
22
23
  const { ACTIONS, HANDLER, STORAGE_TYPES } = require('@izara_project/izara-core-library-service-schemas/src/Consts');
23
-
24
- const {
25
- firstLetterLowerCase: lowerCase,
26
- firstLetterUpperCase: upperCase,
27
- } = require("../../../../MainLibs/index.js").utils;
28
24
  const {
29
25
  DEFAULT_HANDLER_PER_ACTION,
30
26
  createIamRole,
@@ -41,8 +37,14 @@ const {
41
37
  shortNameHandler,
42
38
  SOURCE_GENERATE_IAM_ROLE,
43
39
  getStorageResourceFromObjectSchemas,
44
- SQS_RESOURCE
40
+ SQS_RESOURCE,
41
+ externalResourceYaml
45
42
  } = require("../../../../MainLibs/src/Consts.js");
43
+ const {
44
+ getLocalServiceTag,
45
+ firstLetterLowerCase: lowerCase,
46
+ firstLetterUpperCase: upperCase,
47
+ } = require('../../../../MainLibs/src/Utils.js');
46
48
 
47
49
  const templatePath = path.join(__dirname, "./template.ejs")
48
50
 
@@ -153,6 +155,34 @@ async function createParamForCreateSource(_izContext, allObjSchemas, action, han
153
155
  )
154
156
  }
155
157
 
158
+ const configPath = path.join(srcPath, '../../config/serverless.config.yml');
159
+ const serverlessConfig = fs.readFileSync(configPath, 'utf8');
160
+ const config = yaml.parse(serverlessConfig);
161
+ const serviceTag = config.main_config.iz_serviceTag;
162
+ // create lambdaRole for parent dynamo table if able
163
+ for (const objectSchema of allObjSchemas.records) {
164
+ if (objectSchema.hasOwnProperty("extendObjType")) {
165
+ for (const storageResource of Object.values(objectSchema.storageResources)) {
166
+ if (storageResource.storageType === STORAGE_TYPES.dynamoDB) {
167
+ if (storageResource.serviceTag) {
168
+ if (storageResource.serviceTag !== serviceTag) {
169
+ additionalResourcePermission.push(
170
+ createIamRole(
171
+ {
172
+ [RESOURCE_CLASSES.dynamoDbTable]: Object.values(DYNAMO_RESOURCE)
173
+ },
174
+ [
175
+ externalResourceYaml(RESOURCE_CLASSES.dynamoDbAcrossService, upperCase(storageResource.tableName), storageResource.serviceTag)
176
+ ]
177
+ )
178
+ )
179
+ }
180
+ }
181
+ }
182
+ }
183
+ }
184
+ }
185
+
156
186
  return {
157
187
  templatePath: templatePath,
158
188
  templateData: {
@@ -40,8 +40,8 @@ const perRecordsValidatorSchema = {
40
40
  ],
41
41
  properties: {
42
42
  fieldName: {
43
- type: 'object',
44
-
43
+ type: 'string',
44
+
45
45
  },
46
46
  objType: {
47
47
  type: 'object',
@@ -22,6 +22,8 @@ const snsSharedLib = require('@izara_project/izara-core-library-sns')
22
22
  const sns = require('@izara_project/izara-core-library-external-request').sns
23
23
  const consts = require('@izara_project/izara-market-library-service-schemas/src/GenerateCodeLibs/src/Consts')
24
24
  const { getNestObject } = require('../../../../libs/source/GenerateCodeLibs');
25
+ //(<optionalRequired>)
26
+ //(</optionalRequired>)
25
27
  /**
26
28
  * description of function.
27
29
  * @param {Object} _izContext
@@ -35,6 +35,8 @@ const NoRetryError = require('@izara_project/izara-core-library-core').NoRetryEr
35
35
  const { v4: uuidv4 } = require('uuid')
36
36
  const coreConsts = require("@izara_project/izara-core-library-core/src/Consts");
37
37
  const { TOPIC_NAME_GENERATE_CODE } = require('@izara_project/izara-market-library-service-schemas/src/GenerateCodeLibs/src/Consts')
38
+ //(<optionalRequired>)
39
+ //(</optionalRequired>)
38
40
  /**
39
41
  *
40
42
  *
@@ -91,6 +93,8 @@ module.exports.createObject = async (
91
93
 
92
94
  _izContext.correlationIds.get(coreConsts.X_CORRELATION_ID)
93
95
 
96
+ //(<beforeCreateHook>)
97
+ //(</beforeCreateHook>)
94
98
  // create message Object to create Endpoint
95
99
  let messageObject = {
96
100
  fieldNames: {
@@ -120,7 +124,7 @@ module.exports.createObject = async (
120
124
  // send message to ImportBatchCreateHdrSqs
121
125
  let sendMessageToCreateEndpoint = {
122
126
  Message: JSON.stringify(messageObject),
123
- TopicArn: await snsSharedLib.snsTopicArnByFlowSchema(_izContext, Create_In)
127
+ TopicArn: await snsSharedLib.snsTopicArnByFlowSchema(_izContext, "Create_In")
124
128
  }
125
129
  _izContext.logger.debug("sendMessageToCreateEndpoint", sendMessageToCreateEndpoint);
126
130
  await sns.publishAsync(_izContext, sendMessageToCreateEndpoint);
@@ -55,7 +55,7 @@ function createDataForDefaultSnsInSqs(_izContext, srcPath) {
55
55
  defaultSnsInSqsDataList.push(
56
56
  {
57
57
  queueName: upperCase(FUNCTION_NAME.createObjectS3Complete) + upperCase(HANDLER.hdrSqs),
58
- subScription: upperCase(FUNCTION_NAME.updateNodeComplete) + "_Out"
58
+ subScription: "Out" + upperCase(FUNCTION_NAME.updateNodeComplete)
59
59
  }
60
60
  )
61
61
 
@@ -19,7 +19,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
19
19
 
20
20
  const path = require("path")
21
21
 
22
- const { SOURCE_PATH, SAVE_FILE_NAME, FUNCTION_NAME } = require('../../../../../../../../MainLibs/src/Consts');
22
+ const { SOURCE_PATH, SAVE_FILE_NAME, FUNCTION_NAME, HANDLER } = require('../../../../../../../../MainLibs/src/Consts');
23
23
  const { TOPIC_NAME_GENERATE_CODE } = require("../../../../../../../../GenerateCodeLibs/src/Consts");
24
24
  const { firstLetterUpperCase: upperCase } = require("../../../../../../../../MainLibs/src/Utils");
25
25
  const templatePath = path.join(__dirname, './template.ejs');
@@ -48,8 +48,8 @@ function data(_izContext, srcPath) {
48
48
 
49
49
  WebSocketSqsQueueNames.push(
50
50
  {
51
- queueName: upperCase(FUNCTION_NAME.reservedLimit),
52
- queueNameSubscription: "Out" + upperCase(FUNCTION_NAME.createObjectComplete)
51
+ queueName: upperCase(FUNCTION_NAME.reservedLimit) + upperCase(HANDLER.hdrSqs),
52
+ queueNameSubscription: upperCase(FUNCTION_NAME.createObjectComplete)
53
53
  }
54
54
  )
55
55
 
@@ -3,7 +3,7 @@
3
3
  Type: AWS::SNS::Subscription
4
4
  Properties:
5
5
  TopicArn: !Ref Out<%- queueNameSubscription %>
6
- Endpoint: "arn:aws:sqs:${self:custom.iz_region}:${self:custom.iz_accountId}:${self:custom.iz_resourcePrefix}<%- queueNameSubscription %>Out"
6
+ Endpoint: "arn:aws:sqs:${self:custom.iz_region}:${self:custom.iz_accountId}:${self:custom.iz_resourcePrefix}<%- queueName %>"
7
7
  Protocol: "sqs"
8
8
  ##===== [Queue]
9
9
  <%- queueName %>:
@@ -29,7 +29,7 @@ const hash = require('@izara_project/izara-shared-core').objectHash;
29
29
  const { NoRetryError,inMemoryCacheLib } = require('@izara_project/izara-core-library-core');
30
30
 
31
31
  const client = new ApiGatewayManagementApiClient({
32
- endpoint: `${process.env.iz_webSocketEndpoint}`
32
+ endpoint: `https://${process.env.iz_webSocketEndpoint}`
33
33
  })
34
34
 
35
35
  async function postToConnection(message, connectionId) {
@@ -69,7 +69,7 @@ function createWebSocketConnectYaml(_izContext, srcPath) {
69
69
  templatePath: templatePath,
70
70
  templateData: {
71
71
  functionName,
72
- resourceLocation: "src/generatedCode/FlowSchema/WebSocketConnect/source/",
72
+ resourceLocation: SOURCE_PATH.resourceLocationWebSocketMain,
73
73
  additionalResourcePermission,
74
74
  roleName: "WebsocketConnect"
75
75
 
@@ -45,7 +45,7 @@ function createWebSocketConnectYaml(_izContext, srcPath) {
45
45
  functionName,
46
46
  },
47
47
  setting: {
48
- savePath: path.join(srcPath, "../src/generatedCode/FlowSchema/WebSocketConnect/source/"),
48
+ savePath: path.join(srcPath, SOURCE_PATH.WebSocketMain),
49
49
  saveFileName: functionName,
50
50
  fileExtension: ".js",
51
51
  isAppend: false