-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathevaluate.json.dot
More file actions
113 lines (111 loc) · 3.69 KB
/
evaluate.json.dot
File metadata and controls
113 lines (111 loc) · 3.69 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
{
"id": "http://www.jsonscript.org/schema/evaluate.json#",
"$schema": "https://raw.githubusercontent.com/epoberezkin/ajv/master/lib/refs/json-schema-v5.json#",
"title": "JSONScript evaluation schema",
"description": "Schema with custom keywords that evaluates JSON script. It assumes that the script is valid",
"allOf": [
{
"switch": [
{
"if": { "type": "object" },
"then": {
"switch": [
{{~ it.instructions:inst }}
{
"if": { "required": [ "{{=inst.name}}" ] },
"then": {{# def.instruction }}
},
{{~}}
{
"then": {
"title": "parallel execution",
"allOf": [
{
"title": "evaluate properties",
"description": "evaluates all properties using the same schema, properties-scripts are replaced with returned synchronous or asynchronous value",
"additionalProperties": { "$ref": "#" }
},
{
"title": "object to [async] value",
"description": "Merge object properties into a single [asynchronous] object value",
"objectToAsync": true
}
]
}
}
]
}
},
{
"if": { "type": "array" },
"then": {
"title": "sequential execution",
"description": "queues items so that the next items is executed only after the previous asynchronous value receives data",
"itemsSerial": { "$ref": "#" }
}
},
{
"then": {
"title": "scalar values",
"description": "convert scalar values to asynchronouse values",
"valueToAsync": true
}
}
]
},
{
"description": "store pointer to evaluted object and resolve pending references",
"resolvePendingRefs": true
}
]
}
{{## def.instruction:
{
"title": "instruction {{=inst.name}}",
"allOf": [
{{ var evalKeywords = inst.evaluate.keywords; }}
{{? !evalKeywords || evalKeywords.length }}
{
"title": "evaluate properties",
"description": "evaluates all or some keywords using this (full) schema, properties-scripts are replaced with returned synchronous or asynchronous value",
{{? evalKeywords }}
"properties": {
{{~ evalKeywords:keyword:i }}
{{?i}},{{?}}
"{{=keyword}}": { "$ref": "#" }
{{~}}
}
{{??}}
"additionalProperties": { "$ref": "#" }
{{?}}
},
{
"title": "object to [async] value",
"description": "Merge object properties into a single [asynchronous] object value",
"objectToAsync": true
},
{{?}}
{
"title": "execute instruction",
"description": "executes supported script instructions",
"validateAsync": {
{{? inst.schema }}
"allOf": [
{
"description": "validate evaluated instruction keywords",
"properties": {{= JSON.stringify(inst.schema) }}
},
{
"description": "execute instruction using custom keyword",
"{{=inst.evaluate.validatorKeyword}}": true
}
]
{{??}}
"description": "execute instruction using custom keyword",
"{{=inst.evaluate.validatorKeyword}}": true
{{?}}
}
}
]
}
#}}