feat: add webhook versioning (#23861)

* add webhook version schema

* version the code

* update version from numeric to date val

* migration

* update schema and build factory

* update string

* move version picker

* tooltip instead of infobadge

* --

* fix type

* --

* fix type

* fix type

* --

* fix messed up merge

* improvements to payloadfactory

* extract version off of DB and instead keep it in IWebhookRepository

* fix webhookform

* fix type safety and routing ambiguity

* scalable with easier factory extensions and base definition

* fix types

* --

* --

* clean up prisma/client type imports

* fix

* type fix

* type fix

* cleanup

* add tests and registry changes

* unintended file inclusion

* type-fix

* select in repo

* --

* explicit return type

* --

* fix type

* fixes

* feedback 1

* feedback 2

* use enum instead of string

* fixes
This commit is contained in:
Syed Ali Shahbaz authored and GitHub committed 2025-12-18 09:36:22 +02:00
1 parent 42bd4b4057
commit 056922b6ee
71 files changed
+3319 -1002

No files matched your search

@@ -1,11 +1,6 @@
import { createModule } from "@evyweb/ioctopus";
import { BookingPayloadBuilder } from "@calcom/features/webhooks/lib/factory/BookingPayloadBuilder";
import { FormPayloadBuilder } from "@calcom/features/webhooks/lib/factory/FormPayloadBuilder";
import { InstantMeetingBuilder } from "@calcom/features/webhooks/lib/factory/InstantMeetingBuilder";
import { MeetingPayloadBuilder } from "@calcom/features/webhooks/lib/factory/MeetingPayloadBuilder";
import { OOOPayloadBuilder } from "@calcom/features/webhooks/lib/factory/OOOPayloadBuilder";
import { RecordingPayloadBuilder } from "@calcom/features/webhooks/lib/factory/RecordingPayloadBuilder";
import { createPayloadBuilderFactory } from "@calcom/features/webhooks/lib/factory/versioned/registry";
import { WebhookRepository } from "@calcom/features/webhooks/lib/repository/WebhookRepository";
import { BookingWebhookService } from "@calcom/features/webhooks/lib/service/BookingWebhookService";
import { FormWebhookService } from "@calcom/features/webhooks/lib/service/FormWebhookService";
@@ -54,25 +49,15 @@ webhookModule
SHARED_TOKENS.LOGGER,
]);
// Bind payload builders
webhookModule.bind(WEBHOOK_TOKENS.BOOKING_PAYLOAD_BUILDER).toClass(BookingPayloadBuilder);
webhookModule.bind(WEBHOOK_TOKENS.FORM_PAYLOAD_BUILDER).toClass(FormPayloadBuilder);
webhookModule.bind(WEBHOOK_TOKENS.OOO_PAYLOAD_BUILDER).toClass(OOOPayloadBuilder);
webhookModule.bind(WEBHOOK_TOKENS.RECORDING_PAYLOAD_BUILDER).toClass(RecordingPayloadBuilder);
webhookModule.bind(WEBHOOK_TOKENS.MEETING_PAYLOAD_BUILDER).toClass(MeetingPayloadBuilder);
webhookModule.bind(WEBHOOK_TOKENS.INSTANT_MEETING_BUILDER).toClass(InstantMeetingBuilder);
// Bind payload builder factory (composition root for versioning)
webhookModule.bind(WEBHOOK_TOKENS.PAYLOAD_BUILDER_FACTORY).toFactory(() => createPayloadBuilderFactory());
// Bind notification handler
// Bind notification handler with factory
webhookModule
.bind(WEBHOOK_TOKENS.WEBHOOK_NOTIFICATION_HANDLER)
.toClass(WebhookNotificationHandler, [
WEBHOOK_TOKENS.WEBHOOK_SERVICE,
WEBHOOK_TOKENS.BOOKING_PAYLOAD_BUILDER,
WEBHOOK_TOKENS.FORM_PAYLOAD_BUILDER,
WEBHOOK_TOKENS.OOO_PAYLOAD_BUILDER,
WEBHOOK_TOKENS.RECORDING_PAYLOAD_BUILDER,
WEBHOOK_TOKENS.MEETING_PAYLOAD_BUILDER,
WEBHOOK_TOKENS.INSTANT_MEETING_BUILDER,
WEBHOOK_TOKENS.PAYLOAD_BUILDER_FACTORY,
SHARED_TOKENS.LOGGER,
]);