Files
calendar/packages/features/tasker/tasker.ts
T
2f4dd328c3 feat: new webhook 'Form submitted, no event booked' (#17119)
* add new webhook

* schedule trigger functions

* implement tasker

* fix type errors

* add tests

* remove unused code

* finish tests

* remove unsued code from debugging

* Fix: client-server mixed exports

* Update tasker.ts

---------

Co-authored-by: CarinaWolli <wollencarina@gmail.com>
Co-authored-by: zomars <zomars@me.com>
2024-10-22 03:38:33 +00:00

31 lines
1.1 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
>;
};
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 }
) => Promise<string>;
export interface Tasker {
/** Create a new task with the given type and payload. */
create: TaskerCreate;
processQueue(): Promise<void>;
cleanup(): Promise<void>;
}