@sprucelabs/spruce-calendar-components 28.3.102 → 29.0.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.
Files changed (70) hide show
  1. package/build/.spruce/errors/errors.types.d.ts +12 -12
  2. package/build/.spruce/errors/errors.types.js +0 -2
  3. package/build/.spruce/errors/options.types.d.ts +2 -2
  4. package/build/.spruce/schemas/schemas.types.d.ts +3287 -2737
  5. package/build/.spruce/schemas/schemas.types.js +1 -2
  6. package/build/__tests__/support/CalendarToolBeltStateMachineTestFactory.js +24 -13
  7. package/build/__tests__/support/SpyEventManager.js +1 -1
  8. package/build/__tests__/support/SpyPeopleManager.js +4 -4
  9. package/build/__tests__/support/SpyRemoteEventStore.js +4 -4
  10. package/build/__tests__/support/utilities/calendarAssert.js +2 -4
  11. package/build/__tests__/support/utilities/calendarSkillAssert.js +25 -10
  12. package/build/__tests__/support/utilities/calendarToolBeltInteractor.js +3 -1
  13. package/build/calendar/Calendar.vc.js +52 -43
  14. package/build/calendar/CalendarEventManager.js +86 -66
  15. package/build/calendar/CalendarPeopleManager.js +17 -16
  16. package/build/calendar/CalendarPersister.d.ts +2 -2
  17. package/build/calendar/CalendarPersister.js +13 -8
  18. package/build/calendar/calculateCalendarEventDifferences.js +6 -3
  19. package/build/constants.js +1 -2
  20. package/build/errors/SpruceError.d.ts +1 -1
  21. package/build/errors/SpruceError.js +1 -1
  22. package/build/esm/.spruce/errors/errors.types.d.ts +12 -12
  23. package/build/esm/.spruce/errors/errors.types.js +0 -2
  24. package/build/esm/.spruce/errors/options.types.d.ts +2 -2
  25. package/build/esm/.spruce/schemas/schemas.types.d.ts +3287 -2737
  26. package/build/esm/.spruce/schemas/schemas.types.js +1 -2
  27. package/build/esm/__tests__/support/utilities/calendarAssert.js +0 -1
  28. package/build/esm/__tests__/support/utilities/calendarSkillAssert.js +2 -2
  29. package/build/esm/calendar/Calendar.vc.js +0 -3
  30. package/build/esm/calendar/CalendarEventManager.js +3 -2
  31. package/build/esm/calendar/CalendarPeopleManager.js +0 -2
  32. package/build/esm/calendar/CalendarPersister.d.ts +2 -2
  33. package/build/esm/errors/SpruceError.d.ts +1 -1
  34. package/build/esm/noSchedules/peopleToPeopleWithoutSchedules.d.ts +1 -1
  35. package/build/esm/root/Root.svc.d.ts +2 -2
  36. package/build/esm/root/Root.svc.js +4 -2
  37. package/build/esm/stores/RemoteEventStore.js +7 -4
  38. package/build/esm/toolBelt/CalendarToolRegistrar.js +4 -1
  39. package/build/esm/toolBelt/states/AbstractCalendarEventToolBeltState.js +5 -2
  40. package/build/esm/toolBelt/states/RootToolBeltState.js +2 -1
  41. package/build/esm/tools/CalendarSelectTool.vc.js +5 -2
  42. package/build/esm/tools/EventRepeatingTool.vc.js +3 -1
  43. package/build/esm/tools/PersonSelectTool.vc.js +8 -3
  44. package/build/esm/viewControllers/DateSelectCard.vc.js +1 -4
  45. package/build/esm/viewControllers/RepeatingControlsList.vc.js +2 -1
  46. package/build/noSchedules/peopleToPeopleWithoutSchedules.d.ts +1 -1
  47. package/build/root/Root.svc.d.ts +2 -2
  48. package/build/root/Root.svc.js +73 -48
  49. package/build/stores/RemoteEventStore.js +60 -38
  50. package/build/stores/RemotePreferencesStore.js +10 -4
  51. package/build/toolBelt/CalendarToolRegistrar.js +8 -9
  52. package/build/toolBelt/CalendarToolTestFactory.js +10 -4
  53. package/build/toolBelt/states/AbstractCalendarEventToolBeltState.js +37 -27
  54. package/build/toolBelt/states/PrerequisitesToolBeltState.js +31 -22
  55. package/build/toolBelt/states/RootToolBeltState.js +23 -19
  56. package/build/toolBelt/states/UniversalEventToolBeltState.js +1 -4
  57. package/build/toolBelt/states/makeEventTyped.js +1 -2
  58. package/build/tools/CalendarSelectTool.vc.js +12 -6
  59. package/build/tools/EventDateTimeTool.vc.js +10 -6
  60. package/build/tools/EventDurationTool.vc.js +8 -5
  61. package/build/tools/EventRepeatingTool.vc.js +23 -7
  62. package/build/tools/EventTitleTool.vc.js +8 -5
  63. package/build/tools/PersonSelectTool.vc.js +17 -9
  64. package/build/utilities/draftGenerator.js +1 -1
  65. package/build/viewControllers/DateSelectCard.vc.js +12 -7
  66. package/build/viewControllers/EventControlsCard.vc.js +9 -5
  67. package/build/viewControllers/RepeatingControlsList.vc.js +52 -58
  68. package/build/viewControllers/SelectUpdateRepeatingStrategyCard.vc.js +7 -4
  69. package/build/viewControllers/UniversalCalendarEvent.vc.js +1 -1
  70. package/package.json +1 -1
@@ -1,3 +1,2 @@
1
- /* eslint-disable @typescript-eslint/no-namespace */
2
- /* eslint-disable no-redeclare */
1
+ /* eslint-disable import/order */
3
2
  import '@sprucelabs/spruce-event-utils';
@@ -24,7 +24,6 @@ const calendarAssert = {
24
24
  try {
25
25
  assert.doesInclude(e, lookup);
26
26
  return e;
27
- // eslint-disable-next-line no-empty
28
27
  }
29
28
  catch (_a) { }
30
29
  return null;
@@ -156,8 +156,8 @@ try {
156
156
  assert.isTruthy(
157
157
  //@ts-ignore
158
158
  client.auth.skill, `You gotta be logged in as a skill! Try 'const { client } = await this.skills.loginAsCurrentSkill()'`);
159
- const typeSlugs = types.map((t) => (typeof t === 'string' ? t : t.typeSlug));
160
- const vcIds = types.map((t) => (typeof t === 'string' ? undefined : t.vcId));
159
+ const typeSlugs = types.map((t) => typeof t === 'string' ? t : t.typeSlug);
160
+ const vcIds = types.map((t) => typeof t === 'string' ? undefined : t.vcId);
161
161
  function sort(a, b) {
162
162
  return a.typeSlug > b.typeSlug ? 1 : -1;
163
163
  }
@@ -141,7 +141,6 @@ class CalendarViewController extends CoreCalendarViewController {
141
141
  yield ((_a = this.draftRemovedHandler) === null || _a === void 0 ? void 0 : _a.call(this));
142
142
  try {
143
143
  yield ((_b = this.persister) === null || _b === void 0 ? void 0 : _b.cancelEvent(id));
144
- // eslint-disable-next-line no-empty
145
144
  }
146
145
  catch (err) {
147
146
  console.error((_c = err.stack) !== null && _c !== void 0 ? _c : err.message);
@@ -203,7 +202,6 @@ class CalendarViewController extends CoreCalendarViewController {
203
202
  yield this.selectEvent(to.id);
204
203
  }
205
204
  }));
206
- // eslint-disable-next-line no-empty
207
205
  }
208
206
  catch (_a) { }
209
207
  this.isSwapping = false;
@@ -217,7 +215,6 @@ class CalendarViewController extends CoreCalendarViewController {
217
215
  void this.persist(updated);
218
216
  }
219
217
  return updated;
220
- // eslint-disable-next-line no-empty
221
218
  }
222
219
  catch (_a) { }
223
220
  return Object.assign({}, updates);
@@ -63,7 +63,7 @@ class CalendarEventManager {
63
63
  }
64
64
  get visibleCalendarIds() {
65
65
  var _a;
66
- return (_a = this.prefs.getVisibleCalendarIds()) !== null && _a !== void 0 ? _a : this.calendars.map((c) => c.id);
66
+ return ((_a = this.prefs.getVisibleCalendarIds()) !== null && _a !== void 0 ? _a : this.calendars.map((c) => c.id));
67
67
  }
68
68
  handleStreamEvents(options) {
69
69
  return __awaiter(this, void 0, void 0, function* () {
@@ -582,7 +582,8 @@ class CalendarEventManager {
582
582
  shouldUpdateAllEventsGoingForward = false;
583
583
  }
584
584
  this.dateToUpdate = dateToUpdate;
585
- this.shouldUpdateAllEventsGoingForward = shouldUpdateAllEventsGoingForward;
585
+ this.shouldUpdateAllEventsGoingForward =
586
+ shouldUpdateAllEventsGoingForward;
586
587
  }
587
588
  return { pass: true, dateToUpdate, shouldUpdateAllEventsGoingForward };
588
589
  });
@@ -53,7 +53,6 @@ export default class CalendarPeopleManager extends AbstractEventEmitter {
53
53
  .map((i) => {
54
54
  try {
55
55
  return this.teammateById(i);
56
- // eslint-disable-next-line no-empty
57
56
  }
58
57
  catch (_a) { }
59
58
  return null;
@@ -132,7 +131,6 @@ export default class CalendarPeopleManager extends AbstractEventEmitter {
132
131
  .map((id) => {
133
132
  try {
134
133
  return this.teammateById(id);
135
- // eslint-disable-next-line no-empty
136
134
  }
137
135
  catch (_a) { }
138
136
  return false;
@@ -19,9 +19,9 @@ export default class CalendarPersister {
19
19
  cancelEvent(id: string, options?: CancelEventRecurringOptions): Promise<void>;
20
20
  }
21
21
  type DraftHandlerCalendar = Pick<CalendarViewController, 'hasEvent' | 'updateEvent' | 'swapEvent' | 'removeEvent'>;
22
- export type CalendarPersisterOptions = {
22
+ export interface CalendarPersisterOptions {
23
23
  calendarVc: DraftHandlerCalendar;
24
24
  events?: RemoteEventStore;
25
25
  onEventSwapped?: EventSwappedHandler;
26
- };
26
+ }
27
27
  export {};
@@ -1,5 +1,5 @@
1
1
  import AbstractSpruceError from '@sprucelabs/error';
2
- import ErrorOptions from "./../.spruce/errors/options.types";
2
+ import ErrorOptions from './../.spruce/errors/options.types';
3
3
  export default class SpruceError extends AbstractSpruceError<ErrorOptions> {
4
4
  friendlyMessage(): string;
5
5
  }
@@ -1,3 +1,3 @@
1
- import { SpruceSchemas } from "./../.spruce/schemas/schemas.types";
1
+ import { SpruceSchemas } from './../.spruce/schemas/schemas.types';
2
2
  import { Person } from '../types/calendar.types';
3
3
  export default function peopleToPeopleWithoutSchedules(people: Person[]): SpruceSchemas.Calendar.v2021_05_19.PersonWithoutSchedule[];
@@ -92,6 +92,6 @@ export interface RootArgs {
92
92
  startDate?: number;
93
93
  visiblePeopleIds?: string[];
94
94
  }
95
- export type LoadEventOptions = {
95
+ export interface LoadEventOptions {
96
96
  shouldRenderAlertOnFail: boolean;
97
- };
97
+ }
@@ -271,7 +271,7 @@ class RootSkillViewController extends AbstractSkillViewController {
271
271
  });
272
272
  }
273
273
  handleCloseToolBelt(_a) {
274
- return __awaiter(this, arguments, void 0, function* ({ isDrawer }) {
274
+ return __awaiter(this, arguments, void 0, function* ({ isDrawer, }) {
275
275
  if (!isDrawer) {
276
276
  yield this.resetToRootState();
277
277
  if (this.draftEvent) {
@@ -453,7 +453,9 @@ class RootSkillViewController extends AbstractSkillViewController {
453
453
  return __awaiter(this, arguments, void 0, function* ({ target }) {
454
454
  const { calendarEventId } = target;
455
455
  if (this.events.hasEvent(calendarEventId)) {
456
- yield this.events.cancelEvent(calendarEventId, { shouldPersist: false });
456
+ yield this.events.cancelEvent(calendarEventId, {
457
+ shouldPersist: false,
458
+ });
457
459
  }
458
460
  });
459
461
  }
@@ -91,7 +91,8 @@ export default class RemoteEventStoreImpl {
91
91
  }
92
92
  delete event.isBusy;
93
93
  const lastSaved = (_b = this.lastSavedById[this.getId(id)]) !== null && _b !== void 0 ? _b : {};
94
- if (isEqual(lastSaved.before, event) || isEqual(lastSaved.after, event)) {
94
+ if (isEqual(lastSaved.before, event) ||
95
+ isEqual(lastSaved.after, event)) {
95
96
  resolve(lastSaved.after);
96
97
  }
97
98
  else {
@@ -102,7 +103,8 @@ export default class RemoteEventStoreImpl {
102
103
  if (draftEventGenerator.isDraftId(event.id)) {
103
104
  saved = yield this.createEvent(event);
104
105
  this.draftIdMap[event.id] = saved.id;
105
- this.queueByEventId[saved.id] = this.queueByEventId[event.id];
106
+ this.queueByEventId[saved.id] =
107
+ this.queueByEventId[event.id];
106
108
  delete this.queueByEventId[event.id];
107
109
  }
108
110
  else {
@@ -159,7 +161,8 @@ export default class RemoteEventStoreImpl {
159
161
  });
160
162
  }
161
163
  resolveCalendarId(event) {
162
- return event.calendarId && !draftEventGenerator.isDraftId(event.calendarId)
164
+ return event.calendarId &&
165
+ !draftEventGenerator.isDraftId(event.calendarId)
163
166
  ? event.calendarId
164
167
  : this.calendarId;
165
168
  }
@@ -257,7 +260,7 @@ export default class RemoteEventStoreImpl {
257
260
  });
258
261
  }
259
262
  buildTargetAndPayload(options) {
260
- const { calendarIds, peopleIds: personIds, startDate, endDate } = options;
263
+ const { calendarIds, peopleIds: personIds, startDate, endDate, } = options;
261
264
  const targetAndPayload = {
262
265
  target: {
263
266
  calendarIds,
@@ -28,7 +28,10 @@ class CalendarToolRegistrar {
28
28
  cards = fetchedCards;
29
29
  }
30
30
  else {
31
- cards = CalendarToolRegistrar.fetchedRecord[cacheKey].map((vcId) => { var _a; return this.views.Controller(vcId, (_a = getControllerOptions === null || getControllerOptions === void 0 ? void 0 : getControllerOptions(vcId)) !== null && _a !== void 0 ? _a : {}); });
31
+ cards = CalendarToolRegistrar.fetchedRecord[cacheKey].map((vcId) => {
32
+ var _a;
33
+ return this.views.Controller(vcId, (_a = getControllerOptions === null || getControllerOptions === void 0 ? void 0 : getControllerOptions(vcId)) !== null && _a !== void 0 ? _a : {});
34
+ });
32
35
  }
33
36
  yield Promise.all(cards.map((card) => this.addTool(card)));
34
37
  return cards;
@@ -151,8 +151,11 @@ export default class AbstractCalendarEventToolBeltState {
151
151
  return __awaiter(this, void 0, void 0, function* () {
152
152
  this.vcs.push({ vc, toolId });
153
153
  if (typeof vc.handleUpdateContext !== 'function') {
154
- //@ts-ignore
155
- throw new SpruceError({ code: 'CALENDAR_TOOL_INTERFACE', vcId: vc.id });
154
+ throw new SpruceError({
155
+ code: 'CALENDAR_TOOL_INTERFACE',
156
+ //@ts-ignore
157
+ vcId: vc.id,
158
+ });
156
159
  }
157
160
  this.toolBeltVc.addTool({
158
161
  id: toolId,
@@ -66,7 +66,8 @@ export class RootToolBeltState {
66
66
  resetToolBelt() {
67
67
  var _a;
68
68
  if (!this.scopeSelectionTool) {
69
- this.scopeSelectionTool = (_a = this.toolBeltVc) === null || _a === void 0 ? void 0 : _a.getTool('scope-selection');
69
+ this.scopeSelectionTool =
70
+ (_a = this.toolBeltVc) === null || _a === void 0 ? void 0 : _a.getTool('scope-selection');
70
71
  }
71
72
  this.toolBeltVc.clearTools();
72
73
  }
@@ -29,7 +29,9 @@ class CalendarSelectCardViewController extends AbstractViewController {
29
29
  noResultsRow: {
30
30
  cells: [
31
31
  {
32
- text: { content: "You don't have any calendars yet!" },
32
+ text: {
33
+ content: "You don't have any calendars yet!",
34
+ },
33
35
  },
34
36
  ],
35
37
  },
@@ -51,7 +53,8 @@ class CalendarSelectCardViewController extends AbstractViewController {
51
53
  value: this.selectedCalendarIds.indexOf(calendar.id) > -1,
52
54
  onChange: (isVisible) => __awaiter(this, void 0, void 0, function* () {
53
55
  const calendarId = calendar.id;
54
- this.changePromise = this.events.setCalendarVisibility(calendarId, isVisible);
56
+ this.changePromise =
57
+ this.events.setCalendarVisibility(calendarId, isVisible);
55
58
  const p = this.changePromise;
56
59
  return p;
57
60
  }),
@@ -28,7 +28,9 @@ class EventRepeatingToolViewController extends AbstractViewController {
28
28
  },
29
29
  body: {
30
30
  isBusy: false,
31
- sections: [{ shouldBePadded: false, form: this.formVc.render() }],
31
+ sections: [
32
+ { shouldBePadded: false, form: this.formVc.render() },
33
+ ],
32
34
  },
33
35
  });
34
36
  }
@@ -98,11 +98,15 @@ class PersonSelectToolViewController extends AbstractViewController {
98
98
  id: person.id,
99
99
  cells: [
100
100
  {
101
- avatars: ((_a = person.avatar) === null || _a === void 0 ? void 0 : _a.mUri) ? [person.avatar.mUri] : undefined,
101
+ avatars: ((_a = person.avatar) === null || _a === void 0 ? void 0 : _a.mUri)
102
+ ? [person.avatar.mUri]
103
+ : undefined,
102
104
  },
103
105
  {
104
106
  text: {
105
- content: this.isPersonLoggedIn(person) ? 'You' : person.casualName,
107
+ content: this.isPersonLoggedIn(person)
108
+ ? 'You'
109
+ : person.casualName,
106
110
  },
107
111
  },
108
112
  {
@@ -111,7 +115,8 @@ class PersonSelectToolViewController extends AbstractViewController {
111
115
  value: !!this.visiblePeopleIds.find((id) => id === person.id),
112
116
  onChange: (value) => __awaiter(this, void 0, void 0, function* () {
113
117
  if (this.shouldUpdateVisibilityOnToggleChange) {
114
- this.updatePromise = this.people.setPersonVisibility(person.id, value !== null && value !== void 0 ? value : false);
118
+ this.updatePromise =
119
+ this.people.setPersonVisibility(person.id, value !== null && value !== void 0 ? value : false);
115
120
  }
116
121
  }),
117
122
  },
@@ -12,10 +12,7 @@ import { assertOptions } from '@sprucelabs/schema';
12
12
  class DateSelectCardViewController extends AbstractViewController {
13
13
  constructor(options) {
14
14
  super(options);
15
- const { onSelectDate, startDate, selectedDate } = assertOptions(options, [
16
- 'onSelectDate',
17
- 'startDate',
18
- ]);
15
+ const { onSelectDate, startDate, selectedDate } = assertOptions(options, ['onSelectDate', 'startDate']);
19
16
  this.dateSelectHandler = onSelectDate;
20
17
  this.calendarVc = this.CalendarVc({
21
18
  startDate,
@@ -213,7 +213,8 @@ class RepeatingControlsListViewController extends AbstractViewController {
213
213
  : undefined,
214
214
  onChange: (value) => {
215
215
  var _a;
216
- this.repeating.repeatsUntil = this.dates.getEndOfDay(value);
216
+ this.repeating.repeatsUntil =
217
+ this.dates.getEndOfDay(value);
217
218
  (_a = this.didChangeRepeating) === null || _a === void 0 ? void 0 : _a.call(this, this.repeating);
218
219
  },
219
220
  },
@@ -1,3 +1,3 @@
1
- import { SpruceSchemas } from "./../.spruce/schemas/schemas.types";
1
+ import { SpruceSchemas } from './../.spruce/schemas/schemas.types';
2
2
  import { Person } from '../types/calendar.types';
3
3
  export default function peopleToPeopleWithoutSchedules(people: Person[]): SpruceSchemas.Calendar.v2021_05_19.PersonWithoutSchedule[];
@@ -92,6 +92,6 @@ export interface RootArgs {
92
92
  startDate?: number;
93
93
  visiblePeopleIds?: string[];
94
94
  }
95
- export type LoadEventOptions = {
95
+ export interface LoadEventOptions {
96
96
  shouldRenderAlertOnFail: boolean;
97
- };
97
+ }
@@ -12,10 +12,35 @@ const RemotePreferencesStore_1 = __importDefault(require("../stores/RemotePrefer
12
12
  const PrerequisitesToolBeltState_1 = require("../toolBelt/states/PrerequisitesToolBeltState");
13
13
  const RootToolBeltState_1 = require("../toolBelt/states/RootToolBeltState");
14
14
  class RootSkillViewController extends heartwood_view_controllers_1.AbstractSkillViewController {
15
+ static id = 'root';
16
+ static shouldConfirmDrops = false;
17
+ static shouldUpdateOnInterval = true;
18
+ static refreshInterval = 1000 * 60;
19
+ static shouldCacheEvents = false;
20
+ calendarVc;
21
+ toolBeltVc;
22
+ person;
23
+ sm;
24
+ toolBeltStates;
25
+ remoteEventStore;
26
+ selectingTypePromise;
27
+ selectingTypeResolve;
28
+ client;
29
+ organizationId;
30
+ locationId;
31
+ transitionPromise;
32
+ loadEventsPromise;
33
+ events;
34
+ preferences;
35
+ people;
36
+ remoteVc;
37
+ draftEvent;
38
+ loadEventInterval;
39
+ shouldIgnoreNextDeselectEvent = false;
40
+ lastStartDate;
41
+ locale;
15
42
  constructor(options) {
16
43
  super(options);
17
- this.shouldIgnoreNextDeselectEvent = false;
18
- this.getScope = () => ['employed', 'location'];
19
44
  this.toolBeltVc = this.ToolBeltVc();
20
45
  this.calendarVc = this.CalendarVc();
21
46
  this.sm = this.ToolBeltStateMachine();
@@ -52,6 +77,7 @@ class RootSkillViewController extends heartwood_view_controllers_1.AbstractSkill
52
77
  this.handleDidCreateOrUpdateRemoteEvent.bind(this);
53
78
  this.handleDidCancelEvent = this.handleDidCancelEvent.bind(this);
54
79
  }
80
+ getScope = () => ['employed', 'location'];
55
81
  createToolBeltStates() {
56
82
  this.toolBeltStates = {
57
83
  root: new RootToolBeltState_1.RootToolBeltState({
@@ -78,9 +104,8 @@ class RootSkillViewController extends heartwood_view_controllers_1.AbstractSkill
78
104
  return sm;
79
105
  }
80
106
  async handleCancelEvent(eventId) {
81
- var _a;
82
107
  const event = this.events.getEvent(eventId);
83
- const confirm = ((_a = event.totalInRepeating) !== null && _a !== void 0 ? _a : 0) > 0 ||
108
+ const confirm = (event.totalInRepeating ?? 0) > 0 ||
84
109
  (await this.confirm({
85
110
  title: 'Cancel?',
86
111
  message: `You wanna cancel this?`,
@@ -92,19 +117,21 @@ class RootSkillViewController extends heartwood_view_controllers_1.AbstractSkill
92
117
  }
93
118
  async askForUpdateStrategy(cleaned, action = 'update') {
94
119
  let strategy;
95
- const dlg = this.renderInDialog(Object.assign({ shouldShowCloseButton: false }, this.Controller('calendar.select-update-repeating-strategy-card', {
96
- event: cleaned,
97
- action,
98
- onSelectStrategy: async (s) => {
99
- strategy = s;
100
- await dlg.hide();
101
- },
102
- }).render()));
120
+ const dlg = this.renderInDialog({
121
+ shouldShowCloseButton: false,
122
+ ...this.Controller('calendar.select-update-repeating-strategy-card', {
123
+ event: cleaned,
124
+ action,
125
+ onSelectStrategy: async (s) => {
126
+ strategy = s;
127
+ await dlg.hide();
128
+ },
129
+ }).render(),
130
+ });
103
131
  await dlg.wait();
104
132
  return strategy;
105
133
  }
106
134
  async handleSelectEventType(type) {
107
- var _a, _b;
108
135
  this.selectingTypePromise = new Promise((resolve) => {
109
136
  this.selectingTypeResolve = resolve;
110
137
  });
@@ -114,7 +141,7 @@ class RootSkillViewController extends heartwood_view_controllers_1.AbstractSkill
114
141
  await this.transitionToStateFromDraftEvent();
115
142
  }
116
143
  catch (err) {
117
- (_a = this.selectingTypeResolve) === null || _a === void 0 ? void 0 : _a.call(this);
144
+ this.selectingTypeResolve?.();
118
145
  console.error(err);
119
146
  await this.alert({
120
147
  message: `I could not load what I need to add your ${type.name}! I've let the humans know and they are on the case!`,
@@ -123,7 +150,7 @@ class RootSkillViewController extends heartwood_view_controllers_1.AbstractSkill
123
150
  return;
124
151
  }
125
152
  }
126
- (_b = this.selectingTypeResolve) === null || _b === void 0 ? void 0 : _b.call(this);
153
+ this.selectingTypeResolve?.();
127
154
  }
128
155
  async restoreDraftAfterStateLoadError() {
129
156
  await this.waitUntilDoneSaving();
@@ -136,9 +163,8 @@ class RootSkillViewController extends heartwood_view_controllers_1.AbstractSkill
136
163
  await this.transitionToolBeltForEvent(event.id);
137
164
  }
138
165
  async transitionToolBeltForEvent(eventId) {
139
- var _a;
140
166
  const vc = this.calendarVc.getEventVc(eventId);
141
- const state = (_a = vc.getToolBeltState) === null || _a === void 0 ? void 0 : _a.call(vc);
167
+ const state = vc.getToolBeltState?.();
142
168
  if (state) {
143
169
  await this.transitionTo(state);
144
170
  }
@@ -147,9 +173,8 @@ class RootSkillViewController extends heartwood_view_controllers_1.AbstractSkill
147
173
  await this.sm.transitionTo(state);
148
174
  }
149
175
  async waitUntilDoneSaving() {
150
- var _a;
151
176
  await Promise.all([
152
- (_a = this.remoteEventStore) === null || _a === void 0 ? void 0 : _a.waitForPendingSaves(),
177
+ this.remoteEventStore?.waitForPendingSaves(),
153
178
  this.selectingTypePromise,
154
179
  this.transitionPromise,
155
180
  this.loadEventsPromise,
@@ -159,8 +184,7 @@ class RootSkillViewController extends heartwood_view_controllers_1.AbstractSkill
159
184
  ]);
160
185
  }
161
186
  async handleSelectCalendar(calendar) {
162
- var _a;
163
- (_a = this.remoteEventStore) === null || _a === void 0 ? void 0 : _a.setCalendarId(calendar.id);
187
+ this.remoteEventStore?.setCalendarId(calendar.id);
164
188
  await this.events.makeCalendarVisible(calendar.id);
165
189
  }
166
190
  getToolBeltStateMachine() {
@@ -212,8 +236,7 @@ class RootSkillViewController extends heartwood_view_controllers_1.AbstractSkill
212
236
  this.rootToolBeltState.setSelectedDate(year, month, day);
213
237
  }
214
238
  getStartDate() {
215
- var _a;
216
- return (_a = this.calendarVc.getStartDate()) !== null && _a !== void 0 ? _a : this.dates.date();
239
+ return this.calendarVc.getStartDate() ?? this.dates.date();
217
240
  }
218
241
  async handleDeselectEvent() {
219
242
  if (this.shouldIgnoreNextDeselectEvent ||
@@ -242,7 +265,7 @@ class RootSkillViewController extends heartwood_view_controllers_1.AbstractSkill
242
265
  shouldRenderAllToolsAtOnce: true,
243
266
  });
244
267
  }
245
- async handleCloseToolBelt({ isDrawer }) {
268
+ async handleCloseToolBelt({ isDrawer, }) {
246
269
  if (!isDrawer) {
247
270
  await this.resetToRootState();
248
271
  if (this.draftEvent) {
@@ -253,7 +276,6 @@ class RootSkillViewController extends heartwood_view_controllers_1.AbstractSkill
253
276
  }
254
277
  }
255
278
  async handleClickEvent(options) {
256
- var _a, _b;
257
279
  const { event } = options;
258
280
  const selected = this.events.getSelectedEvent();
259
281
  if (selected) {
@@ -261,7 +283,7 @@ class RootSkillViewController extends heartwood_view_controllers_1.AbstractSkill
261
283
  }
262
284
  await this.events.selectEvent(event.id);
263
285
  this.toolBeltVc.open({ shouldStayOpen: true });
264
- const isSameEventTypeSlug = (selected === null || selected === void 0 ? void 0 : selected.eventTypeSlug) === event.eventTypeSlug;
286
+ const isSameEventTypeSlug = selected?.eventTypeSlug === event.eventTypeSlug;
265
287
  const shouldNotTransition = selected && isSameEventTypeSlug;
266
288
  if (shouldNotTransition) {
267
289
  return;
@@ -275,10 +297,11 @@ class RootSkillViewController extends heartwood_view_controllers_1.AbstractSkill
275
297
  }
276
298
  }
277
299
  catch (err) {
278
- console.error((_a = err.stack) !== null && _a !== void 0 ? _a : err.message);
300
+ console.error(err.stack ?? err.message);
279
301
  await this.events.deselectEvent();
280
302
  await this.alert({
281
- message: (_b = err.message) !== null && _b !== void 0 ? _b : 'Shoot! I could not load that for you! Refresh and try again!!',
303
+ message: err.message ??
304
+ 'Shoot! I could not load that for you! Refresh and try again!!',
282
305
  });
283
306
  }
284
307
  }
@@ -329,8 +352,11 @@ class RootSkillViewController extends heartwood_view_controllers_1.AbstractSkill
329
352
  return this.calendarVc;
330
353
  }
331
354
  async load(options) {
332
- var _a;
333
- await this.sm.updateContext(Object.assign(Object.assign({}, options), { people: this.people, events: this.events }));
355
+ await this.sm.updateContext({
356
+ ...options,
357
+ people: this.people,
358
+ events: this.events,
359
+ });
334
360
  this.client = await this.connectToApi();
335
361
  const { scope, locale, args, router } = options;
336
362
  this.locale = locale;
@@ -347,7 +373,8 @@ class RootSkillViewController extends heartwood_view_controllers_1.AbstractSkill
347
373
  }
348
374
  catch (err) {
349
375
  await this.alert({
350
- message: (_a = err.message) !== null && _a !== void 0 ? _a : 'Something catastrophic happened! We gotta get out of there!',
376
+ message: err.message ??
377
+ 'Something catastrophic happened! We gotta get out of there!',
351
378
  });
352
379
  await router.redirect('heartwood.root');
353
380
  return;
@@ -387,12 +414,11 @@ class RootSkillViewController extends heartwood_view_controllers_1.AbstractSkill
387
414
  }
388
415
  }
389
416
  async destroy() {
390
- var _a, _b, _c, _d;
391
417
  clearInterval(this.loadEventInterval);
392
- await ((_a = this.client) === null || _a === void 0 ? void 0 : _a.off('connection-status-change', this.handleStateChange));
393
- await ((_b = this.client) === null || _b === void 0 ? void 0 : _b.off('calendar.did-create-calendar-event::v2021_05_19', this.handleDidCreateOrUpdateRemoteEvent));
394
- await ((_c = this.client) === null || _c === void 0 ? void 0 : _c.off('calendar.did-update-calendar-event::v2021_05_19', this.handleDidCreateOrUpdateRemoteEvent));
395
- await ((_d = this.client) === null || _d === void 0 ? void 0 : _d.off('calendar.did-cancel-calendar-event::v2021_05_19', this.handleDidCancelEvent));
418
+ await this.client?.off('connection-status-change', this.handleStateChange);
419
+ await this.client?.off('calendar.did-create-calendar-event::v2021_05_19', this.handleDidCreateOrUpdateRemoteEvent);
420
+ await this.client?.off('calendar.did-update-calendar-event::v2021_05_19', this.handleDidCreateOrUpdateRemoteEvent);
421
+ await this.client?.off('calendar.did-cancel-calendar-event::v2021_05_19', this.handleDidCancelEvent);
396
422
  }
397
423
  async setupCalendarEventListeners() {
398
424
  await Promise.all([
@@ -404,7 +430,9 @@ class RootSkillViewController extends heartwood_view_controllers_1.AbstractSkill
404
430
  async handleDidCancelEvent({ target }) {
405
431
  const { calendarEventId } = target;
406
432
  if (this.events.hasEvent(calendarEventId)) {
407
- await this.events.cancelEvent(calendarEventId, { shouldPersist: false });
433
+ await this.events.cancelEvent(calendarEventId, {
434
+ shouldPersist: false,
435
+ });
408
436
  }
409
437
  }
410
438
  async handleDidCreateOrUpdateRemoteEvent({ payload, target, }) {
@@ -412,7 +440,10 @@ class RootSkillViewController extends heartwood_view_controllers_1.AbstractSkill
412
440
  const { locationId } = target;
413
441
  if (calendarEvent.style !== 'draft' && locationId === this.locationId) {
414
442
  if (this.events.hasEvent(calendarEvent.id)) {
415
- this.events.updateEvent(calendarEvent.id, Object.assign(Object.assign({}, calendarEvent), { shouldPersist: false }));
443
+ this.events.updateEvent(calendarEvent.id, {
444
+ ...calendarEvent,
445
+ shouldPersist: false,
446
+ });
416
447
  }
417
448
  else {
418
449
  this.events.addEvent(calendarEvent);
@@ -441,8 +472,8 @@ class RootSkillViewController extends heartwood_view_controllers_1.AbstractSkill
441
472
  scope.getCurrentLocation(),
442
473
  this.loadLoggedInPerson(),
443
474
  ]);
444
- this.organizationId = location === null || location === void 0 ? void 0 : location.organizationId;
445
- this.locationId = location === null || location === void 0 ? void 0 : location.id;
475
+ this.organizationId = location?.organizationId;
476
+ this.locationId = location?.id;
446
477
  }
447
478
  syncPeopleOnCalendar() {
448
479
  const visiblePeople = this.people.getVisiblePeople();
@@ -457,7 +488,6 @@ class RootSkillViewController extends heartwood_view_controllers_1.AbstractSkill
457
488
  await this.loadEventsPromise;
458
489
  }
459
490
  async _loadEvents(options) {
460
- var _a;
461
491
  try {
462
492
  if (this.events.getCalendars().length > 0) {
463
493
  const date = this.getStartDate();
@@ -469,13 +499,13 @@ class RootSkillViewController extends heartwood_view_controllers_1.AbstractSkill
469
499
  }
470
500
  }
471
501
  catch (err) {
472
- if ((options === null || options === void 0 ? void 0 : options.shouldRenderAlertOnFail) === false) {
502
+ if (options?.shouldRenderAlertOnFail === false) {
473
503
  this.toast({
474
504
  message: 'Updating your calendar failed! Trying to connect...',
475
505
  });
476
506
  return;
477
507
  }
478
- console.error((_a = err.stack) !== null && _a !== void 0 ? _a : err.message);
508
+ console.error(err.stack ?? err.message);
479
509
  void this.alert({
480
510
  message: err.message,
481
511
  });
@@ -526,9 +556,4 @@ class RootSkillViewController extends heartwood_view_controllers_1.AbstractSkill
526
556
  };
527
557
  }
528
558
  }
529
- RootSkillViewController.id = 'root';
530
- RootSkillViewController.shouldConfirmDrops = false;
531
- RootSkillViewController.shouldUpdateOnInterval = true;
532
- RootSkillViewController.refreshInterval = 1000 * 60;
533
- RootSkillViewController.shouldCacheEvents = false;
534
559
  exports.default = RootSkillViewController;