import Koa from 'koa'; import 'koa-bodyparser'; declare const webhookRouter: any; /** * Label Studio Webhook Event Types */ export declare enum WebhookAction { ANNOTATION_CREATED = "ANNOTATION_CREATED", ANNOTATION_UPDATED = "ANNOTATION_UPDATED", ANNOTATION_DELETED = "ANNOTATION_DELETED", TASK_CREATED = "TASK_CREATED", TASK_UPDATED = "TASK_UPDATED", TASK_DELETED = "TASK_DELETED", PROJECT_UPDATED = "PROJECT_UPDATED" } export interface WebhookPayload { action: WebhookAction; project: { id: number; title: string; }; task?: { id: number; data: any; annotations: any[]; }; annotation?: { id: number; result: any[]; completed_by: { id: number; email: string; }; lead_time: number; }; } /** * Webhook handler function type * Applications can register custom handlers for any webhook action */ export type WebhookHandler = (payload: WebhookPayload, context: Koa.Context) => Promise; /** * Register a custom webhook handler * Handlers are executed in registration order * * @param action - Webhook action to handle * @param handler - Handler function * * @example * registerWebhookHandler(WebhookAction.ANNOTATION_CREATED, async (payload, ctx) => { * console.log('Custom handler:', payload.annotation?.id) * // Store annotation in database * // Trigger ML training * // Send notifications * }) */ export declare function registerWebhookHandler(action: WebhookAction, handler: WebhookHandler): void; /** * Unregister a webhook handler */ export declare function unregisterWebhookHandler(action: WebhookAction, handler: WebhookHandler): void; /** * Clear all custom handlers for an action */ export declare function clearWebhookHandlers(action?: WebhookAction): void; export { webhookRouter };