@amityco/ts-sdk 7.11.1-ed060e83.0 → 7.11.1-f0f4372a.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 (60) hide show
  1. package/dist/@types/core/events.d.ts +4 -0
  2. package/dist/@types/core/events.d.ts.map +1 -1
  3. package/dist/@types/core/model.d.ts +2 -0
  4. package/dist/@types/core/model.d.ts.map +1 -1
  5. package/dist/@types/domains/community.d.ts +3 -0
  6. package/dist/@types/domains/community.d.ts.map +1 -1
  7. package/dist/@types/domains/event.d.ts +16 -8
  8. package/dist/@types/domains/event.d.ts.map +1 -1
  9. package/dist/@types/domains/notification.d.ts +3 -1
  10. package/dist/@types/domains/notification.d.ts.map +1 -1
  11. package/dist/core/events.d.ts +3 -3
  12. package/dist/core/events.d.ts.map +1 -1
  13. package/dist/core/model/idResolvers.d.ts.map +1 -1
  14. package/dist/eventRepository/events/enums.d.ts +3 -1
  15. package/dist/eventRepository/events/enums.d.ts.map +1 -1
  16. package/dist/eventRepository/events/index.d.ts +7 -0
  17. package/dist/eventRepository/events/index.d.ts.map +1 -1
  18. package/dist/eventRepository/events/onLocalEventCreated.d.ts +17 -0
  19. package/dist/eventRepository/events/onLocalEventCreated.d.ts.map +1 -0
  20. package/dist/eventRepository/events/onLocalEventDeleted.d.ts +17 -0
  21. package/dist/eventRepository/events/onLocalEventDeleted.d.ts.map +1 -0
  22. package/dist/eventRepository/events/onLocalEventUpdated.d.ts +17 -0
  23. package/dist/eventRepository/events/onLocalEventUpdated.d.ts.map +1 -0
  24. package/dist/eventRepository/events/onLocalRSVPCreated.d.ts +17 -0
  25. package/dist/eventRepository/events/onLocalRSVPCreated.d.ts.map +1 -0
  26. package/dist/eventRepository/events/onLocalRSVPUpdated.d.ts +17 -0
  27. package/dist/eventRepository/events/onLocalRSVPUpdated.d.ts.map +1 -0
  28. package/dist/eventRepository/events/onRSVPCreated.d.ts +17 -0
  29. package/dist/eventRepository/events/onRSVPCreated.d.ts.map +1 -0
  30. package/dist/eventRepository/events/onRSVPUpdated.d.ts +17 -0
  31. package/dist/eventRepository/events/onRSVPUpdated.d.ts.map +1 -0
  32. package/dist/eventRepository/internalApi/createRSVP.d.ts +16 -0
  33. package/dist/eventRepository/internalApi/createRSVP.d.ts.map +1 -0
  34. package/dist/eventRepository/internalApi/getMyRSVP.d.ts +32 -0
  35. package/dist/eventRepository/internalApi/getMyRSVP.d.ts.map +1 -0
  36. package/dist/eventRepository/internalApi/index.d.ts +3 -0
  37. package/dist/eventRepository/internalApi/index.d.ts.map +1 -1
  38. package/dist/eventRepository/internalApi/updateRSVP.d.ts +17 -0
  39. package/dist/eventRepository/internalApi/updateRSVP.d.ts.map +1 -0
  40. package/dist/eventRepository/observers/getEvent.d.ts.map +1 -1
  41. package/dist/eventRepository/observers/getEvents/LiveCollectionController.d.ts.map +1 -1
  42. package/dist/eventRepository/observers/getMyEvents/LiveCollectionController.d.ts.map +1 -1
  43. package/dist/eventRepository/observers/getMyEvents/QueryStreamController.d.ts.map +1 -1
  44. package/dist/eventRepository/observers/getRSVPs/LiveCollectionController.d.ts +13 -0
  45. package/dist/eventRepository/observers/getRSVPs/LiveCollectionController.d.ts.map +1 -0
  46. package/dist/eventRepository/observers/getRSVPs/PaginationController.d.ts +5 -0
  47. package/dist/eventRepository/observers/getRSVPs/PaginationController.d.ts.map +1 -0
  48. package/dist/eventRepository/observers/getRSVPs/QueryStreamController.d.ts +15 -0
  49. package/dist/eventRepository/observers/getRSVPs/QueryStreamController.d.ts.map +1 -0
  50. package/dist/eventRepository/observers/getRSVPs.d.ts +12 -0
  51. package/dist/eventRepository/observers/getRSVPs.d.ts.map +1 -0
  52. package/dist/eventRepository/observers/index.d.ts +1 -0
  53. package/dist/eventRepository/observers/index.d.ts.map +1 -1
  54. package/dist/eventRepository/utils/createEventEventSubscriber.d.ts +1 -1
  55. package/dist/eventRepository/utils/createEventEventSubscriber.d.ts.map +1 -1
  56. package/dist/index.cjs.js +462 -36
  57. package/dist/index.esm.js +462 -36
  58. package/dist/index.umd.js +3 -3
  59. package/dist/utils/linkedObject/eventLinkObject.d.ts.map +1 -1
  60. package/package.json +1 -1
package/dist/index.esm.js CHANGED
@@ -197,7 +197,6 @@ var AmityEventStatus;
197
197
  var AmityEventResponseStatus;
198
198
  (function (AmityEventResponseStatus) {
199
199
  AmityEventResponseStatus["Going"] = "going";
200
- AmityEventResponseStatus["Interested"] = "interested";
201
200
  AmityEventResponseStatus["NotGoing"] = "not_going";
202
201
  })(AmityEventResponseStatus || (AmityEventResponseStatus = {}));
203
202
 
@@ -650,6 +649,7 @@ const idResolvers = {
650
649
  invitation: ({ _id }) => _id,
651
650
  joinRequest: ({ joinRequestId }) => joinRequestId,
652
651
  event: ({ eventId }) => eventId,
652
+ discussionCommunity: ({ communityId }) => communityId,
653
653
  };
654
654
  /**
655
655
  * Retrieve the id resolver matching a domain name
@@ -706,7 +706,7 @@ const PAYLOAD2MODEL = {
706
706
  invitations: 'invitation',
707
707
  joinRequests: 'joinRequest',
708
708
  events: 'event',
709
- discussionCommunities: 'community',
709
+ discussionCommunities: 'discussionCommunity',
710
710
  };
711
711
  /** hidden */
712
712
  const isOutdated = (prevData, nextData) => {
@@ -29777,6 +29777,155 @@ const communityLinkedObject = (community) => {
29777
29777
  } });
29778
29778
  };
29779
29779
 
29780
+ const prepareEventPayload = (rawPayload) => {
29781
+ return Object.assign(Object.assign({}, rawPayload), { users: rawPayload.users.map(convertRawUserToInternalUser) });
29782
+ };
29783
+
29784
+ const createEventEventSubscriber = (event, callback) => {
29785
+ const client = getActiveClient();
29786
+ const filter = (payload) => {
29787
+ const unpackedPayload = prepareEventPayload(payload);
29788
+ if (!client.cache) {
29789
+ callback(unpackedPayload.events[0]);
29790
+ }
29791
+ else {
29792
+ ingestInCache(unpackedPayload);
29793
+ const event = pullFromCache([
29794
+ 'event',
29795
+ 'get',
29796
+ unpackedPayload.events[0].eventId,
29797
+ ]);
29798
+ callback(event.data);
29799
+ }
29800
+ };
29801
+ return createEventSubscriber(client, event, event, filter);
29802
+ };
29803
+
29804
+ /* begin_public_function
29805
+ id: event.rsvp.create
29806
+ */
29807
+ /**
29808
+ * ```js
29809
+ * import { event } from '@amityco/ts-sdk'
29810
+ * const response = await event.createRSVP(eventId, status)
29811
+ * ```
29812
+ *
29813
+ * Creates an {@link Amity.InternalEvent}
29814
+ *
29815
+ * @param bundle The data necessary to create a new {@link Amity.InternalEvent}
29816
+ * @returns The newly created {@link Amity.InternalEvent}
29817
+ *
29818
+ * @category Event API
29819
+ * @async
29820
+ */
29821
+ const createRSVP = async (eventId, status) => {
29822
+ const client = getActiveClient();
29823
+ client.log('event/createRSVP', eventId, status);
29824
+ const { data: payload } = await client.http.post(`/api/v1/events/${eventId}/rsvp`, { status });
29825
+ fireEvent('local.rsvp.created', payload);
29826
+ const preparedPayload = prepareEventPayload(payload);
29827
+ const cachedAt = client.cache && Date.now();
29828
+ if (client.cache)
29829
+ ingestInCache(preparedPayload, { cachedAt });
29830
+ return {
29831
+ data: preparedPayload.events[0],
29832
+ cachedAt,
29833
+ };
29834
+ };
29835
+ /* end_public_function */
29836
+
29837
+ /* begin_public_function
29838
+ id: event.update
29839
+ */
29840
+ /**
29841
+ * ```js
29842
+ * import { event } from '@amityco/ts-sdk'
29843
+ * const response = await event.updateRSVP(eventId, status)
29844
+ * ```
29845
+ *
29846
+ * Updates an {@link Amity.InternalEvent}
29847
+ *
29848
+ * @param eventId The ID of the {@link Amity.InternalEvent} to edit
29849
+ * @param bundle The data necessary to update an existing {@link Amity.InternalEvent}
29850
+ * @returns the updated {@link Amity.InternalEvent}
29851
+ *
29852
+ * @category Event API
29853
+ * @async
29854
+ */
29855
+ const updateRSVP = async (eventId, status) => {
29856
+ const client = getActiveClient();
29857
+ client.log('event/updateRSVP', eventId, status);
29858
+ const { data: payload } = await client.http.put(`/api/v1/events/${eventId}/rsvp`, { status });
29859
+ fireEvent('local.rsvp.updated', payload);
29860
+ const preparedPayload = prepareEventPayload(payload);
29861
+ const cachedAt = client.cache && Date.now();
29862
+ if (client.cache)
29863
+ ingestInCache(preparedPayload, { cachedAt });
29864
+ return {
29865
+ data: preparedPayload.events.find(event => event.eventId === eventId),
29866
+ cachedAt,
29867
+ };
29868
+ };
29869
+ /* end_public_function */
29870
+
29871
+ /* begin_public_function
29872
+ id: event.rsvp.me
29873
+ */
29874
+ /**
29875
+ * ```js
29876
+ * import { event } from '@amityco/ts-sdk'
29877
+ * const myRSVP = await event.getMyRSVP(eventId)
29878
+ * ```
29879
+ *
29880
+ * Joins a {@link Amity.InternalEvent} object
29881
+ *
29882
+ * @param eventId the {@link Amity.InternalEvent} to get RSVP for
29883
+ * @returns A success boolean if the {@link Amity.InternalEvent} RSVP was retrieved
29884
+ *
29885
+ * @category Event API
29886
+ * @async
29887
+ */
29888
+ const getMyRSVP = async (eventId) => {
29889
+ const client = getActiveClient();
29890
+ client.log('event/getMyRSVP', eventId);
29891
+ const { data: payload } = await client.http.get(`/api/v1/events/${eventId}/me/rsvp`);
29892
+ const data = prepareEventPayload(payload);
29893
+ const cachedAt = client.cache && Date.now();
29894
+ if (client.cache)
29895
+ ingestInCache(data, { cachedAt });
29896
+ return {
29897
+ data: data.events.find(event => event.eventId === eventId),
29898
+ cachedAt,
29899
+ };
29900
+ };
29901
+ /* end_public_function */
29902
+ /**
29903
+ * ```js
29904
+ * import { event } from '@amityco/ts-sdk'
29905
+ * const event = event.getMyRSVP.locally(eventId)
29906
+ * ```
29907
+ *
29908
+ * Fetches a {@link Amity.InternalEvent} object in cache
29909
+ *
29910
+ * @param eventId the ID of the {@link Amity.InternalEvent} to fetch
29911
+ * @returns the associated {@link Amity.InternalEvent} object
29912
+ *
29913
+ * @category Event API
29914
+ */
29915
+ getMyRSVP.locally = (eventId) => {
29916
+ const client = getActiveClient();
29917
+ client.log('event/getMyRSVP.locally', eventId);
29918
+ if (!client.cache)
29919
+ return;
29920
+ const cache = pullFromCache(['event', 'getMyRSVP', eventId]);
29921
+ if (!cache)
29922
+ return;
29923
+ return {
29924
+ data: cache.data,
29925
+ cachedAt: cache.cachedAt,
29926
+ };
29927
+ };
29928
+
29780
29929
  const eventLinkedObject = (event) => {
29781
29930
  return Object.assign(Object.assign({}, event), { get creator() {
29782
29931
  const cacheData = pullFromCache(['user', 'get', event.userId]);
@@ -29788,7 +29937,7 @@ const eventLinkedObject = (event) => {
29788
29937
  if (!event.discussionCommunityId)
29789
29938
  return;
29790
29939
  const cacheData = pullFromCache([
29791
- 'community',
29940
+ 'discussionCommunity',
29792
29941
  'get',
29793
29942
  event.discussionCommunityId,
29794
29943
  ]);
@@ -29796,6 +29945,22 @@ const eventLinkedObject = (event) => {
29796
29945
  return;
29797
29946
  return communityLinkedObject(cacheData.data);
29798
29947
  },
29948
+ get targetCommunity() {
29949
+ if (!event.originId)
29950
+ return;
29951
+ const cacheData = pullFromCache(['community', 'get', event.originId]);
29952
+ if (!(cacheData === null || cacheData === void 0 ? void 0 : cacheData.data))
29953
+ return;
29954
+ return communityLinkedObject(cacheData.data);
29955
+ },
29956
+ get coverImage() {
29957
+ if (!event.coverImageFileId)
29958
+ return;
29959
+ const cacheData = pullFromCache(['file', 'get', event.coverImageFileId]);
29960
+ if (!(cacheData === null || cacheData === void 0 ? void 0 : cacheData.data))
29961
+ return;
29962
+ return cacheData.data;
29963
+ },
29799
29964
  get liveStream() {
29800
29965
  if (!event.livestreamId)
29801
29966
  return;
@@ -29803,6 +29968,15 @@ const eventLinkedObject = (event) => {
29803
29968
  if (!(cacheData === null || cacheData === void 0 ? void 0 : cacheData.data))
29804
29969
  return;
29805
29970
  return cacheData.data;
29971
+ }, createRSVP: async (status) => {
29972
+ const { data } = await createRSVP(event.eventId, status);
29973
+ return data;
29974
+ }, updateRSVP: async (status) => {
29975
+ const { data } = await updateRSVP(event.eventId, status);
29976
+ return data;
29977
+ }, getMyRSVP: async () => {
29978
+ const { data } = await getMyRSVP(event.eventId);
29979
+ return data;
29806
29980
  } });
29807
29981
  };
29808
29982
 
@@ -46442,30 +46616,6 @@ var index$1 = /*#__PURE__*/Object.freeze({
46442
46616
  getReactions: getReactions
46443
46617
  });
46444
46618
 
46445
- const prepareEventPayload = (rawPayload) => {
46446
- return Object.assign(Object.assign({}, rawPayload), { users: rawPayload.users.map(convertRawUserToInternalUser) });
46447
- };
46448
-
46449
- const createEventEventSubscriber = (event, callback) => {
46450
- const client = getActiveClient();
46451
- const filter = (payload) => {
46452
- const unpackedPayload = prepareEventPayload(payload);
46453
- if (!client.cache) {
46454
- callback(unpackedPayload.events[0]);
46455
- }
46456
- else {
46457
- ingestInCache(unpackedPayload);
46458
- const event = pullFromCache([
46459
- 'event',
46460
- 'get',
46461
- unpackedPayload.events[0].eventId,
46462
- ]);
46463
- callback(event.data);
46464
- }
46465
- };
46466
- return createEventSubscriber(client, event, event, filter);
46467
- };
46468
-
46469
46619
  /* begin_public_function
46470
46620
  id: event.create
46471
46621
  */
@@ -46487,7 +46637,7 @@ const createEvent = async (bundle) => {
46487
46637
  const client = getActiveClient();
46488
46638
  client.log('event/createEvent', bundle);
46489
46639
  const { data: payload } = await client.http.post('/api/v1/events', bundle);
46490
- fireEvent('event.created', payload);
46640
+ fireEvent('local.event.created', payload);
46491
46641
  const preparedPayload = prepareEventPayload(payload);
46492
46642
  const cachedAt = client.cache && Date.now();
46493
46643
  if (client.cache)
@@ -46521,7 +46671,7 @@ const updateEvent = async (eventId, bundle) => {
46521
46671
  const client = getActiveClient();
46522
46672
  client.log('event/updateEvent', eventId, bundle);
46523
46673
  const { data: payload } = await client.http.put(`/api/v1/events/${eventId}`, bundle);
46524
- fireEvent('event.updated', payload);
46674
+ fireEvent('local.event.updated', payload);
46525
46675
  const preparedPayload = prepareEventPayload(payload);
46526
46676
  const cachedAt = client.cache && Date.now();
46527
46677
  if (client.cache)
@@ -46553,7 +46703,7 @@ const updateEvent = async (eventId, bundle) => {
46553
46703
  const getEvent$1 = async (eventId) => {
46554
46704
  const client = getActiveClient();
46555
46705
  client.log('event/getEvent', eventId);
46556
- const { data: payload } = await client.http.get(`/api/v3/events/${eventId}`);
46706
+ const { data: payload } = await client.http.get(`/api/v1/events/${eventId}`);
46557
46707
  const data = prepareEventPayload(payload);
46558
46708
  const cachedAt = client.cache && Date.now();
46559
46709
  if (client.cache)
@@ -46611,10 +46761,10 @@ const deleteEvent = async (eventId) => {
46611
46761
  const client = getActiveClient();
46612
46762
  client.log('event/deleteEvent', eventId);
46613
46763
  const event = await getEvent$1(eventId);
46614
- await client.http.delete(`/api/v3/events/${eventId}`);
46764
+ await client.http.delete(`/api/v1/events/${eventId}`);
46615
46765
  const deletedEvent = Object.assign(Object.assign({}, event.data), { isDeleted: true });
46616
46766
  upsertInCache(['event', 'get', eventId], deletedEvent);
46617
- fireEvent('event.deleted', {
46767
+ fireEvent('local.event.deleted', {
46618
46768
  users: [],
46619
46769
  files: [],
46620
46770
  communities: [],
@@ -46676,6 +46826,125 @@ const onEventUpdated = (callback) => createEventEventSubscriber('event.updated',
46676
46826
  */
46677
46827
  const onEventDeleted = (callback) => createEventEventSubscriber('event.deleted', callback);
46678
46828
 
46829
+ /**
46830
+ * ```js
46831
+ * import { EventRepository } from '@amityco/ts-sdk'
46832
+ * const dispose = EventRepository.onLocalEventCreated(event => {
46833
+ * // ...
46834
+ * })
46835
+ * ```
46836
+ *
46837
+ * Fired when a {@link Amity.Event} has been created
46838
+ *
46839
+ * @param callback The function to call when the event was fired
46840
+ * @returns an {@link Amity.Unsubscriber} function to stop listening
46841
+ *
46842
+ * @category Event Events
46843
+ */
46844
+ const onLocalEventCreated = (callback) => createEventEventSubscriber('local.event.created', callback);
46845
+
46846
+ /**
46847
+ * ```js
46848
+ * import { EventRepository } from '@amityco/ts-sdk'
46849
+ * const dispose = EventRepository.onLocalEventUpdated(event => {
46850
+ * // ...
46851
+ * })
46852
+ * ```
46853
+ *
46854
+ * Fired when a {@link Amity.Event} has been updated
46855
+ *
46856
+ * @param callback The function to call when the event was fired
46857
+ * @returns an {@link Amity.Unsubscriber} function to stop listening
46858
+ *
46859
+ * @category Event Events
46860
+ */
46861
+ const onLocalEventUpdated = (callback) => createEventEventSubscriber('local.event.updated', callback);
46862
+
46863
+ /**
46864
+ * ```js
46865
+ * import { EventRepository } from '@amityco/ts-sdk'
46866
+ * const dispose = EventRepository.onLocalEventDeleted(event => {
46867
+ * // ...
46868
+ * })
46869
+ * ```
46870
+ *
46871
+ * Fired when a {@link Amity.Event} has been deleted
46872
+ *
46873
+ * @param callback The function to call when the event was fired
46874
+ * @returns an {@link Amity.Unsubscriber} function to stop listening
46875
+ *
46876
+ * @category Event Events
46877
+ */
46878
+ const onLocalEventDeleted = (callback) => createEventEventSubscriber('local.event.deleted', callback);
46879
+
46880
+ /**
46881
+ * ```js
46882
+ * import { EventRepository } from '@amityco/ts-sdk'
46883
+ * const dispose = EventRepository.onRSVPCreated(event => {
46884
+ * // ...
46885
+ * })
46886
+ * ```
46887
+ *
46888
+ * Fired when a {@link Amity.Event} has been created
46889
+ *
46890
+ * @param callback The function to call when the event was fired
46891
+ * @returns an {@link Amity.Unsubscriber} function to stop listening
46892
+ *
46893
+ * @category Event Events
46894
+ */
46895
+ const onRSVPCreated = (callback) => createEventEventSubscriber('event.rsvp.created', callback);
46896
+
46897
+ /**
46898
+ * ```js
46899
+ * import { EventRepository } from '@amityco/ts-sdk'
46900
+ * const dispose = EventRepository.onRSVPUpdated(event => {
46901
+ * // ...
46902
+ * })
46903
+ * ```
46904
+ *
46905
+ * Fired when a {@link Amity.Event} has been updated
46906
+ *
46907
+ * @param callback The function to call when the event was fired
46908
+ * @returns an {@link Amity.Unsubscriber} function to stop listening
46909
+ *
46910
+ * @category Event Events
46911
+ */
46912
+ const onRSVPUpdated = (callback) => createEventEventSubscriber('event.rsvp.updated', callback);
46913
+
46914
+ /**
46915
+ * ```js
46916
+ * import { EventRepository } from '@amityco/ts-sdk'
46917
+ * const dispose = EventRepository.onLocalRSVPCreated(event => {
46918
+ * // ...
46919
+ * })
46920
+ * ```
46921
+ *
46922
+ * Fired when a {@link Amity.Event} has been created
46923
+ *
46924
+ * @param callback The function to call when the event was fired
46925
+ * @returns an {@link Amity.Unsubscriber} function to stop listening
46926
+ *
46927
+ * @category Event Events
46928
+ */
46929
+ const onLocalRSVPCreated = (callback) => createEventEventSubscriber('local.rsvp.created', callback);
46930
+
46931
+ /**
46932
+ * ```js
46933
+ * import { EventRepository } from '@amityco/ts-sdk'
46934
+ * const dispose = EventRepository.onLocalEventUpdated(event => {
46935
+ * // ...
46936
+ * })
46937
+ * ```
46938
+ *
46939
+ * Fired when a {@link Amity.Event} has been updated
46940
+ *
46941
+ * @param callback The function to call when the event was fired
46942
+ * @returns an {@link Amity.Unsubscriber} function to stop listening
46943
+ *
46944
+ * @category Event Events
46945
+ */
46946
+ const onLocalRSVPUpdated = (callback) => createEventEventSubscriber('local.rsvp.updated', callback);
46947
+
46679
46948
  /* begin_public_function
46680
46949
  id: event.get
46681
46950
  */
@@ -46699,7 +46968,7 @@ const onEventDeleted = (callback) => createEventEventSubscriber('event.deleted',
46699
46968
  * @category Event Live Object
46700
46969
  */
46701
46970
  const getEvent = (eventId, callback) => {
46702
- return liveObject(eventId, callback, 'eventId', getEvent$1, [onEventCreated, onEventUpdated, onEventDeleted], {
46971
+ return liveObject(eventId, callback, 'eventId', getEvent$1, [onEventUpdated, onEventDeleted, onLocalEventUpdated, onLocalEventDeleted], {
46703
46972
  callbackDataSelector: (data) => (data ? eventLinkedObject(data) : data),
46704
46973
  });
46705
46974
  };
@@ -46710,6 +46979,8 @@ var EventActionsEnum;
46710
46979
  EventActionsEnum["OnEventCreated"] = "onEventCreated";
46711
46980
  EventActionsEnum["OnEventUpdated"] = "onEventUpdated";
46712
46981
  EventActionsEnum["OnEventDeleted"] = "onEventDeleted";
46982
+ EventActionsEnum["OnRSVPCreated"] = "onRSVPCreated";
46983
+ EventActionsEnum["OnRSVPUpdated"] = "onRSVPUpdated";
46713
46984
  })(EventActionsEnum || (EventActionsEnum = {}));
46714
46985
 
46715
46986
  class EventPaginationController extends PaginationController {
@@ -46794,6 +47065,9 @@ class EventLiveCollectionController extends LiveCollectionController {
46794
47065
  { fn: onEventCreated, action: EventActionsEnum.OnEventCreated },
46795
47066
  { fn: onEventUpdated, action: EventActionsEnum.OnEventUpdated },
46796
47067
  { fn: onEventDeleted, action: EventActionsEnum.OnEventDeleted },
47068
+ { fn: onLocalEventCreated, action: EventActionsEnum.OnEventCreated },
47069
+ { fn: onLocalEventUpdated, action: EventActionsEnum.OnEventUpdated },
47070
+ { fn: onLocalEventDeleted, action: EventActionsEnum.OnEventDeleted },
46797
47071
  ]);
46798
47072
  }
46799
47073
  notifyChange({ origin, loading, error }) {
@@ -46805,7 +47079,7 @@ class EventLiveCollectionController extends LiveCollectionController {
46805
47079
  .map(eventId => pullFromCache(['event', 'get', eventId]))
46806
47080
  .filter(isNonNullable)
46807
47081
  .map(({ data }) => data)) !== null && _b !== void 0 ? _b : []).map(LinkedObject.event);
46808
- if (!this.shouldNotify(data) && origin === 'event')
47082
+ if (!this.shouldNotify(data) && origin === "event" /* Amity.LiveDataOrigin.EVENT */)
46809
47083
  return;
46810
47084
  this.callback({
46811
47085
  data,
@@ -46882,6 +47156,12 @@ class MyEventQueryStreamController extends QueryStreamController {
46882
47156
  const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
46883
47157
  if (!collection)
46884
47158
  return;
47159
+ if (action === EventActionsEnum.OnEventCreated) {
47160
+ const client = getActiveClient();
47161
+ if (client.userId !== event.userId)
47162
+ return;
47163
+ collection.data = [...new Set([event.eventId, ...collection.data])];
47164
+ }
46885
47165
  if (action === EventActionsEnum.OnEventDeleted) {
46886
47166
  collection.data = collection.data.filter(eventId => eventId !== event.eventId);
46887
47167
  }
@@ -46922,6 +47202,9 @@ class MyEventLiveCollectionController extends LiveCollectionController {
46922
47202
  { fn: onEventCreated, action: EventActionsEnum.OnEventCreated },
46923
47203
  { fn: onEventUpdated, action: EventActionsEnum.OnEventUpdated },
46924
47204
  { fn: onEventDeleted, action: EventActionsEnum.OnEventDeleted },
47205
+ { fn: onLocalEventCreated, action: EventActionsEnum.OnEventCreated },
47206
+ { fn: onLocalEventUpdated, action: EventActionsEnum.OnEventUpdated },
47207
+ { fn: onLocalEventDeleted, action: EventActionsEnum.OnEventDeleted },
46925
47208
  ]);
46926
47209
  }
46927
47210
  notifyChange({ origin, loading, error }) {
@@ -46933,7 +47216,7 @@ class MyEventLiveCollectionController extends LiveCollectionController {
46933
47216
  .map(eventId => pullFromCache(['event', 'get', eventId]))
46934
47217
  .filter(isNonNullable)
46935
47218
  .map(({ data }) => data)) !== null && _b !== void 0 ? _b : []).map(LinkedObject.event);
46936
- if (!this.shouldNotify(data) && origin === 'event')
47219
+ if (!this.shouldNotify(data) && origin === "event" /* Amity.LiveDataOrigin.EVENT */)
46937
47220
  return;
46938
47221
  this.callback({
46939
47222
  data,
@@ -46971,6 +47254,141 @@ const getMyEvents = (params, callback, config) => {
46971
47254
  };
46972
47255
  };
46973
47256
 
47257
+ class RSVPPaginationController extends PaginationController {
47258
+ async getRequest(queryParams, token) {
47259
+ const { limit = COLLECTION_DEFAULT_PAGINATION_LIMIT, eventId } = queryParams, params = __rest(queryParams, ["limit", "eventId"]);
47260
+ const options = token ? { token } : { limit };
47261
+ const { data: response } = await this.http.get(`/api/v1/events/${eventId}/rsvps`, { params: Object.assign(Object.assign({}, params), { options }) });
47262
+ return response;
47263
+ }
47264
+ }
47265
+
47266
+ class RSVPQueryStreamController extends QueryStreamController {
47267
+ constructor(query, cacheKey, notifyChange, preparePayload) {
47268
+ super(query, cacheKey);
47269
+ this.notifyChange = notifyChange;
47270
+ this.preparePayload = preparePayload;
47271
+ }
47272
+ async saveToMainDB(response) {
47273
+ const processedPayload = this.preparePayload(response);
47274
+ const client = getActiveClient();
47275
+ const cachedAt = client.cache && Date.now();
47276
+ if (client.cache)
47277
+ ingestInCache(processedPayload, { cachedAt });
47278
+ }
47279
+ appendToQueryStream(response, direction, refresh = false) {
47280
+ var _a, _b;
47281
+ if (refresh) {
47282
+ pushToCache(this.cacheKey, { data: response.events.map(getResolver('event')) });
47283
+ }
47284
+ else {
47285
+ const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
47286
+ const events = (_b = collection === null || collection === void 0 ? void 0 : collection.data) !== null && _b !== void 0 ? _b : [];
47287
+ pushToCache(this.cacheKey, Object.assign(Object.assign({}, collection), { data: [...new Set([...events, ...response.events.map(getResolver('event'))])] }));
47288
+ }
47289
+ }
47290
+ reactor(action) {
47291
+ return (event) => {
47292
+ var _a;
47293
+ const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
47294
+ if (!collection)
47295
+ return;
47296
+ if (action === EventActionsEnum.OnEventCreated) {
47297
+ const client = getActiveClient();
47298
+ if (client.userId !== event.userId)
47299
+ return;
47300
+ collection.data = [...new Set([event.eventId, ...collection.data])];
47301
+ }
47302
+ if (action === EventActionsEnum.OnEventDeleted) {
47303
+ collection.data = collection.data.filter(eventId => eventId !== event.eventId);
47304
+ }
47305
+ pushToCache(this.cacheKey, collection);
47306
+ this.notifyChange({ origin: "event" /* Amity.LiveDataOrigin.EVENT */, loading: false });
47307
+ };
47308
+ }
47309
+ subscribeRTE(createSubscriber) {
47310
+ return createSubscriber.map(subscriber => subscriber.fn(this.reactor(subscriber.action)));
47311
+ }
47312
+ }
47313
+
47314
+ class RSVPLiveCollectionController extends LiveCollectionController {
47315
+ constructor(query, callback) {
47316
+ const queryStreamId = hash(query);
47317
+ const cacheKey = ['event', 'collection', queryStreamId];
47318
+ const paginationController = new RSVPPaginationController(query);
47319
+ super(paginationController, queryStreamId, cacheKey, callback);
47320
+ this.query = query;
47321
+ this.queryStreamController = new RSVPQueryStreamController(this.query, this.cacheKey, this.notifyChange.bind(this), prepareEventPayload);
47322
+ this.callback = callback.bind(this);
47323
+ this.loadPage({ initial: true });
47324
+ }
47325
+ setup() {
47326
+ var _a;
47327
+ const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
47328
+ if (!collection)
47329
+ pushToCache(this.cacheKey, { data: [], params: {} });
47330
+ }
47331
+ async persistModel(queryPayload) {
47332
+ await this.queryStreamController.saveToMainDB(queryPayload);
47333
+ }
47334
+ persistQueryStream({ response, direction, refresh, }) {
47335
+ this.queryStreamController.appendToQueryStream(response, direction, refresh);
47336
+ }
47337
+ startSubscription() {
47338
+ return this.queryStreamController.subscribeRTE([
47339
+ { fn: onRSVPCreated, action: EventActionsEnum.OnRSVPCreated },
47340
+ { fn: onRSVPUpdated, action: EventActionsEnum.OnRSVPUpdated },
47341
+ { fn: onLocalRSVPCreated, action: EventActionsEnum.OnRSVPCreated },
47342
+ { fn: onLocalRSVPUpdated, action: EventActionsEnum.OnRSVPUpdated },
47343
+ ]);
47344
+ }
47345
+ notifyChange({ origin, loading, error }) {
47346
+ var _a, _b;
47347
+ const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
47348
+ if (!collection)
47349
+ return;
47350
+ const data = ((_b = collection.data
47351
+ .map(eventId => pullFromCache(['event', 'get', eventId]))
47352
+ .filter(isNonNullable)
47353
+ .map(({ data }) => data)) !== null && _b !== void 0 ? _b : []).map(LinkedObject.event);
47354
+ if (!this.shouldNotify(data) && origin === "event" /* Amity.LiveDataOrigin.EVENT */)
47355
+ return;
47356
+ this.callback({
47357
+ data,
47358
+ error,
47359
+ loading,
47360
+ hasNextPage: !!this.paginationController.getNextToken(),
47361
+ onNextPage: () => this.loadPage({ direction: "next" /* Amity.LiveCollectionPageDirection.NEXT */ }),
47362
+ });
47363
+ }
47364
+ }
47365
+
47366
+ /**
47367
+ * Get events
47368
+ *
47369
+ * @param params the query parameters
47370
+ * @param callback the callback to be called when the events are updated
47371
+ * @returns events
47372
+ *
47373
+ * @category RSVP Live Collection
47374
+ *
47375
+ */
47376
+ const getRSVPs = (params, callback, config) => {
47377
+ const { log, cache } = getActiveClient();
47378
+ if (!cache)
47379
+ console.log(ENABLE_CACHE_MESSAGE);
47380
+ const timestamp = Date.now();
47381
+ log(`getRSVPs: (tmpid: ${timestamp}) > listen`);
47382
+ const eventLiveCollection = new RSVPLiveCollectionController(params, callback);
47383
+ const disposers = eventLiveCollection.startSubscription();
47384
+ const cacheKey = eventLiveCollection.getCacheKey();
47385
+ disposers.push(() => dropFromCache(cacheKey));
47386
+ return () => {
47387
+ log(`getRSVPs (tmpid: ${timestamp}) > dispose`);
47388
+ disposers.forEach(fn => fn());
47389
+ };
47390
+ };
47391
+
46974
47392
  var index = /*#__PURE__*/Object.freeze({
46975
47393
  __proto__: null,
46976
47394
  createEvent: createEvent,
@@ -46979,9 +47397,17 @@ var index = /*#__PURE__*/Object.freeze({
46979
47397
  onEventCreated: onEventCreated,
46980
47398
  onEventUpdated: onEventUpdated,
46981
47399
  onEventDeleted: onEventDeleted,
47400
+ onLocalEventCreated: onLocalEventCreated,
47401
+ onLocalEventUpdated: onLocalEventUpdated,
47402
+ onLocalEventDeleted: onLocalEventDeleted,
47403
+ onRSVPCreated: onRSVPCreated,
47404
+ onRSVPUpdated: onRSVPUpdated,
47405
+ onLocalRSVPCreated: onLocalRSVPCreated,
47406
+ onLocalRSVPUpdated: onLocalRSVPUpdated,
46982
47407
  getEvent: getEvent,
46983
47408
  getEvents: getEvents,
46984
- getMyEvents: getMyEvents
47409
+ getMyEvents: getMyEvents,
47410
+ getRSVPs: getRSVPs
46985
47411
  });
46986
47412
 
46987
47413
  export { API_REGIONS, index$4 as AdRepository, AmityEventOriginType, AmityEventResponseStatus, AmityEventStatus, AmityEventType, index$c as CategoryRepository, index$g as ChannelRepository, index$p as Client, index$b as CommentRepository, CommunityPostSettingMaps, CommunityPostSettings, index$d as CommunityRepository, ContentFeedType, ContentFlagReasonEnum, DefaultCommunityPostSetting, index as EventRepository, FeedDataTypeEnum, index$a as FeedRepository, FeedSortByEnum, FeedSourceEnum, FileAccessTypeEnum, index$m as FileRepository, FileType, GET_WATCHER_URLS, index$2 as InvitationRepository, InvitationSortByEnum, InvitationStatusEnum, InvitationTypeEnum, JoinRequestStatusEnum, JoinResultStatusEnum, index$1 as LiveReactionRepository, index$6 as LiveStreamPlayer, MembershipAcceptanceTypeEnum, MessageContentType, index$k as MessageRepository, index$7 as PollRepository, PostContentType, index$9 as PostRepository, PostStructureType, index$l as ReactionRepository, index$5 as StoryRepository, index$8 as StreamRepository, index$j as SubChannelRepository, SubscriptionLevels, index$n as UserRepository, UserTypeEnum, VERSION, VideoResolution, VideoSize, VideoTranscodingStatus, backupCache, createQuery, createReport, createUserToken, deleteReport, disableCache, dropFromCache, enableCache, filterByChannelMembership, filterByCommunityMembership, filterByFeedType, filterByPostDataTypes, filterByPropEquality, filterByPropInclusion, filterByPropIntersection, filterBySearchTerm, filterByStringComparePartially, getChannelTopic, getCommentTopic, getCommunityStoriesTopic, getCommunityTopic, getLiveReactionTopic, getLiveStreamTopic, getMarkedMessageTopic, getMarkerUserFeedTopic, getMessageTopic, getMyFollowersTopic, getMyFollowingsTopic, getNetworkTopic, getPostTopic, getRole, getSmartFeedChannelTopic, getSmartFeedMessageTopic, getSmartFeedSubChannelTopic, getStoryTopic, getSubChannelTopic, getUserTopic, isAfterBefore, isAfterBeforeRaw, isCachable, isFetcher, isFresh, isLocal, isMutator, isOffline, isPaged, isReportedByMe, isSkip, mergeInCache, index$3 as notificationTray, onChannelMarkerFetched, onFeedMarkerFetched, onFeedMarkerUpdated, onMessageMarked, onMessageMarkerFetched, onSubChannelMarkerFetched, onSubChannelMarkerUpdated, onUserMarkerFetched, onUserMarkerFetchedLegacy, pullFromCache, pushToCache, queryCache, queryOptions, queryRoles, restoreCache, runQuery, sortByChannelSegment, sortByDisplayName, sortByFirstCreated, sortByFirstUpdated, sortByLastActivity, sortByLastCreated, sortByLastUpdated, sortByLocalSortingDate, sortByName, sortBySegmentNumber, subscribeTopic, toPage, toPageRaw, toToken, upsertInCache, wipeCache };