@lukoweb/apitogo 0.1.21 → 0.1.22
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 +21 -18
- package/dist/declarations/app/main.d.ts +4 -3
- package/dist/declarations/config/config.d.ts +1 -0
- package/dist/declarations/config/create-plugin.d.ts +2 -2
- package/dist/declarations/config/validators/ZudokuConfig.d.ts +2 -3
- package/dist/declarations/index.d.ts +7 -3
- package/dist/declarations/lib/components/PluginHeads.d.ts +2 -2
- package/dist/declarations/lib/components/Zudoku.d.ts +7 -1
- package/dist/declarations/lib/components/context/ZudokuContext.d.ts +1 -0
- package/dist/declarations/lib/components/context/ZudokuProvider.d.ts +3 -0
- package/dist/declarations/lib/components/index.d.ts +5 -0
- package/dist/declarations/lib/core/ZudokuContext.d.ts +5 -5
- package/dist/declarations/lib/core/plugins.d.ts +13 -13
- package/dist/declarations/lib/hooks/index.d.ts +1 -0
- package/dist/declarations/lib/hooks/useEvent.d.ts +4 -4
- package/dist/declarations/lib/plugins/api-catalog/index.d.ts +2 -2
- package/dist/declarations/lib/plugins/api-keys/index.d.ts +2 -2
- package/dist/declarations/lib/plugins/markdown/index.d.ts +2 -2
- package/dist/declarations/lib/plugins/openapi/index.d.ts +2 -2
- package/dist/declarations/lib/plugins/search-inkeep/index.d.ts +2 -2
- package/dist/declarations/lib/plugins/search-pagefind/index.d.ts +2 -2
- package/dist/declarations/lib/testing/index.d.ts +3 -2
- package/dist/declarations/lib/util/invariant.d.ts +6 -4
- package/package.json +1 -1
- package/src/app/main.tsx +14 -11
- package/src/config/config.ts +7 -0
- package/src/config/create-plugin.ts +3 -3
- package/src/config/validators/BuildSchema.ts +7 -2
- package/src/config/validators/ZudokuConfig.ts +2 -3
- package/src/index.ts +13 -3
- package/src/lib/authentication/providers/clerk.tsx +2 -2
- package/src/lib/components/PluginHeads.tsx +2 -2
- package/src/lib/components/Zudoku.tsx +13 -8
- package/src/lib/components/context/ZudokuContext.ts +15 -5
- package/src/lib/components/context/ZudokuProvider.tsx +7 -1
- package/src/lib/components/index.ts +9 -1
- package/src/lib/core/ZudokuContext.ts +8 -8
- package/src/lib/core/plugins.ts +13 -13
- package/src/lib/hooks/index.ts +2 -0
- package/src/lib/hooks/useEvent.ts +12 -12
- package/src/lib/plugins/api-catalog/index.tsx +2 -2
- package/src/lib/plugins/api-keys/index.tsx +2 -2
- package/src/lib/plugins/markdown/index.tsx +2 -2
- package/src/lib/plugins/openapi/Sidecar.tsx +4 -2
- package/src/lib/plugins/openapi/index.tsx +6 -3
- package/src/lib/plugins/search-inkeep/index.tsx +2 -2
- package/src/lib/plugins/search-pagefind/index.tsx +2 -2
- package/src/lib/testing/index.tsx +11 -2
- package/src/lib/util/invariant.ts +16 -6
- package/src/types.d.ts +6 -6
- package/src/vite/config.ts +10 -6
package/dist/cli/cli.js
CHANGED
|
@@ -108,17 +108,17 @@ function invariant(condition, message, options) {
|
|
|
108
108
|
return;
|
|
109
109
|
}
|
|
110
110
|
const provided = typeof message === "function" ? message() : message;
|
|
111
|
-
throw new
|
|
111
|
+
throw new ApitogoError(provided ?? "Invariant failed", options);
|
|
112
112
|
}
|
|
113
|
-
var
|
|
113
|
+
var ApitogoError;
|
|
114
114
|
var init_invariant = __esm({
|
|
115
115
|
"src/lib/util/invariant.ts"() {
|
|
116
|
-
|
|
116
|
+
ApitogoError = class extends Error {
|
|
117
117
|
developerHint;
|
|
118
118
|
title;
|
|
119
119
|
constructor(message, { developerHint, title, cause } = {}) {
|
|
120
120
|
super(message, { cause });
|
|
121
|
-
this.name = "
|
|
121
|
+
this.name = "ApitogoError";
|
|
122
122
|
this.title = title;
|
|
123
123
|
this.developerHint = developerHint;
|
|
124
124
|
}
|
|
@@ -3315,7 +3315,6 @@ var init_ZudokuConfig = __esm({
|
|
|
3315
3315
|
logoUrl: z7.string(),
|
|
3316
3316
|
dir: z7.enum(["ltr", "rtl"]).optional(),
|
|
3317
3317
|
logo: LogoSchema,
|
|
3318
|
-
showPoweredBy: z7.boolean().optional(),
|
|
3319
3318
|
banner: z7.object({
|
|
3320
3319
|
message: z7.custom(),
|
|
3321
3320
|
color: z7.custom(
|
|
@@ -3822,7 +3821,7 @@ import {
|
|
|
3822
3821
|
// package.json
|
|
3823
3822
|
var package_default = {
|
|
3824
3823
|
name: "@lukoweb/apitogo",
|
|
3825
|
-
version: "0.1.
|
|
3824
|
+
version: "0.1.22",
|
|
3826
3825
|
type: "module",
|
|
3827
3826
|
sideEffects: [
|
|
3828
3827
|
"**/*.css",
|
|
@@ -4428,7 +4427,12 @@ var BuildConfigSchema2 = z8.object({
|
|
|
4428
4427
|
rehypePlugins: PluginConfigSchema.optional(),
|
|
4429
4428
|
prerender: z8.object({ workers: z8.number().optional() }).optional()
|
|
4430
4429
|
});
|
|
4431
|
-
var
|
|
4430
|
+
var buildConfigFiles = [
|
|
4431
|
+
"apitogo.build.js",
|
|
4432
|
+
"apitogo.build.jsx",
|
|
4433
|
+
"apitogo.build.ts",
|
|
4434
|
+
"apitogo.build.tsx",
|
|
4435
|
+
"apitogo.build.mjs",
|
|
4432
4436
|
"zudoku.build.js",
|
|
4433
4437
|
"zudoku.build.jsx",
|
|
4434
4438
|
"zudoku.build.ts",
|
|
@@ -4436,7 +4440,7 @@ var zudokuBuildConfigFiles = [
|
|
|
4436
4440
|
"zudoku.build.mjs"
|
|
4437
4441
|
];
|
|
4438
4442
|
async function getBuildConfigFilePath(rootDir) {
|
|
4439
|
-
for (const fileName of
|
|
4443
|
+
for (const fileName of buildConfigFiles) {
|
|
4440
4444
|
const filepath = path7.join(rootDir, fileName);
|
|
4441
4445
|
if (await fileExists(filepath)) {
|
|
4442
4446
|
return filepath;
|
|
@@ -7662,11 +7666,9 @@ async function getViteConfig(dir, configEnv) {
|
|
|
7662
7666
|
});
|
|
7663
7667
|
}
|
|
7664
7668
|
}
|
|
7665
|
-
|
|
7666
|
-
|
|
7667
|
-
|
|
7668
|
-
await ensurePagefindDevStub(publicDir);
|
|
7669
|
-
}
|
|
7669
|
+
const publicDir = resolveMergedPublicDir(dir, mergedViteConfig);
|
|
7670
|
+
if (publicDir && (configEnv.mode === "development" || config2.search?.type === "pagefind")) {
|
|
7671
|
+
await ensurePagefindDevStub(publicDir);
|
|
7670
7672
|
}
|
|
7671
7673
|
return mergedViteConfig;
|
|
7672
7674
|
}
|
|
@@ -9459,9 +9461,10 @@ var titleCase = (value) => value.split(/[-_\s]+/).filter(Boolean).map((part) =>
|
|
|
9459
9461
|
var docSortRank = (docPath) => {
|
|
9460
9462
|
const lastSegment = docPath.split("/").at(-1) ?? docPath;
|
|
9461
9463
|
if (lastSegment === "introduction") return 0;
|
|
9462
|
-
if (lastSegment === "
|
|
9463
|
-
if (lastSegment === "
|
|
9464
|
-
return 3;
|
|
9464
|
+
if (lastSegment === "example") return 1;
|
|
9465
|
+
if (lastSegment === "getting-started") return 2;
|
|
9466
|
+
if (lastSegment === "index") return 3;
|
|
9467
|
+
return 4;
|
|
9465
9468
|
};
|
|
9466
9469
|
var sortDocPaths = (docPaths) => [...docPaths].sort((a, b) => {
|
|
9467
9470
|
const rankDiff = docSortRank(a) - docSortRank(b);
|
|
@@ -10026,7 +10029,7 @@ ${colors10.gray("Upgrade to receive the latest features and fixes.")}`
|
|
|
10026
10029
|
}
|
|
10027
10030
|
async function getLatestVersion() {
|
|
10028
10031
|
const response = await fetch(
|
|
10029
|
-
"https://api.github.com/repos/
|
|
10032
|
+
"https://api.github.com/repos/lukoweb/apitogo-doc-tool/releases?per_page=1"
|
|
10030
10033
|
);
|
|
10031
10034
|
if (response.status === 200) {
|
|
10032
10035
|
const result = await response.json();
|
|
@@ -10121,7 +10124,7 @@ var warnPackageVersionMismatch = () => {
|
|
|
10121
10124
|
const pkgManager = getPkgManager();
|
|
10122
10125
|
const message = `${colors11.yellow("React version mismatch detected!")}
|
|
10123
10126
|
|
|
10124
|
-
|
|
10127
|
+
APIToGo requires specific versions of React
|
|
10125
10128
|
and React DOM to function correctly.
|
|
10126
10129
|
|
|
10127
10130
|
Installed: ${colors11.bold(`react@${installed.react}, react-dom@${installed["react-dom"]}`)}
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import type { RouteObject } from "react-router";
|
|
2
2
|
import type { HighlighterCore } from "shiki";
|
|
3
3
|
import "virtual:zudoku-theme.css";
|
|
4
|
-
import type {
|
|
4
|
+
import type { ApitogoConfig } from "../config/config.js";
|
|
5
5
|
import "./main.css";
|
|
6
6
|
import "./polyfills.js";
|
|
7
7
|
import type { ZudokuContextOptions } from "../lib/core/ZudokuContext.js";
|
|
8
8
|
export declare const shikiReady: Promise<HighlighterCore>;
|
|
9
|
-
export declare const
|
|
9
|
+
export declare const convertApitogoConfigToOptions: (config: ApitogoConfig) => ZudokuContextOptions;
|
|
10
|
+
export declare const convertZudokuConfigToOptions: (config: ApitogoConfig) => ZudokuContextOptions;
|
|
10
11
|
export declare const getRoutesByOptions: (options: ZudokuContextOptions, enableStatusPages?: boolean) => ({
|
|
11
12
|
errorElement: import("react/jsx-runtime").JSX.Element;
|
|
12
13
|
caseSensitive?: boolean | undefined;
|
|
@@ -98,4 +99,4 @@ export declare const getRoutesByOptions: (options: ZudokuContextOptions, enableS
|
|
|
98
99
|
ErrorBoundary?: (() => Promise<import("react").ComponentType<{}> | null | undefined>) | undefined;
|
|
99
100
|
}) | import("react-router").LazyRouteFunction<RouteObject>;
|
|
100
101
|
})[];
|
|
101
|
-
export declare const getRoutesByConfig: (config:
|
|
102
|
+
export declare const getRoutesByConfig: (config: ApitogoConfig) => RouteObject[];
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { ConfigWithMeta } from "./loader.js";
|
|
2
2
|
import type { BuildConfig } from "./validators/BuildSchema.js";
|
|
3
3
|
import type { AuthenticationConfig, ZudokuConfig } from "./validators/ZudokuConfig.js";
|
|
4
|
+
export type ApitogoBuildConfig = BuildConfig;
|
|
4
5
|
export type ZudokuBuildConfig = BuildConfig;
|
|
5
6
|
export type LoadedConfig = ConfigWithMeta;
|
|
6
7
|
export type { ZudokuConfig as ApitogoConfig };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { type
|
|
2
|
-
export declare const createPlugin: <TOptions extends unknown[]>(factory: (...options: TOptions) =>
|
|
1
|
+
import { type ApitogoPlugin } from "../lib/core/plugins.js";
|
|
2
|
+
export declare const createPlugin: <TOptions extends unknown[]>(factory: (...options: TOptions) => ApitogoPlugin) => ((...options: TOptions) => ApitogoPlugin);
|
|
@@ -5,7 +5,7 @@ import { z } from "zod";
|
|
|
5
5
|
import type { UseAuthReturn } from "../../lib/authentication/hook.js";
|
|
6
6
|
import type { AuthState } from "../../lib/authentication/state.js";
|
|
7
7
|
import type { SlotType } from "../../lib/components/context/SlotProvider.js";
|
|
8
|
-
import type {
|
|
8
|
+
import type { ApitogoPlugin } from "../../lib/core/plugins.js";
|
|
9
9
|
import type { ZudokuContext } from "../../lib/core/ZudokuContext.js";
|
|
10
10
|
import type { FilterCatalogItemsFn } from "../../lib/plugins/api-catalog/index.js";
|
|
11
11
|
import type { ApiConsumer } from "../../lib/plugins/api-keys/index.js";
|
|
@@ -420,7 +420,7 @@ export declare const ZudokuConfig: z.ZodObject<{
|
|
|
420
420
|
render: z.ZodOptional<z.ZodCustom<ComponentType<ExposedComponentProps>, ComponentType<ExposedComponentProps>>>;
|
|
421
421
|
prose: z.ZodOptional<z.ZodBoolean>;
|
|
422
422
|
}, z.core.$strip>>>;
|
|
423
|
-
plugins: z.ZodOptional<z.ZodArray<z.ZodCustom<
|
|
423
|
+
plugins: z.ZodOptional<z.ZodArray<z.ZodCustom<ApitogoPlugin, ApitogoPlugin>>>;
|
|
424
424
|
build: z.ZodOptional<z.ZodCustom<{
|
|
425
425
|
remarkPlugins?: Options["remarkPlugins"];
|
|
426
426
|
rehypePlugins?: Options["rehypePlugins"];
|
|
@@ -464,7 +464,6 @@ export declare const ZudokuConfig: z.ZodObject<{
|
|
|
464
464
|
href: z.ZodOptional<z.ZodString>;
|
|
465
465
|
reloadDocument: z.ZodOptional<z.ZodBoolean>;
|
|
466
466
|
}, z.core.$strip>>;
|
|
467
|
-
showPoweredBy: z.ZodOptional<z.ZodOptional<z.ZodBoolean>>;
|
|
468
467
|
banner: z.ZodOptional<z.ZodObject<{
|
|
469
468
|
message: z.ZodCustom<NonNullable<ReactNode>, NonNullable<ReactNode>>;
|
|
470
469
|
color: z.ZodOptional<z.ZodCustom<"info" | (string & {}) | "note" | "tip" | "caution" | "danger", "info" | (string & {}) | "note" | "tip" | "caution" | "danger">>;
|
|
@@ -1,10 +1,14 @@
|
|
|
1
|
-
export type { ApitogoConfig, ZudokuBuildConfig } from "./config/config.js";
|
|
1
|
+
export type { ApitogoBuildConfig, ApitogoConfig, ZudokuBuildConfig, } from "./config/config.js";
|
|
2
2
|
export { createPlugin } from "./config/create-plugin.js";
|
|
3
3
|
export type { InputNavigation as Navigation } from "./config/validators/InputNavigationSchema.js";
|
|
4
4
|
export type { SlotType } from "./lib/components/context/SlotProvider.js";
|
|
5
5
|
export { type CustomSlotNames, Slot, type SlotName, } from "./lib/components/Slot.js";
|
|
6
|
-
export type { ApiIdentityPlugin, AuthenticationPlugin, CommonPlugin, NavigationPlugin, ProfileMenuPlugin, ProfileNavigationItem, RouteObject, SearchProviderPlugin, TransformConfigContext,
|
|
7
|
-
export {
|
|
6
|
+
export type { ApiIdentityPlugin, AuthenticationPlugin, CommonPlugin, NavigationPlugin, ProfileMenuPlugin, ProfileNavigationItem, RouteObject, SearchProviderPlugin, TransformConfigContext, ApitogoPlugin, } from "./lib/core/plugins.js";
|
|
7
|
+
export type { ApiIdentity, ApitogoEvents } from "./lib/core/ZudokuContext.js";
|
|
8
|
+
export type { ZudokuContextOptions } from "./lib/core/ZudokuContext.js";
|
|
9
|
+
export type { ZudokuContextOptions as ApitogoContextOptions } from "./lib/core/ZudokuContext.js";
|
|
10
|
+
export { ZudokuContext } from "./lib/core/ZudokuContext.js";
|
|
11
|
+
export { ZudokuContext as ApitogoContext } from "./lib/core/ZudokuContext.js";
|
|
8
12
|
export { useEvent } from "./lib/hooks/index.js";
|
|
9
13
|
export type { MDXImport } from "./lib/plugins/markdown/index.js";
|
|
10
14
|
export { defaultLanguages } from "./lib/shiki.js";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Location } from "react-router";
|
|
2
|
-
import { type
|
|
2
|
+
import { type ApitogoPlugin } from "../core/plugins.js";
|
|
3
3
|
export declare const PluginHeads: ({ plugins, location, }: {
|
|
4
|
-
plugins:
|
|
4
|
+
plugins: ApitogoPlugin[];
|
|
5
5
|
location: Location;
|
|
6
6
|
}) => import("react/jsx-runtime").JSX.Element[];
|
|
@@ -1,9 +1,15 @@
|
|
|
1
1
|
import { type PropsWithChildren } from "react";
|
|
2
2
|
import { type ZudokuContextOptions } from "../core/ZudokuContext.js";
|
|
3
|
+
declare const Apitogo: {
|
|
4
|
+
(props: PropsWithChildren<ZudokuContextOptions & {
|
|
5
|
+
env?: Record<string, string>;
|
|
6
|
+
}>): import("react/jsx-runtime").JSX.Element;
|
|
7
|
+
displayName: string;
|
|
8
|
+
};
|
|
3
9
|
declare const Zudoku: {
|
|
4
10
|
(props: PropsWithChildren<ZudokuContextOptions & {
|
|
5
11
|
env?: Record<string, string>;
|
|
6
12
|
}>): import("react/jsx-runtime").JSX.Element;
|
|
7
13
|
displayName: string;
|
|
8
14
|
};
|
|
9
|
-
export { Zudoku };
|
|
15
|
+
export { Apitogo, Zudoku };
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { NavigationItem } from "../../../config/validators/NavigationSchema.js";
|
|
2
|
+
export declare const useApitogo: () => import("../../core/ZudokuContext.js").ZudokuContext;
|
|
2
3
|
export declare const useZudoku: () => import("../../core/ZudokuContext.js").ZudokuContext;
|
|
3
4
|
export declare const useApiIdentities: () => import("@tanstack/react-query").UseQueryResult<import("../../core/ZudokuContext.js").ApiIdentity[], Error>;
|
|
4
5
|
export declare const useCurrentNavigation: () => {
|
|
@@ -3,3 +3,6 @@ import type { ZudokuContext } from "../../core/ZudokuContext.js";
|
|
|
3
3
|
export declare const ZudokuProvider: ({ children, context, }: PropsWithChildren<{
|
|
4
4
|
context: ZudokuContext;
|
|
5
5
|
}>) => import("react/jsx-runtime").JSX.Element;
|
|
6
|
+
export declare const ApitogoProvider: ({ children, context, }: PropsWithChildren<{
|
|
7
|
+
context: ZudokuContext;
|
|
8
|
+
}>) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -2,6 +2,7 @@ export { Helmet as Head } from "@zudoku/react-helmet-async";
|
|
|
2
2
|
export { Link } from "react-router";
|
|
3
3
|
export { Button } from "../ui/Button.js";
|
|
4
4
|
export { Callout } from "../ui/Callout.js";
|
|
5
|
+
export { ApitogoError } from "../util/invariant.js";
|
|
5
6
|
export { ZudokuError } from "../util/invariant.js";
|
|
6
7
|
export { ClientOnly } from "./ClientOnly.js";
|
|
7
8
|
export { Heading } from "./Heading.js";
|
|
@@ -10,9 +11,13 @@ export { Search } from "./Search.js";
|
|
|
10
11
|
export { type CustomSlotNames, Slot } from "./Slot.js";
|
|
11
12
|
export { Spinner } from "./Spinner.js";
|
|
12
13
|
export { Typography } from "./Typography.js";
|
|
14
|
+
export { Apitogo } from "./Zudoku.js";
|
|
13
15
|
export { Zudoku } from "./Zudoku.js";
|
|
16
|
+
export { ApitogoProvider } from "./context/ZudokuProvider.js";
|
|
17
|
+
export { ZudokuProvider } from "./context/ZudokuProvider.js";
|
|
14
18
|
export { useMDXComponents } from "@mdx-js/react";
|
|
15
19
|
export { useTheme } from "next-themes";
|
|
16
20
|
export { useAuth } from "../authentication/hook.js";
|
|
17
21
|
export { CACHE_KEYS, useCache } from "./cache.js";
|
|
22
|
+
export { useApitogo } from "./context/ZudokuContext.js";
|
|
18
23
|
export { useZudoku } from "./context/ZudokuContext.js";
|
|
@@ -11,8 +11,8 @@ import type { AuthenticationPlugin } from "../authentication/authentication.js";
|
|
|
11
11
|
import { type AuthState } from "../authentication/state.js";
|
|
12
12
|
import type { SlotType } from "../components/context/SlotProvider.js";
|
|
13
13
|
import type { MdxComponentsType } from "../util/MdxComponents.js";
|
|
14
|
-
import { type ProfileNavigationItem, type
|
|
15
|
-
export interface
|
|
14
|
+
import { type ProfileNavigationItem, type ApitogoPlugin } from "./plugins.js";
|
|
15
|
+
export interface ApitogoEvents {
|
|
16
16
|
location: (event: {
|
|
17
17
|
from?: Location;
|
|
18
18
|
to: Location;
|
|
@@ -85,7 +85,7 @@ export type ZudokuContextOptions = {
|
|
|
85
85
|
authentication?: AuthenticationPlugin;
|
|
86
86
|
navigation?: Navigation;
|
|
87
87
|
navigationRules?: ResolvedNavigationRule[];
|
|
88
|
-
plugins?:
|
|
88
|
+
plugins?: ApitogoPlugin[];
|
|
89
89
|
slots?: Record<string, SlotType>;
|
|
90
90
|
UNSAFE_slotlets?: Record<string, SlotType>;
|
|
91
91
|
mdx?: {
|
|
@@ -115,8 +115,8 @@ export declare class ZudokuContext {
|
|
|
115
115
|
readonly initialize: Promise<void> | undefined;
|
|
116
116
|
constructor(options: ZudokuContextOptions, queryClient: QueryClient, env: Record<string, string | undefined>);
|
|
117
117
|
getApiIdentities: () => Promise<ApiIdentity[]>;
|
|
118
|
-
addEventListener<E extends keyof
|
|
119
|
-
emitEvent: <E extends keyof
|
|
118
|
+
addEventListener<E extends keyof ApitogoEvents>(event: E, callback: ApitogoEvents[E]): import("nanoevents").Unsubscribe;
|
|
119
|
+
emitEvent: <E extends keyof ApitogoEvents>(event: E, ...data: Parameters<ApitogoEvents[E]>) => void;
|
|
120
120
|
getPluginNavigation: (path: string) => Promise<import("../../config/validators/NavigationSchema.js").NavigationItem[]>;
|
|
121
121
|
getProfileMenuItems: () => ProfileNavigationItem[];
|
|
122
122
|
signRequest: (request: Request) => Promise<Request>;
|
|
@@ -6,9 +6,9 @@ import type { ProtectedRoutesInput } from "../../config/validators/ProtectedRout
|
|
|
6
6
|
import type { ZudokuConfig } from "../../config/validators/ZudokuConfig.js";
|
|
7
7
|
import type { AuthenticationPlugin } from "../authentication/authentication.js";
|
|
8
8
|
import type { MdxComponentsType } from "../util/MdxComponents.js";
|
|
9
|
-
import type { ApiIdentity,
|
|
9
|
+
import type { ApiIdentity, ApitogoEvents, ZudokuContext } from "./ZudokuContext.js";
|
|
10
10
|
export { runPluginTransformConfig } from "./transform-config.js";
|
|
11
|
-
export type
|
|
11
|
+
export type ApitogoPlugin = CommonPlugin | ProfileMenuPlugin | NavigationPlugin | ApiIdentityPlugin | SearchProviderPlugin | EventConsumerPlugin | AuthenticationPlugin | TransformConfigPlugin;
|
|
12
12
|
export type { AuthenticationPlugin, RouteObject };
|
|
13
13
|
export interface NavigationPlugin {
|
|
14
14
|
getRoutes: () => RouteObject[];
|
|
@@ -57,18 +57,18 @@ export interface CommonPlugin {
|
|
|
57
57
|
}) => ReactNode | undefined;
|
|
58
58
|
getMdxComponents?: () => MdxComponentsType;
|
|
59
59
|
}
|
|
60
|
-
export type EventConsumerPlugin<Event extends
|
|
60
|
+
export type EventConsumerPlugin<Event extends ApitogoEvents = ApitogoEvents> = {
|
|
61
61
|
events: {
|
|
62
62
|
[K in keyof Event]?: Event[K];
|
|
63
63
|
};
|
|
64
64
|
};
|
|
65
|
-
export declare const isEventConsumerPlugin: (obj:
|
|
66
|
-
export declare const isProfileMenuPlugin: (obj:
|
|
67
|
-
export declare const isNavigationPlugin: (obj:
|
|
68
|
-
export declare const isAuthenticationPlugin: (obj:
|
|
69
|
-
export declare const isSearchPlugin: (obj:
|
|
70
|
-
export declare const needsInitialization: (obj:
|
|
71
|
-
export declare const hasHead: (obj:
|
|
72
|
-
export declare const isMdxProviderPlugin: (obj:
|
|
73
|
-
export declare const isApiIdentityPlugin: (obj:
|
|
74
|
-
export declare const isTransformConfigPlugin: (obj:
|
|
65
|
+
export declare const isEventConsumerPlugin: (obj: ApitogoPlugin) => obj is EventConsumerPlugin;
|
|
66
|
+
export declare const isProfileMenuPlugin: (obj: ApitogoPlugin) => obj is ProfileMenuPlugin;
|
|
67
|
+
export declare const isNavigationPlugin: (obj: ApitogoPlugin) => obj is NavigationPlugin;
|
|
68
|
+
export declare const isAuthenticationPlugin: (obj: ApitogoPlugin) => obj is AuthenticationPlugin;
|
|
69
|
+
export declare const isSearchPlugin: (obj: ApitogoPlugin) => obj is SearchProviderPlugin;
|
|
70
|
+
export declare const needsInitialization: (obj: ApitogoPlugin) => obj is CommonPlugin;
|
|
71
|
+
export declare const hasHead: (obj: ApitogoPlugin) => obj is CommonPlugin;
|
|
72
|
+
export declare const isMdxProviderPlugin: (obj: ApitogoPlugin) => obj is CommonPlugin;
|
|
73
|
+
export declare const isApiIdentityPlugin: (obj: ApitogoPlugin) => obj is ApiIdentityPlugin;
|
|
74
|
+
export declare const isTransformConfigPlugin: (obj: ApitogoPlugin) => obj is TransformConfigPlugin;
|
|
@@ -2,6 +2,7 @@ export { useMDXComponents } from "@mdx-js/react";
|
|
|
2
2
|
export { useTheme } from "next-themes";
|
|
3
3
|
export { useAuth, useRefreshUserProfile, useVerifiedEmail, } from "../authentication/hook.js";
|
|
4
4
|
export { CACHE_KEYS, useCache } from "../components/cache.js";
|
|
5
|
+
export { useApitogo } from "../components/context/ZudokuContext.js";
|
|
5
6
|
export { useZudoku } from "../components/context/ZudokuContext.js";
|
|
6
7
|
export { useExposedProps } from "../util/useExposedProps.js";
|
|
7
8
|
export { useEvent } from "./useEvent.js";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
type EventParameters<Event extends keyof
|
|
3
|
-
export declare function useEvent<E extends keyof
|
|
4
|
-
export declare function useEvent<E extends keyof
|
|
1
|
+
import type { ApitogoEvents } from "../core/ZudokuContext.js";
|
|
2
|
+
type EventParameters<Event extends keyof ApitogoEvents> = Parameters<ApitogoEvents[Event]>;
|
|
3
|
+
export declare function useEvent<E extends keyof ApitogoEvents>(event: E): EventParameters<E>;
|
|
4
|
+
export declare function useEvent<E extends keyof ApitogoEvents, R>(event: E, callback: (...args: EventParameters<E>) => R): R;
|
|
5
5
|
export {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { AuthState } from "../../authentication/state.js";
|
|
2
|
-
import type {
|
|
2
|
+
import type { ApitogoPlugin } from "../../core/plugins.js";
|
|
3
3
|
export declare const getKey: (category: string, tag: string) => string;
|
|
4
4
|
export type ApiCatalogItem = {
|
|
5
5
|
path: string;
|
|
@@ -28,4 +28,4 @@ export declare const apiCatalogPlugin: ({ path, items, label, categories, filter
|
|
|
28
28
|
categories?: CatalogCategory[];
|
|
29
29
|
items: ApiCatalogItem[];
|
|
30
30
|
filterCatalogItems?: FilterCatalogItemsFn;
|
|
31
|
-
}) =>
|
|
31
|
+
}) => ApitogoPlugin;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { ApiKeysOptions } from "../../../config/validators/ZudokuConfig.js";
|
|
2
2
|
import type { UseAuthReturn } from "../../authentication/hook.js";
|
|
3
|
-
import type { ApiIdentityPlugin, ProfileMenuPlugin,
|
|
3
|
+
import type { ApiIdentityPlugin, ProfileMenuPlugin, ApitogoPlugin } from "../../core/plugins.js";
|
|
4
4
|
import type { ZudokuContext } from "../../core/ZudokuContext.js";
|
|
5
5
|
export type ApiKeyService = {
|
|
6
6
|
getConsumers: (context: ZudokuContext) => Promise<ApiConsumer[]>;
|
|
@@ -47,5 +47,5 @@ type InternalApiKeyPluginOptions = {
|
|
|
47
47
|
deploymentName?: string;
|
|
48
48
|
isZuplo?: boolean;
|
|
49
49
|
};
|
|
50
|
-
export declare const apiKeyPlugin: ({ deploymentName, isZuplo, ...options }: Omit<ApiKeysOptions, "enabled"> & InternalApiKeyPluginOptions) =>
|
|
50
|
+
export declare const apiKeyPlugin: ({ deploymentName, isZuplo, ...options }: Omit<ApiKeysOptions, "enabled"> & InternalApiKeyPluginOptions) => ApitogoPlugin & ApiIdentityPlugin & ProfileMenuPlugin;
|
|
51
51
|
export {};
|
|
@@ -2,7 +2,7 @@ import type { MDXProps } from "mdx/types.js";
|
|
|
2
2
|
import type { JSX } from "react";
|
|
3
3
|
import type { ZudokuDocsConfig } from "../../../config/validators/ZudokuConfig.js";
|
|
4
4
|
import type { Toc } from "../../../vite/mdx/rehype-extract-toc-with-jsx.js";
|
|
5
|
-
import type {
|
|
5
|
+
import type { ApitogoPlugin } from "../../core/plugins.js";
|
|
6
6
|
export interface MarkdownPluginOptions extends ZudokuDocsConfig {
|
|
7
7
|
basePath: string;
|
|
8
8
|
fileImports: Record<string, () => Promise<MDXImport>>;
|
|
@@ -31,4 +31,4 @@ export type MDXImport = {
|
|
|
31
31
|
__filepath: string;
|
|
32
32
|
default: (props: MDXProps) => JSX.Element;
|
|
33
33
|
};
|
|
34
|
-
export declare const markdownPlugin: (options: MarkdownPluginOptions) =>
|
|
34
|
+
export declare const markdownPlugin: (options: MarkdownPluginOptions) => ApitogoPlugin;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ApitogoPlugin } from "../../core/plugins.js";
|
|
2
2
|
import type { GetNavigationOperationsQuery as GetNavigationOperationsQueryResult } from "./graphql/graphql.js";
|
|
3
3
|
import type { OasPluginConfig } from "./interfaces.js";
|
|
4
4
|
export declare const GetNavigationOperationsQuery: import("./graphql/graphql.js").TypedDocumentString<GetNavigationOperationsQueryResult, import("./graphql/graphql.js").Exact<{
|
|
@@ -8,4 +8,4 @@ export declare const GetNavigationOperationsQuery: import("./graphql/graphql.js"
|
|
|
8
8
|
export type OperationResult = GetNavigationOperationsQueryResult["schema"]["tags"][number]["operations"][number];
|
|
9
9
|
export type OpenApiPluginOptions = OasPluginConfig;
|
|
10
10
|
export declare const UNTAGGED_PATH = "~endpoints";
|
|
11
|
-
export declare const openApiPlugin: (config: OasPluginConfig) =>
|
|
11
|
+
export declare const openApiPlugin: (config: OasPluginConfig) => ApitogoPlugin;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { InkeepBaseSettings, InkeepJS } from "@inkeep/cxkit-types";
|
|
2
|
-
import type {
|
|
2
|
+
import type { ApitogoPlugin } from "../../core/plugins.js";
|
|
3
3
|
declare global {
|
|
4
4
|
interface Window {
|
|
5
5
|
Inkeep: InkeepJS | undefined;
|
|
6
6
|
}
|
|
7
7
|
}
|
|
8
|
-
export declare const inkeepSearchPlugin: (settings: InkeepBaseSettings) =>
|
|
8
|
+
export declare const inkeepSearchPlugin: (settings: InkeepBaseSettings) => ApitogoPlugin;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { ZudokuConfig } from "../../../config/validators/ZudokuConfig.js";
|
|
2
|
-
import type {
|
|
2
|
+
import type { ApitogoPlugin } from "../../core/plugins.js";
|
|
3
3
|
export type PagefindOptions = Extract<ZudokuConfig["search"], {
|
|
4
4
|
type: "pagefind";
|
|
5
5
|
}>;
|
|
6
|
-
export declare const pagefindSearchPlugin: (options: PagefindOptions) =>
|
|
6
|
+
export declare const pagefindSearchPlugin: (options: PagefindOptions) => ApitogoPlugin;
|
|
@@ -5,12 +5,13 @@ type QueryData = {
|
|
|
5
5
|
queryKey: QueryKey;
|
|
6
6
|
data: unknown;
|
|
7
7
|
};
|
|
8
|
-
type StaticZudokuProps = ZudokuContextOptions & {
|
|
8
|
+
export type StaticZudokuProps = ZudokuContextOptions & {
|
|
9
9
|
path: string;
|
|
10
10
|
queryData?: QueryData[];
|
|
11
11
|
env?: Record<string, string>;
|
|
12
12
|
isAuthenticated?: boolean;
|
|
13
13
|
redirects?: ZudokuRedirect[];
|
|
14
14
|
};
|
|
15
|
+
export type StaticApitogoProps = StaticZudokuProps;
|
|
15
16
|
declare const StaticZudoku: ({ path, queryData, env, isAuthenticated, redirects, ...options }: StaticZudokuProps) => import("react/jsx-runtime").JSX.Element;
|
|
16
|
-
export { StaticZudoku,
|
|
17
|
+
export { StaticZudoku, StaticZudoku as StaticApitogo, type QueryData };
|
|
@@ -1,11 +1,13 @@
|
|
|
1
|
-
export default function invariant(condition: any, message?: string | (() => string), options?:
|
|
2
|
-
export type
|
|
1
|
+
export default function invariant(condition: any, message?: string | (() => string), options?: ApitogoErrorOptions): asserts condition;
|
|
2
|
+
export type ApitogoErrorOptions = {
|
|
3
3
|
developerHint?: string;
|
|
4
4
|
title?: string;
|
|
5
5
|
cause?: Error;
|
|
6
6
|
};
|
|
7
|
-
export
|
|
7
|
+
export type ZudokuErrorOptions = ApitogoErrorOptions;
|
|
8
|
+
export declare class ApitogoError extends Error {
|
|
8
9
|
developerHint: string | undefined;
|
|
9
10
|
title: string | undefined;
|
|
10
|
-
constructor(message: string, { developerHint, title, cause }?:
|
|
11
|
+
constructor(message: string, { developerHint, title, cause }?: ApitogoErrorOptions);
|
|
11
12
|
}
|
|
13
|
+
export declare const ZudokuError: typeof ApitogoError;
|
package/package.json
CHANGED
package/src/app/main.tsx
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Apitogo } from "@lukoweb/apitogo/components";
|
|
2
2
|
import { Outlet } from "@lukoweb/apitogo/router";
|
|
3
3
|
import type { RouteObject } from "react-router";
|
|
4
4
|
import type { HighlighterCore } from "shiki";
|
|
@@ -17,7 +17,7 @@ import {
|
|
|
17
17
|
configuredNavigationRules,
|
|
18
18
|
} from "virtual:zudoku-navigation";
|
|
19
19
|
import { configuredSearchPlugin } from "virtual:zudoku-search-plugin";
|
|
20
|
-
import type {
|
|
20
|
+
import type { ApitogoConfig } from "../config/config.js";
|
|
21
21
|
import { BuildCheck } from "../lib/components/BuildCheck.js";
|
|
22
22
|
import "./main.css";
|
|
23
23
|
import { Meta } from "../lib/components/Meta.js";
|
|
@@ -39,8 +39,8 @@ export const shikiReady: Promise<HighlighterCore> =
|
|
|
39
39
|
return highlighter;
|
|
40
40
|
});
|
|
41
41
|
|
|
42
|
-
export const
|
|
43
|
-
config:
|
|
42
|
+
export const convertApitogoConfigToOptions = (
|
|
43
|
+
config: ApitogoConfig,
|
|
44
44
|
): ZudokuContextOptions => {
|
|
45
45
|
const siteTitle =
|
|
46
46
|
config.metadata?.applicationName ?? config.site?.title ?? "APIToGo";
|
|
@@ -52,9 +52,7 @@ export const convertZudokuConfigToOptions = (
|
|
|
52
52
|
protectedRoutes: config.protectedRoutes,
|
|
53
53
|
site: {
|
|
54
54
|
...config.site,
|
|
55
|
-
showPoweredBy:
|
|
56
|
-
ZuploEnv.buildConfig?.entitlements.devPortalZuploBranding ??
|
|
57
|
-
config.site?.showPoweredBy,
|
|
55
|
+
showPoweredBy: ZuploEnv.buildConfig?.entitlements.devPortalZuploBranding,
|
|
58
56
|
logo: config.site?.logo,
|
|
59
57
|
},
|
|
60
58
|
slots: config.slots,
|
|
@@ -89,6 +87,11 @@ export const convertZudokuConfigToOptions = (
|
|
|
89
87
|
};
|
|
90
88
|
};
|
|
91
89
|
|
|
90
|
+
/**
|
|
91
|
+
* @deprecated Use {@link convertApitogoConfigToOptions} instead.
|
|
92
|
+
*/
|
|
93
|
+
export const convertZudokuConfigToOptions = convertApitogoConfigToOptions;
|
|
94
|
+
|
|
92
95
|
export const getRoutesByOptions = (
|
|
93
96
|
options: ZudokuContextOptions,
|
|
94
97
|
enableStatusPages = true,
|
|
@@ -119,8 +122,8 @@ export const getRoutesByOptions = (
|
|
|
119
122
|
return routes;
|
|
120
123
|
};
|
|
121
124
|
|
|
122
|
-
export const getRoutesByConfig = (config:
|
|
123
|
-
const options =
|
|
125
|
+
export const getRoutesByConfig = (config: ApitogoConfig): RouteObject[] => {
|
|
126
|
+
const options = convertApitogoConfigToOptions(config);
|
|
124
127
|
const routes = getRoutesByOptions(
|
|
125
128
|
options,
|
|
126
129
|
import.meta.env.IS_ZUPLO || config.enableStatusPages,
|
|
@@ -130,13 +133,13 @@ export const getRoutesByConfig = (config: ZudokuConfig): RouteObject[] => {
|
|
|
130
133
|
...createRedirectRoutes(config.redirects),
|
|
131
134
|
{
|
|
132
135
|
element: (
|
|
133
|
-
<
|
|
136
|
+
<Apitogo {...options} env={import.meta.env}>
|
|
134
137
|
<BuildCheck
|
|
135
138
|
buildId={import.meta.env.ZUPLO_BUILD_ID}
|
|
136
139
|
environmentType={import.meta.env.ZUPLO_ENVIRONMENT_TYPE}
|
|
137
140
|
/>
|
|
138
141
|
<Outlet />
|
|
139
|
-
</
|
|
142
|
+
</Apitogo>
|
|
140
143
|
),
|
|
141
144
|
hydrateFallbackElement: <div>Loading...</div>,
|
|
142
145
|
children: [
|
package/src/config/config.ts
CHANGED
|
@@ -5,7 +5,14 @@ import type {
|
|
|
5
5
|
ZudokuConfig,
|
|
6
6
|
} from "./validators/ZudokuConfig.js";
|
|
7
7
|
|
|
8
|
+
/** Build-time config for APIToGo (`apitogo.build.ts` / legacy `zudoku.build.ts`). */
|
|
9
|
+
export type ApitogoBuildConfig = BuildConfig;
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* @deprecated Use {@link ApitogoBuildConfig} instead.
|
|
13
|
+
*/
|
|
8
14
|
export type ZudokuBuildConfig = BuildConfig;
|
|
15
|
+
|
|
9
16
|
export type LoadedConfig = ConfigWithMeta;
|
|
10
17
|
export type { ZudokuConfig as ApitogoConfig };
|
|
11
18
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
isTransformConfigPlugin,
|
|
3
|
-
type
|
|
3
|
+
type ApitogoPlugin,
|
|
4
4
|
} from "../lib/core/plugins.js";
|
|
5
5
|
|
|
6
6
|
// Regex from stacktrace-parser for Node.js stack traces
|
|
@@ -36,8 +36,8 @@ const getCallerDir = () => {
|
|
|
36
36
|
};
|
|
37
37
|
|
|
38
38
|
export const createPlugin = <TOptions extends unknown[]>(
|
|
39
|
-
factory: (...options: TOptions) =>
|
|
40
|
-
): ((...options: TOptions) =>
|
|
39
|
+
factory: (...options: TOptions) => ApitogoPlugin,
|
|
40
|
+
): ((...options: TOptions) => ApitogoPlugin) => {
|
|
41
41
|
const pluginDir = getCallerDir();
|
|
42
42
|
|
|
43
43
|
return (...options: TOptions) => {
|
|
@@ -34,7 +34,12 @@ export const BuildConfigSchema = z.object({
|
|
|
34
34
|
prerender: z.object({ workers: z.number().optional() }).optional(),
|
|
35
35
|
});
|
|
36
36
|
|
|
37
|
-
const
|
|
37
|
+
const buildConfigFiles = [
|
|
38
|
+
"apitogo.build.js",
|
|
39
|
+
"apitogo.build.jsx",
|
|
40
|
+
"apitogo.build.ts",
|
|
41
|
+
"apitogo.build.tsx",
|
|
42
|
+
"apitogo.build.mjs",
|
|
38
43
|
"zudoku.build.js",
|
|
39
44
|
"zudoku.build.jsx",
|
|
40
45
|
"zudoku.build.ts",
|
|
@@ -43,7 +48,7 @@ const zudokuBuildConfigFiles = [
|
|
|
43
48
|
];
|
|
44
49
|
|
|
45
50
|
async function getBuildConfigFilePath(rootDir: string) {
|
|
46
|
-
for (const fileName of
|
|
51
|
+
for (const fileName of buildConfigFiles) {
|
|
47
52
|
const filepath = path.join(rootDir, fileName);
|
|
48
53
|
if (await fileExists(filepath)) {
|
|
49
54
|
return filepath;
|