@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
@@ -0,0 +1,85 @@
1
+ import { CodeBuilder } from "../../../helpers/code-builder.js";
2
+ import { convertType, supportedMethods } from "../helpers.js";
3
+ const http1 = {
4
+ info: {
5
+ key: "http1",
6
+ title: "HTTP v1",
7
+ link: "http://php.net/manual/en/book.http.php",
8
+ description: "PHP with pecl/http v1"
9
+ },
10
+ convert: ({ method, url, postData, queryObj, headersObj, cookiesObj }, options = {}) => {
11
+ const {
12
+ closingTag = false,
13
+ indent = " ",
14
+ noTags = false,
15
+ shortTags = false
16
+ } = options;
17
+ const { push, blank, join } = new CodeBuilder({ indent });
18
+ if (!noTags) {
19
+ push(shortTags ? "<?" : "<?php");
20
+ blank();
21
+ }
22
+ if (!supportedMethods.includes(method.toUpperCase())) {
23
+ push(`HttpRequest::methodRegister('${method}');`);
24
+ }
25
+ push("$request = new HttpRequest();");
26
+ push(`$request->setUrl(${convertType(url)});`);
27
+ if (supportedMethods.includes(method.toUpperCase())) {
28
+ push(`$request->setMethod(HTTP_METH_${method.toUpperCase()});`);
29
+ } else {
30
+ push(
31
+ `$request->setMethod(HttpRequest::HTTP_METH_${method.toUpperCase()});`
32
+ );
33
+ }
34
+ blank();
35
+ if (Object.keys(queryObj).length) {
36
+ push(`$request->setQueryData(${convertType(queryObj, indent)});`);
37
+ blank();
38
+ }
39
+ if (Object.keys(headersObj).length) {
40
+ push(`$request->setHeaders(${convertType(headersObj, indent)});`);
41
+ blank();
42
+ }
43
+ if (Object.keys(cookiesObj).length) {
44
+ push(`$request->setCookies(${convertType(cookiesObj, indent)});`);
45
+ blank();
46
+ }
47
+ switch (postData === null || postData === void 0 ? void 0 : postData.mimeType) {
48
+ case "application/x-www-form-urlencoded":
49
+ push(`$request->setContentType(${convertType(postData.mimeType)});`);
50
+ push(
51
+ `$request->setPostFields(${convertType(postData.paramsObj, indent)});`
52
+ );
53
+ blank();
54
+ break;
55
+ case "application/json":
56
+ push(`$request->setContentType(${convertType(postData.mimeType)});`);
57
+ push(
58
+ `$request->setBody(json_encode(${convertType(postData.jsonObj, indent)}));`
59
+ );
60
+ blank();
61
+ break;
62
+ default:
63
+ if (postData === null || postData === void 0 ? void 0 : postData.text) {
64
+ push(`$request->setBody(${convertType(postData.text)});`);
65
+ blank();
66
+ }
67
+ }
68
+ push("try {");
69
+ push("$response = $request->send();", 1);
70
+ blank();
71
+ push("echo $response->getBody();", 1);
72
+ push("} catch (HttpException $ex) {");
73
+ push("echo $ex;", 1);
74
+ push("}");
75
+ if (!noTags && closingTag) {
76
+ blank();
77
+ push("?>");
78
+ }
79
+ return join();
80
+ }
81
+ };
82
+ export {
83
+ http1
84
+ };
85
+ //# sourceMappingURL=client.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../../src/httpsnippet-lite/esm/targets/php/http1/client.ts"],
4
+ "sourcesContent": ["// @ts-nocheck\n/**\n * @description\n * HTTP code snippet generator for PHP using curl-ext.\n *\n * @author\n * @AhmadNassri\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 { convertType, supportedMethods } from '../helpers.js'\n\nexport const http1 = {\n info: {\n key: 'http1',\n title: 'HTTP v1',\n link: 'http://php.net/manual/en/book.http.php',\n description: 'PHP with pecl/http v1',\n },\n convert: (\n { method, url, postData, queryObj, headersObj, cookiesObj },\n options = {},\n ) => {\n const {\n closingTag = false,\n indent = ' ',\n noTags = false,\n shortTags = false,\n } = options\n const { push, blank, join } = new CodeBuilder({ indent })\n if (!noTags) {\n push(shortTags ? '<?' : '<?php')\n blank()\n }\n if (!supportedMethods.includes(method.toUpperCase())) {\n push(`HttpRequest::methodRegister('${method}');`)\n }\n push('$request = new HttpRequest();')\n push(`$request->setUrl(${convertType(url)});`)\n if (supportedMethods.includes(method.toUpperCase())) {\n push(`$request->setMethod(HTTP_METH_${method.toUpperCase()});`)\n } else {\n push(\n `$request->setMethod(HttpRequest::HTTP_METH_${method.toUpperCase()});`,\n )\n }\n blank()\n if (Object.keys(queryObj).length) {\n push(`$request->setQueryData(${convertType(queryObj, indent)});`)\n blank()\n }\n if (Object.keys(headersObj).length) {\n push(`$request->setHeaders(${convertType(headersObj, indent)});`)\n blank()\n }\n if (Object.keys(cookiesObj).length) {\n push(`$request->setCookies(${convertType(cookiesObj, indent)});`)\n blank()\n }\n switch (\n postData === null || postData === void 0 ? void 0 : postData.mimeType\n ) {\n case 'application/x-www-form-urlencoded':\n push(`$request->setContentType(${convertType(postData.mimeType)});`)\n push(\n `$request->setPostFields(${convertType(postData.paramsObj, indent)});`,\n )\n blank()\n break\n case 'application/json':\n push(`$request->setContentType(${convertType(postData.mimeType)});`)\n push(\n `$request->setBody(json_encode(${convertType(postData.jsonObj, indent)}));`,\n )\n blank()\n break\n default:\n if (postData === null || postData === void 0 ? void 0 : postData.text) {\n push(`$request->setBody(${convertType(postData.text)});`)\n blank()\n }\n }\n push('try {')\n push('$response = $request->send();', 1)\n blank()\n push('echo $response->getBody();', 1)\n push('} catch (HttpException $ex) {')\n push('echo $ex;', 1)\n push('}')\n if (!noTags && closingTag) {\n blank()\n push('?>')\n }\n return join()\n },\n}\n"],
5
+ "mappings": "AAUA,SAAS,mBAAmB;AAC5B,SAAS,aAAa,wBAAwB;AAEvC,MAAM,QAAQ;AAAA,EACnB,MAAM;AAAA,IACJ,KAAK;AAAA,IACL,OAAO;AAAA,IACP,MAAM;AAAA,IACN,aAAa;AAAA,EACf;AAAA,EACA,SAAS,CACP,EAAE,QAAQ,KAAK,UAAU,UAAU,YAAY,WAAW,GAC1D,UAAU,CAAC,MACR;AACH,UAAM;AAAA,MACJ,aAAa;AAAA,MACb,SAAS;AAAA,MACT,SAAS;AAAA,MACT,YAAY;AAAA,IACd,IAAI;AACJ,UAAM,EAAE,MAAM,OAAO,KAAK,IAAI,IAAI,YAAY,EAAE,OAAO,CAAC;AACxD,QAAI,CAAC,QAAQ;AACX,WAAK,YAAY,OAAO,OAAO;AAC/B,YAAM;AAAA,IACR;AACA,QAAI,CAAC,iBAAiB,SAAS,OAAO,YAAY,CAAC,GAAG;AACpD,WAAK,gCAAgC,MAAM,KAAK;AAAA,IAClD;AACA,SAAK,+BAA+B;AACpC,SAAK,oBAAoB,YAAY,GAAG,CAAC,IAAI;AAC7C,QAAI,iBAAiB,SAAS,OAAO,YAAY,CAAC,GAAG;AACnD,WAAK,iCAAiC,OAAO,YAAY,CAAC,IAAI;AAAA,IAChE,OAAO;AACL;AAAA,QACE,8CAA8C,OAAO,YAAY,CAAC;AAAA,MACpE;AAAA,IACF;AACA,UAAM;AACN,QAAI,OAAO,KAAK,QAAQ,EAAE,QAAQ;AAChC,WAAK,0BAA0B,YAAY,UAAU,MAAM,CAAC,IAAI;AAChE,YAAM;AAAA,IACR;AACA,QAAI,OAAO,KAAK,UAAU,EAAE,QAAQ;AAClC,WAAK,wBAAwB,YAAY,YAAY,MAAM,CAAC,IAAI;AAChE,YAAM;AAAA,IACR;AACA,QAAI,OAAO,KAAK,UAAU,EAAE,QAAQ;AAClC,WAAK,wBAAwB,YAAY,YAAY,MAAM,CAAC,IAAI;AAChE,YAAM;AAAA,IACR;AACA,YACE,aAAa,QAAQ,aAAa,SAAS,SAAS,SAAS,UAC7D;AAAA,MACA,KAAK;AACH,aAAK,4BAA4B,YAAY,SAAS,QAAQ,CAAC,IAAI;AACnE;AAAA,UACE,2BAA2B,YAAY,SAAS,WAAW,MAAM,CAAC;AAAA,QACpE;AACA,cAAM;AACN;AAAA,MACF,KAAK;AACH,aAAK,4BAA4B,YAAY,SAAS,QAAQ,CAAC,IAAI;AACnE;AAAA,UACE,iCAAiC,YAAY,SAAS,SAAS,MAAM,CAAC;AAAA,QACxE;AACA,cAAM;AACN;AAAA,MACF;AACE,YAAI,aAAa,QAAQ,aAAa,SAAS,SAAS,SAAS,MAAM;AACrE,eAAK,qBAAqB,YAAY,SAAS,IAAI,CAAC,IAAI;AACxD,gBAAM;AAAA,QACR;AAAA,IACJ;AACA,SAAK,OAAO;AACZ,SAAK,iCAAiC,CAAC;AACvC,UAAM;AACN,SAAK,8BAA8B,CAAC;AACpC,SAAK,+BAA+B;AACpC,SAAK,aAAa,CAAC;AACnB,SAAK,GAAG;AACR,QAAI,CAAC,UAAU,YAAY;AACzB,YAAM;AACN,WAAK,IAAI;AAAA,IACX;AACA,WAAO,KAAK;AAAA,EACd;AACF;",
6
+ "names": []
7
+ }
@@ -0,0 +1,127 @@
1
+ import { CodeBuilder } from "../../../helpers/code-builder.js";
2
+ import {
3
+ getHeader,
4
+ getHeaderName,
5
+ hasHeader
6
+ } from "../../../helpers/headers.js";
7
+ import { convertType } from "../helpers.js";
8
+ const http2 = {
9
+ info: {
10
+ key: "http2",
11
+ title: "HTTP v2",
12
+ link: "http://devel-m6w6.rhcloud.com/mdref/http",
13
+ description: "PHP with pecl/http v2"
14
+ },
15
+ convert: ({ postData, headersObj, method, queryObj, cookiesObj, url }, options = {}) => {
16
+ let _a;
17
+ const {
18
+ closingTag = false,
19
+ indent = " ",
20
+ noTags = false,
21
+ shortTags = false
22
+ } = options;
23
+ const { push, blank, join } = new CodeBuilder({ indent });
24
+ let hasBody = false;
25
+ if (!noTags) {
26
+ push(shortTags ? "<?" : "<?php");
27
+ blank();
28
+ }
29
+ push("$client = new http\\Client;");
30
+ push("$request = new http\\Client\\Request;");
31
+ blank();
32
+ switch (postData === null || postData === void 0 ? void 0 : postData.mimeType) {
33
+ case "application/x-www-form-urlencoded":
34
+ push("$body = new http\\Message\\Body;");
35
+ push(
36
+ `$body->append(new http\\QueryString(${convertType(postData.paramsObj, indent)}));`
37
+ );
38
+ blank();
39
+ hasBody = true;
40
+ break;
41
+ case "multipart/form-data": {
42
+ if (!postData.params) {
43
+ break;
44
+ }
45
+ const files = [];
46
+ const fields = {};
47
+ postData.params.forEach(({ name, fileName, value, contentType }) => {
48
+ if (fileName) {
49
+ files.push({
50
+ name,
51
+ type: contentType,
52
+ file: fileName,
53
+ data: value
54
+ });
55
+ return;
56
+ }
57
+ if (value) {
58
+ fields[name] = value;
59
+ }
60
+ });
61
+ const field = Object.keys(fields).length ? convertType(fields, indent) : "null";
62
+ const formValue = files.length ? convertType(files, indent) : "null";
63
+ push("$body = new http\\Message\\Body;");
64
+ push(`$body->addForm(${field}, ${formValue});`);
65
+ if (hasHeader(headersObj, "content-type")) {
66
+ if ((_a = getHeader(headersObj, "content-type")) === null || _a === void 0 ? void 0 : _a.indexOf("boundary")) {
67
+ const headerName = getHeaderName(headersObj, "content-type");
68
+ if (headerName) {
69
+ delete headersObj[headerName];
70
+ }
71
+ }
72
+ }
73
+ blank();
74
+ hasBody = true;
75
+ break;
76
+ }
77
+ case "application/json":
78
+ push("$body = new http\\Message\\Body;");
79
+ push(
80
+ `$body->append(json_encode(${convertType(postData.jsonObj, indent)}));`
81
+ );
82
+ hasBody = true;
83
+ break;
84
+ default:
85
+ if (postData === null || postData === void 0 ? void 0 : postData.text) {
86
+ push("$body = new http\\Message\\Body;");
87
+ push(`$body->append(${convertType(postData.text)});`);
88
+ blank();
89
+ hasBody = true;
90
+ }
91
+ }
92
+ push(`$request->setRequestUrl(${convertType(url)});`);
93
+ push(`$request->setRequestMethod(${convertType(method)});`);
94
+ if (hasBody) {
95
+ push("$request->setBody($body);");
96
+ blank();
97
+ }
98
+ if (Object.keys(queryObj).length) {
99
+ push(
100
+ `$request->setQuery(new http\\QueryString(${convertType(queryObj, indent)}));`
101
+ );
102
+ blank();
103
+ }
104
+ if (Object.keys(headersObj).length) {
105
+ push(`$request->setHeaders(${convertType(headersObj, indent)});`);
106
+ blank();
107
+ }
108
+ if (Object.keys(cookiesObj).length) {
109
+ blank();
110
+ push(`$client->setCookies(${convertType(cookiesObj, indent)});`);
111
+ blank();
112
+ }
113
+ push("$client->enqueue($request)->send();");
114
+ push("$response = $client->getResponse();");
115
+ blank();
116
+ push("echo $response->getBody();");
117
+ if (!noTags && closingTag) {
118
+ blank();
119
+ push("?>");
120
+ }
121
+ return join();
122
+ }
123
+ };
124
+ export {
125
+ http2
126
+ };
127
+ //# sourceMappingURL=client.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../../src/httpsnippet-lite/esm/targets/php/http2/client.ts"],
4
+ "sourcesContent": ["// @ts-nocheck\n/**\n * @description\n * HTTP code snippet generator for PHP using curl-ext.\n *\n * @author\n * @AhmadNassri\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 {\n getHeader,\n getHeaderName,\n hasHeader,\n} from '../../../helpers/headers.js'\nimport { convertType } from '../helpers.js'\n\nexport const http2 = {\n info: {\n key: 'http2',\n title: 'HTTP v2',\n link: 'http://devel-m6w6.rhcloud.com/mdref/http',\n description: 'PHP with pecl/http v2',\n },\n convert: (\n { postData, headersObj, method, queryObj, cookiesObj, url },\n options = {},\n ) => {\n let _a\n const {\n closingTag = false,\n indent = ' ',\n noTags = false,\n shortTags = false,\n } = options\n const { push, blank, join } = new CodeBuilder({ indent })\n let hasBody = false\n if (!noTags) {\n push(shortTags ? '<?' : '<?php')\n blank()\n }\n push('$client = new http\\\\Client;')\n push('$request = new http\\\\Client\\\\Request;')\n blank()\n switch (\n postData === null || postData === void 0 ? void 0 : postData.mimeType\n ) {\n case 'application/x-www-form-urlencoded':\n push('$body = new http\\\\Message\\\\Body;')\n push(\n `$body->append(new http\\\\QueryString(${convertType(postData.paramsObj, indent)}));`,\n )\n blank()\n hasBody = true\n break\n case 'multipart/form-data': {\n if (!postData.params) {\n break\n }\n const files = []\n const fields = {}\n postData.params.forEach(({ name, fileName, value, contentType }) => {\n if (fileName) {\n files.push({\n name,\n type: contentType,\n file: fileName,\n data: value,\n })\n return\n }\n if (value) {\n fields[name] = value\n }\n })\n const field = Object.keys(fields).length\n ? convertType(fields, indent)\n : 'null'\n const formValue = files.length ? convertType(files, indent) : 'null'\n push('$body = new http\\\\Message\\\\Body;')\n push(`$body->addForm(${field}, ${formValue});`)\n // remove the contentType header\n if (hasHeader(headersObj, 'content-type')) {\n if (\n (_a = getHeader(headersObj, 'content-type')) === null ||\n _a === void 0\n ? void 0\n : _a.indexOf('boundary')\n ) {\n const headerName = getHeaderName(headersObj, 'content-type')\n if (headerName) {\n delete headersObj[headerName]\n }\n }\n }\n blank()\n hasBody = true\n break\n }\n case 'application/json':\n push('$body = new http\\\\Message\\\\Body;')\n push(\n `$body->append(json_encode(${convertType(postData.jsonObj, indent)}));`,\n )\n hasBody = true\n break\n default:\n if (postData === null || postData === void 0 ? void 0 : postData.text) {\n push('$body = new http\\\\Message\\\\Body;')\n push(`$body->append(${convertType(postData.text)});`)\n blank()\n hasBody = true\n }\n }\n push(`$request->setRequestUrl(${convertType(url)});`)\n push(`$request->setRequestMethod(${convertType(method)});`)\n if (hasBody) {\n push('$request->setBody($body);')\n blank()\n }\n if (Object.keys(queryObj).length) {\n push(\n `$request->setQuery(new http\\\\QueryString(${convertType(queryObj, indent)}));`,\n )\n blank()\n }\n if (Object.keys(headersObj).length) {\n push(`$request->setHeaders(${convertType(headersObj, indent)});`)\n blank()\n }\n if (Object.keys(cookiesObj).length) {\n blank()\n push(`$client->setCookies(${convertType(cookiesObj, indent)});`)\n blank()\n }\n push('$client->enqueue($request)->send();')\n push('$response = $client->getResponse();')\n blank()\n push('echo $response->getBody();')\n if (!noTags && closingTag) {\n blank()\n push('?>')\n }\n return join()\n },\n}\n"],
5
+ "mappings": "AAUA,SAAS,mBAAmB;AAC5B;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,mBAAmB;AAErB,MAAM,QAAQ;AAAA,EACnB,MAAM;AAAA,IACJ,KAAK;AAAA,IACL,OAAO;AAAA,IACP,MAAM;AAAA,IACN,aAAa;AAAA,EACf;AAAA,EACA,SAAS,CACP,EAAE,UAAU,YAAY,QAAQ,UAAU,YAAY,IAAI,GAC1D,UAAU,CAAC,MACR;AACH,QAAI;AACJ,UAAM;AAAA,MACJ,aAAa;AAAA,MACb,SAAS;AAAA,MACT,SAAS;AAAA,MACT,YAAY;AAAA,IACd,IAAI;AACJ,UAAM,EAAE,MAAM,OAAO,KAAK,IAAI,IAAI,YAAY,EAAE,OAAO,CAAC;AACxD,QAAI,UAAU;AACd,QAAI,CAAC,QAAQ;AACX,WAAK,YAAY,OAAO,OAAO;AAC/B,YAAM;AAAA,IACR;AACA,SAAK,6BAA6B;AAClC,SAAK,uCAAuC;AAC5C,UAAM;AACN,YACE,aAAa,QAAQ,aAAa,SAAS,SAAS,SAAS,UAC7D;AAAA,MACA,KAAK;AACH,aAAK,kCAAkC;AACvC;AAAA,UACE,uCAAuC,YAAY,SAAS,WAAW,MAAM,CAAC;AAAA,QAChF;AACA,cAAM;AACN,kBAAU;AACV;AAAA,MACF,KAAK,uBAAuB;AAC1B,YAAI,CAAC,SAAS,QAAQ;AACpB;AAAA,QACF;AACA,cAAM,QAAQ,CAAC;AACf,cAAM,SAAS,CAAC;AAChB,iBAAS,OAAO,QAAQ,CAAC,EAAE,MAAM,UAAU,OAAO,YAAY,MAAM;AAClE,cAAI,UAAU;AACZ,kBAAM,KAAK;AAAA,cACT;AAAA,cACA,MAAM;AAAA,cACN,MAAM;AAAA,cACN,MAAM;AAAA,YACR,CAAC;AACD;AAAA,UACF;AACA,cAAI,OAAO;AACT,mBAAO,IAAI,IAAI;AAAA,UACjB;AAAA,QACF,CAAC;AACD,cAAM,QAAQ,OAAO,KAAK,MAAM,EAAE,SAC9B,YAAY,QAAQ,MAAM,IAC1B;AACJ,cAAM,YAAY,MAAM,SAAS,YAAY,OAAO,MAAM,IAAI;AAC9D,aAAK,kCAAkC;AACvC,aAAK,kBAAkB,KAAK,KAAK,SAAS,IAAI;AAE9C,YAAI,UAAU,YAAY,cAAc,GAAG;AACzC,eACG,KAAK,UAAU,YAAY,cAAc,OAAO,QACjD,OAAO,SACH,SACA,GAAG,QAAQ,UAAU,GACzB;AACA,kBAAM,aAAa,cAAc,YAAY,cAAc;AAC3D,gBAAI,YAAY;AACd,qBAAO,WAAW,UAAU;AAAA,YAC9B;AAAA,UACF;AAAA,QACF;AACA,cAAM;AACN,kBAAU;AACV;AAAA,MACF;AAAA,MACA,KAAK;AACH,aAAK,kCAAkC;AACvC;AAAA,UACE,6BAA6B,YAAY,SAAS,SAAS,MAAM,CAAC;AAAA,QACpE;AACA,kBAAU;AACV;AAAA,MACF;AACE,YAAI,aAAa,QAAQ,aAAa,SAAS,SAAS,SAAS,MAAM;AACrE,eAAK,kCAAkC;AACvC,eAAK,iBAAiB,YAAY,SAAS,IAAI,CAAC,IAAI;AACpD,gBAAM;AACN,oBAAU;AAAA,QACZ;AAAA,IACJ;AACA,SAAK,2BAA2B,YAAY,GAAG,CAAC,IAAI;AACpD,SAAK,8BAA8B,YAAY,MAAM,CAAC,IAAI;AAC1D,QAAI,SAAS;AACX,WAAK,2BAA2B;AAChC,YAAM;AAAA,IACR;AACA,QAAI,OAAO,KAAK,QAAQ,EAAE,QAAQ;AAChC;AAAA,QACE,4CAA4C,YAAY,UAAU,MAAM,CAAC;AAAA,MAC3E;AACA,YAAM;AAAA,IACR;AACA,QAAI,OAAO,KAAK,UAAU,EAAE,QAAQ;AAClC,WAAK,wBAAwB,YAAY,YAAY,MAAM,CAAC,IAAI;AAChE,YAAM;AAAA,IACR;AACA,QAAI,OAAO,KAAK,UAAU,EAAE,QAAQ;AAClC,YAAM;AACN,WAAK,uBAAuB,YAAY,YAAY,MAAM,CAAC,IAAI;AAC/D,YAAM;AAAA,IACR;AACA,SAAK,qCAAqC;AAC1C,SAAK,qCAAqC;AAC1C,UAAM;AACN,SAAK,4BAA4B;AACjC,QAAI,CAAC,UAAU,YAAY;AACzB,YAAM;AACN,WAAK,IAAI;AAAA,IACX;AACA,WAAO,KAAK;AAAA,EACd;AACF;",
6
+ "names": []
7
+ }
@@ -0,0 +1,22 @@
1
+ import { curl } from "./curl/client.js";
2
+ import { guzzle } from "./guzzle/client.js";
3
+ import { http1 } from "./http1/client.js";
4
+ import { http2 } from "./http2/client.js";
5
+ const php = {
6
+ info: {
7
+ key: "php",
8
+ title: "PHP",
9
+ extname: ".php",
10
+ default: "curl"
11
+ },
12
+ clientsById: {
13
+ curl,
14
+ guzzle,
15
+ http1,
16
+ http2
17
+ }
18
+ };
19
+ export {
20
+ php
21
+ };
22
+ //# sourceMappingURL=target.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../src/httpsnippet-lite/esm/targets/php/target.ts"],
4
+ "sourcesContent": ["// @ts-nocheck\nimport { curl } from './curl/client.js'\nimport { guzzle } from './guzzle/client.js'\nimport { http1 } from './http1/client.js'\nimport { http2 } from './http2/client.js'\n\nexport const php = {\n info: {\n key: 'php',\n title: 'PHP',\n extname: '.php',\n default: 'curl',\n },\n clientsById: {\n curl,\n guzzle,\n http1,\n http2,\n },\n}\n"],
5
+ "mappings": "AACA,SAAS,YAAY;AACrB,SAAS,cAAc;AACvB,SAAS,aAAa;AACtB,SAAS,aAAa;AAEf,MAAM,MAAM;AAAA,EACjB,MAAM;AAAA,IACJ,KAAK;AAAA,IACL,OAAO;AAAA,IACP,SAAS;AAAA,IACT,SAAS;AAAA,EACX;AAAA,EACA,aAAa;AAAA,IACX;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;",
6
+ "names": []
7
+ }
@@ -1,52 +1,64 @@
1
- import { CodeBuilder } from '../../helpers/code-builder.js';
2
- import { escapeString } from '../../helpers/escape.js';
3
- import { getHeader } from '../../helpers/headers.js';
4
-
5
- // @ts-nocheck
1
+ import { CodeBuilder } from "../../helpers/code-builder.js";
2
+ import { escapeString } from "../../helpers/escape.js";
3
+ import { getHeader } from "../../helpers/headers.js";
6
4
  const generatePowershellConvert = (command) => {
7
- const convert = ({ method, headersObj, cookies, uriObj, fullUrl, postData, allHeaders, }) => {
8
- const { push, join } = new CodeBuilder();
9
- const methods = ['GET', 'POST', 'PUT', 'DELETE', 'PATCH', 'HEAD', 'OPTIONS'];
10
- if (!methods.includes(method.toUpperCase())) {
11
- return 'Method not supported';
5
+ const convert = ({
6
+ method,
7
+ headersObj,
8
+ cookies,
9
+ uriObj,
10
+ fullUrl,
11
+ postData,
12
+ allHeaders
13
+ }) => {
14
+ const { push, join } = new CodeBuilder();
15
+ const methods = ["GET", "POST", "PUT", "DELETE", "PATCH", "HEAD", "OPTIONS"];
16
+ if (!methods.includes(method.toUpperCase())) {
17
+ return "Method not supported";
18
+ }
19
+ const commandOptions = [];
20
+ const headers = Object.keys(headersObj);
21
+ if (headers.length) {
22
+ push("$headers=@{}");
23
+ headers.forEach((key) => {
24
+ if (key !== "connection") {
25
+ push(
26
+ `$headers.Add("${key}", "${escapeString(headersObj[key], { escapeChar: "`" })}")`
27
+ );
12
28
  }
13
- const commandOptions = [];
14
- // Add headers, including the cookies
15
- const headers = Object.keys(headersObj);
16
- // construct headers
17
- if (headers.length) {
18
- push('$headers=@{}');
19
- headers.forEach((key) => {
20
- if (key !== 'connection') {
21
- // Not allowed
22
- push(`$headers.Add("${key}", "${escapeString(headersObj[key], { escapeChar: '`' })}")`);
23
- }
24
- });
25
- commandOptions.push('-Headers $headers');
26
- }
27
- // construct cookies
28
- if (cookies.length) {
29
- push('$session = New-Object Microsoft.PowerShell.Commands.WebRequestSession');
30
- cookies.forEach((cookie) => {
31
- push('$cookie = New-Object System.Net.Cookie');
32
- push(`$cookie.Name = '${cookie.name}'`);
33
- push(`$cookie.Value = '${cookie.value}'`);
34
- push(`$cookie.Domain = '${uriObj.host}'`);
35
- push('$session.Cookies.Add($cookie)');
36
- });
37
- commandOptions.push('-WebSession $session');
38
- }
39
- if (postData === null || postData === void 0 ? void 0 : postData.text) {
40
- commandOptions.push(`-ContentType '${escapeString(getHeader(allHeaders, 'content-type'), {
41
- delimiter: "'",
42
- escapeChar: '`',
43
- })}'`);
44
- commandOptions.push(`-Body '${postData.text}'`);
45
- }
46
- push(`$response = ${command} -Uri '${fullUrl}' -Method ${method} ${commandOptions.join(' ')}`);
47
- return join();
48
- };
49
- return convert;
29
+ });
30
+ commandOptions.push("-Headers $headers");
31
+ }
32
+ if (cookies.length) {
33
+ push(
34
+ "$session = New-Object Microsoft.PowerShell.Commands.WebRequestSession"
35
+ );
36
+ cookies.forEach((cookie) => {
37
+ push("$cookie = New-Object System.Net.Cookie");
38
+ push(`$cookie.Name = '${cookie.name}'`);
39
+ push(`$cookie.Value = '${cookie.value}'`);
40
+ push(`$cookie.Domain = '${uriObj.host}'`);
41
+ push("$session.Cookies.Add($cookie)");
42
+ });
43
+ commandOptions.push("-WebSession $session");
44
+ }
45
+ if (postData === null || postData === void 0 ? void 0 : postData.text) {
46
+ commandOptions.push(
47
+ `-ContentType '${escapeString(getHeader(allHeaders, "content-type"), {
48
+ delimiter: "'",
49
+ escapeChar: "`"
50
+ })}'`
51
+ );
52
+ commandOptions.push(`-Body '${postData.text}'`);
53
+ }
54
+ push(
55
+ `$response = ${command} -Uri '${fullUrl}' -Method ${method} ${commandOptions.join(" ")}`
56
+ );
57
+ return join();
58
+ };
59
+ return convert;
60
+ };
61
+ export {
62
+ generatePowershellConvert
50
63
  };
51
-
52
- export { generatePowershellConvert };
64
+ //# sourceMappingURL=common.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../src/httpsnippet-lite/esm/targets/powershell/common.ts"],
4
+ "sourcesContent": ["// @ts-nocheck\nimport { CodeBuilder } from '../../helpers/code-builder.js'\nimport { escapeString } from '../../helpers/escape.js'\nimport { getHeader } from '../../helpers/headers.js'\n\nexport const generatePowershellConvert = (command) => {\n const convert = ({\n method,\n headersObj,\n cookies,\n uriObj,\n fullUrl,\n postData,\n allHeaders,\n }) => {\n const { push, join } = new CodeBuilder()\n const methods = ['GET', 'POST', 'PUT', 'DELETE', 'PATCH', 'HEAD', 'OPTIONS']\n if (!methods.includes(method.toUpperCase())) {\n return 'Method not supported'\n }\n const commandOptions = []\n // Add headers, including the cookies\n const headers = Object.keys(headersObj)\n // construct headers\n if (headers.length) {\n push('$headers=@{}')\n headers.forEach((key) => {\n if (key !== 'connection') {\n // Not allowed\n push(\n `$headers.Add(\"${key}\", \"${escapeString(headersObj[key], { escapeChar: '`' })}\")`,\n )\n }\n })\n commandOptions.push('-Headers $headers')\n }\n // construct cookies\n if (cookies.length) {\n push(\n '$session = New-Object Microsoft.PowerShell.Commands.WebRequestSession',\n )\n cookies.forEach((cookie) => {\n push('$cookie = New-Object System.Net.Cookie')\n push(`$cookie.Name = '${cookie.name}'`)\n push(`$cookie.Value = '${cookie.value}'`)\n push(`$cookie.Domain = '${uriObj.host}'`)\n push('$session.Cookies.Add($cookie)')\n })\n commandOptions.push('-WebSession $session')\n }\n if (postData === null || postData === void 0 ? void 0 : postData.text) {\n commandOptions.push(\n `-ContentType '${escapeString(getHeader(allHeaders, 'content-type'), {\n delimiter: \"'\",\n escapeChar: '`',\n })}'`,\n )\n commandOptions.push(`-Body '${postData.text}'`)\n }\n push(\n `$response = ${command} -Uri '${fullUrl}' -Method ${method} ${commandOptions.join(' ')}`,\n )\n return join()\n }\n return convert\n}\n"],
5
+ "mappings": "AACA,SAAS,mBAAmB;AAC5B,SAAS,oBAAoB;AAC7B,SAAS,iBAAiB;AAEnB,MAAM,4BAA4B,CAAC,YAAY;AACpD,QAAM,UAAU,CAAC;AAAA,IACf;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,MAAM;AACJ,UAAM,EAAE,MAAM,KAAK,IAAI,IAAI,YAAY;AACvC,UAAM,UAAU,CAAC,OAAO,QAAQ,OAAO,UAAU,SAAS,QAAQ,SAAS;AAC3E,QAAI,CAAC,QAAQ,SAAS,OAAO,YAAY,CAAC,GAAG;AAC3C,aAAO;AAAA,IACT;AACA,UAAM,iBAAiB,CAAC;AAExB,UAAM,UAAU,OAAO,KAAK,UAAU;AAEtC,QAAI,QAAQ,QAAQ;AAClB,WAAK,cAAc;AACnB,cAAQ,QAAQ,CAAC,QAAQ;AACvB,YAAI,QAAQ,cAAc;AAExB;AAAA,YACE,iBAAiB,GAAG,OAAO,aAAa,WAAW,GAAG,GAAG,EAAE,YAAY,IAAI,CAAC,CAAC;AAAA,UAC/E;AAAA,QACF;AAAA,MACF,CAAC;AACD,qBAAe,KAAK,mBAAmB;AAAA,IACzC;AAEA,QAAI,QAAQ,QAAQ;AAClB;AAAA,QACE;AAAA,MACF;AACA,cAAQ,QAAQ,CAAC,WAAW;AAC1B,aAAK,wCAAwC;AAC7C,aAAK,mBAAmB,OAAO,IAAI,GAAG;AACtC,aAAK,oBAAoB,OAAO,KAAK,GAAG;AACxC,aAAK,qBAAqB,OAAO,IAAI,GAAG;AACxC,aAAK,+BAA+B;AAAA,MACtC,CAAC;AACD,qBAAe,KAAK,sBAAsB;AAAA,IAC5C;AACA,QAAI,aAAa,QAAQ,aAAa,SAAS,SAAS,SAAS,MAAM;AACrE,qBAAe;AAAA,QACb,iBAAiB,aAAa,UAAU,YAAY,cAAc,GAAG;AAAA,UACnE,WAAW;AAAA,UACX,YAAY;AAAA,QACd,CAAC,CAAC;AAAA,MACJ;AACA,qBAAe,KAAK,UAAU,SAAS,IAAI,GAAG;AAAA,IAChD;AACA;AAAA,MACE,eAAe,OAAO,UAAU,OAAO,aAAa,MAAM,IAAI,eAAe,KAAK,GAAG,CAAC;AAAA,IACxF;AACA,WAAO,KAAK;AAAA,EACd;AACA,SAAO;AACT;",
6
+ "names": []
7
+ }
@@ -1,14 +1,14 @@
1
- import { generatePowershellConvert } from '../common.js';
2
-
3
- // @ts-nocheck
1
+ import { generatePowershellConvert } from "../common.js";
4
2
  const restmethod = {
5
- info: {
6
- key: 'restmethod',
7
- title: 'Invoke-RestMethod',
8
- link: 'https://docs.microsoft.com/en-us/powershell/module/Microsoft.PowerShell.Utility/Invoke-RestMethod',
9
- description: 'Powershell Invoke-RestMethod client',
10
- },
11
- convert: generatePowershellConvert('Invoke-RestMethod'),
3
+ info: {
4
+ key: "restmethod",
5
+ title: "Invoke-RestMethod",
6
+ link: "https://docs.microsoft.com/en-us/powershell/module/Microsoft.PowerShell.Utility/Invoke-RestMethod",
7
+ description: "Powershell Invoke-RestMethod client"
8
+ },
9
+ convert: generatePowershellConvert("Invoke-RestMethod")
12
10
  };
13
-
14
- export { restmethod };
11
+ export {
12
+ restmethod
13
+ };
14
+ //# sourceMappingURL=client.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../../src/httpsnippet-lite/esm/targets/powershell/restmethod/client.ts"],
4
+ "sourcesContent": ["// @ts-nocheck\nimport { generatePowershellConvert } from '../common.js'\n\nexport const restmethod = {\n info: {\n key: 'restmethod',\n title: 'Invoke-RestMethod',\n link: 'https://docs.microsoft.com/en-us/powershell/module/Microsoft.PowerShell.Utility/Invoke-RestMethod',\n description: 'Powershell Invoke-RestMethod client',\n },\n convert: generatePowershellConvert('Invoke-RestMethod'),\n}\n"],
5
+ "mappings": "AACA,SAAS,iCAAiC;AAEnC,MAAM,aAAa;AAAA,EACxB,MAAM;AAAA,IACJ,KAAK;AAAA,IACL,OAAO;AAAA,IACP,MAAM;AAAA,IACN,aAAa;AAAA,EACf;AAAA,EACA,SAAS,0BAA0B,mBAAmB;AACxD;",
6
+ "names": []
7
+ }
@@ -0,0 +1,18 @@
1
+ import { restmethod } from "./restmethod/client.js";
2
+ import { webrequest } from "./webrequest/client.js";
3
+ const powershell = {
4
+ info: {
5
+ key: "powershell",
6
+ title: "Powershell",
7
+ extname: ".ps1",
8
+ default: "webrequest"
9
+ },
10
+ clientsById: {
11
+ webrequest,
12
+ restmethod
13
+ }
14
+ };
15
+ export {
16
+ powershell
17
+ };
18
+ //# sourceMappingURL=target.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../src/httpsnippet-lite/esm/targets/powershell/target.ts"],
4
+ "sourcesContent": ["// @ts-nocheck\nimport { restmethod } from './restmethod/client.js'\nimport { webrequest } from './webrequest/client.js'\n\nexport const powershell = {\n info: {\n key: 'powershell',\n title: 'Powershell',\n extname: '.ps1',\n default: 'webrequest',\n },\n clientsById: {\n webrequest,\n restmethod,\n },\n}\n"],
5
+ "mappings": "AACA,SAAS,kBAAkB;AAC3B,SAAS,kBAAkB;AAEpB,MAAM,aAAa;AAAA,EACxB,MAAM;AAAA,IACJ,KAAK;AAAA,IACL,OAAO;AAAA,IACP,SAAS;AAAA,IACT,SAAS;AAAA,EACX;AAAA,EACA,aAAa;AAAA,IACX;AAAA,IACA;AAAA,EACF;AACF;",
6
+ "names": []
7
+ }
@@ -1,14 +1,14 @@
1
- import { generatePowershellConvert } from '../common.js';
2
-
3
- // @ts-nocheck
1
+ import { generatePowershellConvert } from "../common.js";
4
2
  const webrequest = {
5
- info: {
6
- key: 'webrequest',
7
- title: 'Invoke-WebRequest',
8
- link: 'https://docs.microsoft.com/en-us/powershell/module/Microsoft.PowerShell.Utility/Invoke-WebRequest',
9
- description: 'Powershell Invoke-WebRequest client',
10
- },
11
- convert: generatePowershellConvert('Invoke-WebRequest'),
3
+ info: {
4
+ key: "webrequest",
5
+ title: "Invoke-WebRequest",
6
+ link: "https://docs.microsoft.com/en-us/powershell/module/Microsoft.PowerShell.Utility/Invoke-WebRequest",
7
+ description: "Powershell Invoke-WebRequest client"
8
+ },
9
+ convert: generatePowershellConvert("Invoke-WebRequest")
12
10
  };
13
-
14
- export { webrequest };
11
+ export {
12
+ webrequest
13
+ };
14
+ //# sourceMappingURL=client.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../../src/httpsnippet-lite/esm/targets/powershell/webrequest/client.ts"],
4
+ "sourcesContent": ["// @ts-nocheck\nimport { generatePowershellConvert } from '../common.js'\n\nexport const webrequest = {\n info: {\n key: 'webrequest',\n title: 'Invoke-WebRequest',\n link: 'https://docs.microsoft.com/en-us/powershell/module/Microsoft.PowerShell.Utility/Invoke-WebRequest',\n description: 'Powershell Invoke-WebRequest client',\n },\n convert: generatePowershellConvert('Invoke-WebRequest'),\n}\n"],
5
+ "mappings": "AACA,SAAS,iCAAiC;AAEnC,MAAM,aAAa;AAAA,EACxB,MAAM;AAAA,IACJ,KAAK;AAAA,IACL,OAAO;AAAA,IACP,MAAM;AAAA,IACN,aAAa;AAAA,EACf;AAAA,EACA,SAAS,0BAA0B,mBAAmB;AACxD;",
6
+ "names": []
7
+ }
@@ -0,0 +1,68 @@
1
+ function concatValues(concatType, values, pretty, indentation, indentLevel) {
2
+ const currentIndent = indentation.repeat(indentLevel);
3
+ const closingBraceIndent = indentation.repeat(indentLevel - 1);
4
+ const join = pretty ? `,
5
+ ${currentIndent}` : ", ";
6
+ const openingBrace = concatType === "object" ? "{" : "[";
7
+ const closingBrace = concatType === "object" ? "}" : "]";
8
+ if (pretty) {
9
+ return `${openingBrace}
10
+ ${currentIndent}${values.join(join)}
11
+ ${closingBraceIndent}${closingBrace}`;
12
+ }
13
+ if (concatType === "object" && values.length > 0) {
14
+ return `${openingBrace} ${values.join(join)} ${closingBrace}`;
15
+ }
16
+ return `${openingBrace}${values.join(join)}${closingBrace}`;
17
+ }
18
+ const literalRepresentation = (value, opts, indentLevel) => {
19
+ indentLevel = indentLevel === void 0 ? 1 : indentLevel + 1;
20
+ switch (Object.prototype.toString.call(value)) {
21
+ case "[object Number]":
22
+ return value;
23
+ case "[object Array]": {
24
+ let pretty = false;
25
+ const valuesRepresentation = value.map((v) => {
26
+ if (Object.prototype.toString.call(v) === "[object Object]") {
27
+ pretty = Object.keys(v).length > 1;
28
+ }
29
+ return literalRepresentation(v, opts, indentLevel);
30
+ });
31
+ return concatValues(
32
+ "array",
33
+ valuesRepresentation,
34
+ pretty,
35
+ opts.indent,
36
+ indentLevel
37
+ );
38
+ }
39
+ case "[object Object]": {
40
+ const keyValuePairs = [];
41
+ for (const key in value) {
42
+ keyValuePairs.push(
43
+ `"${key}": ${literalRepresentation(value[key], opts, indentLevel)}`
44
+ );
45
+ }
46
+ return concatValues(
47
+ "object",
48
+ keyValuePairs,
49
+ opts.pretty && keyValuePairs.length > 1,
50
+ opts.indent,
51
+ indentLevel
52
+ );
53
+ }
54
+ case "[object Null]":
55
+ return "None";
56
+ case "[object Boolean]":
57
+ return value ? "True" : "False";
58
+ default:
59
+ if (value === null || value === void 0) {
60
+ return "";
61
+ }
62
+ return `"${value.toString().replace(/"/g, '\\"')}"`;
63
+ }
64
+ };
65
+ export {
66
+ literalRepresentation
67
+ };
68
+ //# sourceMappingURL=helpers.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../src/httpsnippet-lite/esm/targets/python/helpers.ts"],
4
+ "sourcesContent": ["// @ts-nocheck\n/**\n * Create a string corresponding to a Dictionary or Array literal representation with pretty option\n * and indentation.\n */\nfunction concatValues(concatType, values, pretty, indentation, indentLevel) {\n const currentIndent = indentation.repeat(indentLevel)\n const closingBraceIndent = indentation.repeat(indentLevel - 1)\n const join = pretty ? `,\\n${currentIndent}` : ', '\n const openingBrace = concatType === 'object' ? '{' : '['\n const closingBrace = concatType === 'object' ? '}' : ']'\n if (pretty) {\n return `${openingBrace}\\n${currentIndent}${values.join(join)}\\n${closingBraceIndent}${closingBrace}`\n }\n if (concatType === 'object' && values.length > 0) {\n return `${openingBrace} ${values.join(join)} ${closingBrace}`\n }\n return `${openingBrace}${values.join(join)}${closingBrace}`\n}\n/**\n * Create a valid Python string of a literal value according to its type.\n *\n * @param {*} value Any JavaScript literal\n * @param {object} opts Target options\n * @return {string}\n */\nexport const literalRepresentation = (value, opts, indentLevel) => {\n indentLevel = indentLevel === undefined ? 1 : indentLevel + 1\n switch (Object.prototype.toString.call(value)) {\n case '[object Number]':\n return value\n case '[object Array]': {\n let pretty = false\n const valuesRepresentation = value.map((v) => {\n // Switch to prettify if the value is a dictionary with multiple keys\n if (Object.prototype.toString.call(v) === '[object Object]') {\n pretty = Object.keys(v).length > 1\n }\n return literalRepresentation(v, opts, indentLevel)\n })\n return concatValues(\n 'array',\n valuesRepresentation,\n pretty,\n opts.indent,\n indentLevel,\n )\n }\n case '[object Object]': {\n const keyValuePairs = []\n for (const key in value) {\n keyValuePairs.push(\n `\"${key}\": ${literalRepresentation(value[key], opts, indentLevel)}`,\n )\n }\n return concatValues(\n 'object',\n keyValuePairs,\n opts.pretty && keyValuePairs.length > 1,\n opts.indent,\n indentLevel,\n )\n }\n case '[object Null]':\n return 'None'\n case '[object Boolean]':\n return value ? 'True' : 'False'\n default:\n if (value === null || value === undefined) {\n return ''\n }\n return `\"${value.toString().replace(/\"/g, '\\\\\"')}\"`\n }\n}\n"],
5
+ "mappings": "AAKA,SAAS,aAAa,YAAY,QAAQ,QAAQ,aAAa,aAAa;AAC1E,QAAM,gBAAgB,YAAY,OAAO,WAAW;AACpD,QAAM,qBAAqB,YAAY,OAAO,cAAc,CAAC;AAC7D,QAAM,OAAO,SAAS;AAAA,EAAM,aAAa,KAAK;AAC9C,QAAM,eAAe,eAAe,WAAW,MAAM;AACrD,QAAM,eAAe,eAAe,WAAW,MAAM;AACrD,MAAI,QAAQ;AACV,WAAO,GAAG,YAAY;AAAA,EAAK,aAAa,GAAG,OAAO,KAAK,IAAI,CAAC;AAAA,EAAK,kBAAkB,GAAG,YAAY;AAAA,EACpG;AACA,MAAI,eAAe,YAAY,OAAO,SAAS,GAAG;AAChD,WAAO,GAAG,YAAY,IAAI,OAAO,KAAK,IAAI,CAAC,IAAI,YAAY;AAAA,EAC7D;AACA,SAAO,GAAG,YAAY,GAAG,OAAO,KAAK,IAAI,CAAC,GAAG,YAAY;AAC3D;AAQO,MAAM,wBAAwB,CAAC,OAAO,MAAM,gBAAgB;AACjE,gBAAc,gBAAgB,SAAY,IAAI,cAAc;AAC5D,UAAQ,OAAO,UAAU,SAAS,KAAK,KAAK,GAAG;AAAA,IAC7C,KAAK;AACH,aAAO;AAAA,IACT,KAAK,kBAAkB;AACrB,UAAI,SAAS;AACb,YAAM,uBAAuB,MAAM,IAAI,CAAC,MAAM;AAE5C,YAAI,OAAO,UAAU,SAAS,KAAK,CAAC,MAAM,mBAAmB;AAC3D,mBAAS,OAAO,KAAK,CAAC,EAAE,SAAS;AAAA,QACnC;AACA,eAAO,sBAAsB,GAAG,MAAM,WAAW;AAAA,MACnD,CAAC;AACD,aAAO;AAAA,QACL;AAAA,QACA;AAAA,QACA;AAAA,QACA,KAAK;AAAA,QACL;AAAA,MACF;AAAA,IACF;AAAA,IACA,KAAK,mBAAmB;AACtB,YAAM,gBAAgB,CAAC;AACvB,iBAAW,OAAO,OAAO;AACvB,sBAAc;AAAA,UACZ,IAAI,GAAG,MAAM,sBAAsB,MAAM,GAAG,GAAG,MAAM,WAAW,CAAC;AAAA,QACnE;AAAA,MACF;AACA,aAAO;AAAA,QACL;AAAA,QACA;AAAA,QACA,KAAK,UAAU,cAAc,SAAS;AAAA,QACtC,KAAK;AAAA,QACL;AAAA,MACF;AAAA,IACF;AAAA,IACA,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AACH,aAAO,QAAQ,SAAS;AAAA,IAC1B;AACE,UAAI,UAAU,QAAQ,UAAU,QAAW;AACzC,eAAO;AAAA,MACT;AACA,aAAO,IAAI,MAAM,SAAS,EAAE,QAAQ,MAAM,KAAK,CAAC;AAAA,EACpD;AACF;",
6
+ "names": []
7
+ }