* feat: add CalendarsTasker with sync and trigger.dev versions This PR implements a CalendarsTasker following the same pattern as PlatformOrganizationBillingTasker to replace the logic in apps/api/v2/src/ee/calendars/processors/calendars.processor.ts New files created: - CalendarsTasker main orchestrator extending Tasker base class - CalendarsSyncTasker for sync execution - CalendarsTriggerTasker for async execution via trigger.dev - CalendarsTaskService with business logic for ensuring default calendars - trigger.dev task with queue config and retry settings - DI modules using @evyweb/ioctopus - NestJS DI modules for API v2 Co-Authored-By: morgan@cal.com <morgan@cal.com> * fix: import and deasync * style: format trigger.config.ts dirs array Co-Authored-By: unknown <> * refactor: move prisma query to UserRepository and set onboarding to true Co-Authored-By: morgan@cal.com <morgan@cal.com> * refactor: remove credential.key from UserRepository method Co-Authored-By: morgan@cal.com <morgan@cal.com> --------- Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
44 lines
1.4 KiB
TypeScript
44 lines
1.4 KiB
TypeScript
import { Tasker } from "@calcom/lib/tasker/Tasker";
|
|
import type { ILogger } from "@calcom/lib/tasker/types";
|
|
import type { TriggerOptions } from "@trigger.dev/sdk";
|
|
import type { CalendarsSyncTasker } from "./CalendarsSyncTasker";
|
|
import type { CalendarsTriggerTasker } from "./CalendarsTriggerTasker";
|
|
import type { ICalendarsTasker, CalendarsTaskPayload } from "./types";
|
|
|
|
export interface ICalendarsTaskerDependencies {
|
|
asyncTasker: CalendarsTriggerTasker;
|
|
syncTasker: CalendarsSyncTasker;
|
|
logger: ILogger;
|
|
}
|
|
|
|
export class CalendarsTasker extends Tasker<ICalendarsTasker> {
|
|
constructor(public readonly dependencies: ICalendarsTaskerDependencies) {
|
|
super(dependencies);
|
|
}
|
|
|
|
public async ensureDefaultCalendars(data: {
|
|
payload: CalendarsTaskPayload;
|
|
options?: TriggerOptions;
|
|
}): Promise<{ runId: string }> {
|
|
const { payload } = data;
|
|
let taskResponse: {
|
|
runId: string;
|
|
} = { runId: "task-not-found" };
|
|
|
|
try {
|
|
taskResponse = await this.dispatch("ensureDefaultCalendars", payload, data.options);
|
|
|
|
this.logger.info(`CalendarsTasker ensureDefaultCalendars success:`, taskResponse, {
|
|
userId: payload.userId,
|
|
});
|
|
} catch {
|
|
taskResponse = { runId: "task-failed" };
|
|
this.logger.error(`CalendarsTasker ensureDefaultCalendars failed`, taskResponse, {
|
|
userId: payload.userId,
|
|
});
|
|
}
|
|
|
|
return taskResponse;
|
|
}
|
|
}
|