@izara_project/izara-core-generate-service-code 1.0.39 → 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 (29) hide show
  1. package/package.json +6 -6
  2. package/src/generateCode/generateFlowStepWithPlugIn/byConfig/handler/data.js +56 -0
  3. package/src/generateCode/generateFlowStepWithPlugIn/byConfig/handler/templateAwaitingStep.ejs +105 -0
  4. package/src/generateCode/generateFlowStepWithPlugIn/byConfig/handler/templatePaginated.ejs +137 -0
  5. package/src/generateCode/generateFlowStepWithPlugIn/byConfig/mainFunction/data.js +57 -0
  6. package/src/generateCode/generateFlowStepWithPlugIn/byConfig/mainFunction/templateAwaitingStep.ejs +129 -0
  7. package/src/generateCode/generateFlowStepWithPlugIn/byConfig/mainFunction/templatePaginated.ejs +59 -0
  8. package/src/generateCode/generateFlowStepWithPlugIn/byConfig/sns-sqs/data.js +50 -0
  9. package/src/generateCode/generateFlowStepWithPlugIn/byConfig/sns-sqs/queueNoTopic.ejs +43 -0
  10. package/src/generateCode/generateFlowStepWithPlugIn/byConfig/sns-sqs/snsTemplate.ejs +58 -0
  11. package/src/generateCode/generateFlowStepWithPlugIn/byConfig/sns-sqs/sqsTemplate.ejs +43 -0
  12. package/src/generateCode/generateFlowStepWithPlugIn/byConfig/yaml/data.js +47 -0
  13. package/src/generateCode/generateFlowStepWithPlugIn/byConfig/yaml/template.ejs +43 -0
  14. package/src/generateCode/generateFlowStepWithPlugIn/firstFlowStep/handler/data.js +7 -1
  15. package/src/generateCode/generateFlowStepWithPlugIn/firstFlowStep/mainFunction/data.js +38 -6
  16. package/src/generateCode/generateFlowStepWithPlugIn/firstFlowStep/mainFunction/template.ejs +5 -16
  17. package/src/generateCode/generateFlowStepWithPlugIn/firstFlowStep/mainFunction/templateByConfig/awaitingSteps.ejs +63 -0
  18. package/src/generateCode/generateFlowStepWithPlugIn/firstFlowStep/mainFunction/templateByConfig/templateSendPlugin.ejs +18 -0
  19. package/src/generateCode/generateFlowStepWithPlugIn/firstFlowStep/queueNtopic/sqsTemplate.ejs +7 -7
  20. package/src/generateCode/generateFlowStepWithPlugIn/firstFlowStep/topicOut/data.js +1 -1
  21. package/src/generateCode/generateFlowStepWithPlugIn/index(old).js +290 -0
  22. package/src/generateCode/generateFlowStepWithPlugIn/index.js +411 -155
  23. package/src/generateCode/generateInitialSetup/externalServiceComponent/lambdaRole/data.js +22 -0
  24. package/src/generateCode/generateInitialSetup/externalServiceComponent/snsTopicSubscriptions/data.js +16 -0
  25. package/src/generateCode/generateSchema/actionEndpointCompleteComponent/create/mainFunction/template.ejs +44 -4
  26. package/src/generateCode/generateSchema/actionEndpointComponent/mainFunction/create/main/template.ejs +58 -40
  27. package/src/libs/Libs.js +21 -15
  28. package/src/generateCode/generateInitialSetup/externalServiceComponent/lambdaRole/request.json +0 -18
  29. package/src/generateCode/generateInitialSetup/externalServiceComponent/snsTopicSubscriptions/request.json +0 -12
@@ -17,13 +17,11 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
17
17
 
18
18
  import path from 'path'
19
19
  import yaml from 'yaml';
20
- import { consts as coreConsts } from '@izara_project/izara-core-library-service-schemas';
21
20
  import libs from '#libs/Libs.js';
22
- const { createSnsResource, createSqsResource, defaultIamRolePerAction, getLocalOrS3ObjectSchema, getLocalOrS3FlowSchema, resourceNames } = libs;
23
21
  import utils from '#libs/Utils.js';
24
22
  const { firstLetterUpperCase: upperCase, firstLetterLowerCase: lowerCase } = utils;
25
23
  import consts from '#libs/Consts.js';
26
- const { SOURCE_PATH, HANDLER, RESOURCE_CLASSES } = consts;
24
+ const { SOURCE_PATH, HANDLER, RESOURCE_CLASSES, SNS_RESOURCE } = consts;
27
25
 
28
26
  import yamlFlowStep from './firstFlowStep/yaml/data.js';
29
27
  import handlerFlowStep from './firstFlowStep/handler/data.js';
@@ -35,6 +33,22 @@ import yamlRecievePlugIn from './afterFirstFlowStep/recievePlugIn/yaml/data.js';
35
33
  import handlerRecievePlugIn from './afterFirstFlowStep/recievePlugIn/handler/data.js';
36
34
  import mainFunctionRecievePlugIn from './afterFirstFlowStep/recievePlugIn/mainFunction/data.js';
37
35
 
36
+ import handlerFlowConfig from './byConfig/handler/data.js';
37
+ import mainFunctionFlowConfig from './byConfig/mainFunction/data.js';
38
+ import sqsFlowConfig from './byConfig/sns-sqs/data.js';
39
+ import yamlFlowConfig from './byConfig/yaml/data.js';
40
+
41
+ const {
42
+ createSnsResource,
43
+ createSqsResource,
44
+ defaultIamRolePerAction,
45
+ getLocalOrS3ObjectSchema,
46
+ resourceNames,
47
+ awaitingMultipleStepsRole,
48
+ createIamRole,
49
+ externalResourceYaml
50
+ } = libs;
51
+
38
52
  // import yamlSendPlugIn from './afterFirstFlowStep/sendPlugIn/yaml/data.js';
39
53
  // import handlerSendPlugIn from './afterFirstFlowStep/sendPlugIn/handler/data.js';
40
54
  // import mainFunctionSendPlugIn from './afterFirstFlowStep/sendPlugIn/mainFunction/data.js';
@@ -74,167 +88,111 @@ async function generatePlunIg(
74
88
 
75
89
  for (const flowSchema of allLocalFlowSchemas) {
76
90
  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 additionalResourcePermission = defaultIamRolePerAction();
85
-
86
- const data = {
87
- additionalResourcePermission: additionalResourcePermission,
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
- };
91
+ if (flowStepName === "In" || flowStepName === "Out") continue;
95
92
 
96
- if (flowStepConfig.event.includes("ownTopic")) {
97
- data['eventFlow'] = 'ownTopic'
98
- handler = HANDLER.hdrSqs;
99
- additionalResourcePermission.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
- additionalResourcePermission.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
- additionalResourcePermission.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
- };
93
+ const flowTag = flowSchema.flowTag;
94
+ const roleName = upperCase(flowTag);
95
+ const resourceApis = [];
96
+ const additionalResourcePermission = defaultIamRolePerAction();
145
97
 
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),
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
- }
98
+ const data = {
99
+ additionalResourcePermission,
100
+ flowStepName,
101
+ flowTag,
102
+ resourceApis,
103
+ hookTagSetting: `${flowSchema.flowTag}FunctionSetting`,
104
+ functionName: upperCase(flowSchema.flowTag) + upperCase(flowStepName),
105
+ roleName,
106
+ };
168
107
 
169
- const snsOutResult = await snsOut(_izContext, data, appPath);
170
- allCreateSourceParams.push(snsOutResult);
108
+ resolveHandlerConfig(
109
+ data,
110
+ flowStepConfig,
111
+ additionalResourcePermission,
112
+ resourceApis,
113
+ serviceTag);
114
+
115
+ Object.assign(data, {
116
+ handlerType: data.handlerType,
117
+ handlerPath: path.join(
118
+ SOURCE_PATH.resourceLocationFlowSchema,
119
+ upperCase(flowSchema.flowTag),
120
+ upperCase(flowStepName),
121
+ 'source/',
122
+ `${upperCase(flowTag)}${upperCase(flowStepName)}_${upperCase(data.handlerType)}`,
123
+ ),
124
+ functionNameConfig: upperCase(flowSchema.flowTag) +
125
+ upperCase(flowStepName) +
126
+ upperCase(data.handlerType),
127
+ event: resourceNames(
128
+ RESOURCE_CLASSES.sqs,
129
+ upperCase(flowSchema.flowTag) +
130
+ upperCase(flowStepName) +
131
+ upperCase(data.handlerType)),
132
+ queueName: upperCase(flowSchema.flowTag) + upperCase(flowStepName),
133
+ });
171
134
 
172
- let mainResult;
173
- if (flowStepConfig.hasOwnProperty("handleLogic")) {
174
-
175
- }
176
- if (flowStepConfig.hasOwnProperty("plugInHooks")) {
177
- // for (const plugInHookFlow of flowStepConfig.plugInHooks) {
178
- for (let i = 0; i < flowStepConfig.plugInHooks.length; i++) {
179
- if (i === 0) { // create main function for first flowStep
180
- const [objSchema] = await getLocalOrS3ObjectSchema(_izContext, flowStepConfig.plugInHooks[i].objType, path.join(appPath, './src/schemas'));
181
- let targetPlugIn = null;
182
- if (objSchema.hasOwnProperty('plugIns')) {
183
- for (const plugInConfig of Object.values(objSchema.plugIns)) {
184
- targetPlugIn = plugInConfig.plugInHooks.find(h => h.plugInHookTagType.plugInHookTag === flowStepConfig.plugInHooks[i].plugInHookTag);
185
- if (targetPlugIn) {
186
- break;
187
- }
188
- };
189
-
190
- if (targetPlugIn) {
191
- let targetUrl = targetPlugIn.plugInHookTagType.targetUrl;
192
- if (targetPlugIn.invocationType === 'sync') {
193
- targetUrl += '/recievePlugInRequestSync'
194
- }
195
- mainResult = await mainFunctionFlowStep(
196
- _izContext,
197
- {
198
- ...data,
199
- invokeType: targetPlugIn.invocationType, // Ensure this matches "sync" or "async"
200
- havePlugIn: true,
201
- targetUrl: targetUrl
202
- },
203
- appPath
204
- );
205
- } else {
206
- mainResult = await mainFunctionFlowStep(_izContext, { ...data, havePlugIn: false }, appPath);
207
- }
208
- allCreateSourceParams.push(mainResult);
209
- };
210
- }
211
- }
212
- } else {
213
- mainResult = await mainFunctionFlowStep(_izContext, { ...data, havePlugIn: false }, appPath);
214
- allCreateSourceParams.push(mainResult);
215
- };
216
135
 
217
- for (const objSchema of allObjSchemas) {
218
- if (!objSchema.hasOwnProperty("recievePlugInHookTag"))
219
- continue;
220
- for (const recieveConfig of Object.values(objSchema.recievePlugInHookTag)) {
221
- if (recieveConfig.hasOwnProperty('flowType')) {
222
- data['recieveType'] = "async",
223
- data['flowType'] = recieveConfig.flowType
224
- } else {
225
- data['recieveType'] = 'sync'
226
- }
227
- const yamlRecievePlugInResult = await yamlRecievePlugIn(_izContext, data, appPath);
228
- const handlerRecievePlugInResult = await handlerRecievePlugIn(_izContext, data, appPath);
229
- const mainFunctionRecievePlugInResult = await mainFunctionRecievePlugIn(_izContext, data, appPath);
230
- // console.log("mainFunctionRecievePlugInResult", mainFunctionRecievePlugInResult)
231
- allCreateSourceParams.push(...yamlRecievePlugInResult, ...handlerRecievePlugInResult, mainFunctionRecievePlugInResult);
136
+ // ── branch into the three helpers ──────────────────────────────────
137
+ if (flowStepConfig.plugInHooks?.length) {
138
+ for (let i = 0; i < flowStepConfig.plugInHooks.length; i++) {
139
+ if (i === 0) {
140
+ if (flowStepConfig.hasOwnProperty("settings")) {
141
+ data["handleLogic"] = flowStepConfig.settings.handleLogic;
142
+ data["childFlow"] = flowStepConfig.settings.flowType;
143
+ };
144
+ const firstResults = await buildFirstPluginHookResources(
145
+ _izContext,
146
+ data,
147
+ flowStepConfig,
148
+ appPath
149
+ );
150
+ allCreateSourceParams.push(...firstResults);
232
151
  }
152
+
153
+ const afterResults = await buildRecievePluginHookResource(
154
+ _izContext,
155
+ data,
156
+ appPath,
157
+ allObjSchemas
158
+ );
159
+ allCreateSourceParams.push(...afterResults);
233
160
  }
161
+ } else {
162
+ if (flowStepConfig.hasOwnProperty("settings")) {
163
+ data["handleLogic"] = flowStepConfig.settings.handleLogic;
164
+ data["childFlow"] = flowStepConfig.settings.flowType;
165
+ };
166
+
167
+ const noHookResults = await buildNoPluginHookResources(
168
+ _izContext,
169
+ data,
170
+ appPath
171
+ );
172
+ allCreateSourceParams.push(...noHookResults);
234
173
  }
235
- }
236
- };
237
174
 
175
+ if (flowStepConfig.hasOwnProperty("settings")) {
176
+ data["handleLogic"] = flowStepConfig.settings.handleLogic;
177
+ data["childFlow"] = flowStepConfig.settings.flowType;
178
+ data.event = resourceNames(
179
+ RESOURCE_CLASSES.sqs,
180
+ upperCase(flowSchema.flowTag) +
181
+ upperCase(flowStepName) +
182
+ upperCase(data.handleLogic) +
183
+ upperCase(data.handlerType)
184
+ )
185
+ const generateLambdaFlowStepByConfig = buildFlowStepResourceByConfig(
186
+ _izContext,
187
+ data,
188
+ appPath
189
+ );
190
+ allCreateSourceParams.push(...generateLambdaFlowStepByConfig);
191
+
192
+ }
193
+
194
+ }
195
+ }
238
196
 
239
197
 
240
198
  const uniqueSortedTargetFiles = Array.from(
@@ -264,3 +222,301 @@ async function generatePlunIg(
264
222
  }
265
223
 
266
224
  export default generatePlunIg;
225
+
226
+
227
+ async function buildNoPluginHookResources(_izContext, data, appPath) {
228
+ const results = [];
229
+
230
+
231
+ const yamlRes = await yamlFlowStep(
232
+ _izContext,
233
+ data,
234
+ appPath);
235
+ const handlerRes = await handlerFlowStep(
236
+ _izContext,
237
+ data,
238
+ appPath);
239
+
240
+ if (data.handlerType === HANDLER.hdrSqs || data.handlerType === HANDLER.hdrDsq) {
241
+ const sqsRes = await sqsFlowStep(
242
+ _izContext,
243
+ data,
244
+ appPath);
245
+ results.push(sqsRes);
246
+ }
247
+
248
+ // const snsOutRes = await snsOut(
249
+ // _izContext,
250
+ // data,
251
+ // appPath
252
+ // );
253
+
254
+ const mainRes = await mainFunctionFlowStep(
255
+ _izContext,
256
+ { ...data, havePlugIn: false }, appPath);
257
+
258
+ results.push(mainRes,
259
+ // snsOutRes,
260
+ yamlRes,
261
+ handlerRes);
262
+
263
+ return results;
264
+ }
265
+
266
+ async function buildFirstPluginHookResources(_izContext, data, flowStepConfig, appPath) {
267
+ const results = [];
268
+
269
+ const yamlRes = await yamlFlowStep(
270
+ _izContext,
271
+ data,
272
+ appPath);
273
+
274
+ const handlerRes = await handlerFlowStep(
275
+ _izContext,
276
+ data,
277
+ appPath);
278
+
279
+ results.push(yamlRes, handlerRes);
280
+
281
+ if (data.handlerType === HANDLER.hdrSqs ||
282
+ data.handlerType === HANDLER.hdrDsq) {
283
+ const sqsRes = await sqsFlowStep(
284
+ _izContext,
285
+ data,
286
+ appPath);
287
+ results.push(sqsRes);
288
+ }
289
+
290
+ const snsOutRes = await snsOut(
291
+ _izContext,
292
+ data,
293
+ appPath);
294
+ results.push(snsOutRes);
295
+
296
+ // Original: only the first plugInHook (index 0) creates the main function
297
+ const firstHook = flowStepConfig.plugInHooks[0];
298
+ const [objSchema] = await getLocalOrS3ObjectSchema(
299
+ _izContext,
300
+ firstHook.objType,
301
+ path.join(appPath, './src/schemas')
302
+ );
303
+
304
+ let mainData = { ...data, havePlugIn: false };
305
+
306
+ if (objSchema.hasOwnProperty('plugIns')) {
307
+ let targetPlugIn = null;
308
+ for (const plugInConfig of Object.values(objSchema.plugIns)) {
309
+ targetPlugIn = plugInConfig.plugInHooks.find(
310
+ h => h.plugInHookTagType.plugInHookTag === firstHook.plugInHookTag
311
+ );
312
+ if (targetPlugIn) break;
313
+ }
314
+
315
+ if (targetPlugIn) {
316
+ let targetUrl = targetPlugIn.plugInHookTagType.targetUrl;
317
+ if (targetPlugIn.invocationType === 'sync') {
318
+ targetUrl += '/recievePlugInRequestSync';
319
+ }
320
+ mainData = {
321
+ ...data,
322
+ havePlugIn: true,
323
+ invokeType: targetPlugIn.invocationType,
324
+ targetUrl,
325
+ };
326
+ }
327
+ }
328
+
329
+ const mainRes = await mainFunctionFlowStep(
330
+ _izContext,
331
+ mainData,
332
+ appPath);
333
+
334
+ results.push(mainRes);
335
+
336
+ return results;
337
+ }
338
+
339
+ async function buildRecievePluginHookResource(_izContext, data, appPath, allObjSchemas) {
340
+ const results = [];
341
+
342
+ for (const objSchema of allObjSchemas) {
343
+ if (!objSchema.hasOwnProperty("recievePlugInHookTag")) continue;
344
+
345
+ for (const recieveConfig of Object.values(objSchema.recievePlugInHookTag)) {
346
+ const localData = { ...data };
347
+
348
+ if (recieveConfig.hasOwnProperty('flowType')) {
349
+ localData.recieveType = "async";
350
+ localData.flowType = recieveConfig.flowType;
351
+ } else {
352
+ localData.recieveType = 'sync';
353
+ }
354
+
355
+ const yamlRecieveRes = await yamlRecievePlugIn(
356
+ _izContext,
357
+ localData,
358
+ appPath);
359
+ const handlerRecieveRes = await handlerRecievePlugIn(
360
+ _izContext,
361
+ localData,
362
+ appPath);
363
+ const mainRecieveRes = await mainFunctionRecievePlugIn(
364
+ _izContext,
365
+ localData,
366
+ appPath);
367
+
368
+ results.push(
369
+ ...yamlRecieveRes,
370
+ ...handlerRecieveRes,
371
+ mainRecieveRes
372
+ );
373
+ }
374
+ }
375
+
376
+ return results;
377
+ }
378
+
379
+ // Extracted from the original if/else chain — mutates data, additionalResourcePermission, resourceApis in place
380
+ function resolveHandlerConfig(data, flowStepConfig, additionalResourcePermission, resourceApis, serviceTag) {
381
+ const { flowTag, flowStepName } = data;
382
+ let handler;
383
+
384
+ if (flowStepConfig.event.includes("ownTopic")) {
385
+ data.eventFlow = 'ownTopic';
386
+ handler = HANDLER.hdrSqs;
387
+ additionalResourcePermission.push(
388
+ createSnsResource([upperCase(flowTag) +
389
+ upperCase(flowStepName) + "_In"]),
390
+ createSqsResource([
391
+ upperCase(flowTag) +
392
+ upperCase(flowStepName) +
393
+ upperCase(handler),
394
+ upperCase(flowTag) +
395
+ upperCase(flowStepName) +
396
+ upperCase(handler) + "DLQ",
397
+ ])
398
+ );
399
+ } else if (flowStepConfig.event.includes("extTopic")) {
400
+ data.eventFlow = 'extTopic';
401
+ handler = HANDLER.hdrSqs;
402
+ additionalResourcePermission.push(
403
+ createSqsResource([
404
+ upperCase(flowTag) +
405
+ upperCase(flowStepName) +
406
+ upperCase(handler),
407
+ upperCase(flowTag) +
408
+ upperCase(flowStepName) +
409
+ upperCase(handler) + "DLQ",
410
+ ])
411
+ );
412
+ } else if (flowStepConfig.event.includes("lambdaSyncInv")) {
413
+ handler = HANDLER.hdrInv;
414
+ } else if (flowStepConfig.event.includes("lambdaSyncApi")) {
415
+ handler = HANDLER.hdrApi;
416
+ resourceApis.push({
417
+ path: `${serviceTag}/${lowerCase(flowTag)}${lowerCase(flowStepName)}`,
418
+ pathWithUser: `${serviceTag}/${lowerCase(flowTag)}${lowerCase(flowStepName)}/{targetUserId}`,
419
+ method: 'post',
420
+ hookTagApp: `${upperCase(flowStepName)}${upperCase(handler)}AppLevelAuthorizer`,
421
+ hookTagUser: `${upperCase(flowStepName)}${upperCase(handler)}UserLevelAuthorizer`,
422
+ });
423
+ } else if (flowStepConfig.event.includes("queue")) {
424
+ handler = HANDLER.hdrDsq;
425
+ additionalResourcePermission.push(
426
+ createSqsResource([
427
+ upperCase(flowTag) +
428
+ upperCase(flowStepName) +
429
+ upperCase(handler),
430
+ upperCase(flowTag) +
431
+ upperCase(flowStepName) +
432
+ upperCase(handler) +
433
+ "DSQ",
434
+ ])
435
+ );
436
+ }
437
+
438
+ if (flowStepConfig.hasOwnProperty("settings")) {
439
+ if (flowStepConfig.settings.hasOwnProperty("handleLogic")) {
440
+ const handleLogic = flowStepConfig.settings.handleLogic;
441
+ const childFlow = flowStepConfig.settings.flowType;
442
+ if (handleLogic === 'awaitingMultipleSteps') {
443
+ handler = HANDLER.hdrSqs;
444
+ additionalResourcePermission.push(awaitingMultipleStepsRole())
445
+ additionalResourcePermission.push(createIamRole({
446
+ [RESOURCE_CLASSES.sns]: Object.values(SNS_RESOURCE)
447
+ },
448
+ [
449
+ externalResourceYaml(
450
+ RESOURCE_CLASSES.sns,
451
+ `${childFlow.flowTag}_In`,
452
+ childFlow.serviceTag)
453
+ ]
454
+ ))
455
+ } else if (handleLogic === 'paginated') {
456
+ handler = HANDLER.hdrSqs;
457
+ additionalResourcePermission.push(createSqsResource(
458
+ [
459
+ upperCase(flowTag) +
460
+ upperCase(flowStepName) +
461
+ upperCase(HANDLER.hdrDsq),
462
+ upperCase(flowTag) +
463
+ upperCase(flowStepName) +
464
+ upperCase(HANDLER.hdrDsq) + "DLQ"
465
+ ]))
466
+ }
467
+ }
468
+ }
469
+ data.handlerType = handler;
470
+ }
471
+
472
+ function buildFlowStepResourceByConfig(_izContext, data, appPath) {
473
+ const results = [];
474
+
475
+ if (data.handleLogic === 'awaitingMultipleSteps') {
476
+ data.handlerType = HANDLER.hdrSqs
477
+ } else if (data.handleLogic === 'paginated') {
478
+ data.handlerType = HANDLER.hdrDsq
479
+ }
480
+
481
+ data["functionName"] = upperCase(data.flowTag) +
482
+ upperCase(data.flowStepName) +
483
+ upperCase(data.handleLogic)
484
+
485
+ data["functionNameConfig"] = upperCase(data.flowTag) +
486
+ upperCase(data.flowStepName) +
487
+ upperCase(data.handleLogic) +
488
+ upperCase(data.handlerType)
489
+
490
+ const handler = handlerFlowConfig(
491
+ _izContext,
492
+ data,
493
+ appPath
494
+ );
495
+
496
+ const mainFunction = mainFunctionFlowConfig(
497
+ _izContext,
498
+ data,
499
+ appPath
500
+ );
501
+
502
+ const sqs = sqsFlowConfig(
503
+ _izContext,
504
+ data,
505
+ appPath
506
+ );
507
+
508
+ const yaml = yamlFlowConfig(
509
+ _izContext,
510
+ data,
511
+ appPath
512
+ );
513
+
514
+ results.push(
515
+ handler,
516
+ mainFunction,
517
+ sqs,
518
+ yaml
519
+ );
520
+
521
+ return results;
522
+ }
@@ -212,6 +212,28 @@ async function createExternalLambdaRole(
212
212
  });
213
213
  }
214
214
  }
215
+
216
+ for (const flowStepConfig of Object.values(localFlowSchema.flowSteps)) {
217
+ if (flowStepConfig.hasOwnProperty("settings")) {
218
+ if (flowStepConfig.settings.hasOwnProperty('flowType')) {
219
+ roleArray.push({
220
+ objectType: localFlowSchema.flowTag,
221
+ additionalResourcePermission: [
222
+ role(
223
+ sns,
224
+ SNS_RESOURCE.publish,
225
+ [
226
+ extRes(
227
+ sns,
228
+ `${flowStepConfig.settings.flowType.flowTag}_In`,
229
+ flowStepConfig.settings.flowType.serviceTag)
230
+ ]
231
+ )
232
+ ]
233
+ });
234
+ }
235
+ }
236
+ }
215
237
  }
216
238
  }
217
239
 
@@ -122,6 +122,22 @@ async function createExternalSnsSubscriptions(
122
122
  }
123
123
  );
124
124
  }
125
+
126
+ for (const localFlowSchema of allLocalFlowSchemas) {
127
+ for (const [flowStepName, flowStepConfig] of Object.entries(localFlowSchema.flowSteps)) {
128
+ if (flowStepConfig.hasOwnProperty('settings') && flowStepConfig.settings.hasOwnProperty('flowType')) {
129
+ if (flowStepConfig.settings.flowType) {
130
+ snsServiceConfigArray.push({
131
+ serviceTag: [flowStepConfig.settings.flowType.serviceTag],
132
+ topicName: `${flowStepConfig.settings.flowType.flowTag}_Out`,
133
+ sqsEndpoint: upperCase(localFlowSchema.flowTag) +
134
+ upperCase(flowStepName) +
135
+ upperCase(flowStepConfig.settings.handleLogic)
136
+ })
137
+ }
138
+ }
139
+ }
140
+ }
125
141
  }
126
142
 
127
143
  return {