feat(delivery): stream task updates with SSE
This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user