@izara_project/izara-market-library-service-schemas 1.0.8 → 1.0.9
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 +2 -2
- package/src/GenerateCodeLibs/src/Consts.js +12 -12
- package/src/GenerateCodeLibs/src/GenerateCodeLibs.js +1 -2
- package/src/MainLibs/src/Utils.js +13 -0
- package/src/TemplateManager/src/FindData/FindDataYaml/data.js +3 -2
- package/src/TemplateManager/src/FindData/FindDataYaml/template.ejs +1 -1
- package/src/TemplateManager/src/FindData/Handler/data.js +1 -6
- package/src/TemplateManager/src/GenerateCode.js +3 -5
- package/src/TemplateManager/src/OutPerActionComplete/OutCreateComplete/functionYaml/data.js +1 -1
- package/src/TemplateManager/src/OutPerActionComplete/OutCreateComplete/handler/data.js +1 -1
- package/src/TemplateManager/src/OutPerActionComplete/OutCreateComplete/handler/template.ejs +11 -11
- package/src/TemplateManager/src/OutPerActionComplete/OutCreateComplete/mainFunction/data.js +1 -1
- package/src/TemplateManager/src/OutPerActionComplete/OutCreateComplete/mainFunction/template.ejs +5 -8
- package/src/TemplateManager/src/OutPerActionComplete/OutDeleteComplete/functionYaml/data.js +1 -1
- package/src/TemplateManager/src/OutPerActionComplete/OutDeleteComplete/handler/data.js +1 -1
- package/src/TemplateManager/src/OutPerActionComplete/OutDeleteComplete/mainFunction/data.js +1 -1
- package/src/TemplateManager/src/OutPerActionComplete/OutDeleteComplete/mainFunction/template.ejs +3 -3
- package/src/TemplateManager/src/OutPerActionComplete/OutUpdateComplete/functionYaml/data.js +1 -1
- package/src/TemplateManager/src/OutPerActionComplete/OutUpdateComplete/handler/data.js +1 -1
- package/src/TemplateManager/src/OutPerActionComplete/OutUpdateComplete/mainFunction/data.js +1 -1
- package/src/TemplateManager/src/PerActionEndpoint/FunctionYaml/HdrApi/data.js +12 -6
- package/src/TemplateManager/src/PerActionEndpoint/FunctionYaml/HdrApi/template.ejs +1 -1
- package/src/TemplateManager/src/PerActionEndpoint/FunctionYaml/HdrDsq/data.js +12 -8
- package/src/TemplateManager/src/PerActionEndpoint/FunctionYaml/HdrDsq/template.ejs +1 -1
- package/src/TemplateManager/src/PerActionEndpoint/FunctionYaml/HdrInv/data.js +9 -11
- package/src/TemplateManager/src/PerActionEndpoint/FunctionYaml/HdrInv/template.ejs +1 -1
- package/src/TemplateManager/src/PerActionEndpoint/FunctionYaml/HdrSqs/data.js +10 -5
- package/src/TemplateManager/src/PerActionEndpoint/FunctionYaml/HdrSqs/template.ejs +1 -1
- package/src/TemplateManager/src/PerActionEndpoint/Handler/HdrApi/data.js +0 -2
- package/src/TemplateManager/src/PerActionEndpoint/Handler/HdrDsq/data.js +1 -2
- package/src/TemplateManager/src/PerActionEndpoint/Handler/HdrDsq/template.ejs +78 -66
- package/src/TemplateManager/src/PerActionEndpoint/Handler/HdrInv/data.js +0 -2
- package/src/TemplateManager/src/PerActionEndpoint/Handler/HdrInv/template.ejs +1 -2
- package/src/TemplateManager/src/PerActionEndpoint/Handler/HdrSqs/data.js +2 -3
- package/src/TemplateManager/src/PerActionEndpoint/Handler/HdrSqs/template.ejs +62 -53
- package/src/TemplateManager/src/ProcessLogical/Handler/data.js +0 -1
- package/src/TemplateManager/src/ProcessLogical/ProcessLogicalYaml/data.js +3 -2
- package/src/TemplateManager/src/ProcessLogical/ProcessLogicalYaml/template.ejs +1 -1
- package/src/TemplateManager/src/ProcessLogicalPagination/FunctionYaml/HdrDsq/data.js +3 -2
- package/src/TemplateManager/src/ProcessLogicalPagination/FunctionYaml/HdrDsq/template.ejs +1 -1
- package/src/TemplateManager/src/ProcessLogicalPagination/FunctionYaml/HdrSqs/data.js +3 -2
- package/src/TemplateManager/src/ProcessLogicalPagination/FunctionYaml/HdrSqs/template.ejs +1 -1
- package/src/TemplateManager/src/ProcessLogicalPagination/Handler/HdrDsq/data.js +1 -3
- package/src/TemplateManager/src/ProcessLogicalPagination/Handler/HdrSqs/data.js +1 -3
- package/src/TemplateManager/src/RelationshipPerAction/CreateRelationship/createRelationship/functionYaml/HdrApi/data.js +3 -2
- package/src/TemplateManager/src/RelationshipPerAction/CreateRelationship/createRelationship/functionYaml/HdrApi/template.ejs +1 -1
- package/src/TemplateManager/src/RelationshipPerAction/CreateRelationship/createRelationship/functionYaml/HdrDsq/data.js +3 -2
- package/src/TemplateManager/src/RelationshipPerAction/CreateRelationship/createRelationship/functionYaml/HdrDsq/template.ejs +1 -1
- package/src/TemplateManager/src/RelationshipPerAction/CreateRelationship/createRelationship/functionYaml/HdrInv/data.js +3 -2
- package/src/TemplateManager/src/RelationshipPerAction/CreateRelationship/createRelationship/functionYaml/HdrInv/template.ejs +1 -1
- package/src/TemplateManager/src/RelationshipPerAction/CreateRelationship/createRelationship/functionYaml/HdrSqs/data.js +3 -2
- package/src/TemplateManager/src/RelationshipPerAction/CreateRelationship/createRelationship/functionYaml/HdrSqs/template.ejs +1 -1
- package/src/TemplateManager/src/RelationshipPerAction/CreateRelationship/createRelationship/perAction/HdrApi/data.js +0 -2
- package/src/TemplateManager/src/RelationshipPerAction/CreateRelationship/createRelationship/perAction/HdrDsq/data.js +0 -2
- package/src/TemplateManager/src/RelationshipPerAction/CreateRelationship/createRelationship/perAction/HdrInv/data.js +0 -2
- package/src/TemplateManager/src/RelationshipPerAction/CreateRelationship/createRelationship/perAction/HdrSqs/data.js +0 -2
- package/src/TemplateManager/src/RelationshipPerAction/CreateRelationship/createRelationshipComplete/functionYaml/data.js +3 -2
- package/src/TemplateManager/src/RelationshipPerAction/CreateRelationship/createRelationshipComplete/functionYaml/template.ejs +1 -1
- package/src/TemplateManager/src/RelationshipPerAction/CreateRelationship/createRelationshipComplete/handler/HdrSqs/data.js +0 -2
- package/src/TemplateManager/src/RelationshipPerAction/DeleteRelationship/DeleteRelationship/functionYaml/HdrApi/data.js +3 -2
- package/src/TemplateManager/src/RelationshipPerAction/DeleteRelationship/DeleteRelationship/functionYaml/HdrApi/template.ejs +1 -1
- package/src/TemplateManager/src/RelationshipPerAction/DeleteRelationship/DeleteRelationship/functionYaml/HdrDsq/data.js +3 -2
- package/src/TemplateManager/src/RelationshipPerAction/DeleteRelationship/DeleteRelationship/functionYaml/HdrDsq/template.ejs +1 -1
- package/src/TemplateManager/src/RelationshipPerAction/DeleteRelationship/DeleteRelationship/functionYaml/HdrInv/data.js +2 -1
- package/src/TemplateManager/src/RelationshipPerAction/DeleteRelationship/DeleteRelationship/functionYaml/HdrInv/template.ejs +1 -1
- package/src/TemplateManager/src/RelationshipPerAction/DeleteRelationship/DeleteRelationship/functionYaml/HdrSqs/data.js +3 -2
- package/src/TemplateManager/src/RelationshipPerAction/DeleteRelationship/DeleteRelationship/functionYaml/HdrSqs/template.ejs +1 -1
- package/src/TemplateManager/src/RelationshipPerAction/DeleteRelationship/DeleteRelationship/perAction/HdrApi/data.js +0 -2
- package/src/TemplateManager/src/RelationshipPerAction/DeleteRelationship/DeleteRelationship/perAction/HdrDsq/data.js +0 -2
- package/src/TemplateManager/src/RelationshipPerAction/DeleteRelationship/DeleteRelationship/perAction/HdrInv/data.js +0 -2
- package/src/TemplateManager/src/RelationshipPerAction/DeleteRelationship/DeleteRelationship/perAction/HdrSqs/data.js +0 -2
- package/src/TemplateManager/src/RelationshipPerAction/DeleteRelationship/DeleteRelationshipComplete/functionYaml/data.js +3 -2
- package/src/TemplateManager/src/RelationshipPerAction/DeleteRelationship/DeleteRelationshipComplete/functionYaml/template.ejs +1 -1
- package/src/TemplateManager/src/RelationshipPerAction/DeleteRelationship/DeleteRelationshipComplete/handler/HdrSqs/data.js +0 -2
- package/src/TemplateManager/src/RelationshipPerAction/UpdateRelationshipSchema/updateRalationshipComplete/functionYaml/data.js +3 -2
- package/src/TemplateManager/src/RelationshipPerAction/UpdateRelationshipSchema/updateRalationshipComplete/functionYaml/template.ejs +1 -1
- package/src/TemplateManager/src/RelationshipPerAction/UpdateRelationshipSchema/updateRalationshipComplete/handler/HdrSqs/data.js +0 -2
- package/src/TemplateManager/src/RelationshipPerAction/UpdateRelationshipSchema/updateRelationship/functionYaml/HdrApi/data.js +3 -2
- package/src/TemplateManager/src/RelationshipPerAction/UpdateRelationshipSchema/updateRelationship/functionYaml/HdrApi/template.ejs +1 -1
- package/src/TemplateManager/src/RelationshipPerAction/UpdateRelationshipSchema/updateRelationship/functionYaml/HdrDsq/data.js +3 -2
- package/src/TemplateManager/src/RelationshipPerAction/UpdateRelationshipSchema/updateRelationship/functionYaml/HdrDsq/template.ejs +1 -1
- package/src/TemplateManager/src/RelationshipPerAction/UpdateRelationshipSchema/updateRelationship/functionYaml/HdrInv/data.js +4 -2
- package/src/TemplateManager/src/RelationshipPerAction/UpdateRelationshipSchema/updateRelationship/functionYaml/HdrInv/template.ejs +1 -1
- package/src/TemplateManager/src/RelationshipPerAction/UpdateRelationshipSchema/updateRelationship/functionYaml/HdrSqs/data.js +3 -2
- package/src/TemplateManager/src/RelationshipPerAction/UpdateRelationshipSchema/updateRelationship/functionYaml/HdrSqs/template.ejs +1 -1
- package/src/TemplateManager/src/RelationshipPerAction/UpdateRelationshipSchema/updateRelationship/perAction/HdrApi/data.js +0 -2
- package/src/TemplateManager/src/RelationshipPerAction/UpdateRelationshipSchema/updateRelationship/perAction/HdrDsq/data.js +0 -2
- package/src/TemplateManager/src/RelationshipPerAction/UpdateRelationshipSchema/updateRelationship/perAction/HdrInv/data.js +0 -2
- package/src/TemplateManager/src/RelationshipPerAction/UpdateRelationshipSchema/updateRelationship/perAction/HdrSqs/data.js +0 -2
- package/src/TemplateManager/src/ResourceYaml/dynamodb/mainResourcePerObjectSchemaData.js +3 -3
- package/src/TemplateManager/src/ResourceYaml/sns-in-sqs/defaultSnsInSqsForFindDataAndProcessLogical.js +6 -6
- package/src/TemplateManager/src/ResourceYaml/sns-out/defaultSnsOutForFindDataAndProcessLogical.js +2 -2
- package/src/TemplateManager/src/TranslateIdReq/ProcessingTranslateIds/functionYaml/data.js +3 -2
- package/src/TemplateManager/src/TranslateIdReq/ProcessingTranslateIds/functionYaml/template.ejs +1 -1
- package/src/TemplateManager/src/TranslateIdReq/ProcessingTranslateIds/handler/dataHdrDsq.js +0 -2
- package/src/TemplateManager/src/TranslateIdReq/TranslateIds/functionYaml/HdrDsq/data.js +4 -3
- package/src/TemplateManager/src/TranslateIdReq/TranslateIds/functionYaml/HdrDsq/template.ejs +30 -0
- package/src/TemplateManager/src/TranslateIdReq/TranslateIds/functionYaml/HdrSqs/data.js +4 -3
- package/src/TemplateManager/src/TranslateIdReq/TranslateIds/functionYaml/HdrSqs/template.ejs +30 -0
- package/src/TemplateManager/src/TranslateIdReq/TranslateIds/handler/HdrDsq/data.js +0 -2
- package/src/TemplateManager/src/TranslateIdReq/TranslateIds/handler/HdrSqs/data.js +0 -2
- package/src/TemplateManager/src/externalService/FunctionNameConfig/template.ejs +13 -2
- package/src/TemplateManager/src/externalService/LambdaRole/data.js +38 -38
- package/src/TemplateManager/src/externalService/SnsTopicSubscriotions/template.ejs +19 -0
- package/src/TemplateManager/src/libs/Consts.js +20 -17
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@izara_project/izara-market-library-service-schemas",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.9",
|
|
4
4
|
"description": "Schemas for Izara Market project",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"dependencies": {
|
|
23
23
|
"@izara_project/izara-core-library-core": "^1.0.13",
|
|
24
24
|
"@izara_project/izara-core-library-logger": "^1.0.5",
|
|
25
|
-
"@izara_project/izara-core-library-service-schemas": "^1.0.
|
|
25
|
+
"@izara_project/izara-core-library-service-schemas": "^1.0.25",
|
|
26
26
|
"@izara_project/izara-shared": "^1.0.96",
|
|
27
27
|
"ejs": "^3.1.10",
|
|
28
28
|
"js-beautify": "^1.15.1",
|
|
@@ -43,18 +43,18 @@ const TOPIC_NAME_GRAPH_HANDLER = {
|
|
|
43
43
|
}
|
|
44
44
|
|
|
45
45
|
const TOPIC_NAME_GENERATE_CODE = {
|
|
46
|
-
updateRelComplete: "
|
|
47
|
-
createRelComplete: "
|
|
48
|
-
deleteRelComplete: "
|
|
49
|
-
outUpdateRelComplete: "
|
|
50
|
-
outCreateRelComplete: "
|
|
51
|
-
outDeleteRelComplete: "
|
|
52
|
-
updateNodeComplete: "
|
|
53
|
-
outUpdateNodeComplete: "
|
|
54
|
-
createNodeComplete: "
|
|
55
|
-
outCreateNodeComplete: "
|
|
56
|
-
deleteNodeComplete: "
|
|
57
|
-
outDeleteNodeComplete: "
|
|
46
|
+
updateRelComplete: "UpdateRelComp",
|
|
47
|
+
createRelComplete: "CreateRelComp",
|
|
48
|
+
deleteRelComplete: "DeleteRelComp",
|
|
49
|
+
outUpdateRelComplete: "OutUpdateRelComp",
|
|
50
|
+
outCreateRelComplete: "OutCreateRelComp",
|
|
51
|
+
outDeleteRelComplete: "OutDeleteRelComp",
|
|
52
|
+
updateNodeComplete: "UpdateNodeComp",
|
|
53
|
+
outUpdateNodeComplete: "OutUpdateNodeComp",
|
|
54
|
+
createNodeComplete: "CreateObjectComp",
|
|
55
|
+
outCreateNodeComplete: "OutCreateObjectComp",
|
|
56
|
+
deleteNodeComplete: "DeleteNodeComp",
|
|
57
|
+
outDeleteNodeComplete: "OutDeleteNodeComp"
|
|
58
58
|
}
|
|
59
59
|
|
|
60
60
|
const GRAPH_HANDLER_SERVICE_NAME = {
|
|
@@ -48,7 +48,6 @@ const {
|
|
|
48
48
|
const nodeLabelRegexPattern = "^[a-zA-Z0-9_-]+(?:\:[a-zA-Z0-9_-]+)?$"
|
|
49
49
|
|
|
50
50
|
|
|
51
|
-
|
|
52
51
|
const schemaFunctionPerAction = {
|
|
53
52
|
[consts.ACTIONS.create]: validatorSchema.generateValidatorSchemaForCreate,
|
|
54
53
|
[consts.ACTIONS.update]: validatorSchema.generateValidatorSchemaForUpdate,
|
|
@@ -127,7 +126,7 @@ async function validateSchemaPerRecord(
|
|
|
127
126
|
throw new Error(`Not found function for generateValidatorSchema or function for explodeData of action:${action}`);
|
|
128
127
|
}
|
|
129
128
|
|
|
130
|
-
const objectSchema = await getObjectSchema.
|
|
129
|
+
const objectSchema = await getObjectSchema.getObjSchemaS3WithHierarchy(record._izContext, objType);
|
|
131
130
|
|
|
132
131
|
const generateValidatorFunction = schemaFunctionPerAction[action];
|
|
133
132
|
const explodeDataFunction = explodeDataPerAction[action]
|
|
@@ -17,6 +17,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
17
17
|
|
|
18
18
|
'use strict';
|
|
19
19
|
|
|
20
|
+
const lodash = require("lodash")
|
|
20
21
|
|
|
21
22
|
module.exports.firstLetterUpperCase = (text) => {
|
|
22
23
|
return text.charAt(0).toUpperCase() + text.slice(1)
|
|
@@ -34,4 +35,16 @@ module.exports.checkOverWriteGenerateMainFunction = (objectSchema, action) => {
|
|
|
34
35
|
overWriteStatus = false
|
|
35
36
|
}
|
|
36
37
|
return overWriteStatus
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
module.exports.renameObjectType = (objectSchema, srcPath) => {
|
|
41
|
+
const shortNamePath = path.join(srcPath, "./schemas/ShortNameObjectType.js");
|
|
42
|
+
const shortName = fs.existsSync(shortNamePath) ? require(shortNamePath) : {};
|
|
43
|
+
|
|
44
|
+
let newObjectSchema = lodash.cloneDeep(objectSchema)
|
|
45
|
+
|
|
46
|
+
if (shortName[objectSchema.objectType]) {
|
|
47
|
+
newObjectSchema.shortNameObjectType = shortName[objectSchema.objectType]
|
|
48
|
+
}
|
|
49
|
+
return newObjectSchema
|
|
37
50
|
}
|
|
@@ -23,7 +23,7 @@ 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
25
|
const { firstLetterLowerCase: lowerCase, firstLetterUpperCase: upperCase } = require("../../../../MainLibs/src/Utils")
|
|
26
|
-
const { createIamRole, resourceNames, RESOURCE_CLASSES, DEFAULT_LAMBDA_ROLE_PER_ACTION, SQS_RESOURCE, SOURCE_PATH, SAVE_FILE_NAME, FUNCTION_NAME } = require("../../libs/Consts");
|
|
26
|
+
const { createIamRole, resourceNames, RESOURCE_CLASSES, DEFAULT_LAMBDA_ROLE_PER_ACTION, SQS_RESOURCE, SOURCE_PATH, SAVE_FILE_NAME, FUNCTION_NAME, shortNameHandler } = require("../../libs/Consts");
|
|
27
27
|
|
|
28
28
|
const serviceSchemas = require('@izara_project/izara-core-library-service-schemas');
|
|
29
29
|
const serviceConfig = serviceSchemas.serviceConfig;
|
|
@@ -174,7 +174,8 @@ async function data(_izContext, objectSchemas, srcPath) {
|
|
|
174
174
|
functionName: functionName,
|
|
175
175
|
resourceLocation: SOURCE_PATH.resourceLocationFindData,
|
|
176
176
|
handlerType: HANDLER.hdrSqs,
|
|
177
|
-
additionalResourcePermission
|
|
177
|
+
additionalResourcePermission,
|
|
178
|
+
functionNameConfig: upperCase(functionName) + upperCase(shortNameHandler(HANDLER.hdrSqs))
|
|
178
179
|
},
|
|
179
180
|
setting: {
|
|
180
181
|
savePath: path.join(srcPath, SOURCE_PATH.appYaml),
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<%_ const join = require('path').join; _%>
|
|
2
|
-
<%-
|
|
2
|
+
<%- firstLetterUpperCase(functionNameConfig) %>:
|
|
3
3
|
handler: <%- join(resourceLocation, `${functionName}_${firstLetterUpperCase(handlerType)}.main`)%>
|
|
4
4
|
name: ${self:custom.iz_resourcePrefix}<%- functionName %><%- firstLetterUpperCase(handlerType) %>
|
|
5
5
|
events:
|
|
@@ -31,15 +31,10 @@ const { firstLetterLowerCase: lowerCase, firstLetterUpperCase: upperCase } = req
|
|
|
31
31
|
* @return {{ templatePath, templateData, setting } }
|
|
32
32
|
*/
|
|
33
33
|
function data(_izContext, srcPath) {
|
|
34
|
-
let functionName = FUNCTION_NAME.findData
|
|
35
|
-
let handler = HANDLER.hdrSqs
|
|
36
|
-
let functionNameConfig = upperCase(functionName) + upperCase(handler)
|
|
37
34
|
|
|
38
35
|
return {
|
|
39
36
|
templatePath: templatePath,
|
|
40
|
-
templateData: {
|
|
41
|
-
functionNameConfig
|
|
42
|
-
},
|
|
37
|
+
templateData: {},
|
|
43
38
|
setting: {
|
|
44
39
|
savePath: path.join(srcPath, SOURCE_PATH.findData),
|
|
45
40
|
saveFileName: upperCase(FUNCTION_NAME.findData) + "_" + upperCase(HANDLER.hdrSqs),
|
|
@@ -120,14 +120,12 @@ const createUpdateRelationshipSchemaCompleteMainFunction = require('./Relationsh
|
|
|
120
120
|
const createRelationshipSchemaMain = require('./RelationshipPerAction/CreateRelationship/createRelationship/mainFunction/data');
|
|
121
121
|
|
|
122
122
|
// createRelationsihp Handler
|
|
123
|
-
// const createCreateRelationshipHdrApi = require('./CreateRelationship/createrelationship/perAction/HdrApi/data');
|
|
124
123
|
const createCreateRelationshipHdrDsq = require('./RelationshipPerAction/CreateRelationship/createRelationship/perAction/HdrDsq/data');
|
|
125
124
|
const createCreateRelationshipHdrInv = require('./RelationshipPerAction/CreateRelationship/createRelationship/perAction/HdrInv/data');
|
|
126
125
|
const createCreateRelationshipHdrSqs = require('./RelationshipPerAction/CreateRelationship/createRelationship/perAction/HdrSqs/data');
|
|
127
126
|
const createCreateRelationshipHdrApi = require('./RelationshipPerAction/CreateRelationship/createRelationship/perAction/HdrApi/data');
|
|
128
127
|
|
|
129
128
|
// createRelationshipFunctionYaml
|
|
130
|
-
// const createCreateRelationshipFunctionYamlHdrApi = require('./CreateRelationship/createrelationship/functionYaml/HdrApi/data');
|
|
131
129
|
const createCreateRelationshipFunctionYamlHdrInv = require('./RelationshipPerAction/CreateRelationship/createRelationship/functionYaml/HdrInv/data');
|
|
132
130
|
const createCreateRelationshipFunctionYamlHdrDsq = require('./RelationshipPerAction/CreateRelationship/createRelationship/functionYaml/HdrDsq/data');
|
|
133
131
|
const createCreateRelationshipFunctionYamlHdrSqs = require('./RelationshipPerAction/CreateRelationship/createRelationship/functionYaml/HdrSqs/data');
|
|
@@ -502,11 +500,11 @@ async function generateCodeWithTemplate(_izContext, objSchemaPath) {
|
|
|
502
500
|
...deleteRelationshipCompleteData
|
|
503
501
|
)
|
|
504
502
|
}
|
|
505
|
-
// console.log("createSourceParams in GenerateCode", createSourceParams)
|
|
503
|
+
// console.log("createSourceParams templatePath in GenerateCode", createSourceParams.templatePath)
|
|
504
|
+
|
|
506
505
|
const createFunctionNameConfig = functionNameConfigFile(_izContext, createSourceParams, saveFilePath);
|
|
507
506
|
createSourceParams = createSourceParams.concat(createFunctionNameConfig);
|
|
508
507
|
|
|
509
|
-
// console.log("createSourceParams", createSourceParams)
|
|
510
508
|
// delete file .yml before start to prevent confilct of data
|
|
511
509
|
for (let folderPathToEmpty of Object.keys(GENERATECODE_SOURCE_PATH)) {
|
|
512
510
|
await deleteFileInDir(GENERATECODE_SOURCE_PATH[folderPathToEmpty]);
|
|
@@ -515,8 +513,8 @@ async function generateCodeWithTemplate(_izContext, objSchemaPath) {
|
|
|
515
513
|
// console.log(""createSourceParams": ", createSourceParams)
|
|
516
514
|
// start create source
|
|
517
515
|
for (let { templatePath, templateData, setting } of createSourceParams) {
|
|
516
|
+
// console.log("setting.saveFileName in GenerateCode", setting.saveFileName);
|
|
518
517
|
// console.log("templatePath in GenerateCode", templatePath);
|
|
519
|
-
// console.log("setting.savePath in GenerateCode", setting.savePath);
|
|
520
518
|
|
|
521
519
|
await createSource(
|
|
522
520
|
readFileSync(templatePath, 'utf8'),
|
|
@@ -70,7 +70,7 @@ function createFunctionYamlOutUpdateComplete(_izContext, srcPath) {
|
|
|
70
70
|
functionName,
|
|
71
71
|
handlerType,
|
|
72
72
|
additionalResourcePermission,
|
|
73
|
-
resourceLocation: SOURCE_PATH.
|
|
73
|
+
resourceLocation: SOURCE_PATH.resourceLocationOutPerActionComplete
|
|
74
74
|
},
|
|
75
75
|
setting: {
|
|
76
76
|
savePath: path.join(srcPath, SOURCE_PATH.appYaml),
|
|
@@ -50,7 +50,7 @@ function createParamForCreateSource(srcPath) {
|
|
|
50
50
|
functionNameConfig
|
|
51
51
|
},
|
|
52
52
|
setting: {
|
|
53
|
-
savePath: path.join(srcPath, SOURCE_PATH.
|
|
53
|
+
savePath: path.join(srcPath, SOURCE_PATH.outPerActionComplete),
|
|
54
54
|
saveFileName: `${upperCase(functionName)}_${upperCase(HANDLER.hdrSqs)}`,
|
|
55
55
|
fileExtension: ".js",
|
|
56
56
|
isAppend: false
|
|
@@ -26,7 +26,7 @@ const izaraShared = require('@izara_project/izara-shared');
|
|
|
26
26
|
const recordHandlerSharedLib = izaraShared.recordHandlerSharedLib
|
|
27
27
|
const callingFlowSharedLib = izaraShared.callingFlowSharedLib;
|
|
28
28
|
|
|
29
|
-
const
|
|
29
|
+
const createObjectComplete = require('./CreateObjectComplete_Main');
|
|
30
30
|
const Logger = require('@izara_project/izara-core-library-logger');
|
|
31
31
|
// validate event properties in body.Message of sqs event
|
|
32
32
|
middleware.setValidatorSchema(recordHandlerSharedLib.baseValidatorSchema());
|
|
@@ -36,7 +36,8 @@ let perRecordsValidatorSchema = {
|
|
|
36
36
|
required: [
|
|
37
37
|
'returnValue',
|
|
38
38
|
'status',
|
|
39
|
-
'errorFounds'
|
|
39
|
+
'errorFounds',
|
|
40
|
+
'graphServiceTag'
|
|
40
41
|
],
|
|
41
42
|
properties: {
|
|
42
43
|
returnValue: {
|
|
@@ -48,6 +49,9 @@ let perRecordsValidatorSchema = {
|
|
|
48
49
|
errorFounds: {
|
|
49
50
|
type: 'array',
|
|
50
51
|
default: []
|
|
52
|
+
},
|
|
53
|
+
graphServiceTag: {
|
|
54
|
+
type: 'string',
|
|
51
55
|
}
|
|
52
56
|
}
|
|
53
57
|
};
|
|
@@ -82,7 +86,7 @@ module.exports.main = middleware.wrap(async (event, context, callback) => {
|
|
|
82
86
|
//validate message (and MessageAttributes)
|
|
83
87
|
await recordHandlerSharedLib.validateRecord(
|
|
84
88
|
record, // one record will send to mainFunction
|
|
85
|
-
"
|
|
89
|
+
"CreateObjectComplete", // queue name that need to retry or send to dlq
|
|
86
90
|
perRecordsValidatorSchema, // schema for record.Message
|
|
87
91
|
// messageAttributeValidatorSchema // ----- for msgAttr default is null -> do not send this parameter if not want to validate msgAtt
|
|
88
92
|
);
|
|
@@ -91,7 +95,7 @@ module.exports.main = middleware.wrap(async (event, context, callback) => {
|
|
|
91
95
|
passOnProperties.push(record.body.Message.returnValue)
|
|
92
96
|
passOnProperties.push(record.body.Message.status)
|
|
93
97
|
passOnProperties.push(record.body.Message.errorFounds)
|
|
94
|
-
passOnProperties.push(record.body.Message.
|
|
98
|
+
passOnProperties.push(record.body.Message.graphServiceTag)
|
|
95
99
|
passOnProperties.push(callingFlowSharedLib.addPassBackPropertiesToPassOnProperties(record.body.Message)) // is Ok PassBackProperties
|
|
96
100
|
// passOnProperties.push(callingFlowSharedLib.addCallingFlowToPassOnProperties(record.body.Message)) // is Ok callinfFlow
|
|
97
101
|
record._izContext.logger.debug('passOnProperties in handler', passOnProperties);
|
|
@@ -99,8 +103,8 @@ module.exports.main = middleware.wrap(async (event, context, callback) => {
|
|
|
99
103
|
// call recordHandlerSharedLib.recordHandler with 3 parameters and return promise(resolve)
|
|
100
104
|
let recordPromise = recordHandlerSharedLib.recordHandler(
|
|
101
105
|
record, // one record will send to mainFunction
|
|
102
|
-
|
|
103
|
-
"
|
|
106
|
+
createObjectComplete.createObjectComplete, // mainFunction that need to invoke.
|
|
107
|
+
"CreateObjectComplete", // queue name that need to retry or send to dlq
|
|
104
108
|
passOnProperties, // all parameters that mainFunction needed.
|
|
105
109
|
);
|
|
106
110
|
record._izContext.logger.debug('after recordPromise in handler');
|
|
@@ -123,8 +127,4 @@ module.exports.main = middleware.wrap(async (event, context, callback) => {
|
|
|
123
127
|
Logger.error('Unhandled Error, updateNodeCompleteHdrSqs: ', err);
|
|
124
128
|
throw (err);
|
|
125
129
|
}
|
|
126
|
-
});
|
|
127
|
-
|
|
128
|
-
<%_ function firstLetterUpperCase(text){
|
|
129
|
-
return text.charAt(0).toUpperCase()+ text.slice(1)
|
|
130
|
-
} _%>
|
|
130
|
+
});
|
|
@@ -42,7 +42,7 @@ function createMainFunctionCreateComplete(_izContext, srcPath) {
|
|
|
42
42
|
templatePath: templatePath,
|
|
43
43
|
templateData: {},
|
|
44
44
|
setting: {
|
|
45
|
-
savePath: path.join(srcPath, SOURCE_PATH.
|
|
45
|
+
savePath: path.join(srcPath, SOURCE_PATH.outPerActionComplete),
|
|
46
46
|
saveFileName: `${upperCase(FUNCTION_NAME.createObjectComplete)}_Main`,
|
|
47
47
|
fileExtension: ".js",
|
|
48
48
|
isAppend: false
|
package/src/TemplateManager/src/OutPerActionComplete/OutCreateComplete/mainFunction/template.ejs
CHANGED
|
@@ -35,9 +35,8 @@ const PREFIX = {
|
|
|
35
35
|
* @param {*} returnValue
|
|
36
36
|
* @param {*} status
|
|
37
37
|
* @param {*} errorsFounds
|
|
38
|
-
* @param {*}
|
|
38
|
+
* @param {*} graphServiceTag
|
|
39
39
|
* @param {*} passBackProperties
|
|
40
|
-
* @param {*} callingFlowConfig
|
|
41
40
|
returnValue = {
|
|
42
41
|
queryResult: returnCreateNode,
|
|
43
42
|
objType,
|
|
@@ -51,18 +50,16 @@ module.exports.createObjectComplete = async (
|
|
|
51
50
|
returnValue,
|
|
52
51
|
status,
|
|
53
52
|
errorsFound,
|
|
54
|
-
|
|
53
|
+
graphServiceTag,
|
|
55
54
|
passBackProperties,
|
|
56
|
-
callingFlowConfig
|
|
57
55
|
) => {
|
|
58
56
|
try {
|
|
59
57
|
_izContext.logger.debug("function createObjectComplete:", {
|
|
60
58
|
returnValue,
|
|
61
59
|
status,
|
|
62
60
|
errorsFound,
|
|
63
|
-
|
|
61
|
+
graphServiceTag,
|
|
64
62
|
passBackProperties,
|
|
65
|
-
callingFlowConfig
|
|
66
63
|
});
|
|
67
64
|
|
|
68
65
|
let errorFounds = [];
|
|
@@ -91,7 +88,7 @@ module.exports.createObjectComplete = async (
|
|
|
91
88
|
if (status === "complete" && errorsFound.length > 0) {
|
|
92
89
|
errorFounds.push("[Invalid] status is commplete should be not have errorsFound");
|
|
93
90
|
};
|
|
94
|
-
if (
|
|
91
|
+
if (graphServiceTag == null) {
|
|
95
92
|
errorFounds.push("[Invalid] graphServerTag is not empty string");
|
|
96
93
|
};
|
|
97
94
|
|
|
@@ -103,7 +100,7 @@ module.exports.createObjectComplete = async (
|
|
|
103
100
|
let awaitingStepId = await asyncFlowSharedLib.createAwaitingStepId((hash(
|
|
104
101
|
{
|
|
105
102
|
objType: returnValue.objType,
|
|
106
|
-
|
|
103
|
+
graphServiceTag: graphServiceTag,
|
|
107
104
|
identifiers: returnValue.objInstanceFull.identifiers
|
|
108
105
|
})),
|
|
109
106
|
PREFIX.CREATE_OBJECT_ASYNC
|
|
@@ -67,7 +67,7 @@ function createFunctionYamlOutUpdateComplete(_izContext, srcPath) {
|
|
|
67
67
|
functionName,
|
|
68
68
|
handlerType,
|
|
69
69
|
additionalResourcePermission,
|
|
70
|
-
resourceLocation: SOURCE_PATH.
|
|
70
|
+
resourceLocation: SOURCE_PATH.resourceLocationOutPerActionComplete
|
|
71
71
|
},
|
|
72
72
|
setting: {
|
|
73
73
|
savePath: path.join(srcPath, SOURCE_PATH.appYaml),
|
|
@@ -50,7 +50,7 @@ function createParamForCreateSource(srcPath) {
|
|
|
50
50
|
functionNameConfig
|
|
51
51
|
},
|
|
52
52
|
setting: {
|
|
53
|
-
savePath: path.join(srcPath, SOURCE_PATH.
|
|
53
|
+
savePath: path.join(srcPath, SOURCE_PATH.outPerActionComplete),
|
|
54
54
|
saveFileName: `${upperCase(functionName)}_${upperCase(HANDLER.hdrSqs)}`,
|
|
55
55
|
fileExtension: ".js",
|
|
56
56
|
isAppend: false
|
|
@@ -42,7 +42,7 @@ function createMainFunctionUpdateComplete(_izContext, srcPath) {
|
|
|
42
42
|
templatePath: templatePath,
|
|
43
43
|
templateData: {},
|
|
44
44
|
setting: {
|
|
45
|
-
savePath: path.join(srcPath, SOURCE_PATH.
|
|
45
|
+
savePath: path.join(srcPath, SOURCE_PATH.outPerActionComplete),
|
|
46
46
|
saveFileName: `${upperCase(FUNCTION_NAME.deleteNodeComplete)}_Main`,
|
|
47
47
|
fileExtension: ".js",
|
|
48
48
|
isAppend: false
|
package/src/TemplateManager/src/OutPerActionComplete/OutDeleteComplete/mainFunction/template.ejs
CHANGED
|
@@ -52,7 +52,7 @@ module.exports.deleteNodeComplete = async (
|
|
|
52
52
|
passBackProperties: passBackProperties
|
|
53
53
|
});
|
|
54
54
|
|
|
55
|
-
let
|
|
55
|
+
let deleteNodeComplete = {
|
|
56
56
|
objType: {
|
|
57
57
|
objectType: returnValue.objType.objectType,
|
|
58
58
|
serviceTag: returnValue.objType.serviceTag
|
|
@@ -65,14 +65,14 @@ module.exports.deleteNodeComplete = async (
|
|
|
65
65
|
errorsFound: errorsFound
|
|
66
66
|
};
|
|
67
67
|
|
|
68
|
-
|
|
68
|
+
deleteNodeComplete = callingFlowSharedLib.addParentPassBackPropertiesToSnsResponseMessageObject(passBackProperties, updateCompleteMsg);
|
|
69
69
|
_izContext.logger.debug("after addCallingFlow to SnsResponseMessageObject", updateCompleteMsg);
|
|
70
70
|
|
|
71
71
|
let messageAttributes = callingFlowSharedLib.addParentPassBackCallingFlowToSnsResponseMessageAttributes(passBackProperties, {});
|
|
72
72
|
_izContext.logger.debug("after addCallingFlow to SnsResponseMessageAttributes", updateCompleteMsg);
|
|
73
73
|
|
|
74
74
|
let sendMessageToOutUpdateNodeComplete = {
|
|
75
|
-
Message: JSON.stringify(
|
|
75
|
+
Message: JSON.stringify(deleteNodeComplete),
|
|
76
76
|
MessageAttributes: sns.createStringMessageAttributes(_izContext, messageAttributes),
|
|
77
77
|
TopicArn: await snsSharedLib.snsTopicArn(_izContext, TOPIC_NAME_GENERATE_CODE.outUpdateNodeComplete)
|
|
78
78
|
};
|
|
@@ -69,7 +69,7 @@ function createFunctionYamlOutUpdateComplete(_izContext, srcPath) {
|
|
|
69
69
|
functionName,
|
|
70
70
|
handlerType,
|
|
71
71
|
additionalResourcePermission,
|
|
72
|
-
resourceLocation: SOURCE_PATH.
|
|
72
|
+
resourceLocation: SOURCE_PATH.resourceLocationOutPerActionComplete
|
|
73
73
|
},
|
|
74
74
|
setting: {
|
|
75
75
|
savePath: path.join(srcPath, SOURCE_PATH.appYaml),
|
|
@@ -50,7 +50,7 @@ function createParamForCreateSource(srcPath) {
|
|
|
50
50
|
functionNameConfig
|
|
51
51
|
},
|
|
52
52
|
setting: {
|
|
53
|
-
savePath: path.join(srcPath, SOURCE_PATH.
|
|
53
|
+
savePath: path.join(srcPath, SOURCE_PATH.outPerActionComplete),
|
|
54
54
|
saveFileName: `${upperCase(functionName)}_${upperCase(HANDLER.hdrSqs)}`,
|
|
55
55
|
fileExtension: ".js",
|
|
56
56
|
isAppend: false
|
|
@@ -42,7 +42,7 @@ function createMainFunctionUpdateComplete(_izContext, srcPath) {
|
|
|
42
42
|
templatePath: templatePath,
|
|
43
43
|
templateData: {},
|
|
44
44
|
setting: {
|
|
45
|
-
savePath: path.join(srcPath, SOURCE_PATH.
|
|
45
|
+
savePath: path.join(srcPath, SOURCE_PATH.outPerActionComplete),
|
|
46
46
|
saveFileName: `${upperCase(FUNCTION_NAME.updateNodeComplete)}_Main`,
|
|
47
47
|
fileExtension: ".js",
|
|
48
48
|
isAppend: false
|
|
@@ -21,8 +21,8 @@ const fs = require('fs');
|
|
|
21
21
|
|
|
22
22
|
const { ACTIONS, HANDLER, STORAGE_TYPES } = require('@izara_project/izara-core-library-service-schemas/src/Consts')
|
|
23
23
|
|
|
24
|
-
const { firstLetterLowerCase: lowerCase, firstLetterUpperCase: upperCase } = require("../../../../../MainLibs/src/Utils")
|
|
25
|
-
const { DEFAULT_HANDLER_PER_ACTION, createIamRole, resourceNames, RESOURCE_CLASSES, DEFAULT_LAMBDA_ROLE_PER_ACTION, SOURCE_PATH, SAVE_FILE_NAME, DYNAMO_RESOURCE, SNS_RESOURCE, FUNCTION_NAME, defaultIamRolePerAction, awaitingMultipleStepsRole } = require("../../../libs/Consts");
|
|
24
|
+
const { firstLetterLowerCase: lowerCase, firstLetterUpperCase: upperCase, renameObjectType } = require("../../../../../MainLibs/src/Utils")
|
|
25
|
+
const { DEFAULT_HANDLER_PER_ACTION, createIamRole, resourceNames, RESOURCE_CLASSES, DEFAULT_LAMBDA_ROLE_PER_ACTION, SOURCE_PATH, SAVE_FILE_NAME, DYNAMO_RESOURCE, SNS_RESOURCE, FUNCTION_NAME, defaultIamRolePerAction, awaitingMultipleStepsRole, shortNameHandler } = require("../../../libs/Consts");
|
|
26
26
|
|
|
27
27
|
const templatePath = path.join(__dirname, "./template.ejs")
|
|
28
28
|
|
|
@@ -36,12 +36,14 @@ const templatePath = path.join(__dirname, "./template.ejs")
|
|
|
36
36
|
function data(_izContext, objectSchema, srcPath) {
|
|
37
37
|
let createSourceArray = [];
|
|
38
38
|
|
|
39
|
+
let newObjectSchema = renameObjectType(objectSchema, srcPath);
|
|
40
|
+
|
|
39
41
|
for (const action of Object.values(ACTIONS)) {
|
|
40
42
|
if (objectSchema.overWriteHandlers?.[action]) {
|
|
41
43
|
// if have overWriteHander of action check hdrApi inside
|
|
42
44
|
if (objectSchema.overWriteHandlers[action].includes(HANDLER.hdrApi)) {
|
|
43
45
|
// create template data
|
|
44
|
-
const createSourceParam = createParamForCreateSource(
|
|
46
|
+
const createSourceParam = createParamForCreateSource(newObjectSchema, action, srcPath)
|
|
45
47
|
createSourceArray.push(createSourceParam)
|
|
46
48
|
}
|
|
47
49
|
} else {
|
|
@@ -49,7 +51,7 @@ function data(_izContext, objectSchema, srcPath) {
|
|
|
49
51
|
const defaultHandler = DEFAULT_HANDLER_PER_ACTION[action]
|
|
50
52
|
if (defaultHandler.includes(HANDLER.hdrApi)) {
|
|
51
53
|
// create template data and object for create source
|
|
52
|
-
const createSourceParam = createParamForCreateSource(
|
|
54
|
+
const createSourceParam = createParamForCreateSource(newObjectSchema, action, srcPath)
|
|
53
55
|
createSourceArray.push(createSourceParam)
|
|
54
56
|
}
|
|
55
57
|
}
|
|
@@ -58,11 +60,14 @@ function data(_izContext, objectSchema, srcPath) {
|
|
|
58
60
|
}
|
|
59
61
|
|
|
60
62
|
function createParamForCreateSource(objectSchema, action, srcPath) {
|
|
61
|
-
let objectType = objectSchema.objectType
|
|
63
|
+
let objectType = objectSchema.objectType
|
|
62
64
|
let functionName = objectType + upperCase(action);
|
|
63
65
|
let additionalResourcePermission = defaultIamRolePerAction();
|
|
64
66
|
let tableForGetItem = [];
|
|
65
67
|
let hasGraphStorage = false;
|
|
68
|
+
let functionNameObjectType = objectSchema?.shortNameObjectType ? objectSchema.shortNameObjectType : objectSchema.objectType
|
|
69
|
+
let functionNameConfig = upperCase(functionNameObjectType) + upperCase(action) + upperCase(shortNameHandler(HANDLER.hdrApi))
|
|
70
|
+
|
|
66
71
|
for (let storageResource of Object.values(objectSchema.storageResources)) {
|
|
67
72
|
if (storageResource.storageType === STORAGE_TYPES.dynamoDB) {
|
|
68
73
|
// add IamRole for dynamodb depend on tableName in storageResources of objectSchema
|
|
@@ -147,7 +152,8 @@ function createParamForCreateSource(objectSchema, action, srcPath) {
|
|
|
147
152
|
additionalResourcePermission,
|
|
148
153
|
event: event,
|
|
149
154
|
objectType: objectType,
|
|
150
|
-
action: action
|
|
155
|
+
action: action,
|
|
156
|
+
functionNameConfig
|
|
151
157
|
},
|
|
152
158
|
setting: {
|
|
153
159
|
savePath: path.join(srcPath, SOURCE_PATH.appYaml),
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<%_ const join = require('path').join; _%>
|
|
2
|
-
<%- firstLetterUpperCase(
|
|
2
|
+
<%- firstLetterUpperCase(functionNameConfig) %>:
|
|
3
3
|
handler: <%- join(resourceLocation, `${firstLetterUpperCase(functionName)}_${firstLetterUpperCase(handlerType)}.main`)%>
|
|
4
4
|
name: ${self:custom.iz_resourcePrefix}<%- firstLetterUpperCase(functionName) %><%- firstLetterUpperCase(handlerType) %>
|
|
5
5
|
events:
|
|
@@ -21,8 +21,8 @@ const fs = require('fs');
|
|
|
21
21
|
|
|
22
22
|
const { ACTIONS, HANDLER, STORAGE_TYPES } = require('@izara_project/izara-core-library-service-schemas/src/Consts')
|
|
23
23
|
|
|
24
|
-
const { firstLetterLowerCase: lowerCase, firstLetterUpperCase: upperCase } = require("../../../../../MainLibs/src/Utils")
|
|
25
|
-
const { DEFAULT_HANDLER_PER_ACTION, createIamRole, resourceNames, RESOURCE_CLASSES, DEFAULT_LAMBDA_ROLE_PER_ACTION, SQS_RESOURCE, SOURCE_PATH, SAVE_FILE_NAME, DYNAMO_RESOURCE, SNS_RESOURCE, FUNCTION_NAME, defaultIamRolePerAction, awaitingMultipleStepsRole } = require("../../../libs/Consts");
|
|
24
|
+
const { firstLetterLowerCase: lowerCase, firstLetterUpperCase: upperCase, renameObjectType } = require("../../../../../MainLibs/src/Utils")
|
|
25
|
+
const { DEFAULT_HANDLER_PER_ACTION, createIamRole, resourceNames, RESOURCE_CLASSES, DEFAULT_LAMBDA_ROLE_PER_ACTION, SQS_RESOURCE, SOURCE_PATH, SAVE_FILE_NAME, DYNAMO_RESOURCE, SNS_RESOURCE, FUNCTION_NAME, defaultIamRolePerAction, awaitingMultipleStepsRole, shortNameHandler } = require("../../../libs/Consts");
|
|
26
26
|
|
|
27
27
|
const templatePath = path.join(__dirname, "./template.ejs")
|
|
28
28
|
|
|
@@ -36,12 +36,14 @@ const templatePath = path.join(__dirname, "./template.ejs")
|
|
|
36
36
|
function data(_izContext, objectSchema, srcPath) {
|
|
37
37
|
let createSourceArray = [];
|
|
38
38
|
|
|
39
|
+
let newObjectSchema = renameObjectType(objectSchema, srcPath)
|
|
40
|
+
|
|
39
41
|
for (const action of Object.values(ACTIONS)) {
|
|
40
42
|
if (objectSchema.overWriteHandlers?.[action]) {
|
|
41
43
|
// if have overWriteHander of action check hdrApi inside
|
|
42
44
|
if (objectSchema.overWriteHandlers[action].includes(HANDLER.hdrDsq)) {
|
|
43
45
|
// create template data
|
|
44
|
-
const createSourceParam = createParamForCreateSource(
|
|
46
|
+
const createSourceParam = createParamForCreateSource(newObjectSchema, action, srcPath)
|
|
45
47
|
createSourceArray.push(createSourceParam)
|
|
46
48
|
}
|
|
47
49
|
} else {
|
|
@@ -49,7 +51,7 @@ function data(_izContext, objectSchema, srcPath) {
|
|
|
49
51
|
const defaultHandler = DEFAULT_HANDLER_PER_ACTION[action]
|
|
50
52
|
if (defaultHandler.includes(HANDLER.hdrDsq)) {
|
|
51
53
|
// create template data and object for create source
|
|
52
|
-
const createSourceParam = createParamForCreateSource(
|
|
54
|
+
const createSourceParam = createParamForCreateSource(newObjectSchema, action, srcPath)
|
|
53
55
|
createSourceArray.push(createSourceParam)
|
|
54
56
|
}
|
|
55
57
|
}
|
|
@@ -60,9 +62,10 @@ function data(_izContext, objectSchema, srcPath) {
|
|
|
60
62
|
|
|
61
63
|
function createParamForCreateSource(objectSchema, action, srcPath) {
|
|
62
64
|
let objectType = objectSchema.objectType;
|
|
63
|
-
let
|
|
64
|
-
let
|
|
65
|
-
|
|
65
|
+
let functionName = objectType + upperCase(action);
|
|
66
|
+
let functionNameObjectType = objectSchema?.shortNameObjectType ? objectSchema.shortNameObjectType : objectSchema.objectType;
|
|
67
|
+
let functionNameConfig = upperCase(functionNameObjectType) + upperCase(action) + upperCase(shortNameHandler(HANDLER.hdrDsq))
|
|
68
|
+
console.log("functionNameConfigInFunctionYamlHdrDsq", functionNameConfig)
|
|
66
69
|
let additionalResourcePermission = defaultIamRolePerAction();
|
|
67
70
|
let tableForGetItem = [];
|
|
68
71
|
|
|
@@ -156,7 +159,8 @@ function createParamForCreateSource(objectSchema, action, srcPath) {
|
|
|
156
159
|
functionName: functionName,
|
|
157
160
|
resourceLocation: SOURCE_PATH.resourceLocationPerAction,
|
|
158
161
|
handlerType: HANDLER.hdrDsq,
|
|
159
|
-
additionalResourcePermission
|
|
162
|
+
additionalResourcePermission,
|
|
163
|
+
functionNameConfig
|
|
160
164
|
},
|
|
161
165
|
setting: {
|
|
162
166
|
savePath: path.join(srcPath, SOURCE_PATH.appYaml),
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<%_ const join = require('path').join; _%>
|
|
2
|
-
<%- firstLetterUpperCase(
|
|
2
|
+
<%- firstLetterUpperCase(functionNameConfig) %>:
|
|
3
3
|
handler: <%- join(resourceLocation, `${firstLetterUpperCase(functionName)}_${firstLetterUpperCase(handlerType)}.main`)%>
|
|
4
4
|
name: ${self:custom.iz_resourcePrefix}<%- firstLetterUpperCase(functionName) %><%- firstLetterUpperCase(handlerType) %>
|
|
5
5
|
events:
|
|
@@ -21,8 +21,8 @@ const fs = require('fs');
|
|
|
21
21
|
|
|
22
22
|
const { ACTIONS, HANDLER, STORAGE_TYPES } = require('@izara_project/izara-core-library-service-schemas/src/Consts')
|
|
23
23
|
|
|
24
|
-
const { firstLetterLowerCase: lowerCase, firstLetterUpperCase: upperCase } = require("../../../../../MainLibs/src/Utils")
|
|
25
|
-
const { DEFAULT_HANDLER_PER_ACTION, createIamRole, resourceNames, RESOURCE_CLASSES, DEFAULT_LAMBDA_ROLE_PER_ACTION, SOURCE_PATH, SAVE_FILE_NAME, DYNAMO_RESOURCE, SNS_RESOURCE, FUNCTION_NAME, defaultIamRolePerAction, awaitingMultipleStepsRole } = require('../../../libs/Consts');
|
|
24
|
+
const { firstLetterLowerCase: lowerCase, firstLetterUpperCase: upperCase, renameObjectType } = require("../../../../../MainLibs/src/Utils")
|
|
25
|
+
const { DEFAULT_HANDLER_PER_ACTION, createIamRole, resourceNames, RESOURCE_CLASSES, DEFAULT_LAMBDA_ROLE_PER_ACTION, SOURCE_PATH, SAVE_FILE_NAME, DYNAMO_RESOURCE, SNS_RESOURCE, FUNCTION_NAME, defaultIamRolePerAction, awaitingMultipleStepsRole, shortNameHandler } = require('../../../libs/Consts');
|
|
26
26
|
|
|
27
27
|
const templatePath = path.join(__dirname, "./template.ejs")
|
|
28
28
|
|
|
@@ -34,20 +34,15 @@ const templatePath = path.join(__dirname, "./template.ejs")
|
|
|
34
34
|
* @return {{ templatePath, templateData, setting } }
|
|
35
35
|
*/
|
|
36
36
|
function data(_izContext, objectSchema, srcPath) {
|
|
37
|
-
|
|
38
|
-
// const shortNamePath = path.join(srcPath, "./schemas/ShortNameObjectType.js");
|
|
39
|
-
// const shortName = fs.existsSync(shortNamePath) ? require(shortNamePath) : {};
|
|
40
|
-
// console.log("objectSchema in mainFunction: ", objectSchema)
|
|
41
|
-
|
|
42
|
-
|
|
43
37
|
let createSourceArray = [];
|
|
38
|
+
let newObjectSchema = renameObjectType(objectSchema, srcPath);
|
|
44
39
|
|
|
45
40
|
for (const action of Object.values(ACTIONS)) {
|
|
46
41
|
if (objectSchema.overWriteHandlers?.[action]) {
|
|
47
42
|
// if have overWriteHander of action check hdrInv inside
|
|
48
43
|
if (objectSchema.overWriteHandlers[action].includes(HANDLER.hdrInv)) {
|
|
49
44
|
// create template data
|
|
50
|
-
const createSourceParam = createParamForCreateSource(
|
|
45
|
+
const createSourceParam = createParamForCreateSource(newObjectSchema, action, srcPath)
|
|
51
46
|
createSourceArray.push(createSourceParam)
|
|
52
47
|
}
|
|
53
48
|
} else {
|
|
@@ -55,7 +50,7 @@ function data(_izContext, objectSchema, srcPath) {
|
|
|
55
50
|
const defaultHandler = DEFAULT_HANDLER_PER_ACTION[action]
|
|
56
51
|
if (defaultHandler.includes(HANDLER.hdrInv)) {
|
|
57
52
|
// create template data and object for create source
|
|
58
|
-
const createSourceParam = createParamForCreateSource(
|
|
53
|
+
const createSourceParam = createParamForCreateSource(newObjectSchema, action, srcPath)
|
|
59
54
|
createSourceArray.push(createSourceParam)
|
|
60
55
|
}
|
|
61
56
|
}
|
|
@@ -66,6 +61,7 @@ function data(_izContext, objectSchema, srcPath) {
|
|
|
66
61
|
|
|
67
62
|
|
|
68
63
|
function createParamForCreateSource(objectSchema, action, srcPath) {
|
|
64
|
+
let functionNameObjectType = objectSchema?.shortNameObjectType ? objectSchema.shortNameObjectType : objectSchema.objectType;
|
|
69
65
|
let objectType = objectSchema.objectType;
|
|
70
66
|
let actionHandler = action;
|
|
71
67
|
let functionName = objectType + upperCase(actionHandler);
|
|
@@ -144,7 +140,9 @@ function createParamForCreateSource(objectSchema, action, srcPath) {
|
|
|
144
140
|
resourceLocation: SOURCE_PATH.resourceLocationPerAction,
|
|
145
141
|
handlerType: HANDLER.hdrInv,
|
|
146
142
|
additionalResourcePermission,
|
|
147
|
-
objectType
|
|
143
|
+
objectType,
|
|
144
|
+
// functionNameConfig: upperCase(objectType) + upperCase(action) + upperCase(shortNameHandler(HANDLER.hdrInv))
|
|
145
|
+
functionNameConfig: upperCase(functionNameObjectType) + upperCase(action) + upperCase(shortNameHandler(HANDLER.hdrInv))
|
|
148
146
|
},
|
|
149
147
|
setting: {
|
|
150
148
|
savePath: path.join(srcPath, SOURCE_PATH.appYaml),
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<%_ const join = require('path').join; _%>
|
|
2
|
-
<%- firstLetterUpperCase(
|
|
2
|
+
<%- firstLetterUpperCase(functionNameConfig) %>:
|
|
3
3
|
handler: <%- join(resourceLocation, `${firstLetterUpperCase(functionName)}_${firstLetterUpperCase(handlerType)}.main`)%>
|
|
4
4
|
name: ${self:custom.iz_resourcePrefix}<%- firstLetterUpperCase(functionName) %><%- firstLetterUpperCase(handlerType) %>
|
|
5
5
|
iamRoleStatements:
|