@t0.labs/daxta 0.3.7 → 0.4.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.
|
@@ -0,0 +1,1896 @@
|
|
|
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>DAxTA</title>
|
|
7
|
+
<link rel="icon" type="image/png" href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAIAAAAlC+aJAAAAAXNSR0IArs4c6QAAAERlWElmTU0AKgAAAAgAAYdpAAQAAAABAAAAGgAAAAAAA6ABAAMAAAABAAEAAKACAAQAAAABAAAAQKADAAQAAAABAAAAQAAAAABGUUKwAAAKrElEQVRoBdVaa0yUVxqeG8MMF6Vg1HrFxKqRElNLl6WKEVgieEvXP8ZrotmqLJLY1V/dH/6QuOraHyoqYqL1zxKtm5gIxqjQUls1GhONJnZZ7YpEotWqyMXhMjP7vOfyXWa+882gmMBx+nEu7/U573nP+c5XZygUckQVp8MZdoRFt9OhVTVCp9MZDof5kzpBgyI5WIMeIKBuI6U2RqMYYm0rFZwdvMYKFNE/JpPUoWHpAJM6DB6AwDUMzFSbiDmAA3z61VRDeSRMDvAwHMpm2tk2vEMIa3h4O4BU6WFrIEYUydxlN5XvOMbT5UCFIE3DgRiF5/LW1taWlpaenh5K35S/sQmAUaRkQ74XnSQUKZwRsWVGGwtLF4yF6k632z1ixIgxY8aMHTvW5WKxMHA/4IAd/LDsl1/+8803e5uamtrb22nToOkQPNwgUiq7NK+Y/WynE56QR5xNo4HwhISE1NTUzMzJc+fmL126NDs7mySJ7Y2xxHrYbWRQcPny5Q0bNjx58sTn8wmQYkkc6DhA6WcFnpSWlnz11d9mzJgBIXG6oXQA1j9+/HjRokV4ehO9FvMkUbe2WJso9QRDhdFK1AOBQEZG+tdf/33dunVx+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/YdjiV2+2Bo48aNwB3EHBY2oj2YFySR/TgFyacmtOAsiMTQ3dWdmppSXv7X+rr6BQsWxGM9l4QsxPGRgg1/IWXmzJlYrPgKdPbsWXwXw+3xnj17Hj16hBXCbzDh2OzZs5csWdLQ0PDzzz95PAnoMcgQVZgavYLhsyfBk572wdSPPioqLIKQzMxMMMRvPYkFfjL8ovVSD4W0w4GMiY+kI9NG4gMjdiLkGU4NN6aw0vqotfm/zVo/H1U+aVbCODVhkvG/24wePZpTxm+6Jtn6M6s2rFW4G1DAK1o/r6j6I8hsmm9hOpcGB8yxaaNkSA4pF/GQtDbSKAS3XRqNJB96bQTP8J4BQDq8HUBGGd4OYM9w0QapFUpI1BZJjdW1QbsKKLkcksB+dtSGMc6FDq3C68amgZxXyTz2w+P/uznZRGn/oJ4AAAAASUVORK5CYII=" />
|
|
9
|
+
<link rel="preconnect" href="https://fonts.googleapis.com" />
|
|
10
|
+
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
|
|
11
|
+
<link href="https://fonts.googleapis.com/css2?family=Geist+Mono:wght@400;500;600&family=Geist:wght@400;500;600&display=swap" rel="stylesheet" />
|
|
12
|
+
<style>
|
|
13
|
+
:root {
|
|
14
|
+
--canvas: #e8e8e8;
|
|
15
|
+
--sidebar: #f2f2f2;
|
|
16
|
+
--nav: #f7f7f7;
|
|
17
|
+
--paper: #f4f4f4;
|
|
18
|
+
--white: #ffffff;
|
|
19
|
+
--inset: #f0f0f0;
|
|
20
|
+
--hairline: #d6d6d6;
|
|
21
|
+
--line: #c3c3c3;
|
|
22
|
+
--smoke: #7a7a7a;
|
|
23
|
+
--stone: #5c5c5c;
|
|
24
|
+
--charcoal: #333333;
|
|
25
|
+
--obsidian: #171717;
|
|
26
|
+
--sans: Geist, Inter, ui-sans-serif, system-ui, sans-serif;
|
|
27
|
+
--mono: "Geist Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
|
|
28
|
+
--radius: 6px;
|
|
29
|
+
--ring: 0 0 0 1px #cfcfcf;
|
|
30
|
+
--ghost: 0 0 0 1px #cfcfcf;
|
|
31
|
+
}
|
|
32
|
+
* { box-sizing: border-box; }
|
|
33
|
+
html, body { height: 100%; }
|
|
34
|
+
body {
|
|
35
|
+
margin: 0;
|
|
36
|
+
background: var(--canvas);
|
|
37
|
+
color: var(--obsidian);
|
|
38
|
+
font: 15px/1.55 var(--sans);
|
|
39
|
+
}
|
|
40
|
+
button, input { font: inherit; color: inherit; }
|
|
41
|
+
|
|
42
|
+
.topnav {
|
|
43
|
+
height: 56px;
|
|
44
|
+
display: grid;
|
|
45
|
+
grid-template-columns: 1fr auto 1fr;
|
|
46
|
+
align-items: center;
|
|
47
|
+
gap: 16px;
|
|
48
|
+
padding: 0 20px;
|
|
49
|
+
background: var(--nav);
|
|
50
|
+
border-bottom: 1px solid var(--hairline);
|
|
51
|
+
position: sticky;
|
|
52
|
+
top: 0;
|
|
53
|
+
z-index: 20;
|
|
54
|
+
}
|
|
55
|
+
body.searching .topnav { z-index: 30; }
|
|
56
|
+
.brand-wrap { display: flex; align-items: center; gap: 10px; min-width: 0; justify-self: start; }
|
|
57
|
+
.workspace {
|
|
58
|
+
flex: none;
|
|
59
|
+
font: 500 11px/1 var(--mono);
|
|
60
|
+
letter-spacing: 0.06em;
|
|
61
|
+
text-transform: uppercase;
|
|
62
|
+
padding: 5px 8px;
|
|
63
|
+
border-radius: 9999px;
|
|
64
|
+
background: var(--obsidian);
|
|
65
|
+
color: var(--white);
|
|
66
|
+
}
|
|
67
|
+
.brand { font-size: 15px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
|
|
68
|
+
.nav-tools { display: flex; align-items: center; gap: 8px; justify-self: end; }
|
|
69
|
+
.nav-tools .btn {
|
|
70
|
+
height: 36px;
|
|
71
|
+
padding: 0 12px;
|
|
72
|
+
font-size: 12px;
|
|
73
|
+
}
|
|
74
|
+
.nav-tools .btn.icon {
|
|
75
|
+
width: 36px;
|
|
76
|
+
height: 36px;
|
|
77
|
+
padding: 0;
|
|
78
|
+
}
|
|
79
|
+
.nav-tools .btn.icon svg { width: 16px; height: 16px; }
|
|
80
|
+
.btn[data-tip] { position: relative; }
|
|
81
|
+
.btn[data-tip]::after {
|
|
82
|
+
content: attr(data-tip);
|
|
83
|
+
position: absolute;
|
|
84
|
+
top: calc(100% + 8px);
|
|
85
|
+
left: 50%;
|
|
86
|
+
transform: translateX(-50%) translateY(4px);
|
|
87
|
+
background: var(--obsidian);
|
|
88
|
+
color: var(--white);
|
|
89
|
+
font-size: 11px;
|
|
90
|
+
font-weight: 500;
|
|
91
|
+
padding: 6px 8px;
|
|
92
|
+
border-radius: var(--radius);
|
|
93
|
+
white-space: nowrap;
|
|
94
|
+
opacity: 0;
|
|
95
|
+
pointer-events: none;
|
|
96
|
+
transition: opacity 0.12s ease, transform 0.12s ease;
|
|
97
|
+
z-index: 50;
|
|
98
|
+
}
|
|
99
|
+
.btn[data-tip]:hover::after {
|
|
100
|
+
opacity: 1;
|
|
101
|
+
transform: translateX(-50%) translateY(0);
|
|
102
|
+
}
|
|
103
|
+
.search-wrap {
|
|
104
|
+
justify-self: center;
|
|
105
|
+
position: relative;
|
|
106
|
+
width: min(420px, 46vw);
|
|
107
|
+
z-index: 30;
|
|
108
|
+
}
|
|
109
|
+
.search {
|
|
110
|
+
width: 100%;
|
|
111
|
+
height: 36px;
|
|
112
|
+
border: 0;
|
|
113
|
+
border-radius: var(--radius);
|
|
114
|
+
box-shadow: var(--ghost);
|
|
115
|
+
background: var(--white);
|
|
116
|
+
padding: 0 12px;
|
|
117
|
+
}
|
|
118
|
+
.search::placeholder { color: var(--smoke); }
|
|
119
|
+
.search-wrap.open .search {
|
|
120
|
+
box-shadow: 0 0 0 1px var(--obsidian);
|
|
121
|
+
border-radius: var(--radius) var(--radius) 0 0;
|
|
122
|
+
}
|
|
123
|
+
.search-backdrop {
|
|
124
|
+
display: none;
|
|
125
|
+
position: fixed;
|
|
126
|
+
inset: 0;
|
|
127
|
+
background: rgba(232, 232, 232, 0.72);
|
|
128
|
+
backdrop-filter: blur(2px);
|
|
129
|
+
z-index: 25;
|
|
130
|
+
}
|
|
131
|
+
body.searching .search-backdrop { display: block; }
|
|
132
|
+
.search-panel {
|
|
133
|
+
display: none;
|
|
134
|
+
position: absolute;
|
|
135
|
+
top: 100%;
|
|
136
|
+
left: 0;
|
|
137
|
+
right: 0;
|
|
138
|
+
max-height: min(420px, calc(100vh - 90px));
|
|
139
|
+
overflow: auto;
|
|
140
|
+
background: var(--white);
|
|
141
|
+
border-radius: 0 0 var(--radius) var(--radius);
|
|
142
|
+
box-shadow: 0 12px 36px rgba(0, 0, 0, 0.14), var(--ring);
|
|
143
|
+
z-index: 31;
|
|
144
|
+
padding: 6px;
|
|
145
|
+
}
|
|
146
|
+
.search-wrap.open .search-panel { display: block; }
|
|
147
|
+
.search-hit {
|
|
148
|
+
display: flex;
|
|
149
|
+
align-items: center;
|
|
150
|
+
gap: 10px;
|
|
151
|
+
width: 100%;
|
|
152
|
+
border: 0;
|
|
153
|
+
background: transparent;
|
|
154
|
+
text-align: left;
|
|
155
|
+
padding: 10px 10px;
|
|
156
|
+
border-radius: var(--radius);
|
|
157
|
+
cursor: pointer;
|
|
158
|
+
color: var(--charcoal);
|
|
159
|
+
}
|
|
160
|
+
.search-hit:hover,
|
|
161
|
+
.search-hit.active { background: var(--inset); }
|
|
162
|
+
.search-hit-path {
|
|
163
|
+
min-width: 0;
|
|
164
|
+
font: 12px/1.35 var(--mono);
|
|
165
|
+
color: var(--obsidian);
|
|
166
|
+
overflow: hidden;
|
|
167
|
+
text-overflow: ellipsis;
|
|
168
|
+
white-space: nowrap;
|
|
169
|
+
}
|
|
170
|
+
.search-hit mark {
|
|
171
|
+
background: transparent;
|
|
172
|
+
color: var(--obsidian);
|
|
173
|
+
font-weight: 600;
|
|
174
|
+
text-decoration: underline;
|
|
175
|
+
text-decoration-thickness: 1px;
|
|
176
|
+
text-underline-offset: 2px;
|
|
177
|
+
}
|
|
178
|
+
.search-empty {
|
|
179
|
+
padding: 18px 12px;
|
|
180
|
+
color: var(--stone);
|
|
181
|
+
font-size: 13px;
|
|
182
|
+
text-align: center;
|
|
183
|
+
}
|
|
184
|
+
.env-wrap { position: relative; flex: none; }
|
|
185
|
+
.env-wrap.open .env-pop { display: block; }
|
|
186
|
+
.env-trigger {
|
|
187
|
+
flex: none;
|
|
188
|
+
width: 220px;
|
|
189
|
+
height: 36px;
|
|
190
|
+
border: 0;
|
|
191
|
+
border-radius: var(--radius);
|
|
192
|
+
box-shadow: var(--ghost);
|
|
193
|
+
background: var(--white);
|
|
194
|
+
padding: 0 32px 0 12px;
|
|
195
|
+
font: 500 12px/1 var(--mono);
|
|
196
|
+
color: var(--obsidian);
|
|
197
|
+
cursor: pointer;
|
|
198
|
+
position: relative;
|
|
199
|
+
white-space: nowrap;
|
|
200
|
+
text-align: left;
|
|
201
|
+
overflow: hidden;
|
|
202
|
+
text-overflow: ellipsis;
|
|
203
|
+
}
|
|
204
|
+
.env-trigger::after {
|
|
205
|
+
content: "";
|
|
206
|
+
position: absolute;
|
|
207
|
+
right: 12px;
|
|
208
|
+
top: 50%;
|
|
209
|
+
width: 6px;
|
|
210
|
+
height: 6px;
|
|
211
|
+
border-right: 1px solid var(--obsidian);
|
|
212
|
+
border-bottom: 1px solid var(--obsidian);
|
|
213
|
+
transform: translateY(-70%) rotate(45deg);
|
|
214
|
+
}
|
|
215
|
+
.env-wrap.open .env-trigger::after { transform: translateY(-20%) rotate(225deg); }
|
|
216
|
+
.env-pop {
|
|
217
|
+
display: none;
|
|
218
|
+
position: absolute;
|
|
219
|
+
top: calc(100% + 6px);
|
|
220
|
+
right: 0;
|
|
221
|
+
width: min(420px, calc(100vw - 48px));
|
|
222
|
+
max-height: min(520px, calc(100vh - 120px));
|
|
223
|
+
overflow: auto;
|
|
224
|
+
background: var(--white);
|
|
225
|
+
border-radius: var(--radius);
|
|
226
|
+
box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12), var(--ring);
|
|
227
|
+
padding: 16px;
|
|
228
|
+
z-index: 40;
|
|
229
|
+
}
|
|
230
|
+
.env-block { margin-bottom: 20px; }
|
|
231
|
+
.env-block:last-child { margin-bottom: 0; }
|
|
232
|
+
.env-label {
|
|
233
|
+
font-family: var(--mono);
|
|
234
|
+
font-size: 11px;
|
|
235
|
+
letter-spacing: 0.08em;
|
|
236
|
+
text-transform: uppercase;
|
|
237
|
+
color: var(--stone);
|
|
238
|
+
margin-bottom: 8px;
|
|
239
|
+
}
|
|
240
|
+
.env-cell {
|
|
241
|
+
width: 100%;
|
|
242
|
+
min-width: 0;
|
|
243
|
+
height: 32px;
|
|
244
|
+
border: 0;
|
|
245
|
+
border-radius: var(--radius);
|
|
246
|
+
background: var(--inset);
|
|
247
|
+
padding: 0 10px;
|
|
248
|
+
font: 12px/1 var(--mono);
|
|
249
|
+
color: var(--obsidian);
|
|
250
|
+
}
|
|
251
|
+
.env-kv {
|
|
252
|
+
display: grid;
|
|
253
|
+
grid-template-columns: 1fr 1fr 28px;
|
|
254
|
+
gap: 6px;
|
|
255
|
+
margin-bottom: 6px;
|
|
256
|
+
}
|
|
257
|
+
.ghost-btn {
|
|
258
|
+
border: 0;
|
|
259
|
+
background: transparent;
|
|
260
|
+
color: var(--stone);
|
|
261
|
+
cursor: pointer;
|
|
262
|
+
width: 32px;
|
|
263
|
+
height: 32px;
|
|
264
|
+
padding: 0;
|
|
265
|
+
display: inline-flex;
|
|
266
|
+
align-items: center;
|
|
267
|
+
justify-content: center;
|
|
268
|
+
font-size: 16px;
|
|
269
|
+
line-height: 1;
|
|
270
|
+
}
|
|
271
|
+
.ghost-btn:hover { color: var(--obsidian); }
|
|
272
|
+
.ghost-btn:disabled { opacity: 0.35; cursor: default; }
|
|
273
|
+
.ghost-btn:disabled:hover { color: var(--stone); }
|
|
274
|
+
.chip-row { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; align-items: center; }
|
|
275
|
+
.chip-btn {
|
|
276
|
+
border: 0;
|
|
277
|
+
background: var(--inset);
|
|
278
|
+
box-shadow: var(--ghost);
|
|
279
|
+
border-radius: 9999px;
|
|
280
|
+
padding: 5px 10px;
|
|
281
|
+
cursor: pointer;
|
|
282
|
+
font-size: 12px;
|
|
283
|
+
color: var(--charcoal);
|
|
284
|
+
}
|
|
285
|
+
.chip-btn.on {
|
|
286
|
+
background: var(--obsidian);
|
|
287
|
+
color: var(--white);
|
|
288
|
+
box-shadow: none;
|
|
289
|
+
}
|
|
290
|
+
.env-add {
|
|
291
|
+
height: 32px;
|
|
292
|
+
padding: 0 10px;
|
|
293
|
+
font-size: 12px;
|
|
294
|
+
margin-top: 4px;
|
|
295
|
+
}
|
|
296
|
+
.btn.primary {
|
|
297
|
+
background: var(--obsidian);
|
|
298
|
+
color: var(--white);
|
|
299
|
+
box-shadow: none;
|
|
300
|
+
}
|
|
301
|
+
.btn.primary:hover { opacity: 0.92; color: var(--white); }
|
|
302
|
+
.btn.primary:disabled { opacity: 0.45; cursor: default; }
|
|
303
|
+
.live-err { color: #8a2e2e; font-size: 13px; padding: 8px 0; white-space: pre-wrap; }
|
|
304
|
+
|
|
305
|
+
.app {
|
|
306
|
+
display: grid;
|
|
307
|
+
grid-template-columns: 320px minmax(0, 1fr);
|
|
308
|
+
height: calc(100vh - 56px);
|
|
309
|
+
}
|
|
310
|
+
.sidebar, .workbench { height: 100%; overflow: auto; }
|
|
311
|
+
.sidebar {
|
|
312
|
+
padding: 16px 12px 48px;
|
|
313
|
+
background: var(--sidebar);
|
|
314
|
+
border-right: 1px solid var(--line);
|
|
315
|
+
font-size: 13px;
|
|
316
|
+
}
|
|
317
|
+
.tree-root { display: flex; flex-direction: column; gap: 2px; }
|
|
318
|
+
.tree-folder { display: flex; flex-direction: column; gap: 2px; }
|
|
319
|
+
.tree-folder-toggle {
|
|
320
|
+
display: flex;
|
|
321
|
+
align-items: center;
|
|
322
|
+
gap: 6px;
|
|
323
|
+
width: 100%;
|
|
324
|
+
border: 0;
|
|
325
|
+
background: transparent;
|
|
326
|
+
text-align: left;
|
|
327
|
+
padding: 6px 8px;
|
|
328
|
+
border-radius: var(--radius);
|
|
329
|
+
cursor: pointer;
|
|
330
|
+
color: var(--charcoal);
|
|
331
|
+
font: 500 12px/1.4 var(--mono);
|
|
332
|
+
}
|
|
333
|
+
.tree-folder-toggle:hover { background: var(--white); color: var(--obsidian); }
|
|
334
|
+
.tree-folder-toggle .chev {
|
|
335
|
+
width: 10px;
|
|
336
|
+
height: 10px;
|
|
337
|
+
flex: none;
|
|
338
|
+
position: relative;
|
|
339
|
+
opacity: 0.55;
|
|
340
|
+
}
|
|
341
|
+
.tree-folder-toggle .chev::before {
|
|
342
|
+
content: "";
|
|
343
|
+
position: absolute;
|
|
344
|
+
left: 2px;
|
|
345
|
+
top: 1px;
|
|
346
|
+
width: 5px;
|
|
347
|
+
height: 5px;
|
|
348
|
+
border-right: 1.5px solid currentColor;
|
|
349
|
+
border-bottom: 1.5px solid currentColor;
|
|
350
|
+
transform: rotate(-45deg);
|
|
351
|
+
transition: transform 0.15s ease;
|
|
352
|
+
}
|
|
353
|
+
.tree-folder.open > .tree-folder-toggle .chev::before { transform: rotate(45deg); top: 0; }
|
|
354
|
+
.tree-folder-name {
|
|
355
|
+
min-width: 0;
|
|
356
|
+
overflow: hidden;
|
|
357
|
+
text-overflow: ellipsis;
|
|
358
|
+
white-space: nowrap;
|
|
359
|
+
}
|
|
360
|
+
.tree-children {
|
|
361
|
+
display: none;
|
|
362
|
+
margin-left: 14px;
|
|
363
|
+
padding-left: 8px;
|
|
364
|
+
border-left: 1px solid var(--hairline);
|
|
365
|
+
}
|
|
366
|
+
.tree-folder.open > .tree-children { display: flex; flex-direction: column; gap: 2px; }
|
|
367
|
+
.tree-empty {
|
|
368
|
+
padding: 24px 12px;
|
|
369
|
+
color: var(--stone);
|
|
370
|
+
font-size: 13px;
|
|
371
|
+
text-align: center;
|
|
372
|
+
}
|
|
373
|
+
.nav-item {
|
|
374
|
+
display: flex;
|
|
375
|
+
align-items: center;
|
|
376
|
+
gap: 8px;
|
|
377
|
+
width: 100%;
|
|
378
|
+
border: 0;
|
|
379
|
+
background: transparent;
|
|
380
|
+
text-align: left;
|
|
381
|
+
padding: 7px 8px;
|
|
382
|
+
border-radius: var(--radius);
|
|
383
|
+
cursor: pointer;
|
|
384
|
+
}
|
|
385
|
+
.nav-item:hover { background: var(--white); }
|
|
386
|
+
.nav-item.active { background: var(--white); box-shadow: var(--ring); }
|
|
387
|
+
.nav-title {
|
|
388
|
+
font-size: 12px;
|
|
389
|
+
color: var(--charcoal);
|
|
390
|
+
min-width: 0;
|
|
391
|
+
overflow: hidden;
|
|
392
|
+
text-overflow: ellipsis;
|
|
393
|
+
white-space: nowrap;
|
|
394
|
+
}
|
|
395
|
+
.nav-item.active .nav-title { color: var(--obsidian); }
|
|
396
|
+
|
|
397
|
+
.method {
|
|
398
|
+
display: inline-flex;
|
|
399
|
+
align-items: center;
|
|
400
|
+
justify-content: center;
|
|
401
|
+
min-width: 48px;
|
|
402
|
+
height: 22px;
|
|
403
|
+
padding: 0 6px;
|
|
404
|
+
border-radius: 9999px;
|
|
405
|
+
font: 500 11px/1 var(--mono);
|
|
406
|
+
letter-spacing: 0.06em;
|
|
407
|
+
text-transform: uppercase;
|
|
408
|
+
box-shadow: var(--ghost);
|
|
409
|
+
background: var(--white);
|
|
410
|
+
}
|
|
411
|
+
.method.post, .method.put, .method.patch {
|
|
412
|
+
background: var(--obsidian);
|
|
413
|
+
color: var(--white);
|
|
414
|
+
box-shadow: none;
|
|
415
|
+
}
|
|
416
|
+
.method.get { background: var(--inset); color: var(--obsidian); }
|
|
417
|
+
.method.delete { background: var(--white); color: var(--charcoal); }
|
|
418
|
+
|
|
419
|
+
.workbench { padding: 28px 36px 96px; background: var(--paper); }
|
|
420
|
+
.head-row {
|
|
421
|
+
display: flex;
|
|
422
|
+
align-items: flex-start;
|
|
423
|
+
justify-content: space-between;
|
|
424
|
+
gap: 16px;
|
|
425
|
+
margin-bottom: 16px;
|
|
426
|
+
}
|
|
427
|
+
.title { font-size: 28px; letter-spacing: -1px; line-height: 1.15; margin: 0; font-weight: 400; min-width: 0; }
|
|
428
|
+
.meta-line { color: var(--stone); font: 12px/1.4 var(--mono); margin: 8px 0 0; }
|
|
429
|
+
|
|
430
|
+
.dd { position: relative; min-width: min(100%, 420px); }
|
|
431
|
+
.dd-toggle {
|
|
432
|
+
width: 100%;
|
|
433
|
+
min-height: 40px;
|
|
434
|
+
border: 0;
|
|
435
|
+
border-radius: var(--radius);
|
|
436
|
+
box-shadow: var(--ghost);
|
|
437
|
+
background: var(--white);
|
|
438
|
+
padding: 8px 36px 8px 12px;
|
|
439
|
+
text-align: left;
|
|
440
|
+
cursor: pointer;
|
|
441
|
+
font-size: 14px;
|
|
442
|
+
line-height: 1.4;
|
|
443
|
+
position: relative;
|
|
444
|
+
}
|
|
445
|
+
.dd-toggle::after {
|
|
446
|
+
content: "";
|
|
447
|
+
position: absolute;
|
|
448
|
+
right: 14px;
|
|
449
|
+
top: 50%;
|
|
450
|
+
width: 6px;
|
|
451
|
+
height: 6px;
|
|
452
|
+
border-right: 1px solid var(--obsidian);
|
|
453
|
+
border-bottom: 1px solid var(--obsidian);
|
|
454
|
+
transform: translateY(-70%) rotate(45deg);
|
|
455
|
+
}
|
|
456
|
+
.dd.open .dd-toggle::after { transform: translateY(-20%) rotate(225deg); }
|
|
457
|
+
.dd-menu {
|
|
458
|
+
display: none;
|
|
459
|
+
position: absolute;
|
|
460
|
+
z-index: 30;
|
|
461
|
+
top: calc(100% + 4px);
|
|
462
|
+
left: 0;
|
|
463
|
+
right: 0;
|
|
464
|
+
max-height: 320px;
|
|
465
|
+
overflow: auto;
|
|
466
|
+
background: var(--white);
|
|
467
|
+
border-radius: var(--radius);
|
|
468
|
+
box-shadow: var(--ring);
|
|
469
|
+
padding: 6px 0;
|
|
470
|
+
}
|
|
471
|
+
.dd.open .dd-menu { display: block; }
|
|
472
|
+
.dd-group {
|
|
473
|
+
font-family: var(--mono);
|
|
474
|
+
font-size: 11px;
|
|
475
|
+
letter-spacing: 0.08em;
|
|
476
|
+
text-transform: uppercase;
|
|
477
|
+
color: var(--stone);
|
|
478
|
+
padding: 10px 12px 6px;
|
|
479
|
+
}
|
|
480
|
+
.dd-item {
|
|
481
|
+
display: block;
|
|
482
|
+
width: 100%;
|
|
483
|
+
border: 0;
|
|
484
|
+
background: transparent;
|
|
485
|
+
text-align: left;
|
|
486
|
+
padding: 8px 12px;
|
|
487
|
+
font-size: 14px;
|
|
488
|
+
cursor: pointer;
|
|
489
|
+
}
|
|
490
|
+
.dd-item:hover, .dd-item.on { background: var(--inset); }
|
|
491
|
+
|
|
492
|
+
.urlbar {
|
|
493
|
+
display: flex;
|
|
494
|
+
gap: 8px;
|
|
495
|
+
align-items: stretch;
|
|
496
|
+
margin-bottom: 16px;
|
|
497
|
+
}
|
|
498
|
+
.url {
|
|
499
|
+
flex: 1;
|
|
500
|
+
min-width: 0;
|
|
501
|
+
display: flex;
|
|
502
|
+
align-items: center;
|
|
503
|
+
gap: 12px;
|
|
504
|
+
background: var(--white);
|
|
505
|
+
border-radius: var(--radius);
|
|
506
|
+
box-shadow: var(--ring);
|
|
507
|
+
padding: 10px 14px;
|
|
508
|
+
font-family: var(--mono);
|
|
509
|
+
font-size: 13px;
|
|
510
|
+
word-break: break-all;
|
|
511
|
+
}
|
|
512
|
+
.url .method { flex: none; }
|
|
513
|
+
.btn {
|
|
514
|
+
border: 0;
|
|
515
|
+
background: var(--white);
|
|
516
|
+
box-shadow: var(--ghost);
|
|
517
|
+
border-radius: var(--radius);
|
|
518
|
+
padding: 0 14px;
|
|
519
|
+
height: 44px;
|
|
520
|
+
cursor: pointer;
|
|
521
|
+
color: var(--charcoal);
|
|
522
|
+
white-space: nowrap;
|
|
523
|
+
}
|
|
524
|
+
.btn:hover { color: var(--obsidian); }
|
|
525
|
+
.btn.sm { height: 32px; padding: 0 10px; font-size: 12px; }
|
|
526
|
+
.btn.icon {
|
|
527
|
+
width: 32px;
|
|
528
|
+
height: 32px;
|
|
529
|
+
padding: 0;
|
|
530
|
+
display: inline-flex;
|
|
531
|
+
align-items: center;
|
|
532
|
+
justify-content: center;
|
|
533
|
+
color: var(--stone);
|
|
534
|
+
}
|
|
535
|
+
.btn.icon:hover:not(:disabled) { color: var(--obsidian); }
|
|
536
|
+
.btn.icon svg { width: 15px; height: 15px; display: block; }
|
|
537
|
+
.btn:disabled { opacity: 0.4; cursor: default; }
|
|
538
|
+
|
|
539
|
+
.toast {
|
|
540
|
+
position: fixed;
|
|
541
|
+
bottom: 24px;
|
|
542
|
+
left: 50%;
|
|
543
|
+
transform: translateX(-50%) translateY(12px);
|
|
544
|
+
background: var(--obsidian);
|
|
545
|
+
color: var(--white);
|
|
546
|
+
font-size: 13px;
|
|
547
|
+
padding: 10px 16px;
|
|
548
|
+
border-radius: var(--radius);
|
|
549
|
+
box-shadow: var(--ring);
|
|
550
|
+
opacity: 0;
|
|
551
|
+
pointer-events: none;
|
|
552
|
+
transition: opacity 0.18s ease, transform 0.18s ease;
|
|
553
|
+
z-index: 100;
|
|
554
|
+
}
|
|
555
|
+
.toast.show {
|
|
556
|
+
opacity: 1;
|
|
557
|
+
transform: translateX(-50%) translateY(0);
|
|
558
|
+
}
|
|
559
|
+
|
|
560
|
+
.pair {
|
|
561
|
+
display: grid;
|
|
562
|
+
grid-template-columns: 1fr 1fr;
|
|
563
|
+
gap: 16px;
|
|
564
|
+
margin-bottom: 24px;
|
|
565
|
+
align-items: start;
|
|
566
|
+
}
|
|
567
|
+
.card {
|
|
568
|
+
background: var(--white);
|
|
569
|
+
border-radius: var(--radius);
|
|
570
|
+
box-shadow: var(--ring);
|
|
571
|
+
min-width: 0;
|
|
572
|
+
display: flex;
|
|
573
|
+
flex-direction: column;
|
|
574
|
+
max-width: 100%;
|
|
575
|
+
}
|
|
576
|
+
.card.response-card {
|
|
577
|
+
overflow: hidden;
|
|
578
|
+
}
|
|
579
|
+
.card-head {
|
|
580
|
+
display: flex;
|
|
581
|
+
align-items: center;
|
|
582
|
+
justify-content: space-between;
|
|
583
|
+
gap: 12px;
|
|
584
|
+
padding: 14px 16px;
|
|
585
|
+
border-bottom: 1px solid var(--hairline);
|
|
586
|
+
flex: none;
|
|
587
|
+
}
|
|
588
|
+
.card-head h2 { margin: 0; font-size: 14px; font-weight: 500; }
|
|
589
|
+
.card-head-actions { display: flex; align-items: center; gap: 8px; }
|
|
590
|
+
.card-body {
|
|
591
|
+
padding: 0;
|
|
592
|
+
display: flex;
|
|
593
|
+
flex-direction: column;
|
|
594
|
+
min-height: 0;
|
|
595
|
+
}
|
|
596
|
+
#response-body {
|
|
597
|
+
overflow: auto;
|
|
598
|
+
}
|
|
599
|
+
#response-body pre {
|
|
600
|
+
max-height: none;
|
|
601
|
+
}
|
|
602
|
+
.meta-block {
|
|
603
|
+
padding: 14px 16px;
|
|
604
|
+
border-top: 1px solid var(--hairline);
|
|
605
|
+
}
|
|
606
|
+
.meta-block:first-child { border-top: 0; }
|
|
607
|
+
.meta-toolbar {
|
|
608
|
+
display: flex;
|
|
609
|
+
align-items: center;
|
|
610
|
+
justify-content: space-between;
|
|
611
|
+
gap: 8px;
|
|
612
|
+
margin-bottom: 10px;
|
|
613
|
+
}
|
|
614
|
+
.meta-label {
|
|
615
|
+
font: 600 11px/1 var(--mono);
|
|
616
|
+
letter-spacing: 0.08em;
|
|
617
|
+
text-transform: uppercase;
|
|
618
|
+
color: var(--obsidian);
|
|
619
|
+
}
|
|
620
|
+
.meta-source { color: var(--smoke); font: 11px/1 var(--mono); }
|
|
621
|
+
.meta-empty { color: var(--smoke); font-size: 12px; padding: 2px 0; }
|
|
622
|
+
.kv {
|
|
623
|
+
display: flex;
|
|
624
|
+
align-items: center;
|
|
625
|
+
gap: 12px;
|
|
626
|
+
margin-bottom: 8px;
|
|
627
|
+
font-size: 13px;
|
|
628
|
+
min-width: 0;
|
|
629
|
+
}
|
|
630
|
+
.kv:last-child { margin-bottom: 0; }
|
|
631
|
+
.kname {
|
|
632
|
+
flex: none;
|
|
633
|
+
width: 120px;
|
|
634
|
+
color: var(--stone);
|
|
635
|
+
font-family: var(--mono);
|
|
636
|
+
font-size: 11px;
|
|
637
|
+
letter-spacing: 0.04em;
|
|
638
|
+
white-space: nowrap;
|
|
639
|
+
overflow: hidden;
|
|
640
|
+
text-overflow: ellipsis;
|
|
641
|
+
}
|
|
642
|
+
.kval {
|
|
643
|
+
flex: 1;
|
|
644
|
+
min-width: 0;
|
|
645
|
+
font-family: var(--mono);
|
|
646
|
+
font-size: 12px;
|
|
647
|
+
color: var(--obsidian);
|
|
648
|
+
padding: 8px 10px;
|
|
649
|
+
background: var(--inset);
|
|
650
|
+
border-radius: var(--radius);
|
|
651
|
+
white-space: nowrap;
|
|
652
|
+
overflow: hidden;
|
|
653
|
+
text-overflow: ellipsis;
|
|
654
|
+
}
|
|
655
|
+
pre {
|
|
656
|
+
margin: 0;
|
|
657
|
+
padding: 12px;
|
|
658
|
+
background: var(--inset);
|
|
659
|
+
border-radius: var(--radius);
|
|
660
|
+
overflow: auto;
|
|
661
|
+
font: 12px/1.5 var(--mono);
|
|
662
|
+
}
|
|
663
|
+
.k { color: #1f4e79; }
|
|
664
|
+
.s { color: #2e6b2e; }
|
|
665
|
+
.n { color: #8a4b12; }
|
|
666
|
+
.p { color: #6b3fa0; }
|
|
667
|
+
.empty { color: var(--stone); font-size: 13px; padding: 8px 0; }
|
|
668
|
+
.code {
|
|
669
|
+
font: 500 12px/1 var(--mono);
|
|
670
|
+
padding: 4px 8px;
|
|
671
|
+
border-radius: 9999px;
|
|
672
|
+
background: var(--inset);
|
|
673
|
+
}
|
|
674
|
+
.code.ok { background: #e5f2e8; color: #297a3a; }
|
|
675
|
+
.code-text { color: var(--stone); font-size: 12px; }
|
|
676
|
+
|
|
677
|
+
.fields { margin-top: 16px; }
|
|
678
|
+
.fields > h2 {
|
|
679
|
+
font-size: 14px;
|
|
680
|
+
font-weight: 500;
|
|
681
|
+
margin: 0 0 4px;
|
|
682
|
+
color: var(--obsidian);
|
|
683
|
+
}
|
|
684
|
+
.fields-section { padding: 14px 0 2px; }
|
|
685
|
+
.fields-section-title {
|
|
686
|
+
font: 500 11px/1 var(--mono);
|
|
687
|
+
letter-spacing: 0.08em;
|
|
688
|
+
text-transform: uppercase;
|
|
689
|
+
color: var(--stone);
|
|
690
|
+
margin-bottom: 8px;
|
|
691
|
+
padding-bottom: 8px;
|
|
692
|
+
border-bottom: 1px solid var(--hairline);
|
|
693
|
+
}
|
|
694
|
+
.row {
|
|
695
|
+
display: grid;
|
|
696
|
+
grid-template-columns: 1.2fr 0.7fr 1fr;
|
|
697
|
+
gap: 12px;
|
|
698
|
+
padding: 8px 0;
|
|
699
|
+
font-size: 13px;
|
|
700
|
+
}
|
|
701
|
+
.row .name { font-family: var(--mono); font-size: 12px; color: var(--obsidian); }
|
|
702
|
+
.row .name.nested { color: var(--ink, var(--obsidian)); }
|
|
703
|
+
.row .type { color: var(--stone); font-family: var(--mono); font-size: 12px; }
|
|
704
|
+
.flag { margin-top: 4px; font-size: 11px; color: var(--smoke); }
|
|
705
|
+
.flag.req { color: #8a2e2e; }
|
|
706
|
+
|
|
707
|
+
@media (max-width: 960px) {
|
|
708
|
+
.app { grid-template-columns: 1fr; height: auto; }
|
|
709
|
+
.sidebar { max-height: 40vh; }
|
|
710
|
+
.pair { grid-template-columns: 1fr; }
|
|
711
|
+
.search-wrap { width: min(280px, 70vw); }
|
|
712
|
+
}
|
|
713
|
+
</style>
|
|
714
|
+
</head>
|
|
715
|
+
<body>
|
|
716
|
+
<header class="topnav">
|
|
717
|
+
<div class="brand-wrap">
|
|
718
|
+
<span class="workspace" id="workspace">workspace</span>
|
|
719
|
+
<div class="brand" id="brand">API Docs</div>
|
|
720
|
+
</div>
|
|
721
|
+
<div class="search-wrap" id="search-wrap">
|
|
722
|
+
<input class="search" id="search" placeholder="Search endpoints" autocomplete="off" spellcheck="false" />
|
|
723
|
+
<div class="search-panel" id="search-panel" role="listbox"></div>
|
|
724
|
+
</div>
|
|
725
|
+
<div class="nav-tools">
|
|
726
|
+
<button class="btn icon" id="export-openapi" type="button" data-tip="Export OpenAPI" aria-label="Export OpenAPI">
|
|
727
|
+
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/><polyline points="7 10 12 15 17 10"/><line x1="12" y1="15" x2="12" y2="3"/></svg>
|
|
728
|
+
</button>
|
|
729
|
+
<div class="env-wrap" id="env-wrap">
|
|
730
|
+
<button class="env-trigger" id="env-trigger" type="button">local · —</button>
|
|
731
|
+
<div class="env-pop" id="env-pop"></div>
|
|
732
|
+
</div>
|
|
733
|
+
</div>
|
|
734
|
+
</header>
|
|
735
|
+
<div class="search-backdrop" id="search-backdrop"></div>
|
|
736
|
+
<div class="app">
|
|
737
|
+
<aside class="sidebar" id="nav"></aside>
|
|
738
|
+
<main class="workbench" id="main"></main>
|
|
739
|
+
</div>
|
|
740
|
+
<script>
|
|
741
|
+
window.__SPEC__ = {"openapi":"3.0.3","info":{"title":"Onboarding API","version":"1.4.0","description":"Generated from NestJS integration tests","x-workspace":"token-x"},"x-viewer":{"groupBy":"path"},"servers":[{"url":"http://localhost:3000"}],"tags":[{"name":"customers"},{"name":"kyc"}],"paths":{"/v1/customers":{"post":{"tags":["customers"],"summary":"Create customer","security":[{"authorization":[]}],"responses":{"201":{"description":"Created"},"400":{"description":"Bad Request"}},"x-tree-segments":["v1","customers"],"x-docs":{"title":"Create customer","fields":[{"name":"authorization","in":"header","type":"string","required":true},{"name":"email","in":"body","type":"string","required":true},{"name":"fullName","in":"body","type":"string","required":true},{"name":"phone","in":"body","type":"string","required":false},{"name":"metadata.channel","in":"body","type":"string","required":false}]},"x-scenarios":[{"group":"Success","name":"valid payload","status":201,"headers":{"authorization":"Bearer eyJhbGciOi…","content-type":"application/json"},"pathParams":{},"query":{},"reqBody":{"email":"ada@example.com","fullName":"Ada Lovelace","phone":"+905551112233","metadata":{"channel":"mobile"}},"resBody":{"id":"cus_01HXYZ","status":"ACTIVE"}},{"group":"Validation","name":"missing email","status":400,"headers":{"authorization":"Bearer eyJhbGciOi…","content-type":"application/json"},"pathParams":{},"query":{},"reqBody":{"fullName":"Ada Lovelace"},"resBody":{"message":["email must be an email"],"error":"Bad Request","statusCode":400}},{"group":"Auth","name":"missing authorization","status":401,"headers":{},"pathParams":{},"query":{},"reqBody":{"email":"ada@example.com","fullName":"Ada Lovelace"},"resBody":{"message":"Unauthorized","statusCode":401}}]}},"/v1/customers/{customerId}":{"get":{"tags":["customers"],"summary":"Get customer","security":[{"authorization":[]}],"responses":{"200":{"description":"OK"},"404":{"description":"Not Found"}},"x-tree-segments":["v1","customers","{customerId}"],"x-docs":{"title":"Get customer","fields":[{"name":"authorization","in":"header","type":"string","required":true},{"name":"customerId","in":"path","type":"string","required":true}]},"x-scenarios":[{"group":"Success","name":"existing customer","status":200,"headers":{"authorization":"Bearer eyJhbGciOi…"},"pathParams":{"customerId":"cus_01HXYZ"},"query":{},"resBody":{"id":"cus_01HXYZ","email":"ada@example.com","status":"ACTIVE"}}]}},"/v1/kyc/sessions":{"post":{"tags":["kyc"],"summary":"Start KYC session","security":[{"authorization":[]}],"responses":{"201":{"description":"Created"}},"x-tree-segments":["v1","kyc","sessions"],"x-docs":{"title":"Start KYC session","fields":[{"name":"authorization","in":"header","type":"string","required":true},{"name":"customerId","in":"body","type":"string","required":true},{"name":"provider","in":"body","type":"string","required":true}]},"x-scenarios":[{"group":"Success","name":"jumio session","status":201,"headers":{"authorization":"Bearer eyJhbGciOi…","content-type":"application/json"},"pathParams":{},"query":{},"reqBody":{"customerId":"cus_01HXYZ","provider":"jumio"},"resBody":{"sessionId":"kyc_9f2a","redirectUrl":"https://example.com/kyc/start"}}]}}},"components":{"securitySchemes":{"authorization":{"type":"apiKey","in":"header","name":"authorization"}}}};
|
|
742
|
+
</script>
|
|
743
|
+
<script>
|
|
744
|
+
const spec = window.__SPEC__ || {};
|
|
745
|
+
const viewer = spec["x-viewer"] || {};
|
|
746
|
+
const workspace = (spec.info && spec.info["x-workspace"]) || viewer.workspace || "";
|
|
747
|
+
const defaultBaseUrlFromSpec = String((viewer.baseUrl || (spec.servers && spec.servers[0] && spec.servers[0].url) || "http://localhost:3000")).replace(/\/$/, "");
|
|
748
|
+
const docsPathSuffix = String(viewer.docsPath || "/docs").replace(/\/$/, "") || "/docs";
|
|
749
|
+
|
|
750
|
+
const inferBaseUrlFromLocation = () => {
|
|
751
|
+
if (typeof location === "undefined") return null;
|
|
752
|
+
if (location.protocol !== "http:" && location.protocol !== "https:") return null;
|
|
753
|
+
let pathname = (location.pathname || "/").replace(/\/$/, "") || "";
|
|
754
|
+
if (pathname === docsPathSuffix) return location.origin.replace(/\/$/, "");
|
|
755
|
+
if (pathname.endsWith(docsPathSuffix)) {
|
|
756
|
+
const prefix = pathname.slice(0, -docsPathSuffix.length).replace(/\/$/, "");
|
|
757
|
+
return (location.origin + prefix).replace(/\/$/, "");
|
|
758
|
+
}
|
|
759
|
+
const idx = pathname.indexOf(docsPathSuffix + "/");
|
|
760
|
+
if (idx >= 0) {
|
|
761
|
+
const prefix = pathname.slice(0, idx).replace(/\/$/, "");
|
|
762
|
+
return (location.origin + prefix).replace(/\/$/, "");
|
|
763
|
+
}
|
|
764
|
+
return null;
|
|
765
|
+
};
|
|
766
|
+
|
|
767
|
+
const locationBaseUrl = inferBaseUrlFromLocation();
|
|
768
|
+
// Prefer the URL that is serving the viewer (strip /docs), else fall back to spec.
|
|
769
|
+
const defaultBaseUrl = locationBaseUrl || defaultBaseUrlFromSpec;
|
|
770
|
+
const title = (spec.info && spec.info.title) || "API Docs";
|
|
771
|
+
const STORE_KEY = "openapi-docs-env:" + (workspace || "default");
|
|
772
|
+
|
|
773
|
+
let liveResult = null;
|
|
774
|
+
|
|
775
|
+
const escapeAttr = (value) =>
|
|
776
|
+
String(value ?? "")
|
|
777
|
+
.replace(/&/g, "&")
|
|
778
|
+
.replace(/"/g, """)
|
|
779
|
+
.replace(/</g, "<");
|
|
780
|
+
|
|
781
|
+
const varNameFromHeader = (header) => {
|
|
782
|
+
const parts = String(header).replace(/^x-/, "").split("-").filter(Boolean);
|
|
783
|
+
if (!parts.length) return String(header).replace(/[^a-zA-Z0-9]/g, "");
|
|
784
|
+
return parts[0] + parts.slice(1).map((part) => part.charAt(0).toUpperCase() + part.slice(1)).join("");
|
|
785
|
+
};
|
|
786
|
+
|
|
787
|
+
/** Pull try-it defaults from recorded success traffic + parameter examples. */
|
|
788
|
+
const collectDefaultHeaderValues = () => {
|
|
789
|
+
const byHeader = {};
|
|
790
|
+
const take = (header, value, prefer) => {
|
|
791
|
+
if (value == null || value === "") return;
|
|
792
|
+
const key = String(header).toLowerCase();
|
|
793
|
+
if (!byHeader[key] || prefer) byHeader[key] = String(value);
|
|
794
|
+
};
|
|
795
|
+
for (const pathItem of Object.values(spec.paths || {})) {
|
|
796
|
+
for (const op of Object.values(pathItem || {})) {
|
|
797
|
+
if (!op || typeof op !== "object") continue;
|
|
798
|
+
for (const param of op.parameters || []) {
|
|
799
|
+
if (param && param.in === "header" && param.name && param.example != null) {
|
|
800
|
+
take(param.name, param.example, false);
|
|
801
|
+
}
|
|
802
|
+
}
|
|
803
|
+
for (const scenario of op["x-scenarios"] || []) {
|
|
804
|
+
const success = scenario.status >= 200 && scenario.status < 300;
|
|
805
|
+
for (const [header, value] of Object.entries(scenario.headers || {})) {
|
|
806
|
+
if (!String(header).toLowerCase().startsWith("x-")) continue;
|
|
807
|
+
take(header, value, success);
|
|
808
|
+
}
|
|
809
|
+
}
|
|
810
|
+
}
|
|
811
|
+
}
|
|
812
|
+
return byHeader;
|
|
813
|
+
};
|
|
814
|
+
|
|
815
|
+
const defaultHeaderValues = collectDefaultHeaderValues();
|
|
816
|
+
|
|
817
|
+
const buildDefaultStore = () => {
|
|
818
|
+
const schemes = (spec.components && spec.components.securitySchemes) || {};
|
|
819
|
+
const variables = [{ key: "baseUrl", value: defaultBaseUrl }];
|
|
820
|
+
const varKeys = new Set(["baseUrl"]);
|
|
821
|
+
const headerGroups = {};
|
|
822
|
+
for (const [schemeId, scheme] of Object.entries(schemes)) {
|
|
823
|
+
if (!scheme || scheme.in !== "header" || !scheme.name) continue;
|
|
824
|
+
const header = scheme.name;
|
|
825
|
+
const varName = varNameFromHeader(header);
|
|
826
|
+
if (!varKeys.has(varName)) {
|
|
827
|
+
const seeded = defaultHeaderValues[String(header).toLowerCase()] || "";
|
|
828
|
+
variables.push({ key: varName, value: seeded });
|
|
829
|
+
varKeys.add(varName);
|
|
830
|
+
}
|
|
831
|
+
headerGroups[schemeId] = [
|
|
832
|
+
{ key: header, value: "{{" + varName + "}}" },
|
|
833
|
+
{ key: "content-type", value: "application/json" },
|
|
834
|
+
];
|
|
835
|
+
}
|
|
836
|
+
// Pre-build merged groups for operations that need multiple schemes together.
|
|
837
|
+
const seenCombos = new Set();
|
|
838
|
+
for (const pathItem of Object.values(spec.paths || {})) {
|
|
839
|
+
for (const op of Object.values(pathItem || {})) {
|
|
840
|
+
if (!op || typeof op !== "object") continue;
|
|
841
|
+
const ids = [];
|
|
842
|
+
for (const requirement of op.security || []) {
|
|
843
|
+
if (!requirement || typeof requirement !== "object") continue;
|
|
844
|
+
for (const id of Object.keys(requirement)) {
|
|
845
|
+
if (headerGroups[id]) ids.push(id);
|
|
846
|
+
}
|
|
847
|
+
}
|
|
848
|
+
const unique = [...new Set(ids)];
|
|
849
|
+
if (unique.length < 2) continue;
|
|
850
|
+
const comboKey = unique.slice().sort().join("+");
|
|
851
|
+
if (seenCombos.has(comboKey)) continue;
|
|
852
|
+
seenCombos.add(comboKey);
|
|
853
|
+
const byKey = {};
|
|
854
|
+
for (const id of unique) {
|
|
855
|
+
for (const row of headerGroups[id] || []) {
|
|
856
|
+
if (!row.key) continue;
|
|
857
|
+
byKey[row.key] = { key: row.key, value: row.value };
|
|
858
|
+
}
|
|
859
|
+
}
|
|
860
|
+
if (!byKey["content-type"]) byKey["content-type"] = { key: "content-type", value: "application/json" };
|
|
861
|
+
headerGroups[comboKey] = Object.values(byKey);
|
|
862
|
+
}
|
|
863
|
+
}
|
|
864
|
+
|
|
865
|
+
const groupNames = Object.keys(headerGroups);
|
|
866
|
+
if (!groupNames.length) headerGroups.default = [{ key: "content-type", value: "application/json" }];
|
|
867
|
+
return {
|
|
868
|
+
activeEnv: "local",
|
|
869
|
+
activeGroup: groupNames[0] || "default",
|
|
870
|
+
envs: { local: { variables, headerGroups } },
|
|
871
|
+
};
|
|
872
|
+
};
|
|
873
|
+
|
|
874
|
+
const cloneDefaultEnv = () => JSON.parse(JSON.stringify(buildDefaultStore().envs.local));
|
|
875
|
+
|
|
876
|
+
const mergeStore = (saved) => {
|
|
877
|
+
const defaults = buildDefaultStore();
|
|
878
|
+
if (!saved || !saved.envs || typeof saved.envs !== "object") return defaults;
|
|
879
|
+
const envs = {};
|
|
880
|
+
for (const [name, env] of Object.entries(saved.envs)) {
|
|
881
|
+
const base = cloneDefaultEnv();
|
|
882
|
+
const variables = Array.isArray(env.variables) ? env.variables.map((row) => ({ key: String(row.key || ""), value: String(row.value ?? "") })) : base.variables.map((row) => ({ ...row }));
|
|
883
|
+
const known = new Set(variables.map((row) => row.key).filter(Boolean));
|
|
884
|
+
for (const row of base.variables) {
|
|
885
|
+
if (row.key && !known.has(row.key)) variables.push({ ...row });
|
|
886
|
+
}
|
|
887
|
+
// Backfill empty env values from recorded defaults so Try-it works out of the box.
|
|
888
|
+
const defaultsByKey = Object.fromEntries((base.variables || []).filter((row) => row.key).map((row) => [row.key, row.value ?? ""]));
|
|
889
|
+
for (const row of variables) {
|
|
890
|
+
if (!row.key) continue;
|
|
891
|
+
if (String(row.value ?? "").trim()) continue;
|
|
892
|
+
if (defaultsByKey[row.key]) row.value = defaultsByKey[row.key];
|
|
893
|
+
}
|
|
894
|
+
const headerGroups = { ...(env.headerGroups || {}) };
|
|
895
|
+
for (const [group, rows] of Object.entries(base.headerGroups)) {
|
|
896
|
+
if (!headerGroups[group]) headerGroups[group] = rows.map((row) => ({ ...row }));
|
|
897
|
+
}
|
|
898
|
+
if (!Object.keys(headerGroups).length) headerGroups.default = [{ key: "content-type", value: "application/json" }];
|
|
899
|
+
envs[name] = { variables, headerGroups };
|
|
900
|
+
}
|
|
901
|
+
if (!Object.keys(envs).length) return defaults;
|
|
902
|
+
const activeEnv = envs[saved.activeEnv] ? saved.activeEnv : Object.keys(envs)[0];
|
|
903
|
+
const groups = Object.keys(envs[activeEnv].headerGroups || {});
|
|
904
|
+
const activeGroup = groups.includes(saved.activeGroup) ? saved.activeGroup : groups[0] || "default";
|
|
905
|
+
return { activeEnv, activeGroup, envs };
|
|
906
|
+
};
|
|
907
|
+
|
|
908
|
+
const loadStore = () => {
|
|
909
|
+
try {
|
|
910
|
+
const raw = localStorage.getItem(STORE_KEY);
|
|
911
|
+
if (raw) return mergeStore(JSON.parse(raw));
|
|
912
|
+
} catch {}
|
|
913
|
+
return buildDefaultStore();
|
|
914
|
+
};
|
|
915
|
+
|
|
916
|
+
const applyServingBaseUrl = (state) => {
|
|
917
|
+
if (!locationBaseUrl || !state || !state.envs) return state;
|
|
918
|
+
for (const env of Object.values(state.envs)) {
|
|
919
|
+
const variables = env.variables || (env.variables = []);
|
|
920
|
+
const row = variables.find((entry) => entry.key === "baseUrl");
|
|
921
|
+
if (row) row.value = locationBaseUrl;
|
|
922
|
+
else variables.unshift({ key: "baseUrl", value: locationBaseUrl });
|
|
923
|
+
}
|
|
924
|
+
return state;
|
|
925
|
+
};
|
|
926
|
+
|
|
927
|
+
let store = applyServingBaseUrl(loadStore());
|
|
928
|
+
|
|
929
|
+
const persistStore = () => {
|
|
930
|
+
try {
|
|
931
|
+
localStorage.setItem(STORE_KEY, JSON.stringify(store));
|
|
932
|
+
} catch {}
|
|
933
|
+
};
|
|
934
|
+
|
|
935
|
+
const activeEnvConfig = () => store.envs[store.activeEnv] || store.envs[Object.keys(store.envs)[0]];
|
|
936
|
+
|
|
937
|
+
const varMap = () => {
|
|
938
|
+
const env = activeEnvConfig();
|
|
939
|
+
return Object.fromEntries((env.variables || []).filter((row) => row.key).map((row) => [row.key, row.value ?? ""]));
|
|
940
|
+
};
|
|
941
|
+
|
|
942
|
+
const interpolate = (value, vars, depth = 0) => {
|
|
943
|
+
if (value == null || depth > 8) return value;
|
|
944
|
+
if (typeof value === "object") {
|
|
945
|
+
if (Array.isArray(value)) return value.map((item) => interpolate(item, vars, depth));
|
|
946
|
+
return Object.fromEntries(Object.entries(value).map(([key, nested]) => [key, interpolate(nested, vars, depth)]));
|
|
947
|
+
}
|
|
948
|
+
if (typeof value !== "string") return value;
|
|
949
|
+
return value.replace(/\{\{\s*([a-zA-Z0-9_]+)\s*\}\}/g, (_, key) => (key in vars ? String(interpolate(vars[key], vars, depth + 1)) : "{{" + key + "}}"));
|
|
950
|
+
};
|
|
951
|
+
|
|
952
|
+
const resolvedHeadersFromGroup = (groupName) => {
|
|
953
|
+
const env = activeEnvConfig();
|
|
954
|
+
const groups = env.headerGroups || {};
|
|
955
|
+
const group = groups[groupName] || groups[Object.keys(groups)[0]] || [];
|
|
956
|
+
const vars = varMap();
|
|
957
|
+
return Object.fromEntries(group.filter((row) => row.key).map((row) => [row.key, String(interpolate(row.value || "", vars))]));
|
|
958
|
+
};
|
|
959
|
+
|
|
960
|
+
const resolvedHeaders = () => resolvedHeadersFromGroup(store.activeGroup);
|
|
961
|
+
|
|
962
|
+
/** OpenAPI security scheme ids for an operation (union across requirements). */
|
|
963
|
+
const securitySchemeIds = (op) => {
|
|
964
|
+
const requirements = (op && op.security) || spec.security || [];
|
|
965
|
+
if (!Array.isArray(requirements) || !requirements.length) return [];
|
|
966
|
+
const ids = [];
|
|
967
|
+
for (const requirement of requirements) {
|
|
968
|
+
if (!requirement || typeof requirement !== "object") continue;
|
|
969
|
+
for (const id of Object.keys(requirement)) ids.push(id);
|
|
970
|
+
}
|
|
971
|
+
return [...new Set(ids)];
|
|
972
|
+
};
|
|
973
|
+
|
|
974
|
+
/** Stable group name for this op: single scheme, or merged combo (userId+merchantId). */
|
|
975
|
+
const requiredGroupName = (op) => {
|
|
976
|
+
const ids = securitySchemeIds(op);
|
|
977
|
+
if (!ids.length) return null;
|
|
978
|
+
if (ids.length === 1) return ids[0];
|
|
979
|
+
return ids.slice().sort().join("+");
|
|
980
|
+
};
|
|
981
|
+
|
|
982
|
+
/** Fixed hint next to Headers — what this API needs to work. */
|
|
983
|
+
const requiredAuthHint = (op) => {
|
|
984
|
+
const ids = securitySchemeIds(op);
|
|
985
|
+
if (!ids.length) return "";
|
|
986
|
+
return "Required: " + ids.join(" + ");
|
|
987
|
+
};
|
|
988
|
+
|
|
989
|
+
/** Ensure merged combo group exists in the active env (lazy for older localStorage). */
|
|
990
|
+
const ensureRequiredHeaderGroup = (op) => {
|
|
991
|
+
const name = requiredGroupName(op);
|
|
992
|
+
if (!name) return null;
|
|
993
|
+
const env = activeEnvConfig();
|
|
994
|
+
const groups = env.headerGroups || (env.headerGroups = {});
|
|
995
|
+
if (groups[name]) return name;
|
|
996
|
+
const ids = securitySchemeIds(op);
|
|
997
|
+
const byKey = {};
|
|
998
|
+
for (const id of ids) {
|
|
999
|
+
for (const row of groups[id] || []) {
|
|
1000
|
+
if (!row.key) continue;
|
|
1001
|
+
byKey[row.key] = { key: row.key, value: row.value };
|
|
1002
|
+
}
|
|
1003
|
+
}
|
|
1004
|
+
if (!Object.keys(byKey).length) return null;
|
|
1005
|
+
if (!byKey["content-type"]) byKey["content-type"] = { key: "content-type", value: "application/json" };
|
|
1006
|
+
groups[name] = Object.values(byKey);
|
|
1007
|
+
return name;
|
|
1008
|
+
};
|
|
1009
|
+
|
|
1010
|
+
/**
|
|
1011
|
+
* On operation select: switch to the required (possibly merged) group once.
|
|
1012
|
+
* User can still change the group from the top env panel afterward; Send follows that.
|
|
1013
|
+
*/
|
|
1014
|
+
const syncHeaderGroupForOp = (op) => {
|
|
1015
|
+
const name = ensureRequiredHeaderGroup(op);
|
|
1016
|
+
if (!name) return;
|
|
1017
|
+
if (store.activeGroup === name) return;
|
|
1018
|
+
store.activeGroup = name;
|
|
1019
|
+
persistStore();
|
|
1020
|
+
syncEnvTrigger();
|
|
1021
|
+
if (document.getElementById("env-wrap")?.classList.contains("open")) renderEnvPop();
|
|
1022
|
+
};
|
|
1023
|
+
|
|
1024
|
+
const currentBaseUrl = () => String(interpolate(varMap().baseUrl || defaultBaseUrl, varMap()) || defaultBaseUrl).replace(/\/$/, "");
|
|
1025
|
+
|
|
1026
|
+
const envLabel = () => store.activeEnv + " · " + store.activeGroup;
|
|
1027
|
+
|
|
1028
|
+
const syncEnvTrigger = () => {
|
|
1029
|
+
const trigger = document.getElementById("env-trigger");
|
|
1030
|
+
if (trigger) trigger.textContent = envLabel();
|
|
1031
|
+
};
|
|
1032
|
+
|
|
1033
|
+
const renderEnvPop = () => {
|
|
1034
|
+
const env = activeEnvConfig();
|
|
1035
|
+
const envNames = Object.keys(store.envs);
|
|
1036
|
+
const groups = Object.keys(env.headerGroups || {});
|
|
1037
|
+
if (!groups.includes(store.activeGroup)) store.activeGroup = groups[0] || "default";
|
|
1038
|
+
const groupRows = env.headerGroups[store.activeGroup] || [];
|
|
1039
|
+
const canRemoveEnv = envNames.length > 1;
|
|
1040
|
+
const canRemoveGroup = groups.length > 1;
|
|
1041
|
+
|
|
1042
|
+
document.getElementById("env-pop").innerHTML = `
|
|
1043
|
+
<div class="env-block">
|
|
1044
|
+
<div class="env-label">Env</div>
|
|
1045
|
+
<div class="chip-row">
|
|
1046
|
+
${envNames
|
|
1047
|
+
.map((id) => `<button type="button" class="chip-btn ${id === store.activeEnv ? "on" : ""}" data-env="${escapeAttr(id)}">${escapeAttr(id)}</button>`)
|
|
1048
|
+
.join("")}
|
|
1049
|
+
<button type="button" class="ghost-btn" id="add-env" title="Add env">+</button>
|
|
1050
|
+
<button type="button" class="ghost-btn" id="remove-env" title="Remove env" ${canRemoveEnv ? "" : "disabled"}>×</button>
|
|
1051
|
+
</div>
|
|
1052
|
+
</div>
|
|
1053
|
+
<div class="env-block">
|
|
1054
|
+
<div class="env-label">Variables</div>
|
|
1055
|
+
${(env.variables || [])
|
|
1056
|
+
.map(
|
|
1057
|
+
(row, index) => `<div class="env-kv" data-var="${index}">
|
|
1058
|
+
<input class="env-cell" data-field="key" spellcheck="false" value="${escapeAttr(row.key)}" />
|
|
1059
|
+
<input class="env-cell" data-field="value" spellcheck="false" value="${escapeAttr(row.value)}" />
|
|
1060
|
+
<button type="button" class="ghost-btn" data-remove-var="${index}">×</button>
|
|
1061
|
+
</div>`,
|
|
1062
|
+
)
|
|
1063
|
+
.join("")}
|
|
1064
|
+
<button type="button" class="btn env-add" id="add-var">Add variable</button>
|
|
1065
|
+
</div>
|
|
1066
|
+
<div class="env-block">
|
|
1067
|
+
<div class="env-label">Header group</div>
|
|
1068
|
+
<div class="chip-row">
|
|
1069
|
+
${groups
|
|
1070
|
+
.map((group) => `<button type="button" class="chip-btn ${group === store.activeGroup ? "on" : ""}" data-group="${escapeAttr(group)}">${escapeAttr(group)}</button>`)
|
|
1071
|
+
.join("")}
|
|
1072
|
+
<button type="button" class="ghost-btn" id="add-group" title="Add header group">+</button>
|
|
1073
|
+
<button type="button" class="ghost-btn" id="remove-group" title="Remove header group" ${canRemoveGroup ? "" : "disabled"}>×</button>
|
|
1074
|
+
</div>
|
|
1075
|
+
${groupRows
|
|
1076
|
+
.map(
|
|
1077
|
+
(row, index) => `<div class="env-kv" data-hdr="${index}">
|
|
1078
|
+
<input class="env-cell" data-field="key" spellcheck="false" value="${escapeAttr(row.key)}" />
|
|
1079
|
+
<input class="env-cell" data-field="value" spellcheck="false" value="${escapeAttr(row.value)}" />
|
|
1080
|
+
<button type="button" class="ghost-btn" data-remove-hdr="${index}">×</button>
|
|
1081
|
+
</div>`,
|
|
1082
|
+
)
|
|
1083
|
+
.join("")}
|
|
1084
|
+
<button type="button" class="btn env-add" id="add-hdr">Add header</button>
|
|
1085
|
+
</div>
|
|
1086
|
+
`;
|
|
1087
|
+
|
|
1088
|
+
syncEnvTrigger();
|
|
1089
|
+
|
|
1090
|
+
document.getElementById("env-pop").querySelectorAll("[data-env]").forEach((button) => {
|
|
1091
|
+
button.onclick = (event) => {
|
|
1092
|
+
event.stopPropagation();
|
|
1093
|
+
store.activeEnv = button.dataset.env;
|
|
1094
|
+
const nextGroups = Object.keys(activeEnvConfig().headerGroups || {});
|
|
1095
|
+
if (!nextGroups.includes(store.activeGroup)) store.activeGroup = nextGroups[0] || "default";
|
|
1096
|
+
persistStore();
|
|
1097
|
+
renderEnvPop();
|
|
1098
|
+
renderMain();
|
|
1099
|
+
};
|
|
1100
|
+
});
|
|
1101
|
+
document.getElementById("add-env").onclick = (event) => {
|
|
1102
|
+
event.stopPropagation();
|
|
1103
|
+
let name = "env";
|
|
1104
|
+
let n = 1;
|
|
1105
|
+
while (store.envs[name + n]) n += 1;
|
|
1106
|
+
name = name + n;
|
|
1107
|
+
store.envs[name] = cloneDefaultEnv();
|
|
1108
|
+
store.activeEnv = name;
|
|
1109
|
+
store.activeGroup = Object.keys(store.envs[name].headerGroups)[0] || "default";
|
|
1110
|
+
persistStore();
|
|
1111
|
+
renderEnvPop();
|
|
1112
|
+
renderMain();
|
|
1113
|
+
};
|
|
1114
|
+
document.getElementById("remove-env").onclick = (event) => {
|
|
1115
|
+
event.stopPropagation();
|
|
1116
|
+
const names = Object.keys(store.envs);
|
|
1117
|
+
if (names.length <= 1 || !store.envs[store.activeEnv]) return;
|
|
1118
|
+
delete store.envs[store.activeEnv];
|
|
1119
|
+
store.activeEnv = Object.keys(store.envs)[0];
|
|
1120
|
+
const nextGroups = Object.keys(activeEnvConfig().headerGroups || {});
|
|
1121
|
+
store.activeGroup = nextGroups.includes(store.activeGroup) ? store.activeGroup : nextGroups[0] || "default";
|
|
1122
|
+
persistStore();
|
|
1123
|
+
renderEnvPop();
|
|
1124
|
+
renderMain();
|
|
1125
|
+
};
|
|
1126
|
+
document.getElementById("env-pop").querySelectorAll("[data-group]").forEach((button) => {
|
|
1127
|
+
button.onclick = (event) => {
|
|
1128
|
+
event.stopPropagation();
|
|
1129
|
+
store.activeGroup = button.dataset.group;
|
|
1130
|
+
persistStore();
|
|
1131
|
+
renderEnvPop();
|
|
1132
|
+
renderMain();
|
|
1133
|
+
};
|
|
1134
|
+
});
|
|
1135
|
+
document.getElementById("add-group").onclick = (event) => {
|
|
1136
|
+
event.stopPropagation();
|
|
1137
|
+
let name = "group";
|
|
1138
|
+
let n = 1;
|
|
1139
|
+
const groupsMap = activeEnvConfig().headerGroups;
|
|
1140
|
+
while (groupsMap[name + n]) n += 1;
|
|
1141
|
+
name = name + n;
|
|
1142
|
+
groupsMap[name] = [{ key: "content-type", value: "application/json" }];
|
|
1143
|
+
store.activeGroup = name;
|
|
1144
|
+
persistStore();
|
|
1145
|
+
renderEnvPop();
|
|
1146
|
+
renderMain();
|
|
1147
|
+
};
|
|
1148
|
+
document.getElementById("remove-group").onclick = (event) => {
|
|
1149
|
+
event.stopPropagation();
|
|
1150
|
+
const groupsMap = activeEnvConfig().headerGroups;
|
|
1151
|
+
const names = Object.keys(groupsMap || {});
|
|
1152
|
+
if (names.length <= 1 || !groupsMap[store.activeGroup]) return;
|
|
1153
|
+
delete groupsMap[store.activeGroup];
|
|
1154
|
+
store.activeGroup = Object.keys(groupsMap)[0] || "default";
|
|
1155
|
+
persistStore();
|
|
1156
|
+
renderEnvPop();
|
|
1157
|
+
renderMain();
|
|
1158
|
+
};
|
|
1159
|
+
document.getElementById("env-pop").querySelectorAll("[data-var]").forEach((row) => {
|
|
1160
|
+
row.querySelectorAll("input").forEach((input) => {
|
|
1161
|
+
input.oninput = () => {
|
|
1162
|
+
const index = Number(row.dataset.var);
|
|
1163
|
+
const field = input.dataset.field;
|
|
1164
|
+
if (!activeEnvConfig().variables[index] || (field !== "key" && field !== "value")) return;
|
|
1165
|
+
activeEnvConfig().variables[index][field] = input.value;
|
|
1166
|
+
persistStore();
|
|
1167
|
+
syncEnvTrigger();
|
|
1168
|
+
if (field === "value" && activeEnvConfig().variables[index].key === "baseUrl") renderMain();
|
|
1169
|
+
};
|
|
1170
|
+
input.onchange = () => renderMain();
|
|
1171
|
+
});
|
|
1172
|
+
});
|
|
1173
|
+
document.getElementById("env-pop").querySelectorAll("[data-remove-var]").forEach((button) => {
|
|
1174
|
+
button.onclick = (event) => {
|
|
1175
|
+
event.stopPropagation();
|
|
1176
|
+
activeEnvConfig().variables.splice(Number(button.dataset.removeVar), 1);
|
|
1177
|
+
persistStore();
|
|
1178
|
+
renderEnvPop();
|
|
1179
|
+
renderMain();
|
|
1180
|
+
};
|
|
1181
|
+
});
|
|
1182
|
+
document.getElementById("add-var").onclick = (event) => {
|
|
1183
|
+
event.stopPropagation();
|
|
1184
|
+
activeEnvConfig().variables.push({ key: "", value: "" });
|
|
1185
|
+
persistStore();
|
|
1186
|
+
renderEnvPop();
|
|
1187
|
+
};
|
|
1188
|
+
document.getElementById("env-pop").querySelectorAll("[data-hdr]").forEach((row) => {
|
|
1189
|
+
row.querySelectorAll("input").forEach((input) => {
|
|
1190
|
+
input.oninput = () => {
|
|
1191
|
+
const index = Number(row.dataset.hdr);
|
|
1192
|
+
const field = input.dataset.field;
|
|
1193
|
+
const rows = activeEnvConfig().headerGroups[store.activeGroup] || [];
|
|
1194
|
+
if (!rows[index] || (field !== "key" && field !== "value")) return;
|
|
1195
|
+
rows[index][field] = input.value;
|
|
1196
|
+
persistStore();
|
|
1197
|
+
};
|
|
1198
|
+
input.onchange = () => renderMain();
|
|
1199
|
+
});
|
|
1200
|
+
});
|
|
1201
|
+
document.getElementById("env-pop").querySelectorAll("[data-remove-hdr]").forEach((button) => {
|
|
1202
|
+
button.onclick = (event) => {
|
|
1203
|
+
event.stopPropagation();
|
|
1204
|
+
(activeEnvConfig().headerGroups[store.activeGroup] || []).splice(Number(button.dataset.removeHdr), 1);
|
|
1205
|
+
persistStore();
|
|
1206
|
+
renderEnvPop();
|
|
1207
|
+
renderMain();
|
|
1208
|
+
};
|
|
1209
|
+
});
|
|
1210
|
+
document.getElementById("add-hdr").onclick = (event) => {
|
|
1211
|
+
event.stopPropagation();
|
|
1212
|
+
const groupsMap = activeEnvConfig().headerGroups;
|
|
1213
|
+
groupsMap[store.activeGroup] = groupsMap[store.activeGroup] || [];
|
|
1214
|
+
groupsMap[store.activeGroup].push({ key: "", value: "" });
|
|
1215
|
+
persistStore();
|
|
1216
|
+
renderEnvPop();
|
|
1217
|
+
};
|
|
1218
|
+
};
|
|
1219
|
+
|
|
1220
|
+
document.title = "DAxTA";
|
|
1221
|
+
const workspaceEl = document.getElementById("workspace");
|
|
1222
|
+
if (workspace) {
|
|
1223
|
+
workspaceEl.textContent = workspace;
|
|
1224
|
+
workspaceEl.hidden = false;
|
|
1225
|
+
} else {
|
|
1226
|
+
workspaceEl.hidden = true;
|
|
1227
|
+
}
|
|
1228
|
+
document.getElementById("brand").textContent = title;
|
|
1229
|
+
|
|
1230
|
+
const envWrap = document.getElementById("env-wrap");
|
|
1231
|
+
document.getElementById("env-trigger").addEventListener("click", (event) => {
|
|
1232
|
+
event.stopPropagation();
|
|
1233
|
+
envWrap.classList.toggle("open");
|
|
1234
|
+
if (envWrap.classList.contains("open")) renderEnvPop();
|
|
1235
|
+
});
|
|
1236
|
+
document.getElementById("env-pop").addEventListener("click", (event) => event.stopPropagation());
|
|
1237
|
+
renderEnvPop();
|
|
1238
|
+
|
|
1239
|
+
const VIEWER_EXTENSIONS = new Set(["x-viewer", "x-docs", "x-scenarios", "x-tree-segments", "x-workspace"]);
|
|
1240
|
+
|
|
1241
|
+
const toExportSpec = (source) => {
|
|
1242
|
+
const walk = (value) => {
|
|
1243
|
+
if (Array.isArray(value)) return value.map(walk);
|
|
1244
|
+
if (!value || typeof value !== "object") return value;
|
|
1245
|
+
const out = {};
|
|
1246
|
+
for (const [key, child] of Object.entries(value)) {
|
|
1247
|
+
if (VIEWER_EXTENSIONS.has(key)) continue;
|
|
1248
|
+
out[key] = walk(child);
|
|
1249
|
+
}
|
|
1250
|
+
return out;
|
|
1251
|
+
};
|
|
1252
|
+
const exported = walk(source);
|
|
1253
|
+
exported.openapi = exported.openapi || "3.0.3";
|
|
1254
|
+
if (!exported.info) exported.info = { title: title, version: "0.0.0" };
|
|
1255
|
+
if (!exported.paths) exported.paths = {};
|
|
1256
|
+
return exported;
|
|
1257
|
+
};
|
|
1258
|
+
|
|
1259
|
+
const downloadOpenApi = () => {
|
|
1260
|
+
const exported = toExportSpec(spec);
|
|
1261
|
+
const blob = new Blob([JSON.stringify(exported, null, 2) + "\n"], { type: "application/json" });
|
|
1262
|
+
const url = URL.createObjectURL(blob);
|
|
1263
|
+
const link = document.createElement("a");
|
|
1264
|
+
const safeName = String(workspace || title || "openapi")
|
|
1265
|
+
.toLowerCase()
|
|
1266
|
+
.replace(/[^a-z0-9]+/g, "-")
|
|
1267
|
+
.replace(/^-|-$/g, "") || "openapi";
|
|
1268
|
+
link.href = url;
|
|
1269
|
+
link.download = safeName + ".openapi.json";
|
|
1270
|
+
document.body.appendChild(link);
|
|
1271
|
+
link.click();
|
|
1272
|
+
link.remove();
|
|
1273
|
+
URL.revokeObjectURL(url);
|
|
1274
|
+
};
|
|
1275
|
+
|
|
1276
|
+
document.getElementById("export-openapi").addEventListener("click", downloadOpenApi);
|
|
1277
|
+
|
|
1278
|
+
const HTTP = ["get", "post", "put", "patch", "delete"];
|
|
1279
|
+
const STATUS = { 200: "OK", 201: "Created", 204: "No Content", 400: "Bad Request", 401: "Unauthorized", 404: "Not Found", 409: "Conflict", 422: "Unprocessable Entity" };
|
|
1280
|
+
const GROUP_ORDER = ["Success", "Business errors", "Invalid input", "Missing fields", "Auth", "Other"];
|
|
1281
|
+
const METHOD_ORDER = { get: 0, post: 1, put: 2, patch: 3, delete: 4 };
|
|
1282
|
+
|
|
1283
|
+
const ops = [];
|
|
1284
|
+
for (const [path, item] of Object.entries(spec.paths || {})) {
|
|
1285
|
+
for (const method of HTTP) {
|
|
1286
|
+
if (!item[method]) continue;
|
|
1287
|
+
ops.push({
|
|
1288
|
+
id: method + ":" + path,
|
|
1289
|
+
method,
|
|
1290
|
+
path,
|
|
1291
|
+
op: item[method],
|
|
1292
|
+
title: item[method].summary || path,
|
|
1293
|
+
docs: item[method]["x-docs"] || { fields: [] },
|
|
1294
|
+
scenarios: item[method]["x-scenarios"] || [],
|
|
1295
|
+
treeSegments: item[method]["x-tree-segments"] || path.split("/").filter(Boolean),
|
|
1296
|
+
});
|
|
1297
|
+
}
|
|
1298
|
+
}
|
|
1299
|
+
|
|
1300
|
+
const highlight = (value) => {
|
|
1301
|
+
if (value === undefined || value === null || value === "") return "";
|
|
1302
|
+
return JSON.stringify(value, null, 2)
|
|
1303
|
+
.replace(/&/g, "&")
|
|
1304
|
+
.replace(/</g, "<")
|
|
1305
|
+
.replace(/"([^"]+)":/g, '<span class="k">"$1"</span>:')
|
|
1306
|
+
.replace(/: "([^"]*)"/g, ': <span class="s">"$1"</span>')
|
|
1307
|
+
.replace(/: (-?\d+(?:\.\d+)?)/g, ': <span class="n">$1</span>')
|
|
1308
|
+
.replace(/: (true|false|null)/g, ': <span class="p">$1</span>');
|
|
1309
|
+
};
|
|
1310
|
+
|
|
1311
|
+
const copyBodyText = (value) => {
|
|
1312
|
+
if (value === undefined || value === "") return null;
|
|
1313
|
+
if (typeof value === "string") return value;
|
|
1314
|
+
return JSON.stringify(value, null, 2);
|
|
1315
|
+
};
|
|
1316
|
+
|
|
1317
|
+
const copyIcon = `<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><rect x="9" y="9" width="13" height="13" rx="2"/><path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"/></svg>`;
|
|
1318
|
+
|
|
1319
|
+
const showToast = (message) => {
|
|
1320
|
+
let toast = document.getElementById("toast");
|
|
1321
|
+
if (!toast) {
|
|
1322
|
+
toast = document.createElement("div");
|
|
1323
|
+
toast.id = "toast";
|
|
1324
|
+
toast.className = "toast";
|
|
1325
|
+
document.body.appendChild(toast);
|
|
1326
|
+
}
|
|
1327
|
+
toast.textContent = message;
|
|
1328
|
+
toast.classList.add("show");
|
|
1329
|
+
clearTimeout(showToast._timer);
|
|
1330
|
+
showToast._timer = setTimeout(() => toast.classList.remove("show"), 1400);
|
|
1331
|
+
};
|
|
1332
|
+
|
|
1333
|
+
const copy = async (text, button, label) => {
|
|
1334
|
+
try {
|
|
1335
|
+
await navigator.clipboard.writeText(text);
|
|
1336
|
+
if (button && button.classList.contains("icon")) {
|
|
1337
|
+
showToast("Kopyalandı");
|
|
1338
|
+
return;
|
|
1339
|
+
}
|
|
1340
|
+
const previous = button.textContent;
|
|
1341
|
+
button.textContent = "Copied";
|
|
1342
|
+
setTimeout(() => (button.textContent = label || previous), 1200);
|
|
1343
|
+
} catch {}
|
|
1344
|
+
};
|
|
1345
|
+
|
|
1346
|
+
const resolvedUrl = (item, scenario) => {
|
|
1347
|
+
const vars = varMap();
|
|
1348
|
+
let path = item.path;
|
|
1349
|
+
for (const [name, value] of Object.entries(scenario.pathParams || {})) {
|
|
1350
|
+
const fromVar = vars[name] ? String(interpolate(vars[name], vars)) : value;
|
|
1351
|
+
path = path.replace("{" + name + "}", encodeURIComponent(fromVar ?? ""));
|
|
1352
|
+
}
|
|
1353
|
+
const query = { ...(scenario.query || {}) };
|
|
1354
|
+
for (const key of Object.keys(query)) {
|
|
1355
|
+
if (vars[key]) query[key] = String(interpolate(vars[key], vars));
|
|
1356
|
+
}
|
|
1357
|
+
const qs = new URLSearchParams(query).toString();
|
|
1358
|
+
return currentBaseUrl() + path + (qs ? "?" + qs : "");
|
|
1359
|
+
};
|
|
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
|
+
|
|
1383
|
+
const toCurl = (item, scenario) => {
|
|
1384
|
+
const headers = requestHeadersForScenario(scenario);
|
|
1385
|
+
const body = scenario.reqBody !== undefined ? interpolate(scenario.reqBody, varMap()) : undefined;
|
|
1386
|
+
const lines = ["curl -X " + item.method.toUpperCase() + " '" + resolvedUrl(item, scenario).replace(/'/g, "'\\''") + "'"];
|
|
1387
|
+
for (const [name, value] of Object.entries(headers)) {
|
|
1388
|
+
lines.push(" -H '" + name + ": " + String(value).replace(/'/g, "'\\''") + "'");
|
|
1389
|
+
}
|
|
1390
|
+
if (body !== undefined && item.method !== "get") {
|
|
1391
|
+
lines.push(" -d '" + JSON.stringify(body, null, 2).replace(/'/g, "'\\''") + "'");
|
|
1392
|
+
}
|
|
1393
|
+
return lines.join(" \\\n");
|
|
1394
|
+
};
|
|
1395
|
+
|
|
1396
|
+
const proxyUrl = (target) => {
|
|
1397
|
+
try {
|
|
1398
|
+
const absolute = new URL(target, location.href);
|
|
1399
|
+
if (absolute.origin === location.origin) return absolute.href;
|
|
1400
|
+
} catch {}
|
|
1401
|
+
if (location.protocol === "http:" || location.protocol === "https:") {
|
|
1402
|
+
return "/__proxy?target=" + encodeURIComponent(target);
|
|
1403
|
+
}
|
|
1404
|
+
return target;
|
|
1405
|
+
};
|
|
1406
|
+
|
|
1407
|
+
const sendRequest = async (item, scenario) => {
|
|
1408
|
+
const target = resolvedUrl(item, scenario);
|
|
1409
|
+
const headers = { ...requestHeadersForScenario(scenario) };
|
|
1410
|
+
const body = scenario.reqBody !== undefined ? interpolate(scenario.reqBody, varMap()) : undefined;
|
|
1411
|
+
if (body !== undefined && !headers["content-type"] && !headers["Content-Type"]) {
|
|
1412
|
+
headers["content-type"] = "application/json";
|
|
1413
|
+
}
|
|
1414
|
+
const init = {
|
|
1415
|
+
method: item.method.toUpperCase(),
|
|
1416
|
+
headers,
|
|
1417
|
+
};
|
|
1418
|
+
if (body !== undefined && item.method !== "get" && item.method !== "head") {
|
|
1419
|
+
init.body = typeof body === "string" ? body : JSON.stringify(body);
|
|
1420
|
+
}
|
|
1421
|
+
const response = await fetch(proxyUrl(target), init);
|
|
1422
|
+
const text = await response.text();
|
|
1423
|
+
let parsed = text;
|
|
1424
|
+
try {
|
|
1425
|
+
parsed = text ? JSON.parse(text) : undefined;
|
|
1426
|
+
} catch {
|
|
1427
|
+
parsed = text;
|
|
1428
|
+
}
|
|
1429
|
+
return { status: response.status, body: parsed, ok: response.ok };
|
|
1430
|
+
};
|
|
1431
|
+
|
|
1432
|
+
const groupedDropdown = (scenarios, selected) => {
|
|
1433
|
+
const groups = {};
|
|
1434
|
+
scenarios.forEach((scenario, index) => {
|
|
1435
|
+
(groups[scenario.group] ||= []).push({ scenario, index });
|
|
1436
|
+
});
|
|
1437
|
+
const order = GROUP_ORDER.filter((name) => groups[name]).concat(Object.keys(groups).filter((name) => !GROUP_ORDER.includes(name)));
|
|
1438
|
+
const current = scenarios[selected];
|
|
1439
|
+
const label = current ? current.group + " · " + current.name : "Recorded call";
|
|
1440
|
+
return `<div class="dd" id="scenario-dd">
|
|
1441
|
+
<button type="button" class="dd-toggle" id="scenario-toggle">${label}</button>
|
|
1442
|
+
<div class="dd-menu">${order
|
|
1443
|
+
.map(
|
|
1444
|
+
(group) =>
|
|
1445
|
+
`<div class="dd-group">${group}</div>` +
|
|
1446
|
+
groups[group]
|
|
1447
|
+
.map(({ scenario, index }) => `<button type="button" class="dd-item ${index === selected ? "on" : ""}" data-index="${index}">${scenario.status} — ${scenario.name}</button>`)
|
|
1448
|
+
.join(""),
|
|
1449
|
+
)
|
|
1450
|
+
.join("")}</div>
|
|
1451
|
+
</div>`;
|
|
1452
|
+
};
|
|
1453
|
+
|
|
1454
|
+
let currentId = ops[0]?.id;
|
|
1455
|
+
let scenarioIndex = 0;
|
|
1456
|
+
const treePathSegments = (item) => item.treeSegments || item.path.split("/").filter(Boolean);
|
|
1457
|
+
const expandedFolders = new Set(
|
|
1458
|
+
[...new Set(ops.map((item) => treePathSegments(item)[0]).filter(Boolean))].map((version) => "/" + version),
|
|
1459
|
+
);
|
|
1460
|
+
|
|
1461
|
+
const kv = (label, value) => {
|
|
1462
|
+
if (value === undefined || value === "") return "";
|
|
1463
|
+
const shown = typeof value === "object" ? JSON.stringify(value) : String(value);
|
|
1464
|
+
return `<div class="kv" title="${escapeAttr(label)}: ${escapeAttr(shown)}"><div class="kname">${label}</div><div class="kval">${shown}</div></div>`;
|
|
1465
|
+
};
|
|
1466
|
+
|
|
1467
|
+
const metaBlock = (title, bodyHtml, source = "", { always = false } = {}) => {
|
|
1468
|
+
if (!always && !bodyHtml) return "";
|
|
1469
|
+
return `<div class="meta-block">
|
|
1470
|
+
<div class="meta-toolbar">
|
|
1471
|
+
<span class="meta-label">${title}</span>
|
|
1472
|
+
${source ? `<span class="meta-source">${source}</span>` : ""}
|
|
1473
|
+
</div>
|
|
1474
|
+
${bodyHtml || `<div class="meta-empty">—</div>`}
|
|
1475
|
+
</div>`;
|
|
1476
|
+
};
|
|
1477
|
+
|
|
1478
|
+
const buildPathTree = (items) => {
|
|
1479
|
+
const root = { children: {}, ops: [] };
|
|
1480
|
+
for (const item of items) {
|
|
1481
|
+
const parts = treePathSegments(item);
|
|
1482
|
+
let node = root;
|
|
1483
|
+
for (let index = 0; index < parts.length; index += 1) {
|
|
1484
|
+
const part = parts[index];
|
|
1485
|
+
node.children[part] ??= { children: {}, ops: [] };
|
|
1486
|
+
node = node.children[part];
|
|
1487
|
+
if (index === parts.length - 1) node.ops.push(item);
|
|
1488
|
+
}
|
|
1489
|
+
}
|
|
1490
|
+
return root;
|
|
1491
|
+
};
|
|
1492
|
+
|
|
1493
|
+
const expandPathToItem = (item) => {
|
|
1494
|
+
const parts = treePathSegments(item);
|
|
1495
|
+
let prefix = "";
|
|
1496
|
+
for (const part of parts) {
|
|
1497
|
+
prefix += "/" + part;
|
|
1498
|
+
expandedFolders.add(prefix);
|
|
1499
|
+
}
|
|
1500
|
+
};
|
|
1501
|
+
|
|
1502
|
+
const collectVisibleItems = (node) => {
|
|
1503
|
+
const items = [...node.ops];
|
|
1504
|
+
for (const child of Object.values(node.children)) items.push(...collectVisibleItems(child));
|
|
1505
|
+
return items;
|
|
1506
|
+
};
|
|
1507
|
+
|
|
1508
|
+
const renderTreeNode = (node, prefix = "", q = "") => {
|
|
1509
|
+
const opsHtml = [...node.ops]
|
|
1510
|
+
.sort((left, right) => (METHOD_ORDER[left.method] ?? 99) - (METHOD_ORDER[right.method] ?? 99))
|
|
1511
|
+
.map(
|
|
1512
|
+
(item) =>
|
|
1513
|
+
`<button class="nav-item ${item.id === currentId ? "active" : ""}" data-id="${item.id}" title="${item.path}">
|
|
1514
|
+
<span class="method ${item.method}">${item.method}</span>
|
|
1515
|
+
<span class="nav-title">${item.title}</span>
|
|
1516
|
+
</button>`,
|
|
1517
|
+
)
|
|
1518
|
+
.join("");
|
|
1519
|
+
|
|
1520
|
+
const foldersHtml = Object.entries(node.children)
|
|
1521
|
+
.sort(([left], [right]) => left.localeCompare(right))
|
|
1522
|
+
.map(([name, child]) => {
|
|
1523
|
+
const folderPath = (prefix ? prefix + "/" : "/") + name;
|
|
1524
|
+
const subtreeItems = collectVisibleItems(child);
|
|
1525
|
+
if (q && !subtreeItems.some((item) => (item.method + " " + item.path + " " + item.title).toLowerCase().includes(q))) return "";
|
|
1526
|
+
const open = q ? true : expandedFolders.has(folderPath);
|
|
1527
|
+
return `<div class="tree-folder ${open ? "open" : ""}" data-folder="${folderPath}">
|
|
1528
|
+
<button type="button" class="tree-folder-toggle" data-folder="${folderPath}">
|
|
1529
|
+
<span class="chev"></span>
|
|
1530
|
+
<span class="tree-folder-name">${name}</span>
|
|
1531
|
+
</button>
|
|
1532
|
+
<div class="tree-children">${renderTreeNode(child, folderPath, q)}</div>
|
|
1533
|
+
</div>`;
|
|
1534
|
+
})
|
|
1535
|
+
.join("");
|
|
1536
|
+
|
|
1537
|
+
return opsHtml + foldersHtml;
|
|
1538
|
+
};
|
|
1539
|
+
|
|
1540
|
+
const renderNav = () => {
|
|
1541
|
+
const nav = document.getElementById("nav");
|
|
1542
|
+
if (!ops.length) {
|
|
1543
|
+
nav.innerHTML = `<div class="tree-empty">No endpoints recorded</div>`;
|
|
1544
|
+
return;
|
|
1545
|
+
}
|
|
1546
|
+
if (currentId) {
|
|
1547
|
+
const active = ops.find((item) => item.id === currentId);
|
|
1548
|
+
if (active) expandPathToItem(active);
|
|
1549
|
+
}
|
|
1550
|
+
nav.innerHTML = `<div class="tree-root">${renderTreeNode(buildPathTree(ops), "", "")}</div>`;
|
|
1551
|
+
nav.querySelectorAll(".nav-item").forEach((button) => {
|
|
1552
|
+
button.onclick = () => select(button.dataset.id);
|
|
1553
|
+
});
|
|
1554
|
+
nav.querySelectorAll(".tree-folder-toggle").forEach((button) => {
|
|
1555
|
+
button.onclick = (event) => {
|
|
1556
|
+
event.stopPropagation();
|
|
1557
|
+
const folderPath = button.dataset.folder;
|
|
1558
|
+
const folder = button.closest(".tree-folder");
|
|
1559
|
+
if (expandedFolders.has(folderPath)) {
|
|
1560
|
+
expandedFolders.delete(folderPath);
|
|
1561
|
+
folder.classList.remove("open");
|
|
1562
|
+
} else {
|
|
1563
|
+
expandedFolders.add(folderPath);
|
|
1564
|
+
folder.classList.add("open");
|
|
1565
|
+
}
|
|
1566
|
+
};
|
|
1567
|
+
});
|
|
1568
|
+
};
|
|
1569
|
+
|
|
1570
|
+
const escapeHtml = (value) =>
|
|
1571
|
+
String(value ?? "")
|
|
1572
|
+
.replace(/&/g, "&")
|
|
1573
|
+
.replace(/</g, "<")
|
|
1574
|
+
.replace(/>/g, ">")
|
|
1575
|
+
.replace(/"/g, """);
|
|
1576
|
+
|
|
1577
|
+
const highlightMatch = (text, query) => {
|
|
1578
|
+
const raw = String(text ?? "");
|
|
1579
|
+
const q = query.trim();
|
|
1580
|
+
if (!q) return escapeHtml(raw);
|
|
1581
|
+
const lower = raw.toLowerCase();
|
|
1582
|
+
const index = lower.indexOf(q.toLowerCase());
|
|
1583
|
+
if (index < 0) return escapeHtml(raw);
|
|
1584
|
+
return (
|
|
1585
|
+
escapeHtml(raw.slice(0, index)) +
|
|
1586
|
+
"<mark>" +
|
|
1587
|
+
escapeHtml(raw.slice(index, index + q.length)) +
|
|
1588
|
+
"</mark>" +
|
|
1589
|
+
escapeHtml(raw.slice(index + q.length))
|
|
1590
|
+
);
|
|
1591
|
+
};
|
|
1592
|
+
|
|
1593
|
+
let searchActiveIndex = 0;
|
|
1594
|
+
|
|
1595
|
+
const closeSearch = ({ clear = false } = {}) => {
|
|
1596
|
+
const wrap = document.getElementById("search-wrap");
|
|
1597
|
+
const input = document.getElementById("search");
|
|
1598
|
+
wrap.classList.remove("open");
|
|
1599
|
+
document.body.classList.remove("searching");
|
|
1600
|
+
searchActiveIndex = 0;
|
|
1601
|
+
if (clear) input.value = "";
|
|
1602
|
+
};
|
|
1603
|
+
|
|
1604
|
+
const openSearch = () => {
|
|
1605
|
+
document.getElementById("search-wrap").classList.add("open");
|
|
1606
|
+
document.body.classList.add("searching");
|
|
1607
|
+
};
|
|
1608
|
+
|
|
1609
|
+
const renderSearchPanel = (query = "") => {
|
|
1610
|
+
const q = query.trim().toLowerCase();
|
|
1611
|
+
const panel = document.getElementById("search-panel");
|
|
1612
|
+
if (!q) {
|
|
1613
|
+
closeSearch();
|
|
1614
|
+
panel.innerHTML = "";
|
|
1615
|
+
return;
|
|
1616
|
+
}
|
|
1617
|
+
openSearch();
|
|
1618
|
+
const matches = ops.filter((item) => (item.method + " " + item.path + " " + item.title).toLowerCase().includes(q));
|
|
1619
|
+
if (!matches.length) {
|
|
1620
|
+
panel.innerHTML = `<div class="search-empty">No matching endpoints</div>`;
|
|
1621
|
+
return;
|
|
1622
|
+
}
|
|
1623
|
+
if (searchActiveIndex >= matches.length) searchActiveIndex = 0;
|
|
1624
|
+
panel.innerHTML = matches
|
|
1625
|
+
.map(
|
|
1626
|
+
(item, index) => `<button type="button" class="search-hit ${index === searchActiveIndex ? "active" : ""}" data-id="${item.id}" role="option">
|
|
1627
|
+
<span class="method ${item.method}">${item.method}</span>
|
|
1628
|
+
<span class="search-hit-path">${highlightMatch(item.path, q)}</span>
|
|
1629
|
+
</button>`,
|
|
1630
|
+
)
|
|
1631
|
+
.join("");
|
|
1632
|
+
panel.querySelectorAll(".search-hit").forEach((button) => {
|
|
1633
|
+
button.onclick = (event) => {
|
|
1634
|
+
event.stopPropagation();
|
|
1635
|
+
select(button.dataset.id);
|
|
1636
|
+
closeSearch({ clear: true });
|
|
1637
|
+
};
|
|
1638
|
+
});
|
|
1639
|
+
};
|
|
1640
|
+
|
|
1641
|
+
const FIELD_SECTIONS = [
|
|
1642
|
+
{ key: "header", title: "Headers" },
|
|
1643
|
+
{ key: "path", title: "Path" },
|
|
1644
|
+
{ key: "query", title: "Query" },
|
|
1645
|
+
{ key: "body", title: "Body" },
|
|
1646
|
+
];
|
|
1647
|
+
|
|
1648
|
+
const fieldDepth = (name) => {
|
|
1649
|
+
const parts = String(name || "")
|
|
1650
|
+
.replace(/\[\]/g, ".")
|
|
1651
|
+
.split(".")
|
|
1652
|
+
.filter(Boolean);
|
|
1653
|
+
return Math.max(0, parts.length - 1);
|
|
1654
|
+
};
|
|
1655
|
+
|
|
1656
|
+
const rows = (fields) => {
|
|
1657
|
+
if (!fields.length) return "";
|
|
1658
|
+
return fields
|
|
1659
|
+
.map((field) => {
|
|
1660
|
+
const depth = field.in === "body" ? fieldDepth(field.name) : 0;
|
|
1661
|
+
const pad = depth ? ` style="padding-left:${depth * 14}px"` : "";
|
|
1662
|
+
const nestClass = depth ? " nested" : "";
|
|
1663
|
+
return `<div class="row">
|
|
1664
|
+
<div class="name${nestClass}"${pad}>${field.name}</div>
|
|
1665
|
+
<div class="type">${field.in}</div>
|
|
1666
|
+
<div>
|
|
1667
|
+
<div class="type">${field.type}</div>
|
|
1668
|
+
${field.required === true ? `<div class="flag req">Required</div>` : field.required === false ? `<div class="flag">Optional</div>` : ""}
|
|
1669
|
+
</div>
|
|
1670
|
+
</div>`;
|
|
1671
|
+
})
|
|
1672
|
+
.join("");
|
|
1673
|
+
};
|
|
1674
|
+
|
|
1675
|
+
const fieldsPanel = (fields) => {
|
|
1676
|
+
if (!fields.length) return "";
|
|
1677
|
+
const sections = FIELD_SECTIONS.map(({ key, title }) => {
|
|
1678
|
+
const group = fields.filter((field) => field.in === key);
|
|
1679
|
+
if (!group.length) return "";
|
|
1680
|
+
return `<div class="fields-section">
|
|
1681
|
+
<div class="fields-section-title">${title}</div>
|
|
1682
|
+
${rows(group)}
|
|
1683
|
+
</div>`;
|
|
1684
|
+
}).join("");
|
|
1685
|
+
if (!sections) return "";
|
|
1686
|
+
return `<section class="fields"><h2>Fields</h2>${sections}</section>`;
|
|
1687
|
+
};
|
|
1688
|
+
|
|
1689
|
+
const renderMain = () => {
|
|
1690
|
+
const item = ops.find((entry) => entry.id === currentId);
|
|
1691
|
+
if (!item) {
|
|
1692
|
+
document.getElementById("main").innerHTML = `<div class="empty">No operations in this workspace yet. Run integration tests to generate docs.</div>`;
|
|
1693
|
+
return;
|
|
1694
|
+
}
|
|
1695
|
+
if (scenarioIndex >= item.scenarios.length) scenarioIndex = 0;
|
|
1696
|
+
const scenario = item.scenarios[scenarioIndex] || { status: 0, pathParams: {}, query: {}, headers: {}, name: "" };
|
|
1697
|
+
const fields = item.docs.fields || [];
|
|
1698
|
+
ensureRequiredHeaderGroup(item.op);
|
|
1699
|
+
const recordedHeaders = scenario.headers || {};
|
|
1700
|
+
const recordedOk = scenario.status >= 200 && scenario.status < 300;
|
|
1701
|
+
const statusText = STATUS[scenario.status] || item.op.responses?.[String(scenario.status)]?.description || "";
|
|
1702
|
+
const emptyResponse = scenario.resBody === undefined || scenario.status === 204;
|
|
1703
|
+
const reqCopyText = scenario.reqBody !== undefined ? copyBodyText(scenario.reqBody) : null;
|
|
1704
|
+
const showingLive = liveResult && liveResult.id === item.id && liveResult.scenarioIndex === scenarioIndex;
|
|
1705
|
+
const displayStatus = showingLive ? liveResult.status : scenario.status;
|
|
1706
|
+
const displayBody = showingLive ? liveResult.body : scenario.resBody;
|
|
1707
|
+
const displayOk = showingLive ? liveResult.status >= 200 && liveResult.status < 300 : recordedOk;
|
|
1708
|
+
const displayStatusText = STATUS[displayStatus] || (showingLive ? "" : statusText);
|
|
1709
|
+
const displayEmpty = showingLive ? displayBody === undefined || displayBody === "" : emptyResponse;
|
|
1710
|
+
const resCopyText = displayEmpty ? null : copyBodyText(displayBody);
|
|
1711
|
+
const responseTitle = showingLive ? "Live response" : "Recorded response";
|
|
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>`;
|
|
1715
|
+
const pathParamsHtml = Object.entries(scenario.pathParams || {})
|
|
1716
|
+
.map(([name, value]) => kv(name, value))
|
|
1717
|
+
.join("");
|
|
1718
|
+
const queryHtml = Object.entries(scenario.query || {})
|
|
1719
|
+
.map(([name, value]) => kv(name, value))
|
|
1720
|
+
.join("");
|
|
1721
|
+
const bodyHtml =
|
|
1722
|
+
scenario.reqBody !== undefined
|
|
1723
|
+
? `<pre>${highlight(scenario.reqBody)}</pre>`
|
|
1724
|
+
: `<div class="meta-empty">No JSON body</div>`;
|
|
1725
|
+
|
|
1726
|
+
document.getElementById("main").innerHTML = `
|
|
1727
|
+
<div class="head-row">
|
|
1728
|
+
<div>
|
|
1729
|
+
<h1 class="title">${item.title}</h1>
|
|
1730
|
+
<p class="meta-line">${item.method.toUpperCase()} ${item.path}</p>
|
|
1731
|
+
</div>
|
|
1732
|
+
${item.scenarios.length ? groupedDropdown(item.scenarios, scenarioIndex) : ""}
|
|
1733
|
+
</div>
|
|
1734
|
+
<div class="urlbar">
|
|
1735
|
+
<div class="url"><span class="method ${item.method}">${item.method}</span><span>${resolvedUrl(item, scenario)}</span></div>
|
|
1736
|
+
<button class="btn" id="copy-curl" type="button">Copy cURL</button>
|
|
1737
|
+
<button class="btn primary" id="send" type="button">Send</button>
|
|
1738
|
+
</div>
|
|
1739
|
+
<div class="pair">
|
|
1740
|
+
<section class="card" id="request-card">
|
|
1741
|
+
<div class="card-head">
|
|
1742
|
+
<h2>Request</h2>
|
|
1743
|
+
<div class="card-head-actions">
|
|
1744
|
+
<button class="btn sm icon" id="copy-req" type="button" title="Copy body" aria-label="Copy body" ${reqCopyText ? "" : "disabled"}>${copyIcon}</button>
|
|
1745
|
+
</div>
|
|
1746
|
+
</div>
|
|
1747
|
+
<div class="card-body">
|
|
1748
|
+
${metaBlock("Headers", headersHtml, requiredAuthHint(item.op), { always: true })}
|
|
1749
|
+
${metaBlock("Path", pathParamsHtml)}
|
|
1750
|
+
${metaBlock("Query", queryHtml)}
|
|
1751
|
+
${metaBlock("Body", bodyHtml, "", { always: true })}
|
|
1752
|
+
</div>
|
|
1753
|
+
</section>
|
|
1754
|
+
<section class="card response-card" id="response-card">
|
|
1755
|
+
<div class="card-head">
|
|
1756
|
+
<h2>${responseTitle}</h2>
|
|
1757
|
+
<div class="card-head-actions">
|
|
1758
|
+
<button class="btn sm icon" id="copy-res" type="button" title="Copy body" aria-label="Copy body" ${resCopyText ? "" : "disabled"}>${copyIcon}</button>
|
|
1759
|
+
<span><span class="code ${displayOk ? "ok" : ""}">${displayStatus || ""}</span> <span class="code-text">${displayStatusText}</span></span>
|
|
1760
|
+
</div>
|
|
1761
|
+
</div>
|
|
1762
|
+
<div class="card-body" id="response-body">
|
|
1763
|
+
${showingLive && liveResult.error ? `<div class="live-err">${String(liveResult.error).replace(/&/g, "&").replace(/</g, "<")}</div>` : displayEmpty ? `<div class="empty">Empty body</div>` : `<pre>${highlight(displayBody)}</pre>`}
|
|
1764
|
+
</div>
|
|
1765
|
+
</section>
|
|
1766
|
+
</div>
|
|
1767
|
+
${fieldsPanel(fields)}
|
|
1768
|
+
`;
|
|
1769
|
+
|
|
1770
|
+
const scenarioToggle = document.getElementById("scenario-toggle");
|
|
1771
|
+
if (scenarioToggle) {
|
|
1772
|
+
const root = document.getElementById("scenario-dd");
|
|
1773
|
+
scenarioToggle.onclick = (event) => {
|
|
1774
|
+
event.stopPropagation();
|
|
1775
|
+
document.querySelectorAll(".dd.open").forEach((el) => {
|
|
1776
|
+
if (el !== root) el.classList.remove("open");
|
|
1777
|
+
});
|
|
1778
|
+
root.classList.toggle("open");
|
|
1779
|
+
};
|
|
1780
|
+
root.querySelectorAll(".dd-item").forEach((button) => {
|
|
1781
|
+
button.onclick = (event) => {
|
|
1782
|
+
event.stopPropagation();
|
|
1783
|
+
scenarioIndex = Number(button.dataset.index);
|
|
1784
|
+
liveResult = null;
|
|
1785
|
+
root.classList.remove("open");
|
|
1786
|
+
renderMain();
|
|
1787
|
+
};
|
|
1788
|
+
});
|
|
1789
|
+
}
|
|
1790
|
+
|
|
1791
|
+
const syncResponseHeight = () => {
|
|
1792
|
+
const requestCard = document.getElementById("request-card");
|
|
1793
|
+
const responseCard = document.getElementById("response-card");
|
|
1794
|
+
const responseBody = document.getElementById("response-body");
|
|
1795
|
+
if (!requestCard || !responseCard || !responseBody) return;
|
|
1796
|
+
responseCard.style.maxHeight = "";
|
|
1797
|
+
responseBody.style.maxHeight = "";
|
|
1798
|
+
const requestHeight = requestCard.offsetHeight;
|
|
1799
|
+
const head = responseCard.querySelector(".card-head");
|
|
1800
|
+
const headHeight = head ? head.offsetHeight : 0;
|
|
1801
|
+
const maxBody = Math.max(0, requestHeight - headHeight);
|
|
1802
|
+
responseCard.style.maxHeight = requestHeight + "px";
|
|
1803
|
+
responseBody.style.maxHeight = maxBody + "px";
|
|
1804
|
+
};
|
|
1805
|
+
syncResponseHeight();
|
|
1806
|
+
requestAnimationFrame(syncResponseHeight);
|
|
1807
|
+
|
|
1808
|
+
document.getElementById("copy-curl").onclick = (event) => copy(toCurl(item, scenario), event.currentTarget, "Copy cURL");
|
|
1809
|
+
const copyReq = document.getElementById("copy-req");
|
|
1810
|
+
if (copyReq && reqCopyText) copyReq.onclick = (event) => copy(reqCopyText, event.currentTarget, "Copy body");
|
|
1811
|
+
const copyRes = document.getElementById("copy-res");
|
|
1812
|
+
if (copyRes && resCopyText) copyRes.onclick = (event) => copy(resCopyText, event.currentTarget, "Copy body");
|
|
1813
|
+
|
|
1814
|
+
const sendBtn = document.getElementById("send");
|
|
1815
|
+
if (sendBtn) {
|
|
1816
|
+
sendBtn.onclick = async () => {
|
|
1817
|
+
sendBtn.disabled = true;
|
|
1818
|
+
sendBtn.textContent = "Sending…";
|
|
1819
|
+
try {
|
|
1820
|
+
const result = await sendRequest(item, scenario);
|
|
1821
|
+
liveResult = { id: item.id, scenarioIndex, status: result.status, body: result.body };
|
|
1822
|
+
} catch (error) {
|
|
1823
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
1824
|
+
liveResult = {
|
|
1825
|
+
id: item.id,
|
|
1826
|
+
scenarioIndex,
|
|
1827
|
+
status: 0,
|
|
1828
|
+
body: undefined,
|
|
1829
|
+
error:
|
|
1830
|
+
message +
|
|
1831
|
+
"\n\nTip: open docs at the same app port: http://localhost:3000/docs",
|
|
1832
|
+
};
|
|
1833
|
+
}
|
|
1834
|
+
renderMain();
|
|
1835
|
+
};
|
|
1836
|
+
}
|
|
1837
|
+
};
|
|
1838
|
+
|
|
1839
|
+
const select = (id) => {
|
|
1840
|
+
currentId = id;
|
|
1841
|
+
scenarioIndex = 0;
|
|
1842
|
+
liveResult = null;
|
|
1843
|
+
const selected = ops.find((entry) => entry.id === id);
|
|
1844
|
+
if (selected) syncHeaderGroupForOp(selected.op);
|
|
1845
|
+
renderNav();
|
|
1846
|
+
renderMain();
|
|
1847
|
+
history.replaceState(null, "", "#" + encodeURIComponent(id));
|
|
1848
|
+
};
|
|
1849
|
+
|
|
1850
|
+
const searchInput = document.getElementById("search");
|
|
1851
|
+
searchInput.addEventListener("input", (event) => {
|
|
1852
|
+
searchActiveIndex = 0;
|
|
1853
|
+
renderSearchPanel(event.target.value);
|
|
1854
|
+
});
|
|
1855
|
+
searchInput.addEventListener("keydown", (event) => {
|
|
1856
|
+
const panel = document.getElementById("search-panel");
|
|
1857
|
+
const hits = [...panel.querySelectorAll(".search-hit")];
|
|
1858
|
+
if (event.key === "Escape") {
|
|
1859
|
+
closeSearch({ clear: true });
|
|
1860
|
+
searchInput.blur();
|
|
1861
|
+
return;
|
|
1862
|
+
}
|
|
1863
|
+
if (!hits.length) return;
|
|
1864
|
+
if (event.key === "ArrowDown") {
|
|
1865
|
+
event.preventDefault();
|
|
1866
|
+
searchActiveIndex = (searchActiveIndex + 1) % hits.length;
|
|
1867
|
+
renderSearchPanel(searchInput.value);
|
|
1868
|
+
document.querySelectorAll(".search-hit")[searchActiveIndex]?.scrollIntoView({ block: "nearest" });
|
|
1869
|
+
} else if (event.key === "ArrowUp") {
|
|
1870
|
+
event.preventDefault();
|
|
1871
|
+
searchActiveIndex = (searchActiveIndex - 1 + hits.length) % hits.length;
|
|
1872
|
+
renderSearchPanel(searchInput.value);
|
|
1873
|
+
document.querySelectorAll(".search-hit")[searchActiveIndex]?.scrollIntoView({ block: "nearest" });
|
|
1874
|
+
} else if (event.key === "Enter") {
|
|
1875
|
+
event.preventDefault();
|
|
1876
|
+
const target = hits[searchActiveIndex] || hits[0];
|
|
1877
|
+
if (target) {
|
|
1878
|
+
select(target.dataset.id);
|
|
1879
|
+
closeSearch({ clear: true });
|
|
1880
|
+
}
|
|
1881
|
+
}
|
|
1882
|
+
});
|
|
1883
|
+
document.getElementById("search-backdrop").addEventListener("click", () => closeSearch({ clear: true }));
|
|
1884
|
+
document.getElementById("search-wrap").addEventListener("click", (event) => event.stopPropagation());
|
|
1885
|
+
|
|
1886
|
+
document.addEventListener("click", () => {
|
|
1887
|
+
document.querySelectorAll(".dd.open").forEach((el) => el.classList.remove("open"));
|
|
1888
|
+
document.getElementById("env-wrap").classList.remove("open");
|
|
1889
|
+
if (document.body.classList.contains("searching")) closeSearch({ clear: true });
|
|
1890
|
+
});
|
|
1891
|
+
|
|
1892
|
+
const initial = decodeURIComponent(location.hash.replace(/^#/, "")) || ops[0]?.id;
|
|
1893
|
+
select(ops.some((item) => item.id === initial) ? initial : ops[0]?.id);
|
|
1894
|
+
</script>
|
|
1895
|
+
</body>
|
|
1896
|
+
</html>
|