@onlineapps/conn-orch-orchestrator 1.0.19 → 1.0.20

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.19",
3
+ "version": "1.0.20",
4
4
  "description": "Workflow orchestration connector for OA Drive - handles message routing and workflow execution",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
@@ -75,6 +75,9 @@ class WorkflowOrchestrator {
75
75
  const { workflow_id, cookbook: cookbookDef, current_step, context } = message;
76
76
 
77
77
  try {
78
+ // FAIL-FAST: Validate V2 format BEFORE anything else
79
+ this._validateV2Format(cookbookDef);
80
+
78
81
  // Validate cookbook structure
79
82
  this.cookbook.validateCookbook(cookbookDef);
80
83
 
@@ -89,7 +92,7 @@ class WorkflowOrchestrator {
89
92
  // Find current step (V2: step_id only)
90
93
  const step = cookbookDef.steps.find(s => s.step_id === current_step);
91
94
  if (!step) {
92
- throw new Error(`Step not found: ${current_step}`);
95
+ throw new Error(`Step not found: ${current_step}. Available steps: ${cookbookDef.steps.map(s => s.step_id).join(', ')}`);
93
96
  }
94
97
 
95
98
  // Get step_id (V2)
@@ -568,6 +571,63 @@ class WorkflowOrchestrator {
568
571
  const mapper = new ResponseMapper();
569
572
  return mapper.mapResponse(response, mapping);
570
573
  }
574
+
575
+ /**
576
+ * FAIL-FAST: Validate V2 format strictly
577
+ * Rejects V1 format immediately with clear error message
578
+ * @private
579
+ * @param {Object} cookbook - Cookbook definition
580
+ * @throws {Error} If cookbook is not V2 format
581
+ */
582
+ _validateV2Format(cookbook) {
583
+ if (!cookbook) {
584
+ throw new Error('FAIL-FAST: Cookbook is required');
585
+ }
586
+
587
+ // Check version format
588
+ const version = cookbook.version;
589
+ if (!version) {
590
+ throw new Error('FAIL-FAST: Cookbook version is required');
591
+ }
592
+
593
+ // V1 format detection - REJECT immediately
594
+ if (/^1\.\d+\.\d+$/.test(version)) {
595
+ throw new Error(`FAIL-FAST: V1 format (${version}) is DEPRECATED and no longer supported. Use V2 format (2.x.x) with step_id instead of id.`);
596
+ }
597
+
598
+ // Must be V2 format
599
+ if (!/^2\.\d+\.\d+$/.test(version)) {
600
+ throw new Error(`FAIL-FAST: Invalid version format '${version}'. Must be 2.x.x (e.g., 2.0.0)`);
601
+ }
602
+
603
+ // Check steps
604
+ if (!cookbook.steps || !Array.isArray(cookbook.steps) || cookbook.steps.length === 0) {
605
+ throw new Error('FAIL-FAST: Cookbook must have at least one step');
606
+ }
607
+
608
+ // Validate each step has step_id (V2) not id (V1)
609
+ const invalidSteps = [];
610
+ cookbook.steps.forEach((step, index) => {
611
+ if (step.id && !step.step_id) {
612
+ invalidSteps.push(`Step ${index}: has 'id' (V1) but missing 'step_id' (V2)`);
613
+ }
614
+ if (!step.step_id) {
615
+ invalidSteps.push(`Step ${index}: missing required 'step_id'`);
616
+ }
617
+ if (!step.type) {
618
+ invalidSteps.push(`Step ${index} (${step.step_id || 'unknown'}): missing required 'type'`);
619
+ }
620
+ });
621
+
622
+ if (invalidSteps.length > 0) {
623
+ throw new Error(`FAIL-FAST: Invalid V2 cookbook format:\n${invalidSteps.join('\n')}`);
624
+ }
625
+
626
+ this.logger.info('[WorkflowOrchestrator] V2 format validation passed', {
627
+ version: cookbook.version,
628
+ steps: cookbook.steps.map(s => s.step_id)
629
+ });
630
+ }
571
631
  }
572
632
 
573
633
  module.exports = WorkflowOrchestrator;