@t0.labs/daxta 0.3.4 → 0.3.5

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.
@@ -1358,8 +1358,19 @@
1358
1358
  return currentBaseUrl() + path + (qs ? "?" + qs : "");
1359
1359
  };
1360
1360
 
1361
+ /** Headers for this recorded example; fall back to env group only if none were recorded. */
1362
+ const requestHeadersForScenario = (scenario) => {
1363
+ const recorded = { ...(scenario.headers || {}) };
1364
+ const vars = varMap();
1365
+ for (const [name, value] of Object.entries(recorded)) {
1366
+ recorded[name] = String(interpolate(value, vars));
1367
+ }
1368
+ if (Object.keys(recorded).length) return recorded;
1369
+ return resolvedHeaders();
1370
+ };
1371
+
1361
1372
  const toCurl = (item, scenario) => {
1362
- const headers = resolvedHeaders();
1373
+ const headers = requestHeadersForScenario(scenario);
1363
1374
  const body = scenario.reqBody !== undefined ? interpolate(scenario.reqBody, varMap()) : undefined;
1364
1375
  const lines = ["curl -X " + item.method.toUpperCase() + " '" + resolvedUrl(item, scenario).replace(/'/g, "'\\''") + "'"];
1365
1376
  for (const [name, value] of Object.entries(headers)) {
@@ -1384,7 +1395,7 @@
1384
1395
 
1385
1396
  const sendRequest = async (item, scenario) => {
1386
1397
  const target = resolvedUrl(item, scenario);
1387
- const headers = { ...resolvedHeaders() };
1398
+ const headers = { ...requestHeadersForScenario(scenario) };
1388
1399
  const body = scenario.reqBody !== undefined ? interpolate(scenario.reqBody, varMap()) : undefined;
1389
1400
  if (body !== undefined && !headers["content-type"] && !headers["Content-Type"]) {
1390
1401
  headers["content-type"] = "application/json";
@@ -1675,6 +1686,7 @@
1675
1686
  const fields = item.docs.fields || [];
1676
1687
  ensureRequiredHeaderGroup(item.op);
1677
1688
  const injectedHeaders = resolvedHeaders();
1689
+ const recordedHeaders = scenario.headers || {};
1678
1690
  const recordedOk = scenario.status >= 200 && scenario.status < 300;
1679
1691
  const statusText = STATUS[scenario.status] || item.op.responses?.[String(scenario.status)]?.description || "";
1680
1692
  const emptyResponse = scenario.resBody === undefined || scenario.status === 204;
@@ -1687,9 +1699,13 @@
1687
1699
  const displayEmpty = showingLive ? displayBody === undefined || displayBody === "" : emptyResponse;
1688
1700
  const resCopyText = displayEmpty ? null : copyBodyText(displayBody);
1689
1701
  const responseTitle = showingLive ? "Live response" : "Recorded response";
1690
- const headersHtml = Object.keys(injectedHeaders).length
1691
- ? Object.entries(injectedHeaders).map(([name, value]) => kv(name, value)).join("")
1692
- : `<div class="meta-empty">No headers in the active group - pick the required group in the env panel.</div>`;
1702
+ // Request card shows the recorded scenario headers (match this example).
1703
+ // Send / cURL still use env header groups so secrets stay editable.
1704
+ const headersHtml = Object.keys(recordedHeaders).length
1705
+ ? Object.entries(recordedHeaders).map(([name, value]) => kv(name, value)).join("")
1706
+ : Object.keys(injectedHeaders).length
1707
+ ? Object.entries(injectedHeaders).map(([name, value]) => kv(name, value)).join("")
1708
+ : `<div class="meta-empty">No headers recorded for this example</div>`;
1693
1709
  const pathParamsHtml = Object.entries(scenario.pathParams || {})
1694
1710
  .map(([name, value]) => kv(name, value))
1695
1711
  .join("");
@@ -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
- // Include resBody so a new response keeps its matching request as its own scenario.
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) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@t0.labs/daxta",
3
- "version": "0.3.4",
3
+ "version": "0.3.5",
4
4
  "description": "DAxTA \u2014 docs from Nest integration traffic + DTO field CLI / Try-it",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",