@sprucelabs/spruce-calendar-components 21.0.2 → 21.0.5

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.
Files changed (71) hide show
  1. package/build/.spruce/errors/errors.types.d.ts +122 -0
  2. package/build/.spruce/errors/errors.types.js +4 -0
  3. package/build/.spruce/errors/options.types.d.ts +28 -0
  4. package/build/.spruce/errors/options.types.js +2 -0
  5. package/build/constants.d.ts +5 -0
  6. package/build/constants.js +9 -0
  7. package/build/errors/SpruceError.d.ts +5 -0
  8. package/build/errors/SpruceError.js +45 -0
  9. package/build/esm/.spruce/errors/errors.types.d.ts +122 -0
  10. package/build/esm/.spruce/errors/errors.types.js +3 -0
  11. package/build/esm/.spruce/errors/options.types.d.ts +28 -0
  12. package/build/esm/.spruce/errors/options.types.js +1 -0
  13. package/build/esm/constants.d.ts +5 -0
  14. package/build/esm/constants.js +6 -0
  15. package/build/esm/errors/SpruceError.d.ts +5 -0
  16. package/build/esm/errors/SpruceError.js +39 -0
  17. package/build/esm/index-module.d.ts +30 -0
  18. package/build/esm/index-module.js +7 -0
  19. package/build/esm/skillViewControllers/Root.svc.d.ts +73 -0
  20. package/build/esm/skillViewControllers/Root.svc.js +404 -0
  21. package/build/esm/toolBelt/CalendarToolTestFactory.d.ts +5 -0
  22. package/build/esm/toolBelt/CalendarToolTestFactory.js +28 -0
  23. package/build/esm/toolBelt/states/PrerequisitesToolBeltState.d.ts +37 -0
  24. package/build/esm/toolBelt/states/PrerequisitesToolBeltState.js +190 -0
  25. package/build/esm/toolBelt/states/RootToolBeltState.d.ts +37 -0
  26. package/build/esm/toolBelt/states/RootToolBeltState.js +122 -0
  27. package/build/esm/toolBelt/states/makeEventTyped.d.ts +2 -0
  28. package/build/esm/toolBelt/states/makeEventTyped.js +8 -0
  29. package/build/esm/types/calendar.types.d.ts +3 -0
  30. package/build/esm/utilities/CalendarEventManager.d.ts +72 -0
  31. package/build/esm/utilities/CalendarEventManager.js +321 -0
  32. package/build/esm/utilities/CalendarPeopleManager.d.ts +56 -0
  33. package/build/esm/utilities/CalendarPeopleManager.js +182 -0
  34. package/build/esm/utilities/calendarShiftGenerator.d.ts +8 -0
  35. package/build/esm/utilities/calendarShiftGenerator.js +24 -0
  36. package/build/esm/viewControllers/CalendarSelectTool.vc.d.ts +28 -0
  37. package/build/esm/viewControllers/CalendarSelectTool.vc.js +103 -0
  38. package/build/esm/viewControllers/DateSelectCard.vc.d.ts +29 -0
  39. package/build/esm/viewControllers/DateSelectCard.vc.js +77 -0
  40. package/build/esm/viewControllers/PersonSelectTool.vc.d.ts +36 -0
  41. package/build/esm/viewControllers/PersonSelectTool.vc.js +156 -0
  42. package/build/esm/viewControllers/SelectUpdateRepeatingStrategyCard.vc.d.ts +18 -0
  43. package/build/esm/viewControllers/SelectUpdateRepeatingStrategyCard.vc.js +85 -0
  44. package/build/index-module.d.ts +30 -0
  45. package/build/index-module.js +32 -0
  46. package/build/skillViewControllers/Root.svc.d.ts +73 -0
  47. package/build/skillViewControllers/Root.svc.js +359 -0
  48. package/build/toolBelt/CalendarToolTestFactory.d.ts +5 -0
  49. package/build/toolBelt/CalendarToolTestFactory.js +34 -0
  50. package/build/toolBelt/states/PrerequisitesToolBeltState.d.ts +37 -0
  51. package/build/toolBelt/states/PrerequisitesToolBeltState.js +172 -0
  52. package/build/toolBelt/states/RootToolBeltState.d.ts +37 -0
  53. package/build/toolBelt/states/RootToolBeltState.js +113 -0
  54. package/build/toolBelt/states/makeEventTyped.d.ts +2 -0
  55. package/build/toolBelt/states/makeEventTyped.js +14 -0
  56. package/build/types/calendar.types.d.ts +3 -0
  57. package/build/utilities/CalendarEventManager.d.ts +72 -0
  58. package/build/utilities/CalendarEventManager.js +279 -0
  59. package/build/utilities/CalendarPeopleManager.d.ts +56 -0
  60. package/build/utilities/CalendarPeopleManager.js +163 -0
  61. package/build/utilities/calendarShiftGenerator.d.ts +8 -0
  62. package/build/utilities/calendarShiftGenerator.js +26 -0
  63. package/build/viewControllers/CalendarSelectTool.vc.d.ts +28 -0
  64. package/build/viewControllers/CalendarSelectTool.vc.js +93 -0
  65. package/build/viewControllers/DateSelectCard.vc.d.ts +29 -0
  66. package/build/viewControllers/DateSelectCard.vc.js +69 -0
  67. package/build/viewControllers/PersonSelectTool.vc.d.ts +36 -0
  68. package/build/viewControllers/PersonSelectTool.vc.js +140 -0
  69. package/build/viewControllers/SelectUpdateRepeatingStrategyCard.vc.d.ts +18 -0
  70. package/build/viewControllers/SelectUpdateRepeatingStrategyCard.vc.js +88 -0
  71. package/package.json +99 -30
@@ -0,0 +1,172 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.PrerequisitesToolBeltState = void 0;
7
+ const makeEventTyped_1 = __importDefault(require("./makeEventTyped"));
8
+ class PrerequisitesToolBeltState {
9
+ constructor(options) {
10
+ this.id = 'prerequisites';
11
+ this.selectCalendarHandler = options === null || options === void 0 ? void 0 : options.onSelectCalendar;
12
+ this.selectEventTypeHandler = options === null || options === void 0 ? void 0 : options.onSelectEventType;
13
+ }
14
+ async load(stateMachine) {
15
+ const toolBeltVc = stateMachine.getToolBeltVc();
16
+ this.toolBeltVc = toolBeltVc;
17
+ this.sm = stateMachine;
18
+ void this.toolBeltVc.renderOnce(() => {
19
+ this.toolBeltVc.clearTools();
20
+ this.toolBeltVc.clearStickyTools();
21
+ });
22
+ if (!this.calendars) {
23
+ this.calendars = await this.listCalendars();
24
+ }
25
+ if (this.calendars.length === 1) {
26
+ await this.handleSelectCalendar(this.calendars[0]);
27
+ return;
28
+ }
29
+ this.setupCalendarSelectCard(this.calendars);
30
+ await this.sm.updateContext({
31
+ event: Object.assign(Object.assign({}, this.sm.getContext().event), { isBusy: false }),
32
+ });
33
+ }
34
+ destroy() { }
35
+ setupCalendarSelectCard(calendars) {
36
+ this.calendarSelectCardVc = this.SelectCalendarCardVc();
37
+ this.toolBeltVc.addTool({
38
+ id: 'calendars',
39
+ lineIcon: 'calendar-add',
40
+ card: this.calendarSelectCardVc.render(),
41
+ });
42
+ if (calendars.length > 0) {
43
+ this.calendarSelectCardVc.addSection({
44
+ buttons: calendars.map((c) => ({
45
+ id: c.id,
46
+ label: c.title,
47
+ onClick: () => this.handleSelectCalendar(c),
48
+ })),
49
+ });
50
+ }
51
+ else {
52
+ this.calendarSelectCardVc.addSection({
53
+ text: {
54
+ content: `You don't have any calendars. The only way to get one is to book an appointment or work at a place that uses Sprucebot! 🌲🤖`,
55
+ },
56
+ });
57
+ }
58
+ this.calendarSelectCardVc.setIsBusy(false);
59
+ }
60
+ async handleSelectCalendar(calendar) {
61
+ var _a, _b, _c, _d;
62
+ (_a = this.calendarSelectCardVc) === null || _a === void 0 ? void 0 : _a.setIsBusy(true);
63
+ this.calendar = calendar;
64
+ await ((_b = this.selectCalendarHandler) === null || _b === void 0 ? void 0 : _b.call(this, calendar));
65
+ const client = await this.connectToApi();
66
+ let [{ calendarEventTypes }] = await client.emitAndFlattenResponses('calendar.list-calendar-event-types::v2021_05_19');
67
+ const types = (_c = calendar.eventTypes) !== null && _c !== void 0 ? _c : [];
68
+ if (types.length > 0) {
69
+ calendarEventTypes = calendarEventTypes.filter((t) => types.indexOf(t.slug) > -1);
70
+ }
71
+ if (calendarEventTypes.length === 1) {
72
+ await this.handleSelectType(calendarEventTypes[0]);
73
+ }
74
+ else {
75
+ await this.updateEventInContext();
76
+ await this.setupTypeSelectCard(calendarEventTypes);
77
+ }
78
+ (_d = this.calendarSelectCardVc) === null || _d === void 0 ? void 0 : _d.setIsBusy(false);
79
+ }
80
+ async setupTypeSelectCard(types) {
81
+ var _a, _b, _c, _d, _e, _f;
82
+ if (!this.toolBeltVc.getTool('types')) {
83
+ this.typeSelectCardVc = this.TypeSelectCardVc();
84
+ this.toolBeltVc.addTool({
85
+ id: 'types',
86
+ lineIcon: 'calendar-add',
87
+ card: this.typeSelectCardVc.render(),
88
+ });
89
+ }
90
+ (_a = this.typeSelectCardVc) === null || _a === void 0 ? void 0 : _a.setIsBusy(true);
91
+ (_b = this.toolBeltVc) === null || _b === void 0 ? void 0 : _b.focusTool('types');
92
+ const section = await this.renderTypeButtonsSection(types);
93
+ if (((_c = this.typeSelectCardVc) === null || _c === void 0 ? void 0 : _c.getTotalSections()) === 0) {
94
+ (_d = this.typeSelectCardVc) === null || _d === void 0 ? void 0 : _d.addSection(section);
95
+ }
96
+ else {
97
+ (_e = this.typeSelectCardVc) === null || _e === void 0 ? void 0 : _e.setSection(0, section);
98
+ }
99
+ (_f = this.typeSelectCardVc) === null || _f === void 0 ? void 0 : _f.setIsBusy(false);
100
+ }
101
+ async renderTypeButtonsSection(calendarEventTypes) {
102
+ const section = {
103
+ buttons: calendarEventTypes.map((t) => ({
104
+ id: t.id,
105
+ label: t.name,
106
+ onClick: () => this.handleSelectType(t),
107
+ })),
108
+ };
109
+ return section;
110
+ }
111
+ async handleSelectType(type) {
112
+ var _a, _b, _c;
113
+ (_a = this.typeSelectCardVc) === null || _a === void 0 ? void 0 : _a.setIsBusy(true);
114
+ const { event } = this.sm.getContext();
115
+ const updated = (0, makeEventTyped_1.default)(event, type);
116
+ await this.updateEventInContext({
117
+ eventTypeSlug: type.slug,
118
+ timeBlocks: updated.timeBlocks,
119
+ });
120
+ await ((_b = this.selectEventTypeHandler) === null || _b === void 0 ? void 0 : _b.call(this, type));
121
+ (_c = this.typeSelectCardVc) === null || _c === void 0 ? void 0 : _c.setIsBusy(false);
122
+ }
123
+ async updateEventInContext(updates) {
124
+ var _a;
125
+ const { event } = this.sm.getContext();
126
+ if (event) {
127
+ await this.sm.updateContext({
128
+ event: Object.assign(Object.assign(Object.assign({}, event), { calendarId: (_a = this.calendar) === null || _a === void 0 ? void 0 : _a.id }), updates),
129
+ });
130
+ }
131
+ }
132
+ TypeSelectCardVc() {
133
+ return this.sm.Controller('card', {
134
+ header: {
135
+ title: 'What do you want to add?',
136
+ },
137
+ body: {
138
+ isBusy: true,
139
+ },
140
+ });
141
+ }
142
+ getCalendarSelectCardVc() {
143
+ return this.calendarSelectCardVc;
144
+ }
145
+ getTypeSelectCardVc() {
146
+ return this.typeSelectCardVc;
147
+ }
148
+ SelectCalendarCardVc() {
149
+ return this.sm.Controller('card', {
150
+ header: {
151
+ title: 'Which calendar?',
152
+ },
153
+ body: {
154
+ isBusy: true,
155
+ },
156
+ });
157
+ }
158
+ async listCalendars() {
159
+ const org = await this.sm.getContext().scope.getCurrentOrganization();
160
+ const client = await this.connectToApi();
161
+ const [{ calendars }] = await client.emitAndFlattenResponses('calendar.list-calendars::v2021_05_19', {
162
+ target: {
163
+ organizationId: org === null || org === void 0 ? void 0 : org.id,
164
+ },
165
+ });
166
+ return calendars;
167
+ }
168
+ async connectToApi() {
169
+ return await this.sm.connectToApi();
170
+ }
171
+ }
172
+ exports.PrerequisitesToolBeltState = PrerequisitesToolBeltState;
@@ -0,0 +1,37 @@
1
+ import { SpruceSchemas, ToolBeltState } from '@sprucelabs/heartwood-view-controllers';
2
+ import { CalendarToolBeltStateMachine } from '../../types/calendar.types';
3
+ import { CalendarEventManager } from '../../utilities/CalendarEventManager';
4
+ import CalendarPeopleManager from '../../utilities/CalendarPeopleManager';
5
+ import CalendarSelectCardViewController from '../../viewControllers/CalendarSelectTool.vc';
6
+ import DateSelectCardViewController from '../../viewControllers/DateSelectCard.vc';
7
+ import PersonSelectToolViewController from '../../viewControllers/PersonSelectTool.vc';
8
+ export declare class RootToolBeltState implements ToolBeltState {
9
+ readonly id = "root";
10
+ private calendarSelectCardVc?;
11
+ private toolBeltVc;
12
+ private personSelectVc;
13
+ private sm;
14
+ private scopeSelectionTool?;
15
+ private dateSelectVc;
16
+ private lastSelectedDate?;
17
+ private people;
18
+ private events;
19
+ constructor(options: {
20
+ people: CalendarPeopleManager;
21
+ events: CalendarEventManager;
22
+ });
23
+ getCalendarSelectCardVc(): CalendarSelectCardViewController | undefined;
24
+ private CalendarSelectVc;
25
+ load(stateMachine: CalendarToolBeltStateMachine): Promise<void>;
26
+ private optionallyClearStickyTool;
27
+ private handleSelectDate;
28
+ private resetToolBelt;
29
+ private optionallyDropInScopeSelectionTool;
30
+ private setupCalendarSelectVc;
31
+ private optionallyAddPeopleCard;
32
+ getPersonSelectCardVc(): PersonSelectToolViewController;
33
+ getDateSelectVc(): DateSelectCardViewController;
34
+ getSelectedDate(): SpruceSchemas.HeartwoodViewControllers.v2021_02_11.CalendarSelectedDate;
35
+ setSelectedDate(year: number, month: number, day: number): void;
36
+ private PersonSelectVc;
37
+ }
@@ -0,0 +1,113 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.RootToolBeltState = void 0;
4
+ const calendar_utils_1 = require("@sprucelabs/calendar-utils");
5
+ const schema_1 = require("@sprucelabs/schema");
6
+ class RootToolBeltState {
7
+ constructor(options) {
8
+ this.id = 'root';
9
+ const { people, events } = (0, schema_1.assertOptions)(options, ['people', 'events']);
10
+ this.people = people;
11
+ this.events = events;
12
+ }
13
+ getCalendarSelectCardVc() {
14
+ return this.calendarSelectCardVc;
15
+ }
16
+ CalendarSelectVc() {
17
+ var _a;
18
+ return (_a = this.sm) === null || _a === void 0 ? void 0 : _a.Controller('calendar.calendar-select-tool', {
19
+ events: this.events,
20
+ });
21
+ }
22
+ async load(stateMachine) {
23
+ this.sm = stateMachine;
24
+ this.toolBeltVc = stateMachine.getToolBeltVc();
25
+ this.resetToolBelt();
26
+ this.dateSelectVc = this.sm.Controller('calendar.date-select-card', {
27
+ onSelectDate: (date) => this.handleSelectDate(date),
28
+ startDate: calendar_utils_1.dateUtil.getStartOfDay(new Date().getTime()),
29
+ selectedDate: this.lastSelectedDate,
30
+ });
31
+ this.toolBeltVc.addTool({
32
+ id: 'date-selection',
33
+ lineIcon: 'calendar',
34
+ card: this.dateSelectVc.render(),
35
+ });
36
+ await Promise.all([
37
+ this.setupCalendarSelectVc(stateMachine),
38
+ this.optionallyAddPeopleCard(stateMachine.getContext().scope),
39
+ ]);
40
+ this.optionallyDropInScopeSelectionTool();
41
+ this.optionallyClearStickyTool();
42
+ }
43
+ optionallyClearStickyTool() {
44
+ if (this.toolBeltVc.getStickyTools().bottom) {
45
+ this.toolBeltVc.removeStickyTool('bottom');
46
+ }
47
+ }
48
+ handleSelectDate(date) {
49
+ const { calendarVc } = this.sm.getContext();
50
+ calendarVc.setStartDate(date);
51
+ }
52
+ resetToolBelt() {
53
+ var _a;
54
+ if (!this.scopeSelectionTool) {
55
+ this.scopeSelectionTool = (_a = this.toolBeltVc) === null || _a === void 0 ? void 0 : _a.getTool('scope-selection');
56
+ }
57
+ this.toolBeltVc.clearTools();
58
+ }
59
+ optionallyDropInScopeSelectionTool() {
60
+ var _a;
61
+ if (this.scopeSelectionTool) {
62
+ (_a = this.toolBeltVc) === null || _a === void 0 ? void 0 : _a.addTool(this.scopeSelectionTool);
63
+ }
64
+ }
65
+ setupCalendarSelectVc(stateMachine) {
66
+ var _a, _b, _c;
67
+ this.calendarSelectCardVc = this.CalendarSelectVc();
68
+ (_a = this.toolBeltVc) === null || _a === void 0 ? void 0 : _a.addTool({
69
+ lineIcon: 'calendar',
70
+ id: 'calendars',
71
+ card: (_b = this.calendarSelectCardVc) === null || _b === void 0 ? void 0 : _b.render(),
72
+ });
73
+ return (_c = this.calendarSelectCardVc) === null || _c === void 0 ? void 0 : _c.load(stateMachine.getContext());
74
+ }
75
+ async optionallyAddPeopleCard(scope) {
76
+ var _a, _b;
77
+ const location = await scope.getCurrentLocation();
78
+ if (location && !((_a = this.toolBeltVc) === null || _a === void 0 ? void 0 : _a.getTool('people'))) {
79
+ this.personSelectVc = this.PersonSelectVc();
80
+ (_b = this.toolBeltVc) === null || _b === void 0 ? void 0 : _b.addTool({
81
+ lineIcon: 'user',
82
+ id: 'people',
83
+ card: this.personSelectVc.render(),
84
+ });
85
+ await this.personSelectVc.load();
86
+ }
87
+ }
88
+ getPersonSelectCardVc() {
89
+ return this.personSelectVc;
90
+ }
91
+ getDateSelectVc() {
92
+ return this.dateSelectVc;
93
+ }
94
+ getSelectedDate() {
95
+ return this.dateSelectVc.getSelectedDate();
96
+ }
97
+ setSelectedDate(year, month, day) {
98
+ var _a;
99
+ this.lastSelectedDate = {
100
+ year,
101
+ month,
102
+ day,
103
+ };
104
+ (_a = this.dateSelectVc) === null || _a === void 0 ? void 0 : _a.setSelectedDate(year, month, day);
105
+ }
106
+ PersonSelectVc() {
107
+ var _a;
108
+ return (_a = this.sm) === null || _a === void 0 ? void 0 : _a.Controller('calendar.person-select-tool', {
109
+ people: this.people,
110
+ });
111
+ }
112
+ }
113
+ exports.RootToolBeltState = RootToolBeltState;
@@ -0,0 +1,2 @@
1
+ import { SpruceSchemas } from '@sprucelabs/heartwood-view-controllers';
2
+ export default function makeEventTyped(event: SpruceSchemas.HeartwoodViewControllers.v2021_02_11.CalendarEvent, type: SpruceSchemas.Calendar.v2021_05_19.CalendarEventType): SpruceSchemas.HeartwoodViewControllers.v2021_02_11.CalendarEvent;
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const draftGenerator_1 = __importDefault(require("../../utilities/draftGenerator"));
7
+ function makeEventTyped(event, type) {
8
+ var _a;
9
+ const { timeBlocks } = event;
10
+ timeBlocks[0].title = draftGenerator_1.default.generateTitle(type.name);
11
+ timeBlocks[0].leftIcons = [{ icon: (_a = type.lineIcon) !== null && _a !== void 0 ? _a : 'coffee', hint: null }];
12
+ return event;
13
+ }
14
+ exports.default = makeEventTyped;
@@ -1,6 +1,7 @@
1
1
  import { AbstractViewController, LineIcon, SkillViewControllerLoadOptions, ToolBeltState, ToolBeltStateMachine } from '@sprucelabs/heartwood-view-controllers';
2
2
  import { SpruceSchemas } from '@sprucelabs/mercury-types';
3
3
  import { EventTarget } from '@sprucelabs/spruce-event-utils';
4
+ import { UpdateRepeatingStrategy } from '../constants';
4
5
  import { CalendarEventManager } from '../utilities/CalendarEventManager';
5
6
  import CalendarPeopleManager from '../utilities/CalendarPeopleManager';
6
7
  import CalendarViewController from '../viewControllers/Calendar.vc';
@@ -8,6 +9,7 @@ export interface Schedule {
8
9
  target: EventTarget;
9
10
  events: SpruceSchemas.CalendarUtils.v2021_05_19.CalendarEvent[];
10
11
  }
12
+ export declare type EventForShift = Pick<CalendarEvent, 'id' | 'timeBlocks' | 'startDateTimeMs' | 'target'>;
11
13
  export declare type DraftEvent = Pick<CalendarEvent, 'id' | 'startDateTimeMs' | 'style' | 'calendarId' | 'target' | 'timeBlocks' | 'isBusy'>;
12
14
  export declare type CalendarEvent = SpruceSchemas.HeartwoodViewControllers.v2021_02_11.CalendarEvent;
13
15
  export declare type UpdateEvent = SpruceSchemas.Calendar.v2021_05_19.UpdateCalendarEventEmitPayload & CalendarEvent;
@@ -48,6 +50,7 @@ export declare type GetCalendarToolBeltContextHandler = () => CalendarToolBeltCo
48
50
  export declare type GetPersonFromEventHandler = () => Promise<Person | null>;
49
51
  export declare type GetHasPendingContextChangesHandler = () => boolean;
50
52
  export declare type CancelEventHandler = (eventId: string) => boolean | Promise<boolean | void> | void;
53
+ export declare type UpdateRepeatingStrategyWithCancel = UpdateRepeatingStrategy | 'cancel';
51
54
  export interface CalendarToolOptions {
52
55
  updateContext: UpdateCalendarToolBeltContextHandler;
53
56
  getContext: GetCalendarToolBeltContextHandler;
@@ -0,0 +1,72 @@
1
+ import { DateUtils } from '@sprucelabs/calendar-utils';
2
+ import { CalendarEvent } from '@sprucelabs/heartwood-view-controllers';
3
+ import { RemoteViewControllerFactory } from '@sprucelabs/spruce-heartwood-utils';
4
+ import RemoteEventStore from '../stores/RemoteEventStore';
5
+ import RemotePreferencesStore from '../stores/RemotePreferencesStore';
6
+ import { CalendarToolBeltStateMachine, UpdateEvent, UpdateRepeatingStrategyWithCancel } from '../types/calendar.types';
7
+ import CalendarViewController from '../viewControllers/Calendar.vc';
8
+ export declare class CalendarEventManager {
9
+ private calendarVc;
10
+ protected allEvents: CalendarEvent[];
11
+ private inclusiveCalendarIds;
12
+ protected events: RemoteEventStore;
13
+ private eventTypes?;
14
+ private remoteVc;
15
+ private hasVcForEventTypeBeenLoaded;
16
+ private sm;
17
+ private shouldIgnoreNextContextUpdate;
18
+ private askForUpdateStrategy;
19
+ private dateToUpdate?;
20
+ private shouldUpdateAllEventsGoingForward?;
21
+ private dates;
22
+ protected prefs: RemotePreferencesStore;
23
+ private calendars;
24
+ private shouldUpdateContextOnNextSave;
25
+ protected get calendarIds(): string[];
26
+ protected get visibleCalendarIds(): string[];
27
+ constructor(options: CalendarEventManagerOptions);
28
+ replaceEventsInRange(events: CalendarEvent[], startMs: number, endMs: number): void;
29
+ private refreshShifts;
30
+ private isCalendarSelected;
31
+ private doesCalenderExist;
32
+ getAllEvents(): CalendarEvent[];
33
+ getCalendars(): import("@sprucelabs/calendar-utils").SpruceSchemas.Calendar.v2021_05_19.Calendar[];
34
+ addDraftEvent(event: CalendarEvent): Promise<void>;
35
+ silentlySwapEvent(oldId: string, event: CalendarEvent): Promise<void>;
36
+ handleDropEvent(id: string, updates: Partial<CalendarEvent>): Promise<boolean>;
37
+ reset(): Promise<void>;
38
+ restoreEventToDraftOnStateLoadError(): Promise<void>;
39
+ getVisibleCalendarIds(): string[];
40
+ removeEvent(id: string): Promise<void>;
41
+ makeCalendarVisible(calendarId: string): Promise<void>;
42
+ makeCalendarHidden(calendarId: string): Promise<void>;
43
+ updateEvent(id: string, updates: Partial<CalendarEvent> & {
44
+ dateToUpdate?: number;
45
+ shouldUpdateAllEventsGoingForward?: boolean;
46
+ }): void;
47
+ loadEvents(startDate: number, endDate: number, peopleIds: string[]): Promise<void>;
48
+ setCalendarVisibility(calendarId: string, shouldBeVisible: boolean): Promise<void>;
49
+ setupVcForEventType(vcId: string, typeSlug: string): Promise<void>;
50
+ private assertValidCalendarId;
51
+ private updateEventInContext;
52
+ private setEventInContext;
53
+ selectEvent(eventId: string): Promise<void>;
54
+ load(): Promise<void>;
55
+ private loadCalendars;
56
+ private handleWillUpdateContext;
57
+ private handleDidUpdateContext;
58
+ private saveEvent;
59
+ optionallyAskForUpdateRepeatingStrategy(event: UpdateEvent): Promise<boolean>;
60
+ }
61
+ export declare type EventManagerCalendarVc = Pick<CalendarViewController, 'replaceEventsInRange' | 'mixinEvents' | 'removeEvent' | 'addEvent' | 'hasEvent' | 'updateEvent' | 'setShifts' | 'getShifts' | 'getEvent' | 'getPeople' | 'setControllerForEventType' | 'setRemoteStore' | 'getSelectedEvent' | 'selectEvent'>;
62
+ declare type EventManagerRemoteViewControllerFactory = Pick<RemoteViewControllerFactory, 'fetchRemoteController'>;
63
+ export interface CalendarEventManagerOptions {
64
+ calendarVc: EventManagerCalendarVc;
65
+ events: RemoteEventStore;
66
+ remoteVc: EventManagerRemoteViewControllerFactory;
67
+ sm: CalendarToolBeltStateMachine;
68
+ dates: DateUtils;
69
+ preferences: RemotePreferencesStore;
70
+ askForUpdateStrategy: (event: UpdateEvent) => Promise<UpdateRepeatingStrategyWithCancel>;
71
+ }
72
+ export {};