@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.
Files changed (65) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/dist/components/AddressBar/AddressBarHistory.vue.d.ts.map +1 -1
  3. package/dist/components/CodeInput/CodeInput.vue.d.ts +2 -2
  4. package/dist/components/CodeInput/CodeInput.vue.d.ts.map +1 -1
  5. package/dist/components/CodeInput/CodeInput.vue.js +2 -2
  6. package/dist/components/CodeInput/CodeInput.vue2.js +62 -47
  7. package/dist/components/CodeInput/codeDropdownWidget.d.ts +9 -1
  8. package/dist/components/CodeInput/codeDropdownWidget.d.ts.map +1 -1
  9. package/dist/components/CodeInput/codeDropdownWidget.js +62 -51
  10. package/dist/components/CodeInput/codeVariableWidget.d.ts +10 -1
  11. package/dist/components/CodeInput/codeVariableWidget.d.ts.map +1 -1
  12. package/dist/components/CodeInput/codeVariableWidget.js +63 -56
  13. package/dist/components/CommandPalette/CommandPaletteImport.vue.js +1 -1
  14. package/dist/components/HttpMethod/HttpMethod.vue.d.ts +2 -2
  15. package/dist/components/TopNav/TopNav.vue.d.ts.map +1 -1
  16. package/dist/components/TopNav/TopNav.vue.js +1 -1
  17. package/dist/components/TopNav/TopNav.vue2.js +65 -34
  18. package/dist/index.d.ts +1 -1
  19. package/dist/index.d.ts.map +1 -1
  20. package/dist/index.js +8 -8
  21. package/dist/layouts/App/create-api-client-app.d.ts +2966 -0
  22. package/dist/layouts/App/create-api-client-app.d.ts.map +1 -0
  23. package/dist/layouts/App/create-api-client-app.js +18 -0
  24. package/dist/layouts/App/index.d.ts +1 -1
  25. package/dist/layouts/App/index.d.ts.map +1 -1
  26. package/dist/layouts/App/index.js +1 -1
  27. package/dist/layouts/Modal/ApiClientModal.vue.d.ts +1 -17
  28. package/dist/layouts/Modal/ApiClientModal.vue.d.ts.map +1 -1
  29. package/dist/layouts/Modal/ApiClientModal.vue.js +1 -1
  30. package/dist/layouts/Modal/ApiClientModal.vue2.js +20 -24
  31. package/dist/layouts/Modal/api-client-modal.d.ts +5905 -57
  32. package/dist/layouts/Modal/api-client-modal.d.ts.map +1 -1
  33. package/dist/layouts/Modal/api-client-modal.js +27 -129
  34. package/dist/libs/create-client.d.ts +3025 -0
  35. package/dist/libs/create-client.d.ts.map +1 -0
  36. package/dist/libs/create-client.js +147 -0
  37. package/dist/libs/index.d.ts +1 -0
  38. package/dist/libs/index.d.ts.map +1 -1
  39. package/dist/libs/index.js +11 -9
  40. package/dist/router.d.ts +4 -20
  41. package/dist/router.d.ts.map +1 -1
  42. package/dist/router.js +28 -44
  43. package/dist/store/index.d.ts +2 -0
  44. package/dist/store/index.d.ts.map +1 -0
  45. package/dist/store/index.js +5 -0
  46. package/dist/store/workspace.d.ts +3028 -603
  47. package/dist/store/workspace.d.ts.map +1 -1
  48. package/dist/store/workspace.js +454 -432
  49. package/dist/style.css +1 -1
  50. package/dist/views/Environment/EnvironmentVariableDropdown.vue.d.ts +8 -0
  51. package/dist/views/Environment/EnvironmentVariableDropdown.vue.d.ts.map +1 -1
  52. package/dist/views/Environment/EnvironmentVariableDropdown.vue.js +32 -31
  53. package/dist/views/Request/RequestSection/RequestTable.vue.d.ts +2 -2
  54. package/dist/views/Request/RequestSidebarItem.vue.d.ts.map +1 -1
  55. package/dist/views/Request/RequestSidebarItem.vue.js +1 -1
  56. package/dist/views/Request/RequestSidebarItem.vue2.js +24 -23
  57. package/dist/views/Request/RequestSidebarItemMenu.vue.d.ts.map +1 -1
  58. package/dist/views/Request/RequestSidebarItemMenu.vue.js +26 -20
  59. package/package.json +10 -6
  60. package/dist/layouts/App/createApiClientApp.d.ts +0 -16
  61. package/dist/layouts/App/createApiClientApp.d.ts.map +0 -1
  62. package/dist/layouts/App/createApiClientApp.js +0 -62
  63. package/dist/store/topNav.d.ts +0 -445
  64. package/dist/store/topNav.d.ts.map +0 -1
  65. package/dist/store/topNav.js +0 -53
@@ -1,447 +1,469 @@
1
- import { activeRouterParams as U, PathId as b, fallbackMissingParams as X } from "../router.js";
2
- import { useModal as z } from "@scalar/components";
3
- import { createWorkspace as K } from "@scalar/oas-utils/entities/workspace";
4
- import { createCollection as Z } from "@scalar/oas-utils/entities/workspace/collection";
5
- import { createCookie as ee } from "@scalar/oas-utils/entities/workspace/cookie";
6
- import { createEnvironment as te } from "@scalar/oas-utils/entities/workspace/environment";
7
- import { createFolder as se } from "@scalar/oas-utils/entities/workspace/folder";
8
- import { createSecurityScheme as oe } from "@scalar/oas-utils/entities/workspace/security";
9
- import { createServer as ce } from "@scalar/oas-utils/entities/workspace/server";
10
- import { createRequest as ae, createRequestExample as ie, createRequestExampleParameter as le } from "@scalar/oas-utils/entities/workspace/spec";
11
- import { iterateTitle as re, fetchSpecFromUrl as de } from "@scalar/oas-utils/helpers";
12
- import { getRequestBodyFromOperation as ne } from "@scalar/oas-utils/spec-getters";
13
- import { importSpecToWorkspace as ue } from "@scalar/oas-utils/transforms";
14
- import { mutationFactory as f, LS_KEYS as h } from "@scalar/object-utils/mutator-record";
15
- import { reactive as i, computed as r, toRaw as me } from "vue";
16
- import { useSidebar as fe } from "../hooks/useSidebar.js";
17
- const { setCollapsedSidebarFolder: he } = fe();
18
- var B;
19
- const p = !!(typeof window < "u" && ((B = document == null ? void 0 : document.getElementById("scalar-client")) != null && B.getAttribute("data-persist"))), E = i({}), R = f(
20
- E,
21
- i({}),
22
- p && h.REQUEST
23
- ), I = (e, t, s) => {
24
- const o = ae(e), c = L(o, s);
25
- return o.childUids.push(c.uid), R.add(o), t && (a[t] ? m.edit(t, "childUids", [
26
- ...a[t].childUids,
27
- o.uid
28
- ]) : n[t] && y.edit(t, "childUids", [
29
- ...n[t].childUids,
30
- o.uid
31
- ])), o;
32
- }, pe = (e, t) => {
33
- e.childUids.forEach((s) => x.delete(s)), a[t] ? m.edit(
34
- t,
35
- "childUids",
36
- a[t].childUids.filter((s) => s !== e.uid)
37
- ) : n[t] && y.edit(
38
- t,
39
- "childUids",
40
- n[t].childUids.filter((s) => s !== e.uid)
41
- ), R.delete(e.uid);
42
- }, k = r(() => {
43
- var o, c;
44
- const e = U.value[b.Request], t = (c = (o = Y.value) == null ? void 0 : o[0]) == null ? void 0 : c.uid, s = E[e] ?? E[t];
45
- return X(b.Request, s), s && D(s.uid).forEach(
46
- (l) => he(l, !0)
47
- ), s;
48
- }), D = (e, t = []) => {
49
- const s = Object.values(a).find(
50
- (c) => c.childUids.includes(e)
51
- );
52
- if (s) return [...t, s.uid];
53
- const o = Object.values(n).find(
54
- ({ childUids: c }) => c.includes(e)
55
- );
56
- return o ? D(o.uid, [...t, o.uid]) : t;
57
- }, O = i({}), x = f(
58
- O,
59
- i({}),
60
- p && h.REQUEST_EXAMPLE
61
- ), q = (e) => {
62
- var t, s, o, c, l, u, d;
63
- return le({
64
- key: e.name,
65
- 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] : "",
66
- description: e.description,
67
- required: e.required,
68
- enabled: !!e.required,
69
- enum: (t = e.schema) == null ? void 0 : t.enum,
70
- type: (s = e.schema) == null ? void 0 : s.type,
71
- format: (o = e.schema) == null ? void 0 : o.format,
72
- minimum: (c = e.schema) == null ? void 0 : c.minimum,
73
- maximum: (l = e.schema) == null ? void 0 : l.maximum,
74
- default: (u = e.schema) == null ? void 0 : u.default,
75
- nullable: (d = e.schema) == null ? void 0 : d.nullable
76
- });
77
- }, L = (e, t, s) => {
78
- var d;
79
- const o = {
80
- path: Object.values(e.parameters.path).map(q),
81
- query: Object.values(e.parameters.query).map(q),
82
- headers: Object.values(e.parameters.headers).map(q),
83
- cookies: Object.values(e.parameters.cookies).map(q)
84
- }, c = {
85
- activeBody: "raw",
86
- raw: {
87
- encoding: "json",
88
- value: ""
89
- }
90
- };
91
- if (e.requestBody) {
92
- const v = ne({
93
- httpVerb: e.method,
94
- path: e.path,
95
- information: {
96
- requestBody: e.requestBody
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
- ((d = v == null ? void 0 : v.postData) == null ? void 0 : d.mimeType) === "application/json" && (o.headers.push({
100
- key: "Content-Type",
101
- value: "application/json",
102
- enabled: !0
103
- }), c.activeBody = "raw", c.raw.value = v.postData.text);
104
- }
105
- const l = s ?? re(
106
- (e.summary ?? "Example") + " #1",
107
- (v) => e.childUids.some((G) => v === O[G].name)
108
- ), u = ie({
109
- url: t != null && t.url ? `{{${t == null ? void 0 : t.url}}}${e.path}` : e.path,
110
- requestUid: e.uid,
111
- parameters: o,
112
- name: l,
113
- body: c
114
- });
115
- return x.add(u), u;
116
- }, ve = (e, t) => {
117
- const s = L(
118
- e,
119
- A.value[0],
120
- t
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
- }).filter((s) => s).flatMap(
172
- (s) => Object.entries(s).flatMap(([o, c]) => o !== "_scalarEnvId" ? [{ _scalarEnvId: s._scalarEnvId, key: o, value: c }] : [])
173
- );
174
- return [...e, ...t];
175
- }), _ = i({
176
- default: ee({
177
- uid: "default",
178
- name: "Cookie",
179
- value: "",
180
- domain: "",
181
- path: "/",
182
- secure: !1,
183
- httpOnly: !1,
184
- sameSite: "None"
185
- })
186
- }), Re = f(
187
- _,
188
- i({}),
189
- p && h.COOKIE
190
- ), be = r(
191
- () => U.value[b.Cookies]
192
- ), w = i({}), S = f(
193
- w,
194
- i({}),
195
- p && h.WORKSPACE
196
- ), ke = (e = {}) => {
197
- const t = K(e);
198
- S.add(t);
199
- const s = P(
200
- {
201
- spec: {
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
- t.uid
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
- ), V = (e) => E[e] ?? n[e].childUids.flatMap((t) => V(t)), Y = r(
234
- () => {
235
- var e;
236
- return (e = W.value) == null ? void 0 : e.flatMap(
237
- (t) => t.childUids.flatMap((s) => V(s))
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
- ), xe = r(() => {
241
- var e;
242
- return ((e = M.value) == null ? void 0 : e.isReadOnly) ?? !1;
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
- if (Object.values(a).length === 1) {
261
- console.warn("You must have at least one collection");
262
- return;
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
- S.edit(
265
- M.value.uid,
266
- "collectionUids",
267
- M.value.collectionUids.filter((c) => c !== e)
268
- ), m.delete(e);
269
- }
270
- }, C = r(() => {
271
- const e = Object.values(a)[0];
272
- if (!k.value) return e;
273
- const t = D(k.value.uid);
274
- if (!t.length) return null;
275
- const s = t[t.length - 1];
276
- return a[s] ?? e;
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
- y.add(s);
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 = C.value) == null ? void 0 : e.selectedSecuritySchemes.map((t) => {
319
- const s = T[t.uid], o = t.flowKey && "flows" in s && s.flows ? { flow: s.flows[t.flowKey] } : {};
320
- return { scheme: s, ...o };
321
- })[0];
322
- }
323
- ), Fe = r(
324
- () => {
325
- var e, t;
326
- return ((e = k.value) == null ? void 0 : e.security) ?? ((t = C.value) == null ? void 0 : t.spec.security) ?? [];
327
- }
328
- ), F = i({}), j = f(
329
- F,
330
- i({}),
331
- p && h.SERVER
332
- ), Q = (e, t) => {
333
- const s = ce(e);
334
- t && m.edit(t, "spec.serverUids", [
335
- ...a[t].spec.serverUids,
336
- s.uid
337
- ]), j.add(s);
338
- }, Ie = (e, t) => {
339
- m.edit(
340
- t,
341
- "spec.serverUids",
342
- a[t].spec.serverUids.filter(
343
- (s) => s !== e
344
- )
345
- ), j.delete(e);
346
- };
347
- async function $(e, t = "default", s = !0, o = !1) {
348
- var u;
349
- const c = me(e), l = await ue(c);
350
- s && S.add(
351
- K({ uid: t, isReadOnly: o })
352
- ), l.requests.forEach(
353
- (d) => I(d, void 0, l.servers[0])
354
- ), P(l.collection, t), l.folders.forEach((d) => H(d)), l.servers.forEach((d) => Q(d)), Object.entries(
355
- (((u = l.components) == null ? void 0 : u.securitySchemes) || l.securityDefinitions) ?? {}
356
- ).forEach(
357
- ([d, v]) => J.add(
358
- oe({ ...v, uid: d })
359
- )
360
- );
361
- }
362
- async function De(e, t, s = !1) {
363
- try {
364
- const o = await de(e, t);
365
- await $(o, void 0, void 0, s);
366
- } catch (o) {
367
- console.error("Failed to fetch spec from URL:", o);
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
- const ge = z(), Xe = () => ({
371
- // ---------------------------------------------------------------------------
372
- // STATE
373
- workspaces: w,
374
- collections: a,
375
- cookies: _,
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
- D as findRequestFolders,
446
- Xe as useWorkspace
467
+ ze as createWorkspaceStore,
468
+ Ze as useWorkspace
447
469
  };