@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
package/src/TemplateManager/src/flowSchema/UploadS3Case/createObject/mainFunction/template.ejs
ADDED
|
@@ -0,0 +1,133 @@
|
|
|
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
|
|
16
|
+
<http: //www.gnu.org/licenses />.
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
'use strict';
|
|
20
|
+
|
|
21
|
+
const hash = require("object-hash");
|
|
22
|
+
const getObjectSchema = require('@izara_project/izara-core-library-service-schemas/src/GetObjectSchema');
|
|
23
|
+
|
|
24
|
+
const izaraShared = require('@izara_project/izara-shared');
|
|
25
|
+
const dynamodbSharedLib = izaraShared.dynamodbSharedLib;
|
|
26
|
+
const snsSharedLib = izaraShared.snsSharedLib;
|
|
27
|
+
const asyncFlowSharedLib = izaraShared.asyncFlowSharedLib;
|
|
28
|
+
const callingFlowSharedLib = izaraShared.callingFlowSharedLib;
|
|
29
|
+
const lambdaSharedLib = izaraShared.lambdaSharedLib
|
|
30
|
+
|
|
31
|
+
const externalRequest = require('@izara_project/izara-core-library-external-request');
|
|
32
|
+
const sns = externalRequest.sns
|
|
33
|
+
|
|
34
|
+
const utils = require('@izara_project/izara-market-library-service-schemas/src/MainLibs/src/Utils')
|
|
35
|
+
const NoRetryError = require('@izara_project/izara-core-library-core').NoRetryError
|
|
36
|
+
const { v4: uuidv4 } = require('uuid')
|
|
37
|
+
const coreConsts = require("@izara_project/izara-core-library-core/src/Consts");
|
|
38
|
+
const { TOPIC_NAME_GENERATE_CODE } = require('@izara_project/izara-market-library-service-schemas/src/GenerateCodeLibs/src/Consts')
|
|
39
|
+
/**
|
|
40
|
+
*
|
|
41
|
+
*
|
|
42
|
+
* description of function.
|
|
43
|
+
* @param {Object} _izContext
|
|
44
|
+
* @param {CorrelationIds} _izContext.correlationIds - property of _izContext
|
|
45
|
+
* @param {Logger} _izContext.logger - property of _izContext
|
|
46
|
+
* @param {Object} requestParams - request params
|
|
47
|
+
* @param {Object} requestParams.identifiers - identifiers for get data
|
|
48
|
+
* @param {Object} requestParams.additionalRequest - additionalRequest
|
|
49
|
+
*
|
|
50
|
+
*
|
|
51
|
+
* @returns {object} description of return value
|
|
52
|
+
*/
|
|
53
|
+
|
|
54
|
+
module.exports.createObject = async (
|
|
55
|
+
_izContext,
|
|
56
|
+
requestParams,
|
|
57
|
+
callingFlowConfig = {},
|
|
58
|
+
//(<additionalParams>)
|
|
59
|
+
//(</additionalParams>)
|
|
60
|
+
) => {
|
|
61
|
+
|
|
62
|
+
try {
|
|
63
|
+
_izContext.logger.debug("WebSocketInvoke _izContext", _izContext)
|
|
64
|
+
_izContext.logger.debug("WebSocketInvoke requestParams", requestParams)
|
|
65
|
+
_izContext.logger.debug("WebSocketInvoke callingFlowConfig", callingFlowConfig)
|
|
66
|
+
|
|
67
|
+
_izContext.correlationIds.set(coreConsts.BASE_USER_ID, "BasDev");
|
|
68
|
+
_izContext.correlationIds.set(coreConsts.TARGET_ID, "BasDevTarget");
|
|
69
|
+
|
|
70
|
+
let flowSchema = await getObjectSchema.getFlowSchemaS3WithCache(_izContext, {
|
|
71
|
+
flowTag: requestParams.flowTag,
|
|
72
|
+
serviceTag: process.env.iz_serviceTag
|
|
73
|
+
// serviceTag: "GenerateCodeTamplateBas002"
|
|
74
|
+
})
|
|
75
|
+
|
|
76
|
+
_izContext.logger.debug("getFlowSchema", flowSchema)
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
if (!flowSchema) {
|
|
80
|
+
throw new NoRetryError(`flowTag not found ${requestParams.flowTag}`)
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
if (flowSchema.uploadS3 === true) {
|
|
84
|
+
if (!flowSchema.hasOwnProperty("objType")) {
|
|
85
|
+
throw new NoRetryError(`flowTag has uploadS3 setting should have objType in flowSchema`)
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
// get objectType
|
|
90
|
+
let objectSchema = await getObjectSchema.getObjSchemaS3WithHierarchy(_izContext, flowSchema.objType)
|
|
91
|
+
_izContext.logger.debug("objectSchema in flowShcema mainFunction", objectSchema)
|
|
92
|
+
|
|
93
|
+
_izContext.correlationIds.get(coreConsts.X_CORRELATION_ID)
|
|
94
|
+
|
|
95
|
+
// create message Object to create Endpoint
|
|
96
|
+
let messageObject = {
|
|
97
|
+
fieldNames: {
|
|
98
|
+
userId: _izContext.correlationIds.get(coreConsts.BASE_USER_ID),
|
|
99
|
+
// userId: "mockUserId",
|
|
100
|
+
submittedByUserId: _izContext.correlationIds.get(coreConsts.TARGET_ID),
|
|
101
|
+
// submittedByUserId: "mockSubmittedByUserId",
|
|
102
|
+
startTime: Date.now(),
|
|
103
|
+
importConfigId: requestParams.importConfigId,
|
|
104
|
+
importBatchStatus: "processing",
|
|
105
|
+
importType: requestParams.importType,
|
|
106
|
+
fileName: requestParams.fileName,
|
|
107
|
+
fileSize: requestParams.fileSize
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
// create callingFlow
|
|
111
|
+
messageObject = callingFlowSharedLib.addCallingFlowToSnsRequestMessageObject(
|
|
112
|
+
messageObject,
|
|
113
|
+
callingFlowSharedLib.addParentCallingFlowConfig(
|
|
114
|
+
callingFlowConfig,
|
|
115
|
+
callingFlowSharedLib.createCallingFlowConfig(
|
|
116
|
+
await lambdaSharedLib.lambdaFunctionName(_izContext, TOPIC_NAME_GENERATE_CODE.createNodeComplete), {}
|
|
117
|
+
)
|
|
118
|
+
)
|
|
119
|
+
)
|
|
120
|
+
|
|
121
|
+
// send message to ImportBatchCreateHdrSqs
|
|
122
|
+
let sendMessageToCreateEndpoint = {
|
|
123
|
+
Message: JSON.stringify(messageObject),
|
|
124
|
+
TopicArn: await snsSharedLib.snsTopicArn(_izContext, `In${utils.firstLetterUpperCase(objectSchema.objectType)}Create`)
|
|
125
|
+
}
|
|
126
|
+
_izContext.logger.debug("sendMessageToCreateEndpoint", sendMessageToCreateEndpoint);
|
|
127
|
+
await sns.publishAsync(_izContext, sendMessageToCreateEndpoint);
|
|
128
|
+
|
|
129
|
+
} catch (err) {
|
|
130
|
+
_izContext.logger.error('error WebSocketInvoke: ', err)
|
|
131
|
+
throw (err)
|
|
132
|
+
}
|
|
133
|
+
}
|
package/src/TemplateManager/src/flowSchema/UploadS3Case/createObjectComplete/functionYaml/data.js
ADDED
|
@@ -0,0 +1,102 @@
|
|
|
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 templatePath = path.join(__dirname, "./template.ejs")
|
|
23
|
+
|
|
24
|
+
const { HANDLER, STORAGE_TYPES, ACTIONS } = require('@izara_project/izara-core-library-service-schemas/src/Consts')
|
|
25
|
+
const { firstLetterLowerCase: lowerCase, firstLetterUpperCase: upperCase } = require("../../../../../../MainLibs/src/Utils")
|
|
26
|
+
const { createIamRole, resourceNames, RESOURCE_CLASSES, DEFAULT_LAMBDA_ROLE_PER_ACTION, SQS_RESOURCE, SOURCE_PATH, SAVE_FILE_NAME, FUNCTION_NAME, shortNameHandler, defaultIamRolePerAction, DYNAMO_RESOURCE, SHORT_FUNCTION_NAME } = require("../../../../libs/Consts");
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* receive objectSchema
|
|
31
|
+
* create data for FindData Yaml template
|
|
32
|
+
*
|
|
33
|
+
* @param {Object} objectSchemas
|
|
34
|
+
* @return {{ templatePath, templateData, setting } }
|
|
35
|
+
*/
|
|
36
|
+
function data(_izContext, srcPath) {
|
|
37
|
+
return [createSourceParams(_izContext, srcPath)]
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function createSourceParams(_izContext, srcPath) {
|
|
41
|
+
let functionName = upperCase(FUNCTION_NAME.createObjectS3Complete);
|
|
42
|
+
let handlerType = upperCase(HANDLER.hdrSqs);
|
|
43
|
+
let additionalResourcePermission = defaultIamRolePerAction();
|
|
44
|
+
|
|
45
|
+
additionalResourcePermission.push(
|
|
46
|
+
createIamRole(
|
|
47
|
+
{
|
|
48
|
+
[RESOURCE_CLASSES.sqs]: [
|
|
49
|
+
SQS_RESOURCE.sendMessage,
|
|
50
|
+
SQS_RESOURCE.deleteMessage,
|
|
51
|
+
SQS_RESOURCE.getQueueAttributes,
|
|
52
|
+
SQS_RESOURCE.receiveMessage
|
|
53
|
+
]
|
|
54
|
+
},
|
|
55
|
+
[
|
|
56
|
+
resourceNames(RESOURCE_CLASSES.sns, functionName + handlerType),
|
|
57
|
+
resourceNames(RESOURCE_CLASSES.sns, functionName + "DLQ")
|
|
58
|
+
]
|
|
59
|
+
),
|
|
60
|
+
createIamRole(
|
|
61
|
+
{
|
|
62
|
+
[RESOURCE_CLASSES.dynamoDbTable]: [
|
|
63
|
+
DYNAMO_RESOURCE.query,
|
|
64
|
+
DYNAMO_RESOURCE.deleteItem,
|
|
65
|
+
DYNAMO_RESOURCE.getItem
|
|
66
|
+
]
|
|
67
|
+
},
|
|
68
|
+
[
|
|
69
|
+
resourceNames(RESOURCE_CLASSES.dynamoDbTable, "WebSocketTask")
|
|
70
|
+
]
|
|
71
|
+
),
|
|
72
|
+
createIamRole(
|
|
73
|
+
{
|
|
74
|
+
"execute-api": [
|
|
75
|
+
"ManageConnections"
|
|
76
|
+
]
|
|
77
|
+
},
|
|
78
|
+
[
|
|
79
|
+
resourceNames(RESOURCE_CLASSES.webSocket)
|
|
80
|
+
]
|
|
81
|
+
)
|
|
82
|
+
)
|
|
83
|
+
|
|
84
|
+
return {
|
|
85
|
+
templatePath: templatePath,
|
|
86
|
+
templateData: {
|
|
87
|
+
resourceLocation: SOURCE_PATH.resourceLocationWebSocket,
|
|
88
|
+
functionName: functionName,
|
|
89
|
+
handlerType: handlerType,
|
|
90
|
+
additionalResourcePermission: additionalResourcePermission,
|
|
91
|
+
functionNameConfig: upperCase(SHORT_FUNCTION_NAME.createObjectS3Complete) + upperCase(shortNameHandler(handlerType)),
|
|
92
|
+
},
|
|
93
|
+
setting: {
|
|
94
|
+
savePath: path.join(srcPath, SOURCE_PATH.appYaml),
|
|
95
|
+
saveFileName: upperCase(SAVE_FILE_NAME.flowSchema),
|
|
96
|
+
fileExtension: ".yml",
|
|
97
|
+
isAppend: true
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
module.exports = data;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
<%_ const join = require('path').join; _%>
|
|
2
|
+
<%- firstLetterUpperCase(functionNameConfig) %>:
|
|
3
|
+
handler: <%- join(resourceLocation, `${functionName}_${firstLetterUpperCase(handlerType)}.main`)%>
|
|
4
|
+
name: ${self:custom.iz_resourcePrefix}<%- functionName %><%- firstLetterUpperCase(handlerType) %>
|
|
5
|
+
events:
|
|
6
|
+
- sqs:
|
|
7
|
+
arn: arn:aws:sqs:${self:custom.iz_region}:${self:custom.iz_accountId}:${self:custom.iz_resourcePrefix}<%- functionName %><%- firstLetterUpperCase(handlerType) %>
|
|
8
|
+
batchSize: 10
|
|
9
|
+
filterPatterns: #**** need to update serverless framwork upper v.2.69.1
|
|
10
|
+
- body: {"MessageAttributes":{"callingFlow":{"Value":["${self:custom.iz_resourcePrefix}<%- functionName %>"]}}} # functionName of callingFlow
|
|
11
|
+
- body: {"MessageAttributes":{"callingFlow":{"Value":[{"exists":false}]}}}
|
|
12
|
+
iamRoleStatements:
|
|
13
|
+
<%_ additionalResourcePermission.forEach(resourcePermission => { _%>
|
|
14
|
+
- Effect: <%- resourcePermission.effect %>
|
|
15
|
+
Action:
|
|
16
|
+
<%_ Object.keys(resourcePermission.action).forEach(resourcePerAction => { _%>
|
|
17
|
+
<%_ resourcePermission.action[resourcePerAction].forEach(permission => { _%>
|
|
18
|
+
- <%- resourcePerAction %>:<%- permission %>
|
|
19
|
+
<%_ }) _%>
|
|
20
|
+
<%_ }) _%>
|
|
21
|
+
Resource:
|
|
22
|
+
<%_ resourcePermission.resource.forEach(resource => { _%>
|
|
23
|
+
- "<%- resource %>"
|
|
24
|
+
<%_ }) _%>
|
|
25
|
+
<%_}) _%>
|
|
26
|
+
#<#<%- functionName %><%- handlerType %>IamRole#>
|
|
27
|
+
#<#/<%- functionName %><%- handlerType %>IamRole#>
|
|
28
|
+
<%_ function firstLetterUpperCase(text){
|
|
29
|
+
return text.charAt(0).toUpperCase() + text.slice(1)
|
|
30
|
+
} _%>
|
|
@@ -0,0 +1,58 @@
|
|
|
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 templatePath = path.join(__dirname, "./template.ejs")
|
|
23
|
+
|
|
24
|
+
const { HANDLER, STORAGE_TYPES, ACTIONS } = require('@izara_project/izara-core-library-service-schemas/src/Consts')
|
|
25
|
+
const { firstLetterLowerCase: lowerCase, firstLetterUpperCase: upperCase } = require("../../../../../../MainLibs/src/Utils")
|
|
26
|
+
const { createIamRole, resourceNames, RESOURCE_CLASSES, DEFAULT_LAMBDA_ROLE_PER_ACTION, SQS_RESOURCE, SOURCE_PATH, SAVE_FILE_NAME, FUNCTION_NAME, shortNameHandler, defaultIamRolePerAction, DYNAMO_RESOURCE } = require("../../../../libs/Consts");
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* receive objectSchema
|
|
31
|
+
* create data for FindData Yaml template
|
|
32
|
+
*
|
|
33
|
+
* @param {Object} objectSchemas
|
|
34
|
+
* @return {{ templatePath, templateData, setting } }
|
|
35
|
+
*/
|
|
36
|
+
function data(_izContext, srcPath) {
|
|
37
|
+
return [createSourceParams(_izContext, srcPath)]
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function createSourceParams(_izContext, srcPath) {
|
|
41
|
+
let functionName = upperCase(FUNCTION_NAME.createObjectS3Complete)
|
|
42
|
+
let handlerType = upperCase(HANDLER.hdrSqs)
|
|
43
|
+
return {
|
|
44
|
+
templatePath: templatePath,
|
|
45
|
+
templateData: {
|
|
46
|
+
functionName,
|
|
47
|
+
handlerType,
|
|
48
|
+
},
|
|
49
|
+
setting: {
|
|
50
|
+
savePath: path.join(srcPath, SOURCE_PATH.webSocket),
|
|
51
|
+
saveFileName: `${functionName}_${handlerType}`,
|
|
52
|
+
fileExtension: ".js",
|
|
53
|
+
isAppend: false
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
module.exports = data;
|
package/src/TemplateManager/src/flowSchema/UploadS3Case/createObjectComplete/handler/template.ejs
ADDED
|
@@ -0,0 +1,103 @@
|
|
|
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 AWS = require('aws-sdk');
|
|
21
|
+
// const sqs = new AWS.SQS({ apiVersion: '2012-11-05' });
|
|
22
|
+
const izara = require('@izara_project/izara-middleware');
|
|
23
|
+
const middleware = izara.middlewareHandler;;
|
|
24
|
+
const Logger = require('@izara_project/izara-core-library-logger');
|
|
25
|
+
const izaraShared = require("@izara_project/izara-shared");
|
|
26
|
+
const recordHandlerSharedLib = izaraShared.recordHandlerSharedLib
|
|
27
|
+
|
|
28
|
+
const webSocketTaskComplete = require('./WebSocketTaskComplete_Main')
|
|
29
|
+
|
|
30
|
+
middleware.setValidatorSchema(recordHandlerSharedLib.baseValidatorSchema());
|
|
31
|
+
// set schema for record.body.Message
|
|
32
|
+
const perRecordsValidatorSchema = {};
|
|
33
|
+
|
|
34
|
+
// // set schema for record.body.MessageAttributes
|
|
35
|
+
// const messageAttributeValidatorSchema = {
|
|
36
|
+
// type: "object",
|
|
37
|
+
// required: ['msgAtrrParam1', 'msgAtrrParam2'],
|
|
38
|
+
// properties: {
|
|
39
|
+
// msgAtrrParam1: {
|
|
40
|
+
// type: "string"
|
|
41
|
+
// },
|
|
42
|
+
// msgAtrrParam2: {
|
|
43
|
+
// type: "object"
|
|
44
|
+
// }
|
|
45
|
+
// }
|
|
46
|
+
// };
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
// middleware.setValidatorSchema(recordHandlerSharedLib.baseValidatorSchema(perRecordsValidatorSchema));
|
|
50
|
+
|
|
51
|
+
module.exports.main = middleware.wrap(async (event, context, callback) => {
|
|
52
|
+
|
|
53
|
+
try {
|
|
54
|
+
Logger.debug('event ReceiveMsgOutHdrSqs: ', event)
|
|
55
|
+
let recordPromises = [];
|
|
56
|
+
|
|
57
|
+
// loop each record and send to mainFunction
|
|
58
|
+
await Promise.all(event.Records.map(async record => { // promise.all for map() function
|
|
59
|
+
|
|
60
|
+
let passOnProperties = []
|
|
61
|
+
record._izContext.logger.debug('record ReceiveMsgOutHdrSqs', record);
|
|
62
|
+
|
|
63
|
+
//validate message (and MessageAttributes)
|
|
64
|
+
await recordHandlerSharedLib.validateRecord(
|
|
65
|
+
record, // one record will send to mainFunction
|
|
66
|
+
"WebSocketTaskCompleteHdrSqs", // queue name that need to retry or send to dlq
|
|
67
|
+
perRecordsValidatorSchema, // schema for record.Message
|
|
68
|
+
// messageAttributeValidatorSchema // ----- for msgAttr default is null -> do not send this parameter if not want to validate msgAtt
|
|
69
|
+
);
|
|
70
|
+
|
|
71
|
+
// add argument (to invoke lambda) to passOnProperties[]
|
|
72
|
+
// passOnProperties.push(record.body.Message.MessageAttributes)
|
|
73
|
+
passOnProperties.push(record.body.Message.objType)
|
|
74
|
+
passOnProperties.push(record.body.Message.updateItem)
|
|
75
|
+
// passOnProperties.push(record.body.Message.route)
|
|
76
|
+
Logger.debug('passOnProperties in handler', passOnProperties);
|
|
77
|
+
|
|
78
|
+
// call recordHandlerSharedLib.recordHandler with 3 parameters and return promise(resolve)
|
|
79
|
+
let recordPromise = recordHandlerSharedLib.recordHandler(
|
|
80
|
+
record, // one record will send to mainFunction
|
|
81
|
+
webSocketTaskComplete.webSocketTaskComplete, // mainFunction that need to invoke.
|
|
82
|
+
"WebSocketTaskCompleteHdrSqs", // queue name that need to retry or send to dlq
|
|
83
|
+
passOnProperties, // all parameters that mainFunction needed.
|
|
84
|
+
);
|
|
85
|
+
record._izContext.logger.debug('after recordPromise in handler');
|
|
86
|
+
recordPromises.push(recordPromise); // push promise to recordPromises
|
|
87
|
+
}))
|
|
88
|
+
// ProcessLogical
|
|
89
|
+
Logger.debug('before Promise.all(recordPromises) in handler');
|
|
90
|
+
try {
|
|
91
|
+
await Promise.all(recordPromises); // await all promises
|
|
92
|
+
return event.Records // return all for local test
|
|
93
|
+
|
|
94
|
+
} catch {
|
|
95
|
+
Logger.debug('Promise.all(recordPromises) in handler threw error (at least one record did not resolve)');
|
|
96
|
+
}
|
|
97
|
+
Logger.debug('after Promise.all(recordPromises) in handler');
|
|
98
|
+
|
|
99
|
+
} catch (err) {
|
|
100
|
+
Logger.error('Unhandled Error, WebSocketTaskCompleteHdrSqs: ', err);
|
|
101
|
+
throw (err);
|
|
102
|
+
}
|
|
103
|
+
});
|
package/src/TemplateManager/src/flowSchema/UploadS3Case/createObjectComplete/mainFunction/data.js
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright (C) 2020 Sven Mason <http://izara.io>
|
|
3
|
+
|
|
4
|
+
This program is free software: you can redistribute it and/or modify
|
|
5
|
+
it under the terms of the GNU Affero General Public License as
|
|
6
|
+
published by the Free Software Foundation, either version 3 of the
|
|
7
|
+
License, or (at your option) any later version.
|
|
8
|
+
|
|
9
|
+
This program is distributed in the hope that it will be useful,
|
|
10
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
11
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
12
|
+
GNU Affero General Public License for more details.
|
|
13
|
+
|
|
14
|
+
You should have received a copy of the GNU Affero General Public License
|
|
15
|
+
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
'use strict';
|
|
19
|
+
|
|
20
|
+
const path = require('path');
|
|
21
|
+
|
|
22
|
+
const templatePath = path.join(__dirname, "./template.ejs")
|
|
23
|
+
|
|
24
|
+
const { SOURCE_PATH, FUNCTION_NAME } = require("../../../../libs/Consts");
|
|
25
|
+
const { firstLetterUpperCase: upperCase } = require('../../../../../../MainLibs/src/Utils')
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* receive objectSchema
|
|
30
|
+
* create data for FindData Yaml template
|
|
31
|
+
*
|
|
32
|
+
* @param {Object} objectSchemas
|
|
33
|
+
* @return {{ templatePath, templateData, setting } }
|
|
34
|
+
*/
|
|
35
|
+
function data(_izContext, srcPath) {
|
|
36
|
+
return [createSourceParams(_izContext, srcPath)]
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function createSourceParams(_izContext, srcPath) {
|
|
40
|
+
let functionName = upperCase(FUNCTION_NAME.createObjectS3Complete)
|
|
41
|
+
return {
|
|
42
|
+
templatePath: templatePath,
|
|
43
|
+
templateData: {
|
|
44
|
+
functionName,
|
|
45
|
+
},
|
|
46
|
+
setting: {
|
|
47
|
+
savePath: path.join(srcPath, SOURCE_PATH.webSocket),
|
|
48
|
+
saveFileName: `${functionName}_Main`,
|
|
49
|
+
fileExtension: ".js",
|
|
50
|
+
isAppend: false
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
module.exports = data;
|
|
@@ -0,0 +1,86 @@
|
|
|
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
|
+
'use strict';
|
|
18
|
+
const { NoRetryError } = require('@izara_project/izara-core-library-core');
|
|
19
|
+
const izaraShared = require('@izara_project/izara-shared');
|
|
20
|
+
const dynamodbSharedLib = izaraShared.dynamodbSharedLib;
|
|
21
|
+
const snsSharedLib = izaraShared.snsSharedLib;
|
|
22
|
+
const asyncFlowSharedLib = izaraShared.asyncFlowSharedLib;
|
|
23
|
+
let coreConsts = require('@izara_project/izara-middleware/src/MiddlewareCore/Consts')
|
|
24
|
+
|
|
25
|
+
const { postToConnection } = require('../../libs/source/ImportDataLib')
|
|
26
|
+
module.exports.webSocketTaskComplete = async (
|
|
27
|
+
_izContext,
|
|
28
|
+
objType,
|
|
29
|
+
updateItem
|
|
30
|
+
) => {
|
|
31
|
+
try {
|
|
32
|
+
_izContext.logger.debug("requestParams", {
|
|
33
|
+
objType,
|
|
34
|
+
updateItem
|
|
35
|
+
})
|
|
36
|
+
|
|
37
|
+
let connectionId = _izContext.correlationIds.get(coreConsts.CONNECTION_ID);
|
|
38
|
+
let correlationId = _izContext.correlationIds.get(coreConsts.X_CORRELATION_ID);
|
|
39
|
+
|
|
40
|
+
if (updateItem.importBatchStatus === "waitingToUpload") {
|
|
41
|
+
// get upload url
|
|
42
|
+
let webSocketTask = await dynamodbSharedLib.getItem(_izContext,
|
|
43
|
+
await dynamodbSharedLib.tableName(_izContext, "WebSocketTask"),
|
|
44
|
+
{
|
|
45
|
+
taskKey: correlationId,
|
|
46
|
+
connectionId: connectionId
|
|
47
|
+
}
|
|
48
|
+
)
|
|
49
|
+
_izContext.logger.debug("webSocketTask", webSocketTask);
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
_izContext.logger.debug("post message to client")
|
|
53
|
+
// post message to client
|
|
54
|
+
await postToConnection({
|
|
55
|
+
message: {
|
|
56
|
+
uploadUrl: webSocketTask.uploadUrl,
|
|
57
|
+
importBatchId: updateItem.importBatchId
|
|
58
|
+
}
|
|
59
|
+
}, connectionId)
|
|
60
|
+
|
|
61
|
+
await dynamodbSharedLib.deleteItem(_izContext,
|
|
62
|
+
await dynamodbSharedLib.tableName(_izContext, "WebSocketTask"),
|
|
63
|
+
{
|
|
64
|
+
taskKey: correlationId,
|
|
65
|
+
connectionId: connectionId
|
|
66
|
+
}
|
|
67
|
+
)
|
|
68
|
+
} else {
|
|
69
|
+
await postToConnection({
|
|
70
|
+
message: "status is processing can't upload file"
|
|
71
|
+
}, connectionId)
|
|
72
|
+
// delete webSocketTask
|
|
73
|
+
await dynamodbSharedLib.deleteItem(_izContext,
|
|
74
|
+
await dynamodbSharedLib.tableName(_izContext, "WebSocketTask"),
|
|
75
|
+
{
|
|
76
|
+
taskKey: correlationId,
|
|
77
|
+
connectionId: connectionId
|
|
78
|
+
}
|
|
79
|
+
)
|
|
80
|
+
|
|
81
|
+
}
|
|
82
|
+
} catch (err) {
|
|
83
|
+
_izContext.logger.error('error websocketTaskComplete: ', err)
|
|
84
|
+
throw (err);
|
|
85
|
+
}
|
|
86
|
+
};
|
|
@@ -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
|
+
|
|
20
|
+
const path = require("path")
|
|
21
|
+
|
|
22
|
+
const {
|
|
23
|
+
HANDLER,
|
|
24
|
+
STORAGE_TYPES
|
|
25
|
+
} = require('@izara_project/izara-core-library-service-schemas/src/Consts');
|
|
26
|
+
|
|
27
|
+
const { firstLetterLowerCase: lowerCase, firstLetterUpperCase: upperCase } = require("../../../../../../MainLibs/src/Utils")
|
|
28
|
+
const templatePath = path.join(__dirname, "template.ejs")
|
|
29
|
+
const { SOURCE_PATH, SAVE_FILE_NAME, FUNCTION_NAME } = require('../../../../libs/Consts');
|
|
30
|
+
const { TOPIC_NAME_GENERATE_CODE } = require("../../../../../../GenerateCodeLibs/src/Consts");
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* create data for dynamoDbYaml tempalte from objectSchema
|
|
35
|
+
* return array of dynamoDb data
|
|
36
|
+
* because one objectSchema can create multiple dynamoDb table
|
|
37
|
+
*
|
|
38
|
+
* @param {Object} _izContext
|
|
39
|
+
* @param {String} saveFilePath
|
|
40
|
+
* @returns {Object[]} - data of multiple dynamoDb template
|
|
41
|
+
*/
|
|
42
|
+
|
|
43
|
+
function createDataForDefaultSnsInSqs(_izContext, srcPath) {
|
|
44
|
+
let resultsForCreateDefaultSnsInSqs = [];
|
|
45
|
+
const defaultSnsInSqsDataList = [];
|
|
46
|
+
const setting = {
|
|
47
|
+
initialData: "Resources:\n",
|
|
48
|
+
savePath: path.join(srcPath, SOURCE_PATH.resourceYaml),
|
|
49
|
+
saveFileName: SAVE_FILE_NAME.snsInSqsYaml,
|
|
50
|
+
fileExtension: ".yml",
|
|
51
|
+
isAppend: true
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
defaultSnsInSqsDataList.push(
|
|
56
|
+
{
|
|
57
|
+
queueName: upperCase(FUNCTION_NAME.createObjectS3Complete) + upperCase(HANDLER.hdrSqs),
|
|
58
|
+
subScription: upperCase(TOPIC_NAME_GENERATE_CODE.outUpdateNodeComplete)
|
|
59
|
+
}
|
|
60
|
+
)
|
|
61
|
+
|
|
62
|
+
for (let defaultSnsInSqsData of defaultSnsInSqsDataList) {
|
|
63
|
+
resultsForCreateDefaultSnsInSqs.push({
|
|
64
|
+
templatePath: templatePath,
|
|
65
|
+
templateData: defaultSnsInSqsData,
|
|
66
|
+
setting: setting
|
|
67
|
+
})
|
|
68
|
+
}
|
|
69
|
+
return resultsForCreateDefaultSnsInSqs;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
module.exports = createDataForDefaultSnsInSqs;
|