@scalar/api-client 2.0.1 → 2.0.2

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.
@@ -1,4 +1,4 @@
1
- import { type useModal } from '@scalar/components';
1
+ import type { useModal } from '@scalar/components';
2
2
  declare const _default: import("vue").DefineComponent<__VLS_TypePropsToOption<{
3
3
  /** Controls opening and closing the modal */
4
4
  modalState: ReturnType<typeof useModal>;
@@ -1 +1 @@
1
- {"version":3,"file":"ApiClientModal.vue.d.ts","sourceRoot":"","sources":["../../src/Modal/ApiClientModal.vue"],"names":[],"mappings":"AAqCA,OAAO,EAGL,KAAK,QAAQ,EACd,MAAM,oBAAoB,CAAA;;IAOzB,6CAA6C;gBACjC,UAAU,CAAC,OAAO,QAAQ,CAAC;;IADvC,6CAA6C;gBACjC,UAAU,CAAC,OAAO,QAAQ,CAAC;;AA0EzC,wBAMG;AAOH,KAAK,sBAAsB,CAAC,CAAC,IAAI,CAAC,SAAS,SAAS,GAAG,KAAK,GAAG,CAAC,CAAC;AAC5D,KAAK,uBAAuB,CAAC,CAAC,IAAI;KAChC,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,GAAG,EAAE,SAAS,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,GACpC;QAAE,IAAI,EAAE,OAAO,KAAK,EAAE,QAAQ,CAAC,sBAAsB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;KAAE,GAC9D;QAAE,IAAI,EAAE,OAAO,KAAK,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QAAC,QAAQ,EAAE,IAAI,CAAA;KAAE;CACzD,CAAC"}
1
+ {"version":3,"file":"ApiClientModal.vue.d.ts","sourceRoot":"","sources":["../../src/Modal/ApiClientModal.vue"],"names":[],"mappings":"AAyKA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAA;;IAOhD,6CAA6C;gBACjC,UAAU,CAAC,OAAO,QAAQ,CAAC;;IADvC,6CAA6C;gBACjC,UAAU,CAAC,OAAO,QAAQ,CAAC;;AAqGzC,wBAMG;AAOH,KAAK,sBAAsB,CAAC,CAAC,IAAI,CAAC,SAAS,SAAS,GAAG,KAAK,GAAG,CAAC,CAAC;AAC5D,KAAK,uBAAuB,CAAC,CAAC,IAAI;KAChC,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,GAAG,EAAE,SAAS,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,GACpC;QAAE,IAAI,EAAE,OAAO,KAAK,EAAE,QAAQ,CAAC,sBAAsB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;KAAE,GAC9D;QAAE,IAAI,EAAE,OAAO,KAAK,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QAAC,QAAQ,EAAE,IAAI,CAAA;KAAE;CACzD,CAAC"}
@@ -1,24 +1,8 @@
1
- import { defineComponent as o, onBeforeMount as a, openBlock as r, createBlock as l, unref as e, withCtx as s, createVNode as n } from "vue";
2
- import { addScalarClassesToHeadless as d, ScalarModal as f } from "@scalar/components";
3
- import { RouterView as p } from "vue-router";
4
- const C = /* @__PURE__ */ o({
5
- __name: "ApiClientModal",
6
- props: {
7
- modalState: {}
8
- },
9
- setup(u) {
10
- return a(() => d()), (t, m) => (r(), l(e(f), {
11
- bodyClass: "h-full",
12
- size: "full",
13
- state: t.modalState
14
- }, {
15
- default: s(() => [
16
- n(e(p), { key: "$route.fullPath" })
17
- ]),
18
- _: 1
19
- }, 8, ["state"]));
20
- }
21
- });
1
+ import o from "./ApiClientModal.vue2.js";
2
+ /* empty css */
3
+ /* empty css */
4
+ import t from "../_virtual/_plugin-vue_export-helper.js";
5
+ const m = /* @__PURE__ */ t(o, [["__scopeId", "data-v-d109beff"]]);
22
6
  export {
23
- C as default
7
+ m as default
24
8
  };
@@ -0,0 +1,32 @@
1
+ import { defineComponent as l, watch as r, onBeforeUnmount as s, withDirectives as c, openBlock as m, createElementBlock as d, createElementVNode as t, createVNode as i, unref as p, vShow as u } from "vue";
2
+ import { RouterView as f } from "vue-router";
3
+ const v = { class: "scalar" }, h = { className: "scalar-container" }, _ = { className: "scalar-app scalar-client" }, S = /* @__PURE__ */ l({
4
+ __name: "ApiClientModal",
5
+ props: {
6
+ modalState: {}
7
+ },
8
+ setup(n) {
9
+ const a = n;
10
+ return r(
11
+ () => a.modalState.open,
12
+ (e) => {
13
+ e ? document.documentElement.style.overflow = "hidden" : document.documentElement.style.removeProperty("overflow");
14
+ }
15
+ ), s(() => document.documentElement.style.removeProperty("overflow")), (e, o) => c((m(), d("div", v, [
16
+ t("div", h, [
17
+ t("div", _, [
18
+ i(p(f), { key: "$route.fullPath" })
19
+ ]),
20
+ t("div", {
21
+ class: "scalar-app-exit",
22
+ onClick: o[0] || (o[0] = (w) => e.modalState.hide())
23
+ })
24
+ ])
25
+ ], 512)), [
26
+ [u, e.modalState.open]
27
+ ]);
28
+ }
29
+ });
30
+ export {
31
+ S as default
32
+ };
@@ -20,6 +20,8 @@ export type OpenClientPayload = {
20
20
  };
21
21
  /** Initialize Scalar API Client Modal */
22
22
  export declare const createScalarApiClient: (el: HTMLElement | null, initialConfig: ClientConfiguration, mountOnInitialize?: boolean) => Promise<{
23
+ /** The vue app instance for the modal, be careful with this */
24
+ app: import("vue").App<Element>;
23
25
  /** Update the API client config */
24
26
  updateConfig(newConfig: ClientConfiguration, mergeConfigs?: boolean): void;
25
27
  /**
@@ -33,7 +35,7 @@ export declare const createScalarApiClient: (el: HTMLElement | null, initialConf
33
35
  */
34
36
  updateAuth: (auth: AuthenticationState) => void;
35
37
  /** Update the spec file, this will re-parse it and clear your store */
36
- updateSpec: (spec: SpecConfiguration) => Promise<void>;
38
+ updateSpec: (spec: SpecConfiguration) => void;
37
39
  /** Open the API client modal */
38
40
  open: (payload?: OpenClientPayload) => void;
39
41
  /** Mount the references to a given element */
@@ -1 +1 @@
1
- {"version":3,"file":"api-client-modal.d.ts","sourceRoot":"","sources":["../../src/Modal/api-client-modal.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAA;AAG/E,OAAO,EAAE,KAAK,aAAa,EAAe,MAAM,2BAA2B,CAAA;AAQ3E,sDAAsD;AACtD,MAAM,MAAM,mBAAmB,GAAG;IAChC,yCAAyC;IACzC,IAAI,EAAE,iBAAiB,CAAA;IACvB,wCAAwC;IACxC,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,iCAAiC;IACjC,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,kCAAkC;IAClC,WAAW,CAAC,EAAE,OAAO,CAAA;IACrB,4DAA4D;IAE5D,mFAAmF;IACnF,YAAY,CAAC,EACT,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,CAAA;CACR,CAAA;AAED,MAAM,MAAM,iBAAiB,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,aAAa,CAAA;CAAE,CAAA;AAEvE,yCAAyC;AACzC,eAAO,MAAM,qBAAqB,OAE5B,WAAW,GAAG,IAAI,iBAEP,mBAAmB;IA+DhC,mCAAmC;4BACX,mBAAmB;IAQ3C;;;OAGG;iCAC0B,MAAM;IAMnC;;;OAGG;uBACgB,mBAAmB;IAyEtC,uEAAuE;uBACpD,iBAAiB;IACpC,iCAAiC;qBAChB,iBAAiB;IAalC,8CAA8C;;;;;;;EAIjD,CAAA"}
1
+ {"version":3,"file":"api-client-modal.d.ts","sourceRoot":"","sources":["../../src/Modal/api-client-modal.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAA;AAG/E,OAAO,EAAE,KAAK,aAAa,EAAe,MAAM,2BAA2B,CAAA;AAQ3E,sDAAsD;AACtD,MAAM,MAAM,mBAAmB,GAAG;IAChC,yCAAyC;IACzC,IAAI,EAAE,iBAAiB,CAAA;IACvB,wCAAwC;IACxC,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,iCAAiC;IACjC,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,kCAAkC;IAClC,WAAW,CAAC,EAAE,OAAO,CAAA;IACrB,4DAA4D;IAE5D,mFAAmF;IACnF,YAAY,CAAC,EACT,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,CAAA;CACR,CAAA;AAED,MAAM,MAAM,iBAAiB,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,aAAa,CAAA;CAAE,CAAA;AAEvE,yCAAyC;AACzC,eAAO,MAAM,qBAAqB,OAE5B,WAAW,GAAG,IAAI,iBAEP,mBAAmB;IA+DhC,+DAA+D;;IAE/D,mCAAmC;4BACX,mBAAmB;IAQ3C;;;OAGG;iCAC0B,MAAM;IAMnC;;;OAGG;uBACgB,mBAAmB;IAyEtC,uEAAuE;uBACpD,iBAAiB;IAapC,iCAAiC;qBAChB,iBAAiB;IAalC,8CAA8C;;;;;;;EAIjD,CAAA"}
@@ -1,32 +1,31 @@
1
1
  import { clientRouter as b } from "../router.js";
2
- import { useWorkspace as R } from "../store/workspace.js";
3
- import { objectMerge as j } from "@scalar/oas-utils/helpers";
4
- import { getNestedValue as P } from "@scalar/object-utils/nested";
5
- import { toRaw as c, createApp as q } from "vue";
6
- import K from "./ApiClientModal.vue.js";
7
- /* empty css */
8
- const N = async (k, A, v = !0) => {
9
- var f, h, S;
10
- const s = c(A), {
11
- activeCollection: d,
12
- collectionMutators: I,
2
+ import { useWorkspace as O } from "../store/workspace.js";
3
+ import { objectMerge as R } from "@scalar/oas-utils/helpers";
4
+ import { getNestedValue as j } from "@scalar/object-utils/nested";
5
+ import { toRaw as i, createApp as C } from "vue";
6
+ import q from "./ApiClientModal.vue.js";
7
+ const N = async (k, v, I = !0) => {
8
+ var h, S, w;
9
+ const o = i(v), {
10
+ activeCollection: u,
11
+ collectionMutators: g,
13
12
  importSpecFile: a,
14
- importSpecFromUrl: g,
15
- modalState: p,
13
+ importSpecFromUrl: m,
14
+ modalState: n,
16
15
  requests: U,
17
16
  securitySchemeMutators: M,
18
- securitySchemes: x,
19
- serverMutators: O,
20
- workspaceMutators: n
21
- } = R();
22
- (f = s.spec) != null && f.url ? g(c(s.spec.url), c(s.proxyUrl)) : (h = s.spec) != null && h.content ? a(c((S = s.spec) == null ? void 0 : S.content)) : console.error(
17
+ securitySchemes: P,
18
+ serverMutators: x,
19
+ workspaceMutators: p
20
+ } = O();
21
+ (h = o.spec) != null && h.url ? m(i(o.spec.url), i(o.proxyUrl)) : (S = o.spec) != null && S.content ? a(i((w = o.spec) == null ? void 0 : w.content)) : console.error(
23
22
  "[@scalar/api-client-modal] Could not create the API client.",
24
23
  "Please provide an OpenAPI document: { spec: { url: '…' } }",
25
24
  "Read more: https://github.com/scalar/scalar/tree/main/packages/api-client-modal"
26
25
  );
27
- const u = q(K, { config: c(s), modalState: p });
28
- u.use(b);
29
- const m = (e = k) => {
26
+ const d = C(q, { config: i(o), modalState: n });
27
+ d.use(b);
28
+ const f = (e = k) => {
30
29
  if (!e) {
31
30
  console.error(
32
31
  "[@scalar/api-client-modal] Could not create the API client.",
@@ -35,21 +34,23 @@ const N = async (k, A, v = !0) => {
35
34
  );
36
35
  return;
37
36
  }
38
- u.mount(e);
37
+ d.mount(e);
39
38
  };
40
- return v && m(), n.edit("isReadOnly", !0), s.proxyUrl && n.edit("proxyUrl", s.proxyUrl), s.themeId && n.edit("themeId", s.themeId), {
39
+ return I && f(), p.edit("isReadOnly", !0), o.proxyUrl && p.edit("proxyUrl", o.proxyUrl), o.themeId && p.edit("themeId", o.themeId), {
40
+ /** The vue app instance for the modal, be careful with this */
41
+ app: d,
41
42
  /** Update the API client config */
42
- updateConfig(e, r = !0) {
43
- r ? Object.assign(s, e) : j(s, e), e.spec && a(e.spec);
43
+ updateConfig(e, s = !0) {
44
+ s ? Object.assign(o, e) : R(o, e), e.spec && a(e.spec);
44
45
  },
45
46
  /**
46
47
  * TODO this is just temporary for the modal, we'll put in a proper solution later
47
48
  * Here we update the currently selected serverUrl
48
49
  */
49
50
  updateServerUrl: (e) => {
50
- var r;
51
- return O.edit(
52
- ((r = d.value) == null ? void 0 : r.selectedServerUid) ?? "",
51
+ var s;
52
+ return x.edit(
53
+ ((s = u.value) == null ? void 0 : s.selectedServerUid) ?? "",
53
54
  "url",
54
55
  e
55
56
  );
@@ -59,49 +60,55 @@ const N = async (k, A, v = !0) => {
59
60
  * maps the references useAuthenticationStore to the client auth
60
61
  */
61
62
  updateAuth: (e) => {
62
- var i, l;
63
- if (Object.values(x).forEach((o) => {
64
- const t = (w, y = "value") => w.length && !P(o, y).length && M.edit(o.uid, y, w);
65
- switch (o.type) {
63
+ var c, l;
64
+ if (Object.values(P).forEach((r) => {
65
+ const t = (y, A = "value") => y.length && !j(r, A).length && M.edit(r.uid, A, y);
66
+ switch (r.type) {
66
67
  case "apiKey":
67
68
  t(e.apiKey.token);
68
69
  break;
69
70
  case "http":
70
- o.scheme === "bearer" ? t(e.http.bearer.token) : o.scheme === "basic" && (t(e.http.basic.username), t(e.http.basic.password, "secondValue"));
71
+ r.scheme === "bearer" ? t(e.http.bearer.token) : r.scheme === "basic" && (t(e.http.basic.username), t(e.http.basic.password, "secondValue"));
71
72
  break;
72
73
  case "oauth2":
73
- t(e.oAuth2.clientId, "clientId"), o.flows.implicit ? (t(e.oAuth2.accessToken, "flows.implicit.token"), t(e.oAuth2.scopes, "flows.implicit.selectedScopes")) : o.flows.password && (t(e.oAuth2.accessToken, "flows.password.token"), t(e.oAuth2.scopes, "flows.password.selectedScopes"), t(e.oAuth2.username, "flows.password.value"), t(e.oAuth2.password, "flows.password.secondValue"));
74
+ t(e.oAuth2.clientId, "clientId"), r.flows.implicit ? (t(e.oAuth2.accessToken, "flows.implicit.token"), t(e.oAuth2.scopes, "flows.implicit.selectedScopes")) : r.flows.password && (t(e.oAuth2.accessToken, "flows.password.token"), t(e.oAuth2.scopes, "flows.password.selectedScopes"), t(e.oAuth2.username, "flows.password.value"), t(e.oAuth2.password, "flows.password.secondValue"));
74
75
  break;
75
76
  }
76
77
  }), e.preferredSecurityScheme) {
77
- const o = {
78
+ const r = {
78
79
  uid: e.preferredSecurityScheme
79
- }, t = (i = e.securitySchemes) == null ? void 0 : i[e.preferredSecurityScheme ?? ""];
80
- (t == null ? void 0 : t.type) === "oauth2" && (o.flowKey = (l = t.flows) != null && l.implicit ? "implicit" : "password"), I.edit(
81
- d.value.uid,
80
+ }, t = (c = e.securitySchemes) == null ? void 0 : c[e.preferredSecurityScheme ?? ""];
81
+ (t == null ? void 0 : t.type) === "oauth2" && (r.flowKey = (l = t.flows) != null && l.implicit ? "implicit" : "password"), g.edit(
82
+ u.value.uid,
82
83
  "selectedSecuritySchemes",
83
- [o]
84
+ [r]
84
85
  );
85
86
  }
86
87
  },
87
88
  /** Update the spec file, this will re-parse it and clear your store */
88
- updateSpec: (e) => a(e),
89
+ updateSpec: (e) => {
90
+ e != null && e.url ? m(i(e.url), i(o.proxyUrl)) : e != null && e.content ? a(i(e == null ? void 0 : e.content)) : console.error(
91
+ "[@scalar/api-client-modal] Could not create the API client.",
92
+ "Please provide an OpenAPI document: { spec: { url: '…' } }",
93
+ "Read more: https://github.com/scalar/scalar/tree/main/packages/api-client-modal"
94
+ );
95
+ },
89
96
  /** Open the API client modal */
90
97
  open: (e) => {
91
- const r = Object.values(U).find(
92
- ({ path: i, method: l }) => e ? (
98
+ const s = Object.values(U).find(
99
+ ({ path: c, method: l }) => e ? (
93
100
  // The given operation
94
- i === e.path && l === e.method
101
+ c === e.path && l === e.method
95
102
  ) : (
96
103
  // Or the first request
97
104
  !0
98
105
  )
99
106
  );
100
- r && b.push(`/request/${r.uid}`), p.open = !0;
107
+ s && b.push(`/request/${s.uid}`), n.open = !0;
101
108
  },
102
109
  /** Mount the references to a given element */
103
- mount: m,
104
- modalState: p
110
+ mount: f,
111
+ modalState: n
105
112
  };
106
113
  };
107
114
  export {
@@ -1,6 +1,6 @@
1
- import { createScalarApiClient as r } from "./api-client-modal.js";
2
- import { default as l } from "./ApiClientModal.vue.js";
1
+ import { default as r } from "./ApiClientModal.vue.js";
2
+ import { createScalarApiClient as l } from "./api-client-modal.js";
3
3
  export {
4
- l as ApiClientModal,
5
- r as createScalarApiClient
4
+ r as ApiClientModal,
5
+ l as createScalarApiClient
6
6
  };
package/dist/index.js CHANGED
@@ -1,15 +1,14 @@
1
- import { default as a } from "./App.vue.js";
1
+ import { default as o } from "./App.vue.js";
2
2
  /* empty css */
3
- import { useWorkspace as p } from "./store/workspace.js";
4
- import { clientRouter as f, clientRoutes as m } from "./router.js";
5
- import { default as n } from "./Modal/ApiClientModal.vue.js";
6
- /* empty css */
7
- import { createScalarApiClient as u } from "./Modal/api-client-modal.js";
3
+ import { useWorkspace as l } from "./store/workspace.js";
4
+ import { clientRouter as i, clientRoutes as f } from "./router.js";
5
+ import { default as m } from "./Modal/ApiClientModal.vue.js";
6
+ import { createScalarApiClient as s } from "./Modal/api-client-modal.js";
8
7
  export {
9
- n as ApiClientModal,
10
- a as ScalarClient,
11
- f as clientRouter,
12
- m as clientRoutes,
13
- u as createScalarApiClient,
14
- p as useWorkspace
8
+ m as ApiClientModal,
9
+ o as ScalarClient,
10
+ i as clientRouter,
11
+ f as clientRoutes,
12
+ s as createScalarApiClient,
13
+ l as useWorkspace
15
14
  };