@t0.labs/daxta 0.4.22 → 0.4.23

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.
@@ -0,0 +1,176 @@
1
+ <!doctype html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="utf-8" />
5
+ <meta name="viewport" content="width=device-width, initial-scale=1" />
6
+ <title>Notary</title>
7
+ <link rel="preconnect" href="https://fonts.googleapis.com" />
8
+ <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
9
+ <link href="https://fonts.googleapis.com/css2?family=Geist+Mono:wght@400;500;600&family=Geist:wght@400;500;600&display=swap" rel="stylesheet" />
10
+ <style>
11
+ :root {
12
+ --canvas: #fafafa;
13
+ --nav: #ffffff;
14
+ --white: #ffffff;
15
+ --inset: #f5f5f5;
16
+ --hairline: #e6e6e6;
17
+ --stone: #666666;
18
+ --charcoal: #333333;
19
+ --obsidian: #111111;
20
+ --sans: Geist, Inter, ui-sans-serif, system-ui, sans-serif;
21
+ --mono: "Geist Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
22
+ --radius: 5px;
23
+ }
24
+ * { box-sizing: border-box; }
25
+ html, body { height: 100%; }
26
+ body {
27
+ margin: 0;
28
+ background: var(--canvas);
29
+ color: var(--obsidian);
30
+ font: 13px/1.45 var(--sans);
31
+ }
32
+ .topnav {
33
+ height: 44px;
34
+ display: flex;
35
+ align-items: center;
36
+ gap: 10px;
37
+ padding: 0 16px;
38
+ background: var(--nav);
39
+ border-bottom: 1px solid var(--hairline);
40
+ }
41
+ .logo-mark {
42
+ width: 20px;
43
+ height: 20px;
44
+ border-radius: 4px;
45
+ background: var(--obsidian);
46
+ color: var(--white);
47
+ font: 600 11px/20px var(--sans);
48
+ text-align: center;
49
+ flex: none;
50
+ }
51
+ .logo-name {
52
+ font-size: 13px;
53
+ font-weight: 600;
54
+ letter-spacing: -0.02em;
55
+ }
56
+ .nav-meta {
57
+ margin-left: auto;
58
+ font: 11px/1 var(--mono);
59
+ color: var(--stone);
60
+ }
61
+ .stage {
62
+ min-height: calc(100vh - 44px);
63
+ display: flex;
64
+ align-items: center;
65
+ justify-content: center;
66
+ padding: 32px 16px;
67
+ }
68
+ .panel {
69
+ width: min(440px, 100%);
70
+ background: var(--white);
71
+ border: 1px solid var(--hairline);
72
+ border-radius: var(--radius);
73
+ padding: 24px;
74
+ }
75
+ .kicker {
76
+ font: 600 10px/1 var(--mono);
77
+ letter-spacing: 0.08em;
78
+ text-transform: uppercase;
79
+ color: var(--stone);
80
+ margin: 0 0 8px;
81
+ }
82
+ h1 {
83
+ margin: 0 0 8px;
84
+ font-size: 22px;
85
+ font-weight: 600;
86
+ letter-spacing: -0.04em;
87
+ line-height: 1.25;
88
+ }
89
+ p {
90
+ margin: 0 0 16px;
91
+ color: var(--charcoal);
92
+ font-size: 13px;
93
+ line-height: 1.5;
94
+ }
95
+ .steps {
96
+ margin: 0 0 16px;
97
+ padding: 0;
98
+ list-style: none;
99
+ border: 1px solid var(--hairline);
100
+ border-radius: var(--radius);
101
+ overflow: hidden;
102
+ }
103
+ .steps li {
104
+ display: grid;
105
+ grid-template-columns: 22px 1fr;
106
+ gap: 10px;
107
+ align-items: start;
108
+ padding: 10px 12px;
109
+ border-top: 1px solid var(--hairline);
110
+ font-size: 13px;
111
+ }
112
+ .steps li:first-child { border-top: 0; }
113
+ .n {
114
+ font: 600 11px/22px var(--mono);
115
+ color: var(--stone);
116
+ }
117
+ .cmd {
118
+ margin: 0 0 16px;
119
+ padding: 10px 12px;
120
+ background: var(--inset);
121
+ border: 1px solid var(--hairline);
122
+ border-radius: var(--radius);
123
+ font: 12px/1.45 var(--mono);
124
+ color: var(--obsidian);
125
+ }
126
+ .actions { display: flex; gap: 8px; }
127
+ .btn {
128
+ height: 32px;
129
+ padding: 0 12px;
130
+ border: 1px solid var(--hairline);
131
+ border-radius: var(--radius);
132
+ background: var(--white);
133
+ font: 12px/1 var(--sans);
134
+ color: var(--charcoal);
135
+ cursor: pointer;
136
+ }
137
+ .btn.primary {
138
+ background: var(--obsidian);
139
+ color: var(--white);
140
+ border-color: var(--obsidian);
141
+ }
142
+ .foot {
143
+ margin-top: 16px;
144
+ font-size: 11px;
145
+ color: #888;
146
+ }
147
+ </style>
148
+ </head>
149
+ <body>
150
+ <header class="topnav">
151
+ <span class="logo-mark">N</span>
152
+ <span class="logo-name">Notary</span>
153
+ <span class="nav-meta">/docs</span>
154
+ </header>
155
+ <main class="stage">
156
+ <div class="panel">
157
+ <p class="kicker">Waiting</p>
158
+ <h1>No documentation yet</h1>
159
+ <p>This page publishes when API traffic has been recorded. Run your integration tests, then refresh.</p>
160
+ <ol class="steps">
161
+ <li><span class="n">1</span><span>Run the integration suite that hits your API.</span></li>
162
+ <li><span class="n">2</span><span>Notary writes the docs from those requests and responses.</span></li>
163
+ <li><span class="n">3</span><span>Reload this page to open the workbench.</span></li>
164
+ </ol>
165
+ <pre class="cmd">pnpm run test:integration</pre>
166
+ <div class="actions">
167
+ <button class="btn primary" type="button" id="reload">Refresh</button>
168
+ </div>
169
+ <div class="foot">Generated by Notary</div>
170
+ </div>
171
+ </main>
172
+ <script>
173
+ document.getElementById("reload").onclick = () => location.reload();
174
+ </script>
175
+ </body>
176
+ </html>
@@ -553,16 +553,87 @@
553
553
  gap: 2px;
554
554
  min-width: 0;
555
555
  }
556
+ .nav-expand {
557
+ flex: none;
558
+ width: 24px;
559
+ height: 24px;
560
+ border: 0;
561
+ border-radius: 4px;
562
+ background: transparent;
563
+ color: var(--stone);
564
+ cursor: pointer;
565
+ display: inline-flex;
566
+ align-items: center;
567
+ justify-content: center;
568
+ padding: 0;
569
+ }
570
+ .nav-expand:hover { color: var(--obsidian); background: var(--inset); }
571
+ .nav-expand .chev {
572
+ width: 6px;
573
+ height: 6px;
574
+ border-right: 1.5px solid currentColor;
575
+ border-bottom: 1.5px solid currentColor;
576
+ transform: rotate(-45deg);
577
+ margin-top: -2px;
578
+ }
579
+ .nav-op.examples-open > .nav-op-row .nav-expand .chev {
580
+ transform: rotate(45deg);
581
+ margin-top: 0;
582
+ }
583
+ .nav-expand:disabled { opacity: 0.25; cursor: default; }
584
+ .nav-examples {
585
+ display: none;
586
+ flex-direction: column;
587
+ gap: 4px;
588
+ margin: 0 4px 6px 18px;
589
+ padding-left: 8px;
590
+ border-left: 1px solid var(--hairline);
591
+ }
592
+ .nav-op.examples-open > .nav-examples { display: flex; }
593
+ .nav-ex-group { display: flex; flex-direction: column; gap: 1px; }
594
+ .nav-ex-group-label {
595
+ display: flex;
596
+ align-items: center;
597
+ justify-content: space-between;
598
+ gap: 8px;
599
+ padding: 6px 8px 2px;
600
+ font: 600 10px/1.2 var(--sans);
601
+ letter-spacing: 0.02em;
602
+ color: var(--stone);
603
+ }
604
+ .nav-ex-count {
605
+ font: 600 10px/1.4 var(--mono);
606
+ color: var(--stone);
607
+ }
608
+ .nav-example {
609
+ display: block;
610
+ width: 100%;
611
+ border: 0;
612
+ background: transparent;
613
+ text-align: left;
614
+ padding: 4px 8px;
615
+ border-radius: 4px;
616
+ cursor: pointer;
617
+ font-size: 11px;
618
+ line-height: 1.35;
619
+ color: var(--stone);
620
+ overflow: hidden;
621
+ text-overflow: ellipsis;
622
+ white-space: nowrap;
623
+ }
624
+ .nav-example:hover { background: var(--inset); color: var(--charcoal); }
625
+ .nav-example.on { color: var(--obsidian); background: var(--inset); }
556
626
  .nav-ex-total {
557
627
  flex: none;
558
628
  min-width: 16px;
559
- margin-right: 6px;
629
+ margin-right: 2px;
560
630
  padding: 1px 5px;
561
631
  border-radius: 4px;
562
632
  background: var(--obsidian);
563
633
  color: var(--white);
564
634
  font: 600 10px/1.4 var(--mono);
565
635
  text-align: center;
636
+ cursor: pointer;
566
637
  }
567
638
  .nav-title {
568
639
  font-size: 12px;
@@ -2514,11 +2585,6 @@
2514
2585
  "INVALID CASES",
2515
2586
  "OMITTED CASES",
2516
2587
  "SEMANTIC ERROR CASES - AUTH",
2517
- "Success",
2518
- "Business errors",
2519
- "Invalid input",
2520
- "Missing fields",
2521
- "Auth",
2522
2588
  "Other",
2523
2589
  ];
2524
2590
  const METHOD_ORDER = { get: 0, post: 1, put: 2, patch: 3, delete: 4 };
@@ -2688,39 +2754,23 @@
2688
2754
  };
2689
2755
 
2690
2756
  const GROUP_LABEL = {
2691
- "POSITIVE CASES": "Success",
2692
- Success: "Success",
2693
- SUCCESS: "Success",
2694
- "SEMANTIC ERROR CASES": "Business errors",
2695
- "Business errors": "Business errors",
2696
- "INVALID CASES": "Invalid input",
2697
- "Invalid input": "Invalid input",
2698
- "OMITTED CASES": "Invalid input",
2699
- "Missing fields": "Invalid input",
2700
- "SEMANTIC ERROR CASES - AUTH": "Auth",
2701
- Auth: "Auth",
2702
- AUTH: "Auth",
2757
+ "POSITIVE CASES": "Positive cases",
2758
+ "SEMANTIC ERROR CASES": "False positive cases",
2759
+ "INVALID CASES": "Invalid cases",
2760
+ "OMITTED CASES": "Omitted cases",
2761
+ "SEMANTIC ERROR CASES - AUTH": "False positive cases — Auth",
2703
2762
  Other: "Other",
2704
2763
  };
2705
2764
 
2706
- const displayGroup = (group) => (GROUP_LABEL[group] || group || "Other").toUpperCase();
2707
- const groupTone = (label) => {
2708
- const upper = String(label).toUpperCase();
2709
- if (upper.includes("SUCCESS") || upper.includes("POSITIVE")) return "ok";
2710
- if (upper.includes("ERROR") || upper.includes("INVALID") || upper.includes("AUTH") || upper.includes("BUSINESS")) return "err";
2711
- return "";
2712
- };
2765
+ const displayGroup = (group) => GROUP_LABEL[group] || group || "Other";
2766
+ const groupTone = (label) => (String(label).toLowerCase() === "positive cases" ? "ok" : "err");
2713
2767
  const statusOk = (status) => Number(status) >= 200 && Number(status) < 300;
2714
2768
 
2715
2769
  const groupedDropdown = (scenarios, selected) => {
2716
2770
  const { groups, order } = groupScenarios(scenarios);
2717
2771
  const current = scenarios[selected];
2718
2772
  const q = exampleQuery.trim().toLowerCase();
2719
- const kind = current
2720
- ? displayGroup(current.group)
2721
- .toLowerCase()
2722
- .replace(/\b\w/g, (ch) => ch.toUpperCase())
2723
- : "";
2773
+ const kind = current ? displayGroup(current.group) : "";
2724
2774
  const ok = current ? statusOk(current.status) : false;
2725
2775
  return `<div class="dd ${exampleOpen ? "open" : ""}" id="scenario-dd">
2726
2776
  <button type="button" class="dd-toggle" id="scenario-toggle">
@@ -2761,6 +2811,30 @@
2761
2811
  const apiVersions = [...new Set(ops.map((item) => treePathSegments(item)[0]).filter(Boolean))];
2762
2812
  let activeVersion = apiVersions[0] || "";
2763
2813
  const expandedFolders = new Set(apiVersions.map((version) => "/" + version));
2814
+ const expandedExampleOps = new Set();
2815
+
2816
+ const scenarioNavLabel = (scenario) => {
2817
+ const status = scenario.status != null ? String(scenario.status) : "";
2818
+ const name = scenario.name || "example";
2819
+ return status ? status + " " + name : name;
2820
+ };
2821
+
2822
+ const renderNavExamples = (item) => {
2823
+ const { groups, order } = groupScenarios(item.scenarios);
2824
+ return `<div class="nav-examples">${order
2825
+ .map(
2826
+ (group) => `<div class="nav-ex-group">
2827
+ <div class="nav-ex-group-label"><span>${escapeHtml(displayGroup(group))}</span><span class="nav-ex-count">${groups[group].length}</span></div>
2828
+ ${groups[group]
2829
+ .map(
2830
+ ({ scenario, index }) =>
2831
+ `<button type="button" class="nav-example ${item.id === currentId && index === scenarioIndex ? "on" : ""}" data-id="${escapeAttr(item.id)}" data-scenario="${index}" title="${escapeAttr(scenarioNavLabel(scenario))}">${escapeHtml(scenarioNavLabel(scenario))}</button>`,
2832
+ )
2833
+ .join("")}
2834
+ </div>`,
2835
+ )
2836
+ .join("")}</div>`;
2837
+ };
2764
2838
 
2765
2839
  const kv = (label, value) => {
2766
2840
  if (value === undefined || value === "") return "";
@@ -2813,15 +2887,21 @@
2813
2887
  const opsHtml = [...node.ops]
2814
2888
  .sort((left, right) => (METHOD_ORDER[left.method] ?? 99) - (METHOD_ORDER[right.method] ?? 99))
2815
2889
  .map((item) => {
2816
- const exampleCount = Array.isArray(item.scenarios) ? item.scenarios.length : 0;
2817
- return `<div class="nav-op ${item.id === currentId ? "active" : ""}" data-op-id="${escapeAttr(item.id)}">
2890
+ const hasExamples = Array.isArray(item.scenarios) && item.scenarios.length > 0;
2891
+ const examplesOpen = expandedExampleOps.has(item.id);
2892
+ const exampleCount = hasExamples ? item.scenarios.length : 0;
2893
+ return `<div class="nav-op ${item.id === currentId ? "active" : ""} ${examplesOpen ? "examples-open" : ""}" data-op-id="${escapeAttr(item.id)}">
2818
2894
  <div class="nav-op-row">
2819
2895
  <button type="button" class="nav-item" data-id="${escapeAttr(item.id)}" title="${escapeAttr(item.path)}">
2820
2896
  <span class="method ${item.method}">${item.method}</span>
2821
2897
  <span class="nav-title">${escapeAttr(item.title)}</span>
2822
2898
  </button>
2823
- ${exampleCount ? `<span class="nav-ex-total" title="${exampleCount} examples">${exampleCount}</span>` : ""}
2899
+ ${hasExamples ? `<span class="nav-ex-total" title="${exampleCount} examples">${exampleCount}</span>` : ""}
2900
+ <button type="button" class="nav-expand" data-expand-id="${escapeAttr(item.id)}" title="Examples" aria-label="Toggle examples" aria-expanded="${examplesOpen ? "true" : "false"}" ${hasExamples ? "" : "disabled"}>
2901
+ <span class="chev"></span>
2902
+ </button>
2824
2903
  </div>
2904
+ ${hasExamples ? renderNavExamples(item) : ""}
2825
2905
  </div>`;
2826
2906
  })
2827
2907
  .join("");
@@ -2880,6 +2960,40 @@
2880
2960
  nav.querySelectorAll(".nav-item").forEach((button) => {
2881
2961
  button.onclick = () => select(button.dataset.id);
2882
2962
  });
2963
+ nav.querySelectorAll(".nav-expand").forEach((button) => {
2964
+ button.onclick = (event) => {
2965
+ event.stopPropagation();
2966
+ if (button.disabled) return;
2967
+ const opId = button.dataset.expandId;
2968
+ if (expandedExampleOps.has(opId)) expandedExampleOps.delete(opId);
2969
+ else expandedExampleOps.add(opId);
2970
+ const wrap = button.closest(".nav-op");
2971
+ if (wrap) {
2972
+ wrap.classList.toggle("examples-open", expandedExampleOps.has(opId));
2973
+ button.setAttribute("aria-expanded", expandedExampleOps.has(opId) ? "true" : "false");
2974
+ }
2975
+ };
2976
+ });
2977
+ nav.querySelectorAll(".nav-ex-total").forEach((badge) => {
2978
+ badge.onclick = (event) => {
2979
+ event.stopPropagation();
2980
+ const wrap = badge.closest(".nav-op");
2981
+ const opId = wrap && wrap.dataset.opId;
2982
+ if (!opId) return;
2983
+ if (expandedExampleOps.has(opId)) expandedExampleOps.delete(opId);
2984
+ else expandedExampleOps.add(opId);
2985
+ renderNav();
2986
+ };
2987
+ });
2988
+ nav.querySelectorAll(".nav-example").forEach((button) => {
2989
+ button.onclick = (event) => {
2990
+ event.stopPropagation();
2991
+ const opId = button.dataset.id;
2992
+ const index = Number(button.dataset.scenario);
2993
+ expandedExampleOps.add(opId);
2994
+ select(opId, Number.isFinite(index) ? index : 0);
2995
+ };
2996
+ });
2883
2997
  nav.querySelectorAll(".tree-folder-toggle").forEach((button) => {
2884
2998
  button.onclick = (event) => {
2885
2999
  event.stopPropagation();
@@ -3265,6 +3379,7 @@
3265
3379
  syncHeaderGroupForOp(selected.op);
3266
3380
  const version = treePathSegments(selected)[0];
3267
3381
  if (version) activeVersion = version;
3382
+ expandedExampleOps.add(id);
3268
3383
  }
3269
3384
  renderNav();
3270
3385
  renderMain();
@@ -122,7 +122,10 @@ function serveApiDocs(options = {}) {
122
122
  }
123
123
  if (url.pathname === '/' || url.pathname === docsBase || url.pathname === `${docsBase}/`) {
124
124
  if (!(0, fs_1.existsSync)(htmlPath)) {
125
- send(res, 404, 'openapi.html not found. Run `daxta build` first.');
125
+ send(res, 200, (0, paths_1.readEmptyDocsHtml)(), {
126
+ 'content-type': 'text/html; charset=utf-8',
127
+ 'cache-control': 'no-store',
128
+ });
126
129
  return;
127
130
  }
128
131
  send(res, 200, (0, fs_1.readFileSync)(htmlPath), {
@@ -175,8 +175,9 @@ function apiDocsHandler(options = {}) {
175
175
  }
176
176
  const htmlPath = (0, paths_1.getHtmlPath)();
177
177
  if (!(0, fs_1.existsSync)(htmlPath)) {
178
- write(res, 404, 'openapi.html not found. Run integration tests or `daxta build` first.', {
179
- 'content-type': 'text/plain; charset=utf-8',
178
+ write(res, 200, (0, paths_1.readEmptyDocsHtml)(), {
179
+ 'content-type': 'text/html; charset=utf-8',
180
+ 'cache-control': 'no-store',
180
181
  });
181
182
  return;
182
183
  }
@@ -5,5 +5,7 @@ export declare function getHitsJsonPath(): string;
5
5
  /** Try-it env/headers — outside outDir so rebuild does not wipe it. */
6
6
  export declare function getViewerStorePath(): string;
7
7
  export declare function getViewerAssetPath(): string;
8
+ export declare function getEmptyViewerAssetPath(): string;
9
+ export declare function readEmptyDocsHtml(): Buffer;
8
10
  export declare function getFaviconAssetPath(): string;
9
11
  export declare function getDocsBasePath(): string;
@@ -39,8 +39,11 @@ exports.getSpecJsonPath = getSpecJsonPath;
39
39
  exports.getHitsJsonPath = getHitsJsonPath;
40
40
  exports.getViewerStorePath = getViewerStorePath;
41
41
  exports.getViewerAssetPath = getViewerAssetPath;
42
+ exports.getEmptyViewerAssetPath = getEmptyViewerAssetPath;
43
+ exports.readEmptyDocsHtml = readEmptyDocsHtml;
42
44
  exports.getFaviconAssetPath = getFaviconAssetPath;
43
45
  exports.getDocsBasePath = getDocsBasePath;
46
+ const fs_1 = require("fs");
44
47
  const path = __importStar(require("path"));
45
48
  const config_1 = require("../config");
46
49
  function getOutDir() {
@@ -62,6 +65,20 @@ function getViewerStorePath() {
62
65
  function getViewerAssetPath() {
63
66
  return path.join(__dirname, '..', '..', 'assets', 'viewer.html');
64
67
  }
68
+ function getEmptyViewerAssetPath() {
69
+ return path.join(__dirname, '..', '..', 'assets', 'empty.html');
70
+ }
71
+ const EMPTY_DOCS_FALLBACK = `<!doctype html><html lang="en"><head><meta charset="utf-8"/><title>Notary</title></head><body style="font:13px/1.45 system-ui;background:#fafafa;color:#111;margin:0;padding:48px 24px">
72
+ <p style="font:600 10px/1 ui-monospace,monospace;letter-spacing:.08em;text-transform:uppercase;color:#666">Waiting</p>
73
+ <h1 style="font-size:22px;letter-spacing:-.04em">No documentation yet</h1>
74
+ <p>Run your integration tests, then refresh this page.</p>
75
+ </body></html>`;
76
+ function readEmptyDocsHtml() {
77
+ const file = getEmptyViewerAssetPath();
78
+ if ((0, fs_1.existsSync)(file))
79
+ return (0, fs_1.readFileSync)(file);
80
+ return Buffer.from(EMPTY_DOCS_FALLBACK);
81
+ }
65
82
  function getFaviconAssetPath() {
66
83
  return path.join(__dirname, '..', '..', 'assets', 'favicon.png');
67
84
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@t0.labs/daxta",
3
- "version": "0.4.22",
3
+ "version": "0.4.23",
4
4
  "description": "DAxTA \u2014 docs from Nest integration traffic + DTO field CLI / Try-it",
5
5
  "license": "MIT",
6
6
  "repository": {