feat: Populate gCal calendar cache via webhooks (#11928)

* WIP

* WIP

* WIP

* WIP

* WIP

* WIP

* WIP

* WIP

* WIP

* Update CalendarService.ts

* Type fixes

* WIP

* fix: improve cache hits

* Update CalendarService.ts

* Update CalendarService.ts

* Update CalendarService.ts

* Update CalendarService.ts

* Update CalendarService.ts

* Update CalendarService.ts

* Feedback

* Update CalendarService.ts

* Update CalendarService.ts

* Update _router.ts

* feedback

* WIP

* WIP

* Update schema.prisma

* feedback

* typefixes

* Update Calendar.d.ts

* fix: watches when adding a calendar

* Discard changes to packages/app-store/googlecalendar/api/add.ts

* WIP

Signed-off-by: Omar López <[email protected]>

* WIP

Signed-off-by: Omar López <[email protected]>

* WP

Signed-off-by: Omar López <[email protected]>

* Update calendar.ts

* Update calendar.ts

* Update callback.ts

* Update callback.ts

* Conflicts

* WIP

* WIP

* Update CalendarService.ts

* Cleanup

* Discard changes to packages/features/settings/layouts/SettingsLayout.tsx

* Update calendar-cache.repository.ts

* WIP

* Update getSelectedCalendarsToWatch.sql

* WIP

* Update CalendarService.ts

* Cleanup

* Discard changes to packages/app-store/googlecalendar/lib/CalendarService.ts

* Create CalendarService.wip.ts

* WIP

* Update CalendarService.ts

* Update getSelectedCalendarsToWatch.sql

* Delete CalendarService.wip.ts

* test updates

* cleanup

Signed-off-by: Omar López <[email protected]>

* Update CalendarService.test.ts

* Update CalendarService.ts

* type fixes

* Update OAuthManager.ts

* Update CalendarService.ts

* Almost there

* Update CalendarService.test.ts

* Update calendar.ts

* Update callback.ts

* Update toggleFeatureFlag.handler.ts

* fix: feedback

* Update getSelectedCalendarsToWatch.sql

* Fix unit tests

---------

Signed-off-by: Omar López <[email protected]>
Co-authored-by: Udit Takkar <[email protected]>
This commit is contained in:
Omar LópezandUdit Takkar authored and GitHub committed 2024-11-15 14:59:37 -03:00
1 parent 5012a16794
commit d294a74aad
40 files changed
+963 -240

No files matched your search

+18 -2
View File
@@ -1,4 +1,9 @@
import type { BookingSeat, DestinationCalendar, Prisma, SelectedCalendar } from "@prisma/client";
import type {
BookingSeat,
DestinationCalendar,
Prisma,
SelectedCalendar as _SelectedCalendar,
} from "@prisma/client";
import type { Dayjs } from "dayjs";
import type { calendar_v3 } from "googleapis";
import type { Time } from "ical.js";
@@ -231,7 +236,7 @@ export interface AdditionalInformation {
hangoutLink?: string;
}
export interface IntegrationCalendar extends Ensure<Partial<SelectedCalendar>, "externalId"> {
export interface IntegrationCalendar extends Ensure<Partial<_SelectedCalendar>, "externalId"> {
primary?: boolean;
name?: string;
readOnly?: boolean;
@@ -259,7 +264,13 @@ export interface Calendar {
selectedCalendars: IntegrationCalendar[]
): Promise<EventBusyDate[]>;
fetchAvailabilityAndSetCache?(selectedCalendars: IntegrationCalendar[]): Promise<unknown>;
listCalendars(event?: CalendarEvent): Promise<IntegrationCalendar[]>;
watchCalendar?(options: { calendarId: string }): Promise<unknown>;
unwatchCalendar?(options: { calendarId: string }): Promise<void>;
}
/**
@@ -268,3 +279,8 @@ export interface Calendar {
type Class<I, Args extends any[] = any[]> = new (...args: Args) => I;
export type CalendarClass = Class<Calendar, [CredentialPayload]>;
export type SelectedCalendar = Pick<
_SelectedCalendar,
"userId" | "integration" | "externalId" | "credentialId"
>;