docs: add JSDoc to all frontend API modules, pages, components, utilities
Add English JSDoc documentation to 32 source files across the frontend: - API layer (8 files): client CSRF strategy, credential handling, 401 redirect, and endpoint-level docs for auth, settings, sources, syntheses, admin, config, apiKeys - Pages (11 files): Settings export/import, GenerateSynthesis SSE state machine, Home delete confirmation timer, Sources bulk import parsing, SynthesisDetail email/export flows, Login/Register Turnstile lifecycle, AuthVerify token flow, admin Providers/RateLimits/Users - Components (8 files): ApiKeyManager CRUD, Turnstile polling init, Navbar/MobileMenu route detection, Layout/AdminLayout structure, ErrorBoundary retry, Button variants, Toast auto-dismiss timer, LoadingSpinner props - Utilities (2 files): SSE reconnection backoff, dates locale config - Context (1 file): AuthContext session check, isAdmin derived signal No logic changes. TypeScript and vitest pass unchanged. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>master
parent
fa346dc346
commit
6f3ff1e9a2
@ -1,19 +1,25 @@
|
|||||||
import { api } from './client';
|
import { api } from './client';
|
||||||
import type { UserApiKey, CreateApiKeyRequest, TestApiKeyResponse } from '~/types';
|
import type { UserApiKey, CreateApiKeyRequest, TestApiKeyResponse } from '~/types';
|
||||||
|
|
||||||
|
/** User API-key management endpoints (BYOK -- bring your own key). */
|
||||||
export const apiKeysApi = {
|
export const apiKeysApi = {
|
||||||
|
/** GET /user/api-keys -- list stored API keys (returns masked prefixes). */
|
||||||
list: (): Promise<UserApiKey[]> =>
|
list: (): Promise<UserApiKey[]> =>
|
||||||
api.get<UserApiKey[]>('/user/api-keys'),
|
api.get<UserApiKey[]>('/user/api-keys'),
|
||||||
|
|
||||||
|
/** POST /user/api-keys -- store or replace an API key for a provider. */
|
||||||
create: (data: CreateApiKeyRequest): Promise<UserApiKey> =>
|
create: (data: CreateApiKeyRequest): Promise<UserApiKey> =>
|
||||||
api.post<UserApiKey>('/user/api-keys', data),
|
api.post<UserApiKey>('/user/api-keys', data),
|
||||||
|
|
||||||
|
/** DELETE /user/api-keys/:provider -- remove the stored key for a provider. */
|
||||||
remove: (provider: string): Promise<void> =>
|
remove: (provider: string): Promise<void> =>
|
||||||
api.delete<void>(`/user/api-keys/${encodeURIComponent(provider)}`),
|
api.delete<void>(`/user/api-keys/${encodeURIComponent(provider)}`),
|
||||||
|
|
||||||
|
/** POST /user/api-keys/:provider/test -- validate the stored key with a live API call. */
|
||||||
test: (provider: string): Promise<TestApiKeyResponse> =>
|
test: (provider: string): Promise<TestApiKeyResponse> =>
|
||||||
api.post<TestApiKeyResponse>(`/user/api-keys/${encodeURIComponent(provider)}/test`),
|
api.post<TestApiKeyResponse>(`/user/api-keys/${encodeURIComponent(provider)}/test`),
|
||||||
|
|
||||||
|
/** POST /user/api-keys/export -- return all keys in cleartext (for settings export). */
|
||||||
exportKeys: (): Promise<{ provider_name: string; api_key: string }[]> =>
|
exportKeys: (): Promise<{ provider_name: string; api_key: string }[]> =>
|
||||||
api.post('/user/api-keys/export'),
|
api.post('/user/api-keys/export'),
|
||||||
};
|
};
|
||||||
|
|||||||
@ -1,7 +1,9 @@
|
|||||||
import { api } from './client';
|
import { api } from './client';
|
||||||
import type { ProviderConfig } from '~/types';
|
import type { ProviderConfig } from '~/types';
|
||||||
|
|
||||||
|
/** Public configuration endpoints (no admin role required). */
|
||||||
export const configApi = {
|
export const configApi = {
|
||||||
|
/** GET /config/providers -- list enabled AI providers and their models visible to users. */
|
||||||
listProviders: (): Promise<ProviderConfig[]> =>
|
listProviders: (): Promise<ProviderConfig[]> =>
|
||||||
api.get<ProviderConfig[]>('/config/providers'),
|
api.get<ProviderConfig[]>('/config/providers'),
|
||||||
};
|
};
|
||||||
|
|||||||
@ -1,9 +1,12 @@
|
|||||||
import { api } from './client';
|
import { api } from './client';
|
||||||
import type { UserSettings } from '~/types';
|
import type { UserSettings } from '~/types';
|
||||||
|
|
||||||
|
/** User settings API endpoints. */
|
||||||
export const settingsApi = {
|
export const settingsApi = {
|
||||||
|
/** GET /settings -- retrieve the current user's settings (404 if none saved yet). */
|
||||||
get: (): Promise<UserSettings> => api.get<UserSettings>('/settings'),
|
get: (): Promise<UserSettings> => api.get<UserSettings>('/settings'),
|
||||||
|
|
||||||
|
/** PUT /settings -- create or fully replace the current user's settings. */
|
||||||
update: (settings: UserSettings): Promise<UserSettings> =>
|
update: (settings: UserSettings): Promise<UserSettings> =>
|
||||||
api.put<UserSettings>('/settings', settings),
|
api.put<UserSettings>('/settings', settings),
|
||||||
};
|
};
|
||||||
|
|||||||
Loading…
Reference in New Issue