@izara_project/izara-core-library-asynchronous-flow 1.0.27 → 1.0.28

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.27",
6
+ "version": "1.0.28",
7
7
  "description": "Shared asynchronous flow logic",
8
8
  "type": "module",
9
9
  "main": "index.js",
@@ -348,42 +348,27 @@ export async function checkAllAwaitingStepsFinished(
348
348
  errorsFound = [],
349
349
  additionalAttributes = {}
350
350
  ) {
351
-
352
351
  await checkAllAwaitingStepsFinishedShared(
353
352
  _izContext,
354
353
  pendingStepId,
355
- currentAwaitingStepId = null,
356
- errorsFound = [],
357
- additionalAttributes = {}
354
+ currentAwaitingStepId,
355
+ errorsFound,
356
+ additionalAttributes
358
357
  );
359
358
 
360
- let listPendingStepIds = await dynamodbSharedLib.query(
359
+ const items = await dynamodbSharedLib.query(
361
360
  _izContext,
362
361
  dynamodbSharedLib.tableName(_izContext, 'AwaitingMultipleStepByPending'),
363
- {
364
- pendingStepId: pendingStepId
365
- },
366
- {
367
- limit: 50 // arbitrary limit so not pull too many results, need >2 because some others might be marked as "complete" = true
368
- }
362
+ { pendingStepId },
363
+ { limit: 50 }
369
364
  );
370
- for (let idx = 0; idx < listPendingStepIds.Items.length; idx++) {
371
- // if have error found return errorsFound
372
- // wrap function
373
-
374
- if (
375
- currentAwaitingStepId &&
376
- listPendingStepIds.Items[idx].awaitingStepId == currentAwaitingStepId
377
- ) {
378
- continue;
379
- }
380
- // if any record found not set to complete then there are steps not yet finished
381
- if (!listPendingStepIds.Items[idx].complete) {
382
- return false;
383
- }
365
+
366
+ for (const item of items.Items) {
367
+ if (item.awaitingStepId === currentAwaitingStepId) continue;
368
+ if (!item.complete) return false;
384
369
  }
385
370
 
386
- return true; // all passed
371
+ return true;
387
372
  }
388
373
 
389
374
 
@@ -406,22 +391,26 @@ export async function checkAllAwaitingStepsFinishedWithReturnParams(
406
391
  errorsFound = [],
407
392
  additionalAttributes = {}
408
393
  ) {
394
+ _izContext.logger.debug('Lib:checkAllAwaitingStepsFinishedWithReturnParams', {
395
+ pendingStepId,
396
+ currentAwaitingStepId,
397
+ errorsFound,
398
+ additionalAttributes
399
+ });
409
400
 
410
401
  await checkAllAwaitingStepsFinishedShared(
411
402
  _izContext,
412
403
  pendingStepId,
413
- currentAwaitingStepId = null,
414
- errorsFound = [],
415
- additionalAttributes = {}
404
+ currentAwaitingStepId,
405
+ errorsFound,
406
+ additionalAttributes
416
407
  );
417
408
 
418
409
  const awaitingStepItems = await dynamodbSharedLib.query(
419
410
  _izContext,
420
411
  dynamodbSharedLib.tableName(_izContext, 'AwaitingMultipleStepByPending'),
421
412
  { pendingStepId },
422
- {
423
- limit: 50
424
- }
413
+ { limit: 50 }
425
414
  );
426
415
 
427
416
  _izContext.logger.debug('awaitingStepItems:::', awaitingStepItems);
@@ -431,7 +420,7 @@ export async function checkAllAwaitingStepsFinishedWithReturnParams(
431
420
 
432
421
  for (const item of awaitingStepItems.Items) {
433
422
  if (item.awaitingStepId !== currentAwaitingStepId && !item.complete) {
434
- return [false, null, []];
423
+ return [false, null, collectedErrors];
435
424
  }
436
425
 
437
426
  if (item.errorsFound?.length > 0) {