* 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 <zomars@me.com> * WIP Signed-off-by: Omar López <zomars@me.com> * WP Signed-off-by: Omar López <zomars@me.com> * 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 <zomars@me.com> * 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 <zomars@me.com> Co-authored-by: Udit Takkar <53316345+Udit-takkar@users.noreply.github.com>
49 lines
1.4 KiB
TypeScript
49 lines
1.4 KiB
TypeScript
import type { Prisma } from "@prisma/client";
|
|
import type { Credentials } from "google-auth-library";
|
|
|
|
import { CredentialRepository } from "./credential";
|
|
import { SelectedCalendarRepository } from "./selectedCalendar";
|
|
|
|
export class GoogleRepository {
|
|
static async createGoogleCalendarCredential({ userId, key }: { userId: number; key: Credentials }) {
|
|
return await CredentialRepository.create({
|
|
type: "google_calendar",
|
|
key,
|
|
userId,
|
|
appId: "google-calendar",
|
|
});
|
|
}
|
|
|
|
static async createGoogleMeetsCredential({ userId }: { userId: number }) {
|
|
return await CredentialRepository.create({
|
|
type: "google_video",
|
|
key: {},
|
|
userId,
|
|
appId: "google-meet",
|
|
});
|
|
}
|
|
|
|
static async createSelectedCalendar(data: { credentialId: number; userId: number; externalId: string }) {
|
|
return await SelectedCalendarRepository.create({
|
|
...data,
|
|
integration: "google_calendar",
|
|
});
|
|
}
|
|
|
|
static async upsertSelectedCalendar(
|
|
data: Omit<Prisma.SelectedCalendarUncheckedCreateInput, "integration">
|
|
) {
|
|
return await SelectedCalendarRepository.upsert({
|
|
...data,
|
|
integration: "google_calendar",
|
|
});
|
|
}
|
|
|
|
static async findGoogleMeetCredential({ userId }: { userId: number }) {
|
|
return await CredentialRepository.findFirstByUserIdAndType({
|
|
userId,
|
|
type: "google_video",
|
|
});
|
|
}
|
|
}
|