@stoplight/elements-dev-portal 1.6.13 → 1.6.16

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.
@@ -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
  })[];
@@ -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 resolvedUri = resolve(dirname(node.uri), href);
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.13';
221
+ const appVersion = '1.6.16';
206
222
 
207
223
  class ResponseError extends Error {
208
224
  constructor(message, responseCode) {
@@ -370,7 +386,7 @@ const getNodes = ({ workspaceId, branchSlug, projectIds, search, platformUrl = '
370
386
  }
371
387
  if (branchSlug) {
372
388
  const encodedBranchSlug = encodeURIComponent(branchSlug);
373
- queryParams.push(`branchSlug=${encodedBranchSlug}`);
389
+ queryParams.push(`branch=${encodedBranchSlug}`);
374
390
  }
375
391
  const query = queryParams.length ? `?${queryParams.join('&')}` : '';
376
392
  const encodedWorkspaceId = encodeURIComponent(fetchedWorkspaceId);
@@ -623,14 +639,14 @@ function useDebounce(value, delay, options) {
623
639
  return [state, { cancel: debounced.cancel, isPending: debounced.isPending, flush: debounced.flush }];
624
640
  }
625
641
 
626
- function useGetNodes({ search, workspaceId, projectIds, pause, }) {
642
+ function useGetNodes({ search, workspaceId, projectIds, branch, pause, }) {
627
643
  const { platformUrl, platformAuthToken } = React.useContext(PlatformContext);
628
644
  const [debounceSearch] = useDebounce(search, 500);
629
645
  return useQuery([
630
- ...devPortalCacheKeys.searchNodes({ projectIds, workspaceId, search: debounceSearch }),
646
+ ...devPortalCacheKeys.searchNodes({ projectIds, branchSlug: branch, workspaceId, search: debounceSearch }),
631
647
  platformUrl,
632
648
  platformAuthToken,
633
- ], () => getNodes({ workspaceId, projectIds, search: debounceSearch, platformUrl, platformAuthToken }), { enabled: !pause, keepPreviousData: true });
649
+ ], () => getNodes({ workspaceId, projectIds, branchSlug: branch, search: debounceSearch, platformUrl, platformAuthToken }), { enabled: !pause, keepPreviousData: true });
634
650
  }
635
651
 
636
652
  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 resolvedUri = path.resolve(path.dirname(node.uri), href);
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.13';
248
+ const appVersion = '1.6.16';
233
249
 
234
250
  class ResponseError extends Error {
235
251
  constructor(message, responseCode) {
@@ -397,7 +413,7 @@ const getNodes = ({ workspaceId, branchSlug, projectIds, search, platformUrl = '
397
413
  }
398
414
  if (branchSlug) {
399
415
  const encodedBranchSlug = encodeURIComponent(branchSlug);
400
- queryParams.push(`branchSlug=${encodedBranchSlug}`);
416
+ queryParams.push(`branch=${encodedBranchSlug}`);
401
417
  }
402
418
  const query = queryParams.length ? `?${queryParams.join('&')}` : '';
403
419
  const encodedWorkspaceId = encodeURIComponent(fetchedWorkspaceId);
@@ -650,14 +666,14 @@ function useDebounce(value, delay, options) {
650
666
  return [state, { cancel: debounced.cancel, isPending: debounced.isPending, flush: debounced.flush }];
651
667
  }
652
668
 
653
- function useGetNodes({ search, workspaceId, projectIds, pause, }) {
669
+ function useGetNodes({ search, workspaceId, projectIds, branch, pause, }) {
654
670
  const { platformUrl, platformAuthToken } = React__namespace.useContext(PlatformContext);
655
671
  const [debounceSearch] = useDebounce(search, 500);
656
672
  return reactQuery.useQuery([
657
- ...devPortalCacheKeys.searchNodes({ projectIds, workspaceId, search: debounceSearch }),
673
+ ...devPortalCacheKeys.searchNodes({ projectIds, branchSlug: branch, workspaceId, search: debounceSearch }),
658
674
  platformUrl,
659
675
  platformAuthToken,
660
- ], () => getNodes({ workspaceId, projectIds, search: debounceSearch, platformUrl, platformAuthToken }), { enabled: !pause, keepPreviousData: true });
676
+ ], () => getNodes({ workspaceId, projectIds, branchSlug: branch, search: debounceSearch, platformUrl, platformAuthToken }), { enabled: !pause, keepPreviousData: true });
661
677
  }
662
678
 
663
679
  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 resolvedUri = resolve(dirname(node.uri), href);
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.13';
221
+ const appVersion = '1.6.16';
206
222
 
207
223
  class ResponseError extends Error {
208
224
  constructor(message, responseCode) {
@@ -370,7 +386,7 @@ const getNodes = ({ workspaceId, branchSlug, projectIds, search, platformUrl = '
370
386
  }
371
387
  if (branchSlug) {
372
388
  const encodedBranchSlug = encodeURIComponent(branchSlug);
373
- queryParams.push(`branchSlug=${encodedBranchSlug}`);
389
+ queryParams.push(`branch=${encodedBranchSlug}`);
374
390
  }
375
391
  const query = queryParams.length ? `?${queryParams.join('&')}` : '';
376
392
  const encodedWorkspaceId = encodeURIComponent(fetchedWorkspaceId);
@@ -623,14 +639,14 @@ function useDebounce(value, delay, options) {
623
639
  return [state, { cancel: debounced.cancel, isPending: debounced.isPending, flush: debounced.flush }];
624
640
  }
625
641
 
626
- function useGetNodes({ search, workspaceId, projectIds, pause, }) {
642
+ function useGetNodes({ search, workspaceId, projectIds, branch, pause, }) {
627
643
  const { platformUrl, platformAuthToken } = React.useContext(PlatformContext);
628
644
  const [debounceSearch] = useDebounce(search, 500);
629
645
  return useQuery([
630
- ...devPortalCacheKeys.searchNodes({ projectIds, workspaceId, search: debounceSearch }),
646
+ ...devPortalCacheKeys.searchNodes({ projectIds, branchSlug: branch, workspaceId, search: debounceSearch }),
631
647
  platformUrl,
632
648
  platformAuthToken,
633
- ], () => getNodes({ workspaceId, projectIds, search: debounceSearch, platformUrl, platformAuthToken }), { enabled: !pause, keepPreviousData: true });
649
+ ], () => getNodes({ workspaceId, projectIds, branchSlug: branch, search: debounceSearch, platformUrl, platformAuthToken }), { enabled: !pause, keepPreviousData: true });
634
650
  }
635
651
 
636
652
  function useGetWorkspace({ projectIds }) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stoplight/elements-dev-portal",
3
- "version": "1.6.13",
3
+ "version": "1.6.16",
4
4
  "description": "UI components for composing beautiful developer documentation.",
5
5
  "keywords": [],
6
6
  "main": "./index.js",
@@ -27,9 +27,9 @@
27
27
  },
28
28
  "dependencies": {
29
29
  "@fortawesome/free-solid-svg-icons": "^5.10.2",
30
- "@stoplight/elements-core": "~7.5.12",
30
+ "@stoplight/elements-core": "~7.5.13",
31
31
  "@stoplight/markdown-viewer": "^5.4.2",
32
- "@stoplight/mosaic": "^1.15.4",
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.13";
1
+ export declare const appVersion = "1.6.16";