@onlineapps/conn-base-hub 1.0.3 → 1.0.4
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/index.js +21 -2
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -245,14 +245,33 @@ module.exports = {
|
|
|
245
245
|
|
|
246
246
|
/**
|
|
247
247
|
* Determine next queue based on workflow state
|
|
248
|
+
* V2.1: steps is an array, current_step is step_id (string)
|
|
248
249
|
* @param {Object} message - Workflow message
|
|
249
250
|
* @returns {string} - Next queue name
|
|
250
251
|
*/
|
|
251
252
|
getNextQueueFromMessage(message) {
|
|
252
253
|
const { current_step, cookbook } = message;
|
|
253
254
|
|
|
254
|
-
if (cookbook
|
|
255
|
-
|
|
255
|
+
if (!cookbook?.steps) {
|
|
256
|
+
return 'workflow.completed';
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
// V2.1: steps is array, find current step by step_id
|
|
260
|
+
if (Array.isArray(cookbook.steps)) {
|
|
261
|
+
const currentIndex = cookbook.steps.findIndex(s => s.step_id === current_step);
|
|
262
|
+
if (currentIndex >= 0 && currentIndex < cookbook.steps.length - 1) {
|
|
263
|
+
const nextStep = cookbook.steps[currentIndex + 1];
|
|
264
|
+
return `${nextStep.service}.queue`;
|
|
265
|
+
}
|
|
266
|
+
return 'workflow.completed';
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
// V2.0 (deprecated): steps is object, current_step is step_id
|
|
270
|
+
const stepIds = Object.keys(cookbook.steps);
|
|
271
|
+
const currentIndex = stepIds.indexOf(current_step);
|
|
272
|
+
if (currentIndex >= 0 && currentIndex < stepIds.length - 1) {
|
|
273
|
+
const nextStepId = stepIds[currentIndex + 1];
|
|
274
|
+
const nextStep = cookbook.steps[nextStepId];
|
|
256
275
|
return `${nextStep.service}.queue`;
|
|
257
276
|
}
|
|
258
277
|
|