@izara_project/izara-market-library-service-schemas 1.0.4 → 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 +1 -1
- package/src/GenerateCodeLibs/src/Consts.js +11 -5
- 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 +63 -18
- package/src/TemplateManager/src/{FunctionYaml → PerActionEndpoint/FunctionYaml}/HdrApi/data.js +4 -20
- package/src/TemplateManager/src/{FunctionYaml → PerActionEndpoint/FunctionYaml}/HdrDsq/data.js +4 -20
- package/src/TemplateManager/src/{FunctionYaml → PerActionEndpoint/FunctionYaml}/HdrInv/data.js +4 -21
- package/src/TemplateManager/src/{FunctionYaml → PerActionEndpoint/FunctionYaml}/HdrSqs/data.js +4 -21
- package/src/TemplateManager/src/{FunctionYaml → PerActionEndpoint/FunctionYaml}/HdrSqs/template.ejs +1 -1
- 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 +2 -15
- package/src/TemplateManager/src/PerActionEndpoint/Handler/HdrSqs/data.js +3 -16
- package/src/TemplateManager/src/PerActionEndpoint/MainFunction/Get/data.js +0 -15
- package/src/TemplateManager/src/PerActionEndpoint/MainFunction/Get/template.ejs +27 -29
- package/src/TemplateManager/src/PerActionEndpoint/MainFunction/Get/testParam.json +5 -0
- package/src/TemplateManager/src/ResourceYaml/dynamodb/awaitingMultipleStepData.js +5 -8
- package/src/TemplateManager/src/ResourceYaml/dynamodb/mainResourcePerObjectSchemaData.js +4 -26
- package/src/TemplateManager/src/ResourceYaml/dynamodb/processLogicalAndFindData.js +4 -8
- package/src/TemplateManager/src/ResourceYaml/sns-in-sqs/defaultSnsInSqsForFindDataAndProcessLogical.js +2 -5
- package/src/TemplateManager/src/ResourceYaml/sns-in-sqs/snsAndSqsPerActiondata.js +5 -5
- package/src/TemplateManager/src/ResourceYaml/sns-out/data.js +2 -2
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRalationshipComplete/functionYaml/data.js +6 -22
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRalationshipComplete/handler/HdrSqs/data.js +7 -21
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRalationshipComplete/mainFunction/data.js +4 -3
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRalationshipComplete/mainFunction/template.ejs +1 -1
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRalationshipComplete/sns-in-sqs/data.js +10 -13
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRalationshipComplete/sns-in-sqs/template.ejs +1 -0
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRalationshipComplete/sns-out/data.js +6 -5
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRelationship/functionYaml/HdrApi/data.js +4 -19
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRelationship/functionYaml/HdrDsq/data.js +6 -26
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRelationship/functionYaml/HdrInv/data.js +6 -21
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRelationship/functionYaml/HdrSqs/data.js +6 -23
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRelationship/mainFunction/data.js +3 -18
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRelationship/mainFunction/template.ejs +18 -11
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRelationship/perAction/HdrApi/data.js +5 -18
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRelationship/perAction/HdrDsq/data.js +5 -19
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRelationship/perAction/HdrInv/data.js +7 -18
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRelationship/perAction/HdrSqs/data.js +6 -20
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRelationship/perAction/request.json +3 -4
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRelationship/sns-in-sqs/data.js +5 -6
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRelationship/sns-out/data.js +4 -4
- package/src/TemplateManager/src/externalService/LambdaRole/data.js +41 -40
- package/src/TemplateManager/src/externalService/LambdaRole/template.ejs +2 -1
- package/src/TemplateManager/src/externalService/SnsTopicSubscriotions/data.js +27 -44
- package/src/TemplateManager/src/libs/Consts.js +42 -4
- /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
|
@@ -23,11 +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, externalResourceSns, } = 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
|
-
async
|
|
30
|
+
const createExternalLambdaRole = async (_izContext, allObjSchemas, allRelSchemas, srcPath) => {
|
|
31
31
|
const externalLambdaIamRoleArray = [];
|
|
32
32
|
for (const objectSchema of allObjSchemas) {
|
|
33
33
|
|
|
@@ -53,11 +53,18 @@ async function dataForGenerateLambdaRole(_izContext, allObjSchemas, allRelSchema
|
|
|
53
53
|
// updateRelationship external lambda role
|
|
54
54
|
for (const handler of Object.values(HANDLER)) {
|
|
55
55
|
if (handler !== HANDLER.hdrApi) {
|
|
56
|
-
const externalLambdaIamRoleUpdateRelationship = await externalLambdaIamRoleDataUpdateRelationshipSchema(_izContext, allRelSchemas, handler)
|
|
56
|
+
const externalLambdaIamRoleUpdateRelationship = await externalLambdaIamRoleDataUpdateRelationshipSchema(_izContext, allRelSchemas, handler);
|
|
57
57
|
externalLambdaIamRoleUpdateRelationship && externalLambdaIamRoleArray.push(externalLambdaIamRoleUpdateRelationship)
|
|
58
58
|
}
|
|
59
59
|
}
|
|
60
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
|
+
}
|
|
67
|
+
}
|
|
61
68
|
|
|
62
69
|
// findData external lambda role
|
|
63
70
|
|
|
@@ -77,7 +84,7 @@ async function dataForGenerateLambdaRole(_izContext, allObjSchemas, allRelSchema
|
|
|
77
84
|
templateData: { datas: externalLambdaIamRoleArray },
|
|
78
85
|
setting: {
|
|
79
86
|
savePath: path.join(srcPath, SOURCE_PATH.externalService),
|
|
80
|
-
saveFileName:
|
|
87
|
+
saveFileName: SAVE_FILE_NAME.externalLambdaRole,
|
|
81
88
|
fileExtension: ".js",
|
|
82
89
|
isAppend: false
|
|
83
90
|
}
|
|
@@ -87,11 +94,9 @@ async function dataForGenerateLambdaRole(_izContext, allObjSchemas, allRelSchema
|
|
|
87
94
|
async function externalLambdaIamRoleDataPerAction(_izContext, objectSchema, action, handler) {
|
|
88
95
|
const objectType = objectSchema.objectType;
|
|
89
96
|
const additionalResourcePermission = [];
|
|
90
|
-
// let functionNameArray = [];
|
|
91
97
|
const graphServiceNames = [];
|
|
92
98
|
for (const storgaeResource of Object.values(objectSchema.storageResources)) {
|
|
93
99
|
if (storgaeResource.storageType === STORAGE_TYPES.graph) {
|
|
94
|
-
// console.log("graphServerTag", storgaeResource.graphServerTag)
|
|
95
100
|
let getGraphServiceName = await getGraphServiceNameFromGraphServerTagWithCache(_izContext, storgaeResource.graphServerTag)
|
|
96
101
|
if (!graphServiceNames.includes(getGraphServiceName)) {
|
|
97
102
|
graphServiceNames.push(getGraphServiceName)
|
|
@@ -109,7 +114,7 @@ async function externalLambdaIamRoleDataPerAction(_izContext, objectSchema, acti
|
|
|
109
114
|
createIamRole(
|
|
110
115
|
{ [RESOURCE_CLASSES.lambda]: ["InvokeFunction"] },
|
|
111
116
|
graphServiceNames.map(graphServiceName =>
|
|
112
|
-
externalResourceName(RESOURCE_CLASSES.lambda, "
|
|
117
|
+
externalResourceName(RESOURCE_CLASSES.lambda, "GetNodeV2HdrInv", graphServiceName),
|
|
113
118
|
)
|
|
114
119
|
)
|
|
115
120
|
)
|
|
@@ -127,8 +132,7 @@ async function externalLambdaIamRoleDataPerAction(_izContext, objectSchema, acti
|
|
|
127
132
|
// throw Error("invalid action")
|
|
128
133
|
}
|
|
129
134
|
|
|
130
|
-
|
|
131
|
-
console.log("additionalResourcePermissionInExternalRolePerAction", JSON.stringify(additionalResourcePermission))
|
|
135
|
+
|
|
132
136
|
return {
|
|
133
137
|
functionName: functionName,
|
|
134
138
|
action: action,
|
|
@@ -137,57 +141,54 @@ async function externalLambdaIamRoleDataPerAction(_izContext, objectSchema, acti
|
|
|
137
141
|
}
|
|
138
142
|
|
|
139
143
|
|
|
140
|
-
|
|
144
|
+
// update Relationship
|
|
141
145
|
async function externalLambdaIamRoleDataUpdateRelationshipSchema(_izContext, allRelSchemas, handler) {
|
|
142
|
-
const functionName =
|
|
146
|
+
const functionName = upperCase(FUNCTION_NAME.updateRel) + upperCase(handler);
|
|
143
147
|
const additionalResourcePermission = [];
|
|
144
|
-
const
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
for (const storageResource of Object.values(relationship.storageResources)) {
|
|
148
|
-
if (storageResource.storageType === STORAGE_TYPES.graph) {
|
|
149
|
-
let getGraphServiceTag = await getGraphServiceNameFromGraphServerTagWithCache(_izContext, storageResource.graphServerTag)
|
|
150
|
-
if (!graphServiceNames.includes(getGraphServiceTag)) {
|
|
151
|
-
graphServiceNames.push(getGraphServiceTag)
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
console.log("graphServiceNames", graphServiceNames)
|
|
148
|
+
const graphServiceNamesFromAllRelSchemas = await getGraphServiceNameFromAllRelSchema(_izContext, allRelSchemas);
|
|
149
|
+
|
|
150
|
+
|
|
158
151
|
additionalResourcePermission.push(
|
|
159
152
|
createIamRole(
|
|
160
153
|
{
|
|
161
154
|
[RESOURCE_CLASSES.sns]: ["Publish"]
|
|
162
155
|
},
|
|
163
|
-
|
|
156
|
+
graphServiceNamesFromAllRelSchemas.map(graphServiceName =>
|
|
164
157
|
externalResourceSns("InUpdateRelationship", graphServiceName)
|
|
165
158
|
)
|
|
166
159
|
)
|
|
167
160
|
)
|
|
168
161
|
|
|
169
|
-
console.log("additionalResourcePermissionInexternalLambdaIamRoleDataUpdateRelationshipSchema", JSON.stringify(additionalResourcePermission))
|
|
170
162
|
return {
|
|
171
163
|
functionName,
|
|
172
164
|
additionalResourcePermission
|
|
173
165
|
}
|
|
174
166
|
}
|
|
175
167
|
|
|
176
|
-
module.exports = dataForGenerateLambdaRole;
|
|
177
168
|
|
|
169
|
+
// create relationship
|
|
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);
|
|
178
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
|
+
}
|
|
179
191
|
|
|
180
|
-
// for (const action of Object.values(ACTIONS)) {
|
|
181
|
-
// if (objectSchema.overWriteHandlers?.[action]) {
|
|
182
|
-
// // create template data
|
|
183
|
-
// // const createSourceParam = createParamForCreateSource(objectSchema, action, savePath)
|
|
184
|
-
// // createSourceArray.push(createSourceParam)
|
|
185
|
-
// } else {
|
|
186
|
-
// // if not have overWriteHander of action will use default handler
|
|
187
|
-
// const defaultHandler = DEFAULT_HANDLER_PER_ACTION[action]
|
|
188
192
|
|
|
189
|
-
// // const createSourceParam = createParamForCreateSource(objectSchema, action, savePath)
|
|
190
|
-
// // createSourceArray.push(createSourceParam)
|
|
191
193
|
|
|
192
|
-
|
|
193
|
-
// }
|
|
194
|
+
module.exports = createExternalLambdaRole;
|
|
@@ -35,7 +35,8 @@ module.exports.generatedLambdaRole = async () => {
|
|
|
35
35
|
"Sid": "<%- data.functionName %>Test<%- dataIndex %>",
|
|
36
36
|
"Effect": <%_ data.additionalResourcePermission.forEach(resourcePermission => { _%>
|
|
37
37
|
"<%- resourcePermission.effect %>",
|
|
38
|
-
"Action":
|
|
38
|
+
"Action":
|
|
39
|
+
<%_ Object.keys(resourcePermission.action).forEach(resourcePerAction => { _%>
|
|
39
40
|
<%_ resourcePermission.action[resourcePerAction].forEach(permission => { _%>
|
|
40
41
|
[
|
|
41
42
|
"<%- resourcePerAction %>:<%- permission %>",
|
|
@@ -22,75 +22,58 @@ const fs = require('fs');
|
|
|
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, externalResourceName } = 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
|
-
async function getGraphServiceTagFromRelSchema(_izContext, allRelSchemas) {
|
|
30
|
-
let graphServiceNames = [];
|
|
31
|
-
// for (const allRelSchema of Object.values(allRelSchemas)) {
|
|
32
|
-
// for (const relationship of Object.values(allRelSchema)) {
|
|
33
|
-
// for (const storageResource of Object.values(relationship.storageResources)) {
|
|
34
|
-
// if (storageResource.storageType === STORAGE_TYPES.graph) {
|
|
35
|
-
// let getGraphServiceTag = await getGraphServiceNameFromGraphServerTagWithCache(_izContext, storageResource.graphServerTag)
|
|
36
|
-
// if (!graphServiceNames.includes(getGraphServiceTag)) {
|
|
37
|
-
// graphServiceNames.push(getGraphServiceTag);
|
|
38
|
-
// }
|
|
39
|
-
// }
|
|
40
|
-
// }
|
|
41
|
-
// }
|
|
42
|
-
// }
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
await Promise.all(allRelSchemas.map(async relSchema => {
|
|
46
|
-
let relTag = Object.keys(relSchema)[0];
|
|
47
|
-
let relSchemaData = relSchema[relTag];
|
|
48
|
-
|
|
49
|
-
await Promise.all(Object.values(relSchemaData.storageResources).map(async storageResource => {
|
|
50
|
-
if (storageResource.storageType === STORAGE_TYPES.graph) {
|
|
51
|
-
let getGraphServiceTag = await getGraphServiceNameFromGraphServerTagWithCache(_izContext, storageResource.graphServerTag)
|
|
52
|
-
graphServiceNames.push(getGraphServiceTag);
|
|
53
|
-
}
|
|
54
|
-
}))
|
|
55
|
-
}));
|
|
56
|
-
|
|
57
|
-
return [...new Set(graphServiceNames)];
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
|
|
61
32
|
|
|
62
|
-
async
|
|
33
|
+
const createExternalSnsSubscriptions = async (_izContext, allRelSchemas, srcPath) => {
|
|
63
34
|
const snsServiceConfigArray = [];
|
|
64
|
-
const snsServiceConfigUpdateRelationshipComplete = await
|
|
35
|
+
const snsServiceConfigUpdateRelationshipComplete = await snsSubScriptionUpdateRelationshipComplete(_izContext, allRelSchemas)
|
|
65
36
|
snsServiceConfigUpdateRelationshipComplete && snsServiceConfigArray.push(snsServiceConfigUpdateRelationshipComplete)
|
|
66
37
|
|
|
38
|
+
const snsServiceConfigCreateRelationshipComplete = await snsSubscriptionCreateRelationshipComplete(_izContext, allRelSchemas)
|
|
39
|
+
snsServiceConfigCreateRelationshipComplete && snsServiceConfigArray.push(snsServiceConfigCreateRelationshipComplete)
|
|
67
40
|
|
|
68
41
|
return {
|
|
69
42
|
templatePath: templatePath,
|
|
70
43
|
templateData: { datas: snsServiceConfigArray },
|
|
71
44
|
setting: {
|
|
72
45
|
savePath: path.join(srcPath, SOURCE_PATH.externalService),
|
|
73
|
-
saveFileName:
|
|
46
|
+
saveFileName: SAVE_FILE_NAME.snsSubscription,
|
|
74
47
|
fileExtension: ".js",
|
|
75
48
|
isAppend: false
|
|
76
49
|
}
|
|
77
50
|
}
|
|
78
51
|
}
|
|
52
|
+
|
|
53
|
+
|
|
79
54
|
// update Relationship
|
|
80
|
-
async function
|
|
81
|
-
let serviceNames = await
|
|
55
|
+
async function snsSubScriptionUpdateRelationshipComplete(_izContext, allRelSchemas) {
|
|
56
|
+
let serviceNames = await getGraphServiceNameFromAllRelSchema(_izContext, allRelSchemas)
|
|
82
57
|
|
|
83
58
|
return {
|
|
84
59
|
serviceNames: serviceNames,
|
|
85
|
-
topicName:
|
|
86
|
-
sqsEndpoint:
|
|
60
|
+
topicName: TOPIC_NAME_GRAPH_HANDLER.outUpdateRel, // external service
|
|
61
|
+
sqsEndpoint: TOPIC_NAME_GENERATE_CODE.updateRelComplete // in service
|
|
87
62
|
}
|
|
88
63
|
}
|
|
89
64
|
|
|
90
|
-
|
|
91
65
|
// create Relationship
|
|
66
|
+
async function snsSubscriptionCreateRelationshipComplete(_izContext, allRelSchemas) {
|
|
67
|
+
let serviceName = await getGraphServiceNameFromAllRelSchema(_izContext, allRelSchemas)
|
|
92
68
|
|
|
69
|
+
return {
|
|
70
|
+
serviceNames: serviceName,
|
|
71
|
+
topicName: TOPIC_NAME_GRAPH_HANDLER.outCreateRel,
|
|
72
|
+
sqsEndpoint: TOPIC_NAME_GENERATE_CODE.createRelComplete
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
// not done yet wait for comfirmation
|
|
93
76
|
|
|
94
|
-
module.exports = createExternalSnsSubscriptions
|
|
95
77
|
|
|
96
|
-
|
|
78
|
+
|
|
79
|
+
module.exports = createExternalSnsSubscriptions;
|
|
@@ -19,9 +19,11 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
19
19
|
|
|
20
20
|
const {
|
|
21
21
|
HANDLER,
|
|
22
|
-
ACTIONS
|
|
22
|
+
ACTIONS,
|
|
23
|
+
STORAGE_TYPES
|
|
23
24
|
} = require('@izara_project/izara-core-library-service-schemas/src/Consts');
|
|
24
25
|
|
|
26
|
+
const { getGraphServiceNameFromGraphServerTagWithCache } = require('@izara_project/izara-core-library-service-schemas/src/ServiceConfig');
|
|
25
27
|
|
|
26
28
|
const DEFAULT_HANDLER_PER_ACTION = {
|
|
27
29
|
[ACTIONS.create]: [HANDLER.hdrApi, HANDLER.hdrSqs],
|
|
@@ -77,9 +79,9 @@ const SOURCE_PATH = {
|
|
|
77
79
|
lamdaPerCombindActionPath: `/generatedCode/lamdaPerCombindAction/source/`, // test
|
|
78
80
|
externalService: '../initial_setup/generatedCode/source/',
|
|
79
81
|
lambdaPerAction: '../src/generatedCode/ObjectTypePerActionEndpoint/source/',
|
|
80
|
-
|
|
82
|
+
relationshipPerAction: '../src/generatedCode/RelationshipPerAction/source/',
|
|
81
83
|
resourceLocationPerAction: 'src/generatedCode/ObjectTypePerActionEndpoint/source/',
|
|
82
|
-
|
|
84
|
+
resourceLocationRelationshipPerAction: 'src/generatedCode/RelationshipPerAction/source/',
|
|
83
85
|
};
|
|
84
86
|
|
|
85
87
|
|
|
@@ -121,6 +123,39 @@ function externalResourceName(resourceClass, functionName, serviceTag) {
|
|
|
121
123
|
function externalResourceSns(functionName, serviceTag) {
|
|
122
124
|
return "arn:aws:sns:${process.env.iz_region}:${process.env.iz_accountId}:${await snsSharedLib.snsTopicName(_izContext, " + `"${functionName}", "${serviceTag}")}`
|
|
123
125
|
}
|
|
126
|
+
const SAVE_FILE_NAME = {
|
|
127
|
+
dynamoDbYaml: "generated-dynamoDB-table",
|
|
128
|
+
snsInSqsYaml: "generated-sns-in-sqs",
|
|
129
|
+
snsOutYaml: "generated-sns-out",
|
|
130
|
+
functionRelationshipYaml: "RelationshipPerAction",
|
|
131
|
+
functionPerActionYaml: "per-action-function",
|
|
132
|
+
externalLambdaRole: "generatedLambdaRoleServiceConfig",
|
|
133
|
+
snsSubscription: "generatedSnsServiceConfig",
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
const FUNCTION_NAME = {
|
|
137
|
+
updateRel: "updateRelationship",
|
|
138
|
+
createRel: "createRelationship",
|
|
139
|
+
updateRelComplete: "updateRelationshipComplete",
|
|
140
|
+
createRelComplete: "createRelationshipComplete"
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
const getGraphServiceNameFromAllRelSchema = async (_izContext, allRelSchemas) => {
|
|
144
|
+
const graphServiceNameSet = new Set();
|
|
145
|
+
await Promise.all(allRelSchemas.map(async relSchema => {
|
|
146
|
+
let relTag = Object.keys(relSchema)[0];
|
|
147
|
+
let relSchemaData = relSchema[relTag];
|
|
148
|
+
|
|
149
|
+
await Promise.all(Object.values(relSchemaData.storageResources).map(async storageResource => {
|
|
150
|
+
if (storageResource.storageType === STORAGE_TYPES.graph) {
|
|
151
|
+
const getGraphServiceName = await getGraphServiceNameFromGraphServerTagWithCache(_izContext, storageResource.graphServerTag);
|
|
152
|
+
graphServiceNameSet.add(getGraphServiceName)
|
|
153
|
+
}
|
|
154
|
+
}))
|
|
155
|
+
}))
|
|
156
|
+
const graphServiceName = [...graphServiceNameSet]
|
|
157
|
+
return graphServiceName
|
|
158
|
+
}
|
|
124
159
|
|
|
125
160
|
module.exports = {
|
|
126
161
|
ACTIONS,
|
|
@@ -133,5 +168,8 @@ module.exports = {
|
|
|
133
168
|
SQS_RESOURCE,
|
|
134
169
|
HANDLER,
|
|
135
170
|
externalResourceName,
|
|
136
|
-
externalResourceSns
|
|
171
|
+
externalResourceSns,
|
|
172
|
+
SAVE_FILE_NAME,
|
|
173
|
+
FUNCTION_NAME,
|
|
174
|
+
getGraphServiceNameFromAllRelSchema
|
|
137
175
|
}
|
/package/src/TemplateManager/src/{FunctionYaml → PerActionEndpoint/FunctionYaml}/HdrApi/request.json
RENAMED
|
File without changes
|
/package/src/TemplateManager/src/{FunctionYaml → PerActionEndpoint/FunctionYaml}/HdrApi/template.ejs
RENAMED
|
File without changes
|
/package/src/TemplateManager/src/{FunctionYaml → PerActionEndpoint/FunctionYaml}/HdrDsq/request.json
RENAMED
|
File without changes
|
/package/src/TemplateManager/src/{FunctionYaml → PerActionEndpoint/FunctionYaml}/HdrDsq/template.ejs
RENAMED
|
File without changes
|
|
File without changes
|
/package/src/TemplateManager/src/{FunctionYaml → PerActionEndpoint/FunctionYaml}/HdrInv/request.json
RENAMED
|
File without changes
|
/package/src/TemplateManager/src/{FunctionYaml → PerActionEndpoint/FunctionYaml}/HdrInv/template.ejs
RENAMED
|
File without changes
|
/package/src/TemplateManager/src/{FunctionYaml → PerActionEndpoint/FunctionYaml}/HdrSqs/request.json
RENAMED
|
File without changes
|