@izara_project/izara-market-library-service-schemas 1.0.14 → 1.0.16

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 (67) hide show
  1. package/package.json +5 -5
  2. package/src/GenerateCodeLibs/src/Consts.js +3 -1
  3. package/src/GenerateCodeLibs/src/GenerateCodeLibs.js +122 -98
  4. package/src/MainLibs/src/Utils.js +10 -9
  5. package/src/TemplateManager/src/FindData/GetByStorage/getByGraph.ejs +2 -1
  6. package/src/TemplateManager/src/GenerateCode.js +55 -12
  7. package/src/TemplateManager/src/OutPerActionComplete/OutGetComplete/functionYaml/data.js +86 -0
  8. package/src/TemplateManager/src/OutPerActionComplete/OutGetComplete/functionYaml/template.ejs +33 -0
  9. package/src/TemplateManager/src/OutPerActionComplete/OutGetComplete/handler/data.js +59 -0
  10. package/src/TemplateManager/src/OutPerActionComplete/OutGetComplete/handler/template.ejs +129 -0
  11. package/src/TemplateManager/src/OutPerActionComplete/OutGetComplete/mainFunction/data.js +53 -0
  12. package/src/TemplateManager/src/OutPerActionComplete/OutGetComplete/mainFunction/template.ejs +130 -0
  13. package/src/TemplateManager/src/OutPerActionComplete/OutGetComplete/sns-out/data.js +62 -0
  14. package/src/TemplateManager/src/OutPerActionComplete/OutGetComplete/sqs-in-sns/data.js +58 -0
  15. package/src/TemplateManager/src/OutPerActionComplete/OutGetComplete/sqs-in-sns/template.ejs +47 -0
  16. package/src/TemplateManager/src/PerActionEndpoint/FunctionYaml/HdrApi/data.js +15 -7
  17. package/src/TemplateManager/src/PerActionEndpoint/FunctionYaml/HdrDsq/data.js +14 -6
  18. package/src/TemplateManager/src/PerActionEndpoint/FunctionYaml/HdrInv/data.js +14 -4
  19. package/src/TemplateManager/src/PerActionEndpoint/FunctionYaml/HdrSqs/data.js +14 -4
  20. package/src/TemplateManager/src/PerActionEndpoint/FunctionYaml/HdrWbs/data.js +171 -0
  21. package/src/TemplateManager/src/PerActionEndpoint/FunctionYaml/HdrWbs/request.json +19 -0
  22. package/src/TemplateManager/src/PerActionEndpoint/FunctionYaml/HdrWbs/template.ejs +29 -0
  23. package/src/TemplateManager/src/PerActionEndpoint/FunctionYaml/webSocketConnect/data.js +60 -0
  24. package/src/TemplateManager/src/PerActionEndpoint/FunctionYaml/webSocketConnect/template.ejs +10 -0
  25. package/src/TemplateManager/src/PerActionEndpoint/Handler/HdrDsq/template.ejs +15 -12
  26. package/src/TemplateManager/src/PerActionEndpoint/Handler/HdrSqs/template.ejs +14 -13
  27. package/src/TemplateManager/src/PerActionEndpoint/Handler/WebSocket/data.js +76 -0
  28. package/src/TemplateManager/src/PerActionEndpoint/Handler/WebSocket/template.ejs +141 -0
  29. package/src/TemplateManager/src/PerActionEndpoint/Handler/WebSocketConnect/data.js +56 -0
  30. package/src/TemplateManager/src/PerActionEndpoint/Handler/WebSocketConnect/template.ejs +55 -0
  31. package/src/TemplateManager/src/PerActionEndpoint/MainFunction/Create/template.ejs +40 -36
  32. package/src/TemplateManager/src/PerActionEndpoint/MainFunction/Delete/template.ejs +0 -1
  33. package/src/TemplateManager/src/PerActionEndpoint/MainFunction/Get/template.ejs +54 -22
  34. package/src/TemplateManager/src/PerActionEndpoint/MainFunction/Update/template.ejs +23 -27
  35. package/src/TemplateManager/src/ProcessLogical/mainFunction/template.ejs +2 -2
  36. package/src/TemplateManager/src/RelationshipPerAction/CreateRelationship/createRelationship/functionYaml/HdrSqs/template.ejs +4 -0
  37. package/src/TemplateManager/src/RelationshipPerAction/CreateRelationship/createRelationship/perAction/HdrApi/template.ejs +2 -1
  38. package/src/TemplateManager/src/RelationshipPerAction/CreateRelationship/createRelationship/perAction/HdrDsq/template.ejs +1 -5
  39. package/src/TemplateManager/src/RelationshipPerAction/CreateRelationship/createRelationship/perAction/HdrSqs/template.ejs +1 -5
  40. package/src/TemplateManager/src/RelationshipPerAction/CreateRelationship/createRelationshipComplete/mainFunction/template.ejs +11 -7
  41. package/src/TemplateManager/src/RelationshipPerAction/DeleteRelationship/DeleteRelationship/functionYaml/HdrSqs/template.ejs +4 -0
  42. package/src/TemplateManager/src/RelationshipPerAction/DeleteRelationship/DeleteRelationship/perAction/HdrApi/template.ejs +5 -4
  43. package/src/TemplateManager/src/RelationshipPerAction/DeleteRelationship/DeleteRelationship/perAction/HdrInv/template.ejs +3 -2
  44. package/src/TemplateManager/src/RelationshipPerAction/DeleteRelationship/DeleteRelationshipComplete/mainFunction/template.ejs +16 -13
  45. package/src/TemplateManager/src/RelationshipPerAction/UpdateRelationshipSchema/updateRalationshipComplete/mainFunction/template.ejs +9 -6
  46. package/src/TemplateManager/src/RelationshipPerAction/UpdateRelationshipSchema/updateRelationship/functionYaml/HdrSqs/template.ejs +4 -0
  47. package/src/TemplateManager/src/RelationshipPerAction/UpdateRelationshipSchema/updateRelationship/perAction/HdrApi/template.ejs +8 -5
  48. package/src/TemplateManager/src/RelationshipPerAction/UpdateRelationshipSchema/updateRelationship/perAction/HdrDsq/template.ejs +1 -1
  49. package/src/TemplateManager/src/RelationshipPerAction/UpdateRelationshipSchema/updateRelationship/perAction/HdrInv/template.ejs +10 -8
  50. package/src/TemplateManager/src/RelationshipPerAction/UpdateRelationshipSchema/updateRelationship/perAction/HdrSqs/template.ejs +1 -1
  51. package/src/TemplateManager/src/ResourceYaml/dynamodb/{awaitingMultipleStepData.js → defaultDynamoDbTable.js} +39 -3
  52. package/src/TemplateManager/src/ResourceYaml/sns-in-sqs/defaultSnsInSqsForFindDataAndProcessLogical.js +6 -3
  53. package/src/TemplateManager/src/externalService/FunctionNameConfig/data.js +1 -1
  54. package/src/TemplateManager/src/externalService/LambdaRole/data.js +5 -10
  55. package/src/TemplateManager/src/externalService/SnsTopicSubscriotions/data.js +14 -0
  56. package/src/TemplateManager/src/flowTag/resources/dynamoDb/data.js +65 -0
  57. package/src/TemplateManager/src/flowTag/webSocket/webSocketConnect/functionYaml/data.js +56 -0
  58. package/src/TemplateManager/src/flowTag/webSocket/webSocketConnect/functionYaml/template.ejs +10 -0
  59. package/src/TemplateManager/src/flowTag/webSocket/webSocketConnect/handler/data.js +55 -0
  60. package/src/TemplateManager/src/flowTag/webSocket/webSocketConnect/handler/template.ejs +63 -0
  61. package/src/TemplateManager/src/flowTag/webSocket/websocketHandler/functionYaml/data.js +75 -0
  62. package/src/TemplateManager/src/flowTag/webSocket/websocketHandler/functionYaml/template.ejs +33 -0
  63. package/src/TemplateManager/src/flowTag/webSocket/websocketHandler/lambda/data.js +57 -0
  64. package/src/TemplateManager/src/flowTag/webSocket/websocketHandler/lambda/template.ejs +131 -0
  65. package/src/TemplateManager/src/libs/Consts.js +7 -2
  66. package/src/TemplateManager/src/libs/GenerateCodeUtils.js +3 -1
  67. package/src/TemplateManager/src/ResourceYaml/dynamodb/processLogicalAndFindData.js +0 -99
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@izara_project/izara-market-library-service-schemas",
3
- "version": "1.0.14",
3
+ "version": "1.0.16",
4
4
  "description": "Schemas for Izara Market project",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -20,10 +20,10 @@
20
20
  "testEnvironment": "node"
21
21
  },
22
22
  "dependencies": {
23
- "@izara_project/izara-core-library-core": "^1.0.13",
24
- "@izara_project/izara-core-library-external-request": "^1.0.14",
25
- "@izara_project/izara-core-library-service-schemas": "^1.0.25",
26
- "@izara_project/izara-shared": "^1.0.96",
23
+ "@izara_project/izara-core-library-core": "^1.0.14",
24
+ "@izara_project/izara-core-library-external-request": "^1.0.16",
25
+ "@izara_project/izara-core-library-service-schemas": "^1.0.33",
26
+ "@izara_project/izara-shared": "^1.0.113",
27
27
  "ejs": "^3.1.10",
28
28
  "js-beautify": "^1.15.1",
29
29
  "lodash": "^4.17.21",
@@ -54,7 +54,9 @@ const TOPIC_NAME_GENERATE_CODE = {
54
54
  createNodeComplete: "CreateObjectComplete",
55
55
  outCreateNodeComplete: "OutCreateObjectComplete",
56
56
  deleteNodeComplete: "DeleteNodeComplete",
57
- outDeleteNodeComplete: "OutDeleteNodeComplete"
57
+ outDeleteNodeComplete: "OutDeleteNodeComplete",
58
+ getNodeComplete: "GetNodeComplete",
59
+ outGetNodeComplete: "OutGetNodeComplete"
58
60
  }
59
61
 
60
62
  const GRAPH_HANDLER_SERVICE_NAME = {
@@ -44,13 +44,10 @@ const {
44
44
  generateDeliminatorTreeIdentifier,
45
45
  generateDeliminatorTreePerFieldName
46
46
  } = require('@izara_project/izara-core-library-service-schemas/src/libs/DeliminatorTree');
47
+ const Logger = require("@izara_project/izara-core-library-logger");
47
48
 
48
49
  const nodeLabelRegexPattern = "^[a-zA-Z0-9_-]+(?:\:[a-zA-Z0-9_-]+)?$"
49
50
 
50
- const RETURN_GET_DATA_FORMAT = {
51
- std: "STD", // { identifiers:{...}, fields:{...}} , data depend on getDataDetails
52
- full: "FULL", // {storageTag:{...getResult from database}}
53
- }
54
51
 
55
52
  const schemaFunctionPerAction = {
56
53
  [consts.ACTIONS.create]: validatorSchema.generateValidatorSchemaForCreate,
@@ -76,8 +73,6 @@ const explodeDataPerAction = {
76
73
  * @param {middleware} middleware
77
74
  * @param {string} objectType - name of ObjectType
78
75
  * @param {string} action - action type of Lambda create | update | get | delete
79
- * @param {object} [setting]
80
- * @param {string[]} [setting.specificFieldNames] - optional - specific fieldNames use as param in generateValidatorFunction
81
76
  */
82
77
  function validateSchemaMiddleware(
83
78
  middleware,
@@ -89,13 +84,14 @@ function validateSchemaMiddleware(
89
84
  if (!schemaFunctionPerAction[action] || !explodeDataPerAction[action]) {
90
85
  throw new NoRetryError(`Not found function for generateValidatorSchema or explodeDataPerAction of action:${action}`);
91
86
  }
92
-
87
+ Logger.debug("setting in generateCodeLibs", setting)
93
88
  middleware.setServiceSchema(
94
89
  schemaFunctionPerAction[action],
95
90
  explodeDataPerAction[action],
96
91
  {
97
92
  objectType: objectType,
98
- specificFieldNames: setting.specificFieldNames ? setting.specificFieldNames : []
93
+ specificFieldNames: setting?.specificFieldNames ? setting.specificFieldNames : [],
94
+ action: action
99
95
  },
100
96
  );
101
97
  }
@@ -116,7 +112,7 @@ async function validateSchemaPerRecord(
116
112
  lambdaFunctionName,
117
113
  objType,
118
114
  action, // action
119
- setting = {}
115
+ setting
120
116
  ) {
121
117
  try {
122
118
  record._izContext.logger.debug("validateSchemaPerRecord: ", record,
@@ -135,14 +131,15 @@ async function validateSchemaPerRecord(
135
131
  const generateValidatorFunction = schemaFunctionPerAction[action];
136
132
  const explodeDataFunction = explodeDataPerAction[action]
137
133
 
138
- const generatedSchema = await generateValidatorFunction(record._izContext, objType, setting.specificFieldNames);
134
+ const generatedSchema = await generateValidatorFunction(record._izContext, objType, setting);
139
135
  record._izContext.logger.debug(`generatedSchema in validateSchemaPerRecord : `, generatedSchema);
140
136
 
141
137
 
142
138
  const explodedDataRequestParams = await explodeDataFunction(
143
139
  record._izContext,
144
140
  record.body.Message,
145
- objectSchema
141
+ objectSchema,
142
+ setting
146
143
  );
147
144
 
148
145
 
@@ -158,13 +155,67 @@ async function validateSchemaPerRecord(
158
155
  record._izError = new Error(validateStatus.error)
159
156
  }
160
157
  } catch (error) {
158
+ record._izContext.logger.debug("validate PerSchema Record error", error)
161
159
  await messageToDlq(record, error.message, await sqsSharedLib.sqsQueueUrlDLQ(record._izContext, lambdaFunctionName));
162
160
  record._izError = new Error(error)
163
161
  }
164
162
 
165
163
  }
166
164
 
165
+ // /**
166
+ // * use to validate record for Lambda handler hdrSqs/hdrDsq
167
+ // * Note!: cannot throw error when use this function outside recordHandler
168
+
169
+ // * @param {string} objectType - name of ObjectType
170
+ // * @param {string} action - action type of Lambda create | update | get | delete
171
+ // * @param {object} [setting]
172
+ // */
173
+ // async function validateSchemaPerWebSocket(
174
+ // _izContext,
175
+ // requestParams,
176
+ // objectType,
177
+ // action,
178
+ // setting = {}
179
+ // ) {
180
+ // _izContext.logger.debug("validateSchema Per WebSocketFunction", {
181
+ // objectType,
182
+ // requestParams,
183
+ // action,
184
+ // setting
185
+ // })
186
+ // try {
187
+ // if (action === "update") {
188
+ // setting.updateScenario = "versionedData"
189
+ // }
190
+
191
+ // const objType = utils.createObjType(objectType)
192
+ // _izContext.logger.debug("objType in validatorSchema per WebSocket", objType)
193
+
194
+ // const objectSchema = await getObjectSchema.getObjSchemaS3WithHierarchy(_izContext, objType);
195
+ // _izContext.logger.debug("objectSchema", objectSchema)
196
+ // const generateValidatorSchema = schemaFunctionPerAction[action];
197
+ // const explodeDataFunction = explodeDataPerAction[action];
198
+
199
+ // const generateValidatorSchemaPerWebSocket = await generateValidatorSchema(_izContext, objType, setting);
200
+ // _izContext.logger.debug("Generate Validator Schema For WebSocket :", generateValidatorSchemaPerWebSocket);
201
+
202
+ // const explodedDataPerWebSocket = await explodeDataFunction(_izContext, requestParams, objectSchema, setting);
167
203
 
204
+ // _izContext.logger.debug("exploded RequestParams Data in GeneratorValidatorSchema :", explodedDataPerWebSocket);
205
+
206
+
207
+ // let validateStatus = validateObject(_izContext, generateValidatorSchemaPerWebSocket, explodedDataPerWebSocket);
208
+ // _izContext.logger.debug('validateStatus : ', validateStatus);
209
+
210
+ // if (!validateStatus.pass) {
211
+ // const validatorError = new Error(`validation failed: ${validateStatus.error}`)
212
+ // throw validatorError;
213
+ // }
214
+ // } catch (err) {
215
+ // _izContext.logger.error("Error in validateSchemaPerWebSocket:", err);
216
+ // throw err;
217
+ // }
218
+ // }
168
219
 
169
220
  async function sendMsgOutComplete(_izContext, topicName, messageObj, callingFlowConfig) {
170
221
 
@@ -214,7 +265,7 @@ async function messageToDlq(record, messageFailError, queueUrl) {
214
265
 
215
266
  record._izContext.logger.debug('messageToDlq, params before sending DLQ', params);
216
267
 
217
- sqs.sendMessage(record._izContext, params);
268
+ await sqs.sendMessage(record._izContext, params);
218
269
  record._izContext.logger.debug("----- messageToDlq sendMessage success -----");
219
270
  };
220
271
 
@@ -502,16 +553,16 @@ const generateDynamoDbIdentifiersWithCache = inMemoryCacheLib.inMemoryCacheLib(
502
553
  *
503
554
  * @param {Object} _izContext
504
555
  * @param {Object} objectSchema
505
- * @param {Object} getDataDetail
556
+ * @param {Object} dynamoStorageResource
506
557
  * @param {Object} reqIdentifiers
507
558
  */
508
- async function dynamoDbIdentifiersByStorageResource(_izContext, objectSchema, getDataDetail, reqIdentifiers) {
559
+ async function dynamoDbIdentifiersByStorageResource(_izContext, objectSchema, dynamoStorageResource, reqIdentifiers) {
509
560
 
510
561
  let dynamoIdentifiers = await generateDynamoDbIdentifiersWithCache(_izContext, objectSchema, reqIdentifiers)
511
562
 
512
563
  let identifiersByStorageResource = {};
513
564
 
514
- if (getDataDetail.groupByPartitionKeyField) {
565
+ if (dynamoStorageResource.groupByPartitionKeyField) {
515
566
 
516
567
  let deliminatorTreeIdentifiers = await generateDeliminatorTreeIdentifier(_izContext, objectSchema);
517
568
  _izContext.logger.debug("deliminatorTree: ", deliminatorTreeIdentifiers);
@@ -538,7 +589,7 @@ async function dynamoDbIdentifiersByStorageResource(_izContext, objectSchema, ge
538
589
  let newIdentifierValue = sortedIdentifiersValue.join(compositeKeyDeliminator.repeat(currentDeliminatorAmount + 1));
539
590
 
540
591
  identifiersByStorageResource = {
541
- [getDataDetail.groupByPartitionKeyField]: newIdentifierValue
592
+ [dynamoStorageResource.groupByPartitionKeyField]: newIdentifierValue
542
593
  };
543
594
 
544
595
  } else {
@@ -555,41 +606,24 @@ async function dynamoDbIdentifiersByStorageResource(_izContext, objectSchema, ge
555
606
  * @param {object} _izContext
556
607
  * @param {object[]} getResults
557
608
  * @param {object} objectSchema
558
- * @param {string} returnFormat
559
609
  * @returns
560
610
  */
561
- function collectGetData(_izContext, getResults, objectSchema, returnFormat = RETURN_GET_DATA_FORMAT.std) {
611
+ function collectGetData(_izContext, getResults, objectSchema, returnSystemFieldsName) {
562
612
  _izContext.logger.debug("collectGetData: ", {
563
613
  getResults,
564
614
  objectSchema,
565
- returnFormat
615
+ returnSystemFieldsName
566
616
  });
567
617
 
568
- if (returnFormat === "STD") {
569
- return collectGetDataStdFormat(_izContext, getResults, objectSchema);
570
- } else if (returnFormat === "FULL") {
571
- return collectGetDataFullFormat(_izContext, getResults,)
572
- } else {
573
- throw new NoRetryError("invalid format");
574
- }
575
- }
576
-
577
-
578
- /**
579
- * helper function for collectGetData
580
- *
581
- * @param {object} _izContext
582
- * @param {object[]} getResults
583
- * @param {set} identifierFieldNames
584
- * @returns
585
- */
586
- function collectGetDataStdFormat(_izContext, getResults, objectSchema) {
587
618
 
588
619
  let collectedData = {
589
620
  identifiers: {},
590
621
  fields: {}
591
- };
622
+ }
592
623
 
624
+ if (returnSystemFieldsName) {
625
+ Object.assign(collectedData, { versionDataSystemFields: {} })
626
+ }
593
627
  const identifierFieldNames = new Set(utils.getUsedFieldNamesOfIdentifiers(_izContext, objectSchema.identifiers));
594
628
 
595
629
  let addedFieldNames = new Set();
@@ -628,6 +662,9 @@ function collectGetDataStdFormat(_izContext, getResults, objectSchema) {
628
662
  }
629
663
  }
630
664
  }
665
+ if (getData.versionDataSystemFields || returnSystemFieldsName == true) {
666
+ Object.assign(collectedData.versionDataSystemFields, getData.versionDataSystemFields)
667
+ }
631
668
  } else if (getDataDetail.storageType === consts.STORAGE_TYPES.dynamoDB) {
632
669
  for (const getDetailFieldName of getDataDetail.fieldNames) {
633
670
  if (addedFieldNames.has(getDetailFieldName)) {
@@ -664,50 +701,6 @@ function collectGetDataStdFormat(_izContext, getResults, objectSchema) {
664
701
  }
665
702
  }
666
703
 
667
- /**
668
- *
669
- * helper function for collectGetData
670
- *
671
- * @param {object} _izContext
672
- * @param {objects[]} getResults
673
- * @returns
674
- */
675
- function collectGetDataFullFormat(_izContext, getResults) {
676
- let collectedData = {};
677
-
678
- // if isFound === true then return null from this function
679
- let isFound = false;
680
-
681
-
682
- for (const [getData, getDataDetail] of getResults) {
683
- if (!getData || !Object.keys(getData).length) {
684
- continue;
685
- }
686
-
687
- // this process will add result from graph and dynamo to collectedData object by add identifiers and fieldName from getData
688
- if (getDataDetail.storageType === consts.STORAGE_TYPES.graph) {
689
- if (getData.objInstanceFull?.identifiers && Object.keys(getData.objInstanceFull?.identifiers).length) {
690
- Object.assign(collectedData, { [getDataDetail.graphServiceTag]: getData });
691
- isFound = true;
692
- }
693
- } else if (getDataDetail.storageType === consts.STORAGE_TYPES.dynamoDB) {
694
-
695
- if (getData && Object.keys(getData).length) {
696
- Object.assign(collectedData, { [getDataDetail.tableName]: getData });
697
- isFound = true;
698
- }
699
- } else {
700
- throw new NoRetryError("collectGetData unhandled storageType");
701
- }
702
- }
703
-
704
- if (isFound) {
705
- return collectedData;
706
- } else {
707
- return null;
708
- }
709
- }
710
-
711
704
 
712
705
  async function createUpdateDataDetail(_izContext, objectSchema) {
713
706
  let getGraphDataDetails = {};
@@ -717,7 +710,10 @@ async function createUpdateDataDetail(_izContext, objectSchema) {
717
710
  let storageFieldNames = [];
718
711
  for (let [fieldName, fieldNameProperties] of Object.entries(objectSchema.fieldNames)) {
719
712
  if (fieldNameProperties.storageResourceTags.includes(storageTag)) {
720
- storageFieldNames.push(fieldName)
713
+ let versionedDataLabel = fieldNameProperties.versionedDataLabel
714
+ if (!fieldName.includes(versionedDataLabel)) { // not get fieldNames VersionedData_VersionedDataLabel_VersionedDataFieldNames
715
+ storageFieldNames.push(fieldName)
716
+ }
721
717
  }
722
718
  }
723
719
  if (storageProperties.storageType === consts.STORAGE_TYPES.graph) {
@@ -764,10 +760,8 @@ async function createUpdateDataDetail(_izContext, objectSchema) {
764
760
 
765
761
  _izContext.logger.debug("getGraphDataDetails", getGraphDataDetails);
766
762
  _izContext.logger.debug("getDynamoDataDetail", getDynamoDbDataDetails);
767
- _izContext.logger.debug("allUpdateDataDetail", allUpdateDataDetail)
768
-
769
- Object.assign(allUpdateDataDetail, getDynamoDbDataDetails, getGraphDataDetails)
770
763
 
764
+ Object.assign(allUpdateDataDetail, getDynamoDbDataDetails, getGraphDataDetails);
771
765
  return allUpdateDataDetail
772
766
  }
773
767
 
@@ -791,13 +785,13 @@ async function createDataDetailsLib(
791
785
  if (Object.keys(objectSchemas.fieldNames).length == 1) {
792
786
 
793
787
  for (const storageIdentifiers of settingFieldName.storageResourceTags) {
794
- _izContext.logger.debug("case only 1 fieldNames identifiers in ObjectSchema")
788
+ // _izContext.logger.debug("case only 1 fieldNames identifiers in ObjectSchema")
795
789
  if (storageResources[storageIdentifiers].storageType === consts.STORAGE_TYPES.dynamoDB) {
796
790
  if (createDataDetails.hasOwnProperty(storageIdentifiers)) {
797
- _izContext.logger.debug("same table")
791
+ // _izContext.logger.debug("same table")
798
792
  createDataDetails[storageIdentifiers].fieldNames.push(keyFieldName);
799
793
  } else {
800
- _izContext.logger.debug("new table")
794
+ // _izContext.logger.debug("new table")
801
795
  Object.assign(createDataDetails, {
802
796
  [storageResources[storageIdentifiers]]: {
803
797
  storageType: consts.STORAGE_TYPES.dynamoDB,
@@ -835,23 +829,23 @@ async function createDataDetailsLib(
835
829
  }
836
830
  continue
837
831
  };
838
- _izContext.logger.debug("case multiple fieldName");
832
+ // _izContext.logger.debug("case multiple fieldName");
839
833
  // validate storageResourceTags.
840
- _izContext.logger.debug("storageResourceTags is", settingFieldName.storageResourceTags);
834
+ // _izContext.logger.debug("storageResourceTags is", settingFieldName.storageResourceTags);
841
835
 
842
836
  for (let eachStorageResourceTag of settingFieldName.storageResourceTags) {
843
- _izContext.logger.debug("Loop eachStorageResourceTags", eachStorageResourceTag);
837
+ // _izContext.logger.debug("Loop eachStorageResourceTags", eachStorageResourceTag);
844
838
 
845
839
  if (!storageResources.hasOwnProperty(eachStorageResourceTag)) {
846
840
  throw new Error("storageResources is'n exist"); // should be validata in step uplode in s3
847
841
  } else {
848
842
  if (storageResources[eachStorageResourceTag].storageType == consts.STORAGE_TYPES.dynamoDB) {
849
843
  if (createDataDetails.hasOwnProperty(eachStorageResourceTag)) {
850
- _izContext.logger.debug("SAME STG DB", eachStorageResourceTag);
844
+ // _izContext.logger.debug("SAME STG DB", eachStorageResourceTag);
851
845
  createDataDetails[eachStorageResourceTag].fieldNames.push(keyFieldName);
852
846
 
853
847
  } else {
854
- _izContext.logger.debug("NEW STG DB", eachStorageResourceTag);
848
+ // _izContext.logger.debug("NEW STG DB", eachStorageResourceTag);
855
849
  Object.assign(createDataDetails, {
856
850
  [eachStorageResourceTag]: {
857
851
  storageType: consts.STORAGE_TYPES.dynamoDB,
@@ -874,11 +868,11 @@ async function createDataDetailsLib(
874
868
  );
875
869
  if (checkGraphServerTags) {
876
870
  if (createDataDetails.hasOwnProperty(checkGraphServerTags)) {
877
- _izContext.logger.debug("SAME STG", checkGraphServerTags);
871
+ // _izContext.logger.debug("SAME STG", checkGraphServerTags);
878
872
  createDataDetails[checkGraphServerTags].fieldNames.push(keyFieldName)
879
873
 
880
874
  } else {
881
- _izContext.logger.debug("NEW STG", checkGraphServerTags);
875
+ // _izContext.logger.debug("NEW STG", checkGraphServerTags);
882
876
  Object.assign(createDataDetails, {
883
877
  [checkGraphServerTags]: {
884
878
  storageType: consts.STORAGE_TYPES.graph,
@@ -942,6 +936,34 @@ async function createDeleteDataDetail(_izContext, objectSchema) {
942
936
  return allDeleteDataDetail
943
937
  }
944
938
 
939
+ function createFieldForUpdateDynamoDb(_izContext, objectSchema, dynamoDataDetail, fields) {
940
+ console.log("createFieldForUpdateDynamoDb", {
941
+ objectSchema,
942
+ dynamoDataDetail,
943
+ fields
944
+ })
945
+
946
+ let fieldsForUpdateDynamo = {};
947
+
948
+ for (let [fieldName, fieldSetting] of Object.entries(objectSchema.fieldNames)) {
949
+ if (fieldSetting.canUpdate == true || !fieldSetting.hasOwnProperty("canUpdate")) {
950
+ if (dynamoDataDetail.fieldNames.includes(fieldName)) {
951
+ if (fields[fieldName]) {
952
+ if (!fieldsForUpdateDynamo.hasOwnProperty(fields[fieldName])) {
953
+ console.log(fields[fieldName])
954
+ Object.assign(fieldsForUpdateDynamo, {
955
+ [fieldName]: fields[fieldName]
956
+ }
957
+ )
958
+ }
959
+ } else {
960
+ fieldsForUpdateDynamo = {}
961
+ }
962
+ }
963
+ }
964
+ }
965
+ return fieldsForUpdateDynamo
966
+ }
945
967
 
946
968
  module.exports = {
947
969
  sendMsgOutComplete,
@@ -958,7 +980,9 @@ module.exports = {
958
980
  dynamoDbIdentifiersByStorageResource,
959
981
  createUpdateDataDetail,
960
982
  createDataDetailsLib,
961
- createDeleteDataDetail
983
+ createDeleteDataDetail,
984
+
985
+ createFieldForUpdateDynamoDb
962
986
  }
963
987
 
964
988
 
@@ -18,6 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
18
18
  'use strict';
19
19
 
20
20
  const lodash = require("lodash")
21
+ const ACTIONS = require("../../TemplateManager/src/libs/Consts");
21
22
 
22
23
  module.exports.firstLetterUpperCase = (text) => {
23
24
  return text.charAt(0).toUpperCase() + text.slice(1)
@@ -37,14 +38,14 @@ module.exports.checkOverWriteGenerateMainFunction = (objectSchema, action) => {
37
38
  return overWriteStatus
38
39
  }
39
40
 
40
- module.exports.renameObjectType = (objectSchema, srcPath) => {
41
- const shortNamePath = path.join(srcPath, "./schemas/ShortNameObjectType.js");
42
- const shortName = fs.existsSync(shortNamePath) ? require(shortNamePath) : {};
41
+ // module.exports.renameObjectType = (objectSchema, srcPath) => {
42
+ // const shortNamePath = path.join(srcPath, "./schemas/ShortNameObjectType.js");
43
+ // const shortName = fs.existsSync(shortNamePath) ? require(shortNamePath) : {};
43
44
 
44
- let newObjectSchema = lodash.cloneDeep(objectSchema)
45
+ // let newObjectSchema = lodash.cloneDeep(objectSchema)
45
46
 
46
- if (shortName[objectSchema.objectType]) {
47
- newObjectSchema.shortNameObjectType = shortName[objectSchema.objectType]
48
- }
49
- return newObjectSchema
50
- }
47
+ // if (shortName[objectSchema.objectType]) {
48
+ // newObjectSchema.shortNameObjectType = shortName[objectSchema.objectType]
49
+ // }
50
+ // return newObjectSchema
51
+ // }
@@ -11,7 +11,8 @@ let getDataByGraph = await graphSharedLib.getNodeV2(
11
11
  graphHandlerServiceTag,
12
12
  objType,
13
13
  {
14
- identifiers: identifiers
14
+ ...identifiers,
15
+ ...fieldName
15
16
  },
16
17
  <%- JSON.stringify(versionedDataLabel) %>
17
18
  );
@@ -24,6 +24,7 @@ const { readFileSync } = require('fs');
24
24
  const {
25
25
  getAllLocalObjectSchemasWithHierarchy,
26
26
  getAllLocalRelationshipSchemas,
27
+ getAllLocalFlowSchemas
27
28
  } = require('@izara_project/izara-core-library-service-schemas/src/GetObjectSchema');
28
29
 
29
30
  const {
@@ -73,11 +74,10 @@ const snsInSqsOutDeleteNodeComplete = require("./OutPerActionComplete/OutDeleteC
73
74
 
74
75
  // create Main resource
75
76
  const createSourceDataDynamoDB = require('./ResourceYaml/dynamodb/mainResourcePerObjectSchemaData');
76
- const createDefaultSourceDataDynamoDB = require('./ResourceYaml/dynamodb/processLogicalAndFindData');
77
77
  const createSourceSnsAndSqs = require('./ResourceYaml/sns-in-sqs/snsAndSqsPerActiondata');
78
78
  const createDataForCreateSourceSnsOut = require('./ResourceYaml/sns-out/data')
79
79
  const createFindDataAndProcessLogicalDefaultSnsInSqs = require('./ResourceYaml/sns-in-sqs/defaultSnsInSqsForFindDataAndProcessLogical');
80
- const createAwaitingMultipleStepDynamoDbData = require('./ResourceYaml/dynamodb/awaitingMultipleStepData');
80
+ const createDefaultDynamoDb = require('./ResourceYaml/dynamodb/defaultDynamoDbTable');
81
81
  const createDefaultSnsOutForFindDataAndProcessLogical = require('./ResourceYaml/sns-out/defaultSnsOutForFindDataAndProcessLogical')
82
82
 
83
83
  // create External Service
@@ -177,11 +177,25 @@ const createProcessLogicalPaginateMainFunction = require('./ProcessLogicalPagina
177
177
  const createProcessLogicalPaginateFunctionYamlHdrDsq = require('./ProcessLogicalPagination/FunctionYaml/HdrDsq/data')
178
178
  const createProcessLogicalPaginateFunctionYamlHdrSqs = require('./ProcessLogicalPagination/FunctionYaml/HdrSqs/data')
179
179
 
180
+ // getNode complete
181
+ // const createGetNodeCompleteFunctionYaml = require('./OutPerActionComplete/OutGetComplete/functionYaml/data');
182
+ // const createGetNodeCompleteHandler = require('./OutPerActionComplete/OutGetComplete/handler/data');
183
+ // const createGetNodeCompleteMainFunction = require('./OutPerActionComplete/OutGetComplete/mainFunction/data');
184
+ // const createGetNodeSnsInSqs = require('./OutPerActionComplete/OutGetComplete/sqs-in-sns/data');
185
+ const createGetNodeSnsOut = require('./OutPerActionComplete/OutGetComplete/sns-out/data');
186
+
187
+ const createWebSocketDynamoDb = require('./flowTag/resources/dynamoDb/data');
188
+ const createWebSocketConnectYaml = require('./flowTag/webSocket/webSocketConnect/functionYaml/data');
189
+ const createWebSocketConnectHandler = require('./flowTag/webSocket/webSocketConnect/handler/data');
190
+ const createWebSocketHandlerYaml = require('./flowTag/webSocket/websocketHandler/functionYaml/data')
191
+ const createWebSocketHandler = require('./flowTag/webSocket/websocketHandler/lambda/data');
192
+
180
193
  //get functionNameConfig
181
- const functionNameConfigYamldata = require('./externalService/FunctionNameConfig/data')
194
+ const functionNameConfigYamldata = require('./externalService/FunctionNameConfig/data');
182
195
 
183
196
  //lib of generateCode
184
- const { checkValidTableYaml } = require('./libs/GenerateCodeUtils');
197
+ const { checkValidTableYaml,
198
+ } = require('./libs/GenerateCodeUtils');
185
199
 
186
200
  const { NoRetryError } = require('@izara_project/izara-core-library-core');
187
201
 
@@ -216,6 +230,9 @@ async function generateCodeWithTemplate(_izContext, objSchemaPath) {
216
230
  updateRelationship: join(saveFilePath, `../src/generatedCode/RelationshipPerAction/source/`),
217
231
  };
218
232
 
233
+ let createSourceParams = [];
234
+
235
+ let createdTableYaml = {};
219
236
 
220
237
  // from app/src/shcemas
221
238
  let allObjSchemas = await getAllLocalObjectSchemasWithHierarchy(_izContext, objSchemaPath);
@@ -227,17 +244,37 @@ async function generateCodeWithTemplate(_izContext, objSchemaPath) {
227
244
  const processLogicalPaginateFunctionYamlHdrSqs = await createProcessLogicalPaginateFunctionYamlHdrSqs(_izContext, allObjSchemas, saveFilePath);
228
245
 
229
246
  const allObjectRelationships = await getAllLocalRelationshipSchemas(_izContext, objSchemaPath);
247
+ // _izContext.logger.debug("allObjectRelationships::", allObjectRelationships);
248
+
249
+ const allLocalFlowSchemas = await getAllLocalFlowSchemas(_izContext, objSchemaPath);
250
+ // _izContext.logger.debug("allLocalFlowSchemas::", allLocalFlowSchemas)
251
+ if (allLocalFlowSchemas) {
252
+ for (const flowSchema of allLocalFlowSchemas.records) {
253
+ /*
254
+ webSocketHandler to send to queue
255
+ */
256
+ }
257
+ const webSocketTaskTable = createWebSocketDynamoDb(_izContext, saveFilePath);
258
+ const webSocketConnectYaml = createWebSocketConnectYaml(_izContext, saveFilePath);
259
+ const webSocketConnectHandler = createWebSocketConnectHandler(_izContext, saveFilePath);
260
+ const webSocketHandlerYaml = createWebSocketHandlerYaml(_izContext, saveFilePath);
261
+ const webSocketHandler = createWebSocketHandler(_izContext, saveFilePath);
262
+ // const webSocketHandler
263
+
264
+ const webSocketResource = [...webSocketTaskTable, ...webSocketConnectYaml, ...webSocketConnectHandler, ...webSocketHandler, ...webSocketHandlerYaml]
265
+ createSourceParams.push(
266
+ ...webSocketResource
267
+ )
268
+ }
269
+
230
270
 
231
- // _izContext.logger.debug("allObjectRelationships: ", allObjectRelationships)
232
271
  /*
233
272
  Should we generateCode with objectSchema that not in hierarchy or not?
234
273
  Should use objectSchema with hierarchy because we use storageResource of parent to create lambda iam role in .yml file
235
274
  */
236
275
 
237
- let createSourceParams = [];
238
276
 
239
277
  // use to check dynamoDB table yaml, to prevent duplicate tableName
240
- let createdTableYaml = {};
241
278
 
242
279
  for (const relTag in allObjectRelationships) {
243
280
  // const relTagData = allObjectRelationships[relTag];
@@ -249,10 +286,12 @@ async function generateCodeWithTemplate(_izContext, objSchemaPath) {
249
286
  // createSourceParams = createSourceParams.concat(createSourceMainResourcesRelSchema);
250
287
  }
251
288
 
289
+
252
290
  // create External service
253
291
  const createFunctionIamRole = await createExternalLambdaRole(_izContext, allObjSchemas.records, allObjectRelationships, saveFilePath);
254
292
  const createSnsSubscription = await createExternalSnsSubscriptions(_izContext, allObjectRelationships, allObjSchemas.records, saveFilePath);
255
293
  for (let objectSchema of allObjSchemas.records) {
294
+
256
295
  // generate handler perAction
257
296
  const createSourceHdrInv = perActionGetHdrInvData(_izContext, objectSchema, saveFilePath);
258
297
  const createSourceHdrApi = perActionGetHdrApiData(_izContext, objectSchema, saveFilePath);
@@ -274,10 +313,8 @@ async function generateCodeWithTemplate(_izContext, objSchemaPath) {
274
313
  const createFunctionYamlHdrApi = functionYamlDataHdrApi(_izContext, objectSchema, saveFilePath);
275
314
  const createFunctionYamlHdrSqs = functionYamlDataHdrSqs(_izContext, objectSchema, saveFilePath);
276
315
  const createFunctionYamlHdrDsq = functionYamlDataHdrDsq(_izContext, objectSchema, saveFilePath);
277
-
278
316
  // wrapMain Function
279
317
  const createFunctionYaml = [...createFunctionYamlHdrApi, ...createFunctionYamlHdrDsq, ...createFunctionYamlHdrInv, ...createFunctionYamlHdrSqs];
280
-
281
318
  // generate Resource ..via dynamoDb sns-in-sqs sns-put
282
319
  let [createResourceDynamo, newCreatedTableYaml] = checkValidTableYaml(
283
320
  _izContext,
@@ -335,11 +372,10 @@ async function generateCodeWithTemplate(_izContext, objSchemaPath) {
335
372
  const createDeleteNodeResource = [...createFunctionYamlDeleteNodeComplete, ...createHandlerOutDeleteNodeComplete, ...createMainFunctionDeleteNodeComplete, ...createSnsOutDeleteNodeComplete, ...createSnsInSqsDeleteNodeComplete]
336
373
 
337
374
  // create default data resource such as findData ProcessLogical and awaitingMultipleStep
338
- const createResourceFindDataAndProcessLogical = createDefaultSourceDataDynamoDB(_izContext, saveFilePath);
339
- const createResourceAwaitingMultipleStep = createAwaitingMultipleStepDynamoDbData(_izContext, saveFilePath);
375
+ const createResourceDefaultDynamoDb = createDefaultDynamoDb(_izContext, saveFilePath);
340
376
  const createResourceDefaultSnsInSqsFindDataAndProcessLogical = createFindDataAndProcessLogicalDefaultSnsInSqs(_izContext, saveFilePath);
341
377
  const createResourceDefaultSnsOutFindDataAndProcessLogical = createDefaultSnsOutForFindDataAndProcessLogical(_izContext, saveFilePath)
342
- const createMainResourceDefault = [...createResourceFindDataAndProcessLogical, ...createResourceDefaultSnsInSqsFindDataAndProcessLogical, ...createResourceAwaitingMultipleStep, ...createResourceDefaultSnsOutFindDataAndProcessLogical];
378
+ const createMainResourceDefault = [...createResourceDefaultSnsInSqsFindDataAndProcessLogical, ...createResourceDefaultDynamoDb, ...createResourceDefaultSnsOutFindDataAndProcessLogical];
343
379
 
344
380
  // create function yaml for update relationshipSchema per handler
345
381
  const createYamlUpdateRelationshipSchemaHdrSqs = createUpdateRelationshipFunctionYamlHdrSqs(_izContext, saveFilePath);
@@ -458,7 +494,13 @@ async function generateCodeWithTemplate(_izContext, objSchemaPath) {
458
494
  const processLogicalPaginateMainFunction = createProcessLogicalPaginateMainFunction(_izContext, saveFilePath);
459
495
  const processLogicalPaginateResource = [processLogicalPaginateFunctionYamlHdrDsq, processLogicalPaginateFunctionYamlHdrSqs, processLogicalPaginateHandlerDsq, processLogicalPaginateHandlerSqs, processLogicalPaginateMainFunction]
460
496
 
497
+ // const getNodeCompleteFunctionYaml = createGetNodeCompleteFunctionYaml(_izContext, saveFilePath);
498
+ // const getNodeCompleteHandler = createGetNodeCompleteHandler(_izContext, saveFilePath);
499
+ // const getNodeCompleteMainFunction = createGetNodeCompleteMainFunction(_izContext, saveFilePath);
500
+ // const getNodeCompleteSnsInSqs = createGetNodeSnsInSqs(_izContext, saveFilePath);
501
+ const getNodeCompleteSnsOut = createGetNodeSnsOut(_izContext, saveFilePath);
461
502
 
503
+ const getNodeCompleteResource = [...getNodeCompleteSnsOut]
462
504
  createSourceParams.push(...createMainResourceDefault,
463
505
  createSnsSubscription,
464
506
  createFunctionIamRole,
@@ -468,6 +510,7 @@ async function generateCodeWithTemplate(_izContext, objSchemaPath) {
468
510
  ...processLogicalResource,
469
511
  ...processLogicalPaginateResource,
470
512
  ...createDeleteNodeResource,
513
+ ...getNodeCompleteResource
471
514
  );
472
515
  if (allObjectRelationships.length) {
473
516
  createSourceParams.push(