@forcecalendar/core 2.1.69 → 2.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,298 @@
1
+ /**
2
+ * DateUtils - Date manipulation utilities
3
+ * Pure functions, no external dependencies
4
+ * Locker Service compatible
5
+ */
6
+ export declare class DateUtils {
7
+ /**
8
+ * Get the start of a day
9
+ * @param {Date} date - The date
10
+ * @returns {Date}
11
+ */
12
+ static startOfDay(date: Date): Date;
13
+ /**
14
+ * Get the end of a day
15
+ * @param {Date} date - The date
16
+ * @returns {Date}
17
+ */
18
+ static endOfDay(date: Date): Date;
19
+ /**
20
+ * Get the start of a week
21
+ * @param {Date} date - The date
22
+ * @param {number} [weekStartsOn=0] - 0 = Sunday, 1 = Monday, etc.
23
+ * @returns {Date} Start of the week
24
+ */
25
+ static startOfWeek(date: Date, weekStartsOn?: number): Date;
26
+ /**
27
+ * Get the end of a week
28
+ * @param {Date} date - The date
29
+ * @param {number} weekStartsOn - 0 = Sunday, 1 = Monday, etc.
30
+ * @returns {Date}
31
+ */
32
+ static endOfWeek(date: Date, weekStartsOn?: number): Date;
33
+ /**
34
+ * Get the start of a month
35
+ * @param {Date} date - The date
36
+ * @returns {Date}
37
+ */
38
+ static startOfMonth(date: Date): Date;
39
+ /**
40
+ * Get the end of a month
41
+ * @param {Date} date - The date
42
+ * @returns {Date}
43
+ */
44
+ static endOfMonth(date: Date): Date;
45
+ /**
46
+ * Get the start of a year
47
+ * @param {Date} date - The date
48
+ * @returns {Date}
49
+ */
50
+ static startOfYear(date: Date): Date;
51
+ /**
52
+ * Get the end of a year
53
+ * @param {Date} date - The date
54
+ * @returns {Date}
55
+ */
56
+ static endOfYear(date: Date): Date;
57
+ /**
58
+ * Add days to a date
59
+ * @param {Date} date - The date
60
+ * @param {number} days - Number of days to add (can be negative)
61
+ * @returns {Date}
62
+ */
63
+ static addDays(date: Date, days: number): Date;
64
+ /**
65
+ * Add weeks to a date
66
+ * @param {Date} date - The date
67
+ * @param {number} weeks - Number of weeks to add
68
+ * @returns {Date}
69
+ */
70
+ static addWeeks(date: Date, weeks: number): Date;
71
+ /**
72
+ * Add months to a date
73
+ * @param {Date} date - The date
74
+ * @param {number} months - Number of months to add
75
+ * @returns {Date}
76
+ */
77
+ static addMonths(date: Date, months: number): Date;
78
+ /**
79
+ * Add years to a date
80
+ * @param {Date} date - The date
81
+ * @param {number} years - Number of years to add
82
+ * @returns {Date}
83
+ */
84
+ static addYears(date: Date, years: number): Date;
85
+ /**
86
+ * Get a consistent UTC date string for indexing (YYYY-MM-DD format)
87
+ * @param {Date} date - The date
88
+ * @returns {string} UTC date string
89
+ */
90
+ static getUTCDateString(date: Date): string;
91
+ /**
92
+ * Get a consistent local date string for indexing (YYYY-MM-DD format)
93
+ * @param {Date} date - The date
94
+ * @returns {string} Local date string
95
+ */
96
+ static getLocalDateString(date: Date): string;
97
+ /**
98
+ * Check if a date is today
99
+ * @param {Date} date - The date to check
100
+ * @returns {boolean}
101
+ */
102
+ static isToday(date: Date): boolean;
103
+ /**
104
+ * Check if a date is in the past
105
+ * @param {Date} date - The date to check
106
+ * @returns {boolean}
107
+ */
108
+ static isPast(date: Date): boolean;
109
+ /**
110
+ * Check if a date is in the future
111
+ * @param {Date} date - The date to check
112
+ * @returns {boolean}
113
+ */
114
+ static isFuture(date: Date): boolean;
115
+ /**
116
+ * Check if two dates are on the same day
117
+ * @param {Date} date1 - First date
118
+ * @param {Date} date2 - Second date
119
+ * @returns {boolean}
120
+ */
121
+ static isSameDay(date1: Date, date2: Date): boolean;
122
+ /**
123
+ * Check if two dates are in the same week
124
+ * @param {Date} date1 - First date
125
+ * @param {Date} date2 - Second date
126
+ * @param {number} weekStartsOn - 0 = Sunday, 1 = Monday, etc.
127
+ * @returns {boolean}
128
+ */
129
+ static isSameWeek(date1: Date, date2: Date, weekStartsOn?: number): boolean;
130
+ /**
131
+ * Check if two dates are in the same month
132
+ * @param {Date} date1 - First date
133
+ * @param {Date} date2 - Second date
134
+ * @returns {boolean}
135
+ */
136
+ static isSameMonth(date1: Date, date2: Date): boolean;
137
+ /**
138
+ * Check if two dates are in the same year
139
+ * @param {Date} date1 - First date
140
+ * @param {Date} date2 - Second date
141
+ * @returns {boolean}
142
+ */
143
+ static isSameYear(date1: Date, date2: Date): boolean;
144
+ /**
145
+ * Get the difference in days between two dates
146
+ * @param {Date} date1 - First date
147
+ * @param {Date} date2 - Second date
148
+ * @returns {number}
149
+ */
150
+ static differenceInDays(date1: Date, date2: Date): number;
151
+ /**
152
+ * Get the difference in weeks between two dates
153
+ * @param {Date} date1 - First date
154
+ * @param {Date} date2 - Second date
155
+ * @returns {number}
156
+ */
157
+ static differenceInWeeks(date1: Date, date2: Date): number;
158
+ /**
159
+ * Get the difference in months between two dates
160
+ * @param {Date} date1 - First date
161
+ * @param {Date} date2 - Second date
162
+ * @returns {number}
163
+ */
164
+ static differenceInMonths(date1: Date, date2: Date): number;
165
+ /**
166
+ * Get the week number of a date
167
+ * @param {Date} date - The date
168
+ * @returns {number}
169
+ */
170
+ static getWeekNumber(date: Date): number;
171
+ /**
172
+ * Get the day of week for a date
173
+ * @param {Date} date - The date
174
+ * @param {number} weekStartsOn - 0 = Sunday, 1 = Monday, etc.
175
+ * @returns {number} 0-6 where 0 is the first day of the week
176
+ */
177
+ static getDayOfWeek(date: Date, weekStartsOn?: number): number;
178
+ /**
179
+ * Get days in a month
180
+ * @param {Date} date - Any date in the month
181
+ * @returns {number}
182
+ */
183
+ static getDaysInMonth(date: Date): number;
184
+ /**
185
+ * Format a date using Intl.DateTimeFormat
186
+ * @param {Date} date - The date to format
187
+ * @param {string} locale - The locale
188
+ * @param {Object} options - Intl.DateTimeFormat options
189
+ * @returns {string}
190
+ */
191
+ static format(date: Date, locale?: string, options?: Object): string;
192
+ /**
193
+ * Get month name
194
+ * @param {Date} date - The date
195
+ * @param {string} locale - The locale
196
+ * @param {string} format - 'long', 'short', or 'narrow'
197
+ * @returns {string}
198
+ */
199
+ static getMonthName(date: Date, locale?: string, format?: string): string;
200
+ /**
201
+ * Get day name
202
+ * @param {Date} date - The date
203
+ * @param {string} locale - The locale
204
+ * @param {string} format - 'long', 'short', or 'narrow'
205
+ * @returns {string}
206
+ */
207
+ static getDayName(date: Date, locale?: string, format?: string): string;
208
+ /**
209
+ * Format time
210
+ * @param {Date} date - The date
211
+ * @param {string} locale - The locale
212
+ * @param {boolean} use24Hour - Use 24-hour format
213
+ * @returns {string}
214
+ */
215
+ static formatTime(date: Date, locale?: string, use24Hour?: boolean): string;
216
+ /**
217
+ * Parse a time string (HH:MM) to hours and minutes
218
+ * @param {string} timeString - Time string like "09:30"
219
+ * @returns {{hours: number, minutes: number}}
220
+ */
221
+ static parseTime(timeString: string): {
222
+ hours: number;
223
+ minutes: number;
224
+ };
225
+ /**
226
+ * Set time on a date
227
+ * @param {Date} date - The date
228
+ * @param {string} timeString - Time string like "09:30"
229
+ * @returns {Date}
230
+ */
231
+ static setTime(date: Date, timeString: string): Date;
232
+ /**
233
+ * Check if a year is a leap year
234
+ * @param {number} year - The year
235
+ * @returns {boolean}
236
+ */
237
+ static isLeapYear(year: number): boolean;
238
+ /**
239
+ * Get an array of dates between start and end
240
+ * @param {Date} start - Start date
241
+ * @param {Date} end - End date
242
+ * @returns {Date[]}
243
+ */
244
+ static getDateRange(start: Date, end: Date): Date[];
245
+ /**
246
+ * Clone a date
247
+ * @param {Date} date - The date to clone
248
+ * @returns {Date}
249
+ */
250
+ static clone(date: Date): Date;
251
+ /**
252
+ * Validate if a value is a valid date
253
+ * @param {*} value - Value to check
254
+ * @returns {boolean}
255
+ */
256
+ static isValidDate(value: any): boolean;
257
+ /**
258
+ * Convert a date to a specific timezone
259
+ * @param {Date} date - The date to convert
260
+ * @param {string} timeZone - IANA timezone string (e.g., 'America/New_York')
261
+ * @returns {Date} - Date object adjusted for timezone
262
+ */
263
+ static toTimeZone(date: Date, timeZone: string): Date;
264
+ /**
265
+ * Get timezone offset in minutes for a date
266
+ * @param {Date} date - The date
267
+ * @param {string} timeZone - IANA timezone string
268
+ * @returns {number} - Offset in minutes
269
+ */
270
+ static getTimezoneOffset(date: Date, timeZone: string): number;
271
+ /**
272
+ * Check if DST is in effect for a date in a timezone
273
+ * @param {Date} date - The date to check
274
+ * @param {string} timeZone - IANA timezone string
275
+ * @returns {boolean}
276
+ */
277
+ static isDST(date: Date, timeZone: string): boolean;
278
+ /**
279
+ * Add time accounting for DST transitions
280
+ * @param {Date} date - The date
281
+ * @param {number} hours - Hours to add
282
+ * @param {string} timeZone - IANA timezone string
283
+ * @returns {Date}
284
+ */
285
+ static addHoursWithDST(date: Date, hours: number, _timeZone: any): Date;
286
+ /**
287
+ * Create a date in a specific timezone
288
+ * @param {number} year
289
+ * @param {number} month - 0-indexed
290
+ * @param {number} day
291
+ * @param {number} hour
292
+ * @param {number} minute
293
+ * @param {number} second
294
+ * @param {string} timeZone - IANA timezone string
295
+ * @returns {Date}
296
+ */
297
+ static createInTimeZone(year: number, month: number, day: number, hour: number | undefined, minute: number | undefined, second: number | undefined, timeZone: string): Date;
298
+ }
@@ -0,0 +1,103 @@
1
+ /**
2
+ * ConflictDetector - Detects scheduling conflicts between events
3
+ * Checks for time overlaps, attendee conflicts, and resource conflicts
4
+ */
5
+ export declare class ConflictDetector {
6
+ eventStore: import("../index.js").EventStore;
7
+ conflictIdCounter: number;
8
+ /**
9
+ * Create a new ConflictDetector
10
+ * @param {import('../events/EventStore.js').EventStore} eventStore - Event store instance
11
+ */
12
+ constructor(eventStore: import('../events/EventStore.js').EventStore);
13
+ /**
14
+ * Check for conflicts for a specific event
15
+ * @param {import('../events/Event.js').Event|import('../types.js').EventData} event - Event to check
16
+ * @param {import('../types.js').ConflictCheckOptions} [options={}] - Check options
17
+ * @returns {import('../types.js').ConflictSummary} Conflict summary
18
+ */
19
+ checkConflicts(event: import('../events/Event.js').Event | import('../types.js').EventData, options?: import('../types.js').ConflictCheckOptions): import('../types.js').ConflictSummary;
20
+ /**
21
+ * Check for conflicts between two specific events
22
+ * @param {import('../events/Event.js').Event} event1 - First event
23
+ * @param {import('../events/Event.js').Event} event2 - Second event
24
+ * @param {import('../types.js').ConflictCheckOptions} [options={}] - Check options
25
+ * @returns {import('../types.js').ConflictDetails[]} Array of conflicts
26
+ */
27
+ checkEventPairConflicts(event1: import('../events/Event.js').Event, event2: import('../events/Event.js').Event, options?: import('../types.js').ConflictCheckOptions): import('../types.js').ConflictDetails[];
28
+ /**
29
+ * Get busy periods for a set of attendees
30
+ * @param {string[]} attendeeEmails - Attendee email addresses
31
+ * @param {Date} start - Start of period
32
+ * @param {Date} end - End of period
33
+ * @param {Object} [options={}] - Options
34
+ * @returns {Array<{start: Date, end: Date, eventIds: string[]}>} Busy periods
35
+ */
36
+ getBusyPeriods(attendeeEmails: string[], start: Date, end: Date, options?: Object): Array<{
37
+ start: Date;
38
+ end: Date;
39
+ eventIds: string[];
40
+ }>;
41
+ /**
42
+ * Get free time slots
43
+ * @param {Date} start - Start of search period
44
+ * @param {Date} end - End of search period
45
+ * @param {number} duration - Required duration in minutes
46
+ * @param {Object} [options={}] - Options
47
+ * @returns {Array<{start: Date, end: Date}>} Free time slots
48
+ */
49
+ getFreePeriods(start: Date, end: Date, duration: number, options?: Object): Array<{
50
+ start: Date;
51
+ end: Date;
52
+ }>;
53
+ /**
54
+ * Detect conflicts between two events
55
+ * @private
56
+ */
57
+ private _detectEventConflicts;
58
+ /**
59
+ * Check for time overlap between events
60
+ * @private
61
+ */
62
+ private _checkTimeOverlap;
63
+ /**
64
+ * Create time conflict details
65
+ * @private
66
+ */
67
+ private _createTimeConflict;
68
+ /**
69
+ * Check for attendee conflicts
70
+ * @private
71
+ */
72
+ private _checkAttendeeConflicts;
73
+ /**
74
+ * Check for resource conflicts
75
+ * @private
76
+ */
77
+ private _checkResourceConflicts;
78
+ /**
79
+ * Check for location conflicts
80
+ * @private
81
+ */
82
+ private _checkLocationConflict;
83
+ /**
84
+ * Build conflict summary
85
+ * @private
86
+ */
87
+ private _buildConflictSummary;
88
+ /**
89
+ * Merge overlapping busy periods
90
+ * @private
91
+ */
92
+ private _mergeBusyPeriods;
93
+ /**
94
+ * Get all busy periods
95
+ * @private
96
+ */
97
+ private _getAllBusyPeriods;
98
+ /**
99
+ * Check if time period is within business hours
100
+ * @private
101
+ */
102
+ private _isWithinBusinessHours;
103
+ }