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

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@izara_project/izara-core-generate-service-code",
3
- "version": "1.0.34",
3
+ "version": "1.0.35",
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",
@@ -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,82 @@
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
+ //(<hookCode>)
58
+ <% if (havePlugIn) { -%>
59
+ <% if (invokeType === 'async') { -%>
60
+ let messageObject = {
61
+ action: "recievePlugInRequestAsync"
62
+ };
63
+ <% } -%>
64
+ <% } -%>
65
+
66
+
67
+ //(</hookCode>)
68
+
69
+
70
+ <% if (havePlugIn) { -%>
71
+ <% if (invokeType === 'sync') { -%>
72
+ await api.invokeLambdaApi(_izContext, "<%- targetUrl %>", messageObject)
73
+ <% } else if (invokeType === 'async') { -%>
74
+ await webSocket.invokeWebSocket(_izContext, "<%- targetUrl %>", messageObject)
75
+ <% } -%>
76
+ <% } -%>
77
+
78
+ } catch (err) {
79
+ _izContext.logger.error('error AFlowStepsMain: ', err)
80
+ throw (err)
81
+ }
82
+ }
@@ -54,7 +54,7 @@ export default async function <%- functionName %>(
54
54
  _izContext.logger.debug('<%- functionName %> requestParams: ', requestParams);
55
55
  _izContext.logger.debug('<%- functionName %> callingFlowConfig: ', callingFlowConfig);
56
56
 
57
- //(<AFlowStepsHook>)
57
+ //(<hookCode>)
58
58
  <% if (havePlugIn) { -%>
59
59
  <% if (invokeType === 'async') { -%>
60
60
  let messageObject = {
@@ -64,8 +64,7 @@ export default async function <%- functionName %>(
64
64
  <% } -%>
65
65
 
66
66
 
67
- // add properties to messageObject invoke lambda
68
- //(</AFlowStepsHook>)
67
+ //(</hookCode>)
69
68
 
70
69
 
71
70
  <% if (havePlugIn) { -%>
@@ -28,7 +28,6 @@ const { SOURCE_PATH, SAVE_FILE_NAME, HANDLER } = consts;
28
28
  const templatePath = path.join(__dirname, '../../../resourceYamlComponent/sns-out/template.ejs')
29
29
 
30
30
  async function data(_izContext, data, appPath) {
31
- console.log("generate sns out")
32
31
  const queueName = `${upperCase(data.flowTag)}_${upperCase(data.flowStepName)}`;
33
32
 
34
33
  return {
@@ -222,6 +222,9 @@ async function generatePlunIg(
222
222
  }
223
223
  }
224
224
  }
225
+ } else {
226
+ mainResult = await mainFunctionFlowStep(_izContext, { ...data, havePlugIn: false }, appPath);
227
+ allCreateSourceParams.push(mainResult);
225
228
  }
226
229
  }
227
230
  }
@@ -68,7 +68,9 @@ function createSourceSystemText(
68
68
  };
69
69
  const systemTextObjectSchemas = {
70
70
  nameSpace: `${coreUtils.createObjTypeConcat(_izContext, objType)}_description`, // for each objectType
71
- systemTextTag: `${fieldName}_${coreUtils.createObjTypeConcat(_izContext, objType)}` // for each fieldName
71
+ systemTextTag: `${fieldName}_${coreUtils.createObjTypeConcat(_izContext, objType)}`, // for each fieldName
72
+ openHook: `//(<${coreUtils.createObjTypeConcat(_izContext, objType)}${fieldName}Hook>)`,
73
+ closeHook: `//(</${coreUtils.createObjTypeConcat(_izContext, objType)}${fieldName}Hook>)`
72
74
  };
73
75
  createSourceArray.push(systemTextObjectSchemas);
74
76
  }
@@ -83,7 +85,9 @@ function createSourceSystemText(
83
85
  };
84
86
  const systemTextFlowSchemas = {
85
87
  nameSpace: `${coreUtils.createFlowTypeConcat(_izContext, flowType)}`, // for each flowType
86
- systemTextTag: `errors_${coreUtils.createFlowTypeConcat(_izContext, flowType)}`
88
+ systemTextTag: `errors_${coreUtils.createFlowTypeConcat(_izContext, flowType)}`,
89
+ openHook: `//(<${coreUtils.createFlowTypeConcat(_izContext, flowType)}Hook>)`,
90
+ closeHook: `//(</${coreUtils.createFlowTypeConcat(_izContext, flowType)}Hook>)`
87
91
  };
88
92
  createSourceArray.push(systemTextFlowSchemas);
89
93
  }
@@ -101,7 +105,9 @@ function createSourceSystemText(
101
105
  for (const fieldName of Object.keys(relSchema[relTag].fieldNames)) {
102
106
  const systemTextRelSchemas = {
103
107
  nameSpace: `${coreUtils.createRelTypeConcat(_izContext, relType)}_description`,
104
- systemTextTag: `${fieldName}_${coreUtils.createRelTypeConcat(_izContext, relType)}`
108
+ systemTextTag: `${fieldName}_${coreUtils.createRelTypeConcat(_izContext, relType)}`,
109
+ openHook: `//(<${coreUtils.createRelTypeConcat(_izContext, relType)}${fieldName}Hook>)`,
110
+ closeHook: `//(</${coreUtils.createRelTypeConcat(_izContext, relType)}${fieldName}Hook>)`
105
111
  }
106
112
  createSourceArray.push(systemTextRelSchemas);
107
113
  }
@@ -113,7 +119,9 @@ function createSourceSystemText(
113
119
  for (const notification of notificationSchemas) {
114
120
  const notificationSystemText = {
115
121
  nameSpace: `sysNotification_${notification.notificationGrouping}`,
116
- systemTextTag: notification.notificationTag
122
+ systemTextTag: notification.notificationTag,
123
+ openHook: `//(<${notification.notificationTag}Hook>)`,
124
+ closeHook: `//(</${notification.notificationTag}Hook>)`
117
125
  }
118
126
  createSourceArray.push(notificationSystemText)
119
127
  }
@@ -127,7 +135,11 @@ function createSourceSystemText(
127
135
  saveFileName: SAVE_FILE_NAME.systemTextSchema,
128
136
  fileExtension: '.js',
129
137
  isAppend: true,
130
- generateHookFile: false
138
+ hookPath: path.join(
139
+ schemaPath,
140
+ '../schemaHook/'
141
+ ),
142
+ // generateHookFile: false
131
143
  }
132
144
  };
133
145
  }
@@ -1,5 +1,10 @@
1
1
  export default [
2
2
  <% datas.forEach((data, index) => { -%>
3
- <%- JSON.stringify(data,null,2) %><%= index < datas.length - 1 ? ',' : '' %>
3
+ {
4
+ nameSpace: "<%- data.nameSpace %>",
5
+ systemTextTag: "<%- data.systemTextTag %>",
6
+ <%- data.openHook %>
7
+ <%- data.closeHook %>
8
+ }<%= index < datas.length - 1 ? ',' : '' %>
4
9
  <% }); -%>
5
10
  ];