@amityco/ts-sdk 7.11.1-10e0f4d8.0 → 7.11.1-1d608419.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 (32) hide show
  1. package/dist/@types/core/transport.d.ts +0 -3
  2. package/dist/@types/core/transport.d.ts.map +1 -1
  3. package/dist/@types/domains/community.d.ts +1 -8
  4. package/dist/@types/domains/community.d.ts.map +1 -1
  5. package/dist/@types/domains/event.d.ts +0 -9
  6. package/dist/@types/domains/event.d.ts.map +1 -1
  7. package/dist/@types/domains/partials.d.ts +2 -2
  8. package/dist/@types/domains/partials.d.ts.map +1 -1
  9. package/dist/core/model/idResolvers.d.ts.map +1 -1
  10. package/dist/core/model/index.d.ts.map +1 -1
  11. package/dist/eventRepository/api/index.d.ts +0 -1
  12. package/dist/eventRepository/api/index.d.ts.map +1 -1
  13. package/dist/eventRepository/observers/index.d.ts +0 -1
  14. package/dist/eventRepository/observers/index.d.ts.map +1 -1
  15. package/dist/index.cjs.js +54 -235
  16. package/dist/index.esm.js +54 -235
  17. package/dist/index.umd.js +3 -3
  18. package/dist/messagePreview/utils/getChannelMessagePreviewWithUser.d.ts +1 -1
  19. package/dist/utils/linkedObject/eventLinkObject.d.ts.map +1 -1
  20. package/package.json +1 -1
  21. package/dist/eventRepository/api/deleteEvent.d.ts +0 -15
  22. package/dist/eventRepository/api/deleteEvent.d.ts.map +0 -1
  23. package/dist/eventRepository/events/enums.d.ts +0 -6
  24. package/dist/eventRepository/events/enums.d.ts.map +0 -1
  25. package/dist/eventRepository/observers/getEvents/LiveCollectionController.d.ts +0 -13
  26. package/dist/eventRepository/observers/getEvents/LiveCollectionController.d.ts.map +0 -1
  27. package/dist/eventRepository/observers/getEvents/PaginationController.d.ts +0 -5
  28. package/dist/eventRepository/observers/getEvents/PaginationController.d.ts.map +0 -1
  29. package/dist/eventRepository/observers/getEvents/QueryStreamController.d.ts +0 -15
  30. package/dist/eventRepository/observers/getEvents/QueryStreamController.d.ts.map +0 -1
  31. package/dist/eventRepository/observers/getEvents.d.ts +0 -12
  32. package/dist/eventRepository/observers/getEvents.d.ts.map +0 -1
package/dist/index.esm.js CHANGED
@@ -643,7 +643,6 @@ const idResolvers = {
643
643
  notificationTraySeen: ({ userId }) => userId,
644
644
  invitation: ({ _id }) => _id,
645
645
  joinRequest: ({ joinRequestId }) => joinRequestId,
646
- event: ({ eventId }) => eventId,
647
646
  };
648
647
  /**
649
648
  * Retrieve the id resolver matching a domain name
@@ -699,8 +698,6 @@ const PAYLOAD2MODEL = {
699
698
  notificationTrayItems: 'notificationTrayItem',
700
699
  invitations: 'invitation',
701
700
  joinRequests: 'joinRequest',
702
- events: 'event',
703
- discussionCommunities: 'community',
704
701
  };
705
702
  /** hidden */
706
703
  const isOutdated = (prevData, nextData) => {
@@ -29779,13 +29776,9 @@ const eventLinkedObject = (event) => {
29779
29776
  return userLinkedObject(cacheData.data);
29780
29777
  },
29781
29778
  get discussionCommunity() {
29782
- if (!event.discussionCommunityId)
29779
+ if (!event.communityId)
29783
29780
  return;
29784
- const cacheData = pullFromCache([
29785
- 'community',
29786
- 'get',
29787
- event.discussionCommunityId,
29788
- ]);
29781
+ const cacheData = pullFromCache(['community', 'get', event.communityId]);
29789
29782
  if (!(cacheData === null || cacheData === void 0 ? void 0 : cacheData.data))
29790
29783
  return;
29791
29784
  return communityLinkedObject(cacheData.data);
@@ -46527,6 +46520,57 @@ const updateEvent = async (eventId, bundle) => {
46527
46520
  };
46528
46521
  /* end_public_function */
46529
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
+
46530
46574
  /* begin_public_function
46531
46575
  id: event.get
46532
46576
  */
@@ -46585,91 +46629,6 @@ getEvent$1.locally = (eventId) => {
46585
46629
  };
46586
46630
  };
46587
46631
 
46588
- /* begin_public_function
46589
- id: event.delete
46590
- */
46591
- /**
46592
- * ```js
46593
- * import { EventRepository } from '@amityco/ts-sdk'
46594
- * const { success } = await EventRepository.deleteEvent(eventId)
46595
- * ```
46596
- *
46597
- * Deletes a {@link Amity.Event}
46598
- *
46599
- * @param eventId The {@link Amity.Event} ID to delete
46600
- *
46601
- * @category Event API
46602
- * @async
46603
- */
46604
- const deleteEvent = async (eventId) => {
46605
- const client = getActiveClient();
46606
- client.log('event/deleteEvent', eventId);
46607
- const event = await getEvent$1(eventId);
46608
- await client.http.delete(`/api/v3/events/${eventId}`);
46609
- const deletedEvent = Object.assign(Object.assign({}, event.data), { isDeleted: true });
46610
- upsertInCache(['event', 'get', eventId], deletedEvent);
46611
- fireEvent('event.deleted', {
46612
- users: [],
46613
- files: [],
46614
- communities: [],
46615
- videoStreamings: [],
46616
- events: [deletedEvent],
46617
- discussionCommunities: [],
46618
- });
46619
- };
46620
- /* end_public_function */
46621
-
46622
- /**
46623
- * ```js
46624
- * import { EventRepository } from '@amityco/ts-sdk'
46625
- * const dispose = EventRepository.onEventCreated(event => {
46626
- * // ...
46627
- * })
46628
- * ```
46629
- *
46630
- * Fired when a {@link Amity.Event} has been created
46631
- *
46632
- * @param callback The function to call when the event was fired
46633
- * @returns an {@link Amity.Unsubscriber} function to stop listening
46634
- *
46635
- * @category Event Events
46636
- */
46637
- const onEventCreated = (callback) => createEventEventSubscriber('event.created', callback);
46638
-
46639
- /**
46640
- * ```js
46641
- * import { EventRepository } from '@amityco/ts-sdk'
46642
- * const dispose = EventRepository.onEventUpdated(event => {
46643
- * // ...
46644
- * })
46645
- * ```
46646
- *
46647
- * Fired when a {@link Amity.Event} has been updated
46648
- *
46649
- * @param callback The function to call when the event was fired
46650
- * @returns an {@link Amity.Unsubscriber} function to stop listening
46651
- *
46652
- * @category Event Events
46653
- */
46654
- const onEventUpdated = (callback) => createEventEventSubscriber('event.updated', callback);
46655
-
46656
- /**
46657
- * ```js
46658
- * import { EventRepository } from '@amityco/ts-sdk'
46659
- * const dispose = EventRepository.onEventDeleted(event => {
46660
- * // ...
46661
- * })
46662
- * ```
46663
- *
46664
- * Fired when a {@link Amity.Event} has been deleted
46665
- *
46666
- * @param callback The function to call when the event was fired
46667
- * @returns an {@link Amity.Unsubscriber} function to stop listening
46668
- *
46669
- * @category Event Events
46670
- */
46671
- const onEventDeleted = (callback) => createEventEventSubscriber('event.deleted', callback);
46672
-
46673
46632
  /* begin_public_function
46674
46633
  id: event.get
46675
46634
  */
@@ -46699,154 +46658,14 @@ const getEvent = (eventId, callback) => {
46699
46658
  };
46700
46659
  /* end_public_function */
46701
46660
 
46702
- var EventActionsEnum;
46703
- (function (EventActionsEnum) {
46704
- EventActionsEnum["OnEventCreated"] = "onEventCreated";
46705
- EventActionsEnum["OnEventUpdated"] = "onEventUpdated";
46706
- EventActionsEnum["OnEventDeleted"] = "onEventDeleted";
46707
- })(EventActionsEnum || (EventActionsEnum = {}));
46708
-
46709
- class EventPaginationController extends PaginationController {
46710
- async getRequest(queryParams, token) {
46711
- const { limit = COLLECTION_DEFAULT_PAGINATION_LIMIT } = queryParams, params = __rest(queryParams, ["limit"]);
46712
- const options = token ? { token } : { limit };
46713
- const { data: response } = await this.http.get(`/api/v1/events`, { params: Object.assign(Object.assign({}, params), { options }) });
46714
- return response;
46715
- }
46716
- }
46717
-
46718
- class EventQueryStreamController extends QueryStreamController {
46719
- constructor(query, cacheKey, notifyChange, preparePayload) {
46720
- super(query, cacheKey);
46721
- this.notifyChange = notifyChange;
46722
- this.preparePayload = preparePayload;
46723
- }
46724
- async saveToMainDB(response) {
46725
- const processedPayload = this.preparePayload(response);
46726
- const client = getActiveClient();
46727
- const cachedAt = client.cache && Date.now();
46728
- if (client.cache)
46729
- ingestInCache(processedPayload, { cachedAt });
46730
- }
46731
- appendToQueryStream(response, direction, refresh = false) {
46732
- var _a, _b;
46733
- if (refresh) {
46734
- pushToCache(this.cacheKey, { data: response.events.map(getResolver('event')) });
46735
- }
46736
- else {
46737
- const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
46738
- const events = (_b = collection === null || collection === void 0 ? void 0 : collection.data) !== null && _b !== void 0 ? _b : [];
46739
- pushToCache(this.cacheKey, Object.assign(Object.assign({}, collection), { data: [...new Set([...events, ...response.events.map(getResolver('event'))])] }));
46740
- }
46741
- }
46742
- reactor(action) {
46743
- return (event) => {
46744
- var _a;
46745
- const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
46746
- if (!collection)
46747
- return;
46748
- if (action === EventActionsEnum.OnEventCreated) {
46749
- collection.data = [...new Set([event.eventId, ...collection.data])];
46750
- }
46751
- if (action === EventActionsEnum.OnEventDeleted) {
46752
- collection.data = collection.data.filter(eventId => eventId !== event.eventId);
46753
- }
46754
- pushToCache(this.cacheKey, collection);
46755
- this.notifyChange({ origin: "event" /* Amity.LiveDataOrigin.EVENT */, loading: false });
46756
- };
46757
- }
46758
- subscribeRTE(createSubscriber) {
46759
- return createSubscriber.map(subscriber => subscriber.fn(this.reactor(subscriber.action)));
46760
- }
46761
- }
46762
-
46763
- class EventLiveCollectionController extends LiveCollectionController {
46764
- constructor(query, callback) {
46765
- const queryStreamId = hash(query);
46766
- const cacheKey = ['event', 'collection', queryStreamId];
46767
- const paginationController = new EventPaginationController(query);
46768
- super(paginationController, queryStreamId, cacheKey, callback);
46769
- this.query = query;
46770
- this.queryStreamController = new EventQueryStreamController(this.query, this.cacheKey, this.notifyChange.bind(this), prepareEventPayload);
46771
- this.callback = callback.bind(this);
46772
- this.loadPage({ initial: true });
46773
- }
46774
- setup() {
46775
- var _a;
46776
- const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
46777
- if (!collection)
46778
- pushToCache(this.cacheKey, { data: [], params: {} });
46779
- }
46780
- async persistModel(queryPayload) {
46781
- await this.queryStreamController.saveToMainDB(queryPayload);
46782
- }
46783
- persistQueryStream({ response, direction, refresh, }) {
46784
- this.queryStreamController.appendToQueryStream(response, direction, refresh);
46785
- }
46786
- startSubscription() {
46787
- return this.queryStreamController.subscribeRTE([
46788
- { fn: onEventCreated, action: EventActionsEnum.OnEventCreated },
46789
- { fn: onEventUpdated, action: EventActionsEnum.OnEventUpdated },
46790
- { fn: onEventDeleted, action: EventActionsEnum.OnEventDeleted },
46791
- ]);
46792
- }
46793
- notifyChange({ origin, loading, error }) {
46794
- var _a, _b;
46795
- const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
46796
- if (!collection)
46797
- return;
46798
- const data = ((_b = collection.data
46799
- .map(eventId => pullFromCache(['event', 'get', eventId]))
46800
- .filter(isNonNullable)
46801
- .map(({ data }) => data)) !== null && _b !== void 0 ? _b : []).map(LinkedObject.event);
46802
- if (!this.shouldNotify(data) && origin === "event" /* Amity.LiveDataOrigin.EVENT */)
46803
- return;
46804
- this.callback({
46805
- data,
46806
- error,
46807
- loading,
46808
- hasNextPage: !!this.paginationController.getNextToken(),
46809
- onNextPage: () => this.loadPage({ direction: "next" /* Amity.LiveCollectionPageDirection.NEXT */ }),
46810
- });
46811
- }
46812
- }
46813
-
46814
- /**
46815
- * Get events
46816
- *
46817
- * @param params the query parameters
46818
- * @param callback the callback to be called when the events are updated
46819
- * @returns events
46820
- *
46821
- * @category Event Live Collection
46822
- *
46823
- */
46824
- const getEvents = (params, callback, config) => {
46825
- const { log, cache } = getActiveClient();
46826
- if (!cache)
46827
- console.log(ENABLE_CACHE_MESSAGE);
46828
- const timestamp = Date.now();
46829
- log(`getEvents: (tmpid: ${timestamp}) > listen`);
46830
- const eventLiveCollection = new EventLiveCollectionController(params, callback);
46831
- const disposers = eventLiveCollection.startSubscription();
46832
- const cacheKey = eventLiveCollection.getCacheKey();
46833
- disposers.push(() => dropFromCache(cacheKey));
46834
- return () => {
46835
- log(`getEvents (tmpid: ${timestamp}) > dispose`);
46836
- disposers.forEach(fn => fn());
46837
- };
46838
- };
46839
-
46840
46661
  var index = /*#__PURE__*/Object.freeze({
46841
46662
  __proto__: null,
46842
46663
  createEvent: createEvent,
46843
46664
  updateEvent: updateEvent,
46844
- deleteEvent: deleteEvent,
46845
46665
  onEventCreated: onEventCreated,
46846
46666
  onEventUpdated: onEventUpdated,
46847
46667
  onEventDeleted: onEventDeleted,
46848
- getEvent: getEvent,
46849
- getEvents: getEvents
46668
+ getEvent: getEvent
46850
46669
  });
46851
46670
 
46852
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 };