@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
@@ -0,0 +1,14 @@
1
+ import { generatePowershellConvert as e } from "../common.js";
2
+ const t = {
3
+ info: {
4
+ key: "webrequest",
5
+ title: "Invoke-WebRequest",
6
+ link: "https://docs.microsoft.com/en-us/powershell/module/Microsoft.PowerShell.Utility/Invoke-WebRequest",
7
+ description: "Powershell Invoke-WebRequest client",
8
+ extname: ".ps1"
9
+ },
10
+ convert: e("Invoke-WebRequest")
11
+ };
12
+ export {
13
+ t as webrequest
14
+ };
@@ -0,0 +1,33 @@
1
+ function i(t, r, e, c, o) {
2
+ const n = c.repeat(o), $ = c.repeat(o - 1), j = e ? `,
3
+ ${n}` : ", ", s = t === "object" ? "{" : "[", b = t === "object" ? "}" : "]";
4
+ return e ? `${s}
5
+ ${n}${r.join(j)}
6
+ ${$}${b}` : t === "object" && r.length > 0 ? `${s} ${r.join(j)} ${b}` : `${s}${r.join(j)}${b}`;
7
+ }
8
+ const a = (t, r, e) => {
9
+ switch (e = e === void 0 ? 1 : e + 1, Object.prototype.toString.call(t)) {
10
+ case "[object Number]":
11
+ return t;
12
+ case "[object Array]": {
13
+ let c = !1;
14
+ const o = t.map((n) => (Object.prototype.toString.call(n) === "[object Object]" && (c = Object.keys(n).length > 1), a(n, r, e)));
15
+ return i("array", o, c, r.indent, e);
16
+ }
17
+ case "[object Object]": {
18
+ const c = [];
19
+ for (const o in t)
20
+ c.push(`"${o}": ${a(t[o], r, e)}`);
21
+ return i("object", c, r.pretty && c.length > 1, r.indent, e);
22
+ }
23
+ case "[object Null]":
24
+ return "None";
25
+ case "[object Boolean]":
26
+ return t ? "True" : "False";
27
+ default:
28
+ return t == null ? "" : `"${t.toString().replace(/"/g, '\\"')}"`;
29
+ }
30
+ };
31
+ export {
32
+ a as literalRepresentation
33
+ };
@@ -0,0 +1,74 @@
1
+ import { CodeBuilder as T } from "../../../helpers/code-builder.js";
2
+ import { escapeForDoubleQuotes as y } from "../../../helpers/escape.js";
3
+ import { getHeaderName as P } from "../../../helpers/headers.js";
4
+ import { literalRepresentation as c } from "../helpers.js";
5
+ const k = ["HEAD", "GET", "POST", "PUT", "PATCH", "DELETE", "OPTIONS"], x = {
6
+ info: {
7
+ key: "requests",
8
+ title: "Requests",
9
+ link: "http://docs.python-requests.org/en/latest/api/#requests.request",
10
+ description: "Requests HTTP library",
11
+ extname: ".py",
12
+ installation: () => "python -m pip install requests"
13
+ },
14
+ convert: ({ fullUrl: b, postData: t, allHeaders: h, method: p }, j) => {
15
+ const i = {
16
+ indent: " ",
17
+ pretty: !0,
18
+ ...j
19
+ }, { push: s, blank: o, join: q, addPostProcessor: O } = new T({ indent: i.indent });
20
+ s("import requests"), o(), s(`url = "${b}"`), o();
21
+ const r = h;
22
+ let d = {};
23
+ const m = {};
24
+ let f = !1, n = !1, $ = !1;
25
+ switch (t.mimeType) {
26
+ case "application/json":
27
+ t.jsonObj && (s(`payload = ${c(t.jsonObj, i)}`), $ = !0, n = !0);
28
+ break;
29
+ case "multipart/form-data":
30
+ if (!t.params)
31
+ break;
32
+ if (d = {}, t.params.forEach((e) => {
33
+ e.fileName ? (e.contentType ? m[e.name] = `('${e.fileName}', open('${e.fileName}', 'rb'), '${e.contentType}')` : m[e.name] = `('${e.fileName}', open('${e.fileName}', 'rb'))`, f = !0) : (d[e.name] = e.value, n = !0);
34
+ }), f) {
35
+ s(`files = ${c(m, i)}`), n && s(`payload = ${c(d, i)}`);
36
+ const e = P(r, "content-type");
37
+ e && delete r[e];
38
+ } else {
39
+ const e = JSON.stringify(t.text);
40
+ e && (s(`payload = ${e}`), n = !0);
41
+ }
42
+ O(
43
+ (e) => e.replace(/"\('(.+)', open\('(.+)', 'rb'\)\)"/g, '("$1", open("$2", "rb"))').replace(/"\('(.+)', open\('(.+)', 'rb'\), '(.+)'\)"/g, '("$1", open("$2", "rb"), "$3")')
44
+ );
45
+ break;
46
+ default: {
47
+ if (t.mimeType === "application/x-www-form-urlencoded" && t.paramsObj) {
48
+ s(`payload = ${c(t.paramsObj, i)}`), n = !0;
49
+ break;
50
+ }
51
+ const e = JSON.stringify(t.text);
52
+ e && (s(`payload = ${e}`), n = !0);
53
+ }
54
+ }
55
+ const l = Object.keys(r).length;
56
+ if (l === 0 && (n || f))
57
+ o();
58
+ else if (l === 1)
59
+ Object.keys(r).forEach((e) => {
60
+ s(`headers = {"${e}": "${y(r[e])}"}`), o();
61
+ });
62
+ else if (l > 1) {
63
+ let e = 1;
64
+ s("headers = {"), Object.keys(r).forEach((u) => {
65
+ s(e !== l ? `"${u}": "${y(r[u])}",` : `"${u}": "${y(r[u])}"`, 1), e += 1;
66
+ }), s("}"), o();
67
+ }
68
+ let a = k.includes(p) ? `response = requests.${p.toLowerCase()}(url` : `response = requests.request("${p}", url`;
69
+ return n && ($ ? a += ", json=payload" : a += ", data=payload"), f && (a += ", files=files"), l > 0 && (a += ", headers=headers"), a += ")", s(a), o(), s("print(response.text)"), q();
70
+ }
71
+ };
72
+ export {
73
+ x as requests
74
+ };
@@ -0,0 +1,15 @@
1
+ import { requests as t } from "./requests/client.js";
2
+ const o = {
3
+ info: {
4
+ key: "python",
5
+ title: "Python",
6
+ default: "requests",
7
+ cli: "python3 %s"
8
+ },
9
+ clientsById: {
10
+ requests: t
11
+ }
12
+ };
13
+ export {
14
+ o as python
15
+ };
@@ -0,0 +1,46 @@
1
+ import { CodeBuilder as S } from "../../../helpers/code-builder.js";
2
+ import { escapeForDoubleQuotes as h, escapeForSingleQuotes as v } from "../../../helpers/escape.js";
3
+ import { getHeader as k } from "../../../helpers/headers.js";
4
+ const _ = {
5
+ info: {
6
+ key: "httr",
7
+ title: "httr",
8
+ link: "https://cran.r-project.org/web/packages/httr/vignettes/quickstart.html",
9
+ description: "httr: Tools for Working with URLs and HTTP",
10
+ extname: ".r"
11
+ },
12
+ convert: ({ url: u, queryObj: d, queryString: i, postData: r, allHeaders: s, method: $ }) => {
13
+ const { push: e, blank: t, join: b } = new S();
14
+ e("library(httr)"), t(), e(`url <- "${u}"`), t();
15
+ const n = d;
16
+ delete d.key;
17
+ const y = Object.keys(n).length;
18
+ i.length === 1 ? (e(`queryString <- list(${Object.keys(n)} = "${Object.values(n).toString()}")`), t()) : i.length > 1 && (e("queryString <- list("), Object.keys(n).forEach((o, l) => {
19
+ l !== y - 1 ? e(` ${o} = "${n[o].toString()}",`) : e(` ${o} = "${n[o].toString()}"`);
20
+ }), e(")"), t());
21
+ const a = JSON.stringify(r.text);
22
+ if (a && (e(`payload <- ${a}`), t()), r.text || r.jsonObj || r.params)
23
+ switch (r.mimeType) {
24
+ case "application/x-www-form-urlencoded":
25
+ e('encode <- "form"'), t();
26
+ break;
27
+ case "application/json":
28
+ e('encode <- "json"'), t();
29
+ break;
30
+ case "multipart/form-data":
31
+ e('encode <- "multipart"'), t();
32
+ break;
33
+ default:
34
+ e('encode <- "raw"'), t();
35
+ break;
36
+ }
37
+ const p = k(s, "cookie"), f = k(s, "accept"), j = p ? `set_cookies(\`${String(p).replace(/;/g, '", `').replace(/` /g, "`").replace(/[=]/g, '` = "')}")` : void 0, w = f ? `accept("${h(f)}")` : void 0, x = `content_type("${h(r.mimeType)}")`, m = Object.entries(s).filter(([o]) => !["cookie", "accept", "content-type"].includes(o.toLowerCase())).map(([o, l]) => `'${o}' = '${v(l)}'`).join(", "), O = m ? `add_headers(${m})` : void 0;
38
+ let c = `response <- VERB("${$}", url`;
39
+ a && (c += ", body = payload"), i.length && (c += ", query = queryString");
40
+ const g = [O, x, w, j].filter((o) => !!o).join(", ");
41
+ return g && (c += `, ${g}`), (r.text || r.jsonObj || r.params) && (c += ", encode = encode"), c += ")", e(c), t(), e('content(response, "text")'), b();
42
+ }
43
+ };
44
+ export {
45
+ _ as httr
46
+ };
@@ -0,0 +1,14 @@
1
+ import { httr as t } from "./httr/client.js";
2
+ const e = {
3
+ info: {
4
+ key: "r",
5
+ title: "R",
6
+ default: "httr"
7
+ },
8
+ clientsById: {
9
+ httr: t
10
+ }
11
+ };
12
+ export {
13
+ e as r
14
+ };
@@ -0,0 +1,37 @@
1
+ import { CodeBuilder as d } from "../../../helpers/code-builder.js";
2
+ import { escapeForSingleQuotes as E } from "../../../helpers/escape.js";
3
+ const b = {
4
+ info: {
5
+ key: "native",
6
+ title: "net::http",
7
+ link: "http://ruby-doc.org/stdlib-2.2.1/libdoc/net/http/rdoc/Net/HTTP.html",
8
+ description: "Ruby HTTP client",
9
+ extname: ".rb"
10
+ },
11
+ convert: ({ uriObj: p, method: T, fullUrl: c, postData: o, allHeaders: s }) => {
12
+ const { push: t, blank: e, join: h } = new d();
13
+ t("require 'uri'"), t("require 'net/http'"), e();
14
+ const r = T.toUpperCase(), l = [
15
+ "GET",
16
+ "POST",
17
+ "HEAD",
18
+ "DELETE",
19
+ "PATCH",
20
+ "PUT",
21
+ "OPTIONS",
22
+ "COPY",
23
+ "LOCK",
24
+ "UNLOCK",
25
+ "MOVE",
26
+ "TRACE"
27
+ ], n = r.charAt(0) + r.substring(1).toLowerCase();
28
+ l.includes(r) || (t(`class Net::HTTP::${n} < Net::HTTPRequest`), t(` METHOD = '${r.toUpperCase()}'`), t(` REQUEST_HAS_BODY = '${o.text ? "true" : "false"}'`), t(" RESPONSE_HAS_BODY = true"), t("end"), e()), t(`url = URI("${c}")`), e(), t("http = Net::HTTP.new(url.host, url.port)"), p.protocol === "https:" && t("http.use_ssl = true"), e(), t(`request = Net::HTTP::${n}.new(url)`);
29
+ const i = Object.keys(s);
30
+ return i.length && i.forEach((u) => {
31
+ t(`request["${u}"] = '${E(s[u])}'`);
32
+ }), o.text && t(`request.body = ${JSON.stringify(o.text)}`), e(), t("response = http.request(request)"), t("puts response.read_body"), h();
33
+ }
34
+ };
35
+ export {
36
+ b as native
37
+ };
@@ -0,0 +1,14 @@
1
+ import { native as t } from "./native/client.js";
2
+ const i = {
3
+ info: {
4
+ key: "ruby",
5
+ title: "Ruby",
6
+ default: "native"
7
+ },
8
+ clientsById: {
9
+ native: t
10
+ }
11
+ };
12
+ export {
13
+ i as ruby
14
+ };
@@ -0,0 +1,92 @@
1
+ import { CodeBuilder as w } from "../../../helpers/code-builder.js";
2
+ import { getHeader as E, getHeaderName as O, isMimeTypeJSON as S } from "../../../helpers/headers.js";
3
+ import { quote as i } from "../../../helpers/shell.js";
4
+ const J = {
5
+ "http1.0": "0",
6
+ "url ": "",
7
+ cookie: "b",
8
+ data: "d",
9
+ form: "F",
10
+ globoff: "g",
11
+ header: "H",
12
+ insecure: "k",
13
+ request: "X"
14
+ }, U = ($) => (d) => {
15
+ if ($) {
16
+ const l = J[d];
17
+ return l ? `-${l}` : "";
18
+ }
19
+ return `--${d}`;
20
+ }, F = {
21
+ info: {
22
+ key: "curl",
23
+ title: "cURL",
24
+ link: "http://curl.haxx.se/",
25
+ description: "cURL is a command line tool and library for transferring data with URL syntax",
26
+ extname: ".sh"
27
+ },
28
+ convert: ({ fullUrl: $, method: d, httpVersion: l, headersObj: a, allHeaders: s, postData: o }, h = {}) => {
29
+ var g;
30
+ const { indent: m = " ", short: b = !1, binary: c = !1, globOff: x = !1 } = h, y = " ", { push: n, join: k } = new w({
31
+ ...typeof m == "string" ? { indent: m } : {},
32
+ join: m !== !1 ? ` \\
33
+ ${m}` : " "
34
+ }), r = U(b);
35
+ let u = i($);
36
+ if (n(`curl ${r("request")} ${d}`), x && (u = unescape(u), n(r("globoff"))), n(`${r("url ")}${u}`), l === "HTTP/1.0" && n(r("http1.0")), E(s, "accept-encoding") && n("--compressed"), o.mimeType === "multipart/form-data") {
37
+ const e = O(a, "content-type");
38
+ if (e) {
39
+ const t = a[e];
40
+ if (e && t) {
41
+ const f = String(t).replace(/; boundary.+?(?=(;|$))/, "");
42
+ a[e] = f, s[e] = f;
43
+ }
44
+ }
45
+ }
46
+ switch (Object.keys(a).sort().forEach((e) => {
47
+ const t = `${e}: ${a[e]}`;
48
+ n(`${r("header")} ${i(t)}`);
49
+ }), s.cookie && n(`${r("cookie")} ${i(s.cookie)}`), o.mimeType) {
50
+ case "multipart/form-data":
51
+ (g = o.params) == null || g.forEach((e) => {
52
+ let t = "";
53
+ e.fileName ? t = `${e.name}='@${e.fileName}'` : t = i(`${e.name}=${e.value}`), n(`${r("form")} ${t}`);
54
+ });
55
+ break;
56
+ case "application/x-www-form-urlencoded":
57
+ o.params ? o.params.forEach((e) => {
58
+ const t = e.name, f = encodeURIComponent(e.name), p = f !== t, N = p ? f : t, T = c ? "--data-binary" : p ? "--data-urlencode" : r("data");
59
+ n(`${T} ${i(`${N}=${e.value}`)}`);
60
+ }) : n(`${c ? "--data-binary" : r("data")} ${i(o.text)}`);
61
+ break;
62
+ default: {
63
+ if (!o.text)
64
+ break;
65
+ let e = !1;
66
+ if (S(o.mimeType) && o.text.length > 20)
67
+ try {
68
+ const t = JSON.parse(o.text);
69
+ e = !0, o.text.indexOf("'") > 0 ? n(
70
+ `${c ? "--data-binary" : r("data")} @- <<EOF
71
+ ${JSON.stringify(
72
+ t,
73
+ null,
74
+ y
75
+ )}
76
+ EOF`
77
+ ) : n(
78
+ `${c ? "--data-binary" : r("data")} '
79
+ ${JSON.stringify(t, null, y)}
80
+ '`
81
+ );
82
+ } catch {
83
+ }
84
+ e || n(`${c ? "--data-binary" : r("data")} ${i(o.text)}`);
85
+ }
86
+ }
87
+ return k();
88
+ }
89
+ };
90
+ export {
91
+ F as curl
92
+ };
@@ -0,0 +1,56 @@
1
+ import { CodeBuilder as b } from "../../../helpers/code-builder.js";
2
+ import { quote as r } from "../../../helpers/shell.js";
3
+ const g = {
4
+ info: {
5
+ key: "httpie",
6
+ title: "HTTPie",
7
+ link: "http://httpie.org/",
8
+ description: "a CLI, cURL-like tool for humans",
9
+ extname: ".sh",
10
+ installation: () => "brew install httpie"
11
+ },
12
+ convert: ({ allHeaders: h, postData: i, queryObj: a, fullUrl: u, method: y, url: f }, $) => {
13
+ var c;
14
+ const e = {
15
+ body: !1,
16
+ cert: !1,
17
+ headers: !1,
18
+ indent: " ",
19
+ pretty: !1,
20
+ print: !1,
21
+ queryParams: !1,
22
+ short: !1,
23
+ style: !1,
24
+ timeout: !1,
25
+ verbose: !1,
26
+ verify: !1,
27
+ ...$
28
+ }, { push: o, join: m, unshift: l } = new b({
29
+ indent: e.indent,
30
+ // @ts-expect-error SEEMS LEGIT
31
+ join: e.indent !== !1 ? ` \\
32
+ ${e.indent}` : " "
33
+ });
34
+ let p = !1;
35
+ const t = [];
36
+ e.headers && t.push(e.short ? "-h" : "--headers"), e.body && t.push(e.short ? "-b" : "--body"), e.verbose && t.push(e.short ? "-v" : "--verbose"), e.print && t.push(`${e.short ? "-p" : "--print"}=${e.print}`), e.verify && t.push(`--verify=${e.verify}`), e.cert && t.push(`--cert=${e.cert}`), e.pretty && t.push(`--pretty=${e.pretty}`), e.style && t.push(`--style=${e.style}`), e.timeout && t.push(`--timeout=${e.timeout}`), e.queryParams && Object.keys(a).forEach((s) => {
37
+ const n = a[s];
38
+ Array.isArray(n) ? n.forEach((v) => {
39
+ o(`${s}==${r(v)}`);
40
+ }) : o(`${s}==${r(n)}`);
41
+ }), Object.keys(h).sort().forEach((s) => {
42
+ o(`${s}:${r(h[s])}`);
43
+ }), i.mimeType === "application/x-www-form-urlencoded" ? (c = i.params) != null && c.length && (t.push(e.short ? "-f" : "--form"), i.params.forEach((s) => {
44
+ o(`${s.name}=${r(s.value)}`);
45
+ })) : p = !0;
46
+ const d = t.length ? `${t.join(" ")} ` : "";
47
+ if (f = r(e.queryParams ? f : u), l(`http ${d}${y} ${f}`), p && i.text) {
48
+ const s = r(i.text);
49
+ l(`echo ${s} | `);
50
+ }
51
+ return m();
52
+ }
53
+ };
54
+ export {
55
+ g as httpie
56
+ };
@@ -0,0 +1,19 @@
1
+ import { curl as l } from "./curl/client.js";
2
+ import { httpie as t } from "./httpie/client.js";
3
+ import { wget as e } from "./wget/client.js";
4
+ const m = {
5
+ info: {
6
+ key: "shell",
7
+ title: "Shell",
8
+ default: "curl",
9
+ cli: "%s"
10
+ },
11
+ clientsById: {
12
+ curl: l,
13
+ httpie: t,
14
+ wget: e
15
+ }
16
+ };
17
+ export {
18
+ m as shell
19
+ };
@@ -0,0 +1,30 @@
1
+ import { CodeBuilder as c } from "../../../helpers/code-builder.js";
2
+ import { quote as o, escape as h } from "../../../helpers/shell.js";
3
+ const u = {
4
+ info: {
5
+ key: "wget",
6
+ title: "Wget",
7
+ link: "https://www.gnu.org/software/wget/",
8
+ description: "a free software package for retrieving files using HTTP, HTTPS",
9
+ extname: ".sh"
10
+ },
11
+ convert: ({ method: i, postData: n, allHeaders: r, fullUrl: f }, d) => {
12
+ const e = {
13
+ indent: " ",
14
+ short: !1,
15
+ verbose: !1,
16
+ ...d
17
+ }, { push: t, join: g } = new c({
18
+ ...typeof e.indent == "string" ? { indent: e.indent } : {},
19
+ join: e.indent !== !1 ? ` \\
20
+ ${e.indent}` : " "
21
+ });
22
+ return e.verbose ? t(`wget ${e.short ? "-v" : "--verbose"}`) : t(`wget ${e.short ? "-q" : "--quiet"}`), t(`--method ${o(i)}`), Object.keys(r).forEach((s) => {
23
+ const a = `${s}: ${r[s]}`;
24
+ t(`--header ${o(a)}`);
25
+ }), n.text && t(`--body-data ${h(o(n.text))}`), t(e.short ? "-O" : "--output-document"), t(`- ${o(f)}`), g();
26
+ }
27
+ };
28
+ export {
29
+ u as wget
30
+ };
@@ -0,0 +1,38 @@
1
+ const a = (t, r) => r.repeat(t), j = (t, r, c, n) => {
2
+ const o = a(n, c), e = a(n - 1, c), i = r ? `,
3
+ ${o}` : ", ";
4
+ return r ? `[
5
+ ${o}${t.join(i)}
6
+ ${e}]` : `[${t.join(i)}]`;
7
+ }, b = (t, r, c) => `let ${t} = ${s(r, c)}`, s = (t, r, c) => {
8
+ switch (c = c === void 0 ? 1 : c + 1, Object.prototype.toString.call(t)) {
9
+ case "[object Number]":
10
+ return t;
11
+ case "[object Array]": {
12
+ let n = !1;
13
+ const o = t.map((e) => (Object.prototype.toString.call(e) === "[object Object]" && (n = Object.keys(e).length > 1), s(e, r, c)));
14
+ return j(o, n, r.indent, c);
15
+ }
16
+ case "[object Object]": {
17
+ const n = [];
18
+ for (const o in t)
19
+ n.push(`"${o}": ${s(t[o], r, c)}`);
20
+ return j(
21
+ n,
22
+ // @ts-expect-error needs better types
23
+ r.pretty && n.length > 1,
24
+ // @ts-expect-error needs better types
25
+ r.indent,
26
+ c
27
+ );
28
+ }
29
+ case "[object Boolean]":
30
+ return t.toString();
31
+ default:
32
+ return t == null ? "nil" : `"${t.toString().replace(/"/g, '\\"')}"`;
33
+ }
34
+ };
35
+ export {
36
+ b as literalDeclaration,
37
+ s as literalRepresentation
38
+ };
@@ -0,0 +1,14 @@
1
+ import { urlsession as s } from "./urlsession/client.js";
2
+ const i = {
3
+ info: {
4
+ key: "swift",
5
+ title: "Swift",
6
+ default: "urlsession"
7
+ },
8
+ clientsById: {
9
+ urlsession: s
10
+ }
11
+ };
12
+ export {
13
+ i as swift
14
+ };
@@ -0,0 +1,59 @@
1
+ import { CodeBuilder as h } from "../../../helpers/code-builder.js";
2
+ import { literalDeclaration as c, literalRepresentation as j } from "../helpers.js";
3
+ const R = {
4
+ info: {
5
+ key: "urlsession",
6
+ title: "URLSession",
7
+ link: "https://developer.apple.com/documentation/foundation/urlsession",
8
+ description: "Foundation's URLSession request",
9
+ extname: ".swift"
10
+ },
11
+ convert: ({ allHeaders: i, postData: t, uriObj: d, queryObj: l, method: f }, y) => {
12
+ var p;
13
+ const n = {
14
+ indent: " ",
15
+ pretty: !0,
16
+ timeout: 10,
17
+ ...y
18
+ }, { push: e, blank: a, join: b } = new h({ indent: n.indent });
19
+ e("import Foundation"), a();
20
+ const m = t.text || t.jsonObj || t.params;
21
+ if (m)
22
+ switch (t.mimeType) {
23
+ case "application/x-www-form-urlencoded":
24
+ if ((p = t.params) != null && p.length) {
25
+ const o = t.params.map((r) => `"${r.name}": "${r.value}"`);
26
+ n.pretty ? (e("let parameters = ["), o.forEach((r) => {
27
+ e(`${r},`, 1);
28
+ }), e("]")) : e(`let parameters = [${o.join(", ")}]`), e('let joinedParameters = parameters.map { "\\($0.key)=\\($0.value)" }.joined(separator: "&")'), e("let postData = Data(joinedParameters.utf8)"), a();
29
+ }
30
+ break;
31
+ case "application/json":
32
+ t.jsonObj && (e(`${c("parameters", t.jsonObj, n)} as [String : Any?]`), a(), e("let postData = try JSONSerialization.data(withJSONObject: parameters, options: [])"), a());
33
+ break;
34
+ case "multipart/form-data":
35
+ e(c("parameters", t.params, n)), a(), e(`let boundary = "${t.boundary}"`), a(), e('var body = ""'), e("for param in parameters {"), e('let paramName = param["name"]!', 1), e('body += "--\\(boundary)\\r\\n"', 1), e('body += "Content-Disposition:form-data; name=\\"\\(paramName)\\""', 1), e('if let filename = param["fileName"] {', 1), e('let contentType = param["contentType"]!', 2), e("let fileContent = try String(contentsOfFile: filename, encoding: .utf8)", 2), e('body += "; filename=\\"\\(filename)\\"\\r\\n"', 2), e('body += "Content-Type: \\(contentType)\\r\\n\\r\\n"', 2), e("body += fileContent", 2), e('} else if let paramValue = param["value"] {', 1), e('body += "\\r\\n\\r\\n\\(paramValue)"', 2), e("}", 1), e("}"), a(), e("let postData = Data(body.utf8)"), a();
36
+ break;
37
+ default:
38
+ e(`let postData = Data("${t.text}".utf8)`), a();
39
+ }
40
+ e(`let url = URL(string: "${d.href}")!`);
41
+ const u = l ? Object.entries(l) : [];
42
+ return u.length < 1 ? e("var request = URLRequest(url: url)") : (e("var components = URLComponents(url: url, resolvingAgainstBaseURL: true)!"), e("let queryItems: [URLQueryItem] = ["), u.forEach((o) => {
43
+ const r = o[0], s = o[1];
44
+ switch (Object.prototype.toString.call(s)) {
45
+ case "[object String]":
46
+ e(`URLQueryItem(name: "${r}", value: "${s}"),`, 1);
47
+ break;
48
+ case "[object Array]":
49
+ s.forEach(($) => {
50
+ e(`URLQueryItem(name: "${r}", value: "${$}"),`, 1);
51
+ });
52
+ break;
53
+ }
54
+ }), e("]"), e("components.queryItems = components.queryItems.map { $0 + queryItems } ?? queryItems"), a(), e("var request = URLRequest(url: components.url!)")), e(`request.httpMethod = "${f}"`), e(`request.timeoutInterval = ${n.timeout}`), Object.keys(i).length && e(`request.allHTTPHeaderFields = ${j(i, n)}`), m && e("request.httpBody = postData"), a(), e("let (data, _) = try await URLSession.shared.data(for: request)"), e("print(String(decoding: data, as: UTF8.self))"), b();
55
+ }
56
+ };
57
+ export {
58
+ R as urlsession
59
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mintlify/msft-sdk",
3
- "version": "1.1.61",
3
+ "version": "1.1.62",
4
4
  "description": "Lightweight SDK for Microsoft documentation with MDX rendering",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
@@ -56,7 +56,6 @@
56
56
  "@mintlify/validation": "^0.1.513",
57
57
  "@radix-ui/react-dropdown-menu": "^2.1.16",
58
58
  "@radix-ui/react-tabs": "^1.1.3",
59
- "@readme/httpsnippet": "^11.0.0",
60
59
  "@sindresorhus/slugify": "^3.0.0",
61
60
  "@tailwindcss/typography": "^0.5.19",
62
61
  "@types/har-format": "^1.2.16",
@@ -87,7 +86,10 @@
87
86
  "unified": "^11.0.0",
88
87
  "unist-util-visit": "^5.0.0",
89
88
  "usehooks-ts": "^3.1.1",
90
- "zustand": "^5.0.8"
89
+ "zustand": "^5.0.8",
90
+ "qs": "^6.11.2",
91
+ "stringify-object": "^3.3.0",
92
+ "type-fest": "^5.0.1"
91
93
  },
92
94
  "peerDependencies": {
93
95
  "@fluentui/react-components": ">=9.70.0",
@@ -96,25 +98,36 @@
96
98
  "react-dom": ">=18.0.0"
97
99
  },
98
100
  "devDependencies": {
101
+ "@biomejs/biome": "^2.1.3",
99
102
  "@eslint/js": "^9.38.0",
100
103
  "@mintlify/common": "^1.0.594",
104
+ "@readme/standards": "^2.2.0",
101
105
  "@tailwindcss/vite": "^4.1.15",
106
+ "@types/har-format": "^1.2.15",
102
107
  "@types/httpsnippet": "^1.23.1",
103
108
  "@types/lodash": "^4.17.20",
104
109
  "@types/mime-types": "^3.0.1",
110
+ "@types/node": "^24.0.8",
111
+ "@types/qs": "^6.9.10",
105
112
  "@types/react": "^18.2.0",
106
113
  "@types/react-dom": "^18.2.0",
114
+ "@types/stringify-object": "^4.0.5",
107
115
  "@vitejs/plugin-react": "^4.1.1",
116
+ "@vitest/coverage-v8": "^4.0.2",
108
117
  "eslint": "^9.38.0",
109
118
  "memfs": "^4.50.0",
110
119
  "path-browserify": "^1.0.1",
120
+ "prettier": "^3.0.3",
121
+ "require-directory": "^2.1.1",
111
122
  "rimraf": "^5.0.0",
112
123
  "tailwindcss": "^4.1.15",
113
- "typescript": "^5.0.0",
124
+ "tsup": "^8.0.1",
125
+ "typescript": "^5.8.3",
114
126
  "typescript-eslint": "^8.46.2",
115
127
  "url": "^0.11.4",
116
128
  "util": "^0.12.5",
117
129
  "vite": "^5.0.0",
130
+ "vitest": "^4.0.2",
118
131
  "vite-plugin-dts": "^4.5.4",
119
132
  "vite-plugin-lib-inject-css": "^2.2.2"
120
133
  }