@redocly/cli 0.0.0-snapshot.1784620262 → 0.0.0-snapshot.1784895845

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.
@@ -4,7 +4,7 @@ Third-party software bundled in @redocly/cli
4
4
  (MPL-2.0 OR Apache-2.0)
5
5
 
6
6
  Packages:
7
- dompurify@3.4.11 — copyright owner or entity authorized by
7
+ dompurify@3.4.12 — copyright owner or entity authorized by
8
8
 
9
9
  License text:
10
10
 
@@ -574,7 +574,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
574
574
  BSD-3-Clause
575
575
 
576
576
  Packages:
577
- fast-uri@3.1.2 — Copyright (c) 2011-2021, Gary Court until https://github.com/garycourt/uri-js/commit/a1acf730b4bba3f1097c9f52e7d9d3aba8cdcaae
577
+ fast-uri@3.1.4 — Copyright (c) 2011-2021, Gary Court until https://github.com/garycourt/uri-js/commit/a1acf730b4bba3f1097c9f52e7d9d3aba8cdcaae
578
578
  source-map@0.6.1 — Copyright (c) 2009-2011, Mozilla Foundation and contributors
579
579
 
580
580
  License text:
@@ -649,14 +649,14 @@ Packages:
649
649
  @redocly/ajv@8.18.3 — Copyright (c) 2015-2021 Evgeny Poberezkin
650
650
  @redocly/cli-otel@0.3.4 — Copyright 2025 Redocly Inc, all rights reserved.
651
651
  @redocly/config@0.22.0 — Copyright 2024 Redocly Inc.
652
- @redocly/config@0.51.0 — Copyright 2024 Redocly Inc.
653
- @redocly/openapi-core@1.34.16
652
+ @redocly/config@0.52.0 — Copyright 2024 Redocly Inc.
653
+ @redocly/openapi-core@1.34.17
654
654
  agent-base@7.1.4 — Copyright (c) 2013 Nathan Rajlich <nathan@tootallnate.net>
655
655
  ajv-formats@3.0.1 — Copyright (c) 2020 Evgeny Poberezkin
656
656
  ajv@8.20.0 — Copyright (c) 2015-2021 Evgeny Poberezkin
657
657
  ansi-styles@4.3.0
658
658
  balanced-match@1.0.2 — Copyright (c) 2013 Julian Gruber &lt;julian@juliangruber.com&gt;
659
- brace-expansion@2.1.1 — Copyright (c) 2013 Julian Gruber <julian@juliangruber.com>
659
+ brace-expansion@2.1.2 — Copyright (c) 2013 Julian Gruber <julian@juliangruber.com>
660
660
  call-me-maybe@1.0.2 — Copyright (c) 2015 Eric McCarthy
661
661
  chalk@4.1.2
662
662
  classnames@2.5.1 — Copyright (c) 2018 Jed Watson
@@ -679,6 +679,7 @@ Packages:
679
679
  js-levenshtein@1.1.6 — Copyright (c) 2017 Gustaf Andersson
680
680
  js-tokens@4.0.0 — Copyright (c) 2014, 2015, 2016, 2017, 2018 Simon Lydell
681
681
  js-yaml@4.2.0 — Copyright (C) 2011-2015 by Vitaly Puzrin
682
+ js-yaml@5.2.1 — Copyright (C) 2011-2015 by Vitaly Puzrin
682
683
  json-pointer@0.6.2 — Copyright (c) 2016 Manuel Stofer
683
684
  json-schema-traverse@1.0.0 — Copyright (c) 2017 Evgeny Poberezkin
684
685
  jsonpointer@5.0.1 — Copyright (c) 2011-2015 Jan Lehnardt <jan@apache.org> & Marc Bachmann <https://github.com/marcbachmann>
@@ -0,0 +1,496 @@
1
+ import { createRequire as __createRequire } from 'node:module';
2
+ import { fileURLToPath as __fileURLToPath } from 'node:url';
3
+ import { dirname as __pathDirname } from 'node:path';
4
+ const require = __createRequire(import.meta.url);
5
+ var __filename = __fileURLToPath(import.meta.url);
6
+ var __dirname = __pathDirname(__filename);
7
+ import {
8
+ isPlainObject
9
+ } from "./KO5RGRSI.js";
10
+
11
+ // src/commands/drift/utils/files.ts
12
+ import { open, readdir, stat } from "node:fs/promises";
13
+ import path from "node:path";
14
+ var SPEC_FILE_EXTENSIONS = /* @__PURE__ */ new Set([".yaml", ".yml", ".json"]);
15
+ async function listOpenApiFiles(rootDir) {
16
+ const output = [];
17
+ async function walk(currentDir) {
18
+ const entries = await readdir(currentDir, { withFileTypes: true });
19
+ for (const entry of entries) {
20
+ if (entry.name.startsWith(".")) {
21
+ continue;
22
+ }
23
+ const absolutePath = path.join(currentDir, entry.name);
24
+ if (entry.isDirectory()) {
25
+ await walk(absolutePath);
26
+ continue;
27
+ }
28
+ if (entry.isFile() && SPEC_FILE_EXTENSIONS.has(path.extname(entry.name).toLowerCase())) {
29
+ output.push(absolutePath);
30
+ }
31
+ }
32
+ }
33
+ await walk(rootDir);
34
+ output.sort();
35
+ return output;
36
+ }
37
+ async function readProbe(filePath, maxBytes = 4096) {
38
+ const fileHandle = await open(filePath, "r");
39
+ try {
40
+ const buffer = Buffer.allocUnsafe(maxBytes);
41
+ const { bytesRead } = await fileHandle.read(buffer, 0, maxBytes, 0);
42
+ return buffer.toString("utf8", 0, bytesRead);
43
+ } finally {
44
+ await fileHandle.close();
45
+ }
46
+ }
47
+ function normalizeFsPath(value) {
48
+ return path.resolve(process.cwd(), value);
49
+ }
50
+ async function listFilesRecursively(rootPath) {
51
+ const stats = await stat(rootPath);
52
+ if (stats.isFile()) {
53
+ return [rootPath];
54
+ }
55
+ if (!stats.isDirectory()) {
56
+ return [];
57
+ }
58
+ const output = [];
59
+ async function walk(currentDir) {
60
+ const entries = await readdir(currentDir, { withFileTypes: true });
61
+ for (const entry of entries) {
62
+ if (entry.name.startsWith(".")) {
63
+ continue;
64
+ }
65
+ const absolutePath = path.join(currentDir, entry.name);
66
+ if (entry.isDirectory()) {
67
+ await walk(absolutePath);
68
+ continue;
69
+ }
70
+ if (entry.isFile()) {
71
+ output.push(absolutePath);
72
+ }
73
+ }
74
+ }
75
+ await walk(rootPath);
76
+ output.sort();
77
+ return output;
78
+ }
79
+
80
+ // src/commands/drift/utils/http.ts
81
+ var DUMMY_HOST = "drift.local";
82
+ var DUMMY_BASE_URL = `http://${DUMMY_HOST}`;
83
+ function isSyntheticHost(host) {
84
+ return host === DUMMY_HOST;
85
+ }
86
+ var IGNORED_UNDOCUMENTED_HEADERS = /* @__PURE__ */ new Set([
87
+ "accept",
88
+ "accept-charset",
89
+ "accept-encoding",
90
+ "accept-language",
91
+ "authorization",
92
+ "baggage",
93
+ "cache-control",
94
+ "cdn-loop",
95
+ "cookie",
96
+ "connection",
97
+ "content-length",
98
+ "content-type",
99
+ "dpr",
100
+ "dnt",
101
+ "downlink",
102
+ "ect",
103
+ "forwarded",
104
+ "host",
105
+ "if-match",
106
+ "if-modified-since",
107
+ "if-none-match",
108
+ "if-range",
109
+ "if-unmodified-since",
110
+ "origin",
111
+ "pragma",
112
+ "priority",
113
+ "range",
114
+ "referer",
115
+ "sec-fetch-dest",
116
+ "sec-fetch-mode",
117
+ "sec-fetch-site",
118
+ "sec-fetch-user",
119
+ "sec-gpc",
120
+ "sentry-trace",
121
+ "te",
122
+ "traceparent",
123
+ "tracestate",
124
+ "upgrade",
125
+ "upgrade-insecure-requests",
126
+ "user-agent",
127
+ "via",
128
+ "x-amzn-trace-id",
129
+ "x-client-trace-id",
130
+ "x-cloud-trace-context",
131
+ "x-correlation-id",
132
+ "x-http-method-override",
133
+ "x-method-override",
134
+ "x-real-ip",
135
+ "x-request-id",
136
+ "x-forwarded-for",
137
+ "x-forwarded-host",
138
+ "x-forwarded-port",
139
+ "x-forwarded-proto"
140
+ ]);
141
+ var IGNORED_UNDOCUMENTED_HEADER_PREFIXES = [
142
+ "cf-",
143
+ "sec-ch-",
144
+ "sec-fetch-",
145
+ "x-b3-",
146
+ "x-envoy-",
147
+ "x-forwarded-"
148
+ ];
149
+ var SET_COOKIE_SEPARATOR = "\n";
150
+ function splitSetCookieHeader(value) {
151
+ return value.split(SET_COOKIE_SEPARATOR);
152
+ }
153
+ function appendHeaderValue(result, name, value) {
154
+ const key = name.toLowerCase();
155
+ const existing = result[key];
156
+ if (existing === void 0) {
157
+ result[key] = value;
158
+ return;
159
+ }
160
+ result[key] = key === "set-cookie" ? `${existing}${SET_COOKIE_SEPARATOR}${value}` : `${existing},${value}`;
161
+ }
162
+ function normalizeHeaders(input) {
163
+ if (!isPlainObject(input) && !Array.isArray(input)) {
164
+ return {};
165
+ }
166
+ const result = {};
167
+ if (Array.isArray(input)) {
168
+ for (const item of input) {
169
+ if (!isPlainObject(item)) {
170
+ continue;
171
+ }
172
+ const { name, value } = item;
173
+ if (typeof name === "string" && value !== void 0) {
174
+ appendHeaderValue(result, name, String(value));
175
+ }
176
+ }
177
+ return result;
178
+ }
179
+ for (const [key, value] of Object.entries(input)) {
180
+ if (value === void 0 || value === null) {
181
+ continue;
182
+ }
183
+ if (Array.isArray(value)) {
184
+ for (const item of value) {
185
+ appendHeaderValue(result, key, String(item));
186
+ }
187
+ continue;
188
+ }
189
+ appendHeaderValue(result, key, String(value));
190
+ }
191
+ return result;
192
+ }
193
+ function parseUrl(input) {
194
+ try {
195
+ return new URL(input);
196
+ } catch {
197
+ return new URL(input, DUMMY_BASE_URL);
198
+ }
199
+ }
200
+ function getPathWithoutTrailingSlash(pathname) {
201
+ if (pathname.length > 1 && pathname.endsWith("/")) {
202
+ return pathname.slice(0, -1);
203
+ }
204
+ return pathname;
205
+ }
206
+ function escapeRegex(value) {
207
+ return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
208
+ }
209
+ function compileOpenApiPath(pathTemplate) {
210
+ const params = [];
211
+ let score = 0;
212
+ const absolutePath = pathTemplate.startsWith("/") ? pathTemplate : `/${pathTemplate}`;
213
+ const normalizedPath = getPathWithoutTrailingSlash(absolutePath);
214
+ const regexBody = normalizedPath.split("/").map((segment) => {
215
+ if (!segment) {
216
+ return "";
217
+ }
218
+ const paramMatch = segment.match(/^\{([^}]+)\}$/);
219
+ if (paramMatch) {
220
+ params.push(paramMatch[1]);
221
+ return "([^/]+)";
222
+ }
223
+ score += 2;
224
+ return escapeRegex(segment);
225
+ }).join("/");
226
+ return {
227
+ regex: new RegExp(`^${regexBody || "/"}$`),
228
+ params,
229
+ score
230
+ };
231
+ }
232
+ function parseJsonBodyIfPresent(contentType, bodyText) {
233
+ if (!bodyText) {
234
+ return void 0;
235
+ }
236
+ if (!isJsonMime(contentType)) {
237
+ return void 0;
238
+ }
239
+ try {
240
+ return JSON.parse(bodyText);
241
+ } catch {
242
+ return void 0;
243
+ }
244
+ }
245
+ function normalizeContentType(contentType) {
246
+ if (!contentType) {
247
+ return "";
248
+ }
249
+ return contentType.split(";")[0]?.trim().toLowerCase() ?? "";
250
+ }
251
+ function isJsonMime(contentType) {
252
+ const mime = normalizeContentType(contentType);
253
+ return mime === "application/json" || mime.endsWith("+json");
254
+ }
255
+ function pickSchemaByMime(contentMap, contentType) {
256
+ const requestedMime = normalizeContentType(contentType);
257
+ if (!requestedMime) {
258
+ return contentMap["application/json"] ?? contentMap["*/*"];
259
+ }
260
+ if (contentMap[requestedMime] !== void 0) {
261
+ return contentMap[requestedMime];
262
+ }
263
+ const [type, subtype] = requestedMime.split("/");
264
+ if (type && subtype) {
265
+ const wildcardSubtype = `${type}/*`;
266
+ if (contentMap[wildcardSubtype] !== void 0) {
267
+ return contentMap[wildcardSubtype];
268
+ }
269
+ }
270
+ return contentMap["*/*"];
271
+ }
272
+ function parseHeaderIgnoreList(patterns) {
273
+ const names = /* @__PURE__ */ new Set();
274
+ const prefixes = [];
275
+ for (const pattern of patterns) {
276
+ const normalized = pattern.trim().toLowerCase();
277
+ if (normalized.length === 0) {
278
+ continue;
279
+ }
280
+ if (normalized.endsWith("*")) {
281
+ prefixes.push(normalized.slice(0, -1));
282
+ } else {
283
+ names.add(normalized);
284
+ }
285
+ }
286
+ return { names, prefixes };
287
+ }
288
+ function shouldIgnoreHeaderAsUndocumented(headerName, extraIgnored) {
289
+ const normalizedHeaderName = headerName.toLowerCase();
290
+ if (normalizedHeaderName.startsWith(":")) {
291
+ return true;
292
+ }
293
+ if (IGNORED_UNDOCUMENTED_HEADERS.has(normalizedHeaderName) || IGNORED_UNDOCUMENTED_HEADER_PREFIXES.some((prefix) => normalizedHeaderName.startsWith(prefix))) {
294
+ return true;
295
+ }
296
+ if (extraIgnored) {
297
+ return extraIgnored.names.has(normalizedHeaderName) || extraIgnored.prefixes.some((prefix) => normalizedHeaderName.startsWith(prefix));
298
+ }
299
+ return false;
300
+ }
301
+
302
+ // src/commands/drift/log-formats/helpers.ts
303
+ import { createReadStream } from "node:fs";
304
+ import { readFile } from "node:fs/promises";
305
+ import { createInterface } from "node:readline";
306
+ function coerceString(value) {
307
+ if (value === void 0 || value === null) {
308
+ return void 0;
309
+ }
310
+ if (typeof value === "string") {
311
+ return value;
312
+ }
313
+ if (Buffer.isBuffer(value)) {
314
+ return value.toString("utf8");
315
+ }
316
+ if (isPlainObject(value) || Array.isArray(value)) {
317
+ try {
318
+ return JSON.stringify(value);
319
+ } catch {
320
+ return String(value);
321
+ }
322
+ }
323
+ return String(value);
324
+ }
325
+ function coerceNumber(value) {
326
+ if (typeof value === "number" && Number.isFinite(value)) {
327
+ return value;
328
+ }
329
+ if (typeof value === "string" && value.trim() !== "") {
330
+ const parsed = Number(value);
331
+ if (Number.isFinite(parsed)) {
332
+ return parsed;
333
+ }
334
+ }
335
+ return void 0;
336
+ }
337
+ function decodeBody(value, encoding) {
338
+ if (value === void 0 || value === null) {
339
+ return void 0;
340
+ }
341
+ if (encoding === "base64" && typeof value === "string") {
342
+ try {
343
+ return Buffer.from(value, "base64").toString("utf8");
344
+ } catch {
345
+ return value;
346
+ }
347
+ }
348
+ return coerceString(value);
349
+ }
350
+ function createNormalizedExchange(seed, index, source) {
351
+ const method = seed.method?.toUpperCase();
352
+ const url = seed.url;
353
+ if (!method || !url) {
354
+ return null;
355
+ }
356
+ const requestHeaders = normalizeHeaders(seed.requestHeaders);
357
+ let parsedUrl = parseUrl(url);
358
+ if (isSyntheticHost(parsedUrl.host) && requestHeaders.host) {
359
+ try {
360
+ parsedUrl = new URL(
361
+ `${parsedUrl.protocol}//${requestHeaders.host}${parsedUrl.pathname}${parsedUrl.search}`
362
+ );
363
+ } catch {
364
+ parsedUrl = parseUrl(url);
365
+ }
366
+ }
367
+ const requestContentType = seed.requestContentType ?? requestHeaders["content-type"];
368
+ const requestBodyText = decodeBody(seed.requestBody);
369
+ const request = {
370
+ method,
371
+ url: parsedUrl.toString(),
372
+ path: parsedUrl.pathname,
373
+ query: parsedUrl.searchParams,
374
+ protocol: parsedUrl.protocol,
375
+ protocolKnown: seed.schemeKnown ?? /^https?:\/\//i.test(url),
376
+ host: isSyntheticHost(parsedUrl.host) ? void 0 : parsedUrl.host || void 0,
377
+ headers: requestHeaders,
378
+ contentType: requestContentType,
379
+ bodyText: requestBodyText,
380
+ bodyJson: parseJsonBodyIfPresent(requestContentType, requestBodyText)
381
+ };
382
+ let response;
383
+ const responseStatus = seed.responseStatus;
384
+ if (responseStatus !== void 0) {
385
+ const responseHeaders = normalizeHeaders(seed.responseHeaders);
386
+ const responseContentType = seed.responseContentType ?? responseHeaders["content-type"];
387
+ const responseBodyText = decodeBody(seed.responseBody);
388
+ response = {
389
+ status: responseStatus,
390
+ statusText: seed.responseStatusText,
391
+ headers: responseHeaders,
392
+ contentType: responseContentType,
393
+ bodyText: responseBodyText,
394
+ bodyJson: parseJsonBodyIfPresent(responseContentType, responseBodyText)
395
+ };
396
+ }
397
+ return {
398
+ index,
399
+ source,
400
+ startedAt: seed.startedAt,
401
+ request,
402
+ response,
403
+ raw: seed.raw
404
+ };
405
+ }
406
+ async function* streamNdjsonObjects(filePath) {
407
+ const readStream = createReadStream(filePath, { encoding: "utf8" });
408
+ const reader = createInterface({ input: readStream, crlfDelay: Infinity });
409
+ for await (const line of reader) {
410
+ const trimmed = line.trim();
411
+ if (!trimmed) {
412
+ continue;
413
+ }
414
+ try {
415
+ const parsed = JSON.parse(trimmed);
416
+ if (isPlainObject(parsed)) {
417
+ yield parsed;
418
+ }
419
+ } catch {
420
+ }
421
+ }
422
+ }
423
+ async function* iterateJsonArray(filePath, arrayPath) {
424
+ const content = await readFile(filePath, "utf8");
425
+ let value = JSON.parse(content);
426
+ if (arrayPath) {
427
+ for (const key of arrayPath.split(".")) {
428
+ value = isPlainObject(value) ? value[key] : void 0;
429
+ }
430
+ }
431
+ if (Array.isArray(value)) {
432
+ for (const item of value) {
433
+ if (isPlainObject(item)) {
434
+ yield item;
435
+ }
436
+ }
437
+ }
438
+ }
439
+ function pickHeaderContentType(headers) {
440
+ const normalized = normalizeHeaders(headers);
441
+ return normalized["content-type"];
442
+ }
443
+
444
+ // src/commands/drift/utils/server.ts
445
+ function normalizeServerPrefix(server) {
446
+ const trimmed = server?.replace(/\/+$/, "");
447
+ return trimmed || void 0;
448
+ }
449
+ function stripPrefixFromPath(pathname, prefixPath) {
450
+ if (!prefixPath || prefixPath === "/") {
451
+ return pathname || "/";
452
+ }
453
+ if (pathname === prefixPath) {
454
+ return "/";
455
+ }
456
+ if (!pathname.startsWith(`${prefixPath}/`)) {
457
+ return void 0;
458
+ }
459
+ return pathname.slice(prefixPath.length) || "/";
460
+ }
461
+ function resolvePathForServer(request, server) {
462
+ if (server.startsWith("/")) {
463
+ return stripPrefixFromPath(request.path, server);
464
+ }
465
+ const serverUrl = parseUrl(server.includes("://") ? server : `http://${server}`);
466
+ if (isSyntheticHost(serverUrl.host) || request.host !== void 0 && request.host.toLowerCase() !== serverUrl.host) {
467
+ return void 0;
468
+ }
469
+ return stripPrefixFromPath(request.path, getPathWithoutTrailingSlash(serverUrl.pathname));
470
+ }
471
+
472
+ export {
473
+ listOpenApiFiles,
474
+ readProbe,
475
+ normalizeFsPath,
476
+ listFilesRecursively,
477
+ isSyntheticHost,
478
+ splitSetCookieHeader,
479
+ parseUrl,
480
+ getPathWithoutTrailingSlash,
481
+ compileOpenApiPath,
482
+ normalizeContentType,
483
+ isJsonMime,
484
+ pickSchemaByMime,
485
+ parseHeaderIgnoreList,
486
+ shouldIgnoreHeaderAsUndocumented,
487
+ coerceString,
488
+ coerceNumber,
489
+ decodeBody,
490
+ createNormalizedExchange,
491
+ streamNdjsonObjects,
492
+ iterateJsonArray,
493
+ pickHeaderContentType,
494
+ normalizeServerPrefix,
495
+ resolvePathForServer
496
+ };
@@ -12,7 +12,7 @@ import {
12
12
  } from "./JPNXFCZJ.js";
13
13
  import {
14
14
  version
15
- } from "./U5H3NDWA.js";
15
+ } from "./NWE2GATL.js";
16
16
  import {
17
17
  require_undici
18
18
  } from "./QRC5ADSZ.js";
@@ -20,7 +20,7 @@ import {
20
20
  blue,
21
21
  green,
22
22
  logger
23
- } from "./HD24VMMU.js";
23
+ } from "./KO5RGRSI.js";
24
24
  import {
25
25
  __toESM
26
26
  } from "./YDPUXTSG.js";
@@ -6,7 +6,7 @@ var __filename = __fileURLToPath(import.meta.url);
6
6
  var __dirname = __pathDirname(__filename);
7
7
  import {
8
8
  HandledError
9
- } from "./HD24VMMU.js";
9
+ } from "./KO5RGRSI.js";
10
10
 
11
11
  // src/utils/error.ts
12
12
  var AbortFlowError = class extends Error {