@scalar/api-client 2.5.32 → 2.5.33

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 +20 -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 +1 -1
  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,26 +1,25 @@
1
- import { replaceTemplateVariables as e } from "../string-template.js";
2
- import { canMethodHaveBody as c } from "@scalar/oas-utils/helpers";
3
- function v(f, o, t) {
4
- var r, i, n;
5
- if (!c(f))
1
+ import { replaceTemplateVariables as r } from "../string-template.js";
2
+ import { canMethodHaveBody as e } from "@scalar/oas-utils/helpers";
3
+ function c(i, o, t) {
4
+ if (!e(i))
6
5
  return { body: void 0, contentType: void 0 };
7
6
  if (o.body.activeBody === "formData" && o.body.formData) {
8
- const y = o.body.formData.encoding === "form-data" ? "multipart/form-data" : "application/x-www-form-urlencoded", d = o.body.formData.encoding === "form-data" ? new FormData() : new URLSearchParams();
7
+ const n = o.body.formData.encoding === "form-data" ? "multipart/form-data" : "application/x-www-form-urlencoded", d = o.body.formData.encoding === "form-data" ? new FormData() : new URLSearchParams();
9
8
  return o.body.formData.value.forEach((a) => {
10
- !a.enabled || !a.key || (a.file && d instanceof FormData ? d.append(a.key, a.file, a.file.name) : a.value !== void 0 && d.append(a.key, e(a.value, t)));
11
- }), { body: d, contentType: y };
9
+ !a.enabled || !a.key || (a.file && d instanceof FormData ? d.append(a.key, a.file, a.file.name) : a.value !== void 0 && d.append(a.key, r(a.value, t)));
10
+ }), { body: d, contentType: n };
12
11
  }
13
12
  return o.body.activeBody === "raw" ? {
14
- body: e(((r = o.body.raw) == null ? void 0 : r.value) ?? "", t),
15
- contentType: (i = o.body.raw) == null ? void 0 : i.encoding
13
+ body: r(o.body.raw?.value ?? "", t),
14
+ contentType: o.body.raw?.encoding
16
15
  } : o.body.activeBody === "binary" ? {
17
16
  body: o.body.binary,
18
- contentType: (n = o.body.binary) == null ? void 0 : n.type
17
+ contentType: o.body.binary?.type
19
18
  } : {
20
19
  body: void 0,
21
20
  contentType: void 0
22
21
  };
23
22
  }
24
23
  export {
25
- v as createFetchBody
24
+ c as createFetchBody
26
25
  };
@@ -1,26 +1,26 @@
1
- import { replaceTemplateVariables as s } from "../string-template.js";
2
- function f(l, o, n) {
3
- const r = new URLSearchParams(), i = ((n == null ? void 0 : n.parameters) ?? []).reduce(
1
+ import { replaceTemplateVariables as c } from "../string-template.js";
2
+ function m(o, n, l) {
3
+ const r = new URLSearchParams(), u = (l?.parameters ?? []).reduce(
4
4
  (e, a) => (a.in === "query" && (e[a.name] = a), e),
5
5
  {}
6
6
  );
7
- return l.parameters.query.forEach((e) => {
7
+ return o.parameters.query.forEach((e) => {
8
8
  if (!e.enabled) return;
9
- const a = i[e.key];
9
+ const a = u[e.key];
10
10
  switch (e.type) {
11
11
  case "array": {
12
- const t = s(e.value ?? "", o).split(/,\ ?/);
13
- if ((a == null ? void 0 : a.explode) === !1) {
14
- const c = t.join(",");
15
- r.append(e.key, c);
12
+ const t = c(e.value ?? "", n).split(/,\ ?/);
13
+ if (a?.explode === !1) {
14
+ const s = t.join(",");
15
+ r.append(e.key, s);
16
16
  } else
17
- t.forEach((c) => {
18
- r.append(e.key, c.trim());
17
+ t.forEach((s) => {
18
+ r.append(e.key, s.trim());
19
19
  });
20
20
  break;
21
21
  }
22
22
  default: {
23
- const t = s(e.value ?? "", o);
23
+ const t = c(e.value ?? "", n);
24
24
  r.append(e.key, t.trim());
25
25
  break;
26
26
  }
@@ -28,5 +28,5 @@ function f(l, o, n) {
28
28
  }), r;
29
29
  }
30
30
  export {
31
- f as createFetchQueryParams
31
+ m as createFetchQueryParams
32
32
  };
@@ -1,126 +1,125 @@
1
- import { ERRORS as P, normalizeError as U } from "../errors.js";
2
- import { normalizeHeaders as N } from "../normalize-headers.js";
3
- import { createFetchBody as Z } from "./create-fetch-body.js";
4
- import { createFetchHeaders as $ } from "./create-fetch-headers.js";
5
- import { createFetchQueryParams as M } from "./create-fetch-query-params.js";
6
- import { decodeBuffer as ee } from "./decode-buffer.js";
7
- import { setRequestCookies as oe, getCookieHeader as te } from "./set-request-cookies.js";
8
- import { replaceTemplateVariables as h } from "../string-template.js";
9
- import { isElectron as q } from "../electron.js";
10
- import { isDefined as re, mergeUrls as se, shouldUseProxy as D, redirectToProxy as ne, httpStatusCodes as ae } from "@scalar/oas-utils/helpers";
11
- import { buildRequestSecurity as ie } from "./build-request-security.js";
12
- const Ce = ({
13
- environment: E,
14
- example: a,
15
- globalCookies: L,
1
+ import { ERRORS as T, normalizeError as H } from "../errors.js";
2
+ import { normalizeHeaders as Y } from "../normalize-headers.js";
3
+ import { createFetchBody as G } from "./create-fetch-body.js";
4
+ import { createFetchHeaders as J } from "./create-fetch-headers.js";
5
+ import { createFetchQueryParams as N } from "./create-fetch-query-params.js";
6
+ import { decodeBuffer as Z } from "./decode-buffer.js";
7
+ import { setRequestCookies as $, getCookieHeader as M } from "./set-request-cookies.js";
8
+ import { replaceTemplateVariables as c } from "../string-template.js";
9
+ import { isElectron as P } from "../electron.js";
10
+ import { isDefined as ee, mergeUrls as te, shouldUseProxy as U, redirectToProxy as oe, httpStatusCodes as re } from "@scalar/oas-utils/helpers";
11
+ import { buildRequestSecurity as se } from "./build-request-security.js";
12
+ const be = ({
13
+ environment: q,
14
+ example: s,
15
+ globalCookies: v,
16
16
  proxyUrl: u,
17
- request: i,
18
- securitySchemes: z,
19
- selectedSecuritySchemeUids: B = [],
20
- server: d,
21
- status: o,
22
- pluginManager: f
17
+ request: a,
18
+ securitySchemes: D,
19
+ selectedSecuritySchemeUids: E = [],
20
+ server: k,
21
+ status: m,
22
+ pluginManager: h
23
23
  }) => {
24
24
  try {
25
- const t = E ?? {}, w = new AbortController(), R = a.parameters.path.reduce((e, s) => (s.enabled && (e[s.key] = h(s.value, t)), e), {}), F = h((d == null ? void 0 : d.url) ?? "", t), p = h(h(i.path, t), R);
26
- let n = F || p;
27
- if (!n)
28
- throw P.URL_EMPTY;
29
- Object.entries((d == null ? void 0 : d.variables) ?? {}).forEach(([e, s]) => {
30
- n = h(n, {
31
- [e]: R[e] || s.default
25
+ const o = q ?? {}, b = new AbortController(), w = s.parameters.path.reduce((t, e) => (e.enabled && (t[e.key] = c(e.value, o)), t), {}), L = c(k?.url ?? "", o), l = c(c(a.path, o), w);
26
+ let r = L || l;
27
+ if (!r)
28
+ throw T.URL_EMPTY;
29
+ Object.entries(k?.variables ?? {}).forEach(([t, e]) => {
30
+ r = c(r, {
31
+ [t]: w[t] || e.default
32
32
  });
33
33
  });
34
- const _ = M(a, t, i), O = $(a, t), { body: W } = Z(i.method, a, t), { cookieParams: x } = oe({
35
- example: a,
36
- env: t,
37
- globalCookies: L,
38
- serverUrl: n,
34
+ const z = N(s, o, a), B = J(s, o), { body: F } = G(a.method, s, o), { cookieParams: _ } = $({
35
+ example: s,
36
+ env: o,
37
+ globalCookies: v,
38
+ serverUrl: r,
39
39
  proxyUrl: u
40
- }), A = B.flat().map((e) => z[e]).filter(re), S = ie(A, t), c = { ...Object.entries(S.headers).reduce(
41
- (e, [s, y]) => (e[s.toLowerCase()] = y, e),
40
+ }), O = E.flat().map((t) => D[t]).filter(ee), f = se(O, o), n = { ...Object.entries(f.headers).reduce(
41
+ (t, [e, S]) => (t[e.toLowerCase()] = S, t),
42
42
  {}
43
- ), ...O }, X = [...x, ...S.cookies], j = new URLSearchParams([..._, ...S.urlParams]);
44
- q() && c["user-agent"] && (c["X-Scalar-User-Agent"] = c["user-agent"]), n = se(n, p, j);
45
- const k = h(te(X, c.Cookie), t);
46
- k && (q() || D(u, n) ? (console.warn(
43
+ ), ...B }, W = [..._, ...f.cookies], x = new URLSearchParams([...z, ...f.urlParams]);
44
+ P() && n["user-agent"] && (n["X-Scalar-User-Agent"] = n["user-agent"]), r = te(r, l, x);
45
+ const p = c(M(W, n.Cookie), o);
46
+ p && (P() || U(u, r) ? (console.warn(
47
47
  "We're using a `X-Scalar-Cookie` custom header to the request. The proxy will forward this as a `Cookie` header. We do this to avoid the browser omitting the `Cookie` header for cross-origin requests for security reasons."
48
- ), c["X-Scalar-Cookie"] = k) : (console.warn(
48
+ ), n["X-Scalar-Cookie"] = p) : (console.warn(
49
49
  `We're trying to add a Cookie header, but browsers often omit them for cross-origin requests for various security reasons. If it's not working, that's probably why. Here are the requirements for it to work:
50
50
 
51
51
  - The browser URL must be on the same domain as the server URL.
52
52
  - The connection must be made over HTTPS.
53
53
  `
54
- ), c.Cookie = k));
55
- const I = ne(u, n), b = new Request(I, {
56
- method: i.method.toUpperCase(),
57
- body: W ?? null,
58
- headers: c
54
+ ), n.Cookie = p));
55
+ const A = oe(u, r), y = new Request(A, {
56
+ method: a.method.toUpperCase(),
57
+ body: F ?? null,
58
+ headers: n
59
59
  });
60
60
  return [
61
61
  null,
62
62
  {
63
- request: b,
63
+ request: y,
64
64
  sendRequest: async () => {
65
- var s, y, C;
66
- o == null || o.emit("start"), f && f.executeHook("onBeforeRequest", { request: b });
67
- const e = Date.now();
65
+ m?.emit("start"), h && h.executeHook("onBeforeRequest", { request: y });
66
+ const t = Date.now();
68
67
  try {
69
- const r = await fetch(b, {
70
- signal: w.signal
71
- }), Q = (s = r.headers.get("content-type")) == null ? void 0 : s.startsWith("text/event-stream");
72
- o == null || o.emit("stop");
73
- const V = Date.now() - e, v = r.clone(), g = N(r.headers, D(u, n)), K = r.headers.get("content-type") ?? "text/plain;charset=UTF-8", T = await v.arrayBuffer(), Y = ee(T, K), m = r.clone(), G = m.statusText || ((y = ae[m.status]) == null ? void 0 : y.name) || "", J = [204, 205, 304].includes(m.status), l = new Response(J ? null : m.body, {
74
- status: m.status,
75
- statusText: G,
76
- headers: m.headers
68
+ const e = await fetch(y, {
69
+ signal: b.signal
70
+ }), S = e.headers.get("content-type")?.startsWith("text/event-stream");
71
+ m?.emit("stop");
72
+ const X = Date.now() - t, j = e.clone(), R = Y(e.headers, U(u, r)), I = e.headers.get("content-type") ?? "text/plain;charset=UTF-8", C = await j.arrayBuffer(), Q = Z(C, I), i = e.clone(), V = i.statusText || re[i.status]?.name || "", K = [204, 205, 304].includes(i.status), d = new Response(K ? null : i.body, {
73
+ status: i.status,
74
+ statusText: V,
75
+ headers: i.headers
77
76
  });
78
- f && f.executeHook("onResponseReceived", { response: l, operation: i });
79
- const H = "getSetCookie" in l.headers && typeof l.headers.getSetCookie == "function" ? l.headers.getSetCookie() : [];
80
- return Q && r.body ? [
77
+ h && h.executeHook("onResponseReceived", { response: d, operation: a });
78
+ const g = "getSetCookie" in d.headers && typeof d.headers.getSetCookie == "function" ? d.headers.getSetCookie() : [];
79
+ return S && e.body ? [
81
80
  null,
82
81
  {
83
82
  timestamp: Date.now(),
84
- request: a,
83
+ request: s,
85
84
  response: {
86
- ...l,
87
- headers: g,
88
- cookieHeaderKeys: H,
89
- reader: (C = r.body) == null ? void 0 : C.getReader(),
90
- duration: V,
91
- method: i.method,
92
- path: p
85
+ ...d,
86
+ headers: R,
87
+ cookieHeaderKeys: g,
88
+ reader: e.body?.getReader(),
89
+ duration: X,
90
+ method: a.method,
91
+ path: l
93
92
  }
94
93
  }
95
94
  ] : [
96
95
  null,
97
96
  {
98
97
  timestamp: Date.now(),
99
- request: a,
98
+ request: s,
100
99
  response: {
101
- ...r,
102
- headers: g,
103
- cookieHeaderKeys: H,
104
- data: Y,
105
- size: T.byteLength,
106
- duration: Date.now() - e,
107
- method: i.method,
108
- status: r.status,
109
- path: p
100
+ ...e,
101
+ headers: R,
102
+ cookieHeaderKeys: g,
103
+ data: Q,
104
+ size: C.byteLength,
105
+ duration: Date.now() - t,
106
+ method: a.method,
107
+ status: e.status,
108
+ path: l
110
109
  }
111
110
  }
112
111
  ];
113
- } catch (r) {
114
- return o == null || o.emit("abort"), [U(r, P.REQUEST_FAILED), null];
112
+ } catch (e) {
113
+ return m?.emit("abort"), [H(e, T.REQUEST_FAILED), null];
115
114
  }
116
115
  },
117
- controller: w
116
+ controller: b
118
117
  }
119
118
  ];
120
- } catch (t) {
121
- return console.error(t), o == null || o.emit("abort"), [U(t), null];
119
+ } catch (o) {
120
+ return console.error(o), m?.emit("abort"), [H(o), null];
122
121
  }
123
122
  };
124
123
  export {
125
- Ce as createRequestOperation
124
+ be as createRequestOperation
126
125
  };
@@ -1 +1 @@
1
- {"version":3,"file":"decode-buffer.d.ts","sourceRoot":"","sources":["../../../src/libs/send-request/decode-buffer.ts"],"names":[],"mappings":"AAIA,sDAAsD;AACtD,wBAAgB,YAAY,CAAC,MAAM,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,iBAapE"}
1
+ {"version":3,"file":"decode-buffer.d.ts","sourceRoot":"","sources":["../../../src/libs/send-request/decode-buffer.ts"],"names":[],"mappings":"AAKA,sDAAsD;AACtD,wBAAgB,YAAY,CAAC,MAAM,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,iBAapE"}
@@ -5,20 +5,20 @@ const l = "/";
5
5
  function C({
6
6
  example: a,
7
7
  env: t,
8
- globalCookies: e,
9
- serverUrl: o,
8
+ globalCookies: o,
9
+ serverUrl: e,
10
10
  proxyUrl: r
11
11
  }) {
12
- const n = [], h = $(r, o), i = W(
13
- h ? r : o ?? "http://localhost"
12
+ const n = [], h = $(r, e), i = W(
13
+ h ? r : e ?? "http://localhost"
14
14
  );
15
- return e.forEach((s) => {
16
- const { name: c, value: u, domain: m, ...d } = s;
17
- !k(o, m) || !c || n.push(
15
+ return o.forEach((s) => {
16
+ const { name: m, value: u, domain: c, ...d } = s;
17
+ !k(e, c) || !m || n.push(
18
18
  p.parse({
19
- name: c,
19
+ name: m,
20
20
  value: u,
21
- domain: m,
21
+ domain: c,
22
22
  path: d.path
23
23
  })
24
24
  );
@@ -42,14 +42,14 @@ const W = (a) => {
42
42
  if (!a || !t)
43
43
  return !0;
44
44
  try {
45
- const e = a.startsWith("http") ? a : `http://${a}`, o = new URL(e).hostname, r = !t, n = t === o, h = t.startsWith(".") && t === `.${o}`, i = t.startsWith(".") && (o == null ? void 0 : o.endsWith(t));
45
+ const o = a.startsWith("http") ? a : `http://${a}`, e = new URL(o).hostname, r = !t, n = t === e, h = t.startsWith(".") && t === `.${e}`, i = t.startsWith(".") && e?.endsWith(t);
46
46
  return r || n || i || h;
47
47
  } catch {
48
48
  return !1;
49
49
  }
50
50
  }, D = (a, t) => {
51
- const e = a.map((o) => `${o.name}=${o.value}`).join("; ");
52
- return t ? `${t}; ${e}`.trim() : e.trim();
51
+ const o = a.map((e) => `${e.name}=${e.value}`).join("; ");
52
+ return t ? `${t}; ${o}`.trim() : o.trim();
53
53
  };
54
54
  export {
55
55
  D as getCookieHeader,
@@ -1,36 +1,36 @@
1
1
  import { REGEX as l, isDefined as a } from "@scalar/oas-utils/helpers";
2
2
  function i(c, o) {
3
- const n = c.split(".").reduce((s, r) => s == null ? void 0 : s[r], o);
4
- return typeof n == "string" ? n : JSON.stringify(n);
3
+ const s = c.split(".").reduce((u, r) => u?.[r], o);
4
+ return typeof s == "string" ? s : JSON.stringify(s);
5
5
  }
6
6
  function p(c, o) {
7
7
  let t = c;
8
- const n = /* @__PURE__ */ new Set();
9
- return t = t.replace(l.VARIABLES, (s, r) => {
8
+ const s = /* @__PURE__ */ new Set();
9
+ return t = t.replace(l.VARIABLES, (u, r) => {
10
10
  const e = r.trim();
11
- n.add(e);
12
- const u = i(e, o);
13
- return a(u) && u !== "" ? u : `{{${e}}}`;
14
- }), t = t.replace(l.PATH, (s, r) => {
11
+ s.add(e);
12
+ const n = i(e, o);
13
+ return a(n) && n !== "" ? n : `{{${e}}}`;
14
+ }), t = t.replace(l.PATH, (u, r) => {
15
15
  const e = r.trim();
16
- if (n.has(e))
16
+ if (s.has(e))
17
17
  return `{${e}}`;
18
- const u = i(e, o);
19
- return a(u) && u !== "" ? u : `{${e}}`;
20
- }), t = t.replace(/:\b[\w.]+\b/g, (s) => {
21
- const r = s.slice(1);
22
- if (n.has(r))
23
- return s;
18
+ const n = i(e, o);
19
+ return a(n) && n !== "" ? n : `{${e}}`;
20
+ }), t = t.replace(/:\b[\w.]+\b/g, (u) => {
21
+ const r = u.slice(1);
22
+ if (s.has(r))
23
+ return u;
24
24
  const e = i(r, o);
25
- return a(e) && e !== "" ? e : s;
25
+ return a(e) && e !== "" ? e : u;
26
26
  }), t;
27
27
  }
28
28
  function y(c) {
29
- function o(t, n) {
30
- const s = Object.keys(t), r = [];
31
- return s.forEach((e) => {
32
- const u = n ? `${n}.${e}` : e;
33
- typeof t[e] == "object" ? r.push(...o(t[e], u)) : r.push([u, String(t[e])]);
29
+ function o(t, s) {
30
+ const u = Object.keys(t), r = [];
31
+ return u.forEach((e) => {
32
+ const n = s ? `${s}.${e}` : e;
33
+ typeof t[e] == "object" ? r.push(...o(t[e], n)) : r.push([n, String(t[e])]);
34
34
  }), r;
35
35
  }
36
36
  return o(c);
@@ -1,12 +1,9 @@
1
- const i = (a) => {
1
+ const n = (a) => {
2
2
  const e = /* @__PURE__ */ new Set();
3
- return a && ["path", "query", "headers", "cookies"].some((n) => {
4
- var s, t;
5
- return (t = (s = a.parameters) == null ? void 0 : s[n]) == null ? void 0 : t.some((r) => {
6
- r.required && r.value === "" && e.add(r.key);
7
- });
8
- }), e;
3
+ return a && ["path", "query", "headers", "cookies"].some((s) => a.parameters?.[s]?.some((r) => {
4
+ r.required && r.value === "" && e.add(r.key);
5
+ })), e;
9
6
  };
10
7
  export {
11
- i as validateParameters
8
+ n as validateParameters
12
9
  };
@@ -1,32 +1,26 @@
1
- const u = ({ plugins: l = [] }) => {
2
- const a = /* @__PURE__ */ new Map();
3
- return l.forEach((n) => {
4
- const r = n();
5
- a.set(r.name, r);
1
+ const s = ({ plugins: a = [] }) => {
2
+ const t = /* @__PURE__ */ new Map();
3
+ return a.forEach((r) => {
4
+ const e = r();
5
+ t.set(e.name, e);
6
6
  }), {
7
7
  /**
8
8
  * Get all components for a specific view
9
9
  */
10
- getViewComponents: (n) => Array.from(a.values()).flatMap((r) => {
11
- var t;
12
- return ((t = r.views) == null ? void 0 : t[n]) || [];
13
- }),
10
+ getViewComponents: (r) => Array.from(t.values()).flatMap((e) => e.views?.[r] || []),
14
11
  /**
15
12
  * Execute a hook for a specific event
16
13
  */
17
- executeHook: (n, ...r) => {
18
- const t = Array.from(a.values()).flatMap(
19
- (e) => {
20
- var s;
21
- return ((s = e.hooks) == null ? void 0 : s[n]) || [];
22
- }
14
+ executeHook: (r, ...e) => {
15
+ const o = Array.from(t.values()).flatMap(
16
+ (n) => n.hooks?.[r] || []
23
17
  );
24
18
  return Promise.all(
25
- t.filter((e) => e != null).map((e) => e == null ? void 0 : e(...r))
19
+ o.filter((n) => n != null).map((n) => n?.(...e))
26
20
  );
27
21
  }
28
22
  };
29
23
  };
30
24
  export {
31
- u as createPluginManager
25
+ s as createPluginManager
32
26
  };