@luckydye/calendar 1.3.2 → 1.4.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.
@@ -1,5 +1,8 @@
1
+ import type {
2
+ CalendarCredentials,
3
+ CalendarSource,
4
+ } from "./CalendarIntegration.js";
1
5
  import type { CalendarEvent } from "./CalendarInternal.js";
2
- import type { CalendarSource, CalendarCredentials } from "./CalendarIntegration.js";
3
6
 
4
7
  /**
5
8
  * In-memory calendar source for testing event creation and moving.
@@ -17,58 +20,63 @@ import type { CalendarSource, CalendarCredentials } from "./CalendarIntegration.
17
20
  * await integration.sync(source);
18
21
  */
19
22
  export class InMemorySource implements CalendarSource {
20
- readonly type = 'in-memory';
21
- readonly credentials: CalendarCredentials = {};
22
- events: Map<string, CalendarEvent> = new Map();
23
+ readonly type = "in-memory";
24
+ readonly credentials: CalendarCredentials = {};
25
+ events: Map<string, CalendarEvent> = new Map();
23
26
 
24
- constructor(
25
- public id: string,
26
- public name: string,
27
- public color: string = '#3b82f6',
28
- public enabled: boolean = true
29
- ) {}
27
+ constructor(
28
+ public id: string,
29
+ public name: string,
30
+ public color = "#3b82f6",
31
+ public enabled = true,
32
+ ) {}
30
33
 
31
- async fetchEvents(): Promise<CalendarEvent[]> {
32
- return Array.from(this.events.values());
33
- }
34
+ async fetchEvents(): Promise<CalendarEvent[]> {
35
+ return Array.from(this.events.values());
36
+ }
34
37
 
35
- async createEvent(event: Omit<CalendarEvent, 'calendar' | 'color'>): Promise<CalendarEvent> {
36
- const newEvent: CalendarEvent = {
37
- ...event,
38
- calendar: this.name,
39
- calendarId: this.id,
40
- sourceId: this.id,
41
- color: this.color,
42
- };
43
- this.events.set(newEvent.id, newEvent);
44
- return newEvent;
45
- }
38
+ async createEvent(
39
+ event: Omit<CalendarEvent, "calendar" | "color">,
40
+ ): Promise<CalendarEvent> {
41
+ const newEvent: CalendarEvent = {
42
+ ...event,
43
+ calendar: this.name,
44
+ calendarId: this.id,
45
+ sourceId: this.id,
46
+ color: this.color,
47
+ };
48
+ this.events.set(newEvent.id, newEvent);
49
+ return newEvent;
50
+ }
46
51
 
47
- async updateEvent(event: CalendarEvent, updates: Partial<CalendarEvent>): Promise<CalendarEvent> {
48
- const existing = this.events.get(event.id);
49
- if (!existing) {
50
- throw new Error(`Event ${event.id} not found`);
51
- }
52
+ async updateEvent(
53
+ event: CalendarEvent,
54
+ updates: Partial<CalendarEvent>,
55
+ ): Promise<CalendarEvent> {
56
+ const existing = this.events.get(event.id);
57
+ if (!existing) {
58
+ throw new Error(`Event ${event.id} not found`);
59
+ }
52
60
 
53
- const updated = {
54
- ...existing,
55
- ...updates,
56
- };
57
- this.events.set(event.id, updated);
58
- return updated;
59
- }
61
+ const updated = {
62
+ ...existing,
63
+ ...updates,
64
+ };
65
+ this.events.set(event.id, updated);
66
+ return updated;
67
+ }
60
68
 
61
- async deleteEvent(id: string): Promise<void> {
62
- const deleted = this.events.delete(id);
63
- if (!deleted) {
64
- throw new Error(`Event ${id} not found`);
65
- }
66
- }
69
+ async deleteEvent(id: string): Promise<void> {
70
+ const deleted = this.events.delete(id);
71
+ if (!deleted) {
72
+ throw new Error(`Event ${id} not found`);
73
+ }
74
+ }
67
75
 
68
- /**
69
- * Clears all events.
70
- */
71
- clear(): void {
72
- this.events.clear();
73
- }
76
+ /**
77
+ * Clears all events.
78
+ */
79
+ clear(): void {
80
+ this.events.clear();
81
+ }
74
82
  }