feat(delivery): stream task updates with SSE

This commit is contained in:
mac
2026-07-28 09:55:04 +08:00
parent 7b4b9d2ee7
commit 5a260c443f
5 changed files with 168 additions and 4 deletions
+13
View File
@@ -72,6 +72,11 @@ export interface TaskEvent {
created_at: string
}
export interface DeliveryTaskSnapshot {
task: DeliveryTask
events: TaskEvent[]
}
export const deliveryApi = {
async listTargets(): Promise<DeliveryTarget[]> {
const data = await authRequest('/auth/api/v1/delivery/targets?component=mysql')
@@ -112,6 +117,14 @@ export const deliveryApi = {
method: 'POST',
})
},
streamTask(taskId: string): EventSource {
const token = getToken()
const search = new URLSearchParams()
if (token) search.set('access_token', token)
const query = search.toString()
return new EventSource(`/auth/api/v1/delivery/tasks/${encodeURIComponent(taskId)}/stream${query ? `?${query}` : ''}`)
},
}
function createIdempotencyKey(payload: CreateMySQLDeliveryPayload) {