@sprucelabs/spruce-calendar-components 20.9.35 → 20.9.36

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.
@@ -5,6 +5,7 @@ export interface RemoteEventStoreOptions {
5
5
  client: MercuryClient;
6
6
  calendarId?: string;
7
7
  locationId: string;
8
+ organizationId: string;
8
9
  }
9
10
  declare type FullEvent = SpruceSchemas.CalendarUtils.v2021_05_19.CalendarEvent;
10
11
  export default class RemoteEventStore {
@@ -17,6 +18,7 @@ export default class RemoteEventStore {
17
18
  private queueByEventId;
18
19
  private busyByEvent;
19
20
  private lastSavedById;
21
+ private organizationId;
20
22
  constructor(options: RemoteEventStoreOptions);
21
23
  persist(event: UpdateEvent): Promise<FullEvent>;
22
24
  private startQueueForEvent;
@@ -32,6 +34,14 @@ export default class RemoteEventStore {
32
34
  clearCalendarId(): void;
33
35
  getCalendarId(): string | undefined;
34
36
  waitForPendingSaves(): Promise<void>;
35
- deleteEvent(id: string): Promise<void>;
37
+ cancelEvent(id: string): Promise<void>;
38
+ getSchedules(options: {
39
+ calendarIds: string[];
40
+ personIds: string[];
41
+ startDate: number;
42
+ endDate: number;
43
+ }): Promise<import("@sprucelabs/schema").SchemaStaticValues<SpruceSchemas.CalendarUtils.v2021_05_19.CalendarEventSchema, false, import("@sprucelabs/schema").SchemaOptionalFieldNames<SpruceSchemas.CalendarUtils.v2021_05_19.CalendarEventSchema>, import("@sprucelabs/schema").StaticSchemaAllValues<SpruceSchemas.CalendarUtils.v2021_05_19.CalendarEventSchema, false>>[]>;
44
+ loadEventTypes(): Promise<import("@sprucelabs/schema").SchemaStaticValues<SpruceSchemas.Calendar.v2021_05_19.CalendarEventTypeSchema, false, import("@sprucelabs/schema").SchemaOptionalFieldNames<SpruceSchemas.Calendar.v2021_05_19.CalendarEventTypeSchema>, import("@sprucelabs/schema").StaticSchemaAllValues<SpruceSchemas.Calendar.v2021_05_19.CalendarEventTypeSchema, false>>[]>;
45
+ loadCalendars(): Promise<import("@sprucelabs/schema").SchemaStaticValues<SpruceSchemas.Calendar.v2021_05_19.CalendarSchema, false, import("@sprucelabs/schema").SchemaOptionalFieldNames<SpruceSchemas.Calendar.v2021_05_19.CalendarSchema>, import("@sprucelabs/schema").StaticSchemaAllValues<SpruceSchemas.Calendar.v2021_05_19.CalendarSchema, false>>[]>;
36
46
  }
37
47
  export {};
@@ -28,10 +28,11 @@ export default class RemoteEventStore {
28
28
  this.queueByEventId = {};
29
29
  this.busyByEvent = {};
30
30
  this.lastSavedById = {};
31
- assertOptions(options, ['client', 'locationId']);
32
- this.client = options.client;
33
- this.calendarId = options.calendarId;
34
- this.locationId = options.locationId;
31
+ const { client, calendarId, locationId, organizationId } = assertOptions(options, ['client', 'locationId', 'organizationId']);
32
+ this.client = client;
33
+ this.calendarId = calendarId;
34
+ this.locationId = locationId;
35
+ this.organizationId = organizationId;
35
36
  }
36
37
  persist(event) {
37
38
  return __awaiter(this, void 0, void 0, function* () {
@@ -197,7 +198,7 @@ export default class RemoteEventStore {
197
198
  yield Promise.all(this.promises);
198
199
  });
199
200
  }
200
- deleteEvent(id) {
201
+ cancelEvent(id) {
201
202
  var _a;
202
203
  return __awaiter(this, void 0, void 0, function* () {
203
204
  if (((_a = this.pendingEvent) === null || _a === void 0 ? void 0 : _a.id) === id) {
@@ -213,6 +214,39 @@ export default class RemoteEventStore {
213
214
  }
214
215
  });
215
216
  }
217
+ getSchedules(options) {
218
+ return __awaiter(this, void 0, void 0, function* () {
219
+ const { calendarIds, personIds, startDate, endDate } = options;
220
+ const [{ events }] = yield this.client.emitAndFlattenResponses('calendar.get-schedules::v2021_05_19', {
221
+ target: {
222
+ calendarIds,
223
+ locationId: this.locationId,
224
+ },
225
+ payload: {
226
+ startDateTimeMs: startDate,
227
+ endDateTimeMs: endDate,
228
+ personIds,
229
+ },
230
+ });
231
+ return events;
232
+ });
233
+ }
234
+ loadEventTypes() {
235
+ return __awaiter(this, void 0, void 0, function* () {
236
+ const [{ calendarEventTypes }] = yield this.client.emitAndFlattenResponses('calendar.list-calendar-event-types::v2021_05_19');
237
+ return calendarEventTypes;
238
+ });
239
+ }
240
+ loadCalendars() {
241
+ return __awaiter(this, void 0, void 0, function* () {
242
+ const [{ calendars }] = yield this.client.emitAndFlattenResponses('calendar.list-calendars::v2021_05_19', {
243
+ target: {
244
+ organizationId: this.organizationId,
245
+ },
246
+ });
247
+ return calendars;
248
+ });
249
+ }
216
250
  }
217
251
  const equals = (a, b) => {
218
252
  if (a === b) {
@@ -102,7 +102,7 @@ export default class CalendarViewController extends CoreCalendarViewController {
102
102
  this.removeEvent(id);
103
103
  yield ((_a = this.draftRemovedHandler) === null || _a === void 0 ? void 0 : _a.call(this));
104
104
  try {
105
- yield ((_b = this.remoteEventStore) === null || _b === void 0 ? void 0 : _b.deleteEvent(id));
105
+ yield ((_b = this.remoteEventStore) === null || _b === void 0 ? void 0 : _b.cancelEvent(id));
106
106
  // eslint-disable-next-line no-empty
107
107
  }
108
108
  catch (err) {
@@ -5,6 +5,7 @@ export interface RemoteEventStoreOptions {
5
5
  client: MercuryClient;
6
6
  calendarId?: string;
7
7
  locationId: string;
8
+ organizationId: string;
8
9
  }
9
10
  declare type FullEvent = SpruceSchemas.CalendarUtils.v2021_05_19.CalendarEvent;
10
11
  export default class RemoteEventStore {
@@ -17,6 +18,7 @@ export default class RemoteEventStore {
17
18
  private queueByEventId;
18
19
  private busyByEvent;
19
20
  private lastSavedById;
21
+ private organizationId;
20
22
  constructor(options: RemoteEventStoreOptions);
21
23
  persist(event: UpdateEvent): Promise<FullEvent>;
22
24
  private startQueueForEvent;
@@ -32,6 +34,14 @@ export default class RemoteEventStore {
32
34
  clearCalendarId(): void;
33
35
  getCalendarId(): string | undefined;
34
36
  waitForPendingSaves(): Promise<void>;
35
- deleteEvent(id: string): Promise<void>;
37
+ cancelEvent(id: string): Promise<void>;
38
+ getSchedules(options: {
39
+ calendarIds: string[];
40
+ personIds: string[];
41
+ startDate: number;
42
+ endDate: number;
43
+ }): Promise<import("@sprucelabs/schema").SchemaStaticValues<SpruceSchemas.CalendarUtils.v2021_05_19.CalendarEventSchema, false, import("@sprucelabs/schema").SchemaOptionalFieldNames<SpruceSchemas.CalendarUtils.v2021_05_19.CalendarEventSchema>, import("@sprucelabs/schema").StaticSchemaAllValues<SpruceSchemas.CalendarUtils.v2021_05_19.CalendarEventSchema, false>>[]>;
44
+ loadEventTypes(): Promise<import("@sprucelabs/schema").SchemaStaticValues<SpruceSchemas.Calendar.v2021_05_19.CalendarEventTypeSchema, false, import("@sprucelabs/schema").SchemaOptionalFieldNames<SpruceSchemas.Calendar.v2021_05_19.CalendarEventTypeSchema>, import("@sprucelabs/schema").StaticSchemaAllValues<SpruceSchemas.Calendar.v2021_05_19.CalendarEventTypeSchema, false>>[]>;
45
+ loadCalendars(): Promise<import("@sprucelabs/schema").SchemaStaticValues<SpruceSchemas.Calendar.v2021_05_19.CalendarSchema, false, import("@sprucelabs/schema").SchemaOptionalFieldNames<SpruceSchemas.Calendar.v2021_05_19.CalendarSchema>, import("@sprucelabs/schema").StaticSchemaAllValues<SpruceSchemas.Calendar.v2021_05_19.CalendarSchema, false>>[]>;
36
46
  }
37
47
  export {};
@@ -24,10 +24,11 @@ class RemoteEventStore {
24
24
  this.queueByEventId = {};
25
25
  this.busyByEvent = {};
26
26
  this.lastSavedById = {};
27
- (0, schema_1.assertOptions)(options, ['client', 'locationId']);
28
- this.client = options.client;
29
- this.calendarId = options.calendarId;
30
- this.locationId = options.locationId;
27
+ const { client, calendarId, locationId, organizationId } = (0, schema_1.assertOptions)(options, ['client', 'locationId', 'organizationId']);
28
+ this.client = client;
29
+ this.calendarId = calendarId;
30
+ this.locationId = locationId;
31
+ this.organizationId = organizationId;
31
32
  }
32
33
  async persist(event) {
33
34
  if (!this.resolveCalendarId(event)) {
@@ -181,7 +182,7 @@ class RemoteEventStore {
181
182
  async waitForPendingSaves() {
182
183
  await Promise.all(this.promises);
183
184
  }
184
- async deleteEvent(id) {
185
+ async cancelEvent(id) {
185
186
  var _a;
186
187
  if (((_a = this.pendingEvent) === null || _a === void 0 ? void 0 : _a.id) === id) {
187
188
  delete this.pendingEvent;
@@ -195,6 +196,33 @@ class RemoteEventStore {
195
196
  });
196
197
  }
197
198
  }
199
+ async getSchedules(options) {
200
+ const { calendarIds, personIds, startDate, endDate } = options;
201
+ const [{ events }] = await this.client.emitAndFlattenResponses('calendar.get-schedules::v2021_05_19', {
202
+ target: {
203
+ calendarIds,
204
+ locationId: this.locationId,
205
+ },
206
+ payload: {
207
+ startDateTimeMs: startDate,
208
+ endDateTimeMs: endDate,
209
+ personIds,
210
+ },
211
+ });
212
+ return events;
213
+ }
214
+ async loadEventTypes() {
215
+ const [{ calendarEventTypes }] = await this.client.emitAndFlattenResponses('calendar.list-calendar-event-types::v2021_05_19');
216
+ return calendarEventTypes;
217
+ }
218
+ async loadCalendars() {
219
+ const [{ calendars }] = await this.client.emitAndFlattenResponses('calendar.list-calendars::v2021_05_19', {
220
+ target: {
221
+ organizationId: this.organizationId,
222
+ },
223
+ });
224
+ return calendars;
225
+ }
198
226
  }
199
227
  exports.default = RemoteEventStore;
200
228
  const equals = (a, b) => {
@@ -93,7 +93,7 @@ class CalendarViewController extends heartwood_view_controllers_1.CalendarViewCo
93
93
  this.removeEvent(id);
94
94
  await ((_a = this.draftRemovedHandler) === null || _a === void 0 ? void 0 : _a.call(this));
95
95
  try {
96
- await ((_b = this.remoteEventStore) === null || _b === void 0 ? void 0 : _b.deleteEvent(id));
96
+ await ((_b = this.remoteEventStore) === null || _b === void 0 ? void 0 : _b.cancelEvent(id));
97
97
  // eslint-disable-next-line no-empty
98
98
  }
99
99
  catch (err) {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@sprucelabs/spruce-calendar-components",
3
3
  "description": "Calendar components for working with calendars and Sprucebot.",
4
- "version": "20.9.35",
4
+ "version": "20.9.36",
5
5
  "skill": {
6
6
  "namespace": "calendar"
7
7
  },