@uplink-protocol/calendar-controller
Version:
Flexible calendar and time picker API supporting both calendar, date-picker, and time-picker integrations for any JavaScript framework or library
135 lines (134 loc) • 4.82 kB
TypeScript
import { IEventRecurrenceService, RecurrencePattern, RecurrenceBounds, RecurrenceException, RecurrenceExpansionOptions, RecurrenceAnalysis, CalendarSystemSettings, RecurrenceOccurrence, RecurrenceModificationOptions } from '../interfaces/event-recurrence.interfaces';
import { CalendarEvent, EventRecurrence } from '../interfaces/event.interfaces';
/**
* Implementation of event recurrence service
* Handles recurring event generation and management
*/
export declare class EventRecurrenceService implements IEventRecurrenceService {
private exceptions;
private calendarSettings?;
/**
* Initialize recurrence service
*/
initialize(calendarSettings?: CalendarSystemSettings): void;
/**
* Create recurrence pattern
*/
createPattern(_baseEvent: CalendarEvent, pattern: RecurrencePattern, bounds: RecurrenceBounds): EventRecurrence;
/**
* Expand recurrence into occurrences
*/
expandOccurrences(event: CalendarEvent, options: RecurrenceExpansionOptions): RecurrenceOccurrence[];
/**
* Expand recurrence into occurrences
*/
expandRecurrence(event: CalendarEvent, options: RecurrenceExpansionOptions): RecurrenceOccurrence[];
/**
* Get next occurrence
*/
getNextOccurrence(event: CalendarEvent, fromDate?: Date): RecurrenceOccurrence | null;
/**
* Get previous occurrence
*/
getPreviousOccurrence(event: CalendarEvent, fromDate?: Date): RecurrenceOccurrence | null;
/**
* Add exception to recurring event
*/
addException(masterEventId: string, exception: RecurrenceException): Promise<void>;
/**
* Remove exception
*/
removeException(masterEventId: string, exceptionDate: Date): Promise<void>;
/**
* Modify recurring event
*/
modifyRecurringEvent(eventId: string, changes: Partial<CalendarEvent>, options: RecurrenceModificationOptions): Promise<CalendarEvent[]>;
/**
* Delete recurring event
*/
deleteRecurringEvent(eventId: string, options: RecurrenceModificationOptions): Promise<void>;
/**
* Analyze recurrence pattern
*/
analyzeRecurrence(event: CalendarEvent): RecurrenceAnalysis;
/**
* Validate recurrence pattern
*/
validatePattern(pattern: RecurrencePattern, bounds?: RecurrenceBounds): {
isValid: boolean;
errors: string[];
warnings: string[];
};
/**
* Parse RRULE string
*/
parseRRule(rrule: string): RecurrencePattern;
/**
* Generate RRULE string
*/
generateRRule(pattern: RecurrencePattern, bounds: RecurrenceBounds): string;
/**
* Get human-readable description
*/
getRecurrenceDescription(pattern: RecurrencePattern, bounds: RecurrenceBounds, locale?: string): string;
/**
* Find conflicting occurrences
*/
findConflictingOccurrences(event: CalendarEvent, existingEvents: CalendarEvent[], startDate: Date, endDate: Date): Array<{
occurrence: RecurrenceOccurrence;
conflicts: CalendarEvent[];
}>;
/**
* Optimize recurrence pattern
*/
optimizePattern(pattern: RecurrencePattern): RecurrencePattern;
/**
* Get recurrence statistics
*/
getRecurrenceStats(events: CalendarEvent[]): {
totalRecurring: number;
averageOccurrences: number;
mostCommonPattern: string;
complexityDistribution: Record<string, number>;
};
/**
* Add missing method for tests - modifyOccurrence
*/
modifyOccurrence(eventId: string, occurrenceDate: Date, modifications: Partial<CalendarEvent>, options: RecurrenceModificationOptions): {
success: boolean;
modifiedEvents: CalendarEvent[];
splitEvent?: CalendarEvent;
};
/**
* Add missing method for tests - detectRecurrenceConflicts
*/
detectRecurrenceConflicts(event: CalendarEvent, existingEvents: CalendarEvent[]): Array<{
conflictingEvent: CalendarEvent;
occurrence: RecurrenceOccurrence;
}>;
/**
* Add missing method for tests - getRecurrenceStatistics
*/
getRecurrenceStatistics(event: CalendarEvent): {
totalDuration: number;
averageGapDays: number;
patternComplexity: number;
estimatedEndDate?: Date;
};
/**
* Add missing method for tests - isOccurrence
*/
isOccurrence(event: CalendarEvent, date: Date): boolean;
private mapPatternTypeToFrequency;
private mapEventRecurrenceToPattern;
private mapEventRecurrenceToBounds;
private matchesRecurrence;
private getNextDate;
private getPreviousDate;
private calculateFrequencyPerYear;
private calculateComplexityScore;
private parseDaysOfWeek;
private dayNumberToString;
private eventsOverlap;
private getIntervalInMs;
}