@izara_project/izara-market-library-service-schemas 1.0.13 → 1.0.15

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 (27) hide show
  1. package/package.json +5 -5
  2. package/src/GenerateCodeLibs/src/GenerateCodeLibs.js +32 -29
  3. package/src/TemplateManager/src/FindData/GetByStorage/getByGraph.ejs +2 -1
  4. package/src/TemplateManager/src/GenerateCode.js +3 -3
  5. package/src/TemplateManager/src/PerActionEndpoint/Handler/HdrDsq/template.ejs +17 -14
  6. package/src/TemplateManager/src/PerActionEndpoint/Handler/HdrSqs/template.ejs +14 -13
  7. package/src/TemplateManager/src/PerActionEndpoint/MainFunction/Delete/template.ejs +0 -1
  8. package/src/TemplateManager/src/PerActionEndpoint/MainFunction/Update/data.js +1 -1
  9. package/src/TemplateManager/src/PerActionEndpoint/MainFunction/Update/template.ejs +18 -11
  10. package/src/TemplateManager/src/ProcessLogical/mainFunction/template.ejs +2 -2
  11. package/src/TemplateManager/src/RelationshipPerAction/DeleteRelationship/DeleteRelationship/functionYaml/HdrInv/data.js +2 -2
  12. package/src/TemplateManager/src/RelationshipPerAction/DeleteRelationship/DeleteRelationship/mainFunction/template.ejs +25 -17
  13. package/src/TemplateManager/src/RelationshipPerAction/DeleteRelationship/DeleteRelationship/perAction/HdrApi/template.ejs +39 -21
  14. package/src/TemplateManager/src/RelationshipPerAction/DeleteRelationship/DeleteRelationship/perAction/HdrDsq/template.ejs +38 -21
  15. package/src/TemplateManager/src/RelationshipPerAction/DeleteRelationship/DeleteRelationship/perAction/HdrInv/template.ejs +40 -22
  16. package/src/TemplateManager/src/RelationshipPerAction/DeleteRelationship/DeleteRelationship/perAction/HdrSqs/template.ejs +38 -22
  17. package/src/TemplateManager/src/RelationshipPerAction/UpdateRelationshipSchema/updateRelationship/functionYaml/HdrApi/data.js +1 -1
  18. package/src/TemplateManager/src/RelationshipPerAction/UpdateRelationshipSchema/updateRelationship/mainFunction/template.ejs +21 -11
  19. package/src/TemplateManager/src/RelationshipPerAction/UpdateRelationshipSchema/updateRelationship/perAction/HdrApi/template.ejs +37 -20
  20. package/src/TemplateManager/src/RelationshipPerAction/UpdateRelationshipSchema/updateRelationship/perAction/HdrDsq/template.ejs +40 -23
  21. package/src/TemplateManager/src/RelationshipPerAction/UpdateRelationshipSchema/updateRelationship/perAction/HdrInv/template.ejs +40 -23
  22. package/src/TemplateManager/src/RelationshipPerAction/UpdateRelationshipSchema/updateRelationship/perAction/HdrSqs/template.ejs +40 -23
  23. package/src/TemplateManager/src/externalService/FunctionNameConfig/data.js +45 -12
  24. package/src/TemplateManager/src/externalService/FunctionNameConfig/templateIntTesting.ejs +31 -0
  25. package/src/TemplateManager/src/externalService/FunctionNameConfig/templateYaml.ejs +10 -0
  26. package/src/TemplateManager/src/externalService/LambdaRole/data.js +10 -46
  27. package/src/TemplateManager/src/libs/Consts.js +3 -3
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@izara_project/izara-market-library-service-schemas",
3
- "version": "1.0.13",
3
+ "version": "1.0.15",
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.32",
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",
@@ -44,12 +44,14 @@ 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
51
  const RETURN_GET_DATA_FORMAT = {
51
52
  std: "STD", // { identifiers:{...}, fields:{...}} , data depend on getDataDetails
52
53
  full: "FULL", // {storageTag:{...getResult from database}}
54
+ onlyField: "ONLY_FIELD" // {graphHandler only return main fieldName (not versionedData) }
53
55
  }
54
56
 
55
57
  const schemaFunctionPerAction = {
@@ -76,8 +78,6 @@ const explodeDataPerAction = {
76
78
  * @param {middleware} middleware
77
79
  * @param {string} objectType - name of ObjectType
78
80
  * @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
81
  */
82
82
  function validateSchemaMiddleware(
83
83
  middleware,
@@ -89,13 +89,14 @@ function validateSchemaMiddleware(
89
89
  if (!schemaFunctionPerAction[action] || !explodeDataPerAction[action]) {
90
90
  throw new NoRetryError(`Not found function for generateValidatorSchema or explodeDataPerAction of action:${action}`);
91
91
  }
92
-
92
+ Logger.debug("setting in generateCodeLibs", setting)
93
93
  middleware.setServiceSchema(
94
94
  schemaFunctionPerAction[action],
95
95
  explodeDataPerAction[action],
96
96
  {
97
97
  objectType: objectType,
98
- specificFieldNames: setting.specificFieldNames ? setting.specificFieldNames : []
98
+ specificFieldNames: setting?.specificFieldNames ? setting.specificFieldNames : [],
99
+ action: action
99
100
  },
100
101
  );
101
102
  }
@@ -116,7 +117,7 @@ async function validateSchemaPerRecord(
116
117
  lambdaFunctionName,
117
118
  objType,
118
119
  action, // action
119
- setting = {}
120
+ setting
120
121
  ) {
121
122
  try {
122
123
  record._izContext.logger.debug("validateSchemaPerRecord: ", record,
@@ -135,14 +136,15 @@ async function validateSchemaPerRecord(
135
136
  const generateValidatorFunction = schemaFunctionPerAction[action];
136
137
  const explodeDataFunction = explodeDataPerAction[action]
137
138
 
138
- const generatedSchema = await generateValidatorFunction(record._izContext, objType, setting.specificFieldNames);
139
+ const generatedSchema = await generateValidatorFunction(record._izContext, objType, setting);
139
140
  record._izContext.logger.debug(`generatedSchema in validateSchemaPerRecord : `, generatedSchema);
140
141
 
141
142
 
142
143
  const explodedDataRequestParams = await explodeDataFunction(
143
144
  record._izContext,
144
145
  record.body.Message,
145
- objectSchema
146
+ objectSchema,
147
+ setting
146
148
  );
147
149
 
148
150
 
@@ -154,11 +156,11 @@ async function validateSchemaPerRecord(
154
156
 
155
157
  // if not pass validate will sent messsage to dlq and throw NoRetryError
156
158
  if (!validateStatus.pass) {
157
- await messageToDlq(record, `Invalid: ${validateStatus.error}`, sqsSharedLib.sqsQueueUrlDLQ(lambdaFunctionName));
159
+ await messageToDlq(record, `Invalid: ${validateStatus.error}`, await sqsSharedLib.sqsQueueUrlDLQ(record._izContext, lambdaFunctionName));
158
160
  record._izError = new Error(validateStatus.error)
159
161
  }
160
162
  } catch (error) {
161
- await messageToDlq(record, error.message, sqsSharedLib.sqsQueueUrlDLQ(lambdaFunctionName));
163
+ await messageToDlq(record, error.message, await sqsSharedLib.sqsQueueUrlDLQ(record._izContext, lambdaFunctionName));
162
164
  record._izError = new Error(error)
163
165
  }
164
166
 
@@ -176,7 +178,7 @@ async function sendMsgOutComplete(_izContext, topicName, messageObj, callingFlow
176
178
  let sendMessageOutComplete = {
177
179
  Message: JSON.stringify(messageObj),
178
180
  MessageAttributes: sns.createStringMessageAttributes(_izContext, messageAttributes),
179
- TopicArn: snsSharedLib.snsTopicArn(topicName),
181
+ TopicArn: await snsSharedLib.snsTopicArn(_izContext, topicName),
180
182
  };
181
183
 
182
184
  _izContext.logger.debug(`Send message to ${topicName} :`, sendMessageOutComplete);
@@ -214,7 +216,7 @@ async function messageToDlq(record, messageFailError, queueUrl) {
214
216
 
215
217
  record._izContext.logger.debug('messageToDlq, params before sending DLQ', params);
216
218
 
217
- await sqs.sendMessage(record._izContext, params).promise();
219
+ await sqs.sendMessage(record._izContext, params);
218
220
  record._izContext.logger.debug("----- messageToDlq sendMessage success -----");
219
221
  };
220
222
 
@@ -502,16 +504,16 @@ const generateDynamoDbIdentifiersWithCache = inMemoryCacheLib.inMemoryCacheLib(
502
504
  *
503
505
  * @param {Object} _izContext
504
506
  * @param {Object} objectSchema
505
- * @param {Object} getDataDetail
507
+ * @param {Object} dynamoStorageResource
506
508
  * @param {Object} reqIdentifiers
507
509
  */
508
- async function dynamoDbIdentifiersByStorageResource(_izContext, objectSchema, getDataDetail, reqIdentifiers) {
510
+ async function dynamoDbIdentifiersByStorageResource(_izContext, objectSchema, dynamoStorageResource, reqIdentifiers) {
509
511
 
510
512
  let dynamoIdentifiers = await generateDynamoDbIdentifiersWithCache(_izContext, objectSchema, reqIdentifiers)
511
513
 
512
514
  let identifiersByStorageResource = {};
513
515
 
514
- if (getDataDetail.groupByPartitionKeyField) {
516
+ if (dynamoStorageResource.groupByPartitionKeyField) {
515
517
 
516
518
  let deliminatorTreeIdentifiers = await generateDeliminatorTreeIdentifier(_izContext, objectSchema);
517
519
  _izContext.logger.debug("deliminatorTree: ", deliminatorTreeIdentifiers);
@@ -538,7 +540,7 @@ async function dynamoDbIdentifiersByStorageResource(_izContext, objectSchema, ge
538
540
  let newIdentifierValue = sortedIdentifiersValue.join(compositeKeyDeliminator.repeat(currentDeliminatorAmount + 1));
539
541
 
540
542
  identifiersByStorageResource = {
541
- [getDataDetail.groupByPartitionKeyField]: newIdentifierValue
543
+ [dynamoStorageResource.groupByPartitionKeyField]: newIdentifierValue
542
544
  };
543
545
 
544
546
  } else {
@@ -717,7 +719,10 @@ async function createUpdateDataDetail(_izContext, objectSchema) {
717
719
  let storageFieldNames = [];
718
720
  for (let [fieldName, fieldNameProperties] of Object.entries(objectSchema.fieldNames)) {
719
721
  if (fieldNameProperties.storageResourceTags.includes(storageTag)) {
720
- storageFieldNames.push(fieldName)
722
+ let versionedDataLabel = fieldNameProperties.versionedDataLabel
723
+ if (!fieldName.includes(versionedDataLabel)) { // not get fieldNames VersionedData_VersionedDataLabel_VersionedDataFieldNames
724
+ storageFieldNames.push(fieldName)
725
+ }
721
726
  }
722
727
  }
723
728
  if (storageProperties.storageType === consts.STORAGE_TYPES.graph) {
@@ -764,10 +769,8 @@ async function createUpdateDataDetail(_izContext, objectSchema) {
764
769
 
765
770
  _izContext.logger.debug("getGraphDataDetails", getGraphDataDetails);
766
771
  _izContext.logger.debug("getDynamoDataDetail", getDynamoDbDataDetails);
767
- _izContext.logger.debug("allUpdateDataDetail", allUpdateDataDetail)
768
-
769
- Object.assign(allUpdateDataDetail, getDynamoDbDataDetails, getGraphDataDetails)
770
772
 
773
+ Object.assign(allUpdateDataDetail, getDynamoDbDataDetails, getGraphDataDetails);
771
774
  return allUpdateDataDetail
772
775
  }
773
776
 
@@ -791,13 +794,13 @@ async function createDataDetailsLib(
791
794
  if (Object.keys(objectSchemas.fieldNames).length == 1) {
792
795
 
793
796
  for (const storageIdentifiers of settingFieldName.storageResourceTags) {
794
- _izContext.logger.debug("case only 1 fieldNames identifiers in ObjectSchema")
797
+ // _izContext.logger.debug("case only 1 fieldNames identifiers in ObjectSchema")
795
798
  if (storageResources[storageIdentifiers].storageType === consts.STORAGE_TYPES.dynamoDB) {
796
799
  if (createDataDetails.hasOwnProperty(storageIdentifiers)) {
797
- _izContext.logger.debug("same table")
800
+ // _izContext.logger.debug("same table")
798
801
  createDataDetails[storageIdentifiers].fieldNames.push(keyFieldName);
799
802
  } else {
800
- _izContext.logger.debug("new table")
803
+ // _izContext.logger.debug("new table")
801
804
  Object.assign(createDataDetails, {
802
805
  [storageResources[storageIdentifiers]]: {
803
806
  storageType: consts.STORAGE_TYPES.dynamoDB,
@@ -835,23 +838,23 @@ async function createDataDetailsLib(
835
838
  }
836
839
  continue
837
840
  };
838
- _izContext.logger.debug("case multiple fieldName");
841
+ // _izContext.logger.debug("case multiple fieldName");
839
842
  // validate storageResourceTags.
840
- _izContext.logger.debug("storageResourceTags is", settingFieldName.storageResourceTags);
843
+ // _izContext.logger.debug("storageResourceTags is", settingFieldName.storageResourceTags);
841
844
 
842
845
  for (let eachStorageResourceTag of settingFieldName.storageResourceTags) {
843
- _izContext.logger.debug("Loop eachStorageResourceTags", eachStorageResourceTag);
846
+ // _izContext.logger.debug("Loop eachStorageResourceTags", eachStorageResourceTag);
844
847
 
845
848
  if (!storageResources.hasOwnProperty(eachStorageResourceTag)) {
846
849
  throw new Error("storageResources is'n exist"); // should be validata in step uplode in s3
847
850
  } else {
848
851
  if (storageResources[eachStorageResourceTag].storageType == consts.STORAGE_TYPES.dynamoDB) {
849
852
  if (createDataDetails.hasOwnProperty(eachStorageResourceTag)) {
850
- _izContext.logger.debug("SAME STG DB", eachStorageResourceTag);
853
+ // _izContext.logger.debug("SAME STG DB", eachStorageResourceTag);
851
854
  createDataDetails[eachStorageResourceTag].fieldNames.push(keyFieldName);
852
855
 
853
856
  } else {
854
- _izContext.logger.debug("NEW STG DB", eachStorageResourceTag);
857
+ // _izContext.logger.debug("NEW STG DB", eachStorageResourceTag);
855
858
  Object.assign(createDataDetails, {
856
859
  [eachStorageResourceTag]: {
857
860
  storageType: consts.STORAGE_TYPES.dynamoDB,
@@ -874,11 +877,11 @@ async function createDataDetailsLib(
874
877
  );
875
878
  if (checkGraphServerTags) {
876
879
  if (createDataDetails.hasOwnProperty(checkGraphServerTags)) {
877
- _izContext.logger.debug("SAME STG", checkGraphServerTags);
880
+ // _izContext.logger.debug("SAME STG", checkGraphServerTags);
878
881
  createDataDetails[checkGraphServerTags].fieldNames.push(keyFieldName)
879
882
 
880
883
  } else {
881
- _izContext.logger.debug("NEW STG", checkGraphServerTags);
884
+ // _izContext.logger.debug("NEW STG", checkGraphServerTags);
882
885
  Object.assign(createDataDetails, {
883
886
  [checkGraphServerTags]: {
884
887
  storageType: consts.STORAGE_TYPES.graph,
@@ -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
  );
@@ -178,7 +178,7 @@ const createProcessLogicalPaginateFunctionYamlHdrDsq = require('./ProcessLogical
178
178
  const createProcessLogicalPaginateFunctionYamlHdrSqs = require('./ProcessLogicalPagination/FunctionYaml/HdrSqs/data')
179
179
 
180
180
  //get functionNameConfig
181
- const functionNameConfigFile = require('./externalService/FunctionNameConfig/data')
181
+ const functionNameConfigYamldata = require('./externalService/FunctionNameConfig/data')
182
182
 
183
183
  //lib of generateCode
184
184
  const { checkValidTableYaml } = require('./libs/GenerateCodeUtils');
@@ -479,8 +479,8 @@ async function generateCodeWithTemplate(_izContext, objSchemaPath) {
479
479
  }
480
480
  // console.log("createSourceParams templatePath in GenerateCode", createSourceParams.templatePath)
481
481
 
482
- const createFunctionNameConfig = functionNameConfigFile(_izContext, createSourceParams, saveFilePath);
483
- createSourceParams = createSourceParams.concat(createFunctionNameConfig);
482
+ const createFunctionNameConfig = functionNameConfigYamldata(_izContext, createSourceParams, saveFilePath);
483
+ createSourceParams = createSourceParams.concat(...createFunctionNameConfig);
484
484
 
485
485
  // delete file .yml before start to prevent confilct of data
486
486
  for (let folderPathToEmpty of Object.keys(GENERATECODE_SOURCE_PATH)) {
@@ -39,12 +39,15 @@ middleware.setValidatorSchema(
39
39
  //(</middlewareSettings>)
40
40
  )
41
41
 
42
+ /*
43
+ const perRecordsValidatorSchema = {
44
+ type: "object",
45
+ required: [],
46
+ properties: {},
47
+ }
48
+ */
49
+
42
50
  //(<globalValidatorSchema>)
43
- const perRecordsValidatorSchema = {
44
- type: "object",
45
- required: [],
46
- properties: {},
47
- }
48
51
  //(</globalValidatorSchema>)
49
52
 
50
53
  // if need to validate authorizer or additional params , add code to hook tag below
@@ -68,21 +71,21 @@ module.exports.main = middleware.wrap(async (event,context, callback) => {
68
71
  await validateSchemaPerRecord(
69
72
  record,
70
73
  "<%- functionName %><%- firstLetterUpperCase(handler) %>",
71
- "OBJTYPE,
72
- <%- action %>"
74
+ OBJTYPE,
75
+ "<%- action %>"
73
76
  //(<validateSchemaSetting>)
74
77
  //(</validateSchemaSetting>)
75
78
  )
76
79
 
77
80
  //for validate additional params
81
+ /*
82
+ await recordHandlerSharedLib.validateRecord(
83
+ record,
84
+ "<%- functionName %><%- firstLetterUpperCase(handler) %>",
85
+ perRecordsValidatorSchema
86
+ );
87
+ */
78
88
  //(<afterGenerateValidatorSchema>)
79
- /*
80
- await recordHandlerSharedLib.validateRecord(
81
- record,
82
- "<%- functionName %><%- firstLetterUpperCase(handler) %>",
83
- perRecordsValidatorSchema
84
- );
85
- */
86
89
  //(</afterGenerateValidatorSchema>)
87
90
 
88
91
  //(<additionalParams>)
@@ -38,13 +38,14 @@ middleware.setValidatorSchema(
38
38
  //(<middlewareSettings>)
39
39
  //(</middlewareSettings>)
40
40
  )
41
-
41
+ /*
42
+ const perRecordsValidatorSchema = {
43
+ type: "object",
44
+ required: [],
45
+ properties: {},
46
+ }
47
+ */
42
48
  //(<globalValidatorSchema>)
43
- const perRecordsValidatorSchema = {
44
- type: "object",
45
- required: [],
46
- properties: {},
47
- }
48
49
  //(</globalValidatorSchema>)
49
50
 
50
51
  // if need to validate authorizer or additional params , add code to hook tag below
@@ -75,14 +76,14 @@ module.exports.main = middleware.wrap(async (event,context, callback) => {
75
76
  )
76
77
 
77
78
  //for validate additional params
79
+ /*
80
+ await recordHandlerSharedLib.validateRecord(
81
+ record,
82
+ "<%- functionName %><%- firstLetterUpperCase(handler) %>",
83
+ perRecordsValidatorSchema
84
+ );
85
+ */
78
86
  //(<afterGenerateValidatorSchema>)
79
- /*
80
- await recordHandlerSharedLib.validateRecord(
81
- record,
82
- "<%- functionName %><%- firstLetterUpperCase(handler) %>",
83
- perRecordsValidatorSchema
84
- );
85
- */
86
87
  //(</afterGenerateValidatorSchema>)
87
88
 
88
89
  //(<additionalParams>)
@@ -69,7 +69,6 @@ module.exports.<%- functionName %>Main = async (
69
69
  });
70
70
 
71
71
  let errorsFound = []
72
- _izContext.correlationIds.set(coreConsts.BASE_USER_ID,"BasDev");
73
72
  const userId = _izContext.correlationIds.get(coreConsts.BASE_USER_ID);
74
73
  if (!userId){
75
74
  errorsFound.push("not have userId");
@@ -40,7 +40,7 @@ async function data(_izContext, objectSchema, srcPath) {
40
40
  async function createMainFunctionUpdateEndpoint(_izContext, objectSchema, action, srcPath) {
41
41
  let objectType = objectSchema.objectType
42
42
  let actionHandler = action;
43
- let functionName = upperCase(objectType) + upperCase(actionHandler);
43
+ let functionName = (objectType) + upperCase(actionHandler);
44
44
  return {
45
45
  templatePath: templatePath,
46
46
  templateData: {
@@ -83,7 +83,8 @@ module.exports.<%- functionName %>Main = async (
83
83
  _izContext.logger.debug("<%- functionName %> requestParams", requestParams)
84
84
  _izContext.logger.debug("<%- functionName %> callingFlowConfig", callingFlowConfig)
85
85
 
86
- _izContext.correlationIds.set(coreConsts.BASE_USER_ID, "BasDev");
86
+ let errorFounds = [];
87
+
87
88
  const userId = _izContext.correlationIds.get(coreConsts.BASE_USER_ID)
88
89
  if (!userId) {
89
90
  errorFounds.push("Not Have UserId")
@@ -94,11 +95,14 @@ module.exports.<%- functionName %>Main = async (
94
95
  //(<beforeQuery>)
95
96
  //(</beforeQuery>)
96
97
 
97
- const fields = requestParams.objInstanceFull.fields;
98
98
  const identifiers = requestParams.objInstanceFull.identifiers;
99
+ const fields = requestParams?.objInstanceFull?.fields || {};
100
+ const versionedDatas = requestParams?.objInstanceFull?.versionedDatas || {};
101
+
99
102
  _izContext.logger.debug("explode requestParams", {
103
+ identifiers: identifiers,
100
104
  fields: fields,
101
- identifiers: identifiers
105
+ versionedDatas: versionedDatas
102
106
  })
103
107
  let objectSchema = await getObjSchemaS3WithHierarchy(
104
108
  _izContext,
@@ -115,7 +119,6 @@ module.exports.<%- functionName %>Main = async (
115
119
 
116
120
  let originTimestamp = Date.now();
117
121
 
118
- let errorFounds = [];
119
122
 
120
123
  let messageAttributes
121
124
 
@@ -127,7 +130,8 @@ module.exports.<%- functionName %>Main = async (
127
130
  },
128
131
  objInstanceFull: {
129
132
  identifiers: identifiers,
130
- fields: fields
133
+ fields: fields,
134
+ versionedDatas: versionedDatas
131
135
  },
132
136
  status: 'error',
133
137
  errorFounds: errorFounds
@@ -136,7 +140,7 @@ module.exports.<%- functionName %>Main = async (
136
140
 
137
141
  updateNodeCompleteMessage = callingFlowSharedLib.addPassBackPropertiesToSnsResponseMessageObject(callingFlowConfig, updateNodeCompleteMessage);
138
142
  messageAttributes = callingFlowSharedLib.addCallingFlowToSnsResponseMessageAttributes(callingFlowConfig, {})
139
-
143
+
140
144
  let messageParams = {
141
145
  Message: JSON.stringify(updateNodeCompleteMessage),
142
146
  MessageAttributes: sns.createStringMessageAttributes(_izContext, messageAttributes),
@@ -165,6 +169,7 @@ module.exports.<%- functionName %>Main = async (
165
169
  serviceTag: SERVICE_TAG,
166
170
  identifiers: identifiers,
167
171
  fields: fields,
172
+ versionedDatas: versionedDatas
168
173
  // correlationIds: _izContext.correlationIds.get("id")
169
174
  }),
170
175
  PREFIX.updateNode
@@ -180,7 +185,8 @@ module.exports.<%- functionName %>Main = async (
180
185
  hash(
181
186
  {
182
187
  identifiers,
183
- fields
188
+ fields,
189
+ versionedDatas: versionedDatas
184
190
  })
185
191
  )
186
192
  )
@@ -194,7 +200,8 @@ module.exports.<%- functionName %>Main = async (
194
200
  },
195
201
  objInstanceFull: {
196
202
  identifiers: identifiers,
197
- fields: fields
203
+ fields: fields,
204
+ versionedDatas: versionedDatas
198
205
  },
199
206
  originTimestamp
200
207
  }
@@ -204,8 +211,7 @@ module.exports.<%- functionName %>Main = async (
204
211
  callingFlowSharedLib.addParentCallingFlowConfig(
205
212
  callingFlowConfig,
206
213
  callingFlowSharedLib.createCallingFlowConfig(
207
- await lambdaSharedLib.lambdaFunctionName(_izContext, TOPIC_NAME_GENERATE_CODE.updateNodeComplete),
208
- {}
214
+ await lambdaSharedLib.lambdaFunctionName(_izContext, TOPIC_NAME_GENERATE_CODE.updateNodeComplete), {}
209
215
  )
210
216
  )
211
217
  )
@@ -253,7 +259,8 @@ module.exports.<%- functionName %>Main = async (
253
259
  },
254
260
  objInstanceFull: {
255
261
  identifiers: identifiers,
256
- fields: fields
262
+ fields: fields,
263
+ versionedData: versionedData
257
264
  }
258
265
  },
259
266
  status: "complete",
@@ -167,7 +167,7 @@ module.exports.processLogical = async (
167
167
  _izContext.logger.debug("Have errorsFound: ", errorsFound)
168
168
  standardErrorParams.push(errorsFound)
169
169
  await logicalResultsSharedLib.completeLogicalResultsMain(...standardErrorParams);
170
- return;
170
+ return errorsFound;
171
171
  }
172
172
 
173
173
  const graphHandlerServiceTag = await serviceConfig.getGraphServiceTagWithCache(
@@ -347,7 +347,7 @@ module.exports.processLogical = async (
347
347
  errorsFound.push(`can't find data in table ${tableName} by query`)
348
348
  standardErrorParams.push(errorsFound)
349
349
  await logicalResultsSharedLib.completeLogicalResultsMain(...standardErrorParams);
350
- return;
350
+ return errorsFound;
351
351
  }
352
352
 
353
353
  for (const objInstanceBase of queryDatas.Items) {
@@ -22,7 +22,7 @@ const fs = require('fs');
22
22
  const { ACTIONS, HANDLER, STORAGE_TYPES } = require('@izara_project/izara-core-library-service-schemas/src/Consts')
23
23
 
24
24
  const { firstLetterLowerCase: lowerCase, firstLetterUpperCase: upperCase } = require("../../../../../../../MainLibs/src/Utils")
25
- const { createIamRole, resourceNames, RESOURCE_CLASSES, SOURCE_PATH, SAVE_FILE_NAME, FUNCTION_NAME, SNS_RESOURCE, defaultIamRolePerAction, awaitingMultipleStepsRole, SHORT_FUNCTION_NAME } = require("../../../../../libs/Consts");
25
+ const { createIamRole, resourceNames, RESOURCE_CLASSES, SOURCE_PATH, SAVE_FILE_NAME, FUNCTION_NAME, SNS_RESOURCE, defaultIamRolePerAction, awaitingMultipleStepsRole, SHORT_FUNCTION_NAME, shortNameHandler } = require("../../../../../libs/Consts");
26
26
 
27
27
  const templatePath = path.join(__dirname, './template.ejs')
28
28
 
@@ -68,7 +68,7 @@ function createParamForCreateSource(srcPath) {
68
68
  handlerType,
69
69
  additionalResourcePermission,
70
70
  resourceLocation: SOURCE_PATH.resourceLocationRelationshipPerAction,
71
- functionNameConfig: upperCase(SHORT_FUNCTION_NAME.deleteRel) + upperCase(handlerType)
71
+ functionNameConfig: upperCase(SHORT_FUNCTION_NAME.deleteRel) + upperCase(shortNameHandler(handlerType))
72
72
  },
73
73
  setting: {
74
74
  savePath: path.join(srcPath, SOURCE_PATH.appYaml),
@@ -60,7 +60,7 @@ const {
60
60
  *
61
61
  * @returns {object} description of return value
62
62
  */
63
- module.exports.<%- functionName %> = async (
63
+ module.exports.deleteRelationship = async (
64
64
  _izContext,
65
65
  requestParams,
66
66
  callingFlowConfig = {},
@@ -70,15 +70,17 @@ module.exports.<%- functionName %> = async (
70
70
 
71
71
 
72
72
  try {
73
- _izContext.logger.debug('createRelationship _izContext: ', _izContext);
74
- _izContext.logger.debug('createRelationship requestParams: ', requestParams);
75
- _izContext.logger.debug('createRelationship callingFlowConfig: ', callingFlowConfig);
73
+ _izContext.logger.debug('deleteRelationship _izContext: ', _izContext);
74
+ _izContext.logger.debug('deleteRelationship requestParams: ', requestParams);
75
+ _izContext.logger.debug('deleteRelationship callingFlowConfig: ', callingFlowConfig);
76
76
 
77
77
 
78
78
  const {
79
- objects,
79
+ firstObject,
80
+ secondObject,
80
81
  relType,
81
- relationshipProperties
82
+ relationshipProperties,
83
+ relationshipDirection
82
84
  //(<requestparamDeleteRel>)
83
85
  //(</requestparamDeleteRel>)
84
86
  } = requestParams;
@@ -114,8 +116,8 @@ module.exports.<%- functionName %> = async (
114
116
  }
115
117
  }
116
118
 
117
- await validateIdentifiersExists(_izContext, objects[0].objType, objects[0].identifiers);
118
- await validateIdentifiersExists(_izContext, objects[1].objType, objects[1].identifiers);
119
+ await validateIdentifiersExists(_izContext, firstObject.objType, firstObject.identifiers);
120
+ await validateIdentifiersExists(_izContext, secondObject.objType, secondObject.identifiers);
119
121
  // finished validate object and identifiers
120
122
 
121
123
  //(<afterValidateDeleteRel>)
@@ -136,8 +138,8 @@ module.exports.<%- functionName %> = async (
136
138
  const { serviceTag: fromServiceTag, objectType: fromObjectType } = from.objType
137
139
  const { serviceTag: toServiceTag, objectType: toObjectType } = to.objType
138
140
 
139
- const { serviceTag: firstServiceTag, objectType: firstObjectType } = objects[0].objType;
140
- const { serviceTag: secondServiceTag, objectType: secondObjectType } = objects[1].objType;
141
+ const { serviceTag: firstServiceTag, objectType: firstObjectType } = firstObject.objType;
142
+ const { serviceTag: secondServiceTag, objectType: secondObjectType } = secondObject.objType;
141
143
 
142
144
  // find exists link
143
145
  if (
@@ -189,7 +191,7 @@ module.exports.<%- functionName %> = async (
189
191
  }
190
192
 
191
193
  // validate canCreate properties relationship
192
- for (const [propName, propSetting] of Object.entries(relationshipSchema.properties)) {
194
+ for (const [propName, propSetting] of Object.entries(relationshipSchema.fieldNames)) {
193
195
  if (propSetting.requiredOnCreate === true) {
194
196
  if (!relationshipProperties.hasOwnProperty(propName)) {
195
197
  errorsFound.push(`Missing requiredOnCreate property:${propKey}`);
@@ -210,9 +212,11 @@ module.exports.<%- functionName %> = async (
210
212
  if (errorsFound.length) {
211
213
 
212
214
  let deleteRelCompleteMsg = {
213
- objects: objects,
215
+ firstObject: firstObject,
216
+ secondObject: secondObject,
214
217
  relType: relType,
215
218
  relationshipProperties: relationshipProperties,
219
+ relationshipDirection: relationshipDirection,
216
220
  //(<inDeleteRelCompleteMsg>)
217
221
  //(</inDeleteRelCompleteMsg>)
218
222
  status: 'error',
@@ -241,7 +245,7 @@ module.exports.<%- functionName %> = async (
241
245
 
242
246
 
243
247
  // before create awaitingStepId per graph storageResource
244
- const linkTypeId = createLinkTypeId(_izContext, [objects[0].objType, objects[1].objType], relType);
248
+ const linkTypeId = createLinkTypeId(_izContext, objects[0].objType, objects[1].objType, relType, relationshipDirection);
245
249
 
246
250
  let usedGraphServiceTag = []; // collect used graph serviceTag, use to check duplicate graph serviceTag across graph serverTag
247
251
  let targetGraphStorageResources = []; // collect used graph storageResources, filtered duplicate graphServiceTag from graphServerTag out
@@ -277,9 +281,11 @@ module.exports.<%- functionName %> = async (
277
281
 
278
282
  // prepare message body
279
283
  let deleteRelMessageBody = {
280
- objects: objects,
284
+ firstObject: firstObject,
285
+ secondObject: secondObject,
281
286
  relType: relType,
282
- relationshipProperties
287
+ relationshipProperties: relationshipProperties,
288
+ relationshipDirection: relationshipDirection,
283
289
  //(<inDeleteRelMessageBody>)
284
290
  //(</inDeleteRelMessageBody>)
285
291
  }
@@ -315,10 +321,12 @@ module.exports.<%- functionName %> = async (
315
321
  }
316
322
 
317
323
  return {
318
- objects,
324
+ firstObject,
325
+ secondObject,
319
326
  relType,
320
327
  relationshipProperties,
321
- errorFounds: errorsFound
328
+ relationshipDirection,
329
+ errorsFound
322
330
  };
323
331
 
324
332