@redocly/theme 0.58.0-next.0 → 0.58.0-next.2

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.
Files changed (65) hide show
  1. package/lib/components/Buttons/CopyButton.d.ts +1 -0
  2. package/lib/components/Buttons/CopyButton.js +3 -3
  3. package/lib/components/Catalog/Catalog.js +14 -2
  4. package/lib/components/Catalog/CatalogEntitiesEmptyState.d.ts +2 -1
  5. package/lib/components/Catalog/CatalogEntitiesEmptyState.js +32 -11
  6. package/lib/components/Catalog/CatalogEntity/CatalogEntity.d.ts +3 -7
  7. package/lib/components/Catalog/CatalogEntity/CatalogEntity.js +13 -7
  8. package/lib/components/Catalog/CatalogEntity/CatalogEntityMetadata.js +6 -6
  9. package/lib/components/Catalog/CatalogEntity/CatalogEntityProperties/CatalogEntityProperties.js +6 -10
  10. package/lib/components/Catalog/CatalogEntity/CatalogEntityProperties/ContactProperty.js +5 -1
  11. package/lib/components/Catalog/CatalogEntity/CatalogEntityRelations/CatalogEntityApiDescriptionRelations.d.ts +23 -0
  12. package/lib/components/Catalog/CatalogEntity/CatalogEntityRelations/CatalogEntityApiDescriptionRelations.js +27 -0
  13. package/lib/components/Catalog/CatalogEntity/CatalogEntityRelations/CatalogEntityDefaultRelations.d.ts +3 -2
  14. package/lib/components/Catalog/CatalogEntity/CatalogEntityRelations/CatalogEntityDefaultRelations.js +2 -2
  15. package/lib/components/Catalog/CatalogEntity/CatalogEntityRelations/CatalogEntityRelations.js +11 -2
  16. package/lib/components/Catalog/CatalogEntity/CatalogEntityRelations/CatalogEntityRelationsTable.d.ts +2 -1
  17. package/lib/components/Catalog/CatalogEntity/CatalogEntityRelations/CatalogEntityRelationsTable.js +1 -1
  18. package/lib/components/Catalog/CatalogEntity/CatalogEntityRelations/CatalogEntityRelationsTableContent.d.ts +2 -1
  19. package/lib/components/Catalog/CatalogEntity/CatalogEntityRelations/CatalogEntityTeamRelations.js +2 -8
  20. package/lib/components/Catalog/CatalogEntity/CatalogEntitySchema.d.ts +5 -2
  21. package/lib/components/Catalog/CatalogEntity/CatalogEntitySchema.js +64 -30
  22. package/lib/components/Catalog/CatalogTableView/CatalogEntityRelationCell.d.ts +1 -1
  23. package/lib/components/Catalog/CatalogTableView/CatalogEntityRelationCell.js +2 -2
  24. package/lib/components/Catalog/variables.js +1 -1
  25. package/lib/components/Filter/FilterContent.d.ts +1 -1
  26. package/lib/core/constants/catalog.d.ts +1 -0
  27. package/lib/core/constants/catalog.js +28 -1
  28. package/lib/core/hooks/catalog/useCatalogEntitySchema.d.ts +11 -0
  29. package/lib/core/hooks/catalog/useCatalogEntitySchema.js +39 -0
  30. package/lib/core/types/catalog.d.ts +7 -0
  31. package/lib/core/types/filter.d.ts +1 -1
  32. package/lib/core/utils/change-text-casing.d.ts +1 -1
  33. package/lib/core/utils/change-text-casing.js +3 -0
  34. package/lib/ext/configure.d.ts +1 -0
  35. package/lib/ext/configure.js +4 -1
  36. package/lib/ext/useConfigureReplay.d.ts +18 -0
  37. package/lib/ext/useConfigureReplay.js +64 -0
  38. package/package.json +4 -3
  39. package/src/components/Buttons/CopyButton.tsx +4 -1
  40. package/src/components/Catalog/Catalog.tsx +15 -2
  41. package/src/components/Catalog/CatalogEntitiesEmptyState.tsx +39 -16
  42. package/src/components/Catalog/CatalogEntity/CatalogEntity.tsx +42 -14
  43. package/src/components/Catalog/CatalogEntity/CatalogEntityMetadata.tsx +8 -6
  44. package/src/components/Catalog/CatalogEntity/CatalogEntityProperties/CatalogEntityProperties.tsx +15 -14
  45. package/src/components/Catalog/CatalogEntity/CatalogEntityProperties/ContactProperty.tsx +6 -1
  46. package/src/components/Catalog/CatalogEntity/CatalogEntityRelations/CatalogEntityApiDescriptionRelations.tsx +125 -0
  47. package/src/components/Catalog/CatalogEntity/CatalogEntityRelations/CatalogEntityDefaultRelations.tsx +5 -1
  48. package/src/components/Catalog/CatalogEntity/CatalogEntityRelations/CatalogEntityRelations.tsx +30 -3
  49. package/src/components/Catalog/CatalogEntity/CatalogEntityRelations/CatalogEntityRelationsTable.tsx +4 -3
  50. package/src/components/Catalog/CatalogEntity/CatalogEntityRelations/CatalogEntityRelationsTableContent.tsx +3 -1
  51. package/src/components/Catalog/CatalogEntity/CatalogEntityRelations/CatalogEntityTeamRelations.tsx +1 -13
  52. package/src/components/Catalog/CatalogEntity/CatalogEntitySchema.tsx +71 -23
  53. package/src/components/Catalog/CatalogTableView/CatalogEntityRelationCell.tsx +3 -3
  54. package/src/components/Catalog/variables.ts +1 -1
  55. package/src/components/Filter/FilterContent.tsx +3 -1
  56. package/src/core/constants/catalog.ts +28 -0
  57. package/src/core/hooks/catalog/useCatalogEntitySchema.ts +46 -0
  58. package/src/core/types/catalog.ts +9 -0
  59. package/src/core/types/filter.ts +3 -1
  60. package/src/core/utils/change-text-casing.ts +8 -1
  61. package/src/ext/configure.ts +5 -1
  62. package/src/ext/useConfigureReplay.ts +83 -0
  63. package/lib/components/Catalog/CatalogEntity/CatalogEntityProperties/ApiDescriptionProperty.d.ts +0 -6
  64. package/lib/components/Catalog/CatalogEntity/CatalogEntityProperties/ApiDescriptionProperty.js +0 -32
  65. package/src/components/Catalog/CatalogEntity/CatalogEntityProperties/ApiDescriptionProperty.tsx +0 -46
@@ -13,7 +13,7 @@ export const catalog = css`
13
13
  --catalog-filter-padding-vertical-mobile: 0;
14
14
  --catalog-filter-padding-horizontal-mobile: var(--spacing-base);
15
15
 
16
- --catalog-heading-margin: 0 0 var(--spacing-xl) 0;
16
+ --catalog-heading-margin: 0 0 var(--spacing-sm) 0;
17
17
  --catalog-sidebar-width: 285px;
18
18
 
19
19
  /**
@@ -15,7 +15,9 @@ export type FilterContentProps = {
15
15
  setFilterTerm: (value: string) => void;
16
16
  filters: ResolvedFilter[];
17
17
  filterTerm: string;
18
- filterValuesCasing?: NonNullable<RedoclyConfig['catalog']>[string]['filterValuesCasing'];
18
+ filterValuesCasing?:
19
+ | NonNullable<RedoclyConfig['catalog']>[string]['filterValuesCasing']
20
+ | ((str: string) => string);
19
21
  hideSearch?: boolean;
20
22
  showCounter?: boolean;
21
23
  };
@@ -58,6 +58,34 @@ export const reverseRelationMap: Record<EntityRelationType, EntityRelationType>
58
58
  triggeredBy: 'triggers',
59
59
  } as const;
60
60
 
61
+ export const relationTypeMap: Record<EntityRelationType, string> = {
62
+ partOf: 'Part of',
63
+ hasParts: 'Has parts',
64
+ creates: 'Creates',
65
+ createdBy: 'Created by',
66
+ owns: 'Owns',
67
+ ownedBy: 'Owned by',
68
+ implements: 'Implements',
69
+ implementedBy: 'Implemented by',
70
+ dependsOn: 'Depends on',
71
+ dependencyOf: 'Dependency of',
72
+ uses: 'Uses',
73
+ usedBy: 'Used by',
74
+ produces: 'Produces',
75
+ consumes: 'Consumes',
76
+ linksTo: 'Links to',
77
+ supersedes: 'Supersedes',
78
+ supersededBy: 'Superseded by',
79
+ compatibleWith: 'Compatible with',
80
+ extends: 'Extends',
81
+ extendedBy: 'Extended by',
82
+ relatesTo: 'Relates to',
83
+ hasMember: 'Has member',
84
+ memberOf: 'Member of',
85
+ triggers: 'Triggers',
86
+ triggeredBy: 'Triggered by',
87
+ };
88
+
61
89
  export enum GraphHandleType {
62
90
  Target = 'target',
63
91
  Source = 'source',
@@ -0,0 +1,46 @@
1
+ import { BffCatalogEntity, BffCatalogRelatedEntity } from '../../types';
2
+
3
+ type CatalogEntitySchemaProps = {
4
+ entity: BffCatalogEntity;
5
+ relatedEntity: BffCatalogRelatedEntity | null;
6
+ };
7
+
8
+ export function useCatalogEntitySchema({ entity, relatedEntity }: CatalogEntitySchemaProps) {
9
+ const { schema } = entity.metadata || {};
10
+
11
+ let parsedSchema;
12
+
13
+ try {
14
+ parsedSchema = JSON.parse(schema);
15
+ } catch (error) {
16
+ parsedSchema = undefined;
17
+ }
18
+
19
+ let parsedApiDefinition: any | undefined;
20
+
21
+ try {
22
+ parsedApiDefinition = relatedEntity?.metadata?.schema
23
+ ? JSON.parse(relatedEntity.metadata.schema)
24
+ : undefined;
25
+ } catch (err) {
26
+ parsedApiDefinition = undefined;
27
+ }
28
+
29
+ const definition: any =
30
+ !parsedApiDefinition || relatedEntity?.metadata?.specType !== 'openapi'
31
+ ? {
32
+ openapi: '3.0.0',
33
+ info: { version: '1', description: 'test', title: 'test' },
34
+ paths: {},
35
+ components: {
36
+ schemas: {},
37
+ },
38
+ }
39
+ : parsedApiDefinition;
40
+
41
+ return {
42
+ definition,
43
+ parsedSchema,
44
+ rawSchema: schema,
45
+ };
46
+ }
@@ -38,6 +38,12 @@ export type UseCatalogSearchResponse = {
38
38
  setSearchQuery: (query: string) => void;
39
39
  };
40
40
 
41
+ export type UseCatalogFilterResponse = {
42
+ filters: ResolvedFilter[];
43
+ filterQuery: string;
44
+ setFilterQuery: (filterQuery: string) => void;
45
+ };
46
+
41
47
  export type FilteredCatalog = {
42
48
  groups: { title: string; items: CatalogItem[] }[];
43
49
  filters: ResolvedFilter[];
@@ -160,6 +166,7 @@ export type BffCatalogEntity = {
160
166
  slack?: {
161
167
  channels?: Array<{
162
168
  name: string;
169
+ url?: string;
163
170
  }>;
164
171
  };
165
172
  };
@@ -195,3 +202,5 @@ export type Page = {
195
202
  };
196
203
 
197
204
  export type EntityRelationType = (typeof ENTITY_RELATION_TYPES)[number];
205
+
206
+ export type ListType = 'default' | 'team' | 'api-operation' | 'data-schema';
@@ -3,7 +3,9 @@ import type { RedoclyConfig } from '@redocly/config';
3
3
 
4
4
  export type FilterProps = {
5
5
  filter: ResolvedFilter & { selectedOptions: any };
6
- filterValuesCasing?: NonNullable<RedoclyConfig['catalog']>[string]['filterValuesCasing'];
6
+ filterValuesCasing?:
7
+ | NonNullable<RedoclyConfig['catalog']>[string]['filterValuesCasing']
8
+ | ((str: string) => string);
7
9
  showCounter?: boolean;
8
10
  };
9
11
 
@@ -1,6 +1,13 @@
1
1
  type Casing = 'original' | 'lowercase' | 'uppercase' | 'sentence';
2
2
 
3
- export function changeTextCasing(str: string, casing: Casing = 'original') {
3
+ export function changeTextCasing(
4
+ str: string,
5
+ casing: Casing | ((str: string) => string) = 'original',
6
+ ) {
7
+ if (casing instanceof Function) {
8
+ return casing(str);
9
+ }
10
+
4
11
  if (casing === 'original' || !str) return str;
5
12
 
6
13
  if (casing === 'lowercase') {
@@ -20,6 +20,7 @@ export type ConfigureRequestValues = {
20
20
  cookie?: Record<string, string>;
21
21
  security?: SecurityDetails;
22
22
  envVariables?: Record<string, string>;
23
+ serverVariables?: Record<string, string>;
23
24
  };
24
25
 
25
26
  export type ConfigureServerRequestValues = {
@@ -80,6 +81,9 @@ export function configure(_context: ContextProps): Configure {
80
81
  // envVariables: {
81
82
  // customLocation: 'prod'
82
83
  // },
84
+ // serverVariables: {
85
+ // version: 'v1',
86
+ // },
83
87
  // };
84
88
 
85
89
  // const { servers } = _context;
@@ -88,7 +92,7 @@ export function configure(_context: ContextProps): Configure {
88
92
  // for (const server of servers) {
89
93
  // if (server.url === 'https://dev.api.fake-museum-example.com') {
90
94
  // serverRequestValues[server.url] = exampleDevRequestValues;
91
- // } else if (server.url === 'https://api.fake-museum-example.com') {
95
+ // } else if (server.url === 'https://api.fake-museum-example.com/{version}') {
92
96
  // serverRequestValues[server.url] = exampleProdRequestValues;
93
97
  // } else {
94
98
  // serverRequestValues[server.url] = exampleDefaultRequestValues;
@@ -0,0 +1,83 @@
1
+ import { useEffect, useState, useCallback } from 'react';
2
+
3
+ import type {
4
+ ConfigureRequestValues,
5
+ ConfigureServerRequestValues,
6
+ } from '@redocly/theme/ext/configure';
7
+ import type { UserClaims, OpenAPIServer } from '@redocly/theme/core/types';
8
+
9
+ type ContextProps = {
10
+ operation: {
11
+ name: string;
12
+ path: string;
13
+ operationId: string;
14
+ href: string;
15
+ method: string;
16
+ };
17
+ servers: OpenAPIServer[];
18
+ userClaims: UserClaims;
19
+ };
20
+
21
+ async function getReplayConfiguration(
22
+ _context: ContextProps,
23
+ ): Promise<ConfigureRequestValues | ConfigureServerRequestValues | null> {
24
+ // Customize this function to fetch replay configuration from your API endpoint
25
+ // STEP 1: Uncomment the fetch code below and update the URL to your API endpoint
26
+
27
+ // try {
28
+ // const response = await fetch(`/api/replay-config/${_context.operation.operationId}`, {
29
+ // method: 'GET',
30
+ // headers: {
31
+ // 'Content-Type': 'application/json',
32
+ // },
33
+ // });
34
+
35
+ // if (!response.ok) {
36
+ // throw new Error(`HTTP error! status: ${response.status}`);
37
+ // }
38
+
39
+ // const { token } = await response.json();
40
+ //
41
+ // return {
42
+ // security: {
43
+ // token: {
44
+ // access_token: token,
45
+ // }
46
+ // }
47
+ // };
48
+ // } catch (error) {
49
+ // console.warn('Failed to fetch replay configuration:', error);
50
+ // throw error;
51
+ // }
52
+
53
+ // STEP 2: Remove this return null statement once you've implemented the fetch above
54
+ return null;
55
+ }
56
+
57
+ export function useConfigureReplay(context: ContextProps, isOpened: boolean) {
58
+ const [config, setConfig] = useState<
59
+ ConfigureRequestValues | ConfigureServerRequestValues | null
60
+ >();
61
+
62
+ const refresh = useCallback(async () => {
63
+ try {
64
+ const result = await getReplayConfiguration(context);
65
+ setConfig(result);
66
+ } catch (error) {
67
+ console.warn(
68
+ 'Failed to configure replay for operation:',
69
+ context.operation.operationId,
70
+ error,
71
+ );
72
+ }
73
+ // eslint-disable-next-line react-hooks/exhaustive-deps
74
+ }, []);
75
+
76
+ useEffect(() => {
77
+ if (isOpened) {
78
+ refresh();
79
+ }
80
+ }, [isOpened, refresh]);
81
+
82
+ return { config, refresh };
83
+ }
@@ -1,6 +0,0 @@
1
- import { JSX } from 'react';
2
- import { BffCatalogEntity } from '../../../../core/types';
3
- export type ApiDescriptionPropertyProps = {
4
- entity: BffCatalogEntity;
5
- };
6
- export declare function ApiDescriptionProperty({ entity }: ApiDescriptionPropertyProps): JSX.Element;
@@ -1,32 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.ApiDescriptionProperty = ApiDescriptionProperty;
7
- const react_1 = __importDefault(require("react"));
8
- const react_router_dom_1 = require("react-router-dom");
9
- const styled_components_1 = __importDefault(require("styled-components"));
10
- const theme_1 = require("../../../../index.js");
11
- const CatalogEntityPropertyCard_1 = require("../../../../components/Catalog/CatalogEntity/CatalogEntityProperties/CatalogEntityPropertyCard");
12
- function ApiDescriptionProperty({ entity }) {
13
- var _a;
14
- const { useTranslate } = (0, theme_1.useThemeHooks)();
15
- const { translate } = useTranslate();
16
- const navigate = (0, react_router_dom_1.useNavigate)();
17
- const pathPrefix = (0, theme_1.getPathPrefix)();
18
- const descriptionFile = (_a = entity.metadata) === null || _a === void 0 ? void 0 : _a.descriptionFile;
19
- return (react_1.default.createElement("div", { "data-component-name": "Catalog/CatalogEntity/CatalogEntityProperties/ApiDescriptionProperty" },
20
- react_1.default.createElement(CatalogEntityPropertyCard_1.CatalogEntityPropertyCard, { header: react_1.default.createElement(react_1.default.Fragment, null,
21
- react_1.default.createElement(theme_1.DocumentIcon, null),
22
- translate('catalog.entity.properties.apiDescription.title')), content: react_1.default.createElement(theme_1.Tag, { textTransform: "none" },
23
- react_1.default.createElement(DescriptionFile, null, descriptionFile)), onClick: () => {
24
- navigate(`${pathPrefix}/${descriptionFile}`);
25
- } })));
26
- }
27
- const DescriptionFile = styled_components_1.default.span `
28
- word-break: break-all;
29
- overflow-wrap: break-word;
30
- white-space: normal;
31
- `;
32
- //# sourceMappingURL=ApiDescriptionProperty.js.map
@@ -1,46 +0,0 @@
1
- import React, { JSX } from 'react';
2
- import { useNavigate } from 'react-router-dom';
3
- import styled from 'styled-components';
4
-
5
- import { BffCatalogEntity } from '@redocly/theme/core/types';
6
- import { DocumentIcon, getPathPrefix, Tag, useThemeHooks } from '@redocly/theme';
7
- import { CatalogEntityPropertyCard } from '@redocly/theme/components/Catalog/CatalogEntity/CatalogEntityProperties/CatalogEntityPropertyCard';
8
-
9
- export type ApiDescriptionPropertyProps = {
10
- entity: BffCatalogEntity;
11
- };
12
-
13
- export function ApiDescriptionProperty({ entity }: ApiDescriptionPropertyProps): JSX.Element {
14
- const { useTranslate } = useThemeHooks();
15
- const { translate } = useTranslate();
16
- const navigate = useNavigate();
17
- const pathPrefix = getPathPrefix();
18
- const descriptionFile = entity.metadata?.descriptionFile;
19
-
20
- return (
21
- <div data-component-name="Catalog/CatalogEntity/CatalogEntityProperties/ApiDescriptionProperty">
22
- <CatalogEntityPropertyCard
23
- header={
24
- <>
25
- <DocumentIcon />
26
- {translate('catalog.entity.properties.apiDescription.title')}
27
- </>
28
- }
29
- content={
30
- <Tag textTransform="none">
31
- <DescriptionFile>{descriptionFile}</DescriptionFile>
32
- </Tag>
33
- }
34
- onClick={() => {
35
- navigate(`${pathPrefix}/${descriptionFile}`);
36
- }}
37
- />
38
- </div>
39
- );
40
- }
41
-
42
- const DescriptionFile = styled.span`
43
- word-break: break-all;
44
- overflow-wrap: break-word;
45
- white-space: normal;
46
- `;