@onlineapps/conn-orch-orchestrator 1.0.21 → 1.0.22
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 +17 -1
package/package.json
CHANGED
|
@@ -517,6 +517,21 @@ class WorkflowOrchestrator {
|
|
|
517
517
|
// Delivery Dispatcher requires: workflow_id, status, delivery (must be object, not null)
|
|
518
518
|
const delivery = finalContext?.delivery || cookbookDef?.delivery || { handler: 'none' };
|
|
519
519
|
|
|
520
|
+
// Extract api_output from the last completed step
|
|
521
|
+
// steps is an object keyed by step_id in V2
|
|
522
|
+
let api_output = null;
|
|
523
|
+
if (lastStepId && finalContext?.steps?.[lastStepId]?.output) {
|
|
524
|
+
api_output = finalContext.steps[lastStepId].output;
|
|
525
|
+
} else if (finalContext?.steps) {
|
|
526
|
+
// Fallback: find any step with output
|
|
527
|
+
const stepKeys = Object.keys(finalContext.steps);
|
|
528
|
+
for (const key of stepKeys) {
|
|
529
|
+
if (finalContext.steps[key]?.output) {
|
|
530
|
+
api_output = finalContext.steps[key].output;
|
|
531
|
+
}
|
|
532
|
+
}
|
|
533
|
+
}
|
|
534
|
+
|
|
520
535
|
// Build message in format expected by Delivery Dispatcher
|
|
521
536
|
const workflowCompletedMessage = {
|
|
522
537
|
workflow_id,
|
|
@@ -524,10 +539,11 @@ class WorkflowOrchestrator {
|
|
|
524
539
|
service: serviceName, // Service that completed the workflow (for monitoring)
|
|
525
540
|
step_id: lastStepId, // Last step ID for monitoring
|
|
526
541
|
step_index: lastStepIndex, // Last step index for monitoring
|
|
542
|
+
api_output: api_output, // Output from last step - for frontend/delivery
|
|
527
543
|
cookbook: cookbookDef, // Full cookbook for monitoring trace
|
|
528
544
|
delivery: delivery, // Delivery configuration from Gateway context (must be object)
|
|
529
545
|
context: finalContext, // Full context for output resolution
|
|
530
|
-
steps: finalContext?.steps ||
|
|
546
|
+
steps: finalContext?.steps || {}, // Steps results (object) for output resolution
|
|
531
547
|
completed_at: new Date().toISOString()
|
|
532
548
|
};
|
|
533
549
|
|