@t0.labs/daxta 0.4.24 → 0.5.1
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/README.md +139 -91
- package/assets/empty.html +6 -5
- package/assets/example.html +237 -246
- package/assets/favicon.png +0 -0
- package/assets/favicon.svg +16 -0
- package/assets/logo.png +0 -0
- package/assets/viewer.html +164 -113
- package/dist/build/build-spec.d.ts +3 -1
- package/dist/build/build-spec.js +11 -6
- package/dist/cli/install.js +16 -13
- package/dist/cli/main.js +15 -15
- package/dist/cli/migrate.js +2 -2
- package/dist/cli/titles.js +3 -3
- package/dist/cli/tree.d.ts +1 -1
- package/dist/cli/tree.js +4 -4
- package/dist/cli/ui.js +1 -1
- package/dist/cli/uninstall.js +16 -6
- package/dist/config.d.ts +3 -3
- package/dist/config.js +4 -4
- package/dist/index.d.ts +2 -2
- package/dist/index.js +4 -1
- package/dist/jest/global-teardown.d.ts +2 -2
- package/dist/jest/global-teardown.js +3 -3
- package/dist/jest/reporter.d.ts +1 -1
- package/dist/jest/reporter.js +6 -7
- package/dist/serve/index.d.ts +2 -2
- package/dist/serve/index.js +8 -6
- package/dist/serve/middleware.d.ts +4 -4
- package/dist/serve/middleware.js +6 -6
- package/dist/serve/paths.d.ts +8 -0
- package/dist/serve/paths.js +22 -4
- package/package.json +2 -2
package/assets/favicon.png
CHANGED
|
Binary file
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32">
|
|
2
|
+
<style>
|
|
3
|
+
.bg { fill: #ffffff; }
|
|
4
|
+
.fg { fill: #111111; }
|
|
5
|
+
.ring { fill: none; stroke: #111111; stroke-width: 1.25; }
|
|
6
|
+
@media (prefers-color-scheme: dark) {
|
|
7
|
+
.bg { fill: #111111; }
|
|
8
|
+
.fg { fill: #ffffff; }
|
|
9
|
+
.ring { stroke: #ffffff; }
|
|
10
|
+
}
|
|
11
|
+
</style>
|
|
12
|
+
<rect class="bg" width="32" height="32" rx="7"/>
|
|
13
|
+
<rect class="ring" x="0.6" y="0.6" width="30.8" height="30.8" rx="6.4"/>
|
|
14
|
+
<path class="fg" d="M4.2 5.2 14.2 8.8v4.2A4.2 4.2 0 0 1 14.2 21.4v4L4.2 26.8Z"/>
|
|
15
|
+
<path class="fg" d="M27.8 5.2 17.8 8.8v4.2A4.2 4.2 0 0 0 17.8 21.4v4L27.8 26.8Z"/>
|
|
16
|
+
</svg>
|
package/assets/logo.png
ADDED
|
Binary file
|
package/assets/viewer.html
CHANGED
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
<head>
|
|
4
4
|
<meta charset="utf-8" />
|
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
6
|
-
<title>
|
|
7
|
-
<link rel="icon"
|
|
6
|
+
<title>API Documentation</title>
|
|
7
|
+
<link rel="icon" href="__FAVICON_DATA_URI__" />
|
|
8
8
|
<link rel="apple-touch-icon" href="__FAVICON_DATA_URI__" />
|
|
9
9
|
<link rel="preconnect" href="https://fonts.googleapis.com" />
|
|
10
10
|
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
|
|
@@ -23,9 +23,10 @@
|
|
|
23
23
|
--stone: #666666;
|
|
24
24
|
--charcoal: #333333;
|
|
25
25
|
--obsidian: #111111;
|
|
26
|
-
--accent: #
|
|
27
|
-
--ok: #
|
|
28
|
-
--ok-bg: #
|
|
26
|
+
--accent: #6f7d3c;
|
|
27
|
+
--ok: #15803d;
|
|
28
|
+
--ok-bg: #e8f8ee;
|
|
29
|
+
--get: #16a34a;
|
|
29
30
|
--err: #b42318;
|
|
30
31
|
--err-bg: #fbeaea;
|
|
31
32
|
--sans: Geist, Inter, ui-sans-serif, system-ui, sans-serif;
|
|
@@ -47,10 +48,10 @@
|
|
|
47
48
|
.topnav {
|
|
48
49
|
height: 44px;
|
|
49
50
|
display: grid;
|
|
50
|
-
grid-template-columns: 1fr minmax(
|
|
51
|
+
grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr) minmax(0, 1fr);
|
|
51
52
|
align-items: center;
|
|
52
|
-
gap:
|
|
53
|
-
padding: 0
|
|
53
|
+
gap: 12px;
|
|
54
|
+
padding: 0 14px;
|
|
54
55
|
background: var(--nav);
|
|
55
56
|
border-bottom: 1px solid var(--hairline);
|
|
56
57
|
position: sticky;
|
|
@@ -61,6 +62,23 @@
|
|
|
61
62
|
.brand-wrap { display: flex; align-items: center; gap: 10px; min-width: 0; justify-self: start; }
|
|
62
63
|
.workspace { display: none; }
|
|
63
64
|
.brand { font-size: 13px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--charcoal); }
|
|
65
|
+
.ep-nav {
|
|
66
|
+
justify-self: center;
|
|
67
|
+
display: flex;
|
|
68
|
+
align-items: center;
|
|
69
|
+
gap: 8px;
|
|
70
|
+
min-width: 0;
|
|
71
|
+
max-width: 100%;
|
|
72
|
+
}
|
|
73
|
+
.ep-name {
|
|
74
|
+
font-size: 14px;
|
|
75
|
+
font-weight: 600;
|
|
76
|
+
letter-spacing: -0.02em;
|
|
77
|
+
white-space: nowrap;
|
|
78
|
+
overflow: hidden;
|
|
79
|
+
text-overflow: ellipsis;
|
|
80
|
+
color: var(--obsidian);
|
|
81
|
+
}
|
|
64
82
|
.ver-select {
|
|
65
83
|
height: 24px;
|
|
66
84
|
border: 1px solid var(--hairline);
|
|
@@ -107,10 +125,11 @@
|
|
|
107
125
|
transform: translateX(-50%) translateY(0);
|
|
108
126
|
}
|
|
109
127
|
.search-wrap {
|
|
110
|
-
justify-self: center;
|
|
111
128
|
position: relative;
|
|
112
129
|
width: 100%;
|
|
130
|
+
flex: none;
|
|
113
131
|
z-index: 30;
|
|
132
|
+
margin-bottom: 8px;
|
|
114
133
|
}
|
|
115
134
|
.search {
|
|
116
135
|
width: 100%;
|
|
@@ -119,8 +138,8 @@
|
|
|
119
138
|
border-radius: var(--radius);
|
|
120
139
|
box-shadow: none;
|
|
121
140
|
background: var(--white);
|
|
122
|
-
padding: 0
|
|
123
|
-
font-size:
|
|
141
|
+
padding: 0 28px 0 10px;
|
|
142
|
+
font-size: 12px;
|
|
124
143
|
}
|
|
125
144
|
.search-kbd {
|
|
126
145
|
position: absolute;
|
|
@@ -355,13 +374,26 @@
|
|
|
355
374
|
.app {
|
|
356
375
|
display: grid;
|
|
357
376
|
grid-template-columns: var(--sidebar-w, 320px) 6px minmax(0, 1fr);
|
|
377
|
+
grid-template-rows: minmax(0, 1fr) auto;
|
|
358
378
|
height: calc(100vh - 44px);
|
|
359
379
|
}
|
|
360
380
|
.app.sidebar-collapsed {
|
|
361
381
|
grid-template-columns: 0 28px minmax(0, 1fr);
|
|
362
382
|
}
|
|
363
|
-
.sidebar
|
|
364
|
-
|
|
383
|
+
.sidebar {
|
|
384
|
+
grid-row: 1 / -1;
|
|
385
|
+
}
|
|
386
|
+
.sidebar-resizer {
|
|
387
|
+
grid-row: 1 / -1;
|
|
388
|
+
}
|
|
389
|
+
.workbench {
|
|
390
|
+
grid-column: 3;
|
|
391
|
+
grid-row: 1;
|
|
392
|
+
min-height: 0;
|
|
393
|
+
overflow: auto;
|
|
394
|
+
padding: 14px 18px 16px;
|
|
395
|
+
background: var(--paper);
|
|
396
|
+
}
|
|
365
397
|
.sidebar {
|
|
366
398
|
position: relative;
|
|
367
399
|
min-width: 0;
|
|
@@ -394,14 +426,13 @@
|
|
|
394
426
|
.tree-scroll { flex: 1; min-height: 0; overflow: auto; }
|
|
395
427
|
.nav-foot {
|
|
396
428
|
flex: none;
|
|
397
|
-
margin-top:
|
|
398
|
-
padding: 8px;
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
429
|
+
margin-top: 8px;
|
|
430
|
+
padding: 8px 2px 0;
|
|
431
|
+
display: flex;
|
|
432
|
+
justify-content: space-between;
|
|
433
|
+
gap: 8px;
|
|
402
434
|
font-size: 11px;
|
|
403
|
-
color: var(--
|
|
404
|
-
line-height: 1.35;
|
|
435
|
+
color: var(--smoke);
|
|
405
436
|
}
|
|
406
437
|
.sidebar-resizer {
|
|
407
438
|
position: relative;
|
|
@@ -757,59 +788,62 @@
|
|
|
757
788
|
letter-spacing: 0.04em;
|
|
758
789
|
text-transform: uppercase;
|
|
759
790
|
box-shadow: none;
|
|
760
|
-
|
|
761
|
-
|
|
791
|
+
border: 0;
|
|
792
|
+
background: #e4e4e7;
|
|
793
|
+
color: #27272a;
|
|
794
|
+
}
|
|
795
|
+
.method.get { background: #f4f4f5; color: #52525b; }
|
|
796
|
+
.method.patch { background: #d4d4d8; color: #18181b; }
|
|
797
|
+
.method.put { background: #a1a1aa; color: #fafafa; }
|
|
798
|
+
.method.post { background: #3f3f46; color: #fafafa; }
|
|
799
|
+
.method.delete { background: #111111; color: #ffffff; }
|
|
800
|
+
.schema-block {
|
|
801
|
+
padding: 10px 12px 12px;
|
|
802
|
+
border-top: 1px solid var(--hairline);
|
|
762
803
|
}
|
|
763
|
-
.
|
|
764
|
-
.method.delete { background: var(--white); color: var(--charcoal); border: 1px solid var(--hairline); }
|
|
804
|
+
.schema-block .meta-label { margin-bottom: 8px; display: block; }
|
|
765
805
|
|
|
766
|
-
.
|
|
767
|
-
.
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
.meta-line {
|
|
776
|
-
display: flex;
|
|
777
|
-
align-items: center;
|
|
778
|
-
gap: 8px;
|
|
779
|
-
color: var(--stone);
|
|
780
|
-
font: 12px/1.4 var(--mono);
|
|
781
|
-
margin: 8px 0 0;
|
|
782
|
-
}
|
|
783
|
-
.open-editor {
|
|
784
|
-
height: 28px;
|
|
785
|
-
font-size: 12px;
|
|
806
|
+
.ex-block { margin: 0; position: relative; }
|
|
807
|
+
.ex-dock {
|
|
808
|
+
grid-column: 3;
|
|
809
|
+
grid-row: 2;
|
|
810
|
+
position: relative;
|
|
811
|
+
z-index: 100;
|
|
812
|
+
padding: 8px 16px 10px;
|
|
813
|
+
background: var(--white);
|
|
814
|
+
border-top: 1px solid var(--hairline);
|
|
786
815
|
}
|
|
787
|
-
|
|
788
|
-
.ex-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
text-transform: uppercase;
|
|
793
|
-
color: var(--stone);
|
|
794
|
-
margin-bottom: 6px;
|
|
816
|
+
.ex-dock:empty { display: none; }
|
|
817
|
+
.ex-dock .dd-menu {
|
|
818
|
+
top: auto;
|
|
819
|
+
bottom: calc(100% + 4px);
|
|
820
|
+
max-height: min(380px, 45vh);
|
|
795
821
|
}
|
|
796
822
|
.dd { position: relative; width: 100%; }
|
|
797
823
|
.dd-toggle {
|
|
798
824
|
width: 100%;
|
|
799
|
-
|
|
825
|
+
height: 28px;
|
|
826
|
+
min-height: 28px;
|
|
800
827
|
border: 1px solid var(--hairline);
|
|
801
828
|
border-radius: var(--radius);
|
|
802
829
|
box-shadow: none;
|
|
803
830
|
background: var(--white);
|
|
804
|
-
padding:
|
|
831
|
+
padding: 0 28px 0 8px;
|
|
805
832
|
text-align: left;
|
|
806
833
|
cursor: pointer;
|
|
807
|
-
font-size:
|
|
808
|
-
line-height: 1
|
|
834
|
+
font-size: 12px;
|
|
835
|
+
line-height: 1;
|
|
809
836
|
position: relative;
|
|
810
837
|
display: flex;
|
|
811
838
|
align-items: center;
|
|
812
|
-
gap:
|
|
839
|
+
gap: 8px;
|
|
840
|
+
}
|
|
841
|
+
.dd-kicker {
|
|
842
|
+
font: 600 10px/1 var(--mono);
|
|
843
|
+
letter-spacing: 0.06em;
|
|
844
|
+
text-transform: uppercase;
|
|
845
|
+
color: var(--stone);
|
|
846
|
+
flex: none;
|
|
813
847
|
}
|
|
814
848
|
.dd-status {
|
|
815
849
|
font: 600 11px/1 var(--mono);
|
|
@@ -831,10 +865,10 @@
|
|
|
831
865
|
.dd-toggle::after {
|
|
832
866
|
content: "";
|
|
833
867
|
position: absolute;
|
|
834
|
-
right:
|
|
868
|
+
right: 10px;
|
|
835
869
|
top: 50%;
|
|
836
|
-
width:
|
|
837
|
-
height:
|
|
870
|
+
width: 5px;
|
|
871
|
+
height: 5px;
|
|
838
872
|
border-right: 1px solid var(--obsidian);
|
|
839
873
|
border-bottom: 1px solid var(--obsidian);
|
|
840
874
|
transform: translateY(-70%) rotate(45deg);
|
|
@@ -946,6 +980,7 @@
|
|
|
946
980
|
color: var(--charcoal);
|
|
947
981
|
white-space: nowrap;
|
|
948
982
|
font-size: 12px;
|
|
983
|
+
text-decoration: none;
|
|
949
984
|
}
|
|
950
985
|
.btn:hover { color: var(--obsidian); }
|
|
951
986
|
.btn.sm { height: 32px; padding: 0 10px; font-size: 12px; }
|
|
@@ -1110,7 +1145,7 @@
|
|
|
1110
1145
|
font: 12px/1.5 var(--mono);
|
|
1111
1146
|
}
|
|
1112
1147
|
.k { color: #111111; }
|
|
1113
|
-
.s { color:
|
|
1148
|
+
.s { color: var(--accent); }
|
|
1114
1149
|
.n { color: #111111; }
|
|
1115
1150
|
.p { color: #666666; }
|
|
1116
1151
|
.empty { color: var(--stone); font-size: 13px; padding: 14px 16px; }
|
|
@@ -1184,12 +1219,16 @@
|
|
|
1184
1219
|
@media (max-width: 960px) {
|
|
1185
1220
|
.app {
|
|
1186
1221
|
grid-template-columns: 1fr;
|
|
1222
|
+
grid-template-rows: auto 1fr auto;
|
|
1187
1223
|
height: auto;
|
|
1224
|
+
min-height: calc(100vh - 44px);
|
|
1188
1225
|
}
|
|
1189
1226
|
.app.sidebar-collapsed {
|
|
1190
1227
|
grid-template-columns: 1fr;
|
|
1191
1228
|
}
|
|
1229
|
+
.sidebar, .workbench, .ex-dock { grid-column: 1; grid-row: auto; }
|
|
1192
1230
|
.sidebar { max-height: 40vh; opacity: 1 !important; pointer-events: auto !important; padding: 16px 12px 24px !important; }
|
|
1231
|
+
.ex-dock { position: sticky; bottom: 0; }
|
|
1193
1232
|
.sidebar-resizer { display: none; }
|
|
1194
1233
|
.pair, .schemas { grid-template-columns: 1fr; }
|
|
1195
1234
|
.search-wrap { width: min(280px, 70vw); }
|
|
@@ -1202,10 +1241,8 @@
|
|
|
1202
1241
|
<div class="brand" id="brand">API</div>
|
|
1203
1242
|
<select class="ver-select" id="ver-select" aria-label="API version"></select>
|
|
1204
1243
|
</div>
|
|
1205
|
-
<div class="
|
|
1206
|
-
<
|
|
1207
|
-
<span class="search-kbd">⌘K</span>
|
|
1208
|
-
<div class="search-panel" id="search-panel" role="listbox"></div>
|
|
1244
|
+
<div class="ep-nav" id="ep-nav">
|
|
1245
|
+
<span class="ep-name" id="ep-name"></span>
|
|
1209
1246
|
</div>
|
|
1210
1247
|
<div class="nav-tools">
|
|
1211
1248
|
<button class="btn icon" id="export-openapi" type="button" data-tip="Export" aria-label="Export">
|
|
@@ -1244,9 +1281,18 @@
|
|
|
1244
1281
|
</div>
|
|
1245
1282
|
</div>
|
|
1246
1283
|
<div class="app" id="app">
|
|
1247
|
-
<aside class="sidebar"
|
|
1284
|
+
<aside class="sidebar">
|
|
1285
|
+
<div class="search-wrap" id="search-wrap">
|
|
1286
|
+
<input class="search" id="search" placeholder="Search endpoints..." autocomplete="off" spellcheck="false" />
|
|
1287
|
+
<span class="search-kbd">/</span>
|
|
1288
|
+
<div class="search-panel" id="search-panel" role="listbox"></div>
|
|
1289
|
+
</div>
|
|
1290
|
+
<div class="tree-scroll" id="nav"></div>
|
|
1291
|
+
<div class="nav-foot"><span>Generated by DAxTA</span><span id="nav-version"></span></div>
|
|
1292
|
+
</aside>
|
|
1248
1293
|
<button type="button" class="sidebar-resizer" id="sidebar-resizer" aria-label="Resize sidebar" title="Drag to resize · double-click to collapse"></button>
|
|
1249
1294
|
<main class="workbench" id="main"></main>
|
|
1295
|
+
<div class="ex-dock" id="ex-dock"></div>
|
|
1250
1296
|
</div>
|
|
1251
1297
|
<script>
|
|
1252
1298
|
window.__SPEC__ = __SPEC_JSON__;
|
|
@@ -1256,7 +1302,7 @@
|
|
|
1256
1302
|
const viewer = spec["x-viewer"] || {};
|
|
1257
1303
|
const workspace = (spec.info && spec.info["x-workspace"]) || viewer.workspace || "";
|
|
1258
1304
|
const defaultBaseUrlFromSpec = String((viewer.baseUrl || (spec.servers && spec.servers[0] && spec.servers[0].url) || "http://localhost:3000")).replace(/\/$/, "");
|
|
1259
|
-
const docsPathSuffix = String(viewer.docsPath || "/docs").replace(/\/$/, "") || "/docs";
|
|
1305
|
+
const docsPathSuffix = String(viewer.docsPath || "/api-docs").replace(/\/$/, "") || "/api-docs";
|
|
1260
1306
|
|
|
1261
1307
|
const inferBaseUrlFromLocation = () => {
|
|
1262
1308
|
if (typeof location === "undefined") return null;
|
|
@@ -1276,9 +1322,9 @@
|
|
|
1276
1322
|
};
|
|
1277
1323
|
|
|
1278
1324
|
const locationBaseUrl = inferBaseUrlFromLocation();
|
|
1279
|
-
// Prefer the URL that is serving the viewer (strip
|
|
1325
|
+
// Prefer the URL that is serving the viewer (strip the docs path), else fall back to spec.
|
|
1280
1326
|
const defaultBaseUrl = locationBaseUrl || defaultBaseUrlFromSpec;
|
|
1281
|
-
const title = (spec.info && spec.info.title) || "API
|
|
1327
|
+
const title = (spec.info && spec.info.title) || "API Documentation";
|
|
1282
1328
|
const STORE_KEY = "openapi-docs-env:" + (workspace || "default");
|
|
1283
1329
|
const SIDEBAR_STORE_KEY = "openapi-docs-sidebar:" + (workspace || "default");
|
|
1284
1330
|
const SIDEBAR_MIN = 200;
|
|
@@ -2010,8 +2056,12 @@
|
|
|
2010
2056
|
};
|
|
2011
2057
|
};
|
|
2012
2058
|
|
|
2013
|
-
document.title =
|
|
2014
|
-
document.getElementById("brand")
|
|
2059
|
+
document.title = title || "API Documentation";
|
|
2060
|
+
const brandEl = document.getElementById("brand");
|
|
2061
|
+
if (brandEl) brandEl.textContent = title;
|
|
2062
|
+
const specVersion = (spec.info && spec.info.version) || "";
|
|
2063
|
+
const navVersion = document.getElementById("nav-version");
|
|
2064
|
+
if (navVersion) navVersion.textContent = specVersion ? (specVersion.startsWith("v") ? specVersion : "v" + specVersion) : "";
|
|
2015
2065
|
|
|
2016
2066
|
const envWrap = document.getElementById("env-wrap");
|
|
2017
2067
|
document.getElementById("env-trigger").addEventListener("click", (event) => {
|
|
@@ -2260,7 +2310,7 @@
|
|
|
2260
2310
|
}
|
|
2261
2311
|
return {
|
|
2262
2312
|
id: typeof crypto !== "undefined" && crypto.randomUUID ? crypto.randomUUID() : String(Date.now()),
|
|
2263
|
-
name: (workspace || title || "
|
|
2313
|
+
name: (workspace || title || "API") + " · " + store.activeEnv,
|
|
2264
2314
|
values,
|
|
2265
2315
|
_postman_variable_scope: "environment",
|
|
2266
2316
|
_postman_exported_at: new Date().toISOString(),
|
|
@@ -2433,8 +2483,8 @@
|
|
|
2433
2483
|
return {
|
|
2434
2484
|
info: {
|
|
2435
2485
|
_postman_id: typeof crypto !== "undefined" && crypto.randomUUID ? crypto.randomUUID() : String(Date.now()),
|
|
2436
|
-
name: (openapi.info && openapi.info.title) || workspace || title || "
|
|
2437
|
-
description: (openapi.info && openapi.info.description) || "Exported from
|
|
2486
|
+
name: (openapi.info && openapi.info.title) || workspace || title || "API",
|
|
2487
|
+
description: (openapi.info && openapi.info.description) || "Exported from API docs with named examples",
|
|
2438
2488
|
schema: "https://schema.getpostman.com/json/collection/v2.1.0/collection.json",
|
|
2439
2489
|
},
|
|
2440
2490
|
item,
|
|
@@ -2750,6 +2800,7 @@
|
|
|
2750
2800
|
const ok = current ? statusOk(current.status) : false;
|
|
2751
2801
|
return `<div class="dd ${exampleOpen ? "open" : ""}" id="scenario-dd">
|
|
2752
2802
|
<button type="button" class="dd-toggle" id="scenario-toggle">
|
|
2803
|
+
<span class="dd-kicker">Example</span>
|
|
2753
2804
|
<span class="dd-status ${ok ? "ok" : "err"}">${escapeHtml(String(current?.status ?? ""))}</span>
|
|
2754
2805
|
<span class="dd-kind">${escapeHtml(kind)}</span>
|
|
2755
2806
|
<span class="dd-toggle-label">${escapeHtml(current?.name || "Example")}</span>
|
|
@@ -2909,6 +2960,7 @@
|
|
|
2909
2960
|
|
|
2910
2961
|
const renderNav = () => {
|
|
2911
2962
|
const nav = document.getElementById("nav");
|
|
2963
|
+
const q = navQuery.trim().toLowerCase();
|
|
2912
2964
|
if (!ops.length) {
|
|
2913
2965
|
nav.innerHTML = `<div class="tree-empty">No endpoints recorded</div>`;
|
|
2914
2966
|
return;
|
|
@@ -2917,22 +2969,7 @@
|
|
|
2917
2969
|
const active = ops.find((item) => item.id === currentId);
|
|
2918
2970
|
if (active) expandPathToItem(active);
|
|
2919
2971
|
}
|
|
2920
|
-
|
|
2921
|
-
nav.innerHTML = `
|
|
2922
|
-
<input class="nav-filter" id="nav-filter" placeholder="Search endpoints..." value="${escapeAttr(navQuery)}" autocomplete="off" spellcheck="false" />
|
|
2923
|
-
<div class="tree-scroll"><div class="tree-root">${renderTreeNode(buildPathTree(visibleOps()), "", q)}</div></div>
|
|
2924
|
-
<div class="nav-foot">Generated by Notary</div>
|
|
2925
|
-
`;
|
|
2926
|
-
const filter = document.getElementById("nav-filter");
|
|
2927
|
-
if (filter) {
|
|
2928
|
-
filter.oninput = (event) => {
|
|
2929
|
-
navQuery = event.target.value;
|
|
2930
|
-
renderNav();
|
|
2931
|
-
document.getElementById("nav-filter")?.focus();
|
|
2932
|
-
const el = document.getElementById("nav-filter");
|
|
2933
|
-
if (el) el.selectionStart = el.selectionEnd = el.value.length;
|
|
2934
|
-
};
|
|
2935
|
-
}
|
|
2972
|
+
nav.innerHTML = `<div class="tree-root">${renderTreeNode(buildPathTree(visibleOps()), "", q)}</div>`;
|
|
2936
2973
|
nav.querySelectorAll(".nav-item").forEach((button) => {
|
|
2937
2974
|
button.onclick = () => select(button.dataset.id);
|
|
2938
2975
|
});
|
|
@@ -3017,7 +3054,11 @@
|
|
|
3017
3054
|
wrap.classList.remove("open");
|
|
3018
3055
|
document.body.classList.remove("searching");
|
|
3019
3056
|
searchActiveIndex = 0;
|
|
3020
|
-
if (clear)
|
|
3057
|
+
if (clear) {
|
|
3058
|
+
input.value = "";
|
|
3059
|
+
navQuery = "";
|
|
3060
|
+
renderNav();
|
|
3061
|
+
}
|
|
3021
3062
|
};
|
|
3022
3063
|
|
|
3023
3064
|
const openSearch = () => {
|
|
@@ -3027,6 +3068,8 @@
|
|
|
3027
3068
|
|
|
3028
3069
|
const renderSearchPanel = (query = "") => {
|
|
3029
3070
|
const q = query.trim().toLowerCase();
|
|
3071
|
+
navQuery = query;
|
|
3072
|
+
renderNav();
|
|
3030
3073
|
const panel = document.getElementById("search-panel");
|
|
3031
3074
|
if (!q) {
|
|
3032
3075
|
closeSearch();
|
|
@@ -3123,25 +3166,23 @@
|
|
|
3123
3166
|
.join("");
|
|
3124
3167
|
};
|
|
3125
3168
|
|
|
3126
|
-
const
|
|
3169
|
+
const schemasInline = (fields, resBody) => {
|
|
3127
3170
|
const requestFields = fields.filter((field) => field.in === "body" || field.in === "path" || field.in === "query" || field.in === "header");
|
|
3128
3171
|
const responseFields = schemaFromValue(resBody);
|
|
3129
|
-
return
|
|
3130
|
-
|
|
3131
|
-
|
|
3132
|
-
|
|
3133
|
-
</section>
|
|
3134
|
-
<section>
|
|
3135
|
-
<h2>Response schema</h2>
|
|
3136
|
-
${schemaRows(responseFields)}
|
|
3137
|
-
</section>
|
|
3138
|
-
</div>`;
|
|
3172
|
+
return {
|
|
3173
|
+
request: `<div class="schema-block"><span class="meta-label">Request schema</span>${schemaRows(requestFields, { showLoc: true })}</div>`,
|
|
3174
|
+
response: `<div class="schema-block"><span class="meta-label">Response schema</span>${schemaRows(responseFields)}</div>`,
|
|
3175
|
+
};
|
|
3139
3176
|
};
|
|
3140
3177
|
|
|
3141
3178
|
const renderMain = () => {
|
|
3142
3179
|
const item = ops.find((entry) => entry.id === currentId);
|
|
3143
3180
|
if (!item) {
|
|
3144
3181
|
document.getElementById("main").innerHTML = `<div class="empty">No operations in this workspace yet.</div>`;
|
|
3182
|
+
const dock = document.getElementById("ex-dock");
|
|
3183
|
+
if (dock) dock.innerHTML = "";
|
|
3184
|
+
const epName = document.getElementById("ep-name");
|
|
3185
|
+
if (epName) epName.textContent = "";
|
|
3145
3186
|
return;
|
|
3146
3187
|
}
|
|
3147
3188
|
if (scenarioIndex >= item.scenarios.length) scenarioIndex = 0;
|
|
@@ -3185,14 +3226,12 @@
|
|
|
3185
3226
|
? `<div class="empty">Empty body</div>`
|
|
3186
3227
|
: jsonBlock(displayBody, resPretty);
|
|
3187
3228
|
|
|
3229
|
+
const schemas = schemasInline(fields, displayEmpty ? undefined : displayBody);
|
|
3230
|
+
const epName = document.getElementById("ep-name");
|
|
3231
|
+
if (epName) epName.textContent = item.title;
|
|
3232
|
+
document.title = item.title + (title ? " · " + title : "");
|
|
3233
|
+
|
|
3188
3234
|
document.getElementById("main").innerHTML = `
|
|
3189
|
-
<div class="ep-head">
|
|
3190
|
-
<div class="ep-head-top">
|
|
3191
|
-
<h1 class="title">${item.title}</h1>
|
|
3192
|
-
</div>
|
|
3193
|
-
<p class="meta-line"><span class="method ${item.method}">${item.method}</span><span>${item.path}</span></p>
|
|
3194
|
-
</div>
|
|
3195
|
-
${item.scenarios.length ? `<div class="ex-block"><div class="ex-kicker">Example</div>${groupedDropdown(item.scenarios, scenarioIndex)}</div>` : ""}
|
|
3196
3235
|
<div class="urlbar">
|
|
3197
3236
|
<div class="url"><span class="method ${item.method}">${item.method}</span><span>${resolvedUrl(item, scenario)}</span></div>
|
|
3198
3237
|
<button class="btn" id="copy-curl" type="button">Copy cURL</button>
|
|
@@ -3215,6 +3254,7 @@
|
|
|
3215
3254
|
${metaBlock("Path", pathParamsHtml)}
|
|
3216
3255
|
${metaBlock("Query", queryHtml)}
|
|
3217
3256
|
${metaBlock("Body", bodyHtml, "", { always: true })}
|
|
3257
|
+
${schemas.request}
|
|
3218
3258
|
</div>
|
|
3219
3259
|
</section>
|
|
3220
3260
|
<section class="card response-card" id="response-card">
|
|
@@ -3233,13 +3273,17 @@
|
|
|
3233
3273
|
<button class="btn sm icon" id="copy-res" type="button" title="Copy body" aria-label="Copy body" ${resCopyText ? "" : "disabled"}>${copyIcon}</button>
|
|
3234
3274
|
</div>
|
|
3235
3275
|
</div>
|
|
3236
|
-
<div class="card-body"
|
|
3276
|
+
<div class="card-body">
|
|
3277
|
+
<div id="response-body">${resHtml}</div>
|
|
3278
|
+
${schemas.response}
|
|
3279
|
+
</div>
|
|
3237
3280
|
</section>
|
|
3238
3281
|
</div>
|
|
3239
|
-
${schemasPanel(fields, displayEmpty ? undefined : displayBody)}
|
|
3240
|
-
<div class="work-foot">Generated by Notary</div>
|
|
3241
3282
|
`;
|
|
3242
3283
|
|
|
3284
|
+
const dock = document.getElementById("ex-dock");
|
|
3285
|
+
if (dock) dock.innerHTML = item.scenarios.length ? groupedDropdown(item.scenarios, scenarioIndex) : "";
|
|
3286
|
+
|
|
3243
3287
|
const scenarioToggle = document.getElementById("scenario-toggle");
|
|
3244
3288
|
if (scenarioToggle) {
|
|
3245
3289
|
const root = document.getElementById("scenario-dd");
|
|
@@ -3336,7 +3380,7 @@
|
|
|
3336
3380
|
body: undefined,
|
|
3337
3381
|
error:
|
|
3338
3382
|
message +
|
|
3339
|
-
"\n\nTip: open docs at the same app port: http://localhost:3000
|
|
3383
|
+
"\n\nTip: open API docs at the same app port: http://localhost:3000" + docsPathSuffix,
|
|
3340
3384
|
};
|
|
3341
3385
|
}
|
|
3342
3386
|
renderMain();
|
|
@@ -3409,6 +3453,13 @@
|
|
|
3409
3453
|
if ((event.metaKey || event.ctrlKey) && event.key.toLowerCase() === "k") {
|
|
3410
3454
|
event.preventDefault();
|
|
3411
3455
|
document.getElementById("search")?.focus();
|
|
3456
|
+
return;
|
|
3457
|
+
}
|
|
3458
|
+
if (event.key === "/" && !event.metaKey && !event.ctrlKey && !event.altKey) {
|
|
3459
|
+
const tag = (event.target && event.target.tagName) || "";
|
|
3460
|
+
if (tag === "INPUT" || tag === "TEXTAREA" || tag === "SELECT" || event.target?.isContentEditable) return;
|
|
3461
|
+
event.preventDefault();
|
|
3462
|
+
document.getElementById("search")?.focus();
|
|
3412
3463
|
}
|
|
3413
3464
|
});
|
|
3414
3465
|
|
|
@@ -24,5 +24,7 @@ export declare function buildDaxtaSpec(options?: {
|
|
|
24
24
|
requireHits?: boolean;
|
|
25
25
|
html?: boolean;
|
|
26
26
|
}): BuildResult;
|
|
27
|
-
/**
|
|
27
|
+
/** Generate API documentation (OpenAPI spec + HTML viewer) from recorded test execution. */
|
|
28
|
+
export declare const generateApiDocs: typeof buildDaxtaSpec;
|
|
29
|
+
/** @deprecated Use `generateApiDocs` */
|
|
28
30
|
export declare const buildOpenApi: typeof buildDaxtaSpec;
|
package/dist/build/build-spec.js
CHANGED
|
@@ -33,7 +33,7 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
33
33
|
};
|
|
34
34
|
})();
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.buildOpenApi = void 0;
|
|
36
|
+
exports.buildOpenApi = exports.generateApiDocs = void 0;
|
|
37
37
|
exports.loadHits = loadHits;
|
|
38
38
|
exports.buildDaxtaSpec = buildDaxtaSpec;
|
|
39
39
|
const fs_1 = require("fs");
|
|
@@ -75,7 +75,7 @@ function readPackageMeta() {
|
|
|
75
75
|
};
|
|
76
76
|
}
|
|
77
77
|
catch {
|
|
78
|
-
return { title: 'API', version: '0.0.0', description: 'Generated from
|
|
78
|
+
return { title: 'API', version: '0.0.0', description: 'Generated from observed test execution.' };
|
|
79
79
|
}
|
|
80
80
|
}
|
|
81
81
|
function specInfo() {
|
|
@@ -720,8 +720,11 @@ function countOperations(spec) {
|
|
|
720
720
|
}
|
|
721
721
|
function toStandaloneHtml(spec) {
|
|
722
722
|
const template = (0, fs_1.readFileSync)((0, paths_1.getViewerAssetPath)(), 'utf8');
|
|
723
|
-
const
|
|
724
|
-
|
|
723
|
+
const faviconPath = (0, paths_1.getFaviconAssetPath)();
|
|
724
|
+
const faviconUri = (0, fs_1.existsSync)(faviconPath)
|
|
725
|
+
? faviconPath.endsWith('.svg')
|
|
726
|
+
? `data:image/svg+xml;base64,${(0, fs_1.readFileSync)(faviconPath).toString('base64')}`
|
|
727
|
+
: `data:image/png;base64,${(0, fs_1.readFileSync)(faviconPath).toString('base64')}`
|
|
725
728
|
: '';
|
|
726
729
|
return template
|
|
727
730
|
.replace('__SPEC_JSON__', JSON.stringify(spec).replace(/</g, '\\u003c'))
|
|
@@ -804,7 +807,7 @@ function buildDaxtaSpec(options = {}) {
|
|
|
804
807
|
};
|
|
805
808
|
if (!options.silent) {
|
|
806
809
|
if (!changed) {
|
|
807
|
-
console.log(`
|
|
810
|
+
console.log(`API spec unchanged (${hits.length} hits, ${operations} operations — ${unchanged} kept as-is)`);
|
|
808
811
|
}
|
|
809
812
|
else {
|
|
810
813
|
console.log(`Wrote ${(0, paths_1.getSpecJsonPath)()} from ${hits.length} hits (${operations} operations — ${updated} updated, ${unchanged} unchanged)`);
|
|
@@ -813,5 +816,7 @@ function buildDaxtaSpec(options = {}) {
|
|
|
813
816
|
}
|
|
814
817
|
return result;
|
|
815
818
|
}
|
|
816
|
-
/**
|
|
819
|
+
/** Generate API documentation (OpenAPI spec + HTML viewer) from recorded test execution. */
|
|
820
|
+
exports.generateApiDocs = buildDaxtaSpec;
|
|
821
|
+
/** @deprecated Use `generateApiDocs` */
|
|
817
822
|
exports.buildOpenApi = buildDaxtaSpec;
|