@amityco/ts-sdk 7.11.0 → 7.11.1-0e55a3b4.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 (113) hide show
  1. package/dist/@types/core/events.d.ts +36 -2
  2. package/dist/@types/core/events.d.ts.map +1 -1
  3. package/dist/@types/core/model.d.ts +4 -0
  4. package/dist/@types/core/model.d.ts.map +1 -1
  5. package/dist/@types/core/payload.d.ts +17 -0
  6. package/dist/@types/core/payload.d.ts.map +1 -1
  7. package/dist/@types/core/permissions.d.ts +5 -1
  8. package/dist/@types/core/permissions.d.ts.map +1 -1
  9. package/dist/@types/core/transport.d.ts +3 -0
  10. package/dist/@types/core/transport.d.ts.map +1 -1
  11. package/dist/@types/domains/community.d.ts +11 -1
  12. package/dist/@types/domains/community.d.ts.map +1 -1
  13. package/dist/@types/domains/event.d.ts +89 -0
  14. package/dist/@types/domains/event.d.ts.map +1 -0
  15. package/dist/@types/domains/notification.d.ts +3 -1
  16. package/dist/@types/domains/notification.d.ts.map +1 -1
  17. package/dist/@types/domains/partials.d.ts +2 -2
  18. package/dist/@types/domains/partials.d.ts.map +1 -1
  19. package/dist/@types/index.d.ts +1 -0
  20. package/dist/@types/index.d.ts.map +1 -1
  21. package/dist/core/events.d.ts +3 -3
  22. package/dist/core/events.d.ts.map +1 -1
  23. package/dist/core/model/idResolvers.d.ts.map +1 -1
  24. package/dist/core/model/index.d.ts.map +1 -1
  25. package/dist/eventRepository/api/createEvent.d.ts +16 -0
  26. package/dist/eventRepository/api/createEvent.d.ts.map +1 -0
  27. package/dist/eventRepository/api/deleteEvent.d.ts +15 -0
  28. package/dist/eventRepository/api/deleteEvent.d.ts.map +1 -0
  29. package/dist/eventRepository/api/index.d.ts +4 -0
  30. package/dist/eventRepository/api/index.d.ts.map +1 -0
  31. package/dist/eventRepository/api/updateEvent.d.ts +17 -0
  32. package/dist/eventRepository/api/updateEvent.d.ts.map +1 -0
  33. package/dist/eventRepository/events/enums.d.ts +8 -0
  34. package/dist/eventRepository/events/enums.d.ts.map +1 -0
  35. package/dist/eventRepository/events/index.d.ts +11 -0
  36. package/dist/eventRepository/events/index.d.ts.map +1 -0
  37. package/dist/eventRepository/events/onEventCreated.d.ts +17 -0
  38. package/dist/eventRepository/events/onEventCreated.d.ts.map +1 -0
  39. package/dist/eventRepository/events/onEventDeleted.d.ts +17 -0
  40. package/dist/eventRepository/events/onEventDeleted.d.ts.map +1 -0
  41. package/dist/eventRepository/events/onEventUpdated.d.ts +17 -0
  42. package/dist/eventRepository/events/onEventUpdated.d.ts.map +1 -0
  43. package/dist/eventRepository/events/onLocalEventCreated.d.ts +17 -0
  44. package/dist/eventRepository/events/onLocalEventCreated.d.ts.map +1 -0
  45. package/dist/eventRepository/events/onLocalEventDeleted.d.ts +17 -0
  46. package/dist/eventRepository/events/onLocalEventDeleted.d.ts.map +1 -0
  47. package/dist/eventRepository/events/onLocalEventUpdated.d.ts +17 -0
  48. package/dist/eventRepository/events/onLocalEventUpdated.d.ts.map +1 -0
  49. package/dist/eventRepository/events/onLocalRSVPCreated.d.ts +17 -0
  50. package/dist/eventRepository/events/onLocalRSVPCreated.d.ts.map +1 -0
  51. package/dist/eventRepository/events/onLocalRSVPUpdated.d.ts +17 -0
  52. package/dist/eventRepository/events/onLocalRSVPUpdated.d.ts.map +1 -0
  53. package/dist/eventRepository/events/onRSVPCreated.d.ts +17 -0
  54. package/dist/eventRepository/events/onRSVPCreated.d.ts.map +1 -0
  55. package/dist/eventRepository/events/onRSVPUpdated.d.ts +17 -0
  56. package/dist/eventRepository/events/onRSVPUpdated.d.ts.map +1 -0
  57. package/dist/eventRepository/index.d.ts +4 -0
  58. package/dist/eventRepository/index.d.ts.map +1 -0
  59. package/dist/eventRepository/internalApi/createRSVP.d.ts +16 -0
  60. package/dist/eventRepository/internalApi/createRSVP.d.ts.map +1 -0
  61. package/dist/eventRepository/internalApi/getEvent.d.ts +32 -0
  62. package/dist/eventRepository/internalApi/getEvent.d.ts.map +1 -0
  63. package/dist/eventRepository/internalApi/getMyRSVP.d.ts +32 -0
  64. package/dist/eventRepository/internalApi/getMyRSVP.d.ts.map +1 -0
  65. package/dist/eventRepository/internalApi/index.d.ts +5 -0
  66. package/dist/eventRepository/internalApi/index.d.ts.map +1 -0
  67. package/dist/eventRepository/internalApi/updateRSVP.d.ts +17 -0
  68. package/dist/eventRepository/internalApi/updateRSVP.d.ts.map +1 -0
  69. package/dist/eventRepository/observers/getEvent.d.ts +21 -0
  70. package/dist/eventRepository/observers/getEvent.d.ts.map +1 -0
  71. package/dist/eventRepository/observers/getEvents/LiveCollectionController.d.ts +13 -0
  72. package/dist/eventRepository/observers/getEvents/LiveCollectionController.d.ts.map +1 -0
  73. package/dist/eventRepository/observers/getEvents/PaginationController.d.ts +5 -0
  74. package/dist/eventRepository/observers/getEvents/PaginationController.d.ts.map +1 -0
  75. package/dist/eventRepository/observers/getEvents/QueryStreamController.d.ts +15 -0
  76. package/dist/eventRepository/observers/getEvents/QueryStreamController.d.ts.map +1 -0
  77. package/dist/eventRepository/observers/getEvents.d.ts +12 -0
  78. package/dist/eventRepository/observers/getEvents.d.ts.map +1 -0
  79. package/dist/eventRepository/observers/getMyEvents/LiveCollectionController.d.ts +13 -0
  80. package/dist/eventRepository/observers/getMyEvents/LiveCollectionController.d.ts.map +1 -0
  81. package/dist/eventRepository/observers/getMyEvents/PaginationController.d.ts +5 -0
  82. package/dist/eventRepository/observers/getMyEvents/PaginationController.d.ts.map +1 -0
  83. package/dist/eventRepository/observers/getMyEvents/QueryStreamController.d.ts +15 -0
  84. package/dist/eventRepository/observers/getMyEvents/QueryStreamController.d.ts.map +1 -0
  85. package/dist/eventRepository/observers/getMyEvents.d.ts +12 -0
  86. package/dist/eventRepository/observers/getMyEvents.d.ts.map +1 -0
  87. package/dist/eventRepository/observers/getRSVPs/LiveCollectionController.d.ts +13 -0
  88. package/dist/eventRepository/observers/getRSVPs/LiveCollectionController.d.ts.map +1 -0
  89. package/dist/eventRepository/observers/getRSVPs/PaginationController.d.ts +5 -0
  90. package/dist/eventRepository/observers/getRSVPs/PaginationController.d.ts.map +1 -0
  91. package/dist/eventRepository/observers/getRSVPs/QueryStreamController.d.ts +15 -0
  92. package/dist/eventRepository/observers/getRSVPs/QueryStreamController.d.ts.map +1 -0
  93. package/dist/eventRepository/observers/getRSVPs.d.ts +12 -0
  94. package/dist/eventRepository/observers/getRSVPs.d.ts.map +1 -0
  95. package/dist/eventRepository/observers/index.d.ts +5 -0
  96. package/dist/eventRepository/observers/index.d.ts.map +1 -0
  97. package/dist/eventRepository/utils/createEventEventSubscriber.d.ts +2 -0
  98. package/dist/eventRepository/utils/createEventEventSubscriber.d.ts.map +1 -0
  99. package/dist/eventRepository/utils/index.d.ts +3 -0
  100. package/dist/eventRepository/utils/index.d.ts.map +1 -0
  101. package/dist/eventRepository/utils/prepareEventPayload.d.ts +2 -0
  102. package/dist/eventRepository/utils/prepareEventPayload.d.ts.map +1 -0
  103. package/dist/index.cjs.js +1077 -51
  104. package/dist/index.d.ts +1 -0
  105. package/dist/index.d.ts.map +1 -1
  106. package/dist/index.esm.js +1057 -32
  107. package/dist/index.umd.js +3 -3
  108. package/dist/messagePreview/utils/getChannelMessagePreviewWithUser.d.ts +1 -1
  109. package/dist/utils/linkedObject/eventLinkObject.d.ts +2 -0
  110. package/dist/utils/linkedObject/eventLinkObject.d.ts.map +1 -0
  111. package/dist/utils/linkedObject/index.d.ts +1 -0
  112. package/dist/utils/linkedObject/index.d.ts.map +1 -1
  113. package/package.json +1 -1
package/dist/index.esm.js CHANGED
@@ -177,6 +177,29 @@ var FeedSourceEnum;
177
177
  FeedSourceEnum["User"] = "user";
178
178
  })(FeedSourceEnum || (FeedSourceEnum = {}));
179
179
 
180
+ var AmityEventType;
181
+ (function (AmityEventType) {
182
+ AmityEventType["Virtual"] = "virtual";
183
+ AmityEventType["InPerson"] = "in_person";
184
+ })(AmityEventType || (AmityEventType = {}));
185
+ var AmityEventOriginType;
186
+ (function (AmityEventOriginType) {
187
+ AmityEventOriginType["Community"] = "community";
188
+ AmityEventOriginType["User"] = "user";
189
+ })(AmityEventOriginType || (AmityEventOriginType = {}));
190
+ var AmityEventStatus;
191
+ (function (AmityEventStatus) {
192
+ AmityEventStatus["Scheduled"] = "scheduled";
193
+ AmityEventStatus["Live"] = "live";
194
+ AmityEventStatus["Ended"] = "ended";
195
+ AmityEventStatus["Cancelled"] = "cancelled";
196
+ })(AmityEventStatus || (AmityEventStatus = {}));
197
+ var AmityEventResponseStatus;
198
+ (function (AmityEventResponseStatus) {
199
+ AmityEventResponseStatus["Going"] = "going";
200
+ AmityEventResponseStatus["NotGoing"] = "not_going";
201
+ })(AmityEventResponseStatus || (AmityEventResponseStatus = {}));
202
+
180
203
  function getVersion() {
181
204
  try {
182
205
  // the string ''v7.11.0-esm'' should be replaced by actual value by @rollup/plugin-replace
@@ -625,6 +648,8 @@ const idResolvers = {
625
648
  notificationTraySeen: ({ userId }) => userId,
626
649
  invitation: ({ _id }) => _id,
627
650
  joinRequest: ({ joinRequestId }) => joinRequestId,
651
+ event: ({ eventId }) => eventId,
652
+ discussionCommunity: ({ communityId }) => communityId,
628
653
  };
629
654
  /**
630
655
  * Retrieve the id resolver matching a domain name
@@ -680,6 +705,8 @@ const PAYLOAD2MODEL = {
680
705
  notificationTrayItems: 'notificationTrayItem',
681
706
  invitations: 'invitation',
682
707
  joinRequests: 'joinRequest',
708
+ events: 'event',
709
+ discussionCommunities: 'discussionCommunity',
683
710
  };
684
711
  /** hidden */
685
712
  const isOutdated = (prevData, nextData) => {
@@ -26552,7 +26579,7 @@ const getUserUnread = (callback) => {
26552
26579
  };
26553
26580
  };
26554
26581
 
26555
- var index$o = /*#__PURE__*/Object.freeze({
26582
+ var index$p = /*#__PURE__*/Object.freeze({
26556
26583
  __proto__: null,
26557
26584
  getActiveClient: getActiveClient,
26558
26585
  getActiveUser: getActiveUser,
@@ -27771,7 +27798,7 @@ const getMyFollowInfo = (callback) => {
27771
27798
  };
27772
27799
  /* end_public_function */
27773
27800
 
27774
- var index$n = /*#__PURE__*/Object.freeze({
27801
+ var index$o = /*#__PURE__*/Object.freeze({
27775
27802
  __proto__: null,
27776
27803
  blockUser: blockUser,
27777
27804
  unBlockUser: unBlockUser,
@@ -29750,6 +29777,209 @@ const communityLinkedObject = (community) => {
29750
29777
  } });
29751
29778
  };
29752
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
+
29929
+ const eventLinkedObject = (event) => {
29930
+ return Object.assign(Object.assign({}, event), { get creator() {
29931
+ const cacheData = pullFromCache(['user', 'get', event.userId]);
29932
+ if (!(cacheData === null || cacheData === void 0 ? void 0 : cacheData.data))
29933
+ return;
29934
+ return userLinkedObject(cacheData.data);
29935
+ },
29936
+ get discussionCommunity() {
29937
+ if (!event.discussionCommunityId)
29938
+ return;
29939
+ const cacheData = pullFromCache([
29940
+ 'discussionCommunity',
29941
+ 'get',
29942
+ event.discussionCommunityId,
29943
+ ]);
29944
+ if (!(cacheData === null || cacheData === void 0 ? void 0 : cacheData.data))
29945
+ return;
29946
+ return communityLinkedObject(cacheData.data);
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
+ },
29964
+ get liveStream() {
29965
+ if (!event.livestreamId)
29966
+ return;
29967
+ const cacheData = pullFromCache(['stream', 'get', event.livestreamId]);
29968
+ if (!(cacheData === null || cacheData === void 0 ? void 0 : cacheData.data))
29969
+ return;
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;
29980
+ } });
29981
+ };
29982
+
29753
29983
  const LinkedObject = {
29754
29984
  ad: adLinkedObject,
29755
29985
  comment: commentLinkedObject,
@@ -29768,6 +29998,7 @@ const LinkedObject = {
29768
29998
  invitation: invitationLinkedObject,
29769
29999
  joinRequest: joinRequestLinkedObject,
29770
30000
  channelMember: channelMemberLinkedObject,
30001
+ event: eventLinkedObject,
29771
30002
  };
29772
30003
 
29773
30004
  /* begin_public_function
@@ -30758,9 +30989,9 @@ var AmityUserSearchMatchType;
30758
30989
  AmityUserSearchMatchType["PARTIAL"] = "partial";
30759
30990
  })(AmityUserSearchMatchType || (AmityUserSearchMatchType = {}));
30760
30991
 
30761
- var index$m = /*#__PURE__*/Object.freeze({
30992
+ var index$n = /*#__PURE__*/Object.freeze({
30762
30993
  __proto__: null,
30763
- Relationship: index$n,
30994
+ Relationship: index$o,
30764
30995
  getUserByIds: getUserByIds,
30765
30996
  updateUser: updateUser,
30766
30997
  flagUser: flagUser,
@@ -31163,7 +31394,7 @@ const uploadAudio = async (formData, onProgress) => {
31163
31394
  };
31164
31395
  /* end_public_function */
31165
31396
 
31166
- var index$l = /*#__PURE__*/Object.freeze({
31397
+ var index$m = /*#__PURE__*/Object.freeze({
31167
31398
  __proto__: null,
31168
31399
  getFile: getFile,
31169
31400
  uploadFile: uploadFile,
@@ -32975,7 +33206,7 @@ const getReactions$1 = (params, callback, config) => {
32975
33206
  };
32976
33207
  /* end_public_function */
32977
33208
 
32978
- var index$k = /*#__PURE__*/Object.freeze({
33209
+ var index$l = /*#__PURE__*/Object.freeze({
32979
33210
  __proto__: null,
32980
33211
  addReaction: addReaction,
32981
33212
  removeReaction: removeReaction,
@@ -34747,7 +34978,7 @@ const getMessages = (params, callback, config) => {
34747
34978
  };
34748
34979
  /* end_public_function */
34749
34980
 
34750
- var index$j = /*#__PURE__*/Object.freeze({
34981
+ var index$k = /*#__PURE__*/Object.freeze({
34751
34982
  __proto__: null,
34752
34983
  createMessage: createMessage,
34753
34984
  updateMessage: updateMessage,
@@ -35273,7 +35504,7 @@ const stopMessageReceiptSync = (subChannelId) => {
35273
35504
  };
35274
35505
  /* end_public_function */
35275
35506
 
35276
- var index$i = /*#__PURE__*/Object.freeze({
35507
+ var index$j = /*#__PURE__*/Object.freeze({
35277
35508
  __proto__: null,
35278
35509
  getSubChannelByIds: getSubChannels$1,
35279
35510
  createSubChannel: createSubChannel,
@@ -36600,7 +36831,7 @@ const searchMembers$1 = (params, callback, config) => {
36600
36831
  };
36601
36832
  /* end_public_function */
36602
36833
 
36603
- var index$h = /*#__PURE__*/Object.freeze({
36834
+ var index$i = /*#__PURE__*/Object.freeze({
36604
36835
  __proto__: null,
36605
36836
  addMembers: addMembers$1,
36606
36837
  removeMembers: removeMembers$1,
@@ -36803,7 +37034,7 @@ const unmuteMembers = async (channelId, userIds) => {
36803
37034
  };
36804
37035
  /* end_public_function */
36805
37036
 
36806
- var index$g = /*#__PURE__*/Object.freeze({
37037
+ var index$h = /*#__PURE__*/Object.freeze({
36807
37038
  __proto__: null,
36808
37039
  addRole: addRole,
36809
37040
  removeRole: removeRole,
@@ -36813,10 +37044,10 @@ var index$g = /*#__PURE__*/Object.freeze({
36813
37044
  unmuteMembers: unmuteMembers
36814
37045
  });
36815
37046
 
36816
- var index$f = /*#__PURE__*/Object.freeze({
37047
+ var index$g = /*#__PURE__*/Object.freeze({
36817
37048
  __proto__: null,
36818
- Membership: index$h,
36819
- Moderation: index$g,
37049
+ Membership: index$i,
37050
+ Moderation: index$h,
36820
37051
  getChannelByIds: getChannelByIds$1,
36821
37052
  createChannel: createChannel,
36822
37053
  updateChannel: updateChannel,
@@ -38219,7 +38450,7 @@ const searchMembers = (params, callback, config) => {
38219
38450
  };
38220
38451
  /* end_public_function */
38221
38452
 
38222
- var index$e = /*#__PURE__*/Object.freeze({
38453
+ var index$f = /*#__PURE__*/Object.freeze({
38223
38454
  __proto__: null,
38224
38455
  addMembers: addMembers,
38225
38456
  removeMembers: removeMembers,
@@ -39470,7 +39701,7 @@ const unbanMembers = async (communityId, userIds) => {
39470
39701
  };
39471
39702
  /* end_public_function */
39472
39703
 
39473
- var index$d = /*#__PURE__*/Object.freeze({
39704
+ var index$e = /*#__PURE__*/Object.freeze({
39474
39705
  __proto__: null,
39475
39706
  addRoles: addRoles,
39476
39707
  removeRoles: removeRoles,
@@ -39478,10 +39709,10 @@ var index$d = /*#__PURE__*/Object.freeze({
39478
39709
  unbanMembers: unbanMembers
39479
39710
  });
39480
39711
 
39481
- var index$c = /*#__PURE__*/Object.freeze({
39712
+ var index$d = /*#__PURE__*/Object.freeze({
39482
39713
  __proto__: null,
39483
- Moderation: index$d,
39484
- Membership: index$e,
39714
+ Moderation: index$e,
39715
+ Membership: index$f,
39485
39716
  getCommunityByIds: getCommunities$1,
39486
39717
  createCommunity: createCommunity,
39487
39718
  updateCommunity: updateCommunity,
@@ -39715,7 +39946,7 @@ const getCategories = (params, callback, config) => {
39715
39946
  };
39716
39947
  /* end_public_function */
39717
39948
 
39718
- var index$b = /*#__PURE__*/Object.freeze({
39949
+ var index$c = /*#__PURE__*/Object.freeze({
39719
39950
  __proto__: null,
39720
39951
  getCategory: getCategory,
39721
39952
  getCategories: getCategories
@@ -40774,7 +41005,7 @@ const getComments = (params, callback, config) => {
40774
41005
  };
40775
41006
  /* end_public_function */
40776
41007
 
40777
- var index$a = /*#__PURE__*/Object.freeze({
41008
+ var index$b = /*#__PURE__*/Object.freeze({
40778
41009
  __proto__: null,
40779
41010
  getCommentByIds: getCommentByIds,
40780
41011
  createComment: createComment,
@@ -41445,7 +41676,7 @@ const getUserFeed = (params, callback, config) => {
41445
41676
  };
41446
41677
  /* end_public_function */
41447
41678
 
41448
- var index$9 = /*#__PURE__*/Object.freeze({
41679
+ var index$a = /*#__PURE__*/Object.freeze({
41449
41680
  __proto__: null,
41450
41681
  queryGlobalFeed: queryGlobalFeed,
41451
41682
  getCustomRankingGlobalFeed: getCustomRankingGlobalFeed,
@@ -43126,7 +43357,7 @@ const searchPostsByHashtag = (params, callback, config) => {
43126
43357
  };
43127
43358
  /* end_public_function */
43128
43359
 
43129
- var index$8 = /*#__PURE__*/Object.freeze({
43360
+ var index$9 = /*#__PURE__*/Object.freeze({
43130
43361
  __proto__: null,
43131
43362
  getPostByIds: getPostByIds,
43132
43363
  createPost: createPost,
@@ -43734,7 +43965,7 @@ const getStreams = (params, callback, config) => {
43734
43965
  };
43735
43966
  };
43736
43967
 
43737
- var index$7 = /*#__PURE__*/Object.freeze({
43968
+ var index$8 = /*#__PURE__*/Object.freeze({
43738
43969
  __proto__: null,
43739
43970
  createStream: createStream,
43740
43971
  updateStream: updateStream,
@@ -44052,7 +44283,7 @@ const getPoll = (pollId, callback) => {
44052
44283
  };
44053
44284
  /* end_public_function */
44054
44285
 
44055
- var index$6 = /*#__PURE__*/Object.freeze({
44286
+ var index$7 = /*#__PURE__*/Object.freeze({
44056
44287
  __proto__: null,
44057
44288
  createPoll: createPoll,
44058
44289
  closePoll: closePoll,
@@ -44064,7 +44295,7 @@ var index$6 = /*#__PURE__*/Object.freeze({
44064
44295
  getPoll: getPoll
44065
44296
  });
44066
44297
 
44067
- const privateKey = "-----BEGIN PRIVATE KEY-----\nMIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQDHo80SecH7FuF2\nhFYnb+l26/VN8UMLXAQFLnxciNTEwkGVFMpdezlH8rU2HtUJL4RETogbAOLVY0XM\njs6sPn8G1nALmh9qeDpUtVqFOVtBHxEZ910TLOtQiunjqJKO5nWdqZ71EC3OFluR\niGQkO84BiIFbv37ub7xl3S8XarbtKoLcyVpkDHi+1wx1pgCAn6gtBUgckPL5NR8j\nLseabl3HAXQfhTCKo4tmOFM2Dxwl1IUMmIJrJg/aIU/U0tj/1Eoo7mG0JcNWX19l\nW3EecCbi0ncCJOrkUdwlBrcjaMayaX/ubEwyUeTGiLdyc4L3GRLHjyK8xgVNXRMH\nbZWJ2a5NAgMBAAECggEASxuE+35zTFO/XydKgmvIGcWL9FbgMlXb7Vcf0nBoG945\nbiz0NVc2paraIhJXc608xbYF3qLmtAE1MVBI0ORyRdBHNxY024l/6H6SH60Ed+uI\nM4ysp5ourY6Vj+DLwpdRiI9YDjqYAQDIUmhNxJP7XPhOMoZI6st+xZQBM34ic/bv\nAMSJm9OZphSp3+qXVkFZztr2mxD2EZSJJLYxi8BCdgM2qhazalbcJ6zDKHCZWVWm\n8RRxDGldyMb/237JxETzP40tAlzOZDmBAbUgEnurDJ93RVDIE3rbZUshwgeQd18a\nem096mWgvB1AIKYgsTAR3pw+V19YWAjq/glP6fz8wQKBgQD/oQq+ukKF0PRgBeM5\ngeTjSwsdGppQLmf5ndujvoiz/TpdjDEPu6R8kigQr1rG2t4K/yfdZoI8RdmJD1al\n3Q7N9hofooSy4rj6E3txzWZCHJjHad2cnCp/O26HiReGAl7wTcfTmNdiFHhZQzm5\nJBkvWAiwuvQMNfEbnXxw6/vIDwKBgQDH7fX8gsc77JLvAWgp1MaQN/sbqVb6JeT1\nFQfR8E/WFCSmzQBtNzd5KgYuCeelwr/8DyYytvN2BzCYZXp73gI1jF3YlW5jVn74\nOY6TwQ095digwo6Z0yuxopdIOApKgAkL9PRKgNrqAf3NAyMua6lOGifzjDojC3KU\nfylQmxMn4wKBgHp2B9O/H0dEBw5JQ8W0+JX6yWQz7mEjGiR2/1W+XXb8hQ1zr709\nw1r6Gb+EghRpnZ3fBpYGGbYOMFx8wKHM+N6qW3F0ReX8v2juFGE8aRSa5oYBrWzt\nU16Idjbv8hj84cZ1PJmdyvDtpYn9rpWHOZl4rxEbPvbqkIsOMyNVqdT5AoGAOSge\nmwIIU2le2FVeohbibXiToWTYKMuMmURZ5/r72AgKMmWJKbAPe+Q3wBG01/7FRBpQ\noU8Ma0HC8s6QJbliiEyIx9JwrJWd1vkdecBHONrtA4ibm/5zD2WcOllLF+FitLhi\n3qnX6+6F0IaFGFBPJrTzlv0P4dTz/OAdv52V7GECgYEA2TttOKBAqWllgOaZOkql\nLVMJVmgR7s6tLi1+cEP8ZcapV9aRbRzTAKXm4f8AEhtlG9F9kCOvHYCYGi6JaiWJ\nZkHjeex3T+eE6Di6y5Bm/Ift5jtVhJ4jCVwHOKTMej79NPUFTJfv8hCo29haBDv6\nRXFrv+T21KCcw8k3sJeJWWQ=\n-----END PRIVATE KEY-----";
44298
+ const privateKey = "-----BEGIN PRIVATE KEY-----\nMIIEvwIBADANBgkqhkiG9w0BAQEFAASCBKkwggSlAgEAAoIBAQDAARz+hmBgi8pJ\nQb8LeY41gtHhk+ACMwRfhsn7GqpqRQNG2qU0755mzZuVDUqjQMGSo8THJB7O+OJs\nflbZRkFXlFoFOVNw1UpNOgwEQZ6wB9oRwzepTJAfF1sVhm/o/ixvXh1zDFNDy6yZ\npXyiiJHUVxqyjllZhxnwdvjoVtDs6hW6awG09bB9nh/TTejlUKXoAgzqVwu/1QMu\nUVViET495elEe19aUarEy+oL2iKeXCEvqda/pWNBdbieFyJvvZ08HN8dPuT88wq2\njZLEAth1vrwQ2IAa4ktaLcBQdLJgIkrbDvAiVZ8lQAjS/bq5vXQikTGvoPlC5bbn\nvuOM/3eLAgMBAAECggEAVZ+peHAghq2QVj71nX5lxsNCKaCyYwixSJBpfouTt7Rz\nE6PpzMOXFi1W1o+I22jDakuSM2SOQKqI/u0QefB0r0O/KVk5NrZHXk0mkrdYtxOp\nUgaGyf8UvmjB+8VqHrNKyZdk9qtmbnNj01kTTcAtmE4H39zPR7eR/8Rul94vaZbs\nwCnKJS3mLT3JxyGug6lxanveKkjG+CKC1nJQYWaxCJxaFSzbwXQPvDhB+TvrIbee\npd5v4EAyEJohpr+T9oDGGJkb/KARBZCtwLyB976PKJwwBA8MRVL1i5QwawuMiMq5\nUtnOnbGKtCeFzaLbNU0Qi8bqyims84EQxC6DOu1fkQKBgQDdvsoBsEhsOXV7hlIJ\naEd0eSJZVkdqimxH8uGoMM2FeNaOrcB6yBXqTSP0R3OIyf8eaY6yjRvP30ZNXcll\n/gD3O1Mu6YmWQdt1W2WA6pKOsUuPXasf0pdOF7IiFZKlSabz5YHXFqwVuqm8loaj\nsXel3YWqPVdHiankE7tz+3ssnQKBgQDdqi4TNdD1MdEpihx19jr0QjUiXW3939FK\nqp30HESPEGDGQzXdmJgif9HhZb+cJSuWaHEbjgBrYahvgCF+y6LbEpOD+D/dmT+s\nDEAQaR84sah6dokwPjV8fjBSrcVFjCS+doxv0d3p/9OUEeyUhFrY03nxtIEYkLIE\n/Zvn37b4RwKBgQCLENVFe9XfsaVhQ5r9dV2iyTlmh7qgMZG5CbTFs12hQGhm8McO\n+Z7s41YSJCFr/yq1WwP4LJDtrBw99vyQr1zRsG35tNLp3gGRNzGQSQyC2uQFVHw2\np+7mNewsfhUK/gbrXNsyFnDz6635rPlhfbII3sWuP2wWXFqkxE9CbMwR7QKBgQC6\nawDMzxmo2/iYArrkyevSuEuPVxvFwpF1RgAI6C0QVCnPE38dmdN4UB7mfHekje4W\nVEercMURidPp0cxZolCYBQtilUjAyL0vqC3In1/Ogjq6oy3FEMxSop1pKxMY5j+Q\nnoqFD+6deLUrddeNH7J3X4LSr4dSbX4JjG+tlgt+yQKBgQCuwTL4hA6KqeInQ0Ta\n9VQX5Qr8hFlqJz1gpymi/k63tW/Ob8yedbg3WWNWyShwRMFYyY9S81ITFWM95uL6\nvF3x9rmRjwElJw9PMwVu6dmf/CO0Z1wzXSp2VVD12gbrUD/0/d7MUoJ9LgC8X8f/\nn0txLHYGHbx+nf95+JUg6lV3hg==\n-----END PRIVATE KEY-----";
44068
44299
  /*
44069
44300
  * The crypto algorithm used for importing key and signing string
44070
44301
  */
@@ -44435,7 +44666,7 @@ const getPlayer = async (parameters) => {
44435
44666
  return video;
44436
44667
  };
44437
44668
 
44438
- var index$5 = /*#__PURE__*/Object.freeze({
44669
+ var index$6 = /*#__PURE__*/Object.freeze({
44439
44670
  __proto__: null,
44440
44671
  getPlayer: getPlayer
44441
44672
  });
@@ -45608,7 +45839,7 @@ const getGlobalStoryTargets = (params, callback, config) => {
45608
45839
  };
45609
45840
  };
45610
45841
 
45611
- var index$4 = /*#__PURE__*/Object.freeze({
45842
+ var index$5 = /*#__PURE__*/Object.freeze({
45612
45843
  __proto__: null,
45613
45844
  createImageStory: createImageStory,
45614
45845
  createVideoStory: createVideoStory,
@@ -45645,7 +45876,7 @@ const getNetworkAds = async () => {
45645
45876
  };
45646
45877
  };
45647
45878
 
45648
- var index$3 = /*#__PURE__*/Object.freeze({
45879
+ var index$4 = /*#__PURE__*/Object.freeze({
45649
45880
  __proto__: null,
45650
45881
  getNetworkAds: getNetworkAds
45651
45882
  });
@@ -46036,7 +46267,7 @@ const markTraySeen = async (lastSeenAt) => {
46036
46267
  };
46037
46268
  /* end_public_function */
46038
46269
 
46039
- var index$2 = /*#__PURE__*/Object.freeze({
46270
+ var index$3 = /*#__PURE__*/Object.freeze({
46040
46271
  __proto__: null,
46041
46272
  getNotificationTraySeen: getNotificationTraySeen,
46042
46273
  getNotificationTrayItems: getNotificationTrayItems,
@@ -46237,7 +46468,7 @@ const getMyCommunityInvitations = (params, callback, config) => {
46237
46468
  };
46238
46469
  };
46239
46470
 
46240
- var index$1 = /*#__PURE__*/Object.freeze({
46471
+ var index$2 = /*#__PURE__*/Object.freeze({
46241
46472
  __proto__: null,
46242
46473
  onLocalInvitationCreated: onLocalInvitationCreated,
46243
46474
  onLocalInvitationUpdated: onLocalInvitationUpdated,
@@ -46378,11 +46609,805 @@ const getReactions = (postId, callback) => {
46378
46609
  };
46379
46610
  };
46380
46611
 
46381
- var index = /*#__PURE__*/Object.freeze({
46612
+ var index$1 = /*#__PURE__*/Object.freeze({
46382
46613
  __proto__: null,
46383
46614
  createReaction: createReaction,
46384
46615
  onLiveReactionCreated: onLiveReactionCreated,
46385
46616
  getReactions: getReactions
46386
46617
  });
46387
46618
 
46388
- export { API_REGIONS, index$3 as AdRepository, index$b as CategoryRepository, index$f as ChannelRepository, index$o as Client, index$a as CommentRepository, CommunityPostSettingMaps, CommunityPostSettings, index$c as CommunityRepository, ContentFeedType, ContentFlagReasonEnum, DefaultCommunityPostSetting, FeedDataTypeEnum, index$9 as FeedRepository, FeedSortByEnum, FeedSourceEnum, FileAccessTypeEnum, index$l as FileRepository, FileType, GET_WATCHER_URLS, index$1 as InvitationRepository, InvitationSortByEnum, InvitationStatusEnum, InvitationTypeEnum, JoinRequestStatusEnum, JoinResultStatusEnum, index as LiveReactionRepository, index$5 as LiveStreamPlayer, MembershipAcceptanceTypeEnum, MessageContentType, index$j as MessageRepository, index$6 as PollRepository, PostContentType, index$8 as PostRepository, PostStructureType, index$k as ReactionRepository, index$4 as StoryRepository, index$7 as StreamRepository, index$i as SubChannelRepository, SubscriptionLevels, index$m 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$2 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 };
46619
+ /* begin_public_function
46620
+ id: event.create
46621
+ */
46622
+ /**
46623
+ * ```js
46624
+ * import { EventRepository } from '@amityco/ts-sdk'
46625
+ * const response = await EventRepository.createEvent(bundle)
46626
+ * ```
46627
+ *
46628
+ * Creates an {@link Amity.Event}
46629
+ *
46630
+ * @param bundle The data necessary to create a new {@link Amity.Event}
46631
+ * @returns The newly created {@link Amity.Event}
46632
+ *
46633
+ * @category Event API
46634
+ * @async
46635
+ */
46636
+ const createEvent = async (bundle) => {
46637
+ const client = getActiveClient();
46638
+ client.log('event/createEvent', bundle);
46639
+ const { data: payload } = await client.http.post('/api/v1/events', bundle);
46640
+ fireEvent('local.event.created', payload);
46641
+ const preparedPayload = prepareEventPayload(payload);
46642
+ const cachedAt = client.cache && Date.now();
46643
+ if (client.cache)
46644
+ ingestInCache(preparedPayload, { cachedAt });
46645
+ return {
46646
+ data: eventLinkedObject(preparedPayload.events[0]),
46647
+ cachedAt,
46648
+ };
46649
+ };
46650
+ /* end_public_function */
46651
+
46652
+ /* begin_public_function
46653
+ id: event.update
46654
+ */
46655
+ /**
46656
+ * ```js
46657
+ * import { EventRepository } from '@amityco/ts-sdk'
46658
+ * const response = await EventRepository.updateEvent(eventId, bundle)
46659
+ * ```
46660
+ *
46661
+ * Updates an {@link Amity.Event}
46662
+ *
46663
+ * @param eventId The ID of the {@link Amity.Event} to edit
46664
+ * @param bundle The data necessary to update an existing {@link Amity.Event}
46665
+ * @returns the updated {@link Amity.Event}
46666
+ *
46667
+ * @category Event API
46668
+ * @async
46669
+ */
46670
+ const updateEvent = async (eventId, bundle) => {
46671
+ const client = getActiveClient();
46672
+ client.log('event/updateEvent', eventId, bundle);
46673
+ const { data: payload } = await client.http.put(`/api/v1/events/${eventId}`, bundle);
46674
+ fireEvent('local.event.updated', payload);
46675
+ const preparedPayload = prepareEventPayload(payload);
46676
+ const cachedAt = client.cache && Date.now();
46677
+ if (client.cache)
46678
+ ingestInCache(preparedPayload, { cachedAt });
46679
+ return {
46680
+ data: eventLinkedObject(preparedPayload.events.find(event => event.eventId === eventId)),
46681
+ cachedAt,
46682
+ };
46683
+ };
46684
+ /* end_public_function */
46685
+
46686
+ /* begin_public_function
46687
+ id: event.get
46688
+ */
46689
+ /**
46690
+ * ```js
46691
+ * import { EventRepository } from '@amityco/ts-sdk'
46692
+ * const event = await EventRepository.getEvent(eventId)
46693
+ * ```
46694
+ *
46695
+ * Fetches a {@link Amity.Event} object
46696
+ *
46697
+ * @param eventId the ID of the {@link Amity.Event} to fetch
46698
+ * @returns the associated {@link Amity.Event} object
46699
+ *
46700
+ * @category Event API
46701
+ * @async
46702
+ */
46703
+ const getEvent$1 = async (eventId) => {
46704
+ const client = getActiveClient();
46705
+ client.log('event/getEvent', eventId);
46706
+ const { data: payload } = await client.http.get(`/api/v1/events/${eventId}`);
46707
+ const data = prepareEventPayload(payload);
46708
+ const cachedAt = client.cache && Date.now();
46709
+ if (client.cache)
46710
+ ingestInCache(data, { cachedAt });
46711
+ return {
46712
+ data: data.events.find(event => event.eventId === eventId),
46713
+ cachedAt,
46714
+ };
46715
+ };
46716
+ /* end_public_function */
46717
+ /**
46718
+ * ```js
46719
+ * import { EventRepository } from '@amityco/ts-sdk'
46720
+ * const event = EventRepository.getEvent.locally(eventId)
46721
+ * ```
46722
+ *
46723
+ * Fetches a {@link Amity.Event} object in cache
46724
+ *
46725
+ * @param eventId the ID of the {@link Amity.Event} to fetch
46726
+ * @returns the associated {@link Amity.Event} object
46727
+ *
46728
+ * @category Event API
46729
+ */
46730
+ getEvent$1.locally = (eventId) => {
46731
+ const client = getActiveClient();
46732
+ client.log('event/getEvent.locally', eventId);
46733
+ if (!client.cache)
46734
+ return;
46735
+ const cache = pullFromCache(['event', 'get', eventId]);
46736
+ if (!cache)
46737
+ return;
46738
+ return {
46739
+ data: cache.data,
46740
+ cachedAt: cache.cachedAt,
46741
+ };
46742
+ };
46743
+
46744
+ /* begin_public_function
46745
+ id: event.delete
46746
+ */
46747
+ /**
46748
+ * ```js
46749
+ * import { EventRepository } from '@amityco/ts-sdk'
46750
+ * const { success } = await EventRepository.deleteEvent(eventId)
46751
+ * ```
46752
+ *
46753
+ * Deletes a {@link Amity.Event}
46754
+ *
46755
+ * @param eventId The {@link Amity.Event} ID to delete
46756
+ *
46757
+ * @category Event API
46758
+ * @async
46759
+ */
46760
+ const deleteEvent = async (eventId) => {
46761
+ const client = getActiveClient();
46762
+ client.log('event/deleteEvent', eventId);
46763
+ const event = await getEvent$1(eventId);
46764
+ await client.http.delete(`/api/v1/events/${eventId}`);
46765
+ const deletedEvent = Object.assign(Object.assign({}, event.data), { isDeleted: true });
46766
+ upsertInCache(['event', 'get', eventId], deletedEvent);
46767
+ fireEvent('local.event.deleted', {
46768
+ users: [],
46769
+ files: [],
46770
+ communities: [],
46771
+ videoStreamings: [],
46772
+ events: [deletedEvent],
46773
+ discussionCommunities: [],
46774
+ });
46775
+ };
46776
+ /* end_public_function */
46777
+
46778
+ /**
46779
+ * ```js
46780
+ * import { EventRepository } from '@amityco/ts-sdk'
46781
+ * const dispose = EventRepository.onEventCreated(event => {
46782
+ * // ...
46783
+ * })
46784
+ * ```
46785
+ *
46786
+ * Fired when a {@link Amity.Event} has been created
46787
+ *
46788
+ * @param callback The function to call when the event was fired
46789
+ * @returns an {@link Amity.Unsubscriber} function to stop listening
46790
+ *
46791
+ * @category Event Events
46792
+ */
46793
+ const onEventCreated = (callback) => createEventEventSubscriber('event.created', callback);
46794
+
46795
+ /**
46796
+ * ```js
46797
+ * import { EventRepository } from '@amityco/ts-sdk'
46798
+ * const dispose = EventRepository.onEventUpdated(event => {
46799
+ * // ...
46800
+ * })
46801
+ * ```
46802
+ *
46803
+ * Fired when a {@link Amity.Event} has been updated
46804
+ *
46805
+ * @param callback The function to call when the event was fired
46806
+ * @returns an {@link Amity.Unsubscriber} function to stop listening
46807
+ *
46808
+ * @category Event Events
46809
+ */
46810
+ const onEventUpdated = (callback) => createEventEventSubscriber('event.updated', callback);
46811
+
46812
+ /**
46813
+ * ```js
46814
+ * import { EventRepository } from '@amityco/ts-sdk'
46815
+ * const dispose = EventRepository.onEventDeleted(event => {
46816
+ * // ...
46817
+ * })
46818
+ * ```
46819
+ *
46820
+ * Fired when a {@link Amity.Event} has been deleted
46821
+ *
46822
+ * @param callback The function to call when the event was fired
46823
+ * @returns an {@link Amity.Unsubscriber} function to stop listening
46824
+ *
46825
+ * @category Event Events
46826
+ */
46827
+ const onEventDeleted = (callback) => createEventEventSubscriber('event.deleted', callback);
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
+
46948
+ /* begin_public_function
46949
+ id: event.get
46950
+ */
46951
+ /**
46952
+ * ```js
46953
+ * import { EventRepository } from '@amityco/ts-sdk';
46954
+ *
46955
+ * let event;
46956
+ *
46957
+ * const unsubscribe = EventRepository.getEvent(eventId, response => {
46958
+ * event = response.data;
46959
+ * });
46960
+ * ```
46961
+ *
46962
+ * Observe all mutation on a given {@link Amity.Event}
46963
+ *
46964
+ * @param eventId the ID of the event to observe
46965
+ * @param callback the function to call when new snapshot of event are available
46966
+ * @returns An {@link Amity.Unsubscriber} function to run when willing to stop observing the event
46967
+ *
46968
+ * @category Event Live Object
46969
+ */
46970
+ const getEvent = (eventId, callback) => {
46971
+ return liveObject(eventId, callback, 'eventId', getEvent$1, [onEventUpdated, onEventDeleted, onLocalEventUpdated, onLocalEventDeleted], {
46972
+ callbackDataSelector: (data) => (data ? eventLinkedObject(data) : data),
46973
+ });
46974
+ };
46975
+ /* end_public_function */
46976
+
46977
+ var EventActionsEnum;
46978
+ (function (EventActionsEnum) {
46979
+ EventActionsEnum["OnEventCreated"] = "onEventCreated";
46980
+ EventActionsEnum["OnEventUpdated"] = "onEventUpdated";
46981
+ EventActionsEnum["OnEventDeleted"] = "onEventDeleted";
46982
+ EventActionsEnum["OnRSVPCreated"] = "onRSVPCreated";
46983
+ EventActionsEnum["OnRSVPUpdated"] = "onRSVPUpdated";
46984
+ })(EventActionsEnum || (EventActionsEnum = {}));
46985
+
46986
+ class EventPaginationController extends PaginationController {
46987
+ async getRequest(queryParams, token) {
46988
+ const { limit = COLLECTION_DEFAULT_PAGINATION_LIMIT } = queryParams, params = __rest(queryParams, ["limit"]);
46989
+ const options = token ? { token } : { limit };
46990
+ const { data: response } = await this.http.get(`/api/v1/events`, { params: Object.assign(Object.assign({}, params), { options }) });
46991
+ return response;
46992
+ }
46993
+ }
46994
+
46995
+ class EventQueryStreamController extends QueryStreamController {
46996
+ constructor(query, cacheKey, notifyChange, preparePayload) {
46997
+ super(query, cacheKey);
46998
+ this.notifyChange = notifyChange;
46999
+ this.preparePayload = preparePayload;
47000
+ }
47001
+ async saveToMainDB(response) {
47002
+ const processedPayload = this.preparePayload(response);
47003
+ const client = getActiveClient();
47004
+ const cachedAt = client.cache && Date.now();
47005
+ if (client.cache)
47006
+ ingestInCache(processedPayload, { cachedAt });
47007
+ }
47008
+ appendToQueryStream(response, direction, refresh = false) {
47009
+ var _a, _b;
47010
+ if (refresh) {
47011
+ pushToCache(this.cacheKey, { data: response.events.map(getResolver('event')) });
47012
+ }
47013
+ else {
47014
+ const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
47015
+ const events = (_b = collection === null || collection === void 0 ? void 0 : collection.data) !== null && _b !== void 0 ? _b : [];
47016
+ pushToCache(this.cacheKey, Object.assign(Object.assign({}, collection), { data: [...new Set([...events, ...response.events.map(getResolver('event'))])] }));
47017
+ }
47018
+ }
47019
+ reactor(action) {
47020
+ return (event) => {
47021
+ var _a;
47022
+ const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
47023
+ if (!collection)
47024
+ return;
47025
+ if (action === EventActionsEnum.OnEventCreated) {
47026
+ collection.data = [...new Set([event.eventId, ...collection.data])];
47027
+ }
47028
+ if (action === EventActionsEnum.OnEventDeleted) {
47029
+ collection.data = collection.data.filter(eventId => eventId !== event.eventId);
47030
+ }
47031
+ pushToCache(this.cacheKey, collection);
47032
+ this.notifyChange({ origin: "event" /* Amity.LiveDataOrigin.EVENT */, loading: false });
47033
+ };
47034
+ }
47035
+ subscribeRTE(createSubscriber) {
47036
+ return createSubscriber.map(subscriber => subscriber.fn(this.reactor(subscriber.action)));
47037
+ }
47038
+ }
47039
+
47040
+ class EventLiveCollectionController extends LiveCollectionController {
47041
+ constructor(query, callback) {
47042
+ const queryStreamId = hash(query);
47043
+ const cacheKey = ['event', 'collection', queryStreamId];
47044
+ const paginationController = new EventPaginationController(query);
47045
+ super(paginationController, queryStreamId, cacheKey, callback);
47046
+ this.query = query;
47047
+ this.queryStreamController = new EventQueryStreamController(this.query, this.cacheKey, this.notifyChange.bind(this), prepareEventPayload);
47048
+ this.callback = callback.bind(this);
47049
+ this.loadPage({ initial: true });
47050
+ }
47051
+ setup() {
47052
+ var _a;
47053
+ const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
47054
+ if (!collection)
47055
+ pushToCache(this.cacheKey, { data: [], params: {} });
47056
+ }
47057
+ async persistModel(queryPayload) {
47058
+ await this.queryStreamController.saveToMainDB(queryPayload);
47059
+ }
47060
+ persistQueryStream({ response, direction, refresh, }) {
47061
+ this.queryStreamController.appendToQueryStream(response, direction, refresh);
47062
+ }
47063
+ startSubscription() {
47064
+ return this.queryStreamController.subscribeRTE([
47065
+ { fn: onEventCreated, action: EventActionsEnum.OnEventCreated },
47066
+ { fn: onEventUpdated, action: EventActionsEnum.OnEventUpdated },
47067
+ { fn: onEventDeleted, action: EventActionsEnum.OnEventDeleted },
47068
+ { fn: onLocalEventCreated, action: EventActionsEnum.OnEventCreated },
47069
+ { fn: onLocalEventUpdated, action: EventActionsEnum.OnEventUpdated },
47070
+ { fn: onLocalEventDeleted, action: EventActionsEnum.OnEventDeleted },
47071
+ ]);
47072
+ }
47073
+ notifyChange({ origin, loading, error }) {
47074
+ var _a, _b;
47075
+ const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
47076
+ if (!collection)
47077
+ return;
47078
+ const data = ((_b = collection.data
47079
+ .map(eventId => pullFromCache(['event', 'get', eventId]))
47080
+ .filter(isNonNullable)
47081
+ .map(({ data }) => data)) !== null && _b !== void 0 ? _b : []).map(LinkedObject.event);
47082
+ if (!this.shouldNotify(data) && origin === "event" /* Amity.LiveDataOrigin.EVENT */)
47083
+ return;
47084
+ this.callback({
47085
+ data,
47086
+ error,
47087
+ loading,
47088
+ hasNextPage: !!this.paginationController.getNextToken(),
47089
+ onNextPage: () => this.loadPage({ direction: "next" /* Amity.LiveCollectionPageDirection.NEXT */ }),
47090
+ });
47091
+ }
47092
+ }
47093
+
47094
+ /**
47095
+ * Get events
47096
+ *
47097
+ * @param params the query parameters
47098
+ * @param callback the callback to be called when the events are updated
47099
+ * @returns events
47100
+ *
47101
+ * @category Event Live Collection
47102
+ *
47103
+ */
47104
+ const getEvents = (params, callback, config) => {
47105
+ const { log, cache } = getActiveClient();
47106
+ if (!cache)
47107
+ console.log(ENABLE_CACHE_MESSAGE);
47108
+ const timestamp = Date.now();
47109
+ log(`getEvents: (tmpid: ${timestamp}) > listen`);
47110
+ const eventLiveCollection = new EventLiveCollectionController(params, callback);
47111
+ const disposers = eventLiveCollection.startSubscription();
47112
+ const cacheKey = eventLiveCollection.getCacheKey();
47113
+ disposers.push(() => dropFromCache(cacheKey));
47114
+ return () => {
47115
+ log(`getEvents (tmpid: ${timestamp}) > dispose`);
47116
+ disposers.forEach(fn => fn());
47117
+ };
47118
+ };
47119
+
47120
+ class MyEventPaginationController extends PaginationController {
47121
+ async getRequest(queryParams, token) {
47122
+ const { limit = COLLECTION_DEFAULT_PAGINATION_LIMIT } = queryParams, params = __rest(queryParams, ["limit"]);
47123
+ const options = token ? { token } : { limit };
47124
+ const { data: response } = await this.http.get(`/api/v1/events/me/rsvps`, { params: Object.assign(Object.assign({}, params), { options }) });
47125
+ return response;
47126
+ }
47127
+ }
47128
+
47129
+ class MyEventQueryStreamController extends QueryStreamController {
47130
+ constructor(query, cacheKey, notifyChange, preparePayload) {
47131
+ super(query, cacheKey);
47132
+ this.notifyChange = notifyChange;
47133
+ this.preparePayload = preparePayload;
47134
+ }
47135
+ async saveToMainDB(response) {
47136
+ const processedPayload = this.preparePayload(response);
47137
+ const client = getActiveClient();
47138
+ const cachedAt = client.cache && Date.now();
47139
+ if (client.cache)
47140
+ ingestInCache(processedPayload, { cachedAt });
47141
+ }
47142
+ appendToQueryStream(response, direction, refresh = false) {
47143
+ var _a, _b;
47144
+ if (refresh) {
47145
+ pushToCache(this.cacheKey, { data: response.events.map(getResolver('event')) });
47146
+ }
47147
+ else {
47148
+ const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
47149
+ const events = (_b = collection === null || collection === void 0 ? void 0 : collection.data) !== null && _b !== void 0 ? _b : [];
47150
+ pushToCache(this.cacheKey, Object.assign(Object.assign({}, collection), { data: [...new Set([...events, ...response.events.map(getResolver('event'))])] }));
47151
+ }
47152
+ }
47153
+ reactor(action) {
47154
+ return (event) => {
47155
+ var _a;
47156
+ const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
47157
+ if (!collection)
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
+ }
47165
+ if (action === EventActionsEnum.OnEventDeleted) {
47166
+ collection.data = collection.data.filter(eventId => eventId !== event.eventId);
47167
+ }
47168
+ pushToCache(this.cacheKey, collection);
47169
+ this.notifyChange({ origin: "event" /* Amity.LiveDataOrigin.EVENT */, loading: false });
47170
+ };
47171
+ }
47172
+ subscribeRTE(createSubscriber) {
47173
+ return createSubscriber.map(subscriber => subscriber.fn(this.reactor(subscriber.action)));
47174
+ }
47175
+ }
47176
+
47177
+ class MyEventLiveCollectionController extends LiveCollectionController {
47178
+ constructor(query, callback) {
47179
+ const queryStreamId = hash(query);
47180
+ const cacheKey = ['event', 'collection', queryStreamId];
47181
+ const paginationController = new MyEventPaginationController(query);
47182
+ super(paginationController, queryStreamId, cacheKey, callback);
47183
+ this.query = query;
47184
+ this.queryStreamController = new MyEventQueryStreamController(this.query, this.cacheKey, this.notifyChange.bind(this), prepareEventPayload);
47185
+ this.callback = callback.bind(this);
47186
+ this.loadPage({ initial: true });
47187
+ }
47188
+ setup() {
47189
+ var _a;
47190
+ const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
47191
+ if (!collection)
47192
+ pushToCache(this.cacheKey, { data: [], params: {} });
47193
+ }
47194
+ async persistModel(queryPayload) {
47195
+ await this.queryStreamController.saveToMainDB(queryPayload);
47196
+ }
47197
+ persistQueryStream({ response, direction, refresh, }) {
47198
+ this.queryStreamController.appendToQueryStream(response, direction, refresh);
47199
+ }
47200
+ startSubscription() {
47201
+ return this.queryStreamController.subscribeRTE([
47202
+ { fn: onEventCreated, action: EventActionsEnum.OnEventCreated },
47203
+ { fn: onEventUpdated, action: EventActionsEnum.OnEventUpdated },
47204
+ { fn: onEventDeleted, action: EventActionsEnum.OnEventDeleted },
47205
+ { fn: onLocalEventCreated, action: EventActionsEnum.OnEventCreated },
47206
+ { fn: onLocalEventUpdated, action: EventActionsEnum.OnEventUpdated },
47207
+ { fn: onLocalEventDeleted, action: EventActionsEnum.OnEventDeleted },
47208
+ ]);
47209
+ }
47210
+ notifyChange({ origin, loading, error }) {
47211
+ var _a, _b;
47212
+ const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
47213
+ if (!collection)
47214
+ return;
47215
+ const data = ((_b = collection.data
47216
+ .map(eventId => pullFromCache(['event', 'get', eventId]))
47217
+ .filter(isNonNullable)
47218
+ .map(({ data }) => data)) !== null && _b !== void 0 ? _b : []).map(LinkedObject.event);
47219
+ if (!this.shouldNotify(data) && origin === "event" /* Amity.LiveDataOrigin.EVENT */)
47220
+ return;
47221
+ this.callback({
47222
+ data,
47223
+ error,
47224
+ loading,
47225
+ hasNextPage: !!this.paginationController.getNextToken(),
47226
+ onNextPage: () => this.loadPage({ direction: "next" /* Amity.LiveCollectionPageDirection.NEXT */ }),
47227
+ });
47228
+ }
47229
+ }
47230
+
47231
+ /**
47232
+ * Get my events
47233
+ *
47234
+ * @param params the query parameters
47235
+ * @param callback the callback to be called when the events are updated
47236
+ * @returns events
47237
+ *
47238
+ * @category Event Live Collection
47239
+ *
47240
+ */
47241
+ const getMyEvents = (params, callback, config) => {
47242
+ const { log, cache } = getActiveClient();
47243
+ if (!cache)
47244
+ console.log(ENABLE_CACHE_MESSAGE);
47245
+ const timestamp = Date.now();
47246
+ log(`getMyEvents: (tmpid: ${timestamp}) > listen`);
47247
+ const myEventLiveCollection = new MyEventLiveCollectionController(params, callback);
47248
+ const disposers = myEventLiveCollection.startSubscription();
47249
+ const cacheKey = myEventLiveCollection.getCacheKey();
47250
+ disposers.push(() => dropFromCache(cacheKey));
47251
+ return () => {
47252
+ log(`getMyEvents (tmpid: ${timestamp}) > dispose`);
47253
+ disposers.forEach(fn => fn());
47254
+ };
47255
+ };
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
+
47392
+ var index = /*#__PURE__*/Object.freeze({
47393
+ __proto__: null,
47394
+ createEvent: createEvent,
47395
+ updateEvent: updateEvent,
47396
+ deleteEvent: deleteEvent,
47397
+ onEventCreated: onEventCreated,
47398
+ onEventUpdated: onEventUpdated,
47399
+ onEventDeleted: onEventDeleted,
47400
+ onLocalEventCreated: onLocalEventCreated,
47401
+ onLocalEventUpdated: onLocalEventUpdated,
47402
+ onLocalEventDeleted: onLocalEventDeleted,
47403
+ onRSVPCreated: onRSVPCreated,
47404
+ onRSVPUpdated: onRSVPUpdated,
47405
+ onLocalRSVPCreated: onLocalRSVPCreated,
47406
+ onLocalRSVPUpdated: onLocalRSVPUpdated,
47407
+ getEvent: getEvent,
47408
+ getEvents: getEvents,
47409
+ getMyEvents: getMyEvents,
47410
+ getRSVPs: getRSVPs
47411
+ });
47412
+
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 };