@jaredwray/mockhttp 1.8.1 → 2.0.0

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.
Files changed (64) hide show
  1. package/README.md +29 -7
  2. package/dist/index.d.mts +135 -33
  3. package/dist/index.mjs +360 -342
  4. package/package.json +22 -18
  5. package/site/dist/api/index.html +17983 -0
  6. package/site/dist/api/swagger.json +5487 -0
  7. package/site/dist/changelog/index.html +767 -0
  8. package/site/dist/changelog/page/2/index.html +578 -0
  9. package/site/dist/changelog/v0-1-0/index.html +453 -0
  10. package/site/dist/changelog/v0-2-0/index.html +437 -0
  11. package/site/dist/changelog/v0-2-1/index.html +438 -0
  12. package/site/dist/changelog/v0-2-2/index.html +436 -0
  13. package/site/dist/changelog/v0-2-3/index.html +440 -0
  14. package/site/dist/changelog/v0-3-0/index.html +443 -0
  15. package/site/dist/changelog/v0-4-0/index.html +437 -0
  16. package/site/dist/changelog/v0-4-1/index.html +441 -0
  17. package/site/dist/changelog/v0-4-2/index.html +446 -0
  18. package/site/dist/changelog/v0-4-3/index.html +437 -0
  19. package/site/dist/changelog/v0-5-0/index.html +443 -0
  20. package/site/dist/changelog/v0-6-0/index.html +444 -0
  21. package/site/dist/changelog/v0-6-1/index.html +441 -0
  22. package/site/dist/changelog/v0-7-0/index.html +445 -0
  23. package/site/dist/changelog/v0-8-0/index.html +440 -0
  24. package/site/dist/changelog/v0-9-0/index.html +437 -0
  25. package/site/dist/changelog/v1-0-0/index.html +446 -0
  26. package/site/dist/changelog/v1-0-1/index.html +437 -0
  27. package/site/dist/changelog/v1-1-0/index.html +445 -0
  28. package/site/dist/changelog/v1-2-0/index.html +443 -0
  29. package/site/dist/changelog/v1-3-0/index.html +448 -0
  30. package/site/dist/changelog/v1-4-0/index.html +445 -0
  31. package/site/dist/changelog/v1-5-0/index.html +439 -0
  32. package/site/dist/changelog/v1-5-1/index.html +443 -0
  33. package/site/dist/changelog/v1-6-0/index.html +467 -0
  34. package/site/dist/changelog/v1-7-0/index.html +462 -0
  35. package/site/dist/changelog/v1-8-0/index.html +481 -0
  36. package/site/dist/changelog/v1-8-1/index.html +457 -0
  37. package/site/dist/changelog/v1-9-0/index.html +495 -0
  38. package/site/dist/changelog/v2-0-0/index.html +500 -0
  39. package/site/dist/changelog-latest.json +269 -0
  40. package/site/dist/changelog.json +399 -0
  41. package/site/dist/css/api.css +1113 -0
  42. package/site/dist/css/highlight/highlight.min.js +1433 -0
  43. package/site/dist/css/highlight/styles/base16/docula.css +123 -0
  44. package/site/dist/css/home.css +133 -0
  45. package/site/dist/css/styles.css +1227 -0
  46. package/site/dist/css/variables.css +32 -0
  47. package/site/dist/docs/bins/index.html +942 -0
  48. package/site/dist/docs/configuration/index.html +771 -0
  49. package/site/dist/docs/hosted/index.html +544 -0
  50. package/site/dist/docs/https/index.html +758 -0
  51. package/site/dist/docs/index.html +601 -0
  52. package/site/dist/docs/library/index.html +780 -0
  53. package/site/dist/docs/taps/index.html +708 -0
  54. package/site/dist/favicon.svg +14 -0
  55. package/site/dist/feed.xml +1 -0
  56. package/site/dist/index.html +601 -0
  57. package/site/dist/js/api.js +363 -0
  58. package/site/dist/js/search.js +436 -0
  59. package/site/dist/llms-full.txt +7415 -0
  60. package/site/dist/llms.txt +40 -0
  61. package/site/dist/logo.svg +21 -0
  62. package/site/dist/robots.txt +2 -0
  63. package/site/dist/search-index.json +1 -0
  64. package/site/dist/sitemap.xml +1 -0
@@ -0,0 +1,363 @@
1
+ document.addEventListener('DOMContentLoaded', function() {
2
+ // Toggle operations
3
+ document.querySelectorAll('[data-toggle="operation"]').forEach(function(header) {
4
+ header.addEventListener('click', function() {
5
+ this.closest('.api-operation').classList.toggle('api-operation--collapsed');
6
+ });
7
+ });
8
+
9
+ // Toggle sidebar groups
10
+ document.querySelectorAll('.api-sidebar__group-toggle').forEach(function(btn) {
11
+ btn.addEventListener('click', function() {
12
+ this.closest('.api-sidebar__group').classList.toggle('api-sidebar__group--collapsed');
13
+ });
14
+ });
15
+
16
+ // Code example tabs
17
+ document.querySelectorAll('.api-code-tabs').forEach(function(tabs) {
18
+ var container = tabs.closest('.api-code-examples');
19
+ tabs.querySelectorAll('.api-code-tab').forEach(function(tab) {
20
+ tab.addEventListener('click', function() {
21
+ var target = this.getAttribute('data-tab');
22
+ container.querySelectorAll('.api-code-tab').forEach(function(t) { t.classList.remove('api-code-tab--active'); });
23
+ container.querySelectorAll('.api-code-panel').forEach(function(p) { p.classList.remove('api-code-panel--active'); });
24
+ this.classList.add('api-code-tab--active');
25
+ var panel = container.querySelector('[data-panel="' + target + '"]');
26
+ if (panel) panel.classList.add('api-code-panel--active');
27
+ });
28
+ });
29
+ });
30
+
31
+ // Copy to clipboard
32
+ document.querySelectorAll('[data-copy]').forEach(function(btn) {
33
+ btn.addEventListener('click', function() {
34
+ var code = this.closest('.api-code-panel').querySelector('code');
35
+ if (code) {
36
+ navigator.clipboard.writeText(code.textContent).then(function() {
37
+ btn.textContent = 'Copied!';
38
+ setTimeout(function() { btn.textContent = 'Copy'; }, 2000);
39
+ });
40
+ }
41
+ });
42
+ });
43
+
44
+ // Search
45
+ var searchInput = document.getElementById('api-search');
46
+ if (searchInput) {
47
+ searchInput.addEventListener('input', function() {
48
+ var query = this.value.toLowerCase();
49
+ document.querySelectorAll('.api-sidebar__item').forEach(function(item) {
50
+ var path = (item.getAttribute('data-path') || '').toLowerCase();
51
+ var method = (item.getAttribute('data-method') || '').toLowerCase();
52
+ var text = item.textContent.toLowerCase();
53
+ var match = !query || path.indexOf(query) !== -1 || method.indexOf(query) !== -1 || text.indexOf(query) !== -1;
54
+ item.style.display = match ? '' : 'none';
55
+ });
56
+ document.querySelectorAll('.api-operation').forEach(function(op) {
57
+ var path = (op.querySelector('.api-operation__path') || {}).textContent || '';
58
+ var summary = (op.querySelector('.api-operation__summary') || {}).textContent || '';
59
+ var method = (op.querySelector('.method-badge') || {}).textContent || '';
60
+ var match = !query || path.toLowerCase().indexOf(query) !== -1 || summary.toLowerCase().indexOf(query) !== -1 || method.toLowerCase().indexOf(query) !== -1;
61
+ op.style.display = match ? '' : 'none';
62
+ });
63
+ document.querySelectorAll('.api-group').forEach(function(group) {
64
+ var visible = group.querySelectorAll('.api-operation:not([style*="display: none"])');
65
+ group.style.display = visible.length > 0 || !query ? '' : 'none';
66
+ });
67
+ });
68
+ }
69
+
70
+ // Scroll spy
71
+ var sidebarLinks = document.querySelectorAll('.api-sidebar__item');
72
+ if (sidebarLinks.length > 0) {
73
+ var observer = new IntersectionObserver(function(entries) {
74
+ entries.forEach(function(entry) {
75
+ if (entry.isIntersecting) {
76
+ sidebarLinks.forEach(function(l) { l.classList.remove('api-sidebar__item--active'); });
77
+ var link = document.querySelector('.api-sidebar__item[href="#' + entry.target.id + '"]');
78
+ if (link) link.classList.add('api-sidebar__item--active');
79
+ }
80
+ });
81
+ }, { rootMargin: '-80px 0px -70% 0px' });
82
+
83
+ document.querySelectorAll('.api-operation').forEach(function(op) {
84
+ observer.observe(op);
85
+ });
86
+ }
87
+
88
+ // Mobile sidebar toggle
89
+ var sidebarToggle = document.getElementById('api-sidebar-toggle');
90
+ var sidebar = document.getElementById('api-sidebar');
91
+ if (sidebarToggle && sidebar) {
92
+ sidebarToggle.addEventListener('click', function() {
93
+ sidebar.classList.toggle('api-sidebar--mobile-open');
94
+ });
95
+ sidebar.querySelectorAll('.api-sidebar__item').forEach(function(link) {
96
+ link.addEventListener('click', function() {
97
+ sidebar.classList.remove('api-sidebar--mobile-open');
98
+ });
99
+ });
100
+ }
101
+
102
+ // Collapse sidebar groups that have a toggle button (named groups only)
103
+ document.querySelectorAll('.api-sidebar__group').forEach(function(group) {
104
+ if (group.querySelector('.api-sidebar__group-toggle')) {
105
+ group.classList.add('api-sidebar__group--collapsed');
106
+ }
107
+ });
108
+
109
+ // Auth type selector: show/hide value input based on OpenAPI securitySchemes
110
+ // IDs are indexed for multi-spec (e.g. api-auth-type-0), so find by class
111
+ var authTypeSelect = document.querySelector('.api-auth__type');
112
+ var authValueInput = document.querySelector('.api-auth__value');
113
+ var cookieStatusEl = document.querySelector('.api-auth__cookie-status');
114
+ if (authTypeSelect && authValueInput) {
115
+ function getSelectedSchemeData() {
116
+ var option = authTypeSelect.options[authTypeSelect.selectedIndex];
117
+ return {
118
+ key: option.value,
119
+ type: option.getAttribute('data-scheme-type'),
120
+ scheme: option.getAttribute('data-scheme-scheme'),
121
+ name: option.getAttribute('data-scheme-name'),
122
+ inLocation: option.getAttribute('data-scheme-in')
123
+ };
124
+ }
125
+ function updateAuthUI() {
126
+ var data = getSelectedSchemeData();
127
+ if (data.key === 'none') {
128
+ authValueInput.classList.add('api-auth__value--hidden');
129
+ authValueInput.value = '';
130
+ if (cookieStatusEl) cookieStatusEl.classList.add('api-auth__cookie-status--hidden');
131
+ } else if (data.type === 'apiKey' && data.inLocation === 'cookie') {
132
+ authValueInput.classList.add('api-auth__value--hidden');
133
+ authValueInput.value = '';
134
+ if (cookieStatusEl) {
135
+ cookieStatusEl.classList.remove('api-auth__cookie-status--hidden');
136
+ var auth = window.__doculaAuth || { loggedIn: false };
137
+ cookieStatusEl.textContent = auth.loggedIn ? 'Logged in' : 'Not logged in — use Login button above';
138
+ cookieStatusEl.className = 'api-auth__cookie-status' + (auth.loggedIn ? ' api-auth__cookie-status--ok' : ' api-auth__cookie-status--warn');
139
+ }
140
+ } else {
141
+ authValueInput.classList.remove('api-auth__value--hidden');
142
+ if (data.type === 'apiKey') {
143
+ authValueInput.placeholder = 'Enter API key...';
144
+ } else if (data.scheme === 'bearer') {
145
+ authValueInput.placeholder = 'Enter bearer token...';
146
+ } else {
147
+ authValueInput.placeholder = 'Enter value...';
148
+ }
149
+ if (cookieStatusEl) cookieStatusEl.classList.add('api-auth__cookie-status--hidden');
150
+ }
151
+ }
152
+ var savedAuth = localStorage.getItem('docula-api-auth-type');
153
+ if (savedAuth) {
154
+ for (var i = 0; i < authTypeSelect.options.length; i++) {
155
+ if (authTypeSelect.options[i].value === savedAuth) {
156
+ authTypeSelect.selectedIndex = i;
157
+ break;
158
+ }
159
+ }
160
+ }
161
+ authTypeSelect.addEventListener('change', function() {
162
+ localStorage.setItem('docula-api-auth-type', authTypeSelect.value);
163
+ updateAuthUI();
164
+ });
165
+ document.addEventListener('docula-auth-change', updateAuthUI);
166
+ updateAuthUI();
167
+ }
168
+
169
+ // Helper: expand an operation and its corresponding sidebar group
170
+ function expandOperationAndGroup(operationEl) {
171
+ if (!operationEl) return;
172
+ operationEl.classList.remove('api-operation--collapsed');
173
+ var contentGroup = operationEl.closest('.api-group');
174
+ if (contentGroup) {
175
+ var groupId = contentGroup.id.replace(/^group-/, '');
176
+ var sidebarGroup = document.querySelector('.api-sidebar__group[data-group="' + groupId + '"]');
177
+ if (sidebarGroup) sidebarGroup.classList.remove('api-sidebar__group--collapsed');
178
+ }
179
+ }
180
+
181
+ // Expand operation via hash, or expand the first operation by default
182
+ if (window.location.hash) {
183
+ var target = document.querySelector(window.location.hash);
184
+ if (target && target.classList.contains('api-operation')) {
185
+ expandOperationAndGroup(target);
186
+ }
187
+ } else {
188
+ expandOperationAndGroup(document.querySelector('.api-operation'));
189
+ }
190
+
191
+ window.addEventListener('hashchange', function() {
192
+ if (window.location.hash) {
193
+ var target = document.querySelector(window.location.hash);
194
+ if (target && target.classList.contains('api-operation')) {
195
+ expandOperationAndGroup(target);
196
+ }
197
+ }
198
+ });
199
+
200
+ // Try It - Response tab switching
201
+ document.querySelectorAll('.api-try-it__response-tabs').forEach(function(tabs) {
202
+ var container = tabs.closest('.api-try-it__response');
203
+ tabs.querySelectorAll('.api-try-it__rtab').forEach(function(tab) {
204
+ tab.addEventListener('click', function() {
205
+ var target = this.getAttribute('data-try-rtab');
206
+ container.querySelectorAll('.api-try-it__rtab').forEach(function(t) { t.classList.remove('api-try-it__rtab--active'); });
207
+ container.querySelectorAll('.api-try-it__rpanel').forEach(function(p) { p.classList.remove('api-try-it__rpanel--active'); });
208
+ this.classList.add('api-try-it__rtab--active');
209
+ var panel = container.querySelector('[data-try-rpanel="' + target + '"]');
210
+ if (panel) panel.classList.add('api-try-it__rpanel--active');
211
+ });
212
+ });
213
+ });
214
+
215
+ // Try It - Helpers
216
+ function getStatusClass(status) {
217
+ if (status >= 200 && status < 300) return '2xx';
218
+ if (status >= 300 && status < 400) return '3xx';
219
+ if (status >= 400 && status < 500) return '4xx';
220
+ if (status >= 500) return '5xx';
221
+ return 'error';
222
+ }
223
+
224
+ function formatBody(text, contentType) {
225
+ if (contentType && contentType.indexOf('json') !== -1) {
226
+ try { return JSON.stringify(JSON.parse(text), null, 2); } catch(e) { /* ignore */ }
227
+ }
228
+ return text;
229
+ }
230
+
231
+ function resetResponseTabs(responseArea) {
232
+ var tabs = responseArea.querySelectorAll('.api-try-it__rtab');
233
+ var panels = responseArea.querySelectorAll('.api-try-it__rpanel');
234
+ tabs.forEach(function(t) { t.classList.remove('api-try-it__rtab--active'); });
235
+ panels.forEach(function(p) { p.classList.remove('api-try-it__rpanel--active'); });
236
+ tabs[0].classList.add('api-try-it__rtab--active');
237
+ panels[0].classList.add('api-try-it__rpanel--active');
238
+ }
239
+
240
+ // Try It - Send request
241
+ document.querySelectorAll('[data-try-send]').forEach(function(btn) {
242
+ btn.addEventListener('click', function() {
243
+ var tryIt = this.closest('.api-try-it');
244
+ var method = tryIt.getAttribute('data-method');
245
+ var pathTemplate = tryIt.getAttribute('data-path');
246
+ var serverSelect = tryIt.querySelector('[data-try-server]');
247
+ var baseUrl = serverSelect ? serverSelect.value : '';
248
+
249
+ // Substitute path params
250
+ var path = pathTemplate;
251
+ tryIt.querySelectorAll('[data-param-in="path"]').forEach(function(row) {
252
+ var name = row.getAttribute('data-param-name');
253
+ var value = row.querySelector('[data-try-param]').value;
254
+ if (value) {
255
+ path = path.replace('{' + name + '}', encodeURIComponent(value));
256
+ }
257
+ });
258
+
259
+ // Build query string
260
+ var queryParts = [];
261
+ tryIt.querySelectorAll('[data-param-in="query"]').forEach(function(row) {
262
+ var name = row.getAttribute('data-param-name');
263
+ var value = row.querySelector('[data-try-param]').value;
264
+ if (value) queryParts.push(encodeURIComponent(name) + '=' + encodeURIComponent(value));
265
+ });
266
+ var queryString = queryParts.length ? '?' + queryParts.join('&') : '';
267
+
268
+ // Build headers
269
+ var headers = {};
270
+ tryIt.querySelectorAll('[data-param-in="header"]').forEach(function(row) {
271
+ var name = row.getAttribute('data-param-name');
272
+ var value = row.querySelector('[data-try-param]').value;
273
+ if (value) headers[name] = value;
274
+ });
275
+
276
+ // Inject global auth header from selected security scheme
277
+ var authType = document.querySelector('.api-auth__type');
278
+ var authValue = document.querySelector('.api-auth__value');
279
+ var useCookieAuth = false;
280
+ if (authType && authType.value !== 'none') {
281
+ var authOption = authType.options[authType.selectedIndex];
282
+ var schemeType = authOption.getAttribute('data-scheme-type');
283
+ var schemeName = authOption.getAttribute('data-scheme-name');
284
+ var schemeIn = authOption.getAttribute('data-scheme-in');
285
+ var schemeScheme = authOption.getAttribute('data-scheme-scheme');
286
+ if (schemeType === 'apiKey' && schemeIn === 'cookie') {
287
+ useCookieAuth = true;
288
+ } else if (authValue && authValue.value.trim()) {
289
+ var authVal = authValue.value.trim();
290
+ if (schemeType === 'apiKey' && schemeIn === 'header' && schemeName) {
291
+ headers[schemeName] = authVal;
292
+ } else if (schemeType === 'http' && schemeScheme === 'bearer') {
293
+ headers['Authorization'] = 'Bearer ' + authVal;
294
+ } else if (schemeType === 'apiKey' && schemeIn === 'query' && schemeName) {
295
+ queryParts.push(encodeURIComponent(schemeName) + '=' + encodeURIComponent(authVal));
296
+ queryString = '?' + queryParts.join('&');
297
+ }
298
+ }
299
+ }
300
+
301
+ // Body
302
+ var bodyTextarea = tryIt.querySelector('[data-try-body]');
303
+ var body = bodyTextarea ? bodyTextarea.value.trim() : '';
304
+ if (body && !headers['Content-Type']) {
305
+ headers['Content-Type'] = tryIt.getAttribute('data-content-type') || 'application/json';
306
+ }
307
+
308
+ var url = baseUrl + path + queryString;
309
+ var fetchOptions = { method: method, headers: headers };
310
+ if (useCookieAuth) {
311
+ fetchOptions.credentials = 'include';
312
+ }
313
+ if (body && method !== 'GET' && method !== 'HEAD') {
314
+ fetchOptions.body = body;
315
+ }
316
+
317
+ // Loading state
318
+ btn.disabled = true;
319
+ btn.textContent = 'Sending...';
320
+ var startTime = performance.now();
321
+
322
+ var responseArea = tryIt.querySelector('[data-try-response]');
323
+ var statusEl = tryIt.querySelector('[data-try-status]');
324
+ var timeEl = tryIt.querySelector('[data-try-time]');
325
+ var bodyEl = tryIt.querySelector('[data-try-response-body]');
326
+ var headersEl = tryIt.querySelector('[data-try-response-headers]');
327
+
328
+ fetch(url, fetchOptions).then(function(response) {
329
+ var elapsed = Math.round(performance.now() - startTime);
330
+ var statusClass = getStatusClass(response.status);
331
+
332
+ statusEl.textContent = response.status + ' ' + response.statusText;
333
+ statusEl.className = 'api-try-it__response-status api-try-it__response-status--' + statusClass;
334
+ timeEl.textContent = elapsed + 'ms';
335
+
336
+ // Collect response headers
337
+ var headerLines = [];
338
+ response.headers.forEach(function(value, key) {
339
+ headerLines.push(key + ': ' + value);
340
+ });
341
+ headersEl.textContent = headerLines.join('\n') || 'No headers';
342
+
343
+ var ct = response.headers.get('content-type') || '';
344
+ return response.text().then(function(text) {
345
+ bodyEl.textContent = formatBody(text, ct);
346
+ responseArea.classList.remove('api-try-it__response--hidden');
347
+ resetResponseTabs(responseArea);
348
+ });
349
+ }).catch(function(err) {
350
+ statusEl.textContent = 'Error';
351
+ statusEl.className = 'api-try-it__response-status api-try-it__response-status--error';
352
+ timeEl.textContent = '';
353
+ headersEl.textContent = '';
354
+ bodyEl.textContent = 'Request failed: ' + err.message + '\n\nThis may be caused by CORS restrictions. The API server must include appropriate CORS headers to allow browser requests.';
355
+ responseArea.classList.remove('api-try-it__response--hidden');
356
+ resetResponseTabs(responseArea);
357
+ }).finally(function() {
358
+ btn.disabled = false;
359
+ btn.textContent = 'Send Request';
360
+ });
361
+ });
362
+ });
363
+ });