@t0.labs/daxta 0.3.4 → 0.3.6
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/assets/viewer.html +28 -6
- package/dist/build/build-spec.js +10 -2
- package/package.json +1 -1
package/assets/viewer.html
CHANGED
|
@@ -1358,8 +1358,30 @@
|
|
|
1358
1358
|
return currentBaseUrl() + path + (qs ? "?" + qs : "");
|
|
1359
1359
|
};
|
|
1360
1360
|
|
|
1361
|
+
/**
|
|
1362
|
+
* Use only headers that were on this recorded request.
|
|
1363
|
+
* Empty headers (e.g. 401 missing-auth cases) must stay empty — never inject env auth.
|
|
1364
|
+
* When headers exist, env can override values for the same keys (live tokens).
|
|
1365
|
+
*/
|
|
1366
|
+
const requestHeadersForScenario = (scenario) => {
|
|
1367
|
+
const recorded = { ...(scenario.headers || {}) };
|
|
1368
|
+
const vars = varMap();
|
|
1369
|
+
const envHeaders = resolvedHeaders();
|
|
1370
|
+
const envByLower = {};
|
|
1371
|
+
for (const [name, value] of Object.entries(envHeaders)) {
|
|
1372
|
+
envByLower[String(name).toLowerCase()] = value;
|
|
1373
|
+
}
|
|
1374
|
+
const out = {};
|
|
1375
|
+
for (const [name, value] of Object.entries(recorded)) {
|
|
1376
|
+
const fromEnv = envByLower[String(name).toLowerCase()];
|
|
1377
|
+
const raw = fromEnv != null && String(fromEnv).trim() !== "" ? fromEnv : value;
|
|
1378
|
+
out[name] = String(interpolate(raw, vars));
|
|
1379
|
+
}
|
|
1380
|
+
return out;
|
|
1381
|
+
};
|
|
1382
|
+
|
|
1361
1383
|
const toCurl = (item, scenario) => {
|
|
1362
|
-
const headers =
|
|
1384
|
+
const headers = requestHeadersForScenario(scenario);
|
|
1363
1385
|
const body = scenario.reqBody !== undefined ? interpolate(scenario.reqBody, varMap()) : undefined;
|
|
1364
1386
|
const lines = ["curl -X " + item.method.toUpperCase() + " '" + resolvedUrl(item, scenario).replace(/'/g, "'\\''") + "'"];
|
|
1365
1387
|
for (const [name, value] of Object.entries(headers)) {
|
|
@@ -1384,7 +1406,7 @@
|
|
|
1384
1406
|
|
|
1385
1407
|
const sendRequest = async (item, scenario) => {
|
|
1386
1408
|
const target = resolvedUrl(item, scenario);
|
|
1387
|
-
const headers = { ...
|
|
1409
|
+
const headers = { ...requestHeadersForScenario(scenario) };
|
|
1388
1410
|
const body = scenario.reqBody !== undefined ? interpolate(scenario.reqBody, varMap()) : undefined;
|
|
1389
1411
|
if (body !== undefined && !headers["content-type"] && !headers["Content-Type"]) {
|
|
1390
1412
|
headers["content-type"] = "application/json";
|
|
@@ -1674,7 +1696,7 @@
|
|
|
1674
1696
|
const scenario = item.scenarios[scenarioIndex] || { status: 0, pathParams: {}, query: {}, headers: {}, name: "" };
|
|
1675
1697
|
const fields = item.docs.fields || [];
|
|
1676
1698
|
ensureRequiredHeaderGroup(item.op);
|
|
1677
|
-
const
|
|
1699
|
+
const recordedHeaders = scenario.headers || {};
|
|
1678
1700
|
const recordedOk = scenario.status >= 200 && scenario.status < 300;
|
|
1679
1701
|
const statusText = STATUS[scenario.status] || item.op.responses?.[String(scenario.status)]?.description || "";
|
|
1680
1702
|
const emptyResponse = scenario.resBody === undefined || scenario.status === 204;
|
|
@@ -1687,9 +1709,9 @@
|
|
|
1687
1709
|
const displayEmpty = showingLive ? displayBody === undefined || displayBody === "" : emptyResponse;
|
|
1688
1710
|
const resCopyText = displayEmpty ? null : copyBodyText(displayBody);
|
|
1689
1711
|
const responseTitle = showingLive ? "Live response" : "Recorded response";
|
|
1690
|
-
const headersHtml = Object.keys(
|
|
1691
|
-
? Object.entries(
|
|
1692
|
-
: `<div class="meta-empty">No headers
|
|
1712
|
+
const headersHtml = Object.keys(recordedHeaders).length
|
|
1713
|
+
? Object.entries(recordedHeaders).map(([name, value]) => kv(name, value)).join("")
|
|
1714
|
+
: `<div class="meta-empty">No headers on this recorded request</div>`;
|
|
1693
1715
|
const pathParamsHtml = Object.entries(scenario.pathParams || {})
|
|
1694
1716
|
.map(([name, value]) => kv(name, value))
|
|
1695
1717
|
.join("");
|
package/dist/build/build-spec.js
CHANGED
|
@@ -357,7 +357,7 @@ function sortScenarios(scenarios) {
|
|
|
357
357
|
function dedupeScenarios(scenarios) {
|
|
358
358
|
const seen = new Set();
|
|
359
359
|
return scenarios.filter((scenario) => {
|
|
360
|
-
//
|
|
360
|
+
// Full request+response fingerprint so matching headers/body stay with each example.
|
|
361
361
|
const key = JSON.stringify([
|
|
362
362
|
scenario.group,
|
|
363
363
|
scenario.name,
|
|
@@ -366,6 +366,7 @@ function dedupeScenarios(scenarios) {
|
|
|
366
366
|
scenario.resBody,
|
|
367
367
|
scenario.query,
|
|
368
368
|
scenario.pathParams,
|
|
369
|
+
scenario.headers,
|
|
369
370
|
]);
|
|
370
371
|
if (seen.has(key))
|
|
371
372
|
return false;
|
|
@@ -533,11 +534,14 @@ function scenarioSignature(scenario) {
|
|
|
533
534
|
status: scenario.status,
|
|
534
535
|
queryKeys: sortedKeys(scenario.query),
|
|
535
536
|
pathParamKeys: sortedKeys(scenario.pathParams),
|
|
537
|
+
headerKeys: sortedKeys(scenario.headers),
|
|
536
538
|
reqSchema: signatureSchema(scenario.reqBody),
|
|
537
539
|
resSchema: signatureSchema(scenario.resBody),
|
|
538
|
-
// Value fingerprints so body content changes invalidate the cached operation.
|
|
539
540
|
reqValue: valueFingerprint(scenario.reqBody),
|
|
540
541
|
resValue: valueFingerprint(scenario.resBody),
|
|
542
|
+
headerValue: valueFingerprint(scenario.headers),
|
|
543
|
+
queryValue: valueFingerprint(scenario.query),
|
|
544
|
+
pathParamValue: valueFingerprint(scenario.pathParams),
|
|
541
545
|
});
|
|
542
546
|
}
|
|
543
547
|
function exampleFingerprints(operation) {
|
|
@@ -584,10 +588,14 @@ function hitSignature(hit) {
|
|
|
584
588
|
test: hit.test,
|
|
585
589
|
queryKeys: sortedKeys(hit.query),
|
|
586
590
|
pathParamKeys: sortedKeys(hit.pathParams),
|
|
591
|
+
headerKeys: sortedKeys(hit.headers),
|
|
587
592
|
reqSchema: signatureSchema(hit.reqBody),
|
|
588
593
|
resSchema: signatureSchema(hit.resBody),
|
|
589
594
|
reqValue: valueFingerprint(hit.reqBody),
|
|
590
595
|
resValue: valueFingerprint(hit.resBody),
|
|
596
|
+
headerValue: valueFingerprint(hit.headers),
|
|
597
|
+
queryValue: valueFingerprint(hit.query),
|
|
598
|
+
pathParamValue: valueFingerprint(hit.pathParams),
|
|
591
599
|
});
|
|
592
600
|
}
|
|
593
601
|
function hitsStructureSame(existing, fresh) {
|