@onlineapps/conn-orch-cookbook 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/LICENSE CHANGED
File without changes
package/README.md CHANGED
@@ -1,10 +1,10 @@
1
- # @onlineapps/connector-cookbook
1
+ # @onlineapps/conn-orch-cookbook
2
2
 
3
3
  > Complete cookbook toolkit for ALL services - unified wrapper including core, executor, transformer, and router functionality
4
4
 
5
5
  ## 🚀 Version 2.0 - Major Update
6
6
 
7
- The `connector-cookbook` package (v2.0) is now a complete toolkit that combines all cookbook functionality in one unified package. This ensures architectural consistency across ALL services including infrastructure components like workflow_launcher.
7
+ The `conn-orch-cookbook` package (v2.0) is now a complete toolkit that combines all cookbook functionality in one unified package. This ensures architectural consistency across ALL services including infrastructure components like workflow_launcher.
8
8
 
9
9
  ### What's New in v2.0
10
10
 
@@ -24,9 +24,9 @@ Per architectural decision, ALL services including workflow_launcher use this si
24
24
  ## 📦 Installation
25
25
 
26
26
  ```bash
27
- npm install @onlineapps/connector-cookbook
27
+ npm install @onlineapps/conn-orch-cookbook
28
28
  # or
29
- yarn add @onlineapps/connector-cookbook
29
+ yarn add @onlineapps/conn-orch-cookbook
30
30
  ```
31
31
 
32
32
  ## 🔧 Quick Start
@@ -37,7 +37,7 @@ yarn add @onlineapps/connector-cookbook
37
37
  const {
38
38
  parseCookbookFromFile,
39
39
  validateCookbook
40
- } = require('@onlineapps/connector-cookbook');
40
+ } = require('@onlineapps/conn-orch-cookbook');
41
41
 
42
42
  // Works exactly as before
43
43
  const cookbook = await parseCookbookFromFile('./workflow.json');
@@ -47,7 +47,7 @@ validateCookbook(cookbook);
47
47
  ### New Modular Approach (v2.0)
48
48
 
49
49
  ```javascript
50
- const cookbook = require('@onlineapps/connector-cookbook');
50
+ const cookbook = require('@onlineapps/conn-orch-cookbook');
51
51
 
52
52
  // Use specific modules
53
53
  const { CookbookExecutor } = cookbook.executor;
@@ -92,9 +92,9 @@ const processor = cookbook.createProcessor({
92
92
  ### Complete Service Implementation
93
93
 
94
94
  ```javascript
95
- const cookbook = require('@onlineapps/connector-cookbook');
96
- const MQClient = require('@onlineapps/connector-mq-client');
97
- const RegistryClient = require('@onlineapps/connector-registry-client');
95
+ const cookbook = require('@onlineapps/conn-orch-cookbook');
96
+ const MQClient = require('@onlineapps/conn-infra-mq');
97
+ const RegistryClient = require('@onlineapps/conn-orch-registry');
98
98
 
99
99
  class MyService {
100
100
  constructor() {
@@ -133,7 +133,7 @@ class MyService {
133
133
 
134
134
  ```javascript
135
135
  // workflow_launcher uses the SAME package
136
- const cookbook = require('@onlineapps/connector-cookbook');
136
+ const cookbook = require('@onlineapps/conn-orch-cookbook');
137
137
 
138
138
  class WorkflowLauncher {
139
139
  async handleWorkflowInit(message) {
@@ -152,7 +152,7 @@ class WorkflowLauncher {
152
152
  ### OpenAPI Integration
153
153
 
154
154
  ```javascript
155
- const { CookbookGenerator } = require('@onlineapps/connector-cookbook');
155
+ const { CookbookGenerator } = require('@onlineapps/conn-orch-cookbook');
156
156
 
157
157
  const generator = new CookbookGenerator({
158
158
  defaultTimeout: 10000,
@@ -166,29 +166,30 @@ const cookbook = generator.generate(openApiSpec);
166
166
 
167
167
  ## 📖 Cookbook Structure
168
168
 
169
- ### Basic Example
169
+ ### Basic Example (v2.0 Schema)
170
170
  ```json
171
171
  {
172
- "version": "1.0.0",
172
+ "version": "2.0.0",
173
173
  "api_input": {
174
174
  "customer": "ACME Corp",
175
175
  "amount": 1000
176
176
  },
177
177
  "steps": [
178
178
  {
179
- "id": "invoice_step",
179
+ "step_id": "invoice_step",
180
180
  "type": "task",
181
- "service": "invoice_service",
181
+ "service": "invoice-service",
182
+ "operation": "createInvoice",
182
183
  "input": {
183
- "customer": "$api_input.customer",
184
- "amount": "$api_input.amount"
184
+ "customer": "${api_input.customer}",
185
+ "amount": "${api_input.amount}"
185
186
  },
186
187
  "output": {
187
- "invoice_id": "$.invoice_id"
188
+ "invoice_id": "${response.invoice_id}"
188
189
  },
189
190
  "retry": {
190
- "maxAttempts": 3,
191
- "delayMs": 2000
191
+ "max_attempts": 3,
192
+ "delay_ms": 2000
192
193
  }
193
194
  }
194
195
  ]
@@ -207,13 +208,54 @@ All 7 step types are fully supported:
207
208
  - **wait** - Time delays
208
209
  - **dispatch** - Webhook dispatching
209
210
 
211
+ ## 📤 Delivery Block (v2.1)
212
+
213
+ Cookbook nově může definovat top-level sekci `delivery`, která popisuje způsob
214
+ doručení výsledku klientovi:
215
+
216
+ ```json
217
+ "delivery": {
218
+ "handler": "dispatcher",
219
+ "allow_skip": false,
220
+ "destinations": [
221
+ {
222
+ "type": "webhook",
223
+ "url": "https://client.example.com/api/callback",
224
+ "method": "POST",
225
+ "retry": {
226
+ "max_attempts": 5,
227
+ "delay_ms": 3000
228
+ }
229
+ },
230
+ {
231
+ "type": "public_url",
232
+ "path": "result/${context.workflow_id}/invoice.pdf",
233
+ "ttl_seconds": 86400,
234
+ "access": "signed"
235
+ }
236
+ ],
237
+ "output": {
238
+ "workflow_id": "${context.workflow_id}",
239
+ "invoice_id": "${steps.invoice_step.output.invoice_id}"
240
+ }
241
+ }
242
+ ```
243
+
244
+ - `handler`: `dispatcher` (výchozí), `service_step`, nebo `none`.
245
+ - `destinations`: konkrétní výstupy (`webhook`, `websocket`, `public_url`).
246
+ - `output`: mapování hodnot, které se mají doručit.
247
+
248
+ Detailní specifikace viz
249
+ [Schema Final Specification](/shared/cookbook/cookbook-core/docs/SCHEMA_FINAL_SPECIFICATION.md#11-delivery-blok)
250
+ nebo [API Delivery Dispatcher](../../../docs/architecture/api-delivery-dispatcher.md).
251
+
210
252
  ## 🔄 Migration from v1.x
211
253
 
212
254
  Version 2.0 maintains full backward compatibility. Existing code continues to work without changes:
213
255
 
214
256
  ```javascript
215
257
  // This still works exactly as before
216
- const { parseCookbookFromFile } = require('@onlineapps/connector-cookbook');
258
+ const { parseCookbookFromFile } = require('@onlineapps/conn-orch-cookbook');
217
259
  const cookbook = await parseCookbookFromFile('./workflow.json');
218
260
  ```
219
261
 
@@ -221,7 +263,7 @@ To access new features, use the modular exports:
221
263
 
222
264
  ```javascript
223
265
  // New modular approach
224
- const { executor, router, transformer } = require('@onlineapps/connector-cookbook');
266
+ const { executor, router, transformer } = require('@onlineapps/conn-orch-cookbook');
225
267
  ```
226
268
 
227
269
  ## 📋 API Reference
@@ -250,25 +292,33 @@ npm run test:integration # Integration tests
250
292
 
251
293
  ## ⚠️ Important Notes
252
294
 
253
- ### Schema Validation Strictness
254
- The current schema validation is very strict. See [Schema Audit Report](/shared/cookbook/cookbook-core/docs/SCHEMA_AUDIT.md) for detailed analysis and recommendations.
295
+ ### Schema v2.0 Update
296
+ The cookbook schema has been updated to version 2.0 with improved semantics and consistency:
255
297
 
256
- **Known Issues:**
257
- - All step types incorrectly require `service`, `input`, and `output` fields
258
- - `type` field should be required but isn't
259
- - Some control flow steps (foreach, switch) have unnecessary field requirements
298
+ **Major Changes:**
299
+ - All naming conventions now use snake_case (not camelCase)
300
+ - Field `id` renamed to `step_id` for clarity
301
+ - Field `operation` is now required only for task steps (maps to OpenAPI operationId)
302
+ - Removed explicit `queue` field (now implicit from service name)
303
+ - Added comprehensive error handling and compensation support
260
304
 
261
- **Workaround:** Until schema is updated, include all required fields even if not used:
305
+ **Example v2.0 step:**
262
306
  ```javascript
263
307
  {
308
+ step_id: 'process_items',
264
309
  type: 'foreach',
265
- service: 'dummy-service', // Not actually used
266
- input: {}, // Not actually used
267
- output: {}, // Optional but may be required by schema
268
- // ... actual foreach fields
310
+ iterator: '${api_input.items}',
311
+ steps: [
312
+ // nested steps
313
+ ],
314
+ output: {
315
+ processed_items: '${foreach.results}'
316
+ }
269
317
  }
270
318
  ```
271
319
 
320
+ See [Schema v2.0 Specification](/shared/cookbook/cookbook-core/docs/SCHEMA_FINAL_SPECIFICATION.md) for full details.
321
+
272
322
  ## 📄 License
273
323
 
274
324
  PROPRIETARY - All rights reserved
@@ -0,0 +1,117 @@
1
+ # Cookbook Connector - Detailed API Documentation
2
+
3
+ ## API Methods
4
+
5
+ ### CookbookConnector Class
6
+
7
+ ```javascript
8
+ class CookbookConnector {
9
+ validateCookbook(cookbook) // Validates entire cookbook
10
+ getCurrentStep(cookbook, stepIndex) // Returns current step details
11
+ getNextStepIndex(cookbook, currentIndex, results) // Determines next step
12
+ evaluateCondition(condition, context) // For conditional flows
13
+ expandForeach(foreachStep, items) // Expands foreach into steps
14
+ }
15
+ ```
16
+
17
+ ## What it DOES
18
+
19
+ - Parses cookbook JSON structure
20
+ - Validates cookbook schema
21
+ - Extracts step information (service, operation, params)
22
+ - Determines step sequence (next, previous)
23
+ - Handles control flow logic (if, foreach, fork_join)
24
+
25
+ ## What it DOES NOT do
26
+
27
+ - Does NOT execute operations
28
+ - Does NOT make HTTP calls
29
+ - Does NOT route messages
30
+ - Does NOT handle errors
31
+
32
+ ## Usage Example
33
+
34
+ ```javascript
35
+ const { CookbookConnector } = require('@onlineapps/conn-orch-cookbook');
36
+
37
+ const connector = new CookbookConnector();
38
+
39
+ // Validate cookbook
40
+ const isValid = await connector.validateCookbook(cookbook);
41
+
42
+ // Get current step
43
+ const step = connector.getCurrentStep(cookbook, 0);
44
+ // Returns: { service: 'hello-service', operation: 'greet', params: {...} }
45
+
46
+ // Determine next step based on results
47
+ const nextIndex = connector.getNextStepIndex(cookbook, 0, stepResults);
48
+ // Returns: 1 (or -1 if workflow complete)
49
+
50
+ // Evaluate conditional logic
51
+ const shouldProceed = connector.evaluateCondition(
52
+ step.condition,
53
+ { result: stepResults }
54
+ );
55
+
56
+ // Expand foreach into multiple steps
57
+ const expandedSteps = connector.expandForeach(foreachStep, itemArray);
58
+ ```
59
+
60
+ ## Control Flow Patterns
61
+
62
+ ### Sequential Execution
63
+ ```javascript
64
+ steps: [
65
+ { service: 'service1', operation: 'op1' },
66
+ { service: 'service2', operation: 'op2' },
67
+ { service: 'service3', operation: 'op3' }
68
+ ]
69
+ ```
70
+
71
+ ### Conditional Execution
72
+ ```javascript
73
+ {
74
+ service: 'service1',
75
+ operation: 'check',
76
+ condition: 'result.status === "approved"',
77
+ next_if_true: 'approve_step',
78
+ next_if_false: 'reject_step'
79
+ }
80
+ ```
81
+
82
+ ### Parallel Execution (Fork-Join)
83
+ ```javascript
84
+ {
85
+ type: 'fork_join',
86
+ parallel_steps: [
87
+ { service: 'service1', operation: 'op1' },
88
+ { service: 'service2', operation: 'op2' },
89
+ { service: 'service3', operation: 'op3' }
90
+ ],
91
+ join_strategy: 'all' // or 'any', 'threshold'
92
+ }
93
+ ```
94
+
95
+ ### Iteration (Foreach)
96
+ ```javascript
97
+ {
98
+ type: 'foreach',
99
+ items: 'context.items',
100
+ step_template: {
101
+ service: 'processor',
102
+ operation: 'process_item',
103
+ params: { item: '{{current_item}}' }
104
+ }
105
+ }
106
+ ```
107
+
108
+ ## Error Handling
109
+
110
+ The connector validates but does NOT handle errors. Error handling is done by:
111
+ - `conn-infra-error-handler` for error classification
112
+ - Service wrapper for retry logic
113
+ - MQ connector for DLQ routing
114
+
115
+ ## Testing
116
+
117
+ See test examples in `/test/unit/` and `/test/integration/` directories.
File without changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@onlineapps/conn-orch-cookbook",
3
- "version": "2.0.1",
3
+ "version": "2.0.3",
4
4
  "description": "Complete cookbook toolkit for all services - unified wrapper including core, executor, transformer, and router functionality",
5
5
  "main": "src/index.js",
6
6
  "repository": {
@@ -20,8 +20,8 @@
20
20
  "test:unit": "jest --testPathPattern=unit --coverage",
21
21
  "test:component": "jest --testPathPattern=component --coverage",
22
22
  "test:integration": "jest --testPathPattern=integration --coverage",
23
- "test:fixtures": "jest test/integration/cookbook-fixtures.test.js",
24
- "test:smoke": "jest test/smoke.test.js",
23
+ "test:fixtures": "jest tests/integration/cookbook-fixtures.test.js",
24
+ "test:smoke": "jest tests/smoke.test.js",
25
25
  "test:watch": "jest --watch",
26
26
  "test:coverage": "jest --coverage --coverageReporters=text-lcov html",
27
27
  "lint": "eslint \"src/**/*.js\" \"tests/**/*.js\"",
@@ -46,10 +46,11 @@
46
46
  },
47
47
  "homepage": "https://github.com/onlineapps/connector-cookbook#readme",
48
48
  "dependencies": {
49
- "@onlineapps/cookbook-core": "^1.0.0",
49
+ "@onlineapps/cookbook-core": "^2.0.0",
50
50
  "@onlineapps/cookbook-executor": "^1.0.0",
51
51
  "@onlineapps/cookbook-router": "^1.0.0",
52
- "@onlineapps/cookbook-transformer": "^1.0.0"
52
+ "@onlineapps/cookbook-transformer": "1.1.0",
53
+ "jsonpath": "^1.1.1"
53
54
  },
54
55
  "devDependencies": {
55
56
  "eslint": "^8.30.0",
package/src/index.js CHANGED
File without changes