@izara_project/izara-market-library-service-schemas 1.0.34 → 1.0.35
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/GenerateCodeLibs/src/Consts.js +2 -1
- package/src/GenerateCodeLibs/src/GenerateCodeLibs.js +5 -5
- package/src/MainLibs/src/Consts.js +43 -10
- package/src/TemplateManager/src/attributeTree/relationshipSchema/data.js +1 -1
- package/src/reStructure/GenerateCode.js +1 -0
- package/src/reStructure/SchemaConfig.js +1 -0
- package/src/reStructure/TemplateData/EndpointPerService/handler/api/template.ejs +2 -2
- package/src/reStructure/TemplateData/EndpointPerService/handler/inv/template.ejs +2 -2
- package/src/reStructure/TemplateData/EndpointPerService/mainFunction/create/template.ejs +3 -0
- package/src/reStructure/TemplateData/attributeTreeSchema/generateTemplateData.js +28 -44
- package/src/reStructure/TemplateData/attributeTreeSchema/{mainAttributeTreeSchema → mainAttributeTree}/attributeLinkTemplate.ejs +3 -7
- package/src/reStructure/TemplateData/attributeTreeSchema/mainAttributeTree/data.js +134 -0
- package/src/reStructure/TemplateData/attributeTreeSchema/relationshipSchema/data.js +172 -0
- package/src/reStructure/TemplateData/attributeTreeSchema/relationshipSchema/template.ejs +7 -0
- package/src/reStructure/TemplateData/flowSchema/CreateRecordComplete/functionYaml/data.js +123 -0
- package/src/reStructure/TemplateData/flowSchema/CreateRecordComplete/functionYaml/template.ejs +20 -0
- package/src/reStructure/TemplateData/flowSchema/CreateRecordComplete/handler/data.js +57 -0
- package/src/reStructure/TemplateData/flowSchema/CreateRecordComplete/handler/template.ejs +85 -0
- package/src/reStructure/TemplateData/flowSchema/CreateRecordComplete/mainFunction/data.js +68 -0
- package/src/reStructure/TemplateData/flowSchema/CreateRecordComplete/mainFunction/template.ejs +96 -0
- package/src/reStructure/TemplateData/flowSchema/CreateRecordComplete/queue/data.js +77 -0
- package/src/reStructure/TemplateData/flowSchema/CreateRecordComplete/queue/template.ejs +49 -0
- package/src/reStructure/TemplateData/flowSchema/components/websocket/connect/handler/template.ejs +4 -4
- package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/complete/functionYaml/data.js +138 -0
- package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/complete/functionYaml/template.ejs +20 -0
- package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/complete/handler/data.js +55 -0
- package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/complete/handler/template.ejs +83 -0
- package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/complete/mainFunction/data.js +55 -0
- package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/complete/mainFunction/template.ejs +133 -0
- package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/sns-in/data.js +64 -0
- package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/sns-in/template.ejs +12 -0
- package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/statusFieldTemplate.ejs +19 -6
- package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/storedCacheTemplate.ejs +19 -2
- package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/subscriptionOutAll/data.js +76 -0
- package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/subscriptionOutAll/template.ejs +13 -0
- package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/wbs/functionYaml/data.js +142 -0
- package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/wbs/functionYaml/template.ejs +18 -0
- package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/wbs/handler/data.js +64 -0
- package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/wbs/handler/template.ejs +89 -0
- package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/wbs/mainFunction/data.js +55 -0
- package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/wbs/mainFunction/template.ejs +120 -0
- package/src/reStructure/TemplateData/flowSchema/eventBridge/functionYaml/data.js +26 -59
- package/src/reStructure/TemplateData/flowSchema/eventBridge/functionYaml/template.ejs +3 -3
- package/src/reStructure/TemplateData/flowSchema/eventBridge/handler/inv/data.js +8 -8
- package/src/reStructure/TemplateData/flowSchema/eventBridge/mainFunction/data.js +11 -9
- package/src/reStructure/TemplateData/flowSchema/eventBridge/mainFunction/template.ejs +3 -3
- package/src/reStructure/TemplateData/flowSchema/externalTopic/sns-in-sqs/data.js +3 -6
- package/src/reStructure/TemplateData/flowSchema/externalTopic/sqs/functionYaml/data.js +7 -9
- package/src/reStructure/TemplateData/flowSchema/externalTopic/sqs/functionYaml/template.ejs +2 -2
- package/src/reStructure/TemplateData/flowSchema/externalTopic/sqs/handler/data.js +2 -2
- package/src/reStructure/TemplateData/flowSchema/externalTopic/sqs/mainFunction/data.js +1 -1
- package/src/reStructure/TemplateData/flowSchema/externalTopic/websocket/functionYaml/data.js +8 -43
- package/src/reStructure/TemplateData/flowSchema/externalTopic/websocket/functionYaml/template.ejs +1 -1
- package/src/reStructure/TemplateData/flowSchema/externalTopic/websocket/handler/data.js +2 -2
- package/src/reStructure/TemplateData/flowSchema/externalTopic/websocket/handler/template.ejs +1 -0
- package/src/reStructure/TemplateData/flowSchema/externalTopic/websocket/mainFunction/data.js +7 -1
- package/src/reStructure/TemplateData/flowSchema/externalTopic/websocket/mainFunction/template.ejs +18 -7
- package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComplete/mainFunction/data.js +3 -1
- package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComponent/mainFunction/data.js +7 -1
- package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComponent/mainFunction/template.ejs +52 -13
- package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/FlowSchemaCompleteComponent/functionYaml/template.ejs +2 -0
- package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/FlowSchemaComponent/mainFunction/data.js +1 -6
- package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/FlowSchemaComponent/mainFunction/template.ejs +1 -29
- package/src/reStructure/TemplateData/flowSchema/generateTemplateData.js +67 -6
- package/src/reStructure/TemplateData/generateRole/createSharedResource.js +20 -0
- package/src/reStructure/TemplateData/propertyNodeSchema/generateTemplateData.js +66 -0
- package/src/reStructure/TemplateData/propertyNodeSchema/objectPropertyNodeSchema/data.js +151 -0
- package/src/reStructure/TemplateData/propertyNodeSchema/objectPropertyNodeSchema/templateObjectPropertyNodeSchema.ejs +16 -0
- package/src/reStructure/TemplateData/propertyNodeSchema/relationshipPropertyNodeSchema/data.js +179 -0
- package/src/reStructure/TemplateData/propertyNodeSchema/relationshipPropertyNodeSchema/templateRelationshipPropertyNodeSchema.ejs +7 -0
- package/src/reStructure/libs/ValidateAddOnDataStructure.js +62 -0
- package/src/reStructure/TemplateData/attributeTreeSchema/mainAttributeTreeSchema/data.js +0 -188
- /package/src/reStructure/TemplateData/attributeTreeSchema/{mainAttributeTreeSchema → mainAttributeTree}/request.json +0 -0
|
@@ -0,0 +1,64 @@
|
|
|
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
|
+
|
|
20
|
+
const path = require("path")
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
// const {
|
|
24
|
+
// HANDLER,
|
|
25
|
+
// STORAGE_TYPES
|
|
26
|
+
// } = require('@izara_project/izara-core-library-service-schemas/src/Consts');
|
|
27
|
+
|
|
28
|
+
const { firstLetterLowerCase: lowerCase, firstLetterUpperCase: upperCase, firstLetterUpperCase } = require("../../../../../MainLibs/src/Utils.js");
|
|
29
|
+
const STORAGE_TYPES = {
|
|
30
|
+
dynamoDB: "dynamoDB",
|
|
31
|
+
graph: "graph"
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const templatePath = path.join(__dirname, "template.ejs");
|
|
35
|
+
const { SOURCE_PATH, SAVE_FILE_NAME, FUNCTION_NAME, HANDLER, SOURCE_GENERATE_IAM_ROLE } = require('../../../../../MainLibs/src/Consts.js')
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* create data for dynamoDbYaml template from objectSchema
|
|
39
|
+
* return array of dynamoDb data
|
|
40
|
+
* because one objectSchema can create multiple dynamoDb table
|
|
41
|
+
*
|
|
42
|
+
* @param {Object} _izContext
|
|
43
|
+
* @param {String} saveFilePath
|
|
44
|
+
* @returns {Object[]} - data of multiple dynamoDb template
|
|
45
|
+
*/
|
|
46
|
+
|
|
47
|
+
function createDataForSnsIn(_izContext, srcPath) {
|
|
48
|
+
return [{
|
|
49
|
+
templatePath: templatePath,
|
|
50
|
+
templateData: {
|
|
51
|
+
queueName: FUNCTION_NAME.flowSchemaRegister + upperCase(HANDLER.hdrSqs),
|
|
52
|
+
firstLetterUpperCase: upperCase,
|
|
53
|
+
roleName: SOURCE_GENERATE_IAM_ROLE.RegisterRole,
|
|
54
|
+
},
|
|
55
|
+
setting: {
|
|
56
|
+
initialData: "Resources:\n",
|
|
57
|
+
savePath: path.join(srcPath, SOURCE_PATH.resourceYaml),
|
|
58
|
+
saveFileName: SAVE_FILE_NAME.snsInSqsYaml,
|
|
59
|
+
fileExtension: ".yml",
|
|
60
|
+
isAppend: true
|
|
61
|
+
}
|
|
62
|
+
}]
|
|
63
|
+
}
|
|
64
|
+
module.exports = createDataForSnsIn;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
#------- queue ---------
|
|
2
|
+
<%- queueName %>:
|
|
3
|
+
Type: "AWS::SQS::Queue"
|
|
4
|
+
Properties:
|
|
5
|
+
QueueName: ${self:custom.iz_resourcePrefix}<%- queueName %>
|
|
6
|
+
RedrivePolicy:
|
|
7
|
+
deadLetterTargetArn: #!GetAtt
|
|
8
|
+
Fn::GetAtt:
|
|
9
|
+
- <%- queueName %>DLQ
|
|
10
|
+
- Arn
|
|
11
|
+
maxReceiveCount: 3
|
|
12
|
+
VisibilityTimeout: 120
|
package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/statusFieldTemplate.ejs
CHANGED
|
@@ -4,11 +4,24 @@ let objectSchema = await getObjectSchema.getObjSchemaS3WithCache(_izContext, flo
|
|
|
4
4
|
// create record
|
|
5
5
|
let fieldNames = createFieldNamesFromRequestParamsByObjectSchema(_izContext, requestParams, objectSchema)
|
|
6
6
|
|
|
7
|
+
let payload = {
|
|
8
|
+
fieldNames
|
|
9
|
+
}
|
|
10
|
+
Object.assign(payload, {
|
|
11
|
+
objectType: flowSchema.objType.objectType
|
|
12
|
+
})
|
|
7
13
|
|
|
8
|
-
let
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
14
|
+
let result = await lambda.invokeSync(_izContext,
|
|
15
|
+
await lambdaSharedLib.lambdaFunctionName(_izContext, "CreateHdrInv", flowSchema.objType.serviceTag),
|
|
16
|
+
{
|
|
17
|
+
payload: JSON.stringify(payload)
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
_izContext.logger.debug("result from createRecordByStatusType", result)
|
|
21
|
+
|
|
22
|
+
let messageObject = {
|
|
23
|
+
requestParams: requestParams
|
|
24
|
+
//(<messageObject>)
|
|
25
|
+
//(</messageObject>)
|
|
26
|
+
}
|
|
12
27
|
|
|
13
|
-
_izContext.logger.debug("before sendMessageToCreateEndpoint:: ", sendMessageToCreateEndpoint);
|
|
14
|
-
await sns.publishAsync(_izContext, sendMessageToCreateEndpoint);
|
package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/storedCacheTemplate.ejs
CHANGED
|
@@ -9,9 +9,26 @@ function createExpiryTime (_izContext, expiryInterval) {
|
|
|
9
9
|
await dynamodbSharedLib.putItem(_izContext,
|
|
10
10
|
await dynamodbSharedLib.tableName(_izContext, "<%- flowTag %>Main"),
|
|
11
11
|
{
|
|
12
|
-
<%- flowTag %>Id: hash(
|
|
12
|
+
<%- flowTag %>Id: hash({
|
|
13
|
+
//(<createStoredCacheId>)
|
|
14
|
+
//(</createStoredCacheId>)
|
|
15
|
+
}),
|
|
13
16
|
cacheExpiryTime: createExpiryTime(_izContext, 31536000000),
|
|
14
17
|
cacheStatus: "processing",
|
|
15
18
|
cacheUniqueRequestId: _izContext.uniqueRequestId
|
|
16
19
|
}
|
|
17
|
-
)
|
|
20
|
+
)
|
|
21
|
+
|
|
22
|
+
await dynamodbSharedLib.updateItem(_izContext,
|
|
23
|
+
await dynamodbSharedLib.tableName(_izContext, "WebSocketTask"),
|
|
24
|
+
{
|
|
25
|
+
taskKey: correlationId,
|
|
26
|
+
connectionId: connectionId,
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
identifiersTask: hash({
|
|
30
|
+
//(<updateStoredCacheId>)
|
|
31
|
+
//(</updateStoredCacheId>)
|
|
32
|
+
})
|
|
33
|
+
}
|
|
34
|
+
)
|
package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/subscriptionOutAll/data.js
ADDED
|
@@ -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
|
+
|
|
20
|
+
const path = require("path")
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
// const {
|
|
24
|
+
// HANDLER,
|
|
25
|
+
// STORAGE_TYPES
|
|
26
|
+
// } = require('@izara_project/izara-core-library-service-schemas/src/Consts');
|
|
27
|
+
|
|
28
|
+
const { firstLetterLowerCase: lowerCase, firstLetterUpperCase: upperCase, firstLetterUpperCase } = require("../../../../../MainLibs/src/Utils.js");
|
|
29
|
+
const STORAGE_TYPES = {
|
|
30
|
+
dynamoDB: "dynamoDB",
|
|
31
|
+
graph: "graph"
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const templatePath = path.join(__dirname, "template.ejs");
|
|
35
|
+
const { SOURCE_PATH, SAVE_FILE_NAME, FUNCTION_NAME, HANDLER } = require('../../../../../MainLibs/src/Consts.js')
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* create data for dynamoDbYaml template from objectSchema
|
|
39
|
+
* return array of dynamoDb data
|
|
40
|
+
* because one objectSchema can create multiple dynamoDb table
|
|
41
|
+
*
|
|
42
|
+
* @param {Object} _izContext
|
|
43
|
+
* @param {String} saveFilePath
|
|
44
|
+
* @returns {Object[]} - data of multiple dynamoDb template
|
|
45
|
+
*/
|
|
46
|
+
|
|
47
|
+
function createDataForSubscriptionOutAll(_izContext, allLocalFlowSchemas, srcPath) {
|
|
48
|
+
console.log("allLocalFlowSchemas", allLocalFlowSchemas.records)
|
|
49
|
+
const result = []
|
|
50
|
+
for (const flowSchema of allLocalFlowSchemas.records) {
|
|
51
|
+
let event = flowSchema.event;
|
|
52
|
+
if (!event.includes("eventBridge")) {
|
|
53
|
+
const flowStepOut = Object.keys(flowSchema.flowSteps)[1]
|
|
54
|
+
console.log("flowStepOut", flowStepOut)
|
|
55
|
+
result.push({
|
|
56
|
+
templatePath: templatePath,
|
|
57
|
+
templateData: {
|
|
58
|
+
queueName: flowStepOut,
|
|
59
|
+
endpoint: "registerComplete_",
|
|
60
|
+
firstLetterUpperCase: upperCase,
|
|
61
|
+
},
|
|
62
|
+
setting: {
|
|
63
|
+
initialData: "Resources:\n",
|
|
64
|
+
savePath: path.join(srcPath, SOURCE_PATH.resourceYaml),
|
|
65
|
+
saveFileName: SAVE_FILE_NAME.snsInSqsYaml,
|
|
66
|
+
fileExtension: ".yml",
|
|
67
|
+
isAppend: true
|
|
68
|
+
}
|
|
69
|
+
})
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
return result
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
module.exports = createDataForSubscriptionOutAll;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
##===== [Topic In]
|
|
2
|
+
SubscriptionIn<%- queueName %>:
|
|
3
|
+
Type: AWS::SNS::Subscription
|
|
4
|
+
Properties:
|
|
5
|
+
TopicArn: !Ref In<%- queueName %>
|
|
6
|
+
Endpoint: "arn:aws:sqs:${self:custom.iz_region}:${self:custom.iz_accountId}:${self:custom.iz_resourcePrefix}<%- queueName %>HdrSqs"
|
|
7
|
+
Protocol: "sqs"
|
|
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
|
+
} _%>
|
package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/wbs/functionYaml/data.js
ADDED
|
@@ -0,0 +1,142 @@
|
|
|
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
|
+
|
|
20
|
+
const path = require('path');
|
|
21
|
+
|
|
22
|
+
const { FLOW_SCHEMA_HOOK_STATE } = require('@izara_project/izara-core-library-service-schemas/src/Consts')
|
|
23
|
+
|
|
24
|
+
const { firstLetterUpperCase: upperCase } = require("../../../../../../MainLibs/src/Utils");
|
|
25
|
+
const {
|
|
26
|
+
SOURCE_PATH,
|
|
27
|
+
defaultIamRolePerAction,
|
|
28
|
+
createIamRole,
|
|
29
|
+
RESOURCE_CLASSES,
|
|
30
|
+
SNS_RESOURCE,
|
|
31
|
+
resourceNames,
|
|
32
|
+
DYNAMO_RESOURCE,
|
|
33
|
+
SAVE_FILE_NAME,
|
|
34
|
+
FUNCTION_NAME,
|
|
35
|
+
shortNameHandler,
|
|
36
|
+
externalResourceYaml,
|
|
37
|
+
SOURCE_GENERATE_IAM_ROLE,
|
|
38
|
+
LAMBDA_RESOURCE
|
|
39
|
+
} = require("../../../../../../MainLibs/src/Consts");
|
|
40
|
+
|
|
41
|
+
const templatePath = path.join(__dirname, "template.ejs");
|
|
42
|
+
const hookTemplate = path.join(__dirname, "./hookTemplate.ejs");
|
|
43
|
+
/**
|
|
44
|
+
* receive objectSchema
|
|
45
|
+
* create data for WebSocket handler template
|
|
46
|
+
*
|
|
47
|
+
* @param {Object} objectSchema
|
|
48
|
+
* @return {{templatePath, templateData,setting}}
|
|
49
|
+
*/
|
|
50
|
+
function data(_izContext, srcPath) {
|
|
51
|
+
const handlerType = upperCase("hdrWbs");
|
|
52
|
+
const functionName = FUNCTION_NAME.flowSchemaRegister;
|
|
53
|
+
let functionNameConfig = upperCase(functionName) + upperCase(shortNameHandler(handlerType));
|
|
54
|
+
let additionalResourcePermission = defaultIamRolePerAction();
|
|
55
|
+
let route = "webSocket";
|
|
56
|
+
|
|
57
|
+
additionalResourcePermission.push(
|
|
58
|
+
createIamRole(
|
|
59
|
+
{
|
|
60
|
+
[RESOURCE_CLASSES.lambda]: [
|
|
61
|
+
LAMBDA_RESOURCE.invokeFunction
|
|
62
|
+
]
|
|
63
|
+
},
|
|
64
|
+
[
|
|
65
|
+
resourceNames(RESOURCE_CLASSES.lambda, "GetHdrInv")
|
|
66
|
+
]
|
|
67
|
+
),
|
|
68
|
+
createIamRole(
|
|
69
|
+
{
|
|
70
|
+
[RESOURCE_CLASSES.dynamoDbTable]: [
|
|
71
|
+
DYNAMO_RESOURCE.putItem,
|
|
72
|
+
DYNAMO_RESOURCE.getItem,
|
|
73
|
+
DYNAMO_RESOURCE.query,
|
|
74
|
+
DYNAMO_RESOURCE.deleteItem,
|
|
75
|
+
DYNAMO_RESOURCE.updateItem
|
|
76
|
+
]
|
|
77
|
+
},
|
|
78
|
+
[
|
|
79
|
+
resourceNames(RESOURCE_CLASSES.dynamoDbTable, "WebSocketTask")
|
|
80
|
+
]
|
|
81
|
+
),
|
|
82
|
+
createIamRole(
|
|
83
|
+
{
|
|
84
|
+
"execute-api": [
|
|
85
|
+
"ManageConnections"
|
|
86
|
+
]
|
|
87
|
+
},
|
|
88
|
+
[
|
|
89
|
+
resourceNames(RESOURCE_CLASSES.webSocket)
|
|
90
|
+
]
|
|
91
|
+
)
|
|
92
|
+
)
|
|
93
|
+
|
|
94
|
+
// if (flowSchema?.hook) {
|
|
95
|
+
// for (const [hookName, hookProperties] of Object.entries(flowSchema.hook)) {
|
|
96
|
+
// if (hookName === FLOW_SCHEMA_HOOK_STATE.beforeCreate) {
|
|
97
|
+
// for (const hookFunction of hookProperties.functionList) {
|
|
98
|
+
// if ((hookFunction.event.hasOwnProperty("initialEvent") && (hookFunction.event.initialEvent === true))) {
|
|
99
|
+
// if (hookFunction?.permission) {
|
|
100
|
+
// for (const permission of hookFunction.permission) {
|
|
101
|
+
// additionalResourcePermission.push(
|
|
102
|
+
// createIamRole(
|
|
103
|
+
// permission.action,
|
|
104
|
+
// permission.resource.map(resource =>
|
|
105
|
+
// externalResourceYaml(
|
|
106
|
+
// resource.resource,
|
|
107
|
+
// resource.resourceName,
|
|
108
|
+
// resource.serviceTag),
|
|
109
|
+
// permission.effect
|
|
110
|
+
// )
|
|
111
|
+
// )
|
|
112
|
+
// )
|
|
113
|
+
// }
|
|
114
|
+
// }
|
|
115
|
+
// }
|
|
116
|
+
// }
|
|
117
|
+
// }
|
|
118
|
+
// }
|
|
119
|
+
// }
|
|
120
|
+
|
|
121
|
+
// console.log("additionalResourcePermission in createObjectS3", JSON.stringify(additionalResourcePermission))
|
|
122
|
+
return [{
|
|
123
|
+
templatePath: templatePath,
|
|
124
|
+
templateData: {
|
|
125
|
+
resourceLocation: SOURCE_PATH.resourceLocationFlowSchemaRegister,
|
|
126
|
+
additionalResourcePermission,
|
|
127
|
+
route,
|
|
128
|
+
functionName,
|
|
129
|
+
handlerType,
|
|
130
|
+
roleName: SOURCE_GENERATE_IAM_ROLE.RegisterRole,
|
|
131
|
+
functionNameConfig,
|
|
132
|
+
},
|
|
133
|
+
setting: {
|
|
134
|
+
savePath: path.join(srcPath, SOURCE_PATH.appYaml),
|
|
135
|
+
saveFileName: upperCase(SAVE_FILE_NAME.flowSchema),
|
|
136
|
+
fileExtension: ".yml",
|
|
137
|
+
isAppend: true
|
|
138
|
+
}
|
|
139
|
+
}]
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
module.exports = data;
|
|
@@ -0,0 +1,18 @@
|
|
|
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: <%- route %>
|
|
8
|
+
# authorizer: ${self:custom.iz_authorizerAppLevel}
|
|
9
|
+
# identifierResource: 'route.request.header.Auth'
|
|
10
|
+
role: <%- roleName %>Role
|
|
11
|
+
#<#<%- functionName %><%- handlerType %>IamRole#>
|
|
12
|
+
#<#/<%- functionName %><%- handlerType %>IamRole#>
|
|
13
|
+
<%_ function firstLetterUpperCase(text){
|
|
14
|
+
return text.charAt(0).toUpperCase() + text.slice(1)
|
|
15
|
+
} _%>
|
|
16
|
+
<%_ function firstLetterLowerCase(str) {
|
|
17
|
+
return str.charAt(0).toLowerCase() + str.slice(1)
|
|
18
|
+
} _%>
|
|
@@ -0,0 +1,64 @@
|
|
|
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
|
+
|
|
20
|
+
const path = require('path');
|
|
21
|
+
const { FLOW_SCHEMA_HOOK_STATE } = require('@izara_project/izara-core-library-service-schemas/src/Consts')
|
|
22
|
+
|
|
23
|
+
const { SOURCE_PATH, FUNCTION_NAME, SOURCE_GENERATE_IAM_ROLE } = require("../../../../../../MainLibs/src/Consts");
|
|
24
|
+
const { firstLetterLowerCase: lowerCase, firstLetterUpperCase: upperCase } = require("../../../../../../MainLibs/src/Utils");
|
|
25
|
+
const templatePath = path.join(__dirname, "template.ejs")
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* receive objectSchema
|
|
29
|
+
* create data for WebSocket handler template
|
|
30
|
+
*
|
|
31
|
+
* @param {Object} objectSchema
|
|
32
|
+
* @return {{templatePath, templateData,setting}}
|
|
33
|
+
*/
|
|
34
|
+
function data(_izContext, flowSchema, srcPath) {
|
|
35
|
+
return [createParamsForCreateSource(_izContext, flowSchema, srcPath)]
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
function createParamsForCreateSource(_izContext, srcPath) {
|
|
39
|
+
// let functionName = upperCase(FUNCTION_NAME.createObjectS3)
|
|
40
|
+
let functionName = FUNCTION_NAME.flowSchemaRegister
|
|
41
|
+
let handlerType = "HdrWbs"
|
|
42
|
+
let hook = false;
|
|
43
|
+
let hookFunctionName;
|
|
44
|
+
let isAsync = false;
|
|
45
|
+
return {
|
|
46
|
+
templatePath: templatePath,
|
|
47
|
+
templateData: {
|
|
48
|
+
hook: hook,
|
|
49
|
+
hookFunctionName: hookFunctionName,
|
|
50
|
+
isAsync,
|
|
51
|
+
functionName: functionName,
|
|
52
|
+
firstLetterUpperCase: upperCase,
|
|
53
|
+
roleName: SOURCE_GENERATE_IAM_ROLE.RegisterRole,
|
|
54
|
+
routeName: FUNCTION_NAME.flowSchemaRegister,
|
|
55
|
+
},
|
|
56
|
+
setting: {
|
|
57
|
+
savePath: path.join(srcPath, SOURCE_PATH.flowSchemaRegister, 'source/'),
|
|
58
|
+
saveFileName: `${upperCase(functionName)}_${handlerType}`,
|
|
59
|
+
fileExtension: ".js",
|
|
60
|
+
isAppend: false
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
module.exports = data
|
package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/wbs/handler/template.ejs
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright (C) 2021 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
|
+
|
|
20
|
+
const { middlewareHandler, consts } = require("@izara_project/izara-middleware");
|
|
21
|
+
// const AWS = require('aws-sdk');
|
|
22
|
+
// const api = new AWS.ApiGatewayManagementApi({ endpoint: process.env.iz_webSocketEndpoint });
|
|
23
|
+
const dynamodbSharedLib = require('@izara_project/izara-core-library-dynamodb');
|
|
24
|
+
const callingFlowSharedLib = require('@izara_project/izara-core-calling-flow');
|
|
25
|
+
const hash = require('object-hash');
|
|
26
|
+
// const coreConsts = require("@izara_project/izara-core-library-core/src/Consts");
|
|
27
|
+
const consts = require('@izara_project/izara-middleware/src/MiddlewareCore/Consts');
|
|
28
|
+
const { postToConnection } = require("../../libs/source/ImportDataLib");
|
|
29
|
+
const { <%- functionName%>Main } = require("./<%- firstLetterUpperCase(functionName) %>_Main");
|
|
30
|
+
|
|
31
|
+
module.exports.main = middlewareHandler.wrap(async (event, context, callback) => {
|
|
32
|
+
|
|
33
|
+
event._izContext.logger.debug('Event:', event);
|
|
34
|
+
|
|
35
|
+
try {
|
|
36
|
+
|
|
37
|
+
if (event.requestContext) {
|
|
38
|
+
const route = event.requestContext.routeKey;
|
|
39
|
+
const connectionId = event.requestContext.connectionId;
|
|
40
|
+
let correlationId = event._izContext.correlationIds.get(consts.X_CORRELATION_ID)
|
|
41
|
+
|
|
42
|
+
switch (route) {
|
|
43
|
+
case '$default':
|
|
44
|
+
console.log('Received unknown route:', route);
|
|
45
|
+
break
|
|
46
|
+
case '<%- routeName%>':
|
|
47
|
+
console.log("event in route <%- routeName%>", event);
|
|
48
|
+
let eventParams = JSON.parse(event.body)
|
|
49
|
+
|
|
50
|
+
await dynamodbSharedLib.putItem(
|
|
51
|
+
event._izContext,
|
|
52
|
+
await dynamodbSharedLib.tableName(event._izContext, "WebSocketTask"),
|
|
53
|
+
{
|
|
54
|
+
taskKey: correlationId,
|
|
55
|
+
connectionId: connectionId,
|
|
56
|
+
}
|
|
57
|
+
)
|
|
58
|
+
|
|
59
|
+
let callingFlow = eventParams?.callingFlow ? eventParams.callingFlow : {};
|
|
60
|
+
|
|
61
|
+
await <%- functionName%>Main(
|
|
62
|
+
event._izContext,
|
|
63
|
+
eventParams,
|
|
64
|
+
callingFlowSharedLib.addCallingFlowToPassOnProperties(callingFlow)
|
|
65
|
+
//(<additionalParams>)
|
|
66
|
+
//(</additionalParams>)
|
|
67
|
+
)
|
|
68
|
+
break
|
|
69
|
+
}
|
|
70
|
+
} else {
|
|
71
|
+
const connId = event.connId;
|
|
72
|
+
// await postMessage({ message: event.message }, connId);
|
|
73
|
+
await postToConnection({ message: event.message }, connId);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
return (izara.response.webSocketSuccess());
|
|
77
|
+
|
|
78
|
+
} catch (err) {
|
|
79
|
+
const connId = event.requestContext.connectionId
|
|
80
|
+
event._izContext.logger.error('Error, WebSocket: ', err);
|
|
81
|
+
// await sendErrorMessage({ message: err.message }, connId);
|
|
82
|
+
await postToConnection({ message: err.message }, connId);
|
|
83
|
+
return (izara.response.failure(err));
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
<%_ const join = require('path').join _%>
|
|
87
|
+
<%_ function upperCase (text) {
|
|
88
|
+
return text.charAt(0).toUpperCase() + text.slice(1)
|
|
89
|
+
} _%>
|
package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/wbs/mainFunction/data.js
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
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
|
+
|
|
20
|
+
const path = require('path');
|
|
21
|
+
|
|
22
|
+
const { SOURCE_PATH, FUNCTION_NAME } = require("../../../../../../MainLibs/src/Consts");
|
|
23
|
+
const { firstLetterLowerCase: lowerCase, firstLetterUpperCase: upperCase } = require("../../../../../../MainLibs/src/Utils");
|
|
24
|
+
const templatePath = path.join(__dirname, "template.ejs");
|
|
25
|
+
const getObjectSchema = require('@izara_project/izara-core-library-service-schemas/src/GetObjectSchema')
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* receive objectSchema
|
|
29
|
+
* create data for WebSocket Main template
|
|
30
|
+
*
|
|
31
|
+
* @param {Object} objectSchema
|
|
32
|
+
* @return {{templatePath, templateData,setting}}
|
|
33
|
+
*/
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
function data(_izContext, flowSchema, srcPath) {
|
|
37
|
+
return [createParamsForCreateSource(_izContext, flowSchema, srcPath)]
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function createParamsForCreateSource(_izContext, srcPath) {
|
|
41
|
+
const functionName = upperCase(FUNCTION_NAME.flowSchemaRegister)
|
|
42
|
+
return {
|
|
43
|
+
templatePath: templatePath,
|
|
44
|
+
templateData: {
|
|
45
|
+
functionMain: FUNCTION_NAME.flowSchemaRegister + 'Main',
|
|
46
|
+
},
|
|
47
|
+
setting: {
|
|
48
|
+
savePath: path.join(srcPath, SOURCE_PATH.flowSchemaRegister, 'source/'),
|
|
49
|
+
saveFileName: `${functionName}_Main`,
|
|
50
|
+
fileExtension: ".js",
|
|
51
|
+
isAppend: false
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
module.exports = data
|