zudoku 0.1.1-dev.48 → 0.1.1-dev.49

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 (106) hide show
  1. package/dist/app/App.js +5 -5
  2. package/dist/app/App.js.map +1 -1
  3. package/dist/app/main.js +8 -0
  4. package/dist/app/main.js.map +1 -1
  5. package/dist/cli/common/analytics/lib.js +1 -1
  6. package/dist/cli/common/analytics/lib.js.map +1 -1
  7. package/dist/cli/common/logger.js +1 -1
  8. package/dist/lib/authentication/clerk.js +0 -1
  9. package/dist/lib/authentication/clerk.js.map +1 -1
  10. package/dist/lib/authentication/openid.js +3 -2
  11. package/dist/lib/authentication/openid.js.map +1 -1
  12. package/dist/lib/components/Header.d.ts +1 -1
  13. package/dist/lib/components/Header.js +1 -1
  14. package/dist/lib/components/Header.js.map +1 -1
  15. package/dist/lib/components/context/ComponentsContext.d.ts +1 -1
  16. package/dist/lib/components/navigation/SideNavigationWrapper.js +3 -1
  17. package/dist/lib/components/navigation/SideNavigationWrapper.js.map +1 -1
  18. package/dist/lib/oas/graphql/index.js +1 -1
  19. package/dist/lib/oas/graphql/index.js.map +1 -1
  20. package/dist/lib/plugins/api-key/SettingsApiKeys.js +1 -1
  21. package/dist/lib/plugins/api-key/SettingsApiKeys.js.map +1 -1
  22. package/dist/lib/plugins/api-key/index.d.ts +2 -2
  23. package/dist/lib/plugins/api-key/index.js +1 -1
  24. package/dist/lib/plugins/api-key/index.js.map +1 -1
  25. package/dist/lib/plugins/markdown/MdxPage.js +7 -7
  26. package/dist/lib/plugins/markdown/MdxPage.js.map +1 -1
  27. package/dist/lib/plugins/openapi/ColorizedParam.js +1 -1
  28. package/dist/lib/plugins/openapi/MakeRequest.js +3 -3
  29. package/dist/lib/plugins/openapi/MakeRequest.js.map +1 -1
  30. package/dist/lib/plugins/openapi/OperationList.js +1 -1
  31. package/dist/lib/plugins/openapi/OperationList.js.map +1 -1
  32. package/dist/lib/plugins/openapi/OperationListItem.js +2 -2
  33. package/dist/lib/plugins/openapi/OperationListItem.js.map +1 -1
  34. package/dist/lib/plugins/openapi/ResponsesSidecarBox.js +1 -1
  35. package/dist/lib/plugins/openapi/ResponsesSidecarBox.js.map +1 -1
  36. package/dist/lib/plugins/openapi/SchemaListView.js +4 -4
  37. package/dist/lib/plugins/openapi/SchemaListView.js.map +1 -1
  38. package/dist/lib/plugins/openapi/Sidecar.js +2 -2
  39. package/dist/lib/plugins/openapi/Sidecar.js.map +1 -1
  40. package/dist/lib/plugins/openapi/playground/PathParams.js +4 -4
  41. package/dist/lib/plugins/openapi/playground/PathParams.js.map +1 -1
  42. package/dist/lib/plugins/openapi/playground/Playground.js +16 -18
  43. package/dist/lib/plugins/openapi/playground/Playground.js.map +1 -1
  44. package/dist/lib/plugins/openapi/playground/QueryParams.js +4 -3
  45. package/dist/lib/plugins/openapi/playground/QueryParams.js.map +1 -1
  46. package/dist/lib/plugins/openapi/util/generateSchemaExample.js +0 -1
  47. package/dist/lib/plugins/openapi/util/generateSchemaExample.js.map +1 -1
  48. package/dist/lib/plugins/openapi/worker/createSharedWorkerClient.js +1 -0
  49. package/dist/lib/plugins/openapi/worker/createSharedWorkerClient.js.map +1 -1
  50. package/dist/lib/ui/Button.d.ts +3 -7
  51. package/dist/lib/ui/Button.js +3 -26
  52. package/dist/lib/ui/Button.js.map +1 -1
  53. package/dist/lib/ui/button-variants.d.ts +4 -0
  54. package/dist/lib/ui/button-variants.js +24 -0
  55. package/dist/lib/ui/button-variants.js.map +1 -0
  56. package/dist/lib/util/MdxComponents.js +7 -7
  57. package/dist/lib/util/MdxComponents.js.map +1 -1
  58. package/dist/ts.js +1 -2
  59. package/dist/ts.js.map +1 -1
  60. package/dist/vite/config.js +1 -1
  61. package/dist/vite/dev-server.js +5 -4
  62. package/dist/vite/dev-server.js.map +1 -1
  63. package/dist/vite/plugin-api.js +1 -1
  64. package/dist/vite/plugin-api.js.map +1 -1
  65. package/dist/vite/plugin-component.js +1 -1
  66. package/dist/vite/plugin-component.js.map +1 -1
  67. package/dist/vite/plugin-docs.js +1 -1
  68. package/dist/vite/plugin-docs.js.map +1 -1
  69. package/dist/vite/plugin-docs.test.js +1 -1
  70. package/dist/vite/plugin-docs.test.js.map +1 -1
  71. package/lib/{Spinner-DEkC7JSn.js → Spinner-DoNe5ql0.js} +18 -18
  72. package/lib/assets/{worker-BGlCY74N.js → worker-BCcpCNJ7.js} +1 -1
  73. package/lib/zudoku.auth-clerk.js +1 -1
  74. package/lib/zudoku.components.js +260 -258
  75. package/lib/zudoku.openapi-worker.js +10 -10
  76. package/lib/zudoku.plugins.js +10117 -9975
  77. package/package.json +3 -1
  78. package/src/app/App.tsx +5 -5
  79. package/src/app/main.tsx +9 -0
  80. package/src/lib/authentication/clerk.ts +0 -1
  81. package/src/lib/authentication/openid.ts +4 -2
  82. package/src/lib/components/Header.tsx +1 -1
  83. package/src/lib/components/navigation/SideNavigationWrapper.tsx +18 -16
  84. package/src/lib/oas/graphql/index.ts +1 -1
  85. package/src/lib/plugins/api-key/SettingsApiKeys.tsx +1 -1
  86. package/src/lib/plugins/api-key/index.tsx +3 -3
  87. package/src/lib/plugins/markdown/MdxPage.tsx +13 -8
  88. package/src/lib/plugins/openapi/ColorizedParam.tsx +1 -1
  89. package/src/lib/plugins/openapi/MakeRequest.tsx +3 -3
  90. package/src/lib/plugins/openapi/OperationList.tsx +1 -1
  91. package/src/lib/plugins/openapi/OperationListItem.tsx +2 -2
  92. package/src/lib/plugins/openapi/ResponsesSidecarBox.tsx +1 -1
  93. package/src/lib/plugins/openapi/SchemaListView.tsx +5 -5
  94. package/src/lib/plugins/openapi/Sidecar.tsx +3 -3
  95. package/src/lib/plugins/openapi/playground/PathParams.tsx +4 -4
  96. package/src/lib/plugins/openapi/playground/Playground.tsx +19 -22
  97. package/src/lib/plugins/openapi/playground/QueryParams.tsx +4 -3
  98. package/src/lib/plugins/openapi/util/generateSchemaExample.ts +0 -1
  99. package/src/lib/plugins/openapi/worker/createSharedWorkerClient.ts +1 -0
  100. package/src/lib/ui/Button.tsx +11 -42
  101. package/src/lib/ui/button-variants.ts +31 -0
  102. package/src/lib/util/MdxComponents.tsx +31 -7
  103. package/dist/lib/oas/graphql/server.d.ts +0 -1
  104. package/dist/lib/oas/graphql/server.js +0 -8
  105. package/dist/lib/oas/graphql/server.js.map +0 -1
  106. package/src/lib/oas/graphql/server.ts +0 -10
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zudoku",
3
- "version": "0.1.1-dev.48",
3
+ "version": "0.1.1-dev.49",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "dist",
@@ -67,6 +67,7 @@
67
67
  "graphql": "16.9.0",
68
68
  "graphql-type-json": "0.3.2",
69
69
  "graphql-yoga": "5.2.0",
70
+ "loglevel": "^1.9.1",
70
71
  "lru-cache": "10.2.0",
71
72
  "mdx": "0.3.1",
72
73
  "object-hash": "3.0.0",
@@ -109,6 +110,7 @@
109
110
  "@types/express": "^4.17.21",
110
111
  "@types/har-format": "^1.2.15",
111
112
  "@types/json-schema": "7.0.15",
113
+ "@types/loglevel": "^1.6.3",
112
114
  "@types/mdx": "2.0.13",
113
115
  "@types/node": "20.12.10",
114
116
  "@types/object-hash": "^3.0.6",
package/src/app/App.tsx CHANGED
@@ -4,10 +4,10 @@ import "./main.css";
4
4
  import config from "virtual:zudoku-config";
5
5
 
6
6
  // Virtual Plugins
7
+ import { configuredApiKeysPlugin } from "virtual:zudoku-api-keys-plugin";
7
8
  import { configuredApiPlugins } from "virtual:zudoku-api-plugins";
8
9
  import { configuredAuthProvider } from "virtual:zudoku-auth";
9
10
  import { configuredDocsPlugins } from "virtual:zudoku-docs-plugins";
10
- import { configuredApiKeysPlugin } from "virtual:zudoku-api-keys-plugin";
11
11
  import { configuredRedirectPlugin } from "virtual:zudoku-redirect-plugin";
12
12
 
13
13
  // Base React Component
@@ -20,11 +20,11 @@ export default function App() {
20
20
  return (
21
21
  <DevPortal
22
22
  meta={{
23
- headerTitle: config?.ui?.headerTitle ?? "Developer Portal",
24
- pageTitle: config?.ui?.pageTitle ?? "%s | Dev Portal",
25
- logo: config?.ui?.logo ?? "https://cdn.zuplo.com/www/favicon.png",
23
+ headerTitle: config.ui?.headerTitle ?? "Developer Portal",
24
+ pageTitle: config.ui?.pageTitle ?? "%s | Dev Portal",
25
+ logo: config.ui?.logo ?? "https://cdn.zuplo.com/www/favicon.png",
26
26
  favicon:
27
- config?.ui?.metadata?.favicon ??
27
+ config.ui?.metadata?.favicon ??
28
28
  "https://cdn.zuplo.com/www/favicon.png",
29
29
  }}
30
30
  navigation={config.navigation ?? []}
package/src/app/main.tsx CHANGED
@@ -1,7 +1,16 @@
1
+ import log from "loglevel";
1
2
  import { StrictMode } from "react";
2
3
  import { createRoot } from "react-dom/client";
3
4
  import App from "./App.js";
4
5
 
6
+ log.setDefaultLevel("silent");
7
+
8
+ if (import.meta.env.DEV) {
9
+ log.setLevel("debug");
10
+ } else if (localStorage.getItem("ENABLE_DEBUG_LOGS")) {
11
+ log.setLevel("debug");
12
+ }
13
+
5
14
  createRoot(document.getElementById("root")!).render(
6
15
  <StrictMode>
7
16
  <App />
@@ -9,7 +9,6 @@ const clerkAuth = ({ clerkPubKey }: { clerkPubKey: string }): AuthProvider => {
9
9
  clerkApi = new Clerk(clerkPubKey);
10
10
 
11
11
  await clerkApi.load({});
12
- clerkApi.load({});
13
12
  })();
14
13
 
15
14
  return {
@@ -1,6 +1,8 @@
1
+ import logger from "loglevel";
1
2
  import * as oauth from "oauth4webapi";
2
3
  import { DevPortalContext } from "../core/DevPortalContext.js";
3
4
  import { type AuthProvider } from "./authentication.js";
5
+
4
6
  const algorithm = "oauth2";
5
7
 
6
8
  const getAuthServerByIssuer = async (issuer: string) => {
@@ -140,7 +142,7 @@ export const openIdAuth = ({
140
142
  state,
141
143
  );
142
144
  if (oauth.isOAuth2Error(params)) {
143
- console.error("Error Response", params);
145
+ logger.error("Error Response", params);
144
146
  throw new Error(); // Handle OAuth 2.0 redirect error
145
147
  }
146
148
 
@@ -167,7 +169,7 @@ export const openIdAuth = ({
167
169
  response,
168
170
  );
169
171
  if (oauth.isOAuth2Error(oauthResult)) {
170
- console.error("Error Response", oauthResult);
172
+ logger.error("Error Response", oauthResult);
171
173
  throw new Error(oauthResult.error);
172
174
  }
173
175
 
@@ -5,7 +5,7 @@ import { TopNavigation } from "./TopNavigation.js";
5
5
  import { useDevPortal } from "./context/DevPortalProvider.js";
6
6
  import { useTheme } from "./context/ThemeContext.js";
7
7
 
8
- export const Header = memo(() => {
8
+ export const Header = memo(function HeaderInner() {
9
9
  const [isDark, toggleTheme] = useTheme();
10
10
  const { isLoggedIn, email } = useDevPortalState();
11
11
  const { login, logout, meta } = useDevPortal();
@@ -4,19 +4,21 @@ import { cn } from "../../util/cn.js";
4
4
  export const SideNavigationWrapper = forwardRef<
5
5
  HTMLDivElement,
6
6
  PropsWithChildren<{ pushMainContent?: boolean; className?: string }>
7
- >(({ children, className, pushMainContent }, ref) => (
8
- <nav
9
- // this data attribute is used in `Layout.tsx` to determine if side navigation
10
- // is present for the current page so the main content is pushed to the right
11
- // it's also important to set `peer` class here.
12
- // maybe this could be simplified by adjusting the layout
13
- data-navigation={String(pushMainContent)}
14
- className={cn(
15
- "peer hidden lg:flex flex-col fixed text-sm overflow-y-auto shrink-0 p-[--padding-nav-item] -mx-[--padding-nav-item] pb-20 pt-[--padding-content-top] w-[--side-nav-width] h-[calc(100%-var(--header-height))] scroll-pt-2 gap-2",
16
- className,
17
- )}
18
- ref={ref}
19
- >
20
- {children}
21
- </nav>
22
- ));
7
+ >(function SideNavigation({ children, className, pushMainContent }, ref) {
8
+ return (
9
+ <nav
10
+ // this data attribute is used in `Layout.tsx` to determine if side navigation
11
+ // is present for the current page so the main content is pushed to the right
12
+ // it's also important to set `peer` class here.
13
+ // maybe this could be simplified by adjusting the layout
14
+ data-navigation={String(pushMainContent)}
15
+ className={cn(
16
+ "peer hidden lg:flex flex-col fixed text-sm overflow-y-auto shrink-0 p-[--padding-nav-item] -mx-[--padding-nav-item] pb-20 pt-[--padding-content-top] w-[--side-nav-width] h-[calc(100%-var(--header-height))] scroll-pt-2 gap-2",
17
+ className,
18
+ )}
19
+ ref={ref}
20
+ >
21
+ {children}
22
+ </nav>
23
+ );
24
+ });
@@ -69,7 +69,7 @@ const getAllOperations = (paths?: PathsObject, tag?: string) => {
69
69
  if (!value?.[method]) return [];
70
70
 
71
71
  const operation = value[method] as OperationObject;
72
- const pathParameters = value?.parameters ?? [];
72
+ const pathParameters = value.parameters ?? [];
73
73
  const operationParameters = operation.parameters ?? [];
74
74
 
75
75
  // parameters are inherited from the parent path object,
@@ -51,7 +51,7 @@ export const SettingsApiKeys = ({
51
51
 
52
52
  <Card>
53
53
  <ul className="grid grid-cols-[min-content_1fr_min-content] ">
54
- {data?.map((key) => (
54
+ {data.map((key) => (
55
55
  <li
56
56
  className="border-b border-border p-5 grid grid-cols-subgrid col-span-full gap-2 items-center"
57
57
  key={key.id}
@@ -3,8 +3,8 @@ import {
3
3
  type ApiIdentityPlugin,
4
4
  type DevPortalPlugin,
5
5
  } from "../../core/plugins.js";
6
- import { SettingsApiKeys } from "./SettingsApiKeys.js";
7
6
  import { CreateApiKey } from "./CreateApiKey.js";
7
+ import { SettingsApiKeys } from "./SettingsApiKeys.js";
8
8
 
9
9
  export type ApiKeyResults = Promise<ApiKey[]>;
10
10
  const DEFAULT_API_KEY_ENDPOINT =
@@ -25,9 +25,9 @@ export type ApiKeyService = {
25
25
  ) => Promise<void>;
26
26
  };
27
27
 
28
- export type GetApiKeysOptions = ApiKeyService | { endpoint: string } | {};
28
+ export type GetApiKeysOptions = ApiKeyService | { endpoint: string } | object;
29
29
 
30
- export type ApiKeyPluginOptions = {} & GetApiKeysOptions;
30
+ export type ApiKeyPluginOptions = object & GetApiKeysOptions;
31
31
 
32
32
  export interface ApiKey {
33
33
  id: string;
@@ -1,3 +1,4 @@
1
+ import { useMDXComponents } from "@mdx-js/react";
1
2
  import { useMemo, type PropsWithChildren, type ReactNode } from "react";
2
3
  import { CategoryHeading } from "../../components/CategoryHeading.js";
3
4
  import { Heading } from "../../components/Heading.js";
@@ -6,20 +7,24 @@ import { useTopNavigationItem } from "../../components/context/DevPortalProvider
6
7
  import { isPathItem } from "../../components/navigation/util.js";
7
8
  import { Helmet } from "../../core/helmet.js";
8
9
  import { Link, useLocation } from "../../core/router.js";
10
+ import type { MdxComponentsType } from "../../util/MdxComponents.js";
9
11
  import { cn } from "../../util/cn.js";
10
12
  import slugify from "../../util/slugify.js";
11
13
  import { traverseNavigation } from "../../util/traverseNavigation.js";
12
14
  import { Toc } from "./Toc.js";
13
15
  import type { MDXImport } from "./index.js";
14
- import { useMDXComponents } from "@mdx-js/react";
15
- import type { MdxComponentsType } from "../../util/MdxComponents.js";
16
16
 
17
17
  const MarkdownHeadings = {
18
18
  h2: ({ children, id }) => (
19
- <Heading level={2} id={id} children={children} registerSidebarAnchor />
19
+ <Heading level={2} id={id} registerSidebarAnchor>
20
+ {children}
21
+ </Heading>
20
22
  ),
21
23
  h3: ({ children, id }) => (
22
- <Heading level={3} id={id} children={children} registerSidebarAnchor />
24
+ <Heading level={3} id={id} registerSidebarAnchor>
25
+ {" "}
26
+ {children}
27
+ </Heading>
23
28
  ),
24
29
  } satisfies MdxComponentsType;
25
30
 
@@ -43,9 +48,9 @@ export const MdxPage = ({
43
48
  })
44
49
  : undefined;
45
50
 
46
- const title = frontmatter?.title;
47
- const category = frontmatter?.category ?? categoryTitle;
48
- const hideToc = frontmatter?.toc === false;
51
+ const title = frontmatter.title;
52
+ const category = frontmatter.category ?? categoryTitle;
53
+ const hideToc = frontmatter.toc === false;
49
54
 
50
55
  const pageTitle =
51
56
  tableOfContents.find((item) => item.depth === 1)?.value ?? title;
@@ -100,7 +105,7 @@ export const MdxPage = ({
100
105
  {title}
101
106
  </Heading>
102
107
  )}
103
- {frontmatter?.description && (
108
+ {frontmatter.description && (
104
109
  <p className="prose-lg">{frontmatter.description}</p>
105
110
  )}
106
111
  </header>
@@ -74,7 +74,7 @@ export const ColorizedParam = ({
74
74
  className="absolute inset-0 border-b-2 transition-opacity duration-200 opacity-30 group-data-[active=true]:opacity-100"
75
75
  style={{ borderColor, backgroundColor }}
76
76
  />
77
- <span className="relative">{children || name}</span>
77
+ <span className="relative">{children ?? name}</span>
78
78
  </span>
79
79
  );
80
80
  };
@@ -23,19 +23,19 @@ export const MakeRequest = ({
23
23
 
24
24
  const headers = operation.parameters
25
25
  ?.filter((p) => p.in === "header")
26
- ?.map((p) => ({
26
+ .map((p) => ({
27
27
  name: p.name,
28
28
  value: p.examples?.find((x) => x.value)?.value ?? "",
29
29
  }));
30
30
  const queryParams = operation.parameters
31
31
  ?.filter((p) => p.in === "query")
32
- ?.map((p) => ({
32
+ .map((p) => ({
33
33
  name: p.name,
34
34
  value: "",
35
35
  }));
36
36
  const pathParams = operation.parameters
37
37
  ?.filter((p) => p.in === "path")
38
- ?.map((p) => ({
38
+ .map((p) => ({
39
39
  name: p.name,
40
40
  value: "",
41
41
  }));
@@ -101,7 +101,7 @@ export const OperationList = () => {
101
101
  </Heading>
102
102
  <Markdown content={result.data.schema.description ?? ""} />
103
103
  </div>
104
- {result.data?.schema.tags
104
+ {result.data.schema.tags
105
105
  .filter((tag) => tag.operations.length > 0)
106
106
  .map((tag) => (
107
107
  <div key={tag.name}>
@@ -17,7 +17,7 @@ export const OperationListItem = ({
17
17
  operationFragment: FragmentType<typeof OperationsFragment>;
18
18
  }) => {
19
19
  const operation = useFragment(OperationsFragment, operationFragment);
20
- const groupedParameters = groupBy(operation?.parameters ?? [], "in");
20
+ const groupedParameters = groupBy(operation.parameters ?? [], "in");
21
21
  const first = operation.responses.find((re) => re.statusCode === "200");
22
22
  return (
23
23
  <div
@@ -37,7 +37,7 @@ export const OperationListItem = ({
37
37
  {operation.parameters && operation.parameters.length > 0 && (
38
38
  <div className="mt-4">
39
39
  {PARAM_GROUPS.flatMap((group) =>
40
- groupedParameters?.[group]?.length ? (
40
+ groupedParameters[group].length ? (
41
41
  <ParameterList
42
42
  key={group}
43
43
  id={operation.slug}
@@ -15,7 +15,7 @@ export const ResponsesSidecarBox = ({
15
15
  const [tabIndex, setTabIndex] = useState(0);
16
16
 
17
17
  const activeTab = responses[tabIndex];
18
- const schema = activeTab?.content?.[0]?.schema as SchemaObject | undefined;
18
+ const schema = activeTab.content?.[0]?.schema as SchemaObject | undefined;
19
19
 
20
20
  return (
21
21
  <SidecarBox.Root>
@@ -1,10 +1,10 @@
1
- import { SchemaObject } from "../../oas/parser/index.js";
1
+ import * as Collapsible from "@radix-ui/react-collapsible";
2
+ import { ListPlusIcon } from "lucide-react";
2
3
  import { useState } from "react";
3
- import { cn } from "../../util/cn.js";
4
4
  import { Markdown } from "../../components/Markdown.js";
5
- import * as Collapsible from "@radix-ui/react-collapsible";
5
+ import { SchemaObject } from "../../oas/parser/index.js";
6
6
  import { Button } from "../../ui/Button.js";
7
- import { ListPlusIcon } from "lucide-react";
7
+ import { cn } from "../../util/cn.js";
8
8
 
9
9
  export const SchemaListView = ({
10
10
  name,
@@ -117,7 +117,7 @@ const SchemaListViewItemGroup = ({
117
117
  property={property}
118
118
  propertyName={propertyName}
119
119
  nestingLevel={nestingLevel}
120
- isRequired={required?.includes(propertyName) ?? false}
120
+ isRequired={required.includes(propertyName)}
121
121
  />
122
122
  ))}
123
123
  </Collapsible.Content>
@@ -1,5 +1,7 @@
1
+ import { HTTPSnippet } from "@zudoku/httpsnippet";
1
2
  import { Fragment, useMemo, useState } from "react";
2
3
  import { SyntaxHighlight } from "../../components/SyntaxHighlight.js";
4
+ import type { SchemaObject } from "../../oas/parser/index.js";
3
5
  import { cn } from "../../util/cn.js";
4
6
  import { ColorizedParam } from "./ColorizedParam.js";
5
7
  import { MakeRequest } from "./MakeRequest.js";
@@ -9,9 +11,7 @@ import { RequestBodySidecarBox } from "./RequestBodySidecarBox.js";
9
11
  import { ResponsesSidecarBox } from "./ResponsesSidecarBox.js";
10
12
  import { Select } from "./Select.js";
11
13
  import * as SidecarBox from "./SidecarBox.js";
12
- import { HTTPSnippet } from "@zudoku/httpsnippet";
13
14
  import { generateSchemaExample } from "./util/generateSchemaExample.js";
14
- import type { SchemaObject } from "../../oas/parser/index.js";
15
15
 
16
16
  const getConverted = (snippet: HTTPSnippet, option: string) => {
17
17
  let converted;
@@ -105,7 +105,7 @@ export const Sidecar = ({
105
105
  } as never, // 👈 never touch this
106
106
  );
107
107
 
108
- return getConverted(snippet, option) ?? "";
108
+ return getConverted(snippet, option);
109
109
  }, [option, operation.method, operation.path, requestBodyContent]);
110
110
 
111
111
  return (
@@ -1,16 +1,16 @@
1
+ import { forwardRef, InputHTMLAttributes } from "react";
1
2
  import { Control, useFieldArray, UseFormRegister } from "react-hook-form";
3
+ import { cn } from "../../../util/cn.js";
4
+ import { DATA_ATTR, usePastellizedColor } from "../ColorizedParam.js";
2
5
  import { InlineInput } from "./InlineInput.js";
3
6
  import { PlaygroundForm } from "./Playground.js";
4
- import { DATA_ATTR, usePastellizedColor } from "../ColorizedParam.js";
5
- import { forwardRef, InputHTMLAttributes } from "react";
6
- import { cn } from "../../../util/cn.js";
7
7
 
8
8
  type ParameterValueProps = {
9
9
  part: string;
10
10
  } & InputHTMLAttributes<HTMLInputElement>;
11
11
 
12
12
  const ParameterValue = forwardRef<HTMLInputElement, ParameterValueProps>(
13
- ({ part, className, ...props }, ref) => {
13
+ function ParameterValue({ part, className, ...props }, ref) {
14
14
  const color = usePastellizedColor(part);
15
15
  return (
16
16
  <InlineInput
@@ -1,24 +1,15 @@
1
+ import { VisuallyHidden } from "@radix-ui/react-visually-hidden";
2
+ import { useMutation } from "@tanstack/react-query";
3
+ import { CirclePlayIcon } from "lucide-react";
4
+ import { Fragment } from "react";
5
+ import { FormProvider, useForm } from "react-hook-form";
6
+ import { useApiIdentities } from "../../../components/context/DevPortalProvider.js";
1
7
  import {
2
8
  Dialog,
3
9
  DialogContent,
4
10
  DialogTitle,
5
11
  DialogTrigger,
6
12
  } from "../../../components/Dialog.js";
7
- import { Card } from "../../../ui/Card.js";
8
- import { Button } from "../../../ui/Button.js";
9
- import { Tabs, TabsContent, TabsList, TabsTrigger } from "../../../ui/Tabs.js";
10
- import { Fragment } from "react";
11
- import { SyntaxHighlight } from "../../../components/SyntaxHighlight.js";
12
- import { ColorizedParam } from "../ColorizedParam.js";
13
- import { useMutation } from "@tanstack/react-query";
14
- import { FormProvider, useForm } from "react-hook-form";
15
- import { Headers } from "./Headers.js";
16
- import { QueryParams } from "./QueryParams.js";
17
- import { PathParams } from "./PathParams.js";
18
- import { CirclePlayIcon } from "lucide-react";
19
- import { createUrl } from "./createUrl.js";
20
- import { useApiIdentities } from "../../../components/context/DevPortalProvider.js";
21
- import { Spinner } from "../../../components/Spinner.js";
22
13
  import {
23
14
  Select,
24
15
  SelectContent,
@@ -26,7 +17,16 @@ import {
26
17
  SelectTrigger,
27
18
  SelectValue,
28
19
  } from "../../../components/Select.js";
29
- import { VisuallyHidden } from "@radix-ui/react-visually-hidden";
20
+ import { Spinner } from "../../../components/Spinner.js";
21
+ import { SyntaxHighlight } from "../../../components/SyntaxHighlight.js";
22
+ import { Button } from "../../../ui/Button.js";
23
+ import { Card } from "../../../ui/Card.js";
24
+ import { Tabs, TabsContent, TabsList, TabsTrigger } from "../../../ui/Tabs.js";
25
+ import { ColorizedParam } from "../ColorizedParam.js";
26
+ import { createUrl } from "./createUrl.js";
27
+ import { Headers } from "./Headers.js";
28
+ import { PathParams } from "./PathParams.js";
29
+ import { QueryParams } from "./QueryParams.js";
30
30
 
31
31
  function mimeTypeToLanguage(mimeType: string) {
32
32
  const mimeTypeMapping = {
@@ -128,7 +128,7 @@ const Playground = ({
128
128
 
129
129
  if (data.identity !== NO_IDENTITY) {
130
130
  identities.data
131
- ?.find((i) => i.id === data.identity)
131
+ .find((i) => i.id === data.identity)
132
132
  ?.authorizeRequest(request);
133
133
  }
134
134
 
@@ -152,9 +152,6 @@ const Playground = ({
152
152
  <ColorizedParam
153
153
  name={part}
154
154
  backgroundOpacity="0"
155
- onClick={() => {
156
- console.log("asd");
157
- }}
158
155
  slug={part.slice(1, -1)}
159
156
  >
160
157
  {
@@ -257,7 +254,7 @@ const Playground = ({
257
254
  </SelectTrigger>
258
255
  <SelectContent align="center">
259
256
  <SelectItem value={NO_IDENTITY}>None</SelectItem>
260
- {identities.data?.map((identity) => (
257
+ {identities.data.map((identity) => (
261
258
  <SelectItem key={identity.id} value={identity.id}>
262
259
  {identity.label}
263
260
  </SelectItem>
@@ -330,7 +327,7 @@ const Playground = ({
330
327
  noBackground
331
328
  className="overflow-x-auto "
332
329
  code={
333
- queryMutation.data?.body ?? JSON.stringify("")
330
+ queryMutation.data.body ?? JSON.stringify("")
334
331
  }
335
332
  />
336
333
  </Card>
@@ -1,3 +1,6 @@
1
+ import logger from "loglevel";
2
+ import { XIcon } from "lucide-react";
3
+ import { useEffect } from "react";
1
4
  import {
2
5
  Control,
3
6
  Controller,
@@ -5,10 +8,8 @@ import {
5
8
  useFormContext,
6
9
  useWatch,
7
10
  } from "react-hook-form";
8
- import { XIcon } from "lucide-react";
9
11
  import { InlineInput } from "./InlineInput.js";
10
12
  import { PlaygroundForm } from "./Playground.js";
11
- import { useEffect } from "react";
12
13
 
13
14
  const QueryParamActive = ({
14
15
  i,
@@ -23,7 +24,7 @@ const QueryParamActive = ({
23
24
 
24
25
  useEffect(() => {
25
26
  if (value) {
26
- console.log(`queryParams.${i}.active`, active);
27
+ logger.log(`queryParams.${i}.active`, active);
27
28
  form.setValue(`queryParams.${i}.active`, true);
28
29
  }
29
30
  }, [value]);
@@ -50,7 +50,6 @@ function processComplexTypes(schema: SchemaObject, name?: string): any {
50
50
 
51
51
  function getDefaultForType(type?: string | string[]): any {
52
52
  if (Array.isArray(type)) {
53
- debugger;
54
53
  return getDefaultForSingleType(type[0]);
55
54
  }
56
55
  return getDefaultForSingleType(type);
@@ -1,3 +1,4 @@
1
+ /* eslint-disable no-console */
1
2
  import { monotonicFactory } from "ulidx";
2
3
  import { createWaitForNotify } from "../../../util/createWaitForNotify.js";
3
4
  import {
@@ -1,56 +1,25 @@
1
- import * as React from "react"
2
- import { Slot } from "@radix-ui/react-slot"
3
- import { cva, type VariantProps } from "class-variance-authority"
1
+ import { Slot } from "@radix-ui/react-slot";
2
+ import { VariantProps } from "class-variance-authority";
3
+ import * as React from "react";
4
4
  import { cn } from "../util/cn.js";
5
-
6
- const buttonVariants = cva(
7
- "inline-flex items-center justify-center whitespace-nowrap rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50",
8
- {
9
- variants: {
10
- variant: {
11
- default:
12
- "bg-primary text-primary-foreground shadow hover:bg-primary/90",
13
- destructive:
14
- "bg-destructive text-destructive-foreground shadow-sm hover:bg-destructive/90",
15
- outline:
16
- "border border-input bg-background shadow-sm hover:bg-accent hover:text-accent-foreground",
17
- secondary:
18
- "bg-secondary text-secondary-foreground shadow-sm hover:bg-secondary/80",
19
- ghost: "hover:bg-accent hover:text-accent-foreground",
20
- link: "text-primary underline-offset-4 hover:underline",
21
- },
22
- size: {
23
- default: "h-9 px-4 py-2",
24
- sm: "h-8 rounded-md px-3 text-xs",
25
- lg: "h-10 rounded-md px-8",
26
- icon: "h-9 w-9",
27
- },
28
- },
29
- defaultVariants: {
30
- variant: "default",
31
- size: "default",
32
- },
33
- }
34
- )
5
+ import { buttonVariants } from "./button-variants.js";
35
6
 
36
7
  export interface ButtonProps
37
8
  extends React.ButtonHTMLAttributes<HTMLButtonElement>,
38
9
  VariantProps<typeof buttonVariants> {
39
- asChild?: boolean
10
+ asChild?: boolean;
40
11
  }
41
12
 
42
- const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(
13
+ export const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(
43
14
  ({ className, variant, size, asChild = false, ...props }, ref) => {
44
- const Comp = asChild ? Slot : "button"
15
+ const Comp = asChild ? Slot : "button";
45
16
  return (
46
17
  <Comp
47
18
  className={cn(buttonVariants({ variant, size, className }))}
48
19
  ref={ref}
49
20
  {...props}
50
21
  />
51
- )
52
- }
53
- )
54
- Button.displayName = "Button"
55
-
56
- export { Button, buttonVariants }
22
+ );
23
+ },
24
+ );
25
+ Button.displayName = "Button";
@@ -0,0 +1,31 @@
1
+ import { cva } from "class-variance-authority";
2
+
3
+ export const buttonVariants = cva(
4
+ "inline-flex items-center justify-center whitespace-nowrap rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50",
5
+ {
6
+ variants: {
7
+ variant: {
8
+ default:
9
+ "bg-primary text-primary-foreground shadow hover:bg-primary/90",
10
+ destructive:
11
+ "bg-destructive text-destructive-foreground shadow-sm hover:bg-destructive/90",
12
+ outline:
13
+ "border border-input bg-background shadow-sm hover:bg-accent hover:text-accent-foreground",
14
+ secondary:
15
+ "bg-secondary text-secondary-foreground shadow-sm hover:bg-secondary/80",
16
+ ghost: "hover:bg-accent hover:text-accent-foreground",
17
+ link: "text-primary underline-offset-4 hover:underline",
18
+ },
19
+ size: {
20
+ default: "h-9 px-4 py-2",
21
+ sm: "h-8 rounded-md px-3 text-xs",
22
+ lg: "h-10 rounded-md px-8",
23
+ icon: "h-9 w-9",
24
+ },
25
+ },
26
+ defaultVariants: {
27
+ variant: "default",
28
+ size: "default",
29
+ },
30
+ },
31
+ );