@mintlify/msft-sdk 1.1.17 → 1.1.19
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/api-playground/ApiPlayground/ApiPlaygroundContext.js +11 -0
- package/dist/api-playground/ApiPlayground/ApiPlaygroundContext.js.map +1 -0
- package/dist/api-playground-2/ApiExamples.js +3 -3
- package/dist/api-playground-2/components/Example/GeneratedRequestExample.js +97 -92
- package/dist/api-playground-2/components/Example/GeneratedRequestExample.js.map +1 -1
- package/dist/api-playground-2/components/Example/GeneratedResponseExample.js +2 -2
- package/dist/api-playground-2/components/Example/RequestExample.js +40 -40
- package/dist/api-playground-2/components/Example/RequestExample.js.map +1 -1
- package/dist/api-playground-2/components/Example/ResponseExample.js +8 -8
- package/dist/api-playground-2/components/Example/ResponseExample.js.map +1 -1
- package/dist/api-playground-2/constants/index.js +20 -0
- package/dist/api-playground-2/constants/index.js.map +1 -0
- package/dist/api-playground-2/generators/createBodyData.js +67 -0
- package/dist/api-playground-2/generators/createBodyData.js.map +1 -0
- package/dist/api-playground-2/generators/createHeaders.js +45 -0
- package/dist/api-playground-2/generators/createHeaders.js.map +1 -0
- package/dist/api-playground-2/generators/generateInteractiveCodeSample.js +50 -0
- package/dist/api-playground-2/generators/generateInteractiveCodeSample.js.map +1 -0
- package/dist/api-playground-2/generators/generateRequest.js +65 -0
- package/dist/api-playground-2/generators/generateRequest.js.map +1 -0
- package/dist/api-playground-2/generators/generateResponseExampleMap.js +36 -0
- package/dist/api-playground-2/generators/generateResponseExampleMap.js.map +1 -0
- package/dist/api-playground-2/generators/generateSnippet.js +42 -0
- package/dist/api-playground-2/generators/generateSnippet.js.map +1 -0
- package/dist/api-playground-2/generators/generateSnippetMap.js +68 -0
- package/dist/api-playground-2/generators/generateSnippetMap.js.map +1 -0
- package/dist/api-playground-2/generators/getFileProperties.js +24 -0
- package/dist/api-playground-2/generators/getFileProperties.js.map +1 -0
- package/dist/api-playground-2/hooks/usePlaygroundInputsStore.js +22 -0
- package/dist/api-playground-2/hooks/usePlaygroundInputsStore.js.map +1 -0
- package/dist/api-playground-2/schemaGraph/getAllRequiredProperties.js +10 -0
- package/dist/api-playground-2/schemaGraph/getAllRequiredProperties.js.map +1 -0
- package/dist/api-playground-2/schemaGraph/processExamples.js +13 -0
- package/dist/api-playground-2/schemaGraph/processExamples.js.map +1 -0
- package/dist/api-playground-2/schemaGraph/utils.js +76 -0
- package/dist/api-playground-2/schemaGraph/utils.js.map +1 -0
- package/dist/components/Api/dropdown-menu.js +4 -3
- package/dist/components/Api/dropdown-menu.js.map +1 -1
- package/dist/components/content-components/CodeGroupSelect/index.js +3 -3
- package/dist/components/content-components/code-group.js +40 -40
- package/dist/components/content-components/code-group.js.map +1 -1
- package/dist/components/content-components/code-snippets.js +11 -11
- package/dist/components/content-components/code-snippets.js.map +1 -1
- package/dist/constants/initialRequest.js +14 -0
- package/dist/constants/initialRequest.js.map +1 -0
- package/dist/constants/snippetPresets.js +47 -13
- package/dist/constants/snippetPresets.js.map +1 -1
- package/dist/contexts/CodeExampleLabelContext.js +14 -0
- package/dist/contexts/CodeExampleLabelContext.js.map +1 -0
- package/dist/contexts/ConfigContext.js +1 -2
- package/dist/contexts/ConfigContext.js.map +1 -1
- package/dist/env.js +3 -0
- package/dist/env.js.map +1 -0
- package/dist/hooks/useSendPlaygroundRequest.js +18 -0
- package/dist/hooks/useSendPlaygroundRequest.js.map +1 -0
- package/dist/utils/locales/en.js +111 -0
- package/dist/utils/locales/en.js.map +1 -0
- package/dist/utils/locales/index.js +6 -0
- package/dist/utils/locales/index.js.map +1 -0
- package/dist/utils/uuid.js +7 -0
- package/dist/utils/uuid.js.map +1 -0
- package/package.json +2 -7
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { createContext as e } from "react";
|
|
2
|
+
const t = e({
|
|
3
|
+
isSending: !1,
|
|
4
|
+
selectedBaseUrlIndex: 0,
|
|
5
|
+
isPlaygroundExpanded: !1,
|
|
6
|
+
selectedExampleIndex: 0
|
|
7
|
+
});
|
|
8
|
+
export {
|
|
9
|
+
t as ApiPlaygroundContext
|
|
10
|
+
};
|
|
11
|
+
//# sourceMappingURL=ApiPlaygroundContext.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ApiPlaygroundContext.js","sources":["../../../src/api-playground/ApiPlayground/ApiPlaygroundContext.tsx"],"sourcesContent":["'use client';\n\nimport { ApiPlaygroundResultType } from '@mintlify/models';\nimport { createContext } from 'react';\n\nexport type ApiPlaygroundContextType = {\n isSending?: boolean;\n sendRequest?: () => void;\n isPlaygroundExpanded: boolean;\n result?: ApiPlaygroundResultType;\n selectedBaseUrlIndex: number;\n setSelectedBaseUrlIndex?: (index: number) => void;\n setIsPlaygroundExpanded?: (expanded: boolean) => void;\n baseUrlOptions?: string[];\n selectedExampleIndex?: number;\n setSelectedExampleIndex?: (index: number) => void;\n};\n\nexport const ApiPlaygroundContext = createContext<ApiPlaygroundContextType>({\n isSending: false,\n selectedBaseUrlIndex: 0,\n isPlaygroundExpanded: false,\n selectedExampleIndex: 0,\n});\n"],"names":["ApiPlaygroundContext","createContext"],"mappings":";AAkBO,MAAMA,IAAuBC,EAAwC;AAAA,EAC1E,WAAW;AAAA,EACX,sBAAsB;AAAA,EACtB,sBAAsB;AAAA,EACtB,sBAAsB;AACxB,CAAC;"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { jsx as e, jsxs as c } from "react/jsx-runtime";
|
|
2
2
|
import { useContext as x, useState as f, useMemo as u } from "react";
|
|
3
|
-
import { usePlaygroundInputsStore as d } from "
|
|
4
|
-
import { CodeExampleLabelContext as h } from "
|
|
5
|
-
import { ApiReferenceContext2 as g } from "
|
|
3
|
+
import { usePlaygroundInputsStore as d } from "./hooks/usePlaygroundInputsStore.js";
|
|
4
|
+
import { CodeExampleLabelContext as h } from "../contexts/CodeExampleLabelContext.js";
|
|
5
|
+
import { ApiReferenceContext2 as g } from "../contexts/ConfigContext.js";
|
|
6
6
|
import R from "../components/Api/ErrorBoundary.js";
|
|
7
7
|
import { clsx as v } from "clsx";
|
|
8
8
|
import { RequestExample as C } from "./components/Example/RequestExample.js";
|
|
@@ -1,140 +1,145 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { useState as
|
|
3
|
-
import { generateRequest as E } from "
|
|
4
|
-
import { generateSnippet as I } from "
|
|
5
|
-
import { getFirstExampleValue as
|
|
6
|
-
import { CodeGroupSelect as
|
|
7
|
-
import { CodeSnippets as
|
|
8
|
-
import { langToPresetMap as
|
|
1
|
+
import { jsx as y } from "react/jsx-runtime";
|
|
2
|
+
import { useState as M, useEffect as B } from "react";
|
|
3
|
+
import { generateRequest as E } from "../../generators/generateRequest.js";
|
|
4
|
+
import { generateSnippet as I } from "../../generators/generateSnippet.js";
|
|
5
|
+
import { getFirstExampleValue as a } from "../../schemaGraph/processExamples.js";
|
|
6
|
+
import { CodeGroupSelect as w } from "../../../components/content-components/CodeGroupSelect/index.js";
|
|
7
|
+
import { CodeSnippets as A } from "../../../components/content-components/code-snippets.js";
|
|
8
|
+
import { langToPresetMap as G } from "../../../constants/snippetPresets.js";
|
|
9
9
|
const Q = ({
|
|
10
|
-
baseUrl:
|
|
10
|
+
baseUrl: s,
|
|
11
11
|
apiReferenceData: t,
|
|
12
|
-
inputs:
|
|
13
|
-
requestExampleLanguages:
|
|
14
|
-
requiredOnly:
|
|
15
|
-
maxHeight:
|
|
12
|
+
inputs: n,
|
|
13
|
+
requestExampleLanguages: c,
|
|
14
|
+
requiredOnly: p,
|
|
15
|
+
maxHeight: o
|
|
16
16
|
}) => {
|
|
17
|
-
var f, S,
|
|
18
|
-
const
|
|
19
|
-
if (!
|
|
20
|
-
return /* @__PURE__ */
|
|
17
|
+
var f, S, r, x, d;
|
|
18
|
+
const m = (f = t.dependencies) == null ? void 0 : f.requestBody;
|
|
19
|
+
if (!m)
|
|
20
|
+
return /* @__PURE__ */ y(
|
|
21
21
|
C,
|
|
22
22
|
{
|
|
23
23
|
apiReferenceData: t,
|
|
24
|
-
baseUrl:
|
|
25
|
-
inputs:
|
|
26
|
-
requestExampleLanguages:
|
|
27
|
-
requiredOnly:
|
|
28
|
-
maxHeight:
|
|
24
|
+
baseUrl: s,
|
|
25
|
+
inputs: n,
|
|
26
|
+
requestExampleLanguages: c,
|
|
27
|
+
requiredOnly: p,
|
|
28
|
+
maxHeight: o
|
|
29
29
|
}
|
|
30
30
|
);
|
|
31
|
-
const i =
|
|
31
|
+
const i = a(m.content);
|
|
32
32
|
if (!i) return null;
|
|
33
|
-
const
|
|
34
|
-
([
|
|
35
|
-
contentType:
|
|
36
|
-
examples:
|
|
33
|
+
const l = Object.entries(m.content).map(
|
|
34
|
+
([e, T]) => ({
|
|
35
|
+
contentType: e,
|
|
36
|
+
examples: T.examples
|
|
37
37
|
})
|
|
38
|
-
),
|
|
39
|
-
return ((S =
|
|
40
|
-
|
|
38
|
+
), u = 0;
|
|
39
|
+
return ((S = l[u]) == null ? void 0 : S.examples.length) > 1 ? /* @__PURE__ */ y(
|
|
40
|
+
P,
|
|
41
41
|
{
|
|
42
42
|
apiReferenceData: t,
|
|
43
|
-
selectedBodyContentType: (
|
|
44
|
-
baseUrl:
|
|
45
|
-
inputs:
|
|
46
|
-
examples: (x =
|
|
47
|
-
requiredOnly:
|
|
48
|
-
maxHeight:
|
|
43
|
+
selectedBodyContentType: (r = l[u]) == null ? void 0 : r.contentType,
|
|
44
|
+
baseUrl: s,
|
|
45
|
+
inputs: n,
|
|
46
|
+
examples: (x = l[u]) == null ? void 0 : x.examples,
|
|
47
|
+
requiredOnly: p,
|
|
48
|
+
maxHeight: o
|
|
49
49
|
}
|
|
50
|
-
) : /* @__PURE__ */
|
|
50
|
+
) : /* @__PURE__ */ y(
|
|
51
51
|
C,
|
|
52
52
|
{
|
|
53
53
|
apiReferenceData: t,
|
|
54
|
-
selectedBodyContentType: (
|
|
55
|
-
baseUrl:
|
|
56
|
-
inputs:
|
|
54
|
+
selectedBodyContentType: (d = l[u]) == null ? void 0 : d.contentType,
|
|
55
|
+
baseUrl: s,
|
|
56
|
+
inputs: n,
|
|
57
57
|
exampleValue: i,
|
|
58
|
-
requestExampleLanguages:
|
|
59
|
-
requiredOnly:
|
|
60
|
-
maxHeight:
|
|
58
|
+
requestExampleLanguages: c,
|
|
59
|
+
requiredOnly: p,
|
|
60
|
+
maxHeight: o
|
|
61
61
|
}
|
|
62
62
|
);
|
|
63
63
|
}, C = ({
|
|
64
|
-
baseUrl:
|
|
64
|
+
baseUrl: s,
|
|
65
65
|
apiReferenceData: t,
|
|
66
|
-
inputs:
|
|
67
|
-
selectedBodyContentType:
|
|
68
|
-
exampleValue:
|
|
69
|
-
requestExampleLanguages:
|
|
70
|
-
requiredOnly:
|
|
66
|
+
inputs: n,
|
|
67
|
+
selectedBodyContentType: c,
|
|
68
|
+
exampleValue: p,
|
|
69
|
+
requestExampleLanguages: o,
|
|
70
|
+
requiredOnly: m,
|
|
71
71
|
maxHeight: i
|
|
72
72
|
}) => {
|
|
73
|
-
const [
|
|
73
|
+
const [l, u] = M(null), [f, S] = M(null);
|
|
74
74
|
return B(() => {
|
|
75
|
-
|
|
76
|
-
|
|
75
|
+
let r = !1;
|
|
76
|
+
const x = E({
|
|
77
|
+
baseUrl: s,
|
|
77
78
|
apiReferenceData: t,
|
|
78
|
-
inputs:
|
|
79
|
-
selectedBodyContentType:
|
|
80
|
-
exampleData:
|
|
81
|
-
requiredOnly:
|
|
82
|
-
}),
|
|
83
|
-
const
|
|
84
|
-
return
|
|
79
|
+
inputs: n,
|
|
80
|
+
selectedBodyContentType: c,
|
|
81
|
+
exampleData: p,
|
|
82
|
+
requiredOnly: m
|
|
83
|
+
}), d = o == null ? void 0 : o.reduce((e, T) => {
|
|
84
|
+
const h = G[T];
|
|
85
|
+
return h && e.push(h), e;
|
|
85
86
|
}, []);
|
|
86
|
-
I({
|
|
87
|
+
return I({
|
|
87
88
|
apiReferenceData: t,
|
|
88
|
-
pathInputs:
|
|
89
|
-
request:
|
|
90
|
-
snippetPresets:
|
|
91
|
-
}).then(
|
|
92
|
-
|
|
93
|
-
})
|
|
94
|
-
|
|
95
|
-
},
|
|
96
|
-
|
|
89
|
+
pathInputs: n.path,
|
|
90
|
+
request: x,
|
|
91
|
+
snippetPresets: d
|
|
92
|
+
}).then((e) => {
|
|
93
|
+
r || u(e);
|
|
94
|
+
}).catch((e) => {
|
|
95
|
+
r || (console.error(e), S(e));
|
|
96
|
+
}), () => {
|
|
97
|
+
r = !0;
|
|
98
|
+
};
|
|
99
|
+
}, [s, t, n, c, p, o, m]), f || !l ? null : /* @__PURE__ */ y(A, { snippets: l, dropdown: !0, maxHeight: i });
|
|
100
|
+
}, P = ({
|
|
101
|
+
baseUrl: s,
|
|
97
102
|
apiReferenceData: t,
|
|
98
|
-
inputs:
|
|
99
|
-
selectedBodyContentType:
|
|
100
|
-
examples:
|
|
101
|
-
requiredOnly:
|
|
102
|
-
maxHeight:
|
|
103
|
+
inputs: n,
|
|
104
|
+
selectedBodyContentType: c,
|
|
105
|
+
examples: p,
|
|
106
|
+
requiredOnly: o,
|
|
107
|
+
maxHeight: m
|
|
103
108
|
}) => {
|
|
104
|
-
const [i,
|
|
109
|
+
const [i, l] = M({}), [u, f] = M(null);
|
|
105
110
|
return B(() => {
|
|
106
|
-
const S =
|
|
111
|
+
const S = n.path, r = {};
|
|
107
112
|
(async () => {
|
|
108
|
-
for (const [
|
|
109
|
-
if (!
|
|
110
|
-
const
|
|
111
|
-
baseUrl:
|
|
113
|
+
for (const [d, { value: e }] of Object.entries(p)) {
|
|
114
|
+
if (!e) continue;
|
|
115
|
+
const T = E({
|
|
116
|
+
baseUrl: s,
|
|
112
117
|
apiReferenceData: t,
|
|
113
|
-
inputs:
|
|
114
|
-
selectedBodyContentType:
|
|
115
|
-
exampleData:
|
|
116
|
-
requiredOnly:
|
|
118
|
+
inputs: n,
|
|
119
|
+
selectedBodyContentType: c,
|
|
120
|
+
exampleData: e,
|
|
121
|
+
requiredOnly: o
|
|
117
122
|
});
|
|
118
123
|
try {
|
|
119
124
|
(await I({
|
|
120
125
|
apiReferenceData: t,
|
|
121
126
|
pathInputs: S,
|
|
122
|
-
request:
|
|
127
|
+
request: T,
|
|
123
128
|
isMultipleRequest: !0
|
|
124
129
|
})).forEach((j) => {
|
|
125
|
-
|
|
126
|
-
...
|
|
127
|
-
[
|
|
130
|
+
r[j.filename] = {
|
|
131
|
+
...r[j.filename],
|
|
132
|
+
[d]: j
|
|
128
133
|
};
|
|
129
134
|
});
|
|
130
|
-
} catch (
|
|
131
|
-
console.error(
|
|
135
|
+
} catch (h) {
|
|
136
|
+
console.error(h), f(h);
|
|
132
137
|
return;
|
|
133
138
|
}
|
|
134
139
|
}
|
|
135
|
-
|
|
140
|
+
l(r);
|
|
136
141
|
})();
|
|
137
|
-
}, [
|
|
142
|
+
}, [s, t, n, c, p, o]), u || Object.keys(i).length === 0 ? null : /* @__PURE__ */ y(w, { snippets: i, maxHeight: m });
|
|
138
143
|
};
|
|
139
144
|
export {
|
|
140
145
|
Q as GeneratedRequestExample
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GeneratedRequestExample.js","sources":["../../../../src/api-playground-2/components/Example/GeneratedRequestExample.tsx"],"sourcesContent":["import { ApiPlaygroundInputs, ExampleSchema } from '@mintlify/validation';\nimport { JSX, useState, useEffect } from 'react';\n\nimport { generateRequest } from '@/api-playground-2/generators/generateRequest';\nimport { generateSnippet } from '@/api-playground-2/generators/generateSnippet';\nimport { getFirstExampleValue } from '@/api-playground-2/schemaGraph/processExamples';\nimport type { ApiReferenceDataV2 } from '@/api-playground-2/types';\nimport { CodeGroupSelect } from '../../../components/content-components/CodeGroupSelect';\nimport { CodeSnippets } from '../../../components/content-components/code-snippets';\nimport { langToPresetMap, SnippetPreset } from '../../../constants/snippetPresets';\nimport type { ExampleCodeSnippet } from '../../../types/exampleCodeSnippet';\n\nexport type GeneratedRequestExampleParams = {\n baseUrl: string;\n apiReferenceData: ApiReferenceDataV2;\n inputs: ApiPlaygroundInputs;\n requestExampleLanguages?: string[];\n requiredOnly?: boolean;\n maxHeight?: string;\n};\n\nexport const GeneratedRequestExample = ({\n baseUrl,\n apiReferenceData,\n inputs,\n requestExampleLanguages,\n requiredOnly,\n maxHeight,\n}: GeneratedRequestExampleParams): JSX.Element | null => {\n const requestBody = apiReferenceData.dependencies?.requestBody;\n\n if (!requestBody) {\n return (\n <SingleRequest\n apiReferenceData={apiReferenceData}\n baseUrl={baseUrl}\n inputs={inputs}\n requestExampleLanguages={requestExampleLanguages}\n requiredOnly={requiredOnly}\n maxHeight={maxHeight}\n />\n );\n }\n\n const firstExampleValue = getFirstExampleValue(requestBody.content);\n\n if (!firstExampleValue) return null;\n\n const examplesByContentType = Object.entries(requestBody.content).map(\n ([contentType, content]) => {\n return {\n contentType,\n examples: content.examples,\n };\n }\n );\n const selectedContentTypeIndex = 0;\n\n return examplesByContentType[selectedContentTypeIndex]?.examples.length > 1 ? (\n <MultipleRequest\n apiReferenceData={apiReferenceData}\n selectedBodyContentType={examplesByContentType[selectedContentTypeIndex]?.contentType}\n baseUrl={baseUrl}\n inputs={inputs}\n examples={examplesByContentType[selectedContentTypeIndex]?.examples}\n requiredOnly={requiredOnly}\n maxHeight={maxHeight}\n />\n ) : (\n <SingleRequest\n apiReferenceData={apiReferenceData}\n selectedBodyContentType={examplesByContentType[selectedContentTypeIndex]?.contentType}\n baseUrl={baseUrl}\n inputs={inputs}\n exampleValue={firstExampleValue}\n requestExampleLanguages={requestExampleLanguages}\n requiredOnly={requiredOnly}\n maxHeight={maxHeight}\n />\n );\n};\n\ntype SingleRequestParams = GeneratedRequestExampleParams & {\n selectedBodyContentType?: string;\n exampleValue?: unknown;\n};\n\nconst SingleRequest = ({\n baseUrl,\n apiReferenceData,\n inputs,\n selectedBodyContentType,\n exampleValue,\n requestExampleLanguages,\n requiredOnly,\n maxHeight,\n}: SingleRequestParams) => {\n const [snippets, setSnippets] = useState<ExampleCodeSnippet[] | null>(null);\n const [error, setError] = useState<Error | null>(null);\n\n useEffect(() => {\n const request = generateRequest({\n baseUrl,\n apiReferenceData,\n inputs: inputs,\n selectedBodyContentType,\n exampleData: exampleValue,\n requiredOnly,\n });\n\n const snippetPresets = requestExampleLanguages?.reduce<SnippetPreset[]>((acc, lang) => {\n const preset = langToPresetMap[lang];\n if (preset) acc.push(preset);\n return acc;\n }, []);\n\n generateSnippet({\n apiReferenceData,\n pathInputs: inputs.path,\n request,\n snippetPresets,\n })\n .then(setSnippets)\n .catch((err) => {\n console.error(err);\n setError(err);\n });\n }, [baseUrl, apiReferenceData, inputs, selectedBodyContentType, exampleValue, requestExampleLanguages, requiredOnly]);\n\n if (error) return null;\n if (!snippets) return null; // or a loading spinner\n\n return <CodeSnippets snippets={snippets} dropdown maxHeight={maxHeight} />;\n};\n\ntype MultipleRequestParams = GeneratedRequestExampleParams & {\n selectedBodyContentType?: string;\n examples: Record<string, ExampleSchema>;\n};\n\nconst MultipleRequest = ({\n baseUrl,\n apiReferenceData,\n inputs,\n selectedBodyContentType,\n examples,\n requiredOnly,\n maxHeight,\n}: MultipleRequestParams): JSX.Element | null => {\n const [nameToSnippetExamplesMap, setNameToSnippetExamplesMap] = useState<\n Record<string, Record<string, ExampleCodeSnippet>>\n >({});\n const [error, setError] = useState<Error | null>(null);\n\n useEffect(() => {\n const pathInputs = inputs.path;\n const snippetMap: Record<string, Record<string, ExampleCodeSnippet>> = {};\n\n const generateAllSnippets = async () => {\n for (const [name, { value: exampleData }] of Object.entries(examples)) {\n if (!exampleData) continue;\n\n const request = generateRequest({\n baseUrl,\n apiReferenceData,\n inputs,\n selectedBodyContentType,\n exampleData,\n requiredOnly,\n });\n\n try {\n const snippets = await generateSnippet({\n apiReferenceData,\n pathInputs,\n request,\n isMultipleRequest: true,\n });\n\n snippets.forEach((snippet) => {\n snippetMap[snippet.filename] = {\n ...snippetMap[snippet.filename],\n [name]: snippet,\n };\n });\n } catch (err) {\n console.error(err);\n setError(err as Error);\n return;\n }\n }\n setNameToSnippetExamplesMap(snippetMap);\n };\n\n generateAllSnippets();\n }, [baseUrl, apiReferenceData, inputs, selectedBodyContentType, examples, requiredOnly]);\n\n if (error) return null;\n if (Object.keys(nameToSnippetExamplesMap).length === 0) return null;\n\n return <CodeGroupSelect snippets={nameToSnippetExamplesMap} maxHeight={maxHeight} />;\n};\n"],"names":["GeneratedRequestExample","baseUrl","apiReferenceData","inputs","requestExampleLanguages","requiredOnly","maxHeight","requestBody","_a","jsx","SingleRequest","firstExampleValue","getFirstExampleValue","examplesByContentType","contentType","content","selectedContentTypeIndex","_b","MultipleRequest","_c","_d","_e","selectedBodyContentType","exampleValue","snippets","setSnippets","useState","error","setError","useEffect","request","generateRequest","snippetPresets","acc","lang","preset","langToPresetMap","generateSnippet","err","CodeSnippets","examples","nameToSnippetExamplesMap","setNameToSnippetExamplesMap","pathInputs","snippetMap","name","exampleData","snippet","CodeGroupSelect"],"mappings":";;;;;;;;AAqBO,MAAMA,IAA0B,CAAC;AAAA,EACtC,SAAAC;AAAA,EACA,kBAAAC;AAAA,EACA,QAAAC;AAAA,EACA,yBAAAC;AAAA,EACA,cAAAC;AAAA,EACA,WAAAC;AACF,MAAyD;;AACvD,QAAMC,KAAcC,IAAAN,EAAiB,iBAAjB,gBAAAM,EAA+B;AAEnD,MAAI,CAACD;AACH,WACE,gBAAAE;AAAA,MAACC;AAAA,MAAA;AAAA,QACC,kBAAAR;AAAA,QACA,SAAAD;AAAA,QACA,QAAAE;AAAA,QACA,yBAAAC;AAAA,QACA,cAAAC;AAAA,QACA,WAAAC;AAAA,MAAA;AAAA,IAAA;AAKN,QAAMK,IAAoBC,EAAqBL,EAAY,OAAO;AAElE,MAAI,CAACI,EAAmB,QAAO;AAE/B,QAAME,IAAwB,OAAO,QAAQN,EAAY,OAAO,EAAE;AAAA,IAChE,CAAC,CAACO,GAAaC,CAAO,OACb;AAAA,MACL,aAAAD;AAAA,MACA,UAAUC,EAAQ;AAAA,I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AA,YACA,SAAAb;AAAA,YACA,mBAAmB;AAAA,UAAA,CACpB,GAEQ,QAAQ,CAACiB,MAAY;AAC5B,YAAAH,EAAWG,EAAQ,QAAQ,IAAI;AAAA,cAC7B,GAAGH,EAAWG,EAAQ,QAAQ;AAAA,cAC9B,CAACF,CAAI,GAAGE;AAAA,YAAA;AAAA,UAEZ,CAAC;AAAA,QACH,SAAST,GAAK;AACZ,kBAAQ,MAAMA,CAAG,GACjBV,EAASU,CAAY;AACrB;AAAA,QACF;AAAA,MACF;AACA,MAAAI,EAA4BE,CAAU;AAAA,IACxC,GAEA;AAAA,EACF,GAAG,CAAC3C,GAASC,GAAkBC,GAAQmB,GAAyBkB,GAAUnC,CAAY,CAAC,GAEnFsB,KACA,OAAO,KAAKc,CAAwB,EAAE,WAAW,IAAU,OAExD,gBAAAhC,EAACuC,GAAA,EAAgB,UAAUP,GAA0B,WAAAnC,EAAA,CAAsB;AACpF;"}
|
|
1
|
+
{"version":3,"file":"GeneratedRequestExample.js","sources":["../../../../src/api-playground-2/components/Example/GeneratedRequestExample.tsx"],"sourcesContent":["import { ApiPlaygroundInputs, ExampleSchema } from '@mintlify/validation';\nimport { JSX, useState, useEffect } from 'react';\n\nimport { generateRequest } from '@/api-playground-2/generators/generateRequest';\nimport { generateSnippet } from '@/api-playground-2/generators/generateSnippet';\nimport { getFirstExampleValue } from '@/api-playground-2/schemaGraph/processExamples';\nimport type { ApiReferenceDataV2 } from '@/api-playground-2/types';\nimport { CodeGroupSelect } from '../../../components/content-components/CodeGroupSelect';\nimport { CodeSnippets } from '../../../components/content-components/code-snippets';\nimport { langToPresetMap, SnippetPreset } from '../../../constants/snippetPresets';\nimport type { ExampleCodeSnippet } from '../../../types/exampleCodeSnippet';\n\nexport type GeneratedRequestExampleParams = {\n baseUrl: string;\n apiReferenceData: ApiReferenceDataV2;\n inputs: ApiPlaygroundInputs;\n requestExampleLanguages?: string[];\n requiredOnly?: boolean;\n maxHeight?: string;\n};\n\nexport const GeneratedRequestExample = ({\n baseUrl,\n apiReferenceData,\n inputs,\n requestExampleLanguages,\n requiredOnly,\n maxHeight,\n}: GeneratedRequestExampleParams): JSX.Element | null => {\n const requestBody = apiReferenceData.dependencies?.requestBody;\n\n if (!requestBody) {\n return (\n <SingleRequest\n apiReferenceData={apiReferenceData}\n baseUrl={baseUrl}\n inputs={inputs}\n requestExampleLanguages={requestExampleLanguages}\n requiredOnly={requiredOnly}\n maxHeight={maxHeight}\n />\n );\n }\n\n const firstExampleValue = getFirstExampleValue(requestBody.content);\n\n if (!firstExampleValue) return null;\n\n const examplesByContentType = Object.entries(requestBody.content).map(\n ([contentType, content]) => {\n return {\n contentType,\n examples: content.examples,\n };\n }\n );\n const selectedContentTypeIndex = 0;\n\n return examplesByContentType[selectedContentTypeIndex]?.examples.length > 1 ? (\n <MultipleRequest\n apiReferenceData={apiReferenceData}\n selectedBodyContentType={examplesByContentType[selectedContentTypeIndex]?.contentType}\n baseUrl={baseUrl}\n inputs={inputs}\n examples={examplesByContentType[selectedContentTypeIndex]?.examples}\n requiredOnly={requiredOnly}\n maxHeight={maxHeight}\n />\n ) : (\n <SingleRequest\n apiReferenceData={apiReferenceData}\n selectedBodyContentType={examplesByContentType[selectedContentTypeIndex]?.contentType}\n baseUrl={baseUrl}\n inputs={inputs}\n exampleValue={firstExampleValue}\n requestExampleLanguages={requestExampleLanguages}\n requiredOnly={requiredOnly}\n maxHeight={maxHeight}\n />\n );\n};\n\ntype SingleRequestParams = GeneratedRequestExampleParams & {\n selectedBodyContentType?: string;\n exampleValue?: unknown;\n};\n\nconst SingleRequest = ({\n baseUrl,\n apiReferenceData,\n inputs,\n selectedBodyContentType,\n exampleValue,\n requestExampleLanguages,\n requiredOnly,\n maxHeight,\n}: SingleRequestParams) => {\n const [snippets, setSnippets] = useState<ExampleCodeSnippet[] | null>(null);\n const [error, setError] = useState<Error | null>(null);\n\n useEffect(() => {\n let cancelled = false;\n \n const request = generateRequest({\n baseUrl,\n apiReferenceData,\n inputs: inputs,\n selectedBodyContentType,\n exampleData: exampleValue,\n requiredOnly,\n });\n\n const snippetPresets = requestExampleLanguages?.reduce<SnippetPreset[]>((acc, lang) => {\n const preset = langToPresetMap[lang];\n if (preset) acc.push(preset);\n return acc;\n }, []);\n\n generateSnippet({\n apiReferenceData,\n pathInputs: inputs.path,\n request,\n snippetPresets,\n })\n .then((result) => {\n if (!cancelled) {\n setSnippets(result);\n }\n })\n .catch((err) => {\n if (!cancelled) {\n console.error(err);\n setError(err);\n }\n });\n \n return () => {\n cancelled = true;\n };\n }, [baseUrl, apiReferenceData, inputs, selectedBodyContentType, exampleValue, requestExampleLanguages, requiredOnly]);\n\n if (error) return null;\n if (!snippets) return null;\n\n return <CodeSnippets snippets={snippets} dropdown maxHeight={maxHeight} />;\n};\n\ntype MultipleRequestParams = GeneratedRequestExampleParams & {\n selectedBodyContentType?: string;\n examples: Record<string, ExampleSchema>;\n};\n\nconst MultipleRequest = ({\n baseUrl,\n apiReferenceData,\n inputs,\n selectedBodyContentType,\n examples,\n requiredOnly,\n maxHeight,\n}: MultipleRequestParams): JSX.Element | null => {\n const [nameToSnippetExamplesMap, setNameToSnippetExamplesMap] = useState<\n Record<string, Record<string, ExampleCodeSnippet>>\n >({});\n const [error, setError] = useState<Error | null>(null);\n\n useEffect(() => {\n const pathInputs = inputs.path;\n const snippetMap: Record<string, Record<string, ExampleCodeSnippet>> = {};\n\n const generateAllSnippets = async () => {\n for (const [name, { value: exampleData }] of Object.entries(examples)) {\n if (!exampleData) continue;\n\n const request = generateRequest({\n baseUrl,\n apiReferenceData,\n inputs,\n selectedBodyContentType,\n exampleData,\n requiredOnly,\n });\n\n try {\n const snippets = await generateSnippet({\n apiReferenceData,\n pathInputs,\n request,\n isMultipleRequest: true,\n });\n\n snippets.forEach((snippet) => {\n snippetMap[snippet.filename] = {\n ...snippetMap[snippet.filename],\n [name]: snippet,\n };\n });\n } catch (err) {\n console.error(err);\n setError(err as Error);\n return;\n }\n }\n setNameToSnippetExamplesMap(snippetMap);\n };\n\n generateAllSnippets();\n }, [baseUrl, apiReferenceData, inputs, selectedBodyContentType, examples, requiredOnly]);\n\n if (error) return null;\n if (Object.keys(nameToSnippetExamplesMap).length === 0) return null;\n\n return <CodeGroupSelect snippets={nameToSnippetExamplesMap} maxHeight={maxHeight} />;\n};\n"],"names":["GeneratedRequestExample","baseUrl","apiReferenceData","inputs","requestExampleLanguages","requiredOnly","maxHeight","requestBody","_a","jsx","SingleRequest","firstExampleValue","getFirstExampleValue","examplesByContentType","contentType","content","selectedContentTypeIndex","_b","MultipleRequest","_c","_d","_e","selectedBodyContentType","exampleValue","snippets","setSnippets","useState","error","setError","useEffect","cancelled","request","generateRequest","snippetPresets","acc","lang","preset","langToPresetMap","generateSnippet","result","err","CodeSnippets","examples","nameToSnippetExamplesMap","setNameToSnippetExamplesMap","pathInputs","snippetMap","name","exampleData","snippet","CodeGroupSelect"],"mappings":";;;;;;;;AAqBO,MAAMA,IAA0B,CAAC;AAAA,EACtC,SAAAC;AAAA,EACA,kBAAAC;AAAA,EACA,QAAAC;AAAA,EACA,yBAAAC;AAAA,EACA,cAAAC;AAAA,EACA,WAAAC;AACF,MAAyD;;AACvD,QAAMC,KAAcC,IAAAN,EAAiB,iBAAjB,gBAAAM,EAA+B;AAEnD,MAAI,CAACD;AACH,WACE,gBAAAE;AAAA,MAACC;AAAA,MAAA;AAAA,QACC,kBAAAR;AAAA,QACA,SAAAD;AAAA,QACA,QAAAE;AAAA,QACA,yBAAAC;AAAA,QACA,cAAAC;AAAA,QACA,WAAAC;AAAA,MAAA;AAAA,IAAA;AAKN,QAAMK,IAAoBC,EAAqBL,EAAY,OAAO;AAElE,MAAI,CAACI,EAAmB,QAAO;AAE/B,QAAME,IAAwB,OAAO,QAAQN,EAAY,OAAO,EAAE;AAAA,IAChE,CAAC,CAACO,GAAaC,CAAO,OACb;AAAA,MACL,aAAAD;AAAA,MACA,UAAUC,EAAQ;AAAA,IAAA;AAAA,EAEtB,GAEIC,IAA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A3C;AAAA,QAAA,CACD;AAED,YAAI;AAQF,WAPiB,MAAMiC,EAAgB;AAAA,YACrC,kBAAApC;AAAA,YACA,YAAA2C;AAAA,YACA,SAAAd;AAAA,YACA,mBAAmB;AAAA,UAAA,CACpB,GAEQ,QAAQ,CAACkB,MAAY;AAC5B,YAAAH,EAAWG,EAAQ,QAAQ,IAAI;AAAA,cAC7B,GAAGH,EAAWG,EAAQ,QAAQ;AAAA,cAC9B,CAACF,CAAI,GAAGE;AAAA,YAAA;AAAA,UAEZ,CAAC;AAAA,QACH,SAAST,GAAK;AACZ,kBAAQ,MAAMA,CAAG,GACjBZ,EAASY,CAAY;AACrB;AAAA,QACF;AAAA,MACF;AACA,MAAAI,EAA4BE,CAAU;AAAA,IACxC,GAEA;AAAA,EACF,GAAG,CAAC7C,GAASC,GAAkBC,GAAQmB,GAAyBoB,GAAUrC,CAAY,CAAC,GAEnFsB,KACA,OAAO,KAAKgB,CAAwB,EAAE,WAAW,IAAU,OAExD,gBAAAlC,EAACyC,GAAA,EAAgB,UAAUP,GAA0B,WAAArC,EAAA,CAAsB;AACpF;"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as r } from "react/jsx-runtime";
|
|
2
|
-
import { generateResponseExampleMap as m } from "
|
|
3
|
-
import { mapResponseExamples as i } from "
|
|
2
|
+
import { generateResponseExampleMap as m } from "../../generators/generateResponseExampleMap.js";
|
|
3
|
+
import { mapResponseExamples as i } from "../../schemaGraph/utils.js";
|
|
4
4
|
import { CodeGroupSelect as u } from "../../../components/content-components/CodeGroupSelect/index.js";
|
|
5
5
|
import { CodeSnippets as d } from "../../../components/content-components/code-snippets.js";
|
|
6
6
|
const C = ({
|
|
@@ -1,89 +1,89 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { useState as
|
|
3
|
-
import { initialApiPlaygroundInputs as
|
|
4
|
-
import { generateSnippetMap as
|
|
5
|
-
import { CodeGroupSelect as
|
|
6
|
-
import { CodeSnippets as
|
|
7
|
-
import { CodeBlock as
|
|
8
|
-
import { CodeGroup as
|
|
9
|
-
import { prismLangToDisplayLang as
|
|
10
|
-
import { useApiPlaygroundDisplay as
|
|
11
|
-
import { GeneratedRequestExample as
|
|
1
|
+
import { jsx as l } from "react/jsx-runtime";
|
|
2
|
+
import { useState as q, useEffect as y } from "react";
|
|
3
|
+
import { initialApiPlaygroundInputs as E } from "../../constants/index.js";
|
|
4
|
+
import { generateSnippetMap as x } from "../../generators/generateSnippetMap.js";
|
|
5
|
+
import { CodeGroupSelect as M } from "../../../components/content-components/CodeGroupSelect/index.js";
|
|
6
|
+
import { CodeSnippets as O } from "../../../components/content-components/code-snippets.js";
|
|
7
|
+
import { CodeBlock as T } from "../../../components/content-components/code-block.js";
|
|
8
|
+
import { CodeGroup as U } from "../../../components/content-components/code-group.js";
|
|
9
|
+
import { prismLangToDisplayLang as j } from "../../../constants/prism-languages.js";
|
|
10
|
+
import { useApiPlaygroundDisplay as w } from "../../../hooks/useApiPlaygroundDisplay.js";
|
|
11
|
+
import { GeneratedRequestExample as C } from "./GeneratedRequestExample.js";
|
|
12
12
|
const F = ({
|
|
13
13
|
apiReferenceData: o,
|
|
14
|
-
inputs: m =
|
|
15
|
-
maxHeight:
|
|
14
|
+
inputs: m = E,
|
|
15
|
+
maxHeight: p
|
|
16
16
|
}) => {
|
|
17
17
|
var r, s, c, e, g;
|
|
18
|
-
const
|
|
18
|
+
const u = (r = o.operation) == null ? void 0 : r.requestExamples, a = w(), i = (s = o.operation) == null ? void 0 : s.requestExampleLanguages, t = (c = o.operation) == null ? void 0 : c.requiredOnlyExamples, d = (e = o.operation) == null ? void 0 : e.requestExampleType;
|
|
19
19
|
switch (console.log("requestExampleType", d), (g = o.operation) == null ? void 0 : g.requestExampleType) {
|
|
20
20
|
case "mdx":
|
|
21
|
-
if (!
|
|
22
|
-
const f =
|
|
23
|
-
return /* @__PURE__ */
|
|
24
|
-
|
|
21
|
+
if (!u) return null;
|
|
22
|
+
const f = u.some((n) => n.dropdown ?? !1);
|
|
23
|
+
return /* @__PURE__ */ l(U, { isSmallText: !0, dropdown: f, noMargins: !0, className: p, children: u.map((n, b) => /* @__PURE__ */ l(
|
|
24
|
+
T,
|
|
25
25
|
{
|
|
26
|
-
language:
|
|
27
|
-
fileName:
|
|
28
|
-
children: /* @__PURE__ */
|
|
26
|
+
language: n.language,
|
|
27
|
+
fileName: n.filename,
|
|
28
|
+
children: /* @__PURE__ */ l("span", { children: n.code })
|
|
29
29
|
},
|
|
30
|
-
|
|
30
|
+
`${n.filename}-${n.language}-${b}`
|
|
31
31
|
)) });
|
|
32
32
|
case "codeSamples":
|
|
33
|
-
return o.operation.codeSamples ? /* @__PURE__ */
|
|
34
|
-
|
|
33
|
+
return o.operation.codeSamples ? /* @__PURE__ */ l(
|
|
34
|
+
L,
|
|
35
35
|
{
|
|
36
36
|
apiReferenceData: o,
|
|
37
37
|
inputs: m,
|
|
38
38
|
apiPlaygroundDisplay: a,
|
|
39
39
|
requestExampleLanguages: i,
|
|
40
40
|
requiredOnly: t,
|
|
41
|
-
maxHeight:
|
|
41
|
+
maxHeight: p
|
|
42
42
|
}
|
|
43
43
|
) : null;
|
|
44
44
|
case "generated":
|
|
45
45
|
const S = o.operation.baseUrl ?? o.operation.baseUrlOptions[0];
|
|
46
|
-
return S ? /* @__PURE__ */
|
|
47
|
-
|
|
46
|
+
return S ? /* @__PURE__ */ l(
|
|
47
|
+
C,
|
|
48
48
|
{
|
|
49
49
|
apiReferenceData: o,
|
|
50
50
|
baseUrl: S,
|
|
51
51
|
inputs: m,
|
|
52
52
|
requestExampleLanguages: i,
|
|
53
53
|
requiredOnly: t,
|
|
54
|
-
maxHeight:
|
|
54
|
+
maxHeight: p
|
|
55
55
|
}
|
|
56
56
|
) : null;
|
|
57
57
|
}
|
|
58
|
-
},
|
|
58
|
+
}, L = ({
|
|
59
59
|
apiReferenceData: o,
|
|
60
60
|
inputs: m,
|
|
61
|
-
apiPlaygroundDisplay:
|
|
62
|
-
requestExampleLanguages:
|
|
61
|
+
apiPlaygroundDisplay: p,
|
|
62
|
+
requestExampleLanguages: u,
|
|
63
63
|
requiredOnly: a,
|
|
64
64
|
maxHeight: i
|
|
65
65
|
}) => {
|
|
66
|
-
const [t, d] =
|
|
67
|
-
if (
|
|
66
|
+
const [t, d] = q(null);
|
|
67
|
+
if (y(() => {
|
|
68
68
|
var r;
|
|
69
|
-
(r = o.operation) != null && r.codeSamples &&
|
|
69
|
+
(r = o.operation) != null && r.codeSamples && x({
|
|
70
70
|
apiReferenceData: o,
|
|
71
71
|
codeSamples: o.operation.codeSamples,
|
|
72
72
|
baseUrl: o.operation.baseUrl ?? o.operation.baseUrlOptions[0],
|
|
73
|
-
apiPlaygroundMode:
|
|
74
|
-
requestExampleLanguages:
|
|
73
|
+
apiPlaygroundMode: p,
|
|
74
|
+
requestExampleLanguages: u,
|
|
75
75
|
requiredOnly: a,
|
|
76
76
|
inputs: m
|
|
77
77
|
}).then(d);
|
|
78
|
-
}, [o, m,
|
|
78
|
+
}, [o, m, p, u, a]), !t) return null;
|
|
79
79
|
if (Object.values(t).every((r) => Object.keys(r).length <= 1)) {
|
|
80
80
|
let s = Object.values(t).flatMap((e) => Object.values(e));
|
|
81
81
|
return new Set(s.map((e) => e.filename)).size !== s.length && (s = s.map((e) => ({
|
|
82
82
|
...e,
|
|
83
|
-
filename:
|
|
84
|
-
}))), /* @__PURE__ */
|
|
83
|
+
filename: j[e.language] ?? e.language
|
|
84
|
+
}))), /* @__PURE__ */ l(O, { snippets: s, dropdown: !0, maxHeight: i });
|
|
85
85
|
}
|
|
86
|
-
return /* @__PURE__ */
|
|
86
|
+
return /* @__PURE__ */ l(M, { snippets: t, maxHeight: i });
|
|
87
87
|
};
|
|
88
88
|
export {
|
|
89
89
|
F as RequestExample
|
|
@@ -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 console.log('requestExampleType', 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) => (\n <CodeBlock\n language={example.language}\n fileName={example.filename}\n key={example.filename}\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","requestExampleType","_d","_e","dropdown","example","jsx","CodeGroup","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,sBAE3CC,KAAqBC,IAAAb,EAAiB,cAAjB,gBAAAa,EAA4B;AAIvD,UAFA,QAAQ,IAAI,sBAAsBD,CAAkB,IAE5CE,IAAAd,EAAiB,cAAjB,gBAAAc,EAA4B,oBAAA;AAAA,IAClC,KAAK;AACH,UAAI,CAACV,EAAiB,QAAO;AAC7B,YAAMW,IAAWX,EAAgB,KAAK,CAACY,MAAyBA,EAAQ,YAAY,EAAK;AACzF,aACE,gBAAAC,EAACC,GAAA,EAAU,aAAW,IAAC,UAAAH,GAAoB,WAAS,IAAC,WAAWZ,GAC7D,UAAAC,EAAgB,IAAI,CAACY,
|
|
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 console.log('requestExampleType', 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","requestExampleType","_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,sBAE3CC,KAAqBC,IAAAb,EAAiB,cAAjB,gBAAAa,EAA4B;AAIvD,UAFA,QAAQ,IAAI,sBAAsBD,CAAkB,IAE5CE,IAAAd,EAAiB,cAAjB,gBAAAc,EAA4B,oBAAA;AAAA,IAClC,KAAK;AACH,UAAI,CAACV,EAAiB,QAAO;AAC7B,YAAMW,IAAWX,EAAgB,KAAK,CAACY,MAAyBA,EAAQ,YAAY,EAAK;AACzF,aACE,gBAAAC,EAACC,GAAA,EAAU,aAAW,IAAC,UAAAH,GAAoB,WAAS,IAAC,WAAWZ,GAC7D,UAAAC,EAAgB,IAAI,CAACY,GAAsBG,MAC1C,gBAAAF;AAAA,QAACG;AAAA,QAAA;AAAA,UACC,UAAUJ,EAAQ;AAAA,UAClB,UAAUA,EAAQ;AAAA,UAGlB,UAAA,gBAAAC,EAAC,QAAA,EAAM,UAAAD,EAAQ,K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,CAAC,GAEtF,CAACc,EAAY,QAAO;AAExB,MAAI,OAAO,OAAOA,CAAU,EAAE,MAAM,CAACK,MAAU,OAAO,KAAKA,CAAK,EAAE,UAAU,CAAC,GAAG;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,WAAA3B,GAAsB;AAAA,EAC1E;AAEA,SAAO,gBAAAc,EAACkB,GAAA,EAAgB,UAAUX,GAAY,WAAArB,EAAA,CAAsB;AACtE;"}
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { CodeBlock as
|
|
1
|
+
import { jsx as e } from "react/jsx-runtime";
|
|
2
|
+
import { CodeBlock as a } from "../../../components/content-components/code-block.js";
|
|
3
3
|
import { CodeGroup as i } from "../../../components/content-components/code-group.js";
|
|
4
|
-
import { GeneratedResponseExample as
|
|
5
|
-
const
|
|
4
|
+
import { GeneratedResponseExample as d } from "./GeneratedResponseExample.js";
|
|
5
|
+
const E = ({ apiReferenceData: r, maxHeight: s }) => {
|
|
6
6
|
var l, p;
|
|
7
7
|
const n = (l = r.operation) == null ? void 0 : l.responseExamples;
|
|
8
8
|
if (((p = r.operation) == null ? void 0 : p.responseExampleType) === "mdx") {
|
|
9
9
|
if (!n) return null;
|
|
10
|
-
const m = n.some((
|
|
11
|
-
return /* @__PURE__ */
|
|
10
|
+
const m = n.some((o) => o.dropdown ?? !1);
|
|
11
|
+
return /* @__PURE__ */ e(i, { isSmallText: !0, dropdown: m, noMargins: !0, className: s, children: n.map((o, t) => /* @__PURE__ */ e(a, { language: o.language, fileName: o.filename, children: /* @__PURE__ */ e("span", { children: o.code }) }, `${o.filename}-${o.language}-${t}`)) });
|
|
12
12
|
} else
|
|
13
|
-
return /* @__PURE__ */
|
|
13
|
+
return /* @__PURE__ */ e(d, { apiReferenceData: r, maxHeight: s });
|
|
14
14
|
};
|
|
15
15
|
export {
|
|
16
|
-
|
|
16
|
+
E as ResponseExample
|
|
17
17
|
};
|
|
18
18
|
//# sourceMappingURL=ResponseExample.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ResponseExample.js","sources":["../../../../src/api-playground-2/components/Example/ResponseExample.tsx"],"sourcesContent":["'use client';\n\nimport type { ApiReferenceDataV2, CodeExample } from '@/api-playground-2/types';\nimport { CodeBlock } from '../../../components/content-components/code-block';\nimport { CodeGroup } from '../../../components/content-components/code-group';\n\nimport { GeneratedResponseExample } from './GeneratedResponseExample';\n\nexport const ResponseExample = ({ apiReferenceData, maxHeight }: { apiReferenceData: ApiReferenceDataV2; maxHeight?: string }) => {\n const responseExamples = apiReferenceData.operation?.responseExamples;\n\n if (apiReferenceData.operation?.responseExampleType === 'mdx') {\n if (!responseExamples) return null;\n const dropdown = responseExamples.some((example: CodeExample) => example.dropdown ?? false);\n return (\n <CodeGroup isSmallText dropdown={dropdown} noMargins className={maxHeight}>\n {responseExamples.map((example: CodeExample) => (\n <CodeBlock language={example.language} fileName={example.filename} key={example.filename}>\n <span>{example.code}</span>\n </CodeBlock>\n ))}\n </CodeGroup>\n );\n } else {\n return <GeneratedResponseExample apiReferenceData={apiReferenceData} maxHeight={maxHeight} />;\n }\n};\n"],"names":["ResponseExample","apiReferenceData","maxHeight","responseExamples","_a","_b","dropdown","example","
|
|
1
|
+
{"version":3,"file":"ResponseExample.js","sources":["../../../../src/api-playground-2/components/Example/ResponseExample.tsx"],"sourcesContent":["'use client';\n\nimport type { ApiReferenceDataV2, CodeExample } from '@/api-playground-2/types';\nimport { CodeBlock } from '../../../components/content-components/code-block';\nimport { CodeGroup } from '../../../components/content-components/code-group';\n\nimport { GeneratedResponseExample } from './GeneratedResponseExample';\n\nexport const ResponseExample = ({ apiReferenceData, maxHeight }: { apiReferenceData: ApiReferenceDataV2; maxHeight?: string }) => {\n const responseExamples = apiReferenceData.operation?.responseExamples;\n\n if (apiReferenceData.operation?.responseExampleType === 'mdx') {\n if (!responseExamples) return null;\n const dropdown = responseExamples.some((example: CodeExample) => example.dropdown ?? false);\n return (\n <CodeGroup isSmallText dropdown={dropdown} noMargins className={maxHeight}>\n {responseExamples.map((example: CodeExample, index) => (\n <CodeBlock language={example.language} fileName={example.filename} key={`${example.filename}-${example.language}-${index}`}>\n <span>{example.code}</span>\n </CodeBlock>\n ))}\n </CodeGroup>\n );\n } else {\n return <GeneratedResponseExample apiReferenceData={apiReferenceData} maxHeight={maxHeight} />;\n }\n};\n"],"names":["ResponseExample","apiReferenceData","maxHeight","responseExamples","_a","_b","dropdown","example","CodeGroup","index","jsx","CodeBlock","GeneratedResponseExample"],"mappings":";;;;AAQO,MAAMA,IAAkB,CAAC,EAAE,kBAAAC,GAAkB,WAAAC,QAA8E;;AAChI,QAAMC,KAAmBC,IAAAH,EAAiB,cAAjB,gBAAAG,EAA4B;AAErD,QAAIC,IAAAJ,EAAiB,cAAjB,gBAAAI,EAA4B,yBAAwB,OAAO;AAC7D,QAAI,CAACF,EAAkB,QAAO;AAC9B,UAAMG,IAAWH,EAAiB,KAAK,CAACI,MAAyBA,EAAQ,YAAY,EAAK;AAC1F,6BACGC,GAAA,EAAU,aAAW,IAAC,UAAAF,GAAoB,WAAS,IAAC,WAAWJ,GAC7D,UAAAC,EAAiB,IAAI,CAACI,GAAsBE,MAC3C,gBAAAC,EAACC,KAAU,UAAUJ,EAAQ,UAAU,UAAUA,EAAQ,UACvD,UAAA,gBAAAG,EAAC,QAAA,EAAM,UAAAH,EAAQ,MAAK,EAAA,GADkD,GAAGA,EAAQ,QAAQ,IAAIA,EAAQ,QAAQ,IAAIE,CAAK,EAExH,CACD,GACH;AAAA,EAEJ;AACE,WAAO,gBAAAC,EAACE,GAAA,EAAyB,kBAAAX,GAAoC,WAAAC,EAAA,CAAsB;AAE/F;"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
const e = {
|
|
2
|
+
server: {},
|
|
3
|
+
path: {},
|
|
4
|
+
query: {},
|
|
5
|
+
header: {},
|
|
6
|
+
cookie: {},
|
|
7
|
+
body: void 0
|
|
8
|
+
}, o = {
|
|
9
|
+
server: "server",
|
|
10
|
+
path: "path",
|
|
11
|
+
query: "query",
|
|
12
|
+
header: "header",
|
|
13
|
+
cookie: "cookie",
|
|
14
|
+
body: "body"
|
|
15
|
+
};
|
|
16
|
+
export {
|
|
17
|
+
o as apiPlaygroundInputKeys,
|
|
18
|
+
e as initialApiPlaygroundInputs
|
|
19
|
+
};
|
|
20
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../src/api-playground-2/constants/index.ts"],"sourcesContent":["import { ApiPlaygroundInputs } from '@mintlify/validation';\n\nexport const MAX_RECURSION_DEPTH = 10;\nexport const MAX_SCHEMA_COMBINATION_SIZE = 1000;\nexport const CIRCULAR_REF_KEY = '$circularRef';\nexport const stringFileFormats = ['binary', 'base64'];\n\nexport const combinationKeys = [\n 'properties',\n 'additionalProperties',\n 'items',\n 'oneOf',\n 'anyOf',\n 'allOf',\n];\n\n// duplicated from ApiPlaygroundInputsContext.tsx\nexport const initialApiPlaygroundInputs: ApiPlaygroundInputs = {\n server: {},\n path: {},\n query: {},\n header: {},\n cookie: {},\n body: undefined,\n};\n\nexport const apiPlaygroundInputKeys = {\n server: 'server',\n path: 'path',\n query: 'query',\n header: 'header',\n cookie: 'cookie',\n body: 'body',\n};\n"],"names":["initialApiPlaygroundInputs","apiPlaygroundInputKeys"],"mappings":"AAiBO,MAAMA,IAAkD;AAAA,EAC7D,QAAQ,CAAA;AAAA,EACR,MAAM,CAAA;AAAA,EACN,OAAO,CAAA;AAAA,EACP,QAAQ,CAAA;AAAA,EACR,QAAQ,CAAA;AAAA,EACR,MAAM;AACR,GAEaC,IAAyB;AAAA,EACpC,QAAQ;AAAA,EACR,MAAM;AAAA,EACN,OAAO;AAAA,EACP,QAAQ;AAAA,EACR,QAAQ;AAAA,EACR,MAAM;AACR;"}
|