feat(08-07): create domain modules documents.js, auth.js, topics.js — CODE-04
- documents.js: 10 functions; fetchDocumentContent refactored to use fetchWithRetry - auth.js: 15 functions (login through getMyQuota) — import request from utils.js - topics.js: 5 functions — import request from utils.js - All functions copied verbatim from client.js; no consumer files modified
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
/**
|
||||
* Topics API — listing, creation, update, deletion, AI suggestion.
|
||||
*
|
||||
* Consumers: stores/topics.js
|
||||
*/
|
||||
|
||||
import { request } from './utils.js'
|
||||
|
||||
export function listTopics() {
|
||||
return request('/api/topics')
|
||||
}
|
||||
|
||||
export function createTopic({ name, description = '', color = '#6366f1' }) {
|
||||
return request('/api/topics', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ name, description, color }),
|
||||
})
|
||||
}
|
||||
|
||||
export function updateTopic(id, patch) {
|
||||
return request(`/api/topics/${id}`, {
|
||||
method: 'PATCH',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify(patch),
|
||||
})
|
||||
}
|
||||
|
||||
export function deleteTopic(id) {
|
||||
return request(`/api/topics/${id}`, { method: 'DELETE' })
|
||||
}
|
||||
|
||||
export function suggestTopics(documentId) {
|
||||
return request('/api/topics/suggest', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ document_id: documentId }),
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user