feat(evidence): add upload types and API client for frontend
- FileUploadResponse and PendingUpload types in types/upload.ts - uploadsApi with upload(), getUrl(), list(), remove() methods - Exported from types/index.ts and api/index.ts Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -29,3 +29,4 @@ export { flowProposalsApi } from './flowProposals'
|
|||||||
export { flowpilotAnalyticsApi } from './flowpilotAnalytics'
|
export { flowpilotAnalyticsApi } from './flowpilotAnalytics'
|
||||||
export { notificationsApi } from './notifications'
|
export { notificationsApi } from './notifications'
|
||||||
export { publicTemplatesApi } from './publicTemplates'
|
export { publicTemplatesApi } from './publicTemplates'
|
||||||
|
export { uploadsApi, default as uploadsApiDefault } from './uploads'
|
||||||
|
|||||||
32
frontend/src/api/uploads.ts
Normal file
32
frontend/src/api/uploads.ts
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
import apiClient from './client'
|
||||||
|
import type { FileUploadResponse } from '@/types/upload'
|
||||||
|
|
||||||
|
export const uploadsApi = {
|
||||||
|
async upload(file: File, sessionId?: string): Promise<FileUploadResponse> {
|
||||||
|
const formData = new FormData()
|
||||||
|
formData.append('file', file)
|
||||||
|
if (sessionId) formData.append('session_id', sessionId)
|
||||||
|
const response = await apiClient.post<FileUploadResponse>('/uploads', formData, {
|
||||||
|
headers: { 'Content-Type': 'multipart/form-data' },
|
||||||
|
})
|
||||||
|
return response.data
|
||||||
|
},
|
||||||
|
|
||||||
|
async getUrl(id: string): Promise<string> {
|
||||||
|
const response = await apiClient.get<{ url: string }>(`/uploads/${id}/url`)
|
||||||
|
return response.data.url
|
||||||
|
},
|
||||||
|
|
||||||
|
async list(sessionId: string): Promise<FileUploadResponse[]> {
|
||||||
|
const response = await apiClient.get<FileUploadResponse[]>('/uploads', {
|
||||||
|
params: { session_id: sessionId },
|
||||||
|
})
|
||||||
|
return response.data
|
||||||
|
},
|
||||||
|
|
||||||
|
async remove(id: string): Promise<void> {
|
||||||
|
await apiClient.delete(`/uploads/${id}`)
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
export default uploadsApi
|
||||||
@@ -15,6 +15,7 @@ export type { AssistantChat, AssistantChatMessage, ChatListItem, ChatMessageResp
|
|||||||
export * from './ai-session'
|
export * from './ai-session'
|
||||||
export * from './flow-proposal'
|
export * from './flow-proposal'
|
||||||
export * from './flowpilot-analytics'
|
export * from './flowpilot-analytics'
|
||||||
|
export * from './upload'
|
||||||
|
|
||||||
// API response wrapper types
|
// API response wrapper types
|
||||||
export interface PaginatedResponse<T> {
|
export interface PaginatedResponse<T> {
|
||||||
|
|||||||
17
frontend/src/types/upload.ts
Normal file
17
frontend/src/types/upload.ts
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
export interface FileUploadResponse {
|
||||||
|
id: string
|
||||||
|
filename: string
|
||||||
|
content_type: string
|
||||||
|
size_bytes: number
|
||||||
|
url: string
|
||||||
|
created_at: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface PendingUpload {
|
||||||
|
id: string
|
||||||
|
file: File
|
||||||
|
preview: string
|
||||||
|
status: 'uploading' | 'done' | 'error'
|
||||||
|
result?: FileUploadResponse
|
||||||
|
error?: string
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user