@sprucelabs/spruce-calendar-components 28.1.48 → 28.2.26
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.
- package/build/.spruce/schemas/schemas.types.d.ts +592 -352
- package/build/__tests__/support/CalendarToolBeltStateMachineTestFactory.d.ts +3 -1
- package/build/__tests__/support/CalendarToolBeltStateMachineTestFactory.js +4 -0
- package/build/__tests__/support/SpyEventManager.d.ts +5 -5
- package/build/calendar/CalendarEventManager.d.ts +9 -1
- package/build/calendar/CalendarEventManager.js +45 -3
- package/build/calendar/CalendarPeopleManager.d.ts +1 -1
- package/build/calendar/CalendarPersister.d.ts +1 -1
- package/build/esm/.spruce/schemas/schemas.types.d.ts +592 -352
- package/build/esm/__tests__/support/CalendarToolBeltStateMachineTestFactory.d.ts +3 -1
- package/build/esm/__tests__/support/CalendarToolBeltStateMachineTestFactory.js +6 -0
- package/build/esm/__tests__/support/SpyEventManager.d.ts +5 -5
- package/build/esm/calendar/CalendarEventManager.d.ts +9 -1
- package/build/esm/calendar/CalendarEventManager.js +51 -4
- package/build/esm/calendar/CalendarPeopleManager.d.ts +1 -1
- package/build/esm/calendar/CalendarPersister.d.ts +1 -1
- package/build/esm/{skillViewControllers → root}/Root.svc.js +7 -4
- package/build/esm/stores/RemoteEventStore.d.ts +13 -2
- package/build/esm/stores/RemoteEventStore.js +33 -12
- package/build/esm/toolBelt/CalendarToolRegistrar.js +1 -1
- package/build/esm/tools/EventDateTimeTool.vc.js +2 -2
- package/build/esm/types/calendar.types.d.ts +3 -0
- package/build/{skillViewControllers → root}/Root.svc.js +6 -3
- package/build/stores/RemoteEventStore.d.ts +13 -2
- package/build/stores/RemoteEventStore.js +20 -3
- package/build/toolBelt/CalendarToolRegistrar.js +1 -1
- package/build/tools/EventDateTimeTool.vc.js +2 -2
- package/build/types/calendar.types.d.ts +3 -0
- package/package.json +5 -5
- /package/build/esm/{skillViewControllers → root}/Root.svc.d.ts +0 -0
- /package/build/{skillViewControllers → root}/Root.svc.d.ts +0 -0
|
@@ -4,7 +4,7 @@ import { ViewFixture } from '@sprucelabs/spruce-test-fixtures';
|
|
|
4
4
|
import CalendarViewController from '../../calendar/Calendar.vc';
|
|
5
5
|
import CalendarEventManager, { CalendarEventManagerOptions, EventManagerCalendarVc } from '../../calendar/CalendarEventManager';
|
|
6
6
|
import { PeopleManagerCalendarVc } from '../../calendar/CalendarPeopleManager';
|
|
7
|
-
import { GetScheduleOptions, RemoteEventStore } from '../../stores/RemoteEventStore';
|
|
7
|
+
import { GetScheduleOptions, RemoteEventStore, SendScheduleOptions, StreamHandler } from '../../stores/RemoteEventStore';
|
|
8
8
|
import { Calendar, CalendarToolBeltStateMachine, UpdateEvent } from '../../types/calendar.types';
|
|
9
9
|
import SpyEventManager from './SpyEventManager';
|
|
10
10
|
export default class CalendarToolBeltStateMachineTestFactory {
|
|
@@ -35,6 +35,8 @@ export declare class FakeRemoteEventStore implements RemoteEventStore {
|
|
|
35
35
|
getSchedules(_options: GetScheduleOptions): Promise<SpruceSchemas.HeartwoodViewControllers.v2021_02_11.CalendarEvent[]>;
|
|
36
36
|
getEventTypes(): Promise<SpruceSchemas.Calendar.v2021_05_19.CalendarEventType[]>;
|
|
37
37
|
getCalendars(): Promise<SpruceSchemas.Calendar.v2021_05_19.Calendar[]>;
|
|
38
|
+
sendSchedules(options: SendScheduleOptions): Promise<void>;
|
|
39
|
+
setStreamHandler(_cb: StreamHandler): void;
|
|
38
40
|
}
|
|
39
41
|
declare module '@sprucelabs/heartwood-view-controllers/build/types/heartwood.types' {
|
|
40
42
|
interface ViewControllerMap {
|
|
@@ -100,6 +100,10 @@ class FakeRemoteEventStore {
|
|
|
100
100
|
async getCalendars() {
|
|
101
101
|
return FakeRemoteEventStore.calendars;
|
|
102
102
|
}
|
|
103
|
+
async sendSchedules(options) {
|
|
104
|
+
console.log(options);
|
|
105
|
+
}
|
|
106
|
+
setStreamHandler(_cb) { }
|
|
103
107
|
}
|
|
104
108
|
exports.FakeRemoteEventStore = FakeRemoteEventStore;
|
|
105
109
|
FakeRemoteEventStore.calendars = [];
|
|
@@ -8,7 +8,7 @@ export default class SpyEventManager extends CalendarEventManager {
|
|
|
8
8
|
getShouldIgnoreNextContextUpdate(): boolean;
|
|
9
9
|
constructor(options: SpyEventManagerOptions);
|
|
10
10
|
refreshShifts(): void;
|
|
11
|
-
generateShifts(): import("@sprucelabs/
|
|
11
|
+
generateShifts(): import("@sprucelabs/mercury-types").SpruceSchemas.HeartwoodViewControllers.v2021_02_11.CalendarShift[];
|
|
12
12
|
getRemoteEventsStore(): SpyRemoteEventStore;
|
|
13
13
|
getStateMachine(): import("../../types/calendar.types").CalendarToolBeltStateMachine<CalendarToolBeltContext>;
|
|
14
14
|
getPreferences(): SpyRemotePreferencesStore;
|
|
@@ -28,14 +28,14 @@ export default class SpyEventManager extends CalendarEventManager {
|
|
|
28
28
|
updateEventInContext(updates: Partial<CalendarEvent>): Promise<{
|
|
29
29
|
isBusy: boolean;
|
|
30
30
|
id: string;
|
|
31
|
-
target: import("@sprucelabs/
|
|
31
|
+
target: import("@sprucelabs/mercury-types").SpruceSchemas.CalendarUtils.v2021_05_19.CalendarEventTarget;
|
|
32
32
|
calendarId: string;
|
|
33
33
|
eventTypeSlug?: string | null | undefined;
|
|
34
34
|
startDateTimeMs: number;
|
|
35
35
|
isResizeable?: boolean | null | undefined;
|
|
36
36
|
style?: "draft" | "tentative" | "upcoming" | "unavailable" | "blocked" | "active" | "past" | "warn" | "critical" | null | undefined;
|
|
37
37
|
groupId?: string | null | undefined;
|
|
38
|
-
timeBlocks: import("@sprucelabs/
|
|
38
|
+
timeBlocks: import("@sprucelabs/mercury-types").SpruceSchemas.CalendarUtils.v2021_05_19.EventTimeBlock[];
|
|
39
39
|
repeats?: "weekly" | "monthly" | "daily" | null | undefined;
|
|
40
40
|
daysOfWeek?: ("sun" | "mon" | "tue" | "wed" | "thur" | "fri" | "sat")[] | null | undefined;
|
|
41
41
|
daysOfMonth?: ("1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9" | "10" | "11" | "12" | "13" | "14" | "15" | "16" | "17" | "18" | "19" | "20" | "21" | "22" | "23" | "24" | "25" | "26" | "27" | "28" | "29" | "30" | "31")[] | null | undefined;
|
|
@@ -44,13 +44,13 @@ export default class SpyEventManager extends CalendarEventManager {
|
|
|
44
44
|
interval?: number | null | undefined;
|
|
45
45
|
nthOccurrences?: number[] | null | undefined;
|
|
46
46
|
activeUntilDate?: number | null | undefined;
|
|
47
|
-
exclusionDates?: import("@sprucelabs/
|
|
47
|
+
exclusionDates?: import("@sprucelabs/mercury-types").SpruceSchemas.CalendarUtils.v2021_05_19.EventExclusionDate[] | null | undefined;
|
|
48
48
|
nthInRepeating?: number | null | undefined;
|
|
49
49
|
totalInRepeating?: number | null | undefined;
|
|
50
50
|
meta?: Record<string, any> | null | undefined;
|
|
51
51
|
error?: Error | null | undefined;
|
|
52
52
|
isSelected?: boolean | null | undefined;
|
|
53
|
-
colors?: import("@sprucelabs/
|
|
53
|
+
colors?: import("@sprucelabs/mercury-types").SpruceSchemas.HeartwoodViewControllers.v2021_02_11.CalendarEventColorOverride | null | undefined;
|
|
54
54
|
controller?: import("@sprucelabs/heartwood-view-controllers").CalendarEventViewController | null | undefined;
|
|
55
55
|
}>;
|
|
56
56
|
}
|
|
@@ -6,6 +6,7 @@ import RemotePreferencesStore from '../stores/RemotePreferencesStore';
|
|
|
6
6
|
import { CalendarToolBeltContext, CalendarToolBeltStateMachine, UpdateCalendarToolBeltContextHandler, UpdateEvent, UpdateRepeatingStrategyWithCancel } from '../types/calendar.types';
|
|
7
7
|
import CalendarViewController from './Calendar.vc';
|
|
8
8
|
export default class CalendarEventManager {
|
|
9
|
+
static shouldBatchEvents: boolean;
|
|
9
10
|
private calendarVc;
|
|
10
11
|
protected allEvents: CalendarEvent[];
|
|
11
12
|
private inclusiveCalendarIds;
|
|
@@ -27,9 +28,12 @@ export default class CalendarEventManager {
|
|
|
27
28
|
private updateQueuePromise?;
|
|
28
29
|
private persister;
|
|
29
30
|
private hasPendingContextChanges;
|
|
31
|
+
private loadEventsStartTimeMs;
|
|
32
|
+
private activeChunk?;
|
|
30
33
|
constructor(options: CalendarEventManagerOptions);
|
|
31
34
|
protected get calendarIds(): string[];
|
|
32
35
|
protected get visibleCalendarIds(): string[];
|
|
36
|
+
private handleStreamEvents;
|
|
33
37
|
replaceEventsInRange(events: CalendarEvent[], startMs: number, endMs: number): void;
|
|
34
38
|
protected refreshShifts(): void;
|
|
35
39
|
private doShiftsMatchWhatIsInCalendar;
|
|
@@ -58,7 +62,10 @@ export default class CalendarEventManager {
|
|
|
58
62
|
private runUpdateQueue;
|
|
59
63
|
private _updateEvent;
|
|
60
64
|
private calculateDifferences;
|
|
61
|
-
|
|
65
|
+
private get shouldBatchEvents();
|
|
66
|
+
loadEvents(startDate: number, endDate: number, peopleIds: string[]): Promise<import("@sprucelabs/calendar-utils").SpruceSchemas.HeartwoodViewControllers.v2021_02_11.CalendarEvent[] | undefined>;
|
|
67
|
+
private mixinEventsAndLoadTheirVcs;
|
|
68
|
+
private logStep;
|
|
62
69
|
setCalendarVisibility(calendarId: string, shouldBeVisible: boolean): Promise<void>;
|
|
63
70
|
setupVcForEventType(vcId: string, typeSlug: string): Promise<void>;
|
|
64
71
|
private assertValidCalendarId;
|
|
@@ -108,6 +115,7 @@ export default class CalendarEventManager {
|
|
|
108
115
|
private clearRepeatingStrategyOptions;
|
|
109
116
|
getIsLoaded(): boolean;
|
|
110
117
|
hasEvent(id: string): boolean;
|
|
118
|
+
getLastChunkingId(): string | undefined;
|
|
111
119
|
optionallyAskForUpdateRepeatingStrategy(event: UpdateEvent, action?: RepeatingUpdateAction): Promise<{
|
|
112
120
|
pass: boolean;
|
|
113
121
|
dateToUpdate?: number;
|
|
@@ -51,6 +51,8 @@ class CalendarEventManager {
|
|
|
51
51
|
events,
|
|
52
52
|
onEventSwapped: this.handleEventsSwappedInPersister.bind(this),
|
|
53
53
|
});
|
|
54
|
+
this.loadEventsStartTimeMs = new Date().getTime();
|
|
55
|
+
this.events.setStreamHandler(this.handleStreamEvents.bind(this));
|
|
54
56
|
}
|
|
55
57
|
get calendarIds() {
|
|
56
58
|
return this.calendars.map((c) => c.id);
|
|
@@ -59,6 +61,15 @@ class CalendarEventManager {
|
|
|
59
61
|
var _a;
|
|
60
62
|
return (_a = this.prefs.getVisibleCalendarIds()) !== null && _a !== void 0 ? _a : this.calendars.map((c) => c.id);
|
|
61
63
|
}
|
|
64
|
+
async handleStreamEvents(options) {
|
|
65
|
+
var _a;
|
|
66
|
+
const { events, chunkingId } = options;
|
|
67
|
+
const { id, startDate, endDate } = (_a = this.activeChunk) !== null && _a !== void 0 ? _a : {};
|
|
68
|
+
if (id !== chunkingId || !startDate || !endDate) {
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
this.replaceEventsInRange(events, startDate, endDate);
|
|
72
|
+
}
|
|
62
73
|
replaceEventsInRange(events, startMs, endMs) {
|
|
63
74
|
this.calendarVc.replaceEventsInRange(events.filter((e) => this.isCalendarSelected(e.calendarId)), startMs, endMs);
|
|
64
75
|
this.allEvents = this.allEvents.filter((e) => events.findIndex((event) => event.id === e.id) === -1 &&
|
|
@@ -290,13 +301,34 @@ class CalendarEventManager {
|
|
|
290
301
|
const { isTheSame, isTheSameWithoutBusy } = (0, calculateCalendarEventDifferences_1.default)(match, updates);
|
|
291
302
|
return { isTheSame, isTheSameWithoutBusy, match };
|
|
292
303
|
}
|
|
304
|
+
get shouldBatchEvents() {
|
|
305
|
+
return CalendarEventManager.shouldBatchEvents;
|
|
306
|
+
}
|
|
293
307
|
async loadEvents(startDate, endDate, peopleIds) {
|
|
294
|
-
|
|
308
|
+
this.loadEventsStartTimeMs = new Date().getTime();
|
|
309
|
+
this.logStep('starting to load events');
|
|
310
|
+
const scheduleOptions = {
|
|
295
311
|
calendarIds: this.calendarIds,
|
|
296
312
|
startDate,
|
|
297
313
|
endDate,
|
|
298
314
|
peopleIds,
|
|
299
|
-
}
|
|
315
|
+
};
|
|
316
|
+
if (this.shouldBatchEvents) {
|
|
317
|
+
this.activeChunk = {
|
|
318
|
+
id: new Date().getTime().toString(),
|
|
319
|
+
startDate,
|
|
320
|
+
endDate,
|
|
321
|
+
};
|
|
322
|
+
await this.events.sendSchedules(Object.assign(Object.assign({}, scheduleOptions), { chunkingId: this.activeChunk.id }));
|
|
323
|
+
return;
|
|
324
|
+
}
|
|
325
|
+
const events = await this.events.getSchedules(scheduleOptions);
|
|
326
|
+
this.logStep('Loaded events');
|
|
327
|
+
await this.mixinEventsAndLoadTheirVcs(events, startDate, endDate);
|
|
328
|
+
this.logStep('Finished replacing events');
|
|
329
|
+
return events;
|
|
330
|
+
}
|
|
331
|
+
async mixinEventsAndLoadTheirVcs(events, startDate, endDate) {
|
|
300
332
|
await this.calendarVc.renderOnce(async () => {
|
|
301
333
|
if (!this.eventTypes) {
|
|
302
334
|
this.eventTypes = await this.events.getEventTypes();
|
|
@@ -308,9 +340,14 @@ class CalendarEventManager {
|
|
|
308
340
|
await this.setupVcForEventType(type.viewControllerId, type.slug);
|
|
309
341
|
}
|
|
310
342
|
}));
|
|
343
|
+
this.logStep('Loaded view controllers');
|
|
311
344
|
this.replaceEventsInRange(events, startDate, endDate);
|
|
312
345
|
});
|
|
313
|
-
|
|
346
|
+
}
|
|
347
|
+
logStep(_label) {
|
|
348
|
+
// let currentTimeMs = new Date().getTime()
|
|
349
|
+
// const diff = currentTimeMs - this.loadEventsStartTimeMs
|
|
350
|
+
// console.log(label, diff)
|
|
314
351
|
}
|
|
315
352
|
async setCalendarVisibility(calendarId, shouldBeVisible) {
|
|
316
353
|
if (shouldBeVisible) {
|
|
@@ -452,6 +489,10 @@ class CalendarEventManager {
|
|
|
452
489
|
hasEvent(id) {
|
|
453
490
|
return !!this.allEvents.find((e) => e.id === id);
|
|
454
491
|
}
|
|
492
|
+
getLastChunkingId() {
|
|
493
|
+
var _a;
|
|
494
|
+
return (_a = this.activeChunk) === null || _a === void 0 ? void 0 : _a.id;
|
|
495
|
+
}
|
|
455
496
|
async optionallyAskForUpdateRepeatingStrategy(event, action = 'update') {
|
|
456
497
|
var _a;
|
|
457
498
|
if (!event.id) {
|
|
@@ -485,6 +526,7 @@ class CalendarEventManager {
|
|
|
485
526
|
return { pass: true, dateToUpdate, shouldUpdateAllEventsGoingForward };
|
|
486
527
|
}
|
|
487
528
|
}
|
|
529
|
+
CalendarEventManager.shouldBatchEvents = false;
|
|
488
530
|
exports.default = CalendarEventManager;
|
|
489
531
|
class UpdateOperation {
|
|
490
532
|
constructor(options) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { MercuryClient } from '@sprucelabs/mercury-client';
|
|
2
2
|
import { AbstractEventEmitter } from '@sprucelabs/mercury-event-emitter';
|
|
3
|
-
import { CalendarPerson } from '../
|
|
3
|
+
import { CalendarPerson } from '../root/Root.svc';
|
|
4
4
|
import RemotePreferencesStore from '../stores/RemotePreferencesStore';
|
|
5
5
|
import { PersonMode } from '../tools/PersonSelectTool.vc';
|
|
6
6
|
import { CalendarEvent } from '../types/calendar.types';
|
|
@@ -11,7 +11,7 @@ export default class CalendarPersister {
|
|
|
11
11
|
protected eventSwappedHandler?: EventSwappedHandler;
|
|
12
12
|
protected constructor(options: CalendarPersisterOptions);
|
|
13
13
|
static Persister(options: CalendarPersisterOptions): CalendarPersister;
|
|
14
|
-
persist(event: UpdateEvent): Promise<import("@sprucelabs/
|
|
14
|
+
persist(event: UpdateEvent): Promise<import("@sprucelabs/mercury-types").SpruceSchemas.HeartwoodViewControllers.v2021_02_11.CalendarEvent | UpdateEvent | undefined>;
|
|
15
15
|
waitForPendingSaves(): Promise<void>;
|
|
16
16
|
setRemoteStore(events: RemoteEventStore): void;
|
|
17
17
|
getRemoteStore(): RemoteEventStore | undefined;
|