@izara_project/izara-market-library-service-schemas 1.0.9 → 1.0.10
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.
- package/package.json +1 -1
- package/src/GenerateCodeLibs/src/Consts.js +12 -12
- package/src/GenerateCodeLibs/src/GenerateCodeLibs.js +63 -17
- package/src/TemplateManager/src/FindData/mainFunction/template.ejs +0 -7
- package/src/TemplateManager/src/OutPerActionComplete/OutCreateComplete/functionYaml/data.js +4 -3
- package/src/TemplateManager/src/OutPerActionComplete/OutCreateComplete/functionYaml/template.ejs +1 -1
- package/src/TemplateManager/src/OutPerActionComplete/OutCreateComplete/handler/data.js +0 -2
- package/src/TemplateManager/src/OutPerActionComplete/OutCreateComplete/mainFunction/template.ejs +9 -6
- package/src/TemplateManager/src/OutPerActionComplete/OutDeleteComplete/functionYaml/data.js +4 -3
- package/src/TemplateManager/src/OutPerActionComplete/OutDeleteComplete/functionYaml/template.ejs +1 -1
- package/src/TemplateManager/src/OutPerActionComplete/OutDeleteComplete/handler/data.js +0 -2
- package/src/TemplateManager/src/OutPerActionComplete/OutDeleteComplete/mainFunction/template.ejs +5 -2
- package/src/TemplateManager/src/OutPerActionComplete/OutUpdateComplete/functionYaml/data.js +4 -2
- package/src/TemplateManager/src/OutPerActionComplete/OutUpdateComplete/functionYaml/template.ejs +1 -1
- package/src/TemplateManager/src/OutPerActionComplete/OutUpdateComplete/handler/data.js +0 -2
- package/src/TemplateManager/src/OutPerActionComplete/OutUpdateComplete/mainFunction/template.ejs +5 -1
- package/src/TemplateManager/src/PerActionEndpoint/FunctionYaml/HdrApi/data.js +1 -1
- package/src/TemplateManager/src/PerActionEndpoint/FunctionYaml/HdrDsq/data.js +1 -1
- package/src/TemplateManager/src/PerActionEndpoint/FunctionYaml/HdrInv/data.js +1 -1
- package/src/TemplateManager/src/PerActionEndpoint/FunctionYaml/HdrSqs/data.js +3 -3
- package/src/TemplateManager/src/PerActionEndpoint/Handler/HdrDsq/template.ejs +6 -2
- package/src/TemplateManager/src/PerActionEndpoint/Handler/HdrSqs/template.ejs +2 -2
- package/src/TemplateManager/src/PerActionEndpoint/MainFunction/Create/template.ejs +47 -8
- package/src/TemplateManager/src/ProcessLogical/ProcessLogicalYaml/data.js +2 -2
- package/src/TemplateManager/src/ProcessLogicalPagination/FunctionYaml/HdrDsq/data.js +2 -2
- package/src/TemplateManager/src/ProcessLogicalPagination/FunctionYaml/HdrSqs/data.js +2 -2
- package/src/TemplateManager/src/RelationshipPerAction/CreateRelationship/createRelationship/functionYaml/HdrApi/data.js +2 -2
- package/src/TemplateManager/src/RelationshipPerAction/CreateRelationship/createRelationship/functionYaml/HdrDsq/data.js +2 -2
- package/src/TemplateManager/src/RelationshipPerAction/CreateRelationship/createRelationship/functionYaml/HdrInv/data.js +2 -2
- package/src/TemplateManager/src/RelationshipPerAction/CreateRelationship/createRelationship/functionYaml/HdrSqs/data.js +2 -3
- package/src/TemplateManager/src/RelationshipPerAction/CreateRelationship/createRelationship/mainFunction/data.js +2 -0
- package/src/TemplateManager/src/RelationshipPerAction/CreateRelationship/createRelationship/mainFunction/template.ejs +63 -23
- package/src/TemplateManager/src/RelationshipPerAction/CreateRelationship/createRelationship/perAction/HdrApi/template.ejs +45 -28
- package/src/TemplateManager/src/RelationshipPerAction/CreateRelationship/createRelationship/perAction/HdrDsq/template.ejs +42 -21
- package/src/TemplateManager/src/RelationshipPerAction/CreateRelationship/createRelationship/perAction/HdrInv/template.ejs +41 -22
- package/src/TemplateManager/src/RelationshipPerAction/CreateRelationship/createRelationship/perAction/HdrSqs/template.ejs +42 -21
- package/src/TemplateManager/src/RelationshipPerAction/CreateRelationship/createRelationshipComplete/functionYaml/data.js +2 -2
- package/src/TemplateManager/src/RelationshipPerAction/DeleteRelationship/DeleteRelationship/functionYaml/HdrApi/data.js +2 -2
- package/src/TemplateManager/src/RelationshipPerAction/DeleteRelationship/DeleteRelationship/functionYaml/HdrDsq/data.js +2 -2
- package/src/TemplateManager/src/RelationshipPerAction/DeleteRelationship/DeleteRelationship/functionYaml/HdrInv/data.js +2 -2
- package/src/TemplateManager/src/RelationshipPerAction/DeleteRelationship/DeleteRelationship/functionYaml/HdrSqs/data.js +2 -2
- package/src/TemplateManager/src/RelationshipPerAction/DeleteRelationship/DeleteRelationship/mainFunction/data.js +2 -0
- package/src/TemplateManager/src/RelationshipPerAction/DeleteRelationship/DeleteRelationship/mainFunction/template.ejs +1 -1
- package/src/TemplateManager/src/RelationshipPerAction/DeleteRelationship/DeleteRelationshipComplete/functionYaml/data.js +2 -2
- package/src/TemplateManager/src/RelationshipPerAction/UpdateRelationshipSchema/updateRalationshipComplete/functionYaml/data.js +2 -2
- package/src/TemplateManager/src/RelationshipPerAction/UpdateRelationshipSchema/updateRelationship/functionYaml/HdrApi/data.js +2 -2
- package/src/TemplateManager/src/RelationshipPerAction/UpdateRelationshipSchema/updateRelationship/functionYaml/HdrDsq/data.js +2 -2
- package/src/TemplateManager/src/RelationshipPerAction/UpdateRelationshipSchema/updateRelationship/functionYaml/HdrInv/data.js +2 -2
- package/src/TemplateManager/src/RelationshipPerAction/UpdateRelationshipSchema/updateRelationship/functionYaml/HdrSqs/data.js +2 -2
- package/src/TemplateManager/src/RelationshipPerAction/UpdateRelationshipSchema/updateRelationship/mainFunction/data.js +1 -1
- package/src/TemplateManager/src/RelationshipPerAction/UpdateRelationshipSchema/updateRelationship/mainFunction/template.ejs +1 -1
- package/src/TemplateManager/src/RelationshipPerAction/UpdateRelationshipSchema/updateRelationship/perAction/HdrDsq/template.ejs +1 -1
- package/src/TemplateManager/src/RelationshipPerAction/UpdateRelationshipSchema/updateRelationship/perAction/HdrSqs/template.ejs +1 -1
- package/src/TemplateManager/src/ResourceYaml/sns-out/defaultSnsOutForFindDataAndProcessLogical.js +2 -2
- package/src/TemplateManager/src/TranslateIdReq/ProcessingTranslateIds/functionYaml/data.js +2 -2
- package/src/TemplateManager/src/TranslateIdReq/TranslateIds/functionYaml/HdrDsq/data.js +2 -2
- package/src/TemplateManager/src/TranslateIdReq/TranslateIds/functionYaml/HdrSqs/data.js +2 -2
- package/src/TemplateManager/src/externalService/LambdaRole/data.js +7 -6
- package/src/TemplateManager/src/libs/Consts.js +21 -1
- package/src/TemplateManager/src/CreateRelationship/createRelationship/functionYaml/HdrApi/data.js +0 -119
|
@@ -22,7 +22,7 @@ const path = require('path');
|
|
|
22
22
|
const templatePath = path.join(__dirname, "./template.ejs")
|
|
23
23
|
|
|
24
24
|
const { HANDLER, STORAGE_TYPES, ACTIONS } = require('@izara_project/izara-core-library-service-schemas/src/Consts')
|
|
25
|
-
const { createIamRole, resourceNames, RESOURCE_CLASSES, DEFAULT_LAMBDA_ROLE_PER_ACTION, SQS_RESOURCE, SOURCE_PATH, SAVE_FILE_NAME, FUNCTION_NAME, defaultIamRolePerAction, shortNameHandler } = require("../../../libs/Consts");
|
|
25
|
+
const { createIamRole, resourceNames, RESOURCE_CLASSES, DEFAULT_LAMBDA_ROLE_PER_ACTION, SQS_RESOURCE, SOURCE_PATH, SAVE_FILE_NAME, FUNCTION_NAME, defaultIamRolePerAction, shortNameHandler, SHORT_FUNCTION_NAME } = require("../../../libs/Consts");
|
|
26
26
|
const { firstLetterUpperCase: upperCase } = require('../../../../../MainLibs/src/Utils');
|
|
27
27
|
|
|
28
28
|
/**
|
|
@@ -123,7 +123,7 @@ async function data(_izContext, objectSchemas, srcPath) {
|
|
|
123
123
|
resourceLocation: SOURCE_PATH.resourceLocationProcessLogical,
|
|
124
124
|
handlerType: HANDLER.hdrDsq,
|
|
125
125
|
additionalResourcePermission,
|
|
126
|
-
functionNameConfig: upperCase(
|
|
126
|
+
functionNameConfig: upperCase(SHORT_FUNCTION_NAME.paginateProcessLogical) + upperCase(shortNameHandler(HANDLER.hdrDsq))
|
|
127
127
|
},
|
|
128
128
|
setting: {
|
|
129
129
|
savePath: path.join(srcPath, SOURCE_PATH.appYaml),
|
|
@@ -22,7 +22,7 @@ const path = require('path');
|
|
|
22
22
|
const templatePath = path.join(__dirname, "./template.ejs")
|
|
23
23
|
|
|
24
24
|
const { HANDLER, STORAGE_TYPES, ACTIONS } = require('@izara_project/izara-core-library-service-schemas/src/Consts')
|
|
25
|
-
const { createIamRole, resourceNames, RESOURCE_CLASSES, DEFAULT_LAMBDA_ROLE_PER_ACTION, SQS_RESOURCE, SOURCE_PATH, SAVE_FILE_NAME, FUNCTION_NAME, DYNAMO_RESOURCE, defaultIamRolePerAction, SNS_RESOURCE, shortNameHandler } = require("../../../libs/Consts");
|
|
25
|
+
const { createIamRole, resourceNames, RESOURCE_CLASSES, DEFAULT_LAMBDA_ROLE_PER_ACTION, SQS_RESOURCE, SOURCE_PATH, SAVE_FILE_NAME, FUNCTION_NAME, DYNAMO_RESOURCE, defaultIamRolePerAction, SNS_RESOURCE, shortNameHandler, SHORT_FUNCTION_NAME } = require("../../../libs/Consts");
|
|
26
26
|
const { firstLetterUpperCase: upperCase } = require('../../../../../MainLibs/src/Utils');
|
|
27
27
|
|
|
28
28
|
/**
|
|
@@ -125,7 +125,7 @@ async function data(_izContext, objectSchemas, srcPath) {
|
|
|
125
125
|
resourceLocation: SOURCE_PATH.resourceLocationProcessLogical,
|
|
126
126
|
handlerType: HANDLER.hdrSqs,
|
|
127
127
|
additionalResourcePermission,
|
|
128
|
-
functionNameConfig: upperCase(
|
|
128
|
+
functionNameConfig: upperCase(SHORT_FUNCTION_NAME.paginateProcessLogical) + upperCase(shortNameHandler(HANDLER.hdrSqs))
|
|
129
129
|
},
|
|
130
130
|
setting: {
|
|
131
131
|
savePath: path.join(srcPath, SOURCE_PATH.appYaml),
|
|
@@ -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, shortNameHandler } = require("../../../../../libs/Consts");
|
|
25
|
+
const { createIamRole, resourceNames, RESOURCE_CLASSES, SOURCE_PATH, SAVE_FILE_NAME, FUNCTION_NAME, SNS_RESOURCE, defaultIamRolePerAction, awaitingMultipleStepsRole, shortNameHandler, SHORT_FUNCTION_NAME } = require("../../../../../libs/Consts");
|
|
26
26
|
|
|
27
27
|
const templatePath = path.join(__dirname, "./template.ejs")
|
|
28
28
|
|
|
@@ -70,7 +70,7 @@ function createParamForCreateSource(srcPath) {
|
|
|
70
70
|
handlerType,
|
|
71
71
|
additionalResourcePermission,
|
|
72
72
|
resourceLocation: SOURCE_PATH.resourceLocationRelationshipPerAction,
|
|
73
|
-
functionNameConfig: upperCase(
|
|
73
|
+
functionNameConfig: upperCase(SHORT_FUNCTION_NAME.createRel) + upperCase(shortNameHandler(handlerType))
|
|
74
74
|
},
|
|
75
75
|
setting: {
|
|
76
76
|
savePath: path.join(srcPath, SOURCE_PATH.appYaml),
|
|
@@ -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, SQS_RESOURCE, SOURCE_PATH, SAVE_FILE_NAME, FUNCTION_NAME, SNS_RESOURCE, defaultIamRolePerAction, awaitingMultipleStepsRole, shortNameHandler } = require("../../../../../libs/Consts");
|
|
25
|
+
const { createIamRole, resourceNames, RESOURCE_CLASSES, SQS_RESOURCE, SOURCE_PATH, SAVE_FILE_NAME, FUNCTION_NAME, SNS_RESOURCE, defaultIamRolePerAction, awaitingMultipleStepsRole, shortNameHandler, SHORT_FUNCTION_NAME } = require("../../../../../libs/Consts");
|
|
26
26
|
|
|
27
27
|
const templatePath = path.join(__dirname, './template.ejs')
|
|
28
28
|
|
|
@@ -83,7 +83,7 @@ function createParamForCreateSource(srcPath) {
|
|
|
83
83
|
handlerType,
|
|
84
84
|
additionalResourcePermission,
|
|
85
85
|
resourceLocation: SOURCE_PATH.resourceLocationRelationshipPerAction,
|
|
86
|
-
functionNameConfig: upperCase(
|
|
86
|
+
functionNameConfig: upperCase(SHORT_FUNCTION_NAME.createRel) + upperCase(shortNameHandler(handlerType))
|
|
87
87
|
},
|
|
88
88
|
setting: {
|
|
89
89
|
savePath: path.join(srcPath, SOURCE_PATH.appYaml),
|
|
@@ -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, shortNameHandler } = require("../../../../../libs/Consts");
|
|
25
|
+
const { createIamRole, resourceNames, RESOURCE_CLASSES, SOURCE_PATH, SAVE_FILE_NAME, FUNCTION_NAME, SNS_RESOURCE, defaultIamRolePerAction, awaitingMultipleStepsRole, shortNameHandler, SHORT_FUNCTION_NAME } = 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(
|
|
71
|
+
functionNameConfig: upperCase(SHORT_FUNCTION_NAME.createRel) + upperCase(shortNameHandler(handlerType))
|
|
72
72
|
},
|
|
73
73
|
setting: {
|
|
74
74
|
savePath: path.join(srcPath, SOURCE_PATH.appYaml),
|
|
@@ -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, SQS_RESOURCE, SOURCE_PATH, SAVE_FILE_NAME, FUNCTION_NAME, SNS_RESOURCE, defaultIamRolePerAction, awaitingMultipleStepsRole, shortNameHandler } = require("../../../../../libs/Consts");
|
|
25
|
+
const { createIamRole, resourceNames, RESOURCE_CLASSES, SQS_RESOURCE, SOURCE_PATH, SAVE_FILE_NAME, FUNCTION_NAME, SNS_RESOURCE, defaultIamRolePerAction, awaitingMultipleStepsRole, shortNameHandler, SHORT_FUNCTION_NAME } = require("../../../../../libs/Consts");
|
|
26
26
|
|
|
27
27
|
const templatePath = path.join(__dirname, './template.ejs')
|
|
28
28
|
|
|
@@ -82,7 +82,7 @@ function createParamForCreateSource(srcPath) {
|
|
|
82
82
|
handlerType,
|
|
83
83
|
additionalResourcePermission,
|
|
84
84
|
resourceLocation: SOURCE_PATH.resourceLocationRelationshipPerAction,
|
|
85
|
-
functionNameConfig: upperCase(
|
|
85
|
+
functionNameConfig: upperCase(SHORT_FUNCTION_NAME.createRel) + upperCase(shortNameHandler(handlerType))
|
|
86
86
|
},
|
|
87
87
|
setting: {
|
|
88
88
|
savePath: path.join(srcPath, SOURCE_PATH.appYaml),
|
|
@@ -90,7 +90,6 @@ function createParamForCreateSource(srcPath) {
|
|
|
90
90
|
fileExtension: '.yml',
|
|
91
91
|
isAppend: true
|
|
92
92
|
}
|
|
93
|
-
|
|
94
93
|
}
|
|
95
94
|
}
|
|
96
95
|
|
|
@@ -41,9 +41,11 @@ function data(_izContext, srcPath) {
|
|
|
41
41
|
|
|
42
42
|
|
|
43
43
|
function createParamForCreateSource(srcPath) {
|
|
44
|
+
let functionName = FUNCTION_NAME.createRel
|
|
44
45
|
return {
|
|
45
46
|
templatePath: templatePath,
|
|
46
47
|
templateData: {
|
|
48
|
+
functionName
|
|
47
49
|
},
|
|
48
50
|
setting: {
|
|
49
51
|
savePath: path.join(srcPath, SOURCE_PATH.relationshipPerAction),
|
|
@@ -29,6 +29,7 @@ const asyncFlowSharedLib = require('@izara_project/izara-shared/src/AsyncFlowSha
|
|
|
29
29
|
|
|
30
30
|
// const NoRetryError = require('@izara_project/izara-core-library-core/src/NoRetryError');
|
|
31
31
|
|
|
32
|
+
const { findLinksByObjTypes } = require("@izara_project/izara-core-library-service-schemas/src/libs/RelSchemaLib");
|
|
32
33
|
|
|
33
34
|
|
|
34
35
|
|
|
@@ -63,7 +64,7 @@ const {
|
|
|
63
64
|
*
|
|
64
65
|
* @returns {object} description of return value
|
|
65
66
|
*/
|
|
66
|
-
module.exports
|
|
67
|
+
module.exports.<%- functionName %> = async (
|
|
67
68
|
_izContext,
|
|
68
69
|
requestParams,
|
|
69
70
|
callingFlowConfig = {},
|
|
@@ -79,8 +80,10 @@ module.exports.createRelationship = async (
|
|
|
79
80
|
|
|
80
81
|
|
|
81
82
|
const {
|
|
82
|
-
|
|
83
|
+
firstObject,
|
|
84
|
+
secondObject,
|
|
83
85
|
relType,
|
|
86
|
+
relationshipDirection,
|
|
84
87
|
relationshipProperties
|
|
85
88
|
//(<requestparamCreateRel>)
|
|
86
89
|
//(</requestparamCreateRel>)
|
|
@@ -117,8 +120,8 @@ module.exports.createRelationship = async (
|
|
|
117
120
|
}
|
|
118
121
|
}
|
|
119
122
|
|
|
120
|
-
await validateIdentifiersExists(_izContext,
|
|
121
|
-
await validateIdentifiersExists(_izContext,
|
|
123
|
+
await validateIdentifiersExists(_izContext, firstObject.objType, firstObject.identifiers);
|
|
124
|
+
await validateIdentifiersExists(_izContext, secondObject.objType, secondObject.identifiers);
|
|
122
125
|
// finished validate object and identifiers
|
|
123
126
|
|
|
124
127
|
//(<afterValidateCreateRel>)
|
|
@@ -130,6 +133,37 @@ module.exports.createRelationship = async (
|
|
|
130
133
|
const relationshipSchema = await getRelationshipSchemaWithCache(_izContext, relType);
|
|
131
134
|
_izContext.logger.debug("relationshipSchema: ", relationshipSchema);
|
|
132
135
|
|
|
136
|
+
const links = await findLinksByObjTypes(_izContext, [firstObject.objType, secondObject.objType], relationshipSchema.links)
|
|
137
|
+
_izContext.logger.debug("links", links)
|
|
138
|
+
if (!links.length) {
|
|
139
|
+
errorsFound.push(`not found link between ${JSON.stringify({ firstObject: firstObject.objType })} ${JSON.stringify({ secondObject: secondObject.objType })}`)
|
|
140
|
+
};
|
|
141
|
+
|
|
142
|
+
let checkCorrectLink = false;
|
|
143
|
+
for (let link of links) {
|
|
144
|
+
const { serviceTag: fromServiceTag, objectType: fromObjectType } = link.from.objType;
|
|
145
|
+
const { serviceTag: toServiceTag, objectType: toObjType } = link.to.objType;
|
|
146
|
+
|
|
147
|
+
const { serviceTag: firstServiceTag, objectType: firstObjectType } = firstObject.objType
|
|
148
|
+
const { serviceTag: secondServiceTag, objectType: secondObjectType } = secondObject.objType
|
|
149
|
+
|
|
150
|
+
const matchFromTo = fromServiceTag === firstServiceTag && fromObjectType === firstObjectType &&
|
|
151
|
+
toServiceTag === secondServiceTag && toObjType === secondObjectType;
|
|
152
|
+
|
|
153
|
+
const matchToFrom = fromServiceTag === secondServiceTag && fromObjectType === secondObjectType &&
|
|
154
|
+
toServiceTag === firstServiceTag && toObjType === firstObjectType;
|
|
155
|
+
|
|
156
|
+
if ((relationshipDirection === "from" && matchFromTo)
|
|
157
|
+
|| (relationshipDirection === "to" && matchToFrom)) {
|
|
158
|
+
checkCorrectLink = true
|
|
159
|
+
break;
|
|
160
|
+
}
|
|
161
|
+
};
|
|
162
|
+
|
|
163
|
+
if (checkCorrectLink == false) {
|
|
164
|
+
errorsFound.push(`Wrong Relationship Direction`)
|
|
165
|
+
};
|
|
166
|
+
|
|
133
167
|
let targetStorageResources = [];
|
|
134
168
|
|
|
135
169
|
if (relationshipSchema) {
|
|
@@ -139,8 +173,8 @@ module.exports.createRelationship = async (
|
|
|
139
173
|
const { serviceTag: fromServiceTag, objectType: fromObjectType } = from.objType
|
|
140
174
|
const { serviceTag: toServiceTag, objectType: toObjectType } = to.objType
|
|
141
175
|
|
|
142
|
-
const { serviceTag: firstServiceTag, objectType: firstObjectType } =
|
|
143
|
-
const { serviceTag: secondServiceTag, objectType: secondObjectType } =
|
|
176
|
+
const { serviceTag: firstServiceTag, objectType: firstObjectType } = firstObject.objType;
|
|
177
|
+
const { serviceTag: secondServiceTag, objectType: secondObjectType } = secondObject.objType;
|
|
144
178
|
|
|
145
179
|
// find exists link
|
|
146
180
|
if (
|
|
@@ -161,7 +195,7 @@ module.exports.createRelationship = async (
|
|
|
161
195
|
if (usedStorageResource.storageType === consts.STORAGE_TYPES.graph) {
|
|
162
196
|
const graphServiceTag = await getGraphServiceTagWithCache(_izContext, usedStorageResource.graphServerTag);
|
|
163
197
|
if (!graphServiceTag) {
|
|
164
|
-
errorsFound.push(`storageResourceTag
|
|
198
|
+
errorsFound.push(`storageResourceTag: ${storageResourceTag} invalid, not found graph serviceTag from graphServerTag: ${usedStorageResource.graphServerTag}`)
|
|
165
199
|
}
|
|
166
200
|
|
|
167
201
|
targetStorageResources.push({
|
|
@@ -187,7 +221,7 @@ module.exports.createRelationship = async (
|
|
|
187
221
|
// validate properties exists with schema
|
|
188
222
|
for (const propKey in relationshipProperties) {
|
|
189
223
|
if (!relationshipSchema.fieldNames.hasOwnProperty(propKey)) {
|
|
190
|
-
errorsFound.push(`property
|
|
224
|
+
errorsFound.push(`property: ${propKey} not exists in relationshipSchema`);
|
|
191
225
|
}
|
|
192
226
|
}
|
|
193
227
|
|
|
@@ -195,12 +229,12 @@ module.exports.createRelationship = async (
|
|
|
195
229
|
for (const [propName, propSetting] of Object.entries(relationshipSchema.fieldNames)) {
|
|
196
230
|
if (propSetting.requiredOnCreate === true) {
|
|
197
231
|
if (!relationshipProperties.hasOwnProperty(propName)) {
|
|
198
|
-
errorsFound.push(`Missing requiredOnCreate property
|
|
232
|
+
errorsFound.push(`Missing requiredOnCreate property: ${propKey}`);
|
|
199
233
|
}
|
|
200
234
|
}
|
|
201
235
|
|
|
202
236
|
if (!propSetting.optionalOnCreate && !propSetting.requiredOnCreate && relationshipProperties.hasOwnProperty(propName)) {
|
|
203
|
-
errorsFound.push(`property
|
|
237
|
+
errorsFound.push(`property: ${propName} cannot create`);
|
|
204
238
|
}
|
|
205
239
|
}
|
|
206
240
|
|
|
@@ -213,9 +247,11 @@ module.exports.createRelationship = async (
|
|
|
213
247
|
if (errorsFound.length) {
|
|
214
248
|
|
|
215
249
|
let createRelCompleteMsg = {
|
|
216
|
-
|
|
250
|
+
firstObject: firstObject,
|
|
251
|
+
secondObject: secondObject,
|
|
217
252
|
relType: relType,
|
|
218
|
-
|
|
253
|
+
relationshipDirection,
|
|
254
|
+
relationshipProperties,
|
|
219
255
|
//(<inCreateRelCompleteMsgCrateRel>)
|
|
220
256
|
//(</inCreateRelCompleteMsgCrateRel>)
|
|
221
257
|
status: 'error',
|
|
@@ -244,7 +280,7 @@ module.exports.createRelationship = async (
|
|
|
244
280
|
|
|
245
281
|
|
|
246
282
|
// before create awaitingStepId per graph storageResource
|
|
247
|
-
const linkTypeId = createLinkTypeId(_izContext,
|
|
283
|
+
const linkTypeId = createLinkTypeId(_izContext, firstObject.objType, secondObject.objType, relType);
|
|
248
284
|
|
|
249
285
|
let usedGraphServiceTag = []; // collect used graph serviceTag, use to check duplicate graph serviceTag across graph serverTag
|
|
250
286
|
let targetGraphStorageResources = []; // collect used graph storageResources, filtered duplicate graphServiceTag from graphServerTag out
|
|
@@ -284,21 +320,23 @@ module.exports.createRelationship = async (
|
|
|
284
320
|
);
|
|
285
321
|
|
|
286
322
|
// prepare message body
|
|
287
|
-
let
|
|
288
|
-
|
|
323
|
+
let createRelMessageBody = {
|
|
324
|
+
firstObject: firstObject,
|
|
325
|
+
secondObject: secondObject,
|
|
289
326
|
relType: relType,
|
|
327
|
+
relationshipDirection,
|
|
290
328
|
relationshipProperties
|
|
291
329
|
//(<inUpdateRelMessageBodyCreateRel>)
|
|
292
330
|
//(</inUpdateRelMessageBodyCreateRel>)
|
|
293
331
|
}
|
|
294
|
-
_izContext.logger.debug('createRelMessageBody: ',
|
|
332
|
+
_izContext.logger.debug('createRelMessageBody: ', createRelMessageBody);
|
|
295
333
|
|
|
296
334
|
await Promise.all(
|
|
297
335
|
targetGraphStorageResources.map(async (storageResource) => {
|
|
298
336
|
if (storageResource.storageType === consts.STORAGE_TYPES.graph) {
|
|
299
337
|
|
|
300
|
-
|
|
301
|
-
|
|
338
|
+
createRelMessageBody = callingFlowSharedLib.addCallingFlowToSnsRequestMessageObject(
|
|
339
|
+
createRelMessageBody,
|
|
302
340
|
callingFlowSharedLib.addParentCallingFlowConfig(
|
|
303
341
|
callingFlowConfig, // receive parent callingFlowConfig.
|
|
304
342
|
callingFlowSharedLib.createCallingFlowConfig( // callinfflow own service
|
|
@@ -309,10 +347,10 @@ module.exports.createRelationship = async (
|
|
|
309
347
|
)
|
|
310
348
|
)
|
|
311
349
|
);
|
|
312
|
-
_izContext.logger.debug("messageObject before send message:",
|
|
350
|
+
_izContext.logger.debug("messageObject before send message:", createRelMessageBody)
|
|
313
351
|
|
|
314
352
|
let messageToInUpdateRelationship = {
|
|
315
|
-
Message: JSON.stringify(
|
|
353
|
+
Message: JSON.stringify(createRelMessageBody),
|
|
316
354
|
TopicArn: await snsSharedLib.snsTopicArn(_izContext, TOPIC_NAME_GRAPH_HANDLER.inCreateRel, storageResource.graphServiceTag),
|
|
317
355
|
};
|
|
318
356
|
_izContext.logger.debug("RequestParams before send to sqs messageToInUpdateRelationship ::::::: ", messageToInUpdateRelationship);
|
|
@@ -326,10 +364,12 @@ module.exports.createRelationship = async (
|
|
|
326
364
|
}
|
|
327
365
|
|
|
328
366
|
return {
|
|
329
|
-
|
|
330
|
-
|
|
367
|
+
firstObject: firstObject,
|
|
368
|
+
secondObject: secondObject,
|
|
369
|
+
relType: relType,
|
|
370
|
+
relationshipDirection,
|
|
331
371
|
relationshipProperties,
|
|
332
|
-
|
|
372
|
+
status: "complete"
|
|
333
373
|
};
|
|
334
374
|
|
|
335
375
|
|
|
@@ -27,28 +27,41 @@ const <%- functionName %> = require('./<%- firstLetterUpperCase(functionName) %>
|
|
|
27
27
|
// validate event params in middleware before into function
|
|
28
28
|
let validatorSchema = {
|
|
29
29
|
type: "object",
|
|
30
|
-
required: ["
|
|
30
|
+
required: ["firstObject", "secondObject", "relType", "relationshipDirection"],
|
|
31
31
|
properties: {
|
|
32
|
-
|
|
33
|
-
type: "
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
required: ["serviceTag", "objectType"],
|
|
43
|
-
properties: {
|
|
44
|
-
serviceTag: izara.validatorSchema.stringNotEmpty(),
|
|
45
|
-
objectType: izara.validatorSchema.stringNotEmpty()
|
|
46
|
-
}
|
|
47
|
-
},
|
|
48
|
-
identifiers: {
|
|
49
|
-
type: "object",
|
|
50
|
-
minproperties: 1
|
|
32
|
+
firstObject: {
|
|
33
|
+
type: "object",
|
|
34
|
+
required: ["objType", "identifiers"],
|
|
35
|
+
properties: {
|
|
36
|
+
objType: {
|
|
37
|
+
type: "object",
|
|
38
|
+
required: ["serviceTag", "objectType"],
|
|
39
|
+
properties: {
|
|
40
|
+
serviceTag: izara.validatorSchema.stringNotEmpty(),
|
|
41
|
+
objectType: izara.validatorSchema.stringNotEmpty()
|
|
51
42
|
}
|
|
43
|
+
},
|
|
44
|
+
identifiers: {
|
|
45
|
+
type: "object",
|
|
46
|
+
minProperties: 1
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
secondObject: {
|
|
51
|
+
type: "object",
|
|
52
|
+
required: ["objType", "identifiers"],
|
|
53
|
+
properties: {
|
|
54
|
+
objType: {
|
|
55
|
+
type: "object",
|
|
56
|
+
required: ["serviceTag", "objectType"],
|
|
57
|
+
properties: {
|
|
58
|
+
serviceTag: izara.validatorSchema.stringNotEmpty(),
|
|
59
|
+
objectType: izara.validatorSchema.stringNotEmpty()
|
|
60
|
+
}
|
|
61
|
+
},
|
|
62
|
+
identifiers: {
|
|
63
|
+
type: "object",
|
|
64
|
+
minProperties: 1
|
|
52
65
|
}
|
|
53
66
|
}
|
|
54
67
|
},
|
|
@@ -61,14 +74,17 @@ let validatorSchema = {
|
|
|
61
74
|
type: 'string',
|
|
62
75
|
pattern: "^[a-zA-Z0-9_-]+$",
|
|
63
76
|
enum: [process.env.iz_serviceTag]
|
|
64
|
-
}
|
|
77
|
+
},
|
|
65
78
|
}
|
|
66
79
|
},
|
|
67
|
-
|
|
80
|
+
relationshipDirection: {
|
|
81
|
+
type: "string",
|
|
82
|
+
enum: ['from', "to"]
|
|
83
|
+
},
|
|
68
84
|
relationshipProperties: {
|
|
69
|
-
type:
|
|
70
|
-
|
|
71
|
-
}
|
|
85
|
+
type: 'object',
|
|
86
|
+
default: {}
|
|
87
|
+
},
|
|
72
88
|
}
|
|
73
89
|
};
|
|
74
90
|
|
|
@@ -92,10 +108,11 @@ module.exports.main = middleware.wrap(async (event, context, callback) => {
|
|
|
92
108
|
let lambdaFunctionResponse = await <%- functionName %>.<%- functionName %>(
|
|
93
109
|
event._izContext, // correlationId/logger/integrationTestDetail/uniqueRequestId/userId
|
|
94
110
|
{
|
|
95
|
-
|
|
111
|
+
firstObject: event.firstObject,
|
|
112
|
+
secondObject: event.secondObject,
|
|
96
113
|
relType: event.relType,
|
|
97
|
-
|
|
98
|
-
relationshipProperties: event.relationshipProperties
|
|
114
|
+
relationshipDirection: event.relationshipDirection,
|
|
115
|
+
relationshipProperties: event.relationshipProperties,
|
|
99
116
|
}
|
|
100
117
|
);
|
|
101
118
|
|
|
@@ -48,28 +48,41 @@ middleware.setValidatorSchema(recordHandlerSharedLib.baseValidatorSchema(
|
|
|
48
48
|
// validate event params in middlewware before into function.
|
|
49
49
|
let validatorSchema = {
|
|
50
50
|
type: "object",
|
|
51
|
-
required: ["
|
|
51
|
+
required: ["firstObject", "secondObject", "relType", "relationshipDirection"],
|
|
52
52
|
properties: {
|
|
53
|
-
|
|
54
|
-
type: "
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
53
|
+
firstObject: {
|
|
54
|
+
type: "object",
|
|
55
|
+
required: ["objType", "identifiers"],
|
|
56
|
+
properties: {
|
|
57
|
+
objType: {
|
|
58
|
+
type: "object",
|
|
59
|
+
required: ["serviceTag", "objectType"],
|
|
60
|
+
properties: {
|
|
61
|
+
serviceTag: izara.validatorSchema.stringNotEmpty(),
|
|
62
|
+
objectType: izara.validatorSchema.stringNotEmpty()
|
|
63
|
+
}
|
|
64
|
+
},
|
|
65
|
+
identifiers: {
|
|
66
|
+
type: "object",
|
|
67
|
+
minProperties: 1
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
},
|
|
71
|
+
secondObject: {
|
|
72
|
+
type: "object",
|
|
73
|
+
required: ["objType", "identifiers"],
|
|
74
|
+
properties: {
|
|
75
|
+
objType: {
|
|
76
|
+
type: "object",
|
|
77
|
+
required: ["serviceTag", "objectType"],
|
|
78
|
+
properties: {
|
|
79
|
+
serviceTag: izara.validatorSchema.stringNotEmpty(),
|
|
80
|
+
objectType: izara.validatorSchema.stringNotEmpty()
|
|
72
81
|
}
|
|
82
|
+
},
|
|
83
|
+
identifiers: {
|
|
84
|
+
type: "object",
|
|
85
|
+
minProperties: 1
|
|
73
86
|
}
|
|
74
87
|
}
|
|
75
88
|
},
|
|
@@ -85,6 +98,10 @@ let validatorSchema = {
|
|
|
85
98
|
},
|
|
86
99
|
}
|
|
87
100
|
},
|
|
101
|
+
relationshipDirection: {
|
|
102
|
+
type: "string",
|
|
103
|
+
enum: ['from', "to"]
|
|
104
|
+
},
|
|
88
105
|
relationshipProperties: {
|
|
89
106
|
type: 'object',
|
|
90
107
|
default: {}
|
|
@@ -129,7 +146,11 @@ let validatorSchema = {
|
|
|
129
146
|
);
|
|
130
147
|
|
|
131
148
|
// add argument (to invoke lambda) to passOnProperties[]
|
|
132
|
-
passOnProperties.push(record.body.Message)
|
|
149
|
+
passOnProperties.push(record.body.Message.firstObject)
|
|
150
|
+
passOnProperties.push(record.body.Message.secondObject)
|
|
151
|
+
passOnProperties.push(record.body.Message.relType)
|
|
152
|
+
passOnProperties.push(record.body.Message.relationshipDirection)
|
|
153
|
+
passOnProperties.push(record.body.Message.relationshipProperties)
|
|
133
154
|
passOnProperties.push(callingFlowSharedLib.addCallingFlowToPassOnProperties(record.body.Message));
|
|
134
155
|
//(<afterPutParamIntoMainFunction>)
|
|
135
156
|
//(</afterPutParamIntoMainFunction>)
|
|
@@ -31,28 +31,41 @@ const <%- functionName %> = require('./<%- firstLetterUpperCase(functionName) %>
|
|
|
31
31
|
// validate event params in middlewware before into function.
|
|
32
32
|
let validatorSchema = {
|
|
33
33
|
type: "object",
|
|
34
|
-
required: ["
|
|
34
|
+
required: ["firstObject", "secondObject", "relType", "relationshipDirection"],
|
|
35
35
|
properties: {
|
|
36
|
-
|
|
37
|
-
type: "
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
required: ["serviceTag", "objectType"],
|
|
47
|
-
properties: {
|
|
48
|
-
serviceTag: izara.validatorSchema.stringNotEmpty(),
|
|
49
|
-
objectType: izara.validatorSchema.stringNotEmpty()
|
|
50
|
-
}
|
|
51
|
-
},
|
|
52
|
-
identifiers: {
|
|
53
|
-
type: "object",
|
|
54
|
-
minProperties: 1
|
|
36
|
+
firstObject: {
|
|
37
|
+
type: "object",
|
|
38
|
+
required: ["objType", "identifiers"],
|
|
39
|
+
properties: {
|
|
40
|
+
objType: {
|
|
41
|
+
type: "object",
|
|
42
|
+
required: ["serviceTag", "objectType"],
|
|
43
|
+
properties: {
|
|
44
|
+
serviceTag: izara.validatorSchema.stringNotEmpty(),
|
|
45
|
+
objectType: izara.validatorSchema.stringNotEmpty()
|
|
55
46
|
}
|
|
47
|
+
},
|
|
48
|
+
identifiers: {
|
|
49
|
+
type: "object",
|
|
50
|
+
minProperties: 1
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
secondObject: {
|
|
55
|
+
type: "object",
|
|
56
|
+
required: ["objType", "identifiers"],
|
|
57
|
+
properties: {
|
|
58
|
+
objType: {
|
|
59
|
+
type: "object",
|
|
60
|
+
required: ["serviceTag", "objectType"],
|
|
61
|
+
properties: {
|
|
62
|
+
serviceTag: izara.validatorSchema.stringNotEmpty(),
|
|
63
|
+
objectType: izara.validatorSchema.stringNotEmpty()
|
|
64
|
+
}
|
|
65
|
+
},
|
|
66
|
+
identifiers: {
|
|
67
|
+
type: "object",
|
|
68
|
+
minProperties: 1
|
|
56
69
|
}
|
|
57
70
|
}
|
|
58
71
|
},
|
|
@@ -68,6 +81,10 @@ let validatorSchema = {
|
|
|
68
81
|
},
|
|
69
82
|
}
|
|
70
83
|
},
|
|
84
|
+
relationshipDirection: {
|
|
85
|
+
type: "string",
|
|
86
|
+
enum: ['from', "to"]
|
|
87
|
+
},
|
|
71
88
|
relationshipProperties: {
|
|
72
89
|
type: 'object',
|
|
73
90
|
default: {}
|
|
@@ -84,11 +101,13 @@ module.exports.main = middleware.wrap(async (event, context, callback) => {
|
|
|
84
101
|
|
|
85
102
|
try {
|
|
86
103
|
// invoke LambdaFunction
|
|
87
|
-
return await
|
|
104
|
+
return await <%- functionName %>.<%- functionName %>(
|
|
88
105
|
event._izContext, // correlationId/logger/integrationTestDetail/uniqueRequestId
|
|
89
106
|
{
|
|
90
|
-
|
|
107
|
+
firstObject: event.firstObject,
|
|
108
|
+
secondObject: event.secondObject,
|
|
91
109
|
relType: event.relType,
|
|
110
|
+
relationshipDirection: event.relationshipDirection,
|
|
92
111
|
relationshipProperties: event.relationshipProperties,
|
|
93
112
|
},
|
|
94
113
|
callingFlowSharedLib.addCallingFlowToPassOnProperties(event)
|