@stoplight/elements-core 7.3.7 → 7.3.11
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 +1 -2
- package/components/Docs/HttpOperation/HttpOperation.d.ts +1 -2
- package/components/Docs/HttpService/HttpService.d.ts +1 -2
- package/components/Docs/Model/Model.d.ts +1 -2
- package/components/MosaicTableOfContents/types.d.ts +0 -1
- package/context/InlineRefResolver.d.ts +3 -4
- package/context/InlineRefResolver.spec.d.ts +1 -0
- package/hoc/withMosaicProvider.spec.d.ts +1 -0
- package/hoc/withQueryClientProvider.spec.d.ts +1 -0
- package/index.d.ts +1 -0
- package/index.esm.js +41 -23
- package/index.js +87 -67
- package/index.mjs +41 -23
- package/package.json +6 -7
- package/styles.min.css +1 -1
package/index.js
CHANGED
|
@@ -4,8 +4,8 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
var tslib = require('tslib');
|
|
6
6
|
var React = require('react');
|
|
7
|
-
var lodash = require('lodash');
|
|
8
7
|
var json = require('@stoplight/json');
|
|
8
|
+
var _ = require('lodash');
|
|
9
9
|
var markdown = require('@stoplight/markdown');
|
|
10
10
|
var types = require('@stoplight/types');
|
|
11
11
|
var yaml = require('@stoplight/yaml');
|
|
@@ -21,14 +21,13 @@ var URI = require('urijs');
|
|
|
21
21
|
var mosaicCodeViewer = require('@stoplight/mosaic-code-viewer');
|
|
22
22
|
var HTTPSnippet = require('httpsnippet');
|
|
23
23
|
var nanoid = require('nanoid');
|
|
24
|
-
var fp = require('lodash/fp');
|
|
25
24
|
var mosaicCodeEditor = require('@stoplight/mosaic-code-editor');
|
|
26
25
|
var Sampler = require('@stoplight/json-schema-sampler');
|
|
27
26
|
var formatXml = require('xml-formatter');
|
|
28
27
|
var reactRouterDom = require('react-router-dom');
|
|
29
28
|
var jsonSchemaViewer = require('@stoplight/json-schema-viewer');
|
|
30
|
-
var reactQuery = require('react-query');
|
|
31
29
|
var reactRouterHashLink = require('react-router-hash-link');
|
|
30
|
+
var reactQuery = require('react-query');
|
|
32
31
|
var $RefParser = require('@stoplight/json-schema-ref-parser');
|
|
33
32
|
var PropTypes = require('prop-types');
|
|
34
33
|
var ReactDOM = require('react-dom');
|
|
@@ -55,6 +54,7 @@ function _interopNamespace(e) {
|
|
|
55
54
|
|
|
56
55
|
var React__namespace = /*#__PURE__*/_interopNamespace(React);
|
|
57
56
|
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
57
|
+
var ___default = /*#__PURE__*/_interopDefaultLegacy(_);
|
|
58
58
|
var cn__default = /*#__PURE__*/_interopDefaultLegacy(cn);
|
|
59
59
|
var URI__default = /*#__PURE__*/_interopDefaultLegacy(URI);
|
|
60
60
|
var HTTPSnippet__default = /*#__PURE__*/_interopDefaultLegacy(HTTPSnippet);
|
|
@@ -107,7 +107,7 @@ const recursivelyCreateResolvedObject = (currentObject, rootCurrentObject, prope
|
|
|
107
107
|
else {
|
|
108
108
|
resolvedValue = value;
|
|
109
109
|
}
|
|
110
|
-
if (
|
|
110
|
+
if (_.isPlainObject(resolvedValue) || _.isArray(resolvedValue)) {
|
|
111
111
|
return recursivelyCreateResolvedObject(resolvedValue, rootCurrentObject, newPropertyPath, objectToProxiedObjectCache, mergedOptions);
|
|
112
112
|
}
|
|
113
113
|
return resolvedValue;
|
|
@@ -122,16 +122,16 @@ const isResolvedObjectProxy = (someObject) => {
|
|
|
122
122
|
const getOriginalObject = (resolvedObject) => {
|
|
123
123
|
return resolvedObject[originalObjectSymbol] || resolvedObject;
|
|
124
124
|
};
|
|
125
|
-
const isReference = (value) =>
|
|
125
|
+
const isReference = (value) => _.isObject(value) && typeof value['$ref'] === 'string';
|
|
126
126
|
|
|
127
127
|
const InlineRefResolverContext = React__namespace.createContext(undefined);
|
|
128
128
|
InlineRefResolverContext.displayName = 'InlineRefResolverContext';
|
|
129
129
|
const DocumentContext = React__namespace.createContext(undefined);
|
|
130
130
|
DocumentContext.displayName = 'DocumentContext';
|
|
131
|
-
const InlineRefResolverProvider = (
|
|
132
|
-
|
|
133
|
-
const
|
|
134
|
-
return (React__namespace.createElement(InlineRefResolverContext.Provider, { value:
|
|
131
|
+
const InlineRefResolverProvider = ({ children, document: maybeDocument, resolver, }) => {
|
|
132
|
+
const document = json.isPlainObject(maybeDocument) ? maybeDocument : undefined;
|
|
133
|
+
const computedResolver = React__namespace.useMemo(() => resolver || (document !== undefined ? defaultResolver(document) : undefined), [document, resolver]);
|
|
134
|
+
return (React__namespace.createElement(InlineRefResolverContext.Provider, { value: computedResolver },
|
|
135
135
|
React__namespace.createElement(DocumentContext.Provider, { value: document }, children)));
|
|
136
136
|
};
|
|
137
137
|
const useInlineRefResolver = () => React.useContext(InlineRefResolverContext);
|
|
@@ -139,17 +139,17 @@ const useDocument = () => React.useContext(DocumentContext);
|
|
|
139
139
|
const useResolvedObject = (currentObject) => {
|
|
140
140
|
const document = useDocument();
|
|
141
141
|
const resolver = useInlineRefResolver();
|
|
142
|
-
return createResolvedObject(currentObject, { contextObject: document, resolver });
|
|
142
|
+
return React__namespace.useMemo(() => createResolvedObject(currentObject, { contextObject: document, resolver }), [currentObject, document, resolver]);
|
|
143
143
|
};
|
|
144
144
|
|
|
145
145
|
function isSMDASTRoot(maybeAst) {
|
|
146
|
-
return
|
|
146
|
+
return _.isObject(maybeAst) && maybeAst['type'] === 'root' && mosaic.isArray(maybeAst['children']);
|
|
147
147
|
}
|
|
148
148
|
function isJSONSchema(maybeSchema) {
|
|
149
|
-
return
|
|
149
|
+
return _.isPlainObject(maybeSchema);
|
|
150
150
|
}
|
|
151
151
|
function isStoplightNode(maybeNode) {
|
|
152
|
-
return
|
|
152
|
+
return _.isObject(maybeNode) && 'id' in maybeNode;
|
|
153
153
|
}
|
|
154
154
|
function isHttpService(maybeHttpService) {
|
|
155
155
|
return isStoplightNode(maybeHttpService) && 'name' in maybeHttpService && 'version' in maybeHttpService;
|
|
@@ -247,7 +247,7 @@ function useComponentSize(container) {
|
|
|
247
247
|
if (!container) {
|
|
248
248
|
return;
|
|
249
249
|
}
|
|
250
|
-
const updateComponentSize =
|
|
250
|
+
const updateComponentSize = _.throttle(() => (container ? setComponentSize(container.getBoundingClientRect()) : { width: 0, height: 0 }), 1000, {
|
|
251
251
|
trailing: true,
|
|
252
252
|
});
|
|
253
253
|
updateComponentSize();
|
|
@@ -352,7 +352,7 @@ function getReadableSecurityName(securityScheme, includeKey = false) {
|
|
|
352
352
|
name = 'API Key';
|
|
353
353
|
break;
|
|
354
354
|
case 'http':
|
|
355
|
-
name = `${
|
|
355
|
+
name = `${_.capitalize(securityScheme.scheme)} Auth`;
|
|
356
356
|
break;
|
|
357
357
|
case 'oauth2':
|
|
358
358
|
name = 'OAuth 2.0';
|
|
@@ -370,11 +370,11 @@ function getServiceUriFromOperation(uri) {
|
|
|
370
370
|
const match = uri === null || uri === void 0 ? void 0 : uri.match(/(.*)\/(paths|operations)/);
|
|
371
371
|
return match && match.length > 1 ? match[1] || '/' : undefined;
|
|
372
372
|
}
|
|
373
|
-
const isOAuth2ImplicitFlow = (maybeFlow) =>
|
|
374
|
-
const isOauth2AuthorizationCodeFlow = (maybeFlow) =>
|
|
375
|
-
const isOauth2ClientCredentialsOrPasswordFlow = (maybeFlow) =>
|
|
373
|
+
const isOAuth2ImplicitFlow = (maybeFlow) => _.isObject(maybeFlow) && 'authorizationUrl' in maybeFlow && !('tokenUrl' in maybeFlow);
|
|
374
|
+
const isOauth2AuthorizationCodeFlow = (maybeFlow) => _.isObject(maybeFlow) && 'authorizationUrl' in maybeFlow && 'tokenUrl' in maybeFlow;
|
|
375
|
+
const isOauth2ClientCredentialsOrPasswordFlow = (maybeFlow) => _.isObject(maybeFlow) && !('authorizationUrl' in maybeFlow) && 'tokenUrl' in maybeFlow;
|
|
376
376
|
function shouldIncludeKey(schemes, type) {
|
|
377
|
-
return
|
|
377
|
+
return _.filter(schemes, { type }).length > 1;
|
|
378
378
|
}
|
|
379
379
|
|
|
380
380
|
const NodeTypeColors = {
|
|
@@ -837,7 +837,7 @@ const OAuth2Auth = ({ value, onChange }) => {
|
|
|
837
837
|
|
|
838
838
|
const TryItAuth = ({ operationSecurityScheme: operationAuth, onChange, value }) => {
|
|
839
839
|
var _a;
|
|
840
|
-
const operationSecurityArray =
|
|
840
|
+
const operationSecurityArray = _.flatten(operationAuth);
|
|
841
841
|
const filteredSecurityItems = operationSecurityArray.filter(scheme => securitySchemeKeys.includes(scheme === null || scheme === void 0 ? void 0 : scheme.type));
|
|
842
842
|
const securityScheme = value ? value.scheme : filteredSecurityItems[0];
|
|
843
843
|
const menuName = securityScheme ? getReadableSecurityName(securityScheme) : 'Security Scheme';
|
|
@@ -899,15 +899,15 @@ const SecuritySchemeComponent = (_a) => {
|
|
|
899
899
|
};
|
|
900
900
|
const securitySchemeKeys = ['apiKey', 'http', 'oauth2', 'openIdConnect'];
|
|
901
901
|
|
|
902
|
-
const caseInsensitivelyEquals =
|
|
902
|
+
const caseInsensitivelyEquals = _.curry((a, b) => a.toUpperCase() === b.toUpperCase());
|
|
903
903
|
|
|
904
|
-
const isApiKeySecurityScheme = (maybeIApiKey) =>
|
|
905
|
-
const isOAuth2SecurityScheme = (maybeIOAuth2) =>
|
|
906
|
-
const isBasicSecurityScheme = (maybeIBasic) =>
|
|
907
|
-
const isBearerSecurityScheme = (maybeIBearer) =>
|
|
908
|
-
const isDigestSecurityScheme = (maybeIBearer) =>
|
|
904
|
+
const isApiKeySecurityScheme = (maybeIApiKey) => _.isObject(maybeIApiKey) && maybeIApiKey.type === 'apiKey';
|
|
905
|
+
const isOAuth2SecurityScheme = (maybeIOAuth2) => _.isObject(maybeIOAuth2) && maybeIOAuth2.type === 'oauth2';
|
|
906
|
+
const isBasicSecurityScheme = (maybeIBasic) => _.isObject(maybeIBasic) && maybeIBasic.type === 'http' && maybeIBasic.scheme === 'basic';
|
|
907
|
+
const isBearerSecurityScheme = (maybeIBearer) => _.isObject(maybeIBearer) && maybeIBearer.type === 'http' && maybeIBearer.scheme === 'bearer';
|
|
908
|
+
const isDigestSecurityScheme = (maybeIBearer) => _.isObject(maybeIBearer) && maybeIBearer.type === 'http' && maybeIBearer.scheme === 'digest';
|
|
909
909
|
function filterOutAuthorizationParams(queryParams, securitySchemes = []) {
|
|
910
|
-
const flattenedSecuritySchemes =
|
|
910
|
+
const flattenedSecuritySchemes = _.flatten(securitySchemes);
|
|
911
911
|
const securitySchemeNames = getSecuritySchemeNames(flattenedSecuritySchemes);
|
|
912
912
|
return queryParams.filter(queryParam => !securitySchemeNames.some(caseInsensitivelyEquals(queryParam.name)));
|
|
913
913
|
}
|
|
@@ -978,7 +978,7 @@ const booleanOptions = [
|
|
|
978
978
|
{ label: 'True', value: 'true' },
|
|
979
979
|
];
|
|
980
980
|
function enumOptions(enumValues, required) {
|
|
981
|
-
const options =
|
|
981
|
+
const options = _.map(enumValues, v => ({ value: Number.isNaN(Number(v)) ? String(v) : Number(v) }));
|
|
982
982
|
return required ? options : [{ label: 'Not Set', value: '' }, ...options];
|
|
983
983
|
}
|
|
984
984
|
function parameterOptions(parameter) {
|
|
@@ -1018,7 +1018,7 @@ function getPlaceholderForParameter(parameter) {
|
|
|
1018
1018
|
function retrieveDefaultFromSchema(parameter) {
|
|
1019
1019
|
var _a;
|
|
1020
1020
|
const defaultValue = (_a = parameter.schema) === null || _a === void 0 ? void 0 : _a.default;
|
|
1021
|
-
return
|
|
1021
|
+
return _.isObject(defaultValue) ? json.safeStringify(defaultValue) : defaultValue;
|
|
1022
1022
|
}
|
|
1023
1023
|
const getValueForParameter = (parameter) => {
|
|
1024
1024
|
var _a, _b, _c;
|
|
@@ -1039,7 +1039,12 @@ const getInitialValueForParameter = (parameter) => {
|
|
|
1039
1039
|
return '';
|
|
1040
1040
|
return getValueForParameter(parameter);
|
|
1041
1041
|
};
|
|
1042
|
-
const initialParameterValues =
|
|
1042
|
+
const initialParameterValues = params => {
|
|
1043
|
+
return ___default["default"].chain(params)
|
|
1044
|
+
.keyBy((param) => param.name)
|
|
1045
|
+
.mapValues(param => getInitialValueForParameter(param))
|
|
1046
|
+
.value();
|
|
1047
|
+
};
|
|
1043
1048
|
function mapSchemaPropertiesToParameters(properties, required) {
|
|
1044
1049
|
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 }))));
|
|
1045
1050
|
}
|
|
@@ -1080,7 +1085,7 @@ const FormDataBody = ({ specification, values, onChangeValues }) => {
|
|
|
1080
1085
|
if (supportsFileUpload) {
|
|
1081
1086
|
return (React__namespace.createElement(FileUploadParameterEditor, { key: parameter.name, parameter: parameter, value: value instanceof File ? value : undefined, onChange: newValue => newValue
|
|
1082
1087
|
? onChangeValues(Object.assign(Object.assign({}, values), { [parameter.name]: newValue }))
|
|
1083
|
-
: onChangeValues(
|
|
1088
|
+
: onChangeValues(_.omit(values, parameter.name)) }));
|
|
1084
1089
|
}
|
|
1085
1090
|
return (React__namespace.createElement(ParameterEditor, { key: parameter.name, parameter: parameter, value: typeof value === 'string' ? value : undefined, onChange: (value) => onChangeValues(Object.assign(Object.assign({}, values), { [parameter.name]: typeof value === 'number' ? String(value) : value })) }));
|
|
1086
1091
|
}))));
|
|
@@ -1114,7 +1119,7 @@ function createRequestBody(mediaTypeContent, bodyParameterValues) {
|
|
|
1114
1119
|
});
|
|
1115
1120
|
}
|
|
1116
1121
|
const createUrlEncodedRequestBody = ({ bodyParameterValues = {} }) => tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
1117
|
-
const filteredValues =
|
|
1122
|
+
const filteredValues = _.pickBy(bodyParameterValues, _.isString);
|
|
1118
1123
|
return new URLSearchParams(filteredValues);
|
|
1119
1124
|
});
|
|
1120
1125
|
const createMultipartRequestBody = ({ mediaTypeContent, bodyParameterValues = {} }) => tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
@@ -1447,7 +1452,7 @@ function buildPreferHeader({ code, example, dynamic }, httpOperation) {
|
|
|
1447
1452
|
}
|
|
1448
1453
|
const isCodeSupported = supportsResponseCode(httpOperation, code);
|
|
1449
1454
|
const isExampleSupported = isCodeSupported && supportsExample(httpOperation, code, example);
|
|
1450
|
-
const args =
|
|
1455
|
+
const args = _.compact([
|
|
1451
1456
|
code && isCodeSupported ? ['code', code] : undefined,
|
|
1452
1457
|
dynamic ? ['dynamic', String(dynamic)] : undefined,
|
|
1453
1458
|
example && isExampleSupported ? ['example', example] : undefined,
|
|
@@ -1468,7 +1473,7 @@ function supportsExample(httpOperation, code, exampleKey) {
|
|
|
1468
1473
|
const response = (_a = httpOperation.responses) === null || _a === void 0 ? void 0 : _a.find(response => response.code === code);
|
|
1469
1474
|
if (!response)
|
|
1470
1475
|
return false;
|
|
1471
|
-
const exampleKeys =
|
|
1476
|
+
const exampleKeys = _.uniq((_b = response.contents) === null || _b === void 0 ? void 0 : _b.flatMap(c => c.examples || []).map(example => example.key));
|
|
1472
1477
|
return exampleKeys.includes(exampleKey);
|
|
1473
1478
|
}
|
|
1474
1479
|
|
|
@@ -1493,7 +1498,7 @@ const MockingButton = ({ operation, options: { isEnabled, code, example, dynamic
|
|
|
1493
1498
|
var _a;
|
|
1494
1499
|
const menuId = `response-${operationResponse.code}`;
|
|
1495
1500
|
const isActive = operationResponse.code === code;
|
|
1496
|
-
const exampleKeys =
|
|
1501
|
+
const exampleKeys = _.uniq((_a = operationResponse.contents) === null || _a === void 0 ? void 0 : _a.flatMap(c => c.examples || []).map(example => example.key));
|
|
1497
1502
|
const exampleChildren = exampleKeys === null || exampleKeys === void 0 ? void 0 : exampleKeys.map(exampleKey => ({
|
|
1498
1503
|
id: `${menuId}-example-${exampleKey}`,
|
|
1499
1504
|
title: exampleKey,
|
|
@@ -1581,10 +1586,10 @@ const useRequestParameters = (httpOperation) => {
|
|
|
1581
1586
|
function extractAllParameters(httpOperation) {
|
|
1582
1587
|
var _a, _b, _c, _d, _e, _f;
|
|
1583
1588
|
const getRequired = (obj) => { var _a; return (_a = obj.required) !== null && _a !== void 0 ? _a : false; };
|
|
1584
|
-
const pathParameters =
|
|
1585
|
-
const queryParameters = filterOutAuthorizationParams(
|
|
1586
|
-
const headerParameters = filterOutAuthorizationParams(
|
|
1587
|
-
return
|
|
1589
|
+
const pathParameters = _.orderBy((_b = (_a = httpOperation.request) === null || _a === void 0 ? void 0 : _a.path) !== null && _b !== void 0 ? _b : [], [getRequired, 'name'], ['desc', 'asc']);
|
|
1590
|
+
const queryParameters = filterOutAuthorizationParams(_.orderBy((_d = (_c = httpOperation.request) === null || _c === void 0 ? void 0 : _c.query) !== null && _d !== void 0 ? _d : [], [getRequired, 'name'], ['desc', 'asc']), httpOperation.security);
|
|
1591
|
+
const headerParameters = filterOutAuthorizationParams(_.orderBy((_f = (_e = httpOperation.request) === null || _e === void 0 ? void 0 : _e.headers) !== null && _f !== void 0 ? _f : [], [getRequired, 'name'], ['desc', 'asc']), httpOperation.security);
|
|
1592
|
+
return _.uniqBy([...pathParameters, ...queryParameters, ...headerParameters], p => p.name);
|
|
1588
1593
|
}
|
|
1589
1594
|
|
|
1590
1595
|
function getHttpCodeColor(code) {
|
|
@@ -1647,12 +1652,12 @@ const ResponseMenu = ({ types, type, onChange }) => {
|
|
|
1647
1652
|
const menuItems = React__namespace.useMemo(() => {
|
|
1648
1653
|
const items = types.map(type => ({
|
|
1649
1654
|
id: type,
|
|
1650
|
-
title:
|
|
1655
|
+
title: _.capitalize(type),
|
|
1651
1656
|
onPress: () => onChange(type),
|
|
1652
1657
|
}));
|
|
1653
1658
|
return items;
|
|
1654
1659
|
}, [types, onChange]);
|
|
1655
|
-
return (React__namespace.createElement(mosaic.Menu, { "aria-label": "Body Format", items: menuItems, renderTrigger: ({ isOpen }) => (React__namespace.createElement(mosaic.Button, { appearance: "minimal", size: "sm", iconRight: ['fas', 'sort'], active: isOpen },
|
|
1660
|
+
return (React__namespace.createElement(mosaic.Menu, { "aria-label": "Body Format", items: menuItems, renderTrigger: ({ isOpen }) => (React__namespace.createElement(mosaic.Button, { appearance: "minimal", size: "sm", iconRight: ['fas', 'sort'], active: isOpen }, _.capitalize(type))) }));
|
|
1656
1661
|
};
|
|
1657
1662
|
const ResponseError = ({ state: { error } }) => (React__namespace.createElement(mosaic.Panel, { defaultIsOpen: true },
|
|
1658
1663
|
React__namespace.createElement(mosaic.Panel.Titlebar, null, "Error"),
|
|
@@ -1909,7 +1914,7 @@ const defaultStyle = {
|
|
|
1909
1914
|
const Parameters = ({ parameters, parameterType }) => {
|
|
1910
1915
|
if (!parameters || !parameters.length)
|
|
1911
1916
|
return null;
|
|
1912
|
-
return (React__namespace.createElement(mosaic.VStack, { spacing: 2, pl: 6, divider: React__namespace.createElement(mosaic.Box, { borderT: true, borderColor: "light", w: "full" }) },
|
|
1917
|
+
return (React__namespace.createElement(mosaic.VStack, { spacing: 2, pl: 6, divider: React__namespace.createElement(mosaic.Box, { borderT: true, borderColor: "light", w: "full" }) }, _.sortBy(parameters, ['required', 'name']).map(parameter => {
|
|
1913
1918
|
return React__namespace.createElement(Parameter, { key: parameter.name, parameter: parameter, parameterType: parameterType });
|
|
1914
1919
|
})));
|
|
1915
1920
|
};
|
|
@@ -1918,11 +1923,11 @@ const Parameter = ({ parameter, parameterType }) => {
|
|
|
1918
1923
|
var _a, _b, _c, _d, _e;
|
|
1919
1924
|
if (!parameter)
|
|
1920
1925
|
return null;
|
|
1921
|
-
const description =
|
|
1922
|
-
const rootType =
|
|
1926
|
+
const description = _.get(parameter, 'description') || _.get(parameter, 'schema.description');
|
|
1927
|
+
const rootType = _.get(parameter, 'schema.type', 'unknown');
|
|
1923
1928
|
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
1929
|
const format = (_c = parameter.schema) === null || _c === void 0 ? void 0 : _c.format;
|
|
1925
|
-
const deprecated =
|
|
1930
|
+
const deprecated = _.get(parameter, 'deprecated') || _.get(parameter, 'schema.deprecated', false);
|
|
1926
1931
|
const parameterExamples = ((_d = parameter.examples) === null || _d === void 0 ? void 0 : _d.map(example => {
|
|
1927
1932
|
if (isNodeExample(example)) {
|
|
1928
1933
|
return example.value;
|
|
@@ -1931,7 +1936,7 @@ const Parameter = ({ parameter, parameterType }) => {
|
|
|
1931
1936
|
})) || [];
|
|
1932
1937
|
const schemaExamples = (_e = parameter.schema) === null || _e === void 0 ? void 0 : _e.examples;
|
|
1933
1938
|
const schemaExamplesArray = Array.isArray(schemaExamples) ? schemaExamples : [];
|
|
1934
|
-
const validations =
|
|
1939
|
+
const validations = _.omitBy(Object.assign(Object.assign(Object.assign(Object.assign({}, _.omit(parameter, ['name', 'required', 'deprecated', 'description', 'schema', 'style', 'examples'])), _.omit(_.get(parameter, 'schema'), ['description', 'type', 'deprecated'])), _.omit(_.get(parameter, 'schema.items'), ['description', 'type', 'deprecated'])), { examples: [...parameterExamples, ...schemaExamplesArray] }), value => (typeof value === 'object' && _.isEmpty(value)) || typeof value === 'undefined');
|
|
1935
1940
|
return (React__namespace.createElement("div", { className: "HttpOperation__Parameters" },
|
|
1936
1941
|
React__namespace.createElement("div", { className: "sl-flex sl-items-center sl-my-2" },
|
|
1937
1942
|
React__namespace.createElement("div", { className: "sl-flex sl-items-baseline sl-text-base sl-flex-1" },
|
|
@@ -1972,7 +1977,7 @@ Request.displayName = 'HttpOperation.Request';
|
|
|
1972
1977
|
|
|
1973
1978
|
const Responses = ({ responses: unsortedResponses, onStatusCodeChange, onMediaTypeChange }) => {
|
|
1974
1979
|
var _a, _b;
|
|
1975
|
-
const responses =
|
|
1980
|
+
const responses = _.sortBy(_.uniqBy(unsortedResponses, r => r.code), r => r.code);
|
|
1976
1981
|
const [activeResponseId, setActiveResponseId] = React__namespace.useState((_b = (_a = responses[0]) === null || _a === void 0 ? void 0 : _a.code) !== null && _b !== void 0 ? _b : '');
|
|
1977
1982
|
React__namespace.useEffect(() => {
|
|
1978
1983
|
onStatusCodeChange(activeResponseId);
|
|
@@ -2013,13 +2018,13 @@ const HttpOperationComponent = React__namespace.memo(({ className, data: unresol
|
|
|
2013
2018
|
const [responseStatusCode, setResponseStatusCode] = React__namespace.useState('');
|
|
2014
2019
|
const [requestBodyIndex, setTextRequestBodyIndex] = React__namespace.useState(0);
|
|
2015
2020
|
const httpServiceUri = uri && getServiceUriFromOperation(uri);
|
|
2016
|
-
const securitySchemes =
|
|
2021
|
+
const securitySchemes = _.flatten(data.security);
|
|
2017
2022
|
const hasBadges = isDeprecated || securitySchemes.length > 0 || isInternal;
|
|
2018
2023
|
const header = (!(layoutOptions === null || layoutOptions === void 0 ? void 0 : layoutOptions.noHeading) || hasBadges) && (React__namespace.createElement(React__namespace.Fragment, null,
|
|
2019
2024
|
!(layoutOptions === null || layoutOptions === void 0 ? void 0 : layoutOptions.noHeading) && (React__namespace.createElement(mosaic.Heading, { size: 1, mb: 4, fontWeight: "semibold" }, data.summary || data.iid || `${data.method} ${data.path}`)),
|
|
2020
2025
|
hasBadges && (React__namespace.createElement(mosaic.HStack, { spacing: 2 },
|
|
2021
2026
|
isDeprecated && React__namespace.createElement(DeprecatedBadge, null),
|
|
2022
|
-
|
|
2027
|
+
_.sortBy(securitySchemes, 'type').map((scheme, i) => (React__namespace.createElement(SecurityBadge, { key: i, scheme: scheme, httpServiceUri: allowRouting ? httpServiceUri : undefined, includeKey: shouldIncludeKey(securitySchemes, scheme.type) }))),
|
|
2023
2028
|
isInternal && React__namespace.createElement(InternalBadge, { isHttpService: true })))));
|
|
2024
2029
|
const description = (React__namespace.createElement(React__namespace.Fragment, null,
|
|
2025
2030
|
data.description && (React__namespace.createElement(MarkdownViewer, { className: "HttpOperation__Description sl-mb-10", markdown: data.description })),
|
|
@@ -2081,7 +2086,7 @@ const SecuritySchemes = ({ schemes, defaultScheme }) => {
|
|
|
2081
2086
|
return (React__default["default"].createElement(mosaic.Panel, { rounded: true, isCollapsible: false },
|
|
2082
2087
|
React__default["default"].createElement(mosaic.Panel.Titlebar, { bg: "canvas-300" },
|
|
2083
2088
|
React__default["default"].createElement("span", { role: "heading" }, "Security")),
|
|
2084
|
-
React__default["default"].createElement(mosaic.Panel.Content, { p: 0 },
|
|
2089
|
+
React__default["default"].createElement(mosaic.Panel.Content, { p: 0 }, _.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
2090
|
React__default["default"].createElement(mosaic.Panel.Titlebar, null,
|
|
2086
2091
|
React__default["default"].createElement("span", { role: "heading" }, getReadableSecurityName(scheme, shouldIncludeKey(schemes, scheme.type)))),
|
|
2087
2092
|
React__default["default"].createElement(mosaic.Panel.Content, null,
|
|
@@ -2128,7 +2133,7 @@ function getDigestAuthDescription() {
|
|
|
2128
2133
|
Example: \`Authorization: Digest username=guest, realm="test", nonce="2", uri="/uri", response="123"\``;
|
|
2129
2134
|
}
|
|
2130
2135
|
function getOAuthDescription(scheme) {
|
|
2131
|
-
const flows =
|
|
2136
|
+
const flows = _.keys(scheme.flows);
|
|
2132
2137
|
return flows.map(flow => getOAuthFlowDescription(oauthFlowNames[flow], scheme.flows[flow])).join('\n\n');
|
|
2133
2138
|
}
|
|
2134
2139
|
function getOAuthFlowDescription(title, flow) {
|
|
@@ -2143,7 +2148,7 @@ function getOAuthFlowDescription(title, flow) {
|
|
|
2143
2148
|
: '';
|
|
2144
2149
|
description += flow.refreshUrl ? `\n\nRefresh URL: ${flow.refreshUrl}` : '';
|
|
2145
2150
|
description += `\n\nScopes:
|
|
2146
|
-
${
|
|
2151
|
+
${_.entries(flow.scopes)
|
|
2147
2152
|
.map(([key, value]) => `- \`${key}\` - ${value}`)
|
|
2148
2153
|
.join('\n')}`;
|
|
2149
2154
|
return description;
|
|
@@ -2302,7 +2307,7 @@ function useParsedValue(value) {
|
|
|
2302
2307
|
}
|
|
2303
2308
|
|
|
2304
2309
|
function isPartialHttpRequest(maybeHttpRequest) {
|
|
2305
|
-
return (
|
|
2310
|
+
return (_.isObject(maybeHttpRequest) &&
|
|
2306
2311
|
'method' in maybeHttpRequest &&
|
|
2307
2312
|
typeof maybeHttpRequest['method'] === 'string' &&
|
|
2308
2313
|
'url' in maybeHttpRequest &&
|
|
@@ -2328,7 +2333,7 @@ const CodeComponent = props => {
|
|
|
2328
2333
|
return React__default["default"].createElement(SchemaAndDescription, { title: title, schema: parsedValue });
|
|
2329
2334
|
}
|
|
2330
2335
|
if (http) {
|
|
2331
|
-
if (!
|
|
2336
|
+
if (!_.isObject(parsedValue) || (!isPartialHttpRequest(parsedValue) && !isHttpOperation(parsedValue))) {
|
|
2332
2337
|
return null;
|
|
2333
2338
|
}
|
|
2334
2339
|
return (React__default["default"].createElement(TryIt, { httpOperation: isHttpOperation(parsedValue) ? parsedValue : parseHttpRequest(parsedValue), embeddedInMd: true }));
|
|
@@ -2367,6 +2372,15 @@ const MarkdownComponentsProvider = ({ value, children }) => {
|
|
|
2367
2372
|
return React__namespace.createElement(markdownViewer.MarkdownViewerProvider, { components: Object.assign({ code: CodeComponent }, value) }, children);
|
|
2368
2373
|
};
|
|
2369
2374
|
|
|
2375
|
+
const externalRegex = new RegExp('^(?:[a-z]+:)?//', 'i');
|
|
2376
|
+
const ReactRouterMarkdownLink = ({ title, href, children }) => {
|
|
2377
|
+
const isExternal = href !== undefined && externalRegex.test(href);
|
|
2378
|
+
if (isExternal) {
|
|
2379
|
+
return (React__default["default"].createElement("a", { target: "_blank", rel: "noreferrer noopener", href: href, title: title }, children));
|
|
2380
|
+
}
|
|
2381
|
+
return (React__default["default"].createElement(reactRouterHashLink.HashLink, { to: href, title: title }, children));
|
|
2382
|
+
};
|
|
2383
|
+
|
|
2370
2384
|
const NODE_TYPE_TITLE_ICON = {
|
|
2371
2385
|
http_service: freeSolidSvgIcons.faCloud,
|
|
2372
2386
|
};
|
|
@@ -2558,6 +2572,14 @@ function withPersistenceBoundary(WrappedComponent) {
|
|
|
2558
2572
|
|
|
2559
2573
|
function withMosaicProvider(WrappedComponent) {
|
|
2560
2574
|
const WithMosaicProvider = (props) => {
|
|
2575
|
+
try {
|
|
2576
|
+
const mosaicContext = mosaic.useMosaicContext();
|
|
2577
|
+
if (mosaicContext === null || mosaicContext === void 0 ? void 0 : mosaicContext.providerId) {
|
|
2578
|
+
return React__default["default"].createElement(WrappedComponent, Object.assign({}, props));
|
|
2579
|
+
}
|
|
2580
|
+
}
|
|
2581
|
+
catch (_a) {
|
|
2582
|
+
}
|
|
2561
2583
|
return (React__default["default"].createElement(mosaic.Provider, { style: { height: '100%' } },
|
|
2562
2584
|
React__default["default"].createElement(WrappedComponent, Object.assign({}, props))));
|
|
2563
2585
|
};
|
|
@@ -2575,6 +2597,12 @@ const queryClient = new reactQuery.QueryClient({
|
|
|
2575
2597
|
});
|
|
2576
2598
|
function withQueryClientProvider(WrappedComponent) {
|
|
2577
2599
|
const WithQueryClientProvider = (props) => {
|
|
2600
|
+
try {
|
|
2601
|
+
reactQuery.useQueryClient();
|
|
2602
|
+
return React__default["default"].createElement(WrappedComponent, Object.assign({}, props));
|
|
2603
|
+
}
|
|
2604
|
+
catch (_a) {
|
|
2605
|
+
}
|
|
2578
2606
|
return (React__default["default"].createElement(reactQuery.QueryClientProvider, { client: queryClient },
|
|
2579
2607
|
React__default["default"].createElement(WrappedComponent, Object.assign({}, props))));
|
|
2580
2608
|
};
|
|
@@ -2582,15 +2610,6 @@ function withQueryClientProvider(WrappedComponent) {
|
|
|
2582
2610
|
return WithQueryClientProvider;
|
|
2583
2611
|
}
|
|
2584
2612
|
|
|
2585
|
-
const externalRegex = new RegExp('^(?:[a-z]+:)?//', 'i');
|
|
2586
|
-
const ReactRouterMarkdownLink = ({ title, href, children }) => {
|
|
2587
|
-
const isExternal = href !== undefined && externalRegex.test(href);
|
|
2588
|
-
if (isExternal) {
|
|
2589
|
-
return (React__default["default"].createElement("a", { target: "_blank", rel: "noreferrer noopener", href: href, title: title }, children));
|
|
2590
|
-
}
|
|
2591
|
-
return (React__default["default"].createElement(reactRouterHashLink.HashLink, { to: href, title: title }, children));
|
|
2592
|
-
};
|
|
2593
|
-
|
|
2594
2613
|
const RouterComponent = {
|
|
2595
2614
|
history: reactRouterDom.BrowserRouter,
|
|
2596
2615
|
memory: reactRouterDom.MemoryRouter,
|
|
@@ -2623,7 +2642,7 @@ function useBundleRefsIntoDocument(document, options) {
|
|
|
2623
2642
|
const [bundledData, setBundledData] = React__namespace.useState(document);
|
|
2624
2643
|
const baseUrl = options === null || options === void 0 ? void 0 : options.baseUrl;
|
|
2625
2644
|
React__namespace.useEffect(() => {
|
|
2626
|
-
if (!
|
|
2645
|
+
if (!_.isObject(document)) {
|
|
2627
2646
|
setBundledData(document);
|
|
2628
2647
|
return;
|
|
2629
2648
|
}
|
|
@@ -2687,7 +2706,7 @@ const createElementClass = (Component, propDescriptors) => {
|
|
|
2687
2706
|
constructor() {
|
|
2688
2707
|
super();
|
|
2689
2708
|
this._props = {};
|
|
2690
|
-
Object.defineProperties(this,
|
|
2709
|
+
Object.defineProperties(this, _.mapValues(propDescriptors, (_, key) => ({
|
|
2691
2710
|
get: () => {
|
|
2692
2711
|
return this._props[key];
|
|
2693
2712
|
},
|
|
@@ -2708,7 +2727,7 @@ const createElementClass = (Component, propDescriptors) => {
|
|
|
2708
2727
|
attributeChangedCallback(name, oldValue, newValue) {
|
|
2709
2728
|
if (propDescriptors[name]) {
|
|
2710
2729
|
const newPropValue = this._safeReadAttribute(name);
|
|
2711
|
-
if (!
|
|
2730
|
+
if (!_.isEqual(this._props[name], newPropValue)) {
|
|
2712
2731
|
this._props[name] = newPropValue;
|
|
2713
2732
|
this._renderComponent();
|
|
2714
2733
|
}
|
|
@@ -2774,7 +2793,7 @@ const createElementClass = (Component, propDescriptors) => {
|
|
|
2774
2793
|
}
|
|
2775
2794
|
_renderComponent() {
|
|
2776
2795
|
if (this._mountPoint) {
|
|
2777
|
-
const props =
|
|
2796
|
+
const props = _.mapValues(propDescriptors, (descriptor, key) => { var _a; return (_a = this._props[key]) !== null && _a !== void 0 ? _a : descriptor.defaultValue; });
|
|
2778
2797
|
ReactDOM__namespace.render(React__namespace.createElement(Component, props), this._mountPoint);
|
|
2779
2798
|
}
|
|
2780
2799
|
}
|
|
@@ -2800,6 +2819,7 @@ exports.NonIdealState = NonIdealState;
|
|
|
2800
2819
|
exports.ParsedDocs = ParsedDocs;
|
|
2801
2820
|
exports.PersistenceContextProvider = PersistenceContextProvider;
|
|
2802
2821
|
exports.PoweredByLink = PoweredByLink;
|
|
2822
|
+
exports.ReactRouterMarkdownLink = ReactRouterMarkdownLink;
|
|
2803
2823
|
exports.SidebarLayout = SidebarLayout;
|
|
2804
2824
|
exports.Styled = Styled;
|
|
2805
2825
|
exports.TableOfContents = TableOfContents;
|
package/index.mjs
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { __rest, __awaiter } from 'tslib';
|
|
2
2
|
import * as React from 'react';
|
|
3
3
|
import React__default, { useContext, useMemo } from 'react';
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
4
|
+
import { resolveInlineRef, isPlainObject as isPlainObject$1, safeParse, safeStringify } from '@stoplight/json';
|
|
5
|
+
import _, { isObject, isPlainObject, isArray, throttle, filter, capitalize, flatten, curry, map, omit, pickBy, isString, compact, uniq, uniqBy, orderBy, sortBy, get, omitBy, isEmpty, keys, entries, mapValues, isEqual } from 'lodash';
|
|
6
6
|
import { parse } from '@stoplight/markdown';
|
|
7
7
|
import { NodeType, HttpParamStyles } from '@stoplight/types';
|
|
8
8
|
import { parse as parse$1 } from '@stoplight/yaml';
|
|
9
|
-
import { isArray as isArray$1, Flex, Box, Popover, Button, Panel, CopyButton, Menu, Text, Input, Icon, Select, Image, Link, useThemeIsDark, Tooltip, VStack, InvertTheme, Badge, Tabs, TabList, Tab, TabPanels, TabPanel, Heading as Heading$1, HStack, useClipboard, Provider as Provider$1 } from '@stoplight/mosaic';
|
|
9
|
+
import { isArray as isArray$1, Flex, Box, Popover, Button, Panel, CopyButton, Menu, Text, Input, Icon, Select, Image, Link, useThemeIsDark, Tooltip, VStack, InvertTheme, Badge, Tabs, TabList, Tab, TabPanels, TabPanel, Heading as Heading$1, HStack, useClipboard, useMosaicContext, Provider as Provider$1 } from '@stoplight/mosaic';
|
|
10
10
|
import { withErrorBoundary } from '@stoplight/react-error-boundary';
|
|
11
11
|
import { MarkdownViewer as MarkdownViewer$1, DefaultSMDComponents, MarkdownViewerProvider } from '@stoplight/markdown-viewer';
|
|
12
12
|
export { DefaultSMDComponents } from '@stoplight/markdown-viewer';
|
|
@@ -19,14 +19,13 @@ import URI from 'urijs';
|
|
|
19
19
|
import { CodeViewer } from '@stoplight/mosaic-code-viewer';
|
|
20
20
|
import HTTPSnippet from 'httpsnippet';
|
|
21
21
|
import { nanoid } from 'nanoid';
|
|
22
|
-
import { pipe, keyBy, mapValues } from 'lodash/fp';
|
|
23
22
|
import { CodeEditor } from '@stoplight/mosaic-code-editor';
|
|
24
23
|
import * as Sampler from '@stoplight/json-schema-sampler';
|
|
25
24
|
import formatXml from 'xml-formatter';
|
|
26
25
|
import { Link as Link$1, useLocation, BrowserRouter, MemoryRouter, HashRouter, Route } from 'react-router-dom';
|
|
27
26
|
import { JsonSchemaViewer, Validations } from '@stoplight/json-schema-viewer';
|
|
28
|
-
import { QueryClient, QueryClientProvider } from 'react-query';
|
|
29
27
|
import { HashLink } from 'react-router-hash-link';
|
|
28
|
+
import { QueryClient, useQueryClient, QueryClientProvider } from 'react-query';
|
|
30
29
|
import $RefParser from '@stoplight/json-schema-ref-parser';
|
|
31
30
|
import * as PropTypes from 'prop-types';
|
|
32
31
|
import * as ReactDOM from 'react-dom';
|
|
@@ -95,10 +94,10 @@ const InlineRefResolverContext = React.createContext(undefined);
|
|
|
95
94
|
InlineRefResolverContext.displayName = 'InlineRefResolverContext';
|
|
96
95
|
const DocumentContext = React.createContext(undefined);
|
|
97
96
|
DocumentContext.displayName = 'DocumentContext';
|
|
98
|
-
const InlineRefResolverProvider = (
|
|
99
|
-
|
|
100
|
-
const
|
|
101
|
-
return (React.createElement(InlineRefResolverContext.Provider, { value:
|
|
97
|
+
const InlineRefResolverProvider = ({ children, document: maybeDocument, resolver, }) => {
|
|
98
|
+
const document = isPlainObject$1(maybeDocument) ? maybeDocument : undefined;
|
|
99
|
+
const computedResolver = React.useMemo(() => resolver || (document !== undefined ? defaultResolver(document) : undefined), [document, resolver]);
|
|
100
|
+
return (React.createElement(InlineRefResolverContext.Provider, { value: computedResolver },
|
|
102
101
|
React.createElement(DocumentContext.Provider, { value: document }, children)));
|
|
103
102
|
};
|
|
104
103
|
const useInlineRefResolver = () => useContext(InlineRefResolverContext);
|
|
@@ -106,7 +105,7 @@ const useDocument = () => useContext(DocumentContext);
|
|
|
106
105
|
const useResolvedObject = (currentObject) => {
|
|
107
106
|
const document = useDocument();
|
|
108
107
|
const resolver = useInlineRefResolver();
|
|
109
|
-
return createResolvedObject(currentObject, { contextObject: document, resolver });
|
|
108
|
+
return React.useMemo(() => createResolvedObject(currentObject, { contextObject: document, resolver }), [currentObject, document, resolver]);
|
|
110
109
|
};
|
|
111
110
|
|
|
112
111
|
function isSMDASTRoot(maybeAst) {
|
|
@@ -1006,7 +1005,12 @@ const getInitialValueForParameter = (parameter) => {
|
|
|
1006
1005
|
return '';
|
|
1007
1006
|
return getValueForParameter(parameter);
|
|
1008
1007
|
};
|
|
1009
|
-
const initialParameterValues =
|
|
1008
|
+
const initialParameterValues = params => {
|
|
1009
|
+
return _.chain(params)
|
|
1010
|
+
.keyBy((param) => param.name)
|
|
1011
|
+
.mapValues(param => getInitialValueForParameter(param))
|
|
1012
|
+
.value();
|
|
1013
|
+
};
|
|
1010
1014
|
function mapSchemaPropertiesToParameters(properties, required) {
|
|
1011
1015
|
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 }))));
|
|
1012
1016
|
}
|
|
@@ -2334,6 +2338,15 @@ const MarkdownComponentsProvider = ({ value, children }) => {
|
|
|
2334
2338
|
return React.createElement(MarkdownViewerProvider, { components: Object.assign({ code: CodeComponent }, value) }, children);
|
|
2335
2339
|
};
|
|
2336
2340
|
|
|
2341
|
+
const externalRegex = new RegExp('^(?:[a-z]+:)?//', 'i');
|
|
2342
|
+
const ReactRouterMarkdownLink = ({ title, href, children }) => {
|
|
2343
|
+
const isExternal = href !== undefined && externalRegex.test(href);
|
|
2344
|
+
if (isExternal) {
|
|
2345
|
+
return (React__default.createElement("a", { target: "_blank", rel: "noreferrer noopener", href: href, title: title }, children));
|
|
2346
|
+
}
|
|
2347
|
+
return (React__default.createElement(HashLink, { to: href, title: title }, children));
|
|
2348
|
+
};
|
|
2349
|
+
|
|
2337
2350
|
const NODE_TYPE_TITLE_ICON = {
|
|
2338
2351
|
http_service: faCloud,
|
|
2339
2352
|
};
|
|
@@ -2525,6 +2538,14 @@ function withPersistenceBoundary(WrappedComponent) {
|
|
|
2525
2538
|
|
|
2526
2539
|
function withMosaicProvider(WrappedComponent) {
|
|
2527
2540
|
const WithMosaicProvider = (props) => {
|
|
2541
|
+
try {
|
|
2542
|
+
const mosaicContext = useMosaicContext();
|
|
2543
|
+
if (mosaicContext === null || mosaicContext === void 0 ? void 0 : mosaicContext.providerId) {
|
|
2544
|
+
return React__default.createElement(WrappedComponent, Object.assign({}, props));
|
|
2545
|
+
}
|
|
2546
|
+
}
|
|
2547
|
+
catch (_a) {
|
|
2548
|
+
}
|
|
2528
2549
|
return (React__default.createElement(Provider$1, { style: { height: '100%' } },
|
|
2529
2550
|
React__default.createElement(WrappedComponent, Object.assign({}, props))));
|
|
2530
2551
|
};
|
|
@@ -2542,6 +2563,12 @@ const queryClient = new QueryClient({
|
|
|
2542
2563
|
});
|
|
2543
2564
|
function withQueryClientProvider(WrappedComponent) {
|
|
2544
2565
|
const WithQueryClientProvider = (props) => {
|
|
2566
|
+
try {
|
|
2567
|
+
useQueryClient();
|
|
2568
|
+
return React__default.createElement(WrappedComponent, Object.assign({}, props));
|
|
2569
|
+
}
|
|
2570
|
+
catch (_a) {
|
|
2571
|
+
}
|
|
2545
2572
|
return (React__default.createElement(QueryClientProvider, { client: queryClient },
|
|
2546
2573
|
React__default.createElement(WrappedComponent, Object.assign({}, props))));
|
|
2547
2574
|
};
|
|
@@ -2549,15 +2576,6 @@ function withQueryClientProvider(WrappedComponent) {
|
|
|
2549
2576
|
return WithQueryClientProvider;
|
|
2550
2577
|
}
|
|
2551
2578
|
|
|
2552
|
-
const externalRegex = new RegExp('^(?:[a-z]+:)?//', 'i');
|
|
2553
|
-
const ReactRouterMarkdownLink = ({ title, href, children }) => {
|
|
2554
|
-
const isExternal = href !== undefined && externalRegex.test(href);
|
|
2555
|
-
if (isExternal) {
|
|
2556
|
-
return (React__default.createElement("a", { target: "_blank", rel: "noreferrer noopener", href: href, title: title }, children));
|
|
2557
|
-
}
|
|
2558
|
-
return (React__default.createElement(HashLink, { to: href, title: title }, children));
|
|
2559
|
-
};
|
|
2560
|
-
|
|
2561
2579
|
const RouterComponent = {
|
|
2562
2580
|
history: BrowserRouter,
|
|
2563
2581
|
memory: MemoryRouter,
|
|
@@ -2654,7 +2672,7 @@ const createElementClass = (Component, propDescriptors) => {
|
|
|
2654
2672
|
constructor() {
|
|
2655
2673
|
super();
|
|
2656
2674
|
this._props = {};
|
|
2657
|
-
Object.defineProperties(this, mapValues
|
|
2675
|
+
Object.defineProperties(this, mapValues(propDescriptors, (_, key) => ({
|
|
2658
2676
|
get: () => {
|
|
2659
2677
|
return this._props[key];
|
|
2660
2678
|
},
|
|
@@ -2741,11 +2759,11 @@ const createElementClass = (Component, propDescriptors) => {
|
|
|
2741
2759
|
}
|
|
2742
2760
|
_renderComponent() {
|
|
2743
2761
|
if (this._mountPoint) {
|
|
2744
|
-
const props = mapValues
|
|
2762
|
+
const props = mapValues(propDescriptors, (descriptor, key) => { var _a; return (_a = this._props[key]) !== null && _a !== void 0 ? _a : descriptor.defaultValue; });
|
|
2745
2763
|
ReactDOM.render(React.createElement(Component, props), this._mountPoint);
|
|
2746
2764
|
}
|
|
2747
2765
|
}
|
|
2748
2766
|
};
|
|
2749
2767
|
};
|
|
2750
2768
|
|
|
2751
|
-
export { DeprecatedBadge, Docs, ExportButton, HttpMethodColors, InlineRefResolverProvider, Logo, MarkdownComponentsProvider, MockingProvider, NodeTypeColors, NodeTypeIconDefs, NodeTypePrettyName, NonIdealState, ParsedDocs, PersistenceContextProvider, PoweredByLink, SidebarLayout, Styled, TableOfContents, TryIt, TryItWithRequestSamples, createElementClass, createResolvedObject, findFirstNode, isHttpOperation, isHttpService, useBundleRefsIntoDocument, useParsedData, useParsedValue, useRouter, withMosaicProvider, withPersistenceBoundary, withQueryClientProvider, withRouter, withStyles };
|
|
2769
|
+
export { DeprecatedBadge, Docs, ExportButton, HttpMethodColors, InlineRefResolverProvider, Logo, MarkdownComponentsProvider, MockingProvider, NodeTypeColors, NodeTypeIconDefs, NodeTypePrettyName, NonIdealState, ParsedDocs, PersistenceContextProvider, PoweredByLink, ReactRouterMarkdownLink, SidebarLayout, Styled, TableOfContents, TryIt, TryItWithRequestSamples, createElementClass, createResolvedObject, findFirstNode, isHttpOperation, isHttpService, useBundleRefsIntoDocument, useParsedData, useParsedValue, useRouter, withMosaicProvider, withPersistenceBoundary, withQueryClientProvider, withRouter, withStyles };
|