@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 +1,2 @@
|
|
|
1
|
-
export
|
|
1
|
+
export * from "./wget.js";
|
|
2
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -1,17 +1,14 @@
|
|
|
1
|
-
import { wget } from
|
|
2
|
-
import { convertWithHttpSnippetLite } from
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* shell/wget
|
|
6
|
-
*/
|
|
1
|
+
import { wget } from "../../../httpsnippet-lite/esm/targets/shell/wget/client.js";
|
|
2
|
+
import { convertWithHttpSnippetLite } from "../../../utils/convertWithHttpSnippetLite.js";
|
|
7
3
|
const shellWget = {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
},
|
|
4
|
+
target: "shell",
|
|
5
|
+
client: "wget",
|
|
6
|
+
title: "Wget",
|
|
7
|
+
generate(request) {
|
|
8
|
+
return convertWithHttpSnippetLite(wget, request);
|
|
9
|
+
}
|
|
15
10
|
};
|
|
16
|
-
|
|
17
|
-
|
|
11
|
+
export {
|
|
12
|
+
shellWget
|
|
13
|
+
};
|
|
14
|
+
//# sourceMappingURL=wget.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/plugins/shell/wget/wget.ts"],
|
|
4
|
+
"sourcesContent": ["import { wget } from '@/httpsnippet-lite/esm/targets/shell/wget/client'\nimport { convertWithHttpSnippetLite } from '@/utils/convertWithHttpSnippetLite'\nimport type { Plugin } from '@scalar/types/snippetz'\n\n/**\n * shell/wget\n */\nexport const shellWget: Plugin = {\n target: 'shell',\n client: 'wget',\n title: 'Wget',\n generate(request) {\n // TODO: Write an own converter\n return convertWithHttpSnippetLite(wget, request)\n },\n}\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,YAAY;AACrB,SAAS,kCAAkC;AAMpC,MAAM,YAAoB;AAAA,EAC/B,QAAQ;AAAA,EACR,QAAQ;AAAA,EACR,OAAO;AAAA,EACP,SAAS,SAAS;AAEhB,WAAO,2BAA2B,MAAM,OAAO;AAAA,EACjD;AACF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import { describe, expect, it } from "vitest";
|
|
2
|
+
import { shellWget } from "./wget.js";
|
|
3
|
+
describe("shellWget", () => {
|
|
4
|
+
it("returns a basic request", () => {
|
|
5
|
+
const result = shellWget.generate({
|
|
6
|
+
url: "https://example.com"
|
|
7
|
+
});
|
|
8
|
+
expect(result).toBe(`wget --quiet \\
|
|
9
|
+
--method GET \\
|
|
10
|
+
--output-document \\
|
|
11
|
+
- https://example.com`);
|
|
12
|
+
});
|
|
13
|
+
it("returns a POST request", () => {
|
|
14
|
+
const result = shellWget.generate({
|
|
15
|
+
url: "https://example.com",
|
|
16
|
+
method: "post"
|
|
17
|
+
});
|
|
18
|
+
expect(result).toBe(`wget --quiet \\
|
|
19
|
+
--method POST \\
|
|
20
|
+
--output-document \\
|
|
21
|
+
- https://example.com`);
|
|
22
|
+
});
|
|
23
|
+
it("has headers", () => {
|
|
24
|
+
const result = shellWget.generate({
|
|
25
|
+
url: "https://example.com",
|
|
26
|
+
headers: [
|
|
27
|
+
{
|
|
28
|
+
name: "Content-Type",
|
|
29
|
+
value: "application/json"
|
|
30
|
+
}
|
|
31
|
+
]
|
|
32
|
+
});
|
|
33
|
+
expect(result).toBe(`wget --quiet \\
|
|
34
|
+
--method GET \\
|
|
35
|
+
--header 'Content-Type: application/json' \\
|
|
36
|
+
--output-document \\
|
|
37
|
+
- https://example.com`);
|
|
38
|
+
});
|
|
39
|
+
it.skip("handles multipart form data with files", () => {
|
|
40
|
+
const result = shellWget.generate({
|
|
41
|
+
url: "https://example.com",
|
|
42
|
+
method: "POST",
|
|
43
|
+
postData: {
|
|
44
|
+
mimeType: "multipart/form-data",
|
|
45
|
+
params: [
|
|
46
|
+
{
|
|
47
|
+
name: "file",
|
|
48
|
+
fileName: "test.txt"
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
name: "field",
|
|
52
|
+
value: "value"
|
|
53
|
+
}
|
|
54
|
+
]
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
expect(result).toBe(`wget --quiet \\
|
|
58
|
+
--method POST \\
|
|
59
|
+
--body-file='test.txt' \\
|
|
60
|
+
--body-data 'field=value' \\
|
|
61
|
+
--output-document \\
|
|
62
|
+
- https://example.com`);
|
|
63
|
+
});
|
|
64
|
+
it.skip("handles url-encoded form data with special characters", () => {
|
|
65
|
+
const result = shellWget.generate({
|
|
66
|
+
url: "https://example.com",
|
|
67
|
+
method: "POST",
|
|
68
|
+
postData: {
|
|
69
|
+
mimeType: "application/x-www-form-urlencoded",
|
|
70
|
+
params: [
|
|
71
|
+
{
|
|
72
|
+
name: "special chars!@#",
|
|
73
|
+
value: "value"
|
|
74
|
+
}
|
|
75
|
+
]
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
expect(result).toBe(`wget --quiet \\
|
|
79
|
+
--method POST \\
|
|
80
|
+
--body-data 'special%20chars!%40%23=value' \\
|
|
81
|
+
--output-document \\
|
|
82
|
+
- https://example.com`);
|
|
83
|
+
});
|
|
84
|
+
it("handles binary data", () => {
|
|
85
|
+
const result = shellWget.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(`wget --quiet \\
|
|
94
|
+
--method POST \\
|
|
95
|
+
--body-data 'binary content' \\
|
|
96
|
+
--output-document \\
|
|
97
|
+
- https://example.com`);
|
|
98
|
+
});
|
|
99
|
+
it("handles special characters in URL", () => {
|
|
100
|
+
const result = shellWget.generate({
|
|
101
|
+
url: "https://example.com/path with spaces/[brackets]"
|
|
102
|
+
});
|
|
103
|
+
expect(result).toBe(`wget --quiet \\
|
|
104
|
+
--method GET \\
|
|
105
|
+
--output-document \\
|
|
106
|
+
- 'https://example.com/path%20with%20spaces/[brackets]'`);
|
|
107
|
+
});
|
|
108
|
+
it("handles multiple headers with same name", () => {
|
|
109
|
+
const result = shellWget.generate({
|
|
110
|
+
url: "https://example.com",
|
|
111
|
+
headers: [
|
|
112
|
+
{ name: "X-Custom", value: "value1" },
|
|
113
|
+
{ name: "X-Custom", value: "value2" }
|
|
114
|
+
]
|
|
115
|
+
});
|
|
116
|
+
expect(result).toBe(`wget --quiet \\
|
|
117
|
+
--method GET \\
|
|
118
|
+
--header 'X-Custom: value2' \\
|
|
119
|
+
--output-document \\
|
|
120
|
+
- https://example.com`);
|
|
121
|
+
});
|
|
122
|
+
it("handles headers with empty values", () => {
|
|
123
|
+
const result = shellWget.generate({
|
|
124
|
+
url: "https://example.com",
|
|
125
|
+
headers: [{ name: "X-Empty", value: "" }]
|
|
126
|
+
});
|
|
127
|
+
expect(result).toBe(`wget --quiet \\
|
|
128
|
+
--method GET \\
|
|
129
|
+
--header 'X-Empty: ' \\
|
|
130
|
+
--output-document \\
|
|
131
|
+
- https://example.com`);
|
|
132
|
+
});
|
|
133
|
+
it("handles query string parameters", () => {
|
|
134
|
+
const result = shellWget.generate({
|
|
135
|
+
url: "https://example.com/api?param1=value1¶m2=special value¶m3=123"
|
|
136
|
+
});
|
|
137
|
+
expect(result).toBe(`wget --quiet \\
|
|
138
|
+
--method GET \\
|
|
139
|
+
--output-document \\
|
|
140
|
+
- 'https://example.com/api?param1=value1¶m2=special%20value¶m3=123'`);
|
|
141
|
+
});
|
|
142
|
+
});
|
|
143
|
+
//# sourceMappingURL=wget.test.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/plugins/shell/wget/wget.test.ts"],
|
|
4
|
+
"sourcesContent": ["import { describe, expect, it } from 'vitest'\n\nimport { shellWget } from './wget'\n\ndescribe('shellWget', () => {\n it('returns a basic request', () => {\n const result = shellWget.generate({\n url: 'https://example.com',\n })\n\n expect(result).toBe(`wget --quiet \\\\\n --method GET \\\\\n --output-document \\\\\n - https://example.com`)\n })\n\n it('returns a POST request', () => {\n const result = shellWget.generate({\n url: 'https://example.com',\n method: 'post',\n })\n\n expect(result).toBe(`wget --quiet \\\\\n --method POST \\\\\n --output-document \\\\\n - https://example.com`)\n })\n\n it('has headers', () => {\n const result = shellWget.generate({\n url: 'https://example.com',\n headers: [\n {\n name: 'Content-Type',\n value: 'application/json',\n },\n ],\n })\n expect(result).toBe(`wget --quiet \\\\\n --method GET \\\\\n --header 'Content-Type: application/json' \\\\\n --output-document \\\\\n - https://example.com`)\n })\n\n it.skip('handles multipart form data with files', () => {\n const result = shellWget.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(`wget --quiet \\\\\n --method POST \\\\\n --body-file='test.txt' \\\\\n --body-data 'field=value' \\\\\n --output-document \\\\\n - https://example.com`)\n })\n\n it.skip('handles url-encoded form data with special characters', () => {\n const result = shellWget.generate({\n url: 'https://example.com',\n method: 'POST',\n postData: {\n mimeType: 'application/x-www-form-urlencoded',\n params: [\n {\n name: 'special chars!@#',\n value: 'value',\n },\n ],\n },\n })\n\n expect(result).toBe(`wget --quiet \\\\\n --method POST \\\\\n --body-data 'special%20chars!%40%23=value' \\\\\n --output-document \\\\\n - https://example.com`)\n })\n\n it('handles binary data', () => {\n const result = shellWget.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(`wget --quiet \\\\\n --method POST \\\\\n --body-data 'binary content' \\\\\n --output-document \\\\\n - https://example.com`)\n })\n\n it('handles special characters in URL', () => {\n const result = shellWget.generate({\n url: 'https://example.com/path with spaces/[brackets]',\n })\n\n expect(result).toBe(`wget --quiet \\\\\n --method GET \\\\\n --output-document \\\\\n - 'https://example.com/path%20with%20spaces/[brackets]'`)\n })\n\n it('handles multiple headers with same name', () => {\n const result = shellWget.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(`wget --quiet \\\\\n --method GET \\\\\n --header 'X-Custom: value2' \\\\\n --output-document \\\\\n - https://example.com`)\n })\n\n it('handles headers with empty values', () => {\n const result = shellWget.generate({\n url: 'https://example.com',\n headers: [{ name: 'X-Empty', value: '' }],\n })\n\n expect(result).toBe(`wget --quiet \\\\\n --method GET \\\\\n --header 'X-Empty: ' \\\\\n --output-document \\\\\n - https://example.com`)\n })\n\n it('handles query string parameters', () => {\n const result = shellWget.generate({\n url: 'https://example.com/api?param1=value1¶m2=special value¶m3=123',\n })\n\n expect(result).toBe(`wget --quiet \\\\\n --method GET \\\\\n --output-document \\\\\n - 'https://example.com/api?param1=value1¶m2=special%20value¶m3=123'`)\n })\n})\n"],
|
|
5
|
+
"mappings": "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",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export
|
|
1
|
+
export * from "./nsurlsession.js";
|
|
2
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -1,17 +1,14 @@
|
|
|
1
|
-
import { nsurlsession } from
|
|
2
|
-
import { convertWithHttpSnippetLite } from
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* swift/nsurlsession
|
|
6
|
-
*/
|
|
1
|
+
import { nsurlsession } from "../../../httpsnippet-lite/esm/targets/swift/nsurlsession/client.js";
|
|
2
|
+
import { convertWithHttpSnippetLite } from "../../../utils/convertWithHttpSnippetLite.js";
|
|
7
3
|
const swiftNsurlsession = {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
},
|
|
4
|
+
target: "swift",
|
|
5
|
+
client: "nsurlsession",
|
|
6
|
+
title: "NSURLSession",
|
|
7
|
+
generate(request) {
|
|
8
|
+
return convertWithHttpSnippetLite(nsurlsession, request);
|
|
9
|
+
}
|
|
15
10
|
};
|
|
16
|
-
|
|
17
|
-
|
|
11
|
+
export {
|
|
12
|
+
swiftNsurlsession
|
|
13
|
+
};
|
|
14
|
+
//# sourceMappingURL=nsurlsession.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/plugins/swift/nsurlsession/nsurlsession.ts"],
|
|
4
|
+
"sourcesContent": ["import { nsurlsession } from '@/httpsnippet-lite/esm/targets/swift/nsurlsession/client'\nimport { convertWithHttpSnippetLite } from '@/utils/convertWithHttpSnippetLite'\nimport type { Plugin } from '@scalar/types/snippetz'\n\n/**\n * swift/nsurlsession\n */\nexport const swiftNsurlsession: Plugin = {\n target: 'swift',\n client: 'nsurlsession',\n title: 'NSURLSession',\n generate(request) {\n // TODO: Write an own converter\n return convertWithHttpSnippetLite(nsurlsession, request)\n },\n}\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,oBAAoB;AAC7B,SAAS,kCAAkC;AAMpC,MAAM,oBAA4B;AAAA,EACvC,QAAQ;AAAA,EACR,QAAQ;AAAA,EACR,OAAO;AAAA,EACP,SAAS,SAAS;AAEhB,WAAO,2BAA2B,cAAc,OAAO;AAAA,EACzD;AACF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,344 @@
|
|
|
1
|
+
import { describe, expect, it } from "vitest";
|
|
2
|
+
import { swiftNsurlsession } from "./nsurlsession.js";
|
|
3
|
+
describe("swiftNsurlsession", () => {
|
|
4
|
+
it("returns a basic request", () => {
|
|
5
|
+
const result = swiftNsurlsession.generate({
|
|
6
|
+
url: "https://example.com"
|
|
7
|
+
});
|
|
8
|
+
expect(result).toBe(
|
|
9
|
+
`import Foundation
|
|
10
|
+
|
|
11
|
+
let request = NSMutableURLRequest(url: NSURL(string: "https://example.com")! as URL,
|
|
12
|
+
cachePolicy: .useProtocolCachePolicy,
|
|
13
|
+
timeoutInterval: 10.0)
|
|
14
|
+
request.httpMethod = "GET"
|
|
15
|
+
|
|
16
|
+
let session = URLSession.shared
|
|
17
|
+
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
|
|
18
|
+
if (error != nil) {
|
|
19
|
+
print(error as Any)
|
|
20
|
+
} else {
|
|
21
|
+
let httpResponse = response as? HTTPURLResponse
|
|
22
|
+
print(httpResponse)
|
|
23
|
+
}
|
|
24
|
+
})
|
|
25
|
+
|
|
26
|
+
dataTask.resume()`
|
|
27
|
+
);
|
|
28
|
+
});
|
|
29
|
+
it("returns a POST request", () => {
|
|
30
|
+
const result = swiftNsurlsession.generate({
|
|
31
|
+
url: "https://example.com",
|
|
32
|
+
method: "post"
|
|
33
|
+
});
|
|
34
|
+
expect(result).toBe(
|
|
35
|
+
`import Foundation
|
|
36
|
+
|
|
37
|
+
let request = NSMutableURLRequest(url: NSURL(string: "https://example.com")! as URL,
|
|
38
|
+
cachePolicy: .useProtocolCachePolicy,
|
|
39
|
+
timeoutInterval: 10.0)
|
|
40
|
+
request.httpMethod = "POST"
|
|
41
|
+
|
|
42
|
+
let session = URLSession.shared
|
|
43
|
+
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
|
|
44
|
+
if (error != nil) {
|
|
45
|
+
print(error as Any)
|
|
46
|
+
} else {
|
|
47
|
+
let httpResponse = response as? HTTPURLResponse
|
|
48
|
+
print(httpResponse)
|
|
49
|
+
}
|
|
50
|
+
})
|
|
51
|
+
|
|
52
|
+
dataTask.resume()`
|
|
53
|
+
);
|
|
54
|
+
});
|
|
55
|
+
it("has headers", () => {
|
|
56
|
+
const result = swiftNsurlsession.generate({
|
|
57
|
+
url: "https://example.com",
|
|
58
|
+
headers: [
|
|
59
|
+
{
|
|
60
|
+
name: "Content-Type",
|
|
61
|
+
value: "application/json"
|
|
62
|
+
}
|
|
63
|
+
]
|
|
64
|
+
});
|
|
65
|
+
expect(result).toBe(
|
|
66
|
+
`import Foundation
|
|
67
|
+
|
|
68
|
+
let headers = ["Content-Type": "application/json"]
|
|
69
|
+
|
|
70
|
+
let request = NSMutableURLRequest(url: NSURL(string: "https://example.com")! as URL,
|
|
71
|
+
cachePolicy: .useProtocolCachePolicy,
|
|
72
|
+
timeoutInterval: 10.0)
|
|
73
|
+
request.httpMethod = "GET"
|
|
74
|
+
request.allHTTPHeaderFields = headers
|
|
75
|
+
|
|
76
|
+
let session = URLSession.shared
|
|
77
|
+
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
|
|
78
|
+
if (error != nil) {
|
|
79
|
+
print(error as Any)
|
|
80
|
+
} else {
|
|
81
|
+
let httpResponse = response as? HTTPURLResponse
|
|
82
|
+
print(httpResponse)
|
|
83
|
+
}
|
|
84
|
+
})
|
|
85
|
+
|
|
86
|
+
dataTask.resume()`
|
|
87
|
+
);
|
|
88
|
+
});
|
|
89
|
+
it("handles multipart form data with files", () => {
|
|
90
|
+
const result = swiftNsurlsession.generate({
|
|
91
|
+
url: "https://example.com",
|
|
92
|
+
method: "POST",
|
|
93
|
+
postData: {
|
|
94
|
+
mimeType: "multipart/form-data",
|
|
95
|
+
params: [
|
|
96
|
+
{
|
|
97
|
+
name: "file",
|
|
98
|
+
fileName: "test.txt"
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
name: "field",
|
|
102
|
+
value: "value"
|
|
103
|
+
}
|
|
104
|
+
]
|
|
105
|
+
}
|
|
106
|
+
});
|
|
107
|
+
expect(result).toBe(
|
|
108
|
+
`import Foundation
|
|
109
|
+
let parameters = [
|
|
110
|
+
[
|
|
111
|
+
"name": "file",
|
|
112
|
+
"fileName": "test.txt"
|
|
113
|
+
],
|
|
114
|
+
[
|
|
115
|
+
"name": "field",
|
|
116
|
+
"value": "value"
|
|
117
|
+
]
|
|
118
|
+
]
|
|
119
|
+
|
|
120
|
+
let boundary = "undefined"
|
|
121
|
+
|
|
122
|
+
var body = ""
|
|
123
|
+
var error: NSError? = nil
|
|
124
|
+
for param in parameters {
|
|
125
|
+
let paramName = param["name"]!
|
|
126
|
+
body += "--\\(boundary)\\r\\n"
|
|
127
|
+
body += "Content-Disposition:form-data; name=\\"\\(paramName)\\""
|
|
128
|
+
if let filename = param["fileName"] {
|
|
129
|
+
let contentType = param["content-type"]!
|
|
130
|
+
let fileContent = String(contentsOfFile: filename, encoding: String.Encoding.utf8)
|
|
131
|
+
if (error != nil) {
|
|
132
|
+
print(error as Any)
|
|
133
|
+
}
|
|
134
|
+
body += "; filename=\\"\\(filename)\\"\\r\\n"
|
|
135
|
+
body += "Content-Type: \\(contentType)\\r\\n\\r\\n"
|
|
136
|
+
body += fileContent
|
|
137
|
+
} else if let paramValue = param["value"] {
|
|
138
|
+
body += "\\r\\n\\r\\n\\(paramValue)"
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
let request = NSMutableURLRequest(url: NSURL(string: "https://example.com")! as URL,
|
|
143
|
+
cachePolicy: .useProtocolCachePolicy,
|
|
144
|
+
timeoutInterval: 10.0)
|
|
145
|
+
request.httpMethod = "POST"
|
|
146
|
+
request.httpBody = postData as Data
|
|
147
|
+
|
|
148
|
+
let session = URLSession.shared
|
|
149
|
+
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
|
|
150
|
+
if (error != nil) {
|
|
151
|
+
print(error as Any)
|
|
152
|
+
} else {
|
|
153
|
+
let httpResponse = response as? HTTPURLResponse
|
|
154
|
+
print(httpResponse)
|
|
155
|
+
}
|
|
156
|
+
})
|
|
157
|
+
|
|
158
|
+
dataTask.resume()`
|
|
159
|
+
);
|
|
160
|
+
});
|
|
161
|
+
it("handles url-encoded form data with special characters", () => {
|
|
162
|
+
const result = swiftNsurlsession.generate({
|
|
163
|
+
url: "https://example.com",
|
|
164
|
+
method: "POST",
|
|
165
|
+
postData: {
|
|
166
|
+
mimeType: "application/x-www-form-urlencoded",
|
|
167
|
+
params: [
|
|
168
|
+
{
|
|
169
|
+
name: "special chars!@#",
|
|
170
|
+
value: "value"
|
|
171
|
+
}
|
|
172
|
+
]
|
|
173
|
+
}
|
|
174
|
+
});
|
|
175
|
+
expect(result).toBe(
|
|
176
|
+
`import Foundation
|
|
177
|
+
|
|
178
|
+
let postData = NSMutableData(data: "special chars!@#=value".data(using: String.Encoding.utf8)!)
|
|
179
|
+
|
|
180
|
+
let request = NSMutableURLRequest(url: NSURL(string: "https://example.com")! as URL,
|
|
181
|
+
cachePolicy: .useProtocolCachePolicy,
|
|
182
|
+
timeoutInterval: 10.0)
|
|
183
|
+
request.httpMethod = "POST"
|
|
184
|
+
request.httpBody = postData as Data
|
|
185
|
+
|
|
186
|
+
let session = URLSession.shared
|
|
187
|
+
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
|
|
188
|
+
if (error != nil) {
|
|
189
|
+
print(error as Any)
|
|
190
|
+
} else {
|
|
191
|
+
let httpResponse = response as? HTTPURLResponse
|
|
192
|
+
print(httpResponse)
|
|
193
|
+
}
|
|
194
|
+
})
|
|
195
|
+
|
|
196
|
+
dataTask.resume()`
|
|
197
|
+
);
|
|
198
|
+
});
|
|
199
|
+
it("handles binary data", () => {
|
|
200
|
+
const result = swiftNsurlsession.generate({
|
|
201
|
+
url: "https://example.com",
|
|
202
|
+
method: "POST",
|
|
203
|
+
postData: {
|
|
204
|
+
mimeType: "application/octet-stream",
|
|
205
|
+
text: "binary content"
|
|
206
|
+
}
|
|
207
|
+
});
|
|
208
|
+
expect(result).toBe(
|
|
209
|
+
`import Foundation
|
|
210
|
+
|
|
211
|
+
let postData = NSData(data: "binary content".data(using: String.Encoding.utf8)!)
|
|
212
|
+
|
|
213
|
+
let request = NSMutableURLRequest(url: NSURL(string: "https://example.com")! as URL,
|
|
214
|
+
cachePolicy: .useProtocolCachePolicy,
|
|
215
|
+
timeoutInterval: 10.0)
|
|
216
|
+
request.httpMethod = "POST"
|
|
217
|
+
request.httpBody = postData as Data
|
|
218
|
+
|
|
219
|
+
let session = URLSession.shared
|
|
220
|
+
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
|
|
221
|
+
if (error != nil) {
|
|
222
|
+
print(error as Any)
|
|
223
|
+
} else {
|
|
224
|
+
let httpResponse = response as? HTTPURLResponse
|
|
225
|
+
print(httpResponse)
|
|
226
|
+
}
|
|
227
|
+
})
|
|
228
|
+
|
|
229
|
+
dataTask.resume()`
|
|
230
|
+
);
|
|
231
|
+
});
|
|
232
|
+
it("handles special characters in URL", () => {
|
|
233
|
+
const result = swiftNsurlsession.generate({
|
|
234
|
+
url: "https://example.com/path with spaces/[brackets]"
|
|
235
|
+
});
|
|
236
|
+
expect(result).toBe(
|
|
237
|
+
`import Foundation
|
|
238
|
+
|
|
239
|
+
let request = NSMutableURLRequest(url: NSURL(string: "https://example.com/path%20with%20spaces/[brackets]")! as URL,
|
|
240
|
+
cachePolicy: .useProtocolCachePolicy,
|
|
241
|
+
timeoutInterval: 10.0)
|
|
242
|
+
request.httpMethod = "GET"
|
|
243
|
+
|
|
244
|
+
let session = URLSession.shared
|
|
245
|
+
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
|
|
246
|
+
if (error != nil) {
|
|
247
|
+
print(error as Any)
|
|
248
|
+
} else {
|
|
249
|
+
let httpResponse = response as? HTTPURLResponse
|
|
250
|
+
print(httpResponse)
|
|
251
|
+
}
|
|
252
|
+
})
|
|
253
|
+
|
|
254
|
+
dataTask.resume()`
|
|
255
|
+
);
|
|
256
|
+
});
|
|
257
|
+
it("handles multiple headers with same name", () => {
|
|
258
|
+
const result = swiftNsurlsession.generate({
|
|
259
|
+
url: "https://example.com",
|
|
260
|
+
headers: [
|
|
261
|
+
{ name: "X-Custom", value: "value1" },
|
|
262
|
+
{ name: "X-Custom", value: "value2" }
|
|
263
|
+
]
|
|
264
|
+
});
|
|
265
|
+
expect(result).toBe(
|
|
266
|
+
`import Foundation
|
|
267
|
+
|
|
268
|
+
let headers = ["X-Custom": "value2"]
|
|
269
|
+
|
|
270
|
+
let request = NSMutableURLRequest(url: NSURL(string: "https://example.com")! as URL,
|
|
271
|
+
cachePolicy: .useProtocolCachePolicy,
|
|
272
|
+
timeoutInterval: 10.0)
|
|
273
|
+
request.httpMethod = "GET"
|
|
274
|
+
request.allHTTPHeaderFields = headers
|
|
275
|
+
|
|
276
|
+
let session = URLSession.shared
|
|
277
|
+
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
|
|
278
|
+
if (error != nil) {
|
|
279
|
+
print(error as Any)
|
|
280
|
+
} else {
|
|
281
|
+
let httpResponse = response as? HTTPURLResponse
|
|
282
|
+
print(httpResponse)
|
|
283
|
+
}
|
|
284
|
+
})
|
|
285
|
+
|
|
286
|
+
dataTask.resume()`
|
|
287
|
+
);
|
|
288
|
+
});
|
|
289
|
+
it("handles headers with empty values", () => {
|
|
290
|
+
const result = swiftNsurlsession.generate({
|
|
291
|
+
url: "https://example.com",
|
|
292
|
+
headers: [{ name: "X-Empty", value: "" }]
|
|
293
|
+
});
|
|
294
|
+
expect(result).toBe(
|
|
295
|
+
`import Foundation
|
|
296
|
+
|
|
297
|
+
let headers = ["X-Empty": ""]
|
|
298
|
+
|
|
299
|
+
let request = NSMutableURLRequest(url: NSURL(string: "https://example.com")! as URL,
|
|
300
|
+
cachePolicy: .useProtocolCachePolicy,
|
|
301
|
+
timeoutInterval: 10.0)
|
|
302
|
+
request.httpMethod = "GET"
|
|
303
|
+
request.allHTTPHeaderFields = headers
|
|
304
|
+
|
|
305
|
+
let session = URLSession.shared
|
|
306
|
+
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
|
|
307
|
+
if (error != nil) {
|
|
308
|
+
print(error as Any)
|
|
309
|
+
} else {
|
|
310
|
+
let httpResponse = response as? HTTPURLResponse
|
|
311
|
+
print(httpResponse)
|
|
312
|
+
}
|
|
313
|
+
})
|
|
314
|
+
|
|
315
|
+
dataTask.resume()`
|
|
316
|
+
);
|
|
317
|
+
});
|
|
318
|
+
it("handles query string parameters", () => {
|
|
319
|
+
const result = swiftNsurlsession.generate({
|
|
320
|
+
url: "https://example.com/api?param1=value1¶m2=special value¶m3=123"
|
|
321
|
+
});
|
|
322
|
+
expect(result).toBe(
|
|
323
|
+
`import Foundation
|
|
324
|
+
|
|
325
|
+
let request = NSMutableURLRequest(url: NSURL(string: "https://example.com/api?param1=value1¶m2=special%20value¶m3=123")! as URL,
|
|
326
|
+
cachePolicy: .useProtocolCachePolicy,
|
|
327
|
+
timeoutInterval: 10.0)
|
|
328
|
+
request.httpMethod = "GET"
|
|
329
|
+
|
|
330
|
+
let session = URLSession.shared
|
|
331
|
+
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
|
|
332
|
+
if (error != nil) {
|
|
333
|
+
print(error as Any)
|
|
334
|
+
} else {
|
|
335
|
+
let httpResponse = response as? HTTPURLResponse
|
|
336
|
+
print(httpResponse)
|
|
337
|
+
}
|
|
338
|
+
})
|
|
339
|
+
|
|
340
|
+
dataTask.resume()`
|
|
341
|
+
);
|
|
342
|
+
});
|
|
343
|
+
});
|
|
344
|
+
//# sourceMappingURL=nsurlsession.test.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/plugins/swift/nsurlsession/nsurlsession.test.ts"],
|
|
4
|
+
"sourcesContent": ["import { describe, expect, it } from 'vitest'\n\nimport { swiftNsurlsession } from './nsurlsession'\n\ndescribe('swiftNsurlsession', () => {\n it('returns a basic request', () => {\n const result = swiftNsurlsession.generate({\n url: 'https://example.com',\n })\n\n expect(result).toBe(\n `import Foundation\n\nlet request = NSMutableURLRequest(url: NSURL(string: \"https://example.com\")! as URL,\n cachePolicy: .useProtocolCachePolicy,\n timeoutInterval: 10.0)\nrequest.httpMethod = \"GET\"\n\nlet session = URLSession.shared\nlet dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in\n if (error != nil) {\n print(error as Any)\n } else {\n let httpResponse = response as? HTTPURLResponse\n print(httpResponse)\n }\n})\n\ndataTask.resume()`,\n )\n })\n\n it('returns a POST request', () => {\n const result = swiftNsurlsession.generate({\n url: 'https://example.com',\n method: 'post',\n })\n\n expect(result).toBe(\n `import Foundation\n\nlet request = NSMutableURLRequest(url: NSURL(string: \"https://example.com\")! as URL,\n cachePolicy: .useProtocolCachePolicy,\n timeoutInterval: 10.0)\nrequest.httpMethod = \"POST\"\n\nlet session = URLSession.shared\nlet dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in\n if (error != nil) {\n print(error as Any)\n } else {\n let httpResponse = response as? HTTPURLResponse\n print(httpResponse)\n }\n})\n\ndataTask.resume()`,\n )\n })\n\n it('has headers', () => {\n const result = swiftNsurlsession.generate({\n url: 'https://example.com',\n headers: [\n {\n name: 'Content-Type',\n value: 'application/json',\n },\n ],\n })\n expect(result).toBe(\n `import Foundation\n\nlet headers = [\"Content-Type\": \"application/json\"]\n\nlet request = NSMutableURLRequest(url: NSURL(string: \"https://example.com\")! as URL,\n cachePolicy: .useProtocolCachePolicy,\n timeoutInterval: 10.0)\nrequest.httpMethod = \"GET\"\nrequest.allHTTPHeaderFields = headers\n\nlet session = URLSession.shared\nlet dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in\n if (error != nil) {\n print(error as Any)\n } else {\n let httpResponse = response as? HTTPURLResponse\n print(httpResponse)\n }\n})\n\ndataTask.resume()`,\n )\n })\n\n it('handles multipart form data with files', () => {\n const result = swiftNsurlsession.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(\n `import Foundation\nlet parameters = [\n [\n \"name\": \"file\",\n \"fileName\": \"test.txt\"\n ],\n [\n \"name\": \"field\",\n \"value\": \"value\"\n ]\n]\n\nlet boundary = \"undefined\"\n\nvar body = \"\"\nvar error: NSError? = nil\nfor param in parameters {\n let paramName = param[\"name\"]!\n body += \"--\\\\(boundary)\\\\r\\\\n\"\n body += \"Content-Disposition:form-data; name=\\\\\"\\\\(paramName)\\\\\"\"\n if let filename = param[\"fileName\"] {\n let contentType = param[\"content-type\"]!\n let fileContent = String(contentsOfFile: filename, encoding: String.Encoding.utf8)\n if (error != nil) {\n print(error as Any)\n }\n body += \"; filename=\\\\\"\\\\(filename)\\\\\"\\\\r\\\\n\"\n body += \"Content-Type: \\\\(contentType)\\\\r\\\\n\\\\r\\\\n\"\n body += fileContent\n } else if let paramValue = param[\"value\"] {\n body += \"\\\\r\\\\n\\\\r\\\\n\\\\(paramValue)\"\n }\n}\n\nlet request = NSMutableURLRequest(url: NSURL(string: \"https://example.com\")! as URL,\n cachePolicy: .useProtocolCachePolicy,\n timeoutInterval: 10.0)\nrequest.httpMethod = \"POST\"\nrequest.httpBody = postData as Data\n\nlet session = URLSession.shared\nlet dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in\n if (error != nil) {\n print(error as Any)\n } else {\n let httpResponse = response as? HTTPURLResponse\n print(httpResponse)\n }\n})\n\ndataTask.resume()`,\n )\n })\n\n it('handles url-encoded form data with special characters', () => {\n const result = swiftNsurlsession.generate({\n url: 'https://example.com',\n method: 'POST',\n postData: {\n mimeType: 'application/x-www-form-urlencoded',\n params: [\n {\n name: 'special chars!@#',\n value: 'value',\n },\n ],\n },\n })\n\n expect(result).toBe(\n `import Foundation\n\nlet postData = NSMutableData(data: \"special chars!@#=value\".data(using: String.Encoding.utf8)!)\n\nlet request = NSMutableURLRequest(url: NSURL(string: \"https://example.com\")! as URL,\n cachePolicy: .useProtocolCachePolicy,\n timeoutInterval: 10.0)\nrequest.httpMethod = \"POST\"\nrequest.httpBody = postData as Data\n\nlet session = URLSession.shared\nlet dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in\n if (error != nil) {\n print(error as Any)\n } else {\n let httpResponse = response as? HTTPURLResponse\n print(httpResponse)\n }\n})\n\ndataTask.resume()`,\n )\n })\n\n it('handles binary data', () => {\n const result = swiftNsurlsession.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(\n `import Foundation\n\nlet postData = NSData(data: \"binary content\".data(using: String.Encoding.utf8)!)\n\nlet request = NSMutableURLRequest(url: NSURL(string: \"https://example.com\")! as URL,\n cachePolicy: .useProtocolCachePolicy,\n timeoutInterval: 10.0)\nrequest.httpMethod = \"POST\"\nrequest.httpBody = postData as Data\n\nlet session = URLSession.shared\nlet dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in\n if (error != nil) {\n print(error as Any)\n } else {\n let httpResponse = response as? HTTPURLResponse\n print(httpResponse)\n }\n})\n\ndataTask.resume()`,\n )\n })\n\n it('handles special characters in URL', () => {\n const result = swiftNsurlsession.generate({\n url: 'https://example.com/path with spaces/[brackets]',\n })\n\n expect(result).toBe(\n `import Foundation\n\nlet request = NSMutableURLRequest(url: NSURL(string: \"https://example.com/path%20with%20spaces/[brackets]\")! as URL,\n cachePolicy: .useProtocolCachePolicy,\n timeoutInterval: 10.0)\nrequest.httpMethod = \"GET\"\n\nlet session = URLSession.shared\nlet dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in\n if (error != nil) {\n print(error as Any)\n } else {\n let httpResponse = response as? HTTPURLResponse\n print(httpResponse)\n }\n})\n\ndataTask.resume()`,\n )\n })\n\n it('handles multiple headers with same name', () => {\n const result = swiftNsurlsession.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(\n `import Foundation\n\nlet headers = [\"X-Custom\": \"value2\"]\n\nlet request = NSMutableURLRequest(url: NSURL(string: \"https://example.com\")! as URL,\n cachePolicy: .useProtocolCachePolicy,\n timeoutInterval: 10.0)\nrequest.httpMethod = \"GET\"\nrequest.allHTTPHeaderFields = headers\n\nlet session = URLSession.shared\nlet dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in\n if (error != nil) {\n print(error as Any)\n } else {\n let httpResponse = response as? HTTPURLResponse\n print(httpResponse)\n }\n})\n\ndataTask.resume()`,\n )\n })\n\n it('handles headers with empty values', () => {\n const result = swiftNsurlsession.generate({\n url: 'https://example.com',\n headers: [{ name: 'X-Empty', value: '' }],\n })\n\n expect(result).toBe(\n `import Foundation\n\nlet headers = [\"X-Empty\": \"\"]\n\nlet request = NSMutableURLRequest(url: NSURL(string: \"https://example.com\")! as URL,\n cachePolicy: .useProtocolCachePolicy,\n timeoutInterval: 10.0)\nrequest.httpMethod = \"GET\"\nrequest.allHTTPHeaderFields = headers\n\nlet session = URLSession.shared\nlet dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in\n if (error != nil) {\n print(error as Any)\n } else {\n let httpResponse = response as? HTTPURLResponse\n print(httpResponse)\n }\n})\n\ndataTask.resume()`,\n )\n })\n\n it('handles query string parameters', () => {\n const result = swiftNsurlsession.generate({\n url: 'https://example.com/api?param1=value1¶m2=special value¶m3=123',\n })\n\n expect(result).toBe(\n `import Foundation\n\nlet request = NSMutableURLRequest(url: NSURL(string: \"https://example.com/api?param1=value1¶m2=special%20value¶m3=123\")! as URL,\n cachePolicy: .useProtocolCachePolicy,\n timeoutInterval: 10.0)\nrequest.httpMethod = \"GET\"\n\nlet session = URLSession.shared\nlet dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in\n if (error != nil) {\n print(error as Any)\n } else {\n let httpResponse = response as? HTTPURLResponse\n print(httpResponse)\n }\n})\n\ndataTask.resume()`,\n )\n })\n})\n"],
|
|
5
|
+
"mappings": "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",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|