@amityco/ts-sdk 7.11.1-31db2c1f.0 → 7.11.1-36144a41.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 (89) hide show
  1. package/dist/@types/core/events.d.ts +32 -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 +81 -0
  14. package/dist/@types/domains/event.d.ts.map +1 -0
  15. package/dist/@types/domains/partials.d.ts +2 -2
  16. package/dist/@types/domains/partials.d.ts.map +1 -1
  17. package/dist/@types/index.d.ts +1 -0
  18. package/dist/@types/index.d.ts.map +1 -1
  19. package/dist/core/events.d.ts +3 -3
  20. package/dist/core/events.d.ts.map +1 -1
  21. package/dist/core/model/idResolvers.d.ts.map +1 -1
  22. package/dist/core/model/index.d.ts.map +1 -1
  23. package/dist/eventRepository/api/createEvent.d.ts +16 -0
  24. package/dist/eventRepository/api/createEvent.d.ts.map +1 -0
  25. package/dist/eventRepository/api/deleteEvent.d.ts +15 -0
  26. package/dist/eventRepository/api/deleteEvent.d.ts.map +1 -0
  27. package/dist/eventRepository/api/index.d.ts +4 -0
  28. package/dist/eventRepository/api/index.d.ts.map +1 -0
  29. package/dist/eventRepository/api/updateEvent.d.ts +17 -0
  30. package/dist/eventRepository/api/updateEvent.d.ts.map +1 -0
  31. package/dist/eventRepository/events/enums.d.ts +6 -0
  32. package/dist/eventRepository/events/enums.d.ts.map +1 -0
  33. package/dist/eventRepository/events/index.d.ts +7 -0
  34. package/dist/eventRepository/events/index.d.ts.map +1 -0
  35. package/dist/eventRepository/events/onEventCreated.d.ts +17 -0
  36. package/dist/eventRepository/events/onEventCreated.d.ts.map +1 -0
  37. package/dist/eventRepository/events/onEventDeleted.d.ts +17 -0
  38. package/dist/eventRepository/events/onEventDeleted.d.ts.map +1 -0
  39. package/dist/eventRepository/events/onEventUpdated.d.ts +17 -0
  40. package/dist/eventRepository/events/onEventUpdated.d.ts.map +1 -0
  41. package/dist/eventRepository/events/onLocalEventCreated.d.ts +17 -0
  42. package/dist/eventRepository/events/onLocalEventCreated.d.ts.map +1 -0
  43. package/dist/eventRepository/events/onLocalEventDeleted.d.ts +17 -0
  44. package/dist/eventRepository/events/onLocalEventDeleted.d.ts.map +1 -0
  45. package/dist/eventRepository/events/onLocalEventUpdated.d.ts +17 -0
  46. package/dist/eventRepository/events/onLocalEventUpdated.d.ts.map +1 -0
  47. package/dist/eventRepository/index.d.ts +4 -0
  48. package/dist/eventRepository/index.d.ts.map +1 -0
  49. package/dist/eventRepository/internalApi/getEvent.d.ts +32 -0
  50. package/dist/eventRepository/internalApi/getEvent.d.ts.map +1 -0
  51. package/dist/eventRepository/internalApi/index.d.ts +2 -0
  52. package/dist/eventRepository/internalApi/index.d.ts.map +1 -0
  53. package/dist/eventRepository/observers/getEvent.d.ts +21 -0
  54. package/dist/eventRepository/observers/getEvent.d.ts.map +1 -0
  55. package/dist/eventRepository/observers/getEvents/LiveCollectionController.d.ts +13 -0
  56. package/dist/eventRepository/observers/getEvents/LiveCollectionController.d.ts.map +1 -0
  57. package/dist/eventRepository/observers/getEvents/PaginationController.d.ts +5 -0
  58. package/dist/eventRepository/observers/getEvents/PaginationController.d.ts.map +1 -0
  59. package/dist/eventRepository/observers/getEvents/QueryStreamController.d.ts +15 -0
  60. package/dist/eventRepository/observers/getEvents/QueryStreamController.d.ts.map +1 -0
  61. package/dist/eventRepository/observers/getEvents.d.ts +12 -0
  62. package/dist/eventRepository/observers/getEvents.d.ts.map +1 -0
  63. package/dist/eventRepository/observers/getMyEvents/LiveCollectionController.d.ts +13 -0
  64. package/dist/eventRepository/observers/getMyEvents/LiveCollectionController.d.ts.map +1 -0
  65. package/dist/eventRepository/observers/getMyEvents/PaginationController.d.ts +5 -0
  66. package/dist/eventRepository/observers/getMyEvents/PaginationController.d.ts.map +1 -0
  67. package/dist/eventRepository/observers/getMyEvents/QueryStreamController.d.ts +15 -0
  68. package/dist/eventRepository/observers/getMyEvents/QueryStreamController.d.ts.map +1 -0
  69. package/dist/eventRepository/observers/getMyEvents.d.ts +12 -0
  70. package/dist/eventRepository/observers/getMyEvents.d.ts.map +1 -0
  71. package/dist/eventRepository/observers/index.d.ts +4 -0
  72. package/dist/eventRepository/observers/index.d.ts.map +1 -0
  73. package/dist/eventRepository/utils/createEventEventSubscriber.d.ts +2 -0
  74. package/dist/eventRepository/utils/createEventEventSubscriber.d.ts.map +1 -0
  75. package/dist/eventRepository/utils/index.d.ts +3 -0
  76. package/dist/eventRepository/utils/index.d.ts.map +1 -0
  77. package/dist/eventRepository/utils/prepareEventPayload.d.ts +2 -0
  78. package/dist/eventRepository/utils/prepareEventPayload.d.ts.map +1 -0
  79. package/dist/index.cjs.js +735 -52
  80. package/dist/index.d.ts +1 -0
  81. package/dist/index.d.ts.map +1 -1
  82. package/dist/index.esm.js +714 -32
  83. package/dist/index.umd.js +3 -3
  84. package/dist/messagePreview/utils/getChannelMessagePreviewWithUser.d.ts +1 -1
  85. package/dist/utils/linkedObject/eventLinkObject.d.ts +2 -0
  86. package/dist/utils/linkedObject/eventLinkObject.d.ts.map +1 -0
  87. package/dist/utils/linkedObject/index.d.ts +1 -0
  88. package/dist/utils/linkedObject/index.d.ts.map +1 -1
  89. package/package.json +1 -1
package/dist/index.esm.js CHANGED
@@ -184,6 +184,30 @@ var FeedSourceEnum;
184
184
  FeedSourceEnum["User"] = "user";
185
185
  })(FeedSourceEnum || (FeedSourceEnum = {}));
186
186
 
187
+ var AmityEventType;
188
+ (function (AmityEventType) {
189
+ AmityEventType["Virtual"] = "virtual";
190
+ AmityEventType["InPerson"] = "in_person";
191
+ })(AmityEventType || (AmityEventType = {}));
192
+ var AmityEventOriginType;
193
+ (function (AmityEventOriginType) {
194
+ AmityEventOriginType["Community"] = "community";
195
+ AmityEventOriginType["User"] = "user";
196
+ })(AmityEventOriginType || (AmityEventOriginType = {}));
197
+ var AmityEventStatus;
198
+ (function (AmityEventStatus) {
199
+ AmityEventStatus["Scheduled"] = "scheduled";
200
+ AmityEventStatus["Live"] = "live";
201
+ AmityEventStatus["Ended"] = "ended";
202
+ AmityEventStatus["Cancelled"] = "cancelled";
203
+ })(AmityEventStatus || (AmityEventStatus = {}));
204
+ var AmityEventResponseStatus;
205
+ (function (AmityEventResponseStatus) {
206
+ AmityEventResponseStatus["Going"] = "going";
207
+ AmityEventResponseStatus["Interested"] = "interested";
208
+ AmityEventResponseStatus["NotGoing"] = "not_going";
209
+ })(AmityEventResponseStatus || (AmityEventResponseStatus = {}));
210
+
187
211
  function getVersion() {
188
212
  try {
189
213
  // the string ''v7.11.0-esm'' should be replaced by actual value by @rollup/plugin-replace
@@ -633,6 +657,8 @@ const idResolvers = {
633
657
  invitation: ({ _id }) => _id,
634
658
  joinRequest: ({ joinRequestId }) => joinRequestId,
635
659
  room: ({ roomId }) => roomId,
660
+ event: ({ eventId }) => eventId,
661
+ discussionCommunity: ({ communityId }) => communityId,
636
662
  };
637
663
  /**
638
664
  * Retrieve the id resolver matching a domain name
@@ -689,6 +715,8 @@ const PAYLOAD2MODEL = {
689
715
  invitations: 'invitation',
690
716
  joinRequests: 'joinRequest',
691
717
  rooms: 'room',
718
+ events: 'event',
719
+ discussionCommunities: 'discussionCommunity',
692
720
  };
693
721
  /** hidden */
694
722
  const isOutdated = (prevData, nextData) => {
@@ -26571,7 +26599,7 @@ const getUserUnread = (callback) => {
26571
26599
  };
26572
26600
  };
26573
26601
 
26574
- var index$p = /*#__PURE__*/Object.freeze({
26602
+ var index$q = /*#__PURE__*/Object.freeze({
26575
26603
  __proto__: null,
26576
26604
  getActiveClient: getActiveClient,
26577
26605
  getActiveUser: getActiveUser,
@@ -27790,7 +27818,7 @@ const getMyFollowInfo = (callback) => {
27790
27818
  };
27791
27819
  /* end_public_function */
27792
27820
 
27793
- var index$o = /*#__PURE__*/Object.freeze({
27821
+ var index$p = /*#__PURE__*/Object.freeze({
27794
27822
  __proto__: null,
27795
27823
  blockUser: blockUser,
27796
27824
  unBlockUser: unBlockUser,
@@ -29880,6 +29908,51 @@ const communityLinkedObject = (community) => {
29880
29908
  } });
29881
29909
  };
29882
29910
 
29911
+ const eventLinkedObject = (event) => {
29912
+ return Object.assign(Object.assign({}, event), { get creator() {
29913
+ const cacheData = pullFromCache(['user', 'get', event.userId]);
29914
+ if (!(cacheData === null || cacheData === void 0 ? void 0 : cacheData.data))
29915
+ return;
29916
+ return userLinkedObject(cacheData.data);
29917
+ },
29918
+ get discussionCommunity() {
29919
+ if (!event.discussionCommunityId)
29920
+ return;
29921
+ const cacheData = pullFromCache([
29922
+ 'discussionCommunity',
29923
+ 'get',
29924
+ event.discussionCommunityId,
29925
+ ]);
29926
+ if (!(cacheData === null || cacheData === void 0 ? void 0 : cacheData.data))
29927
+ return;
29928
+ return communityLinkedObject(cacheData.data);
29929
+ },
29930
+ get targetCommunity() {
29931
+ if (!event.originId)
29932
+ return;
29933
+ const cacheData = pullFromCache(['community', 'get', event.originId]);
29934
+ if (!(cacheData === null || cacheData === void 0 ? void 0 : cacheData.data))
29935
+ return;
29936
+ return communityLinkedObject(cacheData.data);
29937
+ },
29938
+ get coverImage() {
29939
+ if (!event.coverImageFileId)
29940
+ return;
29941
+ const cacheData = pullFromCache(['file', 'get', event.coverImageFileId]);
29942
+ if (!(cacheData === null || cacheData === void 0 ? void 0 : cacheData.data))
29943
+ return;
29944
+ return cacheData.data;
29945
+ },
29946
+ get liveStream() {
29947
+ if (!event.livestreamId)
29948
+ return;
29949
+ const cacheData = pullFromCache(['stream', 'get', event.livestreamId]);
29950
+ if (!(cacheData === null || cacheData === void 0 ? void 0 : cacheData.data))
29951
+ return;
29952
+ return cacheData.data;
29953
+ } });
29954
+ };
29955
+
29883
29956
  const LinkedObject = {
29884
29957
  ad: adLinkedObject,
29885
29958
  comment: commentLinkedObject,
@@ -29899,6 +29972,7 @@ const LinkedObject = {
29899
29972
  joinRequest: joinRequestLinkedObject,
29900
29973
  channelMember: channelMemberLinkedObject,
29901
29974
  room: roomLinkedObject,
29975
+ event: eventLinkedObject,
29902
29976
  };
29903
29977
 
29904
29978
  /* begin_public_function
@@ -30889,9 +30963,9 @@ var AmityUserSearchMatchType;
30889
30963
  AmityUserSearchMatchType["PARTIAL"] = "partial";
30890
30964
  })(AmityUserSearchMatchType || (AmityUserSearchMatchType = {}));
30891
30965
 
30892
- var index$n = /*#__PURE__*/Object.freeze({
30966
+ var index$o = /*#__PURE__*/Object.freeze({
30893
30967
  __proto__: null,
30894
- Relationship: index$o,
30968
+ Relationship: index$p,
30895
30969
  getUserByIds: getUserByIds,
30896
30970
  updateUser: updateUser,
30897
30971
  flagUser: flagUser,
@@ -31294,7 +31368,7 @@ const uploadAudio = async (formData, onProgress) => {
31294
31368
  };
31295
31369
  /* end_public_function */
31296
31370
 
31297
- var index$m = /*#__PURE__*/Object.freeze({
31371
+ var index$n = /*#__PURE__*/Object.freeze({
31298
31372
  __proto__: null,
31299
31373
  getFile: getFile,
31300
31374
  uploadFile: uploadFile,
@@ -33106,7 +33180,7 @@ const getReactions$1 = (params, callback, config) => {
33106
33180
  };
33107
33181
  /* end_public_function */
33108
33182
 
33109
- var index$l = /*#__PURE__*/Object.freeze({
33183
+ var index$m = /*#__PURE__*/Object.freeze({
33110
33184
  __proto__: null,
33111
33185
  addReaction: addReaction,
33112
33186
  removeReaction: removeReaction,
@@ -34878,7 +34952,7 @@ const getMessages = (params, callback, config) => {
34878
34952
  };
34879
34953
  /* end_public_function */
34880
34954
 
34881
- var index$k = /*#__PURE__*/Object.freeze({
34955
+ var index$l = /*#__PURE__*/Object.freeze({
34882
34956
  __proto__: null,
34883
34957
  createMessage: createMessage,
34884
34958
  updateMessage: updateMessage,
@@ -35404,7 +35478,7 @@ const stopMessageReceiptSync = (subChannelId) => {
35404
35478
  };
35405
35479
  /* end_public_function */
35406
35480
 
35407
- var index$j = /*#__PURE__*/Object.freeze({
35481
+ var index$k = /*#__PURE__*/Object.freeze({
35408
35482
  __proto__: null,
35409
35483
  getSubChannelByIds: getSubChannels$1,
35410
35484
  createSubChannel: createSubChannel,
@@ -36731,7 +36805,7 @@ const searchMembers$1 = (params, callback, config) => {
36731
36805
  };
36732
36806
  /* end_public_function */
36733
36807
 
36734
- var index$i = /*#__PURE__*/Object.freeze({
36808
+ var index$j = /*#__PURE__*/Object.freeze({
36735
36809
  __proto__: null,
36736
36810
  addMembers: addMembers$1,
36737
36811
  removeMembers: removeMembers$1,
@@ -36934,7 +37008,7 @@ const unmuteMembers = async (channelId, userIds) => {
36934
37008
  };
36935
37009
  /* end_public_function */
36936
37010
 
36937
- var index$h = /*#__PURE__*/Object.freeze({
37011
+ var index$i = /*#__PURE__*/Object.freeze({
36938
37012
  __proto__: null,
36939
37013
  addRole: addRole,
36940
37014
  removeRole: removeRole,
@@ -36944,10 +37018,10 @@ var index$h = /*#__PURE__*/Object.freeze({
36944
37018
  unmuteMembers: unmuteMembers
36945
37019
  });
36946
37020
 
36947
- var index$g = /*#__PURE__*/Object.freeze({
37021
+ var index$h = /*#__PURE__*/Object.freeze({
36948
37022
  __proto__: null,
36949
- Membership: index$i,
36950
- Moderation: index$h,
37023
+ Membership: index$j,
37024
+ Moderation: index$i,
36951
37025
  getChannelByIds: getChannelByIds$1,
36952
37026
  createChannel: createChannel,
36953
37027
  updateChannel: updateChannel,
@@ -38350,7 +38424,7 @@ const searchMembers = (params, callback, config) => {
38350
38424
  };
38351
38425
  /* end_public_function */
38352
38426
 
38353
- var index$f = /*#__PURE__*/Object.freeze({
38427
+ var index$g = /*#__PURE__*/Object.freeze({
38354
38428
  __proto__: null,
38355
38429
  addMembers: addMembers,
38356
38430
  removeMembers: removeMembers,
@@ -39601,7 +39675,7 @@ const unbanMembers = async (communityId, userIds) => {
39601
39675
  };
39602
39676
  /* end_public_function */
39603
39677
 
39604
- var index$e = /*#__PURE__*/Object.freeze({
39678
+ var index$f = /*#__PURE__*/Object.freeze({
39605
39679
  __proto__: null,
39606
39680
  addRoles: addRoles,
39607
39681
  removeRoles: removeRoles,
@@ -39609,10 +39683,10 @@ var index$e = /*#__PURE__*/Object.freeze({
39609
39683
  unbanMembers: unbanMembers
39610
39684
  });
39611
39685
 
39612
- var index$d = /*#__PURE__*/Object.freeze({
39686
+ var index$e = /*#__PURE__*/Object.freeze({
39613
39687
  __proto__: null,
39614
- Moderation: index$e,
39615
- Membership: index$f,
39688
+ Moderation: index$f,
39689
+ Membership: index$g,
39616
39690
  getCommunityByIds: getCommunities$1,
39617
39691
  createCommunity: createCommunity,
39618
39692
  updateCommunity: updateCommunity,
@@ -39846,7 +39920,7 @@ const getCategories = (params, callback, config) => {
39846
39920
  };
39847
39921
  /* end_public_function */
39848
39922
 
39849
- var index$c = /*#__PURE__*/Object.freeze({
39923
+ var index$d = /*#__PURE__*/Object.freeze({
39850
39924
  __proto__: null,
39851
39925
  getCategory: getCategory,
39852
39926
  getCategories: getCategories
@@ -40905,7 +40979,7 @@ const getComments = (params, callback, config) => {
40905
40979
  };
40906
40980
  /* end_public_function */
40907
40981
 
40908
- var index$b = /*#__PURE__*/Object.freeze({
40982
+ var index$c = /*#__PURE__*/Object.freeze({
40909
40983
  __proto__: null,
40910
40984
  getCommentByIds: getCommentByIds,
40911
40985
  createComment: createComment,
@@ -41576,7 +41650,7 @@ const getUserFeed = (params, callback, config) => {
41576
41650
  };
41577
41651
  /* end_public_function */
41578
41652
 
41579
- var index$a = /*#__PURE__*/Object.freeze({
41653
+ var index$b = /*#__PURE__*/Object.freeze({
41580
41654
  __proto__: null,
41581
41655
  queryGlobalFeed: queryGlobalFeed,
41582
41656
  getCustomRankingGlobalFeed: getCustomRankingGlobalFeed,
@@ -43257,7 +43331,7 @@ const searchPostsByHashtag = (params, callback, config) => {
43257
43331
  };
43258
43332
  /* end_public_function */
43259
43333
 
43260
- var index$9 = /*#__PURE__*/Object.freeze({
43334
+ var index$a = /*#__PURE__*/Object.freeze({
43261
43335
  __proto__: null,
43262
43336
  getPostByIds: getPostByIds,
43263
43337
  createPost: createPost,
@@ -43865,7 +43939,7 @@ const getStreams = (params, callback, config) => {
43865
43939
  };
43866
43940
  };
43867
43941
 
43868
- var index$8 = /*#__PURE__*/Object.freeze({
43942
+ var index$9 = /*#__PURE__*/Object.freeze({
43869
43943
  __proto__: null,
43870
43944
  createStream: createStream,
43871
43945
  updateStream: updateStream,
@@ -44721,7 +44795,7 @@ const getRooms = (params, callback, config) => {
44721
44795
  };
44722
44796
  /* end_public_function */
44723
44797
 
44724
- var index$7 = /*#__PURE__*/Object.freeze({
44798
+ var index$8 = /*#__PURE__*/Object.freeze({
44725
44799
  __proto__: null,
44726
44800
  createRoom: createRoom,
44727
44801
  updateRoom: updateRoom,
@@ -45049,7 +45123,7 @@ const getPoll = (pollId, callback) => {
45049
45123
  };
45050
45124
  /* end_public_function */
45051
45125
 
45052
- var index$6 = /*#__PURE__*/Object.freeze({
45126
+ var index$7 = /*#__PURE__*/Object.freeze({
45053
45127
  __proto__: null,
45054
45128
  createPoll: createPoll,
45055
45129
  closePoll: closePoll,
@@ -45432,7 +45506,7 @@ const getPlayer = async (parameters) => {
45432
45506
  return video;
45433
45507
  };
45434
45508
 
45435
- var index$5 = /*#__PURE__*/Object.freeze({
45509
+ var index$6 = /*#__PURE__*/Object.freeze({
45436
45510
  __proto__: null,
45437
45511
  getPlayer: getPlayer
45438
45512
  });
@@ -46605,7 +46679,7 @@ const getGlobalStoryTargets = (params, callback, config) => {
46605
46679
  };
46606
46680
  };
46607
46681
 
46608
- var index$4 = /*#__PURE__*/Object.freeze({
46682
+ var index$5 = /*#__PURE__*/Object.freeze({
46609
46683
  __proto__: null,
46610
46684
  createImageStory: createImageStory,
46611
46685
  createVideoStory: createVideoStory,
@@ -46642,7 +46716,7 @@ const getNetworkAds = async () => {
46642
46716
  };
46643
46717
  };
46644
46718
 
46645
- var index$3 = /*#__PURE__*/Object.freeze({
46719
+ var index$4 = /*#__PURE__*/Object.freeze({
46646
46720
  __proto__: null,
46647
46721
  getNetworkAds: getNetworkAds
46648
46722
  });
@@ -47033,7 +47107,7 @@ const markTraySeen = async (lastSeenAt) => {
47033
47107
  };
47034
47108
  /* end_public_function */
47035
47109
 
47036
- var index$2 = /*#__PURE__*/Object.freeze({
47110
+ var index$3 = /*#__PURE__*/Object.freeze({
47037
47111
  __proto__: null,
47038
47112
  getNotificationTraySeen: getNotificationTraySeen,
47039
47113
  getNotificationTrayItems: getNotificationTrayItems,
@@ -47350,7 +47424,7 @@ const observeInvitations = (params, callback) => {
47350
47424
  };
47351
47425
  };
47352
47426
 
47353
- var index$1 = /*#__PURE__*/Object.freeze({
47427
+ var index$2 = /*#__PURE__*/Object.freeze({
47354
47428
  __proto__: null,
47355
47429
  cancelInvitation: cancelInvitation,
47356
47430
  acceptInvitation: acceptInvitation,
@@ -47494,11 +47568,619 @@ const getReactions = (postId, callback) => {
47494
47568
  };
47495
47569
  };
47496
47570
 
47497
- var index = /*#__PURE__*/Object.freeze({
47571
+ var index$1 = /*#__PURE__*/Object.freeze({
47498
47572
  __proto__: null,
47499
47573
  createReaction: createReaction,
47500
47574
  onLiveReactionCreated: onLiveReactionCreated,
47501
47575
  getReactions: getReactions
47502
47576
  });
47503
47577
 
47504
- export { API_REGIONS, index$3 as AdRepository, 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, FeedDataTypeEnum, index$a as FeedRepository, FeedSortByEnum, FeedSourceEnum, FileAccessTypeEnum, index$m as FileRepository, FileType, GET_WATCHER_URLS, index$1 as InvitationRepository, InvitationSortByEnum, InvitationStatusEnum, InvitationTargetTypeEnum, InvitationTypeEnum, JoinRequestStatusEnum, JoinResultStatusEnum, index as LiveReactionRepository, index$5 as LiveStreamPlayer, MembershipAcceptanceTypeEnum, MessageContentType, index$k as MessageRepository, index$6 as PollRepository, PostContentType, index$9 as PostRepository, PostStructureType, index$l as ReactionRepository, index$7 as RoomRepository, index$4 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, getRoomStreamerTopic, getRoomWatcherTopic, 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 };
47578
+ const prepareEventPayload = (rawPayload) => {
47579
+ return Object.assign(Object.assign({}, rawPayload), { users: rawPayload.users.map(convertRawUserToInternalUser) });
47580
+ };
47581
+
47582
+ const createEventEventSubscriber = (event, callback) => {
47583
+ const client = getActiveClient();
47584
+ const filter = (payload) => {
47585
+ const unpackedPayload = prepareEventPayload(payload);
47586
+ if (!client.cache) {
47587
+ callback(unpackedPayload.events[0]);
47588
+ }
47589
+ else {
47590
+ ingestInCache(unpackedPayload);
47591
+ const event = pullFromCache([
47592
+ 'event',
47593
+ 'get',
47594
+ unpackedPayload.events[0].eventId,
47595
+ ]);
47596
+ callback(event.data);
47597
+ }
47598
+ };
47599
+ return createEventSubscriber(client, event, event, filter);
47600
+ };
47601
+
47602
+ /* begin_public_function
47603
+ id: event.create
47604
+ */
47605
+ /**
47606
+ * ```js
47607
+ * import { EventRepository } from '@amityco/ts-sdk'
47608
+ * const response = await EventRepository.createEvent(bundle)
47609
+ * ```
47610
+ *
47611
+ * Creates an {@link Amity.Event}
47612
+ *
47613
+ * @param bundle The data necessary to create a new {@link Amity.Event}
47614
+ * @returns The newly created {@link Amity.Event}
47615
+ *
47616
+ * @category Event API
47617
+ * @async
47618
+ */
47619
+ const createEvent = async (bundle) => {
47620
+ const client = getActiveClient();
47621
+ client.log('event/createEvent', bundle);
47622
+ const { data: payload } = await client.http.post('/api/v1/events', bundle);
47623
+ fireEvent('local.event.created', payload);
47624
+ const preparedPayload = prepareEventPayload(payload);
47625
+ const cachedAt = client.cache && Date.now();
47626
+ if (client.cache)
47627
+ ingestInCache(preparedPayload, { cachedAt });
47628
+ return {
47629
+ data: eventLinkedObject(preparedPayload.events[0]),
47630
+ cachedAt,
47631
+ };
47632
+ };
47633
+ /* end_public_function */
47634
+
47635
+ /* begin_public_function
47636
+ id: event.update
47637
+ */
47638
+ /**
47639
+ * ```js
47640
+ * import { EventRepository } from '@amityco/ts-sdk'
47641
+ * const response = await EventRepository.updateEvent(eventId, bundle)
47642
+ * ```
47643
+ *
47644
+ * Updates an {@link Amity.Event}
47645
+ *
47646
+ * @param eventId The ID of the {@link Amity.Event} to edit
47647
+ * @param bundle The data necessary to update an existing {@link Amity.Event}
47648
+ * @returns the updated {@link Amity.Event}
47649
+ *
47650
+ * @category Event API
47651
+ * @async
47652
+ */
47653
+ const updateEvent = async (eventId, bundle) => {
47654
+ const client = getActiveClient();
47655
+ client.log('event/updateEvent', eventId, bundle);
47656
+ const { data: payload } = await client.http.put(`/api/v1/events/${eventId}`, bundle);
47657
+ fireEvent('local.event.updated', payload);
47658
+ const preparedPayload = prepareEventPayload(payload);
47659
+ const cachedAt = client.cache && Date.now();
47660
+ if (client.cache)
47661
+ ingestInCache(preparedPayload, { cachedAt });
47662
+ return {
47663
+ data: eventLinkedObject(preparedPayload.events.find(event => event.eventId === eventId)),
47664
+ cachedAt,
47665
+ };
47666
+ };
47667
+ /* end_public_function */
47668
+
47669
+ /* begin_public_function
47670
+ id: event.get
47671
+ */
47672
+ /**
47673
+ * ```js
47674
+ * import { EventRepository } from '@amityco/ts-sdk'
47675
+ * const event = await EventRepository.getEvent(eventId)
47676
+ * ```
47677
+ *
47678
+ * Fetches a {@link Amity.Event} object
47679
+ *
47680
+ * @param eventId the ID of the {@link Amity.Event} to fetch
47681
+ * @returns the associated {@link Amity.Event} object
47682
+ *
47683
+ * @category Event API
47684
+ * @async
47685
+ */
47686
+ const getEvent$1 = async (eventId) => {
47687
+ const client = getActiveClient();
47688
+ client.log('event/getEvent', eventId);
47689
+ const { data: payload } = await client.http.get(`/api/v1/events/${eventId}`);
47690
+ const data = prepareEventPayload(payload);
47691
+ const cachedAt = client.cache && Date.now();
47692
+ if (client.cache)
47693
+ ingestInCache(data, { cachedAt });
47694
+ return {
47695
+ data: data.events.find(event => event.eventId === eventId),
47696
+ cachedAt,
47697
+ };
47698
+ };
47699
+ /* end_public_function */
47700
+ /**
47701
+ * ```js
47702
+ * import { EventRepository } from '@amityco/ts-sdk'
47703
+ * const event = EventRepository.getEvent.locally(eventId)
47704
+ * ```
47705
+ *
47706
+ * Fetches a {@link Amity.Event} object in cache
47707
+ *
47708
+ * @param eventId the ID of the {@link Amity.Event} to fetch
47709
+ * @returns the associated {@link Amity.Event} object
47710
+ *
47711
+ * @category Event API
47712
+ */
47713
+ getEvent$1.locally = (eventId) => {
47714
+ const client = getActiveClient();
47715
+ client.log('event/getEvent.locally', eventId);
47716
+ if (!client.cache)
47717
+ return;
47718
+ const cache = pullFromCache(['event', 'get', eventId]);
47719
+ if (!cache)
47720
+ return;
47721
+ return {
47722
+ data: cache.data,
47723
+ cachedAt: cache.cachedAt,
47724
+ };
47725
+ };
47726
+
47727
+ /* begin_public_function
47728
+ id: event.delete
47729
+ */
47730
+ /**
47731
+ * ```js
47732
+ * import { EventRepository } from '@amityco/ts-sdk'
47733
+ * const { success } = await EventRepository.deleteEvent(eventId)
47734
+ * ```
47735
+ *
47736
+ * Deletes a {@link Amity.Event}
47737
+ *
47738
+ * @param eventId The {@link Amity.Event} ID to delete
47739
+ *
47740
+ * @category Event API
47741
+ * @async
47742
+ */
47743
+ const deleteEvent = async (eventId) => {
47744
+ const client = getActiveClient();
47745
+ client.log('event/deleteEvent', eventId);
47746
+ const event = await getEvent$1(eventId);
47747
+ await client.http.delete(`/api/v1/events/${eventId}`);
47748
+ const deletedEvent = Object.assign(Object.assign({}, event.data), { isDeleted: true });
47749
+ upsertInCache(['event', 'get', eventId], deletedEvent);
47750
+ fireEvent('local.event.deleted', {
47751
+ users: [],
47752
+ files: [],
47753
+ communities: [],
47754
+ videoStreamings: [],
47755
+ events: [deletedEvent],
47756
+ discussionCommunities: [],
47757
+ });
47758
+ };
47759
+ /* end_public_function */
47760
+
47761
+ /**
47762
+ * ```js
47763
+ * import { EventRepository } from '@amityco/ts-sdk'
47764
+ * const dispose = EventRepository.onEventCreated(event => {
47765
+ * // ...
47766
+ * })
47767
+ * ```
47768
+ *
47769
+ * Fired when a {@link Amity.Event} has been created
47770
+ *
47771
+ * @param callback The function to call when the event was fired
47772
+ * @returns an {@link Amity.Unsubscriber} function to stop listening
47773
+ *
47774
+ * @category Event Events
47775
+ */
47776
+ const onEventCreated = (callback) => createEventEventSubscriber('event.created', callback);
47777
+
47778
+ /**
47779
+ * ```js
47780
+ * import { EventRepository } from '@amityco/ts-sdk'
47781
+ * const dispose = EventRepository.onEventUpdated(event => {
47782
+ * // ...
47783
+ * })
47784
+ * ```
47785
+ *
47786
+ * Fired when a {@link Amity.Event} has been updated
47787
+ *
47788
+ * @param callback The function to call when the event was fired
47789
+ * @returns an {@link Amity.Unsubscriber} function to stop listening
47790
+ *
47791
+ * @category Event Events
47792
+ */
47793
+ const onEventUpdated = (callback) => createEventEventSubscriber('event.updated', callback);
47794
+
47795
+ /**
47796
+ * ```js
47797
+ * import { EventRepository } from '@amityco/ts-sdk'
47798
+ * const dispose = EventRepository.onEventDeleted(event => {
47799
+ * // ...
47800
+ * })
47801
+ * ```
47802
+ *
47803
+ * Fired when a {@link Amity.Event} has been deleted
47804
+ *
47805
+ * @param callback The function to call when the event was fired
47806
+ * @returns an {@link Amity.Unsubscriber} function to stop listening
47807
+ *
47808
+ * @category Event Events
47809
+ */
47810
+ const onEventDeleted = (callback) => createEventEventSubscriber('event.deleted', callback);
47811
+
47812
+ /**
47813
+ * ```js
47814
+ * import { EventRepository } from '@amityco/ts-sdk'
47815
+ * const dispose = EventRepository.onLocalEventCreated(event => {
47816
+ * // ...
47817
+ * })
47818
+ * ```
47819
+ *
47820
+ * Fired when a {@link Amity.Event} has been created
47821
+ *
47822
+ * @param callback The function to call when the event was fired
47823
+ * @returns an {@link Amity.Unsubscriber} function to stop listening
47824
+ *
47825
+ * @category Event Events
47826
+ */
47827
+ const onLocalEventCreated = (callback) => createEventEventSubscriber('local.event.created', callback);
47828
+
47829
+ /**
47830
+ * ```js
47831
+ * import { EventRepository } from '@amityco/ts-sdk'
47832
+ * const dispose = EventRepository.onLocalEventUpdated(event => {
47833
+ * // ...
47834
+ * })
47835
+ * ```
47836
+ *
47837
+ * Fired when a {@link Amity.Event} has been updated
47838
+ *
47839
+ * @param callback The function to call when the event was fired
47840
+ * @returns an {@link Amity.Unsubscriber} function to stop listening
47841
+ *
47842
+ * @category Event Events
47843
+ */
47844
+ const onLocalEventUpdated = (callback) => createEventEventSubscriber('local.event.updated', callback);
47845
+
47846
+ /**
47847
+ * ```js
47848
+ * import { EventRepository } from '@amityco/ts-sdk'
47849
+ * const dispose = EventRepository.onLocalEventDeleted(event => {
47850
+ * // ...
47851
+ * })
47852
+ * ```
47853
+ *
47854
+ * Fired when a {@link Amity.Event} has been deleted
47855
+ *
47856
+ * @param callback The function to call when the event was fired
47857
+ * @returns an {@link Amity.Unsubscriber} function to stop listening
47858
+ *
47859
+ * @category Event Events
47860
+ */
47861
+ const onLocalEventDeleted = (callback) => createEventEventSubscriber('local.event.deleted', callback);
47862
+
47863
+ /* begin_public_function
47864
+ id: event.get
47865
+ */
47866
+ /**
47867
+ * ```js
47868
+ * import { EventRepository } from '@amityco/ts-sdk';
47869
+ *
47870
+ * let event;
47871
+ *
47872
+ * const unsubscribe = EventRepository.getEvent(eventId, response => {
47873
+ * event = response.data;
47874
+ * });
47875
+ * ```
47876
+ *
47877
+ * Observe all mutation on a given {@link Amity.Event}
47878
+ *
47879
+ * @param eventId the ID of the event to observe
47880
+ * @param callback the function to call when new snapshot of event are available
47881
+ * @returns An {@link Amity.Unsubscriber} function to run when willing to stop observing the event
47882
+ *
47883
+ * @category Event Live Object
47884
+ */
47885
+ const getEvent = (eventId, callback) => {
47886
+ return liveObject(eventId, callback, 'eventId', getEvent$1, [onEventUpdated, onEventDeleted, onLocalEventUpdated, onLocalEventDeleted], {
47887
+ callbackDataSelector: (data) => (data ? eventLinkedObject(data) : data),
47888
+ });
47889
+ };
47890
+ /* end_public_function */
47891
+
47892
+ var EventActionsEnum;
47893
+ (function (EventActionsEnum) {
47894
+ EventActionsEnum["OnEventCreated"] = "onEventCreated";
47895
+ EventActionsEnum["OnEventUpdated"] = "onEventUpdated";
47896
+ EventActionsEnum["OnEventDeleted"] = "onEventDeleted";
47897
+ })(EventActionsEnum || (EventActionsEnum = {}));
47898
+
47899
+ class EventPaginationController extends PaginationController {
47900
+ async getRequest(queryParams, token) {
47901
+ const { limit = COLLECTION_DEFAULT_PAGINATION_LIMIT } = queryParams, params = __rest(queryParams, ["limit"]);
47902
+ const options = token ? { token } : { limit };
47903
+ const { data: response } = await this.http.get(`/api/v1/events`, { params: Object.assign(Object.assign({}, params), { options }) });
47904
+ return response;
47905
+ }
47906
+ }
47907
+
47908
+ class EventQueryStreamController extends QueryStreamController {
47909
+ constructor(query, cacheKey, notifyChange, preparePayload) {
47910
+ super(query, cacheKey);
47911
+ this.notifyChange = notifyChange;
47912
+ this.preparePayload = preparePayload;
47913
+ }
47914
+ async saveToMainDB(response) {
47915
+ const processedPayload = this.preparePayload(response);
47916
+ const client = getActiveClient();
47917
+ const cachedAt = client.cache && Date.now();
47918
+ if (client.cache)
47919
+ ingestInCache(processedPayload, { cachedAt });
47920
+ }
47921
+ appendToQueryStream(response, direction, refresh = false) {
47922
+ var _a, _b;
47923
+ if (refresh) {
47924
+ pushToCache(this.cacheKey, { data: response.events.map(getResolver('event')) });
47925
+ }
47926
+ else {
47927
+ const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
47928
+ const events = (_b = collection === null || collection === void 0 ? void 0 : collection.data) !== null && _b !== void 0 ? _b : [];
47929
+ pushToCache(this.cacheKey, Object.assign(Object.assign({}, collection), { data: [...new Set([...events, ...response.events.map(getResolver('event'))])] }));
47930
+ }
47931
+ }
47932
+ reactor(action) {
47933
+ return (event) => {
47934
+ var _a;
47935
+ const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
47936
+ if (!collection)
47937
+ return;
47938
+ if (action === EventActionsEnum.OnEventCreated) {
47939
+ collection.data = [...new Set([event.eventId, ...collection.data])];
47940
+ }
47941
+ if (action === EventActionsEnum.OnEventDeleted) {
47942
+ collection.data = collection.data.filter(eventId => eventId !== event.eventId);
47943
+ }
47944
+ pushToCache(this.cacheKey, collection);
47945
+ this.notifyChange({ origin: "event" /* Amity.LiveDataOrigin.EVENT */, loading: false });
47946
+ };
47947
+ }
47948
+ subscribeRTE(createSubscriber) {
47949
+ return createSubscriber.map(subscriber => subscriber.fn(this.reactor(subscriber.action)));
47950
+ }
47951
+ }
47952
+
47953
+ class EventLiveCollectionController extends LiveCollectionController {
47954
+ constructor(query, callback) {
47955
+ const queryStreamId = hash(query);
47956
+ const cacheKey = ['event', 'collection', queryStreamId];
47957
+ const paginationController = new EventPaginationController(query);
47958
+ super(paginationController, queryStreamId, cacheKey, callback);
47959
+ this.query = query;
47960
+ this.queryStreamController = new EventQueryStreamController(this.query, this.cacheKey, this.notifyChange.bind(this), prepareEventPayload);
47961
+ this.callback = callback.bind(this);
47962
+ this.loadPage({ initial: true });
47963
+ }
47964
+ setup() {
47965
+ var _a;
47966
+ const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
47967
+ if (!collection)
47968
+ pushToCache(this.cacheKey, { data: [], params: {} });
47969
+ }
47970
+ async persistModel(queryPayload) {
47971
+ await this.queryStreamController.saveToMainDB(queryPayload);
47972
+ }
47973
+ persistQueryStream({ response, direction, refresh, }) {
47974
+ this.queryStreamController.appendToQueryStream(response, direction, refresh);
47975
+ }
47976
+ startSubscription() {
47977
+ return this.queryStreamController.subscribeRTE([
47978
+ { fn: onEventCreated, action: EventActionsEnum.OnEventCreated },
47979
+ { fn: onEventUpdated, action: EventActionsEnum.OnEventUpdated },
47980
+ { fn: onEventDeleted, action: EventActionsEnum.OnEventDeleted },
47981
+ { fn: onLocalEventCreated, action: EventActionsEnum.OnEventCreated },
47982
+ { fn: onLocalEventUpdated, action: EventActionsEnum.OnEventUpdated },
47983
+ { fn: onLocalEventDeleted, action: EventActionsEnum.OnEventDeleted },
47984
+ ]);
47985
+ }
47986
+ notifyChange({ origin, loading, error }) {
47987
+ var _a, _b;
47988
+ const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
47989
+ if (!collection)
47990
+ return;
47991
+ const data = ((_b = collection.data
47992
+ .map(eventId => pullFromCache(['event', 'get', eventId]))
47993
+ .filter(isNonNullable)
47994
+ .map(({ data }) => data)) !== null && _b !== void 0 ? _b : []).map(LinkedObject.event);
47995
+ if (!this.shouldNotify(data) && origin === "event" /* Amity.LiveDataOrigin.EVENT */)
47996
+ return;
47997
+ this.callback({
47998
+ data,
47999
+ error,
48000
+ loading,
48001
+ hasNextPage: !!this.paginationController.getNextToken(),
48002
+ onNextPage: () => this.loadPage({ direction: "next" /* Amity.LiveCollectionPageDirection.NEXT */ }),
48003
+ });
48004
+ }
48005
+ }
48006
+
48007
+ /**
48008
+ * Get events
48009
+ *
48010
+ * @param params the query parameters
48011
+ * @param callback the callback to be called when the events are updated
48012
+ * @returns events
48013
+ *
48014
+ * @category Event Live Collection
48015
+ *
48016
+ */
48017
+ const getEvents = (params, callback, config) => {
48018
+ const { log, cache } = getActiveClient();
48019
+ if (!cache)
48020
+ console.log(ENABLE_CACHE_MESSAGE);
48021
+ const timestamp = Date.now();
48022
+ log(`getEvents: (tmpid: ${timestamp}) > listen`);
48023
+ const eventLiveCollection = new EventLiveCollectionController(params, callback);
48024
+ const disposers = eventLiveCollection.startSubscription();
48025
+ const cacheKey = eventLiveCollection.getCacheKey();
48026
+ disposers.push(() => dropFromCache(cacheKey));
48027
+ return () => {
48028
+ log(`getEvents (tmpid: ${timestamp}) > dispose`);
48029
+ disposers.forEach(fn => fn());
48030
+ };
48031
+ };
48032
+
48033
+ class MyEventPaginationController extends PaginationController {
48034
+ async getRequest(queryParams, token) {
48035
+ const { limit = COLLECTION_DEFAULT_PAGINATION_LIMIT } = queryParams, params = __rest(queryParams, ["limit"]);
48036
+ const options = token ? { token } : { limit };
48037
+ const { data: response } = await this.http.get(`/api/v1/events/me/rsvps`, { params: Object.assign(Object.assign({}, params), { options }) });
48038
+ return response;
48039
+ }
48040
+ }
48041
+
48042
+ class MyEventQueryStreamController extends QueryStreamController {
48043
+ constructor(query, cacheKey, notifyChange, preparePayload) {
48044
+ super(query, cacheKey);
48045
+ this.notifyChange = notifyChange;
48046
+ this.preparePayload = preparePayload;
48047
+ }
48048
+ async saveToMainDB(response) {
48049
+ const processedPayload = this.preparePayload(response);
48050
+ const client = getActiveClient();
48051
+ const cachedAt = client.cache && Date.now();
48052
+ if (client.cache)
48053
+ ingestInCache(processedPayload, { cachedAt });
48054
+ }
48055
+ appendToQueryStream(response, direction, refresh = false) {
48056
+ var _a, _b;
48057
+ if (refresh) {
48058
+ pushToCache(this.cacheKey, { data: response.events.map(getResolver('event')) });
48059
+ }
48060
+ else {
48061
+ const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
48062
+ const events = (_b = collection === null || collection === void 0 ? void 0 : collection.data) !== null && _b !== void 0 ? _b : [];
48063
+ pushToCache(this.cacheKey, Object.assign(Object.assign({}, collection), { data: [...new Set([...events, ...response.events.map(getResolver('event'))])] }));
48064
+ }
48065
+ }
48066
+ reactor(action) {
48067
+ return (event) => {
48068
+ var _a;
48069
+ const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
48070
+ if (!collection)
48071
+ return;
48072
+ if (action === EventActionsEnum.OnEventCreated) {
48073
+ const client = getActiveClient();
48074
+ if (client.userId !== event.userId)
48075
+ return;
48076
+ collection.data = [...new Set([event.eventId, ...collection.data])];
48077
+ }
48078
+ if (action === EventActionsEnum.OnEventDeleted) {
48079
+ collection.data = collection.data.filter(eventId => eventId !== event.eventId);
48080
+ }
48081
+ pushToCache(this.cacheKey, collection);
48082
+ this.notifyChange({ origin: "event" /* Amity.LiveDataOrigin.EVENT */, loading: false });
48083
+ };
48084
+ }
48085
+ subscribeRTE(createSubscriber) {
48086
+ return createSubscriber.map(subscriber => subscriber.fn(this.reactor(subscriber.action)));
48087
+ }
48088
+ }
48089
+
48090
+ class MyEventLiveCollectionController extends LiveCollectionController {
48091
+ constructor(query, callback) {
48092
+ const queryStreamId = hash(query);
48093
+ const cacheKey = ['event', 'collection', queryStreamId];
48094
+ const paginationController = new MyEventPaginationController(query);
48095
+ super(paginationController, queryStreamId, cacheKey, callback);
48096
+ this.query = query;
48097
+ this.queryStreamController = new MyEventQueryStreamController(this.query, this.cacheKey, this.notifyChange.bind(this), prepareEventPayload);
48098
+ this.callback = callback.bind(this);
48099
+ this.loadPage({ initial: true });
48100
+ }
48101
+ setup() {
48102
+ var _a;
48103
+ const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
48104
+ if (!collection)
48105
+ pushToCache(this.cacheKey, { data: [], params: {} });
48106
+ }
48107
+ async persistModel(queryPayload) {
48108
+ await this.queryStreamController.saveToMainDB(queryPayload);
48109
+ }
48110
+ persistQueryStream({ response, direction, refresh, }) {
48111
+ this.queryStreamController.appendToQueryStream(response, direction, refresh);
48112
+ }
48113
+ startSubscription() {
48114
+ return this.queryStreamController.subscribeRTE([
48115
+ { fn: onEventCreated, action: EventActionsEnum.OnEventCreated },
48116
+ { fn: onEventUpdated, action: EventActionsEnum.OnEventUpdated },
48117
+ { fn: onEventDeleted, action: EventActionsEnum.OnEventDeleted },
48118
+ { fn: onLocalEventCreated, action: EventActionsEnum.OnEventCreated },
48119
+ { fn: onLocalEventUpdated, action: EventActionsEnum.OnEventUpdated },
48120
+ { fn: onLocalEventDeleted, action: EventActionsEnum.OnEventDeleted },
48121
+ ]);
48122
+ }
48123
+ notifyChange({ origin, loading, error }) {
48124
+ var _a, _b;
48125
+ const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
48126
+ if (!collection)
48127
+ return;
48128
+ const data = ((_b = collection.data
48129
+ .map(eventId => pullFromCache(['event', 'get', eventId]))
48130
+ .filter(isNonNullable)
48131
+ .map(({ data }) => data)) !== null && _b !== void 0 ? _b : []).map(LinkedObject.event);
48132
+ if (!this.shouldNotify(data) && origin === "event" /* Amity.LiveDataOrigin.EVENT */)
48133
+ return;
48134
+ this.callback({
48135
+ data,
48136
+ error,
48137
+ loading,
48138
+ hasNextPage: !!this.paginationController.getNextToken(),
48139
+ onNextPage: () => this.loadPage({ direction: "next" /* Amity.LiveCollectionPageDirection.NEXT */ }),
48140
+ });
48141
+ }
48142
+ }
48143
+
48144
+ /**
48145
+ * Get my events
48146
+ *
48147
+ * @param params the query parameters
48148
+ * @param callback the callback to be called when the events are updated
48149
+ * @returns events
48150
+ *
48151
+ * @category Event Live Collection
48152
+ *
48153
+ */
48154
+ const getMyEvents = (params, callback, config) => {
48155
+ const { log, cache } = getActiveClient();
48156
+ if (!cache)
48157
+ console.log(ENABLE_CACHE_MESSAGE);
48158
+ const timestamp = Date.now();
48159
+ log(`getMyEvents: (tmpid: ${timestamp}) > listen`);
48160
+ const myEventLiveCollection = new MyEventLiveCollectionController(params, callback);
48161
+ const disposers = myEventLiveCollection.startSubscription();
48162
+ const cacheKey = myEventLiveCollection.getCacheKey();
48163
+ disposers.push(() => dropFromCache(cacheKey));
48164
+ return () => {
48165
+ log(`getMyEvents (tmpid: ${timestamp}) > dispose`);
48166
+ disposers.forEach(fn => fn());
48167
+ };
48168
+ };
48169
+
48170
+ var index = /*#__PURE__*/Object.freeze({
48171
+ __proto__: null,
48172
+ createEvent: createEvent,
48173
+ updateEvent: updateEvent,
48174
+ deleteEvent: deleteEvent,
48175
+ onEventCreated: onEventCreated,
48176
+ onEventUpdated: onEventUpdated,
48177
+ onEventDeleted: onEventDeleted,
48178
+ onLocalEventCreated: onLocalEventCreated,
48179
+ onLocalEventUpdated: onLocalEventUpdated,
48180
+ onLocalEventDeleted: onLocalEventDeleted,
48181
+ getEvent: getEvent,
48182
+ getEvents: getEvents,
48183
+ getMyEvents: getMyEvents
48184
+ });
48185
+
48186
+ export { API_REGIONS, index$4 as AdRepository, AmityEventOriginType, AmityEventResponseStatus, AmityEventStatus, AmityEventType, index$d as CategoryRepository, index$h as ChannelRepository, index$q as Client, index$c as CommentRepository, CommunityPostSettingMaps, CommunityPostSettings, index$e as CommunityRepository, ContentFeedType, ContentFlagReasonEnum, DefaultCommunityPostSetting, index as EventRepository, FeedDataTypeEnum, index$b as FeedRepository, FeedSortByEnum, FeedSourceEnum, FileAccessTypeEnum, index$n as FileRepository, FileType, GET_WATCHER_URLS, index$2 as InvitationRepository, InvitationSortByEnum, InvitationStatusEnum, InvitationTargetTypeEnum, InvitationTypeEnum, JoinRequestStatusEnum, JoinResultStatusEnum, index$1 as LiveReactionRepository, index$6 as LiveStreamPlayer, MembershipAcceptanceTypeEnum, MessageContentType, index$l as MessageRepository, index$7 as PollRepository, PostContentType, index$a as PostRepository, PostStructureType, index$m as ReactionRepository, index$8 as RoomRepository, index$5 as StoryRepository, index$9 as StreamRepository, index$k as SubChannelRepository, SubscriptionLevels, index$o 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, getRoomStreamerTopic, getRoomWatcherTopic, 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 };