@scalar/api-client 2.18.4 → 2.19.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 (223) hide show
  1. package/CHANGELOG.md +37 -0
  2. package/dist/components/AddressBar/AddressBar.vue2.js +5 -5
  3. package/dist/components/CommandPalette/CommandPaletteImport.vue.js +6 -6
  4. package/dist/components/ImportCollection/DropEventListener.vue.d.ts.map +1 -1
  5. package/dist/components/ImportCollection/DropEventListener.vue.js +26 -28
  6. package/dist/components/ImportCollection/utils/get-openapi-version.d.ts.map +1 -1
  7. package/dist/components/ImportCollection/utils/import-collection.d.ts +1 -1
  8. package/dist/components/ImportCollection/utils/import-collection.d.ts.map +1 -1
  9. package/dist/components/Search/useSearch.d.ts.map +1 -1
  10. package/dist/components/Search/useSearch.js +16 -16
  11. package/dist/components/Server/index.d.ts +1 -1
  12. package/dist/components/Server/index.d.ts.map +1 -1
  13. package/dist/components/Server/index.js +6 -6
  14. package/dist/components/SideNav/SideNav.vue.js +3 -3
  15. package/dist/components/Sidebar/index.d.ts +1 -2
  16. package/dist/components/Sidebar/index.d.ts.map +1 -1
  17. package/dist/components/index.d.ts +2 -2
  18. package/dist/components/index.d.ts.map +1 -1
  19. package/dist/hooks/index.d.ts +2 -2
  20. package/dist/hooks/index.d.ts.map +1 -1
  21. package/dist/hooks/useResponseBody.d.ts +1 -1
  22. package/dist/hooks/useResponseBody.d.ts.map +1 -1
  23. package/dist/hooks/useResponseBody.js +4 -4
  24. package/dist/hooks/useSidebar.d.ts +1 -1
  25. package/dist/hooks/useSidebar.d.ts.map +1 -1
  26. package/dist/index.d.ts +2 -2
  27. package/dist/index.d.ts.map +1 -1
  28. package/dist/layouts/App/ApiClientApp.vue.js +5 -5
  29. package/dist/layouts/App/MainLayout.vue.js +4 -4
  30. package/dist/layouts/App/create-api-client-app.d.ts +12 -12
  31. package/dist/layouts/App/index.d.ts +1 -1
  32. package/dist/layouts/App/index.d.ts.map +1 -1
  33. package/dist/layouts/Web/ApiClientWeb.vue.js +6 -6
  34. package/dist/layouts/Web/create-api-client-web.d.ts +12 -12
  35. package/dist/layouts/Web/index.d.ts +1 -1
  36. package/dist/layouts/Web/index.d.ts.map +1 -1
  37. package/dist/libs/create-client.d.ts +12 -12
  38. package/dist/libs/get-request-uid-by-path-method.d.ts +1 -1
  39. package/dist/libs/get-request-uid-by-path-method.d.ts.map +1 -1
  40. package/dist/libs/hot-keys.d.ts +2 -2
  41. package/dist/libs/hot-keys.d.ts.map +1 -1
  42. package/dist/libs/importers/curl.d.ts.map +1 -1
  43. package/dist/libs/index.d.ts +14 -15
  44. package/dist/libs/index.d.ts.map +1 -1
  45. package/dist/libs/index.js +33 -33
  46. package/dist/libs/parse-curl.js +4 -4
  47. package/dist/libs/send-request/create-fetch-body.d.ts +1 -1
  48. package/dist/libs/send-request/create-fetch-body.d.ts.map +1 -1
  49. package/dist/libs/send-request/create-fetch-body.js +1 -1
  50. package/dist/libs/send-request/create-fetch-headers.d.ts.map +1 -1
  51. package/dist/libs/send-request/create-fetch-query-params.d.ts.map +1 -1
  52. package/dist/libs/send-request/create-fetch-query-params.js +2 -1
  53. package/dist/libs/send-request/index.d.ts +1 -1
  54. package/dist/libs/send-request/index.d.ts.map +1 -1
  55. package/dist/libs/send-request/index.js +4 -4
  56. package/dist/libs/send-request/set-request-cookies.d.ts.map +1 -1
  57. package/dist/libs/send-request/set-request-cookies.js +4 -4
  58. package/dist/store/active-entities.d.ts +1 -1
  59. package/dist/store/collections.d.ts +1 -1
  60. package/dist/store/collections.d.ts.map +1 -1
  61. package/dist/store/collections.js +4 -4
  62. package/dist/store/environment.d.ts +1 -1
  63. package/dist/store/environment.d.ts.map +1 -1
  64. package/dist/store/environment.js +4 -4
  65. package/dist/store/import-spec.d.ts +2 -2
  66. package/dist/store/import-spec.d.ts.map +1 -1
  67. package/dist/store/index.d.ts +1 -1
  68. package/dist/store/index.d.ts.map +1 -1
  69. package/dist/store/request-example.d.ts +1 -1
  70. package/dist/store/request-example.d.ts.map +1 -1
  71. package/dist/store/request-example.js +6 -6
  72. package/dist/store/requests.d.ts +1 -1
  73. package/dist/store/requests.d.ts.map +1 -1
  74. package/dist/store/requests.js +8 -8
  75. package/dist/store/security-schemes.d.ts +1 -1
  76. package/dist/store/security-schemes.d.ts.map +1 -1
  77. package/dist/store/security-schemes.js +4 -4
  78. package/dist/store/servers.d.ts +1 -1
  79. package/dist/store/servers.d.ts.map +1 -1
  80. package/dist/store/servers.js +4 -4
  81. package/dist/store/store.d.ts +12 -12
  82. package/dist/store/tags.d.ts +1 -1
  83. package/dist/store/tags.d.ts.map +1 -1
  84. package/dist/store/tags.js +5 -5
  85. package/dist/store/workspace.d.ts +13 -13
  86. package/dist/store/workspace.d.ts.map +1 -1
  87. package/dist/store/workspace.js +7 -7
  88. package/dist/style.css +1 -1
  89. package/dist/v2/blocks/operation-block/OperationBlock.vue.d.ts +4 -5
  90. package/dist/v2/blocks/operation-block/OperationBlock.vue.d.ts.map +1 -1
  91. package/dist/v2/blocks/operation-block/OperationBlock.vue.js +17 -16
  92. package/dist/v2/blocks/operation-block/helpers/build-request-cookie-header.d.ts +3 -3
  93. package/dist/v2/blocks/operation-block/helpers/build-request-cookie-header.d.ts.map +1 -1
  94. package/dist/v2/blocks/operation-block/helpers/build-request-cookie-header.js +22 -22
  95. package/dist/v2/blocks/operation-block/helpers/build-request-parameters.d.ts.map +1 -1
  96. package/dist/v2/blocks/operation-block/helpers/build-request-parameters.js +14 -13
  97. package/dist/v2/blocks/operation-block/helpers/build-request.d.ts.map +1 -1
  98. package/dist/v2/blocks/operation-block/helpers/build-request.js +43 -41
  99. package/dist/v2/blocks/operation-block/helpers/filter-global-cookies.d.ts +14 -0
  100. package/dist/v2/blocks/operation-block/helpers/filter-global-cookies.d.ts.map +1 -0
  101. package/dist/v2/blocks/operation-block/helpers/filter-global-cookies.js +14 -0
  102. package/dist/v2/blocks/operation-block/helpers/get-resolved-url.d.ts +25 -0
  103. package/dist/v2/blocks/operation-block/helpers/get-resolved-url.d.ts.map +1 -0
  104. package/dist/v2/blocks/operation-block/helpers/get-resolved-url.js +17 -0
  105. package/dist/v2/blocks/operation-code-sample/components/OperationCodeSample.vue.d.ts +10 -0
  106. package/dist/v2/blocks/operation-code-sample/components/OperationCodeSample.vue.d.ts.map +1 -1
  107. package/dist/v2/blocks/operation-code-sample/components/OperationCodeSample.vue.js +1 -1
  108. package/dist/v2/blocks/operation-code-sample/components/OperationCodeSample.vue2.js +29 -25
  109. package/dist/v2/blocks/operation-code-sample/helpers/generate-code-snippet.d.ts +6 -1
  110. package/dist/v2/blocks/operation-code-sample/helpers/generate-code-snippet.d.ts.map +1 -1
  111. package/dist/v2/blocks/operation-code-sample/helpers/generate-code-snippet.js +27 -23
  112. package/dist/v2/blocks/operation-code-sample/helpers/operation-to-har/operation-to-har.d.ts +10 -1
  113. package/dist/v2/blocks/operation-code-sample/helpers/operation-to-har/operation-to-har.d.ts.map +1 -1
  114. package/dist/v2/blocks/operation-code-sample/helpers/operation-to-har/operation-to-har.js +48 -39
  115. package/dist/v2/blocks/operation-code-sample/helpers/operation-to-har/process-parameters.d.ts.map +1 -1
  116. package/dist/v2/blocks/operation-code-sample/helpers/operation-to-har/process-parameters.js +49 -46
  117. package/dist/v2/blocks/operation-code-sample/helpers/operation-to-har/process-server-url.d.ts +1 -1
  118. package/dist/v2/blocks/operation-code-sample/helpers/operation-to-har/process-server-url.d.ts.map +1 -1
  119. package/dist/v2/blocks/operation-code-sample/helpers/operation-to-har/process-server-url.js +1 -1
  120. package/dist/v2/blocks/request-block/RequestBlock.vue.d.ts +6 -2
  121. package/dist/v2/blocks/request-block/RequestBlock.vue.d.ts.map +1 -1
  122. package/dist/v2/blocks/request-block/RequestBlock.vue.js +2 -2
  123. package/dist/v2/blocks/request-block/RequestBlock.vue2.js +200 -115
  124. package/dist/v2/blocks/request-block/components/RequestBody.vue.d.ts +4 -4
  125. package/dist/v2/blocks/request-block/components/RequestCodeSnippet.vue.d.ts.map +1 -1
  126. package/dist/v2/blocks/request-block/components/RequestCodeSnippet.vue.js +21 -17
  127. package/dist/v2/blocks/request-block/components/RequestParams.vue.d.ts +16 -10
  128. package/dist/v2/blocks/request-block/components/RequestParams.vue.d.ts.map +1 -1
  129. package/dist/v2/blocks/request-block/components/RequestParams.vue.js +32 -45
  130. package/dist/v2/blocks/request-block/components/RequestTable.vue.d.ts +16 -13
  131. package/dist/v2/blocks/request-block/components/RequestTable.vue.d.ts.map +1 -1
  132. package/dist/v2/blocks/request-block/components/RequestTable.vue.js +4 -4
  133. package/dist/v2/blocks/request-block/components/RequestTable.vue2.js +32 -33
  134. package/dist/v2/blocks/request-block/components/RequestTableRow.vue.d.ts +33 -18
  135. package/dist/v2/blocks/request-block/components/RequestTableRow.vue.d.ts.map +1 -1
  136. package/dist/v2/blocks/request-block/components/RequestTableRow.vue.js +106 -106
  137. package/dist/v2/blocks/request-block/helpers/create-parameter-handlers.d.ts +10 -5
  138. package/dist/v2/blocks/request-block/helpers/create-parameter-handlers.d.ts.map +1 -1
  139. package/dist/v2/blocks/request-block/helpers/create-parameter-handlers.js +60 -31
  140. package/dist/v2/blocks/request-block/helpers/get-default-headers.d.ts +41 -0
  141. package/dist/v2/blocks/request-block/helpers/get-default-headers.d.ts.map +1 -0
  142. package/dist/v2/blocks/request-block/helpers/get-default-headers.js +25 -0
  143. package/dist/v2/blocks/request-block/helpers/group-by.d.ts +1 -1
  144. package/dist/v2/blocks/request-block/helpers/group-by.d.ts.map +1 -1
  145. package/dist/v2/blocks/request-block/helpers/group-by.js +6 -3
  146. package/dist/v2/blocks/request-block/helpers/is-param-disabled.d.ts +13 -0
  147. package/dist/v2/blocks/request-block/helpers/is-param-disabled.d.ts.map +1 -0
  148. package/dist/v2/blocks/request-block/helpers/is-param-disabled.js +7 -0
  149. package/dist/v2/blocks/scalar-address-bar-block/components/AddressBar.vue.d.ts.map +1 -1
  150. package/dist/v2/blocks/scalar-address-bar-block/components/AddressBar.vue.js +1 -1
  151. package/dist/v2/blocks/scalar-address-bar-block/components/AddressBar.vue2.js +61 -63
  152. package/dist/v2/blocks/scalar-auth-selector-block/components/AuthSelector.vue.d.ts +1 -2
  153. package/dist/v2/blocks/scalar-auth-selector-block/components/AuthSelector.vue.d.ts.map +1 -1
  154. package/dist/v2/blocks/scalar-auth-selector-block/components/OAuth2.vue.d.ts +2 -2
  155. package/dist/v2/blocks/scalar-auth-selector-block/components/OAuthScopesInput.vue.d.ts +2 -2
  156. package/dist/v2/blocks/scalar-auth-selector-block/components/RequestAuthDataTable.vue.d.ts +1 -2
  157. package/dist/v2/blocks/scalar-auth-selector-block/components/RequestAuthDataTable.vue.d.ts.map +1 -1
  158. package/dist/v2/blocks/scalar-auth-selector-block/components/RequestAuthTab.vue.d.ts +2 -2
  159. package/dist/v2/components/code-input/CodeInput.vue.d.ts +2 -0
  160. package/dist/v2/components/code-input/CodeInput.vue.d.ts.map +1 -1
  161. package/dist/v2/components/code-input/CodeInput.vue.js +2 -2
  162. package/dist/v2/components/code-input/CodeInput.vue2.js +57 -51
  163. package/dist/v2/features/app/App.vue.js +6 -6
  164. package/dist/v2/features/app/app-events.d.ts +5 -9
  165. package/dist/v2/features/app/app-events.d.ts.map +1 -1
  166. package/dist/v2/features/app/app-events.js +146 -120
  167. package/dist/v2/features/app/app-state.d.ts.map +1 -1
  168. package/dist/v2/features/app/app-state.js +69 -71
  169. package/dist/v2/features/app/components/AppSidebar.vue.js +1 -1
  170. package/dist/v2/features/app/components/AppSidebar.vue2.js +5 -5
  171. package/dist/v2/features/modal/Modal.vue.d.ts.map +1 -1
  172. package/dist/v2/features/modal/Modal.vue.js +1 -1
  173. package/dist/v2/features/modal/Modal.vue2.js +21 -22
  174. package/dist/v2/features/modal/index.d.ts +1 -1
  175. package/dist/v2/features/modal/index.d.ts.map +1 -1
  176. package/dist/v2/features/modal/index.js +4 -4
  177. package/dist/v2/features/modal/modal-events.d.ts +13 -0
  178. package/dist/v2/features/modal/modal-events.d.ts.map +1 -0
  179. package/dist/v2/features/modal/modal-events.js +31 -0
  180. package/dist/v2/features/operation/Operation.vue.d.ts.map +1 -1
  181. package/dist/v2/features/operation/Operation.vue.js +30 -43
  182. package/dist/v2/workspace-events.d.ts +25 -0
  183. package/dist/v2/workspace-events.d.ts.map +1 -0
  184. package/dist/v2/workspace-events.js +202 -0
  185. package/dist/views/Components/CodeSnippet/helpers/convert-to-har-request.d.ts.map +1 -1
  186. package/dist/views/Components/CodeSnippet/helpers/get-snippet.d.ts +1 -1
  187. package/dist/views/Components/CodeSnippet/helpers/get-snippet.d.ts.map +1 -1
  188. package/dist/views/Cookies/Cookies.vue2.js +3 -3
  189. package/dist/views/Environment/handle-drag.d.ts +1 -1
  190. package/dist/views/Environment/handle-drag.d.ts.map +1 -1
  191. package/dist/views/Request/RequestRoot.vue2.js +9 -9
  192. package/dist/views/Request/RequestSection/RequestAuth/RequestAuthDataTable.vue2.js +4 -4
  193. package/dist/views/Request/RequestSection/RequestCodeExample.vue2.js +4 -4
  194. package/dist/views/Request/RequestSection/RequestSection.vue2.js +5 -5
  195. package/dist/views/Request/RequestSection/helpers/update-scheme.d.ts.map +1 -1
  196. package/dist/views/Request/RequestSidebar.vue2.js +6 -6
  197. package/dist/views/Request/RequestSidebarItem.vue2.js +6 -6
  198. package/dist/views/Request/RequestSubpageHeader.vue2.js +4 -4
  199. package/dist/views/Request/ResponseSection/ResponseEmpty.vue2.js +1 -1
  200. package/dist/views/Request/ResponseSection/index.d.ts +1 -1
  201. package/dist/views/Request/ResponseSection/index.d.ts.map +1 -1
  202. package/dist/views/Request/ResponseSection/index.js +4 -4
  203. package/dist/views/Request/consts/index.d.ts +2 -3
  204. package/dist/views/Request/consts/index.d.ts.map +1 -1
  205. package/dist/views/Request/consts/new-auth-options.d.ts +1 -1
  206. package/dist/views/Request/consts/new-auth-options.d.ts.map +1 -1
  207. package/dist/views/Request/handle-drag.d.ts +1 -1
  208. package/dist/views/Request/handle-drag.d.ts.map +1 -1
  209. package/dist/views/Request/hooks/useOpenApiWatcher.d.ts.map +1 -1
  210. package/dist/views/Request/hooks/useOpenApiWatcher.js +14 -14
  211. package/dist/views/Request/libs/auth.d.ts +1 -1
  212. package/dist/views/Request/libs/auth.d.ts.map +1 -1
  213. package/dist/views/Request/libs/index.d.ts +3 -3
  214. package/dist/views/Request/libs/index.d.ts.map +1 -1
  215. package/dist/views/Request/libs/oauth2.js +1 -1
  216. package/dist/views/Request/libs/watch-mode.js +6 -6
  217. package/dist/views/Request/types/index.d.ts +1 -1
  218. package/dist/views/Request/types/index.d.ts.map +1 -1
  219. package/package.json +13 -13
  220. package/dist/v2/features/modal/hooks/use-workspace-client-modal-events.d.ts +0 -18
  221. package/dist/v2/features/modal/hooks/use-workspace-client-modal-events.d.ts.map +0 -1
  222. package/dist/v2/features/modal/hooks/use-workspace-client-modal-events.js +0 -39
  223. package/dist/v2/features/operation/helpers/get-operation-header.js +0 -12
@@ -1,4 +1,4 @@
1
- import { defineComponent as $, computed as o, ref as b, watch as D, useId as I, createBlock as u, createCommentVNode as d, openBlock as s, unref as a, withCtx as n, createVNode as r, createSlots as N, createElementVNode as x, createElementBlock as g, renderSlot as p, createTextVNode as W, toDisplayString as R } from "vue";
1
+ import { defineComponent as $, computed as o, ref as b, watch as D, useId as I, createBlock as u, createCommentVNode as d, openBlock as s, unref as a, withCtx as n, createVNode as r, createSlots as N, createElementVNode as g, createElementBlock as x, renderSlot as y, createTextVNode as W, toDisplayString as R } from "vue";
2
2
  import { ScalarCard as S, ScalarCardHeader as z, ScalarCombobox as U, ScalarButton as A, ScalarCardSection as T, ScalarCodeBlock as F, ScalarVirtualText as M, ScalarCardFooter as K } from "@scalar/components";
3
3
  import { freezeElement as Z } from "@scalar/helpers/dom/freeze-element";
4
4
  import { ScalarIconCaretDown as G } from "@scalar/icons";
@@ -18,6 +18,7 @@ const te = ["innerHTML"], le = ["id"], ae = {
18
18
  ...ne,
19
19
  __name: "OperationCodeSample",
20
20
  props: {
21
+ integration: {},
21
22
  clientOptions: {},
22
23
  selectedClient: {},
23
24
  selectedServer: { default: null },
@@ -30,7 +31,8 @@ const te = ["innerHTML"], le = ["id"], ae = {
30
31
  operation: {},
31
32
  fallback: { type: Boolean },
32
33
  generateLabel: { type: Function },
33
- isWebhook: { type: Boolean }
34
+ isWebhook: { type: Boolean },
35
+ globalCookies: {}
34
36
  },
35
37
  setup(e) {
36
38
  const i = o(() => {
@@ -50,7 +52,7 @@ const te = ["innerHTML"], le = ["id"], ae = {
50
52
  l && (c.value = l);
51
53
  }
52
54
  );
53
- const y = o(() => {
55
+ const k = o(() => {
54
56
  if (!e.isWebhook) return null;
55
57
  try {
56
58
  return P({
@@ -62,7 +64,8 @@ const te = ["innerHTML"], le = ["id"], ae = {
62
64
  } catch (t) {
63
65
  return console.error("[webhookHar]", t), null;
64
66
  }
65
- }), h = o(() => e.isWebhook ? y.value?.postData?.text ?? "" : _({
67
+ }), h = o(() => e.isWebhook ? k.value?.postData?.text ?? "" : _({
68
+ includeDefaultHeaders: e.integration === "client",
66
69
  clientId: c.value?.id,
67
70
  customCodeSamples: C.value,
68
71
  operation: e.operation,
@@ -71,42 +74,43 @@ const te = ["innerHTML"], le = ["id"], ae = {
71
74
  contentType: e.selectedContentType,
72
75
  server: e.selectedServer,
73
76
  securitySchemes: e.securitySchemes,
74
- example: m.value
77
+ example: m.value,
78
+ globalCookies: e.globalCookies
75
79
  })), B = o(() => e.isWebhook ? w.value : c.value?.lang), w = o(() => {
76
- if (!y.value?.postData) return "json";
77
- const t = y.value.postData.mimeType;
80
+ if (!k.value?.postData) return "json";
81
+ const t = k.value.postData.mimeType;
78
82
  return t?.includes("json") ? "json" : t?.includes("xml") ? "xml" : t?.includes("yaml") || t?.includes("yml") ? "yaml" : t?.includes("text/plain") ? "text" : "json";
79
- }), O = o(() => Y(e.securitySchemes)), k = b(null), j = (t) => {
80
- if (k.value) {
81
- const l = Z(k.value.$el);
83
+ }), H = o(() => Y(e.securitySchemes)), p = b(null), O = (t) => {
84
+ if (p.value) {
85
+ const l = Z(p.value.$el);
82
86
  setTimeout(() => {
83
87
  l();
84
88
  }, 300);
85
89
  }
86
90
  c.value = t, t && !t.id.startsWith("custom") && e.eventBus.emit("workspace:update:selected-client", t.id);
87
- }, E = 2e4, H = o(
88
- () => (h.value.length ?? 0) > E
91
+ }, j = 2e4, E = o(
92
+ () => (h.value.length ?? 0) > j
89
93
  ), L = I();
90
94
  return (t, l) => h.value ? (s(), u(a(S), {
91
95
  key: 0,
92
96
  ref_key: "elem",
93
- ref: k,
97
+ ref: p,
94
98
  class: "request-card dark-mode"
95
99
  }, {
96
100
  default: n(() => [
97
101
  r(a(z), { class: "pr-2.5" }, N({
98
102
  default: n(() => [
99
- l[2] || (l[2] = x("span", { class: "sr-only" }, "Request Example for", -1)),
103
+ l[2] || (l[2] = g("span", { class: "sr-only" }, "Request Example for", -1)),
100
104
  r(V, {
101
105
  as: "span",
102
106
  class: "request-method",
103
107
  method: e.method
104
108
  }, null, 8, ["method"]),
105
- e.generateLabel ? (s(), g("span", {
109
+ e.generateLabel ? (s(), x("span", {
106
110
  key: 0,
107
111
  innerHTML: e.generateLabel()
108
112
  }, null, 8, te)) : d("", !0),
109
- p(t.$slots, "header", {}, void 0, !0)
113
+ y(t.$slots, "header", {}, void 0, !0)
110
114
  ]),
111
115
  _: 2
112
116
  }, [
@@ -119,7 +123,7 @@ const te = ["innerHTML"], le = ["id"], ae = {
119
123
  options: f.value,
120
124
  placement: "bottom-end",
121
125
  teleport: "",
122
- "onUpdate:modelValue": l[0] || (l[0] = (v) => j(v))
126
+ "onUpdate:modelValue": l[0] || (l[0] = (v) => O(v))
123
127
  }, {
124
128
  default: n(() => [
125
129
  r(a(A), {
@@ -145,11 +149,11 @@ const te = ["innerHTML"], le = ["id"], ae = {
145
149
  ]), 1024),
146
150
  r(a(T), { class: "request-editor-section custom-scroll p-0" }, {
147
151
  default: n(() => [
148
- x("div", {
152
+ g("div", {
149
153
  id: `${a(L)}-example`,
150
154
  class: "code-snippet"
151
155
  }, [
152
- H.value ? (s(), u(a(M), {
156
+ E.value ? (s(), u(a(M), {
153
157
  key: 1,
154
158
  containerClass: "custom-scroll scalar-code-block border rounded-b flex flex-1 max-h-screen",
155
159
  contentClass: "language-plaintext whitespace-pre font-code text-base",
@@ -159,7 +163,7 @@ const te = ["innerHTML"], le = ["id"], ae = {
159
163
  key: 0,
160
164
  class: "bg-b-2 !min-h-full -outline-offset-2",
161
165
  content: h.value,
162
- hideCredentials: O.value,
166
+ hideCredentials: H.value,
163
167
  lang: B.value,
164
168
  lineNumbers: ""
165
169
  }, null, 8, ["content", "hideCredentials", "lang"]))
@@ -172,7 +176,7 @@ const te = ["innerHTML"], le = ["id"], ae = {
172
176
  class: "request-card-footer bg-b-3"
173
177
  }, {
174
178
  default: n(() => [
175
- Object.keys(i.value).length > 1 ? (s(), g("div", ae, [
179
+ Object.keys(i.value).length > 1 ? (s(), x("div", ae, [
176
180
  Object.keys(i.value).length ? (s(), u(ee, {
177
181
  key: 0,
178
182
  modelValue: m.value,
@@ -180,7 +184,7 @@ const te = ["innerHTML"], le = ["id"], ae = {
180
184
  examples: i.value
181
185
  }, null, 8, ["modelValue", "examples"])) : d("", !0)
182
186
  ])) : d("", !0),
183
- p(t.$slots, "footer", {}, void 0, !0)
187
+ y(t.$slots, "footer", {}, void 0, !0)
184
188
  ]),
185
189
  _: 3
186
190
  })) : d("", !0)
@@ -193,15 +197,15 @@ const te = ["innerHTML"], le = ["id"], ae = {
193
197
  default: n(() => [
194
198
  r(a(T), { class: "request-card-simple" }, {
195
199
  default: n(() => [
196
- x("div", oe, [
200
+ g("div", oe, [
197
201
  r(V, {
198
202
  as: "span",
199
203
  class: "request-method",
200
204
  method: e.method
201
205
  }, null, 8, ["method"]),
202
- p(t.$slots, "header", {}, void 0, !0)
206
+ y(t.$slots, "header", {}, void 0, !0)
203
207
  ]),
204
- p(t.$slots, "footer", {}, void 0, !0)
208
+ y(t.$slots, "footer", {}, void 0, !0)
205
209
  ]),
206
210
  _: 3
207
211
  })
@@ -1,5 +1,6 @@
1
1
  import type { HttpMethod } from '@scalar/helpers/http/http-methods';
2
2
  import type { AvailableClient } from '@scalar/snippetz';
3
+ import type { XScalarCookie } from '@scalar/workspace-store/schemas/extensions/general/x-scalar-cookies';
3
4
  import type { XCodeSample } from '@scalar/workspace-store/schemas/extensions/operation';
4
5
  import type { OperationObject, SecuritySchemeObject, ServerObject } from '@scalar/workspace-store/schemas/v3.1/strict/openapi-document';
5
6
  import { type CustomCodeSampleId } from './generate-client-options.js';
@@ -22,8 +23,12 @@ type GenerateCodeSnippetProps = {
22
23
  securitySchemes: SecuritySchemeObject[];
23
24
  /** The server object defining the base URL for the API request. */
24
25
  server: ServerObject | null;
26
+ /** Workspace + document cookies */
27
+ globalCookies?: XScalarCookie[];
28
+ /** Whether to include default headers (e.g., Accept, Content-Type) automatically. */
29
+ includeDefaultHeaders?: boolean;
25
30
  };
26
31
  /** Generate the code snippet for the selected example OR operation */
27
- export declare const generateCodeSnippet: ({ clientId, customCodeSamples, operation, method, path, example, contentType, server, securitySchemes, }: GenerateCodeSnippetProps) => string;
32
+ export declare const generateCodeSnippet: ({ clientId, customCodeSamples, includeDefaultHeaders, operation, method, path, example, contentType, server, securitySchemes, globalCookies, }: GenerateCodeSnippetProps) => string;
28
33
  export {};
29
34
  //# sourceMappingURL=generate-code-snippet.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"generate-code-snippet.d.ts","sourceRoot":"","sources":["../../../../../src/v2/blocks/operation-code-sample/helpers/generate-code-snippet.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mCAAmC,CAAA;AACnE,OAAO,KAAK,EAAE,eAAe,EAAsB,MAAM,kBAAkB,CAAA;AAC3E,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sDAAsD,CAAA;AACvF,OAAO,KAAK,EACV,eAAe,EACf,oBAAoB,EACpB,YAAY,EACb,MAAM,8DAA8D,CAAA;AAKrE,OAAO,EAAE,KAAK,kBAAkB,EAAoB,MAAM,2BAA2B,CAAA;AAErF,KAAK,wBAAwB,GAAG;IAC9B,wGAAwG;IACxG,QAAQ,EAAE,eAAe,GAAG,kBAAkB,GAAG,SAAS,CAAA;IAC1D,qFAAqF;IACrF,WAAW,EAAE,MAAM,GAAG,SAAS,CAAA;IAC/B,mFAAmF;IACnF,iBAAiB,EAAE,WAAW,EAAE,CAAA;IAChC,0EAA0E;IAC1E,OAAO,EAAE,MAAM,GAAG,SAAS,CAAA;IAC3B,gEAAgE;IAChE,MAAM,EAAE,UAAU,CAAA;IAClB,wEAAwE;IACxE,SAAS,EAAE,eAAe,CAAA;IAC1B,mDAAmD;IACnD,IAAI,EAAE,MAAM,CAAA;IACZ,iFAAiF;IACjF,eAAe,EAAE,oBAAoB,EAAE,CAAA;IACvC,mEAAmE;IACnE,MAAM,EAAE,YAAY,GAAG,IAAI,CAAA;CAC5B,CAAA;AAED,sEAAsE;AACtE,eAAO,MAAM,mBAAmB,GAAI,0GAUjC,wBAAwB,KAAG,MAqC7B,CAAA"}
1
+ {"version":3,"file":"generate-code-snippet.d.ts","sourceRoot":"","sources":["../../../../../src/v2/blocks/operation-code-sample/helpers/generate-code-snippet.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mCAAmC,CAAA;AACnE,OAAO,KAAK,EAAE,eAAe,EAAsB,MAAM,kBAAkB,CAAA;AAC3E,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qEAAqE,CAAA;AACxG,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sDAAsD,CAAA;AACvF,OAAO,KAAK,EACV,eAAe,EACf,oBAAoB,EACpB,YAAY,EACb,MAAM,8DAA8D,CAAA;AAKrE,OAAO,EAAE,KAAK,kBAAkB,EAAoB,MAAM,2BAA2B,CAAA;AAErF,KAAK,wBAAwB,GAAG;IAC9B,wGAAwG;IACxG,QAAQ,EAAE,eAAe,GAAG,kBAAkB,GAAG,SAAS,CAAA;IAC1D,qFAAqF;IACrF,WAAW,EAAE,MAAM,GAAG,SAAS,CAAA;IAC/B,mFAAmF;IACnF,iBAAiB,EAAE,WAAW,EAAE,CAAA;IAChC,0EAA0E;IAC1E,OAAO,EAAE,MAAM,GAAG,SAAS,CAAA;IAC3B,gEAAgE;IAChE,MAAM,EAAE,UAAU,CAAA;IAClB,wEAAwE;IACxE,SAAS,EAAE,eAAe,CAAA;IAC1B,mDAAmD;IACnD,IAAI,EAAE,MAAM,CAAA;IACZ,iFAAiF;IACjF,eAAe,EAAE,oBAAoB,EAAE,CAAA;IACvC,mEAAmE;IACnE,MAAM,EAAE,YAAY,GAAG,IAAI,CAAA;IAC3B,mCAAmC;IACnC,aAAa,CAAC,EAAE,aAAa,EAAE,CAAA;IAC/B,qFAAqF;IACrF,qBAAqB,CAAC,EAAE,OAAO,CAAA;CAChC,CAAA;AAED,sEAAsE;AACtE,eAAO,MAAM,mBAAmB,GAAI,gJAYjC,wBAAwB,KAAG,MAuC7B,CAAA"}
@@ -1,36 +1,40 @@
1
- import { operationToHar as C } from "./operation-to-har/operation-to-har.js";
2
- import { getSnippet as y } from "../../../../views/Components/CodeSnippet/helpers/get-snippet.js";
3
- import { generateCustomId as S } from "./generate-client-options.js";
4
- const E = ({
1
+ import { operationToHar as y } from "./operation-to-har/operation-to-har.js";
2
+ import { getSnippet as S } from "../../../../views/Components/CodeSnippet/helpers/get-snippet.js";
3
+ import { generateCustomId as h } from "./generate-client-options.js";
4
+ const q = ({
5
5
  clientId: e,
6
6
  customCodeSamples: o,
7
- operation: n,
8
- method: p,
9
- path: s,
10
- example: a,
11
- contentType: i,
12
- server: g,
13
- securitySchemes: m
7
+ includeDefaultHeaders: n = !1,
8
+ operation: p,
9
+ method: s,
10
+ path: a,
11
+ example: i,
12
+ contentType: g,
13
+ server: m,
14
+ securitySchemes: u,
15
+ globalCookies: c
14
16
  }) => {
15
17
  try {
16
18
  if (!e)
17
19
  return "";
18
20
  if (e.startsWith("custom"))
19
- return o.find((d) => S(d) === e)?.source ?? "Custom example not found";
20
- const r = C({
21
- operation: n,
22
- contentType: i,
23
- method: p,
24
- path: s,
25
- server: g,
26
- securitySchemes: m,
27
- example: a
28
- }), [u, c] = e.split("/"), [t, f] = y(u, c, r);
29
- return t ? (console.error("[generateCodeSnippet]", t), t.message ?? "Error generating code snippet") : f;
21
+ return o.find((l) => h(l) === e)?.source ?? "Custom example not found";
22
+ const r = y({
23
+ operation: p,
24
+ contentType: g,
25
+ method: s,
26
+ path: a,
27
+ server: m,
28
+ securitySchemes: u,
29
+ example: i,
30
+ globalCookies: c,
31
+ includeDefaultHeaders: n
32
+ }), [f, d] = e.split("/"), [t, C] = S(f, d, r);
33
+ return t ? (console.error("[generateCodeSnippet]", t), t.message ?? "Error generating code snippet") : C;
30
34
  } catch (r) {
31
35
  return console.error("[generateCodeSnippet]", r), "Error generating code snippet";
32
36
  }
33
37
  };
34
38
  export {
35
- E as generateCodeSnippet
39
+ q as generateCodeSnippet
36
40
  };
@@ -1,4 +1,5 @@
1
1
  import type { HttpMethod } from '@scalar/helpers/http/http-methods';
2
+ import type { XScalarCookie } from '@scalar/workspace-store/schemas/extensions/general/x-scalar-cookies';
2
3
  import type { OperationObject, SecuritySchemeObject, ServerObject } from '@scalar/workspace-store/schemas/v3.1/strict/openapi-document';
3
4
  import type { Request as HarRequest } from 'har-format';
4
5
  export type OperationToHarProps = {
@@ -25,6 +26,14 @@ export type OperationToHarProps = {
25
26
  server?: ServerObject | null;
26
27
  /** OpenAPI SecurityScheme objects which are applicable to the operation */
27
28
  securitySchemes?: SecuritySchemeObject[];
29
+ /** Workspace + document cookies */
30
+ globalCookies?: XScalarCookie[];
31
+ /**
32
+ * Whether to include default headers (e.g., Accept, Content-Type) automatically.
33
+ * If false, default headers will be omitted from the HAR request.
34
+ * @default true
35
+ */
36
+ includeDefaultHeaders?: boolean;
28
37
  };
29
38
  /**
30
39
  * Converts an OpenAPI Operation to a HarRequest format for generating HTTP request snippets.
@@ -48,5 +57,5 @@ export type OperationToHarProps = {
48
57
  * @see https://w3c.github.io/web-performance/specs/HAR/Overview.html
49
58
  * @see https://spec.openapis.org/oas/v3.1.0#operation-object
50
59
  */
51
- export declare const operationToHar: ({ operation, contentType, method, path, server, example, securitySchemes, }: OperationToHarProps) => HarRequest;
60
+ export declare const operationToHar: ({ includeDefaultHeaders, operation, contentType, method, path, server, example, securitySchemes, globalCookies, }: OperationToHarProps) => HarRequest;
52
61
  //# sourceMappingURL=operation-to-har.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"operation-to-har.d.ts","sourceRoot":"","sources":["../../../../../../src/v2/blocks/operation-code-sample/helpers/operation-to-har/operation-to-har.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mCAAmC,CAAA;AAEnE,OAAO,KAAK,EACV,eAAe,EACf,oBAAoB,EACpB,YAAY,EACb,MAAM,8DAA8D,CAAA;AACrE,OAAO,KAAK,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,YAAY,CAAA;AAOvD,MAAM,MAAM,mBAAmB,GAAG;IAChC,+BAA+B;IAC/B,SAAS,EAAE,eAAe,CAAA;IAC1B,mCAAmC;IACnC,MAAM,EAAE,UAAU,CAAA;IAClB,4BAA4B;IAC5B,IAAI,EAAE,MAAM,CAAA;IACZ;;;;OAIG;IACH,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB;;;;;OAKG;IACH,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,4BAA4B;IAC5B,MAAM,CAAC,EAAE,YAAY,GAAG,IAAI,CAAA;IAC5B,2EAA2E;IAC3E,eAAe,CAAC,EAAE,oBAAoB,EAAE,CAAA;CACzC,CAAA;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,eAAO,MAAM,cAAc,GAAI,6EAQ5B,mBAAmB,KAAG,UAgFxB,CAAA"}
1
+ {"version":3,"file":"operation-to-har.d.ts","sourceRoot":"","sources":["../../../../../../src/v2/blocks/operation-code-sample/helpers/operation-to-har/operation-to-har.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mCAAmC,CAAA;AAEnE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qEAAqE,CAAA;AACxG,OAAO,KAAK,EACV,eAAe,EACf,oBAAoB,EACpB,YAAY,EACb,MAAM,8DAA8D,CAAA;AACrE,OAAO,KAAK,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,YAAY,CAAA;AAUvD,MAAM,MAAM,mBAAmB,GAAG;IAChC,+BAA+B;IAC/B,SAAS,EAAE,eAAe,CAAA;IAC1B,mCAAmC;IACnC,MAAM,EAAE,UAAU,CAAA;IAClB,4BAA4B;IAC5B,IAAI,EAAE,MAAM,CAAA;IACZ;;;;OAIG;IACH,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB;;;;;OAKG;IACH,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,4BAA4B;IAC5B,MAAM,CAAC,EAAE,YAAY,GAAG,IAAI,CAAA;IAC5B,2EAA2E;IAC3E,eAAe,CAAC,EAAE,oBAAoB,EAAE,CAAA;IACxC,mCAAmC;IACnC,aAAa,CAAC,EAAE,aAAa,EAAE,CAAA;IAC/B;;;;OAIG;IACH,qBAAqB,CAAC,EAAE,OAAO,CAAA;CAChC,CAAA;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,eAAO,MAAM,cAAc,GAAI,mHAU5B,mBAAmB,KAAG,UAgGxB,CAAA"}
@@ -1,21 +1,30 @@
1
- import { getResolvedRef as f } from "@scalar/workspace-store/helpers/get-resolved-ref";
2
- import { processBody as y } from "./process-body.js";
3
- import { processParameters as l } from "./process-parameters.js";
4
- import { processSecuritySchemes as S } from "./process-security-schemes.js";
5
- import { processServerUrl as g } from "./process-server-url.js";
6
- const b = ({
1
+ import { getResolvedRef as k } from "@scalar/workspace-store/helpers/get-resolved-ref";
2
+ import { filterGlobalCookie as q } from "../../../operation-block/helpers/filter-global-cookies.js";
3
+ import { getDefaultHeaders as T } from "../../../request-block/helpers/get-default-headers.js";
4
+ import { processBody as C } from "./process-body.js";
5
+ import { processParameters as H } from "./process-parameters.js";
6
+ import { processSecuritySchemes as z } from "./process-security-schemes.js";
7
+ import { processServerUrl as D } from "./process-server-url.js";
8
+ const w = ({
9
+ includeDefaultHeaders: f = !1,
7
10
  operation: t,
8
- contentType: i,
9
- method: h,
10
- path: a,
11
- server: n,
12
- example: p,
13
- securitySchemes: m
11
+ contentType: l,
12
+ method: n,
13
+ path: p,
14
+ server: c = null,
15
+ example: a,
16
+ securitySchemes: d,
17
+ globalCookies: h
14
18
  }) => {
15
- const e = {
16
- method: h,
17
- url: a,
18
- headers: [],
19
+ const y = f ? T({
20
+ method: n,
21
+ operation: t,
22
+ exampleKey: a ?? "default",
23
+ hideDisabledHeaders: !0
24
+ }).filter((e) => !e.isOverridden) : [], g = t["x-scalar-disable-parameters"]?.["global-cookies"]?.[a ?? "default"] ?? {}, v = D(c, p), r = {
25
+ method: n,
26
+ url: v,
27
+ headers: y.map((e) => ({ name: e.name, value: e.defaultValue })),
19
28
  queryString: [],
20
29
  postData: void 0,
21
30
  httpVersion: "HTTP/1.1",
@@ -23,37 +32,37 @@ const b = ({
23
32
  headersSize: -1,
24
33
  bodySize: -1
25
34
  };
26
- if (n?.url && (e.url = g(n, a)), t.parameters) {
27
- const { url: r, headers: o, queryString: s, cookies: c } = l({
28
- harRequest: e,
35
+ if (t.parameters) {
36
+ const { url: e, headers: s, queryString: o, cookies: S } = H({
37
+ harRequest: r,
29
38
  parameters: t.parameters,
30
- example: p,
31
- contentType: i
32
- });
33
- e.url = r, e.headers = o, e.queryString = s, e.cookies = c;
39
+ example: a,
40
+ contentType: l
41
+ }), b = h?.filter((i) => q({ cookie: i, url: e, disabledGlobalCookies: g }))?.map((i) => ({ name: i.name, value: i.value })) ?? [];
42
+ r.url = e, r.headers = s, r.queryString = o, r.cookies = [...b, ...S];
34
43
  }
35
- const u = f(t.requestBody);
36
- if (u?.content) {
37
- const r = y({ requestBody: u, contentType: i, example: p });
38
- if (r && (e.postData = r, e.bodySize = r.text?.length ?? -1, r.mimeType)) {
39
- const o = e.headers.find(
40
- (s) => s.name.toLowerCase() === "content-type"
44
+ const m = k(t.requestBody);
45
+ if (m?.content) {
46
+ const e = C({ requestBody: m, contentType: l, example: a });
47
+ if (e && (r.postData = e, r.bodySize = e.text?.length ?? -1, e.mimeType)) {
48
+ const s = r.headers.find(
49
+ (o) => o.name.toLowerCase() === "content-type"
41
50
  );
42
- o && !o.value ? o.value = r.mimeType : o || e.headers.push({
51
+ s && !s.value ? s.value = e.mimeType : s || r.headers.push({
43
52
  name: "Content-Type",
44
- value: r.mimeType
53
+ value: e.mimeType
45
54
  });
46
55
  }
47
56
  }
48
- if (m) {
49
- const { headers: r, queryString: o, cookies: s } = S(m);
50
- e.headers.push(...r), e.queryString.push(...o), e.cookies.push(...s);
57
+ if (d) {
58
+ const { headers: e, queryString: s, cookies: o } = z(d);
59
+ r.headers.push(...e), r.queryString.push(...s), r.cookies.push(...o);
51
60
  }
52
- let d = 0;
53
- for (const r of e.headers)
54
- d += (r.name?.length ?? 0) + 2 + (r.value?.length ?? 0) + 2;
55
- return e.headersSize = d, e;
61
+ let u = 0;
62
+ for (const e of r.headers)
63
+ u += (e.name?.length ?? 0) + 2 + (e.value?.length ?? 0) + 2;
64
+ return r.headersSize = u, r;
56
65
  };
57
66
  export {
58
- b as operationToHar
67
+ w as operationToHar
59
68
  };
@@ -1 +1 @@
1
- {"version":3,"file":"process-parameters.d.ts","sourceRoot":"","sources":["../../../../../../src/v2/blocks/operation-code-sample/helpers/operation-to-har/process-parameters.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAmB,MAAM,8DAA8D,CAAA;AAEpH,OAAO,KAAK,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,YAAY,CAAA;AAIvD,KAAK,mBAAmB,GAAG;IACzB,GAAG,EAAE,MAAM,CAAA;IACX,OAAO,EAAE,UAAU,CAAC,SAAS,CAAC,CAAA;IAC9B,WAAW,EAAE,UAAU,CAAC,aAAa,CAAC,CAAA;IACtC,OAAO,EAAE,UAAU,CAAC,SAAS,CAAC,CAAA;CAC/B,CAAA;AA8DD;;;;;GAKG;AACH,eAAO,MAAM,iBAAiB,GAAI,mDAK/B;IACD,UAAU,EAAE,UAAU,CAAA;IACtB,UAAU,EAAE,eAAe,CAAC,YAAY,CAAC,CAAA;IACzC,qCAAqC;IACrC,OAAO,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IAC5B,WAAW,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;CACjC,KAAG,mBAsNH,CAAA"}
1
+ {"version":3,"file":"process-parameters.d.ts","sourceRoot":"","sources":["../../../../../../src/v2/blocks/operation-code-sample/helpers/operation-to-har/process-parameters.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAmB,MAAM,8DAA8D,CAAA;AAEpH,OAAO,KAAK,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,YAAY,CAAA;AAKvD,KAAK,mBAAmB,GAAG;IACzB,GAAG,EAAE,MAAM,CAAA;IACX,OAAO,EAAE,UAAU,CAAC,SAAS,CAAC,CAAA;IAC9B,WAAW,EAAE,UAAU,CAAC,aAAa,CAAC,CAAA;IACtC,OAAO,EAAE,UAAU,CAAC,SAAS,CAAC,CAAA;CAC/B,CAAA;AAuED;;;;;GAKG;AACH,eAAO,MAAM,iBAAiB,GAAI,mDAK/B;IACD,UAAU,EAAE,UAAU,CAAA;IACtB,UAAU,EAAE,eAAe,CAAC,YAAY,CAAC,CAAA;IACzC,qCAAqC;IACrC,OAAO,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IAC5B,WAAW,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;CACjC,KAAG,mBAqNH,CAAA"}
@@ -1,7 +1,8 @@
1
1
  import { getResolvedRef as d } from "@scalar/workspace-store/helpers/get-resolved-ref";
2
2
  import { getExampleFromSchema as p } from "../get-example-from-schema.js";
3
3
  import { getExample as h } from "../../../operation-block/helpers/get-example.js";
4
- const A = (e) => (e ?? []).map((o) => d(o)), g = (e) => {
4
+ import { isParamDisabled as A } from "../../../request-block/helpers/is-param-disabled.js";
5
+ const g = (e) => (e ?? []).map((o) => d(o)), S = (e) => {
5
6
  if (e.in === "header")
6
7
  return { style: "simple", explode: "explode" in e && e.explode !== void 0 ? e.explode : !1 };
7
8
  if (e.in === "cookie")
@@ -11,53 +12,55 @@ const A = (e) => (e ?? []).map((o) => d(o)), g = (e) => {
11
12
  query: "form",
12
13
  header: "simple",
13
14
  cookie: "form"
14
- }[e.in], t = "style" in e && e.style ? e.style : o, $ = "explode" in e && e.explode !== void 0 ? e.explode : t === "form";
15
- return { style: t, explode: $ };
16
- }, S = (e, o, t) => {
17
- const $ = h(e, o, t)?.value;
18
- if ($ !== void 0)
19
- return $;
20
- if ("schema" in e && e.schema) {
21
- const f = e.in === "path" ? { emptyString: `{${e.name}}` } : {};
22
- return p(d(e.schema), f);
23
- }
24
- }, w = ({
15
+ }[e.in], t = "style" in e && e.style ? e.style : o, y = "explode" in e && e.explode !== void 0 ? e.explode : t === "form";
16
+ return { style: t, explode: y };
17
+ }, k = (e, o, t) => {
18
+ const y = h(e, o, t);
19
+ if (A(e, y))
20
+ return;
21
+ if (y?.value !== void 0)
22
+ return y.value;
23
+ if (!("schema" in e) || !e.schema)
24
+ return;
25
+ const f = e.in === "path" ? { emptyString: `{${e.name}}` } : {};
26
+ return p(d(e.schema), f);
27
+ }, E = ({
25
28
  harRequest: e,
26
29
  parameters: o,
27
30
  example: t,
28
- contentType: $
31
+ contentType: y
29
32
  }) => {
30
33
  const f = [...e.headers], i = [...e.queryString];
31
- let r = e.url;
32
- const u = A(o);
34
+ let c = e.url;
35
+ const u = g(o);
33
36
  for (const s of u) {
34
37
  if (!s.in || !s.name)
35
38
  continue;
36
- const n = S(s, t, $);
39
+ const n = k(s, t, y);
37
40
  if (n === void 0)
38
41
  continue;
39
- const { style: b, explode: v } = g(s);
42
+ const { style: m, explode: v } = S(s);
40
43
  switch (s.in) {
41
44
  case "path": {
42
- r = k(r, s, n, b, v);
45
+ c = x(c, s, n, m, v);
43
46
  break;
44
47
  }
45
48
  case "query": {
46
- switch (b) {
49
+ switch (m) {
47
50
  case "form": {
48
51
  if (v)
49
52
  if (Array.isArray(n))
50
53
  for (const l of n)
51
54
  i.push({ name: s.name, value: String(l) });
52
55
  else if (typeof n == "object" && n !== null)
53
- for (const [l, c] of Object.entries(n))
54
- i.push({ name: l, value: String(c) });
56
+ for (const [l, r] of Object.entries(n))
57
+ i.push({ name: l, value: String(r) });
55
58
  else
56
59
  i.push({ name: s.name, value: String(n) });
57
60
  else if (Array.isArray(n))
58
61
  i.push({ name: s.name, value: n.join(",") });
59
62
  else if (typeof n == "object" && n !== null) {
60
- const l = Object.entries(n).map(([c, y]) => `${c},${y}`).join(",");
63
+ const l = Object.entries(n).map(([r, $]) => `${r},${$}`).join(",");
61
64
  i.push({ name: s.name, value: l });
62
65
  } else
63
66
  i.push({ name: s.name, value: String(n) });
@@ -67,7 +70,7 @@ const A = (e) => (e ?? []).map((o) => d(o)), g = (e) => {
67
70
  if (Array.isArray(n))
68
71
  i.push({ name: s.name, value: n.join(" ") });
69
72
  else if (typeof n == "object" && n !== null) {
70
- const l = Object.entries(n).map(([c, y]) => `${c} ${y}`).join(" ");
73
+ const l = Object.entries(n).map(([r, $]) => `${r} ${$}`).join(" ");
71
74
  i.push({ name: s.name, value: l });
72
75
  }
73
76
  break;
@@ -83,8 +86,8 @@ const A = (e) => (e ?? []).map((o) => d(o)), g = (e) => {
83
86
  }
84
87
  case "deepObject": {
85
88
  if (v && typeof n == "object" && n !== null)
86
- for (const [l, c] of Object.entries(n))
87
- i.push({ name: `${s.name}[${l}]`, value: String(c) });
89
+ for (const [l, r] of Object.entries(n))
90
+ i.push({ name: `${s.name}[${l}]`, value: String(r) });
88
91
  break;
89
92
  }
90
93
  // Default to form style
@@ -99,14 +102,14 @@ const A = (e) => (e ?? []).map((o) => d(o)), g = (e) => {
99
102
  for (const l of n)
100
103
  f.push({ name: s.name, value: String(l) });
101
104
  else if (typeof n == "object" && n !== null) {
102
- const l = Object.entries(n).map(([c, y]) => `${c}=${y}`).join(",");
105
+ const l = Object.entries(n).map(([r, $]) => `${r}=${$}`).join(",");
103
106
  f.push({ name: s.name, value: l });
104
107
  } else
105
108
  f.push({ name: s.name, value: String(n) });
106
109
  else if (Array.isArray(n))
107
110
  f.push({ name: s.name, value: n.join(",") });
108
111
  else if (typeof n == "object" && n !== null) {
109
- const l = Object.entries(n).map(([c, y]) => `${c},${y}`).join(",");
112
+ const l = Object.entries(n).map(([r, $]) => `${r},${$}`).join(",");
110
113
  f.push({ name: s.name, value: l });
111
114
  } else
112
115
  f.push({ name: s.name, value: String(n) });
@@ -117,42 +120,42 @@ const A = (e) => (e ?? []).map((o) => d(o)), g = (e) => {
117
120
  for (const l of n)
118
121
  e.cookies.push({ name: s.name, value: l === null ? "null" : String(l) });
119
122
  else if (typeof n == "object" && n !== null)
120
- for (const [l, c] of Object.entries(n))
121
- e.cookies.push({ name: l, value: c === null ? "null" : String(c) });
123
+ for (const [l, r] of Object.entries(n))
124
+ e.cookies.push({ name: l, value: r === null ? "null" : String(r) });
122
125
  else
123
126
  e.cookies.push({ name: s.name, value: n === null ? "null" : String(n) });
124
127
  else if (Array.isArray(n)) {
125
- const l = n.map((c) => c === null ? "null" : String(c)).join(",");
128
+ const l = n.map((r) => r === null ? "null" : String(r)).join(",");
126
129
  e.cookies.push({ name: s.name, value: l });
127
130
  } else if (typeof n == "object" && n !== null) {
128
- const l = (y) => {
131
+ const l = ($) => {
129
132
  const a = [];
130
- for (const [m, j] of Object.entries(y))
131
- typeof j == "object" && j !== null && !Array.isArray(j) ? a.push(m, ...l(j)) : a.push(m, j === null ? "null" : String(j));
133
+ for (const [b, j] of Object.entries($))
134
+ typeof j == "object" && j !== null && !Array.isArray(j) ? a.push(b, ...l(j)) : a.push(b, j === null ? "null" : String(j));
132
135
  return a;
133
- }, c = l(n).join(",");
134
- e.cookies.push({ name: s.name, value: c });
136
+ }, r = l(n).join(",");
137
+ e.cookies.push({ name: s.name, value: r });
135
138
  } else
136
139
  e.cookies.push({ name: s.name, value: n === null ? "null" : String(n) });
137
140
  break;
138
141
  }
139
142
  }
140
143
  return {
141
- url: r,
144
+ url: c,
142
145
  headers: f,
143
146
  queryString: i,
144
147
  cookies: e.cookies
145
148
  };
146
- }, k = (e, o, t, $, f) => {
147
- switch ($) {
149
+ }, x = (e, o, t, y, f) => {
150
+ switch (y) {
148
151
  case "matrix": {
149
152
  if (f) {
150
153
  if (Array.isArray(t)) {
151
- const i = t.map((r) => `${o.name}=${r}`).join(";");
154
+ const i = t.map((c) => `${o.name}=${c}`).join(";");
152
155
  return e.replace(`{;${o.name}}`, `;${i}`);
153
156
  }
154
157
  if (typeof t == "object" && t !== null) {
155
- const i = Object.entries(t).map(([r, u]) => `${r}=${u}`).join(";");
158
+ const i = Object.entries(t).map(([c, u]) => `${c}=${u}`).join(";");
156
159
  return e.replace(`{;${o.name}}`, `;${i}`);
157
160
  }
158
161
  return e.replace(`{;${o.name}}`, `;${o.name}=${t}`);
@@ -160,7 +163,7 @@ const A = (e) => (e ?? []).map((o) => d(o)), g = (e) => {
160
163
  if (Array.isArray(t))
161
164
  return e.replace(`{;${o.name}}`, `;${o.name}=${t.join(",")}`);
162
165
  if (typeof t == "object" && t !== null) {
163
- const i = Object.entries(t).map(([r, u]) => `${r},${u}`).join(",");
166
+ const i = Object.entries(t).map(([c, u]) => `${c},${u}`).join(",");
164
167
  return e.replace(`{;${o.name}}`, `;${o.name}=${i}`);
165
168
  }
166
169
  return e.replace(`{;${o.name}}`, `;${o.name}=${t}`);
@@ -170,7 +173,7 @@ const A = (e) => (e ?? []).map((o) => d(o)), g = (e) => {
170
173
  if (Array.isArray(t))
171
174
  return e.replace(`{.${o.name}}`, `.${t.join(".")}`);
172
175
  if (typeof t == "object" && t !== null) {
173
- const i = Object.entries(t).map(([r, u]) => `${r}=${u}`).join(".");
176
+ const i = Object.entries(t).map(([c, u]) => `${c}=${u}`).join(".");
174
177
  return e.replace(`{.${o.name}}`, `.${i}`);
175
178
  }
176
179
  return e.replace(`{.${o.name}}`, `.${t}`);
@@ -178,7 +181,7 @@ const A = (e) => (e ?? []).map((o) => d(o)), g = (e) => {
178
181
  if (Array.isArray(t))
179
182
  return e.replace(`{.${o.name}}`, `.${t.join(",")}`);
180
183
  if (typeof t == "object" && t !== null) {
181
- const i = Object.entries(t).map(([r, u]) => `${r},${u}`).join(",");
184
+ const i = Object.entries(t).map(([c, u]) => `${c},${u}`).join(",");
182
185
  return e.replace(`{.${o.name}}`, `.${i}`);
183
186
  }
184
187
  return e.replace(`{.${o.name}}`, `.${t}`);
@@ -188,7 +191,7 @@ const A = (e) => (e ?? []).map((o) => d(o)), g = (e) => {
188
191
  if (Array.isArray(t))
189
192
  return e.replace(`{${o.name}}`, t.join(","));
190
193
  if (typeof t == "object" && t !== null) {
191
- const i = Object.entries(t).map(([r, u]) => `${r}=${u}`).join(",");
194
+ const i = Object.entries(t).map(([c, u]) => `${c}=${u}`).join(",");
192
195
  return e.replace(`{${o.name}}`, i);
193
196
  }
194
197
  return e.replace(`{${o.name}}`, String(t));
@@ -196,7 +199,7 @@ const A = (e) => (e ?? []).map((o) => d(o)), g = (e) => {
196
199
  if (Array.isArray(t))
197
200
  return e.replace(`{${o.name}}`, t.join(","));
198
201
  if (typeof t == "object" && t !== null) {
199
- const i = Object.entries(t).map(([r, u]) => `${r},${u}`).join(",");
202
+ const i = Object.entries(t).map(([c, u]) => `${c},${u}`).join(",");
200
203
  return e.replace(`{${o.name}}`, i);
201
204
  }
202
205
  return e.replace(`{${o.name}}`, String(t));
@@ -207,5 +210,5 @@ const A = (e) => (e ?? []).map((o) => d(o)), g = (e) => {
207
210
  }
208
211
  };
209
212
  export {
210
- w as processParameters
213
+ E as processParameters
211
214
  };