@mintlify/msft-sdk 1.1.70 → 1.1.72

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.
@@ -1,41 +1,42 @@
1
1
  import { jsx as n, jsxs as m } from "react/jsx-runtime";
2
2
  import { extension as p } from "mime-types";
3
- import { useState as c, useMemo as f } from "react";
4
- import y from "../../../components/Api/ErrorBoundary.js";
3
+ import { useState as c, useMemo as y } from "react";
4
+ import f from "../../../components/Api/ErrorBoundary.js";
5
5
  import "@mintlify/validation";
6
6
  import "@sindresorhus/slugify";
7
7
  import { cn as d } from "../../../utils/cn.js";
8
- import { ResponseBody as b } from "./ResponseBody/index.js";
9
- import { ResponseError as g } from "./ResponseError.js";
8
+ import { base64ToUint8Array as b } from "../../../utils/base64.js";
9
+ import { ResponseBody as g } from "./ResponseBody/index.js";
10
+ import { ResponseError as h } from "./ResponseError.js";
10
11
  import { ResponseHeaders as u } from "./ResponseHeaders.js";
11
- import { ResponseTopbar as h } from "./ResponseTopbar.js";
12
- const E = ["body", "headers"], H = ({
12
+ import { ResponseTopbar as x } from "./ResponseTopbar.js";
13
+ const A = ["body", "headers"], E = ({
13
14
  result: e,
14
- className: t
15
+ className: r
15
16
  }) => {
16
- const [o, r] = c("body"), s = x(e), i = () => /* @__PURE__ */ n(
17
+ const [o, t] = c("body"), s = R(e), i = () => /* @__PURE__ */ n(
17
18
  "div",
18
19
  {
19
20
  className: d(
20
21
  "mint:rounded-xt mint:dark:bg-zinc-950 mint:bg-white"
21
22
  ),
22
- children: e.error ? /* @__PURE__ */ n(g, { message: e.errorMessage }) : o === "body" ? /* @__PURE__ */ n(b, { data: s }) : /* @__PURE__ */ n(u, { response: e.response })
23
+ children: e.error ? /* @__PURE__ */ n(h, { message: e.errorMessage }) : o === "body" ? /* @__PURE__ */ n(g, { data: s }) : /* @__PURE__ */ n(u, { response: e.response })
23
24
  }
24
25
  );
25
- return /* @__PURE__ */ n(y, { children: /* @__PURE__ */ m(
26
+ return /* @__PURE__ */ n(f, { children: /* @__PURE__ */ m(
26
27
  "div",
27
28
  {
28
29
  className: d(
29
30
  "mint:w-full mint:rounded-2xl mint:border mint:p-0.5",
30
31
  "mint:bg-gray-50 mint:dark:bg-white/5 mint:border-gray-950/10 mint:dark:border-white/10",
31
- t
32
+ r
32
33
  ),
33
34
  children: [
34
35
  /* @__PURE__ */ n(
35
- h,
36
+ x,
36
37
  {
37
38
  selectedSection: o,
38
- setSelectedSection: r,
39
+ setSelectedSection: t,
39
40
  result: e,
40
41
  data: s
41
42
  }
@@ -44,12 +45,12 @@ const E = ["body", "headers"], H = ({
44
45
  ]
45
46
  }
46
47
  ) });
47
- }, x = (e) => f(() => {
48
+ }, R = (e) => y(() => {
48
49
  if (e.error || e.response.data == null)
49
50
  return;
50
- const t = Buffer.from(e.response.data, "base64"), o = R(e.response.headers), r = S(o), s = new Blob([t], { type: o }), i = URL.createObjectURL(s), a = o && p(o) || void 0;
51
- return o && r !== "other" ? {
52
- type: r,
51
+ const r = b(e.response.data), o = w(e.response.headers), t = l(o), s = new Blob([r], { type: o }), i = URL.createObjectURL(s), a = o && p(o) || void 0;
52
+ return o && t !== "other" ? {
53
+ type: t,
53
54
  contentType: o,
54
55
  blob: s,
55
56
  url: i,
@@ -57,24 +58,24 @@ const E = ["body", "headers"], H = ({
57
58
  } : {
58
59
  type: "other",
59
60
  contentType: o,
60
- content: t.toString("utf-8"),
61
+ content: new TextDecoder().decode(r),
61
62
  blob: s,
62
63
  url: i,
63
64
  extension: a
64
65
  };
65
- }, [e]), R = (e) => {
66
- var t;
66
+ }, [e]), w = (e) => {
67
+ var r;
67
68
  for (const o in e)
68
69
  if (o.toLowerCase() === "content-type") {
69
- const r = e[o];
70
- if (typeof r == "string")
71
- return (t = r.split(";")[0]) == null ? void 0 : t.toLowerCase();
70
+ const t = e[o];
71
+ if (typeof t == "string")
72
+ return (r = t.split(";")[0]) == null ? void 0 : r.toLowerCase();
72
73
  }
73
- }, S = (e) => {
74
- const [t] = (e == null ? void 0 : e.split("/")) ?? [];
75
- return t === "image" || t === "audio" || t === "video" ? t : "other";
74
+ }, l = (e) => {
75
+ const [r] = (e == null ? void 0 : e.split("/")) ?? [];
76
+ return r === "image" || r === "audio" || r === "video" ? r : "other";
76
77
  };
77
78
  export {
78
- H as Response,
79
- E as responseSections
79
+ E as Response,
80
+ A as responseSections
80
81
  };
@@ -1,55 +1,56 @@
1
- import { jsxs as n, jsx as r } from "react/jsx-runtime";
2
- import { useContext as P, useState as w, useEffect as b } from "react";
3
- import { useSelectedBaseUrl as U } from "./hooks/useSelectedBaseUrl.js";
4
- import { SendPill as v } from "../api-playground/ApiPlayground/components/SendPill.js";
5
- import { PageContext as C } from "../contexts/ConfigContext.js";
6
- import { useApiPlaygroundDisplay as E } from "../hooks/useApiPlaygroundDisplay.js";
7
- import { ApiFields as I } from "./ApiFields.js";
8
- import { EndpointHeader as S } from "./EndpointHeader.js";
1
+ import { jsxs as r, jsx as e } from "react/jsx-runtime";
2
+ import { useContext as w, useState as b, useEffect as U } from "react";
3
+ import { useSelectedBaseUrl as v } from "./hooks/useSelectedBaseUrl.js";
4
+ import { SendPill as E } from "../api-playground/ApiPlayground/components/SendPill.js";
5
+ import { PageContext as I } from "../contexts/ConfigContext.js";
6
+ import { useApiPlaygroundDisplay as C } from "../hooks/useApiPlaygroundDisplay.js";
7
+ import { ApiExamples as S } from "./ApiExamples.js";
8
+ import { ApiFields as A } from "./ApiFields.js";
9
+ import { EndpointHeader as N } from "./EndpointHeader.js";
9
10
  import { Playground as k } from "./Playground.js";
10
- import { ApiPlaygroundContext as A } from "./contexts/ApiPlaygroundContext.js";
11
- import { Classes as B } from "./types/index.js";
12
- import { cn as N } from "../utils/cn.js";
13
- const z = ({
11
+ import { ApiPlaygroundContext as B } from "./contexts/ApiPlaygroundContext.js";
12
+ import { Classes as L } from "./types/index.js";
13
+ import { cn as R } from "../utils/cn.js";
14
+ const K = ({
14
15
  apiReferenceData: c,
15
16
  operation: u,
16
17
  children: f
17
18
  }) => {
18
- const { path: g, method: o, baseUrlOptions: i } = u, { pageMetadata: y } = P(C), d = E(), [s, l] = w(!1), m = d === "simple", { selectedBaseUrlIndex: h, setSelectedBaseUrlIndex: x, baseUrl: p } = U();
19
- b(() => {
19
+ const { path: g, method: o, baseUrlOptions: d } = u, { pageMetadata: h } = w(I), s = C(), [m, l] = b(!1), t = s === "simple", x = t, { selectedBaseUrlIndex: y, setSelectedBaseUrlIndex: P, baseUrl: p } = v();
20
+ U(() => {
20
21
  if (typeof window > "u") return;
21
22
  new URLSearchParams(window.location.search).has("playground") && requestAnimationFrame(() => {
22
23
  l(!0);
23
24
  });
24
25
  }, []);
25
- const t = (a) => {
26
- if (l(a), !(typeof window > "u"))
27
- if (a) {
28
- const e = new URL(window.location.href);
29
- e.searchParams.set("playground", "open"), window.history.replaceState({}, "", e);
26
+ const a = (i) => {
27
+ if (l(i), !(typeof window > "u"))
28
+ if (i) {
29
+ const n = new URL(window.location.href);
30
+ n.searchParams.set("playground", "open"), window.history.replaceState({}, "", n);
30
31
  } else {
31
- const e = new URL(window.location.href);
32
- e.searchParams.delete("playground"), window.history.replaceState({}, "", e);
32
+ const n = new URL(window.location.href);
33
+ n.searchParams.delete("playground"), window.history.replaceState({}, "", n);
33
34
  }
34
35
  };
35
- return /* @__PURE__ */ n(
36
- A.Provider,
36
+ return /* @__PURE__ */ r(
37
+ B.Provider,
37
38
  {
38
39
  value: {
39
- isPlaygroundExpanded: s,
40
- setIsPlaygroundExpanded: t
40
+ isPlaygroundExpanded: m,
41
+ setIsPlaygroundExpanded: a
41
42
  },
42
43
  children: [
43
- /* @__PURE__ */ n("div", { className: "mint:flex mint:flex-col mint:gap-8", id: "api-playground-2-operation-page", children: [
44
- /* @__PURE__ */ r("div", { className: "mint:flex mint:items-center mint:gap-3 mint:border mint:border-gray-200 mint:dark:border-[#2d2d2d] mint:rounded-2xl mint:p-1.5", children: /* @__PURE__ */ n("div", { className: "mint:flex mint:items-center mint:gap-0 mint:flex-1 mint:bg-white mint:dark:bg-[#1a1a1a] mint:border mint:border-gray-200 mint:dark:border-[#2d2d2d] mint:rounded-2xl", children: [
45
- /* @__PURE__ */ r(
46
- S,
44
+ /* @__PURE__ */ r("div", { className: "mint:flex mint:flex-col mint:gap-8", id: "api-playground-2-operation-page", children: [
45
+ /* @__PURE__ */ e("div", { className: "mint:flex mint:items-center mint:gap-3 mint:border mint:border-gray-200 mint:dark:border-[#2d2d2d] mint:rounded-2xl mint:p-1.5", children: /* @__PURE__ */ r("div", { className: "mint:flex mint:items-center mint:gap-0 mint:flex-1 mint:bg-white mint:dark:bg-[#1a1a1a] mint:border mint:border-gray-200 mint:dark:border-[#2d2d2d] mint:rounded-2xl", children: [
46
+ /* @__PURE__ */ e(
47
+ N,
47
48
  {
48
49
  baseUrl: p,
49
- baseUrlOptions: i,
50
- selectedBaseUrlIndex: h,
51
- setSelectedBaseUrlIndex: x,
52
- display: d,
50
+ baseUrlOptions: d,
51
+ selectedBaseUrlIndex: y,
52
+ setSelectedBaseUrlIndex: P,
53
+ display: s,
53
54
  path: g,
54
55
  method: o,
55
56
  onBaseUrlChange: () => {
@@ -57,36 +58,37 @@ const z = ({
57
58
  isInPlaygroundModal: !1
58
59
  }
59
60
  ),
60
- m ? null : /* @__PURE__ */ r(
61
- v,
61
+ t ? null : /* @__PURE__ */ e(
62
+ E,
62
63
  {
63
64
  label: "Try it",
64
65
  method: o,
65
- onClick: () => t(!0)
66
+ onClick: () => a(!0)
66
67
  }
67
68
  )
68
69
  ] }) }),
69
- /* @__PURE__ */ n(
70
+ /* @__PURE__ */ e("div", { className: "mint:mt-8 mint:lg:mt-0 mint:flex mint:flex-col mint:gap-6 mint:xl:hidden mint:max-h-[30rem]", children: /* @__PURE__ */ e(S, { noInputs: x }) }),
71
+ /* @__PURE__ */ r(
70
72
  "div",
71
73
  {
72
- className: N(
73
- B.Content,
74
+ className: R(
75
+ L.Content,
74
76
  "mint:relative"
75
77
  ),
76
78
  children: [
77
79
  f,
78
- /* @__PURE__ */ r(I, { pageMetadata: y })
80
+ /* @__PURE__ */ e(A, { pageMetadata: h })
79
81
  ]
80
82
  }
81
83
  )
82
84
  ] }),
83
- !m && /* @__PURE__ */ r(
85
+ !t && /* @__PURE__ */ e(
84
86
  k,
85
87
  {
86
- isPlaygroundExpanded: s,
87
- setIsPlaygroundExpanded: t,
88
+ isPlaygroundExpanded: m,
89
+ setIsPlaygroundExpanded: a,
88
90
  baseUrl: p,
89
- baseUrlOptions: i,
91
+ baseUrlOptions: d,
90
92
  apiReferenceData: c
91
93
  }
92
94
  )
@@ -95,5 +97,5 @@ const z = ({
95
97
  );
96
98
  };
97
99
  export {
98
- z as OperationPage
100
+ K as OperationPage
99
101
  };
@@ -1,54 +1,56 @@
1
- import { HTTPSnippet as y } from "../../httpsnippet/src/index.js";
1
+ import { HTTPSnippet as U } from "../../httpsnippet/src/index.js";
2
2
  import { generateUniqueString as x } from "../../utils/uuid.js";
3
- import { isValidUrl as R } from "../../utils/request/isValidUrl.js";
4
- import { snippetPresets as T } from "../../constants/snippetPresets.js";
5
- const E = ({
3
+ import { snippetPresets as y } from "../../constants/snippetPresets.js";
4
+ const v = ({
6
5
  request: n,
7
- pathInputs: a,
8
- apiReferenceData: s,
9
- snippetPresets: p = T,
10
- isMultipleRequest: l = !1
6
+ pathInputs: p,
7
+ apiReferenceData: a,
8
+ snippetPresets: s = y,
9
+ isMultipleRequest: c = !1
11
10
  }) => {
12
- const c = {}, f = /:{[^{}]+}/g, m = n.url.replace(f, (e) => {
11
+ const l = {}, m = /:{[^{}]+}/g, f = n.url.replace(m, (e) => {
13
12
  const t = ":62437";
14
- return c[t] = e, t;
15
- }), d = /{[^{}]+}/g, u = m.replace(d, (e) => {
16
- const t = e.slice(1, e.length - 1), r = a[t];
13
+ return l[t] = e, t;
14
+ }), d = /{[^{}]+}/g, h = f.replace(d, (e) => {
15
+ const t = e.slice(1, e.length - 1), r = p[t];
17
16
  if (e === "{endpoint}")
18
17
  return "https://{endpoint}";
19
18
  if (r && (typeof r != "string" || r.length > 0))
20
19
  return `${encodeURIComponent(r.toString())}`;
21
20
  const o = x();
22
- return c[o] = e, o;
21
+ return l[o] = e, o;
23
22
  });
24
- if (!R(u))
25
- return [
23
+ let u;
24
+ try {
25
+ u = new U({
26
+ ...n,
27
+ url: h,
28
+ postData: n.postData || { mimeType: "application/json" }
29
+ });
30
+ } catch (e) {
31
+ return console.error("Error creating HTTPSnippet:", e), [
26
32
  {
27
33
  filename: "Error",
28
34
  code: "A valid request URL is required to generate request examples",
29
35
  language: ""
30
36
  }
31
37
  ];
32
- const h = new y({
33
- ...n,
34
- url: u,
35
- postData: n.postData || { mimeType: "application/json" }
36
- });
37
- return p.map((e) => {
38
+ }
39
+ return s.map((e) => {
38
40
  var g;
39
- const { filename: t, snippet: r, language: o } = e, { target: S, client: P } = r;
41
+ const { filename: t, snippet: r, language: o } = e, { target: P, client: S } = r;
40
42
  try {
41
- const i = h.convert(S, P), U = A(c, (i == null ? void 0 : i.toString()) || "");
43
+ const i = u.convert(P, S), T = R(l, (i == null ? void 0 : i.toString()) || "");
42
44
  return {
43
- filename: l ? t : ((g = s.operation) == null ? void 0 : g.title) || t,
44
- code: U,
45
+ filename: c ? t : ((g = a.operation) == null ? void 0 : g.title) || t,
46
+ code: T,
45
47
  language: o
46
48
  };
47
49
  } catch (i) {
48
50
  return console.error(`Error generating snippet for ${o}:`, i), null;
49
51
  }
50
52
  }).filter((e) => e !== null);
51
- }, A = (n, a) => Object.entries(n).reduce((s, [p, l]) => s.replace(p, l), a);
53
+ }, R = (n, p) => Object.entries(n).reduce((a, [s, c]) => a.replace(s, c), p);
52
54
  export {
53
- E as generateSnippet
55
+ v as generateSnippet
54
56
  };
@@ -1,8 +1,9 @@
1
- import { useContext as w, useCallback as x } from "react";
1
+ import { useContext as S, useCallback as x } from "react";
2
2
  import { encodeBasicAuth as z } from "../schemaGraph/utils.js";
3
3
  import { usePlaygroundInputsStore as O } from "./usePlaygroundInputsStore.js";
4
4
  import { ApiReferenceContext2 as F } from "../../contexts/ConfigContext.js";
5
- const L = ({
5
+ import { arrayBufferToBase64 as P } from "../../utils/base64.js";
6
+ const k = ({
6
7
  apiReferenceData: t,
7
8
  baseUrl: r,
8
9
  contentType: o = "application/json",
@@ -10,33 +11,33 @@ const L = ({
10
11
  setIsSending: a
11
12
  }) => {
12
13
  var m, b, g;
13
- const { requestEndpointUrl: s, fileRequestEndpointUrl: n } = w(F), i = O((d) => d.getApiPlaygroundInputs), h = (m = t.operation) == null ? void 0 : m.disableProxy, p = (b = t.operation) == null ? void 0 : b.path, f = (g = t.operation) == null ? void 0 : g.method;
14
+ const { requestEndpointUrl: s, fileRequestEndpointUrl: n } = S(F), i = O((p) => p.getApiPlaygroundInputs), h = (m = t.operation) == null ? void 0 : m.disableProxy, d = (b = t.operation) == null ? void 0 : b.path, f = (g = t.operation) == null ? void 0 : g.method;
14
15
  return x(async () => {
15
- const d = i();
16
- if (a(!0), !p || !r || !f || !o || !r) {
16
+ const p = i();
17
+ if (a(!0), !d || !r || !f || !o || !r) {
17
18
  a(!1), e({
18
19
  error: !0,
19
20
  errorMessage: "Missing required fields to send a playground request"
20
21
  }), console.error(
21
22
  `Missing some required field to send a playground request:
22
23
 
23
- path=${p}
24
+ path=${d}
24
25
  method=${f}
25
26
  contentType=${o}
26
27
  baseUrl=${r}`
27
28
  );
28
29
  return;
29
30
  }
30
- const A = await import("axios").then((c) => c.default), j = P(p, d.path), S = C($(r, d.server), j);
31
- let u = E(d.header, o);
32
- u = B(u);
31
+ const A = await import("axios").then((c) => c.default), j = $(d, p.path), w = E(C(r, p.server), j);
32
+ let u = B(p.header, o);
33
+ u = M(u);
33
34
  const l = {
34
35
  method: f,
35
- url: S,
36
+ url: w,
36
37
  header: u,
37
- body: d.body,
38
- cookie: d.cookie,
39
- query: d.query
38
+ body: p.body,
39
+ cookie: p.cookie,
40
+ query: p.query
40
41
  };
41
42
  let y;
42
43
  try {
@@ -70,7 +71,7 @@ baseUrl=${r}`
70
71
  a(!1);
71
72
  }, [
72
73
  f,
73
- p,
74
+ d,
74
75
  a,
75
76
  i,
76
77
  r,
@@ -78,12 +79,12 @@ baseUrl=${r}`
78
79
  h,
79
80
  e
80
81
  ]);
81
- }, P = (t, r) => Object.entries(r).reduce((o, [e, a]) => a == null ? o : o.replace(`{${e}}`, encodeURIComponent(a.toString())), t), $ = (t, r) => {
82
+ }, $ = (t, r) => Object.entries(r).reduce((o, [e, a]) => a == null ? o : o.replace(`{${e}}`, encodeURIComponent(a.toString())), t), C = (t, r) => {
82
83
  let o = t;
83
84
  return Object.entries(r).forEach(([e, a]) => {
84
85
  a && (o = o.replace(`{${e}}`, a));
85
86
  }), o;
86
- }, C = (t, r) => t.replace(/\/$/, "") + "/" + r.replace(/^\//, ""), E = (t, r) => Object.keys(t).some((o) => o.toLowerCase() === "content-type") ? t : {
87
+ }, E = (t, r) => t.replace(/\/$/, "") + "/" + r.replace(/^\//, ""), B = (t, r) => Object.keys(t).some((o) => o.toLowerCase() === "content-type") ? t : {
87
88
  ...t,
88
89
  "content-type": r
89
90
  }, D = async (t) => {
@@ -110,7 +111,7 @@ baseUrl=${r}`
110
111
  validateStatus: () => !0,
111
112
  // prevent axios from parsing json, losing whitespace information, and using default utf-8 encoding
112
113
  // we can't use `responseEncoding` as it's ignored client-side
113
- transformResponse: (s) => Buffer.from(s).toString("base64")
114
+ transformResponse: (s) => P(s)
114
115
  });
115
116
  }, J = async (t, r) => {
116
117
  const o = await import("axios").then((s) => s.default), e = new FormData();
@@ -152,7 +153,7 @@ baseUrl=${r}`
152
153
  }), r = a, delete o["content-type"]);
153
154
  }
154
155
  return { data: r, headers: o };
155
- }, B = (t) => {
156
+ }, M = (t) => {
156
157
  if (!t.Authorization || typeof t.Authorization != "object") return t;
157
158
  if (typeof t.Authorization == "object") {
158
159
  const r = "username" in t.Authorization ? t.Authorization.username : "", o = "password" in t.Authorization ? t.Authorization.password : "", e = z(r, o);
@@ -161,8 +162,8 @@ baseUrl=${r}`
161
162
  return t;
162
163
  };
163
164
  export {
164
- P as addPathParams,
165
- $ as addServerVariables,
166
- C as joinWithSingleSlash,
167
- L as useSendPlaygroundRequest
165
+ $ as addPathParams,
166
+ C as addServerVariables,
167
+ E as joinWithSingleSlash,
168
+ k as useSendPlaygroundRequest
168
169
  };