@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.
- package/dist/clients.js +153 -155
- package/dist/clients.js.map +7 -0
- package/dist/httpsnippet-lite/esm/helpers/code-builder.js +44 -59
- package/dist/httpsnippet-lite/esm/helpers/code-builder.js.map +7 -0
- package/dist/httpsnippet-lite/esm/helpers/escape.js +41 -69
- package/dist/httpsnippet-lite/esm/helpers/escape.js.map +7 -0
- package/dist/httpsnippet-lite/esm/helpers/form-data.js +59 -0
- package/dist/httpsnippet-lite/esm/helpers/form-data.js.map +7 -0
- package/dist/httpsnippet-lite/esm/helpers/headers.js +23 -18
- package/dist/httpsnippet-lite/esm/helpers/headers.js.map +7 -0
- package/dist/httpsnippet-lite/esm/helpers/reducer.js +20 -0
- package/dist/httpsnippet-lite/esm/helpers/reducer.js.map +7 -0
- package/dist/httpsnippet-lite/esm/helpers/shell.js +13 -16
- package/dist/httpsnippet-lite/esm/helpers/shell.js.map +7 -0
- package/dist/httpsnippet-lite/esm/helpers/url.js +20 -0
- package/dist/httpsnippet-lite/esm/helpers/url.js.map +7 -0
- package/dist/httpsnippet-lite/esm/helpers/utils.js +16 -0
- package/dist/httpsnippet-lite/esm/helpers/utils.js.map +7 -0
- package/dist/httpsnippet-lite/esm/targets/c/libcurl/client.d.ts.map +1 -1
- package/dist/httpsnippet-lite/esm/targets/c/libcurl/client.js +72 -40
- package/dist/httpsnippet-lite/esm/targets/c/libcurl/client.js.map +7 -0
- package/dist/httpsnippet-lite/esm/targets/c/target.js +16 -0
- package/dist/httpsnippet-lite/esm/targets/c/target.js.map +7 -0
- package/dist/httpsnippet-lite/esm/targets/clojure/clj_http/client.js +149 -166
- package/dist/httpsnippet-lite/esm/targets/clojure/clj_http/client.js.map +7 -0
- package/dist/httpsnippet-lite/esm/targets/clojure/target.js +16 -0
- package/dist/httpsnippet-lite/esm/targets/clojure/target.js.map +7 -0
- package/dist/httpsnippet-lite/esm/targets/csharp/httpclient/client.js +165 -161
- package/dist/httpsnippet-lite/esm/targets/csharp/httpclient/client.js.map +7 -0
- package/dist/httpsnippet-lite/esm/targets/csharp/restsharp/client.js +47 -46
- package/dist/httpsnippet-lite/esm/targets/csharp/restsharp/client.js.map +7 -0
- package/dist/httpsnippet-lite/esm/targets/csharp/target.js +18 -0
- package/dist/httpsnippet-lite/esm/targets/csharp/target.js.map +7 -0
- package/dist/httpsnippet-lite/esm/targets/go/native/client.d.ts.map +1 -1
- package/dist/httpsnippet-lite/esm/targets/go/native/client.js +167 -116
- package/dist/httpsnippet-lite/esm/targets/go/native/client.js.map +7 -0
- package/dist/httpsnippet-lite/esm/targets/go/target.js +16 -0
- package/dist/httpsnippet-lite/esm/targets/go/target.js.map +7 -0
- package/dist/httpsnippet-lite/esm/targets/java/asynchttp/client.js +37 -44
- package/dist/httpsnippet-lite/esm/targets/java/asynchttp/client.js.map +7 -0
- package/dist/httpsnippet-lite/esm/targets/java/nethttp/client.js +41 -43
- package/dist/httpsnippet-lite/esm/targets/java/nethttp/client.js.map +7 -0
- package/dist/httpsnippet-lite/esm/targets/java/okhttp/client.d.ts.map +1 -1
- package/dist/httpsnippet-lite/esm/targets/java/okhttp/client.js +75 -67
- package/dist/httpsnippet-lite/esm/targets/java/okhttp/client.js.map +7 -0
- package/dist/httpsnippet-lite/esm/targets/java/target.js +22 -0
- package/dist/httpsnippet-lite/esm/targets/java/target.js.map +7 -0
- package/dist/httpsnippet-lite/esm/targets/java/unirest/client.js +37 -44
- package/dist/httpsnippet-lite/esm/targets/java/unirest/client.js.map +7 -0
- package/dist/httpsnippet-lite/esm/targets/javascript/axios/client.js +79 -84
- package/dist/httpsnippet-lite/esm/targets/javascript/axios/client.js.map +7 -0
- package/dist/httpsnippet-lite/esm/targets/javascript/jquery/client.js +76 -83
- package/dist/httpsnippet-lite/esm/targets/javascript/jquery/client.js.map +7 -0
- package/dist/httpsnippet-lite/esm/targets/javascript/target.js +22 -0
- package/dist/httpsnippet-lite/esm/targets/javascript/target.js.map +7 -0
- package/dist/httpsnippet-lite/esm/targets/javascript/xhr/client.js +78 -79
- package/dist/httpsnippet-lite/esm/targets/javascript/xhr/client.js.map +7 -0
- package/dist/httpsnippet-lite/esm/targets/kotlin/okhttp/client.d.ts.map +1 -1
- package/dist/httpsnippet-lite/esm/targets/kotlin/okhttp/client.js +75 -67
- package/dist/httpsnippet-lite/esm/targets/kotlin/okhttp/client.js.map +7 -0
- package/dist/httpsnippet-lite/esm/targets/kotlin/target.js +16 -0
- package/dist/httpsnippet-lite/esm/targets/kotlin/target.js.map +7 -0
- package/dist/httpsnippet-lite/esm/targets/node/axios/client.js +70 -77
- package/dist/httpsnippet-lite/esm/targets/node/axios/client.js.map +7 -0
- package/dist/httpsnippet-lite/esm/targets/node/request/client.js +100 -0
- package/dist/httpsnippet-lite/esm/targets/node/request/client.js.map +7 -0
- package/dist/httpsnippet-lite/esm/targets/node/target.js +24 -0
- package/dist/httpsnippet-lite/esm/targets/node/target.js.map +7 -0
- package/dist/httpsnippet-lite/esm/targets/objc/helpers.js +36 -52
- package/dist/httpsnippet-lite/esm/targets/objc/helpers.js.map +7 -0
- package/dist/httpsnippet-lite/esm/targets/objc/nsurlsession/client.js +157 -128
- package/dist/httpsnippet-lite/esm/targets/objc/nsurlsession/client.js.map +7 -0
- package/dist/httpsnippet-lite/esm/targets/objc/target.js +16 -0
- package/dist/httpsnippet-lite/esm/targets/objc/target.js.map +7 -0
- package/dist/httpsnippet-lite/esm/targets/ocaml/cohttp/client.js +50 -65
- package/dist/httpsnippet-lite/esm/targets/ocaml/cohttp/client.js.map +7 -0
- package/dist/httpsnippet-lite/esm/targets/ocaml/target.js +16 -0
- package/dist/httpsnippet-lite/esm/targets/ocaml/target.js.map +7 -0
- package/dist/httpsnippet-lite/esm/targets/php/helpers.js +72 -0
- package/dist/httpsnippet-lite/esm/targets/php/helpers.js.map +7 -0
- package/dist/httpsnippet-lite/esm/targets/php/http1/client.js +85 -0
- package/dist/httpsnippet-lite/esm/targets/php/http1/client.js.map +7 -0
- package/dist/httpsnippet-lite/esm/targets/php/http2/client.js +127 -0
- package/dist/httpsnippet-lite/esm/targets/php/http2/client.js.map +7 -0
- package/dist/httpsnippet-lite/esm/targets/php/target.js +22 -0
- package/dist/httpsnippet-lite/esm/targets/php/target.js.map +7 -0
- package/dist/httpsnippet-lite/esm/targets/powershell/common.js +61 -49
- package/dist/httpsnippet-lite/esm/targets/powershell/common.js.map +7 -0
- package/dist/httpsnippet-lite/esm/targets/powershell/restmethod/client.js +12 -12
- package/dist/httpsnippet-lite/esm/targets/powershell/restmethod/client.js.map +7 -0
- package/dist/httpsnippet-lite/esm/targets/powershell/target.js +18 -0
- package/dist/httpsnippet-lite/esm/targets/powershell/target.js.map +7 -0
- package/dist/httpsnippet-lite/esm/targets/powershell/webrequest/client.js +12 -12
- package/dist/httpsnippet-lite/esm/targets/powershell/webrequest/client.js.map +7 -0
- package/dist/httpsnippet-lite/esm/targets/python/helpers.js +68 -0
- package/dist/httpsnippet-lite/esm/targets/python/helpers.js.map +7 -0
- package/dist/httpsnippet-lite/esm/targets/python/python3/client.js +71 -90
- package/dist/httpsnippet-lite/esm/targets/python/python3/client.js.map +7 -0
- package/dist/httpsnippet-lite/esm/targets/python/target.js +16 -0
- package/dist/httpsnippet-lite/esm/targets/python/target.js.map +7 -0
- package/dist/httpsnippet-lite/esm/targets/r/httr/client.js +99 -124
- package/dist/httpsnippet-lite/esm/targets/r/httr/client.js.map +7 -0
- package/dist/httpsnippet-lite/esm/targets/r/target.js +16 -0
- package/dist/httpsnippet-lite/esm/targets/r/target.js.map +7 -0
- package/dist/httpsnippet-lite/esm/targets/ruby/native/client.js +69 -69
- package/dist/httpsnippet-lite/esm/targets/ruby/native/client.js.map +7 -0
- package/dist/httpsnippet-lite/esm/targets/ruby/target.js +16 -0
- package/dist/httpsnippet-lite/esm/targets/ruby/target.js.map +7 -0
- package/dist/httpsnippet-lite/esm/targets/shell/httpie/client.d.ts.map +1 -1
- package/dist/httpsnippet-lite/esm/targets/shell/httpie/client.js +106 -113
- package/dist/httpsnippet-lite/esm/targets/shell/httpie/client.js.map +7 -0
- package/dist/httpsnippet-lite/esm/targets/shell/target.js +20 -0
- package/dist/httpsnippet-lite/esm/targets/shell/target.js.map +7 -0
- package/dist/httpsnippet-lite/esm/targets/shell/wget/client.js +42 -51
- package/dist/httpsnippet-lite/esm/targets/shell/wget/client.js.map +7 -0
- package/dist/httpsnippet-lite/esm/targets/swift/helpers.js +51 -67
- package/dist/httpsnippet-lite/esm/targets/swift/helpers.js.map +7 -0
- package/dist/httpsnippet-lite/esm/targets/swift/nsurlsession/client.js +132 -133
- package/dist/httpsnippet-lite/esm/targets/swift/nsurlsession/client.js.map +7 -0
- package/dist/httpsnippet-lite/esm/targets/swift/target.js +16 -0
- package/dist/httpsnippet-lite/esm/targets/swift/target.js.map +7 -0
- package/dist/httpsnippet-lite/types/helpers/code-builder.d.js +1 -0
- package/dist/httpsnippet-lite/types/helpers/code-builder.d.js.map +7 -0
- package/dist/httpsnippet-lite/types/helpers/escape.d.js +1 -0
- package/dist/httpsnippet-lite/types/helpers/escape.d.js.map +7 -0
- package/dist/httpsnippet-lite/types/helpers/form-data.d.js +28 -0
- package/dist/httpsnippet-lite/types/helpers/form-data.d.js.map +7 -0
- package/dist/httpsnippet-lite/types/helpers/headers.d.js +1 -0
- package/dist/httpsnippet-lite/types/helpers/headers.d.js.map +7 -0
- package/dist/httpsnippet-lite/types/helpers/reducer.d.js +1 -0
- package/dist/httpsnippet-lite/types/helpers/reducer.d.js.map +7 -0
- package/dist/httpsnippet-lite/types/helpers/shell.d.js +1 -0
- package/dist/httpsnippet-lite/types/helpers/shell.d.js.map +7 -0
- package/dist/httpsnippet-lite/types/helpers/url.d.js +1 -0
- package/dist/httpsnippet-lite/types/helpers/url.d.js.map +7 -0
- package/dist/httpsnippet-lite/types/helpers/utils.d.js +1 -0
- package/dist/httpsnippet-lite/types/helpers/utils.d.js.map +7 -0
- package/dist/httpsnippet-lite/types/httpsnippet.d.js +19 -0
- package/dist/httpsnippet-lite/types/httpsnippet.d.js.map +7 -0
- package/dist/httpsnippet-lite/types/targets/c/libcurl/client.d.js +1 -0
- package/dist/httpsnippet-lite/types/targets/c/libcurl/client.d.js.map +7 -0
- package/dist/httpsnippet-lite/types/targets/c/target.d.js +1 -0
- package/dist/httpsnippet-lite/types/targets/c/target.d.js.map +7 -0
- package/dist/httpsnippet-lite/types/targets/clojure/clj_http/client.d.js +1 -0
- package/dist/httpsnippet-lite/types/targets/clojure/clj_http/client.d.js.map +7 -0
- package/dist/httpsnippet-lite/types/targets/clojure/target.d.js +1 -0
- package/dist/httpsnippet-lite/types/targets/clojure/target.d.js.map +7 -0
- package/dist/httpsnippet-lite/types/targets/csharp/httpclient/client.d.js +1 -0
- package/dist/httpsnippet-lite/types/targets/csharp/httpclient/client.d.js.map +7 -0
- package/dist/httpsnippet-lite/types/targets/csharp/restsharp/client.d.js +1 -0
- package/dist/httpsnippet-lite/types/targets/csharp/restsharp/client.d.js.map +7 -0
- package/dist/httpsnippet-lite/types/targets/csharp/target.d.js +1 -0
- package/dist/httpsnippet-lite/types/targets/csharp/target.d.js.map +7 -0
- package/dist/httpsnippet-lite/types/targets/dart/http/client.d.js +1 -0
- package/dist/httpsnippet-lite/types/targets/dart/http/client.d.js.map +7 -0
- package/dist/httpsnippet-lite/types/targets/dart/target.d.js +1 -0
- package/dist/httpsnippet-lite/types/targets/dart/target.d.js.map +7 -0
- package/dist/httpsnippet-lite/types/targets/go/native/client.d.js +1 -0
- package/dist/httpsnippet-lite/types/targets/go/native/client.d.js.map +7 -0
- package/dist/httpsnippet-lite/types/targets/go/target.d.js +1 -0
- package/dist/httpsnippet-lite/types/targets/go/target.d.js.map +7 -0
- package/dist/httpsnippet-lite/types/targets/http/http1.1/client.d.js +1 -0
- package/dist/httpsnippet-lite/types/targets/http/http1.1/client.d.js.map +7 -0
- package/dist/httpsnippet-lite/types/targets/http/target.d.js +1 -0
- package/dist/httpsnippet-lite/types/targets/http/target.d.js.map +7 -0
- package/dist/httpsnippet-lite/types/targets/java/asynchttp/client.d.js +1 -0
- package/dist/httpsnippet-lite/types/targets/java/asynchttp/client.d.js.map +7 -0
- package/dist/httpsnippet-lite/types/targets/java/nethttp/client.d.js +1 -0
- package/dist/httpsnippet-lite/types/targets/java/nethttp/client.d.js.map +7 -0
- package/dist/httpsnippet-lite/types/targets/java/okhttp/client.d.js +1 -0
- package/dist/httpsnippet-lite/types/targets/java/okhttp/client.d.js.map +7 -0
- package/dist/httpsnippet-lite/types/targets/java/target.d.js +1 -0
- package/dist/httpsnippet-lite/types/targets/java/target.d.js.map +7 -0
- package/dist/httpsnippet-lite/types/targets/java/unirest/client.d.js +1 -0
- package/dist/httpsnippet-lite/types/targets/java/unirest/client.d.js.map +7 -0
- package/dist/httpsnippet-lite/types/targets/javascript/axios/client.d.js +1 -0
- package/dist/httpsnippet-lite/types/targets/javascript/axios/client.d.js.map +7 -0
- package/dist/httpsnippet-lite/types/targets/javascript/fetch/client.d.js +1 -0
- package/dist/httpsnippet-lite/types/targets/javascript/fetch/client.d.js.map +7 -0
- package/dist/httpsnippet-lite/types/targets/javascript/jquery/client.d.js +1 -0
- package/dist/httpsnippet-lite/types/targets/javascript/jquery/client.d.js.map +7 -0
- package/dist/httpsnippet-lite/types/targets/javascript/target.d.js +1 -0
- package/dist/httpsnippet-lite/types/targets/javascript/target.d.js.map +7 -0
- package/dist/httpsnippet-lite/types/targets/javascript/xhr/client.d.js +1 -0
- package/dist/httpsnippet-lite/types/targets/javascript/xhr/client.d.js.map +7 -0
- package/dist/httpsnippet-lite/types/targets/kotlin/okhttp/client.d.js +1 -0
- package/dist/httpsnippet-lite/types/targets/kotlin/okhttp/client.d.js.map +7 -0
- package/dist/httpsnippet-lite/types/targets/kotlin/target.d.js +1 -0
- package/dist/httpsnippet-lite/types/targets/kotlin/target.d.js.map +7 -0
- package/dist/httpsnippet-lite/types/targets/node/axios/client.d.js +1 -0
- package/dist/httpsnippet-lite/types/targets/node/axios/client.d.js.map +7 -0
- package/dist/httpsnippet-lite/types/targets/node/fetch/client.d.js +1 -0
- package/dist/httpsnippet-lite/types/targets/node/fetch/client.d.js.map +7 -0
- package/dist/httpsnippet-lite/types/targets/node/native/client.d.js +1 -0
- package/dist/httpsnippet-lite/types/targets/node/native/client.d.js.map +7 -0
- package/dist/httpsnippet-lite/types/targets/node/request/client.d.js +1 -0
- package/dist/httpsnippet-lite/types/targets/node/request/client.d.js.map +7 -0
- package/dist/httpsnippet-lite/types/targets/node/target.d.js +1 -0
- package/dist/httpsnippet-lite/types/targets/node/target.d.js.map +7 -0
- package/dist/httpsnippet-lite/types/targets/node/unirest/client.d.js +1 -0
- package/dist/httpsnippet-lite/types/targets/node/unirest/client.d.js.map +7 -0
- package/dist/httpsnippet-lite/types/targets/objc/helpers.d.js +1 -0
- package/dist/httpsnippet-lite/types/targets/objc/helpers.d.js.map +7 -0
- package/dist/httpsnippet-lite/types/targets/objc/nsurlsession/client.d.js +1 -0
- package/dist/httpsnippet-lite/types/targets/objc/nsurlsession/client.d.js.map +7 -0
- package/dist/httpsnippet-lite/types/targets/objc/target.d.js +1 -0
- package/dist/httpsnippet-lite/types/targets/objc/target.d.js.map +7 -0
- package/dist/httpsnippet-lite/types/targets/ocaml/cohttp/client.d.js +1 -0
- package/dist/httpsnippet-lite/types/targets/ocaml/cohttp/client.d.js.map +7 -0
- package/dist/httpsnippet-lite/types/targets/ocaml/target.d.js +1 -0
- package/dist/httpsnippet-lite/types/targets/ocaml/target.d.js.map +7 -0
- package/dist/httpsnippet-lite/types/targets/php/curl/client.d.js +1 -0
- package/dist/httpsnippet-lite/types/targets/php/curl/client.d.js.map +7 -0
- package/dist/httpsnippet-lite/types/targets/php/guzzle/client.d.js +1 -0
- package/dist/httpsnippet-lite/types/targets/php/guzzle/client.d.js.map +7 -0
- package/dist/httpsnippet-lite/types/targets/php/helpers.d.js +1 -0
- package/dist/httpsnippet-lite/types/targets/php/helpers.d.js.map +7 -0
- package/dist/httpsnippet-lite/types/targets/php/http1/client.d.js +1 -0
- package/dist/httpsnippet-lite/types/targets/php/http1/client.d.js.map +7 -0
- package/dist/httpsnippet-lite/types/targets/php/http2/client.d.js +1 -0
- package/dist/httpsnippet-lite/types/targets/php/http2/client.d.js.map +7 -0
- package/dist/httpsnippet-lite/types/targets/php/target.d.js +1 -0
- package/dist/httpsnippet-lite/types/targets/php/target.d.js.map +7 -0
- package/dist/httpsnippet-lite/types/targets/powershell/common.d.js +1 -0
- package/dist/httpsnippet-lite/types/targets/powershell/common.d.js.map +7 -0
- package/dist/httpsnippet-lite/types/targets/powershell/restmethod/client.d.js +1 -0
- package/dist/httpsnippet-lite/types/targets/powershell/restmethod/client.d.js.map +7 -0
- package/dist/httpsnippet-lite/types/targets/powershell/target.d.js +1 -0
- package/dist/httpsnippet-lite/types/targets/powershell/target.d.js.map +7 -0
- package/dist/httpsnippet-lite/types/targets/powershell/webrequest/client.d.js +1 -0
- package/dist/httpsnippet-lite/types/targets/powershell/webrequest/client.d.js.map +7 -0
- package/dist/httpsnippet-lite/types/targets/python/helpers.d.js +1 -0
- package/dist/httpsnippet-lite/types/targets/python/helpers.d.js.map +7 -0
- package/dist/httpsnippet-lite/types/targets/python/python3/client.d.js +1 -0
- package/dist/httpsnippet-lite/types/targets/python/python3/client.d.js.map +7 -0
- package/dist/httpsnippet-lite/types/targets/python/requests/client.d.js +1 -0
- package/dist/httpsnippet-lite/types/targets/python/requests/client.d.js.map +7 -0
- package/dist/httpsnippet-lite/types/targets/python/target.d.js +1 -0
- package/dist/httpsnippet-lite/types/targets/python/target.d.js.map +7 -0
- package/dist/httpsnippet-lite/types/targets/r/httr/client.d.js +1 -0
- package/dist/httpsnippet-lite/types/targets/r/httr/client.d.js.map +7 -0
- package/dist/httpsnippet-lite/types/targets/r/target.d.js +1 -0
- package/dist/httpsnippet-lite/types/targets/r/target.d.js.map +7 -0
- package/dist/httpsnippet-lite/types/targets/ruby/native/client.d.js +1 -0
- package/dist/httpsnippet-lite/types/targets/ruby/native/client.d.js.map +7 -0
- package/dist/httpsnippet-lite/types/targets/ruby/target.d.js +1 -0
- package/dist/httpsnippet-lite/types/targets/ruby/target.d.js.map +7 -0
- package/dist/httpsnippet-lite/types/targets/shell/curl/client.d.js +1 -0
- package/dist/httpsnippet-lite/types/targets/shell/curl/client.d.js.map +7 -0
- package/dist/httpsnippet-lite/types/targets/shell/httpie/client.d.js +1 -0
- package/dist/httpsnippet-lite/types/targets/shell/httpie/client.d.js.map +7 -0
- package/dist/httpsnippet-lite/types/targets/shell/target.d.js +1 -0
- package/dist/httpsnippet-lite/types/targets/shell/target.d.js.map +7 -0
- package/dist/httpsnippet-lite/types/targets/shell/wget/client.d.js +1 -0
- package/dist/httpsnippet-lite/types/targets/shell/wget/client.d.js.map +7 -0
- package/dist/httpsnippet-lite/types/targets/swift/helpers.d.js +1 -0
- package/dist/httpsnippet-lite/types/targets/swift/helpers.d.js.map +7 -0
- package/dist/httpsnippet-lite/types/targets/swift/nsurlsession/client.d.js +1 -0
- package/dist/httpsnippet-lite/types/targets/swift/nsurlsession/client.d.js.map +7 -0
- package/dist/httpsnippet-lite/types/targets/swift/target.d.js +1 -0
- package/dist/httpsnippet-lite/types/targets/swift/target.d.js.map +7 -0
- package/dist/httpsnippet-lite/types/targets/targets.d.js +1 -0
- package/dist/httpsnippet-lite/types/targets/targets.d.js.map +7 -0
- package/dist/index.js +3 -2
- package/dist/index.js.map +7 -0
- package/dist/plugins/c/libcurl/index.js +2 -1
- package/dist/plugins/c/libcurl/index.js.map +7 -0
- package/dist/plugins/c/libcurl/libcurl.js +12 -15
- package/dist/plugins/c/libcurl/libcurl.js.map +7 -0
- package/dist/plugins/c/libcurl/libcurl.test.js +208 -0
- package/dist/plugins/c/libcurl/libcurl.test.js.map +7 -0
- package/dist/plugins/clojure/clj_http/clj_http.js +12 -15
- package/dist/plugins/clojure/clj_http/clj_http.js.map +7 -0
- package/dist/plugins/clojure/clj_http/clj_http.test.js +151 -0
- package/dist/plugins/clojure/clj_http/clj_http.test.js.map +7 -0
- package/dist/plugins/clojure/clj_http/index.js +2 -1
- package/dist/plugins/clojure/clj_http/index.js.map +7 -0
- package/dist/plugins/csharp/httpclient/httpclient.js +12 -15
- package/dist/plugins/csharp/httpclient/httpclient.js.map +7 -0
- package/dist/plugins/csharp/httpclient/index.js +2 -1
- package/dist/plugins/csharp/httpclient/index.js.map +7 -0
- package/dist/plugins/csharp/restsharp/index.js +2 -1
- package/dist/plugins/csharp/restsharp/index.js.map +7 -0
- package/dist/plugins/csharp/restsharp/restsharp.js +12 -15
- package/dist/plugins/csharp/restsharp/restsharp.js.map +7 -0
- package/dist/plugins/dart/http/http.js +92 -96
- package/dist/plugins/dart/http/http.js.map +7 -0
- package/dist/plugins/dart/http/http.test.js +550 -0
- package/dist/plugins/dart/http/http.test.js.map +7 -0
- package/dist/plugins/dart/http/index.js +2 -1
- package/dist/plugins/dart/http/index.js.map +7 -0
- package/dist/plugins/go/native/index.js +2 -1
- package/dist/plugins/go/native/index.js.map +7 -0
- package/dist/plugins/go/native/native.js +12 -15
- package/dist/plugins/go/native/native.js.map +7 -0
- package/dist/plugins/go/native/native.test.js +366 -0
- package/dist/plugins/go/native/native.test.js.map +7 -0
- package/dist/plugins/http/http11/http11.js +84 -104
- package/dist/plugins/http/http11/http11.js.map +7 -0
- package/dist/plugins/http/http11/http11.test.js +175 -0
- package/dist/plugins/http/http11/http11.test.js.map +7 -0
- package/dist/plugins/http/http11/index.js +2 -1
- package/dist/plugins/http/http11/index.js.map +7 -0
- package/dist/plugins/java/asynchttp/asynchttp.js +12 -15
- package/dist/plugins/java/asynchttp/asynchttp.js.map +7 -0
- package/dist/plugins/java/asynchttp/index.js +2 -1
- package/dist/plugins/java/asynchttp/index.js.map +7 -0
- package/dist/plugins/java/nethttp/index.js +2 -1
- package/dist/plugins/java/nethttp/index.js.map +7 -0
- package/dist/plugins/java/nethttp/nethttp.js +12 -15
- package/dist/plugins/java/nethttp/nethttp.js.map +7 -0
- package/dist/plugins/java/okhttp/index.js +2 -1
- package/dist/plugins/java/okhttp/index.js.map +7 -0
- package/dist/plugins/java/okhttp/okhttp.js +12 -15
- package/dist/plugins/java/okhttp/okhttp.js.map +7 -0
- package/dist/plugins/java/okhttp/okhttp.test.js +164 -0
- package/dist/plugins/java/okhttp/okhttp.test.js.map +7 -0
- package/dist/plugins/java/unirest/index.js +2 -1
- package/dist/plugins/java/unirest/index.js.map +7 -0
- package/dist/plugins/java/unirest/unirest.js +12 -15
- package/dist/plugins/java/unirest/unirest.js.map +7 -0
- package/dist/plugins/js/axios/axios.js +12 -15
- package/dist/plugins/js/axios/axios.js.map +7 -0
- package/dist/plugins/js/axios/index.d.ts +1 -1
- package/dist/plugins/js/axios/index.d.ts.map +1 -1
- package/dist/plugins/js/axios/index.js +5 -1
- package/dist/plugins/js/axios/index.js.map +7 -0
- package/dist/plugins/js/fetch/fetch.d.ts.map +1 -1
- package/dist/plugins/js/fetch/fetch.js +67 -60
- package/dist/plugins/js/fetch/fetch.js.map +7 -0
- package/dist/plugins/js/fetch/fetch.test.js +214 -0
- package/dist/plugins/js/fetch/fetch.test.js.map +7 -0
- package/dist/plugins/js/fetch/index.d.ts +1 -1
- package/dist/plugins/js/fetch/index.d.ts.map +1 -1
- package/dist/plugins/js/fetch/index.js +5 -1
- package/dist/plugins/js/fetch/index.js.map +7 -0
- package/dist/plugins/js/jquery/index.js +2 -1
- package/dist/plugins/js/jquery/index.js.map +7 -0
- package/dist/plugins/js/jquery/jquery.js +12 -15
- package/dist/plugins/js/jquery/jquery.js.map +7 -0
- package/dist/plugins/js/ofetch/index.js +2 -1
- package/dist/plugins/js/ofetch/index.js.map +7 -0
- package/dist/plugins/js/ofetch/ofetch.d.ts.map +1 -1
- package/dist/plugins/js/ofetch/ofetch.js +44 -67
- package/dist/plugins/js/ofetch/ofetch.js.map +7 -0
- package/dist/plugins/js/ofetch/ofetch.test.js +126 -0
- package/dist/plugins/js/ofetch/ofetch.test.js.map +7 -0
- package/dist/plugins/js/xhr/index.js +2 -1
- package/dist/plugins/js/xhr/index.js.map +7 -0
- package/dist/plugins/js/xhr/xhr.js +12 -15
- package/dist/plugins/js/xhr/xhr.js.map +7 -0
- package/dist/plugins/kotlin/okhttp/index.js +2 -1
- package/dist/plugins/kotlin/okhttp/index.js.map +7 -0
- package/dist/plugins/kotlin/okhttp/okhttp.js +12 -15
- package/dist/plugins/kotlin/okhttp/okhttp.js.map +7 -0
- package/dist/plugins/kotlin/okhttp/okhttp.test.js +164 -0
- package/dist/plugins/kotlin/okhttp/okhttp.test.js.map +7 -0
- package/dist/plugins/node/axios/axios.js +12 -15
- package/dist/plugins/node/axios/axios.js.map +7 -0
- package/dist/plugins/node/axios/index.js +2 -1
- package/dist/plugins/node/axios/index.js.map +7 -0
- package/dist/plugins/node/fetch/fetch.d.ts.map +1 -1
- package/dist/plugins/node/fetch/fetch.js +73 -59
- package/dist/plugins/node/fetch/fetch.js.map +7 -0
- package/dist/plugins/node/fetch/fetch.test.js +200 -0
- package/dist/plugins/node/fetch/fetch.test.js.map +7 -0
- package/dist/plugins/node/fetch/index.js +2 -1
- package/dist/plugins/node/fetch/index.js.map +7 -0
- package/dist/plugins/node/ofetch/index.js +2 -1
- package/dist/plugins/node/ofetch/index.js.map +7 -0
- package/dist/plugins/node/ofetch/ofetch.d.ts.map +1 -1
- package/dist/plugins/node/ofetch/ofetch.js +44 -67
- package/dist/plugins/node/ofetch/ofetch.js.map +7 -0
- package/dist/plugins/node/ofetch/ofetch.test.js +126 -0
- package/dist/plugins/node/ofetch/ofetch.test.js.map +7 -0
- package/dist/plugins/node/undici/index.js +2 -1
- package/dist/plugins/node/undici/index.js.map +7 -0
- package/dist/plugins/node/undici/undici.d.ts.map +1 -1
- package/dist/plugins/node/undici/undici.js +46 -62
- package/dist/plugins/node/undici/undici.js.map +7 -0
- package/dist/plugins/node/undici/undici.test.js +133 -0
- package/dist/plugins/node/undici/undici.test.js.map +7 -0
- package/dist/plugins/objc/nsurlsession/index.js +2 -1
- package/dist/plugins/objc/nsurlsession/index.js.map +7 -0
- package/dist/plugins/objc/nsurlsession/nsurlsession.js +12 -15
- package/dist/plugins/objc/nsurlsession/nsurlsession.js.map +7 -0
- package/dist/plugins/ocaml/cohttp/cohttp.js +12 -15
- package/dist/plugins/ocaml/cohttp/cohttp.js.map +7 -0
- package/dist/plugins/ocaml/cohttp/index.js +2 -1
- package/dist/plugins/ocaml/cohttp/index.js.map +7 -0
- package/dist/plugins/php/curl/curl.js +119 -157
- package/dist/plugins/php/curl/curl.js.map +7 -0
- package/dist/plugins/php/curl/curl.test.js +564 -0
- package/dist/plugins/php/curl/curl.test.js.map +7 -0
- package/dist/plugins/php/curl/index.js +2 -1
- package/dist/plugins/php/curl/index.js.map +7 -0
- package/dist/plugins/php/guzzle/guzzle.js +115 -148
- package/dist/plugins/php/guzzle/guzzle.js.map +7 -0
- package/dist/plugins/php/guzzle/guzzle.test.js +546 -0
- package/dist/plugins/php/guzzle/guzzle.test.js.map +7 -0
- package/dist/plugins/php/guzzle/index.js +2 -1
- package/dist/plugins/php/guzzle/index.js.map +7 -0
- package/dist/plugins/powershell/restmethod/index.js +2 -1
- package/dist/plugins/powershell/restmethod/index.js.map +7 -0
- package/dist/plugins/powershell/restmethod/restmethod.js +12 -15
- package/dist/plugins/powershell/restmethod/restmethod.js.map +7 -0
- package/dist/plugins/powershell/webrequest/index.js +2 -1
- package/dist/plugins/powershell/webrequest/index.js.map +7 -0
- package/dist/plugins/powershell/webrequest/webrequest.js +12 -15
- package/dist/plugins/powershell/webrequest/webrequest.js.map +7 -0
- package/dist/plugins/python/python3/index.js +2 -1
- package/dist/plugins/python/python3/index.js.map +7 -0
- package/dist/plugins/python/python3/python3.js +12 -15
- package/dist/plugins/python/python3/python3.js.map +7 -0
- package/dist/plugins/python/requests/index.js +2 -1
- package/dist/plugins/python/requests/index.js.map +7 -0
- package/dist/plugins/python/requests/requests.d.ts.map +1 -1
- package/dist/plugins/python/requests/requests.js +98 -126
- package/dist/plugins/python/requests/requests.js.map +7 -0
- package/dist/plugins/python/requests/requests.test.js +419 -0
- package/dist/plugins/python/requests/requests.test.js.map +7 -0
- package/dist/plugins/r/httr/httr.js +12 -15
- package/dist/plugins/r/httr/httr.js.map +7 -0
- package/dist/plugins/r/httr/index.js +2 -1
- package/dist/plugins/r/httr/index.js.map +7 -0
- package/dist/plugins/ruby/native/index.js +2 -1
- package/dist/plugins/ruby/native/index.js.map +7 -0
- package/dist/plugins/ruby/native/native.js +12 -15
- package/dist/plugins/ruby/native/native.js.map +7 -0
- package/dist/plugins/ruby/native/native.test.js +240 -0
- package/dist/plugins/ruby/native/native.test.js.map +7 -0
- package/dist/plugins/shell/curl/curl.js +81 -114
- package/dist/plugins/shell/curl/curl.js.map +7 -0
- package/dist/plugins/shell/curl/curl.test.js +427 -0
- package/dist/plugins/shell/curl/curl.test.js.map +7 -0
- package/dist/plugins/shell/curl/index.js +2 -1
- package/dist/plugins/shell/curl/index.js.map +7 -0
- package/dist/plugins/shell/httpie/httpie.js +12 -15
- package/dist/plugins/shell/httpie/httpie.js.map +7 -0
- package/dist/plugins/shell/httpie/httpie.test.js +113 -0
- package/dist/plugins/shell/httpie/httpie.test.js.map +7 -0
- package/dist/plugins/shell/httpie/index.js +2 -1
- package/dist/plugins/shell/httpie/index.js.map +7 -0
- package/dist/plugins/shell/wget/index.js +2 -1
- package/dist/plugins/shell/wget/index.js.map +7 -0
- package/dist/plugins/shell/wget/wget.js +12 -15
- package/dist/plugins/shell/wget/wget.js.map +7 -0
- package/dist/plugins/shell/wget/wget.test.js +143 -0
- package/dist/plugins/shell/wget/wget.test.js.map +7 -0
- package/dist/plugins/swift/nsurlsession/index.js +2 -1
- package/dist/plugins/swift/nsurlsession/index.js.map +7 -0
- package/dist/plugins/swift/nsurlsession/nsurlsession.js +12 -15
- package/dist/plugins/swift/nsurlsession/nsurlsession.js.map +7 -0
- package/dist/plugins/swift/nsurlsession/nsurlsession.test.js +344 -0
- package/dist/plugins/swift/nsurlsession/nsurlsession.test.js.map +7 -0
- package/dist/snippetz.js +27 -27
- package/dist/snippetz.js.map +7 -0
- package/dist/snippetz.test.js +79 -0
- package/dist/snippetz.test.js.map +7 -0
- package/dist/utils/convertWithHttpSnippetLite.js +101 -104
- package/dist/utils/convertWithHttpSnippetLite.js.map +7 -0
- package/dist/utils/convertWithHttpSnippetLite.test.js +106 -0
- package/dist/utils/convertWithHttpSnippetLite.test.js.map +7 -0
- package/dist/utils/create-search-params.d.ts +4 -0
- package/dist/utils/create-search-params.d.ts.map +1 -0
- package/dist/utils/create-search-params.js +11 -0
- package/dist/utils/create-search-params.js.map +7 -0
- package/dist/utils/create-search-params.test.js +49 -0
- package/dist/utils/create-search-params.test.js.map +7 -0
- package/dist/utils/index.d.ts +0 -1
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/index.js +4 -4
- package/dist/utils/index.js.map +7 -0
- package/dist/utils/needsQuotes.js +5 -8
- package/dist/utils/needsQuotes.js.map +7 -0
- package/dist/utils/objectToString.d.ts +8 -0
- package/dist/utils/objectToString.d.ts.map +1 -1
- package/dist/utils/objectToString.js +48 -54
- package/dist/utils/objectToString.js.map +7 -0
- package/package.json +147 -151
- package/dist/utils/arrayToObject.d.ts +0 -8
- package/dist/utils/arrayToObject.d.ts.map +0 -1
- package/dist/utils/arrayToObject.js +0 -14
|
@@ -1,71 +1,48 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { objectToString } from '../../../utils/objectToString.js';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* js/ofetch
|
|
6
|
-
*/
|
|
1
|
+
import { objectToString } from "../../../utils/objectToString.js";
|
|
7
2
|
const jsOfetch = {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
}
|
|
47
|
-
// Remove undefined keys
|
|
48
|
-
Object.keys(options).forEach((key) => {
|
|
49
|
-
if (options[key] === undefined) {
|
|
50
|
-
delete options[key];
|
|
51
|
-
}
|
|
52
|
-
});
|
|
53
|
-
// Add body
|
|
54
|
-
if (normalizedRequest.postData) {
|
|
55
|
-
// Plain text
|
|
56
|
-
options.body = normalizedRequest.postData.text;
|
|
57
|
-
// JSON
|
|
58
|
-
if (normalizedRequest.postData.mimeType === 'application/json') {
|
|
59
|
-
options.body = JSON.parse(options.body);
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
// Transform to JSON
|
|
63
|
-
const jsonOptions = Object.keys(options).length ? `, ${objectToString(options)}` : '';
|
|
64
|
-
// Code Template
|
|
65
|
-
return `import { ofetch } from 'ofetch'
|
|
3
|
+
target: "js",
|
|
4
|
+
client: "ofetch",
|
|
5
|
+
title: "ofetch",
|
|
6
|
+
generate(request) {
|
|
7
|
+
const normalizedRequest = {
|
|
8
|
+
method: "GET",
|
|
9
|
+
...request
|
|
10
|
+
};
|
|
11
|
+
normalizedRequest.method = normalizedRequest.method.toUpperCase();
|
|
12
|
+
const options = {
|
|
13
|
+
method: normalizedRequest.method === "GET" ? void 0 : normalizedRequest.method
|
|
14
|
+
};
|
|
15
|
+
options.query = normalizedRequest.queryString;
|
|
16
|
+
if (normalizedRequest.headers?.length) {
|
|
17
|
+
options.headers = {};
|
|
18
|
+
normalizedRequest.headers.forEach((header) => {
|
|
19
|
+
options.headers[header.name] = header.value;
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
if (normalizedRequest.cookies?.length) {
|
|
23
|
+
options.headers = options.headers || {};
|
|
24
|
+
normalizedRequest.cookies.forEach((cookie) => {
|
|
25
|
+
options.headers["Set-Cookie"] = options.headers["Set-Cookie"] ? `${options.headers["Set-Cookie"]}; ${cookie.name}=${cookie.value}` : `${cookie.name}=${cookie.value}`;
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
Object.keys(options).forEach((key) => {
|
|
29
|
+
if (options[key] === void 0) {
|
|
30
|
+
delete options[key];
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
if (normalizedRequest.postData) {
|
|
34
|
+
options.body = normalizedRequest.postData.text;
|
|
35
|
+
if (normalizedRequest.postData.mimeType === "application/json") {
|
|
36
|
+
options.body = JSON.parse(options.body);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
const jsonOptions = Object.keys(options).length ? `, ${objectToString(options)}` : "";
|
|
40
|
+
return `import { ofetch } from 'ofetch'
|
|
66
41
|
|
|
67
42
|
ofetch('${normalizedRequest.url}'${jsonOptions})`;
|
|
68
|
-
|
|
43
|
+
}
|
|
69
44
|
};
|
|
70
|
-
|
|
71
|
-
|
|
45
|
+
export {
|
|
46
|
+
jsOfetch
|
|
47
|
+
};
|
|
48
|
+
//# sourceMappingURL=ofetch.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/plugins/js/ofetch/ofetch.ts"],
|
|
4
|
+
"sourcesContent": ["import { objectToString } from '@/utils/objectToString'\nimport type { Plugin } from '@scalar/types/snippetz'\n\n/**\n * js/ofetch\n */\nexport const jsOfetch: Plugin = {\n target: 'js',\n client: 'ofetch',\n title: 'ofetch',\n generate(request) {\n // Defaults\n const normalizedRequest = {\n method: 'GET',\n ...request,\n }\n\n // Normalization\n normalizedRequest.method = normalizedRequest.method.toUpperCase()\n\n // Reset fetch defaults\n const options: Record<string, any> = {\n method: normalizedRequest.method === 'GET' ? undefined : normalizedRequest.method,\n }\n\n // Query\n options.query = normalizedRequest.queryString\n\n // Headers\n if (normalizedRequest.headers?.length) {\n options.headers = {}\n\n normalizedRequest.headers.forEach((header) => {\n options.headers![header.name] = header.value\n })\n }\n\n // Cookies\n if (normalizedRequest.cookies?.length) {\n options.headers = options.headers || {}\n\n normalizedRequest.cookies.forEach((cookie) => {\n options.headers!['Set-Cookie'] = options.headers!['Set-Cookie']\n ? `${options.headers!['Set-Cookie']}; ${cookie.name}=${cookie.value}`\n : `${cookie.name}=${cookie.value}`\n })\n }\n\n // Remove undefined keys\n Object.keys(options).forEach((key) => {\n if (options[key] === undefined) {\n delete options[key]\n }\n })\n\n // Add body\n if (normalizedRequest.postData) {\n // Plain text\n options.body = normalizedRequest.postData.text\n\n // JSON\n if (normalizedRequest.postData.mimeType === 'application/json') {\n options.body = JSON.parse(options.body)\n }\n }\n\n // Transform to JSON\n const jsonOptions = Object.keys(options).length ? `, ${objectToString(options)}` : ''\n\n // Code Template\n return `import { ofetch } from 'ofetch'\n\nofetch('${normalizedRequest.url}'${jsonOptions})`\n },\n}\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,sBAAsB;AAMxB,MAAM,WAAmB;AAAA,EAC9B,QAAQ;AAAA,EACR,QAAQ;AAAA,EACR,OAAO;AAAA,EACP,SAAS,SAAS;AAEhB,UAAM,oBAAoB;AAAA,MACxB,QAAQ;AAAA,MACR,GAAG;AAAA,IACL;AAGA,sBAAkB,SAAS,kBAAkB,OAAO,YAAY;AAGhE,UAAM,UAA+B;AAAA,MACnC,QAAQ,kBAAkB,WAAW,QAAQ,SAAY,kBAAkB;AAAA,IAC7E;AAGA,YAAQ,QAAQ,kBAAkB;AAGlC,QAAI,kBAAkB,SAAS,QAAQ;AACrC,cAAQ,UAAU,CAAC;AAEnB,wBAAkB,QAAQ,QAAQ,CAAC,WAAW;AAC5C,gBAAQ,QAAS,OAAO,IAAI,IAAI,OAAO;AAAA,MACzC,CAAC;AAAA,IACH;AAGA,QAAI,kBAAkB,SAAS,QAAQ;AACrC,cAAQ,UAAU,QAAQ,WAAW,CAAC;AAEtC,wBAAkB,QAAQ,QAAQ,CAAC,WAAW;AAC5C,gBAAQ,QAAS,YAAY,IAAI,QAAQ,QAAS,YAAY,IAC1D,GAAG,QAAQ,QAAS,YAAY,CAAC,KAAK,OAAO,IAAI,IAAI,OAAO,KAAK,KACjE,GAAG,OAAO,IAAI,IAAI,OAAO,KAAK;AAAA,MACpC,CAAC;AAAA,IACH;AAGA,WAAO,KAAK,OAAO,EAAE,QAAQ,CAAC,QAAQ;AACpC,UAAI,QAAQ,GAAG,MAAM,QAAW;AAC9B,eAAO,QAAQ,GAAG;AAAA,MACpB;AAAA,IACF,CAAC;AAGD,QAAI,kBAAkB,UAAU;AAE9B,cAAQ,OAAO,kBAAkB,SAAS;AAG1C,UAAI,kBAAkB,SAAS,aAAa,oBAAoB;AAC9D,gBAAQ,OAAO,KAAK,MAAM,QAAQ,IAAI;AAAA,MACxC;AAAA,IACF;AAGA,UAAM,cAAc,OAAO,KAAK,OAAO,EAAE,SAAS,KAAK,eAAe,OAAO,CAAC,KAAK;AAGnF,WAAO;AAAA;AAAA,UAED,kBAAkB,GAAG,IAAI,WAAW;AAAA,EAC5C;AACF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import { describe, expect, it } from "vitest";
|
|
2
|
+
import { jsOfetch } from "./ofetch.js";
|
|
3
|
+
describe("jsOfetch", () => {
|
|
4
|
+
it("returns a basic request", () => {
|
|
5
|
+
const result = jsOfetch.generate({
|
|
6
|
+
url: "https://example.com"
|
|
7
|
+
});
|
|
8
|
+
expect(result).toBe(`import { ofetch } from 'ofetch'
|
|
9
|
+
|
|
10
|
+
ofetch('https://example.com')`);
|
|
11
|
+
});
|
|
12
|
+
it("returns a POST request", () => {
|
|
13
|
+
const result = jsOfetch.generate({
|
|
14
|
+
url: "https://example.com",
|
|
15
|
+
method: "post"
|
|
16
|
+
});
|
|
17
|
+
expect(result).toBe(`import { ofetch } from 'ofetch'
|
|
18
|
+
|
|
19
|
+
ofetch('https://example.com', {
|
|
20
|
+
method: 'POST'
|
|
21
|
+
})`);
|
|
22
|
+
});
|
|
23
|
+
it("has headers", () => {
|
|
24
|
+
const result = jsOfetch.generate({
|
|
25
|
+
url: "https://example.com",
|
|
26
|
+
headers: [
|
|
27
|
+
{
|
|
28
|
+
name: "Content-Type",
|
|
29
|
+
value: "application/json"
|
|
30
|
+
}
|
|
31
|
+
]
|
|
32
|
+
});
|
|
33
|
+
expect(result).toBe(`import { ofetch } from 'ofetch'
|
|
34
|
+
|
|
35
|
+
ofetch('https://example.com', {
|
|
36
|
+
headers: {
|
|
37
|
+
'Content-Type': 'application/json'
|
|
38
|
+
}
|
|
39
|
+
})`);
|
|
40
|
+
});
|
|
41
|
+
it("doesn\u2019t add empty headers", () => {
|
|
42
|
+
const result = jsOfetch.generate({
|
|
43
|
+
url: "https://example.com",
|
|
44
|
+
headers: []
|
|
45
|
+
});
|
|
46
|
+
expect(result).toBe(`import { ofetch } from 'ofetch'
|
|
47
|
+
|
|
48
|
+
ofetch('https://example.com')`);
|
|
49
|
+
});
|
|
50
|
+
it("has JSON body", () => {
|
|
51
|
+
const result = jsOfetch.generate({
|
|
52
|
+
url: "https://example.com",
|
|
53
|
+
postData: {
|
|
54
|
+
mimeType: "application/json",
|
|
55
|
+
text: JSON.stringify({
|
|
56
|
+
hello: "world"
|
|
57
|
+
})
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
expect(result).toBe(`import { ofetch } from 'ofetch'
|
|
61
|
+
|
|
62
|
+
ofetch('https://example.com', {
|
|
63
|
+
body: {
|
|
64
|
+
hello: 'world'
|
|
65
|
+
}
|
|
66
|
+
})`);
|
|
67
|
+
});
|
|
68
|
+
it("has query string", () => {
|
|
69
|
+
const result = jsOfetch.generate({
|
|
70
|
+
url: "https://example.com",
|
|
71
|
+
queryString: [
|
|
72
|
+
{
|
|
73
|
+
name: "foo",
|
|
74
|
+
value: "bar"
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
name: "bar",
|
|
78
|
+
value: "foo"
|
|
79
|
+
}
|
|
80
|
+
]
|
|
81
|
+
});
|
|
82
|
+
expect(result).toBe(`import { ofetch } from 'ofetch'
|
|
83
|
+
|
|
84
|
+
ofetch('https://example.com', {
|
|
85
|
+
query: [{
|
|
86
|
+
name: 'foo',
|
|
87
|
+
value: 'bar'
|
|
88
|
+
}, {
|
|
89
|
+
name: 'bar',
|
|
90
|
+
value: 'foo'
|
|
91
|
+
}]
|
|
92
|
+
})`);
|
|
93
|
+
});
|
|
94
|
+
it("has cookies", () => {
|
|
95
|
+
const result = jsOfetch.generate({
|
|
96
|
+
url: "https://example.com",
|
|
97
|
+
cookies: [
|
|
98
|
+
{
|
|
99
|
+
name: "foo",
|
|
100
|
+
value: "bar"
|
|
101
|
+
},
|
|
102
|
+
{
|
|
103
|
+
name: "bar",
|
|
104
|
+
value: "foo"
|
|
105
|
+
}
|
|
106
|
+
]
|
|
107
|
+
});
|
|
108
|
+
expect(result).toBe(`import { ofetch } from 'ofetch'
|
|
109
|
+
|
|
110
|
+
ofetch('https://example.com', {
|
|
111
|
+
headers: {
|
|
112
|
+
'Set-Cookie': 'foo=bar; bar=foo'
|
|
113
|
+
}
|
|
114
|
+
})`);
|
|
115
|
+
});
|
|
116
|
+
it("doesn\u2019t add empty cookies", () => {
|
|
117
|
+
const result = jsOfetch.generate({
|
|
118
|
+
url: "https://example.com",
|
|
119
|
+
cookies: []
|
|
120
|
+
});
|
|
121
|
+
expect(result).toBe(`import { ofetch } from 'ofetch'
|
|
122
|
+
|
|
123
|
+
ofetch('https://example.com')`);
|
|
124
|
+
});
|
|
125
|
+
});
|
|
126
|
+
//# sourceMappingURL=ofetch.test.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/plugins/js/ofetch/ofetch.test.ts"],
|
|
4
|
+
"sourcesContent": ["import { describe, expect, it } from 'vitest'\n\nimport { jsOfetch } from './ofetch'\n\ndescribe('jsOfetch', () => {\n it('returns a basic request', () => {\n const result = jsOfetch.generate({\n url: 'https://example.com',\n })\n\n expect(result).toBe(`import { ofetch } from 'ofetch'\n\nofetch('https://example.com')`)\n })\n\n it('returns a POST request', () => {\n const result = jsOfetch.generate({\n url: 'https://example.com',\n method: 'post',\n })\n\n expect(result).toBe(`import { ofetch } from 'ofetch'\n\nofetch('https://example.com', {\n method: 'POST'\n})`)\n })\n\n it('has headers', () => {\n const result = jsOfetch.generate({\n url: 'https://example.com',\n headers: [\n {\n name: 'Content-Type',\n value: 'application/json',\n },\n ],\n })\n\n expect(result).toBe(`import { ofetch } from 'ofetch'\n\nofetch('https://example.com', {\n headers: {\n 'Content-Type': 'application/json'\n }\n})`)\n })\n\n it('doesn\u2019t add empty headers', () => {\n const result = jsOfetch.generate({\n url: 'https://example.com',\n headers: [],\n })\n\n expect(result).toBe(`import { ofetch } from 'ofetch'\n\nofetch('https://example.com')`)\n })\n\n it('has JSON body', () => {\n const result = jsOfetch.generate({\n url: 'https://example.com',\n postData: {\n mimeType: 'application/json',\n text: JSON.stringify({\n hello: 'world',\n }),\n },\n })\n\n expect(result).toBe(`import { ofetch } from 'ofetch'\n\nofetch('https://example.com', {\n body: {\n hello: 'world'\n }\n})`)\n })\n\n it('has query string', () => {\n const result = jsOfetch.generate({\n url: 'https://example.com',\n queryString: [\n {\n name: 'foo',\n value: 'bar',\n },\n {\n name: 'bar',\n value: 'foo',\n },\n ],\n })\n\n expect(result).toBe(`import { ofetch } from 'ofetch'\n\nofetch('https://example.com', {\n query: [{\n name: 'foo',\n value: 'bar'\n }, {\n name: 'bar',\n value: 'foo'\n }]\n})`)\n })\n\n it('has cookies', () => {\n const result = jsOfetch.generate({\n url: 'https://example.com',\n cookies: [\n {\n name: 'foo',\n value: 'bar',\n },\n {\n name: 'bar',\n value: 'foo',\n },\n ],\n })\n\n expect(result).toBe(`import { ofetch } from 'ofetch'\n\nofetch('https://example.com', {\n headers: {\n 'Set-Cookie': 'foo=bar; bar=foo'\n }\n})`)\n })\n\n it('doesn\u2019t add empty cookies', () => {\n const result = jsOfetch.generate({\n url: 'https://example.com',\n cookies: [],\n })\n\n expect(result).toBe(`import { ofetch } from 'ofetch'\n\nofetch('https://example.com')`)\n })\n})\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,UAAU,QAAQ,UAAU;AAErC,SAAS,gBAAgB;AAEzB,SAAS,YAAY,MAAM;AACzB,KAAG,2BAA2B,MAAM;AAClC,UAAM,SAAS,SAAS,SAAS;AAAA,MAC/B,KAAK;AAAA,IACP,CAAC;AAED,WAAO,MAAM,EAAE,KAAK;AAAA;AAAA,8BAEM;AAAA,EAC5B,CAAC;AAED,KAAG,0BAA0B,MAAM;AACjC,UAAM,SAAS,SAAS,SAAS;AAAA,MAC/B,KAAK;AAAA,MACL,QAAQ;AAAA,IACV,CAAC;AAED,WAAO,MAAM,EAAE,KAAK;AAAA;AAAA;AAAA;AAAA,GAIrB;AAAA,EACD,CAAC;AAED,KAAG,eAAe,MAAM;AACtB,UAAM,SAAS,SAAS,SAAS;AAAA,MAC/B,KAAK;AAAA,MACL,SAAS;AAAA,QACP;AAAA,UACE,MAAM;AAAA,UACN,OAAO;AAAA,QACT;AAAA,MACF;AAAA,IACF,CAAC;AAED,WAAO,MAAM,EAAE,KAAK;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,GAMrB;AAAA,EACD,CAAC;AAED,KAAG,kCAA6B,MAAM;AACpC,UAAM,SAAS,SAAS,SAAS;AAAA,MAC/B,KAAK;AAAA,MACL,SAAS,CAAC;AAAA,IACZ,CAAC;AAED,WAAO,MAAM,EAAE,KAAK;AAAA;AAAA,8BAEM;AAAA,EAC5B,CAAC;AAED,KAAG,iBAAiB,MAAM;AACxB,UAAM,SAAS,SAAS,SAAS;AAAA,MAC/B,KAAK;AAAA,MACL,UAAU;AAAA,QACR,UAAU;AAAA,QACV,MAAM,KAAK,UAAU;AAAA,UACnB,OAAO;AAAA,QACT,CAAC;AAAA,MACH;AAAA,IACF,CAAC;AAED,WAAO,MAAM,EAAE,KAAK;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,GAMrB;AAAA,EACD,CAAC;AAED,KAAG,oBAAoB,MAAM;AAC3B,UAAM,SAAS,SAAS,SAAS;AAAA,MAC/B,KAAK;AAAA,MACL,aAAa;AAAA,QACX;AAAA,UACE,MAAM;AAAA,UACN,OAAO;AAAA,QACT;AAAA,QACA;AAAA,UACE,MAAM;AAAA,UACN,OAAO;AAAA,QACT;AAAA,MACF;AAAA,IACF,CAAC;AAED,WAAO,MAAM,EAAE,KAAK;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,GAUrB;AAAA,EACD,CAAC;AAED,KAAG,eAAe,MAAM;AACtB,UAAM,SAAS,SAAS,SAAS;AAAA,MAC/B,KAAK;AAAA,MACL,SAAS;AAAA,QACP;AAAA,UACE,MAAM;AAAA,UACN,OAAO;AAAA,QACT;AAAA,QACA;AAAA,UACE,MAAM;AAAA,UACN,OAAO;AAAA,QACT;AAAA,MACF;AAAA,IACF,CAAC;AAED,WAAO,MAAM,EAAE,KAAK;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,GAMrB;AAAA,EACD,CAAC;AAED,KAAG,kCAA6B,MAAM;AACpC,UAAM,SAAS,SAAS,SAAS;AAAA,MAC/B,KAAK;AAAA,MACL,SAAS,CAAC;AAAA,IACZ,CAAC;AAED,WAAO,MAAM,EAAE,KAAK;AAAA;AAAA,8BAEM;AAAA,EAC5B,CAAC;AACH,CAAC;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export
|
|
1
|
+
export * from "./xhr.js";
|
|
2
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -1,17 +1,14 @@
|
|
|
1
|
-
import { xhr } from
|
|
2
|
-
import { convertWithHttpSnippetLite } from
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* js/xhr
|
|
6
|
-
*/
|
|
1
|
+
import { xhr } from "../../../httpsnippet-lite/esm/targets/javascript/xhr/client.js";
|
|
2
|
+
import { convertWithHttpSnippetLite } from "../../../utils/convertWithHttpSnippetLite.js";
|
|
7
3
|
const jsXhr = {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
},
|
|
4
|
+
target: "js",
|
|
5
|
+
client: "xhr",
|
|
6
|
+
title: "XHR",
|
|
7
|
+
generate(request) {
|
|
8
|
+
return convertWithHttpSnippetLite(xhr, request);
|
|
9
|
+
}
|
|
15
10
|
};
|
|
16
|
-
|
|
17
|
-
|
|
11
|
+
export {
|
|
12
|
+
jsXhr
|
|
13
|
+
};
|
|
14
|
+
//# sourceMappingURL=xhr.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/plugins/js/xhr/xhr.ts"],
|
|
4
|
+
"sourcesContent": ["import { xhr } from '@/httpsnippet-lite/esm/targets/javascript/xhr/client'\nimport { convertWithHttpSnippetLite } from '@/utils/convertWithHttpSnippetLite'\nimport type { Plugin } from '@scalar/types/snippetz'\n\n/**\n * js/xhr\n */\nexport const jsXhr: Plugin = {\n target: 'js',\n client: 'xhr',\n title: 'XHR',\n generate(request) {\n // TODO: Write an own converter\n return convertWithHttpSnippetLite(xhr, request)\n },\n}\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,WAAW;AACpB,SAAS,kCAAkC;AAMpC,MAAM,QAAgB;AAAA,EAC3B,QAAQ;AAAA,EACR,QAAQ;AAAA,EACR,OAAO;AAAA,EACP,SAAS,SAAS;AAEhB,WAAO,2BAA2B,KAAK,OAAO;AAAA,EAChD;AACF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export
|
|
1
|
+
export * from "./okhttp.js";
|
|
2
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -1,17 +1,14 @@
|
|
|
1
|
-
import { okhttp } from
|
|
2
|
-
import { convertWithHttpSnippetLite } from
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* kotlin/okhttp
|
|
6
|
-
*/
|
|
1
|
+
import { okhttp } from "../../../httpsnippet-lite/esm/targets/kotlin/okhttp/client.js";
|
|
2
|
+
import { convertWithHttpSnippetLite } from "../../../utils/convertWithHttpSnippetLite.js";
|
|
7
3
|
const kotlinOkhttp = {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
},
|
|
4
|
+
target: "kotlin",
|
|
5
|
+
client: "okhttp",
|
|
6
|
+
title: "OkHttp",
|
|
7
|
+
generate(request) {
|
|
8
|
+
return convertWithHttpSnippetLite(okhttp, request);
|
|
9
|
+
}
|
|
15
10
|
};
|
|
16
|
-
|
|
17
|
-
|
|
11
|
+
export {
|
|
12
|
+
kotlinOkhttp
|
|
13
|
+
};
|
|
14
|
+
//# sourceMappingURL=okhttp.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/plugins/kotlin/okhttp/okhttp.ts"],
|
|
4
|
+
"sourcesContent": ["import { okhttp } from '@/httpsnippet-lite/esm/targets/kotlin/okhttp/client'\nimport { convertWithHttpSnippetLite } from '@/utils/convertWithHttpSnippetLite'\nimport type { Plugin } from '@scalar/types/snippetz'\n\n/**\n * kotlin/okhttp\n */\nexport const kotlinOkhttp: Plugin = {\n target: 'kotlin',\n client: 'okhttp',\n title: 'OkHttp',\n generate(request) {\n // TODO: Write an own converter\n return convertWithHttpSnippetLite(okhttp, request)\n },\n}\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,cAAc;AACvB,SAAS,kCAAkC;AAMpC,MAAM,eAAuB;AAAA,EAClC,QAAQ;AAAA,EACR,QAAQ;AAAA,EACR,OAAO;AAAA,EACP,SAAS,SAAS;AAEhB,WAAO,2BAA2B,QAAQ,OAAO;AAAA,EACnD;AACF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
import { describe, expect, it } from "vitest";
|
|
2
|
+
import { kotlinOkhttp } from "./okhttp.js";
|
|
3
|
+
describe("kotlinOkhttp", () => {
|
|
4
|
+
it("returns a basic request", () => {
|
|
5
|
+
const result = kotlinOkhttp.generate({
|
|
6
|
+
url: "https://example.com"
|
|
7
|
+
});
|
|
8
|
+
expect(result).toBe(`val client = OkHttpClient()
|
|
9
|
+
|
|
10
|
+
val request = Request.Builder()
|
|
11
|
+
.url("https://example.com")
|
|
12
|
+
.get()
|
|
13
|
+
.build()
|
|
14
|
+
|
|
15
|
+
val response = client.newCall(request).execute()`);
|
|
16
|
+
});
|
|
17
|
+
it("returns a POST request", () => {
|
|
18
|
+
const result = kotlinOkhttp.generate({
|
|
19
|
+
url: "https://example.com",
|
|
20
|
+
method: "post"
|
|
21
|
+
});
|
|
22
|
+
expect(result).toBe(`val client = OkHttpClient()
|
|
23
|
+
|
|
24
|
+
val request = Request.Builder()
|
|
25
|
+
.url("https://example.com")
|
|
26
|
+
.post(null)
|
|
27
|
+
.build()
|
|
28
|
+
|
|
29
|
+
val response = client.newCall(request).execute()`);
|
|
30
|
+
});
|
|
31
|
+
it("has headers", () => {
|
|
32
|
+
const result = kotlinOkhttp.generate({
|
|
33
|
+
url: "https://example.com",
|
|
34
|
+
headers: [
|
|
35
|
+
{
|
|
36
|
+
name: "Content-Type",
|
|
37
|
+
value: "application/json"
|
|
38
|
+
}
|
|
39
|
+
]
|
|
40
|
+
});
|
|
41
|
+
expect(result).toBe(`val client = OkHttpClient()
|
|
42
|
+
|
|
43
|
+
val request = Request.Builder()
|
|
44
|
+
.url("https://example.com")
|
|
45
|
+
.get()
|
|
46
|
+
.addHeader("Content-Type", "application/json")
|
|
47
|
+
.build()
|
|
48
|
+
|
|
49
|
+
val response = client.newCall(request).execute()`);
|
|
50
|
+
});
|
|
51
|
+
it("handles multipart form data with files", () => {
|
|
52
|
+
const result = kotlinOkhttp.generate({
|
|
53
|
+
url: "https://example.com",
|
|
54
|
+
method: "POST",
|
|
55
|
+
postData: {
|
|
56
|
+
mimeType: "multipart/form-data",
|
|
57
|
+
params: [
|
|
58
|
+
{
|
|
59
|
+
name: "file",
|
|
60
|
+
fileName: "test.txt"
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
name: "field",
|
|
64
|
+
value: "value"
|
|
65
|
+
}
|
|
66
|
+
]
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
expect(result).toBe(`val client = OkHttpClient()
|
|
70
|
+
|
|
71
|
+
val body = MultipartBody.Builder()
|
|
72
|
+
.setType(MultipartBody.FORM)
|
|
73
|
+
.addFormDataPart("file", "test.txt", RequestBody.create(MediaType.parse("application/octet-stream"), File("test.txt")))
|
|
74
|
+
.addFormDataPart("field", "value")
|
|
75
|
+
.build()
|
|
76
|
+
|
|
77
|
+
val request = Request.Builder()
|
|
78
|
+
.url("https://example.com")
|
|
79
|
+
.post(body)
|
|
80
|
+
.build()
|
|
81
|
+
|
|
82
|
+
val response = client.newCall(request).execute()`);
|
|
83
|
+
});
|
|
84
|
+
it("handles binary data", () => {
|
|
85
|
+
const result = kotlinOkhttp.generate({
|
|
86
|
+
url: "https://example.com",
|
|
87
|
+
method: "POST",
|
|
88
|
+
postData: {
|
|
89
|
+
mimeType: "application/octet-stream",
|
|
90
|
+
text: "binary content"
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
expect(result).toBe(`val client = OkHttpClient()
|
|
94
|
+
|
|
95
|
+
val mediaType = MediaType.parse("application/octet-stream")
|
|
96
|
+
val body = RequestBody.create(mediaType, "binary content")
|
|
97
|
+
val request = Request.Builder()
|
|
98
|
+
.url("https://example.com")
|
|
99
|
+
.post(body)
|
|
100
|
+
.build()
|
|
101
|
+
|
|
102
|
+
val response = client.newCall(request).execute()`);
|
|
103
|
+
});
|
|
104
|
+
it("handles special characters in URL", () => {
|
|
105
|
+
const result = kotlinOkhttp.generate({
|
|
106
|
+
url: "https://example.com/path with spaces/[brackets]"
|
|
107
|
+
});
|
|
108
|
+
expect(result).toBe(`val client = OkHttpClient()
|
|
109
|
+
|
|
110
|
+
val request = Request.Builder()
|
|
111
|
+
.url("https://example.com/path%20with%20spaces/[brackets]")
|
|
112
|
+
.get()
|
|
113
|
+
.build()
|
|
114
|
+
|
|
115
|
+
val response = client.newCall(request).execute()`);
|
|
116
|
+
});
|
|
117
|
+
it("handles multiple headers with same name", () => {
|
|
118
|
+
const result = kotlinOkhttp.generate({
|
|
119
|
+
url: "https://example.com",
|
|
120
|
+
headers: [
|
|
121
|
+
{ name: "X-Custom", value: "value1" },
|
|
122
|
+
{ name: "X-Custom", value: "value2" }
|
|
123
|
+
]
|
|
124
|
+
});
|
|
125
|
+
expect(result).toBe(`val client = OkHttpClient()
|
|
126
|
+
|
|
127
|
+
val request = Request.Builder()
|
|
128
|
+
.url("https://example.com")
|
|
129
|
+
.get()
|
|
130
|
+
.addHeader("X-Custom", "value2")
|
|
131
|
+
.build()
|
|
132
|
+
|
|
133
|
+
val response = client.newCall(request).execute()`);
|
|
134
|
+
});
|
|
135
|
+
it("handles headers with empty values", () => {
|
|
136
|
+
const result = kotlinOkhttp.generate({
|
|
137
|
+
url: "https://example.com",
|
|
138
|
+
headers: [{ name: "X-Empty", value: "" }]
|
|
139
|
+
});
|
|
140
|
+
expect(result).toBe(`val client = OkHttpClient()
|
|
141
|
+
|
|
142
|
+
val request = Request.Builder()
|
|
143
|
+
.url("https://example.com")
|
|
144
|
+
.get()
|
|
145
|
+
.addHeader("X-Empty", "")
|
|
146
|
+
.build()
|
|
147
|
+
|
|
148
|
+
val response = client.newCall(request).execute()`);
|
|
149
|
+
});
|
|
150
|
+
it("handles query string parameters", () => {
|
|
151
|
+
const result = kotlinOkhttp.generate({
|
|
152
|
+
url: "https://example.com/api?param1=value1¶m2=special value¶m3=123"
|
|
153
|
+
});
|
|
154
|
+
expect(result).toBe(`val client = OkHttpClient()
|
|
155
|
+
|
|
156
|
+
val request = Request.Builder()
|
|
157
|
+
.url("https://example.com/api?param1=value1¶m2=special%20value¶m3=123")
|
|
158
|
+
.get()
|
|
159
|
+
.build()
|
|
160
|
+
|
|
161
|
+
val response = client.newCall(request).execute()`);
|
|
162
|
+
});
|
|
163
|
+
});
|
|
164
|
+
//# sourceMappingURL=okhttp.test.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/plugins/kotlin/okhttp/okhttp.test.ts"],
|
|
4
|
+
"sourcesContent": ["import { describe, expect, it } from 'vitest'\n\nimport { kotlinOkhttp } from './okhttp'\n\ndescribe('kotlinOkhttp', () => {\n it('returns a basic request', () => {\n const result = kotlinOkhttp.generate({\n url: 'https://example.com',\n })\n\n expect(result).toBe(`val client = OkHttpClient()\n\nval request = Request.Builder()\n .url(\"https://example.com\")\n .get()\n .build()\n\nval response = client.newCall(request).execute()`)\n })\n\n it('returns a POST request', () => {\n const result = kotlinOkhttp.generate({\n url: 'https://example.com',\n method: 'post',\n })\n\n expect(result).toBe(`val client = OkHttpClient()\n\nval request = Request.Builder()\n .url(\"https://example.com\")\n .post(null)\n .build()\n\nval response = client.newCall(request).execute()`)\n })\n\n it('has headers', () => {\n const result = kotlinOkhttp.generate({\n url: 'https://example.com',\n headers: [\n {\n name: 'Content-Type',\n value: 'application/json',\n },\n ],\n })\n expect(result).toBe(`val client = OkHttpClient()\n\nval request = Request.Builder()\n .url(\"https://example.com\")\n .get()\n .addHeader(\"Content-Type\", \"application/json\")\n .build()\n\nval response = client.newCall(request).execute()`)\n })\n\n it('handles multipart form data with files', () => {\n const result = kotlinOkhttp.generate({\n url: 'https://example.com',\n method: 'POST',\n postData: {\n mimeType: 'multipart/form-data',\n params: [\n {\n name: 'file',\n fileName: 'test.txt',\n },\n {\n name: 'field',\n value: 'value',\n },\n ],\n },\n })\n\n expect(result).toBe(`val client = OkHttpClient()\n\nval body = MultipartBody.Builder()\n .setType(MultipartBody.FORM)\n .addFormDataPart(\"file\", \"test.txt\", RequestBody.create(MediaType.parse(\"application/octet-stream\"), File(\"test.txt\")))\n .addFormDataPart(\"field\", \"value\")\n .build()\n\nval request = Request.Builder()\n .url(\"https://example.com\")\n .post(body)\n .build()\n\nval response = client.newCall(request).execute()`)\n })\n\n it('handles binary data', () => {\n const result = kotlinOkhttp.generate({\n url: 'https://example.com',\n method: 'POST',\n postData: {\n mimeType: 'application/octet-stream',\n text: 'binary content',\n },\n })\n\n expect(result).toBe(`val client = OkHttpClient()\n\nval mediaType = MediaType.parse(\"application/octet-stream\")\nval body = RequestBody.create(mediaType, \"binary content\")\nval request = Request.Builder()\n .url(\"https://example.com\")\n .post(body)\n .build()\n\nval response = client.newCall(request).execute()`)\n })\n\n it('handles special characters in URL', () => {\n const result = kotlinOkhttp.generate({\n url: 'https://example.com/path with spaces/[brackets]',\n })\n\n expect(result).toBe(`val client = OkHttpClient()\n\nval request = Request.Builder()\n .url(\"https://example.com/path%20with%20spaces/[brackets]\")\n .get()\n .build()\n\nval response = client.newCall(request).execute()`)\n })\n\n it('handles multiple headers with same name', () => {\n const result = kotlinOkhttp.generate({\n url: 'https://example.com',\n headers: [\n { name: 'X-Custom', value: 'value1' },\n { name: 'X-Custom', value: 'value2' },\n ],\n })\n\n expect(result).toBe(`val client = OkHttpClient()\n\nval request = Request.Builder()\n .url(\"https://example.com\")\n .get()\n .addHeader(\"X-Custom\", \"value2\")\n .build()\n\nval response = client.newCall(request).execute()`)\n })\n\n it('handles headers with empty values', () => {\n const result = kotlinOkhttp.generate({\n url: 'https://example.com',\n headers: [{ name: 'X-Empty', value: '' }],\n })\n\n expect(result).toBe(`val client = OkHttpClient()\n\nval request = Request.Builder()\n .url(\"https://example.com\")\n .get()\n .addHeader(\"X-Empty\", \"\")\n .build()\n\nval response = client.newCall(request).execute()`)\n })\n\n it('handles query string parameters', () => {\n const result = kotlinOkhttp.generate({\n url: 'https://example.com/api?param1=value1¶m2=special value¶m3=123',\n })\n\n expect(result).toBe(`val client = OkHttpClient()\n\nval request = Request.Builder()\n .url(\"https://example.com/api?param1=value1¶m2=special%20value¶m3=123\")\n .get()\n .build()\n\nval response = client.newCall(request).execute()`)\n })\n})\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,UAAU,QAAQ,UAAU;AAErC,SAAS,oBAAoB;AAE7B,SAAS,gBAAgB,MAAM;AAC7B,KAAG,2BAA2B,MAAM;AAClC,UAAM,SAAS,aAAa,SAAS;AAAA,MACnC,KAAK;AAAA,IACP,CAAC;AAED,WAAO,MAAM,EAAE,KAAK;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,iDAOyB;AAAA,EAC/C,CAAC;AAED,KAAG,0BAA0B,MAAM;AACjC,UAAM,SAAS,aAAa,SAAS;AAAA,MACnC,KAAK;AAAA,MACL,QAAQ;AAAA,IACV,CAAC;AAED,WAAO,MAAM,EAAE,KAAK;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,iDAOyB;AAAA,EAC/C,CAAC;AAED,KAAG,eAAe,MAAM;AACtB,UAAM,SAAS,aAAa,SAAS;AAAA,MACnC,KAAK;AAAA,MACL,SAAS;AAAA,QACP;AAAA,UACE,MAAM;AAAA,UACN,OAAO;AAAA,QACT;AAAA,MACF;AAAA,IACF,CAAC;AACD,WAAO,MAAM,EAAE,KAAK;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,iDAQyB;AAAA,EAC/C,CAAC;AAED,KAAG,0CAA0C,MAAM;AACjD,UAAM,SAAS,aAAa,SAAS;AAAA,MACnC,KAAK;AAAA,MACL,QAAQ;AAAA,MACR,UAAU;AAAA,QACR,UAAU;AAAA,QACV,QAAQ;AAAA,UACN;AAAA,YACE,MAAM;AAAA,YACN,UAAU;AAAA,UACZ;AAAA,UACA;AAAA,YACE,MAAM;AAAA,YACN,OAAO;AAAA,UACT;AAAA,QACF;AAAA,MACF;AAAA,IACF,CAAC;AAED,WAAO,MAAM,EAAE,KAAK;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,iDAayB;AAAA,EAC/C,CAAC;AAED,KAAG,uBAAuB,MAAM;AAC9B,UAAM,SAAS,aAAa,SAAS;AAAA,MACnC,KAAK;AAAA,MACL,QAAQ;AAAA,MACR,UAAU;AAAA,QACR,UAAU;AAAA,QACV,MAAM;AAAA,MACR;AAAA,IACF,CAAC;AAED,WAAO,MAAM,EAAE,KAAK;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,iDASyB;AAAA,EAC/C,CAAC;AAED,KAAG,qCAAqC,MAAM;AAC5C,UAAM,SAAS,aAAa,SAAS;AAAA,MACnC,KAAK;AAAA,IACP,CAAC;AAED,WAAO,MAAM,EAAE,KAAK;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,iDAOyB;AAAA,EAC/C,CAAC;AAED,KAAG,2CAA2C,MAAM;AAClD,UAAM,SAAS,aAAa,SAAS;AAAA,MACnC,KAAK;AAAA,MACL,SAAS;AAAA,QACP,EAAE,MAAM,YAAY,OAAO,SAAS;AAAA,QACpC,EAAE,MAAM,YAAY,OAAO,SAAS;AAAA,MACtC;AAAA,IACF,CAAC;AAED,WAAO,MAAM,EAAE,KAAK;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,iDAQyB;AAAA,EAC/C,CAAC;AAED,KAAG,qCAAqC,MAAM;AAC5C,UAAM,SAAS,aAAa,SAAS;AAAA,MACnC,KAAK;AAAA,MACL,SAAS,CAAC,EAAE,MAAM,WAAW,OAAO,GAAG,CAAC;AAAA,IAC1C,CAAC;AAED,WAAO,MAAM,EAAE,KAAK;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,iDAQyB;AAAA,EAC/C,CAAC;AAED,KAAG,mCAAmC,MAAM;AAC1C,UAAM,SAAS,aAAa,SAAS;AAAA,MACnC,KAAK;AAAA,IACP,CAAC;AAED,WAAO,MAAM,EAAE,KAAK;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,iDAOyB;AAAA,EAC/C,CAAC;AACH,CAAC;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,17 +1,14 @@
|
|
|
1
|
-
import { axios } from
|
|
2
|
-
import { convertWithHttpSnippetLite } from
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* node/axios
|
|
6
|
-
*/
|
|
1
|
+
import { axios } from "../../../httpsnippet-lite/esm/targets/node/axios/client.js";
|
|
2
|
+
import { convertWithHttpSnippetLite } from "../../../utils/convertWithHttpSnippetLite.js";
|
|
7
3
|
const nodeAxios = {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
},
|
|
4
|
+
target: "node",
|
|
5
|
+
client: "axios",
|
|
6
|
+
title: "Axios",
|
|
7
|
+
generate(request) {
|
|
8
|
+
return convertWithHttpSnippetLite(axios, request);
|
|
9
|
+
}
|
|
15
10
|
};
|
|
16
|
-
|
|
17
|
-
|
|
11
|
+
export {
|
|
12
|
+
nodeAxios
|
|
13
|
+
};
|
|
14
|
+
//# sourceMappingURL=axios.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/plugins/node/axios/axios.ts"],
|
|
4
|
+
"sourcesContent": ["import { axios } from '@/httpsnippet-lite/esm/targets/node/axios/client'\nimport { convertWithHttpSnippetLite } from '@/utils/convertWithHttpSnippetLite'\nimport type { Plugin } from '@scalar/types/snippetz'\n\n/**\n * node/axios\n */\nexport const nodeAxios: Plugin = {\n target: 'node',\n client: 'axios',\n title: 'Axios',\n generate(request) {\n // TODO: Write an own converter\n return convertWithHttpSnippetLite(axios, request)\n },\n}\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,aAAa;AACtB,SAAS,kCAAkC;AAMpC,MAAM,YAAoB;AAAA,EAC/B,QAAQ;AAAA,EACR,QAAQ;AAAA,EACR,OAAO;AAAA,EACP,SAAS,SAAS;AAEhB,WAAO,2BAA2B,OAAO,OAAO;AAAA,EAClD;AACF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export
|
|
1
|
+
export * from "./axios.js";
|
|
2
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fetch.d.ts","sourceRoot":"","sources":["../../../../src/plugins/node/fetch/fetch.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAA;AAEpD;;GAEG;AACH,eAAO,MAAM,SAAS,EAAE,
|
|
1
|
+
{"version":3,"file":"fetch.d.ts","sourceRoot":"","sources":["../../../../src/plugins/node/fetch/fetch.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAA;AAEpD;;GAEG;AACH,eAAO,MAAM,SAAS,EAAE,MA4FvB,CAAA"}
|