@onlineapps/conn-orch-orchestrator 1.0.49 → 1.0.51

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.49",
3
+ "version": "1.0.51",
4
4
  "description": "Workflow orchestration connector for OA Drive - handles message routing and workflow execution",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
@@ -145,13 +145,15 @@ class WorkflowOrchestrator {
145
145
  const updatedSteps = [...stepsArray];
146
146
  updatedSteps[currentIndex] = {
147
147
  ...step,
148
- started_at: new Date().toISOString(),
149
- status: 'in_progress'
148
+ _execution: {
149
+ status: 'in_progress',
150
+ started_at: new Date().toISOString()
151
+ }
150
152
  };
151
153
 
152
- // Execute the step (pass _input from cookbook as context for operations)
154
+ // Execute the step (pass api_input from cookbook as context for operations)
153
155
  const stepContext = {
154
- ...cookbookDef._input,
156
+ ...cookbookDef.api_input,
155
157
  _system: cookbookDef._system,
156
158
  delivery: cookbookDef.delivery
157
159
  };
@@ -177,21 +179,24 @@ class WorkflowOrchestrator {
177
179
  ? this._getStepId(nextStep)
178
180
  : 'api_delivery_dispatcher'; // Last step -> dispatcher
179
181
 
180
- // Update step with output and completion info
182
+ // Update step with output and execution metadata
181
183
  updatedSteps[currentIndex] = {
182
184
  ...step,
183
- started_at: updatedSteps[currentIndex].started_at,
184
185
  output: result,
185
- status: 'completed',
186
- completed_at: new Date().toISOString(),
187
- duration_ms
186
+ _execution: {
187
+ status: 'completed',
188
+ started_at: updatedSteps[currentIndex]._execution?.started_at || new Date().toISOString(),
189
+ completed_at: new Date().toISOString(),
190
+ duration_ms
191
+ }
188
192
  };
189
193
 
190
194
  // Build UPDATED UNIFIED COOKBOOK
195
+ // After last step -> pointer to dispatcher (not null)
191
196
  const updatedCookbook = {
192
197
  ...cookbookDef,
193
198
  steps: updatedSteps,
194
- _pointer: { next: nextStep ? this._getStepId(nextStep) : null }
199
+ _pointer: { next: nextStep ? this._getStepId(nextStep) : 'api_delivery_dispatcher' }
195
200
  };
196
201
 
197
202
  // Publish workflow.progress with UNIFIED COOKBOOK
@@ -230,7 +235,7 @@ class WorkflowOrchestrator {
230
235
  };
231
236
 
232
237
  } catch (error) {
233
- // UNIFIED COOKBOOK: _retry_history is stored INSIDE the step, not globally
238
+ // UNIFIED COOKBOOK: retry_history is stored in _execution.retry_history
234
239
  const crypto = require('crypto');
235
240
 
236
241
  // Find current step index
@@ -238,8 +243,8 @@ class WorkflowOrchestrator {
238
243
  const currentIndex = stepsArray.findIndex(s => this._getStepId(s) === current_step);
239
244
  const currentStepDef = stepsArray[currentIndex] || {};
240
245
 
241
- // Get existing retry history from the step itself
242
- const stepRetryHistory = currentStepDef._retry_history || [];
246
+ // Get existing retry history from _execution.retry_history
247
+ const stepRetryHistory = currentStepDef._execution?.retry_history || [];
243
248
  const attemptNumber = stepRetryHistory.length + 1;
244
249
 
245
250
  // Generate error reference for log lookup (instead of full stack trace)
@@ -255,7 +260,7 @@ class WorkflowOrchestrator {
255
260
  stack: error.stack
256
261
  });
257
262
 
258
- // Add attempt record to step's _retry_history
263
+ // Add attempt record to _execution.retry_history
259
264
  const attemptRecord = {
260
265
  attempt: attemptNumber,
261
266
  error: error.message,
@@ -263,12 +268,15 @@ class WorkflowOrchestrator {
263
268
  at: new Date().toISOString()
264
269
  };
265
270
 
266
- // Update steps array with retry history
271
+ // Update steps array with retry history inside _execution
267
272
  const updatedSteps = [...stepsArray];
268
273
  updatedSteps[currentIndex] = {
269
274
  ...currentStepDef,
270
- status: 'retrying',
271
- _retry_history: [...stepRetryHistory, attemptRecord]
275
+ _execution: {
276
+ ...currentStepDef._execution,
277
+ status: 'retrying',
278
+ retry_history: [...stepRetryHistory, attemptRecord]
279
+ }
272
280
  };
273
281
 
274
282
  // Build updated UNIFIED COOKBOOK
@@ -296,7 +304,7 @@ class WorkflowOrchestrator {
296
304
  service_name: serviceName,
297
305
  step_index: currentIndex,
298
306
  step_id: current_step,
299
- cookbook: updatedCookbook, // UNIFIED cookbook with _retry_history in step
307
+ cookbook: updatedCookbook, // UNIFIED cookbook with _execution.retry_history
300
308
  error: { message: error.message, error_ref: errorRef },
301
309
  status: 'retry',
302
310
  attempt: attemptNumber,
@@ -353,8 +361,12 @@ class WorkflowOrchestrator {
353
361
 
354
362
  updatedSteps[currentIndex] = {
355
363
  ...updatedSteps[currentIndex],
356
- status: 'failed',
357
- _retry_history: [...updatedSteps[currentIndex]._retry_history, dlqEntryRecord]
364
+ _execution: {
365
+ ...updatedSteps[currentIndex]._execution,
366
+ status: 'failed',
367
+ failed_at: new Date().toISOString(),
368
+ retry_history: [...(updatedSteps[currentIndex]._execution?.retry_history || []), dlqEntryRecord]
369
+ }
358
370
  };
359
371
 
360
372
  const finalCookbook = {
@@ -373,7 +385,7 @@ class WorkflowOrchestrator {
373
385
  });
374
386
 
375
387
  // Publish to workflow.failed (DLQ queue - message stays until manual requeue/discard)
376
- // UNIFIED COOKBOOK contains everything including _retry_history in the step
388
+ // UNIFIED COOKBOOK contains everything including _execution.retry_history
377
389
  await this.mqClient.publish('workflow.failed', {
378
390
  workflow_id,
379
391
  current_step,