@izara_project/izara-core-library-asynchronous-flow 1.0.29 → 1.0.30

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
@@ -3,7 +3,7 @@
3
3
  "author": "Sven Mason <thebarbariansven@gmail.com>",
4
4
  "license": "AGPL-3.0-or-later",
5
5
  "homepage": "https://bitbucket.org/izara-core-libraries/izara-core-library-asynchronous-flow#readme",
6
- "version": "1.0.29",
6
+ "version": "1.0.30",
7
7
  "description": "Shared asynchronous flow logic",
8
8
  "type": "module",
9
9
  "main": "index.js",
@@ -208,24 +208,31 @@ export async function createNewAwaitingMultipleSteps(
208
208
  _izContext,
209
209
  pendingStepId,
210
210
  countAwaitingMultipleSteps,
211
+ prefix = '',
211
212
  additionalAttributes = {}
212
213
  ) {
213
- _izContext.logger.debug('[Lib:AsyncFlow:createNewAwaitingMultipleSteps] Input: ', {
214
- pendingStepId,
215
- countAwaitingMultipleSteps,
216
- additionalAttributes
217
- });
214
+ _izContext.logger.debug(
215
+ '[Lib:AsyncFlow:createNewAwaitingMultipleSteps] Input: ',
216
+ {
217
+ pendingStepId,
218
+ countAwaitingMultipleSteps,
219
+ additionalAttributes
220
+ }
221
+ );
218
222
 
219
- const awaitingStepIds = Array.from({ length: countAwaitingMultipleSteps }, () => identifierUuid());
223
+ const parendIds = Array.from(
224
+ { length: countAwaitingMultipleSteps },
225
+ () => (prefix ? `${prefix}_` : '') + identifierUuid.generate()
226
+ );
220
227
 
221
228
  const promiseArray = [];
222
229
 
223
- for (const awaitingStepId of awaitingStepIds) {
230
+ for (const parendId of parendIds) {
224
231
  const attributesWhenCreate = {
225
- awaitingStepId: awaitingStepId,
232
+ awaitingStepId: parendId,
226
233
  pendingStepId: pendingStepId,
227
234
  complete: false,
228
- errorsFound: [],
235
+ errorsFound: []
229
236
  };
230
237
  promiseArray.push(
231
238
  dynamodbSharedLib.putItem(
@@ -258,7 +265,7 @@ export async function createNewAwaitingMultipleSteps(
258
265
 
259
266
  await Promise.all(promiseArray);
260
267
 
261
- return awaitingStepIds;
268
+ return parendIds;
262
269
  }
263
270
 
264
271
  /**
@@ -399,7 +406,6 @@ export async function checkAllAwaitingStepsFinishedShared(
399
406
  }
400
407
  }
401
408
 
402
-
403
409
  /**
404
410
  * Same as checkAllAwaitingStepsFinished but writes errors/additionalAttributes to the *_ByPending row.
405
411
  * @async
@@ -440,7 +446,6 @@ export async function checkAllAwaitingStepsFinished(
440
446
  return true;
441
447
  }
442
448
 
443
-
444
449
  /**
445
450
  * Checks if all awaiting steps for a pending step are complete after marking the current one as complete.
446
451
  * If all steps are finished, returns an object with `isComplete: true` and the collected data.
@@ -527,7 +532,6 @@ export async function checkAllAwaitingStepsFinishedWithReturnParams(
527
532
  };
528
533
  }
529
534
 
530
-
531
535
  /**
532
536
  * Remove all awaiting records for a given pendingStepId from both tables.
533
537
  * @async
@@ -648,4 +652,4 @@ export async function removeAwaitingMultipleStep(
648
652
  );
649
653
  }
650
654
  await Promise.all(promiseArray);
651
- }
655
+ }