@izara_project/izara-market-library-service-schemas 1.0.65 → 1.0.67
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 +3 -3
- package/src/GenerateCodeLibs/src/Consts.js +7 -2
- package/src/GenerateCodeLibs/src/GenerateCodeLibs.js +11 -1
- package/src/MainLibs/src/Consts.js +64 -25
- package/src/MainLibs/src/GenerateCodeUtils.js +6 -6
- package/src/reStructure/GenerateCode.js +2 -1
- package/src/reStructure/TemplateData/EndpointPerService/generateTemplateData.js +1 -1
- package/src/reStructure/TemplateData/EndpointPerService/mainFunction/create/template.ejs +20 -4
- package/src/reStructure/TemplateData/EndpointPerService/yaml/data.js +49 -5
- package/src/reStructure/TemplateData/externalService/snsTopicSubscriptions/data.js +3 -0
- package/src/reStructure/TemplateData/findData/findDataYaml/data.js +2 -2
- package/src/reStructure/TemplateData/flowSchema/components/upload/createObjectComplete/functionYaml/data.js +1 -1
- package/src/reStructure/TemplateData/flowSchema/components/upload/preSignUrl/reservedLimit/mainFunction/data.js +3 -1
- package/src/reStructure/TemplateData/flowSchema/components/upload/preSignUrl/reservedLimit/mainFunction/template.ejs +14 -0
- package/src/reStructure/TemplateData/flowSchema/dynamoDb/data.js +2 -2
- package/src/reStructure/TemplateData/flowSchema/flowStep/functionYaml/data.js +3 -3
- package/src/reStructure/TemplateData/flowSchema/flowStep/handler/data.js +1 -1
- package/src/reStructure/TemplateData/flowSchema/flowStep/sns-in/data.js +4 -2
- package/src/reStructure/TemplateData/flowSchema/flowStep/sns-in/template.ejs +9 -9
- package/src/reStructure/TemplateData/flowSchema/generateTemplateData.js +24 -24
- package/src/reStructure/TemplateData/generateRole/data.js +38 -24
- package/src/reStructure/TemplateData/generateRole/template.ejs +5 -7
- package/src/reStructure/TemplateData/perActionComplete/create/yaml/data.js +1 -1
- package/src/reStructure/TemplateData/perActionComplete/delete/yaml/data.js +1 -1
- package/src/reStructure/TemplateData/perActionComplete/get/yaml/data.js +1 -1
- package/src/reStructure/TemplateData/perActionComplete/update/yaml/data.js +1 -1
- package/src/reStructure/TemplateData/processLogical/yaml/data.js +4 -4
- package/src/reStructure/TemplateData/processLogicalPagination/yaml/dsq/data.js +2 -2
- package/src/reStructure/TemplateData/processLogicalPagination/yaml/sqs/data.js +2 -2
- package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/action/functionYaml/api/data.js +1 -1
- package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/action/functionYaml/data.js +136 -0
- package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/action/functionYaml/dsq/data.js +1 -1
- package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/action/functionYaml/inv/data.js +1 -1
- package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/action/functionYaml/sqs/data.js +1 -1
- package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/action/functionYaml/template.ejs +9 -0
- package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/action/functionYaml/templateByHandler/apiTemplate.ejs +20 -0
- package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/action/functionYaml/templateByHandler/dsqTemplate.ejs +17 -0
- package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/action/functionYaml/templateByHandler/invTemplate.ejs +13 -0
- package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/action/functionYaml/templateByHandler/sqsTemplate.ejs +17 -0
- package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/action/handler/data.js +73 -0
- package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/action/handler/template.ejs +9 -0
- package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/action/handler/templateByHandler/apiTemplate.ejs +155 -0
- package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/action/handler/templateByHandler/dsqTemplate.ejs +202 -0
- package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/action/handler/templateByHandler/invTemplate.ejs +144 -0
- package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/action/handler/templateByHandler/sqsTemplate.ejs +181 -0
- package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/action/mainFunction/template.ejs +11 -11
- package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/complete/functionYaml/data.js +1 -1
- package/src/reStructure/TemplateData/relationshipPerAction/create/action/functionYaml/api/data.js +1 -1
- package/src/reStructure/TemplateData/relationshipPerAction/create/action/functionYaml/data.js +159 -0
- package/src/reStructure/TemplateData/relationshipPerAction/create/action/functionYaml/dsq/data.js +2 -2
- package/src/reStructure/TemplateData/relationshipPerAction/create/action/functionYaml/inv/data.js +2 -2
- package/src/reStructure/TemplateData/relationshipPerAction/create/action/functionYaml/sqs/data.js +2 -2
- package/src/reStructure/TemplateData/relationshipPerAction/create/action/functionYaml/template.ejs +9 -0
- package/src/reStructure/TemplateData/relationshipPerAction/create/action/functionYaml/templateByHandler/apiTemplate.ejs +20 -0
- package/src/reStructure/TemplateData/relationshipPerAction/create/action/functionYaml/templateByHandler/dsqTemplate.ejs +17 -0
- package/src/reStructure/TemplateData/relationshipPerAction/create/action/functionYaml/templateByHandler/invTemplate.ejs +13 -0
- package/src/reStructure/TemplateData/relationshipPerAction/create/action/functionYaml/templateByHandler/sqsTemplate.ejs +17 -0
- package/src/reStructure/TemplateData/relationshipPerAction/create/action/handler/data.js +73 -0
- package/src/reStructure/TemplateData/relationshipPerAction/create/action/handler/template.ejs +9 -0
- package/src/reStructure/TemplateData/relationshipPerAction/create/action/handler/templateByHandler/apiTemplate.ejs +155 -0
- package/src/reStructure/TemplateData/relationshipPerAction/create/action/handler/templateByHandler/dsqTemplate.ejs +202 -0
- package/src/reStructure/TemplateData/relationshipPerAction/create/action/handler/templateByHandler/invTemplate.ejs +144 -0
- package/src/reStructure/TemplateData/relationshipPerAction/create/action/handler/templateByHandler/sqsTemplate.ejs +181 -0
- package/src/reStructure/TemplateData/relationshipPerAction/create/complete/functionYaml/data.js +1 -1
- package/src/reStructure/TemplateData/relationshipPerAction/delete/action/functionYaml/api/data.js +1 -1
- package/src/reStructure/TemplateData/relationshipPerAction/delete/action/functionYaml/data.js +158 -0
- package/src/reStructure/TemplateData/relationshipPerAction/delete/action/functionYaml/dsq/data.js +2 -2
- package/src/reStructure/TemplateData/relationshipPerAction/delete/action/functionYaml/inv/data.js +2 -2
- package/src/reStructure/TemplateData/relationshipPerAction/delete/action/functionYaml/sqs/data.js +1 -1
- package/src/reStructure/TemplateData/relationshipPerAction/delete/action/functionYaml/template.ejs +9 -0
- package/src/reStructure/TemplateData/relationshipPerAction/delete/action/functionYaml/templateByHandler/apiTemplate.ejs +20 -0
- package/src/reStructure/TemplateData/relationshipPerAction/delete/action/functionYaml/templateByHandler/dsqTemplate.ejs +17 -0
- package/src/reStructure/TemplateData/relationshipPerAction/delete/action/functionYaml/templateByHandler/invTemplate.ejs +13 -0
- package/src/reStructure/TemplateData/relationshipPerAction/delete/action/functionYaml/templateByHandler/sqsTemplate.ejs +17 -0
- package/src/reStructure/TemplateData/relationshipPerAction/delete/action/handler/data.js +73 -0
- package/src/reStructure/TemplateData/relationshipPerAction/delete/action/handler/template.ejs +9 -0
- package/src/reStructure/TemplateData/relationshipPerAction/delete/action/handler/templateByHandler/apiTemplate.ejs +155 -0
- package/src/reStructure/TemplateData/relationshipPerAction/delete/action/handler/templateByHandler/dsqTemplate.ejs +202 -0
- package/src/reStructure/TemplateData/relationshipPerAction/delete/action/handler/templateByHandler/invTemplate.ejs +144 -0
- package/src/reStructure/TemplateData/relationshipPerAction/delete/action/handler/templateByHandler/sqsTemplate.ejs +181 -0
- package/src/reStructure/TemplateData/relationshipPerAction/delete/complete/functionYaml/data.js +1 -1
- package/src/reStructure/TemplateData/relationshipPerAction/generateTemplateData.js +131 -88
- package/src/reStructure/TemplateData/relationshipPerAction/get/action/functionYaml/api/data.js +2 -2
- package/src/reStructure/TemplateData/relationshipPerAction/get/action/functionYaml/data.js +158 -0
- package/src/reStructure/TemplateData/relationshipPerAction/get/action/functionYaml/dsq/data.js +2 -2
- package/src/reStructure/TemplateData/relationshipPerAction/get/action/functionYaml/inv/data.js +2 -2
- package/src/reStructure/TemplateData/relationshipPerAction/get/action/functionYaml/sqs/data.js +1 -1
- package/src/reStructure/TemplateData/relationshipPerAction/get/action/functionYaml/template.ejs +9 -0
- package/src/reStructure/TemplateData/relationshipPerAction/get/action/functionYaml/templateByHandler/apiTemplate.ejs +20 -0
- package/src/reStructure/TemplateData/relationshipPerAction/get/action/functionYaml/templateByHandler/dsqTemplate.ejs +17 -0
- package/src/reStructure/TemplateData/relationshipPerAction/get/action/functionYaml/templateByHandler/invTemplate.ejs +13 -0
- package/src/reStructure/TemplateData/relationshipPerAction/get/action/functionYaml/templateByHandler/sqsTemplate.ejs +17 -0
- package/src/reStructure/TemplateData/relationshipPerAction/get/action/handler/data.js +73 -0
- package/src/reStructure/TemplateData/relationshipPerAction/get/action/handler/template.ejs +9 -0
- package/src/reStructure/TemplateData/relationshipPerAction/get/action/handler/templateByHandler/apiTemplate.ejs +155 -0
- package/src/reStructure/TemplateData/relationshipPerAction/get/action/handler/templateByHandler/dsqTemplate.ejs +202 -0
- package/src/reStructure/TemplateData/relationshipPerAction/get/action/handler/templateByHandler/invTemplate.ejs +144 -0
- package/src/reStructure/TemplateData/relationshipPerAction/get/action/handler/templateByHandler/sqsTemplate.ejs +181 -0
- package/src/reStructure/TemplateData/relationshipPerAction/get/complete/functionYaml/data.js +1 -1
- package/src/reStructure/TemplateData/relationshipPerAction/moveRelationship/action/functionYaml/data.js +160 -0
- package/src/reStructure/TemplateData/relationshipPerAction/moveRelationship/action/functionYaml/template.ejs +9 -0
- package/src/reStructure/TemplateData/relationshipPerAction/moveRelationship/action/functionYaml/templateByHandler/apiTemplate.ejs +20 -0
- package/src/reStructure/TemplateData/relationshipPerAction/moveRelationship/action/functionYaml/templateByHandler/dsqTemplate.ejs +17 -0
- package/src/reStructure/TemplateData/relationshipPerAction/moveRelationship/action/functionYaml/templateByHandler/invTemplate.ejs +13 -0
- package/src/reStructure/TemplateData/relationshipPerAction/moveRelationship/action/functionYaml/templateByHandler/sqsTemplate.ejs +17 -0
- package/src/reStructure/TemplateData/relationshipPerAction/moveRelationship/action/handler/data.js +73 -0
- package/src/reStructure/TemplateData/relationshipPerAction/moveRelationship/action/handler/template.ejs +9 -0
- package/src/reStructure/TemplateData/relationshipPerAction/moveRelationship/action/handler/templateByHandler/apiTemplate.ejs +172 -0
- package/src/reStructure/TemplateData/relationshipPerAction/moveRelationship/action/handler/templateByHandler/dsqTemplate.ejs +218 -0
- package/src/reStructure/TemplateData/relationshipPerAction/moveRelationship/action/handler/templateByHandler/invTemplate.ejs +161 -0
- package/src/reStructure/TemplateData/relationshipPerAction/moveRelationship/action/handler/templateByHandler/sqsTemplate.ejs +197 -0
- package/src/reStructure/TemplateData/relationshipPerAction/moveRelationship/action/mainFunction/data.js +59 -0
- package/src/reStructure/TemplateData/relationshipPerAction/moveRelationship/action/mainFunction/template.ejs +386 -0
- package/src/reStructure/TemplateData/relationshipPerAction/moveRelationship/action/sns-in-sqs/data.js +77 -0
- package/src/reStructure/TemplateData/relationshipPerAction/moveRelationship/action/sns-in-sqs/snsTemplate.ejs +59 -0
- package/src/reStructure/TemplateData/relationshipPerAction/moveRelationship/action/sns-in-sqs/sqsTemplate.ejs +43 -0
- package/src/reStructure/TemplateData/relationshipPerAction/moveRelationship/complete/functionYaml/data.js +121 -0
- package/src/reStructure/TemplateData/relationshipPerAction/moveRelationship/complete/functionYaml/template.ejs +20 -0
- package/src/reStructure/TemplateData/relationshipPerAction/moveRelationship/complete/handler/sqs/data.js +60 -0
- package/src/reStructure/TemplateData/relationshipPerAction/moveRelationship/complete/handler/sqs/template.ejs +129 -0
- package/src/reStructure/TemplateData/relationshipPerAction/moveRelationship/complete/mainFunction/data.js +56 -0
- package/src/reStructure/TemplateData/relationshipPerAction/moveRelationship/complete/mainFunction/template.ejs +159 -0
- package/src/reStructure/TemplateData/relationshipPerAction/moveRelationship/complete/sns-in-sqs/data.js +71 -0
- package/src/reStructure/TemplateData/relationshipPerAction/moveRelationship/complete/sns-in-sqs/template.ejs +46 -0
- package/src/reStructure/TemplateData/relationshipPerAction/moveRelationship/complete/sns-out/data.js +71 -0
- package/src/reStructure/TemplateData/relationshipPerAction/moveRelationship/complete/sns-out/template.ejs +10 -0
- package/src/reStructure/TemplateData/relationshipPerAction/update/action/functionYaml/api/data.js +2 -2
- package/src/reStructure/TemplateData/relationshipPerAction/update/action/functionYaml/data.js +164 -0
- package/src/reStructure/TemplateData/relationshipPerAction/update/action/functionYaml/dsq/data.js +2 -2
- package/src/reStructure/TemplateData/relationshipPerAction/update/action/functionYaml/inv/data.js +2 -2
- package/src/reStructure/TemplateData/relationshipPerAction/update/action/functionYaml/sqs/data.js +1 -1
- package/src/reStructure/TemplateData/relationshipPerAction/update/action/functionYaml/template.ejs +9 -0
- package/src/reStructure/TemplateData/relationshipPerAction/update/action/functionYaml/templateByHandler/apiTemplate.ejs +20 -0
- package/src/reStructure/TemplateData/relationshipPerAction/update/action/functionYaml/templateByHandler/dsqTemplate.ejs +17 -0
- package/src/reStructure/TemplateData/relationshipPerAction/update/action/functionYaml/templateByHandler/invTemplate.ejs +13 -0
- package/src/reStructure/TemplateData/relationshipPerAction/update/action/functionYaml/templateByHandler/sqsTemplate.ejs +17 -0
- package/src/reStructure/TemplateData/relationshipPerAction/update/action/handler/data.js +73 -0
- package/src/reStructure/TemplateData/relationshipPerAction/update/action/handler/template.ejs +9 -0
- package/src/reStructure/TemplateData/relationshipPerAction/update/action/handler/templateByHandler/apiTemplate.ejs +155 -0
- package/src/reStructure/TemplateData/relationshipPerAction/update/action/handler/templateByHandler/dsqTemplate.ejs +202 -0
- package/src/reStructure/TemplateData/relationshipPerAction/update/action/handler/templateByHandler/invTemplate.ejs +144 -0
- package/src/reStructure/TemplateData/relationshipPerAction/update/action/handler/templateByHandler/sqsTemplate.ejs +181 -0
- package/src/reStructure/TemplateData/relationshipPerAction/update/complete/functionYaml/data.js +1 -1
- package/src/reStructure/TemplateData/resourceYaml/dynamodb/mainResourcePerObjectSchemaData.js +8 -7
- package/src/reStructure/TemplateData/resourceYaml/filterGenerateResource/data.js +36 -30
- package/src/reStructure/TemplateData/resourceYaml/generateTemplateData.js +3 -3
|
@@ -86,7 +86,7 @@ module.exports.<%- functionName %> = async (
|
|
|
86
86
|
const {
|
|
87
87
|
firstObject,
|
|
88
88
|
secondObject,
|
|
89
|
-
|
|
89
|
+
oldRelTypeAndDirection,
|
|
90
90
|
newRelType,
|
|
91
91
|
//(<requestParamCreateRel>)
|
|
92
92
|
//(</requestParamCreateRel>)
|
|
@@ -153,8 +153,8 @@ module.exports.<%- functionName %> = async (
|
|
|
153
153
|
const matchToFrom = fromServiceTag === secondServiceTag && fromObjectType === secondObjectType &&
|
|
154
154
|
toServiceTag === firstServiceTag && toObjType === firstObjectType;
|
|
155
155
|
|
|
156
|
-
if ((
|
|
157
|
-
(
|
|
156
|
+
if ((oldRelTypeAndDirection.relationshipDirection === "from" && matchFromTo) ||
|
|
157
|
+
(oldRelTypeAndDirection.relationshipDirection === "to" && matchToFrom)) {
|
|
158
158
|
checkCorrectLink = true
|
|
159
159
|
break;
|
|
160
160
|
}
|
|
@@ -219,7 +219,7 @@ module.exports.<%- functionName %> = async (
|
|
|
219
219
|
|
|
220
220
|
|
|
221
221
|
// validate properties exists with schema
|
|
222
|
-
for (const propKey in
|
|
222
|
+
for (const propKey in oldRelTypeAndDirection.relationshipProperties) {
|
|
223
223
|
if (!relationshipSchema.fieldNames.hasOwnProperty(propKey)) {
|
|
224
224
|
errorsFound.push(`property: ${propKey} not exists in relationshipSchema`);
|
|
225
225
|
}
|
|
@@ -236,7 +236,7 @@ module.exports.<%- functionName %> = async (
|
|
|
236
236
|
let changeRelCompleteMsg = {
|
|
237
237
|
fromObject: firstObject,
|
|
238
238
|
toObject: secondObject,
|
|
239
|
-
|
|
239
|
+
oldRelTypeAndDirection,
|
|
240
240
|
newRelType,
|
|
241
241
|
originTimestamp,
|
|
242
242
|
changedByUserId,
|
|
@@ -256,7 +256,7 @@ module.exports.<%- functionName %> = async (
|
|
|
256
256
|
let messageParams = {
|
|
257
257
|
Message: JSON.stringify(changeRelCompleteMsg),
|
|
258
258
|
MessageAttributes: sns.createStringMessageAttributes(_izContext, messageAttributes),
|
|
259
|
-
TopicArn: await snsSharedLib.snsTopicArnByFlowSchema(_izContext, TOPIC_NAME_GENERATE_CODE.
|
|
259
|
+
TopicArn: await snsSharedLib.snsTopicArnByFlowSchema(_izContext, TOPIC_NAME_GENERATE_CODE.outChangeRelationshipComplete),
|
|
260
260
|
};
|
|
261
261
|
|
|
262
262
|
_izContext.logger.debug("messageParams OutCreateRelationshipComplete ::::::: ", messageParams);
|
|
@@ -268,7 +268,7 @@ module.exports.<%- functionName %> = async (
|
|
|
268
268
|
|
|
269
269
|
|
|
270
270
|
// before create awaitingStepId per graph storageResource
|
|
271
|
-
const linkTypeId = createLinkTypeId(_izContext, firstObject.objType, secondObject.objType, newRelType,
|
|
271
|
+
const linkTypeId = createLinkTypeId(_izContext, firstObject.objType, secondObject.objType, newRelType, oldRelTypeAndDirection.relationshipDirection);
|
|
272
272
|
|
|
273
273
|
let usedGraphServiceTag = []; // collect used graph serviceTag, use to check duplicate graph serviceTag across graph serverTag
|
|
274
274
|
let targetGraphStorageResources = []; // collect used graph storageResources, filtered duplicate graphServiceTag from graphServerTag out
|
|
@@ -290,7 +290,7 @@ module.exports.<%- functionName %> = async (
|
|
|
290
290
|
callingFlowProperties: callingFlowConfig.callingFlowProperties || {},
|
|
291
291
|
firstObject,
|
|
292
292
|
secondObject,
|
|
293
|
-
|
|
293
|
+
oldRelTypeAndDirection,
|
|
294
294
|
newRelType,
|
|
295
295
|
}), // hash id
|
|
296
296
|
PREFIX.changeRel // prefix, use constant further
|
|
@@ -311,7 +311,7 @@ module.exports.<%- functionName %> = async (
|
|
|
311
311
|
callingFlowProperties: callingFlowConfig.callingFlowProperties || {},
|
|
312
312
|
firstObject,
|
|
313
313
|
secondObject,
|
|
314
|
-
|
|
314
|
+
oldRelTypeAndDirection,
|
|
315
315
|
newRelType,
|
|
316
316
|
}), // hash id
|
|
317
317
|
PREFIX.changeRel // prefix, use constant further
|
|
@@ -322,7 +322,7 @@ module.exports.<%- functionName %> = async (
|
|
|
322
322
|
let changeRelMessageBody = {
|
|
323
323
|
fromObject: firstObject,
|
|
324
324
|
toObject: secondObject,
|
|
325
|
-
|
|
325
|
+
oldRelTypeAndDirection,
|
|
326
326
|
newRelType,
|
|
327
327
|
originTimestamp,
|
|
328
328
|
changedByUserId,
|
|
@@ -367,7 +367,7 @@ module.exports.<%- functionName %> = async (
|
|
|
367
367
|
return {
|
|
368
368
|
fromObject: firstObject,
|
|
369
369
|
toObject: secondObject,
|
|
370
|
-
|
|
370
|
+
oldRelTypeAndDirection,
|
|
371
371
|
newRelType,
|
|
372
372
|
originTimestamp,
|
|
373
373
|
changedByUserId,
|
|
@@ -104,7 +104,7 @@ function createParamForCreateSource(srcPath) {
|
|
|
104
104
|
handlerType,
|
|
105
105
|
additionalResourcePermission,
|
|
106
106
|
resourceLocation: SOURCE_PATH.resourceLocationRelationshipPerAction,
|
|
107
|
-
functionNameConfig: upperCase(SHORT_FUNCTION_NAME.changeRelComplete),
|
|
107
|
+
functionNameConfig: upperCase(SHORT_FUNCTION_NAME(FUNCTION_NAME.changeRelComplete)),
|
|
108
108
|
roleName: SOURCE_GENERATE_IAM_ROLE.RelationshipCompleteRole
|
|
109
109
|
},
|
|
110
110
|
setting: {
|
package/src/reStructure/TemplateData/relationshipPerAction/create/action/functionYaml/api/data.js
CHANGED
|
@@ -125,7 +125,7 @@ function createParamForCreateSource(allObjectRelationships, srcPath) {
|
|
|
125
125
|
handlerType,
|
|
126
126
|
additionalResourcePermission,
|
|
127
127
|
resourceLocation: SOURCE_PATH.resourceLocationRelationshipPerAction,
|
|
128
|
-
functionNameConfig: upperCase(SHORT_FUNCTION_NAME.createRel) + upperCase(shortNameHandler(handlerType)),
|
|
128
|
+
functionNameConfig: upperCase(SHORT_FUNCTION_NAME(FUNCTION_NAME.createRel)) + upperCase(shortNameHandler(handlerType)),
|
|
129
129
|
roleName: SOURCE_GENERATE_IAM_ROLE.RelationshipRole
|
|
130
130
|
},
|
|
131
131
|
setting: {
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright (C) 2020 Sven Mason <http://izara.io>
|
|
3
|
+
|
|
4
|
+
This program is free software: you can redistribute it and/or modify
|
|
5
|
+
it under the terms of the GNU Affero General Public License as
|
|
6
|
+
published by the Free Software Foundation, either version 3 of the
|
|
7
|
+
License, or (at your option) any later version.
|
|
8
|
+
|
|
9
|
+
This program is distributed in the hope that it will be useful,
|
|
10
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
11
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
12
|
+
GNU Affero General Public License for more details.
|
|
13
|
+
|
|
14
|
+
You should have received a copy of the GNU Affero General Public License
|
|
15
|
+
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
'use strict';
|
|
19
|
+
const path = require('path');
|
|
20
|
+
|
|
21
|
+
const { ACTIONS, HANDLER, STORAGE_TYPES } = require('@izara_project/izara-core-library-service-schemas/src/Consts');
|
|
22
|
+
|
|
23
|
+
const { firstLetterLowerCase: lowerCase, firstLetterUpperCase: upperCase, getLocalConfig } = require("../../../../../../MainLibs/src/Utils.js");
|
|
24
|
+
const {
|
|
25
|
+
createIamRole,
|
|
26
|
+
resourceNames,
|
|
27
|
+
RESOURCE_CLASSES,
|
|
28
|
+
SOURCE_PATH,
|
|
29
|
+
SAVE_FILE_NAME,
|
|
30
|
+
FUNCTION_NAME,
|
|
31
|
+
SNS_RESOURCE,
|
|
32
|
+
defaultIamRolePerAction,
|
|
33
|
+
awaitingMultipleStepsRole,
|
|
34
|
+
shortNameHandler,
|
|
35
|
+
SHORT_FUNCTION_NAME,
|
|
36
|
+
SOURCE_GENERATE_IAM_ROLE,
|
|
37
|
+
checkDynamoTypeRelationship,
|
|
38
|
+
createDynamoDbComponentByLinks,
|
|
39
|
+
DYNAMO_RESOURCE,
|
|
40
|
+
SQS_RESOURCE
|
|
41
|
+
} = require("../../../../../../MainLibs/src/Consts.js");
|
|
42
|
+
const templatePath = path.join(__dirname, "./template.ejs")
|
|
43
|
+
|
|
44
|
+
const apiTemplate = path.join(__dirname, "././templateByHandler/apiTemplate.ejs")
|
|
45
|
+
const dsqTemplate = path.join(__dirname, "././templateByHandler/dsqTemplate.ejs")
|
|
46
|
+
const invTemplate = path.join(__dirname, "././templateByHandler/invTemplate.ejs")
|
|
47
|
+
const sqsTemplate = path.join(__dirname, "././templateByHandler/sqsTemplate.ejs")
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* receive objectSchema
|
|
51
|
+
* create data for updateRelationshipSchema
|
|
52
|
+
*
|
|
53
|
+
* @param {Object} objectSchema
|
|
54
|
+
* @return {{ templatePath, templateData, setting } }
|
|
55
|
+
*/
|
|
56
|
+
|
|
57
|
+
function data(_izContext, allObjectRelationships, srcPath) {
|
|
58
|
+
let createSourceArray = [];
|
|
59
|
+
for (const handlerType of Object.values(HANDLER)) {
|
|
60
|
+
const createSourceParam = createParamForCreateSource(allObjectRelationships, handlerType, srcPath);
|
|
61
|
+
createSourceArray.push(createSourceParam);
|
|
62
|
+
}
|
|
63
|
+
// console.log("createSourceArrayInUpdaterelationShipSchemahdrSqs", createSourceArray)
|
|
64
|
+
return createSourceArray
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
function createParamForCreateSource(allObjectRelationships, handlerType, srcPath) {
|
|
69
|
+
|
|
70
|
+
let functionName = upperCase(FUNCTION_NAME.createRel)
|
|
71
|
+
let additionalResourcePermission = defaultIamRolePerAction();
|
|
72
|
+
|
|
73
|
+
additionalResourcePermission.push(awaitingMultipleStepsRole())
|
|
74
|
+
|
|
75
|
+
if (handlerType === HANDLER.hdrDsq) {
|
|
76
|
+
additionalResourcePermission.push(
|
|
77
|
+
createIamRole(
|
|
78
|
+
{
|
|
79
|
+
[RESOURCE_CLASSES.sqs]: [
|
|
80
|
+
SQS_RESOURCE.deleteMessage,
|
|
81
|
+
SQS_RESOURCE.getQueueAttributes,
|
|
82
|
+
SQS_RESOURCE.receiveMessage,
|
|
83
|
+
SQS_RESOURCE.sendMessage,
|
|
84
|
+
SQS_RESOURCE.getQueueUrl,
|
|
85
|
+
SQS_RESOURCE.deleteMessageBatch
|
|
86
|
+
],
|
|
87
|
+
},
|
|
88
|
+
[
|
|
89
|
+
resourceNames(RESOURCE_CLASSES.sqs, upperCase(functionName) + upperCase(handlerType)),
|
|
90
|
+
resourceNames(RESOURCE_CLASSES.sqs, upperCase(functionName) + upperCase(handlerType) + "DLQ"),
|
|
91
|
+
]
|
|
92
|
+
)
|
|
93
|
+
)
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
if (handlerType === HANDLER.hdrSqs) {
|
|
97
|
+
additionalResourcePermission.push(
|
|
98
|
+
createIamRole(
|
|
99
|
+
{
|
|
100
|
+
[RESOURCE_CLASSES.sns]: [SNS_RESOURCE.publish, SNS_RESOURCE.subscribe],
|
|
101
|
+
[RESOURCE_CLASSES.sqs]: [SQS_RESOURCE.receiveMessage, SQS_RESOURCE.sendMessage]
|
|
102
|
+
},
|
|
103
|
+
[
|
|
104
|
+
resourceNames(RESOURCE_CLASSES.sns, upperCase(FUNCTION_NAME.createRelComplete) + "_Out"),
|
|
105
|
+
resourceNames(RESOURCE_CLASSES.sqs, upperCase(functionName) + upperCase(handlerType)),
|
|
106
|
+
resourceNames(RESOURCE_CLASSES.sqs, upperCase(functionName) + upperCase(handlerType) + "DLQ"),
|
|
107
|
+
resourceNames(RESOURCE_CLASSES.sns, upperCase(functionName) + "_In"),
|
|
108
|
+
resourceNames(RESOURCE_CLASSES.sns, upperCase(functionName) + "_Out"),
|
|
109
|
+
]
|
|
110
|
+
)
|
|
111
|
+
)
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
for (const relationship of allObjectRelationships) {
|
|
115
|
+
let [storageType, relationshipTag, links] = checkDynamoTypeRelationship(relationship)
|
|
116
|
+
if (storageType === STORAGE_TYPES.dynamoDB) {
|
|
117
|
+
for (const link of links) {
|
|
118
|
+
let dynamoComponent = createDynamoDbComponentByLinks(link, relationshipTag)
|
|
119
|
+
additionalResourcePermission.push(
|
|
120
|
+
createIamRole(
|
|
121
|
+
{
|
|
122
|
+
[RESOURCE_CLASSES.dynamoDbTable]: [DYNAMO_RESOURCE.putItem]
|
|
123
|
+
},
|
|
124
|
+
[
|
|
125
|
+
resourceNames(RESOURCE_CLASSES.dynamoDbTable, upperCase(dynamoComponent.tableNameFrom)),
|
|
126
|
+
resourceNames(RESOURCE_CLASSES.dynamoDbTable, upperCase(dynamoComponent.tableNameTo))
|
|
127
|
+
]
|
|
128
|
+
)
|
|
129
|
+
)
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
return {
|
|
135
|
+
templatePath: templatePath,
|
|
136
|
+
templateData: {
|
|
137
|
+
functionName,
|
|
138
|
+
handlerType,
|
|
139
|
+
additionalResourcePermission,
|
|
140
|
+
resourceLocation: SOURCE_PATH.resourceLocationRelationshipPerAction,
|
|
141
|
+
functionNameConfig: upperCase(SHORT_FUNCTION_NAME(FUNCTION_NAME.createRel)) + upperCase(shortNameHandler(handlerType)),
|
|
142
|
+
roleName: SOURCE_GENERATE_IAM_ROLE.RelationshipRole,
|
|
143
|
+
serviceTag: getLocalConfig(path.join(srcPath, "../"), "iz_serviceTag"),
|
|
144
|
+
apiTemplate,
|
|
145
|
+
dsqTemplate,
|
|
146
|
+
invTemplate,
|
|
147
|
+
sqsTemplate
|
|
148
|
+
},
|
|
149
|
+
setting: {
|
|
150
|
+
savePath: path.join(srcPath, SOURCE_PATH.appYaml),
|
|
151
|
+
saveFileName: SAVE_FILE_NAME.functionRelationshipYaml,
|
|
152
|
+
fileExtension: '.yml',
|
|
153
|
+
isAppend: true
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
module.exports = data;
|
package/src/reStructure/TemplateData/relationshipPerAction/create/action/functionYaml/dsq/data.js
CHANGED
|
@@ -126,8 +126,8 @@ function createParamForCreateSource(allObjectRelationships, srcPath) {
|
|
|
126
126
|
handlerType,
|
|
127
127
|
additionalResourcePermission,
|
|
128
128
|
resourceLocation: SOURCE_PATH.resourceLocationRelationshipPerAction,
|
|
129
|
-
functionNameConfig: upperCase(SHORT_FUNCTION_NAME.createRel) + upperCase(shortNameHandler(handlerType)),
|
|
130
|
-
|
|
129
|
+
functionNameConfig: upperCase(SHORT_FUNCTION_NAME(FUNCTION_NAME.createRel)) + upperCase(shortNameHandler(handlerType)),
|
|
130
|
+
roleName: SOURCE_GENERATE_IAM_ROLE.RelationshipRole
|
|
131
131
|
},
|
|
132
132
|
setting: {
|
|
133
133
|
savePath: path.join(srcPath, SOURCE_PATH.appYaml),
|
package/src/reStructure/TemplateData/relationshipPerAction/create/action/functionYaml/inv/data.js
CHANGED
|
@@ -125,8 +125,8 @@ function createParamForCreateSource(allObjectRelationships, srcPath) {
|
|
|
125
125
|
handlerType,
|
|
126
126
|
additionalResourcePermission,
|
|
127
127
|
resourceLocation: SOURCE_PATH.resourceLocationRelationshipPerAction,
|
|
128
|
-
functionNameConfig: upperCase(SHORT_FUNCTION_NAME.createRel) + upperCase(shortNameHandler(handlerType)),
|
|
129
|
-
|
|
128
|
+
functionNameConfig: upperCase(SHORT_FUNCTION_NAME(FUNCTION_NAME.createRel)) + upperCase(shortNameHandler(handlerType)),
|
|
129
|
+
roleName: SOURCE_GENERATE_IAM_ROLE.RelationshipRole
|
|
130
130
|
},
|
|
131
131
|
setting: {
|
|
132
132
|
savePath: path.join(srcPath, SOURCE_PATH.appYaml),
|
package/src/reStructure/TemplateData/relationshipPerAction/create/action/functionYaml/sqs/data.js
CHANGED
|
@@ -127,8 +127,8 @@ function createParamForCreateSource(allObjectRelationships, srcPath) {
|
|
|
127
127
|
handlerType,
|
|
128
128
|
additionalResourcePermission,
|
|
129
129
|
resourceLocation: SOURCE_PATH.resourceLocationRelationshipPerAction,
|
|
130
|
-
functionNameConfig: upperCase(SHORT_FUNCTION_NAME.createRel) + upperCase(shortNameHandler(handlerType)),
|
|
131
|
-
|
|
130
|
+
functionNameConfig: upperCase(SHORT_FUNCTION_NAME(FUNCTION_NAME.createRel)) + upperCase(shortNameHandler(handlerType)),
|
|
131
|
+
roleName: SOURCE_GENERATE_IAM_ROLE.RelationshipRole
|
|
132
132
|
},
|
|
133
133
|
setting: {
|
|
134
134
|
savePath: path.join(srcPath, SOURCE_PATH.appYaml),
|
package/src/reStructure/TemplateData/relationshipPerAction/create/action/functionYaml/template.ejs
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
<% if (handlerType === "hdrApi") { %>
|
|
2
|
+
<%- include(apiTemplate),{ functionName, handlerType, additionalResourcePermission, resourceLocation, functionNameConfig, roleName, serviceTag } %>
|
|
3
|
+
<% } else if (handlerType === "hdrDsq") { %>
|
|
4
|
+
<%- include(dsqTemplate), { functionName, handlerType, additionalResourcePermission, resourceLocation, functionNameConfig, roleName } %>
|
|
5
|
+
<% } else if (handlerType === "hdrInv") { %>
|
|
6
|
+
<%- include(invTemplate), { functionName, handlerType, additionalResourcePermission, resourceLocation, functionNameConfig, roleName } %>
|
|
7
|
+
<% } else if (handlerType === "hdrSqs") { %>
|
|
8
|
+
<%- include(sqsTemplate),{ functionName, handlerType, additionalResourcePermission, resourceLocation, functionNameConfig, roleName } %>
|
|
9
|
+
<% } %>
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
<%_ const join = require('path').join; _%>
|
|
2
|
+
<%- firstLetterUpperCase(functionNameConfig) %>:
|
|
3
|
+
handler: <%- join(resourceLocation, `${firstLetterUpperCase(functionName)}_${firstLetterUpperCase(handlerType)}.main`)%>
|
|
4
|
+
name: ${self:custom.iz_resourcePrefix}<%- firstLetterUpperCase(functionName) %><%- firstLetterUpperCase(handlerType) %>
|
|
5
|
+
events:
|
|
6
|
+
- http:
|
|
7
|
+
path: /<%- serviceTag %>/<%- firstLetterLowerCase(functionName) %>/<%- functionName %>/
|
|
8
|
+
method: put
|
|
9
|
+
cors: true
|
|
10
|
+
#<#Authorizer#>
|
|
11
|
+
#<#/Authorizer#>
|
|
12
|
+
role: <%- roleName %>Role
|
|
13
|
+
#<#<%- functionName %><%- firstLetterUpperCase(handlerType) %>IamRole#>
|
|
14
|
+
#<#/<%- functionName %><%- firstLetterUpperCase(handlerType) %>IamRole#>
|
|
15
|
+
<%_ function firstLetterUpperCase(text){
|
|
16
|
+
return text.charAt(0).toUpperCase() + text.slice(1)
|
|
17
|
+
} _%>
|
|
18
|
+
<%_ function firstLetterLowerCase(str) {
|
|
19
|
+
return str.charAt(0).toLowerCase() + str.slice(1)
|
|
20
|
+
} _%>
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
<%_ const join = require('path').join; _%>
|
|
2
|
+
<%- firstLetterUpperCase(functionNameConfig) %>:
|
|
3
|
+
handler: <%- join(resourceLocation, `${firstLetterUpperCase(functionName)}_${firstLetterUpperCase(handlerType)}.main`)%>
|
|
4
|
+
name: ${self:custom.iz_resourcePrefix}<%- firstLetterUpperCase(functionName) %><%- firstLetterUpperCase(handlerType) %>
|
|
5
|
+
events:
|
|
6
|
+
- sqs:
|
|
7
|
+
arn: arn:aws:sqs:${self:custom.iz_region}:${self:custom.iz_accountId}:${self:custom.iz_resourcePrefix}<%- firstLetterUpperCase(functionName) %><%- firstLetterUpperCase(handlerType) %>
|
|
8
|
+
batchSize: 10
|
|
9
|
+
role: <%- roleName %>Role
|
|
10
|
+
#<#<%- functionName %><%- firstLetterUpperCase(handlerType) %>IamRole#>
|
|
11
|
+
#<#/<%- functionName %><%- firstLetterUpperCase(handlerType) %>IamRole#>
|
|
12
|
+
<%_ function firstLetterUpperCase(text){
|
|
13
|
+
return text.charAt(0).toUpperCase() + text.slice(1)
|
|
14
|
+
} _%>
|
|
15
|
+
<%_ function firstLetterLowerCase(str) {
|
|
16
|
+
return str.charAt(0).toLowerCase() + str.slice(1)
|
|
17
|
+
} _%>
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
<%_ const join = require('path').join; _%>
|
|
2
|
+
<%- firstLetterUpperCase(functionNameConfig) %>:
|
|
3
|
+
handler: <%- join(resourceLocation, `${firstLetterUpperCase(functionName)}_${firstLetterUpperCase(handlerType)}.main`)%>
|
|
4
|
+
name: ${self:custom.iz_resourcePrefix}<%- firstLetterUpperCase(functionName) %><%- firstLetterUpperCase(handlerType) %>
|
|
5
|
+
role: <%- roleName %>Role
|
|
6
|
+
#<#<%- functionName %><%- firstLetterUpperCase(handlerType) %>IamRole#>
|
|
7
|
+
#<#/<%- functionName %><%- firstLetterUpperCase(handlerType) %>IamRole#>
|
|
8
|
+
<%_ function firstLetterUpperCase(text){
|
|
9
|
+
return text.charAt(0).toUpperCase() + text.slice(1)
|
|
10
|
+
} _%>
|
|
11
|
+
<%_ function firstLetterLowerCase(str) {
|
|
12
|
+
return str.charAt(0).toLowerCase() + str.slice(1)
|
|
13
|
+
} _%>
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
<%_ const join = require('path').join; _%>
|
|
2
|
+
<%- firstLetterUpperCase(functionNameConfig) %>:
|
|
3
|
+
handler: <%- join(resourceLocation, `${firstLetterUpperCase(functionName)}_${firstLetterUpperCase(handlerType)}.main`)%>
|
|
4
|
+
name: ${self:custom.iz_resourcePrefix}<%- firstLetterUpperCase(functionName) %><%- firstLetterUpperCase(handlerType) %>
|
|
5
|
+
events:
|
|
6
|
+
- sqs:
|
|
7
|
+
arn: arn:aws:sqs:${self:custom.iz_region}:${self:custom.iz_accountId}:${self:custom.iz_resourcePrefix}<%- firstLetterUpperCase(functionName) %><%- firstLetterUpperCase(handlerType) %>
|
|
8
|
+
batchSize: 10
|
|
9
|
+
role: <%- roleName %>Role
|
|
10
|
+
#<#<%- functionName %><%- firstLetterUpperCase(handlerType) %>IamRole#>
|
|
11
|
+
#<#/<%- functionName %><%- firstLetterUpperCase(handlerType) %>IamRole#>
|
|
12
|
+
<%_ function firstLetterUpperCase(text){
|
|
13
|
+
return text.charAt(0).toUpperCase() + text.slice(1)
|
|
14
|
+
} _%>
|
|
15
|
+
<%_ function firstLetterLowerCase(str) {
|
|
16
|
+
return str.charAt(0).toLowerCase() + str.slice(1)
|
|
17
|
+
} _%>
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright (C) 2020 Sven Mason <http://izara.io>
|
|
3
|
+
|
|
4
|
+
This program is free software: you can redistribute it and/or modify
|
|
5
|
+
it under the terms of the GNU Affero General Public License as
|
|
6
|
+
published by the Free Software Foundation, either version 3 of the
|
|
7
|
+
License, or (at your option) any later version.
|
|
8
|
+
|
|
9
|
+
This program is distributed in the hope that it will be useful,
|
|
10
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
11
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
12
|
+
GNU Affero General Public License for more details.
|
|
13
|
+
|
|
14
|
+
You should have received a copy of the GNU Affero General Public License
|
|
15
|
+
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
'use strict';
|
|
19
|
+
const path = require('path');
|
|
20
|
+
|
|
21
|
+
const { ACTIONS, HANDLER } = require('@izara_project/izara-core-library-service-schemas/src/Consts')
|
|
22
|
+
|
|
23
|
+
const { firstLetterLowerCase: lowerCase, firstLetterUpperCase: upperCase } = require("../../../../../../MainLibs/src/Utils.js");
|
|
24
|
+
const { SOURCE_PATH, FUNCTION_NAME } = require("../../../../../../MainLibs/src/Consts.js");
|
|
25
|
+
|
|
26
|
+
const templatePath = path.join(__dirname, "./template.ejs")
|
|
27
|
+
const apiTemplate = path.join(__dirname, "./templateByHandler/apiTemplate.ejs")
|
|
28
|
+
const dsqTemplate = path.join(__dirname, "./templateByHandler/dsqTemplate.ejs")
|
|
29
|
+
const invTemplate = path.join(__dirname, "./templateByHandler/invTemplate.ejs")
|
|
30
|
+
const sqsTemplate = path.join(__dirname, "./templateByHandler/sqsTemplate.ejs")
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* receive objectSchema
|
|
35
|
+
* create data for hdrInv template
|
|
36
|
+
*
|
|
37
|
+
* @return {{ templatePath, templateData, setting } }
|
|
38
|
+
*/
|
|
39
|
+
function data(_izContext, srcPath) {
|
|
40
|
+
const createSourceParams = [];
|
|
41
|
+
for (const handler of Object.values(HANDLER)) {
|
|
42
|
+
const createSourceParam = createParamForCreateSource(handler, srcPath)
|
|
43
|
+
createSourceParams.push(createSourceParam)
|
|
44
|
+
}
|
|
45
|
+
return createSourceParams
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
function createParamForCreateSource(handler, srcPath) {
|
|
50
|
+
let functionName = FUNCTION_NAME.createRel;
|
|
51
|
+
let queueName = functionName + upperCase(handler)
|
|
52
|
+
return {
|
|
53
|
+
templatePath: templatePath,
|
|
54
|
+
templateData: {
|
|
55
|
+
functionName,
|
|
56
|
+
queueName,
|
|
57
|
+
apiTemplate,
|
|
58
|
+
dsqTemplate,
|
|
59
|
+
invTemplate,
|
|
60
|
+
sqsTemplate,
|
|
61
|
+
handler
|
|
62
|
+
},
|
|
63
|
+
setting: {
|
|
64
|
+
savePath: path.join(srcPath, SOURCE_PATH.relationshipPerAction),
|
|
65
|
+
saveFileName: upperCase(functionName) + "_" + upperCase(handler),
|
|
66
|
+
fileExtension: '.js',
|
|
67
|
+
isAppend: false
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
module.exports = data;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
<% if (handler === "hdrApi") { %>
|
|
2
|
+
<%- include(apiTemplate),{ functionName } %>
|
|
3
|
+
<% } else if (handler === "hdrDsq") { %>
|
|
4
|
+
<%- include(dsqTemplate), { functionName, queueName } %>
|
|
5
|
+
<% } else if (handler === "hdrInv") { %>
|
|
6
|
+
<%- include(invTemplate), { functionName} %>
|
|
7
|
+
<% } else if (handler === "hdrSqs") { %>
|
|
8
|
+
<%- include(sqsTemplate),{ functionName, queueName } %>
|
|
9
|
+
<% } %>
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright (C) 2020 Sven Mason <http://izara.io>
|
|
3
|
+
|
|
4
|
+
This program is free software: you can redistribute it and/or modify
|
|
5
|
+
it under the terms of the GNU Affero General Public License as
|
|
6
|
+
published by the Free Software Foundation, either version 3 of the
|
|
7
|
+
License, or (at your option) any later version.
|
|
8
|
+
|
|
9
|
+
This program is distributed in the hope that it will be useful,
|
|
10
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
11
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
12
|
+
GNU Affero General Public License for more details.
|
|
13
|
+
|
|
14
|
+
You should have received a copy of the GNU Affero General Public License
|
|
15
|
+
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
'use strict';
|
|
19
|
+
const izara = require("@izara_project/izara-middleware");
|
|
20
|
+
const middleware = izara.middlewareHandler;
|
|
21
|
+
const callingFlowSharedLib = require('@izara_project/izara-core-library-calling-flow');
|
|
22
|
+
const {
|
|
23
|
+
validateSchemaMiddleware
|
|
24
|
+
} = require('@izara_project/izara-market-library-service-schemas/src/GenerateCodeLibs/src/GenerateCodeLibs');
|
|
25
|
+
|
|
26
|
+
const <%- functionName %> = require('./<%- firstLetterUpperCase(functionName) %>_Main');
|
|
27
|
+
// validate event params in middleware before into function
|
|
28
|
+
let validatorSchema = {
|
|
29
|
+
type: "object",
|
|
30
|
+
required: [
|
|
31
|
+
'firstObject',
|
|
32
|
+
'secondObject',
|
|
33
|
+
'oldReltypeAndDirection',
|
|
34
|
+
'newRelType',
|
|
35
|
+
],
|
|
36
|
+
properties: {
|
|
37
|
+
firstObject: {
|
|
38
|
+
type: 'object',
|
|
39
|
+
required: ['objType', 'identifiers'],
|
|
40
|
+
properties: {
|
|
41
|
+
objType: {
|
|
42
|
+
type: 'object',
|
|
43
|
+
required: ['objectType', 'serviceTag'],
|
|
44
|
+
properties: {
|
|
45
|
+
serviceTag: izara.validatorSchema.stringNotEmpty(),
|
|
46
|
+
objectType: izara.validatorSchema.stringNotEmpty(),
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
identifiers: {
|
|
50
|
+
type: "object",
|
|
51
|
+
minProperties: 1
|
|
52
|
+
},
|
|
53
|
+
}
|
|
54
|
+
},
|
|
55
|
+
secondObject: {
|
|
56
|
+
type: 'object',
|
|
57
|
+
required: ['objType', 'identifiers'],
|
|
58
|
+
properties: {
|
|
59
|
+
objType: {
|
|
60
|
+
type: 'object',
|
|
61
|
+
required: ['objectType', 'serviceTag'],
|
|
62
|
+
properties: {
|
|
63
|
+
serviceTag: izara.validatorSchema.stringNotEmpty(),
|
|
64
|
+
objectType: izara.validatorSchema.stringNotEmpty(),
|
|
65
|
+
}
|
|
66
|
+
},
|
|
67
|
+
identifiers: {
|
|
68
|
+
type: "object",
|
|
69
|
+
minProperties: 1
|
|
70
|
+
},
|
|
71
|
+
}
|
|
72
|
+
},
|
|
73
|
+
oldReltypeAndDirection: {
|
|
74
|
+
type: 'object',
|
|
75
|
+
required: ['relType', 'relationshipDirection'],
|
|
76
|
+
properties: {
|
|
77
|
+
relType: {
|
|
78
|
+
type: 'object',
|
|
79
|
+
required: ['serviceTag', 'relationshipTag'],
|
|
80
|
+
properties: {
|
|
81
|
+
serviceTag: izara.validatorSchema.stringNotEmpty(),
|
|
82
|
+
relationshipTag: izara.validatorSchema.stringNotEmpty(),
|
|
83
|
+
}
|
|
84
|
+
},
|
|
85
|
+
relationshipProperties: {
|
|
86
|
+
type: 'object',
|
|
87
|
+
},
|
|
88
|
+
relationshipDirection: {
|
|
89
|
+
type: 'string',
|
|
90
|
+
enum: ['from', 'to']
|
|
91
|
+
|
|
92
|
+
},
|
|
93
|
+
}
|
|
94
|
+
},
|
|
95
|
+
newRelType: {
|
|
96
|
+
type: 'object',
|
|
97
|
+
required: ['serviceTag', 'relationshipTag'],
|
|
98
|
+
properties: {
|
|
99
|
+
serviceTag: izara.validatorSchema.stringNotEmpty(),
|
|
100
|
+
relationshipTag: izara.validatorSchema.stringNotEmpty(),
|
|
101
|
+
}
|
|
102
|
+
},
|
|
103
|
+
settings: {
|
|
104
|
+
type: 'object'
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
//(<globalVariable>
|
|
110
|
+
//</globalVariable>)
|
|
111
|
+
|
|
112
|
+
// validate event params in middleware before into main function
|
|
113
|
+
validatorSchema = callingFlowSharedLib.addOptionalCallingFlowToValidatorSchema(validatorSchema);
|
|
114
|
+
middleware.setValidatorSchema(validatorSchema)
|
|
115
|
+
// if need to validate authorizer or additional params , add code to hook tag below
|
|
116
|
+
|
|
117
|
+
//(<afterValidateWith>)
|
|
118
|
+
//(</afterValidateWith>)
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
module.exports.main = middleware.wrap(async (event, context, callback) => {
|
|
122
|
+
event._izContext.logger.debug('Event:', event);
|
|
123
|
+
try {
|
|
124
|
+
// invoke LambdaFunction
|
|
125
|
+
let lambdaFunctionResponse = await <%- functionName %>.<%- functionName %>(
|
|
126
|
+
event._izContext, // correlationId/logger/integrationTestDetail/uniqueRequestId/userId
|
|
127
|
+
{
|
|
128
|
+
firstObject: event.firstObject,
|
|
129
|
+
secondObject: event.secondObject,
|
|
130
|
+
relType: event.relType,
|
|
131
|
+
relationshipDirection: event.relationshipDirection,
|
|
132
|
+
relationshipProperties: event.relationshipProperties,
|
|
133
|
+
},
|
|
134
|
+
callingFlowSharedLib.addCallingFlowToPassOnProperties(event)
|
|
135
|
+
);
|
|
136
|
+
|
|
137
|
+
// return error to client
|
|
138
|
+
if (lambdaFunctionResponse instanceof Error) {
|
|
139
|
+
return (izara.response.failure(lambdaFunctionResponse));
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
// return success to client
|
|
143
|
+
return (izara.response.success(lambdaFunctionResponse));
|
|
144
|
+
|
|
145
|
+
} catch (err) {
|
|
146
|
+
event._izContext.logger.error('Error, <%- functionName %>HdrApi: ', err);
|
|
147
|
+
return (izara.response.failure(err));
|
|
148
|
+
}
|
|
149
|
+
});
|
|
150
|
+
<%_ function firstLetterUpperCase(text) {
|
|
151
|
+
return text.charAt(0).toUpperCase() + text.slice(1)
|
|
152
|
+
} _%>
|
|
153
|
+
<%_ function firstLetterLowerCase(str) {
|
|
154
|
+
return str.charAt(0).toLowerCase() + str.slice(1)
|
|
155
|
+
} _%>
|