zudoku 0.3.0-dev.92 → 0.3.0-dev.94
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/dist/lib/components/navigation/SidebarBadge.d.ts +2 -1
- package/dist/lib/components/navigation/SidebarBadge.js +2 -2
- package/dist/lib/components/navigation/SidebarBadge.js.map +1 -1
- package/dist/lib/components/navigation/SidebarItem.js +4 -4
- package/dist/lib/components/navigation/SidebarItem.js.map +1 -1
- package/dist/lib/oas/graphql/index.js +11 -5
- package/dist/lib/oas/graphql/index.js.map +1 -1
- package/dist/lib/plugins/openapi/index.js +10 -1
- package/dist/lib/plugins/openapi/index.js.map +1 -1
- package/dist/vite/config.test.js +1 -1
- package/dist/vite/config.test.js.map +1 -1
- package/lib/{OperationList-DvKqvB16.js → OperationList-BAZX1Gla.js} +3 -3
- package/lib/{OperationList-DvKqvB16.js.map → OperationList-BAZX1Gla.js.map} +1 -1
- package/lib/{Route-CnmaDun4.js → Route-Cq7WBHPC.js} +2 -2
- package/lib/{Route-CnmaDun4.js.map → Route-Cq7WBHPC.js.map} +1 -1
- package/lib/{Spinner-D99Tq0hv.js → Spinner-BCz1kNGw.js} +39 -37
- package/lib/{Spinner-D99Tq0hv.js.map → Spinner-BCz1kNGw.js.map} +1 -1
- package/lib/assets/{worker-CyHZIIfE.js → worker-CR7aeKop.js} +12 -12
- package/lib/assets/{worker-CyHZIIfE.js.map → worker-CR7aeKop.js.map} +1 -1
- package/lib/{index-7nswqEVR.js → index-D-9Z7HSn.js} +2 -2
- package/lib/{index-7nswqEVR.js.map → index-D-9Z7HSn.js.map} +1 -1
- package/lib/{index-DjaqWcmv.js → index-DGb_offs.js} +22 -14
- package/lib/{index-DjaqWcmv.js.map → index-DGb_offs.js.map} +1 -1
- package/lib/zudoku.components.js +303 -293
- package/lib/zudoku.components.js.map +1 -1
- package/lib/zudoku.openapi-worker.js +12 -12
- package/lib/zudoku.openapi-worker.js.map +1 -1
- package/lib/zudoku.plugin-openapi.js +1 -1
- package/package.json +1 -1
- package/src/lib/components/navigation/SidebarBadge.tsx +3 -0
- package/src/lib/components/navigation/SidebarItem.tsx +38 -10
- package/src/lib/oas/graphql/index.ts +13 -7
- package/src/lib/plugins/openapi/index.tsx +12 -1
package/package.json
CHANGED
|
@@ -23,15 +23,18 @@ export const ColorMap = {
|
|
|
23
23
|
export const SidebarBadge = ({
|
|
24
24
|
color,
|
|
25
25
|
label,
|
|
26
|
+
className,
|
|
26
27
|
}: {
|
|
27
28
|
color: keyof typeof ColorMap;
|
|
28
29
|
label: string;
|
|
30
|
+
className?: string;
|
|
29
31
|
}) => {
|
|
30
32
|
return (
|
|
31
33
|
<span
|
|
32
34
|
className={cn(
|
|
33
35
|
"mt-0.5 flex items-center duration-200 transition-opacity text-center uppercase font-mono text-[0.65rem] font-bold rounded text-background dark:text-zinc-50 h-4 px-1",
|
|
34
36
|
ColorMap[color],
|
|
37
|
+
className,
|
|
35
38
|
)}
|
|
36
39
|
>
|
|
37
40
|
{label}
|
|
@@ -54,8 +54,16 @@ export const SidebarItem = ({
|
|
|
54
54
|
}
|
|
55
55
|
to={joinPath(topNavItem?.id, item.id)}
|
|
56
56
|
>
|
|
57
|
-
{item.
|
|
58
|
-
|
|
57
|
+
{item.badge ? (
|
|
58
|
+
<>
|
|
59
|
+
<span className="truncate" title={item.label}>
|
|
60
|
+
{item.label}
|
|
61
|
+
</span>
|
|
62
|
+
<SidebarBadge {...item.badge} />
|
|
63
|
+
</>
|
|
64
|
+
) : (
|
|
65
|
+
item.label
|
|
66
|
+
)}
|
|
59
67
|
</NavLink>
|
|
60
68
|
);
|
|
61
69
|
case "link":
|
|
@@ -71,10 +79,34 @@ export const SidebarItem = ({
|
|
|
71
79
|
}),
|
|
72
80
|
)}
|
|
73
81
|
>
|
|
74
|
-
{item.
|
|
75
|
-
|
|
82
|
+
{item.badge ? (
|
|
83
|
+
<>
|
|
84
|
+
<span className="truncate" title={item.label}>
|
|
85
|
+
{item.label}
|
|
86
|
+
</span>
|
|
87
|
+
<SidebarBadge {...item.badge} />
|
|
88
|
+
</>
|
|
89
|
+
) : (
|
|
90
|
+
<span className="break-all">{item.label}</span>
|
|
91
|
+
)}
|
|
76
92
|
</AnchorLink>
|
|
77
|
-
) : item.href.startsWith("http") ? (
|
|
93
|
+
) : !item.href.startsWith("http") ? (
|
|
94
|
+
<NavLink
|
|
95
|
+
className={cn("flex gap-2.5 justify-between", navigationListItem())}
|
|
96
|
+
to={item.href}
|
|
97
|
+
>
|
|
98
|
+
{item.badge ? (
|
|
99
|
+
<>
|
|
100
|
+
<span className="truncate" title={item.label}>
|
|
101
|
+
{item.label}
|
|
102
|
+
</span>
|
|
103
|
+
<SidebarBadge {...item.badge} />
|
|
104
|
+
</>
|
|
105
|
+
) : (
|
|
106
|
+
<span className="break-all">{item.label}</span>
|
|
107
|
+
)}
|
|
108
|
+
</NavLink>
|
|
109
|
+
) : (
|
|
78
110
|
<a
|
|
79
111
|
className={cn(
|
|
80
112
|
navigationListItem({ isTopLevel: level === 0 }),
|
|
@@ -85,16 +117,12 @@ export const SidebarItem = ({
|
|
|
85
117
|
rel="noopener noreferrer"
|
|
86
118
|
>
|
|
87
119
|
<span className="whitespace-normal">{item.label}</span>
|
|
88
|
-
{/* This prevents that the icon would be positioned in its own line if the text fills
|
|
120
|
+
{/* This prevents that the icon would be positioned in its own line if the text fills a line entirely */}
|
|
89
121
|
<span className="whitespace-nowrap">
|
|
90
122
|
|
|
91
123
|
<ExternalLinkIcon className="inline ml-1" size={12} />
|
|
92
124
|
</span>
|
|
93
125
|
</a>
|
|
94
|
-
) : (
|
|
95
|
-
<NavLink className={cn(navigationListItem({}), "block")} to={item.href}>
|
|
96
|
-
{item.label}
|
|
97
|
-
</NavLink>
|
|
98
126
|
);
|
|
99
127
|
}
|
|
100
128
|
};
|
|
@@ -37,7 +37,7 @@ type OperationLike = {
|
|
|
37
37
|
};
|
|
38
38
|
export const slugifyOperation = (operation: OperationLike, tag?: string) => {
|
|
39
39
|
const summary =
|
|
40
|
-
operation.summary +
|
|
40
|
+
(operation.summary ?? "") +
|
|
41
41
|
(operation.operationId
|
|
42
42
|
? "-" +
|
|
43
43
|
operation.operationId.slice(0, operation.summary ? Infinity : Infinity)
|
|
@@ -95,6 +95,7 @@ const getAllOperations = (paths?: PathsObject, tag?: string) => {
|
|
|
95
95
|
method,
|
|
96
96
|
path,
|
|
97
97
|
parameters,
|
|
98
|
+
tags: operation.tags ?? [],
|
|
98
99
|
slug: slugifyOperation(
|
|
99
100
|
{
|
|
100
101
|
summary: operation.summary,
|
|
@@ -115,12 +116,17 @@ const SchemaTag = builder.objectRef<TagObject>("SchemaTag").implement({
|
|
|
115
116
|
description: t.exposeString("description", { nullable: true }),
|
|
116
117
|
operations: t.field({
|
|
117
118
|
type: [OperationItem],
|
|
118
|
-
resolve: (parent, _args, ctx) =>
|
|
119
|
-
|
|
119
|
+
resolve: (parent, _args, ctx) => {
|
|
120
|
+
const rootTags = ctx.schema.tags?.map((tag) => tag.name) ?? [];
|
|
121
|
+
|
|
122
|
+
return getAllOperations(ctx.schema.paths, parent.name).filter((item) =>
|
|
120
123
|
parent.name
|
|
121
|
-
? item.tags
|
|
122
|
-
:
|
|
123
|
-
|
|
124
|
+
? item.tags.includes(parent.name)
|
|
125
|
+
: item.tags.length === 0 ||
|
|
126
|
+
// If none of the tags are present in the root tags, then show them here
|
|
127
|
+
item.tags.every((tag) => !rootTags.includes(tag)),
|
|
128
|
+
);
|
|
129
|
+
},
|
|
124
130
|
}),
|
|
125
131
|
}),
|
|
126
132
|
});
|
|
@@ -376,7 +382,7 @@ const Schema = builder.objectRef<OpenAPIDocument>("Schema").implement({
|
|
|
376
382
|
(!args.operationId || item.operationId === args.operationId) &&
|
|
377
383
|
(!args.path || item.path === args.path) &&
|
|
378
384
|
(!args.method || item.method === args.method) &&
|
|
379
|
-
(!args.tag || item.tags
|
|
385
|
+
(!args.tag || item.tags.includes(args.tag)),
|
|
380
386
|
),
|
|
381
387
|
}),
|
|
382
388
|
}),
|
|
@@ -13,6 +13,7 @@ import { createClient } from "zudoku/openapi-worker";
|
|
|
13
13
|
import type { SidebarItem } from "../../../config/validators/SidebarSchema.js";
|
|
14
14
|
import { useAuth } from "../../authentication/hook.js";
|
|
15
15
|
import { ErrorPage } from "../../components/ErrorPage.js";
|
|
16
|
+
import { ColorMap } from "../../components/navigation/SidebarBadge.js";
|
|
16
17
|
import { SyntaxHighlight } from "../../components/SyntaxHighlight.js";
|
|
17
18
|
import { Button } from "../../ui/Button.js";
|
|
18
19
|
import { joinPath } from "../../util/joinPath.js";
|
|
@@ -57,6 +58,16 @@ const OpenApiErrorPage = () => {
|
|
|
57
58
|
|
|
58
59
|
type InternalOasPluginConfig = { inMemory?: boolean };
|
|
59
60
|
|
|
61
|
+
const MethodColorMap: Record<string, keyof typeof ColorMap> = {
|
|
62
|
+
get: "green",
|
|
63
|
+
post: "blue",
|
|
64
|
+
put: "yellow",
|
|
65
|
+
delete: "red",
|
|
66
|
+
patch: "purple",
|
|
67
|
+
options: "gray",
|
|
68
|
+
head: "gray",
|
|
69
|
+
};
|
|
70
|
+
|
|
60
71
|
export const openApiPlugin = (
|
|
61
72
|
config: OasPluginConfig & InternalOasPluginConfig,
|
|
62
73
|
): DevPortalPlugin => {
|
|
@@ -161,7 +172,7 @@ export const openApiPlugin = (
|
|
|
161
172
|
href: `#${operation.slug}`,
|
|
162
173
|
badge: {
|
|
163
174
|
label: operation.method,
|
|
164
|
-
color:
|
|
175
|
+
color: MethodColorMap[operation.method.toLowerCase()],
|
|
165
176
|
},
|
|
166
177
|
})),
|
|
167
178
|
}));
|