@scalar/api-client 2.0.31 → 2.0.33
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 +20 -0
- package/dist/hooks/useDarkModeState.d.ts.map +1 -1
- package/dist/hooks/useDarkModeState.js +5 -5
- package/dist/layouts/App/create-api-client-app.d.ts +1 -1
- package/dist/layouts/App/create-api-client-app.d.ts.map +1 -1
- package/dist/layouts/App/create-api-client-app.js +1 -1
- package/dist/layouts/Modal/ApiClientModal.vue.js +1 -1
- package/dist/layouts/Modal/ApiClientModal.vue2.js +9 -9
- package/dist/layouts/Modal/api-client-modal.d.ts +2 -2
- package/dist/layouts/Modal/api-client-modal.d.ts.map +1 -1
- package/dist/layouts/Modal/api-client-modal.js +2 -2
- package/dist/libs/create-client.d.ts +4 -3
- package/dist/libs/create-client.d.ts.map +1 -1
- package/dist/libs/create-client.js +68 -68
- package/dist/style.css +1 -1
- package/dist/views/Request/Request.vue.js +2 -2
- package/dist/views/Request/Request.vue2.js +85 -85
- package/dist/views/Request/RequestSection/RequestSection.vue.d.ts.map +1 -1
- package/dist/views/Request/RequestSection/RequestSection.vue.js +37 -37
- package/package.json +5 -5
|
@@ -1,41 +1,41 @@
|
|
|
1
|
-
import { createWorkspaceStore as
|
|
2
|
-
import { createWorkspace as
|
|
3
|
-
import { objectMerge as
|
|
4
|
-
import { getNestedValue as
|
|
5
|
-
import { createApp as
|
|
6
|
-
const
|
|
7
|
-
el:
|
|
8
|
-
appComponent:
|
|
9
|
-
configuration:
|
|
10
|
-
isReadOnly:
|
|
11
|
-
persistData:
|
|
12
|
-
mountOnInitialize:
|
|
13
|
-
router:
|
|
1
|
+
import { createWorkspaceStore as O } from "../store/workspace.js";
|
|
2
|
+
import { createWorkspace as P } from "@scalar/oas-utils/entities/workspace";
|
|
3
|
+
import { objectMerge as W } from "@scalar/oas-utils/helpers";
|
|
4
|
+
import { getNestedValue as K } from "@scalar/object-utils/nested";
|
|
5
|
+
import { createApp as T } from "vue";
|
|
6
|
+
const L = ({
|
|
7
|
+
el: b,
|
|
8
|
+
appComponent: A,
|
|
9
|
+
configuration: t = {},
|
|
10
|
+
isReadOnly: U = !1,
|
|
11
|
+
persistData: f = !0,
|
|
12
|
+
mountOnInitialize: I = !0,
|
|
13
|
+
router: d
|
|
14
14
|
}) => {
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
|
|
15
|
+
const c = O(d, f);
|
|
16
|
+
c.workspaceMutators.rawAdd(
|
|
17
|
+
P({
|
|
18
18
|
uid: "default",
|
|
19
19
|
name: "Workspace",
|
|
20
|
-
isReadOnly:
|
|
21
|
-
proxyUrl:
|
|
20
|
+
isReadOnly: U,
|
|
21
|
+
proxyUrl: t == null ? void 0 : t.proxyUrl
|
|
22
22
|
})
|
|
23
23
|
);
|
|
24
|
-
const
|
|
25
|
-
|
|
24
|
+
const o = T(A);
|
|
25
|
+
o.use(d), o.provide("workspace", c);
|
|
26
26
|
const {
|
|
27
|
-
activeCollection:
|
|
28
|
-
activeWorkspace:
|
|
29
|
-
collectionMutators:
|
|
30
|
-
importSpecFile:
|
|
31
|
-
importSpecFromUrl:
|
|
32
|
-
modalState:
|
|
33
|
-
requests:
|
|
34
|
-
securitySchemeMutators:
|
|
35
|
-
securitySchemes:
|
|
36
|
-
serverMutators:
|
|
37
|
-
workspaceMutators:
|
|
38
|
-
} =
|
|
27
|
+
activeCollection: i,
|
|
28
|
+
activeWorkspace: m,
|
|
29
|
+
collectionMutators: x,
|
|
30
|
+
importSpecFile: u,
|
|
31
|
+
importSpecFromUrl: M,
|
|
32
|
+
modalState: w,
|
|
33
|
+
requests: h,
|
|
34
|
+
securitySchemeMutators: C,
|
|
35
|
+
securitySchemes: j,
|
|
36
|
+
serverMutators: q,
|
|
37
|
+
workspaceMutators: k
|
|
38
|
+
} = c, S = (e = b) => {
|
|
39
39
|
if (!e) {
|
|
40
40
|
console.error(
|
|
41
41
|
"[@scalar/api-client-modal] Could not create the API client.",
|
|
@@ -44,22 +44,22 @@ const H = ({
|
|
|
44
44
|
);
|
|
45
45
|
return;
|
|
46
46
|
}
|
|
47
|
-
|
|
47
|
+
o.mount(e);
|
|
48
48
|
};
|
|
49
|
-
return
|
|
50
|
-
|
|
49
|
+
return m.value && (I && S(), t != null && t.proxyUrl && k.edit(
|
|
50
|
+
m.value.uid,
|
|
51
51
|
"proxyUrl",
|
|
52
|
-
|
|
53
|
-
),
|
|
54
|
-
|
|
52
|
+
t == null ? void 0 : t.proxyUrl
|
|
53
|
+
), t != null && t.themeId && k.edit(
|
|
54
|
+
m.value.uid,
|
|
55
55
|
"themeId",
|
|
56
|
-
|
|
56
|
+
t == null ? void 0 : t.themeId
|
|
57
57
|
)), {
|
|
58
58
|
/** The vue app instance for the modal, be careful with this */
|
|
59
|
-
app:
|
|
59
|
+
app: o,
|
|
60
60
|
/** Update the API client config */
|
|
61
61
|
updateConfig(e, r = !0) {
|
|
62
|
-
r ? Object.assign(
|
|
62
|
+
r ? Object.assign(t ?? {}, e) : W(t ?? {}, e), e.spec && u(e.spec);
|
|
63
63
|
},
|
|
64
64
|
/**
|
|
65
65
|
* TODO this is just temporary for the modal, we'll put in a proper solution later
|
|
@@ -67,8 +67,8 @@ const H = ({
|
|
|
67
67
|
*/
|
|
68
68
|
updateServerUrl: (e) => {
|
|
69
69
|
var r;
|
|
70
|
-
return
|
|
71
|
-
((r =
|
|
70
|
+
return q.edit(
|
|
71
|
+
((r = i.value) == null ? void 0 : r.selectedServerUid) ?? "",
|
|
72
72
|
"url",
|
|
73
73
|
e
|
|
74
74
|
);
|
|
@@ -78,34 +78,34 @@ const H = ({
|
|
|
78
78
|
* maps the references useAuthenticationStore to the client auth
|
|
79
79
|
*/
|
|
80
80
|
updateAuth: (e) => {
|
|
81
|
-
var
|
|
82
|
-
if (Object.values(
|
|
83
|
-
const
|
|
84
|
-
switch (
|
|
81
|
+
var p, a;
|
|
82
|
+
if (Object.values(j).forEach((l) => {
|
|
83
|
+
const s = (v, y = "value") => v.length && !K(l, y).length && C.edit(l.uid, y, v);
|
|
84
|
+
switch (l.type) {
|
|
85
85
|
case "apiKey":
|
|
86
|
-
|
|
86
|
+
s(e.apiKey.token);
|
|
87
87
|
break;
|
|
88
88
|
case "http":
|
|
89
|
-
|
|
89
|
+
l.scheme === "bearer" ? s(e.http.bearer.token) : l.scheme === "basic" && (s(e.http.basic.username), s(e.http.basic.password, "secondValue"));
|
|
90
90
|
break;
|
|
91
91
|
case "oauth2":
|
|
92
|
-
|
|
92
|
+
s(e.oAuth2.clientId, "clientId"), l.flows.implicit ? (s(e.oAuth2.accessToken, "flows.implicit.token"), s(e.oAuth2.scopes, "flows.implicit.selectedScopes")) : l.flows.password && (s(e.oAuth2.accessToken, "flows.password.token"), s(e.oAuth2.scopes, "flows.password.selectedScopes"), s(e.oAuth2.username, "flows.password.value"), s(e.oAuth2.password, "flows.password.secondValue"));
|
|
93
93
|
break;
|
|
94
94
|
}
|
|
95
95
|
}), e.preferredSecurityScheme) {
|
|
96
|
-
const
|
|
96
|
+
const l = {
|
|
97
97
|
uid: e.preferredSecurityScheme
|
|
98
|
-
},
|
|
99
|
-
(
|
|
100
|
-
|
|
98
|
+
}, s = (p = e.securitySchemes) == null ? void 0 : p[e.preferredSecurityScheme ?? ""];
|
|
99
|
+
(s == null ? void 0 : s.type) === "oauth2" && (l.flowKey = (a = s.flows) != null && a.implicit ? "implicit" : "password"), x.edit(
|
|
100
|
+
i.value.uid,
|
|
101
101
|
"selectedSecuritySchemes",
|
|
102
|
-
[
|
|
102
|
+
[l]
|
|
103
103
|
);
|
|
104
104
|
}
|
|
105
105
|
},
|
|
106
106
|
/** Update the spec file, this will re-parse it and clear your store */
|
|
107
107
|
updateSpec: async (e) => {
|
|
108
|
-
e != null && e.url ? await
|
|
108
|
+
e != null && e.url ? await M(e.url, t == null ? void 0 : t.proxyUrl) : e != null && e.content ? await u(e == null ? void 0 : e.content) : console.error(
|
|
109
109
|
"[@scalar/api-client-modal] Could not create the API client.",
|
|
110
110
|
"Please provide an OpenAPI document: { spec: { url: '…' } }",
|
|
111
111
|
"Read more: https://github.com/scalar/scalar/tree/main/packages/api-client"
|
|
@@ -113,35 +113,35 @@ const H = ({
|
|
|
113
113
|
},
|
|
114
114
|
/** Route to a method + path */
|
|
115
115
|
route: (e) => {
|
|
116
|
-
const r = Object.values(
|
|
117
|
-
({ path:
|
|
116
|
+
const r = Object.values(h).find(
|
|
117
|
+
({ path: p, method: a }) => p === e.path && a.toUpperCase() === e.method.toUpperCase()
|
|
118
118
|
);
|
|
119
|
-
r &&
|
|
119
|
+
r && d.push(`/workspace/default/request/${r.uid}`);
|
|
120
120
|
},
|
|
121
121
|
/** Open the API client modal and optionally route to a request */
|
|
122
122
|
open: (e) => {
|
|
123
123
|
if (e) {
|
|
124
|
-
const r = Object.values(
|
|
125
|
-
({ path:
|
|
124
|
+
const r = Object.values(h).find(
|
|
125
|
+
({ path: p, method: a }) => e ? (
|
|
126
126
|
// The given operation
|
|
127
|
-
|
|
127
|
+
p === e.path && a.toUpperCase() === e.method.toUpperCase()
|
|
128
128
|
) : (
|
|
129
129
|
// Or the first request
|
|
130
130
|
!0
|
|
131
131
|
)
|
|
132
132
|
);
|
|
133
|
-
r &&
|
|
133
|
+
r && d.push(`/workspace/default/request/${r.uid}`);
|
|
134
134
|
}
|
|
135
|
-
|
|
135
|
+
w.open = !0;
|
|
136
136
|
},
|
|
137
137
|
/** Mount the references to a given element */
|
|
138
|
-
mount:
|
|
138
|
+
mount: S,
|
|
139
139
|
/** State for controlling the modal */
|
|
140
|
-
modalState:
|
|
140
|
+
modalState: w,
|
|
141
141
|
/* The workspace store */
|
|
142
|
-
store:
|
|
142
|
+
store: c
|
|
143
143
|
};
|
|
144
144
|
};
|
|
145
145
|
export {
|
|
146
|
-
|
|
146
|
+
L as createApiClient
|
|
147
147
|
};
|