refactor: remove api-types.ts compatibility layer

- Migrated all 29 files from api-types.ts to use reflector-api.d.ts directly
- Removed $SourceKind manual enum in favor of OpenAPI-generated types
- Fixed unrelated Spinner component TypeScript error in AuthWrapper.tsx
- All imports now use: import type { components } from "path/to/reflector-api"
- Deleted api-types.ts file completely
This commit is contained in:
2025-08-29 16:35:33 -06:00
parent 8c525e09e8
commit 7ddae5ddd5
35 changed files with 96 additions and 77 deletions

View File

@@ -4,13 +4,10 @@ import { useEffect } from "react";
import { configureApiAuth } from "./apiClient";
import useSessionAccessToken from "./useSessionAccessToken";
// Note: Base URL is now configured directly in apiClient.tsx
export function ApiAuthProvider({ children }: { children: React.ReactNode }) {
const { accessToken } = useSessionAccessToken();
useEffect(() => {
// Configure authentication
configureApiAuth(accessToken);
}, [accessToken]);

View File

@@ -1,27 +0,0 @@
// Re-export types from generated OpenAPI schema for backward compatibility
import type { components } from "../reflector-api";
// Export types with their original names
export type Room = components["schemas"]["Room"];
export type Meeting = components["schemas"]["Meeting"];
export type SourceKind = components["schemas"]["SourceKind"];
export type SearchResult = components["schemas"]["SearchResult"];
export type GetTranscript = components["schemas"]["GetTranscript"];
export type GetTranscriptTopic = components["schemas"]["GetTranscriptTopic"];
export type UpdateTranscript = components["schemas"]["UpdateTranscript"];
export type AudioWaveform = components["schemas"]["AudioWaveform"];
export type Participant = components["schemas"]["Participant"];
export type CreateTranscript = components["schemas"]["CreateTranscript"];
export type RtcOffer = components["schemas"]["RtcOffer"];
export type GetTranscriptSegmentTopic =
components["schemas"]["GetTranscriptSegmentTopic"];
export type Page_Room_ = components["schemas"]["Page_Room_"];
export type GetTranscriptTopicWithWordsPerSpeaker =
components["schemas"]["GetTranscriptTopicWithWordsPerSpeaker"];
export type GetTranscriptMinimal =
components["schemas"]["GetTranscriptMinimal"];
// Export any enums or constants that were in the old API
export const $SourceKind = {
values: ["room", "live", "file"] as const,
} as const;

View File

@@ -16,23 +16,21 @@ export const client = createClient<paths>({
baseUrl: "http://127.0.0.1:1250",
});
// Create the React Query client wrapper
export const $api = createFetchClient<paths>(client);
// Store the current auth token and ready state
let currentAuthToken: string | null | undefined = null;
let authConfigured = false;
// Export function to check if auth is ready
export const isAuthConfigured = () => authConfigured;
// Set up authentication middleware once
client.use({
onRequest({ request }) {
if (currentAuthToken) {
request.headers.set("Authorization", `Bearer ${currentAuthToken}`);
}
// Only set Content-Type if not already set (FormData will set its own boundary)
// XXX Only set Content-Type if not already set (FormData will set its own boundary)
// This is a work around for uploading file, we're passing a formdata
// but the content type was still application/json
if (
!request.headers.has("Content-Type") &&
!(request.body instanceof FormData)
@@ -43,13 +41,11 @@ client.use({
},
});
// Configure authentication by updating the token
export const configureApiAuth = (token: string | null | undefined) => {
currentAuthToken = token;
authConfigured = true;
};
// Export typed hooks for convenience
export const useApiQuery = $api.useQuery;
export const useApiMutation = $api.useMutation;
export const useApiSuspenseQuery = $api.useSuspenseQuery;