@scalar/api-client 2.0.22 → 2.0.25

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