@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,17 @@
|
|
|
1
|
+
export declare const unirest: {
|
|
2
|
+
info: {
|
|
3
|
+
key: string;
|
|
4
|
+
title: string;
|
|
5
|
+
link: string;
|
|
6
|
+
description: string;
|
|
7
|
+
};
|
|
8
|
+
convert: ({ method, url, cookies, queryObj, postData, headersObj }: {
|
|
9
|
+
method: any;
|
|
10
|
+
url: any;
|
|
11
|
+
cookies: any;
|
|
12
|
+
queryObj: any;
|
|
13
|
+
postData: any;
|
|
14
|
+
headersObj: any;
|
|
15
|
+
}, options: any) => 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/node/unirest/client.ts"],"names":[],"mappings":"AAeA,eAAO,MAAM,OAAO;;;;;;;;;;;;;;;CAiHnB,CAAA"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Create a string corresponding to a valid declaration and initialization of an Objective-C object literal.
|
|
3
|
+
*
|
|
4
|
+
* @param nsClass Class of the litteral
|
|
5
|
+
* @param name Desired name of the instance
|
|
6
|
+
* @param parameters Key-value object of parameters to translate to an Objective-C object litearal
|
|
7
|
+
* @param indent If true, will declare the litteral by indenting each new key/value pair.
|
|
8
|
+
* @return A valid Objective-C declaration and initialization of an Objective-C object litteral.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* nsDeclaration('NSDictionary', 'params', {a: 'b', c: 'd'}, true)
|
|
12
|
+
* // returns:
|
|
13
|
+
* NSDictionary *params = @{ @"a": @"b",
|
|
14
|
+
* @"c": @"d" };
|
|
15
|
+
*
|
|
16
|
+
* nsDeclaration('NSDictionary', 'params', {a: 'b', c: 'd'})
|
|
17
|
+
* // returns:
|
|
18
|
+
* NSDictionary *params = @{ @"a": @"b", @"c": @"d" };
|
|
19
|
+
*/
|
|
20
|
+
export declare const nsDeclaration: (nsClass: any, name: any, parameters: any, indent: any) => string;
|
|
21
|
+
/**
|
|
22
|
+
* Create a valid Objective-C string of a literal value according to its type.
|
|
23
|
+
*
|
|
24
|
+
* @param value Any JavaScript literal
|
|
25
|
+
*/
|
|
26
|
+
export declare const literalRepresentation: (value: any, indentation: any) => any;
|
|
27
|
+
//# sourceMappingURL=helpers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../../../../src/httpsnippet-lite/esm/targets/objc/helpers.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,aAAa,mEAOzB,CAAA;AACD;;;;GAIG;AACH,eAAO,MAAM,qBAAqB,uCA2BjC,CAAA"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
2
|
+
// @ts-nocheck
|
|
3
|
+
/**
|
|
4
|
+
* Create a string corresponding to a valid declaration and initialization of an Objective-C object literal.
|
|
5
|
+
*
|
|
6
|
+
* @param nsClass Class of the litteral
|
|
7
|
+
* @param name Desired name of the instance
|
|
8
|
+
* @param parameters Key-value object of parameters to translate to an Objective-C object litearal
|
|
9
|
+
* @param indent If true, will declare the litteral by indenting each new key/value pair.
|
|
10
|
+
* @return A valid Objective-C declaration and initialization of an Objective-C object litteral.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* nsDeclaration('NSDictionary', 'params', {a: 'b', c: 'd'}, true)
|
|
14
|
+
* // returns:
|
|
15
|
+
* NSDictionary *params = @{ @"a": @"b",
|
|
16
|
+
* @"c": @"d" };
|
|
17
|
+
*
|
|
18
|
+
* nsDeclaration('NSDictionary', 'params', {a: 'b', c: 'd'})
|
|
19
|
+
* // returns:
|
|
20
|
+
* NSDictionary *params = @{ @"a": @"b", @"c": @"d" };
|
|
21
|
+
*/
|
|
22
|
+
const nsDeclaration = (nsClass, name, parameters, indent) => {
|
|
23
|
+
const opening = `${nsClass} *${name} = `;
|
|
24
|
+
const literal = literalRepresentation(parameters, indent ? opening.length : undefined);
|
|
25
|
+
return `${opening}${literal};`;
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* Create a valid Objective-C string of a literal value according to its type.
|
|
29
|
+
*
|
|
30
|
+
* @param value Any JavaScript literal
|
|
31
|
+
*/
|
|
32
|
+
const literalRepresentation = (value, indentation) => {
|
|
33
|
+
const join = indentation === undefined ? ', ' : `,\n ${' '.repeat(indentation)}`;
|
|
34
|
+
switch (Object.prototype.toString.call(value)) {
|
|
35
|
+
case '[object Number]':
|
|
36
|
+
return `@${value}`;
|
|
37
|
+
case '[object Array]': {
|
|
38
|
+
const valuesRepresentation = value.map((value) => literalRepresentation(value));
|
|
39
|
+
return `@[ ${valuesRepresentation.join(join)} ]`;
|
|
40
|
+
}
|
|
41
|
+
case '[object Object]': {
|
|
42
|
+
const keyValuePairs = [];
|
|
43
|
+
for (const key in value) {
|
|
44
|
+
keyValuePairs.push(`@"${key}": ${literalRepresentation(value[key])}`);
|
|
45
|
+
}
|
|
46
|
+
return `@{ ${keyValuePairs.join(join)} }`;
|
|
47
|
+
}
|
|
48
|
+
case '[object Boolean]':
|
|
49
|
+
return value ? '@YES' : '@NO';
|
|
50
|
+
default:
|
|
51
|
+
if (value === null || value === undefined) {
|
|
52
|
+
return '';
|
|
53
|
+
}
|
|
54
|
+
return `@"${value.toString().replace(/"/g, '\\"')}"`;
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
export { literalRepresentation, nsDeclaration };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export declare const nsurlsession: {
|
|
2
|
+
info: {
|
|
3
|
+
key: string;
|
|
4
|
+
title: string;
|
|
5
|
+
link: string;
|
|
6
|
+
description: string;
|
|
7
|
+
};
|
|
8
|
+
convert: ({ allHeaders, postData, method, fullUrl }: {
|
|
9
|
+
allHeaders: any;
|
|
10
|
+
postData: any;
|
|
11
|
+
method: any;
|
|
12
|
+
fullUrl: any;
|
|
13
|
+
}, options: any) => any;
|
|
14
|
+
};
|
|
15
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../../../../../src/httpsnippet-lite/esm/targets/objc/nsurlsession/client.ts"],"names":[],"mappings":"AAcA,eAAO,MAAM,YAAY;;;;;;;;;;;;;CAwKxB,CAAA"}
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import { CodeBuilder } from '../../../helpers/code-builder.js';
|
|
2
|
+
import { nsDeclaration } from '../helpers.js';
|
|
3
|
+
|
|
4
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
5
|
+
// @ts-nocheck
|
|
6
|
+
/**
|
|
7
|
+
* @description
|
|
8
|
+
* HTTP code snippet generator for Objective-C using NSURLSession.
|
|
9
|
+
*
|
|
10
|
+
* @author
|
|
11
|
+
* @thibaultCha
|
|
12
|
+
*
|
|
13
|
+
* for any questions or issues regarding the generated code snippet, please open an issue mentioning the author.
|
|
14
|
+
*/
|
|
15
|
+
const nsurlsession = {
|
|
16
|
+
info: {
|
|
17
|
+
key: 'nsurlsession',
|
|
18
|
+
title: 'NSURLSession',
|
|
19
|
+
link: 'https://developer.apple.com/library/mac/documentation/Foundation/Reference/NSURLSession_class/index.html',
|
|
20
|
+
description: "Foundation's NSURLSession request",
|
|
21
|
+
},
|
|
22
|
+
convert: ({ allHeaders, postData, method, fullUrl }, options) => {
|
|
23
|
+
let _a;
|
|
24
|
+
const opts = {
|
|
25
|
+
indent: ' ',
|
|
26
|
+
pretty: true,
|
|
27
|
+
timeout: 10,
|
|
28
|
+
...options,
|
|
29
|
+
};
|
|
30
|
+
const { push, join, blank } = new CodeBuilder({ indent: opts.indent });
|
|
31
|
+
// Markers for headers to be created as literal objects and later be set on the NSURLRequest if exist
|
|
32
|
+
const req = {
|
|
33
|
+
hasHeaders: false,
|
|
34
|
+
hasBody: false,
|
|
35
|
+
};
|
|
36
|
+
// We just want to make sure people understand that is the only dependency
|
|
37
|
+
push('#import <Foundation/Foundation.h>');
|
|
38
|
+
if (Object.keys(allHeaders).length) {
|
|
39
|
+
req.hasHeaders = true;
|
|
40
|
+
blank();
|
|
41
|
+
push(nsDeclaration('NSDictionary', 'headers', allHeaders, opts.pretty));
|
|
42
|
+
}
|
|
43
|
+
if (postData && (postData.text || postData.jsonObj || postData.params)) {
|
|
44
|
+
req.hasBody = true;
|
|
45
|
+
switch (postData.mimeType) {
|
|
46
|
+
case 'application/x-www-form-urlencoded':
|
|
47
|
+
if ((_a = postData.params) === null || _a === void 0
|
|
48
|
+
? void 0
|
|
49
|
+
: _a.length) {
|
|
50
|
+
// By appending parameters one by one in the resulting snippet,
|
|
51
|
+
// we make it easier for the user to edit it according to his or her needs after pasting.
|
|
52
|
+
// The user can just add/remove lines adding/removing body parameters.
|
|
53
|
+
blank();
|
|
54
|
+
const [head, ...tail] = postData.params;
|
|
55
|
+
push(`NSMutableData *postData = [[NSMutableData alloc] initWithData:[@"${head.name}=${head.value}" dataUsingEncoding:NSUTF8StringEncoding]];`);
|
|
56
|
+
tail.forEach(({ name, value }) => {
|
|
57
|
+
push(`[postData appendData:[@"&${name}=${value}" dataUsingEncoding:NSUTF8StringEncoding]];`);
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
req.hasBody = false;
|
|
62
|
+
}
|
|
63
|
+
break;
|
|
64
|
+
case 'application/json':
|
|
65
|
+
if (postData.jsonObj) {
|
|
66
|
+
push(nsDeclaration('NSDictionary', 'parameters', postData.jsonObj, opts.pretty));
|
|
67
|
+
blank();
|
|
68
|
+
push('NSData *postData = [NSJSONSerialization dataWithJSONObject:parameters options:0 error:nil];');
|
|
69
|
+
}
|
|
70
|
+
break;
|
|
71
|
+
case 'multipart/form-data':
|
|
72
|
+
// By appending multipart parameters one by one in the resulting snippet,
|
|
73
|
+
// we make it easier for the user to edit it according to his or her needs after pasting.
|
|
74
|
+
// The user can just edit the parameters NSDictionary or put this part of a snippet in a multipart builder method.
|
|
75
|
+
push(nsDeclaration('NSArray', 'parameters', postData.params || [], opts.pretty));
|
|
76
|
+
push(`NSString *boundary = @"${postData.boundary}";`);
|
|
77
|
+
blank();
|
|
78
|
+
push('NSError *error;');
|
|
79
|
+
push('NSMutableString *body = [NSMutableString string];');
|
|
80
|
+
push('for (NSDictionary *param in parameters) {');
|
|
81
|
+
push('[body appendFormat:@"--%@\\r\\n", boundary];', 1);
|
|
82
|
+
push('if (param[@"fileName"]) {', 1);
|
|
83
|
+
push('[body appendFormat:@"Content-Disposition:form-data; name=\\"%@\\"; filename=\\"%@\\"\\r\\n", param[@"name"], param[@"fileName"]];', 2);
|
|
84
|
+
push('[body appendFormat:@"Content-Type: %@\\r\\n\\r\\n", param[@"contentType"]];', 2);
|
|
85
|
+
push('[body appendFormat:@"%@", [NSString stringWithContentsOfFile:param[@"fileName"] encoding:NSUTF8StringEncoding error:&error]];', 2);
|
|
86
|
+
push('if (error) {', 2);
|
|
87
|
+
push('NSLog(@"%@", error);', 3);
|
|
88
|
+
push('}', 2);
|
|
89
|
+
push('} else {', 1);
|
|
90
|
+
push('[body appendFormat:@"Content-Disposition:form-data; name=\\"%@\\"\\r\\n\\r\\n", param[@"name"]];', 2);
|
|
91
|
+
push('[body appendFormat:@"%@", param[@"value"]];', 2);
|
|
92
|
+
push('}', 1);
|
|
93
|
+
push('}');
|
|
94
|
+
push('[body appendFormat:@"\\r\\n--%@--\\r\\n", boundary];');
|
|
95
|
+
push('NSData *postData = [body dataUsingEncoding:NSUTF8StringEncoding];');
|
|
96
|
+
break;
|
|
97
|
+
default:
|
|
98
|
+
blank();
|
|
99
|
+
push(`NSData *postData = [[NSData alloc] initWithData:[@"${postData.text}" dataUsingEncoding:NSUTF8StringEncoding]];`);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
blank();
|
|
103
|
+
push(`NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"${fullUrl}"]`);
|
|
104
|
+
// NSURLRequestUseProtocolCachePolicy is the default policy, let's just always set it to avoid confusion.
|
|
105
|
+
push(' cachePolicy:NSURLRequestUseProtocolCachePolicy');
|
|
106
|
+
push(` timeoutInterval:${opts.timeout.toFixed(1)}];`);
|
|
107
|
+
push(`[request setHTTPMethod:@"${method}"];`);
|
|
108
|
+
if (req.hasHeaders) {
|
|
109
|
+
push('[request setAllHTTPHeaderFields:headers];');
|
|
110
|
+
}
|
|
111
|
+
if (req.hasBody) {
|
|
112
|
+
push('[request setHTTPBody:postData];');
|
|
113
|
+
}
|
|
114
|
+
blank();
|
|
115
|
+
// Retrieving the shared session will be less verbose than creating a new one.
|
|
116
|
+
push('NSURLSession *session = [NSURLSession sharedSession];');
|
|
117
|
+
push('NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request');
|
|
118
|
+
push(' completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {');
|
|
119
|
+
push(' if (error) {', 1);
|
|
120
|
+
push(' NSLog(@"%@", error);', 2);
|
|
121
|
+
push(' } else {', 1);
|
|
122
|
+
// Casting the NSURLResponse to NSHTTPURLResponse so the user can see the status .
|
|
123
|
+
push(' NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response;', 2);
|
|
124
|
+
push(' NSLog(@"%@", httpResponse);', 2);
|
|
125
|
+
push(' }', 1);
|
|
126
|
+
push(' }];');
|
|
127
|
+
push('[dataTask resume];');
|
|
128
|
+
return join();
|
|
129
|
+
},
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
export { nsurlsession };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export declare const objc: {
|
|
2
|
+
info: {
|
|
3
|
+
key: string;
|
|
4
|
+
title: string;
|
|
5
|
+
extname: string;
|
|
6
|
+
default: string;
|
|
7
|
+
};
|
|
8
|
+
clientsById: {
|
|
9
|
+
nsurlsession: {
|
|
10
|
+
info: {
|
|
11
|
+
key: string;
|
|
12
|
+
title: string;
|
|
13
|
+
link: string;
|
|
14
|
+
description: string;
|
|
15
|
+
};
|
|
16
|
+
convert: ({ allHeaders, postData, method, fullUrl }: {
|
|
17
|
+
allHeaders: any;
|
|
18
|
+
postData: any;
|
|
19
|
+
method: any;
|
|
20
|
+
fullUrl: any;
|
|
21
|
+
}, options: any) => any;
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
//# sourceMappingURL=target.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"target.d.ts","sourceRoot":"","sources":["../../../../../src/httpsnippet-lite/esm/targets/objc/target.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,IAAI;;;;;;;;;;;;;;;;;;;;;;;CAUhB,CAAA"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export declare const cohttp: {
|
|
2
|
+
info: {
|
|
3
|
+
key: string;
|
|
4
|
+
title: string;
|
|
5
|
+
link: string;
|
|
6
|
+
description: string;
|
|
7
|
+
};
|
|
8
|
+
convert: ({ fullUrl, allHeaders, postData, method }: {
|
|
9
|
+
fullUrl: any;
|
|
10
|
+
allHeaders: any;
|
|
11
|
+
postData: any;
|
|
12
|
+
method: any;
|
|
13
|
+
}, options: any) => any;
|
|
14
|
+
};
|
|
15
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../../../../../src/httpsnippet-lite/esm/targets/ocaml/cohttp/client.ts"],"names":[],"mappings":"AAcA,eAAO,MAAM,MAAM;;;;;;;;;;;;;CAyDlB,CAAA"}
|
|
@@ -0,0 +1,68 @@
|
|
|
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 OCaml using CoHTTP.
|
|
9
|
+
*
|
|
10
|
+
* @author
|
|
11
|
+
* @SGrondin
|
|
12
|
+
*
|
|
13
|
+
* for any questions or issues regarding the generated code snippet, please open an issue mentioning the author.
|
|
14
|
+
*/
|
|
15
|
+
const cohttp = {
|
|
16
|
+
info: {
|
|
17
|
+
key: 'cohttp',
|
|
18
|
+
title: 'CoHTTP',
|
|
19
|
+
link: 'https://github.com/mirage/ocaml-cohttp',
|
|
20
|
+
description: 'Cohttp is a very lightweight HTTP server using Lwt or Async for OCaml',
|
|
21
|
+
},
|
|
22
|
+
convert: ({ fullUrl, allHeaders, postData, method }, options) => {
|
|
23
|
+
const opts = {
|
|
24
|
+
indent: ' ',
|
|
25
|
+
...options,
|
|
26
|
+
};
|
|
27
|
+
const methods = ['get', 'post', 'head', 'delete', 'patch', 'put', 'options'];
|
|
28
|
+
const { push, blank, join } = new CodeBuilder({ indent: opts.indent });
|
|
29
|
+
push('open Cohttp_lwt_unix');
|
|
30
|
+
push('open Cohttp');
|
|
31
|
+
push('open Lwt');
|
|
32
|
+
blank();
|
|
33
|
+
push(`let uri = Uri.of_string "${fullUrl}" in`);
|
|
34
|
+
// Add headers, including the cookies
|
|
35
|
+
const headers = Object.keys(allHeaders);
|
|
36
|
+
if (headers.length === 1) {
|
|
37
|
+
push(`let headers = Header.add (Header.init ()) "${headers[0]}" "${escapeForDoubleQuotes(allHeaders[headers[0]])}" in`);
|
|
38
|
+
}
|
|
39
|
+
else if (headers.length > 1) {
|
|
40
|
+
push('let headers = Header.add_list (Header.init ()) [');
|
|
41
|
+
headers.forEach((key) => {
|
|
42
|
+
push(`("${key}", "${escapeForDoubleQuotes(allHeaders[key])}");`, 1);
|
|
43
|
+
});
|
|
44
|
+
push('] in');
|
|
45
|
+
}
|
|
46
|
+
// Add body
|
|
47
|
+
if (postData === null || postData === void 0 ? void 0 : postData.text) {
|
|
48
|
+
// Just text
|
|
49
|
+
push(`let body = Cohttp_lwt_body.of_string ${JSON.stringify(postData.text)} in`);
|
|
50
|
+
}
|
|
51
|
+
// Do the request
|
|
52
|
+
blank();
|
|
53
|
+
const h = headers.length ? '~headers ' : '';
|
|
54
|
+
const b = (postData === null || postData === void 0 ? void 0 : postData.text)
|
|
55
|
+
? '~body '
|
|
56
|
+
: '';
|
|
57
|
+
const m = methods.includes(method.toLowerCase())
|
|
58
|
+
? `\`${method.toUpperCase()}`
|
|
59
|
+
: `(Code.method_of_string "${method}")`;
|
|
60
|
+
push(`Client.call ${h}${b}${m} uri`);
|
|
61
|
+
// Catch result
|
|
62
|
+
push('>>= fun (res, body_stream) ->');
|
|
63
|
+
push('(* Do stuff with the result *)', 1);
|
|
64
|
+
return join();
|
|
65
|
+
},
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
export { cohttp };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export declare const ocaml: {
|
|
2
|
+
info: {
|
|
3
|
+
key: string;
|
|
4
|
+
title: string;
|
|
5
|
+
extname: string;
|
|
6
|
+
default: string;
|
|
7
|
+
};
|
|
8
|
+
clientsById: {
|
|
9
|
+
cohttp: {
|
|
10
|
+
info: {
|
|
11
|
+
key: string;
|
|
12
|
+
title: string;
|
|
13
|
+
link: string;
|
|
14
|
+
description: string;
|
|
15
|
+
};
|
|
16
|
+
convert: ({ fullUrl, allHeaders, postData, method }: {
|
|
17
|
+
fullUrl: any;
|
|
18
|
+
allHeaders: any;
|
|
19
|
+
postData: any;
|
|
20
|
+
method: any;
|
|
21
|
+
}, options: any) => any;
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
//# sourceMappingURL=target.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"target.d.ts","sourceRoot":"","sources":["../../../../../src/httpsnippet-lite/esm/targets/ocaml/target.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,KAAK;;;;;;;;;;;;;;;;;;;;;;;CAUjB,CAAA"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export declare const curl: {
|
|
2
|
+
info: {
|
|
3
|
+
key: string;
|
|
4
|
+
title: string;
|
|
5
|
+
link: string;
|
|
6
|
+
description: string;
|
|
7
|
+
};
|
|
8
|
+
convert: ({ uriObj, postData, fullUrl, method, httpVersion, cookies, headersObj }: {
|
|
9
|
+
uriObj: any;
|
|
10
|
+
postData: any;
|
|
11
|
+
fullUrl: any;
|
|
12
|
+
method: any;
|
|
13
|
+
httpVersion: any;
|
|
14
|
+
cookies: any;
|
|
15
|
+
headersObj: any;
|
|
16
|
+
}, options?: {}) => any;
|
|
17
|
+
};
|
|
18
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../../../../../src/httpsnippet-lite/esm/targets/php/curl/client.ts"],"names":[],"mappings":"AAeA,eAAO,MAAM,IAAI;;;;;;;;;;;;;;;;CAkIhB,CAAA"}
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import { CodeBuilder } from '../../../helpers/code-builder.js';
|
|
2
|
+
import { escapeForDoubleQuotes } from '../../../helpers/escape.js';
|
|
3
|
+
import { convertType } from '../helpers.js';
|
|
4
|
+
|
|
5
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
6
|
+
// @ts-nocheck
|
|
7
|
+
/**
|
|
8
|
+
* @description
|
|
9
|
+
* HTTP code snippet generator for PHP using curl-ext.
|
|
10
|
+
*
|
|
11
|
+
* @author
|
|
12
|
+
* @AhmadNassri
|
|
13
|
+
*
|
|
14
|
+
* for any questions or issues regarding the generated code snippet, please open an issue mentioning the author.
|
|
15
|
+
*/
|
|
16
|
+
const curl = {
|
|
17
|
+
info: {
|
|
18
|
+
key: 'curl',
|
|
19
|
+
title: 'cURL',
|
|
20
|
+
link: 'http://php.net/manual/en/book.curl.php',
|
|
21
|
+
description: 'PHP with ext-curl',
|
|
22
|
+
},
|
|
23
|
+
convert: ({ uriObj, postData, fullUrl, method, httpVersion, cookies, headersObj }, options = {}) => {
|
|
24
|
+
const { closingTag = false, indent = ' ', maxRedirects = 10, namedErrors = false, noTags = false, shortTags = false, timeout = 30, } = options;
|
|
25
|
+
const { push, blank, join } = new CodeBuilder({ indent });
|
|
26
|
+
if (!noTags) {
|
|
27
|
+
push(shortTags ? '<?' : '<?php');
|
|
28
|
+
blank();
|
|
29
|
+
}
|
|
30
|
+
push('$curl = curl_init();');
|
|
31
|
+
blank();
|
|
32
|
+
const curlOptions = [
|
|
33
|
+
{
|
|
34
|
+
escape: true,
|
|
35
|
+
name: 'CURLOPT_PORT',
|
|
36
|
+
value: uriObj.port === '' ? null : uriObj.port,
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
escape: true,
|
|
40
|
+
name: 'CURLOPT_URL',
|
|
41
|
+
value: fullUrl,
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
escape: false,
|
|
45
|
+
name: 'CURLOPT_RETURNTRANSFER',
|
|
46
|
+
value: 'true',
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
escape: true,
|
|
50
|
+
name: 'CURLOPT_ENCODING',
|
|
51
|
+
value: '',
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
escape: false,
|
|
55
|
+
name: 'CURLOPT_MAXREDIRS',
|
|
56
|
+
value: maxRedirects,
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
escape: false,
|
|
60
|
+
name: 'CURLOPT_TIMEOUT',
|
|
61
|
+
value: timeout,
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
escape: false,
|
|
65
|
+
name: 'CURLOPT_HTTP_VERSION',
|
|
66
|
+
value: httpVersion === 'HTTP/1.0'
|
|
67
|
+
? 'CURL_HTTP_VERSION_1_0'
|
|
68
|
+
: 'CURL_HTTP_VERSION_1_1',
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
escape: true,
|
|
72
|
+
name: 'CURLOPT_CUSTOMREQUEST',
|
|
73
|
+
value: method,
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
escape: !(postData === null || postData === void 0
|
|
77
|
+
? void 0
|
|
78
|
+
: postData.jsonObj),
|
|
79
|
+
name: 'CURLOPT_POSTFIELDS',
|
|
80
|
+
value: postData
|
|
81
|
+
? postData.jsonObj
|
|
82
|
+
? `json_encode(${convertType(postData.jsonObj, indent.repeat(2), indent)})`
|
|
83
|
+
: postData.text
|
|
84
|
+
: undefined,
|
|
85
|
+
},
|
|
86
|
+
];
|
|
87
|
+
push('curl_setopt_array($curl, [');
|
|
88
|
+
const curlopts = new CodeBuilder({ indent, join: `\n${indent}` });
|
|
89
|
+
curlOptions.forEach(({ value, name, escape }) => {
|
|
90
|
+
if (value !== null && value !== undefined) {
|
|
91
|
+
curlopts.push(`${name} => ${escape ? JSON.stringify(value) : value},`);
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
// construct cookies
|
|
95
|
+
const curlCookies = cookies.map((cookie) => `${encodeURIComponent(cookie.name)}=${encodeURIComponent(cookie.value)}`);
|
|
96
|
+
if (curlCookies.length) {
|
|
97
|
+
curlopts.push(`CURLOPT_COOKIE => "${curlCookies.join('; ')}",`);
|
|
98
|
+
}
|
|
99
|
+
// construct cookies
|
|
100
|
+
const headers = Object.keys(headersObj)
|
|
101
|
+
.sort()
|
|
102
|
+
.map((key) => `"${key}: ${escapeForDoubleQuotes(headersObj[key])}"`);
|
|
103
|
+
if (headers.length) {
|
|
104
|
+
curlopts.push('CURLOPT_HTTPHEADER => [');
|
|
105
|
+
curlopts.push(headers.join(`,\n${indent}${indent}`), 1);
|
|
106
|
+
curlopts.push('],');
|
|
107
|
+
}
|
|
108
|
+
push(curlopts.join(), 1);
|
|
109
|
+
push(']);');
|
|
110
|
+
blank();
|
|
111
|
+
push('$response = curl_exec($curl);');
|
|
112
|
+
push('$err = curl_error($curl);');
|
|
113
|
+
blank();
|
|
114
|
+
push('curl_close($curl);');
|
|
115
|
+
blank();
|
|
116
|
+
push('if ($err) {');
|
|
117
|
+
if (namedErrors) {
|
|
118
|
+
push('echo array_flip(get_defined_constants(true)["curl"])[$err];', 1);
|
|
119
|
+
}
|
|
120
|
+
else {
|
|
121
|
+
push('echo "cURL Error #:" . $err;', 1);
|
|
122
|
+
}
|
|
123
|
+
push('} else {');
|
|
124
|
+
push('echo $response;', 1);
|
|
125
|
+
push('}');
|
|
126
|
+
if (!noTags && closingTag) {
|
|
127
|
+
blank();
|
|
128
|
+
push('?>');
|
|
129
|
+
}
|
|
130
|
+
return join();
|
|
131
|
+
},
|
|
132
|
+
};
|
|
133
|
+
|
|
134
|
+
export { curl };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export declare const guzzle: {
|
|
2
|
+
info: {
|
|
3
|
+
key: string;
|
|
4
|
+
title: string;
|
|
5
|
+
link: string;
|
|
6
|
+
description: string;
|
|
7
|
+
};
|
|
8
|
+
convert: ({ postData, fullUrl, method, cookies, headersObj }: {
|
|
9
|
+
postData: any;
|
|
10
|
+
fullUrl: any;
|
|
11
|
+
method: any;
|
|
12
|
+
cookies: any;
|
|
13
|
+
headersObj: 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/php/guzzle/client.ts"],"names":[],"mappings":"AAoBA,eAAO,MAAM,MAAM;;;;;;;;;;;;;;CA4HlB,CAAA"}
|