@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.
Files changed (111) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/cjs/Error.cjs +12 -13
  3. package/cjs/Literal.cjs +10 -11
  4. package/cjs/Node.cjs +26 -32
  5. package/cjs/ParseResult.cjs +5 -12
  6. package/cjs/Position.cjs +25 -32
  7. package/cjs/index.cjs +9 -1
  8. package/cjs/json/nodes/JsonArray.cjs +5 -11
  9. package/cjs/json/nodes/JsonDocument.cjs +5 -12
  10. package/cjs/json/nodes/JsonEscapeSequence.cjs +3 -6
  11. package/cjs/json/nodes/JsonFalse.cjs +3 -6
  12. package/cjs/json/nodes/JsonKey.cjs +3 -6
  13. package/cjs/json/nodes/JsonNode.cjs +1 -2
  14. package/cjs/json/nodes/JsonNull.cjs +3 -6
  15. package/cjs/json/nodes/JsonNumber.cjs +3 -6
  16. package/cjs/json/nodes/JsonObject.cjs +5 -11
  17. package/cjs/json/nodes/JsonProperty.cjs +8 -17
  18. package/cjs/json/nodes/JsonString.cjs +8 -16
  19. package/cjs/json/nodes/JsonStringContent.cjs +3 -6
  20. package/cjs/json/nodes/JsonTrue.cjs +3 -6
  21. package/cjs/json/nodes/JsonValue.cjs +11 -12
  22. package/cjs/json/nodes/predicates.cjs +24 -12
  23. package/cjs/predicates.cjs +9 -5
  24. package/cjs/yaml/anchors-aliases/ReferenceManager.cjs +28 -0
  25. package/cjs/yaml/errors/YamlError.cjs +7 -0
  26. package/cjs/yaml/errors/YamlReferenceError.cjs +8 -0
  27. package/cjs/yaml/errors/YamlSchemaError.cjs +3 -2
  28. package/cjs/yaml/errors/YamlTagError.cjs +6 -0
  29. package/cjs/yaml/nodes/YamlAlias.cjs +11 -12
  30. package/cjs/yaml/nodes/YamlAnchor.cjs +11 -12
  31. package/cjs/yaml/nodes/YamlCollection.cjs +1 -2
  32. package/cjs/yaml/nodes/YamlComment.cjs +11 -12
  33. package/cjs/yaml/nodes/YamlDirective.cjs +16 -17
  34. package/cjs/yaml/nodes/YamlDocument.cjs +3 -6
  35. package/cjs/yaml/nodes/YamlKeyValuePair.cjs +29 -27
  36. package/cjs/yaml/nodes/YamlMapping.cjs +7 -13
  37. package/cjs/yaml/nodes/YamlNode.cjs +16 -15
  38. package/cjs/yaml/nodes/YamlScalar.cjs +11 -12
  39. package/cjs/yaml/nodes/YamlSequence.cjs +10 -16
  40. package/cjs/yaml/nodes/YamlStream.cjs +7 -15
  41. package/cjs/yaml/nodes/YamlStyle.cjs +2 -11
  42. package/cjs/yaml/nodes/YamlTag.cjs +12 -13
  43. package/cjs/yaml/nodes/predicates.cjs +23 -11
  44. package/cjs/yaml/schemas/ScalarTag.cjs +23 -32
  45. package/cjs/yaml/schemas/Tag.cjs +16 -7
  46. package/cjs/yaml/schemas/failsafe/GenericMapping.cjs +7 -19
  47. package/cjs/yaml/schemas/failsafe/GenericSequence.cjs +7 -19
  48. package/cjs/yaml/schemas/failsafe/GenericString.cjs +3 -16
  49. package/cjs/yaml/schemas/failsafe/index.cjs +83 -87
  50. package/cjs/yaml/schemas/json/Boolean.cjs +13 -21
  51. package/cjs/yaml/schemas/json/FloatingPoint.cjs +13 -21
  52. package/cjs/yaml/schemas/json/Integer.cjs +13 -21
  53. package/cjs/yaml/schemas/json/Null.cjs +12 -20
  54. package/cjs/yaml/schemas/json/index.cjs +20 -26
  55. package/dist/apidom-ast.browser.js +1672 -1889
  56. package/dist/apidom-ast.browser.min.js +1 -1
  57. package/es/Error.mjs +12 -13
  58. package/es/Literal.mjs +10 -11
  59. package/es/Node.mjs +26 -31
  60. package/es/ParseResult.mjs +5 -12
  61. package/es/Position.mjs +24 -31
  62. package/es/index.mjs +4 -1
  63. package/es/json/nodes/JsonArray.mjs +5 -11
  64. package/es/json/nodes/JsonDocument.mjs +5 -12
  65. package/es/json/nodes/JsonEscapeSequence.mjs +3 -6
  66. package/es/json/nodes/JsonFalse.mjs +3 -6
  67. package/es/json/nodes/JsonKey.mjs +3 -6
  68. package/es/json/nodes/JsonNode.mjs +1 -2
  69. package/es/json/nodes/JsonNull.mjs +3 -6
  70. package/es/json/nodes/JsonNumber.mjs +3 -6
  71. package/es/json/nodes/JsonObject.mjs +5 -11
  72. package/es/json/nodes/JsonProperty.mjs +8 -17
  73. package/es/json/nodes/JsonString.mjs +8 -16
  74. package/es/json/nodes/JsonStringContent.mjs +3 -6
  75. package/es/json/nodes/JsonTrue.mjs +3 -6
  76. package/es/json/nodes/JsonValue.mjs +11 -12
  77. package/es/json/nodes/predicates.mjs +12 -12
  78. package/es/predicates.mjs +5 -5
  79. package/es/yaml/anchors-aliases/ReferenceManager.mjs +24 -0
  80. package/es/yaml/errors/YamlError.mjs +3 -0
  81. package/es/yaml/errors/YamlReferenceError.mjs +3 -0
  82. package/es/yaml/errors/YamlSchemaError.mjs +2 -2
  83. package/es/yaml/errors/YamlTagError.mjs +6 -0
  84. package/es/yaml/nodes/YamlAlias.mjs +11 -12
  85. package/es/yaml/nodes/YamlAnchor.mjs +11 -12
  86. package/es/yaml/nodes/YamlCollection.mjs +1 -2
  87. package/es/yaml/nodes/YamlComment.mjs +11 -12
  88. package/es/yaml/nodes/YamlDirective.mjs +16 -17
  89. package/es/yaml/nodes/YamlDocument.mjs +3 -6
  90. package/es/yaml/nodes/YamlKeyValuePair.mjs +29 -27
  91. package/es/yaml/nodes/YamlMapping.mjs +7 -13
  92. package/es/yaml/nodes/YamlNode.mjs +16 -15
  93. package/es/yaml/nodes/YamlScalar.mjs +11 -12
  94. package/es/yaml/nodes/YamlSequence.mjs +10 -16
  95. package/es/yaml/nodes/YamlStream.mjs +7 -15
  96. package/es/yaml/nodes/YamlStyle.mjs +1 -9
  97. package/es/yaml/nodes/YamlTag.mjs +12 -13
  98. package/es/yaml/nodes/predicates.mjs +11 -10
  99. package/es/yaml/schemas/ScalarTag.mjs +23 -31
  100. package/es/yaml/schemas/Tag.mjs +17 -6
  101. package/es/yaml/schemas/failsafe/GenericMapping.mjs +8 -19
  102. package/es/yaml/schemas/failsafe/GenericSequence.mjs +8 -19
  103. package/es/yaml/schemas/failsafe/GenericString.mjs +3 -16
  104. package/es/yaml/schemas/failsafe/index.mjs +86 -90
  105. package/es/yaml/schemas/json/Boolean.mjs +14 -21
  106. package/es/yaml/schemas/json/FloatingPoint.mjs +14 -21
  107. package/es/yaml/schemas/json/Integer.mjs +14 -21
  108. package/es/yaml/schemas/json/Null.mjs +13 -20
  109. package/es/yaml/schemas/json/index.mjs +24 -30
  110. package/package.json +3 -4
  111. 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
- const YamlSequence = stampit(YamlCollection, {
5
- statics: {
6
- type: 'sequence'
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
- propertyDescriptors: {
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
- const YamlStream = stampit(Node, {
5
- statics: {
6
- type: 'stream'
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
- propertyDescriptors: {
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
- const YamlTag = stampit(Node, {
10
- statics: {
11
- type: 'tag'
12
- },
13
- props: {
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.bind(undefined, 'stream');
3
- export const isDocument = isNodeType.bind(undefined, 'document');
4
- export const isMapping = isNodeType.bind(undefined, 'mapping');
5
- export const isSequence = isNodeType.bind(undefined, 'sequence');
6
- export const isKeyValuePair = isNodeType.bind(undefined, 'keyValuePair');
7
- export const isTag = isNodeType.bind(undefined, 'tag');
8
- export const isScalar = isNodeType.bind(undefined, 'scalar');
9
- export const isAlias = isNodeType.bind(undefined, 'alias');
10
- export const isDirective = isNodeType.bind(undefined, 'directive');
11
- export const isComment = isNodeType.bind(undefined, 'comment');
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
- const ScalarTag = stampit({
6
- methods: {
7
- test(node) {
8
- return node.tag.kind === YamlNodeKind.Scalar && typeof node.content === 'string';
9
- },
10
- canonicalFormat(node) {
11
- let canonicalForm = node.content;
12
- const nodeClone = node.clone();
13
- if (node.style === YamlStyle.Plain) {
14
- // @ts-ignore
15
- canonicalForm = formatFlowPlain(node.content);
16
- } else if (node.style === YamlStyle.SingleQuoted) {
17
- // @ts-ignore
18
- canonicalForm = formatFlowSingleQuoted(node.content);
19
- } else if (node.style === YamlStyle.DoubleQuoted) {
20
- // @ts-ignore
21
- canonicalForm = formatFlowDoubleQuoted(node.content);
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;
@@ -1,8 +1,19 @@
1
- import stampit from 'stampit';
2
- import ScalarTag from "./ScalarTag.mjs";
3
- const Tag = stampit(ScalarTag, {
4
- props: {
5
- tag: ''
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
- const GenericMapping = stampit(Tag, {
5
- statics: {
6
- uri: 'tag:yaml.org,2002:map'
7
- },
8
- init(args, {
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
- const GenericSequence = stampit(Tag, {
5
- statics: {
6
- uri: 'tag:yaml.org,2002:seq'
7
- },
8
- init(args, {
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
- const GenericString = stampit(Tag, {
4
- statics: {
5
- uri: 'tag:yaml.org,2002:str'
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 GenericMapping from "./GenericMapping.mjs";
6
- import GenericSequence from "./GenericSequence.mjs";
7
- import GenericString from "./GenericString.mjs";
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
- const FailsafeSchema = stampit({
10
- props: {
11
- tags: [],
12
- tagDirectives: []
13
- },
14
- init() {
8
+ class FailsafeSchema {
9
+ tags;
10
+ tagDirectives;
11
+ constructor() {
15
12
  this.tags = [];
16
13
  this.tagDirectives = [];
17
- this.registerTag(GenericMapping());
18
- this.registerTag(GenericSequence());
19
- this.registerTag(GenericString());
20
- },
21
- methods: {
22
- toSpecificTagName(node) {
23
- let specificTagName = node.tag.explicitName;
24
- if (node.tag.explicitName === '!') {
25
- // non-specific tag; we assume tag by kind
26
- if (node.tag.kind === YamlNodeKind.Scalar) {
27
- // @ts-ignore
28
- specificTagName = GenericString.uri;
29
- } else if (node.tag.kind === YamlNodeKind.Sequence) {
30
- // @ts-ignore
31
- specificTagName = GenericSequence.uri;
32
- } else if (node.tag.kind === YamlNodeKind.Mapping) {
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
- return this;
58
- },
59
- overrideTag(tag) {
60
- this.tags = this.tags.filter(itag => itag.tag === tag.tag);
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
- return this;
63
- },
64
- resolve(node) {
65
- const specificTagName = this.toSpecificTagName(node);
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
- // leave this node unresolved
68
- if (specificTagName === '?') {
69
- return node;
70
- }
64
+ // leave this node unresolved
65
+ if (specificTagName === '?') {
66
+ return node;
67
+ }
71
68
 
72
- // turn scalar nodes into canonical format before resolving
73
- let canonicalNode = node;
74
- if (node.tag.kind === YamlNodeKind.Scalar) {
75
- canonicalNode = ScalarTag().canonicalFormat(node);
76
- }
77
- const tag = this.tags.find(itag => (itag === null || itag === void 0 ? void 0 : itag.tag) === specificTagName);
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
- // mechanism for resolving node (tag implementation) not found
80
- if (typeof tag === 'undefined') {
81
- throw new YamlTagError(`Tag "${specificTagName}" was not recognized.`, {
82
- specificTagName,
83
- explicitTagName: node.tag.explicitName,
84
- tagKind: node.tag.kind,
85
- tagPosition: clone(node.tag.position),
86
- node: node.clone()
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
- // node content is not compatible with resolving mechanism (tag implementation)
91
- if (!tag.test(canonicalNode)) {
92
- throw new YamlTagError(`Node couldn't be resolved against the tag "${specificTagName}"`, {
93
- specificTagName,
94
- explicitTagName: node.tag.explicitName,
95
- tagKind: node.tag.kind,
96
- tagPosition: clone(node.tag.position),
97
- nodeCanonicalContent: canonicalNode.content,
98
- node: node.clone()
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
- const Boolean = stampit(Tag, {
4
- statics: {
5
- uri: 'tag:yaml.org,2002:bool'
6
- },
7
- init(args, {
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
- const FloatingPoint = stampit(Tag, {
4
- statics: {
5
- uri: 'tag:yaml.org,2002:float'
6
- },
7
- init(args, {
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
- const Integer = stampit(Tag, {
4
- statics: {
5
- uri: 'tag:yaml.org,2002:int'
6
- },
7
- init(args, {
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
- const Null = stampit(Tag, {
4
- statics: {
5
- uri: 'tag:yaml.org,2002:null'
6
- },
7
- init(args, {
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;