chore(repo): initialize Tradarr repository
Add the existing application baseline and repository documentation/ignore rules. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
74
frontend/src/api/admin.ts
Normal file
74
frontend/src/api/admin.ts
Normal file
@ -0,0 +1,74 @@
|
||||
import { api } from './client'
|
||||
|
||||
export interface AIProvider {
|
||||
id: string; name: string; model: string; endpoint: string
|
||||
is_active: boolean; has_key: boolean
|
||||
}
|
||||
export interface AIRoleConfig { provider_id: string; model: string }
|
||||
export interface AIRoles { summary: AIRoleConfig; report: AIRoleConfig; filter: AIRoleConfig }
|
||||
export interface OllamaModelInfo {
|
||||
name: string; size: number; modified_at: string
|
||||
details: { parameter_size: string; quantization_level: string; family: string }
|
||||
}
|
||||
export interface Source { id: string; name: string; type: string; enabled: boolean }
|
||||
export interface ScrapeJob {
|
||||
id: string; source_id: string; source_name: string; status: string
|
||||
started_at: { Time: string; Valid: boolean } | null
|
||||
finished_at: { Time: string; Valid: boolean } | null
|
||||
articles_found: number; error_msg: string; created_at: string
|
||||
}
|
||||
export interface Setting { key: string; value: string }
|
||||
export interface ScheduleSlot { id?: string; day_of_week: number; hour: number; minute: number }
|
||||
export interface AdminUser { id: string; email: string; role: string; created_at: string }
|
||||
export interface Credential { source_id: string; source_name: string; username: string; has_password: boolean }
|
||||
|
||||
export const adminApi = {
|
||||
// Credentials
|
||||
getCredentials: () => api.get<Credential[]>('/admin/credentials'),
|
||||
updateCredentials: (data: { source_id: string; username: string; password?: string }) =>
|
||||
api.put<void>('/admin/credentials', data),
|
||||
|
||||
// AI Providers
|
||||
listProviders: () => api.get<AIProvider[]>('/admin/ai-providers'),
|
||||
createProvider: (data: { name: string; api_key?: string; model?: string; endpoint?: string }) =>
|
||||
api.post<AIProvider>('/admin/ai-providers', data),
|
||||
updateProvider: (id: string, data: { name: string; api_key?: string; model?: string; endpoint?: string }) =>
|
||||
api.put<void>(`/admin/ai-providers/${id}`, data),
|
||||
activateProvider: (id: string) => api.post<void>(`/admin/ai-providers/${id}/activate`),
|
||||
deleteProvider: (id: string) => api.delete<void>(`/admin/ai-providers/${id}`),
|
||||
listModels: (id: string) => api.get<string[]>(`/admin/ai-providers/${id}/models`),
|
||||
probeModels: (data: { name: string; api_key?: string; endpoint?: string }) =>
|
||||
api.post<string[]>('/admin/ai-providers/probe-models', data),
|
||||
|
||||
// AI Roles
|
||||
getRoles: () => api.get<AIRoles>('/admin/ai-roles'),
|
||||
updateRole: (role: string, data: AIRoleConfig) => api.put<void>(`/admin/ai-roles/${role}`, data),
|
||||
|
||||
// Ollama model management
|
||||
listOllamaModels: () => api.get<OllamaModelInfo[]>('/admin/ollama/models'),
|
||||
pullOllamaModel: (name: string) => api.post<void>('/admin/ollama/pull', { name }),
|
||||
deleteOllamaModel: (name: string) => api.delete<void>(`/admin/ollama/models/${encodeURIComponent(name)}`),
|
||||
|
||||
// Sources
|
||||
listSources: () => api.get<Source[]>('/admin/sources'),
|
||||
updateSource: (id: string, enabled: boolean) => api.put<void>(`/admin/sources/${id}`, { enabled }),
|
||||
|
||||
// Jobs
|
||||
listJobs: () => api.get<ScrapeJob[]>('/admin/scrape-jobs'),
|
||||
triggerJob: (source_id: string) => api.post<void>('/admin/scrape-jobs/trigger', { source_id }),
|
||||
|
||||
// Settings
|
||||
listSettings: () => api.get<Setting[]>('/admin/settings'),
|
||||
updateSettings: (settings: Setting[]) => api.put<void>('/admin/settings', { settings }),
|
||||
getDefaultPrompt: () => api.get<{ prompt: string }>('/admin/settings/default-prompt'),
|
||||
|
||||
// Schedule
|
||||
getSchedule: () => api.get<ScheduleSlot[]>('/admin/schedule'),
|
||||
updateSchedule: (slots: ScheduleSlot[]) => api.put<void>('/admin/schedule', { slots }),
|
||||
|
||||
// Users
|
||||
listUsers: () => api.get<AdminUser[]>('/admin/users'),
|
||||
updateUser: (id: string, email: string, role: string) =>
|
||||
api.put<AdminUser>(`/admin/users/${id}`, { email, role }),
|
||||
deleteUser: (id: string) => api.delete<void>(`/admin/users/${id}`),
|
||||
}
|
||||
25
frontend/src/api/articles.ts
Normal file
25
frontend/src/api/articles.ts
Normal file
@ -0,0 +1,25 @@
|
||||
import { api } from './client'
|
||||
|
||||
export interface Article {
|
||||
id: string
|
||||
source_id: string
|
||||
source_name: string
|
||||
title: string
|
||||
content: string
|
||||
url: string
|
||||
published_at: { Time: string; Valid: boolean } | null
|
||||
created_at: string
|
||||
symbols?: string[]
|
||||
}
|
||||
|
||||
export const articlesApi = {
|
||||
list: (params?: { symbol?: string; limit?: number; offset?: number }) => {
|
||||
const q = new URLSearchParams()
|
||||
if (params?.symbol) q.set('symbol', params.symbol)
|
||||
if (params?.limit) q.set('limit', String(params.limit))
|
||||
if (params?.offset) q.set('offset', String(params.offset))
|
||||
const qs = q.toString()
|
||||
return api.get<Article[]>(`/articles${qs ? `?${qs}` : ''}`)
|
||||
},
|
||||
get: (id: string) => api.get<Article>(`/articles/${id}`),
|
||||
}
|
||||
9
frontend/src/api/assets.ts
Normal file
9
frontend/src/api/assets.ts
Normal file
@ -0,0 +1,9 @@
|
||||
import { api } from './client'
|
||||
|
||||
export interface Asset { id: string; user_id: string; symbol: string; name: string; created_at: string }
|
||||
|
||||
export const assetsApi = {
|
||||
list: () => api.get<Asset[]>('/me/assets'),
|
||||
add: (symbol: string, name: string) => api.post<Asset>('/me/assets', { symbol, name }),
|
||||
remove: (symbol: string) => api.delete<void>(`/me/assets/${symbol}`),
|
||||
}
|
||||
12
frontend/src/api/auth.ts
Normal file
12
frontend/src/api/auth.ts
Normal file
@ -0,0 +1,12 @@
|
||||
import { api } from './client'
|
||||
|
||||
export interface User { id: string; email: string; role: 'admin' | 'user' }
|
||||
interface AuthResponse { token: string; user: User }
|
||||
|
||||
export const authApi = {
|
||||
login: (email: string, password: string) =>
|
||||
api.post<AuthResponse>('/auth/login', { email, password }),
|
||||
register: (email: string, password: string) =>
|
||||
api.post<AuthResponse>('/auth/register', { email, password }),
|
||||
me: () => api.get<User>('/me'),
|
||||
}
|
||||
39
frontend/src/api/client.ts
Normal file
39
frontend/src/api/client.ts
Normal file
@ -0,0 +1,39 @@
|
||||
const BASE = '/api'
|
||||
|
||||
function getToken() {
|
||||
return localStorage.getItem('token')
|
||||
}
|
||||
|
||||
async function request<T>(path: string, options: RequestInit = {}): Promise<T> {
|
||||
const token = getToken()
|
||||
const res = await fetch(`${BASE}${path}`, {
|
||||
...options,
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
...(token ? { Authorization: `Bearer ${token}` } : {}),
|
||||
...options.headers,
|
||||
},
|
||||
})
|
||||
if (res.status === 401) {
|
||||
localStorage.removeItem('token')
|
||||
localStorage.removeItem('user')
|
||||
window.location.href = '/login'
|
||||
throw new Error('Session expirée')
|
||||
}
|
||||
if (!res.ok) {
|
||||
const err = await res.json().catch(() => ({ error: res.statusText }))
|
||||
throw new Error(err.error || res.statusText)
|
||||
}
|
||||
if (res.status === 204) return undefined as T
|
||||
const json = await res.json()
|
||||
return json.data !== undefined ? json.data : json
|
||||
}
|
||||
|
||||
export const api = {
|
||||
get: <T>(path: string) => request<T>(path),
|
||||
post: <T>(path: string, body?: unknown) =>
|
||||
request<T>(path, { method: 'POST', body: body ? JSON.stringify(body) : undefined }),
|
||||
put: <T>(path: string, body?: unknown) =>
|
||||
request<T>(path, { method: 'PUT', body: body ? JSON.stringify(body) : undefined }),
|
||||
delete: <T>(path: string) => request<T>(path, { method: 'DELETE' }),
|
||||
}
|
||||
32
frontend/src/api/reports.ts
Normal file
32
frontend/src/api/reports.ts
Normal file
@ -0,0 +1,32 @@
|
||||
import { api } from './client'
|
||||
|
||||
export interface Report {
|
||||
id: string
|
||||
user_id: string
|
||||
summary_id: string | null
|
||||
context_excerpt: string
|
||||
question: string
|
||||
answer: string
|
||||
status: 'generating' | 'done' | 'error'
|
||||
error_msg: string
|
||||
created_at: string
|
||||
}
|
||||
|
||||
export interface ReportMessage {
|
||||
id: string
|
||||
report_id: string
|
||||
role: 'user' | 'assistant'
|
||||
content: string
|
||||
status: 'done' | 'generating' | 'error'
|
||||
created_at: string
|
||||
}
|
||||
|
||||
export const reportsApi = {
|
||||
list: () => api.get<Report[]>('/reports'),
|
||||
create: (data: { summary_id?: string; excerpts: string[]; question: string }) =>
|
||||
api.post<Report>('/reports', data),
|
||||
delete: (id: string) => api.delete<void>(`/reports/${id}`),
|
||||
listMessages: (reportId: string) => api.get<ReportMessage[]>(`/reports/${reportId}/messages`),
|
||||
createMessage: (reportId: string, content: string) =>
|
||||
api.post<ReportMessage>(`/reports/${reportId}/messages`, { content }),
|
||||
}
|
||||
15
frontend/src/api/summaries.ts
Normal file
15
frontend/src/api/summaries.ts
Normal file
@ -0,0 +1,15 @@
|
||||
import { api } from './client'
|
||||
|
||||
export interface Summary {
|
||||
id: string
|
||||
user_id: string
|
||||
content: string
|
||||
ai_provider_id: string | null
|
||||
generated_at: string
|
||||
}
|
||||
|
||||
export const summariesApi = {
|
||||
list: (limit = 10) => api.get<Summary[]>(`/summaries?limit=${limit}`),
|
||||
generate: () => api.post<Summary>('/summaries/generate'),
|
||||
status: () => api.get<{ generating: boolean }>('/summaries/status'),
|
||||
}
|
||||
Reference in New Issue
Block a user