yaml-dsl-spec 0.3.3 → 0.3.4
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/index.js +6 -1
- package/lib/resolved-value.js +16 -6
- package/lib/schema-validation.js +1 -1
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -46,7 +46,12 @@ module.exports = {
|
|
|
46
46
|
yamlReader: { parseYaml: yamlReader.parseYaml },
|
|
47
47
|
dslDefinition: { dslDefinitionFromJson: dslDefinition.dslDefinitionFromJson },
|
|
48
48
|
jsonPath: { PathPattern: jsonPath.PathPattern, PathSet: jsonPath.PathSet },
|
|
49
|
-
resolved: {
|
|
49
|
+
resolved: {
|
|
50
|
+
Value: resolved.Value,
|
|
51
|
+
reference: resolved.reference,
|
|
52
|
+
call: resolved.call,
|
|
53
|
+
loop: resolved.loop,
|
|
54
|
+
},
|
|
50
55
|
functionTable: {
|
|
51
56
|
FUNCTION_TABLE_POINTER: functionTable.FUNCTION_TABLE_POINTER,
|
|
52
57
|
FunctionTable: functionTable.FunctionTable,
|
package/lib/resolved-value.js
CHANGED
|
@@ -4,9 +4,9 @@ const { scalarTextOf } = require('./yaml-node');
|
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* A value of the folded, expanded document, with where it was written. `kind` is
|
|
7
|
-
* a node's kind, or `reference`, `call` or `
|
|
8
|
-
* that kind holds, a list of values and of map entries `{ key, keyPosition, value }`
|
|
9
|
-
* included, or the reference, the call,
|
|
7
|
+
* a node's kind, or `reference`, `call`, `template` or `loop`; `value` is what a node
|
|
8
|
+
* of that kind holds, a list of values and of map entries `{ key, keyPosition, value }`
|
|
9
|
+
* included, or the reference, the call, the template's parts, or the loop.
|
|
10
10
|
*/
|
|
11
11
|
class Value {
|
|
12
12
|
constructor(kind, value, position) {
|
|
@@ -70,8 +70,8 @@ class Value {
|
|
|
70
70
|
/**
|
|
71
71
|
* A name read by one of the definition's reference rules: `{ scope, scopeKey,
|
|
72
72
|
* name, path, text, target }`. A target is `{ kind: 'local', value }`, or a
|
|
73
|
-
* `kind` of `local_unknown`, `builtin`, `declaration` with its `position`,
|
|
74
|
-
* `undeclared
|
|
73
|
+
* `kind` of `local_unknown`, `builtin`, `declaration` with its `position`,
|
|
74
|
+
* `undeclared`, or `loop_variable`, a variable of a loop left for the target.
|
|
75
75
|
*/
|
|
76
76
|
function reference(fields) {
|
|
77
77
|
return { scopeKey: null, ...fields };
|
|
@@ -82,6 +82,16 @@ function call(functionName, callArguments) {
|
|
|
82
82
|
return { function: functionName, arguments: callArguments, expandFinalArgument: false };
|
|
83
83
|
}
|
|
84
84
|
|
|
85
|
+
/**
|
|
86
|
+
* A loop whose collection is not known when the document compiles, left for the
|
|
87
|
+
* target to evaluate: `{ variables, collection, body }`. `body` is what one pass
|
|
88
|
+
* yields, `{ kind: 'item', value }` for a list body's one element, or
|
|
89
|
+
* `{ kind: 'entries', entries }` for a map body's entries, each `{ key, value }`.
|
|
90
|
+
*/
|
|
91
|
+
function loop(variables, collection, body) {
|
|
92
|
+
return { variables, collection, body };
|
|
93
|
+
}
|
|
94
|
+
|
|
85
95
|
/**
|
|
86
96
|
* The map values `maps` merged in order by a `merge` macro's `mergeBehavior`, a map
|
|
87
97
|
* at `position`: `deep` merges nested maps key by key, `shallow` replaces a key's
|
|
@@ -109,4 +119,4 @@ function mapMergeResult(maps, mergeBehavior, position) {
|
|
|
109
119
|
return new Value('map', entries, position);
|
|
110
120
|
}
|
|
111
121
|
|
|
112
|
-
module.exports = { Value, reference, call, mapMergeResult };
|
|
122
|
+
module.exports = { Value, reference, call, loop, mapMergeResult };
|
package/lib/schema-validation.js
CHANGED
|
@@ -93,7 +93,7 @@ const SAME_VALUE_LIST_KEYWORDS = ['allOf', 'anyOf', 'oneOf'];
|
|
|
93
93
|
const SAME_VALUE_KEYWORDS = ['else', 'if', 'not', 'propertyNames', 'then'];
|
|
94
94
|
const SAME_VALUE_MAP_KEYWORDS = ['dependencies', 'dependentSchemas'];
|
|
95
95
|
const SCHEMA_LOOKUP_KEY ='urn:yaml-dsl-spec:schema-lookup';
|
|
96
|
-
const UNKNOWN_VALUE_KINDS = new Set(['call', 'reference', 'template']);
|
|
96
|
+
const UNKNOWN_VALUE_KINDS = new Set(['call', 'loop', 'reference', 'template']);
|
|
97
97
|
const SCHEMA_DATA_KEYWORDS = new Set(['const', 'default', 'enum', 'examples']);
|
|
98
98
|
const SCHEMA_NAME_MAP_KEYWORDS = new Set([
|
|
99
99
|
'$defs',
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "yaml-dsl-spec",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.4",
|
|
4
4
|
"description": "The YAML DSL standard: the JSON Schemas of yaml-dsl.yml and of a DSL's function table, and a reader returning a yaml-dsl.yml's DSL definitions validated.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|