@scalar/api-client 2.2.44 → 2.2.45

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 (67) hide show
  1. package/CHANGELOG.md +26 -0
  2. package/dist/components/CodeInput/CodeInput.vue.d.ts.map +1 -1
  3. package/dist/components/CodeInput/CodeInput.vue.js +1 -1
  4. package/dist/components/CodeInput/CodeInput.vue2.js +37 -37
  5. package/dist/components/EmptyState.vue.d.ts +3 -0
  6. package/dist/components/EmptyState.vue.d.ts.map +1 -0
  7. package/dist/components/EmptyState.vue.js +7 -0
  8. package/dist/components/EmptyState.vue2.js +31 -0
  9. package/dist/components/Form/Form.vue.js +1 -1
  10. package/dist/components/ScalarHotkey.vue.d.ts.map +1 -1
  11. package/dist/components/ScalarHotkey.vue.js +12 -7
  12. package/dist/components/Sidebar/SidebarListElement.vue.js +2 -2
  13. package/dist/layouts/App/create-api-client-app.d.ts +2 -2
  14. package/dist/layouts/Modal/create-api-client-modal.d.ts +4 -4
  15. package/dist/layouts/Web/create-api-client-web.d.ts +2 -2
  16. package/dist/libs/create-client.d.ts +2 -2
  17. package/dist/libs/index.js +31 -33
  18. package/dist/libs/send-request/build-request-security.d.ts +17 -0
  19. package/dist/libs/send-request/build-request-security.d.ts.map +1 -0
  20. package/dist/libs/send-request/build-request-security.js +31 -0
  21. package/dist/libs/send-request/create-fetch-body.d.ts +18 -0
  22. package/dist/libs/send-request/create-fetch-body.d.ts.map +1 -0
  23. package/dist/libs/send-request/create-fetch-body.js +26 -0
  24. package/dist/libs/send-request/create-fetch-headers.d.ts +4 -0
  25. package/dist/libs/send-request/create-fetch-headers.d.ts.map +1 -0
  26. package/dist/libs/send-request/create-fetch-headers.js +11 -0
  27. package/dist/libs/send-request/create-fetch-query-params.d.ts +4 -0
  28. package/dist/libs/send-request/create-fetch-query-params.d.ts.map +1 -0
  29. package/dist/libs/send-request/create-fetch-query-params.js +10 -0
  30. package/dist/libs/send-request/create-request-operation.d.ts +29 -0
  31. package/dist/libs/send-request/create-request-operation.d.ts.map +1 -0
  32. package/dist/libs/send-request/create-request-operation.js +107 -0
  33. package/dist/libs/send-request/decode-buffer.d.ts +3 -0
  34. package/dist/libs/send-request/decode-buffer.d.ts.map +1 -0
  35. package/dist/libs/send-request/decode-buffer.js +9 -0
  36. package/dist/libs/send-request/index.d.ts +2 -1
  37. package/dist/libs/send-request/index.d.ts.map +1 -1
  38. package/dist/libs/send-request/index.js +4 -6
  39. package/dist/store/request-example.d.ts +2 -2
  40. package/dist/store/store.d.ts +2 -2
  41. package/dist/style.css +1 -1
  42. package/dist/views/Cookies/CookieModal.vue.d.ts.map +1 -1
  43. package/dist/views/Cookies/CookieModal.vue.js +2 -2
  44. package/dist/views/Cookies/CookieModal.vue2.js +11 -11
  45. package/dist/views/Cookies/Cookies.vue.d.ts.map +1 -1
  46. package/dist/views/Cookies/Cookies.vue2.js +37 -36
  47. package/dist/views/Request/Request.vue2.js +1 -1
  48. package/dist/views/Request/RequestSection/RequestBody.vue.d.ts.map +1 -1
  49. package/dist/views/Request/RequestSection/RequestBody.vue.js +1 -1
  50. package/dist/views/Request/RequestSection/RequestBody.vue2.js +89 -87
  51. package/dist/views/Request/RequestSection/RequestParams.vue.d.ts.map +1 -1
  52. package/dist/views/Request/RequestSection/RequestParams.vue.js +47 -45
  53. package/dist/views/Request/RequestSection/RequestTable.vue.d.ts.map +1 -1
  54. package/dist/views/Request/RequestSection/RequestTable.vue.js +1 -1
  55. package/dist/views/Request/RequestSection/RequestTable.vue2.js +8 -7
  56. package/dist/views/Request/RequestSidebarItem.vue.d.ts.map +1 -1
  57. package/dist/views/Request/RequestSidebarItem.vue.js +2 -2
  58. package/dist/views/Request/RequestSidebarItem.vue2.js +97 -104
  59. package/dist/views/Request/ResponseSection/ResponseEmpty.vue.d.ts.map +1 -1
  60. package/dist/views/Request/ResponseSection/ResponseEmpty.vue.js +2 -2
  61. package/dist/views/Request/ResponseSection/ResponseEmpty.vue2.js +39 -57
  62. package/dist/views/Servers/Servers.vue.d.ts.map +1 -1
  63. package/dist/views/Servers/Servers.vue2.js +74 -71
  64. package/package.json +10 -10
  65. package/dist/libs/send-request/send-request.d.ts +0 -51
  66. package/dist/libs/send-request/send-request.d.ts.map +0 -1
  67. package/dist/libs/send-request/send-request.js +0 -177
@@ -1,177 +0,0 @@
1
- import { ERRORS as D, normalizeError as v } from "../errors.js";
2
- import { normalizeHeaders as F } from "../normalize-headers.js";
3
- import { setRequestCookies as _, getCookieHeader as z } from "./set-request-cookies.js";
4
- import { replaceTemplateVariables as d } from "../string-template.js";
5
- import { canMethodHaveBody as K, isRelativePath as B, concatenateUrlAndPath as M, shouldUseProxy as P, REGEX as W } from "@scalar/oas-utils/helpers";
6
- import X from "whatwg-mimetype";
7
- import { textMediaTypes as Y } from "../../views/Request/consts/mediaTypes.js";
8
- function j(n, o) {
9
- const s = new X(o);
10
- return Y.includes(s.essence) ? new TextDecoder(s.parameters.get("charset")).decode(n) : new Blob([n], { type: s.essence });
11
- }
12
- function I(n, o) {
13
- const s = {};
14
- return n.parameters.headers.forEach((a) => {
15
- const f = a.key.trim().toLowerCase();
16
- a.enabled && (f !== "content-type" || a.value !== "multipart/form-data") && (s[f] = d(a.value, o));
17
- }), s;
18
- }
19
- function N(n, o) {
20
- const s = new URLSearchParams();
21
- return n.parameters.query.forEach((a) => {
22
- a.enabled && (a.type === "array" ? d(a.value ?? "", o).split(",") : [d(a.value ?? "", o)]).forEach((w) => s.append(a.key, w.trim()));
23
- }), s;
24
- }
25
- function Q(n, o, s) {
26
- var a, f, w;
27
- if (!K(n))
28
- return { body: void 0, contentType: void 0 };
29
- if (o.body.activeBody === "formData" && o.body.formData) {
30
- const g = o.body.formData.encoding === "form-data" ? "multipart/form-data" : "application/x-www-form-urlencoded", r = o.body.formData.encoding === "form-data" ? new FormData() : new URLSearchParams();
31
- return o.body.formData.value.forEach((t) => {
32
- !t.enabled || !t.key || (t.file && r instanceof FormData ? r.append(t.key, t.file, t.file.name) : t.value !== void 0 && r.append(t.key, d(t.value, s)));
33
- }), { body: r, contentType: g };
34
- }
35
- return o.body.activeBody === "raw" ? {
36
- body: d(((a = o.body.raw) == null ? void 0 : a.value) ?? "", s),
37
- contentType: (f = o.body.raw) == null ? void 0 : f.encoding
38
- } : o.body.activeBody === "binary" ? {
39
- body: o.body.binary,
40
- contentType: (w = o.body.binary) == null ? void 0 : w.type
41
- } : {
42
- body: void 0,
43
- contentType: void 0
44
- };
45
- }
46
- function V(n) {
47
- return W.PATH.test(n) || n.startsWith("http://") || n.startsWith("https://") ? n : `http://${n}`;
48
- }
49
- const E = "YOUR_SECRET_TOKEN", re = ({
50
- environment: n,
51
- example: o,
52
- globalCookies: s,
53
- proxyUrl: a,
54
- request: f,
55
- securitySchemes: w,
56
- selectedSecuritySchemeUids: g = [],
57
- server: r,
58
- status: t
59
- }) => {
60
- try {
61
- const c = n ?? {}, C = new AbortController(), L = o.parameters.path.reduce((m, e) => (e.enabled && (m[e.key] = d(e.value, c)), m), {}), q = d((r == null ? void 0 : r.url) ?? "", c), b = d(f.path, L);
62
- let i = q || b;
63
- if (!i) throw D.URL_EMPTY;
64
- Object.entries((r == null ? void 0 : r.variables) ?? {}).forEach(([m, e]) => {
65
- i = d(i, {
66
- [m]: L[m] || e.default
67
- });
68
- });
69
- const R = N(o, c), l = I(o, c), { body: H } = Q(f.method, o, c), { cookieParams: S } = _({
70
- example: o,
71
- env: c,
72
- globalCookies: s,
73
- serverUrl: i,
74
- proxyUrl: a
75
- }), k = g.flat();
76
- if (k == null || k.forEach((m) => {
77
- var y;
78
- const e = w[m];
79
- if (e) {
80
- if (e.type === "apiKey") {
81
- const h = d(e.value, c) || E;
82
- e.in === "header" && (l[e.name] = h), e.in === "query" && R.append(e.name, h), e.in === "cookie" && S.push({
83
- name: e.name,
84
- value: h,
85
- path: "/",
86
- uid: e.name
87
- });
88
- }
89
- if (e.type === "http")
90
- if (e.scheme === "basic") {
91
- const h = d(e.username, c), u = d(e.password, c), p = `${h}:${u}`;
92
- l.Authorization = `Basic ${p === ":" ? "username:password" : btoa(p)}`;
93
- } else {
94
- const h = d(e.token, c);
95
- l.Authorization = `Bearer ${h || E}`;
96
- }
97
- if (e.type === "oauth2") {
98
- const u = (y = Object.values(e.flows).find((p) => p.token)) == null ? void 0 : y.token;
99
- l.Authorization = `Bearer ${u || E}`;
100
- }
101
- }
102
- }), i && (!B(i) || typeof window < "u")) {
103
- const m = B(i) ? M(window.location.origin, i) : V(i), e = new URL(m), y = new URL(b, e.origin), h = b.split("?")[0] ?? "", u = new URL(e);
104
- r != null && r.url && (e.pathname === "/" ? u.pathname = h : u.pathname = e.pathname + h);
105
- const p = r != null && r.url ? [...e.searchParams, ...y.searchParams, ...R] : [...y.searchParams, ...R];
106
- u.search = new URLSearchParams(p).toString(), i = u.toString();
107
- }
108
- const T = d(
109
- z(S, l.Cookie),
110
- c
111
- );
112
- T && (P(a, i) ? (console.warn(
113
- "We’re using a `X-Scalar-Cookie` custom header to the request. The proxy will forward this as a `Cookie` header. We do this to avoid the browser omitting the `Cookie` header for cross-origin requests for security reasons."
114
- ), l["X-Scalar-Cookie"] = T) : (console.warn(
115
- `We’re trying to add a Cookie header, but browsers often omit them for cross-origin requests for various security reasons. If it’s not working, that’s probably why. Here are the requirements for it to work:
116
-
117
- - The browser URL must be on the same domain as the server URL.
118
- - The connection must be made over HTTPS.
119
- `
120
- ), l.Cookie = T));
121
- const A = new URLSearchParams([["scalar_url", i.toString()]]), O = P(a, i) ? `${a}?${A.toString()}` : i, U = new Request(O, {
122
- method: f.method.toUpperCase(),
123
- body: H,
124
- headers: l
125
- });
126
- return [
127
- null,
128
- {
129
- request: U,
130
- sendRequest: async () => {
131
- t == null || t.emit("start");
132
- const m = Date.now();
133
- try {
134
- const e = await fetch(U, {
135
- signal: C.signal
136
- });
137
- t == null || t.emit("stop");
138
- const y = F(
139
- e.headers,
140
- P(a, i)
141
- ), h = e.headers.get("content-type") ?? "text/plain;charset=UTF-8", u = await e.arrayBuffer(), p = j(u, h), $ = "getSetCookie" in e.headers && typeof e.headers.getSetCookie == "function" ? e.headers.getSetCookie() : [];
142
- return [
143
- null,
144
- {
145
- timestamp: Date.now(),
146
- request: o,
147
- response: {
148
- ...e,
149
- headers: y,
150
- cookieHeaderKeys: $,
151
- data: p,
152
- size: u.byteLength,
153
- duration: Date.now() - m,
154
- method: f.method,
155
- status: e.status,
156
- path: b
157
- }
158
- }
159
- ];
160
- } catch (e) {
161
- return t == null || t.emit("abort"), [v(e, D.REQUEST_FAILED), null];
162
- }
163
- },
164
- controller: C
165
- }
166
- ];
167
- } catch (c) {
168
- return console.error(c), t == null || t.emit("abort"), [v(c), null];
169
- }
170
- };
171
- export {
172
- Q as createFetchBody,
173
- I as createFetchHeaders,
174
- N as createFetchQueryParams,
175
- re as createRequestOperation,
176
- j as decodeBuffer
177
- };