@onlineapps/conn-orch-orchestrator 2.0.1 → 2.0.3
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 +2 -2
- package/src/WorkflowOrchestrator.js +29 -17
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@onlineapps/conn-orch-orchestrator",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.3",
|
|
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,7 +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.
|
|
27
|
+
"@onlineapps/conn-orch-cookbook": "2.1.3"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
30
|
"jest": "^29.5.0",
|
|
@@ -79,6 +79,8 @@ class WorkflowOrchestrator {
|
|
|
79
79
|
* legacy placements from transports that move AMQP headers onto the
|
|
80
80
|
* parsed message object. Returns undefined if none are set - the caller
|
|
81
81
|
* is responsible for fail-fast.
|
|
82
|
+
*
|
|
83
|
+
* @see api/docs/standards/workflow-message-contract.md
|
|
82
84
|
* @private
|
|
83
85
|
* @param {Object} message - Inbound workflow message
|
|
84
86
|
* @returns {string|undefined}
|
|
@@ -173,23 +175,30 @@ class WorkflowOrchestrator {
|
|
|
173
175
|
async processWorkflowMessage(message, serviceName) {
|
|
174
176
|
const { workflow_id, cookbook: cookbookDef, current_step } = message;
|
|
175
177
|
const startTime = Date.now();
|
|
176
|
-
|
|
177
|
-
//
|
|
178
|
-
//
|
|
179
|
-
//
|
|
180
|
-
// The gateway must publish it; if it does not, that is a gateway bug
|
|
181
|
-
// we want to surface loudly rather than silently produce 500s inside
|
|
182
|
-
// invokeOperation's ContextBuilder.
|
|
178
|
+
// correlation_id is required by RFC §5.8 — validated below inside the
|
|
179
|
+
// try block so malformed messages flow through the retry/DLQ pipeline
|
|
180
|
+
// and a `failed` monitoring event is emitted (no silent redelivery).
|
|
181
|
+
// @see api/docs/standards/workflow-message-contract.md
|
|
183
182
|
const correlationId = this._extractCorrelationId(message);
|
|
184
|
-
if (typeof correlationId !== 'string' || correlationId.length === 0) {
|
|
185
|
-
throw new Error(
|
|
186
|
-
'[WorkflowOrchestrator] message.correlation_id is required - ' +
|
|
187
|
-
`Expected non-empty string on inbound workflow message (workflow_id='${workflow_id}', step='${current_step}'). ` +
|
|
188
|
-
'Fix: ensure publisher (gateway / router) sets correlation_id on message body per RFC §5.8.'
|
|
189
|
-
);
|
|
190
|
-
}
|
|
191
183
|
|
|
192
184
|
try {
|
|
185
|
+
// Fail-fast: correlation_id MUST be present on every workflow message.
|
|
186
|
+
// (ContextBuilder._validateMqMessage rejects empty strings too.)
|
|
187
|
+
// Gateway is expected to publish it; if it does not, that is a gateway
|
|
188
|
+
// bug we want to surface loudly rather than silently produce 500s
|
|
189
|
+
// inside invokeOperation's ContextBuilder.
|
|
190
|
+
if (typeof correlationId !== 'string' || correlationId.length === 0) {
|
|
191
|
+
const err = new Error(
|
|
192
|
+
'[WorkflowOrchestrator] message.correlation_id is required - ' +
|
|
193
|
+
`Expected non-empty string on inbound workflow message (workflow_id='${workflow_id}', step='${current_step}'). ` +
|
|
194
|
+
'Fix: ensure publisher (gateway / router) sets correlation_id on message body per RFC §5.8.'
|
|
195
|
+
);
|
|
196
|
+
err.errorCode = 'MISSING_CORRELATION_ID';
|
|
197
|
+
err.statusCode = 400;
|
|
198
|
+
err.type = 'VALIDATION';
|
|
199
|
+
throw err;
|
|
200
|
+
}
|
|
201
|
+
|
|
193
202
|
// Validate cookbook structure
|
|
194
203
|
this.cookbook.validateCookbook(cookbookDef);
|
|
195
204
|
|
|
@@ -629,7 +638,8 @@ class WorkflowOrchestrator {
|
|
|
629
638
|
data: context,
|
|
630
639
|
workflow_id: context?.workflow_id || null,
|
|
631
640
|
step_id: stepId,
|
|
632
|
-
service: serviceName || null
|
|
641
|
+
service: serviceName || null,
|
|
642
|
+
logger: this.logger
|
|
633
643
|
};
|
|
634
644
|
|
|
635
645
|
const resolvedInput = await this._resolveInputReferencesAsync(step.input, context, helperContext);
|
|
@@ -961,7 +971,8 @@ class WorkflowOrchestrator {
|
|
|
961
971
|
data: context,
|
|
962
972
|
workflow_id: context?.workflow_id || null,
|
|
963
973
|
step_id: stepId,
|
|
964
|
-
service: serviceName || null
|
|
974
|
+
service: serviceName || null,
|
|
975
|
+
logger: this.logger
|
|
965
976
|
};
|
|
966
977
|
|
|
967
978
|
const iteratorResolved = await this._resolveInputReferencesAsync(step.iterator, context, helperContext);
|
|
@@ -1015,7 +1026,8 @@ class WorkflowOrchestrator {
|
|
|
1015
1026
|
data: context,
|
|
1016
1027
|
workflow_id: context?.workflow_id || null,
|
|
1017
1028
|
step_id: stepId,
|
|
1018
|
-
service: serviceName || null
|
|
1029
|
+
service: serviceName || null,
|
|
1030
|
+
logger: this.logger
|
|
1019
1031
|
};
|
|
1020
1032
|
|
|
1021
1033
|
const value = await this._evaluateSwitchExpression(step.expression, context, helperContext);
|