@mintlify/msft-sdk 1.1.61 → 1.1.63
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/Response/DownloadFileButton.js +6 -5
- package/dist/api-playground/ApiPlayground/Response/ResponseBody/CodeResponseContent.js +13 -12
- package/dist/api-playground/ApiPlayground/Response/ResponsePlaceholder.js +8 -7
- package/dist/api-playground/ApiPlayground/Response/ResponseTable.js +3 -2
- package/dist/api-playground/ApiPlayground/Response/ResponseTopbar.js +9 -8
- package/dist/api-playground/ApiPlayground/Response/index.js +4 -3
- package/dist/api-playground/ApiPlayground/components/AdditionalPropertyButton.js +42 -21
- package/dist/api-playground/ApiPlayground/components/ParamFieldWrapper.js +13 -9
- package/dist/api-playground/ApiPlayground/components/PlaygroundModalWrapper.js +6 -5
- package/dist/api-playground/ApiPlayground/components/SendPill.js +3 -2
- package/dist/api-playground/ApiPlayground/components/TypeDropdown.js +6 -5
- package/dist/api-playground/EndpointFields/ParamFields/ExampleDescription.js +3 -2
- package/dist/api-playground/EndpointFields/components/Description.js +6 -5
- package/dist/api-playground/EndpointFields/components/OptionDropdown.js +9 -8
- package/dist/api-playground/EndpointFields/components/SectionHeading.js +8 -7
- package/dist/api-playground-2/ApiExamples.js +19 -20
- package/dist/api-playground-2/ApiFields.js +20 -247
- package/dist/api-playground-2/EndpointHeader.js +59 -47
- package/dist/api-playground-2/OperationPage.js +70 -66
- package/dist/api-playground-2/Playground.js +67 -83
- package/dist/api-playground-2/SchemaPage.js +22 -9
- package/dist/api-playground-2/components/EndpointFields/Body.js +40 -0
- package/dist/api-playground-2/components/EndpointFields/Parameters.js +90 -0
- package/dist/api-playground-2/components/EndpointFields/Response.js +146 -0
- package/dist/api-playground-2/components/EndpointFields/Security.js +88 -0
- package/dist/api-playground-2/components/EndpointFields/fields/ArrayParamField.js +93 -0
- package/dist/api-playground-2/components/EndpointFields/fields/Enum.js +29 -11
- package/dist/api-playground-2/components/EndpointFields/fields/ObjectParamField.js +145 -0
- package/dist/api-playground-2/components/EndpointFields/fields/PrimitiveParamField.js +60 -48
- package/dist/api-playground-2/components/EndpointFields/fields/SchemaField.js +230 -0
- package/dist/api-playground-2/components/Example/GeneratedRequestExample.js +93 -89
- package/dist/api-playground-2/components/Example/GeneratedResponseExample.js +18 -17
- package/dist/api-playground-2/components/Example/RequestExample.js +92 -93
- package/dist/api-playground-2/components/Example/ResponseExample.js +19 -15
- package/dist/api-playground-2/components/Request/ParameterSection.js +20 -18
- package/dist/api-playground-2/components/Request/SecuritySection.js +53 -43
- package/dist/api-playground-2/components/Request/inputs/ArrayInput.js +89 -40
- package/dist/api-playground-2/components/Request/inputs/DifferentiatedInput.js +12 -12
- package/dist/api-playground-2/components/Request/inputs/FileInput.js +16 -15
- package/dist/api-playground-2/components/Request/inputs/InputContainer.js +76 -57
- package/dist/api-playground-2/components/Request/inputs/NumberInput.js +10 -9
- package/dist/api-playground-2/components/Request/inputs/ObjectInput.js +98 -80
- package/dist/api-playground-2/components/Request/inputs/OneOfInput.js +55 -47
- package/dist/api-playground-2/components/Request/inputs/SelectInput.js +18 -17
- package/dist/api-playground-2/components/Request/inputs/StringInput.js +19 -18
- package/dist/api-playground-2/components/Request/inputs/TextInput.js +12 -11
- package/dist/api-playground-2/components/SendPillWrapper.js +35 -0
- package/dist/api-playground-2/contexts/ApiPlaygroundContext.js +3 -5
- package/dist/api-playground-2/generators/createCookies.js +23 -0
- package/dist/api-playground-2/generators/createHeaders.js +53 -36
- package/dist/api-playground-2/generators/createQueryString.js +30 -0
- package/dist/api-playground-2/generators/generateAuthPlaceholder.js +14 -0
- package/dist/api-playground-2/generators/generateInteractiveCodeSample.js +27 -25
- package/dist/api-playground-2/generators/generateRequest.js +47 -51
- package/dist/api-playground-2/generators/generateResponseExampleMap.js +15 -11
- package/dist/api-playground-2/generators/generateSnippet.js +1 -1
- package/dist/api-playground-2/generators/generateSnippetMap.js +13 -11
- package/dist/api-playground-2/hooks/useCopyPathWithInputs.js +11 -11
- package/dist/api-playground-2/hooks/useInitializeInputs.js +185 -88
- package/dist/api-playground-2/hooks/usePlaygroundInputsStore.js +70 -25
- package/dist/api-playground-2/hooks/useSelectedBaseUrl.js +13 -0
- package/dist/api-playground-2/hooks/useSelectedExample.js +10 -0
- package/dist/api-playground-2/hooks/useSelectedRequestBodyContentType.js +12 -0
- package/dist/api-playground-2/hooks/useSelectedResponseContentType.js +12 -0
- package/dist/api-playground-2/hooks/useSelectedSecurityOption.js +31 -0
- package/dist/api-playground-2/hooks/useSendPlaygroundRequest.js +114 -101
- package/dist/api-playground-2/schemaGraph/addApiReferenceDataFromMdxAndDocsConfig.js +23 -32
- package/dist/api-playground-2/schemaGraph/addTypeLabelsToSchema.js +50 -0
- package/dist/api-playground-2/schemaGraph/addUniqueKeysToSchema.js +40 -24
- package/dist/api-playground-2/schemaGraph/getExampleBodyInputs.js +94 -0
- package/dist/api-playground-2/schemaGraph/getSchemaGraphOperationData.js +56 -50
- package/dist/api-playground-2/schemaGraph/processExamples.js +117 -52
- package/dist/api-playground-2/schemaGraph/processSchema.js +10 -0
- package/dist/api-playground-2/schemaGraph/processSecurityOptions.js +58 -28
- package/dist/api-playground-2/schemaGraph/reduceCompositions.js +220 -181
- package/dist/api-playground-2/schemaGraph/resolveOperationWithDependencies.js +128 -89
- package/dist/api-playground-2/schemaGraph/resolveSchemaWithDependencies.js +15 -16
- package/dist/api-playground-2/schemaGraph/sortSchemaByRequired.js +14 -12
- package/dist/api-playground-2/schemaGraph/utils.js +185 -147
- package/dist/common/guards.js +11 -19
- package/dist/components/Api/Expandable.js +10 -9
- package/dist/components/Api/Param.js +11 -13
- package/dist/components/Api/dropdown-menu.js +10 -9
- package/dist/components/content-components/code-group.js +4 -4
- package/dist/contexts/EndpointLocationContext.js +3 -3
- package/dist/hooks/useApiParamFieldOption.js +10 -0
- package/dist/hooks/useEndpoint.js +3 -3
- package/dist/hooks/useKeyboardShortcut.js +13 -13
- package/dist/hooks/useSendPlaygroundRequest.js +14 -146
- package/dist/httpsnippet/src/helpers/code-builder.js +27 -0
- package/dist/httpsnippet/src/helpers/escape.js +11 -0
- package/dist/httpsnippet/src/helpers/headers.js +13 -0
- package/dist/httpsnippet/src/helpers/reducer.js +7 -0
- package/dist/httpsnippet/src/helpers/shell.js +5 -0
- package/dist/httpsnippet/src/helpers/url-format.js +35 -0
- package/dist/httpsnippet/src/helpers/url-parse.js +76 -0
- package/dist/httpsnippet/src/index.js +157 -0
- package/dist/httpsnippet/src/targets/c/libcurl/client.js +22 -0
- package/dist/httpsnippet/src/targets/c/target.js +15 -0
- package/dist/httpsnippet/src/targets/clojure/clj_http/client.js +120 -0
- package/dist/httpsnippet/src/targets/clojure/target.js +14 -0
- package/dist/httpsnippet/src/targets/csharp/httpclient/client.js +76 -0
- package/dist/httpsnippet/src/targets/csharp/restsharp/client.js +63 -0
- package/dist/httpsnippet/src/targets/csharp/target.js +17 -0
- package/dist/httpsnippet/src/targets/go/native/client.js +24 -0
- package/dist/httpsnippet/src/targets/go/target.js +15 -0
- package/dist/httpsnippet/src/targets/http/http1.1/client.js +34 -0
- package/dist/httpsnippet/src/targets/http/target.js +14 -0
- package/dist/httpsnippet/src/targets/index.js +43 -0
- package/dist/httpsnippet/src/targets/java/asynchttp/client.js +23 -0
- package/dist/httpsnippet/src/targets/java/nethttp/client.js +28 -0
- package/dist/httpsnippet/src/targets/java/okhttp/client.js +23 -0
- package/dist/httpsnippet/src/targets/java/target.js +20 -0
- package/dist/httpsnippet/src/targets/java/unirest/client.js +23 -0
- package/dist/httpsnippet/src/targets/javascript/axios/client.js +50 -0
- package/dist/httpsnippet/src/targets/javascript/fetch/client.js +61 -0
- package/dist/httpsnippet/src/targets/javascript/jquery/client.js +51 -0
- package/dist/httpsnippet/src/targets/javascript/target.js +20 -0
- package/dist/httpsnippet/src/targets/javascript/xhr/client.js +49 -0
- package/dist/httpsnippet/src/targets/json/native/client.js +39 -0
- package/dist/httpsnippet/src/targets/json/target.js +14 -0
- package/dist/httpsnippet/src/targets/kotlin/okhttp/client.js +23 -0
- package/dist/httpsnippet/src/targets/kotlin/target.js +14 -0
- package/dist/httpsnippet/src/targets/node/axios/client.js +40 -0
- package/dist/httpsnippet/src/targets/node/fetch/client.js +68 -0
- package/dist/httpsnippet/src/targets/node/native/client.js +45 -0
- package/dist/httpsnippet/src/targets/node/target.js +19 -0
- package/dist/httpsnippet/src/targets/objc/helpers.js +27 -0
- package/dist/httpsnippet/src/targets/objc/nsurlsession/client.js +63 -0
- package/dist/httpsnippet/src/targets/objc/target.js +14 -0
- package/dist/httpsnippet/src/targets/ocaml/cohttp/client.js +32 -0
- package/dist/httpsnippet/src/targets/ocaml/target.js +14 -0
- package/dist/httpsnippet/src/targets/php/curl/client.js +85 -0
- package/dist/httpsnippet/src/targets/php/guzzle/client.js +57 -0
- package/dist/httpsnippet/src/targets/php/helpers.js +65 -0
- package/dist/httpsnippet/src/targets/php/http1/client.js +28 -0
- package/dist/httpsnippet/src/targets/php/http2/client.js +55 -0
- package/dist/httpsnippet/src/targets/php/target.js +21 -0
- package/dist/httpsnippet/src/targets/powershell/common.js +19 -0
- package/dist/httpsnippet/src/targets/powershell/restmethod/client.js +14 -0
- package/dist/httpsnippet/src/targets/powershell/target.js +16 -0
- package/dist/httpsnippet/src/targets/powershell/webrequest/client.js +14 -0
- package/dist/httpsnippet/src/targets/python/helpers.js +33 -0
- package/dist/httpsnippet/src/targets/python/requests/client.js +74 -0
- package/dist/httpsnippet/src/targets/python/target.js +15 -0
- package/dist/httpsnippet/src/targets/r/httr/client.js +46 -0
- package/dist/httpsnippet/src/targets/r/target.js +14 -0
- package/dist/httpsnippet/src/targets/ruby/native/client.js +37 -0
- package/dist/httpsnippet/src/targets/ruby/target.js +14 -0
- package/dist/httpsnippet/src/targets/shell/curl/client.js +92 -0
- package/dist/httpsnippet/src/targets/shell/httpie/client.js +56 -0
- package/dist/httpsnippet/src/targets/shell/target.js +19 -0
- package/dist/httpsnippet/src/targets/shell/wget/client.js +30 -0
- package/dist/httpsnippet/src/targets/swift/helpers.js +38 -0
- package/dist/httpsnippet/src/targets/swift/target.js +14 -0
- package/dist/httpsnippet/src/targets/swift/urlsession/client.js +59 -0
- package/dist/index.d.ts +65 -58
- package/dist/index.js +109 -111
- package/dist/openapi/generateTypeStringFromSchema.js +2 -31
- package/dist/styles.css +1 -1
- package/package.json +17 -4
- package/dist/api-playground/ApiPlayground/Request/BodySection.js +0 -64
- package/dist/api-playground/ApiPlayground/Request/ParameterSection.js +0 -32
- package/dist/api-playground/ApiPlayground/Request/PlaygroundModal.js +0 -201
- package/dist/api-playground/ApiPlayground/Request/SecuritySection.js +0 -146
- package/dist/api-playground/ApiPlayground/Request/ServerSection.js +0 -30
- package/dist/api-playground/ApiPlayground/Request/index.js +0 -43
- package/dist/api-playground/ApiPlayground/Request/inputs/ArrayInput.js +0 -93
- package/dist/api-playground/ApiPlayground/Request/inputs/DifferentiatedInput.js +0 -90
- package/dist/api-playground/ApiPlayground/Request/inputs/FileInput.js +0 -62
- package/dist/api-playground/ApiPlayground/Request/inputs/NullInput.js +0 -33
- package/dist/api-playground/ApiPlayground/Request/inputs/NumberInput.js +0 -61
- package/dist/api-playground/ApiPlayground/Request/inputs/ObjectChildren.js +0 -109
- package/dist/api-playground/ApiPlayground/Request/inputs/ObjectInput.js +0 -87
- package/dist/api-playground/ApiPlayground/Request/inputs/RecursiveInput.js +0 -61
- package/dist/api-playground/ApiPlayground/Request/inputs/SelectInput.js +0 -54
- package/dist/api-playground/ApiPlayground/Request/inputs/StringInput.js +0 -67
- package/dist/api-playground/ApiPlayground/Request/inputs/TextInput.js +0 -44
- package/dist/api-playground/ApiPlayground/components/EndpointsMenu.js +0 -42
- package/dist/api-playground/ApiPlayground/components/EndpointsMenuLink.js +0 -43
- package/dist/api-playground/ApiPlayground/components/EndpointsMenuSearch.js +0 -38
- package/dist/api-playground/ApiPlayground/components/InputContainer.js +0 -128
- package/dist/api-playground/ApiPlayground/components/InputSectionContainer.js +0 -59
- package/dist/api-playground/ApiPlayground/components/PathHeader.js +0 -162
- package/dist/api-playground/ApiPlayground/components/TrashButton.js +0 -26
- package/dist/api-playground/ApiPlayground/index.js +0 -67
- package/dist/api-playground/EndpointFields/ParamFields/PrimitiveParamField/Enum.js +0 -19
- package/dist/api-playground/EndpointFields/ParamFields/PrimitiveParamField/NumberMetadata.js +0 -18
- package/dist/api-playground/EndpointFields/ParamFields/PrimitiveParamField/StringMetadata.js +0 -28
- package/dist/api-playground/EndpointFields/ParamFields/PrimitiveParamField/index.js +0 -5
- package/dist/api-playground/EndpointFields/ParamFields/RecursiveParamField.js +0 -13
- package/dist/api-playground/EndpointFields/index.js +0 -7
- package/dist/api-playground-2/components/EndpointFields/EndpointSecurity.js +0 -87
- package/dist/api-playground-2/components/EndpointFields/fields/SimpleArrayParamField.js +0 -89
- package/dist/api-playground-2/components/EndpointFields/fields/SimpleObjectParamField.js +0 -121
- package/dist/api-playground-2/components/EndpointFields/fields/SimplePrimitiveParamField.js +0 -74
- package/dist/api-playground-2/components/EndpointFields/fields/SimpleSchemaField.js +0 -252
- package/dist/common/potentiallyParseOpenApiString.js +0 -24
- package/dist/common/replaceSlashIndex.js +0 -6
- package/dist/common/slugToTitle.js +0 -10
- package/dist/constants/prism-languages.js +0 -19
- package/dist/contexts/ApiPlaygroundInputsContext.js +0 -17
- package/dist/contexts/MDXContentContext.js +0 -17
- package/dist/hooks/useApiPlaygroundInputs.js +0 -6
- package/dist/hooks/useApiPlaygroundPrefillExamples.js +0 -39
- package/dist/hooks/useBaseUrlOptions.js +0 -18
- package/dist/hooks/useComponentSchemas.js +0 -9
- package/dist/hooks/useGenerateNextAdditionalProperties.js +0 -11
- package/dist/hooks/useGenerateNextItems.js +0 -11
- package/dist/hooks/useGenerateNextProperties.js +0 -11
- package/dist/hooks/useMDXContent.js +0 -6
- package/dist/hooks/useMDXContentController/useApiPlaygroundInputs.js +0 -9
- package/dist/hooks/useMDXContentController/useMDXContentCallbacks/useSetApiBaseIndexCallback.js +0 -15
- package/dist/hooks/useMDXContentController/useMDXContentCallbacks/useSetApiPlaygroundInputsCallback.js +0 -15
- package/dist/hooks/usePlaygroundSchemaOptions.js +0 -42
- package/dist/hooks/usePrefilledInputs/index.js +0 -65
- package/dist/hooks/usePrefilledInputs/storedServerVariables.js +0 -29
- package/dist/hooks/useSecurityOption.js +0 -10
- package/dist/hooks/useSetDefaultValue.js +0 -63
- package/dist/openapi/filterEnums.js +0 -20
- package/dist/openapi/generateNextAdditionalProperties.js +0 -7
- package/dist/openapi/generateNextItems.js +0 -7
- package/dist/openapi/generateNextProperties.js +0 -23
- package/dist/openapi/generateOptionLabels.js +0 -20
- package/dist/openapi/generateSimpleLabels.js +0 -4
- package/dist/openapi/getAuthFilteredSchemaArray.js +0 -18
- package/dist/paths/isEqualIgnoringLeadingSlash.js +0 -21
- package/dist/paths/optionallyRemoveLeadingSlash.js +0 -6
- package/dist/paths/optionallyRemoveTrailingSlash.js +0 -6
- package/dist/utils/api-playground/defaults.js +0 -15
- package/dist/utils/api-playground/paramFieldDefaults.js +0 -10
- package/dist/utils/api-reference/getFilteredSecurityOptions.js +0 -4
- package/dist/utils/api-reference/getNextPropertiesByType.js +0 -5
- package/dist/utils/flattenObject.js +0 -10
|
@@ -1,100 +1,197 @@
|
|
|
1
|
-
import { useRef as
|
|
2
|
-
import { apiPlaygroundInputKeys as
|
|
3
|
-
import {
|
|
4
|
-
import { usePlaygroundInputsStore as
|
|
5
|
-
function
|
|
6
|
-
apiReferenceData:
|
|
7
|
-
selectedBaseUrlIndex:
|
|
8
|
-
selectedExampleIndex:
|
|
9
|
-
selectedRequestBodyContentTypeIndex:
|
|
1
|
+
import { useRef as b, useEffect as x } from "react";
|
|
2
|
+
import { apiPlaygroundInputKeys as m } from "../constants/index.js";
|
|
3
|
+
import { getRequestBodyContentType as K, getSchemaDefault as g, isSchemaObject as A, getBodyDefaultsFromSchema as T, getParametersPerSection as W, mapParamInToPlaygroundInputKey as v, escapeDots as y, getSecurityOptionInputKeyPrefix as B, isBasicAuth as S } from "../schemaGraph/utils.js";
|
|
4
|
+
import { usePlaygroundInputsStore as d } from "./usePlaygroundInputsStore.js";
|
|
5
|
+
function Z({
|
|
6
|
+
apiReferenceData: n,
|
|
7
|
+
selectedBaseUrlIndex: o,
|
|
8
|
+
selectedExampleIndex: c,
|
|
9
|
+
selectedRequestBodyContentTypeIndex: s,
|
|
10
|
+
locallyStoredCredentials: i,
|
|
11
|
+
serverInputs: t
|
|
10
12
|
}) {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
if (
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
13
|
+
var u;
|
|
14
|
+
const e = b(!1), r = b(!1), f = b(c);
|
|
15
|
+
x(() => {
|
|
16
|
+
if (e.current) return;
|
|
17
|
+
const h = d.getState();
|
|
18
|
+
h.reset();
|
|
19
|
+
const p = P({
|
|
20
|
+
apiReferenceData: n,
|
|
21
|
+
selectedBaseUrlIndex: o,
|
|
22
|
+
selectedSecurityOptionIndex: 0,
|
|
23
|
+
// Always start with first security option
|
|
24
|
+
selectedExampleIndex: 0,
|
|
25
|
+
// Always start with first example
|
|
26
|
+
selectedContentTypeIndex: s,
|
|
27
|
+
locallyStoredCredentials: i,
|
|
28
|
+
serverInputs: t
|
|
29
|
+
});
|
|
30
|
+
h.initializeInputs(p), h.initializeApiReferenceData(n), e.current = !0, r.current = !!i, f.current = 0;
|
|
31
|
+
}, []), x(() => {
|
|
32
|
+
if (!e.current || r.current || !i)
|
|
24
33
|
return;
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
34
|
+
const h = d.getState(), p = P({
|
|
35
|
+
apiReferenceData: n,
|
|
36
|
+
selectedBaseUrlIndex: o,
|
|
37
|
+
selectedSecurityOptionIndex: h.selectedSecurityOptionIndex,
|
|
38
|
+
selectedExampleIndex: h.selectedExampleIndex,
|
|
39
|
+
selectedContentTypeIndex: s,
|
|
40
|
+
locallyStoredCredentials: i,
|
|
41
|
+
serverInputs: t
|
|
42
|
+
});
|
|
43
|
+
h.replaceInputs(p), r.current = !0;
|
|
44
|
+
}, [i]), x(() => {
|
|
45
|
+
var E;
|
|
46
|
+
if (!e.current || f.current === c || !((E = n.operation) == null ? void 0 : E.prefillPlaygroundWithExample))
|
|
28
47
|
return;
|
|
48
|
+
const p = d.getState();
|
|
49
|
+
p.clear();
|
|
50
|
+
const a = P({
|
|
51
|
+
apiReferenceData: n,
|
|
52
|
+
selectedBaseUrlIndex: o,
|
|
53
|
+
selectedSecurityOptionIndex: p.selectedSecurityOptionIndex,
|
|
54
|
+
selectedExampleIndex: c,
|
|
55
|
+
selectedContentTypeIndex: s,
|
|
56
|
+
locallyStoredCredentials: i,
|
|
57
|
+
serverInputs: t
|
|
58
|
+
});
|
|
59
|
+
p.initializeInputs(a), f.current = c;
|
|
60
|
+
}, [c, (u = n.operation) == null ? void 0 : u.prefillPlaygroundWithExample]);
|
|
61
|
+
}
|
|
62
|
+
function P({
|
|
63
|
+
apiReferenceData: n,
|
|
64
|
+
selectedBaseUrlIndex: o,
|
|
65
|
+
selectedSecurityOptionIndex: c,
|
|
66
|
+
selectedExampleIndex: s,
|
|
67
|
+
selectedContentTypeIndex: i,
|
|
68
|
+
locallyStoredCredentials: t,
|
|
69
|
+
serverInputs: e
|
|
70
|
+
}) {
|
|
71
|
+
var u;
|
|
72
|
+
const r = (u = n.operation) == null ? void 0 : u.userInfoPlaygroundInputs, f = {
|
|
73
|
+
server: { ...r == null ? void 0 : r.server, ...e },
|
|
74
|
+
header: { ...r == null ? void 0 : r.header, ...t == null ? void 0 : t.header },
|
|
75
|
+
query: { ...r == null ? void 0 : r.query, ...t == null ? void 0 : t.query },
|
|
76
|
+
cookie: { ...r == null ? void 0 : r.cookie, ...t == null ? void 0 : t.cookie }
|
|
77
|
+
};
|
|
78
|
+
return F({
|
|
79
|
+
apiReferenceData: n,
|
|
80
|
+
selectedBaseUrlIndex: o,
|
|
81
|
+
selectedSecurityOptionIndex: c,
|
|
82
|
+
selectedExampleIndex: s,
|
|
83
|
+
selectedContentTypeIndex: i,
|
|
84
|
+
mergedUserInfo: f
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
const F = ({
|
|
88
|
+
apiReferenceData: n,
|
|
89
|
+
selectedBaseUrlIndex: o,
|
|
90
|
+
selectedSecurityOptionIndex: c,
|
|
91
|
+
selectedExampleIndex: s = 0,
|
|
92
|
+
selectedContentTypeIndex: i = 0,
|
|
93
|
+
mergedUserInfo: t
|
|
94
|
+
}) => {
|
|
95
|
+
var O, $, j, l, w, k, q;
|
|
96
|
+
let e = {};
|
|
97
|
+
const r = (O = n.operation) == null ? void 0 : O.prefillPlaygroundWithExample, u = ((($ = n.operation) == null ? void 0 : $.prefillPlaygroundExamples) ?? [])[s], p = (l = Object.values(((j = n.dependencies) == null ? void 0 : j.servers) ?? {})[o]) == null ? void 0 : l.variables, a = (w = n.dependencies) == null ? void 0 : w.processedSecurityOptions, E = a == null ? void 0 : a[c], V = (k = n.dependencies) == null ? void 0 : k.parameters, z = (q = n.dependencies) == null ? void 0 : q.requestBody;
|
|
98
|
+
return r && u ? e = u : e = {
|
|
99
|
+
...N(p),
|
|
100
|
+
...G(E),
|
|
101
|
+
...H({ apiReferenceData: n, parameters: V }),
|
|
102
|
+
...J({ requestBody: z, apiReferenceData: n, selectedContentTypeIndex: i })
|
|
103
|
+
}, t && (e = {
|
|
104
|
+
...e,
|
|
105
|
+
...L({
|
|
106
|
+
mergedUserInfo: t,
|
|
107
|
+
securityOption: E,
|
|
108
|
+
serverVariables: p
|
|
109
|
+
})
|
|
110
|
+
}), e;
|
|
111
|
+
};
|
|
112
|
+
function N(n) {
|
|
113
|
+
const o = {};
|
|
114
|
+
return n && Object.entries(n).forEach(([c, s]) => {
|
|
115
|
+
const i = `${m.server}.${y(c)}`;
|
|
116
|
+
if (typeof s == "object" && s !== null) {
|
|
117
|
+
const t = g(s);
|
|
118
|
+
t && (o[i] = t);
|
|
29
119
|
}
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
t(
|
|
120
|
+
}), o;
|
|
121
|
+
}
|
|
122
|
+
function G(n) {
|
|
123
|
+
const o = {};
|
|
124
|
+
return n && n.schemes.forEach(
|
|
125
|
+
({
|
|
126
|
+
scheme: c,
|
|
127
|
+
schema: s,
|
|
128
|
+
name: i
|
|
129
|
+
}) => {
|
|
130
|
+
const t = B({ scheme: c, name: i }), e = g(s);
|
|
131
|
+
e && typeof e == "string" && (o[t] = e), e && typeof e == "object" && (o[t + ".username"] = "username" in e && typeof e.username == "string" ? e.username : "", o[t + ".password"] = "password" in e && typeof e.password == "string" ? e.password : "");
|
|
41
132
|
}
|
|
42
|
-
|
|
43
|
-
e,
|
|
44
|
-
d,
|
|
45
|
-
a,
|
|
46
|
-
p,
|
|
47
|
-
y,
|
|
48
|
-
t,
|
|
49
|
-
f,
|
|
50
|
-
b
|
|
51
|
-
]);
|
|
133
|
+
), o;
|
|
52
134
|
}
|
|
53
|
-
|
|
54
|
-
apiReferenceData:
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
const f = (E = e.operation) == null ? void 0 : E.prefillPlaygroundWithExample, h = (((V = e.operation) == null ? void 0 : V.prefillPlaygroundExamples) ?? [])[r], S = ($ = Object.values(((I = e.dependencies) == null ? void 0 : I.servers) ?? {})[a]) == null ? void 0 : $.variables, c = (j = e.dependencies) == null ? void 0 : j.processedSecurityOptions, u = c == null ? void 0 : c[p], F = (x = e.dependencies) == null ? void 0 : x.parameters, v = (K = e.dependencies) == null ? void 0 : K.requestBody;
|
|
65
|
-
if (!(f && h)) {
|
|
66
|
-
if (S && Object.entries(S).forEach(([n, s]) => {
|
|
67
|
-
const o = `${q.server}.${O(n)}`, i = P(s);
|
|
68
|
-
i && (t[o] = i);
|
|
69
|
-
}), u) {
|
|
70
|
-
const { scheme: n, schema: s } = u, o = "in" in n ? n.in : "header", i = "name" in n ? n.name : s.title ?? "", l = `${w(o)}.${O(i)}`, g = P(s);
|
|
71
|
-
g && (t[l] = g);
|
|
135
|
+
function H({
|
|
136
|
+
apiReferenceData: n,
|
|
137
|
+
parameters: o
|
|
138
|
+
}) {
|
|
139
|
+
const c = {};
|
|
140
|
+
if (!o) return c;
|
|
141
|
+
const { header: s, path: i, query: t, cookie: e } = W(n);
|
|
142
|
+
return [...s, ...i, ...t, ...e].forEach((r) => {
|
|
143
|
+
if (r.schema) {
|
|
144
|
+
const f = `${v(r.in)}.${y(r.name)}`, u = g(r.schema);
|
|
145
|
+
u && (c[f] = u);
|
|
72
146
|
}
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
147
|
+
}), c;
|
|
148
|
+
}
|
|
149
|
+
function J({
|
|
150
|
+
requestBody: n,
|
|
151
|
+
apiReferenceData: o,
|
|
152
|
+
selectedContentTypeIndex: c
|
|
153
|
+
}) {
|
|
154
|
+
var t;
|
|
155
|
+
const s = {};
|
|
156
|
+
if (!n) return s;
|
|
157
|
+
const i = K(o, c);
|
|
158
|
+
if (i) {
|
|
159
|
+
const e = (t = n.content[i]) == null ? void 0 : t.schema, r = g(e);
|
|
160
|
+
if (r)
|
|
161
|
+
s[`${m.body}`] = r;
|
|
162
|
+
else if (A(e)) {
|
|
163
|
+
const f = T(e);
|
|
164
|
+
return { ...s, ...f };
|
|
81
165
|
}
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
166
|
+
}
|
|
167
|
+
return s;
|
|
168
|
+
}
|
|
169
|
+
function L({
|
|
170
|
+
mergedUserInfo: n,
|
|
171
|
+
securityOption: o,
|
|
172
|
+
serverVariables: c
|
|
173
|
+
}) {
|
|
174
|
+
const s = {};
|
|
175
|
+
if (o) {
|
|
176
|
+
const i = {};
|
|
177
|
+
o.schemes.forEach(
|
|
178
|
+
({ scheme: t, name: e }) => {
|
|
179
|
+
i[e] = t;
|
|
92
180
|
}
|
|
93
|
-
}
|
|
181
|
+
), Object.entries(n.header ?? {}).forEach(([t, e]) => {
|
|
182
|
+
const r = i[t];
|
|
183
|
+
r && (S(r) ? (typeof e == "object" && e !== null && "username" in e && typeof e.username == "string" && (s[`${m.header}.Authorization.username`] = e.username), typeof e == "object" && e !== null && "password" in e && typeof e.password == "string" && (s[`${m.header}.Authorization.password`] = e.password)) : typeof e == "string" && (s[`${m.header}.${y(t)}`] = e));
|
|
184
|
+
}), Object.entries(n.query ?? {}).forEach(([t, e]) => {
|
|
185
|
+
i[t] && (s[`${m.query}.${y(t)}`] = e);
|
|
186
|
+
}), Object.entries(n.cookie ?? {}).forEach(([t, e]) => {
|
|
187
|
+
i[t] && (s[`${m.cookie}.${y(t)}`] = e);
|
|
188
|
+
});
|
|
94
189
|
}
|
|
95
|
-
return t
|
|
96
|
-
};
|
|
190
|
+
return c && Object.keys(c).length > 0 && n.server && Object.entries(n.server).forEach(([i, t]) => {
|
|
191
|
+
c[i] && (s[`${m.server}.${y(i)}`] = t);
|
|
192
|
+
}), s;
|
|
193
|
+
}
|
|
97
194
|
export {
|
|
98
|
-
|
|
99
|
-
|
|
195
|
+
F as getInitialPlaygroundValues,
|
|
196
|
+
Z as useInitializeInputs
|
|
100
197
|
};
|
|
@@ -1,32 +1,77 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
1
|
+
import { useState as l, useEffect as I, useMemo as a } from "react";
|
|
2
|
+
import { create as x } from "zustand";
|
|
3
|
+
import { useShallow as f } from "zustand/react/shallow";
|
|
4
|
+
import { unflattenInputs as i } from "../schemaGraph/utils.js";
|
|
5
|
+
const c = x((t, p) => ({
|
|
4
6
|
inputs: {},
|
|
5
|
-
|
|
6
|
-
|
|
7
|
+
apiReferenceData: void 0,
|
|
8
|
+
initializeInputs: (e) => t({
|
|
9
|
+
inputs: { ...e }
|
|
7
10
|
}),
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
})
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
initializeApiReferenceData: (e) => t({
|
|
12
|
+
apiReferenceData: e
|
|
13
|
+
}),
|
|
14
|
+
setInput: (e, n) => t((s) => {
|
|
15
|
+
const o = { ...s.inputs, [e]: n }, u = e.match(/^(.+)\.oneOf\.(\d+)$/);
|
|
16
|
+
if (u) {
|
|
17
|
+
const [, r] = u;
|
|
18
|
+
Object.keys(o).forEach((d) => {
|
|
19
|
+
d !== e && d.startsWith(`${r}.oneOf.`) && delete o[d];
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
return { inputs: o };
|
|
23
|
+
}),
|
|
24
|
+
setInputs: (e) => t((n) => ({
|
|
25
|
+
inputs: { ...n.inputs, ...e }
|
|
13
26
|
})),
|
|
14
|
-
replaceInputs: (
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
27
|
+
replaceInputs: (e) => t({ inputs: e }),
|
|
28
|
+
deleteInput: (e) => t((n) => {
|
|
29
|
+
const s = { ...n.inputs };
|
|
30
|
+
delete s[e];
|
|
31
|
+
const o = e + ".";
|
|
32
|
+
return Object.keys(s).forEach((u) => {
|
|
33
|
+
u.startsWith(o) && delete s[u];
|
|
34
|
+
}), { inputs: s };
|
|
35
|
+
}),
|
|
36
|
+
getInput: (e) => p().inputs[e],
|
|
37
|
+
getApiPlaygroundInputs: () => i(p().inputs),
|
|
38
|
+
clear: () => t({ inputs: {} }),
|
|
39
|
+
reset: () => t({
|
|
40
|
+
inputs: {},
|
|
41
|
+
selectedSecurityOptionIndex: 0,
|
|
42
|
+
selectedExampleIndex: 0,
|
|
43
|
+
selectedRequestBodyContentTypeIndex: 0,
|
|
44
|
+
selectedResponseContentTypeIndex: 0
|
|
45
|
+
}),
|
|
46
|
+
selectedBaseUrlIndex: 0,
|
|
47
|
+
setSelectedBaseUrlIndex: (e) => t({ selectedBaseUrlIndex: e }),
|
|
19
48
|
selectedSecurityOptionIndex: 0,
|
|
20
|
-
setSelectedSecurityOptionIndex: (
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
49
|
+
setSelectedSecurityOptionIndex: (e) => t({ selectedSecurityOptionIndex: e }),
|
|
50
|
+
// Note: selectedExampleIndex is for prefill example selection (Example 1, Example 2, etc.)
|
|
51
|
+
// NOT for code snippet selection (Python, Node.js, cURL, etc.)
|
|
52
|
+
// Code snippet selection is managed by CodeGroupSelect component's local state
|
|
53
|
+
selectedExampleIndex: 0,
|
|
54
|
+
setSelectedExampleIndex: (e) => t({ selectedExampleIndex: e }),
|
|
55
|
+
selectedRequestBodyContentTypeIndex: 0,
|
|
56
|
+
setSelectedRequestBodyContentTypeIndex: (e) => t({ selectedRequestBodyContentTypeIndex: e }),
|
|
57
|
+
selectedResponseContentTypeIndex: 0,
|
|
58
|
+
setSelectedResponseContentTypeIndex: (e) => t({ selectedResponseContentTypeIndex: e })
|
|
59
|
+
})), T = (t) => {
|
|
60
|
+
const p = c((n) => n.inputs[t]), e = c((n) => n.setInput);
|
|
61
|
+
return { value: p, setInput: e };
|
|
62
|
+
}, O = (t = 300) => {
|
|
63
|
+
const p = c(f((s) => s.inputs)), [e, n] = l(p);
|
|
64
|
+
return I(() => {
|
|
65
|
+
const s = setTimeout(() => {
|
|
66
|
+
n(p);
|
|
67
|
+
}, t);
|
|
68
|
+
return () => {
|
|
69
|
+
clearTimeout(s);
|
|
70
|
+
};
|
|
71
|
+
}, [p, t]), a(() => i(e), [e]);
|
|
28
72
|
};
|
|
29
73
|
export {
|
|
30
|
-
|
|
31
|
-
|
|
74
|
+
O as useDebouncedApiPlaygroundInputs,
|
|
75
|
+
T as usePlaygroundInput,
|
|
76
|
+
c as usePlaygroundInputsStore
|
|
32
77
|
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { useContext as c } from "react";
|
|
2
|
+
import { ApiReferenceContext2 as d } from "../../contexts/ConfigContext.js";
|
|
3
|
+
import { usePlaygroundInputsStore as n } from "./usePlaygroundInputsStore.js";
|
|
4
|
+
const x = () => {
|
|
5
|
+
var s, o;
|
|
6
|
+
const t = n((e) => e.selectedBaseUrlIndex), a = n(
|
|
7
|
+
(e) => e.setSelectedBaseUrlIndex
|
|
8
|
+
), { apiReferenceData2: r } = c(d), l = ((s = r.operation) == null ? void 0 : s.baseUrl) ?? ((o = r.operation) == null ? void 0 : o.baseUrlOptions[t]) ?? "";
|
|
9
|
+
return { selectedBaseUrlIndex: t, setSelectedBaseUrlIndex: a, baseUrl: l };
|
|
10
|
+
};
|
|
11
|
+
export {
|
|
12
|
+
x as useSelectedBaseUrl
|
|
13
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { usePlaygroundInputsStore as t } from "./usePlaygroundInputsStore.js";
|
|
2
|
+
const s = () => {
|
|
3
|
+
const l = t((e) => e.selectedExampleIndex), d = t(
|
|
4
|
+
(e) => e.setSelectedExampleIndex
|
|
5
|
+
);
|
|
6
|
+
return { selectedExampleIndex: l, setSelectedExampleIndex: d };
|
|
7
|
+
};
|
|
8
|
+
export {
|
|
9
|
+
s as useSelectedExample
|
|
10
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { usePlaygroundInputsStore as t } from "./usePlaygroundInputsStore.js";
|
|
2
|
+
const s = () => {
|
|
3
|
+
const n = t(
|
|
4
|
+
(e) => e.selectedRequestBodyContentTypeIndex
|
|
5
|
+
), o = t(
|
|
6
|
+
(e) => e.setSelectedRequestBodyContentTypeIndex
|
|
7
|
+
);
|
|
8
|
+
return { selectedRequestBodyContentTypeIndex: n, setSelectedRequestBodyContentTypeIndex: o };
|
|
9
|
+
};
|
|
10
|
+
export {
|
|
11
|
+
s as useSelectedRequestBodyContentType
|
|
12
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { usePlaygroundInputsStore as n } from "./usePlaygroundInputsStore.js";
|
|
2
|
+
const p = () => {
|
|
3
|
+
const t = n(
|
|
4
|
+
(e) => e.selectedResponseContentTypeIndex
|
|
5
|
+
), s = n(
|
|
6
|
+
(e) => e.setSelectedResponseContentTypeIndex
|
|
7
|
+
);
|
|
8
|
+
return { selectedResponseContentTypeIndex: t, setSelectedResponseContentTypeIndex: s };
|
|
9
|
+
};
|
|
10
|
+
export {
|
|
11
|
+
p as useSelectedResponseContentType
|
|
12
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { useContext as m, useRef as x, useEffect as O } from "react";
|
|
2
|
+
import { ApiReferenceContext2 as g } from "../../contexts/ConfigContext.js";
|
|
3
|
+
import { getSecurityOptionInputKeyPrefix as y, getSchemaDefault as w } from "../schemaGraph/utils.js";
|
|
4
|
+
import { usePlaygroundInputsStore as p } from "./usePlaygroundInputsStore.js";
|
|
5
|
+
const b = () => {
|
|
6
|
+
var f;
|
|
7
|
+
const { apiReferenceData2: S } = m(g), r = p(
|
|
8
|
+
(c) => c.selectedSecurityOptionIndex
|
|
9
|
+
), l = p(
|
|
10
|
+
(c) => c.setSelectedSecurityOptionIndex
|
|
11
|
+
), u = x(r), t = (f = S.dependencies) == null ? void 0 : f.processedSecurityOptions;
|
|
12
|
+
return O(() => {
|
|
13
|
+
if (u.current !== r) {
|
|
14
|
+
const c = t == null ? void 0 : t[u.current], d = t == null ? void 0 : t[r];
|
|
15
|
+
if (c && d) {
|
|
16
|
+
const n = { ...p.getState().inputs };
|
|
17
|
+
c.schemes.forEach(({ scheme: s, name: a }) => {
|
|
18
|
+
const o = y({ scheme: s, name: a });
|
|
19
|
+
s.type === "http" && s.scheme === "basic" ? (delete n[o + ".username"], delete n[o + ".password"]) : delete n[o];
|
|
20
|
+
}), d.schemes.forEach(({ scheme: s, schema: a, name: o }) => {
|
|
21
|
+
const i = y({ scheme: s, name: o }), I = s.type === "http" && s.scheme === "basic", e = w(a);
|
|
22
|
+
I ? e && typeof e == "object" && (n[i + ".username"] = "username" in e && typeof e.username == "string" ? e.username : "", n[i + ".password"] = "password" in e && typeof e.password == "string" ? e.password : "") : e && typeof e == "string" && (n[i] = e);
|
|
23
|
+
}), p.getState().replaceInputs(n);
|
|
24
|
+
}
|
|
25
|
+
u.current = r;
|
|
26
|
+
}
|
|
27
|
+
}, [r, t]), { selectedSecurityOptionIndex: r, setSelectedSecurityOptionIndex: l };
|
|
28
|
+
};
|
|
29
|
+
export {
|
|
30
|
+
b as useSelectedSecurityOption
|
|
31
|
+
};
|