@scalar/api-client 2.0.59 → 2.0.62
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 +47 -0
- package/dist/components/CodeInput/CodeInput.vue.js +2 -2
- package/dist/components/CodeInput/CodeInput.vue2.js +16 -15
- package/dist/components/CodeInput/codeVariableWidget.d.ts.map +1 -1
- package/dist/components/CodeInput/codeVariableWidget.js +35 -30
- package/dist/components/EnvironmentSelector/EnvironmentSelector.vue.d.ts +3 -0
- package/dist/components/EnvironmentSelector/EnvironmentSelector.vue.d.ts.map +1 -0
- package/dist/components/EnvironmentSelector/EnvironmentSelector.vue.js +114 -0
- package/dist/components/EnvironmentSelector/EnvironmentSelector.vue2.js +4 -0
- package/dist/components/TopNav/TopNav.vue.d.ts.map +1 -1
- package/dist/components/TopNav/TopNav.vue.js +2 -2
- package/dist/components/TopNav/TopNav.vue2.js +112 -64
- package/dist/layouts/App/create-api-client-app.d.ts +153 -129
- package/dist/layouts/App/create-api-client-app.d.ts.map +1 -1
- package/dist/layouts/Modal/create-api-client-modal.d.ts +306 -258
- package/dist/layouts/Modal/create-api-client-modal.d.ts.map +1 -1
- package/dist/libs/create-client.d.ts +153 -129
- package/dist/libs/create-client.d.ts.map +1 -1
- package/dist/libs/event-busses/hot-keys-bus.d.ts +1 -1
- package/dist/libs/local-storage.js +1 -1
- package/dist/libs/normalizeHeaders.d.ts +1 -2
- package/dist/libs/normalizeHeaders.d.ts.map +1 -1
- package/dist/libs/sendRequest.d.ts +4 -5
- package/dist/libs/sendRequest.d.ts.map +1 -1
- package/dist/libs/sendRequest.js +104 -86
- package/dist/store/workspace.d.ts +302 -257
- package/dist/store/workspace.d.ts.map +1 -1
- package/dist/store/workspace.js +219 -216
- package/dist/style.css +1 -1
- package/dist/views/Environment/Environment.vue2.js +12 -12
- package/dist/views/Environment/EnvironmentVariableDropdown.vue.d.ts.map +1 -1
- package/dist/views/Environment/EnvironmentVariableDropdown.vue.js +54 -52
- package/dist/views/Request/Request.vue.d.ts.map +1 -1
- package/dist/views/Request/Request.vue.js +4 -4
- package/dist/views/Request/Request.vue2.js +91 -89
- 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 +1 -1
- package/dist/views/Request/RequestSidebarItem.vue.d.ts.map +1 -1
- package/dist/views/Request/RequestSidebarItem.vue.js +2 -2
- package/dist/views/Request/RequestSidebarItem.vue2.js +82 -80
- package/dist/views/Request/ResponseSection/ResponseBody.vue.d.ts +2 -2
- package/dist/views/Request/ResponseSection/ResponseBody.vue.d.ts.map +1 -1
- package/dist/views/Request/ResponseSection/ResponseBody.vue.js +20 -20
- package/dist/views/Request/ResponseSection/ResponseSection.vue.d.ts.map +1 -1
- package/dist/views/Request/ResponseSection/ResponseSection.vue.js +47 -42
- package/package.json +8 -8
package/dist/store/workspace.js
CHANGED
|
@@ -1,61 +1,61 @@
|
|
|
1
|
-
import { PathId as
|
|
2
|
-
import { useModal as
|
|
3
|
-
import { createWorkspace as
|
|
4
|
-
import { createCollection as
|
|
5
|
-
import { createCookie as
|
|
6
|
-
import { createEnvironment as
|
|
7
|
-
import { createFolder as
|
|
8
|
-
import { createSecurityScheme as
|
|
9
|
-
import { createServer as
|
|
10
|
-
import { createRequest as
|
|
11
|
-
import { iterateTitle as
|
|
12
|
-
import { getRequestBodyFromOperation as
|
|
13
|
-
import { importSpecToWorkspace as
|
|
1
|
+
import { PathId as m, fallbackMissingParams as je } from "../router.js";
|
|
2
|
+
import { useModal as Ce } from "@scalar/components";
|
|
3
|
+
import { createWorkspace as We } from "@scalar/oas-utils/entities/workspace";
|
|
4
|
+
import { createCollection as ge } from "@scalar/oas-utils/entities/workspace/collection";
|
|
5
|
+
import { createCookie as Ie } from "@scalar/oas-utils/entities/workspace/cookie";
|
|
6
|
+
import { createEnvironment as Fe } from "@scalar/oas-utils/entities/workspace/environment";
|
|
7
|
+
import { createFolder as Ke } from "@scalar/oas-utils/entities/workspace/folder";
|
|
8
|
+
import { createSecurityScheme as Ae, securitySchemeApiKeyIn as Pe } from "@scalar/oas-utils/entities/workspace/security";
|
|
9
|
+
import { createServer as Te } from "@scalar/oas-utils/entities/workspace/server";
|
|
10
|
+
import { createRequest as qe, createRequestExample as Ne, createRequestExampleParameter as Be } from "@scalar/oas-utils/entities/workspace/spec";
|
|
11
|
+
import { iterateTitle as De, fetchSpecFromUrl as Le } from "@scalar/oas-utils/helpers";
|
|
12
|
+
import { getRequestBodyFromOperation as _e } from "@scalar/oas-utils/spec-getters";
|
|
13
|
+
import { importSpecToWorkspace as Ve } from "@scalar/oas-utils/transforms";
|
|
14
14
|
import { mutationFactory as E, LS_KEYS as b } from "@scalar/object-utils/mutator-record";
|
|
15
|
-
import { computed as u, reactive as
|
|
16
|
-
const
|
|
15
|
+
import { computed as u, reactive as n, ref as $e, inject as Je, toRaw as Ye } from "vue";
|
|
16
|
+
const nt = (H, y = !0) => {
|
|
17
17
|
const C = u(() => {
|
|
18
18
|
const e = {
|
|
19
|
-
[
|
|
20
|
-
[
|
|
21
|
-
[
|
|
22
|
-
[
|
|
23
|
-
[
|
|
24
|
-
[
|
|
25
|
-
[
|
|
26
|
-
[
|
|
19
|
+
[m.Collection]: "default",
|
|
20
|
+
[m.Environment]: "default",
|
|
21
|
+
[m.Request]: "default",
|
|
22
|
+
[m.Examples]: "default",
|
|
23
|
+
[m.Schema]: "default",
|
|
24
|
+
[m.Cookies]: "default",
|
|
25
|
+
[m.Servers]: "default",
|
|
26
|
+
[m.Workspace]: "default"
|
|
27
27
|
}, t = H.currentRoute.value;
|
|
28
|
-
return t && Object.values(
|
|
28
|
+
return t && Object.values(m).forEach((s) => {
|
|
29
29
|
t.params[s] && (e[s] = t.params[s]);
|
|
30
30
|
}), e;
|
|
31
|
-
}),
|
|
32
|
-
|
|
33
|
-
|
|
31
|
+
}), h = n({}), p = E(
|
|
32
|
+
h,
|
|
33
|
+
n({}),
|
|
34
34
|
y && b.REQUEST
|
|
35
|
-
),
|
|
36
|
-
const c =
|
|
37
|
-
return c.childUids.push(i.uid),
|
|
35
|
+
), B = (e, t, s) => {
|
|
36
|
+
const c = qe(e), i = Q(c, s);
|
|
37
|
+
return c.childUids.push(i.uid), p.add(c), t && (d[t] ? v.edit(t, "childUids", [
|
|
38
38
|
...d[t].childUids,
|
|
39
39
|
c.uid
|
|
40
|
-
]) : r[t] &&
|
|
40
|
+
]) : r[t] && k.edit(t, "childUids", [
|
|
41
41
|
...r[t].childUids,
|
|
42
42
|
c.uid
|
|
43
43
|
])), c;
|
|
44
|
-
},
|
|
45
|
-
e.childUids.forEach((s) => g.delete(s)), t && d[t] ?
|
|
44
|
+
}, D = (e, t) => {
|
|
45
|
+
e.childUids.forEach((s) => g.delete(s)), t && d[t] ? v.edit(
|
|
46
46
|
t,
|
|
47
47
|
"childUids",
|
|
48
48
|
d[t].childUids.filter((s) => s !== e.uid)
|
|
49
|
-
) : t && r[t] &&
|
|
49
|
+
) : t && r[t] && k.edit(
|
|
50
50
|
t,
|
|
51
51
|
"childUids",
|
|
52
52
|
r[t].childUids.filter((s) => s !== e.uid)
|
|
53
|
-
),
|
|
54
|
-
},
|
|
53
|
+
), p.delete(e.uid);
|
|
54
|
+
}, x = u(() => {
|
|
55
55
|
var c, i;
|
|
56
|
-
const e = C.value[
|
|
57
|
-
return
|
|
58
|
-
}),
|
|
56
|
+
const e = C.value[m.Request], t = (i = (c = Z.value) == null ? void 0 : c[0]) == null ? void 0 : i.uid, s = h[e] ?? h[t];
|
|
57
|
+
return je(m.Request, s), s;
|
|
58
|
+
}), L = (e, t = []) => {
|
|
59
59
|
const s = Object.values(d).find(
|
|
60
60
|
(i) => i.childUids.includes(e)
|
|
61
61
|
);
|
|
@@ -63,14 +63,14 @@ const lt = (H, y = !0) => {
|
|
|
63
63
|
const c = Object.values(r).find(
|
|
64
64
|
({ childUids: i }) => i.includes(e)
|
|
65
65
|
);
|
|
66
|
-
return c ?
|
|
67
|
-
}, W =
|
|
66
|
+
return c ? L(c.uid, [...t, c.uid]) : t;
|
|
67
|
+
}, W = n({}), g = E(
|
|
68
68
|
W,
|
|
69
|
-
|
|
69
|
+
n({}),
|
|
70
70
|
y && b.REQUEST_EXAMPLE
|
|
71
71
|
), K = (e) => {
|
|
72
|
-
var t, s, c, i,
|
|
73
|
-
return
|
|
72
|
+
var t, s, c, i, l, f, M;
|
|
73
|
+
return Be({
|
|
74
74
|
key: e.name,
|
|
75
75
|
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] : "",
|
|
76
76
|
description: e.description,
|
|
@@ -80,12 +80,12 @@ const lt = (H, y = !0) => {
|
|
|
80
80
|
type: (s = e.schema) == null ? void 0 : s.type,
|
|
81
81
|
format: (c = e.schema) == null ? void 0 : c.format,
|
|
82
82
|
minimum: (i = e.schema) == null ? void 0 : i.minimum,
|
|
83
|
-
maximum: (
|
|
84
|
-
default: (
|
|
85
|
-
nullable: (
|
|
83
|
+
maximum: (l = e.schema) == null ? void 0 : l.maximum,
|
|
84
|
+
default: (f = e.schema) == null ? void 0 : f.default,
|
|
85
|
+
nullable: (M = e.schema) == null ? void 0 : M.nullable
|
|
86
86
|
});
|
|
87
87
|
}, Q = (e, t, s) => {
|
|
88
|
-
var
|
|
88
|
+
var M;
|
|
89
89
|
const c = {
|
|
90
90
|
path: Object.values(e.parameters.path).map(K),
|
|
91
91
|
query: Object.values(e.parameters.query).map(K),
|
|
@@ -103,55 +103,55 @@ const lt = (H, y = !0) => {
|
|
|
103
103
|
}
|
|
104
104
|
};
|
|
105
105
|
if (e.requestBody) {
|
|
106
|
-
const S =
|
|
106
|
+
const S = _e({
|
|
107
107
|
httpVerb: e.method,
|
|
108
108
|
path: e.path,
|
|
109
109
|
information: {
|
|
110
110
|
requestBody: e.requestBody
|
|
111
111
|
}
|
|
112
112
|
});
|
|
113
|
-
((
|
|
113
|
+
((M = S == null ? void 0 : S.postData) == null ? void 0 : M.mimeType) === "application/json" && (c.headers.push({
|
|
114
114
|
key: "Content-Type",
|
|
115
115
|
value: "application/json",
|
|
116
116
|
enabled: !0
|
|
117
117
|
}), i.activeBody = "raw", i.raw.value = S.postData.text);
|
|
118
118
|
}
|
|
119
|
-
const
|
|
119
|
+
const l = s ?? De(
|
|
120
120
|
(e.summary ?? "Example") + " #1",
|
|
121
121
|
(S) => e.childUids.some((o) => S === W[o].name)
|
|
122
|
-
),
|
|
122
|
+
), f = Ne({
|
|
123
123
|
url: t != null && t.url ? `{{${t == null ? void 0 : t.url}}}${e.path}` : e.path,
|
|
124
124
|
requestUid: e.uid,
|
|
125
125
|
parameters: c,
|
|
126
|
-
name:
|
|
126
|
+
name: l,
|
|
127
127
|
body: i
|
|
128
128
|
});
|
|
129
|
-
return g.add(
|
|
129
|
+
return g.add(f), f;
|
|
130
130
|
}, ae = (e, t) => {
|
|
131
131
|
const s = Q(
|
|
132
132
|
e,
|
|
133
133
|
V.value[0],
|
|
134
134
|
t
|
|
135
135
|
);
|
|
136
|
-
return
|
|
136
|
+
return p.edit(e.uid, "childUids", [
|
|
137
137
|
...e.childUids,
|
|
138
138
|
s.uid
|
|
139
139
|
]), s;
|
|
140
140
|
}, de = (e) => {
|
|
141
|
-
|
|
141
|
+
p.edit(
|
|
142
142
|
e.requestUid,
|
|
143
143
|
"childUids",
|
|
144
|
-
|
|
144
|
+
h[e.requestUid].childUids.filter(
|
|
145
145
|
(t) => t !== e.uid
|
|
146
146
|
)
|
|
147
147
|
), g.delete(e.uid);
|
|
148
148
|
}, le = u(
|
|
149
149
|
() => {
|
|
150
150
|
var e;
|
|
151
|
-
return W[C.value[
|
|
151
|
+
return W[C.value[m.Examples]] ?? W[((e = x.value) == null ? void 0 : e.childUids[0]) ?? ""];
|
|
152
152
|
}
|
|
153
|
-
),
|
|
154
|
-
default:
|
|
153
|
+
), ne = u(() => Object.values(h).flatMap((e) => e.history).filter((e) => e.request && e.response).sort((e, t) => t.timestamp - e.timestamp)), A = n({
|
|
154
|
+
default: Fe({
|
|
155
155
|
uid: "default",
|
|
156
156
|
name: "Global Environment",
|
|
157
157
|
color: "blue",
|
|
@@ -160,34 +160,31 @@ const lt = (H, y = !0) => {
|
|
|
160
160
|
isDefault: !0
|
|
161
161
|
})
|
|
162
162
|
}), G = E(
|
|
163
|
-
|
|
164
|
-
|
|
163
|
+
A,
|
|
164
|
+
n({}),
|
|
165
165
|
y && b.ENVIRONMENT
|
|
166
|
-
),
|
|
166
|
+
), re = (e) => {
|
|
167
167
|
if (e === "default") {
|
|
168
168
|
console.warn("Default environment cannot be deleted.");
|
|
169
169
|
return;
|
|
170
170
|
}
|
|
171
171
|
G.delete(e);
|
|
172
172
|
}, ue = u(() => {
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
173
|
+
var c;
|
|
174
|
+
const e = A[((c = R.value) == null ? void 0 : c.activeEnvironmentId) ?? "default"], t = V.value.map((i) => ({
|
|
175
|
+
key: i.url,
|
|
176
|
+
value: i.url
|
|
177
|
+
})), s = e ? (() => {
|
|
177
178
|
try {
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
...JSON.parse(s.raw)
|
|
181
|
-
};
|
|
179
|
+
const i = JSON.parse(e.raw);
|
|
180
|
+
return Object.entries(i).flatMap(([l, f]) => l !== "_scalarEnvId" ? [{ _scalarEnvId: e.uid, key: l, value: f }] : []);
|
|
182
181
|
} catch {
|
|
183
|
-
return
|
|
182
|
+
return [];
|
|
184
183
|
}
|
|
185
|
-
})
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
}), X = l({
|
|
190
|
-
default: ge({
|
|
184
|
+
})() : [];
|
|
185
|
+
return [...t, ...s];
|
|
186
|
+
}), X = n({
|
|
187
|
+
default: Ie({
|
|
191
188
|
uid: "default",
|
|
192
189
|
name: "Cookie",
|
|
193
190
|
value: "",
|
|
@@ -197,19 +194,19 @@ const lt = (H, y = !0) => {
|
|
|
197
194
|
httpOnly: !1,
|
|
198
195
|
sameSite: "None"
|
|
199
196
|
})
|
|
200
|
-
}),
|
|
197
|
+
}), me = E(
|
|
201
198
|
X,
|
|
202
|
-
|
|
199
|
+
n({}),
|
|
203
200
|
y && b.COOKIE
|
|
204
|
-
),
|
|
205
|
-
() => C.value[
|
|
206
|
-
), w =
|
|
201
|
+
), fe = u(
|
|
202
|
+
() => C.value[m.Cookies]
|
|
203
|
+
), w = n({}), U = E(
|
|
207
204
|
w,
|
|
208
|
-
|
|
205
|
+
n({}),
|
|
209
206
|
y && b.WORKSPACE
|
|
210
207
|
), he = (e = {}) => {
|
|
211
|
-
const t =
|
|
212
|
-
|
|
208
|
+
const t = We(e);
|
|
209
|
+
U.add(t);
|
|
213
210
|
const s = $(
|
|
214
211
|
{
|
|
215
212
|
spec: {
|
|
@@ -220,55 +217,60 @@ const lt = (H, y = !0) => {
|
|
|
220
217
|
},
|
|
221
218
|
t.uid
|
|
222
219
|
);
|
|
223
|
-
return
|
|
220
|
+
return B({ summary: "My First Request" }, s.uid), t;
|
|
224
221
|
}, pe = (e) => {
|
|
225
222
|
if (Object.keys(w).length <= 1) {
|
|
226
223
|
console.warn("The last workspace cannot be deleted.");
|
|
227
224
|
return;
|
|
228
225
|
}
|
|
229
|
-
|
|
226
|
+
U.delete(e);
|
|
230
227
|
}, ve = (e, t) => {
|
|
231
|
-
w[e] ?
|
|
232
|
-
},
|
|
233
|
-
() => w[C.value[
|
|
234
|
-
),
|
|
228
|
+
w[e] ? U.edit(e, "name", t) : console.warn(`Workspace with uid ${e} not found.`);
|
|
229
|
+
}, R = u(
|
|
230
|
+
() => w[C.value[m.Workspace]] ?? w[Object.keys(w)[0]]
|
|
231
|
+
), ye = u(
|
|
235
232
|
() => {
|
|
236
233
|
var e;
|
|
237
|
-
return (e =
|
|
238
|
-
|
|
239
|
-
|
|
234
|
+
return A[((e = R.value) == null ? void 0 : e.activeEnvironmentId) ?? "default"];
|
|
235
|
+
}
|
|
236
|
+
), _ = u(
|
|
237
|
+
() => {
|
|
238
|
+
var e;
|
|
239
|
+
return (e = R.value) == null ? void 0 : e.collectionUids.map((t) => d[t]).sort((t, s) => {
|
|
240
|
+
var c, i, l, f;
|
|
241
|
+
return ((i = (c = t.spec) == null ? void 0 : c.info) == null ? void 0 : i.title) === "Drafts" ? 1 : ((f = (l = s.spec) == null ? void 0 : l.info) == null ? void 0 : f.title) === "Drafts" ? -1 : 0;
|
|
240
242
|
});
|
|
241
243
|
}
|
|
242
244
|
), V = u(
|
|
243
245
|
() => {
|
|
244
246
|
var e;
|
|
245
|
-
return (e =
|
|
246
|
-
(t) => t.spec.serverUids.map((s) =>
|
|
247
|
+
return (e = _.value) == null ? void 0 : e.flatMap(
|
|
248
|
+
(t) => t.spec.serverUids.map((s) => q[s])
|
|
247
249
|
);
|
|
248
250
|
}
|
|
249
|
-
), z = (e) =>
|
|
251
|
+
), z = (e) => h[e] ?? r[e].childUids.flatMap((t) => z(t)), Z = u(
|
|
250
252
|
() => {
|
|
251
253
|
var e;
|
|
252
|
-
return (e =
|
|
254
|
+
return (e = _.value) == null ? void 0 : e.flatMap(
|
|
253
255
|
(t) => t.childUids.flatMap((s) => z(s))
|
|
254
256
|
);
|
|
255
257
|
}
|
|
256
|
-
),
|
|
258
|
+
), Se = u(() => {
|
|
257
259
|
var e;
|
|
258
|
-
return ((e =
|
|
259
|
-
}), d =
|
|
260
|
+
return ((e = R.value) == null ? void 0 : e.isReadOnly) ?? !1;
|
|
261
|
+
}), d = n({}), v = E(
|
|
260
262
|
d,
|
|
261
|
-
|
|
263
|
+
n({}),
|
|
262
264
|
y && b.COLLECTION
|
|
263
265
|
), $ = (e, t) => {
|
|
264
|
-
const s =
|
|
265
|
-
return
|
|
266
|
+
const s = ge(e);
|
|
267
|
+
return U.edit(t, "collectionUids", [
|
|
266
268
|
...w[t].collectionUids,
|
|
267
269
|
s.uid
|
|
268
|
-
]),
|
|
269
|
-
},
|
|
270
|
+
]), v.add(s), s;
|
|
271
|
+
}, Ee = (e) => {
|
|
270
272
|
var t, s, c;
|
|
271
|
-
if (
|
|
273
|
+
if (R.value) {
|
|
272
274
|
if (((c = (s = (t = d[e.uid]) == null ? void 0 : t.spec) == null ? void 0 : s.info) == null ? void 0 : c.title) === "Drafts") {
|
|
273
275
|
console.warn("The drafts collection cannot be deleted");
|
|
274
276
|
return;
|
|
@@ -278,38 +280,38 @@ const lt = (H, y = !0) => {
|
|
|
278
280
|
return;
|
|
279
281
|
}
|
|
280
282
|
e.childUids.forEach((i) => {
|
|
281
|
-
|
|
282
|
-
}),
|
|
283
|
-
|
|
283
|
+
h[i] ? D(h[i]) : r[i] && J(r[i]);
|
|
284
|
+
}), U.edit(
|
|
285
|
+
R.value.uid,
|
|
284
286
|
"collectionUids",
|
|
285
|
-
|
|
287
|
+
R.value.collectionUids.filter(
|
|
286
288
|
(i) => i !== e.uid
|
|
287
289
|
)
|
|
288
|
-
),
|
|
290
|
+
), v.delete(e.uid);
|
|
289
291
|
}
|
|
290
|
-
},
|
|
292
|
+
}, P = u(() => {
|
|
291
293
|
const e = Object.values(d)[0];
|
|
292
|
-
if (!
|
|
293
|
-
const t =
|
|
294
|
+
if (!x.value) return e;
|
|
295
|
+
const t = L(x.value.uid);
|
|
294
296
|
if (!t.length) return null;
|
|
295
297
|
const s = t[t.length - 1];
|
|
296
298
|
return d[s] ?? e;
|
|
297
|
-
}),
|
|
298
|
-
() =>
|
|
299
|
-
), r =
|
|
299
|
+
}), be = u(
|
|
300
|
+
() => P.value && q[P.value.selectedServerUid]
|
|
301
|
+
), r = n({}), k = E(
|
|
300
302
|
r,
|
|
301
|
-
|
|
303
|
+
n({}),
|
|
302
304
|
y && b.FOLDER
|
|
303
305
|
), ee = (e, t) => {
|
|
304
|
-
const s =
|
|
306
|
+
const s = Ke(e);
|
|
305
307
|
if (t)
|
|
306
308
|
if (d[t])
|
|
307
|
-
|
|
309
|
+
v.edit(t, "childUids", [
|
|
308
310
|
...d[t].childUids,
|
|
309
311
|
s.uid
|
|
310
312
|
]);
|
|
311
313
|
else if (r[t])
|
|
312
|
-
|
|
314
|
+
k.edit(t, "childUids", [
|
|
313
315
|
...r[t].childUids,
|
|
314
316
|
s.uid
|
|
315
317
|
]);
|
|
@@ -317,99 +319,99 @@ const lt = (H, y = !0) => {
|
|
|
317
319
|
console.error("Could not find folder's parent ID");
|
|
318
320
|
return;
|
|
319
321
|
}
|
|
320
|
-
|
|
322
|
+
k.add(s);
|
|
321
323
|
}, J = (e, t) => {
|
|
322
324
|
e.childUids.forEach((s) => {
|
|
323
|
-
|
|
324
|
-
}), t && d[t] ?
|
|
325
|
+
h[s] ? D(h[s]) : r[s] && J(r[s]);
|
|
326
|
+
}), t && d[t] ? v.edit(
|
|
325
327
|
t,
|
|
326
328
|
"childUids",
|
|
327
329
|
d[t].childUids.filter((s) => s !== e.uid)
|
|
328
|
-
) : t && r[t] &&
|
|
330
|
+
) : t && r[t] && k.edit(
|
|
329
331
|
t,
|
|
330
332
|
"childUids",
|
|
331
333
|
r[t].childUids.filter((s) => s !== e.uid)
|
|
332
|
-
),
|
|
333
|
-
}, Y =
|
|
334
|
+
), k.delete(e.uid);
|
|
335
|
+
}, Y = n({}), T = E(
|
|
334
336
|
Y,
|
|
335
|
-
|
|
337
|
+
n({}),
|
|
336
338
|
y && b.SECURITY_SCHEME
|
|
337
|
-
),
|
|
339
|
+
), we = u(
|
|
338
340
|
() => {
|
|
339
341
|
var e;
|
|
340
|
-
return ((e =
|
|
342
|
+
return ((e = x.value) == null ? void 0 : e.selectedSecuritySchemeUids.map(
|
|
341
343
|
(t) => Y[t]
|
|
342
344
|
)) ?? [];
|
|
343
345
|
}
|
|
344
|
-
),
|
|
346
|
+
), Re = u(
|
|
345
347
|
() => {
|
|
346
348
|
var e, t;
|
|
347
|
-
return ((e =
|
|
349
|
+
return ((e = x.value) == null ? void 0 : e.security) ?? ((t = P.value) == null ? void 0 : t.spec.security) ?? [];
|
|
348
350
|
}
|
|
349
351
|
), I = (e, t, s, c = !1) => {
|
|
350
|
-
const i =
|
|
351
|
-
|
|
352
|
+
const i = Ae(e);
|
|
353
|
+
T.add(i), t && e.nameKey && v.edit(
|
|
352
354
|
t,
|
|
353
355
|
`securitySchemeDict.${e.nameKey}`,
|
|
354
356
|
i.uid
|
|
355
|
-
), s && (
|
|
357
|
+
), s && (p.edit(s.uid, "securitySchemeUids", [
|
|
356
358
|
...s.securitySchemeUids,
|
|
357
359
|
i.uid
|
|
358
|
-
]), c &&
|
|
360
|
+
]), c && p.edit(s.uid, "selectedSecuritySchemeUids", [
|
|
359
361
|
...s.selectedSecuritySchemeUids,
|
|
360
362
|
i.uid
|
|
361
363
|
]));
|
|
362
|
-
},
|
|
363
|
-
t && (
|
|
364
|
+
}, ke = (e, t) => {
|
|
365
|
+
t && (p.edit(
|
|
364
366
|
t.uid,
|
|
365
367
|
"securitySchemeUids",
|
|
366
368
|
t.securitySchemeUids.filter((s) => s !== e.uid)
|
|
367
|
-
),
|
|
369
|
+
), p.edit(
|
|
368
370
|
t.uid,
|
|
369
371
|
"selectedSecuritySchemeUids",
|
|
370
372
|
t.selectedSecuritySchemeUids.filter((s) => s !== e.uid)
|
|
371
|
-
)),
|
|
372
|
-
},
|
|
373
|
-
|
|
374
|
-
|
|
373
|
+
)), T.delete(e.uid);
|
|
374
|
+
}, q = n({}), N = E(
|
|
375
|
+
q,
|
|
376
|
+
n({}),
|
|
375
377
|
y && b.SERVER
|
|
376
378
|
), te = (e, t) => {
|
|
377
|
-
const s =
|
|
378
|
-
t &&
|
|
379
|
+
const s = Te(e);
|
|
380
|
+
t && v.edit(t, "spec.serverUids", [
|
|
379
381
|
...d[t].spec.serverUids,
|
|
380
382
|
s.uid
|
|
381
|
-
]),
|
|
382
|
-
},
|
|
383
|
-
|
|
383
|
+
]), N.add(s);
|
|
384
|
+
}, Me = (e, t) => {
|
|
385
|
+
v.edit(
|
|
384
386
|
t,
|
|
385
387
|
"spec.serverUids",
|
|
386
388
|
d[t].spec.serverUids.filter(
|
|
387
389
|
(s) => s !== e
|
|
388
390
|
)
|
|
389
|
-
),
|
|
391
|
+
), N.delete(e);
|
|
390
392
|
}, se = async (e, t = "default", s) => {
|
|
391
393
|
var S;
|
|
392
|
-
const c =
|
|
394
|
+
const c = Ye(e), i = await Ve(c, s);
|
|
393
395
|
i.requests.forEach(
|
|
394
|
-
(o) =>
|
|
396
|
+
(o) => B(o, void 0, i.servers[0])
|
|
395
397
|
);
|
|
396
|
-
const
|
|
398
|
+
const l = $(i.collection, t);
|
|
397
399
|
i.folders.forEach((o) => ee(o)), i.servers.forEach((o) => te(o));
|
|
398
|
-
const
|
|
400
|
+
const f = Object.entries(
|
|
399
401
|
(((S = i.components) == null ? void 0 : S.securitySchemes) || i.securityDefinitions) ?? {}
|
|
400
|
-
),
|
|
401
|
-
const
|
|
402
|
-
if (!
|
|
403
|
-
const j =
|
|
404
|
-
(F) =>
|
|
402
|
+
), M = (o, a) => {
|
|
403
|
+
const O = Object.keys(o[0]);
|
|
404
|
+
if (!O.length) return;
|
|
405
|
+
const j = O.map(
|
|
406
|
+
(F) => l.securitySchemeDict[F]
|
|
405
407
|
);
|
|
406
|
-
|
|
408
|
+
p.edit(a.uid, "selectedSecuritySchemeUids", j);
|
|
407
409
|
};
|
|
408
|
-
|
|
410
|
+
f.forEach(([o, a]) => {
|
|
409
411
|
if (a && "flows" in a) {
|
|
410
|
-
const { flows:
|
|
411
|
-
if (
|
|
412
|
-
const F = Object.entries(
|
|
412
|
+
const { flows: O, ...j } = a;
|
|
413
|
+
if (O) {
|
|
414
|
+
const F = Object.entries(O), [ce, oe] = F[0];
|
|
413
415
|
ce && oe && I(
|
|
414
416
|
{
|
|
415
417
|
...j,
|
|
@@ -417,12 +419,12 @@ const lt = (H, y = !0) => {
|
|
|
417
419
|
flow: { ...oe, type: ce },
|
|
418
420
|
nameKey: o
|
|
419
421
|
},
|
|
420
|
-
|
|
422
|
+
l.uid
|
|
421
423
|
);
|
|
422
424
|
}
|
|
423
425
|
} else a.type === "basic" ? I(
|
|
424
426
|
{ ...a, type: "http", scheme: "basic", nameKey: o },
|
|
425
|
-
|
|
427
|
+
l.uid
|
|
426
428
|
) : a.type === "http" ? I(
|
|
427
429
|
{
|
|
428
430
|
...a,
|
|
@@ -430,88 +432,89 @@ const lt = (H, y = !0) => {
|
|
|
430
432
|
scheme: a.scheme === "bearer" ? "bearer" : "basic",
|
|
431
433
|
nameKey: o
|
|
432
434
|
},
|
|
433
|
-
|
|
435
|
+
l.uid
|
|
434
436
|
) : a.type === "apiKey" && I(
|
|
435
437
|
{
|
|
436
438
|
...a,
|
|
437
439
|
type: "apiKey",
|
|
438
|
-
in:
|
|
440
|
+
in: Pe.includes(
|
|
439
441
|
a.in
|
|
440
442
|
) ? a.in : "header",
|
|
441
443
|
nameKey: o
|
|
442
444
|
},
|
|
443
|
-
|
|
445
|
+
l.uid
|
|
444
446
|
);
|
|
445
|
-
}),
|
|
446
|
-
var
|
|
447
|
-
const a = ((
|
|
448
|
-
a != null && a.length ?
|
|
447
|
+
}), f.length && Object.values(h).forEach((o) => {
|
|
448
|
+
var O, j;
|
|
449
|
+
const a = ((O = o.security) == null ? void 0 : O.filter((F) => JSON.stringify(F) !== "{}")) ?? [];
|
|
450
|
+
a != null && a.length ? M(a, o) : typeof o.security > "u" && ((j = l.spec.security) != null && j.length) && M(l.spec.security, o);
|
|
449
451
|
});
|
|
450
452
|
};
|
|
451
|
-
async function
|
|
452
|
-
const c = await
|
|
453
|
+
async function Oe(e, t, s) {
|
|
454
|
+
const c = await Le(e, t);
|
|
453
455
|
await se(c, void 0, s);
|
|
454
456
|
}
|
|
455
|
-
const ie =
|
|
457
|
+
const ie = $e(localStorage.getItem("sidebarWidth") || "280px"), Ue = (e) => {
|
|
456
458
|
ie.value = e, localStorage.setItem("sidebarWidth", e);
|
|
457
|
-
},
|
|
459
|
+
}, xe = Ce();
|
|
458
460
|
return {
|
|
459
461
|
// ---------------------------------------------------------------------------
|
|
460
462
|
// STATE
|
|
461
463
|
workspaces: w,
|
|
462
464
|
collections: d,
|
|
463
465
|
cookies: X,
|
|
464
|
-
environments:
|
|
466
|
+
environments: A,
|
|
465
467
|
folders: r,
|
|
466
468
|
requestExamples: W,
|
|
467
|
-
requests:
|
|
468
|
-
servers:
|
|
469
|
+
requests: h,
|
|
470
|
+
servers: q,
|
|
469
471
|
securitySchemes: Y,
|
|
470
|
-
activeCollection:
|
|
471
|
-
activeCookieId:
|
|
472
|
+
activeCollection: P,
|
|
473
|
+
activeCookieId: fe,
|
|
472
474
|
activeExample: le,
|
|
473
|
-
activeRequest:
|
|
475
|
+
activeRequest: x,
|
|
474
476
|
activeRouterParams: C,
|
|
475
|
-
activeSecurityRequirements:
|
|
476
|
-
activeSecuritySchemes:
|
|
477
|
-
activeServer:
|
|
478
|
-
activeWorkspace:
|
|
479
|
-
activeWorkspaceCollections:
|
|
477
|
+
activeSecurityRequirements: Re,
|
|
478
|
+
activeSecuritySchemes: we,
|
|
479
|
+
activeServer: be,
|
|
480
|
+
activeWorkspace: R,
|
|
481
|
+
activeWorkspaceCollections: _,
|
|
480
482
|
activeWorkspaceServers: V,
|
|
481
483
|
activeParsedEnvironments: ue,
|
|
482
484
|
activeWorkspaceRequests: Z,
|
|
483
|
-
|
|
484
|
-
|
|
485
|
+
activeEnvironment: ye,
|
|
486
|
+
modalState: xe,
|
|
487
|
+
isReadOnly: Se,
|
|
485
488
|
router: H,
|
|
486
489
|
sidebarWidth: ie,
|
|
487
|
-
setSidebarWidth:
|
|
490
|
+
setSidebarWidth: Ue,
|
|
488
491
|
// ---------------------------------------------------------------------------
|
|
489
492
|
// METHODS
|
|
490
|
-
findRequestFolders:
|
|
493
|
+
findRequestFolders: L,
|
|
491
494
|
importSpecFile: se,
|
|
492
|
-
importSpecFromUrl:
|
|
493
|
-
cookieMutators:
|
|
495
|
+
importSpecFromUrl: Oe,
|
|
496
|
+
cookieMutators: me,
|
|
494
497
|
collectionMutators: {
|
|
495
|
-
...
|
|
496
|
-
rawAdd:
|
|
498
|
+
...v,
|
|
499
|
+
rawAdd: v.add,
|
|
497
500
|
add: $,
|
|
498
|
-
delete:
|
|
501
|
+
delete: Ee
|
|
499
502
|
},
|
|
500
503
|
environmentMutators: {
|
|
501
504
|
...G,
|
|
502
|
-
delete:
|
|
505
|
+
delete: re
|
|
503
506
|
},
|
|
504
507
|
folderMutators: {
|
|
505
|
-
...
|
|
506
|
-
rawAdd:
|
|
508
|
+
...k,
|
|
509
|
+
rawAdd: k.add,
|
|
507
510
|
add: ee,
|
|
508
511
|
delete: J
|
|
509
512
|
},
|
|
510
513
|
requestMutators: {
|
|
511
|
-
...
|
|
512
|
-
rawAdd:
|
|
513
|
-
add:
|
|
514
|
-
delete:
|
|
514
|
+
...p,
|
|
515
|
+
rawAdd: p.add,
|
|
516
|
+
add: B,
|
|
517
|
+
delete: D
|
|
515
518
|
},
|
|
516
519
|
requestExampleMutators: {
|
|
517
520
|
...g,
|
|
@@ -519,29 +522,29 @@ const lt = (H, y = !0) => {
|
|
|
519
522
|
add: ae,
|
|
520
523
|
delete: de
|
|
521
524
|
},
|
|
522
|
-
requestsHistory:
|
|
525
|
+
requestsHistory: ne,
|
|
523
526
|
securitySchemeMutators: {
|
|
524
|
-
...
|
|
525
|
-
rawAdd:
|
|
527
|
+
...T,
|
|
528
|
+
rawAdd: T.add,
|
|
526
529
|
add: I,
|
|
527
|
-
delete:
|
|
530
|
+
delete: ke
|
|
528
531
|
},
|
|
529
532
|
serverMutators: {
|
|
530
|
-
...
|
|
531
|
-
rawAdd:
|
|
533
|
+
...N,
|
|
534
|
+
rawAdd: N.add,
|
|
532
535
|
add: te,
|
|
533
|
-
delete:
|
|
536
|
+
delete: Me
|
|
534
537
|
},
|
|
535
538
|
workspaceMutators: {
|
|
536
|
-
...
|
|
537
|
-
rawAdd:
|
|
539
|
+
...U,
|
|
540
|
+
rawAdd: U.add,
|
|
538
541
|
add: he,
|
|
539
542
|
delete: pe,
|
|
540
543
|
rename: ve
|
|
541
544
|
}
|
|
542
545
|
};
|
|
543
|
-
}, rt = () =>
|
|
546
|
+
}, rt = () => Je("workspace");
|
|
544
547
|
export {
|
|
545
|
-
|
|
548
|
+
nt as createWorkspaceStore,
|
|
546
549
|
rt as useWorkspace
|
|
547
550
|
};
|