@stoplight/elements-dev-portal 1.6.14 → 1.6.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/components/NodeContent/NodeContent.d.ts +4 -0
- package/consts.d.ts +2 -0
- package/hooks/useGetNodes.d.ts +2 -1
- package/index.esm.js +26 -7
- package/index.js +26 -7
- package/index.mjs +26 -7
- package/package.json +2 -2
- package/version.d.ts +1 -1
- package/web-components.min.js +1 -1
- package/web-components.min.js.LICENSE.txt +3 -3
|
@@ -12,3 +12,7 @@ export declare type NodeContentProps = {
|
|
|
12
12
|
refResolver?: ReferenceResolver;
|
|
13
13
|
};
|
|
14
14
|
export declare const NodeContent: ({ node, Link, hideTryIt, hideTryItPanel, hideMocking, hideExport, tryItCredentialsPolicy, tryItCorsProxy, refResolver, }: NodeContentProps) => JSX.Element;
|
|
15
|
+
export declare const getNodeUriParts: (uri: string) => {
|
|
16
|
+
fileUri: string;
|
|
17
|
+
pointer: string;
|
|
18
|
+
};
|
package/consts.d.ts
CHANGED
|
@@ -16,10 +16,12 @@ export declare const devPortalCacheKeys: {
|
|
|
16
16
|
search: () => string[];
|
|
17
17
|
searchNodes: (filters: {
|
|
18
18
|
projectIds?: string[];
|
|
19
|
+
branchSlug?: string;
|
|
19
20
|
workspaceId?: string;
|
|
20
21
|
search?: string;
|
|
21
22
|
}) => (string | {
|
|
22
23
|
projectIds?: string[] | undefined;
|
|
24
|
+
branchSlug?: string | undefined;
|
|
23
25
|
workspaceId?: string | undefined;
|
|
24
26
|
search?: string | undefined;
|
|
25
27
|
})[];
|
package/hooks/useGetNodes.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
export declare function useGetNodes({ search, workspaceId, projectIds, pause, }: {
|
|
1
|
+
export declare function useGetNodes({ search, workspaceId, projectIds, branch, pause, }: {
|
|
2
2
|
search: string;
|
|
3
3
|
workspaceId?: string;
|
|
4
4
|
projectIds?: string[];
|
|
5
|
+
branch?: string;
|
|
5
6
|
pause?: boolean;
|
|
6
7
|
}): import("react-query").UseQueryResult<import("..").NodeSearchResult[], unknown>;
|
package/index.esm.js
CHANGED
|
@@ -66,7 +66,15 @@ const LinkComponent = ({ children, href }) => {
|
|
|
66
66
|
}
|
|
67
67
|
if (href && ctx) {
|
|
68
68
|
const [node, Link] = ctx;
|
|
69
|
-
const
|
|
69
|
+
const { fileUri } = getNodeUriParts(node.uri);
|
|
70
|
+
const { fileUri: hrefFileUri } = getNodeUriParts(href);
|
|
71
|
+
let resolvedUri;
|
|
72
|
+
if (hrefFileUri) {
|
|
73
|
+
resolvedUri = resolve(dirname(fileUri), href);
|
|
74
|
+
}
|
|
75
|
+
else {
|
|
76
|
+
resolvedUri = resolve(fileUri, href);
|
|
77
|
+
}
|
|
70
78
|
const [resolvedUriWithoutAnchor, hash] = resolvedUri.split('#');
|
|
71
79
|
const decodedUrl = decodeURIComponent(href);
|
|
72
80
|
const decodedResolvedUriWithoutAnchor = decodeURIComponent(resolvedUriWithoutAnchor);
|
|
@@ -85,7 +93,15 @@ function getBundledUrl(url) {
|
|
|
85
93
|
searchParams.append('deref', 'optimizedBundle');
|
|
86
94
|
bundledUrl.search = searchParams.toString();
|
|
87
95
|
return bundledUrl.toString();
|
|
88
|
-
}
|
|
96
|
+
}
|
|
97
|
+
const getNodeUriParts = (uri) => {
|
|
98
|
+
const parts = uri.split(/(\.yaml|\.yml|\.json|\.md)/);
|
|
99
|
+
if (parts.length === 1) {
|
|
100
|
+
return { fileUri: '', pointer: parts[0] || '' };
|
|
101
|
+
}
|
|
102
|
+
const fileUri = `${parts[0] || ''}${parts[1] || ''}`;
|
|
103
|
+
return { fileUri, pointer: parts[2] || '' };
|
|
104
|
+
};
|
|
89
105
|
|
|
90
106
|
const SearchImpl = ({ isLoading, search, searchResults, isOpen, onClose, onClick, onSearch }) => {
|
|
91
107
|
const listBoxRef = React.useRef(null);
|
|
@@ -202,7 +218,7 @@ const UpgradeToStarter = () => (React__default.createElement(Flex, { as: "a", hr
|
|
|
202
218
|
React__default.createElement(Icon, { icon: faExclamationTriangle, size: "4x" }),
|
|
203
219
|
React__default.createElement(Box, { pt: 3 }, "Please upgrade your Stoplight Workspace to the Starter Plan to use Elements Dev Portal in production.")));
|
|
204
220
|
|
|
205
|
-
const appVersion = '1.6.
|
|
221
|
+
const appVersion = '1.6.17';
|
|
206
222
|
|
|
207
223
|
class ResponseError extends Error {
|
|
208
224
|
constructor(message, responseCode) {
|
|
@@ -321,6 +337,9 @@ const StoplightProjectImpl = ({ projectId, hideTryIt, hideMocking, hideExport, c
|
|
|
321
337
|
else if (!node) {
|
|
322
338
|
elem = React.createElement(NotFound, null);
|
|
323
339
|
}
|
|
340
|
+
else if ((node === null || node === void 0 ? void 0 : node.slug) && nodeSlug !== node.slug) {
|
|
341
|
+
return React.createElement(Redirect, { to: branchSlug ? `/branches/${branchSlug}/${node.slug}` : `/${node.slug}` });
|
|
342
|
+
}
|
|
324
343
|
else {
|
|
325
344
|
elem = (React.createElement(NodeContent, { node: node, Link: ReactRouterMarkdownLink, hideTryIt: hideTryIt, hideMocking: hideMocking, hideExport: hideExport, tryItCredentialsPolicy: tryItCredentialsPolicy, tryItCorsProxy: tryItCorsProxy }));
|
|
326
345
|
}
|
|
@@ -370,7 +389,7 @@ const getNodes = ({ workspaceId, branchSlug, projectIds, search, platformUrl = '
|
|
|
370
389
|
}
|
|
371
390
|
if (branchSlug) {
|
|
372
391
|
const encodedBranchSlug = encodeURIComponent(branchSlug);
|
|
373
|
-
queryParams.push(`
|
|
392
|
+
queryParams.push(`branch=${encodedBranchSlug}`);
|
|
374
393
|
}
|
|
375
394
|
const query = queryParams.length ? `?${queryParams.join('&')}` : '';
|
|
376
395
|
const encodedWorkspaceId = encodeURIComponent(fetchedWorkspaceId);
|
|
@@ -623,14 +642,14 @@ function useDebounce(value, delay, options) {
|
|
|
623
642
|
return [state, { cancel: debounced.cancel, isPending: debounced.isPending, flush: debounced.flush }];
|
|
624
643
|
}
|
|
625
644
|
|
|
626
|
-
function useGetNodes({ search, workspaceId, projectIds, pause, }) {
|
|
645
|
+
function useGetNodes({ search, workspaceId, projectIds, branch, pause, }) {
|
|
627
646
|
const { platformUrl, platformAuthToken } = React.useContext(PlatformContext);
|
|
628
647
|
const [debounceSearch] = useDebounce(search, 500);
|
|
629
648
|
return useQuery([
|
|
630
|
-
...devPortalCacheKeys.searchNodes({ projectIds, workspaceId, search: debounceSearch }),
|
|
649
|
+
...devPortalCacheKeys.searchNodes({ projectIds, branchSlug: branch, workspaceId, search: debounceSearch }),
|
|
631
650
|
platformUrl,
|
|
632
651
|
platformAuthToken,
|
|
633
|
-
], () => getNodes({ workspaceId, projectIds, search: debounceSearch, platformUrl, platformAuthToken }), { enabled: !pause, keepPreviousData: true });
|
|
652
|
+
], () => getNodes({ workspaceId, projectIds, branchSlug: branch, search: debounceSearch, platformUrl, platformAuthToken }), { enabled: !pause, keepPreviousData: true });
|
|
634
653
|
}
|
|
635
654
|
|
|
636
655
|
function useGetWorkspace({ projectIds }) {
|
package/index.js
CHANGED
|
@@ -93,7 +93,15 @@ const LinkComponent = ({ children, href }) => {
|
|
|
93
93
|
}
|
|
94
94
|
if (href && ctx) {
|
|
95
95
|
const [node, Link] = ctx;
|
|
96
|
-
const
|
|
96
|
+
const { fileUri } = getNodeUriParts(node.uri);
|
|
97
|
+
const { fileUri: hrefFileUri } = getNodeUriParts(href);
|
|
98
|
+
let resolvedUri;
|
|
99
|
+
if (hrefFileUri) {
|
|
100
|
+
resolvedUri = path.resolve(path.dirname(fileUri), href);
|
|
101
|
+
}
|
|
102
|
+
else {
|
|
103
|
+
resolvedUri = path.resolve(fileUri, href);
|
|
104
|
+
}
|
|
97
105
|
const [resolvedUriWithoutAnchor, hash] = resolvedUri.split('#');
|
|
98
106
|
const decodedUrl = decodeURIComponent(href);
|
|
99
107
|
const decodedResolvedUriWithoutAnchor = decodeURIComponent(resolvedUriWithoutAnchor);
|
|
@@ -112,7 +120,15 @@ function getBundledUrl(url) {
|
|
|
112
120
|
searchParams.append('deref', 'optimizedBundle');
|
|
113
121
|
bundledUrl.search = searchParams.toString();
|
|
114
122
|
return bundledUrl.toString();
|
|
115
|
-
}
|
|
123
|
+
}
|
|
124
|
+
const getNodeUriParts = (uri) => {
|
|
125
|
+
const parts = uri.split(/(\.yaml|\.yml|\.json|\.md)/);
|
|
126
|
+
if (parts.length === 1) {
|
|
127
|
+
return { fileUri: '', pointer: parts[0] || '' };
|
|
128
|
+
}
|
|
129
|
+
const fileUri = `${parts[0] || ''}${parts[1] || ''}`;
|
|
130
|
+
return { fileUri, pointer: parts[2] || '' };
|
|
131
|
+
};
|
|
116
132
|
|
|
117
133
|
const SearchImpl = ({ isLoading, search, searchResults, isOpen, onClose, onClick, onSearch }) => {
|
|
118
134
|
const listBoxRef = React__namespace.useRef(null);
|
|
@@ -229,7 +245,7 @@ const UpgradeToStarter = () => (React__default["default"].createElement(mosaic.F
|
|
|
229
245
|
React__default["default"].createElement(mosaic.Icon, { icon: freeSolidSvgIcons.faExclamationTriangle, size: "4x" }),
|
|
230
246
|
React__default["default"].createElement(mosaic.Box, { pt: 3 }, "Please upgrade your Stoplight Workspace to the Starter Plan to use Elements Dev Portal in production.")));
|
|
231
247
|
|
|
232
|
-
const appVersion = '1.6.
|
|
248
|
+
const appVersion = '1.6.17';
|
|
233
249
|
|
|
234
250
|
class ResponseError extends Error {
|
|
235
251
|
constructor(message, responseCode) {
|
|
@@ -348,6 +364,9 @@ const StoplightProjectImpl = ({ projectId, hideTryIt, hideMocking, hideExport, c
|
|
|
348
364
|
else if (!node) {
|
|
349
365
|
elem = React__namespace.createElement(NotFound, null);
|
|
350
366
|
}
|
|
367
|
+
else if ((node === null || node === void 0 ? void 0 : node.slug) && nodeSlug !== node.slug) {
|
|
368
|
+
return React__namespace.createElement(reactRouterDom.Redirect, { to: branchSlug ? `/branches/${branchSlug}/${node.slug}` : `/${node.slug}` });
|
|
369
|
+
}
|
|
351
370
|
else {
|
|
352
371
|
elem = (React__namespace.createElement(NodeContent, { node: node, Link: elementsCore.ReactRouterMarkdownLink, hideTryIt: hideTryIt, hideMocking: hideMocking, hideExport: hideExport, tryItCredentialsPolicy: tryItCredentialsPolicy, tryItCorsProxy: tryItCorsProxy }));
|
|
353
372
|
}
|
|
@@ -397,7 +416,7 @@ const getNodes = ({ workspaceId, branchSlug, projectIds, search, platformUrl = '
|
|
|
397
416
|
}
|
|
398
417
|
if (branchSlug) {
|
|
399
418
|
const encodedBranchSlug = encodeURIComponent(branchSlug);
|
|
400
|
-
queryParams.push(`
|
|
419
|
+
queryParams.push(`branch=${encodedBranchSlug}`);
|
|
401
420
|
}
|
|
402
421
|
const query = queryParams.length ? `?${queryParams.join('&')}` : '';
|
|
403
422
|
const encodedWorkspaceId = encodeURIComponent(fetchedWorkspaceId);
|
|
@@ -650,14 +669,14 @@ function useDebounce(value, delay, options) {
|
|
|
650
669
|
return [state, { cancel: debounced.cancel, isPending: debounced.isPending, flush: debounced.flush }];
|
|
651
670
|
}
|
|
652
671
|
|
|
653
|
-
function useGetNodes({ search, workspaceId, projectIds, pause, }) {
|
|
672
|
+
function useGetNodes({ search, workspaceId, projectIds, branch, pause, }) {
|
|
654
673
|
const { platformUrl, platformAuthToken } = React__namespace.useContext(PlatformContext);
|
|
655
674
|
const [debounceSearch] = useDebounce(search, 500);
|
|
656
675
|
return reactQuery.useQuery([
|
|
657
|
-
...devPortalCacheKeys.searchNodes({ projectIds, workspaceId, search: debounceSearch }),
|
|
676
|
+
...devPortalCacheKeys.searchNodes({ projectIds, branchSlug: branch, workspaceId, search: debounceSearch }),
|
|
658
677
|
platformUrl,
|
|
659
678
|
platformAuthToken,
|
|
660
|
-
], () => getNodes({ workspaceId, projectIds, search: debounceSearch, platformUrl, platformAuthToken }), { enabled: !pause, keepPreviousData: true });
|
|
679
|
+
], () => getNodes({ workspaceId, projectIds, branchSlug: branch, search: debounceSearch, platformUrl, platformAuthToken }), { enabled: !pause, keepPreviousData: true });
|
|
661
680
|
}
|
|
662
681
|
|
|
663
682
|
function useGetWorkspace({ projectIds }) {
|
package/index.mjs
CHANGED
|
@@ -66,7 +66,15 @@ const LinkComponent = ({ children, href }) => {
|
|
|
66
66
|
}
|
|
67
67
|
if (href && ctx) {
|
|
68
68
|
const [node, Link] = ctx;
|
|
69
|
-
const
|
|
69
|
+
const { fileUri } = getNodeUriParts(node.uri);
|
|
70
|
+
const { fileUri: hrefFileUri } = getNodeUriParts(href);
|
|
71
|
+
let resolvedUri;
|
|
72
|
+
if (hrefFileUri) {
|
|
73
|
+
resolvedUri = resolve(dirname(fileUri), href);
|
|
74
|
+
}
|
|
75
|
+
else {
|
|
76
|
+
resolvedUri = resolve(fileUri, href);
|
|
77
|
+
}
|
|
70
78
|
const [resolvedUriWithoutAnchor, hash] = resolvedUri.split('#');
|
|
71
79
|
const decodedUrl = decodeURIComponent(href);
|
|
72
80
|
const decodedResolvedUriWithoutAnchor = decodeURIComponent(resolvedUriWithoutAnchor);
|
|
@@ -85,7 +93,15 @@ function getBundledUrl(url) {
|
|
|
85
93
|
searchParams.append('deref', 'optimizedBundle');
|
|
86
94
|
bundledUrl.search = searchParams.toString();
|
|
87
95
|
return bundledUrl.toString();
|
|
88
|
-
}
|
|
96
|
+
}
|
|
97
|
+
const getNodeUriParts = (uri) => {
|
|
98
|
+
const parts = uri.split(/(\.yaml|\.yml|\.json|\.md)/);
|
|
99
|
+
if (parts.length === 1) {
|
|
100
|
+
return { fileUri: '', pointer: parts[0] || '' };
|
|
101
|
+
}
|
|
102
|
+
const fileUri = `${parts[0] || ''}${parts[1] || ''}`;
|
|
103
|
+
return { fileUri, pointer: parts[2] || '' };
|
|
104
|
+
};
|
|
89
105
|
|
|
90
106
|
const SearchImpl = ({ isLoading, search, searchResults, isOpen, onClose, onClick, onSearch }) => {
|
|
91
107
|
const listBoxRef = React.useRef(null);
|
|
@@ -202,7 +218,7 @@ const UpgradeToStarter = () => (React__default.createElement(Flex, { as: "a", hr
|
|
|
202
218
|
React__default.createElement(Icon, { icon: faExclamationTriangle, size: "4x" }),
|
|
203
219
|
React__default.createElement(Box, { pt: 3 }, "Please upgrade your Stoplight Workspace to the Starter Plan to use Elements Dev Portal in production.")));
|
|
204
220
|
|
|
205
|
-
const appVersion = '1.6.
|
|
221
|
+
const appVersion = '1.6.17';
|
|
206
222
|
|
|
207
223
|
class ResponseError extends Error {
|
|
208
224
|
constructor(message, responseCode) {
|
|
@@ -321,6 +337,9 @@ const StoplightProjectImpl = ({ projectId, hideTryIt, hideMocking, hideExport, c
|
|
|
321
337
|
else if (!node) {
|
|
322
338
|
elem = React.createElement(NotFound, null);
|
|
323
339
|
}
|
|
340
|
+
else if ((node === null || node === void 0 ? void 0 : node.slug) && nodeSlug !== node.slug) {
|
|
341
|
+
return React.createElement(Redirect, { to: branchSlug ? `/branches/${branchSlug}/${node.slug}` : `/${node.slug}` });
|
|
342
|
+
}
|
|
324
343
|
else {
|
|
325
344
|
elem = (React.createElement(NodeContent, { node: node, Link: ReactRouterMarkdownLink, hideTryIt: hideTryIt, hideMocking: hideMocking, hideExport: hideExport, tryItCredentialsPolicy: tryItCredentialsPolicy, tryItCorsProxy: tryItCorsProxy }));
|
|
326
345
|
}
|
|
@@ -370,7 +389,7 @@ const getNodes = ({ workspaceId, branchSlug, projectIds, search, platformUrl = '
|
|
|
370
389
|
}
|
|
371
390
|
if (branchSlug) {
|
|
372
391
|
const encodedBranchSlug = encodeURIComponent(branchSlug);
|
|
373
|
-
queryParams.push(`
|
|
392
|
+
queryParams.push(`branch=${encodedBranchSlug}`);
|
|
374
393
|
}
|
|
375
394
|
const query = queryParams.length ? `?${queryParams.join('&')}` : '';
|
|
376
395
|
const encodedWorkspaceId = encodeURIComponent(fetchedWorkspaceId);
|
|
@@ -623,14 +642,14 @@ function useDebounce(value, delay, options) {
|
|
|
623
642
|
return [state, { cancel: debounced.cancel, isPending: debounced.isPending, flush: debounced.flush }];
|
|
624
643
|
}
|
|
625
644
|
|
|
626
|
-
function useGetNodes({ search, workspaceId, projectIds, pause, }) {
|
|
645
|
+
function useGetNodes({ search, workspaceId, projectIds, branch, pause, }) {
|
|
627
646
|
const { platformUrl, platformAuthToken } = React.useContext(PlatformContext);
|
|
628
647
|
const [debounceSearch] = useDebounce(search, 500);
|
|
629
648
|
return useQuery([
|
|
630
|
-
...devPortalCacheKeys.searchNodes({ projectIds, workspaceId, search: debounceSearch }),
|
|
649
|
+
...devPortalCacheKeys.searchNodes({ projectIds, branchSlug: branch, workspaceId, search: debounceSearch }),
|
|
631
650
|
platformUrl,
|
|
632
651
|
platformAuthToken,
|
|
633
|
-
], () => getNodes({ workspaceId, projectIds, search: debounceSearch, platformUrl, platformAuthToken }), { enabled: !pause, keepPreviousData: true });
|
|
652
|
+
], () => getNodes({ workspaceId, projectIds, branchSlug: branch, search: debounceSearch, platformUrl, platformAuthToken }), { enabled: !pause, keepPreviousData: true });
|
|
634
653
|
}
|
|
635
654
|
|
|
636
655
|
function useGetWorkspace({ projectIds }) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stoplight/elements-dev-portal",
|
|
3
|
-
"version": "1.6.
|
|
3
|
+
"version": "1.6.17",
|
|
4
4
|
"description": "UI components for composing beautiful developer documentation.",
|
|
5
5
|
"keywords": [],
|
|
6
6
|
"main": "./index.js",
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"@fortawesome/free-solid-svg-icons": "^5.10.2",
|
|
30
30
|
"@stoplight/elements-core": "~7.5.13",
|
|
31
31
|
"@stoplight/markdown-viewer": "^5.4.2",
|
|
32
|
-
"@stoplight/mosaic": "^1.
|
|
32
|
+
"@stoplight/mosaic": "^1.16.2",
|
|
33
33
|
"@stoplight/path": "^1.3.2",
|
|
34
34
|
"@stoplight/types": "^12.0.0",
|
|
35
35
|
"classnames": "^2.2.6",
|
package/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const appVersion = "1.6.
|
|
1
|
+
export declare const appVersion = "1.6.17";
|