@scalar/api-client 2.0.5 → 2.0.6
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/Modal/ApiClientModal.vue.d.ts +1 -1
- package/dist/Modal/ApiClientModal.vue.d.ts.map +1 -1
- package/dist/Modal/ApiClientModal.vue.js +1 -1
- package/dist/Modal/ApiClientModal.vue2.js +16 -15
- package/dist/Modal/api-client-modal.d.ts +1 -1
- package/dist/Modal/api-client-modal.d.ts.map +1 -1
- package/dist/Modal/api-client-modal.js +43 -43
- package/dist/components/DarkModeToggle/DarkModeIconToggle.vue.js +1 -1
- package/dist/components/DataTable/DataTableInput.vue.d.ts +2 -0
- package/dist/components/DataTable/DataTableInput.vue.d.ts.map +1 -1
- package/dist/components/DataTable/DataTableInput.vue.js +2 -2
- package/dist/components/DataTable/DataTableInput.vue2.js +43 -36
- package/dist/components/DataTable/DataTableInputEnumSelect.vue.d.ts +22 -0
- package/dist/components/DataTable/DataTableInputEnumSelect.vue.d.ts.map +1 -0
- package/dist/components/DataTable/DataTableInputEnumSelect.vue.js +102 -0
- package/dist/components/DataTable/DataTableInputEnumSelect.vue2.js +4 -0
- package/dist/components/SideNav/SideNavLink.vue.js +2 -2
- package/dist/constants.js +1 -1
- package/dist/store/workspace.d.ts +75 -12
- package/dist/store/workspace.d.ts.map +1 -1
- package/dist/store/workspace.js +113 -109
- package/dist/style.css +1 -1
- package/dist/views/Cookies/Cookies.vue.d.ts.map +1 -1
- package/dist/views/Cookies/Cookies.vue2.js +13 -11
- package/dist/views/Request/RequestSection/RequestSection.vue.d.ts.map +1 -1
- package/dist/views/Request/RequestSection/RequestSection.vue.js +10 -10
- package/dist/views/Request/RequestSection/RequestTable.vue.d.ts.map +1 -1
- package/dist/views/Request/RequestSection/RequestTable.vue.js +2 -2
- package/dist/views/Request/RequestSection/RequestTable.vue2.js +24 -23
- package/dist/views/Request/ResponseSection/ResponseSection.vue.d.ts.map +1 -1
- package/dist/views/Request/ResponseSection/ResponseSection.vue.js +6 -6
- package/package.json +8 -8
package/dist/store/workspace.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { activeRouterParams as
|
|
1
|
+
import { activeRouterParams as E, PathId as b, fallbackMissingParams as V } from "../router.js";
|
|
2
2
|
import { useModal as N } from "@scalar/components";
|
|
3
3
|
import { createWorkspace as G } from "@scalar/oas-utils/entities/workspace";
|
|
4
4
|
import { createCollection as H } from "@scalar/oas-utils/entities/workspace/collection";
|
|
@@ -12,54 +12,58 @@ import { getRequestBodyFromOperation as $ } from "@scalar/oas-utils/spec-getters
|
|
|
12
12
|
import { importSpecToWorkspace as ee } from "@scalar/oas-utils/transforms";
|
|
13
13
|
import { mutationFactory as n } from "@scalar/object-utils/mutator-record";
|
|
14
14
|
import { setNestedValue as te } from "@scalar/object-utils/nested";
|
|
15
|
-
import { reactive as
|
|
16
|
-
import { useSidebar as
|
|
17
|
-
const { setCollapsedSidebarFolder:
|
|
18
|
-
const s = Q(e),
|
|
19
|
-
return s.childUids.push(
|
|
20
|
-
...i[t].childUids,
|
|
21
|
-
s.uid
|
|
22
|
-
]) : r[t] && m.edit(t, "childUids", [
|
|
15
|
+
import { reactive as o, computed as d, readonly as se, toRaw as oe } from "vue";
|
|
16
|
+
import { useSidebar as ce } from "../hooks/useSidebar.js";
|
|
17
|
+
const { setCollapsedSidebarFolder: ie } = ce(), u = o({}), S = n(u, o({})), U = (e, t) => {
|
|
18
|
+
const s = Q(e), i = R(s);
|
|
19
|
+
return s.childUids.push(i.uid), S.add(s), t && (r[t] ? a.edit(t, "childUids", [
|
|
23
20
|
...r[t].childUids,
|
|
24
21
|
s.uid
|
|
22
|
+
]) : l[t] && m.edit(t, "childUids", [
|
|
23
|
+
...l[t].childUids,
|
|
24
|
+
s.uid
|
|
25
25
|
])), s;
|
|
26
|
-
},
|
|
27
|
-
e.childUids.forEach((s) =>
|
|
26
|
+
}, re = (e, t) => {
|
|
27
|
+
e.childUids.forEach((s) => k.delete(s)), r[t] ? a.edit(
|
|
28
28
|
t,
|
|
29
29
|
"childUids",
|
|
30
|
-
|
|
31
|
-
) :
|
|
30
|
+
r[t].childUids.filter((s) => s !== e.uid)
|
|
31
|
+
) : l[t] && m.edit(
|
|
32
32
|
t,
|
|
33
33
|
"childUids",
|
|
34
|
-
|
|
34
|
+
l[t].childUids.filter((s) => s !== e.uid)
|
|
35
35
|
), S.delete(e.uid);
|
|
36
36
|
}, h = d(() => {
|
|
37
|
-
var
|
|
38
|
-
const e =
|
|
39
|
-
return V(
|
|
40
|
-
(
|
|
37
|
+
var i;
|
|
38
|
+
const e = E.value[b.Request], t = (i = D.value[0]) == null ? void 0 : i.uid, s = u[e] ?? u[t];
|
|
39
|
+
return V(b.Request, s), s && M(s.uid).forEach(
|
|
40
|
+
(c) => ie(c, !0)
|
|
41
41
|
), s;
|
|
42
|
-
}),
|
|
43
|
-
const s = Object.values(
|
|
44
|
-
(
|
|
42
|
+
}), M = (e, t = []) => {
|
|
43
|
+
const s = Object.values(r).find(
|
|
44
|
+
(c) => c.childUids.includes(e)
|
|
45
45
|
);
|
|
46
46
|
if (s) return [...t, s.uid];
|
|
47
|
-
const
|
|
48
|
-
({ childUids:
|
|
47
|
+
const i = Object.values(l).find(
|
|
48
|
+
({ childUids: c }) => c.includes(e)
|
|
49
49
|
);
|
|
50
|
-
return
|
|
51
|
-
}, p =
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
50
|
+
return i ? M(i.uid, [...t, i.uid]) : t;
|
|
51
|
+
}, p = o({}), k = n(p, o({})), x = (e) => {
|
|
52
|
+
var t;
|
|
53
|
+
return Y({
|
|
54
|
+
key: e.name,
|
|
55
|
+
value: e.schema && "default" in e.schema ? e.schema.default : e.schema && "examples" in e.schema && e.schema.examples.length > 0 ? e.schema.examples[0] : "",
|
|
56
|
+
description: e.description,
|
|
57
|
+
required: e.required,
|
|
58
|
+
enum: (t = e.schema) == null ? void 0 : t.enum
|
|
59
|
+
});
|
|
60
|
+
}, R = (e) => {
|
|
61
|
+
var w;
|
|
58
62
|
const t = {
|
|
59
|
-
path: Object.values(e.parameters.path).map(
|
|
60
|
-
query: Object.values(e.parameters.query).map(
|
|
61
|
-
headers: Object.values(e.parameters.headers).map(
|
|
62
|
-
cookies: Object.values(e.parameters.cookies).map(
|
|
63
|
+
path: Object.values(e.parameters.path).map(x),
|
|
64
|
+
query: Object.values(e.parameters.query).map(x),
|
|
65
|
+
headers: Object.values(e.parameters.headers).map(x),
|
|
66
|
+
cookies: Object.values(e.parameters.cookies).map(x)
|
|
63
67
|
}, s = {
|
|
64
68
|
activeBody: "raw",
|
|
65
69
|
raw: {
|
|
@@ -75,42 +79,42 @@ const { setCollapsedSidebarFolder: ce } = oe(), u = c({}), S = n(u, c({})), U =
|
|
|
75
79
|
requestBody: e.requestBody
|
|
76
80
|
}
|
|
77
81
|
});
|
|
78
|
-
((
|
|
82
|
+
((w = f == null ? void 0 : f.postData) == null ? void 0 : w.mimeType) === "application/json" && (t.headers.push({
|
|
79
83
|
key: "Content-Type",
|
|
80
84
|
value: "application/json",
|
|
81
85
|
enabled: !0
|
|
82
86
|
}), s.activeBody = "raw", s.raw.value = f.postData.text);
|
|
83
87
|
}
|
|
84
|
-
const
|
|
88
|
+
const i = Z(
|
|
85
89
|
(e.summary ?? "Example") + " #1",
|
|
86
90
|
(f) => e.childUids.some((T) => f === p[T].name)
|
|
87
|
-
),
|
|
91
|
+
), c = X({
|
|
88
92
|
requestUid: e.uid,
|
|
89
93
|
parameters: t,
|
|
90
|
-
name:
|
|
94
|
+
name: i,
|
|
91
95
|
body: s
|
|
92
96
|
});
|
|
93
|
-
return
|
|
94
|
-
},
|
|
95
|
-
const t =
|
|
97
|
+
return k.add(c), c;
|
|
98
|
+
}, le = (e) => {
|
|
99
|
+
const t = R(e);
|
|
96
100
|
S.edit(e.uid, "childUids", [
|
|
97
101
|
...e.childUids,
|
|
98
102
|
t.uid
|
|
99
103
|
]);
|
|
100
|
-
},
|
|
104
|
+
}, de = (e) => {
|
|
101
105
|
S.edit(
|
|
102
106
|
e.requestUid,
|
|
103
107
|
"childUids",
|
|
104
108
|
u[e.requestUid].childUids.filter(
|
|
105
109
|
(t) => t !== e.uid
|
|
106
110
|
)
|
|
107
|
-
),
|
|
108
|
-
},
|
|
111
|
+
), k.delete(e.uid);
|
|
112
|
+
}, ae = d(
|
|
109
113
|
() => {
|
|
110
114
|
var e;
|
|
111
|
-
return p[
|
|
115
|
+
return p[E.value[b.Example]] ?? p[((e = h.value) == null ? void 0 : e.childUids[0]) ?? ""];
|
|
112
116
|
}
|
|
113
|
-
),
|
|
117
|
+
), ne = d(() => Object.values(u).flatMap((e) => e.history).filter((e) => e.request && e.response).sort((e, t) => t.timestamp - e.timestamp)), O = o({
|
|
114
118
|
default: J({
|
|
115
119
|
uid: "default",
|
|
116
120
|
name: "Global Environment",
|
|
@@ -119,46 +123,46 @@ const { setCollapsedSidebarFolder: ce } = oe(), u = c({}), S = n(u, c({})), U =
|
|
|
119
123
|
parsed: [],
|
|
120
124
|
isDefault: !0
|
|
121
125
|
})
|
|
122
|
-
}), C = n(O,
|
|
126
|
+
}), C = n(O, o({})), ue = (e) => {
|
|
123
127
|
if (e === "default") {
|
|
124
128
|
console.warn("Default environment cannot be deleted.");
|
|
125
129
|
return;
|
|
126
130
|
}
|
|
127
131
|
C.delete(e);
|
|
128
|
-
}, g =
|
|
129
|
-
() =>
|
|
130
|
-
), v =
|
|
132
|
+
}, g = o({}), me = n(g, o({})), fe = d(
|
|
133
|
+
() => E.value[b.Cookies]
|
|
134
|
+
), v = o(G({})), D = d(
|
|
131
135
|
() => Object.values(u).map((e) => ({
|
|
132
136
|
uid: e.uid,
|
|
133
137
|
path: e.path,
|
|
134
138
|
method: e.method,
|
|
135
139
|
summary: e.summary
|
|
136
140
|
}))
|
|
137
|
-
),
|
|
141
|
+
), he = (e, t) => te(v, e, t), r = o({}), a = n(r, o({})), B = (e) => {
|
|
138
142
|
const t = H(e);
|
|
139
143
|
v.collectionUids.push(t.uid), a.add(t);
|
|
140
|
-
},
|
|
144
|
+
}, pe = (e) => {
|
|
141
145
|
const t = v.collectionUids.findIndex((s) => s === e);
|
|
142
146
|
t >= 0 ? (v.collectionUids.splice(t, 1), a.delete(e)) : console.error("Tried to remove a collection that does not exist");
|
|
143
147
|
}, y = d(() => {
|
|
144
148
|
if (!h.value) return null;
|
|
145
|
-
const e =
|
|
149
|
+
const e = M(h.value.uid);
|
|
146
150
|
if (!e.length) return null;
|
|
147
151
|
const t = e[e.length - 1];
|
|
148
|
-
return
|
|
149
|
-
}),
|
|
150
|
-
() => y.value &&
|
|
151
|
-
),
|
|
152
|
+
return r[t];
|
|
153
|
+
}), ve = d(
|
|
154
|
+
() => y.value && j[y.value.selectedServerUid]
|
|
155
|
+
), l = o({}), m = n(l, o({})), I = (e, t) => {
|
|
152
156
|
const s = L(e);
|
|
153
157
|
if (t)
|
|
154
|
-
if (
|
|
158
|
+
if (r[t])
|
|
155
159
|
a.edit(t, "childUids", [
|
|
156
|
-
...
|
|
160
|
+
...r[t].childUids,
|
|
157
161
|
s.uid
|
|
158
162
|
]);
|
|
159
|
-
else if (
|
|
163
|
+
else if (l[t])
|
|
160
164
|
m.edit(t, "childUids", [
|
|
161
|
-
...
|
|
165
|
+
...l[t].childUids,
|
|
162
166
|
s.uid
|
|
163
167
|
]);
|
|
164
168
|
else {
|
|
@@ -166,56 +170,56 @@ const { setCollapsedSidebarFolder: ce } = oe(), u = c({}), S = n(u, c({})), U =
|
|
|
166
170
|
return;
|
|
167
171
|
}
|
|
168
172
|
m.add(s);
|
|
169
|
-
},
|
|
170
|
-
|
|
173
|
+
}, ye = (e, t) => {
|
|
174
|
+
r[t] ? a.edit(
|
|
171
175
|
t,
|
|
172
176
|
"childUids",
|
|
173
|
-
|
|
174
|
-
) :
|
|
177
|
+
r[t].childUids.filter((s) => s !== e)
|
|
178
|
+
) : l[t] && m.edit(
|
|
175
179
|
t,
|
|
176
180
|
"childUids",
|
|
177
|
-
|
|
181
|
+
l[t].childUids.filter((s) => s !== e)
|
|
178
182
|
), m.delete(e);
|
|
179
|
-
}, q =
|
|
183
|
+
}, q = o({}), P = n(q, o({})), Se = d(
|
|
180
184
|
() => {
|
|
181
185
|
var e;
|
|
182
186
|
return (e = y.value) == null ? void 0 : e.selectedSecuritySchemes.map((t) => {
|
|
183
|
-
const s = q[t.uid],
|
|
184
|
-
return { scheme: s, ...
|
|
187
|
+
const s = q[t.uid], i = t.flowKey && "flows" in s && s.flows ? { flow: s.flows[t.flowKey] } : {};
|
|
188
|
+
return { scheme: s, ...i };
|
|
185
189
|
})[0];
|
|
186
190
|
}
|
|
187
|
-
),
|
|
191
|
+
), we = d(
|
|
188
192
|
() => {
|
|
189
193
|
var e, t;
|
|
190
194
|
return ((e = h.value) == null ? void 0 : e.security) ?? ((t = y.value) == null ? void 0 : t.spec.security) ?? [];
|
|
191
195
|
}
|
|
192
|
-
),
|
|
196
|
+
), j = o({}), F = n(j, o({})), K = (e, t) => {
|
|
193
197
|
const s = A(e);
|
|
194
198
|
t && a.edit(t, "spec.serverUids", [
|
|
195
|
-
...
|
|
199
|
+
...r[t].spec.serverUids,
|
|
196
200
|
s.uid
|
|
197
|
-
]),
|
|
198
|
-
},
|
|
201
|
+
]), F.add(s);
|
|
202
|
+
}, xe = (e, t) => {
|
|
199
203
|
a.edit(
|
|
200
204
|
t,
|
|
201
205
|
"spec.serverUids",
|
|
202
|
-
|
|
206
|
+
r[t].spec.serverUids.filter(
|
|
203
207
|
(s) => s !== e
|
|
204
208
|
)
|
|
205
|
-
),
|
|
209
|
+
), F.delete(e);
|
|
206
210
|
};
|
|
207
211
|
async function W(e) {
|
|
208
|
-
var
|
|
209
|
-
const t = await ee(
|
|
210
|
-
|
|
211
|
-
(((
|
|
212
|
+
var i;
|
|
213
|
+
const t = oe(e), s = await ee(t);
|
|
214
|
+
s.requests.forEach((c) => U(c)), B(s.collection), s.folders.forEach((c) => I(c)), s.servers.forEach((c) => K(c)), Object.entries(
|
|
215
|
+
(((i = s.components) == null ? void 0 : i.securitySchemes) || s.securityDefinitions) ?? {}
|
|
212
216
|
).forEach(
|
|
213
|
-
([
|
|
214
|
-
z({ ...
|
|
217
|
+
([c, w]) => P.add(
|
|
218
|
+
z({ ...w, uid: c })
|
|
215
219
|
)
|
|
216
220
|
);
|
|
217
221
|
}
|
|
218
|
-
async function
|
|
222
|
+
async function be(e, t) {
|
|
219
223
|
try {
|
|
220
224
|
const s = await _(e, t);
|
|
221
225
|
await W(s);
|
|
@@ -223,68 +227,68 @@ async function xe(e, t) {
|
|
|
223
227
|
console.error("Failed to fetch spec from URL:", s);
|
|
224
228
|
}
|
|
225
229
|
}
|
|
226
|
-
const
|
|
230
|
+
const ke = N(), Te = () => ({
|
|
227
231
|
// ---------------------------------------------------------------------------
|
|
228
232
|
// STATE
|
|
229
233
|
workspace: se(v),
|
|
230
234
|
workspaceRequests: D,
|
|
231
|
-
collections:
|
|
235
|
+
collections: r,
|
|
232
236
|
requests: u,
|
|
233
237
|
environments: O,
|
|
234
238
|
requestExamples: p,
|
|
235
|
-
folders:
|
|
239
|
+
folders: l,
|
|
236
240
|
cookies: g,
|
|
237
|
-
servers:
|
|
241
|
+
servers: j,
|
|
238
242
|
securitySchemes: q,
|
|
239
|
-
activeCookieId:
|
|
243
|
+
activeCookieId: fe,
|
|
240
244
|
activeCollection: y,
|
|
241
|
-
activeServer:
|
|
242
|
-
activeSecurityRequirements:
|
|
243
|
-
activeSecurityScheme:
|
|
245
|
+
activeServer: ve,
|
|
246
|
+
activeSecurityRequirements: we,
|
|
247
|
+
activeSecurityScheme: Se,
|
|
244
248
|
activeRequest: h,
|
|
245
|
-
activeExample:
|
|
246
|
-
modalState:
|
|
249
|
+
activeExample: ae,
|
|
250
|
+
modalState: ke,
|
|
247
251
|
// ---------------------------------------------------------------------------
|
|
248
252
|
// METHODS
|
|
249
253
|
importSpecFile: W,
|
|
250
|
-
importSpecFromUrl:
|
|
251
|
-
cookieMutators:
|
|
252
|
-
createExampleFromRequest:
|
|
254
|
+
importSpecFromUrl: be,
|
|
255
|
+
cookieMutators: me,
|
|
256
|
+
createExampleFromRequest: R,
|
|
253
257
|
collectionMutators: {
|
|
254
258
|
...a,
|
|
255
259
|
add: B,
|
|
256
|
-
delete:
|
|
260
|
+
delete: pe
|
|
257
261
|
},
|
|
258
262
|
environmentMutators: {
|
|
259
263
|
...C,
|
|
260
|
-
delete:
|
|
264
|
+
delete: ue
|
|
261
265
|
},
|
|
262
266
|
folderMutators: {
|
|
263
267
|
...m,
|
|
264
268
|
add: I,
|
|
265
|
-
delete:
|
|
269
|
+
delete: ye
|
|
266
270
|
},
|
|
267
271
|
requestMutators: {
|
|
268
272
|
...S,
|
|
269
273
|
add: U,
|
|
270
|
-
delete:
|
|
274
|
+
delete: re
|
|
271
275
|
},
|
|
272
276
|
requestExampleMutators: {
|
|
273
|
-
...
|
|
274
|
-
add:
|
|
275
|
-
delete:
|
|
277
|
+
...k,
|
|
278
|
+
add: le,
|
|
279
|
+
delete: de
|
|
276
280
|
},
|
|
277
|
-
requestsHistory:
|
|
281
|
+
requestsHistory: ne,
|
|
278
282
|
securitySchemeMutators: P,
|
|
279
283
|
serverMutators: {
|
|
280
|
-
...
|
|
284
|
+
...F,
|
|
281
285
|
add: K,
|
|
282
|
-
delete:
|
|
286
|
+
delete: xe
|
|
283
287
|
},
|
|
284
288
|
workspaceMutators: {
|
|
285
|
-
edit:
|
|
289
|
+
edit: he
|
|
286
290
|
}
|
|
287
291
|
});
|
|
288
292
|
export {
|
|
289
|
-
|
|
293
|
+
Te as useWorkspace
|
|
290
294
|
};
|