@scalar/snippetz 0.2.7 → 0.2.9
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.
- package/dist/clients.d.ts +6 -0
- package/dist/clients.d.ts.map +1 -0
- package/dist/clients.js +150 -0
- package/dist/httpsnippet-lite/esm/helpers/code-builder.d.ts +8 -0
- package/dist/httpsnippet-lite/esm/helpers/code-builder.d.ts.map +1 -0
- package/dist/httpsnippet-lite/esm/helpers/code-builder.js +62 -0
- package/dist/httpsnippet-lite/esm/helpers/escape.d.ts +29 -0
- package/dist/httpsnippet-lite/esm/helpers/escape.d.ts.map +1 -0
- package/dist/httpsnippet-lite/esm/helpers/escape.js +74 -0
- package/dist/httpsnippet-lite/esm/helpers/form-data.d.ts +3 -0
- package/dist/httpsnippet-lite/esm/helpers/form-data.d.ts.map +1 -0
- package/dist/httpsnippet-lite/esm/helpers/headers.d.ts +17 -0
- package/dist/httpsnippet-lite/esm/helpers/headers.d.ts.map +1 -0
- package/dist/httpsnippet-lite/esm/helpers/headers.js +22 -0
- package/dist/httpsnippet-lite/esm/helpers/reducer.d.ts +2 -0
- package/dist/httpsnippet-lite/esm/helpers/reducer.d.ts.map +1 -0
- package/dist/httpsnippet-lite/esm/helpers/shell.d.ts +7 -0
- package/dist/httpsnippet-lite/esm/helpers/shell.d.ts.map +1 -0
- package/dist/httpsnippet-lite/esm/helpers/shell.js +18 -0
- package/dist/httpsnippet-lite/esm/helpers/url.d.ts +5 -0
- package/dist/httpsnippet-lite/esm/helpers/url.d.ts.map +1 -0
- package/dist/httpsnippet-lite/esm/helpers/utils.d.ts +3 -0
- package/dist/httpsnippet-lite/esm/helpers/utils.d.ts.map +1 -0
- package/dist/httpsnippet-lite/esm/httpsnippet.d.ts +10 -0
- package/dist/httpsnippet-lite/esm/httpsnippet.d.ts.map +1 -0
- package/dist/httpsnippet-lite/esm/targets/c/libcurl/client.d.ts +16 -0
- package/dist/httpsnippet-lite/esm/targets/c/libcurl/client.d.ts.map +1 -0
- package/dist/httpsnippet-lite/esm/targets/c/libcurl/client.js +45 -0
- package/dist/httpsnippet-lite/esm/targets/c/target.d.ts +26 -0
- package/dist/httpsnippet-lite/esm/targets/c/target.d.ts.map +1 -0
- package/dist/httpsnippet-lite/esm/targets/clojure/clj_http/client.d.ts +16 -0
- package/dist/httpsnippet-lite/esm/targets/clojure/clj_http/client.d.ts.map +1 -0
- package/dist/httpsnippet-lite/esm/targets/clojure/clj_http/client.js +189 -0
- package/dist/httpsnippet-lite/esm/targets/clojure/target.d.ts +26 -0
- package/dist/httpsnippet-lite/esm/targets/clojure/target.d.ts.map +1 -0
- package/dist/httpsnippet-lite/esm/targets/csharp/httpclient/client.d.ts +15 -0
- package/dist/httpsnippet-lite/esm/targets/csharp/httpclient/client.d.ts.map +1 -0
- package/dist/httpsnippet-lite/esm/targets/csharp/httpclient/client.js +169 -0
- package/dist/httpsnippet-lite/esm/targets/csharp/restsharp/client.d.ts +17 -0
- package/dist/httpsnippet-lite/esm/targets/csharp/restsharp/client.d.ts.map +1 -0
- package/dist/httpsnippet-lite/esm/targets/csharp/restsharp/client.js +49 -0
- package/dist/httpsnippet-lite/esm/targets/csharp/target.d.ts +41 -0
- package/dist/httpsnippet-lite/esm/targets/csharp/target.d.ts.map +1 -0
- package/dist/httpsnippet-lite/esm/targets/go/native/client.d.ts +15 -0
- package/dist/httpsnippet-lite/esm/targets/go/native/client.d.ts.map +1 -0
- package/dist/httpsnippet-lite/esm/targets/go/native/client.js +124 -0
- package/dist/httpsnippet-lite/esm/targets/go/target.d.ts +25 -0
- package/dist/httpsnippet-lite/esm/targets/go/target.d.ts.map +1 -0
- package/dist/httpsnippet-lite/esm/targets/http/http1.1/client.d.ts +22 -0
- package/dist/httpsnippet-lite/esm/targets/http/http1.1/client.d.ts.map +1 -0
- package/dist/httpsnippet-lite/esm/targets/http/http1.1/client.js +77 -0
- package/dist/httpsnippet-lite/esm/targets/http/target.d.ts +27 -0
- package/dist/httpsnippet-lite/esm/targets/http/target.d.ts.map +1 -0
- package/dist/httpsnippet-lite/esm/targets/java/asynchttp/client.d.ts +15 -0
- package/dist/httpsnippet-lite/esm/targets/java/asynchttp/client.d.ts.map +1 -0
- package/dist/httpsnippet-lite/esm/targets/java/asynchttp/client.js +47 -0
- package/dist/httpsnippet-lite/esm/targets/java/nethttp/client.d.ts +15 -0
- package/dist/httpsnippet-lite/esm/targets/java/nethttp/client.d.ts.map +1 -0
- package/dist/httpsnippet-lite/esm/targets/java/nethttp/client.js +46 -0
- package/dist/httpsnippet-lite/esm/targets/java/okhttp/client.d.ts +15 -0
- package/dist/httpsnippet-lite/esm/targets/java/okhttp/client.d.ts.map +1 -0
- package/dist/httpsnippet-lite/esm/targets/java/okhttp/client.js +73 -0
- package/dist/httpsnippet-lite/esm/targets/java/target.d.ts +67 -0
- package/dist/httpsnippet-lite/esm/targets/java/target.d.ts.map +1 -0
- package/dist/httpsnippet-lite/esm/targets/java/unirest/client.d.ts +15 -0
- package/dist/httpsnippet-lite/esm/targets/java/unirest/client.d.ts.map +1 -0
- package/dist/httpsnippet-lite/esm/targets/java/unirest/client.js +47 -0
- package/dist/httpsnippet-lite/esm/targets/javascript/axios/client.d.ts +16 -0
- package/dist/httpsnippet-lite/esm/targets/javascript/axios/client.d.ts.map +1 -0
- package/dist/httpsnippet-lite/esm/targets/javascript/axios/client.js +91 -0
- package/dist/httpsnippet-lite/esm/targets/javascript/fetch/client.d.ts +15 -0
- package/dist/httpsnippet-lite/esm/targets/javascript/fetch/client.d.ts.map +1 -0
- package/dist/httpsnippet-lite/esm/targets/javascript/jquery/client.d.ts +15 -0
- package/dist/httpsnippet-lite/esm/targets/javascript/jquery/client.d.ts.map +1 -0
- package/dist/httpsnippet-lite/esm/targets/javascript/jquery/client.js +88 -0
- package/dist/httpsnippet-lite/esm/targets/javascript/target.d.ts +68 -0
- package/dist/httpsnippet-lite/esm/targets/javascript/target.d.ts.map +1 -0
- package/dist/httpsnippet-lite/esm/targets/javascript/xhr/client.d.ts +15 -0
- package/dist/httpsnippet-lite/esm/targets/javascript/xhr/client.d.ts.map +1 -0
- package/dist/httpsnippet-lite/esm/targets/javascript/xhr/client.js +86 -0
- package/dist/httpsnippet-lite/esm/targets/kotlin/okhttp/client.d.ts +15 -0
- package/dist/httpsnippet-lite/esm/targets/kotlin/okhttp/client.d.ts.map +1 -0
- package/dist/httpsnippet-lite/esm/targets/kotlin/okhttp/client.js +73 -0
- package/dist/httpsnippet-lite/esm/targets/kotlin/target.d.ts +25 -0
- package/dist/httpsnippet-lite/esm/targets/kotlin/target.d.ts.map +1 -0
- package/dist/httpsnippet-lite/esm/targets/node/axios/client.d.ts +16 -0
- package/dist/httpsnippet-lite/esm/targets/node/axios/client.d.ts.map +1 -0
- package/dist/httpsnippet-lite/esm/targets/node/axios/client.js +83 -0
- package/dist/httpsnippet-lite/esm/targets/node/fetch/client.d.ts +16 -0
- package/dist/httpsnippet-lite/esm/targets/node/fetch/client.d.ts.map +1 -0
- package/dist/httpsnippet-lite/esm/targets/node/native/client.d.ts +15 -0
- package/dist/httpsnippet-lite/esm/targets/node/native/client.d.ts.map +1 -0
- package/dist/httpsnippet-lite/esm/targets/node/request/client.d.ts +17 -0
- package/dist/httpsnippet-lite/esm/targets/node/request/client.d.ts.map +1 -0
- package/dist/httpsnippet-lite/esm/targets/node/target.d.ts +87 -0
- package/dist/httpsnippet-lite/esm/targets/node/target.d.ts.map +1 -0
- package/dist/httpsnippet-lite/esm/targets/node/unirest/client.d.ts +17 -0
- package/dist/httpsnippet-lite/esm/targets/node/unirest/client.d.ts.map +1 -0
- package/dist/httpsnippet-lite/esm/targets/objc/helpers.d.ts +27 -0
- package/dist/httpsnippet-lite/esm/targets/objc/helpers.d.ts.map +1 -0
- package/dist/httpsnippet-lite/esm/targets/objc/helpers.js +58 -0
- package/dist/httpsnippet-lite/esm/targets/objc/nsurlsession/client.d.ts +15 -0
- package/dist/httpsnippet-lite/esm/targets/objc/nsurlsession/client.d.ts.map +1 -0
- package/dist/httpsnippet-lite/esm/targets/objc/nsurlsession/client.js +132 -0
- package/dist/httpsnippet-lite/esm/targets/objc/target.d.ts +25 -0
- package/dist/httpsnippet-lite/esm/targets/objc/target.d.ts.map +1 -0
- package/dist/httpsnippet-lite/esm/targets/ocaml/cohttp/client.d.ts +15 -0
- package/dist/httpsnippet-lite/esm/targets/ocaml/cohttp/client.d.ts.map +1 -0
- package/dist/httpsnippet-lite/esm/targets/ocaml/cohttp/client.js +68 -0
- package/dist/httpsnippet-lite/esm/targets/ocaml/target.d.ts +25 -0
- package/dist/httpsnippet-lite/esm/targets/ocaml/target.d.ts.map +1 -0
- package/dist/httpsnippet-lite/esm/targets/php/curl/client.d.ts +18 -0
- package/dist/httpsnippet-lite/esm/targets/php/curl/client.d.ts.map +1 -0
- package/dist/httpsnippet-lite/esm/targets/php/curl/client.js +134 -0
- package/dist/httpsnippet-lite/esm/targets/php/guzzle/client.d.ts +16 -0
- package/dist/httpsnippet-lite/esm/targets/php/guzzle/client.d.ts.map +1 -0
- package/dist/httpsnippet-lite/esm/targets/php/guzzle/client.js +126 -0
- package/dist/httpsnippet-lite/esm/targets/php/helpers.d.ts +3 -0
- package/dist/httpsnippet-lite/esm/targets/php/helpers.d.ts.map +1 -0
- package/dist/httpsnippet-lite/esm/targets/php/helpers.js +37 -0
- package/dist/httpsnippet-lite/esm/targets/php/http1/client.d.ts +17 -0
- package/dist/httpsnippet-lite/esm/targets/php/http1/client.d.ts.map +1 -0
- package/dist/httpsnippet-lite/esm/targets/php/http2/client.d.ts +17 -0
- package/dist/httpsnippet-lite/esm/targets/php/http2/client.d.ts.map +1 -0
- package/dist/httpsnippet-lite/esm/targets/php/target.d.ts +75 -0
- package/dist/httpsnippet-lite/esm/targets/php/target.d.ts.map +1 -0
- package/dist/httpsnippet-lite/esm/targets/powershell/common.d.ts +10 -0
- package/dist/httpsnippet-lite/esm/targets/powershell/common.d.ts.map +1 -0
- package/dist/httpsnippet-lite/esm/targets/powershell/common.js +53 -0
- package/dist/httpsnippet-lite/esm/targets/powershell/restmethod/client.d.ts +18 -0
- package/dist/httpsnippet-lite/esm/targets/powershell/restmethod/client.d.ts.map +1 -0
- package/dist/httpsnippet-lite/esm/targets/powershell/restmethod/client.js +15 -0
- package/dist/httpsnippet-lite/esm/targets/powershell/target.d.ts +45 -0
- package/dist/httpsnippet-lite/esm/targets/powershell/target.d.ts.map +1 -0
- package/dist/httpsnippet-lite/esm/targets/powershell/webrequest/client.d.ts +18 -0
- package/dist/httpsnippet-lite/esm/targets/powershell/webrequest/client.d.ts.map +1 -0
- package/dist/httpsnippet-lite/esm/targets/powershell/webrequest/client.js +15 -0
- package/dist/httpsnippet-lite/esm/targets/python/helpers.d.ts +9 -0
- package/dist/httpsnippet-lite/esm/targets/python/helpers.d.ts.map +1 -0
- package/dist/httpsnippet-lite/esm/targets/python/helpers.js +63 -0
- package/dist/httpsnippet-lite/esm/targets/python/python3/client.d.ts +19 -0
- package/dist/httpsnippet-lite/esm/targets/python/python3/client.d.ts.map +1 -0
- package/dist/httpsnippet-lite/esm/targets/python/python3/client.js +95 -0
- package/dist/httpsnippet-lite/esm/targets/python/requests/client.d.ts +16 -0
- package/dist/httpsnippet-lite/esm/targets/python/requests/client.d.ts.map +1 -0
- package/dist/httpsnippet-lite/esm/targets/python/requests/client.js +177 -0
- package/dist/httpsnippet-lite/esm/targets/python/target.d.ts +44 -0
- package/dist/httpsnippet-lite/esm/targets/python/target.d.ts.map +1 -0
- package/dist/httpsnippet-lite/esm/targets/r/httr/client.d.ts +17 -0
- package/dist/httpsnippet-lite/esm/targets/r/httr/client.d.ts.map +1 -0
- package/dist/httpsnippet-lite/esm/targets/r/httr/client.js +127 -0
- package/dist/httpsnippet-lite/esm/targets/r/target.d.ts +27 -0
- package/dist/httpsnippet-lite/esm/targets/r/target.d.ts.map +1 -0
- package/dist/httpsnippet-lite/esm/targets/ruby/native/client.d.ts +16 -0
- package/dist/httpsnippet-lite/esm/targets/ruby/native/client.d.ts.map +1 -0
- package/dist/httpsnippet-lite/esm/targets/ruby/native/client.js +72 -0
- package/dist/httpsnippet-lite/esm/targets/ruby/target.d.ts +26 -0
- package/dist/httpsnippet-lite/esm/targets/ruby/target.d.ts.map +1 -0
- package/dist/httpsnippet-lite/esm/targets/shell/curl/client.d.ts +17 -0
- package/dist/httpsnippet-lite/esm/targets/shell/curl/client.d.ts.map +1 -0
- package/dist/httpsnippet-lite/esm/targets/shell/httpie/client.d.ts +17 -0
- package/dist/httpsnippet-lite/esm/targets/shell/httpie/client.d.ts.map +1 -0
- package/dist/httpsnippet-lite/esm/targets/shell/httpie/client.js +118 -0
- package/dist/httpsnippet-lite/esm/targets/shell/target.d.ts +57 -0
- package/dist/httpsnippet-lite/esm/targets/shell/target.d.ts.map +1 -0
- package/dist/httpsnippet-lite/esm/targets/shell/wget/client.d.ts +15 -0
- package/dist/httpsnippet-lite/esm/targets/shell/wget/client.d.ts.map +1 -0
- package/dist/httpsnippet-lite/esm/targets/shell/wget/client.js +54 -0
- package/dist/httpsnippet-lite/esm/targets/swift/helpers.d.ts +17 -0
- package/dist/httpsnippet-lite/esm/targets/swift/helpers.d.ts.map +1 -0
- package/dist/httpsnippet-lite/esm/targets/swift/helpers.js +76 -0
- package/dist/httpsnippet-lite/esm/targets/swift/nsurlsession/client.d.ts +15 -0
- package/dist/httpsnippet-lite/esm/targets/swift/nsurlsession/client.d.ts.map +1 -0
- package/dist/httpsnippet-lite/esm/targets/swift/nsurlsession/client.js +137 -0
- package/dist/httpsnippet-lite/esm/targets/swift/target.d.ts +25 -0
- package/dist/httpsnippet-lite/esm/targets/swift/target.d.ts.map +1 -0
- package/dist/httpsnippet-lite/esm/targets/targets.d.ts +731 -0
- package/dist/httpsnippet-lite/esm/targets/targets.d.ts.map +1 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/plugins/c/libcurl/libcurl.d.ts +1 -1
- package/dist/plugins/c/libcurl/libcurl.d.ts.map +1 -1
- package/dist/plugins/c/libcurl/libcurl.js +3 -2
- package/dist/plugins/clojure/clj_http/clj_http.d.ts +1 -1
- package/dist/plugins/clojure/clj_http/clj_http.d.ts.map +1 -1
- package/dist/plugins/clojure/clj_http/clj_http.js +3 -2
- package/dist/plugins/csharp/httpclient/httpclient.d.ts +1 -1
- package/dist/plugins/csharp/httpclient/httpclient.d.ts.map +1 -1
- package/dist/plugins/csharp/httpclient/httpclient.js +3 -2
- package/dist/plugins/csharp/restsharp/restsharp.d.ts +1 -1
- package/dist/plugins/csharp/restsharp/restsharp.d.ts.map +1 -1
- package/dist/plugins/csharp/restsharp/restsharp.js +3 -2
- package/dist/plugins/go/native/native.d.ts +1 -1
- package/dist/plugins/go/native/native.d.ts.map +1 -1
- package/dist/plugins/go/native/native.js +3 -2
- package/dist/plugins/http/http11/http11.d.ts +1 -1
- package/dist/plugins/http/http11/http11.d.ts.map +1 -1
- package/dist/plugins/http/http11/http11.js +3 -2
- package/dist/plugins/java/asynchttp/asynchttp.d.ts +1 -1
- package/dist/plugins/java/asynchttp/asynchttp.d.ts.map +1 -1
- package/dist/plugins/java/asynchttp/asynchttp.js +3 -2
- package/dist/plugins/java/nethttp/nethttp.d.ts +1 -1
- package/dist/plugins/java/nethttp/nethttp.d.ts.map +1 -1
- package/dist/plugins/java/nethttp/nethttp.js +3 -2
- package/dist/plugins/java/okhttp/okhttp.d.ts +1 -1
- package/dist/plugins/java/okhttp/okhttp.d.ts.map +1 -1
- package/dist/plugins/java/okhttp/okhttp.js +3 -2
- package/dist/plugins/java/unirest/unirest.d.ts +1 -1
- package/dist/plugins/java/unirest/unirest.d.ts.map +1 -1
- package/dist/plugins/java/unirest/unirest.js +3 -2
- package/dist/plugins/js/axios/axios.d.ts +1 -1
- package/dist/plugins/js/axios/axios.d.ts.map +1 -1
- package/dist/plugins/js/axios/axios.js +3 -2
- package/dist/plugins/js/fetch/fetch.d.ts +1 -1
- package/dist/plugins/js/fetch/fetch.d.ts.map +1 -1
- package/dist/plugins/js/fetch/fetch.js +3 -2
- package/dist/plugins/js/jquery/jquery.d.ts +1 -1
- package/dist/plugins/js/jquery/jquery.d.ts.map +1 -1
- package/dist/plugins/js/jquery/jquery.js +3 -2
- package/dist/plugins/js/ofetch/ofetch.d.ts +1 -1
- package/dist/plugins/js/ofetch/ofetch.d.ts.map +1 -1
- package/dist/plugins/js/ofetch/ofetch.js +3 -2
- package/dist/plugins/js/xhr/xhr.d.ts +1 -1
- package/dist/plugins/js/xhr/xhr.d.ts.map +1 -1
- package/dist/plugins/js/xhr/xhr.js +3 -2
- package/dist/plugins/kotlin/okhttp/okhttp.d.ts +1 -1
- package/dist/plugins/kotlin/okhttp/okhttp.d.ts.map +1 -1
- package/dist/plugins/kotlin/okhttp/okhttp.js +3 -2
- package/dist/plugins/node/axios/axios.d.ts +1 -1
- package/dist/plugins/node/axios/axios.d.ts.map +1 -1
- package/dist/plugins/node/axios/axios.js +3 -2
- package/dist/plugins/node/fetch/fetch.d.ts +1 -1
- package/dist/plugins/node/fetch/fetch.d.ts.map +1 -1
- package/dist/plugins/node/fetch/fetch.js +3 -2
- package/dist/plugins/node/ofetch/ofetch.d.ts +1 -1
- package/dist/plugins/node/ofetch/ofetch.d.ts.map +1 -1
- package/dist/plugins/node/ofetch/ofetch.js +3 -2
- package/dist/plugins/node/undici/undici.d.ts +1 -1
- package/dist/plugins/node/undici/undici.d.ts.map +1 -1
- package/dist/plugins/node/undici/undici.js +3 -2
- package/dist/plugins/objc/nsurlsession/nsurlsession.d.ts +1 -1
- package/dist/plugins/objc/nsurlsession/nsurlsession.d.ts.map +1 -1
- package/dist/plugins/objc/nsurlsession/nsurlsession.js +3 -2
- package/dist/plugins/ocaml/cohttp/cohttp.d.ts +1 -1
- package/dist/plugins/ocaml/cohttp/cohttp.d.ts.map +1 -1
- package/dist/plugins/ocaml/cohttp/cohttp.js +3 -2
- package/dist/plugins/php/curl/curl.d.ts +1 -1
- package/dist/plugins/php/curl/curl.d.ts.map +1 -1
- package/dist/plugins/php/curl/curl.js +3 -2
- package/dist/plugins/php/guzzle/guzzle.d.ts +1 -1
- package/dist/plugins/php/guzzle/guzzle.d.ts.map +1 -1
- package/dist/plugins/php/guzzle/guzzle.js +3 -2
- package/dist/plugins/powershell/restmethod/restmethod.d.ts +1 -1
- package/dist/plugins/powershell/restmethod/restmethod.d.ts.map +1 -1
- package/dist/plugins/powershell/restmethod/restmethod.js +3 -2
- package/dist/plugins/powershell/webrequest/webrequest.d.ts +1 -1
- package/dist/plugins/powershell/webrequest/webrequest.d.ts.map +1 -1
- package/dist/plugins/powershell/webrequest/webrequest.js +3 -2
- package/dist/plugins/python/python3/python3.d.ts +1 -1
- package/dist/plugins/python/python3/python3.d.ts.map +1 -1
- package/dist/plugins/python/python3/python3.js +3 -2
- package/dist/plugins/python/requests/requests.d.ts +1 -1
- package/dist/plugins/python/requests/requests.d.ts.map +1 -1
- package/dist/plugins/python/requests/requests.js +3 -2
- package/dist/plugins/r/httr/httr.d.ts +1 -1
- package/dist/plugins/r/httr/httr.d.ts.map +1 -1
- package/dist/plugins/r/httr/httr.js +3 -2
- package/dist/plugins/ruby/native/native.d.ts +1 -1
- package/dist/plugins/ruby/native/native.d.ts.map +1 -1
- package/dist/plugins/ruby/native/native.js +3 -2
- package/dist/plugins/shell/curl/curl.d.ts +1 -1
- package/dist/plugins/shell/curl/curl.d.ts.map +1 -1
- package/dist/plugins/shell/curl/curl.js +1 -0
- package/dist/plugins/shell/httpie/httpie.d.ts +1 -1
- package/dist/plugins/shell/httpie/httpie.d.ts.map +1 -1
- package/dist/plugins/shell/httpie/httpie.js +3 -2
- package/dist/plugins/shell/wget/wget.d.ts +1 -1
- package/dist/plugins/shell/wget/wget.d.ts.map +1 -1
- package/dist/plugins/shell/wget/wget.js +3 -2
- package/dist/plugins/swift/nsurlsession/nsurlsession.d.ts +1 -1
- package/dist/plugins/swift/nsurlsession/nsurlsession.d.ts.map +1 -1
- package/dist/plugins/swift/nsurlsession/nsurlsession.js +3 -2
- package/dist/snippetz.d.ts +4 -6
- package/dist/snippetz.d.ts.map +1 -1
- package/dist/snippetz.js +10 -91
- package/dist/{core/types.d.ts → types/index.d.ts} +15 -4
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +1 -0
- package/dist/types/index.test-d.d.ts +2 -0
- package/dist/types/index.test-d.d.ts.map +1 -0
- package/dist/utils/arrayToObject.d.ts.map +1 -0
- package/dist/utils/convertWithHttpSnippetLite.d.ts +6 -0
- package/dist/utils/convertWithHttpSnippetLite.d.ts.map +1 -0
- package/dist/utils/convertWithHttpSnippetLite.js +95 -0
- package/dist/utils/index.d.ts +5 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +4 -0
- package/dist/utils/needsQuotes.d.ts.map +1 -0
- package/dist/utils/objectToString.d.ts.map +1 -0
- package/package.json +11 -7
- package/dist/core/index.d.ts +0 -5
- package/dist/core/index.d.ts.map +0 -1
- package/dist/core/index.js +0 -3
- package/dist/core/types.d.ts.map +0 -1
- package/dist/core/types.test-d.d.ts +0 -2
- package/dist/core/types.test-d.d.ts.map +0 -1
- package/dist/core/utils/arrayToObject.d.ts.map +0 -1
- package/dist/core/utils/convertWithHttpSnippetLite.d.ts +0 -7
- package/dist/core/utils/convertWithHttpSnippetLite.d.ts.map +0 -1
- package/dist/core/utils/convertWithHttpSnippetLite.js +0 -83
- package/dist/core/utils/needsQuotes.d.ts.map +0 -1
- package/dist/core/utils/objectToString.d.ts.map +0 -1
- /package/dist/{core/utils → utils}/arrayToObject.d.ts +0 -0
- /package/dist/{core/utils → utils}/arrayToObject.js +0 -0
- /package/dist/{core/utils → utils}/needsQuotes.d.ts +0 -0
- /package/dist/{core/utils → utils}/needsQuotes.js +0 -0
- /package/dist/{core/utils → utils}/objectToString.d.ts +0 -0
- /package/dist/{core/utils → utils}/objectToString.js +0 -0
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { CodeBuilder } from '../../../helpers/code-builder.js';
|
|
2
|
+
import { escapeForDoubleQuotes } from '../../../helpers/escape.js';
|
|
3
|
+
|
|
4
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
5
|
+
// @ts-nocheck
|
|
6
|
+
/**
|
|
7
|
+
* @description
|
|
8
|
+
* HTTP code snippet generator for native Python3.
|
|
9
|
+
*
|
|
10
|
+
* @author
|
|
11
|
+
* @montanaflynn
|
|
12
|
+
*
|
|
13
|
+
* for any questions or issues regarding the generated code snippet, please open an issue mentioning the author.
|
|
14
|
+
*/
|
|
15
|
+
const python3 = {
|
|
16
|
+
info: {
|
|
17
|
+
key: 'python3',
|
|
18
|
+
title: 'http.client',
|
|
19
|
+
link: 'https://docs.python.org/3/library/http.client.html',
|
|
20
|
+
description: 'Python3 HTTP Client',
|
|
21
|
+
},
|
|
22
|
+
convert: ({ uriObj: { path, protocol, host }, postData, allHeaders, method }, options = {}) => {
|
|
23
|
+
const { insecureSkipVerify = false } = options;
|
|
24
|
+
const { push, blank, join } = new CodeBuilder();
|
|
25
|
+
// Start Request
|
|
26
|
+
push('import http.client');
|
|
27
|
+
if (insecureSkipVerify) {
|
|
28
|
+
push('import ssl');
|
|
29
|
+
}
|
|
30
|
+
blank();
|
|
31
|
+
// Check which protocol to be used for the client connection
|
|
32
|
+
if (protocol === 'https:') {
|
|
33
|
+
const sslContext = insecureSkipVerify
|
|
34
|
+
? ', context = ssl._create_unverified_context()'
|
|
35
|
+
: '';
|
|
36
|
+
push(`conn = http.client.HTTPSConnection("${host}"${sslContext})`);
|
|
37
|
+
blank();
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
push(`conn = http.client.HTTPConnection("${host}")`);
|
|
41
|
+
blank();
|
|
42
|
+
}
|
|
43
|
+
// Create payload string if it exists
|
|
44
|
+
const payload = JSON.stringify(postData === null || postData === void 0 ? void 0 : postData.text);
|
|
45
|
+
if (payload) {
|
|
46
|
+
push(`payload = ${payload}`);
|
|
47
|
+
blank();
|
|
48
|
+
}
|
|
49
|
+
// Create Headers
|
|
50
|
+
const headers = allHeaders;
|
|
51
|
+
const headerCount = Object.keys(headers).length;
|
|
52
|
+
if (headerCount === 1) {
|
|
53
|
+
for (const header in headers) {
|
|
54
|
+
push(`headers = { '${header}': "${escapeForDoubleQuotes(headers[header])}" }`);
|
|
55
|
+
blank();
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
else if (headerCount > 1) {
|
|
59
|
+
let count = 1;
|
|
60
|
+
push('headers = {');
|
|
61
|
+
for (const header in headers) {
|
|
62
|
+
if (count++ !== headerCount) {
|
|
63
|
+
push(` '${header}': "${escapeForDoubleQuotes(headers[header])}",`);
|
|
64
|
+
}
|
|
65
|
+
else {
|
|
66
|
+
push(` '${header}': "${escapeForDoubleQuotes(headers[header])}"`);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
push('}');
|
|
70
|
+
blank();
|
|
71
|
+
}
|
|
72
|
+
// Make Request
|
|
73
|
+
if (payload && headerCount) {
|
|
74
|
+
push(`conn.request("${method}", "${path}", payload, headers)`);
|
|
75
|
+
}
|
|
76
|
+
else if (payload && !headerCount) {
|
|
77
|
+
push(`conn.request("${method}", "${path}", payload)`);
|
|
78
|
+
}
|
|
79
|
+
else if (!payload && headerCount) {
|
|
80
|
+
push(`conn.request("${method}", "${path}", headers=headers)`);
|
|
81
|
+
}
|
|
82
|
+
else {
|
|
83
|
+
push(`conn.request("${method}", "${path}")`);
|
|
84
|
+
}
|
|
85
|
+
// Get Response
|
|
86
|
+
blank();
|
|
87
|
+
push('res = conn.getresponse()');
|
|
88
|
+
push('data = res.read()');
|
|
89
|
+
blank();
|
|
90
|
+
push('print(data.decode("utf-8"))');
|
|
91
|
+
return join();
|
|
92
|
+
},
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
export { python3 };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export declare const requests: {
|
|
2
|
+
info: {
|
|
3
|
+
key: string;
|
|
4
|
+
title: string;
|
|
5
|
+
link: string;
|
|
6
|
+
description: string;
|
|
7
|
+
};
|
|
8
|
+
convert: ({ queryObj, url, postData, allHeaders, method }: {
|
|
9
|
+
queryObj: any;
|
|
10
|
+
url: any;
|
|
11
|
+
postData: any;
|
|
12
|
+
allHeaders: any;
|
|
13
|
+
method: any;
|
|
14
|
+
}, options: any) => any;
|
|
15
|
+
};
|
|
16
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../../../../../src/httpsnippet-lite/esm/targets/python/requests/client.ts"],"names":[],"mappings":"AAyBA,eAAO,MAAM,QAAQ;;;;;;;;;;;;;;CAqJpB,CAAA"}
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
import { CodeBuilder } from '../../../helpers/code-builder.js';
|
|
2
|
+
import { escapeForDoubleQuotes } from '../../../helpers/escape.js';
|
|
3
|
+
import { getHeaderName } from '../../../helpers/headers.js';
|
|
4
|
+
import { literalRepresentation } from '../helpers.js';
|
|
5
|
+
|
|
6
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
7
|
+
// @ts-nocheck
|
|
8
|
+
/**
|
|
9
|
+
* @description
|
|
10
|
+
* HTTP code snippet generator for Python using Requests
|
|
11
|
+
*
|
|
12
|
+
* @author
|
|
13
|
+
* @montanaflynn
|
|
14
|
+
*
|
|
15
|
+
* for any questions or issues regarding the generated code snippet, please open an issue mentioning the author.
|
|
16
|
+
*/
|
|
17
|
+
const builtInMethods = [
|
|
18
|
+
'HEAD',
|
|
19
|
+
'GET',
|
|
20
|
+
'POST',
|
|
21
|
+
'PUT',
|
|
22
|
+
'PATCH',
|
|
23
|
+
'DELETE',
|
|
24
|
+
'OPTIONS',
|
|
25
|
+
];
|
|
26
|
+
const requests = {
|
|
27
|
+
info: {
|
|
28
|
+
key: 'requests',
|
|
29
|
+
title: 'Requests',
|
|
30
|
+
link: 'http://docs.python-requests.org/en/latest/api/#requests.request',
|
|
31
|
+
description: 'Requests HTTP library',
|
|
32
|
+
},
|
|
33
|
+
convert: ({ queryObj, url, postData, allHeaders, method }, options) => {
|
|
34
|
+
const opts = {
|
|
35
|
+
indent: ' ',
|
|
36
|
+
pretty: true,
|
|
37
|
+
...options,
|
|
38
|
+
};
|
|
39
|
+
// Start snippet
|
|
40
|
+
const { push, blank, join } = new CodeBuilder({ indent: opts.indent });
|
|
41
|
+
// Import requests
|
|
42
|
+
push('import requests');
|
|
43
|
+
blank();
|
|
44
|
+
// Set URL
|
|
45
|
+
push(`url = "${url}"`);
|
|
46
|
+
blank();
|
|
47
|
+
// Construct query string
|
|
48
|
+
let qs;
|
|
49
|
+
if (Object.keys(queryObj).length) {
|
|
50
|
+
qs = `querystring = ${JSON.stringify(queryObj)}`;
|
|
51
|
+
push(qs);
|
|
52
|
+
blank();
|
|
53
|
+
}
|
|
54
|
+
const headers = allHeaders;
|
|
55
|
+
// Construct payload
|
|
56
|
+
let payload = {};
|
|
57
|
+
const files = {};
|
|
58
|
+
let hasFiles = false;
|
|
59
|
+
let hasPayload = false;
|
|
60
|
+
let jsonPayload = false;
|
|
61
|
+
switch (postData === null || postData === void 0 ? void 0 : postData.mimeType) {
|
|
62
|
+
case 'application/json':
|
|
63
|
+
if (postData.jsonObj) {
|
|
64
|
+
push(`payload = ${literalRepresentation(postData.jsonObj, opts)}`);
|
|
65
|
+
jsonPayload = true;
|
|
66
|
+
hasPayload = true;
|
|
67
|
+
}
|
|
68
|
+
break;
|
|
69
|
+
case 'multipart/form-data':
|
|
70
|
+
if (!postData.params) {
|
|
71
|
+
break;
|
|
72
|
+
}
|
|
73
|
+
payload = {};
|
|
74
|
+
postData.params.forEach((p) => {
|
|
75
|
+
if (p.fileName) {
|
|
76
|
+
files[p.name] = `open('${p.fileName}', 'rb')`;
|
|
77
|
+
hasFiles = true;
|
|
78
|
+
}
|
|
79
|
+
else {
|
|
80
|
+
payload[p.name] = p.value;
|
|
81
|
+
hasPayload = true;
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
if (hasFiles) {
|
|
85
|
+
push(`files = ${literalRepresentation(files, opts)}`);
|
|
86
|
+
if (hasPayload) {
|
|
87
|
+
push(`payload = ${literalRepresentation(payload, opts)}`);
|
|
88
|
+
}
|
|
89
|
+
// The requests library will only automatically add a `multipart/form-data` header if there are files being sent. If we're **only** sending form data we still need to send the boundary ourselves.
|
|
90
|
+
const headerName = getHeaderName(headers, 'content-type');
|
|
91
|
+
if (headerName) {
|
|
92
|
+
delete headers[headerName];
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
else {
|
|
96
|
+
const nonFilePayload = JSON.stringify(postData.text);
|
|
97
|
+
if (nonFilePayload) {
|
|
98
|
+
push(`payload = ${nonFilePayload}`);
|
|
99
|
+
hasPayload = true;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
break;
|
|
103
|
+
default: {
|
|
104
|
+
if (!postData) {
|
|
105
|
+
break;
|
|
106
|
+
}
|
|
107
|
+
if (postData.mimeType === 'application/x-www-form-urlencoded' &&
|
|
108
|
+
postData.paramsObj) {
|
|
109
|
+
push(`payload = ${literalRepresentation(postData.paramsObj, opts)}`);
|
|
110
|
+
hasPayload = true;
|
|
111
|
+
break;
|
|
112
|
+
}
|
|
113
|
+
const payload = JSON.stringify(postData.text);
|
|
114
|
+
if (payload) {
|
|
115
|
+
push(`payload = ${payload}`);
|
|
116
|
+
hasPayload = true;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
// Construct headers
|
|
121
|
+
const headerCount = Object.keys(headers).length;
|
|
122
|
+
if (headerCount === 0 && (hasPayload || hasFiles)) {
|
|
123
|
+
// If we don't have any heads but we do have a payload we should put a blank line here between that payload consturction and our execution of the requests library.
|
|
124
|
+
blank();
|
|
125
|
+
}
|
|
126
|
+
else if (headerCount === 1) {
|
|
127
|
+
for (const header in headers) {
|
|
128
|
+
push(`headers = {"${header}": "${escapeForDoubleQuotes(headers[header])}"}`);
|
|
129
|
+
blank();
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
else if (headerCount > 1) {
|
|
133
|
+
let count = 1;
|
|
134
|
+
push('headers = {');
|
|
135
|
+
for (const header in headers) {
|
|
136
|
+
if (count !== headerCount) {
|
|
137
|
+
push(`"${header}": "${escapeForDoubleQuotes(headers[header])}",`, 1);
|
|
138
|
+
}
|
|
139
|
+
else {
|
|
140
|
+
push(`"${header}": "${escapeForDoubleQuotes(headers[header])}"`, 1);
|
|
141
|
+
}
|
|
142
|
+
count += 1;
|
|
143
|
+
}
|
|
144
|
+
push('}');
|
|
145
|
+
blank();
|
|
146
|
+
}
|
|
147
|
+
// Construct request
|
|
148
|
+
let request = builtInMethods.includes(method)
|
|
149
|
+
? `response = requests.${method.toLowerCase()}(url`
|
|
150
|
+
: `response = requests.request("${method}", url`;
|
|
151
|
+
if (hasPayload) {
|
|
152
|
+
if (jsonPayload) {
|
|
153
|
+
request += ', json=payload';
|
|
154
|
+
}
|
|
155
|
+
else {
|
|
156
|
+
request += ', data=payload';
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
if (hasFiles) {
|
|
160
|
+
request += ', files=files';
|
|
161
|
+
}
|
|
162
|
+
if (headerCount > 0) {
|
|
163
|
+
request += ', headers=headers';
|
|
164
|
+
}
|
|
165
|
+
if (qs) {
|
|
166
|
+
request += ', params=querystring';
|
|
167
|
+
}
|
|
168
|
+
request += ')';
|
|
169
|
+
push(request);
|
|
170
|
+
blank();
|
|
171
|
+
// Print response
|
|
172
|
+
push('print(response.json())');
|
|
173
|
+
return join();
|
|
174
|
+
},
|
|
175
|
+
};
|
|
176
|
+
|
|
177
|
+
export { requests };
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
export declare const python: {
|
|
2
|
+
info: {
|
|
3
|
+
key: string;
|
|
4
|
+
title: string;
|
|
5
|
+
extname: string;
|
|
6
|
+
default: string;
|
|
7
|
+
};
|
|
8
|
+
clientsById: {
|
|
9
|
+
python3: {
|
|
10
|
+
info: {
|
|
11
|
+
key: string;
|
|
12
|
+
title: string;
|
|
13
|
+
link: string;
|
|
14
|
+
description: string;
|
|
15
|
+
};
|
|
16
|
+
convert: ({ uriObj: { path, protocol, host }, postData, allHeaders, method }: {
|
|
17
|
+
uriObj: {
|
|
18
|
+
path: any;
|
|
19
|
+
protocol: any;
|
|
20
|
+
host: any;
|
|
21
|
+
};
|
|
22
|
+
postData: any;
|
|
23
|
+
allHeaders: any;
|
|
24
|
+
method: any;
|
|
25
|
+
}, options?: {}) => any;
|
|
26
|
+
};
|
|
27
|
+
requests: {
|
|
28
|
+
info: {
|
|
29
|
+
key: string;
|
|
30
|
+
title: string;
|
|
31
|
+
link: string;
|
|
32
|
+
description: string;
|
|
33
|
+
};
|
|
34
|
+
convert: ({ queryObj, url, postData, allHeaders, method }: {
|
|
35
|
+
queryObj: any;
|
|
36
|
+
url: any;
|
|
37
|
+
postData: any;
|
|
38
|
+
allHeaders: any;
|
|
39
|
+
method: any;
|
|
40
|
+
}, options: any) => any;
|
|
41
|
+
};
|
|
42
|
+
};
|
|
43
|
+
};
|
|
44
|
+
//# sourceMappingURL=target.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"target.d.ts","sourceRoot":"","sources":["../../../../../src/httpsnippet-lite/esm/targets/python/target.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAWlB,CAAA"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export declare const httr: {
|
|
2
|
+
info: {
|
|
3
|
+
key: string;
|
|
4
|
+
title: string;
|
|
5
|
+
link: string;
|
|
6
|
+
description: string;
|
|
7
|
+
};
|
|
8
|
+
convert: ({ url, queryObj, queryString, postData, allHeaders, method }: {
|
|
9
|
+
url: any;
|
|
10
|
+
queryObj: any;
|
|
11
|
+
queryString: any;
|
|
12
|
+
postData: any;
|
|
13
|
+
allHeaders: any;
|
|
14
|
+
method: any;
|
|
15
|
+
}, options?: {}) => any;
|
|
16
|
+
};
|
|
17
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../../../../../src/httpsnippet-lite/esm/targets/r/httr/client.ts"],"names":[],"mappings":"AAkBA,eAAO,MAAM,IAAI;;;;;;;;;;;;;;;CAoHhB,CAAA"}
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import { CodeBuilder } from '../../../helpers/code-builder.js';
|
|
2
|
+
import { escapeForDoubleQuotes, escapeForSingleQuotes } from '../../../helpers/escape.js';
|
|
3
|
+
import { getHeader } from '../../../helpers/headers.js';
|
|
4
|
+
|
|
5
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
6
|
+
// @ts-nocheck
|
|
7
|
+
/**
|
|
8
|
+
* @description
|
|
9
|
+
* HTTP code snippet generator for R using httr
|
|
10
|
+
*
|
|
11
|
+
* @author
|
|
12
|
+
* @gabrielakoreeda
|
|
13
|
+
*
|
|
14
|
+
* for any questions or issues regarding the generated code snippet, please open an issue mentioning the author.
|
|
15
|
+
*/
|
|
16
|
+
const httr = {
|
|
17
|
+
info: {
|
|
18
|
+
key: 'httr',
|
|
19
|
+
title: 'httr',
|
|
20
|
+
link: 'https://cran.r-project.org/web/packages/httr/vignettes/quickstart.html',
|
|
21
|
+
description: 'httr: Tools for Working with URLs and HTTP',
|
|
22
|
+
},
|
|
23
|
+
convert: ({ url, queryObj, queryString, postData, allHeaders, method }, options = {}) => {
|
|
24
|
+
let _a, _b;
|
|
25
|
+
// Start snippet
|
|
26
|
+
const { push, blank, join } = new CodeBuilder({
|
|
27
|
+
indent: (_a = options.indent) !== null && _a !== void 0 ? _a : ' ',
|
|
28
|
+
});
|
|
29
|
+
// Import httr
|
|
30
|
+
push('library(httr)');
|
|
31
|
+
blank();
|
|
32
|
+
// Set URL
|
|
33
|
+
push(`url <- "${url}"`);
|
|
34
|
+
blank();
|
|
35
|
+
// Construct query string
|
|
36
|
+
const qs = queryObj;
|
|
37
|
+
delete queryObj.key;
|
|
38
|
+
const entries = Object.entries(qs);
|
|
39
|
+
const entriesCount = entries.length;
|
|
40
|
+
if (entriesCount === 1) {
|
|
41
|
+
const entry = entries[0];
|
|
42
|
+
push(`queryString <- list(${entry[0]} = "${entry[1]}")`);
|
|
43
|
+
blank();
|
|
44
|
+
}
|
|
45
|
+
else if (entriesCount > 1) {
|
|
46
|
+
push('queryString <- list(');
|
|
47
|
+
entries.forEach(([key, value], i) => {
|
|
48
|
+
const isLastItem = i !== entriesCount - 1;
|
|
49
|
+
const maybeComma = isLastItem ? ',' : '';
|
|
50
|
+
push(`${key} = "${value}"${maybeComma}`, 1);
|
|
51
|
+
});
|
|
52
|
+
push(')');
|
|
53
|
+
blank();
|
|
54
|
+
}
|
|
55
|
+
// Construct payload
|
|
56
|
+
const payload = JSON.stringify(postData === null || postData === void 0 ? void 0 : postData.text);
|
|
57
|
+
if (payload) {
|
|
58
|
+
push(`payload <- ${payload}`);
|
|
59
|
+
blank();
|
|
60
|
+
}
|
|
61
|
+
// Define encode
|
|
62
|
+
if (postData && (postData.text || postData.jsonObj || postData.params)) {
|
|
63
|
+
switch (postData.mimeType) {
|
|
64
|
+
case 'application/x-www-form-urlencoded':
|
|
65
|
+
push('encode <- "form"');
|
|
66
|
+
blank();
|
|
67
|
+
break;
|
|
68
|
+
case 'application/json':
|
|
69
|
+
push('encode <- "json"');
|
|
70
|
+
blank();
|
|
71
|
+
break;
|
|
72
|
+
case 'multipart/form-data':
|
|
73
|
+
push('encode <- "multipart"');
|
|
74
|
+
blank();
|
|
75
|
+
break;
|
|
76
|
+
default:
|
|
77
|
+
push('encode <- "raw"');
|
|
78
|
+
blank();
|
|
79
|
+
break;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
// Construct headers
|
|
83
|
+
const cookieHeader = getHeader(allHeaders, 'cookie');
|
|
84
|
+
const acceptHeader = getHeader(allHeaders, 'accept');
|
|
85
|
+
const setCookies = cookieHeader
|
|
86
|
+
? `set_cookies(\`${String(cookieHeader)
|
|
87
|
+
.replace(/;/g, '", `')
|
|
88
|
+
.replace(/` /g, '`')
|
|
89
|
+
.replace(/[=]/g, '` = "')}")`
|
|
90
|
+
: undefined;
|
|
91
|
+
const setAccept = acceptHeader
|
|
92
|
+
? `accept("${escapeForDoubleQuotes(acceptHeader)}")`
|
|
93
|
+
: undefined;
|
|
94
|
+
const setContentType = `content_type("${escapeForDoubleQuotes((_b = postData === null || postData === void 0 ? void 0 : postData.mimeType) !== null && _b !== void 0 ? _b : 'application/octet-stream')}")`;
|
|
95
|
+
const otherHeaders = Object.entries(allHeaders)
|
|
96
|
+
// These headers are all handled separately:
|
|
97
|
+
.filter(([key]) => !['cookie', 'accept', 'content-type'].includes(key.toLowerCase()))
|
|
98
|
+
.map(([key, value]) => `'${key}' = '${escapeForSingleQuotes(value)}'`)
|
|
99
|
+
.join(', ');
|
|
100
|
+
const setHeaders = otherHeaders ? `add_headers(${otherHeaders})` : undefined;
|
|
101
|
+
// Construct request
|
|
102
|
+
let request = `response <- VERB("${method}", url`;
|
|
103
|
+
if (payload) {
|
|
104
|
+
request += ', body = payload';
|
|
105
|
+
}
|
|
106
|
+
if (queryString.length) {
|
|
107
|
+
request += ', query = queryString';
|
|
108
|
+
}
|
|
109
|
+
const headerAdditions = [setHeaders, setContentType, setAccept, setCookies]
|
|
110
|
+
.filter((x) => !!x)
|
|
111
|
+
.join(', ');
|
|
112
|
+
if (headerAdditions) {
|
|
113
|
+
request += `, ${headerAdditions}`;
|
|
114
|
+
}
|
|
115
|
+
if (postData && (postData.text || postData.jsonObj || postData.params)) {
|
|
116
|
+
request += ', encode = encode';
|
|
117
|
+
}
|
|
118
|
+
request += ')';
|
|
119
|
+
push(request);
|
|
120
|
+
blank();
|
|
121
|
+
// Print response
|
|
122
|
+
push('content(response, "text")');
|
|
123
|
+
return join();
|
|
124
|
+
},
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
export { httr };
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export declare const r: {
|
|
2
|
+
info: {
|
|
3
|
+
key: string;
|
|
4
|
+
title: string;
|
|
5
|
+
extname: string;
|
|
6
|
+
default: string;
|
|
7
|
+
};
|
|
8
|
+
clientsById: {
|
|
9
|
+
httr: {
|
|
10
|
+
info: {
|
|
11
|
+
key: string;
|
|
12
|
+
title: string;
|
|
13
|
+
link: string;
|
|
14
|
+
description: string;
|
|
15
|
+
};
|
|
16
|
+
convert: ({ url, queryObj, queryString, postData, allHeaders, method }: {
|
|
17
|
+
url: any;
|
|
18
|
+
queryObj: any;
|
|
19
|
+
queryString: any;
|
|
20
|
+
postData: any;
|
|
21
|
+
allHeaders: any;
|
|
22
|
+
method: any;
|
|
23
|
+
}, options?: {}) => any;
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
//# sourceMappingURL=target.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"target.d.ts","sourceRoot":"","sources":["../../../../../src/httpsnippet-lite/esm/targets/r/target.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;CAUb,CAAA"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export declare const native: {
|
|
2
|
+
info: {
|
|
3
|
+
key: string;
|
|
4
|
+
title: string;
|
|
5
|
+
link: string;
|
|
6
|
+
description: string;
|
|
7
|
+
};
|
|
8
|
+
convert: ({ uriObj, method: rawMethod, fullUrl, postData, allHeaders }: {
|
|
9
|
+
uriObj: any;
|
|
10
|
+
method: any;
|
|
11
|
+
fullUrl: any;
|
|
12
|
+
postData: any;
|
|
13
|
+
allHeaders: any;
|
|
14
|
+
}, options?: {}) => any;
|
|
15
|
+
};
|
|
16
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../../../../../src/httpsnippet-lite/esm/targets/ruby/native/client.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,MAAM;;;;;;;;;;;;;;CAqElB,CAAA"}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { CodeBuilder } from '../../../helpers/code-builder.js';
|
|
2
|
+
import { escapeForSingleQuotes } from '../../../helpers/escape.js';
|
|
3
|
+
|
|
4
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
5
|
+
// @ts-nocheck
|
|
6
|
+
const native = {
|
|
7
|
+
info: {
|
|
8
|
+
key: 'native',
|
|
9
|
+
title: 'net::http',
|
|
10
|
+
link: 'http://ruby-doc.org/stdlib-2.2.1/libdoc/net/http/rdoc/Net/HTTP.html',
|
|
11
|
+
description: 'Ruby HTTP client',
|
|
12
|
+
},
|
|
13
|
+
convert: ({ uriObj, method: rawMethod, fullUrl, postData, allHeaders }, options = {}) => {
|
|
14
|
+
const { insecureSkipVerify = false } = options;
|
|
15
|
+
const { push, blank, join } = new CodeBuilder();
|
|
16
|
+
push("require 'uri'");
|
|
17
|
+
push("require 'net/http'");
|
|
18
|
+
blank();
|
|
19
|
+
// To support custom methods we check for the supported methods
|
|
20
|
+
// and if doesn't exist then we build a custom class for it
|
|
21
|
+
const method = rawMethod.toUpperCase();
|
|
22
|
+
const methods = [
|
|
23
|
+
'GET',
|
|
24
|
+
'POST',
|
|
25
|
+
'HEAD',
|
|
26
|
+
'DELETE',
|
|
27
|
+
'PATCH',
|
|
28
|
+
'PUT',
|
|
29
|
+
'OPTIONS',
|
|
30
|
+
'COPY',
|
|
31
|
+
'LOCK',
|
|
32
|
+
'UNLOCK',
|
|
33
|
+
'MOVE',
|
|
34
|
+
'TRACE',
|
|
35
|
+
];
|
|
36
|
+
const capMethod = method.charAt(0) + method.substring(1).toLowerCase();
|
|
37
|
+
if (!methods.includes(method)) {
|
|
38
|
+
push(`class Net::HTTP::${capMethod} < Net::HTTPRequest`);
|
|
39
|
+
push(` METHOD = '${method.toUpperCase()}'`);
|
|
40
|
+
push(` REQUEST_HAS_BODY = '${(postData === null || postData === void 0 ? void 0 : postData.text) ? 'true' : 'false'}'`);
|
|
41
|
+
push(' RESPONSE_HAS_BODY = true');
|
|
42
|
+
push('end');
|
|
43
|
+
blank();
|
|
44
|
+
}
|
|
45
|
+
push(`url = URI("${fullUrl}")`);
|
|
46
|
+
blank();
|
|
47
|
+
push('http = Net::HTTP.new(url.host, url.port)');
|
|
48
|
+
if (uriObj.protocol === 'https:') {
|
|
49
|
+
push('http.use_ssl = true');
|
|
50
|
+
if (insecureSkipVerify) {
|
|
51
|
+
push('http.verify_mode = OpenSSL::SSL::VERIFY_NONE');
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
blank();
|
|
55
|
+
push(`request = Net::HTTP::${capMethod}.new(url)`);
|
|
56
|
+
const headers = Object.keys(allHeaders);
|
|
57
|
+
if (headers.length) {
|
|
58
|
+
headers.forEach((key) => {
|
|
59
|
+
push(`request["${key}"] = '${escapeForSingleQuotes(allHeaders[key])}'`);
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
if (postData === null || postData === void 0 ? void 0 : postData.text) {
|
|
63
|
+
push(`request.body = ${JSON.stringify(postData.text)}`);
|
|
64
|
+
}
|
|
65
|
+
blank();
|
|
66
|
+
push('response = http.request(request)');
|
|
67
|
+
push('puts response.read_body');
|
|
68
|
+
return join();
|
|
69
|
+
},
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
export { native };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export declare const ruby: {
|
|
2
|
+
info: {
|
|
3
|
+
key: string;
|
|
4
|
+
title: string;
|
|
5
|
+
extname: string;
|
|
6
|
+
default: string;
|
|
7
|
+
};
|
|
8
|
+
clientsById: {
|
|
9
|
+
native: {
|
|
10
|
+
info: {
|
|
11
|
+
key: string;
|
|
12
|
+
title: string;
|
|
13
|
+
link: string;
|
|
14
|
+
description: string;
|
|
15
|
+
};
|
|
16
|
+
convert: ({ uriObj, method: rawMethod, fullUrl, postData, allHeaders }: {
|
|
17
|
+
uriObj: any;
|
|
18
|
+
method: any;
|
|
19
|
+
fullUrl: any;
|
|
20
|
+
postData: any;
|
|
21
|
+
allHeaders: any;
|
|
22
|
+
}, options?: {}) => any;
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
//# sourceMappingURL=target.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"target.d.ts","sourceRoot":"","sources":["../../../../../src/httpsnippet-lite/esm/targets/ruby/target.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,IAAI;;;;;;;;;;;;;;;;;;;;;;;;CAUhB,CAAA"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export declare const curl: {
|
|
2
|
+
info: {
|
|
3
|
+
key: string;
|
|
4
|
+
title: string;
|
|
5
|
+
link: string;
|
|
6
|
+
description: string;
|
|
7
|
+
};
|
|
8
|
+
convert: ({ fullUrl, method, httpVersion, headersObj, allHeaders, postData }: {
|
|
9
|
+
fullUrl: any;
|
|
10
|
+
method: any;
|
|
11
|
+
httpVersion: any;
|
|
12
|
+
headersObj: any;
|
|
13
|
+
allHeaders: any;
|
|
14
|
+
postData: any;
|
|
15
|
+
}, options?: {}) => any;
|
|
16
|
+
};
|
|
17
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../../../../../src/httpsnippet-lite/esm/targets/shell/curl/client.ts"],"names":[],"mappings":"AA4CA,eAAO,MAAM,IAAI;;;;;;;;;;;;;;;CAsJhB,CAAA"}
|