@izara_project/izara-core-library-asynchronous-flow 1.0.8 → 1.0.10
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 +1 -1
- package/src/AsyncFlowSharedLib.js +28 -15
package/package.json
CHANGED
|
@@ -302,7 +302,8 @@ async function checkAllAwaitingStepsFinished(
|
|
|
302
302
|
byPendingTableName = "AwaitingMultipleStepByPending"
|
|
303
303
|
// indexName = ''
|
|
304
304
|
) {
|
|
305
|
-
|
|
305
|
+
|
|
306
|
+
let remaining = await checkAllAwaitingStepsFinishedWithError(
|
|
306
307
|
_izContext,
|
|
307
308
|
pendingStepId,
|
|
308
309
|
currentAwaitingStepId,
|
|
@@ -314,7 +315,8 @@ async function checkAllAwaitingStepsFinished(
|
|
|
314
315
|
}
|
|
315
316
|
|
|
316
317
|
|
|
317
|
-
|
|
318
|
+
|
|
319
|
+
async function checkAllAwaitingStepsFinishedWithError(
|
|
318
320
|
_izContext,
|
|
319
321
|
pendingStepId,
|
|
320
322
|
currentAwaitingStepId = null,
|
|
@@ -322,7 +324,7 @@ module.exports.checkAllAwaitingStepsFinishedWithError = async (
|
|
|
322
324
|
tableName = 'AwaitingMultipleSteps',
|
|
323
325
|
byPendingTableName = "AwaitingMultipleStepByPending"
|
|
324
326
|
// indexName = ''
|
|
325
|
-
)
|
|
327
|
+
) {
|
|
326
328
|
_izContext.logger.debug("Lib:checkAllAwaitingStepsFinishedWithError", {
|
|
327
329
|
pendingStepId: pendingStepId,
|
|
328
330
|
currentAwaitingStepId: currentAwaitingStepId,
|
|
@@ -380,11 +382,11 @@ module.exports.checkAllAwaitingStepsFinishedWithError = async (
|
|
|
380
382
|
}
|
|
381
383
|
// if any record found not set to complete then there are steps not yet finished
|
|
382
384
|
if (!listPendingStepIds.Items[idx].complete) {
|
|
383
|
-
return
|
|
385
|
+
return false;
|
|
384
386
|
}
|
|
385
387
|
}
|
|
386
388
|
|
|
387
|
-
return
|
|
389
|
+
return true; // all passed
|
|
388
390
|
|
|
389
391
|
|
|
390
392
|
// // mark currentAwaitingStepId as complete, this is done to protect against race condition in between checking all complete
|
|
@@ -512,6 +514,7 @@ async function removeAwaitingMultipleStep(
|
|
|
512
514
|
_izContext,
|
|
513
515
|
awaitingStepId,
|
|
514
516
|
pendingStepId,
|
|
517
|
+
errorsFound = [],
|
|
515
518
|
tableName = "AwaitingMultipleSteps",
|
|
516
519
|
byPendingTableName = "AwaitingMultipleStepByPending"
|
|
517
520
|
) {
|
|
@@ -524,11 +527,20 @@ async function removeAwaitingMultipleStep(
|
|
|
524
527
|
|
|
525
528
|
let promiseArray = []
|
|
526
529
|
|
|
530
|
+
|
|
527
531
|
let keyValues = {
|
|
528
532
|
awaitingStepId: awaitingStepId,
|
|
529
533
|
pendingStepId: pendingStepId
|
|
530
534
|
}
|
|
531
|
-
|
|
535
|
+
|
|
536
|
+
let keyValuesForByPending = {
|
|
537
|
+
pendingStepId: pendingStepId,
|
|
538
|
+
awaitingStepId: awaitingStepId
|
|
539
|
+
}
|
|
540
|
+
_izContext.logger.debug('deleting ... ', {
|
|
541
|
+
keyValues,
|
|
542
|
+
keyValuesForByPending
|
|
543
|
+
});
|
|
532
544
|
|
|
533
545
|
_izContext.logger.debug(`delete item in dynamodb AwaitingMultipleSteps ==> awaitingStepId:${keyValues.awaitingStepId}`)
|
|
534
546
|
promiseArray.push(
|
|
@@ -537,15 +549,15 @@ async function removeAwaitingMultipleStep(
|
|
|
537
549
|
await dynamodbSharedLib.tableName(_izContext, tableName),
|
|
538
550
|
keyValues
|
|
539
551
|
));
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
552
|
+
if (errorsFound.length == 0) {
|
|
553
|
+
_izContext.logger.debug(`delete item in dynamodb AwaitingMultipleStepByPending ==> awaitingStepId:${keyValues.awaitingStepId}`)
|
|
554
|
+
promiseArray.push(
|
|
555
|
+
dynamodbSharedLib.deleteItem(
|
|
556
|
+
_izContext,
|
|
557
|
+
await dynamodbSharedLib.tableName(_izContext, byPendingTableName),
|
|
558
|
+
keyValuesForByPending
|
|
559
|
+
));
|
|
560
|
+
}
|
|
549
561
|
await Promise.all(promiseArray);
|
|
550
562
|
|
|
551
563
|
}
|
|
@@ -944,6 +956,7 @@ module.exports = {
|
|
|
944
956
|
// AwaitingMultipleSteps functions
|
|
945
957
|
createAwaitingMultipleStepsWithAdditionalAttributes,
|
|
946
958
|
createAwaitingMultipleSteps,
|
|
959
|
+
checkAllAwaitingStepsFinishedWithError,
|
|
947
960
|
checkAllAwaitingStepsFinished,
|
|
948
961
|
clearAllAwaitingSteps,
|
|
949
962
|
removeAwaitingMultipleStep,
|