@lukoweb/apitogo 0.1.1 → 0.1.2
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/cli/cli.js +17 -6
- package/dist/declarations/lib/ui/Command.d.ts +1 -1
- package/dist/declarations/lib/util/MdxComponents.d.ts +1 -1
- package/package.json +1 -1
- package/src/app/main.tsx +150 -150
- package/src/config/loader.ts +245 -245
- package/src/index.ts +33 -33
- package/src/lib/authentication/components/CallbackHandler.tsx +45 -45
- package/src/lib/authentication/components/SignIn.tsx +46 -46
- package/src/lib/authentication/components/SignUp.tsx +48 -48
- package/src/lib/authentication/providers/clerk.tsx +224 -224
- package/src/lib/authentication/ui/AuthCard.tsx +7 -7
- package/src/lib/authentication/ui/EmailLinkCallbackUi.tsx +129 -125
- package/src/lib/authentication/ui/EmailLinkSentUi.tsx +105 -101
- package/src/lib/authentication/ui/EmailLinkSignInUi.tsx +100 -96
- package/src/lib/authentication/ui/EmailVerificationUi.tsx +128 -124
- package/src/lib/authentication/ui/ZudokuAuthUi.tsx +620 -616
- package/src/lib/components/AiAssistantMenuItems.tsx +102 -102
- package/src/lib/components/Autocomplete.tsx +123 -123
- package/src/lib/components/DeveloperHint.tsx +39 -35
- package/src/lib/components/Header.tsx +260 -260
- package/src/lib/components/Layout.tsx +53 -53
- package/src/lib/components/Main.tsx +51 -51
- package/src/lib/components/Mermaid.tsx +74 -70
- package/src/lib/components/MobileTopNavigation.tsx +276 -276
- package/src/lib/components/MultiSelect.tsx +86 -82
- package/src/lib/components/TopNavigation.tsx +103 -103
- package/src/lib/components/index.ts +26 -26
- package/src/lib/components/navigation/NavigationCategory.tsx +157 -157
- package/src/lib/components/navigation/NavigationFilterInput.tsx +35 -35
- package/src/lib/components/navigation/NavigationItem.tsx +181 -177
- package/src/lib/core/RouteGuard.tsx +193 -193
- package/src/lib/errors/ErrorMessage.tsx +50 -46
- package/src/lib/plugins/api-catalog/Catalog.tsx +80 -80
- package/src/lib/plugins/api-keys/CreateApiKey.tsx +128 -124
- package/src/lib/plugins/api-keys/CreateApiKeyDialog.tsx +49 -49
- package/src/lib/plugins/api-keys/SettingsApiKeys.tsx +72 -72
- package/src/lib/plugins/api-keys/settings/ApiKeyItem.tsx +342 -342
- package/src/lib/plugins/api-keys/settings/RevealApiKey.tsx +127 -127
- package/src/lib/plugins/markdown/MdxPage.tsx +285 -285
- package/src/lib/plugins/openapi/ApiHeader.tsx +96 -96
- package/src/lib/plugins/openapi/CollapsibleCode.tsx +88 -88
- package/src/lib/plugins/openapi/DownloadSchemaButton.tsx +94 -94
- package/src/lib/plugins/openapi/GeneratedExampleSidecarBox.tsx +52 -52
- package/src/lib/plugins/openapi/OperationListItem.tsx +183 -183
- package/src/lib/plugins/openapi/RequestBodySidecarBox.tsx +63 -63
- package/src/lib/plugins/openapi/ResponsesSidecarBox.tsx +120 -117
- package/src/lib/plugins/openapi/SchemaInfo.tsx +344 -344
- package/src/lib/plugins/openapi/SchemaList.tsx +113 -113
- package/src/lib/plugins/openapi/Sidecar.tsx +312 -309
- package/src/lib/plugins/openapi/SidecarExamples.tsx +177 -174
- package/src/lib/plugins/openapi/components/EnumValues.tsx +58 -58
- package/src/lib/plugins/openapi/components/ResponseContent.tsx +117 -114
- package/src/lib/plugins/openapi/playground/BodyPanel.tsx +274 -271
- package/src/lib/plugins/openapi/playground/CollapsibleHeader.tsx +51 -51
- package/src/lib/plugins/openapi/playground/ExamplesDropdown.tsx +60 -60
- package/src/lib/plugins/openapi/playground/Headers.tsx +188 -181
- package/src/lib/plugins/openapi/playground/IdentityDialog.tsx +75 -75
- package/src/lib/plugins/openapi/playground/IdentitySelector.tsx +38 -38
- package/src/lib/plugins/openapi/playground/ParamsGrid.tsx +45 -45
- package/src/lib/plugins/openapi/playground/Playground.tsx +602 -599
- package/src/lib/plugins/openapi/playground/PlaygroundDialog.tsx +56 -56
- package/src/lib/plugins/openapi/playground/QueryParams.tsx +151 -148
- package/src/lib/plugins/openapi/playground/RequestLoginDialog.tsx +70 -70
- package/src/lib/plugins/openapi/playground/request-panel/MultipartField.tsx +91 -91
- package/src/lib/plugins/openapi/playground/result-panel/AudioPlayer.tsx +50 -50
- package/src/lib/plugins/openapi/playground/result-panel/ResponseTab.tsx +355 -355
- package/src/lib/plugins/openapi/playground/result-panel/ResultPanel.tsx +106 -102
- package/src/lib/plugins/openapi/schema/SchemaPropertyItem.tsx +189 -184
- package/src/lib/plugins/openapi/schema/SchemaView.tsx +299 -299
- package/src/lib/plugins/search-pagefind/IndexingDialog.tsx +162 -162
- package/src/lib/plugins/search-pagefind/PagefindSearch.tsx +202 -202
- package/src/lib/plugins/search-pagefind/ResultList.tsx +122 -118
- package/src/lib/ui/ActionButton.tsx +21 -21
- package/src/lib/ui/Command.tsx +191 -191
- package/src/lib/util/MdxComponents.tsx +150 -150
- package/src/vite/config.ts +234 -231
- package/src/vite/dev-server.ts +291 -291
- package/src/vite/plugin-api-keys.ts +50 -50
- package/src/vite/plugin-api.ts +320 -318
- package/src/vite/plugin-auth.ts +38 -38
- package/src/vite/plugin-component.ts +45 -39
- package/src/vite/plugin-config.ts +75 -75
- package/src/vite/plugin-custom-pages.ts +36 -36
- package/src/vite/plugin-docs.ts +202 -202
- package/src/vite/plugin-markdown-export.ts +214 -214
- package/src/vite/plugin-mdx.ts +149 -149
- package/src/vite/plugin-navigation.ts +106 -106
- package/src/vite/plugin-search.ts +47 -47
- package/src/vite/plugin.ts +42 -42
- package/src/vite/prerender/prerender.ts +233 -233
package/dist/cli/cli.js
CHANGED
|
@@ -3816,7 +3816,7 @@ import {
|
|
|
3816
3816
|
// package.json
|
|
3817
3817
|
var package_default = {
|
|
3818
3818
|
name: "@lukoweb/apitogo",
|
|
3819
|
-
version: "0.1.
|
|
3819
|
+
version: "0.1.2",
|
|
3820
3820
|
type: "module",
|
|
3821
3821
|
sideEffects: [
|
|
3822
3822
|
"**/*.css",
|
|
@@ -6074,7 +6074,9 @@ var viteApiPlugin = async () => {
|
|
|
6074
6074
|
`const configuredApiCatalogPlugins = [];`
|
|
6075
6075
|
];
|
|
6076
6076
|
if (config2.apis) {
|
|
6077
|
-
code.push(
|
|
6077
|
+
code.push(
|
|
6078
|
+
'import { openApiPlugin } from "@lukoweb/apitogo/plugins/openapi";'
|
|
6079
|
+
);
|
|
6078
6080
|
code.push(
|
|
6079
6081
|
`const apis = Array.isArray(config.apis) ? config.apis : [config.apis]`
|
|
6080
6082
|
);
|
|
@@ -6271,8 +6273,14 @@ var viteAliasPlugin = () => {
|
|
|
6271
6273
|
const config2 = getCurrentConfig();
|
|
6272
6274
|
const replacements = [
|
|
6273
6275
|
["@lukoweb/apitogo/components", "src/lib/components/index.ts"],
|
|
6274
|
-
[
|
|
6275
|
-
|
|
6276
|
+
[
|
|
6277
|
+
"@lukoweb/apitogo/plugins/openapi",
|
|
6278
|
+
"src/lib/plugins/openapi/index.tsx"
|
|
6279
|
+
],
|
|
6280
|
+
[
|
|
6281
|
+
"@lukoweb/apitogo/plugins/api-catalog",
|
|
6282
|
+
"src/lib/plugins/api-catalog/index.tsx"
|
|
6283
|
+
],
|
|
6276
6284
|
[
|
|
6277
6285
|
"@lukoweb/apitogo/plugins/search-inkeep",
|
|
6278
6286
|
"src/lib/plugins/search-inkeep/index.tsx"
|
|
@@ -7429,7 +7437,10 @@ async function getViteConfig(dir, configEnv) {
|
|
|
7429
7437
|
),
|
|
7430
7438
|
emptyOutDir: true,
|
|
7431
7439
|
rollupOptions: {
|
|
7432
|
-
input: configEnv.command === "build" ? configEnv.isSsrBuild ? [
|
|
7440
|
+
input: configEnv.command === "build" ? configEnv.isSsrBuild ? [
|
|
7441
|
+
"@lukoweb/apitogo/app/entry.server.tsx",
|
|
7442
|
+
config2.__meta.configPath
|
|
7443
|
+
] : "@lukoweb/apitogo/app/entry.client.tsx" : void 0,
|
|
7433
7444
|
external: [joinUrl(config2.basePath, "/pagefind/pagefind.js")]
|
|
7434
7445
|
},
|
|
7435
7446
|
chunkSizeWarningLimit: 1500
|
|
@@ -8612,7 +8623,7 @@ async function dev(argv) {
|
|
|
8612
8623
|
printDiagnosticsToConsole("Ctrl+C to exit");
|
|
8613
8624
|
printDiagnosticsToConsole("");
|
|
8614
8625
|
printDiagnosticsToConsole(
|
|
8615
|
-
`\u{1F680} Running
|
|
8626
|
+
`\u{1F680} Running APIToGo v${packageJson2.version}: ${url}`
|
|
8616
8627
|
);
|
|
8617
8628
|
printDiagnosticsToConsole("");
|
|
8618
8629
|
let hasExited = false;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
+
import { DialogContent } from "@lukoweb/apitogo/ui/Dialog.js";
|
|
1
2
|
import type { DialogProps } from "@radix-ui/react-dialog";
|
|
2
3
|
import { Command as CommandPrimitive } from "cmdk";
|
|
3
4
|
import type { ComponentPropsWithoutRef } from "react";
|
|
4
5
|
import * as React from "react";
|
|
5
|
-
import { DialogContent } from "@lukoweb/apitogo/ui/Dialog.js";
|
|
6
6
|
declare const Command: React.ForwardRefExoticComponent<Omit<{
|
|
7
7
|
children?: React.ReactNode;
|
|
8
8
|
} & Pick<Pick<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "key" | keyof React.HTMLAttributes<HTMLDivElement>> & {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { MDXComponents } from "mdx/types.js";
|
|
2
1
|
import { Alert } from "@lukoweb/apitogo/ui/Alert.js";
|
|
2
|
+
import type { MDXComponents } from "mdx/types.js";
|
|
3
3
|
import { Badge } from "../ui/Badge.js";
|
|
4
4
|
export type MdxComponentsType = Readonly<MDXComponents> | null | undefined;
|
|
5
5
|
export declare const MdxComponents: {
|
package/package.json
CHANGED
package/src/app/main.tsx
CHANGED
|
@@ -1,150 +1,150 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
import {
|
|
20
|
-
import type { ZudokuConfig } from "../config/config.js";
|
|
21
|
-
import { BuildCheck } from "../lib/components/BuildCheck.js";
|
|
22
|
-
import "./main.css";
|
|
23
|
-
import { Meta } from "../lib/components/Meta.js";
|
|
24
|
-
import "./polyfills.js";
|
|
25
|
-
import { StatusPage } from "../lib/components/StatusPage.js";
|
|
26
|
-
import { isNavigationPlugin } from "../lib/core/plugins.js";
|
|
27
|
-
import { RouteGuard } from "../lib/core/RouteGuard.js";
|
|
28
|
-
import type { ZudokuContextOptions } from "../lib/core/ZudokuContext.js";
|
|
29
|
-
import { RouterError } from "../lib/errors/RouterError.js";
|
|
30
|
-
import { ZuploEnv } from "./env.js";
|
|
31
|
-
import { processRoutes } from "./processRoutes.js";
|
|
32
|
-
import { createRedirectRoutes } from "./utils/createRedirectRoutes.js";
|
|
33
|
-
|
|
34
|
-
export const shikiReady: Promise<HighlighterCore> =
|
|
35
|
-
import("../lib/shiki.js").then(async ({ highlighterPromise }) => {
|
|
36
|
-
const highlighter = await highlighterPromise;
|
|
37
|
-
const { registerShiki } = await import("virtual:zudoku-shiki-register");
|
|
38
|
-
await registerShiki(highlighter);
|
|
39
|
-
return highlighter;
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
export const convertZudokuConfigToOptions = (
|
|
43
|
-
config: ZudokuConfig,
|
|
44
|
-
): ZudokuContextOptions => {
|
|
45
|
-
return {
|
|
46
|
-
basePath: config.basePath,
|
|
47
|
-
canonicalUrlOrigin: config.canonicalUrlOrigin,
|
|
48
|
-
aiAssistants: config.aiAssistants,
|
|
49
|
-
protectedRoutes: config.protectedRoutes,
|
|
50
|
-
site: {
|
|
51
|
-
...config.site,
|
|
52
|
-
showPoweredBy:
|
|
53
|
-
ZuploEnv.buildConfig?.entitlements.devPortalZuploBranding ??
|
|
54
|
-
config.site?.showPoweredBy,
|
|
55
|
-
logo: config.site?.logo,
|
|
56
|
-
},
|
|
57
|
-
slots: config.slots,
|
|
58
|
-
metadata: {
|
|
59
|
-
favicon: "https://cdn.zudoku.dev/logos/favicon.svg",
|
|
60
|
-
title: "%s - Zudoku",
|
|
61
|
-
...config.metadata,
|
|
62
|
-
},
|
|
63
|
-
header: {
|
|
64
|
-
navigation: configuredHeaderNavigation,
|
|
65
|
-
placements: config.header?.placements,
|
|
66
|
-
},
|
|
67
|
-
navigation: configuredNavigation,
|
|
68
|
-
navigationRules: configuredNavigationRules,
|
|
69
|
-
mdx: config.mdx,
|
|
70
|
-
plugins: [
|
|
71
|
-
...(configuredAuthProvider ? [configuredAuthProvider] : []),
|
|
72
|
-
...(configuredDocsPlugin ? [configuredDocsPlugin] : []),
|
|
73
|
-
...configuredApiPlugins,
|
|
74
|
-
...(configuredSearchPlugin ? [configuredSearchPlugin] : []),
|
|
75
|
-
...(configuredApiKeysPlugin ? [configuredApiKeysPlugin] : []),
|
|
76
|
-
...(configuredCustomPagesPlugin ? [configuredCustomPagesPlugin] : []),
|
|
77
|
-
...configuredApiCatalogPlugins,
|
|
78
|
-
...(config.plugins ?? []),
|
|
79
|
-
],
|
|
80
|
-
syntaxHighlighting: {
|
|
81
|
-
highlighterPromise: shikiReady,
|
|
82
|
-
themes: config.syntaxHighlighting?.themes,
|
|
83
|
-
},
|
|
84
|
-
};
|
|
85
|
-
};
|
|
86
|
-
|
|
87
|
-
export const getRoutesByOptions = (
|
|
88
|
-
options: ZudokuContextOptions,
|
|
89
|
-
enableStatusPages = true,
|
|
90
|
-
) => {
|
|
91
|
-
const allPlugins = [
|
|
92
|
-
...(options.plugins ?? []),
|
|
93
|
-
...(options.authentication ? [options.authentication] : []),
|
|
94
|
-
];
|
|
95
|
-
|
|
96
|
-
const routes = allPlugins
|
|
97
|
-
.flatMap((plugin) => (isNavigationPlugin(plugin) ? plugin.getRoutes() : []))
|
|
98
|
-
.concat(
|
|
99
|
-
enableStatusPages
|
|
100
|
-
? [400, 404, 500].map((statusCode) => ({
|
|
101
|
-
path: `/${statusCode}`,
|
|
102
|
-
element: <StatusPage statusCode={statusCode} />,
|
|
103
|
-
}))
|
|
104
|
-
: [],
|
|
105
|
-
)
|
|
106
|
-
.concat([{ path: "*", element: <StatusPage statusCode={404} /> }])
|
|
107
|
-
.map((route) => ({
|
|
108
|
-
...route,
|
|
109
|
-
errorElement: <RouterError className="w-full m-0" />,
|
|
110
|
-
}));
|
|
111
|
-
|
|
112
|
-
// @TODO Detect conflicts in routes and log warning
|
|
113
|
-
|
|
114
|
-
return routes;
|
|
115
|
-
};
|
|
116
|
-
|
|
117
|
-
export const getRoutesByConfig = (config: ZudokuConfig): RouteObject[] => {
|
|
118
|
-
const options = convertZudokuConfigToOptions(config);
|
|
119
|
-
const routes = getRoutesByOptions(
|
|
120
|
-
options,
|
|
121
|
-
import.meta.env.IS_ZUPLO || config.enableStatusPages,
|
|
122
|
-
);
|
|
123
|
-
|
|
124
|
-
return [
|
|
125
|
-
...createRedirectRoutes(config.redirects),
|
|
126
|
-
{
|
|
127
|
-
element: (
|
|
128
|
-
<Zudoku {...options} env={import.meta.env}>
|
|
129
|
-
<BuildCheck
|
|
130
|
-
buildId={import.meta.env.ZUPLO_BUILD_ID}
|
|
131
|
-
environmentType={import.meta.env.ZUPLO_ENVIRONMENT_TYPE}
|
|
132
|
-
/>
|
|
133
|
-
<Outlet />
|
|
134
|
-
</Zudoku>
|
|
135
|
-
),
|
|
136
|
-
hydrateFallbackElement: <div>Loading...</div>,
|
|
137
|
-
children: [
|
|
138
|
-
{
|
|
139
|
-
element: (
|
|
140
|
-
<Meta>
|
|
141
|
-
<RouteGuard />
|
|
142
|
-
</Meta>
|
|
143
|
-
),
|
|
144
|
-
errorElement: <RouterError />,
|
|
145
|
-
children: processRoutes(routes),
|
|
146
|
-
},
|
|
147
|
-
],
|
|
148
|
-
},
|
|
149
|
-
];
|
|
150
|
-
};
|
|
1
|
+
import { Zudoku } from "@lukoweb/apitogo/components";
|
|
2
|
+
import { Outlet } from "@lukoweb/apitogo/router";
|
|
3
|
+
import type { RouteObject } from "react-router";
|
|
4
|
+
import type { HighlighterCore } from "shiki";
|
|
5
|
+
import { configuredApiKeysPlugin } from "virtual:zudoku-api-keys-plugin";
|
|
6
|
+
import {
|
|
7
|
+
configuredApiCatalogPlugins,
|
|
8
|
+
configuredApiPlugins,
|
|
9
|
+
} from "virtual:zudoku-api-plugins";
|
|
10
|
+
import { configuredAuthProvider } from "virtual:zudoku-auth";
|
|
11
|
+
import { configuredCustomPagesPlugin } from "virtual:zudoku-custom-pages-plugin";
|
|
12
|
+
import { configuredDocsPlugin } from "virtual:zudoku-docs-plugin";
|
|
13
|
+
import "virtual:zudoku-theme.css";
|
|
14
|
+
import {
|
|
15
|
+
configuredHeaderNavigation,
|
|
16
|
+
configuredNavigation,
|
|
17
|
+
configuredNavigationRules,
|
|
18
|
+
} from "virtual:zudoku-navigation";
|
|
19
|
+
import { configuredSearchPlugin } from "virtual:zudoku-search-plugin";
|
|
20
|
+
import type { ZudokuConfig } from "../config/config.js";
|
|
21
|
+
import { BuildCheck } from "../lib/components/BuildCheck.js";
|
|
22
|
+
import "./main.css";
|
|
23
|
+
import { Meta } from "../lib/components/Meta.js";
|
|
24
|
+
import "./polyfills.js";
|
|
25
|
+
import { StatusPage } from "../lib/components/StatusPage.js";
|
|
26
|
+
import { isNavigationPlugin } from "../lib/core/plugins.js";
|
|
27
|
+
import { RouteGuard } from "../lib/core/RouteGuard.js";
|
|
28
|
+
import type { ZudokuContextOptions } from "../lib/core/ZudokuContext.js";
|
|
29
|
+
import { RouterError } from "../lib/errors/RouterError.js";
|
|
30
|
+
import { ZuploEnv } from "./env.js";
|
|
31
|
+
import { processRoutes } from "./processRoutes.js";
|
|
32
|
+
import { createRedirectRoutes } from "./utils/createRedirectRoutes.js";
|
|
33
|
+
|
|
34
|
+
export const shikiReady: Promise<HighlighterCore> =
|
|
35
|
+
import("../lib/shiki.js").then(async ({ highlighterPromise }) => {
|
|
36
|
+
const highlighter = await highlighterPromise;
|
|
37
|
+
const { registerShiki } = await import("virtual:zudoku-shiki-register");
|
|
38
|
+
await registerShiki(highlighter);
|
|
39
|
+
return highlighter;
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
export const convertZudokuConfigToOptions = (
|
|
43
|
+
config: ZudokuConfig,
|
|
44
|
+
): ZudokuContextOptions => {
|
|
45
|
+
return {
|
|
46
|
+
basePath: config.basePath,
|
|
47
|
+
canonicalUrlOrigin: config.canonicalUrlOrigin,
|
|
48
|
+
aiAssistants: config.aiAssistants,
|
|
49
|
+
protectedRoutes: config.protectedRoutes,
|
|
50
|
+
site: {
|
|
51
|
+
...config.site,
|
|
52
|
+
showPoweredBy:
|
|
53
|
+
ZuploEnv.buildConfig?.entitlements.devPortalZuploBranding ??
|
|
54
|
+
config.site?.showPoweredBy,
|
|
55
|
+
logo: config.site?.logo,
|
|
56
|
+
},
|
|
57
|
+
slots: config.slots,
|
|
58
|
+
metadata: {
|
|
59
|
+
favicon: "https://cdn.zudoku.dev/logos/favicon.svg",
|
|
60
|
+
title: "%s - Zudoku",
|
|
61
|
+
...config.metadata,
|
|
62
|
+
},
|
|
63
|
+
header: {
|
|
64
|
+
navigation: configuredHeaderNavigation,
|
|
65
|
+
placements: config.header?.placements,
|
|
66
|
+
},
|
|
67
|
+
navigation: configuredNavigation,
|
|
68
|
+
navigationRules: configuredNavigationRules,
|
|
69
|
+
mdx: config.mdx,
|
|
70
|
+
plugins: [
|
|
71
|
+
...(configuredAuthProvider ? [configuredAuthProvider] : []),
|
|
72
|
+
...(configuredDocsPlugin ? [configuredDocsPlugin] : []),
|
|
73
|
+
...configuredApiPlugins,
|
|
74
|
+
...(configuredSearchPlugin ? [configuredSearchPlugin] : []),
|
|
75
|
+
...(configuredApiKeysPlugin ? [configuredApiKeysPlugin] : []),
|
|
76
|
+
...(configuredCustomPagesPlugin ? [configuredCustomPagesPlugin] : []),
|
|
77
|
+
...configuredApiCatalogPlugins,
|
|
78
|
+
...(config.plugins ?? []),
|
|
79
|
+
],
|
|
80
|
+
syntaxHighlighting: {
|
|
81
|
+
highlighterPromise: shikiReady,
|
|
82
|
+
themes: config.syntaxHighlighting?.themes,
|
|
83
|
+
},
|
|
84
|
+
};
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
export const getRoutesByOptions = (
|
|
88
|
+
options: ZudokuContextOptions,
|
|
89
|
+
enableStatusPages = true,
|
|
90
|
+
) => {
|
|
91
|
+
const allPlugins = [
|
|
92
|
+
...(options.plugins ?? []),
|
|
93
|
+
...(options.authentication ? [options.authentication] : []),
|
|
94
|
+
];
|
|
95
|
+
|
|
96
|
+
const routes = allPlugins
|
|
97
|
+
.flatMap((plugin) => (isNavigationPlugin(plugin) ? plugin.getRoutes() : []))
|
|
98
|
+
.concat(
|
|
99
|
+
enableStatusPages
|
|
100
|
+
? [400, 404, 500].map((statusCode) => ({
|
|
101
|
+
path: `/${statusCode}`,
|
|
102
|
+
element: <StatusPage statusCode={statusCode} />,
|
|
103
|
+
}))
|
|
104
|
+
: [],
|
|
105
|
+
)
|
|
106
|
+
.concat([{ path: "*", element: <StatusPage statusCode={404} /> }])
|
|
107
|
+
.map((route) => ({
|
|
108
|
+
...route,
|
|
109
|
+
errorElement: <RouterError className="w-full m-0" />,
|
|
110
|
+
}));
|
|
111
|
+
|
|
112
|
+
// @TODO Detect conflicts in routes and log warning
|
|
113
|
+
|
|
114
|
+
return routes;
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
export const getRoutesByConfig = (config: ZudokuConfig): RouteObject[] => {
|
|
118
|
+
const options = convertZudokuConfigToOptions(config);
|
|
119
|
+
const routes = getRoutesByOptions(
|
|
120
|
+
options,
|
|
121
|
+
import.meta.env.IS_ZUPLO || config.enableStatusPages,
|
|
122
|
+
);
|
|
123
|
+
|
|
124
|
+
return [
|
|
125
|
+
...createRedirectRoutes(config.redirects),
|
|
126
|
+
{
|
|
127
|
+
element: (
|
|
128
|
+
<Zudoku {...options} env={import.meta.env}>
|
|
129
|
+
<BuildCheck
|
|
130
|
+
buildId={import.meta.env.ZUPLO_BUILD_ID}
|
|
131
|
+
environmentType={import.meta.env.ZUPLO_ENVIRONMENT_TYPE}
|
|
132
|
+
/>
|
|
133
|
+
<Outlet />
|
|
134
|
+
</Zudoku>
|
|
135
|
+
),
|
|
136
|
+
hydrateFallbackElement: <div>Loading...</div>,
|
|
137
|
+
children: [
|
|
138
|
+
{
|
|
139
|
+
element: (
|
|
140
|
+
<Meta>
|
|
141
|
+
<RouteGuard />
|
|
142
|
+
</Meta>
|
|
143
|
+
),
|
|
144
|
+
errorElement: <RouterError />,
|
|
145
|
+
children: processRoutes(routes),
|
|
146
|
+
},
|
|
147
|
+
],
|
|
148
|
+
},
|
|
149
|
+
];
|
|
150
|
+
};
|