@stoplight/elements-core 7.3.3 → 7.3.7
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/components/Docs/Article/index.d.ts +2 -1
- package/components/Docs/HttpOperation/HttpOperation.d.ts +2 -1
- package/components/Docs/HttpOperation/Parameters.spec.d.ts +1 -0
- package/components/Docs/HttpService/HttpService.d.ts +2 -1
- package/components/Docs/Model/Model.d.ts +2 -1
- package/components/LoadMore.d.ts +7 -0
- package/components/TryIt/Mocking/mocking-utils.d.ts +1 -1
- package/components/TryIt/Parameters/parameter-utils.d.ts +7 -3
- package/index.esm.js +143 -54
- package/index.js +199 -114
- package/index.mjs +143 -54
- package/package.json +5 -5
- package/styles.min.css +1 -1
- package/utils/{exampleGeneration.d.ts → exampleGeneration/exampleGeneration.d.ts} +1 -0
- package/utils/exampleGeneration/exampleGeneration.spec.d.ts +1 -0
package/index.js
CHANGED
|
@@ -44,14 +44,12 @@ function _interopNamespace(e) {
|
|
|
44
44
|
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
45
45
|
Object.defineProperty(n, k, d.get ? d : {
|
|
46
46
|
enumerable: true,
|
|
47
|
-
get: function () {
|
|
48
|
-
return e[k];
|
|
49
|
-
}
|
|
47
|
+
get: function () { return e[k]; }
|
|
50
48
|
});
|
|
51
49
|
}
|
|
52
50
|
});
|
|
53
51
|
}
|
|
54
|
-
n[
|
|
52
|
+
n["default"] = e;
|
|
55
53
|
return Object.freeze(n);
|
|
56
54
|
}
|
|
57
55
|
|
|
@@ -507,7 +505,7 @@ const getServerUrlWithDefaultValues = (server) => {
|
|
|
507
505
|
variables.forEach(([variableName, variableInfo]) => {
|
|
508
506
|
urlString = urlString.replace(`{${variableName}}`, variableInfo.default);
|
|
509
507
|
});
|
|
510
|
-
let url = URI__default[
|
|
508
|
+
let url = URI__default["default"](urlString);
|
|
511
509
|
if (url.is('relative') && typeof window !== 'undefined') {
|
|
512
510
|
url = url.absoluteTo(window.location.origin);
|
|
513
511
|
}
|
|
@@ -538,7 +536,7 @@ const persistAtom = (key, atomInstance) => {
|
|
|
538
536
|
|
|
539
537
|
const convertRequestToSample = (language, library, request) => {
|
|
540
538
|
try {
|
|
541
|
-
const snippet = new HTTPSnippet__default[
|
|
539
|
+
const snippet = new HTTPSnippet__default["default"](request);
|
|
542
540
|
return snippet.convert(language, library) || null;
|
|
543
541
|
}
|
|
544
542
|
catch (err) {
|
|
@@ -722,7 +720,7 @@ const getConfigFor = (language, library) => {
|
|
|
722
720
|
const selectedLanguageAtom = persistAtom('RequestSamples_selectedLanguage', jotai.atom('Shell'));
|
|
723
721
|
const selectedLibraryAtom = persistAtom('RequestSamples_selectedLibrary', jotai.atom('cURL'));
|
|
724
722
|
const fallbackText = 'Unable to generate code example';
|
|
725
|
-
const RequestSamples = React__default[
|
|
723
|
+
const RequestSamples = React__default["default"].memo(({ request, embeddedInMd = false }) => {
|
|
726
724
|
const [selectedLanguage, setSelectedLanguage] = jotai.useAtom(selectedLanguageAtom);
|
|
727
725
|
const [selectedLibrary, setSelectedLibrary] = jotai.useAtom(selectedLibraryAtom);
|
|
728
726
|
const { httpSnippetLanguage, httpSnippetLibrary, mosaicCodeViewerLanguage } = getConfigFor(selectedLanguage, selectedLibrary);
|
|
@@ -755,16 +753,16 @@ const RequestSamples = React__default['default'].memo(({ request, embeddedInMd =
|
|
|
755
753
|
});
|
|
756
754
|
return items;
|
|
757
755
|
}, [selectedLanguage, selectedLibrary, setSelectedLanguage, setSelectedLibrary]);
|
|
758
|
-
return (React__default[
|
|
759
|
-
React__default[
|
|
760
|
-
React__default[
|
|
761
|
-
React__default[
|
|
756
|
+
return (React__default["default"].createElement(mosaic.Panel, { rounded: embeddedInMd ? undefined : true, isCollapsible: embeddedInMd },
|
|
757
|
+
React__default["default"].createElement(mosaic.Panel.Titlebar, { rightComponent: React__default["default"].createElement(mosaic.CopyButton, { size: "sm", copyValue: requestSample || '' }) },
|
|
758
|
+
React__default["default"].createElement(mosaic.Box, { ml: -2 },
|
|
759
|
+
React__default["default"].createElement(mosaic.Menu, { "aria-label": "Request Sample Language", closeOnPress: true, items: menuItems, renderTrigger: ({ isOpen }) => (React__default["default"].createElement(mosaic.Button, { size: "sm", iconRight: "chevron-down", appearance: "minimal", active: isOpen },
|
|
762
760
|
"Request Sample: ",
|
|
763
761
|
selectedLanguage,
|
|
764
762
|
" ",
|
|
765
763
|
selectedLibrary ? ` / ${selectedLibrary}` : '')) }))),
|
|
766
|
-
React__default[
|
|
767
|
-
React__default[
|
|
764
|
+
React__default["default"].createElement(mosaic.Panel.Content, { p: 0 },
|
|
765
|
+
React__default["default"].createElement(mosaicCodeViewer.CodeViewer, { "aria-label": requestSample !== null && requestSample !== void 0 ? requestSample : fallbackText, noCopyButton: true, maxHeight: "400px", language: mosaicCodeViewerLanguage, value: requestSample || fallbackText }))));
|
|
768
766
|
});
|
|
769
767
|
|
|
770
768
|
const useUniqueId = (prefix = 'id_') => React__namespace.useRef(`${prefix}${nanoid.nanoid(8)}`).current;
|
|
@@ -924,7 +922,7 @@ const getSecuritySchemeNames = (securitySchemes) => securitySchemes.flatMap(sche
|
|
|
924
922
|
});
|
|
925
923
|
const securitySchemeValuesAtom = persistAtom('TryIt_securitySchemeValues', jotai.atom({}));
|
|
926
924
|
const usePersistedSecuritySchemeWithValues = () => {
|
|
927
|
-
const [currentScheme, setCurrentScheme] = React__default[
|
|
925
|
+
const [currentScheme, setCurrentScheme] = React__default["default"].useState();
|
|
928
926
|
const [securitySchemeValues, setSecuritySchemeValues] = jotai.useAtom(securitySchemeValuesAtom);
|
|
929
927
|
const setPersistedAuthenticationSettings = (securitySchemeWithValues) => {
|
|
930
928
|
setCurrentScheme(securitySchemeWithValues);
|
|
@@ -937,7 +935,7 @@ const usePersistedSecuritySchemeWithValues = () => {
|
|
|
937
935
|
}
|
|
938
936
|
};
|
|
939
937
|
const persistedSecuritySchemeValue = currentScheme && securitySchemeValues[currentScheme.scheme.key];
|
|
940
|
-
const schemeWithPersistedValue = React__default[
|
|
938
|
+
const schemeWithPersistedValue = React__default["default"].useMemo(() => {
|
|
941
939
|
if (!currentScheme)
|
|
942
940
|
return undefined;
|
|
943
941
|
if (currentScheme.authValue)
|
|
@@ -979,12 +977,16 @@ const booleanOptions = [
|
|
|
979
977
|
{ label: 'False', value: 'false' },
|
|
980
978
|
{ label: 'True', value: 'true' },
|
|
981
979
|
];
|
|
980
|
+
function enumOptions(enumValues, required) {
|
|
981
|
+
const options = lodash.map(enumValues, v => ({ value: Number.isNaN(Number(v)) ? String(v) : Number(v) }));
|
|
982
|
+
return required ? options : [{ label: 'Not Set', value: '' }, ...options];
|
|
983
|
+
}
|
|
982
984
|
function parameterOptions(parameter) {
|
|
983
985
|
var _a, _b;
|
|
984
986
|
return ((_a = parameter.schema) === null || _a === void 0 ? void 0 : _a.type) === 'boolean'
|
|
985
987
|
? booleanOptions
|
|
986
988
|
: ((_b = parameter.schema) === null || _b === void 0 ? void 0 : _b.enum) !== undefined
|
|
987
|
-
?
|
|
989
|
+
? enumOptions(parameter.schema.enum, parameter.required)
|
|
988
990
|
: null;
|
|
989
991
|
}
|
|
990
992
|
const selectExampleOption = { value: '', label: 'Pick an example' };
|
|
@@ -1032,20 +1034,14 @@ const getValueForParameter = (parameter) => {
|
|
|
1032
1034
|
return '';
|
|
1033
1035
|
};
|
|
1034
1036
|
const getInitialValueForParameter = (parameter) => {
|
|
1035
|
-
var _a;
|
|
1036
1037
|
const isRequired = !!parameter.required;
|
|
1037
|
-
|
|
1038
|
-
if (!isEnum && !isRequired)
|
|
1038
|
+
if (!isRequired)
|
|
1039
1039
|
return '';
|
|
1040
1040
|
return getValueForParameter(parameter);
|
|
1041
1041
|
};
|
|
1042
1042
|
const initialParameterValues = fp.pipe(fp.keyBy((param) => param.name), fp.mapValues(getInitialValueForParameter));
|
|
1043
|
-
function mapSchemaPropertiesToParameters(properties) {
|
|
1044
|
-
return Object.entries(properties).map(([name, schema]) => ({
|
|
1045
|
-
name,
|
|
1046
|
-
schema: typeof schema !== 'boolean' ? schema : undefined,
|
|
1047
|
-
examples: typeof schema !== 'boolean' && schema.examples ? [{ key: 'example', value: schema.examples }] : undefined,
|
|
1048
|
-
}));
|
|
1043
|
+
function mapSchemaPropertiesToParameters(properties, required) {
|
|
1044
|
+
return Object.entries(properties).map(([name, schema]) => (Object.assign({ name, schema: typeof schema !== 'boolean' ? schema : undefined, examples: typeof schema !== 'boolean' && schema.examples ? [{ key: 'example', value: schema.examples }] : undefined }, ((required === null || required === void 0 ? void 0 : required.includes(name)) && { required: true }))));
|
|
1049
1045
|
}
|
|
1050
1046
|
|
|
1051
1047
|
const ParameterEditor = ({ parameter, value, onChange, validate }) => {
|
|
@@ -1067,6 +1063,7 @@ const ParameterEditor = ({ parameter, value, onChange, validate }) => {
|
|
|
1067
1063
|
const FormDataBody = ({ specification, values, onChangeValues }) => {
|
|
1068
1064
|
const schema = specification.schema;
|
|
1069
1065
|
const parameters = schema === null || schema === void 0 ? void 0 : schema.properties;
|
|
1066
|
+
const required = schema === null || schema === void 0 ? void 0 : schema.required;
|
|
1070
1067
|
React__namespace.useEffect(() => {
|
|
1071
1068
|
if (parameters === undefined) {
|
|
1072
1069
|
console.warn(`Invalid schema in form data spec: ${json.safeStringify(schema)}`);
|
|
@@ -1077,7 +1074,7 @@ const FormDataBody = ({ specification, values, onChangeValues }) => {
|
|
|
1077
1074
|
}
|
|
1078
1075
|
return (React__namespace.createElement(mosaic.Panel, { defaultIsOpen: true },
|
|
1079
1076
|
React__namespace.createElement(mosaic.Panel.Titlebar, null, "Body"),
|
|
1080
|
-
React__namespace.createElement(mosaic.Panel.Content, { className: "sl-overflow-y-auto ParameterGrid OperationParametersContent" }, mapSchemaPropertiesToParameters(parameters).map(parameter => {
|
|
1077
|
+
React__namespace.createElement(mosaic.Panel.Content, { className: "sl-overflow-y-auto ParameterGrid OperationParametersContent" }, mapSchemaPropertiesToParameters(parameters, required).map(parameter => {
|
|
1081
1078
|
const supportsFileUpload = parameterSupportsFileUpload(parameter);
|
|
1082
1079
|
const value = values[parameter.name];
|
|
1083
1080
|
if (supportsFileUpload) {
|
|
@@ -1149,12 +1146,13 @@ const requestBodyCreators = {
|
|
|
1149
1146
|
const useBodyParameterState = (mediaTypeContent) => {
|
|
1150
1147
|
const isFormDataBody = mediaTypeContent && isFormDataContent(mediaTypeContent);
|
|
1151
1148
|
const initialState = React__namespace.useMemo(() => {
|
|
1152
|
-
var _a, _b;
|
|
1149
|
+
var _a, _b, _c;
|
|
1153
1150
|
if (!isFormDataBody) {
|
|
1154
1151
|
return {};
|
|
1155
1152
|
}
|
|
1156
1153
|
const properties = (_b = (_a = mediaTypeContent === null || mediaTypeContent === void 0 ? void 0 : mediaTypeContent.schema) === null || _a === void 0 ? void 0 : _a.properties) !== null && _b !== void 0 ? _b : {};
|
|
1157
|
-
const
|
|
1154
|
+
const required = (_c = mediaTypeContent === null || mediaTypeContent === void 0 ? void 0 : mediaTypeContent.schema) === null || _c === void 0 ? void 0 : _c.required;
|
|
1155
|
+
const parameters = mapSchemaPropertiesToParameters(properties, required);
|
|
1158
1156
|
return initialParameterValues(parameters);
|
|
1159
1157
|
}, [isFormDataBody, mediaTypeContent]);
|
|
1160
1158
|
const [bodyParameterValues, setBodyParameterValues] = React__namespace.useState(initialState);
|
|
@@ -1201,7 +1199,7 @@ function ExampleMenu({ examples, requestBody, onChange }) {
|
|
|
1201
1199
|
|
|
1202
1200
|
const useGenerateExampleFromMediaTypeContent = (mediaTypeContent, chosenExampleIndex, { skipReadOnly, skipWriteOnly, skipNonRequired } = {}) => {
|
|
1203
1201
|
const document = useDocument();
|
|
1204
|
-
return React__default[
|
|
1202
|
+
return React__default["default"].useMemo(() => generateExampleFromMediaTypeContent(mediaTypeContent, document, chosenExampleIndex, {
|
|
1205
1203
|
skipNonRequired,
|
|
1206
1204
|
skipWriteOnly,
|
|
1207
1205
|
skipReadOnly,
|
|
@@ -1222,6 +1220,7 @@ const generateExampleFromMediaTypeContent = (mediaTypeContent, document, chosenE
|
|
|
1222
1220
|
}
|
|
1223
1221
|
catch (e) {
|
|
1224
1222
|
console.warn(e);
|
|
1223
|
+
return `Example cannot be created for this schema\n${e}`;
|
|
1225
1224
|
}
|
|
1226
1225
|
return '';
|
|
1227
1226
|
};
|
|
@@ -1251,15 +1250,26 @@ const generateExamplesFromJsonSchema = (schema) => {
|
|
|
1251
1250
|
if (examples.length) {
|
|
1252
1251
|
return examples;
|
|
1253
1252
|
}
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1253
|
+
try {
|
|
1254
|
+
const generated = Sampler__namespace.sample(schema, {
|
|
1255
|
+
maxSampleDepth: 4,
|
|
1256
|
+
});
|
|
1257
|
+
return generated !== null
|
|
1258
|
+
? [
|
|
1259
|
+
{
|
|
1260
|
+
label: 'default',
|
|
1261
|
+
data: (_b = json.safeStringify(generated, undefined, 2)) !== null && _b !== void 0 ? _b : '',
|
|
1262
|
+
},
|
|
1263
|
+
]
|
|
1264
|
+
: [{ label: 'default', data: '' }];
|
|
1265
|
+
}
|
|
1266
|
+
catch (e) {
|
|
1267
|
+
console.error(e);
|
|
1268
|
+
return [{ label: '', data: `Example cannot be created for this schema\n${e}` }];
|
|
1269
|
+
}
|
|
1270
|
+
};
|
|
1271
|
+
const exceedsSize = (example, size = 500) => {
|
|
1272
|
+
return example.split(/\r\n|\r|\n/).length > size;
|
|
1263
1273
|
};
|
|
1264
1274
|
|
|
1265
1275
|
const useTextRequestBodyState = (mediaTypeContent) => {
|
|
@@ -1293,10 +1303,12 @@ function buildFetchRequest({ httpOperation, mediaTypeContent, bodyInput, paramet
|
|
|
1293
1303
|
const rawHeaders = filterOutAuthorizationParams((_e = (_d = httpOperation.request) === null || _d === void 0 ? void 0 : _d.headers) !== null && _e !== void 0 ? _e : [], httpOperation.security).map(header => { var _a; return ({ name: header.name, value: (_a = parameterValues[header.name]) !== null && _a !== void 0 ? _a : '' }); });
|
|
1294
1304
|
const [queryParamsWithAuth, headersWithAuth] = runAuthRequestEhancements(auth, queryParams, rawHeaders);
|
|
1295
1305
|
const expandedPath = uriExpand(httpOperation.path, parameterValues);
|
|
1296
|
-
const url = new URL(URI__default[
|
|
1306
|
+
const url = new URL(URI__default["default"](serverUrl).segment(expandedPath).toString());
|
|
1297
1307
|
url.search = new URLSearchParams(queryParamsWithAuth.map(nameAndValueObjectToPair)).toString();
|
|
1298
1308
|
const body = typeof bodyInput === 'object' ? yield createRequestBody(mediaTypeContent, bodyInput) : bodyInput;
|
|
1299
|
-
const headers = Object.assign(Object.assign({
|
|
1309
|
+
const headers = Object.assign(Object.assign(Object.assign({}, ((mediaTypeContent === null || mediaTypeContent === void 0 ? void 0 : mediaTypeContent.mediaType) !== 'multipart/form-data' && {
|
|
1310
|
+
'Content-Type': (_f = mediaTypeContent === null || mediaTypeContent === void 0 ? void 0 : mediaTypeContent.mediaType) !== null && _f !== void 0 ? _f : 'application/json',
|
|
1311
|
+
})), Object.fromEntries(headersWithAuth.map(nameAndValueObjectToPair))), mockData === null || mockData === void 0 ? void 0 : mockData.header);
|
|
1300
1312
|
return [
|
|
1301
1313
|
url.toString(),
|
|
1302
1314
|
{
|
|
@@ -1391,7 +1403,7 @@ function buildHarRequest({ httpOperation, bodyInput, parameterValues, mediaTypeC
|
|
|
1391
1403
|
}
|
|
1392
1404
|
return {
|
|
1393
1405
|
method: httpOperation.method.toUpperCase(),
|
|
1394
|
-
url: URI__default[
|
|
1406
|
+
url: URI__default["default"](serverUrl).segment(extendedPath).toString(),
|
|
1395
1407
|
httpVersion: 'HTTP/1.1',
|
|
1396
1408
|
cookies: [],
|
|
1397
1409
|
headers: [{ name: 'Content-Type', value: mimeType }, ...headerParamsWithAuth],
|
|
@@ -1430,6 +1442,9 @@ function getMockData(url, httpOperation, { isEnabled, code, dynamic, example })
|
|
|
1430
1442
|
return isEnabled && url ? { url, header: buildPreferHeader({ code, dynamic, example }, httpOperation) } : undefined;
|
|
1431
1443
|
}
|
|
1432
1444
|
function buildPreferHeader({ code, example, dynamic }, httpOperation) {
|
|
1445
|
+
if (!code) {
|
|
1446
|
+
return undefined;
|
|
1447
|
+
}
|
|
1433
1448
|
const isCodeSupported = supportsResponseCode(httpOperation, code);
|
|
1434
1449
|
const isExampleSupported = isCodeSupported && supportsExample(httpOperation, code, example);
|
|
1435
1450
|
const args = lodash.compact([
|
|
@@ -1600,7 +1615,7 @@ function parseBody(body, type) {
|
|
|
1600
1615
|
return json.safeStringify(json.safeParse(body), undefined, 2) || body;
|
|
1601
1616
|
case 'xml':
|
|
1602
1617
|
try {
|
|
1603
|
-
return formatXml__default[
|
|
1618
|
+
return formatXml__default["default"](body);
|
|
1604
1619
|
}
|
|
1605
1620
|
catch (_a) {
|
|
1606
1621
|
return body;
|
|
@@ -1775,11 +1790,17 @@ const TryIt = ({ httpOperation, mockUrl, onRequestChange, requestBodyIndex, embe
|
|
|
1775
1790
|
response && 'error' in response && React__namespace.createElement(ResponseError, { state: response })));
|
|
1776
1791
|
};
|
|
1777
1792
|
|
|
1793
|
+
const LoadMore = ({ loading, onClick }) => {
|
|
1794
|
+
return (React__namespace.createElement(mosaic.Flex, { flexDirection: "col", justifyContent: "center", alignItems: "center", style: { height: '400px' } },
|
|
1795
|
+
React__namespace.createElement(mosaic.Button, { "aria-label": "load-example", onPress: onClick, appearance: "minimal", loading: loading, disabled: loading }, loading ? 'Loading...' : 'Load examples'),
|
|
1796
|
+
React__namespace.createElement(mosaic.Text, { fontSize: "base", textAlign: "center" }, "Large examples are not rendered by default.")));
|
|
1797
|
+
};
|
|
1798
|
+
|
|
1778
1799
|
const ResponseExamples = ({ httpOperation, responseMediaType, responseStatusCode }) => {
|
|
1779
1800
|
var _a;
|
|
1780
|
-
const [chosenExampleIndex, setChosenExampleIndex] = React__default[
|
|
1781
|
-
const [show, setShow] = React__default[
|
|
1782
|
-
const [loading, setLoading] = React__default[
|
|
1801
|
+
const [chosenExampleIndex, setChosenExampleIndex] = React__default["default"].useState(0);
|
|
1802
|
+
const [show, setShow] = React__default["default"].useState(false);
|
|
1803
|
+
const [loading, setLoading] = React__default["default"].useState(false);
|
|
1783
1804
|
const response = httpOperation.responses.find(response => response.code === responseStatusCode);
|
|
1784
1805
|
const responseContents = (_a = response === null || response === void 0 ? void 0 : response.contents) === null || _a === void 0 ? void 0 : _a.find(content => content.mediaType === responseMediaType);
|
|
1785
1806
|
let userDefinedExamples;
|
|
@@ -1789,20 +1810,18 @@ const ResponseExamples = ({ httpOperation, responseMediaType, responseStatusCode
|
|
|
1789
1810
|
const responseExample = useGenerateExampleFromMediaTypeContent(responseContents, chosenExampleIndex, {
|
|
1790
1811
|
skipWriteOnly: true,
|
|
1791
1812
|
});
|
|
1792
|
-
const
|
|
1813
|
+
const handleLoadMore = () => {
|
|
1814
|
+
setLoading(true);
|
|
1815
|
+
setTimeout(() => setShow(true), 50);
|
|
1816
|
+
};
|
|
1793
1817
|
if (!userDefinedExamples && responseMediaType !== 'application/json')
|
|
1794
1818
|
return null;
|
|
1795
1819
|
if (!responseExample)
|
|
1796
1820
|
return null;
|
|
1797
|
-
const examplesSelect = userDefinedExamples && userDefinedExamples.length > 1 && (React__default[
|
|
1798
|
-
return (React__default[
|
|
1799
|
-
React__default[
|
|
1800
|
-
React__default[
|
|
1801
|
-
React__default['default'].createElement(mosaic.Button, { "aria-label": "load-example", onPress: () => {
|
|
1802
|
-
setLoading(true);
|
|
1803
|
-
setTimeout(() => setShow(true), 50);
|
|
1804
|
-
}, appearance: "minimal", loading: loading, disabled: loading }, loading ? 'Loading...' : 'Load examples'),
|
|
1805
|
-
React__default['default'].createElement(mosaic.Text, { fontSize: "base", textAlign: "center" }, "Large examples are not rendered by default."))))));
|
|
1821
|
+
const examplesSelect = userDefinedExamples && userDefinedExamples.length > 1 && (React__default["default"].createElement(mosaic.Select, { "aria-label": "Response Example", value: String(chosenExampleIndex), options: userDefinedExamples.map((example, index) => ({ value: index, label: example.key })), onChange: (value) => setChosenExampleIndex(parseInt(String(value), 10)), size: "sm", triggerTextPrefix: "Response Example: " }));
|
|
1822
|
+
return (React__default["default"].createElement(mosaic.Panel, { rounded: true, isCollapsible: false },
|
|
1823
|
+
React__default["default"].createElement(mosaic.Panel.Titlebar, null, examplesSelect || React__default["default"].createElement(mosaic.Text, { color: "body" }, "Response Example")),
|
|
1824
|
+
React__default["default"].createElement(mosaic.Panel.Content, { p: 0 }, show || !exceedsSize(responseExample) ? (React__default["default"].createElement(mosaicCodeViewer.CodeViewer, { "aria-label": responseExample, noCopyButton: true, maxHeight: "400px", language: "json", value: responseExample, showLineNumbers: true })) : (React__default["default"].createElement(LoadMore, { loading: loading, onClick: handleLoadMore })))));
|
|
1806
1825
|
};
|
|
1807
1826
|
|
|
1808
1827
|
const TryItWithRequestSamples = (_a) => {
|
|
@@ -1816,19 +1835,19 @@ const TryItWithRequestSamples = (_a) => {
|
|
|
1816
1835
|
React__namespace.createElement(ResponseExamples, Object.assign({}, props))));
|
|
1817
1836
|
};
|
|
1818
1837
|
|
|
1819
|
-
const TwoColumnLayout = ({ header, right, left, className }) => (React__default[
|
|
1838
|
+
const TwoColumnLayout = ({ header, right, left, className }) => (React__default["default"].createElement(mosaic.Box, { w: "full", className: className },
|
|
1820
1839
|
header,
|
|
1821
|
-
React__default[
|
|
1822
|
-
React__default[
|
|
1823
|
-
right && (React__default[
|
|
1840
|
+
React__default["default"].createElement(mosaic.Flex, { mt: header ? 12 : undefined },
|
|
1841
|
+
React__default["default"].createElement(mosaic.Box, { style: { width: 0 }, flex: 1 }, left),
|
|
1842
|
+
right && (React__default["default"].createElement(mosaic.Box, { ml: 16, pos: "relative", w: "2/5", style: { maxWidth: 500 } }, right)))));
|
|
1824
1843
|
|
|
1825
|
-
const DeprecatedBadge = () => (React__default[
|
|
1826
|
-
const InternalBadge = ({ isHttpService }) => (React__default[
|
|
1844
|
+
const DeprecatedBadge = () => (React__default["default"].createElement(mosaic.Tooltip, { renderTrigger: React__default["default"].createElement(mosaic.Badge, { intent: "warning", icon: freeSolidSvgIcons.faExclamationCircle, "data-testid": "badge-deprecated" }, "Deprecated") }, "This operation has been marked as deprecated, which means it could be removed at some point in the future."));
|
|
1845
|
+
const InternalBadge = ({ isHttpService }) => (React__default["default"].createElement(mosaic.Tooltip, { renderTrigger: React__default["default"].createElement(mosaic.Badge, { icon: freeSolidSvgIcons.faEye, "data-testid": "badge-internal", className: "sl-bg-danger sl-ml-0" }, "Internal") }, `This ${isHttpService ? 'operation' : 'model'} is marked as internal and won't be visible in public docs.`));
|
|
1827
1846
|
const SecurityBadge = ({ scheme, httpServiceUri, includeKey }) => {
|
|
1828
|
-
const badge = (React__default[
|
|
1829
|
-
return httpServiceUri ? (React__default[
|
|
1847
|
+
const badge = (React__default["default"].createElement(mosaic.Badge, { icon: freeSolidSvgIcons.faLock, "data-testid": "badge-security", className: "sl-truncate", style: { backgroundColor: badgeDefaultBackgroundColor, color: badgeDefaultColor } }, getReadableSecurityName(scheme, includeKey)));
|
|
1848
|
+
return httpServiceUri ? (React__default["default"].createElement(reactRouterDom.Link, { to: `${httpServiceUri}?security=${scheme.key}`, className: "sl-no-underline sl-block" }, badge)) : (badge);
|
|
1830
1849
|
};
|
|
1831
|
-
const VersionBadge = ({ value, backgroundColor }) => (React__default[
|
|
1850
|
+
const VersionBadge = ({ value, backgroundColor }) => (React__default["default"].createElement(mosaic.Badge, { appearance: "solid", size: "sm", style: {
|
|
1832
1851
|
backgroundColor: backgroundColor || badgeDefaultBackgroundColor,
|
|
1833
1852
|
border: 'none',
|
|
1834
1853
|
color: badgeDefaultColor,
|
|
@@ -1896,22 +1915,23 @@ const Parameters = ({ parameters, parameterType }) => {
|
|
|
1896
1915
|
};
|
|
1897
1916
|
Parameters.displayName = 'HttpOperation.Parameters';
|
|
1898
1917
|
const Parameter = ({ parameter, parameterType }) => {
|
|
1899
|
-
var _a, _b, _c;
|
|
1918
|
+
var _a, _b, _c, _d, _e;
|
|
1900
1919
|
if (!parameter)
|
|
1901
1920
|
return null;
|
|
1902
1921
|
const description = lodash.get(parameter, 'description') || lodash.get(parameter, 'schema.description');
|
|
1903
|
-
const
|
|
1904
|
-
const
|
|
1922
|
+
const rootType = lodash.get(parameter, 'schema.type', 'unknown');
|
|
1923
|
+
const type = ((_b = (_a = parameter.schema) === null || _a === void 0 ? void 0 : _a.items) === null || _b === void 0 ? void 0 : _b['type']) && rootType === 'array' ? `array[${parameter.schema.items['type']}]` : rootType;
|
|
1924
|
+
const format = (_c = parameter.schema) === null || _c === void 0 ? void 0 : _c.format;
|
|
1905
1925
|
const deprecated = lodash.get(parameter, 'deprecated') || lodash.get(parameter, 'schema.deprecated', false);
|
|
1906
|
-
const parameterExamples = ((
|
|
1926
|
+
const parameterExamples = ((_d = parameter.examples) === null || _d === void 0 ? void 0 : _d.map(example => {
|
|
1907
1927
|
if (isNodeExample(example)) {
|
|
1908
1928
|
return example.value;
|
|
1909
1929
|
}
|
|
1910
1930
|
return example.externalValue;
|
|
1911
1931
|
})) || [];
|
|
1912
|
-
const schemaExamples = (
|
|
1932
|
+
const schemaExamples = (_e = parameter.schema) === null || _e === void 0 ? void 0 : _e.examples;
|
|
1913
1933
|
const schemaExamplesArray = Array.isArray(schemaExamples) ? schemaExamples : [];
|
|
1914
|
-
const validations = lodash.omitBy(Object.assign(Object.assign(Object.assign({}, lodash.omit(parameter, ['name', 'required', 'deprecated', 'description', 'schema', 'style', 'examples'])), lodash.omit(lodash.get(parameter, 'schema'), ['description', 'type', 'deprecated'])), { examples: [...parameterExamples, ...schemaExamplesArray] }), value => (typeof value === 'object' && lodash.isEmpty(value)) || typeof value === 'undefined');
|
|
1934
|
+
const validations = lodash.omitBy(Object.assign(Object.assign(Object.assign(Object.assign({}, lodash.omit(parameter, ['name', 'required', 'deprecated', 'description', 'schema', 'style', 'examples'])), lodash.omit(lodash.get(parameter, 'schema'), ['description', 'type', 'deprecated'])), lodash.omit(lodash.get(parameter, 'schema.items'), ['description', 'type', 'deprecated'])), { examples: [...parameterExamples, ...schemaExamplesArray] }), value => (typeof value === 'object' && lodash.isEmpty(value)) || typeof value === 'undefined');
|
|
1915
1935
|
return (React__namespace.createElement("div", { className: "HttpOperation__Parameters" },
|
|
1916
1936
|
React__namespace.createElement("div", { className: "sl-flex sl-items-center sl-my-2" },
|
|
1917
1937
|
React__namespace.createElement("div", { className: "sl-flex sl-items-baseline sl-text-base sl-flex-1" },
|
|
@@ -2007,7 +2027,7 @@ const HttpOperationComponent = React__namespace.memo(({ className, data: unresol
|
|
|
2007
2027
|
data.responses && (React__namespace.createElement(Responses, { responses: data.responses, onMediaTypeChange: setResponseMediaType, onStatusCodeChange: setResponseStatusCode }))));
|
|
2008
2028
|
const tryItPanel = !(layoutOptions === null || layoutOptions === void 0 ? void 0 : layoutOptions.hideTryItPanel) && (React__namespace.createElement(mosaic.Box, { className: "HttpOperation__gutter" },
|
|
2009
2029
|
React__namespace.createElement(TryItWithRequestSamples, { httpOperation: data, responseMediaType: responseMediaType, responseStatusCode: responseStatusCode, requestBodyIndex: requestBodyIndex, hideTryIt: layoutOptions === null || layoutOptions === void 0 ? void 0 : layoutOptions.hideTryIt, tryItCredentialsPolicy: tryItCredentialsPolicy, mockUrl: mocking.hideMocking ? undefined : mocking.mockUrl, corsProxy: tryItCorsProxy })));
|
|
2010
|
-
return (React__namespace.createElement(TwoColumnLayout, { className: cn__default[
|
|
2030
|
+
return (React__namespace.createElement(TwoColumnLayout, { className: cn__default["default"]('HttpOperation', className), header: header, left: description, right: tryItPanel }));
|
|
2011
2031
|
});
|
|
2012
2032
|
HttpOperationComponent.displayName = 'HttpOperation.Component';
|
|
2013
2033
|
const HttpOperation = reactErrorBoundary.withErrorBoundary(HttpOperationComponent, {
|
|
@@ -2031,12 +2051,12 @@ const AdditionalInfo = ({ termsOfService, contact, license }) => {
|
|
|
2031
2051
|
const licenseUrl = (license === null || license === void 0 ? void 0 : license.url) || `https://spdx.org/licenses/${license === null || license === void 0 ? void 0 : license.identifier}.html`;
|
|
2032
2052
|
const licenseLink = (license === null || license === void 0 ? void 0 : license.name) && licenseUrl ? `[${license.name} License](${licenseUrl})` : '';
|
|
2033
2053
|
const tosLink = termsOfService ? `[Terms of Service](${termsOfService})` : '';
|
|
2034
|
-
return contactLink || licenseLink || tosLink ? (React__default[
|
|
2035
|
-
React__default[
|
|
2036
|
-
React__default[
|
|
2037
|
-
React__default[
|
|
2038
|
-
React__default[
|
|
2039
|
-
React__default[
|
|
2054
|
+
return contactLink || licenseLink || tosLink ? (React__default["default"].createElement(mosaic.Panel, { rounded: true, isCollapsible: false },
|
|
2055
|
+
React__default["default"].createElement(mosaic.Panel.Titlebar, { bg: "canvas-300" },
|
|
2056
|
+
React__default["default"].createElement("span", { role: "heading" }, "Additional Information")),
|
|
2057
|
+
React__default["default"].createElement(mosaic.Panel.Content, { p: 0 },
|
|
2058
|
+
React__default["default"].createElement(mosaic.Panel.Content, null,
|
|
2059
|
+
React__default["default"].createElement(MarkdownViewer, { style: { fontSize: 12 }, markdown: `${contactLink}\n \n${licenseLink}\n \n ${tosLink}` }))))) : null;
|
|
2040
2060
|
};
|
|
2041
2061
|
|
|
2042
2062
|
const ExportButton = ({ original, bundled }) => {
|
|
@@ -2058,14 +2078,14 @@ const oauthFlowNames = {
|
|
|
2058
2078
|
password: 'Password',
|
|
2059
2079
|
};
|
|
2060
2080
|
const SecuritySchemes = ({ schemes, defaultScheme }) => {
|
|
2061
|
-
return (React__default[
|
|
2062
|
-
React__default[
|
|
2063
|
-
React__default[
|
|
2064
|
-
React__default[
|
|
2065
|
-
React__default[
|
|
2066
|
-
React__default[
|
|
2067
|
-
React__default[
|
|
2068
|
-
React__default[
|
|
2081
|
+
return (React__default["default"].createElement(mosaic.Panel, { rounded: true, isCollapsible: false },
|
|
2082
|
+
React__default["default"].createElement(mosaic.Panel.Titlebar, { bg: "canvas-300" },
|
|
2083
|
+
React__default["default"].createElement("span", { role: "heading" }, "Security")),
|
|
2084
|
+
React__default["default"].createElement(mosaic.Panel.Content, { p: 0 }, lodash.sortBy(schemes, 'type').map((scheme, i) => (React__default["default"].createElement(mosaic.Panel, { key: i, defaultIsOpen: defaultScheme ? scheme.key === defaultScheme : i === 0, isCollapsible: schemes.length > 1 },
|
|
2085
|
+
React__default["default"].createElement(mosaic.Panel.Titlebar, null,
|
|
2086
|
+
React__default["default"].createElement("span", { role: "heading" }, getReadableSecurityName(scheme, shouldIncludeKey(schemes, scheme.type)))),
|
|
2087
|
+
React__default["default"].createElement(mosaic.Panel.Content, null,
|
|
2088
|
+
React__default["default"].createElement(MarkdownViewer, { style: { fontSize: 12 }, markdown: `${scheme.description || ''}\n\n` + getDefaultDescription(scheme) }))))))));
|
|
2069
2089
|
};
|
|
2070
2090
|
function getDefaultDescription(scheme) {
|
|
2071
2091
|
switch (scheme.type) {
|
|
@@ -2185,10 +2205,16 @@ const HttpService = reactErrorBoundary.withErrorBoundary(HttpServiceComponent, {
|
|
|
2185
2205
|
const ModelComponent = ({ data: unresolvedData, className, nodeTitle, layoutOptions, exportProps, }) => {
|
|
2186
2206
|
var _a;
|
|
2187
2207
|
const [chosenExampleIndex, setChosenExampleIndex] = React__namespace.useState(0);
|
|
2208
|
+
const [show, setShow] = React__namespace.useState(false);
|
|
2209
|
+
const [loading, setLoading] = React__namespace.useState(false);
|
|
2188
2210
|
const resolveRef = useInlineRefResolver();
|
|
2189
2211
|
const data = useResolvedObject(unresolvedData);
|
|
2190
2212
|
const title = (_a = data.title) !== null && _a !== void 0 ? _a : nodeTitle;
|
|
2191
2213
|
const isInternal = !!data['x-internal'];
|
|
2214
|
+
const handleLoadMorePress = () => {
|
|
2215
|
+
setLoading(true);
|
|
2216
|
+
setTimeout(() => setShow(true), 50);
|
|
2217
|
+
};
|
|
2192
2218
|
const examples = React__namespace.useMemo(() => generateExamplesFromJsonSchema(data), [data]);
|
|
2193
2219
|
const shouldDisplayHeader = !(layoutOptions === null || layoutOptions === void 0 ? void 0 : layoutOptions.noHeading) && (title !== undefined || (exportProps && !(layoutOptions === null || layoutOptions === void 0 ? void 0 : layoutOptions.hideExport)));
|
|
2194
2220
|
const header = (shouldDisplayHeader || isInternal) && (React__namespace.createElement(React__namespace.Fragment, null,
|
|
@@ -2203,9 +2229,8 @@ const ModelComponent = ({ data: unresolvedData, className, nodeTitle, layoutOpti
|
|
|
2203
2229
|
const examplesSelect = examples.length > 1 && (React__namespace.createElement(mosaic.Select, { "aria-label": "Example", value: String(chosenExampleIndex), options: examples.map(({ label }, index) => ({ value: index, label })), onChange: (value) => setChosenExampleIndex(parseInt(String(value), 10)), size: "sm", triggerTextPrefix: "Example: " }));
|
|
2204
2230
|
const modelExamples = !(layoutOptions === null || layoutOptions === void 0 ? void 0 : layoutOptions.hideModelExamples) && (React__namespace.createElement(mosaic.Panel, { rounded: true, isCollapsible: false },
|
|
2205
2231
|
React__namespace.createElement(mosaic.Panel.Titlebar, null, examplesSelect || (React__namespace.createElement(mosaic.Text, { color: "body", role: "heading" }, "Example"))),
|
|
2206
|
-
React__namespace.createElement(mosaic.Panel.Content, { p: 0 },
|
|
2207
|
-
|
|
2208
|
-
return (React__namespace.createElement(TwoColumnLayout, { className: cn__default['default']('Model', className), header: header, left: description, right: modelExamples }));
|
|
2232
|
+
React__namespace.createElement(mosaic.Panel.Content, { p: 0 }, show || !exceedsSize(examples[chosenExampleIndex].data) ? (React__namespace.createElement(mosaicCodeViewer.CodeViewer, { "aria-label": examples[chosenExampleIndex].data, noCopyButton: true, maxHeight: "500px", language: "json", value: examples[chosenExampleIndex].data, showLineNumbers: true })) : (React__namespace.createElement(LoadMore, { loading: loading, onClick: handleLoadMorePress })))));
|
|
2233
|
+
return (React__namespace.createElement(TwoColumnLayout, { className: cn__default["default"]('Model', className), header: header, left: description, right: modelExamples }));
|
|
2209
2234
|
};
|
|
2210
2235
|
const Model = reactErrorBoundary.withErrorBoundary(ModelComponent, { recoverableProps: ['data'] });
|
|
2211
2236
|
|
|
@@ -2262,8 +2287,84 @@ const Logo = ({ logo }) => {
|
|
|
2262
2287
|
React__namespace.createElement("img", { src: logo.url, height: "30px", width: "30px", alt: logo.altText }))) : (React__namespace.createElement("img", { src: logo.url, height: "30px", width: "30px", alt: logo.altText }))));
|
|
2263
2288
|
};
|
|
2264
2289
|
|
|
2290
|
+
function useParsedValue(value) {
|
|
2291
|
+
return React__namespace.useMemo(() => {
|
|
2292
|
+
let parsedValue = value;
|
|
2293
|
+
if (typeof value === 'string') {
|
|
2294
|
+
try {
|
|
2295
|
+
parsedValue = yaml.parse(value);
|
|
2296
|
+
}
|
|
2297
|
+
catch (error) {
|
|
2298
|
+
}
|
|
2299
|
+
}
|
|
2300
|
+
return parsedValue;
|
|
2301
|
+
}, [value]);
|
|
2302
|
+
}
|
|
2303
|
+
|
|
2304
|
+
function isPartialHttpRequest(maybeHttpRequest) {
|
|
2305
|
+
return (lodash.isObject(maybeHttpRequest) &&
|
|
2306
|
+
'method' in maybeHttpRequest &&
|
|
2307
|
+
typeof maybeHttpRequest['method'] === 'string' &&
|
|
2308
|
+
'url' in maybeHttpRequest &&
|
|
2309
|
+
typeof maybeHttpRequest['url'] === 'string');
|
|
2310
|
+
}
|
|
2311
|
+
const SchemaAndDescription = ({ title: titleProp, schema }) => {
|
|
2312
|
+
const resolveRef = useInlineRefResolver();
|
|
2313
|
+
const title = titleProp !== null && titleProp !== void 0 ? titleProp : schema.title;
|
|
2314
|
+
return (React__default["default"].createElement(mosaic.Box, { py: 2 },
|
|
2315
|
+
title && (React__default["default"].createElement(mosaic.Flex, { alignItems: "center", p: 2 },
|
|
2316
|
+
React__default["default"].createElement(reactFontawesome.FontAwesomeIcon, { icon: NodeTypeIconDefs[types.NodeType.Model], color: NodeTypeColors[types.NodeType.Model] }),
|
|
2317
|
+
React__default["default"].createElement(mosaic.Box, { color: "muted", px: 2 }, title))),
|
|
2318
|
+
React__default["default"].createElement(jsonSchemaViewer.JsonSchemaViewer, { resolveRef: resolveRef, schema: getOriginalObject(schema) })));
|
|
2319
|
+
};
|
|
2320
|
+
const CodeComponent = props => {
|
|
2321
|
+
const { title, jsonSchema, http, children } = props;
|
|
2322
|
+
const value = String(Array.isArray(children) ? children[0] : children);
|
|
2323
|
+
const parsedValue = useParsedValue(value);
|
|
2324
|
+
if (jsonSchema) {
|
|
2325
|
+
if (!isJSONSchema(parsedValue)) {
|
|
2326
|
+
return null;
|
|
2327
|
+
}
|
|
2328
|
+
return React__default["default"].createElement(SchemaAndDescription, { title: title, schema: parsedValue });
|
|
2329
|
+
}
|
|
2330
|
+
if (http) {
|
|
2331
|
+
if (!lodash.isObject(parsedValue) || (!isPartialHttpRequest(parsedValue) && !isHttpOperation(parsedValue))) {
|
|
2332
|
+
return null;
|
|
2333
|
+
}
|
|
2334
|
+
return (React__default["default"].createElement(TryIt, { httpOperation: isHttpOperation(parsedValue) ? parsedValue : parseHttpRequest(parsedValue), embeddedInMd: true }));
|
|
2335
|
+
}
|
|
2336
|
+
const DefaultCode = markdownViewer.DefaultSMDComponents.code;
|
|
2337
|
+
return React__default["default"].createElement(DefaultCode, Object.assign({}, props));
|
|
2338
|
+
};
|
|
2339
|
+
function parseHttpRequest(data) {
|
|
2340
|
+
const uri = URI__default["default"](data.url);
|
|
2341
|
+
const pathParam = data.url.match(/[^{\}]+(?=})/g);
|
|
2342
|
+
return {
|
|
2343
|
+
id: '?http-operation-id?',
|
|
2344
|
+
method: data.method,
|
|
2345
|
+
path: uri.is('absolute') ? uri.path() : data.url,
|
|
2346
|
+
servers: [{ url: uri.is('absolute') ? uri.origin() : data.baseUrl || '' }],
|
|
2347
|
+
request: Object.assign({ query: Object.entries(data.query || {}).map(([key, value]) => ({
|
|
2348
|
+
name: key,
|
|
2349
|
+
style: types.HttpParamStyles.Form,
|
|
2350
|
+
schema: { default: Array.isArray(value) && value.length > 0 ? value[0] : value },
|
|
2351
|
+
})), headers: Object.entries(data.headers || {}).map(([key, value]) => ({
|
|
2352
|
+
name: key,
|
|
2353
|
+
style: types.HttpParamStyles.Simple,
|
|
2354
|
+
schema: { default: value },
|
|
2355
|
+
})), path: pathParam === null || pathParam === void 0 ? void 0 : pathParam.map(name => ({
|
|
2356
|
+
name,
|
|
2357
|
+
style: types.HttpParamStyles.Simple,
|
|
2358
|
+
required: true,
|
|
2359
|
+
})) }, (data.body
|
|
2360
|
+
? { body: { contents: [{ mediaType: 'application/json', schema: { default: data.body } }] } }
|
|
2361
|
+
: null)),
|
|
2362
|
+
responses: [],
|
|
2363
|
+
};
|
|
2364
|
+
}
|
|
2365
|
+
|
|
2265
2366
|
const MarkdownComponentsProvider = ({ value, children }) => {
|
|
2266
|
-
return React__namespace.createElement(markdownViewer.MarkdownViewerProvider, { components: value }, children);
|
|
2367
|
+
return React__namespace.createElement(markdownViewer.MarkdownViewerProvider, { components: Object.assign({ code: CodeComponent }, value) }, children);
|
|
2267
2368
|
};
|
|
2268
2369
|
|
|
2269
2370
|
const NODE_TYPE_TITLE_ICON = {
|
|
@@ -2457,8 +2558,8 @@ function withPersistenceBoundary(WrappedComponent) {
|
|
|
2457
2558
|
|
|
2458
2559
|
function withMosaicProvider(WrappedComponent) {
|
|
2459
2560
|
const WithMosaicProvider = (props) => {
|
|
2460
|
-
return (React__default[
|
|
2461
|
-
React__default[
|
|
2561
|
+
return (React__default["default"].createElement(mosaic.Provider, { style: { height: '100%' } },
|
|
2562
|
+
React__default["default"].createElement(WrappedComponent, Object.assign({}, props))));
|
|
2462
2563
|
};
|
|
2463
2564
|
WithMosaicProvider.displayName = `WithMosaicProvider(${getDisplayName(WrappedComponent)})`;
|
|
2464
2565
|
return WithMosaicProvider;
|
|
@@ -2474,8 +2575,8 @@ const queryClient = new reactQuery.QueryClient({
|
|
|
2474
2575
|
});
|
|
2475
2576
|
function withQueryClientProvider(WrappedComponent) {
|
|
2476
2577
|
const WithQueryClientProvider = (props) => {
|
|
2477
|
-
return (React__default[
|
|
2478
|
-
React__default[
|
|
2578
|
+
return (React__default["default"].createElement(reactQuery.QueryClientProvider, { client: queryClient },
|
|
2579
|
+
React__default["default"].createElement(WrappedComponent, Object.assign({}, props))));
|
|
2479
2580
|
};
|
|
2480
2581
|
WithQueryClientProvider.displayName = `WithQueryClientProvider(${getDisplayName(WrappedComponent)})`;
|
|
2481
2582
|
return WithQueryClientProvider;
|
|
@@ -2485,9 +2586,9 @@ const externalRegex = new RegExp('^(?:[a-z]+:)?//', 'i');
|
|
|
2485
2586
|
const ReactRouterMarkdownLink = ({ title, href, children }) => {
|
|
2486
2587
|
const isExternal = href !== undefined && externalRegex.test(href);
|
|
2487
2588
|
if (isExternal) {
|
|
2488
|
-
return (React__default[
|
|
2589
|
+
return (React__default["default"].createElement("a", { target: "_blank", rel: "noreferrer noopener", href: href, title: title }, children));
|
|
2489
2590
|
}
|
|
2490
|
-
return (React__default[
|
|
2591
|
+
return (React__default["default"].createElement(reactRouterHashLink.HashLink, { to: href, title: title }, children));
|
|
2491
2592
|
};
|
|
2492
2593
|
|
|
2493
2594
|
const RouterComponent = {
|
|
@@ -2551,27 +2652,13 @@ function useBundleRefsIntoDocument(document, options) {
|
|
|
2551
2652
|
const commonBundleOptions = { continueOnError: true };
|
|
2552
2653
|
const doBundle = (data, baseUrl) => {
|
|
2553
2654
|
if (!baseUrl) {
|
|
2554
|
-
return $RefParser__default[
|
|
2655
|
+
return $RefParser__default["default"].bundle(data, commonBundleOptions);
|
|
2555
2656
|
}
|
|
2556
2657
|
else {
|
|
2557
|
-
return $RefParser__default[
|
|
2658
|
+
return $RefParser__default["default"].bundle(baseUrl, data, commonBundleOptions);
|
|
2558
2659
|
}
|
|
2559
2660
|
};
|
|
2560
2661
|
|
|
2561
|
-
function useParsedValue(value) {
|
|
2562
|
-
return React__namespace.useMemo(() => {
|
|
2563
|
-
let parsedValue = value;
|
|
2564
|
-
if (typeof value === 'string') {
|
|
2565
|
-
try {
|
|
2566
|
-
parsedValue = yaml.parse(value);
|
|
2567
|
-
}
|
|
2568
|
-
catch (error) {
|
|
2569
|
-
}
|
|
2570
|
-
}
|
|
2571
|
-
return parsedValue;
|
|
2572
|
-
}, [value]);
|
|
2573
|
-
}
|
|
2574
|
-
|
|
2575
2662
|
const scopeClassName = 'sl-elements';
|
|
2576
2663
|
class Styled extends React__namespace.Component {
|
|
2577
2664
|
getChildContext() {
|
|
@@ -2696,9 +2783,7 @@ const createElementClass = (Component, propDescriptors) => {
|
|
|
2696
2783
|
|
|
2697
2784
|
Object.defineProperty(exports, 'DefaultSMDComponents', {
|
|
2698
2785
|
enumerable: true,
|
|
2699
|
-
get: function () {
|
|
2700
|
-
return markdownViewer.DefaultSMDComponents;
|
|
2701
|
-
}
|
|
2786
|
+
get: function () { return markdownViewer.DefaultSMDComponents; }
|
|
2702
2787
|
});
|
|
2703
2788
|
exports.DeprecatedBadge = DeprecatedBadge;
|
|
2704
2789
|
exports.Docs = Docs;
|