@mintlify/msft-sdk 1.1.24 → 1.1.26
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.map +1 -1
- package/dist/api-playground/ApiPlayground/Request/BodySection.js.map +1 -1
- package/dist/api-playground/ApiPlayground/Request/ParameterSection.js.map +1 -1
- 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/SecuritySection.js.map +1 -1
- package/dist/api-playground/ApiPlayground/Request/ServerSection.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/Request/inputs/ArrayInput.js.map +1 -1
- package/dist/api-playground/ApiPlayground/Request/inputs/FileInput.js.map +1 -1
- package/dist/api-playground/ApiPlayground/Request/inputs/NullInput.js.map +1 -1
- package/dist/api-playground/ApiPlayground/Request/inputs/NumberInput.js.map +1 -1
- package/dist/api-playground/ApiPlayground/Request/inputs/ObjectInput.js.map +1 -1
- package/dist/api-playground/ApiPlayground/Request/inputs/RecursiveInput.js.map +1 -1
- package/dist/api-playground/ApiPlayground/Request/inputs/SelectInput.js.map +1 -1
- package/dist/api-playground/ApiPlayground/Request/inputs/StringInput.js.map +1 -1
- package/dist/api-playground/ApiPlayground/Request/inputs/TextInput.js.map +1 -1
- package/dist/api-playground/ApiPlayground/Response/CopyFileToClipboardButton.js.map +1 -1
- package/dist/api-playground/ApiPlayground/Response/DownloadFileButton.js.map +1 -1
- package/dist/api-playground/ApiPlayground/Response/ResponseBody/CodeResponseContent.js.map +1 -1
- package/dist/api-playground/ApiPlayground/Response/ResponseBody/index.js.map +1 -1
- package/dist/api-playground/ApiPlayground/Response/ResponseError.js.map +1 -1
- package/dist/api-playground/ApiPlayground/Response/ResponseHeaders.js.map +1 -1
- package/dist/api-playground/ApiPlayground/Response/ResponsePlaceholder.js.map +1 -1
- package/dist/api-playground/ApiPlayground/Response/ResponseTable.js.map +1 -1
- package/dist/api-playground/ApiPlayground/Response/ResponseTopbar.js.map +1 -1
- package/dist/api-playground/ApiPlayground/Response/index.js.map +1 -1
- package/dist/api-playground/ApiPlayground/components/AdditionalPropertyButton.js.map +1 -1
- package/dist/api-playground/ApiPlayground/components/ArrayCount.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/components/InputContainer.js.map +1 -1
- package/dist/api-playground/ApiPlayground/components/InputSectionContainer.js.map +1 -1
- package/dist/api-playground/ApiPlayground/components/ObjectExpandButton.js.map +1 -1
- package/dist/api-playground/ApiPlayground/components/PathHeader.js.map +1 -1
- package/dist/api-playground/ApiPlayground/components/PlaygroundModalWrapper.js.map +1 -1
- package/dist/api-playground/ApiPlayground/components/TrashButton.js.map +1 -1
- package/dist/api-playground/ApiPlayground/components/TypeDropdown.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/EndpointFields/ParamFields/PrimitiveParamField/NumberMetadata.js.map +1 -1
- package/dist/api-playground/EndpointFields/ParamFields/PrimitiveParamField/StringMetadata.js.map +1 -1
- package/dist/api-playground/EndpointFields/ParamFields/PrimitiveParamField/index.js.map +1 -1
- package/dist/api-playground/EndpointFields/ParamFields/RecursiveParamField.js.map +1 -1
- package/dist/api-playground/EndpointFields/components/Description.js.map +1 -1
- package/dist/api-playground/EndpointFields/components/OneOfDropdown.js.map +1 -1
- package/dist/api-playground/EndpointFields/components/OptionDropdown.js.map +1 -1
- package/dist/api-playground/EndpointFields/components/SectionHeading.js.map +1 -1
- package/dist/api-playground/EndpointFields/index.js.map +1 -1
- package/dist/api-playground-2/Api.js.map +1 -1
- package/dist/api-playground-2/ApiExamples.js.map +1 -1
- package/dist/api-playground-2/ApiFields.js.map +1 -1
- package/dist/api-playground-2/components/EndpointFields/EndpointSecurity.js.map +1 -1
- package/dist/api-playground-2/components/EndpointFields/fields/NumberMetadata.js.map +1 -1
- package/dist/api-playground-2/components/EndpointFields/fields/PrimitiveParamField.js.map +1 -1
- package/dist/api-playground-2/components/EndpointFields/fields/SimpleArrayParamField.js.map +1 -1
- package/dist/api-playground-2/components/EndpointFields/fields/SimpleObjectParamField.js.map +1 -1
- package/dist/api-playground-2/components/EndpointFields/fields/SimplePrimitiveParamField.js.map +1 -1
- package/dist/api-playground-2/components/EndpointFields/fields/StringMetadata.js.map +1 -1
- package/dist/api-playground-2/components/Example/RequestExample.js +17 -15
- package/dist/api-playground-2/components/Example/RequestExample.js.map +1 -1
- package/dist/api-playground-2/components/Example/ResponseExample.js.map +1 -1
- package/dist/api-playground-2/components/Request/InputSectionContainer.js.map +1 -1
- package/dist/api-playground-2/components/TypeDropdown.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/contexts/ApiPlaygroundContext.js.map +1 -1
- package/dist/api-playground-2/generators/generateInteractiveCodeSample.js +10 -10
- package/dist/api-playground-2/generators/generateInteractiveCodeSample.js.map +1 -1
- package/dist/api-playground-2/generators/generateSnippetMap.js +24 -24
- package/dist/api-playground-2/generators/generateSnippetMap.js.map +1 -1
- package/dist/api-playground-2/hooks/useSendPlaygroundRequest.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/Api/ErrorBoundary.js.map +1 -1
- package/dist/components/Api/Expandable.js.map +1 -1
- package/dist/components/Api/Markdown.js.map +1 -1
- package/dist/components/Api/MethodPill.js.map +1 -1
- package/dist/components/Api/Param.js.map +1 -1
- package/dist/components/Api/colors.js.map +1 -1
- package/dist/components/content-components/CodeGroupSelect/CodeGroupCopyButton.js.map +1 -1
- package/dist/components/content-components/CodeGroupSelect/CodeSelectDropdown.js.map +1 -1
- package/dist/components/content-components/CodeGroupSelect/index.js.map +1 -1
- package/dist/components/content-components/code-block.js.map +1 -1
- package/dist/components/content-components/code-group.js.map +1 -1
- package/dist/components/content-components/code-snippet.js.map +1 -1
- package/dist/components/content-components/code-snippets.js.map +1 -1
- package/dist/components/content-components/getNodeText.js.map +1 -1
- package/dist/components/docsLayout.js +29 -27
- package/dist/components/docsLayout.js.map +1 -1
- package/dist/components/nav-tree/index.js +165 -156
- package/dist/components/nav-tree/index.js.map +1 -1
- package/dist/contexts/CodeExampleLabelContext.js.map +1 -1
- package/dist/contexts/ConfigContext.js +61 -12
- package/dist/contexts/ConfigContext.js.map +1 -1
- package/dist/contexts/EndpointLocationContext.js.map +1 -1
- package/dist/contexts/MDXContentContext.js +0 -1
- package/dist/contexts/MDXContentContext.js.map +1 -1
- package/dist/hooks/useApiPlaygroundDisplay.js.map +1 -1
- package/dist/hooks/useApiPlaygroundInputs.js.map +1 -1
- package/dist/hooks/useBaseUrlOptions.js.map +1 -1
- package/dist/hooks/useEndpoint.js.map +1 -1
- package/dist/hooks/useKeyboardShortcut.js.map +1 -1
- package/dist/hooks/useMDXContent.js.map +1 -1
- package/dist/hooks/useMDXContentController/useApiPlaygroundInputs.js.map +1 -1
- package/dist/hooks/useMDXContentController/useMDXContentCallbacks/useSetApiBaseIndexCallback.js.map +1 -1
- package/dist/hooks/useMDXContentController/useMDXContentCallbacks/useSetApiPlaygroundInputsCallback.js.map +1 -1
- package/dist/hooks/usePlaygroundSchemaOptions.js.map +1 -1
- package/dist/hooks/usePrefilledInputs/index.js.map +1 -1
- package/dist/hooks/usePrefilledInputs/storedServerVariables.js.map +1 -1
- package/dist/hooks/useSecurityOption.js.map +1 -1
- package/dist/hooks/useSendPlaygroundRequest.js.map +1 -1
- package/dist/index.d.ts +129 -11
- 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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ApiPlaygroundContext.js","sources":["../../../src/api-playground/ApiPlayground/ApiPlaygroundContext.tsx"],"sourcesContent":["
|
|
1
|
+
{"version":3,"file":"ApiPlaygroundContext.js","sources":["../../../src/api-playground/ApiPlayground/ApiPlaygroundContext.tsx"],"sourcesContent":["\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":";AAiBO,MAAMA,IAAuBC,EAAwC;AAAA,EAC1E,WAAW;AAAA,EACX,sBAAsB;AAAA,EACtB,sBAAsB;AAAA,EACtB,sBAAsB;AACxB,CAAC;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BodySection.js","sources":["../../../../src/api-playground/ApiPlayground/Request/BodySection.tsx"],"sourcesContent":["
|
|
1
|
+
{"version":3,"file":"BodySection.js","sources":["../../../../src/api-playground/ApiPlayground/Request/BodySection.tsx"],"sourcesContent":["\nimport { BodySchema, DataSchemaArray, IncrementalDataSchemaArray } from '@mintlify/validation';\nimport { SetStateAction, useMemo, useState } from 'react';\n\nimport { Tab, Tabs } from '@/components/content-components/tabs';\nimport { NoAnyDataSchema } from '@/hooks/usePlaygroundSchemaOptions';\n\nimport { InputSectionContainer } from '../components/InputSectionContainer';\nimport { TypeDropdown } from '../components/TypeDropdown';\nimport { RecursiveInput } from './inputs/RecursiveInput';\n\ntype BodySectionParams = {\n body: BodySchema;\n value: unknown;\n setValue: (value: unknown) => void;\n};\n\nexport const BodySection = ({ body, value, setValue }: BodySectionParams) => {\n const [selectedSchemaArrayIndex, setSelectedSchemaArrayIndex] = useState(0);\n const [selectedContentTypeIndex, setSelectedContentTypeIndex] = useState(0);\n\n const bodyArray = useMemo(() => {\n return Object.entries(body);\n }, [body]);\n\n const contentTypeAndContent = bodyArray[selectedContentTypeIndex] ?? bodyArray[0];\n if (contentTypeAndContent === undefined) return null;\n\n const [_contentType, { schemaArray }] = contentTypeAndContent;\n\n return (\n <InputSectionContainer\n name=\"Body\"\n rightElement={\n bodyArray.length > 1 && (\n <div onClick={(e) => e.stopPropagation()} className=\"mint:text-xs mint:font-mono\">\n <TypeDropdown\n options={bodyArray.map(([label, schema]) => ({\n label,\n schema: schema as unknown as NoAnyDataSchema,\n }))}\n selectedIndex={selectedContentTypeIndex}\n onSelectOption={(index) => {\n setSelectedContentTypeIndex(index);\n }}\n />\n </div>\n )\n }\n >\n {schemaArray.length > 1 ? (\n <Tabs\n defaultTab={selectedSchemaArrayIndex}\n onClickTab={(index: SetStateAction<number>) => setSelectedSchemaArrayIndex(index)}\n className=\"mint:mb-0!\"\n >\n {schemaArray.map((schema, index) => {\n const title = schema.title ?? `Option ${index + 1}`;\n return (\n <Tab key={title} title={title}>\n <RecursiveInput\n schemaArray={[schema] as DataSchemaArray | IncrementalDataSchemaArray}\n value={value}\n setValue={setValue}\n clearValue={value === undefined ? undefined : () => setValue(undefined)}\n isBody\n />\n </Tab>\n );\n })}\n </Tabs>\n ) : (\n <RecursiveInput\n schemaArray={schemaArray}\n value={value}\n setValue={setValue}\n clearValue={value === undefined ? undefined : () => setValue(undefined)}\n isBody\n />\n )}\n </InputSectionContainer>\n );\n};\n"],"names":["BodySection","body","value","setValue","selectedSchemaArrayIndex","setSelectedSchemaArrayIndex","useState","selectedContentTypeIndex","setSelectedContentTypeIndex","bodyArray","useMemo","contentTypeAndContent","_contentType","schemaArray","jsx","InputSectionContainer","TypeDropdown","label","schema","index","Tabs","title","Tab","RecursiveInput"],"mappings":";;;;;;;AAiBO,MAAMA,IAAc,CAAC,EAAE,MAAAC,GAAM,OAAAC,GAAO,UAAAC,QAAkC;AAC3E,QAAM,CAACC,GAA0BC,CAA2B,IAAIC,EAAS,CAAC,GACpE,CAACC,GAA0BC,CAA2B,IAAIF,EAAS,CAAC,GAEpEG,IAAYC,EAAQ,MACjB,OAAO,QAAQT,CAAI,GACzB,CAACA,CAAI,CAAC,GAEHU,IAAwBF,EAAUF,CAAwB,KAAKE,EAAU,CAAC;AAChF,MAAIE,MAA0B,OAAW,QAAO;AAEhD,QAAM,CAACC,GAAc,EAAE,aAAAC,EAAA,CAAa,IAAIF;AAExC,SACE,gBAAAG;AAAA,IAACC;AAAA,IAAA;AAAA,MACC,MAAK;AAAA,MACL,cACEN,EAAU,SAAS,KACjB,gBAAAK,EAAC,OAAA,EAAI,SAAS,CAAC,MAAM,EAAE,gBAAA,GAAmB,WAAU,+BAClD,UAAA,gBAAAA;AAAA,QAACE;AAAA,QAAA;AAAA,UACC,SAASP,EAAU,IAAI,CAAC,CAACQ,GAAOC,CAAM,OAAO;AAAA,YAC3C,OAAAD;AAAA,YACA,QAAAC;AAAA,UAAA,EACA;AAAA,UACF,eAAeX;AAAA,UACf,gBAAgB,CAACY,MAAU;AACzB,YAAAX,EAA4BW,CAAK;AAAA,UACnC;AAAA,QAAA;AAAA,MAAA,GAEJ;AAAA,MAIH,UAAAN,EAAY,SAAS,IACpB,gBAAAC;AAAA,QAACM;AAAA,QAAA;AAAA,UACC,YAAYhB;AAAA,UACZ,YAAY,CAACe,MAAkCd,EAA4Bc,CAAK;AAAA,UAChF,WAAU;AAAA,UAET,UAAAN,EAAY,IAAI,CAACK,GAAQC,MAAU;AAClC,kBAAME,IAAQH,EAAO,SAAS,UAAUC,IAAQ,CAAC;AACjD,mBACE,gBAAAL,EAACQ,KAAgB,OAAAD,GACf,UAAA,gBAAAP;AAAA,cAACS;AAAA,cAAA;AAAA,gBACC,aAAa,CAACL,CAAM;AAAA,gBACpB,OAAAhB;AAAA,gBACA,UAAAC;AAAA,gBACA,YAAYD,MAAU,SAAY,SAAY,MAAMC,EAAS,MAAS;AAAA,gBACtE,QAAM;AAAA,cAAA;AAAA,YAAA,KANAkB,CAQV;AAAA,UAEJ,CAAC;AAAA,QAAA;AAAA,MAAA,IAGH,gBAAAP;AAAA,QAACS;AAAA,QAAA;AAAA,UACC,aAAAV;AAAA,UACA,OAAAX;AAAA,UACA,UAAAC;AAAA,UACA,YAAYD,MAAU,SAAY,SAAY,MAAMC,EAAS,MAAS;AAAA,UACtE,QAAM;AAAA,QAAA;AAAA,MAAA;AAAA,IACR;AAAA,EAAA;AAIR;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ParameterSection.js","sources":["../../../../src/api-playground/ApiPlayground/Request/ParameterSection.tsx"],"sourcesContent":["
|
|
1
|
+
{"version":3,"file":"ParameterSection.js","sources":["../../../../src/api-playground/ApiPlayground/Request/ParameterSection.tsx"],"sourcesContent":["\nimport { ParameterGroup } from '@mintlify/validation';\nimport { useMemo } from 'react';\n\nimport { InputSectionContainer } from '../components/InputSectionContainer';\nimport { RecursiveInput } from './inputs/RecursiveInput';\n\ntype ParameterSectionParams = {\n name: string;\n parameters: ParameterGroup;\n value: Record<string, unknown>;\n setValue: (value: Record<string, unknown>) => void;\n};\n\nexport const ParameterSection = ({ name, parameters, value, setValue }: ParameterSectionParams) => {\n const inputs = useMemo(() => {\n return Object.entries(parameters).map(([paramName, parameter]) => {\n const paramValue = value[paramName];\n const setParamValue = (newParamValue: unknown) => {\n const newObj = { ...value };\n newObj[paramName] = newParamValue;\n setValue(newObj);\n };\n\n const clearParamValue =\n paramValue === undefined\n ? undefined\n : () => {\n const newObj = { ...value };\n delete newObj[paramName];\n setValue(newObj);\n };\n\n return (\n <RecursiveInput\n key={paramName}\n name={paramName}\n schemaArray={parameter.schema}\n style={parameter.style}\n explode={parameter.explode}\n value={paramValue}\n setValue={setParamValue}\n clearValue={clearParamValue}\n />\n );\n });\n }, [parameters, setValue, value]);\n\n if (inputs.length === 0) {\n return null;\n }\n\n return <InputSectionContainer name={name}>{inputs}</InputSectionContainer>;\n};\n"],"names":["ParameterSection","name","parameters","value","setValue","inputs","useMemo","paramName","parameter","paramValue","setParamValue","newParamValue","newObj","clearParamValue","jsx","RecursiveInput","InputSectionContainer"],"mappings":";;;;AAcO,MAAMA,IAAmB,CAAC,EAAE,MAAAC,GAAM,YAAAC,GAAY,OAAAC,GAAO,UAAAC,QAAuC;AACjG,QAAMC,IAASC,EAAQ,MACd,OAAO,QAAQJ,CAAU,EAAE,IAAI,CAAC,CAACK,GAAWC,CAAS,MAAM;AAChE,UAAMC,IAAaN,EAAMI,CAAS,GAC5BG,IAAgB,CAACC,MAA2B;AAChD,YAAMC,IAAS,EAAE,GAAGT,EAAA;AACpB,MAAAS,EAAOL,CAAS,IAAII,GACpBP,EAASQ,CAAM;AAAA,IACjB,GAEMC,IACJJ,MAAe,SACX,SACA,MAAM;AACJ,YAAMG,IAAS,EAAE,GAAGT,EAAA;AACpB,aAAOS,EAAOL,CAAS,GACvBH,EAASQ,CAAM;AAAA,IACjB;AAEN,WACE,gBAAAE;AAAA,MAACC;AAAA,MAAA;AAAA,QAEC,MAAMR;AAAA,QACN,aAAaC,EAAU;AAAA,QACvB,OAAOA,EAAU;AAAA,QACjB,SAASA,EAAU;AAAA,QACnB,OAAOC;AAAA,QACP,UAAUC;AAAA,QACV,YAAYG;AAAA,MAAA;AAAA,MAPPN;AAAA,IAAA;AAAA,EAUX,CAAC,GACA,CAACL,GAAYE,GAAUD,CAAK,CAAC;AAEhC,SAAIE,EAAO,WAAW,IACb,OAGF,gBAAAS,EAACE,GAAA,EAAsB,MAAAf,GAAa,UAAAI,EAAA,CAAO;AACpD;"}
|
|
@@ -1,41 +1,42 @@
|
|
|
1
1
|
import { jsxs as s, jsx as r } from "react/jsx-runtime";
|
|
2
|
-
import { useState as
|
|
3
|
-
import { DescriptionWithoutHeaders as
|
|
4
|
-
import { useApiPlaygroundPrefillExamples as
|
|
5
|
-
import { useMDXContent as
|
|
6
|
-
import { parseAuthInputsFromUserInfo as
|
|
7
|
-
import { useSecurityOption as
|
|
8
|
-
import { getDefaultsFromParameterGroup as
|
|
2
|
+
import { useState as C, useContext as B, useEffect as J } from "react";
|
|
3
|
+
import { DescriptionWithoutHeaders as H } from "../../EndpointFields/components/Description.js";
|
|
4
|
+
import { useApiPlaygroundPrefillExamples as I } from "../../../hooks/useApiPlaygroundPrefillExamples.js";
|
|
5
|
+
import { useMDXContent as R } from "../../../hooks/useMDXContent.js";
|
|
6
|
+
import { parseAuthInputsFromUserInfo as G } from "../../../hooks/usePrefilledInputs/index.js";
|
|
7
|
+
import { useSecurityOption as U } from "../../../hooks/useSecurityOption.js";
|
|
8
|
+
import { getDefaultsFromParameterGroup as W, getDefaultFromSchema as Q } from "../../../utils/api-playground/defaults.js";
|
|
9
9
|
import { paramFieldDefaults as w } from "../../../utils/api-playground/paramFieldDefaults.js";
|
|
10
|
-
import { getFilteredSecurityOptions as
|
|
10
|
+
import { getFilteredSecurityOptions as X } from "../../../utils/api-reference/getFilteredSecurityOptions.js";
|
|
11
11
|
import "@mintlify/validation";
|
|
12
|
-
import { cn as
|
|
13
|
-
import { ApiPlaygroundContext as
|
|
12
|
+
import { cn as z } from "../../../utils/cn.js";
|
|
13
|
+
import { ApiPlaygroundContext as K } from "../ApiPlaygroundContext.js";
|
|
14
14
|
import { Response as P } from "../Response/index.js";
|
|
15
|
-
import { EndpointsMenu as
|
|
16
|
-
import { PathHeader as
|
|
17
|
-
import { PlaygroundModalWrapper as
|
|
18
|
-
import { BodySection as
|
|
15
|
+
import { EndpointsMenu as L } from "../components/EndpointsMenu.js";
|
|
16
|
+
import { PathHeader as T, SendPill as Y } from "../components/PathHeader.js";
|
|
17
|
+
import { PlaygroundModalWrapper as Z } from "../components/PlaygroundModalWrapper.js";
|
|
18
|
+
import { BodySection as _ } from "./BodySection.js";
|
|
19
19
|
import { ParameterSection as y } from "./ParameterSection.js";
|
|
20
|
-
import { SecuritySection as
|
|
21
|
-
import { ServerSection as
|
|
22
|
-
import { ApiExamples as
|
|
23
|
-
function
|
|
20
|
+
import { SecuritySection as $ } from "./SecuritySection.js";
|
|
21
|
+
import { ServerSection as ee } from "./ServerSection.js";
|
|
22
|
+
import { ApiExamples as te } from "../../../api-playground-2/ApiExamples.js";
|
|
23
|
+
function Oe({
|
|
24
24
|
endpoint: t,
|
|
25
25
|
inputs: a,
|
|
26
|
-
setInputs: m
|
|
26
|
+
setInputs: m,
|
|
27
|
+
pathname: j
|
|
27
28
|
}) {
|
|
28
29
|
var k;
|
|
29
|
-
const [{ pageMetadata: b }] =
|
|
30
|
-
isSending:
|
|
31
|
-
selectedBaseUrlIndex:
|
|
30
|
+
const [{ pageMetadata: b }] = R(), [v, A] = C(0), { prefillExamplesEnabled: f, generatedRequestExampleData: p } = I(), S = U(t.request.security), {
|
|
31
|
+
isSending: E,
|
|
32
|
+
selectedBaseUrlIndex: D,
|
|
32
33
|
isPlaygroundExpanded: g,
|
|
33
|
-
setIsPlaygroundExpanded:
|
|
34
|
-
sendRequest:
|
|
34
|
+
setIsPlaygroundExpanded: F,
|
|
35
|
+
sendRequest: M,
|
|
35
36
|
result: l,
|
|
36
37
|
selectedExampleIndex: d
|
|
37
|
-
} =
|
|
38
|
-
return
|
|
38
|
+
} = B(K), h = (k = t.servers) == null ? void 0 : k[D], q = X(t), V = q[v], n = h == null ? void 0 : h.variables;
|
|
39
|
+
return J(() => {
|
|
39
40
|
var N;
|
|
40
41
|
if (!g) return;
|
|
41
42
|
const e = f ? p[d ?? 0] : JSON.parse(JSON.stringify(a));
|
|
@@ -52,20 +53,20 @@ function Ne({
|
|
|
52
53
|
["cookie", t.request.parameters.cookie]
|
|
53
54
|
].forEach(([i, o]) => {
|
|
54
55
|
var O;
|
|
55
|
-
const c = f ? (O = p[d ?? 0]) == null ? void 0 : O[i] :
|
|
56
|
+
const c = f ? (O = p[d ?? 0]) == null ? void 0 : O[i] : W(o);
|
|
56
57
|
e[i] = {
|
|
57
58
|
...c,
|
|
58
59
|
...w[i],
|
|
59
60
|
...e[i]
|
|
60
61
|
};
|
|
61
62
|
});
|
|
62
|
-
const x =
|
|
63
|
+
const x = G(
|
|
63
64
|
S
|
|
64
65
|
);
|
|
65
66
|
e.query = { ...e.query, ...x.query }, e.header = { ...e.header, ...x.header }, e.cookie = { ...e.cookie, ...x.cookie };
|
|
66
67
|
const u = Object.values(t.request.body)[0];
|
|
67
68
|
if (u != null && u.schemaArray.length) {
|
|
68
|
-
const i = f ? (N = p[d ?? 0]) == null ? void 0 : N.body :
|
|
69
|
+
const i = f ? (N = p[d ?? 0]) == null ? void 0 : N.body : Q(u.schemaArray[0]), o = w.body;
|
|
69
70
|
if (typeof i == "object" && i !== null)
|
|
70
71
|
e.body = Object.assign(
|
|
71
72
|
{},
|
|
@@ -80,21 +81,21 @@ function Ne({
|
|
|
80
81
|
}
|
|
81
82
|
JSON.stringify(e) !== JSON.stringify(a) && m(e);
|
|
82
83
|
}, [g, t, d, S]), /* @__PURE__ */ s(
|
|
83
|
-
|
|
84
|
+
Z,
|
|
84
85
|
{
|
|
85
86
|
isPlaygroundExpanded: g,
|
|
86
|
-
setIsPlaygroundExpanded:
|
|
87
|
+
setIsPlaygroundExpanded: F,
|
|
87
88
|
children: [
|
|
88
89
|
/* @__PURE__ */ s("div", { className: "mint:flex mint:items-center mint:justify-between mint:gap-x-2", children: [
|
|
89
|
-
/* @__PURE__ */ r(
|
|
90
|
-
/* @__PURE__ */ r(
|
|
90
|
+
/* @__PURE__ */ r(L, { endpoint: t, pathname: j }),
|
|
91
|
+
/* @__PURE__ */ r(T, { endpoint: t, hasGrayBackground: !0, display: "interactive" }),
|
|
91
92
|
/* @__PURE__ */ r(
|
|
92
|
-
|
|
93
|
+
Y,
|
|
93
94
|
{
|
|
94
95
|
label: "Send",
|
|
95
96
|
method: t.method,
|
|
96
|
-
isSending:
|
|
97
|
-
onClick:
|
|
97
|
+
isSending: E,
|
|
98
|
+
onClick: M,
|
|
98
99
|
className: "mint:w-20"
|
|
99
100
|
}
|
|
100
101
|
)
|
|
@@ -104,7 +105,7 @@ function Ne({
|
|
|
104
105
|
/* @__PURE__ */ s("div", { className: "mint:space-y-1 mint:min-w-full mint:w-full mint:max-w-full mint:overflow-hidden", children: [
|
|
105
106
|
/* @__PURE__ */ r("div", { className: "mint:text-base mint:font-medium mint:text-gray-900 mint:dark:text-white mint:max-w-full", children: t.title }),
|
|
106
107
|
/* @__PURE__ */ r("div", { className: "mint:flex mint:items-start mint:gap-x-12 mint:justify-between mint:max-w-full! mint:overflow-x-auto", children: b.description && /* @__PURE__ */ r(
|
|
107
|
-
|
|
108
|
+
H,
|
|
108
109
|
{
|
|
109
110
|
markdown: b.description,
|
|
110
111
|
className: "mint:text-sm mint:text-gray-500 mint:dark:text-gray-400"
|
|
@@ -114,21 +115,21 @@ function Ne({
|
|
|
114
115
|
l && /* @__PURE__ */ r(P, { result: l, className: "mint:mt-6 mint:block mint:lg:hidden" }),
|
|
115
116
|
/* @__PURE__ */ s("div", { className: "mint:space-y-2 mint:mt-6", children: [
|
|
116
117
|
n && Object.keys(n).length > 0 && /* @__PURE__ */ r(
|
|
117
|
-
|
|
118
|
+
ee,
|
|
118
119
|
{
|
|
119
120
|
variables: n,
|
|
120
121
|
value: a.server,
|
|
121
122
|
setValue: (e) => m({ ...a, server: e })
|
|
122
123
|
}
|
|
123
124
|
),
|
|
124
|
-
|
|
125
|
-
|
|
125
|
+
V && /* @__PURE__ */ r(
|
|
126
|
+
$,
|
|
126
127
|
{
|
|
127
128
|
inputs: a,
|
|
128
129
|
setInputs: m,
|
|
129
130
|
securityOptions: q,
|
|
130
131
|
selectedSecurityOptionIndex: v,
|
|
131
|
-
setSelectedSecurityOptionIndex:
|
|
132
|
+
setSelectedSecurityOptionIndex: A
|
|
132
133
|
}
|
|
133
134
|
),
|
|
134
135
|
/* @__PURE__ */ r(
|
|
@@ -168,7 +169,7 @@ function Ne({
|
|
|
168
169
|
}
|
|
169
170
|
),
|
|
170
171
|
/* @__PURE__ */ r(
|
|
171
|
-
|
|
172
|
+
_,
|
|
172
173
|
{
|
|
173
174
|
value: a.body,
|
|
174
175
|
setValue: (e) => m({ ...a, body: e }),
|
|
@@ -180,13 +181,13 @@ function Ne({
|
|
|
180
181
|
/* @__PURE__ */ s(
|
|
181
182
|
"div",
|
|
182
183
|
{
|
|
183
|
-
className:
|
|
184
|
+
className: z(
|
|
184
185
|
"mint:p-px mint:col-span-1 mint:lg:col-span-2 mint:lg:space-y-6 mint:lg:flex mint:lg:sticky mint:lg:top-0 mint:lg:self-start mint:lg:h-[calc(100vh-5.5rem)]",
|
|
185
186
|
l && "mint:lg:flex-col mint:overflow-y-auto mint:lg:-top-12 mint:lg:h-screen"
|
|
186
187
|
),
|
|
187
188
|
children: [
|
|
188
189
|
l && /* @__PURE__ */ r(P, { result: l, className: "mint:hidden mint:lg:block mint:min-h-fit" }),
|
|
189
|
-
/* @__PURE__ */ r(
|
|
190
|
+
/* @__PURE__ */ r(te, { isModal: !0, "data-testid": "api-playground-request-example", className: "mint:xl:w-full" })
|
|
190
191
|
]
|
|
191
192
|
}
|
|
192
193
|
)
|
|
@@ -196,6 +197,6 @@ function Ne({
|
|
|
196
197
|
);
|
|
197
198
|
}
|
|
198
199
|
export {
|
|
199
|
-
|
|
200
|
+
Oe as PlaygroundModal
|
|
200
201
|
};
|
|
201
202
|
//# sourceMappingURL=PlaygroundModal.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PlaygroundModal.js","sources":["../../../../src/api-playground/ApiPlayground/Request/PlaygroundModal.tsx"],"sourcesContent":["'use client';\n\nimport { ApiPlaygroundInputs, Endpoint } from '@mintlify/validation';\nimport { useContext, useState, useEffect } from 'react';\n\nimport { DescriptionWithoutHeaders } from '@/api-playground/EndpointFields/components/Description';\nimport { useApiPlaygroundPrefillExamples } from '@/hooks/useApiPlaygroundPrefillExamples';\nimport { useMDXContent } from '@/hooks/useMDXContent';\nimport { parseAuthInputsFromUserInfo } from '@/hooks/usePrefilledInputs';\nimport { useSecurityOption } from '@/hooks/useSecurityOption';\nimport {\n getDefaultsFromParameterGroup,\n getDefaultFromSchema,\n} from '@/utils/api-playground/defaults';\nimport { paramFieldDefaults } from '@/utils/api-playground/paramFieldDefaults';\nimport { getFilteredSecurityOptions } from '@/utils/api-reference/getFilteredSecurityOptions';\nimport { cn } from '@/api-playground-2/schemaGraph/utils';\n\nimport { ApiPlaygroundContext } from '../ApiPlaygroundContext';\nimport { Response } from '../Response';\nimport { EndpointsMenu } from '../components/EndpointsMenu';\nimport { PathHeader, SendPill } from '../components/PathHeader';\nimport { PlaygroundModalWrapper } from '../components/PlaygroundModalWrapper';\nimport { BodySection } from './BodySection';\nimport { ParameterSection } from './ParameterSection';\nimport { SecuritySection } from './SecuritySection';\nimport { ServerSection } from './ServerSection';\nimport ApiExamples from '@/api-playground-2/ApiExamples';\n\nexport function PlaygroundModal({\n endpoint,\n inputs,\n setInputs,\n}: {\n endpoint: Endpoint;\n inputs: ApiPlaygroundInputs;\n setInputs: (inputs: ApiPlaygroundInputs) => void;\n}) {\n const [{ pageMetadata }] = useMDXContent();\n const [selectedSecurityOptionIndex, setSelectedSecurityOptionIndex] = useState(0);\n const { prefillExamplesEnabled, generatedRequestExampleData } = useApiPlaygroundPrefillExamples();\n const securityOption = useSecurityOption(endpoint.request.security);\n\n const {\n isSending,\n selectedBaseUrlIndex,\n isPlaygroundExpanded,\n setIsPlaygroundExpanded,\n sendRequest,\n result,\n selectedExampleIndex,\n } = useContext(ApiPlaygroundContext);\n const server = endpoint.servers?.[selectedBaseUrlIndex];\n\n const filteredSecurityOptions = getFilteredSecurityOptions(endpoint);\n\n const selectedSecurityOption = filteredSecurityOptions[selectedSecurityOptionIndex];\n\n const variables = server?.variables;\n\n useEffect(() => {\n if (!isPlaygroundExpanded) return;\n\n const nextInputs: ApiPlaygroundInputs = prefillExamplesEnabled\n ? generatedRequestExampleData[selectedExampleIndex ?? 0]\n : JSON.parse(JSON.stringify(inputs));\n\n if (variables) {\n const serverDefaults: Record<string, string> = {};\n Object.entries(variables).forEach(([k, v]) => {\n if (nextInputs.server[k] === undefined) {\n serverDefaults[k] = String(v.default);\n }\n });\n nextInputs.server = { ...nextInputs.server, ...serverDefaults };\n }\n\n const paramSections: Array<\n ['header' | 'path' | 'query' | 'cookie', typeof endpoint.request.parameters.header]\n > = [\n ['header', endpoint.request.parameters.header],\n ['path', endpoint.request.parameters.path],\n ['query', endpoint.request.parameters.query],\n ['cookie', endpoint.request.parameters.cookie],\n ];\n\n paramSections.forEach(([section, group]) => {\n const spec = prefillExamplesEnabled\n ? generatedRequestExampleData[selectedExampleIndex ?? 0]?.[section]\n : getDefaultsFromParameterGroup(group);\n\n nextInputs[section] = {\n ...spec,\n ...paramFieldDefaults[section],\n ...nextInputs[section],\n };\n });\n\n const userInfoAuthInputs = parseAuthInputsFromUserInfo(\n securityOption,\n undefined\n );\n\n nextInputs.query = { ...nextInputs.query, ...userInfoAuthInputs.query };\n nextInputs.header = { ...nextInputs.header, ...userInfoAuthInputs.header };\n nextInputs.cookie = { ...nextInputs.cookie, ...userInfoAuthInputs.cookie };\n\n const bodyEntry = Object.values(endpoint.request.body)[0];\n if (bodyEntry?.schemaArray.length) {\n const bodyDefaultFromSpec = prefillExamplesEnabled\n ? generatedRequestExampleData[selectedExampleIndex ?? 0]?.body\n : getDefaultFromSchema(bodyEntry.schemaArray[0]);\n\n const bodyDefaultsFromParamField: Record<string, unknown> = paramFieldDefaults.body;\n\n if (typeof bodyDefaultFromSpec === 'object' && bodyDefaultFromSpec !== null) {\n nextInputs.body = Object.assign(\n {},\n bodyDefaultFromSpec,\n bodyDefaultsFromParamField,\n typeof nextInputs.body === 'object' &&\n nextInputs.body !== null &&\n !Array.isArray(nextInputs.body)\n ? nextInputs.body\n : {}\n );\n } else if (Object.keys(bodyDefaultsFromParamField).length) {\n const existingBody =\n typeof nextInputs.body === 'object' &&\n nextInputs.body !== null &&\n !Array.isArray(nextInputs.body)\n ? nextInputs.body\n : {};\n nextInputs.body = { ...bodyDefaultsFromParamField, ...existingBody };\n } else if (nextInputs.body === undefined && bodyDefaultFromSpec !== undefined) {\n nextInputs.body = bodyDefaultFromSpec;\n }\n }\n\n if (JSON.stringify(nextInputs) !== JSON.stringify(inputs)) {\n setInputs(nextInputs);\n }\n }, [isPlaygroundExpanded, endpoint, selectedExampleIndex, securityOption]);\n\n return (\n <PlaygroundModalWrapper\n isPlaygroundExpanded={isPlaygroundExpanded}\n setIsPlaygroundExpanded={setIsPlaygroundExpanded}\n >\n <div className=\"mint:flex mint:items-center mint:justify-between mint:gap-x-2\">\n <EndpointsMenu endpoint={endpoint} />\n <PathHeader endpoint={endpoint} hasGrayBackground display=\"interactive\" />\n <SendPill\n label=\"Send\"\n method={endpoint.method}\n isSending={isSending}\n onClick={sendRequest}\n className=\"mint:w-20\"\n />\n </div>\n <div className=\"mint:grid mint:grid-cols-1 mint:lg:grid-cols-5 mint:gap-x-8 mint:gap-y-6 mint:mt-5 mint:relative\">\n <div className=\"mint:col-span-1 mint:lg:col-span-3\">\n <div className=\"mint:space-y-1 mint:min-w-full mint:w-full mint:max-w-full mint:overflow-hidden\">\n <div className=\"mint:text-base mint:font-medium mint:text-gray-900 mint:dark:text-white mint:max-w-full\">\n {endpoint.title}\n </div>\n <div className=\"mint:flex mint:items-start mint:gap-x-12 mint:justify-between mint:max-w-full! mint:overflow-x-auto\">\n {pageMetadata.description && (\n <DescriptionWithoutHeaders\n markdown={pageMetadata.description}\n className=\"mint:text-sm mint:text-gray-500 mint:dark:text-gray-400\"\n />\n )}\n </div>\n </div>\n {result && <Response result={result} className=\"mint:mt-6 mint:block mint:lg:hidden\" />}\n <div className=\"mint:space-y-2 mint:mt-6\">\n {variables && Object.keys(variables).length > 0 && (\n <ServerSection\n variables={variables}\n value={inputs.server}\n setValue={(server) => setInputs({ ...inputs, server })}\n />\n )}\n {selectedSecurityOption && (\n <SecuritySection\n inputs={inputs}\n setInputs={setInputs}\n securityOptions={filteredSecurityOptions}\n selectedSecurityOptionIndex={selectedSecurityOptionIndex}\n setSelectedSecurityOptionIndex={setSelectedSecurityOptionIndex}\n />\n )}\n <ParameterSection\n name=\"Header\"\n value={inputs.header}\n setValue={(header) => setInputs({ ...inputs, header })}\n parameters={endpoint.request.parameters.header}\n />\n <ParameterSection\n name=\"Cookie\"\n value={inputs.cookie}\n setValue={(cookie) => setInputs({ ...inputs, cookie })}\n parameters={endpoint.request.parameters.cookie}\n />\n <ParameterSection\n name=\"Path\"\n value={inputs.path}\n setValue={(path) => setInputs({ ...inputs, path })}\n parameters={endpoint.request.parameters.path}\n />\n <ParameterSection\n name=\"Query\"\n value={inputs.query}\n setValue={(query) => setInputs({ ...inputs, query })}\n parameters={endpoint.request.parameters.query}\n />\n <BodySection\n value={inputs.body}\n setValue={(body) => setInputs({ ...inputs, body })}\n body={endpoint.request.body}\n />\n </div>\n </div>\n <div\n className={cn(\n 'mint:p-px mint:col-span-1 mint:lg:col-span-2 mint:lg:space-y-6 mint:lg:flex mint:lg:sticky mint:lg:top-0 mint:lg:self-start mint:lg:h-[calc(100vh-5.5rem)]',\n result && 'mint:lg:flex-col mint:overflow-y-auto mint:lg:-top-12 mint:lg:h-screen'\n )}\n >\n {result && <Response result={result} className=\"mint:hidden mint:lg:block mint:min-h-fit\" />}\n <ApiExamples isModal data-testid=\"api-playground-request-example\" className=\"mint:xl:w-full\" />\n </div>\n </div>\n </PlaygroundModalWrapper>\n );\n}\n"],"names":["PlaygroundModal","endpoint","inputs","setInputs","pageMetadata","useMDXContent","selectedSecurityOptionIndex","setSelectedSecurityOptionIndex","useState","prefillExamplesEnabled","generatedRequestExampleData","useApiPlaygroundPrefillExamples","securityOption","useSecurityOption","isSending","selectedBaseUrlIndex","isPlaygroundExpanded","setIsPlaygroundExpanded","sendRequest","result","selectedExampleIndex","useContext","ApiPlaygroundContext","server","_a","filteredSecurityOptions","getFilteredSecurityOptions","selectedSecurityOption","variables","useEffect","nextInputs","serverDefaults","k","v","section","group","spec","getDefaultsFromParameterGroup","paramFieldDefaults","userInfoAuthInputs","parseAuthInputsFromUserInfo","bodyEntry","bodyDefaultFromSpec","getDefaultFromSchema","bodyDefaultsFromParamField","existingBody","jsxs","PlaygroundModalWrapper","jsx","EndpointsMenu","PathHeader","SendPill","DescriptionWithoutHeaders","Response","ServerSection","SecuritySection","ParameterSection","header","cookie","path","query","BodySection","body","cn","ApiExamples"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AA6BO,SAASA,GAAgB;AAAA,EAC9B,UAAAC;AAAA,EACA,QAAAC;AAAA,EACA,WAAAC;AACF,GAIG;;AACD,QAAM,CAAC,EAAE,cAAAC,GAAc,IAAIC,EAAA,GACrB,CAACC,GAA6BC,CAA8B,IAAIC,EAAS,CAAC,GAC1E,EAAE,wBAAAC,GAAwB,6BAAAC,EAAA,IAAgCC,EAAA,GAC1DC,IAAiBC,EAAkBZ,EAAS,QAAQ,QAAQ,GAE5D;AAAA,IACJ,WAAAa;AAAA,IACA,sBAAAC;AAAA,IACA,sBAAAC;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AAAA,kBACd,UAAU,CAAC4D,MAAS3D,EAAU,EAAE,GAAGD,GAAQ,MAAA4D,GAAM;AAAA,kBACjD,MAAM7D,EAAS,QAAQ;AAAA,gBAAA;AAAA,cAAA;AAAA,YACzB,EAAA,CACF;AAAA,UAAA,GACF;AAAA,UACA,gBAAA6C;AAAA,YAAC;AAAA,YAAA;AAAA,cACC,WAAWiB;AAAA,gBACT;AAAA,gBACA5C,KAAU;AAAA,cAAA;AAAA,cAGX,UAAA;AAAA,gBAAAA,KAAU,gBAAA6B,EAACK,GAAA,EAAS,QAAAlC,GAAgB,WAAU,4CAA2C;AAAA,kCACzF6C,IAAA,EAAY,SAAO,IAAC,eAAY,kCAAiC,WAAU,iBAAA,CAAiB;AAAA,cAAA;AAAA,YAAA;AAAA,UAAA;AAAA,QAC/F,EAAA,CACF;AAAA,MAAA;AAAA,IAAA;AAAA,EAAA;AAGN;"}
|
|
1
|
+
{"version":3,"file":"PlaygroundModal.js","sources":["../../../../src/api-playground/ApiPlayground/Request/PlaygroundModal.tsx"],"sourcesContent":["\nimport { ApiPlaygroundInputs, Endpoint } from '@mintlify/validation';\nimport { useContext, useState, useEffect } from 'react';\n\nimport { DescriptionWithoutHeaders } from '@/api-playground/EndpointFields/components/Description';\nimport { useApiPlaygroundPrefillExamples } from '@/hooks/useApiPlaygroundPrefillExamples';\nimport { useMDXContent } from '@/hooks/useMDXContent';\nimport { parseAuthInputsFromUserInfo } from '@/hooks/usePrefilledInputs';\nimport { useSecurityOption } from '@/hooks/useSecurityOption';\nimport {\n getDefaultsFromParameterGroup,\n getDefaultFromSchema,\n} from '@/utils/api-playground/defaults';\nimport { paramFieldDefaults } from '@/utils/api-playground/paramFieldDefaults';\nimport { getFilteredSecurityOptions } from '@/utils/api-reference/getFilteredSecurityOptions';\nimport { cn } from '@/api-playground-2/schemaGraph/utils';\n\nimport { ApiPlaygroundContext } from '../ApiPlaygroundContext';\nimport { Response } from '../Response';\nimport { EndpointsMenu } from '../components/EndpointsMenu';\nimport { PathHeader, SendPill } from '../components/PathHeader';\nimport { PlaygroundModalWrapper } from '../components/PlaygroundModalWrapper';\nimport { BodySection } from './BodySection';\nimport { ParameterSection } from './ParameterSection';\nimport { SecuritySection } from './SecuritySection';\nimport { ServerSection } from './ServerSection';\nimport ApiExamples from '@/api-playground-2/ApiExamples';\n\nexport function PlaygroundModal({\n endpoint,\n inputs,\n setInputs,\n pathname,\n}: {\n endpoint: Endpoint;\n inputs: ApiPlaygroundInputs;\n setInputs: (inputs: ApiPlaygroundInputs) => void;\n pathname: string;\n}) {\n const [{ pageMetadata }] = useMDXContent();\n const [selectedSecurityOptionIndex, setSelectedSecurityOptionIndex] = useState(0);\n const { prefillExamplesEnabled, generatedRequestExampleData } = useApiPlaygroundPrefillExamples();\n const securityOption = useSecurityOption(endpoint.request.security);\n\n const {\n isSending,\n selectedBaseUrlIndex,\n isPlaygroundExpanded,\n setIsPlaygroundExpanded,\n sendRequest,\n result,\n selectedExampleIndex,\n } = useContext(ApiPlaygroundContext);\n const server = endpoint.servers?.[selectedBaseUrlIndex];\n\n const filteredSecurityOptions = getFilteredSecurityOptions(endpoint);\n\n const selectedSecurityOption = filteredSecurityOptions[selectedSecurityOptionIndex];\n\n const variables = server?.variables;\n\n useEffect(() => {\n if (!isPlaygroundExpanded) return;\n\n const nextInputs: ApiPlaygroundInputs = prefillExamplesEnabled\n ? generatedRequestExampleData[selectedExampleIndex ?? 0]\n : JSON.parse(JSON.stringify(inputs));\n\n if (variables) {\n const serverDefaults: Record<string, string> = {};\n Object.entries(variables).forEach(([k, v]) => {\n if (nextInputs.server[k] === undefined) {\n serverDefaults[k] = String(v.default);\n }\n });\n nextInputs.server = { ...nextInputs.server, ...serverDefaults };\n }\n\n const paramSections: Array<\n ['header' | 'path' | 'query' | 'cookie', typeof endpoint.request.parameters.header]\n > = [\n ['header', endpoint.request.parameters.header],\n ['path', endpoint.request.parameters.path],\n ['query', endpoint.request.parameters.query],\n ['cookie', endpoint.request.parameters.cookie],\n ];\n\n paramSections.forEach(([section, group]) => {\n const spec = prefillExamplesEnabled\n ? generatedRequestExampleData[selectedExampleIndex ?? 0]?.[section]\n : getDefaultsFromParameterGroup(group);\n\n nextInputs[section] = {\n ...spec,\n ...paramFieldDefaults[section],\n ...nextInputs[section],\n };\n });\n\n const userInfoAuthInputs = parseAuthInputsFromUserInfo(\n securityOption,\n undefined\n );\n\n nextInputs.query = { ...nextInputs.query, ...userInfoAuthInputs.query };\n nextInputs.header = { ...nextInputs.header, ...userInfoAuthInputs.header };\n nextInputs.cookie = { ...nextInputs.cookie, ...userInfoAuthInputs.cookie };\n\n const bodyEntry = Object.values(endpoint.request.body)[0];\n if (bodyEntry?.schemaArray.length) {\n const bodyDefaultFromSpec = prefillExamplesEnabled\n ? generatedRequestExampleData[selectedExampleIndex ?? 0]?.body\n : getDefaultFromSchema(bodyEntry.schemaArray[0]);\n\n const bodyDefaultsFromParamField: Record<string, unknown> = paramFieldDefaults.body;\n\n if (typeof bodyDefaultFromSpec === 'object' && bodyDefaultFromSpec !== null) {\n nextInputs.body = Object.assign(\n {},\n bodyDefaultFromSpec,\n bodyDefaultsFromParamField,\n typeof nextInputs.body === 'object' &&\n nextInputs.body !== null &&\n !Array.isArray(nextInputs.body)\n ? nextInputs.body\n : {}\n );\n } else if (Object.keys(bodyDefaultsFromParamField).length) {\n const existingBody =\n typeof nextInputs.body === 'object' &&\n nextInputs.body !== null &&\n !Array.isArray(nextInputs.body)\n ? nextInputs.body\n : {};\n nextInputs.body = { ...bodyDefaultsFromParamField, ...existingBody };\n } else if (nextInputs.body === undefined && bodyDefaultFromSpec !== undefined) {\n nextInputs.body = bodyDefaultFromSpec;\n }\n }\n\n if (JSON.stringify(nextInputs) !== JSON.stringify(inputs)) {\n setInputs(nextInputs);\n }\n }, [isPlaygroundExpanded, endpoint, selectedExampleIndex, securityOption]);\n\n return (\n <PlaygroundModalWrapper\n isPlaygroundExpanded={isPlaygroundExpanded}\n setIsPlaygroundExpanded={setIsPlaygroundExpanded}\n >\n <div className=\"mint:flex mint:items-center mint:justify-between mint:gap-x-2\">\n <EndpointsMenu endpoint={endpoint} pathname={pathname} />\n <PathHeader endpoint={endpoint} hasGrayBackground display=\"interactive\" />\n <SendPill\n label=\"Send\"\n method={endpoint.method}\n isSending={isSending}\n onClick={sendRequest}\n className=\"mint:w-20\"\n />\n </div>\n <div className=\"mint:grid mint:grid-cols-1 mint:lg:grid-cols-5 mint:gap-x-8 mint:gap-y-6 mint:mt-5 mint:relative\">\n <div className=\"mint:col-span-1 mint:lg:col-span-3\">\n <div className=\"mint:space-y-1 mint:min-w-full mint:w-full mint:max-w-full mint:overflow-hidden\">\n <div className=\"mint:text-base mint:font-medium mint:text-gray-900 mint:dark:text-white mint:max-w-full\">\n {endpoint.title}\n </div>\n <div className=\"mint:flex mint:items-start mint:gap-x-12 mint:justify-between mint:max-w-full! mint:overflow-x-auto\">\n {pageMetadata.description && (\n <DescriptionWithoutHeaders\n markdown={pageMetadata.description}\n className=\"mint:text-sm mint:text-gray-500 mint:dark:text-gray-400\"\n />\n )}\n </div>\n </div>\n {result && <Response result={result} className=\"mint:mt-6 mint:block mint:lg:hidden\" />}\n <div className=\"mint:space-y-2 mint:mt-6\">\n {variables && Object.keys(variables).length > 0 && (\n <ServerSection\n variables={variables}\n value={inputs.server}\n setValue={(server) => setInputs({ ...inputs, server })}\n />\n )}\n {selectedSecurityOption && (\n <SecuritySection\n inputs={inputs}\n setInputs={setInputs}\n securityOptions={filteredSecurityOptions}\n selectedSecurityOptionIndex={selectedSecurityOptionIndex}\n setSelectedSecurityOptionIndex={setSelectedSecurityOptionIndex}\n />\n )}\n <ParameterSection\n name=\"Header\"\n value={inputs.header}\n setValue={(header) => setInputs({ ...inputs, header })}\n parameters={endpoint.request.parameters.header}\n />\n <ParameterSection\n name=\"Cookie\"\n value={inputs.cookie}\n setValue={(cookie) => setInputs({ ...inputs, cookie })}\n parameters={endpoint.request.parameters.cookie}\n />\n <ParameterSection\n name=\"Path\"\n value={inputs.path}\n setValue={(path) => setInputs({ ...inputs, path })}\n parameters={endpoint.request.parameters.path}\n />\n <ParameterSection\n name=\"Query\"\n value={inputs.query}\n setValue={(query) => setInputs({ ...inputs, query })}\n parameters={endpoint.request.parameters.query}\n />\n <BodySection\n value={inputs.body}\n setValue={(body) => setInputs({ ...inputs, body })}\n body={endpoint.request.body}\n />\n </div>\n </div>\n <div\n className={cn(\n 'mint:p-px mint:col-span-1 mint:lg:col-span-2 mint:lg:space-y-6 mint:lg:flex mint:lg:sticky mint:lg:top-0 mint:lg:self-start mint:lg:h-[calc(100vh-5.5rem)]',\n result && 'mint:lg:flex-col mint:overflow-y-auto mint:lg:-top-12 mint:lg:h-screen'\n )}\n >\n {result && <Response result={result} className=\"mint:hidden mint:lg:block mint:min-h-fit\" />}\n <ApiExamples isModal data-testid=\"api-playground-request-example\" className=\"mint:xl:w-full\" />\n </div>\n </div>\n </PlaygroundModalWrapper>\n );\n}\n"],"names":["PlaygroundModal","endpoint","inputs","setInputs","pathname","pageMetadata","useMDXContent","selectedSecurityOptionIndex","setSelectedSecurityOptionIndex","useState","prefillExamplesEnabled","generatedRequestExampleData","useApiPlaygroundPrefillExamples","securityOption","useSecurityOption","isSending","selectedBaseUrlIndex","isPlaygroundExpanded","setIsPlaygroundExpanded","sendRequest","result","selectedExampleIndex","useContext","ApiPlaygroundContext","server","_a","filteredSecurityOptions","getFilteredSecurityOptions","selectedSecurityOption","variables","useEffect","nextInputs","serverDefaults","k","v","section","group","spec","getDefaultsFromParameterGroup","paramFieldDefaults","userInfoAuthInputs","parseAuthInputsFromUserInfo","bodyEntry","bodyDefaultFromSpec","getDefaultFromSchema","bodyDefaultsFromParamField","existingBody","jsxs","PlaygroundModalWrapper","jsx","EndpointsMenu","PathHeader","SendPill","DescriptionWithoutHeaders","Response","ServerSection","SecuritySection","ParameterSection","header","cookie","path","query","BodySection","body","cn","ApiExamples"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AA4BO,SAASA,GAA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GAAM;AAAA,kBACjD,YAAY3D,EAAS,QAAQ,WAAW;AAAA,gBAAA;AAAA,cAAA;AAAA,cAE1C,gBAAAgD;AAAA,gBAACQ;AAAA,gBAAA;AAAA,kBACC,MAAK;AAAA,kBACL,OAAOvD,EAAO;AAAA,kBACd,UAAU,CAAC2D,MAAU1D,EAAU,EAAE,GAAGD,GAAQ,OAAA2D,GAAO;AAAA,kBACnD,YAAY5D,EAAS,QAAQ,WAAW;AAAA,gBAAA;AAAA,cAAA;AAAA,cAE1C,gBAAAgD;AAAA,gBAACa;AAAA,gBAAA;AAAA,kBACC,OAAO5D,EAAO;AAAA,kBACd,UAAU,CAAC6D,MAAS5D,EAAU,EAAE,GAAGD,GAAQ,MAAA6D,GAAM;AAAA,kBACjD,MAAM9D,EAAS,QAAQ;AAAA,gBAAA;AAAA,cAAA;AAAA,YACzB,EAAA,CACF;AAAA,UAAA,GACF;AAAA,UACA,gBAAA8C;AAAA,YAAC;AAAA,YAAA;AAAA,cACC,WAAWiB;AAAA,gBACT;AAAA,gBACA5C,KAAU;AAAA,cAAA;AAAA,cAGX,UAAA;AAAA,gBAAAA,KAAU,gBAAA6B,EAACK,GAAA,EAAS,QAAAlC,GAAgB,WAAU,4CAA2C;AAAA,kCACzF6C,IAAA,EAAY,SAAO,IAAC,eAAY,kCAAiC,WAAU,iBAAA,CAAiB;AAAA,cAAA;AAAA,YAAA;AAAA,UAAA;AAAA,QAC/F,EAAA,CACF;AAAA,MAAA;AAAA,IAAA;AAAA,EAAA;AAGN;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SecuritySection.js","sources":["../../../../src/api-playground/ApiPlayground/Request/SecuritySection.tsx"],"sourcesContent":["'use client';\n\nimport {\n ApiPlaygroundInputs,\n DataSchemaArray,\n SecurityOption,\n SecurityParameterSchema,\n} from '@mintlify/validation';\nimport { useMemo } from 'react';\n\nimport { NoAnyDataSchema } from '@/hooks/usePlaygroundSchemaOptions';\nimport { cn } from '@/api-playground-2/schemaGraph/utils';\n\nimport { InputSectionContainer } from '../components/InputSectionContainer';\nimport { TypeDropdown } from '../components/TypeDropdown';\nimport { RecursiveInput } from './inputs/RecursiveInput';\n\nexport const basicDescription =\n 'Basic authentication header of the form `Basic <encoded-value>`, where `<encoded-value>` is the base64-encoded string `username:password`.';\nexport const bearerDescription =\n 'Bearer authentication header of the form `Bearer <token>`, where `<token>` is your auth token.';\nexport const oauth2Description =\n 'The access token received from the authorization server in the OAuth 2.0 flow.';\n\ntype SecuritySectionParams = {\n inputs: ApiPlaygroundInputs;\n setInputs: (inputs: ApiPlaygroundInputs) => void;\n securityOptions: SecurityOption[];\n selectedSecurityOptionIndex: number;\n setSelectedSecurityOptionIndex: (index: number) => void;\n};\n\nexport const SecuritySection = ({\n inputs,\n setInputs,\n securityOptions,\n selectedSecurityOptionIndex,\n setSelectedSecurityOptionIndex,\n}: SecuritySectionParams) => {\n const selectedSecurityOption = securityOptions[selectedSecurityOptionIndex];\n\n const parameters = useMemo(() => {\n if (!selectedSecurityOption) return null;\n\n return (['header', 'query', 'cookie'] as const).flatMap((location) =>\n Object.entries(selectedSecurityOption.parameters[location]).map(([name, parameter]) => {\n const {\n schemaArray,\n transform,\n value: paramValue,\n } = getPropsForParameter(parameter, inputs[location][name]);\n\n const setParamValue = (paramValue: unknown) => {\n const newObj = {\n ...inputs,\n [location]: { ...inputs[location] },\n };\n newObj[location][name] = transform(paramValue);\n setInputs(newObj);\n };\n\n const clearParamValue =\n paramValue === undefined\n ? undefined\n : () => {\n const newObj = {\n ...inputs,\n [location]: { ...inputs[location] },\n };\n delete newObj[location][name];\n setInputs(newObj);\n };\n\n return (\n <RecursiveInput\n name={name}\n key={`${location}:${name}`}\n schemaArray={schemaArray}\n value={paramValue}\n setValue={setParamValue}\n clearValue={clearParamValue}\n />\n );\n })\n );\n }, [selectedSecurityOption, setInputs, inputs]);\n\n return (\n <InputSectionContainer\n name=\"Authorization\"\n rightElement={\n <div\n onClick={(e) => e.stopPropagation()}\n className={cn('mint:text-xs mint:font-mono', securityOptions.length <= 1 && 'mint:hidden')}\n >\n <TypeDropdown\n options={securityOptions.map((option) => ({\n label: option.title,\n \n schema: option as unknown as NoAnyDataSchema,\n }))}\n selectedIndex={selectedSecurityOptionIndex}\n onSelectOption={(index) => {\n setSelectedSecurityOptionIndex(index);\n }}\n />\n </div>\n }\n >\n {parameters}\n </InputSectionContainer>\n );\n};\n\nconst getPropsForParameter = (parameter: SecurityParameterSchema, value: unknown) => {\n return {\n schemaArray: getSchemaArrayForParameter(parameter),\n transform: getTransformForParameter(parameter),\n value: parseValueForParameter(parameter, value),\n };\n};\n\nconst getSchemaArrayForParameter = (parameter: SecurityParameterSchema): DataSchemaArray => {\n const description = getDescriptionForSecurityParameter(parameter);\n switch (parameter.type) {\n case 'apiKey':\n return [\n {\n type: 'string',\n required: true,\n description,\n \n default: parameter['x-default' as never],\n },\n ];\n case 'http':\n return parameter.scheme === 'basic'\n ? [\n {\n type: 'object',\n required: true,\n description,\n properties: {\n username: [{ type: 'string' }],\n password: [{ type: 'string' }],\n },\n additionalProperties: false,\n \n default: parameter['x-default' as never],\n },\n ]\n : [\n {\n type: 'string',\n required: true,\n format: 'bearer',\n description,\n \n default: parameter['x-default' as never],\n },\n ];\n case 'oauth2':\n return [\n {\n type: 'string',\n required: true,\n format: 'bearer',\n description,\n },\n ];\n }\n};\n\nexport const getDescriptionForSecurityParameter = (\n parameter: SecurityParameterSchema\n): string | undefined => {\n switch (parameter.type) {\n case 'apiKey':\n return parameter.description;\n case 'http':\n return (\n parameter.description ??\n (parameter.scheme === 'basic' ? basicDescription : bearerDescription)\n );\n case 'oauth2':\n return parameter.description ?? oauth2Description;\n }\n};\n\nconst parseValueForParameter = (parameter: SecurityParameterSchema, value: unknown) => {\n if (\n parameter.type !== 'http' ||\n parameter.scheme !== 'basic' ||\n typeof value !== 'string' ||\n !value.startsWith('Basic ')\n )\n return value;\n\n const encoded = value.slice('Basic '.length);\n const decoded = Buffer.from(encoded, 'base64').toString('utf-8');\n const [username, password] = decoded.split(':');\n return { username, password };\n};\n\nconst getTransformForParameter = (parameter: SecurityParameterSchema) => {\n if (parameter.type !== 'http' || parameter.scheme !== 'basic') {\n return (value: unknown) => value;\n }\n\n return (value: unknown) => {\n const username =\n value && typeof value === 'object' && 'username' in value ? value['username'] : undefined;\n const password =\n value && typeof value === 'object' && 'password' in value ? value['password'] : undefined;\n const unencoded = `${username ?? ''}:${password ?? ''}`;\n const encoded = Buffer.from(unencoded).toString('base64');\n return `Basic ${encoded}`;\n };\n};\n"],"names":["basicDescription","bearerDescription","oauth2Description","SecuritySection","inputs","setInputs","securityOptions","selectedSecurityOptionIndex","setSelectedSecurityOptionIndex","selectedSecurityOption","parameters","useMemo","location","name","parameter","schemaArray","transform","paramValue","getPropsForParameter","jsx","RecursiveInput","newObj","InputSectionContainer","e","cn","TypeDropdown","option","index","value","getSchemaArrayForParameter","getTransformForParameter","parseValueForParameter","description","getDescriptionForSecurityParameter","encoded","decoded","username","password","unencoded"],"mappings":";;;;;;;AAiBO,MAAMA,IACX,8IACWC,IACX,kGACWC,IACX,kFAUWC,IAAkB,CAAC;AAAA,EAC9B,QAAAC;AAAA,EACA,WAAAC;AAAA,EACA,iBAAAC;AAAA,EACA,6BAAAC;AAAA,EACA,gCAAAC;AACF,MAA6B;AAC3B,QAAMC,IAAyBH,EAAgBC,CAA2B,GAEpEG,IAAaC,EAAQ,MACpBF,IAEG,CAAC,UAAU,SAAS,QAAQ,EAAY;AAAA,IAAQ,CAACG,MACvD,OAAO,QAAQH,EAAuB,WAAWG,CAAQ,CAAC,EAAE,IAAI,CAAC,CAACC,GAAMC,CAAS,MAAM;AACrF,YAAM;AAAA,QACJ,aAAAC;AAAA,QACA,WAAAC;AAAA,QACA,OAAOC;AAAA,MAAA,IACLC,EAAqBJ,GAAWV,EAAOQ,CAAQ,EAAEC,CAAI,CAAC;AAuB1D,aACE,gBAAAM;AAAA,QAACC;AAAA,QAAA;AAAA,UACC,MAAA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C,GAEM6B,IAAyB,CAACjB,GAAoCc,MAAmB;AACrF,MACEd,EAAU,SAAS,UACnBA,EAAU,WAAW,WACrB,OAAOc,KAAU,YACjB,CAACA,EAAM,WAAW,QAAQ;AAE1B,WAAOA;AAET,QAAMM,IAAUN,EAAM,MAAM,CAAe,GACrCO,IAAU,OAAO,KAAKD,GAAS,QAAQ,EAAE,SAAS,OAAO,GACzD,CAACE,GAAUC,CAAQ,IAAIF,EAAQ,MAAM,GAAG;AAC9C,SAAO,EAAE,UAAAC,GAAU,UAAAC,EAAA;AACrB,GAEMP,IAA2B,CAAChB,MAC5BA,EAAU,SAAS,UAAUA,EAAU,WAAW,UAC7C,CAACc,MAAmBA,IAGtB,CAACA,MAAmB;AACzB,QAAMQ,IACJR,KAAS,OAAOA,KAAU,YAAY,cAAcA,IAAQA,EAAM,WAAc,QAC5ES,IACJT,KAAS,OAAOA,KAAU,YAAY,cAAcA,IAAQA,EAAM,WAAc,QAC5EU,IAAY,GAAGF,KAAY,EAAE,IAAIC,KAAY,EAAE;AAErD,SAAO,SADS,OAAO,KAAKC,CAAS,EAAE,SAAS,QAAQ,CACjC;AACzB;"}
|
|
1
|
+
{"version":3,"file":"SecuritySection.js","sources":["../../../../src/api-playground/ApiPlayground/Request/SecuritySection.tsx"],"sourcesContent":["\nimport {\n ApiPlaygroundInputs,\n DataSchemaArray,\n SecurityOption,\n SecurityParameterSchema,\n} from '@mintlify/validation';\nimport { useMemo } from 'react';\n\nimport { NoAnyDataSchema } from '@/hooks/usePlaygroundSchemaOptions';\nimport { cn } from '@/api-playground-2/schemaGraph/utils';\n\nimport { InputSectionContainer } from '../components/InputSectionContainer';\nimport { TypeDropdown } from '../components/TypeDropdown';\nimport { RecursiveInput } from './inputs/RecursiveInput';\n\nexport const basicDescription =\n 'Basic authentication header of the form `Basic <encoded-value>`, where `<encoded-value>` is the base64-encoded string `username:password`.';\nexport const bearerDescription =\n 'Bearer authentication header of the form `Bearer <token>`, where `<token>` is your auth token.';\nexport const oauth2Description =\n 'The access token received from the authorization server in the OAuth 2.0 flow.';\n\ntype SecuritySectionParams = {\n inputs: ApiPlaygroundInputs;\n setInputs: (inputs: ApiPlaygroundInputs) => void;\n securityOptions: SecurityOption[];\n selectedSecurityOptionIndex: number;\n setSelectedSecurityOptionIndex: (index: number) => void;\n};\n\nexport const SecuritySection = ({\n inputs,\n setInputs,\n securityOptions,\n selectedSecurityOptionIndex,\n setSelectedSecurityOptionIndex,\n}: SecuritySectionParams) => {\n const selectedSecurityOption = securityOptions[selectedSecurityOptionIndex];\n\n const parameters = useMemo(() => {\n if (!selectedSecurityOption) return null;\n\n return (['header', 'query', 'cookie'] as const).flatMap((location) =>\n Object.entries(selectedSecurityOption.parameters[location]).map(([name, parameter]) => {\n const {\n schemaArray,\n transform,\n value: paramValue,\n } = getPropsForParameter(parameter, inputs[location][name]);\n\n const setParamValue = (paramValue: unknown) => {\n const newObj = {\n ...inputs,\n [location]: { ...inputs[location] },\n };\n newObj[location][name] = transform(paramValue);\n setInputs(newObj);\n };\n\n const clearParamValue =\n paramValue === undefined\n ? undefined\n : () => {\n const newObj = {\n ...inputs,\n [location]: { ...inputs[location] },\n };\n delete newObj[location][name];\n setInputs(newObj);\n };\n\n return (\n <RecursiveInput\n name={name}\n key={`${location}:${name}`}\n schemaArray={schemaArray}\n value={paramValue}\n setValue={setParamValue}\n clearValue={clearParamValue}\n />\n );\n })\n );\n }, [selectedSecurityOption, setInputs, inputs]);\n\n return (\n <InputSectionContainer\n name=\"Authorization\"\n rightElement={\n <div\n onClick={(e) => e.stopPropagation()}\n className={cn('mint:text-xs mint:font-mono', securityOptions.length <= 1 && 'mint:hidden')}\n >\n <TypeDropdown\n options={securityOptions.map((option) => ({\n label: option.title,\n \n schema: option as unknown as NoAnyDataSchema,\n }))}\n selectedIndex={selectedSecurityOptionIndex}\n onSelectOption={(index) => {\n setSelectedSecurityOptionIndex(index);\n }}\n />\n </div>\n }\n >\n {parameters}\n </InputSectionContainer>\n );\n};\n\nconst getPropsForParameter = (parameter: SecurityParameterSchema, value: unknown) => {\n return {\n schemaArray: getSchemaArrayForParameter(parameter),\n transform: getTransformForParameter(parameter),\n value: parseValueForParameter(parameter, value),\n };\n};\n\nconst getSchemaArrayForParameter = (parameter: SecurityParameterSchema): DataSchemaArray => {\n const description = getDescriptionForSecurityParameter(parameter);\n switch (parameter.type) {\n case 'apiKey':\n return [\n {\n type: 'string',\n required: true,\n description,\n \n default: parameter['x-default' as never],\n },\n ];\n case 'http':\n return parameter.scheme === 'basic'\n ? [\n {\n type: 'object',\n required: true,\n description,\n properties: {\n username: [{ type: 'string' }],\n password: [{ type: 'string' }],\n },\n additionalProperties: false,\n \n default: parameter['x-default' as never],\n },\n ]\n : [\n {\n type: 'string',\n required: true,\n format: 'bearer',\n description,\n \n default: parameter['x-default' as never],\n },\n ];\n case 'oauth2':\n return [\n {\n type: 'string',\n required: true,\n format: 'bearer',\n description,\n },\n ];\n }\n};\n\nexport const getDescriptionForSecurityParameter = (\n parameter: SecurityParameterSchema\n): string | undefined => {\n switch (parameter.type) {\n case 'apiKey':\n return parameter.description;\n case 'http':\n return (\n parameter.description ??\n (parameter.scheme === 'basic' ? basicDescription : bearerDescription)\n );\n case 'oauth2':\n return parameter.description ?? oauth2Description;\n }\n};\n\nconst parseValueForParameter = (parameter: SecurityParameterSchema, value: unknown) => {\n if (\n parameter.type !== 'http' ||\n parameter.scheme !== 'basic' ||\n typeof value !== 'string' ||\n !value.startsWith('Basic ')\n )\n return value;\n\n const encoded = value.slice('Basic '.length);\n const decoded = Buffer.from(encoded, 'base64').toString('utf-8');\n const [username, password] = decoded.split(':');\n return { username, password };\n};\n\nconst getTransformForParameter = (parameter: SecurityParameterSchema) => {\n if (parameter.type !== 'http' || parameter.scheme !== 'basic') {\n return (value: unknown) => value;\n }\n\n return (value: unknown) => {\n const username =\n value && typeof value === 'object' && 'username' in value ? value['username'] : undefined;\n const password =\n value && typeof value === 'object' && 'password' in value ? value['password'] : undefined;\n const unencoded = `${username ?? ''}:${password ?? ''}`;\n const encoded = Buffer.from(unencoded).toString('base64');\n return `Basic ${encoded}`;\n };\n};\n"],"names":["basicDescription","bearerDescription","oauth2Description","SecuritySection","inputs","setInputs","securityOptions","selectedSecurityOptionIndex","setSelectedSecurityOptionIndex","selectedSecurityOption","parameters","useMemo","location","name","parameter","schemaArray","transform","paramValue","getPropsForParameter","jsx","RecursiveInput","newObj","InputSectionContainer","e","cn","TypeDropdown","option","index","value","getSchemaArrayForParameter","getTransformForParameter","parseValueForParameter","description","getDescriptionForSecurityParameter","encoded","decoded","username","password","unencoded"],"mappings":";;;;;;;AAgBO,MAAMA,IACX,8IACWC,IACX,kGACWC,IACX,kFAUWC,IAAkB,CAAC;AAAA,EAC9B,QAAAC;AAAA,EACA,WAAAC;AAAA,EACA,iBAAAC;AAAA,EACA,6BAAAC;AAAA,EACA,gCAAAC;AACF,MAA6B;AAC3B,QAAMC,IAAyBH,EAAgBC,CAA2B,GAEpEG,IAAaC,EAAQ,MACpBF,IAEG,CAAC,UAAU,SAAS,QAAQ,EAAY;AAAA,IAAQ,CAACG,MACvD,OAAO,QAAQH,EAAuB,WAAWG,CAAQ,CAAC,EAAE,IAAI,CAAC,CAACC,GAAMC,CAAS,MAAM;AACrF,YAAM;AAAA,QACJ,aAAAC;AAAA,QACA,WAAAC;AAAA,QACA,OAAOC;AAAA,MAAA,IACLC,EAAqBJ,GAAWV,EAAOQ,CAAQ,EAAEC,CAAI,CAAC;AAuB1D,aACE,gBAAAM;AAAA,QAACC;AAAA,QAAA;AAAA,UACC,MAAAP;AAAA,UAEA,aAAAE;AAAA,UACA,OAAOE;AAAA,UACP,UA3BkB,CAACA,MAAwB;AAC7C,kBAAMI,IAAS;AAAA,cACb,GAAGjB;AAAA,cACH,CAACQ,CAAQ,GAAG,EAAE,GAAGR,EAAOQ,CAAQ,EAAA;AAAA,YAAE;AAEpC,YAAAS,EAAOT,CAAQ,EAAEC,CAAI,IAAIG,EAAUC,CAAU,GAC7C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UC,CAAQ,IAAIF,EAAQ,MAAM,GAAG;AAC9C,SAAO,EAAE,UAAAC,GAAU,UAAAC,EAAA;AACrB,GAEMP,IAA2B,CAAChB,MAC5BA,EAAU,SAAS,UAAUA,EAAU,WAAW,UAC7C,CAACc,MAAmBA,IAGtB,CAACA,MAAmB;AACzB,QAAMQ,IACJR,KAAS,OAAOA,KAAU,YAAY,cAAcA,IAAQA,EAAM,WAAc,QAC5ES,IACJT,KAAS,OAAOA,KAAU,YAAY,cAAcA,IAAQA,EAAM,WAAc,QAC5EU,IAAY,GAAGF,KAAY,EAAE,IAAIC,KAAY,EAAE;AAErD,SAAO,SADS,OAAO,KAAKC,CAAS,EAAE,SAAS,QAAQ,CACjC;AACzB;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ServerSection.js","sources":["../../../../src/api-playground/ApiPlayground/Request/ServerSection.tsx"],"sourcesContent":["
|
|
1
|
+
{"version":3,"file":"ServerSection.js","sources":["../../../../src/api-playground/ApiPlayground/Request/ServerSection.tsx"],"sourcesContent":["\nimport { Server } from '@mintlify/validation';\nimport { useMemo } from 'react';\n\nimport { InputSectionContainer } from '../components/InputSectionContainer';\nimport { RecursiveInput } from './inputs/RecursiveInput';\n\ntype ServerSectionProps = {\n variables: NonNullable<Server['variables']>;\n value: Record<string, string>;\n setValue: (value: Record<string, string>) => void;\n};\n\nexport const ServerSection = ({ variables, value, setValue }: ServerSectionProps) => {\n const inputs = useMemo(() => {\n return Object.entries(variables).map(([key, schema]) => {\n const paramValue = value[key];\n const setParamValue = (newParamValue: unknown) => {\n const newObj = { ...value };\n newObj[key] = String(newParamValue);\n setValue(newObj);\n };\n const clearParamValue =\n paramValue === undefined\n ? undefined\n : () => {\n const newObj = { ...value };\n delete newObj[key];\n setValue(newObj);\n };\n\n return (\n <RecursiveInput\n key={key}\n name={key}\n schemaArray={[schema]}\n value={paramValue}\n setValue={setParamValue}\n clearValue={clearParamValue}\n />\n );\n });\n }, [variables, setValue, value]);\n\n return <InputSectionContainer name=\"Server\">{inputs}</InputSectionContainer>;\n};\n"],"names":["ServerSection","variables","value","setValue","inputs","useMemo","key","schema","paramValue","jsx","RecursiveInput","newParamValue","newObj","InputSectionContainer"],"mappings":";;;;AAaO,MAAMA,IAAgB,CAAC,EAAE,WAAAC,GAAW,OAAAC,GAAO,UAAAC,QAAmC;AACnF,QAAMC,IAASC,EAAQ,MACd,OAAO,QAAQJ,CAAS,EAAE,IAAI,CAAC,CAACK,GAAKC,CAAM,MAAM;AACtD,UAAMC,IAAaN,EAAMI,CAAG;AAe5B,WACE,gBAAAG;AAAA,MAACC;AAAA,MAAA;AAAA,QAEC,MAAMJ;AAAA,QACN,aAAa,CAACC,CAAM;AAAA,QACpB,OAAOC;AAAA,QACP,UApBkB,CAACG,MAA2B;AAChD,gBAAMC,IAAS,EAAE,GAAGV,EAAA;AACpB,UAAAU,EAAON,CAAG,IAAI,OAAOK,CAAa,GAClCR,EAASS,CAAM;AAAA,QACjB;AAAA,QAiBI,YAfFJ,MAAe,SACX,SACA,MAAM;AACJ,gBAAMI,IAAS,EAAE,GAAGV,EAAA;AACpB,iBAAOU,EAAON,CAAG,GACjBH,EAASS,CAAM;AAAA,QACjB;AAAA,MASU;AAAA,MALPN;AAAA,IAAA;AAAA,EAQX,CAAC,GACA,CAACL,GAAWE,GAAUD,CAAK,CAAC;AAE/B,SAAO,gBAAAO,EAACI,GAAA,EAAsB,MAAK,UAAU,UAAAT,GAAO;AACtD;"}
|
|
@@ -1,44 +1,44 @@
|
|
|
1
|
-
import { jsx as e, jsxs as
|
|
2
|
-
import { useContext as
|
|
3
|
-
import { usePrefilledInputs as
|
|
4
|
-
import { useSecurityOption as
|
|
5
|
-
import
|
|
1
|
+
import { jsx as e, jsxs as d } from "react/jsx-runtime";
|
|
2
|
+
import { useContext as f } from "react";
|
|
3
|
+
import { usePrefilledInputs as a } from "../../../hooks/usePrefilledInputs/index.js";
|
|
4
|
+
import { useSecurityOption as p } from "../../../hooks/useSecurityOption.js";
|
|
5
|
+
import x from "../../../components/Api/ErrorBoundary.js";
|
|
6
6
|
import "@mintlify/validation";
|
|
7
|
-
import { cn as
|
|
8
|
-
import { ApiPlaygroundContext as
|
|
9
|
-
import { EndpointHeader as
|
|
10
|
-
import { PlaygroundModal as
|
|
11
|
-
const
|
|
7
|
+
import { cn as b } from "../../../utils/cn.js";
|
|
8
|
+
import { ApiPlaygroundContext as g } from "../ApiPlaygroundContext.js";
|
|
9
|
+
import { EndpointHeader as k } from "../components/PathHeader.js";
|
|
10
|
+
import { PlaygroundModal as y } from "./PlaygroundModal.js";
|
|
11
|
+
const w = ({ endpoint: r, inputs: i, setInputs: m, display: n, pathname: s }) => {
|
|
12
12
|
var l;
|
|
13
|
-
const { selectedBaseUrlIndex:
|
|
14
|
-
return
|
|
13
|
+
const { selectedBaseUrlIndex: u, setIsPlaygroundExpanded: o } = f(g), t = (l = r.servers) == null ? void 0 : l[u], c = p(r.request.security);
|
|
14
|
+
return a({
|
|
15
15
|
inputs: i,
|
|
16
16
|
setInputs: m,
|
|
17
17
|
baseUrl: t == null ? void 0 : t.url,
|
|
18
|
-
securityOption:
|
|
18
|
+
securityOption: c,
|
|
19
19
|
userInfoInputs: void 0
|
|
20
|
-
}), /* @__PURE__ */ e(
|
|
20
|
+
}), /* @__PURE__ */ e(x, { children: /* @__PURE__ */ d(
|
|
21
21
|
"div",
|
|
22
22
|
{
|
|
23
|
-
className:
|
|
23
|
+
className: b(
|
|
24
24
|
"mint:flex mint:w-full mint:flex-col mint:bg-background-light mint:dark:bg-background-dark mint:border-standard mint:rounded-2xl",
|
|
25
25
|
n === "simple" ? "mint:p-1" : "mint:p-1.5"
|
|
26
26
|
),
|
|
27
27
|
children: [
|
|
28
28
|
/* @__PURE__ */ e(
|
|
29
|
-
|
|
29
|
+
k,
|
|
30
30
|
{
|
|
31
31
|
endpoint: r,
|
|
32
32
|
display: n,
|
|
33
33
|
onClickInteractive: () => o == null ? void 0 : o(!0)
|
|
34
34
|
}
|
|
35
35
|
),
|
|
36
|
-
/* @__PURE__ */ e(
|
|
36
|
+
/* @__PURE__ */ e(y, { endpoint: r, inputs: i, setInputs: m, pathname: s })
|
|
37
37
|
]
|
|
38
38
|
}
|
|
39
39
|
) });
|
|
40
40
|
};
|
|
41
41
|
export {
|
|
42
|
-
|
|
42
|
+
w as Request
|
|
43
43
|
};
|
|
44
44
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../../src/api-playground/ApiPlayground/Request/index.tsx"],"sourcesContent":["
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../src/api-playground/ApiPlayground/Request/index.tsx"],"sourcesContent":["\nimport { ApiPlaygroundDisplayType } from '@mintlify/models';\nimport { ApiPlaygroundInputs, Endpoint } from '@mintlify/validation';\nimport { useContext } from 'react';\n\nimport { usePrefilledInputs } from '@/hooks/usePrefilledInputs';\nimport { useSecurityOption } from '@/hooks/useSecurityOption';\nimport ErrorBoundary from '@/components/Api/ErrorBoundary';\nimport { cn } from '@/api-playground-2/schemaGraph/utils';\n\nimport { ApiPlaygroundContext } from '../ApiPlaygroundContext';\nimport { EndpointHeader } from '../components/PathHeader';\nimport { PlaygroundModal } from './PlaygroundModal';\n\ntype RequestParams = {\n endpoint: Endpoint;\n inputs: ApiPlaygroundInputs;\n setInputs: (inputs: ApiPlaygroundInputs) => void;\n display: ApiPlaygroundDisplayType;\n pathname: string;\n};\n\nexport const Request = ({ endpoint, inputs, setInputs, display, pathname }: RequestParams) => {\n const { selectedBaseUrlIndex, setIsPlaygroundExpanded } = useContext(ApiPlaygroundContext);\n const server = endpoint.servers?.[selectedBaseUrlIndex];\n\n const securityOption = useSecurityOption(endpoint.request.security);\n usePrefilledInputs({\n inputs,\n setInputs,\n baseUrl: server?.url,\n securityOption,\n userInfoInputs: undefined,\n });\n\n return (\n <ErrorBoundary>\n <div\n className={cn(\n 'mint:flex mint:w-full mint:flex-col mint:bg-background-light mint:dark:bg-background-dark mint:border-standard mint:rounded-2xl',\n display === 'simple' ? 'mint:p-1' : 'mint:p-1.5'\n )}\n >\n <EndpointHeader\n endpoint={endpoint}\n display={display}\n onClickInteractive={() => setIsPlaygroundExpanded?.(true)}\n />\n <PlaygroundModal endpoint={endpoint} inputs={inputs} setInputs={setInputs} pathname={pathname} />\n </div>\n </ErrorBoundary>\n );\n};\n"],"names":["Request","endpoint","inputs","setInputs","display","pathname","selectedBaseUrlIndex","setIsPlaygroundExpanded","useContext","ApiPlaygroundContext","server","_a","securityOption","useSecurityOption","usePrefilledInputs","ErrorBoundary","jsxs","cn","jsx","EndpointHeader","PlaygroundModal"],"mappings":";;;;;;;;;;AAsBO,MAAMA,IAAU,CAAC,EAAE,UAAAC,GAAU,QAAAC,GAAQ,WAAAC,GAAW,SAAAC,GAAS,UAAAC,QAA8B;;AAC5F,QAAM,EAAE,sBAAAC,GAAsB,yBAAAC,MAA4BC,EAAWC,CAAoB,GACnFC,KAASC,IAAAV,EAAS,YAAT,gBAAAU,EAAmBL,IAE5BM,IAAiBC,EAAkBZ,EAAS,QAAQ,QAAQ;AAClE,SAAAa,EAAmB;AAAA,IACjB,QAAAZ;AAAA,IACA,WAAAC;AAAA,IACA,SAASO,KAAA,gBAAAA,EAAQ;AAAA,IACjB,gBAAAE;AAAA,IACA,gBAAgB;AAAA,EAAA,CACjB,qBAGEG,GAAA,EACC,UAAA,gBAAAC;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,WAAWC;AAAA,QACT;AAAA,QACAb,MAAY,WAAW,aAAa;AAAA,MAAA;AAAA,MAGtC,UAAA;AAAA,QAAA,gBAAAc;AAAA,UAACC;AAAA,UAAA;AAAA,YACC,UAAAlB;AAAA,YACA,SAAAG;AAAA,YACA,oBAAoB,MAAMG,KAAA,gBAAAA,EAA0B;AAAA,UAAI;AAAA,QAAA;AAAA,QAE1D,gBAAAW,EAACE,GAAA,EAAgB,UAAAnB,GAAoB,QAAAC,GAAgB,WAAAC,GAAsB,UAAAE,EAAA,CAAoB;AAAA,MAAA;AAAA,IAAA;AAAA,EAAA,GAEnG;AAEJ;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ArrayInput.js","sources":["../../../../../src/api-playground/ApiPlayground/Request/inputs/ArrayInput.tsx"],"sourcesContent":["
|
|
1
|
+
{"version":3,"file":"ArrayInput.js","sources":["../../../../../src/api-playground/ApiPlayground/Request/inputs/ArrayInput.tsx"],"sourcesContent":["\nimport { ArraySchema, IncrementalArraySchema } from '@mintlify/validation';\nimport { useMemo, useState } from 'react';\nimport { generateUniqueString } from '@/utils/uuid';\n\nimport { useGenerateNextItems } from '@/hooks/useGenerateNextItems';\nimport { AddRegular } from '@fluentui/react-icons';\nimport { cn } from '@/api-playground-2/schemaGraph/utils';\n\nimport { InputContainer } from '../../components/InputContainer';\nimport { RecursiveInput } from './RecursiveInput';\n\nexport const ArrayInput: RecursiveInput<ArraySchema | IncrementalArraySchema> = ({\n name,\n schema,\n typeDropdown,\n value,\n setValue,\n clearValue,\n depth,\n parentNames,\n}) => {\n const [childKeys, setChildKeys] = useState(value?.map(generateUniqueString) ?? []);\n const items = useGenerateNextItems(schema);\n\n const children = useMemo(() => {\n const elementInputs =\n value?.map((elemValue, i) => {\n const setElemValue = (newElemValue: unknown) => {\n const newArr = [...value];\n newArr[i] = newElemValue;\n setValue(newArr);\n };\n\n const clearElemValue = () => {\n const newArr = [...value];\n newArr.splice(i, 1);\n setChildKeys((prev) => {\n const newKeys = [...prev];\n newKeys.splice(i, 1);\n return newKeys;\n });\n setValue(newArr);\n };\n\n return (\n <RecursiveInput\n key={childKeys[i]}\n schemaArray={items}\n value={elemValue}\n setValue={setElemValue}\n clearValue={clearElemValue}\n depth={depth + 1}\n arrayIndex={i}\n />\n );\n }) ?? [];\n\n const onAddElement = () => {\n setChildKeys((prev) => [...prev, generateUniqueString()]);\n setValue([...(value ?? []), undefined]);\n };\n elementInputs.push(\n <AddAdditionalItemButton\n label=\"Add an item\"\n key=\"add-button\"\n className={cn(elementInputs.length > 0 && 'mint:mt-4')}\n onClick={onAddElement}\n dataTestId={name + '-add-item-button'}\n />\n );\n return elementInputs;\n }, [childKeys, items, value, setValue, depth, name]);\n\n return (\n <InputContainer\n name={name}\n typeDropdown={typeDropdown}\n schema={schema}\n onClear={clearValue}\n parentNames={parentNames}\n isArray\n >\n {children}\n </InputContainer>\n );\n};\n\nexport function AddAdditionalItemButton({\n className,\n onClick,\n label,\n dataTestId,\n}: {\n className?: string;\n onClick: () => void;\n label: string;\n dataTestId?: string;\n}) {\n return (\n <div className={className}>\n <button\n aria-label={label}\n className=\"mint:flex mint:text-playground-input mint:w-fit mint:items-center mint:gap-x-1.5 mint:py-1! mint:px-2! mint:hover:bg-gray-50 mint:dark:hover:bg-white/[0.03] mint:cursor-pointer\"\n onClick={onClick}\n data-testid={dataTestId}\n >\n <AddRegular className=\"mint:h-3 mint:w-3\" />\n <span className=\"mint:text-gray-600 mint:dark:text-gray-200\">{label}</span>\n </button>\n </div>\n );\n}\n"],"names":["ArrayInput","name","schema","typeDropdown","value","setValue","clearValue","depth","parentNames","childKeys","setChildKeys","useState","generateUniqueString","items","useGenerateNextItems","children","useMemo","elementInputs","elemValue","i","jsx","RecursiveInput","newElemValue","newArr","prev","newKeys","onAddElement","AddAdditionalItemButton","cn","InputContainer","className","onClick","label","dataTestId","jsxs","AddRegular"],"mappings":";;;;;;;;;AAYO,MAAMA,IAAmE,CAAC;AAAA,EAC/E,MAAAC;AAAA,EACA,QAAAC;AAAA,EACA,cAAAC;AAAA,EACA,OAAAC;AAAA,EACA,UAAAC;AAAA,EACA,YAAAC;AAAA,EACA,OAAAC;AAAA,EACA,aAAAC;AACF,MAAM;AACJ,QAAM,CAACC,GAAWC,CAAY,IAAIC,GAASP,KAAA,gBAAAA,EAAO,IAAIQ,OAAyB,EAAE,GAC3EC,IAAQC,EAAqBZ,CAAM,GAEnCa,IAAWC,EAAQ,MAAM;AAC7B,UAAMC,KAC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AAE;AAAA,MACA,SAAO;AAAA,MAEN,UAAAO;AAAA,IAAA;AAAA,EAAA;AAGP;AAEO,SAASY,EAAwB;AAAA,EACtC,WAAAG;AAAA,EACA,SAAAC;AAAA,EACA,OAAAC;AAAA,EACA,YAAAC;AACF,GAKG;AACD,SACE,gBAAAb,EAAC,SAAI,WAAAU,GACH,UAAA,gBAAAI;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,cAAYF;AAAA,MACZ,WAAU;AAAA,MACV,SAAAD;AAAA,MACA,eAAaE;AAAA,MAEb,UAAA;AAAA,QAAA,gBAAAb,EAACe,GAAA,EAAW,WAAU,oBAAA,CAAoB;AAAA,QAC1C,gBAAAf,EAAC,QAAA,EAAK,WAAU,8CAA8C,UAAAY,EAAA,CAAM;AAAA,MAAA;AAAA,IAAA;AAAA,EAAA,GAExE;AAEJ;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FileInput.js","sources":["../../../../../src/api-playground/ApiPlayground/Request/inputs/FileInput.tsx"],"sourcesContent":["
|
|
1
|
+
{"version":3,"file":"FileInput.js","sources":["../../../../../src/api-playground/ApiPlayground/Request/inputs/FileInput.tsx"],"sourcesContent":["\nimport { FileSchema } from '@mintlify/validation';\nimport { useRef } from 'react';\n\nimport { useSelectedLocale } from '@/utils/locales';\nimport { cn } from '@/api-playground-2/schemaGraph/utils';\n\nimport { InputContainer } from '../../components/InputContainer';\nimport { GenericInput } from './RecursiveInput';\n\nexport const FileInput: GenericInput<FileSchema> = ({\n name,\n schema,\n typeDropdown,\n value,\n setValue,\n clearValue,\n parentNames,\n arrayIndex,\n}) => {\n const locale = useSelectedLocale();\n const hiddenInputRef = useRef<HTMLInputElement>(null);\n\n return (\n <InputContainer\n name={name}\n typeDropdown={typeDropdown}\n schema={schema}\n onClear={clearValue}\n parentNames={parentNames}\n arrayIndex={arrayIndex}\n >\n <button\n aria-label={locale['aria.fileUploadButton']}\n className={cn(\n 'mint:text-left mint:flex mint:text-playground-input mint:overflow-hidden',\n value ? 'mint:text-gray-900! mint:dark:text-gray-100!' : 'mint:text-gray-400! mint:dark:text-white/30!'\n )}\n onClick={() => hiddenInputRef.current?.click()}\n >\n {value?.name ?? schema.placeholder ?? 'Drop a file here or click to upload'}\n </button>\n {/* HACK: file inputs are notoriously hard to style, so hide the native input and click it programmatically */}\n <input\n type=\"file\"\n data-testid=\"file-input\"\n onChange={(event) => setValue(event.target.files?.[0])}\n ref={hiddenInputRef}\n className=\"mint:hidden\"\n />\n </InputContainer>\n );\n};\n"],"names":["FileInput","name","schema","typeDropdown","value","setValue","clearValue","parentNames","arrayIndex","locale","useSelectedLocale","hiddenInputRef","useRef","jsxs","InputContainer","jsx","cn","_a","event"],"mappings":";;;;;;AAUO,MAAMA,IAAsC,CAAC;AAAA,EAClD,MAAAC;AAAA,EACA,QAAAC;AAAA,EACA,cAAAC;AAAA,EACA,OAAAC;AAAA,EACA,UAAAC;AAAA,EACA,YAAAC;AAAA,EACA,aAAAC;AAAA,EACA,YAAAC;AACF,MAAM;AACJ,QAAMC,IAASC,EAAA,GACTC,IAAiBC,EAAyB,IAAI;AAEpD,SACE,gBAAAC;AAAA,IAACC;AAAA,IAAA;AAAA,MACC,MAAAb;AAAA,MACA,cAAAE;AAAA,MACA,QAAAD;AAAA,MACA,SAASI;AAAA,MACT,aAAAC;AAAA,MACA,YAAAC;AAAA,MAEA,UAAA;AAAA,QAAA,gBAAAO;AAAA,UAAC;AAAA,UAAA;AAAA,YACC,cAAYN,EAAO,uBAAuB;AAAA,YAC1C,WAAWO;AAAA,cACT;AAAA,cACAZ,IAAQ,iDAAiD;AAAA,YAAA;AAAA,YAE3D,SAAS,MAAA;;AAAM,sBAAAa,IAAAN,EAAe,YAAf,gBAAAM,EAAwB;AAAA;AAAA,YAEtC,WAAAb,KAAA,gBAAAA,EAAO,SAAQF,EAAO,eAAe;AAAA,UAAA;AAAA,QAAA;AAAA,QAGxC,gBAAAa;AAAA,UAAC;AAAA,UAAA;AAAA,YACC,MAAK;AAAA,YACL,eAAY;AAAA,YACZ,UAAU,CAACG;;AAAU,qBAAAb,GAASY,IAAAC,EAAM,OAAO,UAAb,gBAAAD,EAAqB,EAAE;AAAA;AAAA,YACrD,KAAKN;AAAA,YACL,WAAU;AAAA,UAAA;AAAA,QAAA;AAAA,MACZ;AAAA,IAAA;AAAA,EAAA;AAGN;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NullInput.js","sources":["../../../../../src/api-playground/ApiPlayground/Request/inputs/NullInput.tsx"],"sourcesContent":["
|
|
1
|
+
{"version":3,"file":"NullInput.js","sources":["../../../../../src/api-playground/ApiPlayground/Request/inputs/NullInput.tsx"],"sourcesContent":["\nimport { NullSchema } from '@mintlify/validation';\n\nimport { InputContainer } from '../../components/InputContainer';\nimport { GenericInput } from './RecursiveInput';\nimport { cn } from \"../../../../utils/cn\";\n\nexport const NullInput: GenericInput<NullSchema> = ({\n name,\n schema,\n typeDropdown,\n clearValue,\n parentNames,\n arrayIndex,\n}) => {\n return (\n <InputContainer\n name={name}\n typeDropdown={typeDropdown}\n schema={schema}\n onClear={clearValue}\n parentNames={parentNames}\n arrayIndex={arrayIndex}\n >\n <input\n className=\"mint:flex-1 mint:min-w-0 mint:outline-0 mint:bg-transparent mint:text-playground-input\"\n type=\"text\"\n placeholder=\"--\"\n contentEditable=\"false\"\n disabled\n />\n </InputContainer>\n );\n};\n"],"names":["NullInput","name","schema","typeDropdown","clearValue","parentNames","arrayIndex","jsx","InputContainer"],"mappings":";;AAOO,MAAMA,IAAsC,CAAC;AAAA,EAClD,MAAAC;AAAA,EACA,QAAAC;AAAA,EACA,cAAAC;AAAA,EACA,YAAAC;AAAA,EACA,aAAAC;AAAA,EACA,YAAAC;AACF,MAEI,gBAAAC;AAAA,EAACC;AAAA,EAAA;AAAA,IACC,MAAAP;AAAA,IACA,cAAAE;AAAA,IACA,QAAAD;AAAA,IACA,SAASE;AAAA,IACT,aAAAC;AAAA,IACA,YAAAC;AAAA,IAEA,UAAA,gBAAAC;AAAA,MAAC;AAAA,MAAA;AAAA,QACC,WAAU;AAAA,QACV,MAAK;AAAA,QACL,aAAY;AAAA,QACZ,iBAAgB;AAAA,QAChB,UAAQ;AAAA,MAAA;AAAA,IAAA;AAAA,EACV;AAAA;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NumberInput.js","sources":["../../../../../src/api-playground/ApiPlayground/Request/inputs/NumberInput.tsx"],"sourcesContent":["
|
|
1
|
+
{"version":3,"file":"NumberInput.js","sources":["../../../../../src/api-playground/ApiPlayground/Request/inputs/NumberInput.tsx"],"sourcesContent":["\nimport { NumberSchema } from '@mintlify/validation';\nimport { ChangeEvent, useCallback } from 'react';\n\nimport { useSelectedLocale } from '@/utils/locales';\n\nimport { InputContainer } from '../../components/InputContainer';\nimport { GenericInput } from './RecursiveInput';\nimport { Ids } from '@/api-playground-2/types';\nimport { cn } from \"../../../../utils/cn\";\n\nexport const NumberInput: GenericInput<NumberSchema> = ({\n name,\n typeDropdown,\n schema,\n value,\n setValue,\n clearValue,\n arrayIndex,\n ...sharedProps\n}) => {\n const locale = useSelectedLocale();\n const onChange = useCallback(\n (event: ChangeEvent<HTMLInputElement>) => {\n if (event.target.value.length === 0) {\n setValue(undefined);\n return;\n }\n\n if (schema.type === 'integer') {\n const parsedInteger = parseInt(event.target.value);\n if (isNaN(parsedInteger)) {\n return;\n }\n setValue(parsedInteger);\n } else {\n setValue(parseFloat(event.target.value));\n }\n },\n [setValue, schema.type]\n );\n\n return (\n <InputContainer\n name={name}\n typeDropdown={typeDropdown}\n schema={schema}\n onClear={clearValue}\n parentNames={sharedProps.parentNames}\n arrayIndex={arrayIndex}\n >\n <input\n id={Ids.APIPlaygroundInput}\n className=\"mint:flex-1 mint:min-w-0 mint:bg-transparent mint:outline-0 mint:text-playground-input\"\n placeholder={schema.placeholder ?? `enter ${name ?? 'value'}`}\n aria-label={\n schema.placeholder ?? locale['aria.enterValue'].replace('{name}', name ?? 'value')\n }\n onKeyDown={(event) => {\n // disallow \"e\", and disallow \".\" for integer inputs\n if (event.key === 'e' || (event.key === '.' && schema.type === 'integer')) {\n event.preventDefault();\n }\n }}\n type=\"number\"\n value={value ?? ''}\n onChange={onChange}\n />\n </InputContainer>\n );\n};\n"],"names":["NumberInput","name","typeDropdown","schema","value","setValue","clearValue","arrayIndex","sharedProps","locale","useSelectedLocale","onChange","useCallback","event","parsedInteger","jsx","InputContainer","Ids"],"mappings":";;;;;AAWO,MAAMA,IAA0C,CAAC;AAAA,EACtD,MAAAC;AAAA,EACA,cAAAC;AAAA,EACA,QAAAC;AAAA,EACA,OAAAC;AAAA,EACA,UAAAC;AAAA,EACA,YAAAC;AAAA,EACA,YAAAC;AAAA,EACA,GAAGC;AACL,MAAM;AACJ,QAAMC,IAASC,EAAA,GACTC,IAAWC;AAAA,IACf,CAACC,MAAyC;AACxC,UAAIA,EAAM,OAAO,MAAM,WAAW,GAAG;AACnC,QAAAR,EAAS,MAAS;AAClB;AAAA,MACF;AAEA,UAAIF,EAAO,SAAS,WAAW;AAC7B,cAAMW,IAAgB,SAASD,EAAM,OAAO,KAAK;AACjD,YAAI,MAAMC,CAAa;AACrB;AAEF,QAAAT,EAASS,CAAa;AAAA,MACxB;AACE,QAAAT,EAAS,WAAWQ,EAAM,OAAO,KAAK,CAAC;AAAA,IAE3C;AAAA,IACA,CAACR,GAAUF,EAAO,IAAI;AAAA,EAAA;AAGxB,SACE,gBAAAY;AAAA,IAACC;AAAA,IAAA;AAAA,MACC,MAAAf;AAAA,MACA,cAAAC;AAAA,MACA,QAAAC;AAAA,MACA,SAASG;AAAA,MACT,aAAaE,EAAY;AAAA,MACzB,YAAAD;AAAA,MAEA,UAAA,gBAAAQ;AAAA,QAAC;AAAA,QAAA;AAAA,UACC,IAAIE,EAAI;AAAA,UACR,WAAU;AAAA,UACV,aAAad,EAAO,eAAe,SAASF,KAAQ,OAAO;AAAA,UAC3D,cACEE,EAAO,eAAeM,EAAO,iBAA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