@scalar/api-client 2.2.54 → 2.2.56

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 (82) hide show
  1. package/CHANGELOG.md +24 -0
  2. package/dist/components/CommandPalette/CommandActionForm.vue.d.ts +1 -1
  3. package/dist/components/CommandPalette/CommandActionForm.vue.d.ts.map +1 -1
  4. package/dist/components/CommandPalette/CommandActionForm.vue.js +15 -14
  5. package/dist/components/CommandPalette/CommandPaletteImport.vue.d.ts.map +1 -1
  6. package/dist/components/CommandPalette/CommandPaletteImport.vue.js +121 -106
  7. package/dist/components/{ImportCurl/ImportCurlModal.vue.d.ts → CommandPalette/CommandPaletteImportCurl.vue.d.ts} +9 -17
  8. package/dist/components/CommandPalette/CommandPaletteImportCurl.vue.d.ts.map +1 -0
  9. package/dist/components/CommandPalette/CommandPaletteImportCurl.vue.js +7 -0
  10. package/dist/components/CommandPalette/CommandPaletteImportCurl.vue2.js +141 -0
  11. package/dist/components/CommandPalette/TheCommandPalette.vue.d.ts +98 -1
  12. package/dist/components/CommandPalette/TheCommandPalette.vue.d.ts.map +1 -1
  13. package/dist/components/CommandPalette/TheCommandPalette.vue.js +2 -2
  14. package/dist/components/CommandPalette/TheCommandPalette.vue2.js +128 -113
  15. package/dist/components/HttpMethod/HttpMethod.vue.d.ts +2 -2
  16. package/dist/components/OpenApiClientButton.vue.d.ts.map +1 -1
  17. package/dist/components/OpenApiClientButton.vue.js +2 -2
  18. package/dist/components/TopNav/TopNav.vue.d.ts.map +1 -1
  19. package/dist/components/TopNav/TopNav.vue.js +122 -94
  20. package/dist/components/TopNav/TopNavItem.vue.d.ts +1 -0
  21. package/dist/components/TopNav/TopNavItem.vue.d.ts.map +1 -1
  22. package/dist/components/TopNav/TopNavItem.vue.js +1 -1
  23. package/dist/components/TopNav/TopNavItem.vue2.js +49 -42
  24. package/dist/layouts/App/create-api-client-app.d.ts +12 -12
  25. package/dist/layouts/Modal/ApiClientModal.vue.d.ts.map +1 -1
  26. package/dist/layouts/Modal/ApiClientModal.vue.js +2 -2
  27. package/dist/layouts/Modal/create-api-client-modal.d.ts +24 -24
  28. package/dist/layouts/Web/create-api-client-web.d.ts +12 -12
  29. package/dist/libs/create-client.d.ts +12 -12
  30. package/dist/libs/create-client.d.ts.map +1 -1
  31. package/dist/libs/create-client.js +91 -115
  32. package/dist/libs/get-request-uid-by-path-method.d.ts +7 -0
  33. package/dist/libs/get-request-uid-by-path-method.d.ts.map +1 -0
  34. package/dist/libs/get-request-uid-by-path-method.js +10 -0
  35. package/dist/libs/get-request-uid-by-path-method.test.d.ts +2 -0
  36. package/dist/libs/get-request-uid-by-path-method.test.d.ts.map +1 -0
  37. package/dist/libs/send-request/create-fetch-body.d.ts +1 -1
  38. package/dist/libs/validate-parameters.d.ts +6 -0
  39. package/dist/libs/validate-parameters.d.ts.map +1 -0
  40. package/dist/libs/validate-parameters.js +12 -0
  41. package/dist/libs/validate-parameters.test.d.ts +2 -0
  42. package/dist/libs/validate-parameters.test.d.ts.map +1 -0
  43. package/dist/store/cookies.d.ts +4 -4
  44. package/dist/store/request-example.d.ts +4 -4
  45. package/dist/store/requests.d.ts +4 -4
  46. package/dist/store/store.d.ts +12 -12
  47. package/dist/style.css +1 -1
  48. package/dist/views/Request/Request.vue.d.ts +6 -3
  49. package/dist/views/Request/Request.vue.d.ts.map +1 -1
  50. package/dist/views/Request/Request.vue.js +2 -2
  51. package/dist/views/Request/Request.vue2.js +96 -145
  52. package/dist/views/Request/RequestRoot.vue.d.ts.map +1 -1
  53. package/dist/views/Request/RequestRoot.vue.js +2 -2
  54. package/dist/views/Request/RequestRoot.vue2.js +68 -57
  55. package/dist/views/Request/RequestSection/RequestBody.vue.d.ts.map +1 -1
  56. package/dist/views/Request/RequestSection/RequestBody.vue.js +2 -2
  57. package/dist/views/Request/RequestSection/RequestBody.vue2.js +1 -1
  58. package/dist/views/Request/RequestSection/RequestParams.vue.d.ts +1 -0
  59. package/dist/views/Request/RequestSection/RequestParams.vue.d.ts.map +1 -1
  60. package/dist/views/Request/RequestSection/RequestParams.vue.js +34 -31
  61. package/dist/views/Request/RequestSection/RequestPathParams.vue.d.ts +1 -0
  62. package/dist/views/Request/RequestSection/RequestPathParams.vue.d.ts.map +1 -1
  63. package/dist/views/Request/RequestSection/RequestPathParams.vue.js +35 -33
  64. package/dist/views/Request/RequestSection/RequestSection.vue.d.ts +1 -0
  65. package/dist/views/Request/RequestSection/RequestSection.vue.d.ts.map +1 -1
  66. package/dist/views/Request/RequestSection/RequestSection.vue.js +2 -2
  67. package/dist/views/Request/RequestSection/RequestSection.vue2.js +59 -54
  68. package/dist/views/Request/RequestSection/RequestTable.vue.d.ts +1 -0
  69. package/dist/views/Request/RequestSection/RequestTable.vue.d.ts.map +1 -1
  70. package/dist/views/Request/RequestSection/RequestTable.vue.js +2 -2
  71. package/dist/views/Request/RequestSection/RequestTable.vue2.js +29 -27
  72. package/dist/views/Request/RequestSidebar.vue.js +2 -2
  73. package/dist/views/Request/RequestSidebar.vue2.js +23 -23
  74. package/dist/views/Request/RequestSubpageHeader.vue.d.ts.map +1 -1
  75. package/dist/views/Request/RequestSubpageHeader.vue.js +2 -2
  76. package/dist/views/Request/RequestSubpageHeader.vue2.js +4 -4
  77. package/dist/views/Request/ResponseSection/ResponseEmpty.vue2.js +1 -1
  78. package/dist/views/Request/libs/request.js +1 -2
  79. package/package.json +12 -12
  80. package/dist/components/ImportCurl/ImportCurlModal.vue.d.ts.map +0 -1
  81. package/dist/components/ImportCurl/ImportCurlModal.vue.js +0 -7
  82. package/dist/components/ImportCurl/ImportCurlModal.vue2.js +0 -125
package/CHANGELOG.md CHANGED
@@ -1,5 +1,29 @@
1
1
  # @scalar/api-client
2
2
 
3
+ ## 2.2.56
4
+
5
+ ### Patch Changes
6
+
7
+ - a5dc41f: fix: remove header update if initial body is set to raw
8
+
9
+ ## 2.2.55
10
+
11
+ ### Patch Changes
12
+
13
+ - d078633: fix: updates top nav icon logic
14
+ - 0d4520f: fix(themes): improve how we handle zoomed in screens
15
+ - 98323b8: feat: adds command palette import curl
16
+ - eb3bb7f: fix: sets error cue on invalid param request
17
+ - ea19156: fix: routing to the api client modal
18
+ - Updated dependencies [0d4520f]
19
+ - @scalar/components@0.13.28
20
+ - @scalar/use-hooks@0.1.25
21
+ - @scalar/themes@0.9.71
22
+ - @scalar/use-codemirror@0.11.73
23
+ - @scalar/oas-utils@0.2.110
24
+ - @scalar/import@0.2.30
25
+ - @scalar/postman-to-openapi@0.1.33
26
+
3
27
  ## 2.2.54
4
28
 
5
29
  ### Patch Changes
@@ -1,7 +1,7 @@
1
1
  import { type useLoadingState } from '@scalar/components';
2
2
  type __VLS_Props = {
3
3
  loading?: ReturnType<typeof useLoadingState>;
4
- disabled: boolean;
4
+ disabled?: boolean;
5
5
  };
6
6
  declare function __VLS_template(): {
7
7
  attrs: Partial<{}>;
@@ -1 +1 @@
1
- {"version":3,"file":"CommandActionForm.vue.d.ts","sourceRoot":"","sources":["../../../src/components/CommandPalette/CommandActionForm.vue"],"names":[],"mappings":"AAAA,OAsCO,EAAgB,KAAK,eAAe,EAAE,MAAM,oBAAoB,CAAA;AAIvE,KAAK,WAAW,GAAG;IACjB,OAAO,CAAC,EAAE,UAAU,CAAC,OAAO,eAAe,CAAC,CAAA;IAC5C,QAAQ,EAAE,OAAO,CAAA;CAClB,CAAC;AAiBF,iBAAS,cAAc;WAwET,OAAO,IAA6B;;yBAVrB,GAAG;yBACH,GAAG;wBACJ,GAAG;;;;EAa9B;AAUD,KAAK,oBAAoB,GAAG,UAAU,CAAC,OAAO,cAAc,CAAC,CAAC;AAC9D,QAAA,MAAM,eAAe;;;;;;;;8FAQnB,CAAC;wBACkB,uBAAuB,CAAC,OAAO,eAAe,EAAE,oBAAoB,CAAC,OAAO,CAAC,CAAC;AAAnG,wBAAoG;AAUpG,KAAK,uBAAuB,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,GAAG;IACxC,QAAO;QACN,MAAM,EAAE,CAAC,CAAC;KAEV,CAAA;CACD,CAAC"}
1
+ {"version":3,"file":"CommandActionForm.vue.d.ts","sourceRoot":"","sources":["../../../src/components/CommandPalette/CommandActionForm.vue"],"names":[],"mappings":"AA4CA,OAAO,EAGL,KAAK,eAAe,EACrB,MAAM,oBAAoB,CAAA;AAI3B,KAAK,WAAW,GAAG;IACjB,OAAO,CAAC,EAAE,UAAU,CAAC,OAAO,eAAe,CAAC,CAAA;IAC5C,QAAQ,CAAC,EAAE,OAAO,CAAA;CACnB,CAAC;AAmBF,iBAAS,cAAc;WAmET,OAAO,IAA6B;;yBAVrB,GAAG;yBACH,GAAG;wBACJ,GAAG;;;;EAa9B;AAWD,KAAK,oBAAoB,GAAG,UAAU,CAAC,OAAO,cAAc,CAAC,CAAC;AAC9D,QAAA,MAAM,eAAe;;;;;;;;8FAQnB,CAAC;wBACkB,uBAAuB,CAAC,OAAO,eAAe,EAAE,oBAAoB,CAAC,OAAO,CAAC,CAAC;AAAnG,wBAAoG;AAUpG,KAAK,uBAAuB,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,GAAG;IACxC,QAAO;QACN,MAAM,EAAE,CAAC,CAAC;KAEV,CAAA;CACD,CAAC"}
@@ -1,35 +1,36 @@
1
- import { defineComponent as n, openBlock as i, createElementBlock as d, withKeys as a, withModifiers as l, createElementVNode as o, renderSlot as s, createVNode as r, unref as m, withCtx as f, createTextVNode as p } from "vue";
2
- import { ScalarButton as u } from "@scalar/components";
3
- const b = { class: "relative flex min-h-20 flex-col rounded" }, x = { class: "flex gap-2" }, c = { class: "flex max-h-8 flex-1" }, h = /* @__PURE__ */ n({
1
+ import { defineComponent as a, openBlock as d, createElementBlock as r, withKeys as m, withModifiers as l, createElementVNode as t, normalizeProps as p, guardReactiveProps as f, unref as n, renderSlot as s, createVNode as u, withCtx as x, createTextVNode as b } from "vue";
2
+ import { useBindCx as c, ScalarButton as g } from "@scalar/components";
3
+ const v = { class: "flex gap-2" }, w = { class: "flex max-h-8 flex-1" }, h = /* @__PURE__ */ a({
4
4
  __name: "CommandActionForm",
5
5
  props: {
6
6
  loading: {},
7
7
  disabled: { type: Boolean, default: !1 }
8
8
  },
9
9
  emits: ["submit", "cancel", "back"],
10
- setup(g) {
11
- return (e, t) => (i(), d("form", {
10
+ setup(B) {
11
+ const { cx: i } = c();
12
+ return (e, o) => (d(), r("form", {
12
13
  class: "flex w-full flex-col gap-3",
13
- onKeydown: t[0] || (t[0] = a(l(() => {
14
+ onKeydown: o[0] || (o[0] = m(l(() => {
14
15
  }, ["stop"]), ["enter"])),
15
- onSubmit: t[1] || (t[1] = l((v) => e.$emit("submit"), ["prevent", "stop"]))
16
+ onSubmit: o[1] || (o[1] = l((C) => e.$emit("submit"), ["prevent", "stop"]))
16
17
  }, [
17
- o("div", b, [
18
+ t("div", p(f(n(i)("relative flex min-h-20 flex-col rounded"))), [
18
19
  s(e.$slots, "default")
19
- ]),
20
- o("div", x, [
21
- o("div", c, [
20
+ ], 16),
21
+ t("div", v, [
22
+ t("div", w, [
22
23
  s(e.$slots, "options")
23
24
  ]),
24
- r(m(u), {
25
+ u(n(g), {
25
26
  class: "max-h-8 p-0 px-3 text-xs",
26
27
  disabled: e.disabled,
27
28
  loading: e.loading,
28
29
  type: "submit"
29
30
  }, {
30
- default: f(() => [
31
+ default: x(() => [
31
32
  s(e.$slots, "submit", {}, () => [
32
- t[2] || (t[2] = p("Continue"))
33
+ o[2] || (o[2] = b("Continue"))
33
34
  ])
34
35
  ]),
35
36
  _: 3
@@ -1 +1 @@
1
- {"version":3,"file":"CommandPaletteImport.vue.d.ts","sourceRoot":"","sources":["../../../src/components/CommandPalette/CommandPaletteImport.vue"],"names":[],"mappings":";;;;;;;AAqtBA,wBAOG"}
1
+ {"version":3,"file":"CommandPaletteImport.vue.d.ts","sourceRoot":"","sources":["../../../src/components/CommandPalette/CommandPaletteImport.vue"],"names":[],"mappings":";;;;;;;AA+vBA,wBAOG"}
@@ -1,94 +1,95 @@
1
- import { defineComponent as J, ref as L, computed as C, watch as R, openBlock as i, createBlock as U, unref as s, withCtx as v, createElementVNode as w, createVNode as b, createTextVNode as f, createElementBlock as c, Fragment as g, toDisplayString as V, createCommentVNode as Y } from "vue";
2
- import { useLoadingState as q, ScalarButton as T, ScalarIcon as G, ScalarTooltip as H, ScalarCodeBlock as K } from "@scalar/components";
3
- import { useToasts as Q } from "@scalar/use-toasts";
4
- import { useRouter as X } from "vue-router";
5
- import { useActiveEntities as Z } from "../../store/active-entities.js";
6
- import ee from "./CommandActionForm.vue.js";
7
- import te from "./CommandActionInput.vue.js";
8
- import oe from "./WatchModeToggle.vue.js";
9
- import { isPostmanCollection as _, getPostmanDocumentDetails as le, convertPostmanToOpenApi as F } from "../../libs/postman.js";
10
- import { getOpenApiDocumentDetails as ae } from "../../libs/getOpenApiDocumentDetails.js";
11
- import { isUrl as P } from "../../libs/isUrl.js";
12
- import { useFileDialog as ne } from "../../hooks/useFileDialog.js";
1
+ import { defineComponent as G, ref as R, computed as k, watch as D, openBlock as n, createBlock as S, unref as s, withCtx as v, createElementVNode as w, createVNode as C, createTextVNode as f, createElementBlock as u, Fragment as g, toDisplayString as V, createCommentVNode as H } from "vue";
2
+ import { useLoadingState as K, ScalarButton as T, ScalarIcon as Q, ScalarTooltip as X, ScalarCodeBlock as Z } from "@scalar/components";
3
+ import { useToasts as ee } from "@scalar/use-toasts";
4
+ import { useRouter as te } from "vue-router";
5
+ import { importCurlCommand as oe } from "../../libs/importers/curl.js";
6
+ import { useActiveEntities as ae } from "../../store/active-entities.js";
7
+ import le from "./CommandActionForm.vue.js";
8
+ import ne from "./CommandActionInput.vue.js";
9
+ import re from "./WatchModeToggle.vue.js";
10
+ import { isPostmanCollection as _, getPostmanDocumentDetails as ie, convertPostmanToOpenApi as F } from "../../libs/postman.js";
11
+ import { getOpenApiDocumentDetails as se } from "../../libs/getOpenApiDocumentDetails.js";
12
+ import { isUrl as U } from "../../libs/isUrl.js";
13
+ import { useFileDialog as ce } from "../../hooks/useFileDialog.js";
13
14
  import { PathId as M } from "../../routes.js";
14
- import { useWorkspace as ie } from "../../store/store.js";
15
- const re = { class: "flex justify-between" }, se = { class: "flex w-full flex-row items-center justify-between gap-3" }, ue = { class: "w-content bg-b-1 z-100 text-xxs text-c-1 pointer-events-none z-10 grid max-w-[320px] gap-1.5 rounded p-2 leading-5 shadow-lg" }, ce = { class: "text-c-2 flex items-center" }, me = {
15
+ import { useWorkspace as ue } from "../../store/store.js";
16
+ const me = { class: "flex justify-between" }, de = { class: "flex w-full flex-row items-center justify-between gap-3" }, pe = { class: "w-content bg-b-1 text-xxs text-c-1 pointer-events-none z-10 grid max-w-[320px] gap-1.5 rounded p-2 leading-5 shadow-lg" }, ve = { class: "text-c-2 flex items-center" }, fe = {
16
17
  key: 0,
17
18
  class: "text-pretty"
18
- }, de = {
19
+ }, ge = {
19
20
  key: 1,
20
21
  class: "text-pretty"
21
- }, _e = /* @__PURE__ */ J({
22
+ }, De = /* @__PURE__ */ G({
22
23
  __name: "CommandPaletteImport",
23
24
  emits: ["close", "back"],
24
- setup(pe, { emit: $ }) {
25
- const S = $, z = X(), { activeWorkspace: m } = Z(), { importSpecFile: k, importSpecFromUrl: B } = ie(), { toast: d } = Q(), p = q(), o = L(""), y = L(!0), r = C(() => _(o.value) ? le(o.value) : ae(o.value)), A = C(
26
- () => r.value ? r.value.type : "json"
25
+ setup(ye, { emit: N }) {
26
+ const P = N, $ = te(), { activeWorkspace: m, activeCollection: B } = ae(), { importSpecFile: b, importSpecFromUrl: W, events: j } = ue(), { toast: d } = ee(), p = K(), a = R(""), y = R(!0), i = k(() => _(a.value) ? ie(a.value) : se(a.value)), A = k(
27
+ () => i.value ? i.value.type : "json"
27
28
  );
28
- function x(l) {
29
+ function x(t) {
29
30
  var e;
30
- l && z.push({
31
+ t && $.push({
31
32
  name: "collection",
32
33
  params: {
33
34
  [M.Workspace]: (e = m.value) == null ? void 0 : e.uid,
34
- [M.Collection]: l.uid
35
+ [M.Collection]: t.uid
35
36
  }
36
37
  });
37
38
  }
38
- const h = C(() => P(o.value)), N = C(() => !!r.value), { open: j } = ne({
39
- onChange: async (l) => {
40
- const e = l == null ? void 0 : l[0];
39
+ const h = k(() => U(a.value)), z = k(() => !!i.value), { open: E } = ce({
40
+ onChange: async (t) => {
41
+ const e = t == null ? void 0 : t[0];
41
42
  if (e) {
42
- const a = new FileReader();
43
- a.onload = async (I) => {
44
- var u, O, D;
45
- const t = (u = I.target) == null ? void 0 : u.result;
43
+ const r = new FileReader();
44
+ r.onload = async (I) => {
45
+ var c, L, O;
46
+ const o = (c = I.target) == null ? void 0 : c.result;
46
47
  try {
47
- if (_(t)) {
48
- const n = await k(
49
- await F(t),
50
- ((O = m.value) == null ? void 0 : O.uid) ?? ""
48
+ if (_(o)) {
49
+ const l = await b(
50
+ await F(o),
51
+ ((L = m.value) == null ? void 0 : L.uid) ?? ""
51
52
  );
52
- x(n == null ? void 0 : n.collection);
53
+ x(l == null ? void 0 : l.collection);
53
54
  } else {
54
- const n = await k(
55
- t,
56
- ((D = m.value) == null ? void 0 : D.uid) ?? ""
55
+ const l = await b(
56
+ o,
57
+ ((O = m.value) == null ? void 0 : O.uid) ?? ""
57
58
  );
58
- x(n == null ? void 0 : n.collection);
59
+ x(l == null ? void 0 : l.collection);
59
60
  }
60
- d("Import successful", "info"), S("close");
61
- } catch (n) {
62
- console.error(n);
63
- const E = (n == null ? void 0 : n.message) || "Unknown error";
64
- d(`Import failed: ${E}`, "error");
61
+ d("Import successful", "info"), P("close");
62
+ } catch (l) {
63
+ console.error(l);
64
+ const q = (l == null ? void 0 : l.message) || "Unknown error";
65
+ d(`Import failed: ${q}`, "error");
65
66
  }
66
- }, a.readAsText(e);
67
+ }, r.readAsText(e);
67
68
  }
68
69
  },
69
70
  multiple: !1,
70
71
  accept: ".json,.yaml,.yml"
71
72
  });
72
- R(h, (l) => {
73
- l || (y.value = !1);
74
- }), R(o, (l) => {
75
- P(l) || (y.value = !1);
73
+ D(h, (t) => {
74
+ t || (y.value = !1);
75
+ }), D(a, (t) => {
76
+ U(t) || (y.value = !1);
76
77
  });
77
- async function W() {
78
- var l, e, a, I;
79
- if (!(!o.value || p.isLoading)) {
78
+ async function J() {
79
+ var t, e, r, I;
80
+ if (!(!a.value || p.isLoading)) {
80
81
  p.startLoading();
81
82
  try {
82
83
  if (h.value) {
83
- const [t, u] = await B(
84
- o.value,
85
- ((l = m.value) == null ? void 0 : l.uid) ?? "",
84
+ const [o, c] = await W(
85
+ a.value,
86
+ ((t = m.value) == null ? void 0 : t.uid) ?? "",
86
87
  {
87
88
  proxyUrl: (e = m.value) == null ? void 0 : e.proxyUrl,
88
89
  watchMode: y.value
89
90
  }
90
91
  );
91
- if (x(u == null ? void 0 : u.collection), t) {
92
+ if (x(c == null ? void 0 : c.collection), o) {
92
93
  d(
93
94
  "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.",
94
95
  "error",
@@ -96,47 +97,61 @@ const re = { class: "flex justify-between" }, se = { class: "flex w-full flex-ro
96
97
  ), p.invalidate(2e3, !0);
97
98
  return;
98
99
  }
99
- } else if (N.value)
100
- if (_(o.value)) {
101
- const t = await k(
102
- await F(o.value),
103
- ((a = m.value) == null ? void 0 : a.uid) ?? ""
100
+ } else if (z.value)
101
+ if (_(a.value)) {
102
+ const o = await b(
103
+ await F(a.value),
104
+ ((r = m.value) == null ? void 0 : r.uid) ?? ""
104
105
  );
105
- x(t == null ? void 0 : t.collection), d("Successfully converted Postman collection", "info");
106
+ x(o == null ? void 0 : o.collection), d("Successfully converted Postman collection", "info");
106
107
  } else {
107
- const t = await k(
108
- o.value,
108
+ const o = await b(
109
+ a.value,
109
110
  ((I = m.value) == null ? void 0 : I.uid) ?? ""
110
111
  );
111
- x(t == null ? void 0 : t.collection);
112
+ x(o == null ? void 0 : o.collection);
112
113
  }
113
114
  else {
114
115
  d("Import failed: Invalid URL or OpenAPI document", "error"), p.invalidate(2e3, !0);
115
116
  return;
116
117
  }
117
- p.clear(), S("close"), d("Import successful", "info");
118
- } catch (t) {
119
- console.error("[importCollection]", t);
120
- const u = (t == null ? void 0 : t.message) || "Unknown error";
121
- p.invalidate(2e3, !0), d(`Import failed: ${u}`, "error");
118
+ p.clear(), P("close"), d("Import successful", "info");
119
+ } catch (o) {
120
+ console.error("[importCollection]", o);
121
+ const c = (o == null ? void 0 : o.message) || "Unknown error";
122
+ p.invalidate(2e3, !0), d(`Import failed: ${c}`, "error");
122
123
  }
123
124
  }
124
125
  }
125
- return (l, e) => (i(), U(ee, {
126
- disabled: !o.value.trim(),
126
+ const Y = (t) => {
127
+ var e;
128
+ if (t.trim().toLowerCase().startsWith("curl")) {
129
+ j.commandPalette.emit({
130
+ commandName: "Import from cURL",
131
+ metaData: {
132
+ parsedCurl: oe(t),
133
+ collectionUid: (e = B.value) == null ? void 0 : e.uid
134
+ }
135
+ });
136
+ return;
137
+ }
138
+ a.value = t;
139
+ };
140
+ return (t, e) => (n(), S(le, {
141
+ disabled: !a.value.trim(),
127
142
  loading: s(p),
128
- onSubmit: W
143
+ onSubmit: J
129
144
  }, {
130
145
  options: v(() => [
131
- w("div", se, [
132
- b(s(T), {
146
+ w("div", de, [
147
+ C(s(T), {
133
148
  class: "hover:bg-b-2 relative max-h-8 gap-1.5 p-2 text-xs",
134
149
  variant: "outlined",
135
- onClick: s(j)
150
+ onClick: s(E)
136
151
  }, {
137
152
  default: v(() => [
138
- e[6] || (e[6] = f(" JSON, or YAML File ")),
139
- b(s(G), {
153
+ e[5] || (e[5] = f(" JSON, or YAML File ")),
154
+ C(s(Q), {
140
155
  class: "text-c-3",
141
156
  icon: "UploadSimple",
142
157
  size: "md"
@@ -144,23 +159,23 @@ const re = { class: "flex justify-between" }, se = { class: "flex w-full flex-ro
144
159
  ]),
145
160
  _: 1
146
161
  }, 8, ["onClick"]),
147
- b(s(H), {
162
+ C(s(X), {
148
163
  as: "div",
149
164
  class: "z-[10001]",
150
165
  side: "bottom",
151
166
  sideOffset: 5
152
167
  }, {
153
168
  trigger: v(() => [
154
- b(oe, {
169
+ C(re, {
155
170
  modelValue: y.value,
156
- "onUpdate:modelValue": e[3] || (e[3] = (a) => y.value = a),
171
+ "onUpdate:modelValue": e[2] || (e[2] = (r) => y.value = r),
157
172
  disabled: !h.value
158
173
  }, null, 8, ["modelValue", "disabled"])
159
174
  ]),
160
175
  content: v(() => [
161
- w("div", ue, [
162
- w("div", ce, [
163
- h.value ? (i(), c("span", me, " Automatically updates the API client when the OpenAPI URL content changes, ensuring your client remains up-to-date. ")) : (i(), c("span", de, " Watch Mode is only available for URL imports. It automatically updates the API client when the OpenAPI URL content changes. "))
176
+ w("div", pe, [
177
+ w("div", ve, [
178
+ h.value ? (n(), u("span", fe, " Automatically updates the API client when the OpenAPI URL content changes, ensuring your client remains up-to-date. ")) : (n(), u("span", ge, " Watch Mode is only available for URL imports. It automatically updates the API client when the OpenAPI URL content changes. "))
164
179
  ])
165
180
  ])
166
181
  ]),
@@ -169,47 +184,47 @@ const re = { class: "flex justify-between" }, se = { class: "flex w-full flex-ro
169
184
  ])
170
185
  ]),
171
186
  submit: v(() => [
172
- e[7] || (e[7] = f(" Import ")),
173
- h.value ? (i(), c(g, { key: 0 }, [
187
+ e[6] || (e[6] = f(" Import ")),
188
+ h.value ? (n(), u(g, { key: 0 }, [
174
189
  f(" from URL ")
175
- ], 64)) : r.value && A.value ? (i(), c(g, { key: 1 }, [
176
- r.value.title ? (i(), c(g, { key: 0 }, [
177
- f(' "' + V(r.value.title) + '" ', 1)
178
- ], 64)) : (i(), c(g, { key: 1 }, [
179
- f(V(r.value.version), 1)
190
+ ], 64)) : i.value && A.value ? (n(), u(g, { key: 1 }, [
191
+ i.value.title ? (n(), u(g, { key: 0 }, [
192
+ f(' "' + V(i.value.title) + '" ', 1)
193
+ ], 64)) : (n(), u(g, { key: 1 }, [
194
+ f(V(i.value.version), 1)
180
195
  ], 64))
181
- ], 64)) : (i(), c(g, { key: 2 }, [
196
+ ], 64)) : (n(), u(g, { key: 2 }, [
182
197
  f(" Collection ")
183
198
  ], 64))
184
199
  ]),
185
200
  default: v(() => [
186
- !r.value || s(P)(o.value) ? (i(), U(te, {
201
+ !i.value || s(U)(a.value) ? (n(), S(ne, {
187
202
  key: 0,
188
- modelValue: o.value,
189
- "onUpdate:modelValue": e[0] || (e[0] = (a) => o.value = a),
190
- placeholder: "OpenAPI/Swagger/Postman URL or document",
191
- onOnDelete: e[1] || (e[1] = (a) => S("back", a))
192
- }, null, 8, ["modelValue"])) : (i(), c(g, { key: 1 }, [
193
- w("div", re, [
194
- e[5] || (e[5] = w("div", { class: "text-c-2 min-h-8 py-2 pl-8 text-xs" }, "Preview", -1)),
195
- b(s(T), {
203
+ modelValue: a.value,
204
+ "onUpdate:modelValue": Y,
205
+ placeholder: "OpenAPI/Swagger/Postman URL or cURL",
206
+ onOnDelete: e[0] || (e[0] = (r) => P("back", r))
207
+ }, null, 8, ["modelValue"])) : (n(), u(g, { key: 1 }, [
208
+ w("div", me, [
209
+ e[4] || (e[4] = w("div", { class: "text-c-2 min-h-8 py-2 pl-8 text-xs" }, "Preview", -1)),
210
+ C(s(T), {
196
211
  class: "hover:bg-b-2 relative ml-auto max-h-8 gap-1.5 p-2 text-xs",
197
212
  variant: "ghost",
198
- onClick: e[2] || (e[2] = (a) => o.value = "")
213
+ onClick: e[1] || (e[1] = (r) => a.value = "")
199
214
  }, {
200
- default: v(() => e[4] || (e[4] = [
215
+ default: v(() => e[3] || (e[3] = [
201
216
  f(" Clear ")
202
217
  ])),
203
218
  _: 1
204
219
  })
205
220
  ]),
206
- r.value && !s(P)(o.value) ? (i(), U(s(K), {
221
+ i.value && !s(U)(a.value) ? (n(), S(s(Z), {
207
222
  key: 0,
208
223
  class: "bg-b-2 mt-1 max-h-[40dvh] rounded border [--scalar-small:--scalar-font-size-4]",
209
- content: o.value,
224
+ content: a.value,
210
225
  copy: !1,
211
226
  lang: A.value
212
- }, null, 8, ["content", "lang"])) : Y("", !0)
227
+ }, null, 8, ["content", "lang"])) : H("", !0)
213
228
  ], 64))
214
229
  ]),
215
230
  _: 1
@@ -217,5 +232,5 @@ const re = { class: "flex justify-between" }, se = { class: "flex w-full flex-ro
217
232
  }
218
233
  });
219
234
  export {
220
- _e as default
235
+ De as default
221
236
  };
@@ -1,27 +1,19 @@
1
1
  import type { RequestPayload } from '@scalar/oas-utils/entities/spec';
2
+ type ExtendedRequestPayload = RequestPayload & {
3
+ url?: string;
4
+ };
2
5
  type __VLS_Props = {
3
- parsedCurl: RequestPayload | null;
4
- state: {
5
- open: boolean;
6
- show: () => void;
7
- hide: () => void;
6
+ metaData: {
7
+ parsedCurl: ExtendedRequestPayload;
8
+ collectionUid: string;
8
9
  };
9
- collectionUid: string;
10
10
  };
11
11
  declare const _default: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
12
12
  close: () => any;
13
- importCurl: (payload: {
14
- parsedCurl: RequestPayload;
15
- requestName: string;
16
- collectionUid: string;
17
- }) => any;
13
+ back: (e: KeyboardEvent) => any;
18
14
  }, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
19
15
  onClose?: () => any;
20
- onImportCurl?: (payload: {
21
- parsedCurl: RequestPayload;
22
- requestName: string;
23
- collectionUid: string;
24
- }) => any;
16
+ onBack?: (e: KeyboardEvent) => any;
25
17
  }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
26
18
  export default _default;
27
- //# sourceMappingURL=ImportCurlModal.vue.d.ts.map
19
+ //# sourceMappingURL=CommandPaletteImportCurl.vue.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CommandPaletteImportCurl.vue.d.ts","sourceRoot":"","sources":["../../../src/components/CommandPalette/CommandPaletteImportCurl.vue"],"names":[],"mappings":"AAiMA,OAAO,KAAK,EAEV,cAAc,EACf,MAAM,iCAAiC,CAAA;AAaxC,KAAK,sBAAsB,GAAG,cAAc,GAAG;IAC7C,GAAG,CAAC,EAAE,MAAM,CAAA;CACb,CAAA;AAED,KAAK,WAAW,GAAG;IACjB,QAAQ,EAAE;QACR,UAAU,EAAE,sBAAsB,CAAA;QAClC,aAAa,EAAE,MAAM,CAAA;KACtB,CAAA;CACF,CAAC;;;;;;;;AAqQF,wBAOG"}
@@ -0,0 +1,7 @@
1
+ import o from "./CommandPaletteImportCurl.vue2.js";
2
+ /* empty css */
3
+ import t from "../../_virtual/_plugin-vue_export-helper.js";
4
+ const f = /* @__PURE__ */ t(o, [["__scopeId", "data-v-fd598a6f"]]);
5
+ export {
6
+ f as default
7
+ };
@@ -0,0 +1,141 @@
1
+ import { defineComponent as N, ref as I, computed as A, openBlock as G, createElementBlock as H, Fragment as T, createElementVNode as r, createVNode as n, withCtx as d, unref as f, normalizeClass as X, toDisplayString as v } from "vue";
2
+ import { ScalarListbox as $, ScalarButton as J, ScalarIcon as K } from "@scalar/components";
3
+ import { REGEX as Q } from "@scalar/oas-utils/helpers";
4
+ import { useRouter as Y } from "vue-router";
5
+ import Z from "./CommandActionForm.vue.js";
6
+ import _ from "../HttpMethod/HttpMethod.vue.js";
7
+ import { useActiveEntities as ee } from "../../store/active-entities.js";
8
+ import { PathId as C } from "../../routes.js";
9
+ import { useWorkspace as te } from "../../store/store.js";
10
+ const ae = { class: "flex h-9 flex-row items-center gap-2 rounded border p-[3px] text-sm" }, le = { class: "flex h-full" }, re = { class: "scroll-timeline-x whitespace-nowrap" }, se = { class: "flex" }, ve = /* @__PURE__ */ N({
11
+ __name: "CommandPaletteImportCurl",
12
+ props: {
13
+ metaData: {}
14
+ },
15
+ emits: ["close", "back"],
16
+ setup(a, { emit: B }) {
17
+ const V = B, O = te(), { activeWorkspaceCollections: h, activeCollection: W, activeWorkspace: D } = ee(), { requestMutators: L, serverMutators: M, servers: P } = O, c = I(""), j = Y(), p = A(
18
+ () => h.value.map((t) => {
19
+ var e;
20
+ return {
21
+ id: t.uid,
22
+ label: ((e = t.info) == null ? void 0 : e.title) ?? "Unititled Collection"
23
+ };
24
+ })
25
+ ), s = I(
26
+ a.metaData.collectionUid ? p.value.find(
27
+ (t) => t.id === a.metaData.collectionUid
28
+ ) : p.value.find(
29
+ (t) => {
30
+ var e;
31
+ return t.id === ((e = W.value) == null ? void 0 : e.uid);
32
+ }
33
+ )
34
+ );
35
+ function z({ collectionUid: t }) {
36
+ var i, u, b, w, k, S, q, R, U, g;
37
+ if (!a.metaData.parsedCurl) return;
38
+ const e = h.value.find(
39
+ (m) => m.uid === t
40
+ );
41
+ if (!e) return;
42
+ const l = ((i = e == null ? void 0 : e.info) == null ? void 0 : i.title) === "Drafts";
43
+ if (!l && a.metaData.parsedCurl.servers) {
44
+ const m = Object.values(P).find(
45
+ (F) => {
46
+ var y, E;
47
+ return F.url === ((E = (y = a.metaData.parsedCurl) == null ? void 0 : y.servers) == null ? void 0 : E[0]);
48
+ }
49
+ );
50
+ m ? c.value = m.uid : c.value = M.add(
51
+ { url: a.metaData.parsedCurl.servers[0] ?? "/" },
52
+ e.uid
53
+ ).uid;
54
+ }
55
+ const o = L.add(
56
+ {
57
+ summary: l ? (b = (u = a.metaData.parsedCurl) == null ? void 0 : u.url) == null ? void 0 : b.replace(Q.PROTOCOL, "") : (w = a.metaData.parsedCurl) == null ? void 0 : w.path,
58
+ path: l ? (k = a.metaData.parsedCurl) == null ? void 0 : k.url : (S = a.metaData.parsedCurl) == null ? void 0 : S.path,
59
+ method: (q = a.metaData.parsedCurl) == null ? void 0 : q.method,
60
+ parameters: (R = a.metaData.parsedCurl) == null ? void 0 : R.parameters,
61
+ selectedServerUid: l ? void 0 : c.value,
62
+ requestBody: (U = a.metaData.parsedCurl) == null ? void 0 : U.requestBody
63
+ },
64
+ e.uid
65
+ );
66
+ o && ((g = D.value) != null && g.uid) && j.push({
67
+ name: "request",
68
+ params: {
69
+ [C.Workspace]: D.value.uid,
70
+ [C.Collection]: e.uid,
71
+ [C.Request]: o.uid
72
+ }
73
+ }), V("close");
74
+ }
75
+ const x = () => {
76
+ var t;
77
+ z({
78
+ collectionUid: ((t = s.value) == null ? void 0 : t.id) ?? ""
79
+ });
80
+ };
81
+ return (t, e) => (G(), H(T, null, [
82
+ e[1] || (e[1] = r("div", { class: "text-c-2 flex-center py-1.5 text-sm" }, "Import cURL", -1)),
83
+ n(Z, {
84
+ onSubmit: x,
85
+ class: "mt-1.5 min-h-fit"
86
+ }, {
87
+ options: d(() => [
88
+ r("div", se, [
89
+ n(f($), {
90
+ modelValue: s.value,
91
+ "onUpdate:modelValue": e[0] || (e[0] = (l) => s.value = l),
92
+ options: p.value
93
+ }, {
94
+ default: d(() => [
95
+ n(f(J), {
96
+ class: "hover:bg-b-2 max-h-8 w-full justify-between gap-1 p-2 text-xs",
97
+ variant: "outlined"
98
+ }, {
99
+ default: d(() => [
100
+ r("span", {
101
+ class: X(["whitespace-nowrap", s.value ? "text-c-1" : "text-c-3"])
102
+ }, v(s.value ? s.value.label : "Select Collection"), 3),
103
+ n(f(K), {
104
+ class: "text-c-3",
105
+ icon: "ChevronDown",
106
+ size: "md"
107
+ })
108
+ ]),
109
+ _: 1
110
+ })
111
+ ]),
112
+ _: 1
113
+ }, 8, ["modelValue", "options"])
114
+ ])
115
+ ]),
116
+ submit: d(() => [
117
+ r("span", { onClick: x }, "Import Request")
118
+ ]),
119
+ default: d(() => {
120
+ var l, o, i, u;
121
+ return [
122
+ r("div", ae, [
123
+ r("div", le, [
124
+ n(_, {
125
+ isEditable: !1,
126
+ isSquare: "",
127
+ method: ((l = t.metaData.parsedCurl) == null ? void 0 : l.method) || "get"
128
+ }, null, 8, ["method"])
129
+ ]),
130
+ r("span", re, v(((i = (o = t.metaData.parsedCurl) == null ? void 0 : o.servers) == null ? void 0 : i[0]) || "") + v(((u = t.metaData.parsedCurl) == null ? void 0 : u.path) || ""), 1)
131
+ ])
132
+ ];
133
+ }),
134
+ _: 1
135
+ })
136
+ ], 64));
137
+ }
138
+ });
139
+ export {
140
+ ve as default
141
+ };