@lukoweb/apitogo 0.1.0 → 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.
Files changed (91) hide show
  1. package/dist/cli/cli.js +37 -147
  2. package/dist/declarations/lib/ui/Command.d.ts +1 -1
  3. package/dist/declarations/lib/util/MdxComponents.d.ts +1 -1
  4. package/package.json +1 -1
  5. package/src/app/main.tsx +150 -150
  6. package/src/config/loader.ts +245 -245
  7. package/src/index.ts +33 -33
  8. package/src/lib/authentication/components/CallbackHandler.tsx +45 -45
  9. package/src/lib/authentication/components/SignIn.tsx +46 -46
  10. package/src/lib/authentication/components/SignUp.tsx +48 -48
  11. package/src/lib/authentication/providers/clerk.tsx +224 -224
  12. package/src/lib/authentication/ui/AuthCard.tsx +7 -7
  13. package/src/lib/authentication/ui/EmailLinkCallbackUi.tsx +129 -125
  14. package/src/lib/authentication/ui/EmailLinkSentUi.tsx +105 -101
  15. package/src/lib/authentication/ui/EmailLinkSignInUi.tsx +100 -96
  16. package/src/lib/authentication/ui/EmailVerificationUi.tsx +128 -124
  17. package/src/lib/authentication/ui/ZudokuAuthUi.tsx +620 -616
  18. package/src/lib/components/AiAssistantMenuItems.tsx +102 -102
  19. package/src/lib/components/Autocomplete.tsx +123 -123
  20. package/src/lib/components/DeveloperHint.tsx +39 -35
  21. package/src/lib/components/Header.tsx +260 -260
  22. package/src/lib/components/Layout.tsx +53 -53
  23. package/src/lib/components/Main.tsx +51 -51
  24. package/src/lib/components/Mermaid.tsx +74 -70
  25. package/src/lib/components/MobileTopNavigation.tsx +276 -276
  26. package/src/lib/components/MultiSelect.tsx +86 -82
  27. package/src/lib/components/TopNavigation.tsx +103 -103
  28. package/src/lib/components/index.ts +26 -26
  29. package/src/lib/components/navigation/NavigationCategory.tsx +157 -157
  30. package/src/lib/components/navigation/NavigationFilterInput.tsx +35 -35
  31. package/src/lib/components/navigation/NavigationItem.tsx +181 -177
  32. package/src/lib/core/RouteGuard.tsx +193 -193
  33. package/src/lib/errors/ErrorMessage.tsx +50 -46
  34. package/src/lib/plugins/api-catalog/Catalog.tsx +80 -80
  35. package/src/lib/plugins/api-keys/CreateApiKey.tsx +128 -124
  36. package/src/lib/plugins/api-keys/CreateApiKeyDialog.tsx +49 -49
  37. package/src/lib/plugins/api-keys/SettingsApiKeys.tsx +72 -72
  38. package/src/lib/plugins/api-keys/settings/ApiKeyItem.tsx +342 -342
  39. package/src/lib/plugins/api-keys/settings/RevealApiKey.tsx +127 -127
  40. package/src/lib/plugins/markdown/MdxPage.tsx +285 -285
  41. package/src/lib/plugins/openapi/ApiHeader.tsx +96 -96
  42. package/src/lib/plugins/openapi/CollapsibleCode.tsx +88 -88
  43. package/src/lib/plugins/openapi/DownloadSchemaButton.tsx +94 -94
  44. package/src/lib/plugins/openapi/GeneratedExampleSidecarBox.tsx +52 -52
  45. package/src/lib/plugins/openapi/OperationListItem.tsx +183 -183
  46. package/src/lib/plugins/openapi/RequestBodySidecarBox.tsx +63 -63
  47. package/src/lib/plugins/openapi/ResponsesSidecarBox.tsx +120 -117
  48. package/src/lib/plugins/openapi/SchemaInfo.tsx +344 -344
  49. package/src/lib/plugins/openapi/SchemaList.tsx +113 -113
  50. package/src/lib/plugins/openapi/Sidecar.tsx +312 -309
  51. package/src/lib/plugins/openapi/SidecarExamples.tsx +177 -174
  52. package/src/lib/plugins/openapi/components/EnumValues.tsx +58 -58
  53. package/src/lib/plugins/openapi/components/ResponseContent.tsx +117 -114
  54. package/src/lib/plugins/openapi/playground/BodyPanel.tsx +274 -271
  55. package/src/lib/plugins/openapi/playground/CollapsibleHeader.tsx +51 -51
  56. package/src/lib/plugins/openapi/playground/ExamplesDropdown.tsx +60 -60
  57. package/src/lib/plugins/openapi/playground/Headers.tsx +188 -181
  58. package/src/lib/plugins/openapi/playground/IdentityDialog.tsx +75 -75
  59. package/src/lib/plugins/openapi/playground/IdentitySelector.tsx +38 -38
  60. package/src/lib/plugins/openapi/playground/ParamsGrid.tsx +45 -45
  61. package/src/lib/plugins/openapi/playground/Playground.tsx +602 -599
  62. package/src/lib/plugins/openapi/playground/PlaygroundDialog.tsx +56 -56
  63. package/src/lib/plugins/openapi/playground/QueryParams.tsx +151 -148
  64. package/src/lib/plugins/openapi/playground/RequestLoginDialog.tsx +70 -70
  65. package/src/lib/plugins/openapi/playground/request-panel/MultipartField.tsx +91 -91
  66. package/src/lib/plugins/openapi/playground/result-panel/AudioPlayer.tsx +50 -50
  67. package/src/lib/plugins/openapi/playground/result-panel/ResponseTab.tsx +355 -355
  68. package/src/lib/plugins/openapi/playground/result-panel/ResultPanel.tsx +106 -102
  69. package/src/lib/plugins/openapi/schema/SchemaPropertyItem.tsx +189 -184
  70. package/src/lib/plugins/openapi/schema/SchemaView.tsx +299 -299
  71. package/src/lib/plugins/search-pagefind/IndexingDialog.tsx +162 -162
  72. package/src/lib/plugins/search-pagefind/PagefindSearch.tsx +202 -202
  73. package/src/lib/plugins/search-pagefind/ResultList.tsx +122 -118
  74. package/src/lib/ui/ActionButton.tsx +21 -21
  75. package/src/lib/ui/Command.tsx +191 -191
  76. package/src/lib/util/MdxComponents.tsx +150 -150
  77. package/src/vite/config.ts +234 -231
  78. package/src/vite/dev-server.ts +291 -291
  79. package/src/vite/plugin-api-keys.ts +50 -50
  80. package/src/vite/plugin-api.ts +320 -318
  81. package/src/vite/plugin-auth.ts +38 -38
  82. package/src/vite/plugin-component.ts +45 -39
  83. package/src/vite/plugin-config.ts +75 -75
  84. package/src/vite/plugin-custom-pages.ts +36 -36
  85. package/src/vite/plugin-docs.ts +202 -202
  86. package/src/vite/plugin-markdown-export.ts +214 -214
  87. package/src/vite/plugin-mdx.ts +149 -149
  88. package/src/vite/plugin-navigation.ts +106 -106
  89. package/src/vite/plugin-search.ts +47 -47
  90. package/src/vite/plugin.ts +42 -42
  91. package/src/vite/prerender/prerender.ts +233 -233
@@ -1,245 +1,245 @@
1
- import { stat } from "node:fs/promises";
2
- import path from "node:path";
3
- import colors from "picocolors";
4
- import type { RollupOutput, RollupWatcher } from "rollup";
5
- import {
6
- type ConfigEnv,
7
- runnerImport,
8
- loadEnv as viteLoadEnv,
9
- type Plugin as VitePlugin,
10
- } from "vite";
11
- import { logger } from "../cli/common/logger.js";
12
- import { getZudokuRootDir } from "../cli/common/package-json.js";
13
- import { runPluginTransformConfig } from "../lib/core/transform-config.js";
14
- import invariant from "../lib/util/invariant.js";
15
- import { fileExists } from "./file-exists.js";
16
- import type { ZudokuConfig } from "./validators/ZudokuConfig.js";
17
- import { validateConfig } from "./validators/ZudokuConfig.js";
18
-
19
- export type ConfigWithMeta = ZudokuConfig & {
20
- __meta: {
21
- rootDir: string;
22
- moduleDir: string;
23
- configPath: string;
24
- mode: typeof process.env.ZUDOKU_ENV;
25
- dependencies: string[];
26
- };
27
- };
28
-
29
- let config: ConfigWithMeta | undefined;
30
- let envPrefix: string[] | undefined;
31
- let publicEnv: Record<string, string> | undefined;
32
- let modifiedTimes: Map<string, number> | undefined;
33
-
34
- const zudokuConfigFiles = [
35
- "apitogo.config.js",
36
- "apitogo.config.jsx",
37
- "apitogo.config.ts",
38
- "apitogo.config.tsx",
39
- "apitogo.config.mjs",
40
- "zudoku.config.js",
41
- "zudoku.config.jsx",
42
- "zudoku.config.ts",
43
- "zudoku.config.tsx",
44
- "zudoku.config.mjs",
45
- ];
46
-
47
- const serverConfigOutputFiles = ["apitogo.config.js", "zudoku.config.js"];
48
-
49
- async function getConfigFilePath(rootDir: string) {
50
- for (const fileName of zudokuConfigFiles) {
51
- const filepath = path.join(rootDir, fileName);
52
- if (await fileExists(filepath)) {
53
- return filepath;
54
- }
55
- }
56
- throw new Error(`No APIToGo or Zudoku config file found in project root.`);
57
- }
58
-
59
- // Stub virtual modules so transitive imports don't fail during config loading.
60
- // The real Vite server replaces these with actual values at runtime.
61
- const virtualModuleStubPlugin: VitePlugin = {
62
- name: "zudoku-virtual-module-stubs",
63
- resolveId(id) {
64
- if (id.startsWith("virtual:")) return `\0${id}`;
65
- },
66
- load(id) {
67
- if (id.startsWith("\0virtual:")) return "export default {}";
68
- },
69
- };
70
-
71
- async function loadZudokuConfigWithMeta(
72
- rootDir: string,
73
- ): Promise<ConfigWithMeta> {
74
- const configPath = await getConfigFilePath(rootDir);
75
-
76
- const { module, dependencies } = await runnerImport<{
77
- default: ZudokuConfig;
78
- }>(configPath, {
79
- plugins: [virtualModuleStubPlugin],
80
- environments: {
81
- inline: {
82
- resolve: {
83
- // Prevent Node.js from trying to load apitogo's raw .ts source
84
- // directly, which fails with ERR_UNSUPPORTED_NODE_MODULES_TYPE_STRIPPING
85
- // when --experimental-strip-types is enabled. Uses regex to also
86
- // catch plugins that re-export from apitogo (e.g. @zuplo/zudoku-plugin-*).
87
- noExternal: [/apitogo/],
88
- },
89
- },
90
- },
91
- server: {
92
- // this allows us to 'load' CSS files in the config
93
- // see https://github.com/vitejs/vite/pull/19577
94
- perEnvironmentStartEndDuringDev: true,
95
- },
96
- });
97
-
98
- const config = module.default;
99
-
100
- validateConfig(config, configPath);
101
-
102
- const configWithMetadata: ConfigWithMeta = {
103
- ...config,
104
- __meta: {
105
- rootDir,
106
- moduleDir: getZudokuRootDir(),
107
- mode: process.env.ZUDOKU_ENV,
108
- dependencies,
109
- configPath,
110
- },
111
- };
112
-
113
- return configWithMetadata;
114
- }
115
-
116
- export function findOutputPathOfServerConfig(
117
- output: RollupOutput | RollupOutput[] | RollupWatcher,
118
- ) {
119
- if (Array.isArray(output)) {
120
- throw new Error("Expected a single output, but got an array");
121
- }
122
- if ("output" in output) {
123
- const result = output.output.find(
124
- (o) =>
125
- "isEntry" in o &&
126
- o.isEntry &&
127
- serverConfigOutputFiles.includes(o.fileName),
128
- );
129
- if (result) {
130
- return result.fileName;
131
- }
132
- }
133
- throw new Error("Could not find server config output file");
134
- }
135
-
136
- function loadEnv(configEnv: ConfigEnv, rootDir: string) {
137
- const envPrefix = ["ZUPLO_PUBLIC_", "ZUDOKU_PUBLIC_"];
138
- const localEnv = viteLoadEnv(configEnv.mode, rootDir, envPrefix);
139
-
140
- process.env = { ...localEnv, ...process.env };
141
-
142
- const publicEnv = Object.fromEntries(
143
- Object.entries(process.env)
144
- .filter(([key]) => envPrefix.some((prefix) => key.startsWith(prefix)))
145
- .map(([key, value]) => [key, JSON.stringify(value)]),
146
- );
147
-
148
- return { publicEnv, envPrefix };
149
- }
150
-
151
- async function hasConfigChanged() {
152
- if (!config || !modifiedTimes) return true;
153
-
154
- const files = [config.__meta.configPath, ...config.__meta.dependencies];
155
-
156
- try {
157
- const hasChanged = await Promise.all(
158
- files.map(async (depPath) => {
159
- const depStat = await stat(depPath);
160
- const cachedMtime = modifiedTimes?.get(depPath);
161
- return !cachedMtime || depStat.mtimeMs !== cachedMtime;
162
- }),
163
- ).then((results) => results.some(Boolean));
164
-
165
- return hasChanged;
166
- } catch {
167
- return true;
168
- }
169
- }
170
-
171
- async function updateModifiedTimes() {
172
- if (!config) return;
173
-
174
- const files = [config.__meta.configPath, ...config.__meta.dependencies];
175
-
176
- modifiedTimes = new Map();
177
-
178
- await Promise.all(
179
- files.map(async (depPath) => {
180
- const depStat = await stat(depPath);
181
- modifiedTimes?.set(depPath, depStat.mtimeMs);
182
- }),
183
- );
184
- }
185
-
186
- export const getCurrentConfig = () => {
187
- invariant(config, "Config not loaded");
188
- return config;
189
- };
190
-
191
- export const setCurrentConfig = (newConfig: ConfigWithMeta) => {
192
- config = newConfig;
193
- };
194
-
195
- export async function loadZudokuConfig(
196
- configEnv: ConfigEnv,
197
- rootDir: string,
198
- ): Promise<{
199
- config: ConfigWithMeta;
200
- envPrefix: string[];
201
- publicEnv: Record<string, string>;
202
- }> {
203
- const shouldReload = await hasConfigChanged();
204
-
205
- if (!shouldReload && config && envPrefix && publicEnv) {
206
- return { config, envPrefix, publicEnv };
207
- }
208
-
209
- ({ publicEnv, envPrefix } = loadEnv(configEnv, rootDir));
210
-
211
- try {
212
- const loadedConfig = await loadZudokuConfigWithMeta(rootDir);
213
- config = await runPluginTransformConfig(loadedConfig);
214
-
215
- logger.info(
216
- colors.cyan(`loaded config file `) + colors.dim(config.__meta.configPath),
217
- { timestamp: true },
218
- );
219
-
220
- return { config, envPrefix, publicEnv };
221
- } catch (error) {
222
- const errorMessage = error instanceof Error ? error.message : String(error);
223
-
224
- if (config) {
225
- // return the last valid config if it exists
226
- return { config, envPrefix, publicEnv };
227
- }
228
-
229
- throw new Error(errorMessage, { cause: error });
230
- } finally {
231
- await updateModifiedTimes();
232
- }
233
- }
234
-
235
- export const setStandaloneConfig = (rootDir: string) => {
236
- config = {
237
- __meta: {
238
- rootDir,
239
- moduleDir: getZudokuRootDir(),
240
- mode: "standalone",
241
- dependencies: [],
242
- configPath: "",
243
- },
244
- };
245
- };
1
+ import { stat } from "node:fs/promises";
2
+ import path from "node:path";
3
+ import colors from "picocolors";
4
+ import type { RollupOutput, RollupWatcher } from "rollup";
5
+ import {
6
+ type ConfigEnv,
7
+ runnerImport,
8
+ loadEnv as viteLoadEnv,
9
+ type Plugin as VitePlugin,
10
+ } from "vite";
11
+ import { logger } from "../cli/common/logger.js";
12
+ import { getZudokuRootDir } from "../cli/common/package-json.js";
13
+ import { runPluginTransformConfig } from "../lib/core/transform-config.js";
14
+ import invariant from "../lib/util/invariant.js";
15
+ import { fileExists } from "./file-exists.js";
16
+ import type { ZudokuConfig } from "./validators/ZudokuConfig.js";
17
+ import { validateConfig } from "./validators/ZudokuConfig.js";
18
+
19
+ export type ConfigWithMeta = ZudokuConfig & {
20
+ __meta: {
21
+ rootDir: string;
22
+ moduleDir: string;
23
+ configPath: string;
24
+ mode: typeof process.env.ZUDOKU_ENV;
25
+ dependencies: string[];
26
+ };
27
+ };
28
+
29
+ let config: ConfigWithMeta | undefined;
30
+ let envPrefix: string[] | undefined;
31
+ let publicEnv: Record<string, string> | undefined;
32
+ let modifiedTimes: Map<string, number> | undefined;
33
+
34
+ const zudokuConfigFiles = [
35
+ "apitogo.config.js",
36
+ "apitogo.config.jsx",
37
+ "apitogo.config.ts",
38
+ "apitogo.config.tsx",
39
+ "apitogo.config.mjs",
40
+ "zudoku.config.js",
41
+ "zudoku.config.jsx",
42
+ "zudoku.config.ts",
43
+ "zudoku.config.tsx",
44
+ "zudoku.config.mjs",
45
+ ];
46
+
47
+ const serverConfigOutputFiles = ["apitogo.config.js", "zudoku.config.js"];
48
+
49
+ async function getConfigFilePath(rootDir: string) {
50
+ for (const fileName of zudokuConfigFiles) {
51
+ const filepath = path.join(rootDir, fileName);
52
+ if (await fileExists(filepath)) {
53
+ return filepath;
54
+ }
55
+ }
56
+ throw new Error(`No APIToGo or Zudoku config file found in project root.`);
57
+ }
58
+
59
+ // Stub virtual modules so transitive imports don't fail during config loading.
60
+ // The real Vite server replaces these with actual values at runtime.
61
+ const virtualModuleStubPlugin: VitePlugin = {
62
+ name: "zudoku-virtual-module-stubs",
63
+ resolveId(id) {
64
+ if (id.startsWith("virtual:")) return `\0${id}`;
65
+ },
66
+ load(id) {
67
+ if (id.startsWith("\0virtual:")) return "export default {}";
68
+ },
69
+ };
70
+
71
+ async function loadZudokuConfigWithMeta(
72
+ rootDir: string,
73
+ ): Promise<ConfigWithMeta> {
74
+ const configPath = await getConfigFilePath(rootDir);
75
+
76
+ const { module, dependencies } = await runnerImport<{
77
+ default: ZudokuConfig;
78
+ }>(configPath, {
79
+ plugins: [virtualModuleStubPlugin],
80
+ environments: {
81
+ inline: {
82
+ resolve: {
83
+ // Prevent Node.js from trying to load apitogo's raw .ts source
84
+ // directly, which fails with ERR_UNSUPPORTED_NODE_MODULES_TYPE_STRIPPING
85
+ // when --experimental-strip-types is enabled. Uses regex to also
86
+ // catch plugins that re-export from apitogo (e.g. @zuplo/zudoku-plugin-*).
87
+ noExternal: [/apitogo/],
88
+ },
89
+ },
90
+ },
91
+ server: {
92
+ // this allows us to 'load' CSS files in the config
93
+ // see https://github.com/vitejs/vite/pull/19577
94
+ perEnvironmentStartEndDuringDev: true,
95
+ },
96
+ });
97
+
98
+ const config = module.default;
99
+
100
+ validateConfig(config, configPath);
101
+
102
+ const configWithMetadata: ConfigWithMeta = {
103
+ ...config,
104
+ __meta: {
105
+ rootDir,
106
+ moduleDir: getZudokuRootDir(),
107
+ mode: process.env.ZUDOKU_ENV,
108
+ dependencies,
109
+ configPath,
110
+ },
111
+ };
112
+
113
+ return configWithMetadata;
114
+ }
115
+
116
+ export function findOutputPathOfServerConfig(
117
+ output: RollupOutput | RollupOutput[] | RollupWatcher,
118
+ ) {
119
+ if (Array.isArray(output)) {
120
+ throw new Error("Expected a single output, but got an array");
121
+ }
122
+ if ("output" in output) {
123
+ const result = output.output.find(
124
+ (o) =>
125
+ "isEntry" in o &&
126
+ o.isEntry &&
127
+ serverConfigOutputFiles.includes(o.fileName),
128
+ );
129
+ if (result) {
130
+ return result.fileName;
131
+ }
132
+ }
133
+ throw new Error("Could not find server config output file");
134
+ }
135
+
136
+ function loadEnv(configEnv: ConfigEnv, rootDir: string) {
137
+ const envPrefix = ["ZUPLO_PUBLIC_", "ZUDOKU_PUBLIC_"];
138
+ const localEnv = viteLoadEnv(configEnv.mode, rootDir, envPrefix);
139
+
140
+ process.env = { ...localEnv, ...process.env };
141
+
142
+ const publicEnv = Object.fromEntries(
143
+ Object.entries(process.env)
144
+ .filter(([key]) => envPrefix.some((prefix) => key.startsWith(prefix)))
145
+ .map(([key, value]) => [key, JSON.stringify(value)]),
146
+ );
147
+
148
+ return { publicEnv, envPrefix };
149
+ }
150
+
151
+ async function hasConfigChanged() {
152
+ if (!config || !modifiedTimes) return true;
153
+
154
+ const files = [config.__meta.configPath, ...config.__meta.dependencies];
155
+
156
+ try {
157
+ const hasChanged = await Promise.all(
158
+ files.map(async (depPath) => {
159
+ const depStat = await stat(depPath);
160
+ const cachedMtime = modifiedTimes?.get(depPath);
161
+ return !cachedMtime || depStat.mtimeMs !== cachedMtime;
162
+ }),
163
+ ).then((results) => results.some(Boolean));
164
+
165
+ return hasChanged;
166
+ } catch {
167
+ return true;
168
+ }
169
+ }
170
+
171
+ async function updateModifiedTimes() {
172
+ if (!config) return;
173
+
174
+ const files = [config.__meta.configPath, ...config.__meta.dependencies];
175
+
176
+ modifiedTimes = new Map();
177
+
178
+ await Promise.all(
179
+ files.map(async (depPath) => {
180
+ const depStat = await stat(depPath);
181
+ modifiedTimes?.set(depPath, depStat.mtimeMs);
182
+ }),
183
+ );
184
+ }
185
+
186
+ export const getCurrentConfig = () => {
187
+ invariant(config, "Config not loaded");
188
+ return config;
189
+ };
190
+
191
+ export const setCurrentConfig = (newConfig: ConfigWithMeta) => {
192
+ config = newConfig;
193
+ };
194
+
195
+ export async function loadZudokuConfig(
196
+ configEnv: ConfigEnv,
197
+ rootDir: string,
198
+ ): Promise<{
199
+ config: ConfigWithMeta;
200
+ envPrefix: string[];
201
+ publicEnv: Record<string, string>;
202
+ }> {
203
+ const shouldReload = await hasConfigChanged();
204
+
205
+ if (!shouldReload && config && envPrefix && publicEnv) {
206
+ return { config, envPrefix, publicEnv };
207
+ }
208
+
209
+ ({ publicEnv, envPrefix } = loadEnv(configEnv, rootDir));
210
+
211
+ try {
212
+ const loadedConfig = await loadZudokuConfigWithMeta(rootDir);
213
+ config = await runPluginTransformConfig(loadedConfig);
214
+
215
+ logger.info(
216
+ colors.cyan(`loaded config file `) + colors.dim(config.__meta.configPath),
217
+ { timestamp: true },
218
+ );
219
+
220
+ return { config, envPrefix, publicEnv };
221
+ } catch (error) {
222
+ const errorMessage = error instanceof Error ? error.message : String(error);
223
+
224
+ if (config) {
225
+ // return the last valid config if it exists
226
+ return { config, envPrefix, publicEnv };
227
+ }
228
+
229
+ throw new Error(errorMessage, { cause: error });
230
+ } finally {
231
+ await updateModifiedTimes();
232
+ }
233
+ }
234
+
235
+ export const setStandaloneConfig = (rootDir: string) => {
236
+ config = {
237
+ __meta: {
238
+ rootDir,
239
+ moduleDir: getZudokuRootDir(),
240
+ mode: "standalone",
241
+ dependencies: [],
242
+ configPath: "",
243
+ },
244
+ };
245
+ };
package/src/index.ts CHANGED
@@ -1,33 +1,33 @@
1
- export type { ZudokuBuildConfig, ZudokuConfig } from "./config/config.js";
2
- export { createPlugin } from "./config/create-plugin.js";
3
- export type { InputNavigation as Navigation } from "./config/validators/InputNavigationSchema.js";
4
- export type { SlotType } from "./lib/components/context/SlotProvider.js";
5
- export {
6
- type CustomSlotNames,
7
- Slot,
8
- type SlotName,
9
- } from "./lib/components/Slot.js";
10
- export type {
11
- ApiIdentityPlugin,
12
- AuthenticationPlugin,
13
- CommonPlugin,
14
- NavigationPlugin,
15
- ProfileMenuPlugin,
16
- ProfileNavigationItem,
17
- RouteObject,
18
- SearchProviderPlugin,
19
- TransformConfigContext,
20
- ZudokuPlugin,
21
- } from "./lib/core/plugins.js";
22
- export { type ApiIdentity, ZudokuContext } from "./lib/core/ZudokuContext.js";
23
- /** @deprecated Import from `apitogo/hooks` instead */
24
- export { useEvent } from "./lib/hooks/index.js";
25
- export type { MDXImport } from "./lib/plugins/markdown/index.js";
26
- export { defaultLanguages } from "./lib/shiki.js";
27
- export { cn } from "./lib/ui/util.js";
28
- export { joinUrl } from "./lib/util/joinUrl.js";
29
- export {
30
- type ProblemJson,
31
- throwIfProblemJson,
32
- } from "./lib/util/problemJson.js";
33
- export type { MdxComponentsType } from "./lib/util/MdxComponents.js";
1
+ export type { ZudokuBuildConfig, ZudokuConfig } from "./config/config.js";
2
+ export { createPlugin } from "./config/create-plugin.js";
3
+ export type { InputNavigation as Navigation } from "./config/validators/InputNavigationSchema.js";
4
+ export type { SlotType } from "./lib/components/context/SlotProvider.js";
5
+ export {
6
+ type CustomSlotNames,
7
+ Slot,
8
+ type SlotName,
9
+ } from "./lib/components/Slot.js";
10
+ export type {
11
+ ApiIdentityPlugin,
12
+ AuthenticationPlugin,
13
+ CommonPlugin,
14
+ NavigationPlugin,
15
+ ProfileMenuPlugin,
16
+ ProfileNavigationItem,
17
+ RouteObject,
18
+ SearchProviderPlugin,
19
+ TransformConfigContext,
20
+ ZudokuPlugin,
21
+ } from "./lib/core/plugins.js";
22
+ export { type ApiIdentity, ZudokuContext } from "./lib/core/ZudokuContext.js";
23
+ /** @deprecated Import from `apitogo/hooks` instead */
24
+ export { useEvent } from "./lib/hooks/index.js";
25
+ export type { MDXImport } from "./lib/plugins/markdown/index.js";
26
+ export { defaultLanguages } from "./lib/shiki.js";
27
+ export { cn } from "./lib/ui/util.js";
28
+ export { joinUrl } from "./lib/util/joinUrl.js";
29
+ export {
30
+ type ProblemJson,
31
+ throwIfProblemJson,
32
+ } from "./lib/util/problemJson.js";
33
+ export type { MdxComponentsType } from "./lib/util/MdxComponents.js";
@@ -1,45 +1,45 @@
1
- import { useSuspenseQuery } from "@tanstack/react-query";
2
- import { Navigate } from "react-router";
3
- import { useZudoku } from "@lukoweb/apitogo/components";
4
- import { joinUrl } from "../../util/joinUrl.js";
5
- import { normalizeRedirectUrl } from "../../util/url.js";
6
- import { OAuthAuthorizationError, type OAuthErrorType } from "../errors.js";
7
-
8
- export function CallbackHandler({
9
- handleCallback,
10
- }: {
11
- handleCallback: () => Promise<string>;
12
- }) {
13
- const { options } = useZudoku();
14
- const executeCallback = useSuspenseQuery({
15
- retry: false,
16
- queryKey: ["oauth-callback", window.location.search],
17
- queryFn: async () => {
18
- const url = new URL(window.location.href);
19
-
20
- const errorParam = url.searchParams.get("error");
21
- const errorDescription =
22
- url.searchParams.get("error_description") ?? undefined;
23
- const errorUri = url.searchParams.get("error_uri") ?? undefined;
24
- if (errorParam) {
25
- throw new OAuthAuthorizationError(
26
- `OAuth error '${errorParam}': ${errorDescription}`,
27
- {
28
- error: errorParam as OAuthErrorType,
29
- error_description: errorDescription,
30
- error_uri: errorUri,
31
- },
32
- );
33
- }
34
- return joinUrl(
35
- normalizeRedirectUrl(
36
- await handleCallback(),
37
- window.location.origin,
38
- options.basePath,
39
- ),
40
- );
41
- },
42
- });
43
-
44
- return <Navigate to={executeCallback.data} replace />;
45
- }
1
+ import { useZudoku } from "@lukoweb/apitogo/components";
2
+ import { useSuspenseQuery } from "@tanstack/react-query";
3
+ import { Navigate } from "react-router";
4
+ import { joinUrl } from "../../util/joinUrl.js";
5
+ import { normalizeRedirectUrl } from "../../util/url.js";
6
+ import { OAuthAuthorizationError, type OAuthErrorType } from "../errors.js";
7
+
8
+ export function CallbackHandler({
9
+ handleCallback,
10
+ }: {
11
+ handleCallback: () => Promise<string>;
12
+ }) {
13
+ const { options } = useZudoku();
14
+ const executeCallback = useSuspenseQuery({
15
+ retry: false,
16
+ queryKey: ["oauth-callback", window.location.search],
17
+ queryFn: async () => {
18
+ const url = new URL(window.location.href);
19
+
20
+ const errorParam = url.searchParams.get("error");
21
+ const errorDescription =
22
+ url.searchParams.get("error_description") ?? undefined;
23
+ const errorUri = url.searchParams.get("error_uri") ?? undefined;
24
+ if (errorParam) {
25
+ throw new OAuthAuthorizationError(
26
+ `OAuth error '${errorParam}': ${errorDescription}`,
27
+ {
28
+ error: errorParam as OAuthErrorType,
29
+ error_description: errorDescription,
30
+ error_uri: errorUri,
31
+ },
32
+ );
33
+ }
34
+ return joinUrl(
35
+ normalizeRedirectUrl(
36
+ await handleCallback(),
37
+ window.location.origin,
38
+ options.basePath,
39
+ ),
40
+ );
41
+ },
42
+ });
43
+
44
+ return <Navigate to={executeCallback.data} replace />;
45
+ }