@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
@@ -4,65 +4,66 @@ import { objectToString } from '../../../core/utils/objectToString.js';
4
4
  /**
5
5
  * node/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 nodeFetch = {
8
+ target: 'node',
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: 'node',
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 { nodeFetch };
@@ -1 +1 @@
1
- export { fetch } from './fetch.js';
1
+ export { nodeFetch } from './fetch.js';
@@ -1 +1 @@
1
- export { ofetch } from './ofetch.js';
1
+ export { nodeOfetch } 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<'node', 'ofetch'> {
4
- }
5
- }
1
+ import { type Plugin } from '../../../core/index.js';
6
2
  /**
7
3
  * node/ofetch
8
4
  */
9
- export declare function ofetch(request?: Partial<Request>): Source;
5
+ export declare const nodeOfetch: Plugin;
10
6
  //# sourceMappingURL=ofetch.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ofetch.d.ts","sourceRoot":"","sources":["../../../../src/plugins/node/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,MAAM,EAAE,QAAQ,CAAC;KAAG;CACzD;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/node/ofetch/ofetch.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,MAAM,EAAiC,MAAM,eAAe,CAAA;AAE1E;;GAEG;AACH,eAAO,MAAM,UAAU,EAAE,MAmFxB,CAAA"}
@@ -4,72 +4,73 @@ import { objectToString } from '../../../core/utils/objectToString.js';
4
4
  /**
5
5
  * node/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 nodeOfetch = {
8
+ target: 'node',
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: 'node',
70
- client: 'ofetch',
71
- code,
72
- };
73
- }
73
+ },
74
+ };
74
75
 
75
- export { ofetch };
76
+ export { nodeOfetch };
@@ -1 +1 @@
1
- export { undici } from './undici.js';
1
+ export { nodeUndici } from './undici.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', 'undici'> {
4
- }
5
- }
1
+ import { type Plugin } from '../../../core/index.js';
6
2
  /**
7
3
  * node/undici
8
4
  */
9
- export declare function undici(request?: Partial<Request>): Source;
5
+ export declare const nodeUndici: Plugin;
10
6
  //# sourceMappingURL=undici.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"undici.d.ts","sourceRoot":"","sources":["../../../../src/plugins/node/undici/undici.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,QAAQ,CAAC;KAAG;CACzD;AAED;;GAEG;AACH,wBAAgB,MAAM,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC,OAAO,CAAC,GAAG,MAAM,CA+EzD"}
1
+ {"version":3,"file":"undici.d.ts","sourceRoot":"","sources":["../../../../src/plugins/node/undici/undici.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,MAAM,EAAiC,MAAM,eAAe,CAAA;AAE1E;;GAEG;AACH,eAAO,MAAM,UAAU,EAAE,MA+ExB,CAAA"}
@@ -4,67 +4,68 @@ import { objectToString } from '../../../core/utils/objectToString.js';
4
4
  /**
5
5
  * node/undici
6
6
  */
7
- function undici(request) {
8
- // Defaults
9
- const normalizedRequest = {
10
- method: 'GET',
11
- ...request,
12
- };
13
- // Normalization
14
- normalizedRequest.method = normalizedRequest.method.toUpperCase();
15
- // Reset undici 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 nodeUndici = {
8
+ target: 'node',
9
+ client: 'undici',
10
+ generate(request) {
11
+ // Defaults
12
+ const normalizedRequest = {
13
+ method: 'GET',
14
+ ...request,
15
+ };
16
+ // Normalization
17
+ normalizedRequest.method = normalizedRequest.method.toUpperCase();
18
+ // Reset undici 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 = `import { request } from 'undici'
60
+ // Transform to JSON
61
+ const jsonOptions = Object.keys(options).length
62
+ ? `, ${objectToString(options)}`
63
+ : '';
64
+ // Code Template
65
+ return `import { request } from 'undici'
61
66
 
62
67
  const { statusCode, body } = await request('${normalizedRequest.url}${queryString}'${jsonOptions})`;
63
- return {
64
- target: 'node',
65
- client: 'undici',
66
- code,
67
- };
68
- }
68
+ },
69
+ };
69
70
 
70
- export { undici };
71
+ export { nodeUndici };
@@ -0,0 +1,2 @@
1
+ export * from './nsurlsession.js';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/plugins/objc/nsurlsession/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAA"}
@@ -0,0 +1 @@
1
+ export { objcNsurlsession } from './nsurlsession.js';
@@ -0,0 +1,6 @@
1
+ import type { Plugin } from '../../../core/index.js';
2
+ /**
3
+ * objc/nsurlsession
4
+ */
5
+ export declare const objcNsurlsession: Plugin;
6
+ //# sourceMappingURL=nsurlsession.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"nsurlsession.d.ts","sourceRoot":"","sources":["../../../../src/plugins/objc/nsurlsession/nsurlsession.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 { nsurlsession } from '../../../../node_modules/httpsnippet-lite/dist/esm/targets/objc/nsurlsession/client.mjs';
3
+
4
+ /**
5
+ * objc/nsurlsession
6
+ */
7
+ const objcNsurlsession = {
8
+ target: 'objc',
9
+ client: 'nsurlsession',
10
+ generate(request) {
11
+ // TODO: Write an own converter
12
+ return convertWithHttpSnippetLite(nsurlsession, request);
13
+ },
14
+ };
15
+
16
+ export { objcNsurlsession };
@@ -0,0 +1,6 @@
1
+ import type { Plugin } from '../../../core/index.js';
2
+ /**
3
+ * ocaml/cohttp
4
+ */
5
+ export declare const ocamlCohttp: Plugin;
6
+ //# sourceMappingURL=cohttp.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cohttp.d.ts","sourceRoot":"","sources":["../../../../src/plugins/ocaml/cohttp/cohttp.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 { cohttp } from '../../../../node_modules/httpsnippet-lite/dist/esm/targets/ocaml/cohttp/client.mjs';
3
+
4
+ /**
5
+ * ocaml/cohttp
6
+ */
7
+ const ocamlCohttp = {
8
+ target: 'ocaml',
9
+ client: 'cohttp',
10
+ generate(request) {
11
+ // TODO: Write an own converter
12
+ return convertWithHttpSnippetLite(cohttp, request);
13
+ },
14
+ };
15
+
16
+ export { ocamlCohttp };
@@ -0,0 +1,2 @@
1
+ export * from './cohttp.js';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/plugins/ocaml/cohttp/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAA"}
@@ -0,0 +1 @@
1
+ export { ocamlCohttp } from './cohttp.js';
@@ -0,0 +1,6 @@
1
+ import type { Plugin } from '../../../core/index.js';
2
+ /**
3
+ * php/curl
4
+ */
5
+ export declare const phpCurl: Plugin;
6
+ //# sourceMappingURL=curl.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"curl.d.ts","sourceRoot":"","sources":["../../../../src/plugins/php/curl/curl.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAKpC;;GAEG;AACH,eAAO,MAAM,OAAO,EAAE,MAOrB,CAAA"}
@@ -0,0 +1,16 @@
1
+ import { convertWithHttpSnippetLite } from '../../../core/utils/convertWithHttpSnippetLite.js';
2
+ import { curl } from '../../../../node_modules/httpsnippet-lite/dist/esm/targets/php/curl/client.mjs';
3
+
4
+ /**
5
+ * php/curl
6
+ */
7
+ const phpCurl = {
8
+ target: 'php',
9
+ client: 'curl',
10
+ generate(request) {
11
+ // TODO: Write an own converter
12
+ return convertWithHttpSnippetLite(curl, request);
13
+ },
14
+ };
15
+
16
+ export { phpCurl };
@@ -0,0 +1,2 @@
1
+ export * from './curl.js';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/plugins/php/curl/index.ts"],"names":[],"mappings":"AAAA,cAAc,QAAQ,CAAA"}
@@ -0,0 +1 @@
1
+ export { phpCurl } from './curl.js';
@@ -0,0 +1,6 @@
1
+ import type { Plugin } from '../../../core/index.js';
2
+ /**
3
+ * php/guzzle
4
+ */
5
+ export declare const phpGuzzle: Plugin;
6
+ //# sourceMappingURL=guzzle.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"guzzle.d.ts","sourceRoot":"","sources":["../../../../src/plugins/php/guzzle/guzzle.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 { guzzle } from '../../../../node_modules/httpsnippet-lite/dist/esm/targets/php/guzzle/client.mjs';
3
+
4
+ /**
5
+ * php/guzzle
6
+ */
7
+ const phpGuzzle = {
8
+ target: 'php',
9
+ client: 'guzzle',
10
+ generate(request) {
11
+ // TODO: Write an own converter
12
+ return convertWithHttpSnippetLite(guzzle, request);
13
+ },
14
+ };
15
+
16
+ export { phpGuzzle };
@@ -0,0 +1,2 @@
1
+ export * from './guzzle.js';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/plugins/php/guzzle/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAA"}
@@ -0,0 +1 @@
1
+ export { phpGuzzle } from './guzzle.js';
@@ -0,0 +1,2 @@
1
+ export * from './restmethod.js';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/plugins/powershell/restmethod/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAA"}
@@ -0,0 +1 @@
1
+ export { powershellRestmethod } from './restmethod.js';
@@ -0,0 +1,6 @@
1
+ import type { Plugin } from '../../../core/index.js';
2
+ /**
3
+ * powershell/restmethod
4
+ */
5
+ export declare const powershellRestmethod: Plugin;
6
+ //# sourceMappingURL=restmethod.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"restmethod.d.ts","sourceRoot":"","sources":["../../../../src/plugins/powershell/restmethod/restmethod.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAKpC;;GAEG;AACH,eAAO,MAAM,oBAAoB,EAAE,MAOlC,CAAA"}