@apilift/cli 1.8.8 → 1.8.9
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/dist/apilift.js
CHANGED
|
@@ -47639,13 +47639,30 @@ function requestEncoding(entry2) {
|
|
|
47639
47639
|
}
|
|
47640
47640
|
return { mediaType, encoding: mediaType === "application/json" || mediaType.endsWith("+json") ? "invalid-json" : "unsupported", reason: "No complete JSON or declared URL-encoded body is available; do not guess a replay body or repeat a mutation" };
|
|
47641
47641
|
}
|
|
47642
|
-
function
|
|
47642
|
+
function assertRequestBody(entry2) {
|
|
47643
47643
|
const state = entry2.reqBodyState;
|
|
47644
47644
|
if (entry2.pending || state !== void 0 && !["complete", "absent"].includes(String(state))) {
|
|
47645
47645
|
const encoding = requestEncoding(entry2);
|
|
47646
47646
|
throw new Error(`Captured request body is ${entry2.pending ? "collecting" : String(state)} (media type: ${encoding.mediaType}; encoding: ${encoding.encoding}). Use retained evidence or an authorized alternative; do not repeat a mutation`);
|
|
47647
47647
|
}
|
|
47648
47648
|
if (entry2.reqBody == null && Number(entry2.reqHeaders?.["content-length"]) > 0) throw new Error("Captured request declares a nonempty body but retained no body. Do not author a bodyless replay or repeat the mutation");
|
|
47649
|
+
}
|
|
47650
|
+
function scalarMultipart(entry2) {
|
|
47651
|
+
assertRequestBody(entry2);
|
|
47652
|
+
const encoding = requestEncoding(entry2);
|
|
47653
|
+
const contentType = String(Object.entries(entry2.reqHeaders ?? {}).find(([name]) => name.toLowerCase() === "content-type")?.[1] ?? "");
|
|
47654
|
+
let parsed;
|
|
47655
|
+
try {
|
|
47656
|
+
if (typeof entry2.reqBody !== "string") throw new Error();
|
|
47657
|
+
parsed = parseMultipart(entry2.reqBody, contentType);
|
|
47658
|
+
} catch {
|
|
47659
|
+
throw new Error(`Captured request cannot be authored (media type: ${encoding.mediaType}; encoding: ${encoding.encoding}). Scalar multipart framing is incomplete; inspect retained evidence without repeating a mutation`);
|
|
47660
|
+
}
|
|
47661
|
+
if (parsed.parts.some((part) => part.file)) throw new Error("Multipart file bytes require an explicit approved local file input");
|
|
47662
|
+
return parsed.parts.map(({ name, value }) => ({ name, value }));
|
|
47663
|
+
}
|
|
47664
|
+
function deriveRequest(entry2, inputs) {
|
|
47665
|
+
assertRequestBody(entry2);
|
|
47649
47666
|
const url3 = new URL(String(entry2.url));
|
|
47650
47667
|
const unresolved2 = [];
|
|
47651
47668
|
const secrets = new Set(Object.entries(entry2.reqHeaders ?? {}).filter(([name]) => sensitive.test(name)).flatMap(([, value]) => typeof value === "string" ? [value, value.replace(/^(Bearer|Basic) /i, "")] : []));
|
|
@@ -47702,15 +47719,7 @@ function deriveRequest(entry2, inputs) {
|
|
|
47702
47719
|
}
|
|
47703
47720
|
request2.form = form;
|
|
47704
47721
|
} else if (encoding.encoding === "multipart") {
|
|
47705
|
-
|
|
47706
|
-
let parsed;
|
|
47707
|
-
try {
|
|
47708
|
-
parsed = parseMultipart(entry2.reqBody, contentType);
|
|
47709
|
-
} catch {
|
|
47710
|
-
throw new Error(`Captured request cannot be authored (media type: ${encoding.mediaType}; encoding: ${encoding.encoding}). Scalar multipart framing is incomplete; inspect retained evidence without repeating a mutation`);
|
|
47711
|
-
}
|
|
47712
|
-
if (parsed.parts.some((part) => part.file)) throw new Error("Multipart file bytes require an explicit approved local file input");
|
|
47713
|
-
request2.multipart = parsed.parts.map((part, index2) => ({ name: part.name, value: sensitive.test(part.name) || /^policy$/iu.test(part.name) ? pending(`/request/multipart/${index2}/value`) : bind2(part.value, `/request/multipart/${index2}/value`, true) }));
|
|
47722
|
+
request2.multipart = scalarMultipart(entry2).map((part, index2) => ({ name: part.name, value: sensitive.test(part.name) || /^policy$/iu.test(part.name) ? pending(`/request/multipart/${index2}/value`) : bind2(part.value, `/request/multipart/${index2}/value`, true) }));
|
|
47714
47723
|
} else {
|
|
47715
47724
|
let body;
|
|
47716
47725
|
try {
|
|
@@ -49318,7 +49327,15 @@ ${requestHeaderSummary(entry2)}${requestQuerySummary(entry2)}${entry2.reqBodySha
|
|
|
49318
49327
|
if (typeof body !== "string") return fail5(`Captured ${part} body for c${item.seq} is ${String(unavailable ?? "unavailable")}. Metadata: ${candidateLine(item)}
|
|
49319
49328
|
${redactionReason}`);
|
|
49320
49329
|
let parsed;
|
|
49321
|
-
|
|
49330
|
+
const multipart2 = part === "request" && requestEncoding(entry2).encoding === "multipart";
|
|
49331
|
+
if (multipart2) {
|
|
49332
|
+
try {
|
|
49333
|
+
parsed = { multipart: scalarMultipart({ ...entry2, reqBody: body }) };
|
|
49334
|
+
} catch (error62) {
|
|
49335
|
+
return fail5(`${error62 instanceof Error ? error62.message : "Captured multipart request is unavailable"}. No app request is sent.
|
|
49336
|
+
`);
|
|
49337
|
+
}
|
|
49338
|
+
} else try {
|
|
49322
49339
|
parsed = JSON.parse(body);
|
|
49323
49340
|
} catch {
|
|
49324
49341
|
const headers = entry2[part === "request" ? "reqHeaders" : "resHeaders"] ?? {};
|
|
@@ -49339,25 +49356,27 @@ Metadata: ${candidateLine(item)}
|
|
|
49339
49356
|
`);
|
|
49340
49357
|
}
|
|
49341
49358
|
}
|
|
49359
|
+
const values = sensitiveValues(entry2.reqHeaders, sensitiveValues(entry2.resHeaders, sensitiveValues(parsed)));
|
|
49360
|
+
if (multipart2) for (const value of preparationSecrets(parsed).filter(Boolean)) values.add(value);
|
|
49361
|
+
parsed = protectedBody(parsed, values);
|
|
49342
49362
|
if (pointer11) {
|
|
49343
|
-
if (!pointer11.startsWith("/")) return fail5("--pointer must be a JSON pointer beginning with /.\n");
|
|
49363
|
+
if (!pointer11.startsWith("/") || /~(?![01])/u.test(pointer11)) return fail5("--pointer must be a JSON pointer beginning with /.\n");
|
|
49344
49364
|
for (const segment of pointer11.slice(1).split("/").map((value) => value.replaceAll("~1", "/").replaceAll("~0", "~"))) {
|
|
49345
|
-
if (parsed === null || typeof parsed !== "object" || !(segment
|
|
49365
|
+
if (parsed === null || typeof parsed !== "object" || !Object.hasOwn(parsed, segment)) return fail5(`Pointer ${pointer11} is absent in the captured ${part}.
|
|
49346
49366
|
`);
|
|
49347
49367
|
parsed = parsed[segment];
|
|
49348
49368
|
}
|
|
49349
49369
|
}
|
|
49350
|
-
const values = sensitiveValues(entry2.reqHeaders, sensitiveValues(entry2.resHeaders, sensitiveValues(parsed)));
|
|
49351
49370
|
const firstField = !pointer11 && parsed && typeof parsed === "object" ? Array.isArray(parsed) ? parsed.length ? "0" : null : Object.keys(parsed)[0] : null;
|
|
49352
|
-
const fieldPointer = firstField === null || firstField === void 0 ? null : `/${firstField.replaceAll("~", "~0").replaceAll("/", "~1")}`;
|
|
49371
|
+
const fieldPointer = !pointer11 && multipart2 ? "/multipart/0/value" : firstField === null || firstField === void 0 ? null : `/${firstField.replaceAll("~", "~0").replaceAll("/", "~1")}`;
|
|
49353
49372
|
return ok4(`Captured ${part} for c${item.seq}; protected fields redacted.
|
|
49354
|
-
${JSON.stringify(
|
|
49373
|
+
${JSON.stringify(parsed, null, 2)}
|
|
49355
49374
|
${part === "request" ? `
|
|
49356
49375
|
${requestHeaderSummary(entry2)}${requestQuerySummary(entry2)}` : ""}
|
|
49357
49376
|
This reads retained evidence; it sends no app request.
|
|
49358
49377
|
Inspect request metadata or its available body: ${command4(invocation, `discover capture show c${item.seq} --part request`)}
|
|
49359
49378
|
${fieldPointer ? `Inspect a displayed JSON field with --pointer <JSON-pointer>:
|
|
49360
|
-
${command4(invocation, `discover capture show c${item.seq} --part
|
|
49379
|
+
${command4(invocation, `discover capture show c${item.seq} --part ${part} --pointer ${fieldPointer}`)}
|
|
49361
49380
|
` : ""}If this request caused the intended UI outcome, select it for the draft:
|
|
49362
49381
|
${command4(invocation, `discover capture select c${item.seq}`)}
|
|
49363
49382
|
`);
|
|
@@ -49673,6 +49692,7 @@ var import__16, exampleBinding, ok4, fail5, backendKind, label, command4, action
|
|
|
49673
49692
|
var init_discover = __esm({
|
|
49674
49693
|
"src/commands/discover.ts"() {
|
|
49675
49694
|
"use strict";
|
|
49695
|
+
init_prepared_fields();
|
|
49676
49696
|
init_version();
|
|
49677
49697
|
init_api2();
|
|
49678
49698
|
init_definitions();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@apilift/cli",
|
|
3
|
-
"version": "1.8.
|
|
3
|
+
"version": "1.8.9",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"engines": {
|
|
38
38
|
"node": ">=24.16.0 <27"
|
|
39
39
|
},
|
|
40
|
-
"gitHead": "
|
|
40
|
+
"gitHead": "7daa043350aad9d05a3382853784f158e57b8661",
|
|
41
41
|
"repository": {
|
|
42
42
|
"type": "git",
|
|
43
43
|
"url": "git+https://github.com/egor-sergeev/apilift.git",
|