@onlineapps/conn-orch-orchestrator 1.0.20 → 1.0.21
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/WorkflowOrchestrator.js +36 -7
package/package.json
CHANGED
|
@@ -303,7 +303,9 @@ class WorkflowOrchestrator {
|
|
|
303
303
|
|
|
304
304
|
/**
|
|
305
305
|
* Resolve variable references in input object
|
|
306
|
-
* Supports
|
|
306
|
+
* Supports both syntaxes:
|
|
307
|
+
* - {{steps.step_id.output.field}}, {{api_input.field}} (preferred, V2)
|
|
308
|
+
* - ${steps[N].output.field}, ${api_input.field} (legacy)
|
|
307
309
|
* @private
|
|
308
310
|
* @param {Object} input - Input object with potential references
|
|
309
311
|
* @param {Object} context - Current context with steps, api_input, etc
|
|
@@ -313,12 +315,39 @@ class WorkflowOrchestrator {
|
|
|
313
315
|
if (!input) return input;
|
|
314
316
|
|
|
315
317
|
const resolveValue = (value) => {
|
|
316
|
-
if (typeof value === 'string'
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
318
|
+
if (typeof value === 'string') {
|
|
319
|
+
let result = value;
|
|
320
|
+
|
|
321
|
+
// Replace {{...}} references (V2 preferred syntax)
|
|
322
|
+
if (result.includes('{{')) {
|
|
323
|
+
result = result.replace(/\{\{([^}]+)\}\}/g, (match, path) => {
|
|
324
|
+
const resolved = this._getValueFromPath(path.trim(), context);
|
|
325
|
+
if (resolved !== undefined) {
|
|
326
|
+
// If resolved value is an object, stringify it for embedding in strings
|
|
327
|
+
if (typeof resolved === 'object' && result !== match) {
|
|
328
|
+
return JSON.stringify(resolved);
|
|
329
|
+
}
|
|
330
|
+
return resolved;
|
|
331
|
+
}
|
|
332
|
+
return match;
|
|
333
|
+
});
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
// Replace ${...} references (legacy syntax)
|
|
337
|
+
if (result.includes('${')) {
|
|
338
|
+
result = result.replace(/\$\{([^}]+)\}/g, (match, path) => {
|
|
339
|
+
const resolved = this._getValueFromPath(path.trim(), context);
|
|
340
|
+
if (resolved !== undefined) {
|
|
341
|
+
if (typeof resolved === 'object' && result !== match) {
|
|
342
|
+
return JSON.stringify(resolved);
|
|
343
|
+
}
|
|
344
|
+
return resolved;
|
|
345
|
+
}
|
|
346
|
+
return match;
|
|
347
|
+
});
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
return result;
|
|
322
351
|
}
|
|
323
352
|
if (Array.isArray(value)) {
|
|
324
353
|
return value.map(resolveValue);
|