Files
calendar/packages/features/calendars/lib/tasker/trigger/ensure-default-calendars.ts
T
MorganGitHubmorgan@cal.com <morgan@cal.com>unknown <>morgan@cal.com <morgan@cal.com>morgan@cal.com <morgan@cal.com>Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
62216f2db6 feat: add CalendarsTasker with sync and trigger.dev versions (#26854)
* 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>
2026-01-19 16:20:05 +02:00

25 lines
855 B
TypeScript

import { schemaTask, type TaskWithSchema } from "@trigger.dev/sdk";
import type { z } from "zod";
import { calendarsTaskConfig } from "./config";
import { calendarsTaskSchema } from "./schema";
export const ENSURE_DEFAULT_CALENDARS_JOB_ID = "calendars.ensure-default-calendars";
export const ensureDefaultCalendars: TaskWithSchema<
typeof ENSURE_DEFAULT_CALENDARS_JOB_ID,
typeof calendarsTaskSchema
> = schemaTask({
id: ENSURE_DEFAULT_CALENDARS_JOB_ID,
...calendarsTaskConfig,
schema: calendarsTaskSchema,
run: async (payload: z.infer<typeof calendarsTaskSchema>) => {
const { getCalendarsTaskService } = await import(
"@calcom/features/calendars/di/tasker/CalendarsTaskService.container"
);
const calendarsTaskService = getCalendarsTaskService();
await calendarsTaskService.ensureDefaultCalendars(payload);
},
});