@izara_project/izara-market-library-service-schemas 1.0.17 → 1.0.19
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 +4 -4
- package/src/GenerateCodeLibs/src/Consts.js +32 -2
- package/src/GenerateCodeLibs/src/GenerateCodeLibs.js +27 -61
- package/src/SourceManager/src/Utils.js +16 -1
- package/src/TemplateManager/src/FindData/FindDataYaml/data.js +0 -9
- package/src/TemplateManager/src/GenerateCode.js +133 -33
- package/src/TemplateManager/src/OutPerActionComplete/OutCreateComplete/functionYaml/data.js +1 -1
- package/src/TemplateManager/src/OutPerActionComplete/OutDeleteComplete/functionYaml/data.js +1 -1
- package/src/TemplateManager/src/OutPerActionComplete/OutUpdateComplete/functionYaml/data.js +1 -1
- package/src/TemplateManager/src/OutPerActionComplete/OutUpdateComplete/mainFunction/template.ejs +1 -1
- package/src/TemplateManager/src/PerActionEndpoint/Handler/HdrDsq/template.ejs +2 -2
- package/src/TemplateManager/src/PerActionEndpoint/Handler/HdrSqs/template.ejs +2 -2
- package/src/TemplateManager/src/PerActionEndpoint/MainFunction/Create/template.ejs +78 -47
- package/src/TemplateManager/src/PerActionEndpoint/MainFunction/Delete/template.ejs +0 -1
- package/src/TemplateManager/src/PerActionEndpoint/MainFunction/Get/template.ejs +13 -11
- package/src/TemplateManager/src/PerActionEndpoint/MainFunction/Update/template.ejs +57 -13
- package/src/TemplateManager/src/{flowTag/webSocket/websocketHandler/lambda → PerActionEndpoint/libs}/data.js +12 -21
- package/src/TemplateManager/src/PerActionEndpoint/libs/template.ejs +46 -0
- package/src/TemplateManager/src/RelationshipPerAction/CreateRelationship/createRelationshipComplete/mainFunction/template.ejs +1 -1
- package/src/TemplateManager/src/RelationshipPerAction/DeleteRelationship/DeleteRelationshipComplete/mainFunction/template.ejs +1 -1
- package/src/TemplateManager/src/RelationshipPerAction/UpdateRelationshipSchema/updateRalationshipComplete/mainFunction/template.ejs +1 -1
- package/src/TemplateManager/src/ResourceYaml/dynamodb/defaultDynamoDbTable.js +15 -0
- package/src/TemplateManager/src/externalService/LambdaRole/data.js +120 -23
- package/src/TemplateManager/src/externalService/LambdaRole/template.ejs +3 -4
- package/src/TemplateManager/src/externalService/SnsTopicSubscriotions/data.js +31 -6
- package/src/TemplateManager/src/flowSchema/DefaultWebSocketResource/dynamoDb/ReservedTableData.js +65 -0
- package/src/TemplateManager/src/{flowTag/webSocket → flowSchema/DefaultWebSocketResource}/webSocketConnect/functionYaml/data.js +23 -5
- package/src/TemplateManager/src/flowSchema/DefaultWebSocketResource/webSocketConnect/functionYaml/template.ejs +29 -0
- package/src/TemplateManager/src/{flowTag/webSocket → flowSchema/DefaultWebSocketResource}/webSocketConnect/handler/data.js +3 -3
- package/src/TemplateManager/src/{flowTag/webSocket → flowSchema/DefaultWebSocketResource}/webSocketConnect/handler/template.ejs +19 -14
- package/src/TemplateManager/src/{flowTag/webSocket/websocketHandler → flowSchema/FlowSchemaEndpoint/InProcessFlowSchema}/functionYaml/data.js +29 -27
- package/src/TemplateManager/src/flowSchema/FlowSchemaEndpoint/InProcessFlowSchema/functionYaml/template.ejs +37 -0
- package/src/TemplateManager/src/flowSchema/FlowSchemaEndpoint/InProcessFlowSchema/handler/data.js +47 -0
- package/src/TemplateManager/src/flowSchema/FlowSchemaEndpoint/InProcessFlowSchema/handler/template.ejs +103 -0
- package/src/TemplateManager/src/flowSchema/FlowSchemaEndpoint/InProcessFlowSchema/mainFunction/data.js +46 -0
- package/src/TemplateManager/src/flowSchema/FlowSchemaEndpoint/InProcessFlowSchema/mainFunction/template.ejs +0 -0
- package/src/TemplateManager/src/flowSchema/FlowSchemaEndpoint/InProcessFlowSchema/sns-sqs/data.js +36 -0
- package/src/TemplateManager/src/flowSchema/FlowSchemaEndpoint/InProcessFlowSchema/sns-sqs/template.ejs +0 -0
- package/src/TemplateManager/src/flowSchema/FlowSchemaEndpoint/OutComplete/functionYaml/data.js +35 -0
- package/src/TemplateManager/src/flowSchema/FlowSchemaEndpoint/OutComplete/functionYaml/template.ejs +0 -0
- package/src/TemplateManager/src/flowSchema/FlowSchemaEndpoint/OutComplete/handler/data.js +35 -0
- package/src/TemplateManager/src/flowSchema/FlowSchemaEndpoint/OutComplete/handler/template.ejs +0 -0
- package/src/TemplateManager/src/flowSchema/FlowSchemaEndpoint/OutComplete/mainFunction/data.js +35 -0
- package/src/TemplateManager/src/flowSchema/FlowSchemaEndpoint/OutComplete/mainFunction/template.ejs +0 -0
- package/src/TemplateManager/src/flowSchema/FlowSchemaEndpoint/OutComplete/sns-sqs/data.js +35 -0
- package/src/TemplateManager/src/flowSchema/FlowSchemaEndpoint/OutComplete/sns-sqs/template.ejs +0 -0
- package/src/TemplateManager/src/flowSchema/UploadS3Case/confirmReservedAfterUpload/functionYaml/data.js +102 -0
- package/src/TemplateManager/src/flowSchema/UploadS3Case/confirmReservedAfterUpload/functionYaml/template.ejs +30 -0
- package/src/TemplateManager/src/flowSchema/UploadS3Case/confirmReservedAfterUpload/handler/data.js +58 -0
- package/src/TemplateManager/src/flowSchema/UploadS3Case/confirmReservedAfterUpload/handler/template.ejs +126 -0
- package/src/TemplateManager/src/flowSchema/UploadS3Case/confirmReservedAfterUpload/mainFunction/data.js +51 -0
- package/src/TemplateManager/src/flowSchema/UploadS3Case/confirmReservedAfterUpload/mainFunction/template.ejs +121 -0
- package/src/TemplateManager/src/flowSchema/UploadS3Case/confirmReservedAfterUpload/queue/data.js +64 -0
- package/src/TemplateManager/src/flowSchema/UploadS3Case/confirmReservedAfterUpload/queue/template.ejs +45 -0
- package/src/TemplateManager/src/flowSchema/UploadS3Case/createObject/functionYaml/data.js +122 -0
- package/src/TemplateManager/src/flowSchema/UploadS3Case/createObject/functionYaml/template.ejs +37 -0
- package/src/TemplateManager/src/flowSchema/UploadS3Case/createObject/handler/data.js +72 -0
- package/src/TemplateManager/src/flowSchema/UploadS3Case/createObject/handler/template.ejs +107 -0
- package/src/TemplateManager/src/flowSchema/UploadS3Case/createObject/mainFunction/data.js +55 -0
- package/src/TemplateManager/src/flowSchema/UploadS3Case/createObject/mainFunction/template.ejs +133 -0
- package/src/TemplateManager/src/flowSchema/UploadS3Case/createObjectComplete/functionYaml/data.js +102 -0
- package/src/TemplateManager/src/flowSchema/UploadS3Case/createObjectComplete/functionYaml/template.ejs +30 -0
- package/src/TemplateManager/src/flowSchema/UploadS3Case/createObjectComplete/handler/data.js +58 -0
- package/src/TemplateManager/src/flowSchema/UploadS3Case/createObjectComplete/handler/template.ejs +103 -0
- package/src/TemplateManager/src/flowSchema/UploadS3Case/createObjectComplete/mainFunction/data.js +55 -0
- package/src/TemplateManager/src/flowSchema/UploadS3Case/createObjectComplete/mainFunction/template.ejs +86 -0
- package/src/TemplateManager/src/flowSchema/UploadS3Case/createObjectComplete/sns-sqs/data.js +72 -0
- package/src/TemplateManager/src/flowSchema/UploadS3Case/createObjectComplete/sns-sqs/template.ejs +49 -0
- package/src/TemplateManager/src/flowSchema/UploadS3Case/createPresignUrl/getsignUrlsAcc/functionYaml/data.js +85 -0
- package/src/TemplateManager/src/flowSchema/UploadS3Case/createPresignUrl/getsignUrlsAcc/functionYaml/template.ejs +27 -0
- package/src/TemplateManager/src/flowSchema/UploadS3Case/createPresignUrl/getsignUrlsAcc/handler/data.js +57 -0
- package/src/TemplateManager/src/flowSchema/UploadS3Case/createPresignUrl/getsignUrlsAcc/handler/template.ejs +120 -0
- package/src/TemplateManager/src/flowSchema/UploadS3Case/createPresignUrl/getsignUrlsAcc/mainFunction/data.js +51 -0
- package/src/TemplateManager/src/flowSchema/UploadS3Case/createPresignUrl/getsignUrlsAcc/mainFunction/template.ejs +164 -0
- package/src/TemplateManager/src/flowSchema/UploadS3Case/createPresignUrl/getsignUrlsAcc/sqs/data.js +65 -0
- package/src/TemplateManager/src/flowSchema/UploadS3Case/createPresignUrl/getsignUrlsAcc/sqs/template.ejs +53 -0
- package/src/TemplateManager/src/flowSchema/UploadS3Case/createPresignUrl/reservedLimitComplete/functionYaml/data.js +112 -0
- package/src/TemplateManager/src/flowSchema/UploadS3Case/createPresignUrl/reservedLimitComplete/functionYaml/template.ejs +30 -0
- package/src/TemplateManager/src/flowSchema/UploadS3Case/createPresignUrl/reservedLimitComplete/handler/data.js +57 -0
- package/src/TemplateManager/src/flowSchema/UploadS3Case/createPresignUrl/reservedLimitComplete/handler/template.ejs +126 -0
- package/src/TemplateManager/src/flowSchema/UploadS3Case/createPresignUrl/reservedLimitComplete/mainFunction/data.js +54 -0
- package/src/TemplateManager/src/flowSchema/UploadS3Case/createPresignUrl/reservedLimitComplete/mainFunction/template.ejs +254 -0
- package/src/TemplateManager/src/flowSchema/UploadS3Case/createPresignUrl/reservedLimitComplete/queue/data.js +64 -0
- package/src/TemplateManager/src/flowSchema/UploadS3Case/createPresignUrl/reservedLimitComplete/queue/template.ejs +45 -0
- package/src/TemplateManager/src/flowSchema/UploadS3Case/hookCode/handler/data.js +94 -0
- package/src/TemplateManager/src/flowSchema/UploadS3Case/hookCode/handler/templateAsyncHandler.ejs +110 -0
- package/src/TemplateManager/src/flowSchema/UploadS3Case/hookCode/handler/templateSyncHandler.ejs +49 -0
- package/src/TemplateManager/src/flowSchema/UploadS3Case/hookCode/hookLogic/data.js +44 -0
- package/src/TemplateManager/src/flowSchema/UploadS3Case/hookCode/mainFunction/data.js +66 -0
- package/src/TemplateManager/src/flowSchema/UploadS3Case/hookCode/mainFunction/template.ejs +7 -0
- package/src/TemplateManager/src/flowSchema/UploadS3Case/hookCode/queue/data.js +73 -0
- package/src/TemplateManager/src/flowSchema/UploadS3Case/hookCode/queue/snsTemplate.ejs +59 -0
- package/src/TemplateManager/src/flowSchema/UploadS3Case/hookCode/queue/sqsTemplate.ejs +43 -0
- package/src/TemplateManager/src/flowSchema/UploadS3Case/processFileS3AfterUpload/functionYml/HdrDsq/data.js +87 -0
- package/src/TemplateManager/src/flowSchema/UploadS3Case/processFileS3AfterUpload/functionYml/HdrDsq/template.ejs +30 -0
- package/src/TemplateManager/src/flowSchema/UploadS3Case/processFileS3AfterUpload/functionYml/HdrS3/data.js +112 -0
- package/src/TemplateManager/src/{flowTag/webSocket/websocketHandler/functionYaml → flowSchema/UploadS3Case/processFileS3AfterUpload/functionYml/HdrS3}/template.ejs +10 -5
- package/src/TemplateManager/src/flowSchema/UploadS3Case/processFileS3AfterUpload/handler/handlerDsq/data.js +45 -0
- package/src/TemplateManager/src/flowSchema/UploadS3Case/processFileS3AfterUpload/handler/handlerDsq/template.ejs +151 -0
- package/src/TemplateManager/src/flowSchema/UploadS3Case/processFileS3AfterUpload/handler/handlerS3/data.js +43 -0
- package/src/TemplateManager/src/flowSchema/UploadS3Case/processFileS3AfterUpload/handler/handlerS3/template.ejs +68 -0
- package/src/TemplateManager/src/flowSchema/UploadS3Case/processFileS3AfterUpload/mainFunction/data.js +43 -0
- package/src/TemplateManager/src/flowSchema/UploadS3Case/processFileS3AfterUpload/mainFunction/template.ejs +392 -0
- package/src/TemplateManager/src/flowSchema/UploadS3Case/processFileS3AfterUpload/queue/data.js +77 -0
- package/src/TemplateManager/src/flowSchema/UploadS3Case/processFileS3AfterUpload/queue/dsqTemplatePath.ejs +32 -0
- package/src/TemplateManager/src/flowSchema/UploadS3Case/processFileS3AfterUpload/queue/s3Template.ejs +59 -0
- package/src/TemplateManager/src/flowSchema/UploadS3Case/relate/S3/data.js +51 -0
- package/src/TemplateManager/src/flowSchema/UploadS3Case/relate/S3/template.ejs +13 -0
- package/src/TemplateManager/src/flowSchema/UploadS3Case/relate/libs/data.js +42 -0
- package/src/TemplateManager/src/flowSchema/UploadS3Case/relate/libs/template.ejs +137 -0
- package/src/TemplateManager/src/libs/Consts.js +60 -28
- package/src/TemplateManager/src/flowTag/webSocket/webSocketConnect/functionYaml/template.ejs +0 -10
- package/src/TemplateManager/src/flowTag/webSocket/websocketHandler/lambda/template.ejs +0 -131
- /package/src/TemplateManager/src/{flowTag/resources/dynamoDb/data.js → flowSchema/DefaultWebSocketResource/dynamoDb/WebSocketTaskData.js} +0 -0
|
@@ -25,12 +25,12 @@ const { getGraphServiceNameFromGraphServerTagWithCache,
|
|
|
25
25
|
} = require('@izara_project/izara-core-library-service-schemas/src/ServiceConfig')
|
|
26
26
|
|
|
27
27
|
const { firstLetterLowerCase: lowerCase, firstLetterUpperCase: upperCase } = require("../../../../MainLibs/src/Utils")
|
|
28
|
-
const { DEFAULT_HANDLER_PER_ACTION, createIamRole, RESOURCE_CLASSES, SOURCE_PATH, externalResourceName, externalResourceSns, getGraphServiceNameFromAllRelSchema, SAVE_FILE_NAME, LAMBDA_RESOURCE, SNS_RESOURCE, getGraphServiceNameFromObjectSchema, shortNameHandler, SHORT_FUNCTION_NAME } = require("../../libs/Consts");
|
|
28
|
+
const { DEFAULT_HANDLER_PER_ACTION, createIamRole, RESOURCE_CLASSES, SOURCE_PATH, externalResourceName, externalResourceSns, getGraphServiceNameFromAllRelSchema, SAVE_FILE_NAME, LAMBDA_RESOURCE, SNS_RESOURCE, getGraphServiceNameFromObjectSchema, shortNameHandler, SHORT_FUNCTION_NAME, defaultIamRolePerAction, resourceNames } = require("../../libs/Consts");
|
|
29
29
|
// const templatePath = path.join(__dirname, "./template.ejs");
|
|
30
30
|
const templatePath = path.join(__dirname, "./template.ejs");
|
|
31
31
|
const { getAllLocalRelationshipSchemas } = require('@izara_project/izara-core-library-service-schemas/src/GetObjectSchema')
|
|
32
|
-
|
|
33
|
-
const createExternalLambdaRole = async (_izContext, allObjSchemas, allRelSchemas, srcPath) => {
|
|
32
|
+
const { EXTERNAL_SERVICE_NAME } = require("../../../../GenerateCodeLibs/src/Consts")
|
|
33
|
+
const createExternalLambdaRole = async (_izContext, allObjSchemas, allRelSchemas, allLocalFlowSchemas, srcPath) => {
|
|
34
34
|
const allRelationshipSchemas = getAllLocalRelationshipSchemas(_izContext, srcPath)
|
|
35
35
|
// console.log("allRelationshipSchemas", allRelationshipSchemas);
|
|
36
36
|
const externalLambdaIamRoleArray = [];
|
|
@@ -75,9 +75,8 @@ const createExternalLambdaRole = async (_izContext, allObjSchemas, allRelSchemas
|
|
|
75
75
|
}
|
|
76
76
|
|
|
77
77
|
// findData external lambda role
|
|
78
|
-
const externalLambdaIamRoleFindData =
|
|
78
|
+
const externalLambdaIamRoleFindData = externalLambdaIamRoleDataFindData(_izContext);
|
|
79
79
|
externalLambdaIamRoleFindData && externalLambdaIamRoleArray.push(externalLambdaIamRoleFindData)
|
|
80
|
-
// processLogical
|
|
81
80
|
|
|
82
81
|
|
|
83
82
|
// updateRelationshipComplete external lambda role
|
|
@@ -89,7 +88,25 @@ const createExternalLambdaRole = async (_izContext, allObjSchemas, allRelSchemas
|
|
|
89
88
|
externalLambdaIamRoleProcessLogical && externalLambdaIamRoleArray.push(externalLambdaIamRoleProcessLogical)
|
|
90
89
|
}
|
|
91
90
|
|
|
92
|
-
|
|
91
|
+
if (allLocalFlowSchemas) {
|
|
92
|
+
for (const localFlowSchema of allLocalFlowSchemas) {
|
|
93
|
+
if (localFlowSchema.hasOwnProperty("uploadS3") && localFlowSchema.uploadS3 === true) {
|
|
94
|
+
const externalLambdaIamRoleGetPresignUrl = await externalLambdaIamRoleDataGetPresignUrl(_izContext);
|
|
95
|
+
externalLambdaIamRoleGetPresignUrl && externalLambdaIamRoleArray.push(externalLambdaIamRoleGetPresignUrl);
|
|
96
|
+
|
|
97
|
+
const externalLambdaIamRoleReservedLimitComplete = await externalLambdaIamRoleDataReservedLimitComplete(_izContext);
|
|
98
|
+
externalLambdaIamRoleReservedLimitComplete && externalLambdaIamRoleArray.push(externalLambdaIamRoleReservedLimitComplete);
|
|
99
|
+
|
|
100
|
+
const externalLambdaIamRoleProcessAfterUpload = await externalLambdaIamRoleDataProcessAfterUpload(_izContext);
|
|
101
|
+
externalLambdaIamRoleProcessAfterUpload && externalLambdaIamRoleArray.push(externalLambdaIamRoleProcessAfterUpload);
|
|
102
|
+
|
|
103
|
+
const externalLambdaIamRoleConfirmReservedAfterUpload = await externalLambdaIamRoleDataConfirmReservedAfterUpload(_izContext);
|
|
104
|
+
externalLambdaIamRoleConfirmReservedAfterUpload && externalLambdaIamRoleArray.push(externalLambdaIamRoleConfirmReservedAfterUpload);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
// console.log("externalLambdaIamRoleArray", externalLambdaIamRoleArray)
|
|
93
110
|
// console.log("createSourceArrayIamRole", JSON.stringify(externalLambdaIamRoleArray))
|
|
94
111
|
// return externalLambdaIamRoleArray
|
|
95
112
|
|
|
@@ -255,33 +272,21 @@ async function externalLambdaIamRoleDataDeleteRelationshipSchema(_izContext, all
|
|
|
255
272
|
}
|
|
256
273
|
}
|
|
257
274
|
|
|
258
|
-
|
|
275
|
+
function externalLambdaIamRoleDataFindData(_izContext) {
|
|
259
276
|
let functionName = upperCase(SHORT_FUNCTION_NAME.findData) + upperCase(shortNameHandler(HANDLER.hdrSqs));
|
|
260
277
|
let additionalResourcePermission = [];
|
|
261
|
-
let graphServiceNames = []
|
|
262
|
-
for (const objectSchema of allObjSchemas) {
|
|
263
|
-
for (const storgaeResource of Object.values(objectSchema.storageResources)) {
|
|
264
|
-
if (storgaeResource.storageType === STORAGE_TYPES.graph) {
|
|
265
|
-
let getGraphServiceName = await getGraphServiceNameFromGraphServerTagWithCache(_izContext, storgaeResource.graphServerTag)
|
|
266
|
-
if (!graphServiceNames.includes(getGraphServiceName)) {
|
|
267
|
-
graphServiceNames.push(getGraphServiceName)
|
|
268
|
-
}
|
|
269
|
-
}
|
|
270
|
-
}
|
|
271
|
-
}
|
|
272
|
-
|
|
273
278
|
|
|
274
279
|
additionalResourcePermission.push(
|
|
275
280
|
createIamRole(
|
|
276
281
|
{
|
|
277
282
|
[RESOURCE_CLASSES.lambda]: [LAMBDA_RESOURCE.invokeFunction]
|
|
278
283
|
},
|
|
279
|
-
|
|
280
|
-
externalResourceName(RESOURCE_CLASSES.lambda, "GetNodeV2HdrInv",
|
|
281
|
-
|
|
282
|
-
)
|
|
284
|
+
[
|
|
285
|
+
externalResourceName(RESOURCE_CLASSES.lambda, "GetNodeV2HdrInv", "GraphHandler")
|
|
286
|
+
]
|
|
283
287
|
)
|
|
284
288
|
)
|
|
289
|
+
console.log("findData template data:", { functionName, additionalResourcePermission })
|
|
285
290
|
return {
|
|
286
291
|
functionName,
|
|
287
292
|
additionalResourcePermission
|
|
@@ -310,4 +315,96 @@ async function externalLambdaIamRoleDataProcessLogical(_izContext, allObjectSche
|
|
|
310
315
|
}
|
|
311
316
|
}
|
|
312
317
|
|
|
318
|
+
function externalLambdaIamRoleDataGetPresignUrl(_izContext) {
|
|
319
|
+
let functionName = "GetPresignUrl" + upperCase(shortNameHandler(HANDLER.hdrSqs));
|
|
320
|
+
let additionalResourcePermission = [];
|
|
321
|
+
|
|
322
|
+
additionalResourcePermission.push(
|
|
323
|
+
createIamRole(
|
|
324
|
+
{
|
|
325
|
+
[RESOURCE_CLASSES.sns]: [SNS_RESOURCE.publish]
|
|
326
|
+
},
|
|
327
|
+
[
|
|
328
|
+
externalResourceSns("InReservedDynamicUsage", EXTERNAL_SERVICE_NAME.accountLimits)
|
|
329
|
+
]
|
|
330
|
+
),
|
|
331
|
+
createIamRole(
|
|
332
|
+
{
|
|
333
|
+
[RESOURCE_CLASSES.lambda]: [LAMBDA_RESOURCE.invokeFunction]
|
|
334
|
+
},
|
|
335
|
+
[
|
|
336
|
+
externalResourceName(RESOURCE_CLASSES.lambda, "StaticLimitProcessHdrInv", EXTERNAL_SERVICE_NAME.accountLimits)
|
|
337
|
+
]
|
|
338
|
+
)
|
|
339
|
+
)
|
|
340
|
+
// console.log("additionalResourcePermission GetPresignUrl::", JSON.stringify(additionalResourcePermission))
|
|
341
|
+
return {
|
|
342
|
+
functionName,
|
|
343
|
+
additionalResourcePermission
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
function externalLambdaIamRoleDataReservedLimitComplete(_izContext) {
|
|
348
|
+
let functionName = "ReservedLimitComp" + upperCase(shortNameHandler(HANDLER.hdrSqs));
|
|
349
|
+
let additionalResourcePermission = [];
|
|
350
|
+
|
|
351
|
+
additionalResourcePermission.push(
|
|
352
|
+
createIamRole(
|
|
353
|
+
{
|
|
354
|
+
[RESOURCE_CLASSES.sns]: [SNS_RESOURCE.publish]
|
|
355
|
+
},
|
|
356
|
+
[
|
|
357
|
+
externalResourceSns("InCancelUsage", EXTERNAL_SERVICE_NAME.accountLimits)
|
|
358
|
+
]
|
|
359
|
+
)
|
|
360
|
+
)
|
|
361
|
+
return {
|
|
362
|
+
functionName,
|
|
363
|
+
additionalResourcePermission
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
function externalLambdaIamRoleDataConfirmReservedAfterUpload(_izContext) {
|
|
368
|
+
let functionName = "ConfirmNewReserved" + upperCase(shortNameHandler(HANDLER.hdrSqs));
|
|
369
|
+
let additionalResourcePermission = []
|
|
370
|
+
|
|
371
|
+
additionalResourcePermission.push(
|
|
372
|
+
createIamRole(
|
|
373
|
+
{
|
|
374
|
+
[RESOURCE_CLASSES.sns]: [SNS_RESOURCE.publish]
|
|
375
|
+
},
|
|
376
|
+
[
|
|
377
|
+
externalResourceSns("OutReservedDynamicUsageComplet", EXTERNAL_SERVICE_NAME.accountLimits),
|
|
378
|
+
externalResourceSns("InConfirmUsage", EXTERNAL_SERVICE_NAME.accountLimits)
|
|
379
|
+
]
|
|
380
|
+
),
|
|
381
|
+
)
|
|
382
|
+
return {
|
|
383
|
+
functionName,
|
|
384
|
+
additionalResourcePermission
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
function externalLambdaIamRoleDataProcessAfterUpload(_izContext) {
|
|
389
|
+
let functionName = "ProcessAfterUploadS3" + shortNameHandler(upperCase("HdrS3"));
|
|
390
|
+
let additionalResourcePermission = []
|
|
391
|
+
|
|
392
|
+
additionalResourcePermission.push(
|
|
393
|
+
createIamRole(
|
|
394
|
+
{
|
|
395
|
+
[RESOURCE_CLASSES.sns]: [SNS_RESOURCE.publish]
|
|
396
|
+
},
|
|
397
|
+
[
|
|
398
|
+
externalResourceSns("InCancelUsage", EXTERNAL_SERVICE_NAME.accountLimits),
|
|
399
|
+
externalResourceSns("InConfirmUsage", EXTERNAL_SERVICE_NAME.accountLimits),
|
|
400
|
+
externalResourceSns("InReservedDynamicUsage", EXTERNAL_SERVICE_NAME.accountLimits),
|
|
401
|
+
]
|
|
402
|
+
)
|
|
403
|
+
)
|
|
404
|
+
return {
|
|
405
|
+
functionName,
|
|
406
|
+
additionalResourcePermission
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
|
|
313
410
|
module.exports = createExternalLambdaRole;
|
|
@@ -41,12 +41,11 @@ module.exports.generatedLambdaRole = async () => {
|
|
|
41
41
|
<%_ resourcePermission.action[resourcePerAction].forEach(permission => { _%>
|
|
42
42
|
"<%- resourcePerAction %>:<%- permission %>",
|
|
43
43
|
],
|
|
44
|
-
"Resource":
|
|
44
|
+
"Resource":[
|
|
45
45
|
<%_ resourcePermission.resource.forEach(resource => { _%>
|
|
46
|
-
[
|
|
47
46
|
`<%- resource _%>`,
|
|
48
|
-
|
|
49
|
-
|
|
47
|
+
<%_ }) _%>
|
|
48
|
+
]
|
|
50
49
|
<%_ }) _%>
|
|
51
50
|
<%_ }) _%>
|
|
52
51
|
}<% if(resourceIdx < data.additionalResourcePermission.length-1) {_%>, <%_} %>
|
|
@@ -23,14 +23,11 @@ const { ACTIONS, HANDLER, STORAGE_TYPES } = require('@izara_project/izara-core-l
|
|
|
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
25
|
const { DEFAULT_HANDLER_PER_ACTION, createIamRole, resourceNames, RESOURCE_CLASSES, DEFAULT_LAMBDA_ROLE_PER_ACTION, SOURCE_PATH, externalResourceName, getGraphServiceNameFromAllRelSchema, FUNCTION_NAME, SAVE_FILE_NAME, getGraphServiceNameFromObjectSchema } = require("../../libs/Consts");
|
|
26
|
-
const {
|
|
27
|
-
TOPIC_NAME_GRAPH_HANDLER,
|
|
28
|
-
TOPIC_NAME_GENERATE_CODE
|
|
29
|
-
} = require('../../../../GenerateCodeLibs/src/Consts')
|
|
26
|
+
const { TOPIC_NAME_GRAPH_HANDLER, TOPIC_NAME_GENERATE_CODE, EXTERNAL_SERVICE_NAME, TOPIC_NAME_EXTERNAL_SERVICE } = require('../../../../GenerateCodeLibs/src/Consts')
|
|
30
27
|
const templatePath = path.join(__dirname, "./template.ejs");
|
|
31
28
|
|
|
32
29
|
|
|
33
|
-
const createExternalSnsSubscriptions = async (_izContext, allRelSchemas,
|
|
30
|
+
const createExternalSnsSubscriptions = async (_izContext, allObjSchemas, allRelSchemas, allLocalFlowSchemas, srcPath) => {
|
|
34
31
|
const snsServiceConfigArray = [];
|
|
35
32
|
|
|
36
33
|
const snsServiceConfigUpdateRelationshipComplete = await snsSubScriptionUpdateRelationshipComplete(_izContext, allRelSchemas)
|
|
@@ -51,7 +48,18 @@ const createExternalSnsSubscriptions = async (_izContext, allRelSchemas, allObjS
|
|
|
51
48
|
const snsServiceConfigDeleteNodeComplete = await snsSubscriptionDeleteNodeComplate(_izContext, allObjSchemas)
|
|
52
49
|
snsServiceConfigDeleteNodeComplete && snsServiceConfigArray.push(snsServiceConfigDeleteNodeComplete);
|
|
53
50
|
|
|
51
|
+
if (allLocalFlowSchemas) {
|
|
52
|
+
for (const flowSchema of allLocalFlowSchemas) {
|
|
53
|
+
if (flowSchema.hasOwnProperty("uploadS3") && flowSchema.uploadS3 === true) {
|
|
54
|
+
const snsServiceConfigForReservedDynamicUsage = await snsSubscriptionReservedLimitCompleteForReservedDynamicUsage(_izContext);
|
|
55
|
+
snsServiceConfigForReservedDynamicUsage && snsServiceConfigArray.push(snsServiceConfigForReservedDynamicUsage);
|
|
54
56
|
|
|
57
|
+
const snsServiceConfigForConfirmReserved = await snsSubscriptionConfirmReserved(_izContext);
|
|
58
|
+
snsServiceConfigForConfirmReserved && snsServiceConfigArray.push(snsServiceConfigForConfirmReserved);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
// console.log("snsServiceConfigArray::", snsServiceConfigArray)
|
|
55
63
|
|
|
56
64
|
return {
|
|
57
65
|
templatePath: templatePath,
|
|
@@ -129,7 +137,24 @@ async function snsSubscriptionDeleteRelatipnshipComplete(_izContext, allRelSchem
|
|
|
129
137
|
sqsEndpoint: TOPIC_NAME_GENERATE_CODE.deleteRelComplete
|
|
130
138
|
}
|
|
131
139
|
}
|
|
132
|
-
// not done yet wait for comfirmation
|
|
133
140
|
|
|
141
|
+
function snsSubscriptionReservedLimitCompleteForReservedDynamicUsage(_izContext) {
|
|
142
|
+
let serviceNames = [EXTERNAL_SERVICE_NAME.accountLimits]
|
|
143
|
+
return {
|
|
144
|
+
serviceNames: serviceNames,
|
|
145
|
+
topicName: TOPIC_NAME_EXTERNAL_SERVICE.reservedDynamicUsageComplete,
|
|
146
|
+
sqsEndpoint: TOPIC_NAME_GENERATE_CODE.reservedLimitComplete + upperCase(HANDLER.hdrSqs)
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
|
|
151
|
+
function snsSubscriptionConfirmReserved(_izContext) {
|
|
152
|
+
let serviceNames = [EXTERNAL_SERVICE_NAME.accountLimits];
|
|
153
|
+
return {
|
|
154
|
+
serviceNames: serviceNames,
|
|
155
|
+
topicName: TOPIC_NAME_EXTERNAL_SERVICE.reservedDynamicUsageComplete,
|
|
156
|
+
sqsEndpoint: "ConfirmNewReserved" + upperCase(HANDLER.hdrSqs)
|
|
157
|
+
}
|
|
158
|
+
}
|
|
134
159
|
|
|
135
160
|
module.exports = createExternalSnsSubscriptions;
|
package/src/TemplateManager/src/flowSchema/DefaultWebSocketResource/dynamoDb/ReservedTableData.js
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright (C) 2020 Sven Mason <http://izara.io>
|
|
3
|
+
|
|
4
|
+
This program is free software: you can redistribute it and/or modify
|
|
5
|
+
it under the terms of the GNU Affero General Public License as
|
|
6
|
+
published by the Free Software Foundation, either version 3 of the
|
|
7
|
+
License, or (at your option) any later version.
|
|
8
|
+
|
|
9
|
+
This program is distributed in the hope that it will be useful,
|
|
10
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
11
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
12
|
+
GNU Affero General Public License for more details.
|
|
13
|
+
|
|
14
|
+
You should have received a copy of the GNU Affero General Public License
|
|
15
|
+
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
'use strict';
|
|
19
|
+
const path = require('path');
|
|
20
|
+
const fs = require('fs');
|
|
21
|
+
const { SOURCE_PATH, SAVE_FILE_NAME } = require('../../../libs/Consts');
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
const templatePath = path.join(__dirname, "../../../ResourceYaml/dynamodb/template.ejs")
|
|
26
|
+
|
|
27
|
+
function data(_izContext, srcPath) {
|
|
28
|
+
let resultForCreateSources = [];
|
|
29
|
+
const reservedDataTables = [
|
|
30
|
+
{
|
|
31
|
+
tableName: "ReservedDataMain",
|
|
32
|
+
attributes: [
|
|
33
|
+
{
|
|
34
|
+
keyType: "partitionKey",
|
|
35
|
+
AttributeName: "servicePendingId",
|
|
36
|
+
AttributeType: "S"
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
keyType: "sortKey",
|
|
40
|
+
AttributeName: "reservedDataId",
|
|
41
|
+
AttributeType: "S"
|
|
42
|
+
}
|
|
43
|
+
]
|
|
44
|
+
}
|
|
45
|
+
];
|
|
46
|
+
|
|
47
|
+
for (let reservedDataTable of reservedDataTables) {
|
|
48
|
+
resultForCreateSources.push(
|
|
49
|
+
{
|
|
50
|
+
templatePath: templatePath,
|
|
51
|
+
templateData: reservedDataTable,
|
|
52
|
+
setting: {
|
|
53
|
+
initialData: 'Resources:\n',
|
|
54
|
+
savePath: path.join(srcPath, SOURCE_PATH.resourceYaml),
|
|
55
|
+
saveFileName: SAVE_FILE_NAME.dynamoDbYaml,
|
|
56
|
+
fileExtension: ".yml",
|
|
57
|
+
isAppend: true
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
)
|
|
61
|
+
}
|
|
62
|
+
return resultForCreateSources;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
module.exports = data;
|
|
@@ -19,7 +19,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
19
19
|
const path = require('path');
|
|
20
20
|
const fs = require('fs');
|
|
21
21
|
|
|
22
|
-
const { SOURCE_PATH, SAVE_FILE_NAME,
|
|
22
|
+
const { SOURCE_PATH, SAVE_FILE_NAME, defaultIamRolePerAction, createIamRole, RESOURCE_CLASSES, DYNAMO_RESOURCE, resourceNames } = require("../../../../libs/Consts");
|
|
23
|
+
const { firstLetterUpperCase: upperCase } = require('../../../../../../MainLibs/src/Utils');
|
|
23
24
|
|
|
24
25
|
const templatePath = path.join(__dirname, "./template.ejs")
|
|
25
26
|
|
|
@@ -32,22 +33,39 @@ const templatePath = path.join(__dirname, "./template.ejs")
|
|
|
32
33
|
*/
|
|
33
34
|
|
|
34
35
|
function data(_izContext, srcPath) {
|
|
35
|
-
let createSourceParam
|
|
36
|
-
createSourceParam = [createWebSocketConnectYaml(_izContext, srcPath)]
|
|
36
|
+
let createSourceParam = [createWebSocketConnectYaml(_izContext, srcPath)]
|
|
37
37
|
return createSourceParam
|
|
38
38
|
}
|
|
39
39
|
|
|
40
40
|
function createWebSocketConnectYaml(_izContext, srcPath) {
|
|
41
41
|
let functionName = "WebSocketConnect"
|
|
42
|
+
let additionalResourcePermission = defaultIamRolePerAction();
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
additionalResourcePermission.push(
|
|
46
|
+
createIamRole(
|
|
47
|
+
{
|
|
48
|
+
[RESOURCE_CLASSES.dynamoDbTable]: [
|
|
49
|
+
DYNAMO_RESOURCE.putItem,
|
|
50
|
+
DYNAMO_RESOURCE.deleteItem
|
|
51
|
+
]
|
|
52
|
+
},
|
|
53
|
+
[
|
|
54
|
+
resourceNames(RESOURCE_CLASSES.dynamoDbTable, "WebSocketTask")
|
|
55
|
+
]
|
|
56
|
+
)
|
|
57
|
+
)
|
|
58
|
+
|
|
42
59
|
return {
|
|
43
60
|
templatePath: templatePath,
|
|
44
61
|
templateData: {
|
|
45
62
|
functionName,
|
|
46
|
-
resourceLocation: SOURCE_PATH.
|
|
63
|
+
resourceLocation: SOURCE_PATH.resourceLocationWebSocket,
|
|
64
|
+
additionalResourcePermission
|
|
47
65
|
},
|
|
48
66
|
setting: {
|
|
49
67
|
savePath: path.join(srcPath, SOURCE_PATH.appYaml),
|
|
50
|
-
saveFileName:
|
|
68
|
+
saveFileName: upperCase(SAVE_FILE_NAME.flowSchema),
|
|
51
69
|
fileExtension: ".yml",
|
|
52
70
|
isAppend: true
|
|
53
71
|
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
<%_ const join = require('path').join %>
|
|
2
|
+
<%- firstLetterUpperCase(functionName) -%>:
|
|
3
|
+
handler: <%- join(resourceLocation, `${firstLetterUpperCase(functionName)}.main`) %>
|
|
4
|
+
name: ${self:custom.iz_resourcePrefix}<%- firstLetterUpperCase(functionName) %>
|
|
5
|
+
events:
|
|
6
|
+
- websocket:
|
|
7
|
+
route: $connect
|
|
8
|
+
- websocket:
|
|
9
|
+
route: $disconnect
|
|
10
|
+
iamRoleStatements:
|
|
11
|
+
<%_ additionalResourcePermission.forEach(resourcePermission => { _%>
|
|
12
|
+
- Effect: <%- resourcePermission.effect %>
|
|
13
|
+
Action:
|
|
14
|
+
<%_ Object.keys(resourcePermission.action).forEach(resourcePerAction => { _%>
|
|
15
|
+
<%_ resourcePermission.action[resourcePerAction].forEach(permission => { _%>
|
|
16
|
+
- <%- resourcePerAction %>:<%- permission %>
|
|
17
|
+
<%_ }) _%>
|
|
18
|
+
<%_ }) _%>
|
|
19
|
+
Resource:
|
|
20
|
+
<%_ resourcePermission.resource.forEach(resource => { _%>
|
|
21
|
+
- "<%- resource %>"
|
|
22
|
+
<%_ }) _%>
|
|
23
|
+
<%_}) _%>
|
|
24
|
+
#<#<WebSocketConnectIamRole#>
|
|
25
|
+
#<#/<WebSocketConnectIamRole#>
|
|
26
|
+
|
|
27
|
+
<%_ function firstLetterUpperCase(text){
|
|
28
|
+
return text.charAt(0).toUpperCase() + text.slice(1)
|
|
29
|
+
} _%>
|
|
@@ -19,7 +19,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
19
19
|
const path = require('path');
|
|
20
20
|
const fs = require('fs');
|
|
21
21
|
|
|
22
|
-
const { SOURCE_PATH
|
|
22
|
+
const { SOURCE_PATH } = require("../../../../libs/Consts");
|
|
23
23
|
|
|
24
24
|
const templatePath = path.join(__dirname, "./template.ejs")
|
|
25
25
|
|
|
@@ -45,10 +45,10 @@ function createWebSocketConnectYaml(_izContext, srcPath) {
|
|
|
45
45
|
functionName,
|
|
46
46
|
},
|
|
47
47
|
setting: {
|
|
48
|
-
savePath: path.join(srcPath, SOURCE_PATH.
|
|
48
|
+
savePath: path.join(srcPath, SOURCE_PATH.webSocket),
|
|
49
49
|
saveFileName: functionName,
|
|
50
50
|
fileExtension: ".js",
|
|
51
|
-
isAppend:
|
|
51
|
+
isAppend: false
|
|
52
52
|
}
|
|
53
53
|
}
|
|
54
54
|
}
|
|
@@ -17,35 +17,40 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
17
17
|
|
|
18
18
|
'use strict';
|
|
19
19
|
|
|
20
|
+
const izaraShared = require('@izara_project/izara-shared');
|
|
21
|
+
const dynamodbSharedLib = izaraShared.dynamodbSharedLib;
|
|
20
22
|
const izara = require("@izara_project/izara-middleware");
|
|
21
23
|
const middleware = izara.middlewareHandler;
|
|
22
|
-
const
|
|
23
|
-
const api = new AWS.ApiGatewayManagementApi({ endpoint: process.env.iz_webSocketEndpoint });
|
|
24
|
-
|
|
24
|
+
const hash = require('object-hash')
|
|
25
25
|
module.exports.main = middleware.wrap(async (event, context, callback) => {
|
|
26
26
|
|
|
27
27
|
event._izContext.logger.debug('Event:', event);
|
|
28
|
-
|
|
28
|
+
const { eventType, connectionId } = event.requestContext
|
|
29
29
|
try {
|
|
30
30
|
|
|
31
31
|
if (event.requestContext) {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
switch (route) {
|
|
36
|
-
case '$connect':
|
|
32
|
+
switch (eventType) {
|
|
33
|
+
case 'CONNECT':
|
|
37
34
|
console.log('Connect websocket')
|
|
35
|
+
// await dynamodbSharedLib.putItem(
|
|
36
|
+
// event._izContext,
|
|
37
|
+
// await dynamodbSharedLib.tableName(event._izContext, "WebSocketTask"),
|
|
38
|
+
// {
|
|
39
|
+
// taskKey: "connect" + connectionId,
|
|
40
|
+
// connectionId: connectionId,
|
|
41
|
+
// }
|
|
42
|
+
// )
|
|
38
43
|
break
|
|
39
|
-
case '
|
|
44
|
+
case 'DISCONNECT':
|
|
45
|
+
console.log('Websocket are Disconnection')
|
|
40
46
|
// await dynamodbSharedLib.deleteItem(
|
|
41
47
|
// event._izContext,
|
|
42
|
-
// dynamodbSharedLib.tableName("WebSocketTask"),
|
|
48
|
+
// await dynamodbSharedLib.tableName(event._izContext, "WebSocketTask"),
|
|
43
49
|
// {
|
|
44
|
-
// taskKey: "
|
|
45
|
-
// connectionid:
|
|
50
|
+
// taskKey: "connect" + connectionId,
|
|
51
|
+
// connectionid: connectionId
|
|
46
52
|
// }
|
|
47
53
|
// );
|
|
48
|
-
console.log('Websocket are Disconnection')
|
|
49
54
|
break
|
|
50
55
|
case '$default':
|
|
51
56
|
console.log('Received unknown route:', route)
|
|
@@ -19,57 +19,59 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
19
19
|
const path = require('path');
|
|
20
20
|
const fs = require('fs');
|
|
21
21
|
|
|
22
|
-
const {
|
|
22
|
+
const { firstLetterLowerCase: lowerCase, firstLetterUpperCase: upperCase } = require("../../../../../../MainLibs/src/Utils");
|
|
23
|
+
const { SOURCE_PATH, defaultIamRolePerAction, shortNameHandler, SAVE_FILE_NAME, createIamRole, RESOURCE_CLASSES, SNS_RESOURCE, resourceNames, DYNAMO_RESOURCE } = require('../../../../libs/Consts');
|
|
24
|
+
const templatePath = path.join(__dirname, "./template.ejs")
|
|
23
25
|
|
|
24
|
-
const { firstLetterLowerCase: lowerCase, firstLetterUpperCase: upperCase, firstLetterUpperCase, checkOverWriteGenerateMainFunction } = require("../../../../../../MainLibs/src/Utils")
|
|
25
|
-
const { DEFAULT_HANDLER_PER_ACTION, SOURCE_PATH, defaultIamRolePerAction, createIamRole, RESOURCE_CLASSES, SNS_RESOURCE, resourceNames } = require("../../../../libs/Consts");
|
|
26
26
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* receive objectSchema
|
|
31
|
-
* create data for WebScoket handler template
|
|
32
|
-
*
|
|
33
|
-
* @param {Object} objectSchema
|
|
34
|
-
* @return {{templatePath, templateData,setting}}
|
|
35
|
-
*/
|
|
36
|
-
|
|
37
|
-
function data(_izContext, srcPath) {
|
|
27
|
+
function data(_izContext, flowSchema, srcPath) {
|
|
38
28
|
return [createSourceParams(_izContext, srcPath)]
|
|
39
29
|
}
|
|
40
30
|
|
|
41
|
-
function createSourceParams(_izContext, srcPath) {
|
|
42
|
-
let functionName = "
|
|
31
|
+
function createSourceParams(_izContext, flowSchema, srcPath) {
|
|
32
|
+
let functionName = "InProcessWebSocket";
|
|
33
|
+
let handlerType = "HdrWbs"
|
|
43
34
|
let additionalResourcePermission = defaultIamRolePerAction();
|
|
44
|
-
let
|
|
45
|
-
|
|
35
|
+
let functionNameConfig = upperCase(functionName) + upperCase(shortNameHandler(handlerType))
|
|
36
|
+
|
|
46
37
|
additionalResourcePermission.push(
|
|
47
38
|
createIamRole(
|
|
48
39
|
{
|
|
49
|
-
[RESOURCE_CLASSES.sns]: [
|
|
50
|
-
SNS_RESOURCE.publish
|
|
51
|
-
]
|
|
40
|
+
[RESOURCE_CLASSES.sns]: [SNS_RESOURCE.publish]
|
|
52
41
|
},
|
|
53
42
|
[
|
|
54
|
-
resourceNames(RESOURCE_CLASSES.sns,
|
|
43
|
+
resourceNames(RESOURCE_CLASSES.sns, `InProcess${flowSchema.flowTag}`)
|
|
55
44
|
]
|
|
45
|
+
),
|
|
46
|
+
createIamRole(
|
|
47
|
+
{
|
|
48
|
+
[RESOURCE_CLASSES.dynamoDbTable]: [
|
|
49
|
+
DYNAMO_RESOURCE.putItem,
|
|
50
|
+
DYNAMO_RESOURCE.deleteItem
|
|
51
|
+
]
|
|
52
|
+
},
|
|
53
|
+
resourceNames(RESOURCE_CLASSES.dynamoDbTable, "WebSocketTask")
|
|
56
54
|
)
|
|
57
55
|
)
|
|
56
|
+
|
|
58
57
|
return {
|
|
59
58
|
templatePath: templatePath,
|
|
60
59
|
templateData: {
|
|
61
|
-
resourceLocation: SOURCE_PATH.resourceLocationPerAction,
|
|
62
60
|
functionName,
|
|
63
61
|
handlerType,
|
|
64
62
|
functionNameConfig,
|
|
65
|
-
additionalResourcePermission
|
|
63
|
+
additionalResourcePermission,
|
|
64
|
+
resourceLocation: SOURCE_PATH.resourceLocationWebSocket,
|
|
65
|
+
route: flowSchema.flowTag
|
|
66
66
|
},
|
|
67
67
|
setting: {
|
|
68
68
|
savePath: path.join(srcPath, SOURCE_PATH.appYaml),
|
|
69
|
-
saveFileName:
|
|
70
|
-
fileExtension:
|
|
69
|
+
saveFileName: upperCase(SAVE_FILE_NAME.flowSchema),
|
|
70
|
+
fileExtension: '.yml',
|
|
71
71
|
isAppend: true
|
|
72
72
|
}
|
|
73
73
|
}
|
|
74
74
|
}
|
|
75
|
-
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
module.exports = data;
|
|
@@ -0,0 +1,37 @@
|
|
|
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: $connect
|
|
8
|
+
- websocket:
|
|
9
|
+
route: $disconnect
|
|
10
|
+
- websocket:
|
|
11
|
+
route: $default
|
|
12
|
+
- websocket:
|
|
13
|
+
route: <%- route %>
|
|
14
|
+
# authorizer: ${self:custom.iz_authorizerAppLevel}
|
|
15
|
+
# identifierResource: 'route.request.header.Auth'
|
|
16
|
+
iamRoleStatements:
|
|
17
|
+
<%_ additionalResourcePermission.forEach(resourcePermission => { _%>
|
|
18
|
+
- Effect: <%- resourcePermission.effect %>
|
|
19
|
+
Action:
|
|
20
|
+
<%_ Object.keys(resourcePermission.action).forEach(resourcePerAction => { _%>
|
|
21
|
+
<%_ resourcePermission.action[resourcePerAction].forEach(permission => { _%>
|
|
22
|
+
- <%- resourcePerAction %>:<%- permission %>
|
|
23
|
+
<%_}) _%>
|
|
24
|
+
<%_ }) _%>
|
|
25
|
+
Resource:
|
|
26
|
+
<%_ resourcePermission.resource.forEach(resource => { _%>
|
|
27
|
+
- <%- resource %>
|
|
28
|
+
<%_ }) _%>
|
|
29
|
+
<%_}) _%>
|
|
30
|
+
#<#<%- functionName %><%- handlerType %>IamRole#>
|
|
31
|
+
#<#/<%- functionName %><%- handlerType %>IamRole#>
|
|
32
|
+
<%_ function firstLetterUpperCase(text){
|
|
33
|
+
return text.charAt(0).toUpperCase() + text.slice(1)
|
|
34
|
+
} _%>
|
|
35
|
+
<%_ function firstLetterLowerCase(str) {
|
|
36
|
+
return str.charAt(0).toLowerCase() + str.slice(1)
|
|
37
|
+
} _%>
|
package/src/TemplateManager/src/flowSchema/FlowSchemaEndpoint/InProcessFlowSchema/handler/data.js
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright (C) 2020 Sven Mason <http://izara.io>
|
|
3
|
+
|
|
4
|
+
This program is free software: you can redistribute it and/or modify
|
|
5
|
+
it under the terms of the GNU Affero General Public License as
|
|
6
|
+
published by the Free Software Foundation, either version 3 of the
|
|
7
|
+
License, or (at your option) any later version.
|
|
8
|
+
|
|
9
|
+
This program is distributed in the hope that it will be useful,
|
|
10
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
11
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
12
|
+
GNU Affero General Public License for more details.
|
|
13
|
+
|
|
14
|
+
You should have received a copy of the GNU Affero General Public License
|
|
15
|
+
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
'use strict';
|
|
19
|
+
const path = require('path');
|
|
20
|
+
const fs = require('fs');
|
|
21
|
+
|
|
22
|
+
const { firstLetterLowerCase: lowerCase, firstLetterUpperCase: upperCase } = require("../../../../../../MainLibs/src/Utils");
|
|
23
|
+
const { SOURCE_PATH } = require('../../../../libs/Consts');
|
|
24
|
+
const templatePath = path.join(__dirname, './template.ejs')
|
|
25
|
+
|
|
26
|
+
function data(_izContext, srcPath) {
|
|
27
|
+
return [createSourceParams(_izContext, srcPath)]
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function createSourceParams(_izContext, srcPath) {
|
|
31
|
+
let functionName = "InProcessWebSocket";
|
|
32
|
+
let handlerType = "HdrWbs";
|
|
33
|
+
|
|
34
|
+
return {
|
|
35
|
+
templatePath: templatePath,
|
|
36
|
+
templateData: {},
|
|
37
|
+
setting: {
|
|
38
|
+
savePath: path.join(srcPath, SOURCE_PATH.webSocket),
|
|
39
|
+
saveFileName: upperCase(functionName) + upperCase(handlerType),
|
|
40
|
+
fileExtension: ".js",
|
|
41
|
+
isAppend: true
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
module.exports = data;
|