@redocly/cli 2.41.2 → 2.42.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/README.md +15 -0
- package/THIRD_PARTY_NOTICES +3 -2
- package/lib/chunks/32XCOMOR.js +7 -0
- package/lib/chunks/4S2W4DOH.js +7 -0
- package/lib/chunks/55GMSQDD.js +7 -0
- package/lib/chunks/62KMHHXM.js +93 -0
- package/lib/chunks/7J6QXKSL.js +59 -0
- package/lib/chunks/7TEHO26G.js +3132 -0
- package/lib/chunks/AE6JGTY4.js +7 -0
- package/lib/chunks/B62AKN6U.js +7 -0
- package/lib/chunks/BZ7PKRCP.js +2317 -0
- package/lib/chunks/D5T6ETPZ.js +8 -0
- package/lib/chunks/DNYSY7SK.js +8 -0
- package/lib/chunks/E2UJUSIU.js +11 -0
- package/lib/chunks/ECZUPR2N.js +7 -0
- package/lib/chunks/EU6GURJZ.js +7 -0
- package/lib/chunks/F4DGJH6G.js +8 -0
- package/lib/chunks/GELB6SHC.js +22 -0
- package/lib/chunks/HJ6KJBQG.js +9 -0
- package/lib/chunks/HXR6INJN.js +22 -0
- package/lib/chunks/IP2FG3VC.js +19 -0
- package/lib/chunks/KLY5RV3W.js +7 -0
- package/lib/chunks/LSG6IYBM.js +47 -0
- package/lib/chunks/NEWT5A6S.js +159 -0
- package/lib/chunks/O6MCQRCP.js +59 -0
- package/lib/chunks/O6PRCLSV.js +13 -0
- package/lib/chunks/OFAMJNQ6.js +7 -0
- package/lib/chunks/P26PQ2RU.js +7 -0
- package/lib/chunks/QQOKWPJZ.js +184 -0
- package/lib/chunks/RFWIIJFG.js +7 -0
- package/lib/chunks/RS5PUOTT.js +18 -0
- package/lib/chunks/SPVQTYE2.js +7 -0
- package/lib/chunks/TXOARWFE.js +7 -0
- package/lib/chunks/UPPWQBGX.js +7 -0
- package/lib/chunks/UYZXI3NO.js +7 -0
- package/lib/chunks/WZXA5XPB.js +7 -0
- package/lib/chunks/XYO6U5CE.js +31 -0
- package/lib/chunks/ZGSJFP2Z.js +8 -0
- package/lib/index.js +226 -13885
- package/package.json +1 -1
- package/lib/chunks/3CX2Z7JI.js +0 -496
- package/lib/chunks/3UUTQVCJ.js +0 -3614
- package/lib/chunks/4FB5ZIPP.js +0 -1133
- package/lib/chunks/5ILQMFXK.js +0 -59
- package/lib/chunks/7F5O43EU.js +0 -1756
- package/lib/chunks/7IX44JLO.js +0 -16
- package/lib/chunks/7MOL2QVN.js +0 -92635
- package/lib/chunks/A3VFVVHD.js +0 -25
- package/lib/chunks/A6JSOHCP.js +0 -41
- package/lib/chunks/AIT3U3JT.js +0 -22
- package/lib/chunks/ASYQPOQY.js +0 -681
- package/lib/chunks/BVP23YP7.js +0 -13374
- package/lib/chunks/FO6BDVGE.js +0 -25
- package/lib/chunks/GFU5KGSW.js +0 -92
- package/lib/chunks/ICPYP2LP.js +0 -401
- package/lib/chunks/KPMZLKQG.js +0 -79
- package/lib/chunks/KRMBH6JF.js +0 -17902
- package/lib/chunks/NLIKC7UP.js +0 -528
- package/lib/chunks/NW3XJZXQ.js +0 -175
- package/lib/chunks/P6UGG7F6.js +0 -414
- package/lib/chunks/RRC5IDC3.js +0 -2416
- package/lib/chunks/T6UZU3XM.js +0 -17
- package/lib/chunks/TS33ZDKX.js +0 -35
- package/lib/chunks/UUU33DK3.js +0 -125
- package/lib/chunks/VUDTNFRL.js +0 -42
- package/lib/chunks/VXIQEZPR.js +0 -2564
- package/lib/chunks/W7G5WVPB.js +0 -44
- package/lib/chunks/XB6C62FW.js +0 -18497
- package/lib/chunks/XHPY6UJF.js +0 -1638
- package/lib/chunks/Y6DTFCLS.js +0 -15
- package/lib/chunks/Z2664VV5.js +0 -39331
- package/lib/chunks/Z2I5YXYN.js +0 -20272
- package/lib/chunks/ZK3QRKL5.js +0 -129
package/package.json
CHANGED
package/lib/chunks/3CX2Z7JI.js
DELETED
|
@@ -1,496 +0,0 @@
|
|
|
1
|
-
import { createRequire as __createRequire } from 'node:module';
|
|
2
|
-
const require = __createRequire(import.meta.url);
|
|
3
|
-
import {
|
|
4
|
-
isPlainObject
|
|
5
|
-
} from "./Z2664VV5.js";
|
|
6
|
-
|
|
7
|
-
// src/commands/drift/utils/files.ts
|
|
8
|
-
import { open, readdir, stat } from "node:fs/promises";
|
|
9
|
-
import path from "node:path";
|
|
10
|
-
var SPEC_FILE_EXTENSIONS = /* @__PURE__ */ new Set([".yaml", ".yml", ".json"]);
|
|
11
|
-
async function listOpenApiFiles(rootDir) {
|
|
12
|
-
const output = [];
|
|
13
|
-
async function walk(currentDir) {
|
|
14
|
-
const entries = await readdir(currentDir, { withFileTypes: true });
|
|
15
|
-
for (const entry of entries) {
|
|
16
|
-
if (entry.name.startsWith(".")) {
|
|
17
|
-
continue;
|
|
18
|
-
}
|
|
19
|
-
const absolutePath = path.join(currentDir, entry.name);
|
|
20
|
-
if (entry.isDirectory()) {
|
|
21
|
-
await walk(absolutePath);
|
|
22
|
-
continue;
|
|
23
|
-
}
|
|
24
|
-
if (entry.isFile() && SPEC_FILE_EXTENSIONS.has(path.extname(entry.name).toLowerCase())) {
|
|
25
|
-
output.push(absolutePath);
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
await walk(rootDir);
|
|
30
|
-
output.sort();
|
|
31
|
-
return output;
|
|
32
|
-
}
|
|
33
|
-
async function readProbe(filePath, maxBytes = 4096) {
|
|
34
|
-
const fileHandle = await open(filePath, "r");
|
|
35
|
-
try {
|
|
36
|
-
const buffer = Buffer.allocUnsafe(maxBytes);
|
|
37
|
-
const { bytesRead } = await fileHandle.read(buffer, 0, maxBytes, 0);
|
|
38
|
-
return buffer.toString("utf8", 0, bytesRead);
|
|
39
|
-
} finally {
|
|
40
|
-
await fileHandle.close();
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
function normalizeFsPath(value) {
|
|
44
|
-
return path.resolve(process.cwd(), value);
|
|
45
|
-
}
|
|
46
|
-
async function listFilesRecursively(rootPath) {
|
|
47
|
-
const stats = await stat(rootPath);
|
|
48
|
-
if (stats.isFile()) {
|
|
49
|
-
return [rootPath];
|
|
50
|
-
}
|
|
51
|
-
if (!stats.isDirectory()) {
|
|
52
|
-
return [];
|
|
53
|
-
}
|
|
54
|
-
const output = [];
|
|
55
|
-
async function walk(currentDir) {
|
|
56
|
-
const entries = await readdir(currentDir, { withFileTypes: true });
|
|
57
|
-
for (const entry of entries) {
|
|
58
|
-
if (entry.name.startsWith(".")) {
|
|
59
|
-
continue;
|
|
60
|
-
}
|
|
61
|
-
const absolutePath = path.join(currentDir, entry.name);
|
|
62
|
-
if (entry.isDirectory()) {
|
|
63
|
-
await walk(absolutePath);
|
|
64
|
-
continue;
|
|
65
|
-
}
|
|
66
|
-
if (entry.isFile()) {
|
|
67
|
-
output.push(absolutePath);
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
await walk(rootPath);
|
|
72
|
-
output.sort();
|
|
73
|
-
return output;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
// src/commands/drift/utils/http.ts
|
|
77
|
-
var DUMMY_HOST = "drift.local";
|
|
78
|
-
var DUMMY_BASE_URL = `http://${DUMMY_HOST}`;
|
|
79
|
-
function isSyntheticHost(host) {
|
|
80
|
-
return host === DUMMY_HOST;
|
|
81
|
-
}
|
|
82
|
-
var IGNORED_UNDOCUMENTED_HEADERS = /* @__PURE__ */ new Set([
|
|
83
|
-
"accept",
|
|
84
|
-
"accept-charset",
|
|
85
|
-
"accept-encoding",
|
|
86
|
-
"accept-language",
|
|
87
|
-
"authorization",
|
|
88
|
-
"baggage",
|
|
89
|
-
"cache-control",
|
|
90
|
-
"cdn-loop",
|
|
91
|
-
"cookie",
|
|
92
|
-
"connection",
|
|
93
|
-
"content-length",
|
|
94
|
-
"content-type",
|
|
95
|
-
"dpr",
|
|
96
|
-
"dnt",
|
|
97
|
-
"downlink",
|
|
98
|
-
"ect",
|
|
99
|
-
"forwarded",
|
|
100
|
-
"host",
|
|
101
|
-
"if-match",
|
|
102
|
-
"if-modified-since",
|
|
103
|
-
"if-none-match",
|
|
104
|
-
"if-range",
|
|
105
|
-
"if-unmodified-since",
|
|
106
|
-
"origin",
|
|
107
|
-
"pragma",
|
|
108
|
-
"priority",
|
|
109
|
-
"range",
|
|
110
|
-
"referer",
|
|
111
|
-
"sec-fetch-dest",
|
|
112
|
-
"sec-fetch-mode",
|
|
113
|
-
"sec-fetch-site",
|
|
114
|
-
"sec-fetch-user",
|
|
115
|
-
"sec-gpc",
|
|
116
|
-
"sentry-trace",
|
|
117
|
-
"te",
|
|
118
|
-
"traceparent",
|
|
119
|
-
"tracestate",
|
|
120
|
-
"upgrade",
|
|
121
|
-
"upgrade-insecure-requests",
|
|
122
|
-
"user-agent",
|
|
123
|
-
"via",
|
|
124
|
-
"x-client-trace-id",
|
|
125
|
-
"x-cloud-trace-context",
|
|
126
|
-
"x-correlation-id",
|
|
127
|
-
"x-http-method-override",
|
|
128
|
-
"x-hub-signature",
|
|
129
|
-
"x-hub-signature-256",
|
|
130
|
-
"x-method-override",
|
|
131
|
-
"x-real-ip",
|
|
132
|
-
"x-request-id",
|
|
133
|
-
"x-forwarded-for",
|
|
134
|
-
"x-forwarded-host",
|
|
135
|
-
"x-forwarded-port",
|
|
136
|
-
"x-forwarded-proto"
|
|
137
|
-
]);
|
|
138
|
-
var IGNORED_UNDOCUMENTED_HEADER_PREFIXES = [
|
|
139
|
-
"cf-",
|
|
140
|
-
"sec-ch-",
|
|
141
|
-
"sec-fetch-",
|
|
142
|
-
"x-amz-",
|
|
143
|
-
"x-amzn-",
|
|
144
|
-
"x-b3-",
|
|
145
|
-
"x-envoy-",
|
|
146
|
-
"x-forwarded-",
|
|
147
|
-
"x-github-"
|
|
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
|
-
};
|