@onlineapps/cookbook-core 2.1.4 → 2.1.5
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
|
@@ -29,19 +29,18 @@ class CookbookValidationError extends Error {
|
|
|
29
29
|
}
|
|
30
30
|
|
|
31
31
|
/**
|
|
32
|
-
* Load schema
|
|
32
|
+
* Load V2 schema - V1 IS BANNED, only one schema exists
|
|
33
33
|
*/
|
|
34
34
|
function loadSchema(version = '2.0') {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
}
|
|
35
|
+
// V1 is BANNED - reject immediately
|
|
36
|
+
if (version.startsWith('1.')) {
|
|
37
|
+
throw new CookbookValidationError('V1 FORMAT BANNED! Use version 2.x.x');
|
|
38
|
+
}
|
|
39
39
|
|
|
40
|
-
const
|
|
41
|
-
const schemaPath = path.join(__dirname, '../../schemas', filename);
|
|
40
|
+
const schemaPath = path.join(__dirname, '../../schemas/cookbook.schema.json');
|
|
42
41
|
|
|
43
42
|
if (!fs.existsSync(schemaPath)) {
|
|
44
|
-
throw new CookbookValidationError(
|
|
43
|
+
throw new CookbookValidationError('Schema file not found: cookbook.schema.json');
|
|
45
44
|
}
|
|
46
45
|
|
|
47
46
|
return JSON.parse(fs.readFileSync(schemaPath, 'utf-8'));
|
|
@@ -1,345 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
3
|
-
"$comment": "COOKBOOK V2 FORMAT - V1 IS BANNED! steps MUST be object keyed by step_id, NOT array!",
|
|
4
|
-
"type": "object",
|
|
5
|
-
"required": ["steps", "version"],
|
|
6
|
-
"additionalProperties": true,
|
|
7
|
-
"properties": {
|
|
8
|
-
"name": {
|
|
9
|
-
"type": "string",
|
|
10
|
-
"minLength": 1
|
|
11
|
-
},
|
|
12
|
-
"version": {
|
|
13
|
-
"type": "string",
|
|
14
|
-
"pattern": "^2\\.\\d+\\.\\d+$",
|
|
15
|
-
"description": "Semantic version - MUST be 2.x.x (V1 is banned)"
|
|
16
|
-
},
|
|
17
|
-
"description": {
|
|
18
|
-
"type": "string"
|
|
19
|
-
},
|
|
20
|
-
"api_input": {
|
|
21
|
-
"type": "object"
|
|
22
|
-
},
|
|
23
|
-
"global_error_handler": {
|
|
24
|
-
"$ref": "#/definitions/ErrorHandler",
|
|
25
|
-
"description": "Default error handling for all steps"
|
|
26
|
-
},
|
|
27
|
-
"global_retry": {
|
|
28
|
-
"$ref": "#/definitions/Retry",
|
|
29
|
-
"description": "Default retry policy for all steps"
|
|
30
|
-
},
|
|
31
|
-
"global_timeout": {
|
|
32
|
-
"type": "integer",
|
|
33
|
-
"minimum": 1,
|
|
34
|
-
"description": "Maximum execution time for entire workflow in milliseconds"
|
|
35
|
-
},
|
|
36
|
-
"metadata": {
|
|
37
|
-
"type": "object",
|
|
38
|
-
"additionalProperties": true
|
|
39
|
-
},
|
|
40
|
-
"steps": {
|
|
41
|
-
"type": "object",
|
|
42
|
-
"minProperties": 1,
|
|
43
|
-
"additionalProperties": {
|
|
44
|
-
"$ref": "#/definitions/Step"
|
|
45
|
-
},
|
|
46
|
-
"description": "V2: Object keyed by step_id (NOT array!)"
|
|
47
|
-
},
|
|
48
|
-
"delivery": {
|
|
49
|
-
"type": "object",
|
|
50
|
-
"description": "Delivery configuration for workflow results"
|
|
51
|
-
}
|
|
52
|
-
},
|
|
53
|
-
"definitions": {
|
|
54
|
-
"Step": {
|
|
55
|
-
"type": "object",
|
|
56
|
-
"required": ["step_id", "type"],
|
|
57
|
-
"oneOf": [
|
|
58
|
-
{ "$ref": "#/definitions/TaskStep" },
|
|
59
|
-
{ "$ref": "#/definitions/ForeachStep" },
|
|
60
|
-
{ "$ref": "#/definitions/ForkJoinStep" },
|
|
61
|
-
{ "$ref": "#/definitions/SwitchStep" },
|
|
62
|
-
{ "$ref": "#/definitions/SubWorkflowStep" },
|
|
63
|
-
{ "$ref": "#/definitions/WaitStep" },
|
|
64
|
-
{ "$ref": "#/definitions/DispatchStep" }
|
|
65
|
-
]
|
|
66
|
-
},
|
|
67
|
-
"TaskStep": {
|
|
68
|
-
"type": "object",
|
|
69
|
-
"required": ["step_id", "type", "service"],
|
|
70
|
-
"additionalProperties": true,
|
|
71
|
-
"properties": {
|
|
72
|
-
"step_id": {
|
|
73
|
-
"type": "string",
|
|
74
|
-
"minLength": 1,
|
|
75
|
-
"pattern": "^[a-zA-Z0-9_]+$",
|
|
76
|
-
"description": "V2: step_id (snake_case, must match object key)"
|
|
77
|
-
},
|
|
78
|
-
"type": {
|
|
79
|
-
"type": "string",
|
|
80
|
-
"const": "task"
|
|
81
|
-
},
|
|
82
|
-
"name": {
|
|
83
|
-
"type": "string",
|
|
84
|
-
"minLength": 1
|
|
85
|
-
},
|
|
86
|
-
"service": {
|
|
87
|
-
"type": "string",
|
|
88
|
-
"minLength": 1
|
|
89
|
-
},
|
|
90
|
-
"operation": {
|
|
91
|
-
"type": "string",
|
|
92
|
-
"minLength": 1,
|
|
93
|
-
"description": "Operation identifier for the service to execute"
|
|
94
|
-
},
|
|
95
|
-
"input": {
|
|
96
|
-
"type": "object",
|
|
97
|
-
"additionalProperties": true
|
|
98
|
-
},
|
|
99
|
-
"output": {
|
|
100
|
-
"type": "object",
|
|
101
|
-
"additionalProperties": true
|
|
102
|
-
},
|
|
103
|
-
"depends_on": {
|
|
104
|
-
"type": "array",
|
|
105
|
-
"items": { "type": "string" }
|
|
106
|
-
},
|
|
107
|
-
"retry": {
|
|
108
|
-
"$ref": "#/definitions/Retry"
|
|
109
|
-
},
|
|
110
|
-
"timeoutMs": {
|
|
111
|
-
"type": "integer",
|
|
112
|
-
"minimum": 1
|
|
113
|
-
},
|
|
114
|
-
"on_error": {
|
|
115
|
-
"$ref": "#/definitions/ErrorHandler"
|
|
116
|
-
},
|
|
117
|
-
"condition": {
|
|
118
|
-
"type": "string"
|
|
119
|
-
},
|
|
120
|
-
"expect": {
|
|
121
|
-
"type": "object",
|
|
122
|
-
"description": "Expected output for testing"
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
},
|
|
126
|
-
"ForeachStep": {
|
|
127
|
-
"type": "object",
|
|
128
|
-
"required": ["step_id", "type", "iterator", "body"],
|
|
129
|
-
"additionalProperties": true,
|
|
130
|
-
"properties": {
|
|
131
|
-
"step_id": {
|
|
132
|
-
"type": "string",
|
|
133
|
-
"minLength": 1,
|
|
134
|
-
"pattern": "^[a-zA-Z0-9_]+$"
|
|
135
|
-
},
|
|
136
|
-
"type": {
|
|
137
|
-
"type": "string",
|
|
138
|
-
"const": "foreach"
|
|
139
|
-
},
|
|
140
|
-
"iterator": {
|
|
141
|
-
"type": "string",
|
|
142
|
-
"minLength": 1
|
|
143
|
-
},
|
|
144
|
-
"body": {
|
|
145
|
-
"type": "object",
|
|
146
|
-
"minProperties": 1,
|
|
147
|
-
"additionalProperties": {
|
|
148
|
-
"$ref": "#/definitions/Step"
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
},
|
|
153
|
-
"ForkJoinStep": {
|
|
154
|
-
"type": "object",
|
|
155
|
-
"required": ["step_id", "type", "branches", "join"],
|
|
156
|
-
"additionalProperties": true,
|
|
157
|
-
"properties": {
|
|
158
|
-
"step_id": {
|
|
159
|
-
"type": "string",
|
|
160
|
-
"minLength": 1,
|
|
161
|
-
"pattern": "^[a-zA-Z0-9_]+$"
|
|
162
|
-
},
|
|
163
|
-
"type": {
|
|
164
|
-
"type": "string",
|
|
165
|
-
"const": "fork_join"
|
|
166
|
-
},
|
|
167
|
-
"branches": {
|
|
168
|
-
"type": "object",
|
|
169
|
-
"minProperties": 1,
|
|
170
|
-
"additionalProperties": {
|
|
171
|
-
"$ref": "#/definitions/Step"
|
|
172
|
-
}
|
|
173
|
-
},
|
|
174
|
-
"join": {
|
|
175
|
-
"type": "object",
|
|
176
|
-
"required": ["strategy"],
|
|
177
|
-
"properties": {
|
|
178
|
-
"strategy": {
|
|
179
|
-
"type": "string",
|
|
180
|
-
"enum": ["merge", "first", "last", "all", "custom"]
|
|
181
|
-
},
|
|
182
|
-
"output": {
|
|
183
|
-
"type": "object"
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
},
|
|
189
|
-
"SwitchStep": {
|
|
190
|
-
"type": "object",
|
|
191
|
-
"required": ["step_id", "type", "expression", "cases"],
|
|
192
|
-
"additionalProperties": true,
|
|
193
|
-
"properties": {
|
|
194
|
-
"step_id": {
|
|
195
|
-
"type": "string",
|
|
196
|
-
"minLength": 1,
|
|
197
|
-
"pattern": "^[a-zA-Z0-9_]+$"
|
|
198
|
-
},
|
|
199
|
-
"type": {
|
|
200
|
-
"type": "string",
|
|
201
|
-
"const": "switch"
|
|
202
|
-
},
|
|
203
|
-
"expression": {
|
|
204
|
-
"type": "string",
|
|
205
|
-
"minLength": 1
|
|
206
|
-
},
|
|
207
|
-
"cases": {
|
|
208
|
-
"type": "object",
|
|
209
|
-
"minProperties": 1,
|
|
210
|
-
"additionalProperties": {
|
|
211
|
-
"$ref": "#/definitions/Step"
|
|
212
|
-
}
|
|
213
|
-
},
|
|
214
|
-
"default": {
|
|
215
|
-
"$ref": "#/definitions/Step"
|
|
216
|
-
}
|
|
217
|
-
}
|
|
218
|
-
},
|
|
219
|
-
"SubWorkflowStep": {
|
|
220
|
-
"type": "object",
|
|
221
|
-
"required": ["step_id", "type", "steps"],
|
|
222
|
-
"additionalProperties": true,
|
|
223
|
-
"properties": {
|
|
224
|
-
"step_id": {
|
|
225
|
-
"type": "string",
|
|
226
|
-
"minLength": 1,
|
|
227
|
-
"pattern": "^[a-zA-Z0-9_]+$"
|
|
228
|
-
},
|
|
229
|
-
"type": {
|
|
230
|
-
"type": "string",
|
|
231
|
-
"const": "sub_workflow"
|
|
232
|
-
},
|
|
233
|
-
"input": {
|
|
234
|
-
"type": "object"
|
|
235
|
-
},
|
|
236
|
-
"steps": {
|
|
237
|
-
"type": "object",
|
|
238
|
-
"minProperties": 1,
|
|
239
|
-
"additionalProperties": {
|
|
240
|
-
"$ref": "#/definitions/Step"
|
|
241
|
-
}
|
|
242
|
-
}
|
|
243
|
-
}
|
|
244
|
-
},
|
|
245
|
-
"WaitStep": {
|
|
246
|
-
"type": "object",
|
|
247
|
-
"required": ["step_id", "type", "durationMs"],
|
|
248
|
-
"additionalProperties": true,
|
|
249
|
-
"properties": {
|
|
250
|
-
"step_id": {
|
|
251
|
-
"type": "string",
|
|
252
|
-
"minLength": 1,
|
|
253
|
-
"pattern": "^[a-zA-Z0-9_]+$"
|
|
254
|
-
},
|
|
255
|
-
"type": {
|
|
256
|
-
"type": "string",
|
|
257
|
-
"const": "wait"
|
|
258
|
-
},
|
|
259
|
-
"durationMs": {
|
|
260
|
-
"type": "integer",
|
|
261
|
-
"minimum": 0
|
|
262
|
-
}
|
|
263
|
-
}
|
|
264
|
-
},
|
|
265
|
-
"DispatchStep": {
|
|
266
|
-
"type": "object",
|
|
267
|
-
"required": ["step_id", "type", "method", "target"],
|
|
268
|
-
"additionalProperties": true,
|
|
269
|
-
"properties": {
|
|
270
|
-
"step_id": {
|
|
271
|
-
"type": "string",
|
|
272
|
-
"minLength": 1,
|
|
273
|
-
"pattern": "^[a-zA-Z0-9_]+$"
|
|
274
|
-
},
|
|
275
|
-
"type": {
|
|
276
|
-
"type": "string",
|
|
277
|
-
"const": "dispatch"
|
|
278
|
-
},
|
|
279
|
-
"method": {
|
|
280
|
-
"type": "string",
|
|
281
|
-
"enum": ["webhook", "http", "grpc", "kafka", "sqs", "custom"]
|
|
282
|
-
},
|
|
283
|
-
"target": {
|
|
284
|
-
"type": "string",
|
|
285
|
-
"format": "uri"
|
|
286
|
-
},
|
|
287
|
-
"input": {
|
|
288
|
-
"type": "object"
|
|
289
|
-
},
|
|
290
|
-
"retry": {
|
|
291
|
-
"$ref": "#/definitions/Retry"
|
|
292
|
-
}
|
|
293
|
-
}
|
|
294
|
-
},
|
|
295
|
-
"Retry": {
|
|
296
|
-
"type": "object",
|
|
297
|
-
"required": ["maxAttempts", "delayMs"],
|
|
298
|
-
"additionalProperties": false,
|
|
299
|
-
"properties": {
|
|
300
|
-
"maxAttempts": {
|
|
301
|
-
"type": "integer",
|
|
302
|
-
"minimum": 1
|
|
303
|
-
},
|
|
304
|
-
"delayMs": {
|
|
305
|
-
"type": "integer",
|
|
306
|
-
"minimum": 0
|
|
307
|
-
},
|
|
308
|
-
"backoffMultiplier": {
|
|
309
|
-
"type": "number",
|
|
310
|
-
"minimum": 1.0,
|
|
311
|
-
"maximum": 5.0
|
|
312
|
-
}
|
|
313
|
-
}
|
|
314
|
-
},
|
|
315
|
-
"ErrorHandler": {
|
|
316
|
-
"type": "object",
|
|
317
|
-
"required": ["strategy"],
|
|
318
|
-
"additionalProperties": false,
|
|
319
|
-
"properties": {
|
|
320
|
-
"strategy": {
|
|
321
|
-
"type": "string",
|
|
322
|
-
"enum": ["retry", "fail", "continue", "compensate", "fallback"]
|
|
323
|
-
},
|
|
324
|
-
"retries": {
|
|
325
|
-
"type": "integer",
|
|
326
|
-
"minimum": 0,
|
|
327
|
-
"maximum": 10
|
|
328
|
-
},
|
|
329
|
-
"retryDelayMs": {
|
|
330
|
-
"type": "integer",
|
|
331
|
-
"minimum": 0
|
|
332
|
-
},
|
|
333
|
-
"fallbackStep": {
|
|
334
|
-
"type": "string"
|
|
335
|
-
},
|
|
336
|
-
"compensationStep": {
|
|
337
|
-
"type": "string"
|
|
338
|
-
},
|
|
339
|
-
"errorOutput": {
|
|
340
|
-
"type": "string"
|
|
341
|
-
}
|
|
342
|
-
}
|
|
343
|
-
}
|
|
344
|
-
}
|
|
345
|
-
}
|