@amityco/ts-sdk 7.11.1-38ad45e1.0 → 7.11.1-614107f7.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.
- package/dist/@types/core/transport.d.ts +1 -1
- package/dist/@types/core/transport.d.ts.map +1 -1
- package/dist/@types/domains/community.d.ts +8 -1
- package/dist/@types/domains/community.d.ts.map +1 -1
- package/dist/@types/domains/event.d.ts +9 -0
- package/dist/@types/domains/event.d.ts.map +1 -1
- package/dist/@types/domains/partials.d.ts +2 -2
- package/dist/@types/domains/partials.d.ts.map +1 -1
- package/dist/core/model/idResolvers.d.ts.map +1 -1
- package/dist/core/model/index.d.ts.map +1 -1
- package/dist/eventRepository/api/deleteEvent.d.ts +0 -1
- package/dist/eventRepository/api/deleteEvent.d.ts.map +1 -1
- package/dist/eventRepository/events/enums.d.ts +6 -0
- package/dist/eventRepository/events/enums.d.ts.map +1 -0
- package/dist/eventRepository/observers/getEvents/LiveCollectionController.d.ts +13 -0
- package/dist/eventRepository/observers/getEvents/LiveCollectionController.d.ts.map +1 -0
- package/dist/eventRepository/observers/getEvents/PaginationController.d.ts +5 -0
- package/dist/eventRepository/observers/getEvents/PaginationController.d.ts.map +1 -0
- package/dist/eventRepository/observers/getEvents/QueryStreamController.d.ts +15 -0
- package/dist/eventRepository/observers/getEvents/QueryStreamController.d.ts.map +1 -0
- package/dist/eventRepository/observers/getEvents.d.ts +12 -0
- package/dist/eventRepository/observers/getEvents.d.ts.map +1 -0
- package/dist/eventRepository/observers/index.d.ts +1 -0
- package/dist/eventRepository/observers/index.d.ts.map +1 -1
- package/dist/index.cjs.js +151 -6
- package/dist/index.esm.js +151 -6
- package/dist/index.umd.js +3 -3
- package/dist/messagePreview/utils/getChannelMessagePreviewWithUser.d.ts +1 -1
- package/dist/utils/linkedObject/eventLinkObject.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.esm.js
CHANGED
|
@@ -643,6 +643,7 @@ const idResolvers = {
|
|
|
643
643
|
notificationTraySeen: ({ userId }) => userId,
|
|
644
644
|
invitation: ({ _id }) => _id,
|
|
645
645
|
joinRequest: ({ joinRequestId }) => joinRequestId,
|
|
646
|
+
event: ({ eventId }) => eventId,
|
|
646
647
|
};
|
|
647
648
|
/**
|
|
648
649
|
* Retrieve the id resolver matching a domain name
|
|
@@ -698,6 +699,8 @@ const PAYLOAD2MODEL = {
|
|
|
698
699
|
notificationTrayItems: 'notificationTrayItem',
|
|
699
700
|
invitations: 'invitation',
|
|
700
701
|
joinRequests: 'joinRequest',
|
|
702
|
+
events: 'event',
|
|
703
|
+
discussionCommunities: 'community',
|
|
701
704
|
};
|
|
702
705
|
/** hidden */
|
|
703
706
|
const isOutdated = (prevData, nextData) => {
|
|
@@ -29776,9 +29779,13 @@ const eventLinkedObject = (event) => {
|
|
|
29776
29779
|
return userLinkedObject(cacheData.data);
|
|
29777
29780
|
},
|
|
29778
29781
|
get discussionCommunity() {
|
|
29779
|
-
if (!event.
|
|
29782
|
+
if (!event.discussionCommunityId)
|
|
29780
29783
|
return;
|
|
29781
|
-
const cacheData = pullFromCache([
|
|
29784
|
+
const cacheData = pullFromCache([
|
|
29785
|
+
'community',
|
|
29786
|
+
'get',
|
|
29787
|
+
event.discussionCommunityId,
|
|
29788
|
+
]);
|
|
29782
29789
|
if (!(cacheData === null || cacheData === void 0 ? void 0 : cacheData.data))
|
|
29783
29790
|
return;
|
|
29784
29791
|
return communityLinkedObject(cacheData.data);
|
|
@@ -46590,7 +46597,6 @@ getEvent$1.locally = (eventId) => {
|
|
|
46590
46597
|
* Deletes a {@link Amity.Event}
|
|
46591
46598
|
*
|
|
46592
46599
|
* @param eventId The {@link Amity.Event} ID to delete
|
|
46593
|
-
* @return A success boolean if the {@link Amity.Event} was deleted
|
|
46594
46600
|
*
|
|
46595
46601
|
* @category Event API
|
|
46596
46602
|
* @async
|
|
@@ -46599,8 +46605,8 @@ const deleteEvent = async (eventId) => {
|
|
|
46599
46605
|
const client = getActiveClient();
|
|
46600
46606
|
client.log('event/deleteEvent', eventId);
|
|
46601
46607
|
const event = await getEvent$1(eventId);
|
|
46602
|
-
|
|
46603
|
-
const deletedEvent = Object.assign(Object.assign({}, event.data), { isDeleted:
|
|
46608
|
+
await client.http.delete(`/api/v3/events/${eventId}`);
|
|
46609
|
+
const deletedEvent = Object.assign(Object.assign({}, event.data), { isDeleted: true });
|
|
46604
46610
|
upsertInCache(['event', 'get', eventId], deletedEvent);
|
|
46605
46611
|
fireEvent('event.deleted', {
|
|
46606
46612
|
users: [],
|
|
@@ -46693,6 +46699,144 @@ const getEvent = (eventId, callback) => {
|
|
|
46693
46699
|
};
|
|
46694
46700
|
/* end_public_function */
|
|
46695
46701
|
|
|
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
|
+
|
|
46696
46840
|
var index = /*#__PURE__*/Object.freeze({
|
|
46697
46841
|
__proto__: null,
|
|
46698
46842
|
createEvent: createEvent,
|
|
@@ -46701,7 +46845,8 @@ var index = /*#__PURE__*/Object.freeze({
|
|
|
46701
46845
|
onEventCreated: onEventCreated,
|
|
46702
46846
|
onEventUpdated: onEventUpdated,
|
|
46703
46847
|
onEventDeleted: onEventDeleted,
|
|
46704
|
-
getEvent: getEvent
|
|
46848
|
+
getEvent: getEvent,
|
|
46849
|
+
getEvents: getEvents
|
|
46705
46850
|
});
|
|
46706
46851
|
|
|
46707
46852
|
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 };
|