@t0.labs/daxta 0.3.5 → 0.3.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.
@@ -1358,15 +1358,26 @@
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. */
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
+ */
1362
1366
  const requestHeadersForScenario = (scenario) => {
1363
1367
  const recorded = { ...(scenario.headers || {}) };
1364
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 = {};
1365
1375
  for (const [name, value] of Object.entries(recorded)) {
1366
- recorded[name] = String(interpolate(value, vars));
1376
+ const fromEnv = envByLower[String(name).toLowerCase()];
1377
+ const raw = fromEnv != null && String(fromEnv).trim() !== "" ? fromEnv : value;
1378
+ out[name] = String(interpolate(raw, vars));
1367
1379
  }
1368
- if (Object.keys(recorded).length) return recorded;
1369
- return resolvedHeaders();
1380
+ return out;
1370
1381
  };
1371
1382
 
1372
1383
  const toCurl = (item, scenario) => {
@@ -1685,7 +1696,6 @@
1685
1696
  const scenario = item.scenarios[scenarioIndex] || { status: 0, pathParams: {}, query: {}, headers: {}, name: "" };
1686
1697
  const fields = item.docs.fields || [];
1687
1698
  ensureRequiredHeaderGroup(item.op);
1688
- const injectedHeaders = resolvedHeaders();
1689
1699
  const recordedHeaders = scenario.headers || {};
1690
1700
  const recordedOk = scenario.status >= 200 && scenario.status < 300;
1691
1701
  const statusText = STATUS[scenario.status] || item.op.responses?.[String(scenario.status)]?.description || "";
@@ -1699,13 +1709,9 @@
1699
1709
  const displayEmpty = showingLive ? displayBody === undefined || displayBody === "" : emptyResponse;
1700
1710
  const resCopyText = displayEmpty ? null : copyBodyText(displayBody);
1701
1711
  const responseTitle = showingLive ? "Live response" : "Recorded response";
1702
- // Request card shows the recorded scenario headers (match this example).
1703
- // Send / cURL still use env header groups so secrets stay editable.
1704
1712
  const headersHtml = Object.keys(recordedHeaders).length
1705
1713
  ? 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>`;
1714
+ : `<div class="meta-empty">No headers on this recorded request</div>`;
1709
1715
  const pathParamsHtml = Object.entries(scenario.pathParams || {})
1710
1716
  .map(([name, value]) => kv(name, value))
1711
1717
  .join("");
@@ -1,11 +1,8 @@
1
1
  /**
2
- * Jest reporter plugin — records/rebuilds during the run, prints Docs ready at the end.
3
- * Jest stays the process parent; DAxTA is only a plugin.
2
+ * Jest reporter — only builds OpenAPI/HTML when the full run completes.
3
+ * During the run we only record hits (superagent hook + flush); no mid-run rebuilds.
4
4
  */
5
5
  declare class DaxtaJestReporter {
6
- private suitesDone;
7
- onTestResult(): void;
8
6
  onRunComplete(): void;
9
- private rebuild;
10
7
  }
11
8
  export = DaxtaJestReporter;
@@ -28,43 +28,28 @@ function printDocsReady(hits, operations) {
28
28
  }
29
29
  }
30
30
  /**
31
- * Jest reporter plugin — records/rebuilds during the run, prints Docs ready at the end.
32
- * Jest stays the process parent; DAxTA is only a plugin.
31
+ * Jest reporter — only builds OpenAPI/HTML when the full run completes.
32
+ * During the run we only record hits (superagent hook + flush); no mid-run rebuilds.
33
33
  */
34
34
  class DaxtaJestReporter {
35
- constructor() {
36
- this.suitesDone = 0;
37
- }
38
- onTestResult() {
39
- this.suitesDone += 1;
40
- this.rebuild({ html: this.suitesDone % 5 === 0 });
41
- }
42
35
  onRunComplete() {
43
- const result = this.rebuild({ html: true });
44
- if (!result || result.skipped) {
45
- try {
46
- const build = (0, build_spec_1.buildDaxtaSpec)({ silent: true, html: true });
47
- (0, incremental_1.clearPartialMarker)();
48
- if (!build.skipped)
49
- printDocsReady(build.hits, build.operations);
50
- }
51
- catch {
52
- // ignore
53
- }
54
- return;
55
- }
56
- printDocsReady(result.hits ?? 0, result.operations ?? 0);
57
- }
58
- rebuild(options) {
59
36
  try {
60
37
  // eslint-disable-next-line @typescript-eslint/no-var-requires
61
38
  require('reflect-metadata');
62
39
  // eslint-disable-next-line @typescript-eslint/no-var-requires
63
40
  const { rebuildFromDisk } = require('../build/incremental');
64
- return rebuildFromDisk({ silent: true, force: true, html: options.html });
41
+ const result = rebuildFromDisk({ silent: true, force: true, html: true });
42
+ if (result && !result.skipped) {
43
+ printDocsReady(result.hits ?? 0, result.operations ?? 0);
44
+ return;
45
+ }
46
+ const build = (0, build_spec_1.buildDaxtaSpec)({ silent: true, html: true });
47
+ (0, incremental_1.clearPartialMarker)();
48
+ if (!build.skipped)
49
+ printDocsReady(build.hits, build.operations);
65
50
  }
66
51
  catch {
67
- return null;
52
+ // never fail the test run
68
53
  }
69
54
  }
70
55
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@t0.labs/daxta",
3
- "version": "0.3.5",
3
+ "version": "0.3.7",
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",