@redocly/theme 0.1.26 → 0.1.29
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/Button/Button.js +3 -3
- package/CodeBlock/CodeBlock.js +1 -1
- package/CopyButton/CopyButton.js +17 -1
- package/CopyButton/CopyButtonWrapper.js +1 -1
- package/Footer/Footer.js +2 -1
- package/Footer/FooterColumn.js +1 -1
- package/Footer/FooterColumns.d.ts +2 -2
- package/Footer/FooterColumns.js +1 -1
- package/JsonViewer/JsonViewer.d.ts +2 -0
- package/JsonViewer/JsonViewer.js +53 -22
- package/Markdown/Admonition.js +1 -1
- package/Markdown/CodeSample/CodeSample.js +17 -1
- package/Markdown/Heading.js +11 -2
- package/Markdown/MarkdownWrapper.js +2 -2
- package/Markdown/Mermaid.js +1 -1
- package/Markdown/Sup.d.ts +2 -0
- package/Markdown/Sup.js +19 -0
- package/Markdown/Tabs/Tabs.js +17 -1
- package/Markdown/index.d.ts +4 -3
- package/Markdown/index.js +4 -3
- package/Navbar/MobileNavbarDropdown.d.ts +8 -0
- package/Navbar/MobileNavbarDropdown.js +21 -0
- package/Navbar/MobileNavbarItem.d.ts +15 -0
- package/Navbar/MobileNavbarItem.js +102 -0
- package/Navbar/MobileNavbarMenu.d.ts +6 -0
- package/Navbar/MobileNavbarMenu.js +32 -0
- package/Navbar/MobileNavbarMenuButton.d.ts +4 -0
- package/Navbar/MobileNavbarMenuButton.js +19 -0
- package/Navbar/Navbar.js +26 -4
- package/Navbar/NavbarDropdown.js +1 -1
- package/Navbar/NavbarItem.d.ts +9 -3
- package/Navbar/NavbarItem.js +9 -9
- package/Navbar/NavbarMenu.js +3 -2
- package/PageNavigation/NextPageLink.js +4 -4
- package/PageNavigation/PreviousPageLink.js +4 -4
- package/Panel/PanelComponent.js +18 -2
- package/Profile/Profile.d.ts +8 -0
- package/Profile/Profile.js +60 -0
- package/Profile/index.d.ts +2 -0
- package/Profile/index.js +5 -0
- package/Search/Autocomplete.js +18 -2
- package/Search/utils.js +17 -1
- package/Sidebar/SidebarLayout.js +17 -1
- package/SourceCode/SourceCode.d.ts +10 -3
- package/SourceCode/SourceCode.js +10 -5
- package/TableOfContent/TableOfContent.js +4 -4
- package/Tooltip/Tooltip.d.ts +5 -4
- package/Tooltip/Tooltip.js +43 -21
- package/globalStyle.js +2 -2
- package/hooks/useActiveHeading.js +17 -1
- package/hooks/useActiveSectionId.d.ts +1 -1
- package/hooks/useActiveSectionId.js +17 -1
- package/hooks/useControl.js +17 -1
- package/hooks/useMobileMenu.js +17 -1
- package/hooks/useNavbarHeight.js +17 -1
- package/index.d.ts +1 -0
- package/index.js +1 -0
- package/package.json +1 -1
- package/src/Button/Button.tsx +5 -1
- package/src/CodeBlock/CodeBlock.ts +12 -0
- package/src/CopyButton/CopyButtonWrapper.tsx +1 -1
- package/src/Footer/Footer.tsx +4 -3
- package/src/Footer/FooterColumn.tsx +3 -1
- package/src/Footer/FooterColumns.tsx +3 -3
- package/src/JsonViewer/JsonViewer.tsx +55 -40
- package/src/Markdown/Admonition.tsx +1 -1
- package/src/Markdown/Heading.tsx +13 -2
- package/src/Markdown/MarkdownWrapper.tsx +58 -58
- package/src/Markdown/Mermaid.tsx +1 -1
- package/src/Markdown/Sup.tsx +8 -0
- package/src/Markdown/index.ts +4 -3
- package/src/Navbar/MobileNavbarDropdown.tsx +37 -0
- package/src/Navbar/MobileNavbarItem.tsx +116 -0
- package/src/Navbar/MobileNavbarMenu.tsx +106 -0
- package/src/Navbar/MobileNavbarMenuButton.tsx +13 -0
- package/src/Navbar/Navbar.tsx +11 -3
- package/src/Navbar/NavbarDropdown.tsx +1 -1
- package/src/Navbar/NavbarItem.tsx +9 -8
- package/src/Navbar/NavbarMenu.tsx +9 -4
- package/src/PageNavigation/NextPageLink.tsx +3 -3
- package/src/PageNavigation/PreviousPageLink.tsx +3 -3
- package/src/Profile/Profile.tsx +91 -0
- package/src/Profile/index.ts +2 -0
- package/src/SourceCode/SourceCode.tsx +32 -5
- package/src/TableOfContent/TableOfContent.tsx +3 -3
- package/src/Tooltip/Tooltip.tsx +87 -63
- package/src/globalStyle.ts +2 -0
- package/src/hooks/useActiveSectionId.ts +1 -1
- package/src/index.ts +1 -0
- package/src/types/portal/src/client/app/Sidebar/types.d.ts +2 -1
- package/src/types/portal/src/server/constants.d.ts +2 -0
- package/src/types/portal/src/server/dev-server/types.d.ts +22 -0
- package/src/types/portal/src/server/plugins/markdown/types.d.ts +15 -5
- package/src/types/portal/src/server/plugins/portal-config/get-frontmatter-keys-to-resolve.d.ts +2 -0
- package/src/types/portal/src/server/plugins/portal-config/types.d.ts +6 -2
- package/src/types/portal/src/server/plugins/reference-docs/utils.d.ts +26 -0
- package/src/types/portal/src/server/plugins/types.d.ts +29 -12
- package/src/types/portal/src/server/store.d.ts +16 -16
- package/src/types/portal/src/server/utils/fs.d.ts +2 -1
- package/src/types/portal/src/server/utils/index.d.ts +1 -0
- package/src/types/portal/src/server/utils/paths.d.ts +4 -0
- package/src/types/portal/src/server/utils/rbac.d.ts +15 -0
- package/src/types/portal/src/shared/constants.d.ts +7 -0
- package/src/types/portal/src/shared/models/config.d.ts +24 -12
- package/src/types/portal/src/shared/types.d.ts +17 -4
- package/src/types/portal/src/shared/urls.d.ts +1 -1
- package/src/types/portal/src/shared/utils.d.ts +2 -0
- package/src/ui/Burger.tsx +36 -0
- package/src/ui/Flex.tsx +1 -0
- package/src/utils/args-typecheck.ts +9 -0
- package/src/utils/class-names.ts +8 -0
- package/src/utils/color.ts +9 -0
- package/src/utils/highlight.ts +11 -0
- package/src/utils/index.ts +3 -0
- package/src/utils/jsonToHtml.ts +171 -59
- package/src/utils/theme-helpers.ts +3 -1
- package/ui/Burger.d.ts +8 -0
- package/ui/Burger.js +23 -0
- package/ui/Dropdown.js +17 -1
- package/ui/Flex.js +1 -1
- package/ui/UniversalLink.js +17 -1
- package/utils/args-typecheck.d.ts +2 -0
- package/utils/args-typecheck.js +13 -0
- package/utils/class-names.d.ts +1 -0
- package/utils/class-names.js +15 -0
- package/utils/color.d.ts +2 -0
- package/utils/color.js +12 -0
- package/utils/highlight.d.ts +1 -0
- package/utils/highlight.js +12 -1
- package/utils/index.d.ts +3 -0
- package/utils/index.js +3 -0
- package/utils/jsonToHtml.d.ts +4 -1
- package/utils/jsonToHtml.js +287 -83
- package/utils/media-css.js +40 -3
- package/utils/theme-helpers.js +59 -10
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import http from 'http';
|
|
3
|
+
import { MatchFunction } from 'path-to-regexp';
|
|
4
|
+
import { BuildIncremental } from 'esbuild';
|
|
5
|
+
export interface DevServerOptions {
|
|
6
|
+
clientEsbuild: BuildIncremental;
|
|
7
|
+
serverEsbuild: BuildIncremental;
|
|
8
|
+
port?: number;
|
|
9
|
+
}
|
|
10
|
+
export interface EnhancedIncomingMessage extends http.IncomingMessage {
|
|
11
|
+
pathname: string;
|
|
12
|
+
params: Record<string, string>;
|
|
13
|
+
body: string;
|
|
14
|
+
}
|
|
15
|
+
export interface Route {
|
|
16
|
+
matchPath: MatchFunction<EnhancedIncomingMessage['params']>;
|
|
17
|
+
handler(req: EnhancedIncomingMessage, res: http.ServerResponse): void;
|
|
18
|
+
}
|
|
19
|
+
export interface Server {
|
|
20
|
+
httpServer: http.Server;
|
|
21
|
+
addRoute(path: string, handler: Route['handler']): void;
|
|
22
|
+
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Config, Node, RenderableTreeNode } from '@markdoc/markdoc/dist/src/types';
|
|
2
|
+
import type { PageStaticData } from '../../../shared/types.js';
|
|
2
3
|
import type { ContentProvider, ContentRecord } from '../../content/content-provider.js';
|
|
3
4
|
import { PluginDefaultOptions } from '../types.js';
|
|
4
5
|
import type { RouteDetails } from '../types.js';
|
|
@@ -7,16 +8,21 @@ export interface MdHeading {
|
|
|
7
8
|
value: string;
|
|
8
9
|
depth: number;
|
|
9
10
|
}
|
|
10
|
-
export declare type
|
|
11
|
+
export declare type RoutesInfoActions = {
|
|
11
12
|
getRouteByFsPath: (relativePath: string) => RouteDetails | undefined;
|
|
12
13
|
getRouteBySlug?: (slug: string) => RouteDetails | undefined;
|
|
13
|
-
contentProvider: ContentProvider;
|
|
14
14
|
};
|
|
15
|
-
export interface
|
|
15
|
+
export interface MdOptions {
|
|
16
16
|
partials: Record<string, Node>;
|
|
17
|
+
variables?: Record<string, any>;
|
|
17
18
|
}
|
|
18
|
-
export declare type MdRenderContext = ContentRecord & PluginDefaultOptions &
|
|
19
|
-
export declare type MdCompilationContext = MdRenderContext &
|
|
19
|
+
export declare type MdRenderContext = ContentRecord & PluginDefaultOptions & MdOptions;
|
|
20
|
+
export declare type MdCompilationContext = MdRenderContext & RoutesInfoActions & {
|
|
21
|
+
contentProvider: ContentProvider;
|
|
22
|
+
};
|
|
23
|
+
export declare type MdProcessContext = PluginDefaultOptions & RoutesInfoActions & {
|
|
24
|
+
contentProvider: ContentProvider;
|
|
25
|
+
} & MdOptions;
|
|
20
26
|
export interface MdCompilationResult {
|
|
21
27
|
result: RenderableTreeNode;
|
|
22
28
|
headings: MdHeading[];
|
|
@@ -24,3 +30,7 @@ export interface MdCompilationResult {
|
|
|
24
30
|
export interface ExtendedMarkdocConfig extends Config {
|
|
25
31
|
currentProcessedPage?: string;
|
|
26
32
|
}
|
|
33
|
+
export interface MdPageStaticData extends PageStaticData {
|
|
34
|
+
ast: string;
|
|
35
|
+
frontmatter: Record<string, unknown>;
|
|
36
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ResolvedConfigLinks } from '../../../shared/types.js';
|
|
2
|
-
import { PortalConfig, RawTheme } from '../../../shared/models/config.js';
|
|
2
|
+
import { AuthConfig, PortalConfig, RawTheme } from '../../../shared/models/config.js';
|
|
3
3
|
import { Redirect } from '../types';
|
|
4
4
|
export interface GlobalData {
|
|
5
5
|
nav?: ResolvedConfigLinks;
|
|
@@ -13,8 +13,12 @@ export interface GlobalConfig {
|
|
|
13
13
|
stylesheets?: string;
|
|
14
14
|
redirects: Record<string, Redirect>;
|
|
15
15
|
fileName: string;
|
|
16
|
+
rbac: RbacConfig;
|
|
16
17
|
[k: string]: unknown;
|
|
17
18
|
}
|
|
18
|
-
export declare type RbacConfig =
|
|
19
|
+
export declare type RbacConfig = {
|
|
20
|
+
roles: Record<string, string[]>;
|
|
21
|
+
auth?: AuthConfig;
|
|
22
|
+
};
|
|
19
23
|
export declare type CustomEntryPropertyType = Record<string, string | boolean>;
|
|
20
24
|
export declare type ScriptOrStylesheetConfig = string | CustomEntryPropertyType;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { Pagination as PaginationType, IMenuItem, OpenAPIDefinition as IOpenAPIDefinition, MenuItemType } from '@redocly/reference-docs';
|
|
2
|
+
import { RedocProRawOptions } from '@redocly/reference-docs';
|
|
3
|
+
import type { ResolvedNavItem } from '../../../shared/types.js';
|
|
4
|
+
import type { ParsedContentRecord } from '../../content/content-provider.js';
|
|
5
|
+
export interface IMenuItemExtended extends IMenuItem {
|
|
6
|
+
httpVerb?: string;
|
|
7
|
+
}
|
|
8
|
+
export declare function loadDefinition(content: ParsedContentRecord): Promise<IOpenAPIDefinition | undefined>;
|
|
9
|
+
export declare function convertRedocToSidebar(data: {
|
|
10
|
+
redocItems: IMenuItemExtended[];
|
|
11
|
+
sidebarItems: ResolvedNavItem[];
|
|
12
|
+
parentId?: string;
|
|
13
|
+
routeSlug: string;
|
|
14
|
+
pagination: PaginationType;
|
|
15
|
+
}): void;
|
|
16
|
+
export declare const shouldAddPage: ({ pagination, type, }: {
|
|
17
|
+
pagination: PaginationType;
|
|
18
|
+
type: MenuItemType;
|
|
19
|
+
}) => boolean;
|
|
20
|
+
export declare const removeMarkdownLinks: (text: string) => string;
|
|
21
|
+
export declare function getConfigByPath(apis: {
|
|
22
|
+
[x: string]: {
|
|
23
|
+
root: string;
|
|
24
|
+
'features.openapi': RedocProRawOptions;
|
|
25
|
+
};
|
|
26
|
+
} | undefined, path: string): RedocProRawOptions;
|
|
@@ -1,24 +1,39 @@
|
|
|
1
|
-
import type { PageProps, ResolvedNavItem } from '../../shared/types.js';
|
|
2
|
-
import type { Template } from '../store';
|
|
1
|
+
import type { PageProps, PageStaticData, ResolvedNavItem, Version } from '../../shared/types.js';
|
|
3
2
|
import type { ContentProvider } from '../content/content-provider.js';
|
|
4
3
|
import { SearchData, SearchDocument } from '../../shared/models';
|
|
5
|
-
import
|
|
6
|
-
|
|
4
|
+
import { PERMISSION_PROP_NAME } from '@shared/constants.js';
|
|
5
|
+
import { Store } from '../store.js';
|
|
6
|
+
import type { GlobalData, GlobalConfig } from './portal-config/types.js';
|
|
7
|
+
import { MdOptions } from './markdown/types.js';
|
|
8
|
+
export declare type GetStaticDataContext = {
|
|
7
9
|
getRouteByFsPath: (relativePath: string) => RouteDetails | undefined;
|
|
8
10
|
getRouteBySlug: (relativePath: string) => RouteDetails | undefined;
|
|
11
|
+
getGlobalConfig<T = unknown>(key: string): T | undefined;
|
|
12
|
+
getAllRoutes: () => RouteDetails[];
|
|
13
|
+
contentDir: string;
|
|
14
|
+
outdir: string;
|
|
15
|
+
};
|
|
16
|
+
export declare type RbacContext = {
|
|
17
|
+
roles: string[];
|
|
18
|
+
permissions: string[];
|
|
9
19
|
};
|
|
10
|
-
export declare type
|
|
11
|
-
export
|
|
20
|
+
export declare type GetStaticDataFn<TData extends PageStaticData = PageStaticData, TProps extends PageProps = PageProps> = (route: RouteDetails<TData, TProps>, contentProvider: ContentProvider, context: GetStaticDataContext) => Promise<TData>;
|
|
21
|
+
export declare type GetServerPropsContext = {
|
|
22
|
+
getGlobalConfig<T = unknown>(key: string): T | undefined;
|
|
23
|
+
getRbacPermissionsByRole: Store['getRbacPermissionsByRole'];
|
|
24
|
+
};
|
|
25
|
+
export declare type GetServerPropsFn<TData extends PageStaticData = PageStaticData, TProps extends PageProps = PageProps> = (route: RouteDetails<TData, TProps>, data: TData, mdOptions: MdOptions) => Promise<TProps>;
|
|
26
|
+
export interface RouteDetails<TData extends PageStaticData = PageStaticData, TProps extends PageProps = PageProps> {
|
|
12
27
|
slug: string;
|
|
13
28
|
fsPath: string;
|
|
14
29
|
templateId: string;
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
[k: string]: DataLoader;
|
|
18
|
-
};
|
|
30
|
+
[PERMISSION_PROP_NAME]?: string;
|
|
31
|
+
versions?: Version[];
|
|
19
32
|
getNavText?: () => Promise<string>;
|
|
20
33
|
getSidebar?(): ResolvedNavItem[];
|
|
21
34
|
getSearchDocuments?(): Promise<SearchDocument[]>;
|
|
35
|
+
getStaticData?: GetStaticDataFn<TData, TProps>;
|
|
36
|
+
serverPropsGetterIds?: string[];
|
|
22
37
|
}
|
|
23
38
|
export interface Redirect {
|
|
24
39
|
to: string;
|
|
@@ -32,9 +47,10 @@ export interface PathVersionInfo {
|
|
|
32
47
|
export interface ProcessContentActions {
|
|
33
48
|
createSharedData(id: string, data: unknown): string;
|
|
34
49
|
addRouteSharedData(slug: string, dataKey: string, dataId: string): void;
|
|
50
|
+
setGlobalConfig: (data: Partial<GlobalConfig>) => void;
|
|
35
51
|
addRoute: (route: RouteDetails) => void;
|
|
36
|
-
createTemplate: (
|
|
37
|
-
|
|
52
|
+
createTemplate: (id: string, importPath: string) => string;
|
|
53
|
+
registerServerPropsGetter: (id: string, importPath: string) => string;
|
|
38
54
|
}
|
|
39
55
|
export interface AfterRoutesCreatedActions {
|
|
40
56
|
createSharedData(id: string, data: unknown): string;
|
|
@@ -47,6 +63,7 @@ export interface AfterRoutesCreatedActions {
|
|
|
47
63
|
setSearchData: (data: SearchData) => void;
|
|
48
64
|
addRedirect: (from: string, to: Redirect) => void;
|
|
49
65
|
contentDir: string;
|
|
66
|
+
outdir: string;
|
|
50
67
|
}
|
|
51
68
|
export interface PluginInstance {
|
|
52
69
|
watch?: RegExp;
|
|
@@ -1,13 +1,9 @@
|
|
|
1
1
|
import { Plugin } from 'esbuild';
|
|
2
2
|
import { JSONIndex, SearchDocument, SearchData } from '../shared/models';
|
|
3
|
+
import type { PageStaticData } from '../shared/types.js';
|
|
3
4
|
import type { RouteDetails, Redirect } from './plugins/types.js';
|
|
4
|
-
import type { GlobalData, GlobalConfig
|
|
5
|
-
|
|
6
|
-
pathOrThemePath: string;
|
|
7
|
-
id: string;
|
|
8
|
-
hash: string;
|
|
9
|
-
constructor(pathOrThemePath: string, id: string);
|
|
10
|
-
}
|
|
5
|
+
import type { GlobalData, GlobalConfig } from './plugins/portal-config/types';
|
|
6
|
+
import type { ContentProvider } from './content/content-provider';
|
|
11
7
|
export declare class Store {
|
|
12
8
|
contentDir: string;
|
|
13
9
|
outdir: string;
|
|
@@ -18,10 +14,11 @@ export declare class Store {
|
|
|
18
14
|
searchDocuments: SearchDocument[];
|
|
19
15
|
searchIndex: JSONIndex;
|
|
20
16
|
sharedData: Map<string, unknown>;
|
|
21
|
-
|
|
17
|
+
routesStaticDataCache: Map<string, PageStaticData>;
|
|
18
|
+
templates: Map<string, string>;
|
|
19
|
+
serverPropsGetters: Map<string, string>;
|
|
22
20
|
esbuildPlugins: Plugin[];
|
|
23
21
|
listeners: Map<string, Set<Function>>;
|
|
24
|
-
rbacConfig: RbacConfig;
|
|
25
22
|
globalData: GlobalData;
|
|
26
23
|
cliOptions: Record<string, string>;
|
|
27
24
|
globalConfig: GlobalConfig;
|
|
@@ -34,19 +31,22 @@ export declare class Store {
|
|
|
34
31
|
on(type: 'global-data-updated', cb: (pathname: string, data: Record<string, unknown>) => void): void;
|
|
35
32
|
runListeners<T extends Array<unknown>>(type: 'template-updated' | 'global-data-updated' | 'shared-data-updated' | 'search-data-updated' | 'routes-updated' | 'build-updated', ...args: T): void;
|
|
36
33
|
addEsbuildPlugin(plugin: Plugin): void;
|
|
37
|
-
setGlobalData(data: GlobalData)
|
|
34
|
+
setGlobalData: (data: GlobalData) => void;
|
|
38
35
|
setSearchData(data: SearchData): void;
|
|
39
36
|
setCliOptions(data: Record<string, string>): void;
|
|
40
37
|
setGlobalConfig(data: Partial<GlobalConfig>): void;
|
|
41
|
-
|
|
38
|
+
getRbacPermissionsByRole(role: string): string[] | undefined;
|
|
39
|
+
getGlobalConfig<T = unknown>(key: string): T;
|
|
42
40
|
addRedirect(from: string, to: Redirect): void;
|
|
43
41
|
createSharedData: (id: string, data: unknown) => string;
|
|
44
42
|
addRouteSharedData: (routeSlug: string, dataKey: string, dataId: string) => void;
|
|
45
43
|
addRoute: (route: RouteDetails) => void;
|
|
46
|
-
getRouteByFsPath: (relativePath: string) => RouteDetails | undefined;
|
|
47
|
-
getRouteBySlug: (slug: string) => RouteDetails | undefined;
|
|
48
|
-
getAllRoutes: () => RouteDetails[];
|
|
49
|
-
getTemplate: (id: string) =>
|
|
50
|
-
createTemplate: (
|
|
44
|
+
getRouteByFsPath: (relativePath: string) => RouteDetails<PageStaticData, import("../shared/types.js").PageProps> | undefined;
|
|
45
|
+
getRouteBySlug: (slug: string) => RouteDetails<PageStaticData, import("../shared/types.js").PageProps> | undefined;
|
|
46
|
+
getAllRoutes: () => RouteDetails<PageStaticData, import("../shared/types.js").PageProps>[];
|
|
47
|
+
getTemplate: (id: string) => string | undefined;
|
|
48
|
+
createTemplate: (id: string, importPath: string) => string;
|
|
49
|
+
registerServerPropsGetter: (id: string, importPath: string) => string;
|
|
50
|
+
resolveRouteStaticData(route: RouteDetails, contentProvider: ContentProvider): Promise<{}>;
|
|
51
51
|
clear: () => void;
|
|
52
52
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export declare function readFileAsStringSync(filePath: string): string | null | undefined;
|
|
2
2
|
export declare function readFileNames(dir: string): string[];
|
|
3
|
-
export declare function copyStaticFile(absolutePath: string, outdir: string): string;
|
|
3
|
+
export declare function copyStaticFile(absolutePath: string, outdir: string): string | undefined;
|
|
4
|
+
export declare function copyFolderRecursiveSync(source: string, target: string): void;
|
|
4
5
|
export declare function ensureDir(path: string): string;
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
import { OpenAPIDefinition } from '@redocly/reference-docs';
|
|
1
2
|
import type { ContentProvider } from '../content/content-provider.js';
|
|
3
|
+
import { Route } from '../dev-server/types';
|
|
2
4
|
export declare function getDataFromRelativePath(relativePath: string): {
|
|
3
5
|
pathVersion: string | null;
|
|
4
6
|
basePath: string;
|
|
@@ -11,3 +13,5 @@ export declare function excludeVersion<T extends string[] | string>(arg: T): {
|
|
|
11
13
|
version?: string;
|
|
12
14
|
data: T;
|
|
13
15
|
};
|
|
16
|
+
export declare function getParamsFromPath(path: string, route: Route): Record<string, string>;
|
|
17
|
+
export declare function getDefinitionFiles(contentProvider: ContentProvider): Promise<Map<string, OpenAPIDefinition>>;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Store } from '../store';
|
|
2
|
+
import { PERMISSION_PROP_NAME } from '../../shared/constants.js';
|
|
3
|
+
export declare function canAccessResource<T extends {
|
|
4
|
+
[PERMISSION_PROP_NAME]?: string;
|
|
5
|
+
}>(resource: T, permissions: Set<string>): boolean;
|
|
6
|
+
export declare function getPermissionsForRoles(store: Pick<Store, 'getRbacPermissionsByRole'>, roles: string[]): Set<string>;
|
|
7
|
+
export declare function getUserRolesFromCookies(cookies?: string): string[];
|
|
8
|
+
/**
|
|
9
|
+
* Maps the input deep and removes objects that have a 'permission' prop
|
|
10
|
+
* but do not match the input permissions list
|
|
11
|
+
* @param input can be object, array, string or any other value
|
|
12
|
+
* @param permissions
|
|
13
|
+
* @returns
|
|
14
|
+
*/
|
|
15
|
+
export declare function filterDataByAccessDeep(input: any, permissions: Set<string>): any;
|
|
@@ -1,10 +1,17 @@
|
|
|
1
1
|
export declare const RUNTIME_RESOURCES_DIR = "runtime";
|
|
2
2
|
export declare const REDOC_OVERVIEW_ITEM_ID = "overview";
|
|
3
3
|
export declare const PORTAL_CUSTOM_THEMES_FOLDER = "@theme";
|
|
4
|
+
export declare const DEFAULT_THEME_NAME = "@redocly/theme";
|
|
4
5
|
export declare const CUSTOM_MARKDOC_OPTIONS_PATH = "markdoc";
|
|
5
6
|
export declare const CUSTOM_MARKDOC_TAGS_PATH = "tags";
|
|
6
7
|
export declare const USER_THEME_ALIAS = "@theme";
|
|
8
|
+
export declare const PUBLIC_ASSETS_FOLDER = "/assets";
|
|
7
9
|
export declare const PUBLIC_STATIC_FOLDER = "/static";
|
|
10
|
+
export declare const THEME_ASSETS_FOLDER = "theme-assets";
|
|
11
|
+
export declare const PERMISSION_PROP_NAME = "redocly::permission";
|
|
12
|
+
export declare const OIDC_CALLBACK_ROUTE_PATH = "/_auth/oidc";
|
|
13
|
+
export declare const DEFAULT_OIDC_SCOPES = "openid";
|
|
8
14
|
export declare enum FsErrors {
|
|
9
15
|
NotExist = "ENOENT"
|
|
10
16
|
}
|
|
17
|
+
export declare const INTERNALLY_IGNORED_FILES: string[];
|
|
@@ -1,9 +1,28 @@
|
|
|
1
|
-
import { RawNavItem, LogoConfig
|
|
1
|
+
import { RawNavItem, LogoConfig } from '../types';
|
|
2
|
+
declare type RawNavConfig = RawNavItem[] | Record<string, RawNavItem[] | {
|
|
3
|
+
items: RawNavItem[];
|
|
4
|
+
} | string>;
|
|
5
|
+
export declare type AuthProviderConfig = {
|
|
6
|
+
type: string;
|
|
7
|
+
configurationUrl: string;
|
|
8
|
+
clientId: string;
|
|
9
|
+
clientSecret: string;
|
|
10
|
+
rolesClaimName: string;
|
|
11
|
+
scopes?: Array<string>;
|
|
12
|
+
};
|
|
13
|
+
export declare type AuthIdpsConfig = {
|
|
14
|
+
main: AuthProviderConfig;
|
|
15
|
+
};
|
|
16
|
+
export declare type AuthConfig = {
|
|
17
|
+
idps: AuthIdpsConfig;
|
|
18
|
+
};
|
|
2
19
|
export interface PortalConfig extends Record<string, any> {
|
|
3
|
-
nav?:
|
|
20
|
+
nav?: RawNavConfig;
|
|
4
21
|
logo?: LogoConfig;
|
|
5
22
|
themes?: RawTheme[];
|
|
6
|
-
footer?:
|
|
23
|
+
footer?: RawNavConfig;
|
|
24
|
+
auth?: AuthConfig;
|
|
25
|
+
frontmatterKeysToResolve?: string[];
|
|
7
26
|
}
|
|
8
27
|
export interface RawTheme {
|
|
9
28
|
name: string;
|
|
@@ -11,18 +30,11 @@ export interface RawTheme {
|
|
|
11
30
|
}
|
|
12
31
|
export interface ResolvedTheme extends RawTheme {
|
|
13
32
|
stylesFile?: string;
|
|
33
|
+
path: string;
|
|
14
34
|
markdoc: {
|
|
15
35
|
nodesFiles: string[];
|
|
16
36
|
tagsFiles: string[];
|
|
17
37
|
componentsFile?: string;
|
|
18
38
|
};
|
|
19
39
|
}
|
|
20
|
-
export
|
|
21
|
-
copyrightText?: string;
|
|
22
|
-
columns?: FooterColumn[];
|
|
23
|
-
}
|
|
24
|
-
export interface FooterColumn {
|
|
25
|
-
group: string;
|
|
26
|
-
label?: string;
|
|
27
|
-
items: ResolvedNavItem[];
|
|
28
|
-
}
|
|
40
|
+
export {};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
+
import { PERMISSION_PROP_NAME } from './constants';
|
|
2
3
|
export declare type ResolvedNavLinkItem = {
|
|
3
4
|
type: 'link';
|
|
4
5
|
link: string;
|
|
@@ -12,6 +13,7 @@ export declare type ResolvedNavLinkItem = {
|
|
|
12
13
|
separatorLine?: boolean;
|
|
13
14
|
routeSlug?: string;
|
|
14
15
|
active?: boolean;
|
|
16
|
+
[PERMISSION_PROP_NAME]?: string;
|
|
15
17
|
};
|
|
16
18
|
export declare type ResolvedNavGroupItem = {
|
|
17
19
|
type: 'group';
|
|
@@ -25,6 +27,7 @@ export declare type ResolvedNavGroupItem = {
|
|
|
25
27
|
separatorLine?: boolean;
|
|
26
28
|
routeSlug?: string;
|
|
27
29
|
active?: boolean;
|
|
30
|
+
[PERMISSION_PROP_NAME]?: string;
|
|
28
31
|
};
|
|
29
32
|
export declare type ResolvedNavItem = ResolvedNavLinkItem | ResolvedNavGroupItem | {
|
|
30
33
|
type: 'separator';
|
|
@@ -35,6 +38,7 @@ export declare type ResolvedNavItem = ResolvedNavLinkItem | ResolvedNavGroupItem
|
|
|
35
38
|
separatorLine?: boolean;
|
|
36
39
|
link?: undefined;
|
|
37
40
|
items?: ResolvedNavItem[];
|
|
41
|
+
[PERMISSION_PROP_NAME]?: string;
|
|
38
42
|
} | {
|
|
39
43
|
type: 'error';
|
|
40
44
|
version?: string;
|
|
@@ -43,23 +47,30 @@ export declare type ResolvedNavItem = ResolvedNavLinkItem | ResolvedNavGroupItem
|
|
|
43
47
|
label: string;
|
|
44
48
|
link?: undefined;
|
|
45
49
|
items?: ResolvedNavItem[];
|
|
50
|
+
[PERMISSION_PROP_NAME]?: string;
|
|
46
51
|
};
|
|
47
52
|
export declare type ResolvedNavItemWithLink = (ResolvedNavLinkItem | ResolvedNavGroupItem) & {
|
|
48
53
|
link: string;
|
|
49
54
|
};
|
|
50
55
|
export declare type ResolvedSidebar = ResolvedNavItem[];
|
|
51
56
|
export interface PageProps {
|
|
52
|
-
seo
|
|
57
|
+
seo?: {
|
|
53
58
|
title: string;
|
|
54
59
|
};
|
|
55
|
-
|
|
56
|
-
|
|
60
|
+
frontmatter?: Omit<PageProps, 'frontmatter'> & {
|
|
61
|
+
settings?: any;
|
|
62
|
+
};
|
|
63
|
+
[k: string]: any;
|
|
64
|
+
}
|
|
65
|
+
export interface PageStaticData {
|
|
66
|
+
props?: PageProps;
|
|
57
67
|
[k: string]: unknown;
|
|
58
68
|
}
|
|
59
69
|
export interface PageData {
|
|
60
70
|
templateId: string;
|
|
61
71
|
sharedDataIds: Record<string, string>;
|
|
62
72
|
props: PageProps;
|
|
73
|
+
versions?: Version[];
|
|
63
74
|
}
|
|
64
75
|
export interface CachedPageData extends PageData {
|
|
65
76
|
Template: React.ComponentType<{
|
|
@@ -117,6 +128,8 @@ export declare type VersionedFolderConfig = {
|
|
|
117
128
|
versions: VersionConfigItem[];
|
|
118
129
|
hasVersionsConfig?: boolean;
|
|
119
130
|
};
|
|
120
|
-
export declare type NavGroup = ResolvedNavItem[] | undefined | string;
|
|
131
|
+
export declare type NavGroup = ResolvedNavItem[] | undefined | string | boolean | number;
|
|
121
132
|
export declare type NavGroupRecord = Record<string, NavGroup>;
|
|
122
133
|
export declare type ResolvedConfigLinks = NavGroup | NavGroupRecord;
|
|
134
|
+
export declare type RawNavConfigItem = RawNavItem | RawNavItem[] | string | undefined | boolean | number;
|
|
135
|
+
export declare type RawNavConfig = RawNavConfigItem | Record<string, RawNavConfigItem>;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
export declare function getPageDataUrl(normalizedRoute: string): string;
|
|
2
2
|
export declare function getClientPageDataUrl(normalizedRoute: string): string;
|
|
3
|
-
export declare function getSidebarUrl(id: string): string;
|
|
4
3
|
export declare function getSharedDataUrl(id: string): string;
|
|
5
4
|
export declare const GLOBAL_DATA_URL = "/app-data.json";
|
|
6
5
|
export declare const SEARCH_DATA_URL = "/search-data.json";
|
|
7
6
|
export declare const SEARCH_INDEX_URL = "/search-index.json";
|
|
7
|
+
export declare const EJECT_COMPONENT_URL = "/eject-component";
|
|
8
8
|
export declare function combineUrls(baseURL: string, ...relativeURLs: string[]): string;
|
|
9
9
|
export declare function withPathPrefix(url: string): string;
|
|
10
10
|
export declare function withoutHash(url: string): string;
|
|
@@ -14,3 +14,5 @@ export declare function getGlobMatcher(glob: Glob, options?: {}): (file: string)
|
|
|
14
14
|
export declare function isTag(value?: any): value is Tag;
|
|
15
15
|
export declare function isNode(value?: any): value is Node;
|
|
16
16
|
export declare const getCssPropertyValue: (name: string) => string;
|
|
17
|
+
export declare function normalizeRoute(route: string): string;
|
|
18
|
+
export declare function isPrimitive(arg: any): arg is string | boolean | number;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import React, { MouseEventHandler } from 'react';
|
|
2
|
+
import styled from 'styled-components';
|
|
3
|
+
|
|
4
|
+
export interface BurgerProps {
|
|
5
|
+
onClick: MouseEventHandler;
|
|
6
|
+
className?: string;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
function BurgerComponent({ onClick, className }: BurgerProps): JSX.Element {
|
|
10
|
+
return (
|
|
11
|
+
<Button onClick={onClick} className={className} data-component-name="ui/Burger">
|
|
12
|
+
<Line></Line>
|
|
13
|
+
<Line></Line>
|
|
14
|
+
<Line></Line>
|
|
15
|
+
</Button>
|
|
16
|
+
);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const Button = styled.button`
|
|
20
|
+
all: unset;
|
|
21
|
+
max-width: 30px;
|
|
22
|
+
width: 100%;
|
|
23
|
+
min-width: 10px;
|
|
24
|
+
display: block;
|
|
25
|
+
cursor: pointer;
|
|
26
|
+
`;
|
|
27
|
+
|
|
28
|
+
const Line = styled.div`
|
|
29
|
+
margin: 4px 0;
|
|
30
|
+
width: 100%;
|
|
31
|
+
height: 2px;
|
|
32
|
+
background: #fff;
|
|
33
|
+
border-radius: 1px;
|
|
34
|
+
`;
|
|
35
|
+
|
|
36
|
+
export const Burger = styled(BurgerComponent)``;
|
package/src/ui/Flex.tsx
CHANGED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
|
|
2
|
+
export function isEmptyArray(items: any): boolean {
|
|
3
|
+
return Array.isArray(items) && !items?.length;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
|
|
7
|
+
export function isPrimitive(arg: any): boolean {
|
|
8
|
+
return ['string', 'boolean', 'number'].includes(typeof arg);
|
|
9
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export const getRandomNumber = (limit: number): number => Math.floor(Math.random() * limit);
|
|
2
|
+
|
|
3
|
+
export function getRandomColor(): string {
|
|
4
|
+
const h = getRandomNumber(360);
|
|
5
|
+
const s = getRandomNumber(100);
|
|
6
|
+
const l = getRandomNumber(100);
|
|
7
|
+
|
|
8
|
+
return `hsl(${h}deg, ${s}%, ${l}%)`;
|
|
9
|
+
}
|
package/src/utils/highlight.ts
CHANGED
|
@@ -22,6 +22,7 @@ import 'prismjs/components/prism-swift.js';
|
|
|
22
22
|
import 'prismjs/components/prism-graphql.js';
|
|
23
23
|
|
|
24
24
|
const DEFAULT_LANG = 'clike';
|
|
25
|
+
const NEW_LINE_EXP = /\n(?!$)/g;
|
|
25
26
|
|
|
26
27
|
Prism.languages.insertBefore(
|
|
27
28
|
'javascript',
|
|
@@ -79,3 +80,13 @@ export function highlight(source: string | number | boolean, lang: string = DEFA
|
|
|
79
80
|
}
|
|
80
81
|
return Prism.highlight(source.toString(), grammar, lang);
|
|
81
82
|
}
|
|
83
|
+
|
|
84
|
+
export function addLineNumbers(highlightedCode: string, start = 1): string {
|
|
85
|
+
const codeLines = highlightedCode.split(NEW_LINE_EXP);
|
|
86
|
+
|
|
87
|
+
return codeLines
|
|
88
|
+
.map((line, i) => {
|
|
89
|
+
return `<span class="code-line" data-line-number=${start + i}>${line}</span>`;
|
|
90
|
+
})
|
|
91
|
+
.join('\n');
|
|
92
|
+
}
|