@scalar/api-client 2.2.31 → 2.2.32

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @scalar/api-client
2
2
 
3
+ ## 2.2.32
4
+
5
+ ### Patch Changes
6
+
7
+ - d3199be: fix: duplicate query params
8
+
3
9
  ## 2.2.31
4
10
 
5
11
  ### Patch Changes
@@ -1 +1 @@
1
- {"version":3,"file":"send-request.d.ts","sourceRoot":"","sources":["../../../src/libs/send-request/send-request.ts"],"names":[],"mappings":"AAAA,OAAO,EAAU,KAAK,aAAa,EAAkB,MAAM,eAAe,CAAA;AAC1E,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAA;AAIhD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mCAAmC,CAAA;AAC/D,OAAO,KAAK;AACV,4DAA4D;AAC5D,OAAO,IAAI,UAAU,EACrB,cAAc,EACd,aAAa,EACb,gBAAgB,EAChB,cAAc,EACd,MAAM,EACP,MAAM,iCAAiC,CAAA;AAWxC,MAAM,MAAM,aAAa,GAAG,OAAO,GAAG,MAAM,GAAG,OAAO,CAAA;AAGtD,sDAAsD;AACtD,wBAAgB,YAAY,CAAC,MAAM,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,iBAapE;AAED,mDAAmD;AACnD,wBAAgB,kBAAkB,CAChC,OAAO,EAAE,IAAI,CAAC,cAAc,EAAE,YAAY,CAAC,EAC3C,GAAG,EAAE,MAAM,0BAgBZ;AAED,sDAAsD;AACtD,wBAAgB,sBAAsB,CACpC,OAAO,EAAE,IAAI,CAAC,cAAc,EAAE,YAAY,CAAC,EAC3C,GAAG,EAAE,MAAM,mBASZ;AAED,4EAA4E;AAC5E,wBAAgB,iBAAiB,CAAC,EAChC,OAAO,EACP,GAAG,EACH,aAAa,EACb,MAAM,EACN,QAAQ,GACT,EAAE;IACD,OAAO,EAAE,cAA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MAAM,sBAAsB,6HAUhC;IACD,OAAO,EAAE,UAAU,CAAA;IACnB,OAAO,EAAE,cAAc,CAAA;IACvB,0BAA0B,CAAC,EAAE,MAAM,EAAE,CAAA;IACrC,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,MAAM,CAAC,EAAE,QAAQ,CAAC,aAAa,CAAC,CAAA;IAChC,WAAW,EAAE,MAAM,GAAG,SAAS,CAAA;IAC/B,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAAA;IAC/C,aAAa,EAAE,MAAM,EAAE,CAAA;CACxB,KAAG,aAAa,CAAC;IAChB,UAAU,EAAE,eAAe,CAAA;IAC3B,WAAW,EAAE,MAAM,mBAAmB,CAAA;IACtC,OAAO,EAAE,OAAO,CAAA;CACjB,CA6MA,CAAA"}
@@ -1,31 +1,31 @@
1
- import { ERRORS as v, normalizeError as B } from "../errors.js";
1
+ import { ERRORS as B, normalizeError as C } from "../errors.js";
2
2
  import { normalizeHeaders as $ } from "../normalize-headers.js";
3
3
  import { replaceTemplateVariables as f } from "../string-template.js";
4
- import { canMethodHaveBody as q, isRelativePath as C, concatenateUrlAndPath as F, shouldUseProxy as U, REGEX as H } from "@scalar/oas-utils/helpers";
4
+ import { canMethodHaveBody as q, isRelativePath as U, concatenateUrlAndPath as F, shouldUseProxy as O, REGEX as H } from "@scalar/oas-utils/helpers";
5
5
  import g from "js-cookie";
6
6
  import M from "whatwg-mimetype";
7
7
  import { textMediaTypes as z } from "../../views/Request/consts/mediaTypes.js";
8
- function K(n, o) {
9
- const t = new M(o);
10
- return z.includes(t.essence) ? new TextDecoder(t.parameters.get("charset")).decode(n) : new Blob([n], { type: t.essence });
8
+ function K(n, t) {
9
+ const o = new M(t);
10
+ return z.includes(o.essence) ? new TextDecoder(o.parameters.get("charset")).decode(n) : new Blob([n], { type: o.essence });
11
11
  }
12
- function W(n, o) {
13
- const t = {};
12
+ function W(n, t) {
13
+ const o = {};
14
14
  return n.parameters.headers.forEach((r) => {
15
15
  const h = r.key.trim().toLowerCase();
16
- r.enabled && (h !== "content-type" || r.value !== "multipart/form-data") && (t[h] = f(r.value, o));
17
- }), t;
16
+ r.enabled && (h !== "content-type" || r.value !== "multipart/form-data") && (o[h] = f(r.value, t));
17
+ }), o;
18
18
  }
19
- function j(n, o) {
20
- const t = new URLSearchParams();
19
+ function j(n, t) {
20
+ const o = new URLSearchParams();
21
21
  return n.parameters.query.forEach((r) => {
22
- r.enabled && t.append(r.key, f(r.value ?? "", o));
23
- }), t;
22
+ r.enabled && o.append(r.key, f(r.value ?? "", t));
23
+ }), o;
24
24
  }
25
25
  function N({
26
26
  example: n,
27
- env: o,
28
- globalCookies: t,
27
+ env: t,
28
+ globalCookies: o,
29
29
  domain: r,
30
30
  proxyUrl: h
31
31
  }) {
@@ -44,11 +44,11 @@ function N({
44
44
  secure: !0
45
45
  }, y = g.get();
46
46
  return Object.keys(y).forEach((a) => g.remove(a)), n.parameters.cookies.forEach((a) => {
47
- a.enabled && g.set(a.key, f(a.value, o));
48
- }), t.forEach((a) => {
49
- var l;
47
+ a.enabled && g.set(a.key, f(a.value, t));
48
+ }), o.forEach((a) => {
49
+ var b;
50
50
  const { name: c, value: k, ...p } = a;
51
- (p.domain === r || ((l = p.domain) == null ? void 0 : l.startsWith(".")) && r.endsWith(p.domain ?? "")) && g.set(c, k, {
51
+ (p.domain === r || ((b = p.domain) == null ? void 0 : b.startsWith(".")) && r.endsWith(p.domain ?? "")) && g.set(c, k, {
52
52
  /** Override the domain with the proxy value */
53
53
  domain: m,
54
54
  // TODO: path cookies probably don't worth with the proxy
@@ -61,22 +61,22 @@ function N({
61
61
  cookieParams: i
62
62
  };
63
63
  }
64
- function Y(n, o, t) {
64
+ function Y(n, t, o) {
65
65
  var r, h, m;
66
66
  if (!q(n))
67
67
  return { body: void 0, contentType: void 0 };
68
- if (o.body.activeBody === "formData" && o.body.formData) {
69
- const i = o.body.formData.encoding === "form-data" ? "multipart/form-data" : "application/x-www-form-urlencoded", y = o.body.formData.encoding === "form-data" ? new FormData() : new URLSearchParams();
70
- return o.body.formData.value.forEach((a) => {
71
- !a.enabled || !a.key || (a.file && y instanceof FormData ? y.append(a.key, a.file, a.file.name) : a.value !== void 0 && y.append(a.key, f(a.value, t)));
68
+ if (t.body.activeBody === "formData" && t.body.formData) {
69
+ const i = t.body.formData.encoding === "form-data" ? "multipart/form-data" : "application/x-www-form-urlencoded", y = t.body.formData.encoding === "form-data" ? new FormData() : new URLSearchParams();
70
+ return t.body.formData.value.forEach((a) => {
71
+ !a.enabled || !a.key || (a.file && y instanceof FormData ? y.append(a.key, a.file, a.file.name) : a.value !== void 0 && y.append(a.key, f(a.value, o)));
72
72
  }), { body: y, contentType: i };
73
73
  }
74
- return o.body.activeBody === "raw" ? {
75
- body: f(((r = o.body.raw) == null ? void 0 : r.value) ?? "", t),
76
- contentType: (h = o.body.raw) == null ? void 0 : h.encoding
77
- } : o.body.activeBody === "binary" ? {
78
- body: o.body.binary,
79
- contentType: (m = o.body.binary) == null ? void 0 : m.type
74
+ return t.body.activeBody === "raw" ? {
75
+ body: f(((r = t.body.raw) == null ? void 0 : r.value) ?? "", o),
76
+ contentType: (h = t.body.raw) == null ? void 0 : h.encoding
77
+ } : t.body.activeBody === "binary" ? {
78
+ body: t.body.binary,
79
+ contentType: (m = t.body.binary) == null ? void 0 : m.type
80
80
  } : {
81
81
  body: void 0,
82
82
  contentType: void 0
@@ -87,8 +87,8 @@ function Q(n) {
87
87
  }
88
88
  const T = "YOUR_SECRET_TOKEN", oe = ({
89
89
  request: n,
90
- example: o,
91
- server: t,
90
+ example: t,
91
+ server: o,
92
92
  securitySchemes: r,
93
93
  selectedSecuritySchemeUids: h = [],
94
94
  proxyUrl: m,
@@ -97,53 +97,51 @@ const T = "YOUR_SECRET_TOKEN", oe = ({
97
97
  globalCookies: a
98
98
  }) => {
99
99
  try {
100
- const c = y ?? {}, k = new AbortController(), p = o.parameters.path.reduce((u, e) => (e.enabled && (u[e.key] = f(e.value, c)), u), {}), P = f((t == null ? void 0 : t.url) ?? "", c), l = f(n.path, p);
101
- let d = P || l;
102
- if (!d) throw v.URL_EMPTY;
103
- Object.entries((t == null ? void 0 : t.variables) ?? {}).forEach(([u, e]) => {
104
- d = f(d, {
100
+ const c = y ?? {}, k = new AbortController(), p = t.parameters.path.reduce((u, e) => (e.enabled && (u[e.key] = f(e.value, c)), u), {}), D = f((o == null ? void 0 : o.url) ?? "", c), b = f(n.path, p);
101
+ let s = D || b;
102
+ if (!s) throw B.URL_EMPTY;
103
+ Object.entries((o == null ? void 0 : o.variables) ?? {}).forEach(([u, e]) => {
104
+ s = f(s, {
105
105
  [u]: p[u] || e.default
106
106
  });
107
107
  });
108
- const D = j(o, c), E = W(o, c), { body: O } = Y(n.method, o, c);
108
+ const P = j(t, c), E = W(t, c), { body: v } = Y(n.method, t, c);
109
109
  if (N({
110
- example: o,
110
+ example: t,
111
111
  env: c,
112
112
  globalCookies: a,
113
- domain: d,
113
+ domain: s,
114
114
  proxyUrl: m
115
115
  }), h == null || h.forEach((u) => {
116
- var w;
116
+ var R;
117
117
  const e = r[u];
118
118
  if (e) {
119
119
  if (e.type === "apiKey") {
120
- const s = f(e.value, c) || T;
121
- e.in === "header" && (E[e.name] = s), e.in === "query" && D.append(e.name, s), e.in === "cookie" && g.set(e.name, s);
120
+ const d = f(e.value, c) || T;
121
+ e.in === "header" && (E[e.name] = d), e.in === "query" && P.append(e.name, d), e.in === "cookie" && g.set(e.name, d);
122
122
  }
123
123
  if (e.type === "http")
124
124
  if (e.scheme === "basic") {
125
- const s = f(e.username, c), b = f(e.password, c), R = `${s}:${b}`;
126
- E.Authorization = `Basic ${R === ":" ? "username:password" : btoa(R)}`;
125
+ const d = f(e.username, c), l = f(e.password, c), w = `${d}:${l}`;
126
+ E.Authorization = `Basic ${w === ":" ? "username:password" : btoa(w)}`;
127
127
  } else {
128
- const s = f(e.token, c);
129
- E.Authorization = `Bearer ${s || T}`;
128
+ const d = f(e.token, c);
129
+ E.Authorization = `Bearer ${d || T}`;
130
130
  }
131
131
  if (e.type === "oauth2") {
132
- const b = (w = Object.values(e.flows).find((R) => R.token)) == null ? void 0 : w.token;
133
- E.Authorization = `Bearer ${b || T}`;
132
+ const l = (R = Object.values(e.flows).find((w) => w.token)) == null ? void 0 : R.token;
133
+ E.Authorization = `Bearer ${l || T}`;
134
134
  }
135
135
  }
136
- }), d && (!C(d) || typeof window < "u")) {
137
- const u = C(d) ? F(window.location.origin, d) : Q(d), e = new URL(u), w = new URL(l, e.origin), s = new URL(e);
138
- t != null && t.url && (e.pathname === "/" ? s.pathname = l : s.pathname = e.pathname + l), s.search = new URLSearchParams([
139
- ...e.searchParams,
140
- ...w.searchParams,
141
- ...D
142
- ]).toString(), d = s.toString();
136
+ }), s && (!U(s) || typeof window < "u")) {
137
+ const u = U(s) ? F(window.location.origin, s) : Q(s), e = new URL(u), R = new URL(b, e.origin), d = b.split("?")[0] ?? "", l = new URL(e);
138
+ o != null && o.url && (e.pathname === "/" ? l.pathname = d : l.pathname = e.pathname + d);
139
+ const w = o != null && o.url ? [...e.searchParams, ...R.searchParams, ...P] : [...R.searchParams, ...P];
140
+ l.search = new URLSearchParams(w).toString(), s = l.toString();
143
141
  }
144
- const S = new URLSearchParams([["scalar_url", d.toString()]]), A = U(m, d) ? `${m}?${S.toString()}` : d, L = new Request(A, {
142
+ const S = new URLSearchParams([["scalar_url", s.toString()]]), A = O(m, s) ? `${m}?${S.toString()}` : s, L = new Request(A, {
145
143
  method: n.method.toUpperCase(),
146
- body: O,
144
+ body: v,
147
145
  headers: E
148
146
  });
149
147
  return [
@@ -158,37 +156,37 @@ const T = "YOUR_SECRET_TOKEN", oe = ({
158
156
  signal: k.signal
159
157
  });
160
158
  i == null || i.emit("stop");
161
- const w = $(
159
+ const R = $(
162
160
  e.headers,
163
- U(m, d)
164
- ), s = e.headers.get("content-type") ?? "text/plain;charset=UTF-8", b = await e.arrayBuffer(), R = K(b, s), _ = "getSetCookie" in e.headers && typeof e.headers.getSetCookie == "function" ? e.headers.getSetCookie() : [];
161
+ O(m, s)
162
+ ), d = e.headers.get("content-type") ?? "text/plain;charset=UTF-8", l = await e.arrayBuffer(), w = K(l, d), _ = "getSetCookie" in e.headers && typeof e.headers.getSetCookie == "function" ? e.headers.getSetCookie() : [];
165
163
  return [
166
164
  null,
167
165
  {
168
166
  timestamp: Date.now(),
169
- request: o,
167
+ request: t,
170
168
  response: {
171
169
  ...e,
172
- headers: w,
170
+ headers: R,
173
171
  cookieHeaderKeys: _,
174
- data: R,
175
- size: b.byteLength,
172
+ data: w,
173
+ size: l.byteLength,
176
174
  duration: Date.now() - u,
177
175
  method: n.method,
178
176
  status: e.status,
179
- path: l
177
+ path: b
180
178
  }
181
179
  }
182
180
  ];
183
181
  } catch (e) {
184
- return i == null || i.emit("abort"), [B(e, v.REQUEST_FAILED), null];
182
+ return i == null || i.emit("abort"), [C(e, B.REQUEST_FAILED), null];
185
183
  }
186
184
  },
187
185
  controller: k
188
186
  }
189
187
  ];
190
188
  } catch (c) {
191
- return console.error(c), i == null || i.emit("abort"), [B(c), null];
189
+ return console.error(c), i == null || i.emit("abort"), [C(c), null];
192
190
  }
193
191
  };
194
192
  export {
@@ -17,7 +17,7 @@ const K = { class: "relative col-1 flex-center gap-6 p-2 capitalize" }, A = {
17
17
  a.commandPalette.emit({ commandName: "Create Request" });
18
18
  }, y = (i) => {
19
19
  i != null && i.createNew && v.name === "request" && f();
20
- }, h = "2.2.31";
20
+ }, h = "2.2.32";
21
21
  return R(() => a.hotKeys.on(y)), C(() => a.hotKeys.off(y)), (i, e) => (r(), l("div", K, [
22
22
  o("div", {
23
23
  class: k(["flex h-[calc(100%_-_50px)] flex-col items-center justify-center", {
package/package.json CHANGED
@@ -18,7 +18,7 @@
18
18
  "rest",
19
19
  "testing"
20
20
  ],
21
- "version": "2.2.31",
21
+ "version": "2.2.32",
22
22
  "engines": {
23
23
  "node": ">=18"
24
24
  },
@@ -179,21 +179,21 @@
179
179
  "whatwg-mimetype": "^4.0.0",
180
180
  "yaml": "^2.4.5",
181
181
  "zod": "^3.23.8",
182
- "@scalar/components": "0.13.13",
183
- "@scalar/draggable": "0.1.8",
184
182
  "@scalar/icons": "0.1.2",
185
183
  "@scalar/import": "0.2.16",
186
- "@scalar/oas-utils": "0.2.96",
187
184
  "@scalar/object-utils": "1.1.12",
188
- "@scalar/openapi-types": "0.1.5",
185
+ "@scalar/oas-utils": "0.2.96",
189
186
  "@scalar/openapi-parser": "0.10.3",
190
- "@scalar/themes": "0.9.59",
187
+ "@scalar/openapi-types": "0.1.5",
191
188
  "@scalar/postman-to-openapi": "0.1.19",
189
+ "@scalar/themes": "0.9.59",
190
+ "@scalar/use-codemirror": "0.11.57",
192
191
  "@scalar/types": "0.0.25",
192
+ "@scalar/components": "0.13.13",
193
193
  "@scalar/use-hooks": "0.1.13",
194
- "@scalar/use-codemirror": "0.11.57",
194
+ "@scalar/use-tooltip": "1.0.5",
195
195
  "@scalar/use-toasts": "0.7.8",
196
- "@scalar/use-tooltip": "1.0.5"
196
+ "@scalar/draggable": "0.1.8"
197
197
  },
198
198
  "devDependencies": {
199
199
  "@types/js-cookie": "^3.0.6",