1739114490
* refactor: separate task creation from processing to eliminate compilation overhead - Create TaskProcessor class to handle task processing logic - Move processQueue and cleanup methods to TaskProcessor - Remove task handler imports from InternalTasker creation path - Eliminate 2.5-3s compilation overhead by only loading task handlers during processing - Maintain existing tasker.create() API for all callers - Use composition pattern for clean separation of concerns Co-Authored-By: keith@cal.com <keithwillcode@gmail.com> refactor: completely separate TaskProcessor from InternalTasker - Remove processQueue() and cleanup() methods from Tasker interface - Eliminate TaskProcessor dependency from InternalTasker class - Update API endpoints (cron.ts, cleanup.ts) to use TaskProcessor directly - Update README documentation to show correct TaskProcessor usage - Complete separation ensures task creation no longer imports task handlers - Eliminates 2.5-3s compilation overhead while preserving all functionality Co-Authored-By: keith@cal.com <keithwillcode@gmail.com> * Moved the cleanup method back to internal tasker --------- Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
49 lines
1.9 KiB
TypeScript
49 lines
1.9 KiB
TypeScript
import type { z } from "zod";
|
|
|
|
export type TaskerTypes = "internal" | "redis";
|
|
type TaskPayloads = {
|
|
sendEmail: string;
|
|
sendWebhook: string;
|
|
sendSms: string;
|
|
triggerHostNoShowWebhook: z.infer<
|
|
typeof import("./tasks/triggerNoShow/schema").ZSendNoShowWebhookPayloadSchema
|
|
>;
|
|
triggerGuestNoShowWebhook: z.infer<
|
|
typeof import("./tasks/triggerNoShow/schema").ZSendNoShowWebhookPayloadSchema
|
|
>;
|
|
triggerFormSubmittedNoEventWebhook: z.infer<
|
|
typeof import("./tasks/triggerFormSubmittedNoEvent/triggerFormSubmittedNoEventWebhook").ZTriggerFormSubmittedNoEventWebhookPayloadSchema
|
|
>;
|
|
translateEventTypeData: z.infer<
|
|
typeof import("./tasks/translateEventTypeData").ZTranslateEventDataPayloadSchema
|
|
>;
|
|
createCRMEvent: z.infer<typeof import("./tasks/crm/schema").createCRMEventSchema>;
|
|
sendWorkflowEmails: z.infer<typeof import("./tasks/sendWorkflowEmails").ZSendWorkflowEmailsSchema>;
|
|
scanWorkflowBody: z.infer<typeof import("./tasks/scanWorkflowBody").scanWorkflowBodySchema>;
|
|
sendAnalyticsEvent: z.infer<typeof import("./tasks/analytics/schema").sendAnalyticsEventSchema>;
|
|
executeAIPhoneCall: {
|
|
workflowReminderId: number;
|
|
agentId: string;
|
|
fromNumber: string;
|
|
toNumber: string;
|
|
bookingUid: string;
|
|
userId: number | null;
|
|
teamId: number | null;
|
|
providerAgentId: string;
|
|
};
|
|
};
|
|
export type TaskTypes = keyof TaskPayloads;
|
|
export type TaskHandler = (payload: string) => Promise<void>;
|
|
export type TaskerCreate = <TaskKey extends keyof TaskPayloads>(
|
|
type: TaskKey,
|
|
payload: TaskPayloads[TaskKey],
|
|
options?: { scheduledAt?: Date; maxAttempts?: number; referenceUid?: string }
|
|
) => Promise<string>;
|
|
export interface Tasker {
|
|
/** Create a new task with the given type and payload. */
|
|
create: TaskerCreate;
|
|
cleanup(): Promise<void>;
|
|
cancel(id: string): Promise<string>;
|
|
cancelWithReference(referenceUid: string, type: TaskTypes): Promise<string | null>;
|
|
}
|