@mintlify/msft-sdk 1.1.19 → 1.1.21
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,55 +1,55 @@
|
|
|
1
1
|
import { jsx as l } from "react/jsx-runtime";
|
|
2
|
-
import { useState as
|
|
3
|
-
import { initialApiPlaygroundInputs as
|
|
4
|
-
import { generateSnippetMap as
|
|
2
|
+
import { useState as b, useEffect as q } from "react";
|
|
3
|
+
import { initialApiPlaygroundInputs as y } from "../../constants/index.js";
|
|
4
|
+
import { generateSnippetMap as E } from "../../generators/generateSnippetMap.js";
|
|
5
5
|
import { CodeGroupSelect as M } from "../../../components/content-components/CodeGroupSelect/index.js";
|
|
6
6
|
import { CodeSnippets as O } from "../../../components/content-components/code-snippets.js";
|
|
7
|
-
import { CodeBlock as
|
|
7
|
+
import { CodeBlock as x } from "../../../components/content-components/code-block.js";
|
|
8
8
|
import { CodeGroup as U } from "../../../components/content-components/code-group.js";
|
|
9
9
|
import { prismLangToDisplayLang as j } from "../../../constants/prism-languages.js";
|
|
10
10
|
import { useApiPlaygroundDisplay as w } from "../../../hooks/useApiPlaygroundDisplay.js";
|
|
11
11
|
import { GeneratedRequestExample as C } from "./GeneratedRequestExample.js";
|
|
12
|
-
const
|
|
12
|
+
const I = ({
|
|
13
13
|
apiReferenceData: o,
|
|
14
|
-
inputs:
|
|
14
|
+
inputs: i = y,
|
|
15
15
|
maxHeight: p
|
|
16
16
|
}) => {
|
|
17
|
-
var r,
|
|
18
|
-
const u = (
|
|
19
|
-
switch (
|
|
17
|
+
var d, r, n, c, e;
|
|
18
|
+
const u = (d = o.operation) == null ? void 0 : d.requestExamples, a = w(), m = (r = o.operation) == null ? void 0 : r.requestExampleLanguages, t = (n = o.operation) == null ? void 0 : n.requiredOnlyExamples;
|
|
19
|
+
switch ((c = o.operation) == null || c.requestExampleType, (e = o.operation) == null ? void 0 : e.requestExampleType) {
|
|
20
20
|
case "mdx":
|
|
21
21
|
if (!u) return null;
|
|
22
|
-
const
|
|
23
|
-
return /* @__PURE__ */ l(U, { isSmallText: !0, dropdown:
|
|
24
|
-
|
|
22
|
+
const S = u.some((s) => s.dropdown ?? !1);
|
|
23
|
+
return /* @__PURE__ */ l(U, { isSmallText: !0, dropdown: S, noMargins: !0, className: p, children: u.map((s, f) => /* @__PURE__ */ l(
|
|
24
|
+
x,
|
|
25
25
|
{
|
|
26
|
-
language:
|
|
27
|
-
fileName:
|
|
28
|
-
children: /* @__PURE__ */ l("span", { children:
|
|
26
|
+
language: s.language,
|
|
27
|
+
fileName: s.filename,
|
|
28
|
+
children: /* @__PURE__ */ l("span", { children: s.code })
|
|
29
29
|
},
|
|
30
|
-
`${
|
|
30
|
+
`${s.filename}-${s.language}-${f}`
|
|
31
31
|
)) });
|
|
32
32
|
case "codeSamples":
|
|
33
33
|
return o.operation.codeSamples ? /* @__PURE__ */ l(
|
|
34
34
|
L,
|
|
35
35
|
{
|
|
36
36
|
apiReferenceData: o,
|
|
37
|
-
inputs:
|
|
37
|
+
inputs: i,
|
|
38
38
|
apiPlaygroundDisplay: a,
|
|
39
|
-
requestExampleLanguages:
|
|
39
|
+
requestExampleLanguages: m,
|
|
40
40
|
requiredOnly: t,
|
|
41
41
|
maxHeight: p
|
|
42
42
|
}
|
|
43
43
|
) : null;
|
|
44
44
|
case "generated":
|
|
45
|
-
const
|
|
46
|
-
return
|
|
45
|
+
const g = o.operation.baseUrl ?? o.operation.baseUrlOptions[0];
|
|
46
|
+
return g ? /* @__PURE__ */ l(
|
|
47
47
|
C,
|
|
48
48
|
{
|
|
49
49
|
apiReferenceData: o,
|
|
50
|
-
baseUrl:
|
|
51
|
-
inputs:
|
|
52
|
-
requestExampleLanguages:
|
|
50
|
+
baseUrl: g,
|
|
51
|
+
inputs: i,
|
|
52
|
+
requestExampleLanguages: m,
|
|
53
53
|
requiredOnly: t,
|
|
54
54
|
maxHeight: p
|
|
55
55
|
}
|
|
@@ -57,35 +57,35 @@ const F = ({
|
|
|
57
57
|
}
|
|
58
58
|
}, L = ({
|
|
59
59
|
apiReferenceData: o,
|
|
60
|
-
inputs:
|
|
60
|
+
inputs: i,
|
|
61
61
|
apiPlaygroundDisplay: p,
|
|
62
62
|
requestExampleLanguages: u,
|
|
63
63
|
requiredOnly: a,
|
|
64
|
-
maxHeight:
|
|
64
|
+
maxHeight: m
|
|
65
65
|
}) => {
|
|
66
|
-
const [t, d] =
|
|
67
|
-
if (
|
|
66
|
+
const [t, d] = b(null);
|
|
67
|
+
if (q(() => {
|
|
68
68
|
var r;
|
|
69
|
-
(r = o.operation) != null && r.codeSamples &&
|
|
69
|
+
(r = o.operation) != null && r.codeSamples && E({
|
|
70
70
|
apiReferenceData: o,
|
|
71
71
|
codeSamples: o.operation.codeSamples,
|
|
72
72
|
baseUrl: o.operation.baseUrl ?? o.operation.baseUrlOptions[0],
|
|
73
73
|
apiPlaygroundMode: p,
|
|
74
74
|
requestExampleLanguages: u,
|
|
75
75
|
requiredOnly: a,
|
|
76
|
-
inputs:
|
|
76
|
+
inputs: i
|
|
77
77
|
}).then(d);
|
|
78
|
-
}, [o,
|
|
78
|
+
}, [o, i, p, u, a]), !t) return null;
|
|
79
79
|
if (Object.values(t).every((r) => Object.keys(r).length <= 1)) {
|
|
80
|
-
let
|
|
81
|
-
return new Set(
|
|
80
|
+
let n = Object.values(t).flatMap((e) => Object.values(e));
|
|
81
|
+
return new Set(n.map((e) => e.filename)).size !== n.length && (n = n.map((e) => ({
|
|
82
82
|
...e,
|
|
83
83
|
filename: j[e.language] ?? e.language
|
|
84
|
-
}))), /* @__PURE__ */ l(O, { snippets:
|
|
84
|
+
}))), /* @__PURE__ */ l(O, { snippets: n, dropdown: !0, maxHeight: m });
|
|
85
85
|
}
|
|
86
|
-
return /* @__PURE__ */ l(M, { snippets: t, maxHeight:
|
|
86
|
+
return /* @__PURE__ */ l(M, { snippets: t, maxHeight: m });
|
|
87
87
|
};
|
|
88
88
|
export {
|
|
89
|
-
|
|
89
|
+
I as RequestExample
|
|
90
90
|
};
|
|
91
91
|
//# sourceMappingURL=RequestExample.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RequestExample.js","sources":["../../../../src/api-playground-2/components/Example/RequestExample.tsx"],"sourcesContent":["import { ApiPlaygroundInputs } from '@mintlify/validation';\nimport { useState, useEffect } from 'react';\n\nimport { initialApiPlaygroundInputs } from '@/api-playground-2/constants';\nimport { generateSnippetMap } from '@/api-playground-2/generators/generateSnippetMap';\nimport type { ApiReferenceDataV2, CodeExample } from '@/api-playground-2/types';\nimport { CodeGroupSelect } from '../../../components/content-components/CodeGroupSelect';\nimport { CodeSnippet } from '../../../components/content-components/code-snippet';\nimport { CodeSnippets } from '../../../components/content-components/code-snippets';\nimport { CodeBlock } from '../../../components/content-components/code-block';\nimport { CodeGroup } from '../../../components/content-components/code-group';\nimport { prismLangToDisplayLang } from '../../../constants/prism-languages';\nimport { useApiPlaygroundDisplay } from '../../../hooks/useApiPlaygroundDisplay';\nimport type { ExampleCodeSnippet } from '../../../types/exampleCodeSnippet';\n\nimport { GeneratedRequestExample } from './GeneratedRequestExample';\n\nexport const RequestExample = ({\n apiReferenceData,\n inputs = initialApiPlaygroundInputs,\n maxHeight,\n}: {\n apiReferenceData: ApiReferenceDataV2;\n inputs: ApiPlaygroundInputs;\n maxHeight?: string;\n}) => {\n const requestExamples = apiReferenceData.operation?.requestExamples;\n const apiPlaygroundDisplay = useApiPlaygroundDisplay();\n const requestExampleLanguages = apiReferenceData.operation?.requestExampleLanguages;\n const requiredOnly = apiReferenceData.operation?.requiredOnlyExamples;\n\n const requestExampleType = apiReferenceData.operation?.requestExampleType;\n\n
|
|
1
|
+
{"version":3,"file":"RequestExample.js","sources":["../../../../src/api-playground-2/components/Example/RequestExample.tsx"],"sourcesContent":["import { ApiPlaygroundInputs } from '@mintlify/validation';\nimport { useState, useEffect } from 'react';\n\nimport { initialApiPlaygroundInputs } from '@/api-playground-2/constants';\nimport { generateSnippetMap } from '@/api-playground-2/generators/generateSnippetMap';\nimport type { ApiReferenceDataV2, CodeExample } from '@/api-playground-2/types';\nimport { CodeGroupSelect } from '../../../components/content-components/CodeGroupSelect';\nimport { CodeSnippet } from '../../../components/content-components/code-snippet';\nimport { CodeSnippets } from '../../../components/content-components/code-snippets';\nimport { CodeBlock } from '../../../components/content-components/code-block';\nimport { CodeGroup } from '../../../components/content-components/code-group';\nimport { prismLangToDisplayLang } from '../../../constants/prism-languages';\nimport { useApiPlaygroundDisplay } from '../../../hooks/useApiPlaygroundDisplay';\nimport type { ExampleCodeSnippet } from '../../../types/exampleCodeSnippet';\n\nimport { GeneratedRequestExample } from './GeneratedRequestExample';\n\nexport const RequestExample = ({\n apiReferenceData,\n inputs = initialApiPlaygroundInputs,\n maxHeight,\n}: {\n apiReferenceData: ApiReferenceDataV2;\n inputs: ApiPlaygroundInputs;\n maxHeight?: string;\n}) => {\n const requestExamples = apiReferenceData.operation?.requestExamples;\n const apiPlaygroundDisplay = useApiPlaygroundDisplay();\n const requestExampleLanguages = apiReferenceData.operation?.requestExampleLanguages;\n const requiredOnly = apiReferenceData.operation?.requiredOnlyExamples;\n\n const requestExampleType = apiReferenceData.operation?.requestExampleType;\n\n switch (apiReferenceData.operation?.requestExampleType) {\n case 'mdx':\n if (!requestExamples) return null;\n const dropdown = requestExamples.some((example: CodeExample) => example.dropdown ?? false);\n return (\n <CodeGroup isSmallText dropdown={dropdown} noMargins className={maxHeight}>\n {requestExamples.map((example: CodeExample, index) => (\n <CodeBlock\n language={example.language}\n fileName={example.filename}\n key={`${example.filename}-${example.language}-${index}`}\n >\n <span>{example.code}</span>\n </CodeBlock>\n ))}\n </CodeGroup>\n );\n case 'codeSamples':\n if (!apiReferenceData.operation.codeSamples) return null;\n return (\n <CodeSamplesExample\n apiReferenceData={apiReferenceData}\n inputs={inputs}\n apiPlaygroundDisplay={apiPlaygroundDisplay}\n requestExampleLanguages={requestExampleLanguages}\n requiredOnly={requiredOnly}\n maxHeight={maxHeight}\n />\n );\n case 'generated':\n const baseUrl =\n apiReferenceData.operation.baseUrl ?? apiReferenceData.operation.baseUrlOptions[0];\n if (!baseUrl) return null;\n return (\n <GeneratedRequestExample\n apiReferenceData={apiReferenceData}\n baseUrl={baseUrl}\n inputs={inputs}\n requestExampleLanguages={requestExampleLanguages}\n requiredOnly={requiredOnly}\n maxHeight={maxHeight}\n />\n );\n }\n};\n\nconst CodeSamplesExample = ({\n apiReferenceData,\n inputs,\n apiPlaygroundDisplay,\n requestExampleLanguages,\n requiredOnly,\n maxHeight,\n}: {\n apiReferenceData: ApiReferenceDataV2;\n inputs: ApiPlaygroundInputs;\n apiPlaygroundDisplay: 'none' | 'simple' | 'interactive';\n requestExampleLanguages?: string[];\n requiredOnly?: boolean;\n maxHeight?: string;\n}) => {\n const [snippetMap, setSnippetMap] = useState<Record<string, Record<string, ExampleCodeSnippet>> | null>(null);\n\n useEffect(() => {\n if (!apiReferenceData.operation?.codeSamples) return;\n\n generateSnippetMap({\n apiReferenceData,\n codeSamples: apiReferenceData.operation.codeSamples,\n baseUrl: apiReferenceData.operation.baseUrl ?? apiReferenceData.operation.baseUrlOptions[0],\n apiPlaygroundMode: apiPlaygroundDisplay,\n requestExampleLanguages,\n requiredOnly,\n inputs,\n }).then(setSnippetMap);\n }, [apiReferenceData, inputs, apiPlaygroundDisplay, requestExampleLanguages, requiredOnly]);\n\n if (!snippetMap) return null;\n\n if (Object.values(snippetMap).every((value) => Object.keys(value).length <= 1)) {\n const codeSnippetMap = Object.values(snippetMap);\n let snippets = codeSnippetMap.flatMap((record) => Object.values(record));\n const uniqueLabels = new Set(snippets.map((snippet) => snippet.filename));\n if (uniqueLabels.size !== snippets.length) {\n snippets = snippets.map((snippet) => ({\n ...snippet,\n filename: prismLangToDisplayLang[snippet.language] ?? snippet.language,\n }));\n }\n return <CodeSnippets snippets={snippets} dropdown maxHeight={maxHeight} />;\n }\n\n return <CodeGroupSelect snippets={snippetMap} maxHeight={maxHeight} />;\n};\n"],"names":["RequestExample","apiReferenceData","inputs","initialApiPlaygroundInputs","maxHeight","requestExamples","_a","apiPlaygroundDisplay","useApiPlaygroundDisplay","requestExampleLanguages","_b","requiredOnly","_c","_d","_e","dropdown","example","jsx","CodeGroup","index","CodeBlock","CodeSamplesExample","baseUrl","GeneratedRequestExample","snippetMap","setSnippetMap","useState","useEffect","generateSnippetMap","value","snippets","record","snippet","prismLangToDisplayLang","CodeSnippets","CodeGroupSelect"],"mappings":";;;;;;;;;;;AAiBO,MAAMA,IAAiB,CAAC;AAAA,EAC7B,kBAAAC;AAAA,EACA,QAAAC,IAASC;AAAA,EACT,WAAAC;AACF,MAIM;;AACJ,QAAMC,KAAkBC,IAAAL,EAAiB,cAAjB,gBAAAK,EAA4B,iBAC9CC,IAAuBC,EAAA,GACvBC,KAA0BC,IAAAT,EAAiB,cAAjB,gBAAAS,EAA4B,yBACtDC,KAAeC,IAAAX,EAAiB,cAAjB,gBAAAW,EAA4B;AAIjD,WAF2BC,IAAAZ,EAAiB,cAAjB,QAAAY,EAA4B,qBAE/CC,IAAAb,EAAiB,cAAjB,gBAAAa,EAA4B,oBAAA;AAAA,IAClC,KAAK;AACH,UAAI,CAACT,EAAiB,QAAO;AAC7B,YAAMU,IAAWV,EAAgB,KAAK,CAACW,MAAyBA,EAAQ,YAAY,EAAK;AACzF,aACE,gBAAAC,EAACC,GAAA,EAAU,aAAW,IAAC,UAAAH,GAAoB,WAAS,IAAC,WAAWX,GAC7D,UAAAC,EAAgB,IAAI,CAACW,GAAsBG,MAC1C,gBAAAF;AAAA,QAACG;AAAA,QAAA;AAAA,UACC,UAAUJ,EAAQ;AAAA,UAClB,UAAUA,EAAQ;AAAA,UAGlB,UAAA,gBAAAC,EAAC,QAAA,EAAM,UAAAD,EAAQ,KAAA,CAAK;AAAA,QAAA;AAAA,QAFf,GAAGA,EAAQ,QAAQ,IAAIA,EAAQ,QAAQ,IAAIG,CAAK;AAAA,MAAA,CAIxD,GACH;AAAA,IAEJ,K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;AAE9E,QAAIC,IADmB,OAAO,OAAON,CAAU,EACjB,QAAQ,CAACO,MAAW,OAAO,OAAOA,CAAM,CAAC;AAEvE,WADqB,IAAI,IAAID,EAAS,IAAI,CAACE,MAAYA,EAAQ,QAAQ,CAAC,EACvD,SAASF,EAAS,WACjCA,IAAWA,EAAS,IAAI,CAACE,OAAa;AAAA,MACpC,GAAGA;AAAA,MACH,UAAUC,EAAuBD,EAAQ,QAAQ,KAAKA,EAAQ;AAAA,IAAA,EAC9D,IAEG,gBAAAf,EAACiB,GAAA,EAAa,UAAAJ,GAAoB,UAAQ,IAAC,WAAA1B,GAAsB;AAAA,EAC1E;AAEA,SAAO,gBAAAa,EAACkB,GAAA,EAAgB,UAAUX,GAAY,WAAApB,EAAA,CAAsB;AACtE;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mintlify/msft-sdk",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.21",
|
|
4
4
|
"description": "Lightweight SDK for Microsoft documentation with MDX rendering",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -57,6 +57,7 @@
|
|
|
57
57
|
"@mintlify/validation": "^0.1.513",
|
|
58
58
|
"@radix-ui/react-dropdown-menu": "^2.1.16",
|
|
59
59
|
"@radix-ui/react-tabs": "^1.1.3",
|
|
60
|
+
"@readme/httpsnippet": "^11.0.0",
|
|
60
61
|
"@sindresorhus/slugify": "^3.0.0",
|
|
61
62
|
"@tailwindcss/typography": "^0.5.19",
|
|
62
63
|
"@types/har-format": "^1.2.16",
|
|
@@ -67,7 +68,6 @@
|
|
|
67
68
|
"hast-util-to-mdast": "^10.1.2",
|
|
68
69
|
"hast-util-to-string": "^3.0.1",
|
|
69
70
|
"html-react-parser": "^5.2.8",
|
|
70
|
-
"@readme/httpsnippet": "^11.0.0",
|
|
71
71
|
"lodash": "^4.17.21",
|
|
72
72
|
"lucide-react": "^0.552.0",
|
|
73
73
|
"mdast-util-mdx-jsx": "^3.2.0",
|
|
@@ -102,10 +102,14 @@
|
|
|
102
102
|
"@types/react-dom": "^18.2.0",
|
|
103
103
|
"@vitejs/plugin-react": "^4.1.1",
|
|
104
104
|
"eslint": "^9.38.0",
|
|
105
|
+
"memfs": "^4.50.0",
|
|
106
|
+
"path-browserify": "^1.0.1",
|
|
105
107
|
"rimraf": "^5.0.0",
|
|
106
108
|
"tailwindcss": "^4.1.15",
|
|
107
109
|
"typescript": "^5.0.0",
|
|
108
110
|
"typescript-eslint": "^8.46.2",
|
|
111
|
+
"url": "^0.11.4",
|
|
112
|
+
"util": "^0.12.5",
|
|
109
113
|
"vite": "^5.0.0",
|
|
110
114
|
"vite-plugin-dts": "^4.5.4",
|
|
111
115
|
"vite-plugin-lib-inject-css": "^2.2.2"
|