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