@izara_project/izara-market-library-service-schemas 1.0.12 → 1.0.14
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/GenerateCodeLibs.js +4 -4
- package/src/TemplateManager/src/GenerateCode.js +24 -47
- package/src/TemplateManager/src/PerActionEndpoint/Handler/HdrDsq/template.ejs +2 -2
- package/src/TemplateManager/src/PerActionEndpoint/MainFunction/Update/data.js +1 -1
- package/src/TemplateManager/src/PerActionEndpoint/MainFunction/Update/template.ejs +3 -2
- package/src/TemplateManager/src/RelationshipPerAction/DeleteRelationship/DeleteRelationship/functionYaml/HdrInv/data.js +2 -2
- package/src/TemplateManager/src/RelationshipPerAction/DeleteRelationship/DeleteRelationship/mainFunction/template.ejs +25 -17
- package/src/TemplateManager/src/RelationshipPerAction/DeleteRelationship/DeleteRelationship/perAction/HdrApi/template.ejs +39 -21
- package/src/TemplateManager/src/RelationshipPerAction/DeleteRelationship/DeleteRelationship/perAction/HdrDsq/template.ejs +38 -21
- package/src/TemplateManager/src/RelationshipPerAction/DeleteRelationship/DeleteRelationship/perAction/HdrInv/template.ejs +40 -22
- package/src/TemplateManager/src/RelationshipPerAction/DeleteRelationship/DeleteRelationship/perAction/HdrSqs/template.ejs +38 -22
- package/src/TemplateManager/src/RelationshipPerAction/UpdateRelationshipSchema/updateRelationship/functionYaml/HdrApi/data.js +1 -1
- package/src/TemplateManager/src/RelationshipPerAction/UpdateRelationshipSchema/updateRelationship/mainFunction/template.ejs +21 -11
- package/src/TemplateManager/src/RelationshipPerAction/UpdateRelationshipSchema/updateRelationship/perAction/HdrApi/template.ejs +37 -20
- package/src/TemplateManager/src/RelationshipPerAction/UpdateRelationshipSchema/updateRelationship/perAction/HdrDsq/template.ejs +40 -23
- package/src/TemplateManager/src/RelationshipPerAction/UpdateRelationshipSchema/updateRelationship/perAction/HdrInv/template.ejs +40 -23
- package/src/TemplateManager/src/RelationshipPerAction/UpdateRelationshipSchema/updateRelationship/perAction/HdrSqs/template.ejs +40 -23
- package/src/TemplateManager/src/externalService/FunctionNameConfig/data.js +45 -12
- package/src/TemplateManager/src/externalService/FunctionNameConfig/templateIntTesting.ejs +31 -0
- package/src/TemplateManager/src/externalService/FunctionNameConfig/templateYaml.ejs +10 -0
- package/src/TemplateManager/src/externalService/LambdaRole/data.js +10 -46
- package/src/TemplateManager/src/libs/Consts.js +3 -3
- package/src/TemplateManager/src/libs/GenerateCodeUtils.js +57 -0
package/package.json
CHANGED
|
@@ -154,11 +154,11 @@ async function validateSchemaPerRecord(
|
|
|
154
154
|
|
|
155
155
|
// if not pass validate will sent messsage to dlq and throw NoRetryError
|
|
156
156
|
if (!validateStatus.pass) {
|
|
157
|
-
await messageToDlq(record, `Invalid: ${validateStatus.error}`, sqsSharedLib.sqsQueueUrlDLQ(lambdaFunctionName));
|
|
157
|
+
await messageToDlq(record, `Invalid: ${validateStatus.error}`, await sqsSharedLib.sqsQueueUrlDLQ(record._izContext, lambdaFunctionName));
|
|
158
158
|
record._izError = new Error(validateStatus.error)
|
|
159
159
|
}
|
|
160
160
|
} catch (error) {
|
|
161
|
-
await messageToDlq(record, error.message, sqsSharedLib.sqsQueueUrlDLQ(lambdaFunctionName));
|
|
161
|
+
await messageToDlq(record, error.message, await sqsSharedLib.sqsQueueUrlDLQ(record._izContext, lambdaFunctionName));
|
|
162
162
|
record._izError = new Error(error)
|
|
163
163
|
}
|
|
164
164
|
|
|
@@ -176,7 +176,7 @@ async function sendMsgOutComplete(_izContext, topicName, messageObj, callingFlow
|
|
|
176
176
|
let sendMessageOutComplete = {
|
|
177
177
|
Message: JSON.stringify(messageObj),
|
|
178
178
|
MessageAttributes: sns.createStringMessageAttributes(_izContext, messageAttributes),
|
|
179
|
-
TopicArn: snsSharedLib.snsTopicArn(topicName),
|
|
179
|
+
TopicArn: await snsSharedLib.snsTopicArn(_izContext, topicName),
|
|
180
180
|
};
|
|
181
181
|
|
|
182
182
|
_izContext.logger.debug(`Send message to ${topicName} :`, sendMessageOutComplete);
|
|
@@ -214,7 +214,7 @@ async function messageToDlq(record, messageFailError, queueUrl) {
|
|
|
214
214
|
|
|
215
215
|
record._izContext.logger.debug('messageToDlq, params before sending DLQ', params);
|
|
216
216
|
|
|
217
|
-
|
|
217
|
+
sqs.sendMessage(record._izContext, params);
|
|
218
218
|
record._izContext.logger.debug("----- messageToDlq sendMessage success -----");
|
|
219
219
|
};
|
|
220
220
|
|
|
@@ -160,22 +160,6 @@ const createDeleteRelationshipCompleteHandler = require('./RelationshipPerAction
|
|
|
160
160
|
const createDeleteRelationshipCompleteSnsAndSqs = require('./RelationshipPerAction/DeleteRelationship/DeleteRelationshipComplete/sns-in-sqs/data');
|
|
161
161
|
const createDeleteRelationshipCompleteSnsOut = require('./RelationshipPerAction/DeleteRelationship/DeleteRelationshipComplete/sns-out/data');
|
|
162
162
|
|
|
163
|
-
// TranslateIdRequest
|
|
164
|
-
const createTranslateIdsCacheMainTable = require('./TranslateIdReq/TranslateIds/resourceYaml/dynamoDb/data');
|
|
165
|
-
const createTranslateIdsRequestMainFunction = require('./TranslateIdReq/TranslateIds/mainFunction/data');
|
|
166
|
-
const createTranslateIdsHandlerDsq = require('./TranslateIdReq/TranslateIds/handler/HdrDsq/data');
|
|
167
|
-
const createTranslateIdsHandlerSqs = require('./TranslateIdReq/TranslateIds/handler/HdrSqs/data');
|
|
168
|
-
const createTranslateIdFunctionYamlHdrDsq = require('./TranslateIdReq/TranslateIds/functionYaml/HdrDsq/data');
|
|
169
|
-
const createTranslateIdFunctionYamlHdrSqs = require('./TranslateIdReq/TranslateIds/functionYaml/HdrSqs/data');
|
|
170
|
-
const createSnsAndSqsTranslateId = require('./TranslateIdReq/TranslateIds/resourceYaml/sns-sqs/data');
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
// processTranslateIds
|
|
174
|
-
const createProcessTranslateIdsCompleteSnsOut = require('./TranslateIdReq/ProcessingTranslateIds/sns-out/data');
|
|
175
|
-
const createTranslateIdsProcessSnsQueue = require('./TranslateIdReq/ProcessingTranslateIds/sqs-sns/data');
|
|
176
|
-
const createTranslateIdsProcessFunctionYaml = require('./TranslateIdReq/ProcessingTranslateIds/functionYaml/data');
|
|
177
|
-
const createTranslateIdsProcessHandler = require('./TranslateIdReq/ProcessingTranslateIds/handler/dataHdrDsq');
|
|
178
|
-
const createTranslateIdsProcessMainFunction = require('./TranslateIdReq/ProcessingTranslateIds/mainFunction/data')
|
|
179
163
|
// findData
|
|
180
164
|
const createFindDataFunctionYaml = require('./FindData/FindDataYaml/data');
|
|
181
165
|
const createFindDataHandler = require('./FindData/Handler/data');
|
|
@@ -194,7 +178,12 @@ const createProcessLogicalPaginateFunctionYamlHdrDsq = require('./ProcessLogical
|
|
|
194
178
|
const createProcessLogicalPaginateFunctionYamlHdrSqs = require('./ProcessLogicalPagination/FunctionYaml/HdrSqs/data')
|
|
195
179
|
|
|
196
180
|
//get functionNameConfig
|
|
197
|
-
const
|
|
181
|
+
const functionNameConfigYamldata = require('./externalService/FunctionNameConfig/data')
|
|
182
|
+
|
|
183
|
+
//lib of generateCode
|
|
184
|
+
const { checkValidTableYaml } = require('./libs/GenerateCodeUtils');
|
|
185
|
+
|
|
186
|
+
const { NoRetryError } = require('@izara_project/izara-core-library-core');
|
|
198
187
|
|
|
199
188
|
/**
|
|
200
189
|
*
|
|
@@ -225,7 +214,6 @@ async function generateCodeWithTemplate(_izContext, objSchemaPath) {
|
|
|
225
214
|
lamdaPerCombindActionPath: join(saveFilePath, `/generatedCode/lamdaPerCombindAction/source/`), // test
|
|
226
215
|
lambdaPerObjectTypePath: join(saveFilePath, `/generatedCode/lambdaPerObjectType/source/`), // test
|
|
227
216
|
updateRelationship: join(saveFilePath, `../src/generatedCode/RelationshipPerAction/source/`),
|
|
228
|
-
translateId: join(saveFilePath, `../src/generatedCode/TranslateId/source/`)
|
|
229
217
|
};
|
|
230
218
|
|
|
231
219
|
|
|
@@ -248,6 +236,9 @@ async function generateCodeWithTemplate(_izContext, objSchemaPath) {
|
|
|
248
236
|
|
|
249
237
|
let createSourceParams = [];
|
|
250
238
|
|
|
239
|
+
// use to check dynamoDB table yaml, to prevent duplicate tableName
|
|
240
|
+
let createdTableYaml = {};
|
|
241
|
+
|
|
251
242
|
for (const relTag in allObjectRelationships) {
|
|
252
243
|
// const relTagData = allObjectRelationships[relTag];
|
|
253
244
|
|
|
@@ -288,12 +279,19 @@ async function generateCodeWithTemplate(_izContext, objSchemaPath) {
|
|
|
288
279
|
const createFunctionYaml = [...createFunctionYamlHdrApi, ...createFunctionYamlHdrDsq, ...createFunctionYamlHdrInv, ...createFunctionYamlHdrSqs];
|
|
289
280
|
|
|
290
281
|
// generate Resource ..via dynamoDb sns-in-sqs sns-put
|
|
291
|
-
|
|
282
|
+
let [createResourceDynamo, newCreatedTableYaml] = checkValidTableYaml(
|
|
283
|
+
_izContext,
|
|
284
|
+
createSourceDataDynamoDB(_izContext, objectSchema, saveFilePath),
|
|
285
|
+
createdTableYaml
|
|
286
|
+
);
|
|
287
|
+
|
|
288
|
+
createdTableYaml = newCreatedTableYaml;
|
|
289
|
+
_izContext.logger.debug("createResourceDynamo: ", createResourceDynamo);
|
|
290
|
+
|
|
292
291
|
const createResourceSnsInSqs = createSourceSnsAndSqs(_izContext, objectSchema, saveFilePath);
|
|
293
292
|
const createResourceSnsOut = createDataForCreateSourceSnsOut(_izContext, objectSchema, saveFilePath);
|
|
294
293
|
|
|
295
294
|
// translateIdsMainFunction
|
|
296
|
-
const translateIdsMainFunction = await createTranslateIdsRequestMainFunction(_izContext, objectSchema, saveFilePath);
|
|
297
295
|
|
|
298
296
|
// wrap main Resource
|
|
299
297
|
const createMainResource = [...createResourceDynamo, ...createResourceSnsInSqs, ...createResourceSnsOut];
|
|
@@ -301,11 +299,10 @@ async function generateCodeWithTemplate(_izContext, objSchemaPath) {
|
|
|
301
299
|
|
|
302
300
|
createSourceParams = createSourceParams.concat([
|
|
303
301
|
// ...createSourceMainResourcesObjectSchema,
|
|
304
|
-
...createSourceHandler,
|
|
305
|
-
...createMainFunction,
|
|
306
|
-
...createFunctionYaml,
|
|
307
|
-
...createMainResource,
|
|
308
|
-
...translateIdsMainFunction,
|
|
302
|
+
...createSourceHandler, // create handler function
|
|
303
|
+
...createMainFunction, // create main function
|
|
304
|
+
...createFunctionYaml, // create function.yaml
|
|
305
|
+
...createMainResource, // create resource yaml
|
|
309
306
|
]);
|
|
310
307
|
|
|
311
308
|
// console.log("createSourceParams after concat: ", createSourceParams);
|
|
@@ -446,24 +443,6 @@ async function generateCodeWithTemplate(_izContext, objSchemaPath) {
|
|
|
446
443
|
|
|
447
444
|
const deleteRelationshipCompleteData = [...deleteRelationshipCompleteFunctionYaml, ...deleteRelationshipCompleteMainFunction, ...deleteRelationshipCompleteHandler, ...deleteRelationshipCompleteSnsAndSqs, ...deleteRelationshipCompleteSnsOut]
|
|
448
445
|
|
|
449
|
-
const translateIdsCacheIdsMainTable = createTranslateIdsCacheMainTable(_izContext, saveFilePath);
|
|
450
|
-
const translateIdsHandlerFunctionDsq = createTranslateIdsHandlerDsq(_izContext, saveFilePath);
|
|
451
|
-
const translateIdsHandlerFunctionSqs = createTranslateIdsHandlerSqs(_izContext, saveFilePath);
|
|
452
|
-
const translateIdsFunctionYamlDsq = createTranslateIdFunctionYamlHdrDsq(_izContext, saveFilePath);
|
|
453
|
-
const translateIdsFunctionYamlSqs = createTranslateIdFunctionYamlHdrSqs(_izContext, saveFilePath);
|
|
454
|
-
const translateIdsSnsAndSqsResourceQueue = createSnsAndSqsTranslateId(_izContext, saveFilePath);
|
|
455
|
-
|
|
456
|
-
const createTranslateIdsResourece = [...translateIdsCacheIdsMainTable, ...translateIdsHandlerFunctionDsq, ...translateIdsHandlerFunctionSqs,
|
|
457
|
-
...translateIdsFunctionYamlDsq, ...translateIdsFunctionYamlSqs, ...translateIdsSnsAndSqsResourceQueue
|
|
458
|
-
]
|
|
459
|
-
|
|
460
|
-
const translateIdsProcessingSnsOut = createProcessTranslateIdsCompleteSnsOut(_izContext, saveFilePath);
|
|
461
|
-
const translateIdsProcessingQueue = createTranslateIdsProcessSnsQueue(_izContext, saveFilePath);
|
|
462
|
-
const translateIdsProcessingFunctionYaml = createTranslateIdsProcessFunctionYaml(_izContext, saveFilePath);
|
|
463
|
-
const translateIdsProcessingHandler = createTranslateIdsProcessHandler(_izContext, saveFilePath);
|
|
464
|
-
const translateIdsProcessingMainFunction = createTranslateIdsProcessMainFunction(_izContext, saveFilePath);
|
|
465
|
-
const createTranslateIdsProcessing = [...translateIdsProcessingQueue, ...translateIdsProcessingFunctionYaml, ...translateIdsProcessingHandler, ...translateIdsProcessingMainFunction, ...translateIdsProcessingSnsOut]
|
|
466
|
-
|
|
467
446
|
const findDataHandlerSqs = createFindDataHandler(_izContext, saveFilePath);
|
|
468
447
|
const findDataMainFunction = await createFindDataMainFunction(_izContext, saveFilePath);
|
|
469
448
|
|
|
@@ -494,16 +473,14 @@ async function generateCodeWithTemplate(_izContext, objSchemaPath) {
|
|
|
494
473
|
createSourceParams.push(
|
|
495
474
|
...updateRelationshipSchemaDatas,
|
|
496
475
|
...createRelationshipSchemaDatas,
|
|
497
|
-
...createTranslateIdsResourece,
|
|
498
|
-
...createTranslateIdsProcessing,
|
|
499
476
|
...deleteRelationshipData,
|
|
500
477
|
...deleteRelationshipCompleteData
|
|
501
478
|
)
|
|
502
479
|
}
|
|
503
480
|
// console.log("createSourceParams templatePath in GenerateCode", createSourceParams.templatePath)
|
|
504
481
|
|
|
505
|
-
const createFunctionNameConfig =
|
|
506
|
-
createSourceParams = createSourceParams.concat(createFunctionNameConfig);
|
|
482
|
+
const createFunctionNameConfig = functionNameConfigYamldata(_izContext, createSourceParams, saveFilePath);
|
|
483
|
+
createSourceParams = createSourceParams.concat(...createFunctionNameConfig);
|
|
507
484
|
|
|
508
485
|
// delete file .yml before start to prevent confilct of data
|
|
509
486
|
for (let folderPathToEmpty of Object.keys(GENERATECODE_SOURCE_PATH)) {
|
|
@@ -68,8 +68,8 @@ module.exports.main = middleware.wrap(async (event,context, callback) => {
|
|
|
68
68
|
await validateSchemaPerRecord(
|
|
69
69
|
record,
|
|
70
70
|
"<%- functionName %><%- firstLetterUpperCase(handler) %>",
|
|
71
|
-
|
|
72
|
-
<%- action %>"
|
|
71
|
+
OBJTYPE,
|
|
72
|
+
"<%- action %>"
|
|
73
73
|
//(<validateSchemaSetting>)
|
|
74
74
|
//(</validateSchemaSetting>)
|
|
75
75
|
)
|
|
@@ -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 =
|
|
43
|
+
let functionName = (objectType) + upperCase(actionHandler);
|
|
44
44
|
return {
|
|
45
45
|
templatePath: templatePath,
|
|
46
46
|
templateData: {
|
|
@@ -83,6 +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
|
+
let errorFounds = [];
|
|
87
|
+
|
|
86
88
|
_izContext.correlationIds.set(coreConsts.BASE_USER_ID, "BasDev");
|
|
87
89
|
const userId = _izContext.correlationIds.get(coreConsts.BASE_USER_ID)
|
|
88
90
|
if (!userId) {
|
|
@@ -115,7 +117,6 @@ module.exports.<%- functionName %>Main = async (
|
|
|
115
117
|
|
|
116
118
|
let originTimestamp = Date.now();
|
|
117
119
|
|
|
118
|
-
let errorFounds = [];
|
|
119
120
|
|
|
120
121
|
let messageAttributes
|
|
121
122
|
|
|
@@ -136,7 +137,7 @@ module.exports.<%- functionName %>Main = async (
|
|
|
136
137
|
|
|
137
138
|
updateNodeCompleteMessage = callingFlowSharedLib.addPassBackPropertiesToSnsResponseMessageObject(callingFlowConfig, updateNodeCompleteMessage);
|
|
138
139
|
messageAttributes = callingFlowSharedLib.addCallingFlowToSnsResponseMessageAttributes(callingFlowConfig, {})
|
|
139
|
-
|
|
140
|
+
|
|
140
141
|
let messageParams = {
|
|
141
142
|
Message: JSON.stringify(updateNodeCompleteMessage),
|
|
142
143
|
MessageAttributes: sns.createStringMessageAttributes(_izContext, messageAttributes),
|
|
@@ -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
|
|
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('
|
|
74
|
-
_izContext.logger.debug('
|
|
75
|
-
_izContext.logger.debug('
|
|
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
|
-
|
|
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,
|
|
118
|
-
await validateIdentifiersExists(_izContext,
|
|
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 } =
|
|
140
|
-
const { serviceTag: secondServiceTag, objectType: secondObjectType } =
|
|
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.
|
|
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
|
-
|
|
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,
|
|
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
|
-
|
|
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
|
-
|
|
324
|
+
firstObject,
|
|
325
|
+
secondObject,
|
|
319
326
|
relType,
|
|
320
327
|
relationshipProperties,
|
|
321
|
-
|
|
328
|
+
relationshipDirection,
|
|
329
|
+
errorsFound
|
|
322
330
|
};
|
|
323
331
|
|
|
324
332
|
|
|
@@ -27,31 +27,44 @@ 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", "relationshipProperties","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
|
|
52
47
|
}
|
|
53
48
|
}
|
|
54
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
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
},
|
|
55
68
|
relType: {
|
|
56
69
|
type: "object",
|
|
57
70
|
required: ["relationshipTag", "serviceTag"],
|
|
@@ -67,6 +80,10 @@ let validatorSchema = {
|
|
|
67
80
|
relationshipProperties: {
|
|
68
81
|
type: "object",
|
|
69
82
|
minProperties: 1
|
|
83
|
+
},
|
|
84
|
+
relationshipDirection: {
|
|
85
|
+
type: "string",
|
|
86
|
+
enum: ['from','to']
|
|
70
87
|
}
|
|
71
88
|
}
|
|
72
89
|
};
|
|
@@ -94,7 +111,8 @@ module.exports.main = middleware.wrap(async (event, context, callback) => {
|
|
|
94
111
|
objects: event.objects,
|
|
95
112
|
relType: event.relType,
|
|
96
113
|
relId: event.relId,
|
|
97
|
-
relationshipProperties: event.relationshipProperties
|
|
114
|
+
relationshipProperties: event.relationshipProperties,
|
|
115
|
+
relationshipDirection: event.relationshipDirection
|
|
98
116
|
}
|
|
99
117
|
);
|
|
100
118
|
|
|
@@ -46,33 +46,46 @@ middleware.setValidatorSchema(recordHandlerSharedLib.baseValidatorSchema(
|
|
|
46
46
|
));
|
|
47
47
|
|
|
48
48
|
// validate event params in middlewware before into function.
|
|
49
|
-
let validatorSchema =
|
|
49
|
+
let validatorSchema = {
|
|
50
50
|
type: "object",
|
|
51
|
-
required: ["
|
|
51
|
+
required: ["firstObject","secondObject", "relType", "relationshipProperties","relationshipDirection"],
|
|
52
52
|
properties: {
|
|
53
|
-
|
|
54
|
-
type: "
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
required: ["serviceTag", "objectType"],
|
|
64
|
-
properties: {
|
|
65
|
-
serviceTag: izara.validatorSchema.stringNotEmpty(),
|
|
66
|
-
objectType: izara.validatorSchema.stringNotEmpty()
|
|
67
|
-
}
|
|
68
|
-
},
|
|
69
|
-
identifiers: {
|
|
70
|
-
type: "object",
|
|
71
|
-
minproperties: 1
|
|
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(),
|
|
72
63
|
}
|
|
64
|
+
},
|
|
65
|
+
identifiers: {
|
|
66
|
+
type: "object",
|
|
67
|
+
minProperties: 1
|
|
73
68
|
}
|
|
74
69
|
}
|
|
75
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(),
|
|
81
|
+
}
|
|
82
|
+
},
|
|
83
|
+
identifiers: {
|
|
84
|
+
type: "object",
|
|
85
|
+
minProperties: 1
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
},
|
|
76
89
|
relType: {
|
|
77
90
|
type: "object",
|
|
78
91
|
required: ["relationshipTag", "serviceTag"],
|
|
@@ -88,6 +101,10 @@ let validatorSchema = {
|
|
|
88
101
|
relationshipProperties: {
|
|
89
102
|
type: "object",
|
|
90
103
|
minProperties: 1
|
|
104
|
+
},
|
|
105
|
+
relationshipDirection: {
|
|
106
|
+
type: "string",
|
|
107
|
+
enum: ['from','to']
|
|
91
108
|
}
|
|
92
109
|
}
|
|
93
110
|
};
|
|
@@ -29,33 +29,46 @@ const callingFlowSharedLib = require('@izara_project/izara-shared/src/CallingFlo
|
|
|
29
29
|
const <%- functionName %> = require('./<%- firstLetterUpperCase(functionName) %>_Main');
|
|
30
30
|
|
|
31
31
|
// validate event params in middlewware before into function.
|
|
32
|
-
let validatorSchema =
|
|
32
|
+
let validatorSchema = {
|
|
33
33
|
type: "object",
|
|
34
|
-
required: ["
|
|
34
|
+
required: ["firstObject","secondObject", "relType", "relationshipProperties","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
|
|
56
51
|
}
|
|
57
52
|
}
|
|
58
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
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
},
|
|
59
72
|
relType: {
|
|
60
73
|
type: "object",
|
|
61
74
|
required: ["relationshipTag", "serviceTag"],
|
|
@@ -71,6 +84,10 @@ let validatorSchema = {
|
|
|
71
84
|
relationshipProperties: {
|
|
72
85
|
type: "object",
|
|
73
86
|
minProperties: 1
|
|
87
|
+
},
|
|
88
|
+
relationshipDirection: {
|
|
89
|
+
type: "string",
|
|
90
|
+
enum: ['from','to']
|
|
74
91
|
}
|
|
75
92
|
}
|
|
76
93
|
};
|
|
@@ -84,12 +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
|
objects: event.objects,
|
|
91
108
|
relType: event.relType,
|
|
92
109
|
relationshipProperties: event.relationshipProperties,
|
|
110
|
+
relationshipDirection: event.relationshipDirection
|
|
93
111
|
},
|
|
94
112
|
callingFlowSharedLib.addCallingFlowToPassOnProperties(event)
|
|
95
113
|
);
|