@stoplight/elements-dev-portal 1.6.4 → 1.6.8

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,4 +1,4 @@
1
- import { CustomLinkComponent } from '@stoplight/elements-core';
1
+ import { CustomLinkComponent, ReferenceResolver } from '@stoplight/elements-core';
2
2
  import { Node } from '../../types';
3
3
  export declare type NodeContentProps = {
4
4
  node: Node;
@@ -9,5 +9,6 @@ export declare type NodeContentProps = {
9
9
  hideExport?: boolean;
10
10
  tryItCredentialsPolicy?: 'omit' | 'include' | 'same-origin';
11
11
  tryItCorsProxy?: string;
12
+ refResolver?: ReferenceResolver;
12
13
  };
13
- export declare const NodeContent: ({ node, Link, hideTryIt, hideTryItPanel, hideMocking, hideExport, tryItCredentialsPolicy, tryItCorsProxy, }: NodeContentProps) => JSX.Element;
14
+ export declare const NodeContent: ({ node, Link, hideTryIt, hideTryItPanel, hideMocking, hideExport, tryItCredentialsPolicy, tryItCorsProxy, refResolver, }: NodeContentProps) => JSX.Element;
package/index.esm.js CHANGED
@@ -38,7 +38,7 @@ const PlatformProvider = ({ platformUrl = 'https://stoplight.io', platformAuthTo
38
38
  };
39
39
  const DevPortalProvider = withPersistenceBoundary(withQueryClientProvider(withMosaicProvider(PlatformProvider)));
40
40
 
41
- const NodeContent = ({ node, Link, hideTryIt, hideTryItPanel, hideMocking, hideExport, tryItCredentialsPolicy, tryItCorsProxy, }) => {
41
+ const NodeContent = ({ node, Link, hideTryIt, hideTryItPanel, hideMocking, hideExport, tryItCredentialsPolicy, tryItCorsProxy, refResolver, }) => {
42
42
  return (React.createElement(NodeLinkContext.Provider, { value: [node, Link] },
43
43
  React.createElement(MarkdownComponentsProvider, { value: { a: LinkComponent } },
44
44
  React.createElement(MockingProvider, { mockUrl: node.links.mock_url, hideMocking: hideMocking },
@@ -46,7 +46,7 @@ const NodeContent = ({ node, Link, hideTryIt, hideTryItPanel, hideMocking, hideE
46
46
  hideTryIt: hideTryIt,
47
47
  hideTryItPanel: hideTryItPanel,
48
48
  hideExport: hideExport || node.links.export_url === undefined,
49
- }, useNodeForRefResolving: true, tryItCorsProxy: tryItCorsProxy, exportProps: [NodeType.HttpService, NodeType.Model].includes(node.type)
49
+ }, useNodeForRefResolving: true, refResolver: refResolver, tryItCorsProxy: tryItCorsProxy, exportProps: [NodeType.HttpService, NodeType.Model].includes(node.type)
50
50
  ? {
51
51
  original: {
52
52
  href: node.links.export_url,
@@ -72,7 +72,7 @@ const LinkComponent = ({ children, href }) => {
72
72
  const decodedResolvedUriWithoutAnchor = decodeURIComponent(resolvedUriWithoutAnchor);
73
73
  const edge = node.outbound_edges.find(edge => edge.uri === decodedUrl || edge.uri === decodedResolvedUriWithoutAnchor);
74
74
  if (edge) {
75
- return React.createElement(Link, { to: `${edge.slug}${hash && `#${hash}`}` }, children);
75
+ return React.createElement(Link, { to: `${edge.slug}${hash ? `#${hash}` : ''}` }, children);
76
76
  }
77
77
  }
78
78
  return React.createElement("a", { href: href }, children);
@@ -179,7 +179,7 @@ const UpgradeToStarter = () => (React__default.createElement(Flex, { as: "a", hr
179
179
  React__default.createElement(Icon, { icon: faExclamationTriangle, size: "4x" }),
180
180
  React__default.createElement(Box, { pt: 3 }, "Please upgrade your Stoplight Workspace to the Starter Plan to use Elements Dev Portal in production.")));
181
181
 
182
- const appVersion = '1.6.4';
182
+ const appVersion = '1.6.8';
183
183
 
184
184
  class ResponseError extends Error {
185
185
  constructor(message, responseCode) {
@@ -190,8 +190,11 @@ class ResponseError extends Error {
190
190
  }
191
191
  const getNodeContent = ({ nodeSlug, projectId, branchSlug, platformUrl = 'https://stoplight.io', platformAuthToken, }) => __awaiter(void 0, void 0, void 0, function* () {
192
192
  const nodeId = getNodeIdFromSlug(nodeSlug);
193
- const branchQuery = branchSlug ? `?branch=${branchSlug}` : '';
194
- const response = yield fetch(`${platformUrl}/api/v1/projects/${projectId}/nodes/${nodeId}${branchQuery}`, {
193
+ const encodedNodeId = encodeURIComponent(nodeId);
194
+ const encodedProjectId = encodeURIComponent(projectId);
195
+ const encodedBranchSlug = branchSlug ? encodeURIComponent(branchSlug) : '';
196
+ const branchQuery = encodedBranchSlug ? `?branch=${encodedBranchSlug}` : '';
197
+ const response = yield fetch(`${platformUrl}/api/v1/projects/${encodedProjectId}/nodes/${encodedNodeId}${branchQuery}`, {
195
198
  headers: Object.assign({ 'Stoplight-Elements-Version': appVersion }, (platformAuthToken && { Authorization: `Bearer ${platformAuthToken}` })),
196
199
  });
197
200
  const data = yield response.json();
@@ -213,7 +216,8 @@ function getNodeIdFromSlug(nodeSlug) {
213
216
  }
214
217
 
215
218
  const getBranches = ({ projectId, platformUrl = 'https://stoplight.io', platformAuthToken, }) => __awaiter(void 0, void 0, void 0, function* () {
216
- const response = yield fetch(`${platformUrl}/api/v1/projects/${projectId}/branches`, {
219
+ const encodedProjectId = encodeURIComponent(projectId);
220
+ const response = yield fetch(`${platformUrl}/api/v1/projects/${encodedProjectId}/branches`, {
217
221
  headers: Object.assign({ 'Stoplight-Elements-Version': appVersion }, (platformAuthToken && { Authorization: `Bearer ${platformAuthToken}` })),
218
222
  });
219
223
  const data = yield response.json();
@@ -236,8 +240,10 @@ function useGetNodeContent({ nodeSlug, projectId, branchSlug, }) {
236
240
  }
237
241
 
238
242
  const getTableOfContents = ({ projectId, branchSlug, platformUrl = 'https://stoplight.io', platformAuthToken, }) => __awaiter(void 0, void 0, void 0, function* () {
239
- const branchQuery = branchSlug ? `?branch=${branchSlug}` : '';
240
- const response = yield fetch(`${platformUrl}/api/v1/projects/${projectId}/table-of-contents${branchQuery}`, {
243
+ const encodedProjectId = encodeURIComponent(projectId);
244
+ const encodedBranchSlug = branchSlug ? encodeURIComponent(branchSlug) : '';
245
+ const branchQuery = encodedBranchSlug ? `?branch=${encodedBranchSlug}` : '';
246
+ const response = yield fetch(`${platformUrl}/api/v1/projects/${encodedProjectId}/table-of-contents${branchQuery}`, {
241
247
  headers: Object.assign({ 'Stoplight-Elements-Version': appVersion }, (platformAuthToken && { Authorization: `Bearer ${platformAuthToken}` })),
242
248
  });
243
249
  const data = yield response.json();
@@ -322,23 +328,30 @@ const getNodes = ({ workspaceId, branchSlug, projectIds, search, platformUrl = '
322
328
  const queryParams = [];
323
329
  let fetchedWorkspaceId = workspaceId || '';
324
330
  if (!workspaceId && (projectIds === null || projectIds === void 0 ? void 0 : projectIds.length)) {
325
- const response = yield fetch(`${platformUrl}/api/v1/projects/${projectIds[0]}`, {
331
+ const encodedProjectId = encodeURIComponent(projectIds[0]);
332
+ const response = yield fetch(`${platformUrl}/api/v1/projects/${encodedProjectId}`, {
326
333
  headers: Object.assign({ 'Stoplight-Elements-Version': appVersion }, (platformAuthToken && { Authorization: `Bearer ${platformAuthToken}` })),
327
334
  });
328
335
  const data = yield response.json();
329
336
  fetchedWorkspaceId = data.workspace.id;
330
337
  }
331
338
  if (projectIds && projectIds.length) {
332
- queryParams.push(...projectIds.map((projectId, index) => `project_ids[${index}]=${projectId}`));
339
+ queryParams.push(...projectIds.map((projectId, index) => {
340
+ const encodedProjectId = encodeURIComponent(projectId);
341
+ return `project_ids[${index}]=${encodedProjectId}`;
342
+ }));
333
343
  }
334
344
  if (search) {
335
- queryParams.push(`search=${search}`);
345
+ const encodedSearch = encodeURIComponent(search);
346
+ queryParams.push(`search=${encodedSearch}`);
336
347
  }
337
348
  if (branchSlug) {
338
- queryParams.push(`branchSlug=${branchSlug}`);
349
+ const encodedBranchSlug = encodeURIComponent(branchSlug);
350
+ queryParams.push(`branchSlug=${encodedBranchSlug}`);
339
351
  }
340
352
  const query = queryParams.length ? `?${queryParams.join('&')}` : '';
341
- const response = yield fetch(`${platformUrl}/api/v1/workspaces/${fetchedWorkspaceId}/nodes${query}`, {
353
+ const encodedWorkspaceId = encodeURIComponent(fetchedWorkspaceId);
354
+ const response = yield fetch(`${platformUrl}/api/v1/workspaces/${encodedWorkspaceId}/nodes${query}`, {
342
355
  headers: Object.assign({ 'Stoplight-Elements-Version': appVersion }, (platformAuthToken && { Authorization: `Bearer ${platformAuthToken}` })),
343
356
  });
344
357
  const data = yield response.json();
@@ -349,7 +362,8 @@ const getNodes = ({ workspaceId, branchSlug, projectIds, search, platformUrl = '
349
362
  });
350
363
 
351
364
  const getWorkspace = ({ projectIds, platformUrl = 'https://stoplight.io', platformAuthToken, }) => __awaiter(void 0, void 0, void 0, function* () {
352
- const response = yield fetch(`${platformUrl}/api/v1/projects/${projectIds[0]}`, {
365
+ const encodedProjectId = encodeURIComponent(projectIds[0]);
366
+ const response = yield fetch(`${platformUrl}/api/v1/projects/${encodedProjectId}`, {
353
367
  headers: Object.assign({ 'Stoplight-Elements-Version': appVersion }, (platformAuthToken && { Authorization: `Bearer ${platformAuthToken}` })),
354
368
  });
355
369
  const data = yield response.json();
package/index.js CHANGED
@@ -65,7 +65,7 @@ const PlatformProvider = ({ platformUrl = 'https://stoplight.io', platformAuthTo
65
65
  };
66
66
  const DevPortalProvider = elementsCore.withPersistenceBoundary(elementsCore.withQueryClientProvider(elementsCore.withMosaicProvider(PlatformProvider)));
67
67
 
68
- const NodeContent = ({ node, Link, hideTryIt, hideTryItPanel, hideMocking, hideExport, tryItCredentialsPolicy, tryItCorsProxy, }) => {
68
+ const NodeContent = ({ node, Link, hideTryIt, hideTryItPanel, hideMocking, hideExport, tryItCredentialsPolicy, tryItCorsProxy, refResolver, }) => {
69
69
  return (React__namespace.createElement(NodeLinkContext.Provider, { value: [node, Link] },
70
70
  React__namespace.createElement(elementsCore.MarkdownComponentsProvider, { value: { a: LinkComponent } },
71
71
  React__namespace.createElement(elementsCore.MockingProvider, { mockUrl: node.links.mock_url, hideMocking: hideMocking },
@@ -73,7 +73,7 @@ const NodeContent = ({ node, Link, hideTryIt, hideTryItPanel, hideMocking, hideE
73
73
  hideTryIt: hideTryIt,
74
74
  hideTryItPanel: hideTryItPanel,
75
75
  hideExport: hideExport || node.links.export_url === undefined,
76
- }, useNodeForRefResolving: true, tryItCorsProxy: tryItCorsProxy, exportProps: [types.NodeType.HttpService, types.NodeType.Model].includes(node.type)
76
+ }, useNodeForRefResolving: true, refResolver: refResolver, tryItCorsProxy: tryItCorsProxy, exportProps: [types.NodeType.HttpService, types.NodeType.Model].includes(node.type)
77
77
  ? {
78
78
  original: {
79
79
  href: node.links.export_url,
@@ -99,7 +99,7 @@ const LinkComponent = ({ children, href }) => {
99
99
  const decodedResolvedUriWithoutAnchor = decodeURIComponent(resolvedUriWithoutAnchor);
100
100
  const edge = node.outbound_edges.find(edge => edge.uri === decodedUrl || edge.uri === decodedResolvedUriWithoutAnchor);
101
101
  if (edge) {
102
- return React__namespace.createElement(Link, { to: `${edge.slug}${hash && `#${hash}`}` }, children);
102
+ return React__namespace.createElement(Link, { to: `${edge.slug}${hash ? `#${hash}` : ''}` }, children);
103
103
  }
104
104
  }
105
105
  return React__namespace.createElement("a", { href: href }, children);
@@ -206,7 +206,7 @@ const UpgradeToStarter = () => (React__default["default"].createElement(mosaic.F
206
206
  React__default["default"].createElement(mosaic.Icon, { icon: freeSolidSvgIcons.faExclamationTriangle, size: "4x" }),
207
207
  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
208
 
209
- const appVersion = '1.6.4';
209
+ const appVersion = '1.6.8';
210
210
 
211
211
  class ResponseError extends Error {
212
212
  constructor(message, responseCode) {
@@ -217,8 +217,11 @@ class ResponseError extends Error {
217
217
  }
218
218
  const getNodeContent = ({ nodeSlug, projectId, branchSlug, platformUrl = 'https://stoplight.io', platformAuthToken, }) => __awaiter(void 0, void 0, void 0, function* () {
219
219
  const nodeId = getNodeIdFromSlug(nodeSlug);
220
- const branchQuery = branchSlug ? `?branch=${branchSlug}` : '';
221
- const response = yield fetch(`${platformUrl}/api/v1/projects/${projectId}/nodes/${nodeId}${branchQuery}`, {
220
+ const encodedNodeId = encodeURIComponent(nodeId);
221
+ const encodedProjectId = encodeURIComponent(projectId);
222
+ const encodedBranchSlug = branchSlug ? encodeURIComponent(branchSlug) : '';
223
+ const branchQuery = encodedBranchSlug ? `?branch=${encodedBranchSlug}` : '';
224
+ const response = yield fetch(`${platformUrl}/api/v1/projects/${encodedProjectId}/nodes/${encodedNodeId}${branchQuery}`, {
222
225
  headers: Object.assign({ 'Stoplight-Elements-Version': appVersion }, (platformAuthToken && { Authorization: `Bearer ${platformAuthToken}` })),
223
226
  });
224
227
  const data = yield response.json();
@@ -240,7 +243,8 @@ function getNodeIdFromSlug(nodeSlug) {
240
243
  }
241
244
 
242
245
  const getBranches = ({ projectId, platformUrl = 'https://stoplight.io', platformAuthToken, }) => __awaiter(void 0, void 0, void 0, function* () {
243
- const response = yield fetch(`${platformUrl}/api/v1/projects/${projectId}/branches`, {
246
+ const encodedProjectId = encodeURIComponent(projectId);
247
+ const response = yield fetch(`${platformUrl}/api/v1/projects/${encodedProjectId}/branches`, {
244
248
  headers: Object.assign({ 'Stoplight-Elements-Version': appVersion }, (platformAuthToken && { Authorization: `Bearer ${platformAuthToken}` })),
245
249
  });
246
250
  const data = yield response.json();
@@ -263,8 +267,10 @@ function useGetNodeContent({ nodeSlug, projectId, branchSlug, }) {
263
267
  }
264
268
 
265
269
  const getTableOfContents = ({ projectId, branchSlug, platformUrl = 'https://stoplight.io', platformAuthToken, }) => __awaiter(void 0, void 0, void 0, function* () {
266
- const branchQuery = branchSlug ? `?branch=${branchSlug}` : '';
267
- const response = yield fetch(`${platformUrl}/api/v1/projects/${projectId}/table-of-contents${branchQuery}`, {
270
+ const encodedProjectId = encodeURIComponent(projectId);
271
+ const encodedBranchSlug = branchSlug ? encodeURIComponent(branchSlug) : '';
272
+ const branchQuery = encodedBranchSlug ? `?branch=${encodedBranchSlug}` : '';
273
+ const response = yield fetch(`${platformUrl}/api/v1/projects/${encodedProjectId}/table-of-contents${branchQuery}`, {
268
274
  headers: Object.assign({ 'Stoplight-Elements-Version': appVersion }, (platformAuthToken && { Authorization: `Bearer ${platformAuthToken}` })),
269
275
  });
270
276
  const data = yield response.json();
@@ -349,23 +355,30 @@ const getNodes = ({ workspaceId, branchSlug, projectIds, search, platformUrl = '
349
355
  const queryParams = [];
350
356
  let fetchedWorkspaceId = workspaceId || '';
351
357
  if (!workspaceId && (projectIds === null || projectIds === void 0 ? void 0 : projectIds.length)) {
352
- const response = yield fetch(`${platformUrl}/api/v1/projects/${projectIds[0]}`, {
358
+ const encodedProjectId = encodeURIComponent(projectIds[0]);
359
+ const response = yield fetch(`${platformUrl}/api/v1/projects/${encodedProjectId}`, {
353
360
  headers: Object.assign({ 'Stoplight-Elements-Version': appVersion }, (platformAuthToken && { Authorization: `Bearer ${platformAuthToken}` })),
354
361
  });
355
362
  const data = yield response.json();
356
363
  fetchedWorkspaceId = data.workspace.id;
357
364
  }
358
365
  if (projectIds && projectIds.length) {
359
- queryParams.push(...projectIds.map((projectId, index) => `project_ids[${index}]=${projectId}`));
366
+ queryParams.push(...projectIds.map((projectId, index) => {
367
+ const encodedProjectId = encodeURIComponent(projectId);
368
+ return `project_ids[${index}]=${encodedProjectId}`;
369
+ }));
360
370
  }
361
371
  if (search) {
362
- queryParams.push(`search=${search}`);
372
+ const encodedSearch = encodeURIComponent(search);
373
+ queryParams.push(`search=${encodedSearch}`);
363
374
  }
364
375
  if (branchSlug) {
365
- queryParams.push(`branchSlug=${branchSlug}`);
376
+ const encodedBranchSlug = encodeURIComponent(branchSlug);
377
+ queryParams.push(`branchSlug=${encodedBranchSlug}`);
366
378
  }
367
379
  const query = queryParams.length ? `?${queryParams.join('&')}` : '';
368
- const response = yield fetch(`${platformUrl}/api/v1/workspaces/${fetchedWorkspaceId}/nodes${query}`, {
380
+ const encodedWorkspaceId = encodeURIComponent(fetchedWorkspaceId);
381
+ const response = yield fetch(`${platformUrl}/api/v1/workspaces/${encodedWorkspaceId}/nodes${query}`, {
369
382
  headers: Object.assign({ 'Stoplight-Elements-Version': appVersion }, (platformAuthToken && { Authorization: `Bearer ${platformAuthToken}` })),
370
383
  });
371
384
  const data = yield response.json();
@@ -376,7 +389,8 @@ const getNodes = ({ workspaceId, branchSlug, projectIds, search, platformUrl = '
376
389
  });
377
390
 
378
391
  const getWorkspace = ({ projectIds, platformUrl = 'https://stoplight.io', platformAuthToken, }) => __awaiter(void 0, void 0, void 0, function* () {
379
- const response = yield fetch(`${platformUrl}/api/v1/projects/${projectIds[0]}`, {
392
+ const encodedProjectId = encodeURIComponent(projectIds[0]);
393
+ const response = yield fetch(`${platformUrl}/api/v1/projects/${encodedProjectId}`, {
380
394
  headers: Object.assign({ 'Stoplight-Elements-Version': appVersion }, (platformAuthToken && { Authorization: `Bearer ${platformAuthToken}` })),
381
395
  });
382
396
  const data = yield response.json();
package/index.mjs CHANGED
@@ -38,7 +38,7 @@ const PlatformProvider = ({ platformUrl = 'https://stoplight.io', platformAuthTo
38
38
  };
39
39
  const DevPortalProvider = withPersistenceBoundary(withQueryClientProvider(withMosaicProvider(PlatformProvider)));
40
40
 
41
- const NodeContent = ({ node, Link, hideTryIt, hideTryItPanel, hideMocking, hideExport, tryItCredentialsPolicy, tryItCorsProxy, }) => {
41
+ const NodeContent = ({ node, Link, hideTryIt, hideTryItPanel, hideMocking, hideExport, tryItCredentialsPolicy, tryItCorsProxy, refResolver, }) => {
42
42
  return (React.createElement(NodeLinkContext.Provider, { value: [node, Link] },
43
43
  React.createElement(MarkdownComponentsProvider, { value: { a: LinkComponent } },
44
44
  React.createElement(MockingProvider, { mockUrl: node.links.mock_url, hideMocking: hideMocking },
@@ -46,7 +46,7 @@ const NodeContent = ({ node, Link, hideTryIt, hideTryItPanel, hideMocking, hideE
46
46
  hideTryIt: hideTryIt,
47
47
  hideTryItPanel: hideTryItPanel,
48
48
  hideExport: hideExport || node.links.export_url === undefined,
49
- }, useNodeForRefResolving: true, tryItCorsProxy: tryItCorsProxy, exportProps: [NodeType.HttpService, NodeType.Model].includes(node.type)
49
+ }, useNodeForRefResolving: true, refResolver: refResolver, tryItCorsProxy: tryItCorsProxy, exportProps: [NodeType.HttpService, NodeType.Model].includes(node.type)
50
50
  ? {
51
51
  original: {
52
52
  href: node.links.export_url,
@@ -72,7 +72,7 @@ const LinkComponent = ({ children, href }) => {
72
72
  const decodedResolvedUriWithoutAnchor = decodeURIComponent(resolvedUriWithoutAnchor);
73
73
  const edge = node.outbound_edges.find(edge => edge.uri === decodedUrl || edge.uri === decodedResolvedUriWithoutAnchor);
74
74
  if (edge) {
75
- return React.createElement(Link, { to: `${edge.slug}${hash && `#${hash}`}` }, children);
75
+ return React.createElement(Link, { to: `${edge.slug}${hash ? `#${hash}` : ''}` }, children);
76
76
  }
77
77
  }
78
78
  return React.createElement("a", { href: href }, children);
@@ -179,7 +179,7 @@ const UpgradeToStarter = () => (React__default.createElement(Flex, { as: "a", hr
179
179
  React__default.createElement(Icon, { icon: faExclamationTriangle, size: "4x" }),
180
180
  React__default.createElement(Box, { pt: 3 }, "Please upgrade your Stoplight Workspace to the Starter Plan to use Elements Dev Portal in production.")));
181
181
 
182
- const appVersion = '1.6.4';
182
+ const appVersion = '1.6.8';
183
183
 
184
184
  class ResponseError extends Error {
185
185
  constructor(message, responseCode) {
@@ -190,8 +190,11 @@ class ResponseError extends Error {
190
190
  }
191
191
  const getNodeContent = ({ nodeSlug, projectId, branchSlug, platformUrl = 'https://stoplight.io', platformAuthToken, }) => __awaiter(void 0, void 0, void 0, function* () {
192
192
  const nodeId = getNodeIdFromSlug(nodeSlug);
193
- const branchQuery = branchSlug ? `?branch=${branchSlug}` : '';
194
- const response = yield fetch(`${platformUrl}/api/v1/projects/${projectId}/nodes/${nodeId}${branchQuery}`, {
193
+ const encodedNodeId = encodeURIComponent(nodeId);
194
+ const encodedProjectId = encodeURIComponent(projectId);
195
+ const encodedBranchSlug = branchSlug ? encodeURIComponent(branchSlug) : '';
196
+ const branchQuery = encodedBranchSlug ? `?branch=${encodedBranchSlug}` : '';
197
+ const response = yield fetch(`${platformUrl}/api/v1/projects/${encodedProjectId}/nodes/${encodedNodeId}${branchQuery}`, {
195
198
  headers: Object.assign({ 'Stoplight-Elements-Version': appVersion }, (platformAuthToken && { Authorization: `Bearer ${platformAuthToken}` })),
196
199
  });
197
200
  const data = yield response.json();
@@ -213,7 +216,8 @@ function getNodeIdFromSlug(nodeSlug) {
213
216
  }
214
217
 
215
218
  const getBranches = ({ projectId, platformUrl = 'https://stoplight.io', platformAuthToken, }) => __awaiter(void 0, void 0, void 0, function* () {
216
- const response = yield fetch(`${platformUrl}/api/v1/projects/${projectId}/branches`, {
219
+ const encodedProjectId = encodeURIComponent(projectId);
220
+ const response = yield fetch(`${platformUrl}/api/v1/projects/${encodedProjectId}/branches`, {
217
221
  headers: Object.assign({ 'Stoplight-Elements-Version': appVersion }, (platformAuthToken && { Authorization: `Bearer ${platformAuthToken}` })),
218
222
  });
219
223
  const data = yield response.json();
@@ -236,8 +240,10 @@ function useGetNodeContent({ nodeSlug, projectId, branchSlug, }) {
236
240
  }
237
241
 
238
242
  const getTableOfContents = ({ projectId, branchSlug, platformUrl = 'https://stoplight.io', platformAuthToken, }) => __awaiter(void 0, void 0, void 0, function* () {
239
- const branchQuery = branchSlug ? `?branch=${branchSlug}` : '';
240
- const response = yield fetch(`${platformUrl}/api/v1/projects/${projectId}/table-of-contents${branchQuery}`, {
243
+ const encodedProjectId = encodeURIComponent(projectId);
244
+ const encodedBranchSlug = branchSlug ? encodeURIComponent(branchSlug) : '';
245
+ const branchQuery = encodedBranchSlug ? `?branch=${encodedBranchSlug}` : '';
246
+ const response = yield fetch(`${platformUrl}/api/v1/projects/${encodedProjectId}/table-of-contents${branchQuery}`, {
241
247
  headers: Object.assign({ 'Stoplight-Elements-Version': appVersion }, (platformAuthToken && { Authorization: `Bearer ${platformAuthToken}` })),
242
248
  });
243
249
  const data = yield response.json();
@@ -322,23 +328,30 @@ const getNodes = ({ workspaceId, branchSlug, projectIds, search, platformUrl = '
322
328
  const queryParams = [];
323
329
  let fetchedWorkspaceId = workspaceId || '';
324
330
  if (!workspaceId && (projectIds === null || projectIds === void 0 ? void 0 : projectIds.length)) {
325
- const response = yield fetch(`${platformUrl}/api/v1/projects/${projectIds[0]}`, {
331
+ const encodedProjectId = encodeURIComponent(projectIds[0]);
332
+ const response = yield fetch(`${platformUrl}/api/v1/projects/${encodedProjectId}`, {
326
333
  headers: Object.assign({ 'Stoplight-Elements-Version': appVersion }, (platformAuthToken && { Authorization: `Bearer ${platformAuthToken}` })),
327
334
  });
328
335
  const data = yield response.json();
329
336
  fetchedWorkspaceId = data.workspace.id;
330
337
  }
331
338
  if (projectIds && projectIds.length) {
332
- queryParams.push(...projectIds.map((projectId, index) => `project_ids[${index}]=${projectId}`));
339
+ queryParams.push(...projectIds.map((projectId, index) => {
340
+ const encodedProjectId = encodeURIComponent(projectId);
341
+ return `project_ids[${index}]=${encodedProjectId}`;
342
+ }));
333
343
  }
334
344
  if (search) {
335
- queryParams.push(`search=${search}`);
345
+ const encodedSearch = encodeURIComponent(search);
346
+ queryParams.push(`search=${encodedSearch}`);
336
347
  }
337
348
  if (branchSlug) {
338
- queryParams.push(`branchSlug=${branchSlug}`);
349
+ const encodedBranchSlug = encodeURIComponent(branchSlug);
350
+ queryParams.push(`branchSlug=${encodedBranchSlug}`);
339
351
  }
340
352
  const query = queryParams.length ? `?${queryParams.join('&')}` : '';
341
- const response = yield fetch(`${platformUrl}/api/v1/workspaces/${fetchedWorkspaceId}/nodes${query}`, {
353
+ const encodedWorkspaceId = encodeURIComponent(fetchedWorkspaceId);
354
+ const response = yield fetch(`${platformUrl}/api/v1/workspaces/${encodedWorkspaceId}/nodes${query}`, {
342
355
  headers: Object.assign({ 'Stoplight-Elements-Version': appVersion }, (platformAuthToken && { Authorization: `Bearer ${platformAuthToken}` })),
343
356
  });
344
357
  const data = yield response.json();
@@ -349,7 +362,8 @@ const getNodes = ({ workspaceId, branchSlug, projectIds, search, platformUrl = '
349
362
  });
350
363
 
351
364
  const getWorkspace = ({ projectIds, platformUrl = 'https://stoplight.io', platformAuthToken, }) => __awaiter(void 0, void 0, void 0, function* () {
352
- const response = yield fetch(`${platformUrl}/api/v1/projects/${projectIds[0]}`, {
365
+ const encodedProjectId = encodeURIComponent(projectIds[0]);
366
+ const response = yield fetch(`${platformUrl}/api/v1/projects/${encodedProjectId}`, {
353
367
  headers: Object.assign({ 'Stoplight-Elements-Version': appVersion }, (platformAuthToken && { Authorization: `Bearer ${platformAuthToken}` })),
354
368
  });
355
369
  const data = yield response.json();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stoplight/elements-dev-portal",
3
- "version": "1.6.4",
3
+ "version": "1.6.8",
4
4
  "description": "UI components for composing beautiful developer documentation.",
5
5
  "keywords": [],
6
6
  "main": "./index.js",
@@ -27,7 +27,7 @@
27
27
  },
28
28
  "dependencies": {
29
29
  "@fortawesome/free-solid-svg-icons": "^5.10.2",
30
- "@stoplight/elements-core": "~7.5.4",
30
+ "@stoplight/elements-core": "~7.5.8",
31
31
  "@stoplight/markdown-viewer": "^5.3.2",
32
32
  "@stoplight/mosaic": "^1.15.2",
33
33
  "@stoplight/path": "^1.3.2",
package/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const appVersion = "1.6.4";
1
+ export declare const appVersion = "1.6.8";