* refactor: apply biome formatting to packages/features (batch 1 - small subdirs) Format small subdirectories in packages/features: di, flags, holidays, oauth, settings, users, assignment-reason, selectedCalendar, hashedLink, host, form, form-builder, availability, data-table, pbac, schedules, troubleshooter, eventtypes, calendar-subscription, and root-level files. Also includes straggler apps/web BookEventForm.tsx. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * refactor: apply biome formatting to packages/features (batch 2 - medium subdirs) Format medium subdirectories in packages/features: auth, credentials, calendars, routing-forms, routing-trace, attributes, watchlist, calAIPhone, tasker, and webhooks. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * refactor: apply biome formatting to packages/features (batch 3 - bookings + insights) Format bookings and insights subdirectories in packages/features. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * refactor: apply biome formatting to packages/features (batch 4 - ee) Format packages/features/ee subdirectory covering billing, workflows, organizations, teams, managed-event-types, round-robin, dsync, integration-attribute-sync, and payments. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * refactor: apply biome formatting to packages/features (batch 5 - booking-audit part 1) Format booking-audit di, actions, common, dto, repository, and types subdirectories in packages/features/booking-audit. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * refactor: apply biome formatting to packages/features (batch 6 - booking-audit part 2) Format booking-audit service subdirectory in packages/features/booking-audit. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
53 lines
1.8 KiB
TypeScript
53 lines
1.8 KiB
TypeScript
import { ErrorWithCode } from "@calcom/lib/errors";
|
|
import { logger, schemaTask, type TaskWithSchema } from "@trigger.dev/sdk";
|
|
|
|
import type { WebhookTaskPayload } from "../../types/webhookTask";
|
|
import { webhookDeliveryTaskConfig } from "./config";
|
|
import { webhookDeliveryTaskSchema } from "./schema";
|
|
|
|
const WEBHOOK_DELIVERY_JOB_ID = "webhook.deliver" as const;
|
|
|
|
/**
|
|
* Trigger.dev task for webhook delivery
|
|
*
|
|
* This task is triggered by WebhookTriggerTasker and processes webhook
|
|
* delivery using the WebhookTaskConsumer from the DI container.
|
|
*
|
|
* The task:
|
|
* 1. Imports the DI container getter
|
|
* 2. Gets the WebhookTaskConsumer instance
|
|
* 3. Calls processWebhookTask with the payload
|
|
*
|
|
* Errors are logged and re-thrown to enable trigger.dev's retry mechanism.
|
|
*/
|
|
export const deliverWebhook: TaskWithSchema<
|
|
typeof WEBHOOK_DELIVERY_JOB_ID,
|
|
typeof webhookDeliveryTaskSchema
|
|
> = schemaTask({
|
|
id: WEBHOOK_DELIVERY_JOB_ID,
|
|
...webhookDeliveryTaskConfig,
|
|
schema: webhookDeliveryTaskSchema,
|
|
run: async (payload: WebhookTaskPayload, { ctx }) => {
|
|
const { getWebhookTaskConsumer } = await import("@calcom/features/di/webhooks/containers/webhook");
|
|
|
|
const webhookTaskConsumer = getWebhookTaskConsumer();
|
|
const taskId = ctx.run.id;
|
|
|
|
try {
|
|
await webhookTaskConsumer.processWebhookTask(payload, taskId);
|
|
logger.info("Webhook delivered successfully", { operationId: payload.operationId, taskId });
|
|
} catch (error) {
|
|
if (error instanceof Error || error instanceof ErrorWithCode) {
|
|
logger.error(error.message, { operationId: payload.operationId, taskId });
|
|
} else {
|
|
logger.error("Unknown error in webhook delivery", {
|
|
error,
|
|
operationId: payload.operationId,
|
|
taskId,
|
|
});
|
|
}
|
|
throw error;
|
|
}
|
|
},
|
|
});
|