@izara_project/izara-core-generate-service-code 1.0.32 → 1.0.34

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.
Files changed (36) hide show
  1. package/package.json +1 -1
  2. package/src/generateCode/generateFlowSchema/GenerateCodeFlowSchema.js +1 -1
  3. package/src/generateCode/generateFlowSchema/event/s3Component/upload/preSignUrl/createPreSignUrl/mainFunction/template.ejs +1 -1
  4. package/src/generateCode/generateFlowSchema/flowSchemaMainFunction/template.ejs +11 -5
  5. package/src/generateCode/generateFlowSchema/flowStep/flowStep.js +3 -3
  6. package/src/generateCode/generateFlowSchema/statusType/statusFieldComponent/mainFunction/template.ejs +0 -2
  7. package/src/generateCode/generateFlowStepWithPlugIn/afterFirstFlowStep/recievePlugIn/handler/data.js +61 -0
  8. package/src/generateCode/generateFlowStepWithPlugIn/afterFirstFlowStep/recievePlugIn/handler/templateApi.ejs +84 -0
  9. package/src/generateCode/generateFlowStepWithPlugIn/afterFirstFlowStep/recievePlugIn/handler/templateWebSocket.ejs +64 -0
  10. package/src/generateCode/generateFlowStepWithPlugIn/afterFirstFlowStep/recievePlugIn/mainFunction/data.js +52 -0
  11. package/src/generateCode/generateFlowStepWithPlugIn/afterFirstFlowStep/recievePlugIn/mainFunction/template.ejs +76 -0
  12. package/src/generateCode/generateFlowStepWithPlugIn/afterFirstFlowStep/recievePlugIn/yaml/data.js +86 -0
  13. package/src/generateCode/generateFlowStepWithPlugIn/afterFirstFlowStep/recievePlugIn/yaml/template.ejs +18 -0
  14. package/src/generateCode/generateFlowStepWithPlugIn/afterFirstFlowStep/sendPlugIn/handler/data.js +0 -0
  15. package/src/generateCode/generateFlowStepWithPlugIn/afterFirstFlowStep/sendPlugIn/handler/template.ejs +0 -0
  16. package/src/generateCode/generateFlowStepWithPlugIn/afterFirstFlowStep/sendPlugIn/mainFunction/data.js +0 -0
  17. package/src/generateCode/generateFlowStepWithPlugIn/afterFirstFlowStep/sendPlugIn/mainFunction/template.ejs +0 -0
  18. package/src/generateCode/generateFlowStepWithPlugIn/afterFirstFlowStep/sendPlugIn/yaml/data.js +0 -0
  19. package/src/generateCode/generateFlowStepWithPlugIn/afterFirstFlowStep/sendPlugIn/yaml/template.ejs +0 -0
  20. package/src/generateCode/generateFlowStepWithPlugIn/firstFlowStep/handler/data.js +53 -0
  21. package/src/generateCode/generateFlowStepWithPlugIn/firstFlowStep/handler/templateApi.ejs +84 -0
  22. package/src/generateCode/generateFlowStepWithPlugIn/firstFlowStep/handler/templateDsq.ejs +105 -0
  23. package/src/generateCode/generateFlowStepWithPlugIn/firstFlowStep/handler/templateInv.ejs +53 -0
  24. package/src/generateCode/generateFlowStepWithPlugIn/firstFlowStep/handler/templateSqs.ejs +87 -0
  25. package/src/generateCode/generateFlowStepWithPlugIn/firstFlowStep/mainFunction/data.js +45 -0
  26. package/src/generateCode/generateFlowStepWithPlugIn/firstFlowStep/mainFunction/template.ejs +83 -0
  27. package/src/generateCode/generateFlowStepWithPlugIn/firstFlowStep/queueNtopic/data.js +50 -0
  28. package/src/generateCode/generateFlowStepWithPlugIn/firstFlowStep/queueNtopic/template.ejs +0 -0
  29. package/src/generateCode/generateFlowStepWithPlugIn/firstFlowStep/topicOut/data.js +46 -0
  30. package/src/generateCode/generateFlowStepWithPlugIn/firstFlowStep/yaml/data.js +47 -0
  31. package/src/generateCode/generateFlowStepWithPlugIn/firstFlowStep/yaml/template.ejs +28 -0
  32. package/src/generateCode/generateFlowStepWithPlugIn/index.js +256 -0
  33. package/src/generateCode/generateSchema/generateTextTag/systemText/data.js +55 -46
  34. package/src/generateCode/resourceYamlComponent/sns-out/template.ejs +4 -0
  35. package/src/generateCode.js +21 -12
  36. package/src/libs/Libs.js +111 -22
@@ -0,0 +1,84 @@
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
+ const RBAC_TARGET_ID = process.env.iz_rbacTargetIdUser // iz_rbacTargetIdUser | iz_rbacDeliveryMethodId
19
+
20
+ import { middlewareHandler as middleware, response } from "@izara_project/izara-middleware";
21
+ import Logger from '@izara_project/izara-core-library-logger';
22
+ import callingFlowSharedLib from '@izara_project/izara-core-library-calling-flow';
23
+
24
+ import <%- functionName %> from './<%- functionName %>_Main.js';
25
+
26
+ // validate event params in middleware before into function.
27
+ let validatorSchema = {
28
+ //(<validatorSchema>)
29
+ //(</validatorSchema>)
30
+ };
31
+ // NOTE: not sure about remap_when_flatten and remove_when_flatten function of api still require for validate or not? Tam(19-Nov) -- Yes
32
+
33
+ // for auth userLevel
34
+ // if (process.env.iz_rbacTargetIdUser) {
35
+ // validatorSchema["required"] = ['pathParameters'];
36
+ // validatorSchema.properties.pathParameters = {
37
+ // additionalProperties: false,
38
+ // type: ['object', 'boolean'],
39
+ // required: [process.env.iz_rbacTargetIdUser],
40
+ // properties: {
41
+ // }
42
+ // };
43
+ // validatorSchema.properties.pathParameters.properties[process.env.iz_rbacTargetIdUser] = {
44
+ // type: 'string'
45
+ // };
46
+ //}
47
+ // If not have Authorizer set setMiddlewareSettings.
48
+ middleware.setValidatorSchema(validatorSchema, { noAuthorizer: true })
49
+
50
+ // // default user Authorizer.
51
+ // middleware.setValidatorSchema(validatorSchema)
52
+
53
+
54
+ export const main = middleware.wrap(async (event, context, callback) => {
55
+ event._izContext.logger.debug('Event:', event);
56
+ try {
57
+
58
+ // for targetUserId
59
+ // let targetUserId = null
60
+ // if (process.env.iz_rbacTargetIdUser) {
61
+ // targetUserId = event.pathParameters[process.env.iz_rbacTargetIdUser]
62
+ // }
63
+ // invoke LambdaFunction
64
+ let lambdaFunctionResponse = await <%- functionName %>.<%- functionName %>(
65
+ event._izContext, // correlationId/logger/integrationTestDetail/uniqueRequestId/userId
66
+ event.body,
67
+ callingFlowSharedLib.addCallingFlowToPassOnProperties(event)
68
+ //(<additionalParams>)
69
+ //(</additionalParams>)
70
+ );
71
+
72
+ // return error to client
73
+ if (lambdaFunctionResponse instanceof Error) {
74
+ return (response.failure(lambdaFunctionResponse));
75
+ }
76
+
77
+ // return success to client
78
+ return (response.success(lambdaFunctionResponse));
79
+
80
+ } catch (err) {
81
+ event._izContext.logger.error('Error, LambdaFunctionHdrApi: ', err);
82
+ return (response.failure(err));
83
+ }
84
+ });
@@ -0,0 +1,105 @@
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
+
19
+
20
+ import { middlewareHandler as middleware } from "@izara_project/izara-middleware";
21
+ import { recordHandlerSharedLib } from "@izara_project/izara-core-library-record-handler";
22
+ import Logger from '@izara_project/izara-core-library-logger';
23
+ import callingFlowSharedLib from '@izara_project/izara-core-library-calling-flow';
24
+ import <%- functionName %> from './<%- functionName %>_Main.js';
25
+
26
+ // validate event properties in body.Message of sqs event
27
+ let perRecordsValidatorSchema = {
28
+ //(<validatorSchema>)
29
+ //(</validatorSchema>)
30
+ }
31
+
32
+ middleware.setValidatorSchema(recordHandlerSharedLib.baseValidatorSchema(
33
+ {
34
+ type: "object",
35
+ required: ['body', 'messageAttributes'],
36
+ properties: {
37
+ body: {
38
+ type: 'object',
39
+ },
40
+ messageAttributes: {
41
+ type: 'object'
42
+ }
43
+ }
44
+ }
45
+ ));
46
+
47
+ export const main = middleware.wrap(async (event, context) => {
48
+
49
+ try {
50
+
51
+ let recordPromises = [];
52
+
53
+ // loop each record and send to mainFunction
54
+ await Promise.all(event.Records.map(async record => { // promise.all for map() function
55
+
56
+ // --- reforming record.body for Dsq request
57
+ record = recordHandlerSharedLib.reformatDsqMessage(record._izContext, record);
58
+ record._izContext.logger.debug('record LambdaFunctionHdrDsq after reform', record);
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
+ "<%- queueName %>", // 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);
73
+ passOnProperties.push(callingFlowSharedLib.addCallingFlowToPassOnProperties(record.body.Message));
74
+ //(<additionalParams>)
75
+ //(</additionalParams>)
76
+ record._izContext.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
+ <%- functionName %>, // mainFunction that need to invoke.
82
+ "<%- queueName %>", // 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
+
89
+ Logger.debug('before Promise.all(recordPromises) in handler');
90
+ try {
91
+ // --- main await all promises
92
+ await Promise.all(recordPromises); // await all promises
93
+
94
+ return event.Records // return all for local testing
95
+
96
+ } catch {
97
+ Logger.debug('Promise.all(recordPromises) in handler threw error (at least one record did no resolve)');
98
+ }
99
+ Logger.debug('after Promise.all(recordPromises) in handler');
100
+
101
+ } catch (err) {
102
+ Logger.error('Unhandled Error, LambdaFunctionHdrSqs: ', err);
103
+ throw (err);
104
+ }
105
+ });
@@ -0,0 +1,53 @@
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
+ import { middlewareHandler as middleware } from "@izara_project/izara-middleware";
19
+ import callingFlowSharedLib from '@izara_project/zara-core-library-calling-flow';
20
+
21
+ import <%- functionName %>Main from './<%- functionName %>_Main.js'
22
+
23
+ //(<globalVariable>
24
+ //</globalVariable>)
25
+
26
+
27
+ //(<afterValidateWithGenereatedSchema>)
28
+ //(</afterValidateWithGenereatedSchema>)
29
+
30
+
31
+ export const main = middlewareHandler.wrap(async (event, context) => {
32
+ event._izContext.logger.debug('Event:', event);
33
+ event._izContext.logger.debug('context:', context);
34
+
35
+ try {
36
+
37
+ //(<beforeInvoke>)
38
+ //(</beforeInvoke>)
39
+
40
+ // invoke LambdaFunction
41
+ return await <%- functionName %> Main(
42
+ event._izContext, // correlationId/logger/integrationTestDetail/uniqueRequestId
43
+ event,
44
+ callingFlowSharedLib.addCallingFlowToPassOnProperties(event),
45
+ //(<additionalParams>)
46
+ //(</additionalParams>)
47
+ );
48
+
49
+ } catch (err) {
50
+ event._izContext.logger.error('Error, <%- flowTag %>: ', err);
51
+ throw (err);
52
+ }
53
+ });
@@ -0,0 +1,87 @@
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
+
19
+
20
+ import { middlewareHandler as middleware } from "@izara_project/izara-middleware";
21
+ import { recordHandlerSharedLib } from "@izara_project/izara-core-library-record-handler";
22
+ import Logger from '@izara_project/izara-core-library-logger';
23
+ import callingFlowSharedLib from '@izara_project/izara-core-library-calling-flow';
24
+ import <%- functionName %> from './<%- functionName %>_Main.js';
25
+
26
+ // validate event properties in body.Message of sqs event
27
+ let perRecordsValidatorSchema = {
28
+ //(<validatorSchema>)
29
+ //(</validatorSchema>)
30
+ }
31
+ middleware.setValidatorSchema(recordHandlerSharedLib.baseValidatorSchema());
32
+
33
+ export const main = middleware.wrap(async (event, context) => {
34
+
35
+ try {
36
+
37
+ let recordPromises = [];
38
+
39
+ // loop each record and send to mainFunction
40
+ await Promise.all(event.Records.map(async record => { // promise.all for map() function
41
+
42
+ let passOnProperties = []
43
+ record._izContext.logger.debug('record ReceiveMsgOutHdrSqs', record);
44
+
45
+ //validate message (and MessageAttributes)
46
+ await recordHandlerSharedLib.validateRecord(
47
+ record, // one record will send to mainFunction
48
+ "<%- queueName %>", // queue name that need to retry or send to dlq
49
+ perRecordsValidatorSchema, // schema for record.Message
50
+ // messageAttributeValidatorSchema // ----- for msgAttr default is null -> do not send this parameter if not want to validate msgAtt
51
+ );
52
+
53
+ // add argument (to invoke lambda) to passOnProperties[]
54
+ passOnProperties.push(record.body.Message);
55
+ passOnProperties.push(callingFlowSharedLib.addCallingFlowToPassOnProperties(record.body.Message));
56
+ //(<additionalParams>)
57
+ //(</additionalParams>)
58
+ record._izContext.logger.debug('passOnProperties in handler', passOnProperties);
59
+
60
+ // call recordHandlerSharedLib.recordHandler with 3 parameters and return promise(resolve)
61
+ let recordPromise = recordHandlerSharedLib.recordHandler(
62
+ record, // one record will send to mainFunction
63
+ <%- functionName %>, // mainFunction that need to invoke.
64
+ "<%- queueName %>", // queue name that need to retry or send to dlq
65
+ passOnProperties, // all parameters that mainFunction needed.
66
+ );
67
+ record._izContext.logger.debug('after recordPromise in handler');
68
+ recordPromises.push(recordPromise); // push promise to recordPromises
69
+ }))
70
+
71
+ Logger.debug('before Promise.all(recordPromises) in handler');
72
+ try {
73
+ // --- main await all promises
74
+ await Promise.all(recordPromises); // await all promises
75
+
76
+ return event.Records // return all for local testing
77
+
78
+ } catch {
79
+ Logger.debug('Promise.all(recordPromises) in handler threw error (at least one record did no resolve)');
80
+ }
81
+ Logger.debug('after Promise.all(recordPromises) in handler');
82
+
83
+ } catch (err) {
84
+ Logger.error('Unhandled Error, LambdaFunctionHdrSqs: ', err);
85
+ throw (err);
86
+ }
87
+ });
@@ -0,0 +1,45 @@
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
+ import path from 'path';
19
+ import { fileURLToPath } from 'url';
20
+ const __filename = fileURLToPath(import.meta.url);
21
+ const __dirname = path.dirname(__filename);
22
+
23
+ import consts from '#libs/Consts.js';
24
+ import utils from '#libs/Utils.js';
25
+
26
+ const { firstLetterUpperCase: upperCase } = utils;
27
+ const { SOURCE_PATH, SAVE_FILE_NAME } = consts;
28
+ const templatePath = path.join(__dirname, 'template.ejs');
29
+
30
+
31
+ async function data(_izContext, data, appPath) {
32
+ console.log("data", data)
33
+ return {
34
+ templatePath: templatePath,
35
+ templateData: { ...data },
36
+ setting: {
37
+ savePath: path.join(appPath, SOURCE_PATH.flowSchema, `${upperCase(data.flowTag)}`, `${data.flowStepName}`, 'source/'),
38
+ saveFileName: `${upperCase(data.functionName)}_Main`,
39
+ fileExtension: '.js',
40
+ isAppend: false
41
+ }
42
+ }
43
+ }
44
+
45
+ export default data;
@@ -0,0 +1,83 @@
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
+ <% if (havePlugIn) { -%>
19
+ <% if (invokeType === 'sync') { -%>
20
+ import { api } from '@izara_project/izara-core-library-external-request';
21
+ <% } else if (invokeType === 'async') { -%>
22
+ import { webSocket } from '@izara_project/izara-core-library-external-request'
23
+ <% } -%>
24
+ <% } -%>
25
+
26
+ //(<optionalRequire>)
27
+ //(</optionalRequire>)
28
+
29
+ /**
30
+ *
31
+ *
32
+ * description of function.
33
+ * @param {Object} _izContext
34
+ * @param {CorrelationIds} _izContext.correlationIds - property of _izContext
35
+ * @param {Logger} _izContext.logger - property of _izContext
36
+ * @param {Object} requestParams - request params
37
+ * @param {Object} requestParams.identifiers - identifiers for get data
38
+ * @param {Object} requestParams.additionalRequest - additionalRequest
39
+ *
40
+ *
41
+ * @returns {object} description of return value
42
+ */
43
+ export default async function <%- functionName %>(
44
+ _izContext,
45
+ requestParams,
46
+ callingFlowConfig = {},
47
+ //(<additionalParams>)
48
+ //(</additionalParams>)
49
+ ) {
50
+
51
+
52
+ try {
53
+ _izContext.logger.debug('<%- functionName %> _izContext: ', _izContext);
54
+ _izContext.logger.debug('<%- functionName %> requestParams: ', requestParams);
55
+ _izContext.logger.debug('<%- functionName %> callingFlowConfig: ', callingFlowConfig);
56
+
57
+ //(<AFlowStepsHook>)
58
+ <% if (havePlugIn) { -%>
59
+ <% if (invokeType === 'async') { -%>
60
+ let messageObject = {
61
+ action: "recievePlugInRequestAsync"
62
+ };
63
+ <% } -%>
64
+ <% } -%>
65
+
66
+
67
+ // add properties to messageObject invoke lambda
68
+ //(</AFlowStepsHook>)
69
+
70
+
71
+ <% if (havePlugIn) { -%>
72
+ <% if (invokeType === 'sync') { -%>
73
+ await api.invokeLambdaApi(_izContext, "<%- targetUrl %>", messageObject)
74
+ <% } else if (invokeType === 'async') { -%>
75
+ await webSocket.invokeWebSocket(_izContext, "<%- targetUrl %>", messageObject)
76
+ <% } -%>
77
+ <% } -%>
78
+
79
+ } catch (err) {
80
+ _izContext.logger.error('error AFlowStepsMain: ', err)
81
+ throw (err)
82
+ }
83
+ }
@@ -0,0 +1,50 @@
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
+ import path from 'path';
19
+ import { fileURLToPath } from 'url';
20
+ const __filename = fileURLToPath(import.meta.url);
21
+ const __dirname = path.dirname(__filename);
22
+
23
+ import consts from '#libs/Consts.js';
24
+ import utils from '#libs/Utils.js';
25
+
26
+ const { firstLetterUpperCase: upperCase } = utils;
27
+ const { SOURCE_PATH, SAVE_FILE_NAME, HANDLER } = consts;
28
+ const templatePathByHandler = {
29
+ [HANDLER.hdrDsq]: path.join(__dirname, '../../../resourceYamlComponent/sns-in-sqs/sqsTemplate.ejs'),
30
+ [HANDLER.hdrSqs]: path.join(__dirname, '../../../resourceYamlComponent/sns-in-sqs/snsTemplate.ejs'),
31
+ queueNoTopic: path.join(__dirname, '../../../resourceYamlComponent/sns-in-sqs/sqsTemplate.ejs')
32
+ };
33
+
34
+ async function data(_izContext, data, appPath) {
35
+ if (data.eventFlow === 'extTopic') {
36
+ data.handlerType = 'queueNoTopic';
37
+ }
38
+ return {
39
+ templatePath: templatePathByHandler[data.handlerType],
40
+ templateData: { ...data },
41
+ setting: {
42
+ savePath: path.join(appPath, SOURCE_PATH.resourceYaml),
43
+ saveFileName: SAVE_FILE_NAME.snsInSqsYaml,
44
+ fileExtension: '.yml',
45
+ isAppend: true
46
+ }
47
+ }
48
+ }
49
+
50
+ export default data;
@@ -0,0 +1,46 @@
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
+ import path from 'path';
19
+ import { fileURLToPath } from 'url';
20
+ const __filename = fileURLToPath(import.meta.url);
21
+ const __dirname = path.dirname(__filename);
22
+
23
+ import consts from '#libs/Consts.js';
24
+ import utils from '#libs/Utils.js';
25
+
26
+ const { firstLetterUpperCase: upperCase } = utils;
27
+ const { SOURCE_PATH, SAVE_FILE_NAME, HANDLER } = consts;
28
+ const templatePath = path.join(__dirname, '../../../resourceYamlComponent/sns-out/template.ejs')
29
+
30
+ async function data(_izContext, data, appPath) {
31
+ console.log("generate sns out")
32
+ const queueName = `${upperCase(data.flowTag)}_${upperCase(data.flowStepName)}`;
33
+
34
+ return {
35
+ templatePath: templatePath,
36
+ templateData: { queueName },
37
+ setting: {
38
+ savePath: path.join(appPath, SOURCE_PATH.resourceYaml),
39
+ saveFileName: SAVE_FILE_NAME.snsOutYaml,
40
+ fileExtension: '.yml',
41
+ isAppend: true
42
+ }
43
+ }
44
+ }
45
+
46
+ export default data;
@@ -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
+ import path from 'path';
19
+ import { fileURLToPath } from 'url';
20
+ const __filename = fileURLToPath(import.meta.url);
21
+ const __dirname = path.dirname(__filename);
22
+
23
+ import consts from '#libs/Consts.js';
24
+ import utils from '#libs/Utils.js';
25
+ import libs from '#libs/Libs.js';
26
+
27
+ const { firstLetterUpperCase: upperCase } = utils;
28
+ const { SOURCE_PATH, SAVE_FILE_NAME } = consts;
29
+ const templatePath = path.join(__dirname, 'template.ejs');
30
+
31
+ async function data(_izContext, data, appPath) {
32
+ return {
33
+ templatePath: templatePath,
34
+ templateData: {
35
+ ...data,
36
+ },
37
+ setting: {
38
+ savePath: path.join(appPath, SOURCE_PATH.appYaml),
39
+ saveFileName: SAVE_FILE_NAME.flowSchemaYaml,
40
+ fileExtension: '.yml',
41
+ isAppend: true
42
+ }
43
+ }
44
+ }
45
+
46
+
47
+ export default data;
@@ -0,0 +1,28 @@
1
+ <%- functionNameConfig %>:
2
+ handler: <%- handlerPath %>
3
+ name: ${self:custom.iz_resourcePrefix}<%- functionName %>
4
+ role: <%- roleName %>Role
5
+ #<#<%- hookTagSetting %>#>
6
+ #<#/<%- hookTagSetting %>#>
7
+ <%_ if (handlerType === 'hdrDsq' || handlerType === 'hdrSqs') { _%>
8
+ events:
9
+ - sqs:
10
+ arn: <%- event %>
11
+ batchSize: 10
12
+ <%_ } else if (handlerType === 'hdrApi' && resourceApis.length > 0) { _%>
13
+ events:
14
+ <%_ resourceApis.forEach(api => { _%>
15
+ - httpApi:
16
+ path: <%- api.path %>
17
+ method: <%- api.method %>
18
+ #<#<%- api.hookTagApp %>#>
19
+ # authorizer: authorizerServiceSchema
20
+ #<#/<%- api.hookTagApp %>#>
21
+ - httpApi:
22
+ path: <%- api.pathWithUser %>
23
+ method: <%- api.method %>
24
+ #<#<%- api.hookTagUser %>#>
25
+ # authorizer: authorizerIdentifiers
26
+ #<#/<%- api.hookTagUser %>#>
27
+ <%_ }) _%>
28
+ <%_ } _%>