@jpmorganchase/elemental 7.0.1 → 7.1.1

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/index.js CHANGED
@@ -1,7 +1,5 @@
1
1
  'use strict';
2
2
 
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
3
  var elementalCore = require('@jpmorganchase/elemental-core');
6
4
  var mosaic = require('@stoplight/mosaic');
7
5
  var types = require('@stoplight/types');
@@ -21,677 +19,696 @@ var get = require('lodash/get.js');
21
19
  var isObject = require('lodash/isObject.js');
22
20
  var last = require('lodash/last.js');
23
21
 
24
- function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
25
-
26
- function _interopNamespace(e) {
27
- if (e && e.__esModule) return e;
28
- var n = Object.create(null);
29
- if (e) {
30
- Object.keys(e).forEach(function (k) {
31
- if (k !== 'default') {
32
- var d = Object.getOwnPropertyDescriptor(e, k);
33
- Object.defineProperty(n, k, d.get ? d : {
34
- enumerable: true,
35
- get: function () { return e[k]; }
22
+ function _interopNamespaceDefault(e) {
23
+ var n = Object.create(null);
24
+ if (e) {
25
+ Object.keys(e).forEach(function (k) {
26
+ if (k !== 'default') {
27
+ var d = Object.getOwnPropertyDescriptor(e, k);
28
+ Object.defineProperty(n, k, d.get ? d : {
29
+ enumerable: true,
30
+ get: function () { return e[k]; }
31
+ });
32
+ }
36
33
  });
37
- }
38
- });
39
- }
40
- n["default"] = e;
41
- return Object.freeze(n);
34
+ }
35
+ n.default = e;
36
+ return Object.freeze(n);
42
37
  }
43
38
 
44
- var cn__default = /*#__PURE__*/_interopDefaultLegacy(cn);
45
- var React__namespace = /*#__PURE__*/_interopNamespace(React);
46
- var defaults__default = /*#__PURE__*/_interopDefaultLegacy(defaults);
47
- var flow__default = /*#__PURE__*/_interopDefaultLegacy(flow);
48
- var saver__default = /*#__PURE__*/_interopDefaultLegacy(saver);
49
- var get__default = /*#__PURE__*/_interopDefaultLegacy(get);
50
- var isObject__default = /*#__PURE__*/_interopDefaultLegacy(isObject);
51
- var last__default = /*#__PURE__*/_interopDefaultLegacy(last);
39
+ var React__namespace = /*#__PURE__*/_interopNamespaceDefault(React);
52
40
 
53
- function computeTagGroups(serviceNode, nodeType) {
54
- const groupsByTagId = {};
55
- const ungrouped = [];
56
- const lowerCaseServiceTags = serviceNode.tags.map(tn => tn.toLowerCase());
57
- const groupableNodes = serviceNode.children.filter(n => n.type === nodeType);
58
- for (const node of groupableNodes) {
59
- const tagName = node.tags[0];
60
- if (tagName) {
61
- const tagId = tagName.toLowerCase();
62
- if (groupsByTagId[tagId]) {
63
- groupsByTagId[tagId].items.push(node);
64
- }
65
- else {
66
- const serviceTagIndex = lowerCaseServiceTags.findIndex(tn => tn === tagId);
67
- const serviceTagName = serviceNode.tags[serviceTagIndex];
68
- groupsByTagId[tagId] = {
69
- title: serviceTagName || tagName,
70
- items: [node],
71
- };
72
- }
73
- }
74
- else {
75
- ungrouped.push(node);
76
- }
77
- }
78
- const orderedTagGroups = Object.entries(groupsByTagId)
79
- .sort(([g1], [g2]) => {
80
- const g1LC = g1.toLowerCase();
81
- const g2LC = g2.toLowerCase();
82
- const g1Idx = lowerCaseServiceTags.findIndex(tn => tn === g1LC);
83
- const g2Idx = lowerCaseServiceTags.findIndex(tn => tn === g2LC);
84
- if (g1Idx < 0 && g2Idx < 0)
85
- return 0;
86
- if (g1Idx < 0)
87
- return 1;
88
- if (g2Idx < 0)
89
- return -1;
90
- return g1Idx - g2Idx;
91
- })
92
- .map(([, tagGroup]) => tagGroup);
93
- return { groups: orderedTagGroups, ungrouped };
94
- }
95
- const defaultComputerAPITreeConfig = {
96
- hideSchemas: false,
97
- hideInternal: false,
98
- };
99
- const computeAPITree = (serviceNode, config = {}) => {
100
- const mergedConfig = defaults__default["default"](config, defaultComputerAPITreeConfig);
101
- const tree = [];
102
- tree.push({
103
- id: '/',
104
- slug: '/',
105
- title: 'Overview',
106
- type: 'overview',
107
- meta: '',
108
- });
109
- const hasOperationNodes = serviceNode.children.some(node => node.type === types.NodeType.HttpOperation);
110
- if (hasOperationNodes) {
111
- tree.push({
112
- title: 'Endpoints',
113
- });
114
- const { groups, ungrouped } = computeTagGroups(serviceNode, types.NodeType.HttpOperation);
115
- addTagGroupsToTree(groups, ungrouped, tree, types.NodeType.HttpOperation, mergedConfig.hideInternal);
116
- }
117
- const hasWebhookNodes = serviceNode.children.some(node => node.type === types.NodeType.HttpWebhook);
118
- if (hasWebhookNodes) {
119
- tree.push({
120
- title: 'Webhooks',
121
- });
122
- const { groups, ungrouped } = computeTagGroups(serviceNode, types.NodeType.HttpWebhook);
123
- addTagGroupsToTree(groups, ungrouped, tree, types.NodeType.HttpWebhook, mergedConfig.hideInternal);
124
- }
125
- let schemaNodes = serviceNode.children.filter(node => node.type === types.NodeType.Model);
126
- if (mergedConfig.hideInternal) {
127
- schemaNodes = schemaNodes.filter(n => !isInternal(n));
128
- }
129
- if (!mergedConfig.hideSchemas && schemaNodes.length) {
130
- tree.push({
131
- title: 'Schemas',
132
- });
133
- const { groups, ungrouped } = computeTagGroups(serviceNode, types.NodeType.Model);
134
- addTagGroupsToTree(groups, ungrouped, tree, types.NodeType.Model, mergedConfig.hideInternal);
135
- }
136
- return tree;
137
- };
138
- const findFirstNodeSlug = (tree) => {
139
- for (const item of tree) {
140
- if ('slug' in item) {
141
- return item.slug;
142
- }
143
- if ('items' in item) {
144
- const slug = findFirstNodeSlug(item.items);
145
- if (slug) {
146
- return slug;
147
- }
148
- }
149
- }
150
- return;
151
- };
152
- const isInternal = (node) => {
153
- const data = node.data;
154
- if (elementalCore.isHttpOperation(data) || elementalCore.isHttpWebhookOperation(data)) {
155
- return !!data.internal;
156
- }
157
- if (elementalCore.isHttpService(data)) {
158
- return false;
159
- }
160
- return !!data['x-internal'];
161
- };
162
- const addTagGroupsToTree = (groups, ungrouped, tree, itemsType, hideInternal) => {
163
- ungrouped.forEach(node => {
164
- if (hideInternal && isInternal(node)) {
165
- return;
166
- }
167
- tree.push({
168
- id: node.uri,
169
- slug: node.uri,
170
- title: node.name,
171
- type: node.type,
172
- meta: elementalCore.isHttpOperation(node.data) || elementalCore.isHttpWebhookOperation(node.data) ? node.data.method : '',
173
- });
174
- });
175
- groups.forEach(group => {
176
- const items = group.items.flatMap(node => {
177
- if (hideInternal && isInternal(node)) {
178
- return [];
179
- }
180
- return {
181
- id: node.uri,
182
- slug: node.uri,
183
- title: node.name,
184
- type: node.type,
185
- meta: elementalCore.isHttpOperation(node.data) || elementalCore.isHttpWebhookOperation(node.data) ? node.data.method : '',
186
- };
187
- });
188
- if (items.length > 0) {
189
- tree.push({
190
- title: group.title,
191
- items,
192
- itemsType,
193
- });
194
- }
195
- });
41
+ function computeTagGroups(serviceNode, nodeType) {
42
+ const groupsByTagId = {};
43
+ const ungrouped = [];
44
+ const lowerCaseServiceTags = serviceNode.tags.map(tn => tn.toLowerCase());
45
+ const groupableNodes = serviceNode.children.filter(n => n.type === nodeType);
46
+ for (const node of groupableNodes) {
47
+ for (const tagName of node.tags) {
48
+ const tagId = tagName.toLowerCase();
49
+ if (groupsByTagId[tagId]) {
50
+ groupsByTagId[tagId].items.push(node);
51
+ }
52
+ else {
53
+ const serviceTagIndex = lowerCaseServiceTags.findIndex(tn => tn === tagId);
54
+ const serviceTagName = serviceNode.tags[serviceTagIndex];
55
+ groupsByTagId[tagId] = {
56
+ title: serviceTagName || tagName,
57
+ items: [node],
58
+ };
59
+ }
60
+ }
61
+ if (node.tags.length === 0) {
62
+ ungrouped.push(node);
63
+ }
64
+ }
65
+ const orderedTagGroups = Object.entries(groupsByTagId)
66
+ .sort(([g1], [g2]) => {
67
+ const g1LC = g1.toLowerCase();
68
+ const g2LC = g2.toLowerCase();
69
+ const g1Idx = lowerCaseServiceTags.findIndex(tn => tn === g1LC);
70
+ const g2Idx = lowerCaseServiceTags.findIndex(tn => tn === g2LC);
71
+ if (g1Idx < 0 && g2Idx < 0)
72
+ return 0;
73
+ if (g1Idx < 0)
74
+ return 1;
75
+ if (g2Idx < 0)
76
+ return -1;
77
+ return g1Idx - g2Idx;
78
+ })
79
+ .map(([, tagGroup]) => tagGroup);
80
+ return { groups: orderedTagGroups, ungrouped };
81
+ }
82
+ const defaultComputerAPITreeConfig = {
83
+ hideSchemas: false,
84
+ hideInternal: false,
85
+ };
86
+ const computeAPITree = (serviceNode, config = {}) => {
87
+ const mergedConfig = defaults(config, defaultComputerAPITreeConfig);
88
+ const tree = [];
89
+ tree.push({
90
+ id: '/',
91
+ slug: '/',
92
+ title: 'Overview',
93
+ type: 'overview',
94
+ meta: '',
95
+ });
96
+ const hasOperationNodes = serviceNode.children.some(node => node.type === types.NodeType.HttpOperation);
97
+ if (hasOperationNodes) {
98
+ tree.push({
99
+ title: 'Endpoints',
100
+ });
101
+ const { groups, ungrouped } = computeTagGroups(serviceNode, types.NodeType.HttpOperation);
102
+ addTagGroupsToTree(groups, ungrouped, tree, types.NodeType.HttpOperation, mergedConfig.hideInternal);
103
+ }
104
+ const hasWebhookNodes = serviceNode.children.some(node => node.type === types.NodeType.HttpWebhook);
105
+ if (hasWebhookNodes) {
106
+ tree.push({
107
+ title: 'Webhooks',
108
+ });
109
+ const { groups, ungrouped } = computeTagGroups(serviceNode, types.NodeType.HttpWebhook);
110
+ addTagGroupsToTree(groups, ungrouped, tree, types.NodeType.HttpWebhook, mergedConfig.hideInternal);
111
+ }
112
+ let schemaNodes = serviceNode.children.filter(node => node.type === types.NodeType.Model);
113
+ if (mergedConfig.hideInternal) {
114
+ schemaNodes = schemaNodes.filter(n => !isInternal(n));
115
+ }
116
+ if (!mergedConfig.hideSchemas && schemaNodes.length) {
117
+ tree.push({
118
+ title: 'Schemas',
119
+ });
120
+ const { groups, ungrouped } = computeTagGroups(serviceNode, types.NodeType.Model);
121
+ addTagGroupsToTree(groups, ungrouped, tree, types.NodeType.Model, mergedConfig.hideInternal);
122
+ }
123
+ return tree;
124
+ };
125
+ const findFirstNodeSlug = (tree) => {
126
+ for (const item of tree) {
127
+ if ('slug' in item) {
128
+ return item.slug;
129
+ }
130
+ if ('items' in item) {
131
+ const slug = findFirstNodeSlug(item.items);
132
+ if (slug) {
133
+ return slug;
134
+ }
135
+ }
136
+ }
137
+ return;
138
+ };
139
+ const isInternal = (node) => {
140
+ const data = node.data;
141
+ if (elementalCore.isHttpOperation(data) || elementalCore.isHttpWebhookOperation(data)) {
142
+ return !!data.internal;
143
+ }
144
+ if (elementalCore.isHttpService(data)) {
145
+ return false;
146
+ }
147
+ return !!data['x-internal'];
148
+ };
149
+ const addTagGroupsToTree = (groups, ungrouped, tree, itemsType, hideInternal) => {
150
+ ungrouped.forEach(node => {
151
+ if (hideInternal && isInternal(node)) {
152
+ return;
153
+ }
154
+ tree.push({
155
+ id: node.uri,
156
+ slug: node.uri,
157
+ title: node.name,
158
+ type: node.type,
159
+ meta: elementalCore.isHttpOperation(node.data) || elementalCore.isHttpWebhookOperation(node.data) ? node.data.method : '',
160
+ });
161
+ });
162
+ groups.forEach(group => {
163
+ const items = group.items.flatMap(node => {
164
+ if (hideInternal && isInternal(node)) {
165
+ return [];
166
+ }
167
+ return {
168
+ id: node.uri,
169
+ slug: node.uri,
170
+ title: node.name,
171
+ type: node.type,
172
+ meta: elementalCore.isHttpOperation(node.data) || elementalCore.isHttpWebhookOperation(node.data) ? node.data.method : '',
173
+ };
174
+ });
175
+ if (items.length > 0) {
176
+ tree.push({
177
+ title: group.title,
178
+ items,
179
+ itemsType,
180
+ });
181
+ }
182
+ });
183
+ };
184
+ const resolveRelativePath = (currentPath, basePath, outerRouter) => {
185
+ if (!outerRouter || !basePath || basePath === '/') {
186
+ return currentPath;
187
+ }
188
+ const baseUrl = elementalCore.resolveUrl(basePath);
189
+ const currentUrl = elementalCore.resolveUrl(currentPath);
190
+ return baseUrl && currentUrl && baseUrl !== currentUrl ? currentUrl.replace(baseUrl, '') : '/';
196
191
  };
197
192
 
198
- const itemUriMatchesPathname = (itemUri, pathname) => itemUri === pathname;
199
- const TryItContext = React__namespace.createContext({
200
- hideTryIt: false,
201
- tryItCredentialsPolicy: 'omit',
202
- });
203
- TryItContext.displayName = 'TryItContext';
204
- const LocationContext = React__namespace.createContext({
205
- location: {
206
- hash: '',
207
- key: '',
208
- pathname: '',
209
- search: '',
210
- state: '',
211
- },
212
- });
213
- LocationContext.displayName = 'LocationContext';
214
- const APIWithStackedLayout = ({ serviceNode, hideTryIt, hideExport, hideInlineExamples, exportProps, tryItCredentialsPolicy, tryItCorsProxy, renderExtensionAddon, showPoweredByLink = true, location, tryItOutDefaultServer, }) => {
215
- const { groups: operationGroups } = computeTagGroups(serviceNode, types.NodeType.HttpOperation);
216
- const { groups: webhookGroups } = computeTagGroups(serviceNode, types.NodeType.HttpWebhook);
217
- return (React__namespace.createElement(LocationContext.Provider, { value: { location } },
218
- React__namespace.createElement(TryItContext.Provider, { value: {
219
- hideTryIt,
220
- tryItCredentialsPolicy,
221
- corsProxy: tryItCorsProxy,
222
- hideInlineExamples,
223
- tryItOutDefaultServer,
224
- } },
225
- React__namespace.createElement(mosaic.Flex, { w: "full", flexDirection: "col", m: "auto", className: "sl-max-w-4xl" },
226
- React__namespace.createElement(mosaic.Box, { w: "full", borderB: true },
227
- React__namespace.createElement(elementalCore.Docs, { className: "sl-mx-auto", nodeData: serviceNode.data, nodeTitle: serviceNode.name, nodeType: types.NodeType.HttpService, location: location, layoutOptions: { showPoweredByLink, hideExport }, exportProps: exportProps, tryItCredentialsPolicy: tryItCredentialsPolicy, renderExtensionAddon: renderExtensionAddon, tryItOutDefaultServer: tryItOutDefaultServer })),
228
- operationGroups.length > 0 && webhookGroups.length > 0 ? React__namespace.createElement(mosaic.Heading, { size: 2 }, "Endpoints") : null,
229
- operationGroups.map(group => (React__namespace.createElement(Group, { key: group.title, group: group }))),
230
- webhookGroups.length > 0 ? React__namespace.createElement(mosaic.Heading, { size: 2 }, "Webhooks") : null,
231
- webhookGroups.map(group => (React__namespace.createElement(Group, { key: group.title, group: group })))))));
232
- };
233
- APIWithStackedLayout.displayName = 'APIWithStackedLayout';
234
- const Group = React__namespace.memo(({ group }) => {
235
- const [isExpanded, setIsExpanded] = React__namespace.useState(false);
236
- const { location: { pathname }, } = React__namespace.useContext(LocationContext);
237
- const onClick = React__namespace.useCallback(() => setIsExpanded(!isExpanded), [isExpanded]);
238
- const shouldExpand = React__namespace.useMemo(() => {
239
- return group.items.some(item => itemUriMatchesPathname(item.uri, pathname));
240
- }, [group, pathname]);
241
- React__namespace.useEffect(() => {
242
- if (shouldExpand) {
243
- setIsExpanded(true);
244
- }
245
- }, [shouldExpand]);
246
- return (React__namespace.createElement(mosaic.Box, null,
247
- React__namespace.createElement(mosaic.Flex, { onClick: onClick, mx: "auto", justifyContent: "between", alignItems: "center", borderB: true, px: 2, py: 4, cursor: "pointer", color: { default: 'current', hover: 'muted' } },
248
- React__namespace.createElement(mosaic.Box, { fontSize: "lg", fontWeight: "medium" }, group.title),
249
- React__namespace.createElement(mosaic.Icon, { className: "sl-mr-2", icon: isExpanded ? 'chevron-down' : 'chevron-right', size: "sm" })),
250
- React__namespace.createElement(Collapse, { isOpen: isExpanded }, group.items.map(item => {
251
- return React__namespace.createElement(Item, { key: item.uri, item: item });
252
- }))));
253
- });
254
- Group.displayName = 'Group';
255
- const Item = React__namespace.memo(({ item }) => {
256
- const { location } = React__namespace.useContext(LocationContext);
257
- const { pathname } = location;
258
- const [isExpanded, setIsExpanded] = React__namespace.useState(false);
259
- const scrollRef = React__namespace.useRef(null);
260
- const color = elementalCore.HttpMethodColors[item.data.method] || 'gray';
261
- const isDeprecated = !!item.data.deprecated;
262
- const { hideTryIt, hideInlineExamples, tryItCredentialsPolicy, corsProxy, tryItOutDefaultServer } = React__namespace.useContext(TryItContext);
263
- const onClick = React__namespace.useCallback(() => {
264
- setIsExpanded(!isExpanded);
265
- if (window && window.location) {
266
- window.history.pushState(null, '', `#${item.uri}`);
267
- }
268
- }, [isExpanded, item]);
269
- React__namespace.useEffect(() => {
270
- if (itemUriMatchesPathname(item.uri, pathname)) {
271
- setIsExpanded(true);
272
- if (scrollRef === null || scrollRef === void 0 ? void 0 : scrollRef.current) {
273
- scrollRef === null || scrollRef === void 0 ? void 0 : scrollRef.current.scrollIntoView();
274
- }
275
- }
276
- }, [pathname, item]);
277
- return (React__namespace.createElement(mosaic.Box, { ref: scrollRef, w: "full", my: 2, border: true, borderColor: { default: isExpanded ? 'light' : 'transparent', hover: 'light' }, bg: { default: isExpanded ? 'code' : 'transparent', hover: 'code' } },
278
- React__namespace.createElement(mosaic.Flex, { mx: "auto", alignItems: "center", cursor: "pointer", fontSize: "lg", p: 2, onClick: onClick, color: "current" },
279
- React__namespace.createElement(mosaic.Box, { w: 24, textTransform: "uppercase", textAlign: "center", fontWeight: "semibold", border: true, rounded: true, px: 2, bg: "canvas", className: cn__default["default"](`sl-mr-5 sl-text-base`, `sl-text-${color}`, `sl-border-${color}`) }, item.data.method || 'UNKNOWN'),
280
- React__namespace.createElement(mosaic.Box, { flex: 1, fontWeight: "medium", wordBreak: "all" }, item.type === types.NodeType.HttpOperation ? item.data.path : item.name),
281
- isDeprecated && React__namespace.createElement(elementalCore.DeprecatedBadge, null)),
282
- React__namespace.createElement(Collapse, { isOpen: isExpanded },
283
- React__namespace.createElement(mosaic.Box, { flex: 1, p: 2, fontWeight: "medium", mx: "auto", fontSize: "xl" }, item.name),
284
- hideTryIt ? (React__namespace.createElement(mosaic.Box, { as: elementalCore.ParsedDocs, layoutOptions: { noHeading: true, hideTryItPanel: true }, node: item, p: 4 })) : (React__namespace.createElement(mosaic.Tabs, { appearance: "line" },
285
- React__namespace.createElement(mosaic.TabList, null,
286
- React__namespace.createElement(mosaic.Tab, null, "Docs"),
287
- React__namespace.createElement(mosaic.Tab, null, "TryIt")),
288
- React__namespace.createElement(mosaic.TabPanels, null,
289
- React__namespace.createElement(mosaic.TabPanel, null,
290
- React__namespace.createElement(elementalCore.ParsedDocs, { className: "sl-px-4", node: item, location: location, layoutOptions: { noHeading: true, hideTryItPanel: true } })),
291
- React__namespace.createElement(mosaic.TabPanel, null,
292
- React__namespace.createElement(elementalCore.TryItWithRequestSamples, { httpOperation: item.data, hideInlineExamples: hideInlineExamples, tryItCredentialsPolicy: tryItCredentialsPolicy, tryItOutDefaultServer: tryItOutDefaultServer, corsProxy: corsProxy }))))))));
293
- });
294
- Item.displayName = 'Item';
295
- const Collapse = ({ isOpen, children }) => {
296
- if (!isOpen)
297
- return null;
298
- return React__namespace.createElement(mosaic.Box, null, children);
299
- };
193
+ const itemUriMatchesPathname = (itemUri, pathname) => itemUri === pathname;
194
+ const TryItContext = React__namespace.createContext({
195
+ hideTryIt: false,
196
+ hideTryItPanel: false,
197
+ hideSamples: false,
198
+ tryItCredentialsPolicy: 'omit',
199
+ });
200
+ TryItContext.displayName = 'TryItContext';
201
+ const LocationContext = React__namespace.createContext({
202
+ location: {
203
+ hash: '',
204
+ key: '',
205
+ pathname: '',
206
+ search: '',
207
+ state: '',
208
+ },
209
+ });
210
+ LocationContext.displayName = 'LocationContext';
211
+ const APIWithStackedLayout = ({ serviceNode, hideTryItPanel, hideTryIt, hideSamples, hideExport, hideSecurityInfo, hideServerInfo, exportProps, tryItCredentialsPolicy, tryItCorsProxy, renderExtensionAddon, showPoweredByLink = true, location, hideInlineExamples, tryItOutDefaultServer, }) => {
212
+ const { groups: operationGroups } = computeTagGroups(serviceNode, types.NodeType.HttpOperation);
213
+ const { groups: webhookGroups } = computeTagGroups(serviceNode, types.NodeType.HttpWebhook);
214
+ return (React__namespace.createElement(LocationContext.Provider, { value: { location } },
215
+ React__namespace.createElement(TryItContext.Provider, { value: {
216
+ hideTryItPanel,
217
+ hideTryIt,
218
+ hideSamples,
219
+ tryItCredentialsPolicy,
220
+ corsProxy: tryItCorsProxy,
221
+ hideInlineExamples,
222
+ tryItOutDefaultServer,
223
+ } },
224
+ React__namespace.createElement(mosaic.Flex, { w: "full", flexDirection: "col", m: "auto", className: "sl-max-w-4xl" },
225
+ React__namespace.createElement(mosaic.Box, { w: "full", borderB: true },
226
+ React__namespace.createElement(elementalCore.Docs, { className: "sl-mx-auto", nodeData: serviceNode.data, nodeTitle: serviceNode.name, nodeType: types.NodeType.HttpService, location: location, layoutOptions: { showPoweredByLink, hideExport, hideSecurityInfo, hideServerInfo }, exportProps: exportProps, tryItCredentialsPolicy: tryItCredentialsPolicy, renderExtensionAddon: renderExtensionAddon, tryItOutDefaultServer: tryItOutDefaultServer })),
227
+ operationGroups.length > 0 && webhookGroups.length > 0 ? React__namespace.createElement(mosaic.Heading, { size: 2 }, "Endpoints") : null,
228
+ operationGroups.map(group => (React__namespace.createElement(Group, { key: group.title, group: group }))),
229
+ webhookGroups.length > 0 ? React__namespace.createElement(mosaic.Heading, { size: 2 }, "Webhooks") : null,
230
+ webhookGroups.map(group => (React__namespace.createElement(Group, { key: group.title, group: group })))))));
231
+ };
232
+ APIWithStackedLayout.displayName = 'APIWithStackedLayout';
233
+ const Group = React__namespace.memo(({ group }) => {
234
+ const [isExpanded, setIsExpanded] = React__namespace.useState(false);
235
+ const { location: { pathname }, } = React__namespace.useContext(LocationContext);
236
+ const onClick = React__namespace.useCallback(() => setIsExpanded(!isExpanded), [isExpanded]);
237
+ const shouldExpand = React__namespace.useMemo(() => {
238
+ return group.items.some(item => itemUriMatchesPathname(item.uri, pathname));
239
+ }, [group, pathname]);
240
+ React__namespace.useEffect(() => {
241
+ if (shouldExpand) {
242
+ setIsExpanded(true);
243
+ }
244
+ }, [shouldExpand]);
245
+ return (React__namespace.createElement(mosaic.Box, null,
246
+ React__namespace.createElement(mosaic.Flex, { onClick: onClick, mx: "auto", justifyContent: "between", alignItems: "center", borderB: true, px: 2, py: 4, cursor: "pointer", color: { default: 'current', hover: 'muted' } },
247
+ React__namespace.createElement(mosaic.Box, { fontSize: "lg", fontWeight: "medium" }, group.title),
248
+ React__namespace.createElement(mosaic.Icon, { className: "sl-mr-2", icon: isExpanded ? 'chevron-down' : 'chevron-right', size: "sm" })),
249
+ React__namespace.createElement(Collapse, { isOpen: isExpanded }, group.items.map(item => {
250
+ return React__namespace.createElement(Item, { key: item.uri, item: item });
251
+ }))));
252
+ });
253
+ Group.displayName = 'Group';
254
+ const Item = React__namespace.memo(({ item }) => {
255
+ const { location } = React__namespace.useContext(LocationContext);
256
+ const { pathname } = location;
257
+ const [isExpanded, setIsExpanded] = React__namespace.useState(false);
258
+ const scrollRef = React__namespace.useRef(null);
259
+ const color = elementalCore.HttpMethodColors[item.data.method] || 'gray';
260
+ const isDeprecated = !!item.data.deprecated;
261
+ const { hideTryIt, hideSamples, hideTryItPanel, tryItCredentialsPolicy, corsProxy, hideInlineExamples, tryItOutDefaultServer, } = React__namespace.useContext(TryItContext);
262
+ const onClick = React__namespace.useCallback(() => {
263
+ setIsExpanded(!isExpanded);
264
+ if (window && window.location) {
265
+ window.history.pushState(null, '', `#${item.uri}`);
266
+ }
267
+ }, [isExpanded, item]);
268
+ React__namespace.useEffect(() => {
269
+ if (itemUriMatchesPathname(item.uri, pathname)) {
270
+ setIsExpanded(true);
271
+ if (scrollRef === null || scrollRef === void 0 ? void 0 : scrollRef.current) {
272
+ scrollRef === null || scrollRef === void 0 ? void 0 : scrollRef.current.scrollIntoView();
273
+ }
274
+ }
275
+ }, [pathname, item]);
276
+ return (React__namespace.createElement(mosaic.Box, { ref: scrollRef, w: "full", my: 2, border: true, borderColor: { default: isExpanded ? 'light' : 'transparent', hover: 'light' }, bg: { default: isExpanded ? 'code' : 'transparent', hover: 'code' } },
277
+ React__namespace.createElement(mosaic.Flex, { mx: "auto", alignItems: "center", cursor: "pointer", fontSize: "lg", p: 2, onClick: onClick, color: "current" },
278
+ React__namespace.createElement(mosaic.Box, { w: 24, textTransform: "uppercase", textAlign: "center", fontWeight: "semibold", border: true, rounded: true, px: 2, bg: "canvas", className: cn(`sl-mr-5 sl-text-base`, `sl-text-${color}`, `sl-border-${color}`) }, item.data.method || 'UNKNOWN'),
279
+ React__namespace.createElement(mosaic.Box, { flex: 1, fontWeight: "medium", wordBreak: "all" }, item.type === types.NodeType.HttpOperation ? item.data.path : item.name),
280
+ isDeprecated && React__namespace.createElement(elementalCore.DeprecatedBadge, null)),
281
+ React__namespace.createElement(Collapse, { isOpen: isExpanded },
282
+ React__namespace.createElement(mosaic.Box, { flex: 1, p: 2, fontWeight: "medium", mx: "auto", fontSize: "xl" }, item.name),
283
+ hideTryItPanel ? (React__namespace.createElement(mosaic.Box, { as: elementalCore.ParsedDocs, layoutOptions: { noHeading: true, hideTryItPanel: true, hideSamples, hideTryIt }, node: item, p: 4 })) : (React__namespace.createElement(mosaic.Tabs, { appearance: "line" },
284
+ React__namespace.createElement(mosaic.TabList, null,
285
+ React__namespace.createElement(mosaic.Tab, null, "Docs"),
286
+ React__namespace.createElement(mosaic.Tab, null, "TryIt")),
287
+ React__namespace.createElement(mosaic.TabPanels, null,
288
+ React__namespace.createElement(mosaic.TabPanel, null,
289
+ React__namespace.createElement(elementalCore.ParsedDocs, { className: "sl-px-4", node: item, location: location, layoutOptions: { noHeading: true, hideTryItPanel: false, hideSamples, hideTryIt } })),
290
+ React__namespace.createElement(mosaic.TabPanel, null,
291
+ React__namespace.createElement(elementalCore.TryItWithRequestSamples, { httpOperation: item.data, hideInlineExamples: hideInlineExamples, tryItCredentialsPolicy: tryItCredentialsPolicy, tryItOutDefaultServer: tryItOutDefaultServer, corsProxy: corsProxy, hideSamples: hideSamples, hideTryIt: hideTryIt }))))))));
292
+ });
293
+ Item.displayName = 'Item';
294
+ const Collapse = ({ isOpen, children }) => {
295
+ if (!isOpen)
296
+ return null;
297
+ return React__namespace.createElement(mosaic.Box, null, children);
298
+ };
300
299
  Collapse.displayName = 'Collapse';
301
300
 
302
- const APIWithResponsiveSidebarLayout = ({ serviceNode, logo, hideTryIt, compact, hideSchemas, hideInternal, hideExport, exportProps, tryItCredentialsPolicy, tryItCorsProxy, renderExtensionAddon, }) => {
303
- const container = React__namespace.useRef(null);
304
- const tree = React__namespace.useMemo(() => computeAPITree(serviceNode, { hideSchemas, hideInternal }), [serviceNode, hideSchemas, hideInternal]);
305
- const location = reactRouterDom.useLocation();
306
- const { pathname } = location;
307
- const isRootPath = !pathname || pathname === '/';
308
- const node = isRootPath ? serviceNode : serviceNode.children.find(child => child.uri === pathname);
309
- const layoutOptions = React__namespace.useMemo(() => ({ hideTryIt: hideTryIt, compact: compact, hideExport: hideExport || (node === null || node === void 0 ? void 0 : node.type) !== types.NodeType.HttpService }), [hideTryIt, hideExport, node, compact]);
310
- if (!node) {
311
- const firstSlug = findFirstNodeSlug(tree);
312
- if (firstSlug) {
313
- return React__namespace.createElement(reactRouterDom.Redirect, { to: firstSlug });
314
- }
315
- }
316
- if (hideInternal && node && isInternal(node)) {
317
- return React__namespace.createElement(reactRouterDom.Redirect, { to: "/" });
318
- }
319
- const handleTocClick = () => {
320
- if (container.current) {
321
- container.current.scrollIntoView();
322
- }
323
- };
324
- return (React__namespace.createElement(elementalCore.ResponsiveSidebarLayout, { onTocClick: handleTocClick, tree: tree, logo: logo !== null && logo !== void 0 ? logo : serviceNode.data.logo, ref: container, name: serviceNode.name }, node && (React__namespace.createElement(elementalCore.ElementsOptionsProvider, { renderExtensionAddon: renderExtensionAddon },
325
- React__namespace.createElement(elementalCore.ParsedDocs, { key: pathname, uri: pathname, node: node, nodeTitle: node.name, layoutOptions: layoutOptions, location: location, exportProps: exportProps, tryItCredentialsPolicy: tryItCredentialsPolicy, tryItCorsProxy: tryItCorsProxy, renderExtensionAddon: renderExtensionAddon })))));
301
+ const APIWithResponsiveSidebarLayout = ({ serviceNode, logo, hideTryItPanel, hideTryIt, hideSamples, compact, hideSchemas, hideInternal, hideExport, hideServerInfo, hideSecurityInfo, exportProps, tryItCredentialsPolicy, tryItCorsProxy, renderExtensionAddon, basePath = '/', outerRouter = false, }) => {
302
+ const container = React__namespace.useRef(null);
303
+ const tree = React__namespace.useMemo(() => computeAPITree(serviceNode, { hideSchemas, hideInternal }), [serviceNode, hideSchemas, hideInternal]);
304
+ const location = reactRouterDom.useLocation();
305
+ const { pathname: currentPath } = location;
306
+ const relativePath = resolveRelativePath(currentPath, basePath, outerRouter);
307
+ const isRootPath = relativePath === '/';
308
+ const node = isRootPath ? serviceNode : serviceNode.children.find(child => child.uri === relativePath);
309
+ const layoutOptions = React__namespace.useMemo(() => ({
310
+ hideTryIt: hideTryIt,
311
+ hideTryItPanel,
312
+ hideSamples,
313
+ hideSecurityInfo: hideSecurityInfo,
314
+ hideServerInfo: hideServerInfo,
315
+ compact: compact,
316
+ hideExport: hideExport || (node === null || node === void 0 ? void 0 : node.type) !== types.NodeType.HttpService,
317
+ }), [hideTryIt, hideSecurityInfo, hideServerInfo, compact, hideExport, hideTryItPanel, hideSamples, node === null || node === void 0 ? void 0 : node.type]);
318
+ if (!node) {
319
+ const firstSlug = findFirstNodeSlug(tree);
320
+ if (firstSlug) {
321
+ return React__namespace.createElement(reactRouterDom.Navigate, { to: elementalCore.resolveRelativeLink(firstSlug), replace: true });
322
+ }
323
+ }
324
+ if (hideInternal && node && isInternal(node)) {
325
+ return React__namespace.createElement(reactRouterDom.Navigate, { to: ".", replace: true });
326
+ }
327
+ const handleTocClick = () => {
328
+ if (container.current) {
329
+ container.current.scrollIntoView();
330
+ }
331
+ };
332
+ return (React__namespace.createElement(elementalCore.ResponsiveSidebarLayout, { onTocClick: handleTocClick, tree: tree, logo: logo !== null && logo !== void 0 ? logo : serviceNode.data.logo, ref: container, name: serviceNode.name }, node && (React__namespace.createElement(elementalCore.ElementsOptionsProvider, { renderExtensionAddon: renderExtensionAddon },
333
+ React__namespace.createElement(elementalCore.ParsedDocs, { key: relativePath, uri: relativePath, node: node, nodeTitle: node.name, layoutOptions: layoutOptions, location: location, exportProps: exportProps, tryItCredentialsPolicy: tryItCredentialsPolicy, tryItCorsProxy: tryItCorsProxy, renderExtensionAddon: renderExtensionAddon })))));
326
334
  };
327
335
 
328
- const APIWithSidebarLayout = ({ serviceNode, logo, hideTryIt, hideSchemas, hideInternal, hideExport, hideInlineExamples = false, exportProps, tryItCredentialsPolicy, tryItCorsProxy, renderExtensionAddon, tryItOutDefaultServer, useCustomNav, layout, }) => {
329
- const container = React__namespace.useRef(null);
330
- const tree = React__namespace.useMemo(() => {
331
- if (!useCustomNav)
332
- return computeAPITree(serviceNode, { hideSchemas, hideInternal });
333
- else
334
- return [];
335
- }, [serviceNode, hideSchemas, hideInternal, useCustomNav]);
336
- const location = reactRouterDom.useLocation();
337
- const { pathname } = location;
338
- const isRootPath = !pathname || pathname === '/';
339
- const node = isRootPath ? serviceNode : serviceNode.children.find(child => child.uri === pathname);
340
- React__namespace.useEffect(() => {
341
- }, [pathname]);
342
- const layoutOptions = React__namespace.useMemo(() => ({ hideTryIt: hideTryIt, hideInlineExamples, hideExport: hideExport || (node === null || node === void 0 ? void 0 : node.type) !== types.NodeType.HttpService }), [hideTryIt, hideExport, node, hideInlineExamples]);
343
- if (!node) {
344
- const firstSlug = findFirstNodeSlug(tree);
345
- if (firstSlug) {
346
- return React__namespace.createElement(reactRouterDom.Redirect, { to: firstSlug });
347
- }
348
- }
349
- if (hideInternal && node && isInternal(node)) {
350
- return React__namespace.createElement(reactRouterDom.Redirect, { to: "/" });
351
- }
352
- const sidebar = (React__namespace.createElement(Sidebar, { serviceNode: serviceNode, logo: logo, container: container, pathname: pathname, tree: tree }));
353
- return (React__namespace.createElement(elementalCore.SidebarLayout, { ref: container, sidebar: sidebar, renderSideBar: !useCustomNav, layout: layout }, node && (React__namespace.createElement(elementalCore.ElementsOptionsProvider, { renderExtensionAddon: renderExtensionAddon },
354
- React__namespace.createElement(elementalCore.ParsedDocs, { key: pathname, uri: pathname, node: node, nodeTitle: node.name, layoutOptions: layoutOptions, location: location, exportProps: exportProps, tryItCredentialsPolicy: tryItCredentialsPolicy, tryItCorsProxy: tryItCorsProxy, renderExtensionAddon: renderExtensionAddon, tryItOutDefaultServer: tryItOutDefaultServer })))));
355
- };
356
- const Sidebar = ({ serviceNode, logo, container, pathname, tree }) => {
357
- const handleTocClick = () => {
358
- if (container.current) {
359
- container.current.scrollIntoView();
360
- }
361
- };
362
- return (React__namespace.createElement(React__namespace.Fragment, null,
363
- React__namespace.createElement(mosaic.Flex, { ml: 4, mb: 5, alignItems: "center" },
364
- logo ? (React__namespace.createElement(elementalCore.Logo, { logo: { url: logo, altText: 'logo' } })) : (serviceNode.data.logo && React__namespace.createElement(elementalCore.Logo, { logo: serviceNode.data.logo })),
365
- React__namespace.createElement(mosaic.Heading, { size: 4 }, serviceNode.name)),
366
- React__namespace.createElement(mosaic.Flex, { flexGrow: true, flexShrink: true, overflowY: "auto", direction: "col" },
367
- React__namespace.createElement(elementalCore.TableOfContents, { tree: tree, activeId: pathname, Link: reactRouterDom.Link, onLinkClick: handleTocClick })),
368
- React__namespace.createElement(elementalCore.PoweredByLink, { source: serviceNode.name, pathname: pathname, packageType: "elements" })));
369
- };
336
+ const APIWithSidebarLayout = ({ serviceNode, logo, hideTryItPanel, hideTryIt, hideSamples, hideSchemas, hideSecurityInfo, hideServerInfo, hideInternal, hideExport, hideInlineExamples = false, exportProps, tryItCredentialsPolicy, tryItCorsProxy, renderExtensionAddon, basePath = '/', outerRouter = false, tryItOutDefaultServer, useCustomNav, layout, }) => {
337
+ const container = React__namespace.useRef(null);
338
+ const tree = React__namespace.useMemo(() => {
339
+ if (!useCustomNav)
340
+ return computeAPITree(serviceNode, { hideSchemas, hideInternal });
341
+ else
342
+ return [];
343
+ }, [serviceNode, hideSchemas, hideInternal, useCustomNav]);
344
+ const location = reactRouterDom.useLocation();
345
+ const { pathname: currentPath } = location;
346
+ const relativePath = resolveRelativePath(currentPath, basePath, outerRouter);
347
+ const isRootPath = relativePath === '/';
348
+ const node = isRootPath ? serviceNode : serviceNode.children.find(child => child.uri === relativePath);
349
+ React__namespace.useEffect(() => {
350
+ }, [currentPath]);
351
+ const layoutOptions = React__namespace.useMemo(() => ({
352
+ hideTryIt: hideTryIt,
353
+ hideTryItPanel,
354
+ hideSamples,
355
+ hideServerInfo: hideServerInfo,
356
+ hideSecurityInfo: hideSecurityInfo,
357
+ hideExport: hideExport || (node === null || node === void 0 ? void 0 : node.type) !== types.NodeType.HttpService,
358
+ hideInlineExamples
359
+ }), [hideTryIt, hideServerInfo, hideSecurityInfo, hideExport, hideTryItPanel, hideSamples, node === null || node === void 0 ? void 0 : node.type, hideInlineExamples]);
360
+ if (!node) {
361
+ const firstSlug = findFirstNodeSlug(tree);
362
+ if (firstSlug) {
363
+ return React__namespace.createElement(reactRouterDom.Navigate, { to: elementalCore.resolveRelativeLink(firstSlug), replace: true });
364
+ }
365
+ }
366
+ if (hideInternal && node && isInternal(node)) {
367
+ return React__namespace.createElement(reactRouterDom.Navigate, { to: ".", replace: true });
368
+ }
369
+ const sidebar = (React__namespace.createElement(Sidebar, { serviceNode: serviceNode, logo: logo, container: container, pathname: relativePath, tree: tree }));
370
+ return (React__namespace.createElement(elementalCore.SidebarLayout, { ref: container, sidebar: sidebar, renderSideBar: !useCustomNav, layout: layout }, node && (React__namespace.createElement(elementalCore.ElementsOptionsProvider, { renderExtensionAddon: renderExtensionAddon },
371
+ React__namespace.createElement(elementalCore.ParsedDocs, { key: relativePath, uri: relativePath, node: node, nodeTitle: node.name, layoutOptions: layoutOptions, location: location, exportProps: exportProps, tryItCredentialsPolicy: tryItCredentialsPolicy, tryItCorsProxy: tryItCorsProxy, renderExtensionAddon: renderExtensionAddon, tryItOutDefaultServer: tryItOutDefaultServer })))));
372
+ };
373
+ const Sidebar = ({ serviceNode, logo, container, pathname, tree }) => {
374
+ const handleTocClick = () => {
375
+ if (container.current) {
376
+ container.current.scrollIntoView();
377
+ }
378
+ };
379
+ return (React__namespace.createElement(React__namespace.Fragment, null,
380
+ React__namespace.createElement(mosaic.Flex, { ml: 4, mb: 5, alignItems: "center" },
381
+ logo ? (React__namespace.createElement(elementalCore.Logo, { logo: { url: logo, altText: 'logo' } })) : (serviceNode.data.logo && React__namespace.createElement(elementalCore.Logo, { logo: serviceNode.data.logo })),
382
+ React__namespace.createElement(mosaic.Heading, { size: 4 }, serviceNode.name)),
383
+ React__namespace.createElement(mosaic.Flex, { flexGrow: true, flexShrink: true, overflowY: "auto", direction: "col" },
384
+ React__namespace.createElement(elementalCore.TableOfContents, { tree: tree, activeId: pathname, Link: reactRouterDom.Link, onLinkClick: handleTocClick })),
385
+ React__namespace.createElement(elementalCore.PoweredByLink, { source: serviceNode.name, pathname: pathname, packageType: "elements" })));
386
+ };
370
387
  Sidebar.displayName = 'Sidebar';
371
388
 
372
- var NodeTypes;
373
- (function (NodeTypes) {
374
- NodeTypes["Paths"] = "paths";
375
- NodeTypes["Path"] = "path";
376
- NodeTypes["Operation"] = "operation";
377
- NodeTypes["Webhooks"] = "webhooks";
378
- NodeTypes["Webhook"] = "webhook";
379
- NodeTypes["Components"] = "components";
380
- NodeTypes["Models"] = "models";
381
- NodeTypes["Model"] = "model";
389
+ var NodeTypes;
390
+ (function (NodeTypes) {
391
+ NodeTypes["Paths"] = "paths";
392
+ NodeTypes["Path"] = "path";
393
+ NodeTypes["Operation"] = "operation";
394
+ NodeTypes["Webhooks"] = "webhooks";
395
+ NodeTypes["Webhook"] = "webhook";
396
+ NodeTypes["Components"] = "components";
397
+ NodeTypes["Models"] = "models";
398
+ NodeTypes["Model"] = "model";
382
399
  })(NodeTypes || (NodeTypes = {}));
383
400
 
384
- const oas2SourceMap = [
385
- {
386
- match: 'paths',
387
- type: NodeTypes.Paths,
388
- children: [
389
- {
390
- notMatch: '^x-',
391
- type: NodeTypes.Path,
392
- children: [
393
- {
394
- match: 'get|post|put|delete|options|head|patch|trace',
395
- type: NodeTypes.Operation,
396
- },
397
- ],
398
- },
399
- ],
400
- },
401
- {
402
- match: 'definitions',
403
- type: NodeTypes.Models,
404
- children: [
405
- {
406
- notMatch: '^x-',
407
- type: NodeTypes.Model,
408
- },
409
- ],
410
- },
401
+ const oas2SourceMap = [
402
+ {
403
+ match: 'paths',
404
+ type: NodeTypes.Paths,
405
+ children: [
406
+ {
407
+ notMatch: '^x-',
408
+ type: NodeTypes.Path,
409
+ children: [
410
+ {
411
+ match: 'get|post|put|delete|options|head|patch|trace',
412
+ type: NodeTypes.Operation,
413
+ },
414
+ ],
415
+ },
416
+ ],
417
+ },
418
+ {
419
+ match: 'definitions',
420
+ type: NodeTypes.Models,
421
+ children: [
422
+ {
423
+ notMatch: '^x-',
424
+ type: NodeTypes.Model,
425
+ },
426
+ ],
427
+ },
411
428
  ];
412
429
 
413
- const oas3SourceMap = [
414
- {
415
- match: 'paths',
416
- type: NodeTypes.Paths,
417
- children: [
418
- {
419
- notMatch: '^x-',
420
- type: NodeTypes.Path,
421
- children: [
422
- {
423
- match: 'get|post|put|delete|options|head|patch|trace',
424
- type: NodeTypes.Operation,
425
- },
426
- ],
427
- },
428
- ],
429
- },
430
- {
431
- match: 'webhooks',
432
- type: NodeTypes.Webhooks,
433
- children: [
434
- {
435
- notMatch: '^x-',
436
- type: NodeTypes.Webhook,
437
- children: [
438
- {
439
- match: 'get|post|put|delete|options|head|patch|trace',
440
- type: NodeTypes.Webhook,
441
- },
442
- ],
443
- },
444
- ],
445
- },
446
- {
447
- match: 'components',
448
- type: NodeTypes.Components,
449
- children: [
450
- {
451
- match: 'schemas',
452
- type: NodeTypes.Models,
453
- children: [
454
- {
455
- notMatch: '^x-',
456
- type: NodeTypes.Model,
457
- },
458
- ],
459
- },
460
- ],
461
- },
430
+ const oas3SourceMap = [
431
+ {
432
+ match: 'paths',
433
+ type: NodeTypes.Paths,
434
+ children: [
435
+ {
436
+ notMatch: '^x-',
437
+ type: NodeTypes.Path,
438
+ children: [
439
+ {
440
+ match: 'get|post|put|delete|options|head|patch|trace',
441
+ type: NodeTypes.Operation,
442
+ },
443
+ ],
444
+ },
445
+ ],
446
+ },
447
+ {
448
+ match: 'webhooks',
449
+ type: NodeTypes.Webhooks,
450
+ children: [
451
+ {
452
+ notMatch: '^x-',
453
+ type: NodeTypes.Webhook,
454
+ children: [
455
+ {
456
+ match: 'get|post|put|delete|options|head|patch|trace',
457
+ type: NodeTypes.Webhook,
458
+ },
459
+ ],
460
+ },
461
+ ],
462
+ },
463
+ {
464
+ match: 'components',
465
+ type: NodeTypes.Components,
466
+ children: [
467
+ {
468
+ match: 'schemas',
469
+ type: NodeTypes.Models,
470
+ children: [
471
+ {
472
+ notMatch: '^x-',
473
+ type: NodeTypes.Model,
474
+ },
475
+ ],
476
+ },
477
+ ],
478
+ },
462
479
  ];
463
480
 
464
- const isOas2 = (parsed) => isObject__default["default"](parsed) &&
465
- 'swagger' in parsed &&
466
- Number.parseInt(String(parsed.swagger)) === 2;
467
- const isOas3 = (parsed) => isObject__default["default"](parsed) &&
468
- 'openapi' in parsed &&
469
- Number.parseFloat(String(parsed.openapi)) >= 3;
470
- const isOas31 = (parsed) => isObject__default["default"](parsed) &&
471
- 'openapi' in parsed &&
472
- Number.parseFloat(String(parsed.openapi)) === 3.1;
473
- const OAS_MODEL_REGEXP = /((definitions|components)\/?(schemas)?)\//;
474
- function transformOasToServiceNode(apiDescriptionDocument) {
475
- if (isOas31(apiDescriptionDocument)) {
476
- return computeServiceNode(Object.assign(Object.assign({}, apiDescriptionDocument), { jsonSchemaDialect: 'http://json-schema.org/draft-07/schema#' }), oas3SourceMap, oas3.transformOas3Service, oas3.transformOas3Operation);
477
- }
478
- if (isOas3(apiDescriptionDocument)) {
479
- return computeServiceNode(apiDescriptionDocument, oas3SourceMap, oas3.transformOas3Service, oas3.transformOas3Operation);
480
- }
481
- else if (isOas2(apiDescriptionDocument)) {
482
- return computeServiceNode(apiDescriptionDocument, oas2SourceMap, oas2.transformOas2Service, oas2.transformOas2Operation);
483
- }
484
- return null;
485
- }
486
- function computeServiceNode(document, map, transformService, transformOperation) {
487
- var _a;
488
- const serviceDocument = transformService({ document });
489
- const serviceNode = {
490
- type: types.NodeType.HttpService,
491
- uri: '/',
492
- name: serviceDocument.name,
493
- data: serviceDocument,
494
- tags: ((_a = serviceDocument.tags) === null || _a === void 0 ? void 0 : _a.map(tag => tag.name)) || [],
495
- children: computeChildNodes(document, document, map, transformOperation),
496
- };
497
- return serviceNode;
498
- }
499
- function computeChildNodes(document, data, map, transformer, parentUri = '') {
500
- var _a, _b;
501
- const nodes = [];
502
- if (!isObject__default["default"](data))
503
- return nodes;
504
- for (const key of Object.keys(data)) {
505
- const sanitizedKey = json.encodePointerFragment(key);
506
- const match = findMapMatch(sanitizedKey, map);
507
- if (match) {
508
- const uri = `${parentUri}/${sanitizedKey}`;
509
- const jsonPath = json.pointerToPath(`#${uri}`);
510
- if (match.type === NodeTypes.Operation && jsonPath.length === 3) {
511
- const path = String(jsonPath[1]);
512
- const method = String(jsonPath[2]);
513
- const operationDocument = transformer({
514
- document,
515
- name: path,
516
- method,
517
- config: oas.OPERATION_CONFIG,
518
- });
519
- let parsedUri;
520
- const encodedPath = String(json.encodePointerFragment(path));
521
- if (operationDocument.iid) {
522
- parsedUri = `/operations/${operationDocument.iid}`;
523
- }
524
- else {
525
- parsedUri = uri.replace(encodedPath, elementalCore.slugify(path));
526
- }
527
- nodes.push({
528
- type: types.NodeType.HttpOperation,
529
- uri: parsedUri,
530
- data: operationDocument,
531
- name: operationDocument.summary || operationDocument.iid || operationDocument.path,
532
- tags: ((_a = operationDocument.tags) === null || _a === void 0 ? void 0 : _a.map(tag => tag.name)) || [],
533
- });
534
- }
535
- else if (match.type === NodeTypes.Webhook && jsonPath.length === 3) {
536
- const name = String(jsonPath[1]);
537
- const method = String(jsonPath[2]);
538
- const webhookDocument = transformer({
539
- document,
540
- name,
541
- method,
542
- config: oas.WEBHOOK_CONFIG,
543
- });
544
- let parsedUri;
545
- const encodedPath = String(json.encodePointerFragment(name));
546
- if (webhookDocument.iid) {
547
- parsedUri = `/webhooks/${webhookDocument.iid}`;
548
- }
549
- else {
550
- parsedUri = uri.replace(encodedPath, elementalCore.slugify(name));
551
- }
552
- nodes.push({
553
- type: types.NodeType.HttpWebhook,
554
- uri: parsedUri,
555
- data: webhookDocument,
556
- name: webhookDocument.summary || webhookDocument.name,
557
- tags: ((_b = webhookDocument.tags) === null || _b === void 0 ? void 0 : _b.map(tag => tag.name)) || [],
558
- });
559
- }
560
- else if (match.type === NodeTypes.Model) {
561
- const schemaDocument = get__default["default"](document, jsonPath);
562
- const parsedUri = uri.replace(OAS_MODEL_REGEXP, 'schemas/');
563
- nodes.push({
564
- type: types.NodeType.Model,
565
- uri: parsedUri,
566
- data: schemaDocument,
567
- name: schemaDocument.title || last__default["default"](uri.split('/')) || '',
568
- tags: schemaDocument['x-tags'] || [],
569
- });
570
- }
571
- if (match.children) {
572
- nodes.push(...computeChildNodes(document, data[key], match.children, transformer, uri));
573
- }
574
- }
575
- }
576
- return nodes;
577
- }
578
- function findMapMatch(key, map) {
579
- var _a;
580
- if (typeof key === 'number')
581
- return;
582
- for (const entry of map) {
583
- const escapedKey = key.replace(/[\\^$*+?.()|[\]{}]/g, '\\$&');
584
- if (!!((_a = entry.match) === null || _a === void 0 ? void 0 : _a.match(escapedKey)) || (entry.notMatch !== void 0 && !entry.notMatch.match(escapedKey))) {
585
- return entry;
586
- }
587
- }
588
- }
589
- function isJson(value) {
590
- try {
591
- JSON.parse(value);
592
- }
593
- catch (e) {
594
- return false;
595
- }
596
- return true;
481
+ const isOas2 = (parsed) => isObject(parsed) &&
482
+ 'swagger' in parsed &&
483
+ Number.parseInt(String(parsed.swagger)) === 2;
484
+ const isOas3 = (parsed) => isObject(parsed) &&
485
+ 'openapi' in parsed &&
486
+ Number.parseFloat(String(parsed.openapi)) >= 3;
487
+ const isOas31 = (parsed) => isObject(parsed) &&
488
+ 'openapi' in parsed &&
489
+ Number.parseFloat(String(parsed.openapi)) === 3.1;
490
+ const OAS_MODEL_REGEXP = /((definitions|components)\/?(schemas)?)\//;
491
+ function transformOasToServiceNode(apiDescriptionDocument) {
492
+ if (isOas31(apiDescriptionDocument)) {
493
+ return computeServiceNode(Object.assign(Object.assign({}, apiDescriptionDocument), { jsonSchemaDialect: 'http://json-schema.org/draft-07/schema#' }), oas3SourceMap, oas3.transformOas3Service, oas3.transformOas3Operation);
494
+ }
495
+ if (isOas3(apiDescriptionDocument)) {
496
+ return computeServiceNode(apiDescriptionDocument, oas3SourceMap, oas3.transformOas3Service, oas3.transformOas3Operation);
497
+ }
498
+ else if (isOas2(apiDescriptionDocument)) {
499
+ return computeServiceNode(apiDescriptionDocument, oas2SourceMap, oas2.transformOas2Service, oas2.transformOas2Operation);
500
+ }
501
+ return null;
502
+ }
503
+ function computeServiceNode(document, map, transformService, transformOperation) {
504
+ var _a;
505
+ const serviceDocument = transformService({ document });
506
+ const serviceNode = {
507
+ type: types.NodeType.HttpService,
508
+ uri: '/',
509
+ name: serviceDocument.name,
510
+ data: serviceDocument,
511
+ tags: ((_a = serviceDocument.tags) === null || _a === void 0 ? void 0 : _a.map(tag => tag.name)) || [],
512
+ children: computeChildNodes(document, document, map, transformOperation),
513
+ };
514
+ return serviceNode;
515
+ }
516
+ function computeChildNodes(document, data, map, transformer, parentUri = '') {
517
+ var _a, _b;
518
+ const nodes = [];
519
+ if (!isObject(data))
520
+ return nodes;
521
+ for (const [key, value] of Object.entries(data)) {
522
+ const sanitizedKey = json.encodePointerFragment(key);
523
+ const match = findMapMatch(sanitizedKey, map);
524
+ if (match) {
525
+ const uri = `${parentUri}/${sanitizedKey}`;
526
+ const jsonPath = json.pointerToPath(`#${uri}`);
527
+ if (match.type === NodeTypes.Operation && jsonPath.length === 3) {
528
+ const path = String(jsonPath[1]);
529
+ const method = String(jsonPath[2]);
530
+ const operationDocument = transformer({
531
+ document,
532
+ name: path,
533
+ method,
534
+ config: oas.OPERATION_CONFIG,
535
+ });
536
+ let parsedUri;
537
+ const encodedPath = String(json.encodePointerFragment(path));
538
+ if (operationDocument.iid) {
539
+ parsedUri = `/operations/${operationDocument.iid}`;
540
+ }
541
+ else {
542
+ parsedUri = uri.replace(encodedPath, elementalCore.slugify(path));
543
+ }
544
+ nodes.push({
545
+ type: types.NodeType.HttpOperation,
546
+ uri: parsedUri,
547
+ data: operationDocument,
548
+ name: operationDocument.summary || operationDocument.iid || operationDocument.path,
549
+ tags: ((_a = operationDocument.tags) === null || _a === void 0 ? void 0 : _a.map(tag => tag.name)) || [],
550
+ });
551
+ }
552
+ else if (match.type === NodeTypes.Webhook && jsonPath.length === 3) {
553
+ const name = String(jsonPath[1]);
554
+ const method = String(jsonPath[2]);
555
+ const webhookDocument = transformer({
556
+ document,
557
+ name,
558
+ method,
559
+ config: oas.WEBHOOK_CONFIG,
560
+ });
561
+ let parsedUri;
562
+ const encodedPath = String(json.encodePointerFragment(name));
563
+ if (webhookDocument.iid) {
564
+ parsedUri = `/webhooks/${webhookDocument.iid}`;
565
+ }
566
+ else {
567
+ parsedUri = uri.replace(encodedPath, elementalCore.slugify(name));
568
+ }
569
+ nodes.push({
570
+ type: types.NodeType.HttpWebhook,
571
+ uri: parsedUri,
572
+ data: webhookDocument,
573
+ name: webhookDocument.summary || webhookDocument.name,
574
+ tags: ((_b = webhookDocument.tags) === null || _b === void 0 ? void 0 : _b.map(tag => tag.name)) || [],
575
+ });
576
+ }
577
+ else if (match.type === NodeTypes.Model) {
578
+ const schemaDocument = get(document, jsonPath);
579
+ const parsedUri = uri.replace(OAS_MODEL_REGEXP, 'schemas/');
580
+ nodes.push({
581
+ type: types.NodeType.Model,
582
+ uri: parsedUri,
583
+ data: schemaDocument,
584
+ name: schemaDocument.title || last(uri.split('/')) || '',
585
+ tags: schemaDocument['x-tags'] || [],
586
+ });
587
+ }
588
+ if (match.children) {
589
+ nodes.push(...computeChildNodes(document, value, match.children, transformer, uri));
590
+ }
591
+ }
592
+ }
593
+ return nodes;
594
+ }
595
+ function findMapMatch(key, map) {
596
+ var _a;
597
+ if (typeof key === 'number')
598
+ return;
599
+ for (const entry of map) {
600
+ const escapedKey = key.replace(/[\\^$*+?.()|[\]{}]/g, '\\$&');
601
+ if (!!((_a = entry.match) === null || _a === void 0 ? void 0 : _a.match(escapedKey)) || (entry.notMatch !== void 0 && !entry.notMatch.match(escapedKey))) {
602
+ return entry;
603
+ }
604
+ }
605
+ }
606
+ function isJson(value) {
607
+ try {
608
+ JSON.parse(value);
609
+ }
610
+ catch (e) {
611
+ return false;
612
+ }
613
+ return true;
597
614
  }
598
615
 
599
- function useExportDocumentProps({ originalDocument, bundledDocument, }) {
600
- const isJsonDocument = typeof originalDocument === 'object' || (!!originalDocument && isJson(originalDocument));
601
- const exportDocument = React__namespace.useCallback((document) => {
602
- const type = isJsonDocument ? 'json' : 'yaml';
603
- const blob = new Blob([document], {
604
- type: `application/${type}`,
605
- });
606
- saver__default["default"].saveAs(blob, `document.${type}`);
607
- }, [isJsonDocument]);
608
- const exportOriginalDocument = React__namespace.useCallback(() => {
609
- const stringifiedDocument = typeof originalDocument === 'object' ? JSON.stringify(originalDocument, null, 2) : originalDocument || '';
610
- exportDocument(stringifiedDocument);
611
- }, [originalDocument, exportDocument]);
612
- const exportBundledDocument = React__namespace.useCallback(() => {
613
- const stringifiedDocument = isJsonDocument
614
- ? JSON.stringify(bundledDocument, null, 2)
615
- : yaml.safeStringify(bundledDocument);
616
- exportDocument(stringifiedDocument);
617
- }, [bundledDocument, isJsonDocument, exportDocument]);
618
- return {
619
- original: {
620
- onPress: exportOriginalDocument,
621
- },
622
- bundled: {
623
- onPress: exportBundledDocument,
624
- },
625
- };
616
+ function useExportDocumentProps({ originalDocument, bundledDocument, }) {
617
+ const isJsonDocument = typeof originalDocument === 'object' || (!!originalDocument && isJson(originalDocument));
618
+ const exportDocument = React__namespace.useCallback((document) => {
619
+ const type = isJsonDocument ? 'json' : 'yaml';
620
+ const blob = new Blob([document], {
621
+ type: `application/${type}`,
622
+ });
623
+ saver.saveAs(blob, `document.${type}`);
624
+ }, [isJsonDocument]);
625
+ const exportOriginalDocument = React__namespace.useCallback(() => {
626
+ const stringifiedDocument = typeof originalDocument === 'object' ? JSON.stringify(originalDocument, null, 2) : originalDocument || '';
627
+ exportDocument(stringifiedDocument);
628
+ }, [originalDocument, exportDocument]);
629
+ const exportBundledDocument = React__namespace.useCallback(() => {
630
+ const stringifiedDocument = isJsonDocument
631
+ ? JSON.stringify(bundledDocument, null, 2)
632
+ : yaml.safeStringify(bundledDocument);
633
+ exportDocument(stringifiedDocument);
634
+ }, [bundledDocument, isJsonDocument, exportDocument]);
635
+ return {
636
+ original: {
637
+ onPress: exportOriginalDocument,
638
+ },
639
+ bundled: {
640
+ onPress: exportBundledDocument,
641
+ },
642
+ };
626
643
  }
627
644
 
628
- const propsAreWithDocument = (props) => {
629
- return props.hasOwnProperty('apiDescriptionDocument');
630
- };
631
- const APIImpl = props => {
632
- const { layout = 'sidebar', apiDescriptionUrl = '', logo, hideTryIt, hideSchemas, hideInternal, hideExport, hideInlineExamples, tryItCredentialsPolicy, tryItCorsProxy, maxRefDepth, renderExtensionAddon, tryItOutDefaultServer, useCustomNav, } = props;
633
- const location = reactRouterDom.useLocation();
634
- const apiDescriptionDocument = propsAreWithDocument(props) ? props.apiDescriptionDocument : undefined;
635
- const { isResponsiveLayoutEnabled } = elementalCore.useResponsiveLayout();
636
- const { data: fetchedDocument, error } = reactQuery.useQuery([apiDescriptionUrl], () => fetch(apiDescriptionUrl).then(res => {
637
- if (res.ok) {
638
- return res.text();
639
- }
640
- throw new Error(`Unable to load description document, status code: ${res.status}`);
641
- }), {
642
- enabled: apiDescriptionUrl !== '' && !apiDescriptionDocument,
643
- });
644
- const document = apiDescriptionDocument || fetchedDocument || '';
645
- const parsedDocument = elementalCore.useParsedValue(document);
646
- const bundledDocument = elementalCore.useBundleRefsIntoDocument(parsedDocument, { baseUrl: apiDescriptionUrl });
647
- const serviceNode = React__namespace.useMemo(() => transformOasToServiceNode(bundledDocument), [bundledDocument]);
648
- const exportProps = useExportDocumentProps({ originalDocument: document, bundledDocument });
649
- if (error) {
650
- return (React__namespace.createElement(mosaic.Flex, { justify: "center", alignItems: "center", w: "full", minH: "screen" },
651
- React__namespace.createElement(elementalCore.NonIdealState, { title: "Document could not be loaded", description: "The API description document could not be fetched. This could indicate connectivity problems, or issues with the server hosting the spec.", icon: "exclamation-triangle" })));
652
- }
653
- if (!bundledDocument) {
654
- return (React__namespace.createElement(mosaic.Flex, { justify: "center", alignItems: "center", w: "full", minH: "screen", color: "light" },
655
- React__namespace.createElement(mosaic.Box, { as: mosaic.Icon, icon: ['fal', 'circle-notch'], size: "3x", spin: true })));
656
- }
657
- if (!serviceNode) {
658
- return (React__namespace.createElement(mosaic.Flex, { justify: "center", alignItems: "center", w: "full", minH: "screen" },
659
- React__namespace.createElement(elementalCore.NonIdealState, { title: "Failed to parse OpenAPI file", description: "Please make sure your OpenAPI file is valid and try again" })));
660
- }
661
- return (React__namespace.createElement(elementalCore.InlineRefResolverProvider, { document: parsedDocument, maxRefDepth: maxRefDepth },
662
- layout === 'stacked' && (React__namespace.createElement(APIWithStackedLayout, { serviceNode: serviceNode, hideTryIt: hideTryIt, hideExport: hideExport, hideInlineExamples: hideInlineExamples, exportProps: exportProps, tryItCredentialsPolicy: tryItCredentialsPolicy, tryItCorsProxy: tryItCorsProxy, renderExtensionAddon: renderExtensionAddon, location: location, tryItOutDefaultServer: tryItOutDefaultServer })),
663
- layout === 'sidebar' && (React__namespace.createElement(APIWithSidebarLayout, { logo: logo, serviceNode: serviceNode, hideTryIt: hideTryIt, hideSchemas: hideSchemas, hideInternal: hideInternal, hideExport: hideExport, hideInlineExamples: hideInlineExamples, exportProps: exportProps, tryItCredentialsPolicy: tryItCredentialsPolicy, tryItCorsProxy: tryItCorsProxy, renderExtensionAddon: renderExtensionAddon, tryItOutDefaultServer: tryItOutDefaultServer, useCustomNav: useCustomNav, layout: layout })),
664
- layout === 'responsive' && (React__namespace.createElement(APIWithResponsiveSidebarLayout, { logo: logo, serviceNode: serviceNode, hideTryIt: hideTryIt, hideSchemas: hideSchemas, hideInternal: hideInternal, hideExport: hideExport, exportProps: exportProps, tryItCredentialsPolicy: tryItCredentialsPolicy, tryItCorsProxy: tryItCorsProxy, renderExtensionAddon: renderExtensionAddon, compact: isResponsiveLayoutEnabled }))));
665
- };
666
- const API = flow__default["default"](elementalCore.withRouter, elementalCore.withStyles, elementalCore.withPersistenceBoundary, elementalCore.withMosaicProvider, elementalCore.withQueryClientProvider)(APIImpl);
645
+ const propsAreWithDocument = (props) => {
646
+ return props.hasOwnProperty('apiDescriptionDocument');
647
+ };
648
+ const APIImpl = props => {
649
+ const { layout = 'sidebar', apiDescriptionUrl = '', logo, hideTryItPanel, hideTryIt, hideSamples, hideSecurityInfo, hideServerInfo, hideSchemas, hideInternal, hideExport, hideInlineExamples, tryItCredentialsPolicy, tryItCorsProxy, maxRefDepth, renderExtensionAddon, basePath, outerRouter = false, tryItOutDefaultServer, useCustomNav, } = props;
650
+ const location = reactRouterDom.useLocation();
651
+ const apiDescriptionDocument = propsAreWithDocument(props) ? props.apiDescriptionDocument : undefined;
652
+ const { isResponsiveLayoutEnabled } = elementalCore.useResponsiveLayout();
653
+ const { data: fetchedDocument, error } = reactQuery.useQuery([apiDescriptionUrl], () => fetch(apiDescriptionUrl).then(res => {
654
+ if (res.ok) {
655
+ return res.text();
656
+ }
657
+ throw new Error(`Unable to load description document, status code: ${res.status}`);
658
+ }), {
659
+ enabled: apiDescriptionUrl !== '' && !apiDescriptionDocument,
660
+ });
661
+ const document = apiDescriptionDocument || fetchedDocument || '';
662
+ const parsedDocument = elementalCore.useParsedValue(document);
663
+ const bundledDocument = elementalCore.useBundleRefsIntoDocument(parsedDocument, { baseUrl: apiDescriptionUrl });
664
+ const serviceNode = React__namespace.useMemo(() => transformOasToServiceNode(bundledDocument), [bundledDocument]);
665
+ const exportProps = useExportDocumentProps({ originalDocument: document, bundledDocument });
666
+ if (error) {
667
+ return (React__namespace.createElement(mosaic.Flex, { justify: "center", alignItems: "center", w: "full", minH: "screen" },
668
+ React__namespace.createElement(elementalCore.NonIdealState, { title: "Document could not be loaded", description: "The API description document could not be fetched. This could indicate connectivity problems, or issues with the server hosting the spec.", icon: "exclamation-triangle" })));
669
+ }
670
+ if (!bundledDocument) {
671
+ return (React__namespace.createElement(mosaic.Flex, { justify: "center", alignItems: "center", w: "full", minH: "screen", color: "light" },
672
+ React__namespace.createElement(mosaic.Box, { as: mosaic.Icon, icon: ['fal', 'circle-notch'], size: "3x", spin: true })));
673
+ }
674
+ if (!serviceNode) {
675
+ return (React__namespace.createElement(mosaic.Flex, { justify: "center", alignItems: "center", w: "full", minH: "screen" },
676
+ React__namespace.createElement(elementalCore.NonIdealState, { title: "Failed to parse OpenAPI file", description: "Please make sure your OpenAPI file is valid and try again" })));
677
+ }
678
+ return (React__namespace.createElement(elementalCore.InlineRefResolverProvider, { document: parsedDocument, maxRefDepth: maxRefDepth },
679
+ layout === 'stacked' && (React__namespace.createElement(APIWithStackedLayout, { serviceNode: serviceNode, hideTryIt: hideTryIt, hideSamples: hideSamples, hideTryItPanel: hideTryItPanel, hideSecurityInfo: hideSecurityInfo, hideServerInfo: hideServerInfo, hideExport: hideExport, hideInlineExamples: hideInlineExamples, exportProps: exportProps, tryItCredentialsPolicy: tryItCredentialsPolicy, tryItCorsProxy: tryItCorsProxy, renderExtensionAddon: renderExtensionAddon, location: location, tryItOutDefaultServer: tryItOutDefaultServer })),
680
+ layout === 'sidebar' && (React__namespace.createElement(APIWithSidebarLayout, { logo: logo, serviceNode: serviceNode, hideTryItPanel: hideTryItPanel, hideTryIt: hideTryIt, hideSamples: hideSamples, hideSecurityInfo: hideSecurityInfo, hideServerInfo: hideServerInfo, hideSchemas: hideSchemas, hideInternal: hideInternal, hideExport: hideExport, hideInlineExamples: hideInlineExamples, exportProps: exportProps, tryItCredentialsPolicy: tryItCredentialsPolicy, tryItCorsProxy: tryItCorsProxy, renderExtensionAddon: renderExtensionAddon, basePath: basePath, outerRouter: outerRouter, tryItOutDefaultServer: tryItOutDefaultServer, useCustomNav: useCustomNav, layout: layout })),
681
+ layout === 'responsive' && (React__namespace.createElement(APIWithResponsiveSidebarLayout, { logo: logo, serviceNode: serviceNode, hideTryItPanel: hideTryItPanel, hideTryIt: hideTryIt, hideSamples: hideSamples, hideSecurityInfo: hideSecurityInfo, hideServerInfo: hideServerInfo, hideSchemas: hideSchemas, hideInternal: hideInternal, hideExport: hideExport, exportProps: exportProps, tryItCredentialsPolicy: tryItCredentialsPolicy, tryItCorsProxy: tryItCorsProxy, renderExtensionAddon: renderExtensionAddon, compact: isResponsiveLayoutEnabled, basePath: basePath, outerRouter: outerRouter }))));
682
+ };
683
+ const API = flow(elementalCore.withRouter, elementalCore.withStyles, elementalCore.withPersistenceBoundary, elementalCore.withMosaicProvider, elementalCore.withQueryClientProvider)(APIImpl);
667
684
 
668
- const useGetOasNavTree = (apiDescriptionDocument) => {
669
- const parsedDocument = elementalCore.useParsedValue(apiDescriptionDocument);
670
- const bundledDocument = elementalCore.useBundleRefsIntoDocument(parsedDocument);
671
- if (!bundledDocument)
672
- return [];
673
- const groupSchemas = (tree) => {
674
- const targetTitle = 'Schemas';
675
- const newTree = tree.reduce((accumulator, currentObject) => {
676
- var _a;
677
- if (currentObject.title === targetTitle) {
678
- accumulator.matchedObject = currentObject;
679
- }
680
- else if ((_a = currentObject.id) === null || _a === void 0 ? void 0 : _a.includes(targetTitle.toLowerCase())) {
681
- accumulator.matchedObject.items = accumulator.matchedObject.items || [];
682
- accumulator.matchedObject.items.push(currentObject);
683
- }
684
- else {
685
- accumulator.others = accumulator.others || [];
686
- accumulator.others.push(currentObject);
687
- }
688
- return accumulator;
689
- }, {});
690
- const navTree = [...newTree.others, newTree.matchedObject];
691
- return navTree;
692
- };
693
- const apiTree = computeAPITree(transformOasToServiceNode(bundledDocument));
694
- return groupSchemas(apiTree);
685
+ const useGetOasNavTree = (apiDescriptionDocument) => {
686
+ const parsedDocument = elementalCore.useParsedValue(apiDescriptionDocument);
687
+ const bundledDocument = elementalCore.useBundleRefsIntoDocument(parsedDocument);
688
+ if (!bundledDocument)
689
+ return [];
690
+ const groupSchemas = (tree) => {
691
+ const targetTitle = 'Schemas';
692
+ const newTree = tree.reduce((accumulator, currentObject) => {
693
+ var _a;
694
+ if (currentObject.title === targetTitle) {
695
+ accumulator.matchedObject = currentObject;
696
+ }
697
+ else if ((_a = currentObject.id) === null || _a === void 0 ? void 0 : _a.includes(targetTitle.toLowerCase())) {
698
+ accumulator.matchedObject.items = accumulator.matchedObject.items || [];
699
+ accumulator.matchedObject.items.push(currentObject);
700
+ }
701
+ else {
702
+ accumulator.others = accumulator.others || [];
703
+ accumulator.others.push(currentObject);
704
+ }
705
+ return accumulator;
706
+ }, {});
707
+ const navTree = [...newTree.others, newTree.matchedObject];
708
+ return navTree;
709
+ };
710
+ const apiTree = computeAPITree(transformOasToServiceNode(bundledDocument));
711
+ return groupSchemas(apiTree);
695
712
  };
696
713
 
697
714
  exports.API = API;