@swagger-api/apidom-ast 0.68.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 (110) hide show
  1. package/CHANGELOG.md +352 -0
  2. package/LICENSES/Apache-2.0.txt +202 -0
  3. package/LICENSES/MIT.txt +9 -0
  4. package/NOTICE +57 -0
  5. package/README.md +98 -0
  6. package/cjs/Error.cjs +25 -0
  7. package/cjs/Literal.cjs +22 -0
  8. package/cjs/Node.cjs +46 -0
  9. package/cjs/ParseResult.cjs +22 -0
  10. package/cjs/Position.cjs +46 -0
  11. package/cjs/index.cjs +113 -0
  12. package/cjs/json/nodes/JsonArray.cjs +21 -0
  13. package/cjs/json/nodes/JsonDocument.cjs +22 -0
  14. package/cjs/json/nodes/JsonEscapeSequence.cjs +14 -0
  15. package/cjs/json/nodes/JsonFalse.cjs +14 -0
  16. package/cjs/json/nodes/JsonKey.cjs +14 -0
  17. package/cjs/json/nodes/JsonNode.cjs +10 -0
  18. package/cjs/json/nodes/JsonNull.cjs +14 -0
  19. package/cjs/json/nodes/JsonNumber.cjs +14 -0
  20. package/cjs/json/nodes/JsonObject.cjs +21 -0
  21. package/cjs/json/nodes/JsonProperty.cjs +27 -0
  22. package/cjs/json/nodes/JsonString.cjs +27 -0
  23. package/cjs/json/nodes/JsonStringContent.cjs +14 -0
  24. package/cjs/json/nodes/JsonTrue.cjs +14 -0
  25. package/cjs/json/nodes/JsonValue.cjs +22 -0
  26. package/cjs/json/nodes/predicates.cjs +29 -0
  27. package/cjs/predicates.cjs +14 -0
  28. package/cjs/traversal/visitor.cjs +493 -0
  29. package/cjs/yaml/nodes/YamlAlias.cjs +22 -0
  30. package/cjs/yaml/nodes/YamlAnchor.cjs +22 -0
  31. package/cjs/yaml/nodes/YamlCollection.cjs +10 -0
  32. package/cjs/yaml/nodes/YamlComment.cjs +22 -0
  33. package/cjs/yaml/nodes/YamlDirective.cjs +30 -0
  34. package/cjs/yaml/nodes/YamlDocument.cjs +14 -0
  35. package/cjs/yaml/nodes/YamlKeyValuePair.cjs +40 -0
  36. package/cjs/yaml/nodes/YamlMapping.cjs +24 -0
  37. package/cjs/yaml/nodes/YamlNode.cjs +28 -0
  38. package/cjs/yaml/nodes/YamlScalar.cjs +22 -0
  39. package/cjs/yaml/nodes/YamlSequence.cjs +27 -0
  40. package/cjs/yaml/nodes/YamlStream.cjs +26 -0
  41. package/cjs/yaml/nodes/YamlStyle.cjs +33 -0
  42. package/cjs/yaml/nodes/YamlTag.cjs +32 -0
  43. package/cjs/yaml/nodes/predicates.cjs +25 -0
  44. package/cjs/yaml/schemas/ScalarTag.cjs +43 -0
  45. package/cjs/yaml/schemas/Tag.cjs +14 -0
  46. package/cjs/yaml/schemas/canonical-format.cjs +129 -0
  47. package/cjs/yaml/schemas/failsafe/GenericMapping.cjs +29 -0
  48. package/cjs/yaml/schemas/failsafe/GenericSequence.cjs +29 -0
  49. package/cjs/yaml/schemas/failsafe/GenericString.cjs +24 -0
  50. package/cjs/yaml/schemas/failsafe/index.cjs +96 -0
  51. package/cjs/yaml/schemas/json/Boolean.cjs +30 -0
  52. package/cjs/yaml/schemas/json/FloatingPoint.cjs +30 -0
  53. package/cjs/yaml/schemas/json/Integer.cjs +30 -0
  54. package/cjs/yaml/schemas/json/Null.cjs +29 -0
  55. package/cjs/yaml/schemas/json/index.cjs +47 -0
  56. package/dist/apidom-ast.browser.js +21212 -0
  57. package/dist/apidom-ast.browser.min.js +2 -0
  58. package/dist/apidom-ast.browser.min.js.LICENSE.txt +6 -0
  59. package/es/Error.js +19 -0
  60. package/es/Literal.js +16 -0
  61. package/es/Node.js +40 -0
  62. package/es/ParseResult.js +16 -0
  63. package/es/Position.js +39 -0
  64. package/es/index.js +39 -0
  65. package/es/json/nodes/JsonArray.js +15 -0
  66. package/es/json/nodes/JsonDocument.js +16 -0
  67. package/es/json/nodes/JsonEscapeSequence.js +8 -0
  68. package/es/json/nodes/JsonFalse.js +8 -0
  69. package/es/json/nodes/JsonKey.js +8 -0
  70. package/es/json/nodes/JsonNode.js +4 -0
  71. package/es/json/nodes/JsonNull.js +8 -0
  72. package/es/json/nodes/JsonNumber.js +8 -0
  73. package/es/json/nodes/JsonObject.js +15 -0
  74. package/es/json/nodes/JsonProperty.js +21 -0
  75. package/es/json/nodes/JsonString.js +21 -0
  76. package/es/json/nodes/JsonStringContent.js +8 -0
  77. package/es/json/nodes/JsonTrue.js +8 -0
  78. package/es/json/nodes/JsonValue.js +16 -0
  79. package/es/json/nodes/predicates.js +13 -0
  80. package/es/predicates.js +5 -0
  81. package/es/traversal/visitor.js +483 -0
  82. package/es/yaml/nodes/YamlAlias.js +16 -0
  83. package/es/yaml/nodes/YamlAnchor.js +16 -0
  84. package/es/yaml/nodes/YamlCollection.js +4 -0
  85. package/es/yaml/nodes/YamlComment.js +16 -0
  86. package/es/yaml/nodes/YamlDirective.js +24 -0
  87. package/es/yaml/nodes/YamlDocument.js +8 -0
  88. package/es/yaml/nodes/YamlKeyValuePair.js +34 -0
  89. package/es/yaml/nodes/YamlMapping.js +18 -0
  90. package/es/yaml/nodes/YamlNode.js +22 -0
  91. package/es/yaml/nodes/YamlScalar.js +16 -0
  92. package/es/yaml/nodes/YamlSequence.js +21 -0
  93. package/es/yaml/nodes/YamlStream.js +20 -0
  94. package/es/yaml/nodes/YamlStyle.js +25 -0
  95. package/es/yaml/nodes/YamlTag.js +25 -0
  96. package/es/yaml/nodes/predicates.js +11 -0
  97. package/es/yaml/schemas/ScalarTag.js +37 -0
  98. package/es/yaml/schemas/Tag.js +8 -0
  99. package/es/yaml/schemas/canonical-format.js +122 -0
  100. package/es/yaml/schemas/failsafe/GenericMapping.js +23 -0
  101. package/es/yaml/schemas/failsafe/GenericSequence.js +23 -0
  102. package/es/yaml/schemas/failsafe/GenericString.js +18 -0
  103. package/es/yaml/schemas/failsafe/index.js +90 -0
  104. package/es/yaml/schemas/json/Boolean.js +24 -0
  105. package/es/yaml/schemas/json/FloatingPoint.js +24 -0
  106. package/es/yaml/schemas/json/Integer.js +24 -0
  107. package/es/yaml/schemas/json/Null.js +23 -0
  108. package/es/yaml/schemas/json/index.js +41 -0
  109. package/package.json +62 -0
  110. package/types/dist.d.ts +362 -0
@@ -0,0 +1,362 @@
1
+ import stampit from 'stampit';
2
+
3
+ interface Point {
4
+ type: 'point';
5
+ row: number | null;
6
+ column: number | null;
7
+ char: number | null;
8
+ }
9
+ declare const Point: stampit.Stamp<Point>;
10
+ interface Position extends Node {
11
+ type: 'position';
12
+ start: Point | null;
13
+ end: Point | null;
14
+ }
15
+ declare const Position: stampit.Stamp<Position>;
16
+
17
+ interface Node$1 {
18
+ type: string | null;
19
+ isMissing: boolean;
20
+ children: unknown[];
21
+ position: Position | null;
22
+ }
23
+ declare const Node$1: stampit.Stamp<Node$1>;
24
+
25
+ type JsonNode = Node$1;
26
+ declare const JsonNode: stampit.Stamp<JsonNode>;
27
+
28
+ interface JsonDocument extends JsonNode {
29
+ child: unknown | null;
30
+ }
31
+ declare const JsonDocument: stampit.Stamp<JsonDocument>;
32
+
33
+ type JsonObject = JsonNode;
34
+ declare const JsonObject: stampit.Stamp<JsonObject>;
35
+
36
+ interface JsonString extends JsonNode {
37
+ value: string;
38
+ }
39
+ declare const JsonString: stampit.Stamp<JsonString>;
40
+
41
+ type JsonKey = JsonString;
42
+ declare const JsonKey: stampit.Stamp<JsonKey>;
43
+
44
+ interface JsonProperty extends JsonNode {
45
+ key: JsonKey;
46
+ value: unknown;
47
+ }
48
+ declare const JsonProperty: stampit.Stamp<JsonProperty>;
49
+
50
+ type JsonArray = JsonNode;
51
+ declare const JsonArray: stampit.Stamp<JsonArray>;
52
+
53
+ interface JsonValue extends JsonNode {
54
+ value: unknown;
55
+ }
56
+ declare const JsonValue: stampit.Stamp<JsonValue>;
57
+
58
+ type JsonStringContent = JsonValue;
59
+ declare const JsonStringContent: stampit.Stamp<JsonStringContent>;
60
+
61
+ type JsonEscapeSequence = JsonValue;
62
+ declare const JsonEscapeSequence: stampit.Stamp<JsonEscapeSequence>;
63
+
64
+ type JsonNumber = JsonValue;
65
+ declare const JsonNumber: stampit.Stamp<JsonNumber>;
66
+
67
+ type JsonTrue = JsonValue;
68
+ declare const JsonTrue: stampit.Stamp<JsonTrue>;
69
+
70
+ type JsonFalse = JsonValue;
71
+ declare const JsonFalse: stampit.Stamp<JsonFalse>;
72
+
73
+ type JsonNull = JsonValue;
74
+ declare const JsonNull: stampit.Stamp<JsonNull>;
75
+
76
+ declare const isDocument$1: (node: any) => boolean;
77
+ declare const isString: (node: any) => boolean;
78
+ declare const isFalse: (node: any) => boolean;
79
+ declare const isTrue: (node: any) => boolean;
80
+ declare const isNull: (node: any) => boolean;
81
+ declare const isNumber: (node: any) => boolean;
82
+ declare const isArray: (node: any) => boolean;
83
+ declare const isObject: (node: any) => boolean;
84
+ declare const isStringContent: (node: any) => boolean;
85
+ declare const isEscapeSequence: (node: any) => boolean;
86
+ declare const isProperty: (node: any) => boolean;
87
+ declare const isKey: (node: any) => boolean;
88
+
89
+ interface YamlAlias extends Node$1 {
90
+ type: 'alias';
91
+ content: string | null;
92
+ }
93
+ declare const YamlAlias: stampit.Stamp<YamlAlias>;
94
+
95
+ declare enum YamlNodeKind {
96
+ Scalar = "Scalar",
97
+ Sequence = "Sequence",
98
+ Mapping = "Mapping"
99
+ }
100
+ interface YamlTag extends Node$1 {
101
+ type: 'tag';
102
+ explicitName: string;
103
+ kind: YamlNodeKind;
104
+ }
105
+ declare const YamlTag: stampit.Stamp<YamlTag>;
106
+
107
+ interface YamlAnchor extends Node$1 {
108
+ type: 'anchor';
109
+ name: string | null;
110
+ }
111
+ declare const YamlAnchor: stampit.Stamp<YamlAnchor>;
112
+
113
+ declare enum YamlStyle {
114
+ Plain = "Plain",
115
+ SingleQuoted = "SingleQuoted",
116
+ DoubleQuoted = "DoubleQuoted",
117
+ Literal = "Literal",
118
+ Folded = "Folded",
119
+ Explicit = "Explicit",
120
+ SinglePair = "SinglePair",
121
+ NextLine = "NextLine",
122
+ InLine = "InLine"
123
+ }
124
+ declare enum YamlStyleGroup {
125
+ Flow = "Flow",
126
+ Block = "Block"
127
+ }
128
+ interface YamlStyleModel {
129
+ styleGroup: YamlStyleGroup | null;
130
+ style: YamlStyle | null;
131
+ }
132
+ declare const YamlStyleModel: stampit.Stamp<YamlStyleModel>;
133
+
134
+ interface YamlNode extends Node$1 {
135
+ anchor: YamlAnchor | null;
136
+ tag: YamlTag | null;
137
+ style: YamlStyle;
138
+ styleGroup: YamlStyleGroup;
139
+ }
140
+ declare const YamlNode: stampit.Stamp<YamlNode>;
141
+
142
+ type YamlCollection = YamlNode;
143
+ declare const YamlCollection: stampit.Stamp<YamlCollection>;
144
+
145
+ interface YamlComment extends Node$1 {
146
+ type: 'comment';
147
+ content: string | null;
148
+ }
149
+ declare const YamlComment: stampit.Stamp<YamlComment>;
150
+
151
+ interface YamlDirectiveParameters {
152
+ version: string | null;
153
+ handle: string | null;
154
+ prefix: string | null;
155
+ }
156
+ interface YamlDirective extends Node$1 {
157
+ type: 'directive';
158
+ name: string | null;
159
+ parameters: YamlDirectiveParameters;
160
+ }
161
+ declare const YamlDirective: stampit.Stamp<YamlDirective>;
162
+
163
+ interface YamlDocument extends Node$1 {
164
+ type: 'document';
165
+ }
166
+ declare const YamlDocument: stampit.Stamp<YamlDocument>;
167
+
168
+ interface YamlScalar extends YamlNode {
169
+ type: 'scalar';
170
+ format: string | null;
171
+ text: string;
172
+ readonly content: string | null;
173
+ }
174
+ declare const YamlScalar: stampit.Stamp<YamlScalar>;
175
+
176
+ interface YamlKeyValuePair extends Node$1, YamlStyleModel {
177
+ type: 'keyValuePair';
178
+ readonly key: YamlScalar;
179
+ readonly value: any;
180
+ }
181
+ declare const YamlKeyValuePair: stampit.Stamp<YamlKeyValuePair>;
182
+
183
+ interface YamlMapping extends YamlCollection {
184
+ type: 'mapping';
185
+ readonly content: Array<YamlKeyValuePair>;
186
+ }
187
+ declare const YamlMapping: stampit.Stamp<YamlMapping>;
188
+
189
+ interface YamlSequence extends YamlCollection {
190
+ type: 'sequence';
191
+ readonly content: Array<YamlSequence | YamlMapping | YamlScalar | YamlAlias>;
192
+ }
193
+ declare const YamlSequence: stampit.Stamp<YamlSequence>;
194
+
195
+ interface YamlStream extends Node$1 {
196
+ type: 'stream';
197
+ readonly content: Array<YamlDocument | YamlComment>;
198
+ children: Array<YamlDocument>;
199
+ }
200
+ declare const YamlStream: stampit.Stamp<YamlStream>;
201
+
202
+ declare const FailsafeSchema: stampit.Stamp<any>;
203
+
204
+ declare const JsonSchema: stampit.Stamp<any>;
205
+
206
+ declare const isStream: (node: any) => boolean;
207
+ declare const isDocument: (node: any) => boolean;
208
+ declare const isMapping: (node: any) => boolean;
209
+ declare const isSequence: (node: any) => boolean;
210
+ declare const isKeyValuePair: (node: any) => boolean;
211
+ declare const isTag: (node: any) => boolean;
212
+ declare const isScalar: (node: any) => boolean;
213
+ declare const isAlias: (node: any) => boolean;
214
+ declare const isDirective: (node: any) => boolean;
215
+
216
+ interface Literal extends Node$1 {
217
+ type: 'literal';
218
+ value: unknown;
219
+ }
220
+ declare const Literal: stampit.Stamp<Literal>;
221
+
222
+ interface Error extends Node$1 {
223
+ value: unknown;
224
+ isUnexpected: boolean;
225
+ }
226
+ declare const Error: stampit.Stamp<Error>;
227
+
228
+ interface ParseResult extends Node$1 {
229
+ type: 'parseResult';
230
+ rootNode: unknown;
231
+ }
232
+ declare const ParseResult: stampit.Stamp<ParseResult>;
233
+
234
+ declare const isLiteral: (node: any) => boolean;
235
+ declare const isPosition: (node: any) => boolean;
236
+ declare const isPoint: (node: any) => boolean;
237
+ declare const isParseResult: (node: any) => boolean;
238
+
239
+ /**
240
+ * SPDX-FileCopyrightText: Copyright (c) GraphQL Contributors
241
+ *
242
+ * SPDX-License-Identifier: MIT
243
+ */
244
+ declare const getVisitFn: (visitor: any, type: string, isLeaving: boolean) => any;
245
+ declare const BREAK: {};
246
+ declare const getNodeType: (node: any) => any;
247
+ declare const isNode: (node: any) => boolean;
248
+ /**
249
+ * Creates a new visitor instance which delegates to many visitors to run in
250
+ * parallel. Each visitor will be visited for each node before moving on.
251
+ *
252
+ * If a prior visitor edits a node, no following visitors will see that node.
253
+ */
254
+ declare const mergeAll: (visitors: any[], { visitFnGetter, nodeTypeGetter }?: {
255
+ visitFnGetter?: ((visitor: any, type: string, isLeaving: boolean) => any) | undefined;
256
+ nodeTypeGetter?: ((node: any) => any) | undefined;
257
+ }) => {
258
+ enter(node: any, ...rest: any[]): any;
259
+ leave(node: any, ...rest: any[]): any;
260
+ };
261
+ /**
262
+ * visit() will walk through an AST using a preorder depth first traversal, calling
263
+ * the visitor's enter function at each node in the traversal, and calling the
264
+ * leave function after visiting that node and all of its child nodes.
265
+ *
266
+ * By returning different values from the enter and leave functions, the
267
+ * behavior of the visitor can be altered, including skipping over a sub-tree of
268
+ * the AST (by returning false), editing the AST by returning a value or null
269
+ * to remove the value, or to stop the whole traversal by returning BREAK.
270
+ *
271
+ * When using visit() to edit an AST, the original AST will not be modified, and
272
+ * a new version of the AST with the changes applied will be returned from the
273
+ * visit function.
274
+ *
275
+ * const editedAST = visit(ast, {
276
+ * enter(node, key, parent, path, ancestors) {
277
+ * // @return
278
+ * // undefined: no action
279
+ * // false: skip visiting this node
280
+ * // BREAK: stop visiting altogether
281
+ * // null: delete this node
282
+ * // any value: replace this node with the returned value
283
+ * },
284
+ * leave(node, key, parent, path, ancestors) {
285
+ * // @return
286
+ * // undefined: no action
287
+ * // false: no action
288
+ * // BREAK: stop visiting altogether
289
+ * // null: delete this node
290
+ * // any value: replace this node with the returned value
291
+ * }
292
+ * });
293
+ *
294
+ * Alternatively to providing enter() and leave() functions, a visitor can
295
+ * instead provide functions named the same as the kinds of AST nodes, or
296
+ * enter/leave visitors at a named key, leading to four permutations of
297
+ * visitor API:
298
+ *
299
+ * 1) Named visitors triggered when entering a node a specific kind.
300
+ *
301
+ * visit(ast, {
302
+ * Kind(node) {
303
+ * // enter the "Kind" node
304
+ * }
305
+ * })
306
+ *
307
+ * 2) Named visitors that trigger upon entering and leaving a node of
308
+ * a specific kind.
309
+ *
310
+ * visit(ast, {
311
+ * Kind: {
312
+ * enter(node) {
313
+ * // enter the "Kind" node
314
+ * }
315
+ * leave(node) {
316
+ * // leave the "Kind" node
317
+ * }
318
+ * }
319
+ * })
320
+ *
321
+ * 3) Generic visitors that trigger upon entering and leaving any node.
322
+ *
323
+ * visit(ast, {
324
+ * enter(node) {
325
+ * // enter any node
326
+ * },
327
+ * leave(node) {
328
+ * // leave any node
329
+ * }
330
+ * })
331
+ *
332
+ * 4) Parallel visitors for entering and leaving nodes of a specific kind.
333
+ *
334
+ * visit(ast, {
335
+ * enter: {
336
+ * Kind(node) {
337
+ * // enter the "Kind" node
338
+ * }
339
+ * },
340
+ * leave: {
341
+ * Kind(node) {
342
+ * // leave the "Kind" node
343
+ * }
344
+ * }
345
+ * })
346
+ *
347
+ * @sig visit :: (Node, Visitor, Options)
348
+ * @sig Options = { keyMap: Object, state: Object }
349
+ */
350
+ declare const visit: (root: any, visitor: any, { keyMap, state, breakSymbol, deleteNodeSymbol, skipVisitingNodeSymbol, visitFnGetter, nodeTypeGetter, nodePredicate, detectCycles, }?: {
351
+ keyMap?: null | undefined;
352
+ state?: {} | undefined;
353
+ breakSymbol?: {} | undefined;
354
+ deleteNodeSymbol?: null | undefined;
355
+ skipVisitingNodeSymbol?: boolean | undefined;
356
+ visitFnGetter?: ((visitor: any, type: string, isLeaving: boolean) => any) | undefined;
357
+ nodeTypeGetter?: ((node: any) => any) | undefined;
358
+ nodePredicate?: ((node: any) => boolean) | undefined;
359
+ detectCycles?: boolean | undefined;
360
+ }) => any;
361
+
362
+ export { BREAK, Error, JsonArray, JsonDocument, JsonEscapeSequence, JsonFalse, JsonKey, JsonNode, JsonNull, JsonNumber, JsonObject, JsonProperty, JsonString, JsonStringContent, JsonTrue, JsonValue, Literal, ParseResult, Point, Position, YamlAlias, YamlAnchor, YamlCollection, YamlComment, YamlDirective, YamlDocument, FailsafeSchema as YamlFailsafeSchema, JsonSchema as YamlJsonSchema, YamlKeyValuePair, YamlMapping, YamlNode, YamlNodeKind, YamlScalar, YamlSequence, YamlStream, YamlStyle, YamlStyleGroup, YamlTag, getNodeType, getVisitFn, isArray as isJsonArray, isDocument$1 as isJsonDocument, isEscapeSequence as isJsonEscapeSequence, isFalse as isJsonFalse, isKey as isJsonKey, isNull as isJsonNull, isNumber as isJsonNumber, isObject as isJsonObject, isProperty as isJsonProperty, isString as isJsonString, isStringContent as isJsonStringContent, isTrue as isJsonTrue, isLiteral, isNode, isParseResult, isPoint, isPosition, isAlias as isYamlAlias, isDirective as isYamlDirective, isDocument as isYamlDocument, isKeyValuePair as isYamlKeyValuePair, isMapping as isYamlMapping, isScalar as isYamlScalar, isSequence as isYamlSequence, isStream as isYamlStream, isTag as isYamlTag, mergeAll as mergeAllVisitors, visit };