@scalar/snippetz 0.2.19 → 0.3.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 (483) hide show
  1. package/dist/clients.js +153 -155
  2. package/dist/clients.js.map +7 -0
  3. package/dist/httpsnippet-lite/esm/helpers/code-builder.js +44 -59
  4. package/dist/httpsnippet-lite/esm/helpers/code-builder.js.map +7 -0
  5. package/dist/httpsnippet-lite/esm/helpers/escape.js +41 -69
  6. package/dist/httpsnippet-lite/esm/helpers/escape.js.map +7 -0
  7. package/dist/httpsnippet-lite/esm/helpers/form-data.js +59 -0
  8. package/dist/httpsnippet-lite/esm/helpers/form-data.js.map +7 -0
  9. package/dist/httpsnippet-lite/esm/helpers/headers.js +23 -18
  10. package/dist/httpsnippet-lite/esm/helpers/headers.js.map +7 -0
  11. package/dist/httpsnippet-lite/esm/helpers/reducer.js +20 -0
  12. package/dist/httpsnippet-lite/esm/helpers/reducer.js.map +7 -0
  13. package/dist/httpsnippet-lite/esm/helpers/shell.js +13 -16
  14. package/dist/httpsnippet-lite/esm/helpers/shell.js.map +7 -0
  15. package/dist/httpsnippet-lite/esm/helpers/url.js +20 -0
  16. package/dist/httpsnippet-lite/esm/helpers/url.js.map +7 -0
  17. package/dist/httpsnippet-lite/esm/helpers/utils.js +16 -0
  18. package/dist/httpsnippet-lite/esm/helpers/utils.js.map +7 -0
  19. package/dist/httpsnippet-lite/esm/targets/c/libcurl/client.d.ts.map +1 -1
  20. package/dist/httpsnippet-lite/esm/targets/c/libcurl/client.js +72 -40
  21. package/dist/httpsnippet-lite/esm/targets/c/libcurl/client.js.map +7 -0
  22. package/dist/httpsnippet-lite/esm/targets/c/target.js +16 -0
  23. package/dist/httpsnippet-lite/esm/targets/c/target.js.map +7 -0
  24. package/dist/httpsnippet-lite/esm/targets/clojure/clj_http/client.js +149 -166
  25. package/dist/httpsnippet-lite/esm/targets/clojure/clj_http/client.js.map +7 -0
  26. package/dist/httpsnippet-lite/esm/targets/clojure/target.js +16 -0
  27. package/dist/httpsnippet-lite/esm/targets/clojure/target.js.map +7 -0
  28. package/dist/httpsnippet-lite/esm/targets/csharp/httpclient/client.js +165 -161
  29. package/dist/httpsnippet-lite/esm/targets/csharp/httpclient/client.js.map +7 -0
  30. package/dist/httpsnippet-lite/esm/targets/csharp/restsharp/client.js +47 -46
  31. package/dist/httpsnippet-lite/esm/targets/csharp/restsharp/client.js.map +7 -0
  32. package/dist/httpsnippet-lite/esm/targets/csharp/target.js +18 -0
  33. package/dist/httpsnippet-lite/esm/targets/csharp/target.js.map +7 -0
  34. package/dist/httpsnippet-lite/esm/targets/go/native/client.d.ts.map +1 -1
  35. package/dist/httpsnippet-lite/esm/targets/go/native/client.js +167 -116
  36. package/dist/httpsnippet-lite/esm/targets/go/native/client.js.map +7 -0
  37. package/dist/httpsnippet-lite/esm/targets/go/target.js +16 -0
  38. package/dist/httpsnippet-lite/esm/targets/go/target.js.map +7 -0
  39. package/dist/httpsnippet-lite/esm/targets/java/asynchttp/client.js +37 -44
  40. package/dist/httpsnippet-lite/esm/targets/java/asynchttp/client.js.map +7 -0
  41. package/dist/httpsnippet-lite/esm/targets/java/nethttp/client.js +41 -43
  42. package/dist/httpsnippet-lite/esm/targets/java/nethttp/client.js.map +7 -0
  43. package/dist/httpsnippet-lite/esm/targets/java/okhttp/client.d.ts.map +1 -1
  44. package/dist/httpsnippet-lite/esm/targets/java/okhttp/client.js +75 -67
  45. package/dist/httpsnippet-lite/esm/targets/java/okhttp/client.js.map +7 -0
  46. package/dist/httpsnippet-lite/esm/targets/java/target.js +22 -0
  47. package/dist/httpsnippet-lite/esm/targets/java/target.js.map +7 -0
  48. package/dist/httpsnippet-lite/esm/targets/java/unirest/client.js +37 -44
  49. package/dist/httpsnippet-lite/esm/targets/java/unirest/client.js.map +7 -0
  50. package/dist/httpsnippet-lite/esm/targets/javascript/axios/client.js +79 -84
  51. package/dist/httpsnippet-lite/esm/targets/javascript/axios/client.js.map +7 -0
  52. package/dist/httpsnippet-lite/esm/targets/javascript/jquery/client.js +76 -83
  53. package/dist/httpsnippet-lite/esm/targets/javascript/jquery/client.js.map +7 -0
  54. package/dist/httpsnippet-lite/esm/targets/javascript/target.js +22 -0
  55. package/dist/httpsnippet-lite/esm/targets/javascript/target.js.map +7 -0
  56. package/dist/httpsnippet-lite/esm/targets/javascript/xhr/client.js +78 -79
  57. package/dist/httpsnippet-lite/esm/targets/javascript/xhr/client.js.map +7 -0
  58. package/dist/httpsnippet-lite/esm/targets/kotlin/okhttp/client.d.ts.map +1 -1
  59. package/dist/httpsnippet-lite/esm/targets/kotlin/okhttp/client.js +75 -67
  60. package/dist/httpsnippet-lite/esm/targets/kotlin/okhttp/client.js.map +7 -0
  61. package/dist/httpsnippet-lite/esm/targets/kotlin/target.js +16 -0
  62. package/dist/httpsnippet-lite/esm/targets/kotlin/target.js.map +7 -0
  63. package/dist/httpsnippet-lite/esm/targets/node/axios/client.js +70 -77
  64. package/dist/httpsnippet-lite/esm/targets/node/axios/client.js.map +7 -0
  65. package/dist/httpsnippet-lite/esm/targets/node/request/client.js +100 -0
  66. package/dist/httpsnippet-lite/esm/targets/node/request/client.js.map +7 -0
  67. package/dist/httpsnippet-lite/esm/targets/node/target.js +24 -0
  68. package/dist/httpsnippet-lite/esm/targets/node/target.js.map +7 -0
  69. package/dist/httpsnippet-lite/esm/targets/objc/helpers.js +36 -52
  70. package/dist/httpsnippet-lite/esm/targets/objc/helpers.js.map +7 -0
  71. package/dist/httpsnippet-lite/esm/targets/objc/nsurlsession/client.js +157 -128
  72. package/dist/httpsnippet-lite/esm/targets/objc/nsurlsession/client.js.map +7 -0
  73. package/dist/httpsnippet-lite/esm/targets/objc/target.js +16 -0
  74. package/dist/httpsnippet-lite/esm/targets/objc/target.js.map +7 -0
  75. package/dist/httpsnippet-lite/esm/targets/ocaml/cohttp/client.js +50 -65
  76. package/dist/httpsnippet-lite/esm/targets/ocaml/cohttp/client.js.map +7 -0
  77. package/dist/httpsnippet-lite/esm/targets/ocaml/target.js +16 -0
  78. package/dist/httpsnippet-lite/esm/targets/ocaml/target.js.map +7 -0
  79. package/dist/httpsnippet-lite/esm/targets/php/helpers.js +72 -0
  80. package/dist/httpsnippet-lite/esm/targets/php/helpers.js.map +7 -0
  81. package/dist/httpsnippet-lite/esm/targets/php/http1/client.js +85 -0
  82. package/dist/httpsnippet-lite/esm/targets/php/http1/client.js.map +7 -0
  83. package/dist/httpsnippet-lite/esm/targets/php/http2/client.js +127 -0
  84. package/dist/httpsnippet-lite/esm/targets/php/http2/client.js.map +7 -0
  85. package/dist/httpsnippet-lite/esm/targets/php/target.js +22 -0
  86. package/dist/httpsnippet-lite/esm/targets/php/target.js.map +7 -0
  87. package/dist/httpsnippet-lite/esm/targets/powershell/common.js +61 -49
  88. package/dist/httpsnippet-lite/esm/targets/powershell/common.js.map +7 -0
  89. package/dist/httpsnippet-lite/esm/targets/powershell/restmethod/client.js +12 -12
  90. package/dist/httpsnippet-lite/esm/targets/powershell/restmethod/client.js.map +7 -0
  91. package/dist/httpsnippet-lite/esm/targets/powershell/target.js +18 -0
  92. package/dist/httpsnippet-lite/esm/targets/powershell/target.js.map +7 -0
  93. package/dist/httpsnippet-lite/esm/targets/powershell/webrequest/client.js +12 -12
  94. package/dist/httpsnippet-lite/esm/targets/powershell/webrequest/client.js.map +7 -0
  95. package/dist/httpsnippet-lite/esm/targets/python/helpers.js +68 -0
  96. package/dist/httpsnippet-lite/esm/targets/python/helpers.js.map +7 -0
  97. package/dist/httpsnippet-lite/esm/targets/python/python3/client.js +71 -90
  98. package/dist/httpsnippet-lite/esm/targets/python/python3/client.js.map +7 -0
  99. package/dist/httpsnippet-lite/esm/targets/python/target.js +16 -0
  100. package/dist/httpsnippet-lite/esm/targets/python/target.js.map +7 -0
  101. package/dist/httpsnippet-lite/esm/targets/r/httr/client.js +99 -124
  102. package/dist/httpsnippet-lite/esm/targets/r/httr/client.js.map +7 -0
  103. package/dist/httpsnippet-lite/esm/targets/r/target.js +16 -0
  104. package/dist/httpsnippet-lite/esm/targets/r/target.js.map +7 -0
  105. package/dist/httpsnippet-lite/esm/targets/ruby/native/client.js +69 -69
  106. package/dist/httpsnippet-lite/esm/targets/ruby/native/client.js.map +7 -0
  107. package/dist/httpsnippet-lite/esm/targets/ruby/target.js +16 -0
  108. package/dist/httpsnippet-lite/esm/targets/ruby/target.js.map +7 -0
  109. package/dist/httpsnippet-lite/esm/targets/shell/httpie/client.d.ts.map +1 -1
  110. package/dist/httpsnippet-lite/esm/targets/shell/httpie/client.js +106 -113
  111. package/dist/httpsnippet-lite/esm/targets/shell/httpie/client.js.map +7 -0
  112. package/dist/httpsnippet-lite/esm/targets/shell/target.js +20 -0
  113. package/dist/httpsnippet-lite/esm/targets/shell/target.js.map +7 -0
  114. package/dist/httpsnippet-lite/esm/targets/shell/wget/client.js +42 -51
  115. package/dist/httpsnippet-lite/esm/targets/shell/wget/client.js.map +7 -0
  116. package/dist/httpsnippet-lite/esm/targets/swift/helpers.js +51 -67
  117. package/dist/httpsnippet-lite/esm/targets/swift/helpers.js.map +7 -0
  118. package/dist/httpsnippet-lite/esm/targets/swift/nsurlsession/client.js +132 -133
  119. package/dist/httpsnippet-lite/esm/targets/swift/nsurlsession/client.js.map +7 -0
  120. package/dist/httpsnippet-lite/esm/targets/swift/target.js +16 -0
  121. package/dist/httpsnippet-lite/esm/targets/swift/target.js.map +7 -0
  122. package/dist/httpsnippet-lite/types/helpers/code-builder.d.js +1 -0
  123. package/dist/httpsnippet-lite/types/helpers/code-builder.d.js.map +7 -0
  124. package/dist/httpsnippet-lite/types/helpers/escape.d.js +1 -0
  125. package/dist/httpsnippet-lite/types/helpers/escape.d.js.map +7 -0
  126. package/dist/httpsnippet-lite/types/helpers/form-data.d.js +28 -0
  127. package/dist/httpsnippet-lite/types/helpers/form-data.d.js.map +7 -0
  128. package/dist/httpsnippet-lite/types/helpers/headers.d.js +1 -0
  129. package/dist/httpsnippet-lite/types/helpers/headers.d.js.map +7 -0
  130. package/dist/httpsnippet-lite/types/helpers/reducer.d.js +1 -0
  131. package/dist/httpsnippet-lite/types/helpers/reducer.d.js.map +7 -0
  132. package/dist/httpsnippet-lite/types/helpers/shell.d.js +1 -0
  133. package/dist/httpsnippet-lite/types/helpers/shell.d.js.map +7 -0
  134. package/dist/httpsnippet-lite/types/helpers/url.d.js +1 -0
  135. package/dist/httpsnippet-lite/types/helpers/url.d.js.map +7 -0
  136. package/dist/httpsnippet-lite/types/helpers/utils.d.js +1 -0
  137. package/dist/httpsnippet-lite/types/helpers/utils.d.js.map +7 -0
  138. package/dist/httpsnippet-lite/types/httpsnippet.d.js +19 -0
  139. package/dist/httpsnippet-lite/types/httpsnippet.d.js.map +7 -0
  140. package/dist/httpsnippet-lite/types/targets/c/libcurl/client.d.js +1 -0
  141. package/dist/httpsnippet-lite/types/targets/c/libcurl/client.d.js.map +7 -0
  142. package/dist/httpsnippet-lite/types/targets/c/target.d.js +1 -0
  143. package/dist/httpsnippet-lite/types/targets/c/target.d.js.map +7 -0
  144. package/dist/httpsnippet-lite/types/targets/clojure/clj_http/client.d.js +1 -0
  145. package/dist/httpsnippet-lite/types/targets/clojure/clj_http/client.d.js.map +7 -0
  146. package/dist/httpsnippet-lite/types/targets/clojure/target.d.js +1 -0
  147. package/dist/httpsnippet-lite/types/targets/clojure/target.d.js.map +7 -0
  148. package/dist/httpsnippet-lite/types/targets/csharp/httpclient/client.d.js +1 -0
  149. package/dist/httpsnippet-lite/types/targets/csharp/httpclient/client.d.js.map +7 -0
  150. package/dist/httpsnippet-lite/types/targets/csharp/restsharp/client.d.js +1 -0
  151. package/dist/httpsnippet-lite/types/targets/csharp/restsharp/client.d.js.map +7 -0
  152. package/dist/httpsnippet-lite/types/targets/csharp/target.d.js +1 -0
  153. package/dist/httpsnippet-lite/types/targets/csharp/target.d.js.map +7 -0
  154. package/dist/httpsnippet-lite/types/targets/dart/http/client.d.js +1 -0
  155. package/dist/httpsnippet-lite/types/targets/dart/http/client.d.js.map +7 -0
  156. package/dist/httpsnippet-lite/types/targets/dart/target.d.js +1 -0
  157. package/dist/httpsnippet-lite/types/targets/dart/target.d.js.map +7 -0
  158. package/dist/httpsnippet-lite/types/targets/go/native/client.d.js +1 -0
  159. package/dist/httpsnippet-lite/types/targets/go/native/client.d.js.map +7 -0
  160. package/dist/httpsnippet-lite/types/targets/go/target.d.js +1 -0
  161. package/dist/httpsnippet-lite/types/targets/go/target.d.js.map +7 -0
  162. package/dist/httpsnippet-lite/types/targets/http/http1.1/client.d.js +1 -0
  163. package/dist/httpsnippet-lite/types/targets/http/http1.1/client.d.js.map +7 -0
  164. package/dist/httpsnippet-lite/types/targets/http/target.d.js +1 -0
  165. package/dist/httpsnippet-lite/types/targets/http/target.d.js.map +7 -0
  166. package/dist/httpsnippet-lite/types/targets/java/asynchttp/client.d.js +1 -0
  167. package/dist/httpsnippet-lite/types/targets/java/asynchttp/client.d.js.map +7 -0
  168. package/dist/httpsnippet-lite/types/targets/java/nethttp/client.d.js +1 -0
  169. package/dist/httpsnippet-lite/types/targets/java/nethttp/client.d.js.map +7 -0
  170. package/dist/httpsnippet-lite/types/targets/java/okhttp/client.d.js +1 -0
  171. package/dist/httpsnippet-lite/types/targets/java/okhttp/client.d.js.map +7 -0
  172. package/dist/httpsnippet-lite/types/targets/java/target.d.js +1 -0
  173. package/dist/httpsnippet-lite/types/targets/java/target.d.js.map +7 -0
  174. package/dist/httpsnippet-lite/types/targets/java/unirest/client.d.js +1 -0
  175. package/dist/httpsnippet-lite/types/targets/java/unirest/client.d.js.map +7 -0
  176. package/dist/httpsnippet-lite/types/targets/javascript/axios/client.d.js +1 -0
  177. package/dist/httpsnippet-lite/types/targets/javascript/axios/client.d.js.map +7 -0
  178. package/dist/httpsnippet-lite/types/targets/javascript/fetch/client.d.js +1 -0
  179. package/dist/httpsnippet-lite/types/targets/javascript/fetch/client.d.js.map +7 -0
  180. package/dist/httpsnippet-lite/types/targets/javascript/jquery/client.d.js +1 -0
  181. package/dist/httpsnippet-lite/types/targets/javascript/jquery/client.d.js.map +7 -0
  182. package/dist/httpsnippet-lite/types/targets/javascript/target.d.js +1 -0
  183. package/dist/httpsnippet-lite/types/targets/javascript/target.d.js.map +7 -0
  184. package/dist/httpsnippet-lite/types/targets/javascript/xhr/client.d.js +1 -0
  185. package/dist/httpsnippet-lite/types/targets/javascript/xhr/client.d.js.map +7 -0
  186. package/dist/httpsnippet-lite/types/targets/kotlin/okhttp/client.d.js +1 -0
  187. package/dist/httpsnippet-lite/types/targets/kotlin/okhttp/client.d.js.map +7 -0
  188. package/dist/httpsnippet-lite/types/targets/kotlin/target.d.js +1 -0
  189. package/dist/httpsnippet-lite/types/targets/kotlin/target.d.js.map +7 -0
  190. package/dist/httpsnippet-lite/types/targets/node/axios/client.d.js +1 -0
  191. package/dist/httpsnippet-lite/types/targets/node/axios/client.d.js.map +7 -0
  192. package/dist/httpsnippet-lite/types/targets/node/fetch/client.d.js +1 -0
  193. package/dist/httpsnippet-lite/types/targets/node/fetch/client.d.js.map +7 -0
  194. package/dist/httpsnippet-lite/types/targets/node/native/client.d.js +1 -0
  195. package/dist/httpsnippet-lite/types/targets/node/native/client.d.js.map +7 -0
  196. package/dist/httpsnippet-lite/types/targets/node/request/client.d.js +1 -0
  197. package/dist/httpsnippet-lite/types/targets/node/request/client.d.js.map +7 -0
  198. package/dist/httpsnippet-lite/types/targets/node/target.d.js +1 -0
  199. package/dist/httpsnippet-lite/types/targets/node/target.d.js.map +7 -0
  200. package/dist/httpsnippet-lite/types/targets/node/unirest/client.d.js +1 -0
  201. package/dist/httpsnippet-lite/types/targets/node/unirest/client.d.js.map +7 -0
  202. package/dist/httpsnippet-lite/types/targets/objc/helpers.d.js +1 -0
  203. package/dist/httpsnippet-lite/types/targets/objc/helpers.d.js.map +7 -0
  204. package/dist/httpsnippet-lite/types/targets/objc/nsurlsession/client.d.js +1 -0
  205. package/dist/httpsnippet-lite/types/targets/objc/nsurlsession/client.d.js.map +7 -0
  206. package/dist/httpsnippet-lite/types/targets/objc/target.d.js +1 -0
  207. package/dist/httpsnippet-lite/types/targets/objc/target.d.js.map +7 -0
  208. package/dist/httpsnippet-lite/types/targets/ocaml/cohttp/client.d.js +1 -0
  209. package/dist/httpsnippet-lite/types/targets/ocaml/cohttp/client.d.js.map +7 -0
  210. package/dist/httpsnippet-lite/types/targets/ocaml/target.d.js +1 -0
  211. package/dist/httpsnippet-lite/types/targets/ocaml/target.d.js.map +7 -0
  212. package/dist/httpsnippet-lite/types/targets/php/curl/client.d.js +1 -0
  213. package/dist/httpsnippet-lite/types/targets/php/curl/client.d.js.map +7 -0
  214. package/dist/httpsnippet-lite/types/targets/php/guzzle/client.d.js +1 -0
  215. package/dist/httpsnippet-lite/types/targets/php/guzzle/client.d.js.map +7 -0
  216. package/dist/httpsnippet-lite/types/targets/php/helpers.d.js +1 -0
  217. package/dist/httpsnippet-lite/types/targets/php/helpers.d.js.map +7 -0
  218. package/dist/httpsnippet-lite/types/targets/php/http1/client.d.js +1 -0
  219. package/dist/httpsnippet-lite/types/targets/php/http1/client.d.js.map +7 -0
  220. package/dist/httpsnippet-lite/types/targets/php/http2/client.d.js +1 -0
  221. package/dist/httpsnippet-lite/types/targets/php/http2/client.d.js.map +7 -0
  222. package/dist/httpsnippet-lite/types/targets/php/target.d.js +1 -0
  223. package/dist/httpsnippet-lite/types/targets/php/target.d.js.map +7 -0
  224. package/dist/httpsnippet-lite/types/targets/powershell/common.d.js +1 -0
  225. package/dist/httpsnippet-lite/types/targets/powershell/common.d.js.map +7 -0
  226. package/dist/httpsnippet-lite/types/targets/powershell/restmethod/client.d.js +1 -0
  227. package/dist/httpsnippet-lite/types/targets/powershell/restmethod/client.d.js.map +7 -0
  228. package/dist/httpsnippet-lite/types/targets/powershell/target.d.js +1 -0
  229. package/dist/httpsnippet-lite/types/targets/powershell/target.d.js.map +7 -0
  230. package/dist/httpsnippet-lite/types/targets/powershell/webrequest/client.d.js +1 -0
  231. package/dist/httpsnippet-lite/types/targets/powershell/webrequest/client.d.js.map +7 -0
  232. package/dist/httpsnippet-lite/types/targets/python/helpers.d.js +1 -0
  233. package/dist/httpsnippet-lite/types/targets/python/helpers.d.js.map +7 -0
  234. package/dist/httpsnippet-lite/types/targets/python/python3/client.d.js +1 -0
  235. package/dist/httpsnippet-lite/types/targets/python/python3/client.d.js.map +7 -0
  236. package/dist/httpsnippet-lite/types/targets/python/requests/client.d.js +1 -0
  237. package/dist/httpsnippet-lite/types/targets/python/requests/client.d.js.map +7 -0
  238. package/dist/httpsnippet-lite/types/targets/python/target.d.js +1 -0
  239. package/dist/httpsnippet-lite/types/targets/python/target.d.js.map +7 -0
  240. package/dist/httpsnippet-lite/types/targets/r/httr/client.d.js +1 -0
  241. package/dist/httpsnippet-lite/types/targets/r/httr/client.d.js.map +7 -0
  242. package/dist/httpsnippet-lite/types/targets/r/target.d.js +1 -0
  243. package/dist/httpsnippet-lite/types/targets/r/target.d.js.map +7 -0
  244. package/dist/httpsnippet-lite/types/targets/ruby/native/client.d.js +1 -0
  245. package/dist/httpsnippet-lite/types/targets/ruby/native/client.d.js.map +7 -0
  246. package/dist/httpsnippet-lite/types/targets/ruby/target.d.js +1 -0
  247. package/dist/httpsnippet-lite/types/targets/ruby/target.d.js.map +7 -0
  248. package/dist/httpsnippet-lite/types/targets/shell/curl/client.d.js +1 -0
  249. package/dist/httpsnippet-lite/types/targets/shell/curl/client.d.js.map +7 -0
  250. package/dist/httpsnippet-lite/types/targets/shell/httpie/client.d.js +1 -0
  251. package/dist/httpsnippet-lite/types/targets/shell/httpie/client.d.js.map +7 -0
  252. package/dist/httpsnippet-lite/types/targets/shell/target.d.js +1 -0
  253. package/dist/httpsnippet-lite/types/targets/shell/target.d.js.map +7 -0
  254. package/dist/httpsnippet-lite/types/targets/shell/wget/client.d.js +1 -0
  255. package/dist/httpsnippet-lite/types/targets/shell/wget/client.d.js.map +7 -0
  256. package/dist/httpsnippet-lite/types/targets/swift/helpers.d.js +1 -0
  257. package/dist/httpsnippet-lite/types/targets/swift/helpers.d.js.map +7 -0
  258. package/dist/httpsnippet-lite/types/targets/swift/nsurlsession/client.d.js +1 -0
  259. package/dist/httpsnippet-lite/types/targets/swift/nsurlsession/client.d.js.map +7 -0
  260. package/dist/httpsnippet-lite/types/targets/swift/target.d.js +1 -0
  261. package/dist/httpsnippet-lite/types/targets/swift/target.d.js.map +7 -0
  262. package/dist/httpsnippet-lite/types/targets/targets.d.js +1 -0
  263. package/dist/httpsnippet-lite/types/targets/targets.d.js.map +7 -0
  264. package/dist/index.js +3 -2
  265. package/dist/index.js.map +7 -0
  266. package/dist/plugins/c/libcurl/index.js +2 -1
  267. package/dist/plugins/c/libcurl/index.js.map +7 -0
  268. package/dist/plugins/c/libcurl/libcurl.js +12 -15
  269. package/dist/plugins/c/libcurl/libcurl.js.map +7 -0
  270. package/dist/plugins/c/libcurl/libcurl.test.js +208 -0
  271. package/dist/plugins/c/libcurl/libcurl.test.js.map +7 -0
  272. package/dist/plugins/clojure/clj_http/clj_http.js +12 -15
  273. package/dist/plugins/clojure/clj_http/clj_http.js.map +7 -0
  274. package/dist/plugins/clojure/clj_http/clj_http.test.js +151 -0
  275. package/dist/plugins/clojure/clj_http/clj_http.test.js.map +7 -0
  276. package/dist/plugins/clojure/clj_http/index.js +2 -1
  277. package/dist/plugins/clojure/clj_http/index.js.map +7 -0
  278. package/dist/plugins/csharp/httpclient/httpclient.js +12 -15
  279. package/dist/plugins/csharp/httpclient/httpclient.js.map +7 -0
  280. package/dist/plugins/csharp/httpclient/index.js +2 -1
  281. package/dist/plugins/csharp/httpclient/index.js.map +7 -0
  282. package/dist/plugins/csharp/restsharp/index.js +2 -1
  283. package/dist/plugins/csharp/restsharp/index.js.map +7 -0
  284. package/dist/plugins/csharp/restsharp/restsharp.js +12 -15
  285. package/dist/plugins/csharp/restsharp/restsharp.js.map +7 -0
  286. package/dist/plugins/dart/http/http.js +92 -96
  287. package/dist/plugins/dart/http/http.js.map +7 -0
  288. package/dist/plugins/dart/http/http.test.js +550 -0
  289. package/dist/plugins/dart/http/http.test.js.map +7 -0
  290. package/dist/plugins/dart/http/index.js +2 -1
  291. package/dist/plugins/dart/http/index.js.map +7 -0
  292. package/dist/plugins/go/native/index.js +2 -1
  293. package/dist/plugins/go/native/index.js.map +7 -0
  294. package/dist/plugins/go/native/native.js +12 -15
  295. package/dist/plugins/go/native/native.js.map +7 -0
  296. package/dist/plugins/go/native/native.test.js +366 -0
  297. package/dist/plugins/go/native/native.test.js.map +7 -0
  298. package/dist/plugins/http/http11/http11.js +84 -104
  299. package/dist/plugins/http/http11/http11.js.map +7 -0
  300. package/dist/plugins/http/http11/http11.test.js +175 -0
  301. package/dist/plugins/http/http11/http11.test.js.map +7 -0
  302. package/dist/plugins/http/http11/index.js +2 -1
  303. package/dist/plugins/http/http11/index.js.map +7 -0
  304. package/dist/plugins/java/asynchttp/asynchttp.js +12 -15
  305. package/dist/plugins/java/asynchttp/asynchttp.js.map +7 -0
  306. package/dist/plugins/java/asynchttp/index.js +2 -1
  307. package/dist/plugins/java/asynchttp/index.js.map +7 -0
  308. package/dist/plugins/java/nethttp/index.js +2 -1
  309. package/dist/plugins/java/nethttp/index.js.map +7 -0
  310. package/dist/plugins/java/nethttp/nethttp.js +12 -15
  311. package/dist/plugins/java/nethttp/nethttp.js.map +7 -0
  312. package/dist/plugins/java/okhttp/index.js +2 -1
  313. package/dist/plugins/java/okhttp/index.js.map +7 -0
  314. package/dist/plugins/java/okhttp/okhttp.js +12 -15
  315. package/dist/plugins/java/okhttp/okhttp.js.map +7 -0
  316. package/dist/plugins/java/okhttp/okhttp.test.js +164 -0
  317. package/dist/plugins/java/okhttp/okhttp.test.js.map +7 -0
  318. package/dist/plugins/java/unirest/index.js +2 -1
  319. package/dist/plugins/java/unirest/index.js.map +7 -0
  320. package/dist/plugins/java/unirest/unirest.js +12 -15
  321. package/dist/plugins/java/unirest/unirest.js.map +7 -0
  322. package/dist/plugins/js/axios/axios.js +12 -15
  323. package/dist/plugins/js/axios/axios.js.map +7 -0
  324. package/dist/plugins/js/axios/index.d.ts +1 -1
  325. package/dist/plugins/js/axios/index.d.ts.map +1 -1
  326. package/dist/plugins/js/axios/index.js +5 -1
  327. package/dist/plugins/js/axios/index.js.map +7 -0
  328. package/dist/plugins/js/fetch/fetch.d.ts.map +1 -1
  329. package/dist/plugins/js/fetch/fetch.js +67 -60
  330. package/dist/plugins/js/fetch/fetch.js.map +7 -0
  331. package/dist/plugins/js/fetch/fetch.test.js +214 -0
  332. package/dist/plugins/js/fetch/fetch.test.js.map +7 -0
  333. package/dist/plugins/js/fetch/index.d.ts +1 -1
  334. package/dist/plugins/js/fetch/index.d.ts.map +1 -1
  335. package/dist/plugins/js/fetch/index.js +5 -1
  336. package/dist/plugins/js/fetch/index.js.map +7 -0
  337. package/dist/plugins/js/jquery/index.js +2 -1
  338. package/dist/plugins/js/jquery/index.js.map +7 -0
  339. package/dist/plugins/js/jquery/jquery.js +12 -15
  340. package/dist/plugins/js/jquery/jquery.js.map +7 -0
  341. package/dist/plugins/js/ofetch/index.js +2 -1
  342. package/dist/plugins/js/ofetch/index.js.map +7 -0
  343. package/dist/plugins/js/ofetch/ofetch.d.ts.map +1 -1
  344. package/dist/plugins/js/ofetch/ofetch.js +44 -67
  345. package/dist/plugins/js/ofetch/ofetch.js.map +7 -0
  346. package/dist/plugins/js/ofetch/ofetch.test.js +126 -0
  347. package/dist/plugins/js/ofetch/ofetch.test.js.map +7 -0
  348. package/dist/plugins/js/xhr/index.js +2 -1
  349. package/dist/plugins/js/xhr/index.js.map +7 -0
  350. package/dist/plugins/js/xhr/xhr.js +12 -15
  351. package/dist/plugins/js/xhr/xhr.js.map +7 -0
  352. package/dist/plugins/kotlin/okhttp/index.js +2 -1
  353. package/dist/plugins/kotlin/okhttp/index.js.map +7 -0
  354. package/dist/plugins/kotlin/okhttp/okhttp.js +12 -15
  355. package/dist/plugins/kotlin/okhttp/okhttp.js.map +7 -0
  356. package/dist/plugins/kotlin/okhttp/okhttp.test.js +164 -0
  357. package/dist/plugins/kotlin/okhttp/okhttp.test.js.map +7 -0
  358. package/dist/plugins/node/axios/axios.js +12 -15
  359. package/dist/plugins/node/axios/axios.js.map +7 -0
  360. package/dist/plugins/node/axios/index.js +2 -1
  361. package/dist/plugins/node/axios/index.js.map +7 -0
  362. package/dist/plugins/node/fetch/fetch.d.ts.map +1 -1
  363. package/dist/plugins/node/fetch/fetch.js +73 -59
  364. package/dist/plugins/node/fetch/fetch.js.map +7 -0
  365. package/dist/plugins/node/fetch/fetch.test.js +200 -0
  366. package/dist/plugins/node/fetch/fetch.test.js.map +7 -0
  367. package/dist/plugins/node/fetch/index.js +2 -1
  368. package/dist/plugins/node/fetch/index.js.map +7 -0
  369. package/dist/plugins/node/ofetch/index.js +2 -1
  370. package/dist/plugins/node/ofetch/index.js.map +7 -0
  371. package/dist/plugins/node/ofetch/ofetch.d.ts.map +1 -1
  372. package/dist/plugins/node/ofetch/ofetch.js +44 -67
  373. package/dist/plugins/node/ofetch/ofetch.js.map +7 -0
  374. package/dist/plugins/node/ofetch/ofetch.test.js +126 -0
  375. package/dist/plugins/node/ofetch/ofetch.test.js.map +7 -0
  376. package/dist/plugins/node/undici/index.js +2 -1
  377. package/dist/plugins/node/undici/index.js.map +7 -0
  378. package/dist/plugins/node/undici/undici.d.ts.map +1 -1
  379. package/dist/plugins/node/undici/undici.js +46 -62
  380. package/dist/plugins/node/undici/undici.js.map +7 -0
  381. package/dist/plugins/node/undici/undici.test.js +133 -0
  382. package/dist/plugins/node/undici/undici.test.js.map +7 -0
  383. package/dist/plugins/objc/nsurlsession/index.js +2 -1
  384. package/dist/plugins/objc/nsurlsession/index.js.map +7 -0
  385. package/dist/plugins/objc/nsurlsession/nsurlsession.js +12 -15
  386. package/dist/plugins/objc/nsurlsession/nsurlsession.js.map +7 -0
  387. package/dist/plugins/ocaml/cohttp/cohttp.js +12 -15
  388. package/dist/plugins/ocaml/cohttp/cohttp.js.map +7 -0
  389. package/dist/plugins/ocaml/cohttp/index.js +2 -1
  390. package/dist/plugins/ocaml/cohttp/index.js.map +7 -0
  391. package/dist/plugins/php/curl/curl.js +119 -157
  392. package/dist/plugins/php/curl/curl.js.map +7 -0
  393. package/dist/plugins/php/curl/curl.test.js +564 -0
  394. package/dist/plugins/php/curl/curl.test.js.map +7 -0
  395. package/dist/plugins/php/curl/index.js +2 -1
  396. package/dist/plugins/php/curl/index.js.map +7 -0
  397. package/dist/plugins/php/guzzle/guzzle.js +115 -148
  398. package/dist/plugins/php/guzzle/guzzle.js.map +7 -0
  399. package/dist/plugins/php/guzzle/guzzle.test.js +546 -0
  400. package/dist/plugins/php/guzzle/guzzle.test.js.map +7 -0
  401. package/dist/plugins/php/guzzle/index.js +2 -1
  402. package/dist/plugins/php/guzzle/index.js.map +7 -0
  403. package/dist/plugins/powershell/restmethod/index.js +2 -1
  404. package/dist/plugins/powershell/restmethod/index.js.map +7 -0
  405. package/dist/plugins/powershell/restmethod/restmethod.js +12 -15
  406. package/dist/plugins/powershell/restmethod/restmethod.js.map +7 -0
  407. package/dist/plugins/powershell/webrequest/index.js +2 -1
  408. package/dist/plugins/powershell/webrequest/index.js.map +7 -0
  409. package/dist/plugins/powershell/webrequest/webrequest.js +12 -15
  410. package/dist/plugins/powershell/webrequest/webrequest.js.map +7 -0
  411. package/dist/plugins/python/python3/index.js +2 -1
  412. package/dist/plugins/python/python3/index.js.map +7 -0
  413. package/dist/plugins/python/python3/python3.js +12 -15
  414. package/dist/plugins/python/python3/python3.js.map +7 -0
  415. package/dist/plugins/python/requests/index.js +2 -1
  416. package/dist/plugins/python/requests/index.js.map +7 -0
  417. package/dist/plugins/python/requests/requests.d.ts.map +1 -1
  418. package/dist/plugins/python/requests/requests.js +98 -126
  419. package/dist/plugins/python/requests/requests.js.map +7 -0
  420. package/dist/plugins/python/requests/requests.test.js +419 -0
  421. package/dist/plugins/python/requests/requests.test.js.map +7 -0
  422. package/dist/plugins/r/httr/httr.js +12 -15
  423. package/dist/plugins/r/httr/httr.js.map +7 -0
  424. package/dist/plugins/r/httr/index.js +2 -1
  425. package/dist/plugins/r/httr/index.js.map +7 -0
  426. package/dist/plugins/ruby/native/index.js +2 -1
  427. package/dist/plugins/ruby/native/index.js.map +7 -0
  428. package/dist/plugins/ruby/native/native.js +12 -15
  429. package/dist/plugins/ruby/native/native.js.map +7 -0
  430. package/dist/plugins/ruby/native/native.test.js +240 -0
  431. package/dist/plugins/ruby/native/native.test.js.map +7 -0
  432. package/dist/plugins/shell/curl/curl.js +81 -114
  433. package/dist/plugins/shell/curl/curl.js.map +7 -0
  434. package/dist/plugins/shell/curl/curl.test.js +427 -0
  435. package/dist/plugins/shell/curl/curl.test.js.map +7 -0
  436. package/dist/plugins/shell/curl/index.js +2 -1
  437. package/dist/plugins/shell/curl/index.js.map +7 -0
  438. package/dist/plugins/shell/httpie/httpie.js +12 -15
  439. package/dist/plugins/shell/httpie/httpie.js.map +7 -0
  440. package/dist/plugins/shell/httpie/httpie.test.js +113 -0
  441. package/dist/plugins/shell/httpie/httpie.test.js.map +7 -0
  442. package/dist/plugins/shell/httpie/index.js +2 -1
  443. package/dist/plugins/shell/httpie/index.js.map +7 -0
  444. package/dist/plugins/shell/wget/index.js +2 -1
  445. package/dist/plugins/shell/wget/index.js.map +7 -0
  446. package/dist/plugins/shell/wget/wget.js +12 -15
  447. package/dist/plugins/shell/wget/wget.js.map +7 -0
  448. package/dist/plugins/shell/wget/wget.test.js +143 -0
  449. package/dist/plugins/shell/wget/wget.test.js.map +7 -0
  450. package/dist/plugins/swift/nsurlsession/index.js +2 -1
  451. package/dist/plugins/swift/nsurlsession/index.js.map +7 -0
  452. package/dist/plugins/swift/nsurlsession/nsurlsession.js +12 -15
  453. package/dist/plugins/swift/nsurlsession/nsurlsession.js.map +7 -0
  454. package/dist/plugins/swift/nsurlsession/nsurlsession.test.js +344 -0
  455. package/dist/plugins/swift/nsurlsession/nsurlsession.test.js.map +7 -0
  456. package/dist/snippetz.js +27 -27
  457. package/dist/snippetz.js.map +7 -0
  458. package/dist/snippetz.test.js +79 -0
  459. package/dist/snippetz.test.js.map +7 -0
  460. package/dist/utils/convertWithHttpSnippetLite.js +101 -104
  461. package/dist/utils/convertWithHttpSnippetLite.js.map +7 -0
  462. package/dist/utils/convertWithHttpSnippetLite.test.js +106 -0
  463. package/dist/utils/convertWithHttpSnippetLite.test.js.map +7 -0
  464. package/dist/utils/create-search-params.d.ts +4 -0
  465. package/dist/utils/create-search-params.d.ts.map +1 -0
  466. package/dist/utils/create-search-params.js +11 -0
  467. package/dist/utils/create-search-params.js.map +7 -0
  468. package/dist/utils/create-search-params.test.js +49 -0
  469. package/dist/utils/create-search-params.test.js.map +7 -0
  470. package/dist/utils/index.d.ts +0 -1
  471. package/dist/utils/index.d.ts.map +1 -1
  472. package/dist/utils/index.js +4 -4
  473. package/dist/utils/index.js.map +7 -0
  474. package/dist/utils/needsQuotes.js +5 -8
  475. package/dist/utils/needsQuotes.js.map +7 -0
  476. package/dist/utils/objectToString.d.ts +8 -0
  477. package/dist/utils/objectToString.d.ts.map +1 -1
  478. package/dist/utils/objectToString.js +48 -54
  479. package/dist/utils/objectToString.js.map +7 -0
  480. package/package.json +147 -151
  481. package/dist/utils/arrayToObject.d.ts +0 -8
  482. package/dist/utils/arrayToObject.d.ts.map +0 -1
  483. package/dist/utils/arrayToObject.js +0 -14
@@ -1,123 +1,174 @@
1
- import { CodeBuilder } from '../../../helpers/code-builder.js';
2
- import { escapeForDoubleQuotes } from '../../../helpers/escape.js';
3
-
4
- // @ts-nocheck
5
- /**
6
- * @description
7
- * HTTP code snippet generator for native Go.
8
- *
9
- * @author
10
- * @montanaflynn
11
- *
12
- * for any questions or issues regarding the generated code snippet, please open an issue mentioning the author.
13
- */
1
+ import { CodeBuilder } from "../../../helpers/code-builder.js";
2
+ import { escapeForDoubleQuotes } from "../../../helpers/escape.js";
14
3
  const native = {
15
- info: {
16
- key: 'native',
17
- title: 'NewRequest',
18
- link: 'http://golang.org/pkg/net/http/#NewRequest',
19
- description: 'Golang HTTP client request',
20
- },
21
- convert: ({ postData, method, allHeaders, fullUrl }, options = {}) => {
22
- const { blank, push, join } = new CodeBuilder({ indent: '\t' });
23
- const { showBoilerplate = true, checkErrors = false, printBody = true, timeout = -1, insecureSkipVerify = false, } = options;
24
- const errorPlaceholder = checkErrors ? 'err' : '_';
25
- const indent = showBoilerplate ? 1 : 0;
26
- const errorCheck = () => {
27
- if (checkErrors) {
28
- push('if err != nil {', indent);
29
- push('panic(err)', indent + 1);
30
- push('}', indent);
31
- }
32
- };
33
- // Create boilerplate
34
- if (showBoilerplate) {
35
- push('package main');
36
- blank();
37
- push('import (');
38
- push('"fmt"', indent);
39
- if (timeout > 0) {
40
- push('"time"', indent);
41
- }
42
- if (insecureSkipVerify) {
43
- push('"crypto/tls"', indent);
44
- }
45
- if (postData === null || postData === void 0 ? void 0 : postData.text) {
46
- push('"strings"', indent);
47
- }
48
- push('"net/http"', indent);
49
- if (printBody) {
50
- push('"io"', indent);
51
- }
52
- push(')');
53
- blank();
54
- push('func main() {');
55
- blank();
56
- }
57
- // Create an insecure transport for the client
58
- if (insecureSkipVerify) {
59
- push('insecureTransport := http.DefaultTransport.(*http.Transport).Clone()', indent);
60
- push('insecureTransport.TLSClientConfig = &tls.Config{InsecureSkipVerify: true}', indent);
61
- }
62
- // Create client
63
- const hasTimeout = timeout > 0;
64
- const hasClient = hasTimeout || insecureSkipVerify;
65
- const client = hasClient ? 'client' : 'http.DefaultClient';
66
- if (hasClient) {
67
- push('client := http.Client{', indent);
68
- if (hasTimeout) {
69
- push(`Timeout: time.Duration(${timeout} * time.Second),`, indent + 1);
70
- }
71
- if (insecureSkipVerify) {
72
- push('Transport: insecureTransport,', indent + 1);
73
- }
74
- push('}', indent);
75
- blank();
76
- }
77
- push(`url := "${fullUrl}"`, indent);
4
+ info: {
5
+ key: "native",
6
+ title: "NewRequest",
7
+ link: "http://golang.org/pkg/net/http/#NewRequest",
8
+ description: "Golang HTTP client request"
9
+ },
10
+ convert: ({ postData, method, allHeaders, fullUrl }, options = {}) => {
11
+ const { blank, push, join, addPostProcessor } = new CodeBuilder({ indent: " " });
12
+ const {
13
+ showBoilerplate = true,
14
+ checkErrors = false,
15
+ printBody = true,
16
+ timeout = -1,
17
+ insecureSkipVerify = false
18
+ } = options;
19
+ const errorPlaceholder = checkErrors ? "err" : "_";
20
+ const indent = showBoilerplate ? 1 : 0;
21
+ const errorCheck = () => {
22
+ if (checkErrors) {
23
+ push("if err != nil {", indent);
24
+ push("panic(err)", indent + 1);
25
+ push("}", indent);
26
+ }
27
+ };
28
+ const imports = /* @__PURE__ */ new Set();
29
+ if (showBoilerplate) {
30
+ push("package main");
31
+ blank();
32
+ push("import ()");
33
+ addPostProcessor((code) => {
34
+ const importArray = [...imports];
35
+ importArray.sort();
36
+ const importBlock = importArray.map((line) => ` "${line}"`).join("\n");
37
+ return code.replace(/import \(\)/, `import (
38
+ ${importBlock}
39
+ )`);
40
+ });
41
+ imports.add("fmt");
42
+ imports.add("net/http");
43
+ blank();
44
+ push("func main() {");
45
+ }
46
+ if (insecureSkipVerify) {
47
+ imports.add("crypto/tls");
48
+ push(
49
+ "insecureTransport := http.DefaultTransport.(*http.Transport).Clone()",
50
+ indent
51
+ );
52
+ push(
53
+ "insecureTransport.TLSClientConfig = &tls.Config{InsecureSkipVerify: true}",
54
+ indent
55
+ );
56
+ }
57
+ const hasTimeout = timeout > 0;
58
+ const hasClient = hasTimeout || insecureSkipVerify;
59
+ const client = hasClient ? "client" : "http.DefaultClient";
60
+ if (hasClient) {
61
+ push("client := http.Client{", indent);
62
+ if (hasTimeout) {
63
+ imports.add("time");
64
+ push(`Timeout: time.Duration(${timeout} * time.Second),`, indent + 1);
65
+ }
66
+ if (insecureSkipVerify) {
67
+ push("Transport: insecureTransport,", indent + 1);
68
+ }
69
+ push("}", indent);
70
+ blank();
71
+ }
72
+ push(`url := "${fullUrl}"`, indent);
73
+ blank();
74
+ if (postData !== null && postData !== void 0 && (postData.params || postData.text)) {
75
+ if (postData.mimeType === "application/x-www-form-urlencoded" && postData.params) {
76
+ imports.add("net/url");
77
+ imports.add("strings");
78
+ push("postData := url.Values{}", indent);
79
+ postData.params.forEach((param) => {
80
+ push(
81
+ `postData.Set("${param.name}", "${escapeForDoubleQuotes(param.value)}")`,
82
+ indent
83
+ );
84
+ });
78
85
  blank();
79
- // If we have body content or not create the var and reader or nil
80
- if (postData === null || postData === void 0 ? void 0 : postData.text) {
81
- push(`payload := strings.NewReader(${JSON.stringify(postData.text)})`, indent);
82
- blank();
83
- push(`req, ${errorPlaceholder} := http.NewRequest("${method}", url, payload)`, indent);
84
- blank();
85
- }
86
- else {
87
- push(`req, ${errorPlaceholder} := http.NewRequest("${method}", url, nil)`, indent);
88
- blank();
89
- }
90
- errorCheck();
91
- // Add headers
92
- if (Object.keys(allHeaders).length) {
93
- Object.keys(allHeaders).forEach((key) => {
94
- push(`req.Header.Add("${key}", "${escapeForDoubleQuotes(allHeaders[key])}")`, indent);
95
- });
86
+ push(
87
+ `req, ${errorPlaceholder} := http.NewRequest("${method}", url, strings.NewReader(postData.Encode()))`,
88
+ indent
89
+ );
90
+ } else if (postData.mimeType === "multipart/form-data" && postData.params) {
91
+ imports.add("bytes");
92
+ imports.add("mime/multipart");
93
+ push("payload := &bytes.Buffer{}", indent);
94
+ push("writer := multipart.NewWriter(payload)", indent);
95
+ postData.params.forEach((param) => {
96
+ blank();
97
+ if (param.fileName) {
98
+ push(`part, ${errorPlaceholder} := writer.CreateFormFile("${param.name}", "${param.fileName}")`, indent);
99
+ errorCheck();
96
100
  blank();
97
- }
98
- // Make request
99
- push(`res, ${errorPlaceholder} := ${client}.Do(req)`, indent);
100
- errorCheck();
101
- // Get Body
102
- if (printBody) {
101
+ push(`f, ${errorPlaceholder} := os.Open("${param.fileName}")`, indent);
102
+ errorCheck();
103
+ push("defer f.Close()", indent);
103
104
  blank();
104
- push('defer res.Body.Close()', indent);
105
- push(`body, ${errorPlaceholder} := io.ReadAll(res.Body)`, indent);
105
+ push(`_, ${errorPlaceholder} = io.Copy(part, f)`, indent);
106
+ errorCheck();
107
+ } else {
108
+ push(`${errorPlaceholder} = writer.WriteField("${param.name}", "${escapeForDoubleQuotes(param.value)}")`, indent);
106
109
  errorCheck();
107
- }
108
- // Print it
110
+ }
111
+ });
112
+ push("writer.Close()", indent);
109
113
  blank();
110
- push('fmt.Println(res)', indent);
111
- if (printBody) {
112
- push('fmt.Println(string(body))', indent);
113
- }
114
- // End main block
115
- if (showBoilerplate) {
116
- blank();
117
- push('}');
118
- }
119
- return join();
120
- },
114
+ push(
115
+ `req, ${errorPlaceholder} := http.NewRequest("${method}", url, payload)`,
116
+ indent
117
+ );
118
+ } else {
119
+ imports.add("strings");
120
+ push(
121
+ `payload := strings.NewReader(${JSON.stringify(postData.text)})`,
122
+ indent
123
+ );
124
+ blank();
125
+ push(
126
+ `req, ${errorPlaceholder} := http.NewRequest("${method}", url, payload)`,
127
+ indent
128
+ );
129
+ }
130
+ } else {
131
+ push(
132
+ `req, ${errorPlaceholder} := http.NewRequest("${method}", url, nil)`,
133
+ indent
134
+ );
135
+ }
136
+ errorCheck();
137
+ blank();
138
+ if (postData !== null && postData !== void 0 && postData.mimeType === "multipart/form-data" && postData.params) {
139
+ push(`req.Header.Set("Content-Type", writer.FormDataContentType())`, indent);
140
+ }
141
+ if (Object.keys(allHeaders).length) {
142
+ Object.keys(allHeaders).forEach((key) => {
143
+ push(
144
+ `req.Header.Add("${key}", "${escapeForDoubleQuotes(allHeaders[key])}")`,
145
+ indent
146
+ );
147
+ });
148
+ blank();
149
+ }
150
+ push(`res, ${errorPlaceholder} := ${client}.Do(req)`, indent);
151
+ errorCheck();
152
+ if (printBody) {
153
+ imports.add("io");
154
+ blank();
155
+ push("defer res.Body.Close()", indent);
156
+ push(`body, ${errorPlaceholder} := io.ReadAll(res.Body)`, indent);
157
+ errorCheck();
158
+ }
159
+ blank();
160
+ push("fmt.Println(res)", indent);
161
+ if (printBody) {
162
+ push("fmt.Println(string(body))", indent);
163
+ }
164
+ if (showBoilerplate) {
165
+ blank();
166
+ push("}");
167
+ }
168
+ return join();
169
+ }
170
+ };
171
+ export {
172
+ native
121
173
  };
122
-
123
- export { native };
174
+ //# sourceMappingURL=client.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../../src/httpsnippet-lite/esm/targets/go/native/client.ts"],
4
+ "sourcesContent": ["// @ts-nocheck\n/**\n * @description\n * HTTP code snippet generator for native Go.\n *\n * @author\n * @montanaflynn\n *\n * for any questions or issues regarding the generated code snippet, please open an issue mentioning the author.\n */\nimport { CodeBuilder } from '../../../helpers/code-builder.js'\nimport { escapeForDoubleQuotes } from '../../../helpers/escape.js'\n\nexport const native = {\n info: {\n key: 'native',\n title: 'NewRequest',\n link: 'http://golang.org/pkg/net/http/#NewRequest',\n description: 'Golang HTTP client request',\n },\n convert: ({ postData, method, allHeaders, fullUrl }, options = {}) => {\n const { blank, push, join, addPostProcessor } = new CodeBuilder({ indent: '\\t' })\n const {\n showBoilerplate = true,\n checkErrors = false,\n printBody = true,\n timeout = -1,\n insecureSkipVerify = false,\n } = options\n const errorPlaceholder = checkErrors ? 'err' : '_'\n const indent = showBoilerplate ? 1 : 0\n const errorCheck = () => {\n if (checkErrors) {\n push('if err != nil {', indent)\n push('panic(err)', indent + 1)\n push('}', indent)\n }\n }\n // Create boilerplate\n const imports = new Set()\n if (showBoilerplate) {\n push('package main')\n blank()\n\n push('import ()')\n addPostProcessor((code) => {\n const importArray = [...imports]\n importArray.sort()\n const importBlock = importArray.map((line) => `\\t\"${line}\"`).join('\\n')\n return code.replace(/import \\(\\)/, `import (\\n${importBlock}\\n)`)\n })\n\n imports.add('fmt')\n imports.add('net/http')\n\n blank()\n push('func main() {')\n }\n // Create an insecure transport for the client\n if (insecureSkipVerify) {\n imports.add('crypto/tls')\n push(\n 'insecureTransport := http.DefaultTransport.(*http.Transport).Clone()',\n indent,\n )\n push(\n 'insecureTransport.TLSClientConfig = &tls.Config{InsecureSkipVerify: true}',\n indent,\n )\n }\n // Create client\n const hasTimeout = timeout > 0\n const hasClient = hasTimeout || insecureSkipVerify\n const client = hasClient ? 'client' : 'http.DefaultClient'\n if (hasClient) {\n push('client := http.Client{', indent)\n if (hasTimeout) {\n imports.add('time')\n push(`Timeout: time.Duration(${timeout} * time.Second),`, indent + 1)\n }\n if (insecureSkipVerify) {\n push('Transport: insecureTransport,', indent + 1)\n }\n push('}', indent)\n blank()\n }\n push(`url := \"${fullUrl}\"`, indent)\n blank()\n // If we have body content or not create the var and reader or nil\n if (postData !== null && postData !== void 0 && (postData.params || postData.text)) {\n if (postData.mimeType === 'application/x-www-form-urlencoded' && postData.params) {\n imports.add('net/url')\n imports.add('strings')\n\n push('postData := url.Values{}', indent)\n postData.params.forEach((param) => {\n push(\n `postData.Set(\"${param.name}\", \"${escapeForDoubleQuotes(param.value)}\")`,\n indent,\n )\n })\n blank()\n push(\n `req, ${errorPlaceholder} := http.NewRequest(\"${method}\", url, strings.NewReader(postData.Encode()))`,\n indent,\n )\n } else if (postData.mimeType === 'multipart/form-data' && postData.params) {\n imports.add('bytes')\n imports.add('mime/multipart')\n\n push('payload := &bytes.Buffer{}', indent)\n push('writer := multipart.NewWriter(payload)', indent)\n postData.params.forEach((param) => {\n blank()\n if (param.fileName) {\n push(`part, ${errorPlaceholder} := writer.CreateFormFile(\"${param.name}\", \"${param.fileName}\")`, indent)\n errorCheck()\n blank()\n push(`f, ${errorPlaceholder} := os.Open(\"${param.fileName}\")`, indent)\n errorCheck()\n push('defer f.Close()', indent)\n blank()\n push(`_, ${errorPlaceholder} = io.Copy(part, f)`, indent)\n errorCheck()\n } else {\n push(`${errorPlaceholder} = writer.WriteField(\"${param.name}\", \"${escapeForDoubleQuotes(param.value)}\")`, indent)\n errorCheck()\n }\n })\n push('writer.Close()', indent)\n blank()\n push(\n `req, ${errorPlaceholder} := http.NewRequest(\"${method}\", url, payload)`,\n indent,\n )\n } else {\n imports.add('strings')\n\n push(\n `payload := strings.NewReader(${JSON.stringify(postData.text)})`,\n indent,\n )\n blank()\n push(\n `req, ${errorPlaceholder} := http.NewRequest(\"${method}\", url, payload)`,\n indent,\n )\n }\n } else {\n push(\n `req, ${errorPlaceholder} := http.NewRequest(\"${method}\", url, nil)`,\n indent,\n )\n }\n errorCheck()\n blank()\n // Add headers\n if (postData !== null && postData !== void 0 && postData.mimeType === 'multipart/form-data' && postData.params) {\n push(`req.Header.Set(\"Content-Type\", writer.FormDataContentType())`, indent)\n }\n if (Object.keys(allHeaders).length) {\n Object.keys(allHeaders).forEach((key) => {\n push(\n `req.Header.Add(\"${key}\", \"${escapeForDoubleQuotes(allHeaders[key])}\")`,\n indent,\n )\n })\n blank()\n }\n // Make request\n push(`res, ${errorPlaceholder} := ${client}.Do(req)`, indent)\n errorCheck()\n // Get Body\n if (printBody) {\n imports.add('io')\n blank()\n push('defer res.Body.Close()', indent)\n push(`body, ${errorPlaceholder} := io.ReadAll(res.Body)`, indent)\n errorCheck()\n }\n // Print it\n blank()\n push('fmt.Println(res)', indent)\n if (printBody) {\n push('fmt.Println(string(body))', indent)\n }\n // End main block\n if (showBoilerplate) {\n blank()\n push('}')\n }\n return join()\n },\n}\n"],
5
+ "mappings": "AAUA,SAAS,mBAAmB;AAC5B,SAAS,6BAA6B;AAE/B,MAAM,SAAS;AAAA,EACpB,MAAM;AAAA,IACJ,KAAK;AAAA,IACL,OAAO;AAAA,IACP,MAAM;AAAA,IACN,aAAa;AAAA,EACf;AAAA,EACA,SAAS,CAAC,EAAE,UAAU,QAAQ,YAAY,QAAQ,GAAG,UAAU,CAAC,MAAM;AACpE,UAAM,EAAE,OAAO,MAAM,MAAM,iBAAiB,IAAI,IAAI,YAAY,EAAE,QAAQ,IAAK,CAAC;AAChF,UAAM;AAAA,MACJ,kBAAkB;AAAA,MAClB,cAAc;AAAA,MACd,YAAY;AAAA,MACZ,UAAU;AAAA,MACV,qBAAqB;AAAA,IACvB,IAAI;AACJ,UAAM,mBAAmB,cAAc,QAAQ;AAC/C,UAAM,SAAS,kBAAkB,IAAI;AACrC,UAAM,aAAa,MAAM;AACvB,UAAI,aAAa;AACf,aAAK,mBAAmB,MAAM;AAC9B,aAAK,cAAc,SAAS,CAAC;AAC7B,aAAK,KAAK,MAAM;AAAA,MAClB;AAAA,IACF;AAEA,UAAM,UAAU,oBAAI,IAAI;AACxB,QAAI,iBAAiB;AACnB,WAAK,cAAc;AACnB,YAAM;AAEN,WAAK,WAAW;AAChB,uBAAiB,CAAC,SAAS;AACzB,cAAM,cAAc,CAAC,GAAG,OAAO;AAC/B,oBAAY,KAAK;AACjB,cAAM,cAAc,YAAY,IAAI,CAAC,SAAS,KAAM,IAAI,GAAG,EAAE,KAAK,IAAI;AACtE,eAAO,KAAK,QAAQ,eAAe;AAAA,EAAa,WAAW;AAAA,EAAK;AAAA,MAClE,CAAC;AAED,cAAQ,IAAI,KAAK;AACjB,cAAQ,IAAI,UAAU;AAEtB,YAAM;AACN,WAAK,eAAe;AAAA,IACtB;AAEA,QAAI,oBAAoB;AACtB,cAAQ,IAAI,YAAY;AACxB;AAAA,QACE;AAAA,QACA;AAAA,MACF;AACA;AAAA,QACE;AAAA,QACA;AAAA,MACF;AAAA,IACF;AAEA,UAAM,aAAa,UAAU;AAC7B,UAAM,YAAY,cAAc;AAChC,UAAM,SAAS,YAAY,WAAW;AACtC,QAAI,WAAW;AACb,WAAK,0BAA0B,MAAM;AACrC,UAAI,YAAY;AACd,gBAAQ,IAAI,MAAM;AAClB,aAAK,0BAA0B,OAAO,oBAAoB,SAAS,CAAC;AAAA,MACtE;AACA,UAAI,oBAAoB;AACtB,aAAK,iCAAiC,SAAS,CAAC;AAAA,MAClD;AACA,WAAK,KAAK,MAAM;AAChB,YAAM;AAAA,IACR;AACA,SAAK,WAAW,OAAO,KAAK,MAAM;AAClC,UAAM;AAEN,QAAI,aAAa,QAAQ,aAAa,WAAW,SAAS,UAAU,SAAS,OAAO;AAClF,UAAI,SAAS,aAAa,uCAAuC,SAAS,QAAQ;AAChF,gBAAQ,IAAI,SAAS;AACrB,gBAAQ,IAAI,SAAS;AAErB,aAAK,4BAA4B,MAAM;AACvC,iBAAS,OAAO,QAAQ,CAAC,UAAU;AACjC;AAAA,YACE,iBAAiB,MAAM,IAAI,OAAO,sBAAsB,MAAM,KAAK,CAAC;AAAA,YACpE;AAAA,UACF;AAAA,QACF,CAAC;AACD,cAAM;AACN;AAAA,UACE,QAAQ,gBAAgB,wBAAwB,MAAM;AAAA,UACtD;AAAA,QACF;AAAA,MACF,WAAW,SAAS,aAAa,yBAAyB,SAAS,QAAQ;AACzE,gBAAQ,IAAI,OAAO;AACnB,gBAAQ,IAAI,gBAAgB;AAE5B,aAAK,8BAA8B,MAAM;AACzC,aAAK,0CAA0C,MAAM;AACrD,iBAAS,OAAO,QAAQ,CAAC,UAAU;AACjC,gBAAM;AACN,cAAI,MAAM,UAAU;AAClB,iBAAK,SAAS,gBAAgB,8BAA8B,MAAM,IAAI,OAAO,MAAM,QAAQ,MAAM,MAAM;AACvG,uBAAW;AACX,kBAAM;AACN,iBAAK,MAAM,gBAAgB,gBAAgB,MAAM,QAAQ,MAAM,MAAM;AACrE,uBAAW;AACX,iBAAK,mBAAmB,MAAM;AAC9B,kBAAM;AACN,iBAAK,MAAM,gBAAgB,uBAAuB,MAAM;AACxD,uBAAW;AAAA,UACb,OAAO;AACL,iBAAK,GAAG,gBAAgB,yBAAyB,MAAM,IAAI,OAAO,sBAAsB,MAAM,KAAK,CAAC,MAAM,MAAM;AAChH,uBAAW;AAAA,UACb;AAAA,QACF,CAAC;AACD,aAAK,kBAAkB,MAAM;AAC7B,cAAM;AACN;AAAA,UACE,QAAQ,gBAAgB,wBAAwB,MAAM;AAAA,UACtD;AAAA,QACF;AAAA,MACF,OAAO;AACL,gBAAQ,IAAI,SAAS;AAErB;AAAA,UACE,gCAAgC,KAAK,UAAU,SAAS,IAAI,CAAC;AAAA,UAC7D;AAAA,QACF;AACA,cAAM;AACN;AAAA,UACE,QAAQ,gBAAgB,wBAAwB,MAAM;AAAA,UACtD;AAAA,QACF;AAAA,MACF;AAAA,IACF,OAAO;AACL;AAAA,QACE,QAAQ,gBAAgB,wBAAwB,MAAM;AAAA,QACtD;AAAA,MACF;AAAA,IACF;AACA,eAAW;AACX,UAAM;AAEN,QAAI,aAAa,QAAQ,aAAa,UAAU,SAAS,aAAa,yBAAyB,SAAS,QAAQ;AAC9G,WAAK,gEAAgE,MAAM;AAAA,IAC7E;AACA,QAAI,OAAO,KAAK,UAAU,EAAE,QAAQ;AAClC,aAAO,KAAK,UAAU,EAAE,QAAQ,CAAC,QAAQ;AACvC;AAAA,UACE,mBAAmB,GAAG,OAAO,sBAAsB,WAAW,GAAG,CAAC,CAAC;AAAA,UACnE;AAAA,QACF;AAAA,MACF,CAAC;AACD,YAAM;AAAA,IACR;AAEA,SAAK,QAAQ,gBAAgB,OAAO,MAAM,YAAY,MAAM;AAC5D,eAAW;AAEX,QAAI,WAAW;AACb,cAAQ,IAAI,IAAI;AAChB,YAAM;AACN,WAAK,0BAA0B,MAAM;AACrC,WAAK,SAAS,gBAAgB,4BAA4B,MAAM;AAChE,iBAAW;AAAA,IACb;AAEA,UAAM;AACN,SAAK,oBAAoB,MAAM;AAC/B,QAAI,WAAW;AACb,WAAK,6BAA6B,MAAM;AAAA,IAC1C;AAEA,QAAI,iBAAiB;AACnB,YAAM;AACN,WAAK,GAAG;AAAA,IACV;AACA,WAAO,KAAK;AAAA,EACd;AACF;",
6
+ "names": []
7
+ }
@@ -0,0 +1,16 @@
1
+ import { native } from "./native/client.js";
2
+ const go = {
3
+ info: {
4
+ key: "go",
5
+ title: "Go",
6
+ extname: ".go",
7
+ default: "native"
8
+ },
9
+ clientsById: {
10
+ native
11
+ }
12
+ };
13
+ export {
14
+ go
15
+ };
16
+ //# sourceMappingURL=target.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../src/httpsnippet-lite/esm/targets/go/target.ts"],
4
+ "sourcesContent": ["// @ts-nocheck\nimport { native } from './native/client.js'\n\nexport const go = {\n info: {\n key: 'go',\n title: 'Go',\n extname: '.go',\n default: 'native',\n },\n clientsById: {\n native,\n },\n}\n"],
5
+ "mappings": "AACA,SAAS,cAAc;AAEhB,MAAM,KAAK;AAAA,EAChB,MAAM;AAAA,IACJ,KAAK;AAAA,IACL,OAAO;AAAA,IACP,SAAS;AAAA,IACT,SAAS;AAAA,EACX;AAAA,EACA,aAAa;AAAA,IACX;AAAA,EACF;AACF;",
6
+ "names": []
7
+ }
@@ -1,46 +1,39 @@
1
- import { CodeBuilder } from '../../../helpers/code-builder.js';
2
- import { escapeForDoubleQuotes } from '../../../helpers/escape.js';
3
-
4
- // @ts-nocheck
5
- /**
6
- * @description
7
- * Asynchronous Http and WebSocket Client library for Java
8
- *
9
- * @author
10
- * @windard
11
- *
12
- * for any questions or issues regarding the generated code snippet, please open an issue mentioning the author.
13
- */
1
+ import { CodeBuilder } from "../../../helpers/code-builder.js";
2
+ import { escapeForDoubleQuotes } from "../../../helpers/escape.js";
14
3
  const asynchttp = {
15
- info: {
16
- key: 'asynchttp',
17
- title: 'AsyncHttp',
18
- link: 'https://github.com/AsyncHttpClient/async-http-client',
19
- description: 'Asynchronous Http and WebSocket Client library for Java',
20
- },
21
- convert: ({ method, allHeaders, postData, fullUrl }, options) => {
22
- const opts = {
23
- indent: ' ',
24
- ...options,
25
- };
26
- const { blank, push, join } = new CodeBuilder({ indent: opts.indent });
27
- push('AsyncHttpClient client = new DefaultAsyncHttpClient();');
28
- push(`client.prepare("${method.toUpperCase()}", "${fullUrl}")`);
29
- // Add headers, including the cookies
30
- Object.keys(allHeaders).forEach((key) => {
31
- push(`.setHeader("${key}", "${escapeForDoubleQuotes(allHeaders[key])}")`, 1);
32
- });
33
- if (postData === null || postData === void 0 ? void 0 : postData.text) {
34
- push(`.setBody(${JSON.stringify(postData.text)})`, 1);
35
- }
36
- push('.execute()', 1);
37
- push('.toCompletableFuture()', 1);
38
- push('.thenAccept(System.out::println)', 1);
39
- push('.join();', 1);
40
- blank();
41
- push('client.close();');
42
- return join();
43
- },
4
+ info: {
5
+ key: "asynchttp",
6
+ title: "AsyncHttp",
7
+ link: "https://github.com/AsyncHttpClient/async-http-client",
8
+ description: "Asynchronous Http and WebSocket Client library for Java"
9
+ },
10
+ convert: ({ method, allHeaders, postData, fullUrl }, options) => {
11
+ const opts = {
12
+ indent: " ",
13
+ ...options
14
+ };
15
+ const { blank, push, join } = new CodeBuilder({ indent: opts.indent });
16
+ push("AsyncHttpClient client = new DefaultAsyncHttpClient();");
17
+ push(`client.prepare("${method.toUpperCase()}", "${fullUrl}")`);
18
+ Object.keys(allHeaders).forEach((key) => {
19
+ push(
20
+ `.setHeader("${key}", "${escapeForDoubleQuotes(allHeaders[key])}")`,
21
+ 1
22
+ );
23
+ });
24
+ if (postData === null || postData === void 0 ? void 0 : postData.text) {
25
+ push(`.setBody(${JSON.stringify(postData.text)})`, 1);
26
+ }
27
+ push(".execute()", 1);
28
+ push(".toCompletableFuture()", 1);
29
+ push(".thenAccept(System.out::println)", 1);
30
+ push(".join();", 1);
31
+ blank();
32
+ push("client.close();");
33
+ return join();
34
+ }
44
35
  };
45
-
46
- export { asynchttp };
36
+ export {
37
+ asynchttp
38
+ };
39
+ //# sourceMappingURL=client.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../../src/httpsnippet-lite/esm/targets/java/asynchttp/client.ts"],
4
+ "sourcesContent": ["// @ts-nocheck\n/**\n * @description\n * Asynchronous Http and WebSocket Client library for Java\n *\n * @author\n * @windard\n *\n * for any questions or issues regarding the generated code snippet, please open an issue mentioning the author.\n */\nimport { CodeBuilder } from '../../../helpers/code-builder.js'\nimport { escapeForDoubleQuotes } from '../../../helpers/escape.js'\n\nexport const asynchttp = {\n info: {\n key: 'asynchttp',\n title: 'AsyncHttp',\n link: 'https://github.com/AsyncHttpClient/async-http-client',\n description: 'Asynchronous Http and WebSocket Client library for Java',\n },\n convert: ({ method, allHeaders, postData, fullUrl }, options) => {\n const opts = {\n indent: ' ',\n ...options,\n }\n const { blank, push, join } = new CodeBuilder({ indent: opts.indent })\n push('AsyncHttpClient client = new DefaultAsyncHttpClient();')\n push(`client.prepare(\"${method.toUpperCase()}\", \"${fullUrl}\")`)\n // Add headers, including the cookies\n Object.keys(allHeaders).forEach((key) => {\n push(\n `.setHeader(\"${key}\", \"${escapeForDoubleQuotes(allHeaders[key])}\")`,\n 1,\n )\n })\n if (postData === null || postData === void 0 ? void 0 : postData.text) {\n push(`.setBody(${JSON.stringify(postData.text)})`, 1)\n }\n push('.execute()', 1)\n push('.toCompletableFuture()', 1)\n push('.thenAccept(System.out::println)', 1)\n push('.join();', 1)\n blank()\n push('client.close();')\n return join()\n },\n}\n"],
5
+ "mappings": "AAUA,SAAS,mBAAmB;AAC5B,SAAS,6BAA6B;AAE/B,MAAM,YAAY;AAAA,EACvB,MAAM;AAAA,IACJ,KAAK;AAAA,IACL,OAAO;AAAA,IACP,MAAM;AAAA,IACN,aAAa;AAAA,EACf;AAAA,EACA,SAAS,CAAC,EAAE,QAAQ,YAAY,UAAU,QAAQ,GAAG,YAAY;AAC/D,UAAM,OAAO;AAAA,MACX,QAAQ;AAAA,MACR,GAAG;AAAA,IACL;AACA,UAAM,EAAE,OAAO,MAAM,KAAK,IAAI,IAAI,YAAY,EAAE,QAAQ,KAAK,OAAO,CAAC;AACrE,SAAK,wDAAwD;AAC7D,SAAK,mBAAmB,OAAO,YAAY,CAAC,OAAO,OAAO,IAAI;AAE9D,WAAO,KAAK,UAAU,EAAE,QAAQ,CAAC,QAAQ;AACvC;AAAA,QACE,eAAe,GAAG,OAAO,sBAAsB,WAAW,GAAG,CAAC,CAAC;AAAA,QAC/D;AAAA,MACF;AAAA,IACF,CAAC;AACD,QAAI,aAAa,QAAQ,aAAa,SAAS,SAAS,SAAS,MAAM;AACrE,WAAK,YAAY,KAAK,UAAU,SAAS,IAAI,CAAC,KAAK,CAAC;AAAA,IACtD;AACA,SAAK,cAAc,CAAC;AACpB,SAAK,0BAA0B,CAAC;AAChC,SAAK,oCAAoC,CAAC;AAC1C,SAAK,YAAY,CAAC;AAClB,UAAM;AACN,SAAK,iBAAiB;AACtB,WAAO,KAAK;AAAA,EACd;AACF;",
6
+ "names": []
7
+ }
@@ -1,45 +1,43 @@
1
- import { CodeBuilder } from '../../../helpers/code-builder.js';
2
- import { escapeForDoubleQuotes } from '../../../helpers/escape.js';
3
-
4
- // @ts-nocheck
5
- /**
6
- * @description
7
- * HTTP code snippet generator for Java using java.net.http.
8
- *
9
- * @author
10
- * @wtetsu
11
- *
12
- * for any questions or issues regarding the generated code snippet, please open an issue mentioning the author.
13
- */
1
+ import { CodeBuilder } from "../../../helpers/code-builder.js";
2
+ import { escapeForDoubleQuotes } from "../../../helpers/escape.js";
14
3
  const nethttp = {
15
- info: {
16
- key: 'nethttp',
17
- title: 'java.net.http',
18
- link: 'https://openjdk.java.net/groups/net/httpclient/intro.html',
19
- description: 'Java Standardized HTTP Client API',
20
- },
21
- convert: ({ allHeaders, fullUrl, method, postData }, options) => {
22
- const opts = {
23
- indent: ' ',
24
- ...options,
25
- };
26
- const { push, join } = new CodeBuilder({ indent: opts.indent });
27
- push('HttpRequest request = HttpRequest.newBuilder()');
28
- push(`.uri(URI.create("${fullUrl}"))`, 2);
29
- Object.keys(allHeaders).forEach((key) => {
30
- push(`.header("${key}", "${escapeForDoubleQuotes(allHeaders[key])}")`, 2);
31
- });
32
- if (postData === null || postData === void 0 ? void 0 : postData.text) {
33
- push(`.method("${method.toUpperCase()}", HttpRequest.BodyPublishers.ofString(${JSON.stringify(postData.text)}))`, 2);
34
- }
35
- else {
36
- push(`.method("${method.toUpperCase()}", HttpRequest.BodyPublishers.noBody())`, 2);
37
- }
38
- push('.build();', 2);
39
- push('HttpResponse<String> response = HttpClient.newHttpClient().send(request, HttpResponse.BodyHandlers.ofString());');
40
- push('System.out.println(response.body());');
41
- return join();
42
- },
4
+ info: {
5
+ key: "nethttp",
6
+ title: "java.net.http",
7
+ link: "https://openjdk.java.net/groups/net/httpclient/intro.html",
8
+ description: "Java Standardized HTTP Client API"
9
+ },
10
+ convert: ({ allHeaders, fullUrl, method, postData }, options) => {
11
+ const opts = {
12
+ indent: " ",
13
+ ...options
14
+ };
15
+ const { push, join } = new CodeBuilder({ indent: opts.indent });
16
+ push("HttpRequest request = HttpRequest.newBuilder()");
17
+ push(`.uri(URI.create("${fullUrl}"))`, 2);
18
+ Object.keys(allHeaders).forEach((key) => {
19
+ push(`.header("${key}", "${escapeForDoubleQuotes(allHeaders[key])}")`, 2);
20
+ });
21
+ if (postData === null || postData === void 0 ? void 0 : postData.text) {
22
+ push(
23
+ `.method("${method.toUpperCase()}", HttpRequest.BodyPublishers.ofString(${JSON.stringify(postData.text)}))`,
24
+ 2
25
+ );
26
+ } else {
27
+ push(
28
+ `.method("${method.toUpperCase()}", HttpRequest.BodyPublishers.noBody())`,
29
+ 2
30
+ );
31
+ }
32
+ push(".build();", 2);
33
+ push(
34
+ "HttpResponse<String> response = HttpClient.newHttpClient().send(request, HttpResponse.BodyHandlers.ofString());"
35
+ );
36
+ push("System.out.println(response.body());");
37
+ return join();
38
+ }
43
39
  };
44
-
45
- export { nethttp };
40
+ export {
41
+ nethttp
42
+ };
43
+ //# sourceMappingURL=client.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../../src/httpsnippet-lite/esm/targets/java/nethttp/client.ts"],
4
+ "sourcesContent": ["// @ts-nocheck\n/**\n * @description\n * HTTP code snippet generator for Java using java.net.http.\n *\n * @author\n * @wtetsu\n *\n * for any questions or issues regarding the generated code snippet, please open an issue mentioning the author.\n */\nimport { CodeBuilder } from '../../../helpers/code-builder.js'\nimport { escapeForDoubleQuotes } from '../../../helpers/escape.js'\n\nexport const nethttp = {\n info: {\n key: 'nethttp',\n title: 'java.net.http',\n link: 'https://openjdk.java.net/groups/net/httpclient/intro.html',\n description: 'Java Standardized HTTP Client API',\n },\n convert: ({ allHeaders, fullUrl, method, postData }, options) => {\n const opts = {\n indent: ' ',\n ...options,\n }\n const { push, join } = new CodeBuilder({ indent: opts.indent })\n push('HttpRequest request = HttpRequest.newBuilder()')\n push(`.uri(URI.create(\"${fullUrl}\"))`, 2)\n Object.keys(allHeaders).forEach((key) => {\n push(`.header(\"${key}\", \"${escapeForDoubleQuotes(allHeaders[key])}\")`, 2)\n })\n if (postData === null || postData === void 0 ? void 0 : postData.text) {\n push(\n `.method(\"${method.toUpperCase()}\", HttpRequest.BodyPublishers.ofString(${JSON.stringify(postData.text)}))`,\n 2,\n )\n } else {\n push(\n `.method(\"${method.toUpperCase()}\", HttpRequest.BodyPublishers.noBody())`,\n 2,\n )\n }\n push('.build();', 2)\n push(\n 'HttpResponse<String> response = HttpClient.newHttpClient().send(request, HttpResponse.BodyHandlers.ofString());',\n )\n push('System.out.println(response.body());')\n return join()\n },\n}\n"],
5
+ "mappings": "AAUA,SAAS,mBAAmB;AAC5B,SAAS,6BAA6B;AAE/B,MAAM,UAAU;AAAA,EACrB,MAAM;AAAA,IACJ,KAAK;AAAA,IACL,OAAO;AAAA,IACP,MAAM;AAAA,IACN,aAAa;AAAA,EACf;AAAA,EACA,SAAS,CAAC,EAAE,YAAY,SAAS,QAAQ,SAAS,GAAG,YAAY;AAC/D,UAAM,OAAO;AAAA,MACX,QAAQ;AAAA,MACR,GAAG;AAAA,IACL;AACA,UAAM,EAAE,MAAM,KAAK,IAAI,IAAI,YAAY,EAAE,QAAQ,KAAK,OAAO,CAAC;AAC9D,SAAK,gDAAgD;AACrD,SAAK,oBAAoB,OAAO,OAAO,CAAC;AACxC,WAAO,KAAK,UAAU,EAAE,QAAQ,CAAC,QAAQ;AACvC,WAAK,YAAY,GAAG,OAAO,sBAAsB,WAAW,GAAG,CAAC,CAAC,MAAM,CAAC;AAAA,IAC1E,CAAC;AACD,QAAI,aAAa,QAAQ,aAAa,SAAS,SAAS,SAAS,MAAM;AACrE;AAAA,QACE,YAAY,OAAO,YAAY,CAAC,0CAA0C,KAAK,UAAU,SAAS,IAAI,CAAC;AAAA,QACvG;AAAA,MACF;AAAA,IACF,OAAO;AACL;AAAA,QACE,YAAY,OAAO,YAAY,CAAC;AAAA,QAChC;AAAA,MACF;AAAA,IACF;AACA,SAAK,aAAa,CAAC;AACnB;AAAA,MACE;AAAA,IACF;AACA,SAAK,sCAAsC;AAC3C,WAAO,KAAK;AAAA,EACd;AACF;",
6
+ "names": []
7
+ }
@@ -1 +1 @@
1
- {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../../../../../src/httpsnippet-lite/esm/targets/java/okhttp/client.ts"],"names":[],"mappings":"AAaA,eAAO,MAAM,MAAM;;;;;;;;;;;;;CA0DlB,CAAA"}
1
+ {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../../../../../src/httpsnippet-lite/esm/targets/java/okhttp/client.ts"],"names":[],"mappings":"AAaA,eAAO,MAAM,MAAM;;;;;;;;;;;;;CA0ElB,CAAA"}