@scalar/api-client 2.1.51 → 2.2.0

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 (201) hide show
  1. package/CHANGELOG.md +47 -0
  2. package/dist/components/AddressBar/AddressBar.vue.d.ts.map +1 -1
  3. package/dist/components/AddressBar/AddressBar.vue.js +1 -1
  4. package/dist/components/AddressBar/AddressBar.vue2.js +35 -42
  5. package/dist/components/AddressBar/AddressBarHistory.vue.d.ts.map +1 -1
  6. package/dist/components/AddressBar/AddressBarHistory.vue.js +2 -2
  7. package/dist/components/AddressBar/AddressBarHistory.vue2.js +25 -24
  8. package/dist/components/AddressBar/AddressBarServer.vue.d.ts.map +1 -1
  9. package/dist/components/AddressBar/AddressBarServer.vue.js +32 -39
  10. package/dist/components/AddressBar/AddressBarServerItem.vue.d.ts.map +1 -1
  11. package/dist/components/AddressBar/AddressBarServerItem.vue.js +10 -15
  12. package/dist/components/CodeInput/CodeInput.vue.d.ts.map +1 -1
  13. package/dist/components/CodeInput/CodeInput.vue.js +1 -1
  14. package/dist/components/CodeInput/CodeInput.vue2.js +48 -47
  15. package/dist/components/CodeInput/codeVariableWidget.d.ts +3 -2
  16. package/dist/components/CodeInput/codeVariableWidget.d.ts.map +1 -1
  17. package/dist/components/CommandPalette/CommandPaletteCollection.vue.d.ts.map +1 -1
  18. package/dist/components/CommandPalette/CommandPaletteCollection.vue.js +16 -15
  19. package/dist/components/CommandPalette/CommandPaletteExample.vue.d.ts.map +1 -1
  20. package/dist/components/CommandPalette/CommandPaletteExample.vue.js +18 -23
  21. package/dist/components/CommandPalette/CommandPaletteImport.vue.d.ts.map +1 -1
  22. package/dist/components/CommandPalette/CommandPaletteImport.vue.js +27 -26
  23. package/dist/components/CommandPalette/CommandPaletteRequest.vue.d.ts.map +1 -1
  24. package/dist/components/CommandPalette/CommandPaletteRequest.vue.js +19 -20
  25. package/dist/components/CommandPalette/CommandPaletteServer.vue.d.ts.map +1 -1
  26. package/dist/components/CommandPalette/CommandPaletteServer.vue.js +19 -24
  27. package/dist/components/CommandPalette/CommandPaletteTag.vue.d.ts.map +1 -1
  28. package/dist/components/CommandPalette/CommandPaletteTag.vue.js +23 -22
  29. package/dist/components/CommandPalette/TheCommandPalette.vue.d.ts.map +1 -1
  30. package/dist/components/CommandPalette/TheCommandPalette.vue.js +4 -4
  31. package/dist/components/CommandPalette/TheCommandPalette.vue2.js +47 -46
  32. package/dist/components/DataTable/DataTableInput.vue.d.ts +1 -1
  33. package/dist/components/DataTable/DataTableInput.vue.d.ts.map +1 -1
  34. package/dist/components/EnvironmentSelector/EnvironmentSelector.vue.d.ts.map +1 -1
  35. package/dist/components/EnvironmentSelector/EnvironmentSelector.vue.js +23 -28
  36. package/dist/components/HttpMethod/HttpMethod.vue.d.ts +2 -2
  37. package/dist/components/IconSelector.vue.js +2 -2
  38. package/dist/components/ImportCollection/ImportCollectionModal.vue.d.ts.map +1 -1
  39. package/dist/components/ImportCollection/ImportCollectionModal.vue.js +127 -96
  40. package/dist/components/ImportCollection/ImportNowButton.vue.d.ts.map +1 -1
  41. package/dist/components/ImportCollection/ImportNowButton.vue.js +28 -27
  42. package/dist/components/ImportCollection/IntegrationLogo.vue.d.ts +1 -1
  43. package/dist/components/ImportCollection/IntegrationLogo.vue.d.ts.map +1 -1
  44. package/dist/components/ImportCollection/IntegrationLogo.vue.js +14 -18
  45. package/dist/components/ImportCollection/WorkspaceSelector.vue.d.ts.map +1 -1
  46. package/dist/components/ImportCollection/WorkspaceSelector.vue.js +15 -14
  47. package/dist/components/Search/useSearch.d.ts.map +1 -1
  48. package/dist/components/Search/useSearch.js +20 -19
  49. package/dist/components/SideNav/SideNavRouterLink.vue.js +9 -9
  50. package/dist/components/Sidebar/Sidebar.vue.d.ts.map +1 -1
  51. package/dist/components/Sidebar/Sidebar.vue.js +2 -2
  52. package/dist/components/Sidebar/Sidebar.vue2.js +37 -39
  53. package/dist/components/TopNav/TopNav.vue.d.ts.map +1 -1
  54. package/dist/components/TopNav/TopNav.vue.js +1 -1
  55. package/dist/components/TopNav/TopNav.vue2.js +20 -19
  56. package/dist/components/TopNav/TopNavItem.vue.d.ts +2 -2
  57. package/dist/hooks/index.js +3 -2
  58. package/dist/hooks/useLayout.d.ts +2 -0
  59. package/dist/hooks/useLayout.d.ts.map +1 -1
  60. package/dist/hooks/useLayout.js +4 -3
  61. package/dist/layouts/App/ApiClientApp.vue.d.ts.map +1 -1
  62. package/dist/layouts/App/ApiClientApp.vue.js +38 -37
  63. package/dist/layouts/App/MainLayout.vue.d.ts.map +1 -1
  64. package/dist/layouts/App/MainLayout.vue.js +3 -3
  65. package/dist/layouts/App/create-api-client-app.d.ts +670 -1232
  66. package/dist/layouts/App/create-api-client-app.d.ts.map +1 -1
  67. package/dist/layouts/Modal/ApiClientModal.vue.d.ts.map +1 -1
  68. package/dist/layouts/Modal/ApiClientModal.vue.js +2 -2
  69. package/dist/layouts/Modal/ApiClientModal.vue2.js +24 -23
  70. package/dist/layouts/Modal/create-api-client-modal.d.ts +1384 -2508
  71. package/dist/layouts/Modal/create-api-client-modal.d.ts.map +1 -1
  72. package/dist/layouts/Web/ApiClientWeb.vue.d.ts.map +1 -1
  73. package/dist/layouts/Web/ApiClientWeb.vue.js +34 -33
  74. package/dist/layouts/Web/create-api-client-web.d.ts +670 -1232
  75. package/dist/layouts/Web/create-api-client-web.d.ts.map +1 -1
  76. package/dist/libs/create-client.d.ts +675 -1236
  77. package/dist/libs/create-client.d.ts.map +1 -1
  78. package/dist/libs/create-client.js +100 -95
  79. package/dist/libs/hot-keys.d.ts +1 -1
  80. package/dist/libs/send-request.d.ts +3 -7
  81. package/dist/libs/send-request.d.ts.map +1 -1
  82. package/dist/libs/send-request.js +126 -119
  83. package/dist/libs/string-template.d.ts.map +1 -1
  84. package/dist/libs/string-template.js +23 -22
  85. package/dist/store/active-entities.d.ts +333 -0
  86. package/dist/store/active-entities.d.ts.map +1 -0
  87. package/dist/store/active-entities.js +97 -0
  88. package/dist/store/collections.d.ts +4 -274
  89. package/dist/store/collections.d.ts.map +1 -1
  90. package/dist/store/cookies.d.ts +4 -4
  91. package/dist/store/environment.d.ts +4 -4
  92. package/dist/store/import-spec.d.ts +0 -54
  93. package/dist/store/import-spec.d.ts.map +1 -1
  94. package/dist/store/index.js +4 -3
  95. package/dist/store/request-example.d.ts +4 -4
  96. package/dist/store/requests.d.ts +15 -15
  97. package/dist/store/security-schemes.d.ts +527 -317
  98. package/dist/store/security-schemes.d.ts.map +1 -1
  99. package/dist/store/security-schemes.js +33 -41
  100. package/dist/store/servers.d.ts +4 -4
  101. package/dist/store/store-context.d.ts +0 -3
  102. package/dist/store/store-context.d.ts.map +1 -1
  103. package/dist/store/store.d.ts +640 -5297
  104. package/dist/store/store.d.ts.map +1 -1
  105. package/dist/store/store.js +111 -189
  106. package/dist/store/tags.d.ts +4 -4
  107. package/dist/store/workspace.d.ts +14 -24
  108. package/dist/store/workspace.d.ts.map +1 -1
  109. package/dist/style.css +1 -1
  110. package/dist/views/Cookies/CookieForm.vue.d.ts.map +1 -1
  111. package/dist/views/Cookies/CookieForm.vue.js +14 -13
  112. package/dist/views/Cookies/CookieRaw.vue.d.ts.map +1 -1
  113. package/dist/views/Cookies/CookieRaw.vue.js +14 -13
  114. package/dist/views/Environment/EnvironmentVariableDropdown.vue.d.ts +3 -3
  115. package/dist/views/Environment/EnvironmentVariableDropdown.vue.d.ts.map +1 -1
  116. package/dist/views/Request/Request.vue.d.ts.map +1 -1
  117. package/dist/views/Request/Request.vue.js +2 -2
  118. package/dist/views/Request/Request.vue2.js +94 -94
  119. package/dist/views/Request/RequestSection/RequestAuth/OAuth2.vue.d.ts +2 -2
  120. package/dist/views/Request/RequestSection/RequestAuth/OAuth2.vue.d.ts.map +1 -1
  121. package/dist/views/Request/RequestSection/RequestAuth/OAuth2.vue.js +96 -99
  122. package/dist/views/Request/RequestSection/RequestAuth/OAuthScopesInput.vue.d.ts +2 -2
  123. package/dist/views/Request/RequestSection/RequestAuth/OAuthScopesInput.vue.d.ts.map +1 -1
  124. package/dist/views/Request/RequestSection/RequestAuth/OAuthScopesInput.vue.js +49 -46
  125. package/dist/views/Request/RequestSection/RequestAuth/RequestAuth.vue.d.ts.map +1 -1
  126. package/dist/views/Request/RequestSection/RequestAuth/RequestAuth.vue.js +2 -2
  127. package/dist/views/Request/RequestSection/RequestAuth/RequestAuth.vue2.js +94 -100
  128. package/dist/views/Request/RequestSection/RequestAuth/RequestExampleAuth.vue.d.ts.map +1 -1
  129. package/dist/views/Request/RequestSection/RequestAuth/RequestExampleAuth.vue.js +60 -67
  130. package/dist/views/Request/RequestSection/RequestAuthDataTableInput.vue.d.ts +1 -1
  131. package/dist/views/Request/RequestSection/RequestAuthDataTableInput.vue.d.ts.map +1 -1
  132. package/dist/views/Request/RequestSection/RequestBody.vue.d.ts.map +1 -1
  133. package/dist/views/Request/RequestSection/RequestBody.vue.js +2 -2
  134. package/dist/views/Request/RequestSection/RequestBody.vue2.js +29 -28
  135. package/dist/views/Request/RequestSection/RequestParams.vue.d.ts.map +1 -1
  136. package/dist/views/Request/RequestSection/RequestParams.vue.js +11 -10
  137. package/dist/views/Request/RequestSection/RequestPathParams.vue.d.ts.map +1 -1
  138. package/dist/views/Request/RequestSection/RequestPathParams.vue.js +24 -28
  139. package/dist/views/Request/RequestSection/RequestSection.vue.d.ts.map +1 -1
  140. package/dist/views/Request/RequestSection/RequestSection.vue.js +2 -2
  141. package/dist/views/Request/RequestSection/RequestSection.vue2.js +19 -18
  142. package/dist/views/Request/RequestSection/RequestTable.vue.d.ts +2 -2
  143. package/dist/views/Request/RequestSection/RequestTableTooltip.vue.d.ts.map +1 -1
  144. package/dist/views/Request/RequestSection/RequestTableTooltip.vue.js +27 -27
  145. package/dist/views/Request/RequestSidebar.vue.d.ts.map +1 -1
  146. package/dist/views/Request/RequestSidebar.vue.js +1 -1
  147. package/dist/views/Request/RequestSidebar.vue2.js +74 -75
  148. package/dist/views/Request/RequestSidebarItem.vue.d.ts.map +1 -1
  149. package/dist/views/Request/RequestSidebarItem.vue.js +1 -1
  150. package/dist/views/Request/RequestSidebarItem.vue2.js +111 -109
  151. package/dist/views/Request/RequestSidebarItemMenu.vue.d.ts.map +1 -1
  152. package/dist/views/Request/RequestSidebarItemMenu.vue.js +2 -2
  153. package/dist/views/Request/RequestSidebarItemMenu.vue2.js +15 -16
  154. package/dist/views/Request/RequestSubpageHeader.vue.js +1 -1
  155. package/dist/views/Request/RequestSubpageHeader.vue2.js +14 -14
  156. package/dist/views/Request/ResponseSection/ResponseBodyRaw.vue.d.ts.map +1 -1
  157. package/dist/views/Request/ResponseSection/ResponseBodyRaw.vue.js +2 -2
  158. package/dist/views/Request/ResponseSection/ResponseBodyRaw.vue2.js +35 -15
  159. package/dist/views/Request/ResponseSection/ResponseEmpty.vue.d.ts.map +1 -1
  160. package/dist/views/Request/ResponseSection/ResponseEmpty.vue.js +1 -1
  161. package/dist/views/Request/ResponseSection/ResponseEmpty.vue2.js +23 -22
  162. package/dist/views/Request/components/WorkspaceDropdown.vue.d.ts.map +1 -1
  163. package/dist/views/Request/components/WorkspaceDropdown.vue.js +32 -31
  164. package/dist/views/Request/consts/new-auth-options.d.ts +16 -8
  165. package/dist/views/Request/consts/new-auth-options.d.ts.map +1 -1
  166. package/dist/views/Request/consts/new-auth-options.js +16 -8
  167. package/dist/views/Request/handle-drag.d.ts +2 -1
  168. package/dist/views/Request/handle-drag.d.ts.map +1 -1
  169. package/dist/views/Request/handle-drag.js +23 -25
  170. package/dist/views/Request/hooks/useOpenApiWatcher.d.ts.map +1 -1
  171. package/dist/views/Request/hooks/useOpenApiWatcher.js +40 -39
  172. package/dist/views/Request/libs/auth.d.ts +1 -29
  173. package/dist/views/Request/libs/auth.d.ts.map +1 -1
  174. package/dist/views/Request/libs/auth.js +2 -9
  175. package/dist/views/Request/libs/index.js +6 -8
  176. package/dist/views/Request/libs/live-sync.d.ts +6 -5
  177. package/dist/views/Request/libs/live-sync.d.ts.map +1 -1
  178. package/dist/views/Request/libs/live-sync.js +164 -185
  179. package/dist/views/Request/libs/oauth2.d.ts +6 -10
  180. package/dist/views/Request/libs/oauth2.d.ts.map +1 -1
  181. package/dist/views/Request/libs/oauth2.js +54 -69
  182. package/dist/views/Servers/ServerForm.vue.d.ts.map +1 -1
  183. package/dist/views/Servers/ServerForm.vue.js +14 -13
  184. package/dist/views/Servers/Servers.vue.d.ts.map +1 -1
  185. package/dist/views/Servers/Servers.vue2.js +18 -17
  186. package/dist/views/Settings/SettingsGeneral.vue.d.ts.map +1 -1
  187. package/dist/views/Settings/SettingsGeneral.vue.js +218 -126
  188. package/dist/views/Settings/{SettingsGeneralMode.vue.d.ts → components/SettingsAppearance.vue.d.ts} +2 -2
  189. package/dist/views/Settings/components/SettingsAppearance.vue.d.ts.map +1 -0
  190. package/dist/views/Settings/components/SettingsAppearance.vue.js +74 -0
  191. package/dist/views/Settings/components/SettingsAppearance.vue2.js +4 -0
  192. package/dist/views/Settings/components/SettingsSection.vue.d.ts +24 -0
  193. package/dist/views/Settings/components/SettingsSection.vue.d.ts.map +1 -0
  194. package/dist/views/Settings/components/SettingsSection.vue.js +24 -0
  195. package/dist/views/Settings/components/SettingsSection.vue2.js +4 -0
  196. package/package.json +12 -12
  197. package/dist/views/Request/RequestSection/RequestAuth/RequestAuthModal.vue.d.ts +0 -16
  198. package/dist/views/Request/RequestSection/RequestAuth/RequestAuthModal.vue.d.ts.map +0 -1
  199. package/dist/views/Settings/SettingsGeneralMode.vue.d.ts.map +0 -1
  200. package/dist/views/Settings/SettingsGeneralMode.vue.js +0 -78
  201. package/dist/views/Settings/SettingsGeneralMode.vue2.js +0 -4
@@ -1,190 +1,197 @@
1
- import { ERRORS as B, normalizeError as C } from "./errors.js";
2
- import { normalizeHeaders as H } from "./normalize-headers.js";
1
+ import { ERRORS as U, normalizeError as B } from "./errors.js";
2
+ import { normalizeHeaders as M } from "./normalize-headers.js";
3
3
  import { replaceTemplateVariables as f } from "./string-template.js";
4
- import { canMethodHaveBody as q, isRelativePath as S, shouldUseProxy as A } from "@scalar/oas-utils/helpers";
5
- import g from "js-cookie";
6
- import K from "whatwg-mimetype";
4
+ import { canMethodHaveBody as H, isRelativePath as C, concatenateUrlAndPath as q, shouldUseProxy as S } from "@scalar/oas-utils/helpers";
5
+ import R from "js-cookie";
6
+ import W from "whatwg-mimetype";
7
7
  import { textMediaTypes as _ } from "../views/Request/consts/mediaTypes.js";
8
- function j(c, t) {
9
- const n = new K(t);
10
- return _.includes(n.essence) ? new TextDecoder(n.parameters.get("charset")).decode(c) : new Blob([c], { type: n.essence });
8
+ function j(n, e) {
9
+ const t = new W(e);
10
+ return _.includes(t.essence) ? new TextDecoder(t.parameters.get("charset")).decode(n) : new Blob([n], { type: t.essence });
11
11
  }
12
- function Q(c, t) {
13
- const n = {};
14
- return c.parameters.headers.forEach((e) => {
15
- const p = e.key.trim().toLowerCase();
16
- e.enabled && (p !== "content-type" || e.value !== "multipart/form-data") && (n[p] = f(e.value, t));
17
- }), n;
12
+ function K(n, e) {
13
+ const t = {};
14
+ return n.parameters.headers.forEach((r) => {
15
+ const h = r.key.trim().toLowerCase();
16
+ r.enabled && (h !== "content-type" || r.value !== "multipart/form-data") && (t[h] = f(r.value, e));
17
+ }), t;
18
18
  }
19
- function V(c, t) {
20
- const n = new URLSearchParams();
21
- return c.parameters.query.forEach((e) => {
22
- e.enabled && e.value && n.append(e.key, f(e.value, t));
23
- }), n;
19
+ function Q(n, e) {
20
+ const t = new URLSearchParams();
21
+ return n.parameters.query.forEach((r) => {
22
+ r.enabled && r.value && t.append(r.key, f(r.value, e));
23
+ }), t;
24
24
  }
25
- function W({
26
- example: c,
27
- env: t,
28
- globalCookies: n,
29
- domain: e,
30
- proxy: p
25
+ function V({
26
+ example: n,
27
+ env: e,
28
+ globalCookies: t,
29
+ domain: r,
30
+ proxy: h
31
31
  }) {
32
- let h;
32
+ let m;
33
33
  try {
34
- h = new URL(p || e).host;
34
+ m = new URL(h || r).host;
35
35
  } catch {
36
- typeof window < "u" && (h = window.location.host);
36
+ typeof window < "u" && (m = window.location.host);
37
37
  }
38
- const u = {
38
+ const c = {
39
39
  // Must point all cookies to the proxy and let it sort them out
40
- domain: h,
40
+ domain: m,
41
41
  // Means that the browser sends the cookie with both cross-site and same-site requests.
42
42
  sameSite: "None",
43
43
  // The Secure attribute must also be set when setting SameSite=None.
44
44
  secure: !0
45
- }, r = g.get();
46
- return Object.keys(r).forEach((a) => g.remove(a)), c.parameters.cookies.forEach((a) => {
47
- a.enabled && g.set(a.key, f(a.value, t));
48
- }), n.forEach((a) => {
49
- var R;
50
- const { name: v, value: s, ...m } = a;
51
- (m.domain === e || ((R = m.domain) == null ? void 0 : R.startsWith(".")) && e.endsWith(m.domain ?? "")) && g.set(v, s, {
45
+ }, l = R.get();
46
+ return Object.keys(l).forEach((a) => R.remove(a)), n.parameters.cookies.forEach((a) => {
47
+ a.enabled && R.set(a.key, f(a.value, e));
48
+ }), t.forEach((a) => {
49
+ var u;
50
+ const { name: s, value: v, ...p } = a;
51
+ (p.domain === r || ((u = p.domain) == null ? void 0 : u.startsWith(".")) && r.endsWith(p.domain ?? "")) && R.set(s, v, {
52
52
  /** Override the domain with the proxy value */
53
- domain: h,
53
+ domain: m,
54
54
  // TODO: path cookies probably don't worth with the proxy
55
- path: m.path,
56
- expires: m.expires ? new Date(m.expires) : void 0,
57
- httpOnly: m.httpOnly,
58
- secure: m.secure
55
+ path: p.path,
56
+ expires: p.expires ? new Date(p.expires) : void 0,
57
+ httpOnly: p.httpOnly,
58
+ secure: p.secure
59
59
  });
60
60
  }), {
61
- cookieParams: u
61
+ cookieParams: c
62
62
  };
63
63
  }
64
- function I(c, t, n) {
65
- var e, p, h;
66
- if (!q(c))
64
+ function I(n, e, t) {
65
+ var r, h, m;
66
+ if (!H(n))
67
67
  return { body: void 0, contentType: void 0 };
68
- if (t.body.activeBody === "formData" && t.body.formData) {
69
- const u = t.body.formData.encoding === "form-data" ? "multipart/form-data" : "application/x-www-form-urlencoded", r = t.body.formData.encoding === "form-data" ? new FormData() : new URLSearchParams();
70
- return t.body.formData.value.forEach((a) => {
71
- !a.enabled || !a.key || (a.file && r instanceof FormData ? r.append(a.key, a.file, a.file.name) : a.value !== void 0 && r.append(a.key, f(a.value, n)));
72
- }), { body: r, contentType: u };
68
+ if (e.body.activeBody === "formData" && e.body.formData) {
69
+ const c = e.body.formData.encoding === "form-data" ? "multipart/form-data" : "application/x-www-form-urlencoded", l = e.body.formData.encoding === "form-data" ? new FormData() : new URLSearchParams();
70
+ return e.body.formData.value.forEach((a) => {
71
+ !a.enabled || !a.key || (a.file && l instanceof FormData ? l.append(a.key, a.file, a.file.name) : a.value !== void 0 && l.append(a.key, f(a.value, t)));
72
+ }), { body: l, contentType: c };
73
73
  }
74
- return t.body.activeBody === "raw" ? {
75
- body: f(((e = t.body.raw) == null ? void 0 : e.value) ?? "", n),
76
- contentType: (p = t.body.raw) == null ? void 0 : p.encoding
77
- } : t.body.activeBody === "binary" ? {
78
- body: t.body.binary,
79
- contentType: (h = t.body.binary) == null ? void 0 : h.type
74
+ return e.body.activeBody === "raw" ? {
75
+ body: f(((r = e.body.raw) == null ? void 0 : r.value) ?? "", t),
76
+ contentType: (h = e.body.raw) == null ? void 0 : h.encoding
77
+ } : e.body.activeBody === "binary" ? {
78
+ body: e.body.binary,
79
+ contentType: (m = e.body.binary) == null ? void 0 : m.type
80
80
  } : {
81
81
  body: void 0,
82
82
  contentType: void 0
83
83
  };
84
84
  }
85
- const oe = ({
86
- request: c,
87
- auth: t,
88
- example: n,
89
- server: e,
90
- securitySchemes: p,
85
+ function N(n) {
86
+ return n.startsWith("http://") || n.startsWith("https://") ? n : `http://${n}`;
87
+ }
88
+ const te = ({
89
+ request: n,
90
+ example: e,
91
+ server: t,
92
+ securitySchemes: r,
91
93
  selectedSecuritySchemeUids: h = [],
92
- proxy: u,
93
- status: r,
94
- environment: a,
95
- globalCookies: v
94
+ proxy: m,
95
+ status: c,
96
+ environment: l,
97
+ globalCookies: a
96
98
  }) => {
97
99
  try {
98
- const s = a ?? {}, m = new AbortController(), E = n.parameters.path.reduce((l, o) => (o.enabled && (l[o.key] = f(o.value, s)), l), {}), R = f((e == null ? void 0 : e.url) ?? "", s), w = f(c.path, E);
99
- let d = R || w;
100
- if (!d) throw B.URL_EMPTY;
101
- Object.entries((e == null ? void 0 : e.variables) ?? {}).forEach(([l, o]) => {
102
- d = f(d, { [l]: o.default });
100
+ const s = l ?? {}, v = new AbortController(), p = e.parameters.path.reduce((y, o) => (o.enabled && (y[o.key] = f(o.value, s)), y), {}), L = f((t == null ? void 0 : t.url) ?? "", s), u = f(n.path, p);
101
+ let d = L || u;
102
+ if (!d) throw U.URL_EMPTY;
103
+ Object.entries((t == null ? void 0 : t.variables) ?? {}).forEach(([y, o]) => {
104
+ d = f(d, { [y]: o.default });
103
105
  });
104
- const P = V(n, s), b = Q(n, s), { body: F } = I(c.method, n, s);
105
- return W({
106
- example: n,
106
+ const T = Q(e, s), b = K(e, s), { body: $ } = I(n.method, e, s);
107
+ return V({
108
+ example: e,
107
109
  env: s,
108
- globalCookies: v,
110
+ globalCookies: a,
109
111
  domain: d,
110
- proxy: u
111
- }), h == null || h.forEach((l) => {
112
- const o = t[l], y = p[l];
113
- if (!(!o || !y)) {
114
- if (y.type === "apiKey" && o.type === "apiKey") {
112
+ proxy: m
113
+ }), h == null || h.forEach((y) => {
114
+ var D;
115
+ const o = r[y];
116
+ if (o) {
117
+ if (o.type === "apiKey") {
115
118
  const i = f(o.value, s);
116
- y.in === "header" && (b[o.name] = i), y.in === "query" && P.append(o.name, i), y.in === "cookie" && g.set(o.name, i);
119
+ o.in === "header" && (b[o.name] = i), o.in === "query" && T.append(o.name, i), o.in === "cookie" && R.set(o.name, i);
117
120
  }
118
- if (y.type === "http" && o.type === "http")
119
- if (y.scheme === "basic") {
120
- const i = f(o.username, s), L = f(o.password, s), T = `${i}:${L}`;
121
- b.Authorization = `Basic ${btoa(T)}`;
121
+ if (o.type === "http")
122
+ if (o.scheme === "basic") {
123
+ const i = f(o.username, s), w = f(o.password, s), k = `${i}:${w}`;
124
+ b.Authorization = `Basic ${btoa(k)}`;
122
125
  } else {
123
126
  const i = f(o.token, s);
124
127
  b.Authorization = `Bearer ${i}`;
125
128
  }
126
- y.type === "oauth2" && o.type.includes("oauth") && "token" in o && (o.token || console.error("OAuth token was not created"), b.Authorization = `Bearer ${o.token}`);
129
+ if (o.type === "oauth2") {
130
+ const w = (D = Object.values(o.flows).find((k) => k.token)) == null ? void 0 : D.token;
131
+ if (!w) return;
132
+ b.Authorization = `Bearer ${w}`;
133
+ }
127
134
  }
128
135
  }), [
129
136
  null,
130
137
  {
131
138
  sendRequest: async () => {
132
- r == null || r.emit("start");
133
- const l = Date.now();
139
+ c == null || c.emit("start");
140
+ const y = Date.now();
134
141
  try {
135
- if (d && (!S(d) || typeof window < "u")) {
136
- const z = S(d) ? window.location.origin + d : d, k = new URL(z), M = new URL(w, k.origin), D = new URL(k);
137
- e != null && e.url && (k.pathname === "/" ? D.pathname = w : D.pathname = k.pathname + w), D.search = new URLSearchParams([
138
- ...k.searchParams,
139
- ...M.searchParams,
140
- ...P
141
- ]).toString(), d = D.toString();
142
+ if (d && (!C(d) || typeof window < "u")) {
143
+ const z = C(d) ? q(window.location.origin, d) : N(d), g = new URL(z), A = new URL(u, g.origin), P = new URL(g);
144
+ t != null && t.url && (g.pathname === "/" ? P.pathname = u : P.pathname = g.pathname + u), P.search = new URLSearchParams([
145
+ ...g.searchParams,
146
+ ...A.searchParams,
147
+ ...T
148
+ ]).toString(), d = P.toString();
142
149
  }
143
- const o = new URLSearchParams([["scalar_url", d.toString()]]), y = A(u, d) ? `${u}?${o.toString()}` : d, i = await fetch(y, {
144
- signal: m.signal,
145
- method: c.method.toUpperCase(),
146
- body: F,
150
+ const o = new URLSearchParams([["scalar_url", d.toString()]]), D = S(m, d) ? `${m}?${o.toString()}` : d, i = await fetch(D, {
151
+ signal: v.signal,
152
+ method: n.method.toUpperCase(),
153
+ body: $,
147
154
  headers: b
148
155
  });
149
- r == null || r.emit("stop");
150
- const L = H(
156
+ c == null || c.emit("stop");
157
+ const w = M(
151
158
  i.headers,
152
- A(u, d)
153
- ), T = i.headers.get("content-type") ?? "text/plain;charset=UTF-8", U = await i.arrayBuffer(), O = j(U, T), $ = "getSetCookie" in i.headers && typeof i.headers.getSetCookie == "function" ? i.headers.getSetCookie() : [];
159
+ S(m, d)
160
+ ), k = i.headers.get("content-type") ?? "text/plain;charset=UTF-8", E = await i.arrayBuffer(), F = j(E, k), O = "getSetCookie" in i.headers && typeof i.headers.getSetCookie == "function" ? i.headers.getSetCookie() : [];
154
161
  return [
155
162
  null,
156
163
  {
157
164
  timestamp: Date.now(),
158
- request: n,
165
+ request: e,
159
166
  response: {
160
167
  ...i,
161
- headers: L,
162
- cookieHeaderKeys: $,
163
- data: O,
164
- size: U.byteLength,
165
- duration: Date.now() - l,
166
- method: c.method,
168
+ headers: w,
169
+ cookieHeaderKeys: O,
170
+ data: F,
171
+ size: E.byteLength,
172
+ duration: Date.now() - y,
173
+ method: n.method,
167
174
  status: i.status,
168
- path: w
175
+ path: u
169
176
  }
170
177
  }
171
178
  ];
172
179
  } catch (o) {
173
- return r == null || r.emit("abort"), [C(o, B.REQUEST_FAILED), null];
180
+ return c == null || c.emit("abort"), [B(o, U.REQUEST_FAILED), null];
174
181
  }
175
182
  },
176
- controller: m
183
+ controller: v
177
184
  }
178
185
  ];
179
186
  } catch (s) {
180
- return r == null || r.emit("abort"), [C(s), null];
187
+ return c == null || c.emit("abort"), [B(s), null];
181
188
  }
182
189
  };
183
190
  export {
184
191
  I as createFetchBody,
185
- Q as createFetchHeaders,
186
- V as createFetchQueryParams,
187
- oe as createRequestOperation,
192
+ K as createFetchHeaders,
193
+ Q as createFetchQueryParams,
194
+ te as createRequestOperation,
188
195
  j as decodeBuffer,
189
- W as setRequestCookies
196
+ V as setRequestCookies
190
197
  };
@@ -1 +1 @@
1
- {"version":3,"file":"string-template.d.ts","sourceRoot":"","sources":["../../src/libs/string-template.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,UAQ5D;AAED;;;;;;GAMG;AACH,wBAAgB,wBAAwB,CACtC,cAAc,EAAE,MAAM,EACtB,OAAO,EAAE,MAAM,UAkBhB;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAAC,WAAW,EAAE,MAAM,sBAoBjD"}
1
+ {"version":3,"file":"string-template.d.ts","sourceRoot":"","sources":["../../src/libs/string-template.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,UAQ5D;AAED;;;;;;GAMG;AACH,wBAAgB,wBAAwB,CACtC,cAAc,EAAE,MAAM,EACtB,OAAO,EAAE,MAAM,UAehB;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAAC,WAAW,EAAE,MAAM,sBAoBjD"}
@@ -1,30 +1,31 @@
1
- function l(n, a) {
2
- const s = n.split(".").reduce(
3
- (e, t) => e == null ? void 0 : e[t],
4
- a
1
+ import { REGEX as u } from "@scalar/oas-utils/helpers";
2
+ function l(n, o) {
3
+ const t = n.split(".").reduce(
4
+ (e, c) => e == null ? void 0 : e[c],
5
+ o
5
6
  );
6
- return typeof s == "string" ? s : JSON.stringify(s);
7
+ return typeof t == "string" ? t : JSON.stringify(t);
7
8
  }
8
- function u(n, a) {
9
- const c = /{{\s*([^}\s]+?)\s*}}|{\s*([^}\s]+?)\s*}|:\b[\w.]+\b/g, s = n.match(c) ?? [];
10
- let e = n;
11
- return s.forEach((t) => {
12
- const r = t.startsWith(":") ? t.slice(1) : t.replace(/[{}]/g, "").trim(), o = l(r, a);
13
- o != null && (e = e.replaceAll(t, o));
14
- }), e;
9
+ function f(n, o) {
10
+ const r = n.match(u.TEMPLATE_VARIABLE) ?? [];
11
+ let t = n;
12
+ return r.forEach((e) => {
13
+ const c = e.startsWith(":") ? e.slice(1) : e.replace(/[{}]/g, "").trim(), s = l(c, o);
14
+ s != null && (t = t.replaceAll(e, s));
15
+ }), t;
15
16
  }
16
- function i(n) {
17
- function a(c, s) {
18
- const e = Object.keys(c), t = [];
19
- return e.forEach((r) => {
20
- const o = s ? `${s}.${r}` : r;
21
- typeof c[r] == "object" ? t.push(...a(c[r], o)) : t.push([o, String(c[r])]);
22
- }), t;
17
+ function p(n) {
18
+ function o(r, t) {
19
+ const e = Object.keys(r), c = [];
20
+ return e.forEach((s) => {
21
+ const a = t ? `${t}.${s}` : s;
22
+ typeof r[s] == "object" ? c.push(...o(r[s], a)) : c.push([a, String(r[s])]);
23
+ }), c;
23
24
  }
24
- return a(n);
25
+ return o(n);
25
26
  }
26
27
  export {
27
- i as flattenEnvVars,
28
+ p as flattenEnvVars,
28
29
  l as getDotPathValue,
29
- u as replaceTemplateVariables
30
+ f as replaceTemplateVariables
30
31
  };