@izara_project/izara-core-library-asynchronous-flow 1.0.7 → 1.0.9
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/index.js +1 -0
- package/package.json +1 -1
- package/src/AsyncFlowSharedLib.js +55 -4
package/index.js
CHANGED
|
@@ -38,6 +38,7 @@ module.exports = {
|
|
|
38
38
|
createAwaitingStep: asyncFlowSharedLib.createAwaitingStep,
|
|
39
39
|
findPendingStepIdsAwaitingStep: asyncFlowSharedLib.findPendingStepIdsAwaitingStep,
|
|
40
40
|
findPendingStepsAwaitingStep: asyncFlowSharedLib.findPendingStepsAwaitingStep,
|
|
41
|
+
findPendingStepAwaitingStep: asyncFlowSharedLib.findPendingStepAwaitingStep,
|
|
41
42
|
|
|
42
43
|
// Checking and clearing steps
|
|
43
44
|
checkAllAwaitingStepsFinished: asyncFlowSharedLib.checkAllAwaitingStepsFinished,
|
package/package.json
CHANGED
|
@@ -269,6 +269,27 @@ async function findPendingStepsAwaitingStep(
|
|
|
269
269
|
_izContext.logger.debug("Record of awaitingStepId", listPendingSteps)
|
|
270
270
|
return listPendingSteps.Items;
|
|
271
271
|
}
|
|
272
|
+
async function findPendingStepAwaitingStep(
|
|
273
|
+
_izContext,
|
|
274
|
+
awaitingStepId,
|
|
275
|
+
tableName = "AwaitingStep"
|
|
276
|
+
) {
|
|
277
|
+
|
|
278
|
+
let listPendingSteps = await dynamodbSharedLib.query(
|
|
279
|
+
_izContext,
|
|
280
|
+
await dynamodbSharedLib.tableName(_izContext, tableName),
|
|
281
|
+
{
|
|
282
|
+
awaitingStepId: awaitingStepId
|
|
283
|
+
}
|
|
284
|
+
);
|
|
285
|
+
_izContext.logger.debug("Record of awaitingStepId", listPendingSteps)
|
|
286
|
+
|
|
287
|
+
if (listPendingSteps.length !== 1) {
|
|
288
|
+
throw new NoRetryError("listPendingSteps not equals 1")
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
return listPendingSteps.Items[0];
|
|
292
|
+
}
|
|
272
293
|
|
|
273
294
|
|
|
274
295
|
|
|
@@ -276,11 +297,34 @@ async function checkAllAwaitingStepsFinished(
|
|
|
276
297
|
_izContext,
|
|
277
298
|
pendingStepId,
|
|
278
299
|
currentAwaitingStepId = null,
|
|
300
|
+
errorsFound = [],
|
|
279
301
|
tableName = 'AwaitingMultipleSteps',
|
|
280
302
|
byPendingTableName = "AwaitingMultipleStepByPending"
|
|
281
303
|
// indexName = ''
|
|
282
304
|
) {
|
|
283
|
-
|
|
305
|
+
let remaining;
|
|
306
|
+
[remaining, errorsFound] = await this.checkAllAwaitingStepsFinishedWithError(
|
|
307
|
+
_izContext,
|
|
308
|
+
pendingStepId,
|
|
309
|
+
currentAwaitingStepId,
|
|
310
|
+
errorsFound,
|
|
311
|
+
tableName,
|
|
312
|
+
byPendingTableName
|
|
313
|
+
);
|
|
314
|
+
return remaining;
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
|
|
318
|
+
module.exports.checkAllAwaitingStepsFinishedWithError = async (
|
|
319
|
+
_izContext,
|
|
320
|
+
pendingStepId,
|
|
321
|
+
currentAwaitingStepId = null,
|
|
322
|
+
errorsFound = [],
|
|
323
|
+
tableName = 'AwaitingMultipleSteps',
|
|
324
|
+
byPendingTableName = "AwaitingMultipleStepByPending"
|
|
325
|
+
// indexName = ''
|
|
326
|
+
) => {
|
|
327
|
+
_izContext.logger.debug("Lib:checkAllAwaitingStepsFinishedWithError", {
|
|
284
328
|
pendingStepId: pendingStepId,
|
|
285
329
|
currentAwaitingStepId: currentAwaitingStepId,
|
|
286
330
|
tableName: tableName,
|
|
@@ -311,7 +355,8 @@ async function checkAllAwaitingStepsFinished(
|
|
|
311
355
|
awaitingStepId: currentAwaitingStepId
|
|
312
356
|
},
|
|
313
357
|
{
|
|
314
|
-
complete: true
|
|
358
|
+
complete: true,
|
|
359
|
+
errorsFound: errorsFound
|
|
315
360
|
},
|
|
316
361
|
);
|
|
317
362
|
|
|
@@ -328,16 +373,19 @@ async function checkAllAwaitingStepsFinished(
|
|
|
328
373
|
);
|
|
329
374
|
for (let idx = 0; idx < listPendingStepIds.Items.length; idx++) {
|
|
330
375
|
|
|
376
|
+
// if have error found return errorfound
|
|
377
|
+
// wrap function
|
|
378
|
+
|
|
331
379
|
if (currentAwaitingStepId && listPendingStepIds.Items[idx].awaitingStepId == currentAwaitingStepId) {
|
|
332
380
|
continue;
|
|
333
381
|
}
|
|
334
382
|
// if any record found not set to complete then there are steps not yet finished
|
|
335
383
|
if (!listPendingStepIds.Items[idx].complete) {
|
|
336
|
-
return false;
|
|
384
|
+
return [false, errorsFound];
|
|
337
385
|
}
|
|
338
386
|
}
|
|
339
387
|
|
|
340
|
-
return true;
|
|
388
|
+
return [true, errorsFound]; // all passed
|
|
341
389
|
|
|
342
390
|
|
|
343
391
|
// // mark currentAwaitingStepId as complete, this is done to protect against race condition in between checking all complete
|
|
@@ -384,6 +432,8 @@ async function checkAllAwaitingStepsFinished(
|
|
|
384
432
|
// return true;
|
|
385
433
|
}
|
|
386
434
|
|
|
435
|
+
|
|
436
|
+
|
|
387
437
|
async function clearAllAwaitingSteps(
|
|
388
438
|
_izContext,
|
|
389
439
|
pendingStepId,
|
|
@@ -902,6 +952,7 @@ module.exports = {
|
|
|
902
952
|
// AwaitingStep functions
|
|
903
953
|
createAwaitingStep,
|
|
904
954
|
findPendingStepIdsAwaitingStep,
|
|
955
|
+
findPendingStepAwaitingStep,
|
|
905
956
|
findPendingStepsAwaitingStep,
|
|
906
957
|
removeAwaitingStep,
|
|
907
958
|
removeAwaitingStepWithCheckUniqueRequestId,
|