@onlineapps/conn-orch-orchestrator 1.0.34 → 1.0.40

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@onlineapps/conn-orch-orchestrator",
3
- "version": "1.0.34",
3
+ "version": "1.0.40",
4
4
  "description": "Workflow orchestration connector for OA Drive - handles message routing and workflow execution",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
@@ -21,14 +21,14 @@
21
21
  "license": "MIT",
22
22
  "dependencies": {
23
23
  "@onlineapps/conn-base-monitoring": "^1.0.0",
24
- "@onlineapps/conn-infra-mq": "^1.1.0",
25
- "@onlineapps/conn-orch-registry": "^1.1.4",
24
+ "@onlineapps/conn-infra-mq": "1.1.54",
25
+ "@onlineapps/conn-orch-api-mapper": "^1.0.0",
26
26
  "@onlineapps/conn-orch-cookbook": "^2.0.0",
27
- "@onlineapps/conn-orch-api-mapper": "^1.0.0"
27
+ "@onlineapps/conn-orch-registry": "^1.1.4"
28
28
  },
29
29
  "devDependencies": {
30
- "jest": "^29.5.0",
31
30
  "eslint": "^8.30.0",
31
+ "jest": "^29.5.0",
32
32
  "jsdoc-to-markdown": "^8.0.0"
33
33
  },
34
34
  "jest": {
@@ -326,7 +326,7 @@ class WorkflowOrchestrator {
326
326
 
327
327
  /**
328
328
  * Resolve variable references in input object
329
- * Supports ${steps[N].output.field}, ${api_input.field}, ${context.field}
329
+ * Supports {{steps.step_id.output.field}}, {{api_input.field}}, {{context.field}}
330
330
  * @private
331
331
  * @param {Object} input - Input object with potential references
332
332
  * @param {Object} context - Current context with steps, api_input, etc
@@ -336,11 +336,24 @@ class WorkflowOrchestrator {
336
336
  if (!input) return input;
337
337
 
338
338
  const resolveValue = (value) => {
339
- if (typeof value === 'string' && value.includes('${')) {
340
- // Replace ${...} references
341
- return value.replace(/\$\{([^}]+)\}/g, (match, path) => {
339
+ if (typeof value === 'string' && value.includes('{{')) {
340
+ // Check if the ENTIRE string is a single template reference
341
+ // e.g. "{{steps.greeting.output}}" should return the object directly
342
+ const singleRefMatch = value.match(/^\{\{([^}]+)\}\}$/);
343
+ if (singleRefMatch) {
344
+ // Entire value is a single reference - return the resolved value directly (preserves objects)
345
+ const resolved = this._getValueFromPath(singleRefMatch[1].trim(), context);
346
+ return resolved !== undefined ? resolved : value;
347
+ }
348
+
349
+ // Multiple references or mixed with text - use string replacement
350
+ // e.g. "Hello {{name}}, your order {{orderId}}" becomes "Hello John, your order 123"
351
+ return value.replace(/\{\{([^}]+)\}\}/g, (match, path) => {
342
352
  const resolved = this._getValueFromPath(path.trim(), context);
343
- return resolved !== undefined ? resolved : match;
353
+ if (resolved === undefined) return match;
354
+ // For string concatenation, convert objects to JSON string
355
+ if (typeof resolved === 'object') return JSON.stringify(resolved);
356
+ return String(resolved);
344
357
  });
345
358
  }
346
359
  if (Array.isArray(value)) {
@@ -360,7 +373,7 @@ class WorkflowOrchestrator {
360
373
  /**
361
374
  * Get value from dot/bracket notation path
362
375
  * @private
363
- * @param {string} path - Path like "steps[0].output.message" or "api_input.name"
376
+ * @param {string} path - Path like "steps.greeting.output.message" or "api_input.name"
364
377
  * @param {Object} context - Context object
365
378
  * @returns {*} Resolved value or undefined
366
379
  */
@@ -378,9 +391,20 @@ class WorkflowOrchestrator {
378
391
  const parts = normalized.split('.');
379
392
 
380
393
  let current = context;
381
- for (const part of parts) {
394
+ for (let i = 0; i < parts.length; i++) {
395
+ const part = parts[i];
382
396
  if (current === undefined || current === null) return undefined;
383
- current = current[part];
397
+
398
+ // Special handling for 'steps' array - lookup by step id
399
+ // context.steps is an array of {id/step_id: "step_id", output: {...}}
400
+ // Path like "steps.greeting.output" should find step with id="greeting"
401
+ if (parts[i - 1] === 'steps' && Array.isArray(context.steps)) {
402
+ // 'part' is the step_id, find the step in the array (support both 'id' and 'step_id')
403
+ const step = context.steps.find(s => s.id === part || s.step_id === part);
404
+ current = step;
405
+ } else {
406
+ current = current[part];
407
+ }
384
408
  }
385
409
  return current;
386
410
  }