@stoplight/elements-dev-portal 1.6.12 → 1.6.13

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/consts.d.ts ADDED
@@ -0,0 +1,26 @@
1
+ export declare const devPortalCacheKeys: {
2
+ all: readonly ["@stoplight/elements-dev-portal/client-query"];
3
+ projects: () => readonly ["@stoplight/elements-dev-portal/client-query", "projects"];
4
+ project: (projectId: string) => readonly ["@stoplight/elements-dev-portal/client-query", "projects", string];
5
+ projectsList: () => readonly ["@stoplight/elements-dev-portal/client-query", "projects", "list"];
6
+ projectDetails: (projectId: string) => readonly ["@stoplight/elements-dev-portal/client-query", "projects", string, "details"];
7
+ branches: (projectId: string) => readonly ["@stoplight/elements-dev-portal/client-query", "projects", string, "branches"];
8
+ branch: (projectId: string, branch: string) => readonly ["@stoplight/elements-dev-portal/client-query", "projects", string, "branches", string];
9
+ branchesList: (projectId: string) => readonly ["@stoplight/elements-dev-portal/client-query", "projects", string, "branches", "list"];
10
+ branchDetails: (projectId: string, branch: string) => readonly ["@stoplight/elements-dev-portal/client-query", "projects", string, "branches", string, "details"];
11
+ branchTOC: (projectId: string, branch: string) => readonly ["@stoplight/elements-dev-portal/client-query", "projects", string, "branches", string, "toc"];
12
+ branchNodes: (projectId: string, branch: string) => readonly ["@stoplight/elements-dev-portal/client-query", "projects", string, "branches", string, "nodes"];
13
+ branchNode: (projectId: string, branch: string, node: string) => readonly ["@stoplight/elements-dev-portal/client-query", "projects", string, "branches", string, "nodes", string];
14
+ branchNodesList: (projectId: string, branch: string) => readonly ["@stoplight/elements-dev-portal/client-query", "projects", string, "branches", string, "nodes", "list"];
15
+ branchNodeDetails: (projectId: string, branch: string, node: string) => readonly ["@stoplight/elements-dev-portal/client-query", "projects", string, "branches", string, "nodes", string, "details"];
16
+ search: () => string[];
17
+ searchNodes: (filters: {
18
+ projectIds?: string[];
19
+ workspaceId?: string;
20
+ search?: string;
21
+ }) => (string | {
22
+ projectIds?: string[] | undefined;
23
+ workspaceId?: string | undefined;
24
+ search?: string | undefined;
25
+ })[];
26
+ };
@@ -1,7 +1,6 @@
1
- export declare function useGetNodes({ search, workspaceId, branchSlug, projectIds, pause, }: {
1
+ export declare function useGetNodes({ search, workspaceId, projectIds, pause, }: {
2
2
  search: string;
3
3
  workspaceId?: string;
4
- branchSlug?: string;
5
4
  projectIds?: string[];
6
5
  pause?: boolean;
7
6
  }): import("react-query").UseQueryResult<import("..").NodeSearchResult[], unknown>;
package/index.d.ts CHANGED
@@ -8,6 +8,7 @@ export type { SearchProps } from './components/Search';
8
8
  export { Search } from './components/Search';
9
9
  export type { TableOfContentsProps } from './components/TableOfContents';
10
10
  export { TableOfContents } from './components/TableOfContents';
11
+ export { devPortalCacheKeys } from './consts';
11
12
  export type { StoplightProjectProps } from './containers/StoplightProject';
12
13
  export { StoplightProject } from './containers/StoplightProject';
13
14
  export { getBranches } from './handlers/getBranches';
package/index.esm.js CHANGED
@@ -162,6 +162,29 @@ const TableOfContents = (_a) => {
162
162
  tableOfContents.hide_powered_by ? null : (React.createElement(PoweredByLink, { source: activeId, pathname: typeof window !== 'undefined' ? window.location.pathname : '', packageType: "elements-dev-portal" }))));
163
163
  };
164
164
 
165
+ const ROOT_CACHE_KEY = '@stoplight/elements-dev-portal/client-query';
166
+ const devPortalCacheKeys = {
167
+ all: [ROOT_CACHE_KEY],
168
+ projects: () => [ROOT_CACHE_KEY, 'projects'],
169
+ project: (projectId) => [...devPortalCacheKeys.projects(), projectId],
170
+ projectsList: () => [...devPortalCacheKeys.projects(), 'list'],
171
+ projectDetails: (projectId) => [...devPortalCacheKeys.project(projectId), 'details'],
172
+ branches: (projectId) => [...devPortalCacheKeys.project(projectId), 'branches'],
173
+ branch: (projectId, branch) => [...devPortalCacheKeys.branches(projectId), branch],
174
+ branchesList: (projectId) => [...devPortalCacheKeys.branches(projectId), 'list'],
175
+ branchDetails: (projectId, branch) => [...devPortalCacheKeys.branch(projectId, branch), 'details'],
176
+ branchTOC: (projectId, branch) => [...devPortalCacheKeys.branch(projectId, branch), 'toc'],
177
+ branchNodes: (projectId, branch) => [...devPortalCacheKeys.branch(projectId, branch), 'nodes'],
178
+ branchNode: (projectId, branch, node) => [...devPortalCacheKeys.branchNodes(projectId, branch), node],
179
+ branchNodesList: (projectId, branch) => [...devPortalCacheKeys.branchNodes(projectId, branch), 'list'],
180
+ branchNodeDetails: (projectId, branch, node) => [...devPortalCacheKeys.branchNode(projectId, branch, node), 'details'],
181
+ search: () => [...devPortalCacheKeys.all, 'search'],
182
+ searchNodes: (filters) => [
183
+ ...devPortalCacheKeys.search(),
184
+ filters,
185
+ ],
186
+ };
187
+
165
188
  const Forbidden = () => (React__default.createElement(Flex, { align: "center", justify: "center", flexGrow: true },
166
189
  React__default.createElement(VStack, { spacing: 4, align: "center" },
167
190
  React__default.createElement(Heading, { size: 1 }, "Forbidden"),
@@ -179,7 +202,7 @@ const UpgradeToStarter = () => (React__default.createElement(Flex, { as: "a", hr
179
202
  React__default.createElement(Icon, { icon: faExclamationTriangle, size: "4x" }),
180
203
  React__default.createElement(Box, { pt: 3 }, "Please upgrade your Stoplight Workspace to the Starter Plan to use Elements Dev Portal in production.")));
181
204
 
182
- const appVersion = '1.6.12';
205
+ const appVersion = '1.6.13';
183
206
 
184
207
  class ResponseError extends Error {
185
208
  constructor(message, responseCode) {
@@ -229,14 +252,14 @@ const getBranches = ({ projectId, platformUrl = 'https://stoplight.io', platform
229
252
 
230
253
  function useGetBranches({ projectId }) {
231
254
  const { platformUrl, platformAuthToken } = React.useContext(PlatformContext);
232
- return useQuery(['branches', projectId, platformUrl, platformAuthToken], () => getBranches({ projectId, platformUrl, platformAuthToken }), {
255
+ return useQuery([...devPortalCacheKeys.branchesList(projectId), platformUrl, platformAuthToken], () => getBranches({ projectId, platformUrl, platformAuthToken }), {
233
256
  enabled: projectId ? true : false,
234
257
  });
235
258
  }
236
259
 
237
260
  function useGetNodeContent({ nodeSlug, projectId, branchSlug, }) {
238
261
  const { platformUrl, platformAuthToken } = React.useContext(PlatformContext);
239
- return useQuery(['useNodeContent', nodeSlug, projectId, branchSlug, platformUrl, platformAuthToken], () => getNodeContent({ nodeSlug, projectId, branchSlug, platformUrl, platformAuthToken }), { enabled: nodeSlug && projectId ? true : false });
262
+ 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 });
240
263
  }
241
264
 
242
265
  const getTableOfContents = ({ projectId, branchSlug, platformUrl = 'https://stoplight.io', platformAuthToken, }) => __awaiter(void 0, void 0, void 0, function* () {
@@ -255,7 +278,7 @@ const getTableOfContents = ({ projectId, branchSlug, platformUrl = 'https://stop
255
278
 
256
279
  function useGetTableOfContents({ projectId, branchSlug }) {
257
280
  const { platformUrl, platformAuthToken } = React.useContext(PlatformContext);
258
- return useQuery(['tableOfContents', projectId, branchSlug, platformUrl, platformAuthToken], () => getTableOfContents({ projectId, branchSlug, platformUrl, platformAuthToken }), { enabled: projectId ? true : false });
281
+ return useQuery([...devPortalCacheKeys.branchTOC(projectId, branchSlug !== null && branchSlug !== void 0 ? branchSlug : ''), platformUrl, platformAuthToken], () => getTableOfContents({ projectId, branchSlug, platformUrl, platformAuthToken }), { enabled: projectId ? true : false });
259
282
  }
260
283
 
261
284
  const StoplightProjectImpl = ({ projectId, hideTryIt, hideMocking, hideExport, collapseTableOfContents = false, tryItCredentialsPolicy, tryItCorsProxy, }) => {
@@ -600,15 +623,19 @@ function useDebounce(value, delay, options) {
600
623
  return [state, { cancel: debounced.cancel, isPending: debounced.isPending, flush: debounced.flush }];
601
624
  }
602
625
 
603
- function useGetNodes({ search, workspaceId, branchSlug, projectIds, pause, }) {
626
+ function useGetNodes({ search, workspaceId, projectIds, pause, }) {
604
627
  const { platformUrl, platformAuthToken } = React.useContext(PlatformContext);
605
628
  const [debounceSearch] = useDebounce(search, 500);
606
- return useQuery(['workspaceNodes', platformUrl, platformAuthToken, workspaceId, branchSlug, projectIds, debounceSearch], () => getNodes({ workspaceId, branchSlug, projectIds, search: debounceSearch, platformUrl, platformAuthToken }), { enabled: !pause, keepPreviousData: true });
629
+ return useQuery([
630
+ ...devPortalCacheKeys.searchNodes({ projectIds, workspaceId, search: debounceSearch }),
631
+ platformUrl,
632
+ platformAuthToken,
633
+ ], () => getNodes({ workspaceId, projectIds, search: debounceSearch, platformUrl, platformAuthToken }), { enabled: !pause, keepPreviousData: true });
607
634
  }
608
635
 
609
636
  function useGetWorkspace({ projectIds }) {
610
637
  const { platformUrl, platformAuthToken } = React.useContext(PlatformContext);
611
- return useQuery(['useWorkspace', projectIds, platformUrl, platformAuthToken], () => getWorkspace({ projectIds, platformUrl, platformAuthToken }));
638
+ return useQuery([...devPortalCacheKeys.searchNodes({ projectIds }), platformUrl, platformAuthToken], () => getWorkspace({ projectIds, platformUrl, platformAuthToken }));
612
639
  }
613
640
 
614
- export { BranchSelector, DevPortalProvider, NodeContent, ResponseError, Search, StoplightProject, TableOfContents, getBranches, getNodeContent, getNodes, getTableOfContents, getWorkspace, useGetBranches, useGetNodeContent, useGetNodes, useGetTableOfContents, useGetWorkspace };
641
+ export { BranchSelector, DevPortalProvider, NodeContent, ResponseError, Search, StoplightProject, TableOfContents, devPortalCacheKeys, getBranches, getNodeContent, getNodes, getTableOfContents, getWorkspace, useGetBranches, useGetNodeContent, useGetNodes, useGetTableOfContents, useGetWorkspace };
package/index.js CHANGED
@@ -189,6 +189,29 @@ const TableOfContents = (_a) => {
189
189
  tableOfContents.hide_powered_by ? null : (React__namespace.createElement(elementsCore.PoweredByLink, { source: activeId, pathname: typeof window !== 'undefined' ? window.location.pathname : '', packageType: "elements-dev-portal" }))));
190
190
  };
191
191
 
192
+ const ROOT_CACHE_KEY = '@stoplight/elements-dev-portal/client-query';
193
+ const devPortalCacheKeys = {
194
+ all: [ROOT_CACHE_KEY],
195
+ projects: () => [ROOT_CACHE_KEY, 'projects'],
196
+ project: (projectId) => [...devPortalCacheKeys.projects(), projectId],
197
+ projectsList: () => [...devPortalCacheKeys.projects(), 'list'],
198
+ projectDetails: (projectId) => [...devPortalCacheKeys.project(projectId), 'details'],
199
+ branches: (projectId) => [...devPortalCacheKeys.project(projectId), 'branches'],
200
+ branch: (projectId, branch) => [...devPortalCacheKeys.branches(projectId), branch],
201
+ branchesList: (projectId) => [...devPortalCacheKeys.branches(projectId), 'list'],
202
+ branchDetails: (projectId, branch) => [...devPortalCacheKeys.branch(projectId, branch), 'details'],
203
+ branchTOC: (projectId, branch) => [...devPortalCacheKeys.branch(projectId, branch), 'toc'],
204
+ branchNodes: (projectId, branch) => [...devPortalCacheKeys.branch(projectId, branch), 'nodes'],
205
+ branchNode: (projectId, branch, node) => [...devPortalCacheKeys.branchNodes(projectId, branch), node],
206
+ branchNodesList: (projectId, branch) => [...devPortalCacheKeys.branchNodes(projectId, branch), 'list'],
207
+ branchNodeDetails: (projectId, branch, node) => [...devPortalCacheKeys.branchNode(projectId, branch, node), 'details'],
208
+ search: () => [...devPortalCacheKeys.all, 'search'],
209
+ searchNodes: (filters) => [
210
+ ...devPortalCacheKeys.search(),
211
+ filters,
212
+ ],
213
+ };
214
+
192
215
  const Forbidden = () => (React__default["default"].createElement(mosaic.Flex, { align: "center", justify: "center", flexGrow: true },
193
216
  React__default["default"].createElement(mosaic.VStack, { spacing: 4, align: "center" },
194
217
  React__default["default"].createElement(mosaic.Heading, { size: 1 }, "Forbidden"),
@@ -206,7 +229,7 @@ const UpgradeToStarter = () => (React__default["default"].createElement(mosaic.F
206
229
  React__default["default"].createElement(mosaic.Icon, { icon: freeSolidSvgIcons.faExclamationTriangle, size: "4x" }),
207
230
  React__default["default"].createElement(mosaic.Box, { pt: 3 }, "Please upgrade your Stoplight Workspace to the Starter Plan to use Elements Dev Portal in production.")));
208
231
 
209
- const appVersion = '1.6.12';
232
+ const appVersion = '1.6.13';
210
233
 
211
234
  class ResponseError extends Error {
212
235
  constructor(message, responseCode) {
@@ -256,14 +279,14 @@ const getBranches = ({ projectId, platformUrl = 'https://stoplight.io', platform
256
279
 
257
280
  function useGetBranches({ projectId }) {
258
281
  const { platformUrl, platformAuthToken } = React__namespace.useContext(PlatformContext);
259
- return reactQuery.useQuery(['branches', projectId, platformUrl, platformAuthToken], () => getBranches({ projectId, platformUrl, platformAuthToken }), {
282
+ return reactQuery.useQuery([...devPortalCacheKeys.branchesList(projectId), platformUrl, platformAuthToken], () => getBranches({ projectId, platformUrl, platformAuthToken }), {
260
283
  enabled: projectId ? true : false,
261
284
  });
262
285
  }
263
286
 
264
287
  function useGetNodeContent({ nodeSlug, projectId, branchSlug, }) {
265
288
  const { platformUrl, platformAuthToken } = React__namespace.useContext(PlatformContext);
266
- return reactQuery.useQuery(['useNodeContent', nodeSlug, projectId, branchSlug, platformUrl, platformAuthToken], () => getNodeContent({ nodeSlug, projectId, branchSlug, platformUrl, platformAuthToken }), { enabled: nodeSlug && projectId ? true : false });
289
+ 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 });
267
290
  }
268
291
 
269
292
  const getTableOfContents = ({ projectId, branchSlug, platformUrl = 'https://stoplight.io', platformAuthToken, }) => __awaiter(void 0, void 0, void 0, function* () {
@@ -282,7 +305,7 @@ const getTableOfContents = ({ projectId, branchSlug, platformUrl = 'https://stop
282
305
 
283
306
  function useGetTableOfContents({ projectId, branchSlug }) {
284
307
  const { platformUrl, platformAuthToken } = React__namespace.useContext(PlatformContext);
285
- return reactQuery.useQuery(['tableOfContents', projectId, branchSlug, platformUrl, platformAuthToken], () => getTableOfContents({ projectId, branchSlug, platformUrl, platformAuthToken }), { enabled: projectId ? true : false });
308
+ return reactQuery.useQuery([...devPortalCacheKeys.branchTOC(projectId, branchSlug !== null && branchSlug !== void 0 ? branchSlug : ''), platformUrl, platformAuthToken], () => getTableOfContents({ projectId, branchSlug, platformUrl, platformAuthToken }), { enabled: projectId ? true : false });
286
309
  }
287
310
 
288
311
  const StoplightProjectImpl = ({ projectId, hideTryIt, hideMocking, hideExport, collapseTableOfContents = false, tryItCredentialsPolicy, tryItCorsProxy, }) => {
@@ -627,15 +650,19 @@ function useDebounce(value, delay, options) {
627
650
  return [state, { cancel: debounced.cancel, isPending: debounced.isPending, flush: debounced.flush }];
628
651
  }
629
652
 
630
- function useGetNodes({ search, workspaceId, branchSlug, projectIds, pause, }) {
653
+ function useGetNodes({ search, workspaceId, projectIds, pause, }) {
631
654
  const { platformUrl, platformAuthToken } = React__namespace.useContext(PlatformContext);
632
655
  const [debounceSearch] = useDebounce(search, 500);
633
- return reactQuery.useQuery(['workspaceNodes', platformUrl, platformAuthToken, workspaceId, branchSlug, projectIds, debounceSearch], () => getNodes({ workspaceId, branchSlug, projectIds, search: debounceSearch, platformUrl, platformAuthToken }), { enabled: !pause, keepPreviousData: true });
656
+ return reactQuery.useQuery([
657
+ ...devPortalCacheKeys.searchNodes({ projectIds, workspaceId, search: debounceSearch }),
658
+ platformUrl,
659
+ platformAuthToken,
660
+ ], () => getNodes({ workspaceId, projectIds, search: debounceSearch, platformUrl, platformAuthToken }), { enabled: !pause, keepPreviousData: true });
634
661
  }
635
662
 
636
663
  function useGetWorkspace({ projectIds }) {
637
664
  const { platformUrl, platformAuthToken } = React__namespace.useContext(PlatformContext);
638
- return reactQuery.useQuery(['useWorkspace', projectIds, platformUrl, platformAuthToken], () => getWorkspace({ projectIds, platformUrl, platformAuthToken }));
665
+ return reactQuery.useQuery([...devPortalCacheKeys.searchNodes({ projectIds }), platformUrl, platformAuthToken], () => getWorkspace({ projectIds, platformUrl, platformAuthToken }));
639
666
  }
640
667
 
641
668
  exports.BranchSelector = BranchSelector;
@@ -645,6 +672,7 @@ exports.ResponseError = ResponseError;
645
672
  exports.Search = Search;
646
673
  exports.StoplightProject = StoplightProject;
647
674
  exports.TableOfContents = TableOfContents;
675
+ exports.devPortalCacheKeys = devPortalCacheKeys;
648
676
  exports.getBranches = getBranches;
649
677
  exports.getNodeContent = getNodeContent;
650
678
  exports.getNodes = getNodes;
package/index.mjs CHANGED
@@ -162,6 +162,29 @@ const TableOfContents = (_a) => {
162
162
  tableOfContents.hide_powered_by ? null : (React.createElement(PoweredByLink, { source: activeId, pathname: typeof window !== 'undefined' ? window.location.pathname : '', packageType: "elements-dev-portal" }))));
163
163
  };
164
164
 
165
+ const ROOT_CACHE_KEY = '@stoplight/elements-dev-portal/client-query';
166
+ const devPortalCacheKeys = {
167
+ all: [ROOT_CACHE_KEY],
168
+ projects: () => [ROOT_CACHE_KEY, 'projects'],
169
+ project: (projectId) => [...devPortalCacheKeys.projects(), projectId],
170
+ projectsList: () => [...devPortalCacheKeys.projects(), 'list'],
171
+ projectDetails: (projectId) => [...devPortalCacheKeys.project(projectId), 'details'],
172
+ branches: (projectId) => [...devPortalCacheKeys.project(projectId), 'branches'],
173
+ branch: (projectId, branch) => [...devPortalCacheKeys.branches(projectId), branch],
174
+ branchesList: (projectId) => [...devPortalCacheKeys.branches(projectId), 'list'],
175
+ branchDetails: (projectId, branch) => [...devPortalCacheKeys.branch(projectId, branch), 'details'],
176
+ branchTOC: (projectId, branch) => [...devPortalCacheKeys.branch(projectId, branch), 'toc'],
177
+ branchNodes: (projectId, branch) => [...devPortalCacheKeys.branch(projectId, branch), 'nodes'],
178
+ branchNode: (projectId, branch, node) => [...devPortalCacheKeys.branchNodes(projectId, branch), node],
179
+ branchNodesList: (projectId, branch) => [...devPortalCacheKeys.branchNodes(projectId, branch), 'list'],
180
+ branchNodeDetails: (projectId, branch, node) => [...devPortalCacheKeys.branchNode(projectId, branch, node), 'details'],
181
+ search: () => [...devPortalCacheKeys.all, 'search'],
182
+ searchNodes: (filters) => [
183
+ ...devPortalCacheKeys.search(),
184
+ filters,
185
+ ],
186
+ };
187
+
165
188
  const Forbidden = () => (React__default.createElement(Flex, { align: "center", justify: "center", flexGrow: true },
166
189
  React__default.createElement(VStack, { spacing: 4, align: "center" },
167
190
  React__default.createElement(Heading, { size: 1 }, "Forbidden"),
@@ -179,7 +202,7 @@ const UpgradeToStarter = () => (React__default.createElement(Flex, { as: "a", hr
179
202
  React__default.createElement(Icon, { icon: faExclamationTriangle, size: "4x" }),
180
203
  React__default.createElement(Box, { pt: 3 }, "Please upgrade your Stoplight Workspace to the Starter Plan to use Elements Dev Portal in production.")));
181
204
 
182
- const appVersion = '1.6.12';
205
+ const appVersion = '1.6.13';
183
206
 
184
207
  class ResponseError extends Error {
185
208
  constructor(message, responseCode) {
@@ -229,14 +252,14 @@ const getBranches = ({ projectId, platformUrl = 'https://stoplight.io', platform
229
252
 
230
253
  function useGetBranches({ projectId }) {
231
254
  const { platformUrl, platformAuthToken } = React.useContext(PlatformContext);
232
- return useQuery(['branches', projectId, platformUrl, platformAuthToken], () => getBranches({ projectId, platformUrl, platformAuthToken }), {
255
+ return useQuery([...devPortalCacheKeys.branchesList(projectId), platformUrl, platformAuthToken], () => getBranches({ projectId, platformUrl, platformAuthToken }), {
233
256
  enabled: projectId ? true : false,
234
257
  });
235
258
  }
236
259
 
237
260
  function useGetNodeContent({ nodeSlug, projectId, branchSlug, }) {
238
261
  const { platformUrl, platformAuthToken } = React.useContext(PlatformContext);
239
- return useQuery(['useNodeContent', nodeSlug, projectId, branchSlug, platformUrl, platformAuthToken], () => getNodeContent({ nodeSlug, projectId, branchSlug, platformUrl, platformAuthToken }), { enabled: nodeSlug && projectId ? true : false });
262
+ 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 });
240
263
  }
241
264
 
242
265
  const getTableOfContents = ({ projectId, branchSlug, platformUrl = 'https://stoplight.io', platformAuthToken, }) => __awaiter(void 0, void 0, void 0, function* () {
@@ -255,7 +278,7 @@ const getTableOfContents = ({ projectId, branchSlug, platformUrl = 'https://stop
255
278
 
256
279
  function useGetTableOfContents({ projectId, branchSlug }) {
257
280
  const { platformUrl, platformAuthToken } = React.useContext(PlatformContext);
258
- return useQuery(['tableOfContents', projectId, branchSlug, platformUrl, platformAuthToken], () => getTableOfContents({ projectId, branchSlug, platformUrl, platformAuthToken }), { enabled: projectId ? true : false });
281
+ return useQuery([...devPortalCacheKeys.branchTOC(projectId, branchSlug !== null && branchSlug !== void 0 ? branchSlug : ''), platformUrl, platformAuthToken], () => getTableOfContents({ projectId, branchSlug, platformUrl, platformAuthToken }), { enabled: projectId ? true : false });
259
282
  }
260
283
 
261
284
  const StoplightProjectImpl = ({ projectId, hideTryIt, hideMocking, hideExport, collapseTableOfContents = false, tryItCredentialsPolicy, tryItCorsProxy, }) => {
@@ -600,15 +623,19 @@ function useDebounce(value, delay, options) {
600
623
  return [state, { cancel: debounced.cancel, isPending: debounced.isPending, flush: debounced.flush }];
601
624
  }
602
625
 
603
- function useGetNodes({ search, workspaceId, branchSlug, projectIds, pause, }) {
626
+ function useGetNodes({ search, workspaceId, projectIds, pause, }) {
604
627
  const { platformUrl, platformAuthToken } = React.useContext(PlatformContext);
605
628
  const [debounceSearch] = useDebounce(search, 500);
606
- return useQuery(['workspaceNodes', platformUrl, platformAuthToken, workspaceId, branchSlug, projectIds, debounceSearch], () => getNodes({ workspaceId, branchSlug, projectIds, search: debounceSearch, platformUrl, platformAuthToken }), { enabled: !pause, keepPreviousData: true });
629
+ return useQuery([
630
+ ...devPortalCacheKeys.searchNodes({ projectIds, workspaceId, search: debounceSearch }),
631
+ platformUrl,
632
+ platformAuthToken,
633
+ ], () => getNodes({ workspaceId, projectIds, search: debounceSearch, platformUrl, platformAuthToken }), { enabled: !pause, keepPreviousData: true });
607
634
  }
608
635
 
609
636
  function useGetWorkspace({ projectIds }) {
610
637
  const { platformUrl, platformAuthToken } = React.useContext(PlatformContext);
611
- return useQuery(['useWorkspace', projectIds, platformUrl, platformAuthToken], () => getWorkspace({ projectIds, platformUrl, platformAuthToken }));
638
+ return useQuery([...devPortalCacheKeys.searchNodes({ projectIds }), platformUrl, platformAuthToken], () => getWorkspace({ projectIds, platformUrl, platformAuthToken }));
612
639
  }
613
640
 
614
- export { BranchSelector, DevPortalProvider, NodeContent, ResponseError, Search, StoplightProject, TableOfContents, getBranches, getNodeContent, getNodes, getTableOfContents, getWorkspace, useGetBranches, useGetNodeContent, useGetNodes, useGetTableOfContents, useGetWorkspace };
641
+ export { BranchSelector, DevPortalProvider, NodeContent, ResponseError, Search, StoplightProject, TableOfContents, devPortalCacheKeys, getBranches, getNodeContent, getNodes, getTableOfContents, getWorkspace, useGetBranches, useGetNodeContent, useGetNodes, useGetTableOfContents, useGetWorkspace };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stoplight/elements-dev-portal",
3
- "version": "1.6.12",
3
+ "version": "1.6.13",
4
4
  "description": "UI components for composing beautiful developer documentation.",
5
5
  "keywords": [],
6
6
  "main": "./index.js",