@scalar/snippetz 0.7.4 → 0.7.6

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 (249) hide show
  1. package/dist/clients/index.js +168 -169
  2. package/dist/httpsnippet-lite/helpers/code-builder.js +86 -74
  3. package/dist/httpsnippet-lite/helpers/escape.js +69 -44
  4. package/dist/httpsnippet-lite/helpers/headers.js +17 -14
  5. package/dist/httpsnippet-lite/helpers/reducer.js +1 -1
  6. package/dist/httpsnippet-lite/helpers/shell.js +13 -13
  7. package/dist/httpsnippet-lite/helpers/snippet-request.js +1 -1
  8. package/dist/httpsnippet-lite/helpers/url.js +4 -8
  9. package/dist/httpsnippet-lite/targets/c/libcurl/client.js +69 -67
  10. package/dist/httpsnippet-lite/targets/clojure/clj_http/client.js +165 -154
  11. package/dist/httpsnippet-lite/targets/csharp/restsharp/client.js +35 -38
  12. package/dist/httpsnippet-lite/targets/go/native/client.js +151 -147
  13. package/dist/httpsnippet-lite/targets/java/asynchttp/client.js +32 -35
  14. package/dist/httpsnippet-lite/targets/java/nethttp/client.js +40 -39
  15. package/dist/httpsnippet-lite/targets/java/okhttp/client.js +83 -73
  16. package/dist/httpsnippet-lite/targets/java/unirest/client.js +41 -34
  17. package/dist/httpsnippet-lite/targets/javascript/axios/client.js +81 -76
  18. package/dist/httpsnippet-lite/targets/javascript/jquery/client.js +77 -71
  19. package/dist/httpsnippet-lite/targets/javascript/xhr/client.js +73 -71
  20. package/dist/httpsnippet-lite/targets/kotlin/okhttp/client.js +83 -73
  21. package/dist/httpsnippet-lite/targets/node/axios/client.js +74 -69
  22. package/dist/httpsnippet-lite/targets/objc/helpers.js +52 -33
  23. package/dist/httpsnippet-lite/targets/objc/nsurlsession/client.js +123 -121
  24. package/dist/httpsnippet-lite/targets/ocaml/cohttp/client.js +60 -49
  25. package/dist/httpsnippet-lite/targets/powershell/common.js +46 -56
  26. package/dist/httpsnippet-lite/targets/powershell/restmethod/client.js +9 -13
  27. package/dist/httpsnippet-lite/targets/powershell/webrequest/client.js +9 -13
  28. package/dist/httpsnippet-lite/targets/python/python3/client.js +85 -68
  29. package/dist/httpsnippet-lite/targets/r/httr/client.js +114 -95
  30. package/dist/httpsnippet-lite/targets/ruby/native/client.js +66 -70
  31. package/dist/httpsnippet-lite/targets/shell/httpie/client.js +121 -107
  32. package/dist/httpsnippet-lite/targets/shell/wget/client.js +48 -43
  33. package/dist/httpsnippet-lite/targets/swift/helpers.js +62 -44
  34. package/dist/httpsnippet-lite/targets/swift/nsurlsession/client.js +126 -112
  35. package/dist/httpsnippet-lite/targets/target.js +1 -1
  36. package/dist/index.js +2 -9
  37. package/dist/libs/http.js +68 -56
  38. package/dist/libs/javascript.js +77 -60
  39. package/dist/libs/php.js +59 -49
  40. package/dist/libs/rust.js +60 -33
  41. package/dist/libs/shell.js +14 -5
  42. package/dist/plugins/c/libcurl/index.js +1 -5
  43. package/dist/plugins/c/libcurl/libcurl.js +13 -13
  44. package/dist/plugins/clojure/clj_http/clj_http.js +13 -13
  45. package/dist/plugins/clojure/clj_http/index.js +1 -5
  46. package/dist/plugins/csharp/httpclient/httpclient.js +206 -150
  47. package/dist/plugins/csharp/httpclient/index.js +1 -5
  48. package/dist/plugins/csharp/restsharp/index.js +1 -5
  49. package/dist/plugins/csharp/restsharp/restsharp.js +13 -13
  50. package/dist/plugins/dart/http/http.js +95 -93
  51. package/dist/plugins/dart/http/index.js +1 -5
  52. package/dist/plugins/fsharp/httpclient/httpclient.js +169 -122
  53. package/dist/plugins/fsharp/httpclient/index.js +1 -5
  54. package/dist/plugins/go/native/index.js +1 -5
  55. package/dist/plugins/go/native/native.js +13 -13
  56. package/dist/plugins/http/http11/http11.d.ts.map +1 -1
  57. package/dist/plugins/http/http11/http11.js +104 -85
  58. package/dist/plugins/http/http11/index.js +1 -5
  59. package/dist/plugins/java/asynchttp/asynchttp.js +13 -13
  60. package/dist/plugins/java/asynchttp/index.js +1 -5
  61. package/dist/plugins/java/nethttp/index.js +1 -5
  62. package/dist/plugins/java/nethttp/nethttp.js +13 -13
  63. package/dist/plugins/java/okhttp/index.js +1 -5
  64. package/dist/plugins/java/okhttp/okhttp.js +13 -13
  65. package/dist/plugins/java/unirest/index.js +1 -5
  66. package/dist/plugins/java/unirest/unirest.js +13 -13
  67. package/dist/plugins/js/axios/axios.js +13 -13
  68. package/dist/plugins/js/axios/index.js +1 -5
  69. package/dist/plugins/js/fetch/fetch.js +82 -68
  70. package/dist/plugins/js/fetch/index.js +1 -5
  71. package/dist/plugins/js/jquery/index.js +1 -5
  72. package/dist/plugins/js/jquery/jquery.js +13 -13
  73. package/dist/plugins/js/ofetch/index.js +1 -5
  74. package/dist/plugins/js/ofetch/ofetch.js +61 -48
  75. package/dist/plugins/js/xhr/index.js +1 -5
  76. package/dist/plugins/js/xhr/xhr.js +13 -13
  77. package/dist/plugins/kotlin/okhttp/index.js +1 -5
  78. package/dist/plugins/kotlin/okhttp/okhttp.js +13 -13
  79. package/dist/plugins/node/axios/axios.js +13 -13
  80. package/dist/plugins/node/axios/index.js +1 -5
  81. package/dist/plugins/node/fetch/fetch.js +86 -74
  82. package/dist/plugins/node/fetch/index.js +1 -5
  83. package/dist/plugins/node/ofetch/index.js +1 -5
  84. package/dist/plugins/node/ofetch/ofetch.js +61 -48
  85. package/dist/plugins/node/undici/index.js +1 -5
  86. package/dist/plugins/node/undici/undici.js +60 -47
  87. package/dist/plugins/objc/nsurlsession/index.js +1 -5
  88. package/dist/plugins/objc/nsurlsession/nsurlsession.js +13 -13
  89. package/dist/plugins/ocaml/cohttp/cohttp.js +13 -13
  90. package/dist/plugins/ocaml/cohttp/index.js +1 -5
  91. package/dist/plugins/php/curl/curl.js +143 -101
  92. package/dist/plugins/php/curl/index.js +1 -5
  93. package/dist/plugins/php/guzzle/guzzle.d.ts.map +1 -1
  94. package/dist/plugins/php/guzzle/guzzle.js +109 -83
  95. package/dist/plugins/php/guzzle/index.js +1 -5
  96. package/dist/plugins/powershell/restmethod/index.js +1 -5
  97. package/dist/plugins/powershell/restmethod/restmethod.js +13 -13
  98. package/dist/plugins/powershell/webrequest/index.js +1 -5
  99. package/dist/plugins/powershell/webrequest/webrequest.js +13 -13
  100. package/dist/plugins/python/httpx/async.js +17 -15
  101. package/dist/plugins/python/httpx/index.js +2 -7
  102. package/dist/plugins/python/httpx/sync.js +11 -12
  103. package/dist/plugins/python/python3/index.js +1 -5
  104. package/dist/plugins/python/python3/python3.js +13 -13
  105. package/dist/plugins/python/requests/index.js +1 -5
  106. package/dist/plugins/python/requests/requests.js +11 -12
  107. package/dist/plugins/python/requestsLike.d.ts.map +1 -1
  108. package/dist/plugins/python/requestsLike.js +145 -112
  109. package/dist/plugins/r/httr/httr.js +13 -13
  110. package/dist/plugins/r/httr/index.js +1 -5
  111. package/dist/plugins/ruby/native/index.js +1 -5
  112. package/dist/plugins/ruby/native/native.js +13 -13
  113. package/dist/plugins/rust/reqwest/index.js +1 -5
  114. package/dist/plugins/rust/reqwest/reqwest.js +126 -83
  115. package/dist/plugins/shell/curl/curl.d.ts.map +1 -1
  116. package/dist/plugins/shell/curl/curl.js +129 -97
  117. package/dist/plugins/shell/curl/index.js +1 -5
  118. package/dist/plugins/shell/httpie/httpie.js +13 -13
  119. package/dist/plugins/shell/httpie/index.js +1 -5
  120. package/dist/plugins/shell/wget/index.js +1 -5
  121. package/dist/plugins/shell/wget/wget.js +13 -13
  122. package/dist/plugins/swift/nsurlsession/index.js +1 -5
  123. package/dist/plugins/swift/nsurlsession/nsurlsession.js +13 -13
  124. package/dist/snippetz.js +25 -28
  125. package/dist/utils/convertWithHttpSnippetLite.js +100 -96
  126. package/dist/utils/index.js +1 -5
  127. package/package.json +8 -12
  128. package/dist/clients/index.js.map +0 -7
  129. package/dist/httpsnippet-lite/helpers/code-builder.js.map +0 -7
  130. package/dist/httpsnippet-lite/helpers/escape.js.map +0 -7
  131. package/dist/httpsnippet-lite/helpers/headers.js.map +0 -7
  132. package/dist/httpsnippet-lite/helpers/reducer.js.map +0 -7
  133. package/dist/httpsnippet-lite/helpers/shell.js.map +0 -7
  134. package/dist/httpsnippet-lite/helpers/snippet-request.js.map +0 -7
  135. package/dist/httpsnippet-lite/helpers/url.js.map +0 -7
  136. package/dist/httpsnippet-lite/targets/c/libcurl/client.js.map +0 -7
  137. package/dist/httpsnippet-lite/targets/clojure/clj_http/client.js.map +0 -7
  138. package/dist/httpsnippet-lite/targets/csharp/restsharp/client.js.map +0 -7
  139. package/dist/httpsnippet-lite/targets/go/native/client.js.map +0 -7
  140. package/dist/httpsnippet-lite/targets/java/asynchttp/client.js.map +0 -7
  141. package/dist/httpsnippet-lite/targets/java/nethttp/client.js.map +0 -7
  142. package/dist/httpsnippet-lite/targets/java/okhttp/client.js.map +0 -7
  143. package/dist/httpsnippet-lite/targets/java/unirest/client.js.map +0 -7
  144. package/dist/httpsnippet-lite/targets/javascript/axios/client.js.map +0 -7
  145. package/dist/httpsnippet-lite/targets/javascript/jquery/client.js.map +0 -7
  146. package/dist/httpsnippet-lite/targets/javascript/xhr/client.js.map +0 -7
  147. package/dist/httpsnippet-lite/targets/kotlin/okhttp/client.js.map +0 -7
  148. package/dist/httpsnippet-lite/targets/node/axios/client.js.map +0 -7
  149. package/dist/httpsnippet-lite/targets/objc/helpers.js.map +0 -7
  150. package/dist/httpsnippet-lite/targets/objc/nsurlsession/client.js.map +0 -7
  151. package/dist/httpsnippet-lite/targets/ocaml/cohttp/client.js.map +0 -7
  152. package/dist/httpsnippet-lite/targets/powershell/common.js.map +0 -7
  153. package/dist/httpsnippet-lite/targets/powershell/restmethod/client.js.map +0 -7
  154. package/dist/httpsnippet-lite/targets/powershell/webrequest/client.js.map +0 -7
  155. package/dist/httpsnippet-lite/targets/python/python3/client.js.map +0 -7
  156. package/dist/httpsnippet-lite/targets/r/httr/client.js.map +0 -7
  157. package/dist/httpsnippet-lite/targets/ruby/native/client.js.map +0 -7
  158. package/dist/httpsnippet-lite/targets/shell/httpie/client.js.map +0 -7
  159. package/dist/httpsnippet-lite/targets/shell/wget/client.js.map +0 -7
  160. package/dist/httpsnippet-lite/targets/swift/helpers.js.map +0 -7
  161. package/dist/httpsnippet-lite/targets/swift/nsurlsession/client.js.map +0 -7
  162. package/dist/httpsnippet-lite/targets/target.js.map +0 -7
  163. package/dist/index.js.map +0 -7
  164. package/dist/libs/http.js.map +0 -7
  165. package/dist/libs/javascript.js.map +0 -7
  166. package/dist/libs/php.js.map +0 -7
  167. package/dist/libs/rust.js.map +0 -7
  168. package/dist/libs/shell.js.map +0 -7
  169. package/dist/plugins/c/libcurl/index.js.map +0 -7
  170. package/dist/plugins/c/libcurl/libcurl.js.map +0 -7
  171. package/dist/plugins/clojure/clj_http/clj_http.js.map +0 -7
  172. package/dist/plugins/clojure/clj_http/index.js.map +0 -7
  173. package/dist/plugins/csharp/httpclient/httpclient.js.map +0 -7
  174. package/dist/plugins/csharp/httpclient/index.js.map +0 -7
  175. package/dist/plugins/csharp/restsharp/index.js.map +0 -7
  176. package/dist/plugins/csharp/restsharp/restsharp.js.map +0 -7
  177. package/dist/plugins/dart/http/http.js.map +0 -7
  178. package/dist/plugins/dart/http/index.js.map +0 -7
  179. package/dist/plugins/fsharp/httpclient/httpclient.js.map +0 -7
  180. package/dist/plugins/fsharp/httpclient/index.js.map +0 -7
  181. package/dist/plugins/go/native/index.js.map +0 -7
  182. package/dist/plugins/go/native/native.js.map +0 -7
  183. package/dist/plugins/http/http11/http11.js.map +0 -7
  184. package/dist/plugins/http/http11/index.js.map +0 -7
  185. package/dist/plugins/java/asynchttp/asynchttp.js.map +0 -7
  186. package/dist/plugins/java/asynchttp/index.js.map +0 -7
  187. package/dist/plugins/java/nethttp/index.js.map +0 -7
  188. package/dist/plugins/java/nethttp/nethttp.js.map +0 -7
  189. package/dist/plugins/java/okhttp/index.js.map +0 -7
  190. package/dist/plugins/java/okhttp/okhttp.js.map +0 -7
  191. package/dist/plugins/java/unirest/index.js.map +0 -7
  192. package/dist/plugins/java/unirest/unirest.js.map +0 -7
  193. package/dist/plugins/js/axios/axios.js.map +0 -7
  194. package/dist/plugins/js/axios/index.js.map +0 -7
  195. package/dist/plugins/js/fetch/fetch.js.map +0 -7
  196. package/dist/plugins/js/fetch/index.js.map +0 -7
  197. package/dist/plugins/js/jquery/index.js.map +0 -7
  198. package/dist/plugins/js/jquery/jquery.js.map +0 -7
  199. package/dist/plugins/js/ofetch/index.js.map +0 -7
  200. package/dist/plugins/js/ofetch/ofetch.js.map +0 -7
  201. package/dist/plugins/js/xhr/index.js.map +0 -7
  202. package/dist/plugins/js/xhr/xhr.js.map +0 -7
  203. package/dist/plugins/kotlin/okhttp/index.js.map +0 -7
  204. package/dist/plugins/kotlin/okhttp/okhttp.js.map +0 -7
  205. package/dist/plugins/node/axios/axios.js.map +0 -7
  206. package/dist/plugins/node/axios/index.js.map +0 -7
  207. package/dist/plugins/node/fetch/fetch.js.map +0 -7
  208. package/dist/plugins/node/fetch/index.js.map +0 -7
  209. package/dist/plugins/node/ofetch/index.js.map +0 -7
  210. package/dist/plugins/node/ofetch/ofetch.js.map +0 -7
  211. package/dist/plugins/node/undici/index.js.map +0 -7
  212. package/dist/plugins/node/undici/undici.js.map +0 -7
  213. package/dist/plugins/objc/nsurlsession/index.js.map +0 -7
  214. package/dist/plugins/objc/nsurlsession/nsurlsession.js.map +0 -7
  215. package/dist/plugins/ocaml/cohttp/cohttp.js.map +0 -7
  216. package/dist/plugins/ocaml/cohttp/index.js.map +0 -7
  217. package/dist/plugins/php/curl/curl.js.map +0 -7
  218. package/dist/plugins/php/curl/index.js.map +0 -7
  219. package/dist/plugins/php/guzzle/guzzle.js.map +0 -7
  220. package/dist/plugins/php/guzzle/index.js.map +0 -7
  221. package/dist/plugins/powershell/restmethod/index.js.map +0 -7
  222. package/dist/plugins/powershell/restmethod/restmethod.js.map +0 -7
  223. package/dist/plugins/powershell/webrequest/index.js.map +0 -7
  224. package/dist/plugins/powershell/webrequest/webrequest.js.map +0 -7
  225. package/dist/plugins/python/httpx/async.js.map +0 -7
  226. package/dist/plugins/python/httpx/index.js.map +0 -7
  227. package/dist/plugins/python/httpx/sync.js.map +0 -7
  228. package/dist/plugins/python/python3/index.js.map +0 -7
  229. package/dist/plugins/python/python3/python3.js.map +0 -7
  230. package/dist/plugins/python/requests/index.js.map +0 -7
  231. package/dist/plugins/python/requests/requests.js.map +0 -7
  232. package/dist/plugins/python/requestsLike.js.map +0 -7
  233. package/dist/plugins/r/httr/httr.js.map +0 -7
  234. package/dist/plugins/r/httr/index.js.map +0 -7
  235. package/dist/plugins/ruby/native/index.js.map +0 -7
  236. package/dist/plugins/ruby/native/native.js.map +0 -7
  237. package/dist/plugins/rust/reqwest/index.js.map +0 -7
  238. package/dist/plugins/rust/reqwest/reqwest.js.map +0 -7
  239. package/dist/plugins/shell/curl/curl.js.map +0 -7
  240. package/dist/plugins/shell/curl/index.js.map +0 -7
  241. package/dist/plugins/shell/httpie/httpie.js.map +0 -7
  242. package/dist/plugins/shell/httpie/index.js.map +0 -7
  243. package/dist/plugins/shell/wget/index.js.map +0 -7
  244. package/dist/plugins/shell/wget/wget.js.map +0 -7
  245. package/dist/plugins/swift/nsurlsession/index.js.map +0 -7
  246. package/dist/plugins/swift/nsurlsession/nsurlsession.js.map +0 -7
  247. package/dist/snippetz.js.map +0 -7
  248. package/dist/utils/convertWithHttpSnippetLite.js.map +0 -7
  249. package/dist/utils/index.js.map +0 -7
@@ -1,14 +1,14 @@
1
- import { nethttp } from "../../../httpsnippet-lite/targets/java/nethttp/client.js";
2
- import { convertWithHttpSnippetLite } from "../../../utils/convertWithHttpSnippetLite.js";
3
- const javaNethttp = {
4
- target: "java",
5
- client: "nethttp",
6
- title: "java.net.http",
7
- generate(request) {
8
- return convertWithHttpSnippetLite(nethttp, request);
9
- }
1
+ import { nethttp } from '../../../httpsnippet-lite/targets/java/nethttp/client.js';
2
+ import { convertWithHttpSnippetLite } from '../../../utils/convertWithHttpSnippetLite.js';
3
+ /**
4
+ * java/nethttp
5
+ */
6
+ export const javaNethttp = {
7
+ target: 'java',
8
+ client: 'nethttp',
9
+ title: 'java.net.http',
10
+ generate(request) {
11
+ // TODO: Write an own converter
12
+ return convertWithHttpSnippetLite(nethttp, request);
13
+ },
10
14
  };
11
- export {
12
- javaNethttp
13
- };
14
- //# sourceMappingURL=nethttp.js.map
@@ -1,5 +1 @@
1
- import { javaOkhttp } from "./okhttp.js";
2
- export {
3
- javaOkhttp
4
- };
5
- //# sourceMappingURL=index.js.map
1
+ export { javaOkhttp } from './okhttp.js';
@@ -1,14 +1,14 @@
1
- import { okhttp } from "../../../httpsnippet-lite/targets/java/okhttp/client.js";
2
- import { convertWithHttpSnippetLite } from "../../../utils/convertWithHttpSnippetLite.js";
3
- const javaOkhttp = {
4
- target: "java",
5
- client: "okhttp",
6
- title: "OkHttp",
7
- generate(request) {
8
- return convertWithHttpSnippetLite(okhttp, request);
9
- }
1
+ import { okhttp } from '../../../httpsnippet-lite/targets/java/okhttp/client.js';
2
+ import { convertWithHttpSnippetLite } from '../../../utils/convertWithHttpSnippetLite.js';
3
+ /**
4
+ * java/okhttp
5
+ */
6
+ export const javaOkhttp = {
7
+ target: 'java',
8
+ client: 'okhttp',
9
+ title: 'OkHttp',
10
+ generate(request) {
11
+ // TODO: Write an own converter
12
+ return convertWithHttpSnippetLite(okhttp, request);
13
+ },
10
14
  };
11
- export {
12
- javaOkhttp
13
- };
14
- //# sourceMappingURL=okhttp.js.map
@@ -1,5 +1 @@
1
- import { javaUnirest } from "./unirest.js";
2
- export {
3
- javaUnirest
4
- };
5
- //# sourceMappingURL=index.js.map
1
+ export { javaUnirest } from './unirest.js';
@@ -1,14 +1,14 @@
1
- import { unirest } from "../../../httpsnippet-lite/targets/java/unirest/client.js";
2
- import { convertWithHttpSnippetLite } from "../../../utils/convertWithHttpSnippetLite.js";
3
- const javaUnirest = {
4
- target: "java",
5
- client: "unirest",
6
- title: "Unirest",
7
- generate(request) {
8
- return convertWithHttpSnippetLite(unirest, request);
9
- }
1
+ import { unirest } from '../../../httpsnippet-lite/targets/java/unirest/client.js';
2
+ import { convertWithHttpSnippetLite } from '../../../utils/convertWithHttpSnippetLite.js';
3
+ /**
4
+ * java/unirest
5
+ */
6
+ export const javaUnirest = {
7
+ target: 'java',
8
+ client: 'unirest',
9
+ title: 'Unirest',
10
+ generate(request) {
11
+ // TODO: Write an own converter
12
+ return convertWithHttpSnippetLite(unirest, request);
13
+ },
10
14
  };
11
- export {
12
- javaUnirest
13
- };
14
- //# sourceMappingURL=unirest.js.map
@@ -1,14 +1,14 @@
1
- import { axios } from "../../../httpsnippet-lite/targets/javascript/axios/client.js";
2
- import { convertWithHttpSnippetLite } from "../../../utils/convertWithHttpSnippetLite.js";
3
- const jsAxios = {
4
- target: "js",
5
- client: "axios",
6
- title: "Axios",
7
- generate(request) {
8
- return convertWithHttpSnippetLite(axios, request);
9
- }
1
+ import { axios } from '../../../httpsnippet-lite/targets/javascript/axios/client.js';
2
+ import { convertWithHttpSnippetLite } from '../../../utils/convertWithHttpSnippetLite.js';
3
+ /**
4
+ * js/axios
5
+ */
6
+ export const jsAxios = {
7
+ target: 'js',
8
+ client: 'axios',
9
+ title: 'Axios',
10
+ generate(request) {
11
+ // TODO: Write an own converter
12
+ return convertWithHttpSnippetLite(axios, request);
13
+ },
10
14
  };
11
- export {
12
- jsAxios
13
- };
14
- //# sourceMappingURL=axios.js.map
@@ -1,5 +1 @@
1
- import { jsAxios } from "./axios.js";
2
- export {
3
- jsAxios
4
- };
5
- //# sourceMappingURL=index.js.map
1
+ export { jsAxios } from './axios.js';
@@ -1,71 +1,85 @@
1
- import { createSearchParams } from "../../../libs/http.js";
2
- import { Raw, objectToString } from "../../../libs/javascript.js";
3
- const jsFetch = {
4
- target: "js",
5
- client: "fetch",
6
- title: "Fetch",
7
- generate(request) {
8
- const normalizedRequest = {
9
- method: "GET",
10
- ...request
11
- };
12
- let prefix = "";
13
- normalizedRequest.method = normalizedRequest.method.toUpperCase();
14
- const options = {
15
- method: normalizedRequest.method === "GET" ? void 0 : normalizedRequest.method
16
- };
17
- const searchParams = createSearchParams(normalizedRequest.queryString);
18
- const queryString = searchParams.size ? `?${searchParams.toString()}` : "";
19
- if (normalizedRequest.headers?.length) {
20
- options.headers = {};
21
- normalizedRequest.headers.forEach((header) => {
22
- options.headers[header.name] = header.value;
23
- });
24
- }
25
- if (normalizedRequest.cookies?.length) {
26
- options.headers = options.headers || {};
27
- normalizedRequest.cookies.forEach((cookie) => {
28
- options.headers["Set-Cookie"] = options.headers["Set-Cookie"] ? `${options.headers["Set-Cookie"]}; ${cookie.name}=${cookie.value}` : `${cookie.name}=${cookie.value}`;
29
- });
30
- }
31
- Object.keys(options).forEach((key) => {
32
- if (options[key] === void 0) {
33
- delete options[key];
34
- }
35
- });
36
- if (normalizedRequest.postData) {
37
- const { mimeType, text, params } = normalizedRequest.postData;
38
- if (mimeType === "application/json" && text) {
39
- try {
40
- options.body = new Raw(`JSON.stringify(${objectToString(JSON.parse(text))})`);
41
- } catch {
42
- options.body = text;
1
+ import { createSearchParams } from '../../../libs/http.js';
2
+ import { Raw, objectToString } from '../../../libs/javascript.js';
3
+ /**
4
+ * js/fetch
5
+ */
6
+ export const jsFetch = {
7
+ target: 'js',
8
+ client: 'fetch',
9
+ title: 'Fetch',
10
+ generate(request) {
11
+ // Defaults
12
+ const normalizedRequest = {
13
+ method: 'GET',
14
+ ...request,
15
+ };
16
+ let prefix = '';
17
+ // Normalization
18
+ normalizedRequest.method = normalizedRequest.method.toUpperCase();
19
+ // Reset fetch defaults
20
+ const options = {
21
+ method: normalizedRequest.method === 'GET' ? undefined : normalizedRequest.method,
22
+ };
23
+ // Query
24
+ const searchParams = createSearchParams(normalizedRequest.queryString);
25
+ const queryString = searchParams.size ? `?${searchParams.toString()}` : '';
26
+ // Headers
27
+ if (normalizedRequest.headers?.length) {
28
+ options.headers = {};
29
+ normalizedRequest.headers.forEach((header) => {
30
+ options.headers[header.name] = header.value;
31
+ });
43
32
  }
44
- } else if (mimeType === "multipart/form-data" && params) {
45
- prefix = "const formData = new FormData()\n";
46
- params.forEach((param) => {
47
- if (param.fileName !== void 0) {
48
- prefix += `formData.append('${param.name}', new Blob([]), '${param.fileName}')
49
- `;
50
- } else if (param.value !== void 0) {
51
- prefix += `formData.append('${param.name}', '${param.value}')
52
- `;
53
- }
33
+ // Cookies
34
+ if (normalizedRequest.cookies?.length) {
35
+ options.headers = options.headers || {};
36
+ normalizedRequest.cookies.forEach((cookie) => {
37
+ options.headers['Set-Cookie'] = options.headers['Set-Cookie']
38
+ ? `${options.headers['Set-Cookie']}; ${cookie.name}=${cookie.value}`
39
+ : `${cookie.name}=${cookie.value}`;
40
+ });
41
+ }
42
+ // Remove undefined keys
43
+ Object.keys(options).forEach((key) => {
44
+ if (options[key] === undefined) {
45
+ delete options[key];
46
+ }
54
47
  });
55
- prefix += "\n";
56
- options.body = new Raw("formData");
57
- } else if (mimeType === "application/x-www-form-urlencoded" && params) {
58
- const form = Object.fromEntries(params.map((p) => [p.name, p.value]));
59
- options.body = new Raw(`new URLSearchParams(${objectToString(form)})`);
60
- } else {
61
- options.body = normalizedRequest.postData.text;
62
- }
63
- }
64
- const jsonOptions = Object.keys(options).length ? `, ${objectToString(options)}` : "";
65
- return `${prefix}fetch('${normalizedRequest.url}${queryString}'${jsonOptions})`;
66
- }
67
- };
68
- export {
69
- jsFetch
48
+ // Add body
49
+ if (normalizedRequest.postData) {
50
+ const { mimeType, text, params } = normalizedRequest.postData;
51
+ if (mimeType === 'application/json' && text) {
52
+ try {
53
+ options.body = new Raw(`JSON.stringify(${objectToString(JSON.parse(text))})`);
54
+ }
55
+ catch {
56
+ options.body = text;
57
+ }
58
+ }
59
+ else if (mimeType === 'multipart/form-data' && params) {
60
+ prefix = 'const formData = new FormData()\n';
61
+ params.forEach((param) => {
62
+ if (param.fileName !== undefined) {
63
+ prefix += `formData.append('${param.name}', new Blob([]), '${param.fileName}')\n`;
64
+ }
65
+ else if (param.value !== undefined) {
66
+ prefix += `formData.append('${param.name}', '${param.value}')\n`;
67
+ }
68
+ });
69
+ prefix += '\n';
70
+ options.body = new Raw('formData');
71
+ }
72
+ else if (mimeType === 'application/x-www-form-urlencoded' && params) {
73
+ const form = Object.fromEntries(params.map((p) => [p.name, p.value]));
74
+ options.body = new Raw(`new URLSearchParams(${objectToString(form)})`);
75
+ }
76
+ else {
77
+ options.body = normalizedRequest.postData.text;
78
+ }
79
+ }
80
+ // Transform to JSON
81
+ const jsonOptions = Object.keys(options).length ? `, ${objectToString(options)}` : '';
82
+ // Code Template
83
+ return `${prefix}fetch('${normalizedRequest.url}${queryString}'${jsonOptions})`;
84
+ },
70
85
  };
71
- //# sourceMappingURL=fetch.js.map
@@ -1,5 +1 @@
1
- import { jsFetch } from "./fetch.js";
2
- export {
3
- jsFetch
4
- };
5
- //# sourceMappingURL=index.js.map
1
+ export { jsFetch } from './fetch.js';
@@ -1,5 +1 @@
1
- import { jsJquery } from "./jquery.js";
2
- export {
3
- jsJquery
4
- };
5
- //# sourceMappingURL=index.js.map
1
+ export { jsJquery } from './jquery.js';
@@ -1,14 +1,14 @@
1
- import { jquery } from "../../../httpsnippet-lite/targets/javascript/jquery/client.js";
2
- import { convertWithHttpSnippetLite } from "../../../utils/convertWithHttpSnippetLite.js";
3
- const jsJquery = {
4
- target: "js",
5
- client: "jquery",
6
- title: "jQuery",
7
- generate(request) {
8
- return convertWithHttpSnippetLite(jquery, request);
9
- }
1
+ import { jquery } from '../../../httpsnippet-lite/targets/javascript/jquery/client.js';
2
+ import { convertWithHttpSnippetLite } from '../../../utils/convertWithHttpSnippetLite.js';
3
+ /**
4
+ * js/jquery
5
+ */
6
+ export const jsJquery = {
7
+ target: 'js',
8
+ client: 'jquery',
9
+ title: 'jQuery',
10
+ generate(request) {
11
+ // TODO: Write an own converter
12
+ return convertWithHttpSnippetLite(jquery, request);
13
+ },
10
14
  };
11
- export {
12
- jsJquery
13
- };
14
- //# sourceMappingURL=jquery.js.map
@@ -1,5 +1 @@
1
- import { jsOfetch } from "./ofetch.js";
2
- export {
3
- jsOfetch
4
- };
5
- //# sourceMappingURL=index.js.map
1
+ export { jsOfetch } from './ofetch.js';
@@ -1,51 +1,64 @@
1
- import { reduceQueryParams } from "../../../libs/http.js";
2
- import { objectToString } from "../../../libs/javascript.js";
3
- const jsOfetch = {
4
- target: "js",
5
- client: "ofetch",
6
- title: "ofetch",
7
- generate(request) {
8
- const normalizedRequest = {
9
- method: "GET",
10
- ...request
11
- };
12
- normalizedRequest.method = normalizedRequest.method.toUpperCase();
13
- const options = {
14
- method: normalizedRequest.method === "GET" ? void 0 : normalizedRequest.method
15
- };
16
- if (normalizedRequest.queryString?.length) {
17
- options.query = reduceQueryParams(normalizedRequest.queryString);
18
- }
19
- if (normalizedRequest.headers?.length) {
20
- options.headers = {};
21
- normalizedRequest.headers.forEach((header) => {
22
- options.headers[header.name] = header.value;
23
- });
24
- }
25
- if (normalizedRequest.cookies?.length) {
26
- options.headers = options.headers || {};
27
- normalizedRequest.cookies.forEach((cookie) => {
28
- options.headers["Set-Cookie"] = options.headers["Set-Cookie"] ? `${options.headers["Set-Cookie"]}; ${cookie.name}=${cookie.value}` : `${cookie.name}=${cookie.value}`;
29
- });
30
- }
31
- Object.keys(options).forEach((key) => {
32
- if (options[key] === void 0) {
33
- delete options[key];
34
- }
35
- });
36
- if (normalizedRequest.postData) {
37
- options.body = normalizedRequest.postData.text;
38
- if (normalizedRequest.postData.mimeType === "application/json") {
39
- options.body = JSON.parse(options.body);
40
- }
41
- }
42
- const jsonOptions = Object.keys(options).length ? `, ${objectToString(options)}` : "";
43
- return `import { ofetch } from 'ofetch'
1
+ import { reduceQueryParams } from '../../../libs/http.js';
2
+ import { objectToString } from '../../../libs/javascript.js';
3
+ /**
4
+ * js/ofetch
5
+ */
6
+ export const jsOfetch = {
7
+ target: 'js',
8
+ client: 'ofetch',
9
+ title: 'ofetch',
10
+ generate(request) {
11
+ // Defaults
12
+ const normalizedRequest = {
13
+ method: 'GET',
14
+ ...request,
15
+ };
16
+ // Normalization
17
+ normalizedRequest.method = normalizedRequest.method.toUpperCase();
18
+ // Reset fetch defaults
19
+ const options = {
20
+ method: normalizedRequest.method === 'GET' ? undefined : normalizedRequest.method,
21
+ };
22
+ // Query
23
+ if (normalizedRequest.queryString?.length) {
24
+ options.query = reduceQueryParams(normalizedRequest.queryString);
25
+ }
26
+ // Headers
27
+ if (normalizedRequest.headers?.length) {
28
+ options.headers = {};
29
+ normalizedRequest.headers.forEach((header) => {
30
+ options.headers[header.name] = header.value;
31
+ });
32
+ }
33
+ // Cookies
34
+ if (normalizedRequest.cookies?.length) {
35
+ options.headers = options.headers || {};
36
+ normalizedRequest.cookies.forEach((cookie) => {
37
+ options.headers['Set-Cookie'] = options.headers['Set-Cookie']
38
+ ? `${options.headers['Set-Cookie']}; ${cookie.name}=${cookie.value}`
39
+ : `${cookie.name}=${cookie.value}`;
40
+ });
41
+ }
42
+ // Remove undefined keys
43
+ Object.keys(options).forEach((key) => {
44
+ if (options[key] === undefined) {
45
+ delete options[key];
46
+ }
47
+ });
48
+ // Add body
49
+ if (normalizedRequest.postData) {
50
+ // Plain text
51
+ options.body = normalizedRequest.postData.text;
52
+ // JSON
53
+ if (normalizedRequest.postData.mimeType === 'application/json') {
54
+ options.body = JSON.parse(options.body);
55
+ }
56
+ }
57
+ // Transform to JSON
58
+ const jsonOptions = Object.keys(options).length ? `, ${objectToString(options)}` : '';
59
+ // Code Template
60
+ return `import { ofetch } from 'ofetch'
44
61
 
45
62
  ofetch('${normalizedRequest.url}'${jsonOptions})`;
46
- }
63
+ },
47
64
  };
48
- export {
49
- jsOfetch
50
- };
51
- //# sourceMappingURL=ofetch.js.map
@@ -1,5 +1 @@
1
- import { jsXhr } from "./xhr.js";
2
- export {
3
- jsXhr
4
- };
5
- //# sourceMappingURL=index.js.map
1
+ export { jsXhr } from './xhr.js';
@@ -1,14 +1,14 @@
1
- import { xhr } from "../../../httpsnippet-lite/targets/javascript/xhr/client.js";
2
- import { convertWithHttpSnippetLite } from "../../../utils/convertWithHttpSnippetLite.js";
3
- const jsXhr = {
4
- target: "js",
5
- client: "xhr",
6
- title: "XHR",
7
- generate(request) {
8
- return convertWithHttpSnippetLite(xhr, request);
9
- }
1
+ import { xhr } from '../../../httpsnippet-lite/targets/javascript/xhr/client.js';
2
+ import { convertWithHttpSnippetLite } from '../../../utils/convertWithHttpSnippetLite.js';
3
+ /**
4
+ * js/xhr
5
+ */
6
+ export const jsXhr = {
7
+ target: 'js',
8
+ client: 'xhr',
9
+ title: 'XHR',
10
+ generate(request) {
11
+ // TODO: Write an own converter
12
+ return convertWithHttpSnippetLite(xhr, request);
13
+ },
10
14
  };
11
- export {
12
- jsXhr
13
- };
14
- //# sourceMappingURL=xhr.js.map
@@ -1,5 +1 @@
1
- import { kotlinOkhttp } from "./okhttp.js";
2
- export {
3
- kotlinOkhttp
4
- };
5
- //# sourceMappingURL=index.js.map
1
+ export { kotlinOkhttp } from './okhttp.js';
@@ -1,14 +1,14 @@
1
- import { okhttp } from "../../../httpsnippet-lite/targets/kotlin/okhttp/client.js";
2
- import { convertWithHttpSnippetLite } from "../../../utils/convertWithHttpSnippetLite.js";
3
- const kotlinOkhttp = {
4
- target: "kotlin",
5
- client: "okhttp",
6
- title: "OkHttp",
7
- generate(request) {
8
- return convertWithHttpSnippetLite(okhttp, request);
9
- }
1
+ import { okhttp } from '../../../httpsnippet-lite/targets/kotlin/okhttp/client.js';
2
+ import { convertWithHttpSnippetLite } from '../../../utils/convertWithHttpSnippetLite.js';
3
+ /**
4
+ * kotlin/okhttp
5
+ */
6
+ export const kotlinOkhttp = {
7
+ target: 'kotlin',
8
+ client: 'okhttp',
9
+ title: 'OkHttp',
10
+ generate(request) {
11
+ // TODO: Write an own converter
12
+ return convertWithHttpSnippetLite(okhttp, request);
13
+ },
10
14
  };
11
- export {
12
- kotlinOkhttp
13
- };
14
- //# sourceMappingURL=okhttp.js.map
@@ -1,14 +1,14 @@
1
- import { axios } from "../../../httpsnippet-lite/targets/node/axios/client.js";
2
- import { convertWithHttpSnippetLite } from "../../../utils/convertWithHttpSnippetLite.js";
3
- const nodeAxios = {
4
- target: "node",
5
- client: "axios",
6
- title: "Axios",
7
- generate(request) {
8
- return convertWithHttpSnippetLite(axios, request);
9
- }
1
+ import { axios } from '../../../httpsnippet-lite/targets/node/axios/client.js';
2
+ import { convertWithHttpSnippetLite } from '../../../utils/convertWithHttpSnippetLite.js';
3
+ /**
4
+ * node/axios
5
+ */
6
+ export const nodeAxios = {
7
+ target: 'node',
8
+ client: 'axios',
9
+ title: 'Axios',
10
+ generate(request) {
11
+ // TODO: Write an own converter
12
+ return convertWithHttpSnippetLite(axios, request);
13
+ },
10
14
  };
11
- export {
12
- nodeAxios
13
- };
14
- //# sourceMappingURL=axios.js.map
@@ -1,5 +1 @@
1
- import { nodeAxios } from "./axios.js";
2
- export {
3
- nodeAxios
4
- };
5
- //# sourceMappingURL=index.js.map
1
+ export { nodeAxios } from './axios.js';