@izara_project/izara-market-library-service-schemas 1.0.3 → 1.0.5
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 +46 -0
- package/src/GenerateCodeLibs/src/GenerateCodeLibs.js +69 -8
- package/src/TemplateManager/src/CreateRelationship/createRelationship/functionYaml/HdrApi/data.js +111 -0
- package/src/TemplateManager/src/CreateRelationship/createRelationship/functionYaml/HdrDsq/data.js +132 -0
- package/src/TemplateManager/src/CreateRelationship/createRelationship/functionYaml/HdrInv/data.js +110 -0
- package/src/TemplateManager/src/CreateRelationship/createRelationship/functionYaml/HdrSqs/data.js +132 -0
- package/src/TemplateManager/src/CreateRelationship/createRelationship/mainFunction/data.js +59 -0
- package/src/TemplateManager/src/CreateRelationship/createRelationship/mainFunction/template.ejs +338 -0
- package/src/TemplateManager/src/CreateRelationship/createRelationship/perAction/HdrApi/data.js +58 -0
- package/src/TemplateManager/src/CreateRelationship/createRelationship/perAction/HdrApi/request.json +0 -0
- package/src/TemplateManager/src/CreateRelationship/createRelationship/perAction/HdrApi/template.ejs +120 -0
- package/src/TemplateManager/src/CreateRelationship/createRelationship/perAction/HdrDsq/data.js +60 -0
- package/src/TemplateManager/src/CreateRelationship/createRelationship/perAction/HdrDsq/request.json +0 -0
- package/src/TemplateManager/src/CreateRelationship/createRelationship/perAction/HdrDsq/template.ejs +167 -0
- package/src/TemplateManager/src/CreateRelationship/createRelationship/perAction/HdrInv/data.js +60 -0
- package/src/TemplateManager/src/CreateRelationship/createRelationship/perAction/HdrInv/request.json +0 -0
- package/src/TemplateManager/src/CreateRelationship/createRelationship/perAction/HdrInv/template.ejs +107 -0
- package/src/TemplateManager/src/CreateRelationship/createRelationship/perAction/HdrSqs/data.js +60 -0
- package/src/TemplateManager/src/CreateRelationship/createRelationship/perAction/HdrSqs/request.json +0 -0
- package/src/TemplateManager/src/CreateRelationship/createRelationship/perAction/HdrSqs/template.ejs +146 -0
- package/src/TemplateManager/src/CreateRelationship/createRelationship/perAction/request.json +30 -0
- package/src/TemplateManager/src/CreateRelationship/createRelationship/sns-in-sqs/data.js +80 -0
- package/src/TemplateManager/src/CreateRelationship/createRelationshipComplete/functionYaml/data.js +133 -0
- package/src/TemplateManager/src/CreateRelationship/createRelationshipComplete/functionYaml/request.json +0 -0
- package/src/TemplateManager/src/CreateRelationship/createRelationshipComplete/functionYaml/template.ejs +33 -0
- package/src/TemplateManager/src/CreateRelationship/createRelationshipComplete/handler/HdrSqs/data.js +62 -0
- package/src/TemplateManager/src/CreateRelationship/createRelationshipComplete/handler/HdrSqs/request.json +0 -0
- package/src/TemplateManager/src/CreateRelationship/createRelationshipComplete/handler/HdrSqs/template.ejs +125 -0
- package/src/TemplateManager/src/CreateRelationship/createRelationshipComplete/mainFunction/data.js +56 -0
- package/src/TemplateManager/src/CreateRelationship/createRelationshipComplete/mainFunction/request.json +0 -0
- package/src/TemplateManager/src/CreateRelationship/createRelationshipComplete/mainFunction/template.ejs +137 -0
- package/src/TemplateManager/src/CreateRelationship/createRelationshipComplete/sns-in-sqs/data.js +72 -0
- package/src/TemplateManager/src/CreateRelationship/createRelationshipComplete/sns-in-sqs/request.json +0 -0
- package/src/TemplateManager/src/CreateRelationship/createRelationshipComplete/sns-in-sqs/template.ejs +47 -0
- package/src/TemplateManager/src/CreateRelationship/createRelationshipComplete/sns-out/data.js +72 -0
- package/src/TemplateManager/src/CreateRelationship/createRelationshipComplete/sns-out/request.json +0 -0
- package/src/TemplateManager/src/GenerateCode.js +176 -43
- package/src/TemplateManager/src/{FunctionYaml → PerActionEndpoint/FunctionYaml}/HdrApi/data.js +7 -23
- package/src/TemplateManager/src/{FunctionYaml → PerActionEndpoint/FunctionYaml}/HdrDsq/data.js +10 -24
- package/src/TemplateManager/src/{FunctionYaml → PerActionEndpoint/FunctionYaml}/HdrInv/data.js +6 -23
- package/src/TemplateManager/src/{FunctionYaml → PerActionEndpoint/FunctionYaml}/HdrSqs/data.js +14 -33
- package/src/TemplateManager/src/{FunctionYaml → PerActionEndpoint/FunctionYaml}/HdrSqs/template.ejs +2 -2
- package/src/TemplateManager/src/PerActionEndpoint/Handler/HdrApi/data.js +2 -16
- package/src/TemplateManager/src/PerActionEndpoint/Handler/HdrDsq/data.js +3 -17
- package/src/TemplateManager/src/PerActionEndpoint/Handler/HdrInv/data.js +3 -16
- package/src/TemplateManager/src/PerActionEndpoint/Handler/HdrSqs/data.js +4 -17
- package/src/TemplateManager/src/PerActionEndpoint/MainFunction/Get/data.js +0 -15
- package/src/TemplateManager/src/PerActionEndpoint/MainFunction/Get/template.ejs +28 -30
- package/src/TemplateManager/src/PerActionEndpoint/MainFunction/Get/testParam.json +5 -0
- package/src/TemplateManager/src/ResourceYaml/dynamodb/awaitingMultipleStepData.js +95 -0
- package/src/TemplateManager/src/ResourceYaml/dynamodb/mainResourcePerObjectSchemaData.js +7 -29
- package/src/TemplateManager/src/ResourceYaml/dynamodb/processLogicalAndFindData.js +5 -8
- package/src/TemplateManager/src/ResourceYaml/sns-in-sqs/defaultSnsInSqsForFindDataAndProcessLogical.js +3 -6
- package/src/TemplateManager/src/ResourceYaml/sns-in-sqs/snsAndSqsPerActiondata.js +6 -6
- package/src/TemplateManager/src/ResourceYaml/sns-in-sqs/sqsTemplate.ejs +1 -0
- package/src/TemplateManager/src/ResourceYaml/sns-out/data.js +89 -0
- package/src/TemplateManager/src/ResourceYaml/sns-out/request.json +3 -0
- package/src/TemplateManager/src/ResourceYaml/sns-out/template.ejs +10 -0
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRalationshipComplete/functionYaml/data.js +135 -0
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRalationshipComplete/functionYaml/request.json +3 -0
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRalationshipComplete/functionYaml/template.ejs +33 -0
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRalationshipComplete/handler/HdrSqs/data.js +62 -0
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRalationshipComplete/handler/HdrSqs/request.json +0 -0
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRalationshipComplete/handler/HdrSqs/template.ejs +127 -0
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRalationshipComplete/mainFunction/data.js +56 -0
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRalationshipComplete/mainFunction/request.json +1 -0
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRalationshipComplete/mainFunction/template.ejs +140 -0
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRalationshipComplete/sns-in-sqs/data.js +72 -0
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRalationshipComplete/sns-in-sqs/request.json +3 -0
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRalationshipComplete/sns-in-sqs/template.ejs +46 -0
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRalationshipComplete/sns-out/data.js +71 -0
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRalationshipComplete/sns-out/request.json +3 -0
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRelationship/functionYaml/HdrApi/data.js +112 -0
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRelationship/functionYaml/HdrApi/request.json +0 -0
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRelationship/functionYaml/HdrApi/template.ejs +33 -0
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRelationship/functionYaml/HdrDsq/data.js +128 -0
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRelationship/functionYaml/HdrDsq/request.json +0 -0
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRelationship/functionYaml/HdrInv/data.js +110 -0
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRelationship/functionYaml/HdrInv/request.json +0 -0
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRelationship/functionYaml/HdrSqs/data.js +131 -0
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRelationship/functionYaml/HdrSqs/request.json +0 -0
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRelationship/mainFunction/data.js +65 -0
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRelationship/mainFunction/request.json +1 -0
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRelationship/mainFunction/template.ejs +331 -0
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRelationship/perAction/HdrApi/data.js +59 -0
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRelationship/perAction/HdrApi/request.json +7 -0
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRelationship/perAction/HdrApi/template.ejs +120 -0
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRelationship/perAction/HdrDsq/data.js +59 -0
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRelationship/perAction/HdrDsq/request.json +7 -0
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRelationship/perAction/HdrDsq/template.ejs +167 -0
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRelationship/perAction/HdrInv/data.js +62 -0
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRelationship/perAction/HdrInv/request.json +5 -0
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRelationship/perAction/HdrInv/template.ejs +126 -0
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRelationship/perAction/HdrSqs/data.js +59 -0
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRelationship/perAction/HdrSqs/request.json +7 -0
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRelationship/perAction/HdrSqs/template.ejs +146 -0
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRelationship/perAction/request.json +30 -0
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRelationship/sns-in-sqs/data.js +90 -0
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRelationship/sns-in-sqs/request.json +3 -0
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRelationship/sns-out/data.js +70 -0
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRelationship/sns-out/request.json +3 -0
- package/src/TemplateManager/src/externalService/LambdaRole/data.js +72 -25
- package/src/TemplateManager/src/externalService/LambdaRole/template.ejs +8 -3
- package/src/TemplateManager/src/externalService/SnsTopicSubscriotions/data.js +51 -3
- package/src/TemplateManager/src/externalService/SnsTopicSubscriotions/request.json +12 -0
- package/src/TemplateManager/src/externalService/SnsTopicSubscriotions/template.ejs +10 -14
- package/src/TemplateManager/src/libs/Consts.js +52 -23
- package/src/TemplateManager/src/MainResourcesYaml/CreateSourceData.js +0 -76
- package/src/TemplateManager/src/MainResourcesYaml/TemplateAndData/DynamoDbMain/Data/MainDynamoDbYamlData.js +0 -155
- package/src/TemplateManager/src/MainResourcesYaml/TemplateAndData/DynamoDbMain/Template/DynamoDb.ejs +0 -31
- package/src/TemplateManager/src/MainResourcesYaml/TemplateAndData/DynamoDbMain/Template/DynamoDb.exampleData.js +0 -12
- /package/src/TemplateManager/src/{FunctionYaml → PerActionEndpoint/FunctionYaml}/HdrApi/request.json +0 -0
- /package/src/TemplateManager/src/{FunctionYaml → PerActionEndpoint/FunctionYaml}/HdrApi/template.ejs +0 -0
- /package/src/TemplateManager/src/{FunctionYaml → PerActionEndpoint/FunctionYaml}/HdrDsq/request.json +0 -0
- /package/src/TemplateManager/src/{FunctionYaml → PerActionEndpoint/FunctionYaml}/HdrDsq/template.ejs +0 -0
- /package/src/TemplateManager/src/{FunctionYaml → PerActionEndpoint/FunctionYaml}/HdrInv/example req.js +0 -0
- /package/src/TemplateManager/src/{FunctionYaml → PerActionEndpoint/FunctionYaml}/HdrInv/request.json +0 -0
- /package/src/TemplateManager/src/{FunctionYaml → PerActionEndpoint/FunctionYaml}/HdrInv/template.ejs +0 -0
- /package/src/TemplateManager/src/{FunctionYaml → PerActionEndpoint/FunctionYaml}/HdrSqs/request.json +0 -0
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright (C) 2020 Sven Mason <http://izara.io>
|
|
3
|
+
|
|
4
|
+
This program is free software: you can redistribute it and/or modify
|
|
5
|
+
it under the terms of the GNU Affero General Public License as
|
|
6
|
+
published by the Free Software Foundation, either version 3 of the
|
|
7
|
+
License, or (at your option) any later version.
|
|
8
|
+
|
|
9
|
+
This program is distributed in the hope that it will be useful,
|
|
10
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
11
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
12
|
+
GNU Affero General Public License for more details.
|
|
13
|
+
|
|
14
|
+
You should have received a copy of the GNU Affero General Public License
|
|
15
|
+
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
'use strict';
|
|
19
|
+
const izara = require("@izara_project/izara-middleware");
|
|
20
|
+
const middleware = izara.middlewareHandler;
|
|
21
|
+
const callingFlowSharedLib = require('@izara_project/izara-shared/src/CallingFlowSharedLib')
|
|
22
|
+
const {
|
|
23
|
+
validateSchemaMiddleware
|
|
24
|
+
} = require('@izara_project/izara-market-library-service-schemas/src/GenerateCodeLibs/src/GenerateCodeLibs');
|
|
25
|
+
const Logger = require('@izara_project/izara-core-library-logger');
|
|
26
|
+
const recordHandlerSharedLib = require('@izara_project/izara-shared').recordHandlerSharedLib
|
|
27
|
+
|
|
28
|
+
const updateRelationship = require('./UpdateRelationship_Main');
|
|
29
|
+
|
|
30
|
+
middleware.setValidatorSchema(recordHandlerSharedLib.baseValidatorSchema());
|
|
31
|
+
|
|
32
|
+
// validate event params in middleware before into function
|
|
33
|
+
let validatorSchema = {
|
|
34
|
+
type: "object",
|
|
35
|
+
required: ["objects", "relId", "relType", "relationshipProperties"],
|
|
36
|
+
properties: {
|
|
37
|
+
objects: {
|
|
38
|
+
type: "array",
|
|
39
|
+
minItems: 2,
|
|
40
|
+
maxItems: 2,
|
|
41
|
+
items: {
|
|
42
|
+
type: 'object',
|
|
43
|
+
required: ["objType", "identifiers"],
|
|
44
|
+
properties: {
|
|
45
|
+
objType: {
|
|
46
|
+
type: "object",
|
|
47
|
+
required: ["serviceTag", "objectType"],
|
|
48
|
+
properties: {
|
|
49
|
+
serviceTag: izara.validatorSchema.stringNotEmpty(),
|
|
50
|
+
objectType: izara.validatorSchema.stringNotEmpty()
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
identifiers: {
|
|
54
|
+
type: "object",
|
|
55
|
+
minProperties: 1
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
},
|
|
60
|
+
relType: {
|
|
61
|
+
type: "object",
|
|
62
|
+
required: ["relationshipTag", "serviceTag"],
|
|
63
|
+
properties: {
|
|
64
|
+
relationshipTag: izara.validatorSchema.stringNotEmpty(),
|
|
65
|
+
serviceTag: {
|
|
66
|
+
type: 'string',
|
|
67
|
+
pattern: "^[a-zA-Z0-9_-]+$",
|
|
68
|
+
enum: [process.env.iz_serviceTag]
|
|
69
|
+
},
|
|
70
|
+
}
|
|
71
|
+
},
|
|
72
|
+
relId: izara.validatorSchema.stringNotEmpty(),
|
|
73
|
+
relationshipProperties: {
|
|
74
|
+
type: 'object',
|
|
75
|
+
minProperties: 1,
|
|
76
|
+
},
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
//(<globalVarible>
|
|
81
|
+
//</globalVarible>)
|
|
82
|
+
|
|
83
|
+
// validate event params in middleware before into main function
|
|
84
|
+
validatorSchema = callingFlowSharedLib.addOptionalCallingFlowToValidatorSchema(validatorSchema);
|
|
85
|
+
// if need to validate authorizer or additional params , add code to hook tag below
|
|
86
|
+
|
|
87
|
+
//(<afterValidateWith>)
|
|
88
|
+
//(</afterValidateWith>)
|
|
89
|
+
|
|
90
|
+
module.exports.main = middleware.wrap(async (event, context, callback) => {
|
|
91
|
+
|
|
92
|
+
try {
|
|
93
|
+
|
|
94
|
+
let recordPromises = []; // final return
|
|
95
|
+
|
|
96
|
+
// loop each record and send to mainFunction
|
|
97
|
+
await Promise.all(event.Records.map(async record => { // promise.all for map() function
|
|
98
|
+
|
|
99
|
+
let passOnProperties = []
|
|
100
|
+
|
|
101
|
+
// --- validate message (and MessageAttributes)
|
|
102
|
+
await recordHandlerSharedLib.validateRecord(
|
|
103
|
+
record, // one record will send to mainFunction
|
|
104
|
+
"<%- queueName %>", // queue name that need to retry or send to dlq
|
|
105
|
+
validatorSchema, // schema for record.Message
|
|
106
|
+
// messageAttributeValidatorSchema // ----- for msgAttr default is null -> do not send this parameter if not want to validate msgAtt
|
|
107
|
+
);
|
|
108
|
+
|
|
109
|
+
// add argument (to invoke lambda) to passOnProperties[]
|
|
110
|
+
passOnProperties.push(record.body.Message)
|
|
111
|
+
passOnProperties.push(callingFlowSharedLib.addCallingFlowToPassOnProperties(record.body.Message));
|
|
112
|
+
//(<afterPutParamIntoMainFunction>)
|
|
113
|
+
//(</afterPutParamIntoMainFunction>)
|
|
114
|
+
|
|
115
|
+
record._izContext.logger.debug('passOnProperties in handler', passOnProperties);
|
|
116
|
+
|
|
117
|
+
// call recordHandlerSharedLib.recordHandler with 3 parameters and return promise(resolve)
|
|
118
|
+
let recordPromise = recordHandlerSharedLib.recordHandler(
|
|
119
|
+
record, // one record will send to mainFunction
|
|
120
|
+
<%- functionName %>.<%- functionName %>, // mainFunction that need to invoke.
|
|
121
|
+
"<%- queueName %>", // queue name that need to retry or send to dlq
|
|
122
|
+
passOnProperties, // all parameters that mainFunction needed.
|
|
123
|
+
);
|
|
124
|
+
record._izContext.logger.debug('after recordPromise in handler');
|
|
125
|
+
recordPromises.push(recordPromise); // push promise to recordPromises
|
|
126
|
+
})) //end record
|
|
127
|
+
|
|
128
|
+
Logger.debug('before Promise.all(recordPromises) in handler');
|
|
129
|
+
try {
|
|
130
|
+
await Promise.all(recordPromises); // await all promises
|
|
131
|
+
return event.Records // return all for local test
|
|
132
|
+
} catch {
|
|
133
|
+
Logger.debug('Promise.all(recordPromises) in handler threw error (at least one record did no resolve)');
|
|
134
|
+
}
|
|
135
|
+
Logger.debug('after Promise.all(recordPromises) in handler');
|
|
136
|
+
} catch (err) {
|
|
137
|
+
Logger.error('Unhandled Error, updateRelationshipHdrDsq:', err);
|
|
138
|
+
throw (err);
|
|
139
|
+
}
|
|
140
|
+
});
|
|
141
|
+
<%_ function firstLetterUpperCase(text) {
|
|
142
|
+
return text.charAt(0).toUpperCase() + text.slice(1)
|
|
143
|
+
} _%>
|
|
144
|
+
<%_ function firstLetterLowerCase(str) {
|
|
145
|
+
return str.charAt(0).toLowerCase() + str.slice(1)
|
|
146
|
+
} _%>
|
package/src/TemplateManager/src/UpdateRelationshipSchema/updateRelationship/perAction/request.json
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
{
|
|
2
|
+
"objects": [
|
|
3
|
+
{
|
|
4
|
+
"objType": {
|
|
5
|
+
"objectType": "Sunny",
|
|
6
|
+
"serviceTag": "GenerateCodeTemplateBas"
|
|
7
|
+
},
|
|
8
|
+
"identifiers": {
|
|
9
|
+
"personId": "TestUpdateNode1"
|
|
10
|
+
}
|
|
11
|
+
},
|
|
12
|
+
{
|
|
13
|
+
"objType": {
|
|
14
|
+
"objectType": "Weather",
|
|
15
|
+
"serviceTag": "GenerateCodeTemplateBas"
|
|
16
|
+
},
|
|
17
|
+
"identifiers": {
|
|
18
|
+
"personId": "TestUpdateNode2"
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
],
|
|
22
|
+
"relType": {
|
|
23
|
+
"relationshipTag": "RelTag",
|
|
24
|
+
"serviceTag": "GenerateCodeTemplateBas"
|
|
25
|
+
},
|
|
26
|
+
"relId": "aa-bb-cc",
|
|
27
|
+
"relationshipProperties": {
|
|
28
|
+
"name": "bas007"
|
|
29
|
+
}
|
|
30
|
+
}
|
package/src/TemplateManager/src/UpdateRelationshipSchema/updateRelationship/sns-in-sqs/data.js
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
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
|
+
|
|
29
|
+
const STORAGE_TYPES = {
|
|
30
|
+
dynamoDB: "dynamoDB",
|
|
31
|
+
graph: "graph"
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const { firstLetterLowerCase: lowerCase, firstLetterUpperCase: upperCase, firstLetterUpperCase } = require("../../../../../MainLibs/src/Utils")
|
|
35
|
+
const { DEFAULT_HANDLER_PER_ACTION, SOURCE_PATH, SAVE_FILE_NAME, FUNCTION_NAME, HANDLER } = require("../../../libs/Consts");
|
|
36
|
+
const snsTemplatePath = path.join(__dirname, "../../../ResourceYaml/sns-in-sqs/snsTemplate.ejs")
|
|
37
|
+
const sqsTemplatePath = path.join(__dirname, "../../../ResourceYaml/sns-in-sqs/sqsTemplate.ejs")
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* create data for dynamoDbYaml tempalte from objectSchema
|
|
41
|
+
* return array of dynamoDb data
|
|
42
|
+
* because one objectSchema can create multiple dynamoDb table
|
|
43
|
+
*
|
|
44
|
+
* @param {Object} _izContext
|
|
45
|
+
* @param {String} saveFilePath
|
|
46
|
+
* @returns {Object[]} - data of multiple dynamoDb template
|
|
47
|
+
*/
|
|
48
|
+
|
|
49
|
+
function createDataForDefaultSnsInSqs(_izContext, srcPath) {
|
|
50
|
+
let resultsForCreateDefaultSnsInSqs = [];
|
|
51
|
+
const defaultSnsInSqsDataList = [
|
|
52
|
+
{
|
|
53
|
+
queueName: upperCase(FUNCTION_NAME.updateRel)
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
queueName: upperCase(FUNCTION_NAME.updateRel) + upperCase(HANDLER.hdrDsq)
|
|
57
|
+
}
|
|
58
|
+
]
|
|
59
|
+
|
|
60
|
+
for (let defaultSnsInSqsData of defaultSnsInSqsDataList) {
|
|
61
|
+
if (defaultSnsInSqsData.queueName.includes("HdrDsq")) {
|
|
62
|
+
resultsForCreateDefaultSnsInSqs.push({
|
|
63
|
+
templatePath: sqsTemplatePath,
|
|
64
|
+
templateData: defaultSnsInSqsData,
|
|
65
|
+
setting: {
|
|
66
|
+
initialData: "Resources:\n",
|
|
67
|
+
savePath: path.join(srcPath, SOURCE_PATH.resourceYaml),
|
|
68
|
+
saveFileName: SAVE_FILE_NAME.snsInSqsYaml,
|
|
69
|
+
fileExtension: '.yml',
|
|
70
|
+
isAppend: true
|
|
71
|
+
}
|
|
72
|
+
})
|
|
73
|
+
} else {
|
|
74
|
+
resultsForCreateDefaultSnsInSqs.push({
|
|
75
|
+
templatePath: snsTemplatePath,
|
|
76
|
+
templateData: defaultSnsInSqsData,
|
|
77
|
+
setting: {
|
|
78
|
+
initialData: "Resources:\n",
|
|
79
|
+
savePath: path.join(srcPath, SOURCE_PATH.resourceYaml),
|
|
80
|
+
saveFileName: SAVE_FILE_NAME.snsInSqsYaml,
|
|
81
|
+
fileExtension: ".yml",
|
|
82
|
+
isAppend: true
|
|
83
|
+
}
|
|
84
|
+
})
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
return resultsForCreateDefaultSnsInSqs;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
module.exports = createDataForDefaultSnsInSqs;
|
|
@@ -0,0 +1,70 @@
|
|
|
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
|
+
|
|
29
|
+
const STORAGE_TYPES = {
|
|
30
|
+
dynamoDB: "dynamoDB",
|
|
31
|
+
graph: "graph"
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const { firstLetterLowerCase: lowerCase, firstLetterUpperCase: upperCase, firstLetterUpperCase } = require("../../../../../MainLibs/src/Utils")
|
|
35
|
+
const { DEFAULT_HANDLER_PER_ACTION, SOURCE_PATH, SAVE_FILE_NAME, FUNCTION_NAME } = require("../../../libs/Consts");
|
|
36
|
+
const templatePath = path.join(__dirname, '../../../ResourceYaml/sns-out/template.ejs')
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* create data for dynamoDbYaml tempalte from objectSchema
|
|
40
|
+
* return array of dynamoDb data
|
|
41
|
+
* because one objectSchema can create multiple dynamoDb table
|
|
42
|
+
*
|
|
43
|
+
* @param {Object} _izContext
|
|
44
|
+
* @param {String} saveFilePath
|
|
45
|
+
* @returns {Object[]} - data of multiple dynamoDb template
|
|
46
|
+
*/
|
|
47
|
+
|
|
48
|
+
function createDefaultSnsOut(_izContext, srcPath) {
|
|
49
|
+
const createSourceParams = createParamsForCreateSource(_izContext, srcPath)
|
|
50
|
+
return [createSourceParams]
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
function createParamsForCreateSource(_izContext, srcPath) {
|
|
54
|
+
let queueName = FUNCTION_NAME.updateRel
|
|
55
|
+
return {
|
|
56
|
+
templatePath: templatePath,
|
|
57
|
+
templateData: {
|
|
58
|
+
queueName: upperCase(queueName)
|
|
59
|
+
},
|
|
60
|
+
setting: {
|
|
61
|
+
initialData: 'Resources:\n',
|
|
62
|
+
savePath: path.join(srcPath, SOURCE_PATH.resourceYaml),
|
|
63
|
+
saveFileName: SAVE_FILE_NAME.snsOutYaml,
|
|
64
|
+
fileExtension: '.yml',
|
|
65
|
+
isAppend: true
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
module.exports = createDefaultSnsOut
|
|
@@ -23,12 +23,11 @@ const { ACTIONS, HANDLER, STORAGE_TYPES } = require('@izara_project/izara-core-l
|
|
|
23
23
|
const { getGraphServiceNameFromGraphServerTagWithCache } = require('@izara_project/izara-core-library-service-schemas/src/ServiceConfig')
|
|
24
24
|
|
|
25
25
|
const { firstLetterLowerCase: lowerCase, firstLetterUpperCase: upperCase } = require("../../../../MainLibs/src/Utils")
|
|
26
|
-
const { DEFAULT_HANDLER_PER_ACTION, createIamRole, resourceNames, RESOURCE_CLASSES, DEFAULT_LAMBDA_ROLE_PER_ACTION, SOURCE_PATH, externalResourceName, } = require("../../libs/Consts");
|
|
26
|
+
const { DEFAULT_HANDLER_PER_ACTION, createIamRole, resourceNames, RESOURCE_CLASSES, DEFAULT_LAMBDA_ROLE_PER_ACTION, SOURCE_PATH, externalResourceName, externalResourceSns, FUNCTION_NAME, getGraphServiceNameFromAllRelSchema, SAVE_FILE_NAME } = require("../../libs/Consts");
|
|
27
27
|
const templatePath = path.join(__dirname, "./template.ejs");
|
|
28
28
|
|
|
29
29
|
|
|
30
|
-
|
|
31
|
-
async function dataForGenerateLambdaRole(_izContext, allObjSchemas, srcPath) {
|
|
30
|
+
const createExternalLambdaRole = async (_izContext, allObjSchemas, allRelSchemas, srcPath) => {
|
|
32
31
|
const externalLambdaIamRoleArray = [];
|
|
33
32
|
for (const objectSchema of allObjSchemas) {
|
|
34
33
|
|
|
@@ -47,19 +46,37 @@ async function dataForGenerateLambdaRole(_izContext, allObjSchemas, srcPath) {
|
|
|
47
46
|
}
|
|
48
47
|
}
|
|
49
48
|
}
|
|
49
|
+
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
// updateRelationship external lambda role
|
|
54
|
+
for (const handler of Object.values(HANDLER)) {
|
|
55
|
+
if (handler !== HANDLER.hdrApi) {
|
|
56
|
+
const externalLambdaIamRoleUpdateRelationship = await externalLambdaIamRoleDataUpdateRelationshipSchema(_izContext, allRelSchemas, handler);
|
|
57
|
+
externalLambdaIamRoleUpdateRelationship && externalLambdaIamRoleArray.push(externalLambdaIamRoleUpdateRelationship)
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
// CreateRelationship external lambda role
|
|
62
|
+
for (const handler of Object.values(HANDLER)) {
|
|
63
|
+
if (handler !== HANDLER.hdrApi) {
|
|
64
|
+
const externalLambdaIamRoleCreateRelationship = await externalLambdaIamRoleDataCreateRelationshipSchema(_izContext, allRelSchemas, handler);
|
|
65
|
+
externalLambdaIamRoleCreateRelationship && externalLambdaIamRoleArray.push(externalLambdaIamRoleCreateRelationship)
|
|
66
|
+
}
|
|
50
67
|
}
|
|
51
68
|
|
|
52
69
|
// findData external lambda role
|
|
53
70
|
|
|
54
71
|
// processLogical
|
|
55
72
|
|
|
56
|
-
|
|
73
|
+
|
|
57
74
|
// updateRelationshipComplete external lambda role
|
|
58
75
|
|
|
59
76
|
// ... another external lambda role data
|
|
60
77
|
|
|
61
78
|
|
|
62
|
-
console.log("createSourceArrayIamRole", (externalLambdaIamRoleArray))
|
|
79
|
+
console.log("createSourceArrayIamRole", JSON.stringify(externalLambdaIamRoleArray))
|
|
63
80
|
// return externalLambdaIamRoleArray
|
|
64
81
|
|
|
65
82
|
return {
|
|
@@ -67,21 +84,19 @@ async function dataForGenerateLambdaRole(_izContext, allObjSchemas, srcPath) {
|
|
|
67
84
|
templateData: { datas: externalLambdaIamRoleArray },
|
|
68
85
|
setting: {
|
|
69
86
|
savePath: path.join(srcPath, SOURCE_PATH.externalService),
|
|
70
|
-
saveFileName:
|
|
71
|
-
fileExtension:
|
|
87
|
+
saveFileName: SAVE_FILE_NAME.externalLambdaRole,
|
|
88
|
+
fileExtension: ".js",
|
|
72
89
|
isAppend: false
|
|
73
90
|
}
|
|
74
91
|
}
|
|
75
92
|
}
|
|
76
|
-
async function externalLambdaIamRoleDataPerAction(_izContext, objectSchema, action, handler) {
|
|
77
93
|
|
|
94
|
+
async function externalLambdaIamRoleDataPerAction(_izContext, objectSchema, action, handler) {
|
|
78
95
|
const objectType = objectSchema.objectType;
|
|
79
96
|
const additionalResourcePermission = [];
|
|
80
|
-
// let functionNameArray = [];
|
|
81
97
|
const graphServiceNames = [];
|
|
82
98
|
for (const storgaeResource of Object.values(objectSchema.storageResources)) {
|
|
83
99
|
if (storgaeResource.storageType === STORAGE_TYPES.graph) {
|
|
84
|
-
// console.log("graphServerTag", storgaeResource.graphServerTag)
|
|
85
100
|
let getGraphServiceName = await getGraphServiceNameFromGraphServerTagWithCache(_izContext, storgaeResource.graphServerTag)
|
|
86
101
|
if (!graphServiceNames.includes(getGraphServiceName)) {
|
|
87
102
|
graphServiceNames.push(getGraphServiceName)
|
|
@@ -99,7 +114,7 @@ async function externalLambdaIamRoleDataPerAction(_izContext, objectSchema, acti
|
|
|
99
114
|
createIamRole(
|
|
100
115
|
{ [RESOURCE_CLASSES.lambda]: ["InvokeFunction"] },
|
|
101
116
|
graphServiceNames.map(graphServiceName =>
|
|
102
|
-
externalResourceName(RESOURCE_CLASSES.lambda, "
|
|
117
|
+
externalResourceName(RESOURCE_CLASSES.lambda, "GetNodeV2HdrInv", graphServiceName),
|
|
103
118
|
)
|
|
104
119
|
)
|
|
105
120
|
)
|
|
@@ -117,7 +132,6 @@ async function externalLambdaIamRoleDataPerAction(_izContext, objectSchema, acti
|
|
|
117
132
|
// throw Error("invalid action")
|
|
118
133
|
}
|
|
119
134
|
|
|
120
|
-
console.log("additionalResourcePermission:", (additionalResourcePermission))
|
|
121
135
|
|
|
122
136
|
return {
|
|
123
137
|
functionName: functionName,
|
|
@@ -127,21 +141,54 @@ async function externalLambdaIamRoleDataPerAction(_izContext, objectSchema, acti
|
|
|
127
141
|
}
|
|
128
142
|
|
|
129
143
|
|
|
130
|
-
|
|
144
|
+
// update Relationship
|
|
145
|
+
async function externalLambdaIamRoleDataUpdateRelationshipSchema(_izContext, allRelSchemas, handler) {
|
|
146
|
+
const functionName = upperCase(FUNCTION_NAME.updateRel) + upperCase(handler);
|
|
147
|
+
const additionalResourcePermission = [];
|
|
148
|
+
const graphServiceNamesFromAllRelSchemas = await getGraphServiceNameFromAllRelSchema(_izContext, allRelSchemas);
|
|
149
|
+
|
|
150
|
+
|
|
151
|
+
additionalResourcePermission.push(
|
|
152
|
+
createIamRole(
|
|
153
|
+
{
|
|
154
|
+
[RESOURCE_CLASSES.sns]: ["Publish"]
|
|
155
|
+
},
|
|
156
|
+
graphServiceNamesFromAllRelSchemas.map(graphServiceName =>
|
|
157
|
+
externalResourceSns("InUpdateRelationship", graphServiceName)
|
|
158
|
+
)
|
|
159
|
+
)
|
|
160
|
+
)
|
|
161
|
+
|
|
162
|
+
return {
|
|
163
|
+
functionName,
|
|
164
|
+
additionalResourcePermission
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
|
|
131
168
|
|
|
169
|
+
// create relationship
|
|
132
170
|
|
|
171
|
+
async function externalLambdaIamRoleDataCreateRelationshipSchema(_izContext, allRelSchemas, handler) {
|
|
172
|
+
const functionName = upperCase(FUNCTION_NAME.createRel) + upperCase(handler);
|
|
173
|
+
const additionalResourcePermission = [];
|
|
174
|
+
const graphServiceNamesFromAllRelSchemas = await getGraphServiceNameFromAllRelSchema(_izContext, allRelSchemas);
|
|
175
|
+
|
|
176
|
+
additionalResourcePermission.push(
|
|
177
|
+
createIamRole(
|
|
178
|
+
{
|
|
179
|
+
[RESOURCE_CLASSES.sns]: ["Publish"]
|
|
180
|
+
},
|
|
181
|
+
graphServiceNamesFromAllRelSchemas.map(graphServiceName =>
|
|
182
|
+
externalResourceSns("InCreateRelationshipV2", graphServiceName)
|
|
183
|
+
)
|
|
184
|
+
)
|
|
185
|
+
)
|
|
186
|
+
return {
|
|
187
|
+
functionName,
|
|
188
|
+
additionalResourcePermission
|
|
189
|
+
}
|
|
190
|
+
}
|
|
133
191
|
|
|
134
|
-
// for (const action of Object.values(ACTIONS)) {
|
|
135
|
-
// if (objectSchema.overWriteHandlers?.[action]) {
|
|
136
|
-
// // create template data
|
|
137
|
-
// // const createSourceParam = createParamForCreateSource(objectSchema, action, savePath)
|
|
138
|
-
// // createSourceArray.push(createSourceParam)
|
|
139
|
-
// } else {
|
|
140
|
-
// // if not have overWriteHander of action will use default handler
|
|
141
|
-
// const defaultHandler = DEFAULT_HANDLER_PER_ACTION[action]
|
|
142
192
|
|
|
143
|
-
// // const createSourceParam = createParamForCreateSource(objectSchema, action, savePath)
|
|
144
|
-
// // createSourceArray.push(createSourceParam)
|
|
145
193
|
|
|
146
|
-
|
|
147
|
-
// }
|
|
194
|
+
module.exports = createExternalLambdaRole;
|
|
@@ -24,8 +24,10 @@ const lambdaSharedLib = izaraShared.lambdaSharedLib
|
|
|
24
24
|
const snsSharedLib = izaraShared.snsSharedLib
|
|
25
25
|
const initialSetupConfig = require('../../config/Config') // config external serviceName
|
|
26
26
|
const basicNodeSchemaLib = require('@izara_project/izara-attribute-tree').basicNodeSchemaLib
|
|
27
|
+
const _izContext = {logger : Logger}
|
|
27
28
|
|
|
28
|
-
module.exports.generatedLambdaRole =
|
|
29
|
+
module.exports.generatedLambdaRole = async () => {
|
|
30
|
+
let externalLambdaRole = [ <%_ datas.forEach((data,dataIndex) => { %>
|
|
29
31
|
{
|
|
30
32
|
functionName: "<%- data.functionName %>",
|
|
31
33
|
statement: [
|
|
@@ -33,7 +35,8 @@ module.exports.generatedLambdaRole = [ <%_ datas.forEach((data,dataIndex) => { %
|
|
|
33
35
|
"Sid": "<%- data.functionName %>Test<%- dataIndex %>",
|
|
34
36
|
"Effect": <%_ data.additionalResourcePermission.forEach(resourcePermission => { _%>
|
|
35
37
|
"<%- resourcePermission.effect %>",
|
|
36
|
-
"Action":
|
|
38
|
+
"Action":
|
|
39
|
+
<%_ Object.keys(resourcePermission.action).forEach(resourcePerAction => { _%>
|
|
37
40
|
<%_ resourcePermission.action[resourcePerAction].forEach(permission => { _%>
|
|
38
41
|
[
|
|
39
42
|
"<%- resourcePerAction %>:<%- permission %>",
|
|
@@ -49,4 +52,6 @@ module.exports.generatedLambdaRole = [ <%_ datas.forEach((data,dataIndex) => { %
|
|
|
49
52
|
}
|
|
50
53
|
]
|
|
51
54
|
}, <%_ }) -%>
|
|
52
|
-
]
|
|
55
|
+
]
|
|
56
|
+
return externalLambdaRole
|
|
57
|
+
}
|
|
@@ -20,12 +20,60 @@ const path = require('path');
|
|
|
20
20
|
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
|
+
const { getGraphServiceNameFromGraphServerTagWithCache, getServiceNameWithCache } = require('@izara_project/izara-core-library-service-schemas/src/ServiceConfig')
|
|
24
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 } = require("../../libs/Consts");
|
|
26
|
-
|
|
25
|
+
const { DEFAULT_HANDLER_PER_ACTION, createIamRole, resourceNames, RESOURCE_CLASSES, DEFAULT_LAMBDA_ROLE_PER_ACTION, SOURCE_PATH, externalResourceName, getGraphServiceNameFromAllRelSchema, FUNCTION_NAME, SAVE_FILE_NAME } = require("../../libs/Consts");
|
|
26
|
+
const {
|
|
27
|
+
TOPIC_NAME_GRAPH_HANDLER,
|
|
28
|
+
TOPIC_NAME_GENERATE_CODE
|
|
29
|
+
} = require('../../../../GenerateCodeLibs/src/Consts')
|
|
27
30
|
const templatePath = path.join(__dirname, "./template.ejs");
|
|
28
31
|
|
|
29
32
|
|
|
33
|
+
const createExternalSnsSubscriptions = async (_izContext, allRelSchemas, srcPath) => {
|
|
34
|
+
const snsServiceConfigArray = [];
|
|
35
|
+
const snsServiceConfigUpdateRelationshipComplete = await snsSubScriptionUpdateRelationshipComplete(_izContext, allRelSchemas)
|
|
36
|
+
snsServiceConfigUpdateRelationshipComplete && snsServiceConfigArray.push(snsServiceConfigUpdateRelationshipComplete)
|
|
37
|
+
|
|
38
|
+
const snsServiceConfigCreateRelationshipComplete = await snsSubscriptionCreateRelationshipComplete(_izContext, allRelSchemas)
|
|
39
|
+
snsServiceConfigCreateRelationshipComplete && snsServiceConfigArray.push(snsServiceConfigCreateRelationshipComplete)
|
|
40
|
+
|
|
41
|
+
return {
|
|
42
|
+
templatePath: templatePath,
|
|
43
|
+
templateData: { datas: snsServiceConfigArray },
|
|
44
|
+
setting: {
|
|
45
|
+
savePath: path.join(srcPath, SOURCE_PATH.externalService),
|
|
46
|
+
saveFileName: SAVE_FILE_NAME.snsSubscription,
|
|
47
|
+
fileExtension: ".js",
|
|
48
|
+
isAppend: false
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
// update Relationship
|
|
55
|
+
async function snsSubScriptionUpdateRelationshipComplete(_izContext, allRelSchemas) {
|
|
56
|
+
let serviceNames = await getGraphServiceNameFromAllRelSchema(_izContext, allRelSchemas)
|
|
30
57
|
|
|
58
|
+
return {
|
|
59
|
+
serviceNames: serviceNames,
|
|
60
|
+
topicName: TOPIC_NAME_GRAPH_HANDLER.outUpdateRel, // external service
|
|
61
|
+
sqsEndpoint: TOPIC_NAME_GENERATE_CODE.updateRelComplete // in service
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
// create Relationship
|
|
66
|
+
async function snsSubscriptionCreateRelationshipComplete(_izContext, allRelSchemas) {
|
|
67
|
+
let serviceName = await getGraphServiceNameFromAllRelSchema(_izContext, allRelSchemas)
|
|
68
|
+
|
|
69
|
+
return {
|
|
70
|
+
serviceNames: serviceName,
|
|
71
|
+
topicName: TOPIC_NAME_GRAPH_HANDLER.outCreateRel,
|
|
72
|
+
sqsEndpoint: TOPIC_NAME_GENERATE_CODE.createRelComplete
|
|
73
|
+
}
|
|
74
|
+
}
|
|
31
75
|
// not done yet wait for comfirmation
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
module.exports = createExternalSnsSubscriptions;
|
|
@@ -1,14 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
// topicName: "OutCreateNode", // sns of external service
|
|
12
|
-
// sqsEndpoint: "AucCreateCompleteHdrSqs" // sqs inside this service
|
|
13
|
-
// },
|
|
14
|
-
]
|
|
1
|
+
module.exports.generatedSnsTopicSubscription = [ <% datas.forEach(data => { -%>
|
|
2
|
+
<% data.serviceNames.forEach(serviceName => { _%>
|
|
3
|
+
{
|
|
4
|
+
serviceName: "<%- serviceName %>",
|
|
5
|
+
topicName: "<%- data.topicName %>",
|
|
6
|
+
sqsEndpoint: "<%- data.sqsEndpoint %>"
|
|
7
|
+
},
|
|
8
|
+
<% }) _%>
|
|
9
|
+
<% }) _%>
|
|
10
|
+
]
|