@scalar/snippetz 0.2.5 → 0.2.7
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/README.md +3 -3
- package/dist/core/types.d.ts +46 -11
- package/dist/core/types.d.ts.map +1 -1
- package/dist/core/utils/convertWithHttpSnippetLite.d.ts +7 -0
- package/dist/core/utils/convertWithHttpSnippetLite.d.ts.map +1 -0
- package/dist/core/utils/convertWithHttpSnippetLite.js +83 -0
- package/dist/plugins/c/libcurl/index.d.ts +2 -0
- package/dist/plugins/c/libcurl/index.d.ts.map +1 -0
- package/dist/plugins/c/libcurl/index.js +1 -0
- package/dist/plugins/c/libcurl/libcurl.d.ts +6 -0
- package/dist/plugins/c/libcurl/libcurl.d.ts.map +1 -0
- package/dist/plugins/c/libcurl/libcurl.js +16 -0
- package/dist/plugins/clojure/clj_http/clj_http.d.ts +6 -0
- package/dist/plugins/clojure/clj_http/clj_http.d.ts.map +1 -0
- package/dist/plugins/clojure/clj_http/clj_http.js +16 -0
- package/dist/plugins/clojure/clj_http/index.d.ts +2 -0
- package/dist/plugins/clojure/clj_http/index.d.ts.map +1 -0
- package/dist/plugins/clojure/clj_http/index.js +1 -0
- package/dist/plugins/csharp/httpclient/httpclient.d.ts +6 -0
- package/dist/plugins/csharp/httpclient/httpclient.d.ts.map +1 -0
- package/dist/plugins/csharp/httpclient/httpclient.js +16 -0
- package/dist/plugins/csharp/httpclient/index.d.ts +2 -0
- package/dist/plugins/csharp/httpclient/index.d.ts.map +1 -0
- package/dist/plugins/csharp/httpclient/index.js +1 -0
- package/dist/plugins/csharp/restsharp/index.d.ts +2 -0
- package/dist/plugins/csharp/restsharp/index.d.ts.map +1 -0
- package/dist/plugins/csharp/restsharp/index.js +1 -0
- package/dist/plugins/csharp/restsharp/restsharp.d.ts +6 -0
- package/dist/plugins/csharp/restsharp/restsharp.d.ts.map +1 -0
- package/dist/plugins/csharp/restsharp/restsharp.js +16 -0
- package/dist/plugins/go/native/index.d.ts +2 -0
- package/dist/plugins/go/native/index.d.ts.map +1 -0
- package/dist/plugins/go/native/index.js +1 -0
- package/dist/plugins/go/native/native.d.ts +6 -0
- package/dist/plugins/go/native/native.d.ts.map +1 -0
- package/dist/plugins/go/native/native.js +16 -0
- package/dist/plugins/http/http11/http11.d.ts +6 -0
- package/dist/plugins/http/http11/http11.d.ts.map +1 -0
- package/dist/plugins/http/http11/http11.js +16 -0
- package/dist/plugins/http/http11/index.d.ts +2 -0
- package/dist/plugins/http/http11/index.d.ts.map +1 -0
- package/dist/plugins/http/http11/index.js +1 -0
- package/dist/plugins/java/asynchttp/asynchttp.d.ts +6 -0
- package/dist/plugins/java/asynchttp/asynchttp.d.ts.map +1 -0
- package/dist/plugins/java/asynchttp/asynchttp.js +16 -0
- package/dist/plugins/java/asynchttp/index.d.ts +2 -0
- package/dist/plugins/java/asynchttp/index.d.ts.map +1 -0
- package/dist/plugins/java/asynchttp/index.js +1 -0
- package/dist/plugins/java/nethttp/index.d.ts +2 -0
- package/dist/plugins/java/nethttp/index.d.ts.map +1 -0
- package/dist/plugins/java/nethttp/index.js +1 -0
- package/dist/plugins/java/nethttp/nethttp.d.ts +6 -0
- package/dist/plugins/java/nethttp/nethttp.d.ts.map +1 -0
- package/dist/plugins/java/nethttp/nethttp.js +16 -0
- package/dist/plugins/java/okhttp/index.d.ts +2 -0
- package/dist/plugins/java/okhttp/index.d.ts.map +1 -0
- package/dist/plugins/java/okhttp/index.js +1 -0
- package/dist/plugins/java/okhttp/okhttp.d.ts +6 -0
- package/dist/plugins/java/okhttp/okhttp.d.ts.map +1 -0
- package/dist/plugins/java/okhttp/okhttp.js +16 -0
- package/dist/plugins/java/unirest/index.d.ts +2 -0
- package/dist/plugins/java/unirest/index.d.ts.map +1 -0
- package/dist/plugins/java/unirest/index.js +1 -0
- package/dist/plugins/java/unirest/unirest.d.ts +6 -0
- package/dist/plugins/java/unirest/unirest.d.ts.map +1 -0
- package/dist/plugins/java/unirest/unirest.js +16 -0
- package/dist/plugins/js/axios/axios.d.ts +6 -0
- package/dist/plugins/js/axios/axios.d.ts.map +1 -0
- package/dist/plugins/js/axios/axios.js +16 -0
- package/dist/plugins/js/axios/index.d.ts +2 -0
- package/dist/plugins/js/axios/index.d.ts.map +1 -0
- package/dist/plugins/js/axios/index.js +1 -0
- package/dist/plugins/js/fetch/fetch.d.ts +2 -6
- package/dist/plugins/js/fetch/fetch.d.ts.map +1 -1
- package/dist/plugins/js/fetch/fetch.js +60 -59
- package/dist/plugins/js/fetch/index.js +1 -1
- package/dist/plugins/js/jquery/index.d.ts +2 -0
- package/dist/plugins/js/jquery/index.d.ts.map +1 -0
- package/dist/plugins/js/jquery/index.js +1 -0
- package/dist/plugins/js/jquery/jquery.d.ts +6 -0
- package/dist/plugins/js/jquery/jquery.d.ts.map +1 -0
- package/dist/plugins/js/jquery/jquery.js +16 -0
- package/dist/plugins/js/ofetch/index.js +1 -1
- package/dist/plugins/js/ofetch/ofetch.d.ts +2 -6
- package/dist/plugins/js/ofetch/ofetch.d.ts.map +1 -1
- package/dist/plugins/js/ofetch/ofetch.js +65 -64
- package/dist/plugins/js/xhr/index.d.ts +2 -0
- package/dist/plugins/js/xhr/index.d.ts.map +1 -0
- package/dist/plugins/js/xhr/index.js +1 -0
- package/dist/plugins/js/xhr/xhr.d.ts +6 -0
- package/dist/plugins/js/xhr/xhr.d.ts.map +1 -0
- package/dist/plugins/js/xhr/xhr.js +16 -0
- package/dist/plugins/kotlin/okhttp/index.d.ts +2 -0
- package/dist/plugins/kotlin/okhttp/index.d.ts.map +1 -0
- package/dist/plugins/kotlin/okhttp/index.js +1 -0
- package/dist/plugins/kotlin/okhttp/okhttp.d.ts +6 -0
- package/dist/plugins/kotlin/okhttp/okhttp.d.ts.map +1 -0
- package/dist/plugins/kotlin/okhttp/okhttp.js +16 -0
- package/dist/plugins/node/axios/axios.d.ts +6 -0
- package/dist/plugins/node/axios/axios.d.ts.map +1 -0
- package/dist/plugins/node/axios/axios.js +16 -0
- package/dist/plugins/node/axios/index.d.ts +2 -0
- package/dist/plugins/node/axios/index.d.ts.map +1 -0
- package/dist/plugins/node/axios/index.js +1 -0
- package/dist/plugins/node/fetch/fetch.d.ts +2 -6
- package/dist/plugins/node/fetch/fetch.d.ts.map +1 -1
- package/dist/plugins/node/fetch/fetch.js +60 -59
- package/dist/plugins/node/fetch/index.js +1 -1
- package/dist/plugins/node/ofetch/index.js +1 -1
- package/dist/plugins/node/ofetch/ofetch.d.ts +2 -6
- package/dist/plugins/node/ofetch/ofetch.d.ts.map +1 -1
- package/dist/plugins/node/ofetch/ofetch.js +65 -64
- package/dist/plugins/node/undici/index.js +1 -1
- package/dist/plugins/node/undici/undici.d.ts +2 -6
- package/dist/plugins/node/undici/undici.d.ts.map +1 -1
- package/dist/plugins/node/undici/undici.js +60 -59
- package/dist/plugins/objc/nsurlsession/index.d.ts +2 -0
- package/dist/plugins/objc/nsurlsession/index.d.ts.map +1 -0
- package/dist/plugins/objc/nsurlsession/index.js +1 -0
- package/dist/plugins/objc/nsurlsession/nsurlsession.d.ts +6 -0
- package/dist/plugins/objc/nsurlsession/nsurlsession.d.ts.map +1 -0
- package/dist/plugins/objc/nsurlsession/nsurlsession.js +16 -0
- package/dist/plugins/ocaml/cohttp/cohttp.d.ts +6 -0
- package/dist/plugins/ocaml/cohttp/cohttp.d.ts.map +1 -0
- package/dist/plugins/ocaml/cohttp/cohttp.js +16 -0
- package/dist/plugins/ocaml/cohttp/index.d.ts +2 -0
- package/dist/plugins/ocaml/cohttp/index.d.ts.map +1 -0
- package/dist/plugins/ocaml/cohttp/index.js +1 -0
- package/dist/plugins/php/curl/curl.d.ts +6 -0
- package/dist/plugins/php/curl/curl.d.ts.map +1 -0
- package/dist/plugins/php/curl/curl.js +16 -0
- package/dist/plugins/php/curl/index.d.ts +2 -0
- package/dist/plugins/php/curl/index.d.ts.map +1 -0
- package/dist/plugins/php/curl/index.js +1 -0
- package/dist/plugins/php/guzzle/guzzle.d.ts +6 -0
- package/dist/plugins/php/guzzle/guzzle.d.ts.map +1 -0
- package/dist/plugins/php/guzzle/guzzle.js +16 -0
- package/dist/plugins/php/guzzle/index.d.ts +2 -0
- package/dist/plugins/php/guzzle/index.d.ts.map +1 -0
- package/dist/plugins/php/guzzle/index.js +1 -0
- package/dist/plugins/powershell/restmethod/index.d.ts +2 -0
- package/dist/plugins/powershell/restmethod/index.d.ts.map +1 -0
- package/dist/plugins/powershell/restmethod/index.js +1 -0
- package/dist/plugins/powershell/restmethod/restmethod.d.ts +6 -0
- package/dist/plugins/powershell/restmethod/restmethod.d.ts.map +1 -0
- package/dist/plugins/powershell/restmethod/restmethod.js +16 -0
- package/dist/plugins/powershell/webrequest/index.d.ts +2 -0
- package/dist/plugins/powershell/webrequest/index.d.ts.map +1 -0
- package/dist/plugins/powershell/webrequest/index.js +1 -0
- package/dist/plugins/powershell/webrequest/webrequest.d.ts +6 -0
- package/dist/plugins/powershell/webrequest/webrequest.d.ts.map +1 -0
- package/dist/plugins/powershell/webrequest/webrequest.js +16 -0
- package/dist/plugins/python/python3/index.d.ts +2 -0
- package/dist/plugins/python/python3/index.d.ts.map +1 -0
- package/dist/plugins/python/python3/index.js +1 -0
- package/dist/plugins/python/python3/python3.d.ts +6 -0
- package/dist/plugins/python/python3/python3.d.ts.map +1 -0
- package/dist/plugins/python/python3/python3.js +16 -0
- package/dist/plugins/python/requests/index.d.ts +2 -0
- package/dist/plugins/python/requests/index.d.ts.map +1 -0
- package/dist/plugins/python/requests/index.js +1 -0
- package/dist/plugins/python/requests/requests.d.ts +6 -0
- package/dist/plugins/python/requests/requests.d.ts.map +1 -0
- package/dist/plugins/python/requests/requests.js +16 -0
- package/dist/plugins/r/httr/httr.d.ts +6 -0
- package/dist/plugins/r/httr/httr.d.ts.map +1 -0
- package/dist/plugins/r/httr/httr.js +16 -0
- package/dist/plugins/r/httr/index.d.ts +2 -0
- package/dist/plugins/r/httr/index.d.ts.map +1 -0
- package/dist/plugins/r/httr/index.js +1 -0
- package/dist/plugins/ruby/native/index.d.ts +2 -0
- package/dist/plugins/ruby/native/index.d.ts.map +1 -0
- package/dist/plugins/ruby/native/index.js +1 -0
- package/dist/plugins/ruby/native/native.d.ts +6 -0
- package/dist/plugins/ruby/native/native.d.ts.map +1 -0
- package/dist/plugins/ruby/native/native.js +16 -0
- package/dist/plugins/shell/curl/curl.d.ts +2 -6
- package/dist/plugins/shell/curl/curl.d.ts.map +1 -1
- package/dist/plugins/shell/curl/curl.js +95 -95
- package/dist/plugins/shell/curl/index.js +1 -1
- package/dist/plugins/shell/httpie/httpie.d.ts +6 -0
- package/dist/plugins/shell/httpie/httpie.d.ts.map +1 -0
- package/dist/plugins/shell/httpie/httpie.js +16 -0
- package/dist/plugins/shell/httpie/index.d.ts +2 -0
- package/dist/plugins/shell/httpie/index.d.ts.map +1 -0
- package/dist/plugins/shell/httpie/index.js +1 -0
- package/dist/plugins/shell/wget/index.d.ts +2 -0
- package/dist/plugins/shell/wget/index.d.ts.map +1 -0
- package/dist/plugins/shell/wget/index.js +1 -0
- package/dist/plugins/shell/wget/wget.d.ts +6 -0
- package/dist/plugins/shell/wget/wget.d.ts.map +1 -0
- package/dist/plugins/shell/wget/wget.js +16 -0
- package/dist/plugins/swift/nsurlsession/index.d.ts +2 -0
- package/dist/plugins/swift/nsurlsession/index.d.ts.map +1 -0
- package/dist/plugins/swift/nsurlsession/index.js +1 -0
- package/dist/plugins/swift/nsurlsession/nsurlsession.d.ts +6 -0
- package/dist/plugins/swift/nsurlsession/nsurlsession.d.ts.map +1 -0
- package/dist/plugins/swift/nsurlsession/nsurlsession.js +16 -0
- package/dist/snippetz.d.ts +8 -11
- package/dist/snippetz.d.ts.map +1 -1
- package/dist/snippetz.js +78 -23
- package/package.json +146 -1
package/README.md
CHANGED
|
@@ -69,13 +69,13 @@ const snippet = snippetz().hasPlugin('node', 'undici')
|
|
|
69
69
|
You can also just use one specific plugin to keep your bundle size small.
|
|
70
70
|
|
|
71
71
|
```ts
|
|
72
|
-
import {
|
|
72
|
+
import { nodeUndici } from '@scalar/snippetz/plugins/node/undici'
|
|
73
73
|
|
|
74
|
-
const
|
|
74
|
+
const result = nodeUndici.generate({
|
|
75
75
|
url: 'https://example.com',
|
|
76
76
|
})
|
|
77
77
|
|
|
78
|
-
console.log(source
|
|
78
|
+
console.log(source)
|
|
79
79
|
|
|
80
80
|
// import { request } from 'undici'
|
|
81
81
|
|
package/dist/core/types.d.ts
CHANGED
|
@@ -1,21 +1,56 @@
|
|
|
1
|
+
import type { Request } from 'har-format';
|
|
1
2
|
export type { Request } from 'har-format';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
3
|
+
/**
|
|
4
|
+
* List of available clients
|
|
5
|
+
*/
|
|
6
|
+
export type AvailableClients = [
|
|
7
|
+
'c/libcurl',
|
|
8
|
+
'clojure/clj_http',
|
|
9
|
+
'csharp/httpclient',
|
|
10
|
+
'csharp/restsharp',
|
|
11
|
+
'go/native',
|
|
12
|
+
'http/http1.1',
|
|
13
|
+
'java/asynchttp',
|
|
14
|
+
'java/nethttp',
|
|
15
|
+
'java/okhttp',
|
|
16
|
+
'java/unirest',
|
|
17
|
+
'js/axios',
|
|
18
|
+
'js/fetch',
|
|
19
|
+
'js/jquery',
|
|
20
|
+
'js/ofetch',
|
|
21
|
+
'js/xhr',
|
|
22
|
+
'kotlin/okhttp',
|
|
23
|
+
'node/axios',
|
|
24
|
+
'node/fetch',
|
|
25
|
+
'node/ofetch',
|
|
26
|
+
'node/undici',
|
|
27
|
+
'objc/nsurlsession',
|
|
28
|
+
'ocaml/cohttp',
|
|
29
|
+
'php/curl',
|
|
30
|
+
'php/guzzle',
|
|
31
|
+
'powershell/restmethod',
|
|
32
|
+
'powershell/webrequest',
|
|
33
|
+
'python/python3',
|
|
34
|
+
'python/requests',
|
|
35
|
+
'r/httr',
|
|
36
|
+
'ruby/native',
|
|
37
|
+
'shell/curl',
|
|
38
|
+
'shell/httpie',
|
|
39
|
+
'shell/wget',
|
|
40
|
+
'swift/nsurlsession'
|
|
41
|
+
];
|
|
42
|
+
/** Programming language */
|
|
43
|
+
export type TargetId = AvailableClients[number] extends `${infer T}/${string}` ? T : never;
|
|
44
|
+
/** HTTP client */
|
|
45
|
+
export type ClientId<T extends string> = T extends TargetId ? Extract<AvailableClients[number], `${T}/${string}`> extends `${T}/${infer C}` ? C : never : never;
|
|
11
46
|
/** What any plugins needs to return */
|
|
12
|
-
export type
|
|
47
|
+
export type Plugin = {
|
|
13
48
|
/** The language or environment. */
|
|
14
49
|
target: TargetId;
|
|
15
50
|
/** The identifier of the client. */
|
|
16
51
|
client: ClientId<TargetId>;
|
|
17
52
|
/** The actual source code. */
|
|
18
|
-
|
|
53
|
+
generate: (request?: Partial<Request>, configuration?: PluginConfiguration) => string;
|
|
19
54
|
};
|
|
20
55
|
/**
|
|
21
56
|
* Optional configuration for any plugin
|
package/dist/core/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/core/types.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/core/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAA;AAEzC,YAAY,EAAE,OAAO,EAAE,MAAM,YAAY,CAAA;AAEzC;;GAEG;AACH,MAAM,MAAM,gBAAgB,GAAG;IAC7B,WAAW;IACX,kBAAkB;IAClB,mBAAmB;IACnB,kBAAkB;IAClB,WAAW;IACX,cAAc;IACd,gBAAgB;IAChB,cAAc;IACd,aAAa;IACb,cAAc;IACd,UAAU;IACV,UAAU;IACV,WAAW;IACX,WAAW;IACX,QAAQ;IACR,eAAe;IACf,YAAY;IACZ,YAAY;IACZ,aAAa;IACb,aAAa;IACb,mBAAmB;IACnB,cAAc;IACd,UAAU;IACV,YAAY;IACZ,uBAAuB;IACvB,uBAAuB;IACvB,gBAAgB;IAChB,iBAAiB;IACjB,QAAQ;IACR,aAAa;IACb,YAAY;IACZ,cAAc;IACd,YAAY;IACZ,oBAAoB;CACrB,CAAA;AAED,2BAA2B;AAC3B,MAAM,MAAM,QAAQ,GAAG,gBAAgB,CAAC,MAAM,CAAC,SAAS,GAAG,MAAM,CAAC,IAAI,MAAM,EAAE,GAC1E,CAAC,GACD,KAAK,CAAA;AAET,kBAAkB;AAClB,MAAM,MAAM,QAAQ,CAAC,CAAC,SAAS,MAAM,IAAI,CAAC,SAAS,QAAQ,GACvD,OAAO,CACL,gBAAgB,CAAC,MAAM,CAAC,EACxB,GAAG,CAAC,IAAI,MAAM,EAAE,CACjB,SAAS,GAAG,CAAC,IAAI,MAAM,CAAC,EAAE,GACzB,CAAC,GACD,KAAK,GACP,KAAK,CAAA;AAET,uCAAuC;AACvC,MAAM,MAAM,MAAM,GAAG;IACnB,mCAAmC;IACnC,MAAM,EAAE,QAAQ,CAAA;IAChB,oCAAoC;IACpC,MAAM,EAAE,QAAQ,CAAC,QAAQ,CAAC,CAAA;IAC1B,8BAA8B;IAC9B,QAAQ,EAAE,CACR,OAAO,CAAC,EAAE,OAAO,CAAC,OAAO,CAAC,EAC1B,aAAa,CAAC,EAAE,mBAAmB,KAChC,MAAM,CAAA;CACZ,CAAA;AAED;;GAEG;AACH,MAAM,MAAM,mBAAmB,GAAG;IAChC,mDAAmD;IACnD,IAAI,CAAC,EAAE;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAA;KAAE,CAAA;CAC9C,CAAA"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { Request } from 'har-format';
|
|
2
|
+
import type { Client } from '../../../node_modules/httpsnippet-lite/dist/types/targets/targets';
|
|
3
|
+
/**
|
|
4
|
+
* Takes a httpsnippet-lite client and converts the given request to a code example with it.
|
|
5
|
+
*/
|
|
6
|
+
export declare function convertWithHttpSnippetLite(client: Client<object>, partialRequest?: Partial<Request>): string;
|
|
7
|
+
//# sourceMappingURL=convertWithHttpSnippetLite.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"convertWithHttpSnippetLite.d.ts","sourceRoot":"","sources":["../../../src/core/utils/convertWithHttpSnippetLite.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAA;AAEzC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,8CAA8C,CAAA;AAE1E;;GAEG;AACH,wBAAgB,0BAA0B,CACxC,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,EACtB,cAAc,CAAC,EAAE,OAAO,CAAC,OAAO,CAAC,GAChC,MAAM,CAiGR"}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Takes a httpsnippet-lite client and converts the given request to a code example with it.
|
|
3
|
+
*/
|
|
4
|
+
function convertWithHttpSnippetLite(client, partialRequest) {
|
|
5
|
+
const request = {
|
|
6
|
+
url: partialRequest?.url ?? '',
|
|
7
|
+
httpVersion: partialRequest?.httpVersion ?? 'HTTP/1.1',
|
|
8
|
+
cookies: partialRequest?.cookies ?? [],
|
|
9
|
+
headers: partialRequest?.headers ?? [],
|
|
10
|
+
headersSize: partialRequest?.headersSize ?? 0,
|
|
11
|
+
bodySize: partialRequest?.bodySize ?? 0,
|
|
12
|
+
queryString: partialRequest?.queryString ?? [],
|
|
13
|
+
...partialRequest,
|
|
14
|
+
};
|
|
15
|
+
const allHeaders = (request?.headers ?? []).reduce((acc, header) => ({
|
|
16
|
+
...acc,
|
|
17
|
+
[header.name]: header.value,
|
|
18
|
+
}), {});
|
|
19
|
+
const queryObj = (request.queryString ?? []).reduce((acc, param) => ({
|
|
20
|
+
...acc,
|
|
21
|
+
[param.name]: param.value,
|
|
22
|
+
}), {});
|
|
23
|
+
const cookiesObj = (request.cookies ?? []).reduce((acc, cookie) => ({
|
|
24
|
+
...acc,
|
|
25
|
+
[cookie.name]: cookie.value,
|
|
26
|
+
}), {});
|
|
27
|
+
const parsedUrl = new URL(request.url);
|
|
28
|
+
const uriObj = {
|
|
29
|
+
protocol: parsedUrl.protocol,
|
|
30
|
+
hostname: parsedUrl.hostname,
|
|
31
|
+
host: parsedUrl.hostname,
|
|
32
|
+
port: parsedUrl.port,
|
|
33
|
+
pathname: parsedUrl.pathname
|
|
34
|
+
.split('/')
|
|
35
|
+
.map((segment) => encodeURIComponent(decodeURIComponent(segment)))
|
|
36
|
+
.join('/') + parsedUrl.search,
|
|
37
|
+
path: parsedUrl.pathname
|
|
38
|
+
.split('/')
|
|
39
|
+
.map((segment) => encodeURIComponent(decodeURIComponent(segment)))
|
|
40
|
+
.join('/') + parsedUrl.search,
|
|
41
|
+
search: parsedUrl.search,
|
|
42
|
+
hash: parsedUrl.hash,
|
|
43
|
+
href: parsedUrl.href,
|
|
44
|
+
origin: parsedUrl.origin,
|
|
45
|
+
password: parsedUrl.password,
|
|
46
|
+
searchParams: parsedUrl.searchParams,
|
|
47
|
+
username: parsedUrl.username,
|
|
48
|
+
toString: parsedUrl.toString,
|
|
49
|
+
toJSON: () => parsedUrl.toJSON(),
|
|
50
|
+
};
|
|
51
|
+
return client?.convert({
|
|
52
|
+
url: request.url,
|
|
53
|
+
uriObj,
|
|
54
|
+
method: request.method?.toLocaleUpperCase() ?? 'GET',
|
|
55
|
+
httpVersion: request.httpVersion,
|
|
56
|
+
cookies: request.cookies ?? [],
|
|
57
|
+
headers: request.headers ?? [],
|
|
58
|
+
headersSize: request.headersSize ?? 0,
|
|
59
|
+
headersObj: allHeaders ?? {},
|
|
60
|
+
bodySize: request.bodySize ?? 0,
|
|
61
|
+
queryString: request.queryString ?? [],
|
|
62
|
+
postData: request.postData
|
|
63
|
+
? {
|
|
64
|
+
mimeType: request.postData.mimeType ?? 'application/json',
|
|
65
|
+
text: request.postData.text,
|
|
66
|
+
params: request.postData.params ?? [],
|
|
67
|
+
jsonObj: request.postData.mimeType?.includes('json')
|
|
68
|
+
? JSON.parse(request.postData.text ?? '{}')
|
|
69
|
+
: undefined,
|
|
70
|
+
paramsObj: request.postData.params?.reduce((acc, param) => ({
|
|
71
|
+
...acc,
|
|
72
|
+
[param.name]: param.value ?? '',
|
|
73
|
+
}), {}) ?? {},
|
|
74
|
+
}
|
|
75
|
+
: undefined,
|
|
76
|
+
allHeaders: allHeaders ?? {},
|
|
77
|
+
fullUrl: request.url,
|
|
78
|
+
queryObj: queryObj ?? {},
|
|
79
|
+
cookiesObj: cookiesObj ?? {},
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export { convertWithHttpSnippetLite };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/plugins/c/libcurl/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { cLibcurl } from './libcurl.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"libcurl.d.ts","sourceRoot":"","sources":["../../../../src/plugins/c/libcurl/libcurl.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAKpC;;GAEG;AACH,eAAO,MAAM,QAAQ,EAAE,MAOtB,CAAA"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { convertWithHttpSnippetLite } from '../../../core/utils/convertWithHttpSnippetLite.js';
|
|
2
|
+
import { libcurl } from '../../../../node_modules/httpsnippet-lite/dist/esm/targets/c/libcurl/client.mjs';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* c/libcurl
|
|
6
|
+
*/
|
|
7
|
+
const cLibcurl = {
|
|
8
|
+
target: 'c',
|
|
9
|
+
client: 'libcurl',
|
|
10
|
+
generate(request) {
|
|
11
|
+
// TODO: Write an own converter
|
|
12
|
+
return convertWithHttpSnippetLite(libcurl, request);
|
|
13
|
+
},
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export { cLibcurl };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"clj_http.d.ts","sourceRoot":"","sources":["../../../../src/plugins/clojure/clj_http/clj_http.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAKpC;;GAEG;AACH,eAAO,MAAM,cAAc,EAAE,MAO5B,CAAA"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { convertWithHttpSnippetLite } from '../../../core/utils/convertWithHttpSnippetLite.js';
|
|
2
|
+
import { clj_http } from '../../../../node_modules/httpsnippet-lite/dist/esm/targets/clojure/clj_http/client.mjs';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* clojure/clj_http
|
|
6
|
+
*/
|
|
7
|
+
const clojureCljhttp = {
|
|
8
|
+
target: 'clojure',
|
|
9
|
+
client: 'clj_http',
|
|
10
|
+
generate(request) {
|
|
11
|
+
// TODO: Write an own converter
|
|
12
|
+
return convertWithHttpSnippetLite(clj_http, request);
|
|
13
|
+
},
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export { clojureCljhttp };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/plugins/clojure/clj_http/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { clojureCljhttp } from './clj_http.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"httpclient.d.ts","sourceRoot":"","sources":["../../../../src/plugins/csharp/httpclient/httpclient.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAKpC;;GAEG;AACH,eAAO,MAAM,gBAAgB,EAAE,MAO9B,CAAA"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { convertWithHttpSnippetLite } from '../../../core/utils/convertWithHttpSnippetLite.js';
|
|
2
|
+
import { httpclient } from '../../../../node_modules/httpsnippet-lite/dist/esm/targets/csharp/httpclient/client.mjs';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* csharp/httpclient
|
|
6
|
+
*/
|
|
7
|
+
const csharpHttpclient = {
|
|
8
|
+
target: 'csharp',
|
|
9
|
+
client: 'httpclient',
|
|
10
|
+
generate(request) {
|
|
11
|
+
// TODO: Write an own converter
|
|
12
|
+
return convertWithHttpSnippetLite(httpclient, request);
|
|
13
|
+
},
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export { csharpHttpclient };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/plugins/csharp/httpclient/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { csharpHttpclient } from './httpclient.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/plugins/csharp/restsharp/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { csharpRestsharp } from './restsharp.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"restsharp.d.ts","sourceRoot":"","sources":["../../../../src/plugins/csharp/restsharp/restsharp.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAKpC;;GAEG;AACH,eAAO,MAAM,eAAe,EAAE,MAO7B,CAAA"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { convertWithHttpSnippetLite } from '../../../core/utils/convertWithHttpSnippetLite.js';
|
|
2
|
+
import { restsharp } from '../../../../node_modules/httpsnippet-lite/dist/esm/targets/csharp/restsharp/client.mjs';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* csharp/restsharp
|
|
6
|
+
*/
|
|
7
|
+
const csharpRestsharp = {
|
|
8
|
+
target: 'csharp',
|
|
9
|
+
client: 'restsharp',
|
|
10
|
+
generate(request) {
|
|
11
|
+
// TODO: Write an own converter
|
|
12
|
+
return convertWithHttpSnippetLite(restsharp, request);
|
|
13
|
+
},
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export { csharpRestsharp };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/plugins/go/native/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { goNative } from './native.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"native.d.ts","sourceRoot":"","sources":["../../../../src/plugins/go/native/native.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAKpC;;GAEG;AACH,eAAO,MAAM,QAAQ,EAAE,MAOtB,CAAA"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { convertWithHttpSnippetLite } from '../../../core/utils/convertWithHttpSnippetLite.js';
|
|
2
|
+
import { native } from '../../../../node_modules/httpsnippet-lite/dist/esm/targets/go/native/client.mjs';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* go/native
|
|
6
|
+
*/
|
|
7
|
+
const goNative = {
|
|
8
|
+
target: 'go',
|
|
9
|
+
client: 'native',
|
|
10
|
+
generate(request) {
|
|
11
|
+
// TODO: Write an own converter
|
|
12
|
+
return convertWithHttpSnippetLite(native, request);
|
|
13
|
+
},
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export { goNative };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"http11.d.ts","sourceRoot":"","sources":["../../../../src/plugins/http/http11/http11.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAKpC;;GAEG;AACH,eAAO,MAAM,UAAU,EAAE,MAOxB,CAAA"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { convertWithHttpSnippetLite } from '../../../core/utils/convertWithHttpSnippetLite.js';
|
|
2
|
+
import { http11 } from '../../../../node_modules/httpsnippet-lite/dist/esm/targets/http/http1.1/client.mjs';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* http/http1.1
|
|
6
|
+
*/
|
|
7
|
+
const httpHttp11 = {
|
|
8
|
+
target: 'http',
|
|
9
|
+
client: 'http1.1',
|
|
10
|
+
generate(request) {
|
|
11
|
+
// TODO: Write an own converter
|
|
12
|
+
return convertWithHttpSnippetLite(http11, request);
|
|
13
|
+
},
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export { httpHttp11 };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/plugins/http/http11/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { httpHttp11 } from './http11.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"asynchttp.d.ts","sourceRoot":"","sources":["../../../../src/plugins/java/asynchttp/asynchttp.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAKpC;;GAEG;AACH,eAAO,MAAM,aAAa,EAAE,MAO3B,CAAA"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { convertWithHttpSnippetLite } from '../../../core/utils/convertWithHttpSnippetLite.js';
|
|
2
|
+
import { asynchttp } from '../../../../node_modules/httpsnippet-lite/dist/esm/targets/java/asynchttp/client.mjs';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* java/asynchttp
|
|
6
|
+
*/
|
|
7
|
+
const javaAsynchttp = {
|
|
8
|
+
target: 'java',
|
|
9
|
+
client: 'asynchttp',
|
|
10
|
+
generate(request) {
|
|
11
|
+
// TODO: Write an own converter
|
|
12
|
+
return convertWithHttpSnippetLite(asynchttp, request);
|
|
13
|
+
},
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export { javaAsynchttp };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/plugins/java/asynchttp/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { javaAsynchttp } from './asynchttp.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/plugins/java/nethttp/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { javaNethttp } from './nethttp.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nethttp.d.ts","sourceRoot":"","sources":["../../../../src/plugins/java/nethttp/nethttp.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAKpC;;GAEG;AACH,eAAO,MAAM,WAAW,EAAE,MAOzB,CAAA"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { convertWithHttpSnippetLite } from '../../../core/utils/convertWithHttpSnippetLite.js';
|
|
2
|
+
import { nethttp } from '../../../../node_modules/httpsnippet-lite/dist/esm/targets/java/nethttp/client.mjs';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* java/nethttp
|
|
6
|
+
*/
|
|
7
|
+
const javaNethttp = {
|
|
8
|
+
target: 'java',
|
|
9
|
+
client: 'nethttp',
|
|
10
|
+
generate(request) {
|
|
11
|
+
// TODO: Write an own converter
|
|
12
|
+
return convertWithHttpSnippetLite(nethttp, request);
|
|
13
|
+
},
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export { javaNethttp };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/plugins/java/okhttp/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { javaOkhttp } from './okhttp.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"okhttp.d.ts","sourceRoot":"","sources":["../../../../src/plugins/java/okhttp/okhttp.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAKpC;;GAEG;AACH,eAAO,MAAM,UAAU,EAAE,MAOxB,CAAA"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { convertWithHttpSnippetLite } from '../../../core/utils/convertWithHttpSnippetLite.js';
|
|
2
|
+
import { okhttp } from '../../../../node_modules/httpsnippet-lite/dist/esm/targets/java/okhttp/client.mjs';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* java/okhttp
|
|
6
|
+
*/
|
|
7
|
+
const javaOkhttp = {
|
|
8
|
+
target: 'java',
|
|
9
|
+
client: 'okhttp',
|
|
10
|
+
generate(request) {
|
|
11
|
+
// TODO: Write an own converter
|
|
12
|
+
return convertWithHttpSnippetLite(okhttp, request);
|
|
13
|
+
},
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export { javaOkhttp };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/plugins/java/unirest/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { javaUnirest } from './unirest.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"unirest.d.ts","sourceRoot":"","sources":["../../../../src/plugins/java/unirest/unirest.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAKpC;;GAEG;AACH,eAAO,MAAM,WAAW,EAAE,MAOzB,CAAA"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { convertWithHttpSnippetLite } from '../../../core/utils/convertWithHttpSnippetLite.js';
|
|
2
|
+
import { unirest } from '../../../../node_modules/httpsnippet-lite/dist/esm/targets/java/unirest/client.mjs';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* java/unirest
|
|
6
|
+
*/
|
|
7
|
+
const javaUnirest = {
|
|
8
|
+
target: 'java',
|
|
9
|
+
client: 'unirest',
|
|
10
|
+
generate(request) {
|
|
11
|
+
// TODO: Write an own converter
|
|
12
|
+
return convertWithHttpSnippetLite(unirest, request);
|
|
13
|
+
},
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export { javaUnirest };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"axios.d.ts","sourceRoot":"","sources":["../../../../src/plugins/js/axios/axios.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAKpC;;GAEG;AACH,eAAO,MAAM,OAAO,EAAE,MAOrB,CAAA"}
|