@scalar/api-client 2.1.26 → 2.1.28

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 (63) hide show
  1. package/CHANGELOG.md +23 -0
  2. package/dist/components/CommandPalette/CommandPaletteImport.vue.d.ts.map +1 -1
  3. package/dist/components/CommandPalette/CommandPaletteImport.vue.js +149 -89
  4. package/dist/components/ImportCollection/ImportNowButton.vue.d.ts.map +1 -1
  5. package/dist/components/ImportCollection/ImportNowButton.vue.js +7 -9
  6. package/dist/layouts/App/create-api-client-app.d.ts +77 -20
  7. package/dist/layouts/App/create-api-client-app.d.ts.map +1 -1
  8. package/dist/layouts/App/create-api-client-app.js +14 -12
  9. package/dist/layouts/Modal/create-api-client-modal.d.ts +154 -40
  10. package/dist/layouts/Modal/create-api-client-modal.d.ts.map +1 -1
  11. package/dist/layouts/Modal/create-api-client-modal.js +23 -26
  12. package/dist/layouts/Web/create-api-client-web.d.ts +77 -20
  13. package/dist/layouts/Web/create-api-client-web.d.ts.map +1 -1
  14. package/dist/layouts/Web/create-api-client-web.js +12 -10
  15. package/dist/libs/create-client.d.ts +77 -20
  16. package/dist/libs/create-client.d.ts.map +1 -1
  17. package/dist/libs/create-client.js +60 -58
  18. package/dist/store/collections.d.ts +34 -4
  19. package/dist/store/collections.d.ts.map +1 -1
  20. package/dist/store/import-spec.d.ts +43 -4
  21. package/dist/store/import-spec.d.ts.map +1 -1
  22. package/dist/store/import-spec.js +60 -36
  23. package/dist/store/requests.d.ts +4 -1
  24. package/dist/store/requests.d.ts.map +1 -1
  25. package/dist/store/requests.js +76 -76
  26. package/dist/store/security-schemes.d.ts +2 -2
  27. package/dist/store/security-schemes.d.ts.map +1 -1
  28. package/dist/store/security-schemes.js +35 -37
  29. package/dist/store/servers.d.ts +10 -10
  30. package/dist/store/servers.d.ts.map +1 -1
  31. package/dist/store/store.d.ts +154 -40
  32. package/dist/store/store.d.ts.map +1 -1
  33. package/dist/store/store.js +27 -27
  34. package/dist/style.css +1 -1
  35. package/dist/views/Request/Request.vue.d.ts.map +1 -1
  36. package/dist/views/Request/Request.vue.js +1 -1
  37. package/dist/views/Request/Request.vue2.js +39 -38
  38. package/dist/views/Request/RequestSection/RequestAuth/DeleteRequestAuthModal.vue.d.ts.map +1 -1
  39. package/dist/views/Request/RequestSection/RequestAuth/DeleteRequestAuthModal.vue.js +12 -12
  40. package/dist/views/Request/RequestSidebar.vue.d.ts.map +1 -1
  41. package/dist/views/Request/RequestSidebar.vue.js +4 -4
  42. package/dist/views/Request/RequestSidebar.vue2.js +107 -102
  43. package/dist/views/Request/RequestSidebarItem.vue.d.ts.map +1 -1
  44. package/dist/views/Request/RequestSidebarItem.vue.js +1 -1
  45. package/dist/views/Request/RequestSidebarItem.vue2.js +165 -135
  46. package/dist/views/Request/RequestSidebarItemMenu.vue.d.ts +3 -1
  47. package/dist/views/Request/RequestSidebarItemMenu.vue.d.ts.map +1 -1
  48. package/dist/views/Request/RequestSidebarItemMenu.vue.js +4 -4
  49. package/dist/views/Request/RequestSidebarItemMenu.vue2.js +96 -71
  50. package/dist/views/Request/ResponseSection/ResponseEmpty.vue2.js +1 -1
  51. package/dist/views/Request/hooks/useOpenApiWatcher.d.ts +9 -0
  52. package/dist/views/Request/hooks/useOpenApiWatcher.d.ts.map +1 -0
  53. package/dist/views/Request/hooks/useOpenApiWatcher.js +86 -0
  54. package/dist/views/Request/libs/live-sync.d.ts +59 -0
  55. package/dist/views/Request/libs/live-sync.d.ts.map +1 -0
  56. package/dist/views/Request/libs/live-sync.js +289 -0
  57. package/dist/views/Request/types/sidebar-item.d.ts +2 -0
  58. package/dist/views/Request/types/sidebar-item.d.ts.map +1 -1
  59. package/dist/views/Settings/SettingsGeneral.vue.d.ts.map +1 -1
  60. package/dist/views/Settings/SettingsGeneral.vue.js +59 -69
  61. package/dist/views/Settings/SettingsGeneralMode.vue.d.ts.map +1 -1
  62. package/dist/views/Settings/SettingsGeneralMode.vue.js +22 -22
  63. package/package.json +12 -10
package/CHANGELOG.md CHANGED
@@ -1,5 +1,28 @@
1
1
  # @scalar/api-client
2
2
 
3
+ ## 2.1.28
4
+
5
+ ### Patch Changes
6
+
7
+ - dea4f88: chore: update wording on settings page
8
+
9
+ ## 2.1.27
10
+
11
+ ### Patch Changes
12
+
13
+ - 4e50d65: feat: added openapi watcher to live update the api client
14
+ - 4e50d65: feat: adds watch toggle in request sidebar item menu
15
+ - Updated dependencies [4e50d65]
16
+ - Updated dependencies [4e50d65]
17
+ - Updated dependencies [4e50d65]
18
+ - Updated dependencies [4e50d65]
19
+ - Updated dependencies [4e50d65]
20
+ - Updated dependencies [6bbb815]
21
+ - @scalar/components@0.12.56
22
+ - @scalar/oas-utils@0.2.59
23
+ - @scalar/themes@0.9.40
24
+ - @scalar/use-codemirror@0.11.23
25
+
3
26
  ## 2.1.26
4
27
 
5
28
  ### Patch Changes
@@ -1 +1 @@
1
- {"version":3,"file":"CommandPaletteImport.vue.d.ts","sourceRoot":"","sources":["../../../src/components/CommandPalette/CommandPaletteImport.vue"],"names":[],"mappings":";;;;;;;AAmfA,wBASG"}
1
+ {"version":3,"file":"CommandPaletteImport.vue.d.ts","sourceRoot":"","sources":["../../../src/components/CommandPalette/CommandPaletteImport.vue"],"names":[],"mappings":";;;;;;;AA6sBA,wBASG"}
@@ -1,133 +1,193 @@
1
- import { defineComponent as P, ref as R, computed as v, openBlock as l, createBlock as k, unref as r, withCtx as p, createVNode as y, createTextVNode as i, createElementBlock as u, Fragment as m, toDisplayString as w, createElementVNode as U, createCommentVNode as T } from "vue";
2
- import { useLoadingState as j, ScalarButton as D, ScalarIcon as M, ScalarCodeBlock as _ } from "@scalar/components";
3
- import { useToasts as z } from "@scalar/use-toasts";
4
- import E from "./CommandActionForm.vue.js";
5
- import W from "./CommandActionInput.vue.js";
6
- import { getOpenApiDocumentDetails as h } from "../../libs/getOpenApiDocumentDetails.js";
7
- import { isUrl as x } from "../../libs/isUrl.js";
8
- import { useFileDialog as J } from "../../hooks/useFileDialog.js";
9
- import { useWorkspace as Y } from "../../store/store.js";
10
- const q = { class: "flex justify-between" }, le = /* @__PURE__ */ P({
1
+ import { defineComponent as M, ref as U, computed as w, watch as O, openBlock as a, createBlock as h, unref as l, withCtx as c, createElementVNode as d, createVNode as f, createTextVNode as n, normalizeClass as V, createElementBlock as i, Fragment as g, toDisplayString as _, createCommentVNode as N } from "vue";
2
+ import { useLoadingState as $, ScalarButton as F, ScalarIcon as L, ScalarTooltip as j, ScalarToggle as E, ScalarCodeBlock as J } from "@scalar/components";
3
+ import { useToasts as Y } from "@scalar/use-toasts";
4
+ import q from "./CommandActionForm.vue.js";
5
+ import G from "./CommandActionInput.vue.js";
6
+ import { getOpenApiDocumentDetails as H } from "../../libs/getOpenApiDocumentDetails.js";
7
+ import { isUrl as k } from "../../libs/isUrl.js";
8
+ import { useFileDialog as K } from "../../hooks/useFileDialog.js";
9
+ import { useWorkspace as Q } from "../../store/store.js";
10
+ const X = { class: "flex justify-between" }, Z = { class: "flex flex-row items-center justify-between gap-3 w-full" }, ee = { class: "grid gap-1.5 pointer-events-none max-w-[320px] w-content shadow-lg rounded bg-b-1 z-100 p-2 text-xxs leading-5 z-10 text-c-1" }, te = { class: "flex items-center text-c-2" }, oe = { key: 0 }, ae = {
11
+ key: 1,
12
+ class: "text-pretty"
13
+ }, ve = /* @__PURE__ */ M({
11
14
  __name: "CommandPaletteImport",
12
15
  emits: ["close", "back"],
13
- setup(G, { emit: F }) {
14
- const f = F, { activeWorkspace: g, importSpecFile: b, importSpecFromUrl: L } = Y(), { toast: c } = z(), s = j(), t = R(""), o = v(
15
- () => h(t.value)
16
- ), C = v(
17
- () => o.value ? o.value.type : "json"
18
- ), S = v(() => x(t.value)), V = v(() => !!o.value), { open: A } = J({
19
- onChange: async (a) => {
20
- const e = a == null ? void 0 : a[0];
16
+ setup(le, { emit: A }) {
17
+ const b = A, { activeWorkspace: x, importSpecFile: C, importSpecFromUrl: D } = Q(), { toast: m } = Y(), u = $(), t = U(""), p = U(!0), r = w(
18
+ () => H(t.value)
19
+ ), S = w(
20
+ () => r.value ? r.value.type : "json"
21
+ ), v = w(() => k(t.value)), R = w(() => !!r.value), { open: z } = K({
22
+ onChange: async (o) => {
23
+ const e = o == null ? void 0 : o[0];
21
24
  if (e) {
22
- const n = new FileReader();
23
- n.onload = async (N) => {
25
+ const s = new FileReader();
26
+ s.onload = async (T) => {
24
27
  var I;
25
- const O = (I = N.target) == null ? void 0 : I.result;
28
+ const W = (I = T.target) == null ? void 0 : I.result;
26
29
  try {
27
- await b(O, g.value.uid), c("Import successful", "info"), f("close");
28
- } catch (d) {
29
- console.error(d);
30
- const $ = (d == null ? void 0 : d.message) || "Unknown error";
31
- c(`Import failed: ${$}`, "error");
30
+ await C(W, x.value.uid), m("Import successful", "info"), b("close");
31
+ } catch (y) {
32
+ console.error(y);
33
+ const B = (y == null ? void 0 : y.message) || "Unknown error";
34
+ m(`Import failed: ${B}`, "error");
32
35
  }
33
- }, n.readAsText(e);
36
+ }, s.readAsText(e);
34
37
  }
35
38
  },
36
39
  multiple: !1,
37
40
  accept: ".json,.yaml,.yml"
38
41
  });
39
- async function B() {
40
- if (!(!t.value || s.isLoading)) {
41
- s.startLoading();
42
+ O(v, (o) => {
43
+ o || (p.value = !1);
44
+ }), O(t, (o) => {
45
+ k(o) || (p.value = !1);
46
+ });
47
+ async function P() {
48
+ if (!(!t.value || u.isLoading)) {
49
+ u.startLoading();
42
50
  try {
43
- if (S.value)
44
- await L(
51
+ if (v.value) {
52
+ const [o] = await D(
45
53
  t.value,
46
- void 0,
47
- void 0,
48
- g.value.uid
54
+ x.value.uid,
55
+ {
56
+ proxy: x.value.proxyUrl,
57
+ watchForChanges: p.value
58
+ }
49
59
  );
50
- else if (V.value)
51
- await b(
60
+ if (o) {
61
+ m(
62
+ "There was a possible CORS error while importing your spec, please make sure this server is allowed in the CORS policy of your OpenAPI document.",
63
+ "error",
64
+ { timeout: 5e3 }
65
+ ), u.invalidate(2e3, !0);
66
+ return;
67
+ }
68
+ } else if (R.value)
69
+ await C(
52
70
  String(t.value),
53
- g.value.uid
71
+ x.value.uid
54
72
  );
55
73
  else {
56
- c("Import failed: Invalid URL or OpenAPI document", "error"), s.invalidate(2e3, !0);
74
+ m("Import failed: Invalid URL or OpenAPI document", "error"), u.invalidate(2e3, !0);
57
75
  return;
58
76
  }
59
- s.clear(), f("close"), c("Import successful", "info");
60
- } catch (a) {
61
- console.error("[importCollection]", a);
62
- const e = (a == null ? void 0 : a.message) || "Unknown error";
63
- s.invalidate(2e3, !0), c(`Import failed: ${e}`, "error");
77
+ u.clear(), b("close"), m("Import successful", "info");
78
+ } catch (o) {
79
+ console.error("[importCollection]", o);
80
+ const e = (o == null ? void 0 : o.message) || "Unknown error";
81
+ u.invalidate(2e3, !0), m(`Import failed: ${e}`, "error");
64
82
  }
65
83
  }
66
84
  }
67
- return (a, e) => (l(), k(E, {
85
+ return (o, e) => (a(), h(q, {
68
86
  disabled: !t.value.trim(),
69
- loading: r(s),
70
- onSubmit: B
87
+ loading: l(u),
88
+ onSubmit: P
71
89
  }, {
72
- options: p(() => [
73
- y(r(D), {
74
- class: "p-2 max-h-8 gap-1.5 text-xs hover:bg-b-2 relative",
75
- variant: "outlined",
76
- onClick: r(A)
77
- }, {
78
- default: p(() => [
79
- e[5] || (e[5] = i(" JSON, or YAML File ")),
80
- y(r(M), {
81
- class: "text-c-3",
82
- icon: "UploadSimple",
83
- size: "md"
84
- })
85
- ]),
86
- _: 1
87
- }, 8, ["onClick"])
90
+ options: c(() => [
91
+ d("div", Z, [
92
+ f(l(F), {
93
+ class: "p-2 max-h-8 gap-1.5 text-xs hover:bg-b-2 relative",
94
+ variant: "outlined",
95
+ onClick: l(z)
96
+ }, {
97
+ default: c(() => [
98
+ e[6] || (e[6] = n(" JSON, or YAML File ")),
99
+ f(l(L), {
100
+ class: "text-c-3",
101
+ icon: "UploadSimple",
102
+ size: "md"
103
+ })
104
+ ]),
105
+ _: 1
106
+ }, 8, ["onClick"]),
107
+ f(l(j), {
108
+ as: "div",
109
+ class: "z-[10001]",
110
+ side: "bottom",
111
+ sideOffset: 5
112
+ }, {
113
+ trigger: c(() => [
114
+ d("label", {
115
+ class: V([
116
+ "p-3 py-1.5 rounded flex items-center text-sm text-c-2 gap-2 select-none",
117
+ t.value && !v.value ? "cursor-default" : "cursor-pointer"
118
+ ]),
119
+ for: "watch-toggle"
120
+ }, [
121
+ d("span", {
122
+ class: V(["text-c-1 flex gap-1 items-center font-medium text-xs", { "text-c-3": !p.value }])
123
+ }, [
124
+ f(l(L), {
125
+ icon: "Watch",
126
+ size: "sm"
127
+ }),
128
+ e[7] || (e[7] = n(" Watch Mode "))
129
+ ], 2),
130
+ f(l(E), {
131
+ id: "watch-toggle",
132
+ modelValue: p.value,
133
+ "onUpdate:modelValue": e[3] || (e[3] = (s) => p.value = s),
134
+ disabled: !!t.value && !v.value
135
+ }, null, 8, ["modelValue", "disabled"])
136
+ ], 2)
137
+ ]),
138
+ content: c(() => [
139
+ d("div", ee, [
140
+ d("div", te, [
141
+ t.value && !v.value ? (a(), i("span", oe, "Watch Mode is only supported with URL")) : (a(), i("span", ae, "Watch your OpenAPI URL for changes. Enabled it will update the API client for you."))
142
+ ])
143
+ ])
144
+ ]),
145
+ _: 1
146
+ })
147
+ ])
88
148
  ]),
89
- submit: p(() => [
90
- e[6] || (e[6] = i(" Import ")),
91
- S.value ? (l(), u(m, { key: 0 }, [
92
- i(" from URL ")
93
- ], 64)) : o.value && C.value ? (l(), u(m, { key: 1 }, [
94
- o.value.title ? (l(), u(m, { key: 0 }, [
95
- i(' "' + w(o.value.title) + '" ', 1)
96
- ], 64)) : (l(), u(m, { key: 1 }, [
97
- i(w(o.value.version) + " Spec", 1)
149
+ submit: c(() => [
150
+ e[8] || (e[8] = n(" Import ")),
151
+ v.value ? (a(), i(g, { key: 0 }, [
152
+ n(" from URL ")
153
+ ], 64)) : r.value && S.value ? (a(), i(g, { key: 1 }, [
154
+ r.value.title ? (a(), i(g, { key: 0 }, [
155
+ n(' "' + _(r.value.title) + '" ', 1)
156
+ ], 64)) : (a(), i(g, { key: 1 }, [
157
+ n(_(r.value.version) + " Spec", 1)
98
158
  ], 64))
99
- ], 64)) : (l(), u(m, { key: 2 }, [
100
- i("Collection")
159
+ ], 64)) : (a(), i(g, { key: 2 }, [
160
+ n("Collection")
101
161
  ], 64))
102
162
  ]),
103
- default: p(() => [
104
- !o.value || r(x)(t.value) ? (l(), k(W, {
163
+ default: c(() => [
164
+ !r.value || l(k)(t.value) ? (a(), h(G, {
105
165
  key: 0,
106
166
  modelValue: t.value,
107
- "onUpdate:modelValue": e[0] || (e[0] = (n) => t.value = n),
167
+ "onUpdate:modelValue": e[0] || (e[0] = (s) => t.value = s),
108
168
  placeholder: "OpenAPI/Swagger URL or document",
109
- onOnDelete: e[1] || (e[1] = (n) => f("back", n))
110
- }, null, 8, ["modelValue"])) : (l(), u(m, { key: 1 }, [
111
- U("div", q, [
112
- e[4] || (e[4] = U("div", { class: "pl-8 text-xs min-h-8 py-2 text-c-2" }, "Preview", -1)),
113
- y(r(D), {
169
+ onOnDelete: e[1] || (e[1] = (s) => b("back", s))
170
+ }, null, 8, ["modelValue"])) : (a(), i(g, { key: 1 }, [
171
+ d("div", X, [
172
+ e[5] || (e[5] = d("div", { class: "pl-8 text-xs min-h-8 py-2 text-c-2" }, "Preview", -1)),
173
+ f(l(F), {
114
174
  class: "ml-auto p-2 max-h-8 gap-1.5 text-xs hover:bg-b-2 relative",
115
175
  variant: "ghost",
116
- onClick: e[2] || (e[2] = (n) => t.value = "")
176
+ onClick: e[2] || (e[2] = (s) => t.value = "")
117
177
  }, {
118
- default: p(() => e[3] || (e[3] = [
119
- i(" Clear ")
178
+ default: c(() => e[4] || (e[4] = [
179
+ n(" Clear ")
120
180
  ])),
121
181
  _: 1
122
182
  })
123
183
  ]),
124
- o.value && !r(x)(t.value) ? (l(), k(r(_), {
184
+ r.value && !l(k)(t.value) ? (a(), h(l(J), {
125
185
  key: 0,
126
186
  class: "border max-h-[40dvh] mt-1 bg-b-2 rounded [--scalar-small:--scalar-font-size-4]",
127
187
  content: t.value,
128
188
  copy: !1,
129
- lang: C.value
130
- }, null, 8, ["content", "lang"])) : T("", !0)
189
+ lang: S.value
190
+ }, null, 8, ["content", "lang"])) : N("", !0)
131
191
  ], 64))
132
192
  ]),
133
193
  _: 1
@@ -135,5 +195,5 @@ const q = { class: "flex justify-between" }, le = /* @__PURE__ */ P({
135
195
  }
136
196
  });
137
197
  export {
138
- le as default
198
+ ve as default
139
199
  };
@@ -1 +1 @@
1
- {"version":3,"file":"ImportNowButton.vue.d.ts","sourceRoot":"","sources":["../../../src/components/ImportCollection/ImportNowButton.vue"],"names":[],"mappings":";aA6GW,MAAM,GAAG,IAAI;cACZ,QAAQ,GAAG,MAAM;;;;aADlB,MAAM,GAAG,IAAI;cACZ,QAAQ,GAAG,MAAM;;;;AAkL7B,wBASG"}
1
+ {"version":3,"file":"ImportNowButton.vue.d.ts","sourceRoot":"","sources":["../../../src/components/ImportCollection/ImportNowButton.vue"],"names":[],"mappings":";aA2GW,MAAM,GAAG,IAAI;cACZ,QAAQ,GAAG,MAAM;;;;aADlB,MAAM,GAAG,IAAI;cACZ,QAAQ,GAAG,MAAM;;;;AAgL7B,wBASG"}
@@ -1,10 +1,10 @@
1
- import { defineComponent as x, openBlock as s, createElementBlock as b, Fragment as w, createBlock as m, unref as a, withCtx as p, createTextVNode as c, createCommentVNode as g } from "vue";
1
+ import { defineComponent as b, openBlock as s, createElementBlock as v, Fragment as w, createBlock as m, unref as a, withCtx as p, createTextVNode as c, createCommentVNode as g } from "vue";
2
2
  import { isUrl as h } from "./utils/isUrl.js";
3
3
  import { ScalarButton as l } from "@scalar/components";
4
4
  import { useToasts as F } from "@scalar/use-toasts";
5
5
  import { useRouter as B } from "vue-router";
6
6
  import { useWorkspace as I } from "../../store/store.js";
7
- const R = /* @__PURE__ */ x({
7
+ const R = /* @__PURE__ */ b({
8
8
  __name: "ImportNowButton",
9
9
  props: {
10
10
  source: {},
@@ -12,20 +12,18 @@ const R = /* @__PURE__ */ x({
12
12
  },
13
13
  emits: ["importFinished"],
14
14
  setup(f, { emit: d }) {
15
- const o = f, k = d, y = B(), { importSpecFromUrl: v, importSpecFile: C, activeWorkspace: r } = I(), { toast: i } = F();
15
+ const o = f, k = d, y = B(), { importSpecFromUrl: C, importSpecFile: x, activeWorkspace: r } = I(), { toast: i } = F();
16
16
  async function n() {
17
17
  try {
18
18
  if (o.source) {
19
19
  if (h(o.source)) {
20
- const t = await v(
20
+ const [t, e] = await C(
21
21
  o.source,
22
- void 0,
23
- void 0,
24
22
  r.value.uid
25
23
  );
26
- u(t);
24
+ t || u(e);
27
25
  } else {
28
- const t = await C(
26
+ const t = await x(
29
27
  o.source,
30
28
  r.value.uid
31
29
  );
@@ -48,7 +46,7 @@ const R = /* @__PURE__ */ x({
48
46
  }
49
47
  });
50
48
  }
51
- return (t, e) => t.source ? (s(), b(w, { key: 0 }, [
49
+ return (t, e) => t.source ? (s(), v(w, { key: 0 }, [
52
50
  t.variant === "button" ? (s(), m(a(l), {
53
51
  key: 0,
54
52
  class: "text-[21px] py-2.5 px-6 rounded-lg font-bold h-fit mt-3 mb-1.5",