@mintlify/msft-sdk 1.1.62 → 1.1.64
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 +7 -6
- 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 -67
- 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/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/apiPage.js +125 -0
- package/dist/components/content-components/code-group.js +4 -4
- package/dist/components/docsPage.js +54 -56
- 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/index.d.ts +80 -60
- package/dist/index.js +99 -101
- package/dist/openapi/generateTypeStringFromSchema.js +2 -31
- package/dist/plugins/sanitize/rehype-pre-to-mdx-fence.js +13 -13
- package/dist/styles.css +1 -1
- package/package.json +1 -1
- 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,106 @@
|
|
|
1
1
|
import { useCallback as j } from "react";
|
|
2
|
-
import { NEXT_PUBLIC as
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
2
|
+
import { NEXT_PUBLIC as b } from "../../env.js";
|
|
3
|
+
import { encodeBasicAuth as w } from "../schemaGraph/utils.js";
|
|
4
|
+
import { usePlaygroundInputsStore as z } from "./usePlaygroundInputsStore.js";
|
|
5
|
+
const H = ({
|
|
6
|
+
apiReferenceData: t,
|
|
7
|
+
baseUrl: e,
|
|
8
|
+
contentType: o = "application/json",
|
|
9
|
+
setResult: i,
|
|
10
|
+
setIsSending: r
|
|
10
11
|
}) => {
|
|
11
|
-
var
|
|
12
|
-
const
|
|
12
|
+
var y, h, m;
|
|
13
|
+
const n = z((p) => p.getApiPlaygroundInputs), a = (y = t.operation) == null ? void 0 : y.disableProxy, c = (h = t.operation) == null ? void 0 : h.path, d = (m = t.operation) == null ? void 0 : m.method;
|
|
13
14
|
return j(async () => {
|
|
14
|
-
|
|
15
|
-
|
|
15
|
+
const p = n();
|
|
16
|
+
if (r(!0), !c || !e || !d || !o || !e) {
|
|
17
|
+
r(!1), i({
|
|
16
18
|
error: !0,
|
|
17
19
|
errorMessage: "Missing required fields to send a playground request"
|
|
18
20
|
}), console.error(
|
|
19
21
|
`Missing some required field to send a playground request:
|
|
20
22
|
|
|
21
23
|
path=${c}
|
|
22
|
-
method=${
|
|
23
|
-
contentType=${
|
|
24
|
-
baseUrl=${
|
|
24
|
+
method=${d}
|
|
25
|
+
contentType=${o}
|
|
26
|
+
baseUrl=${e}`
|
|
25
27
|
);
|
|
26
28
|
return;
|
|
27
29
|
}
|
|
28
|
-
const
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
30
|
+
const A = await import("axios").then((s) => s.default), g = O(c, p.path), S = $(P(e, p.server), g);
|
|
31
|
+
let f = x(p.header, o);
|
|
32
|
+
f = C(f);
|
|
33
|
+
const u = {
|
|
34
|
+
method: d,
|
|
35
|
+
url: S,
|
|
36
|
+
header: f,
|
|
37
|
+
body: p.body,
|
|
38
|
+
cookie: p.cookie,
|
|
39
|
+
query: p.query
|
|
35
40
|
};
|
|
41
|
+
let l;
|
|
36
42
|
try {
|
|
37
|
-
if (
|
|
38
|
-
const
|
|
39
|
-
s({
|
|
43
|
+
if (a) {
|
|
44
|
+
const s = await E(u);
|
|
45
|
+
l = s.status, i({
|
|
40
46
|
error: !1,
|
|
41
47
|
response: {
|
|
42
|
-
status:
|
|
43
|
-
statusText:
|
|
44
|
-
headers:
|
|
45
|
-
data:
|
|
48
|
+
status: s.status,
|
|
49
|
+
statusText: s.statusText,
|
|
50
|
+
headers: s.headers,
|
|
51
|
+
data: s.data
|
|
46
52
|
}
|
|
47
53
|
});
|
|
48
|
-
} else if (
|
|
49
|
-
const
|
|
50
|
-
s(i);
|
|
54
|
+
} else if (o && o.includes("multipart/form-data")) {
|
|
55
|
+
const s = await F(u);
|
|
56
|
+
"response" in s && (l = s.response.status), i(s);
|
|
51
57
|
} else {
|
|
52
|
-
const { data:
|
|
53
|
-
`${
|
|
54
|
-
|
|
58
|
+
const { data: s } = await A.post(
|
|
59
|
+
`${b.BASE_PATH}/_mintlify/api/request`,
|
|
60
|
+
u
|
|
55
61
|
);
|
|
56
|
-
s(i);
|
|
62
|
+
"response" in s && (l = s.response.status), i(s);
|
|
57
63
|
}
|
|
58
|
-
} catch (
|
|
59
|
-
|
|
64
|
+
} catch (s) {
|
|
65
|
+
i({
|
|
60
66
|
error: !0,
|
|
61
67
|
errorMessage: "unable to complete request"
|
|
62
|
-
}), console.error(
|
|
68
|
+
}), console.error(s);
|
|
63
69
|
}
|
|
64
|
-
|
|
70
|
+
r(!1);
|
|
65
71
|
}, [
|
|
66
|
-
|
|
72
|
+
d,
|
|
67
73
|
c,
|
|
74
|
+
r,
|
|
75
|
+
n,
|
|
68
76
|
e,
|
|
69
77
|
o,
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
d,
|
|
73
|
-
s
|
|
78
|
+
a,
|
|
79
|
+
i
|
|
74
80
|
]);
|
|
75
|
-
}, O = (
|
|
76
|
-
let
|
|
77
|
-
return Object.entries(
|
|
78
|
-
|
|
79
|
-
}),
|
|
80
|
-
},
|
|
81
|
-
...
|
|
82
|
-
"content-type":
|
|
83
|
-
},
|
|
84
|
-
const
|
|
85
|
-
(
|
|
81
|
+
}, O = (t, e) => Object.entries(e).reduce((o, [i, r]) => r == null ? o : o.replace(`{${i}}`, encodeURIComponent(r.toString())), t), P = (t, e) => {
|
|
82
|
+
let o = t;
|
|
83
|
+
return Object.entries(e).forEach(([i, r]) => {
|
|
84
|
+
r && (o = o.replace(`{${i}}`, r));
|
|
85
|
+
}), o;
|
|
86
|
+
}, $ = (t, e) => t.replace(/\/$/, "") + "/" + e.replace(/^\//, ""), x = (t, e) => Object.keys(t).some((o) => o.toLowerCase() === "content-type") ? t : {
|
|
87
|
+
...t,
|
|
88
|
+
"content-type": e
|
|
89
|
+
}, E = async (t) => {
|
|
90
|
+
const e = await import("axios").then((n) => n.default), o = Object.keys(t.header).find(
|
|
91
|
+
(n) => n.toLowerCase() === "content-type"
|
|
86
92
|
);
|
|
87
|
-
let
|
|
88
|
-
if (
|
|
89
|
-
const { data:
|
|
90
|
-
|
|
93
|
+
let i = t.body, r = t.header;
|
|
94
|
+
if (o != null && o.includes("multipart/form-data")) {
|
|
95
|
+
const { data: n, headers: a } = B(t);
|
|
96
|
+
i = n, r = a;
|
|
91
97
|
}
|
|
92
|
-
return
|
|
93
|
-
url:
|
|
94
|
-
method:
|
|
95
|
-
params:
|
|
96
|
-
data:
|
|
97
|
-
headers:
|
|
98
|
+
return e({
|
|
99
|
+
url: t.url,
|
|
100
|
+
method: t.method,
|
|
101
|
+
params: t.query,
|
|
102
|
+
data: i,
|
|
103
|
+
headers: r,
|
|
98
104
|
// prevent axios from adding [] after array query params
|
|
99
105
|
paramsSerializer: {
|
|
100
106
|
indexes: null
|
|
@@ -104,52 +110,59 @@ baseUrl=${n}`
|
|
|
104
110
|
validateStatus: () => !0,
|
|
105
111
|
// prevent axios from parsing json, losing whitespace information, and using default utf-8 encoding
|
|
106
112
|
// we can't use `responseEncoding` as it's ignored client-side
|
|
107
|
-
transformResponse: (
|
|
113
|
+
transformResponse: (n) => Buffer.from(n).toString("base64")
|
|
108
114
|
});
|
|
109
|
-
},
|
|
110
|
-
const
|
|
111
|
-
|
|
115
|
+
}, F = async (t) => {
|
|
116
|
+
const e = await import("axios").then((r) => r.default), o = new FormData();
|
|
117
|
+
o.append(
|
|
112
118
|
"requestInfo",
|
|
113
119
|
JSON.stringify({
|
|
114
|
-
method:
|
|
115
|
-
url:
|
|
116
|
-
header:
|
|
117
|
-
query:
|
|
118
|
-
cookie:
|
|
120
|
+
method: t.method,
|
|
121
|
+
url: t.url,
|
|
122
|
+
header: t.header,
|
|
123
|
+
query: t.query,
|
|
124
|
+
cookie: t.cookie
|
|
119
125
|
})
|
|
120
|
-
), typeof
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
}) :
|
|
126
|
+
), typeof t.body == "object" && t.body !== null && Object.entries(t.body).forEach(([r, n]) => {
|
|
127
|
+
n instanceof File ? o.append(r, n) : Array.isArray(n) ? n.forEach((a) => {
|
|
128
|
+
a instanceof File ? o.append(r, a) : a != null && o.append(r, typeof a == "object" ? JSON.stringify(a) : a.toString());
|
|
129
|
+
}) : n != null && o.append(r, typeof n == "object" ? JSON.stringify(n) : n.toString());
|
|
124
130
|
});
|
|
125
|
-
const { data:
|
|
126
|
-
`${
|
|
127
|
-
|
|
131
|
+
const { data: i } = await e.post(
|
|
132
|
+
`${b.BASE_PATH}/_mintlify/api/file-request`,
|
|
133
|
+
o
|
|
128
134
|
);
|
|
129
|
-
return
|
|
130
|
-
},
|
|
131
|
-
var
|
|
132
|
-
let
|
|
133
|
-
const
|
|
134
|
-
if ((
|
|
135
|
-
const
|
|
136
|
-
typeof
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
typeof
|
|
135
|
+
return i;
|
|
136
|
+
}, B = (t) => {
|
|
137
|
+
var i;
|
|
138
|
+
let e = t.body;
|
|
139
|
+
const o = t.header;
|
|
140
|
+
if ((i = o["content-type"]) != null && i.includes("multipart/form-data")) {
|
|
141
|
+
const r = new FormData();
|
|
142
|
+
typeof e == "object" && e !== null && (Object.entries(e).forEach(([n, a]) => {
|
|
143
|
+
a instanceof File ? r.append(n, a) : Array.isArray(a) ? a.forEach((c) => {
|
|
144
|
+
c instanceof File ? r.append(n, c) : c != null && r.append(
|
|
145
|
+
n,
|
|
146
|
+
typeof c == "object" ? JSON.stringify(c) : c.toString()
|
|
141
147
|
);
|
|
142
|
-
}) :
|
|
143
|
-
|
|
144
|
-
typeof
|
|
148
|
+
}) : a != null && r.append(
|
|
149
|
+
n,
|
|
150
|
+
typeof a == "object" ? JSON.stringify(a) : a.toString()
|
|
145
151
|
);
|
|
146
|
-
}),
|
|
152
|
+
}), e = r, delete o["content-type"]);
|
|
153
|
+
}
|
|
154
|
+
return { data: e, headers: o };
|
|
155
|
+
}, C = (t) => {
|
|
156
|
+
if (!t.Authorization || typeof t.Authorization != "object") return t;
|
|
157
|
+
if (typeof t.Authorization == "object") {
|
|
158
|
+
const e = "username" in t.Authorization ? t.Authorization.username : "", o = "password" in t.Authorization ? t.Authorization.password : "", i = w(e, o);
|
|
159
|
+
t.Authorization = `Basic ${i}`, delete t.Authorization.username, delete t.Authorization.password;
|
|
147
160
|
}
|
|
148
|
-
return
|
|
161
|
+
return t;
|
|
149
162
|
};
|
|
150
163
|
export {
|
|
151
164
|
O as addPathParams,
|
|
152
165
|
P as addServerVariables,
|
|
153
|
-
|
|
154
|
-
|
|
166
|
+
$ as joinWithSingleSlash,
|
|
167
|
+
H as useSendPlaygroundRequest
|
|
155
168
|
};
|
|
@@ -1,56 +1,47 @@
|
|
|
1
1
|
import { toShikiLang as w } from "../../constants/snippetPresets.js";
|
|
2
|
-
import { mdxCodeExampleToExamples as
|
|
2
|
+
import { mdxCodeExampleToExamples as R, getFirstWebhookExample as B } from "./processExamples.js";
|
|
3
3
|
import { getDocsJsonSecurityOptions as F } from "./processSecurityOptions.js";
|
|
4
|
-
import {
|
|
5
|
-
const
|
|
4
|
+
import { getPrefillRequestExamples as J } from "./utils.js";
|
|
5
|
+
const W = (a) => {
|
|
6
6
|
var p;
|
|
7
|
-
const
|
|
7
|
+
const l = ((p = a.servers) == null ? void 0 : p.map((e) => e.url)) ?? [];
|
|
8
8
|
let r;
|
|
9
|
-
return
|
|
9
|
+
return l.length > 1, r = l[0], {
|
|
10
10
|
path: a.path,
|
|
11
11
|
method: a.method,
|
|
12
12
|
title: a.title ?? "",
|
|
13
13
|
description: a.description ?? "",
|
|
14
14
|
type: a.type ?? "path",
|
|
15
15
|
baseUrl: r,
|
|
16
|
-
baseUrlOptions:
|
|
16
|
+
baseUrlOptions: l,
|
|
17
17
|
deprecated: a.deprecated
|
|
18
18
|
};
|
|
19
|
-
},
|
|
19
|
+
}, I = ({
|
|
20
20
|
pageMetadata: a,
|
|
21
|
-
apiReferenceData2:
|
|
21
|
+
apiReferenceData2: l,
|
|
22
22
|
mdxExtracts: r,
|
|
23
23
|
docsConfig: p
|
|
24
24
|
}) => {
|
|
25
|
-
var y, h, b, q,
|
|
26
|
-
const e =
|
|
27
|
-
if (!
|
|
25
|
+
var u, y, h, b, q, x, E, U, O, T, S, d, P, v, f, k;
|
|
26
|
+
const e = l ?? { operation: void 0 };
|
|
27
|
+
if (!l && (r != null && r.endpoint) && (e.operation = W(r.endpoint)), a.description && e.operation && (e.operation.description = a.description), !e.operation)
|
|
28
28
|
return e;
|
|
29
|
-
const
|
|
30
|
-
if (typeof
|
|
31
|
-
const
|
|
32
|
-
method:
|
|
33
|
-
name:
|
|
29
|
+
const t = (y = (u = p == null ? void 0 : p.api) == null ? void 0 : u.mdx) == null ? void 0 : y.server, o = (b = (h = p == null ? void 0 : p.api) == null ? void 0 : h.mdx) == null ? void 0 : b.auth, i = e.operation.baseUrl || e.operation.baseUrlOptions.length > 0;
|
|
30
|
+
if (typeof t == "string" && !i ? e.operation.baseUrl = t : Array.isArray(t) && !i && (t.length > 1 ? e.operation.baseUrlOptions = t : e.operation.baseUrl = t[0]), o && Object.keys(((q = e.dependencies) == null ? void 0 : q.security) ?? {}).length === 0) {
|
|
31
|
+
const A = F({
|
|
32
|
+
method: o.method,
|
|
33
|
+
name: o.name
|
|
34
34
|
});
|
|
35
|
-
|
|
35
|
+
A && (e.dependencies || (e.dependencies = {
|
|
36
36
|
servers: {},
|
|
37
37
|
security: {}
|
|
38
|
-
}), e.dependencies.security = { ...
|
|
38
|
+
}), e.dependencies.security = { ...A });
|
|
39
39
|
}
|
|
40
|
-
const
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
e.operation.requestExamples = B(e), e.operation.requestExampleType = "webhook";
|
|
45
|
-
else if (e.operation.codeSamples && e.operation.codeSamples.length > 0) {
|
|
46
|
-
const o = (v = (T = (S = p == null ? void 0 : p.api) == null ? void 0 : S.examples) == null ? void 0 : T.languages) == null ? void 0 : v.map(w);
|
|
47
|
-
e.operation.requestExampleType = "codeSamples", e.operation.requestExampleLanguages = o, e.operation.requiredOnlyExamples = ((P = (x = p == null ? void 0 : p.api) == null ? void 0 : x.examples) == null ? void 0 : P.defaults) === "required";
|
|
48
|
-
} else
|
|
49
|
-
e.operation.requestExampleType = "generated";
|
|
50
|
-
m ? (e.operation.responseExamples = f(m), e.operation.responseExampleType = "mdx") : e.operation.responseExampleType = "generated";
|
|
51
|
-
const L = e.operation.baseUrl || e.operation.baseUrlOptions.length > 0, u = ((d = (k = p == null ? void 0 : p.api) == null ? void 0 : k.examples) == null ? void 0 : d.prefill) && L;
|
|
52
|
-
return u && (e.operation.prefillPlaygroundWithExample = !!u, e.operation.prefillPlaygroundExamples = J(e)), ((D = (A = p == null ? void 0 : p.api) == null ? void 0 : A.playground) == null ? void 0 : D.proxy) === !1 && (e.operation.disableProxy = !0), e;
|
|
40
|
+
const s = (x = r == null ? void 0 : r.codeExamples) == null ? void 0 : x.request, n = (E = r == null ? void 0 : r.codeExamples) == null ? void 0 : E.response, D = (T = (O = (U = p == null ? void 0 : p.api) == null ? void 0 : U.examples) == null ? void 0 : O.languages) == null ? void 0 : T.map(w);
|
|
41
|
+
e.operation.requestExampleLanguages = D, s ? (e.operation.requestExamples = R(s), e.operation.requestExampleType = "mdx") : e.operation.type === "webhook" ? (e.operation.requestExamples = B(e, 0), e.operation.requestExampleType = "webhook") : e.operation.codeSamples && e.operation.codeSamples.length > 0 ? (e.operation.requestExampleType = "codeSamples", e.operation.requiredOnlyExamples = ((d = (S = p == null ? void 0 : p.api) == null ? void 0 : S.examples) == null ? void 0 : d.defaults) === "required") : e.operation.requestExampleType = "generated", n ? (e.operation.responseExamples = R(n), e.operation.responseExampleType = "mdx") : e.operation.responseExampleType = "generated";
|
|
42
|
+
const L = e.operation.baseUrl || e.operation.baseUrlOptions.length > 0, m = ((v = (P = p == null ? void 0 : p.api) == null ? void 0 : P.examples) == null ? void 0 : v.prefill) && L;
|
|
43
|
+
return m && (e.operation.prefillPlaygroundWithExample = !!m, e.operation.prefillPlaygroundExamples = J(e), e.operation.prefillPlaygroundExamples.length > 0 && (e.operation.requestExampleType = "examples")), ((k = (f = p == null ? void 0 : p.api) == null ? void 0 : f.playground) == null ? void 0 : k.proxy) === !1 && (e.operation.disableProxy = !0), e;
|
|
53
44
|
};
|
|
54
45
|
export {
|
|
55
|
-
|
|
46
|
+
I as addApiReferenceDataFromMdxAndDocsConfig
|
|
56
47
|
};
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { isSchemaObject as n } from "./utils.js";
|
|
2
|
+
const p = (t) => {
|
|
3
|
+
const e = t.type;
|
|
4
|
+
if (Array.isArray(e))
|
|
5
|
+
return e[0] ?? "string";
|
|
6
|
+
if (!e) {
|
|
7
|
+
if (t.oneOf && Array.isArray(t.oneOf)) {
|
|
8
|
+
const i = t.oneOf.map(
|
|
9
|
+
(r) => n(r) && "typeLabel" in r ? r.typeLabel : void 0
|
|
10
|
+
).filter((r) => r !== void 0);
|
|
11
|
+
if (i.length > 0) {
|
|
12
|
+
const o = new Set(i).size === i.length ? " | " : " · ";
|
|
13
|
+
return i.join(o);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
return "any";
|
|
17
|
+
}
|
|
18
|
+
switch (e) {
|
|
19
|
+
case "null":
|
|
20
|
+
return "null";
|
|
21
|
+
case "object":
|
|
22
|
+
return t.title ? `${t.title} · object` : "object";
|
|
23
|
+
case "array":
|
|
24
|
+
if ("items" in t && t.items && n(t.items)) {
|
|
25
|
+
const r = "typeLabel" in t.items && typeof t.items.typeLabel == "string" ? t.items.typeLabel : p(t.items), s = r.includes(" | ") ? `(${r})` : r;
|
|
26
|
+
return r === "object" && t.title ? `${t.title} · object[]` : `${s}[]`;
|
|
27
|
+
}
|
|
28
|
+
return t.title ? `${t.title} · array` : "array";
|
|
29
|
+
default:
|
|
30
|
+
return "enum" in t && t.enum !== void 0 ? `enum<${e}>` : "format" in t && typeof t.format == "string" ? `${e}<${t.format}>` : e;
|
|
31
|
+
}
|
|
32
|
+
}, l = (t) => {
|
|
33
|
+
if (!n(t))
|
|
34
|
+
return t;
|
|
35
|
+
const e = {
|
|
36
|
+
...t
|
|
37
|
+
};
|
|
38
|
+
if (e.oneOf && Array.isArray(e.oneOf) && (e.oneOf = e.oneOf.map((i) => n(i) ? l(i) : i)), e.type === "object" && e.properties) {
|
|
39
|
+
const i = {};
|
|
40
|
+
Object.entries(e.properties).forEach(([r, o]) => {
|
|
41
|
+
n(o) ? i[r] = l(o) : i[r] = o;
|
|
42
|
+
}), e.properties = i;
|
|
43
|
+
}
|
|
44
|
+
return e.additionalProperties && typeof e.additionalProperties == "object" && n(e.additionalProperties) && (e.additionalProperties = l(
|
|
45
|
+
e.additionalProperties
|
|
46
|
+
)), e.type === "array" && "items" in e && n(e.items) && (e.items = l(e.items)), e.typeLabel = p(e), e;
|
|
47
|
+
};
|
|
48
|
+
export {
|
|
49
|
+
l as addTypeLabelsToSchema
|
|
50
|
+
};
|
|
@@ -1,40 +1,56 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import l from "@sindresorhus/slugify";
|
|
2
|
+
import { buildRecursiveParamFieldId as p, isSchemaObject as s, escapeDots as d } from "./utils.js";
|
|
3
|
+
const u = (r, t = "") => {
|
|
4
|
+
if (!s(r))
|
|
5
|
+
return r;
|
|
5
6
|
const e = {
|
|
6
|
-
...
|
|
7
|
-
uniqueKey:
|
|
7
|
+
...r,
|
|
8
|
+
uniqueKey: t
|
|
8
9
|
};
|
|
9
|
-
if (e.oneOf && Array.isArray(e.oneOf) && (e.oneOf = e.oneOf.map((
|
|
10
|
-
if (s(
|
|
11
|
-
const
|
|
12
|
-
return
|
|
10
|
+
if (e.oneOf && Array.isArray(e.oneOf) && (e.oneOf = e.oneOf.map((o, i) => {
|
|
11
|
+
if (s(o)) {
|
|
12
|
+
const n = t ? `${t}.oneOf.${i}` : `oneOf.${i}`;
|
|
13
|
+
return u(o, n);
|
|
13
14
|
}
|
|
14
|
-
return
|
|
15
|
+
return o;
|
|
15
16
|
})), e.type === "object" && e.properties) {
|
|
16
|
-
const
|
|
17
|
-
Object.entries(e.properties).forEach(([i,
|
|
18
|
-
if (s(
|
|
19
|
-
const
|
|
20
|
-
|
|
17
|
+
const o = {};
|
|
18
|
+
Object.entries(e.properties).forEach(([i, n]) => {
|
|
19
|
+
if (s(n)) {
|
|
20
|
+
const c = t ? `${t}.${d(i)}` : d(i);
|
|
21
|
+
o[i] = u(n, c);
|
|
21
22
|
} else
|
|
22
|
-
|
|
23
|
-
}), e.properties =
|
|
23
|
+
o[i] = n;
|
|
24
|
+
}), e.properties = o;
|
|
24
25
|
}
|
|
25
26
|
if (e.additionalProperties && typeof e.additionalProperties == "object" && s(e.additionalProperties)) {
|
|
26
|
-
const
|
|
27
|
-
e.additionalProperties =
|
|
27
|
+
const o = t ? `${t}.additionalProperties` : "additionalProperties";
|
|
28
|
+
e.additionalProperties = u(
|
|
28
29
|
e.additionalProperties,
|
|
29
|
-
|
|
30
|
+
o
|
|
30
31
|
);
|
|
31
32
|
}
|
|
32
33
|
if (e.type === "array" && "items" in e && s(e.items)) {
|
|
33
|
-
const
|
|
34
|
-
e.items =
|
|
34
|
+
const o = t ? `${t}.items` : "items";
|
|
35
|
+
e.items = u(e.items, o + ".[INDEX]");
|
|
35
36
|
}
|
|
36
37
|
return e;
|
|
38
|
+
}, f = (r, t, e, o) => {
|
|
39
|
+
if (t.uniqueKey) {
|
|
40
|
+
let i = t.uniqueKey;
|
|
41
|
+
return e == null || e.forEach((n) => {
|
|
42
|
+
i = i.replace("[INDEX]", n.toString());
|
|
43
|
+
}), `${r ? r + "." : ""}${i}`;
|
|
44
|
+
} else
|
|
45
|
+
return r;
|
|
46
|
+
}, m = (r, t, e, o) => {
|
|
47
|
+
if (!r.uniqueKey)
|
|
48
|
+
return p(t, e, o);
|
|
49
|
+
const i = r.uniqueKey.replace(/\[INDEX\]/g, ""), n = t ? `${t}-${i}` : i;
|
|
50
|
+
return l(n, { decamelize: !0 });
|
|
37
51
|
};
|
|
38
52
|
export {
|
|
39
|
-
|
|
53
|
+
u as addUniqueKeysToSchema,
|
|
54
|
+
m as getParamIdFromSchema,
|
|
55
|
+
f as getUniqueInputKey
|
|
40
56
|
};
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { apiPlaygroundInputKeys as g } from "../constants/index.js";
|
|
2
|
+
import { isSchemaObject as b } from "./utils.js";
|
|
3
|
+
const j = ({
|
|
4
|
+
schema: r,
|
|
5
|
+
example: t
|
|
6
|
+
}) => s(r, t, g.body);
|
|
7
|
+
function c(r, t) {
|
|
8
|
+
let e = r;
|
|
9
|
+
return t.forEach((i) => {
|
|
10
|
+
e = e.replace("[INDEX]", i.toString());
|
|
11
|
+
}), e;
|
|
12
|
+
}
|
|
13
|
+
function s(r, t, e, i = []) {
|
|
14
|
+
const u = {};
|
|
15
|
+
if (t == null)
|
|
16
|
+
return u;
|
|
17
|
+
if (r.oneOf && Array.isArray(r.oneOf)) {
|
|
18
|
+
for (const n of r.oneOf)
|
|
19
|
+
if (b(n) && l(n, t)) {
|
|
20
|
+
const o = n;
|
|
21
|
+
if (o.type !== "object" && o.type !== "array") {
|
|
22
|
+
if (o.uniqueKey) {
|
|
23
|
+
const f = c(
|
|
24
|
+
o.uniqueKey,
|
|
25
|
+
i
|
|
26
|
+
);
|
|
27
|
+
u[`${e}.${f}`] = t;
|
|
28
|
+
}
|
|
29
|
+
return u;
|
|
30
|
+
}
|
|
31
|
+
return s(o, t, e, i);
|
|
32
|
+
}
|
|
33
|
+
if (r.oneOf.length > 0 && b(r.oneOf[0])) {
|
|
34
|
+
const n = r.oneOf[0];
|
|
35
|
+
if (n.type !== "object" && n.type !== "array") {
|
|
36
|
+
if (n.uniqueKey) {
|
|
37
|
+
const o = c(n.uniqueKey, i);
|
|
38
|
+
u[`${e}.${o}`] = t;
|
|
39
|
+
}
|
|
40
|
+
return u;
|
|
41
|
+
}
|
|
42
|
+
return s(n, t, e, i);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
if (r.type === "object" && r.properties && typeof t == "object" && !Array.isArray(t))
|
|
46
|
+
for (const [n, o] of Object.entries(r.properties)) {
|
|
47
|
+
if (!b(o)) continue;
|
|
48
|
+
const f = t[n];
|
|
49
|
+
if (f === void 0) continue;
|
|
50
|
+
const y = o;
|
|
51
|
+
if (y.type === "object" || y.type === "array" || y.oneOf) {
|
|
52
|
+
const p = s(
|
|
53
|
+
y,
|
|
54
|
+
f,
|
|
55
|
+
e,
|
|
56
|
+
i
|
|
57
|
+
);
|
|
58
|
+
Object.assign(u, p);
|
|
59
|
+
} else if (y.uniqueKey) {
|
|
60
|
+
const p = c(
|
|
61
|
+
y.uniqueKey,
|
|
62
|
+
i
|
|
63
|
+
);
|
|
64
|
+
u[`${e}.${p}`] = f;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
if (r.type === "array" && Array.isArray(t) && "items" in r && b(r.items)) {
|
|
68
|
+
const n = r.items;
|
|
69
|
+
t.forEach((o, f) => {
|
|
70
|
+
const y = [...i, f], p = s(n, o, e, y);
|
|
71
|
+
Object.assign(u, p);
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
if (!r.properties && !r.oneOf && r.type !== "array" && r.type !== "object" && r.uniqueKey) {
|
|
75
|
+
const n = c(r.uniqueKey, i);
|
|
76
|
+
u[`${e}.${n}`] = t;
|
|
77
|
+
}
|
|
78
|
+
return u;
|
|
79
|
+
}
|
|
80
|
+
function l(r, t) {
|
|
81
|
+
const e = typeof t;
|
|
82
|
+
if (r.enum && Array.isArray(r.enum))
|
|
83
|
+
return r.enum.includes(t);
|
|
84
|
+
if (r.type === "string" && e === "string" && r.pattern && typeof t == "string")
|
|
85
|
+
try {
|
|
86
|
+
return new RegExp(r.pattern).test(t);
|
|
87
|
+
} catch {
|
|
88
|
+
return !1;
|
|
89
|
+
}
|
|
90
|
+
return !!(r.type === "string" && e === "string" || r.type === "number" && e === "number" || r.type === "integer" && e === "number" && Number.isInteger(t) || r.type === "boolean" && e === "boolean" || r.type === "object" && e === "object" && t !== null && !Array.isArray(t) || r.type === "array" && Array.isArray(t));
|
|
91
|
+
}
|
|
92
|
+
export {
|
|
93
|
+
j as getExampleBodyInputs
|
|
94
|
+
};
|