@checkfirst/nestjs-outlook
Version:
An opinionated NestJS module for Microsoft Outlook integration that provides easy access to Microsoft Graph API for emails, calendars, and more.
58 lines (57 loc) • 3.3 kB
TypeScript
import { EventEmitter2 } from "@nestjs/event-emitter";
import { Client } from "@microsoft/microsoft-graph-client";
import { Event, Subscription, ChangeNotification } from "../../types";
import { MicrosoftAuthService } from "../auth/microsoft-auth.service";
import { OutlookWebhookSubscriptionRepository } from "../../repositories/outlook-webhook-subscription.repository";
import { OutlookDeltaLinkRepository } from "../../repositories/outlook-delta-link.repository";
import { MicrosoftOutlookConfig } from "../../interfaces/config/outlook-config.interface";
import { MicrosoftUser } from "../../entities/microsoft-user.entity";
import { Repository } from "typeorm";
import { DeltaSyncService } from "../shared/delta-sync.service";
export declare class CalendarService {
private readonly microsoftAuthService;
private readonly webhookSubscriptionRepository;
private readonly eventEmitter;
private readonly microsoftConfig;
private readonly deltaLinkRepository;
private readonly microsoftUserRepository;
private readonly deltaSyncService;
private readonly logger;
private readonly syncLocks;
constructor(microsoftAuthService: MicrosoftAuthService, webhookSubscriptionRepository: OutlookWebhookSubscriptionRepository, eventEmitter: EventEmitter2, microsoftConfig: MicrosoftOutlookConfig, deltaLinkRepository: OutlookDeltaLinkRepository, microsoftUserRepository: Repository<MicrosoftUser>, deltaSyncService: DeltaSyncService);
getDefaultCalendarId(externalUserId: string): Promise<string>;
createEvent(event: Partial<Event>, externalUserId: string, calendarId: string): Promise<{
event: Event;
}>;
deleteEvent(event: Partial<Event>, externalUserId: string, calendarId: string): Promise<void>;
createWebhookSubscription(externalUserId: string): Promise<Subscription>;
renewWebhookSubscription(subscriptionId: string, externalUserId: string): Promise<Subscription>;
renewWebhookSubscriptionByUserId(subscriptionId: string, internalUserId: number | string): Promise<Subscription>;
deleteWebhookSubscription(subscriptionId: string, externalUserId: string): Promise<boolean>;
renewSubscriptions(): Promise<void>;
handleOutlookWebhook(notificationItem: ChangeNotification, useStreaming?: boolean): Promise<{
success: boolean;
message: string;
}>;
fetchAndSortChanges(externalUserId: string, forceReset?: boolean, dateRange?: {
startDate: Date;
endDate: Date;
}): Promise<Event[]>;
streamCalendarChanges(externalUserId: string, forceReset?: boolean, dateRange?: {
startDate: Date;
endDate: Date;
}, saveDeltaLink?: boolean): AsyncGenerator<Event[], void, unknown>;
getAuthenticatedClient(externalUserId: string): Promise<Client>;
getEventDetails(resource: string, externalUserId: string): Promise<Event | null>;
importEventsStream(externalUserId: string, options?: {
startDate?: Date;
endDate?: Date;
batchSize?: number;
}): AsyncGenerator<Event[], void, unknown>;
initializeDeltaSync(externalUserId: string): Promise<void>;
private processChangesStreaming;
private processChangesBuffering;
private processDeltaEventChange;
private validateWebhookSubscription;
private buildRequestUrl;
}