@alauda/doom 0.10.1 → 0.11.1
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/lib/cli/load-config.js +10 -15
- package/lib/plugins/permission/index.d.ts +3 -0
- package/lib/plugins/permission/index.js +28 -0
- package/lib/plugins/permission/types.d.ts +30 -0
- package/lib/plugins/permission/types.js +1 -0
- package/lib/plugins/shiki/transformers/callouts.js +0 -1
- package/lib/runtime/components/JsonViewer.js +2 -1
- package/lib/runtime/components/K8sCrd.js +3 -1
- package/lib/runtime/components/K8sPermissionTable.d.ts +13 -0
- package/lib/runtime/components/K8sPermissionTable.js +72 -0
- package/lib/runtime/components/OpenAPIPath.js +4 -2
- package/lib/runtime/components/OpenAPIRef.js +2 -2
- package/lib/runtime/components/_HeadingTitle.js +2 -2
- package/lib/runtime/components/_Markdown.js +5 -2
- package/lib/runtime/components/_RefLink.js +2 -2
- package/lib/runtime/components/index.d.ts +3 -2
- package/lib/runtime/components/index.js +3 -2
- package/lib/runtime/hooks/useTranslation.d.ts +1 -1
- package/lib/runtime/translation.d.ts +12 -0
- package/lib/runtime/translation.js +12 -0
- package/lib/runtime/types.d.ts +3 -0
- package/lib/shared/types.d.ts +13 -0
- package/lib/utils/types.d.ts +2 -0
- package/package.json +12 -12
package/lib/cli/load-config.js
CHANGED
|
@@ -11,6 +11,7 @@ import { pkgResolve, resolveStaticConfig, } from '../utils/index.js';
|
|
|
11
11
|
import { CWD, DEFAULT_CONFIG_NAME, DEFAULT_EXTENSIONS, I18N_FILE, SITES_FILE, YAML_EXTENSIONS, } from './constants.js';
|
|
12
12
|
import { replacePlugin } from '../plugins/replace/index.js';
|
|
13
13
|
import { mermaidPlugin } from '../plugins/mermaid/index.js';
|
|
14
|
+
import { permissionPlugin } from '../plugins/permission/index.js';
|
|
14
15
|
const DEFAULT_LOGO = '/logo.svg';
|
|
15
16
|
const zhLocaleConfig = {
|
|
16
17
|
searchPlaceholderText: '搜索文档',
|
|
@@ -75,6 +76,10 @@ const getCommonConfig = (config, cliRoot, configFilePath, version, ignore, force
|
|
|
75
76
|
version,
|
|
76
77
|
}),
|
|
77
78
|
mermaidPlugin(),
|
|
79
|
+
permissionPlugin({
|
|
80
|
+
...config.permission,
|
|
81
|
+
localBasePath,
|
|
82
|
+
}),
|
|
78
83
|
replacePlugin({
|
|
79
84
|
root,
|
|
80
85
|
lang: fallbackToZh ? null : (config.lang ?? 'en'),
|
|
@@ -89,21 +94,11 @@ const getCommonConfig = (config, cliRoot, configFilePath, version, ignore, force
|
|
|
89
94
|
// builtin transformers
|
|
90
95
|
transformerMetaHighlight(),
|
|
91
96
|
transformerMetaWordHighlight(),
|
|
92
|
-
transformerNotationDiff(
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
}),
|
|
98
|
-
transformerNotationFocus({
|
|
99
|
-
matchAlgorithm: 'v3',
|
|
100
|
-
}),
|
|
101
|
-
transformerNotationHighlight({
|
|
102
|
-
matchAlgorithm: 'v3',
|
|
103
|
-
}),
|
|
104
|
-
transformerNotationWordHighlight({
|
|
105
|
-
matchAlgorithm: 'v3',
|
|
106
|
-
}),
|
|
97
|
+
transformerNotationDiff(),
|
|
98
|
+
transformerNotationErrorLevel(),
|
|
99
|
+
transformerNotationFocus(),
|
|
100
|
+
transformerNotationHighlight(),
|
|
101
|
+
transformerNotationWordHighlight(),
|
|
107
102
|
transformerRemoveNotationEscape(),
|
|
108
103
|
// custom transformers
|
|
109
104
|
createTransformerCallouts(),
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import path from 'node:path';
|
|
2
|
+
import { glob } from 'tinyglobby';
|
|
3
|
+
import { resolveStaticConfig } from '../../utils/index.js';
|
|
4
|
+
export const permissionPlugin = ({ functionresources, localBasePath, roletemplates, }) => {
|
|
5
|
+
return {
|
|
6
|
+
async extendPageData(pageData) {
|
|
7
|
+
const functionResourcesMap = {};
|
|
8
|
+
const roleTemplatesMap = {};
|
|
9
|
+
if (functionresources) {
|
|
10
|
+
for (const file of await glob(functionresources, {
|
|
11
|
+
cwd: localBasePath,
|
|
12
|
+
})) {
|
|
13
|
+
functionResourcesMap[file] = (await resolveStaticConfig(path.resolve(localBasePath, file))).items;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
if (roletemplates) {
|
|
17
|
+
for (const file of await glob(roletemplates, {
|
|
18
|
+
cwd: localBasePath,
|
|
19
|
+
})) {
|
|
20
|
+
roleTemplatesMap[file] = (await resolveStaticConfig(path.resolve(localBasePath, file))).items;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
pageData.functionResourcesMap = functionResourcesMap;
|
|
24
|
+
pageData.roleTemplatesMap = roleTemplatesMap;
|
|
25
|
+
},
|
|
26
|
+
name: 'doom-permission',
|
|
27
|
+
};
|
|
28
|
+
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { K8sTypeMeta } from '../../shared/types.js';
|
|
2
|
+
export interface FunctionResource extends K8sTypeMeta {
|
|
3
|
+
kind: 'FunctionResource';
|
|
4
|
+
spec: {
|
|
5
|
+
rules: FunctionResourceRule[];
|
|
6
|
+
};
|
|
7
|
+
}
|
|
8
|
+
export interface FunctionResourceRule {
|
|
9
|
+
apiGroup: string;
|
|
10
|
+
bindCluster: 'bussiness' | 'global' | 'unlimit';
|
|
11
|
+
bindNamespacePart: '' | 'common' | 'kube-public' | 'project_ns' | 'system';
|
|
12
|
+
bindScope: 'cluster' | 'namespace';
|
|
13
|
+
resources: string[];
|
|
14
|
+
}
|
|
15
|
+
export interface PermissionPluginOptions {
|
|
16
|
+
functionresources?: string[];
|
|
17
|
+
localBasePath: string;
|
|
18
|
+
roletemplates?: string[];
|
|
19
|
+
}
|
|
20
|
+
export interface RoleTemplate extends K8sTypeMeta {
|
|
21
|
+
kind: 'RoleTemplate';
|
|
22
|
+
spec: {
|
|
23
|
+
rules: RoleTemplateRule[];
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
export interface RoleTemplateRule {
|
|
27
|
+
functionResourceRef: string;
|
|
28
|
+
verbs: RoleTemplateRuleVerb[];
|
|
29
|
+
}
|
|
30
|
+
export type RoleTemplateRuleVerb = '*' | 'create' | 'delete' | 'deletecollection' | 'get' | 'list' | 'patch' | 'update' | 'watch';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { getCustomMDXComponent, Tab, Tabs } from '@rspress/core/theme';
|
|
3
|
+
import { useState } from 'react';
|
|
3
4
|
import { stringify } from 'yaml';
|
|
4
|
-
const X = getCustomMDXComponent();
|
|
5
5
|
export const JsonViewer = ({ value }) => {
|
|
6
|
+
const [X] = useState(getCustomMDXComponent);
|
|
6
7
|
return (_jsxs(Tabs, { children: [_jsx(Tab, { label: "yaml", children: _jsx(X.pre, { children: _jsx(X.code, { className: "language-yaml", codeHighlighter: "prism", children: stringify(value) }) }) }), _jsx(Tab, { label: "json", children: _jsx(X.pre, { children: _jsx(X.code, { className: "language-json", codeHighlighter: "prism", children: JSON.stringify(value, null, 2) }) }) })] }));
|
|
7
8
|
};
|
|
8
9
|
export default JsonViewer;
|
|
@@ -8,8 +8,8 @@ import { useCallback, useEffect, useMemo, useState } from 'react';
|
|
|
8
8
|
import { useTranslation } from '../hooks/index.js';
|
|
9
9
|
import { Directive } from './Directive.js';
|
|
10
10
|
import { Markdown } from './_Markdown.js';
|
|
11
|
-
const X = getCustomMDXComponent();
|
|
12
11
|
export const K8sCrdSchemaPart = ({ name, parent, schema: property, expandAll, }) => {
|
|
12
|
+
const [X] = useState(getCustomMDXComponent);
|
|
13
13
|
const [open, setOpen] = useState(expandAll);
|
|
14
14
|
const onToggle = useCallback((open) => {
|
|
15
15
|
setOpen(open);
|
|
@@ -43,6 +43,7 @@ export const K8sCrdSchemaPart = ({ name, parent, schema: property, expandAll, })
|
|
|
43
43
|
};
|
|
44
44
|
const SKIPPED_PROPERTIES = ['apiVersion', 'kind', 'metadata'];
|
|
45
45
|
export const K8sCrdSchema = ({ schema, version, }) => {
|
|
46
|
+
const [X] = useState(getCustomMDXComponent);
|
|
46
47
|
const { description, properties } = schema;
|
|
47
48
|
const t = useTranslation();
|
|
48
49
|
const [expandAll, setExpandAll] = useState(false);
|
|
@@ -52,6 +53,7 @@ export const K8sCrdSchema = ({ schema, version, }) => {
|
|
|
52
53
|
return (_jsxs(_Fragment, { children: [_jsx(Markdown, { children: description }), _jsxs("div", { className: "flex items-center", children: [_jsxs("span", { children: [_jsx(X.code, { children: version }), _jsx(Badge, { children: "version" })] }), properties != null && (_jsx(Button, { className: "ml-auto doom-btn", type: "button", text: _jsxs("span", { onClick: toggleExpandAll, children: [expandAll ? '-' : '+', ' ', t(expandAll ? 'collapse_all' : 'expand_all')] }), size: "medium", theme: "alt" }))] }), properties == null ? (_jsx(Directive, { type: "warning", children: t('crd_no_schema') })) : (_jsx("div", { className: "doom-collapse-group", children: Object.entries(properties).map(([name, subSchema]) => SKIPPED_PROPERTIES.includes(name) || (_jsx(K8sCrdSchemaPart, { name: name, parent: schema, schema: subSchema, expandAll: expandAll }, name))) }))] }));
|
|
53
54
|
};
|
|
54
55
|
export const K8sCrd = ({ name, crdPath }) => {
|
|
56
|
+
const [X] = useState(getCustomMDXComponent);
|
|
55
57
|
const { page } = usePageData();
|
|
56
58
|
const [, crd] = useMemo(() => Object.entries(page.crdsMap || {}).find(([pathname, crd]) => {
|
|
57
59
|
if (crdPath && pathname !== crdPath) {
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export interface K8sPermissionTableProps {
|
|
2
|
+
functions: string[];
|
|
3
|
+
}
|
|
4
|
+
export declare const VerbsMap: {
|
|
5
|
+
readonly view: readonly ["get", "list", "watch"];
|
|
6
|
+
readonly create: readonly ["create"];
|
|
7
|
+
readonly update: readonly ["update", "patch"];
|
|
8
|
+
readonly delete: readonly ["delete", "deletecollection"];
|
|
9
|
+
};
|
|
10
|
+
export type Verb = keyof typeof VerbsMap;
|
|
11
|
+
export declare const Verbs: Verb[];
|
|
12
|
+
export declare const K8sPermissionTable: ({ functions }: K8sPermissionTableProps) => import("react/jsx-runtime").JSX.Element;
|
|
13
|
+
export default K8sPermissionTable;
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useLang, usePageData } from '@rspress/core/runtime';
|
|
3
|
+
import { getCustomMDXComponent } from '@rspress/core/theme';
|
|
4
|
+
import { intersection, sortBy } from 'es-toolkit';
|
|
5
|
+
import { Fragment, useMemo, useState } from 'react';
|
|
6
|
+
import { useTranslation } from '../hooks/index.js';
|
|
7
|
+
export const VerbsMap = {
|
|
8
|
+
view: ['get', 'list', 'watch'],
|
|
9
|
+
create: ['create'],
|
|
10
|
+
update: ['update', 'patch'],
|
|
11
|
+
delete: ['delete', 'deletecollection'],
|
|
12
|
+
};
|
|
13
|
+
export const Verbs = Object.keys(VerbsMap);
|
|
14
|
+
const FUNCTION_DISPLAY_NAME_ZH = 'cpaas.io/functionresource.function.display-name';
|
|
15
|
+
const FUNCTION_DISPLAY_NAME_EN = 'cpaas.io/functionresource.function.display-name.en';
|
|
16
|
+
const DISPLAY_NAME_ZH = 'cpaas.io/display-name';
|
|
17
|
+
const DISPLAY_NAME_EN = 'cpaas.io/display-name.en';
|
|
18
|
+
const TEXT_CENTER_STYLE = { textAlign: 'center' };
|
|
19
|
+
const TEXT_NO_WRAP_STYLE = { whiteSpace: 'nowrap' };
|
|
20
|
+
const RolesPermission = ({ functionResource, roleTemplates, verb, }) => {
|
|
21
|
+
const [X] = useState(getCustomMDXComponent);
|
|
22
|
+
const functionResourceName = functionResource.metadata.name;
|
|
23
|
+
const actions = functionResource.metadata.annotations['auth.cpaas.io/actions'];
|
|
24
|
+
return roleTemplates.map(({ metadata: { name }, spec: { rules } }) => {
|
|
25
|
+
const found = rules.find((r) => r.functionResourceRef === functionResourceName);
|
|
26
|
+
let hasPermission = false;
|
|
27
|
+
if (found) {
|
|
28
|
+
if (found.verbs.includes('*')) {
|
|
29
|
+
hasPermission = true;
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
const verbs = actions
|
|
33
|
+
? intersection(found.verbs, actions.split(','))
|
|
34
|
+
: found.verbs;
|
|
35
|
+
if (VerbsMap[verb].every((v) => verbs.includes(v))) {
|
|
36
|
+
hasPermission = true;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
return (_jsx(X.td, { style: TEXT_CENTER_STYLE, children: hasPermission ? '✓' : '✕' }, name));
|
|
41
|
+
});
|
|
42
|
+
};
|
|
43
|
+
export const K8sPermissionTable = ({ functions }) => {
|
|
44
|
+
const [X] = useState(getCustomMDXComponent);
|
|
45
|
+
const { page } = usePageData();
|
|
46
|
+
const functionResourcesMap = useMemo(() => Object.values(page.functionResourcesMap || {}).reduce((acc, curr) => Object.assign(acc, ...curr.map((fr) => ({ [fr.metadata.name]: fr }))), {}), [page.functionResourcesMap]);
|
|
47
|
+
const functionResources = useMemo(() => {
|
|
48
|
+
return functions.flatMap((name) => {
|
|
49
|
+
const matched = functionResourcesMap[name];
|
|
50
|
+
if (!matched) {
|
|
51
|
+
console.error(`FunctionResource \`${name}\` not found!\n`);
|
|
52
|
+
return [];
|
|
53
|
+
}
|
|
54
|
+
return matched;
|
|
55
|
+
});
|
|
56
|
+
}, [...functions]);
|
|
57
|
+
const roleTemplates = useMemo(() => sortBy(Object.values(page.roleTemplatesMap || {}).flat(), [
|
|
58
|
+
(it) => it.metadata.annotations['auth.cpaas.io/role.id'],
|
|
59
|
+
]), []);
|
|
60
|
+
const t = useTranslation();
|
|
61
|
+
const lang = useLang() || 'zh';
|
|
62
|
+
const isZh = lang === 'zh';
|
|
63
|
+
return (_jsxs(X.table, { children: [_jsx("thead", { children: _jsxs(X.tr, { children: [_jsx(X.th, { children: t('function') }), _jsx(X.th, { style: TEXT_NO_WRAP_STYLE, children: t('action') }), roleTemplates.map(({ metadata: { annotations, name } }) => (_jsx(X.th, { children: isZh
|
|
64
|
+
? annotations[DISPLAY_NAME_ZH]
|
|
65
|
+
: annotations[DISPLAY_NAME_EN] }, name)))] }) }), _jsx("tbody", { children: functionResources.map((fr) => {
|
|
66
|
+
const { metadata: { annotations, name }, } = fr;
|
|
67
|
+
return (_jsxs(Fragment, { children: [_jsxs(X.tr, { children: [_jsxs(X.td, { rowSpan: 4, style: TEXT_CENTER_STYLE, children: [isZh
|
|
68
|
+
? annotations[FUNCTION_DISPLAY_NAME_ZH]
|
|
69
|
+
: annotations[FUNCTION_DISPLAY_NAME_EN], _jsx("br", {}), _jsx(X.code, { children: name })] }), _jsx(X.td, { children: t('view') }), _jsx(RolesPermission, { functionResource: fr, roleTemplates: roleTemplates, verb: "view" })] }), Verbs.slice(1).map((verb) => (_jsxs(X.tr, { children: [_jsx(X.td, { children: t(verb) }), _jsx(RolesPermission, { functionResource: fr, roleTemplates: roleTemplates, verb: verb })] }, verb)))] }, name));
|
|
70
|
+
}) })] }));
|
|
71
|
+
};
|
|
72
|
+
export default K8sPermissionTable;
|
|
@@ -3,14 +3,14 @@ import { usePageData } from '@rspress/core/runtime';
|
|
|
3
3
|
import { Badge, getCustomMDXComponent } from '@rspress/core/theme';
|
|
4
4
|
import BananaSlug from 'github-slugger';
|
|
5
5
|
import { OpenAPIV3 } from 'openapi-types';
|
|
6
|
-
import { useMemo } from 'react';
|
|
6
|
+
import { useMemo, useState } from 'react';
|
|
7
7
|
import { DEFAULT_COMMON_REFS, omitRoutePathRefs, resolveRef } from '../utils.js';
|
|
8
8
|
import { HeadingTitle } from './_HeadingTitle.js';
|
|
9
9
|
import { RefLink } from './_RefLink.js';
|
|
10
10
|
import OpenAPIRef from './OpenAPIRef.js';
|
|
11
11
|
import { Markdown } from './_Markdown.js';
|
|
12
|
-
const X = getCustomMDXComponent();
|
|
13
12
|
export const OpenAPIParameters = ({ parameters, openapi, }) => {
|
|
13
|
+
const [X] = useState(getCustomMDXComponent);
|
|
14
14
|
return (_jsx(X.ul, { children: parameters.map((param, index) => {
|
|
15
15
|
const paramObj = '$ref' in param
|
|
16
16
|
? resolveRef(openapi, param.$ref)
|
|
@@ -28,6 +28,7 @@ export const OpenAPIParameters = ({ parameters, openapi, }) => {
|
|
|
28
28
|
}) }));
|
|
29
29
|
};
|
|
30
30
|
export const OpenAPIResponses = ({ responses, openapi, }) => {
|
|
31
|
+
const [X] = useState(getCustomMDXComponent);
|
|
31
32
|
return (_jsx(X.ul, { children: Object.entries(responses).map(([code, response], index) => {
|
|
32
33
|
const responseObj = '$ref' in response
|
|
33
34
|
? resolveRef(openapi, response.$ref)
|
|
@@ -73,6 +74,7 @@ const getRefsForPath = (openapi, path, knownRefs) => {
|
|
|
73
74
|
return Array.from(refs);
|
|
74
75
|
};
|
|
75
76
|
export const OpenAPIPath = ({ path, openapiPath: openapiPath_, pathPrefix: pathPrefix_, }) => {
|
|
77
|
+
const [X] = useState(getCustomMDXComponent);
|
|
76
78
|
const { page } = usePageData();
|
|
77
79
|
const pathPrefix = pathPrefix_ ?? (page.pathPrefix || '');
|
|
78
80
|
const slugger = useMemo(() => new BananaSlug(), []);
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
2
|
import { usePageData } from '@rspress/core/runtime';
|
|
3
3
|
import { getCustomMDXComponent } from '@rspress/core/theme';
|
|
4
|
-
import { useMemo } from 'react';
|
|
4
|
+
import { useMemo, useState } from 'react';
|
|
5
5
|
import { DEFAULT_COMMON_REFS, modelName, omitRoutePathRefs, resolveRef, } from '../utils.js';
|
|
6
6
|
import { HeadingTitle } from './_HeadingTitle.js';
|
|
7
7
|
import { Markdown } from './_Markdown.js';
|
|
8
8
|
import { RefLink } from './_RefLink.js';
|
|
9
|
-
const X = getCustomMDXComponent();
|
|
10
9
|
export const OpenAPIProperties = ({ properties, openapi, }) => {
|
|
10
|
+
const [X] = useState(getCustomMDXComponent);
|
|
11
11
|
return (_jsx(X.ul, { children: Object.entries(properties).map(([name, prop], index) => {
|
|
12
12
|
const propObj = '$ref' in prop ? resolveRef(openapi, prop.$ref) : prop;
|
|
13
13
|
const type = propObj.type;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { getCustomMDXComponent } from '@rspress/core/theme';
|
|
3
|
-
import { Children, useMemo } from 'react';
|
|
3
|
+
import { Children, useMemo, useState } from 'react';
|
|
4
4
|
export const HeadingTitle = ({ slug, slugger, level, children, }) => {
|
|
5
|
-
const X =
|
|
5
|
+
const [X] = useState(getCustomMDXComponent);
|
|
6
6
|
const HeadingComponents = useMemo(() => {
|
|
7
7
|
return [null, X.h1, X.h2, X.h3, X.h4, X.h5, X.h6];
|
|
8
8
|
}, [X]);
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { getCustomMDXComponent } from '@rspress/core/theme';
|
|
3
|
+
import { useState } from 'react';
|
|
3
4
|
import ReactMarkdown from 'react-markdown';
|
|
4
5
|
import remarkGfm from 'remark-gfm';
|
|
5
|
-
const
|
|
6
|
-
|
|
6
|
+
export const Markdown = ({ children }) => {
|
|
7
|
+
const [components] = useState(getCustomMDXComponent);
|
|
8
|
+
return (children && (_jsx(ReactMarkdown, { remarkPlugins: [[remarkGfm]], components: components, skipHtml: true, children: children })));
|
|
9
|
+
};
|
|
@@ -2,9 +2,9 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
2
2
|
import { getCustomMDXComponent } from '@rspress/core/theme';
|
|
3
3
|
import { DEFAULT_COMMON_REFS, modelName } from '../utils.js';
|
|
4
4
|
import { usePageData } from '@rspress/core/runtime';
|
|
5
|
-
import { useMemo } from 'react';
|
|
6
|
-
const X = getCustomMDXComponent();
|
|
5
|
+
import { useMemo, useState } from 'react';
|
|
7
6
|
export const RefLink = ({ $ref }) => {
|
|
7
|
+
const [X] = useState(getCustomMDXComponent);
|
|
8
8
|
const { page } = usePageData();
|
|
9
9
|
const references = useMemo(() => ({
|
|
10
10
|
...DEFAULT_COMMON_REFS,
|
|
@@ -9,11 +9,12 @@ export * from './ExternalSite.js';
|
|
|
9
9
|
export * from './ExternalSiteLink.js';
|
|
10
10
|
export * from './JsonViewer.js';
|
|
11
11
|
export * from './K8sCrd.js';
|
|
12
|
+
export * from './K8sPermissionTable.js';
|
|
12
13
|
export * from './LinkCard.js';
|
|
13
14
|
export * from './Mermaid.js';
|
|
14
|
-
export * from './Overview.js';
|
|
15
|
-
export * from './OpenAPIRef.js';
|
|
16
15
|
export * from './OpenAPIPath.js';
|
|
16
|
+
export * from './OpenAPIRef.js';
|
|
17
|
+
export * from './Overview.js';
|
|
17
18
|
export * from './PackageManagerTabs.js';
|
|
18
19
|
export * from './ProductBrand.js';
|
|
19
20
|
export * from './ProductShortBrand.js';
|
|
@@ -9,11 +9,12 @@ export * from './ExternalSite.js';
|
|
|
9
9
|
export * from './ExternalSiteLink.js';
|
|
10
10
|
export * from './JsonViewer.js';
|
|
11
11
|
export * from './K8sCrd.js';
|
|
12
|
+
export * from './K8sPermissionTable.js';
|
|
12
13
|
export * from './LinkCard.js';
|
|
13
14
|
export * from './Mermaid.js';
|
|
14
|
-
export * from './Overview.js';
|
|
15
|
-
export * from './OpenAPIRef.js';
|
|
16
15
|
export * from './OpenAPIPath.js';
|
|
16
|
+
export * from './OpenAPIRef.js';
|
|
17
|
+
export * from './Overview.js';
|
|
17
18
|
export * from './PackageManagerTabs.js';
|
|
18
19
|
export * from './ProductBrand.js';
|
|
19
20
|
export * from './ProductShortBrand.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const useTranslation: () => (key: "collapse_all" | "expand_all" | "crd_no_schema") => string;
|
|
1
|
+
export declare const useTranslation: () => (key: "function" | "delete" | "create" | "update" | "collapse_all" | "expand_all" | "crd_no_schema" | "action" | "view") => string;
|
|
@@ -3,11 +3,23 @@ export declare const TRANSLATIONS: {
|
|
|
3
3
|
collapse_all: string;
|
|
4
4
|
expand_all: string;
|
|
5
5
|
crd_no_schema: string;
|
|
6
|
+
function: string;
|
|
7
|
+
action: string;
|
|
8
|
+
view: string;
|
|
9
|
+
create: string;
|
|
10
|
+
update: string;
|
|
11
|
+
delete: string;
|
|
6
12
|
};
|
|
7
13
|
zh: {
|
|
8
14
|
collapse_all: string;
|
|
9
15
|
expand_all: string;
|
|
10
16
|
crd_no_schema: string;
|
|
17
|
+
function: string;
|
|
18
|
+
action: string;
|
|
19
|
+
view: string;
|
|
20
|
+
create: string;
|
|
21
|
+
update: string;
|
|
22
|
+
delete: string;
|
|
11
23
|
};
|
|
12
24
|
};
|
|
13
25
|
export type Locale = keyof typeof TRANSLATIONS;
|
|
@@ -2,10 +2,22 @@ const en = {
|
|
|
2
2
|
collapse_all: 'Collapse All',
|
|
3
3
|
expand_all: 'Expand All',
|
|
4
4
|
crd_no_schema: 'This CRD has an empty or unspecified schema.',
|
|
5
|
+
function: 'Function',
|
|
6
|
+
action: 'Action',
|
|
7
|
+
view: 'View',
|
|
8
|
+
create: 'Create',
|
|
9
|
+
update: 'Update',
|
|
10
|
+
delete: 'Delete',
|
|
5
11
|
};
|
|
6
12
|
const zh = {
|
|
7
13
|
collapse_all: '全部收起',
|
|
8
14
|
expand_all: '全部展开',
|
|
9
15
|
crd_no_schema: '此 CRD 未定义或定义为空。',
|
|
16
|
+
function: '功能',
|
|
17
|
+
action: '操作',
|
|
18
|
+
view: '查看',
|
|
19
|
+
create: '创建',
|
|
20
|
+
update: '更新',
|
|
21
|
+
delete: '删除',
|
|
10
22
|
};
|
|
11
23
|
export const TRANSLATIONS = { en, zh };
|
package/lib/runtime/types.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ import { PageData } from '@rspress/core';
|
|
|
2
2
|
import { OpenAPIV3_1 } from 'openapi-types';
|
|
3
3
|
import type { CustomResourceDefinition } from '../plugins/api/types.js';
|
|
4
4
|
import type { DoomSite } from '../shared/types.js';
|
|
5
|
+
import { FunctionResource, RoleTemplate } from '../plugins/permission/types.js';
|
|
5
6
|
export interface SiteBrand {
|
|
6
7
|
company: string;
|
|
7
8
|
product: string;
|
|
@@ -12,6 +13,8 @@ export interface ExtendedPage {
|
|
|
12
13
|
openapisMap?: Record<string, OpenAPIV3_1.Document>;
|
|
13
14
|
references?: Record<string, string>;
|
|
14
15
|
pathPrefix?: string;
|
|
16
|
+
functionResourcesMap?: Record<string, FunctionResource[]>;
|
|
17
|
+
roleTemplatesMap?: Record<string, RoleTemplate[]>;
|
|
15
18
|
sites?: DoomSite[];
|
|
16
19
|
v?: string;
|
|
17
20
|
}
|
package/lib/shared/types.d.ts
CHANGED
|
@@ -6,3 +6,16 @@ export interface DoomSite {
|
|
|
6
6
|
repo?: string;
|
|
7
7
|
image?: string;
|
|
8
8
|
}
|
|
9
|
+
export type StringMapper = Record<string, string>;
|
|
10
|
+
export interface K8sObjectMeta {
|
|
11
|
+
annotations: StringMapper;
|
|
12
|
+
name: string;
|
|
13
|
+
}
|
|
14
|
+
export interface K8sTypeMeta {
|
|
15
|
+
apiVersion: string;
|
|
16
|
+
kind: string;
|
|
17
|
+
metadata: K8sObjectMeta;
|
|
18
|
+
}
|
|
19
|
+
export interface K8sTypeList<T extends K8sTypeMeta> extends K8sTypeMeta {
|
|
20
|
+
items: T[];
|
|
21
|
+
}
|
package/lib/utils/types.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { UserConfig } from '@rspress/core';
|
|
2
2
|
import type { ApiPluginOptions } from '../plugins/api/types.js';
|
|
3
3
|
import type { AutoSidebarPluginOptions } from '../plugins/index.js';
|
|
4
|
+
import type { PermissionPluginOptions } from '../plugins/permission/types.js';
|
|
4
5
|
import type { ReferenceItem, ReleaseNotesOptions } from '../plugins/replace/types.js';
|
|
5
6
|
import type { DoomSite } from '../shared/index.js';
|
|
6
7
|
export interface GlobalCliOptions {
|
|
@@ -13,6 +14,7 @@ export interface GlobalCliOptions {
|
|
|
13
14
|
export interface DoomConfig extends UserConfig {
|
|
14
15
|
api?: ApiPluginOptions;
|
|
15
16
|
sites?: DoomSite[];
|
|
17
|
+
permission?: PermissionPluginOptions;
|
|
16
18
|
reference?: ReferenceItem[];
|
|
17
19
|
sidebar?: AutoSidebarPluginOptions;
|
|
18
20
|
releaseNotes?: ReleaseNotesOptions;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alauda/doom",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.11.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Doctor Doom making docs.",
|
|
6
6
|
"repository": {
|
|
@@ -38,10 +38,10 @@
|
|
|
38
38
|
"swc-node": "node --enable-source-maps --import @swc-node/register/esm-register"
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@inquirer/prompts": "^7.3.
|
|
41
|
+
"@inquirer/prompts": "^7.3.2",
|
|
42
42
|
"@openapi-contrib/openapi-schema-to-json-schema": "^5.1.0",
|
|
43
|
-
"@rspress/core": "1.41.
|
|
44
|
-
"@shikijs/transformers": "^
|
|
43
|
+
"@rspress/core": "1.41.3",
|
|
44
|
+
"@shikijs/transformers": "^3.0.0",
|
|
45
45
|
"chokidar": "^4.0.3",
|
|
46
46
|
"clsx": "^2.1.1",
|
|
47
47
|
"commander": "^13.1.0",
|
|
@@ -55,33 +55,33 @@
|
|
|
55
55
|
"remark-directive": "^2.0.1",
|
|
56
56
|
"remark-frontmatter": "^4.0.1",
|
|
57
57
|
"remark-gfm": "^3.0.1",
|
|
58
|
-
"shiki": "^
|
|
58
|
+
"shiki": "^3.0.0",
|
|
59
59
|
"simple-git": "^3.27.0",
|
|
60
60
|
"swagger2openapi": "^7.0.8",
|
|
61
|
-
"tinyglobby": "^0.2.
|
|
62
|
-
"type-fest": "^4.
|
|
61
|
+
"tinyglobby": "^0.2.11",
|
|
62
|
+
"type-fest": "^4.35.0",
|
|
63
63
|
"yaml": "^2.7.0",
|
|
64
64
|
"yoctocolors": "^2.1.1"
|
|
65
65
|
},
|
|
66
66
|
"devDependencies": {
|
|
67
67
|
"@eslint/js": "^9.20.0",
|
|
68
68
|
"@swc-node/register": "^1.10.9",
|
|
69
|
-
"@swc/core": "1.10.
|
|
69
|
+
"@swc/core": "1.10.17",
|
|
70
70
|
"@types/ejs": "^3.1.5",
|
|
71
71
|
"@types/eslint__js": "^8.42.3",
|
|
72
|
-
"@types/node": "^18.19.
|
|
72
|
+
"@types/node": "^18.19.76",
|
|
73
73
|
"@types/picomatch": "^3.0.2",
|
|
74
74
|
"@types/react-dom": "^18.3.5",
|
|
75
75
|
"@types/swagger2openapi": "^7.0.4",
|
|
76
76
|
"@unts/patch-package": "^8.0.0",
|
|
77
|
-
"eslint": "^9.20.
|
|
77
|
+
"eslint": "^9.20.1",
|
|
78
78
|
"lint-staged": "^15.4.3",
|
|
79
79
|
"npm-run-all2": "^7.0.2",
|
|
80
|
-
"prettier": "^3.5.
|
|
80
|
+
"prettier": "^3.5.1",
|
|
81
81
|
"prettier-plugin-pkg": "^0.18.1",
|
|
82
82
|
"simple-git-hooks": "^2.11.1",
|
|
83
83
|
"typescript": "^5.7.3",
|
|
84
|
-
"typescript-eslint": "^8.
|
|
84
|
+
"typescript-eslint": "^8.24.1"
|
|
85
85
|
},
|
|
86
86
|
"publishConfig": {
|
|
87
87
|
"access": "public"
|