@mintlify/msft-sdk 1.1.61 → 1.1.62

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 (69) hide show
  1. package/dist/api-playground-2/generators/generateSnippet.js +1 -1
  2. package/dist/httpsnippet/src/helpers/code-builder.js +27 -0
  3. package/dist/httpsnippet/src/helpers/escape.js +11 -0
  4. package/dist/httpsnippet/src/helpers/headers.js +13 -0
  5. package/dist/httpsnippet/src/helpers/reducer.js +7 -0
  6. package/dist/httpsnippet/src/helpers/shell.js +5 -0
  7. package/dist/httpsnippet/src/helpers/url-format.js +35 -0
  8. package/dist/httpsnippet/src/helpers/url-parse.js +76 -0
  9. package/dist/httpsnippet/src/index.js +157 -0
  10. package/dist/httpsnippet/src/targets/c/libcurl/client.js +22 -0
  11. package/dist/httpsnippet/src/targets/c/target.js +15 -0
  12. package/dist/httpsnippet/src/targets/clojure/clj_http/client.js +120 -0
  13. package/dist/httpsnippet/src/targets/clojure/target.js +14 -0
  14. package/dist/httpsnippet/src/targets/csharp/httpclient/client.js +76 -0
  15. package/dist/httpsnippet/src/targets/csharp/restsharp/client.js +63 -0
  16. package/dist/httpsnippet/src/targets/csharp/target.js +17 -0
  17. package/dist/httpsnippet/src/targets/go/native/client.js +24 -0
  18. package/dist/httpsnippet/src/targets/go/target.js +15 -0
  19. package/dist/httpsnippet/src/targets/http/http1.1/client.js +34 -0
  20. package/dist/httpsnippet/src/targets/http/target.js +14 -0
  21. package/dist/httpsnippet/src/targets/index.js +43 -0
  22. package/dist/httpsnippet/src/targets/java/asynchttp/client.js +23 -0
  23. package/dist/httpsnippet/src/targets/java/nethttp/client.js +28 -0
  24. package/dist/httpsnippet/src/targets/java/okhttp/client.js +23 -0
  25. package/dist/httpsnippet/src/targets/java/target.js +20 -0
  26. package/dist/httpsnippet/src/targets/java/unirest/client.js +23 -0
  27. package/dist/httpsnippet/src/targets/javascript/axios/client.js +50 -0
  28. package/dist/httpsnippet/src/targets/javascript/fetch/client.js +61 -0
  29. package/dist/httpsnippet/src/targets/javascript/jquery/client.js +51 -0
  30. package/dist/httpsnippet/src/targets/javascript/target.js +20 -0
  31. package/dist/httpsnippet/src/targets/javascript/xhr/client.js +49 -0
  32. package/dist/httpsnippet/src/targets/json/native/client.js +39 -0
  33. package/dist/httpsnippet/src/targets/json/target.js +14 -0
  34. package/dist/httpsnippet/src/targets/kotlin/okhttp/client.js +23 -0
  35. package/dist/httpsnippet/src/targets/kotlin/target.js +14 -0
  36. package/dist/httpsnippet/src/targets/node/axios/client.js +40 -0
  37. package/dist/httpsnippet/src/targets/node/fetch/client.js +68 -0
  38. package/dist/httpsnippet/src/targets/node/native/client.js +45 -0
  39. package/dist/httpsnippet/src/targets/node/target.js +19 -0
  40. package/dist/httpsnippet/src/targets/objc/helpers.js +27 -0
  41. package/dist/httpsnippet/src/targets/objc/nsurlsession/client.js +63 -0
  42. package/dist/httpsnippet/src/targets/objc/target.js +14 -0
  43. package/dist/httpsnippet/src/targets/ocaml/cohttp/client.js +32 -0
  44. package/dist/httpsnippet/src/targets/ocaml/target.js +14 -0
  45. package/dist/httpsnippet/src/targets/php/curl/client.js +85 -0
  46. package/dist/httpsnippet/src/targets/php/guzzle/client.js +57 -0
  47. package/dist/httpsnippet/src/targets/php/helpers.js +65 -0
  48. package/dist/httpsnippet/src/targets/php/http1/client.js +28 -0
  49. package/dist/httpsnippet/src/targets/php/http2/client.js +55 -0
  50. package/dist/httpsnippet/src/targets/php/target.js +21 -0
  51. package/dist/httpsnippet/src/targets/powershell/common.js +19 -0
  52. package/dist/httpsnippet/src/targets/powershell/restmethod/client.js +14 -0
  53. package/dist/httpsnippet/src/targets/powershell/target.js +16 -0
  54. package/dist/httpsnippet/src/targets/powershell/webrequest/client.js +14 -0
  55. package/dist/httpsnippet/src/targets/python/helpers.js +33 -0
  56. package/dist/httpsnippet/src/targets/python/requests/client.js +74 -0
  57. package/dist/httpsnippet/src/targets/python/target.js +15 -0
  58. package/dist/httpsnippet/src/targets/r/httr/client.js +46 -0
  59. package/dist/httpsnippet/src/targets/r/target.js +14 -0
  60. package/dist/httpsnippet/src/targets/ruby/native/client.js +37 -0
  61. package/dist/httpsnippet/src/targets/ruby/target.js +14 -0
  62. package/dist/httpsnippet/src/targets/shell/curl/client.js +92 -0
  63. package/dist/httpsnippet/src/targets/shell/httpie/client.js +56 -0
  64. package/dist/httpsnippet/src/targets/shell/target.js +19 -0
  65. package/dist/httpsnippet/src/targets/shell/wget/client.js +30 -0
  66. package/dist/httpsnippet/src/targets/swift/helpers.js +38 -0
  67. package/dist/httpsnippet/src/targets/swift/target.js +14 -0
  68. package/dist/httpsnippet/src/targets/swift/urlsession/client.js +59 -0
  69. package/package.json +17 -4
@@ -1,4 +1,4 @@
1
- import { HTTPSnippet as U } from "@readme/httpsnippet";
1
+ import { HTTPSnippet as U } from "../../httpsnippet/src/index.js";
2
2
  import { generateUniqueString as x } from "../../utils/uuid.js";
3
3
  import { snippetPresets as R } from "../../constants/snippetPresets.js";
4
4
  const N = ({
@@ -0,0 +1,27 @@
1
+ const n = "", e = `
2
+ `;
3
+ class d {
4
+ /**
5
+ * Helper object to format and aggragate lines of code.
6
+ * Lines are aggregated in a `code` array, and need to be joined to obtain a proper code snippet.
7
+ */
8
+ constructor({ indent: o, join: h } = {}) {
9
+ this.postProcessors = [], this.code = [], this.indentationCharacter = n, this.lineJoin = e, this.indentLine = (t, s = 0) => `${this.indentationCharacter.repeat(s)}${t}`, this.unshift = (t, s) => {
10
+ const i = this.indentLine(t, s);
11
+ this.code.unshift(i);
12
+ }, this.push = (t, s) => {
13
+ const i = this.indentLine(t, s);
14
+ this.code.push(i);
15
+ }, this.blank = () => {
16
+ this.code.push("");
17
+ }, this.join = () => {
18
+ const t = this.code.join(this.lineJoin);
19
+ return this.postProcessors.reduce((i, r) => r(i), t);
20
+ }, this.addPostProcessor = (t) => {
21
+ this.postProcessors = [...this.postProcessors, t];
22
+ }, this.indentationCharacter = o || n, this.lineJoin = h ?? e;
23
+ }
24
+ }
25
+ export {
26
+ d as CodeBuilder
27
+ };
@@ -0,0 +1,11 @@
1
+ function s(t, u = {}) {
2
+ const { delimiter: n = '"', escapeChar: r = "\\", escapeNewlines: i = !0 } = u;
3
+ return [...t.toString()].map((e) => e === "\b" ? `${r}b` : e === " " ? `${r}t` : e === `
4
+ ` ? i ? `${r}n` : e : e === "\f" ? `${r}f` : e === "\r" ? i ? `${r}r` : e : e === r ? r + r : e === n ? r + n : e < " " || e > "~" ? JSON.stringify(e).slice(1, -1) : e).join("");
5
+ }
6
+ const f = (t) => s(t, { delimiter: "'" }), o = (t) => s(t, { delimiter: '"' });
7
+ export {
8
+ o as escapeForDoubleQuotes,
9
+ f as escapeForSingleQuotes,
10
+ s as escapeString
11
+ };
@@ -0,0 +1,13 @@
1
+ const n = (e, o) => Object.keys(e).find((t) => t.toLowerCase() === o.toLowerCase()), s = (e, o) => {
2
+ const t = n(e, o);
3
+ if (t)
4
+ return e[t];
5
+ }, a = (e, o) => !!n(e, o), i = (e) => ["application/json", "application/x-json", "text/json", "text/x-json", "+json"].some(
6
+ (o) => e.indexOf(o) > -1
7
+ );
8
+ export {
9
+ s as getHeader,
10
+ n as getHeaderName,
11
+ a as hasHeader,
12
+ i as isMimeTypeJSON
13
+ };
@@ -0,0 +1,7 @@
1
+ const s = (e, n) => {
2
+ const r = e[n.name];
3
+ return r === void 0 ? (e[n.name] = n.value, e) : Array.isArray(r) ? (r.push(n.value), e) : (e[n.name] = [r, n.value], e);
4
+ };
5
+ export {
6
+ s as reducer
7
+ };
@@ -0,0 +1,5 @@
1
+ const t = (e = "") => /^[a-z0-9-_/.@%^=:]+$/i.test(e) ? e : `'${e.replace(/'/g, "'\\''")}'`, c = (e) => e.replace(/\r/g, "\\r").replace(/\n/g, "\\n");
2
+ export {
3
+ c as escape,
4
+ t as quote
5
+ };
@@ -0,0 +1,35 @@
1
+ function i(t) {
2
+ if (!t)
3
+ return "";
4
+ if (t.href && !t.protocol && !t.host && !t.hostname)
5
+ return t.href;
6
+ let e = "";
7
+ if (t.protocol && (e += t.protocol, t.protocol.endsWith(":") || (e += ":")), (t.slashes || t.protocol && (t.host || t.hostname)) && (e += "//"), t.auth) {
8
+ const h = t.auth.split(":").map((a, o) => o === 0 ? a : a.replace(/@/g, "%40")).join(":");
9
+ e += `${h}@`;
10
+ }
11
+ if (t.host ? e += t.host : t.hostname && (e += t.hostname, t.port && (e += `:${t.port}`)), t.pathname) {
12
+ const s = t.pathname.startsWith("/") ? t.pathname : `/${t.pathname}`;
13
+ e += s;
14
+ }
15
+ if (t.search)
16
+ e += t.search.startsWith("?") ? t.search : `?${t.search}`;
17
+ else if (t.query)
18
+ if (typeof t.query == "string")
19
+ e += t.query.startsWith("?") ? t.query : `?${t.query}`;
20
+ else {
21
+ const s = new URLSearchParams();
22
+ for (const [a, o] of Object.entries(t.query))
23
+ if (Array.isArray(o))
24
+ for (const n of o)
25
+ s.append(a, n);
26
+ else
27
+ s.append(a, o);
28
+ const h = s.toString();
29
+ h && (e += `?${h}`);
30
+ }
31
+ return t.hash && (e += t.hash.startsWith("#") ? t.hash : `#${t.hash}`), e;
32
+ }
33
+ export {
34
+ i as format
35
+ };
@@ -0,0 +1,76 @@
1
+ function z(l, f = !1, $ = !1) {
2
+ let c = l;
3
+ $ && !l.match(/^[a-z][a-z0-9+.-]*:/i) && (c = `http://${l}`);
4
+ let e;
5
+ try {
6
+ e = new URL(c);
7
+ } catch {
8
+ try {
9
+ e = new URL(c, "http://example.com");
10
+ } catch {
11
+ return {
12
+ auth: null,
13
+ hash: null,
14
+ host: null,
15
+ hostname: null,
16
+ href: l,
17
+ path: null,
18
+ pathname: null,
19
+ protocol: null,
20
+ search: null,
21
+ slashes: null,
22
+ query: f ? {} : "",
23
+ port: null
24
+ };
25
+ }
26
+ }
27
+ const y = e.username || e.password ? `${decodeURIComponent(e.username)}${e.password ? `:${decodeURIComponent(e.password)}` : ""}` : null;
28
+ let s = e.hostname || null;
29
+ s && s.startsWith("[") && s.endsWith("]") && (s = s.slice(1, -1));
30
+ let t = e.port || null;
31
+ const d = l.match(/:(\d+)(?:\/|$|\?|#)/);
32
+ !t && d && (t = d[1]);
33
+ let i = null;
34
+ if (s) {
35
+ const a = s.includes(":");
36
+ t ? i = a ? `[${s}]:${t}` : `${s}:${t}` : i = s;
37
+ }
38
+ const n = l.includes("?") && !e.search ? "?" : e.search || null, w = l.includes("#") && !e.hash ? "#" : e.hash || null;
39
+ let h = null;
40
+ try {
41
+ const a = c.match(/^[a-z][a-z0-9+.-]*:\/\/[^/]+(\/[^?#]*)/i);
42
+ a && a[1] ? h = a[1] : h = e.pathname || null;
43
+ } catch {
44
+ h = e.pathname || null;
45
+ }
46
+ const U = n ? `${h}${n}` : h;
47
+ let u;
48
+ if (f && n) {
49
+ const a = new URLSearchParams(n), o = {};
50
+ for (const [r, p] of a.entries())
51
+ if (r in o) {
52
+ const m = o[r];
53
+ Array.isArray(m) ? m.push(p) : o[r] = [m, p];
54
+ } else
55
+ o[r] = p;
56
+ u = o;
57
+ } else
58
+ u = n ? n.slice(1) : "";
59
+ return {
60
+ auth: y,
61
+ hash: w,
62
+ host: i,
63
+ hostname: s,
64
+ href: e.href,
65
+ path: U,
66
+ pathname: h,
67
+ protocol: e.protocol || null,
68
+ search: n,
69
+ slashes: e.protocol ? !0 : null,
70
+ query: u,
71
+ port: t
72
+ };
73
+ }
74
+ export {
75
+ z as parse
76
+ };
@@ -0,0 +1,157 @@
1
+ import { stringify as f } from "qs";
2
+ import { getHeaderName as w } from "./helpers/headers.js";
3
+ import { reducer as T } from "./helpers/reducer.js";
4
+ import { targets as x } from "./targets/index.js";
5
+ import { parse as E } from "./helpers/url-parse.js";
6
+ import { format as $ } from "./helpers/url-format.js";
7
+ const N = (m) => typeof m == "object" && "log" in m && typeof m.log == "object" && "entries" in m.log && Array.isArray(m.log.entries);
8
+ class V {
9
+ constructor(a, t = {}) {
10
+ this.initCalled = !1, this.entries = [], this.requests = [], this.options = {}, this.options = {
11
+ harIsAlreadyEncoded: !1,
12
+ ...t
13
+ }, this.requests = [], N(a) ? this.entries = a.log.entries : this.entries = [
14
+ {
15
+ request: a
16
+ }
17
+ ];
18
+ }
19
+ init() {
20
+ return this.initCalled = !0, this.requests = this.entries.map(({ request: a }) => {
21
+ var e;
22
+ const t = {
23
+ bodySize: 0,
24
+ headersSize: 0,
25
+ headers: [],
26
+ cookies: [],
27
+ httpVersion: "HTTP/1.1",
28
+ queryString: [],
29
+ postData: {
30
+ mimeType: ((e = a.postData) == null ? void 0 : e.mimeType) || "application/octet-stream"
31
+ },
32
+ ...a
33
+ };
34
+ return t.postData && !t.postData.mimeType && (t.postData.mimeType = "application/octet-stream"), this.prepare(t, this.options);
35
+ }), this;
36
+ }
37
+ prepare(a, t) {
38
+ var j, b, D;
39
+ const e = {
40
+ ...a,
41
+ fullUrl: "",
42
+ uriObj: {},
43
+ queryObj: {},
44
+ headersObj: {},
45
+ cookiesObj: {},
46
+ allHeaders: {}
47
+ };
48
+ if (e != null && e.queryString.length && (e.queryObj = e.queryString.reduce(T, {})), e != null && e.headers.length) {
49
+ const r = /^HTTP\/2/;
50
+ e.headersObj = e.headers.reduce((p, { name: u, value: d }) => {
51
+ const h = r.exec(e.httpVersion) ? u.toLocaleLowerCase() : u;
52
+ return {
53
+ ...p,
54
+ [h]: d
55
+ };
56
+ }, {});
57
+ }
58
+ e != null && e.cookies.length && (e.cookiesObj = e.cookies.reduceRight(
59
+ (r, { name: p, value: u }) => ({
60
+ ...r,
61
+ [p]: u
62
+ }),
63
+ {}
64
+ ));
65
+ const s = (j = e.cookies) == null ? void 0 : j.map(({ name: r, value: p }) => t.harIsAlreadyEncoded ? `${r}=${p}` : `${encodeURIComponent(r)}=${encodeURIComponent(p)}`);
66
+ switch (s != null && s.length && (e.allHeaders.cookie = s.join("; ")), e.postData.mimeType) {
67
+ case "multipart/mixed":
68
+ case "multipart/related":
69
+ case "multipart/form-data":
70
+ case "multipart/alternative":
71
+ if (e.postData.text = "", e.postData.mimeType = "multipart/form-data", (b = e.postData) != null && b.params) {
72
+ const r = "---011000010111000001101001", p = `${r}--`, u = `\r
73
+ `;
74
+ /*! formdata-polyfill. MIT License. Jimmy Wärting <https://jimmy.warting.se/opensource> */
75
+ const d = (l) => l.replace(/\n/g, "%0A").replace(/\r/g, "%0D").replace(/"/g, "%22"), h = (l) => l.replace(/\r?\n|\r/g, `\r
76
+ `), c = [`--${r}`];
77
+ (D = e.postData) == null || D.params.forEach((l, k) => {
78
+ const g = l.name, S = l.value || "", O = l.fileName || null, A = l.contentType || "application/octet-stream";
79
+ O ? (c.push(
80
+ `Content-Disposition: form-data; name="${d(h(g))}"; filename="${O}"`
81
+ ), c.push(`Content-Type: ${A}`)) : c.push(`Content-Disposition: form-data; name="${escape(h(g))}"`), c.push(""), c.push(h(S)), k !== e.postData.params.length - 1 && c.push(`--${r}`);
82
+ }), c.push(`--${p}`), e.postData.boundary = r, e.postData.text = c.join(u);
83
+ const H = w(e.headersObj, "content-type") || "content-type";
84
+ e.headersObj[H] = `multipart/form-data; boundary=${r}`;
85
+ }
86
+ break;
87
+ case "application/x-www-form-urlencoded":
88
+ e.postData.params ? (e.postData.paramsObj = e.postData.params.reduce(T, {}), e.postData.text = f(e.postData.paramsObj)) : e.postData.text = "";
89
+ break;
90
+ case "text/json":
91
+ case "text/x-json":
92
+ case "application/json":
93
+ case "application/x-json":
94
+ if (e.postData.mimeType = "application/json", e.postData.text)
95
+ try {
96
+ e.postData.jsonObj = JSON.parse(e.postData.text);
97
+ } catch {
98
+ e.postData.mimeType = "text/plain";
99
+ }
100
+ break;
101
+ }
102
+ const i = {
103
+ ...e.allHeaders,
104
+ ...e.headersObj
105
+ }, n = E(e.url, !0, !0);
106
+ e.queryObj = {
107
+ ...e.queryObj,
108
+ ...n.query
109
+ };
110
+ let o;
111
+ t.harIsAlreadyEncoded ? o = f(e.queryObj, {
112
+ encode: !1,
113
+ indices: !1
114
+ }) : o = f(e.queryObj, {
115
+ indices: !1
116
+ });
117
+ const y = {
118
+ ...n,
119
+ query: e.queryObj,
120
+ search: o,
121
+ path: o ? `${n.pathname}?${o}` : n.pathname
122
+ }, q = $({
123
+ ...n,
124
+ query: null,
125
+ search: null
126
+ }), C = $({
127
+ ...n,
128
+ ...y
129
+ });
130
+ return {
131
+ ...e,
132
+ allHeaders: i,
133
+ fullUrl: C,
134
+ url: q,
135
+ uriObj: y
136
+ };
137
+ }
138
+ convert(a, t, e) {
139
+ this.initCalled || this.init(), !e && t && (e = { clientId: t });
140
+ const s = x[a];
141
+ if (!s)
142
+ return [!1];
143
+ const { convert: i } = s.clientsById[t || s.info.default];
144
+ return this.requests.map((o) => i(o, e));
145
+ }
146
+ installation(a, t, e) {
147
+ this.initCalled || this.init(), !e && t && (e = { clientId: t });
148
+ const s = x[a];
149
+ if (!s)
150
+ return [!1];
151
+ const { info: i } = s.clientsById[t || s.info.default];
152
+ return this.requests.map((o) => i != null && i.installation ? i.installation(o, e) : !1);
153
+ }
154
+ }
155
+ export {
156
+ V as HTTPSnippet
157
+ };
@@ -0,0 +1,22 @@
1
+ import { CodeBuilder as u } from "../../../helpers/code-builder.js";
2
+ import { escapeForDoubleQuotes as p } from "../../../helpers/escape.js";
3
+ const T = {
4
+ info: {
5
+ key: "libcurl",
6
+ title: "Libcurl",
7
+ link: "http://curl.haxx.se/libcurl",
8
+ description: "Simple REST and HTTP API Client for C",
9
+ extname: ".c"
10
+ },
11
+ convert: ({ method: l, fullUrl: n, headersObj: r, allHeaders: s, postData: o }) => {
12
+ const { push: e, blank: t, join: _ } = new u();
13
+ e("CURL *hnd = curl_easy_init();"), t(), e(`curl_easy_setopt(hnd, CURLOPT_CUSTOMREQUEST, "${l.toUpperCase()}");`), e("curl_easy_setopt(hnd, CURLOPT_WRITEDATA, stdout);"), e(`curl_easy_setopt(hnd, CURLOPT_URL, "${n}");`);
14
+ const c = Object.keys(r);
15
+ return c.length && (t(), e("struct curl_slist *headers = NULL;"), c.forEach((i) => {
16
+ e(`headers = curl_slist_append(headers, "${i}: ${p(r[i])}");`);
17
+ }), e("curl_easy_setopt(hnd, CURLOPT_HTTPHEADER, headers);")), s.cookie && (t(), e(`curl_easy_setopt(hnd, CURLOPT_COOKIE, "${s.cookie}");`)), o.text && (t(), e(`curl_easy_setopt(hnd, CURLOPT_POSTFIELDS, ${JSON.stringify(o.text)});`)), t(), e("CURLcode ret = curl_easy_perform(hnd);"), _();
18
+ }
19
+ };
20
+ export {
21
+ T as libcurl
22
+ };
@@ -0,0 +1,15 @@
1
+ import { libcurl as c } from "./libcurl/client.js";
2
+ const i = {
3
+ info: {
4
+ key: "c",
5
+ title: "C",
6
+ default: "libcurl",
7
+ cli: "c"
8
+ },
9
+ clientsById: {
10
+ libcurl: c
11
+ }
12
+ };
13
+ export {
14
+ i as c
15
+ };
@@ -0,0 +1,120 @@
1
+ import { CodeBuilder as b } from "../../../helpers/code-builder.js";
2
+ import { getHeaderName as o, getHeader as y } from "../../../helpers/headers.js";
3
+ class m {
4
+ constructor(t) {
5
+ this.name = "", this.toString = () => `:${this.name}`, this.name = t;
6
+ }
7
+ }
8
+ class w {
9
+ constructor(t) {
10
+ this.path = "", this.toString = () => `(clojure.java.io/file "${this.path}")`, this.path = t;
11
+ }
12
+ }
13
+ const g = (e) => e === void 0 ? null : e === null ? "null" : e.constructor.name.toLowerCase(), j = (e) => e === void 0 ? !0 : g(e) === "object" ? Object.keys(e).length === 0 : !1, f = (e) => (Object.keys(e).filter((t) => j(e[t])).forEach((t) => {
14
+ delete e[t];
15
+ }), e), l = (e, t) => {
16
+ const c = " ".repeat(e);
17
+ return t.replace(/\n/g, `
18
+ ${c}`);
19
+ }, p = (e) => {
20
+ switch (g(e)) {
21
+ case "string":
22
+ return `"${e.replace(/"/g, '\\"')}"`;
23
+ case "file":
24
+ return e.toString();
25
+ case "keyword":
26
+ return e.toString();
27
+ case "null":
28
+ return "nil";
29
+ case "regexp":
30
+ return `#"${e.source}"`;
31
+ case "object": {
32
+ const t = Object.keys(e).reduce((c, a) => {
33
+ const d = l(a.length + 2, p(e[a]));
34
+ return `${c}:${a} ${d}
35
+ `;
36
+ }, "").trim();
37
+ return `{${l(1, t)}}`;
38
+ }
39
+ case "array": {
40
+ const t = e.reduce((c, a) => `${c} ${p(a)}`, "").trim();
41
+ return `[${l(1, t)}]`;
42
+ }
43
+ default:
44
+ return e.toString();
45
+ }
46
+ }, x = {
47
+ info: {
48
+ key: "clj_http",
49
+ title: "clj-http",
50
+ link: "https://github.com/dakrone/clj-http",
51
+ description: "An idiomatic clojure http client wrapping the apache client.",
52
+ extname: ".clj"
53
+ },
54
+ convert: ({ queryObj: e, method: t, postData: c, url: a, allHeaders: d }, h) => {
55
+ const { push: i, join: u } = new b({ indent: h == null ? void 0 : h.indent }), $ = ["get", "post", "put", "delete", "patch", "head", "options"];
56
+ if (t = t.toLowerCase(), !$.includes(t))
57
+ return i("Method not supported"), u();
58
+ const r = {
59
+ headers: d,
60
+ "query-params": e
61
+ };
62
+ switch (c.mimeType) {
63
+ case "application/json":
64
+ {
65
+ r["content-type"] = new m("json"), r["form-params"] = c.jsonObj;
66
+ const n = o(r.headers, "content-type");
67
+ n && delete r.headers[n];
68
+ }
69
+ break;
70
+ case "application/x-www-form-urlencoded":
71
+ {
72
+ r["form-params"] = c.paramsObj;
73
+ const n = o(r.headers, "content-type");
74
+ n && delete r.headers[n];
75
+ }
76
+ break;
77
+ case "text/plain":
78
+ {
79
+ r.body = c.text;
80
+ const n = o(r.headers, "content-type");
81
+ n && delete r.headers[n];
82
+ }
83
+ break;
84
+ case "multipart/form-data": {
85
+ if (c.params) {
86
+ r.multipart = c.params.map((s) => s.fileName && !s.value ? {
87
+ name: s.name,
88
+ content: new w(s.fileName)
89
+ } : {
90
+ name: s.name,
91
+ content: s.value
92
+ });
93
+ const n = o(r.headers, "content-type");
94
+ n && delete r.headers[n];
95
+ }
96
+ break;
97
+ }
98
+ }
99
+ switch (y(r.headers, "accept")) {
100
+ case "application/json":
101
+ {
102
+ r.accept = new m("json");
103
+ const n = o(r.headers, "accept");
104
+ n && delete r.headers[n];
105
+ }
106
+ break;
107
+ }
108
+ if (i(`(require '[clj-http.client :as client])
109
+ `), j(f(r)))
110
+ i(`(client/${t} "${a}")`);
111
+ else {
112
+ const n = 11 + t.length + a.length, s = l(n, p(f(r)));
113
+ i(`(client/${t} "${a}" ${s})`);
114
+ }
115
+ return u();
116
+ }
117
+ };
118
+ export {
119
+ x as clj_http
120
+ };
@@ -0,0 +1,14 @@
1
+ import { clj_http as t } from "./clj_http/client.js";
2
+ const l = {
3
+ info: {
4
+ key: "clojure",
5
+ title: "Clojure",
6
+ default: "clj_http"
7
+ },
8
+ clientsById: {
9
+ clj_http: t
10
+ }
11
+ };
12
+ export {
13
+ l as clojure
14
+ };
@@ -0,0 +1,76 @@
1
+ import { CodeBuilder as g } from "../../../helpers/code-builder.js";
2
+ import { escapeForDoubleQuotes as m } from "../../../helpers/escape.js";
3
+ import { getHeader as y } from "../../../helpers/headers.js";
4
+ const H = (i) => {
5
+ let n = y(i, "accept-encoding");
6
+ if (!n)
7
+ return [];
8
+ const t = {
9
+ gzip: "DecompressionMethods.GZip",
10
+ deflate: "DecompressionMethods.Deflate"
11
+ }, r = [];
12
+ return typeof n == "string" && (n = [n]), n.forEach((a) => {
13
+ a.split(",").forEach((p) => {
14
+ const e = /\s*([^;\s]+)/.exec(p);
15
+ if (e) {
16
+ const c = t[e[1]];
17
+ c && r.push(c);
18
+ }
19
+ });
20
+ }), r;
21
+ }, M = {
22
+ info: {
23
+ key: "httpclient",
24
+ title: "HttpClient",
25
+ link: "https://docs.microsoft.com/en-us/dotnet/api/system.net.http.httpclient",
26
+ description: ".NET Standard HTTP Client",
27
+ extname: ".cs"
28
+ },
29
+ convert: ({ allHeaders: i, postData: n, method: t, fullUrl: r }, a) => {
30
+ var C, h;
31
+ const p = {
32
+ indent: " ",
33
+ ...a
34
+ }, { push: e, join: c } = new g({ indent: p.indent });
35
+ e("using System.Net.Http.Headers;");
36
+ let d = "";
37
+ const f = !!i.cookie, l = H(i);
38
+ (f || l.length) && (d = "clientHandler", e("var clientHandler = new HttpClientHandler"), e("{"), f && e("UseCookies = false,", 1), l.length && e(`AutomaticDecompression = ${l.join(" | ")},`, 1), e("};")), e(`var client = new HttpClient(${d});`), e("var request = new HttpRequestMessage"), e("{");
39
+ const w = ["GET", "POST", "PUT", "DELETE", "PATCH", "HEAD", "OPTIONS", "TRACE"];
40
+ t = t.toUpperCase(), t && w.includes(t) ? t = `HttpMethod.${t[0]}${t.substring(1).toLowerCase()}` : t = `new HttpMethod("${t}")`, e(`Method = ${t},`, 1), e(`RequestUri = new Uri("${r}"),`, 1);
41
+ const u = Object.keys(i).filter((s) => {
42
+ switch (s.toLowerCase()) {
43
+ case "content-type":
44
+ case "content-length":
45
+ case "accept-encoding":
46
+ return !1;
47
+ default:
48
+ return !0;
49
+ }
50
+ });
51
+ if (u.length && (e("Headers =", 1), e("{", 1), u.forEach((s) => {
52
+ e(`{ "${s}", "${m(i[s])}" },`, 2);
53
+ }), e("},", 1)), n.text) {
54
+ const s = n.mimeType;
55
+ switch (s) {
56
+ case "application/x-www-form-urlencoded":
57
+ e("Content = new FormUrlEncodedContent(new Dictionary<string, string>", 1), e("{", 1), (C = n.params) == null || C.forEach((o) => {
58
+ e(`{ "${o.name}", "${o.value}" },`, 2);
59
+ }), e("}),", 1);
60
+ break;
61
+ case "multipart/form-data":
62
+ e("Content = new MultipartFormDataContent", 1), e("{", 1), (h = n.params) == null || h.forEach((o) => {
63
+ e(`new StringContent(${JSON.stringify(o.value || "")})`, 2), e("{", 2), e("Headers =", 3), e("{", 3), o.contentType && e(`ContentType = new MediaTypeHeaderValue("${o.contentType}"),`, 4), e('ContentDisposition = new ContentDispositionHeaderValue("form-data")', 4), e("{", 4), e(`Name = "${o.name}",`, 5), o.fileName && e(`FileName = "${o.fileName}",`, 5), e("}", 4), e("}", 3), e("},", 2);
64
+ }), e("},", 1);
65
+ break;
66
+ default:
67
+ e(`Content = new StringContent(${JSON.stringify(n.text || "")})`, 1), e("{", 1), e("Headers =", 2), e("{", 2), e(`ContentType = new MediaTypeHeaderValue("${s}")`, 3), e("}", 2), e("}", 1);
68
+ break;
69
+ }
70
+ }
71
+ return e("};"), e("using (var response = await client.SendAsync(request))"), e("{"), e("response.EnsureSuccessStatusCode();", 1), e("var body = await response.Content.ReadAsStringAsync();", 1), e("Console.WriteLine(body);", 1), e("}"), c();
72
+ }
73
+ };
74
+ export {
75
+ M as httpclient
76
+ };
@@ -0,0 +1,63 @@
1
+ import { CodeBuilder as m } from "../../../helpers/code-builder.js";
2
+ import { escapeForDoubleQuotes as a } from "../../../helpers/escape.js";
3
+ function p(n) {
4
+ return n[0].toUpperCase() + n.slice(1).toLowerCase();
5
+ }
6
+ const T = {
7
+ info: {
8
+ key: "restsharp",
9
+ title: "RestSharp",
10
+ link: "http://restsharp.org/",
11
+ description: "Simple REST and HTTP API Client for .NET",
12
+ extname: ".cs",
13
+ installation: () => "dotnet add package RestSharp"
14
+ },
15
+ convert: ({ method: n, fullUrl: d, headersObj: i, cookies: u, postData: e, uriObj: s }) => {
16
+ const { push: t, join: l } = new m();
17
+ if (!["GET", "POST", "PUT", "DELETE", "PATCH", "HEAD", "OPTIONS"].includes(
18
+ n.toUpperCase()
19
+ ))
20
+ return "Method not supported";
21
+ t(`using RestSharp;
22
+
23
+ `), t(`var options = new RestClientOptions("${d}");`), t("var client = new RestClient(options);"), t('var request = new RestRequest("");');
24
+ const o = e.mimeType && e.mimeType === "multipart/form-data";
25
+ switch (o && t("request.AlwaysMultipartFormData = true;"), Object.keys(i).forEach((r) => {
26
+ if (e.mimeType && r.toLowerCase() === "content-type" && e.text) {
27
+ o && e.boundary && t(`request.FormBoundary = "${e.boundary}";`);
28
+ return;
29
+ }
30
+ t(`request.AddHeader("${r}", "${a(i[r])}");`);
31
+ }), u.forEach(({ name: r, value: c }) => {
32
+ t(`request.AddCookie("${r}", "${a(c)}", "${s.pathname}", "${s.host}");`);
33
+ }), e.mimeType) {
34
+ case "multipart/form-data":
35
+ if (!e.params) break;
36
+ e.params.forEach((r) => {
37
+ r.fileName ? t(`request.AddFile("${r.name}", "${r.fileName}");`) : t(`request.AddParameter("${r.name}", "${r.value}");`);
38
+ });
39
+ break;
40
+ case "application/x-www-form-urlencoded":
41
+ if (!e.params) break;
42
+ e.params.forEach((r) => {
43
+ t(`request.AddParameter("${r.name}", "${r.value}");`);
44
+ });
45
+ break;
46
+ case "application/json": {
47
+ if (!e.text) break;
48
+ const r = JSON.stringify(e.text);
49
+ t(`request.AddJsonBody(${r}, false);`);
50
+ break;
51
+ }
52
+ default:
53
+ if (!e.text) break;
54
+ t(`request.AddStringBody("${e.text}", "${e.mimeType}");`);
55
+ }
56
+ return t(`var response = await client.${p(n)}Async(request);
57
+ `), t(`Console.WriteLine("{0}", response.Content);
58
+ `), l();
59
+ }
60
+ };
61
+ export {
62
+ T as restsharp
63
+ };
@@ -0,0 +1,17 @@
1
+ import { httpclient as t } from "./httpclient/client.js";
2
+ import { restsharp as r } from "./restsharp/client.js";
3
+ const p = {
4
+ info: {
5
+ key: "csharp",
6
+ title: "C#",
7
+ default: "restsharp",
8
+ cli: "dotnet"
9
+ },
10
+ clientsById: {
11
+ httpclient: t,
12
+ restsharp: r
13
+ }
14
+ };
15
+ export {
16
+ p as csharp
17
+ };