| 67 | } |
| 68 | |
| 69 | export class FetchDataAdapter implements DataAdapter { |
| 70 | // ==================== 会话管理 ==================== |
| 71 | |
| 72 | getSessions(): Promise<AnalysisSession[]> { |
| 73 | return get('/sessions') |
| 74 | } |
| 75 | |
| 76 | getSession(sessionId: string): Promise<AnalysisSession | null> { |
| 77 | return get(`/sessions/${sessionId}`) |
| 78 | } |
| 79 | |
| 80 | async deleteSession(sessionId: string): Promise<boolean> { |
| 81 | const result = await del<{ success: boolean }>(`/sessions/${sessionId}`) |
| 82 | return result.success |
| 83 | } |
| 84 | |
| 85 | async renameSession(sessionId: string, newName: string): Promise<boolean> { |
| 86 | const result = await patch<{ success: boolean }>(`/sessions/${sessionId}/name`, { |
| 87 | name: newName, |
| 88 | }) |
| 89 | return result.success |
| 90 | } |
| 91 | |
| 92 | async updateSessionOwnerId(sessionId: string, ownerId: string | null): Promise<boolean> { |
| 93 | const result = await patch<{ success: boolean }>(`/sessions/${sessionId}/owner`, { |
| 94 | ownerId, |
| 95 | }) |
| 96 | return result.success |
| 97 | } |
| 98 | |
| 99 | tryApplyOwnerProfile(sessionId: string): Promise<ApplyOwnerProfileResult> { |
| 100 | return post(`/sessions/${sessionId}/owner/apply-profile`, {}) |
| 101 | } |
| 102 | |
| 103 | setOwnerAndApplyProfile(sessionId: string, ownerPlatformId: string): Promise<SetOwnerAndApplyProfileResult> { |
| 104 | return post(`/sessions/${sessionId}/owner/select`, { ownerPlatformId }) |
| 105 | } |
| 106 | |
| 107 | async dismissOwnerPrompt(sessionId: string): Promise<boolean> { |
| 108 | const result = await post<{ success: boolean }>(`/sessions/${sessionId}/owner/dismiss-prompt`, {}) |
| 109 | return result.success |
| 110 | } |
| 111 | |
| 112 | // ==================== 联系人 ==================== |
| 113 | |
| 114 | getContacts(options?: ContactsFetchOptions): Promise<ContactsResponse> { |
| 115 | const params = new URLSearchParams() |
| 116 | if (options?.acceptStale) params.set('acceptStale', '1') |
| 117 | if (options?.timeRangePreset) params.set('timeRange', options.timeRangePreset) |
| 118 | if (options?.pool) params.set('pool', options.pool) |
| 119 | if (options?.page) params.set('page', String(options.page)) |
| 120 | if (options?.pageSize) params.set('pageSize', String(options.pageSize)) |
| 121 | if (options?.query) params.set('q', options.query) |
| 122 | const qs = params.toString() |
| 123 | return get(`/contacts${qs ? `?${qs}` : ''}`) |
| 124 | } |
| 125 | |
| 126 | getContactDetail(key: string, options?: ContactsFetchOptions): Promise<ContactDetailResponse> { |
nothing calls this directly
no outgoing calls
no test coverage detected