@kubb/agent 4.33.5 → 4.34.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/.output/nitro.json +1 -1
- package/.output/server/chunks/nitro/nitro.mjs +22 -4176
- package/.output/server/chunks/nitro/nitro.mjs.map +1 -1
- package/.output/server/chunks/routes/api/health.get.mjs +1 -0
- package/.output/server/chunks/routes/api/health.get.mjs.map +1 -1
- package/.output/server/index.mjs +1 -0
- package/.output/server/index.mjs.map +1 -1
- package/.output/server/node_modules/@stoplight/ordered-object-literal/package.json +53 -0
- package/.output/server/node_modules/@stoplight/ordered-object-literal/src/index.cjs +221 -0
- package/.output/server/node_modules/@stoplight/types/dist/index.js +129 -0
- package/.output/server/node_modules/@stoplight/types/package.json +81 -0
- package/.output/server/node_modules/@stoplight/yaml/buildJsonPath.js +41 -0
- package/.output/server/node_modules/@stoplight/yaml/dereferenceAnchor.js +38 -0
- package/.output/server/node_modules/@stoplight/yaml/getJsonPathForPosition.js +98 -0
- package/.output/server/node_modules/@stoplight/yaml/getLocationForJsonPath.js +145 -0
- package/.output/server/node_modules/@stoplight/yaml/index.js +16 -0
- package/.output/server/node_modules/@stoplight/yaml/lineForPosition.js +31 -0
- package/.output/server/node_modules/@stoplight/yaml/package.json +33 -0
- package/.output/server/node_modules/@stoplight/yaml/parse.js +5 -0
- package/.output/server/node_modules/@stoplight/yaml/parseWithPointers.js +456 -0
- package/.output/server/node_modules/@stoplight/yaml/safeStringify.js +5 -0
- package/.output/server/node_modules/@stoplight/yaml/trapAccess.js +11 -0
- package/.output/server/node_modules/@stoplight/yaml/types.js +6 -0
- package/.output/server/node_modules/@stoplight/yaml/utils.js +4 -0
- package/.output/server/node_modules/@stoplight/yaml-ast-parser/dist/src/common.js +45 -0
- package/.output/server/node_modules/@stoplight/yaml-ast-parser/dist/src/dumper.js +710 -0
- package/.output/server/node_modules/@stoplight/yaml-ast-parser/dist/src/exception.js +35 -0
- package/.output/server/node_modules/@stoplight/yaml-ast-parser/dist/src/index.js +22 -0
- package/.output/server/node_modules/@stoplight/yaml-ast-parser/dist/src/loader.js +1414 -0
- package/.output/server/node_modules/@stoplight/yaml-ast-parser/dist/src/mark.js +58 -0
- package/.output/server/node_modules/@stoplight/yaml-ast-parser/dist/src/scalarInference.js +90 -0
- package/.output/server/node_modules/@stoplight/yaml-ast-parser/dist/src/schema/core.js +8 -0
- package/.output/server/node_modules/@stoplight/yaml-ast-parser/dist/src/schema/default_full.js +14 -0
- package/.output/server/node_modules/@stoplight/yaml-ast-parser/dist/src/schema/default_safe.js +19 -0
- package/.output/server/node_modules/@stoplight/yaml-ast-parser/dist/src/schema/failsafe.js +10 -0
- package/.output/server/node_modules/@stoplight/yaml-ast-parser/dist/src/schema/json.js +14 -0
- package/.output/server/node_modules/@stoplight/yaml-ast-parser/dist/src/schema.js +77 -0
- package/.output/server/node_modules/@stoplight/yaml-ast-parser/dist/src/type/binary.js +92 -0
- package/.output/server/node_modules/@stoplight/yaml-ast-parser/dist/src/type/bool.js +32 -0
- package/.output/server/node_modules/@stoplight/yaml-ast-parser/dist/src/type/float.js +94 -0
- package/.output/server/node_modules/@stoplight/yaml-ast-parser/dist/src/type/int.js +159 -0
- package/.output/server/node_modules/@stoplight/yaml-ast-parser/dist/src/type/js/regexp.js +64 -0
- package/.output/server/node_modules/@stoplight/yaml-ast-parser/dist/src/type/js/undefined.js +22 -0
- package/.output/server/node_modules/@stoplight/yaml-ast-parser/dist/src/type/map.js +7 -0
- package/.output/server/node_modules/@stoplight/yaml-ast-parser/dist/src/type/merge.js +10 -0
- package/.output/server/node_modules/@stoplight/yaml-ast-parser/dist/src/type/null.js +30 -0
- package/.output/server/node_modules/@stoplight/yaml-ast-parser/dist/src/type/omap.js +46 -0
- package/.output/server/node_modules/@stoplight/yaml-ast-parser/dist/src/type/pairs.js +55 -0
- package/.output/server/node_modules/@stoplight/yaml-ast-parser/dist/src/type/seq.js +7 -0
- package/.output/server/node_modules/@stoplight/yaml-ast-parser/dist/src/type/set.js +22 -0
- package/.output/server/node_modules/@stoplight/yaml-ast-parser/dist/src/type/str.js +7 -0
- package/.output/server/node_modules/@stoplight/yaml-ast-parser/dist/src/type/timestamp.js +70 -0
- package/.output/server/node_modules/@stoplight/yaml-ast-parser/dist/src/type.js +53 -0
- package/.output/server/node_modules/@stoplight/yaml-ast-parser/dist/src/yamlAST.js +81 -0
- package/.output/server/node_modules/@stoplight/yaml-ast-parser/package.json +38 -0
- package/.output/server/node_modules/tslib/package.json +47 -0
- package/.output/server/node_modules/tslib/tslib.js +484 -0
- package/.output/server/package.json +6 -1
- package/package.json +16 -16
|
@@ -0,0 +1,456 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const ordered_object_literal_1 = require("@stoplight/ordered-object-literal");
|
|
4
|
+
const types_1 = require("@stoplight/types");
|
|
5
|
+
const yaml_ast_parser_1 = require("@stoplight/yaml-ast-parser");
|
|
6
|
+
const buildJsonPath_1 = require("./buildJsonPath");
|
|
7
|
+
const dereferenceAnchor_1 = require("./dereferenceAnchor");
|
|
8
|
+
const lineForPosition_1 = require("./lineForPosition");
|
|
9
|
+
const types_2 = require("./types");
|
|
10
|
+
const utils_1 = require("./utils");
|
|
11
|
+
exports.parseWithPointers = (value, options) => {
|
|
12
|
+
const lineMap = computeLineMap(value);
|
|
13
|
+
const ast = yaml_ast_parser_1.load(value, Object.assign({}, options, { ignoreDuplicateKeys: true }));
|
|
14
|
+
const parsed = {
|
|
15
|
+
ast,
|
|
16
|
+
lineMap,
|
|
17
|
+
data: undefined,
|
|
18
|
+
diagnostics: [],
|
|
19
|
+
metadata: options,
|
|
20
|
+
comments: {},
|
|
21
|
+
};
|
|
22
|
+
if (!ast)
|
|
23
|
+
return parsed;
|
|
24
|
+
const normalizedOptions = normalizeOptions(options);
|
|
25
|
+
const comments = new Comments(parsed.comments, Comments.mapComments(normalizedOptions.attachComments && ast.comments ? ast.comments : [], lineMap), ast, lineMap, '#');
|
|
26
|
+
const ctx = {
|
|
27
|
+
lineMap,
|
|
28
|
+
diagnostics: parsed.diagnostics,
|
|
29
|
+
};
|
|
30
|
+
parsed.data = walkAST(ctx, ast, comments, normalizedOptions);
|
|
31
|
+
if (ast.errors) {
|
|
32
|
+
parsed.diagnostics.push(...transformErrors(ast.errors, lineMap));
|
|
33
|
+
}
|
|
34
|
+
if (parsed.diagnostics.length > 0) {
|
|
35
|
+
parsed.diagnostics.sort((itemA, itemB) => itemA.range.start.line - itemB.range.start.line);
|
|
36
|
+
}
|
|
37
|
+
if (Array.isArray(parsed.ast.errors)) {
|
|
38
|
+
parsed.ast.errors.length = 0;
|
|
39
|
+
}
|
|
40
|
+
return parsed;
|
|
41
|
+
};
|
|
42
|
+
const TILDE_REGEXP = /~/g;
|
|
43
|
+
const SLASH_REGEXP = /\//g;
|
|
44
|
+
function encodeSegment(input) {
|
|
45
|
+
return input.replace(TILDE_REGEXP, '~0').replace(SLASH_REGEXP, '~1');
|
|
46
|
+
}
|
|
47
|
+
const walkAST = (ctx, node, comments, options) => {
|
|
48
|
+
if (node) {
|
|
49
|
+
switch (node.kind) {
|
|
50
|
+
case types_2.Kind.MAP: {
|
|
51
|
+
const mapComments = comments.enter(node);
|
|
52
|
+
const { lineMap, diagnostics } = ctx;
|
|
53
|
+
const { preserveKeyOrder, ignoreDuplicateKeys, json, mergeKeys } = options;
|
|
54
|
+
const container = createMapContainer(preserveKeyOrder);
|
|
55
|
+
const seenKeys = [];
|
|
56
|
+
const handleMergeKeys = mergeKeys;
|
|
57
|
+
const yamlMode = !json;
|
|
58
|
+
const handleDuplicates = !ignoreDuplicateKeys;
|
|
59
|
+
for (const mapping of node.mappings) {
|
|
60
|
+
if (!validateMappingKey(mapping, lineMap, diagnostics, yamlMode))
|
|
61
|
+
continue;
|
|
62
|
+
const key = String(getScalarValue(mapping.key));
|
|
63
|
+
const mappingComments = mapComments.enter(mapping, encodeSegment(key));
|
|
64
|
+
if ((yamlMode || handleDuplicates) && (!handleMergeKeys || key !== "<<")) {
|
|
65
|
+
if (seenKeys.includes(key)) {
|
|
66
|
+
if (yamlMode) {
|
|
67
|
+
throw new Error('Duplicate YAML mapping key encountered');
|
|
68
|
+
}
|
|
69
|
+
if (handleDuplicates) {
|
|
70
|
+
diagnostics.push(createYAMLException(mapping.key, lineMap, 'duplicate key'));
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
else {
|
|
74
|
+
seenKeys.push(key);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
if (handleMergeKeys && key === "<<") {
|
|
78
|
+
const reduced = reduceMergeKeys(walkAST(ctx, mapping.value, mappingComments, options), preserveKeyOrder);
|
|
79
|
+
Object.assign(container, reduced);
|
|
80
|
+
}
|
|
81
|
+
else {
|
|
82
|
+
container[key] = walkAST(ctx, mapping.value, mappingComments, options);
|
|
83
|
+
if (preserveKeyOrder) {
|
|
84
|
+
pushKey(container, key);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
mappingComments.attachComments();
|
|
88
|
+
}
|
|
89
|
+
mapComments.attachComments();
|
|
90
|
+
return container;
|
|
91
|
+
}
|
|
92
|
+
case types_2.Kind.SEQ: {
|
|
93
|
+
const nodeComments = comments.enter(node);
|
|
94
|
+
const container = node.items.map((item, i) => {
|
|
95
|
+
if (item !== null) {
|
|
96
|
+
const sequenceItemComments = nodeComments.enter(item, i);
|
|
97
|
+
const walked = walkAST(ctx, item, sequenceItemComments, options);
|
|
98
|
+
sequenceItemComments.attachComments();
|
|
99
|
+
return walked;
|
|
100
|
+
}
|
|
101
|
+
else {
|
|
102
|
+
return null;
|
|
103
|
+
}
|
|
104
|
+
});
|
|
105
|
+
nodeComments.attachComments();
|
|
106
|
+
return container;
|
|
107
|
+
}
|
|
108
|
+
case types_2.Kind.SCALAR: {
|
|
109
|
+
const value = getScalarValue(node);
|
|
110
|
+
return !options.bigInt && typeof value === 'bigint' ? Number(value) : value;
|
|
111
|
+
}
|
|
112
|
+
case types_2.Kind.ANCHOR_REF: {
|
|
113
|
+
if (utils_1.isObject(node.value)) {
|
|
114
|
+
node.value = dereferenceAnchor_1.dereferenceAnchor(node.value, node.referencesAnchor);
|
|
115
|
+
}
|
|
116
|
+
return walkAST(ctx, node.value, comments, options);
|
|
117
|
+
}
|
|
118
|
+
default:
|
|
119
|
+
return null;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
return node;
|
|
123
|
+
};
|
|
124
|
+
function getScalarValue(node) {
|
|
125
|
+
switch (yaml_ast_parser_1.determineScalarType(node)) {
|
|
126
|
+
case types_2.ScalarType.null:
|
|
127
|
+
return null;
|
|
128
|
+
case types_2.ScalarType.string:
|
|
129
|
+
return String(node.value);
|
|
130
|
+
case types_2.ScalarType.bool:
|
|
131
|
+
return yaml_ast_parser_1.parseYamlBoolean(node.value);
|
|
132
|
+
case types_2.ScalarType.int:
|
|
133
|
+
return yaml_ast_parser_1.parseYamlBigInteger(node.value);
|
|
134
|
+
case types_2.ScalarType.float:
|
|
135
|
+
return yaml_ast_parser_1.parseYamlFloat(node.value);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
const computeLineMap = (input) => {
|
|
139
|
+
const lineMap = [];
|
|
140
|
+
let i = 0;
|
|
141
|
+
for (; i < input.length; i++) {
|
|
142
|
+
if (input[i] === '\n') {
|
|
143
|
+
lineMap.push(i + 1);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
lineMap.push(i + 1);
|
|
147
|
+
return lineMap;
|
|
148
|
+
};
|
|
149
|
+
function getLineLength(lineMap, line) {
|
|
150
|
+
if (line === 0) {
|
|
151
|
+
return Math.max(0, lineMap[0] - 1);
|
|
152
|
+
}
|
|
153
|
+
return Math.max(0, lineMap[line] - lineMap[line - 1] - 1);
|
|
154
|
+
}
|
|
155
|
+
const transformErrors = (errors, lineMap) => {
|
|
156
|
+
const validations = [];
|
|
157
|
+
let possiblyUnexpectedFlow = -1;
|
|
158
|
+
let i = 0;
|
|
159
|
+
for (const error of errors) {
|
|
160
|
+
const validation = {
|
|
161
|
+
code: error.name,
|
|
162
|
+
message: error.reason,
|
|
163
|
+
severity: error.isWarning ? types_1.DiagnosticSeverity.Warning : types_1.DiagnosticSeverity.Error,
|
|
164
|
+
range: {
|
|
165
|
+
start: {
|
|
166
|
+
line: error.mark.line,
|
|
167
|
+
character: error.mark.column,
|
|
168
|
+
},
|
|
169
|
+
end: {
|
|
170
|
+
line: error.mark.line,
|
|
171
|
+
character: error.mark.toLineEnd ? getLineLength(lineMap, error.mark.line) : error.mark.column,
|
|
172
|
+
},
|
|
173
|
+
},
|
|
174
|
+
};
|
|
175
|
+
const isBrokenFlow = error.reason === 'missed comma between flow collection entries';
|
|
176
|
+
if (isBrokenFlow) {
|
|
177
|
+
possiblyUnexpectedFlow = possiblyUnexpectedFlow === -1 ? i : possiblyUnexpectedFlow;
|
|
178
|
+
}
|
|
179
|
+
else if (possiblyUnexpectedFlow !== -1) {
|
|
180
|
+
validations[possiblyUnexpectedFlow].range.end = validation.range.end;
|
|
181
|
+
validations[possiblyUnexpectedFlow].message = 'invalid mixed usage of block and flow styles';
|
|
182
|
+
validations.length = possiblyUnexpectedFlow + 1;
|
|
183
|
+
i = validations.length;
|
|
184
|
+
possiblyUnexpectedFlow = -1;
|
|
185
|
+
}
|
|
186
|
+
validations.push(validation);
|
|
187
|
+
i++;
|
|
188
|
+
}
|
|
189
|
+
return validations;
|
|
190
|
+
};
|
|
191
|
+
const reduceMergeKeys = (items, preserveKeyOrder) => {
|
|
192
|
+
if (Array.isArray(items)) {
|
|
193
|
+
const reduced = items.reduceRight(preserveKeyOrder
|
|
194
|
+
? (merged, item) => {
|
|
195
|
+
const keys = Object.keys(item);
|
|
196
|
+
Object.assign(merged, item);
|
|
197
|
+
for (let i = keys.length - 1; i >= 0; i--) {
|
|
198
|
+
unshiftKey(merged, keys[i]);
|
|
199
|
+
}
|
|
200
|
+
return merged;
|
|
201
|
+
}
|
|
202
|
+
: (merged, item) => Object.assign(merged, item), createMapContainer(preserveKeyOrder));
|
|
203
|
+
return reduced;
|
|
204
|
+
}
|
|
205
|
+
return typeof items !== 'object' || items === null ? null : Object(items);
|
|
206
|
+
};
|
|
207
|
+
function createMapContainer(preserveKeyOrder) {
|
|
208
|
+
return preserveKeyOrder ? ordered_object_literal_1.default({}) : {};
|
|
209
|
+
}
|
|
210
|
+
function deleteKey(container, key) {
|
|
211
|
+
if (!(key in container))
|
|
212
|
+
return;
|
|
213
|
+
const order = ordered_object_literal_1.getOrder(container);
|
|
214
|
+
const index = order.indexOf(key);
|
|
215
|
+
if (index !== -1) {
|
|
216
|
+
order.splice(index, 1);
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
function unshiftKey(container, key) {
|
|
220
|
+
deleteKey(container, key);
|
|
221
|
+
ordered_object_literal_1.getOrder(container).unshift(key);
|
|
222
|
+
}
|
|
223
|
+
function pushKey(container, key) {
|
|
224
|
+
deleteKey(container, key);
|
|
225
|
+
ordered_object_literal_1.getOrder(container).push(key);
|
|
226
|
+
}
|
|
227
|
+
function validateMappingKey(mapping, lineMap, diagnostics, yamlMode) {
|
|
228
|
+
if (mapping.key.kind !== types_2.Kind.SCALAR) {
|
|
229
|
+
if (!yamlMode) {
|
|
230
|
+
diagnostics.push(createYAMLIncompatibilityException(mapping.key, lineMap, 'mapping key must be a string scalar', yamlMode));
|
|
231
|
+
}
|
|
232
|
+
return false;
|
|
233
|
+
}
|
|
234
|
+
if (!yamlMode) {
|
|
235
|
+
const type = typeof getScalarValue(mapping.key);
|
|
236
|
+
if (type !== 'string') {
|
|
237
|
+
diagnostics.push(createYAMLIncompatibilityException(mapping.key, lineMap, `mapping key must be a string scalar rather than ${mapping.key.valueObject === null ? 'null' : type}`, yamlMode));
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
return true;
|
|
241
|
+
}
|
|
242
|
+
function createYAMLIncompatibilityException(node, lineMap, message, yamlMode) {
|
|
243
|
+
const exception = createYAMLException(node, lineMap, message);
|
|
244
|
+
exception.code = 'YAMLIncompatibleValue';
|
|
245
|
+
exception.severity = yamlMode ? types_1.DiagnosticSeverity.Hint : types_1.DiagnosticSeverity.Warning;
|
|
246
|
+
return exception;
|
|
247
|
+
}
|
|
248
|
+
function createYAMLException(node, lineMap, message) {
|
|
249
|
+
return {
|
|
250
|
+
code: 'YAMLException',
|
|
251
|
+
message,
|
|
252
|
+
severity: types_1.DiagnosticSeverity.Error,
|
|
253
|
+
path: buildJsonPath_1.buildJsonPath(node),
|
|
254
|
+
range: getRange(lineMap, node.startPosition, node.endPosition),
|
|
255
|
+
};
|
|
256
|
+
}
|
|
257
|
+
function getRange(lineMap, startPosition, endPosition) {
|
|
258
|
+
const startLine = lineForPosition_1.lineForPosition(startPosition, lineMap);
|
|
259
|
+
const endLine = lineForPosition_1.lineForPosition(endPosition, lineMap);
|
|
260
|
+
return {
|
|
261
|
+
start: {
|
|
262
|
+
line: startLine,
|
|
263
|
+
character: startLine === 0 ? startPosition : startPosition - lineMap[startLine - 1],
|
|
264
|
+
},
|
|
265
|
+
end: {
|
|
266
|
+
line: endLine,
|
|
267
|
+
character: endLine === 0 ? endPosition : endPosition - lineMap[endLine - 1],
|
|
268
|
+
},
|
|
269
|
+
};
|
|
270
|
+
}
|
|
271
|
+
class Comments {
|
|
272
|
+
constructor(attachedComments, comments, node, lineMap, pointer) {
|
|
273
|
+
this.attachedComments = attachedComments;
|
|
274
|
+
this.node = node;
|
|
275
|
+
this.lineMap = lineMap;
|
|
276
|
+
this.pointer = pointer;
|
|
277
|
+
if (comments.length === 0) {
|
|
278
|
+
this.comments = [];
|
|
279
|
+
}
|
|
280
|
+
else {
|
|
281
|
+
const startPosition = this.getStartPosition(node);
|
|
282
|
+
const endPosition = this.getEndPosition(node);
|
|
283
|
+
const startLine = lineForPosition_1.lineForPosition(startPosition, this.lineMap);
|
|
284
|
+
const endLine = lineForPosition_1.lineForPosition(endPosition, this.lineMap);
|
|
285
|
+
const matchingComments = [];
|
|
286
|
+
for (let i = comments.length - 1; i >= 0; i--) {
|
|
287
|
+
const comment = comments[i];
|
|
288
|
+
if (comment.range.start.line >= startLine && comment.range.end.line <= endLine) {
|
|
289
|
+
matchingComments.push(comment);
|
|
290
|
+
comments.splice(i, 1);
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
this.comments = matchingComments;
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
getStartPosition(node) {
|
|
297
|
+
if (node.parent === null) {
|
|
298
|
+
return 0;
|
|
299
|
+
}
|
|
300
|
+
return node.kind === types_2.Kind.MAPPING ? node.key.startPosition : node.startPosition;
|
|
301
|
+
}
|
|
302
|
+
getEndPosition(node) {
|
|
303
|
+
switch (node.kind) {
|
|
304
|
+
case types_2.Kind.MAPPING:
|
|
305
|
+
return node.value === null ? node.endPosition : this.getEndPosition(node.value);
|
|
306
|
+
case types_2.Kind.MAP:
|
|
307
|
+
return node.mappings.length === 0 ? node.endPosition : node.mappings[node.mappings.length - 1].endPosition;
|
|
308
|
+
case types_2.Kind.SEQ: {
|
|
309
|
+
if (node.items.length === 0) {
|
|
310
|
+
return node.endPosition;
|
|
311
|
+
}
|
|
312
|
+
const lastItem = node.items[node.items.length - 1];
|
|
313
|
+
return lastItem === null ? node.endPosition : lastItem.endPosition;
|
|
314
|
+
}
|
|
315
|
+
default:
|
|
316
|
+
return node.endPosition;
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
static mapComments(comments, lineMap) {
|
|
320
|
+
return comments.map(comment => ({
|
|
321
|
+
value: comment.value,
|
|
322
|
+
range: getRange(lineMap, comment.startPosition, comment.endPosition),
|
|
323
|
+
startPosition: comment.startPosition,
|
|
324
|
+
endPosition: comment.endPosition,
|
|
325
|
+
}));
|
|
326
|
+
}
|
|
327
|
+
enter(node, key) {
|
|
328
|
+
return new Comments(this.attachedComments, this.comments, node, this.lineMap, key === void 0 ? this.pointer : `${this.pointer}/${key}`);
|
|
329
|
+
}
|
|
330
|
+
static isLeading(node, startPosition) {
|
|
331
|
+
switch (node.kind) {
|
|
332
|
+
case types_2.Kind.MAP:
|
|
333
|
+
return node.mappings.length === 0 || node.mappings[0].startPosition > startPosition;
|
|
334
|
+
case types_2.Kind.SEQ: {
|
|
335
|
+
if (node.items.length === 0) {
|
|
336
|
+
return true;
|
|
337
|
+
}
|
|
338
|
+
const firstItem = node.items[0];
|
|
339
|
+
return firstItem === null || firstItem.startPosition > startPosition;
|
|
340
|
+
}
|
|
341
|
+
case types_2.Kind.MAPPING:
|
|
342
|
+
return node.value === null || node.value.startPosition > startPosition;
|
|
343
|
+
default:
|
|
344
|
+
return false;
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
static isTrailing(node, endPosition) {
|
|
348
|
+
switch (node.kind) {
|
|
349
|
+
case types_2.Kind.MAP:
|
|
350
|
+
return node.mappings.length > 0 && endPosition > node.mappings[node.mappings.length - 1].endPosition;
|
|
351
|
+
case types_2.Kind.SEQ:
|
|
352
|
+
if (node.items.length === 0) {
|
|
353
|
+
return false;
|
|
354
|
+
}
|
|
355
|
+
const lastItem = node.items[node.items.length - 1];
|
|
356
|
+
return lastItem !== null && endPosition > lastItem.endPosition;
|
|
357
|
+
case types_2.Kind.MAPPING:
|
|
358
|
+
return node.value !== null && endPosition > node.value.endPosition;
|
|
359
|
+
default:
|
|
360
|
+
return false;
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
static findBetween(node, startPosition, endPosition) {
|
|
364
|
+
switch (node.kind) {
|
|
365
|
+
case types_2.Kind.MAP: {
|
|
366
|
+
let left;
|
|
367
|
+
for (const mapping of node.mappings) {
|
|
368
|
+
if (startPosition > mapping.startPosition) {
|
|
369
|
+
left = mapping.key.value;
|
|
370
|
+
}
|
|
371
|
+
else if (left !== void 0 && mapping.startPosition > endPosition) {
|
|
372
|
+
return [left, mapping.key.value];
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
return null;
|
|
376
|
+
}
|
|
377
|
+
case types_2.Kind.SEQ: {
|
|
378
|
+
let left;
|
|
379
|
+
for (let i = 0; i < node.items.length; i++) {
|
|
380
|
+
const item = node.items[i];
|
|
381
|
+
if (item === null)
|
|
382
|
+
continue;
|
|
383
|
+
if (startPosition > item.startPosition) {
|
|
384
|
+
left = String(i);
|
|
385
|
+
}
|
|
386
|
+
else if (left !== void 0 && item.startPosition > endPosition) {
|
|
387
|
+
return [left, String(i)];
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
return null;
|
|
391
|
+
}
|
|
392
|
+
default:
|
|
393
|
+
return null;
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
isBeforeEOL(comment) {
|
|
397
|
+
return (this.node.kind === types_2.Kind.SCALAR ||
|
|
398
|
+
(this.node.kind === types_2.Kind.MAPPING &&
|
|
399
|
+
comment.range.end.line === lineForPosition_1.lineForPosition(this.node.key.endPosition, this.lineMap)));
|
|
400
|
+
}
|
|
401
|
+
attachComments() {
|
|
402
|
+
if (this.comments.length === 0)
|
|
403
|
+
return;
|
|
404
|
+
const attachedComments = (this.attachedComments[this.pointer] = this.attachedComments[this.pointer] || []);
|
|
405
|
+
for (const comment of this.comments) {
|
|
406
|
+
if (this.isBeforeEOL(comment)) {
|
|
407
|
+
attachedComments.push({
|
|
408
|
+
value: comment.value,
|
|
409
|
+
placement: 'before-eol',
|
|
410
|
+
});
|
|
411
|
+
}
|
|
412
|
+
else if (Comments.isLeading(this.node, comment.startPosition)) {
|
|
413
|
+
attachedComments.push({
|
|
414
|
+
value: comment.value,
|
|
415
|
+
placement: 'leading',
|
|
416
|
+
});
|
|
417
|
+
}
|
|
418
|
+
else if (Comments.isTrailing(this.node, comment.endPosition)) {
|
|
419
|
+
attachedComments.push({
|
|
420
|
+
value: comment.value,
|
|
421
|
+
placement: 'trailing',
|
|
422
|
+
});
|
|
423
|
+
}
|
|
424
|
+
else {
|
|
425
|
+
const between = Comments.findBetween(this.node, comment.startPosition, comment.endPosition);
|
|
426
|
+
if (between !== null) {
|
|
427
|
+
attachedComments.push({
|
|
428
|
+
value: comment.value,
|
|
429
|
+
placement: 'between',
|
|
430
|
+
between,
|
|
431
|
+
});
|
|
432
|
+
}
|
|
433
|
+
else {
|
|
434
|
+
attachedComments.push({
|
|
435
|
+
value: comment.value,
|
|
436
|
+
placement: 'trailing',
|
|
437
|
+
});
|
|
438
|
+
}
|
|
439
|
+
}
|
|
440
|
+
}
|
|
441
|
+
}
|
|
442
|
+
}
|
|
443
|
+
function normalizeOptions(options) {
|
|
444
|
+
if (options === void 0) {
|
|
445
|
+
return {
|
|
446
|
+
attachComments: false,
|
|
447
|
+
preserveKeyOrder: false,
|
|
448
|
+
bigInt: false,
|
|
449
|
+
mergeKeys: false,
|
|
450
|
+
json: true,
|
|
451
|
+
ignoreDuplicateKeys: false,
|
|
452
|
+
};
|
|
453
|
+
}
|
|
454
|
+
return Object.assign({}, options, { attachComments: options.attachComments === true, preserveKeyOrder: options.preserveKeyOrder === true, bigInt: options.bigInt === true, mergeKeys: options.mergeKeys === true, json: options.json !== false, ignoreDuplicateKeys: options.ignoreDuplicateKeys !== false });
|
|
455
|
+
}
|
|
456
|
+
//# sourceMappingURL=parseWithPointers.js.map
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const yaml_ast_parser_1 = require("@stoplight/yaml-ast-parser");
|
|
4
|
+
exports.safeStringify = (value, options) => typeof value === 'string' ? value : yaml_ast_parser_1.safeDump(value, options);
|
|
5
|
+
//# sourceMappingURL=safeStringify.js.map
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const ordered_object_literal_1 = require("@stoplight/ordered-object-literal");
|
|
4
|
+
exports.KEYS = Symbol.for(ordered_object_literal_1.ORDER_KEY_ID);
|
|
5
|
+
const traps = {
|
|
6
|
+
ownKeys(target) {
|
|
7
|
+
return exports.KEYS in target ? target[exports.KEYS] : Reflect.ownKeys(target);
|
|
8
|
+
},
|
|
9
|
+
};
|
|
10
|
+
exports.trapAccess = (target) => new Proxy(target, traps);
|
|
11
|
+
//# sourceMappingURL=trapAccess.js.map
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const yaml_ast_parser_1 = require("@stoplight/yaml-ast-parser");
|
|
4
|
+
exports.Kind = yaml_ast_parser_1.Kind;
|
|
5
|
+
exports.ScalarType = yaml_ast_parser_1.ScalarType;
|
|
6
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
function isNothing(subject) {
|
|
4
|
+
return (typeof subject === 'undefined') || (null === subject);
|
|
5
|
+
}
|
|
6
|
+
exports.isNothing = isNothing;
|
|
7
|
+
function isObject(subject) {
|
|
8
|
+
return (typeof subject === 'object') && (null !== subject);
|
|
9
|
+
}
|
|
10
|
+
exports.isObject = isObject;
|
|
11
|
+
function toArray(sequence) {
|
|
12
|
+
if (Array.isArray(sequence)) {
|
|
13
|
+
return sequence;
|
|
14
|
+
}
|
|
15
|
+
else if (isNothing(sequence)) {
|
|
16
|
+
return [];
|
|
17
|
+
}
|
|
18
|
+
return [sequence];
|
|
19
|
+
}
|
|
20
|
+
exports.toArray = toArray;
|
|
21
|
+
function extend(target, source) {
|
|
22
|
+
var index, length, key, sourceKeys;
|
|
23
|
+
if (source) {
|
|
24
|
+
sourceKeys = Object.keys(source);
|
|
25
|
+
for (index = 0, length = sourceKeys.length; index < length; index += 1) {
|
|
26
|
+
key = sourceKeys[index];
|
|
27
|
+
target[key] = source[key];
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
return target;
|
|
31
|
+
}
|
|
32
|
+
exports.extend = extend;
|
|
33
|
+
function repeat(string, count) {
|
|
34
|
+
var result = '', cycle;
|
|
35
|
+
for (cycle = 0; cycle < count; cycle += 1) {
|
|
36
|
+
result += string;
|
|
37
|
+
}
|
|
38
|
+
return result;
|
|
39
|
+
}
|
|
40
|
+
exports.repeat = repeat;
|
|
41
|
+
function isNegativeZero(number) {
|
|
42
|
+
return (0 === number) && (Number.NEGATIVE_INFINITY === 1 / number);
|
|
43
|
+
}
|
|
44
|
+
exports.isNegativeZero = isNegativeZero;
|
|
45
|
+
//# sourceMappingURL=common.js.map
|