@izara_project/izara-market-library-service-schemas 1.0.14 → 1.0.16
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 +5 -5
- package/src/GenerateCodeLibs/src/Consts.js +3 -1
- package/src/GenerateCodeLibs/src/GenerateCodeLibs.js +122 -98
- package/src/MainLibs/src/Utils.js +10 -9
- package/src/TemplateManager/src/FindData/GetByStorage/getByGraph.ejs +2 -1
- package/src/TemplateManager/src/GenerateCode.js +55 -12
- package/src/TemplateManager/src/OutPerActionComplete/OutGetComplete/functionYaml/data.js +86 -0
- package/src/TemplateManager/src/OutPerActionComplete/OutGetComplete/functionYaml/template.ejs +33 -0
- package/src/TemplateManager/src/OutPerActionComplete/OutGetComplete/handler/data.js +59 -0
- package/src/TemplateManager/src/OutPerActionComplete/OutGetComplete/handler/template.ejs +129 -0
- package/src/TemplateManager/src/OutPerActionComplete/OutGetComplete/mainFunction/data.js +53 -0
- package/src/TemplateManager/src/OutPerActionComplete/OutGetComplete/mainFunction/template.ejs +130 -0
- package/src/TemplateManager/src/OutPerActionComplete/OutGetComplete/sns-out/data.js +62 -0
- package/src/TemplateManager/src/OutPerActionComplete/OutGetComplete/sqs-in-sns/data.js +58 -0
- package/src/TemplateManager/src/OutPerActionComplete/OutGetComplete/sqs-in-sns/template.ejs +47 -0
- package/src/TemplateManager/src/PerActionEndpoint/FunctionYaml/HdrApi/data.js +15 -7
- package/src/TemplateManager/src/PerActionEndpoint/FunctionYaml/HdrDsq/data.js +14 -6
- package/src/TemplateManager/src/PerActionEndpoint/FunctionYaml/HdrInv/data.js +14 -4
- package/src/TemplateManager/src/PerActionEndpoint/FunctionYaml/HdrSqs/data.js +14 -4
- package/src/TemplateManager/src/PerActionEndpoint/FunctionYaml/HdrWbs/data.js +171 -0
- package/src/TemplateManager/src/PerActionEndpoint/FunctionYaml/HdrWbs/request.json +19 -0
- package/src/TemplateManager/src/PerActionEndpoint/FunctionYaml/HdrWbs/template.ejs +29 -0
- package/src/TemplateManager/src/PerActionEndpoint/FunctionYaml/webSocketConnect/data.js +60 -0
- package/src/TemplateManager/src/PerActionEndpoint/FunctionYaml/webSocketConnect/template.ejs +10 -0
- package/src/TemplateManager/src/PerActionEndpoint/Handler/HdrDsq/template.ejs +15 -12
- package/src/TemplateManager/src/PerActionEndpoint/Handler/HdrSqs/template.ejs +14 -13
- package/src/TemplateManager/src/PerActionEndpoint/Handler/WebSocket/data.js +76 -0
- package/src/TemplateManager/src/PerActionEndpoint/Handler/WebSocket/template.ejs +141 -0
- package/src/TemplateManager/src/PerActionEndpoint/Handler/WebSocketConnect/data.js +56 -0
- package/src/TemplateManager/src/PerActionEndpoint/Handler/WebSocketConnect/template.ejs +55 -0
- package/src/TemplateManager/src/PerActionEndpoint/MainFunction/Create/template.ejs +40 -36
- package/src/TemplateManager/src/PerActionEndpoint/MainFunction/Delete/template.ejs +0 -1
- package/src/TemplateManager/src/PerActionEndpoint/MainFunction/Get/template.ejs +54 -22
- package/src/TemplateManager/src/PerActionEndpoint/MainFunction/Update/template.ejs +23 -27
- package/src/TemplateManager/src/ProcessLogical/mainFunction/template.ejs +2 -2
- package/src/TemplateManager/src/RelationshipPerAction/CreateRelationship/createRelationship/functionYaml/HdrSqs/template.ejs +4 -0
- package/src/TemplateManager/src/RelationshipPerAction/CreateRelationship/createRelationship/perAction/HdrApi/template.ejs +2 -1
- package/src/TemplateManager/src/RelationshipPerAction/CreateRelationship/createRelationship/perAction/HdrDsq/template.ejs +1 -5
- package/src/TemplateManager/src/RelationshipPerAction/CreateRelationship/createRelationship/perAction/HdrSqs/template.ejs +1 -5
- package/src/TemplateManager/src/RelationshipPerAction/CreateRelationship/createRelationshipComplete/mainFunction/template.ejs +11 -7
- package/src/TemplateManager/src/RelationshipPerAction/DeleteRelationship/DeleteRelationship/functionYaml/HdrSqs/template.ejs +4 -0
- package/src/TemplateManager/src/RelationshipPerAction/DeleteRelationship/DeleteRelationship/perAction/HdrApi/template.ejs +5 -4
- package/src/TemplateManager/src/RelationshipPerAction/DeleteRelationship/DeleteRelationship/perAction/HdrInv/template.ejs +3 -2
- package/src/TemplateManager/src/RelationshipPerAction/DeleteRelationship/DeleteRelationshipComplete/mainFunction/template.ejs +16 -13
- package/src/TemplateManager/src/RelationshipPerAction/UpdateRelationshipSchema/updateRalationshipComplete/mainFunction/template.ejs +9 -6
- package/src/TemplateManager/src/RelationshipPerAction/UpdateRelationshipSchema/updateRelationship/functionYaml/HdrSqs/template.ejs +4 -0
- package/src/TemplateManager/src/RelationshipPerAction/UpdateRelationshipSchema/updateRelationship/perAction/HdrApi/template.ejs +8 -5
- package/src/TemplateManager/src/RelationshipPerAction/UpdateRelationshipSchema/updateRelationship/perAction/HdrDsq/template.ejs +1 -1
- package/src/TemplateManager/src/RelationshipPerAction/UpdateRelationshipSchema/updateRelationship/perAction/HdrInv/template.ejs +10 -8
- package/src/TemplateManager/src/RelationshipPerAction/UpdateRelationshipSchema/updateRelationship/perAction/HdrSqs/template.ejs +1 -1
- package/src/TemplateManager/src/ResourceYaml/dynamodb/{awaitingMultipleStepData.js → defaultDynamoDbTable.js} +39 -3
- package/src/TemplateManager/src/ResourceYaml/sns-in-sqs/defaultSnsInSqsForFindDataAndProcessLogical.js +6 -3
- package/src/TemplateManager/src/externalService/FunctionNameConfig/data.js +1 -1
- package/src/TemplateManager/src/externalService/LambdaRole/data.js +5 -10
- package/src/TemplateManager/src/externalService/SnsTopicSubscriotions/data.js +14 -0
- package/src/TemplateManager/src/flowTag/resources/dynamoDb/data.js +65 -0
- package/src/TemplateManager/src/flowTag/webSocket/webSocketConnect/functionYaml/data.js +56 -0
- package/src/TemplateManager/src/flowTag/webSocket/webSocketConnect/functionYaml/template.ejs +10 -0
- package/src/TemplateManager/src/flowTag/webSocket/webSocketConnect/handler/data.js +55 -0
- package/src/TemplateManager/src/flowTag/webSocket/webSocketConnect/handler/template.ejs +63 -0
- package/src/TemplateManager/src/flowTag/webSocket/websocketHandler/functionYaml/data.js +75 -0
- package/src/TemplateManager/src/flowTag/webSocket/websocketHandler/functionYaml/template.ejs +33 -0
- package/src/TemplateManager/src/flowTag/webSocket/websocketHandler/lambda/data.js +57 -0
- package/src/TemplateManager/src/flowTag/webSocket/websocketHandler/lambda/template.ejs +131 -0
- package/src/TemplateManager/src/libs/Consts.js +7 -2
- package/src/TemplateManager/src/libs/GenerateCodeUtils.js +3 -1
- package/src/TemplateManager/src/ResourceYaml/dynamodb/processLogicalAndFindData.js +0 -99
|
@@ -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
|
|
25
|
-
const { DEFAULT_HANDLER_PER_ACTION, createIamRole, resourceNames, RESOURCE_CLASSES, DEFAULT_LAMBDA_ROLE_PER_ACTION, SOURCE_PATH, SAVE_FILE_NAME,
|
|
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, SNS_RESOURCE, FUNCTION_NAME, defaultIamRolePerAction, awaitingMultipleStepsRole, shortNameHandler } = require("../../../libs/Consts");
|
|
26
26
|
|
|
27
27
|
const templatePath = path.join(__dirname, "./template.ejs")
|
|
28
28
|
|
|
@@ -35,15 +35,12 @@ const templatePath = path.join(__dirname, "./template.ejs")
|
|
|
35
35
|
*/
|
|
36
36
|
function data(_izContext, objectSchema, srcPath) {
|
|
37
37
|
let createSourceArray = [];
|
|
38
|
-
|
|
39
|
-
let newObjectSchema = renameObjectType(objectSchema, srcPath);
|
|
40
|
-
|
|
41
38
|
for (const action of Object.values(ACTIONS)) {
|
|
42
39
|
if (objectSchema.overWriteHandlers?.[action]) {
|
|
43
40
|
// if have overWriteHander of action check hdrApi inside
|
|
44
41
|
if (objectSchema.overWriteHandlers[action].includes(HANDLER.hdrApi)) {
|
|
45
42
|
// create template data
|
|
46
|
-
const createSourceParam = createParamForCreateSource(
|
|
43
|
+
const createSourceParam = createParamForCreateSource(objectSchema, action, srcPath)
|
|
47
44
|
createSourceArray.push(createSourceParam)
|
|
48
45
|
}
|
|
49
46
|
} else {
|
|
@@ -51,7 +48,7 @@ function data(_izContext, objectSchema, srcPath) {
|
|
|
51
48
|
const defaultHandler = DEFAULT_HANDLER_PER_ACTION[action]
|
|
52
49
|
if (defaultHandler.includes(HANDLER.hdrApi)) {
|
|
53
50
|
// create template data and object for create source
|
|
54
|
-
const createSourceParam = createParamForCreateSource(
|
|
51
|
+
const createSourceParam = createParamForCreateSource(objectSchema, action, srcPath)
|
|
55
52
|
createSourceArray.push(createSourceParam)
|
|
56
53
|
}
|
|
57
54
|
}
|
|
@@ -141,6 +138,17 @@ function createParamForCreateSource(objectSchema, action, srcPath) {
|
|
|
141
138
|
// ]
|
|
142
139
|
// )
|
|
143
140
|
// )
|
|
141
|
+
} else if (action === ACTIONS.get) {
|
|
142
|
+
additionalResourcePermission.push(
|
|
143
|
+
createIamRole(
|
|
144
|
+
{
|
|
145
|
+
[RESOURCE_CLASSES.sns]: [SNS_RESOURCE.publish]
|
|
146
|
+
},
|
|
147
|
+
[
|
|
148
|
+
resourceNames(RESOURCE_CLASSES.sns, "OutGetNodeComplete")
|
|
149
|
+
]
|
|
150
|
+
)
|
|
151
|
+
)
|
|
144
152
|
}
|
|
145
153
|
|
|
146
154
|
return {
|
|
@@ -21,7 +21,7 @@ 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
|
|
24
|
+
const { firstLetterLowerCase: lowerCase, firstLetterUpperCase: upperCase } = require("../../../../../MainLibs/src/Utils")
|
|
25
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")
|
|
@@ -36,14 +36,12 @@ 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
|
-
|
|
41
39
|
for (const action of Object.values(ACTIONS)) {
|
|
42
40
|
if (objectSchema.overWriteHandlers?.[action]) {
|
|
43
41
|
// if have overWriteHander of action check hdrApi inside
|
|
44
42
|
if (objectSchema.overWriteHandlers[action].includes(HANDLER.hdrDsq)) {
|
|
45
43
|
// create template data
|
|
46
|
-
const createSourceParam = createParamForCreateSource(
|
|
44
|
+
const createSourceParam = createParamForCreateSource(objectSchema, action, srcPath)
|
|
47
45
|
createSourceArray.push(createSourceParam)
|
|
48
46
|
}
|
|
49
47
|
} else {
|
|
@@ -51,7 +49,7 @@ function data(_izContext, objectSchema, srcPath) {
|
|
|
51
49
|
const defaultHandler = DEFAULT_HANDLER_PER_ACTION[action]
|
|
52
50
|
if (defaultHandler.includes(HANDLER.hdrDsq)) {
|
|
53
51
|
// create template data and object for create source
|
|
54
|
-
const createSourceParam = createParamForCreateSource(
|
|
52
|
+
const createSourceParam = createParamForCreateSource(objectSchema, action, srcPath)
|
|
55
53
|
createSourceArray.push(createSourceParam)
|
|
56
54
|
}
|
|
57
55
|
}
|
|
@@ -65,7 +63,6 @@ function createParamForCreateSource(objectSchema, action, srcPath) {
|
|
|
65
63
|
let functionName = upperCase(objectType) + upperCase(action);
|
|
66
64
|
let functionNameObjectType = objectSchema?.shortNameObjectType ? objectSchema.shortNameObjectType : objectSchema.objectType;
|
|
67
65
|
let functionNameConfig = upperCase(functionNameObjectType) + upperCase(action) + upperCase(shortNameHandler(HANDLER.hdrDsq))
|
|
68
|
-
console.log("functionNameConfigInFunctionYamlHdrDsq", functionNameConfig)
|
|
69
66
|
let additionalResourcePermission = defaultIamRolePerAction();
|
|
70
67
|
let tableForGetItem = [];
|
|
71
68
|
|
|
@@ -149,6 +146,17 @@ function createParamForCreateSource(objectSchema, action, srcPath) {
|
|
|
149
146
|
// ]
|
|
150
147
|
// )
|
|
151
148
|
// )
|
|
149
|
+
} else if (action === ACTIONS.get) {
|
|
150
|
+
additionalResourcePermission.push(
|
|
151
|
+
createIamRole(
|
|
152
|
+
{
|
|
153
|
+
[RESOURCE_CLASSES.sns]: [SNS_RESOURCE.publish]
|
|
154
|
+
},
|
|
155
|
+
[
|
|
156
|
+
resourceNames(RESOURCE_CLASSES.sns, "OutGetNodeComplete")
|
|
157
|
+
]
|
|
158
|
+
)
|
|
159
|
+
)
|
|
152
160
|
}
|
|
153
161
|
|
|
154
162
|
|
|
@@ -21,7 +21,7 @@ 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
|
|
24
|
+
const { firstLetterLowerCase: lowerCase, firstLetterUpperCase: upperCase } = require("../../../../../MainLibs/src/Utils")
|
|
25
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")
|
|
@@ -35,14 +35,13 @@ const templatePath = path.join(__dirname, "./template.ejs")
|
|
|
35
35
|
*/
|
|
36
36
|
function data(_izContext, objectSchema, srcPath) {
|
|
37
37
|
let createSourceArray = [];
|
|
38
|
-
let newObjectSchema = renameObjectType(objectSchema, srcPath);
|
|
39
38
|
|
|
40
39
|
for (const action of Object.values(ACTIONS)) {
|
|
41
40
|
if (objectSchema.overWriteHandlers?.[action]) {
|
|
42
41
|
// if have overWriteHander of action check hdrInv inside
|
|
43
42
|
if (objectSchema.overWriteHandlers[action].includes(HANDLER.hdrInv)) {
|
|
44
43
|
// create template data
|
|
45
|
-
const createSourceParam = createParamForCreateSource(
|
|
44
|
+
const createSourceParam = createParamForCreateSource(objectSchema, action, srcPath)
|
|
46
45
|
createSourceArray.push(createSourceParam)
|
|
47
46
|
}
|
|
48
47
|
} else {
|
|
@@ -50,7 +49,7 @@ function data(_izContext, objectSchema, srcPath) {
|
|
|
50
49
|
const defaultHandler = DEFAULT_HANDLER_PER_ACTION[action]
|
|
51
50
|
if (defaultHandler.includes(HANDLER.hdrInv)) {
|
|
52
51
|
// create template data and object for create source
|
|
53
|
-
const createSourceParam = createParamForCreateSource(
|
|
52
|
+
const createSourceParam = createParamForCreateSource(objectSchema, action, srcPath)
|
|
54
53
|
createSourceArray.push(createSourceParam)
|
|
55
54
|
}
|
|
56
55
|
}
|
|
@@ -129,6 +128,17 @@ function createParamForCreateSource(objectSchema, action, srcPath) {
|
|
|
129
128
|
// ]
|
|
130
129
|
// )
|
|
131
130
|
// )
|
|
131
|
+
} else if (action === ACTIONS.get) {
|
|
132
|
+
additionalResourcePermission.push(
|
|
133
|
+
createIamRole(
|
|
134
|
+
{
|
|
135
|
+
[RESOURCE_CLASSES.sns]: [SNS_RESOURCE.publish]
|
|
136
|
+
},
|
|
137
|
+
[
|
|
138
|
+
resourceNames(RESOURCE_CLASSES.sns, "OutGetNodeComplete")
|
|
139
|
+
]
|
|
140
|
+
)
|
|
141
|
+
)
|
|
132
142
|
}
|
|
133
143
|
|
|
134
144
|
|
|
@@ -21,7 +21,7 @@ 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
|
|
24
|
+
const { firstLetterLowerCase: lowerCase, firstLetterUpperCase: upperCase } = require("../../../../../MainLibs/src/Utils")
|
|
25
25
|
const { DEFAULT_HANDLER_PER_ACTION, createIamRole, resourceNames, RESOURCE_CLASSES, DEFAULT_LAMBDA_ROLE_PER_ACTION, SQS_RESOURCE, SOURCE_PATH, SAVE_FILE_NAME, SNS_RESOURCE, FUNCTION_NAME, DYNAMO_RESOURCE, defaultIamRolePerAction, awaitingMultipleStepsRole, shortNameHandler } = require("../../../libs/Consts");
|
|
26
26
|
|
|
27
27
|
const templatePath = path.join(__dirname, "./template.ejs")
|
|
@@ -35,13 +35,12 @@ const templatePath = path.join(__dirname, "./template.ejs")
|
|
|
35
35
|
*/
|
|
36
36
|
function data(_izContext, objectSchema, srcPath) {
|
|
37
37
|
let createSourceArray = [];
|
|
38
|
-
let newObjectSchema = renameObjectType(objectSchema, srcPath)
|
|
39
38
|
for (const action of Object.values(ACTIONS)) {
|
|
40
39
|
if (objectSchema.overWriteHandlers?.[action]) {
|
|
41
40
|
// if have overWriteHander of action check hdrApi inside
|
|
42
41
|
if (objectSchema.overWriteHandlers[action].includes(HANDLER.hdrSqs)) {
|
|
43
42
|
// create template data
|
|
44
|
-
const createSourceParam = createParamForCreateSource(
|
|
43
|
+
const createSourceParam = createParamForCreateSource(objectSchema, action, srcPath)
|
|
45
44
|
createSourceArray.push(createSourceParam)
|
|
46
45
|
}
|
|
47
46
|
} else {
|
|
@@ -49,7 +48,7 @@ function data(_izContext, objectSchema, srcPath) {
|
|
|
49
48
|
const defaultHandler = DEFAULT_HANDLER_PER_ACTION[action]
|
|
50
49
|
if (defaultHandler.includes(HANDLER.hdrSqs)) {
|
|
51
50
|
// create template data and object for create source
|
|
52
|
-
const createSourceParam = createParamForCreateSource(
|
|
51
|
+
const createSourceParam = createParamForCreateSource(objectSchema, action, srcPath)
|
|
53
52
|
createSourceArray.push(createSourceParam)
|
|
54
53
|
}
|
|
55
54
|
}
|
|
@@ -150,6 +149,17 @@ function createParamForCreateSource(objectSchema, action, srcPath) {
|
|
|
150
149
|
// ]
|
|
151
150
|
// )
|
|
152
151
|
// )
|
|
152
|
+
} else if (action === ACTIONS.get) {
|
|
153
|
+
additionalResourcePermission.push(
|
|
154
|
+
createIamRole(
|
|
155
|
+
{
|
|
156
|
+
[RESOURCE_CLASSES.sns]: [SNS_RESOURCE.publish]
|
|
157
|
+
},
|
|
158
|
+
[
|
|
159
|
+
resourceNames(RESOURCE_CLASSES.sns, "OutGetNodeComplete")
|
|
160
|
+
]
|
|
161
|
+
)
|
|
162
|
+
)
|
|
153
163
|
}
|
|
154
164
|
|
|
155
165
|
// console.log("additionalResourcePermissionBeforeReturn", additionalResourcePermission)
|
|
@@ -0,0 +1,171 @@
|
|
|
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
|
+
const fs = require('fs');
|
|
21
|
+
|
|
22
|
+
const { ACTIONS, HANDLER, STORAGE_TYPES } = require('@izara_project/izara-core-library-service-schemas/src/Consts')
|
|
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, SNS_RESOURCE, FUNCTION_NAME, DYNAMO_RESOURCE, defaultIamRolePerAction, awaitingMultipleStepsRole, shortNameHandler } = require("../../../libs/Consts");
|
|
26
|
+
|
|
27
|
+
const templatePath = path.join(__dirname, "./template.ejs")
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* receive objectSchema
|
|
31
|
+
* create data for hdrInv template
|
|
32
|
+
*
|
|
33
|
+
* @param {Object} objectSchema
|
|
34
|
+
* @return {{ templatePath, templateData, setting } }
|
|
35
|
+
*/
|
|
36
|
+
function data(_izContext, objectSchema, srcPath) {
|
|
37
|
+
let createSourceArray = [];
|
|
38
|
+
for (const action of Object.values(ACTIONS)) {
|
|
39
|
+
if (objectSchema.overWriteHandlers?.[action]) {
|
|
40
|
+
// if have overWriteHander of action check hdrApi inside
|
|
41
|
+
if (objectSchema.overWriteHandlers[action].includes(HANDLER.hdrWbs)) {
|
|
42
|
+
// create template data
|
|
43
|
+
const createSourceParam = createParamForCreateSource(objectSchema, action, srcPath)
|
|
44
|
+
createSourceArray.push(createSourceParam)
|
|
45
|
+
}
|
|
46
|
+
} else {
|
|
47
|
+
// if not have overWriteHander of action will use default handler
|
|
48
|
+
const defaultHandler = DEFAULT_HANDLER_PER_ACTION[action]
|
|
49
|
+
if (defaultHandler.includes(HANDLER.hdrWbs)) {
|
|
50
|
+
// create template data and object for create source
|
|
51
|
+
const createSourceParam = createParamForCreateSource(objectSchema, action, srcPath)
|
|
52
|
+
createSourceArray.push(createSourceParam)
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
return createSourceArray;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
function createParamForCreateSource(objectSchema, action, srcPath) {
|
|
62
|
+
let objectType = objectSchema.objectType;
|
|
63
|
+
let actionHandler = action;
|
|
64
|
+
let functionName = upperCase(objectType) + upperCase(actionHandler);
|
|
65
|
+
let additionalResourcePermission = defaultIamRolePerAction();
|
|
66
|
+
let tableForGetItem = [];
|
|
67
|
+
let hasGraphStorage = false;
|
|
68
|
+
let functionNameObjectType = objectSchema?.shortNameObjectType ? objectSchema.shortNameObjectType : objectSchema.objectType
|
|
69
|
+
let functionNameConfig = upperCase(functionNameObjectType) + upperCase(action) + upperCase(shortNameHandler(HANDLER.hdrWbs))
|
|
70
|
+
|
|
71
|
+
for (let storageResource of Object.values(objectSchema.storageResources)) {
|
|
72
|
+
if (storageResource.storageType === STORAGE_TYPES.dynamoDB) {
|
|
73
|
+
// add IamRole for dynamodb depend on tableName in storageResources of objectSchema
|
|
74
|
+
tableForGetItem.push(resourceNames(RESOURCE_CLASSES.dynamoDbTable, storageResource.tableName));
|
|
75
|
+
|
|
76
|
+
} else if (storageResource.storageType === STORAGE_TYPES.graph) {
|
|
77
|
+
// find graph serviceName from graphServerTag or *GetNodeHdrInv ?
|
|
78
|
+
|
|
79
|
+
if (hasGraphStorage) {
|
|
80
|
+
continue;
|
|
81
|
+
} else {
|
|
82
|
+
hasGraphStorage = true;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
additionalResourcePermission.push(awaitingMultipleStepsRole())
|
|
87
|
+
|
|
88
|
+
additionalResourcePermission.push(
|
|
89
|
+
createIamRole(
|
|
90
|
+
{
|
|
91
|
+
[RESOURCE_CLASSES.dynamoDbTable]: [
|
|
92
|
+
DYNAMO_RESOURCE.getItem,
|
|
93
|
+
DYNAMO_RESOURCE.putItem,
|
|
94
|
+
DYNAMO_RESOURCE.deleteItem
|
|
95
|
+
]
|
|
96
|
+
},
|
|
97
|
+
[
|
|
98
|
+
resourceNames(RESOURCE_CLASSES.dynamoDbTable, "WebSocketTask")
|
|
99
|
+
]
|
|
100
|
+
)
|
|
101
|
+
)
|
|
102
|
+
|
|
103
|
+
additionalResourcePermission.push(
|
|
104
|
+
createIamRole(
|
|
105
|
+
{
|
|
106
|
+
["execute-api"]: ["ManageConnections"]
|
|
107
|
+
},
|
|
108
|
+
[
|
|
109
|
+
resourceNames(RESOURCE_CLASSES.webSocket)
|
|
110
|
+
]
|
|
111
|
+
)
|
|
112
|
+
)
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
if (action == ACTIONS.update) {
|
|
116
|
+
additionalResourcePermission.push(
|
|
117
|
+
createIamRole(
|
|
118
|
+
{
|
|
119
|
+
[RESOURCE_CLASSES.sns]: [SNS_RESOURCE.publish]
|
|
120
|
+
},
|
|
121
|
+
[
|
|
122
|
+
resourceNames(RESOURCE_CLASSES.sns, "Out" + upperCase(FUNCTION_NAME.updateNodeComplete))
|
|
123
|
+
]
|
|
124
|
+
)
|
|
125
|
+
)
|
|
126
|
+
} else if (action == ACTIONS.create) {
|
|
127
|
+
additionalResourcePermission.push(
|
|
128
|
+
createIamRole(
|
|
129
|
+
{
|
|
130
|
+
[RESOURCE_CLASSES.sns]: [SNS_RESOURCE.publish]
|
|
131
|
+
},
|
|
132
|
+
[
|
|
133
|
+
resourceNames(RESOURCE_CLASSES.sns, "Out" + upperCase(FUNCTION_NAME.createObjectComplete))
|
|
134
|
+
]
|
|
135
|
+
)
|
|
136
|
+
)
|
|
137
|
+
} else if (action == ACTIONS.delete) {
|
|
138
|
+
// additionalResourcePermission.push(
|
|
139
|
+
// createIamRole(
|
|
140
|
+
// {
|
|
141
|
+
// [RESOURCE_CLASSES.sns]: [SNS_RESOURCE.publish]
|
|
142
|
+
// },
|
|
143
|
+
// [
|
|
144
|
+
// resourceNames(RESOURCE_CLASSES.sns, "Out" + upperCase(FUNCTION_NAME.createObjectComplete))
|
|
145
|
+
// ]
|
|
146
|
+
// )
|
|
147
|
+
// )
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
// console.log("additionalResourcePermissionBeforeReturn", additionalResourcePermission)
|
|
151
|
+
return {
|
|
152
|
+
templatePath: templatePath,
|
|
153
|
+
templateData: {
|
|
154
|
+
functionName: functionName,
|
|
155
|
+
actionHandler: actionHandler,
|
|
156
|
+
resourceLocation: SOURCE_PATH.resourceLocationPerAction,
|
|
157
|
+
handlerType: HANDLER.hdrWbs,
|
|
158
|
+
additionalResourcePermission,
|
|
159
|
+
functionNameConfig,
|
|
160
|
+
objectType
|
|
161
|
+
},
|
|
162
|
+
setting: {
|
|
163
|
+
savePath: path.join(srcPath, SOURCE_PATH.appYaml),
|
|
164
|
+
saveFileName: SAVE_FILE_NAME.functionPerActionYaml,
|
|
165
|
+
fileExtension: '.yml',
|
|
166
|
+
isAppend: true
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
module.exports = data;
|
|
@@ -0,0 +1,29 @@
|
|
|
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
|
+
- websocket:
|
|
7
|
+
route: <%- objectType -%><%- firstLetterUpperCase(actionHandler) %>
|
|
8
|
+
iamRoleStatements:
|
|
9
|
+
<%_ additionalResourcePermission.forEach(resourcePermission => { _%>
|
|
10
|
+
- Effect: <%- resourcePermission.effect %>
|
|
11
|
+
Action:
|
|
12
|
+
<%_ Object.keys(resourcePermission.action).forEach(resourcePerAction => { _%>
|
|
13
|
+
<%_ resourcePermission.action[resourcePerAction].forEach(permission => { _%>
|
|
14
|
+
- <%- resourcePerAction %>:<%- permission %>
|
|
15
|
+
<%_ }) _%>
|
|
16
|
+
<%_ }) _%>
|
|
17
|
+
Resource:
|
|
18
|
+
<%_ resourcePermission.resource.forEach(resource => { _%>
|
|
19
|
+
- "<%- resource %>"
|
|
20
|
+
<%_ }) _%>
|
|
21
|
+
<%_}) _%>
|
|
22
|
+
#<#<%- functionName %><%- handlerType %>IamRole#>
|
|
23
|
+
#<#/<%- functionName %><%- handlerType %>IamRole#>
|
|
24
|
+
<%_ function firstLetterUpperCase(text){
|
|
25
|
+
return text.charAt(0).toUpperCase() + text.slice(1)
|
|
26
|
+
} _%>
|
|
27
|
+
<%_ function firstLetterLowerCase(str) {
|
|
28
|
+
return str.charAt(0).toLowerCase() + str.slice(1)
|
|
29
|
+
} _%>
|
|
@@ -0,0 +1,60 @@
|
|
|
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
|
+
const fs = require('fs');
|
|
21
|
+
|
|
22
|
+
const { SOURCE_PATH, SAVE_FILE_NAME, ACTIONS, HANDLER } = require("../../../libs/Consts");
|
|
23
|
+
|
|
24
|
+
const templatePath = path.join(__dirname, "./template.ejs")
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* receive objectSchema
|
|
28
|
+
* create data for websocket connect function yaml template
|
|
29
|
+
*
|
|
30
|
+
* @param {Object} objectSchema
|
|
31
|
+
* @return {{ templatePath, templateData, setting } }
|
|
32
|
+
*/
|
|
33
|
+
|
|
34
|
+
function data(_izContext, webSocketStatus, srcPath) {
|
|
35
|
+
let createSourceParam;
|
|
36
|
+
if (webSocketStatus) {
|
|
37
|
+
createSourceParam = [createWebSocketConnectYaml(_izContext, srcPath)]
|
|
38
|
+
} else {
|
|
39
|
+
createSourceParam = []
|
|
40
|
+
}
|
|
41
|
+
return createSourceParam
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
function createWebSocketConnectYaml(_izContext, srcPath) {
|
|
45
|
+
let functionName = "WebSocketConnect"
|
|
46
|
+
return {
|
|
47
|
+
templatePath: templatePath,
|
|
48
|
+
templateData: {
|
|
49
|
+
functionName,
|
|
50
|
+
resourceLocation: SOURCE_PATH.resourceLocationPerAction
|
|
51
|
+
},
|
|
52
|
+
setting: {
|
|
53
|
+
savePath: path.join(srcPath, SOURCE_PATH.appYaml),
|
|
54
|
+
saveFileName: SAVE_FILE_NAME.functionPerActionYaml,
|
|
55
|
+
fileExtension: ".yml",
|
|
56
|
+
isAppend: true
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
module.exports = data
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
WebSocketConnect:
|
|
2
|
+
handler: src/generatedCode/ObjectTypePerActionEndpoint/source/WebSocketConnect.main
|
|
3
|
+
name: ${self:custom.iz_resourcePrefix}WebSocketConnect
|
|
4
|
+
events:
|
|
5
|
+
- websocket:
|
|
6
|
+
route: $connect
|
|
7
|
+
- websocket:
|
|
8
|
+
route: $disconnect
|
|
9
|
+
#<#<WebSocketConnectIamRole#>
|
|
10
|
+
#<#/<WebSocketConnectIamRole#>
|
|
@@ -39,12 +39,15 @@ middleware.setValidatorSchema(
|
|
|
39
39
|
//(</middlewareSettings>)
|
|
40
40
|
)
|
|
41
41
|
|
|
42
|
+
/*
|
|
43
|
+
const perRecordsValidatorSchema = {
|
|
44
|
+
type: "object",
|
|
45
|
+
required: [],
|
|
46
|
+
properties: {},
|
|
47
|
+
}
|
|
48
|
+
*/
|
|
49
|
+
|
|
42
50
|
//(<globalValidatorSchema>)
|
|
43
|
-
const perRecordsValidatorSchema = {
|
|
44
|
-
type: "object",
|
|
45
|
-
required: [],
|
|
46
|
-
properties: {},
|
|
47
|
-
}
|
|
48
51
|
//(</globalValidatorSchema>)
|
|
49
52
|
|
|
50
53
|
// if need to validate authorizer or additional params , add code to hook tag below
|
|
@@ -75,14 +78,14 @@ module.exports.main = middleware.wrap(async (event,context, callback) => {
|
|
|
75
78
|
)
|
|
76
79
|
|
|
77
80
|
//for validate additional params
|
|
81
|
+
/*
|
|
82
|
+
await recordHandlerSharedLib.validateRecord(
|
|
83
|
+
record,
|
|
84
|
+
"<%- functionName %><%- firstLetterUpperCase(handler) %>",
|
|
85
|
+
perRecordsValidatorSchema
|
|
86
|
+
);
|
|
87
|
+
*/
|
|
78
88
|
//(<afterGenerateValidatorSchema>)
|
|
79
|
-
/*
|
|
80
|
-
await recordHandlerSharedLib.validateRecord(
|
|
81
|
-
record,
|
|
82
|
-
"<%- functionName %><%- firstLetterUpperCase(handler) %>",
|
|
83
|
-
perRecordsValidatorSchema
|
|
84
|
-
);
|
|
85
|
-
*/
|
|
86
89
|
//(</afterGenerateValidatorSchema>)
|
|
87
90
|
|
|
88
91
|
//(<additionalParams>)
|
|
@@ -38,13 +38,14 @@ middleware.setValidatorSchema(
|
|
|
38
38
|
//(<middlewareSettings>)
|
|
39
39
|
//(</middlewareSettings>)
|
|
40
40
|
)
|
|
41
|
-
|
|
41
|
+
/*
|
|
42
|
+
const perRecordsValidatorSchema = {
|
|
43
|
+
type: "object",
|
|
44
|
+
required: [],
|
|
45
|
+
properties: {},
|
|
46
|
+
}
|
|
47
|
+
*/
|
|
42
48
|
//(<globalValidatorSchema>)
|
|
43
|
-
const perRecordsValidatorSchema = {
|
|
44
|
-
type: "object",
|
|
45
|
-
required: [],
|
|
46
|
-
properties: {},
|
|
47
|
-
}
|
|
48
49
|
//(</globalValidatorSchema>)
|
|
49
50
|
|
|
50
51
|
// if need to validate authorizer or additional params , add code to hook tag below
|
|
@@ -75,14 +76,14 @@ module.exports.main = middleware.wrap(async (event,context, callback) => {
|
|
|
75
76
|
)
|
|
76
77
|
|
|
77
78
|
//for validate additional params
|
|
79
|
+
/*
|
|
80
|
+
await recordHandlerSharedLib.validateRecord(
|
|
81
|
+
record,
|
|
82
|
+
"<%- functionName %><%- firstLetterUpperCase(handler) %>",
|
|
83
|
+
perRecordsValidatorSchema
|
|
84
|
+
);
|
|
85
|
+
*/
|
|
78
86
|
//(<afterGenerateValidatorSchema>)
|
|
79
|
-
/*
|
|
80
|
-
await recordHandlerSharedLib.validateRecord(
|
|
81
|
-
record,
|
|
82
|
-
"<%- functionName %><%- firstLetterUpperCase(handler) %>",
|
|
83
|
-
perRecordsValidatorSchema
|
|
84
|
-
);
|
|
85
|
-
*/
|
|
86
87
|
//(</afterGenerateValidatorSchema>)
|
|
87
88
|
|
|
88
89
|
//(<additionalParams>)
|
|
@@ -0,0 +1,76 @@
|
|
|
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
|
+
const fs = require('fs');
|
|
21
|
+
|
|
22
|
+
const { ACTIONS, HANDLER } = require('@izara_project/izara-core-library-service-schemas/src/Consts')
|
|
23
|
+
|
|
24
|
+
const { firstLetterLowerCase: lowerCase, firstLetterUpperCase: upperCase, firstLetterUpperCase, checkOverWriteGenerateMainFunction } = require("../../../../../MainLibs/src/Utils")
|
|
25
|
+
const { DEFAULT_HANDLER_PER_ACTION, SOURCE_PATH } = require("../../../libs/Consts");
|
|
26
|
+
|
|
27
|
+
const templatePath = path.join(__dirname, "template.ejs")
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* receive objectSchema
|
|
31
|
+
* create data for WebScoket handler template
|
|
32
|
+
*
|
|
33
|
+
* @param {Object} objectSchema
|
|
34
|
+
* @return {{templatePath, templateData,setting}}
|
|
35
|
+
*/
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
function data(_izContext, objectSchema, srcPath) {
|
|
39
|
+
let createSourceArray = [];
|
|
40
|
+
for (const action of Object.values(ACTIONS)) {
|
|
41
|
+
if (objectSchema.overWriteHandlers?.[action]) {
|
|
42
|
+
if (objectSchema.overWriteHandlers[action].includes(HANDLER.hdrWbs)) {
|
|
43
|
+
const createSourceParams = createParamsForCreateSource(objectSchema, action, HANDLER.hdrWbs, srcPath)
|
|
44
|
+
createSourceParams && createSourceArray.push(createSourceParams);
|
|
45
|
+
}
|
|
46
|
+
} else {
|
|
47
|
+
if (DEFAULT_HANDLER_PER_ACTION[action].includes(HANDLER.hdrWbs)) {
|
|
48
|
+
const createSourceParams = createParamsForCreateSource(objectSchema, action, HANDLER.hdrWbs, srcPath)
|
|
49
|
+
createSourceParams && createSourceArray.push(createSourceParams);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
return createSourceArray;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
function createParamsForCreateSource(objectSchema, action, handler, srcPath) {
|
|
57
|
+
let objectType = objectSchema.objectType;
|
|
58
|
+
let functionName = objectType + upperCase(action)
|
|
59
|
+
|
|
60
|
+
return {
|
|
61
|
+
templatePath: templatePath,
|
|
62
|
+
templateData: {
|
|
63
|
+
functionName,
|
|
64
|
+
objectType,
|
|
65
|
+
action,
|
|
66
|
+
isCreateMainFunction: checkOverWriteGenerateMainFunction(objectSchema, action)
|
|
67
|
+
},
|
|
68
|
+
setting: {
|
|
69
|
+
savePath: path.join(srcPath, SOURCE_PATH.lambdaPerAction),
|
|
70
|
+
saveFileName: `${upperCase(objectType)}${upperCase(action)}_${upperCase(handler)}`,
|
|
71
|
+
fileExtension: ".js",
|
|
72
|
+
isAppend: false
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
module.exports = data
|