import api from './client'; import type { AccountEventPage, AccountItem, AccountBulkSelection, AccountBulkTagRequest, AccountOverview, AssignmentsSummary, BasicSummary, MessageCountResponse, MessageDeletedResponse, MessageResponse, PageParams, PaginatedResponse, } from './types'; export const accountApi = { list: (params?: { assigned_only?: boolean; tag?: string; has_cookie?: boolean; include_sensitive?: boolean }) => api.get('/accounts', { params }), listPaged: (params: PageParams & { assigned_only?: boolean; tag?: string; has_cookie?: boolean; include_sensitive?: boolean }) => api.get, PaginatedResponse>('/accounts', { params }), summary: () => api.get('/accounts/summary'), import: (text: string, tag?: string) => api.post('/accounts/import', { text, tag: tag || '' }), assign: (id: number, assigned_to: number | null) => api.put(`/accounts/${id}/assign`, { assigned_to }), batchAssign: (account_ids: number[], assigned_to: number | null) => api.post('/accounts/batch-assign', { account_ids, assigned_to }), assignmentsSummary: () => api.get('/accounts/assignments/summary'), setTag: (id: number, tag: string) => api.put(`/accounts/${id}/tag`, { tag }), batchTag: (account_ids: number[], tag: string) => api.put('/accounts/batch-tag', { account_ids, tag }), batchTagSelection: (data: AccountBulkTagRequest) => api.put('/accounts/batch-tag-selection', data), listTags: () => api.get('/accounts/tags/list'), delete: (id: number) => api.delete(`/accounts/${id}`), batchDelete: (account_ids: number[]) => api.delete('/accounts/batch/delete', { params: { account_ids: account_ids.join(',') } }), batchDeleteSelection: (data: AccountBulkSelection) => api.post('/accounts/batch-delete', data), // 详情页:状态卡 + 统计 overview: (id: number) => api.get(`/accounts/${id}/overview`), // 时间线(倒序分页),event_type 为空表示全部 events: (id: number, params: { page?: number; page_size?: number; event_type?: string }) => api.get(`/accounts/${id}/events`, { params: { page: 1, page_size: 50, ...params, event_type: params.event_type || '' }, }), };