@sprucelabs/spruce-calendar-components 20.9.36 → 20.9.39

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.
@@ -867,6 +867,138 @@ declare module '@sprucelabs/spruce-core-schemas/build/.spruce/schemas/core.schem
867
867
  }
868
868
  type CancelCalendarEventResponsePayloadEntity = SchemaEntity<SpruceSchemas.Calendar.v2021_05_19.CancelCalendarEventResponsePayloadSchema>;
869
869
  }
870
+ namespace SpruceSchemas.Calendar.v2021_05_19 {
871
+ interface CreateCalendarEmitTarget {
872
+ 'organizationId': string;
873
+ }
874
+ interface CreateCalendarEmitTargetSchema extends SpruceSchema.Schema {
875
+ id: 'createCalendarEmitTarget';
876
+ version: 'v2021_05_19';
877
+ namespace: 'Calendar';
878
+ name: '';
879
+ fields: {
880
+ /** . */
881
+ 'organizationId': {
882
+ type: 'id';
883
+ isRequired: true;
884
+ options: undefined;
885
+ };
886
+ };
887
+ }
888
+ type CreateCalendarEmitTargetEntity = SchemaEntity<SpruceSchemas.Calendar.v2021_05_19.CreateCalendarEmitTargetSchema>;
889
+ }
890
+ namespace SpruceSchemas.Calendar.v2021_05_19 {
891
+ interface CreateCalendarEmitPayload {
892
+ 'slug': string;
893
+ 'title': string;
894
+ 'eventTypes'?: string[] | undefined | null;
895
+ 'availableTimeSlotBehavior'?: ("include" | "exclude") | undefined | null;
896
+ }
897
+ interface CreateCalendarEmitPayloadSchema extends SpruceSchema.Schema {
898
+ id: 'createCalendarEmitPayload';
899
+ version: 'v2021_05_19';
900
+ namespace: 'Calendar';
901
+ name: '';
902
+ fields: {
903
+ /** . */
904
+ 'slug': {
905
+ type: 'id';
906
+ isRequired: true;
907
+ options: undefined;
908
+ };
909
+ /** . */
910
+ 'title': {
911
+ type: 'text';
912
+ isRequired: true;
913
+ options: undefined;
914
+ };
915
+ /** . */
916
+ 'eventTypes': {
917
+ type: 'text';
918
+ isArray: true;
919
+ minArrayLength: 0;
920
+ options: undefined;
921
+ };
922
+ /** . */
923
+ 'availableTimeSlotBehavior': {
924
+ type: 'select';
925
+ options: {
926
+ choices: [{
927
+ "value": "include";
928
+ "label": "Include";
929
+ }, {
930
+ "value": "exclude";
931
+ "label": "Exclude";
932
+ }];
933
+ };
934
+ };
935
+ };
936
+ }
937
+ type CreateCalendarEmitPayloadEntity = SchemaEntity<SpruceSchemas.Calendar.v2021_05_19.CreateCalendarEmitPayloadSchema>;
938
+ }
939
+ namespace SpruceSchemas.Calendar.v2021_05_19 {
940
+ interface CreateCalendarEmitTargetAndPayload {
941
+ /** Source. */
942
+ 'source'?: SpruceSchemas.SpruceEventUtils.v2021_09_13.EventSource | undefined | null;
943
+ 'target': SpruceSchemas.Calendar.v2021_05_19.CreateCalendarEmitTarget;
944
+ 'payload': SpruceSchemas.Calendar.v2021_05_19.CreateCalendarEmitPayload;
945
+ }
946
+ interface CreateCalendarEmitTargetAndPayloadSchema extends SpruceSchema.Schema {
947
+ id: 'createCalendarEmitTargetAndPayload';
948
+ version: 'v2021_05_19';
949
+ namespace: 'Calendar';
950
+ name: '';
951
+ fields: {
952
+ /** Source. */
953
+ 'source': {
954
+ label: 'Source';
955
+ type: 'schema';
956
+ options: {
957
+ schema: SpruceSchemas.SpruceEventUtils.v2021_09_13.EventSourceSchema;
958
+ };
959
+ };
960
+ /** . */
961
+ 'target': {
962
+ type: 'schema';
963
+ isRequired: true;
964
+ options: {
965
+ schema: SpruceSchemas.Calendar.v2021_05_19.CreateCalendarEmitTargetSchema;
966
+ };
967
+ };
968
+ /** . */
969
+ 'payload': {
970
+ type: 'schema';
971
+ isRequired: true;
972
+ options: {
973
+ schema: SpruceSchemas.Calendar.v2021_05_19.CreateCalendarEmitPayloadSchema;
974
+ };
975
+ };
976
+ };
977
+ }
978
+ type CreateCalendarEmitTargetAndPayloadEntity = SchemaEntity<SpruceSchemas.Calendar.v2021_05_19.CreateCalendarEmitTargetAndPayloadSchema>;
979
+ }
980
+ namespace SpruceSchemas.Calendar.v2021_05_19 {
981
+ interface CreateCalendarResponsePayload {
982
+ 'calendar': SpruceSchemas.Calendar.v2021_05_19.Calendar;
983
+ }
984
+ interface CreateCalendarResponsePayloadSchema extends SpruceSchema.Schema {
985
+ id: 'createCalendarResponsePayload';
986
+ version: 'v2021_05_19';
987
+ namespace: 'Calendar';
988
+ name: '';
989
+ fields: {
990
+ /** . */
991
+ 'calendar': {
992
+ type: 'schema';
993
+ isRequired: true;
994
+ options: {
995
+ schema: SpruceSchemas.Calendar.v2021_05_19.CalendarSchema;
996
+ };
997
+ };
998
+ };
999
+ }
1000
+ type CreateCalendarResponsePayloadEntity = SchemaEntity<SpruceSchemas.Calendar.v2021_05_19.CreateCalendarResponsePayloadSchema>;
1001
+ }
870
1002
  namespace SpruceSchemas.Calendar.v2021_05_19 {
871
1003
  interface CreateCalendarEventTypeEmitPayload {
872
1004
  'name': string;
@@ -1373,138 +1505,6 @@ declare module '@sprucelabs/spruce-core-schemas/build/.spruce/schemas/core.schem
1373
1505
  }
1374
1506
  type CreateCalendarEventTypeResponsePayloadEntity = SchemaEntity<SpruceSchemas.Calendar.v2021_05_19.CreateCalendarEventTypeResponsePayloadSchema>;
1375
1507
  }
1376
- namespace SpruceSchemas.Calendar.v2021_05_19 {
1377
- interface CreateCalendarEmitTarget {
1378
- 'organizationId': string;
1379
- }
1380
- interface CreateCalendarEmitTargetSchema extends SpruceSchema.Schema {
1381
- id: 'createCalendarEmitTarget';
1382
- version: 'v2021_05_19';
1383
- namespace: 'Calendar';
1384
- name: '';
1385
- fields: {
1386
- /** . */
1387
- 'organizationId': {
1388
- type: 'id';
1389
- isRequired: true;
1390
- options: undefined;
1391
- };
1392
- };
1393
- }
1394
- type CreateCalendarEmitTargetEntity = SchemaEntity<SpruceSchemas.Calendar.v2021_05_19.CreateCalendarEmitTargetSchema>;
1395
- }
1396
- namespace SpruceSchemas.Calendar.v2021_05_19 {
1397
- interface CreateCalendarEmitPayload {
1398
- 'slug': string;
1399
- 'title': string;
1400
- 'eventTypes'?: string[] | undefined | null;
1401
- 'availableTimeSlotBehavior'?: ("include" | "exclude") | undefined | null;
1402
- }
1403
- interface CreateCalendarEmitPayloadSchema extends SpruceSchema.Schema {
1404
- id: 'createCalendarEmitPayload';
1405
- version: 'v2021_05_19';
1406
- namespace: 'Calendar';
1407
- name: '';
1408
- fields: {
1409
- /** . */
1410
- 'slug': {
1411
- type: 'id';
1412
- isRequired: true;
1413
- options: undefined;
1414
- };
1415
- /** . */
1416
- 'title': {
1417
- type: 'text';
1418
- isRequired: true;
1419
- options: undefined;
1420
- };
1421
- /** . */
1422
- 'eventTypes': {
1423
- type: 'text';
1424
- isArray: true;
1425
- minArrayLength: 0;
1426
- options: undefined;
1427
- };
1428
- /** . */
1429
- 'availableTimeSlotBehavior': {
1430
- type: 'select';
1431
- options: {
1432
- choices: [{
1433
- "value": "include";
1434
- "label": "Include";
1435
- }, {
1436
- "value": "exclude";
1437
- "label": "Exclude";
1438
- }];
1439
- };
1440
- };
1441
- };
1442
- }
1443
- type CreateCalendarEmitPayloadEntity = SchemaEntity<SpruceSchemas.Calendar.v2021_05_19.CreateCalendarEmitPayloadSchema>;
1444
- }
1445
- namespace SpruceSchemas.Calendar.v2021_05_19 {
1446
- interface CreateCalendarEmitTargetAndPayload {
1447
- /** Source. */
1448
- 'source'?: SpruceSchemas.SpruceEventUtils.v2021_09_13.EventSource | undefined | null;
1449
- 'target': SpruceSchemas.Calendar.v2021_05_19.CreateCalendarEmitTarget;
1450
- 'payload': SpruceSchemas.Calendar.v2021_05_19.CreateCalendarEmitPayload;
1451
- }
1452
- interface CreateCalendarEmitTargetAndPayloadSchema extends SpruceSchema.Schema {
1453
- id: 'createCalendarEmitTargetAndPayload';
1454
- version: 'v2021_05_19';
1455
- namespace: 'Calendar';
1456
- name: '';
1457
- fields: {
1458
- /** Source. */
1459
- 'source': {
1460
- label: 'Source';
1461
- type: 'schema';
1462
- options: {
1463
- schema: SpruceSchemas.SpruceEventUtils.v2021_09_13.EventSourceSchema;
1464
- };
1465
- };
1466
- /** . */
1467
- 'target': {
1468
- type: 'schema';
1469
- isRequired: true;
1470
- options: {
1471
- schema: SpruceSchemas.Calendar.v2021_05_19.CreateCalendarEmitTargetSchema;
1472
- };
1473
- };
1474
- /** . */
1475
- 'payload': {
1476
- type: 'schema';
1477
- isRequired: true;
1478
- options: {
1479
- schema: SpruceSchemas.Calendar.v2021_05_19.CreateCalendarEmitPayloadSchema;
1480
- };
1481
- };
1482
- };
1483
- }
1484
- type CreateCalendarEmitTargetAndPayloadEntity = SchemaEntity<SpruceSchemas.Calendar.v2021_05_19.CreateCalendarEmitTargetAndPayloadSchema>;
1485
- }
1486
- namespace SpruceSchemas.Calendar.v2021_05_19 {
1487
- interface CreateCalendarResponsePayload {
1488
- 'calendar': SpruceSchemas.Calendar.v2021_05_19.Calendar;
1489
- }
1490
- interface CreateCalendarResponsePayloadSchema extends SpruceSchema.Schema {
1491
- id: 'createCalendarResponsePayload';
1492
- version: 'v2021_05_19';
1493
- namespace: 'Calendar';
1494
- name: '';
1495
- fields: {
1496
- /** . */
1497
- 'calendar': {
1498
- type: 'schema';
1499
- isRequired: true;
1500
- options: {
1501
- schema: SpruceSchemas.Calendar.v2021_05_19.CalendarSchema;
1502
- };
1503
- };
1504
- };
1505
- }
1506
- type CreateCalendarResponsePayloadEntity = SchemaEntity<SpruceSchemas.Calendar.v2021_05_19.CreateCalendarResponsePayloadSchema>;
1507
- }
1508
1508
  namespace SpruceSchemas.Calendar.v2021_05_19 {
1509
1509
  interface DeleteCalendarEmitTarget {
1510
1510
  'organizationId': string;
@@ -867,6 +867,138 @@ declare module '@sprucelabs/spruce-core-schemas/build/.spruce/schemas/core.schem
867
867
  }
868
868
  type CancelCalendarEventResponsePayloadEntity = SchemaEntity<SpruceSchemas.Calendar.v2021_05_19.CancelCalendarEventResponsePayloadSchema>;
869
869
  }
870
+ namespace SpruceSchemas.Calendar.v2021_05_19 {
871
+ interface CreateCalendarEmitTarget {
872
+ 'organizationId': string;
873
+ }
874
+ interface CreateCalendarEmitTargetSchema extends SpruceSchema.Schema {
875
+ id: 'createCalendarEmitTarget';
876
+ version: 'v2021_05_19';
877
+ namespace: 'Calendar';
878
+ name: '';
879
+ fields: {
880
+ /** . */
881
+ 'organizationId': {
882
+ type: 'id';
883
+ isRequired: true;
884
+ options: undefined;
885
+ };
886
+ };
887
+ }
888
+ type CreateCalendarEmitTargetEntity = SchemaEntity<SpruceSchemas.Calendar.v2021_05_19.CreateCalendarEmitTargetSchema>;
889
+ }
890
+ namespace SpruceSchemas.Calendar.v2021_05_19 {
891
+ interface CreateCalendarEmitPayload {
892
+ 'slug': string;
893
+ 'title': string;
894
+ 'eventTypes'?: string[] | undefined | null;
895
+ 'availableTimeSlotBehavior'?: ("include" | "exclude") | undefined | null;
896
+ }
897
+ interface CreateCalendarEmitPayloadSchema extends SpruceSchema.Schema {
898
+ id: 'createCalendarEmitPayload';
899
+ version: 'v2021_05_19';
900
+ namespace: 'Calendar';
901
+ name: '';
902
+ fields: {
903
+ /** . */
904
+ 'slug': {
905
+ type: 'id';
906
+ isRequired: true;
907
+ options: undefined;
908
+ };
909
+ /** . */
910
+ 'title': {
911
+ type: 'text';
912
+ isRequired: true;
913
+ options: undefined;
914
+ };
915
+ /** . */
916
+ 'eventTypes': {
917
+ type: 'text';
918
+ isArray: true;
919
+ minArrayLength: 0;
920
+ options: undefined;
921
+ };
922
+ /** . */
923
+ 'availableTimeSlotBehavior': {
924
+ type: 'select';
925
+ options: {
926
+ choices: [{
927
+ "value": "include";
928
+ "label": "Include";
929
+ }, {
930
+ "value": "exclude";
931
+ "label": "Exclude";
932
+ }];
933
+ };
934
+ };
935
+ };
936
+ }
937
+ type CreateCalendarEmitPayloadEntity = SchemaEntity<SpruceSchemas.Calendar.v2021_05_19.CreateCalendarEmitPayloadSchema>;
938
+ }
939
+ namespace SpruceSchemas.Calendar.v2021_05_19 {
940
+ interface CreateCalendarEmitTargetAndPayload {
941
+ /** Source. */
942
+ 'source'?: SpruceSchemas.SpruceEventUtils.v2021_09_13.EventSource | undefined | null;
943
+ 'target': SpruceSchemas.Calendar.v2021_05_19.CreateCalendarEmitTarget;
944
+ 'payload': SpruceSchemas.Calendar.v2021_05_19.CreateCalendarEmitPayload;
945
+ }
946
+ interface CreateCalendarEmitTargetAndPayloadSchema extends SpruceSchema.Schema {
947
+ id: 'createCalendarEmitTargetAndPayload';
948
+ version: 'v2021_05_19';
949
+ namespace: 'Calendar';
950
+ name: '';
951
+ fields: {
952
+ /** Source. */
953
+ 'source': {
954
+ label: 'Source';
955
+ type: 'schema';
956
+ options: {
957
+ schema: SpruceSchemas.SpruceEventUtils.v2021_09_13.EventSourceSchema;
958
+ };
959
+ };
960
+ /** . */
961
+ 'target': {
962
+ type: 'schema';
963
+ isRequired: true;
964
+ options: {
965
+ schema: SpruceSchemas.Calendar.v2021_05_19.CreateCalendarEmitTargetSchema;
966
+ };
967
+ };
968
+ /** . */
969
+ 'payload': {
970
+ type: 'schema';
971
+ isRequired: true;
972
+ options: {
973
+ schema: SpruceSchemas.Calendar.v2021_05_19.CreateCalendarEmitPayloadSchema;
974
+ };
975
+ };
976
+ };
977
+ }
978
+ type CreateCalendarEmitTargetAndPayloadEntity = SchemaEntity<SpruceSchemas.Calendar.v2021_05_19.CreateCalendarEmitTargetAndPayloadSchema>;
979
+ }
980
+ namespace SpruceSchemas.Calendar.v2021_05_19 {
981
+ interface CreateCalendarResponsePayload {
982
+ 'calendar': SpruceSchemas.Calendar.v2021_05_19.Calendar;
983
+ }
984
+ interface CreateCalendarResponsePayloadSchema extends SpruceSchema.Schema {
985
+ id: 'createCalendarResponsePayload';
986
+ version: 'v2021_05_19';
987
+ namespace: 'Calendar';
988
+ name: '';
989
+ fields: {
990
+ /** . */
991
+ 'calendar': {
992
+ type: 'schema';
993
+ isRequired: true;
994
+ options: {
995
+ schema: SpruceSchemas.Calendar.v2021_05_19.CalendarSchema;
996
+ };
997
+ };
998
+ };
999
+ }
1000
+ type CreateCalendarResponsePayloadEntity = SchemaEntity<SpruceSchemas.Calendar.v2021_05_19.CreateCalendarResponsePayloadSchema>;
1001
+ }
870
1002
  namespace SpruceSchemas.Calendar.v2021_05_19 {
871
1003
  interface CreateCalendarEventTypeEmitPayload {
872
1004
  'name': string;
@@ -1373,138 +1505,6 @@ declare module '@sprucelabs/spruce-core-schemas/build/.spruce/schemas/core.schem
1373
1505
  }
1374
1506
  type CreateCalendarEventTypeResponsePayloadEntity = SchemaEntity<SpruceSchemas.Calendar.v2021_05_19.CreateCalendarEventTypeResponsePayloadSchema>;
1375
1507
  }
1376
- namespace SpruceSchemas.Calendar.v2021_05_19 {
1377
- interface CreateCalendarEmitTarget {
1378
- 'organizationId': string;
1379
- }
1380
- interface CreateCalendarEmitTargetSchema extends SpruceSchema.Schema {
1381
- id: 'createCalendarEmitTarget';
1382
- version: 'v2021_05_19';
1383
- namespace: 'Calendar';
1384
- name: '';
1385
- fields: {
1386
- /** . */
1387
- 'organizationId': {
1388
- type: 'id';
1389
- isRequired: true;
1390
- options: undefined;
1391
- };
1392
- };
1393
- }
1394
- type CreateCalendarEmitTargetEntity = SchemaEntity<SpruceSchemas.Calendar.v2021_05_19.CreateCalendarEmitTargetSchema>;
1395
- }
1396
- namespace SpruceSchemas.Calendar.v2021_05_19 {
1397
- interface CreateCalendarEmitPayload {
1398
- 'slug': string;
1399
- 'title': string;
1400
- 'eventTypes'?: string[] | undefined | null;
1401
- 'availableTimeSlotBehavior'?: ("include" | "exclude") | undefined | null;
1402
- }
1403
- interface CreateCalendarEmitPayloadSchema extends SpruceSchema.Schema {
1404
- id: 'createCalendarEmitPayload';
1405
- version: 'v2021_05_19';
1406
- namespace: 'Calendar';
1407
- name: '';
1408
- fields: {
1409
- /** . */
1410
- 'slug': {
1411
- type: 'id';
1412
- isRequired: true;
1413
- options: undefined;
1414
- };
1415
- /** . */
1416
- 'title': {
1417
- type: 'text';
1418
- isRequired: true;
1419
- options: undefined;
1420
- };
1421
- /** . */
1422
- 'eventTypes': {
1423
- type: 'text';
1424
- isArray: true;
1425
- minArrayLength: 0;
1426
- options: undefined;
1427
- };
1428
- /** . */
1429
- 'availableTimeSlotBehavior': {
1430
- type: 'select';
1431
- options: {
1432
- choices: [{
1433
- "value": "include";
1434
- "label": "Include";
1435
- }, {
1436
- "value": "exclude";
1437
- "label": "Exclude";
1438
- }];
1439
- };
1440
- };
1441
- };
1442
- }
1443
- type CreateCalendarEmitPayloadEntity = SchemaEntity<SpruceSchemas.Calendar.v2021_05_19.CreateCalendarEmitPayloadSchema>;
1444
- }
1445
- namespace SpruceSchemas.Calendar.v2021_05_19 {
1446
- interface CreateCalendarEmitTargetAndPayload {
1447
- /** Source. */
1448
- 'source'?: SpruceSchemas.SpruceEventUtils.v2021_09_13.EventSource | undefined | null;
1449
- 'target': SpruceSchemas.Calendar.v2021_05_19.CreateCalendarEmitTarget;
1450
- 'payload': SpruceSchemas.Calendar.v2021_05_19.CreateCalendarEmitPayload;
1451
- }
1452
- interface CreateCalendarEmitTargetAndPayloadSchema extends SpruceSchema.Schema {
1453
- id: 'createCalendarEmitTargetAndPayload';
1454
- version: 'v2021_05_19';
1455
- namespace: 'Calendar';
1456
- name: '';
1457
- fields: {
1458
- /** Source. */
1459
- 'source': {
1460
- label: 'Source';
1461
- type: 'schema';
1462
- options: {
1463
- schema: SpruceSchemas.SpruceEventUtils.v2021_09_13.EventSourceSchema;
1464
- };
1465
- };
1466
- /** . */
1467
- 'target': {
1468
- type: 'schema';
1469
- isRequired: true;
1470
- options: {
1471
- schema: SpruceSchemas.Calendar.v2021_05_19.CreateCalendarEmitTargetSchema;
1472
- };
1473
- };
1474
- /** . */
1475
- 'payload': {
1476
- type: 'schema';
1477
- isRequired: true;
1478
- options: {
1479
- schema: SpruceSchemas.Calendar.v2021_05_19.CreateCalendarEmitPayloadSchema;
1480
- };
1481
- };
1482
- };
1483
- }
1484
- type CreateCalendarEmitTargetAndPayloadEntity = SchemaEntity<SpruceSchemas.Calendar.v2021_05_19.CreateCalendarEmitTargetAndPayloadSchema>;
1485
- }
1486
- namespace SpruceSchemas.Calendar.v2021_05_19 {
1487
- interface CreateCalendarResponsePayload {
1488
- 'calendar': SpruceSchemas.Calendar.v2021_05_19.Calendar;
1489
- }
1490
- interface CreateCalendarResponsePayloadSchema extends SpruceSchema.Schema {
1491
- id: 'createCalendarResponsePayload';
1492
- version: 'v2021_05_19';
1493
- namespace: 'Calendar';
1494
- name: '';
1495
- fields: {
1496
- /** . */
1497
- 'calendar': {
1498
- type: 'schema';
1499
- isRequired: true;
1500
- options: {
1501
- schema: SpruceSchemas.Calendar.v2021_05_19.CalendarSchema;
1502
- };
1503
- };
1504
- };
1505
- }
1506
- type CreateCalendarResponsePayloadEntity = SchemaEntity<SpruceSchemas.Calendar.v2021_05_19.CreateCalendarResponsePayloadSchema>;
1507
- }
1508
1508
  namespace SpruceSchemas.Calendar.v2021_05_19 {
1509
1509
  interface DeleteCalendarEmitTarget {
1510
1510
  'organizationId': string;
@@ -1,25 +1,23 @@
1
1
  import { SpruceSchemas } from '@sprucelabs/heartwood-view-controllers';
2
2
  import { MercuryClient } from '@sprucelabs/mercury-client';
3
3
  import { UpdateEvent } from '../types/calendar.types';
4
- export interface RemoteEventStoreOptions {
5
- client: MercuryClient;
6
- calendarId?: string;
7
- locationId: string;
8
- organizationId: string;
9
- }
10
- declare type FullEvent = SpruceSchemas.CalendarUtils.v2021_05_19.CalendarEvent;
11
4
  export default class RemoteEventStore {
12
- private client;
13
- private calendarId?;
14
- private locationId;
15
- private pendingEvent?;
5
+ private connectToApi;
6
+ protected calendarId?: string;
7
+ protected locationId: string;
8
+ protected organizationId: string;
9
+ protected client: MercuryClient;
10
+ private pendingEvents;
16
11
  private draftIdMap;
17
12
  private promises;
18
13
  private queueByEventId;
19
14
  private busyByEvent;
20
15
  private lastSavedById;
21
- private organizationId;
22
16
  constructor(options: RemoteEventStoreOptions);
17
+ load(options: {
18
+ organizationId: string;
19
+ locationId: string;
20
+ }): Promise<void>;
23
21
  persist(event: UpdateEvent): Promise<FullEvent>;
24
22
  private startQueueForEvent;
25
23
  private getId;
@@ -44,4 +42,9 @@ export default class RemoteEventStore {
44
42
  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
43
  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>>[]>;
46
44
  }
45
+ export interface RemoteEventStoreOptions {
46
+ connectToApi: () => Promise<MercuryClient>;
47
+ calendarId?: string;
48
+ }
49
+ declare type FullEvent = SpruceSchemas.CalendarUtils.v2021_05_19.CalendarEvent;
47
50
  export {};
@@ -23,21 +23,33 @@ import { assertOptions, normalizeSchemaValues } from '@sprucelabs/schema';
23
23
  import draftEventGenerator from '../utilities/draftGenerator.js';
24
24
  export default class RemoteEventStore {
25
25
  constructor(options) {
26
+ this.pendingEvents = {};
26
27
  this.draftIdMap = {};
27
28
  this.promises = [];
28
29
  this.queueByEventId = {};
29
30
  this.busyByEvent = {};
30
31
  this.lastSavedById = {};
31
- const { client, calendarId, locationId, organizationId } = assertOptions(options, ['client', 'locationId', 'organizationId']);
32
- this.client = client;
32
+ const { connectToApi, calendarId } = assertOptions(options, [
33
+ 'connectToApi',
34
+ ]);
35
+ this.connectToApi = connectToApi;
33
36
  this.calendarId = calendarId;
34
- this.locationId = locationId;
35
- this.organizationId = organizationId;
37
+ }
38
+ load(options) {
39
+ return __awaiter(this, void 0, void 0, function* () {
40
+ const { organizationId, locationId } = assertOptions(options, [
41
+ 'locationId',
42
+ 'organizationId',
43
+ ]);
44
+ this.locationId = locationId;
45
+ this.organizationId = organizationId;
46
+ this.client = yield this.connectToApi();
47
+ });
36
48
  }
37
49
  persist(event) {
38
50
  return __awaiter(this, void 0, void 0, function* () {
39
51
  if (!this.resolveCalendarId(event)) {
40
- this.pendingEvent = event;
52
+ this.pendingEvents[event.id] = event;
41
53
  return event;
42
54
  }
43
55
  if (!this.queueByEventId[this.getId(event.id)]) {
@@ -106,7 +118,8 @@ export default class RemoteEventStore {
106
118
  updateEvent(event) {
107
119
  return __awaiter(this, void 0, void 0, function* () {
108
120
  const { target, payload } = this.splitPayloadAndTarget(event);
109
- const results = yield this.client.emitAndFlattenResponses('calendar.update-calendar-event::v2021_05_19', {
121
+ const client = yield this.connectToApi();
122
+ const results = yield client.emitAndFlattenResponses('calendar.update-calendar-event::v2021_05_19', {
110
123
  target: Object.assign({ calendarEventId: event.id }, target),
111
124
  payload: Object.assign({}, payload),
112
125
  });
@@ -199,10 +212,9 @@ export default class RemoteEventStore {
199
212
  });
200
213
  }
201
214
  cancelEvent(id) {
202
- var _a;
203
215
  return __awaiter(this, void 0, void 0, function* () {
204
- if (((_a = this.pendingEvent) === null || _a === void 0 ? void 0 : _a.id) === id) {
205
- delete this.pendingEvent;
216
+ if (this.pendingEvents[id]) {
217
+ delete this.pendingEvents[id];
206
218
  }
207
219
  else {
208
220
  yield this.client.emitAndFlattenResponses('calendar.cancel-calendar-event::v2021_05_19', {
@@ -69,7 +69,7 @@ export default class CalendarViewController extends CoreCalendarViewController {
69
69
  }>;
70
70
  getIsSwappingEvent(): boolean;
71
71
  private swapEvent;
72
- updateEvent(id: string, updates: Partial<UpdateEvent>): SpruceSchemas.HeartwoodViewControllers.v2021_02_11.CalendarEvent;
72
+ updateEvent(id: string, updates: Partial<UpdateEvent>): any;
73
73
  private persist;
74
74
  getPeople(): SpruceSchemas.HeartwoodViewControllers.v2021_02_11.CalendarPerson[];
75
75
  render(): {
@@ -171,9 +171,14 @@ export default class CalendarViewController extends CoreCalendarViewController {
171
171
  });
172
172
  }
173
173
  updateEvent(id, updates) {
174
- const updated = super.updateEvent(id, Object.assign(Object.assign({}, updates), { isBusy: true }));
175
- void this.persist(updated);
176
- return updated;
174
+ try {
175
+ const updated = super.updateEvent(id, Object.assign(Object.assign({}, updates), { isBusy: true }));
176
+ void this.persist(updated);
177
+ return updated;
178
+ // eslint-disable-next-line no-empty
179
+ }
180
+ catch (_a) { }
181
+ return Object.assign({}, updates);
177
182
  }
178
183
  persist(event, options) {
179
184
  const _super = Object.create(null, {
@@ -1,25 +1,23 @@
1
1
  import { SpruceSchemas } from '@sprucelabs/heartwood-view-controllers';
2
2
  import { MercuryClient } from '@sprucelabs/mercury-client';
3
3
  import { UpdateEvent } from '../types/calendar.types';
4
- export interface RemoteEventStoreOptions {
5
- client: MercuryClient;
6
- calendarId?: string;
7
- locationId: string;
8
- organizationId: string;
9
- }
10
- declare type FullEvent = SpruceSchemas.CalendarUtils.v2021_05_19.CalendarEvent;
11
4
  export default class RemoteEventStore {
12
- private client;
13
- private calendarId?;
14
- private locationId;
15
- private pendingEvent?;
5
+ private connectToApi;
6
+ protected calendarId?: string;
7
+ protected locationId: string;
8
+ protected organizationId: string;
9
+ protected client: MercuryClient;
10
+ private pendingEvents;
16
11
  private draftIdMap;
17
12
  private promises;
18
13
  private queueByEventId;
19
14
  private busyByEvent;
20
15
  private lastSavedById;
21
- private organizationId;
22
16
  constructor(options: RemoteEventStoreOptions);
17
+ load(options: {
18
+ organizationId: string;
19
+ locationId: string;
20
+ }): Promise<void>;
23
21
  persist(event: UpdateEvent): Promise<FullEvent>;
24
22
  private startQueueForEvent;
25
23
  private getId;
@@ -44,4 +42,9 @@ export default class RemoteEventStore {
44
42
  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
43
  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>>[]>;
46
44
  }
45
+ export interface RemoteEventStoreOptions {
46
+ connectToApi: () => Promise<MercuryClient>;
47
+ calendarId?: string;
48
+ }
49
+ declare type FullEvent = SpruceSchemas.CalendarUtils.v2021_05_19.CalendarEvent;
47
50
  export {};
@@ -19,20 +19,30 @@ const schema_1 = require("@sprucelabs/schema");
19
19
  const draftGenerator_1 = __importDefault(require("../utilities/draftGenerator"));
20
20
  class RemoteEventStore {
21
21
  constructor(options) {
22
+ this.pendingEvents = {};
22
23
  this.draftIdMap = {};
23
24
  this.promises = [];
24
25
  this.queueByEventId = {};
25
26
  this.busyByEvent = {};
26
27
  this.lastSavedById = {};
27
- const { client, calendarId, locationId, organizationId } = (0, schema_1.assertOptions)(options, ['client', 'locationId', 'organizationId']);
28
- this.client = client;
28
+ const { connectToApi, calendarId } = (0, schema_1.assertOptions)(options, [
29
+ 'connectToApi',
30
+ ]);
31
+ this.connectToApi = connectToApi;
29
32
  this.calendarId = calendarId;
33
+ }
34
+ async load(options) {
35
+ const { organizationId, locationId } = (0, schema_1.assertOptions)(options, [
36
+ 'locationId',
37
+ 'organizationId',
38
+ ]);
30
39
  this.locationId = locationId;
31
40
  this.organizationId = organizationId;
41
+ this.client = await this.connectToApi();
32
42
  }
33
43
  async persist(event) {
34
44
  if (!this.resolveCalendarId(event)) {
35
- this.pendingEvent = event;
45
+ this.pendingEvents[event.id] = event;
36
46
  return event;
37
47
  }
38
48
  if (!this.queueByEventId[this.getId(event.id)]) {
@@ -97,7 +107,8 @@ class RemoteEventStore {
97
107
  }
98
108
  async updateEvent(event) {
99
109
  const { target, payload } = this.splitPayloadAndTarget(event);
100
- const results = await this.client.emitAndFlattenResponses('calendar.update-calendar-event::v2021_05_19', {
110
+ const client = await this.connectToApi();
111
+ const results = await client.emitAndFlattenResponses('calendar.update-calendar-event::v2021_05_19', {
101
112
  target: Object.assign({ calendarEventId: event.id }, target),
102
113
  payload: Object.assign({}, payload),
103
114
  });
@@ -183,9 +194,8 @@ class RemoteEventStore {
183
194
  await Promise.all(this.promises);
184
195
  }
185
196
  async cancelEvent(id) {
186
- var _a;
187
- if (((_a = this.pendingEvent) === null || _a === void 0 ? void 0 : _a.id) === id) {
188
- delete this.pendingEvent;
197
+ if (this.pendingEvents[id]) {
198
+ delete this.pendingEvents[id];
189
199
  }
190
200
  else {
191
201
  await this.client.emitAndFlattenResponses('calendar.cancel-calendar-event::v2021_05_19', {
@@ -69,7 +69,7 @@ export default class CalendarViewController extends CoreCalendarViewController {
69
69
  }>;
70
70
  getIsSwappingEvent(): boolean;
71
71
  private swapEvent;
72
- updateEvent(id: string, updates: Partial<UpdateEvent>): SpruceSchemas.HeartwoodViewControllers.v2021_02_11.CalendarEvent;
72
+ updateEvent(id: string, updates: Partial<UpdateEvent>): any;
73
73
  private persist;
74
74
  getPeople(): SpruceSchemas.HeartwoodViewControllers.v2021_02_11.CalendarPerson[];
75
75
  render(): {
@@ -152,9 +152,14 @@ class CalendarViewController extends heartwood_view_controllers_1.CalendarViewCo
152
152
  this.enableAnimation();
153
153
  }
154
154
  updateEvent(id, updates) {
155
- const updated = super.updateEvent(id, Object.assign(Object.assign({}, updates), { isBusy: true }));
156
- void this.persist(updated);
157
- return updated;
155
+ try {
156
+ const updated = super.updateEvent(id, Object.assign(Object.assign({}, updates), { isBusy: true }));
157
+ void this.persist(updated);
158
+ return updated;
159
+ // eslint-disable-next-line no-empty
160
+ }
161
+ catch (_a) { }
162
+ return Object.assign({}, updates);
158
163
  }
159
164
  async persist(event, options) {
160
165
  var _a, _b;
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.36",
4
+ "version": "20.9.39",
5
5
  "skill": {
6
6
  "namespace": "calendar"
7
7
  },