* init * wiring up * fix type * feat: implement DI pattern for webhook producer in API v2 - Export IWebhookProducerService and getWebhookProducer from platform-libraries - Add WEBHOOK_PRODUCER token and useFactory provider in RegularBookingModule - Inject webhookProducer in RegularBookingService and pass to base class This follows the composition root pattern where only the NestJS module knows about getWebhookProducer(), and all consumers depend only on the IWebhookProducerService interface via constructor injection. Co-Authored-By: ali@cal.com <alishahbaz7@gmail.com> * test: migrate BOOKING_REQUESTED tests to new webhook architecture - Remove failing BOOKING_REQUESTED tests from fresh-booking.test.ts (4 tests) - Remove failing BOOKING_REQUESTED tests from reschedule.test.ts (2 tests) - Remove failing BOOKING_REQUESTED test from collective-scheduling.test.ts (1 test) - Replace WebhookTaskConsumer.test.ts with placeholder (constructor changed) - Create new webhook architecture test suite: - producer/WebhookTaskerProducerService.test.ts (14 tests) - consumer/WebhookTaskConsumer.test.ts (8 tests) - consumer/triggers/booking-requested.test.ts (8 tests) The new test suite is organized by trigger type for extensibility as more triggers are migrated to the producer/consumer pattern. Co-Authored-By: ali@cal.com <alishahbaz7@gmail.com> * test: remove paid events BOOKING_REQUESTED test (moved to new architecture) Co-Authored-By: ali@cal.com <alishahbaz7@gmail.com> * wrap webhook in own try-catch * wire datafetcher * fix * fix v2 * fix circular dependency * -- * merge-conflict-resolve * mreg-conflict-resolve * remove early return * test: add integration tests for BOOKING_REQUESTED webhook producer invocation Cover all 8 scenarios verifying the booking flow correctly invokes the webhook producer for BOOKING_REQUESTED: 1. Basic confirmation → queueBookingRequestedWebhook called 2. Booker-is-organizer + confirmation → still called 3. Confirmation threshold NOT met → not called (BOOKING_CREATED instead) 4. Confirmation threshold IS met → called 5. Paid event + confirmation → called after payment succeeds 6. Reschedule + confirmation (non-organizer) → called (not BOOKING_RESCHEDULED) 7. Reschedule + confirmation (organizer) → not called (BOOKING_RESCHEDULED instead) 8. Collective scheduling + confirmation → called Adds reusable MockWebhookProducer helper in @calcom/testing for extendable use as more webhook triggers migrate to the new architecture. Co-Authored-By: ali@cal.com <alishahbaz7@gmail.com> * fix bug * fix conditional check * remove unnecessary comment * add missing expect * remove empty test * clean up * tasker config * -- * fix missing metadata * remove faulty if else * test: add payload content verification tests for BOOKING_REQUESTED webhook Co-Authored-By: ali@cal.com <alishahbaz7@gmail.com> * remove unnecessary tests --------- Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Co-authored-by: Hariom Balhara <1780212+hariombalhara@users.noreply.github.com>
44 lines
2.4 KiB
TypeScript
44 lines
2.4 KiB
TypeScript
import { moduleLoader as bookingEventHandlerModuleLoader } from "@calcom/features/bookings/di/BookingEventHandlerService.module";
|
|
import { RegularBookingService } from "@calcom/features/bookings/lib/service/RegularBookingService";
|
|
import { bindModuleToClassOnToken, createModule, type ModuleLoader } from "@calcom/features/di/di";
|
|
import { moduleLoader as bookingRepositoryModuleLoader } from "@calcom/features/di/modules/Booking";
|
|
import { moduleLoader as checkBookingAndDurationLimitsModuleLoader } from "@calcom/features/di/modules/CheckBookingAndDurationLimits";
|
|
import { moduleLoader as featuresRepositoryModuleLoader } from "@calcom/features/di/modules/FeaturesRepository";
|
|
import { moduleLoader as luckyUserServiceModuleLoader } from "@calcom/features/di/modules/LuckyUser";
|
|
import { moduleLoader as prismaModuleLoader } from "@calcom/features/di/modules/Prisma";
|
|
import { moduleLoader as userRepositoryModuleLoader } from "@calcom/features/di/modules/User";
|
|
import { DI_TOKENS } from "@calcom/features/di/tokens";
|
|
import { moduleLoader as webhookProducerModuleLoader } from "@calcom/features/di/webhooks/modules/WebhookProducerService.module";
|
|
import { moduleLoader as hashedLinkServiceModuleLoader } from "@calcom/features/hashedLink/di/HashedLinkService.module";
|
|
import { moduleLoader as bookingEmailAndSmsTaskerModuleLoader } from "./tasker/BookingEmailAndSmsTasker.module";
|
|
|
|
const thisModule = createModule();
|
|
const token = DI_TOKENS.REGULAR_BOOKING_SERVICE;
|
|
const moduleToken = DI_TOKENS.REGULAR_BOOKING_SERVICE_MODULE;
|
|
const loadModule = bindModuleToClassOnToken({
|
|
module: thisModule,
|
|
moduleToken,
|
|
token,
|
|
classs: RegularBookingService,
|
|
depsMap: {
|
|
// TODO: In a followup PR, we aim to remove prisma dependency and instead inject the repositories as dependencies.
|
|
prismaClient: prismaModuleLoader,
|
|
checkBookingAndDurationLimitsService: checkBookingAndDurationLimitsModuleLoader,
|
|
bookingRepository: bookingRepositoryModuleLoader,
|
|
luckyUserService: luckyUserServiceModuleLoader,
|
|
userRepository: userRepositoryModuleLoader,
|
|
hashedLinkService: hashedLinkServiceModuleLoader,
|
|
bookingEmailAndSmsTasker: bookingEmailAndSmsTaskerModuleLoader,
|
|
featuresRepository: featuresRepositoryModuleLoader,
|
|
bookingEventHandler: bookingEventHandlerModuleLoader,
|
|
webhookProducer: webhookProducerModuleLoader,
|
|
},
|
|
});
|
|
|
|
export const moduleLoader = {
|
|
token,
|
|
loadModule,
|
|
} satisfies ModuleLoader;
|
|
|
|
export type { RegularBookingService };
|