@readme/httpsnippet 11.0.0 → 11.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-Y7NI4MMY.js → chunk-6B3J3CUI.js} +2 -2
- package/dist/chunk-6B3J3CUI.js.map +1 -0
- package/dist/{chunk-452Q5GGQ.js → chunk-EFUQ6POB.js} +26 -24
- package/dist/chunk-EFUQ6POB.js.map +1 -0
- package/dist/{chunk-KT7MO6Z4.js → chunk-LCVMSGCB.js} +2 -2
- package/dist/chunk-LCVMSGCB.js.map +1 -0
- package/dist/helpers/code-builder.cjs.map +1 -1
- package/dist/helpers/code-builder.js +1 -1
- package/dist/helpers/reducer.cjs.map +1 -1
- package/dist/helpers/reducer.js +1 -1
- package/dist/index.cjs +51 -34
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +4 -4
- package/dist/index.d.ts +4 -4
- package/dist/index.js +27 -12
- package/dist/index.js.map +1 -1
- package/dist/targets/index.cjs +23 -21
- package/dist/targets/index.cjs.map +1 -1
- package/dist/targets/index.d.cts +160 -6
- package/dist/targets/index.d.ts +160 -6
- package/dist/targets/index.js +2 -2
- package/package.json +14 -14
- package/dist/chunk-452Q5GGQ.js.map +0 -1
- package/dist/chunk-KT7MO6Z4.js.map +0 -1
- package/dist/chunk-Y7NI4MMY.js.map +0 -1
- package/dist/index-Bi-oJSCB.d.ts +0 -164
- package/dist/index-CM3ebXTM.d.cts +0 -164
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/helpers/code-builder.ts"],"names":[],"mappings":";AAAA,IAAM,6BAAA,GAAgC,EAAA;AACtC,IAAM,iBAAA,GAAoB,IAAA;AAkBnB,IAAM,cAAN,MAAkB;AAAA;AAAA;AAAA;AAAA;AAAA,EAavB,YAAY,EAAE,MAAA,EAAQ,IAAA,EAAK,GAAwB,EAAC,EAAG;AAZvD,IAAA,IAAA,CAAA,cAAA,GAAkC,EAAC;AAEnC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,CAAA,EAAG,cAAc,CAAA;AAClH,MAAA,OAAO,cAAA;AAAA,KACT;AAMA;AAAA;AAAA;AAAA;AAAA,IAAA,IAAA,CAAA,gBAAA,GAAmB,CAAC,aAAA,KAAuC;AACzD,MAAA,IAAA,CAAK,cAAA,GAAiB,CAAC,GAAG,IAAA,CAAK,gBAAgB,aAAa,CAAA;AAAA,KAC9D;AAlDE,IAAA,IAAA,CAAK,uBAAuB,MAAA,IAAU,6BAAA;AACtC,IAAA,IAAA,CAAK,WAAW,IAAA,IAAQ,iBAAA;AAAA;AAkD5B","file":"chunk-6B3J3CUI.js","sourcesContent":["const DEFAULT_INDENTATION_CHARACTER = '';\nconst DEFAULT_LINE_JOIN = '\\n';\n\nexport type PostProcessor = (unreplacedCode: string) => string;\n\nexport interface CodeBuilderOptions {\n /**\n * Desired indentation character for aggregated lines of code\n * @default ''\n */\n indent?: string;\n\n /**\n * Desired character to join each line of code\n * @default \\n\n */\n join?: string;\n}\n\nexport class CodeBuilder {\n postProcessors: PostProcessor[] = [];\n\n code: string[] = [];\n\n indentationCharacter: string = DEFAULT_INDENTATION_CHARACTER;\n\n lineJoin: string = DEFAULT_LINE_JOIN;\n\n /**\n * Helper object to format and aggragate lines of code.\n * Lines are aggregated in a `code` array, and need to be joined to obtain a proper code snippet.\n */\n constructor({ indent, join }: CodeBuilderOptions = {}) {\n this.indentationCharacter = indent || DEFAULT_INDENTATION_CHARACTER;\n this.lineJoin = join ?? DEFAULT_LINE_JOIN;\n }\n\n /**\n * Add given indentation level to given line of code\n */\n indentLine = (line: string, indentationLevel = 0) => {\n const indent = this.indentationCharacter.repeat(indentationLevel);\n return `${indent}${line}`;\n };\n\n /**\n * Add the line at the beginning of the current lines\n */\n unshift = (line: string, indentationLevel?: number): void => {\n const newLine = this.indentLine(line, indentationLevel);\n this.code.unshift(newLine);\n };\n\n /**\n * Add the line at the end of the current lines\n */\n push = (line: string, indentationLevel?: number): void => {\n const newLine = this.indentLine(line, indentationLevel);\n this.code.push(newLine);\n };\n\n /**\n * Add an empty line at the end of current lines\n */\n blank = (): void => {\n this.code.push('');\n };\n\n /**\n * Concatenate all current lines using the given lineJoin, then apply any replacers that may have been added\n */\n join = (): string => {\n const unreplacedCode = this.code.join(this.lineJoin);\n const replacedOutput = this.postProcessors.reduce((accumulator, replacer) => replacer(accumulator), unreplacedCode);\n return replacedOutput;\n };\n\n /**\n * Often when writing modules you may wish to add a literal tag or bit of metadata that you wish to transform after other processing as a final step.\n * To do so, you can provide a PostProcessor function and it will be run automatically for you when you call `join()` later on.\n */\n addPostProcessor = (postProcessor: PostProcessor): void => {\n this.postProcessors = [...this.postProcessors, postProcessor];\n };\n}\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CodeBuilder } from './chunk-
|
|
1
|
+
import { CodeBuilder } from './chunk-6B3J3CUI.js';
|
|
2
2
|
import stringifyObject7 from 'stringify-object';
|
|
3
3
|
|
|
4
4
|
// src/helpers/escape.ts
|
|
@@ -432,7 +432,7 @@ var restsharp = {
|
|
|
432
432
|
link: "http://restsharp.org/",
|
|
433
433
|
description: "Simple REST and HTTP API Client for .NET",
|
|
434
434
|
extname: ".cs",
|
|
435
|
-
installation: "dotnet add package RestSharp"
|
|
435
|
+
installation: () => "dotnet add package RestSharp"
|
|
436
436
|
},
|
|
437
437
|
convert: ({ method, fullUrl, headersObj, cookies, postData, uriObj }) => {
|
|
438
438
|
const { push, join } = new CodeBuilder();
|
|
@@ -841,7 +841,7 @@ var axios = {
|
|
|
841
841
|
link: "https://github.com/axios/axios",
|
|
842
842
|
description: "Promise based HTTP client for the browser and node.js",
|
|
843
843
|
extname: ".js",
|
|
844
|
-
installation: "npm install axios --save"
|
|
844
|
+
installation: () => "npm install axios --save"
|
|
845
845
|
},
|
|
846
846
|
convert: ({ allHeaders, method, url, queryObj, postData }, options) => {
|
|
847
847
|
const opts = {
|
|
@@ -940,7 +940,7 @@ var fetch = {
|
|
|
940
940
|
options.body = postData.jsonObj;
|
|
941
941
|
}
|
|
942
942
|
break;
|
|
943
|
-
case "multipart/form-data":
|
|
943
|
+
case "multipart/form-data": {
|
|
944
944
|
if (!postData.params) {
|
|
945
945
|
break;
|
|
946
946
|
}
|
|
@@ -954,6 +954,7 @@ var fetch = {
|
|
|
954
954
|
});
|
|
955
955
|
blank();
|
|
956
956
|
break;
|
|
957
|
+
}
|
|
957
958
|
default:
|
|
958
959
|
if (postData.text) {
|
|
959
960
|
options.body = postData.text;
|
|
@@ -1164,7 +1165,7 @@ var native2 = {
|
|
|
1164
1165
|
payload = postData.jsonObj;
|
|
1165
1166
|
}
|
|
1166
1167
|
break;
|
|
1167
|
-
case "multipart/form-data":
|
|
1168
|
+
case "multipart/form-data": {
|
|
1168
1169
|
if (!postData.params) {
|
|
1169
1170
|
break;
|
|
1170
1171
|
}
|
|
@@ -1174,6 +1175,7 @@ var native2 = {
|
|
|
1174
1175
|
});
|
|
1175
1176
|
payload = multipartPayload;
|
|
1176
1177
|
break;
|
|
1178
|
+
}
|
|
1177
1179
|
default:
|
|
1178
1180
|
if (postData.text) {
|
|
1179
1181
|
payload = postData.text;
|
|
@@ -1270,7 +1272,7 @@ var axios2 = {
|
|
|
1270
1272
|
link: "https://github.com/axios/axios",
|
|
1271
1273
|
description: "Promise based HTTP client for the browser and node.js",
|
|
1272
1274
|
extname: ".js",
|
|
1273
|
-
installation: "npm install axios --save"
|
|
1275
|
+
installation: () => "npm install axios --save"
|
|
1274
1276
|
},
|
|
1275
1277
|
convert: ({ method, fullUrl, allHeaders, postData }, options) => {
|
|
1276
1278
|
const opts = {
|
|
@@ -1355,7 +1357,7 @@ var fetch2 = {
|
|
|
1355
1357
|
reqOpts.body = postData.jsonObj;
|
|
1356
1358
|
}
|
|
1357
1359
|
break;
|
|
1358
|
-
case "multipart/form-data":
|
|
1360
|
+
case "multipart/form-data": {
|
|
1359
1361
|
if (!postData.params) {
|
|
1360
1362
|
break;
|
|
1361
1363
|
}
|
|
@@ -1379,6 +1381,7 @@ var fetch2 = {
|
|
|
1379
1381
|
reqOpts.body = "formData";
|
|
1380
1382
|
blank();
|
|
1381
1383
|
break;
|
|
1384
|
+
}
|
|
1382
1385
|
default:
|
|
1383
1386
|
if (postData.text) {
|
|
1384
1387
|
reqOpts.body = postData.text;
|
|
@@ -1676,7 +1679,7 @@ var cohttp = {
|
|
|
1676
1679
|
link: "https://github.com/mirage/ocaml-cohttp",
|
|
1677
1680
|
description: "Cohttp is a very lightweight HTTP server using Lwt or Async for OCaml",
|
|
1678
1681
|
extname: ".ml",
|
|
1679
|
-
installation: "opam install cohttp-lwt-unix cohttp-async"
|
|
1682
|
+
installation: () => "opam install cohttp-lwt-unix cohttp-async"
|
|
1680
1683
|
},
|
|
1681
1684
|
convert: ({ fullUrl, allHeaders, postData, method }, options) => {
|
|
1682
1685
|
const opts = {
|
|
@@ -1923,7 +1926,7 @@ var guzzle = {
|
|
|
1923
1926
|
link: "http://docs.guzzlephp.org/en/stable/",
|
|
1924
1927
|
description: "PHP with Guzzle",
|
|
1925
1928
|
extname: ".php",
|
|
1926
|
-
installation: "composer require guzzlehttp/guzzle"
|
|
1929
|
+
installation: () => "composer require guzzlehttp/guzzle"
|
|
1927
1930
|
},
|
|
1928
1931
|
convert: ({ postData, fullUrl, method, cookies, headersObj }, options) => {
|
|
1929
1932
|
const opts = {
|
|
@@ -1984,9 +1987,7 @@ var guzzle = {
|
|
|
1984
1987
|
requestPush(`'body' => ${convertType(postData.text)},`, 1);
|
|
1985
1988
|
}
|
|
1986
1989
|
}
|
|
1987
|
-
const headers = Object.keys(headersObj).sort().map(
|
|
1988
|
-
return `${opts.indent}${opts.indent}'${key}' => '${escapeForSingleQuotes(headersObj[key])}',`;
|
|
1989
|
-
});
|
|
1990
|
+
const headers = Object.keys(headersObj).sort().map((key) => `${opts.indent}${opts.indent}'${key}' => '${escapeForSingleQuotes(headersObj[key])}',`);
|
|
1990
1991
|
const cookieString = cookies.map((cookie) => `${encodeURIComponent(cookie.name)}=${encodeURIComponent(cookie.value)}`).join("; ");
|
|
1991
1992
|
if (cookieString.length) {
|
|
1992
1993
|
headers.push(`${opts.indent}${opts.indent}'cookie' => '${escapeForSingleQuotes(cookieString)}',`);
|
|
@@ -2349,7 +2350,7 @@ var requests = {
|
|
|
2349
2350
|
link: "http://docs.python-requests.org/en/latest/api/#requests.request",
|
|
2350
2351
|
description: "Requests HTTP library",
|
|
2351
2352
|
extname: ".py",
|
|
2352
|
-
installation: "python -m pip install requests"
|
|
2353
|
+
installation: () => "python -m pip install requests"
|
|
2353
2354
|
},
|
|
2354
2355
|
convert: ({ fullUrl, postData, allHeaders, method }, options) => {
|
|
2355
2356
|
const opts = {
|
|
@@ -2753,18 +2754,16 @@ ${indent}` : " "
|
|
|
2753
2754
|
case "application/x-www-form-urlencoded":
|
|
2754
2755
|
if (postData.params) {
|
|
2755
2756
|
postData.params.forEach((param) => {
|
|
2756
|
-
const unencoded = param.name;
|
|
2757
2757
|
const encoded = encodeURIComponent(param.name);
|
|
2758
|
-
const
|
|
2759
|
-
const
|
|
2760
|
-
const flag = binary ? "--data-binary" : needsEncoding ? "--data-urlencode" : arg("data");
|
|
2758
|
+
const name = encoded !== param.name ? encoded : param.name;
|
|
2759
|
+
const flag = binary ? "--data-binary" : "--data-urlencode";
|
|
2761
2760
|
push(`${flag} ${quote(`${name}=${param.value}`)}`);
|
|
2762
2761
|
});
|
|
2763
2762
|
} else {
|
|
2764
2763
|
push(`${binary ? "--data-binary" : arg("data")} ${quote(postData.text)}`);
|
|
2765
2764
|
}
|
|
2766
2765
|
break;
|
|
2767
|
-
default:
|
|
2766
|
+
default: {
|
|
2768
2767
|
if (!postData.text) {
|
|
2769
2768
|
break;
|
|
2770
2769
|
}
|
|
@@ -2791,13 +2790,14 @@ ${JSON.stringify(jsonPayload, null, indentJSON)}
|
|
|
2791
2790
|
'`
|
|
2792
2791
|
);
|
|
2793
2792
|
}
|
|
2794
|
-
} catch
|
|
2793
|
+
} catch {
|
|
2795
2794
|
}
|
|
2796
2795
|
}
|
|
2797
2796
|
}
|
|
2798
2797
|
if (!builtPayload) {
|
|
2799
2798
|
push(`${binary ? "--data-binary" : arg("data")} ${quote(postData.text)}`);
|
|
2800
2799
|
}
|
|
2800
|
+
}
|
|
2801
2801
|
}
|
|
2802
2802
|
return join();
|
|
2803
2803
|
}
|
|
@@ -2811,7 +2811,7 @@ var httpie = {
|
|
|
2811
2811
|
link: "http://httpie.org/",
|
|
2812
2812
|
description: "a CLI, cURL-like tool for humans",
|
|
2813
2813
|
extname: ".sh",
|
|
2814
|
-
installation: "brew install httpie"
|
|
2814
|
+
installation: () => "brew install httpie"
|
|
2815
2815
|
},
|
|
2816
2816
|
convert: ({ allHeaders, postData, queryObj, fullUrl, method, url }, options) => {
|
|
2817
2817
|
const opts = {
|
|
@@ -2880,7 +2880,7 @@ ${opts.indent}` : " "
|
|
|
2880
2880
|
push(`${key}:${quote(allHeaders[key])}`);
|
|
2881
2881
|
});
|
|
2882
2882
|
if (postData.mimeType === "application/x-www-form-urlencoded") {
|
|
2883
|
-
if (postData.params
|
|
2883
|
+
if (postData.params?.length) {
|
|
2884
2884
|
flags.push(opts.short ? "-f" : "--form");
|
|
2885
2885
|
postData.params.forEach((param) => {
|
|
2886
2886
|
push(`${param.name}=${quote(param.value)}`);
|
|
@@ -3036,7 +3036,9 @@ var urlsession = {
|
|
|
3036
3036
|
const parameters = postData.params.map((p) => `"${p.name}": "${p.value}"`);
|
|
3037
3037
|
if (opts.pretty) {
|
|
3038
3038
|
push("let parameters = [");
|
|
3039
|
-
parameters.forEach((param) =>
|
|
3039
|
+
parameters.forEach((param) => {
|
|
3040
|
+
push(`${param},`, 1);
|
|
3041
|
+
});
|
|
3040
3042
|
push("]");
|
|
3041
3043
|
} else {
|
|
3042
3044
|
push(`let parameters = [${parameters.join(", ")}]`);
|
|
@@ -3250,5 +3252,5 @@ var addTargetClient = (targetId, client) => {
|
|
|
3250
3252
|
};
|
|
3251
3253
|
|
|
3252
3254
|
export { addClientPlugin, addTarget, addTargetClient, getHeaderName, isClient, isTarget, targets };
|
|
3253
|
-
//# sourceMappingURL=chunk-
|
|
3254
|
-
//# sourceMappingURL=chunk-
|
|
3255
|
+
//# sourceMappingURL=chunk-EFUQ6POB.js.map
|
|
3256
|
+
//# sourceMappingURL=chunk-EFUQ6POB.js.map
|