@lukoweb/apitogo 0.1.1 → 0.1.3

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 +168 -57
  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 +2 -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,38 +1,38 @@
1
- import type { Plugin } from "vite";
2
- import { getCurrentConfig } from "../config/loader.js";
3
-
4
- const viteAuthPlugin = (): Plugin => {
5
- const virtualModuleId = "virtual:zudoku-auth";
6
- const resolvedVirtualModuleId = `\0${virtualModuleId}`;
7
-
8
- return {
9
- name: "zudoku-auth-plugin", // required, will show up in warnings and errors
10
- resolveId(id) {
11
- if (id === virtualModuleId) {
12
- return resolvedVirtualModuleId;
13
- }
14
- },
15
- async load(id) {
16
- if (id === resolvedVirtualModuleId) {
17
- const config = getCurrentConfig();
18
-
19
- if (!config.authentication || config.__meta.mode === "standalone") {
20
- return `export const configuredAuthProvider = undefined;`;
21
- }
22
- // TODO: Validate that the authConfig.type is a valid authentication provider
23
- return [
24
- `const config = {
25
- ...${JSON.stringify(config.authentication, null, 2)},
26
- basePath: ${config.basePath ? JSON.stringify(config.basePath) : "undefined"},
27
- };`,
28
- config.__meta.mode === "internal"
29
- ? `import authProvider from "${config.__meta.moduleDir}/src/lib/authentication/providers/${config.authentication.type}.tsx";`
30
- : `import authProvider from "@lukoweb/apitogo/auth/${config.authentication.type}";`,
31
- `export const configuredAuthProvider = authProvider(config);`,
32
- ].join("\n");
33
- }
34
- },
35
- };
36
- };
37
-
38
- export default viteAuthPlugin;
1
+ import type { Plugin } from "vite";
2
+ import { getCurrentConfig } from "../config/loader.js";
3
+
4
+ const viteAuthPlugin = (): Plugin => {
5
+ const virtualModuleId = "virtual:zudoku-auth";
6
+ const resolvedVirtualModuleId = `\0${virtualModuleId}`;
7
+
8
+ return {
9
+ name: "zudoku-auth-plugin", // required, will show up in warnings and errors
10
+ resolveId(id) {
11
+ if (id === virtualModuleId) {
12
+ return resolvedVirtualModuleId;
13
+ }
14
+ },
15
+ async load(id) {
16
+ if (id === resolvedVirtualModuleId) {
17
+ const config = getCurrentConfig();
18
+
19
+ if (!config.authentication || config.__meta.mode === "standalone") {
20
+ return `export const configuredAuthProvider = undefined;`;
21
+ }
22
+ // TODO: Validate that the authConfig.type is a valid authentication provider
23
+ return [
24
+ `const config = {
25
+ ...${JSON.stringify(config.authentication, null, 2)},
26
+ basePath: ${config.basePath ? JSON.stringify(config.basePath) : "undefined"},
27
+ };`,
28
+ config.__meta.mode === "internal"
29
+ ? `import authProvider from "${config.__meta.moduleDir}/src/lib/authentication/providers/${config.authentication.type}.tsx";`
30
+ : `import authProvider from "@lukoweb/apitogo/auth/${config.authentication.type}";`,
31
+ `export const configuredAuthProvider = authProvider(config);`,
32
+ ].join("\n");
33
+ }
34
+ },
35
+ };
36
+ };
37
+
38
+ export default viteAuthPlugin;
@@ -1,39 +1,45 @@
1
- import path from "node:path";
2
- import type { Plugin } from "vite";
3
- import { getCurrentConfig } from "../config/loader.js";
4
-
5
- const viteAliasPlugin = (): Plugin => {
6
- return {
7
- name: "zudoku-component-plugin",
8
- config: () => {
9
- const config = getCurrentConfig();
10
-
11
- const replacements = [
12
- ["@lukoweb/apitogo/components", "src/lib/components/index.ts"],
13
- ["@lukoweb/apitogo/plugins/openapi", "src/lib/plugins/openapi/index.tsx"],
14
- ["@lukoweb/apitogo/plugins/api-catalog", "src/lib/plugins/api-catalog/index.tsx"],
15
- [
16
- "@lukoweb/apitogo/plugins/search-inkeep",
17
- "src/lib/plugins/search-inkeep/index.tsx",
18
- ],
19
- [
20
- "@lukoweb/apitogo/plugins/search-pagefind",
21
- "src/lib/plugins/search-pagefind/index.tsx",
22
- ],
23
- [/^@lukoweb\/apitogo\/ui\/(.*)\.js/, "src/lib/ui/$1.tsx"],
24
- ] as const;
25
-
26
- const aliases = replacements.map(([find, replacement]) => ({
27
- find,
28
- replacement: path.posix.join(config.__meta.moduleDir, replacement),
29
- }));
30
-
31
- return config.__meta.mode === "internal" ||
32
- config.__meta.mode === "standalone"
33
- ? { resolve: { alias: aliases } }
34
- : undefined;
35
- },
36
- };
37
- };
38
-
39
- export default viteAliasPlugin;
1
+ import path from "node:path";
2
+ import type { Plugin } from "vite";
3
+ import { getCurrentConfig } from "../config/loader.js";
4
+
5
+ const viteAliasPlugin = (): Plugin => {
6
+ return {
7
+ name: "zudoku-component-plugin",
8
+ config: () => {
9
+ const config = getCurrentConfig();
10
+
11
+ const replacements = [
12
+ ["@lukoweb/apitogo/components", "src/lib/components/index.ts"],
13
+ [
14
+ "@lukoweb/apitogo/plugins/openapi",
15
+ "src/lib/plugins/openapi/index.tsx",
16
+ ],
17
+ [
18
+ "@lukoweb/apitogo/plugins/api-catalog",
19
+ "src/lib/plugins/api-catalog/index.tsx",
20
+ ],
21
+ [
22
+ "@lukoweb/apitogo/plugins/search-inkeep",
23
+ "src/lib/plugins/search-inkeep/index.tsx",
24
+ ],
25
+ [
26
+ "@lukoweb/apitogo/plugins/search-pagefind",
27
+ "src/lib/plugins/search-pagefind/index.tsx",
28
+ ],
29
+ [/^@lukoweb\/apitogo\/ui\/(.*)\.js/, "src/lib/ui/$1.tsx"],
30
+ ] as const;
31
+
32
+ const aliases = replacements.map(([find, replacement]) => ({
33
+ find,
34
+ replacement: path.posix.join(config.__meta.moduleDir, replacement),
35
+ }));
36
+
37
+ return config.__meta.mode === "internal" ||
38
+ config.__meta.mode === "standalone"
39
+ ? { resolve: { alias: aliases } }
40
+ : undefined;
41
+ },
42
+ };
43
+ };
44
+
45
+ export default viteAliasPlugin;
@@ -1,75 +1,75 @@
1
- import { normalizePath, type Plugin, type ResolvedConfig } from "vite";
2
- import { getCurrentConfig } from "../config/loader.js";
3
-
4
- const virtualModuleId = "virtual:zudoku-config";
5
- const resolvedVirtualModuleId = `\0${virtualModuleId}`;
6
-
7
- const viteConfigPlugin = (): Plugin => {
8
- let viteConfig: ResolvedConfig;
9
-
10
- return {
11
- name: "zudoku-config-plugin",
12
- resolveId(id) {
13
- if (id !== virtualModuleId) return;
14
-
15
- return resolvedVirtualModuleId;
16
- },
17
- configResolved(resolvedConfig) {
18
- viteConfig = resolvedConfig;
19
- },
20
- load(id) {
21
- if (id !== resolvedVirtualModuleId) return;
22
-
23
- const configPath = getCurrentConfig().__meta.configPath;
24
- if (!configPath) {
25
- return `export default {};`;
26
- }
27
-
28
- return `
29
- import rawConfig from "${normalizePath(configPath)}";
30
- import { runPluginTransformConfig } from "@lukoweb/apitogo/plugins";
31
-
32
- const config = await runPluginTransformConfig(rawConfig);
33
- export default config;
34
- `;
35
- },
36
- async transform(code, id) {
37
- if (id !== getCurrentConfig().__meta.configPath) return;
38
-
39
- const replacedCode = code.replaceAll(
40
- /process\.env\.([a-z_][a-z0-9_]*)/gi,
41
- (_, envVar) => {
42
- const allowedPrefixes = Array.isArray(viteConfig.envPrefix)
43
- ? viteConfig.envPrefix
44
- : [viteConfig.envPrefix];
45
-
46
- if (!allowedPrefixes.some((prefix) => envVar.startsWith(prefix))) {
47
- viteConfig.logger.warn(
48
- `Warning: process.env.${envVar} is not prefixed with ${allowedPrefixes.join(
49
- " or ",
50
- )}.`,
51
- );
52
- return "undefined";
53
- }
54
-
55
- const value =
56
- viteConfig.define?.[`process.env.${envVar}`] ??
57
- viteConfig.define?.[`import.meta.env.${envVar}`];
58
-
59
- if (value === undefined) {
60
- viteConfig.logger.warn(
61
- `Warning: process.env.${envVar} is not defined.`,
62
- );
63
- return "undefined";
64
- }
65
-
66
- return value;
67
- },
68
- );
69
-
70
- return { code: replacedCode, map: null };
71
- },
72
- };
73
- };
74
-
75
- export default viteConfigPlugin;
1
+ import { normalizePath, type Plugin, type ResolvedConfig } from "vite";
2
+ import { getCurrentConfig } from "../config/loader.js";
3
+
4
+ const virtualModuleId = "virtual:zudoku-config";
5
+ const resolvedVirtualModuleId = `\0${virtualModuleId}`;
6
+
7
+ const viteConfigPlugin = (): Plugin => {
8
+ let viteConfig: ResolvedConfig;
9
+
10
+ return {
11
+ name: "zudoku-config-plugin",
12
+ resolveId(id) {
13
+ if (id !== virtualModuleId) return;
14
+
15
+ return resolvedVirtualModuleId;
16
+ },
17
+ configResolved(resolvedConfig) {
18
+ viteConfig = resolvedConfig;
19
+ },
20
+ load(id) {
21
+ if (id !== resolvedVirtualModuleId) return;
22
+
23
+ const configPath = getCurrentConfig().__meta.configPath;
24
+ if (!configPath) {
25
+ return `export default {};`;
26
+ }
27
+
28
+ return `
29
+ import rawConfig from "${normalizePath(configPath)}";
30
+ import { runPluginTransformConfig } from "@lukoweb/apitogo/plugins";
31
+
32
+ const config = await runPluginTransformConfig(rawConfig);
33
+ export default config;
34
+ `;
35
+ },
36
+ async transform(code, id) {
37
+ if (id !== getCurrentConfig().__meta.configPath) return;
38
+
39
+ const replacedCode = code.replaceAll(
40
+ /process\.env\.([a-z_][a-z0-9_]*)/gi,
41
+ (_, envVar) => {
42
+ const allowedPrefixes = Array.isArray(viteConfig.envPrefix)
43
+ ? viteConfig.envPrefix
44
+ : [viteConfig.envPrefix];
45
+
46
+ if (!allowedPrefixes.some((prefix) => envVar.startsWith(prefix))) {
47
+ viteConfig.logger.warn(
48
+ `Warning: process.env.${envVar} is not prefixed with ${allowedPrefixes.join(
49
+ " or ",
50
+ )}.`,
51
+ );
52
+ return "undefined";
53
+ }
54
+
55
+ const value =
56
+ viteConfig.define?.[`process.env.${envVar}`] ??
57
+ viteConfig.define?.[`import.meta.env.${envVar}`];
58
+
59
+ if (value === undefined) {
60
+ viteConfig.logger.warn(
61
+ `Warning: process.env.${envVar} is not defined.`,
62
+ );
63
+ return "undefined";
64
+ }
65
+
66
+ return value;
67
+ },
68
+ );
69
+
70
+ return { code: replacedCode, map: null };
71
+ },
72
+ };
73
+ };
74
+
75
+ export default viteConfigPlugin;
@@ -1,36 +1,36 @@
1
- import type { Plugin } from "vite";
2
- import { getCurrentConfig } from "../config/loader.js";
3
-
4
- const viteCustomPagesPlugin = (): Plugin => {
5
- const virtualModuleId = "virtual:zudoku-custom-pages-plugin";
6
- const resolvedVirtualModuleId = `\0${virtualModuleId}`;
7
- return {
8
- name: "zudoku-custom-pages-plugin",
9
- resolveId(id) {
10
- if (id === virtualModuleId) {
11
- return resolvedVirtualModuleId;
12
- }
13
- },
14
- async load(id) {
15
- if (id === resolvedVirtualModuleId) {
16
- const config = getCurrentConfig();
17
-
18
- if (config.__meta.mode === "standalone" || !config.navigation) {
19
- return `export const configuredCustomPagesPlugin = undefined;`;
20
- }
21
-
22
- const code = [
23
- `import config from "virtual:zudoku-config";`,
24
- config.__meta.mode === "internal"
25
- ? `import { customPagesPlugin } from "${config.__meta.moduleDir}/src/lib/plugins/custom-pages/index.tsx";`
26
- : `import { customPagesPlugin } from "@lukoweb/apitogo/plugins/custom-pages";`,
27
- `export const configuredCustomPagesPlugin = customPagesPlugin(config.navigation);`,
28
- ];
29
-
30
- return code.join("\n");
31
- }
32
- },
33
- };
34
- };
35
-
36
- export default viteCustomPagesPlugin;
1
+ import type { Plugin } from "vite";
2
+ import { getCurrentConfig } from "../config/loader.js";
3
+
4
+ const viteCustomPagesPlugin = (): Plugin => {
5
+ const virtualModuleId = "virtual:zudoku-custom-pages-plugin";
6
+ const resolvedVirtualModuleId = `\0${virtualModuleId}`;
7
+ return {
8
+ name: "zudoku-custom-pages-plugin",
9
+ resolveId(id) {
10
+ if (id === virtualModuleId) {
11
+ return resolvedVirtualModuleId;
12
+ }
13
+ },
14
+ async load(id) {
15
+ if (id === resolvedVirtualModuleId) {
16
+ const config = getCurrentConfig();
17
+
18
+ if (config.__meta.mode === "standalone" || !config.navigation) {
19
+ return `export const configuredCustomPagesPlugin = undefined;`;
20
+ }
21
+
22
+ const code = [
23
+ `import config from "virtual:zudoku-config";`,
24
+ config.__meta.mode === "internal"
25
+ ? `import { customPagesPlugin } from "${config.__meta.moduleDir}/src/lib/plugins/custom-pages/index.tsx";`
26
+ : `import { customPagesPlugin } from "@lukoweb/apitogo/plugins/custom-pages";`,
27
+ `export const configuredCustomPagesPlugin = customPagesPlugin(config.navigation);`,
28
+ ];
29
+
30
+ return code.join("\n");
31
+ }
32
+ },
33
+ };
34
+ };
35
+
36
+ export default viteCustomPagesPlugin;