@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.
- package/CHANGELOG.md +8 -0
- package/dist/App.vue.d.ts.map +1 -1
- package/dist/App.vue.js +25 -736
- package/dist/Modal/ApiClientModal.vue.d.ts +1 -1
- package/dist/Modal/ApiClientModal.vue.d.ts.map +1 -1
- package/dist/Modal/ApiClientModal.vue.js +6 -22
- package/dist/Modal/ApiClientModal.vue2.js +32 -0
- package/dist/Modal/api-client-modal.d.ts +3 -1
- package/dist/Modal/api-client-modal.d.ts.map +1 -1
- package/dist/Modal/api-client-modal.js +53 -46
- package/dist/Modal/index.js +4 -4
- package/dist/index.js +11 -12
- package/dist/style.css +1 -1
- package/package.json +4 -4
- package/dist/Modal/ApiClientModal.vue3.js +0 -5
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
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":"
|
|
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
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
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
|
-
|
|
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) =>
|
|
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;
|
|
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
|
|
3
|
-
import { objectMerge as
|
|
4
|
-
import { getNestedValue as
|
|
5
|
-
import { toRaw as
|
|
6
|
-
import
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
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:
|
|
15
|
-
modalState:
|
|
13
|
+
importSpecFromUrl: m,
|
|
14
|
+
modalState: n,
|
|
16
15
|
requests: U,
|
|
17
16
|
securitySchemeMutators: M,
|
|
18
|
-
securitySchemes:
|
|
19
|
-
serverMutators:
|
|
20
|
-
workspaceMutators:
|
|
21
|
-
} =
|
|
22
|
-
(
|
|
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
|
|
28
|
-
|
|
29
|
-
const
|
|
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
|
-
|
|
37
|
+
d.mount(e);
|
|
39
38
|
};
|
|
40
|
-
return
|
|
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,
|
|
43
|
-
|
|
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
|
|
51
|
-
return
|
|
52
|
-
((
|
|
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
|
|
63
|
-
if (Object.values(
|
|
64
|
-
const t = (
|
|
65
|
-
switch (
|
|
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
|
-
|
|
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"),
|
|
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
|
|
78
|
+
const r = {
|
|
78
79
|
uid: e.preferredSecurityScheme
|
|
79
|
-
}, t = (
|
|
80
|
-
(t == null ? void 0 : t.type) === "oauth2" && (
|
|
81
|
-
|
|
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
|
-
[
|
|
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) =>
|
|
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
|
|
92
|
-
({ path:
|
|
98
|
+
const s = Object.values(U).find(
|
|
99
|
+
({ path: c, method: l }) => e ? (
|
|
93
100
|
// The given operation
|
|
94
|
-
|
|
101
|
+
c === e.path && l === e.method
|
|
95
102
|
) : (
|
|
96
103
|
// Or the first request
|
|
97
104
|
!0
|
|
98
105
|
)
|
|
99
106
|
);
|
|
100
|
-
|
|
107
|
+
s && b.push(`/request/${s.uid}`), n.open = !0;
|
|
101
108
|
},
|
|
102
109
|
/** Mount the references to a given element */
|
|
103
|
-
mount:
|
|
104
|
-
modalState:
|
|
110
|
+
mount: f,
|
|
111
|
+
modalState: n
|
|
105
112
|
};
|
|
106
113
|
};
|
|
107
114
|
export {
|
package/dist/Modal/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { default as r } from "./ApiClientModal.vue.js";
|
|
2
|
+
import { createScalarApiClient as l } from "./api-client-modal.js";
|
|
3
3
|
export {
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
r as ApiClientModal,
|
|
5
|
+
l as createScalarApiClient
|
|
6
6
|
};
|
package/dist/index.js
CHANGED
|
@@ -1,15 +1,14 @@
|
|
|
1
|
-
import { default as
|
|
1
|
+
import { default as o } from "./App.vue.js";
|
|
2
2
|
/* empty css */
|
|
3
|
-
import { useWorkspace as
|
|
4
|
-
import { clientRouter as
|
|
5
|
-
import { default as
|
|
6
|
-
|
|
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
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
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
|
};
|