@mintlify/msft-sdk 1.1.24 → 1.1.25
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/Request/PlaygroundModal.js +46 -45
- package/dist/api-playground/ApiPlayground/Request/PlaygroundModal.js.map +1 -1
- package/dist/api-playground/ApiPlayground/Request/index.js +18 -18
- package/dist/api-playground/ApiPlayground/Request/index.js.map +1 -1
- package/dist/api-playground/ApiPlayground/components/EndpointsMenu.js +20 -21
- package/dist/api-playground/ApiPlayground/components/EndpointsMenu.js.map +1 -1
- package/dist/api-playground/ApiPlayground/components/EndpointsMenuLink.js +10 -11
- package/dist/api-playground/ApiPlayground/components/EndpointsMenuLink.js.map +1 -1
- package/dist/api-playground/ApiPlayground/index.js +30 -30
- package/dist/api-playground/ApiPlayground/index.js.map +1 -1
- package/dist/api-playground-2/constants/index.js +12 -3
- package/dist/api-playground-2/constants/index.js.map +1 -1
- package/dist/api-playground-2/schemaGraph/addUniqueKeysToSchema.js +41 -0
- package/dist/api-playground-2/schemaGraph/addUniqueKeysToSchema.js.map +1 -0
- package/dist/api-playground-2/schemaGraph/errors.js +19 -0
- package/dist/api-playground-2/schemaGraph/errors.js.map +1 -0
- package/dist/api-playground-2/schemaGraph/getApiReferenceDataFromGraph.js +26 -0
- package/dist/api-playground-2/schemaGraph/getApiReferenceDataFromGraph.js.map +1 -0
- package/dist/api-playground-2/schemaGraph/getDocumentProperties.js +58 -0
- package/dist/api-playground-2/schemaGraph/getDocumentProperties.js.map +1 -0
- package/dist/api-playground-2/schemaGraph/getSchemaGraphOperationData.js +77 -0
- package/dist/api-playground-2/schemaGraph/getSchemaGraphOperationData.js.map +1 -0
- package/dist/api-playground-2/schemaGraph/getSchemaGraphSchemaData.js +16 -0
- package/dist/api-playground-2/schemaGraph/getSchemaGraphSchemaData.js.map +1 -0
- package/dist/api-playground-2/schemaGraph/processExamples.js +111 -34
- package/dist/api-playground-2/schemaGraph/processExamples.js.map +1 -1
- package/dist/api-playground-2/schemaGraph/reduceCompositions.js +283 -0
- package/dist/api-playground-2/schemaGraph/reduceCompositions.js.map +1 -0
- package/dist/api-playground-2/schemaGraph/resolveGraphNode.js +61 -0
- package/dist/api-playground-2/schemaGraph/resolveGraphNode.js.map +1 -0
- package/dist/api-playground-2/schemaGraph/resolveOperationWithDependencies.js +149 -0
- package/dist/api-playground-2/schemaGraph/resolveOperationWithDependencies.js.map +1 -0
- package/dist/api-playground-2/schemaGraph/resolveSchemaWithDependencies.js +33 -0
- package/dist/api-playground-2/schemaGraph/resolveSchemaWithDependencies.js.map +1 -0
- package/dist/api-playground-2/schemaGraph/sortSchemaByRequired.js +35 -0
- package/dist/api-playground-2/schemaGraph/sortSchemaByRequired.js.map +1 -0
- package/dist/api-playground-2/schemaGraph/utils.js +144 -98
- package/dist/api-playground-2/schemaGraph/utils.js.map +1 -1
- package/dist/common/parseApiTargetFromMetadata.js +24 -0
- package/dist/common/parseApiTargetFromMetadata.js.map +1 -0
- package/dist/common/parseOpenApiString.js +42 -0
- package/dist/common/parseOpenApiString.js.map +1 -0
- package/dist/components/Api/ApiReferenceProvider.js +6 -15
- package/dist/components/Api/ApiReferenceProvider.js.map +1 -1
- package/dist/components/nav-tree/index.js +135 -109
- package/dist/components/nav-tree/index.js.map +1 -1
- package/dist/contexts/ConfigContext.js +61 -12
- package/dist/contexts/ConfigContext.js.map +1 -1
- package/dist/contexts/MDXContentContext.js +0 -1
- package/dist/contexts/MDXContentContext.js.map +1 -1
- package/dist/index.d.ts +125 -9
- package/dist/index.js +156 -144
- package/dist/index.js.map +1 -1
- package/dist/styles.css +1 -1
- package/package.json +1 -1
- package/dist/hooks/useCurrentPath.js +0 -17
- package/dist/hooks/useCurrentPath.js.map +0 -1
- package/dist/utils/decodeSlug.js +0 -8
- package/dist/utils/decodeSlug.js.map +0 -1
- package/dist/utils/optionallyAddLeadingSlash.js +0 -7
- package/dist/utils/optionallyAddLeadingSlash.js.map +0 -1
|
@@ -1,32 +1,32 @@
|
|
|
1
1
|
import { jsx as s } from "react/jsx-runtime";
|
|
2
|
-
import { useContext as
|
|
3
|
-
import { DocsConfigContext as
|
|
4
|
-
import { EndpointLocationProvider as
|
|
5
|
-
import { useBaseUrlOptions as
|
|
2
|
+
import { useContext as U, useState as n, useEffect as b } from "react";
|
|
3
|
+
import { DocsConfigContext as L } from "../../contexts/ConfigContext.js";
|
|
4
|
+
import { EndpointLocationProvider as T } from "../../contexts/EndpointLocationContext.js";
|
|
5
|
+
import { useBaseUrlOptions as j } from "../../hooks/useBaseUrlOptions.js";
|
|
6
6
|
import { useKeyboardShortcut as y } from "../../hooks/useKeyboardShortcut.js";
|
|
7
|
-
import { useApiPlaygroundInputs as
|
|
8
|
-
import { useSetApiBaseIndexCallback as
|
|
9
|
-
import { useSetApiPlaygroundInputsCallback as
|
|
10
|
-
import { useSendPlaygroundRequest as
|
|
11
|
-
import
|
|
12
|
-
import { ApiPlaygroundContext as
|
|
13
|
-
import { Request as
|
|
14
|
-
const
|
|
7
|
+
import { useApiPlaygroundInputs as F } from "../../hooks/useMDXContentController/useApiPlaygroundInputs.js";
|
|
8
|
+
import { useSetApiBaseIndexCallback as K } from "../../hooks/useMDXContentController/useMDXContentCallbacks/useSetApiBaseIndexCallback.js";
|
|
9
|
+
import { useSetApiPlaygroundInputsCallback as D } from "../../hooks/useMDXContentController/useMDXContentCallbacks/useSetApiPlaygroundInputsCallback.js";
|
|
10
|
+
import { useSendPlaygroundRequest as N } from "../../hooks/useSendPlaygroundRequest.js";
|
|
11
|
+
import Q from "../../components/Api/ErrorBoundary.js";
|
|
12
|
+
import { ApiPlaygroundContext as W } from "./ApiPlaygroundContext.js";
|
|
13
|
+
import { Request as _ } from "./Request/index.js";
|
|
14
|
+
const oe = ({ endpoint: r, display: f, pathname: x }) => {
|
|
15
15
|
var m, p;
|
|
16
|
-
const { docsConfig: a } =
|
|
17
|
-
|
|
16
|
+
const { docsConfig: a } = U(L), h = F(), I = D(), g = K(), e = j(), [c, P] = n(0), [l, i] = n(!1), [S, w] = n(!1), [E, B] = n(), [k, z] = n(0), v = Object.keys(r.request.body)[k], [A, C] = n(0), R = (e == null ? void 0 : e[c]) ?? (e == null ? void 0 : e[0]) ?? "";
|
|
17
|
+
b(() => {
|
|
18
18
|
new URLSearchParams(window.location.search).has("playground") && requestAnimationFrame(() => {
|
|
19
19
|
i(!0);
|
|
20
20
|
});
|
|
21
21
|
}, []);
|
|
22
|
-
const d =
|
|
22
|
+
const d = N({
|
|
23
23
|
endpoint: r,
|
|
24
|
-
baseUrl:
|
|
25
|
-
contentType:
|
|
26
|
-
setIsFetching:
|
|
27
|
-
setResult:
|
|
28
|
-
}),
|
|
29
|
-
|
|
24
|
+
baseUrl: R,
|
|
25
|
+
contentType: v ?? "application/json",
|
|
26
|
+
setIsFetching: w,
|
|
27
|
+
setResult: B
|
|
28
|
+
}), q = (t) => {
|
|
29
|
+
P(t), g(t);
|
|
30
30
|
}, u = (t) => {
|
|
31
31
|
if (i(t), t) {
|
|
32
32
|
const o = new URL(window.location.href);
|
|
@@ -43,26 +43,26 @@ const ne = ({ endpoint: r, display: f }) => {
|
|
|
43
43
|
key: "Escape",
|
|
44
44
|
callback: l ? () => u(!1) : void 0,
|
|
45
45
|
isSingleKey: !0
|
|
46
|
-
}), /* @__PURE__ */ s(
|
|
47
|
-
|
|
46
|
+
}), /* @__PURE__ */ s(Q, { children: /* @__PURE__ */ s(
|
|
47
|
+
W.Provider,
|
|
48
48
|
{
|
|
49
49
|
value: {
|
|
50
|
-
isSending:
|
|
50
|
+
isSending: S,
|
|
51
51
|
sendRequest: d,
|
|
52
|
-
result:
|
|
53
|
-
setSelectedBaseUrlIndex:
|
|
52
|
+
result: E,
|
|
53
|
+
setSelectedBaseUrlIndex: q,
|
|
54
54
|
selectedBaseUrlIndex: c,
|
|
55
55
|
baseUrlOptions: e,
|
|
56
56
|
isPlaygroundExpanded: l,
|
|
57
57
|
setIsPlaygroundExpanded: u,
|
|
58
|
-
selectedExampleIndex:
|
|
59
|
-
setSelectedExampleIndex:
|
|
58
|
+
selectedExampleIndex: A,
|
|
59
|
+
setSelectedExampleIndex: C
|
|
60
60
|
},
|
|
61
|
-
children: /* @__PURE__ */ s("div", { className: "mint:mt-6 mint:flex mint:w-full mint:flex-col mint:space-y-4", children: /* @__PURE__ */ s(
|
|
61
|
+
children: /* @__PURE__ */ s("div", { className: "mint:mt-6 mint:flex mint:w-full mint:flex-col mint:space-y-4", children: /* @__PURE__ */ s(T, { location: "request", children: /* @__PURE__ */ s(_, { inputs: h, setInputs: I, endpoint: r, display: f, pathname: x }) }) })
|
|
62
62
|
}
|
|
63
63
|
) });
|
|
64
64
|
};
|
|
65
65
|
export {
|
|
66
|
-
|
|
66
|
+
oe as ApiPlayground
|
|
67
67
|
};
|
|
68
68
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../src/api-playground/ApiPlayground/index.tsx"],"sourcesContent":["'use client';\n\nimport { ApiPlaygroundResultType, ApiPlaygroundDisplayType } from '@mintlify/models';\nimport { Endpoint } from '@mintlify/validation';\nimport { useContext, useEffect, useState } from 'react';\n\nimport { DocsConfigContext } from '@/contexts/ConfigContext';\nimport { EndpointLocationProvider } from '@/contexts/EndpointLocationContext';\nimport { useBaseUrlOptions } from '../../hooks/useBaseUrlOptions';\nimport { useKeyboardShortcut } from '@/hooks/useKeyboardShortcut';\nimport { useApiPlaygroundInputs } from '@/hooks/useMDXContentController/useApiPlaygroundInputs';\nimport { useSetApiBaseIndexCallback } from '@/hooks/useMDXContentController/useMDXContentCallbacks/useSetApiBaseIndexCallback';\nimport { useSetApiPlaygroundInputsCallback } from '@/hooks/useMDXContentController/useMDXContentCallbacks/useSetApiPlaygroundInputsCallback';\nimport { useSendPlaygroundRequest } from '@/hooks/useSendPlaygroundRequest';\nimport ErrorBoundary from '@/components/Api/ErrorBoundary';\n\nimport { ApiPlaygroundContext } from './ApiPlaygroundContext';\nimport { Request } from './Request';\nimport { cn } from \"../../utils/cn\";\n\ntype ApiPlaygroundParams = {\n endpoint: Endpoint;\n display: ApiPlaygroundDisplayType;\n};\n\nexport const ApiPlayground = ({ endpoint, display }: ApiPlaygroundParams) => {\n const { docsConfig } = useContext(DocsConfigContext);\n const inputs = useApiPlaygroundInputs();\n const setInputs = useSetApiPlaygroundInputsCallback();\n const setApiBaseIndex = useSetApiBaseIndexCallback();\n\n const baseUrlOptions = useBaseUrlOptions();\n const [selectedBaseUrlIndex, setSelectedBaseUrlIndex] = useState(0);\n const [isPlaygroundExpanded, setIsPlaygroundExpanded] = useState(false);\n\n const [isSending, setIsSending] = useState(false);\n const [result, setResult] = useState<ApiPlaygroundResultType>();\n\n const [selectedContentTypeIndex, _setSelectedContentTypeIndex] = useState(0);\n const contentType = Object.keys(endpoint.request.body)[selectedContentTypeIndex];\n const [selectedExampleIndex, setSelectedExampleIndex] = useState(0);\n\n const baseUrl = baseUrlOptions?.[selectedBaseUrlIndex] ?? baseUrlOptions?.[0] ?? '';\n\n useEffect(() => {\n const searchParams = new URLSearchParams(window.location.search);\n if (searchParams.has('playground')) {\n requestAnimationFrame(() => {\n setIsPlaygroundExpanded(true);\n });\n }\n }, []);\n\n const sendRequest = useSendPlaygroundRequest({\n endpoint,\n baseUrl,\n contentType: contentType ?? 'application/json',\n setIsFetching: setIsSending,\n setResult,\n });\n\n const setBaseUrlIndex = (index: number) => {\n setSelectedBaseUrlIndex(index);\n setApiBaseIndex(index);\n };\n\n const setIsPlaygroundExpandedWithQueryParam = (expanded: boolean) => {\n setIsPlaygroundExpanded(expanded);\n if (expanded) {\n const url = new URL(window.location.href);\n url.searchParams.set('playground', 'open');\n window.history.replaceState({}, '', url);\n } else {\n const url = new URL(window.location.href);\n url.searchParams.delete('playground');\n window.history.replaceState({}, '', url);\n }\n };\n\n useKeyboardShortcut({\n key: 'Enter',\n callback: docsConfig?.api?.playground?.display === 'interactive' ? sendRequest : undefined,\n });\n useKeyboardShortcut({\n key: 'Escape',\n callback: isPlaygroundExpanded ? () => setIsPlaygroundExpandedWithQueryParam(false) : undefined,\n isSingleKey: true,\n });\n\n return (\n <ErrorBoundary>\n <ApiPlaygroundContext.Provider\n value={{\n isSending,\n sendRequest,\n result,\n setSelectedBaseUrlIndex: setBaseUrlIndex,\n selectedBaseUrlIndex,\n baseUrlOptions,\n isPlaygroundExpanded,\n setIsPlaygroundExpanded: setIsPlaygroundExpandedWithQueryParam,\n selectedExampleIndex,\n setSelectedExampleIndex,\n }}\n >\n <div className=\"mint:mt-6 mint:flex mint:w-full mint:flex-col mint:space-y-4\">\n <EndpointLocationProvider location=\"request\">\n <Request inputs={inputs} setInputs={setInputs} endpoint={endpoint} display={display} />\n </EndpointLocationProvider>\n </div>\n </ApiPlaygroundContext.Provider>\n </ErrorBoundary>\n );\n};\n"],"names":["ApiPlayground","endpoint","display","docsConfig","useContext","DocsConfigContext","inputs","useApiPlaygroundInputs","setInputs","useSetApiPlaygroundInputsCallback","setApiBaseIndex","useSetApiBaseIndexCallback","baseUrlOptions","useBaseUrlOptions","selectedBaseUrlIndex","setSelectedBaseUrlIndex","useState","isPlaygroundExpanded","setIsPlaygroundExpanded","isSending","setIsSending","result","setResult","selectedContentTypeIndex","_setSelectedContentTypeIndex","contentType","selectedExampleIndex","setSelectedExampleIndex","baseUrl","useEffect","sendRequest","useSendPlaygroundRequest","setBaseUrlIndex","index","setIsPlaygroundExpandedWithQueryParam","expanded","url","useKeyboardShortcut","_b","_a","ErrorBoundary","jsx","ApiPlaygroundContext","EndpointLocationProvider","Request"],"mappings":";;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../src/api-playground/ApiPlayground/index.tsx"],"sourcesContent":["'use client';\n\nimport { ApiPlaygroundResultType, ApiPlaygroundDisplayType } from '@mintlify/models';\nimport { Endpoint } from '@mintlify/validation';\nimport { useContext, useEffect, useState } from 'react';\n\nimport { DocsConfigContext } from '@/contexts/ConfigContext';\nimport { EndpointLocationProvider } from '@/contexts/EndpointLocationContext';\nimport { useBaseUrlOptions } from '../../hooks/useBaseUrlOptions';\nimport { useKeyboardShortcut } from '@/hooks/useKeyboardShortcut';\nimport { useApiPlaygroundInputs } from '@/hooks/useMDXContentController/useApiPlaygroundInputs';\nimport { useSetApiBaseIndexCallback } from '@/hooks/useMDXContentController/useMDXContentCallbacks/useSetApiBaseIndexCallback';\nimport { useSetApiPlaygroundInputsCallback } from '@/hooks/useMDXContentController/useMDXContentCallbacks/useSetApiPlaygroundInputsCallback';\nimport { useSendPlaygroundRequest } from '@/hooks/useSendPlaygroundRequest';\nimport ErrorBoundary from '@/components/Api/ErrorBoundary';\n\nimport { ApiPlaygroundContext } from './ApiPlaygroundContext';\nimport { Request } from './Request';\nimport { cn } from \"../../utils/cn\";\n\ntype ApiPlaygroundParams = {\n endpoint: Endpoint;\n display: ApiPlaygroundDisplayType;\n pathname: string;\n};\n\nexport const ApiPlayground = ({ endpoint, display, pathname }: ApiPlaygroundParams) => {\n const { docsConfig } = useContext(DocsConfigContext);\n const inputs = useApiPlaygroundInputs();\n const setInputs = useSetApiPlaygroundInputsCallback();\n const setApiBaseIndex = useSetApiBaseIndexCallback();\n\n const baseUrlOptions = useBaseUrlOptions();\n const [selectedBaseUrlIndex, setSelectedBaseUrlIndex] = useState(0);\n const [isPlaygroundExpanded, setIsPlaygroundExpanded] = useState(false);\n\n const [isSending, setIsSending] = useState(false);\n const [result, setResult] = useState<ApiPlaygroundResultType>();\n\n const [selectedContentTypeIndex, _setSelectedContentTypeIndex] = useState(0);\n const contentType = Object.keys(endpoint.request.body)[selectedContentTypeIndex];\n const [selectedExampleIndex, setSelectedExampleIndex] = useState(0);\n\n const baseUrl = baseUrlOptions?.[selectedBaseUrlIndex] ?? baseUrlOptions?.[0] ?? '';\n\n useEffect(() => {\n const searchParams = new URLSearchParams(window.location.search);\n if (searchParams.has('playground')) {\n requestAnimationFrame(() => {\n setIsPlaygroundExpanded(true);\n });\n }\n }, []);\n\n const sendRequest = useSendPlaygroundRequest({\n endpoint,\n baseUrl,\n contentType: contentType ?? 'application/json',\n setIsFetching: setIsSending,\n setResult,\n });\n\n const setBaseUrlIndex = (index: number) => {\n setSelectedBaseUrlIndex(index);\n setApiBaseIndex(index);\n };\n\n const setIsPlaygroundExpandedWithQueryParam = (expanded: boolean) => {\n setIsPlaygroundExpanded(expanded);\n if (expanded) {\n const url = new URL(window.location.href);\n url.searchParams.set('playground', 'open');\n window.history.replaceState({}, '', url);\n } else {\n const url = new URL(window.location.href);\n url.searchParams.delete('playground');\n window.history.replaceState({}, '', url);\n }\n };\n\n useKeyboardShortcut({\n key: 'Enter',\n callback: docsConfig?.api?.playground?.display === 'interactive' ? sendRequest : undefined,\n });\n useKeyboardShortcut({\n key: 'Escape',\n callback: isPlaygroundExpanded ? () => setIsPlaygroundExpandedWithQueryParam(false) : undefined,\n isSingleKey: true,\n });\n\n return (\n <ErrorBoundary>\n <ApiPlaygroundContext.Provider\n value={{\n isSending,\n sendRequest,\n result,\n setSelectedBaseUrlIndex: setBaseUrlIndex,\n selectedBaseUrlIndex,\n baseUrlOptions,\n isPlaygroundExpanded,\n setIsPlaygroundExpanded: setIsPlaygroundExpandedWithQueryParam,\n selectedExampleIndex,\n setSelectedExampleIndex,\n }}\n >\n <div className=\"mint:mt-6 mint:flex mint:w-full mint:flex-col mint:space-y-4\">\n <EndpointLocationProvider location=\"request\">\n <Request inputs={inputs} setInputs={setInputs} endpoint={endpoint} display={display} pathname={pathname} />\n </EndpointLocationProvider>\n </div>\n </ApiPlaygroundContext.Provider>\n </ErrorBoundary>\n );\n};\n"],"names":["ApiPlayground","endpoint","display","pathname","docsConfig","useContext","DocsConfigContext","inputs","useApiPlaygroundInputs","setInputs","useSetApiPlaygroundInputsCallback","setApiBaseIndex","useSetApiBaseIndexCallback","baseUrlOptions","useBaseUrlOptions","selectedBaseUrlIndex","setSelectedBaseUrlIndex","useState","isPlaygroundExpanded","setIsPlaygroundExpanded","isSending","setIsSending","result","setResult","selectedContentTypeIndex","_setSelectedContentTypeIndex","contentType","selectedExampleIndex","setSelectedExampleIndex","baseUrl","useEffect","sendRequest","useSendPlaygroundRequest","setBaseUrlIndex","index","setIsPlaygroundExpandedWithQueryParam","expanded","url","useKeyboardShortcut","_b","_a","ErrorBoundary","jsx","ApiPlaygroundContext","EndpointLocationProvider","Request"],"mappings":";;;;;;;;;;;;;AA0BO,MAAMA,KAAgB,CAAC,EAAE,UAAAC,GAAU,SAAAC,GAAS,UAAAC,QAAoC;;AACrF,QAAM,EAAE,YAAAC,EAAA,IAAeC,EAAWC,CAAiB,GAC7CC,IAASC,EAAA,GACTC,IAAYC,EAAA,GACZC,IAAkBC,EAAA,GAElBC,IAAiBC,EAAA,GACjB,CAACC,GAAsBC,CAAuB,IAAIC,EAAS,CAAC,GAC5D,CAACC,GAAsBC,CAAuB,IAAIF,EAAS,EAAK,GAEhE,CAACG,GAAWC,CAAY,IAAIJ,EAAS,EAAK,GAC1C,CAACK,GAAQC,CAAS,IAAIN,EAAA,GAEtB,CAACO,GAA0BC,CAA4B,IAAIR,EAAS,CAAC,GACrES,IAAc,OAAO,KAAKzB,EAAS,QAAQ,IAAI,EAAEuB,CAAwB,GACzE,CAACG,GAAsBC,CAAuB,IAAIX,EAAS,CAAC,GAE5DY,KAAUhB,KAAA,gBAAAA,EAAiBE,QAAyBF,KAAA,gBAAAA,EAAiB,OAAM;AAEjF,EAAAiB,EAAU,MAAM;AAEd,IADqB,IAAI,gBAAgB,OAAO,SAAS,MAAM,EAC9C,IAAI,YAAY,KAC/B,sBAAsB,MAAM;AAC1B,MAAAX,EAAwB,EAAI;AAAA,IAC9B,CAAC;AAAA,EAEL,GAAG,CAAA,CAAE;AAEL,QAAMY,IAAcC,EAAyB;AAAA,IAC3C,UAAA/B;AAAA,IACA,SAAA4B;AAAA,IACA,aAAaH,KAAe;AAAA,IAC5B,eAAeL;AAAA,IACf,WAAAE;AAAA,EAAA,CACD,GAEKU,IAAkB,CAACC,MAAkB;AACzC,IAAAlB,EAAwBkB,CAAK,GAC7BvB,EAAgBuB,CAAK;AAAA,EACvB,GAEMC,IAAwC,CAACC,MAAsB;AAEnE,QADAjB,EAAwBiB,CAAQ,GAC5BA,GAAU;AACZ,YAAMC,IAAM,IAAI,IAAI,OAAO,SAAS,IAAI;AACxC,MAAAA,EAAI,aAAa,IAAI,cAAc,MAAM,GACzC,OAAO,QAAQ,aAAa,CAAA,GAAI,IAAIA,CAAG;AAAA,IACzC,OAAO;AACL,YAAMA,IAAM,IAAI,IAAI,OAAO,SAAS,IAAI;AACxC,MAAAA,EAAI,aAAa,OAAO,YAAY,GACpC,OAAO,QAAQ,aAAa,CAAA,GAAI,IAAIA,CAAG;AAAA,IACzC;AAAA,EACF;AAEA,SAAAC,EAAoB;AAAA,IAClB,KAAK;AAAA,IACL,YAAUC,KAAAC,IAAApC,KAAA,gBAAAA,EAAY,QAAZ,gBAAAoC,EAAiB,eAAjB,gBAAAD,EAA6B,aAAY,gBAAgBR,IAAc;AAAA,EAAA,CAClF,GACDO,EAAoB;AAAA,IAClB,KAAK;AAAA,IACL,UAAUpB,IAAuB,MAAMiB,EAAsC,EAAK,IAAI;AAAA,IACtF,aAAa;AAAA,EAAA,CACd,qBAGEM,GAAA,EACC,UAAA,gBAAAC;AAAA,IAACC,EAAqB;AAAA,IAArB;AAAA,MACC,OAAO;AAAA,QACL,WAAAvB;AAAA,QACA,aAAAW;AAAA,QACA,QAAAT;AAAA,QACA,yBAAyBW;AAAA,QACzB,sBAAAlB;AAAA,QACA,gBAAAF;AAAA,QACA,sBAAAK;AAAA,QACA,yBAAyBiB;AAAA,QACzB,sBAAAR;AAAA,QACA,yBAAAC;AAAA,MAAA;AAAA,MAGF,4BAAC,OAAA,EAAI,WAAU,gEACb,UAAA,gBAAAc,EAACE,KAAyB,UAAS,WACjC,UAAA,gBAAAF,EAACG,GAAA,EAAQ,QAAAtC,GAAgB,WAAAE,GAAsB,UAAAR,GAAoB,SAAAC,GAAkB,UAAAC,GAAoB,GAC3G,EAAA,CACF;AAAA,IAAA;AAAA,EAAA,GAEJ;AAEJ;"}
|
|
@@ -1,4 +1,11 @@
|
|
|
1
|
-
const e = "$circularRef", r = ["binary", "base64"],
|
|
1
|
+
const e = 1e3, o = "$circularRef", r = ["binary", "base64"], i = [
|
|
2
|
+
"properties",
|
|
3
|
+
"additionalProperties",
|
|
4
|
+
"items",
|
|
5
|
+
"oneOf",
|
|
6
|
+
"anyOf",
|
|
7
|
+
"allOf"
|
|
8
|
+
], t = {
|
|
2
9
|
server: {},
|
|
3
10
|
path: {},
|
|
4
11
|
query: {},
|
|
@@ -14,9 +21,11 @@ const e = "$circularRef", r = ["binary", "base64"], o = {
|
|
|
14
21
|
body: "body"
|
|
15
22
|
};
|
|
16
23
|
export {
|
|
17
|
-
|
|
24
|
+
o as CIRCULAR_REF_KEY,
|
|
25
|
+
e as MAX_SCHEMA_COMBINATION_SIZE,
|
|
18
26
|
a as apiPlaygroundInputKeys,
|
|
19
|
-
|
|
27
|
+
i as combinationKeys,
|
|
28
|
+
t as initialApiPlaygroundInputs,
|
|
20
29
|
r as stringFileFormats
|
|
21
30
|
};
|
|
22
31
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +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":["CIRCULAR_REF_KEY","stringFileFormats","initialApiPlaygroundInputs","apiPlaygroundInputKeys"],"mappings":"
|
|
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":["MAX_SCHEMA_COMBINATION_SIZE","CIRCULAR_REF_KEY","stringFileFormats","combinationKeys","initialApiPlaygroundInputs","apiPlaygroundInputKeys"],"mappings":"AAGO,MAAMA,IAA8B,KAC9BC,IAAmB,gBACnBC,IAAoB,CAAC,UAAU,QAAQ,GAEvCC,IAAkB;AAAA,EAC7B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAGaC,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;"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { isSchemaObject as s, escapeDots as p } from "./utils.js";
|
|
2
|
+
const n = (d, o = "") => {
|
|
3
|
+
if (!s(d))
|
|
4
|
+
return d;
|
|
5
|
+
const e = {
|
|
6
|
+
...d,
|
|
7
|
+
uniqueKey: o
|
|
8
|
+
};
|
|
9
|
+
if (e.oneOf && Array.isArray(e.oneOf) && (e.oneOf = e.oneOf.map((t, i) => {
|
|
10
|
+
if (s(t)) {
|
|
11
|
+
const r = o ? `${o}.oneOf.${i}` : `${i}`;
|
|
12
|
+
return n(t, r);
|
|
13
|
+
}
|
|
14
|
+
return t;
|
|
15
|
+
})), e.type === "object" && e.properties) {
|
|
16
|
+
const t = {};
|
|
17
|
+
Object.entries(e.properties).forEach(([i, r]) => {
|
|
18
|
+
if (s(r)) {
|
|
19
|
+
const a = o ? `${o}.${p(i)}` : p(i);
|
|
20
|
+
t[i] = n(r, a);
|
|
21
|
+
} else
|
|
22
|
+
t[i] = r;
|
|
23
|
+
}), e.properties = t;
|
|
24
|
+
}
|
|
25
|
+
if (e.additionalProperties && typeof e.additionalProperties == "object" && s(e.additionalProperties)) {
|
|
26
|
+
const t = o ? `${o}.additionalProperties` : "additionalProperties";
|
|
27
|
+
e.additionalProperties = n(
|
|
28
|
+
e.additionalProperties,
|
|
29
|
+
t
|
|
30
|
+
);
|
|
31
|
+
}
|
|
32
|
+
if (e.type === "array" && "items" in e && s(e.items)) {
|
|
33
|
+
const t = o ? `${o}.items` : "items";
|
|
34
|
+
e.items = n(e.items, t);
|
|
35
|
+
}
|
|
36
|
+
return e;
|
|
37
|
+
};
|
|
38
|
+
export {
|
|
39
|
+
n as addUniqueKeysToSchema
|
|
40
|
+
};
|
|
41
|
+
//# sourceMappingURL=addUniqueKeysToSchema.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"addUniqueKeysToSchema.js","sources":["../../../src/api-playground-2/schemaGraph/addUniqueKeysToSchema.ts"],"sourcesContent":["import { SchemaObject } from '@mintlify/validation';\n\nimport { escapeDots, isSchemaObject } from '@/api-playground-2/schemaGraph/utils';\nimport type { ResolvedSchemaObject } from '@/api-playground-2/types';\n\n/**\n * Add unique keys to each schema node, representing the path from the root.\n * This is used to generate unique input keys for the playground data store.\n *\n * @param schema - The schema to process\n * @param pathPrefix - The current path prefix (e.g., \"body.application/json\")\n * @returns The schema with uniqueKey properties added\n */\nexport const addUniqueKeysToSchema = (\n schema: SchemaObject,\n pathPrefix: string = ''\n): ResolvedSchemaObject => {\n if (!isSchemaObject(schema)) {\n return schema;\n }\n\n const processedSchema: ResolvedSchemaObject = {\n ...schema,\n uniqueKey: pathPrefix,\n };\n\n if (processedSchema.oneOf && Array.isArray(processedSchema.oneOf)) {\n processedSchema.oneOf = processedSchema.oneOf.map((subSchema, index) => {\n if (isSchemaObject(subSchema)) {\n const subPath = pathPrefix ? `${pathPrefix}.oneOf.${index}` : `${index}`;\n return addUniqueKeysToSchema(subSchema, subPath);\n }\n return subSchema;\n });\n }\n\n if (processedSchema.type === 'object' && processedSchema.properties) {\n const processedProperties: Record<string, SchemaObject> = {};\n Object.entries(processedSchema.properties).forEach(([name, propSchema]) => {\n if (isSchemaObject(propSchema)) {\n const propPath = pathPrefix ? `${pathPrefix}.${escapeDots(name)}` : escapeDots(name);\n processedProperties[name] = addUniqueKeysToSchema(propSchema, propPath);\n } else {\n processedProperties[name] = propSchema;\n }\n });\n processedSchema.properties = processedProperties;\n }\n\n if (\n processedSchema.additionalProperties &&\n typeof processedSchema.additionalProperties === 'object' &&\n isSchemaObject(processedSchema.additionalProperties)\n ) {\n const addPropsPath = pathPrefix ? `${pathPrefix}.additionalProperties` : 'additionalProperties';\n processedSchema.additionalProperties = addUniqueKeysToSchema(\n processedSchema.additionalProperties,\n addPropsPath\n );\n }\n\n if (\n processedSchema.type === 'array' &&\n 'items' in processedSchema &&\n isSchemaObject(processedSchema.items)\n ) {\n const itemsPath = pathPrefix ? `${pathPrefix}.items` : 'items';\n processedSchema.items = addUniqueKeysToSchema(processedSchema.items, itemsPath);\n }\n\n return processedSchema;\n};\n"],"names":["addUniqueKeysToSchema","schema","pathPrefix","isSchemaObject","processedSchema","subSchema","index","subPath","processedProperties","name","propSchema","propPath","escapeDots","addPropsPath","itemsPath"],"mappings":";AAaO,MAAMA,IAAwB,CACnCC,GACAC,IAAqB,OACI;AACzB,MAAI,CAACC,EAAeF,CAAM;AACxB,WAAOA;AAGT,QAAMG,IAAwC;AAAA,IAC5C,GAAGH;AAAA,IACH,WAAWC;AAAA,EAAA;AAab,MAVIE,EAAgB,SAAS,MAAM,QAAQA,EAAgB,KAAK,MAC9DA,EAAgB,QAAQA,EAAgB,MAAM,IAAI,CAACC,GAAWC,MAAU;AACtE,QAAIH,EAAeE,CAAS,GAAG;AAC7B,YAAME,IAAUL,IAAa,GAAGA,CAAU,UAAUI,CAAK,KAAK,GAAGA,CAAK;AACtE,aAAON,EAAsBK,GAAWE,CAAO;AAAA,IACjD;AACA,WAAOF;AAAA,EACT,CAAC,IAGCD,EAAgB,SAAS,YAAYA,EAAgB,YAAY;AACnE,UAAMI,IAAoD,CAAA;AAC1D,WAAO,QAAQJ,EAAgB,UAAU,EAAE,QAAQ,CAAC,CAACK,GAAMC,CAAU,MAAM;AACzE,UAAIP,EAAeO,CAAU,GAAG;AAC9B,cAAMC,IAAWT,IAAa,GAAGA,CAAU,IAAIU,EAAWH,CAAI,CAAC,KAAKG,EAAWH,CAAI;AACnF,QAAAD,EAAoBC,CAAI,IAAIT,EAAsBU,GAAYC,CAAQ;AAAA,MACxE;AACE,QAAAH,EAAoBC,CAAI,IAAIC;AAAA,IAEhC,CAAC,GACDN,EAAgB,aAAaI;AAAA,EAC/B;AAEA,MACEJ,EAAgB,wBAChB,OAAOA,EAAgB,wBAAyB,YAChDD,EAAeC,EAAgB,oBAAoB,GACnD;AACA,UAAMS,IAAeX,IAAa,GAAGA,CAAU,0BAA0B;AACzE,IAAAE,EAAgB,uBAAuBJ;AAAA,MACrCI,EAAgB;AAAA,MAChBS;AAAA,IAAA;AAAA,EAEJ;AAEA,MACET,EAAgB,SAAS,WACzB,WAAWA,KACXD,EAAeC,EAAgB,KAAK,GACpC;AACA,UAAMU,IAAYZ,IAAa,GAAGA,CAAU,WAAW;AACvD,IAAAE,EAAgB,QAAQJ,EAAsBI,EAAgB,OAAOU,CAAS;AAAA,EAChF;AAEA,SAAOV;AACT;"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
const s = (r, ...e) => [r.map((o) => o.replace("\\", "\\\\").replace("/", "\\/")).join("/"), ...e].join(`
|
|
2
|
+
`);
|
|
3
|
+
class n extends Error {
|
|
4
|
+
constructor(e, ...t) {
|
|
5
|
+
super(s(e, ...t)), this.name = "ImpossibleSchemaError", Object.setPrototypeOf(this, n.prototype);
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
function a(r, e, t = !1, ...o) {
|
|
9
|
+
if (t)
|
|
10
|
+
console.error(s(e, ...o), r);
|
|
11
|
+
else
|
|
12
|
+
throw r;
|
|
13
|
+
}
|
|
14
|
+
export {
|
|
15
|
+
n as ImpossibleSchemaError,
|
|
16
|
+
s as generateMessage,
|
|
17
|
+
a as handleExistingError
|
|
18
|
+
};
|
|
19
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sources":["../../../src/api-playground-2/schemaGraph/errors.ts"],"sourcesContent":["// ERRORS\nexport const generateMessage = (path: string[], ...messages: string[]): string => {\n const pathString = path\n .map((component) => component.replace('\\\\', '\\\\\\\\').replace('/', '\\\\/'))\n .join('/');\n return [pathString, ...messages].join('\\n');\n};\n\n/**\n * Thrown when a value is incorrect or missing, according to the OpenAPI spec.\n */\nexport class InvalidSchemaError extends Error {\n constructor(path: string[], ...messages: string[]) {\n super(generateMessage(path, ...messages));\n this.name = 'InvalidSchemaError';\n Object.setPrototypeOf(this, InvalidSchemaError.prototype);\n }\n}\n\n/**\n * Thrown when a schema is valid according to OpenAPI, but is unsatisfiable\n * (e.g. a value that must be both a number and a string).\n */\nexport class ImpossibleSchemaError extends Error {\n constructor(path: string[], ...messages: string[]) {\n super(generateMessage(path, ...messages));\n this.name = 'ImpossibleSchemaError';\n Object.setPrototypeOf(this, ImpossibleSchemaError.prototype);\n }\n}\n\n/**\n * Thrown when there is an issue that was caused in another part of the conversion\n * (e.g. a schema in reduced form that is missing `oneOf`).\n */\nexport class ConversionError extends Error {\n constructor(path: string[], ...messages: string[]) {\n super(generateMessage(path, ...messages));\n this.name = 'ConversionError';\n Object.setPrototypeOf(this, ConversionError.prototype);\n }\n}\n\nexport function handleExistingError(\n error: unknown,\n path: string[],\n safeParse: boolean = false,\n ...messages: string[]\n) {\n if (safeParse) {\n console.error(generateMessage(path, ...messages), error);\n } else {\n throw error;\n }\n}\n"],"names":["generateMessage","path","messages","component","ImpossibleSchemaError","handleExistingError","error","safeParse"],"mappings":"AACO,MAAMA,IAAkB,CAACC,MAAmBC,MAI1C,CAHYD,EAChB,IAAI,CAACE,MAAcA,EAAU,QAAQ,MAAM,MAAM,EAAE,QAAQ,KAAK,KAAK,CAAC,EACtE,KAAK,GAAG,GACS,GAAGD,CAAQ,EAAE,KAAK;AAAA,CAAI;AAkBrC,MAAME,UAA8B,MAAM;AAAA,EAC/C,YAAYH,MAAmBC,GAAoB;AACjD,UAAMF,EAAgBC,GAAM,GAAGC,CAAQ,CAAC,GACxC,KAAK,OAAO,yBACZ,OAAO,eAAe,MAAME,EAAsB,SAAS;AAAA,EAC7D;AACF;AAcO,SAASC,EACdC,GACAL,GACAM,IAAqB,OAClBL,GACH;AACA,MAAIK;AACF,YAAQ,MAAMP,EAAgBC,GAAM,GAAGC,CAAQ,GAAGI,CAAK;AAAA;AAEvD,UAAMA;AAEV;"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { parseApiTargetFromMetadata as o } from "../../common/parseApiTargetFromMetadata.js";
|
|
2
|
+
import { getSchemaGraphOperationData as p } from "./getSchemaGraphOperationData.js";
|
|
3
|
+
import { getSchemaGraphSchemaData as m } from "./getSchemaGraphSchemaData.js";
|
|
4
|
+
const f = ({
|
|
5
|
+
metadata: e,
|
|
6
|
+
schemaGraphData: t
|
|
7
|
+
}) => {
|
|
8
|
+
const r = o(e);
|
|
9
|
+
if (!r)
|
|
10
|
+
return {};
|
|
11
|
+
try {
|
|
12
|
+
return r.type === "operation" ? p({
|
|
13
|
+
target: r,
|
|
14
|
+
schemaGraphData: t
|
|
15
|
+
}) : m({
|
|
16
|
+
target: r,
|
|
17
|
+
schemaGraphData: t
|
|
18
|
+
});
|
|
19
|
+
} catch (a) {
|
|
20
|
+
throw a;
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
export {
|
|
24
|
+
f as getApiReferenceDataFromGraph
|
|
25
|
+
};
|
|
26
|
+
//# sourceMappingURL=getApiReferenceDataFromGraph.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getApiReferenceDataFromGraph.js","sources":["../../../src/api-playground-2/schemaGraph/getApiReferenceDataFromGraph.ts"],"sourcesContent":["import { parseApiTargetFromMetadata } from '../../common/parseApiTargetFromMetadata';\nimport type { PageMetaTags } from '@mintlify/models';\nimport type { SchemaGraphData } from '@mintlify/validation';\n\nimport type { ApiReferenceDataV2 } from '@/api-playground-2/types';\n\nimport { getSchemaGraphOperationData } from './getSchemaGraphOperationData';\nimport { getSchemaGraphSchemaData } from './getSchemaGraphSchemaData';\n\nexport const getApiReferenceDataFromGraph = ({\n metadata,\n schemaGraphData,\n}: {\n metadata: PageMetaTags;\n schemaGraphData: SchemaGraphData;\n}): ApiReferenceDataV2 => {\n const target = parseApiTargetFromMetadata(metadata);\n\n if (!target) {\n return {};\n }\n\n try {\n if (target.type === 'operation') {\n return getSchemaGraphOperationData({\n target,\n schemaGraphData,\n });\n } else {\n return getSchemaGraphSchemaData({\n target,\n schemaGraphData,\n });\n }\n } catch (error) {\n throw error;\n }\n};\n"],"names":["getApiReferenceDataFromGraph","metadata","schemaGraphData","target","parseApiTargetFromMetadata","getSchemaGraphOperationData","getSchemaGraphSchemaData","error"],"mappings":";;;AASO,MAAMA,IAA+B,CAAC;AAAA,EAC3C,UAAAC;AAAA,EACA,iBAAAC;AACF,MAG0B;AACxB,QAAMC,IAASC,EAA2BH,CAAQ;AAElD,MAAI,CAACE;AACH,WAAO,CAAA;AAGT,MAAI;AACF,WAAIA,EAAO,SAAS,cACXE,EAA4B;AAAA,MACjC,QAAAF;AAAA,MACA,iBAAAD;AAAA,IAAA,CACD,IAEMI,EAAyB;AAAA,MAC9B,QAAAH;AAAA,MACA,iBAAAD;AAAA,IAAA,CACD;AAAA,EAEL,SAASK,GAAO;AACd,UAAMA;AAAA,EACR;AACF;"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import u from "lodash/zip";
|
|
2
|
+
import { deeplyResolveGraphNode as p, resolveGraphNode as n } from "./resolveGraphNode.js";
|
|
3
|
+
import { flattenSingleOneOf as c } from "./utils.js";
|
|
4
|
+
const d = (e) => n({
|
|
5
|
+
uuidObjectHashMap: e.spec.uuidObjectHashMap,
|
|
6
|
+
hashedNodeMap: e.spec.hashedNodeMap,
|
|
7
|
+
id: e.documentId
|
|
8
|
+
});
|
|
9
|
+
function O({
|
|
10
|
+
operation: e,
|
|
11
|
+
schemaGraphData: r
|
|
12
|
+
}) {
|
|
13
|
+
var o, i;
|
|
14
|
+
const t = (o = d(r)) == null ? void 0 : o.servers, s = (i = d(r)) == null ? void 0 : i.security;
|
|
15
|
+
return {
|
|
16
|
+
...e,
|
|
17
|
+
servers: t,
|
|
18
|
+
security: s
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
const l = (e) => {
|
|
22
|
+
var t;
|
|
23
|
+
const r = (t = d(e)) == null ? void 0 : t.servers;
|
|
24
|
+
return r ? Object.fromEntries(
|
|
25
|
+
u(
|
|
26
|
+
r,
|
|
27
|
+
r.map(
|
|
28
|
+
(s) => p({
|
|
29
|
+
uuidObjectHashMap: e.spec.uuidObjectHashMap,
|
|
30
|
+
hashedNodeMap: e.spec.hashedNodeMap,
|
|
31
|
+
id: s
|
|
32
|
+
})
|
|
33
|
+
)
|
|
34
|
+
).filter((s) => s[1] !== void 0).map(([s, o]) => [s, c(o)])
|
|
35
|
+
) : {};
|
|
36
|
+
}, b = (e) => {
|
|
37
|
+
var t;
|
|
38
|
+
const r = (t = d(e)) == null ? void 0 : t.security;
|
|
39
|
+
return r ? Object.fromEntries(
|
|
40
|
+
u(
|
|
41
|
+
r,
|
|
42
|
+
r.map(
|
|
43
|
+
(s) => p({
|
|
44
|
+
uuidObjectHashMap: e.spec.uuidObjectHashMap,
|
|
45
|
+
hashedNodeMap: e.spec.hashedNodeMap,
|
|
46
|
+
id: s
|
|
47
|
+
})
|
|
48
|
+
)
|
|
49
|
+
).filter((s) => s[1] !== void 0).map(([s, o]) => [s, c(o)])
|
|
50
|
+
) : {};
|
|
51
|
+
};
|
|
52
|
+
export {
|
|
53
|
+
d as getDocument,
|
|
54
|
+
b as getResolvedSecuritys,
|
|
55
|
+
l as getResolvedServers,
|
|
56
|
+
O as withDocumentProperties
|
|
57
|
+
};
|
|
58
|
+
//# sourceMappingURL=getDocumentProperties.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getDocumentProperties.js","sources":["../../../src/api-playground-2/schemaGraph/getDocumentProperties.ts"],"sourcesContent":["import {\n Operation,\n SchemaGraphData,\n Document,\n ServerObject,\n SecurityRequirement,\n UUID,\n} from '@mintlify/validation';\nimport zip from 'lodash/zip';\n\nimport {\n deeplyResolveGraphNode,\n resolveGraphNode,\n} from '@/api-playground-2/schemaGraph/resolveGraphNode';\nimport { flattenSingleOneOf } from '@/api-playground-2/schemaGraph/utils';\nimport type { ResolvedSecurityObject } from '@/api-playground-2/types';\n\nexport const getDocument = (schemaGraphData: SchemaGraphData) => {\n return resolveGraphNode<Document>({\n uuidObjectHashMap: schemaGraphData.spec.uuidObjectHashMap,\n hashedNodeMap: schemaGraphData.spec.hashedNodeMap,\n id: schemaGraphData.documentId,\n });\n};\n\n// Decorate an Operation object that has been parsed from a path with some additional properties which\n// are stored at the top level of the schema document.\nexport function withDocumentProperties({\n operation,\n schemaGraphData,\n}: {\n operation: Operation;\n schemaGraphData: SchemaGraphData;\n}): Operation {\n // get servers\n const servers = getDocument(schemaGraphData)?.servers;\n\n // get security\n const security = getDocument(schemaGraphData)?.security;\n\n return {\n ...operation,\n servers,\n security,\n };\n}\n\nexport const getResolvedServers = (\n schemaGraphData: SchemaGraphData\n): Record<string, ServerObject> => {\n const serverUUIDs = getDocument(schemaGraphData)?.servers;\n if (!serverUUIDs) return {};\n\n return Object.fromEntries(\n zip(\n serverUUIDs,\n serverUUIDs.map((serverUUID) =>\n deeplyResolveGraphNode<ServerObject>({\n uuidObjectHashMap: schemaGraphData.spec.uuidObjectHashMap,\n hashedNodeMap: schemaGraphData.spec.hashedNodeMap,\n id: serverUUID,\n })\n )\n )\n .filter((entry): entry is [UUID, ServerObject] => entry[1] !== undefined)\n .map(([uuid, server]) => [uuid, flattenSingleOneOf(server)])\n );\n};\n\nexport const getResolvedSecuritys = (\n schemaGraphData: SchemaGraphData\n): Record<string, ResolvedSecurityObject> => {\n const securityUUIDs = getDocument(schemaGraphData)?.security;\n if (!securityUUIDs) return {};\n\n return Object.fromEntries(\n zip(\n securityUUIDs,\n securityUUIDs.map((securityUUID) =>\n deeplyResolveGraphNode<SecurityRequirement>({\n uuidObjectHashMap: schemaGraphData.spec.uuidObjectHashMap,\n hashedNodeMap: schemaGraphData.spec.hashedNodeMap,\n id: securityUUID,\n })\n )\n )\n .filter((entry): entry is [UUID, ResolvedSecurityObject] => entry[1] !== undefined)\n .map(([uuid, security]) => [uuid, flattenSingleOneOf(security)])\n );\n};\n"],"names":["getDocument","schemaGraphData","resolveGraphNode","withDocumentProperties","operation","servers","_a","security","_b","getResolvedServers","serverUUIDs","zip","serverUUID","deeplyResolveGraphNode","entry","uuid","server","flattenSingleOneOf","getResolvedSecuritys","securityUUIDs","securityUUID"],"mappings":";;;AAiBO,MAAMA,IAAc,CAACC,MACnBC,EAA2B;AAAA,EAChC,mBAAmBD,EAAgB,KAAK;AAAA,EACxC,eAAeA,EAAgB,KAAK;AAAA,EACpC,IAAIA,EAAgB;AAAA,CACrB;AAKI,SAASE,EAAuB;AAAA,EACrC,WAAAC;AAAA,EACA,iBAAAH;AACF,GAGc;;AAEZ,QAAMI,KAAUC,IAAAN,EAAYC,CAAe,MAA3B,gBAAAK,EAA8B,SAGxCC,KAAWC,IAAAR,EAAYC,CAAe,MAA3B,gBAAAO,EAA8B;AAE/C,SAAO;AAAA,IACL,GAAGJ;AAAA,IACH,SAAAC;AAAA,IACA,UAAAE;AAAA,EAAA;AAEJ;AAEO,MAAME,IAAqB,CAChCR,MACiC;;AACjC,QAAMS,KAAcJ,IAAAN,EAAYC,CAAe,MAA3B,gBAAAK,EAA8B;AAClD,SAAKI,IAEE,OAAO;AAAA,IACZC;AAAA,MACED;AAAA,MACAA,EAAY;AAAA,QAAI,CAACE,MACfC,EAAqC;AAAA,UACnC,mBAAmBZ,EAAgB,KAAK;AAAA,UACxC,eAAeA,EAAgB,KAAK;AAAA,UACpC,IAAIW;AAAA,QAAA,CACL;AAAA,MAAA;AAAA,IACH,EAEC,OAAO,CAACE,MAAyCA,EAAM,CAAC,MAAM,MAAS,EACvE,IAAI,CAAC,CAACC,GAAMC,CAAM,MAAM,CAACD,GAAME,EAAmBD,CAAM,CAAC,CAAC;AAAA,EAAA,IAdtC,CAAA;AAgB3B,GAEaE,IAAuB,CAClCjB,MAC2C;;AAC3C,QAAMkB,KAAgBb,IAAAN,EAAYC,CAAe,MAA3B,gBAAAK,EAA8B;AACpD,SAAKa,IAEE,OAAO;AAAA,IACZR;AAAA,MACEQ;AAAA,MACAA,EAAc;AAAA,QAAI,CAACC,MACjBP,EAA4C;AAAA,UAC1C,mBAAmBZ,EAAgB,KAAK;AAAA,UACxC,eAAeA,EAAgB,KAAK;AAAA,UACpC,IAAImB;AAAA,QAAA,CACL;AAAA,MAAA;AAAA,IACH,EAEC,OAAO,CAACN,MAAmDA,EAAM,CAAC,MAAM,MAAS,EACjF,IAAI,CAAC,CAACC,GAAMR,CAAQ,MAAM,CAACQ,GAAME,EAAmBV,CAAQ,CAAC,CAAC;AAAA,EAAA,IAdxC,CAAA;AAgB7B;"}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { withDocumentProperties as h, getResolvedServers as f, getResolvedSecuritys as b } from "./getDocumentProperties.js";
|
|
2
|
+
import { resolveGraphNode as O } from "./resolveGraphNode.js";
|
|
3
|
+
import { resolveOperationWithDependencies as v } from "./resolveOperationWithDependencies.js";
|
|
4
|
+
const y = ({
|
|
5
|
+
operation: e,
|
|
6
|
+
target: n,
|
|
7
|
+
baseUrlOptions: o
|
|
8
|
+
}) => {
|
|
9
|
+
let r, t = [];
|
|
10
|
+
o.length > 1 ? t = o : r = o[0];
|
|
11
|
+
const i = [];
|
|
12
|
+
return Array.isArray(e["x-code-samples"]) && e["x-code-samples"].length > 0 && e["x-code-samples"].forEach((s) => {
|
|
13
|
+
s && typeof s == "object" && "source" in s && typeof s.source == "string" && "lang" in s && typeof s.lang == "string" && i.push({
|
|
14
|
+
label: "label" in s && typeof s.label == "string" ? s.label : void 0,
|
|
15
|
+
lang: s.lang,
|
|
16
|
+
source: s.source
|
|
17
|
+
});
|
|
18
|
+
}), {
|
|
19
|
+
...e,
|
|
20
|
+
path: n.endpoint || "",
|
|
21
|
+
baseUrl: r,
|
|
22
|
+
baseUrlOptions: t,
|
|
23
|
+
title: e.summary ?? "",
|
|
24
|
+
description: e.description ?? "",
|
|
25
|
+
codeSamples: i
|
|
26
|
+
};
|
|
27
|
+
}, g = (e, n, o) => {
|
|
28
|
+
const r = e.spec.refUuidMap[`${n}/${o}`];
|
|
29
|
+
if (!r) return;
|
|
30
|
+
const t = O({
|
|
31
|
+
uuidObjectHashMap: e.spec.uuidObjectHashMap,
|
|
32
|
+
hashedNodeMap: e.spec.hashedNodeMap,
|
|
33
|
+
id: r
|
|
34
|
+
});
|
|
35
|
+
return o === "webhook" ? t == null ? void 0 : t.post : t == null ? void 0 : t[o];
|
|
36
|
+
}, w = ({
|
|
37
|
+
target: e,
|
|
38
|
+
schemaGraphData: n
|
|
39
|
+
}) => {
|
|
40
|
+
const { uuidObjectHashMap: o, hashedNodeMap: r } = n.spec, t = g(n, e.endpoint, e.method);
|
|
41
|
+
if (!t)
|
|
42
|
+
throw new Error(
|
|
43
|
+
`no matching OpenAPI operation found with path "${e.endpoint}" and method "${e.method}"`
|
|
44
|
+
);
|
|
45
|
+
const i = v({
|
|
46
|
+
operationId: t,
|
|
47
|
+
uuidObjectHashMap: o,
|
|
48
|
+
hashedNodeMap: r
|
|
49
|
+
});
|
|
50
|
+
if (!i)
|
|
51
|
+
return {};
|
|
52
|
+
let s = i.operation;
|
|
53
|
+
s = h({
|
|
54
|
+
operation: s,
|
|
55
|
+
schemaGraphData: n
|
|
56
|
+
});
|
|
57
|
+
const c = f(n), p = b(n), d = Object.values(c).map((l) => l.url), u = y({
|
|
58
|
+
operation: s,
|
|
59
|
+
target: e,
|
|
60
|
+
baseUrlOptions: d
|
|
61
|
+
}), a = {
|
|
62
|
+
...i.dependencies,
|
|
63
|
+
servers: c,
|
|
64
|
+
security: p,
|
|
65
|
+
...i.schemas && { schemas: i.schemas }
|
|
66
|
+
};
|
|
67
|
+
return {
|
|
68
|
+
operation: u,
|
|
69
|
+
dependencies: a
|
|
70
|
+
};
|
|
71
|
+
};
|
|
72
|
+
export {
|
|
73
|
+
y as createOperationV2,
|
|
74
|
+
g as getOperationId,
|
|
75
|
+
w as getSchemaGraphOperationData
|
|
76
|
+
};
|
|
77
|
+
//# sourceMappingURL=getSchemaGraphOperationData.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getSchemaGraphOperationData.js","sources":["../../../src/api-playground-2/schemaGraph/getSchemaGraphOperationData.ts"],"sourcesContent":["import type { OperationTargetType } from '@mintlify/common';\nimport type {\n CodeSample,\n HttpMethod,\n PathOrRef,\n SchemaGraphData,\n Operation,\n} from '@mintlify/validation';\n\nimport {\n getResolvedSecuritys,\n getResolvedServers,\n withDocumentProperties,\n} from '@/api-playground-2/schemaGraph/getDocumentProperties';\nimport { resolveGraphNode } from '@/api-playground-2/schemaGraph/resolveGraphNode';\nimport type { ApiReferenceDataV2, OperationV2 } from '@/api-playground-2/types';\n\nimport { resolveOperationWithDependencies } from './resolveOperationWithDependencies';\n\nexport const createOperationV2 = ({\n operation,\n target,\n baseUrlOptions,\n}: {\n operation: Operation;\n target: OperationTargetType;\n baseUrlOptions: string[];\n}): OperationV2 => {\n let baseUrl: string | undefined = undefined;\n let baseUrls: string[] = [];\n if (baseUrlOptions.length > 1) {\n baseUrls = baseUrlOptions;\n } else {\n baseUrl = baseUrlOptions[0];\n }\n\n const codeSamples: CodeSample[] = [];\n if (Array.isArray(operation['x-code-samples']) && operation['x-code-samples'].length > 0) {\n operation['x-code-samples'].forEach((codeSample) => {\n if (\n codeSample &&\n typeof codeSample === 'object' &&\n 'source' in codeSample &&\n typeof codeSample['source'] === 'string' &&\n 'lang' in codeSample &&\n typeof codeSample['lang'] === 'string'\n ) {\n codeSamples.push({\n label:\n 'label' in codeSample && typeof codeSample['label'] === 'string'\n ? codeSample['label']\n : undefined,\n lang: codeSample['lang'],\n source: codeSample['source'],\n });\n }\n });\n }\n\n return {\n ...operation,\n path: target.endpoint || '',\n baseUrl,\n baseUrlOptions: baseUrls,\n title: operation.summary ?? '',\n description: operation.description ?? '',\n codeSamples,\n };\n};\n\n// An OpenAPI doc comes to us with a `paths` array. We turn that array into a series of path objects\n// which have a set of `method` keys that map to operation objects.\nexport const getOperationId = (\n graph: SchemaGraphData,\n endpoint: string,\n method: HttpMethod | 'webhook'\n) => {\n const pathUuid = graph.spec.refUuidMap[`${endpoint}/${method}`];\n if (!pathUuid) return undefined;\n\n // pathNode has a shape like:\n // {\n // path: string;\n // [method: HttpMethod]: UUID;\n // }\n const pathNode = resolveGraphNode<PathOrRef>({\n uuidObjectHashMap: graph.spec.uuidObjectHashMap,\n hashedNodeMap: graph.spec.hashedNodeMap,\n id: pathUuid,\n });\n\n // TODO - Api Playground Refactor: I think we assume in the converter that webhooks always have \"post\" as a method\n // technically I they can have multiple/other methods specified?\n const pathNodeOperationObject = method === 'webhook' ? pathNode?.['post'] : pathNode?.[method];\n\n return pathNodeOperationObject;\n};\n\nexport const getSchemaGraphOperationData = ({\n target,\n schemaGraphData,\n}: {\n target: OperationTargetType;\n schemaGraphData: SchemaGraphData;\n}): ApiReferenceDataV2 => {\n const { uuidObjectHashMap, hashedNodeMap } = schemaGraphData.spec;\n\n const operationId = getOperationId(schemaGraphData, target.endpoint, target.method);\n\n if (!operationId) {\n throw new Error(\n `no matching OpenAPI operation found with path \"${target.endpoint}\" and method \"${target.method}\"`\n );\n }\n\n const resolvedData = resolveOperationWithDependencies({\n operationId,\n uuidObjectHashMap,\n hashedNodeMap,\n });\n\n if (!resolvedData) {\n // better error handling?\n return {};\n }\n\n let operation = resolvedData.operation;\n\n // The Operation object doesn't directly contain all the properties we want, so we add a few elsewhere\n // in the spec.\n operation = withDocumentProperties({\n operation,\n schemaGraphData,\n });\n\n const servers = getResolvedServers(schemaGraphData);\n const security = getResolvedSecuritys(schemaGraphData);\n const baseUrlOptions = Object.values(servers).map((server) => server.url);\n\n const operationV2 = createOperationV2({\n operation,\n target,\n baseUrlOptions,\n });\n\n // Then we need to make sure we have dependencies for those new properties.\n const dependenciesWithDocumentDependencies = {\n ...resolvedData.dependencies,\n servers,\n security,\n ...(resolvedData.schemas && { schemas: resolvedData.schemas }),\n };\n\n return {\n operation: operationV2,\n dependencies: dependenciesWithDocumentDependencies,\n };\n};\n"],"names":["createOperationV2","operation","target","baseUrlOptions","baseUrl","baseUrls","codeSamples","codeSample","getOperationId","graph","endpoint","method","pathUuid","pathNode","resolveGraphNode","getSchemaGraphOperationData","schemaGraphData","uuidObjectHashMap","hashedNodeMap","operationId","resolvedData","resolveOperationWithDependencies","withDocumentProperties","servers","getResolvedServers","security","getResolvedSecuritys","server","operationV2","dependenciesWithDocumentDependencies"],"mappings":";;;AAmBO,MAAMA,IAAoB,CAAC;AAAA,EAChC,WAAAC;AAAA,EACA,QAAAC;AAAA,EACA,gBAAAC;AACF,MAImB;AACjB,MAAIC,GACAC,IAAqB,CAAA;AACzB,EAAIF,EAAe,SAAS,IAC1BE,IAAWF,IAEXC,IAAUD,EAAe,CAAC;AAG5B,QAAMG,IAA4B,CAAA;AAClC,SAAI,MAAM,QAAQL,EAAU,gBAAgB,CAAC,KAAKA,EAAU,gBAAgB,EAAE,SAAS,KACrFA,EAAU,gBAAgB,EAAE,QAAQ,CAACM,MAAe;AAClD,IACEA,KACA,OAAOA,KAAe,YACtB,YAAYA,KACZ,OAAOA,EAAW,UAAc,YAChC,UAAUA,KACV,OAAOA,EAAW,QAAY,YAE9BD,EAAY,KAAK;AAAA,MACf,OACE,WAAWC,KAAc,OAAOA,EAAW,SAAa,WACpDA,EAAW,QACX;AAAA,MACN,MAAMA,EAAW;AAAA,MACjB,QAAQA,EAAW;AAAA,IAAQ,CAC5B;AAAA,EAEL,CAAC,GAGI;AAAA,IACL,GAAGN;AAAA,IACH,MAAMC,EAAO,YAAY;AAAA,IACzB,SAAAE;AAAA,IACA,gBAAgBC;AAAA,IAChB,OAAOJ,EAAU,WAAW;AAAA,IAC5B,aAAaA,EAAU,eAAe;AAAA,IACtC,aAAAK;AAAA,EAAA;AAEJ,GAIaE,IAAiB,CAC5BC,GACAC,GACAC,MACG;AACH,QAAMC,IAAWH,EAAM,KAAK,WAAW,GAAGC,CAAQ,IAAIC,CAAM,EAAE;AAC9D,MAAI,CAACC,EAAU;AAOf,QAAMC,IAAWC,EAA4B;AAAA,IAC3C,mBAAmBL,EAAM,KAAK;AAAA,IAC9B,eAAeA,EAAM,KAAK;AAAA,IAC1B,IAAIG;AAAA,EAAA,CACL;AAMD,SAFgCD,MAAW,YAAYE,KAAA,gBAAAA,EAAW,OAAUA,KAAA,gBAAAA,EAAWF;AAGzF,GAEaI,IAA8B,CAAC;AAAA,EAC1C,QAAAb;AAAA,EACA,iBAAAc;AACF,MAG0B;AACxB,QAAM,EAAE,mBAAAC,GAAmB,eAAAC,EAAA,IAAkBF,EAAgB,MAEvDG,IAAcX,EAAeQ,GAAiBd,EAAO,UAAUA,EAAO,MAAM;AAElF,MAAI,CAACiB;AACH,UAAM,IAAI;AAAA,MACR,kDAAkDjB,EAAO,QAAQ,iBAAiBA,EAAO,MAAM;AAAA,IAAA;AAInG,QAAMkB,IAAeC,EAAiC;AAAA,IACpD,aAAAF;AAAA,IACA,mBAAAF;AAAA,IACA,eAAAC;AAAA,EAAA,CACD;AAED,MAAI,CAACE;AAEH,WAAO,CAAA;AAGT,MAAInB,IAAYmB,EAAa;AAI7B,EAAAnB,IAAYqB,EAAuB;AAAA,IACjC,WAAArB;AAAA,IACA,iBAAAe;AAAA,EAAA,CACD;AAED,QAAMO,IAAUC,EAAmBR,CAAe,GAC5CS,IAAWC,EAAqBV,CAAe,GAC/Cb,IAAiB,OAAO,OAAOoB,CAAO,EAAE,IAAI,CAACI,MAAWA,EAAO,GAAG,GAElEC,IAAc5B,EAAkB;AAAA,IACpC,WAAAC;AAAA,IACA,QAAAC;AAAA,IACA,gBAAAC;AAAA,EAAA,CACD,GAGK0B,IAAuC;AAAA,IAC3C,GAAGT,EAAa;AAAA,IAChB,SAAAG;AAAA,IACA,UAAAE;AAAA,IACA,GAAIL,EAAa,WAAW,EAAE,SAASA,EAAa,QAAA;AAAA,EAAQ;AAG9D,SAAO;AAAA,IACL,WAAWQ;AAAA,IACX,cAAcC;AAAA,EAAA;AAElB;"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { resolveSchemaWithDependencies as t } from "./resolveSchemaWithDependencies.js";
|
|
2
|
+
function o({
|
|
3
|
+
target: e,
|
|
4
|
+
schemaGraphData: a
|
|
5
|
+
}) {
|
|
6
|
+
return {
|
|
7
|
+
schemaData: t({
|
|
8
|
+
schemaPath: `#/components/schemas/${e.name}`,
|
|
9
|
+
schemaGraphData: a
|
|
10
|
+
})
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
export {
|
|
14
|
+
o as getSchemaGraphSchemaData
|
|
15
|
+
};
|
|
16
|
+
//# sourceMappingURL=getSchemaGraphSchemaData.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getSchemaGraphSchemaData.js","sources":["../../../src/api-playground-2/schemaGraph/getSchemaGraphSchemaData.ts"],"sourcesContent":["import type { SchemaTargetType } from '@mintlify/common';\nimport { SchemaGraphData } from '@mintlify/validation';\n\nimport { resolveSchemaWithDependencies } from '@/api-playground-2/schemaGraph/resolveSchemaWithDependencies';\nimport { ApiReferenceDataV2 } from '@/api-playground-2/types';\n\nexport function getSchemaGraphSchemaData({\n target,\n schemaGraphData,\n}: {\n target: SchemaTargetType;\n schemaGraphData: SchemaGraphData;\n}): ApiReferenceDataV2 {\n const resolvedData = resolveSchemaWithDependencies({\n schemaPath: `#/components/schemas/${target.name}`,\n schemaGraphData,\n });\n\n return {\n schemaData: resolvedData,\n };\n}\n"],"names":["getSchemaGraphSchemaData","target","schemaGraphData","resolveSchemaWithDependencies"],"mappings":";AAMO,SAASA,EAAyB;AAAA,EACvC,QAAAC;AAAA,EACA,iBAAAC;AACF,GAGuB;AAMrB,SAAO;AAAA,IACL,YANmBC,EAA8B;AAAA,MACjD,YAAY,wBAAwBF,EAAO,IAAI;AAAA,MAC/C,iBAAAC;AAAA,IAAA,CACD;AAAA,EAGa;AAEhB;"}
|
|
@@ -1,46 +1,123 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import m from "html-react-parser";
|
|
2
|
+
import { isSchemaObject as s } from "./utils.js";
|
|
3
|
+
function p(e, r) {
|
|
4
|
+
const t = /language-(\w+)/.exec(e ?? "");
|
|
5
|
+
return t ? t[1] ?? "text" : r ?? "text";
|
|
5
6
|
}
|
|
6
|
-
const
|
|
7
|
-
var
|
|
8
|
-
const
|
|
9
|
-
(
|
|
7
|
+
const g = (e) => {
|
|
8
|
+
var a, i;
|
|
9
|
+
const r = [], t = (a = e.attributes) == null ? void 0 : a.some(
|
|
10
|
+
(n) => n.name === "dropdown" && n.value !== "false"
|
|
10
11
|
);
|
|
11
|
-
return (
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
dropdown:
|
|
15
|
-
language:
|
|
16
|
-
code:
|
|
17
|
-
filename:
|
|
12
|
+
return (i = e.children) == null || i.map((n) => {
|
|
13
|
+
const u = m(n.html ?? ""), o = typeof u == "object" && !Array.isArray(u) && u.type === "pre" ? u.props.language ?? p(u.props.className, n.filename) : void 0;
|
|
14
|
+
r.push({
|
|
15
|
+
dropdown: t,
|
|
16
|
+
language: o,
|
|
17
|
+
code: u,
|
|
18
|
+
filename: n.filename
|
|
18
19
|
});
|
|
19
|
-
}),
|
|
20
|
-
},
|
|
21
|
-
const
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
20
|
+
}), r;
|
|
21
|
+
}, E = (e) => (Object.entries(e).forEach(([r, t]) => {
|
|
22
|
+
const a = {};
|
|
23
|
+
t.examples ? (Object.entries(t.examples).forEach(
|
|
24
|
+
([i, n]) => {
|
|
25
|
+
"$ref" in n || (a[i] = {
|
|
26
|
+
title: i,
|
|
27
|
+
description: n.description,
|
|
28
|
+
value: n.value
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
), e[r] && (e[r].examples = a)) : t.example ? (a.Example = {
|
|
32
|
+
title: "Example",
|
|
33
|
+
value: t.example
|
|
34
|
+
}, e[r] && (e[r].examples = a)) : s(t.schema) && (a.Example = l(t.schema), e[r] && (e[r].examples = a));
|
|
35
|
+
}), e), l = (e) => {
|
|
36
|
+
const r = {
|
|
37
|
+
title: "Example",
|
|
38
|
+
value: void 0
|
|
39
|
+
};
|
|
40
|
+
if (e.example !== void 0)
|
|
41
|
+
return r.value = e.example, r;
|
|
42
|
+
if (e.default !== void 0)
|
|
43
|
+
return r.value = e.default, r;
|
|
44
|
+
if (e.enum)
|
|
45
|
+
return r.value = e.enum[0], r;
|
|
46
|
+
if (e.oneOf && Array.isArray(e.oneOf) && e.oneOf.length > 0) {
|
|
47
|
+
const t = e.oneOf[0];
|
|
48
|
+
if (s(t))
|
|
49
|
+
return l(t);
|
|
26
50
|
}
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
51
|
+
switch (e.type) {
|
|
52
|
+
case "string":
|
|
53
|
+
return r.value = x(e), r;
|
|
54
|
+
case "boolean":
|
|
55
|
+
return r.value = !0, r;
|
|
56
|
+
case "number":
|
|
57
|
+
case "integer":
|
|
58
|
+
return r.value = f(e), r;
|
|
59
|
+
case "object":
|
|
60
|
+
return r.value = Object.fromEntries(
|
|
61
|
+
Object.entries(e.properties ?? {}).map(([t, a]) => [
|
|
62
|
+
t,
|
|
63
|
+
l(a).value
|
|
64
|
+
])
|
|
65
|
+
), r;
|
|
66
|
+
case "array":
|
|
67
|
+
return r.value = [l(e.items).value], r;
|
|
68
|
+
default:
|
|
69
|
+
return r.value = "<unknown>", r;
|
|
70
|
+
}
|
|
71
|
+
}, f = (e) => {
|
|
72
|
+
const r = e.type === "integer" ? Math.floor : (t) => t;
|
|
73
|
+
return e.minimum !== void 0 && e.maximum !== void 0 ? r((e.minimum + e.maximum) / 2) : e.minimum !== void 0 ? r(e.minimum + 1) : e.maximum !== void 0 ? 123 < e.maximum ? 123 : r(e.maximum - 1) : 123;
|
|
74
|
+
}, x = (e) => {
|
|
75
|
+
var r;
|
|
76
|
+
switch ((r = e.format) == null ? void 0 : r.toLowerCase()) {
|
|
77
|
+
case "byte":
|
|
78
|
+
case "base64":
|
|
79
|
+
return "aSDinaTvuI8gbWludGxpZnk=";
|
|
80
|
+
case "date":
|
|
81
|
+
return "2023-12-25";
|
|
82
|
+
case "date-time":
|
|
83
|
+
return "2023-11-07T05:31:56Z";
|
|
84
|
+
case "email":
|
|
85
|
+
return "jsmith@example.com";
|
|
86
|
+
case "uuid":
|
|
87
|
+
return "3c90c3cc-0d44-4b50-8888-8dd25736052a";
|
|
88
|
+
case "ipv4":
|
|
89
|
+
return "127.0.0.1";
|
|
90
|
+
case "ipv6":
|
|
91
|
+
return "2606:4700:3108::ac42:2835";
|
|
92
|
+
default:
|
|
93
|
+
return "<string>";
|
|
94
|
+
}
|
|
95
|
+
}, v = (e) => {
|
|
96
|
+
const r = Object.keys(e)[0];
|
|
97
|
+
if (r) {
|
|
98
|
+
const t = e[r], i = Object.values((t == null ? void 0 : t.examples) ?? {})[0];
|
|
99
|
+
if (i && "value" in i)
|
|
100
|
+
return i.value;
|
|
101
|
+
}
|
|
102
|
+
}, b = (e) => {
|
|
103
|
+
var t, a;
|
|
104
|
+
const r = [];
|
|
105
|
+
if ((a = (t = e.dependencies) == null ? void 0 : t.requestBody) != null && a.content) {
|
|
106
|
+
const i = v(e.dependencies.requestBody.content);
|
|
107
|
+
i && r.push({
|
|
33
108
|
language: "json",
|
|
34
109
|
filename: "Example Request Body",
|
|
35
|
-
code: JSON.stringify(
|
|
110
|
+
code: JSON.stringify(i.value, null, 2)
|
|
36
111
|
});
|
|
37
112
|
}
|
|
38
|
-
return
|
|
113
|
+
return r;
|
|
39
114
|
};
|
|
40
115
|
export {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
116
|
+
l as generateExampleFromSchema,
|
|
117
|
+
E as generateExamplesFromSchema,
|
|
118
|
+
v as getFirstExampleValue,
|
|
119
|
+
b as getFirstWebhookExample,
|
|
120
|
+
p as getLanguageFromClassName,
|
|
121
|
+
g as mdxCodeExampleToExamples
|
|
45
122
|
};
|
|
46
123
|
//# sourceMappingURL=processExamples.js.map
|