@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.
Files changed (202) hide show
  1. package/README.md +3 -3
  2. package/dist/core/types.d.ts +46 -11
  3. package/dist/core/types.d.ts.map +1 -1
  4. package/dist/core/utils/convertWithHttpSnippetLite.d.ts +7 -0
  5. package/dist/core/utils/convertWithHttpSnippetLite.d.ts.map +1 -0
  6. package/dist/core/utils/convertWithHttpSnippetLite.js +83 -0
  7. package/dist/plugins/c/libcurl/index.d.ts +2 -0
  8. package/dist/plugins/c/libcurl/index.d.ts.map +1 -0
  9. package/dist/plugins/c/libcurl/index.js +1 -0
  10. package/dist/plugins/c/libcurl/libcurl.d.ts +6 -0
  11. package/dist/plugins/c/libcurl/libcurl.d.ts.map +1 -0
  12. package/dist/plugins/c/libcurl/libcurl.js +16 -0
  13. package/dist/plugins/clojure/clj_http/clj_http.d.ts +6 -0
  14. package/dist/plugins/clojure/clj_http/clj_http.d.ts.map +1 -0
  15. package/dist/plugins/clojure/clj_http/clj_http.js +16 -0
  16. package/dist/plugins/clojure/clj_http/index.d.ts +2 -0
  17. package/dist/plugins/clojure/clj_http/index.d.ts.map +1 -0
  18. package/dist/plugins/clojure/clj_http/index.js +1 -0
  19. package/dist/plugins/csharp/httpclient/httpclient.d.ts +6 -0
  20. package/dist/plugins/csharp/httpclient/httpclient.d.ts.map +1 -0
  21. package/dist/plugins/csharp/httpclient/httpclient.js +16 -0
  22. package/dist/plugins/csharp/httpclient/index.d.ts +2 -0
  23. package/dist/plugins/csharp/httpclient/index.d.ts.map +1 -0
  24. package/dist/plugins/csharp/httpclient/index.js +1 -0
  25. package/dist/plugins/csharp/restsharp/index.d.ts +2 -0
  26. package/dist/plugins/csharp/restsharp/index.d.ts.map +1 -0
  27. package/dist/plugins/csharp/restsharp/index.js +1 -0
  28. package/dist/plugins/csharp/restsharp/restsharp.d.ts +6 -0
  29. package/dist/plugins/csharp/restsharp/restsharp.d.ts.map +1 -0
  30. package/dist/plugins/csharp/restsharp/restsharp.js +16 -0
  31. package/dist/plugins/go/native/index.d.ts +2 -0
  32. package/dist/plugins/go/native/index.d.ts.map +1 -0
  33. package/dist/plugins/go/native/index.js +1 -0
  34. package/dist/plugins/go/native/native.d.ts +6 -0
  35. package/dist/plugins/go/native/native.d.ts.map +1 -0
  36. package/dist/plugins/go/native/native.js +16 -0
  37. package/dist/plugins/http/http11/http11.d.ts +6 -0
  38. package/dist/plugins/http/http11/http11.d.ts.map +1 -0
  39. package/dist/plugins/http/http11/http11.js +16 -0
  40. package/dist/plugins/http/http11/index.d.ts +2 -0
  41. package/dist/plugins/http/http11/index.d.ts.map +1 -0
  42. package/dist/plugins/http/http11/index.js +1 -0
  43. package/dist/plugins/java/asynchttp/asynchttp.d.ts +6 -0
  44. package/dist/plugins/java/asynchttp/asynchttp.d.ts.map +1 -0
  45. package/dist/plugins/java/asynchttp/asynchttp.js +16 -0
  46. package/dist/plugins/java/asynchttp/index.d.ts +2 -0
  47. package/dist/plugins/java/asynchttp/index.d.ts.map +1 -0
  48. package/dist/plugins/java/asynchttp/index.js +1 -0
  49. package/dist/plugins/java/nethttp/index.d.ts +2 -0
  50. package/dist/plugins/java/nethttp/index.d.ts.map +1 -0
  51. package/dist/plugins/java/nethttp/index.js +1 -0
  52. package/dist/plugins/java/nethttp/nethttp.d.ts +6 -0
  53. package/dist/plugins/java/nethttp/nethttp.d.ts.map +1 -0
  54. package/dist/plugins/java/nethttp/nethttp.js +16 -0
  55. package/dist/plugins/java/okhttp/index.d.ts +2 -0
  56. package/dist/plugins/java/okhttp/index.d.ts.map +1 -0
  57. package/dist/plugins/java/okhttp/index.js +1 -0
  58. package/dist/plugins/java/okhttp/okhttp.d.ts +6 -0
  59. package/dist/plugins/java/okhttp/okhttp.d.ts.map +1 -0
  60. package/dist/plugins/java/okhttp/okhttp.js +16 -0
  61. package/dist/plugins/java/unirest/index.d.ts +2 -0
  62. package/dist/plugins/java/unirest/index.d.ts.map +1 -0
  63. package/dist/plugins/java/unirest/index.js +1 -0
  64. package/dist/plugins/java/unirest/unirest.d.ts +6 -0
  65. package/dist/plugins/java/unirest/unirest.d.ts.map +1 -0
  66. package/dist/plugins/java/unirest/unirest.js +16 -0
  67. package/dist/plugins/js/axios/axios.d.ts +6 -0
  68. package/dist/plugins/js/axios/axios.d.ts.map +1 -0
  69. package/dist/plugins/js/axios/axios.js +16 -0
  70. package/dist/plugins/js/axios/index.d.ts +2 -0
  71. package/dist/plugins/js/axios/index.d.ts.map +1 -0
  72. package/dist/plugins/js/axios/index.js +1 -0
  73. package/dist/plugins/js/fetch/fetch.d.ts +2 -6
  74. package/dist/plugins/js/fetch/fetch.d.ts.map +1 -1
  75. package/dist/plugins/js/fetch/fetch.js +60 -59
  76. package/dist/plugins/js/fetch/index.js +1 -1
  77. package/dist/plugins/js/jquery/index.d.ts +2 -0
  78. package/dist/plugins/js/jquery/index.d.ts.map +1 -0
  79. package/dist/plugins/js/jquery/index.js +1 -0
  80. package/dist/plugins/js/jquery/jquery.d.ts +6 -0
  81. package/dist/plugins/js/jquery/jquery.d.ts.map +1 -0
  82. package/dist/plugins/js/jquery/jquery.js +16 -0
  83. package/dist/plugins/js/ofetch/index.js +1 -1
  84. package/dist/plugins/js/ofetch/ofetch.d.ts +2 -6
  85. package/dist/plugins/js/ofetch/ofetch.d.ts.map +1 -1
  86. package/dist/plugins/js/ofetch/ofetch.js +65 -64
  87. package/dist/plugins/js/xhr/index.d.ts +2 -0
  88. package/dist/plugins/js/xhr/index.d.ts.map +1 -0
  89. package/dist/plugins/js/xhr/index.js +1 -0
  90. package/dist/plugins/js/xhr/xhr.d.ts +6 -0
  91. package/dist/plugins/js/xhr/xhr.d.ts.map +1 -0
  92. package/dist/plugins/js/xhr/xhr.js +16 -0
  93. package/dist/plugins/kotlin/okhttp/index.d.ts +2 -0
  94. package/dist/plugins/kotlin/okhttp/index.d.ts.map +1 -0
  95. package/dist/plugins/kotlin/okhttp/index.js +1 -0
  96. package/dist/plugins/kotlin/okhttp/okhttp.d.ts +6 -0
  97. package/dist/plugins/kotlin/okhttp/okhttp.d.ts.map +1 -0
  98. package/dist/plugins/kotlin/okhttp/okhttp.js +16 -0
  99. package/dist/plugins/node/axios/axios.d.ts +6 -0
  100. package/dist/plugins/node/axios/axios.d.ts.map +1 -0
  101. package/dist/plugins/node/axios/axios.js +16 -0
  102. package/dist/plugins/node/axios/index.d.ts +2 -0
  103. package/dist/plugins/node/axios/index.d.ts.map +1 -0
  104. package/dist/plugins/node/axios/index.js +1 -0
  105. package/dist/plugins/node/fetch/fetch.d.ts +2 -6
  106. package/dist/plugins/node/fetch/fetch.d.ts.map +1 -1
  107. package/dist/plugins/node/fetch/fetch.js +60 -59
  108. package/dist/plugins/node/fetch/index.js +1 -1
  109. package/dist/plugins/node/ofetch/index.js +1 -1
  110. package/dist/plugins/node/ofetch/ofetch.d.ts +2 -6
  111. package/dist/plugins/node/ofetch/ofetch.d.ts.map +1 -1
  112. package/dist/plugins/node/ofetch/ofetch.js +65 -64
  113. package/dist/plugins/node/undici/index.js +1 -1
  114. package/dist/plugins/node/undici/undici.d.ts +2 -6
  115. package/dist/plugins/node/undici/undici.d.ts.map +1 -1
  116. package/dist/plugins/node/undici/undici.js +60 -59
  117. package/dist/plugins/objc/nsurlsession/index.d.ts +2 -0
  118. package/dist/plugins/objc/nsurlsession/index.d.ts.map +1 -0
  119. package/dist/plugins/objc/nsurlsession/index.js +1 -0
  120. package/dist/plugins/objc/nsurlsession/nsurlsession.d.ts +6 -0
  121. package/dist/plugins/objc/nsurlsession/nsurlsession.d.ts.map +1 -0
  122. package/dist/plugins/objc/nsurlsession/nsurlsession.js +16 -0
  123. package/dist/plugins/ocaml/cohttp/cohttp.d.ts +6 -0
  124. package/dist/plugins/ocaml/cohttp/cohttp.d.ts.map +1 -0
  125. package/dist/plugins/ocaml/cohttp/cohttp.js +16 -0
  126. package/dist/plugins/ocaml/cohttp/index.d.ts +2 -0
  127. package/dist/plugins/ocaml/cohttp/index.d.ts.map +1 -0
  128. package/dist/plugins/ocaml/cohttp/index.js +1 -0
  129. package/dist/plugins/php/curl/curl.d.ts +6 -0
  130. package/dist/plugins/php/curl/curl.d.ts.map +1 -0
  131. package/dist/plugins/php/curl/curl.js +16 -0
  132. package/dist/plugins/php/curl/index.d.ts +2 -0
  133. package/dist/plugins/php/curl/index.d.ts.map +1 -0
  134. package/dist/plugins/php/curl/index.js +1 -0
  135. package/dist/plugins/php/guzzle/guzzle.d.ts +6 -0
  136. package/dist/plugins/php/guzzle/guzzle.d.ts.map +1 -0
  137. package/dist/plugins/php/guzzle/guzzle.js +16 -0
  138. package/dist/plugins/php/guzzle/index.d.ts +2 -0
  139. package/dist/plugins/php/guzzle/index.d.ts.map +1 -0
  140. package/dist/plugins/php/guzzle/index.js +1 -0
  141. package/dist/plugins/powershell/restmethod/index.d.ts +2 -0
  142. package/dist/plugins/powershell/restmethod/index.d.ts.map +1 -0
  143. package/dist/plugins/powershell/restmethod/index.js +1 -0
  144. package/dist/plugins/powershell/restmethod/restmethod.d.ts +6 -0
  145. package/dist/plugins/powershell/restmethod/restmethod.d.ts.map +1 -0
  146. package/dist/plugins/powershell/restmethod/restmethod.js +16 -0
  147. package/dist/plugins/powershell/webrequest/index.d.ts +2 -0
  148. package/dist/plugins/powershell/webrequest/index.d.ts.map +1 -0
  149. package/dist/plugins/powershell/webrequest/index.js +1 -0
  150. package/dist/plugins/powershell/webrequest/webrequest.d.ts +6 -0
  151. package/dist/plugins/powershell/webrequest/webrequest.d.ts.map +1 -0
  152. package/dist/plugins/powershell/webrequest/webrequest.js +16 -0
  153. package/dist/plugins/python/python3/index.d.ts +2 -0
  154. package/dist/plugins/python/python3/index.d.ts.map +1 -0
  155. package/dist/plugins/python/python3/index.js +1 -0
  156. package/dist/plugins/python/python3/python3.d.ts +6 -0
  157. package/dist/plugins/python/python3/python3.d.ts.map +1 -0
  158. package/dist/plugins/python/python3/python3.js +16 -0
  159. package/dist/plugins/python/requests/index.d.ts +2 -0
  160. package/dist/plugins/python/requests/index.d.ts.map +1 -0
  161. package/dist/plugins/python/requests/index.js +1 -0
  162. package/dist/plugins/python/requests/requests.d.ts +6 -0
  163. package/dist/plugins/python/requests/requests.d.ts.map +1 -0
  164. package/dist/plugins/python/requests/requests.js +16 -0
  165. package/dist/plugins/r/httr/httr.d.ts +6 -0
  166. package/dist/plugins/r/httr/httr.d.ts.map +1 -0
  167. package/dist/plugins/r/httr/httr.js +16 -0
  168. package/dist/plugins/r/httr/index.d.ts +2 -0
  169. package/dist/plugins/r/httr/index.d.ts.map +1 -0
  170. package/dist/plugins/r/httr/index.js +1 -0
  171. package/dist/plugins/ruby/native/index.d.ts +2 -0
  172. package/dist/plugins/ruby/native/index.d.ts.map +1 -0
  173. package/dist/plugins/ruby/native/index.js +1 -0
  174. package/dist/plugins/ruby/native/native.d.ts +6 -0
  175. package/dist/plugins/ruby/native/native.d.ts.map +1 -0
  176. package/dist/plugins/ruby/native/native.js +16 -0
  177. package/dist/plugins/shell/curl/curl.d.ts +2 -6
  178. package/dist/plugins/shell/curl/curl.d.ts.map +1 -1
  179. package/dist/plugins/shell/curl/curl.js +95 -95
  180. package/dist/plugins/shell/curl/index.js +1 -1
  181. package/dist/plugins/shell/httpie/httpie.d.ts +6 -0
  182. package/dist/plugins/shell/httpie/httpie.d.ts.map +1 -0
  183. package/dist/plugins/shell/httpie/httpie.js +16 -0
  184. package/dist/plugins/shell/httpie/index.d.ts +2 -0
  185. package/dist/plugins/shell/httpie/index.d.ts.map +1 -0
  186. package/dist/plugins/shell/httpie/index.js +1 -0
  187. package/dist/plugins/shell/wget/index.d.ts +2 -0
  188. package/dist/plugins/shell/wget/index.d.ts.map +1 -0
  189. package/dist/plugins/shell/wget/index.js +1 -0
  190. package/dist/plugins/shell/wget/wget.d.ts +6 -0
  191. package/dist/plugins/shell/wget/wget.d.ts.map +1 -0
  192. package/dist/plugins/shell/wget/wget.js +16 -0
  193. package/dist/plugins/swift/nsurlsession/index.d.ts +2 -0
  194. package/dist/plugins/swift/nsurlsession/index.d.ts.map +1 -0
  195. package/dist/plugins/swift/nsurlsession/index.js +1 -0
  196. package/dist/plugins/swift/nsurlsession/nsurlsession.d.ts +6 -0
  197. package/dist/plugins/swift/nsurlsession/nsurlsession.d.ts.map +1 -0
  198. package/dist/plugins/swift/nsurlsession/nsurlsession.js +16 -0
  199. package/dist/snippetz.d.ts +8 -11
  200. package/dist/snippetz.d.ts.map +1 -1
  201. package/dist/snippetz.js +78 -23
  202. package/package.json +146 -1
@@ -0,0 +1,16 @@
1
+ import { convertWithHttpSnippetLite } from '../../../core/utils/convertWithHttpSnippetLite.js';
2
+ import { axios } from '../../../../node_modules/httpsnippet-lite/dist/esm/targets/javascript/axios/client.mjs';
3
+
4
+ /**
5
+ * js/axios
6
+ */
7
+ const jsAxios = {
8
+ target: 'js',
9
+ client: 'axios',
10
+ generate(request) {
11
+ // TODO: Write an own converter
12
+ return convertWithHttpSnippetLite(axios, request);
13
+ },
14
+ };
15
+
16
+ export { jsAxios };
@@ -0,0 +1,2 @@
1
+ export * from './axios.js';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/plugins/js/axios/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAA"}
@@ -0,0 +1 @@
1
+ export { jsAxios } from './axios.js';
@@ -1,10 +1,6 @@
1
- import { type AddClient, type Request, type Source } from '../../../core/index.js';
2
- declare global {
3
- interface Clients extends AddClient<'js', 'fetch'> {
4
- }
5
- }
1
+ import { type Plugin } from '../../../core/index.js';
6
2
  /**
7
3
  * js/fetch
8
4
  */
9
- export declare function fetch(request?: Partial<Request>): Source;
5
+ export declare const jsFetch: Plugin;
10
6
  //# sourceMappingURL=fetch.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"fetch.d.ts","sourceRoot":"","sources":["../../../../src/plugins/js/fetch/fetch.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,SAAS,EACd,KAAK,OAAO,EACZ,KAAK,MAAM,EAGZ,MAAM,eAAe,CAAA;AAEtB,OAAO,CAAC,MAAM,CAAC;IAEb,UAAU,OAAQ,SAAQ,SAAS,CAAC,IAAI,EAAE,OAAO,CAAC;KAAG;CACtD;AAED;;GAEG;AACH,wBAAgB,KAAK,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC,OAAO,CAAC,GAAG,MAAM,CA6ExD"}
1
+ {"version":3,"file":"fetch.d.ts","sourceRoot":"","sources":["../../../../src/plugins/js/fetch/fetch.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,MAAM,EAAiC,MAAM,eAAe,CAAA;AAE1E;;GAEG;AACH,eAAO,MAAM,OAAO,EAAE,MA6ErB,CAAA"}
@@ -4,65 +4,66 @@ import { objectToString } from '../../../core/utils/objectToString.js';
4
4
  /**
5
5
  * js/fetch
6
6
  */
7
- function fetch(request) {
8
- // Defaults
9
- const normalizedRequest = {
10
- method: 'GET',
11
- ...request,
12
- };
13
- // Normalization
14
- normalizedRequest.method = normalizedRequest.method.toUpperCase();
15
- // Reset fetch defaults
16
- const options = {
17
- method: normalizedRequest.method === 'GET' ? undefined : normalizedRequest.method,
18
- };
19
- // Query
20
- const searchParams = new URLSearchParams(normalizedRequest.queryString
21
- ? arrayToObject(normalizedRequest.queryString)
22
- : undefined);
23
- const queryString = searchParams.size ? `?${searchParams.toString()}` : '';
24
- // Headers
25
- if (normalizedRequest.headers?.length) {
26
- options.headers = {};
27
- normalizedRequest.headers.forEach((header) => {
28
- options.headers[header.name] = header.value;
29
- });
30
- }
31
- // Cookies
32
- if (normalizedRequest.cookies?.length) {
33
- options.headers = options.headers || {};
34
- normalizedRequest.cookies.forEach((cookie) => {
35
- options.headers['Set-Cookie'] = options.headers['Set-Cookie']
36
- ? `${options.headers['Set-Cookie']}; ${cookie.name}=${cookie.value}`
37
- : `${cookie.name}=${cookie.value}`;
38
- });
39
- }
40
- // Remove undefined keys
41
- Object.keys(options).forEach((key) => {
42
- if (options[key] === undefined) {
43
- delete options[key];
7
+ const jsFetch = {
8
+ target: 'js',
9
+ client: 'fetch',
10
+ generate(request) {
11
+ // Defaults
12
+ const normalizedRequest = {
13
+ method: 'GET',
14
+ ...request,
15
+ };
16
+ // Normalization
17
+ normalizedRequest.method = normalizedRequest.method.toUpperCase();
18
+ // Reset fetch defaults
19
+ const options = {
20
+ method: normalizedRequest.method === 'GET'
21
+ ? undefined
22
+ : normalizedRequest.method,
23
+ };
24
+ // Query
25
+ const searchParams = new URLSearchParams(normalizedRequest.queryString
26
+ ? arrayToObject(normalizedRequest.queryString)
27
+ : undefined);
28
+ const queryString = searchParams.size ? `?${searchParams.toString()}` : '';
29
+ // Headers
30
+ if (normalizedRequest.headers?.length) {
31
+ options.headers = {};
32
+ normalizedRequest.headers.forEach((header) => {
33
+ options.headers[header.name] = header.value;
34
+ });
44
35
  }
45
- });
46
- // Add body
47
- if (normalizedRequest.postData) {
48
- // Plain text
49
- options.body = normalizedRequest.postData.text;
50
- // JSON
51
- if (normalizedRequest.postData.mimeType === 'application/json') {
52
- options.body = `JSON.stringify(${objectToString(JSON.parse(options.body))})`;
36
+ // Cookies
37
+ if (normalizedRequest.cookies?.length) {
38
+ options.headers = options.headers || {};
39
+ normalizedRequest.cookies.forEach((cookie) => {
40
+ options.headers['Set-Cookie'] = options.headers['Set-Cookie']
41
+ ? `${options.headers['Set-Cookie']}; ${cookie.name}=${cookie.value}`
42
+ : `${cookie.name}=${cookie.value}`;
43
+ });
44
+ }
45
+ // Remove undefined keys
46
+ Object.keys(options).forEach((key) => {
47
+ if (options[key] === undefined) {
48
+ delete options[key];
49
+ }
50
+ });
51
+ // Add body
52
+ if (normalizedRequest.postData) {
53
+ // Plain text
54
+ options.body = normalizedRequest.postData.text;
55
+ // JSON
56
+ if (normalizedRequest.postData.mimeType === 'application/json') {
57
+ options.body = `JSON.stringify(${objectToString(JSON.parse(options.body))})`;
58
+ }
53
59
  }
54
- }
55
- // Transform to JSON
56
- const jsonOptions = Object.keys(options).length
57
- ? `, ${objectToString(options)}`
58
- : '';
59
- // Code Template
60
- const code = `fetch('${normalizedRequest.url}${queryString}'${jsonOptions})`;
61
- return {
62
- target: 'js',
63
- client: 'fetch',
64
- code,
65
- };
66
- }
60
+ // Transform to JSON
61
+ const jsonOptions = Object.keys(options).length
62
+ ? `, ${objectToString(options)}`
63
+ : '';
64
+ // Code Template
65
+ return `fetch('${normalizedRequest.url}${queryString}'${jsonOptions})`;
66
+ },
67
+ };
67
68
 
68
- export { fetch };
69
+ export { jsFetch };
@@ -1 +1 @@
1
- export { fetch } from './fetch.js';
1
+ export { jsFetch } from './fetch.js';
@@ -0,0 +1,2 @@
1
+ export * from './jquery.js';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/plugins/js/jquery/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAA"}
@@ -0,0 +1 @@
1
+ export { jsJquery } from './jquery.js';
@@ -0,0 +1,6 @@
1
+ import type { Plugin } from '../../../core/index.js';
2
+ /**
3
+ * js/jquery
4
+ */
5
+ export declare const jsJquery: Plugin;
6
+ //# sourceMappingURL=jquery.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"jquery.d.ts","sourceRoot":"","sources":["../../../../src/plugins/js/jquery/jquery.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 { jquery } from '../../../../node_modules/httpsnippet-lite/dist/esm/targets/javascript/jquery/client.mjs';
3
+
4
+ /**
5
+ * js/jquery
6
+ */
7
+ const jsJquery = {
8
+ target: 'js',
9
+ client: 'jquery',
10
+ generate(request) {
11
+ // TODO: Write an own converter
12
+ return convertWithHttpSnippetLite(jquery, request);
13
+ },
14
+ };
15
+
16
+ export { jsJquery };
@@ -1 +1 @@
1
- export { ofetch } from './ofetch.js';
1
+ export { jsOfetch } from './ofetch.js';
@@ -1,10 +1,6 @@
1
- import { type AddClient, type Request, type Source } from '../../../core/index.js';
2
- declare global {
3
- interface Clients extends AddClient<'js', 'ofetch'> {
4
- }
5
- }
1
+ import { type Plugin } from '../../../core/index.js';
6
2
  /**
7
3
  * js/ofetch
8
4
  */
9
- export declare function ofetch(request?: Partial<Request>): Source;
5
+ export declare const jsOfetch: Plugin;
10
6
  //# sourceMappingURL=ofetch.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ofetch.d.ts","sourceRoot":"","sources":["../../../../src/plugins/js/ofetch/ofetch.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,SAAS,EACd,KAAK,OAAO,EACZ,KAAK,MAAM,EAGZ,MAAM,eAAe,CAAA;AAEtB,OAAO,CAAC,MAAM,CAAC;IAEb,UAAU,OAAQ,SAAQ,SAAS,CAAC,IAAI,EAAE,QAAQ,CAAC;KAAG;CACvD;AAED;;GAEG;AACH,wBAAgB,MAAM,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC,OAAO,CAAC,GAAG,MAAM,CAmFzD"}
1
+ {"version":3,"file":"ofetch.d.ts","sourceRoot":"","sources":["../../../../src/plugins/js/ofetch/ofetch.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,MAAM,EAAiC,MAAM,eAAe,CAAA;AAE1E;;GAEG;AACH,eAAO,MAAM,QAAQ,EAAE,MAmFtB,CAAA"}
@@ -4,72 +4,73 @@ import { objectToString } from '../../../core/utils/objectToString.js';
4
4
  /**
5
5
  * js/ofetch
6
6
  */
7
- function ofetch(request) {
8
- // Defaults
9
- const normalizedRequest = {
10
- method: 'GET',
11
- ...request,
12
- };
13
- // Normalization
14
- normalizedRequest.method = normalizedRequest.method.toUpperCase();
15
- // Reset fetch defaults
16
- const options = {
17
- method: normalizedRequest.method === 'GET' ? undefined : normalizedRequest.method,
18
- };
19
- // Query
20
- const searchParams = new URLSearchParams(normalizedRequest.queryString
21
- ? arrayToObject(normalizedRequest.queryString)
22
- : undefined);
23
- if (searchParams.size) {
24
- options.query = {};
25
- searchParams.forEach((value, key) => {
26
- options.query[key] = value;
27
- });
28
- }
29
- // Headers
30
- if (normalizedRequest.headers?.length) {
31
- options.headers = {};
32
- normalizedRequest.headers.forEach((header) => {
33
- options.headers[header.name] = header.value;
34
- });
35
- }
36
- // Cookies
37
- if (normalizedRequest.cookies?.length) {
38
- options.headers = options.headers || {};
39
- normalizedRequest.cookies.forEach((cookie) => {
40
- options.headers['Set-Cookie'] = options.headers['Set-Cookie']
41
- ? `${options.headers['Set-Cookie']}; ${cookie.name}=${cookie.value}`
42
- : `${cookie.name}=${cookie.value}`;
43
- });
44
- }
45
- // Remove undefined keys
46
- Object.keys(options).forEach((key) => {
47
- if (options[key] === undefined) {
48
- delete options[key];
7
+ const jsOfetch = {
8
+ target: 'js',
9
+ client: 'ofetch',
10
+ generate(request) {
11
+ // Defaults
12
+ const normalizedRequest = {
13
+ method: 'GET',
14
+ ...request,
15
+ };
16
+ // Normalization
17
+ normalizedRequest.method = normalizedRequest.method.toUpperCase();
18
+ // Reset fetch defaults
19
+ const options = {
20
+ method: normalizedRequest.method === 'GET'
21
+ ? undefined
22
+ : normalizedRequest.method,
23
+ };
24
+ // Query
25
+ const searchParams = new URLSearchParams(normalizedRequest.queryString
26
+ ? arrayToObject(normalizedRequest.queryString)
27
+ : undefined);
28
+ if (searchParams.size) {
29
+ options.query = {};
30
+ searchParams.forEach((value, key) => {
31
+ options.query[key] = value;
32
+ });
49
33
  }
50
- });
51
- // Add body
52
- if (normalizedRequest.postData) {
53
- // Plain text
54
- options.body = normalizedRequest.postData.text;
55
- // JSON
56
- if (normalizedRequest.postData.mimeType === 'application/json') {
57
- options.body = JSON.parse(options.body);
34
+ // Headers
35
+ if (normalizedRequest.headers?.length) {
36
+ options.headers = {};
37
+ normalizedRequest.headers.forEach((header) => {
38
+ options.headers[header.name] = header.value;
39
+ });
40
+ }
41
+ // Cookies
42
+ if (normalizedRequest.cookies?.length) {
43
+ options.headers = options.headers || {};
44
+ normalizedRequest.cookies.forEach((cookie) => {
45
+ options.headers['Set-Cookie'] = options.headers['Set-Cookie']
46
+ ? `${options.headers['Set-Cookie']}; ${cookie.name}=${cookie.value}`
47
+ : `${cookie.name}=${cookie.value}`;
48
+ });
49
+ }
50
+ // Remove undefined keys
51
+ Object.keys(options).forEach((key) => {
52
+ if (options[key] === undefined) {
53
+ delete options[key];
54
+ }
55
+ });
56
+ // Add body
57
+ if (normalizedRequest.postData) {
58
+ // Plain text
59
+ options.body = normalizedRequest.postData.text;
60
+ // JSON
61
+ if (normalizedRequest.postData.mimeType === 'application/json') {
62
+ options.body = JSON.parse(options.body);
63
+ }
58
64
  }
59
- }
60
- // Transform to JSON
61
- const jsonOptions = Object.keys(options).length
62
- ? `, ${objectToString(options)}`
63
- : '';
64
- // Code Template
65
- const code = `import { ofetch } from 'ofetch'
65
+ // Transform to JSON
66
+ const jsonOptions = Object.keys(options).length
67
+ ? `, ${objectToString(options)}`
68
+ : '';
69
+ // Code Template
70
+ return `import { ofetch } from 'ofetch'
66
71
 
67
72
  ofetch('${normalizedRequest.url}'${jsonOptions})`;
68
- return {
69
- target: 'js',
70
- client: 'ofetch',
71
- code,
72
- };
73
- }
73
+ },
74
+ };
74
75
 
75
- export { ofetch };
76
+ export { jsOfetch };
@@ -0,0 +1,2 @@
1
+ export * from './xhr.js';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/plugins/js/xhr/index.ts"],"names":[],"mappings":"AAAA,cAAc,OAAO,CAAA"}
@@ -0,0 +1 @@
1
+ export { jsXhr } from './xhr.js';
@@ -0,0 +1,6 @@
1
+ import type { Plugin } from '../../../core/index.js';
2
+ /**
3
+ * js/xhr
4
+ */
5
+ export declare const jsXhr: Plugin;
6
+ //# sourceMappingURL=xhr.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"xhr.d.ts","sourceRoot":"","sources":["../../../../src/plugins/js/xhr/xhr.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAKpC;;GAEG;AACH,eAAO,MAAM,KAAK,EAAE,MAOnB,CAAA"}
@@ -0,0 +1,16 @@
1
+ import { convertWithHttpSnippetLite } from '../../../core/utils/convertWithHttpSnippetLite.js';
2
+ import { xhr } from '../../../../node_modules/httpsnippet-lite/dist/esm/targets/javascript/xhr/client.mjs';
3
+
4
+ /**
5
+ * js/xhr
6
+ */
7
+ const jsXhr = {
8
+ target: 'js',
9
+ client: 'xhr',
10
+ generate(request) {
11
+ // TODO: Write an own converter
12
+ return convertWithHttpSnippetLite(xhr, request);
13
+ },
14
+ };
15
+
16
+ export { jsXhr };
@@ -0,0 +1,2 @@
1
+ export * from './okhttp.js';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/plugins/kotlin/okhttp/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAA"}
@@ -0,0 +1 @@
1
+ export { kotlinOkhttp } from './okhttp.js';
@@ -0,0 +1,6 @@
1
+ import type { Plugin } from '../../../core/index.js';
2
+ /**
3
+ * kotlin/okhttp
4
+ */
5
+ export declare const kotlinOkhttp: Plugin;
6
+ //# sourceMappingURL=okhttp.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"okhttp.d.ts","sourceRoot":"","sources":["../../../../src/plugins/kotlin/okhttp/okhttp.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAKpC;;GAEG;AACH,eAAO,MAAM,YAAY,EAAE,MAO1B,CAAA"}
@@ -0,0 +1,16 @@
1
+ import { convertWithHttpSnippetLite } from '../../../core/utils/convertWithHttpSnippetLite.js';
2
+ import { okhttp } from '../../../../node_modules/httpsnippet-lite/dist/esm/targets/kotlin/okhttp/client.mjs';
3
+
4
+ /**
5
+ * kotlin/okhttp
6
+ */
7
+ const kotlinOkhttp = {
8
+ target: 'kotlin',
9
+ client: 'okhttp',
10
+ generate(request) {
11
+ // TODO: Write an own converter
12
+ return convertWithHttpSnippetLite(okhttp, request);
13
+ },
14
+ };
15
+
16
+ export { kotlinOkhttp };
@@ -0,0 +1,6 @@
1
+ import type { Plugin } from '../../../core/index.js';
2
+ /**
3
+ * node/axios
4
+ */
5
+ export declare const nodeAxios: Plugin;
6
+ //# sourceMappingURL=axios.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"axios.d.ts","sourceRoot":"","sources":["../../../../src/plugins/node/axios/axios.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAKpC;;GAEG;AACH,eAAO,MAAM,SAAS,EAAE,MAOvB,CAAA"}
@@ -0,0 +1,16 @@
1
+ import { convertWithHttpSnippetLite } from '../../../core/utils/convertWithHttpSnippetLite.js';
2
+ import { axios } from '../../../../node_modules/httpsnippet-lite/dist/esm/targets/node/axios/client.mjs';
3
+
4
+ /**
5
+ * node/axios
6
+ */
7
+ const nodeAxios = {
8
+ target: 'node',
9
+ client: 'axios',
10
+ generate(request) {
11
+ // TODO: Write an own converter
12
+ return convertWithHttpSnippetLite(axios, request);
13
+ },
14
+ };
15
+
16
+ export { nodeAxios };
@@ -0,0 +1,2 @@
1
+ export * from './axios.js';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/plugins/node/axios/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAA"}
@@ -0,0 +1 @@
1
+ export { nodeAxios } from './axios.js';
@@ -1,10 +1,6 @@
1
- import { type AddClient, type Request, type Source } from '../../../core/index.js';
2
- declare global {
3
- interface Clients extends AddClient<'node', 'fetch'> {
4
- }
5
- }
1
+ import { type Plugin } from '../../../core/index.js';
6
2
  /**
7
3
  * node/fetch
8
4
  */
9
- export declare function fetch(request?: Partial<Request>): Source;
5
+ export declare const nodeFetch: Plugin;
10
6
  //# sourceMappingURL=fetch.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"fetch.d.ts","sourceRoot":"","sources":["../../../../src/plugins/node/fetch/fetch.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,SAAS,EACd,KAAK,OAAO,EACZ,KAAK,MAAM,EAGZ,MAAM,eAAe,CAAA;AAEtB,OAAO,CAAC,MAAM,CAAC;IAEb,UAAU,OAAQ,SAAQ,SAAS,CAAC,MAAM,EAAE,OAAO,CAAC;KAAG;CACxD;AAED;;GAEG;AACH,wBAAgB,KAAK,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC,OAAO,CAAC,GAAG,MAAM,CA6ExD"}
1
+ {"version":3,"file":"fetch.d.ts","sourceRoot":"","sources":["../../../../src/plugins/node/fetch/fetch.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,MAAM,EAAiC,MAAM,eAAe,CAAA;AAE1E;;GAEG;AACH,eAAO,MAAM,SAAS,EAAE,MA6EvB,CAAA"}