@swagger-api/apidom-ast 0.92.0 → 0.93.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 (99) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/cjs/Error.cjs +10 -13
  3. package/cjs/Literal.cjs +9 -11
  4. package/cjs/Node.cjs +23 -32
  5. package/cjs/ParseResult.cjs +5 -12
  6. package/cjs/Position.cjs +20 -32
  7. package/cjs/json/nodes/JsonArray.cjs +5 -11
  8. package/cjs/json/nodes/JsonDocument.cjs +5 -12
  9. package/cjs/json/nodes/JsonEscapeSequence.cjs +3 -6
  10. package/cjs/json/nodes/JsonFalse.cjs +3 -6
  11. package/cjs/json/nodes/JsonKey.cjs +3 -6
  12. package/cjs/json/nodes/JsonNode.cjs +1 -2
  13. package/cjs/json/nodes/JsonNull.cjs +3 -6
  14. package/cjs/json/nodes/JsonNumber.cjs +3 -6
  15. package/cjs/json/nodes/JsonObject.cjs +5 -11
  16. package/cjs/json/nodes/JsonProperty.cjs +8 -17
  17. package/cjs/json/nodes/JsonString.cjs +8 -16
  18. package/cjs/json/nodes/JsonStringContent.cjs +3 -6
  19. package/cjs/json/nodes/JsonTrue.cjs +3 -6
  20. package/cjs/json/nodes/JsonValue.cjs +10 -12
  21. package/cjs/json/nodes/predicates.cjs +24 -12
  22. package/cjs/predicates.cjs +9 -5
  23. package/cjs/yaml/nodes/YamlAlias.cjs +10 -12
  24. package/cjs/yaml/nodes/YamlAnchor.cjs +10 -12
  25. package/cjs/yaml/nodes/YamlCollection.cjs +1 -2
  26. package/cjs/yaml/nodes/YamlComment.cjs +10 -12
  27. package/cjs/yaml/nodes/YamlDirective.cjs +14 -17
  28. package/cjs/yaml/nodes/YamlDocument.cjs +3 -6
  29. package/cjs/yaml/nodes/YamlKeyValuePair.cjs +28 -27
  30. package/cjs/yaml/nodes/YamlMapping.cjs +7 -13
  31. package/cjs/yaml/nodes/YamlNode.cjs +12 -15
  32. package/cjs/yaml/nodes/YamlScalar.cjs +10 -12
  33. package/cjs/yaml/nodes/YamlSequence.cjs +10 -16
  34. package/cjs/yaml/nodes/YamlStream.cjs +7 -15
  35. package/cjs/yaml/nodes/YamlStyle.cjs +2 -11
  36. package/cjs/yaml/nodes/YamlTag.cjs +10 -13
  37. package/cjs/yaml/nodes/predicates.cjs +20 -10
  38. package/cjs/yaml/schemas/ScalarTag.cjs +23 -32
  39. package/cjs/yaml/schemas/Tag.cjs +16 -7
  40. package/cjs/yaml/schemas/failsafe/GenericMapping.cjs +7 -19
  41. package/cjs/yaml/schemas/failsafe/GenericSequence.cjs +7 -19
  42. package/cjs/yaml/schemas/failsafe/GenericString.cjs +3 -16
  43. package/cjs/yaml/schemas/failsafe/index.cjs +81 -87
  44. package/cjs/yaml/schemas/json/Boolean.cjs +13 -21
  45. package/cjs/yaml/schemas/json/FloatingPoint.cjs +13 -21
  46. package/cjs/yaml/schemas/json/Integer.cjs +13 -21
  47. package/cjs/yaml/schemas/json/Null.cjs +12 -20
  48. package/cjs/yaml/schemas/json/index.cjs +20 -26
  49. package/dist/apidom-ast.browser.js +577 -893
  50. package/dist/apidom-ast.browser.min.js +1 -1
  51. package/es/Error.mjs +10 -13
  52. package/es/Literal.mjs +9 -11
  53. package/es/Node.mjs +23 -31
  54. package/es/ParseResult.mjs +5 -12
  55. package/es/Position.mjs +19 -31
  56. package/es/json/nodes/JsonArray.mjs +5 -11
  57. package/es/json/nodes/JsonDocument.mjs +5 -12
  58. package/es/json/nodes/JsonEscapeSequence.mjs +3 -6
  59. package/es/json/nodes/JsonFalse.mjs +3 -6
  60. package/es/json/nodes/JsonKey.mjs +3 -6
  61. package/es/json/nodes/JsonNode.mjs +1 -2
  62. package/es/json/nodes/JsonNull.mjs +3 -6
  63. package/es/json/nodes/JsonNumber.mjs +3 -6
  64. package/es/json/nodes/JsonObject.mjs +5 -11
  65. package/es/json/nodes/JsonProperty.mjs +8 -17
  66. package/es/json/nodes/JsonString.mjs +8 -16
  67. package/es/json/nodes/JsonStringContent.mjs +3 -6
  68. package/es/json/nodes/JsonTrue.mjs +3 -6
  69. package/es/json/nodes/JsonValue.mjs +10 -12
  70. package/es/json/nodes/predicates.mjs +12 -12
  71. package/es/predicates.mjs +5 -5
  72. package/es/yaml/nodes/YamlAlias.mjs +10 -12
  73. package/es/yaml/nodes/YamlAnchor.mjs +10 -12
  74. package/es/yaml/nodes/YamlCollection.mjs +1 -2
  75. package/es/yaml/nodes/YamlComment.mjs +10 -12
  76. package/es/yaml/nodes/YamlDirective.mjs +14 -17
  77. package/es/yaml/nodes/YamlDocument.mjs +3 -6
  78. package/es/yaml/nodes/YamlKeyValuePair.mjs +28 -27
  79. package/es/yaml/nodes/YamlMapping.mjs +7 -13
  80. package/es/yaml/nodes/YamlNode.mjs +12 -15
  81. package/es/yaml/nodes/YamlScalar.mjs +10 -12
  82. package/es/yaml/nodes/YamlSequence.mjs +10 -16
  83. package/es/yaml/nodes/YamlStream.mjs +7 -15
  84. package/es/yaml/nodes/YamlStyle.mjs +1 -9
  85. package/es/yaml/nodes/YamlTag.mjs +10 -13
  86. package/es/yaml/nodes/predicates.mjs +10 -10
  87. package/es/yaml/schemas/ScalarTag.mjs +23 -31
  88. package/es/yaml/schemas/Tag.mjs +17 -6
  89. package/es/yaml/schemas/failsafe/GenericMapping.mjs +8 -19
  90. package/es/yaml/schemas/failsafe/GenericSequence.mjs +8 -19
  91. package/es/yaml/schemas/failsafe/GenericString.mjs +3 -16
  92. package/es/yaml/schemas/failsafe/index.mjs +84 -90
  93. package/es/yaml/schemas/json/Boolean.mjs +14 -21
  94. package/es/yaml/schemas/json/FloatingPoint.mjs +14 -21
  95. package/es/yaml/schemas/json/Integer.mjs +14 -21
  96. package/es/yaml/schemas/json/Null.mjs +13 -20
  97. package/es/yaml/schemas/json/index.mjs +24 -30
  98. package/package.json +3 -4
  99. package/types/dist.d.ts +222 -157
@@ -1,11 +1,11 @@
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 isScalar = node => isNodeType('scalar', node);
9
+ export const isAlias = node => isNodeType('alias', node);
10
+ export const isDirective = node => isNodeType('directive', node);
11
+ 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,99 @@
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
+ constructor() {
15
10
  this.tags = [];
16
11
  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);
12
+ this.registerTag(new GenericMappingTag());
13
+ this.registerTag(new GenericSequenceTag());
14
+ this.registerTag(new GenericStringTag());
15
+ }
16
+
17
+ // eslint-disable-next-line class-methods-use-this
18
+ toSpecificTagName(node) {
19
+ let specificTagName = node.tag.explicitName;
20
+ if (node.tag.explicitName === '!') {
21
+ // non-specific tag; we assume tag by kind
22
+ if (node.tag.kind === YamlNodeKind.Scalar) {
23
+ specificTagName = GenericStringTag.uri;
24
+ } else if (node.tag.kind === YamlNodeKind.Sequence) {
25
+ specificTagName = GenericSequenceTag.uri;
26
+ } else if (node.tag.kind === YamlNodeKind.Mapping) {
27
+ specificTagName = GenericMappingTag.uri;
56
28
  }
57
- return this;
58
- },
59
- overrideTag(tag) {
60
- this.tags = this.tags.filter(itag => itag.tag === tag.tag);
29
+ } else if (node.tag.explicitName.startsWith('!<')) {
30
+ // verbatim form
31
+ specificTagName = node.tag.explicitName.replace(/^!</, '').replace(/>$/, '');
32
+ } else if (node.tag.explicitName.startsWith('!!')) {
33
+ // shorthand notation
34
+ specificTagName = `tag:yaml.org,2002:${node.tag.explicitName.replace(/^!!/, '')}`;
35
+ }
36
+ return specificTagName;
37
+ }
38
+ registerTagDirective(tagDirective) {
39
+ this.tagDirectives.push({
40
+ // @ts-ignore
41
+ handle: tagDirective.parameters.handle,
42
+ // @ts-ignore
43
+ prefix: tagDirective.parameters.prefix
44
+ });
45
+ }
46
+ registerTag(tag, beginning = false) {
47
+ if (beginning) {
48
+ this.tags.unshift(tag);
49
+ } else {
61
50
  this.tags.push(tag);
62
- return this;
63
- },
64
- resolve(node) {
65
- const specificTagName = this.toSpecificTagName(node);
51
+ }
52
+ return this;
53
+ }
54
+ overrideTag(tag) {
55
+ this.tags = this.tags.filter(itag => itag.tag === tag.tag);
56
+ this.tags.push(tag);
57
+ return this;
58
+ }
59
+ resolve(node) {
60
+ const specificTagName = this.toSpecificTagName(node);
66
61
 
67
- // leave this node unresolved
68
- if (specificTagName === '?') {
69
- return node;
70
- }
62
+ // leave this node unresolved
63
+ if (specificTagName === '?') {
64
+ return node;
65
+ }
71
66
 
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);
67
+ // turn scalar nodes into canonical format before resolving
68
+ let canonicalNode = node;
69
+ if (ScalarTag.test(node)) {
70
+ canonicalNode = ScalarTag.canonicalFormat(node);
71
+ }
72
+ const tag = this.tags.find(itag => (itag === null || itag === void 0 ? void 0 : itag.tag) === specificTagName);
78
73
 
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
- }
74
+ // mechanism for resolving node (tag implementation) not found
75
+ if (typeof tag === 'undefined') {
76
+ throw new YamlTagError(`Tag "${specificTagName}" was not recognized.`, {
77
+ specificTagName,
78
+ explicitTagName: node.tag.explicitName,
79
+ tagKind: node.tag.kind,
80
+ tagPosition: clone(node.tag.position),
81
+ node: node.clone()
82
+ });
83
+ }
89
84
 
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);
85
+ // node content is not compatible with resolving mechanism (tag implementation)
86
+ if (!tag.test(canonicalNode)) {
87
+ throw new YamlTagError(`Node couldn't be resolved against the tag "${specificTagName}"`, {
88
+ specificTagName,
89
+ explicitTagName: node.tag.explicitName,
90
+ tagKind: node.tag.kind,
91
+ tagPosition: clone(node.tag.position),
92
+ nodeCanonicalContent: canonicalNode.content,
93
+ node: node.clone()
94
+ });
102
95
  }
96
+ return tag.resolve(canonicalNode);
103
97
  }
104
- });
98
+ }
105
99
  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;
@@ -1,41 +1,35 @@
1
- import stampit from 'stampit';
2
1
  import FailsafeSchema from "../failsafe/index.mjs";
3
- import Boolean from "./Boolean.mjs";
4
- import FloatingPoint from "./FloatingPoint.mjs";
5
- import Integer from "./Integer.mjs";
6
- import Null from "./Null.mjs";
2
+ import BooleanTag from "./Boolean.mjs";
3
+ import FloatingPointTag from "./FloatingPoint.mjs";
4
+ import IntegerTag from "./Integer.mjs";
5
+ import NullTag from "./Null.mjs";
7
6
  import { YamlNodeKind } from "../../nodes/YamlTag.mjs";
8
7
  import GenericSequence from "../failsafe/GenericSequence.mjs";
9
8
  import GenericMapping from "../failsafe/GenericMapping.mjs";
10
- const JsonSchema = stampit(FailsafeSchema, {
11
- init() {
9
+ class JsonSchema extends FailsafeSchema {
10
+ constructor() {
11
+ super();
12
12
  /**
13
13
  * We're registering more specific tags before more generic ones from Failsafe schema.
14
14
  */
15
- this.registerTag(Boolean(), true);
16
- this.registerTag(FloatingPoint(), true);
17
- this.registerTag(Integer(), true);
18
- this.registerTag(Null(), true);
19
- },
20
- methods: {
21
- toSpecificTagName(node) {
22
- // @ts-ignore
23
- let specificTagName = FailsafeSchema.compose.methods.toSpecificTagName.call(this, node);
24
- if (specificTagName === '?') {
25
- if (node.tag.vkind === YamlNodeKind.Sequence) {
26
- // @ts-ignore
27
- specificTagName = GenericSequence.uri;
28
- } else if (node.tag.kind === YamlNodeKind.Mapping) {
29
- // @ts-ignore
30
- specificTagName = GenericMapping.uri;
31
- } else if (node.tag.kind === YamlNodeKind.Scalar) {
32
- // @ts-ignore
33
- const foundTag = this.tags.find(tag => tag.test(node));
34
- specificTagName = (foundTag === null || foundTag === void 0 ? void 0 : foundTag.tag) || '?';
35
- }
15
+ this.registerTag(new BooleanTag(), true);
16
+ this.registerTag(new FloatingPointTag(), true);
17
+ this.registerTag(new IntegerTag(), true);
18
+ this.registerTag(new NullTag(), true);
19
+ }
20
+ toSpecificTagName(node) {
21
+ let specificTagName = super.toSpecificTagName(node);
22
+ if (specificTagName === '?') {
23
+ if (node.tag.vkind === YamlNodeKind.Sequence) {
24
+ specificTagName = GenericSequence.uri;
25
+ } else if (node.tag.kind === YamlNodeKind.Mapping) {
26
+ specificTagName = GenericMapping.uri;
27
+ } else if (node.tag.kind === YamlNodeKind.Scalar) {
28
+ const foundTag = this.tags.find(tag => tag.test(node));
29
+ specificTagName = (foundTag === null || foundTag === void 0 ? void 0 : foundTag.tag) || '?';
36
30
  }
37
- return specificTagName;
38
31
  }
32
+ return specificTagName;
39
33
  }
40
- });
34
+ }
41
35
  export default JsonSchema;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@swagger-api/apidom-ast",
3
- "version": "0.92.0",
3
+ "version": "0.93.0",
4
4
  "description": "Tools necessary for parsing stage of ApiDOM, specifically for syntactic analysis.",
5
5
  "publishConfig": {
6
6
  "access": "public",
@@ -42,11 +42,10 @@
42
42
  "homepage": "https://github.com/swagger-api/apidom#readme",
43
43
  "dependencies": {
44
44
  "@babel/runtime-corejs3": "^7.20.7",
45
- "@swagger-api/apidom-error": "^0.92.0",
45
+ "@swagger-api/apidom-error": "^0.93.0",
46
46
  "@types/ramda": "~0.29.6",
47
47
  "ramda": "~0.29.1",
48
48
  "ramda-adjunct": "^4.1.1",
49
- "stampit": "^4.3.2",
50
49
  "unraw": "^3.0.0"
51
50
  },
52
51
  "files": [
@@ -59,5 +58,5 @@
59
58
  "README.md",
60
59
  "CHANGELOG.md"
61
60
  ],
62
- "gitHead": "c7a45ee8d68ac82ac2ab93ebb639a95ced1d6e86"
61
+ "gitHead": "65ea9068f5d8b144293c2f91eb5fe5ebacfd947c"
63
62
  }