@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,167 +1,129 @@
1
- /**
2
- * php/curl
3
- */
4
1
  const phpCurl = {
5
- target: 'php',
6
- client: 'curl',
7
- title: 'cURL',
8
- generate(request, configuration) {
9
- // Defaults
10
- const normalizedRequest = {
11
- method: 'GET',
12
- ...request,
13
- };
14
- // Normalization
15
- normalizedRequest.method = normalizedRequest.method.toUpperCase();
16
- // Build PHP cURL code parts
17
- const parts = [];
18
- // Initialize cURL
19
- // URL (with query parameters)
20
- const queryString = normalizedRequest.queryString?.length
21
- ? '?' +
22
- normalizedRequest.queryString
23
- .map((param) => {
24
- const encodedName = encodeURIComponent(param.name);
25
- const encodedValue = encodeURIComponent(param.value);
26
- return `${encodedName}=${encodedValue}`;
27
- })
28
- .join('&')
29
- : '';
30
- const url = `${normalizedRequest.url}${queryString}`;
31
- parts.push(`$ch = curl_init("${url}");`);
32
- parts.push('');
33
- // Method
34
- if (normalizedRequest.method === 'POST') {
35
- parts.push('curl_setopt($ch, CURLOPT_POST, true);');
36
- }
37
- // Basic Auth
38
- if (configuration?.auth?.username && configuration?.auth?.password) {
39
- parts.push(`curl_setopt($ch, CURLOPT_USERPWD, '${configuration.auth.username}:${configuration.auth.password}');`);
40
- }
41
- // Headers
42
- if (normalizedRequest.headers?.length) {
43
- const headerStrings = normalizedRequest.headers.map((header) => `'${header.name}: ${header.value}'`);
44
- parts.push(`curl_setopt($ch, CURLOPT_HTTPHEADER, [${headerStrings.join(', ')}]);`);
45
- // Add encoding option if Accept-Encoding header includes compression
46
- const acceptEncoding = normalizedRequest.headers.find((header) => header.name.toLowerCase() === 'accept-encoding');
47
- if (acceptEncoding && /gzip|deflate/.test(acceptEncoding.value)) {
48
- parts.push("curl_setopt($ch, CURLOPT_ENCODING, '');");
49
- }
50
- }
51
- // Cookies
52
- if (normalizedRequest.cookies?.length) {
53
- const cookieString = normalizedRequest.cookies
54
- .map((cookie) => {
55
- const encodedName = encodeURIComponent(cookie.name);
56
- const encodedValue = encodeURIComponent(cookie.value);
57
- return `${encodedName}=${encodedValue}`;
58
- })
59
- .join('; ');
60
- parts.push(`curl_setopt($ch, CURLOPT_COOKIE, '${cookieString}');`);
2
+ target: "php",
3
+ client: "curl",
4
+ title: "cURL",
5
+ generate(request, configuration) {
6
+ const normalizedRequest = {
7
+ method: "GET",
8
+ ...request
9
+ };
10
+ normalizedRequest.method = normalizedRequest.method.toUpperCase();
11
+ const parts = [];
12
+ const queryString = normalizedRequest.queryString?.length ? "?" + normalizedRequest.queryString.map((param) => {
13
+ const encodedName = encodeURIComponent(param.name);
14
+ const encodedValue = encodeURIComponent(param.value);
15
+ return `${encodedName}=${encodedValue}`;
16
+ }).join("&") : "";
17
+ const url = `${normalizedRequest.url}${queryString}`;
18
+ parts.push(`$ch = curl_init("${url}");`);
19
+ parts.push("");
20
+ if (normalizedRequest.method === "POST") {
21
+ parts.push("curl_setopt($ch, CURLOPT_POST, true);");
22
+ }
23
+ if (configuration?.auth?.username && configuration?.auth?.password) {
24
+ parts.push(`curl_setopt($ch, CURLOPT_USERPWD, '${configuration.auth.username}:${configuration.auth.password}');`);
25
+ }
26
+ if (normalizedRequest.headers?.length) {
27
+ const headerStrings = normalizedRequest.headers.map((header) => `'${header.name}: ${header.value}'`);
28
+ parts.push(`curl_setopt($ch, CURLOPT_HTTPHEADER, [${headerStrings.join(", ")}]);`);
29
+ const acceptEncoding = normalizedRequest.headers.find((header) => header.name.toLowerCase() === "accept-encoding");
30
+ if (acceptEncoding && /gzip|deflate/.test(acceptEncoding.value)) {
31
+ parts.push("curl_setopt($ch, CURLOPT_ENCODING, '');");
32
+ }
33
+ }
34
+ if (normalizedRequest.cookies?.length) {
35
+ const cookieString = normalizedRequest.cookies.map((cookie) => {
36
+ const encodedName = encodeURIComponent(cookie.name);
37
+ const encodedValue = encodeURIComponent(cookie.value);
38
+ return `${encodedName}=${encodedValue}`;
39
+ }).join("; ");
40
+ parts.push(`curl_setopt($ch, CURLOPT_COOKIE, '${cookieString}');`);
41
+ }
42
+ if (normalizedRequest.postData) {
43
+ if (normalizedRequest.postData.mimeType === "application/json") {
44
+ if (normalizedRequest.postData.text) {
45
+ try {
46
+ const jsonData = JSON.parse(normalizedRequest.postData.text);
47
+ const phpArray = convertToPhpArray(jsonData);
48
+ parts.push(`curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode(${phpArray}));`);
49
+ } catch {
50
+ parts.push(`curl_setopt($ch, CURLOPT_POSTFIELDS, '${normalizedRequest.postData.text}');`);
51
+ }
61
52
  }
62
- // Body
63
- if (normalizedRequest.postData) {
64
- if (normalizedRequest.postData.mimeType === 'application/json') {
65
- // Convert JSON to PHP array syntax
66
- if (normalizedRequest.postData.text) {
67
- try {
68
- const jsonData = JSON.parse(normalizedRequest.postData.text);
69
- const phpArray = convertToPhpArray(jsonData);
70
- parts.push(`curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode(${phpArray}));`);
71
- }
72
- catch {
73
- parts.push(`curl_setopt($ch, CURLOPT_POSTFIELDS, '${normalizedRequest.postData.text}');`);
74
- }
75
- }
76
- }
77
- else if (normalizedRequest.postData.mimeType === 'multipart/form-data' && normalizedRequest.postData.params) {
78
- // Handle multipart form data
79
- const formData = normalizedRequest.postData.params.reduce((acc, param) => {
80
- if (param.fileName !== undefined) {
81
- acc.push(`'${param.name}' => '@${param.fileName}'`);
82
- }
83
- else if (param.value !== undefined) {
84
- acc.push(`'${param.name}' => '${param.value}'`);
85
- }
86
- return acc;
87
- }, []);
88
- parts.push(`curl_setopt($ch, CURLOPT_HTTPHEADER, ['Content-Type: multipart/form-data']);`);
89
- parts.push(`curl_setopt($ch, CURLOPT_POSTFIELDS, [${formData.join(', ')}]);`);
90
- }
91
- else if (normalizedRequest.postData.mimeType === 'application/x-www-form-urlencoded' &&
92
- normalizedRequest.postData.params) {
93
- // Handle URL-encoded form data
94
- const formData = normalizedRequest.postData.params
95
- .map((param) => {
96
- const encodedName = encodeURIComponent(param.name);
97
- const encodedValue = param.value ? encodeURIComponent(param.value) : '';
98
- return `${encodedName}=${encodedValue}`;
99
- })
100
- .join('&');
101
- parts.push(`curl_setopt($ch, CURLOPT_HTTPHEADER, ['Content-Type: application/x-www-form-urlencoded']);`);
102
- parts.push(`curl_setopt($ch, CURLOPT_POSTFIELDS, '${formData}');`);
103
- }
104
- else if (normalizedRequest.postData.mimeType === 'application/octet-stream') {
105
- parts.push(`curl_setopt($ch, CURLOPT_HTTPHEADER, ['Content-Type: application/octet-stream']);`);
106
- parts.push(`curl_setopt($ch, CURLOPT_POSTFIELDS, '${normalizedRequest.postData.text || ''}');`);
107
- }
108
- else if (normalizedRequest.postData.text) {
109
- // Try to parse as JSON and convert to PHP array, otherwise use raw text
110
- try {
111
- const jsonData = JSON.parse(normalizedRequest.postData.text);
112
- const phpArray = convertToPhpArray(jsonData);
113
- parts.push(`curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode(${phpArray}));`);
114
- }
115
- catch {
116
- parts.push(`curl_setopt($ch, CURLOPT_POSTFIELDS, '${normalizedRequest.postData.text}');`);
117
- }
118
- }
53
+ } else if (normalizedRequest.postData.mimeType === "multipart/form-data" && normalizedRequest.postData.params) {
54
+ const formData = normalizedRequest.postData.params.reduce((acc, param) => {
55
+ if (param.fileName !== void 0) {
56
+ acc.push(`'${param.name}' => '@${param.fileName}'`);
57
+ } else if (param.value !== void 0) {
58
+ acc.push(`'${param.name}' => '${param.value}'`);
59
+ }
60
+ return acc;
61
+ }, []);
62
+ parts.push(`curl_setopt($ch, CURLOPT_HTTPHEADER, ['Content-Type: multipart/form-data']);`);
63
+ parts.push(`curl_setopt($ch, CURLOPT_POSTFIELDS, [${formData.join(", ")}]);`);
64
+ } else if (normalizedRequest.postData.mimeType === "application/x-www-form-urlencoded" && normalizedRequest.postData.params) {
65
+ const formData = normalizedRequest.postData.params.map((param) => {
66
+ const encodedName = encodeURIComponent(param.name);
67
+ const encodedValue = param.value ? encodeURIComponent(param.value) : "";
68
+ return `${encodedName}=${encodedValue}`;
69
+ }).join("&");
70
+ parts.push(`curl_setopt($ch, CURLOPT_HTTPHEADER, ['Content-Type: application/x-www-form-urlencoded']);`);
71
+ parts.push(`curl_setopt($ch, CURLOPT_POSTFIELDS, '${formData}');`);
72
+ } else if (normalizedRequest.postData.mimeType === "application/octet-stream") {
73
+ parts.push(`curl_setopt($ch, CURLOPT_HTTPHEADER, ['Content-Type: application/octet-stream']);`);
74
+ parts.push(`curl_setopt($ch, CURLOPT_POSTFIELDS, '${normalizedRequest.postData.text || ""}');`);
75
+ } else if (normalizedRequest.postData.text) {
76
+ try {
77
+ const jsonData = JSON.parse(normalizedRequest.postData.text);
78
+ const phpArray = convertToPhpArray(jsonData);
79
+ parts.push(`curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode(${phpArray}));`);
80
+ } catch {
81
+ parts.push(`curl_setopt($ch, CURLOPT_POSTFIELDS, '${normalizedRequest.postData.text}');`);
119
82
  }
120
- // Execute and close
121
- parts.push('');
122
- parts.push('curl_exec($ch);');
123
- parts.push('');
124
- parts.push('curl_close($ch);');
125
- return parts.join('\n').replace(/\n\n\n/g, '\n\n');
126
- },
83
+ }
84
+ }
85
+ parts.push("");
86
+ parts.push("curl_exec($ch);");
87
+ parts.push("");
88
+ parts.push("curl_close($ch);");
89
+ return parts.join("\n").replace(/\n\n\n/g, "\n\n");
90
+ }
127
91
  };
128
- /**
129
- * Helper function to create consistent indentation
130
- */
131
92
  function indent(level) {
132
- return ' '.repeat(level * 2);
93
+ return " ".repeat(level * 2);
133
94
  }
134
- /**
135
- * Converts a JavaScript object to a PHP array string representation
136
- */
137
95
  function convertToPhpArray(data, indentLevel = 0) {
138
- if (data === null || data === undefined) {
139
- return 'null';
140
- }
141
- if (typeof data === 'string') {
142
- return `'${data.replace(/'/g, "\\'")}'`;
96
+ if (data === null || data === void 0) {
97
+ return "null";
98
+ }
99
+ if (typeof data === "string") {
100
+ return `'${data.replace(/'/g, "\\'")}'`;
101
+ }
102
+ if (typeof data === "number" || typeof data === "boolean") {
103
+ return String(data);
104
+ }
105
+ if (Array.isArray(data)) {
106
+ if (data.length === 0) {
107
+ return "[]";
143
108
  }
144
- if (typeof data === 'number' || typeof data === 'boolean') {
145
- return String(data);
146
- }
147
- if (Array.isArray(data)) {
148
- if (data.length === 0) {
149
- return '[]';
150
- }
151
- const items = data.map((item) => convertToPhpArray(item, indentLevel + 1)).join(',\n' + indent(indentLevel + 1));
152
- return `[\n${indent(indentLevel + 1)}${items}\n${indent(indentLevel)}]`;
109
+ const items = data.map((item) => convertToPhpArray(item, indentLevel + 1)).join(",\n" + indent(indentLevel + 1));
110
+ return `[
111
+ ${indent(indentLevel + 1)}${items}
112
+ ${indent(indentLevel)}]`;
113
+ }
114
+ if (typeof data === "object") {
115
+ const entries = Object.entries(data);
116
+ if (entries.length === 0) {
117
+ return "[]";
153
118
  }
154
- if (typeof data === 'object') {
155
- const entries = Object.entries(data);
156
- if (entries.length === 0) {
157
- return '[]';
158
- }
159
- const items = entries
160
- .map(([key, value]) => `'${key}' => ${convertToPhpArray(value, indentLevel + 1)}`)
161
- .join(',\n' + indent(indentLevel + 1));
162
- return `[\n${indent(indentLevel + 1)}${items}\n${indent(indentLevel)}]`;
163
- }
164
- return 'null';
119
+ const items = entries.map(([key, value]) => `'${key}' => ${convertToPhpArray(value, indentLevel + 1)}`).join(",\n" + indent(indentLevel + 1));
120
+ return `[
121
+ ${indent(indentLevel + 1)}${items}
122
+ ${indent(indentLevel)}]`;
123
+ }
124
+ return "null";
165
125
  }
166
-
167
- export { phpCurl };
126
+ export {
127
+ phpCurl
128
+ };
129
+ //# sourceMappingURL=curl.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../src/plugins/php/curl/curl.ts"],
4
+ "sourcesContent": ["import type { Plugin } from '@scalar/types/snippetz'\n\n/**\n * php/curl\n */\nexport const phpCurl: Plugin = {\n target: 'php',\n client: 'curl',\n title: 'cURL',\n generate(request, configuration) {\n // Defaults\n const normalizedRequest = {\n method: 'GET',\n ...request,\n }\n\n // Normalization\n normalizedRequest.method = normalizedRequest.method.toUpperCase()\n\n // Build PHP cURL code parts\n const parts: string[] = []\n\n // Initialize cURL\n // URL (with query parameters)\n const queryString = normalizedRequest.queryString?.length\n ? '?' +\n normalizedRequest.queryString\n .map((param) => {\n const encodedName = encodeURIComponent(param.name)\n const encodedValue = encodeURIComponent(param.value)\n return `${encodedName}=${encodedValue}`\n })\n .join('&')\n : ''\n const url = `${normalizedRequest.url}${queryString}`\n parts.push(`$ch = curl_init(\"${url}\");`)\n parts.push('')\n\n // Method\n if (normalizedRequest.method === 'POST') {\n parts.push('curl_setopt($ch, CURLOPT_POST, true);')\n }\n\n // Basic Auth\n if (configuration?.auth?.username && configuration?.auth?.password) {\n parts.push(`curl_setopt($ch, CURLOPT_USERPWD, '${configuration.auth.username}:${configuration.auth.password}');`)\n }\n\n // Headers\n if (normalizedRequest.headers?.length) {\n const headerStrings = normalizedRequest.headers.map((header) => `'${header.name}: ${header.value}'`)\n parts.push(`curl_setopt($ch, CURLOPT_HTTPHEADER, [${headerStrings.join(', ')}]);`)\n\n // Add encoding option if Accept-Encoding header includes compression\n const acceptEncoding = normalizedRequest.headers.find((header) => header.name.toLowerCase() === 'accept-encoding')\n if (acceptEncoding && /gzip|deflate/.test(acceptEncoding.value)) {\n parts.push(\"curl_setopt($ch, CURLOPT_ENCODING, '');\")\n }\n }\n\n // Cookies\n if (normalizedRequest.cookies?.length) {\n const cookieString = normalizedRequest.cookies\n .map((cookie) => {\n const encodedName = encodeURIComponent(cookie.name)\n const encodedValue = encodeURIComponent(cookie.value)\n return `${encodedName}=${encodedValue}`\n })\n .join('; ')\n parts.push(`curl_setopt($ch, CURLOPT_COOKIE, '${cookieString}');`)\n }\n\n // Body\n if (normalizedRequest.postData) {\n if (normalizedRequest.postData.mimeType === 'application/json') {\n // Convert JSON to PHP array syntax\n if (normalizedRequest.postData.text) {\n try {\n const jsonData = JSON.parse(normalizedRequest.postData.text)\n const phpArray = convertToPhpArray(jsonData)\n parts.push(`curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode(${phpArray}));`)\n } catch {\n parts.push(`curl_setopt($ch, CURLOPT_POSTFIELDS, '${normalizedRequest.postData.text}');`)\n }\n }\n } else if (normalizedRequest.postData.mimeType === 'multipart/form-data' && normalizedRequest.postData.params) {\n // Handle multipart form data\n const formData = normalizedRequest.postData.params.reduce((acc, param) => {\n if (param.fileName !== undefined) {\n acc.push(`'${param.name}' => '@${param.fileName}'`)\n } else if (param.value !== undefined) {\n acc.push(`'${param.name}' => '${param.value}'`)\n }\n return acc\n }, [] as string[])\n\n parts.push(`curl_setopt($ch, CURLOPT_HTTPHEADER, ['Content-Type: multipart/form-data']);`)\n parts.push(`curl_setopt($ch, CURLOPT_POSTFIELDS, [${formData.join(', ')}]);`)\n } else if (\n normalizedRequest.postData.mimeType === 'application/x-www-form-urlencoded' &&\n normalizedRequest.postData.params\n ) {\n // Handle URL-encoded form data\n const formData = normalizedRequest.postData.params\n .map((param) => {\n const encodedName = encodeURIComponent(param.name)\n const encodedValue = param.value ? encodeURIComponent(param.value) : ''\n return `${encodedName}=${encodedValue}`\n })\n .join('&')\n parts.push(`curl_setopt($ch, CURLOPT_HTTPHEADER, ['Content-Type: application/x-www-form-urlencoded']);`)\n parts.push(`curl_setopt($ch, CURLOPT_POSTFIELDS, '${formData}');`)\n } else if (normalizedRequest.postData.mimeType === 'application/octet-stream') {\n parts.push(`curl_setopt($ch, CURLOPT_HTTPHEADER, ['Content-Type: application/octet-stream']);`)\n parts.push(`curl_setopt($ch, CURLOPT_POSTFIELDS, '${normalizedRequest.postData.text || ''}');`)\n } else if (normalizedRequest.postData.text) {\n // Try to parse as JSON and convert to PHP array, otherwise use raw text\n try {\n const jsonData = JSON.parse(normalizedRequest.postData.text)\n const phpArray = convertToPhpArray(jsonData)\n parts.push(`curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode(${phpArray}));`)\n } catch {\n parts.push(`curl_setopt($ch, CURLOPT_POSTFIELDS, '${normalizedRequest.postData.text}');`)\n }\n }\n }\n\n // Execute and close\n parts.push('')\n parts.push('curl_exec($ch);')\n parts.push('')\n parts.push('curl_close($ch);')\n\n return parts.join('\\n').replace(/\\n\\n\\n/g, '\\n\\n')\n },\n}\n\n/**\n * Helper function to create consistent indentation\n */\nfunction indent(level: number): string {\n return ' '.repeat(level * 2)\n}\n\n/**\n * Converts a JavaScript object to a PHP array string representation\n */\nfunction convertToPhpArray(data: unknown, indentLevel = 0): string {\n if (data === null || data === undefined) {\n return 'null'\n }\n\n if (typeof data === 'string') {\n return `'${data.replace(/'/g, \"\\\\'\")}'`\n }\n\n if (typeof data === 'number' || typeof data === 'boolean') {\n return String(data)\n }\n\n if (Array.isArray(data)) {\n if (data.length === 0) {\n return '[]'\n }\n\n const items = data.map((item) => convertToPhpArray(item, indentLevel + 1)).join(',\\n' + indent(indentLevel + 1))\n return `[\\n${indent(indentLevel + 1)}${items}\\n${indent(indentLevel)}]`\n }\n\n if (typeof data === 'object') {\n const entries = Object.entries(data)\n if (entries.length === 0) {\n return '[]'\n }\n\n const items = entries\n .map(([key, value]) => `'${key}' => ${convertToPhpArray(value, indentLevel + 1)}`)\n .join(',\\n' + indent(indentLevel + 1))\n return `[\\n${indent(indentLevel + 1)}${items}\\n${indent(indentLevel)}]`\n }\n\n return 'null'\n}\n"],
5
+ "mappings": "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",
6
+ "names": []
7
+ }