@scalar/api-client 2.0.24 → 2.0.26

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