@alauda/doom 1.17.5 → 1.18.0
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/runtime/components/K8sAPI.d.ts +10 -0
- package/lib/runtime/components/K8sAPI.js +61 -0
- package/lib/runtime/components/Masonry.d.ts +2 -2
- package/lib/runtime/components/Masonry.js +5 -2
- package/lib/runtime/components/Overview.js +2 -2
- package/lib/runtime/components/_K8sAPIEndpoints.d.ts +10 -0
- package/lib/runtime/components/_K8sAPIEndpoints.js +19 -0
- package/lib/runtime/components/_K8sAPISchema.d.ts +15 -0
- package/lib/runtime/components/_K8sAPISchema.js +62 -0
- package/lib/runtime/components/index.d.ts +1 -0
- package/lib/runtime/components/index.js +1 -0
- package/package.json +1 -1
- package/styles/global.scss +22 -0
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export interface K8sAPIProps {
|
|
2
|
+
name: string;
|
|
3
|
+
pathPrefix?: string;
|
|
4
|
+
filepath?: string;
|
|
5
|
+
apiGroup?: string;
|
|
6
|
+
apiVersion?: string;
|
|
7
|
+
apiKind?: string;
|
|
8
|
+
}
|
|
9
|
+
export declare const K8sAPI: ({ name, pathPrefix, filepath, apiGroup, apiVersion, apiKind, }: K8sAPIProps) => import("react/jsx-runtime").JSX.Element | null;
|
|
10
|
+
export default K8sAPI;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import crdsMap from 'doom-@api-crdsMap';
|
|
3
|
+
import openapisMap from 'doom-@api-openapisMap';
|
|
4
|
+
import { useMemo } from 'react';
|
|
5
|
+
import { resolveRef } from '../utils.js';
|
|
6
|
+
import { K8sAPIEndpoints } from './_K8sAPIEndpoints.js';
|
|
7
|
+
import { K8sAPISchema } from './_K8sAPISchema.js';
|
|
8
|
+
export const K8sAPI = ({ name, pathPrefix, filepath, apiGroup, apiVersion, apiKind, }) => {
|
|
9
|
+
const [, openapi] = useMemo(() => Object.entries(openapisMap).find(([pathname, openapi]) => {
|
|
10
|
+
if (filepath && pathname !== filepath) {
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
return resolveRef(openapi, name);
|
|
14
|
+
}) || [], [filepath, name]);
|
|
15
|
+
const [, crd] = useMemo(() => Object.entries(crdsMap).find(([pathname, crd]) => {
|
|
16
|
+
if (filepath && pathname !== filepath) {
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
return crd.metadata.name === name;
|
|
20
|
+
}) || [], [filepath, name]);
|
|
21
|
+
const schema = useMemo(() => {
|
|
22
|
+
if (openapi) {
|
|
23
|
+
return resolveRef(openapi, name);
|
|
24
|
+
}
|
|
25
|
+
if (!crd) {
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
const { versions } = crd.spec;
|
|
29
|
+
const v = apiVersion ?? versions[0]?.name;
|
|
30
|
+
const versionDef = versions.find((ver) => ver.name === v);
|
|
31
|
+
if (!versionDef) {
|
|
32
|
+
console.error(`CRD ${name} does not have version ${v}, available versions: ${versions
|
|
33
|
+
.map((ver) => ver.name)
|
|
34
|
+
.join(', ')}`);
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
return versionDef.schema.openAPIV3Schema;
|
|
38
|
+
}, [apiVersion, crd, name, openapi]);
|
|
39
|
+
const k8sApiDef = useMemo(() => {
|
|
40
|
+
if (!schema) {
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
if ('x-kubernetes-group-version-kind' in schema) {
|
|
44
|
+
const def = schema['x-kubernetes-group-version-kind'];
|
|
45
|
+
return Array.isArray(def) ? def[0] : def;
|
|
46
|
+
}
|
|
47
|
+
if (crd) {
|
|
48
|
+
return {
|
|
49
|
+
group: crd.spec.group,
|
|
50
|
+
version: crd.spec.versions[0].name,
|
|
51
|
+
kind: crd.spec.names.kind,
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
}, [crd, schema]);
|
|
55
|
+
if (!openapi && !crd) {
|
|
56
|
+
console.error(`No OpenAPI nor CustomResourceDefinition schema found for ${name}`);
|
|
57
|
+
return null;
|
|
58
|
+
}
|
|
59
|
+
return schema ? (_jsxs(_Fragment, { children: [_jsx(K8sAPISchema, { schema: schema, fullSchema: openapi }), _jsx(K8sAPIEndpoints, { hasStatus: !!schema.properties?.status, group: apiGroup ?? k8sApiDef?.group, version: apiVersion ?? k8sApiDef?.version ?? '', kind: apiKind ?? k8sApiDef?.kind ?? '', pathPrefix: pathPrefix })] })) : null;
|
|
60
|
+
};
|
|
61
|
+
export default K8sAPI;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import type { Options } from 'masonry-layout';
|
|
2
2
|
import { type HTMLAttributes } from 'react';
|
|
3
3
|
export interface MasonryProps extends HTMLAttributes<HTMLDivElement> {
|
|
4
|
-
options?:
|
|
4
|
+
options?: Options;
|
|
5
5
|
}
|
|
6
6
|
export declare const Masonry: ({ options, ...props }: MasonryProps) => import("react/jsx-runtime").JSX.Element;
|
|
7
7
|
export default Masonry;
|
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { useLayoutEffect, useRef } from 'react';
|
|
3
|
+
let MasonryLayout;
|
|
4
|
+
if (typeof window !== 'undefined') {
|
|
5
|
+
MasonryLayout = (await import('masonry-layout')).default;
|
|
6
|
+
}
|
|
3
7
|
export const Masonry = ({ options, ...props }) => {
|
|
4
8
|
const ref = useRef(null);
|
|
5
9
|
useLayoutEffect(() => {
|
|
6
10
|
if (!ref.current) {
|
|
7
11
|
return;
|
|
8
12
|
}
|
|
9
|
-
|
|
10
|
-
const masonry = new (require('masonry-layout'))(ref.current, options);
|
|
13
|
+
const masonry = new MasonryLayout(ref.current, options);
|
|
11
14
|
return () => {
|
|
12
15
|
masonry.destroy?.();
|
|
13
16
|
};
|
|
@@ -15,7 +15,7 @@ const getChildLink = (traverseItem) => {
|
|
|
15
15
|
return '';
|
|
16
16
|
};
|
|
17
17
|
const masonryOptions = {
|
|
18
|
-
itemSelector:
|
|
18
|
+
itemSelector: `.masonry-item`,
|
|
19
19
|
gutter: 16,
|
|
20
20
|
};
|
|
21
21
|
// The sidebar data include two types: sidebar item and sidebar group.
|
|
@@ -113,6 +113,6 @@ export function Overview(props) {
|
|
|
113
113
|
}, [getGroup, overviewSidebarGroups]);
|
|
114
114
|
const groups = customGroups ?? defaultGroups;
|
|
115
115
|
return (_jsxs("div", { className: "overview-index doom-overview-index", children: [content, groups.map((group) => (_jsxs(Fragment, { children: [(!title || [title, defaultGroupTitle].includes(group.name)) &&
|
|
116
|
-
groups.length === 1 ? (_jsx("h2", { style: { paddingTop: 0 } })) : (_jsx(FallbackHeading, { level: 2, title: group.name })), _jsx(Masonry, { className: classes.overviewGroups, options: masonryOptions, children: group.items.map((item) => (_jsxs("div", { className: classes.overviewGroup
|
|
116
|
+
groups.length === 1 ? (_jsx("h2", { style: { paddingTop: 0 } })) : (_jsx(FallbackHeading, { level: 2, title: group.name })), _jsx(Masonry, { className: classes.overviewGroups, options: masonryOptions, children: group.items.map((item) => (_jsxs("div", { className: `${classes.overviewGroup} masonry-item`, children: [_jsx("h3", { children: _jsx(Link, { href: item.link, ...renderInlineMarkdown(item.text) }) }), item.description && (_jsx("div", { className: classes.overviewDescription, children: item.description })), !item.headers?.length || (_jsx("ul", { className: classes.overviewList, children: item.headers.map((header) => (_jsx("li", { className: `${classes.overviewGroupLi} ${classes[`level${header.depth}`]}`, children: _jsx(Link, { href: `${item.link}#${header.id}`, ...renderInlineMarkdown(header.text) }) }, header.id))) }))] }, item.link))) })] }, group.name)))] }));
|
|
117
117
|
}
|
|
118
118
|
export default Overview;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export interface K8sAPIDefinition {
|
|
2
|
+
group?: string;
|
|
3
|
+
version: string;
|
|
4
|
+
kind: string;
|
|
5
|
+
}
|
|
6
|
+
export interface K8sAPIEndpointsProps extends K8sAPIDefinition {
|
|
7
|
+
hasStatus?: boolean;
|
|
8
|
+
pathPrefix?: string;
|
|
9
|
+
}
|
|
10
|
+
export declare const K8sAPIEndpoints: ({ hasStatus, group, version, kind, pathPrefix: pathPrefix_, }: K8sAPIEndpointsProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { FallbackHeading } from '@rspress/core/theme';
|
|
3
|
+
import virtual from 'doom-@api-virtual';
|
|
4
|
+
import { plural } from 'pluralize';
|
|
5
|
+
import { X } from './_X.js';
|
|
6
|
+
const QueryParameters = ({ fieldValidation = true, }) => {
|
|
7
|
+
return (_jsxs(_Fragment, { children: [_jsx("dl", { children: _jsx("dt", { children: "Query parameters" }) }), _jsxs(X.table, { children: [_jsx("thead", { children: _jsxs("tr", { children: [_jsx("th", { children: "Parameter" }), _jsx("th", { children: "Type" }), _jsx("th", { children: "Description" })] }) }), _jsxs("tbody", { children: [_jsxs("tr", { children: [_jsx("td", { children: _jsx("code", { children: "dryRun" }) }), _jsx("td", { children: _jsx("code", { children: "string" }) }), _jsx("td", { children: "When present, indicates that modifications should not be persisted. An invalid or unrecognized dryRun directive will result in an error response and no further processing of the request. Valid values are: - All: all dry run stages will be processed" })] }), fieldValidation && (_jsxs("tr", { children: [_jsx("td", { children: _jsx("code", { children: "fieldValidation" }) }), _jsx("td", { children: _jsx("code", { children: "string" }) }), _jsx("td", { children: "fieldValidation instructs the server on how to handle objects in the request (POST/PUT/PATCH) containing unknown or duplicate fields. Valid values are: - Ignore: This will ignore any unknown fields that are silently dropped from the object, and will ignore all but the last duplicate field that the decoder encounters. This is the default behavior prior to v1.23. - Warn: This will send a warning via the standard warning response header for each unknown field that is dropped from the object, and for each duplicate field that is encountered. The request will still succeed if there are no other errors, and will only persist the last of any duplicate fields. This is the default in v1.23+ - Strict: This will fail the request with a BadRequest error if any unknown fields would be dropped from the object, or if any duplicate fields are present. The error returned from the server will contain all unknown and duplicate fields encountered." })] }))] })] })] }));
|
|
8
|
+
};
|
|
9
|
+
const BodyParameters = ({ kind }) => {
|
|
10
|
+
return (_jsxs(_Fragment, { children: [_jsx("dl", { children: _jsx("dt", { children: "Body parameters" }) }), _jsxs(X.table, { children: [_jsx("thead", { children: _jsxs("tr", { children: [_jsx("th", { children: "Parameter" }), _jsx("th", { children: "Type" }), _jsx("th", { children: "Description" })] }) }), _jsx("tbody", { children: _jsxs("tr", { children: [_jsx("td", { children: _jsx("code", { children: "body" }) }), _jsxs("td", { children: [_jsx("code", { children: kind }), " schema"] }), _jsxs("td", { children: [_jsx("code", { children: "application/json" }), " formatted"] })] }) })] })] }));
|
|
11
|
+
};
|
|
12
|
+
const K8sAPIListEndpoint = ({ kind }) => (_jsxs(_Fragment, { children: [_jsxs("dl", { children: [_jsx("dt", { children: "HTTP method" }), _jsx("dd", { children: _jsx("code", { children: "DELETE" }) }), _jsx("dt", { children: "Description" }), _jsxs("dd", { children: ["delete collection of ", kind] }), _jsx("dt", { children: "HTTP responses" })] }), _jsxs(X.table, { children: [_jsx("thead", { children: _jsxs("tr", { children: [_jsx("th", { children: "HTTP code" }), _jsx("th", { children: "Response body" })] }) }), _jsxs("tbody", { children: [_jsxs("tr", { children: [_jsx("td", { children: "200 - OK" }), _jsxs("td", { children: [_jsx("code", { children: _jsx(X.a, { href: "#status", children: "Status" }) }), ' ', "schema"] })] }), _jsxs("tr", { children: [_jsx("td", { children: "401 - Unauthorized" }), _jsx("td", { children: "Empty" })] })] })] }), _jsxs("dl", { children: [_jsx("dt", { children: "HTTP method" }), _jsx("dd", { children: _jsx("code", { children: "GET" }) }), _jsx("dt", { children: "Description" }), _jsxs("dd", { children: ["list objects of kind ", kind] }), _jsx("dt", { children: "HTTP responses" })] }), _jsxs(X.table, { children: [_jsx("thead", { children: _jsxs("tr", { children: [_jsx("th", { children: "HTTP code" }), _jsx("th", { children: "Response body" })] }) }), _jsxs("tbody", { children: [_jsxs("tr", { children: [_jsx("td", { children: "200 - OK" }), _jsxs("td", { children: [_jsxs("code", { children: [kind, "List"] }), " schema"] })] }), _jsxs("tr", { children: [_jsx("td", { children: "401 - Unauthorized" }), _jsx("td", { children: "Empty" })] })] })] }), _jsxs("dl", { children: [_jsx("dt", { children: "HTTP method" }), _jsx("dd", { children: _jsx("code", { children: "POST" }) }), _jsx("dt", { children: "Description" }), _jsxs("dd", { children: ["create a new ", kind] })] }), _jsx(QueryParameters, {}), _jsx(BodyParameters, { kind: kind }), _jsx("dl", { children: _jsx("dt", { children: "HTTP responses" }) }), _jsxs(X.table, { children: [_jsx("thead", { children: _jsxs("tr", { children: [_jsx("th", { children: "HTTP code" }), _jsx("th", { children: "Response body" })] }) }), _jsxs("tbody", { children: [_jsxs("tr", { children: [_jsx("td", { children: "200 - OK" }), _jsxs("td", { children: [_jsx("code", { children: kind }), " schema"] })] }), _jsxs("tr", { children: [_jsx("td", { children: "201 - Created" }), _jsxs("td", { children: [_jsx("code", { children: kind }), " schema"] })] }), _jsxs("tr", { children: [_jsx("td", { children: "202 - Accepted" }), _jsxs("td", { children: [_jsx("code", { children: kind }), " schema"] })] }), _jsxs("tr", { children: [_jsx("td", { children: "401 - Unauthorized" }), _jsx("td", { children: "Empty" })] })] })] })] }));
|
|
13
|
+
const K8sAPIItemEndpoint = ({ kind }) => (_jsxs(_Fragment, { children: [_jsxs("dl", { children: [_jsx("dt", { children: "HTTP method" }), _jsx("dd", { children: _jsx("code", { children: "DELETE" }) }), _jsx("dt", { children: "Description" }), _jsxs("dd", { children: ["delete the specified ", kind] })] }), _jsx(QueryParameters, { fieldValidation: false }), _jsx("dl", { children: _jsx("dt", { children: "HTTP responses" }) }), _jsxs(X.table, { children: [_jsx("thead", { children: _jsxs("tr", { children: [_jsx("th", { children: "HTTP code" }), _jsx("th", { children: "Response body" })] }) }), _jsxs("tbody", { children: [_jsxs("tr", { children: [_jsx("td", { children: "200 - OK" }), _jsxs("td", { children: [_jsx("code", { children: _jsx(X.a, { href: "#status", children: "Status" }) }), ' ', "schema"] })] }), _jsxs("tr", { children: [_jsx("td", { children: "202 - Accepted" }), _jsxs("td", { children: [_jsx("code", { children: _jsx(X.a, { href: "#status", children: "Status" }) }), ' ', "schema"] })] }), _jsxs("tr", { children: [_jsx("td", { children: "401 - Unauthorized" }), _jsx("td", { children: "Empty" })] })] })] }), _jsxs("dl", { children: [_jsx("dt", { children: "HTTP method" }), _jsx("dd", { children: _jsx("code", { children: "GET" }) }), _jsx("dt", { children: "Description" }), _jsxs("dd", { children: ["read the specified ", kind] }), _jsx("dt", { children: "HTTP responses" })] }), _jsxs(X.table, { children: [_jsx("thead", { children: _jsxs("tr", { children: [_jsx("th", { children: "HTTP code" }), _jsx("th", { children: "Response body" })] }) }), _jsxs("tbody", { children: [_jsxs("tr", { children: [_jsx("td", { children: "200 - OK" }), _jsxs("td", { children: [_jsx("code", { children: kind }), " schema"] })] }), _jsxs("tr", { children: [_jsx("td", { children: "401 - Unauthorized" }), _jsx("td", { children: "Empty" })] })] })] }), _jsxs("dl", { children: [_jsx("dt", { children: "HTTP method" }), _jsx("dd", { children: _jsx("code", { children: "PATCH" }) }), _jsx("dt", { children: "Description" }), _jsxs("dd", { children: ["partially update the specified ", kind] })] }), _jsx(QueryParameters, {}), _jsx("dl", { children: _jsx("dt", { children: "HTTP responses" }) }), _jsxs(X.table, { children: [_jsx("thead", { children: _jsxs("tr", { children: [_jsx("th", { children: "HTTP code" }), _jsx("th", { children: "Response body" })] }) }), _jsxs("tbody", { children: [_jsxs("tr", { children: [_jsx("td", { children: "200 - OK" }), _jsxs("td", { children: [_jsx("code", { children: kind }), " schema"] })] }), _jsxs("tr", { children: [_jsx("td", { children: "401 - Unauthorized" }), _jsx("td", { children: "Empty" })] })] })] }), _jsxs("dl", { children: [_jsx("dt", { children: "HTTP method" }), _jsx("dd", { children: _jsx("code", { children: "PUT" }) }), _jsx("dt", { children: "Description" }), _jsxs("dd", { children: ["replace the specified ", kind] })] }), _jsx(QueryParameters, {}), _jsx(BodyParameters, { kind: kind }), _jsx("dl", { children: _jsx("dt", { children: "HTTP responses" }) }), _jsxs(X.table, { children: [_jsx("thead", { children: _jsxs("tr", { children: [_jsx("th", { children: "HTTP code" }), _jsx("th", { children: "Response body" })] }) }), _jsxs("tbody", { children: [_jsxs("tr", { children: [_jsx("td", { children: "200 - OK" }), _jsxs("td", { children: [_jsx("code", { children: kind }), " schema"] })] }), _jsxs("tr", { children: [_jsx("td", { children: "201 - Created" }), _jsxs("td", { children: [_jsx("code", { children: kind }), " schema"] })] }), _jsxs("tr", { children: [_jsx("td", { children: "401 - Unauthorized" }), _jsx("td", { children: "Empty" })] })] })] })] }));
|
|
14
|
+
const K8sAPIStatusEndpoint = ({ kind }) => (_jsxs(_Fragment, { children: [_jsxs("dl", { children: [_jsx("dt", { children: "HTTP method" }), _jsx("dd", { children: _jsx("code", { children: "GET" }) }), _jsx("dt", { children: "Description" }), _jsxs("dd", { children: ["read status of the specified ", kind] }), _jsx("dt", { children: "HTTP responses" })] }), _jsxs(X.table, { children: [_jsx("thead", { children: _jsxs("tr", { children: [_jsx("th", { children: "HTTP code" }), _jsx("th", { children: "Response body" })] }) }), _jsxs("tbody", { children: [_jsxs("tr", { children: [_jsx("td", { children: "200 - OK" }), _jsxs("td", { children: [_jsx("code", { children: kind }), " schema"] })] }), _jsxs("tr", { children: [_jsx("td", { children: "401 - Unauthorized" }), _jsx("td", { children: "Empty" })] })] })] }), _jsxs("dl", { children: [_jsx("dt", { children: "HTTP method" }), _jsx("dd", { children: _jsx("code", { children: "PATCH" }) }), _jsx("dt", { children: "Description" }), _jsxs("dd", { children: ["partially update status of the specified ", kind] })] }), _jsx(QueryParameters, {}), _jsx("dl", { children: _jsx("dt", { children: "HTTP responses" }) }), _jsxs(X.table, { children: [_jsx("thead", { children: _jsxs("tr", { children: [_jsx("th", { children: "HTTP code" }), _jsx("th", { children: "Response body" })] }) }), _jsxs("tbody", { children: [_jsxs("tr", { children: [_jsx("td", { children: "200 - OK" }), _jsxs("td", { children: [_jsx("code", { children: kind }), " schema"] })] }), _jsxs("tr", { children: [_jsx("td", { children: "401 - Unauthorized" }), _jsx("td", { children: "Empty" })] })] })] }), _jsxs("dl", { children: [_jsx("dt", { children: "HTTP method" }), _jsx("dd", { children: _jsx("code", { children: "PUT" }) }), _jsx("dt", { children: "Description" }), _jsxs("dd", { children: ["replace status of the specified ", kind] })] }), _jsx(QueryParameters, {}), _jsx(BodyParameters, { kind: kind }), _jsx("dl", { children: _jsx("dt", { children: "HTTP responses" }) }), _jsxs(X.table, { children: [_jsx("thead", { children: _jsxs("tr", { children: [_jsx("th", { children: "HTTP code" }), _jsx("th", { children: "Response body" })] }) }), _jsxs("tbody", { children: [_jsxs("tr", { children: [_jsx("td", { children: "200 - OK" }), _jsxs("td", { children: [_jsx("code", { children: kind }), " schema"] })] }), _jsxs("tr", { children: [_jsx("td", { children: "201 - Created" }), _jsxs("td", { children: [_jsx("code", { children: kind }), " schema"] })] }), _jsxs("tr", { children: [_jsx("td", { children: "401 - Unauthorized" }), _jsx("td", { children: "Empty" })] })] })] })] }));
|
|
15
|
+
export const K8sAPIEndpoints = ({ hasStatus, group, version, kind, pathPrefix: pathPrefix_, }) => {
|
|
16
|
+
const pathPrefix = pathPrefix_ ?? (virtual.pathPrefix || '');
|
|
17
|
+
const apiPath = `${pathPrefix}/${group ? `apis/${group}` : 'api'}/${version}/namespaces/{namespace}/${plural(kind).toLocaleLowerCase()}`;
|
|
18
|
+
return (_jsxs(_Fragment, { children: [_jsx(FallbackHeading, { level: 2, title: "API Endpoints" }), _jsx(X.p, { children: "The following API endpoints are available:" }), _jsxs(X.ul, { children: [_jsxs(X.li, { children: [_jsx("code", { children: apiPath }), _jsxs(X.ul, { children: [_jsxs(X.li, { children: [_jsx("code", { children: "DELETE" }), ": delete collection of ", kind] }), _jsxs(X.li, { children: [_jsx("code", { children: "GET" }), ": list objects of kind ", kind] }), _jsxs(X.li, { children: [_jsx("code", { children: "POST" }), ": create a new ", kind] })] })] }), _jsxs(X.li, { children: [_jsx("code", { children: `${apiPath}/{name}` }), _jsxs(X.ul, { children: [_jsxs(X.li, { children: [_jsx("code", { children: "DELETE" }), ": delete the specified ", kind] }), _jsxs(X.li, { children: [_jsx("code", { children: "GET" }), ": read the specified ", kind] }), _jsxs(X.li, { children: [_jsx("code", { children: "PATCH" }), ": partially update the specified ", kind] }), _jsxs(X.li, { children: [_jsx("code", { children: "PUT" }), ": replace the specified ", kind] })] })] }), hasStatus && (_jsxs(X.li, { children: [_jsx("code", { children: `${apiPath}/{name}/status` }), _jsxs(X.ul, { children: [_jsxs(X.li, { children: [_jsx("code", { children: "GET" }), ": read status of the specified ", kind] }), _jsxs(X.li, { children: [_jsx("code", { children: "PATCH" }), ": partially update status of the specified", ' ', kind] }), _jsxs(X.li, { children: [_jsx("code", { children: "PUT" }), ": replace status of the specified ", kind] })] })] }))] }), _jsx("div", { className: "rp-toc-exclude", children: _jsx(FallbackHeading, { level: 3, title: apiPath }) }), _jsx(K8sAPIListEndpoint, { kind: kind }), _jsx("div", { className: "rp-toc-exclude", children: _jsx(FallbackHeading, { level: 3, title: `${apiPath}/{name}` }) }), _jsx(K8sAPIItemEndpoint, { kind: kind }), hasStatus && (_jsxs(_Fragment, { children: [_jsx("div", { className: "rp-toc-exclude", children: _jsx(FallbackHeading, { level: 3, title: `${apiPath}/{name}/status` }) }), _jsx(K8sAPIStatusEndpoint, { kind: kind })] }))] }));
|
|
19
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { OpenAPIV3_1 } from 'openapi-types';
|
|
2
|
+
export interface K8sAPISchemaProps {
|
|
3
|
+
schema: OpenAPIV3_1.SchemaObject;
|
|
4
|
+
fullSchema?: OpenAPIV3_1.Document;
|
|
5
|
+
}
|
|
6
|
+
export interface K8sAPISchemaItemProps {
|
|
7
|
+
schema: OpenAPIV3_1.SchemaObject;
|
|
8
|
+
fullSchema?: OpenAPIV3_1.Document;
|
|
9
|
+
propertyPath?: string;
|
|
10
|
+
}
|
|
11
|
+
export declare const K8sAPISchemaItemBasic: ({ schema, }: {
|
|
12
|
+
schema: OpenAPIV3_1.SchemaObject;
|
|
13
|
+
}) => import("react/jsx-runtime").JSX.Element;
|
|
14
|
+
export declare const K8sAPISchemaItem: ({ schema, fullSchema, propertyPath, }: K8sAPISchemaItemProps) => import("react/jsx-runtime").JSX.Element;
|
|
15
|
+
export declare const K8sAPISchema: ({ schema, fullSchema }: K8sAPISchemaProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { FallbackHeading } from '@rspress/core/theme';
|
|
3
|
+
import { Fragment, useMemo } from 'react';
|
|
4
|
+
import { resolveRef } from '../utils.js';
|
|
5
|
+
import { Markdown } from './Markdown.js';
|
|
6
|
+
import { X } from './_X.js';
|
|
7
|
+
const getSchemaValue = (schema, key = 'type') => {
|
|
8
|
+
if (schema[key]) {
|
|
9
|
+
return schema[key];
|
|
10
|
+
}
|
|
11
|
+
if (schema.allOf?.length) {
|
|
12
|
+
const allOf = schema.allOf[0];
|
|
13
|
+
const value = allOf[key];
|
|
14
|
+
if (value) {
|
|
15
|
+
return value;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
if (key === 'type' && schema.oneOf?.length) {
|
|
19
|
+
return schema.oneOf.map((it) => it[key]);
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
const NESTED_SCHEMA_TYPES = new Set(['object', 'array']);
|
|
23
|
+
const METADATA = 'metadata';
|
|
24
|
+
const DEFAULT_METADATA_DESCRIPTION = 'ObjectMeta is metadata that all persisted resources must have, which includes all objects users must create.';
|
|
25
|
+
const derefSchema = (schema, fullSchema) => {
|
|
26
|
+
const $ref = getSchemaValue(schema, '$ref');
|
|
27
|
+
if (fullSchema && $ref) {
|
|
28
|
+
return resolveRef(fullSchema, $ref);
|
|
29
|
+
}
|
|
30
|
+
return schema;
|
|
31
|
+
};
|
|
32
|
+
const typeCode = (type) => (_jsx("code", { children: Array.isArray(type) ? type.join('|') : type }));
|
|
33
|
+
export const K8sAPISchemaItemBasic = ({ schema, }) => {
|
|
34
|
+
const description = getSchemaValue(schema, 'description');
|
|
35
|
+
return (_jsxs("dl", { children: [description && (_jsxs(_Fragment, { children: [_jsx("dt", { children: "Description" }), _jsx("dd", { children: description })] })), _jsx("dt", { children: "Type" }), _jsx("dd", { children: typeCode(getSchemaValue(schema)) }), schema.required && (_jsxs(_Fragment, { children: [_jsx("dt", { children: "Required" }), _jsx("dd", { children: schema.required.map((it) => (_jsx("code", { children: it }, it))) })] }))] }));
|
|
36
|
+
};
|
|
37
|
+
export const K8sAPISchemaItem = ({ schema, fullSchema, propertyPath = '', }) => {
|
|
38
|
+
const schemaType = useMemo(() => getSchemaValue(schema), [schema]);
|
|
39
|
+
const isArraySchema = schemaType === 'array';
|
|
40
|
+
const nestedSchema = useMemo(() => isArraySchema
|
|
41
|
+
? derefSchema(schema.items, fullSchema)
|
|
42
|
+
: schema, [fullSchema, isArraySchema, schema]);
|
|
43
|
+
const propertiesEntry = useMemo(() => {
|
|
44
|
+
const properties = getSchemaValue(nestedSchema, 'properties');
|
|
45
|
+
return (properties &&
|
|
46
|
+
Object.entries(properties).map(([key, value]) => [key, derefSchema(value, fullSchema)]));
|
|
47
|
+
}, [fullSchema, nestedSchema]);
|
|
48
|
+
return (_jsxs(_Fragment, { children: [_jsx(K8sAPISchemaItemBasic, { schema: schema }), !propertyPath && _jsx(FallbackHeading, { level: 2, title: "Specification" }), isArraySchema && (_jsxs(_Fragment, { children: [_jsx("div", { className: "rp-toc-exclude", children: _jsx(FallbackHeading, { level: 3, title: `${propertyPath}[]` }) }), _jsx(K8sAPISchemaItemBasic, { schema: nestedSchema })] })), propertiesEntry && (_jsxs(_Fragment, { children: [_jsxs(X.table, { children: [_jsx("thead", { children: _jsxs("tr", { children: [_jsx("th", { children: "Property" }), _jsx("th", { children: "Type" }), _jsx("th", { children: "Description" })] }) }), _jsx("tbody", { children: propertiesEntry.map(([key, value]) => {
|
|
49
|
+
const description = getSchemaValue(value, 'description');
|
|
50
|
+
const isMetadata = key === METADATA;
|
|
51
|
+
return (_jsxs("tr", { children: [_jsx("td", { children: _jsx("code", { children: key }) }), _jsx("td", { children: isMetadata ? (_jsx("code", { children: _jsx(X.a, { href: "/apis/references/ObjectMeta.html", children: "ObjectMeta" }) })) : (typeCode(getSchemaValue(value))) }), _jsx("td", { children: _jsx(Markdown, { children: description ||
|
|
52
|
+
(isMetadata ? DEFAULT_METADATA_DESCRIPTION : '') }) })] }, key));
|
|
53
|
+
}) })] }), propertiesEntry.map(([key, value]) => {
|
|
54
|
+
const type = getSchemaValue(value);
|
|
55
|
+
if (!NESTED_SCHEMA_TYPES.has(type) || key === METADATA) {
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
const nestedPropertyPath = `${propertyPath}${isArraySchema ? '[]' : ''}.${key}`;
|
|
59
|
+
return (_jsxs(Fragment, { children: [_jsx("div", { className: "rp-toc-exclude", children: _jsx(FallbackHeading, { level: 3, title: nestedPropertyPath }) }), _jsx(K8sAPISchemaItem, { schema: value, fullSchema: fullSchema, propertyPath: nestedPropertyPath })] }, key));
|
|
60
|
+
})] }))] }));
|
|
61
|
+
};
|
|
62
|
+
export const K8sAPISchema = ({ schema, fullSchema }) => (_jsx(K8sAPISchemaItem, { schema: schema, fullSchema: fullSchema }));
|
|
@@ -6,6 +6,7 @@ export * from './ExternalApisOverview.js';
|
|
|
6
6
|
export * from './ExternalSite.js';
|
|
7
7
|
export * from './ExternalSiteLink.js';
|
|
8
8
|
export * from './JsonViewer.js';
|
|
9
|
+
export * from './K8sAPI.js';
|
|
9
10
|
export * from './K8sCrd.js';
|
|
10
11
|
export * from './K8sPermissionTable.js';
|
|
11
12
|
export * from './Markdown.js';
|
|
@@ -6,6 +6,7 @@ export * from './ExternalApisOverview.js';
|
|
|
6
6
|
export * from './ExternalSite.js';
|
|
7
7
|
export * from './ExternalSiteLink.js';
|
|
8
8
|
export * from './JsonViewer.js';
|
|
9
|
+
export * from './K8sAPI.js';
|
|
9
10
|
export * from './K8sCrd.js';
|
|
10
11
|
export * from './K8sPermissionTable.js';
|
|
11
12
|
export * from './Markdown.js';
|
package/package.json
CHANGED
package/styles/global.scss
CHANGED
|
@@ -174,4 +174,26 @@ td {
|
|
|
174
174
|
}
|
|
175
175
|
}
|
|
176
176
|
|
|
177
|
+
.rp-doc {
|
|
178
|
+
dl {
|
|
179
|
+
margin: 1rem 0;
|
|
180
|
+
|
|
181
|
+
dt {
|
|
182
|
+
font-weight: 600;
|
|
183
|
+
margin: 0.5rem 0;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
dd {
|
|
187
|
+
display: flex;
|
|
188
|
+
flex-wrap: wrap;
|
|
189
|
+
gap: 0.5rem;
|
|
190
|
+
margin: 0.5rem 0 0.5rem 1rem;
|
|
191
|
+
|
|
192
|
+
> p {
|
|
193
|
+
margin: 0.5rem 0;
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
|
|
177
199
|
@import 'intelligence.scss';
|