@izara_project/izara-core-generate-service-code 1.0.33 → 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.
Files changed (37) 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 +45 -0
  17. package/src/generateCode/generateFlowStepWithPlugIn/afterFirstFlowStep/sendPlugIn/mainFunction/template.ejs +82 -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 +82 -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 +45 -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 +259 -0
  33. package/src/generateCode/generateSchema/generateTextTag/systemText/data.js +68 -47
  34. package/src/generateCode/generateSchema/generateTextTag/systemText/template.ejs +6 -1
  35. package/src/generateCode/resourceYamlComponent/sns-out/template.ejs +4 -0
  36. package/src/generateCode.js +41 -32
  37. package/src/libs/Libs.js +106 -8
@@ -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
+ <%_ } _%>
@@ -0,0 +1,259 @@
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 yaml from 'yaml';
20
+ import { consts as coreConsts } from '@izara_project/izara-core-library-service-schemas';
21
+ import libs from '#libs/Libs.js';
22
+ const { createSnsResource, createSqsResource, defaultIamRolePerAction, getLocalOrS3ObjectSchema, getLocalOrS3FlowSchema, resourceNames } = libs;
23
+ import utils from '#libs/Utils.js';
24
+ const { firstLetterUpperCase: upperCase, firstLetterLowerCase: lowerCase } = utils;
25
+ import consts from '#libs/Consts.js';
26
+ const { SOURCE_PATH, HANDLER, RESOURCE_CLASSES } = consts;
27
+
28
+ import yamlFlowStep from './firstFlowStep/yaml/data.js';
29
+ import handlerFlowStep from './firstFlowStep/handler/data.js';
30
+ import mainFunctionFlowStep from './firstFlowStep/mainFunction/data.js';
31
+ import sqsFlowStep from './firstFlowStep/queueNtopic/data.js';
32
+ import snsOut from './firstFlowStep/topicOut/data.js';
33
+
34
+ import yamlRecievePlugIn from './afterFirstFlowStep/recievePlugIn/yaml/data.js';
35
+ import handlerRecievePlugIn from './afterFirstFlowStep/recievePlugIn/handler/data.js';
36
+ import mainFunctionRecievePlugIn from './afterFirstFlowStep/recievePlugIn/mainFunction/data.js';
37
+
38
+ // import yamlSendPlugIn from './afterFirstFlowStep/sendPlugIn/yaml/data.js';
39
+ // import handlerSendPlugIn from './afterFirstFlowStep/sendPlugIn/handler/data.js';
40
+ // import mainFunctionSendPlugIn from './afterFirstFlowStep/sendPlugIn/mainFunction/data.js';
41
+
42
+
43
+ /**
44
+ * Generates code from templates based on object schemas
45
+ * @param {Object} _izContext
46
+ * @param {string} appPath
47
+ * @param {Array} allObjSchemas
48
+ * @param {Array} allRelationshipSchemas
49
+ * @param {Object} settings
50
+ * @returns {Promise<Array>}
51
+ */
52
+ async function generatePlunIg(
53
+ _izContext,
54
+ appPath,
55
+ allObjSchemas,
56
+ allLocalFlowSchemas,
57
+ ) {
58
+ const allCreateSourceParams = [];
59
+
60
+ try {
61
+ const startAllMs = Date.now();
62
+ const totalSchemas = Array.isArray(allObjSchemas)
63
+ ? allObjSchemas.length
64
+ : 0;
65
+
66
+
67
+ console.info(`[plugIn] start totalSchemas=${totalSchemas}`);
68
+ if (totalSchemas === 0) return [];
69
+
70
+ const configPath = path.join(appPath, '../config/serverless.config.yml');
71
+ const serverlessConfig = fs.readFileSync(configPath, 'utf8');
72
+ const config = yaml.parse(serverlessConfig);
73
+ const serviceTag = config.main_config.iz_serviceTag;
74
+
75
+ for (const flowSchema of allLocalFlowSchemas) {
76
+ for (const [flowStepName, flowStepConfig] of Object.entries(flowSchema.flowSteps)) {
77
+ if (flowStepName === "In" || flowStepName === "Out") {
78
+ continue;
79
+ } else {
80
+ const flowTag = flowSchema.flowTag;
81
+ const roleName = upperCase(flowTag);
82
+ const resourceApis = [];
83
+ let handler;
84
+ const additionalResourcePremission = defaultIamRolePerAction();
85
+
86
+ const data = {
87
+ additionalResourcePremission: additionalResourcePremission,
88
+ flowStepName: flowStepName,
89
+ flowTag: flowTag,
90
+ resourceApis: resourceApis,
91
+ hookTagSetting: `${flowSchema.flowTag}FunctionSetting`,
92
+ functionName: upperCase(flowSchema.flowTag) + upperCase(flowStepName),
93
+ roleName: roleName,
94
+ };
95
+
96
+ if (flowStepConfig.event.includes("ownTopic")) {
97
+ data['eventFlow'] = 'ownTopic'
98
+ handler = HANDLER.hdrSqs;
99
+ additionalResourcePremission.push(
100
+ createSnsResource(
101
+ [
102
+ upperCase(flowSchema.flowTag) + upperCase(flowStepName) + "_In"
103
+ ]
104
+ ),
105
+ createSqsResource(
106
+ [
107
+ upperCase(flowSchema.flowTag) + upperCase(flowStepName) + upperCase(handler),
108
+ upperCase(flowSchema.flowTag) + upperCase(flowStepName) + upperCase(handler) + "DSQ"
109
+ ]
110
+ )
111
+ );
112
+ } else if (flowStepConfig.event.includes("extTopic")) {
113
+ data['eventFlow'] = 'extTopic'
114
+ handler = HANDLER.hdrSqs;
115
+ additionalResourcePremission.push(
116
+ createSqsResource(
117
+ [
118
+ upperCase(flowSchema.flowTag) + upperCase(flowStepName) + upperCase(handler),
119
+ upperCase(flowSchema.flowTag) + upperCase(flowStepName) + upperCase(handler) + "DSQ"
120
+ ]
121
+ )
122
+ );
123
+ } else if (flowStepConfig.event.includes("lambdaSyncInv")) {
124
+ handler = HANDLER.hdrInv;
125
+ } else if (flowStepConfig.event.includes("lambdaSyncApi")) {
126
+ handler = HANDLER.hdrApi;
127
+ resourceApis.push({
128
+ path: `${serviceTag}/${lowerCase(flowTag)}${lowerCase(flowStepName)}`,
129
+ pathWithUser: `${serviceTag}/${lowerCase(flowTag)}${lowerCase(flowStepName)}/{targetUserId}`,
130
+ method: 'post',
131
+ hookTagApp: `${upperCase(flowStepName)}${upperCase(handler)}AppLevelAuthorizer`,
132
+ hookTagUser: `${upperCase(flowStepName)}${upperCase(handler)}UserLevelAuthorizer`
133
+ })
134
+ } else if (flowStepConfig.event.includes("queue")) {
135
+ handler = HANDLER.hdrDsq;
136
+ additionalResourcePremission.push(
137
+ createSqsResource(
138
+ [
139
+ upperCase(flowSchema.flowTag) + upperCase(flowStepName) + upperCase(handler),
140
+ upperCase(flowSchema.flowTag) + upperCase(flowStepName) + upperCase(handler) + "DSQ"
141
+ ]
142
+ )
143
+ );
144
+ };
145
+
146
+ Object.assign(data, {
147
+ handlerType: handler,
148
+ handlerPath: path.join(
149
+ SOURCE_PATH.resourceLocationFlowSchema,
150
+ upperCase(flowSchema.flowTag),
151
+ upperCase(flowStepName),
152
+ 'source/',
153
+ `${upperCase(flowTag)}${upperCase(flowStepName)}_${upperCase(handler)}`,
154
+ ),
155
+ functionNameConfig: upperCase(flowSchema.flowTag) + upperCase(flowStepName) + upperCase(handler),
156
+ event: resourceNames(RESOURCE_CLASSES.sqs, upperCase(flowSchema.flowTag) + upperCase(flowStepName) + upperCase(handler)),
157
+ queueName: upperCase(flowSchema.flowTag) + upperCase(flowStepName) + upperCase(handler),
158
+ })
159
+
160
+ const yamlFlowStepRes = await yamlFlowStep(_izContext, data, appPath);
161
+ const handlerResult = await handlerFlowStep(_izContext, data, appPath);
162
+ allCreateSourceParams.push(yamlFlowStepRes, handlerResult);
163
+
164
+ if (handler === HANDLER.hdrSqs || handler === HANDLER.hdrDsq) {
165
+ const sqsResult = await sqsFlowStep(_izContext, data, appPath);
166
+ allCreateSourceParams.push(sqsResult);
167
+ }
168
+
169
+ const snsOutResult = await snsOut(_izContext, data, appPath);
170
+ allCreateSourceParams.push(snsOutResult);
171
+
172
+ let mainResult;
173
+ if (flowStepConfig.hasOwnProperty("plugInHooks")) {
174
+ // for (const plugInHookFlow of flowStepConfig.plugInHooks) {
175
+ for (let i = 0; i < flowStepConfig.plugInHooks.length; i++) {
176
+ if (i === 0) { // create main function for first flowStep
177
+ const [objSchema] = await getLocalOrS3ObjectSchema(_izContext, flowStepConfig.plugInHooks[i].objType, path.join(appPath, './src/schemas'));
178
+ let targetPlugIn = null;
179
+ if (objSchema.hasOwnProperty('plugIns')) {
180
+ for (const plugInConfig of Object.values(objSchema.plugIns)) {
181
+ targetPlugIn = plugInConfig.plugInHooks.find(h => h.plugInHookTagType.plugInHookTag === flowStepConfig.plugInHooks[i].plugInHookTag);
182
+ if (targetPlugIn) {
183
+ break;
184
+ }
185
+ };
186
+
187
+ if (targetPlugIn) {
188
+ let targetUrl = targetPlugIn.plugInHookTagType.targetUrl;
189
+ if (targetPlugIn.invocationType === 'sync') {
190
+ targetUrl += '/recievePlugInRequestSync'
191
+ }
192
+ mainResult = await mainFunctionFlowStep(
193
+ _izContext,
194
+ {
195
+ ...data,
196
+ invokeType: targetPlugIn.invocationType, // Ensure this matches "sync" or "async"
197
+ havePlugIn: true,
198
+ targetUrl: targetUrl
199
+ },
200
+ appPath
201
+ );
202
+ } else {
203
+ mainResult = await mainFunctionFlowStep(_izContext, { ...data, havePlugIn: false }, appPath);
204
+ }
205
+ allCreateSourceParams.push(mainResult);
206
+ };
207
+
208
+ if (objSchema.hasOwnProperty('recievePlugInHookTag')) {
209
+ for (const recieveConfig of Object.values(objSchema.recievePlugInHookTag)) {
210
+ if (recieveConfig.hasOwnProperty('flowType')) {
211
+ data['recieveType'] = "async",
212
+ data['flowType'] = recieveConfig.flowType
213
+ } else {
214
+ data['recieveType'] = 'sync'
215
+ }
216
+ const yamlRecievePlugInResult = await yamlRecievePlugIn(_izContext, data, appPath);
217
+ const handlerRecievePlugInResult = await handlerRecievePlugIn(_izContext, data, appPath);
218
+ const mainFunctionRecievePlugInResult = await mainFunctionRecievePlugIn(_izContext, data, appPath);
219
+ // console.log("mainFunctionRecievePlugInResult", mainFunctionRecievePlugInResult)
220
+ allCreateSourceParams.push(...yamlRecievePlugInResult, ...handlerRecievePlugInResult, mainFunctionRecievePlugInResult);
221
+ }
222
+ }
223
+ }
224
+ }
225
+ } else {
226
+ mainResult = await mainFunctionFlowStep(_izContext, { ...data, havePlugIn: false }, appPath);
227
+ allCreateSourceParams.push(mainResult);
228
+ }
229
+ }
230
+ }
231
+ };
232
+
233
+ const uniqueSortedTargetFiles = Array.from(
234
+ new Set(
235
+ allCreateSourceParams
236
+ .filter(
237
+ item => item?.setting?.savePath && item?.setting?.saveFileName
238
+ )
239
+ .map(
240
+ item =>
241
+ `${item.setting.savePath.replace(/\/+$/, '')}/${item.setting.saveFileName}${item.setting.fileExtension || ''}`
242
+ )
243
+ )
244
+ ).sort();
245
+
246
+ console.info(
247
+ `[plugIn] completed total=${allCreateSourceParams.length} uniqueFiles=${uniqueSortedTargetFiles.length} elapsedMs=${Date.now() - startAllMs}`
248
+ );
249
+ if (uniqueSortedTargetFiles.length > 0 && _izContext.logger?.debug)
250
+ console.log('[plugIn] targetFiles=', uniqueSortedTargetFiles);
251
+
252
+ return allCreateSourceParams;
253
+ } catch (error) {
254
+ console.error('[plugIn] error:', error);
255
+ return [];
256
+ }
257
+ }
258
+
259
+ export default generatePlunIg;
@@ -49,67 +49,84 @@ function createSourceSystemText(
49
49
  schemaPath
50
50
  ) {
51
51
  const createSourceArray = [];
52
- // console.log("params objSchema", JSON.stringify(allObjectSchema, null, 2));
53
- for (const objectSchema of allObjectSchema) {
54
- const fieldNames = [...Object.keys(objectSchema.fieldNames)];
55
- if (objectSchema.hasOwnProperty("addOnDataStructure")) {
56
- for (const addOn of objectSchema.addOnDataStructure) {
57
- if (addOn.type === "versionedData") {
58
- fieldNames.push(...Object.keys(addOn.fieldNames))
52
+
53
+ if (allObjectSchema.length > 0) {
54
+ for (const objectSchema of allObjectSchema) {
55
+ const fieldNames = [...Object.keys(objectSchema.fieldNames)];
56
+ if (objectSchema.hasOwnProperty("addOnDataStructure")) {
57
+ for (const addOn of objectSchema.addOnDataStructure) {
58
+ if (addOn.type === "versionedData") {
59
+ fieldNames.push(...Object.keys(addOn.fieldNames))
60
+ }
59
61
  }
62
+ };
63
+
64
+ for (const fieldName of fieldNames) {
65
+ const objType = {
66
+ objectType: objectSchema.objectType,
67
+ serviceTag: getLocalConfig('iz_serviceTag')
68
+ };
69
+ const systemTextObjectSchemas = {
70
+ nameSpace: `${coreUtils.createObjTypeConcat(_izContext, objType)}_description`, // for each objectType
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>)`
74
+ };
75
+ createSourceArray.push(systemTextObjectSchemas);
60
76
  }
61
- };
77
+ }
78
+ }
62
79
 
63
- for (const fieldName of fieldNames) {
64
- const objType = {
65
- objectType: objectSchema.objectType,
80
+ if (allFlowSchemas.length > 0) {
81
+ for (const flowSchema of allFlowSchemas) {
82
+ const flowType = {
83
+ flowTag: flowSchema.flowTag,
66
84
  serviceTag: getLocalConfig('iz_serviceTag')
67
85
  };
68
- const systemTextObjectSchemas = {
69
- nameSpace: `${coreUtils.createObjTypeConcat(_izContext, objType)}_description`, // for each objectType
70
- systemTextTag: `${fieldName}_${coreUtils.createObjTypeConcat(_izContext, objType)}` // for each fieldName
86
+ const systemTextFlowSchemas = {
87
+ nameSpace: `${coreUtils.createFlowTypeConcat(_izContext, flowType)}`, // for each flowType
88
+ systemTextTag: `errors_${coreUtils.createFlowTypeConcat(_izContext, flowType)}`,
89
+ openHook: `//(<${coreUtils.createFlowTypeConcat(_izContext, flowType)}Hook>)`,
90
+ closeHook: `//(</${coreUtils.createFlowTypeConcat(_izContext, flowType)}Hook>)`
71
91
  };
72
- createSourceArray.push(systemTextObjectSchemas);
92
+ createSourceArray.push(systemTextFlowSchemas);
73
93
  }
74
94
  }
75
95
 
76
- for (const flowSchema of allFlowSchemas) {
77
- const flowType = {
78
- flowTag: flowSchema.flowTag,
79
- serviceTag: getLocalConfig('iz_serviceTag')
80
- };
81
- const systemTextFlowSchemas = {
82
- nameSpace: `${coreUtils.createFlowTypeConcat(_izContext, flowType)}`, // for each flowType
83
- systemTextTag: `errors_${coreUtils.createFlowTypeConcat(_izContext, flowType)}`
84
- };
85
- createSourceArray.push(systemTextFlowSchemas);
86
- }
96
+ if (allRelSchema.length > 0) {
97
+ for (const relSchema of allRelSchema) {
98
+ const relTag = Object.keys(relSchema)[0]
99
+ const relType = {
100
+ serviceTag: getLocalConfig('iz_serviceTag'),
101
+ relationshipTag: relTag
102
+ };
87
103
 
88
- for (const relSchema of allRelSchema) {
89
- const relTag = Object.keys(relSchema)[0]
90
- const relType = {
91
- serviceTag: getLocalConfig('iz_serviceTag'),
92
- relationshipTag: relTag
93
- };
94
-
95
- for (const fieldName of Object.keys(relSchema[relTag].fieldNames)) {
96
- const systemTextRelSchemas = {
97
- nameSpace: `${coreUtils.createRelTypeConcat(_izContext, relType)}_description`,
98
- systemTextTag: `${fieldName}_${coreUtils.createRelTypeConcat(_izContext, relType)}`
104
+ if (relSchema[relTag].hasOwnProperty('fieldNames') && Object.keys(relSchema[relTag].fieldNames).length > 0) {
105
+ for (const fieldName of Object.keys(relSchema[relTag].fieldNames)) {
106
+ const systemTextRelSchemas = {
107
+ nameSpace: `${coreUtils.createRelTypeConcat(_izContext, relType)}_description`,
108
+ systemTextTag: `${fieldName}_${coreUtils.createRelTypeConcat(_izContext, relType)}`,
109
+ openHook: `//(<${coreUtils.createRelTypeConcat(_izContext, relType)}${fieldName}Hook>)`,
110
+ closeHook: `//(</${coreUtils.createRelTypeConcat(_izContext, relType)}${fieldName}Hook>)`
111
+ }
112
+ createSourceArray.push(systemTextRelSchemas);
113
+ }
99
114
  }
100
- createSourceArray.push(systemTextRelSchemas);
101
115
  }
102
116
  }
103
- console.log("notificationSchemas", notificationSchemas);
104
- for (const notification of notificationSchemas) {
105
- const notificationSystemText = {
106
- nameSpace: `sysNotification_${notification.notificationGrouping}`,
107
- systemTextTag: notification.notificationTag
117
+
118
+ if (notificationSchemas.length > 0) {
119
+ for (const notification of notificationSchemas) {
120
+ const notificationSystemText = {
121
+ nameSpace: `sysNotification_${notification.notificationGrouping}`,
122
+ systemTextTag: notification.notificationTag,
123
+ openHook: `//(<${notification.notificationTag}Hook>)`,
124
+ closeHook: `//(</${notification.notificationTag}Hook>)`
125
+ }
126
+ createSourceArray.push(notificationSystemText)
108
127
  }
109
- createSourceArray.push(notificationSystemText)
110
128
  }
111
- // console.log("schemaPath", schemaPath)
112
- // console.log("createSourceArray", createSourceArray)
129
+
113
130
  return {
114
131
  templatePath: templatePath,
115
132
  templateData: { datas: createSourceArray },
@@ -118,7 +135,11 @@ function createSourceSystemText(
118
135
  saveFileName: SAVE_FILE_NAME.systemTextSchema,
119
136
  fileExtension: '.js',
120
137
  isAppend: true,
121
- generateHookFile: false
138
+ hookPath: path.join(
139
+ schemaPath,
140
+ '../schemaHook/'
141
+ ),
142
+ // generateHookFile: false
122
143
  }
123
144
  };
124
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
  ];
@@ -1,5 +1,9 @@
1
1
  ##--------- [Create Topic Out]
2
+ <% if (queueName.includes("_")) { %>
3
+ Out<%- (queueName.split("_")).join("") %>:
4
+ <% } else { -%>
2
5
  Out<%- queueName %>:
6
+ <% } -%>
3
7
  Type: AWS::SNS::Topic
4
8
  Properties:
5
9
  DisplayName: "SNS Message out"
@@ -38,6 +38,8 @@ import generateTemplateDataOther from './generateCode/generateOther/generateCode
38
38
 
39
39
  import generateTemplateDataRole from './generateCode/generateRole/generateCodeRole.js';
40
40
 
41
+ import generatePlugIn from './generateCode/generateFlowStepWithPlugIn/index.js';
42
+
41
43
  const __filename = fileURLToPath(import.meta.url);
42
44
  const __dirname = dirname(__filename);
43
45
 
@@ -97,37 +99,43 @@ async function generateCodeWithTemplate(
97
99
  console.info('[INFO] [generateCode] STATUS=GENERATING| template data...');
98
100
  _izContext.logger.info('[generateCode] generating template data...');
99
101
  const genStartTime = Date.now();
100
- const [flowSchemaResult, schemaResult, initialSetupResult, otherResult] =
101
- await Promise.all([
102
- generateTemplateDataFromFlowSchema(
103
- _izContext,
104
- appPath,
105
- allLocalFlowSchemas.records,
106
- settings
107
- ),
108
- generateTemplateDataFromSchema(
109
- _izContext,
110
- appPath,
111
- allObjSchemas,
112
- allLocalRelationshipSchemas,
113
- allLocalFlowSchemas.records,
114
- allLocalNotificationSystem,
115
- settings
116
- ).catch(error => {
117
- console.error('[generateCode] schemaResult error:', error);
118
- _izContext.logger.error('[generateCode] schemaResult error:', error);
119
- return [];
120
- }),
121
- generateTemplateDataInitialSetup(
122
- _izContext,
123
- appPath,
124
- allObjSchemas.records,
125
- allLocalRelationshipSchemas,
126
- allLocalFlowSchemas.records,
127
- settings
128
- ),
129
- generateTemplateDataOther(_izContext, appPath)
130
- ]);
102
+ const [
103
+ flowSchemaResult,
104
+ schemaResult,
105
+ initialSetupResult,
106
+ otherResult,
107
+ generatePlugInResult
108
+ ] = await Promise.all([
109
+ generateTemplateDataFromFlowSchema(
110
+ _izContext,
111
+ appPath,
112
+ allLocalFlowSchemas.records,
113
+ settings
114
+ ),
115
+ generateTemplateDataFromSchema(
116
+ _izContext,
117
+ appPath,
118
+ allObjSchemas,
119
+ allLocalRelationshipSchemas,
120
+ allLocalFlowSchemas.records,
121
+ allLocalNotificationSystem,
122
+ settings
123
+ ).catch(error => {
124
+ console.error('[generateCode] schemaResult error:', error);
125
+ _izContext.logger.error('[generateCode] schemaResult error:', error);
126
+ return [];
127
+ }),
128
+ generateTemplateDataInitialSetup(
129
+ _izContext,
130
+ appPath,
131
+ allObjSchemas.records,
132
+ allLocalRelationshipSchemas,
133
+ allLocalFlowSchemas.records,
134
+ settings
135
+ ),
136
+ generateTemplateDataOther(_izContext, appPath),
137
+ generatePlugIn(_izContext, appPath, allObjSchemas.records, allLocalFlowSchemas.records)
138
+ ]);
131
139
 
132
140
  const genDuration = Date.now() - genStartTime;
133
141
  const genStr = `flow=${flowSchemaResult.length} sch=${schemaResult.length} setup=${initialSetupResult.length} other=${otherResult.length}`;
@@ -139,7 +147,8 @@ async function generateCodeWithTemplate(
139
147
  ...flowSchemaResult,
140
148
  ...schemaResult,
141
149
  ...initialSetupResult,
142
- ...otherResult
150
+ ...otherResult,
151
+ ...generatePlugInResult
143
152
  ];
144
153
 
145
154
  // ── 3. Generate role configs ─────────────────────────────────────────────