@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
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright (C) 2021 Sven Mason <http://izara.io>
|
|
3
|
+
|
|
4
|
+
This program is free software: you can redistribute it and/or modify
|
|
5
|
+
it under the terms of the GNU Affero General Public License as
|
|
6
|
+
published by the Free Software Foundation, either version 3 of the
|
|
7
|
+
License, or (at your option) any later version.
|
|
8
|
+
|
|
9
|
+
This program is distributed in the hope that it will be useful,
|
|
10
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
11
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
12
|
+
GNU Affero General Public License for more details.
|
|
13
|
+
|
|
14
|
+
You should have received a copy of the GNU Affero General Public License
|
|
15
|
+
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
'use strict';
|
|
19
|
+
|
|
20
|
+
const path = require('path');
|
|
21
|
+
|
|
22
|
+
const templatePath = path.join(__dirname, "./template.ejs")
|
|
23
|
+
|
|
24
|
+
const { SOURCE_PATH } = require("../../../../libs/Consts");
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* receive objectSchema
|
|
28
|
+
*
|
|
29
|
+
* @param {Object} flowSchema
|
|
30
|
+
* @return {{ templatePath, templateData, setting } }
|
|
31
|
+
*/
|
|
32
|
+
|
|
33
|
+
function data(_izContext, flowSchema, srcPath) {
|
|
34
|
+
return [createSourceParams(_izContext, flowSchema, srcPath)]
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function createSourceParams(_izContext, srcPath) {
|
|
38
|
+
let functionName = "ConfirmNewReserved"
|
|
39
|
+
return {
|
|
40
|
+
templatePath: templatePath,
|
|
41
|
+
templateData: {},
|
|
42
|
+
setting: {
|
|
43
|
+
saveFileName: `${functionName}_Main`,
|
|
44
|
+
savePath: path.join(srcPath, SOURCE_PATH.webSocket),
|
|
45
|
+
fileExtension: ".js",
|
|
46
|
+
isAppend: false
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
module.exports = data
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright (C) 2021 Sven Mason <http://izara.io>
|
|
3
|
+
|
|
4
|
+
This program is free software: you can redistribute it and/or modify
|
|
5
|
+
it under the terms of the GNU Affero General Public License as
|
|
6
|
+
published by the Free Software Foundation, either version 3 of the
|
|
7
|
+
License, or (at your option) any later version.
|
|
8
|
+
|
|
9
|
+
This program is distributed in the hope that it will be useful,
|
|
10
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
11
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
12
|
+
GNU Affero General Public License for more details.
|
|
13
|
+
|
|
14
|
+
You should have received a copy of the GNU Affero General Public License
|
|
15
|
+
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
'use strict';
|
|
19
|
+
|
|
20
|
+
const izaraShared = require('@izara_project/izara-shared');
|
|
21
|
+
const dynamodbSharedLib = izaraShared.dynamodbSharedLib;
|
|
22
|
+
const snsSharedLib = izaraShared.snsSharedLib;
|
|
23
|
+
const sns = require('@izara_project/izara-core-library-external-request').sns
|
|
24
|
+
const consts = require('@izara_project/izara-market-library-service-schemas/src/GenerateCodeLibs/src/Consts')
|
|
25
|
+
const { getNestObject } = require('../../libs/source/ImportDataLib')
|
|
26
|
+
/**
|
|
27
|
+
* description of function.
|
|
28
|
+
* @param {Object} _izContext
|
|
29
|
+
* @param {CorrelationIds} _izContext.correlationIds - property of _izContext
|
|
30
|
+
* @param {Logger} _izContext.logger - property of _izContext
|
|
31
|
+
* @param {Logger} _izContext.logger - property of _izContext
|
|
32
|
+
* @param {Object} returnMessage - limitValue or limitFound
|
|
33
|
+
* @param {Array} errorsFound - array
|
|
34
|
+
* @param {boolean} passStatus - true || false
|
|
35
|
+
* @param {Object} passBackProperties - identifier
|
|
36
|
+
|
|
37
|
+
*
|
|
38
|
+
* @returns {object} returnResponse
|
|
39
|
+
*/
|
|
40
|
+
|
|
41
|
+
module.exports.confirmNewReserved = async (
|
|
42
|
+
_izContext,
|
|
43
|
+
returnMessage,
|
|
44
|
+
errorsFound,
|
|
45
|
+
passStatus,
|
|
46
|
+
passBackProperties
|
|
47
|
+
|
|
48
|
+
) => {
|
|
49
|
+
try {
|
|
50
|
+
_izContext.logger.debug('----- confirmNewReserved event params', {
|
|
51
|
+
_izContext: _izContext,
|
|
52
|
+
returnMessage: returnMessage,
|
|
53
|
+
errorsFound: errorsFound,
|
|
54
|
+
passStatus: passStatus,
|
|
55
|
+
passBackProperties: passBackProperties
|
|
56
|
+
})
|
|
57
|
+
|
|
58
|
+
let servicePendingId = passBackProperties.passBackProperties.identifier.servicePendingId;
|
|
59
|
+
let reservedDataId = passBackProperties.passBackProperties.identifier.reservedDataId;
|
|
60
|
+
let userId = passBackProperties.passBackProperties.identifier.userId;
|
|
61
|
+
let realFileSize = passBackProperties.passBackProperties.identifier.realFileSize;
|
|
62
|
+
|
|
63
|
+
let uniqueIdentify = getNestObject(
|
|
64
|
+
_izContext,
|
|
65
|
+
returnMessage.limitFound,
|
|
66
|
+
["runningTotal", "uniqueIdentify", "usedTimestampId"]
|
|
67
|
+
);
|
|
68
|
+
|
|
69
|
+
// confirmUsage
|
|
70
|
+
let confirmUsageMessage = {
|
|
71
|
+
userId: userId,
|
|
72
|
+
limitTag: consts.LIMIT_TAG.uploadData,
|
|
73
|
+
uniqueIdentify: uniqueIdentify,
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
let sendMessageToConfirmUsage = {
|
|
77
|
+
Message: JSON.stringify(confirmUsageMessage),
|
|
78
|
+
TopicArn: await snsSharedLib.snsTopicArn(_izContext, 'InConfirmUsage', consts.EXTERNAL_SERVICE_NAME.accountLimits)
|
|
79
|
+
};
|
|
80
|
+
_izContext.logger.debug("sendMessageToConfirmUsage", sendMessageToConfirmUsage);
|
|
81
|
+
await sns.publishAsync(_izContext, sendMessageToConfirmUsage);
|
|
82
|
+
|
|
83
|
+
// update reservedDataValue as real size in ReservedDataMain table
|
|
84
|
+
await dynamodbSharedLib.updateItem(
|
|
85
|
+
_izContext,
|
|
86
|
+
await dynamodbSharedLib.tableName(_izContext, 'ReservedDataMain'),
|
|
87
|
+
{
|
|
88
|
+
servicePendingId: servicePendingId,
|
|
89
|
+
reservedDataId: reservedDataId
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
reservedValue: realFileSize
|
|
93
|
+
}
|
|
94
|
+
)
|
|
95
|
+
|
|
96
|
+
// update importBatchMainTable
|
|
97
|
+
let sendMessageToUpdateImportBatchStatus = {
|
|
98
|
+
objInstanceFull: {
|
|
99
|
+
identifiers: {
|
|
100
|
+
importBatchId: servicePendingId
|
|
101
|
+
},
|
|
102
|
+
fields: {
|
|
103
|
+
importBatchStatus: 'uploadComplete'
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
let sendMessageToUpdateImportBatch = {
|
|
109
|
+
Message: JSON.stringify(sendMessageToUpdateImportBatchStatus),
|
|
110
|
+
TopicArn: await snsSharedLib.snsTopicArn(_izContext, `InImportBatchMainUpdate`)
|
|
111
|
+
};
|
|
112
|
+
_izContext.logger.debug("sendMessageToUpdateImportBatch", sendMessageToUpdateImportBatch);
|
|
113
|
+
await sns.publishAsync(_izContext, sendMessageToUpdateImportBatch);
|
|
114
|
+
|
|
115
|
+
return { returnResponse: 'success' }
|
|
116
|
+
|
|
117
|
+
} catch (err) {
|
|
118
|
+
_izContext.logger.debug('error ConfirmNewReservedMain: ', err)
|
|
119
|
+
throw (err)
|
|
120
|
+
}
|
|
121
|
+
}
|
package/src/TemplateManager/src/flowSchema/UploadS3Case/confirmReservedAfterUpload/queue/data.js
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright (C) 2020 Sven Mason <http://izara.io>
|
|
3
|
+
|
|
4
|
+
This program is free software: you can redistribute it and/or modify
|
|
5
|
+
it under the terms of the GNU Affero General Public License as
|
|
6
|
+
published by the Free Software Foundation, either version 3 of the
|
|
7
|
+
License, or (at your option) any later version.
|
|
8
|
+
|
|
9
|
+
This program is distributed in the hope that it will be useful,
|
|
10
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
11
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
12
|
+
GNU Affero General Public License for more details.
|
|
13
|
+
|
|
14
|
+
You should have received a copy of the GNU Affero General Public License
|
|
15
|
+
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
'use strict';
|
|
19
|
+
|
|
20
|
+
const path = require("path")
|
|
21
|
+
|
|
22
|
+
const { SOURCE_PATH, SAVE_FILE_NAME } = require('../../../../libs/Consts');
|
|
23
|
+
const { TOPIC_NAME_GENERATE_CODE } = require("../../../../../../GenerateCodeLibs/src/Consts");
|
|
24
|
+
|
|
25
|
+
const templatePath = path.join(__dirname, './template.ejs');
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* create data for dynamoDbYaml tempalte from objectSchema
|
|
30
|
+
* return array of dynamoDb data
|
|
31
|
+
* because one objectSchema can create multiple dynamoDb table
|
|
32
|
+
*
|
|
33
|
+
* @param {Object} _izContext
|
|
34
|
+
* @param {Object} objectSchema
|
|
35
|
+
* @returns {Object[]} - data of multiple dynamoDb template
|
|
36
|
+
*/
|
|
37
|
+
|
|
38
|
+
function data(_izContext, srcPath) {
|
|
39
|
+
let resultForCreateSqs = [];
|
|
40
|
+
const WebSocketSqsQueueNames = [];
|
|
41
|
+
const setting = {
|
|
42
|
+
initialData: "Resources:\n",
|
|
43
|
+
savePath: path.join(srcPath, SOURCE_PATH.resourceYaml),
|
|
44
|
+
saveFileName: SAVE_FILE_NAME.snsInSqsYaml,
|
|
45
|
+
fileExtension: ".yml",
|
|
46
|
+
isAppend: true
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
WebSocketSqsQueueNames.push(
|
|
50
|
+
{
|
|
51
|
+
queueName: "ConfirmNewReserved"
|
|
52
|
+
}
|
|
53
|
+
)
|
|
54
|
+
|
|
55
|
+
for (let WebSocketSqsQueueName of WebSocketSqsQueueNames) {
|
|
56
|
+
resultForCreateSqs.push(({
|
|
57
|
+
templatePath: templatePath,
|
|
58
|
+
templateData: WebSocketSqsQueueName,
|
|
59
|
+
setting: setting
|
|
60
|
+
}))
|
|
61
|
+
}
|
|
62
|
+
return resultForCreateSqs
|
|
63
|
+
}
|
|
64
|
+
module.exports = data;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
##===== [Queue]
|
|
2
|
+
<%- queueName %>HdrSqs:
|
|
3
|
+
Type: "AWS::SQS::Queue"
|
|
4
|
+
Properties:
|
|
5
|
+
QueueName: ${self:custom.iz_resourcePrefix}<%- queueName %>HdrSqs
|
|
6
|
+
RedrivePolicy:
|
|
7
|
+
deadLetterTargetArn:
|
|
8
|
+
# !GetAtt
|
|
9
|
+
Fn::GetAtt:
|
|
10
|
+
- <%- queueName %>HdrSqsDLQ
|
|
11
|
+
- Arn
|
|
12
|
+
maxReceiveCount: 3
|
|
13
|
+
VisibilityTimeout: 120
|
|
14
|
+
##==== [QueueDLQ]
|
|
15
|
+
<%- queueName %>HdrSqsDLQ:
|
|
16
|
+
Type: AWS::SQS::Queue
|
|
17
|
+
Properties:
|
|
18
|
+
QueueName: ${self:custom.iz_resourcePrefix}<%- queueName %>HdrSqsDLQ
|
|
19
|
+
##==== [QueuePolicy]
|
|
20
|
+
<%- queueName %>HdrSqsPolicy:
|
|
21
|
+
Type: AWS::SQS::QueuePolicy
|
|
22
|
+
Properties:
|
|
23
|
+
PolicyDocument:
|
|
24
|
+
Version: "2012-10-17"
|
|
25
|
+
Statement:
|
|
26
|
+
- Sid: "allow-sns-messages"
|
|
27
|
+
Effect: Allow
|
|
28
|
+
Principal: "*"
|
|
29
|
+
Resource:
|
|
30
|
+
# !GetAtt
|
|
31
|
+
Fn::GetAtt:
|
|
32
|
+
- <%- queueName %>HdrSqs
|
|
33
|
+
- Arn
|
|
34
|
+
Action: "SQS:SendMessage"
|
|
35
|
+
Queues:
|
|
36
|
+
- Ref: <%- queueName %>HdrSqs
|
|
37
|
+
#<#<%- firstLetterUpperCase(queueName) %>QueueSetting#>
|
|
38
|
+
#<#/<%- firstLetterUpperCase(queueName) %>QueueSetting#>
|
|
39
|
+
|
|
40
|
+
<%_ function firstLetterUpperCase(text){
|
|
41
|
+
return text.charAt(0).toUpperCase() + text.slice(1)
|
|
42
|
+
} _%>
|
|
43
|
+
<%_ function firstLetterLowerCase(str) {
|
|
44
|
+
return str.charAt(0).toLowerCase() + str.slice(1)
|
|
45
|
+
} _%>
|
|
@@ -0,0 +1,122 @@
|
|
|
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 { FLOW_SCHEMA_HOOK_STATE } = require('@izara_project/izara-core-library-service-schemas/src/Consts')
|
|
23
|
+
const { firstLetterUpperCase: upperCase } = require('../../../../../../MainLibs/src/Utils')
|
|
24
|
+
const { SOURCE_PATH, defaultIamRolePerAction, createIamRole, RESOURCE_CLASSES, SNS_RESOURCE, resourceNames, DYNAMO_RESOURCE, SAVE_FILE_NAME, FUNCTION_NAME, shortNameHandler } = require("../../../../libs/Consts");
|
|
25
|
+
const templatePath = path.join(__dirname, "template.ejs")
|
|
26
|
+
const hookTemplate = path.join(__dirname, "./hookTemplate.ejs")
|
|
27
|
+
/**
|
|
28
|
+
* receive objectSchema
|
|
29
|
+
* create data for WebScoket handler template
|
|
30
|
+
*
|
|
31
|
+
* @param {Object} objectSchema
|
|
32
|
+
* @return {{templatePath, templateData,setting}}
|
|
33
|
+
*/
|
|
34
|
+
|
|
35
|
+
function data(_izContext, flowSchema, srcPath) {
|
|
36
|
+
return [createSourceParams(_izContext, flowSchema, srcPath)]
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function createSourceParams(_izContext, flowSchema, srcPath) {
|
|
40
|
+
let functionName = upperCase(FUNCTION_NAME.createObjectS3)
|
|
41
|
+
let handlerType = upperCase("hdrWbs")
|
|
42
|
+
let additionalResourcePermission = defaultIamRolePerAction();
|
|
43
|
+
let route = "webSocket"
|
|
44
|
+
|
|
45
|
+
additionalResourcePermission.push(
|
|
46
|
+
createIamRole(
|
|
47
|
+
{
|
|
48
|
+
[RESOURCE_CLASSES.sns]: [
|
|
49
|
+
SNS_RESOURCE.publish
|
|
50
|
+
]
|
|
51
|
+
},
|
|
52
|
+
[
|
|
53
|
+
resourceNames(RESOURCE_CLASSES.sns, "*")
|
|
54
|
+
]
|
|
55
|
+
),
|
|
56
|
+
createIamRole(
|
|
57
|
+
{
|
|
58
|
+
[RESOURCE_CLASSES.dynamoDbTable]: [
|
|
59
|
+
DYNAMO_RESOURCE.putItem,
|
|
60
|
+
DYNAMO_RESOURCE.getItem,
|
|
61
|
+
DYNAMO_RESOURCE.query,
|
|
62
|
+
DYNAMO_RESOURCE.deleteItem,
|
|
63
|
+
DYNAMO_RESOURCE.updateItem
|
|
64
|
+
]
|
|
65
|
+
},
|
|
66
|
+
[
|
|
67
|
+
resourceNames(RESOURCE_CLASSES.dynamoDbTable, "WebSocketTask")
|
|
68
|
+
]
|
|
69
|
+
),
|
|
70
|
+
createIamRole(
|
|
71
|
+
{
|
|
72
|
+
"execute-api": [
|
|
73
|
+
"ManageConnections"
|
|
74
|
+
]
|
|
75
|
+
},
|
|
76
|
+
[
|
|
77
|
+
resourceNames(RESOURCE_CLASSES.webSocket)
|
|
78
|
+
]
|
|
79
|
+
)
|
|
80
|
+
)
|
|
81
|
+
|
|
82
|
+
if (flowSchema?.hook) {
|
|
83
|
+
for (const [hookName, hookProperties] of Object.entries(flowSchema.hook)) {
|
|
84
|
+
for (const hookFunction of hookProperties.functionList) {
|
|
85
|
+
if (hookName === FLOW_SCHEMA_HOOK_STATE.beforeCreate) {
|
|
86
|
+
if (hookFunction?.permission) {
|
|
87
|
+
for (const permission of hookFunction.permission) {
|
|
88
|
+
if (hookFunction.event?.initialEvent && hookFunction.initialEvent === true)
|
|
89
|
+
additionalResourcePermission.push(
|
|
90
|
+
createIamRole(
|
|
91
|
+
permission.action,
|
|
92
|
+
permission.resource,
|
|
93
|
+
permission.effect
|
|
94
|
+
)
|
|
95
|
+
)
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
// console.log("additionalResourcePermission in createObjectS3", additionalResourcePermission)
|
|
103
|
+
return {
|
|
104
|
+
templatePath: templatePath,
|
|
105
|
+
templateData: {
|
|
106
|
+
resourceLocation: SOURCE_PATH.resourceLocationWebSocket,
|
|
107
|
+
functionName,
|
|
108
|
+
handlerType,
|
|
109
|
+
additionalResourcePermission,
|
|
110
|
+
route,
|
|
111
|
+
functionNameConfig: upperCase(functionName) + upperCase(shortNameHandler(handlerType))
|
|
112
|
+
},
|
|
113
|
+
setting: {
|
|
114
|
+
savePath: path.join(srcPath, SOURCE_PATH.appYaml),
|
|
115
|
+
saveFileName: upperCase(SAVE_FILE_NAME.flowSchema),
|
|
116
|
+
fileExtension: ".yml",
|
|
117
|
+
isAppend: true
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
module.exports = data;
|
package/src/TemplateManager/src/flowSchema/UploadS3Case/createObject/functionYaml/template.ejs
ADDED
|
@@ -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
|
+
} _%>
|
|
@@ -0,0 +1,72 @@
|
|
|
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 { FLOW_SCHEMA_HOOK_STATE } = require('@izara_project/izara-core-library-service-schemas/src/Consts')
|
|
22
|
+
const { SOURCE_PATH, FUNCTION_NAME } = require("../../../../libs/Consts");
|
|
23
|
+
const { firstLetterLowerCase: lowerCase, firstLetterUpperCase: upperCase } = require("../../../../../../MainLibs/src/Utils")
|
|
24
|
+
const templatePath = path.join(__dirname, "template.ejs")
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* receive objectSchema
|
|
28
|
+
* create data for WebScoket handler template
|
|
29
|
+
*
|
|
30
|
+
* @param {Object} objectSchema
|
|
31
|
+
* @return {{templatePath, templateData,setting}}
|
|
32
|
+
*/
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
function data(_izContext, flowSchema, srcPath) {
|
|
36
|
+
return [createParamsForCreateSource(_izContext, flowSchema, srcPath)]
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function createParamsForCreateSource(_izContext, flowSchema, srcPath) {
|
|
40
|
+
let functionName = upperCase(FUNCTION_NAME.createObjectS3)
|
|
41
|
+
let handlerType = "HdrWbs"
|
|
42
|
+
let hook;
|
|
43
|
+
let hookFunctionName;
|
|
44
|
+
if (flowSchema?.hook) {
|
|
45
|
+
for (const [hookName, hookProperties] of Object.entries(flowSchema.hook)) {
|
|
46
|
+
for (const hookFunction of hookProperties.functionList) {
|
|
47
|
+
if (hookName === FLOW_SCHEMA_HOOK_STATE.beforeCreate) {
|
|
48
|
+
if (hookFunction.event?.initialEvent && hookFunction.event.initialEvent === true) {
|
|
49
|
+
hook = true
|
|
50
|
+
hookFunctionName = hookFunction.name
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
return {
|
|
58
|
+
templatePath: templatePath,
|
|
59
|
+
templateData: {
|
|
60
|
+
hook: hook ? hook : false,
|
|
61
|
+
hookFunctionName: hookFunctionName ? hookFunctionName : null,
|
|
62
|
+
// hookSourcePath: hook ? SOURCE_PATH.webSocketHook : {}
|
|
63
|
+
},
|
|
64
|
+
setting: {
|
|
65
|
+
savePath: path.join(srcPath, SOURCE_PATH.webSocket),
|
|
66
|
+
saveFileName: `${functionName}_${handlerType}`,
|
|
67
|
+
fileExtension: ".js",
|
|
68
|
+
isAppend: false
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
module.exports = data
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright (C) 2021 Sven Mason <http://izara.io>
|
|
3
|
+
|
|
4
|
+
This program is free software: you can redistribute it and/or modify
|
|
5
|
+
it under the terms of the GNU Affero General Public License as
|
|
6
|
+
published by the Free Software Foundation, either version 3 of the
|
|
7
|
+
License, or (at your option) any later version.
|
|
8
|
+
|
|
9
|
+
This program is distributed in the hope that it will be useful,
|
|
10
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
11
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
12
|
+
GNU Affero General Public License for more details.
|
|
13
|
+
|
|
14
|
+
You should have received a copy of the GNU Affero General Public License
|
|
15
|
+
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
'use strict';
|
|
19
|
+
|
|
20
|
+
const izara = require("@izara_project/izara-middleware");
|
|
21
|
+
const middleware = izara.middlewareHandler;
|
|
22
|
+
// const AWS = require('aws-sdk');
|
|
23
|
+
// const api = new AWS.ApiGatewayManagementApi({ endpoint: process.env.iz_webSocketEndpoint });
|
|
24
|
+
const izaraShared = require('@izara_project/izara-shared')
|
|
25
|
+
const dynamodbSharedLib = izaraShared.dynamodbSharedLib
|
|
26
|
+
const callingFlowSharedLib = izaraShared.callingFlowSharedLib;
|
|
27
|
+
const hash = require('object-hash')
|
|
28
|
+
// const coreConsts = require("@izara_project/izara-core-library-core/src/Consts");
|
|
29
|
+
const consts = require('@izara_project/izara-middleware/src/MiddlewareCore/Consts')
|
|
30
|
+
const { postToConnection } = require("../../libs/source/ImportDataLib");
|
|
31
|
+
<% if (hook) { _%>
|
|
32
|
+
const <%- hookFunctionName %> = required("<% hookFunctionName _%>_Main ")
|
|
33
|
+
<% } else { _%>
|
|
34
|
+
const createObject = require('./CreateObjectS3_Main');
|
|
35
|
+
<% } _%>
|
|
36
|
+
module.exports.main = middleware.wrap(async (event, context, callback) => {
|
|
37
|
+
|
|
38
|
+
event._izContext.logger.debug('Event:', event);
|
|
39
|
+
|
|
40
|
+
try {
|
|
41
|
+
|
|
42
|
+
if (event.requestContext) {
|
|
43
|
+
const route = event.requestContext.routeKey;
|
|
44
|
+
const connectionId = event.requestContext.connectionId;
|
|
45
|
+
let correlationId = event._izContext.correlationIds.get(consts.X_CORRELATION_ID)
|
|
46
|
+
|
|
47
|
+
switch (route) {
|
|
48
|
+
case "$connect":
|
|
49
|
+
console.log("webSocket Connect");
|
|
50
|
+
break
|
|
51
|
+
case "$disconnect":
|
|
52
|
+
console.log("webSocket Disconnect");
|
|
53
|
+
break
|
|
54
|
+
case '$default':
|
|
55
|
+
console.log('Received unknown route:', route);
|
|
56
|
+
break
|
|
57
|
+
case 'webSocket':
|
|
58
|
+
console.log("event in route webSocket", event);
|
|
59
|
+
let eventParams = JSON.parse(event.body)
|
|
60
|
+
|
|
61
|
+
await dynamodbSharedLib.putItem(
|
|
62
|
+
event._izContext,
|
|
63
|
+
await dynamodbSharedLib.tableName(event._izContext, "WebSocketTask"),
|
|
64
|
+
{
|
|
65
|
+
taskKey: correlationId,
|
|
66
|
+
connectionId: connectionId,
|
|
67
|
+
}
|
|
68
|
+
)
|
|
69
|
+
|
|
70
|
+
let callingFlow = eventParams?.callingFlow ? eventParams.callingFlow : {};
|
|
71
|
+
<% if (hook) { _%>
|
|
72
|
+
await <%- hookFunctionName %>.<%- hookFunctionName %>(
|
|
73
|
+
event._izContext,
|
|
74
|
+
eventParams,
|
|
75
|
+
callingFlowSharedLib.addCallingFlowToPassOnProperties(callingFlow)
|
|
76
|
+
//(<additionalParams>)
|
|
77
|
+
//(</additionalParams>)
|
|
78
|
+
)
|
|
79
|
+
<% } else { _%>
|
|
80
|
+
await createObject.createObject(
|
|
81
|
+
event._izContext,
|
|
82
|
+
eventParams,
|
|
83
|
+
callingFlowSharedLib.addCallingFlowToPassOnProperties(callingFlow)
|
|
84
|
+
//(<additionalParams>)
|
|
85
|
+
//(</additionalParams>)
|
|
86
|
+
)
|
|
87
|
+
<% } _%>
|
|
88
|
+
|
|
89
|
+
break
|
|
90
|
+
}
|
|
91
|
+
} else {
|
|
92
|
+
const connId = event.connId;
|
|
93
|
+
// await postMessage({ message: event.message }, connId);
|
|
94
|
+
await postToConnection({ message: event.message }, connId);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
return (izara.response.webSocketSuccess());
|
|
98
|
+
|
|
99
|
+
} catch (err) {
|
|
100
|
+
const connId = event.requestContext.connectionId
|
|
101
|
+
event._izContext.logger.error('Error, WebSocket: ', err);
|
|
102
|
+
// await sendErrorMessage({ message: err.message }, connId);
|
|
103
|
+
await postToConnection({ message: err.message }, connId);
|
|
104
|
+
return (izara.response.failure(err));
|
|
105
|
+
}
|
|
106
|
+
});
|
|
107
|
+
<%_ const join = require('path').join _%>
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright (C) 2020 Sven Mason <http://izara.io>
|
|
3
|
+
|
|
4
|
+
This program is free software: you can redistribute it and/or modify
|
|
5
|
+
it under the terms of the GNU Affero General Public License as
|
|
6
|
+
published by the Free Software Foundation, either version 3 of the
|
|
7
|
+
License, or (at your option) any later version.
|
|
8
|
+
|
|
9
|
+
This program is distributed in the hope that it will be useful,
|
|
10
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
11
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
12
|
+
GNU Affero General Public License for more details.
|
|
13
|
+
|
|
14
|
+
You should have received a copy of the GNU Affero General Public License
|
|
15
|
+
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
'use strict';
|
|
19
|
+
const path = require('path');
|
|
20
|
+
const fs = require('fs');
|
|
21
|
+
|
|
22
|
+
const { SOURCE_PATH, FUNCTION_NAME } = require("../../../../libs/Consts");
|
|
23
|
+
const { firstLetterLowerCase: lowerCase, firstLetterUpperCase: upperCase } = require("../../../../../../MainLibs/src/Utils")
|
|
24
|
+
const templatePath = path.join(__dirname, "template.ejs");
|
|
25
|
+
const getObjectSchema = require('@izara_project/izara-core-library-service-schemas/src/GetObjectSchema')
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* receive objectSchema
|
|
29
|
+
* create data for WebScoket handler template
|
|
30
|
+
*
|
|
31
|
+
* @param {Object} objectSchema
|
|
32
|
+
* @return {{templatePath, templateData,setting}}
|
|
33
|
+
*/
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
async function data(_izContext, flowSchema, srcPath) {
|
|
37
|
+
return [await createParamsForCreateSource(_izContext, flowSchema, srcPath)]
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
async function createParamsForCreateSource(_izContext, flowSchema, srcPath) {
|
|
41
|
+
let functionName = upperCase(FUNCTION_NAME.createObjectS3)
|
|
42
|
+
// let objectSchema = await getObjectSchema.getObjectSchemaCombineFieldNamesWithCache(_izContext, flowSchema.objType)
|
|
43
|
+
// let fieldNames = Object.keys(objectSchema.fieldNames)
|
|
44
|
+
return {
|
|
45
|
+
templatePath: templatePath,
|
|
46
|
+
templateData: {},
|
|
47
|
+
setting: {
|
|
48
|
+
savePath: path.join(srcPath, SOURCE_PATH.webSocket),
|
|
49
|
+
saveFileName: `${functionName}_Main`,
|
|
50
|
+
fileExtension: ".js",
|
|
51
|
+
isAppend: false
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
module.exports = data
|