@scalar/snippetz 0.9.30 → 0.9.32

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 (123) hide show
  1. package/dist/libs/browser-request.d.ts +14 -0
  2. package/dist/libs/browser-request.d.ts.map +1 -0
  3. package/dist/libs/browser-request.js +64 -0
  4. package/dist/libs/http.d.ts.map +1 -1
  5. package/dist/libs/java.d.ts +6 -0
  6. package/dist/libs/java.d.ts.map +1 -0
  7. package/dist/libs/java.js +21 -0
  8. package/dist/libs/julia.d.ts.map +1 -1
  9. package/dist/libs/julia.js +2 -1
  10. package/dist/libs/powershell.d.ts +4 -0
  11. package/dist/libs/powershell.d.ts.map +1 -0
  12. package/dist/libs/powershell.js +38 -0
  13. package/dist/libs/prepare-request.d.ts +21 -0
  14. package/dist/libs/prepare-request.d.ts.map +1 -0
  15. package/dist/libs/prepare-request.js +58 -0
  16. package/dist/plugins/clojure/clj_http/clj_http.d.ts.map +1 -1
  17. package/dist/plugins/clojure/clj_http/clj_http.js +2 -1
  18. package/dist/plugins/csharp/restsharp/restsharp.js +2 -2
  19. package/dist/plugins/dart/http/http.d.ts.map +1 -1
  20. package/dist/plugins/java/asynchttp/asynchttp.d.ts +1 -3
  21. package/dist/plugins/java/asynchttp/asynchttp.d.ts.map +1 -1
  22. package/dist/plugins/java/asynchttp/asynchttp.js +16 -8
  23. package/dist/plugins/java/nethttp/nethttp.d.ts +1 -3
  24. package/dist/plugins/java/nethttp/nethttp.d.ts.map +1 -1
  25. package/dist/plugins/java/nethttp/nethttp.js +17 -8
  26. package/dist/plugins/java/okhttp/okhttp.d.ts +1 -3
  27. package/dist/plugins/java/okhttp/okhttp.d.ts.map +1 -1
  28. package/dist/plugins/java/okhttp/okhttp.js +50 -8
  29. package/dist/plugins/java/unirest/unirest.d.ts +1 -3
  30. package/dist/plugins/java/unirest/unirest.d.ts.map +1 -1
  31. package/dist/plugins/java/unirest/unirest.js +13 -8
  32. package/dist/plugins/js/jquery/jquery.d.ts +1 -3
  33. package/dist/plugins/js/jquery/jquery.d.ts.map +1 -1
  34. package/dist/plugins/js/jquery/jquery.js +22 -8
  35. package/dist/plugins/js/xhr/xhr.d.ts +1 -3
  36. package/dist/plugins/js/xhr/xhr.d.ts.map +1 -1
  37. package/dist/plugins/js/xhr/xhr.js +13 -8
  38. package/dist/plugins/kotlin/okhttp/okhttp.d.ts.map +1 -1
  39. package/dist/plugins/kotlin/okhttp/okhttp.js +15 -9
  40. package/dist/plugins/ocaml/cohttp/cohttp.d.ts +1 -3
  41. package/dist/plugins/ocaml/cohttp/cohttp.d.ts.map +1 -1
  42. package/dist/plugins/ocaml/cohttp/cohttp.js +32 -8
  43. package/dist/plugins/php/laravel/laravel.d.ts.map +1 -1
  44. package/dist/plugins/php/laravel/laravel.js +2 -1
  45. package/dist/plugins/powershell/restmethod/restmethod.d.ts +1 -3
  46. package/dist/plugins/powershell/restmethod/restmethod.d.ts.map +1 -1
  47. package/dist/plugins/powershell/restmethod/restmethod.js +4 -8
  48. package/dist/plugins/powershell/webrequest/webrequest.d.ts +1 -3
  49. package/dist/plugins/powershell/webrequest/webrequest.d.ts.map +1 -1
  50. package/dist/plugins/powershell/webrequest/webrequest.js +4 -8
  51. package/dist/plugins/python/requestsLike.d.ts.map +1 -1
  52. package/dist/plugins/r/httr2/httr2.d.ts.map +1 -1
  53. package/dist/plugins/r/httr2/httr2.js +2 -1
  54. package/dist/plugins/shared/axios.d.ts.map +1 -1
  55. package/dist/plugins/shell/curl/curl.d.ts.map +1 -1
  56. package/dist/plugins/shell/curl/curl.js +12 -1
  57. package/dist/plugins/shell/httpie/httpie.d.ts +1 -3
  58. package/dist/plugins/shell/httpie/httpie.d.ts.map +1 -1
  59. package/dist/plugins/shell/httpie/httpie.js +34 -8
  60. package/package.json +4 -11
  61. package/dist/httpsnippet-lite/helpers/code-builder.d.ts +0 -51
  62. package/dist/httpsnippet-lite/helpers/code-builder.d.ts.map +0 -1
  63. package/dist/httpsnippet-lite/helpers/code-builder.js +0 -87
  64. package/dist/httpsnippet-lite/helpers/escape.d.ts +0 -48
  65. package/dist/httpsnippet-lite/helpers/escape.d.ts.map +0 -1
  66. package/dist/httpsnippet-lite/helpers/escape.js +0 -70
  67. package/dist/httpsnippet-lite/helpers/headers.d.ts +0 -15
  68. package/dist/httpsnippet-lite/helpers/headers.d.ts.map +0 -1
  69. package/dist/httpsnippet-lite/helpers/headers.js +0 -18
  70. package/dist/httpsnippet-lite/helpers/reducer.d.ts +0 -2
  71. package/dist/httpsnippet-lite/helpers/reducer.d.ts.map +0 -1
  72. package/dist/httpsnippet-lite/helpers/reducer.js +0 -1
  73. package/dist/httpsnippet-lite/helpers/shell.d.ts +0 -6
  74. package/dist/httpsnippet-lite/helpers/shell.d.ts.map +0 -1
  75. package/dist/httpsnippet-lite/helpers/shell.js +0 -13
  76. package/dist/httpsnippet-lite/helpers/snippet-request.d.ts +0 -33
  77. package/dist/httpsnippet-lite/helpers/snippet-request.d.ts.map +0 -1
  78. package/dist/httpsnippet-lite/helpers/snippet-request.js +0 -1
  79. package/dist/httpsnippet-lite/helpers/url.d.ts +0 -4
  80. package/dist/httpsnippet-lite/helpers/url.d.ts.map +0 -1
  81. package/dist/httpsnippet-lite/helpers/url.js +0 -5
  82. package/dist/httpsnippet-lite/targets/java/asynchttp/client.d.ts +0 -12
  83. package/dist/httpsnippet-lite/targets/java/asynchttp/client.d.ts.map +0 -1
  84. package/dist/httpsnippet-lite/targets/java/asynchttp/client.js +0 -33
  85. package/dist/httpsnippet-lite/targets/java/nethttp/client.d.ts +0 -3
  86. package/dist/httpsnippet-lite/targets/java/nethttp/client.d.ts.map +0 -1
  87. package/dist/httpsnippet-lite/targets/java/nethttp/client.js +0 -41
  88. package/dist/httpsnippet-lite/targets/java/okhttp/client.d.ts +0 -12
  89. package/dist/httpsnippet-lite/targets/java/okhttp/client.d.ts.map +0 -1
  90. package/dist/httpsnippet-lite/targets/java/okhttp/client.js +0 -87
  91. package/dist/httpsnippet-lite/targets/java/unirest/client.d.ts +0 -12
  92. package/dist/httpsnippet-lite/targets/java/unirest/client.d.ts.map +0 -1
  93. package/dist/httpsnippet-lite/targets/java/unirest/client.js +0 -42
  94. package/dist/httpsnippet-lite/targets/javascript/jquery/client.d.ts +0 -3
  95. package/dist/httpsnippet-lite/targets/javascript/jquery/client.d.ts.map +0 -1
  96. package/dist/httpsnippet-lite/targets/javascript/jquery/client.js +0 -80
  97. package/dist/httpsnippet-lite/targets/javascript/xhr/client.d.ts +0 -3
  98. package/dist/httpsnippet-lite/targets/javascript/xhr/client.d.ts.map +0 -1
  99. package/dist/httpsnippet-lite/targets/javascript/xhr/client.js +0 -78
  100. package/dist/httpsnippet-lite/targets/ocaml/cohttp/client.d.ts +0 -3
  101. package/dist/httpsnippet-lite/targets/ocaml/cohttp/client.d.ts.map +0 -1
  102. package/dist/httpsnippet-lite/targets/ocaml/cohttp/client.js +0 -61
  103. package/dist/httpsnippet-lite/targets/powershell/common.d.ts +0 -3
  104. package/dist/httpsnippet-lite/targets/powershell/common.d.ts.map +0 -1
  105. package/dist/httpsnippet-lite/targets/powershell/common.js +0 -48
  106. package/dist/httpsnippet-lite/targets/powershell/restmethod/client.d.ts +0 -3
  107. package/dist/httpsnippet-lite/targets/powershell/restmethod/client.d.ts.map +0 -1
  108. package/dist/httpsnippet-lite/targets/powershell/restmethod/client.js +0 -10
  109. package/dist/httpsnippet-lite/targets/powershell/webrequest/client.d.ts +0 -3
  110. package/dist/httpsnippet-lite/targets/powershell/webrequest/client.d.ts.map +0 -1
  111. package/dist/httpsnippet-lite/targets/powershell/webrequest/client.js +0 -10
  112. package/dist/httpsnippet-lite/targets/shell/httpie/client.d.ts +0 -12
  113. package/dist/httpsnippet-lite/targets/shell/httpie/client.d.ts.map +0 -1
  114. package/dist/httpsnippet-lite/targets/shell/httpie/client.js +0 -124
  115. package/dist/httpsnippet-lite/targets/target.d.ts +0 -19
  116. package/dist/httpsnippet-lite/targets/target.d.ts.map +0 -1
  117. package/dist/httpsnippet-lite/targets/target.js +0 -1
  118. package/dist/utils/convertWithHttpSnippetLite.d.ts +0 -8
  119. package/dist/utils/convertWithHttpSnippetLite.d.ts.map +0 -1
  120. package/dist/utils/convertWithHttpSnippetLite.js +0 -102
  121. package/dist/utils/index.d.ts +0 -2
  122. package/dist/utils/index.d.ts.map +0 -1
  123. package/dist/utils/index.js +0 -1
@@ -1,70 +0,0 @@
1
- /**
2
- * Escape characters within a value to make it safe to insert directly into a
3
- * snippet. Takes options which define the escape requirements.
4
- *
5
- * This is closely based on the JSON-stringify string serialization algorithm,
6
- * but generalized for other string delimiters (e.g. " or ') and different escape
7
- * characters (e.g. Powershell uses `)
8
- *
9
- * See https://tc39.es/ecma262/multipage/structured-data.html#sec-quotejsonstring
10
- * for the complete original algorithm.
11
- */
12
- export function escapeString(rawValue, options = {}) {
13
- const { delimiter = '"', escapeChar = '\\', escapeNewlines = true } = options;
14
- const stringValue = rawValue.toString();
15
- return [...stringValue]
16
- .map((c) => {
17
- if (c === '\b') {
18
- return `${escapeChar}b`;
19
- }
20
- if (c === '\t') {
21
- return `${escapeChar}t`;
22
- }
23
- if (c === '\n') {
24
- if (escapeNewlines) {
25
- return `${escapeChar}n`;
26
- }
27
- return c; // Don't just continue, or this is caught by < \u0020
28
- }
29
- if (c === '\f') {
30
- return `${escapeChar}f`;
31
- }
32
- if (c === '\r') {
33
- if (escapeNewlines) {
34
- return `${escapeChar}r`;
35
- }
36
- return c; // Don't just continue, or this is caught by < \u0020
37
- }
38
- if (c === escapeChar) {
39
- return escapeChar + escapeChar;
40
- }
41
- if (c === delimiter) {
42
- return escapeChar + delimiter;
43
- }
44
- if (c < '\u0020' || c > '\u007E') {
45
- // Delegate the trickier non-ASCII cases to the normal algorithm. Some of these
46
- // are escaped as \uXXXX, whilst others are represented literally. Since we're
47
- // using this primarily for header values that are generally (though not 100%
48
- // strictly?) ASCII-only, this should almost never happen.
49
- return JSON.stringify(c).slice(1, -1);
50
- }
51
- return c;
52
- })
53
- .join('');
54
- }
55
- /**
56
- * Make a string value safe to insert literally into a snippet within single quotes,
57
- * by escaping problematic characters, including single quotes inside the string,
58
- * backslashes, newlines, and other special characters.
59
- *
60
- * If value is not a string, it will be stringified with .toString() first.
61
- */
62
- export const escapeForSingleQuotes = (value) => escapeString(value, { delimiter: "'" });
63
- /**
64
- * Make a string value safe to insert literally into a snippet within double quotes,
65
- * by escaping problematic characters, including double quotes inside the string,
66
- * backslashes, newlines, and other special characters.
67
- *
68
- * If value is not a string, it will be stringified with .toString() first.
69
- */
70
- export const escapeForDoubleQuotes = (value) => escapeString(value, { delimiter: '"' });
@@ -1,15 +0,0 @@
1
- type Headers<T> = Record<string, T>;
2
- /**
3
- * Given a headers object retrieve a specific header out of it via a case-insensitive key.
4
- */
5
- export declare const getHeaderName: <T>(headers: Headers<T>, name: string) => string | undefined;
6
- /**
7
- * Given a headers object retrieve the contents of a header out of it via a case-insensitive key.
8
- */
9
- export declare const getHeader: <T>(headers: Headers<T>, name: string) => T;
10
- /**
11
- * Determine if a given case-insensitive header exists within a header object.
12
- */
13
- export declare const hasHeader: <T>(headers: Headers<T>, name: string) => boolean;
14
- export {};
15
- //# sourceMappingURL=headers.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"headers.d.ts","sourceRoot":"","sources":["../../../src/httpsnippet-lite/helpers/headers.ts"],"names":[],"mappings":"AAAA,KAAK,OAAO,CAAC,CAAC,IAAI,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,CAAA;AAEnC;;GAEG;AACH,eAAO,MAAM,aAAa,GAAI,CAAC,EAAE,SAAS,OAAO,CAAC,CAAC,CAAC,EAAE,MAAM,MAAM,KAAG,MAAM,GAAG,SACM,CAAA;AAEpF;;GAEG;AACH,eAAO,MAAM,SAAS,GAAI,CAAC,EAAE,SAAS,OAAO,CAAC,CAAC,CAAC,EAAE,MAAM,MAAM,KAAG,CAMhE,CAAA;AACD;;GAEG;AACH,eAAO,MAAM,SAAS,GAAI,CAAC,EAAE,SAAS,OAAO,CAAC,CAAC,CAAC,EAAE,MAAM,MAAM,KAAG,OAAgD,CAAA"}
@@ -1,18 +0,0 @@
1
- /**
2
- * Given a headers object retrieve a specific header out of it via a case-insensitive key.
3
- */
4
- export const getHeaderName = (headers, name) => Object.keys(headers).find((header) => header.toLowerCase() === name.toLowerCase());
5
- /**
6
- * Given a headers object retrieve the contents of a header out of it via a case-insensitive key.
7
- */
8
- export const getHeader = (headers, name) => {
9
- const headerName = getHeaderName(headers, name);
10
- if (!headerName) {
11
- return undefined;
12
- }
13
- return headers[headerName];
14
- };
15
- /**
16
- * Determine if a given case-insensitive header exists within a header object.
17
- */
18
- export const hasHeader = (headers, name) => Boolean(getHeaderName(headers, name));
@@ -1,2 +0,0 @@
1
- export type ReducedHelperObject = Record<string, string[] | string>;
2
- //# sourceMappingURL=reducer.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"reducer.d.ts","sourceRoot":"","sources":["../../../src/httpsnippet-lite/helpers/reducer.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,mBAAmB,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,CAAC,CAAA"}
@@ -1 +0,0 @@
1
- export {};
@@ -1,6 +0,0 @@
1
- /**
2
- * Use 'strong quoting' using single quotes so that we only need to deal with nested single quote characters.
3
- * see: http://wiki.bash-hackers.org/syntax/quoting#strong_quoting
4
- */
5
- export declare const shellQuote: (value?: string) => string;
6
- //# sourceMappingURL=shell.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"shell.d.ts","sourceRoot":"","sources":["../../../src/httpsnippet-lite/helpers/shell.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,eAAO,MAAM,UAAU,GAAI,cAAU,KAAG,MAQvC,CAAA"}
@@ -1,13 +0,0 @@
1
- /**
2
- * Use 'strong quoting' using single quotes so that we only need to deal with nested single quote characters.
3
- * see: http://wiki.bash-hackers.org/syntax/quoting#strong_quoting
4
- */
5
- export const shellQuote = (value = '') => {
6
- const safe = /^[a-z0-9-_/.@%^=:]+$/i;
7
- const isShellSafe = safe.test(value);
8
- if (isShellSafe) {
9
- return value;
10
- }
11
- // if the value is not shell safe, then quote it
12
- return `'${value.replace(/'/g, "'\\''")}'`;
13
- };
@@ -1,33 +0,0 @@
1
- import type { HarRequest as NpmHarRequest, FormDataParam as Param, PostDataCommon } from '@scalar/types/snippetz';
2
- import type { ReducedHelperObject } from '../../httpsnippet-lite/helpers/reducer.js';
3
- import type { ExtendedURL } from '../../httpsnippet-lite/helpers/url.js';
4
- /**
5
- * is this wrong? yes. according to the spec (http://www.softwareishard.com/blog/har-12-spec/#postData) it's technically wrong since `params` and `text` are (by the spec) mutually exclusive. However, in practice, this is not what is often the case.
6
- *
7
- * In general, this library takes a _descriptive_ rather than _perscriptive_ approach (see https://amyrey.web.unc.edu/classes/ling-101-online/tutorials/understanding-prescriptive-vs-descriptive-grammar/).
8
- *
9
- * Then, in addition to that, it really adds to complexity with TypeScript (TypeScript takes this constraint very very seriously) in a way that's not actually super useful. So, we treat this object as though it could have both or either of `params` and/or `text`.
10
- */
11
- type PostDataBase = PostDataCommon & {
12
- text?: string;
13
- params?: Param[];
14
- };
15
- type HarRequest = Omit<NpmHarRequest, 'postData'> & {
16
- postData?: PostDataBase;
17
- };
18
- type RequestExtras = {
19
- postData?: PostDataBase & {
20
- jsonObj?: ReducedHelperObject;
21
- paramsObj?: ReducedHelperObject;
22
- boundary?: string;
23
- };
24
- fullUrl: string;
25
- queryObj: ReducedHelperObject;
26
- headersObj: ReducedHelperObject;
27
- uriObj: ExtendedURL;
28
- cookiesObj: ReducedHelperObject;
29
- allHeaders: ReducedHelperObject;
30
- };
31
- export type SnippetRequest = HarRequest & RequestExtras;
32
- export {};
33
- //# sourceMappingURL=snippet-request.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"snippet-request.d.ts","sourceRoot":"","sources":["../../../src/httpsnippet-lite/helpers/snippet-request.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,IAAI,aAAa,EAAE,aAAa,IAAI,KAAK,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAA;AAEjH,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,oCAAoC,CAAA;AAC7E,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gCAAgC,CAAA;AAEjE;;;;;;GAMG;AACH,KAAK,YAAY,GAAG,cAAc,GAAG;IACnC,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,MAAM,CAAC,EAAE,KAAK,EAAE,CAAA;CACjB,CAAA;AACD,KAAK,UAAU,GAAG,IAAI,CAAC,aAAa,EAAE,UAAU,CAAC,GAAG;IAClD,QAAQ,CAAC,EAAE,YAAY,CAAA;CACxB,CAAA;AACD,KAAK,aAAa,GAAG;IACnB,QAAQ,CAAC,EAAE,YAAY,GAAG;QACxB,OAAO,CAAC,EAAE,mBAAmB,CAAA;QAC7B,SAAS,CAAC,EAAE,mBAAmB,CAAA;QAC/B,QAAQ,CAAC,EAAE,MAAM,CAAA;KAClB,CAAA;IACD,OAAO,EAAE,MAAM,CAAA;IACf,QAAQ,EAAE,mBAAmB,CAAA;IAC7B,UAAU,EAAE,mBAAmB,CAAA;IAC/B,MAAM,EAAE,WAAW,CAAA;IACnB,UAAU,EAAE,mBAAmB,CAAA;IAC/B,UAAU,EAAE,mBAAmB,CAAA;CAChC,CAAA;AAED,MAAM,MAAM,cAAc,GAAG,UAAU,GAAG,aAAa,CAAA"}
@@ -1 +0,0 @@
1
- export {};
@@ -1,4 +0,0 @@
1
- export declare class ExtendedURL extends URL {
2
- get path(): string;
3
- }
4
- //# sourceMappingURL=url.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"url.d.ts","sourceRoot":"","sources":["../../../src/httpsnippet-lite/helpers/url.ts"],"names":[],"mappings":"AAAA,qBAAa,WAAY,SAAQ,GAAG;IAClC,IAAI,IAAI,WAEP;CACF"}
@@ -1,5 +0,0 @@
1
- export class ExtendedURL extends URL {
2
- get path() {
3
- return this.pathname + this.search;
4
- }
5
- }
@@ -1,12 +0,0 @@
1
- /**
2
- * @description
3
- * Asynchronous Http and WebSocket Client library for Java
4
- *
5
- * @author
6
- * @windard
7
- *
8
- * for any questions or issues regarding the generated code snippet, please open an issue mentioning the author.
9
- */
10
- import type { Client } from '../../../../httpsnippet-lite/targets/target.js';
11
- export declare const asynchttp: Client;
12
- //# sourceMappingURL=client.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../../../../src/httpsnippet-lite/targets/java/asynchttp/client.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,sCAAsC,CAAA;AAKlE,eAAO,MAAM,SAAS,EAAE,MA8BvB,CAAA"}
@@ -1,33 +0,0 @@
1
- import { CodeBuilder } from '../../../helpers/code-builder.js';
2
- import { escapeForDoubleQuotes } from '../../../helpers/escape.js';
3
- export const asynchttp = {
4
- info: {
5
- key: 'asynchttp',
6
- title: 'AsyncHttp',
7
- link: 'https://github.com/AsyncHttpClient/async-http-client',
8
- description: 'Asynchronous Http and WebSocket Client library for Java',
9
- },
10
- convert: ({ method, allHeaders, postData, fullUrl }, options) => {
11
- const opts = {
12
- indent: ' ',
13
- ...options,
14
- };
15
- const { blank, push, join } = new CodeBuilder({ indent: opts.indent });
16
- push('AsyncHttpClient client = new DefaultAsyncHttpClient();');
17
- push(`client.prepare("${method.toUpperCase()}", "${fullUrl}")`);
18
- // Add headers, including the cookies
19
- Object.keys(allHeaders).forEach((key) => {
20
- push(`.setHeader("${key}", "${escapeForDoubleQuotes(allHeaders[key])}")`, 1);
21
- });
22
- if (postData === null || postData === void 0 ? void 0 : postData.text) {
23
- push(`.setBody(${JSON.stringify(postData.text)})`, 1);
24
- }
25
- push('.execute()', 1);
26
- push('.toCompletableFuture()', 1);
27
- push('.thenAccept(System.out::println)', 1);
28
- push('.join();', 1);
29
- blank();
30
- push('client.close();');
31
- return join();
32
- },
33
- };
@@ -1,3 +0,0 @@
1
- import type { Client } from '../../../../httpsnippet-lite/targets/target.js';
2
- export declare const nethttp: Client;
3
- //# sourceMappingURL=client.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../../../../src/httpsnippet-lite/targets/java/nethttp/client.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,sCAAsC,CAAA;AAElE,eAAO,MAAM,OAAO,EAAE,MAiCrB,CAAA"}
@@ -1,41 +0,0 @@
1
- /**
2
- * @description
3
- * HTTP code snippet generator for Java using java.net.http.
4
- *
5
- * @author
6
- * @wtetsu
7
- *
8
- * for any questions or issues regarding the generated code snippet, please open an issue mentioning the author.
9
- */
10
- import { CodeBuilder } from '../../../../httpsnippet-lite/helpers/code-builder.js';
11
- import { escapeForDoubleQuotes } from '../../../../httpsnippet-lite/helpers/escape.js';
12
- export const nethttp = {
13
- info: {
14
- key: 'nethttp',
15
- title: 'java.net.http',
16
- link: 'https://openjdk.java.net/groups/net/httpclient/intro.html',
17
- description: 'Java Standardized HTTP Client API',
18
- },
19
- convert: ({ allHeaders, fullUrl, method, postData }, options) => {
20
- const opts = {
21
- indent: ' ',
22
- ...options,
23
- };
24
- const { push, join } = new CodeBuilder({ indent: opts.indent });
25
- push('HttpRequest request = HttpRequest.newBuilder()');
26
- push(`.uri(URI.create("${fullUrl}"))`, 2);
27
- Object.keys(allHeaders).forEach((key) => {
28
- push(`.header("${key}", "${escapeForDoubleQuotes(allHeaders[key])}")`, 2);
29
- });
30
- if (postData === null || postData === void 0 ? void 0 : postData.text) {
31
- push(`.method("${method.toUpperCase()}", HttpRequest.BodyPublishers.ofString(${JSON.stringify(postData.text)}))`, 2);
32
- }
33
- else {
34
- push(`.method("${method.toUpperCase()}", HttpRequest.BodyPublishers.noBody())`, 2);
35
- }
36
- push('.build();', 2);
37
- push('HttpResponse<String> response = HttpClient.newHttpClient().send(request, HttpResponse.BodyHandlers.ofString());');
38
- push('System.out.println(response.body());');
39
- return join();
40
- },
41
- };
@@ -1,12 +0,0 @@
1
- /**
2
- * @description
3
- * HTTP code snippet generator for Java using OkHttp.
4
- *
5
- * @author
6
- * @shashiranjan84
7
- *
8
- * for any questions or issues regarding the generated code snippet, please open an issue mentioning the author.
9
- */
10
- import type { Client } from '../../../../httpsnippet-lite/targets/target.js';
11
- export declare const okhttp: Client;
12
- //# sourceMappingURL=client.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../../../../src/httpsnippet-lite/targets/java/okhttp/client.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAIH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mCAAmC,CAAA;AAE/D,eAAO,MAAM,MAAM,EAAE,MAuEpB,CAAA"}
@@ -1,87 +0,0 @@
1
- /**
2
- * @description
3
- * HTTP code snippet generator for Java using OkHttp.
4
- *
5
- * @author
6
- * @shashiranjan84
7
- *
8
- * for any questions or issues regarding the generated code snippet, please open an issue mentioning the author.
9
- */
10
- import { CodeBuilder } from '../../../../httpsnippet-lite/helpers/code-builder.js';
11
- import { escapeForDoubleQuotes } from '../../../../httpsnippet-lite/helpers/escape.js';
12
- export const okhttp = {
13
- info: {
14
- key: 'okhttp',
15
- title: 'OkHttp',
16
- link: 'http://square.github.io/okhttp/',
17
- description: 'An HTTP Request Client Library',
18
- },
19
- convert: ({ postData, method, fullUrl, allHeaders }, options) => {
20
- const opts = {
21
- indent: ' ',
22
- ...options,
23
- };
24
- const { push, blank, join } = new CodeBuilder({ indent: opts.indent });
25
- const methods = ['GET', 'POST', 'PUT', 'DELETE', 'PATCH', 'HEAD'];
26
- const methodsWithBody = ['POST', 'PUT', 'DELETE', 'PATCH'];
27
- push('OkHttpClient client = new OkHttpClient();');
28
- blank();
29
- if (postData !== null && postData !== void 0) {
30
- if (postData.mimeType === 'application/x-www-form-urlencoded' && postData.params) {
31
- push('FormBody formBody = new FormBody.Builder()');
32
- postData.params.forEach((param) => {
33
- push(`.addEncoded("${param.name}", "${param.value}")`, 1);
34
- });
35
- push('.build();', 1);
36
- blank();
37
- }
38
- else if (postData.mimeType === 'multipart/form-data' && postData.params) {
39
- push('MultipartBody body = new MultipartBody.Builder()');
40
- push('.setType(MultipartBody.FORM)', 1);
41
- postData.params.forEach((param) => {
42
- if (param.fileName !== undefined) {
43
- push(`.addFormDataPart("${param.name}", "${param.fileName}", RequestBody.create(MediaType.parse("application/octet-stream"), new File("${param.fileName}")))`, 1);
44
- }
45
- else if (param.value !== undefined) {
46
- push(`.addFormDataPart("${param.name}", "${param.value}")`, 1);
47
- }
48
- });
49
- push('.build();', 1);
50
- blank();
51
- }
52
- else {
53
- push(`MediaType mediaType = MediaType.parse("${postData.mimeType}");`);
54
- push(`RequestBody body = RequestBody.create(mediaType, ${JSON.stringify(postData.text)});`);
55
- }
56
- }
57
- push('Request request = new Request.Builder()');
58
- push(`.url("${fullUrl}")`, 1);
59
- if (!methods.includes(method.toUpperCase())) {
60
- if (postData === null || postData === void 0 ? void 0 : postData.text) {
61
- push(`.method("${method.toUpperCase()}", body)`, 1);
62
- }
63
- else {
64
- push(`.method("${method.toUpperCase()}", null)`, 1);
65
- }
66
- }
67
- else if (methodsWithBody.includes(method.toUpperCase())) {
68
- if (postData === null || postData === void 0 ? void 0 : postData.text || postData.params) {
69
- push(`.${method.toLowerCase()}(body)`, 1);
70
- }
71
- else {
72
- push(`.${method.toLowerCase()}(null)`, 1);
73
- }
74
- }
75
- else {
76
- push(`.${method.toLowerCase()}()`, 1);
77
- }
78
- // Add headers, including the cookies
79
- Object.keys(allHeaders).forEach((key) => {
80
- push(`.addHeader("${key}", "${escapeForDoubleQuotes(allHeaders[key])}")`, 1);
81
- });
82
- push('.build();', 1);
83
- blank();
84
- push('Response response = client.newCall(request).execute();');
85
- return join();
86
- },
87
- };
@@ -1,12 +0,0 @@
1
- /**
2
- * @description
3
- * HTTP code snippet generator for Java using Unirest.
4
- *
5
- * @author
6
- * @shashiranjan84
7
- *
8
- * for any questions or issues regarding the generated code snippet, please open an issue mentioning the author.
9
- */
10
- import type { Client } from '../../../../httpsnippet-lite/targets/target.js';
11
- export declare const unirest: Client;
12
- //# sourceMappingURL=client.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../../../../src/httpsnippet-lite/targets/java/unirest/client.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAIH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mCAAmC,CAAA;AAE/D,eAAO,MAAM,OAAO,EAAE,MA6BrB,CAAA"}
@@ -1,42 +0,0 @@
1
- /**
2
- * @description
3
- * HTTP code snippet generator for Java using Unirest.
4
- *
5
- * @author
6
- * @shashiranjan84
7
- *
8
- * for any questions or issues regarding the generated code snippet, please open an issue mentioning the author.
9
- */
10
- import { CodeBuilder } from '../../../../httpsnippet-lite/helpers/code-builder.js';
11
- import { escapeForDoubleQuotes } from '../../../../httpsnippet-lite/helpers/escape.js';
12
- export const unirest = {
13
- info: {
14
- key: 'unirest',
15
- title: 'Unirest',
16
- link: 'http://unirest.io/java.html',
17
- description: 'Lightweight HTTP Request Client Library',
18
- },
19
- convert: ({ method, allHeaders, postData, fullUrl }, options) => {
20
- const opts = {
21
- indent: ' ',
22
- ...options,
23
- };
24
- const { join, push } = new CodeBuilder({ indent: opts.indent });
25
- const methods = ['GET', 'POST', 'PUT', 'DELETE', 'PATCH', 'HEAD', 'OPTIONS'];
26
- if (!methods.includes(method.toUpperCase())) {
27
- push(`HttpResponse<String> response = Unirest.customMethod("${method.toUpperCase()}","${fullUrl}")`);
28
- }
29
- else {
30
- push(`HttpResponse<String> response = Unirest.${method.toLowerCase()}("${fullUrl}")`);
31
- }
32
- // Add headers, including the cookies
33
- Object.keys(allHeaders).forEach((key) => {
34
- push(`.header("${key}", "${escapeForDoubleQuotes(allHeaders[key])}")`, 1);
35
- });
36
- if (postData === null || postData === void 0 ? void 0 : postData.text) {
37
- push(`.body(${JSON.stringify(postData.text)})`, 1);
38
- }
39
- push('.asString();', 1);
40
- return join();
41
- },
42
- };
@@ -1,3 +0,0 @@
1
- import type { Client } from '../../../../httpsnippet-lite/targets/target.js';
2
- export declare const jquery: Client;
3
- //# sourceMappingURL=client.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../../../../src/httpsnippet-lite/targets/javascript/jquery/client.ts"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mCAAmC,CAAA;AAE/D,eAAO,MAAM,MAAM,EAAE,MA+EpB,CAAA"}
@@ -1,80 +0,0 @@
1
- /**
2
- * @description
3
- * HTTP code snippet generator for native XMLHttpRequest
4
- *
5
- * @author
6
- * @AhmadNassri
7
- *
8
- * for any questions or issues regarding the generated code snippet, please open an issue mentioning the author.
9
- */
10
- import stringifyObject from 'stringify-object';
11
- import { CodeBuilder } from '../../../../httpsnippet-lite/helpers/code-builder.js';
12
- import { getHeader, getHeaderName, hasHeader } from '../../../../httpsnippet-lite/helpers/headers.js';
13
- export const jquery = {
14
- info: {
15
- key: 'jquery',
16
- title: 'jQuery',
17
- link: 'http://api.jquery.com/jquery.ajax/',
18
- description: 'Perform an asynchronous HTTP (Ajax) requests with jQuery',
19
- },
20
- convert: ({ fullUrl, method, allHeaders, postData }, options) => {
21
- let _a;
22
- const opts = {
23
- indent: ' ',
24
- ...options,
25
- };
26
- const { blank, push, join } = new CodeBuilder({ indent: opts.indent });
27
- const settings = {
28
- async: true,
29
- crossDomain: true,
30
- url: fullUrl,
31
- method,
32
- headers: allHeaders,
33
- };
34
- switch (postData === null || postData === void 0 ? void 0 : postData.mimeType) {
35
- case 'application/x-www-form-urlencoded':
36
- settings.data = postData?.paramsObj ? postData.paramsObj : postData.text;
37
- break;
38
- case 'application/json':
39
- settings.processData = false;
40
- settings.data = postData.text;
41
- break;
42
- case 'multipart/form-data':
43
- if (!postData?.params) {
44
- break;
45
- }
46
- push('const form = new FormData();');
47
- postData.params.forEach((param) => {
48
- push(`form.append('${param.name}', '${param.value || param.fileName || ''}');`);
49
- });
50
- settings.processData = false;
51
- settings.contentType = false;
52
- settings.mimeType = 'multipart/form-data';
53
- settings.data = '[form]';
54
- // remove the contentType header
55
- if (hasHeader(allHeaders, 'content-type')) {
56
- if ((_a = getHeader(allHeaders, 'content-type')) === null || _a === void 0 ? void 0 : _a.includes('boundary')) {
57
- const headerName = getHeaderName(allHeaders, 'content-type');
58
- if (headerName) {
59
- delete settings.headers[headerName];
60
- }
61
- }
62
- }
63
- blank();
64
- break;
65
- default:
66
- if (postData === null || postData === void 0 ? void 0 : postData.text) {
67
- settings.data = postData.text;
68
- }
69
- }
70
- const stringifiedSettings = stringifyObject(settings, {
71
- indent: opts.indent,
72
- }).replace("'[form]'", 'form');
73
- push(`const settings = ${stringifiedSettings};`);
74
- blank();
75
- push('$.ajax(settings).done(function (response) {');
76
- push('console.log(response);', 1);
77
- push('});');
78
- return join();
79
- },
80
- };
@@ -1,3 +0,0 @@
1
- import type { Client } from '../../../../httpsnippet-lite/targets/target.js';
2
- export declare const xhr: Client;
3
- //# sourceMappingURL=client.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../../../../src/httpsnippet-lite/targets/javascript/xhr/client.ts"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mCAAmC,CAAA;AAE/D,eAAO,MAAM,GAAG,EAAE,MAsEjB,CAAA"}