@scalar/api-client 2.0.33 → 2.0.35

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