@onlineapps/conn-orch-orchestrator 1.0.110 → 1.0.112
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/API.md +5 -34
- package/package.json +4 -4
- package/src/WorkflowOrchestrator.js +13 -35
package/API.md
CHANGED
|
@@ -22,14 +22,13 @@ Coordinates all other connectors to process workflow messages.</p>
|
|
|
22
22
|
<dt><a href="#processWorkflowMessage">processWorkflowMessage(message, serviceName)</a> ⇒ <code>Promise.<Object></code></dt>
|
|
23
23
|
<dd><p>Process a workflow message</p>
|
|
24
24
|
</dd>
|
|
25
|
-
<dt><a href="#generateCookbook">generateCookbook(openApiSpec)</a> ⇒ <code>Object</code></dt>
|
|
26
|
-
<dd><p>Generate cookbook from OpenAPI spec (utility method)</p>
|
|
27
|
-
</dd>
|
|
28
|
-
<dt><a href="#transformResponse">transformResponse(response, mapping)</a> ⇒ <code>Object</code></dt>
|
|
29
|
-
<dd><p>Transform API response using cookbook mapping</p>
|
|
30
|
-
</dd>
|
|
31
25
|
</dl>
|
|
32
26
|
|
|
27
|
+
> NOTE: `generateCookbook(openApiSpec)` and `transformResponse(response, mapping)`
|
|
28
|
+
> were removed together with the `cookbook-transformer` module when the project
|
|
29
|
+
> migrated to the operations.json-first contract.
|
|
30
|
+
> See `/api/docs/standards/operations-registry-contract.md` §3.
|
|
31
|
+
|
|
33
32
|
<a name="module_@onlineapps/conn-orch-orchestrator"></a>
|
|
34
33
|
|
|
35
34
|
## @onlineapps/conn-orch-orchestrator
|
|
@@ -164,32 +163,4 @@ const result = await orchestrator.processWorkflowMessage({
|
|
|
164
163
|
context: {}
|
|
165
164
|
}, 'hello-service');
|
|
166
165
|
```
|
|
167
|
-
<a name="generateCookbook"></a>
|
|
168
|
-
|
|
169
|
-
## generateCookbook(openApiSpec) ⇒ <code>Object</code>
|
|
170
|
-
Generate cookbook from OpenAPI spec (utility method)
|
|
171
|
-
|
|
172
|
-
**Kind**: global function
|
|
173
|
-
**Returns**: <code>Object</code> - Generated cookbook
|
|
174
|
-
|
|
175
|
-
| Param | Type | Description |
|
|
176
|
-
| --- | --- | --- |
|
|
177
|
-
| openApiSpec | <code>Object</code> | OpenAPI specification |
|
|
178
|
-
|
|
179
|
-
**Example**
|
|
180
|
-
```js
|
|
181
|
-
const cookbook = orchestrator.generateCookbook(openApiSpec);
|
|
182
|
-
```
|
|
183
|
-
<a name="transformResponse"></a>
|
|
184
|
-
|
|
185
|
-
## transformResponse(response, mapping) ⇒ <code>Object</code>
|
|
186
|
-
Transform API response using cookbook mapping
|
|
187
|
-
|
|
188
|
-
**Kind**: global function
|
|
189
|
-
**Returns**: <code>Object</code> - Transformed response
|
|
190
|
-
|
|
191
|
-
| Param | Type | Description |
|
|
192
|
-
| --- | --- | --- |
|
|
193
|
-
| response | <code>Object</code> | API response |
|
|
194
|
-
| mapping | <code>Object</code> | Output mapping |
|
|
195
166
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@onlineapps/conn-orch-orchestrator",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.112",
|
|
4
4
|
"description": "Workflow orchestration connector for OA Drive - handles message routing and workflow execution",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -21,10 +21,10 @@
|
|
|
21
21
|
"author": "OA Drive Team",
|
|
22
22
|
"license": "MIT",
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@onlineapps/conn-base-monitoring": "1.0.
|
|
24
|
+
"@onlineapps/conn-base-monitoring": "1.0.12",
|
|
25
25
|
"@onlineapps/conn-infra-mq": "1.1.70",
|
|
26
|
-
"@onlineapps/conn-orch-registry": "1.1
|
|
27
|
-
"@onlineapps/conn-orch-cookbook": "2.
|
|
26
|
+
"@onlineapps/conn-orch-registry": "1.2.1",
|
|
27
|
+
"@onlineapps/conn-orch-cookbook": "2.1.1",
|
|
28
28
|
"@onlineapps/conn-orch-api-mapper": "1.0.33"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
@@ -1120,6 +1120,18 @@ class WorkflowOrchestrator {
|
|
|
1120
1120
|
// at top level — not buried inside cookbook._system.
|
|
1121
1121
|
const sys = cookbook._system || {};
|
|
1122
1122
|
|
|
1123
|
+
// Extract api_output from the last executed step's output.
|
|
1124
|
+
// Canonical source: cookbook.steps[lastStepIndex].output.
|
|
1125
|
+
// Downstream (DeliveryDispatcher, monitoring, Admin UI) needs a flat
|
|
1126
|
+
// api_output field to surface workflow results to clients without
|
|
1127
|
+
// having to traverse the cookbook graph.
|
|
1128
|
+
let apiOutput = null;
|
|
1129
|
+
const steps = Array.isArray(finalCookbook.steps) ? finalCookbook.steps : [];
|
|
1130
|
+
const lastStep = steps[lastStepIndex] || (steps.length > 0 ? steps[steps.length - 1] : null);
|
|
1131
|
+
if (lastStep && typeof lastStep === 'object' && Object.prototype.hasOwnProperty.call(lastStep, 'output')) {
|
|
1132
|
+
apiOutput = lastStep.output ?? null;
|
|
1133
|
+
}
|
|
1134
|
+
|
|
1123
1135
|
const workflowCompletedMessage = {
|
|
1124
1136
|
workflow_id,
|
|
1125
1137
|
tenant_id: sys.tenant_id,
|
|
@@ -1129,6 +1141,7 @@ class WorkflowOrchestrator {
|
|
|
1129
1141
|
service: serviceName,
|
|
1130
1142
|
step_id: lastStepId,
|
|
1131
1143
|
step_index: lastStepIndex,
|
|
1144
|
+
api_output: apiOutput,
|
|
1132
1145
|
cookbook: finalCookbook,
|
|
1133
1146
|
delivery: cookbook.delivery || { handler: 'none' },
|
|
1134
1147
|
completed_at: new Date().toISOString()
|
|
@@ -1169,41 +1182,6 @@ class WorkflowOrchestrator {
|
|
|
1169
1182
|
return `workflow:step:${step.service}:${step.operation || stepId}:${hash}`;
|
|
1170
1183
|
}
|
|
1171
1184
|
|
|
1172
|
-
/**
|
|
1173
|
-
* Generate cookbook from OpenAPI spec (utility method)
|
|
1174
|
-
* @method generateCookbook
|
|
1175
|
-
* @param {Object} openApiSpec - OpenAPI specification
|
|
1176
|
-
* @returns {Object} Generated cookbook
|
|
1177
|
-
*
|
|
1178
|
-
* @example
|
|
1179
|
-
* const cookbook = orchestrator.generateCookbook(openApiSpec);
|
|
1180
|
-
*/
|
|
1181
|
-
generateCookbook(openApiSpec) {
|
|
1182
|
-
const { CookbookGenerator } = this.cookbook;
|
|
1183
|
-
|
|
1184
|
-
const generator = new CookbookGenerator({
|
|
1185
|
-
defaultTimeout: 10000,
|
|
1186
|
-
defaultRetry: {
|
|
1187
|
-
maxAttempts: 3,
|
|
1188
|
-
delayMs: 2000
|
|
1189
|
-
}
|
|
1190
|
-
});
|
|
1191
|
-
|
|
1192
|
-
return generator.generate(openApiSpec);
|
|
1193
|
-
}
|
|
1194
|
-
|
|
1195
|
-
/**
|
|
1196
|
-
* Transform API response using cookbook mapping
|
|
1197
|
-
* @method transformResponse
|
|
1198
|
-
* @param {Object} response - API response
|
|
1199
|
-
* @param {Object} mapping - Output mapping
|
|
1200
|
-
* @returns {Object} Transformed response
|
|
1201
|
-
*/
|
|
1202
|
-
transformResponse(response, mapping) {
|
|
1203
|
-
const { ResponseMapper } = this.cookbook;
|
|
1204
|
-
const mapper = new ResponseMapper();
|
|
1205
|
-
return mapper.mapResponse(response, mapping);
|
|
1206
|
-
}
|
|
1207
1185
|
}
|
|
1208
1186
|
|
|
1209
1187
|
module.exports = WorkflowOrchestrator;
|