@scalar/api-client 2.0.21 → 2.0.22

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.0.22
4
+
5
+ ### Patch Changes
6
+
7
+ - 45b956f: fix: only add body data if body data is not null
8
+
3
9
  ## 2.0.21
4
10
 
5
11
  ### Patch Changes
package/README.md CHANGED
@@ -57,31 +57,28 @@ await createApiClientApp(document.getElementById('scalar-client'), {
57
57
  Or you can mount a more compact version, which is living in a modal:
58
58
 
59
59
  ```ts
60
- import { createApiClientModal } from '@scalar/api-client'
61
-
62
- const targetElement = document.getElementById('root')
60
+ // main.js
61
+ import { createApiClientApp } from '@/App'
63
62
 
64
63
  // Initialize
65
- const { open } = await createApiClientModal(targetElement, {
66
- spec: {
67
- // Load a spec from URL
68
- url: 'https://cdn.jsdelivr.net/npm/@scalar/galaxy/dist/latest.json',
69
- // OR the spec directly
70
- content: {
71
- ...
72
- }
64
+ const { open } = await createApiClientApp(
65
+ document.getElementById('scalar-client'),
66
+ {
67
+ spec: {
68
+ url: 'https://cdn.jsdelivr.net/npm/@scalar/galaxy/dist/latest.json',
69
+ },
70
+ proxyUrl: 'https://proxy.scalar.com',
73
71
  },
74
- proxyUrl: 'https://proxy.scalar.com',
75
- })
72
+ )
76
73
 
77
74
  // Open the API client right-away
78
75
  open()
79
76
 
80
77
  // Or: Open a specific operation
81
- open({
82
- method: 'GET',
83
- path: '/me',
84
- })
78
+ // open({
79
+ // method: 'GET',
80
+ // path: '/me',
81
+ // })
85
82
  ```
86
83
 
87
84
  ## Configuration
@@ -1 +1 @@
1
- {"version":3,"file":"SearchModal.vue.d.ts","sourceRoot":"","sources":["../../../src/components/Search/SearchModal.vue"],"names":[],"mappings":"AAgPA,OAAO,EACL,KAAK,UAAU,EAKhB,MAAM,oBAAoB,CAAA;;gBASb,UAAU;;gBAAV,U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"","sources":["../../src/libs/sendRequest.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,cAAc,EACd,oBAAoB,EACrB,MAAM,+CAA+C,CAAA;AACtD,OAAO,KAAK,EACV,OAAO,EACP,cAAc,EAEd,gBAAgB,EACjB,MAAM,2CAA2C,CAAA;AAkBlD;;;GAGG;AACH,eAAO,MAAM,WAAW,YACb,OAAO,WACP,cAAc,UACf,MAAM,mBACG;IACf,MAAM,EAAE,cAAc,CAAA;IACtB,IAAI,CAAC,EAAE,oBAAoB,CAAC,MAAM,CAAC,CAAA;CACpC,aACU,MAAM,KAChB,OAAO,CAAC;IACT,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,OAAO,CAAC,EAAE,cAAc,CAAA;IACxB,QAAQ,CAAC,EAAE,gBAAgB,CAAA;CAC5B,CA0LA,CAAA"}
1
+ {"version":3,"file":"sendRequest.d.ts","sourceRoot":"","sources":["../../src/libs/sendRequest.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,cAAc,EACd,oBAAoB,EACrB,MAAM,+CAA+C,CAAA;AACtD,OAAO,KAAK,EACV,OAAO,EACP,cAAc,EAEd,gBAAgB,EACjB,MAAM,2CAA2C,CAAA;AAkBlD;;;GAGG;AACH,eAAO,MAAM,WAAW,YACb,OAAO,WACP,cAAc,UACf,MAAM,mBACG;IACf,MAAM,EAAE,cAAc,CAAA;IACtB,IAAI,CAAC,EAAE,oBAAoB,CAAC,MAAM,CAAC,CAAA;CACpC,aACU,MAAM,KAChB,OAAO,CAAC;IACT,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,OAAO,CAAC,EAAE,cAAc,CAAA;IACxB,QAAQ,CAAC,EAAE,gBAAgB,CAAA;CAC5B,CA2LA,CAAA"}
@@ -1,23 +1,23 @@
1
1
  import { redirectToProxy as A, shouldUseProxy as C } from "@scalar/oas-utils/helpers";
2
2
  import E from "axios";
3
3
  import R from "js-cookie";
4
- const c = (d = []) => d.reduce(
4
+ const u = (c = []) => c.reduce(
5
5
  (o, i) => (i.key && (o[i.key] = i.value), o),
6
6
  {}
7
- ), g = async (d, o, i, s, y) => {
8
- var w;
9
- let n = i;
7
+ ), g = async (c, o, i, s, y) => {
8
+ var k;
9
+ let a = i;
10
10
  o.parameters.path.forEach((e) => {
11
- !e.key || !e.value || (n = n.replace(`{${e.key}}`, e.value));
11
+ !e.key || !e.value || (a = a.replace(`{${e.key}}`, e.value));
12
12
  });
13
- const r = c(
13
+ const r = u(
14
14
  o.parameters.headers.filter(({ enabled: e }) => e)
15
15
  );
16
- let u = null;
16
+ let d = null;
17
17
  if (o.body.activeBody === "binary" && o.body.binary)
18
- r["Content-Type"] = o.body.binary.type, r["Content-Disposition"] = `attachment; filename="${o.body.binary.name}"`, u = o.body.binary;
19
- else if (o.body.activeBody === "raw")
20
- u = o.body.raw.value;
18
+ r["Content-Type"] = o.body.binary.type, r["Content-Disposition"] = `attachment; filename="${o.body.binary.name}"`, d = o.body.binary;
19
+ else if (o.body.activeBody === "raw" && o.body.raw.value)
20
+ d = o.body.raw.value;
21
21
  else if (o.body.activeBody === "formData") {
22
22
  r["Content-Type"] = "multipart/form-data";
23
23
  const e = new FormData();
@@ -25,23 +25,23 @@ const c = (d = []) => d.reduce(
25
25
  (t) => {
26
26
  t.key && t.value ? e.append(t.key, t.value) : t.file && e.append(t.file.name, t.file);
27
27
  }
28
- ), u = e);
28
+ ), d = e);
29
29
  }
30
- const f = [], [k, p] = n.split("?");
31
- new URLSearchParams(p ?? "").forEach((e, t) => {
30
+ const f = [], [p, D] = a.split("?");
31
+ new URLSearchParams(D ?? "").forEach((e, t) => {
32
32
  f.push({
33
33
  key: t,
34
34
  value: e,
35
35
  enabled: !0
36
36
  });
37
37
  });
38
- const h = {
39
- ...c(
38
+ const b = {
39
+ ...u(
40
40
  o.parameters.query.filter(({ enabled: e }) => e).filter(({ value: e }) => e !== "")
41
41
  ),
42
- ...c(f)
42
+ ...u(f)
43
43
  }, l = {
44
- ...c(
44
+ ...u(
45
45
  (o.parameters.cookies ?? []).filter(({ enabled: e }) => e)
46
46
  )
47
47
  };
@@ -53,13 +53,13 @@ const c = (d = []) => d.reduce(
53
53
  l[e.name] = e.value;
54
54
  break;
55
55
  case "query":
56
- h[e.name] = e.value;
56
+ b[e.name] = e.value;
57
57
  break;
58
58
  case "header":
59
59
  r[e.name] = e.value;
60
60
  break;
61
61
  }
62
- else e.type === "http" && e.value ? e.scheme === "basic" && e.secondValue ? r.Authorization = `Basic ${btoa(`${e.value}:${e.secondValue}`)}` : r.Authorization = `Bearer ${e.value}` : e.type === "oauth2" && ((w = s.flow) != null && w.token) && (r.Authorization = `Bearer ${s.flow.token}`);
62
+ else e.type === "http" && e.value ? e.scheme === "basic" && e.secondValue ? r.Authorization = `Basic ${btoa(`${e.value}:${e.secondValue}`)}` : r.Authorization = `Bearer ${e.value}` : e.type === "oauth2" && ((k = s.flow) != null && k.token) && (r.Authorization = `Bearer ${s.flow.token}`);
63
63
  }
64
64
  Object.keys(l).forEach((e) => {
65
65
  R.set(e, l[e], {
@@ -69,37 +69,38 @@ const c = (d = []) => d.reduce(
69
69
  secure: !0
70
70
  });
71
71
  });
72
- const b = new URLSearchParams(h).toString();
73
- n = `${k}${b ? "?" + b : ""}`;
74
- const D = {
75
- url: A(y, n),
76
- method: d.method,
77
- headers: r,
78
- data: u
79
- }, v = Date.now();
72
+ const h = new URLSearchParams(b).toString();
73
+ a = `${p}${h ? "?" + h : ""}`;
74
+ const v = {
75
+ url: A(y, a),
76
+ method: c.method,
77
+ headers: r
78
+ };
79
+ d && (v.data = d);
80
+ const w = Date.now();
80
81
  try {
81
- const e = await E(D);
82
- return C(y, n) && [
82
+ const e = await E(v);
83
+ return C(y, a) && [
83
84
  "Access-Control-Allow-Headers",
84
85
  "Access-Control-Allow-Origin",
85
86
  "Access-Control-Allow-Methods",
86
87
  "Access-Control-Expose-Headers"
87
- ].map((a) => a.toLowerCase()).forEach((a) => delete e.headers[a]), {
88
+ ].map((n) => n.toLowerCase()).forEach((n) => delete e.headers[n]), {
88
89
  sentTime: Date.now(),
89
90
  request: o,
90
91
  response: {
91
92
  ...e,
92
- duration: Date.now() - v
93
+ duration: Date.now() - w
93
94
  }
94
95
  };
95
96
  } catch (e) {
96
- const a = e.response;
97
+ const n = e.response;
97
98
  return console.error("ERROR", e), {
98
99
  sentTime: Date.now(),
99
100
  request: o,
100
- response: a ? {
101
- ...a,
102
- duration: Date.now() - v
101
+ response: n ? {
102
+ ...n,
103
+ duration: Date.now() - w
103
104
  } : void 0
104
105
  };
105
106
  }
package/package.json CHANGED
@@ -18,7 +18,7 @@
18
18
  "rest",
19
19
  "testing"
20
20
  ],
21
- "version": "2.0.21",
21
+ "version": "2.0.22",
22
22
  "engines": {
23
23
  "node": ">=18"
24
24
  },
@@ -111,14 +111,14 @@
111
111
  "nanoid": "^5.0.7",
112
112
  "pretty-bytes": "^6.1.1",
113
113
  "pretty-ms": "^8.0.0",
114
- "vue": "^3.4.22",
114
+ "vue": "^3.4.29",
115
115
  "vue-router": "^4.3.0",
116
116
  "zod": "^3.22.4",
117
117
  "@scalar/components": "0.12.14",
118
- "@scalar/object-utils": "1.1.4",
119
118
  "@scalar/draggable": "0.1.3",
120
- "@scalar/oas-utils": "0.2.13",
121
119
  "@scalar/themes": "0.9.13",
120
+ "@scalar/oas-utils": "0.2.13",
121
+ "@scalar/object-utils": "1.1.4",
122
122
  "@scalar/use-codemirror": "0.11.6",
123
123
  "@scalar/use-toasts": "0.7.4",
124
124
  "@scalar/use-tooltip": "1.0.2"