@scalar/snippetz 0.2.20 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/clients.d.ts.map +1 -1
- package/dist/clients.js +2 -1
- package/dist/clients.js.map +2 -2
- package/dist/httpsnippet-lite/esm/targets/c/libcurl/client.d.ts.map +1 -1
- package/dist/httpsnippet-lite/esm/targets/c/libcurl/client.js +37 -8
- package/dist/httpsnippet-lite/esm/targets/c/libcurl/client.js.map +2 -2
- package/dist/httpsnippet-lite/esm/targets/go/native/client.d.ts.map +1 -1
- package/dist/httpsnippet-lite/esm/targets/go/native/client.js +76 -30
- package/dist/httpsnippet-lite/esm/targets/go/native/client.js.map +2 -2
- package/dist/httpsnippet-lite/esm/targets/java/okhttp/client.d.ts.map +1 -1
- package/dist/httpsnippet-lite/esm/targets/java/okhttp/client.js +25 -9
- package/dist/httpsnippet-lite/esm/targets/java/okhttp/client.js.map +2 -2
- package/dist/httpsnippet-lite/esm/targets/kotlin/okhttp/client.d.ts.map +1 -1
- package/dist/httpsnippet-lite/esm/targets/kotlin/okhttp/client.js +25 -9
- package/dist/httpsnippet-lite/esm/targets/kotlin/okhttp/client.js.map +2 -2
- package/dist/httpsnippet-lite/esm/targets/shell/httpie/client.d.ts.map +1 -1
- package/dist/httpsnippet-lite/esm/targets/shell/httpie/client.js +11 -0
- package/dist/httpsnippet-lite/esm/targets/shell/httpie/client.js.map +2 -2
- 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 +4 -1
- package/dist/plugins/js/axios/index.js.map +2 -2
- package/dist/plugins/js/fetch/fetch.d.ts.map +1 -1
- package/dist/plugins/js/fetch/fetch.js +30 -9
- package/dist/plugins/js/fetch/fetch.js.map +2 -2
- 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 +4 -1
- package/dist/plugins/js/fetch/index.js.map +2 -2
- package/dist/plugins/js/ofetch/ofetch.d.ts.map +1 -1
- package/dist/plugins/js/ofetch/ofetch.js +1 -10
- package/dist/plugins/js/ofetch/ofetch.js.map +2 -2
- package/dist/plugins/node/fetch/fetch.d.ts.map +1 -1
- package/dist/plugins/node/fetch/fetch.js +37 -9
- package/dist/plugins/node/fetch/fetch.js.map +2 -2
- package/dist/plugins/node/ofetch/ofetch.d.ts.map +1 -1
- package/dist/plugins/node/ofetch/ofetch.js +1 -10
- package/dist/plugins/node/ofetch/ofetch.js.map +2 -2
- package/dist/plugins/node/undici/undici.d.ts.map +1 -1
- package/dist/plugins/node/undici/undici.js +4 -6
- package/dist/plugins/node/undici/undici.js.map +2 -2
- package/dist/plugins/python/httpx/async.d.ts +6 -0
- package/dist/plugins/python/httpx/async.d.ts.map +1 -0
- package/dist/plugins/python/httpx/async.js +16 -0
- package/dist/plugins/python/httpx/async.js.map +7 -0
- package/dist/plugins/python/httpx/index.d.ts +3 -0
- package/dist/plugins/python/httpx/index.d.ts.map +1 -0
- package/dist/plugins/python/httpx/index.js +3 -0
- package/dist/plugins/python/httpx/index.js.map +7 -0
- package/dist/plugins/python/httpx/sync.d.ts +6 -0
- package/dist/plugins/python/httpx/sync.d.ts.map +1 -0
- package/dist/plugins/python/httpx/sync.js +13 -0
- package/dist/plugins/python/httpx/sync.js.map +7 -0
- package/dist/plugins/python/requests/requests.d.ts.map +1 -1
- package/dist/plugins/python/requests/requests.js +2 -92
- package/dist/plugins/python/requests/requests.js.map +2 -2
- package/dist/plugins/python/requestsLike.d.ts +3 -0
- package/dist/plugins/python/requestsLike.d.ts.map +1 -0
- package/dist/plugins/python/requestsLike.js +120 -0
- package/dist/plugins/python/requestsLike.js.map +7 -0
- package/dist/snippetz.d.ts +1 -1
- 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/index.d.ts +0 -1
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/index.js +0 -1
- package/dist/utils/index.js.map +2 -2
- package/dist/utils/objectToString.d.ts +8 -0
- package/dist/utils/objectToString.d.ts.map +1 -1
- package/dist/utils/objectToString.js +20 -15
- package/dist/utils/objectToString.js.map +2 -2
- package/package.json +10 -5
- package/dist/plugins/c/libcurl/libcurl.test.js +0 -200
- package/dist/plugins/c/libcurl/libcurl.test.js.map +0 -7
- package/dist/plugins/clojure/clj_http/clj_http.test.js +0 -151
- package/dist/plugins/clojure/clj_http/clj_http.test.js.map +0 -7
- package/dist/plugins/dart/http/http.test.js +0 -550
- package/dist/plugins/dart/http/http.test.js.map +0 -7
- package/dist/plugins/go/native/native.test.js +0 -367
- package/dist/plugins/go/native/native.test.js.map +0 -7
- package/dist/plugins/http/http11/http11.test.js +0 -175
- package/dist/plugins/http/http11/http11.test.js.map +0 -7
- package/dist/plugins/js/fetch/fetch.test.js +0 -111
- package/dist/plugins/js/fetch/fetch.test.js.map +0 -7
- package/dist/plugins/js/ofetch/ofetch.test.js +0 -123
- package/dist/plugins/js/ofetch/ofetch.test.js.map +0 -7
- package/dist/plugins/node/fetch/fetch.test.js +0 -111
- package/dist/plugins/node/fetch/fetch.test.js.map +0 -7
- package/dist/plugins/node/ofetch/ofetch.test.js +0 -123
- package/dist/plugins/node/ofetch/ofetch.test.js.map +0 -7
- package/dist/plugins/node/undici/undici.test.js +0 -133
- package/dist/plugins/node/undici/undici.test.js.map +0 -7
- package/dist/plugins/php/curl/curl.test.js +0 -564
- package/dist/plugins/php/curl/curl.test.js.map +0 -7
- package/dist/plugins/php/guzzle/guzzle.test.js +0 -546
- package/dist/plugins/php/guzzle/guzzle.test.js.map +0 -7
- package/dist/plugins/python/requests/requests.test.js +0 -390
- package/dist/plugins/python/requests/requests.test.js.map +0 -7
- package/dist/plugins/ruby/native/native.test.js +0 -240
- package/dist/plugins/ruby/native/native.test.js.map +0 -7
- package/dist/plugins/shell/curl/curl.test.js +0 -427
- package/dist/plugins/shell/curl/curl.test.js.map +0 -7
- package/dist/plugins/shell/httpie/httpie.test.js +0 -113
- package/dist/plugins/shell/httpie/httpie.test.js.map +0 -7
- package/dist/plugins/shell/wget/wget.test.js +0 -143
- package/dist/plugins/shell/wget/wget.test.js.map +0 -7
- package/dist/plugins/swift/nsurlsession/nsurlsession.test.js +0 -344
- package/dist/plugins/swift/nsurlsession/nsurlsession.test.js.map +0 -7
- package/dist/snippetz.test.js +0 -79
- package/dist/snippetz.test.js.map +0 -7
- package/dist/utils/arrayToObject.d.ts +0 -8
- package/dist/utils/arrayToObject.d.ts.map +0 -1
- package/dist/utils/arrayToObject.js +0 -10
- package/dist/utils/arrayToObject.js.map +0 -7
- package/dist/utils/convertWithHttpSnippetLite.test.js +0 -106
- package/dist/utils/convertWithHttpSnippetLite.test.js.map +0 -7
package/dist/clients.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"clients.d.ts","sourceRoot":"","sources":["../src/clients.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"clients.d.ts","sourceRoot":"","sources":["../src/clients.ts"],"names":[],"mappings":"AAoCA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAA;AAEpD;;GAEG;AACH,eAAO,MAAM,OAAO,EAAE,MAAM,EAmH3B,CAAA"}
|
package/dist/clients.js
CHANGED
|
@@ -27,6 +27,7 @@ import { powershellRestmethod } from "./plugins/powershell/restmethod/index.js";
|
|
|
27
27
|
import { powershellWebrequest } from "./plugins/powershell/webrequest/index.js";
|
|
28
28
|
import { pythonPython3 } from "./plugins/python/python3/index.js";
|
|
29
29
|
import { pythonRequests } from "./plugins/python/requests/index.js";
|
|
30
|
+
import { pythonHttpxSync, pythonHttpxAsync } from "./plugins/python/httpx/index.js";
|
|
30
31
|
import { rHttr } from "./plugins/r/httr/index.js";
|
|
31
32
|
import { rubyNative } from "./plugins/ruby/native/index.js";
|
|
32
33
|
import { shellCurl } from "./plugins/shell/curl/index.js";
|
|
@@ -122,7 +123,7 @@ const clients = [
|
|
|
122
123
|
key: "python",
|
|
123
124
|
title: "Python",
|
|
124
125
|
default: "python3",
|
|
125
|
-
clients: [pythonPython3, pythonRequests]
|
|
126
|
+
clients: [pythonPython3, pythonRequests, pythonHttpxSync, pythonHttpxAsync]
|
|
126
127
|
},
|
|
127
128
|
{
|
|
128
129
|
key: "r",
|
package/dist/clients.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/clients.ts"],
|
|
4
|
-
"sourcesContent": ["import { cLibcurl } from '@/plugins/c/libcurl/libcurl'\nimport { clojureCljhttp } from '@/plugins/clojure/clj_http'\nimport { csharpHttpclient } from '@/plugins/csharp/httpclient'\nimport { csharpRestsharp } from '@/plugins/csharp/restsharp'\nimport { dartHttp } from '@/plugins/dart/http'\nimport { goNative } from '@/plugins/go/native'\nimport { httpHttp11 } from '@/plugins/http/http11'\nimport { javaAsynchttp } from '@/plugins/java/asynchttp'\nimport { javaNethttp } from '@/plugins/java/nethttp/nethttp'\nimport { javaOkhttp } from '@/plugins/java/okhttp/okhttp'\nimport { javaUnirest } from '@/plugins/java/unirest/unirest'\nimport { jsAxios } from '@/plugins/js/axios'\nimport { jsFetch } from '@/plugins/js/fetch'\nimport { jsJquery } from '@/plugins/js/jquery'\nimport { jsOfetch } from '@/plugins/js/ofetch'\nimport { jsXhr } from '@/plugins/js/xhr'\nimport { kotlinOkhttp } from '@/plugins/kotlin/okhttp'\nimport { nodeAxios } from '@/plugins/node/axios'\nimport { nodeFetch } from '@/plugins/node/fetch'\nimport { nodeOfetch } from '@/plugins/node/ofetch'\nimport { nodeUndici } from '@/plugins/node/undici'\nimport { objcNsurlsession } from '@/plugins/objc/nsurlsession'\nimport { ocamlCohttp } from '@/plugins/ocaml/cohttp'\nimport { phpCurl } from '@/plugins/php/curl'\nimport { phpGuzzle } from '@/plugins/php/guzzle'\nimport { powershellRestmethod } from '@/plugins/powershell/restmethod'\nimport { powershellWebrequest } from '@/plugins/powershell/webrequest'\nimport { pythonPython3 } from '@/plugins/python/python3'\nimport { pythonRequests } from '@/plugins/python/requests'\nimport { rHttr } from '@/plugins/r/httr'\nimport { rubyNative } from '@/plugins/ruby/native'\nimport { shellCurl } from '@/plugins/shell/curl'\nimport { shellHttpie } from '@/plugins/shell/httpie'\nimport { shellWget } from '@/plugins/shell/wget'\nimport { swiftNsurlsession } from '@/plugins/swift/nsurlsession'\nimport type { Target } from '@scalar/types/snippetz'\n\n/**\n * All available clients\n */\nexport const clients: Target[] = [\n {\n key: 'c',\n title: 'C',\n default: 'libcurl',\n clients: [cLibcurl],\n },\n {\n key: 'csharp',\n title: 'C#',\n default: 'restsharp',\n clients: [csharpHttpclient, csharpRestsharp],\n },\n {\n key: 'clojure',\n title: 'Clojure',\n default: 'clj_http',\n clients: [clojureCljhttp],\n },\n {\n key: 'dart',\n title: 'Dart',\n default: 'http',\n clients: [dartHttp],\n },\n {\n key: 'go',\n title: 'Go',\n default: 'native',\n clients: [goNative],\n },\n {\n key: 'http',\n title: 'HTTP',\n default: 'http1.1',\n clients: [httpHttp11],\n },\n {\n key: 'java',\n title: 'Java',\n default: 'unirest',\n clients: [javaAsynchttp, javaNethttp, javaOkhttp, javaUnirest],\n },\n {\n key: 'js',\n title: 'JavaScript',\n default: 'fetch',\n clients: [jsFetch, jsAxios, jsOfetch, jsJquery, jsXhr],\n },\n {\n key: 'kotlin',\n title: 'Kotlin',\n default: 'okhttp',\n clients: [kotlinOkhttp],\n },\n {\n key: 'node',\n title: 'Node.js',\n default: 'fetch',\n clients: [nodeFetch, nodeAxios, nodeOfetch, nodeUndici],\n },\n {\n key: 'objc',\n title: 'Objective-C',\n default: 'nsurlsession',\n clients: [objcNsurlsession],\n },\n {\n key: 'ocaml',\n title: 'OCaml',\n default: 'cohttp',\n clients: [ocamlCohttp],\n },\n {\n key: 'php',\n title: 'PHP',\n default: 'curl',\n clients: [phpCurl, phpGuzzle],\n },\n {\n key: 'powershell',\n title: 'Powershell',\n default: 'webrequest',\n clients: [powershellWebrequest, powershellRestmethod],\n },\n {\n key: 'python',\n title: 'Python',\n default: 'python3',\n clients: [pythonPython3, pythonRequests],\n },\n {\n key: 'r',\n title: 'R',\n default: 'httr',\n clients: [rHttr],\n },\n {\n key: 'ruby',\n title: 'Ruby',\n default: 'native',\n clients: [rubyNative],\n },\n {\n key: 'shell',\n title: 'Shell',\n default: 'curl',\n clients: [shellCurl, shellWget, shellHttpie],\n },\n {\n key: 'swift',\n title: 'Swift',\n default: 'nsurlsession',\n clients: [swiftNsurlsession],\n },\n]\n"],
|
|
5
|
-
"mappings": "AAAA,SAAS,gBAAgB;AACzB,SAAS,sBAAsB;AAC/B,SAAS,wBAAwB;AACjC,SAAS,uBAAuB;AAChC,SAAS,gBAAgB;AACzB,SAAS,gBAAgB;AACzB,SAAS,kBAAkB;AAC3B,SAAS,qBAAqB;AAC9B,SAAS,mBAAmB;AAC5B,SAAS,kBAAkB;AAC3B,SAAS,mBAAmB;AAC5B,SAAS,eAAe;AACxB,SAAS,eAAe;AACxB,SAAS,gBAAgB;AACzB,SAAS,gBAAgB;AACzB,SAAS,aAAa;AACtB,SAAS,oBAAoB;AAC7B,SAAS,iBAAiB;AAC1B,SAAS,iBAAiB;AAC1B,SAAS,kBAAkB;AAC3B,SAAS,kBAAkB;AAC3B,SAAS,wBAAwB;AACjC,SAAS,mBAAmB;AAC5B,SAAS,eAAe;AACxB,SAAS,iBAAiB;AAC1B,SAAS,4BAA4B;AACrC,SAAS,4BAA4B;AACrC,SAAS,qBAAqB;AAC9B,SAAS,sBAAsB;AAC/B,SAAS,aAAa;AACtB,SAAS,kBAAkB;AAC3B,SAAS,iBAAiB;AAC1B,SAAS,mBAAmB;AAC5B,SAAS,iBAAiB;AAC1B,SAAS,yBAAyB;AAM3B,MAAM,UAAoB;AAA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AAA,IACL,OAAO;AAAA,IACP,SAAS;AAAA,IACT,SAAS,CAAC,WAAW;AAAA,EACvB;AAAA,EACA;AAAA,IACE,KAAK;AAAA,IACL,OAAO;AAAA,IACP,SAAS;AAAA,IACT,SAAS,CAAC,SAAS,SAAS;AAAA,EAC9B;AAAA,EACA;AAAA,IACE,KAAK;AAAA,IACL,OAAO;AAAA,IACP,SAAS;AAAA,IACT,SAAS,CAAC,sBAAsB,oBAAoB;AAAA,EACtD;AAAA,EACA;AAAA,IACE,KAAK;AAAA,IACL,OAAO;AAAA,IACP,SAAS;AAAA,IACT,SAAS,CAAC,eAAe,
|
|
4
|
+
"sourcesContent": ["import { cLibcurl } from '@/plugins/c/libcurl/libcurl'\nimport { clojureCljhttp } from '@/plugins/clojure/clj_http'\nimport { csharpHttpclient } from '@/plugins/csharp/httpclient'\nimport { csharpRestsharp } from '@/plugins/csharp/restsharp'\nimport { dartHttp } from '@/plugins/dart/http'\nimport { goNative } from '@/plugins/go/native'\nimport { httpHttp11 } from '@/plugins/http/http11'\nimport { javaAsynchttp } from '@/plugins/java/asynchttp'\nimport { javaNethttp } from '@/plugins/java/nethttp/nethttp'\nimport { javaOkhttp } from '@/plugins/java/okhttp/okhttp'\nimport { javaUnirest } from '@/plugins/java/unirest/unirest'\nimport { jsAxios } from '@/plugins/js/axios'\nimport { jsFetch } from '@/plugins/js/fetch'\nimport { jsJquery } from '@/plugins/js/jquery'\nimport { jsOfetch } from '@/plugins/js/ofetch'\nimport { jsXhr } from '@/plugins/js/xhr'\nimport { kotlinOkhttp } from '@/plugins/kotlin/okhttp'\nimport { nodeAxios } from '@/plugins/node/axios'\nimport { nodeFetch } from '@/plugins/node/fetch'\nimport { nodeOfetch } from '@/plugins/node/ofetch'\nimport { nodeUndici } from '@/plugins/node/undici'\nimport { objcNsurlsession } from '@/plugins/objc/nsurlsession'\nimport { ocamlCohttp } from '@/plugins/ocaml/cohttp'\nimport { phpCurl } from '@/plugins/php/curl'\nimport { phpGuzzle } from '@/plugins/php/guzzle'\nimport { powershellRestmethod } from '@/plugins/powershell/restmethod'\nimport { powershellWebrequest } from '@/plugins/powershell/webrequest'\nimport { pythonPython3 } from '@/plugins/python/python3'\nimport { pythonRequests } from '@/plugins/python/requests'\nimport { pythonHttpxSync, pythonHttpxAsync } from '@/plugins/python/httpx'\nimport { rHttr } from '@/plugins/r/httr'\nimport { rubyNative } from '@/plugins/ruby/native'\nimport { shellCurl } from '@/plugins/shell/curl'\nimport { shellHttpie } from '@/plugins/shell/httpie'\nimport { shellWget } from '@/plugins/shell/wget'\nimport { swiftNsurlsession } from '@/plugins/swift/nsurlsession'\nimport type { Target } from '@scalar/types/snippetz'\n\n/**\n * All available clients\n */\nexport const clients: Target[] = [\n {\n key: 'c',\n title: 'C',\n default: 'libcurl',\n clients: [cLibcurl],\n },\n {\n key: 'csharp',\n title: 'C#',\n default: 'restsharp',\n clients: [csharpHttpclient, csharpRestsharp],\n },\n {\n key: 'clojure',\n title: 'Clojure',\n default: 'clj_http',\n clients: [clojureCljhttp],\n },\n {\n key: 'dart',\n title: 'Dart',\n default: 'http',\n clients: [dartHttp],\n },\n {\n key: 'go',\n title: 'Go',\n default: 'native',\n clients: [goNative],\n },\n {\n key: 'http',\n title: 'HTTP',\n default: 'http1.1',\n clients: [httpHttp11],\n },\n {\n key: 'java',\n title: 'Java',\n default: 'unirest',\n clients: [javaAsynchttp, javaNethttp, javaOkhttp, javaUnirest],\n },\n {\n key: 'js',\n title: 'JavaScript',\n default: 'fetch',\n clients: [jsFetch, jsAxios, jsOfetch, jsJquery, jsXhr],\n },\n {\n key: 'kotlin',\n title: 'Kotlin',\n default: 'okhttp',\n clients: [kotlinOkhttp],\n },\n {\n key: 'node',\n title: 'Node.js',\n default: 'fetch',\n clients: [nodeFetch, nodeAxios, nodeOfetch, nodeUndici],\n },\n {\n key: 'objc',\n title: 'Objective-C',\n default: 'nsurlsession',\n clients: [objcNsurlsession],\n },\n {\n key: 'ocaml',\n title: 'OCaml',\n default: 'cohttp',\n clients: [ocamlCohttp],\n },\n {\n key: 'php',\n title: 'PHP',\n default: 'curl',\n clients: [phpCurl, phpGuzzle],\n },\n {\n key: 'powershell',\n title: 'Powershell',\n default: 'webrequest',\n clients: [powershellWebrequest, powershellRestmethod],\n },\n {\n key: 'python',\n title: 'Python',\n default: 'python3',\n clients: [pythonPython3, pythonRequests, pythonHttpxSync, pythonHttpxAsync],\n },\n {\n key: 'r',\n title: 'R',\n default: 'httr',\n clients: [rHttr],\n },\n {\n key: 'ruby',\n title: 'Ruby',\n default: 'native',\n clients: [rubyNative],\n },\n {\n key: 'shell',\n title: 'Shell',\n default: 'curl',\n clients: [shellCurl, shellWget, shellHttpie],\n },\n {\n key: 'swift',\n title: 'Swift',\n default: 'nsurlsession',\n clients: [swiftNsurlsession],\n },\n]\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,gBAAgB;AACzB,SAAS,sBAAsB;AAC/B,SAAS,wBAAwB;AACjC,SAAS,uBAAuB;AAChC,SAAS,gBAAgB;AACzB,SAAS,gBAAgB;AACzB,SAAS,kBAAkB;AAC3B,SAAS,qBAAqB;AAC9B,SAAS,mBAAmB;AAC5B,SAAS,kBAAkB;AAC3B,SAAS,mBAAmB;AAC5B,SAAS,eAAe;AACxB,SAAS,eAAe;AACxB,SAAS,gBAAgB;AACzB,SAAS,gBAAgB;AACzB,SAAS,aAAa;AACtB,SAAS,oBAAoB;AAC7B,SAAS,iBAAiB;AAC1B,SAAS,iBAAiB;AAC1B,SAAS,kBAAkB;AAC3B,SAAS,kBAAkB;AAC3B,SAAS,wBAAwB;AACjC,SAAS,mBAAmB;AAC5B,SAAS,eAAe;AACxB,SAAS,iBAAiB;AAC1B,SAAS,4BAA4B;AACrC,SAAS,4BAA4B;AACrC,SAAS,qBAAqB;AAC9B,SAAS,sBAAsB;AAC/B,SAAS,iBAAiB,wBAAwB;AAClD,SAAS,aAAa;AACtB,SAAS,kBAAkB;AAC3B,SAAS,iBAAiB;AAC1B,SAAS,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S;AAAA,IACT,SAAS,CAAC,gBAAgB;AAAA,EAC5B;AAAA,EACA;AAAA,IACE,KAAK;AAAA,IACL,OAAO;AAAA,IACP,SAAS;AAAA,IACT,SAAS,CAAC,WAAW;AAAA,EACvB;AAAA,EACA;AAAA,IACE,KAAK;AAAA,IACL,OAAO;AAAA,IACP,SAAS;AAAA,IACT,SAAS,CAAC,SAAS,SAAS;AAAA,EAC9B;AAAA,EACA;AAAA,IACE,KAAK;AAAA,IACL,OAAO;AAAA,IACP,SAAS;AAAA,IACT,SAAS,CAAC,sBAAsB,oBAAoB;AAAA,EACtD;AAAA,EACA;AAAA,IACE,KAAK;AAAA,IACL,OAAO;AAAA,IACP,SAAS;AAAA,IACT,SAAS,CAAC,eAAe,gBAAgB,iBAAiB,gBAAgB;AAAA,EAC5E;AAAA,EACA;AAAA,IACE,KAAK;AAAA,IACL,OAAO;AAAA,IACP,SAAS;AAAA,IACT,SAAS,CAAC,KAAK;AAAA,EACjB;AAAA,EACA;AAAA,IACE,KAAK;AAAA,IACL,OAAO;AAAA,IACP,SAAS;AAAA,IACT,SAAS,CAAC,UAAU;AAAA,EACtB;AAAA,EACA;AAAA,IACE,KAAK;AAAA,IACL,OAAO;AAAA,IACP,SAAS;AAAA,IACT,SAAS,CAAC,WAAW,WAAW,WAAW;AAAA,EAC7C;AAAA,EACA;AAAA,IACE,KAAK;AAAA,IACL,OAAO;AAAA,IACP,SAAS;AAAA,IACT,SAAS,CAAC,iBAAiB;AAAA,EAC7B;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../../../../../src/httpsnippet-lite/esm/targets/c/libcurl/client.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../../../../../src/httpsnippet-lite/esm/targets/c/libcurl/client.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,OAAO;;;;;;;;;;;;;;CAwEnB,CAAA"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { createSearchParams } from "../../../../../utils/create-search-params.js";
|
|
1
2
|
import { CodeBuilder } from "../../../helpers/code-builder.js";
|
|
2
3
|
import { escapeForDoubleQuotes } from "../../../helpers/escape.js";
|
|
3
4
|
const libcurl = {
|
|
@@ -8,7 +9,7 @@ const libcurl = {
|
|
|
8
9
|
description: "Simple REST and HTTP API Client for C"
|
|
9
10
|
},
|
|
10
11
|
convert: ({ method, fullUrl, headersObj, allHeaders, postData }) => {
|
|
11
|
-
const { push, blank, join } = new CodeBuilder();
|
|
12
|
+
const { push, blank, join } = new CodeBuilder({ indent: " " });
|
|
12
13
|
push("CURL *hnd = curl_easy_init();");
|
|
13
14
|
blank();
|
|
14
15
|
push(
|
|
@@ -20,9 +21,13 @@ const libcurl = {
|
|
|
20
21
|
blank();
|
|
21
22
|
push("struct curl_slist *headers = NULL;");
|
|
22
23
|
headers.forEach((header) => {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
24
|
+
if (headersObj[header]) {
|
|
25
|
+
push(
|
|
26
|
+
`headers = curl_slist_append(headers, "${header}: ${escapeForDoubleQuotes(headersObj[header])}");`
|
|
27
|
+
);
|
|
28
|
+
} else {
|
|
29
|
+
push(`headers = curl_slist_append(headers, "${header};");`);
|
|
30
|
+
}
|
|
26
31
|
});
|
|
27
32
|
push("curl_easy_setopt(hnd, CURLOPT_HTTPHEADER, headers);");
|
|
28
33
|
}
|
|
@@ -30,11 +35,35 @@ const libcurl = {
|
|
|
30
35
|
blank();
|
|
31
36
|
push(`curl_easy_setopt(hnd, CURLOPT_COOKIE, "${allHeaders.cookie}");`);
|
|
32
37
|
}
|
|
33
|
-
if (postData
|
|
38
|
+
if (postData !== null && postData !== void 0) {
|
|
34
39
|
blank();
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
40
|
+
if (postData.text) {
|
|
41
|
+
push(
|
|
42
|
+
`curl_easy_setopt(hnd, CURLOPT_POSTFIELDS, ${JSON.stringify(postData.text)});`
|
|
43
|
+
);
|
|
44
|
+
} else if (postData.mimeType === "application/x-www-form-urlencoded" && postData.params) {
|
|
45
|
+
push(
|
|
46
|
+
`curl_easy_setopt(hnd, CURLOPT_POSTFIELDS, "${createSearchParams(postData.params).toString()}");`
|
|
47
|
+
);
|
|
48
|
+
} else if (postData.mimeType === "multipart/form-data" && postData.params) {
|
|
49
|
+
push("curl_mime *mime = curl_mime_init(hnd);");
|
|
50
|
+
postData.params.forEach((param) => {
|
|
51
|
+
blank();
|
|
52
|
+
push("{");
|
|
53
|
+
push(`curl_mimepart *part = curl_mime_addpart(mime);`, 1);
|
|
54
|
+
if (param.name) {
|
|
55
|
+
push(`curl_mime_name(part, "${param.name}");`, 1);
|
|
56
|
+
}
|
|
57
|
+
if (param.fileName) {
|
|
58
|
+
push(`curl_mime_filedata(part, "${param.fileName}");`, 1);
|
|
59
|
+
} else if (param.value) {
|
|
60
|
+
push(`curl_mime_data(part, "${escapeForDoubleQuotes(param.value)}", CURL_ZERO_TERMINATED);`, 1);
|
|
61
|
+
}
|
|
62
|
+
push("}");
|
|
63
|
+
});
|
|
64
|
+
blank();
|
|
65
|
+
push("curl_easy_setopt(hnd, CURLOPT_MIMEPOST, mime);");
|
|
66
|
+
}
|
|
38
67
|
}
|
|
39
68
|
blank();
|
|
40
69
|
push("CURLcode ret = curl_easy_perform(hnd);");
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../src/httpsnippet-lite/esm/targets/c/libcurl/client.ts"],
|
|
4
|
-
"sourcesContent": ["// @ts-nocheck\nimport { CodeBuilder } from '../../../helpers/code-builder.js'\nimport { escapeForDoubleQuotes } from '../../../helpers/escape.js'\n\nexport const libcurl = {\n info: {\n key: 'libcurl',\n title: 'Libcurl',\n link: 'http://curl.haxx.se/libcurl',\n description: 'Simple REST and HTTP API Client for C',\n },\n convert: ({ method, fullUrl, headersObj, allHeaders, postData }) => {\n const { push, blank, join } = new CodeBuilder()\n push('CURL *hnd = curl_easy_init();')\n blank()\n push(\n `curl_easy_setopt(hnd, CURLOPT_CUSTOMREQUEST, \"${method.toUpperCase()}\");`,\n )\n push(`curl_easy_setopt(hnd, CURLOPT_URL, \"${fullUrl}\");`)\n // Add headers, including the cookies\n const headers = Object.keys(headersObj)\n // construct headers\n if (headers.length) {\n blank()\n push('struct curl_slist *headers = NULL;')\n headers.forEach((header) => {\n push(\n
|
|
5
|
-
"mappings": "AACA,SAAS,mBAAmB;AAC5B,SAAS,6BAA6B;AAE/B,MAAM,UAAU;AAAA,EACrB,MAAM;AAAA,IACJ,KAAK;AAAA,IACL,OAAO;AAAA,IACP,MAAM;AAAA,IACN,aAAa;AAAA,EACf;AAAA,EACA,SAAS,CAAC,EAAE,QAAQ,SAAS,YAAY,YAAY,SAAS,MAAM;AAClE,UAAM,EAAE,MAAM,OAAO,KAAK,IAAI,IAAI,YAAY;
|
|
4
|
+
"sourcesContent": ["// @ts-nocheck\nimport { createSearchParams } from '../../../../../utils/create-search-params.js'\nimport { CodeBuilder } from '../../../helpers/code-builder.js'\nimport { escapeForDoubleQuotes } from '../../../helpers/escape.js'\n\nexport const libcurl = {\n info: {\n key: 'libcurl',\n title: 'Libcurl',\n link: 'http://curl.haxx.se/libcurl',\n description: 'Simple REST and HTTP API Client for C',\n },\n convert: ({ method, fullUrl, headersObj, allHeaders, postData }) => {\n const { push, blank, join } = new CodeBuilder({ indent: ' ' })\n push('CURL *hnd = curl_easy_init();')\n blank()\n push(\n `curl_easy_setopt(hnd, CURLOPT_CUSTOMREQUEST, \"${method.toUpperCase()}\");`,\n )\n push(`curl_easy_setopt(hnd, CURLOPT_URL, \"${fullUrl}\");`)\n // Add headers, including the cookies\n const headers = Object.keys(headersObj)\n // construct headers\n if (headers.length) {\n blank()\n push('struct curl_slist *headers = NULL;')\n headers.forEach((header) => {\n // See https://curl.se/libcurl/c/httpcustomheader.html for syntax\n if (headersObj[header]) {\n push(\n `headers = curl_slist_append(headers, \"${header}: ${escapeForDoubleQuotes(headersObj[header])}\");`,\n )\n } else {\n push(`headers = curl_slist_append(headers, \"${header};\");`)\n }\n })\n push('curl_easy_setopt(hnd, CURLOPT_HTTPHEADER, headers);')\n }\n // construct cookies\n if (allHeaders.cookie) {\n blank()\n push(`curl_easy_setopt(hnd, CURLOPT_COOKIE, \"${allHeaders.cookie}\");`)\n }\n if (postData !== null && postData !== void 0) {\n blank()\n if (postData.text) {\n push(\n `curl_easy_setopt(hnd, CURLOPT_POSTFIELDS, ${JSON.stringify(postData.text)});`,\n )\n } else if (postData.mimeType === 'application/x-www-form-urlencoded' && postData.params) {\n push(\n `curl_easy_setopt(hnd, CURLOPT_POSTFIELDS, \"${createSearchParams(postData.params).toString()}\");`,\n )\n } else if (postData.mimeType === 'multipart/form-data' && postData.params) {\n push('curl_mime *mime = curl_mime_init(hnd);')\n postData.params.forEach((param) => {\n blank()\n push('{')\n push(`curl_mimepart *part = curl_mime_addpart(mime);`, 1)\n if (param.name) {\n push(`curl_mime_name(part, \"${param.name}\");`, 1)\n }\n if (param.fileName) {\n push(`curl_mime_filedata(part, \"${param.fileName}\");`, 1)\n } else if (param.value) {\n push(`curl_mime_data(part, \"${escapeForDoubleQuotes(param.value)}\", CURL_ZERO_TERMINATED);`, 1)\n }\n push('}')\n })\n blank()\n push('curl_easy_setopt(hnd, CURLOPT_MIMEPOST, mime);')\n }\n }\n blank()\n push('CURLcode ret = curl_easy_perform(hnd);')\n return join()\n },\n}\n"],
|
|
5
|
+
"mappings": "AACA,SAAS,0BAA0B;AACnC,SAAS,mBAAmB;AAC5B,SAAS,6BAA6B;AAE/B,MAAM,UAAU;AAAA,EACrB,MAAM;AAAA,IACJ,KAAK;AAAA,IACL,OAAO;AAAA,IACP,MAAM;AAAA,IACN,aAAa;AAAA,EACf;AAAA,EACA,SAAS,CAAC,EAAE,QAAQ,SAAS,YAAY,YAAY,SAAS,M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A,UAC1D,WAAW,MAAM,OAAO;AACtB,iBAAK,yBAAyB,sBAAsB,MAAM,KAAK,CAAC,6BAA6B,CAAC;AAAA,UAChG;AACA,eAAK,GAAG;AAAA,QACV,CAAC;AACD,cAAM;AACN,aAAK,gDAAgD;AAAA,MACvD;AAAA,IACF;AACA,UAAM;AACN,SAAK,wCAAwC;AAC7C,WAAO,KAAK;AAAA,EACd;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../../../../../src/httpsnippet-lite/esm/targets/go/native/client.ts"],"names":[],"mappings":"AAaA,eAAO,MAAM,MAAM;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../../../../../src/httpsnippet-lite/esm/targets/go/native/client.ts"],"names":[],"mappings":"AAaA,eAAO,MAAM,MAAM;;;;;;;;;;;;;CAoLlB,CAAA"}
|
|
@@ -8,7 +8,7 @@ const native = {
|
|
|
8
8
|
description: "Golang HTTP client request"
|
|
9
9
|
},
|
|
10
10
|
convert: ({ postData, method, allHeaders, fullUrl }, options = {}) => {
|
|
11
|
-
const { blank, push, join } = new CodeBuilder({ indent: " " });
|
|
11
|
+
const { blank, push, join, addPostProcessor } = new CodeBuilder({ indent: " " });
|
|
12
12
|
const {
|
|
13
13
|
showBoilerplate = true,
|
|
14
14
|
checkErrors = false,
|
|
@@ -25,30 +25,26 @@ const native = {
|
|
|
25
25
|
push("}", indent);
|
|
26
26
|
}
|
|
27
27
|
};
|
|
28
|
+
const imports = /* @__PURE__ */ new Set();
|
|
28
29
|
if (showBoilerplate) {
|
|
29
30
|
push("package main");
|
|
30
31
|
blank();
|
|
31
|
-
push("import (");
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
push('"net/http"', indent);
|
|
43
|
-
if (printBody) {
|
|
44
|
-
push('"io"', indent);
|
|
45
|
-
}
|
|
46
|
-
push(")");
|
|
32
|
+
push("import ()");
|
|
33
|
+
addPostProcessor((code) => {
|
|
34
|
+
const importArray = [...imports];
|
|
35
|
+
importArray.sort();
|
|
36
|
+
const importBlock = importArray.map((line) => ` "${line}"`).join("\n");
|
|
37
|
+
return code.replace(/import \(\)/, `import (
|
|
38
|
+
${importBlock}
|
|
39
|
+
)`);
|
|
40
|
+
});
|
|
41
|
+
imports.add("fmt");
|
|
42
|
+
imports.add("net/http");
|
|
47
43
|
blank();
|
|
48
44
|
push("func main() {");
|
|
49
|
-
blank();
|
|
50
45
|
}
|
|
51
46
|
if (insecureSkipVerify) {
|
|
47
|
+
imports.add("crypto/tls");
|
|
52
48
|
push(
|
|
53
49
|
"insecureTransport := http.DefaultTransport.(*http.Transport).Clone()",
|
|
54
50
|
indent
|
|
@@ -64,6 +60,7 @@ const native = {
|
|
|
64
60
|
if (hasClient) {
|
|
65
61
|
push("client := http.Client{", indent);
|
|
66
62
|
if (hasTimeout) {
|
|
63
|
+
imports.add("time");
|
|
67
64
|
push(`Timeout: time.Duration(${timeout} * time.Second),`, indent + 1);
|
|
68
65
|
}
|
|
69
66
|
if (insecureSkipVerify) {
|
|
@@ -74,25 +71,73 @@ const native = {
|
|
|
74
71
|
}
|
|
75
72
|
push(`url := "${fullUrl}"`, indent);
|
|
76
73
|
blank();
|
|
77
|
-
if (postData
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
74
|
+
if (postData !== null && postData !== void 0 && (postData.params || postData.text)) {
|
|
75
|
+
if (postData.mimeType === "application/x-www-form-urlencoded" && postData.params) {
|
|
76
|
+
imports.add("net/url");
|
|
77
|
+
imports.add("strings");
|
|
78
|
+
push("postData := url.Values{}", indent);
|
|
79
|
+
postData.params.forEach((param) => {
|
|
80
|
+
push(
|
|
81
|
+
`postData.Set("${param.name}", "${escapeForDoubleQuotes(param.value)}")`,
|
|
82
|
+
indent
|
|
83
|
+
);
|
|
84
|
+
});
|
|
85
|
+
blank();
|
|
86
|
+
push(
|
|
87
|
+
`req, ${errorPlaceholder} := http.NewRequest("${method}", url, strings.NewReader(postData.Encode()))`,
|
|
88
|
+
indent
|
|
89
|
+
);
|
|
90
|
+
} else if (postData.mimeType === "multipart/form-data" && postData.params) {
|
|
91
|
+
imports.add("bytes");
|
|
92
|
+
imports.add("mime/multipart");
|
|
93
|
+
push("payload := &bytes.Buffer{}", indent);
|
|
94
|
+
push("writer := multipart.NewWriter(payload)", indent);
|
|
95
|
+
postData.params.forEach((param) => {
|
|
96
|
+
blank();
|
|
97
|
+
if (param.fileName) {
|
|
98
|
+
push(`part, ${errorPlaceholder} := writer.CreateFormFile("${param.name}", "${param.fileName}")`, indent);
|
|
99
|
+
errorCheck();
|
|
100
|
+
blank();
|
|
101
|
+
push(`f, ${errorPlaceholder} := os.Open("${param.fileName}")`, indent);
|
|
102
|
+
errorCheck();
|
|
103
|
+
push("defer f.Close()", indent);
|
|
104
|
+
blank();
|
|
105
|
+
push(`_, ${errorPlaceholder} = io.Copy(part, f)`, indent);
|
|
106
|
+
errorCheck();
|
|
107
|
+
} else {
|
|
108
|
+
push(`${errorPlaceholder} = writer.WriteField("${param.name}", "${escapeForDoubleQuotes(param.value)}")`, indent);
|
|
109
|
+
errorCheck();
|
|
110
|
+
}
|
|
111
|
+
});
|
|
112
|
+
push("writer.Close()", indent);
|
|
113
|
+
blank();
|
|
114
|
+
push(
|
|
115
|
+
`req, ${errorPlaceholder} := http.NewRequest("${method}", url, payload)`,
|
|
116
|
+
indent
|
|
117
|
+
);
|
|
118
|
+
} else {
|
|
119
|
+
imports.add("strings");
|
|
120
|
+
push(
|
|
121
|
+
`payload := strings.NewReader(${JSON.stringify(postData.text)})`,
|
|
122
|
+
indent
|
|
123
|
+
);
|
|
124
|
+
blank();
|
|
125
|
+
push(
|
|
126
|
+
`req, ${errorPlaceholder} := http.NewRequest("${method}", url, payload)`,
|
|
127
|
+
indent
|
|
128
|
+
);
|
|
129
|
+
}
|
|
88
130
|
} else {
|
|
89
131
|
push(
|
|
90
132
|
`req, ${errorPlaceholder} := http.NewRequest("${method}", url, nil)`,
|
|
91
133
|
indent
|
|
92
134
|
);
|
|
93
|
-
blank();
|
|
94
135
|
}
|
|
95
136
|
errorCheck();
|
|
137
|
+
blank();
|
|
138
|
+
if (postData !== null && postData !== void 0 && postData.mimeType === "multipart/form-data" && postData.params) {
|
|
139
|
+
push(`req.Header.Set("Content-Type", writer.FormDataContentType())`, indent);
|
|
140
|
+
}
|
|
96
141
|
if (Object.keys(allHeaders).length) {
|
|
97
142
|
Object.keys(allHeaders).forEach((key) => {
|
|
98
143
|
push(
|
|
@@ -105,6 +150,7 @@ const native = {
|
|
|
105
150
|
push(`res, ${errorPlaceholder} := ${client}.Do(req)`, indent);
|
|
106
151
|
errorCheck();
|
|
107
152
|
if (printBody) {
|
|
153
|
+
imports.add("io");
|
|
108
154
|
blank();
|
|
109
155
|
push("defer res.Body.Close()", indent);
|
|
110
156
|
push(`body, ${errorPlaceholder} := io.ReadAll(res.Body)`, indent);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../src/httpsnippet-lite/esm/targets/go/native/client.ts"],
|
|
4
|
-
"sourcesContent": ["// @ts-nocheck\n/**\n * @description\n * HTTP code snippet generator for native Go.\n *\n * @author\n * @montanaflynn\n *\n * for any questions or issues regarding the generated code snippet, please open an issue mentioning the author.\n */\nimport { CodeBuilder } from '../../../helpers/code-builder.js'\nimport { escapeForDoubleQuotes } from '../../../helpers/escape.js'\n\nexport const native = {\n info: {\n key: 'native',\n title: 'NewRequest',\n link: 'http://golang.org/pkg/net/http/#NewRequest',\n description: 'Golang HTTP client request',\n },\n convert: ({ postData, method, allHeaders, fullUrl }, options = {}) => {\n const { blank, push, join } = new CodeBuilder({ indent: '\\t' })\n const {\n showBoilerplate = true,\n checkErrors = false,\n printBody = true,\n timeout = -1,\n insecureSkipVerify = false,\n } = options\n const errorPlaceholder = checkErrors ? 'err' : '_'\n const indent = showBoilerplate ? 1 : 0\n const errorCheck = () => {\n if (checkErrors) {\n push('if err != nil {', indent)\n push('panic(err)', indent + 1)\n push('}', indent)\n }\n }\n // Create boilerplate\n if (showBoilerplate) {\n push('package main')\n blank()\n push('import (')\n
|
|
5
|
-
"mappings": "AAUA,SAAS,mBAAmB;AAC5B,SAAS,6BAA6B;AAE/B,MAAM,SAAS;AAAA,EACpB,MAAM;AAAA,IACJ,KAAK;AAAA,IACL,OAAO;AAAA,IACP,MAAM;AAAA,IACN,aAAa;AAAA,EACf;AAAA,EACA,SAAS,CAAC,EAAE,UAAU,QAAQ,YAAY,QAAQ,GAAG,UAAU,CAAC,MAAM;AACpE,UAAM,EAAE,OAAO,MAAM,
|
|
4
|
+
"sourcesContent": ["// @ts-nocheck\n/**\n * @description\n * HTTP code snippet generator for native Go.\n *\n * @author\n * @montanaflynn\n *\n * for any questions or issues regarding the generated code snippet, please open an issue mentioning the author.\n */\nimport { CodeBuilder } from '../../../helpers/code-builder.js'\nimport { escapeForDoubleQuotes } from '../../../helpers/escape.js'\n\nexport const native = {\n info: {\n key: 'native',\n title: 'NewRequest',\n link: 'http://golang.org/pkg/net/http/#NewRequest',\n description: 'Golang HTTP client request',\n },\n convert: ({ postData, method, allHeaders, fullUrl }, options = {}) => {\n const { blank, push, join, addPostProcessor } = new CodeBuilder({ indent: '\\t' })\n const {\n showBoilerplate = true,\n checkErrors = false,\n printBody = true,\n timeout = -1,\n insecureSkipVerify = false,\n } = options\n const errorPlaceholder = checkErrors ? 'err' : '_'\n const indent = showBoilerplate ? 1 : 0\n const errorCheck = () => {\n if (checkErrors) {\n push('if err != nil {', indent)\n push('panic(err)', indent + 1)\n push('}', indent)\n }\n }\n // Create boilerplate\n const imports = new Set()\n if (showBoilerplate) {\n push('package main')\n blank()\n\n push('import ()')\n addPostProcessor((code) => {\n const importArray = [...imports]\n importArray.sort()\n const importBlock = importArray.map((line) => `\\t\"${line}\"`).join('\\n')\n return code.replace(/import \\(\\)/, `import (\\n${importBlock}\\n)`)\n })\n\n imports.add('fmt')\n imports.add('net/http')\n\n blank()\n push('func main() {')\n }\n // Create an insecure transport for the client\n if (insecureSkipVerify) {\n imports.add('crypto/tls')\n push(\n 'insecureTransport := http.DefaultTransport.(*http.Transport).Clone()',\n indent,\n )\n push(\n 'insecureTransport.TLSClientConfig = &tls.Config{InsecureSkipVerify: true}',\n indent,\n )\n }\n // Create client\n const hasTimeout = timeout > 0\n const hasClient = hasTimeout || insecureSkipVerify\n const client = hasClient ? 'client' : 'http.DefaultClient'\n if (hasClient) {\n push('client := http.Client{', indent)\n if (hasTimeout) {\n imports.add('time')\n push(`Timeout: time.Duration(${timeout} * time.Second),`, indent + 1)\n }\n if (insecureSkipVerify) {\n push('Transport: insecureTransport,', indent + 1)\n }\n push('}', indent)\n blank()\n }\n push(`url := \"${fullUrl}\"`, indent)\n blank()\n // If we have body content or not create the var and reader or nil\n if (postData !== null && postData !== void 0 && (postData.params || postData.text)) {\n if (postData.mimeType === 'application/x-www-form-urlencoded' && postData.params) {\n imports.add('net/url')\n imports.add('strings')\n\n push('postData := url.Values{}', indent)\n postData.params.forEach((param) => {\n push(\n `postData.Set(\"${param.name}\", \"${escapeForDoubleQuotes(param.value)}\")`,\n indent,\n )\n })\n blank()\n push(\n `req, ${errorPlaceholder} := http.NewRequest(\"${method}\", url, strings.NewReader(postData.Encode()))`,\n indent,\n )\n } else if (postData.mimeType === 'multipart/form-data' && postData.params) {\n imports.add('bytes')\n imports.add('mime/multipart')\n\n push('payload := &bytes.Buffer{}', indent)\n push('writer := multipart.NewWriter(payload)', indent)\n postData.params.forEach((param) => {\n blank()\n if (param.fileName) {\n push(`part, ${errorPlaceholder} := writer.CreateFormFile(\"${param.name}\", \"${param.fileName}\")`, indent)\n errorCheck()\n blank()\n push(`f, ${errorPlaceholder} := os.Open(\"${param.fileName}\")`, indent)\n errorCheck()\n push('defer f.Close()', indent)\n blank()\n push(`_, ${errorPlaceholder} = io.Copy(part, f)`, indent)\n errorCheck()\n } else {\n push(`${errorPlaceholder} = writer.WriteField(\"${param.name}\", \"${escapeForDoubleQuotes(param.value)}\")`, indent)\n errorCheck()\n }\n })\n push('writer.Close()', indent)\n blank()\n push(\n `req, ${errorPlaceholder} := http.NewRequest(\"${method}\", url, payload)`,\n indent,\n )\n } else {\n imports.add('strings')\n\n push(\n `payload := strings.NewReader(${JSON.stringify(postData.text)})`,\n indent,\n )\n blank()\n push(\n `req, ${errorPlaceholder} := http.NewRequest(\"${method}\", url, payload)`,\n indent,\n )\n }\n } else {\n push(\n `req, ${errorPlaceholder} := http.NewRequest(\"${method}\", url, nil)`,\n indent,\n )\n }\n errorCheck()\n blank()\n // Add headers\n if (postData !== null && postData !== void 0 && postData.mimeType === 'multipart/form-data' && postData.params) {\n push(`req.Header.Set(\"Content-Type\", writer.FormDataContentType())`, indent)\n }\n if (Object.keys(allHeaders).length) {\n Object.keys(allHeaders).forEach((key) => {\n push(\n `req.Header.Add(\"${key}\", \"${escapeForDoubleQuotes(allHeaders[key])}\")`,\n indent,\n )\n })\n blank()\n }\n // Make request\n push(`res, ${errorPlaceholder} := ${client}.Do(req)`, indent)\n errorCheck()\n // Get Body\n if (printBody) {\n imports.add('io')\n blank()\n push('defer res.Body.Close()', indent)\n push(`body, ${errorPlaceholder} := io.ReadAll(res.Body)`, indent)\n errorCheck()\n }\n // Print it\n blank()\n push('fmt.Println(res)', indent)\n if (printBody) {\n push('fmt.Println(string(body))', indent)\n }\n // End main block\n if (showBoilerplate) {\n blank()\n push('}')\n }\n return join()\n },\n}\n"],
|
|
5
|
+
"mappings": "AAUA,SAAS,mBAAmB;AAC5B,SAAS,6BAA6B;AAE/B,MAAM,SAAS;AAAA,EACp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,iBAAiB;AACnB,YAAM;AACN,WAAK,GAAG;AAAA,IACV;AACA,WAAO,KAAK;AAAA,EACd;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../../../../../src/httpsnippet-lite/esm/targets/java/okhttp/client.ts"],"names":[],"mappings":"AAaA,eAAO,MAAM,MAAM;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../../../../../src/httpsnippet-lite/esm/targets/java/okhttp/client.ts"],"names":[],"mappings":"AAaA,eAAO,MAAM,MAAM;;;;;;;;;;;;;CA0ElB,CAAA"}
|
|
@@ -17,17 +17,33 @@ const okhttp = {
|
|
|
17
17
|
const methodsWithBody = ["POST", "PUT", "DELETE", "PATCH"];
|
|
18
18
|
push("OkHttpClient client = new OkHttpClient();");
|
|
19
19
|
blank();
|
|
20
|
-
if (postData
|
|
21
|
-
if (postData.
|
|
22
|
-
push(
|
|
23
|
-
|
|
24
|
-
|
|
20
|
+
if (postData !== null && postData !== void 0) {
|
|
21
|
+
if (postData.mimeType === "application/x-www-form-urlencoded" && postData.params) {
|
|
22
|
+
push("FormBody formBody = new FormBody.Builder()");
|
|
23
|
+
postData.params.forEach((param) => {
|
|
24
|
+
push(`.addEncoded("${param.name}", "${param.value}")`, 1);
|
|
25
|
+
});
|
|
26
|
+
push(".build();", 1);
|
|
27
|
+
blank();
|
|
28
|
+
} else if (postData.mimeType === "multipart/form-data" && postData.params) {
|
|
29
|
+
push(`MultipartBody body = new MultipartBody.Builder()`);
|
|
30
|
+
push(`.setType(MultipartBody.FORM)`, 1);
|
|
31
|
+
postData.params.forEach((param) => {
|
|
32
|
+
if (param.fileName !== void 0) {
|
|
33
|
+
push(
|
|
34
|
+
`.addFormDataPart("${param.name}", "${param.fileName}", RequestBody.create(MediaType.parse("application/octet-stream"), new File("${param.fileName}")))`,
|
|
35
|
+
1
|
|
36
|
+
);
|
|
37
|
+
} else if (param.value !== void 0) {
|
|
38
|
+
push(`.addFormDataPart("${param.name}", "${param.value}")`, 1);
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
push(".build();", 1);
|
|
42
|
+
blank();
|
|
25
43
|
} else {
|
|
26
44
|
push(`MediaType mediaType = MediaType.parse("${postData.mimeType}");`);
|
|
45
|
+
push(`RequestBody body = RequestBody.create(mediaType, ${JSON.stringify(postData.text)});`);
|
|
27
46
|
}
|
|
28
|
-
push(
|
|
29
|
-
`RequestBody body = RequestBody.create(mediaType, ${JSON.stringify(postData.text)});`
|
|
30
|
-
);
|
|
31
47
|
}
|
|
32
48
|
push("Request request = new Request.Builder()");
|
|
33
49
|
push(`.url("${fullUrl}")`, 1);
|
|
@@ -38,7 +54,7 @@ const okhttp = {
|
|
|
38
54
|
push(`.method("${method.toUpperCase()}", null)`, 1);
|
|
39
55
|
}
|
|
40
56
|
} else if (methodsWithBody.includes(method.toUpperCase())) {
|
|
41
|
-
if (postData === null || postData === void 0 ? void 0 : postData.text) {
|
|
57
|
+
if (postData === null || postData === void 0 ? void 0 : postData.text || postData.params) {
|
|
42
58
|
push(`.${method.toLowerCase()}(body)`, 1);
|
|
43
59
|
} else {
|
|
44
60
|
push(`.${method.toLowerCase()}(null)`, 1);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../src/httpsnippet-lite/esm/targets/java/okhttp/client.ts"],
|
|
4
|
-
"sourcesContent": ["// @ts-nocheck\n/**\n * @description\n * HTTP code snippet generator for Java using OkHttp.\n *\n * @author\n * @shashiranjan84\n *\n * for any questions or issues regarding the generated code snippet, please open an issue mentioning the author.\n */\nimport { CodeBuilder } from '../../../helpers/code-builder.js'\nimport { escapeForDoubleQuotes } from '../../../helpers/escape.js'\n\nexport const okhttp = {\n info: {\n key: 'okhttp',\n title: 'OkHttp',\n link: 'http://square.github.io/okhttp/',\n description: 'An HTTP Request Client Library',\n },\n convert: ({ postData, method, fullUrl, allHeaders }, options) => {\n const opts = {\n indent: ' ',\n ...options,\n }\n const { push, blank, join } = new CodeBuilder({ indent: opts.indent })\n const methods = ['GET', 'POST', 'PUT', 'DELETE', 'PATCH', 'HEAD']\n const methodsWithBody = ['POST', 'PUT', 'DELETE', 'PATCH']\n push('OkHttpClient client = new OkHttpClient();')\n blank()\n if (postData
|
|
5
|
-
"mappings": "AAUA,SAAS,mBAAmB;AAC5B,SAAS,6BAA6B;AAE/B,MAAM,SAAS;AAAA,EACpB,MAAM;AAAA,IACJ,KAAK;AAAA,IACL,OAAO;AAAA,IACP,MAAM;AAAA,IACN,aAAa;AAAA,EACf;AAAA,EACA,SAAS,CAAC,EAAE,UAAU,QAAQ,SAAS,WAAW,GAAG,YAAY;AAC/D,UAAM,OAAO;AAAA,MACX,QAAQ;AAAA,MACR,GAAG;AAAA,IACL;AACA,UAAM,EAAE,MAAM,OAAO,KAAK,IAAI,IAAI,YAAY,EAAE,QAAQ,KAAK,OAAO,CAAC;AACrE,UAAM,UAAU,CAAC,OAAO,QAAQ,OAAO,UAAU,SAAS,MAAM;AAChE,UAAM,kBAAkB,CAAC,QAAQ,OAAO,UAAU,OAAO;AACzD,SAAK,2CAA2C;AAChD,UAAM;AACN,QAAI,aAAa,QAAQ,aAAa,
|
|
4
|
+
"sourcesContent": ["// @ts-nocheck\n/**\n * @description\n * HTTP code snippet generator for Java using OkHttp.\n *\n * @author\n * @shashiranjan84\n *\n * for any questions or issues regarding the generated code snippet, please open an issue mentioning the author.\n */\nimport { CodeBuilder } from '../../../helpers/code-builder.js'\nimport { escapeForDoubleQuotes } from '../../../helpers/escape.js'\n\nexport const okhttp = {\n info: {\n key: 'okhttp',\n title: 'OkHttp',\n link: 'http://square.github.io/okhttp/',\n description: 'An HTTP Request Client Library',\n },\n convert: ({ postData, method, fullUrl, allHeaders }, options) => {\n const opts = {\n indent: ' ',\n ...options,\n }\n const { push, blank, join } = new CodeBuilder({ indent: opts.indent })\n const methods = ['GET', 'POST', 'PUT', 'DELETE', 'PATCH', 'HEAD']\n const methodsWithBody = ['POST', 'PUT', 'DELETE', 'PATCH']\n push('OkHttpClient client = new OkHttpClient();')\n blank()\n if (postData !== null && postData !== void 0) {\n if (postData.mimeType === 'application/x-www-form-urlencoded' && postData.params) {\n push('FormBody formBody = new FormBody.Builder()')\n postData.params.forEach((param) => {\n push(`.addEncoded(\"${param.name}\", \"${param.value}\")`, 1)\n })\n push('.build();', 1)\n blank()\n } else if (postData.mimeType === 'multipart/form-data' && postData.params) {\n push(`MultipartBody body = new MultipartBody.Builder()`)\n push(`.setType(MultipartBody.FORM)`, 1)\n postData.params.forEach((param) => {\n if (param.fileName !== undefined) {\n push(\n `.addFormDataPart(\"${param.name}\", \"${param.fileName}\", RequestBody.create(MediaType.parse(\"application/octet-stream\"), new File(\"${param.fileName}\")))`,\n 1,\n )\n } else if (param.value !== undefined) {\n push(`.addFormDataPart(\"${param.name}\", \"${param.value}\")`, 1)\n }\n })\n push('.build();', 1)\n blank()\n } else {\n push(`MediaType mediaType = MediaType.parse(\"${postData.mimeType}\");`)\n push(`RequestBody body = RequestBody.create(mediaType, ${JSON.stringify(postData.text)});`)\n }\n }\n push('Request request = new Request.Builder()')\n push(`.url(\"${fullUrl}\")`, 1)\n if (!methods.includes(method.toUpperCase())) {\n if (postData === null || postData === void 0 ? void 0 : postData.text) {\n push(`.method(\"${method.toUpperCase()}\", body)`, 1)\n } else {\n push(`.method(\"${method.toUpperCase()}\", null)`, 1)\n }\n } else if (methodsWithBody.includes(method.toUpperCase())) {\n if (postData === null || postData === void 0 ? void 0 : postData.text || postData.params) {\n push(`.${method.toLowerCase()}(body)`, 1)\n } else {\n push(`.${method.toLowerCase()}(null)`, 1)\n }\n } else {\n push(`.${method.toLowerCase()}()`, 1)\n }\n // Add headers, including the cookies\n Object.keys(allHeaders).forEach((key) => {\n push(\n `.addHeader(\"${key}\", \"${escapeForDoubleQuotes(allHeaders[key])}\")`,\n 1,\n )\n })\n push('.build();', 1)\n blank()\n push('Response response = client.newCall(request).execute();')\n return join()\n },\n}\n"],
|
|
5
|
+
"mappings": "AAUA,SAAS,mBAAmB;AAC5B,SAAS,6BAA6B;AAE/B,MAAM,SAAS;AAAA,EACpB,MAAM;AAAA,IACJ,KAAK;AAAA,IACL,OAAO;AAAA,IACP,MAAM;AAAA,IACN,aAAa;AAAA,EACf;AAAA,EACA,SAAS,CAAC,EAAE,UAAU,QAAQ,SAAS,WAAW,GAAG,YAAY;AAC/D,UAAM,OAAO;AAAA,MACX,QAAQ;AAAA,MACR,GAAG;AAAA,IACL;AACA,UAAM,EAAE,MAAM,OAAO,KAAK,IAAI,IAAI,YAAY,EAAE,QAAQ,KAAK,OAAO,CAAC;AACrE,UAAM,UAAU,CAAC,OAAO,QAAQ,OAAO,UAAU,SAAS,MAAM;AAChE,UAAM,kBAAkB,CAAC,QAAQ,OAAO,UAAU,OAAO;AACzD,SAAK,2CAA2C;AAChD,UAAM;AACN,QAAI,aAAa,QAAQ,aAAa,QAAQ;AAC5C,UAAI,SAAS,aAAa,uCAAuC,SAAS,QAAQ;AAChF,aAAK,4CAA4C;AACjD,iBAAS,OAAO,QAAQ,CAAC,UAAU;AACjC,eAAK,gBAAgB,MAAM,IAAI,OAAO,MAAM,KAAK,MAAM,CAAC;AAAA,QAC1D,CAAC;AACD,aAAK,aAAa,CAAC;AACnB,cAAM;AAAA,MACR,WAAW,SAAS,aAAa,yBAAyB,SAAS,QAAQ;AACzE,aAAK,kDAAkD;AACvD,aAAK,gCAAgC,CAAC;AACtC,iBAAS,OAAO,QAAQ,CAAC,UAAU;AACjC,cAAI,MAAM,aAAa,QAAW;AAChC;AAAA,cACE,qBAAqB,MAAM,IAAI,OAAO,MAAM,QAAQ,gFAAgF,MAAM,QAAQ;AAAA,cAClJ;AAAA,YACF;AAAA,UACF,WAAW,MAAM,UAAU,QAAW;AACpC,iBAAK,qBAAqB,MAAM,IAAI,OAAO,MA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/okhttp/client.ts"],"names":[],"mappings":"AAaA,eAAO,MAAM,MAAM;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../../../../../src/httpsnippet-lite/esm/targets/kotlin/okhttp/client.ts"],"names":[],"mappings":"AAaA,eAAO,MAAM,MAAM;;;;;;;;;;;;;CA0ElB,CAAA"}
|
|
@@ -17,17 +17,33 @@ const okhttp = {
|
|
|
17
17
|
const methodsWithBody = ["POST", "PUT", "DELETE", "PATCH"];
|
|
18
18
|
push("val client = OkHttpClient()");
|
|
19
19
|
blank();
|
|
20
|
-
if (postData
|
|
21
|
-
if (postData.
|
|
22
|
-
push(
|
|
23
|
-
|
|
24
|
-
|
|
20
|
+
if (postData !== null && postData !== void 0) {
|
|
21
|
+
if (postData.mimeType === "application/x-www-form-urlencoded" && postData.params) {
|
|
22
|
+
push("val formBody = FormBody.Builder()");
|
|
23
|
+
postData.params.forEach((param) => {
|
|
24
|
+
push(`.addEncoded("${param.name}", "${param.value}")`, 1);
|
|
25
|
+
});
|
|
26
|
+
push(".build()", 1);
|
|
27
|
+
blank();
|
|
28
|
+
} else if (postData.mimeType === "multipart/form-data" && postData.params) {
|
|
29
|
+
push(`val body = MultipartBody.Builder()`);
|
|
30
|
+
push(`.setType(MultipartBody.FORM)`, 1);
|
|
31
|
+
postData.params.forEach((param) => {
|
|
32
|
+
if (param.fileName !== void 0) {
|
|
33
|
+
push(
|
|
34
|
+
`.addFormDataPart("${param.name}", "${param.fileName}", RequestBody.create(MediaType.parse("application/octet-stream"), File("${param.fileName}")))`,
|
|
35
|
+
1
|
|
36
|
+
);
|
|
37
|
+
} else if (param.value !== void 0) {
|
|
38
|
+
push(`.addFormDataPart("${param.name}", "${param.value}")`, 1);
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
push(`.build()`, 1);
|
|
42
|
+
blank();
|
|
25
43
|
} else {
|
|
26
44
|
push(`val mediaType = MediaType.parse("${postData.mimeType}")`);
|
|
45
|
+
push(`val body = RequestBody.create(mediaType, ${JSON.stringify(postData.text)})`);
|
|
27
46
|
}
|
|
28
|
-
push(
|
|
29
|
-
`val body = RequestBody.create(mediaType, ${JSON.stringify(postData.text)})`
|
|
30
|
-
);
|
|
31
47
|
}
|
|
32
48
|
push("val request = Request.Builder()");
|
|
33
49
|
push(`.url("${fullUrl}")`, 1);
|
|
@@ -38,7 +54,7 @@ const okhttp = {
|
|
|
38
54
|
push(`.method("${method.toUpperCase()}", null)`, 1);
|
|
39
55
|
}
|
|
40
56
|
} else if (methodsWithBody.includes(method.toUpperCase())) {
|
|
41
|
-
if (postData === null || postData === void 0 ? void 0 : postData.text) {
|
|
57
|
+
if (postData === null || postData === void 0 ? void 0 : postData.text || postData.params) {
|
|
42
58
|
push(`.${method.toLowerCase()}(body)`, 1);
|
|
43
59
|
} else {
|
|
44
60
|
push(`.${method.toLowerCase()}(null)`, 1);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../src/httpsnippet-lite/esm/targets/kotlin/okhttp/client.ts"],
|
|
4
|
-
"sourcesContent": ["// @ts-nocheck\n/**\n * @description\n * HTTP code snippet generator for Kotlin using OkHttp.\n *\n * @author\n * @seanghay\n *\n * for any questions or issues regarding the generated code snippet, please open an issue mentioning the author.\n */\nimport { CodeBuilder } from '../../../helpers/code-builder.js'\nimport { escapeForDoubleQuotes } from '../../../helpers/escape.js'\n\nexport const okhttp = {\n info: {\n key: 'okhttp',\n title: 'OkHttp',\n link: 'http://square.github.io/okhttp/',\n description: 'An HTTP Request Client Library',\n },\n convert: ({ postData, fullUrl, method, allHeaders }, options) => {\n const opts = {\n indent: ' ',\n ...options,\n }\n const { blank, join, push } = new CodeBuilder({ indent: opts.indent })\n const methods = ['GET', 'POST', 'PUT', 'DELETE', 'PATCH', 'HEAD']\n const methodsWithBody = ['POST', 'PUT', 'DELETE', 'PATCH']\n push('val client = OkHttpClient()')\n blank()\n if (postData
|
|
5
|
-
"mappings": "AAUA,SAAS,mBAAmB;AAC5B,SAAS,6BAA6B;AAE/B,MAAM,SAAS;AAAA,EACpB,MAAM;AAAA,IACJ,KAAK;AAAA,IACL,OAAO;AAAA,IACP,MAAM;AAAA,IACN,aAAa;AAAA,EACf;AAAA,EACA,SAAS,CAAC,EAAE,UAAU,SAAS,QAAQ,WAAW,GAAG,YAAY;AAC/D,UAAM,OAAO;AAAA,MACX,QAAQ;AAAA,MACR,GAAG;AAAA,IACL;AACA,UAAM,EAAE,OAAO,MAAM,KAAK,IAAI,IAAI,YAAY,EAAE,QAAQ,KAAK,OAAO,CAAC;AACrE,UAAM,UAAU,CAAC,OAAO,QAAQ,OAAO,UAAU,SAAS,MAAM;AAChE,UAAM,kBAAkB,CAAC,QAAQ,OAAO,UAAU,OAAO;AACzD,SAAK,6BAA6B;AAClC,UAAM;AACN,QAAI,aAAa,QAAQ,aAAa,
|
|
4
|
+
"sourcesContent": ["// @ts-nocheck\n/**\n * @description\n * HTTP code snippet generator for Kotlin using OkHttp.\n *\n * @author\n * @seanghay\n *\n * for any questions or issues regarding the generated code snippet, please open an issue mentioning the author.\n */\nimport { CodeBuilder } from '../../../helpers/code-builder.js'\nimport { escapeForDoubleQuotes } from '../../../helpers/escape.js'\n\nexport const okhttp = {\n info: {\n key: 'okhttp',\n title: 'OkHttp',\n link: 'http://square.github.io/okhttp/',\n description: 'An HTTP Request Client Library',\n },\n convert: ({ postData, fullUrl, method, allHeaders }, options) => {\n const opts = {\n indent: ' ',\n ...options,\n }\n const { blank, join, push } = new CodeBuilder({ indent: opts.indent })\n const methods = ['GET', 'POST', 'PUT', 'DELETE', 'PATCH', 'HEAD']\n const methodsWithBody = ['POST', 'PUT', 'DELETE', 'PATCH']\n push('val client = OkHttpClient()')\n blank()\n if (postData !== null && postData !== void 0) {\n if (postData.mimeType === 'application/x-www-form-urlencoded' && postData.params) {\n push('val formBody = FormBody.Builder()')\n postData.params.forEach((param) => {\n push(`.addEncoded(\"${param.name}\", \"${param.value}\")`, 1)\n })\n push('.build()', 1)\n blank()\n } else if (postData.mimeType === 'multipart/form-data' && postData.params) {\n push(`val body = MultipartBody.Builder()`)\n push(`.setType(MultipartBody.FORM)`, 1)\n postData.params.forEach((param) => {\n if (param.fileName !== undefined) {\n push(\n `.addFormDataPart(\"${param.name}\", \"${param.fileName}\", RequestBody.create(MediaType.parse(\"application/octet-stream\"), File(\"${param.fileName}\")))`,\n 1,\n )\n } else if (param.value !== undefined) {\n push(`.addFormDataPart(\"${param.name}\", \"${param.value}\")`, 1)\n }\n })\n push(`.build()`, 1)\n blank()\n } else {\n push(`val mediaType = MediaType.parse(\"${postData.mimeType}\")`)\n push(`val body = RequestBody.create(mediaType, ${JSON.stringify(postData.text)})`)\n }\n }\n push('val request = Request.Builder()')\n push(`.url(\"${fullUrl}\")`, 1)\n if (!methods.includes(method.toUpperCase())) {\n if (postData === null || postData === void 0 ? void 0 : postData.text) {\n push(`.method(\"${method.toUpperCase()}\", body)`, 1)\n } else {\n push(`.method(\"${method.toUpperCase()}\", null)`, 1)\n }\n } else if (methodsWithBody.includes(method.toUpperCase())) {\n if (postData === null || postData === void 0 ? void 0 : postData.text || postData.params) {\n push(`.${method.toLowerCase()}(body)`, 1)\n } else {\n push(`.${method.toLowerCase()}(null)`, 1)\n }\n } else {\n push(`.${method.toLowerCase()}()`, 1)\n }\n // Add headers, including the cookies\n Object.keys(allHeaders).forEach((key) => {\n push(\n `.addHeader(\"${key}\", \"${escapeForDoubleQuotes(allHeaders[key])}\")`,\n 1,\n )\n })\n push('.build()', 1)\n blank()\n push('val response = client.newCall(request).execute()')\n return join()\n },\n}\n"],
|
|
5
|
+
"mappings": "AAUA,SAAS,mBAAmB;AAC5B,SAAS,6BAA6B;AAE/B,MAAM,SAAS;AAAA,EACpB,MAAM;AAAA,IACJ,KAAK;AAAA,IACL,OAAO;AAAA,IACP,MAAM;AAAA,IACN,aAAa;AAAA,EACf;AAAA,EACA,SAAS,C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,QAAI,CAAC,QAAQ,SAAS,OAAO,YAAY,CAAC,GAAG;AAC3C,UAAI,aAAa,QAAQ,aAAa,SAAS,SAAS,SAAS,MAAM;AACrE,aAAK,YAAY,OAAO,YAAY,CAAC,YAAY,CAAC;AAAA,MACpD,OAAO;AACL,aAAK,YAAY,OAAO,YAAY,CAAC,YAAY,CAAC;AAAA,MACpD;AAAA,IACF,WAAW,gBAAgB,SAAS,OAAO,YAAY,CAAC,GAAG;AACzD,UAAI,aAAa,QAAQ,aAAa,SAAS,SAAS,SAAS,QAAQ,SAAS,QAAQ;AACxF,aAAK,IAAI,OAAO,YAAY,CAAC,UAAU,CAAC;AAAA,MAC1C,OAAO;AACL,aAAK,IAAI,OAAO,YAAY,CAAC,UAAU,CAAC;AAAA,MAC1C;AAAA,IACF,OAAO;AACL,WAAK,IAAI,OAAO,YAAY,CAAC,MAAM,CAAC;AAAA,IACtC;AAEA,WAAO,KAAK,UAAU,EAAE,QAAQ,CAAC,QAAQ;AACvC;AAAA,QACE,eAAe,GAAG,OAAO,sBAAsB,WAAW,GAAG,CAAC,CAAC;AAAA,QAC/D;AAAA,MACF;AAAA,IACF,CAAC;AACD,SAAK,YAAY,CAAC;AAClB,UAAM;AACN,SAAK,kDAAkD;AACvD,WAAO,KAAK;AAAA,EACd;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../../../../../src/httpsnippet-lite/esm/targets/shell/httpie/client.ts"],"names":[],"mappings":"AAaA,eAAO,MAAM,MAAM;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../../../../../src/httpsnippet-lite/esm/targets/shell/httpie/client.ts"],"names":[],"mappings":"AAaA,eAAO,MAAM,MAAM;;;;;;;;;;;;;;;CA0HlB,CAAA"}
|
|
@@ -80,6 +80,17 @@ ${opts.indent}` : " "
|
|
|
80
80
|
push(`${param.name}=${quote(param.value)}`);
|
|
81
81
|
});
|
|
82
82
|
}
|
|
83
|
+
} else if ((postData === null || postData === void 0 ? void 0 : postData.mimeType) === "multipart/form-data") {
|
|
84
|
+
if (postData.params?.length) {
|
|
85
|
+
flags.push("--multipart");
|
|
86
|
+
postData.params.forEach((param) => {
|
|
87
|
+
if (param.fileName) {
|
|
88
|
+
push(`${param.name}@${quote(param.fileName)}`);
|
|
89
|
+
} else {
|
|
90
|
+
push(`${param.name}='${quote(param.value)}'`);
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
}
|
|
83
94
|
} else {
|
|
84
95
|
raw = true;
|
|
85
96
|
}
|