@alauda/doom 2.5.3 → 2.6.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/cli/api.d.ts +2 -0
- package/lib/cli/api.js +147 -0
- package/lib/cli/helpers.d.ts +1 -7
- package/lib/cli/helpers.js +4 -41
- package/lib/cli/index.js +2 -0
- package/lib/cli/translate-agent.d.ts +81 -0
- package/lib/cli/translate-agent.js +450 -0
- package/lib/cli/translate-check.d.ts +17 -0
- package/lib/cli/translate-check.js +67 -0
- package/lib/cli/translate-checker.d.ts +58 -0
- package/lib/cli/translate-checker.js +112 -0
- package/lib/cli/translate-judge.d.ts +119 -0
- package/lib/cli/translate-judge.js +224 -0
- package/lib/cli/translate-limits.d.ts +43 -0
- package/lib/cli/translate-limits.js +55 -0
- package/lib/cli/translate-mask.d.ts +144 -0
- package/lib/cli/translate-mask.js +617 -0
- package/lib/cli/translate-models.d.ts +127 -0
- package/lib/cli/translate-models.js +189 -0
- package/lib/cli/translate-scratch.d.ts +142 -0
- package/lib/cli/translate-scratch.js +187 -0
- package/lib/cli/translate-terms.d.ts +22 -0
- package/lib/cli/translate-terms.js +33 -0
- package/lib/cli/translate.d.ts +15 -10
- package/lib/cli/translate.js +228 -185
- package/lib/eslint.js +48 -5
- package/lib/plugins/api/index.js +1 -1
- package/lib/plugins/api/types.d.ts +36 -1
- package/lib/plugins/global/components.d.ts +18 -0
- package/lib/plugins/global/components.js +33 -0
- package/lib/plugins/global/index.js +2 -10
- package/lib/remark-lint/index.d.ts +20 -0
- package/lib/remark-lint/index.js +40 -0
- package/lib/remark-lint/no-unmatched-anchor.d.ts +10 -0
- package/lib/remark-lint/no-unmatched-anchor.js +13 -0
- package/lib/remark-lint/no-unopened-frontmatter.d.ts +2 -0
- package/lib/remark-lint/no-unopened-frontmatter.js +70 -0
- package/lib/remark-lint/no-unparsed-emphasis.d.ts +2 -0
- package/lib/remark-lint/no-unparsed-emphasis.js +53 -0
- package/lib/remark-lint/no-unresolved-api-ref.d.ts +40 -0
- package/lib/remark-lint/no-unresolved-api-ref.js +194 -0
- package/lib/remark-lint/rule-sets.d.ts +75 -0
- package/lib/remark-lint/rule-sets.js +120 -0
- package/lib/remark-lint/translation-parity/component-multiset.d.ts +17 -0
- package/lib/remark-lint/translation-parity/component-multiset.js +35 -0
- package/lib/remark-lint/translation-parity/echoed-source.d.ts +2 -0
- package/lib/remark-lint/translation-parity/echoed-source.js +37 -0
- package/lib/remark-lint/translation-parity/frontmatter-preservation.d.ts +2 -0
- package/lib/remark-lint/translation-parity/frontmatter-preservation.js +36 -0
- package/lib/remark-lint/translation-parity/heading-sequence.d.ts +12 -0
- package/lib/remark-lint/translation-parity/heading-sequence.js +25 -0
- package/lib/remark-lint/translation-parity/index.d.ts +24 -0
- package/lib/remark-lint/translation-parity/index.js +24 -0
- package/lib/remark-lint/translation-parity/jsx-attribute-parity.d.ts +14 -0
- package/lib/remark-lint/translation-parity/jsx-attribute-parity.js +47 -0
- package/lib/remark-lint/translation-parity/length-ratio.d.ts +2 -0
- package/lib/remark-lint/translation-parity/length-ratio.js +49 -0
- package/lib/remark-lint/translation-parity/link-isomorphism.d.ts +26 -0
- package/lib/remark-lint/translation-parity/link-isomorphism.js +45 -0
- package/lib/remark-lint/translation-parity/shared.d.ts +110 -0
- package/lib/remark-lint/translation-parity/shared.js +282 -0
- package/lib/remark-lint/translation-parity/terminology-adherence.d.ts +2 -0
- package/lib/remark-lint/translation-parity/terminology-adherence.js +67 -0
- package/lib/remark-lint/translation-parity/up-to-date.d.ts +11 -0
- package/lib/remark-lint/translation-parity/up-to-date.js +21 -0
- package/lib/remark-lint/translation-parity/url-residue.d.ts +2 -0
- package/lib/remark-lint/translation-parity/url-residue.js +46 -0
- package/lib/remarkrc.d.ts +1 -1
- package/lib/remarkrc.js +7 -34
- package/lib/runtime/api-paths.d.ts +20 -0
- package/lib/runtime/api-paths.js +29 -0
- package/lib/runtime/components/K8sAPI.d.ts +14 -1
- package/lib/runtime/components/K8sAPI.js +49 -10
- package/lib/runtime/components/K8sCrd.d.ts +1 -1
- package/lib/runtime/components/K8sPermissionTable.js +10 -5
- package/lib/runtime/components/OpenAPIPath.js +19 -2
- package/lib/runtime/components/_HeadingTitle.js +24 -6
- package/lib/runtime/components/_K8sAPIEndpoints.d.ts +8 -1
- package/lib/runtime/components/_K8sAPIEndpoints.js +27 -9
- package/lib/runtime/components/_K8sAPISchema.d.ts +9 -1
- package/lib/runtime/components/_K8sAPISchema.js +24 -6
- package/lib/runtime/components/_translation-policy.d.ts +23 -0
- package/lib/runtime/components/_translation-policy.js +32 -0
- package/lib/runtime/hooks/useTranslation.d.ts +1 -1
- package/lib/runtime/translation.d.ts +68 -0
- package/lib/runtime/translation.js +51 -0
- package/lib/runtime/utils.d.ts +24 -2
- package/lib/runtime/utils.js +87 -5
- package/lib/shared/constants.d.ts +9 -0
- package/lib/shared/constants.js +14 -0
- package/lib/types.d.ts +70 -0
- package/lib/utils/helpers.js +8 -2
- package/package.json +3 -1
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { lintRule } from 'unified-lint-rule';
|
|
2
|
+
import { visit } from 'unist-util-visit';
|
|
3
|
+
import { currentPair, diffMultiset } from "./shared.js";
|
|
4
|
+
/**
|
|
5
|
+
* URLs written in prose that markdown does not turn into links still survive
|
|
6
|
+
* translation.
|
|
7
|
+
*
|
|
8
|
+
* This is the other half of a deliberate asymmetry. A URL with a scheme becomes
|
|
9
|
+
* a link node and is protected structurally; a bare `example.com` or an
|
|
10
|
+
* `ftp://…` stays plain text, and protecting *that* would mean pattern-matching
|
|
11
|
+
* inside prose — the one way masking could swallow something that ought to have
|
|
12
|
+
* been translated. So it is checked instead: a check that misfires costs one
|
|
13
|
+
* finding to read, whereas a mask that misfires hides a sentence.
|
|
14
|
+
*
|
|
15
|
+
* The pattern insists on a scheme or a `www.`, which is narrower than "looks
|
|
16
|
+
* like a domain" on purpose. A first attempt matched any `name.tld/path` and
|
|
17
|
+
* reported seven documents — every one an API group or an annotation key
|
|
18
|
+
* (`autoscaling.k8s.io/v1`, `kubevirt.io/storage`) that had merely moved
|
|
19
|
+
* between prose and inline code. Those are identifiers, not links, and a guard
|
|
20
|
+
* that cries wolf about them is worse than no guard at all.
|
|
21
|
+
*
|
|
22
|
+
* Honest caveat: measured exposure on this corpus is zero — all seven bare URLs
|
|
23
|
+
* carry `https://`, which makes them link nodes, protected structurally. This
|
|
24
|
+
* is a guard for a case nothing else covers, not a demonstrated detector.
|
|
25
|
+
*/
|
|
26
|
+
const BARE_URL = /\b(?:[a-z][a-z0-9+.-]*:\/\/|www\.)\S+/gi;
|
|
27
|
+
const collect = (tree) => {
|
|
28
|
+
const found = [];
|
|
29
|
+
visit(tree, 'text', (node) => {
|
|
30
|
+
for (const [match] of node.value.matchAll(BARE_URL)) {
|
|
31
|
+
found.push(match);
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
return found;
|
|
35
|
+
};
|
|
36
|
+
export const translationUrlResidue = lintRule('doom-lint:translation-url-residue', async (tree, vfile) => {
|
|
37
|
+
const pair = await currentPair(tree, vfile);
|
|
38
|
+
if (!pair) {
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
const { missing } = diffMultiset(collect(pair.sourceTree), collect(tree));
|
|
42
|
+
if (!missing.length) {
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
vfile.message(`Translation lost ${missing.length} URL(s) written in prose: ${missing.map((url) => `\`${url}\``).join(', ')}. These are plain text rather than links, so nothing protects them structurally.`, tree);
|
|
46
|
+
});
|
package/lib/remarkrc.d.ts
CHANGED
package/lib/remarkrc.js
CHANGED
|
@@ -1,39 +1,12 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import remarkGfm from 'remark-gfm';
|
|
4
|
-
// @ts-expect-error -- https://github.com/ilyatitovich/remark-lint-code-block-split-list/issues/2
|
|
5
|
-
import remarkLintCodeBlockSplitList from 'remark-lint-code-block-split-list';
|
|
6
|
-
import remarkLintHeadingIncrement from 'remark-lint-heading-increment';
|
|
7
|
-
// @ts-expect-error -- https://github.com/laysent/remark-lint-plugins/issues/51
|
|
8
|
-
import remarkLintLintMatchPunctuation from 'remark-lint-match-punctuation';
|
|
9
|
-
// @ts-expect-error -- https://github.com/laysent/remark-lint-plugins/issues/51
|
|
10
|
-
import remarkLintNoChinesePunctuationInNumber from 'remark-lint-no-chinese-punctuation-in-number';
|
|
11
|
-
import remarkLintNoDuplicateHeadingsInSection from 'remark-lint-no-duplicate-headings-in-section';
|
|
12
|
-
import remarkLintNoHiddenTableCell from 'remark-lint-no-hidden-table-cell';
|
|
13
|
-
import doomLint, { checkDeadLinks, headingAnchorFormat, noDeepHeading, noDeepList, noLegacyOSNames, noMultiOpenAPIPaths, noParagraphIndent, noUnmatchedAnchor, site, tableSize, titleRequired, unitCase, } from "./remark-lint/index.js";
|
|
1
|
+
import doomLint from "./remark-lint/index.js";
|
|
2
|
+
import { LINT_RULES, SYNTAX_PLUGINS } from "./remark-lint/rule-sets.js";
|
|
14
3
|
export default {
|
|
15
4
|
plugins: [
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
remarkLintHeadingIncrement,
|
|
21
|
-
remarkLintLintMatchPunctuation,
|
|
22
|
-
remarkLintNoChinesePunctuationInNumber,
|
|
23
|
-
remarkLintNoDuplicateHeadingsInSection,
|
|
24
|
-
remarkLintNoHiddenTableCell,
|
|
5
|
+
...SYNTAX_PLUGINS,
|
|
6
|
+
// Message control (`<!-- lint disable -->`). It registers its transformer
|
|
7
|
+
// from inside its own attacher, which lands it at the end of the queue, so
|
|
8
|
+
// it filters the messages of every rule regardless of where it sits here.
|
|
25
9
|
doomLint,
|
|
26
|
-
|
|
27
|
-
headingAnchorFormat,
|
|
28
|
-
noDeepHeading,
|
|
29
|
-
noDeepList,
|
|
30
|
-
noLegacyOSNames,
|
|
31
|
-
noMultiOpenAPIPaths,
|
|
32
|
-
noParagraphIndent,
|
|
33
|
-
noUnmatchedAnchor,
|
|
34
|
-
site,
|
|
35
|
-
tableSize,
|
|
36
|
-
titleRequired,
|
|
37
|
-
unitCase,
|
|
10
|
+
...LINT_RULES,
|
|
38
11
|
],
|
|
39
12
|
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Reading facts off an OpenAPI document's `paths`.
|
|
3
|
+
*
|
|
4
|
+
* Kept free of the `doom-@api-*` virtual modules so it stays importable — and
|
|
5
|
+
* therefore testable — outside a build.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Whether an OpenAPI document declares a `/status` subresource route for a
|
|
9
|
+
* resource.
|
|
10
|
+
*
|
|
11
|
+
* A `/status` endpoint exists because the API server routes it, not because the
|
|
12
|
+
* resource's schema happens to carry a `status` property — a property is state,
|
|
13
|
+
* a route is an interface. CRDs say so in `subresources.status`; an OpenAPI
|
|
14
|
+
* document says so by listing the route.
|
|
15
|
+
*
|
|
16
|
+
* Returns `undefined` when the document does not describe the resource's routes
|
|
17
|
+
* at all: it then says nothing about the subresource either, and the caller must
|
|
18
|
+
* fall back to a weaker signal rather than read the silence as a denial.
|
|
19
|
+
*/
|
|
20
|
+
export declare const declaresStatusSubresource: (paths: string[], pluralName: string | undefined) => boolean | undefined;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Reading facts off an OpenAPI document's `paths`.
|
|
3
|
+
*
|
|
4
|
+
* Kept free of the `doom-@api-*` virtual modules so it stays importable — and
|
|
5
|
+
* therefore testable — outside a build.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Whether an OpenAPI document declares a `/status` subresource route for a
|
|
9
|
+
* resource.
|
|
10
|
+
*
|
|
11
|
+
* A `/status` endpoint exists because the API server routes it, not because the
|
|
12
|
+
* resource's schema happens to carry a `status` property — a property is state,
|
|
13
|
+
* a route is an interface. CRDs say so in `subresources.status`; an OpenAPI
|
|
14
|
+
* document says so by listing the route.
|
|
15
|
+
*
|
|
16
|
+
* Returns `undefined` when the document does not describe the resource's routes
|
|
17
|
+
* at all: it then says nothing about the subresource either, and the caller must
|
|
18
|
+
* fall back to a weaker signal rather than read the silence as a denial.
|
|
19
|
+
*/
|
|
20
|
+
export const declaresStatusSubresource = (paths, pluralName) => {
|
|
21
|
+
if (!pluralName) {
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
const covers = (path) => path.includes(`/${pluralName}/`) || path.endsWith(`/${pluralName}`);
|
|
25
|
+
if (!paths.some(covers)) {
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
return paths.some((path) => path.endsWith('/status') && covers(path));
|
|
29
|
+
};
|
|
@@ -6,6 +6,19 @@ export interface K8sAPIProps {
|
|
|
6
6
|
apiGroup?: string;
|
|
7
7
|
apiVersion?: string;
|
|
8
8
|
apiKind?: string;
|
|
9
|
+
/**
|
|
10
|
+
* Override the resource's plural name in the endpoint paths. Only needed for
|
|
11
|
+
* OpenAPI-sourced resources whose plural cannot be read from a CRD; for CRD
|
|
12
|
+
* sources the plural comes from `spec.names.plural` automatically.
|
|
13
|
+
*/
|
|
14
|
+
plural?: string;
|
|
15
|
+
/**
|
|
16
|
+
* Whether the API server exposes a `/status` subresource. Declared by the
|
|
17
|
+
* caller when the source cannot be trusted to answer — an aggregation-layer
|
|
18
|
+
* OpenAPI document may describe neither the subresource routes nor the
|
|
19
|
+
* resource's own routes.
|
|
20
|
+
*/
|
|
21
|
+
hasStatus?: boolean;
|
|
9
22
|
}
|
|
10
|
-
export declare const K8sAPI: ({ name, namespaced, pathPrefix, filepath, apiGroup, apiVersion, apiKind, }: K8sAPIProps) => import("react/jsx-runtime").JSX.Element | null;
|
|
23
|
+
export declare const K8sAPI: ({ name, namespaced, pathPrefix, filepath, apiGroup, apiVersion, apiKind, plural, hasStatus, }: K8sAPIProps) => import("react/jsx-runtime").JSX.Element | null;
|
|
11
24
|
export default K8sAPI;
|
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import crdsMap from 'doom-@api-crdsMap';
|
|
3
3
|
import openapisMap from 'doom-@api-openapisMap';
|
|
4
|
+
import virtual from 'doom-@api-virtual';
|
|
5
|
+
import { plural as pluralize } from 'pluralize';
|
|
4
6
|
import { useMemo } from 'react';
|
|
5
|
-
import {
|
|
7
|
+
import { declaresStatusSubresource } from '../api-paths.js';
|
|
8
|
+
import { resolveRef, selectCrdVersionName } from '../utils.js';
|
|
6
9
|
import { K8sAPIEndpoints } from './_K8sAPIEndpoints.js';
|
|
7
10
|
import { K8sAPISchema } from './_K8sAPISchema.js';
|
|
8
|
-
export const K8sAPI = ({ name, namespaced, pathPrefix, filepath, apiGroup, apiVersion, apiKind, }) => {
|
|
11
|
+
export const K8sAPI = ({ name, namespaced, pathPrefix, filepath, apiGroup, apiVersion, apiKind, plural, hasStatus, }) => {
|
|
9
12
|
const [, openapi] = useMemo(() => Object.entries(openapisMap).find(([pathname, openapi]) => {
|
|
10
13
|
if (filepath && pathname !== filepath) {
|
|
11
14
|
return;
|
|
@@ -18,6 +21,15 @@ export const K8sAPI = ({ name, namespaced, pathPrefix, filepath, apiGroup, apiVe
|
|
|
18
21
|
}
|
|
19
22
|
return crd.metadata.name === name;
|
|
20
23
|
}) || [], [filepath, name]);
|
|
24
|
+
// The version this page renders: an explicit `apiVersion` prop wins,
|
|
25
|
+
// otherwise the version `kubectl` would resolve to (see `selectCrdVersionName`
|
|
26
|
+
// / `api.crdVersion`). Used consistently for the schema AND the endpoint
|
|
27
|
+
// paths so the two never disagree.
|
|
28
|
+
const resolvedVersion = useMemo(() => crd
|
|
29
|
+
? (apiVersion ??
|
|
30
|
+
selectCrdVersionName(crd.spec.versions, virtual.crdVersion))
|
|
31
|
+
: apiVersion, [apiVersion, crd]);
|
|
32
|
+
const versionDef = useMemo(() => crd?.spec.versions.find((ver) => ver.name === resolvedVersion), [crd, resolvedVersion]);
|
|
21
33
|
const schema = useMemo(() => {
|
|
22
34
|
if (openapi) {
|
|
23
35
|
return resolveRef(openapi, name);
|
|
@@ -25,17 +37,14 @@ export const K8sAPI = ({ name, namespaced, pathPrefix, filepath, apiGroup, apiVe
|
|
|
25
37
|
if (!crd) {
|
|
26
38
|
return;
|
|
27
39
|
}
|
|
28
|
-
const { versions } = crd.spec;
|
|
29
|
-
const v = apiVersion ?? versions[0]?.name;
|
|
30
|
-
const versionDef = versions.find((ver) => ver.name === v);
|
|
31
40
|
if (!versionDef) {
|
|
32
|
-
console.error(`CRD ${name} does not have version ${
|
|
41
|
+
console.error(`CRD ${name} does not have version ${resolvedVersion}, available versions: ${crd.spec.versions
|
|
33
42
|
.map((ver) => ver.name)
|
|
34
43
|
.join(', ')}`);
|
|
35
44
|
return;
|
|
36
45
|
}
|
|
37
46
|
return versionDef.schema.openAPIV3Schema;
|
|
38
|
-
}, [
|
|
47
|
+
}, [crd, name, openapi, resolvedVersion, versionDef]);
|
|
39
48
|
const k8sApiDef = useMemo(() => {
|
|
40
49
|
if (!schema) {
|
|
41
50
|
return;
|
|
@@ -47,15 +56,45 @@ export const K8sAPI = ({ name, namespaced, pathPrefix, filepath, apiGroup, apiVe
|
|
|
47
56
|
if (crd) {
|
|
48
57
|
return {
|
|
49
58
|
group: crd.spec.group,
|
|
50
|
-
version: crd.spec.versions[0].name,
|
|
59
|
+
version: resolvedVersion ?? crd.spec.versions[0].name,
|
|
51
60
|
kind: crd.spec.names.kind,
|
|
52
61
|
};
|
|
53
62
|
}
|
|
54
|
-
}, [crd, schema]);
|
|
63
|
+
}, [crd, resolvedVersion, schema]);
|
|
64
|
+
// The endpoint paths are built by concatenating group / version / plural. An
|
|
65
|
+
// unknown segment used to fall back to `''`, which concatenates into a
|
|
66
|
+
// silently broken path such as `/api//` — a guess dressed up as a fact. Merge
|
|
67
|
+
// the caller's props with whatever the fact sources yielded, then render the
|
|
68
|
+
// endpoints only if the result is actually complete.
|
|
69
|
+
const group = apiGroup ?? k8sApiDef?.group;
|
|
70
|
+
const version = apiVersion ?? k8sApiDef?.version;
|
|
71
|
+
const kind = apiKind ?? k8sApiDef?.kind;
|
|
72
|
+
const pluralName = plural ??
|
|
73
|
+
crd?.spec.names.plural ??
|
|
74
|
+
(kind ? pluralize(kind).toLowerCase() : undefined);
|
|
75
|
+
// `subresources.status` is the CRD's own declaration. An OpenAPI source has
|
|
76
|
+
// no such field, so the routes it lists are the next best fact; only when it
|
|
77
|
+
// lists none for this resource does the weaker "the schema has a `status`
|
|
78
|
+
// property" signal still apply (see `declaresStatusSubresource`).
|
|
79
|
+
const derivedHasStatus = useMemo(() => {
|
|
80
|
+
if (crd) {
|
|
81
|
+
return !!versionDef?.subresources?.status;
|
|
82
|
+
}
|
|
83
|
+
if (!schema) {
|
|
84
|
+
return false;
|
|
85
|
+
}
|
|
86
|
+
return (declaresStatusSubresource(Object.keys(openapi?.paths ?? {}), pluralName) ?? !!schema.properties?.status);
|
|
87
|
+
}, [crd, openapi, pluralName, schema, versionDef]);
|
|
55
88
|
if (!openapi && !crd) {
|
|
56
89
|
console.error(`No OpenAPI nor CustomResourceDefinition schema found for ${name}`);
|
|
57
90
|
return null;
|
|
58
91
|
}
|
|
59
|
-
|
|
92
|
+
// `group` is legitimately absent for core-group resources (`/api/v1/...`);
|
|
93
|
+
// `version` and `kind` are not — without them there is no path to render.
|
|
94
|
+
const endpointDef = version && kind ? { group, version, kind } : undefined;
|
|
95
|
+
if (schema && !endpointDef) {
|
|
96
|
+
console.error(`Cannot resolve the group/version/kind of ${name}: its OpenAPI schema carries no \`x-kubernetes-group-version-kind\` extension and no CustomResourceDefinition defines it. Pass explicit \`apiVersion\` and \`apiKind\` props (plus \`apiGroup\` for non-core groups, and \`plural\` if the plural is irregular). Omitting the API endpoints section.`);
|
|
97
|
+
}
|
|
98
|
+
return schema ? (_jsxs(_Fragment, { children: [_jsx(K8sAPISchema, { schema: schema, fullSchema: openapi }), endpointDef && (_jsx(K8sAPIEndpoints, { ...endpointDef, hasStatus: hasStatus ?? derivedHasStatus, hasScale: crd ? !!versionDef?.subresources?.scale : undefined, plural: pluralName, pathPrefix: pathPrefix, namespaced: namespaced ?? (crd ? crd.spec.scope === 'Namespaced' : undefined) }))] })) : null;
|
|
60
99
|
};
|
|
61
100
|
export default K8sAPI;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @deprecated Use `K8sAPI` component instead
|
|
3
3
|
*/
|
|
4
|
-
export declare const K8sCrd: ({ name, namespaced, pathPrefix, filepath, apiGroup, apiVersion, apiKind, }: import("./K8sAPI.js").K8sAPIProps) => import("react/jsx-runtime").JSX.Element | null;
|
|
4
|
+
export declare const K8sCrd: ({ name, namespaced, pathPrefix, filepath, apiGroup, apiVersion, apiKind, plural, hasStatus, }: import("./K8sAPI.js").K8sAPIProps) => import("react/jsx-runtime").JSX.Element | null;
|
|
5
5
|
export default K8sCrd;
|
|
@@ -49,13 +49,15 @@ const RolesPermission = ({ functionResource, roleTemplates, verb, }) => {
|
|
|
49
49
|
};
|
|
50
50
|
const allFunctionResources = Object.values(functionResourcesMap).reduce((acc, curr) => Object.assign(acc, ...curr.map((fr) => ({ [fr.metadata.name]: fr }))), {});
|
|
51
51
|
export const K8sPermissionTable = ({ functions }) => {
|
|
52
|
-
const functionResources = useMemo(() => functions.
|
|
52
|
+
const functionResources = useMemo(() => functions.map((name) => {
|
|
53
53
|
const matched = allFunctionResources[name];
|
|
54
54
|
if (!matched) {
|
|
55
|
+
// Do NOT drop the row: a missing FunctionResource used to vanish
|
|
56
|
+
// silently, leaving a complete-looking table with a build exit 0.
|
|
57
|
+
// Keep it visible and log for the build-integrity summary.
|
|
55
58
|
console.error(`FunctionResource \`${name}\` not found!\n`);
|
|
56
|
-
return [];
|
|
57
59
|
}
|
|
58
|
-
return matched;
|
|
60
|
+
return { name, resource: matched };
|
|
59
61
|
}),
|
|
60
62
|
// eslint-disable-next-line @eslint-react/exhaustive-deps
|
|
61
63
|
functions);
|
|
@@ -67,8 +69,11 @@ export const K8sPermissionTable = ({ functions }) => {
|
|
|
67
69
|
const isZh = lang === 'zh';
|
|
68
70
|
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
|
|
69
71
|
? annotations[DISPLAY_NAME_ZH]
|
|
70
|
-
: annotations[DISPLAY_NAME_EN] }, name)))] }) }), _jsx("tbody", { children: functionResources.map((fr) => {
|
|
71
|
-
|
|
72
|
+
: annotations[DISPLAY_NAME_EN] }, name)))] }) }), _jsx("tbody", { children: functionResources.map(({ name, resource: fr }) => {
|
|
73
|
+
if (!fr) {
|
|
74
|
+
return (_jsxs(X.tr, { children: [_jsx(X.td, { style: TEXT_CENTER_STYLE, children: _jsx("code", { children: name }) }), _jsxs(X.td, { colSpan: 1 + roleTemplates.length, children: [_jsx("code", { children: "FunctionResource" }), " ", _jsx("code", { children: name }), " not found"] })] }, name));
|
|
75
|
+
}
|
|
76
|
+
const { metadata: { annotations }, } = fr;
|
|
72
77
|
return (_jsxs(Fragment, { children: [_jsxs(X.tr, { children: [_jsxs(X.td, { rowSpan: 4, style: TEXT_CENTER_STYLE, children: [isZh
|
|
73
78
|
? annotations[FUNCTION_DISPLAY_NAME_ZH]
|
|
74
79
|
: annotations[FUNCTION_DISPLAY_NAME_EN], _jsx("br", {}), _jsx("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));
|
|
@@ -6,6 +6,7 @@ import openapisMap from 'doom-@api-openapisMap';
|
|
|
6
6
|
import virtual from 'doom-@api-virtual';
|
|
7
7
|
import { OpenAPIV3 } from 'openapi-types';
|
|
8
8
|
import { Fragment, useMemo } from 'react';
|
|
9
|
+
import { useTranslation } from '../hooks/index.js';
|
|
9
10
|
import { omitRoutePathRefs, resolveRef } from '../utils.js';
|
|
10
11
|
import { Markdown } from './Markdown.js';
|
|
11
12
|
import { OpenAPIProperties, OpenAPIProperty, OpenAPIRef } from './OpenAPIRef.js';
|
|
@@ -87,12 +88,13 @@ const setRefsForPath = (openapi, path, knownRefs, refs) => {
|
|
|
87
88
|
}
|
|
88
89
|
};
|
|
89
90
|
const OpenAPIPathBase = ({ path, pathItem, openapi, pathPrefix: pathPrefix_, slugger, }) => {
|
|
91
|
+
const t = useTranslation();
|
|
90
92
|
const pathPrefix = pathPrefix_ ?? (virtual.pathPrefix || '');
|
|
91
93
|
if (!pathItem || !openapi) {
|
|
92
94
|
console.error(`No OpenAPI path definition found for ${path}`);
|
|
93
95
|
return null;
|
|
94
96
|
}
|
|
95
|
-
return (_jsxs(_Fragment, { children: [_jsxs(HeadingTitle, { slugger: slugger, level: 2, children: [pathPrefix, path] }), pathItem.parameters && (_jsxs(_Fragment, { children: [_jsx(HeadingTitle, { slugger: slugger, level: 3, children:
|
|
97
|
+
return (_jsxs(_Fragment, { children: [_jsxs(HeadingTitle, { slugger: slugger, level: 2, children: [pathPrefix, path] }), pathItem.parameters && (_jsxs(_Fragment, { children: [_jsx(HeadingTitle, { slugger: slugger, level: 3, children: t('common_parameters') }), _jsx(OpenAPIParameters, { parameters: pathItem.parameters, openapi: openapi })] })), Object.values(OpenAPIV3.HttpMethods).map((method) => {
|
|
96
98
|
if (!pathItem[method]) {
|
|
97
99
|
return null;
|
|
98
100
|
}
|
|
@@ -108,7 +110,16 @@ const OpenAPIPathBase = ({ path, pathItem, openapi, pathPrefix: pathPrefix_, slu
|
|
|
108
110
|
const requestBodySchema = requestBodyRef
|
|
109
111
|
? resolveRef(openapi, requestBodyRef)
|
|
110
112
|
: undefined;
|
|
111
|
-
|
|
113
|
+
// Whether the request body itself is required — the boolean on the
|
|
114
|
+
// RequestBodyObject. NOT `requestBodySchema.required`, which is the
|
|
115
|
+
// list of required *properties* of the body schema (truthy whenever the
|
|
116
|
+
// body has any required field, which is unrelated).
|
|
117
|
+
const requestBodyObj = requestBody &&
|
|
118
|
+
('$ref' in requestBody
|
|
119
|
+
? resolveRef(openapi, requestBody.$ref)
|
|
120
|
+
: requestBody);
|
|
121
|
+
const requestBodyRequired = !!requestBodyObj?.required;
|
|
122
|
+
return (_jsxs(Fragment, { children: [_jsxs(HeadingTitle, { slugger: slugger, level: 3, children: [_jsx("code", { children: method }), " ", summary] }), _jsx(Markdown, { children: description }), parameters && (_jsxs(_Fragment, { children: [_jsx(HeadingTitle, { slugger: slugger, level: 4, children: t('parameters') }), _jsx(OpenAPIParameters, { parameters: parameters, openapi: openapi })] })), requestBodySchema && (_jsxs(_Fragment, { children: [_jsx(HeadingTitle, { slugger: slugger, level: 4, children: t('request_body') }), _jsxs(X.p, { children: [_jsx(RefLink, { "$ref": requestBodyRef }), requestBodyRequired && _jsx(Badge, { children: "required" })] })] })), responses && (_jsxs(_Fragment, { children: [_jsx(HeadingTitle, { slugger: slugger, level: 4, children: t('response') }), _jsx(OpenAPIResponses, { responses: responses, openapi: openapi })] }))] }, method));
|
|
112
123
|
})] }));
|
|
113
124
|
};
|
|
114
125
|
export const OpenAPIPath = ({ path, openapiPath, pathPrefix, }) => {
|
|
@@ -122,6 +133,12 @@ export const OpenAPIPath = ({ path, openapiPath, pathPrefix, }) => {
|
|
|
122
133
|
continue;
|
|
123
134
|
}
|
|
124
135
|
for (const path of paths) {
|
|
136
|
+
// First matched file wins, consistent with `K8sAPI`/`OpenAPIRef` and
|
|
137
|
+
// this component's own JSDoc. Files are sorted (see
|
|
138
|
+
// `generateRuntimeModule`), so "first" is deterministic.
|
|
139
|
+
if (pathMap.has(path)) {
|
|
140
|
+
continue;
|
|
141
|
+
}
|
|
125
142
|
const pathItem = openapi.paths?.[path];
|
|
126
143
|
if (pathItem) {
|
|
127
144
|
pathMap.set(path, {
|
|
@@ -1,18 +1,36 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import BananaSlug from '@rspress/shared/github-slugger';
|
|
3
|
-
import {
|
|
3
|
+
import { isValidElement, useMemo } from 'react';
|
|
4
4
|
import { X } from './_X.js';
|
|
5
|
+
/**
|
|
6
|
+
* Flatten a React node tree to its visible text. Unlike a plain
|
|
7
|
+
* `Children.toArray().filter(string)`, this descends into element children, so
|
|
8
|
+
* a heading like `<code>{method}</code> {summary}` still yields `method` even
|
|
9
|
+
* when `summary` is `undefined` — instead of an empty slug that becomes
|
|
10
|
+
* `id="undefined"` / `href="#undefined"`.
|
|
11
|
+
*/
|
|
12
|
+
const extractText = (node) => {
|
|
13
|
+
if (node == null || typeof node === 'boolean') {
|
|
14
|
+
return '';
|
|
15
|
+
}
|
|
16
|
+
if (typeof node === 'string' || typeof node === 'number') {
|
|
17
|
+
return String(node);
|
|
18
|
+
}
|
|
19
|
+
if (Array.isArray(node)) {
|
|
20
|
+
return node.map(extractText).join('');
|
|
21
|
+
}
|
|
22
|
+
if (isValidElement(node)) {
|
|
23
|
+
return extractText(node.props.children);
|
|
24
|
+
}
|
|
25
|
+
return '';
|
|
26
|
+
};
|
|
5
27
|
// TODO: use context to simplify the usage of `slugger`
|
|
6
28
|
export const HeadingTitle = ({ slug, slugger, level, children, }) => {
|
|
7
29
|
const HeadingComponents = useMemo(() => {
|
|
8
30
|
return [null, X.h1, X.h2, X.h3, X.h4, X.h5, X.h6];
|
|
9
31
|
}, []);
|
|
10
32
|
const HeadingComponent = HeadingComponents[level];
|
|
11
|
-
const slugFromChildren = useMemo(() =>
|
|
12
|
-
// eslint-disable-next-line @eslint-react/no-children-to-array
|
|
13
|
-
Children.toArray(children)
|
|
14
|
-
.filter((it) => typeof it === 'string' && !!it.trim())
|
|
15
|
-
.join(''), [children]);
|
|
33
|
+
const slugFromChildren = useMemo(() => extractText(children).trim(), [children]);
|
|
16
34
|
const id = useMemo(() => [slug || slugger?.slug(slugFromChildren)].filter(Boolean).join('-') ||
|
|
17
35
|
undefined, [slug, slugger, slugFromChildren]);
|
|
18
36
|
return (_jsxs(HeadingComponent, { id: id, children: [_jsx(X.a, { className: "rp-header-anchor", href: `#${id}`, "aria-hidden": true, children: "#" }), children] }));
|
|
@@ -6,6 +6,13 @@ export interface K8sAPIDefinition {
|
|
|
6
6
|
export interface K8sAPIEndpointsProps extends K8sAPIDefinition {
|
|
7
7
|
namespaced?: boolean;
|
|
8
8
|
hasStatus?: boolean;
|
|
9
|
+
hasScale?: boolean;
|
|
10
|
+
/**
|
|
11
|
+
* The resource's plural name. When provided (e.g. read from a CRD's
|
|
12
|
+
* `spec.names.plural`) it is used verbatim; otherwise it is guessed with the
|
|
13
|
+
* `pluralize` package, which is wrong for irregular or hyphenated plurals.
|
|
14
|
+
*/
|
|
15
|
+
plural?: string;
|
|
9
16
|
pathPrefix?: string;
|
|
10
17
|
}
|
|
11
|
-
export declare const K8sAPIEndpoints: ({ hasStatus, group, version, kind, pathPrefix: pathPrefix_, namespaced, }: K8sAPIEndpointsProps) => import("react/jsx-runtime").JSX.Element;
|
|
18
|
+
export declare const K8sAPIEndpoints: ({ hasStatus, hasScale, group, version, kind, plural, pathPrefix: pathPrefix_, namespaced, }: K8sAPIEndpointsProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,20 +1,38 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
2
|
import { FallbackHeading } from '@rspress/core/theme';
|
|
3
3
|
import virtual from 'doom-@api-virtual';
|
|
4
|
-
import { plural } from 'pluralize';
|
|
4
|
+
import { plural as pluralize } from 'pluralize';
|
|
5
|
+
import { useTranslation } from '../hooks/index.js';
|
|
5
6
|
import { APIReferenceLink } from './_APIReferenceLink.js';
|
|
6
7
|
import { X } from './_X.js';
|
|
7
8
|
const QueryParameters = ({ fieldValidation = true, }) => {
|
|
8
|
-
|
|
9
|
+
const t = useTranslation();
|
|
10
|
+
return (_jsxs(_Fragment, { children: [_jsx("dl", { children: _jsx("dt", { children: t('query_parameters') }) }), _jsxs(X.table, { children: [_jsx("thead", { children: _jsxs("tr", { children: [_jsx("th", { children: t('parameter') }), _jsx("th", { children: t('type') }), _jsx("th", { children: t('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." })] }))] })] })] }));
|
|
9
11
|
};
|
|
10
12
|
const BodyParameters = ({ kind }) => {
|
|
11
|
-
|
|
13
|
+
const t = useTranslation();
|
|
14
|
+
return (_jsxs(_Fragment, { children: [_jsx("dl", { children: _jsx("dt", { children: t('body_parameters') }) }), _jsxs(X.table, { children: [_jsx("thead", { children: _jsxs("tr", { children: [_jsx("th", { children: t('parameter') }), _jsx("th", { children: t('type') }), _jsx("th", { children: t('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"] })] }) })] })] }));
|
|
12
15
|
};
|
|
13
|
-
const K8sAPIListEndpoint = ({ kind }) =>
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
|
|
16
|
+
const K8sAPIListEndpoint = ({ kind }) => {
|
|
17
|
+
const t = useTranslation();
|
|
18
|
+
return (_jsxs(_Fragment, { children: [_jsxs("dl", { children: [_jsx("dt", { children: t('http_method') }), _jsx("dd", { children: _jsx("code", { children: "DELETE" }) }), _jsx("dt", { children: t('description') }), _jsxs("dd", { children: ["delete collection of ", kind] }), _jsx("dt", { children: t('http_responses') })] }), _jsxs(X.table, { children: [_jsx("thead", { children: _jsxs("tr", { children: [_jsx("th", { children: t('http_code') }), _jsx("th", { children: t('response_body') })] }) }), _jsxs("tbody", { children: [_jsxs("tr", { children: [_jsx("td", { children: "200 - OK" }), _jsxs("td", { children: [_jsx("code", { children: _jsx(APIReferenceLink, { name: "Status" }) }), ' ', "schema"] })] }), _jsxs("tr", { children: [_jsx("td", { children: "401 - Unauthorized" }), _jsx("td", { children: "Empty" })] })] })] }), _jsxs("dl", { children: [_jsx("dt", { children: t('http_method') }), _jsx("dd", { children: _jsx("code", { children: "GET" }) }), _jsx("dt", { children: t('description') }), _jsxs("dd", { children: ["list objects of kind ", kind] }), _jsx("dt", { children: t('http_responses') })] }), _jsxs(X.table, { children: [_jsx("thead", { children: _jsxs("tr", { children: [_jsx("th", { children: t('http_code') }), _jsx("th", { children: t('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: t('http_method') }), _jsx("dd", { children: _jsx("code", { children: "POST" }) }), _jsx("dt", { children: t('description') }), _jsxs("dd", { children: ["create a new ", kind] })] }), _jsx(QueryParameters, {}), _jsx(BodyParameters, { kind: kind }), _jsx("dl", { children: _jsx("dt", { children: t('http_responses') }) }), _jsxs(X.table, { children: [_jsx("thead", { children: _jsxs("tr", { children: [_jsx("th", { children: t('http_code') }), _jsx("th", { children: t('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" })] })] })] })] }));
|
|
19
|
+
};
|
|
20
|
+
const K8sAPIItemEndpoint = ({ kind }) => {
|
|
21
|
+
const t = useTranslation();
|
|
22
|
+
return (_jsxs(_Fragment, { children: [_jsxs("dl", { children: [_jsx("dt", { children: t('http_method') }), _jsx("dd", { children: _jsx("code", { children: "DELETE" }) }), _jsx("dt", { children: t('description') }), _jsxs("dd", { children: ["delete the specified ", kind] })] }), _jsx(QueryParameters, { fieldValidation: false }), _jsx("dl", { children: _jsx("dt", { children: t('http_responses') }) }), _jsxs(X.table, { children: [_jsx("thead", { children: _jsxs("tr", { children: [_jsx("th", { children: t('http_code') }), _jsx("th", { children: t('response_body') })] }) }), _jsxs("tbody", { children: [_jsxs("tr", { children: [_jsx("td", { children: "200 - OK" }), _jsxs("td", { children: [_jsx("code", { children: _jsx(APIReferenceLink, { name: "Status" }) }), ' ', "schema"] })] }), _jsxs("tr", { children: [_jsx("td", { children: "202 - Accepted" }), _jsxs("td", { children: [_jsx("code", { children: _jsx(APIReferenceLink, { name: "Status" }) }), ' ', "schema"] })] }), _jsxs("tr", { children: [_jsx("td", { children: "401 - Unauthorized" }), _jsx("td", { children: "Empty" })] })] })] }), _jsxs("dl", { children: [_jsx("dt", { children: t('http_method') }), _jsx("dd", { children: _jsx("code", { children: "GET" }) }), _jsx("dt", { children: t('description') }), _jsxs("dd", { children: ["read the specified ", kind] }), _jsx("dt", { children: t('http_responses') })] }), _jsxs(X.table, { children: [_jsx("thead", { children: _jsxs("tr", { children: [_jsx("th", { children: t('http_code') }), _jsx("th", { children: t('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: t('http_method') }), _jsx("dd", { children: _jsx("code", { children: "PATCH" }) }), _jsx("dt", { children: t('description') }), _jsxs("dd", { children: ["partially update the specified ", kind] })] }), _jsx(QueryParameters, {}), _jsx("dl", { children: _jsx("dt", { children: t('http_responses') }) }), _jsxs(X.table, { children: [_jsx("thead", { children: _jsxs("tr", { children: [_jsx("th", { children: t('http_code') }), _jsx("th", { children: t('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: t('http_method') }), _jsx("dd", { children: _jsx("code", { children: "PUT" }) }), _jsx("dt", { children: t('description') }), _jsxs("dd", { children: ["replace the specified ", kind] })] }), _jsx(QueryParameters, {}), _jsx(BodyParameters, { kind: kind }), _jsx("dl", { children: _jsx("dt", { children: t('http_responses') }) }), _jsxs(X.table, { children: [_jsx("thead", { children: _jsxs("tr", { children: [_jsx("th", { children: t('http_code') }), _jsx("th", { children: t('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" })] })] })] })] }));
|
|
23
|
+
};
|
|
24
|
+
const K8sAPIStatusEndpoint = ({ kind }) => {
|
|
25
|
+
const t = useTranslation();
|
|
26
|
+
return (_jsxs(_Fragment, { children: [_jsxs("dl", { children: [_jsx("dt", { children: t('http_method') }), _jsx("dd", { children: _jsx("code", { children: "GET" }) }), _jsx("dt", { children: t('description') }), _jsxs("dd", { children: ["read status of the specified ", kind] }), _jsx("dt", { children: t('http_responses') })] }), _jsxs(X.table, { children: [_jsx("thead", { children: _jsxs("tr", { children: [_jsx("th", { children: t('http_code') }), _jsx("th", { children: t('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: t('http_method') }), _jsx("dd", { children: _jsx("code", { children: "PATCH" }) }), _jsx("dt", { children: t('description') }), _jsxs("dd", { children: ["partially update status of the specified ", kind] })] }), _jsx(QueryParameters, {}), _jsx("dl", { children: _jsx("dt", { children: t('http_responses') }) }), _jsxs(X.table, { children: [_jsx("thead", { children: _jsxs("tr", { children: [_jsx("th", { children: t('http_code') }), _jsx("th", { children: t('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: t('http_method') }), _jsx("dd", { children: _jsx("code", { children: "PUT" }) }), _jsx("dt", { children: t('description') }), _jsxs("dd", { children: ["replace status of the specified ", kind] })] }), _jsx(QueryParameters, {}), _jsx(BodyParameters, { kind: kind }), _jsx("dl", { children: _jsx("dt", { children: t('http_responses') }) }), _jsxs(X.table, { children: [_jsx("thead", { children: _jsxs("tr", { children: [_jsx("th", { children: t('http_code') }), _jsx("th", { children: t('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" })] })] })] })] }));
|
|
27
|
+
};
|
|
28
|
+
const K8sAPIScaleEndpoint = ({ kind }) => {
|
|
29
|
+
const t = useTranslation();
|
|
30
|
+
return (_jsxs(_Fragment, { children: [_jsxs("dl", { children: [_jsx("dt", { children: t('http_method') }), _jsx("dd", { children: _jsx("code", { children: "GET" }) }), _jsx("dt", { children: t('description') }), _jsxs("dd", { children: ["read scale of the specified ", kind] }), _jsx("dt", { children: t('http_responses') })] }), _jsxs(X.table, { children: [_jsx("thead", { children: _jsxs("tr", { children: [_jsx("th", { children: t('http_code') }), _jsx("th", { children: t('response_body') })] }) }), _jsxs("tbody", { children: [_jsxs("tr", { children: [_jsx("td", { children: "200 - OK" }), _jsxs("td", { children: [_jsx("code", { children: _jsx(APIReferenceLink, { name: "Scale" }) }), ' ', "schema"] })] }), _jsxs("tr", { children: [_jsx("td", { children: "401 - Unauthorized" }), _jsx("td", { children: "Empty" })] })] })] }), _jsxs("dl", { children: [_jsx("dt", { children: t('http_method') }), _jsx("dd", { children: _jsx("code", { children: "PATCH" }) }), _jsx("dt", { children: t('description') }), _jsxs("dd", { children: ["partially update scale of the specified ", kind] })] }), _jsx(QueryParameters, {}), _jsxs("dl", { children: [_jsx("dt", { children: t('http_method') }), _jsx("dd", { children: _jsx("code", { children: "PUT" }) }), _jsx("dt", { children: t('description') }), _jsxs("dd", { children: ["replace scale of the specified ", kind] })] }), _jsx(QueryParameters, {}), _jsx(BodyParameters, { kind: "Scale" })] }));
|
|
31
|
+
};
|
|
32
|
+
export const K8sAPIEndpoints = ({ hasStatus, hasScale, group, version, kind, plural, pathPrefix: pathPrefix_, namespaced = true, }) => {
|
|
33
|
+
const t = useTranslation();
|
|
17
34
|
const pathPrefix = pathPrefix_ ?? (virtual.pathPrefix || '');
|
|
18
|
-
const
|
|
19
|
-
|
|
35
|
+
const pluralName = plural ?? pluralize(kind).toLowerCase();
|
|
36
|
+
const apiPath = `${pathPrefix}/${group ? `apis/${group}` : 'api'}/${version}/${namespaced ? `namespaces/{namespace}/` : ''}${pluralName}`;
|
|
37
|
+
return (_jsxs(_Fragment, { children: [_jsx(FallbackHeading, { level: 2, title: t('api_endpoints') }), _jsx(X.p, { children: t('available_api_endpoints') }), _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] })] })] })), hasScale && (_jsxs(X.li, { children: [_jsx("code", { children: `${apiPath}/{name}/scale` }), _jsxs(X.ul, { children: [_jsxs(X.li, { children: [_jsx("code", { children: "GET" }), ": read scale of the specified ", kind] }), _jsxs(X.li, { children: [_jsx("code", { children: "PATCH" }), ": partially update scale of the specified", ' ', kind] }), _jsxs(X.li, { children: [_jsx("code", { children: "PUT" }), ": replace scale 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 })] })), hasScale && (_jsxs(_Fragment, { children: [_jsx("div", { className: "rp-toc-exclude", children: _jsx(FallbackHeading, { level: 3, title: `${apiPath}/{name}/scale` }) }), _jsx(K8sAPIScaleEndpoint, { kind: kind })] }))] }));
|
|
20
38
|
};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import BananaSlug from '@rspress/shared/github-slugger';
|
|
1
2
|
import type { OpenAPIV3_1 } from 'openapi-types';
|
|
2
3
|
export interface K8sAPISchemaProps {
|
|
3
4
|
schema: OpenAPIV3_1.SchemaObject;
|
|
@@ -7,9 +8,16 @@ export interface K8sAPISchemaItemProps {
|
|
|
7
8
|
schema: OpenAPIV3_1.SchemaObject;
|
|
8
9
|
fullSchema?: OpenAPIV3_1.Document;
|
|
9
10
|
propertyPath?: string;
|
|
11
|
+
/**
|
|
12
|
+
* A single stateful slugger shared across the whole schema tree of a page.
|
|
13
|
+
* github-slugger's stateless `slug()` strips `.`/`[`/`]`, so
|
|
14
|
+
* `.spec.foo` and `.spec.foo[]` collide into one id; a shared instance
|
|
15
|
+
* de-duplicates them (WCAG 4.1.1 / HTML id uniqueness).
|
|
16
|
+
*/
|
|
17
|
+
slugger?: BananaSlug;
|
|
10
18
|
}
|
|
11
19
|
export declare const K8sAPISchemaItemBasic: ({ schema, }: {
|
|
12
20
|
schema: OpenAPIV3_1.SchemaObject;
|
|
13
21
|
}) => import("react/jsx-runtime").JSX.Element;
|
|
14
|
-
export declare const K8sAPISchemaItem: ({ schema, fullSchema, propertyPath, }: K8sAPISchemaItemProps) => import("react/jsx-runtime").JSX.Element;
|
|
22
|
+
export declare const K8sAPISchemaItem: ({ schema, fullSchema, propertyPath, slugger, }: K8sAPISchemaItemProps) => import("react/jsx-runtime").JSX.Element;
|
|
15
23
|
export declare const K8sAPISchema: ({ schema, fullSchema }: K8sAPISchemaProps) => import("react/jsx-runtime").JSX.Element;
|