@izara_project/izara-core-generate-service-code 1.0.47 → 1.0.49

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.47",
3
+ "version": "1.0.49",
4
4
  "description": "Code for locally generating per service files",
5
5
  "homepage": "https://bitbucket.org/izara-core-support-services/izara-core-support-services-generate-service-code#readme",
6
6
  "repository": {
@@ -23,8 +23,8 @@ const __dirname = path.dirname(__filename);
23
23
  import { getObjectSchema } from '@izara_project/izara-core-library-service-schemas';
24
24
  import util from '#libs/Utils.js';
25
25
  import consts from '#libs/Consts.js';
26
- import intTestLibs from '#libs/Libs.js';
27
- const { directoryPath } = intTestLibs;
26
+ import libs from '../libs/libs';
27
+ const { directoryPath } = libs;
28
28
  const { getLocalConfig } = util;
29
29
  const templatePath = path.join(__dirname, './templateResources.ejs');
30
30
 
@@ -23,7 +23,7 @@ const templatePath = path.join(__dirname, './templateEvents.ejs');
23
23
  import utils from '#libs/Utils.js';
24
24
  const { getLocalConfig } = utils;
25
25
 
26
- import libs from '#libs/Libs.js';
26
+ import libs from '../../libs/libs';
27
27
  const {
28
28
  setEvent,
29
29
  createEventCaseByHandler,
@@ -20,7 +20,7 @@ import generateEvent from './events/events.js';
20
20
  import generateTest from './tests/tests.js';
21
21
  import generatePathIntTest from './pathIntTest/pathIntTest.js';
22
22
  // import generateBashScript from './bashScript/data.js'
23
- import libs from '#libs/Libs.js';
23
+ import libs from '../libs/libs.js';
24
24
  const { getIntTestConfig } = libs;
25
25
  import utils from '#libs/Utils.js';
26
26
  const { getLocalConfig } = utils;
@@ -40,7 +40,7 @@ async function generateCodeWithTemplate(_izContext, savePath, settings) {
40
40
  // console.log("oo:", process.env.iz_resourcePrefix);
41
41
  let allIntTestConfig = await getIntTestConfig(
42
42
  _izContext,
43
- join(savePath, './libs/')
43
+ 'generateIntegrationTest/libs/'
44
44
  );
45
45
  // console.log({ settings })
46
46
  const event = await generateEvent(_izContext, allIntTestConfig, savePath);
@@ -24,7 +24,7 @@ const templatePath = path.join(__dirname, './templateTests.ejs');
24
24
  import utils from '#libs/Utils.js';
25
25
  const { getLocalConfig } = utils;
26
26
 
27
- import libs from '#libs/Libs.js';
27
+ import libs from '../../libs/libs';
28
28
  const {
29
29
  createTestFunctionName,
30
30
  getHandlerFromEventTag,
@@ -10,44 +10,51 @@ function lowercaseFirst(str) {
10
10
  return str[0].toLowerCase() + str.slice(1);
11
11
  }
12
12
 
13
- function directoryPath(dirPath) {
14
- let result = [];
13
+ function directoryPath(dirPath, result = []) {
14
+ if (!fs.existsSync(dirPath)) return {};
15
15
  const items = fs.readdirSync(dirPath);
16
+
16
17
  for (let item of items) {
17
18
  const fullPath = path.join(dirPath, item);
18
19
  const stat = fs.statSync(fullPath);
19
20
 
20
21
  if (stat.isDirectory()) {
21
- directoryPath(fullPath, result); // recursion
22
+ directoryPath(fullPath, result); // ✅ ใช้ result เดียวกัน
22
23
  } else if (stat.isFile()) {
23
24
  if (
24
- !fullPath.includes('shared-resource.yml') &&
25
- !fullPath.includes('core-function.yml')
25
+ !fullPath.includes("shared-resource.yml") &&
26
+ !fullPath.includes("core-function.yml")
26
27
  ) {
27
- if (fullPath.endsWith('.yml')) {
28
+ if (fullPath.endsWith(".yml")) {
28
29
  result.push(fullPath);
29
30
  } else {
30
- console.log('Skipped File:', fullPath);
31
+ console.log("Skipped File:", fullPath);
31
32
  }
32
33
  }
33
34
  }
34
35
  }
35
36
 
36
37
  let functionComponent = {};
38
+
37
39
  for (let ymlFilesPath of result) {
38
- const fileContent = fs.readFileSync(ymlFilesPath, 'utf8');
40
+ const fileContent = fs.readFileSync(ymlFilesPath, "utf8");
39
41
  const parsedYaml = yaml.parse(fileContent);
42
+
40
43
  for (const component of Object.values(parsedYaml)) {
41
44
  if (component.handler && component.name) {
42
45
  const clearName = component.name.replace(
43
- '${self:custom.iz_resourcePrefix}',
44
- ''
46
+ "${self:custom.iz_resourcePrefix}",
47
+ ""
45
48
  );
46
- const clearMain = component.handler.replace(/\.main$/, '');
47
- Object.assign(functionComponent, { [clearName]: clearMain });
49
+ const clearMain = component.handler.replace(/\.main$/, "");
50
+
51
+ Object.assign(functionComponent, {
52
+ [clearName]: clearMain,
53
+ });
48
54
  }
49
55
  }
50
56
  }
57
+
51
58
  return functionComponent;
52
59
  }
53
60
 
@@ -386,10 +393,11 @@ function createResourceName(eventTag) {
386
393
  }
387
394
 
388
395
  async function getIntTestConfig(_izContext, intTestPath) {
389
- return await getDataFromPath(
396
+ return await getObjectSchema.getDataFromPath(
390
397
  _izContext,
391
- 'GenerateIntegrationTestConfig.js',
392
- intTestPath
398
+ intTestPath, // :white_check_mark: ใช้ relative
399
+ path.join(process.cwd(), 'src/'), // :white_check_mark: root ที่ถูก
400
+ { exceptFileName: 'saveConfig' }
393
401
  );
394
402
  }
395
403
 
@@ -427,5 +435,6 @@ export default {
427
435
  getHandlerFromTestTag,
428
436
  createResourceName,
429
437
  setInvokeTest,
430
- getIntTestConfig
438
+ getIntTestConfig,
439
+ buildInvokeStages
431
440
  };
@@ -204,15 +204,17 @@ export async function createMainLogical(
204
204
  createObjInstanceFullFieldsByStorageTag(_izContext, storageTag, createDataDetail));
205
205
  _izContext.logger.debug('objInstanceFull before send to Graph', objInstanceFullForGraph);
206
206
 
207
+ //(<additionalAttributeCreateNode>)
208
+ const additionalAttributes = {};
209
+ //(</additionalAttributeCreateNode>)
210
+
207
211
  const records = allAwaitingStepsId.length === 0 ? listOfRecords : [];
208
212
  allAwaitingStepsId.push({
209
213
  awaitingStepId: await asyncFlowSharedLib.createAwaitingStepId(
210
214
  parentFlowId,
211
215
  PREFIX.CREATE_OBJECT_ASYNC
212
216
  ),
213
- //(<additionalAttributeCreateNode>)
214
- additionalAttributes: { listOfRecords: records }
215
- //(</additionalAttributeCreateNode>)
217
+ additionalAttributes: { listOfRecords: records ,additionalAttributes: additionalAttributes}
216
218
  });
217
219
 
218
220
  listOfObjectForCreates.push({
@@ -239,9 +241,7 @@ export async function createMainLogical(
239
241
  parentFlowId,
240
242
  PREFIX.CREATE_OBJECT_EXTERNAL_TOPIC
241
243
  ),
242
- //(<additionalAttributeCreateExternalTopic>)
243
244
  additionalAttributes: {}
244
- //(</additionalAttributeCreateExternalTopic>)
245
245
  });
246
246
 
247
247
  Object.assign(objInstanceFullForExternalTopic, { parentFlowId: parentFlowId });
@@ -260,7 +260,7 @@ export async function createMainLogical(
260
260
  _izContext,
261
261
  allAwaitingStepsId,
262
262
  asyncFlowSharedLib.createPendingStepId(
263
- hash({ objType, identifiers: objInstanceFull.identifiers }),
263
+ _izContext.uniqueRequestId,
264
264
  PREFIX.CREATE_OBJECT_ASYNC_COMPLETE
265
265
  )
266
266
  );
@@ -326,7 +326,7 @@ export async function createMainLogical(
326
326
  await asyncFlowSharedLib.clearAllAwaitingSteps(
327
327
  _izContext,
328
328
  asyncFlowSharedLib.createPendingStepId(
329
- hash({ objType, identifiers: objInstanceFull.identifiers }),
329
+ _izContext.uniqueRequestId,
330
330
  PREFIX.CREATE_OBJECT_ASYNC_COMPLETE
331
331
  )
332
332
  );
@@ -610,7 +610,7 @@ export default async function createMain(
610
610
  _izContext,
611
611
  awaitingMultipleStepIds,
612
612
  asyncFlowSharedLib.createPendingStepId(
613
- hash(objInstanceFull.identifiers),
613
+ _izContext.uniqueRequestId,
614
614
  'beforeLogical_<%= objectType %>'
615
615
  )
616
616
  );
@@ -187,6 +187,10 @@ export async function updateMainLogical(
187
187
  //(<beforeUpdateNode>)
188
188
  //(</beforeUpdateNode>)
189
189
 
190
+ //(<additionalAttributes>)
191
+ const additionalAttributes = {}
192
+ //(</additionalAttributes>)
193
+
190
194
 
191
195
  records = awaitingStepIds.lenght === 0 ? listOfRecords : [];
192
196
  awaitingStepIds.push({
@@ -194,16 +198,14 @@ export async function updateMainLogical(
194
198
  parentFlowId,
195
199
  PREFIX.updateNode
196
200
  ),
197
- //(<additionalAttributes>)
198
- additionalAttributes: { listOfRecords: records }
199
- //(</additionalAttributes>)
201
+ additionalAttributes: { listOfRecords: records, additionalAttributes: additionalAttributes }
200
202
  });
201
203
 
202
204
  if (awaitingStepIds.length) {
203
205
  const awaitingMultipleStep = await asyncFlowSharedLib.createAwaitingMultipleStepsWithAdditionalAttributes(
204
206
  _izContext,
205
207
  awaitingStepIds,
206
- asyncFlowSharedLib.createPendingStepId(hash({ identifiers, fields }))
208
+ asyncFlowSharedLib.createPendingStepId(_izContext.uniqueRequestId)
207
209
  );
208
210
  _izContext.logger.debug('awaitingMultipleStep', awaitingMultipleStep);
209
211
  }
@@ -444,7 +446,7 @@ export default async function updateMain(
444
446
  _izContext,
445
447
  awaitingMultipleStepIds,
446
448
  asyncFlowSharedLib.createPendingStepId(
447
- hash(identifiers),
449
+ _izContext.uniqueRequestId,
448
450
  'beforeLogical_<%= objectType %>'
449
451
  )
450
452
  );
@@ -286,7 +286,7 @@ export default async function createObjectComplete(
286
286
  await asyncFlowSharedLib.removeAwaitingMultipleStep(
287
287
  _izContext,
288
288
  awaitingStepId,
289
- pendingStepId,
289
+ recordAwaitingStep.pendingStepId,
290
290
  errorsFound,
291
291
  );
292
292
  }),
@@ -316,15 +316,7 @@ export default async function <%- functionName %> (
316
316
  _izContext,
317
317
  awaitingStepIds, // awaitingStepIds
318
318
  asyncFlowSharedLib.createPendingStepId( // pendingStepId
319
- hash({
320
- linkTypeId,
321
- correlationId: _izContext.correlationIds.get("id"),
322
- callingFlowProperties: callingFlowConfig.callingFlowProperties || {},
323
- firstObject,
324
- secondObject,
325
- oldRelTypeAndDirection,
326
- newRelType,
327
- }), // hash id
319
+ _izContext.uniqueRequestId, // hash id
328
320
  PREFIX.changeRel // prefix, use constant further
329
321
  )
330
322
  );
@@ -337,15 +337,7 @@ export default async function createRelationship(
337
337
  _izContext,
338
338
  awaitingStepIds, // awaitingStepIds
339
339
  asyncFlowSharedLib.createPendingStepId( // pendingStepId
340
- hash({
341
- linkTypeId,
342
- relationshipProperties,
343
- correlationId: _izContext.correlationIds.get("id"),
344
- callingFlowProperties: callingFlowConfig.callingFlowProperties || {},
345
- firstObject: firstObject,
346
- secondObject: secondObject,
347
- relType: relType
348
- }), // hash id
340
+ _izContext.uniqueRequestId, // hash id
349
341
  PREFIX.createRel // prefix, use constant further
350
342
  )
351
343
  );
@@ -268,7 +268,7 @@ export default async function deleteRelationship(
268
268
  _izContext,
269
269
  awaitingStepIds, // awaitingStepIds
270
270
  asyncFlowSharedLib.createPendingStepId( // pendingStepId
271
- hash({ linkTypeId, correlationId: _izContext.correlationIds.get("id") }), // hash id
271
+ _izContext.uniqueRequestId, // hash id
272
272
  PREFIX.deleteRel // prefix, use constant further
273
273
  )
274
274
  );
@@ -308,17 +308,7 @@ export default async function moveRelationship(
308
308
  _izContext,
309
309
  awaitingStepIds, // awaitingStepIds
310
310
  asyncFlowSharedLib.createPendingStepId( // pendingStepId
311
- hash({
312
- linkTypeId,
313
- correlationId: _izContext.correlationIds.get("id"),
314
- callingFlowProperties: callingFlowConfig.callingFlowProperties || {},
315
- firstObject,
316
- secondObject,
317
- relType,
318
- relationshipDirection,
319
- relationshipProperties,
320
- moveObject
321
- }), // hash id
311
+ _izContext.uniqueRequestId, // hash id
322
312
  PREFIX.changeRel // prefix, use constant further
323
313
  )
324
314
  );
@@ -314,7 +314,7 @@ export default async function updateRelationship(
314
314
  _izContext,
315
315
  awaitingStepIds, // awaitingStepIds
316
316
  asyncFlowSharedLib.createPendingStepId( // pendingStepId
317
- hash({ linkTypeId, relId, relationshipProperties, correlationId: _izContext.correlationIds.get("id") }), // hash id
317
+ _izContext.uniqueRequestId, // hash id
318
318
  PREFIX.updateRel // prefix, use constant further
319
319
  )
320
320
  );
@@ -14,20 +14,7 @@ await asyncFlowSharedLib.createAwaitingMultipleStepsWithAdditionalAttributes(
14
14
  _izContext,
15
15
  allAwaitingStepsId,
16
16
  asyncFlowSharedLib.createPendingStepId(
17
- hash({
18
- <% if (mainObjType) { -%>
19
- objType: {
20
- serviceTag: "<%- mainObjType.serviceTag %>",
21
- objectType: "<%- mainObjType.objectType %>"
22
- },
23
- //(<createPendingStepIds>)
24
- //(</createPendingStepIds>)
25
- <% } else { -%>
26
- xCorrelationId: _izContext.correlationIds.xCorrelationId,
27
- //(<createPendingStepIds>)
28
- //(</createPendingStepIds>)
29
- <% } %>
30
- }),
17
+ _izContext.awsRequestId,
31
18
  "<%- upperFlowTag %><%- upperFlowStepName %><%- upperHandleLogic %>"
32
19
  )
33
20
  );
@@ -52,6 +39,3 @@ await asyncFlowSharedLib.createAwaitingMultipleStepsWithAdditionalAttributes(
52
39
  )
53
40
  )
54
41
  );
55
-
56
-
57
-
@@ -20,7 +20,8 @@ import fs from 'fs';
20
20
  import yaml from 'yaml';
21
21
  import libs from '#libs/Libs.js';
22
22
  import utils from '#libs/Utils.js';
23
- const { firstLetterUpperCase: upperCase, firstLetterLowerCase: lowerCase } = utils;
23
+ const { firstLetterUpperCase: upperCase, firstLetterLowerCase: lowerCase } =
24
+ utils;
24
25
  import consts from '#libs/Consts.js';
25
26
  const { SOURCE_PATH, HANDLER, RESOURCE_CLASSES, SNS_RESOURCE } = consts;
26
27
 
@@ -54,7 +55,6 @@ const {
54
55
  // import handlerSendPlugIn from './afterFirstFlowStep/sendPlugIn/handler/handler.js';
55
56
  // import mainFunctionSendPlugIn from './afterFirstFlowStep/sendPlugIn/mainFunction/main.js';
56
57
 
57
-
58
58
  /**
59
59
  * Generates code from templates based on object schemas
60
60
  * @param {Object} _izContext
@@ -69,7 +69,7 @@ async function generatePlunIg(
69
69
  rootServicePath,
70
70
  appPath,
71
71
  allObjSchemas,
72
- allLocalFlowSchemas,
72
+ allLocalFlowSchemas
73
73
  ) {
74
74
  const allCreateSourceParams = [];
75
75
 
@@ -79,18 +79,22 @@ async function generatePlunIg(
79
79
  ? allObjSchemas.length
80
80
  : 0;
81
81
 
82
-
83
82
  console.info(`[plugIn] start totalSchemas=${totalSchemas}`);
84
83
  if (totalSchemas === 0) return [];
85
84
 
86
- const configPath = path.join(rootServicePath, 'config/serverless.config.yml');
85
+ const configPath = path.join(
86
+ rootServicePath,
87
+ 'config/serverless.config.yml'
88
+ );
87
89
  const serverlessConfig = fs.readFileSync(configPath, 'utf8');
88
90
  const config = yaml.parse(serverlessConfig);
89
91
  const serviceTag = config.main_config.iz_serviceTag;
90
92
 
91
93
  for (const flowSchema of allLocalFlowSchemas) {
92
- for (const [flowStepName, flowStepConfig] of Object.entries(flowSchema.flowSteps)) {
93
- if (flowStepName === "In" || flowStepName === "Out") continue;
94
+ for (const [flowStepName, flowStepConfig] of Object.entries(
95
+ flowSchema.flowSteps
96
+ )) {
97
+ if (flowStepName === 'In' || flowStepName === 'Out') continue;
94
98
 
95
99
  const flowTag = flowSchema.flowTag;
96
100
  const roleName = upperCase(flowTag);
@@ -102,9 +106,9 @@ async function generatePlunIg(
102
106
  flowStepName,
103
107
  flowTag,
104
108
  resourceApis,
105
- hookTagSetting: `${flowSchema.flowTag}FunctionSetting`,
109
+ hookTagSetting: `${flowSchema.flowTag}${upperCase(flowStepName)}FunctionSetting`,
106
110
  functionName: upperCase(flowSchema.flowTag) + upperCase(flowStepName),
107
- roleName,
111
+ roleName
108
112
  };
109
113
 
110
114
  resolveHandlerConfig(
@@ -123,21 +127,25 @@ async function generatePlunIg(
123
127
  upperCase(flowSchema.flowTag),
124
128
  upperCase(flowStepName),
125
129
  'source/',
126
- `${upperCase(flowTag)}${upperCase(flowStepName)}_${upperCase(data.handlerType)}`,
130
+ `${upperCase(flowTag)}${upperCase(flowStepName)}_${upperCase(data.handlerType)}`
127
131
  ),
128
- functionNameConfig: upperCase(flowSchema.flowTag) +
132
+ functionNameConfig:
133
+ upperCase(flowSchema.flowTag) +
129
134
  upperCase(flowStepName) +
130
135
  upperCase(data.handlerType),
131
136
  event: resourceNames(
132
137
  RESOURCE_CLASSES.sqs,
133
138
  upperCase(flowSchema.flowTag) +
134
139
  upperCase(flowStepName) +
135
- upperCase(data.handlerType)),
136
- queueName: upperCase(flowSchema.flowTag) + upperCase(flowStepName) + upperCase(data.handlerType),
140
+ upperCase(data.handlerType)
141
+ ),
142
+ queueName:
143
+ upperCase(flowSchema.flowTag) +
144
+ upperCase(flowStepName) +
145
+ upperCase(data.handlerType),
137
146
  topicName: upperCase(flowSchema.flowTag) + upperCase(flowStepName)
138
147
  });
139
148
 
140
-
141
149
  // ── branch into the three helpers ──────────────────────────────────
142
150
  if (flowStepConfig.plugInHooks?.length) {
143
151
  for (let i = 0; i < flowStepConfig.plugInHooks.length; i++) {
@@ -169,29 +177,26 @@ async function generatePlunIg(
169
177
  allCreateSourceParams.push(...noHookResults);
170
178
  }
171
179
 
172
- if (flowStepConfig.hasOwnProperty("settings")) {
173
- data["handleLogic"] = flowStepConfig.settings.handleLogic;
174
- data["childFlow"] = flowStepConfig.settings.flowType;
180
+ if (flowStepConfig.hasOwnProperty('settings')) {
181
+ data['handleLogic'] = flowStepConfig.settings.handleLogic;
182
+ data['childFlow'] = flowStepConfig.settings.flowType;
175
183
  data.event = resourceNames(
176
184
  RESOURCE_CLASSES.sqs,
177
185
  upperCase(flowSchema.flowTag) +
178
186
  upperCase(flowStepName) +
179
187
  upperCase(data.handleLogic) +
180
188
  upperCase(data.handlerType)
181
- )
189
+ );
182
190
  const generateLambdaFlowStepByConfig = buildFlowStepResourceByConfig(
183
191
  _izContext,
184
192
  data,
185
193
  appPath
186
194
  );
187
195
  allCreateSourceParams.push(...generateLambdaFlowStepByConfig);
188
-
189
196
  }
190
-
191
197
  }
192
198
  }
193
199
 
194
-
195
200
  const uniqueSortedTargetFiles = Array.from(
196
201
  new Set(
197
202
  allCreateSourceParams
@@ -220,24 +225,22 @@ async function generatePlunIg(
220
225
 
221
226
  export default generatePlunIg;
222
227
 
223
-
224
- async function buildNoPluginHookResources(_izContext, data, flowStepConfig, appPath) {
228
+ async function buildNoPluginHookResources(
229
+ _izContext,
230
+ data,
231
+ flowStepConfig,
232
+ appPath
233
+ ) {
225
234
  const results = [];
226
235
 
227
- const yamlRes = await yamlFlowStep(
228
- _izContext,
229
- data,
230
- appPath);
231
- const handlerRes = await handlerFlowStep(
232
- _izContext,
233
- data,
234
- appPath);
235
-
236
- if (data.handlerType === HANDLER.hdrSqs || data.handlerType === HANDLER.hdrDsq) {
237
- const sqsRes = await sqsFlowStep(
238
- _izContext,
239
- data,
240
- appPath);
236
+ const yamlRes = await yamlFlowStep(_izContext, data, appPath);
237
+ const handlerRes = await handlerFlowStep(_izContext, data, appPath);
238
+
239
+ if (
240
+ data.handlerType === HANDLER.hdrSqs ||
241
+ data.handlerType === HANDLER.hdrDsq
242
+ ) {
243
+ const sqsRes = await sqsFlowStep(_izContext, data, appPath);
241
244
  results.push(sqsRes);
242
245
  }
243
246
 
@@ -257,51 +260,52 @@ async function buildNoPluginHookResources(_izContext, data, flowStepConfig, appP
257
260
  appPath
258
261
  );
259
262
 
260
- results.push(mainRes,
263
+ results.push(
264
+ mainRes,
261
265
  // snsOutRes,
262
266
  yamlRes,
263
- handlerRes);
267
+ handlerRes
268
+ );
264
269
 
265
270
  return results;
266
271
  }
267
272
 
268
- async function buildFirstPluginHookResources(_izContext, data, flowStepConfig, appPath) {
273
+ async function buildFirstPluginHookResources(
274
+ _izContext,
275
+ data,
276
+ flowStepConfig,
277
+ appPath
278
+ ) {
269
279
  const results = [];
270
280
 
271
- const yamlRes = await yamlFlowStep(
272
- _izContext,
273
- data,
274
- appPath);
281
+ const yamlRes = await yamlFlowStep(_izContext, data, appPath);
275
282
 
276
- const handlerRes = await handlerFlowStep(
277
- _izContext,
278
- data,
279
- appPath);
283
+ const handlerRes = await handlerFlowStep(_izContext, data, appPath);
280
284
 
281
285
  results.push(yamlRes, handlerRes);
282
286
 
283
- if (data.handlerType === HANDLER.hdrSqs ||
284
- data.handlerType === HANDLER.hdrDsq) {
285
- const sqsRes = await sqsFlowStep(
286
- _izContext,
287
- data,
288
- appPath);
287
+ if (
288
+ data.handlerType === HANDLER.hdrSqs ||
289
+ data.handlerType === HANDLER.hdrDsq
290
+ ) {
291
+ const sqsRes = await sqsFlowStep(_izContext, data, appPath);
289
292
  results.push(sqsRes);
290
293
  }
291
294
 
292
- const snsOutRes = await snsOut(
293
- _izContext,
294
- data,
295
- appPath);
295
+ const snsOutRes = await snsOut(_izContext, data, appPath);
296
296
  results.push(snsOutRes);
297
297
 
298
298
  // Original: only the first plugInHook (index 0) creates the main function
299
299
  const firstHook = flowStepConfig.plugInHooks[0];
300
- const [objSchema] = await getLocalOrS3ObjectSchema(
300
+ const [objSchema, error] = await getLocalOrS3ObjectSchema(
301
301
  _izContext,
302
302
  firstHook.objType,
303
303
  path.join(appPath, './src/schemas')
304
304
  );
305
+ if (error) {
306
+ console.error('[plugIn] error:', error);
307
+ throw new NoRetryError(error);
308
+ }
305
309
 
306
310
  let mainData = { ...data, havePlugIn: false };
307
311
 
@@ -329,27 +333,29 @@ async function buildFirstPluginHookResources(_izContext, data, flowStepConfig, a
329
333
  }
330
334
  }
331
335
 
332
- const mainRes = await mainFunctionFlowStep(
333
- _izContext,
334
- mainData,
335
- appPath);
336
+ const mainRes = await mainFunctionFlowStep(_izContext, mainData, appPath);
336
337
 
337
338
  results.push(mainRes);
338
339
 
339
340
  return results;
340
341
  }
341
342
 
342
- async function buildRecievePluginHookResource(_izContext, data, appPath, allObjSchemas) {
343
+ async function buildRecievePluginHookResource(
344
+ _izContext,
345
+ data,
346
+ appPath,
347
+ allObjSchemas
348
+ ) {
343
349
  const results = [];
344
350
 
345
351
  for (const objSchema of allObjSchemas) {
346
- if (!objSchema.hasOwnProperty("recievePlugInHookTag")) continue;
352
+ if (!objSchema.hasOwnProperty('recievePlugInHookTag')) continue;
347
353
 
348
354
  for (const recieveConfig of Object.values(objSchema.recievePlugInHookTag)) {
349
355
  const localData = { ...data };
350
356
 
351
357
  if (recieveConfig.hasOwnProperty('flowType')) {
352
- localData.recieveType = "async";
358
+ localData.recieveType = 'async';
353
359
  localData.flowType = recieveConfig.flowType;
354
360
  } else {
355
361
  localData.recieveType = 'sync';
@@ -358,21 +364,20 @@ async function buildRecievePluginHookResource(_izContext, data, appPath, allObjS
358
364
  const yamlRecieveRes = await yamlRecievePlugIn(
359
365
  _izContext,
360
366
  localData,
361
- appPath);
367
+ appPath
368
+ );
362
369
  const handlerRecieveRes = await handlerRecievePlugIn(
363
370
  _izContext,
364
371
  localData,
365
- appPath);
372
+ appPath
373
+ );
366
374
  const mainRecieveRes = await mainFunctionRecievePlugIn(
367
375
  _izContext,
368
376
  localData,
369
- appPath);
370
-
371
- results.push(
372
- ...yamlRecieveRes,
373
- ...handlerRecieveRes,
374
- mainRecieveRes
377
+ appPath
375
378
  );
379
+
380
+ results.push(...yamlRecieveRes, ...handlerRecieveRes, mainRecieveRes);
376
381
  }
377
382
  }
378
383
 
@@ -380,74 +385,76 @@ async function buildRecievePluginHookResource(_izContext, data, appPath, allObjS
380
385
  }
381
386
 
382
387
  // Extracted from the original if/else chain — mutates data, additionalResourcePermission, resourceApis in place
383
- function resolveHandlerConfig(data, flowStepConfig, additionalResourcePermission, resourceApis, serviceTag, fallbackEvent = []) {
388
+ function resolveHandlerConfig(
389
+ data,
390
+ flowStepConfig,
391
+ additionalResourcePermission,
392
+ resourceApis,
393
+ serviceTag,
394
+ fallbackEvent = []
395
+ ) {
384
396
  const { flowTag, flowStepName } = data;
385
397
  let handler;
386
398
  const events = flowStepConfig.event || fallbackEvent || [];
387
399
 
388
- if (events.includes("ownTopic")) {
400
+ if (events.includes('ownTopic')) {
389
401
  data.eventFlow = 'ownTopic';
390
402
  handler = HANDLER.hdrSqs;
391
403
  additionalResourcePermission.push(
392
- createSnsResource([upperCase(flowTag) +
393
- upperCase(flowStepName) + "_In"]),
404
+ createSnsResource([upperCase(flowTag) + upperCase(flowStepName) + '_In']),
394
405
  createSqsResource([
406
+ upperCase(flowTag) + upperCase(flowStepName) + upperCase(handler),
395
407
  upperCase(flowTag) +
396
408
  upperCase(flowStepName) +
397
- upperCase(handler),
398
- upperCase(flowTag) +
399
- upperCase(flowStepName) +
400
- upperCase(handler) + "DLQ",
409
+ upperCase(handler) +
410
+ 'DLQ'
401
411
  ])
402
412
  );
403
- } else if (events.includes("extTopic")) {
413
+ } else if (events.includes('extTopic')) {
404
414
  data.eventFlow = 'extTopic';
405
415
  handler = HANDLER.hdrSqs;
406
416
  additionalResourcePermission.push(
407
417
  createSqsResource([
418
+ upperCase(flowTag) + upperCase(flowStepName) + upperCase(handler),
408
419
  upperCase(flowTag) +
409
420
  upperCase(flowStepName) +
410
- upperCase(handler),
411
- upperCase(flowTag) +
412
- upperCase(flowStepName) +
413
- upperCase(handler) + "DLQ",
421
+ upperCase(handler) +
422
+ 'DLQ'
414
423
  ])
415
424
  );
416
- } else if (events.includes("lambdaSyncInv")) {
425
+ } else if (events.includes('lambdaSyncInv')) {
417
426
  handler = HANDLER.hdrInv;
418
- } else if (events.includes("lambdaSyncApi")) {
427
+ } else if (events.includes('lambdaSyncApi')) {
419
428
  handler = HANDLER.hdrApi;
420
429
  resourceApis.push({
421
430
  path: `${serviceTag}/${lowerCase(flowTag)}${lowerCase(flowStepName)}`,
422
431
  pathWithUser: `${serviceTag}/${lowerCase(flowTag)}${lowerCase(flowStepName)}/{targetUserId}`,
423
432
  method: 'post',
424
433
  hookTagApp: `${upperCase(flowStepName)}${upperCase(handler)}AppLevelAuthorizer`,
425
- hookTagUser: `${upperCase(flowStepName)}${upperCase(handler)}UserLevelAuthorizer`,
434
+ hookTagUser: `${upperCase(flowStepName)}${upperCase(handler)}UserLevelAuthorizer`
426
435
  });
427
- } else if (events.includes("queue")) {
436
+ } else if (events.includes('queue')) {
428
437
  handler = HANDLER.hdrDsq;
429
438
  additionalResourcePermission.push(
430
439
  createSqsResource([
431
- upperCase(flowTag) +
432
- upperCase(flowStepName) +
433
- upperCase(handler),
440
+ upperCase(flowTag) + upperCase(flowStepName) + upperCase(handler),
434
441
  upperCase(flowTag) +
435
442
  upperCase(flowStepName) +
436
443
  upperCase(handler) +
437
- "DSQ",
444
+ 'DSQ'
438
445
  ])
439
446
  );
440
447
  }
441
448
 
442
- if (flowStepConfig.hasOwnProperty("settings")) {
443
- if (flowStepConfig.settings.hasOwnProperty("handleLogic")) {
449
+ if (flowStepConfig.hasOwnProperty('settings')) {
450
+ if (flowStepConfig.settings.hasOwnProperty('handleLogic')) {
444
451
  const handleLogic = flowStepConfig.settings.handleLogic;
445
452
  const childFlow = flowStepConfig.settings.flowType;
446
453
  if (handleLogic === 'awaitingMultipleSteps') {
447
454
  handler = HANDLER.hdrSqs;
448
- additionalResourcePermission.push(awaitingMultipleStepsRole())
449
- additionalResourcePermission.push(createSqsResource(
450
- [
455
+ additionalResourcePermission.push(awaitingMultipleStepsRole());
456
+ additionalResourcePermission.push(
457
+ createSqsResource([
451
458
  upperCase(flowTag) +
452
459
  upperCase(flowStepName) +
453
460
  upperCase(flowStepConfig.settings.handleLogic) +
@@ -455,20 +462,23 @@ function resolveHandlerConfig(data, flowStepConfig, additionalResourcePermission
455
462
  upperCase(flowTag) +
456
463
  upperCase(flowStepName) +
457
464
  upperCase(flowStepConfig.settings.handleLogic) +
458
- upperCase(HANDLER.hdrSqs) + "DLQ"
459
- ]
460
- ))
465
+ upperCase(HANDLER.hdrSqs) +
466
+ 'DLQ'
467
+ ])
468
+ );
461
469
  } else if (handleLogic === 'paginated') {
462
470
  handler = HANDLER.hdrSqs;
463
- additionalResourcePermission.push(createSqsResource(
464
- [
471
+ additionalResourcePermission.push(
472
+ createSqsResource([
465
473
  upperCase(flowTag) +
466
474
  upperCase(flowStepName) +
467
475
  upperCase(HANDLER.hdrDsq),
468
476
  upperCase(flowTag) +
469
477
  upperCase(flowStepName) +
470
- upperCase(HANDLER.hdrDsq) + "DLQ"
471
- ]))
478
+ upperCase(HANDLER.hdrDsq) +
479
+ 'DLQ'
480
+ ])
481
+ );
472
482
  }
473
483
  }
474
484
  }
@@ -479,50 +489,31 @@ function buildFlowStepResourceByConfig(_izContext, data, appPath) {
479
489
  const results = [];
480
490
 
481
491
  if (data.handleLogic === 'awaitingMultipleSteps') {
482
- data.handlerType = HANDLER.hdrSqs
492
+ data.handlerType = HANDLER.hdrSqs;
483
493
  } else if (data.handleLogic === 'paginated') {
484
- data.handlerType = HANDLER.hdrDsq
494
+ data.handlerType = HANDLER.hdrDsq;
485
495
  }
486
496
 
487
- data["functionName"] = upperCase(data.flowTag) +
497
+ data['functionName'] =
498
+ upperCase(data.flowTag) +
488
499
  upperCase(data.flowStepName) +
489
- upperCase(data.handleLogic)
500
+ upperCase(data.handleLogic);
490
501
 
491
- data["functionNameConfig"] = upperCase(data.flowTag) +
502
+ data['functionNameConfig'] =
503
+ upperCase(data.flowTag) +
492
504
  upperCase(data.flowStepName) +
493
505
  upperCase(data.handleLogic) +
494
- upperCase(data.handlerType)
506
+ upperCase(data.handlerType);
495
507
 
496
- const handler = handlerFlowConfig(
497
- _izContext,
498
- data,
499
- appPath
500
- );
508
+ const handler = handlerFlowConfig(_izContext, data, appPath);
501
509
 
502
- const mainFunction = mainFunctionFlowConfig(
503
- _izContext,
504
- data,
505
- appPath
506
- );
510
+ const mainFunction = mainFunctionFlowConfig(_izContext, data, appPath);
507
511
 
508
- const sqs = sqsFlowConfig(
509
- _izContext,
510
- data,
511
- appPath
512
- );
512
+ const sqs = sqsFlowConfig(_izContext, data, appPath);
513
513
 
514
- const yaml = yamlFlowConfig(
515
- _izContext,
516
- data,
517
- appPath
518
- );
514
+ const yaml = yamlFlowConfig(_izContext, data, appPath);
519
515
 
520
- results.push(
521
- handler,
522
- mainFunction,
523
- sqs,
524
- yaml
525
- );
516
+ results.push(handler, mainFunction, sqs, yaml);
526
517
 
527
518
  return results;
528
- }
519
+ }