@alauda/doom 0.23.7 → 0.23.9
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/plugins/replace/resolve-release.js +1 -1
- package/lib/runtime/components/OpenAPIPath.js +5 -4
- package/lib/runtime/components/OpenAPIRef.d.ts +2 -1
- package/lib/runtime/components/OpenAPIRef.js +7 -3
- package/lib/runtime/components/_HeadingTitle.d.ts +2 -1
- package/lib/runtime/components/_HeadingTitle.js +11 -5
- package/package.json +1 -1
|
@@ -85,7 +85,7 @@ const resolveRelease_ = async (releaseTemplates, releaseQuery) => {
|
|
|
85
85
|
catch (err) {
|
|
86
86
|
if (err instanceof ResponseError) {
|
|
87
87
|
const error = err;
|
|
88
|
-
logger.error(`Failed to fetch release notes for query \`${red(releaseQuery)}\` with status \`${error.response.status}\` and ${error.data ? `data ${JSON.stringify(data, null, 2)}` : `message \`${error.message}\``}`);
|
|
88
|
+
logger.error(`Failed to fetch release notes for query \`${red(releaseQuery)}\` with status \`${error.response.status}\` and ${error.data ? `data ${JSON.stringify(error.data, null, 2)}` : `message \`${error.message}\``}`);
|
|
89
89
|
}
|
|
90
90
|
return;
|
|
91
91
|
}
|
|
@@ -5,7 +5,7 @@ import openapisMap from 'doom-@api-openapisMap';
|
|
|
5
5
|
import virtual from 'doom-@api-virtual';
|
|
6
6
|
import BananaSlug from 'github-slugger';
|
|
7
7
|
import { OpenAPIV3 } from 'openapi-types';
|
|
8
|
-
import { Fragment, useMemo, useState } from 'react';
|
|
8
|
+
import { Fragment, useId, useMemo, useState } from 'react';
|
|
9
9
|
import { omitRoutePathRefs, resolveRef } from '../utils.js';
|
|
10
10
|
import { OpenAPIProperties, OpenAPIProperty, OpenAPIRef } from './OpenAPIRef.js';
|
|
11
11
|
import { HeadingTitle } from './_HeadingTitle.js';
|
|
@@ -93,6 +93,7 @@ export const OpenAPIPath = ({ path, openapiPath: openapiPath_, pathPrefix: pathP
|
|
|
93
93
|
const [X] = useState(getCustomMDXComponent);
|
|
94
94
|
const { page } = usePageData();
|
|
95
95
|
const pathPrefix = pathPrefix_ ?? (virtual.pathPrefix || '');
|
|
96
|
+
const uid = useId();
|
|
96
97
|
const slugger = useMemo(() => new BananaSlug(), []);
|
|
97
98
|
const [pathItem, openapi, openapiPath, refs] = useMemo(() => {
|
|
98
99
|
for (const [pathname, openapi] of Object.entries(openapisMap)) {
|
|
@@ -115,7 +116,7 @@ export const OpenAPIPath = ({ path, openapiPath: openapiPath_, pathPrefix: pathP
|
|
|
115
116
|
console.error(`No OpenAPI path definition found for ${path}`);
|
|
116
117
|
return null;
|
|
117
118
|
}
|
|
118
|
-
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: "Common Parameters" }), _jsx(OpenAPIParameters, { parameters: pathItem.parameters, openapi: openapi })] })), Object.values(OpenAPIV3.HttpMethods).map((method) => {
|
|
119
|
+
return (_jsxs(_Fragment, { children: [_jsxs(HeadingTitle, { slugger: slugger, uid: uid, level: 2, children: [pathPrefix, path] }), pathItem.parameters && (_jsxs(_Fragment, { children: [_jsx(HeadingTitle, { slugger: slugger, uid: uid, level: 3, children: "Common Parameters" }), _jsx(OpenAPIParameters, { parameters: pathItem.parameters, openapi: openapi })] })), Object.values(OpenAPIV3.HttpMethods).map((method) => {
|
|
119
120
|
if (!pathItem[method]) {
|
|
120
121
|
return null;
|
|
121
122
|
}
|
|
@@ -127,9 +128,9 @@ export const OpenAPIPath = ({ path, openapiPath: openapiPath_, pathPrefix: pathP
|
|
|
127
128
|
const requestBodySchema = requestBodyRef
|
|
128
129
|
? resolveRef(openapi, requestBodyRef)
|
|
129
130
|
: undefined;
|
|
130
|
-
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: "Parameters" }), _jsx(OpenAPIParameters, { parameters: parameters, openapi: openapi })] })), requestBodySchema && (_jsxs(_Fragment, { children: [_jsx(HeadingTitle, { slugger: slugger, level: 4, children: "Request Body" }), _jsxs(X.p, { children: [_jsx(RefLink, { "$ref": requestBodyRef }), requestBodySchema.required && _jsx(Badge, { children: "required" })] })] })), responses && (_jsxs(_Fragment, { children: [_jsx(HeadingTitle, { slugger: slugger, level: 4, children: "Response" }), _jsx(OpenAPIResponses, { responses: responses, openapi: openapi })] }))] }, method));
|
|
131
|
+
return (_jsxs(Fragment, { children: [_jsxs(HeadingTitle, { slugger: slugger, uid: uid, level: 3, children: [_jsx("code", { children: method }), summary] }), _jsx(Markdown, { children: description }), parameters && (_jsxs(_Fragment, { children: [_jsx(HeadingTitle, { slugger: slugger, uid: uid, level: 4, children: "Parameters" }), _jsx(OpenAPIParameters, { parameters: parameters, openapi: openapi })] })), requestBodySchema && (_jsxs(_Fragment, { children: [_jsx(HeadingTitle, { slugger: slugger, uid: uid, level: 4, children: "Request Body" }), _jsxs(X.p, { children: [_jsx(RefLink, { "$ref": requestBodyRef }), requestBodySchema.required && _jsx(Badge, { children: "required" })] })] })), responses && (_jsxs(_Fragment, { children: [_jsx(HeadingTitle, { slugger: slugger, uid: uid, level: 4, children: "Response" }), _jsx(OpenAPIResponses, { responses: responses, openapi: openapi })] }))] }, method));
|
|
131
132
|
}), refs?.map((ref) => {
|
|
132
|
-
return (_jsx(OpenAPIRef, { schema: ref, openapiPath: openapiPath, collectRefs: false }, ref));
|
|
133
|
+
return (_jsx(OpenAPIRef, { schema: ref, openapiPath: openapiPath, uid: uid, collectRefs: false }, ref));
|
|
133
134
|
})] }));
|
|
134
135
|
};
|
|
135
136
|
export default OpenAPIPath;
|
|
@@ -8,6 +8,7 @@ export interface OpenAPIRefProps {
|
|
|
8
8
|
* The specific path to the OpenAPI schema, otherwise the first matched will be used.
|
|
9
9
|
*/
|
|
10
10
|
openapiPath?: string;
|
|
11
|
+
uid?: string;
|
|
11
12
|
collectRefs?: boolean;
|
|
12
13
|
}
|
|
13
14
|
export declare const OpenAPIProperty: ({ name, property, openapi, }: {
|
|
@@ -19,5 +20,5 @@ export declare const OpenAPIProperties: ({ properties, openapi, }: {
|
|
|
19
20
|
properties: Record<string, OpenAPIV3_1.ReferenceObject | OpenAPIV3_1.SchemaObject>;
|
|
20
21
|
openapi: OpenAPIV3_1.Document;
|
|
21
22
|
}) => import("react/jsx-runtime").JSX.Element;
|
|
22
|
-
export declare const OpenAPIRef: ({ schema, openapiPath: openapiPath_, collectRefs, }: OpenAPIRefProps) => import("react/jsx-runtime").JSX.Element | null;
|
|
23
|
+
export declare const OpenAPIRef: ({ schema, openapiPath: openapiPath_, uid, collectRefs, }: OpenAPIRefProps) => import("react/jsx-runtime").JSX.Element | null;
|
|
23
24
|
export default OpenAPIRef;
|
|
@@ -2,7 +2,7 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
|
|
|
2
2
|
import { usePageData } from '@rspress/core/runtime';
|
|
3
3
|
import { getCustomMDXComponent } from '@rspress/core/theme';
|
|
4
4
|
import openapisMap from 'doom-@api-openapisMap';
|
|
5
|
-
import { useMemo, useState } from 'react';
|
|
5
|
+
import { useId, useMemo, useState } from 'react';
|
|
6
6
|
import { modelName, omitRoutePathRefs, resolveRef } from '../utils.js';
|
|
7
7
|
import { HeadingTitle } from './_HeadingTitle.js';
|
|
8
8
|
import { Markdown } from './_Markdown.js';
|
|
@@ -69,8 +69,12 @@ const getRefsForSchema = (openapi, schema, knownRefs) => {
|
|
|
69
69
|
collectRefs(refSchema);
|
|
70
70
|
return Array.from(refs);
|
|
71
71
|
};
|
|
72
|
-
export const OpenAPIRef = ({ schema, openapiPath: openapiPath_, collectRefs = true, }) => {
|
|
72
|
+
export const OpenAPIRef = ({ schema, openapiPath: openapiPath_, uid, collectRefs = true, }) => {
|
|
73
73
|
const { page } = usePageData();
|
|
74
|
+
const innerUid = useId();
|
|
75
|
+
if (uid == null) {
|
|
76
|
+
uid = innerUid;
|
|
77
|
+
}
|
|
74
78
|
const [schemaItem, openapi, openapiPath] = useMemo(() => {
|
|
75
79
|
for (const [pathname, openapi] of Object.entries(openapisMap)) {
|
|
76
80
|
if (openapiPath_ && pathname !== openapiPath_) {
|
|
@@ -92,6 +96,6 @@ export const OpenAPIRef = ({ schema, openapiPath: openapiPath_, collectRefs = tr
|
|
|
92
96
|
return getRefsForSchema(openapi, schema, omitRoutePathRefs(page.routePath));
|
|
93
97
|
}
|
|
94
98
|
}, [collectRefs, openapi, page.routePath, schema]);
|
|
95
|
-
return (_jsxs(_Fragment, { children: [_jsx(HeadingTitle, { slug: schema, level: 2, children: modelName(schema) }), _jsx(Markdown, { children: schemaItem.description }), schemaItem.properties && (_jsx(OpenAPIProperties, { properties: schemaItem.properties, openapi: openapi })), refs?.map((schema) => (_jsx(OpenAPIRef, { schema: schema, openapiPath: openapiPath, collectRefs: false }, schema)))] }));
|
|
99
|
+
return (_jsxs(_Fragment, { children: [_jsx(HeadingTitle, { uid: uid, slug: schema, level: 2, children: modelName(schema) }), _jsx(Markdown, { children: schemaItem.description }), schemaItem.properties && (_jsx(OpenAPIProperties, { properties: schemaItem.properties, openapi: openapi })), refs?.map((schema) => (_jsx(OpenAPIRef, { schema: schema, openapiPath: openapiPath, uid: uid, collectRefs: false }, schema)))] }));
|
|
96
100
|
};
|
|
97
101
|
export default OpenAPIRef;
|
|
@@ -3,7 +3,8 @@ import { type ReactNode } from 'react';
|
|
|
3
3
|
export interface HeadingTitleProps {
|
|
4
4
|
slug?: string;
|
|
5
5
|
slugger?: BananaSlug;
|
|
6
|
+
uid?: string;
|
|
6
7
|
level: 1 | 2 | 3 | 4 | 5 | 6;
|
|
7
8
|
children: ReactNode;
|
|
8
9
|
}
|
|
9
|
-
export declare const HeadingTitle: ({ slug, slugger, level, children, }: HeadingTitleProps) => import("react/jsx-runtime").JSX.Element;
|
|
10
|
+
export declare const HeadingTitle: ({ slug, slugger, uid, level, children, }: HeadingTitleProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -2,15 +2,21 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
2
2
|
import { getCustomMDXComponent } from '@rspress/core/theme';
|
|
3
3
|
import BananaSlug from 'github-slugger';
|
|
4
4
|
import { Children, useMemo, useState } from 'react';
|
|
5
|
-
|
|
5
|
+
// TODO: use context to simplify the usage of `slugger` and `uid`
|
|
6
|
+
export const HeadingTitle = ({ slug, slugger, uid, level, children, }) => {
|
|
6
7
|
const [X] = useState(getCustomMDXComponent);
|
|
7
8
|
const HeadingComponents = useMemo(() => {
|
|
8
9
|
return [null, X.h1, X.h2, X.h3, X.h4, X.h5, X.h6];
|
|
9
10
|
}, [X]);
|
|
10
11
|
const HeadingComponent = HeadingComponents[level];
|
|
11
|
-
const id = useMemo(() =>
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
.
|
|
12
|
+
const id = useMemo(() => [
|
|
13
|
+
uid,
|
|
14
|
+
slug ||
|
|
15
|
+
slugger?.slug(Children.toArray(children)
|
|
16
|
+
.filter((it) => typeof it === 'string')
|
|
17
|
+
.join('')),
|
|
18
|
+
]
|
|
19
|
+
.filter(Boolean)
|
|
20
|
+
.join('-') || undefined, [slug, uid, children]);
|
|
15
21
|
return (_jsxs(HeadingComponent, { id: id, children: [children, _jsx(X.a, { className: "header-anchor", href: `#${id}`, "aria-hidden": true, children: "#" })] }));
|
|
16
22
|
};
|