@onlineapps/conn-base-hub 1.0.2 → 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.
Files changed (2) hide show
  1. package/package.json +2 -2
  2. package/src/index.js +21 -2
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@onlineapps/conn-base-hub",
3
- "version": "1.0.2",
3
+ "version": "1.0.4",
4
4
  "description": "Central hub for OA Drive connectors - bundles and integrates all essential connector libraries",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
@@ -23,7 +23,7 @@
23
23
  "dependencies": {
24
24
  "@onlineapps/conn-base-monitoring": "^1.0.0",
25
25
  "@onlineapps/conn-base-storage": "^1.0.0",
26
- "@onlineapps/conn-infra-mq": "1.1.53",
26
+ "@onlineapps/conn-infra-mq": "1.1.54",
27
27
  "@onlineapps/conn-orch-cookbook": "^2.0.0",
28
28
  "@onlineapps/conn-orch-registry": "^1.1.4",
29
29
  "dotenv": "^16.0.3"
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 && current_step < cookbook.steps.length) {
255
- const nextStep = cookbook.steps[current_step];
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