@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/lib/chunks/P6UGG7F6.js
DELETED
|
@@ -1,414 +0,0 @@
|
|
|
1
|
-
import { createRequire as __createRequire } from 'node:module';
|
|
2
|
-
const require = __createRequire(import.meta.url);
|
|
3
|
-
import {
|
|
4
|
-
coerceNumber,
|
|
5
|
-
coerceString,
|
|
6
|
-
createNormalizedExchange,
|
|
7
|
-
decodeBody,
|
|
8
|
-
iterateJsonArray,
|
|
9
|
-
normalizeContentType,
|
|
10
|
-
pickHeaderContentType,
|
|
11
|
-
readProbe,
|
|
12
|
-
streamNdjsonObjects
|
|
13
|
-
} from "./3CX2Z7JI.js";
|
|
14
|
-
import {
|
|
15
|
-
isPlainObject
|
|
16
|
-
} from "./Z2664VV5.js";
|
|
17
|
-
|
|
18
|
-
// src/commands/drift/log-formats/har.ts
|
|
19
|
-
import path from "node:path";
|
|
20
|
-
function formParamsToBody(mimeType, params) {
|
|
21
|
-
if (normalizeContentType(mimeType) !== "application/x-www-form-urlencoded") {
|
|
22
|
-
return void 0;
|
|
23
|
-
}
|
|
24
|
-
if (!Array.isArray(params)) {
|
|
25
|
-
return void 0;
|
|
26
|
-
}
|
|
27
|
-
const searchParams = new URLSearchParams();
|
|
28
|
-
for (const param of params) {
|
|
29
|
-
if (!isPlainObject(param)) {
|
|
30
|
-
continue;
|
|
31
|
-
}
|
|
32
|
-
const name = coerceString(param.name);
|
|
33
|
-
if (name === void 0) {
|
|
34
|
-
continue;
|
|
35
|
-
}
|
|
36
|
-
searchParams.append(name, coerceString(param.value) ?? "");
|
|
37
|
-
}
|
|
38
|
-
return searchParams.size > 0 ? searchParams.toString() : void 0;
|
|
39
|
-
}
|
|
40
|
-
function normalizeHarEntry(entry, index, source) {
|
|
41
|
-
const request = entry?.request;
|
|
42
|
-
const response = entry?.response;
|
|
43
|
-
if (!request) {
|
|
44
|
-
return null;
|
|
45
|
-
}
|
|
46
|
-
const postData = request?.postData;
|
|
47
|
-
const requestContentType = coerceString(postData?.mimeType);
|
|
48
|
-
const requestBody = postData?.text ?? formParamsToBody(requestContentType, postData?.params);
|
|
49
|
-
const requestEncoding = coerceString(postData?.encoding);
|
|
50
|
-
const responseBody = response?.content?.text;
|
|
51
|
-
const responseEncoding = coerceString(response?.content?.encoding);
|
|
52
|
-
const responseStatus = coerceNumber(response?.status);
|
|
53
|
-
return createNormalizedExchange(
|
|
54
|
-
{
|
|
55
|
-
method: coerceString(request?.method),
|
|
56
|
-
url: coerceString(request?.url),
|
|
57
|
-
requestHeaders: request?.headers,
|
|
58
|
-
requestBody: decodeBody(requestBody, requestEncoding),
|
|
59
|
-
requestContentType,
|
|
60
|
-
responseStatus: responseStatus === 0 ? void 0 : responseStatus,
|
|
61
|
-
responseStatusText: coerceString(response?.statusText),
|
|
62
|
-
responseHeaders: response?.headers,
|
|
63
|
-
responseBody: decodeBody(responseBody, responseEncoding),
|
|
64
|
-
responseContentType: coerceString(response?.content?.mimeType),
|
|
65
|
-
startedAt: coerceString(entry?.startedDateTime),
|
|
66
|
-
raw: entry
|
|
67
|
-
},
|
|
68
|
-
index,
|
|
69
|
-
source
|
|
70
|
-
);
|
|
71
|
-
}
|
|
72
|
-
var HarTrafficParser = class {
|
|
73
|
-
id = "har";
|
|
74
|
-
canParse(filePath, probe) {
|
|
75
|
-
const ext = path.extname(filePath).toLowerCase();
|
|
76
|
-
if (ext === ".har") {
|
|
77
|
-
return true;
|
|
78
|
-
}
|
|
79
|
-
const normalizedProbe = probe.toLowerCase();
|
|
80
|
-
return normalizedProbe.includes('"log"') && normalizedProbe.includes('"entries"');
|
|
81
|
-
}
|
|
82
|
-
async *parse(filePath) {
|
|
83
|
-
let index = 0;
|
|
84
|
-
for await (const entry of iterateJsonArray(filePath, "log.entries")) {
|
|
85
|
-
const exchange = normalizeHarEntry(entry, index, filePath);
|
|
86
|
-
if (exchange) {
|
|
87
|
-
yield exchange;
|
|
88
|
-
}
|
|
89
|
-
index += 1;
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
};
|
|
93
|
-
|
|
94
|
-
// src/commands/drift/log-formats/kong.ts
|
|
95
|
-
import path2 from "node:path";
|
|
96
|
-
function buildKongUrl(request) {
|
|
97
|
-
const directUrl = coerceString(request.url ?? request.uri);
|
|
98
|
-
if (directUrl) {
|
|
99
|
-
return { url: directUrl };
|
|
100
|
-
}
|
|
101
|
-
const host = coerceString(request.host ?? request.headers?.host);
|
|
102
|
-
const requestPath = coerceString(request.path ?? request.request_uri);
|
|
103
|
-
const explicitScheme = coerceString(request.scheme ?? request.forwarded_proto);
|
|
104
|
-
if (host && requestPath) {
|
|
105
|
-
return {
|
|
106
|
-
url: `${explicitScheme ?? "http"}://${host}${requestPath}`,
|
|
107
|
-
schemeKnown: Boolean(explicitScheme)
|
|
108
|
-
};
|
|
109
|
-
}
|
|
110
|
-
return { url: requestPath, schemeKnown: Boolean(explicitScheme) };
|
|
111
|
-
}
|
|
112
|
-
function normalizeKongRecord(record, index, source) {
|
|
113
|
-
const request = record?.request ?? record?.req ?? record?.http?.request;
|
|
114
|
-
if (!request) {
|
|
115
|
-
return null;
|
|
116
|
-
}
|
|
117
|
-
const response = record?.response ?? record?.res ?? record?.http?.response;
|
|
118
|
-
const responseBody = response?.body ?? response?.raw_body ?? response?.payload ?? response?.data;
|
|
119
|
-
const requestBody = request?.body ?? request?.raw_body ?? request?.payload ?? request?.data;
|
|
120
|
-
const { url, schemeKnown } = buildKongUrl(request);
|
|
121
|
-
return createNormalizedExchange(
|
|
122
|
-
{
|
|
123
|
-
method: coerceString(request?.method ?? request?.http_method),
|
|
124
|
-
url,
|
|
125
|
-
schemeKnown,
|
|
126
|
-
requestHeaders: request?.headers,
|
|
127
|
-
requestBody,
|
|
128
|
-
requestContentType: pickHeaderContentType(request?.headers),
|
|
129
|
-
responseStatus: coerceNumber(response?.status ?? response?.statusCode),
|
|
130
|
-
responseHeaders: response?.headers,
|
|
131
|
-
responseBody,
|
|
132
|
-
responseContentType: pickHeaderContentType(response?.headers),
|
|
133
|
-
startedAt: coerceString(record?.started_at ?? record?.startedAt ?? record?.timestamp),
|
|
134
|
-
raw: record
|
|
135
|
-
},
|
|
136
|
-
index,
|
|
137
|
-
source
|
|
138
|
-
);
|
|
139
|
-
}
|
|
140
|
-
var KongTrafficParser = class {
|
|
141
|
-
id = "kong";
|
|
142
|
-
canParse(filePath, probe) {
|
|
143
|
-
const ext = path2.extname(filePath).toLowerCase();
|
|
144
|
-
if (ext === ".kong") {
|
|
145
|
-
return true;
|
|
146
|
-
}
|
|
147
|
-
const lowerProbe = probe.toLowerCase();
|
|
148
|
-
return lowerProbe.includes('"latencies"') || lowerProbe.includes('"request"') && lowerProbe.includes('"response"') && lowerProbe.includes('"route"');
|
|
149
|
-
}
|
|
150
|
-
async *parse(filePath) {
|
|
151
|
-
const firstChar = (await readProbe(filePath, 16)).trim().slice(0, 1);
|
|
152
|
-
let index = 0;
|
|
153
|
-
if (firstChar === "[") {
|
|
154
|
-
for await (const record of iterateJsonArray(filePath)) {
|
|
155
|
-
const normalized = normalizeKongRecord(record, index, filePath);
|
|
156
|
-
if (normalized) {
|
|
157
|
-
yield normalized;
|
|
158
|
-
}
|
|
159
|
-
index += 1;
|
|
160
|
-
}
|
|
161
|
-
return;
|
|
162
|
-
}
|
|
163
|
-
for await (const record of streamNdjsonObjects(filePath)) {
|
|
164
|
-
const normalized = normalizeKongRecord(record, index, filePath);
|
|
165
|
-
if (normalized) {
|
|
166
|
-
yield normalized;
|
|
167
|
-
}
|
|
168
|
-
index += 1;
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
};
|
|
172
|
-
|
|
173
|
-
// src/commands/drift/log-formats/ndjson.ts
|
|
174
|
-
import path3 from "node:path";
|
|
175
|
-
function getRequestCandidate(record) {
|
|
176
|
-
return record?.request ?? record?.req ?? record?.httpRequest ?? record?.http?.request ?? record;
|
|
177
|
-
}
|
|
178
|
-
function getResponseCandidate(record) {
|
|
179
|
-
return record?.response ?? record?.res ?? record?.httpResponse ?? record?.http?.response;
|
|
180
|
-
}
|
|
181
|
-
function buildUrl(record, request) {
|
|
182
|
-
const directUrl = coerceString(
|
|
183
|
-
request?.url ?? request?.uri ?? request?.requestUrl ?? record?.url
|
|
184
|
-
);
|
|
185
|
-
if (directUrl) {
|
|
186
|
-
return { url: directUrl };
|
|
187
|
-
}
|
|
188
|
-
const host = coerceString(request?.host ?? request?.headers?.host ?? record?.host);
|
|
189
|
-
const path5 = coerceString(request?.path ?? record?.path ?? request?.pathname);
|
|
190
|
-
const explicitScheme = coerceString(request?.scheme ?? record?.scheme);
|
|
191
|
-
if (host && path5) {
|
|
192
|
-
return {
|
|
193
|
-
url: `${explicitScheme ?? "http"}://${host}${path5}`,
|
|
194
|
-
schemeKnown: Boolean(explicitScheme)
|
|
195
|
-
};
|
|
196
|
-
}
|
|
197
|
-
return { url: path5, schemeKnown: Boolean(explicitScheme) };
|
|
198
|
-
}
|
|
199
|
-
function normalizeGenericRecord(record, index, source) {
|
|
200
|
-
const request = getRequestCandidate(record);
|
|
201
|
-
const response = getResponseCandidate(record);
|
|
202
|
-
const requestBody = request?.body ?? request?.bodyText ?? request?.payload ?? request?.data ?? request?.rawBody;
|
|
203
|
-
const responseBody = response?.body ?? response?.bodyText ?? response?.payload ?? response?.data ?? response?.rawBody;
|
|
204
|
-
const { url, schemeKnown } = buildUrl(record, request);
|
|
205
|
-
return createNormalizedExchange(
|
|
206
|
-
{
|
|
207
|
-
method: coerceString(
|
|
208
|
-
request?.method ?? request?.httpMethod ?? record?.method ?? record?.httpMethod
|
|
209
|
-
),
|
|
210
|
-
url,
|
|
211
|
-
schemeKnown,
|
|
212
|
-
requestHeaders: request?.headers,
|
|
213
|
-
requestBody,
|
|
214
|
-
requestContentType: pickHeaderContentType(request?.headers),
|
|
215
|
-
responseStatus: coerceNumber(
|
|
216
|
-
response?.status ?? response?.statusCode ?? record?.status ?? record?.statusCode
|
|
217
|
-
),
|
|
218
|
-
responseHeaders: response?.headers,
|
|
219
|
-
responseBody,
|
|
220
|
-
responseContentType: pickHeaderContentType(response?.headers),
|
|
221
|
-
startedAt: coerceString(record?.startedAt ?? record?.timestamp ?? record?.time),
|
|
222
|
-
raw: record
|
|
223
|
-
},
|
|
224
|
-
index,
|
|
225
|
-
source
|
|
226
|
-
);
|
|
227
|
-
}
|
|
228
|
-
var NdjsonTrafficParser = class {
|
|
229
|
-
id = "ndjson";
|
|
230
|
-
canParse(filePath, probe) {
|
|
231
|
-
const ext = path3.extname(filePath).toLowerCase();
|
|
232
|
-
if (ext === ".ndjson" || ext === ".jsonl" || ext === ".jsonlines") {
|
|
233
|
-
return true;
|
|
234
|
-
}
|
|
235
|
-
const lastNewlineIndex = probe.lastIndexOf("\n");
|
|
236
|
-
const completeLines = lastNewlineIndex === -1 ? probe : probe.slice(0, lastNewlineIndex);
|
|
237
|
-
const firstLine = completeLines.split("\n").map((line) => line.trim()).find(Boolean);
|
|
238
|
-
if (!firstLine?.startsWith("{") || !firstLine.endsWith("}")) {
|
|
239
|
-
return false;
|
|
240
|
-
}
|
|
241
|
-
try {
|
|
242
|
-
JSON.parse(firstLine);
|
|
243
|
-
return true;
|
|
244
|
-
} catch {
|
|
245
|
-
return false;
|
|
246
|
-
}
|
|
247
|
-
}
|
|
248
|
-
async *parse(filePath) {
|
|
249
|
-
let index = 0;
|
|
250
|
-
for await (const record of streamNdjsonObjects(filePath)) {
|
|
251
|
-
const normalized = normalizeGenericRecord(record, index, filePath);
|
|
252
|
-
if (normalized) {
|
|
253
|
-
yield normalized;
|
|
254
|
-
}
|
|
255
|
-
index += 1;
|
|
256
|
-
}
|
|
257
|
-
}
|
|
258
|
-
};
|
|
259
|
-
|
|
260
|
-
// src/commands/drift/log-formats/webserver-json.ts
|
|
261
|
-
import path4 from "node:path";
|
|
262
|
-
function parseRequestLine(requestLine) {
|
|
263
|
-
if (!requestLine) {
|
|
264
|
-
return {};
|
|
265
|
-
}
|
|
266
|
-
const parts = requestLine.trim().split(/\s+/);
|
|
267
|
-
if (parts.length < 2) {
|
|
268
|
-
return {};
|
|
269
|
-
}
|
|
270
|
-
return {
|
|
271
|
-
method: parts[0],
|
|
272
|
-
path: parts[1],
|
|
273
|
-
protocol: parts[2]
|
|
274
|
-
};
|
|
275
|
-
}
|
|
276
|
-
function buildUrl2(record, request) {
|
|
277
|
-
const directUrl = coerceString(
|
|
278
|
-
request?.url ?? request?.request_uri ?? request?.uri ?? record?.url ?? record?.request_url ?? record?.absolute_uri
|
|
279
|
-
);
|
|
280
|
-
const requestLine = parseRequestLine(coerceString(record?.request ?? request?.request_line));
|
|
281
|
-
const requestPath = coerceString(
|
|
282
|
-
request?.request_uri ?? request?.uri ?? request?.path ?? record?.request_uri ?? record?.uri
|
|
283
|
-
) ?? requestLine.path;
|
|
284
|
-
if (directUrl?.startsWith("http://") || directUrl?.startsWith("https://")) {
|
|
285
|
-
return { url: directUrl };
|
|
286
|
-
}
|
|
287
|
-
const host = coerceString(
|
|
288
|
-
request?.host ?? request?.headers?.host ?? record?.host ?? record?.http_host ?? record?.server_name ?? record?.vhost
|
|
289
|
-
);
|
|
290
|
-
const explicitScheme = coerceString(record?.scheme ?? request?.scheme ?? record?.request_scheme);
|
|
291
|
-
const schemeKnown = Boolean(explicitScheme);
|
|
292
|
-
if (host && (directUrl || requestPath)) {
|
|
293
|
-
const scheme = explicitScheme ?? "http";
|
|
294
|
-
const targetPath = directUrl ?? requestPath;
|
|
295
|
-
if (targetPath?.startsWith("/")) {
|
|
296
|
-
return { url: `${scheme}://${host}${targetPath}`, schemeKnown };
|
|
297
|
-
}
|
|
298
|
-
return { url: `${scheme}://${host}/${targetPath}`, schemeKnown };
|
|
299
|
-
}
|
|
300
|
-
return { url: directUrl ?? requestPath, schemeKnown };
|
|
301
|
-
}
|
|
302
|
-
function normalizeWebServerRecord(record, index, source) {
|
|
303
|
-
const request = isPlainObject(record?.request) ? record.request : record;
|
|
304
|
-
const response = isPlainObject(record?.response) ? record.response : void 0;
|
|
305
|
-
const requestLine = parseRequestLine(coerceString(record?.request));
|
|
306
|
-
const method = coerceString(
|
|
307
|
-
request?.method ?? request?.request_method ?? record?.request_method ?? record?.method
|
|
308
|
-
) ?? requestLine.method;
|
|
309
|
-
const { url, schemeKnown } = buildUrl2(record, request);
|
|
310
|
-
return createNormalizedExchange(
|
|
311
|
-
{
|
|
312
|
-
method,
|
|
313
|
-
url,
|
|
314
|
-
schemeKnown,
|
|
315
|
-
requestHeaders: request?.headers ?? request?.request_headers ?? record?.request_headers ?? record?.headers,
|
|
316
|
-
requestBody: request?.body ?? request?.request_body ?? record?.request_body ?? record?.body,
|
|
317
|
-
requestContentType: pickHeaderContentType(
|
|
318
|
-
request?.headers ?? request?.request_headers ?? record?.request_headers
|
|
319
|
-
),
|
|
320
|
-
responseStatus: coerceNumber(
|
|
321
|
-
response?.status ?? response?.status_code ?? record?.status ?? record?.status_code ?? record?.response_status
|
|
322
|
-
),
|
|
323
|
-
responseHeaders: response?.headers ?? response?.response_headers ?? record?.response_headers ?? record?.headers_out,
|
|
324
|
-
responseBody: response?.body ?? response?.response_body ?? record?.response_body,
|
|
325
|
-
responseContentType: pickHeaderContentType(
|
|
326
|
-
response?.headers ?? response?.response_headers ?? record?.response_headers
|
|
327
|
-
),
|
|
328
|
-
startedAt: coerceString(
|
|
329
|
-
record?.time_iso8601 ?? record?.timestamp ?? record?.time ?? record?.time_local ?? record?.["@timestamp"]
|
|
330
|
-
),
|
|
331
|
-
raw: record
|
|
332
|
-
},
|
|
333
|
-
index,
|
|
334
|
-
source
|
|
335
|
-
);
|
|
336
|
-
}
|
|
337
|
-
async function* parseJsonFile(filePath) {
|
|
338
|
-
const firstChar = (await readProbe(filePath, 16)).trim().slice(0, 1);
|
|
339
|
-
if (firstChar === "[") {
|
|
340
|
-
yield* iterateJsonArray(filePath);
|
|
341
|
-
return;
|
|
342
|
-
}
|
|
343
|
-
for await (const record of streamNdjsonObjects(filePath)) {
|
|
344
|
-
yield record;
|
|
345
|
-
}
|
|
346
|
-
}
|
|
347
|
-
var NginxJsonTrafficParser = class {
|
|
348
|
-
id = "nginx-json";
|
|
349
|
-
canParse(filePath, probe) {
|
|
350
|
-
const ext = path4.extname(filePath).toLowerCase();
|
|
351
|
-
const lowerFilePath = filePath.toLowerCase();
|
|
352
|
-
if (ext === ".ndjson" && lowerFilePath.includes("nginx")) {
|
|
353
|
-
return true;
|
|
354
|
-
}
|
|
355
|
-
const lowerProbe = probe.toLowerCase();
|
|
356
|
-
return lowerProbe.includes('"request_uri"') || lowerProbe.includes('"time_iso8601"') || lowerProbe.includes('"upstream_response_time"') || lowerProbe.includes('"remote_addr"');
|
|
357
|
-
}
|
|
358
|
-
async *parse(filePath) {
|
|
359
|
-
let index = 0;
|
|
360
|
-
for await (const record of parseJsonFile(filePath)) {
|
|
361
|
-
const normalized = normalizeWebServerRecord(record, index, filePath);
|
|
362
|
-
if (normalized) {
|
|
363
|
-
yield normalized;
|
|
364
|
-
}
|
|
365
|
-
index += 1;
|
|
366
|
-
}
|
|
367
|
-
}
|
|
368
|
-
};
|
|
369
|
-
var ApacheJsonTrafficParser = class {
|
|
370
|
-
id = "apache-json";
|
|
371
|
-
canParse(filePath, probe) {
|
|
372
|
-
const ext = path4.extname(filePath).toLowerCase();
|
|
373
|
-
const lowerFilePath = filePath.toLowerCase();
|
|
374
|
-
if (ext === ".ndjson" && lowerFilePath.includes("apache")) {
|
|
375
|
-
return true;
|
|
376
|
-
}
|
|
377
|
-
const lowerProbe = probe.toLowerCase();
|
|
378
|
-
return lowerProbe.includes('"request_method"') || lowerProbe.includes('"request_uri"') || lowerProbe.includes('"vhost"') || lowerProbe.includes('"response_status"');
|
|
379
|
-
}
|
|
380
|
-
async *parse(filePath) {
|
|
381
|
-
let index = 0;
|
|
382
|
-
for await (const record of parseJsonFile(filePath)) {
|
|
383
|
-
const normalized = normalizeWebServerRecord(record, index, filePath);
|
|
384
|
-
if (normalized) {
|
|
385
|
-
yield normalized;
|
|
386
|
-
}
|
|
387
|
-
index += 1;
|
|
388
|
-
}
|
|
389
|
-
}
|
|
390
|
-
};
|
|
391
|
-
|
|
392
|
-
// src/commands/drift/log-formats/registry.ts
|
|
393
|
-
var PARSERS = [
|
|
394
|
-
new HarTrafficParser(),
|
|
395
|
-
new KongTrafficParser(),
|
|
396
|
-
new NginxJsonTrafficParser(),
|
|
397
|
-
new ApacheJsonTrafficParser(),
|
|
398
|
-
new NdjsonTrafficParser()
|
|
399
|
-
];
|
|
400
|
-
async function selectTrafficParser(filePath, format) {
|
|
401
|
-
if (format !== "auto") {
|
|
402
|
-
const parser = PARSERS.find((candidate) => candidate.id === format);
|
|
403
|
-
if (!parser) {
|
|
404
|
-
throw new Error(`Unsupported parser format: ${format}`);
|
|
405
|
-
}
|
|
406
|
-
return parser;
|
|
407
|
-
}
|
|
408
|
-
const probe = await readProbe(filePath);
|
|
409
|
-
return PARSERS.find((candidate) => candidate.canParse(filePath, probe));
|
|
410
|
-
}
|
|
411
|
-
|
|
412
|
-
export {
|
|
413
|
-
selectTrafficParser
|
|
414
|
-
};
|