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