@jpmorganchase/elemental-dev-portal 2.9.2 → 2.10.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.
@@ -1,15 +1,2 @@
1
- export declare const branches: ({
2
- id: number;
3
- slug: string;
4
- is_default: boolean;
5
- is_published: boolean;
6
- projectId: number;
7
- name: string;
8
- } | {
9
- id: number;
10
- slug: string;
11
- is_default: boolean;
12
- is_published: boolean;
13
- projectId: number;
14
- name?: undefined;
15
- })[];
1
+ import { Branch } from '../../types';
2
+ export declare const branches: Branch[];
@@ -2,6 +2,7 @@ import * as React from 'react';
2
2
  export declare type DevPortalProviderProps = {
3
3
  platformUrl?: string;
4
4
  platformAuthToken?: string;
5
+ isLoggedIn?: boolean;
5
6
  };
6
7
  export declare const PlatformContext: React.Context<DevPortalProviderProps>;
7
8
  export declare const DevPortalProvider: React.FC<DevPortalProviderProps>;
@@ -7,9 +7,10 @@ export declare type NodeContentProps = {
7
7
  Link: CustomLinkComponent;
8
8
  hideMocking?: boolean;
9
9
  refResolver?: ReferenceResolver;
10
+ maxRefDepth?: number;
10
11
  onExportRequest?: (type: 'original' | 'bundled') => void;
11
12
  } & DocsBaseProps & DocsLayoutProps;
12
- export declare const NodeContent: ({ node, Link, hideMocking, refResolver, tryItCorsProxy, tryItCredentialsPolicy, nodeHasChanged, nodeUnsupported, compact, hideTryIt, hideTryItPanel, hideExport, onExportRequest, }: NodeContentProps) => JSX.Element;
13
+ export declare const NodeContent: ({ node, Link, hideMocking, refResolver, maxRefDepth, tryItCorsProxy, tryItCredentialsPolicy, nodeHasChanged, nodeUnsupported, compact, hideTryIt, hideTryItPanel, hideExport, onExportRequest, }: NodeContentProps) => JSX.Element;
13
14
  export declare const getNodeUriParts: (uri: string) => {
14
15
  fileUri: string;
15
16
  pointer: string;
@@ -0,0 +1,16 @@
1
+ import { NodeSearchResult, ProjectTableOfContents } from '../../types';
2
+ declare type SearchOverlayProps = {
3
+ isFetching: boolean;
4
+ search: string;
5
+ setSearch: (search: string) => void;
6
+ data?: NodeSearchResult[];
7
+ toc?: ProjectTableOfContents;
8
+ nodeSlug?: string;
9
+ projectSlug?: string;
10
+ branchSlug?: string;
11
+ isSearchShowing: boolean;
12
+ onClose: () => void;
13
+ onClick: (item?: NodeSearchResult) => void;
14
+ };
15
+ export declare const SearchOverlay: ({ isFetching, search, setSearch, data, toc, nodeSlug, projectSlug, branchSlug, isSearchShowing, onClose, onClick, }: SearchOverlayProps) => JSX.Element;
16
+ export {};
@@ -1,6 +1,6 @@
1
- import { Branch } from '../types';
1
+ import { Branches } from '../types';
2
2
  export declare const getBranches: ({ projectId, platformUrl, platformAuthToken, }: {
3
3
  projectId: string;
4
4
  platformUrl?: string | undefined;
5
5
  platformAuthToken?: string | undefined;
6
- }) => Promise<Branch[]>;
6
+ }) => Promise<Branches>;
@@ -1,3 +1,3 @@
1
1
  export declare function useGetBranches({ projectId }: {
2
2
  projectId: string;
3
- }): import("react-query").UseQueryResult<import("..").Branch[], unknown>;
3
+ }): import("react-query").UseQueryResult<import("../types").Branches, unknown>;
package/index.esm.js CHANGED
@@ -1,11 +1,11 @@
1
1
  import { Menu, FieldButton, Modal, Input, Box, Icon, ListBox, ListBoxItem, Flex, VStack, Heading } from '@stoplight/mosaic';
2
2
  import * as React from 'react';
3
3
  import React__default, { useRef, useEffect, useMemo, useCallback, useState } from 'react';
4
- import { withPersistenceBoundary, withQueryClientProvider, withMosaicProvider, MarkdownComponentsProvider, MockingProvider, Docs, withStyles, NodeTypeIconDefs, NodeTypeColors, TableOfContents as TableOfContents$1, PoweredByLink, useRouter, RouterTypeContext, findFirstNode, ReactRouterMarkdownLink, SidebarLayout } from '@jpmorganchase/elemental-core';
4
+ import { withPersistenceBoundary, withQueryClientProvider, withMosaicProvider, MarkdownComponentsProvider, LinkHeading, MockingProvider, Docs, withStyles, NodeTypeIconDefs, NodeTypeColors, TableOfContents as TableOfContents$1, PoweredByLink, useRouter, RouterTypeContext, findFirstNode, ReactRouterMarkdownLink, SidebarLayout } from '@jpmorganchase/elemental-core';
5
5
  import { resolve, dirname } from '@stoplight/path';
6
6
  import { NodeType } from '@stoplight/types';
7
7
  import flow from 'lodash/flow.js';
8
- import { Route, useParams, useHistory, Redirect, Link } from 'react-router-dom';
8
+ import { Switch, Route, useParams, useHistory, Redirect, Link } from 'react-router-dom';
9
9
  import { useQuery } from 'react-query';
10
10
 
11
11
  const BranchSelector = ({ branchSlug, branches, onChange }) => {
@@ -23,7 +23,7 @@ const BranchSelector = ({ branchSlug, branches, onChange }) => {
23
23
  onChange: handleChange,
24
24
  value: (currentBranch === null || currentBranch === void 0 ? void 0 : currentBranch.slug) || '',
25
25
  children: branches.map(branch => ({
26
- label: branch.name || branch.slug,
26
+ title: branch.name || branch.slug,
27
27
  value: branch.slug,
28
28
  meta: branch.is_default ? 'Default' : undefined,
29
29
  })),
@@ -32,15 +32,66 @@ const BranchSelector = ({ branchSlug, branches, onChange }) => {
32
32
  };
33
33
 
34
34
  const PlatformContext = React.createContext({ platformUrl: 'https://stoplight.io' });
35
- const PlatformProvider = ({ platformUrl = 'https://stoplight.io', platformAuthToken, children, }) => {
36
- return React.createElement(PlatformContext.Provider, { value: { platformUrl, platformAuthToken } }, children);
35
+ const PlatformProvider = ({ platformUrl = 'https://stoplight.io', platformAuthToken, isLoggedIn, children, }) => {
36
+ return (React.createElement(PlatformContext.Provider, { value: { platformUrl, platformAuthToken, isLoggedIn } }, children));
37
37
  };
38
38
  const DevPortalProvider = withPersistenceBoundary(withQueryClientProvider(withMosaicProvider(PlatformProvider)));
39
39
 
40
- const NodeContent = ({ node, Link, hideMocking, refResolver, tryItCorsProxy, tryItCredentialsPolicy, nodeHasChanged, nodeUnsupported, compact, hideTryIt, hideTryItPanel, hideExport, onExportRequest, }) => {
40
+ /*! *****************************************************************************
41
+ Copyright (c) Microsoft Corporation.
42
+
43
+ Permission to use, copy, modify, and/or distribute this software for any
44
+ purpose with or without fee is hereby granted.
45
+
46
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
47
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
48
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
49
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
50
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
51
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
52
+ PERFORMANCE OF THIS SOFTWARE.
53
+ ***************************************************************************** */
54
+
55
+ function __rest(s, e) {
56
+ var t = {};
57
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
58
+ t[p] = s[p];
59
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
60
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
61
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
62
+ t[p[i]] = s[p[i]];
63
+ }
64
+ return t;
65
+ }
66
+
67
+ function __awaiter(thisArg, _arguments, P, generator) {
68
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
69
+ return new (P || (P = Promise))(function (resolve, reject) {
70
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
71
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
72
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
73
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
74
+ });
75
+ }
76
+
77
+ const NodeContent = ({ node, Link, hideMocking, refResolver, maxRefDepth, tryItCorsProxy, tryItCredentialsPolicy, nodeHasChanged, nodeUnsupported, compact, hideTryIt, hideTryItPanel, hideExport, onExportRequest, }) => {
41
78
  var _a, _b, _c, _d;
42
79
  return (React.createElement(NodeLinkContext.Provider, { value: [node, Link] },
43
- React.createElement(MarkdownComponentsProvider, { value: { a: LinkComponent } },
80
+ React.createElement(MarkdownComponentsProvider, { value: {
81
+ a: LinkComponent,
82
+ h2: (_a) => {
83
+ var props = __rest(_a, ["color"]);
84
+ return React.createElement(LinkHeading, Object.assign({ size: 2 }, props));
85
+ },
86
+ h3: (_a) => {
87
+ var props = __rest(_a, ["color"]);
88
+ return React.createElement(LinkHeading, Object.assign({ size: 3 }, props));
89
+ },
90
+ h4: (_a) => {
91
+ var props = __rest(_a, ["color"]);
92
+ return React.createElement(LinkHeading, Object.assign({ size: 4 }, props));
93
+ },
94
+ } },
44
95
  React.createElement(MockingProvider, { mockUrl: node.links.mock_url, hideMocking: hideMocking },
45
96
  React.createElement(Docs, { nodeType: node.type, nodeData: node.data, nodeTitle: node.title, layoutOptions: {
46
97
  compact,
@@ -49,7 +100,7 @@ const NodeContent = ({ node, Link, hideMocking, refResolver, tryItCorsProxy, try
49
100
  hideExport: hideExport ||
50
101
  ((_b = (_a = node.links.export_url) !== null && _a !== void 0 ? _a : node.links.export_original_file_url) !== null && _b !== void 0 ? _b : node.links.export_bundled_file_url) ===
51
102
  undefined,
52
- }, useNodeForRefResolving: true, refResolver: refResolver, tryItCorsProxy: tryItCorsProxy, exportProps: [NodeType.HttpService, NodeType.Model].includes(node.type)
103
+ }, useNodeForRefResolving: true, refResolver: refResolver, maxRefDepth: maxRefDepth, tryItCorsProxy: tryItCorsProxy, exportProps: [NodeType.HttpService, NodeType.Model].includes(node.type)
53
104
  ? {
54
105
  original: onExportRequest
55
106
  ? { onPress: () => onExportRequest('original') }
@@ -164,43 +215,6 @@ const SearchResultsList = ({ searchResults, onClick, isEmbedded, showDivider = t
164
215
  const SearchResults = flow(withStyles, withPersistenceBoundary, withMosaicProvider, withQueryClientProvider)(SearchResultsList);
165
216
  const Search = flow(withStyles, withPersistenceBoundary, withMosaicProvider, withQueryClientProvider)(SearchImpl);
166
217
 
167
- /*! *****************************************************************************
168
- Copyright (c) Microsoft Corporation.
169
-
170
- Permission to use, copy, modify, and/or distribute this software for any
171
- purpose with or without fee is hereby granted.
172
-
173
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
174
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
175
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
176
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
177
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
178
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
179
- PERFORMANCE OF THIS SOFTWARE.
180
- ***************************************************************************** */
181
-
182
- function __rest(s, e) {
183
- var t = {};
184
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
185
- t[p] = s[p];
186
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
187
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
188
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
189
- t[p[i]] = s[p[i]];
190
- }
191
- return t;
192
- }
193
-
194
- function __awaiter(thisArg, _arguments, P, generator) {
195
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
196
- return new (P || (P = Promise))(function (resolve, reject) {
197
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
198
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
199
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
200
- step((generator = generator.apply(thisArg, _arguments || [])).next());
201
- });
202
- }
203
-
204
218
  const TableOfContents = (_a) => {
205
219
  var { tableOfContents, activeId, Link, collapseTableOfContents = false, externalScrollbar, isInResponsiveMode = false, onLinkClick } = _a, boxProps = __rest(_a, ["tableOfContents", "activeId", "Link", "collapseTableOfContents", "externalScrollbar", "isInResponsiveMode", "onLinkClick"]);
206
220
  return (React.createElement(Flex, Object.assign({ bg: isInResponsiveMode ? 'canvas' : 'canvas-100' }, boxProps, { flexDirection: "col", maxH: "full" }),
@@ -249,7 +263,7 @@ const UpgradeToStarter = () => (React__default.createElement(Flex, { as: "a", hr
249
263
  React__default.createElement(Icon, { icon: ['fas', 'exclamation-triangle'], size: "4x" }),
250
264
  React__default.createElement(Box, { pt: 3 }, "Please upgrade your Stoplight Workspace to the Starter Plan to use Elements Dev Portal in production.")));
251
265
 
252
- const appVersion = '2.9.2';
266
+ const appVersion = '2.10.1';
253
267
 
254
268
  class ResponseError extends Error {
255
269
  constructor(message, responseCode) {
@@ -294,15 +308,15 @@ const getBranches = ({ projectId, platformUrl = 'https://stoplight.io', platform
294
308
  });
295
309
 
296
310
  function useGetBranches({ projectId }) {
297
- const { platformUrl, platformAuthToken } = React.useContext(PlatformContext);
298
- return useQuery([...devPortalCacheKeys.branchesList(projectId), platformUrl, platformAuthToken], () => getBranches({ projectId, platformUrl, platformAuthToken }), {
311
+ const { platformUrl, platformAuthToken, isLoggedIn } = React.useContext(PlatformContext);
312
+ return useQuery([...devPortalCacheKeys.branchesList(projectId), platformUrl, isLoggedIn], () => getBranches({ projectId, platformUrl, platformAuthToken }), {
299
313
  enabled: projectId ? true : false,
300
314
  });
301
315
  }
302
316
 
303
317
  function useGetNodeContent({ nodeSlug, projectId, branchSlug, }) {
304
- const { platformUrl, platformAuthToken } = React.useContext(PlatformContext);
305
- return useQuery([...devPortalCacheKeys.branchNodeDetails(projectId, branchSlug !== null && branchSlug !== void 0 ? branchSlug : '', nodeSlug), platformUrl, platformAuthToken], () => getNodeContent({ nodeSlug, projectId, branchSlug, platformUrl, platformAuthToken }), { enabled: nodeSlug && projectId ? true : false });
318
+ const { platformUrl, platformAuthToken, isLoggedIn } = React.useContext(PlatformContext);
319
+ return useQuery([...devPortalCacheKeys.branchNodeDetails(projectId, branchSlug !== null && branchSlug !== void 0 ? branchSlug : '', nodeSlug), platformUrl, isLoggedIn], () => getNodeContent({ nodeSlug, projectId, branchSlug, platformUrl, platformAuthToken }), { enabled: nodeSlug && projectId ? true : false });
306
320
  }
307
321
 
308
322
  const getTableOfContents = ({ projectId, branchSlug, platformUrl = 'https://stoplight.io', platformAuthToken, }) => __awaiter(void 0, void 0, void 0, function* () {
@@ -320,8 +334,8 @@ const getTableOfContents = ({ projectId, branchSlug, platformUrl = 'https://stop
320
334
  });
321
335
 
322
336
  function useGetTableOfContents({ projectId, branchSlug }) {
323
- const { platformUrl, platformAuthToken } = React.useContext(PlatformContext);
324
- return useQuery([...devPortalCacheKeys.branchTOC(projectId, branchSlug !== null && branchSlug !== void 0 ? branchSlug : ''), platformUrl, platformAuthToken], () => getTableOfContents({ projectId, branchSlug, platformUrl, platformAuthToken }), { enabled: projectId ? true : false });
337
+ const { platformUrl, platformAuthToken, isLoggedIn } = React.useContext(PlatformContext);
338
+ return useQuery([...devPortalCacheKeys.branchTOC(projectId, branchSlug !== null && branchSlug !== void 0 ? branchSlug : ''), platformUrl, isLoggedIn], () => getTableOfContents({ projectId, branchSlug, platformUrl, platformAuthToken }), { enabled: projectId ? true : false });
325
339
  }
326
340
 
327
341
  const StoplightProjectImpl = ({ projectId, hideTryIt, hideMocking, hideExport, collapseTableOfContents = false, tryItCredentialsPolicy, tryItCorsProxy, }) => {
@@ -377,7 +391,7 @@ const StoplightProjectImpl = ({ projectId, hideTryIt, hideMocking, hideExport, c
377
391
  }
378
392
  };
379
393
  return (React.createElement(SidebarLayout, { ref: container, sidebar: React.createElement(React.Fragment, null,
380
- branches && branches.length > 1 ? (React.createElement(BranchSelector, { branchSlug: branchSlug, branches: branches, onChange: branch => {
394
+ branches && branches.items.length > 1 ? (React.createElement(BranchSelector, { branchSlug: branchSlug, branches: branches.items, onChange: branch => {
381
395
  const encodedBranchSlug = encodeURIComponent(branch.slug);
382
396
  history.push(branch.is_default ? `/${nodeSlug}` : `/branches/${encodedBranchSlug}/${nodeSlug}`);
383
397
  } })) : null,
@@ -389,12 +403,13 @@ const StoplightProjectRouter = (_a) => {
389
403
  return (React.createElement(DevPortalProvider, { platformUrl: platformUrl },
390
404
  React.createElement(RouterTypeContext.Provider, { value: router },
391
405
  React.createElement(Router, Object.assign({}, routerProps, { key: basePath }),
392
- React.createElement(Route, { path: "/branches/:branchSlug/:nodeSlug", exact: true },
393
- React.createElement(StoplightProjectImpl, Object.assign({}, props))),
394
- React.createElement(Route, { path: "/:nodeSlug", exact: true },
395
- React.createElement(StoplightProjectImpl, Object.assign({}, props))),
396
- React.createElement(Route, { path: "/", exact: true },
397
- React.createElement(StoplightProjectImpl, Object.assign({}, props)))))));
406
+ React.createElement(Switch, null,
407
+ React.createElement(Route, { path: "/branches/:branchSlug/:nodeSlug+", exact: true },
408
+ React.createElement(StoplightProjectImpl, Object.assign({}, props))),
409
+ React.createElement(Route, { path: "/:nodeSlug+", exact: true },
410
+ React.createElement(StoplightProjectImpl, Object.assign({}, props))),
411
+ React.createElement(Route, { path: "/", exact: true },
412
+ React.createElement(StoplightProjectImpl, Object.assign({}, props))))))));
398
413
  };
399
414
  const StoplightProject = withStyles(StoplightProjectRouter);
400
415
 
@@ -675,12 +690,12 @@ function useDebounce(value, delay, options) {
675
690
  }
676
691
 
677
692
  function useGetNodes({ search, workspaceId, projectIds, branch, pause, }) {
678
- const { platformUrl, platformAuthToken } = React.useContext(PlatformContext);
693
+ const { platformUrl, platformAuthToken, isLoggedIn } = React.useContext(PlatformContext);
679
694
  const [debounceSearch] = useDebounce(search, 500);
680
695
  return useQuery([
681
696
  ...devPortalCacheKeys.searchNodes({ projectIds, branchSlug: branch, workspaceId, search: debounceSearch }),
682
697
  platformUrl,
683
- platformAuthToken,
698
+ isLoggedIn,
684
699
  ], () => getNodes({ workspaceId, projectIds, branchSlug: branch, search: debounceSearch, platformUrl, platformAuthToken }), { enabled: !pause, keepPreviousData: true });
685
700
  }
686
701
 
package/index.js CHANGED
@@ -50,7 +50,7 @@ const BranchSelector = ({ branchSlug, branches, onChange }) => {
50
50
  onChange: handleChange,
51
51
  value: (currentBranch === null || currentBranch === void 0 ? void 0 : currentBranch.slug) || '',
52
52
  children: branches.map(branch => ({
53
- label: branch.name || branch.slug,
53
+ title: branch.name || branch.slug,
54
54
  value: branch.slug,
55
55
  meta: branch.is_default ? 'Default' : undefined,
56
56
  })),
@@ -59,15 +59,66 @@ const BranchSelector = ({ branchSlug, branches, onChange }) => {
59
59
  };
60
60
 
61
61
  const PlatformContext = React__namespace.createContext({ platformUrl: 'https://stoplight.io' });
62
- const PlatformProvider = ({ platformUrl = 'https://stoplight.io', platformAuthToken, children, }) => {
63
- return React__namespace.createElement(PlatformContext.Provider, { value: { platformUrl, platformAuthToken } }, children);
62
+ const PlatformProvider = ({ platformUrl = 'https://stoplight.io', platformAuthToken, isLoggedIn, children, }) => {
63
+ return (React__namespace.createElement(PlatformContext.Provider, { value: { platformUrl, platformAuthToken, isLoggedIn } }, children));
64
64
  };
65
65
  const DevPortalProvider = elementalCore.withPersistenceBoundary(elementalCore.withQueryClientProvider(elementalCore.withMosaicProvider(PlatformProvider)));
66
66
 
67
- const NodeContent = ({ node, Link, hideMocking, refResolver, tryItCorsProxy, tryItCredentialsPolicy, nodeHasChanged, nodeUnsupported, compact, hideTryIt, hideTryItPanel, hideExport, onExportRequest, }) => {
67
+ /*! *****************************************************************************
68
+ Copyright (c) Microsoft Corporation.
69
+
70
+ Permission to use, copy, modify, and/or distribute this software for any
71
+ purpose with or without fee is hereby granted.
72
+
73
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
74
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
75
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
76
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
77
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
78
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
79
+ PERFORMANCE OF THIS SOFTWARE.
80
+ ***************************************************************************** */
81
+
82
+ function __rest(s, e) {
83
+ var t = {};
84
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
85
+ t[p] = s[p];
86
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
87
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
88
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
89
+ t[p[i]] = s[p[i]];
90
+ }
91
+ return t;
92
+ }
93
+
94
+ function __awaiter(thisArg, _arguments, P, generator) {
95
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
96
+ return new (P || (P = Promise))(function (resolve, reject) {
97
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
98
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
99
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
100
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
101
+ });
102
+ }
103
+
104
+ const NodeContent = ({ node, Link, hideMocking, refResolver, maxRefDepth, tryItCorsProxy, tryItCredentialsPolicy, nodeHasChanged, nodeUnsupported, compact, hideTryIt, hideTryItPanel, hideExport, onExportRequest, }) => {
68
105
  var _a, _b, _c, _d;
69
106
  return (React__namespace.createElement(NodeLinkContext.Provider, { value: [node, Link] },
70
- React__namespace.createElement(elementalCore.MarkdownComponentsProvider, { value: { a: LinkComponent } },
107
+ React__namespace.createElement(elementalCore.MarkdownComponentsProvider, { value: {
108
+ a: LinkComponent,
109
+ h2: (_a) => {
110
+ var props = __rest(_a, ["color"]);
111
+ return React__namespace.createElement(elementalCore.LinkHeading, Object.assign({ size: 2 }, props));
112
+ },
113
+ h3: (_a) => {
114
+ var props = __rest(_a, ["color"]);
115
+ return React__namespace.createElement(elementalCore.LinkHeading, Object.assign({ size: 3 }, props));
116
+ },
117
+ h4: (_a) => {
118
+ var props = __rest(_a, ["color"]);
119
+ return React__namespace.createElement(elementalCore.LinkHeading, Object.assign({ size: 4 }, props));
120
+ },
121
+ } },
71
122
  React__namespace.createElement(elementalCore.MockingProvider, { mockUrl: node.links.mock_url, hideMocking: hideMocking },
72
123
  React__namespace.createElement(elementalCore.Docs, { nodeType: node.type, nodeData: node.data, nodeTitle: node.title, layoutOptions: {
73
124
  compact,
@@ -76,7 +127,7 @@ const NodeContent = ({ node, Link, hideMocking, refResolver, tryItCorsProxy, try
76
127
  hideExport: hideExport ||
77
128
  ((_b = (_a = node.links.export_url) !== null && _a !== void 0 ? _a : node.links.export_original_file_url) !== null && _b !== void 0 ? _b : node.links.export_bundled_file_url) ===
78
129
  undefined,
79
- }, useNodeForRefResolving: true, refResolver: refResolver, tryItCorsProxy: tryItCorsProxy, exportProps: [types.NodeType.HttpService, types.NodeType.Model].includes(node.type)
130
+ }, useNodeForRefResolving: true, refResolver: refResolver, maxRefDepth: maxRefDepth, tryItCorsProxy: tryItCorsProxy, exportProps: [types.NodeType.HttpService, types.NodeType.Model].includes(node.type)
80
131
  ? {
81
132
  original: onExportRequest
82
133
  ? { onPress: () => onExportRequest('original') }
@@ -191,43 +242,6 @@ const SearchResultsList = ({ searchResults, onClick, isEmbedded, showDivider = t
191
242
  const SearchResults = flow__default["default"](elementalCore.withStyles, elementalCore.withPersistenceBoundary, elementalCore.withMosaicProvider, elementalCore.withQueryClientProvider)(SearchResultsList);
192
243
  const Search = flow__default["default"](elementalCore.withStyles, elementalCore.withPersistenceBoundary, elementalCore.withMosaicProvider, elementalCore.withQueryClientProvider)(SearchImpl);
193
244
 
194
- /*! *****************************************************************************
195
- Copyright (c) Microsoft Corporation.
196
-
197
- Permission to use, copy, modify, and/or distribute this software for any
198
- purpose with or without fee is hereby granted.
199
-
200
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
201
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
202
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
203
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
204
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
205
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
206
- PERFORMANCE OF THIS SOFTWARE.
207
- ***************************************************************************** */
208
-
209
- function __rest(s, e) {
210
- var t = {};
211
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
212
- t[p] = s[p];
213
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
214
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
215
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
216
- t[p[i]] = s[p[i]];
217
- }
218
- return t;
219
- }
220
-
221
- function __awaiter(thisArg, _arguments, P, generator) {
222
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
223
- return new (P || (P = Promise))(function (resolve, reject) {
224
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
225
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
226
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
227
- step((generator = generator.apply(thisArg, _arguments || [])).next());
228
- });
229
- }
230
-
231
245
  const TableOfContents = (_a) => {
232
246
  var { tableOfContents, activeId, Link, collapseTableOfContents = false, externalScrollbar, isInResponsiveMode = false, onLinkClick } = _a, boxProps = __rest(_a, ["tableOfContents", "activeId", "Link", "collapseTableOfContents", "externalScrollbar", "isInResponsiveMode", "onLinkClick"]);
233
247
  return (React__namespace.createElement(mosaic.Flex, Object.assign({ bg: isInResponsiveMode ? 'canvas' : 'canvas-100' }, boxProps, { flexDirection: "col", maxH: "full" }),
@@ -276,7 +290,7 @@ const UpgradeToStarter = () => (React__default["default"].createElement(mosaic.F
276
290
  React__default["default"].createElement(mosaic.Icon, { icon: ['fas', 'exclamation-triangle'], size: "4x" }),
277
291
  React__default["default"].createElement(mosaic.Box, { pt: 3 }, "Please upgrade your Stoplight Workspace to the Starter Plan to use Elements Dev Portal in production.")));
278
292
 
279
- const appVersion = '2.9.2';
293
+ const appVersion = '2.10.1';
280
294
 
281
295
  class ResponseError extends Error {
282
296
  constructor(message, responseCode) {
@@ -321,15 +335,15 @@ const getBranches = ({ projectId, platformUrl = 'https://stoplight.io', platform
321
335
  });
322
336
 
323
337
  function useGetBranches({ projectId }) {
324
- const { platformUrl, platformAuthToken } = React__namespace.useContext(PlatformContext);
325
- return reactQuery.useQuery([...devPortalCacheKeys.branchesList(projectId), platformUrl, platformAuthToken], () => getBranches({ projectId, platformUrl, platformAuthToken }), {
338
+ const { platformUrl, platformAuthToken, isLoggedIn } = React__namespace.useContext(PlatformContext);
339
+ return reactQuery.useQuery([...devPortalCacheKeys.branchesList(projectId), platformUrl, isLoggedIn], () => getBranches({ projectId, platformUrl, platformAuthToken }), {
326
340
  enabled: projectId ? true : false,
327
341
  });
328
342
  }
329
343
 
330
344
  function useGetNodeContent({ nodeSlug, projectId, branchSlug, }) {
331
- const { platformUrl, platformAuthToken } = React__namespace.useContext(PlatformContext);
332
- return reactQuery.useQuery([...devPortalCacheKeys.branchNodeDetails(projectId, branchSlug !== null && branchSlug !== void 0 ? branchSlug : '', nodeSlug), platformUrl, platformAuthToken], () => getNodeContent({ nodeSlug, projectId, branchSlug, platformUrl, platformAuthToken }), { enabled: nodeSlug && projectId ? true : false });
345
+ const { platformUrl, platformAuthToken, isLoggedIn } = React__namespace.useContext(PlatformContext);
346
+ return reactQuery.useQuery([...devPortalCacheKeys.branchNodeDetails(projectId, branchSlug !== null && branchSlug !== void 0 ? branchSlug : '', nodeSlug), platformUrl, isLoggedIn], () => getNodeContent({ nodeSlug, projectId, branchSlug, platformUrl, platformAuthToken }), { enabled: nodeSlug && projectId ? true : false });
333
347
  }
334
348
 
335
349
  const getTableOfContents = ({ projectId, branchSlug, platformUrl = 'https://stoplight.io', platformAuthToken, }) => __awaiter(void 0, void 0, void 0, function* () {
@@ -347,8 +361,8 @@ const getTableOfContents = ({ projectId, branchSlug, platformUrl = 'https://stop
347
361
  });
348
362
 
349
363
  function useGetTableOfContents({ projectId, branchSlug }) {
350
- const { platformUrl, platformAuthToken } = React__namespace.useContext(PlatformContext);
351
- return reactQuery.useQuery([...devPortalCacheKeys.branchTOC(projectId, branchSlug !== null && branchSlug !== void 0 ? branchSlug : ''), platformUrl, platformAuthToken], () => getTableOfContents({ projectId, branchSlug, platformUrl, platformAuthToken }), { enabled: projectId ? true : false });
364
+ const { platformUrl, platformAuthToken, isLoggedIn } = React__namespace.useContext(PlatformContext);
365
+ return reactQuery.useQuery([...devPortalCacheKeys.branchTOC(projectId, branchSlug !== null && branchSlug !== void 0 ? branchSlug : ''), platformUrl, isLoggedIn], () => getTableOfContents({ projectId, branchSlug, platformUrl, platformAuthToken }), { enabled: projectId ? true : false });
352
366
  }
353
367
 
354
368
  const StoplightProjectImpl = ({ projectId, hideTryIt, hideMocking, hideExport, collapseTableOfContents = false, tryItCredentialsPolicy, tryItCorsProxy, }) => {
@@ -404,7 +418,7 @@ const StoplightProjectImpl = ({ projectId, hideTryIt, hideMocking, hideExport, c
404
418
  }
405
419
  };
406
420
  return (React__namespace.createElement(elementalCore.SidebarLayout, { ref: container, sidebar: React__namespace.createElement(React__namespace.Fragment, null,
407
- branches && branches.length > 1 ? (React__namespace.createElement(BranchSelector, { branchSlug: branchSlug, branches: branches, onChange: branch => {
421
+ branches && branches.items.length > 1 ? (React__namespace.createElement(BranchSelector, { branchSlug: branchSlug, branches: branches.items, onChange: branch => {
408
422
  const encodedBranchSlug = encodeURIComponent(branch.slug);
409
423
  history.push(branch.is_default ? `/${nodeSlug}` : `/branches/${encodedBranchSlug}/${nodeSlug}`);
410
424
  } })) : null,
@@ -416,12 +430,13 @@ const StoplightProjectRouter = (_a) => {
416
430
  return (React__namespace.createElement(DevPortalProvider, { platformUrl: platformUrl },
417
431
  React__namespace.createElement(elementalCore.RouterTypeContext.Provider, { value: router },
418
432
  React__namespace.createElement(Router, Object.assign({}, routerProps, { key: basePath }),
419
- React__namespace.createElement(reactRouterDom.Route, { path: "/branches/:branchSlug/:nodeSlug", exact: true },
420
- React__namespace.createElement(StoplightProjectImpl, Object.assign({}, props))),
421
- React__namespace.createElement(reactRouterDom.Route, { path: "/:nodeSlug", exact: true },
422
- React__namespace.createElement(StoplightProjectImpl, Object.assign({}, props))),
423
- React__namespace.createElement(reactRouterDom.Route, { path: "/", exact: true },
424
- React__namespace.createElement(StoplightProjectImpl, Object.assign({}, props)))))));
433
+ React__namespace.createElement(reactRouterDom.Switch, null,
434
+ React__namespace.createElement(reactRouterDom.Route, { path: "/branches/:branchSlug/:nodeSlug+", exact: true },
435
+ React__namespace.createElement(StoplightProjectImpl, Object.assign({}, props))),
436
+ React__namespace.createElement(reactRouterDom.Route, { path: "/:nodeSlug+", exact: true },
437
+ React__namespace.createElement(StoplightProjectImpl, Object.assign({}, props))),
438
+ React__namespace.createElement(reactRouterDom.Route, { path: "/", exact: true },
439
+ React__namespace.createElement(StoplightProjectImpl, Object.assign({}, props))))))));
425
440
  };
426
441
  const StoplightProject = elementalCore.withStyles(StoplightProjectRouter);
427
442
 
@@ -702,12 +717,12 @@ function useDebounce(value, delay, options) {
702
717
  }
703
718
 
704
719
  function useGetNodes({ search, workspaceId, projectIds, branch, pause, }) {
705
- const { platformUrl, platformAuthToken } = React__namespace.useContext(PlatformContext);
720
+ const { platformUrl, platformAuthToken, isLoggedIn } = React__namespace.useContext(PlatformContext);
706
721
  const [debounceSearch] = useDebounce(search, 500);
707
722
  return reactQuery.useQuery([
708
723
  ...devPortalCacheKeys.searchNodes({ projectIds, branchSlug: branch, workspaceId, search: debounceSearch }),
709
724
  platformUrl,
710
- platformAuthToken,
725
+ isLoggedIn,
711
726
  ], () => getNodes({ workspaceId, projectIds, branchSlug: branch, search: debounceSearch, platformUrl, platformAuthToken }), { enabled: !pause, keepPreviousData: true });
712
727
  }
713
728