@amityco/ts-sdk 7.11.1-c23e18e.0 → 7.11.1-cef76519.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 (52) 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 +2 -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/domains/event.d.ts +57 -0
  8. package/dist/@types/domains/event.d.ts.map +1 -0
  9. package/dist/@types/index.d.ts +1 -0
  10. package/dist/@types/index.d.ts.map +1 -1
  11. package/dist/core/events.d.ts +3 -3
  12. package/dist/core/events.d.ts.map +1 -1
  13. package/dist/eventRepository/api/createEvent.d.ts +16 -0
  14. package/dist/eventRepository/api/createEvent.d.ts.map +1 -0
  15. package/dist/eventRepository/api/index.d.ts +3 -0
  16. package/dist/eventRepository/api/index.d.ts.map +1 -0
  17. package/dist/eventRepository/api/updateEvent.d.ts +17 -0
  18. package/dist/eventRepository/api/updateEvent.d.ts.map +1 -0
  19. package/dist/eventRepository/events/index.d.ts +4 -0
  20. package/dist/eventRepository/events/index.d.ts.map +1 -0
  21. package/dist/eventRepository/events/onEventCreated.d.ts +17 -0
  22. package/dist/eventRepository/events/onEventCreated.d.ts.map +1 -0
  23. package/dist/eventRepository/events/onEventDeleted.d.ts +17 -0
  24. package/dist/eventRepository/events/onEventDeleted.d.ts.map +1 -0
  25. package/dist/eventRepository/events/onEventUpdated.d.ts +17 -0
  26. package/dist/eventRepository/events/onEventUpdated.d.ts.map +1 -0
  27. package/dist/eventRepository/index.d.ts +4 -0
  28. package/dist/eventRepository/index.d.ts.map +1 -0
  29. package/dist/eventRepository/internalApi/getEvent.d.ts +32 -0
  30. package/dist/eventRepository/internalApi/getEvent.d.ts.map +1 -0
  31. package/dist/eventRepository/internalApi/index.d.ts +2 -0
  32. package/dist/eventRepository/internalApi/index.d.ts.map +1 -0
  33. package/dist/eventRepository/observers/getEvent.d.ts +21 -0
  34. package/dist/eventRepository/observers/getEvent.d.ts.map +1 -0
  35. package/dist/eventRepository/observers/index.d.ts +2 -0
  36. package/dist/eventRepository/observers/index.d.ts.map +1 -0
  37. package/dist/eventRepository/utils/createEventEventSubscriber.d.ts +2 -0
  38. package/dist/eventRepository/utils/createEventEventSubscriber.d.ts.map +1 -0
  39. package/dist/eventRepository/utils/index.d.ts +3 -0
  40. package/dist/eventRepository/utils/index.d.ts.map +1 -0
  41. package/dist/eventRepository/utils/prepareEventPayload.d.ts +2 -0
  42. package/dist/eventRepository/utils/prepareEventPayload.d.ts.map +1 -0
  43. package/dist/index.cjs.js +334 -50
  44. package/dist/index.d.ts +1 -0
  45. package/dist/index.d.ts.map +1 -1
  46. package/dist/index.esm.js +314 -31
  47. package/dist/index.umd.js +3 -3
  48. package/dist/utils/linkedObject/eventLinkObject.d.ts +2 -0
  49. package/dist/utils/linkedObject/eventLinkObject.d.ts.map +1 -0
  50. package/dist/utils/linkedObject/index.d.ts +1 -0
  51. package/dist/utils/linkedObject/index.d.ts.map +1 -1
  52. package/package.json +1 -1
package/dist/index.esm.js CHANGED
@@ -177,6 +177,24 @@ 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
+
180
198
  function getVersion() {
181
199
  try {
182
200
  // the string ''v7.11.0-esm'' should be replaced by actual value by @rollup/plugin-replace
@@ -26552,7 +26570,7 @@ const getUserUnread = (callback) => {
26552
26570
  };
26553
26571
  };
26554
26572
 
26555
- var index$o = /*#__PURE__*/Object.freeze({
26573
+ var index$p = /*#__PURE__*/Object.freeze({
26556
26574
  __proto__: null,
26557
26575
  getActiveClient: getActiveClient,
26558
26576
  getActiveUser: getActiveUser,
@@ -27771,7 +27789,7 @@ const getMyFollowInfo = (callback) => {
27771
27789
  };
27772
27790
  /* end_public_function */
27773
27791
 
27774
- var index$n = /*#__PURE__*/Object.freeze({
27792
+ var index$o = /*#__PURE__*/Object.freeze({
27775
27793
  __proto__: null,
27776
27794
  blockUser: blockUser,
27777
27795
  unBlockUser: unBlockUser,
@@ -29750,6 +29768,31 @@ const communityLinkedObject = (community) => {
29750
29768
  } });
29751
29769
  };
29752
29770
 
29771
+ const eventLinkedObject = (event) => {
29772
+ return Object.assign(Object.assign({}, event), { get creator() {
29773
+ const cacheData = pullFromCache(['user', 'get', event.userId]);
29774
+ if (!(cacheData === null || cacheData === void 0 ? void 0 : cacheData.data))
29775
+ return;
29776
+ return userLinkedObject(cacheData.data);
29777
+ },
29778
+ get discussionCommunity() {
29779
+ if (!event.communityId)
29780
+ return;
29781
+ const cacheData = pullFromCache(['community', 'get', event.communityId]);
29782
+ if (!(cacheData === null || cacheData === void 0 ? void 0 : cacheData.data))
29783
+ return;
29784
+ return communityLinkedObject(cacheData.data);
29785
+ },
29786
+ get liveStream() {
29787
+ if (!event.livestreamId)
29788
+ return;
29789
+ const cacheData = pullFromCache(['stream', 'get', event.livestreamId]);
29790
+ if (!(cacheData === null || cacheData === void 0 ? void 0 : cacheData.data))
29791
+ return;
29792
+ return cacheData.data;
29793
+ } });
29794
+ };
29795
+
29753
29796
  const LinkedObject = {
29754
29797
  ad: adLinkedObject,
29755
29798
  comment: commentLinkedObject,
@@ -29768,6 +29811,7 @@ const LinkedObject = {
29768
29811
  invitation: invitationLinkedObject,
29769
29812
  joinRequest: joinRequestLinkedObject,
29770
29813
  channelMember: channelMemberLinkedObject,
29814
+ event: eventLinkedObject,
29771
29815
  };
29772
29816
 
29773
29817
  /* begin_public_function
@@ -30758,9 +30802,9 @@ var AmityUserSearchMatchType;
30758
30802
  AmityUserSearchMatchType["PARTIAL"] = "partial";
30759
30803
  })(AmityUserSearchMatchType || (AmityUserSearchMatchType = {}));
30760
30804
 
30761
- var index$m = /*#__PURE__*/Object.freeze({
30805
+ var index$n = /*#__PURE__*/Object.freeze({
30762
30806
  __proto__: null,
30763
- Relationship: index$n,
30807
+ Relationship: index$o,
30764
30808
  getUserByIds: getUserByIds,
30765
30809
  updateUser: updateUser,
30766
30810
  flagUser: flagUser,
@@ -31163,7 +31207,7 @@ const uploadAudio = async (formData, onProgress) => {
31163
31207
  };
31164
31208
  /* end_public_function */
31165
31209
 
31166
- var index$l = /*#__PURE__*/Object.freeze({
31210
+ var index$m = /*#__PURE__*/Object.freeze({
31167
31211
  __proto__: null,
31168
31212
  getFile: getFile,
31169
31213
  uploadFile: uploadFile,
@@ -32975,7 +33019,7 @@ const getReactions$1 = (params, callback, config) => {
32975
33019
  };
32976
33020
  /* end_public_function */
32977
33021
 
32978
- var index$k = /*#__PURE__*/Object.freeze({
33022
+ var index$l = /*#__PURE__*/Object.freeze({
32979
33023
  __proto__: null,
32980
33024
  addReaction: addReaction,
32981
33025
  removeReaction: removeReaction,
@@ -34747,7 +34791,7 @@ const getMessages = (params, callback, config) => {
34747
34791
  };
34748
34792
  /* end_public_function */
34749
34793
 
34750
- var index$j = /*#__PURE__*/Object.freeze({
34794
+ var index$k = /*#__PURE__*/Object.freeze({
34751
34795
  __proto__: null,
34752
34796
  createMessage: createMessage,
34753
34797
  updateMessage: updateMessage,
@@ -35273,7 +35317,7 @@ const stopMessageReceiptSync = (subChannelId) => {
35273
35317
  };
35274
35318
  /* end_public_function */
35275
35319
 
35276
- var index$i = /*#__PURE__*/Object.freeze({
35320
+ var index$j = /*#__PURE__*/Object.freeze({
35277
35321
  __proto__: null,
35278
35322
  getSubChannelByIds: getSubChannels$1,
35279
35323
  createSubChannel: createSubChannel,
@@ -36600,7 +36644,7 @@ const searchMembers$1 = (params, callback, config) => {
36600
36644
  };
36601
36645
  /* end_public_function */
36602
36646
 
36603
- var index$h = /*#__PURE__*/Object.freeze({
36647
+ var index$i = /*#__PURE__*/Object.freeze({
36604
36648
  __proto__: null,
36605
36649
  addMembers: addMembers$1,
36606
36650
  removeMembers: removeMembers$1,
@@ -36803,7 +36847,7 @@ const unmuteMembers = async (channelId, userIds) => {
36803
36847
  };
36804
36848
  /* end_public_function */
36805
36849
 
36806
- var index$g = /*#__PURE__*/Object.freeze({
36850
+ var index$h = /*#__PURE__*/Object.freeze({
36807
36851
  __proto__: null,
36808
36852
  addRole: addRole,
36809
36853
  removeRole: removeRole,
@@ -36813,10 +36857,10 @@ var index$g = /*#__PURE__*/Object.freeze({
36813
36857
  unmuteMembers: unmuteMembers
36814
36858
  });
36815
36859
 
36816
- var index$f = /*#__PURE__*/Object.freeze({
36860
+ var index$g = /*#__PURE__*/Object.freeze({
36817
36861
  __proto__: null,
36818
- Membership: index$h,
36819
- Moderation: index$g,
36862
+ Membership: index$i,
36863
+ Moderation: index$h,
36820
36864
  getChannelByIds: getChannelByIds$1,
36821
36865
  createChannel: createChannel,
36822
36866
  updateChannel: updateChannel,
@@ -38219,7 +38263,7 @@ const searchMembers = (params, callback, config) => {
38219
38263
  };
38220
38264
  /* end_public_function */
38221
38265
 
38222
- var index$e = /*#__PURE__*/Object.freeze({
38266
+ var index$f = /*#__PURE__*/Object.freeze({
38223
38267
  __proto__: null,
38224
38268
  addMembers: addMembers,
38225
38269
  removeMembers: removeMembers,
@@ -39470,7 +39514,7 @@ const unbanMembers = async (communityId, userIds) => {
39470
39514
  };
39471
39515
  /* end_public_function */
39472
39516
 
39473
- var index$d = /*#__PURE__*/Object.freeze({
39517
+ var index$e = /*#__PURE__*/Object.freeze({
39474
39518
  __proto__: null,
39475
39519
  addRoles: addRoles,
39476
39520
  removeRoles: removeRoles,
@@ -39478,10 +39522,10 @@ var index$d = /*#__PURE__*/Object.freeze({
39478
39522
  unbanMembers: unbanMembers
39479
39523
  });
39480
39524
 
39481
- var index$c = /*#__PURE__*/Object.freeze({
39525
+ var index$d = /*#__PURE__*/Object.freeze({
39482
39526
  __proto__: null,
39483
- Moderation: index$d,
39484
- Membership: index$e,
39527
+ Moderation: index$e,
39528
+ Membership: index$f,
39485
39529
  getCommunityByIds: getCommunities$1,
39486
39530
  createCommunity: createCommunity,
39487
39531
  updateCommunity: updateCommunity,
@@ -39715,7 +39759,7 @@ const getCategories = (params, callback, config) => {
39715
39759
  };
39716
39760
  /* end_public_function */
39717
39761
 
39718
- var index$b = /*#__PURE__*/Object.freeze({
39762
+ var index$c = /*#__PURE__*/Object.freeze({
39719
39763
  __proto__: null,
39720
39764
  getCategory: getCategory,
39721
39765
  getCategories: getCategories
@@ -40774,7 +40818,7 @@ const getComments = (params, callback, config) => {
40774
40818
  };
40775
40819
  /* end_public_function */
40776
40820
 
40777
- var index$a = /*#__PURE__*/Object.freeze({
40821
+ var index$b = /*#__PURE__*/Object.freeze({
40778
40822
  __proto__: null,
40779
40823
  getCommentByIds: getCommentByIds,
40780
40824
  createComment: createComment,
@@ -41445,7 +41489,7 @@ const getUserFeed = (params, callback, config) => {
41445
41489
  };
41446
41490
  /* end_public_function */
41447
41491
 
41448
- var index$9 = /*#__PURE__*/Object.freeze({
41492
+ var index$a = /*#__PURE__*/Object.freeze({
41449
41493
  __proto__: null,
41450
41494
  queryGlobalFeed: queryGlobalFeed,
41451
41495
  getCustomRankingGlobalFeed: getCustomRankingGlobalFeed,
@@ -43126,7 +43170,7 @@ const searchPostsByHashtag = (params, callback, config) => {
43126
43170
  };
43127
43171
  /* end_public_function */
43128
43172
 
43129
- var index$8 = /*#__PURE__*/Object.freeze({
43173
+ var index$9 = /*#__PURE__*/Object.freeze({
43130
43174
  __proto__: null,
43131
43175
  getPostByIds: getPostByIds,
43132
43176
  createPost: createPost,
@@ -43734,7 +43778,7 @@ const getStreams = (params, callback, config) => {
43734
43778
  };
43735
43779
  };
43736
43780
 
43737
- var index$7 = /*#__PURE__*/Object.freeze({
43781
+ var index$8 = /*#__PURE__*/Object.freeze({
43738
43782
  __proto__: null,
43739
43783
  createStream: createStream,
43740
43784
  updateStream: updateStream,
@@ -44052,7 +44096,7 @@ const getPoll = (pollId, callback) => {
44052
44096
  };
44053
44097
  /* end_public_function */
44054
44098
 
44055
- var index$6 = /*#__PURE__*/Object.freeze({
44099
+ var index$7 = /*#__PURE__*/Object.freeze({
44056
44100
  __proto__: null,
44057
44101
  createPoll: createPoll,
44058
44102
  closePoll: closePoll,
@@ -44435,7 +44479,7 @@ const getPlayer = async (parameters) => {
44435
44479
  return video;
44436
44480
  };
44437
44481
 
44438
- var index$5 = /*#__PURE__*/Object.freeze({
44482
+ var index$6 = /*#__PURE__*/Object.freeze({
44439
44483
  __proto__: null,
44440
44484
  getPlayer: getPlayer
44441
44485
  });
@@ -45608,7 +45652,7 @@ const getGlobalStoryTargets = (params, callback, config) => {
45608
45652
  };
45609
45653
  };
45610
45654
 
45611
- var index$4 = /*#__PURE__*/Object.freeze({
45655
+ var index$5 = /*#__PURE__*/Object.freeze({
45612
45656
  __proto__: null,
45613
45657
  createImageStory: createImageStory,
45614
45658
  createVideoStory: createVideoStory,
@@ -45645,7 +45689,7 @@ const getNetworkAds = async () => {
45645
45689
  };
45646
45690
  };
45647
45691
 
45648
- var index$3 = /*#__PURE__*/Object.freeze({
45692
+ var index$4 = /*#__PURE__*/Object.freeze({
45649
45693
  __proto__: null,
45650
45694
  getNetworkAds: getNetworkAds
45651
45695
  });
@@ -46036,7 +46080,7 @@ const markTraySeen = async (lastSeenAt) => {
46036
46080
  };
46037
46081
  /* end_public_function */
46038
46082
 
46039
- var index$2 = /*#__PURE__*/Object.freeze({
46083
+ var index$3 = /*#__PURE__*/Object.freeze({
46040
46084
  __proto__: null,
46041
46085
  getNotificationTraySeen: getNotificationTraySeen,
46042
46086
  getNotificationTrayItems: getNotificationTrayItems,
@@ -46237,7 +46281,7 @@ const getMyCommunityInvitations = (params, callback, config) => {
46237
46281
  };
46238
46282
  };
46239
46283
 
46240
- var index$1 = /*#__PURE__*/Object.freeze({
46284
+ var index$2 = /*#__PURE__*/Object.freeze({
46241
46285
  __proto__: null,
46242
46286
  onLocalInvitationCreated: onLocalInvitationCreated,
46243
46287
  onLocalInvitationUpdated: onLocalInvitationUpdated,
@@ -46378,11 +46422,250 @@ const getReactions = (postId, callback) => {
46378
46422
  };
46379
46423
  };
46380
46424
 
46381
- var index = /*#__PURE__*/Object.freeze({
46425
+ var index$1 = /*#__PURE__*/Object.freeze({
46382
46426
  __proto__: null,
46383
46427
  createReaction: createReaction,
46384
46428
  onLiveReactionCreated: onLiveReactionCreated,
46385
46429
  getReactions: getReactions
46386
46430
  });
46387
46431
 
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 };
46432
+ const prepareEventPayload = (rawPayload) => {
46433
+ return Object.assign(Object.assign({}, rawPayload), { users: rawPayload.users.map(convertRawUserToInternalUser) });
46434
+ };
46435
+
46436
+ const createEventEventSubscriber = (event, callback) => {
46437
+ const client = getActiveClient();
46438
+ const filter = (payload) => {
46439
+ const unpackedPayload = prepareEventPayload(payload);
46440
+ if (!client.cache) {
46441
+ callback(unpackedPayload.events[0]);
46442
+ }
46443
+ else {
46444
+ ingestInCache(unpackedPayload);
46445
+ const event = pullFromCache([
46446
+ 'event',
46447
+ 'get',
46448
+ unpackedPayload.events[0].eventId,
46449
+ ]);
46450
+ callback(event.data);
46451
+ }
46452
+ };
46453
+ return createEventSubscriber(client, event, event, filter);
46454
+ };
46455
+
46456
+ /* begin_public_function
46457
+ id: event.create
46458
+ */
46459
+ /**
46460
+ * ```js
46461
+ * import { EventRepository } from '@amityco/ts-sdk'
46462
+ * const response = await EventRepository.createEvent(bundle)
46463
+ * ```
46464
+ *
46465
+ * Creates an {@link Amity.Event}
46466
+ *
46467
+ * @param bundle The data necessary to create a new {@link Amity.Event}
46468
+ * @returns The newly created {@link Amity.Event}
46469
+ *
46470
+ * @category Event API
46471
+ * @async
46472
+ */
46473
+ const createEvent = async (bundle) => {
46474
+ const client = getActiveClient();
46475
+ client.log('event/createEvent', bundle);
46476
+ const { data: payload } = await client.http.post('/api/v1/events', bundle);
46477
+ fireEvent('event.created', payload);
46478
+ const preparedPayload = prepareEventPayload(payload);
46479
+ const cachedAt = client.cache && Date.now();
46480
+ if (client.cache)
46481
+ ingestInCache(preparedPayload, { cachedAt });
46482
+ return {
46483
+ data: eventLinkedObject(preparedPayload.events[0]),
46484
+ cachedAt,
46485
+ };
46486
+ };
46487
+ /* end_public_function */
46488
+
46489
+ /* begin_public_function
46490
+ id: event.update
46491
+ */
46492
+ /**
46493
+ * ```js
46494
+ * import { EventRepository } from '@amityco/ts-sdk'
46495
+ * const response = await EventRepository.updateEvent(eventId, bundle)
46496
+ * ```
46497
+ *
46498
+ * Updates an {@link Amity.Event}
46499
+ *
46500
+ * @param eventId The ID of the {@link Amity.Event} to edit
46501
+ * @param bundle The data necessary to update an existing {@link Amity.Event}
46502
+ * @returns the updated {@link Amity.Event}
46503
+ *
46504
+ * @category Event API
46505
+ * @async
46506
+ */
46507
+ const updateEvent = async (eventId, bundle) => {
46508
+ const client = getActiveClient();
46509
+ client.log('event/updateEvent', eventId, bundle);
46510
+ const { data: payload } = await client.http.put(`/api/v1/events/${eventId}`, bundle);
46511
+ fireEvent('event.updated', payload);
46512
+ const preparedPayload = prepareEventPayload(payload);
46513
+ const cachedAt = client.cache && Date.now();
46514
+ if (client.cache)
46515
+ ingestInCache(preparedPayload, { cachedAt });
46516
+ return {
46517
+ data: eventLinkedObject(preparedPayload.events.find(event => event.eventId === eventId)),
46518
+ cachedAt,
46519
+ };
46520
+ };
46521
+ /* end_public_function */
46522
+
46523
+ /**
46524
+ * ```js
46525
+ * import { EventRepository } from '@amityco/ts-sdk'
46526
+ * const dispose = EventRepository.onEventCreated(event => {
46527
+ * // ...
46528
+ * })
46529
+ * ```
46530
+ *
46531
+ * Fired when a {@link Amity.Event} has been created
46532
+ *
46533
+ * @param callback The function to call when the event was fired
46534
+ * @returns an {@link Amity.Unsubscriber} function to stop listening
46535
+ *
46536
+ * @category Event Events
46537
+ */
46538
+ const onEventCreated = (callback) => createEventEventSubscriber('event.created', callback);
46539
+
46540
+ /**
46541
+ * ```js
46542
+ * import { EventRepository } from '@amityco/ts-sdk'
46543
+ * const dispose = EventRepository.onEventUpdated(event => {
46544
+ * // ...
46545
+ * })
46546
+ * ```
46547
+ *
46548
+ * Fired when a {@link Amity.Event} has been updated
46549
+ *
46550
+ * @param callback The function to call when the event was fired
46551
+ * @returns an {@link Amity.Unsubscriber} function to stop listening
46552
+ *
46553
+ * @category Event Events
46554
+ */
46555
+ const onEventUpdated = (callback) => createEventEventSubscriber('event.updated', callback);
46556
+
46557
+ /**
46558
+ * ```js
46559
+ * import { EventRepository } from '@amityco/ts-sdk'
46560
+ * const dispose = EventRepository.onEventDeleted(event => {
46561
+ * // ...
46562
+ * })
46563
+ * ```
46564
+ *
46565
+ * Fired when a {@link Amity.Event} has been deleted
46566
+ *
46567
+ * @param callback The function to call when the event was fired
46568
+ * @returns an {@link Amity.Unsubscriber} function to stop listening
46569
+ *
46570
+ * @category Event Events
46571
+ */
46572
+ const onEventDeleted = (callback) => createEventEventSubscriber('event.deleted', callback);
46573
+
46574
+ /* begin_public_function
46575
+ id: event.get
46576
+ */
46577
+ /**
46578
+ * ```js
46579
+ * import { EventRepository } from '@amityco/ts-sdk'
46580
+ * const event = await EventRepository.getEvent(eventId)
46581
+ * ```
46582
+ *
46583
+ * Fetches a {@link Amity.Event} object
46584
+ *
46585
+ * @param eventId the ID of the {@link Amity.Event} to fetch
46586
+ * @returns the associated {@link Amity.Event} object
46587
+ *
46588
+ * @category Event API
46589
+ * @async
46590
+ */
46591
+ const getEvent$1 = async (eventId) => {
46592
+ const client = getActiveClient();
46593
+ client.log('event/getEvent', eventId);
46594
+ const { data: payload } = await client.http.get(`/api/v3/events/${eventId}`);
46595
+ const data = prepareEventPayload(payload);
46596
+ const cachedAt = client.cache && Date.now();
46597
+ if (client.cache)
46598
+ ingestInCache(data, { cachedAt });
46599
+ return {
46600
+ data: data.events.find(event => event.eventId === eventId),
46601
+ cachedAt,
46602
+ };
46603
+ };
46604
+ /* end_public_function */
46605
+ /**
46606
+ * ```js
46607
+ * import { EventRepository } from '@amityco/ts-sdk'
46608
+ * const event = EventRepository.getEvent.locally(eventId)
46609
+ * ```
46610
+ *
46611
+ * Fetches a {@link Amity.Event} object in cache
46612
+ *
46613
+ * @param eventId the ID of the {@link Amity.Event} to fetch
46614
+ * @returns the associated {@link Amity.Event} object
46615
+ *
46616
+ * @category Event API
46617
+ */
46618
+ getEvent$1.locally = (eventId) => {
46619
+ const client = getActiveClient();
46620
+ client.log('event/getEvent.locally', eventId);
46621
+ if (!client.cache)
46622
+ return;
46623
+ const cache = pullFromCache(['event', 'get', eventId]);
46624
+ if (!cache)
46625
+ return;
46626
+ return {
46627
+ data: cache.data,
46628
+ cachedAt: cache.cachedAt,
46629
+ };
46630
+ };
46631
+
46632
+ /* begin_public_function
46633
+ id: event.get
46634
+ */
46635
+ /**
46636
+ * ```js
46637
+ * import { EventRepository } from '@amityco/ts-sdk';
46638
+ *
46639
+ * let event;
46640
+ *
46641
+ * const unsubscribe = EventRepository.getEvent(eventId, response => {
46642
+ * event = response.data;
46643
+ * });
46644
+ * ```
46645
+ *
46646
+ * Observe all mutation on a given {@link Amity.Event}
46647
+ *
46648
+ * @param eventId the ID of the event to observe
46649
+ * @param callback the function to call when new snapshot of event are available
46650
+ * @returns An {@link Amity.Unsubscriber} function to run when willing to stop observing the event
46651
+ *
46652
+ * @category Event Live Object
46653
+ */
46654
+ const getEvent = (eventId, callback) => {
46655
+ return liveObject(eventId, callback, 'eventId', getEvent$1, [onEventCreated, onEventUpdated, onEventDeleted], {
46656
+ callbackDataSelector: (data) => (data ? eventLinkedObject(data) : data),
46657
+ });
46658
+ };
46659
+ /* end_public_function */
46660
+
46661
+ var index = /*#__PURE__*/Object.freeze({
46662
+ __proto__: null,
46663
+ createEvent: createEvent,
46664
+ updateEvent: updateEvent,
46665
+ onEventCreated: onEventCreated,
46666
+ onEventUpdated: onEventUpdated,
46667
+ onEventDeleted: onEventDeleted,
46668
+ getEvent: getEvent
46669
+ });
46670
+
46671
+ export { API_REGIONS, index$4 as AdRepository, AmityEventOriginType, 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 };