@onlineapps/cookbook-core 2.1.0 → 2.1.2
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,9 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@onlineapps/cookbook-core",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.2",
|
|
4
4
|
"description": "Core cookbook parsing and validation - lightweight foundation for workflow definitions",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"scripts": {
|
|
7
|
+
"prepublishOnly": "../../../scripts/pre-publish-compatibility-check.sh",
|
|
8
|
+
"postpublish": "../../../scripts/update-manifest-from-npm.sh && ../../../scripts/update-all-services.sh",
|
|
7
9
|
"test": "jest",
|
|
8
10
|
"test:watch": "jest --watch",
|
|
9
11
|
"test:coverage": "jest --coverage",
|
|
@@ -35,4 +37,4 @@
|
|
|
35
37
|
"publishConfig": {
|
|
36
38
|
"access": "public"
|
|
37
39
|
}
|
|
38
|
-
}
|
|
40
|
+
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
{
|
|
2
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!",
|
|
3
4
|
"type": "object",
|
|
4
5
|
"required": ["steps", "version"],
|
|
5
6
|
"additionalProperties": true,
|
|
@@ -10,8 +11,8 @@
|
|
|
10
11
|
},
|
|
11
12
|
"version": {
|
|
12
13
|
"type": "string",
|
|
13
|
-
"pattern": "
|
|
14
|
-
"description": "Semantic version
|
|
14
|
+
"pattern": "^2\\.\\d+\\.\\d+$",
|
|
15
|
+
"description": "Semantic version - MUST be 2.x.x (V1 is banned)"
|
|
15
16
|
},
|
|
16
17
|
"description": {
|
|
17
18
|
"type": "string"
|
|
@@ -34,50 +35,25 @@
|
|
|
34
35
|
},
|
|
35
36
|
"metadata": {
|
|
36
37
|
"type": "object",
|
|
37
|
-
"properties": {
|
|
38
|
-
"tags": {
|
|
39
|
-
"type": "array",
|
|
40
|
-
"items": {
|
|
41
|
-
"type": "string"
|
|
42
|
-
}
|
|
43
|
-
},
|
|
44
|
-
"priority": {
|
|
45
|
-
"type": "integer",
|
|
46
|
-
"minimum": 0,
|
|
47
|
-
"maximum": 10
|
|
48
|
-
},
|
|
49
|
-
"deprecated": {
|
|
50
|
-
"type": "boolean"
|
|
51
|
-
},
|
|
52
|
-
"deprecationMessage": {
|
|
53
|
-
"type": "string"
|
|
54
|
-
},
|
|
55
|
-
"author": {
|
|
56
|
-
"type": "string"
|
|
57
|
-
},
|
|
58
|
-
"created": {
|
|
59
|
-
"type": "string",
|
|
60
|
-
"format": "date-time"
|
|
61
|
-
},
|
|
62
|
-
"modified": {
|
|
63
|
-
"type": "string",
|
|
64
|
-
"format": "date-time"
|
|
65
|
-
}
|
|
66
|
-
},
|
|
67
38
|
"additionalProperties": true
|
|
68
39
|
},
|
|
69
40
|
"steps": {
|
|
70
|
-
"type": "
|
|
71
|
-
"
|
|
72
|
-
"
|
|
41
|
+
"type": "object",
|
|
42
|
+
"minProperties": 1,
|
|
43
|
+
"additionalProperties": {
|
|
73
44
|
"$ref": "#/definitions/Step"
|
|
74
|
-
}
|
|
45
|
+
},
|
|
46
|
+
"description": "V2: Object keyed by step_id (NOT array!)"
|
|
47
|
+
},
|
|
48
|
+
"delivery": {
|
|
49
|
+
"type": "object",
|
|
50
|
+
"description": "Delivery configuration for workflow results"
|
|
75
51
|
}
|
|
76
52
|
},
|
|
77
53
|
"definitions": {
|
|
78
54
|
"Step": {
|
|
79
55
|
"type": "object",
|
|
80
|
-
"required": ["
|
|
56
|
+
"required": ["step_id", "type"],
|
|
81
57
|
"oneOf": [
|
|
82
58
|
{ "$ref": "#/definitions/TaskStep" },
|
|
83
59
|
{ "$ref": "#/definitions/ForeachStep" },
|
|
@@ -90,12 +66,14 @@
|
|
|
90
66
|
},
|
|
91
67
|
"TaskStep": {
|
|
92
68
|
"type": "object",
|
|
93
|
-
"required": ["
|
|
69
|
+
"required": ["step_id", "type", "service"],
|
|
94
70
|
"additionalProperties": true,
|
|
95
71
|
"properties": {
|
|
96
|
-
"
|
|
72
|
+
"step_id": {
|
|
97
73
|
"type": "string",
|
|
98
|
-
"minLength": 1
|
|
74
|
+
"minLength": 1,
|
|
75
|
+
"pattern": "^[a-zA-Z0-9_]+$",
|
|
76
|
+
"description": "V2: step_id (snake_case, must match object key)"
|
|
99
77
|
},
|
|
100
78
|
"type": {
|
|
101
79
|
"type": "string",
|
|
@@ -109,14 +87,6 @@
|
|
|
109
87
|
"type": "string",
|
|
110
88
|
"minLength": 1
|
|
111
89
|
},
|
|
112
|
-
"action": {
|
|
113
|
-
"type": "string",
|
|
114
|
-
"enum": ["GET", "POST", "PUT", "DELETE", "PATCH"]
|
|
115
|
-
},
|
|
116
|
-
"endpoint": {
|
|
117
|
-
"type": "string",
|
|
118
|
-
"minLength": 1
|
|
119
|
-
},
|
|
120
90
|
"operation": {
|
|
121
91
|
"type": "string",
|
|
122
92
|
"minLength": 1,
|
|
@@ -124,20 +94,15 @@
|
|
|
124
94
|
},
|
|
125
95
|
"input": {
|
|
126
96
|
"type": "object",
|
|
127
|
-
"additionalProperties": true
|
|
128
|
-
"description": "Optional input mapping - supports all JSON types"
|
|
97
|
+
"additionalProperties": true
|
|
129
98
|
},
|
|
130
99
|
"output": {
|
|
131
100
|
"type": "object",
|
|
132
|
-
"additionalProperties": true
|
|
133
|
-
"description": "Optional output mapping - supports all JSON types"
|
|
101
|
+
"additionalProperties": true
|
|
134
102
|
},
|
|
135
103
|
"depends_on": {
|
|
136
104
|
"type": "array",
|
|
137
|
-
"items": {
|
|
138
|
-
"type": "string",
|
|
139
|
-
"minLength": 1
|
|
140
|
-
}
|
|
105
|
+
"items": { "type": "string" }
|
|
141
106
|
},
|
|
142
107
|
"retry": {
|
|
143
108
|
"$ref": "#/definitions/Retry"
|
|
@@ -150,130 +115,91 @@
|
|
|
150
115
|
"$ref": "#/definitions/ErrorHandler"
|
|
151
116
|
},
|
|
152
117
|
"condition": {
|
|
153
|
-
"type": "string"
|
|
154
|
-
|
|
118
|
+
"type": "string"
|
|
119
|
+
},
|
|
120
|
+
"expect": {
|
|
121
|
+
"type": "object",
|
|
122
|
+
"description": "Expected output for testing"
|
|
155
123
|
}
|
|
156
|
-
},
|
|
157
|
-
"condition": {
|
|
158
|
-
"type": "string",
|
|
159
|
-
"description": "JSONPath expression for conditional execution"
|
|
160
|
-
},
|
|
161
|
-
"timeoutMs": {
|
|
162
|
-
"type": "integer",
|
|
163
|
-
"minimum": 1,
|
|
164
|
-
"description": "Timeout for entire foreach loop"
|
|
165
|
-
},
|
|
166
|
-
"on_error": {
|
|
167
|
-
"$ref": "#/definitions/ErrorHandler"
|
|
168
124
|
}
|
|
169
125
|
},
|
|
170
126
|
"ForeachStep": {
|
|
171
127
|
"type": "object",
|
|
172
|
-
"required": ["
|
|
128
|
+
"required": ["step_id", "type", "iterator", "body"],
|
|
173
129
|
"additionalProperties": true,
|
|
174
130
|
"properties": {
|
|
175
|
-
"
|
|
131
|
+
"step_id": {
|
|
176
132
|
"type": "string",
|
|
177
|
-
"minLength": 1
|
|
133
|
+
"minLength": 1,
|
|
134
|
+
"pattern": "^[a-zA-Z0-9_]+$"
|
|
178
135
|
},
|
|
179
136
|
"type": {
|
|
180
137
|
"type": "string",
|
|
181
138
|
"const": "foreach"
|
|
182
139
|
},
|
|
183
|
-
"name": {
|
|
184
|
-
"type": "string",
|
|
185
|
-
"minLength": 1
|
|
186
|
-
},
|
|
187
140
|
"iterator": {
|
|
188
141
|
"type": "string",
|
|
189
142
|
"minLength": 1
|
|
190
143
|
},
|
|
191
144
|
"body": {
|
|
192
|
-
"type": "
|
|
193
|
-
"
|
|
194
|
-
"
|
|
145
|
+
"type": "object",
|
|
146
|
+
"minProperties": 1,
|
|
147
|
+
"additionalProperties": {
|
|
195
148
|
"$ref": "#/definitions/Step"
|
|
196
149
|
}
|
|
197
|
-
},
|
|
198
|
-
"output": {
|
|
199
|
-
"type": "object",
|
|
200
|
-
"additionalProperties": true,
|
|
201
|
-
"description": "Optional output collection mapping"
|
|
202
150
|
}
|
|
203
151
|
}
|
|
204
152
|
},
|
|
205
153
|
"ForkJoinStep": {
|
|
206
154
|
"type": "object",
|
|
207
|
-
"required": ["
|
|
155
|
+
"required": ["step_id", "type", "branches", "join"],
|
|
208
156
|
"additionalProperties": true,
|
|
209
157
|
"properties": {
|
|
210
|
-
"
|
|
158
|
+
"step_id": {
|
|
211
159
|
"type": "string",
|
|
212
|
-
"minLength": 1
|
|
160
|
+
"minLength": 1,
|
|
161
|
+
"pattern": "^[a-zA-Z0-9_]+$"
|
|
213
162
|
},
|
|
214
163
|
"type": {
|
|
215
164
|
"type": "string",
|
|
216
165
|
"const": "fork_join"
|
|
217
166
|
},
|
|
218
|
-
"name": {
|
|
219
|
-
"type": "string",
|
|
220
|
-
"minLength": 1
|
|
221
|
-
},
|
|
222
167
|
"branches": {
|
|
223
|
-
"type": "
|
|
224
|
-
"
|
|
225
|
-
"
|
|
168
|
+
"type": "object",
|
|
169
|
+
"minProperties": 1,
|
|
170
|
+
"additionalProperties": {
|
|
226
171
|
"$ref": "#/definitions/Step"
|
|
227
172
|
}
|
|
228
173
|
},
|
|
229
174
|
"join": {
|
|
230
175
|
"type": "object",
|
|
231
176
|
"required": ["strategy"],
|
|
232
|
-
"additionalProperties": false,
|
|
233
177
|
"properties": {
|
|
234
178
|
"strategy": {
|
|
235
179
|
"type": "string",
|
|
236
|
-
"enum": ["merge", "first", "last", "all", "custom"]
|
|
237
|
-
"description": "How to combine branch results"
|
|
180
|
+
"enum": ["merge", "first", "last", "all", "custom"]
|
|
238
181
|
},
|
|
239
182
|
"output": {
|
|
240
|
-
"type": "object"
|
|
241
|
-
"additionalProperties": true,
|
|
242
|
-
"description": "Optional output mapping for joined results"
|
|
183
|
+
"type": "object"
|
|
243
184
|
}
|
|
244
185
|
}
|
|
245
186
|
}
|
|
246
|
-
},
|
|
247
|
-
"condition": {
|
|
248
|
-
"type": "string",
|
|
249
|
-
"description": "JSONPath expression for conditional execution"
|
|
250
|
-
},
|
|
251
|
-
"timeoutMs": {
|
|
252
|
-
"type": "integer",
|
|
253
|
-
"minimum": 1,
|
|
254
|
-
"description": "Timeout for all branches"
|
|
255
|
-
},
|
|
256
|
-
"on_error": {
|
|
257
|
-
"$ref": "#/definitions/ErrorHandler"
|
|
258
187
|
}
|
|
259
188
|
},
|
|
260
189
|
"SwitchStep": {
|
|
261
190
|
"type": "object",
|
|
262
|
-
"required": ["
|
|
191
|
+
"required": ["step_id", "type", "expression", "cases"],
|
|
263
192
|
"additionalProperties": true,
|
|
264
193
|
"properties": {
|
|
265
|
-
"
|
|
194
|
+
"step_id": {
|
|
266
195
|
"type": "string",
|
|
267
|
-
"minLength": 1
|
|
196
|
+
"minLength": 1,
|
|
197
|
+
"pattern": "^[a-zA-Z0-9_]+$"
|
|
268
198
|
},
|
|
269
199
|
"type": {
|
|
270
200
|
"type": "string",
|
|
271
201
|
"const": "switch"
|
|
272
202
|
},
|
|
273
|
-
"name": {
|
|
274
|
-
"type": "string",
|
|
275
|
-
"minLength": 1
|
|
276
|
-
},
|
|
277
203
|
"expression": {
|
|
278
204
|
"type": "string",
|
|
279
205
|
"minLength": 1
|
|
@@ -287,138 +213,82 @@
|
|
|
287
213
|
},
|
|
288
214
|
"default": {
|
|
289
215
|
"$ref": "#/definitions/Step"
|
|
290
|
-
},
|
|
291
|
-
"depends_on": {
|
|
292
|
-
"type": "array",
|
|
293
|
-
"items": {
|
|
294
|
-
"type": "string",
|
|
295
|
-
"minLength": 1
|
|
296
|
-
}
|
|
297
|
-
},
|
|
298
|
-
"condition": {
|
|
299
|
-
"type": "string",
|
|
300
|
-
"description": "JSONPath expression for conditional execution"
|
|
301
|
-
},
|
|
302
|
-
"on_error": {
|
|
303
|
-
"$ref": "#/definitions/ErrorHandler"
|
|
304
216
|
}
|
|
305
217
|
}
|
|
306
218
|
},
|
|
307
219
|
"SubWorkflowStep": {
|
|
308
220
|
"type": "object",
|
|
309
|
-
"required": ["
|
|
221
|
+
"required": ["step_id", "type", "steps"],
|
|
310
222
|
"additionalProperties": true,
|
|
311
223
|
"properties": {
|
|
312
|
-
"
|
|
224
|
+
"step_id": {
|
|
313
225
|
"type": "string",
|
|
314
|
-
"minLength": 1
|
|
226
|
+
"minLength": 1,
|
|
227
|
+
"pattern": "^[a-zA-Z0-9_]+$"
|
|
315
228
|
},
|
|
316
229
|
"type": {
|
|
317
230
|
"type": "string",
|
|
318
231
|
"const": "sub_workflow"
|
|
319
232
|
},
|
|
320
|
-
"name": {
|
|
321
|
-
"type": "string",
|
|
322
|
-
"minLength": 1
|
|
323
|
-
},
|
|
324
233
|
"input": {
|
|
325
|
-
"type": "object"
|
|
326
|
-
"additionalProperties": true,
|
|
327
|
-
"description": "Optional input for sub-workflow - supports all JSON types"
|
|
234
|
+
"type": "object"
|
|
328
235
|
},
|
|
329
236
|
"steps": {
|
|
330
|
-
"type": "
|
|
331
|
-
"
|
|
332
|
-
"
|
|
237
|
+
"type": "object",
|
|
238
|
+
"minProperties": 1,
|
|
239
|
+
"additionalProperties": {
|
|
333
240
|
"$ref": "#/definitions/Step"
|
|
334
241
|
}
|
|
335
|
-
},
|
|
336
|
-
"condition": {
|
|
337
|
-
"type": "string",
|
|
338
|
-
"description": "JSONPath expression for conditional execution"
|
|
339
|
-
},
|
|
340
|
-
"timeoutMs": {
|
|
341
|
-
"type": "integer",
|
|
342
|
-
"minimum": 1,
|
|
343
|
-
"description": "Timeout for entire sub-workflow"
|
|
344
|
-
},
|
|
345
|
-
"on_error": {
|
|
346
|
-
"$ref": "#/definitions/ErrorHandler"
|
|
347
242
|
}
|
|
348
243
|
}
|
|
349
244
|
},
|
|
350
245
|
"WaitStep": {
|
|
351
246
|
"type": "object",
|
|
352
|
-
"required": ["
|
|
247
|
+
"required": ["step_id", "type", "durationMs"],
|
|
353
248
|
"additionalProperties": true,
|
|
354
249
|
"properties": {
|
|
355
|
-
"
|
|
250
|
+
"step_id": {
|
|
356
251
|
"type": "string",
|
|
357
|
-
"minLength": 1
|
|
252
|
+
"minLength": 1,
|
|
253
|
+
"pattern": "^[a-zA-Z0-9_]+$"
|
|
358
254
|
},
|
|
359
255
|
"type": {
|
|
360
256
|
"type": "string",
|
|
361
257
|
"const": "wait"
|
|
362
258
|
},
|
|
363
|
-
"name": {
|
|
364
|
-
"type": "string",
|
|
365
|
-
"minLength": 1
|
|
366
|
-
},
|
|
367
259
|
"durationMs": {
|
|
368
260
|
"type": "integer",
|
|
369
261
|
"minimum": 0
|
|
370
|
-
},
|
|
371
|
-
"condition": {
|
|
372
|
-
"type": "string",
|
|
373
|
-
"description": "JSONPath expression for conditional execution"
|
|
374
262
|
}
|
|
375
263
|
}
|
|
376
264
|
},
|
|
377
265
|
"DispatchStep": {
|
|
378
266
|
"type": "object",
|
|
379
|
-
"required": ["
|
|
267
|
+
"required": ["step_id", "type", "method", "target"],
|
|
380
268
|
"additionalProperties": true,
|
|
381
269
|
"properties": {
|
|
382
|
-
"
|
|
270
|
+
"step_id": {
|
|
383
271
|
"type": "string",
|
|
384
|
-
"minLength": 1
|
|
272
|
+
"minLength": 1,
|
|
273
|
+
"pattern": "^[a-zA-Z0-9_]+$"
|
|
385
274
|
},
|
|
386
275
|
"type": {
|
|
387
276
|
"type": "string",
|
|
388
277
|
"const": "dispatch"
|
|
389
278
|
},
|
|
390
|
-
"name": {
|
|
391
|
-
"type": "string",
|
|
392
|
-
"minLength": 1
|
|
393
|
-
},
|
|
394
279
|
"method": {
|
|
395
280
|
"type": "string",
|
|
396
|
-
"enum": ["webhook", "http", "grpc", "kafka", "sqs", "custom"]
|
|
397
|
-
"description": "Dispatch method to use"
|
|
281
|
+
"enum": ["webhook", "http", "grpc", "kafka", "sqs", "custom"]
|
|
398
282
|
},
|
|
399
283
|
"target": {
|
|
400
284
|
"type": "string",
|
|
401
285
|
"format": "uri"
|
|
402
286
|
},
|
|
403
287
|
"input": {
|
|
404
|
-
"type": "object"
|
|
405
|
-
"additionalProperties": true,
|
|
406
|
-
"description": "Optional dispatch payload - supports all JSON types"
|
|
288
|
+
"type": "object"
|
|
407
289
|
},
|
|
408
290
|
"retry": {
|
|
409
291
|
"$ref": "#/definitions/Retry"
|
|
410
|
-
},
|
|
411
|
-
"condition": {
|
|
412
|
-
"type": "string",
|
|
413
|
-
"description": "JSONPath expression for conditional execution"
|
|
414
|
-
},
|
|
415
|
-
"timeoutMs": {
|
|
416
|
-
"type": "integer",
|
|
417
|
-
"minimum": 1,
|
|
418
|
-
"description": "Timeout for dispatch operation"
|
|
419
|
-
},
|
|
420
|
-
"on_error": {
|
|
421
|
-
"$ref": "#/definitions/ErrorHandler"
|
|
422
292
|
}
|
|
423
293
|
}
|
|
424
294
|
},
|
|
@@ -438,45 +308,38 @@
|
|
|
438
308
|
"backoffMultiplier": {
|
|
439
309
|
"type": "number",
|
|
440
310
|
"minimum": 1.0,
|
|
441
|
-
"maximum": 5.0
|
|
442
|
-
"description": "Exponential backoff multiplier"
|
|
311
|
+
"maximum": 5.0
|
|
443
312
|
}
|
|
444
313
|
}
|
|
445
314
|
},
|
|
446
315
|
"ErrorHandler": {
|
|
447
316
|
"type": "object",
|
|
317
|
+
"required": ["strategy"],
|
|
448
318
|
"additionalProperties": false,
|
|
449
319
|
"properties": {
|
|
450
320
|
"strategy": {
|
|
451
321
|
"type": "string",
|
|
452
|
-
"enum": ["retry", "fail", "continue", "compensate", "fallback"]
|
|
453
|
-
"description": "How to handle errors"
|
|
322
|
+
"enum": ["retry", "fail", "continue", "compensate", "fallback"]
|
|
454
323
|
},
|
|
455
324
|
"retries": {
|
|
456
325
|
"type": "integer",
|
|
457
326
|
"minimum": 0,
|
|
458
|
-
"maximum": 10
|
|
459
|
-
"description": "Number of retries before applying strategy"
|
|
327
|
+
"maximum": 10
|
|
460
328
|
},
|
|
461
329
|
"retryDelayMs": {
|
|
462
330
|
"type": "integer",
|
|
463
|
-
"minimum": 0
|
|
464
|
-
"description": "Delay between retries"
|
|
331
|
+
"minimum": 0
|
|
465
332
|
},
|
|
466
333
|
"fallbackStep": {
|
|
467
|
-
"type": "string"
|
|
468
|
-
"description": "Step ID to execute as fallback"
|
|
334
|
+
"type": "string"
|
|
469
335
|
},
|
|
470
336
|
"compensationStep": {
|
|
471
|
-
"type": "string"
|
|
472
|
-
"description": "Step ID to execute for compensation/rollback"
|
|
337
|
+
"type": "string"
|
|
473
338
|
},
|
|
474
339
|
"errorOutput": {
|
|
475
|
-
"type": "string"
|
|
476
|
-
"description": "JSONPath to store error details"
|
|
340
|
+
"type": "string"
|
|
477
341
|
}
|
|
478
|
-
}
|
|
479
|
-
"required": ["strategy"]
|
|
342
|
+
}
|
|
480
343
|
}
|
|
481
344
|
}
|
|
482
|
-
}
|
|
345
|
+
}
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
|
|
9
9
|
const fs = require('fs');
|
|
10
10
|
const path = require('path');
|
|
11
|
-
const { validateCookbook, CookbookValidationError } = require('./
|
|
11
|
+
const { validateCookbook, CookbookValidationError } = require('./cookbookValidatorV2');
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
14
|
* Read file contents as UTF-8 string (sync version).
|
|
@@ -148,20 +148,23 @@ function checkMigration(cookbook, detectedVersion) {
|
|
|
148
148
|
const suggestions = [];
|
|
149
149
|
|
|
150
150
|
// Check for camelCase fields that should be snake_case
|
|
151
|
-
if (cookbook.steps) {
|
|
151
|
+
if (cookbook.steps && Array.isArray(cookbook.steps)) {
|
|
152
152
|
cookbook.steps.forEach((step, idx) => {
|
|
153
|
-
if (
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
153
|
+
if (step && typeof step === 'object') {
|
|
154
|
+
if ('id' in step) {
|
|
155
|
+
suggestions.push(`- Step ${idx}: Rename 'id' to 'step_id'`);
|
|
156
|
+
}
|
|
157
|
+
if ('timeoutMs' in step) {
|
|
158
|
+
suggestions.push(`- Step ${idx}: Rename 'timeoutMs' to 'timeout_ms'`);
|
|
159
|
+
}
|
|
160
|
+
if (step.retry && typeof step.retry === 'object') {
|
|
161
|
+
if ('maxAttempts' in step.retry) {
|
|
162
|
+
suggestions.push(`- Step ${idx}: Rename 'retry.maxAttempts' to 'retry.max_attempts'`);
|
|
163
|
+
}
|
|
164
|
+
if ('delayMs' in step.retry) {
|
|
165
|
+
suggestions.push(`- Step ${idx}: Rename 'retry.delayMs' to 'retry.delay_ms'`);
|
|
166
|
+
}
|
|
167
|
+
}
|
|
165
168
|
}
|
|
166
169
|
});
|
|
167
170
|
}
|
|
@@ -306,23 +309,26 @@ function validateSemantics(cookbook, version) {
|
|
|
306
309
|
*/
|
|
307
310
|
function validateStep(step, version = '2.0') {
|
|
308
311
|
const schema = loadSchema(version);
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
const validate = createValidator({
|
|
316
|
-
...stepSchema,
|
|
317
|
-
$schema: schema.$schema
|
|
318
|
-
});
|
|
312
|
+
|
|
313
|
+
// Create a minimal cookbook wrapper for step validation
|
|
314
|
+
const cookbookWrapper = {
|
|
315
|
+
version: version === '1.0' ? '1.0.0' : '2.0.0',
|
|
316
|
+
steps: [step]
|
|
317
|
+
};
|
|
319
318
|
|
|
320
|
-
|
|
319
|
+
// Use full cookbook validation but only check the step
|
|
320
|
+
const validate = createValidator(schema);
|
|
321
|
+
const isValid = validate(cookbookWrapper);
|
|
321
322
|
|
|
322
323
|
if (!isValid) {
|
|
324
|
+
// Filter errors to only show step-related ones
|
|
325
|
+
const stepErrors = validate.errors?.filter(err =>
|
|
326
|
+
err.instancePath?.startsWith('/steps/0')
|
|
327
|
+
) || validate.errors;
|
|
328
|
+
|
|
323
329
|
throw new CookbookValidationError(
|
|
324
|
-
'Step validation failed:\n' + formatErrors(
|
|
325
|
-
|
|
330
|
+
'Step validation failed:\n' + formatErrors(stepErrors),
|
|
331
|
+
stepErrors
|
|
326
332
|
);
|
|
327
333
|
}
|
|
328
334
|
|