@scalar/api-client 2.5.32 → 2.5.34

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 (235) hide show
  1. package/CHANGELOG.md +39 -0
  2. package/dist/components/AddressBar/AddressBar.vue.js +1 -1
  3. package/dist/components/AddressBar/AddressBar.vue2.js +120 -128
  4. package/dist/components/AddressBar/AddressBarHistory.vue.js +1 -1
  5. package/dist/components/AddressBar/AddressBarHistory.vue2.js +57 -63
  6. package/dist/components/CodeInput/CodeInput.vue.js +2 -2
  7. package/dist/components/CodeInput/CodeInput.vue2.js +143 -150
  8. package/dist/components/CodeInput/codeVariableWidget.js +70 -75
  9. package/dist/components/CommandPalette/CommandActionInput.vue.js +17 -19
  10. package/dist/components/CommandPalette/CommandPaletteCollection.vue.js +26 -27
  11. package/dist/components/CommandPalette/CommandPaletteExample.vue.js +53 -55
  12. package/dist/components/CommandPalette/CommandPaletteImport.vue.js +129 -133
  13. package/dist/components/CommandPalette/CommandPaletteImportCurl.vue.js +1 -1
  14. package/dist/components/CommandPalette/CommandPaletteImportCurl.vue2.js +84 -98
  15. package/dist/components/CommandPalette/CommandPaletteServer.vue.js +64 -74
  16. package/dist/components/CommandPalette/CommandPaletteTag.vue.js +5 -11
  17. package/dist/components/CommandPalette/TheCommandPalette.vue.js +1 -1
  18. package/dist/components/CommandPalette/TheCommandPalette.vue2.js +164 -183
  19. package/dist/components/DataTable/DataTableInput.vue.d.ts.map +1 -1
  20. package/dist/components/DataTable/DataTableInput.vue.js +4 -4
  21. package/dist/components/DataTable/DataTableInput.vue2.js +31 -31
  22. package/dist/components/DataTable/DataTableInputSelect.vue.js +1 -2
  23. package/dist/components/EmptyState.vue.js +1 -1
  24. package/dist/components/EnvironmentSelector/EnvironmentSelector.vue.js +75 -84
  25. package/dist/components/Form/LabelInput.vue.js +1 -1
  26. package/dist/components/HttpMethod/HttpMethod.vue.js +1 -1
  27. package/dist/components/HttpMethod/HttpMethod.vue2.js +11 -11
  28. package/dist/components/ImportCollection/DropEventListener.vue.js +42 -44
  29. package/dist/components/ImportCollection/ImportCollectionListener.vue.js +22 -23
  30. package/dist/components/ImportCollection/ImportCollectionModal.vue.js +141 -149
  31. package/dist/components/ImportCollection/ImportCollectionModal.vue3.js +1 -1
  32. package/dist/components/ImportCollection/ImportNowButton.vue.js +22 -23
  33. package/dist/components/ImportCollection/IntegrationLogo.vue.js +12 -13
  34. package/dist/components/ImportCollection/PasteEventListener.vue.js +11 -12
  35. package/dist/components/ImportCollection/WorkspaceSelector.vue.js +69 -76
  36. package/dist/components/ImportCollection/utils/get-openapi-version.js +8 -8
  37. package/dist/components/ImportCollection/utils/import-collection.js +14 -14
  38. package/dist/components/OpenApiClientButton.vue.js +1 -1
  39. package/dist/components/OpenApiClientButton.vue2.js +10 -10
  40. package/dist/components/ScalarAsciiArt.vue.js +1 -1
  41. package/dist/components/ScalarAsciiArt.vue2.js +19 -22
  42. package/dist/components/Search/useSearch.js +51 -61
  43. package/dist/components/SectionFilter.vue.js +1 -1
  44. package/dist/components/SectionFilter.vue2.js +26 -29
  45. package/dist/components/Server/ServerDropdown.vue.js +70 -96
  46. package/dist/components/Server/ServerDropdownItem.vue.js +1 -1
  47. package/dist/components/Server/ServerDropdownItem.vue2.js +57 -67
  48. package/dist/components/Server/ServerSelector.vue.js +44 -55
  49. package/dist/components/Server/ServerVariablesForm.vue.js +36 -42
  50. package/dist/components/Server/ServerVariablesSelect.vue.js +6 -6
  51. package/dist/components/SideNav/DownloadAppButton.vue.js +1 -1
  52. package/dist/components/SideNav/SideNav.vue.js +68 -74
  53. package/dist/components/Sidebar/Actions/SidebarListElementForm.vue.js +1 -1
  54. package/dist/components/Sidebar/Sidebar.vue.js +1 -1
  55. package/dist/components/Sidebar/SidebarListElement.vue.js +2 -2
  56. package/dist/components/TopNav/TopNav.vue.js +107 -122
  57. package/dist/components/TopNav/TopNavItem.vue.js +1 -1
  58. package/dist/hooks/useFileDialog.js +12 -12
  59. package/dist/hooks/useResponseBody.js +14 -16
  60. package/dist/index.d.ts +1 -1
  61. package/dist/index.js +2 -2
  62. package/dist/layouts/App/ApiClientApp.vue.js +50 -56
  63. package/dist/layouts/App/ApiClientApp.vue3.js +1 -1
  64. package/dist/layouts/App/create-api-client-app.js +19 -20
  65. package/dist/layouts/App/index.js +1 -1
  66. package/dist/layouts/Modal/ApiClientModal.vue.js +1 -1
  67. package/dist/layouts/Modal/ApiClientModal.vue2.js +18 -21
  68. package/dist/layouts/Web/ApiClientWeb.vue.js +45 -51
  69. package/dist/layouts/Web/ApiClientWeb.vue3.js +1 -1
  70. package/dist/layouts/Web/create-api-client-web.js +19 -20
  71. package/dist/layouts/Web/index.js +1 -1
  72. package/dist/libs/create-client.js +102 -109
  73. package/dist/libs/env-helpers.js +3 -3
  74. package/dist/libs/event-bus.js +15 -15
  75. package/dist/libs/extractAttachmentFilename.js +5 -6
  76. package/dist/libs/find-request.js +9 -10
  77. package/dist/libs/get-request-uid-by-path-method.js +12 -12
  78. package/dist/libs/getOpenApiDocumentDetails.js +7 -7
  79. package/dist/libs/importers/curl.js +3 -3
  80. package/dist/libs/normalize-headers.js +9 -10
  81. package/dist/libs/postman.js +15 -17
  82. package/dist/libs/send-request/build-request-security.js +9 -10
  83. package/dist/libs/send-request/create-fetch-body.js +11 -12
  84. package/dist/libs/send-request/create-fetch-query-params.js +13 -13
  85. package/dist/libs/send-request/create-request-operation.js +83 -84
  86. package/dist/libs/send-request/decode-buffer.d.ts.map +1 -1
  87. package/dist/libs/send-request/set-request-cookies.js +12 -12
  88. package/dist/libs/string-template.js +21 -21
  89. package/dist/libs/validate-parameters.js +5 -8
  90. package/dist/plugins/plugin-manager.js +11 -17
  91. package/dist/store/active-entities.js +90 -117
  92. package/dist/store/collections.js +41 -42
  93. package/dist/store/import-spec.js +25 -26
  94. package/dist/store/request-example.js +20 -24
  95. package/dist/store/requests.js +63 -81
  96. package/dist/store/router-params.js +7 -7
  97. package/dist/store/security-schemes.js +35 -36
  98. package/dist/store/store.js +2 -2
  99. package/dist/store/tags.js +20 -21
  100. package/dist/style.css +1 -1
  101. package/dist/views/Collection/Collection.vue2.js +21 -22
  102. package/dist/views/Collection/CollectionAuthentication.vue.js +1 -1
  103. package/dist/views/Collection/CollectionAuthentication.vue2.js +43 -47
  104. package/dist/views/Collection/CollectionEnvironment.vue.js +1 -1
  105. package/dist/views/Collection/CollectionEnvironment.vue2.js +196 -207
  106. package/dist/views/Collection/CollectionInfoForm.vue.js +1 -1
  107. package/dist/views/Collection/CollectionInfoForm.vue2.js +34 -41
  108. package/dist/views/Collection/CollectionNavigation.vue.js +116 -125
  109. package/dist/views/Collection/CollectionOverview.vue2.js +22 -25
  110. package/dist/views/Collection/CollectionServerForm.vue.js +39 -45
  111. package/dist/views/Collection/CollectionServers.vue2.js +88 -98
  112. package/dist/views/Collection/CollectionSettings.vue.js +1 -1
  113. package/dist/views/Collection/CollectionSettings.vue2.js +101 -108
  114. package/dist/views/Collection/components/EnvironmentForm.vue.js +1 -1
  115. package/dist/views/Collection/components/EnvironmentForm.vue2.js +141 -145
  116. package/dist/views/Collection/components/MarkdownInput.vue.js +1 -1
  117. package/dist/views/Collection/components/MarkdownInput.vue2.js +1 -2
  118. package/dist/views/Components/CodeSnippet/CodeSnippet.vue.js +15 -15
  119. package/dist/views/Components/CodeSnippet/helpers/convert-to-har-request.js +15 -16
  120. package/dist/views/Components/CodeSnippet/helpers/get-har-request.js +61 -64
  121. package/dist/views/Components/CodeSnippet/helpers/get-snippet.js +9 -10
  122. package/dist/views/Cookies/CookieModal.vue.js +1 -1
  123. package/dist/views/Cookies/Cookies.vue2.js +90 -93
  124. package/dist/views/Environment/Environment.vue2.js +267 -295
  125. package/dist/views/Environment/EnvironmentModal.vue.js +63 -70
  126. package/dist/views/Environment/EnvironmentVariableDropdown.vue.js +38 -42
  127. package/dist/views/Request/Request.vue.js +1 -1
  128. package/dist/views/Request/Request.vue2.js +60 -67
  129. package/dist/views/Request/RequestRoot.vue.js +1 -1
  130. package/dist/views/Request/RequestRoot.vue2.js +78 -89
  131. package/dist/views/Request/RequestSection/RequestAuth/DeleteRequestAuthModal.vue.js +37 -44
  132. package/dist/views/Request/RequestSection/RequestAuth/OAuth2.vue.js +44 -45
  133. package/dist/views/Request/RequestSection/RequestAuth/OAuthScopesInput.vue.js +111 -127
  134. package/dist/views/Request/RequestSection/RequestAuth/RequestAuth.vue.js +1 -1
  135. package/dist/views/Request/RequestSection/RequestAuth/RequestAuth.vue2.js +120 -139
  136. package/dist/views/Request/RequestSection/RequestAuth/RequestAuthDataTable.vue.js +1 -1
  137. package/dist/views/Request/RequestSection/RequestAuth/RequestAuthTab.vue.js +97 -97
  138. package/dist/views/Request/RequestSection/RequestBody.vue.js +1 -1
  139. package/dist/views/Request/RequestSection/RequestBody.vue2.js +287 -310
  140. package/dist/views/Request/RequestSection/RequestCodeExample.vue.js +1 -1
  141. package/dist/views/Request/RequestSection/RequestCodeExample.vue2.js +86 -94
  142. package/dist/views/Request/RequestSection/RequestParams.vue.js +37 -38
  143. package/dist/views/Request/RequestSection/RequestPathParams.vue.js +36 -38
  144. package/dist/views/Request/RequestSection/RequestSection.vue.js +1 -1
  145. package/dist/views/Request/RequestSection/RequestSection.vue2.js +28 -31
  146. package/dist/views/Request/RequestSection/RequestTable.vue.js +1 -1
  147. package/dist/views/Request/RequestSection/RequestTable.vue2.js +49 -52
  148. package/dist/views/Request/RequestSection/RequestTableTooltip.vue.js +1 -1
  149. package/dist/views/Request/RequestSection/helpers/filter-security-requirements.js +16 -16
  150. package/dist/views/Request/RequestSection/helpers/getting-started.js +7 -11
  151. package/dist/views/Request/RequestSection/helpers/update-scheme.js +7 -8
  152. package/dist/views/Request/RequestSidebar.vue.js +1 -1
  153. package/dist/views/Request/RequestSidebar.vue2.js +199 -211
  154. package/dist/views/Request/RequestSidebarItem.vue.js +2 -2
  155. package/dist/views/Request/RequestSidebarItem.vue2.js +332 -349
  156. package/dist/views/Request/RequestSidebarItemMenu.vue.js +1 -1
  157. package/dist/views/Request/RequestSidebarItemMenu.vue2.js +210 -240
  158. package/dist/views/Request/RequestSubpageHeader.vue.js +1 -1
  159. package/dist/views/Request/ResponseSection/RequestHeaders.vue.js +38 -41
  160. package/dist/views/Request/ResponseSection/ResponseBody.vue.js +1 -1
  161. package/dist/views/Request/ResponseSection/ResponseBody.vue2.js +58 -64
  162. package/dist/views/Request/ResponseSection/ResponseBodyDownload.vue.js +1 -2
  163. package/dist/views/Request/ResponseSection/ResponseBodyPreview.vue.js +1 -1
  164. package/dist/views/Request/ResponseSection/ResponseBodyRaw.vue.js +1 -1
  165. package/dist/views/Request/ResponseSection/ResponseBodyRaw.vue2.js +20 -23
  166. package/dist/views/Request/ResponseSection/ResponseBodyVirtual.vue3.js +1 -1
  167. package/dist/views/Request/ResponseSection/ResponseEmpty.vue.js +1 -1
  168. package/dist/views/Request/ResponseSection/ResponseEmpty.vue2.js +29 -30
  169. package/dist/views/Request/ResponseSection/ResponseHeaders.vue.js +38 -41
  170. package/dist/views/Request/ResponseSection/ResponseLoadingOverlay.vue.js +3 -3
  171. package/dist/views/Request/ResponseSection/ResponseMetaInformation.vue.js +28 -29
  172. package/dist/views/Request/ResponseSection/ResponseSection.vue.js +1 -1
  173. package/dist/views/Request/ResponseSection/ResponseSection.vue2.js +128 -140
  174. package/dist/views/Request/components/WorkspaceDropdown.vue.js +116 -124
  175. package/dist/views/Request/consts/mediaTypes.js +2 -3
  176. package/dist/views/Request/handle-drag.js +24 -28
  177. package/dist/views/Request/hooks/useOpenApiWatcher.js +26 -33
  178. package/dist/views/Request/libs/auth.js +37 -43
  179. package/dist/views/Request/libs/oauth2.js +30 -32
  180. package/dist/views/Request/libs/watch-mode.js +100 -103
  181. package/dist/views/Settings/SettingsGeneral.vue.js +206 -236
  182. package/package.json +22 -22
  183. package/dist/components/AddressBar/AddressBar.vue3.js +0 -4
  184. package/dist/components/AddressBar/AddressBarHistory.vue3.js +0 -4
  185. package/dist/components/CodeInput/CodeInput.vue3.js +0 -4
  186. package/dist/components/CodeInput/CodeInput.vue4.js +0 -4
  187. package/dist/components/CommandPalette/CommandPaletteImportCurl.vue3.js +0 -4
  188. package/dist/components/CommandPalette/TheCommandPalette.vue3.js +0 -4
  189. package/dist/components/DataTable/DataTableInput.vue3.js +0 -4
  190. package/dist/components/EmptyState.vue3.js +0 -4
  191. package/dist/components/Form/LabelInput.vue3.js +0 -4
  192. package/dist/components/HttpMethod/HttpMethod.vue3.js +0 -4
  193. package/dist/components/ImportCollection/ImportCollectionModal.vue2.js +0 -4
  194. package/dist/components/OpenApiClientButton.vue3.js +0 -4
  195. package/dist/components/ScalarAsciiArt.vue3.js +0 -4
  196. package/dist/components/SectionFilter.vue3.js +0 -4
  197. package/dist/components/Server/ServerDropdownItem.vue3.js +0 -4
  198. package/dist/components/SideNav/DownloadAppButton.vue3.js +0 -4
  199. package/dist/components/Sidebar/Actions/SidebarListElementForm.vue3.js +0 -4
  200. package/dist/components/Sidebar/Sidebar.vue3.js +0 -4
  201. package/dist/components/Sidebar/SidebarListElement.vue3.js +0 -4
  202. package/dist/components/Sidebar/SidebarListElement.vue4.js +0 -4
  203. package/dist/components/TopNav/TopNavItem.vue3.js +0 -4
  204. package/dist/layouts/App/ApiClientApp.vue2.js +0 -4
  205. package/dist/layouts/Modal/ApiClientModal.vue3.js +0 -4
  206. package/dist/layouts/Web/ApiClientWeb.vue2.js +0 -4
  207. package/dist/style.css.js +0 -4
  208. package/dist/views/Collection/CollectionAuthentication.vue3.js +0 -4
  209. package/dist/views/Collection/CollectionEnvironment.vue3.js +0 -4
  210. package/dist/views/Collection/CollectionInfoForm.vue3.js +0 -4
  211. package/dist/views/Collection/CollectionSettings.vue3.js +0 -4
  212. package/dist/views/Collection/components/EnvironmentForm.vue3.js +0 -4
  213. package/dist/views/Collection/components/MarkdownInput.vue3.js +0 -4
  214. package/dist/views/Cookies/CookieModal.vue3.js +0 -4
  215. package/dist/views/Request/Request.vue3.js +0 -4
  216. package/dist/views/Request/RequestRoot.vue3.js +0 -4
  217. package/dist/views/Request/RequestSection/RequestAuth/RequestAuth.vue3.js +0 -4
  218. package/dist/views/Request/RequestSection/RequestAuth/RequestAuthDataTable.vue3.js +0 -4
  219. package/dist/views/Request/RequestSection/RequestBody.vue3.js +0 -4
  220. package/dist/views/Request/RequestSection/RequestCodeExample.vue3.js +0 -4
  221. package/dist/views/Request/RequestSection/RequestSection.vue3.js +0 -4
  222. package/dist/views/Request/RequestSection/RequestTable.vue3.js +0 -4
  223. package/dist/views/Request/RequestSection/RequestTableTooltip.vue3.js +0 -4
  224. package/dist/views/Request/RequestSidebar.vue3.js +0 -4
  225. package/dist/views/Request/RequestSidebarItem.vue3.js +0 -4
  226. package/dist/views/Request/RequestSidebarItem.vue4.js +0 -4
  227. package/dist/views/Request/RequestSidebarItemMenu.vue3.js +0 -4
  228. package/dist/views/Request/RequestSubpageHeader.vue3.js +0 -4
  229. package/dist/views/Request/ResponseSection/ResponseBody.vue3.js +0 -4
  230. package/dist/views/Request/ResponseSection/ResponseBodyPreview.vue3.js +0 -4
  231. package/dist/views/Request/ResponseSection/ResponseBodyRaw.vue3.js +0 -4
  232. package/dist/views/Request/ResponseSection/ResponseBodyVirtual.vue2.js +0 -4
  233. package/dist/views/Request/ResponseSection/ResponseEmpty.vue3.js +0 -4
  234. package/dist/views/Request/ResponseSection/ResponseLoadingOverlay.vue3.js +0 -4
  235. package/dist/views/Request/ResponseSection/ResponseSection.vue3.js +0 -4
@@ -1,46 +1,42 @@
1
- import { useLayout as I } from "../../hooks/useLayout.js";
2
- function F(f, { collections: l, collectionMutators: a, tags: o, tagMutators: p, workspaceMutators: x }) {
3
- const { layout: b } = I(), y = (i, r) => {
4
- i.type === "collection" ? a.edit(i.uid, "children", r) : i.type === "tag" && p.edit(i.uid, "children", r);
1
+ import { useLayout as v } from "../../hooks/useLayout.js";
2
+ function I(f, { collections: n, collectionMutators: a, tags: o, tagMutators: p, workspaceMutators: x }) {
3
+ const { layout: D } = v(), y = (i, d) => {
4
+ i.type === "collection" ? a.edit(i.uid, "children", d) : i.type === "tag" && p.edit(i.uid, "children", d);
5
5
  };
6
6
  return {
7
- handleDragEnd: (i, r) => {
8
- var D, U, v, C;
9
- if (!i || !r)
7
+ handleDragEnd: (i, d) => {
8
+ if (!i || !d)
10
9
  return;
11
- const { id: n, parentId: d } = i, { id: u, parentId: s, offset: c } = r;
12
- if (d ? l[d] ? a.edit(
13
- d,
10
+ const { id: l, parentId: r } = i, { id: u, parentId: s, offset: c } = d;
11
+ if (r ? n[r] ? a.edit(
12
+ r,
14
13
  "children",
15
- l[d].children.filter((e) => e !== n)
16
- ) : o[d] && p.edit(
17
- d,
14
+ n[r].children.filter((e) => e !== l)
15
+ ) : o[r] && p.edit(
16
+ r,
18
17
  "children",
19
- o[d].children.filter((e) => e !== n)
18
+ o[r].children.filter((e) => e !== l)
20
19
  ) : x.edit(
21
- (D = f.value) == null ? void 0 : D.uid,
20
+ f.value?.uid,
22
21
  "collections",
23
- ((U = f.value) == null ? void 0 : U.collections.filter((e) => e !== n)) ?? []
22
+ f.value?.collections.filter((e) => e !== l) ?? []
24
23
  ), c === 2) {
25
- const e = l[u] || o[u];
26
- e && y(e, [...e.children ?? [], n]);
24
+ const e = n[u] || o[u];
25
+ e && y(e, [...e.children ?? [], l]);
27
26
  } else if (s) {
28
- const e = l[s] || o[s];
27
+ const e = n[s] || o[s];
29
28
  if (!e)
30
29
  return;
31
- const t = [...e.children ?? []], h = t.findIndex((E) => u === E) ?? 0;
32
- t.splice(h + c, 0, n), y(e, t);
30
+ const t = [...e.children ?? []], h = t.findIndex((U) => u === U) ?? 0;
31
+ t.splice(h + c, 0, l), y(e, t);
33
32
  } else {
34
- const e = [...((v = f.value) == null ? void 0 : v.collections) ?? []], t = e.findIndex((h) => u === h) ?? 0;
35
- e.splice(t + c, 0, n), x.edit((C = f.value) == null ? void 0 : C.uid, "collections", e);
33
+ const e = [...f.value?.collections ?? []], t = e.findIndex((h) => u === h) ?? 0;
34
+ e.splice(t + c, 0, l), x.edit(f.value?.uid, "collections", e);
36
35
  }
37
36
  },
38
- isDroppable: (i, r) => {
39
- var n, d;
40
- return !(b === "modal" || !l[i.id] && r.offset !== 2 || l[i.id] && ((d = (n = l[r.id]) == null ? void 0 : n.info) == null ? void 0 : d.title) === "Drafts");
41
- }
37
+ isDroppable: (i, d) => !(D === "modal" || !n[i.id] && d.offset !== 2 || n[i.id] && n[d.id]?.info?.title === "Drafts")
42
38
  };
43
39
  }
44
40
  export {
45
- F as dragHandlerFactory
41
+ I as dragHandlerFactory
46
42
  };
@@ -1,39 +1,38 @@
1
- import { useActiveEntities as d } from "../../../store/active-entities.js";
1
+ import { useActiveEntities as A } from "../../../store/active-entities.js";
2
2
  import { specDictionary as f } from "../../../store/import-spec.js";
3
- import { combineRenameDiffs as D, mutateCollectionDiff as R, mutateSecuritySchemeDiff as g, mutateServerDiff as S, mutateTagDiff as T, mutateRequestDiff as M } from "../libs/watch-mode.js";
4
- import { fetchDocument as I, createHash as C } from "@scalar/oas-utils/helpers";
5
- import { parseSchema as O } from "@scalar/oas-utils/transforms";
6
- import { useToasts as L } from "@scalar/use-toasts";
7
- import { useTimeoutPoll as N } from "@vueuse/core";
8
- import U from "microdiff";
9
- import { watch as b } from "vue";
10
- import { useWorkspace as P } from "../../../store/store.js";
11
- const k = 5 * 1e3, q = 60 * 1e3, J = () => {
12
- const { toast: h } = L(), c = d(), o = P(), { activeCollection: s, activeWorkspace: W } = c, { collectionMutators: n } = o, i = (e) => h(`[useOpenApiWatcher] Changes to the ${e} were not applied`, "error"), w = (e) => {
13
- e.path[0] === "info" || e.path[0] === "security" ? R(e, c, o) || i("collection") : e.path[0] === "components" && e.path[1] === "securitySchemes" ? g(e, c, o) || i("securitySchemes") : e.path[0] === "servers" ? S(e, c, o) || i("servers") : e.path[0] === "tags" ? T(e, c, o) || i("tags") : e.path[0] === "paths" && (M(e, c, o) || i("requests"));
14
- }, { pause: p, resume: m } = N(async () => {
15
- var l, v;
16
- const e = (l = s.value) == null ? void 0 : l.documentUrl;
3
+ import { combineRenameDiffs as y, mutateCollectionDiff as E, mutateSecuritySchemeDiff as D, mutateServerDiff as R, mutateTagDiff as g, mutateRequestDiff as S } from "../libs/watch-mode.js";
4
+ import { fetchDocument as T, createHash as M } from "@scalar/oas-utils/helpers";
5
+ import { parseSchema as l } from "@scalar/oas-utils/transforms";
6
+ import { useToasts as I } from "@scalar/use-toasts";
7
+ import { useTimeoutPoll as C } from "@vueuse/core";
8
+ import L from "microdiff";
9
+ import { watch as N } from "vue";
10
+ import { useWorkspace as U } from "../../../store/store.js";
11
+ const b = 5 * 1e3, P = 60 * 1e3, B = () => {
12
+ const { toast: h } = I(), c = A(), o = U(), { activeCollection: s, activeWorkspace: v } = c, { collectionMutators: n } = o, i = (e) => h(`[useOpenApiWatcher] Changes to the ${e} were not applied`, "error"), O = (e) => {
13
+ e.path[0] === "info" || e.path[0] === "security" ? E(e, c, o) || i("collection") : e.path[0] === "components" && e.path[1] === "securitySchemes" ? D(e, c, o) || i("securitySchemes") : e.path[0] === "servers" ? R(e, c, o) || i("servers") : e.path[0] === "tags" ? g(e, c, o) || i("tags") : e.path[0] === "paths" && (S(e, c, o) || i("requests"));
14
+ }, { pause: p, resume: m } = C(async () => {
15
+ const e = s.value?.documentUrl;
17
16
  if (!e)
18
17
  return;
19
18
  const t = f[e];
20
19
  try {
21
- const a = await I(e, (v = W.value) == null ? void 0 : v.proxyUrl, void 0, !1), u = C(a);
22
- if (n.edit(s.value.uid, "watchModeStatus", "WATCHING"), t != null && t.hash)
20
+ const a = await T(e, v.value?.proxyUrl, void 0, !1), u = M(a);
21
+ if (n.edit(s.value.uid, "watchModeStatus", "WATCHING"), t?.hash)
23
22
  if (t.hash && t.hash !== u) {
24
- const { schema: r } = await O(a), A = U(t.schema, r), y = D(A);
23
+ const { schema: r } = await l(a), W = L(t.schema, r), d = y(W);
25
24
  try {
26
- y.forEach(w), f[e] = {
25
+ d.forEach(O), f[e] = {
27
26
  hash: u,
28
27
  schema: r
29
28
  };
30
- } catch (E) {
31
- console.error("[useOpenApiWatcher] Error:", E);
29
+ } catch (w) {
30
+ console.error("[useOpenApiWatcher] Error:", w);
32
31
  }
33
32
  } else
34
33
  console.log("[useOpenApiWatcher] No changes detected yet…");
35
34
  else {
36
- const { schema: r } = await O(a);
35
+ const { schema: r } = await l(a);
37
36
  r && (f[e] = {
38
37
  hash: u,
39
38
  schema: r
@@ -42,17 +41,11 @@ const k = 5 * 1e3, q = 60 * 1e3, J = () => {
42
41
  } catch (a) {
43
42
  console.error("[useOpenApiWatcher] Error:", a), console.info("[useOpenApiWatcher] Pausing watcher for 60 seconds"), p(), n.edit(s.value.uid, "watchModeStatus", "ERROR"), h("[useOpenApiWatcher] Unable to fetch the spec file, paused the watcher for 60 seconds", "error"), setTimeout(() => {
44
43
  console.info("[useOpenApiWatcher] Resuming watcher"), m();
45
- }, q);
44
+ }, P);
46
45
  }
47
- }, k);
48
- b(
49
- [() => {
50
- var e;
51
- return (e = s.value) == null ? void 0 : e.documentUrl;
52
- }, () => {
53
- var e;
54
- return (e = s.value) == null ? void 0 : e.watchMode;
55
- }],
46
+ }, b);
47
+ N(
48
+ [() => s.value?.documentUrl, () => s.value?.watchMode],
56
49
  ([e, t]) => {
57
50
  e && t ? (console.info(`[useOpenApiWatcher] Watching ${e} …`), m()) : s.value && (p(), n.edit(s.value.uid, "watchModeStatus", "IDLE"));
58
51
  },
@@ -60,5 +53,5 @@ const k = 5 * 1e3, q = 60 * 1e3, J = () => {
60
53
  );
61
54
  };
62
55
  export {
63
- J as useOpenApiWatcher
56
+ B as useOpenApiWatcher
64
57
  };
@@ -1,58 +1,52 @@
1
- import { isDefined as p } from "@scalar/oas-utils/helpers";
2
- import { ADD_AUTH_OPTIONS as O } from "../consts/new-auth-options.js";
3
- const d = (t) => ({
4
- id: t.uid,
5
- label: t.type === "openIdConnect" ? `${t.nameKey} (coming soon)` : t.nameKey
6
- }), b = (t, e) => d(
7
- t.reduce(
8
- (r, a, i) => {
9
- const m = e[a];
10
- return m && (r.nameKey += `${i > 0 ? " & " : ""}${m.nameKey}`, r.uid = `${r.uid}${i > 0 ? "," : ""}${m.uid}`), r;
1
+ import { isDefined as l } from "@scalar/oas-utils/helpers";
2
+ import { ADD_AUTH_OPTIONS as p } from "../consts/new-auth-options.js";
3
+ const c = (e) => ({
4
+ id: e.uid,
5
+ label: e.type === "openIdConnect" ? `${e.nameKey} (coming soon)` : e.nameKey
6
+ }), y = (e, n) => c(
7
+ e.reduce(
8
+ (i, u, a) => {
9
+ const s = n[u];
10
+ return s && (i.nameKey += `${a > 0 ? " & " : ""}${s.nameKey}`, i.uid = `${i.uid}${a > 0 ? "," : ""}${s.uid}`), i;
11
11
  },
12
12
  { type: "complex", nameKey: "", uid: "" }
13
13
  )
14
- ), A = (t, e) => {
15
- var r;
16
- return JSON.stringify(t == null ? void 0 : t.security) === "[{}]" && ((r = e == null ? void 0 : e.security) != null && r.length) ? !!(e != null && e.security.find((i) => JSON.stringify(i) === "{}")) ? e.security : [...e.security, {}] : (t == null ? void 0 : t.security) ?? (e == null ? void 0 : e.security) ?? [];
17
- }, D = (t, e, r, a = !1) => {
14
+ ), O = (e, n) => JSON.stringify(e?.security) === "[{}]" && n?.security?.length ? !!n?.security.find((u) => JSON.stringify(u) === "{}") ? n.security : [...n.security, {}] : e?.security ?? n?.security ?? [], b = (e, n, i, u = !1) => {
18
15
  {
19
- const i = e.reduce(
20
- (n, s) => {
21
- const u = r[s];
22
- return u && (n[u.nameKey] = u), n;
16
+ const a = n.reduce(
17
+ (r, t) => {
18
+ const o = i[t];
19
+ return o && (r[o.nameKey] = o), r;
23
20
  },
24
21
  {}
25
- ), m = t.flatMap((n) => {
26
- const s = Object.keys(n);
27
- if (s.length > 1) {
28
- const u = s.map((g) => {
29
- var h;
30
- return (h = i[g]) == null ? void 0 : h.uid;
31
- }).filter(p);
32
- return b(u, r);
22
+ ), s = e.flatMap((r) => {
23
+ const t = Object.keys(r);
24
+ if (t.length > 1) {
25
+ const o = t.map((d) => a[d]?.uid).filter(l);
26
+ return y(o, i);
33
27
  }
34
- if (s[0]) {
35
- const u = i[s[0]];
36
- if (u)
37
- return d(u);
28
+ if (t[0]) {
29
+ const o = a[t[0]];
30
+ if (o)
31
+ return c(o);
38
32
  }
39
33
  return [];
40
- }), y = e.filter((n) => !m.some((s) => s.id === n)).map((n) => {
41
- const s = r[n];
42
- return s ? d(s) : null;
43
- }).filter(p), f = [
44
- { label: "Required authentication", options: m },
45
- { label: "Available authentication", options: y }
34
+ }), f = n.filter((r) => !s.some((t) => t.id === r)).map((r) => {
35
+ const t = i[r];
36
+ return t ? c(t) : null;
37
+ }).filter(l), m = [
38
+ { label: "Required authentication", options: s },
39
+ { label: "Available authentication", options: f }
46
40
  ];
47
- return a ? m.length ? f : y : (f.push({
41
+ return u ? s.length ? m : f : (m.push({
48
42
  label: "Add new authentication",
49
- options: O
50
- }), f);
43
+ options: p
44
+ }), m);
51
45
  }
52
46
  };
53
47
  export {
54
- b as formatComplexScheme,
55
- d as formatScheme,
56
- D as getSchemeOptions,
57
- A as getSecurityRequirements
48
+ y as formatComplexScheme,
49
+ c as formatScheme,
50
+ b as getSchemeOptions,
51
+ O as getSecurityRequirements
58
52
  };
@@ -1,28 +1,28 @@
1
- import { shouldUseProxy as k } from "@scalar/oas-utils/helpers";
2
- import { fromUint8Array as S, encode as U } from "js-base64";
3
- const w = () => {
1
+ import { shouldUseProxy as S } from "@scalar/oas-utils/helpers";
2
+ import { fromUint8Array as P, encode as k } from "js-base64";
3
+ const U = () => {
4
4
  const e = new Uint8Array(32);
5
- return crypto.getRandomValues(e), S(e, !0);
6
- }, A = async (e, l) => {
5
+ return crypto.getRandomValues(e), P(e, !0);
6
+ }, w = async (e, l) => {
7
7
  if (l === "plain")
8
8
  return e;
9
- const n = new TextEncoder().encode(e), i = await crypto.subtle.digest("SHA-256", n);
10
- return S(new Uint8Array(i), !0);
11
- }, b = async (e, l, u) => {
9
+ const n = new TextEncoder().encode(e), c = await crypto.subtle.digest("SHA-256", n);
10
+ return P(new Uint8Array(c), !0);
11
+ }, C = async (e, l, u) => {
12
12
  try {
13
13
  if (!e)
14
14
  return [new Error("Flow not found"), null];
15
15
  const n = e.selectedScopes.join(" ");
16
16
  if (e.type === "clientCredentials" || e.type === "password")
17
- return P(e, n, {
17
+ return x(e, n, {
18
18
  proxyUrl: u
19
19
  });
20
- const i = (Math.random() + 1).toString(36).substring(2, 10), t = new URL(e.authorizationUrl);
20
+ const c = (Math.random() + 1).toString(36).substring(2, 10), t = new URL(e.authorizationUrl);
21
21
  let m = null;
22
22
  if (e.type === "implicit")
23
23
  t.searchParams.set("response_type", "token");
24
24
  else if (e.type === "authorizationCode" && (t.searchParams.set("response_type", "code"), e["x-usePkce"] !== "no")) {
25
- const r = w(), s = await A(r, e["x-usePkce"]);
25
+ const r = U(), s = await w(r, e["x-usePkce"]);
26
26
  m = {
27
27
  codeVerifier: r,
28
28
  codeChallenge: s,
@@ -35,29 +35,27 @@ const w = () => {
35
35
  } else
36
36
  t.searchParams.set("redirect_uri", e["x-scalar-redirect-uri"]);
37
37
  e["x-scalar-security-query"] && Object.keys(e["x-scalar-security-query"]).forEach((r) => {
38
- var c;
39
- const s = (c = e["x-scalar-security-query"]) == null ? void 0 : c[r];
38
+ const s = e["x-scalar-security-query"]?.[r];
40
39
  s && t.searchParams.set(r, s);
41
- }), t.searchParams.set("client_id", e["x-scalar-client-id"]), t.searchParams.set("state", i), n && t.searchParams.set("scope", n);
40
+ }), t.searchParams.set("client_id", e["x-scalar-client-id"]), t.searchParams.set("state", c), n && t.searchParams.set("scope", n);
42
41
  const a = window.open(t, "openAuth2Window", "left=100,top=100,width=800,height=600");
43
42
  return a ? new Promise((r) => {
44
43
  const s = setInterval(() => {
45
- var _;
46
- let c = null, d = null, h = null, y = null;
44
+ let o = null, d = null, h = null, y = null;
47
45
  try {
48
- const o = new URL(a.location.href).searchParams, x = e["x-tokenName"] || "access_token";
49
- c = o.get(x), d = o.get("code"), h = o.get("error"), y = o.get("error_description");
46
+ const i = new URL(a.location.href).searchParams, _ = e["x-tokenName"] || "access_token";
47
+ o = i.get(_), d = i.get("code"), h = i.get("error"), y = i.get("error_description");
50
48
  const g = new URLSearchParams(a.location.href.split("#")[1]);
51
- c || (c = g.get(x)), d || (d = g.get("code")), h || (h = g.get("error")), y || (y = g.get("error_description"));
49
+ o ||= g.get(_), d ||= g.get("code"), h ||= g.get("error"), y ||= g.get("error_description");
52
50
  } catch {
53
51
  }
54
- if (a.closed || c || d || h)
52
+ if (a.closed || o || d || h)
55
53
  if (clearInterval(s), a.close(), h)
56
54
  r([new Error(`OAuth error: ${h}${y ? ` (${y})` : ""}`), null]);
57
- else if (c) {
58
- const o = (_ = a.location.href.match(/state=([^&]*)/)) == null ? void 0 : _[1];
59
- r(o === i ? [null, c] : [new Error("State mismatch"), null]);
60
- } else d ? new URL(a.location.href).searchParams.get("state") === i ? P(e, n, {
55
+ else if (o) {
56
+ const i = a.location.href.match(/state=([^&]*)/)?.[1];
57
+ r(i === c ? [null, o] : [new Error("State mismatch"), null]);
58
+ } else d ? new URL(a.location.href).searchParams.get("state") === c ? x(e, n, {
61
59
  code: d,
62
60
  pkce: m,
63
61
  proxyUrl: u
@@ -67,10 +65,10 @@ const w = () => {
67
65
  } catch {
68
66
  return [new Error("Failed to authorize oauth2 flow"), null];
69
67
  }
70
- }, P = async (e, l, {
68
+ }, x = async (e, l, {
71
69
  code: u,
72
70
  pkce: n,
73
- proxyUrl: i
71
+ proxyUrl: c
74
72
  } = {}) => {
75
73
  if (!e)
76
74
  return [new Error("OAuth2 flow was not defined"), null];
@@ -82,19 +80,19 @@ const w = () => {
82
80
  const p = {
83
81
  "Content-Type": "application/x-www-form-urlencoded"
84
82
  };
85
- e.clientSecret && (!e["x-scalar-credentials-location"] || e["x-scalar-credentials-location"] === "header") && (p.Authorization = `Basic ${U(`${e["x-scalar-client-id"]}:${e.clientSecret}`)}`);
86
- const r = k(i, e.tokenUrl) ? `${i}?${new URLSearchParams([["scalar_url", e.tokenUrl]]).toString()}` : e.tokenUrl, c = await (await fetch(r, {
83
+ e.clientSecret && (!e["x-scalar-credentials-location"] || e["x-scalar-credentials-location"] === "header") && (p.Authorization = `Basic ${k(`${e["x-scalar-client-id"]}:${e.clientSecret}`)}`);
84
+ const r = S(c, e.tokenUrl) ? `${c}?${new URLSearchParams([["scalar_url", e.tokenUrl]]).toString()}` : e.tokenUrl, o = await (await fetch(r, {
87
85
  method: "POST",
88
86
  headers: p,
89
87
  body: t
90
88
  })).json(), d = e["x-tokenName"] || "access_token";
91
- return [null, c[d]];
89
+ return [null, o[d]];
92
90
  } catch {
93
91
  return [new Error("Failed to get an access token. Please check your credentials."), null];
94
92
  }
95
93
  };
96
94
  export {
97
- b as authorizeOauth2,
98
- P as authorizeServers,
99
- A as generateCodeChallenge
95
+ C as authorizeOauth2,
96
+ x as authorizeServers,
97
+ w as generateCodeChallenge
100
98
  };