@stoplight/elements-core 7.4.1 → 7.5.3
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/Article.stories.d.ts +1 -0
- package/components/Docs/HttpOperation/Body.d.ts +2 -1
- package/components/Docs/HttpOperation/Parameters.d.ts +0 -5
- package/components/Docs/Sections.d.ts +4 -1
- package/components/MosaicTableOfContents/types.d.ts +0 -1
- package/components/TryIt/Mocking/mocking-utils.d.ts +1 -2
- package/components/TryIt/Servers/ServersDropdown.d.ts +8 -0
- package/components/TryIt/build-request.d.ts +1 -1
- package/components/TryIt/chosenServer.d.ts +18 -0
- package/components/TryIt/index.d.ts +1 -0
- package/constants.d.ts +2 -0
- package/context/Persistence.d.ts +4 -1
- package/hooks/useRouter.d.ts +7 -5
- package/index.d.ts +1 -0
- package/index.esm.js +325 -212
- package/index.js +321 -210
- package/index.mjs +325 -212
- package/package.json +5 -5
- package/styles.min.css +1 -1
- package/types.d.ts +3 -1
- package/utils/http-spec/IServer.d.ts +1 -1
- package/utils/string.d.ts +1 -0
package/index.js
CHANGED
|
@@ -18,6 +18,7 @@ var freeSolidSvgIcons = require('@fortawesome/free-solid-svg-icons');
|
|
|
18
18
|
var throttle = require('lodash/throttle.js');
|
|
19
19
|
var unistUtilSelect = require('unist-util-select');
|
|
20
20
|
var cn = require('classnames');
|
|
21
|
+
var utils = require('jotai/utils');
|
|
21
22
|
var jotai = require('jotai');
|
|
22
23
|
var URI = require('urijs');
|
|
23
24
|
var mosaicCodeViewer = require('@stoplight/mosaic-code-viewer');
|
|
@@ -40,13 +41,9 @@ var uniq = require('lodash/uniq.js');
|
|
|
40
41
|
var orderBy = require('lodash/orderBy.js');
|
|
41
42
|
var uniqBy = require('lodash/uniqBy.js');
|
|
42
43
|
var formatXml = require('xml-formatter');
|
|
43
|
-
var utils = require('jotai/utils');
|
|
44
44
|
var entries = require('lodash/entries.js');
|
|
45
45
|
var keys = require('lodash/keys.js');
|
|
46
46
|
var jsonSchemaViewer = require('@stoplight/json-schema-viewer');
|
|
47
|
-
var get = require('lodash/get.js');
|
|
48
|
-
var isEmpty = require('lodash/isEmpty.js');
|
|
49
|
-
var omitBy = require('lodash/omitBy.js');
|
|
50
47
|
var sortBy = require('lodash/sortBy.js');
|
|
51
48
|
var reactRouterDom = require('react-router-dom');
|
|
52
49
|
var reactRouterHashLink = require('react-router-hash-link');
|
|
@@ -103,9 +100,6 @@ var uniqBy__default = /*#__PURE__*/_interopDefaultLegacy(uniqBy);
|
|
|
103
100
|
var formatXml__default = /*#__PURE__*/_interopDefaultLegacy(formatXml);
|
|
104
101
|
var entries__default = /*#__PURE__*/_interopDefaultLegacy(entries);
|
|
105
102
|
var keys__default = /*#__PURE__*/_interopDefaultLegacy(keys);
|
|
106
|
-
var get__default = /*#__PURE__*/_interopDefaultLegacy(get);
|
|
107
|
-
var isEmpty__default = /*#__PURE__*/_interopDefaultLegacy(isEmpty);
|
|
108
|
-
var omitBy__default = /*#__PURE__*/_interopDefaultLegacy(omitBy);
|
|
109
103
|
var sortBy__default = /*#__PURE__*/_interopDefaultLegacy(sortBy);
|
|
110
104
|
var $RefParser__default = /*#__PURE__*/_interopDefaultLegacy($RefParser);
|
|
111
105
|
var PropTypes__namespace = /*#__PURE__*/_interopNamespace(PropTypes);
|
|
@@ -328,7 +322,7 @@ const findTitle = (parent) => {
|
|
|
328
322
|
};
|
|
329
323
|
|
|
330
324
|
function useLocationHash() {
|
|
331
|
-
const isBrowser = typeof window !== undefined;
|
|
325
|
+
const isBrowser = typeof window !== 'undefined';
|
|
332
326
|
const [locationHash, setLocationHash] = React__namespace.useState(isBrowser && window.location.hash);
|
|
333
327
|
React__namespace.useEffect(() => {
|
|
334
328
|
if (!isBrowser)
|
|
@@ -355,9 +349,10 @@ const Headings = ({ headings, className, title = 'On This Page', minimal, maxWid
|
|
|
355
349
|
React__namespace.createElement(mosaic.Box, { as: mosaic.Icon, icon: freeSolidSvgIcons.faStream, mr: 2 }),
|
|
356
350
|
title)),
|
|
357
351
|
headings.map((heading, i) => (React__namespace.createElement(Heading, { key: i, item: heading, isSelected: locationHash === `#${heading.id}` })))));
|
|
352
|
+
const button = React__namespace.createElement(mosaic.Button, { pos: "sticky", size: "sm", borderColor: "light", icon: freeSolidSvgIcons.faStream, style: { top: 10 } });
|
|
358
353
|
if (minimal) {
|
|
359
|
-
return (React__namespace.createElement(mosaic.Box, { pos: "
|
|
360
|
-
React__namespace.createElement(mosaic.Popover, { renderTrigger:
|
|
354
|
+
return (React__namespace.createElement(mosaic.Box, { pos: "sticky", top: 0, right: 0, style: { top: 10 } },
|
|
355
|
+
React__namespace.createElement(mosaic.Popover, { renderTrigger: button, placement: "bottom" },
|
|
361
356
|
React__namespace.createElement(mosaic.Box, { className: className }, component))));
|
|
362
357
|
}
|
|
363
358
|
return (React__namespace.createElement(mosaic.Box, { pos: "sticky", pr: 4, pl: 16, h: "full", overflowX: "auto", overflowY: "auto", className: className, style: { top: 30 } },
|
|
@@ -379,20 +374,6 @@ const ArticleComponent = React__namespace.memo(({ data }) => {
|
|
|
379
374
|
});
|
|
380
375
|
const Article = reactErrorBoundary.withErrorBoundary(ArticleComponent, { recoverableProps: ['data'] });
|
|
381
376
|
|
|
382
|
-
const MockingContext = createNamedContext('MockingContext', { mockUrl: undefined, hideMocking: undefined });
|
|
383
|
-
const MockingProvider = ({ mockUrl, hideMocking, children }) => {
|
|
384
|
-
const info = {
|
|
385
|
-
mockUrl,
|
|
386
|
-
hideMocking: hideMocking || !mockUrl,
|
|
387
|
-
};
|
|
388
|
-
return React__namespace.createElement(MockingContext.Provider, { value: info }, children);
|
|
389
|
-
};
|
|
390
|
-
function createNamedContext(name, defaultValue) {
|
|
391
|
-
const context = React__namespace.createContext(defaultValue);
|
|
392
|
-
context.displayName = name;
|
|
393
|
-
return context;
|
|
394
|
-
}
|
|
395
|
-
|
|
396
377
|
const NodeTypeColors = {
|
|
397
378
|
http_operation: '#6a6acb',
|
|
398
379
|
http_service: '#e056fd',
|
|
@@ -509,10 +490,36 @@ const HttpCodeDescriptions = {
|
|
|
509
490
|
const badgeDefaultBackgroundColor = '#293742';
|
|
510
491
|
const badgeDefaultColor = '#FFFFFF';
|
|
511
492
|
|
|
512
|
-
const
|
|
513
|
-
|
|
514
|
-
|
|
493
|
+
const MockingContext = createNamedContext('MockingContext', { mockUrl: undefined, hideMocking: undefined });
|
|
494
|
+
const MockingProvider = ({ mockUrl, hideMocking, children }) => {
|
|
495
|
+
const info = {
|
|
496
|
+
mockUrl,
|
|
497
|
+
hideMocking: hideMocking || !mockUrl,
|
|
498
|
+
};
|
|
499
|
+
return React__namespace.createElement(MockingContext.Provider, { value: info }, children);
|
|
500
|
+
};
|
|
501
|
+
function createNamedContext(name, defaultValue) {
|
|
502
|
+
const context = React__namespace.createContext(defaultValue);
|
|
503
|
+
context.displayName = name;
|
|
504
|
+
return context;
|
|
505
|
+
}
|
|
506
|
+
|
|
507
|
+
const chosenServerAtom = jotai.atom(undefined);
|
|
508
|
+
|
|
509
|
+
const getServersToDisplay = (originalServers, mockUrl) => {
|
|
510
|
+
const servers = originalServers
|
|
511
|
+
.map((server, i) => {
|
|
512
|
+
const fallbackDescription = originalServers.length === 1 ? 'Live Server' : `Server ${i + 1}`;
|
|
513
|
+
return Object.assign(Object.assign({}, server), { url: getServerUrlWithDefaultValues(server), description: server.description || fallbackDescription });
|
|
514
|
+
})
|
|
515
515
|
.filter(server => isProperUrl(server.url));
|
|
516
|
+
if (mockUrl) {
|
|
517
|
+
servers.push({
|
|
518
|
+
description: 'Mock Server',
|
|
519
|
+
url: mockUrl,
|
|
520
|
+
});
|
|
521
|
+
}
|
|
522
|
+
return servers;
|
|
516
523
|
};
|
|
517
524
|
const getServerUrlWithDefaultValues = (server) => {
|
|
518
525
|
var _a;
|
|
@@ -525,7 +532,8 @@ const getServerUrlWithDefaultValues = (server) => {
|
|
|
525
532
|
if (url.is('relative') && typeof window !== 'undefined') {
|
|
526
533
|
url = url.absoluteTo(window.location.origin);
|
|
527
534
|
}
|
|
528
|
-
|
|
535
|
+
const stringifiedUrl = url.toString();
|
|
536
|
+
return stringifiedUrl.endsWith('/') ? stringifiedUrl.slice(0, -1) : stringifiedUrl;
|
|
529
537
|
};
|
|
530
538
|
|
|
531
539
|
const persistAtom = (key, atomInstance) => {
|
|
@@ -778,7 +786,12 @@ const RequestSamples = React__default["default"].memo(({ request, embeddedInMd =
|
|
|
778
786
|
" ",
|
|
779
787
|
selectedLibrary ? ` / ${selectedLibrary}` : '')) }))),
|
|
780
788
|
React__default["default"].createElement(mosaic.Panel.Content, { p: 0 },
|
|
781
|
-
React__default["default"].createElement(mosaicCodeViewer.CodeViewer, { "aria-label": requestSample !== null && requestSample !== void 0 ? requestSample : fallbackText, noCopyButton: true, maxHeight: "400px", language: mosaicCodeViewerLanguage, value: requestSample || fallbackText
|
|
789
|
+
React__default["default"].createElement(mosaicCodeViewer.CodeViewer, { "aria-label": requestSample !== null && requestSample !== void 0 ? requestSample : fallbackText, noCopyButton: true, maxHeight: "400px", language: mosaicCodeViewerLanguage, value: requestSample || fallbackText, style: embeddedInMd
|
|
790
|
+
? undefined
|
|
791
|
+
:
|
|
792
|
+
{
|
|
793
|
+
'--fs-code': 12,
|
|
794
|
+
} }))));
|
|
782
795
|
});
|
|
783
796
|
|
|
784
797
|
function getReadableSecurityName(securityScheme, includeKey = false) {
|
|
@@ -943,7 +956,14 @@ const SecuritySchemeComponent = (_a) => {
|
|
|
943
956
|
};
|
|
944
957
|
const securitySchemeKeys = ['apiKey', 'http', 'oauth2', 'openIdConnect'];
|
|
945
958
|
|
|
946
|
-
const caseInsensitivelyEquals = curry__default["default"]((a, b) => a.toUpperCase() === b.toUpperCase());
|
|
959
|
+
const caseInsensitivelyEquals = curry__default["default"]((a, b) => a.toUpperCase() === b.toUpperCase());
|
|
960
|
+
function slugify(name) {
|
|
961
|
+
return name
|
|
962
|
+
.replace(/\/|{|}|\s/g, '-')
|
|
963
|
+
.replace(/-{2,}/, '-')
|
|
964
|
+
.replace(/^-/, '')
|
|
965
|
+
.replace(/-$/, '');
|
|
966
|
+
}
|
|
947
967
|
|
|
948
968
|
const isApiKeySecurityScheme = (maybeIApiKey) => isObject__default["default"](maybeIApiKey) && maybeIApiKey.type === 'apiKey';
|
|
949
969
|
const isOAuth2SecurityScheme = (maybeIOAuth2) => isObject__default["default"](maybeIOAuth2) && maybeIOAuth2.type === 'oauth2';
|
|
@@ -1054,10 +1074,10 @@ function exampleValue(example) {
|
|
|
1054
1074
|
}
|
|
1055
1075
|
function getPlaceholderForParameter(parameter) {
|
|
1056
1076
|
var _a, _b;
|
|
1057
|
-
const parameterValue = getValueForParameter(parameter);
|
|
1077
|
+
const { value: parameterValue, isDefault } = getValueForParameter(parameter);
|
|
1058
1078
|
if (parameterValue)
|
|
1059
|
-
return
|
|
1060
|
-
return
|
|
1079
|
+
return `${isDefault ? 'defaults to' : 'example'}: ${parameterValue}`;
|
|
1080
|
+
return String((_b = (_a = parameter.schema) === null || _a === void 0 ? void 0 : _a.type) !== null && _b !== void 0 ? _b : '');
|
|
1061
1081
|
}
|
|
1062
1082
|
function retrieveDefaultFromSchema(parameter) {
|
|
1063
1083
|
var _a;
|
|
@@ -1066,22 +1086,25 @@ function retrieveDefaultFromSchema(parameter) {
|
|
|
1066
1086
|
}
|
|
1067
1087
|
const getValueForParameter = (parameter) => {
|
|
1068
1088
|
var _a, _b, _c;
|
|
1069
|
-
const examples = (_a = parameter.examples) !== null && _a !== void 0 ? _a : [];
|
|
1070
|
-
if (examples.length > 0)
|
|
1071
|
-
return exampleValue(examples[0]);
|
|
1072
1089
|
const defaultValue = retrieveDefaultFromSchema(parameter);
|
|
1073
|
-
if (defaultValue)
|
|
1074
|
-
return String(defaultValue);
|
|
1090
|
+
if (typeof defaultValue !== 'undefined') {
|
|
1091
|
+
return { value: String(defaultValue), isDefault: true };
|
|
1092
|
+
}
|
|
1093
|
+
const examples = (_a = parameter.examples) !== null && _a !== void 0 ? _a : [];
|
|
1094
|
+
if (examples.length > 0) {
|
|
1095
|
+
return { value: exampleValue(examples[0]) };
|
|
1096
|
+
}
|
|
1075
1097
|
const enums = (_c = (_b = parameter.schema) === null || _b === void 0 ? void 0 : _b.enum) !== null && _c !== void 0 ? _c : [];
|
|
1076
|
-
if (enums.length > 0)
|
|
1077
|
-
return String(enums[0]);
|
|
1078
|
-
|
|
1098
|
+
if (enums.length > 0) {
|
|
1099
|
+
return { value: String(enums[0]) };
|
|
1100
|
+
}
|
|
1101
|
+
return { value: '' };
|
|
1079
1102
|
};
|
|
1080
1103
|
const getInitialValueForParameter = (parameter) => {
|
|
1081
1104
|
const isRequired = !!parameter.required;
|
|
1082
1105
|
if (!isRequired)
|
|
1083
1106
|
return '';
|
|
1084
|
-
return getValueForParameter(parameter);
|
|
1107
|
+
return getValueForParameter(parameter).value;
|
|
1085
1108
|
};
|
|
1086
1109
|
const initialParameterValues = params => {
|
|
1087
1110
|
const paramsByName = keyBy__default["default"](params, (param) => param.name);
|
|
@@ -1226,7 +1249,9 @@ const RequestBody = ({ examples, requestBody, onChange }) => {
|
|
|
1226
1249
|
return (React__namespace.createElement(mosaic.Panel, { defaultIsOpen: true },
|
|
1227
1250
|
React__namespace.createElement(mosaic.Panel.Titlebar, { rightComponent: examples.length > 1 && React__namespace.createElement(ExampleMenu, { examples: examples, requestBody: requestBody, onChange: onChange }) }, "Body"),
|
|
1228
1251
|
React__namespace.createElement(mosaic.Panel.Content, { className: "TextRequestBody" },
|
|
1229
|
-
React__namespace.createElement(mosaicCodeEditor.CodeEditor, { onChange: onChange, language: "json", value: requestBody, showLineNumbers: true, padding: 0
|
|
1252
|
+
React__namespace.createElement(mosaicCodeEditor.CodeEditor, { onChange: onChange, language: "json", value: requestBody, showLineNumbers: true, padding: 0, style: {
|
|
1253
|
+
fontSize: 12,
|
|
1254
|
+
} }))));
|
|
1230
1255
|
};
|
|
1231
1256
|
function ExampleMenu({ examples, requestBody, onChange }) {
|
|
1232
1257
|
const handleClick = React__namespace.useCallback((example) => {
|
|
@@ -1484,8 +1509,8 @@ const formatMultiValueHeader = (...keyValuePairs) => {
|
|
|
1484
1509
|
.join(', ');
|
|
1485
1510
|
};
|
|
1486
1511
|
|
|
1487
|
-
function getMockData(url, httpOperation, {
|
|
1488
|
-
return
|
|
1512
|
+
function getMockData(url, httpOperation, { code, dynamic, example }) {
|
|
1513
|
+
return url ? { url, header: buildPreferHeader({ code, dynamic, example }, httpOperation) } : undefined;
|
|
1489
1514
|
}
|
|
1490
1515
|
function buildPreferHeader({ code, example, dynamic }, httpOperation) {
|
|
1491
1516
|
if (!code) {
|
|
@@ -1518,23 +1543,14 @@ function supportsExample(httpOperation, code, exampleKey) {
|
|
|
1518
1543
|
return exampleKeys.includes(exampleKey);
|
|
1519
1544
|
}
|
|
1520
1545
|
|
|
1521
|
-
const MockingButton = ({ operation, options: {
|
|
1522
|
-
const toggleEnabled = React__namespace.useCallback(() => {
|
|
1523
|
-
onOptionsChange({ isEnabled: !isEnabled });
|
|
1524
|
-
}, [isEnabled, onOptionsChange]);
|
|
1546
|
+
const MockingButton = ({ operation, options: { code, example, dynamic }, onOptionsChange, }) => {
|
|
1525
1547
|
const operationResponses = operation.responses;
|
|
1526
1548
|
const setMockingOptions = React__namespace.useCallback(({ code, example, dynamic }) => {
|
|
1527
|
-
onOptionsChange({
|
|
1528
|
-
}, [
|
|
1549
|
+
onOptionsChange({ code, example, dynamic });
|
|
1550
|
+
}, [onOptionsChange]);
|
|
1529
1551
|
const menuItems = React__namespace.useMemo(() => {
|
|
1530
1552
|
var _a;
|
|
1531
|
-
const items =
|
|
1532
|
-
{ id: 'mocking-enabled', title: 'Enabled', isChecked: isEnabled, onPress: toggleEnabled },
|
|
1533
|
-
{
|
|
1534
|
-
type: 'group',
|
|
1535
|
-
children: (_a = operationResponses === null || operationResponses === void 0 ? void 0 : operationResponses.filter(operationResponse => Number.isInteger(parseFloat(operationResponse.code)))) === null || _a === void 0 ? void 0 : _a.map(generateOperationResponseMenu),
|
|
1536
|
-
},
|
|
1537
|
-
];
|
|
1553
|
+
const items = (_a = operationResponses === null || operationResponses === void 0 ? void 0 : operationResponses.filter(operationResponse => Number.isInteger(parseFloat(operationResponse.code)))) === null || _a === void 0 ? void 0 : _a.map(generateOperationResponseMenu);
|
|
1538
1554
|
function generateOperationResponseMenu(operationResponse) {
|
|
1539
1555
|
var _a;
|
|
1540
1556
|
const menuId = `response-${operationResponse.code}`;
|
|
@@ -1568,7 +1584,6 @@ const MockingButton = ({ operation, options: { isEnabled, code, example, dynamic
|
|
|
1568
1584
|
];
|
|
1569
1585
|
const menuItem = {
|
|
1570
1586
|
id: menuId,
|
|
1571
|
-
isDisabled: !isEnabled,
|
|
1572
1587
|
isChecked: isActive,
|
|
1573
1588
|
title: operationResponse.code,
|
|
1574
1589
|
onPress: () => {
|
|
@@ -1582,13 +1597,13 @@ const MockingButton = ({ operation, options: { isEnabled, code, example, dynamic
|
|
|
1582
1597
|
return menuItem;
|
|
1583
1598
|
}
|
|
1584
1599
|
return items;
|
|
1585
|
-
}, [code, dynamic, example,
|
|
1600
|
+
}, [code, dynamic, example, operationResponses, setMockingOptions]);
|
|
1586
1601
|
return (React__namespace.createElement(mosaic.Box, null,
|
|
1587
|
-
React__namespace.createElement(mosaic.Menu, { "aria-label": "
|
|
1602
|
+
React__namespace.createElement(mosaic.Menu, { "aria-label": "Mock settings", items: menuItems, renderTrigger: ({ isOpen }) => (React__namespace.createElement(mosaic.FieldButton, { active: isOpen, size: "sm" }, "Mock Settings")) })));
|
|
1588
1603
|
};
|
|
1589
1604
|
|
|
1590
|
-
const
|
|
1591
|
-
const useMockingOptions = () => jotai.useAtom(
|
|
1605
|
+
const mockingOptionsAtom = jotai.atom({});
|
|
1606
|
+
const useMockingOptions = () => jotai.useAtom(mockingOptionsAtom);
|
|
1592
1607
|
|
|
1593
1608
|
const OperationParameters = ({ parameters, values, onChangeValue, validate, }) => {
|
|
1594
1609
|
return (React__namespace.createElement(mosaic.Panel, { defaultIsOpen: true },
|
|
@@ -1717,7 +1732,32 @@ class NetworkError extends Error {
|
|
|
1717
1732
|
}
|
|
1718
1733
|
const isNetworkError = (error) => error instanceof NetworkError;
|
|
1719
1734
|
|
|
1720
|
-
const
|
|
1735
|
+
const ServersDropdown = ({ servers }) => {
|
|
1736
|
+
const [chosenServer, setChosenServer] = jotai.useAtom(chosenServerAtom);
|
|
1737
|
+
const serverItems = [
|
|
1738
|
+
{
|
|
1739
|
+
type: 'option_group',
|
|
1740
|
+
title: 'Servers',
|
|
1741
|
+
value: (chosenServer === null || chosenServer === void 0 ? void 0 : chosenServer.url) || '',
|
|
1742
|
+
onChange: url => {
|
|
1743
|
+
const server = servers.find(server => server.url === url);
|
|
1744
|
+
setChosenServer(server);
|
|
1745
|
+
},
|
|
1746
|
+
children: [
|
|
1747
|
+
...servers.map((server, i) => ({
|
|
1748
|
+
id: server.url,
|
|
1749
|
+
title: server.name || server.description,
|
|
1750
|
+
description: server.name ? server.description || server.url : server.description ? server.url : undefined,
|
|
1751
|
+
value: server.url,
|
|
1752
|
+
})),
|
|
1753
|
+
],
|
|
1754
|
+
},
|
|
1755
|
+
];
|
|
1756
|
+
return (React__namespace.createElement(mosaic.Menu, { "aria-label": "Server", items: serverItems, closeOnPress: true, renderTrigger: ({ isOpen }) => (React__namespace.createElement(mosaic.FieldButton, { icon: freeSolidSvgIcons.faServer, size: "sm", active: isOpen }, (chosenServer === null || chosenServer === void 0 ? void 0 : chosenServer.name) || (chosenServer === null || chosenServer === void 0 ? void 0 : chosenServer.description) || 'Server')) }));
|
|
1757
|
+
};
|
|
1758
|
+
ServersDropdown.displayName = 'ServersDropdown';
|
|
1759
|
+
|
|
1760
|
+
const defaultServers = [];
|
|
1721
1761
|
const TryIt = ({ httpOperation, mockUrl, onRequestChange, requestBodyIndex, embeddedInMd = false, tryItCredentialsPolicy, corsProxy, }) => {
|
|
1722
1762
|
var _a, _b, _c, _d, _e, _f, _g;
|
|
1723
1763
|
const isDark = mosaic.useThemeIsDark();
|
|
@@ -1731,18 +1771,28 @@ const TryIt = ({ httpOperation, mockUrl, onRequestChange, requestBodyIndex, embe
|
|
|
1731
1771
|
const [bodyParameterValues, setBodyParameterValues, formDataState] = useBodyParameterState(mediaTypeContent);
|
|
1732
1772
|
const [textRequestBody, setTextRequestBody] = useTextRequestBodyState(mediaTypeContent);
|
|
1733
1773
|
const [operationAuthValue, setOperationAuthValue] = usePersistedSecuritySchemeWithValues();
|
|
1734
|
-
const servers =
|
|
1774
|
+
const servers = React__namespace.useMemo(() => {
|
|
1775
|
+
const toDisplay = getServersToDisplay(httpOperation.servers || defaultServers, mockUrl);
|
|
1776
|
+
return toDisplay;
|
|
1777
|
+
}, [httpOperation.servers, mockUrl]);
|
|
1778
|
+
const firstServer = servers[0] || null;
|
|
1735
1779
|
const [chosenServer, setChosenServer] = jotai.useAtom(chosenServerAtom);
|
|
1780
|
+
const isMockingEnabled = mockUrl && (chosenServer === null || chosenServer === void 0 ? void 0 : chosenServer.url) === mockUrl;
|
|
1736
1781
|
const hasRequiredButEmptyParameters = allParameters.some(parameter => parameter.required && !parameterValuesWithDefaults[parameter.name]);
|
|
1737
1782
|
React__namespace.useEffect(() => {
|
|
1738
|
-
|
|
1739
|
-
|
|
1783
|
+
const currentUrl = chosenServer === null || chosenServer === void 0 ? void 0 : chosenServer.url;
|
|
1784
|
+
const exists = currentUrl && servers.find(s => s.url === currentUrl);
|
|
1785
|
+
if (!exists) {
|
|
1786
|
+
setChosenServer(firstServer);
|
|
1740
1787
|
}
|
|
1741
|
-
|
|
1788
|
+
else if (exists !== chosenServer) {
|
|
1789
|
+
setChosenServer(exists);
|
|
1790
|
+
}
|
|
1791
|
+
}, [servers, firstServer, chosenServer, setChosenServer]);
|
|
1742
1792
|
React__namespace.useEffect(() => {
|
|
1743
1793
|
let isMounted = true;
|
|
1744
1794
|
if (onRequestChange || embeddedInMd) {
|
|
1745
|
-
buildHarRequest(Object.assign(Object.assign({ mediaTypeContent, parameterValues: parameterValuesWithDefaults, httpOperation, bodyInput: formDataState.isFormDataBody ? bodyParameterValues : textRequestBody, auth: operationAuthValue }, (
|
|
1795
|
+
buildHarRequest(Object.assign(Object.assign({ mediaTypeContent, parameterValues: parameterValuesWithDefaults, httpOperation, bodyInput: formDataState.isFormDataBody ? bodyParameterValues : textRequestBody, auth: operationAuthValue }, (isMockingEnabled && { mockData: getMockData(mockUrl, httpOperation, mockingOptions) })), { chosenServer,
|
|
1746
1796
|
corsProxy })).then(request => {
|
|
1747
1797
|
if (isMounted) {
|
|
1748
1798
|
if (onRequestChange) {
|
|
@@ -1769,13 +1819,13 @@ const TryIt = ({ httpOperation, mockUrl, onRequestChange, requestBodyIndex, embe
|
|
|
1769
1819
|
corsProxy,
|
|
1770
1820
|
embeddedInMd,
|
|
1771
1821
|
]);
|
|
1772
|
-
const
|
|
1822
|
+
const handleSendRequest = () => tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
1773
1823
|
setValidateParameters(true);
|
|
1774
1824
|
if (hasRequiredButEmptyParameters)
|
|
1775
1825
|
return;
|
|
1776
1826
|
try {
|
|
1777
1827
|
setLoading(true);
|
|
1778
|
-
const mockData = getMockData(mockUrl, httpOperation, mockingOptions);
|
|
1828
|
+
const mockData = isMockingEnabled ? getMockData(mockUrl, httpOperation, mockingOptions) : undefined;
|
|
1779
1829
|
const request = yield buildFetchRequest({
|
|
1780
1830
|
parameterValues: parameterValuesWithDefaults,
|
|
1781
1831
|
httpOperation,
|
|
@@ -1812,29 +1862,32 @@ const TryIt = ({ httpOperation, mockUrl, onRequestChange, requestBodyIndex, embe
|
|
|
1812
1862
|
setLoading(false);
|
|
1813
1863
|
}
|
|
1814
1864
|
});
|
|
1815
|
-
const
|
|
1816
|
-
|
|
1817
|
-
|
|
1818
|
-
|
|
1819
|
-
|
|
1820
|
-
|
|
1821
|
-
|
|
1865
|
+
const isOnlySendButton = !((_d = httpOperation.security) === null || _d === void 0 ? void 0 : _d.length) && !allParameters.length && !formDataState.isFormDataBody && !mediaTypeContent;
|
|
1866
|
+
const tryItPanelContents = (React__namespace.createElement(React__namespace.Fragment, null,
|
|
1867
|
+
((_e = httpOperation.security) === null || _e === void 0 ? void 0 : _e.length) ? (React__namespace.createElement(TryItAuth, { onChange: setOperationAuthValue, operationSecurityScheme: (_f = httpOperation.security) !== null && _f !== void 0 ? _f : [], value: operationAuthValue })) : null,
|
|
1868
|
+
allParameters.length > 0 && (React__namespace.createElement(OperationParameters, { parameters: allParameters, values: parameterValuesWithDefaults, onChangeValue: updateParameterValue, validate: validateParameters })),
|
|
1869
|
+
formDataState.isFormDataBody ? (React__namespace.createElement(FormDataBody, { specification: formDataState.bodySpecification, values: bodyParameterValues, onChangeValues: setBodyParameterValues })) : mediaTypeContent ? (React__namespace.createElement(RequestBody, { examples: (_g = mediaTypeContent.examples) !== null && _g !== void 0 ? _g : [], requestBody: textRequestBody, onChange: setTextRequestBody })) : null,
|
|
1870
|
+
React__namespace.createElement(mosaic.Panel.Content, { className: "SendButtonHolder", mt: 4, pt: !isOnlySendButton && !embeddedInMd ? 0 : undefined },
|
|
1871
|
+
React__namespace.createElement(mosaic.HStack, { alignItems: "center", spacing: 2 },
|
|
1872
|
+
React__namespace.createElement(mosaic.Button, { appearance: "primary", loading: loading, disabled: loading, onPress: handleSendRequest, size: "sm" }, "Send API Request"),
|
|
1873
|
+
servers.length > 1 && React__namespace.createElement(ServersDropdown, { servers: servers }),
|
|
1874
|
+
isMockingEnabled && (React__namespace.createElement(MockingButton, { options: mockingOptions, onOptionsChange: setMockingOptions, operation: httpOperation }))),
|
|
1875
|
+
validateParameters && hasRequiredButEmptyParameters && (React__namespace.createElement(mosaic.Box, { mt: 4, color: "danger-light", fontSize: "sm" },
|
|
1876
|
+
React__namespace.createElement(mosaic.Icon, { icon: freeSolidSvgIcons.faExclamationTriangle, className: "sl-mr-1" }),
|
|
1877
|
+
"You didn't provide all of the required parameters!")))));
|
|
1878
|
+
let tryItPanelElem;
|
|
1879
|
+
if (embeddedInMd) {
|
|
1880
|
+
tryItPanelElem = (React__namespace.createElement(mosaic.Panel, { isCollapsible: false, p: 0, className: "TryItPanel" },
|
|
1881
|
+
React__namespace.createElement(mosaic.Panel.Titlebar, { bg: "canvas-300" },
|
|
1882
|
+
React__namespace.createElement(mosaic.Box, { fontWeight: "bold", color: !isDark ? HttpMethodColors[httpOperation.method] : undefined }, httpOperation.method.toUpperCase()),
|
|
1883
|
+
React__namespace.createElement(mosaic.Box, { fontWeight: "medium", ml: 2, textOverflow: "truncate", overflowX: "hidden" }, `${(chosenServer === null || chosenServer === void 0 ? void 0 : chosenServer.url) || ''}${httpOperation.path}`)),
|
|
1884
|
+
tryItPanelContents));
|
|
1885
|
+
}
|
|
1886
|
+
else {
|
|
1887
|
+
tryItPanelElem = (React__namespace.createElement(mosaic.Box, { className: "TryItPanel", bg: "canvas-100", rounded: "lg" }, tryItPanelContents));
|
|
1888
|
+
}
|
|
1822
1889
|
return (React__namespace.createElement(mosaic.Box, { rounded: "lg", overflowY: "hidden" },
|
|
1823
|
-
|
|
1824
|
-
React__namespace.createElement(mosaic.Panel.Titlebar, { rightComponent: servers.length > 1 ? serversSelect : serverDescription, bg: "canvas-300" },
|
|
1825
|
-
React__namespace.createElement("div", { role: "heading", className: "sl-font-bold" },
|
|
1826
|
-
React__namespace.createElement(mosaic.Text, { color: !isDark ? HttpMethodColors[httpOperation.method] : undefined }, httpOperation.method.toUpperCase()),
|
|
1827
|
-
React__namespace.createElement(mosaic.Text, { ml: 2 }, httpOperation.path))),
|
|
1828
|
-
React__namespace.createElement(TryItAuth, { onChange: setOperationAuthValue, operationSecurityScheme: (_f = httpOperation.security) !== null && _f !== void 0 ? _f : [], value: operationAuthValue }),
|
|
1829
|
-
allParameters.length > 0 && (React__namespace.createElement(OperationParameters, { parameters: allParameters, values: parameterValuesWithDefaults, onChangeValue: updateParameterValue, validate: validateParameters })),
|
|
1830
|
-
formDataState.isFormDataBody ? (React__namespace.createElement(FormDataBody, { specification: formDataState.bodySpecification, values: bodyParameterValues, onChangeValues: setBodyParameterValues })) : mediaTypeContent ? (React__namespace.createElement(RequestBody, { examples: (_g = mediaTypeContent.examples) !== null && _g !== void 0 ? _g : [], requestBody: textRequestBody, onChange: setTextRequestBody })) : null,
|
|
1831
|
-
React__namespace.createElement(mosaic.Panel.Content, { className: "SendButtonHolder" },
|
|
1832
|
-
React__namespace.createElement(mosaic.Flex, { alignItems: "center" },
|
|
1833
|
-
React__namespace.createElement(mosaic.Button, { appearance: "primary", loading: loading, disabled: loading, onPress: handleClick, size: "sm" }, "Send Request"),
|
|
1834
|
-
mockUrl && (React__namespace.createElement(MockingButton, { options: mockingOptions, onOptionsChange: setMockingOptions, operation: httpOperation }))),
|
|
1835
|
-
validateParameters && hasRequiredButEmptyParameters && (React__namespace.createElement(mosaic.Box, { mt: 4, color: "danger-light", fontSize: "sm" },
|
|
1836
|
-
React__namespace.createElement(mosaic.Icon, { icon: freeSolidSvgIcons.faExclamationTriangle, className: "sl-mr-1" }),
|
|
1837
|
-
"You didn't provide all of the required parameters!")))),
|
|
1890
|
+
tryItPanelElem,
|
|
1838
1891
|
requestData && embeddedInMd && React__namespace.createElement(RequestSamples, { request: requestData, embeddedInMd: true }),
|
|
1839
1892
|
response && !('error' in response) && React__namespace.createElement(TryItResponse, { response: response }),
|
|
1840
1893
|
response && 'error' in response && React__namespace.createElement(ResponseError, { state: response })));
|
|
@@ -1871,7 +1924,9 @@ const ResponseExamples = ({ httpOperation, responseMediaType, responseStatusCode
|
|
|
1871
1924
|
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: " }));
|
|
1872
1925
|
return (React__default["default"].createElement(mosaic.Panel, { rounded: true, isCollapsible: false },
|
|
1873
1926
|
React__default["default"].createElement(mosaic.Panel.Titlebar, null, examplesSelect || React__default["default"].createElement(mosaic.Text, { color: "body" }, "Response Example")),
|
|
1874
|
-
React__default["default"].createElement(mosaic.Panel.Content, { p: 0 }, show || !exceedsSize(responseExample) ? (React__default["default"].createElement(mosaicCodeViewer.CodeViewer, { "aria-label": responseExample, noCopyButton: true, maxHeight: "
|
|
1927
|
+
React__default["default"].createElement(mosaic.Panel.Content, { p: 0 }, show || !exceedsSize(responseExample) ? (React__default["default"].createElement(mosaicCodeViewer.CodeViewer, { "aria-label": responseExample, noCopyButton: true, maxHeight: "500px", language: "json", value: responseExample, showLineNumbers: true, style: {
|
|
1928
|
+
'--fs-code': 12,
|
|
1929
|
+
} })) : (React__default["default"].createElement(LoadMore, { loading: loading, onClick: handleLoadMore })))));
|
|
1875
1930
|
};
|
|
1876
1931
|
|
|
1877
1932
|
const TryItWithRequestSamples = (_a) => {
|
|
@@ -1885,14 +1940,14 @@ const TryItWithRequestSamples = (_a) => {
|
|
|
1885
1940
|
React__namespace.createElement(ResponseExamples, Object.assign({}, props))));
|
|
1886
1941
|
};
|
|
1887
1942
|
|
|
1888
|
-
const TwoColumnLayout = ({ header, right, left, className }) => (React__default["default"].createElement(mosaic.
|
|
1943
|
+
const TwoColumnLayout = ({ header, right, left, className }) => (React__default["default"].createElement(mosaic.VStack, { w: "full", className: className, spacing: 8 },
|
|
1889
1944
|
header,
|
|
1890
|
-
React__default["default"].createElement(mosaic.Flex,
|
|
1945
|
+
React__default["default"].createElement(mosaic.Flex, null,
|
|
1891
1946
|
React__default["default"].createElement(mosaic.Box, { w: 0, flex: 1 }, left),
|
|
1892
1947
|
right && (React__default["default"].createElement(mosaic.Box, { ml: 16, pos: "relative", w: "2/5", style: { maxWidth: 500 } }, right)))));
|
|
1893
1948
|
|
|
1894
1949
|
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."));
|
|
1895
|
-
const InternalBadge = ({ isHttpService }) => (React__default["default"].createElement(mosaic.Tooltip, { renderTrigger: React__default["default"].createElement(mosaic.Badge, { icon: freeSolidSvgIcons.faEye, "data-testid": "badge-internal", bg: "danger"
|
|
1950
|
+
const InternalBadge = ({ isHttpService }) => (React__default["default"].createElement(mosaic.Tooltip, { renderTrigger: React__default["default"].createElement(mosaic.Badge, { icon: freeSolidSvgIcons.faEye, "data-testid": "badge-internal", bg: "danger" }, "Internal") }, `This ${isHttpService ? 'operation' : 'model'} is marked as internal and won't be visible in public docs.`));
|
|
1896
1951
|
const VersionBadge = ({ value, backgroundColor }) => (React__default["default"].createElement(mosaic.Badge, { appearance: "solid", size: "sm", border: 0, style: {
|
|
1897
1952
|
backgroundColor: backgroundColor || badgeDefaultBackgroundColor,
|
|
1898
1953
|
color: badgeDefaultColor,
|
|
@@ -1972,32 +2027,43 @@ ${scopes.map(([key, value]) => `- \`${key}\` - ${value}`).join('\n')}`;
|
|
|
1972
2027
|
return description;
|
|
1973
2028
|
}
|
|
1974
2029
|
|
|
1975
|
-
const SectionTitle = ({ title, children }) => {
|
|
1976
|
-
return (React__namespace.createElement(mosaic.
|
|
1977
|
-
React__namespace.createElement(mosaic.
|
|
2030
|
+
const SectionTitle = ({ title, id, size = 2, children }) => {
|
|
2031
|
+
return (React__namespace.createElement(mosaic.HStack, { spacing: 6 },
|
|
2032
|
+
React__namespace.createElement(mosaic.Box, { as: mosaic.LinkHeading, size: size, "aria-label": title, id: id || slugify(title) }, title),
|
|
1978
2033
|
children));
|
|
1979
2034
|
};
|
|
2035
|
+
const SectionSubtitle = props => {
|
|
2036
|
+
return React__namespace.createElement(SectionTitle, Object.assign({}, props, { size: 3 }));
|
|
2037
|
+
};
|
|
1980
2038
|
const SubSectionPanel = ({ title, children, hasContent, rightComponent, defaultIsOpen = true, onChange, }) => {
|
|
1981
|
-
return (React__namespace.createElement(mosaic.Panel, {
|
|
2039
|
+
return (React__namespace.createElement(mosaic.Panel, { isCollapsible: hasContent, defaultIsOpen: defaultIsOpen, onChange: onChange, appearance: "outlined" },
|
|
1982
2040
|
React__namespace.createElement(mosaic.Panel.Titlebar, { fontWeight: "medium", rightComponent: rightComponent },
|
|
1983
2041
|
React__namespace.createElement("div", { role: "heading" }, title)),
|
|
1984
|
-
hasContent !== false &&
|
|
2042
|
+
hasContent !== false && React__namespace.createElement(mosaic.Panel.Content, null, children)));
|
|
1985
2043
|
};
|
|
1986
2044
|
|
|
1987
|
-
const
|
|
2045
|
+
const isBodyEmpty = (body) => {
|
|
2046
|
+
if (!body)
|
|
2047
|
+
return true;
|
|
2048
|
+
const { contents = [], description } = body;
|
|
2049
|
+
return contents.length === 0 && !(description === null || description === void 0 ? void 0 : description.trim());
|
|
2050
|
+
};
|
|
2051
|
+
const Body = ({ body, onChange }) => {
|
|
1988
2052
|
var _a;
|
|
1989
2053
|
const refResolver = useInlineRefResolver();
|
|
1990
2054
|
const [chosenContent, setChosenContent] = React__namespace.useState(0);
|
|
1991
2055
|
React__namespace.useEffect(() => {
|
|
1992
2056
|
onChange(chosenContent);
|
|
1993
2057
|
}, [chosenContent]);
|
|
1994
|
-
if (
|
|
2058
|
+
if (isBodyEmpty(body))
|
|
1995
2059
|
return null;
|
|
2060
|
+
const { contents = [], description } = body;
|
|
1996
2061
|
const schema = (_a = contents[chosenContent]) === null || _a === void 0 ? void 0 : _a.schema;
|
|
1997
|
-
return (React__namespace.createElement(
|
|
1998
|
-
|
|
1999
|
-
|
|
2000
|
-
|
|
2062
|
+
return (React__namespace.createElement(mosaic.VStack, { spacing: 6 },
|
|
2063
|
+
React__namespace.createElement(SectionSubtitle, { title: "Body", id: "request-body" }, contents.length > 0 && (React__namespace.createElement(mosaic.Flex, { flex: 1, justify: "end" },
|
|
2064
|
+
React__namespace.createElement(mosaic.Select, { "aria-label": "Request Body Content Type", value: String(chosenContent), onChange: (value) => setChosenContent(parseInt(String(value), 10)), options: contents.map((content, index) => ({ label: content.mediaType, value: index })), size: "sm" })))),
|
|
2065
|
+
description && React__namespace.createElement(MarkdownViewer, { markdown: description }),
|
|
2066
|
+
isJSONSchema(schema) && (React__namespace.createElement(jsonSchemaViewer.JsonSchemaViewer, { resolveRef: refResolver, schema: getOriginalObject(schema), viewMode: "write", hideExamples: true, renderRootTreeLines: true }))));
|
|
2001
2067
|
};
|
|
2002
2068
|
Body.displayName = 'HttpOperation.Body';
|
|
2003
2069
|
|
|
@@ -2021,66 +2087,71 @@ const defaultStyle = {
|
|
|
2021
2087
|
cookie: types.HttpParamStyles.Form,
|
|
2022
2088
|
};
|
|
2023
2089
|
const Parameters = ({ parameters, parameterType }) => {
|
|
2024
|
-
|
|
2090
|
+
const schema = React__namespace.useMemo(() => httpOperationParamsToSchema({ parameters, parameterType }), [parameters, parameterType]);
|
|
2091
|
+
if (!schema)
|
|
2025
2092
|
return null;
|
|
2026
|
-
return
|
|
2027
|
-
return React__namespace.createElement(Parameter, { key: parameter.name, parameter: parameter, parameterType: parameterType });
|
|
2028
|
-
})));
|
|
2093
|
+
return React__namespace.createElement(jsonSchemaViewer.JsonSchemaViewer, { schema: schema, disableCrumbs: true });
|
|
2029
2094
|
};
|
|
2030
2095
|
Parameters.displayName = 'HttpOperation.Parameters';
|
|
2031
|
-
const
|
|
2032
|
-
var _a
|
|
2033
|
-
if (!
|
|
2096
|
+
const httpOperationParamsToSchema = ({ parameters, parameterType }) => {
|
|
2097
|
+
var _a;
|
|
2098
|
+
if (!parameters || !parameters.length)
|
|
2034
2099
|
return null;
|
|
2035
|
-
const
|
|
2036
|
-
|
|
2037
|
-
|
|
2038
|
-
|
|
2039
|
-
const
|
|
2040
|
-
const
|
|
2041
|
-
if (
|
|
2042
|
-
|
|
2100
|
+
const schema = {
|
|
2101
|
+
properties: {},
|
|
2102
|
+
required: [],
|
|
2103
|
+
};
|
|
2104
|
+
const sortedParams = sortBy__default["default"](parameters, ['required', 'name']);
|
|
2105
|
+
for (const p of sortedParams) {
|
|
2106
|
+
if (!p.schema)
|
|
2107
|
+
continue;
|
|
2108
|
+
const { name, description, required, deprecated, examples, style } = p;
|
|
2109
|
+
const paramExamples = (examples === null || examples === void 0 ? void 0 : examples.map(example => {
|
|
2110
|
+
if (isNodeExample(example)) {
|
|
2111
|
+
return example.value;
|
|
2112
|
+
}
|
|
2113
|
+
return example.externalValue;
|
|
2114
|
+
})) || [];
|
|
2115
|
+
const schemaExamples = (_a = p.schema) === null || _a === void 0 ? void 0 : _a.examples;
|
|
2116
|
+
const schemaExamplesArray = Array.isArray(schemaExamples) ? schemaExamples : [];
|
|
2117
|
+
const paramDescription = description || p.schema.description;
|
|
2118
|
+
const paramDeprecated = deprecated || p.schema.deprecated;
|
|
2119
|
+
const paramStyle = style && defaultStyle[parameterType] !== style ? readableStyles[style] || style : undefined;
|
|
2120
|
+
schema.properties[p.name] = Object.assign(Object.assign({}, p.schema), { description: paramDescription, examples: [...paramExamples, ...schemaExamplesArray], deprecated: paramDeprecated, style: paramStyle });
|
|
2121
|
+
if (required) {
|
|
2122
|
+
schema.required.push(name);
|
|
2043
2123
|
}
|
|
2044
|
-
|
|
2045
|
-
|
|
2046
|
-
|
|
2047
|
-
const schemaExamplesArray = Array.isArray(schemaExamples) ? schemaExamples : [];
|
|
2048
|
-
const validations = omitBy__default["default"](Object.assign(Object.assign(Object.assign(Object.assign({}, omit__default["default"](parameter, ['name', 'required', 'deprecated', 'description', 'schema', 'style', 'examples'])), omit__default["default"](get__default["default"](parameter, 'schema'), ['description', 'type', 'deprecated'])), omit__default["default"](get__default["default"](parameter, 'schema.items'), ['description', 'type', 'deprecated'])), { examples: [...parameterExamples, ...schemaExamplesArray] }), value => (typeof value === 'object' && isEmpty__default["default"](value)) || typeof value === 'undefined');
|
|
2049
|
-
return (React__namespace.createElement(mosaic.Box, { className: "HttpOperation__Parameters" },
|
|
2050
|
-
React__namespace.createElement(mosaic.Flex, { alignItems: "center", my: 2 },
|
|
2051
|
-
React__namespace.createElement(mosaic.Flex, { alignItems: "baseline", fontSize: "base", flex: 1 },
|
|
2052
|
-
React__namespace.createElement(mosaic.Box, { fontFamily: "mono", fontWeight: "bold" }, parameter.name),
|
|
2053
|
-
React__namespace.createElement(mosaic.Box, { ml: 2, color: "muted" }, format ? `${type}<${format}>` : type)),
|
|
2054
|
-
React__namespace.createElement(mosaic.Box, { fontSize: "sm", color: "warning" },
|
|
2055
|
-
deprecated && (React__namespace.createElement(mosaic.Box, { as: "span", ml: 2 }, "deprecated")),
|
|
2056
|
-
parameter.required && (React__namespace.createElement(mosaic.Box, { as: "span", ml: 2 }, "required")))),
|
|
2057
|
-
description && (React__namespace.createElement(mosaic.Box, { w: "full", color: "muted", fontSize: "sm", my: 2 },
|
|
2058
|
-
React__namespace.createElement(markdownViewer.MarkdownViewer, { markdown: description }))),
|
|
2059
|
-
React__namespace.createElement(mosaic.Box, { fontSize: "sm" },
|
|
2060
|
-
React__namespace.createElement(jsonSchemaViewer.Validations, { validations: validations })),
|
|
2061
|
-
parameter.style && defaultStyle[parameterType] !== parameter.style && (React__namespace.createElement(mosaic.Flex, { my: 2 },
|
|
2062
|
-
React__namespace.createElement(mosaic.Box, { as: "span", px: 1, color: "muted", fontFamily: "mono", rounded: "lg", fontSize: "sm", textTransform: "capitalize", style: { backgroundColor: '#EDF2F7' } }, readableStyles[parameter.style] || parameter.style)))));
|
|
2063
|
-
};
|
|
2064
|
-
Parameter.displayName = 'HttpOperation.Parameter';
|
|
2124
|
+
}
|
|
2125
|
+
return schema;
|
|
2126
|
+
};
|
|
2065
2127
|
|
|
2066
|
-
const Request = ({ operation: {
|
|
2128
|
+
const Request = ({ operation: { request, request: { path: pathParams = [], headers: headerParams = [], cookie: cookieParams = [], body, query: queryParams = [], } = {}, security, }, onChange, }) => {
|
|
2067
2129
|
if (!request || typeof request !== 'object')
|
|
2068
2130
|
return null;
|
|
2131
|
+
const bodyIsEmpty = isBodyEmpty(body);
|
|
2069
2132
|
const securitySchemes = flatten__default["default"](security);
|
|
2070
|
-
const
|
|
2071
|
-
|
|
2072
|
-
|
|
2073
|
-
|
|
2074
|
-
|
|
2133
|
+
const hasRequestData = Boolean(securitySchemes.length ||
|
|
2134
|
+
pathParams.length ||
|
|
2135
|
+
queryParams.length ||
|
|
2136
|
+
headerParams.length ||
|
|
2137
|
+
cookieParams.length ||
|
|
2138
|
+
!bodyIsEmpty);
|
|
2139
|
+
if (!hasRequestData)
|
|
2140
|
+
return null;
|
|
2141
|
+
return (React__namespace.createElement(mosaic.VStack, { spacing: 8 },
|
|
2075
2142
|
React__namespace.createElement(SectionTitle, { title: "Request" }),
|
|
2076
|
-
securitySchemes.map((scheme, i) => (React__namespace.createElement(SecurityPanel, { key: i, scheme: scheme, includeKey: shouldIncludeKey(securitySchemes, scheme.type) }))),
|
|
2077
|
-
React__namespace.createElement(
|
|
2078
|
-
React__namespace.createElement(
|
|
2079
|
-
|
|
2143
|
+
securitySchemes.length > 0 && (React__namespace.createElement(mosaic.VStack, { spacing: 3 }, securitySchemes.map((scheme, i) => (React__namespace.createElement(SecurityPanel, { key: i, scheme: scheme, includeKey: shouldIncludeKey(securitySchemes, scheme.type) }))))),
|
|
2144
|
+
pathParams.length > 0 && (React__namespace.createElement(mosaic.VStack, { spacing: 5 },
|
|
2145
|
+
React__namespace.createElement(SectionSubtitle, { title: "Path Parameters" }),
|
|
2146
|
+
React__namespace.createElement(Parameters, { parameterType: "path", parameters: pathParams }))),
|
|
2147
|
+
queryParams.length > 0 && (React__namespace.createElement(mosaic.VStack, { spacing: 5 },
|
|
2148
|
+
React__namespace.createElement(SectionSubtitle, { title: "Query Parameters" }),
|
|
2080
2149
|
React__namespace.createElement(Parameters, { parameterType: "query", parameters: queryParams }))),
|
|
2081
|
-
headerParams.length > 0 && (React__namespace.createElement(
|
|
2150
|
+
headerParams.length > 0 && (React__namespace.createElement(mosaic.VStack, { spacing: 5 },
|
|
2151
|
+
React__namespace.createElement(SectionSubtitle, { title: "Headers", id: "request-headers" }),
|
|
2082
2152
|
React__namespace.createElement(Parameters, { parameterType: "header", parameters: headerParams }))),
|
|
2083
|
-
cookieParams.length > 0 && (React__namespace.createElement(
|
|
2153
|
+
cookieParams.length > 0 && (React__namespace.createElement(mosaic.VStack, { spacing: 5 },
|
|
2154
|
+
React__namespace.createElement(SectionSubtitle, { title: "Cookies", id: "request-cookies" }),
|
|
2084
2155
|
React__namespace.createElement(Parameters, { parameterType: "cookie", parameters: cookieParams }))),
|
|
2085
2156
|
body && React__namespace.createElement(Body, { onChange: onChange, body: body })));
|
|
2086
2157
|
};
|
|
@@ -2101,15 +2172,15 @@ const Responses = ({ responses: unsortedResponses, onStatusCodeChange, onMediaTy
|
|
|
2101
2172
|
}, [activeResponseId]);
|
|
2102
2173
|
if (!responses.length)
|
|
2103
2174
|
return null;
|
|
2104
|
-
return (React__namespace.createElement(mosaic.
|
|
2105
|
-
React__namespace.createElement(
|
|
2106
|
-
React__namespace.createElement(
|
|
2107
|
-
|
|
2108
|
-
React__namespace.createElement(
|
|
2109
|
-
React__namespace.createElement(Response, { response: response, onMediaTypeChange: onMediaTypeChange }))))))));
|
|
2175
|
+
return (React__namespace.createElement(mosaic.VStack, { spacing: 8, as: mosaic.Tabs, selectedId: activeResponseId, onChange: setActiveResponseId, appearance: "pill" },
|
|
2176
|
+
React__namespace.createElement(SectionTitle, { title: "Responses" },
|
|
2177
|
+
React__namespace.createElement(mosaic.TabList, { density: "compact" }, responses.map(({ code }) => (React__namespace.createElement(mosaic.Tab, { key: code, id: code, intent: codeToIntentVal(code) }, code))))),
|
|
2178
|
+
React__namespace.createElement(mosaic.TabPanels, { p: 0 }, responses.map(response => (React__namespace.createElement(mosaic.TabPanel, { key: response.code, id: response.code },
|
|
2179
|
+
React__namespace.createElement(Response, { response: response, onMediaTypeChange: onMediaTypeChange })))))));
|
|
2110
2180
|
};
|
|
2111
2181
|
Responses.displayName = 'HttpOperation.Responses';
|
|
2112
|
-
const Response = ({ response
|
|
2182
|
+
const Response = ({ response, onMediaTypeChange }) => {
|
|
2183
|
+
const { contents = [], headers = [], description } = response;
|
|
2113
2184
|
const [chosenContent, setChosenContent] = React__namespace.useState(0);
|
|
2114
2185
|
const refResolver = useInlineRefResolver();
|
|
2115
2186
|
const responseContent = contents[chosenContent];
|
|
@@ -2117,14 +2188,31 @@ const Response = ({ response: { contents = [], headers = [], description }, onMe
|
|
|
2117
2188
|
React__namespace.useEffect(() => {
|
|
2118
2189
|
responseContent && onMediaTypeChange(responseContent.mediaType);
|
|
2119
2190
|
}, [responseContent]);
|
|
2120
|
-
return (React__namespace.createElement(mosaic.
|
|
2121
|
-
description && React__namespace.createElement(MarkdownViewer, {
|
|
2122
|
-
headers.length > 0 && (React__namespace.createElement(
|
|
2191
|
+
return (React__namespace.createElement(mosaic.VStack, { spacing: 8, pt: 8 },
|
|
2192
|
+
description && React__namespace.createElement(MarkdownViewer, { markdown: description }),
|
|
2193
|
+
headers.length > 0 && (React__namespace.createElement(mosaic.VStack, { spacing: 5 },
|
|
2194
|
+
React__namespace.createElement(SectionSubtitle, { title: "Headers", id: "response-headers" }),
|
|
2123
2195
|
React__namespace.createElement(Parameters, { parameterType: "header", parameters: headers }))),
|
|
2124
|
-
contents.length > 0 && (React__namespace.createElement(
|
|
2125
|
-
React__namespace.createElement(
|
|
2196
|
+
contents.length > 0 && (React__namespace.createElement(React__namespace.Fragment, null,
|
|
2197
|
+
React__namespace.createElement(SectionSubtitle, { title: "Body", id: "response-body" },
|
|
2198
|
+
React__namespace.createElement(mosaic.Flex, { flex: 1, justify: "end" },
|
|
2199
|
+
React__namespace.createElement(mosaic.Select, { "aria-label": "Response Body Content Type", value: String(chosenContent), onChange: (value) => setChosenContent(parseInt(String(value), 10)), options: contents.map((content, index) => ({ label: content.mediaType, value: index })), size: "sm" }))),
|
|
2200
|
+
schema && (React__namespace.createElement(jsonSchemaViewer.JsonSchemaViewer, { schema: getOriginalObject(schema), resolveRef: refResolver, viewMode: "read", hideExamples: true, parentCrumbs: ['responses', response.code], renderRootTreeLines: true }))))));
|
|
2126
2201
|
};
|
|
2127
|
-
Response.displayName = 'HttpOperation.Response';
|
|
2202
|
+
Response.displayName = 'HttpOperation.Response';
|
|
2203
|
+
const codeToIntentVal = (code) => {
|
|
2204
|
+
const firstChar = code.charAt(0);
|
|
2205
|
+
switch (firstChar) {
|
|
2206
|
+
case '2':
|
|
2207
|
+
return 'success';
|
|
2208
|
+
case '4':
|
|
2209
|
+
return 'warning';
|
|
2210
|
+
case '5':
|
|
2211
|
+
return 'danger';
|
|
2212
|
+
default:
|
|
2213
|
+
return 'default';
|
|
2214
|
+
}
|
|
2215
|
+
};
|
|
2128
2216
|
|
|
2129
2217
|
const HttpOperationComponent = React__namespace.memo(({ className, data: unresolvedData, layoutOptions, tryItCredentialsPolicy, tryItCorsProxy }) => {
|
|
2130
2218
|
const data = useResolvedObject(unresolvedData);
|
|
@@ -2134,13 +2222,16 @@ const HttpOperationComponent = React__namespace.memo(({ className, data: unresol
|
|
|
2134
2222
|
const [responseMediaType, setResponseMediaType] = React__namespace.useState('');
|
|
2135
2223
|
const [responseStatusCode, setResponseStatusCode] = React__namespace.useState('');
|
|
2136
2224
|
const [requestBodyIndex, setTextRequestBodyIndex] = React__namespace.useState(0);
|
|
2225
|
+
const prettyName = (data.summary || data.iid || '').trim();
|
|
2137
2226
|
const hasBadges = isDeprecated || isInternal;
|
|
2138
|
-
const header = (!(layoutOptions === null || layoutOptions === void 0 ? void 0 : layoutOptions.noHeading) || hasBadges) && (React__namespace.createElement(
|
|
2139
|
-
|
|
2140
|
-
|
|
2141
|
-
|
|
2142
|
-
|
|
2143
|
-
|
|
2227
|
+
const header = (!(layoutOptions === null || layoutOptions === void 0 ? void 0 : layoutOptions.noHeading) || hasBadges) && (React__namespace.createElement(mosaic.VStack, { spacing: 5 },
|
|
2228
|
+
React__namespace.createElement(mosaic.HStack, { spacing: 5 },
|
|
2229
|
+
!(layoutOptions === null || layoutOptions === void 0 ? void 0 : layoutOptions.noHeading) && prettyName ? (React__namespace.createElement(mosaic.Heading, { size: 1, fontWeight: "semibold" }, prettyName)) : null,
|
|
2230
|
+
React__namespace.createElement(mosaic.HStack, { spacing: 2 },
|
|
2231
|
+
isDeprecated && React__namespace.createElement(DeprecatedBadge, null),
|
|
2232
|
+
isInternal && React__namespace.createElement(InternalBadge, { isHttpService: true }))),
|
|
2233
|
+
React__namespace.createElement(MethodPath, { method: data.method, path: data.path })));
|
|
2234
|
+
const description = (React__namespace.createElement(mosaic.VStack, { spacing: 10 },
|
|
2144
2235
|
data.description && React__namespace.createElement(MarkdownViewer, { className: "HttpOperation__Description", markdown: data.description }),
|
|
2145
2236
|
React__namespace.createElement(Request, { onChange: setTextRequestBodyIndex, operation: data }),
|
|
2146
2237
|
data.responses && (React__namespace.createElement(Responses, { responses: data.responses, onMediaTypeChange: setResponseMediaType, onStatusCodeChange: setResponseStatusCode }))));
|
|
@@ -2150,7 +2241,26 @@ const HttpOperationComponent = React__namespace.memo(({ className, data: unresol
|
|
|
2150
2241
|
HttpOperationComponent.displayName = 'HttpOperation.Component';
|
|
2151
2242
|
const HttpOperation = reactErrorBoundary.withErrorBoundary(HttpOperationComponent, {
|
|
2152
2243
|
recoverableProps: ['data'],
|
|
2153
|
-
});
|
|
2244
|
+
});
|
|
2245
|
+
function MethodPath({ method, path }) {
|
|
2246
|
+
const chosenServer = utils.useAtomValue(chosenServerAtom);
|
|
2247
|
+
let chosenServerUrl = '';
|
|
2248
|
+
if (chosenServer) {
|
|
2249
|
+
chosenServerUrl = chosenServer.url.endsWith('/') ? chosenServer.url.slice(0, -1) : chosenServer.url;
|
|
2250
|
+
}
|
|
2251
|
+
return (React__namespace.createElement(mosaic.Box, null,
|
|
2252
|
+
React__namespace.createElement(MethodPathInner, { method: method, path: path, chosenServerUrl: chosenServerUrl })));
|
|
2253
|
+
}
|
|
2254
|
+
function MethodPathInner({ method, path, chosenServerUrl }) {
|
|
2255
|
+
const isDark = mosaic.useThemeIsDark();
|
|
2256
|
+
const fullUrl = `${chosenServerUrl}${path}`;
|
|
2257
|
+
const pathElem = (React__namespace.createElement(mosaic.Flex, { overflowX: "hidden" },
|
|
2258
|
+
chosenServerUrl ? (React__namespace.createElement(mosaic.Box, { dir: "rtl", color: "muted", fontSize: "lg", textOverflow: "truncate", overflowX: "hidden" }, chosenServerUrl)) : null,
|
|
2259
|
+
React__namespace.createElement(mosaic.Box, { fontSize: "lg", fontWeight: "semibold", flex: 1 }, path)));
|
|
2260
|
+
return (React__namespace.createElement(mosaic.HStack, { spacing: 3, pl: 2.5, pr: 4, py: 2, bg: "canvas-50", rounded: "lg", fontFamily: "mono", display: "inline-flex", maxW: "full", title: fullUrl },
|
|
2261
|
+
React__namespace.createElement(mosaic.Box, { py: 1, px: 2.5, rounded: "lg", bg: !isDark ? HttpMethodColors[method] : 'canvas-100', color: !isDark ? 'on-primary' : 'body', fontSize: "lg", fontWeight: "semibold", textTransform: "uppercase" }, method),
|
|
2262
|
+
pathElem));
|
|
2263
|
+
}
|
|
2154
2264
|
|
|
2155
2265
|
const PoweredByLink = ({ source, pathname, packageType, layout = 'sidebar' }) => {
|
|
2156
2266
|
return (React__namespace.createElement(mosaic.Flex, { as: "a", align: "center", borderT: layout === 'stacked' ? undefined : true, px: layout === 'stacked' ? 1 : 4, py: 3, justify: layout === 'stacked' ? 'end' : undefined, href: `https://stoplight.io/?utm_source=${packageType}&utm_medium=${source}&utm_campaign=powered_by&utm_content=${pathname}`, target: "_blank", rel: "noopener noreferrer" },
|
|
@@ -2186,7 +2296,7 @@ const ExportButton = ({ original, bundled }) => {
|
|
|
2186
2296
|
return items;
|
|
2187
2297
|
}, [original, bundled]);
|
|
2188
2298
|
return (React__namespace.createElement(mosaic.Box, null,
|
|
2189
|
-
React__namespace.createElement(mosaic.Menu, { "aria-label": "Export", items: menuItems, renderTrigger: ({ isOpen }) => (React__namespace.createElement(mosaic.Button, { iconRight: "chevron-down", appearance: "default", ml: 2, active: isOpen, size: "sm" }, "Export")) })));
|
|
2299
|
+
React__namespace.createElement(mosaic.Menu, { "aria-label": "Export", items: menuItems, placement: "bottom right", renderTrigger: ({ isOpen }) => (React__namespace.createElement(mosaic.Button, { iconRight: "chevron-down", appearance: "default", ml: 2, active: isOpen, size: "sm" }, "Export")) })));
|
|
2190
2300
|
};
|
|
2191
2301
|
|
|
2192
2302
|
const SecuritySchemes = ({ schemes, defaultScheme, defaultCollapsed = false, }) => {
|
|
@@ -2206,7 +2316,8 @@ const SecurityScheme = ({ scheme, defaultIsOpen, isCollapsible, showSchemeKey })
|
|
|
2206
2316
|
const ServerInfo = ({ servers, mockUrl }) => {
|
|
2207
2317
|
const mocking = React__namespace.useContext(MockingContext);
|
|
2208
2318
|
const showMocking = !mocking.hideMocking && mockUrl && isProperUrl(mockUrl);
|
|
2209
|
-
const
|
|
2319
|
+
const $mockUrl = showMocking ? mockUrl || mocking.mockUrl : undefined;
|
|
2320
|
+
const serversToDisplay = getServersToDisplay(servers, $mockUrl);
|
|
2210
2321
|
if (!showMocking && serversToDisplay.length === 0) {
|
|
2211
2322
|
return null;
|
|
2212
2323
|
}
|
|
@@ -2215,14 +2326,11 @@ const ServerInfo = ({ servers, mockUrl }) => {
|
|
|
2215
2326
|
React__namespace.createElement(mosaic.Panel.Titlebar, { whitespace: "nowrap" }, "API Base URL"),
|
|
2216
2327
|
React__namespace.createElement(mosaic.Box, { overflowX: "auto" },
|
|
2217
2328
|
React__namespace.createElement(mosaic.Panel.Content, { w: "full", className: "sl-flex sl-flex-col" },
|
|
2218
|
-
serversToDisplay.map((server, index) => (React__namespace.createElement(ServerUrl, Object.assign({}, server, { key: index }))))
|
|
2219
|
-
showMocking && (React__namespace.createElement(React__namespace.Fragment, null,
|
|
2220
|
-
React__namespace.createElement(mosaic.Box, { borderT: 2, pt: 2, borderColor: "light", w: "full" }),
|
|
2221
|
-
React__namespace.createElement(ServerUrl, { description: "Mock Server", url: mockUrl || '', marginBottom: false }))))))));
|
|
2329
|
+
React__namespace.createElement(mosaic.VStack, { spacing: 1, divider: true }, serversToDisplay.map((server, index) => (React__namespace.createElement(ServerUrl, Object.assign({}, server, { key: index }))))))))));
|
|
2222
2330
|
};
|
|
2223
2331
|
const ServerUrl = ({ description, url, marginBottom = true }) => {
|
|
2224
2332
|
const { onCopy, hasCopied } = mosaic.useClipboard(url);
|
|
2225
|
-
return (React__namespace.createElement(mosaic.Box, { whitespace: "nowrap"
|
|
2333
|
+
return (React__namespace.createElement(mosaic.Box, { whitespace: "nowrap" },
|
|
2226
2334
|
React__namespace.createElement(mosaic.Text, { pr: 2, fontWeight: "bold" },
|
|
2227
2335
|
description,
|
|
2228
2336
|
":"),
|
|
@@ -2271,14 +2379,13 @@ const ModelComponent = ({ data: unresolvedData, className, nodeTitle, layoutOpti
|
|
|
2271
2379
|
};
|
|
2272
2380
|
const examples = React__namespace.useMemo(() => generateExamplesFromJsonSchema(data), [data]);
|
|
2273
2381
|
const shouldDisplayHeader = !(layoutOptions === null || layoutOptions === void 0 ? void 0 : layoutOptions.noHeading) && (title !== undefined || (exportProps && !(layoutOptions === null || layoutOptions === void 0 ? void 0 : layoutOptions.hideExport)));
|
|
2274
|
-
const header = (shouldDisplayHeader || isInternal) && (React__namespace.createElement(
|
|
2275
|
-
|
|
2276
|
-
React__namespace.createElement(mosaic.Heading, { size: 1,
|
|
2277
|
-
|
|
2278
|
-
|
|
2279
|
-
|
|
2280
|
-
|
|
2281
|
-
data.description && data.type === 'object' && (React__namespace.createElement(MarkdownViewer, { className: "sl-mb-6", role: "textbox", markdown: data.description })),
|
|
2382
|
+
const header = (shouldDisplayHeader || isInternal) && (React__namespace.createElement(mosaic.Flex, { justifyContent: "between", alignItems: "center" },
|
|
2383
|
+
React__namespace.createElement(mosaic.HStack, { spacing: 5 },
|
|
2384
|
+
title && (React__namespace.createElement(mosaic.Heading, { size: 1, fontWeight: "semibold" }, title)),
|
|
2385
|
+
React__namespace.createElement(mosaic.HStack, { spacing: 2 }, isInternal && React__namespace.createElement(InternalBadge, null))),
|
|
2386
|
+
exportProps && !(layoutOptions === null || layoutOptions === void 0 ? void 0 : layoutOptions.hideExport) && React__namespace.createElement(ExportButton, Object.assign({}, exportProps))));
|
|
2387
|
+
const description = (React__namespace.createElement(mosaic.VStack, { spacing: 10 },
|
|
2388
|
+
data.description && data.type === 'object' && React__namespace.createElement(MarkdownViewer, { role: "textbox", markdown: data.description }),
|
|
2282
2389
|
React__namespace.createElement(jsonSchemaViewer.JsonSchemaViewer, { resolveRef: resolveRef, schema: getOriginalObject(data) })));
|
|
2283
2390
|
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: " }));
|
|
2284
2391
|
const modelExamples = !(layoutOptions === null || layoutOptions === void 0 ? void 0 : layoutOptions.hideModelExamples) && (React__namespace.createElement(mosaic.Panel, { rounded: true, isCollapsible: false },
|
|
@@ -2341,6 +2448,20 @@ const Logo = ({ logo }) => {
|
|
|
2341
2448
|
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 }))));
|
|
2342
2449
|
};
|
|
2343
2450
|
|
|
2451
|
+
function getDisplayName(WrappedComponent) {
|
|
2452
|
+
return WrappedComponent.displayName || WrappedComponent.name || 'Component';
|
|
2453
|
+
}
|
|
2454
|
+
|
|
2455
|
+
const PersistenceContextProvider = jotai.Provider;
|
|
2456
|
+
function withPersistenceBoundary(WrappedComponent) {
|
|
2457
|
+
const WithPersistenceBoundary = props => {
|
|
2458
|
+
return (React__namespace.createElement(PersistenceContextProvider, null,
|
|
2459
|
+
React__namespace.createElement(WrappedComponent, Object.assign({}, props))));
|
|
2460
|
+
};
|
|
2461
|
+
WithPersistenceBoundary.displayName = `withPersistenceBoundary(${getDisplayName(WrappedComponent)})`;
|
|
2462
|
+
return WithPersistenceBoundary;
|
|
2463
|
+
}
|
|
2464
|
+
|
|
2344
2465
|
function useParsedValue(value) {
|
|
2345
2466
|
return React__namespace.useMemo(() => {
|
|
2346
2467
|
let parsedValue = value;
|
|
@@ -2385,7 +2506,8 @@ const CodeComponent = props => {
|
|
|
2385
2506
|
if (!isObject__default["default"](parsedValue) || (!isPartialHttpRequest(parsedValue) && !isHttpOperation(parsedValue))) {
|
|
2386
2507
|
return null;
|
|
2387
2508
|
}
|
|
2388
|
-
return (React__default["default"].createElement(
|
|
2509
|
+
return (React__default["default"].createElement(PersistenceContextProvider, null,
|
|
2510
|
+
React__default["default"].createElement(TryIt, { httpOperation: isHttpOperation(parsedValue) ? parsedValue : parseHttpRequest(parsedValue), embeddedInMd: true })));
|
|
2389
2511
|
}
|
|
2390
2512
|
const DefaultCode = markdownViewer.DefaultSMDComponents.code;
|
|
2391
2513
|
return React__default["default"].createElement(DefaultCode, Object.assign({}, props));
|
|
@@ -2605,20 +2727,6 @@ const NonIdealState = ({ description, icon, title }) => {
|
|
|
2605
2727
|
React__namespace.createElement(mosaic.Text, null, description)));
|
|
2606
2728
|
};
|
|
2607
2729
|
|
|
2608
|
-
function getDisplayName(WrappedComponent) {
|
|
2609
|
-
return WrappedComponent.displayName || WrappedComponent.name || 'Component';
|
|
2610
|
-
}
|
|
2611
|
-
|
|
2612
|
-
const PersistenceContextProvider = jotai.Provider;
|
|
2613
|
-
function withPersistenceBoundary(WrappedComponent) {
|
|
2614
|
-
const WithPersistenceBoundary = props => {
|
|
2615
|
-
return (React__namespace.createElement(PersistenceContextProvider, null,
|
|
2616
|
-
React__namespace.createElement(WrappedComponent, Object.assign({}, props))));
|
|
2617
|
-
};
|
|
2618
|
-
WithPersistenceBoundary.displayName = `withPersistenceBoundary(${getDisplayName(WrappedComponent)})`;
|
|
2619
|
-
return WithPersistenceBoundary;
|
|
2620
|
-
}
|
|
2621
|
-
|
|
2622
2730
|
function withMosaicProvider(WrappedComponent) {
|
|
2623
2731
|
const WithMosaicProvider = (props) => {
|
|
2624
2732
|
try {
|
|
@@ -2663,10 +2771,11 @@ const RouterComponent = {
|
|
|
2663
2771
|
history: reactRouterDom.BrowserRouter,
|
|
2664
2772
|
memory: reactRouterDom.MemoryRouter,
|
|
2665
2773
|
hash: reactRouterDom.HashRouter,
|
|
2774
|
+
static: reactRouterDom.StaticRouter,
|
|
2666
2775
|
};
|
|
2667
|
-
const useRouter = (router, basePath) => {
|
|
2776
|
+
const useRouter = (router, basePath, staticRouterPath) => {
|
|
2668
2777
|
const Router = RouterComponent[router];
|
|
2669
|
-
const routerProps = Object.assign({}, (router !== 'memory' && { basename: basePath }));
|
|
2778
|
+
const routerProps = Object.assign(Object.assign({}, (router !== 'memory' && { basename: basePath })), (router === 'static' && { location: staticRouterPath }));
|
|
2670
2779
|
return {
|
|
2671
2780
|
Router,
|
|
2672
2781
|
routerProps,
|
|
@@ -2675,9 +2784,10 @@ const useRouter = (router, basePath) => {
|
|
|
2675
2784
|
|
|
2676
2785
|
function withRouter(WrappedComponent) {
|
|
2677
2786
|
const WithRouter = (props) => {
|
|
2678
|
-
var _a, _b;
|
|
2787
|
+
var _a, _b, _c;
|
|
2679
2788
|
const basePath = (_a = props.basePath) !== null && _a !== void 0 ? _a : '/';
|
|
2680
|
-
const
|
|
2789
|
+
const staticRouterPath = (_b = props.staticRouterPath) !== null && _b !== void 0 ? _b : '';
|
|
2790
|
+
const { Router, routerProps } = useRouter((_c = props.router) !== null && _c !== void 0 ? _c : 'history', basePath, staticRouterPath);
|
|
2681
2791
|
return (React__namespace.createElement(Router, Object.assign({}, routerProps, { key: basePath }),
|
|
2682
2792
|
React__namespace.createElement(reactRouterDom.Route, { path: "/" },
|
|
2683
2793
|
React__namespace.createElement(MarkdownComponentsProvider, { value: { link: ReactRouterMarkdownLink } },
|
|
@@ -2881,6 +2991,7 @@ exports.createResolvedObject = createResolvedObject;
|
|
|
2881
2991
|
exports.findFirstNode = findFirstNode;
|
|
2882
2992
|
exports.isHttpOperation = isHttpOperation;
|
|
2883
2993
|
exports.isHttpService = isHttpService;
|
|
2994
|
+
exports.slugify = slugify;
|
|
2884
2995
|
exports.useBundleRefsIntoDocument = useBundleRefsIntoDocument;
|
|
2885
2996
|
exports.useParsedData = useParsedData;
|
|
2886
2997
|
exports.useParsedValue = useParsedValue;
|