@swagger-api/apidom-ast 0.92.0 → 0.94.0
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/CHANGELOG.md +10 -0
- package/cjs/Error.cjs +12 -13
- package/cjs/Literal.cjs +10 -11
- package/cjs/Node.cjs +26 -32
- package/cjs/ParseResult.cjs +5 -12
- package/cjs/Position.cjs +25 -32
- package/cjs/index.cjs +9 -1
- package/cjs/json/nodes/JsonArray.cjs +5 -11
- package/cjs/json/nodes/JsonDocument.cjs +5 -12
- package/cjs/json/nodes/JsonEscapeSequence.cjs +3 -6
- package/cjs/json/nodes/JsonFalse.cjs +3 -6
- package/cjs/json/nodes/JsonKey.cjs +3 -6
- package/cjs/json/nodes/JsonNode.cjs +1 -2
- package/cjs/json/nodes/JsonNull.cjs +3 -6
- package/cjs/json/nodes/JsonNumber.cjs +3 -6
- package/cjs/json/nodes/JsonObject.cjs +5 -11
- package/cjs/json/nodes/JsonProperty.cjs +8 -17
- package/cjs/json/nodes/JsonString.cjs +8 -16
- package/cjs/json/nodes/JsonStringContent.cjs +3 -6
- package/cjs/json/nodes/JsonTrue.cjs +3 -6
- package/cjs/json/nodes/JsonValue.cjs +11 -12
- package/cjs/json/nodes/predicates.cjs +24 -12
- package/cjs/predicates.cjs +9 -5
- package/cjs/yaml/anchors-aliases/ReferenceManager.cjs +28 -0
- package/cjs/yaml/errors/YamlError.cjs +7 -0
- package/cjs/yaml/errors/YamlReferenceError.cjs +8 -0
- package/cjs/yaml/errors/YamlSchemaError.cjs +3 -2
- package/cjs/yaml/errors/YamlTagError.cjs +6 -0
- package/cjs/yaml/nodes/YamlAlias.cjs +11 -12
- package/cjs/yaml/nodes/YamlAnchor.cjs +11 -12
- package/cjs/yaml/nodes/YamlCollection.cjs +1 -2
- package/cjs/yaml/nodes/YamlComment.cjs +11 -12
- package/cjs/yaml/nodes/YamlDirective.cjs +16 -17
- package/cjs/yaml/nodes/YamlDocument.cjs +3 -6
- package/cjs/yaml/nodes/YamlKeyValuePair.cjs +29 -27
- package/cjs/yaml/nodes/YamlMapping.cjs +7 -13
- package/cjs/yaml/nodes/YamlNode.cjs +16 -15
- package/cjs/yaml/nodes/YamlScalar.cjs +11 -12
- package/cjs/yaml/nodes/YamlSequence.cjs +10 -16
- package/cjs/yaml/nodes/YamlStream.cjs +7 -15
- package/cjs/yaml/nodes/YamlStyle.cjs +2 -11
- package/cjs/yaml/nodes/YamlTag.cjs +12 -13
- package/cjs/yaml/nodes/predicates.cjs +23 -11
- package/cjs/yaml/schemas/ScalarTag.cjs +23 -32
- package/cjs/yaml/schemas/Tag.cjs +16 -7
- package/cjs/yaml/schemas/failsafe/GenericMapping.cjs +7 -19
- package/cjs/yaml/schemas/failsafe/GenericSequence.cjs +7 -19
- package/cjs/yaml/schemas/failsafe/GenericString.cjs +3 -16
- package/cjs/yaml/schemas/failsafe/index.cjs +83 -87
- package/cjs/yaml/schemas/json/Boolean.cjs +13 -21
- package/cjs/yaml/schemas/json/FloatingPoint.cjs +13 -21
- package/cjs/yaml/schemas/json/Integer.cjs +13 -21
- package/cjs/yaml/schemas/json/Null.cjs +12 -20
- package/cjs/yaml/schemas/json/index.cjs +20 -26
- package/dist/apidom-ast.browser.js +1672 -1889
- package/dist/apidom-ast.browser.min.js +1 -1
- package/es/Error.mjs +12 -13
- package/es/Literal.mjs +10 -11
- package/es/Node.mjs +26 -31
- package/es/ParseResult.mjs +5 -12
- package/es/Position.mjs +24 -31
- package/es/index.mjs +4 -1
- package/es/json/nodes/JsonArray.mjs +5 -11
- package/es/json/nodes/JsonDocument.mjs +5 -12
- package/es/json/nodes/JsonEscapeSequence.mjs +3 -6
- package/es/json/nodes/JsonFalse.mjs +3 -6
- package/es/json/nodes/JsonKey.mjs +3 -6
- package/es/json/nodes/JsonNode.mjs +1 -2
- package/es/json/nodes/JsonNull.mjs +3 -6
- package/es/json/nodes/JsonNumber.mjs +3 -6
- package/es/json/nodes/JsonObject.mjs +5 -11
- package/es/json/nodes/JsonProperty.mjs +8 -17
- package/es/json/nodes/JsonString.mjs +8 -16
- package/es/json/nodes/JsonStringContent.mjs +3 -6
- package/es/json/nodes/JsonTrue.mjs +3 -6
- package/es/json/nodes/JsonValue.mjs +11 -12
- package/es/json/nodes/predicates.mjs +12 -12
- package/es/predicates.mjs +5 -5
- package/es/yaml/anchors-aliases/ReferenceManager.mjs +24 -0
- package/es/yaml/errors/YamlError.mjs +3 -0
- package/es/yaml/errors/YamlReferenceError.mjs +3 -0
- package/es/yaml/errors/YamlSchemaError.mjs +2 -2
- package/es/yaml/errors/YamlTagError.mjs +6 -0
- package/es/yaml/nodes/YamlAlias.mjs +11 -12
- package/es/yaml/nodes/YamlAnchor.mjs +11 -12
- package/es/yaml/nodes/YamlCollection.mjs +1 -2
- package/es/yaml/nodes/YamlComment.mjs +11 -12
- package/es/yaml/nodes/YamlDirective.mjs +16 -17
- package/es/yaml/nodes/YamlDocument.mjs +3 -6
- package/es/yaml/nodes/YamlKeyValuePair.mjs +29 -27
- package/es/yaml/nodes/YamlMapping.mjs +7 -13
- package/es/yaml/nodes/YamlNode.mjs +16 -15
- package/es/yaml/nodes/YamlScalar.mjs +11 -12
- package/es/yaml/nodes/YamlSequence.mjs +10 -16
- package/es/yaml/nodes/YamlStream.mjs +7 -15
- package/es/yaml/nodes/YamlStyle.mjs +1 -9
- package/es/yaml/nodes/YamlTag.mjs +12 -13
- package/es/yaml/nodes/predicates.mjs +11 -10
- package/es/yaml/schemas/ScalarTag.mjs +23 -31
- package/es/yaml/schemas/Tag.mjs +17 -6
- package/es/yaml/schemas/failsafe/GenericMapping.mjs +8 -19
- package/es/yaml/schemas/failsafe/GenericSequence.mjs +8 -19
- package/es/yaml/schemas/failsafe/GenericString.mjs +3 -16
- package/es/yaml/schemas/failsafe/index.mjs +86 -90
- package/es/yaml/schemas/json/Boolean.mjs +14 -21
- package/es/yaml/schemas/json/FloatingPoint.mjs +14 -21
- package/es/yaml/schemas/json/Integer.mjs +14 -21
- package/es/yaml/schemas/json/Null.mjs +13 -20
- package/es/yaml/schemas/json/index.mjs +24 -30
- package/package.json +3 -4
- package/types/dist.d.ts +236 -158
@@ -1,21 +1,15 @@
|
|
1
|
-
import stampit from 'stampit';
|
2
1
|
import YamlCollection from "./YamlCollection.mjs";
|
3
2
|
import { isMapping, isScalar, isSequence, isAlias } from "./predicates.mjs";
|
4
|
-
|
5
|
-
|
6
|
-
|
3
|
+
class YamlSequence extends YamlCollection {
|
4
|
+
static type = 'sequence';
|
5
|
+
}
|
6
|
+
Object.defineProperty(YamlSequence.prototype, 'content', {
|
7
|
+
get() {
|
8
|
+
const {
|
9
|
+
children
|
10
|
+
} = this;
|
11
|
+
return Array.isArray(children) ? children.filter(node => isSequence(node) || isMapping(node) || isScalar(node) || isAlias(node)) : [];
|
7
12
|
},
|
8
|
-
|
9
|
-
content: {
|
10
|
-
get() {
|
11
|
-
// @ts-ignore
|
12
|
-
const {
|
13
|
-
children
|
14
|
-
} = this;
|
15
|
-
return Array.isArray(children) ? children.filter(node => isSequence(node) || isMapping(node) || isScalar(node) || isAlias(node)) : [];
|
16
|
-
},
|
17
|
-
enumerable: true
|
18
|
-
}
|
19
|
-
}
|
13
|
+
enumerable: true
|
20
14
|
});
|
21
15
|
export default YamlSequence;
|
@@ -1,20 +1,12 @@
|
|
1
|
-
import stampit from 'stampit';
|
2
1
|
import Node from "../../Node.mjs";
|
3
2
|
import { isComment, isDocument } from "./predicates.mjs";
|
4
|
-
|
5
|
-
|
6
|
-
|
3
|
+
class YamlStream extends Node {
|
4
|
+
static type = 'stream';
|
5
|
+
}
|
6
|
+
Object.defineProperty(YamlStream.prototype, 'content', {
|
7
|
+
get() {
|
8
|
+
return Array.isArray(this.children) ? this.children.filter(node => isDocument(node) || isComment(node)) : [];
|
7
9
|
},
|
8
|
-
|
9
|
-
content: {
|
10
|
-
get() {
|
11
|
-
// @ts-ignore
|
12
|
-
return Array.isArray(this.children) ?
|
13
|
-
// @ts-ignore
|
14
|
-
this.children.filter(node => isDocument(node) || isComment(node)) : [];
|
15
|
-
},
|
16
|
-
enumerable: true
|
17
|
-
}
|
18
|
-
}
|
10
|
+
enumerable: true
|
19
11
|
});
|
20
12
|
export default YamlStream;
|
@@ -1,4 +1,3 @@
|
|
1
|
-
import stampit from 'stampit';
|
2
1
|
export let YamlStyle = /*#__PURE__*/function (YamlStyle) {
|
3
2
|
YamlStyle["Plain"] = "Plain";
|
4
3
|
YamlStyle["SingleQuoted"] = "SingleQuoted";
|
@@ -15,11 +14,4 @@ export let YamlStyleGroup = /*#__PURE__*/function (YamlStyleGroup) {
|
|
15
14
|
YamlStyleGroup["Flow"] = "Flow";
|
16
15
|
YamlStyleGroup["Block"] = "Block";
|
17
16
|
return YamlStyleGroup;
|
18
|
-
}({});
|
19
|
-
const YamlStyleModel = stampit({
|
20
|
-
props: {
|
21
|
-
styleGroup: null,
|
22
|
-
style: null
|
23
|
-
}
|
24
|
-
});
|
25
|
-
export default YamlStyleModel;
|
17
|
+
}({});
|
@@ -1,4 +1,3 @@
|
|
1
|
-
import stampit from 'stampit';
|
2
1
|
import Node from "../../Node.mjs";
|
3
2
|
export let YamlNodeKind = /*#__PURE__*/function (YamlNodeKind) {
|
4
3
|
YamlNodeKind["Scalar"] = "Scalar";
|
@@ -6,20 +5,20 @@ export let YamlNodeKind = /*#__PURE__*/function (YamlNodeKind) {
|
|
6
5
|
YamlNodeKind["Mapping"] = "Mapping";
|
7
6
|
return YamlNodeKind;
|
8
7
|
}({});
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
explicitName: '',
|
15
|
-
kind: null
|
16
|
-
},
|
17
|
-
init({
|
8
|
+
class YamlTag extends Node {
|
9
|
+
static type = 'tag';
|
10
|
+
explicitName;
|
11
|
+
kind;
|
12
|
+
constructor({
|
18
13
|
explicitName,
|
19
|
-
kind
|
20
|
-
|
14
|
+
kind,
|
15
|
+
...rest
|
16
|
+
}) {
|
17
|
+
super({
|
18
|
+
...rest
|
19
|
+
});
|
21
20
|
this.explicitName = explicitName;
|
22
21
|
this.kind = kind;
|
23
22
|
}
|
24
|
-
}
|
23
|
+
}
|
25
24
|
export default YamlTag;
|
@@ -1,11 +1,12 @@
|
|
1
1
|
import { isNodeType } from "../../predicates.mjs";
|
2
|
-
export const isStream = isNodeType
|
3
|
-
export const isDocument = isNodeType
|
4
|
-
export const isMapping = isNodeType
|
5
|
-
export const isSequence = isNodeType
|
6
|
-
export const isKeyValuePair = isNodeType
|
7
|
-
export const isTag = isNodeType
|
8
|
-
export const
|
9
|
-
export const
|
10
|
-
export const
|
11
|
-
export const
|
2
|
+
export const isStream = node => isNodeType('stream', node);
|
3
|
+
export const isDocument = node => isNodeType('document', node);
|
4
|
+
export const isMapping = node => isNodeType('mapping', node);
|
5
|
+
export const isSequence = node => isNodeType('sequence', node);
|
6
|
+
export const isKeyValuePair = node => isNodeType('keyValuePair', node);
|
7
|
+
export const isTag = node => isNodeType('tag', node);
|
8
|
+
export const isAnchor = node => isNodeType('anchor', node);
|
9
|
+
export const isScalar = node => isNodeType('scalar', node);
|
10
|
+
export const isAlias = node => isNodeType('alias', node);
|
11
|
+
export const isDirective = node => isNodeType('directive', node);
|
12
|
+
export const isComment = node => isNodeType('comment', node);
|
@@ -1,37 +1,29 @@
|
|
1
|
-
import stampit from 'stampit';
|
2
1
|
import { formatFlowPlain, formatFlowSingleQuoted, formatFlowDoubleQuoted, formatBlockLiteral, formatBlockFolded } from "./canonical-format.mjs";
|
3
2
|
import { YamlStyle } from "../nodes/YamlStyle.mjs";
|
4
3
|
import { YamlNodeKind } from "../nodes/YamlTag.mjs";
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
} else if (node.style === YamlStyle.Literal) {
|
23
|
-
// @ts-ignore
|
24
|
-
canonicalForm = formatBlockLiteral(node.content);
|
25
|
-
} else if (node.style === YamlStyle.Folded) {
|
26
|
-
// @ts-ignore
|
27
|
-
canonicalForm = formatBlockFolded(node.content);
|
28
|
-
}
|
29
|
-
nodeClone.content = canonicalForm;
|
30
|
-
return nodeClone;
|
31
|
-
},
|
32
|
-
resolve(node) {
|
33
|
-
return node;
|
4
|
+
class ScalarTag {
|
5
|
+
static test(node) {
|
6
|
+
return node.tag.kind === YamlNodeKind.Scalar && typeof node.content === 'string';
|
7
|
+
}
|
8
|
+
static canonicalFormat(node) {
|
9
|
+
let canonicalForm = node.content;
|
10
|
+
const nodeClone = node.clone();
|
11
|
+
if (node.style === YamlStyle.Plain) {
|
12
|
+
canonicalForm = formatFlowPlain(node.content);
|
13
|
+
} else if (node.style === YamlStyle.SingleQuoted) {
|
14
|
+
canonicalForm = formatFlowSingleQuoted(node.content);
|
15
|
+
} else if (node.style === YamlStyle.DoubleQuoted) {
|
16
|
+
canonicalForm = formatFlowDoubleQuoted(node.content);
|
17
|
+
} else if (node.style === YamlStyle.Literal) {
|
18
|
+
canonicalForm = formatBlockLiteral(node.content);
|
19
|
+
} else if (node.style === YamlStyle.Folded) {
|
20
|
+
canonicalForm = formatBlockFolded(node.content);
|
34
21
|
}
|
22
|
+
nodeClone.content = canonicalForm;
|
23
|
+
return nodeClone;
|
24
|
+
}
|
25
|
+
static resolve(node) {
|
26
|
+
return node;
|
35
27
|
}
|
36
|
-
}
|
28
|
+
}
|
37
29
|
export default ScalarTag;
|
package/es/yaml/schemas/Tag.mjs
CHANGED
@@ -1,8 +1,19 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
1
|
+
/* eslint-disable class-methods-use-this */
|
2
|
+
class Tag {
|
3
|
+
static uri = '';
|
4
|
+
tag = '';
|
5
|
+
constructor() {
|
6
|
+
this.tag = this.constructor.uri;
|
6
7
|
}
|
7
|
-
|
8
|
+
|
9
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
10
|
+
test(node) {
|
11
|
+
return true;
|
12
|
+
}
|
13
|
+
resolve(node) {
|
14
|
+
return node;
|
15
|
+
}
|
16
|
+
}
|
17
|
+
/* eslint-enable class-methods-use-this */
|
18
|
+
|
8
19
|
export default Tag;
|
@@ -1,23 +1,12 @@
|
|
1
|
-
import stampit from 'stampit';
|
2
1
|
import Tag from "../Tag.mjs";
|
3
2
|
import { YamlNodeKind } from "../../nodes/YamlTag.mjs";
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
stamp
|
10
|
-
}) {
|
11
|
-
this.tag = stamp.uri;
|
12
|
-
},
|
13
|
-
methods: {
|
14
|
-
test(node) {
|
15
|
-
// @ts-ignore
|
16
|
-
return node.tag.kind === YamlNodeKind.Mapping;
|
17
|
-
},
|
18
|
-
resolve(node) {
|
19
|
-
return node;
|
20
|
-
}
|
3
|
+
/* eslint-disable class-methods-use-this */
|
4
|
+
class GenericMapping extends Tag {
|
5
|
+
static uri = 'tag:yaml.org,2002:map';
|
6
|
+
test(node) {
|
7
|
+
return node.tag.kind === YamlNodeKind.Mapping;
|
21
8
|
}
|
22
|
-
}
|
9
|
+
}
|
10
|
+
/* eslint-enable class-methods-use-this */
|
11
|
+
|
23
12
|
export default GenericMapping;
|
@@ -1,23 +1,12 @@
|
|
1
|
-
import stampit from 'stampit';
|
2
1
|
import Tag from "../Tag.mjs";
|
3
2
|
import { YamlNodeKind } from "../../nodes/YamlTag.mjs";
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
stamp
|
10
|
-
}) {
|
11
|
-
this.tag = stamp.uri;
|
12
|
-
},
|
13
|
-
methods: {
|
14
|
-
test(node) {
|
15
|
-
// @ts-ignore
|
16
|
-
return node.tag.kind === YamlNodeKind.Sequence;
|
17
|
-
},
|
18
|
-
resolve(node) {
|
19
|
-
return node;
|
20
|
-
}
|
3
|
+
/* eslint-disable class-methods-use-this */
|
4
|
+
class GenericSequence extends Tag {
|
5
|
+
static uri = 'tag:yaml.org,2002:seq';
|
6
|
+
test(node) {
|
7
|
+
return node.tag.kind === YamlNodeKind.Sequence;
|
21
8
|
}
|
22
|
-
}
|
9
|
+
}
|
10
|
+
/* eslint-enable class-methods-use-this */
|
11
|
+
|
23
12
|
export default GenericSequence;
|
@@ -1,18 +1,5 @@
|
|
1
|
-
import stampit from 'stampit';
|
2
1
|
import Tag from "../Tag.mjs";
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
},
|
7
|
-
init(args, {
|
8
|
-
stamp
|
9
|
-
}) {
|
10
|
-
this.tag = stamp.uri;
|
11
|
-
},
|
12
|
-
methods: {
|
13
|
-
resolve(node) {
|
14
|
-
return node;
|
15
|
-
}
|
16
|
-
}
|
17
|
-
});
|
2
|
+
class GenericString extends Tag {
|
3
|
+
static uri = 'tag:yaml.org,2002:str';
|
4
|
+
}
|
18
5
|
export default GenericString;
|
@@ -1,105 +1,101 @@
|
|
1
1
|
import { clone } from 'ramda';
|
2
|
-
import stampit from 'stampit';
|
3
2
|
import YamlTagError from "../../errors/YamlTagError.mjs";
|
4
3
|
import { YamlNodeKind } from "../../nodes/YamlTag.mjs";
|
5
|
-
import
|
6
|
-
import
|
7
|
-
import
|
4
|
+
import GenericMappingTag from "./GenericMapping.mjs";
|
5
|
+
import GenericSequenceTag from "./GenericSequence.mjs";
|
6
|
+
import GenericStringTag from "./GenericString.mjs";
|
8
7
|
import ScalarTag from "../ScalarTag.mjs";
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
},
|
14
|
-
init() {
|
8
|
+
class FailsafeSchema {
|
9
|
+
tags;
|
10
|
+
tagDirectives;
|
11
|
+
constructor() {
|
15
12
|
this.tags = [];
|
16
13
|
this.tagDirectives = [];
|
17
|
-
this.registerTag(
|
18
|
-
this.registerTag(
|
19
|
-
this.registerTag(
|
20
|
-
}
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
// @ts-ignore
|
34
|
-
specificTagName = GenericMapping.uri;
|
35
|
-
}
|
36
|
-
} else if (node.tag.explicitName.startsWith('!<')) {
|
37
|
-
// verbatim form
|
38
|
-
specificTagName = node.tag.explicitName.replace(/^!</, '').replace(/>$/, '');
|
39
|
-
} else if (node.tag.explicitName.startsWith('!!')) {
|
40
|
-
// shorthand notation
|
41
|
-
specificTagName = `tag:yaml.org,2002:${node.tag.explicitName.replace(/^!!/, '')}`;
|
42
|
-
}
|
43
|
-
return specificTagName;
|
44
|
-
},
|
45
|
-
registerTagDirective(tagDirective) {
|
46
|
-
this.tagDirectives.push({
|
47
|
-
handle: tagDirective.parameters.handle,
|
48
|
-
prefix: tagDirective.parameters.prefix
|
49
|
-
});
|
50
|
-
},
|
51
|
-
registerTag(tag, beginning = false) {
|
52
|
-
if (beginning) {
|
53
|
-
this.tags.unshift(tag);
|
54
|
-
} else {
|
55
|
-
this.tags.push(tag);
|
14
|
+
this.registerTag(new GenericMappingTag());
|
15
|
+
this.registerTag(new GenericSequenceTag());
|
16
|
+
this.registerTag(new GenericStringTag());
|
17
|
+
}
|
18
|
+
|
19
|
+
// eslint-disable-next-line class-methods-use-this
|
20
|
+
toSpecificTagName(node) {
|
21
|
+
let specificTagName = node.tag.explicitName;
|
22
|
+
if (node.tag.explicitName === '!') {
|
23
|
+
// non-specific tag; we assume tag by kind
|
24
|
+
if (node.tag.kind === YamlNodeKind.Scalar) {
|
25
|
+
specificTagName = GenericStringTag.uri;
|
26
|
+
} else if (node.tag.kind === YamlNodeKind.Sequence) {
|
27
|
+
specificTagName = GenericSequenceTag.uri;
|
28
|
+
} else if (node.tag.kind === YamlNodeKind.Mapping) {
|
29
|
+
specificTagName = GenericMappingTag.uri;
|
56
30
|
}
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
31
|
+
} else if (node.tag.explicitName.startsWith('!<')) {
|
32
|
+
// verbatim form
|
33
|
+
specificTagName = node.tag.explicitName.replace(/^!</, '').replace(/>$/, '');
|
34
|
+
} else if (node.tag.explicitName.startsWith('!!')) {
|
35
|
+
// shorthand notation
|
36
|
+
specificTagName = `tag:yaml.org,2002:${node.tag.explicitName.replace(/^!!/, '')}`;
|
37
|
+
}
|
38
|
+
return specificTagName;
|
39
|
+
}
|
40
|
+
registerTagDirective(tagDirective) {
|
41
|
+
this.tagDirectives.push({
|
42
|
+
// @ts-ignore
|
43
|
+
handle: tagDirective.parameters.handle,
|
44
|
+
// @ts-ignore
|
45
|
+
prefix: tagDirective.parameters.prefix
|
46
|
+
});
|
47
|
+
}
|
48
|
+
registerTag(tag, beginning = false) {
|
49
|
+
if (beginning) {
|
50
|
+
this.tags.unshift(tag);
|
51
|
+
} else {
|
61
52
|
this.tags.push(tag);
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
53
|
+
}
|
54
|
+
return this;
|
55
|
+
}
|
56
|
+
overrideTag(tag) {
|
57
|
+
this.tags = this.tags.filter(itag => itag.tag === tag.tag);
|
58
|
+
this.tags.push(tag);
|
59
|
+
return this;
|
60
|
+
}
|
61
|
+
resolve(node) {
|
62
|
+
const specificTagName = this.toSpecificTagName(node);
|
66
63
|
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
64
|
+
// leave this node unresolved
|
65
|
+
if (specificTagName === '?') {
|
66
|
+
return node;
|
67
|
+
}
|
71
68
|
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
69
|
+
// turn scalar nodes into canonical format before resolving
|
70
|
+
let canonicalNode = node;
|
71
|
+
if (ScalarTag.test(node)) {
|
72
|
+
canonicalNode = ScalarTag.canonicalFormat(node);
|
73
|
+
}
|
74
|
+
const tag = this.tags.find(itag => (itag === null || itag === void 0 ? void 0 : itag.tag) === specificTagName);
|
78
75
|
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
76
|
+
// mechanism for resolving node (tag implementation) not found
|
77
|
+
if (typeof tag === 'undefined') {
|
78
|
+
throw new YamlTagError(`Tag "${specificTagName}" was not recognized.`, {
|
79
|
+
specificTagName,
|
80
|
+
explicitTagName: node.tag.explicitName,
|
81
|
+
tagKind: node.tag.kind,
|
82
|
+
tagPosition: clone(node.tag.position),
|
83
|
+
node: node.clone()
|
84
|
+
});
|
85
|
+
}
|
89
86
|
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
}
|
101
|
-
return tag.resolve(canonicalNode);
|
87
|
+
// node content is not compatible with resolving mechanism (tag implementation)
|
88
|
+
if (!tag.test(canonicalNode)) {
|
89
|
+
throw new YamlTagError(`Node couldn't be resolved against the tag "${specificTagName}"`, {
|
90
|
+
specificTagName,
|
91
|
+
explicitTagName: node.tag.explicitName,
|
92
|
+
tagKind: node.tag.kind,
|
93
|
+
tagPosition: clone(node.tag.position),
|
94
|
+
nodeCanonicalContent: canonicalNode.content,
|
95
|
+
node: node.clone()
|
96
|
+
});
|
102
97
|
}
|
98
|
+
return tag.resolve(canonicalNode);
|
103
99
|
}
|
104
|
-
}
|
100
|
+
}
|
105
101
|
export default FailsafeSchema;
|
@@ -1,24 +1,17 @@
|
|
1
|
-
import stampit from 'stampit';
|
2
1
|
import Tag from "../Tag.mjs";
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
stamp
|
9
|
-
}) {
|
10
|
-
this.tag = stamp.uri;
|
11
|
-
},
|
12
|
-
methods: {
|
13
|
-
test(node) {
|
14
|
-
return /^(true|false)$/.test(node.content);
|
15
|
-
},
|
16
|
-
resolve(node) {
|
17
|
-
const content = node.content === 'true';
|
18
|
-
const nodeClone = node.clone();
|
19
|
-
nodeClone.content = content;
|
20
|
-
return nodeClone;
|
21
|
-
}
|
2
|
+
/* eslint-disable class-methods-use-this */
|
3
|
+
class Boolean extends Tag {
|
4
|
+
static uri = 'tag:yaml.org,2002:bool';
|
5
|
+
test(node) {
|
6
|
+
return /^(true|false)$/.test(node.content);
|
22
7
|
}
|
23
|
-
|
8
|
+
resolve(node) {
|
9
|
+
const content = node.content === 'true';
|
10
|
+
const nodeClone = node.clone();
|
11
|
+
nodeClone.content = content;
|
12
|
+
return nodeClone;
|
13
|
+
}
|
14
|
+
}
|
15
|
+
/* eslint-enable class-methods-use-this */
|
16
|
+
|
24
17
|
export default Boolean;
|
@@ -1,24 +1,17 @@
|
|
1
|
-
import stampit from 'stampit';
|
2
1
|
import Tag from "../Tag.mjs";
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
stamp
|
9
|
-
}) {
|
10
|
-
this.tag = stamp.uri;
|
11
|
-
},
|
12
|
-
methods: {
|
13
|
-
test(node) {
|
14
|
-
return /^-?(0|[1-9][0-9]*)(\.[0-9]*)?([eE][-+]?[0-9]+)?$/.test(node.content);
|
15
|
-
},
|
16
|
-
resolve(node) {
|
17
|
-
const content = parseFloat(node.content);
|
18
|
-
const nodeClone = node.clone();
|
19
|
-
nodeClone.content = content;
|
20
|
-
return nodeClone;
|
21
|
-
}
|
2
|
+
/* eslint-disable class-methods-use-this */
|
3
|
+
class FloatingPoint extends Tag {
|
4
|
+
static uri = 'tag:yaml.org,2002:float';
|
5
|
+
test(node) {
|
6
|
+
return /^-?(0|[1-9][0-9]*)(\.[0-9]*)?([eE][-+]?[0-9]+)?$/.test(node.content);
|
22
7
|
}
|
23
|
-
|
8
|
+
resolve(node) {
|
9
|
+
const content = parseFloat(node.content);
|
10
|
+
const nodeClone = node.clone();
|
11
|
+
nodeClone.content = content;
|
12
|
+
return nodeClone;
|
13
|
+
}
|
14
|
+
}
|
15
|
+
/* eslint-enable class-methods-use-this */
|
16
|
+
|
24
17
|
export default FloatingPoint;
|
@@ -1,24 +1,17 @@
|
|
1
|
-
import stampit from 'stampit';
|
2
1
|
import Tag from "../Tag.mjs";
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
stamp
|
9
|
-
}) {
|
10
|
-
this.tag = stamp.uri;
|
11
|
-
},
|
12
|
-
methods: {
|
13
|
-
test(node) {
|
14
|
-
return /^-?(0|[1-9][0-9]*)$/.test(node.content);
|
15
|
-
},
|
16
|
-
resolve(node) {
|
17
|
-
const content = parseInt(node.content, 10);
|
18
|
-
const nodeClone = node.clone();
|
19
|
-
nodeClone.content = content;
|
20
|
-
return nodeClone;
|
21
|
-
}
|
2
|
+
/* eslint-disable class-methods-use-this */
|
3
|
+
class Integer extends Tag {
|
4
|
+
static uri = 'tag:yaml.org,2002:int';
|
5
|
+
test(node) {
|
6
|
+
return /^-?(0|[1-9][0-9]*)$/.test(node.content);
|
22
7
|
}
|
23
|
-
|
8
|
+
resolve(node) {
|
9
|
+
const content = parseInt(node.content, 10);
|
10
|
+
const nodeClone = node.clone();
|
11
|
+
nodeClone.content = content;
|
12
|
+
return nodeClone;
|
13
|
+
}
|
14
|
+
}
|
15
|
+
/* eslint-enable class-methods-use-this */
|
16
|
+
|
24
17
|
export default Integer;
|
@@ -1,23 +1,16 @@
|
|
1
|
-
import stampit from 'stampit';
|
2
1
|
import Tag from "../Tag.mjs";
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
stamp
|
9
|
-
}) {
|
10
|
-
this.tag = stamp.uri;
|
11
|
-
},
|
12
|
-
methods: {
|
13
|
-
test(node) {
|
14
|
-
return /^null$/.test(node.content);
|
15
|
-
},
|
16
|
-
resolve(node) {
|
17
|
-
const nodeClone = node.clone();
|
18
|
-
nodeClone.content = null;
|
19
|
-
return nodeClone;
|
20
|
-
}
|
2
|
+
/* eslint-disable class-methods-use-this */
|
3
|
+
class Null extends Tag {
|
4
|
+
static uri = 'tag:yaml.org,2002:null';
|
5
|
+
test(node) {
|
6
|
+
return /^null$/.test(node.content);
|
21
7
|
}
|
22
|
-
|
8
|
+
resolve(node) {
|
9
|
+
const nodeClone = node.clone();
|
10
|
+
nodeClone.content = null;
|
11
|
+
return nodeClone;
|
12
|
+
}
|
13
|
+
}
|
14
|
+
/* eslint-enable class-methods-use-this */
|
15
|
+
|
23
16
|
export default Null;
|