@onlineapps/conn-orch-orchestrator 1.0.115 → 2.0.0

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.115",
3
+ "version": "2.0.0",
4
4
  "description": "Workflow orchestration connector for OA Drive - handles message routing and workflow execution",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
@@ -24,8 +24,7 @@
24
24
  "@onlineapps/conn-base-monitoring": "1.0.12",
25
25
  "@onlineapps/conn-infra-mq": "1.1.70",
26
26
  "@onlineapps/conn-orch-registry": "1.2.1",
27
- "@onlineapps/conn-orch-cookbook": "2.1.2",
28
- "@onlineapps/conn-orch-api-mapper": "1.0.34"
27
+ "@onlineapps/conn-orch-cookbook": "2.1.2"
29
28
  },
30
29
  "devDependencies": {
31
30
  "jest": "^29.5.0",
@@ -15,7 +15,10 @@ class WorkflowOrchestrator {
15
15
  * @param {Object} config - Configuration object
16
16
  * @param {Object} config.mqClient - MQ client for message operations
17
17
  * @param {Object} config.registryClient - Registry client for service discovery
18
- * @param {Object} config.apiMapper - API mapper for cookbook to HTTP mapping
18
+ * @param {Object} config.invoker - Intra-service operation invoker exposing
19
+ * async invokeOperation({ operation, input, envelope, workflow_id,
20
+ * correlation_id, step_id }) -> { status, result } | { status, error }.
21
+ * Replaces the retired apiMapper HTTP-loopback path (RFC §5.9, §5.10).
19
22
  * @param {Object} config.cookbook - Cookbook connector for validation and execution
20
23
  * @param {Object} [config.cache] - Cache connector for caching
21
24
  * @param {Object} [config.errorHandler] - Error handler connector
@@ -25,12 +28,16 @@ class WorkflowOrchestrator {
25
28
  constructor(config) {
26
29
  if (!config.mqClient) throw new Error('mqClient is required');
27
30
  if (!config.registryClient) throw new Error('registryClient is required');
28
- if (!config.apiMapper) throw new Error('apiMapper is required');
31
+ if (!config.invoker || typeof config.invoker.invokeOperation !== 'function') {
32
+ throw new Error(
33
+ '[WorkflowOrchestrator] invoker with invokeOperation(message) is required - Expected object exposing async invokeOperation({operation, input, envelope, workflow_id, correlation_id, step_id}) returning {status, result}'
34
+ );
35
+ }
29
36
  if (!config.cookbook) throw new Error('cookbook is required');
30
37
 
31
38
  this.mqClient = config.mqClient;
32
39
  this.registryClient = config.registryClient;
33
- this.apiMapper = config.apiMapper;
40
+ this._invoker = config.invoker;
34
41
  this.cookbook = config.cookbook;
35
42
  this.cache = config.cache;
36
43
  this.errorHandler = config.errorHandler;
@@ -552,26 +559,46 @@ class WorkflowOrchestrator {
552
559
 
553
560
  const resolvedInput = await this._resolveInputReferencesAsync(step.input, context, helperContext);
554
561
  console.log(`[WorkflowOrchestrator] [RESOLVE] Step ${stepId} input AFTER:`, JSON.stringify(resolvedInput));
555
-
556
- // Use API mapper to call the service with resolved input
557
- const result = await this.apiMapper.callOperation(
558
- step.operation || stepId,
559
- resolvedInput,
560
- {
561
- ...context,
562
- workflow_id: context?.workflow_id,
563
- step_id: stepId
564
- }
565
- );
566
562
 
567
- this.logger.info(`Task step executed`, {
568
- step: stepId,
569
- service: step.service,
570
- operation: step.operation,
571
- inputResolved: !!resolvedInput
563
+ // Intra-service handler dispatch via service-wrapper v3.0.0 (RFC §5.9, §5.10).
564
+ // Replaces the retired apiMapper.callOperation HTTP-loopback path.
565
+ const envelope = await this._invoker.invokeOperation({
566
+ operation: step.operation || stepId,
567
+ input: resolvedInput,
568
+ envelope: {
569
+ tenant_id: context?.tenant_id,
570
+ workspace_id: context?.workspace_id,
571
+ person_id: context?.person_id
572
+ },
573
+ workflow_id: context?.workflow_id,
574
+ correlation_id: context?.correlation_id,
575
+ step_id: stepId
572
576
  });
573
577
 
574
- return result;
578
+ if (envelope && envelope.status >= 200 && envelope.status < 300) {
579
+ this.logger.info(`Task step executed`, {
580
+ step: stepId,
581
+ service: step.service,
582
+ operation: step.operation,
583
+ inputResolved: !!resolvedInput
584
+ });
585
+ return envelope.result;
586
+ }
587
+
588
+ // Non-2xx: surface the typed error envelope so the outer workflow handler
589
+ // can record retry_history / DLQ classification per existing logic.
590
+ const err = new Error(
591
+ `[WorkflowOrchestrator] Step '${stepId}' (operation '${step.operation}') failed with status ${envelope?.status}`
592
+ );
593
+ err.status = envelope?.status;
594
+ err.statusCode = envelope?.status;
595
+ err.code = envelope?.error?.code;
596
+ err.errorCode = envelope?.error?.code;
597
+ err.details = envelope?.error?.details;
598
+ if (envelope?.error?.message) {
599
+ err.message = envelope.error.message;
600
+ }
601
+ throw err;
575
602
  }
576
603
 
577
604
  /**
package/src/index.js CHANGED
@@ -19,7 +19,11 @@ const WorkflowOrchestrator = require('./WorkflowOrchestrator');
19
19
  * @param {Object} config - Configuration options
20
20
  * @param {Object} config.mqClient - MQ client instance
21
21
  * @param {Object} config.registryClient - Registry client instance
22
- * @param {Object} config.apiMapper - API mapper instance
22
+ * @param {Object} config.invoker - Intra-service operation invoker.
23
+ * Expected shape: `{ async invokeOperation({ operation, input, envelope,
24
+ * workflow_id, correlation_id, step_id }) -> { status, result } | { status, error } }`.
25
+ * Typically `{ invokeOperation: serviceWrapper.invokeOperation.bind(serviceWrapper) }`.
26
+ * Replaces the retired `apiMapper` HTTP-loopback dep (RFC §5.9, §5.10).
23
27
  * @param {Object} config.cookbook - Cookbook connector instance
24
28
  * @param {Object} [config.logger] - Logger instance
25
29
  * @returns {WorkflowOrchestrator} New orchestrator instance
@@ -28,7 +32,7 @@ const WorkflowOrchestrator = require('./WorkflowOrchestrator');
28
32
  * const orchestrator = create({
29
33
  * mqClient: new MQClient(),
30
34
  * registryClient: new RegistryClient(),
31
- * apiMapper: new ApiMapper(),
35
+ * invoker: { invokeOperation: wrapper.invokeOperation.bind(wrapper) },
32
36
  * cookbook: new CookbookConnector()
33
37
  * });
34
38
  */