@piyushdoorwar/yamlet 1.1.5 → 1.1.7
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/yamlet.js +13 -6
- package/package.json +2 -2
package/dist/yamlet.js
CHANGED
|
@@ -1602,6 +1602,7 @@ async function exchange(opts) {
|
|
|
1602
1602
|
let headers = opts.headers.filter((h) => !(body instanceof FormData && h.key.toLowerCase() === "content-type" && !/boundary=/i.test(h.value)));
|
|
1603
1603
|
let explicitCookie = headers.find((h) => h.key.toLowerCase() === "cookie")?.value;
|
|
1604
1604
|
const start = performance.now();
|
|
1605
|
+
const redirects = [];
|
|
1605
1606
|
for (let hop = 0; ; hop++) {
|
|
1606
1607
|
const sent = headers.filter((h) => h.key.toLowerCase() !== "cookie");
|
|
1607
1608
|
const fromJar = opts.jar?.cookieHeaderFor(url);
|
|
@@ -1621,6 +1622,7 @@ async function exchange(opts) {
|
|
|
1621
1622
|
const location = headerValue(res.headers, "location");
|
|
1622
1623
|
if (opts.followRedirects && location && [301, 302, 303, 307, 308].includes(res.statusCode) && hop < MAX_REDIRECTS) {
|
|
1623
1624
|
await res.body.dump();
|
|
1625
|
+
redirects.push({ statusCode: res.statusCode, url });
|
|
1624
1626
|
const next = new URL(location, url);
|
|
1625
1627
|
if (next.host !== new URL(url).host) {
|
|
1626
1628
|
headers = headers.filter((h) => !["authorization", "cookie"].includes(h.key.toLowerCase()));
|
|
@@ -1635,7 +1637,7 @@ async function exchange(opts) {
|
|
|
1635
1637
|
continue;
|
|
1636
1638
|
}
|
|
1637
1639
|
const bytes = Buffer.from(await res.body.arrayBuffer());
|
|
1638
|
-
return { status: res.statusCode, headers: res.headers, bytes, sentHeaders: sent, firstByteMs, totalMs: performance.now() - start };
|
|
1640
|
+
return { status: res.statusCode, headers: res.headers, bytes, sentHeaders: sent, firstByteMs, totalMs: performance.now() - start, redirects };
|
|
1639
1641
|
}
|
|
1640
1642
|
}
|
|
1641
1643
|
function cookiesOf(url, headers) {
|
|
@@ -1655,6 +1657,7 @@ function consoleText(r) {
|
|
|
1655
1657
|
const lines = [`${r.method} ${r.resolvedUrl}`, "", "Request Headers", formatHeaders(r.requestHeaders), "", "Request Body", r.requestBody || "[empty]", "", "Response"];
|
|
1656
1658
|
if (r.isError) lines.push(`Error: ${r.errorMessage ?? "Request failed."}`);
|
|
1657
1659
|
else {
|
|
1660
|
+
for (const hop of r.redirects ?? []) lines.push(`${`HTTP ${hop.statusCode} ${STATUS_CODES[hop.statusCode] ?? ""}`.trim()} from ${hop.url} (followed)`);
|
|
1658
1661
|
lines.push(`HTTP ${r.statusCode} ${r.reasonPhrase}`, "Response Headers", formatHeaders(r.headers), "", "Response Body");
|
|
1659
1662
|
lines.push(r.bodyEncoding === "base64" ? `[binary body, ${r.sizeBytes} bytes]` : r.body || "[empty]");
|
|
1660
1663
|
}
|
|
@@ -1804,7 +1807,8 @@ async function execute(input) {
|
|
|
1804
1807
|
body: textual ? decodeText(ex.bytes, contentType) : ex.bytes.toString("base64"),
|
|
1805
1808
|
bodyEncoding: textual ? "utf8" : "base64",
|
|
1806
1809
|
contentType,
|
|
1807
|
-
timings: { total: Math.round(ex.totalMs), firstByte: Math.round(ex.firstByteMs), download: Math.max(0, Math.round(ex.totalMs - ex.firstByteMs)) }
|
|
1810
|
+
timings: { total: Math.round(ex.totalMs), firstByte: Math.round(ex.firstByteMs), download: Math.max(0, Math.round(ex.totalMs - ex.firstByteMs)) },
|
|
1811
|
+
...ex.redirects.length ? { redirects: ex.redirects } : {}
|
|
1808
1812
|
};
|
|
1809
1813
|
} catch (e) {
|
|
1810
1814
|
const message = input.signal?.aborted ? "Request was cancelled." : timeoutSignal?.aborted ? `Request timed out after ${timeoutMs} ms` : errMessage2(e);
|
|
@@ -2429,10 +2433,12 @@ function writeBody(b) {
|
|
|
2429
2433
|
function readSettings(o) {
|
|
2430
2434
|
const s = defaultSettings();
|
|
2431
2435
|
const raw = isObj(o.settings) ? o.settings : {};
|
|
2436
|
+
const behavior = isObj(o.protocolProfileBehavior) ? o.protocolProfileBehavior : {};
|
|
2432
2437
|
s.timeoutMs = int(raw.timeoutMs ?? raw.timeout) ?? 0;
|
|
2433
|
-
s.followRedirects = bool(raw.followRedirects) ?? true;
|
|
2438
|
+
s.followRedirects = bool(raw.followRedirects) ?? bool(behavior.followRedirects) ?? true;
|
|
2434
2439
|
const ssl = isObj(o.ssl) ? o.ssl : {};
|
|
2435
|
-
|
|
2440
|
+
const strict = bool(raw.strictSSL) ?? bool(behavior.strictSSL);
|
|
2441
|
+
s.skipSslVerification = bool(raw.skipSslVerification) ?? (strict === void 0 ? void 0 : !strict) ?? bool(o.skipSslVerification) ?? bool(ssl.skipVerification) ?? (bool(ssl.verify) === false ? true : void 0) ?? false;
|
|
2436
2442
|
return s;
|
|
2437
2443
|
}
|
|
2438
2444
|
function writeSettings(s) {
|
|
@@ -2487,7 +2493,8 @@ var REQUEST_KEYS = /* @__PURE__ */ new Set([
|
|
|
2487
2493
|
"settings",
|
|
2488
2494
|
"examples",
|
|
2489
2495
|
"skipSslVerification",
|
|
2490
|
-
"ssl"
|
|
2496
|
+
"ssl",
|
|
2497
|
+
"protocolProfileBehavior"
|
|
2491
2498
|
]);
|
|
2492
2499
|
function deriveNameFromFile(filePath) {
|
|
2493
2500
|
let name = filePath.split(/[\\/]/).pop() ?? filePath;
|
|
@@ -3357,7 +3364,7 @@ function ensureUniqueIds(ws, rel) {
|
|
|
3357
3364
|
}
|
|
3358
3365
|
|
|
3359
3366
|
// cli/src/index.ts
|
|
3360
|
-
var VERSION = true ? "1.1.
|
|
3367
|
+
var VERSION = true ? "1.1.7" : "0.0.0-dev";
|
|
3361
3368
|
setYamletVersion(VERSION);
|
|
3362
3369
|
var CliError = class extends Error {
|
|
3363
3370
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@piyushdoorwar/yamlet",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.7",
|
|
4
4
|
"description": "Run Yamlet API collections (Git-friendly YAML) from the command line or CI.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"ci",
|
|
29
29
|
"api-client"
|
|
30
30
|
],
|
|
31
|
-
"homepage": "https://piyushdoorwar.
|
|
31
|
+
"homepage": "https://yamlet.piyushdoorwar.com/",
|
|
32
32
|
"repository": {
|
|
33
33
|
"type": "git",
|
|
34
34
|
"url": "git+https://github.com/piyushdoorwar/yamlet.git",
|