Skip to content

Commit 3b7d4ab

Browse files
feat: switch to json schema 2020
Signed-off-by: Matthias Pichler <[email protected]>
1 parent 2709fb5 commit 3b7d4ab

File tree

3 files changed

+56
-32
lines changed

3 files changed

+56
-32
lines changed

.ci/validation/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
*/
1616

1717
import fs from "node:fs";
18-
import Ajv from "ajv";
18+
import Ajv from "ajv/dist/2020";
1919
import addFormats from "ajv-formats";
2020
import path from "node:path";
2121
import yaml = require("js-yaml");

examples/accumulate-room-readings.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ do:
2424
from: .roomid
2525
output:
2626
from: .data.reading
27-
as: readings
2827
- logReading:
2928
for:
3029
each: reading

schema/workflow.yaml

Lines changed: 55 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
$id: https://serverlessworkflow.io/schemas/1.0.0-alpha1/workflow.json
2-
$schema: http://json-schema.org/draft-07/schema
2+
$schema: https://json-schema.org/draft/2020-12/schema
33
description: Serverless Workflow DSL - Workflow Schema
44
type: object
55
properties:
@@ -109,9 +109,8 @@ $defs:
109109
maxProperties: 1
110110
additionalProperties:
111111
$ref: '#/$defs/task'
112-
task:
112+
taskBase:
113113
type: object
114-
unevaluatedProperties: false
115114
properties:
116115
input:
117116
$ref: '#/$defs/input'
@@ -125,6 +124,8 @@ $defs:
125124
then:
126125
$ref: '#/$defs/flowDirective'
127126
description: The flow directive to be performed upon completion of the task.
127+
task:
128+
unevaluatedProperties: false
128129
oneOf:
129130
- $ref: '#/$defs/callTask'
130131
- $ref: '#/$defs/doTask'
@@ -139,7 +140,9 @@ $defs:
139140
- $ref: '#/$defs/tryTask'
140141
- $ref: '#/$defs/waitTask'
141142
callTask:
143+
$ref: '#/$defs/taskBase'
142144
type: object
145+
unevaluatedProperties: false
143146
oneOf:
144147
- properties:
145148
call:
@@ -284,9 +287,11 @@ $defs:
284287
description: A name/value mapping of the parameters, if any, to call the function with.
285288
required: [ call ]
286289
branchTask:
290+
description: Allows to execute multiple tasks concurrently.
291+
$ref: '#/$defs/taskBase'
287292
type: object
288293
required: [ branch ]
289-
description: Allows to execute multiple tasks concurrently.
294+
unevaluatedProperties: false
290295
properties:
291296
branch:
292297
type: object
@@ -299,14 +304,20 @@ $defs:
299304
type: boolean
300305
default: false
301306
doTask:
307+
$ref: '#/$defs/taskBase'
302308
type: object
303309
required: [ do ]
310+
unevaluatedProperties: false
304311
description: Allows to execute multiple tasks sequentially.
305312
properties:
306313
do:
307314
$ref: '#/$defs/taskList'
308315
emitTask:
316+
description: Allows workflows to publish events to event brokers or messaging systems, facilitating communication and coordination between different components and services.
317+
$ref: '#/$defs/taskBase'
309318
type: object
319+
required: [ emit ]
320+
unevaluatedProperties: false
310321
properties:
311322
emit:
312323
type: object
@@ -338,17 +349,12 @@ $defs:
338349
required: [ source, type ]
339350
additionalProperties: true
340351
required: [ event ]
341-
required: [ emit ]
342-
description: Allows workflows to publish events to event brokers or messaging systems, facilitating communication and coordination between different components and services.
343-
flowDirective:
344-
additionalProperties: false
345-
anyOf:
346-
- type: string
347-
enum: [ continue, exit, end ]
348-
default: continue
349-
- type: string
350352
forTask:
353+
description: Allows workflows to iterate over a collection of items, executing a defined set of subtasks for each item in the collection. This task type is instrumental in handling scenarios such as batch processing, data transformation, and repetitive operations across datasets.
354+
$ref: '#/$defs/taskBase'
351355
type: object
356+
required: [ for, do ]
357+
unevaluatedProperties: false
352358
properties:
353359
for:
354360
type: object
@@ -370,10 +376,12 @@ $defs:
370376
description: A runtime expression that represents the condition, if any, that must be met for the iteration to continue.
371377
do:
372378
$ref: '#/$defs/taskList'
373-
description: Allows workflows to iterate over a collection of items, executing a defined set of subtasks for each item in the collection. This task type is instrumental in handling scenarios such as batch processing, data transformation, and repetitive operations across datasets.
374-
required: [ for, do ]
375379
listenTask:
380+
description: Provides a mechanism for workflows to await and react to external events, enabling event-driven behavior within workflow systems.
381+
$ref: '#/$defs/taskBase'
376382
type: object
383+
required: [ listen ]
384+
unevaluatedProperties: false
377385
properties:
378386
listen:
379387
type: object
@@ -382,10 +390,12 @@ $defs:
382390
$ref: '#/$defs/eventConsumptionStrategy'
383391
description: Defines the event(s) to listen to.
384392
required: [ to ]
385-
required: [ listen ]
386-
description: Provides a mechanism for workflows to await and react to external events, enabling event-driven behavior within workflow systems.
387393
raiseTask:
394+
description: Intentionally triggers and propagates errors.
395+
$ref: '#/$defs/taskBase'
388396
type: object
397+
required: [ raise ]
398+
unevaluatedProperties: false
389399
properties:
390400
raise:
391401
type: object
@@ -394,10 +404,12 @@ $defs:
394404
$ref: '#/$defs/error'
395405
description: Defines the error to raise.
396406
required: [ error ]
397-
required: [ raise ]
398-
description: Intentionally triggers and propagates errors.
399407
runTask:
408+
description: Provides the capability to execute external containers, shell commands, scripts, or workflows.
409+
$ref: '#/$defs/taskBase'
400410
type: object
411+
required: [ run ]
412+
unevaluatedProperties: false
401413
properties:
402414
run:
403415
type: object
@@ -488,20 +500,24 @@ $defs:
488500
required: [ namespace, name, version ]
489501
required: [ workflow ]
490502
description: Enables the invocation and execution of nested workflows within a parent workflow, facilitating modularization, reusability, and abstraction of complex logic or business processes by encapsulating them into standalone workflow units.
491-
required: [ run ]
492-
description: Provides the capability to execute external containers, shell commands, scripts, or workflows.
493503
setTask:
504+
description: A task used to set data
505+
$ref: '#/$defs/taskBase'
494506
type: object
507+
required: [ set ]
508+
unevaluatedProperties: false
495509
properties:
496510
set:
497511
type: object
498512
minProperties: 1
499513
additionalProperties: true
500514
description: The data to set
501-
required: [ set ]
502-
description: A task used to set data
503515
switchTask:
516+
description: Enables conditional branching within workflows, allowing them to dynamically select different paths based on specified conditions or criteria
517+
$ref: '#/$defs/taskBase'
504518
type: object
519+
required: [ switch ]
520+
unevaluatedProperties: false
505521
properties:
506522
switch:
507523
type: array
@@ -522,10 +538,12 @@ $defs:
522538
then:
523539
$ref: '#/$defs/flowDirective'
524540
description: The flow directive to execute when the case matches.
525-
required: [ switch ]
526-
description: Enables conditional branching within workflows, allowing them to dynamically select different paths based on specified conditions or criteria
527541
tryTask:
542+
description: Serves as a mechanism within workflows to handle errors gracefully, potentially retrying failed tasks before proceeding with alternate ones.
543+
$ref: '#/$defs/taskBase'
528544
type: object
545+
required: [ try, catch ]
546+
unevaluatedProperties: false
529547
properties:
530548
try:
531549
description: The task(s) to perform.
@@ -550,16 +568,23 @@ $defs:
550568
do:
551569
description: The definition of the task(s) to run when catching an error.
552570
$ref: '#/$defs/taskList'
553-
required: [ try, catch ]
554-
description: Serves as a mechanism within workflows to handle errors gracefully, potentially retrying failed tasks before proceeding with alternate ones.
555571
waitTask:
572+
description: Allows workflows to pause or delay their execution for a specified period of time.
573+
$ref: '#/$defs/taskBase'
556574
type: object
575+
required: [ wait ]
576+
unevaluatedProperties: false
557577
properties:
558578
wait:
559-
$ref: '#/$defs/duration'
560579
description: The amount of time to wait.
561-
required: [ wait ]
562-
description: Allows workflows to pause or delay their execution for a specified period of time.
580+
$ref: '#/$defs/duration'
581+
flowDirective:
582+
additionalProperties: false
583+
anyOf:
584+
- type: string
585+
enum: [ continue, exit, end ]
586+
default: continue
587+
- type: string
563588
authenticationPolicy:
564589
type: object
565590
oneOf:

0 commit comments

Comments
 (0)