@izara_project/izara-core-generate-service-code 1.0.38 → 1.0.40

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 (34) hide show
  1. package/package.json +6 -6
  2. package/src/generateCode/generateFlowStepWithPlugIn/afterFirstFlowStep/recievePlugIn/handler/data.js +7 -1
  3. package/src/generateCode/generateFlowStepWithPlugIn/afterFirstFlowStep/recievePlugIn/handler/templateWebSocket.ejs +2 -0
  4. package/src/generateCode/generateFlowStepWithPlugIn/afterFirstFlowStep/recievePlugIn/mainFunction/data.js +7 -1
  5. package/src/generateCode/generateFlowStepWithPlugIn/afterFirstFlowStep/recievePlugIn/mainFunction/template.ejs +1 -1
  6. package/src/generateCode/generateFlowStepWithPlugIn/byConfig/handler/data.js +56 -0
  7. package/src/generateCode/generateFlowStepWithPlugIn/byConfig/handler/templateAwaitingStep.ejs +105 -0
  8. package/src/generateCode/generateFlowStepWithPlugIn/byConfig/handler/templatePaginated.ejs +137 -0
  9. package/src/generateCode/generateFlowStepWithPlugIn/byConfig/mainFunction/data.js +57 -0
  10. package/src/generateCode/generateFlowStepWithPlugIn/byConfig/mainFunction/templateAwaitingStep.ejs +129 -0
  11. package/src/generateCode/generateFlowStepWithPlugIn/byConfig/mainFunction/templatePaginated.ejs +59 -0
  12. package/src/generateCode/generateFlowStepWithPlugIn/byConfig/sns-sqs/data.js +50 -0
  13. package/src/generateCode/generateFlowStepWithPlugIn/byConfig/sns-sqs/queueNoTopic.ejs +43 -0
  14. package/src/generateCode/generateFlowStepWithPlugIn/byConfig/sns-sqs/snsTemplate.ejs +58 -0
  15. package/src/generateCode/generateFlowStepWithPlugIn/byConfig/sns-sqs/sqsTemplate.ejs +43 -0
  16. package/src/generateCode/generateFlowStepWithPlugIn/byConfig/yaml/data.js +47 -0
  17. package/src/generateCode/generateFlowStepWithPlugIn/byConfig/yaml/template.ejs +43 -0
  18. package/src/generateCode/generateFlowStepWithPlugIn/firstFlowStep/handler/data.js +7 -1
  19. package/src/generateCode/generateFlowStepWithPlugIn/firstFlowStep/mainFunction/data.js +45 -7
  20. package/src/generateCode/generateFlowStepWithPlugIn/firstFlowStep/mainFunction/template.ejs +5 -16
  21. package/src/generateCode/generateFlowStepWithPlugIn/firstFlowStep/mainFunction/templateByConfig/awaitingSteps.ejs +63 -0
  22. package/src/generateCode/generateFlowStepWithPlugIn/firstFlowStep/mainFunction/templateByConfig/templateSendPlugin.ejs +18 -0
  23. package/src/generateCode/generateFlowStepWithPlugIn/firstFlowStep/queueNtopic/sqsTemplate.ejs +7 -7
  24. package/src/generateCode/generateFlowStepWithPlugIn/firstFlowStep/topicOut/data.js +1 -1
  25. package/src/generateCode/generateFlowStepWithPlugIn/index(old).js +290 -0
  26. package/src/generateCode/generateFlowStepWithPlugIn/index.js +414 -151
  27. package/src/generateCode/generateInitialSetup/externalServiceComponent/lambdaRole/data.js +22 -0
  28. package/src/generateCode/generateInitialSetup/externalServiceComponent/snsTopicSubscriptions/data.js +16 -0
  29. package/src/generateCode/generateSchema/actionEndpointCompleteComponent/create/mainFunction/template.ejs +44 -4
  30. package/src/generateCode/generateSchema/actionEndpointComponent/mainFunction/create/main/template.ejs +58 -40
  31. package/src/libs/Consts.js +1 -1
  32. package/src/libs/Libs.js +22 -15
  33. package/src/generateCode/generateInitialSetup/externalServiceComponent/lambdaRole/request.json +0 -18
  34. package/src/generateCode/generateInitialSetup/externalServiceComponent/snsTopicSubscriptions/request.json +0 -12
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@izara_project/izara-core-generate-service-code",
3
- "version": "1.0.38",
3
+ "version": "1.0.40",
4
4
  "description": "Code for locally generating per service files",
5
5
  "author": "Sven Mason <thebarbariansven@gmail.com>",
6
6
  "license": "AGPL-3.0-or-later",
@@ -24,11 +24,11 @@
24
24
  },
25
25
  "type": "module",
26
26
  "dependencies": {
27
- "@izara_project/izara-core-library-core": "^1.0.31",
28
- "@izara_project/izara-core-library-logger": "^1.0.8",
29
- "@izara_project/izara-core-library-s3": "^1.0.5",
30
- "@izara_project/izara-core-library-service-schemas": "^1.0.135",
31
- "@izara_project/izara-shared-core": "^1.0.9",
27
+ "@izara_project/izara-core-library-core": "^1.0.32",
28
+ "@izara_project/izara-core-library-logger": "^1.0.9",
29
+ "@izara_project/izara-core-library-s3": "^1.0.8",
30
+ "@izara_project/izara-core-library-service-schemas": "^1.0.141",
31
+ "@izara_project/izara-shared-core": "^1.0.12",
32
32
  "ejs": "^5.0.1",
33
33
  "js-beautify": "^1.15.4",
34
34
  "yaml": "^2.8.2"
@@ -49,7 +49,13 @@ async function data(_izContext, data, appPath) {
49
49
  route: functionName
50
50
  },
51
51
  setting: {
52
- savePath: path.join(appPath, SOURCE_PATH.flowSchema, `${upperCase(data.flowTag)}`, `${data.flowStepName}`, 'source/'),
52
+ savePath: path.join(
53
+ appPath,
54
+ SOURCE_PATH.flowSchema,
55
+ `${upperCase(data.flowTag)}`,
56
+ `${upperCase(data.flowStepName)}`,
57
+ 'source/'
58
+ ),
53
59
  saveFileName: `${upperCase(functionName)}_${upperCase(handlerType)}`,
54
60
  fileExtension: '.js',
55
61
  isAppend: true
@@ -20,6 +20,8 @@ import callingFlowSharedLib from '@izara_project/izara-core-library-calling-flow
20
20
  import { webSocket } from '@izara_project/izara-core-library-external-request';
21
21
  const { postToConnection } = webSocket;
22
22
 
23
+ import <%- functionName %> from './<%- functionName %>_Main.js';
24
+
23
25
  export const main = middleware.wrap(async (event, context) => {
24
26
 
25
27
  event._izContext.logger.debug('Event:', event);
@@ -41,7 +41,13 @@ async function data(_izContext, data, appPath) {
41
41
  functionName
42
42
  },
43
43
  setting: {
44
- savePath: path.join(appPath, SOURCE_PATH.flowSchema, `${upperCase(data.flowTag)}`, `${data.flowStepName}`, 'source/'),
44
+ savePath: path.join(
45
+ appPath,
46
+ SOURCE_PATH.flowSchema,
47
+ `${upperCase(data.flowTag)}`,
48
+ `${upperCase(data.flowStepName)}`,
49
+ 'source/'
50
+ ),
45
51
  saveFileName: `${upperCase(functionName)}${upperCase(data.recieveType)}_Main`,
46
52
  fileExtension: '.js',
47
53
  isAppend: false
@@ -70,7 +70,7 @@ export default async function <%- functionName %> (
70
70
 
71
71
 
72
72
  } catch (err) {
73
- _izContext.logger.error('error recievePlugInRequest: ', err)
73
+ _izContext.logger.error('error <%- functionName %>: ', err)
74
74
  throw (err)
75
75
  }
76
76
  }
@@ -0,0 +1,56 @@
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 templatePathByLogic = {
29
+ awaitingMultipleSteps: path.join(__dirname, 'templateAwaitingStep.ejs'),
30
+ paginated: path.join(__dirname, 'templatePaginated.ejs'),
31
+ };
32
+
33
+ function data(_izContext, data, appPath) {
34
+
35
+ return {
36
+ templatePath: templatePathByLogic[data.handleLogic],
37
+ templateData: { ...data },
38
+ setting: {
39
+ savePath: path.join(
40
+ appPath,
41
+ SOURCE_PATH.flowSchema,
42
+ `${upperCase(data.flowTag)}`,
43
+ `${upperCase(data.flowStepName)}`,
44
+ 'source/'
45
+ ),
46
+ saveFileName: upperCase(data.functionName) +
47
+ '_' +
48
+ upperCase(data.handlerType),
49
+ fileExtension: '.js',
50
+ isAppend: false
51
+ }
52
+ }
53
+ }
54
+
55
+
56
+ export default data;
@@ -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
+ import { middlewareHandler as middleware } from "@izara_project/izara-middleware";
19
+ import Logger from '@izara_project/izara-core-library-logger';
20
+ import { recordHandlerSharedLib } from "@izara_project/izara-core-library-record-handler";
21
+ import callingFlowSharedLib from '@izara_project/izara-core-library-calling-flow';
22
+
23
+ import <%- functionName %> from './<%- functionName %>_Main.js';
24
+
25
+ // validate event properties in body.Message of sqs event
26
+ middleware.setValidatorSchema(recordHandlerSharedLib.baseValidatorSchema());
27
+ // set schema for record.body.Message
28
+ let perRecordsValidatorSchema = {
29
+ type: "object",
30
+ required: [
31
+ 'returnValue',
32
+ 'status',
33
+ 'errorsFound'
34
+ ],
35
+ properties: {
36
+ returnValue: {
37
+ type: 'object',
38
+ },
39
+ status: {
40
+ type: 'string',
41
+ },
42
+ errorsFound: {
43
+ type: 'array',
44
+ default: []
45
+ }
46
+ }
47
+ };
48
+
49
+ perRecordsValidatorSchema = callingFlowSharedLib.addOptionalPassBackPropertiesToValidatorSchema(perRecordsValidatorSchema); // is Ok passBackProperties
50
+ export const main = middleware.wrap(async (event, context) => {
51
+
52
+ try {
53
+
54
+ let recordPromises = [];
55
+
56
+ // loop each record and send to mainFunction
57
+ await Promise.all(event.Records.map(async record => { // promise.all for map() function
58
+
59
+ let passOnProperties = []
60
+ record._izContext.logger.debug('record ReceiveMsgOutHdrSqs', record);
61
+
62
+ //validate message (and MessageAttributes)
63
+ await recordHandlerSharedLib.validateRecord(
64
+ record, // one record will send to mainFunction
65
+ "<%- functionName %>", // queue name that need to retry or send to dlq
66
+ perRecordsValidatorSchema, // schema for record.Message
67
+ // messageAttributeValidatorSchema // ----- for msgAttr default is null -> do not send this parameter if not want to validate msgAtt
68
+ );
69
+
70
+ // add argument (to invoke lambda) to passOnProperties[]
71
+ passOnProperties.push(record.body.Message.returnValue)
72
+ passOnProperties.push(record.body.Message.status)
73
+ passOnProperties.push(record.body.Message.errorsFound)
74
+ passOnProperties.push(callingFlowSharedLib.addPassBackPropertiesToPassOnProperties(record.body.Message)) // is Ok PassBackProperties
75
+ // passOnProperties.push(callingFlowSharedLib.addCallingFlowToPassOnProperties(record.body.Message)) // is Ok callinfFlow
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
+ "<%- functionName %>", // 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, <%- functionName %>: ', err);
103
+ throw (err);
104
+ }
105
+ });
@@ -0,0 +1,137 @@
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 Logger from '@izara_project/izara-core-library-logger';
20
+ import { recordHandlerSharedLib } from '@izara_project/izara-core-library-record-handler';
21
+ import callingFlowSharedLib from '@izara_project/izara-core-library-calling-flow';
22
+
23
+ import <%- functionName %> from './<%- functionName %>_Main.js';
24
+
25
+ // validate event properties in body.Message of sqs event
26
+ middleware.setValidatorSchema(
27
+ recordHandlerSharedLib.baseValidatorSchema({
28
+ type: 'object',
29
+ required: ['body', 'messageAttributes'],
30
+ properties: {
31
+ body: {
32
+ type: 'object'
33
+ },
34
+ messageAttributes: {
35
+ type: 'object'
36
+ }
37
+ }
38
+ })
39
+ );
40
+
41
+ // set schema for record.body.Message
42
+ const perRecordsValidatorSchema = {
43
+ type: 'object',
44
+ required: [
45
+ //(<<%- functionName %>ValidateSchemaRequired>)
46
+ //(</<%- functionName %>ValidateSchemaRequired>)
47
+ 'overWriteCache'
48
+ ],
49
+ properties: {
50
+ //(<<%- functionName %>ValidateSchemaProperties>)
51
+ //(</<%- functionName %>ValidateSchemaProperties>)
52
+ startKey: {
53
+ type: 'object'
54
+ },
55
+ overwriteUniqueRequestId: {
56
+ type: 'string'
57
+ },
58
+ overWriteCache: {
59
+ type: 'boolean'
60
+ },
61
+ callingFlow: {
62
+ type: 'string',
63
+ default: ''
64
+ }
65
+ }
66
+ };
67
+
68
+ export const main = middleware.wrap(async (event, context, callback) => {
69
+ try {
70
+ let recordPromises = [];
71
+
72
+ // loop each record and send to mainFunction
73
+ await Promise.all(
74
+ event.Records.map(async record => {
75
+ // promise.all for map() function
76
+
77
+ // --- reforming record.body for Dsq request
78
+ record = recordHandlerSharedLib.reformatDsqMessage(
79
+ record._izContext,
80
+ record
81
+ );
82
+ record._izContext.logger.debug(
83
+ 'record PaginateProcessLogicalHdrDsq after reform',
84
+ record
85
+ );
86
+
87
+ let passOnProperties = [];
88
+
89
+ // validate message (and MessageAttributes)
90
+ await recordHandlerSharedLib.validateRecord(
91
+ record, // one record will send to mainFunction
92
+ 'PaginateProcessLogicalHdrDsq', // queue name that need to retry or send to dlq
93
+ perRecordsValidatorSchema // schema for record.Message
94
+ // messageAttributeValidatorSchema // ----- for msgAttr default is null -> do not send this parameter if not want to validate msgAtt
95
+ );
96
+
97
+ // add argument (to invoke lambda) to passOnProperties[]
98
+ //(<<%- functionName %>AddPassOnProperties>)
99
+ //(</<%- functionName %>AddPassOnProperties>)
100
+ passOnProperties.push(record.body.startKey);
101
+ passOnProperties.push(record.body.overwriteUniqueRequestId);
102
+ passOnProperties.push(record.body.overWriteCache);
103
+ callingFlowSharedLib.addCallingFlowToPassOnProperties(record.body.Message),
104
+ record._izContext.logger.debug(
105
+ 'passOnProperties in handler',
106
+ passOnProperties
107
+ );
108
+
109
+ // call recordHandlerSharedLib.recordHandler with 3 parameters and return promise(resolve)
110
+ let recordPromise = recordHandlerSharedLib.recordHandler(
111
+ record, // one record will send to mainFunction
112
+ paginateProcessLogical, // mainFunction that need to invoke.
113
+ 'PaginateProcessLogicalHdrDsq', // queue name that need to retry or send to dlq
114
+ passOnProperties // all parameters that mainFunction needed.
115
+ );
116
+ record._izContext.logger.debug('after recordPromise in handler');
117
+ recordPromises.push(recordPromise); // push promise to recordPromises
118
+ })
119
+ );
120
+
121
+ Logger.debug('before Promise.all(recordPromises) in handler');
122
+ try {
123
+ // --- main await all promises
124
+ await Promise.all(recordPromises); // await all promises
125
+
126
+ return event.Records; // return all for local testing
127
+ } catch {
128
+ Logger.debug(
129
+ 'Promise.all(recordPromises) in handler threw error (at least one record did no resolve)'
130
+ );
131
+ }
132
+ Logger.debug('after Promise.all(recordPromises) in handler');
133
+ } catch (err) {
134
+ Logger.error('Unhandled Error, PaginateProcessLogicalHdrDsq: ', err);
135
+ throw err;
136
+ }
137
+ });
@@ -0,0 +1,57 @@
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 templateByHandleLogic = {
29
+ awaitingMultipleSteps: path.join(__dirname, 'templateAwaitingStep.ejs'),
30
+ paginated: path.join(__dirname, 'templatePaginated.ejs')
31
+ }
32
+
33
+
34
+ function data(_izContext, data, appPath) {
35
+ console.log("data main", data)
36
+ return {
37
+ templatePath: templateByHandleLogic[data.handleLogic],
38
+ templateData: {
39
+ ...data,
40
+ },
41
+ setting: {
42
+ savePath: path.join(
43
+ appPath,
44
+ SOURCE_PATH.flowSchema,
45
+ `${upperCase(data.flowTag)}`,
46
+ `${upperCase(data.flowStepName)}`,
47
+ 'source/'
48
+ ),
49
+ saveFileName: upperCase(data.functionName) + '_Main',
50
+ fileExtension: '.js',
51
+ isAppend: false
52
+ }
53
+ }
54
+ }
55
+
56
+
57
+ export default data;
@@ -0,0 +1,129 @@
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
+ import asyncFlowSharedLib from '@izara_project/izara-core-library-asynchronous-flow';
20
+ import callingFlowSharedLib from '@izara_project/izara-core-library-calling-flow';
21
+ import dynamodbSharedLib from '@izara_project/izara-core-library-dynamodb';
22
+ import snsSharedLib from '@izara_project/izara-core-library-sns';
23
+
24
+ import { sns } from '@izara_project/izara-core-library-external-request';
25
+ import { objectHash as hash } from '@izara_project/izara-shared-core';
26
+ import { consts } from '@izara_project/izara-core-library-service-schemas';
27
+ import { NoRetryError } from '@izara_project/izara-core-library-core';
28
+
29
+ const { TOPIC_NAME_GENERATE_CODE } = consts;
30
+ const PREFIX = {
31
+ CREATE_OBJECT_ASYNC: 'createObjectAsync',
32
+ CREATE_OBJECT_ASYNC_COMPLETE: 'createObjectAsyncComplete',
33
+ };
34
+
35
+ //(<optionalRequire>)
36
+ //(</optionalRequire>)
37
+
38
+ /**
39
+ *
40
+ *
41
+ * description of function.
42
+ * @param {Object} _izContext
43
+ * @param {CorrelationIds} _izContext.correlationIds - property of _izContext
44
+ * @param {Logger} _izContext.logger - property of _izContext
45
+ * @param {*} returnValue
46
+ * @param {*} status
47
+ * @param {*} errorsFound
48
+ *
49
+ * @returns {object} description of return value
50
+ */
51
+ export default async function AFlowStepsAwaitingMultipleSteps(
52
+ _izContext,
53
+ returnValue,
54
+ status,
55
+ errorsFound,
56
+ passBackProperties,
57
+ //(<additionalParams>)
58
+ //(</additionalParams>)
59
+ ) {
60
+ try {
61
+ _izContext.logger.debug('AFlowStepsAwaitingMultipleSteps _izContext: ', _izContext);
62
+ _izContext.logger.debug('AFlowStepsAwaitingMultipleSteps requestParams: ', {
63
+ returnValue: returnValue,
64
+ status: status
65
+ });
66
+ _izContext.logger.debug('AFlowStepsAwaitingMultipleSteps passBackProperties: ', passBackProperties);
67
+
68
+ //(<beforeCheckAwaitingStep>)
69
+ //(</beforeCheckAwaitingStep>)
70
+
71
+ const awaitingStepId = await asyncFlowSharedLib.createAwaitingStepId(
72
+ hash({
73
+ //(<createAwaitingStep>)
74
+ //(</createAwaitingStep>)
75
+ }),
76
+ "<%- firstLetterUpperCase(flowTag) %><%- firstLetterUpperCase(flowStepName) %>"
77
+ );
78
+ _izContext.logger.debug('awaitingStepId:', awaitingStepId);
79
+
80
+ const recordAwaitingSteps = await dynamodbSharedLib.query(
81
+ _izContext,
82
+ await dynamodbSharedLib.tableName(_izContext,
83
+ 'AwaitingMultipleSteps'
84
+ ),
85
+ {
86
+ awaitingStepId
87
+ },
88
+ );
89
+
90
+ await Promise.all(
91
+ recordAwaitingSteps.Items.map(async ({ pendingStepId }) => {
92
+ if (
93
+ await asyncFlowSharedLib.checkAllAwaitingStepsFinished(
94
+ _izContext,
95
+ pendingStepId,
96
+ awaitingStepId,
97
+ errorsFound,
98
+ )
99
+ ) {
100
+ _izContext.logger.debug('finish all awaitingStep');
101
+ //(<checkAwaitingStepFinish>)
102
+ //(</checkAwaitingStepFinish>)
103
+ }
104
+
105
+ //(<beforeRemoveAwatingStep>)
106
+ //(</beforeRemoveAwatingStep>)
107
+ await asyncFlowSharedLib.removeAwaitingMultipleStep(
108
+ _izContext,
109
+ awaitingStepId,
110
+ pendingStepId,
111
+ errorsFound,
112
+ );
113
+ }
114
+ )
115
+ )
116
+ _izContext.logger.debug('record awaitingSteps::', recordAwaitingSteps);
117
+
118
+ //(<afterCheckAwatingFinish>)
119
+ //(</afterCheckAwatingFinish>)
120
+
121
+ } catch (err) {
122
+ _izContext.logger.error('error AFlowStepsAwaitingMultipleStepsMain: ', err)
123
+ throw (err)
124
+ }
125
+ }
126
+
127
+ <%_ function firstLetterUpperCase(text) {
128
+ return text.charAt(0).toUpperCase() + text.slice(1);
129
+ } -%>
@@ -0,0 +1,59 @@
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
+ //(<optionalRequire>)
20
+ //(</optionalRequire>)
21
+
22
+ /**
23
+ *
24
+ *
25
+ * description of function.
26
+ * @param {Object} _izContext
27
+ * @param {CorrelationIds} _izContext.correlationIds - property of _izContext
28
+ * @param {Logger} _izContext.logger - property of _izContext
29
+ * @param {Object} requestParams - request params
30
+ * @param {Object} requestParams.identifiers - identifiers for get data
31
+ * @param {Object} requestParams.additionalRequest - additionalRequest
32
+ *
33
+ *
34
+ * @returns {object} description of return value
35
+ */
36
+ export default async function <%- functionName %>(
37
+ _izContext,
38
+ //(<<%- functionName %>ValidateSchemaProperties>)
39
+ //(</<%- functionName %>ValidateSchemaProperties>)
40
+ startKey,
41
+ overwriteUniqueRequestId,
42
+ overWriteCache,
43
+ callingFlowConfig = {},
44
+ //(<additionalParams>)
45
+ //(</additionalParams>)
46
+ ) {
47
+
48
+
49
+ try {
50
+ _izContext.logger.debug('<%- functionName %> _izContext: ', _izContext);
51
+ _izContext.logger.debug('<%- functionName %> requestParams: ', requestParams);
52
+ _izContext.logger.debug('<%- functionName %> callingFlowConfig: ', callingFlowConfig);
53
+
54
+
55
+ } catch (err) {
56
+ _izContext.logger.error('error <%- functionName %>Main: ', err)
57
+ throw (err)
58
+ }
59
+ }
@@ -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, './sqsTemplate.ejs'),
30
+ [HANDLER.hdrSqs]: path.join(__dirname, './queueNoTopic.ejs'),
31
+ };
32
+ function data(_izContext, data, appPath) {
33
+ const queueName = upperCase(data.flowTag) +
34
+ upperCase(data.flowStepName) +
35
+ upperCase(data.handleLogic)
36
+
37
+ return {
38
+ templatePath: templatePathByHandler[data.handlerType],
39
+ templateData: { ...data, queueName },
40
+ setting: {
41
+ savePath: path.join(appPath, SOURCE_PATH.resourceYaml),
42
+ saveFileName: SAVE_FILE_NAME.snsInSqsYaml,
43
+ fileExtension: '.yml',
44
+ isAppend: true
45
+ }
46
+ }
47
+ }
48
+
49
+
50
+ export default data;