@amityco/ts-sdk 7.11.0 → 7.11.1-0e55a3b4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/@types/core/events.d.ts +36 -2
- package/dist/@types/core/events.d.ts.map +1 -1
- package/dist/@types/core/model.d.ts +4 -0
- package/dist/@types/core/model.d.ts.map +1 -1
- package/dist/@types/core/payload.d.ts +17 -0
- package/dist/@types/core/payload.d.ts.map +1 -1
- package/dist/@types/core/permissions.d.ts +5 -1
- package/dist/@types/core/permissions.d.ts.map +1 -1
- package/dist/@types/core/transport.d.ts +3 -0
- package/dist/@types/core/transport.d.ts.map +1 -1
- package/dist/@types/domains/community.d.ts +11 -1
- package/dist/@types/domains/community.d.ts.map +1 -1
- package/dist/@types/domains/event.d.ts +89 -0
- package/dist/@types/domains/event.d.ts.map +1 -0
- package/dist/@types/domains/notification.d.ts +3 -1
- package/dist/@types/domains/notification.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/@types/index.d.ts +1 -0
- package/dist/@types/index.d.ts.map +1 -1
- package/dist/core/events.d.ts +3 -3
- package/dist/core/events.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/createEvent.d.ts +16 -0
- package/dist/eventRepository/api/createEvent.d.ts.map +1 -0
- package/dist/eventRepository/api/deleteEvent.d.ts +15 -0
- package/dist/eventRepository/api/deleteEvent.d.ts.map +1 -0
- package/dist/eventRepository/api/index.d.ts +4 -0
- package/dist/eventRepository/api/index.d.ts.map +1 -0
- package/dist/eventRepository/api/updateEvent.d.ts +17 -0
- package/dist/eventRepository/api/updateEvent.d.ts.map +1 -0
- package/dist/eventRepository/events/enums.d.ts +8 -0
- package/dist/eventRepository/events/enums.d.ts.map +1 -0
- package/dist/eventRepository/events/index.d.ts +11 -0
- package/dist/eventRepository/events/index.d.ts.map +1 -0
- package/dist/eventRepository/events/onEventCreated.d.ts +17 -0
- package/dist/eventRepository/events/onEventCreated.d.ts.map +1 -0
- package/dist/eventRepository/events/onEventDeleted.d.ts +17 -0
- package/dist/eventRepository/events/onEventDeleted.d.ts.map +1 -0
- package/dist/eventRepository/events/onEventUpdated.d.ts +17 -0
- package/dist/eventRepository/events/onEventUpdated.d.ts.map +1 -0
- package/dist/eventRepository/events/onLocalEventCreated.d.ts +17 -0
- package/dist/eventRepository/events/onLocalEventCreated.d.ts.map +1 -0
- package/dist/eventRepository/events/onLocalEventDeleted.d.ts +17 -0
- package/dist/eventRepository/events/onLocalEventDeleted.d.ts.map +1 -0
- package/dist/eventRepository/events/onLocalEventUpdated.d.ts +17 -0
- package/dist/eventRepository/events/onLocalEventUpdated.d.ts.map +1 -0
- package/dist/eventRepository/events/onLocalRSVPCreated.d.ts +17 -0
- package/dist/eventRepository/events/onLocalRSVPCreated.d.ts.map +1 -0
- package/dist/eventRepository/events/onLocalRSVPUpdated.d.ts +17 -0
- package/dist/eventRepository/events/onLocalRSVPUpdated.d.ts.map +1 -0
- package/dist/eventRepository/events/onRSVPCreated.d.ts +17 -0
- package/dist/eventRepository/events/onRSVPCreated.d.ts.map +1 -0
- package/dist/eventRepository/events/onRSVPUpdated.d.ts +17 -0
- package/dist/eventRepository/events/onRSVPUpdated.d.ts.map +1 -0
- package/dist/eventRepository/index.d.ts +4 -0
- package/dist/eventRepository/index.d.ts.map +1 -0
- package/dist/eventRepository/internalApi/createRSVP.d.ts +16 -0
- package/dist/eventRepository/internalApi/createRSVP.d.ts.map +1 -0
- package/dist/eventRepository/internalApi/getEvent.d.ts +32 -0
- package/dist/eventRepository/internalApi/getEvent.d.ts.map +1 -0
- package/dist/eventRepository/internalApi/getMyRSVP.d.ts +32 -0
- package/dist/eventRepository/internalApi/getMyRSVP.d.ts.map +1 -0
- package/dist/eventRepository/internalApi/index.d.ts +5 -0
- package/dist/eventRepository/internalApi/index.d.ts.map +1 -0
- package/dist/eventRepository/internalApi/updateRSVP.d.ts +17 -0
- package/dist/eventRepository/internalApi/updateRSVP.d.ts.map +1 -0
- package/dist/eventRepository/observers/getEvent.d.ts +21 -0
- package/dist/eventRepository/observers/getEvent.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/getMyEvents/LiveCollectionController.d.ts +13 -0
- package/dist/eventRepository/observers/getMyEvents/LiveCollectionController.d.ts.map +1 -0
- package/dist/eventRepository/observers/getMyEvents/PaginationController.d.ts +5 -0
- package/dist/eventRepository/observers/getMyEvents/PaginationController.d.ts.map +1 -0
- package/dist/eventRepository/observers/getMyEvents/QueryStreamController.d.ts +15 -0
- package/dist/eventRepository/observers/getMyEvents/QueryStreamController.d.ts.map +1 -0
- package/dist/eventRepository/observers/getMyEvents.d.ts +12 -0
- package/dist/eventRepository/observers/getMyEvents.d.ts.map +1 -0
- package/dist/eventRepository/observers/getRSVPs/LiveCollectionController.d.ts +13 -0
- package/dist/eventRepository/observers/getRSVPs/LiveCollectionController.d.ts.map +1 -0
- package/dist/eventRepository/observers/getRSVPs/PaginationController.d.ts +5 -0
- package/dist/eventRepository/observers/getRSVPs/PaginationController.d.ts.map +1 -0
- package/dist/eventRepository/observers/getRSVPs/QueryStreamController.d.ts +15 -0
- package/dist/eventRepository/observers/getRSVPs/QueryStreamController.d.ts.map +1 -0
- package/dist/eventRepository/observers/getRSVPs.d.ts +12 -0
- package/dist/eventRepository/observers/getRSVPs.d.ts.map +1 -0
- package/dist/eventRepository/observers/index.d.ts +5 -0
- package/dist/eventRepository/observers/index.d.ts.map +1 -0
- package/dist/eventRepository/utils/createEventEventSubscriber.d.ts +2 -0
- package/dist/eventRepository/utils/createEventEventSubscriber.d.ts.map +1 -0
- package/dist/eventRepository/utils/index.d.ts +3 -0
- package/dist/eventRepository/utils/index.d.ts.map +1 -0
- package/dist/eventRepository/utils/prepareEventPayload.d.ts +2 -0
- package/dist/eventRepository/utils/prepareEventPayload.d.ts.map +1 -0
- package/dist/index.cjs.js +1077 -51
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.esm.js +1057 -32
- package/dist/index.umd.js +3 -3
- package/dist/messagePreview/utils/getChannelMessagePreviewWithUser.d.ts +1 -1
- package/dist/utils/linkedObject/eventLinkObject.d.ts +2 -0
- package/dist/utils/linkedObject/eventLinkObject.d.ts.map +1 -0
- package/dist/utils/linkedObject/index.d.ts +1 -0
- package/dist/utils/linkedObject/index.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs.js
CHANGED
|
@@ -192,6 +192,29 @@ exports.FeedSourceEnum = void 0;
|
|
|
192
192
|
FeedSourceEnum["User"] = "user";
|
|
193
193
|
})(exports.FeedSourceEnum || (exports.FeedSourceEnum = {}));
|
|
194
194
|
|
|
195
|
+
exports.AmityEventType = void 0;
|
|
196
|
+
(function (AmityEventType) {
|
|
197
|
+
AmityEventType["Virtual"] = "virtual";
|
|
198
|
+
AmityEventType["InPerson"] = "in_person";
|
|
199
|
+
})(exports.AmityEventType || (exports.AmityEventType = {}));
|
|
200
|
+
exports.AmityEventOriginType = void 0;
|
|
201
|
+
(function (AmityEventOriginType) {
|
|
202
|
+
AmityEventOriginType["Community"] = "community";
|
|
203
|
+
AmityEventOriginType["User"] = "user";
|
|
204
|
+
})(exports.AmityEventOriginType || (exports.AmityEventOriginType = {}));
|
|
205
|
+
exports.AmityEventStatus = void 0;
|
|
206
|
+
(function (AmityEventStatus) {
|
|
207
|
+
AmityEventStatus["Scheduled"] = "scheduled";
|
|
208
|
+
AmityEventStatus["Live"] = "live";
|
|
209
|
+
AmityEventStatus["Ended"] = "ended";
|
|
210
|
+
AmityEventStatus["Cancelled"] = "cancelled";
|
|
211
|
+
})(exports.AmityEventStatus || (exports.AmityEventStatus = {}));
|
|
212
|
+
exports.AmityEventResponseStatus = void 0;
|
|
213
|
+
(function (AmityEventResponseStatus) {
|
|
214
|
+
AmityEventResponseStatus["Going"] = "going";
|
|
215
|
+
AmityEventResponseStatus["NotGoing"] = "not_going";
|
|
216
|
+
})(exports.AmityEventResponseStatus || (exports.AmityEventResponseStatus = {}));
|
|
217
|
+
|
|
195
218
|
function getVersion() {
|
|
196
219
|
try {
|
|
197
220
|
// the string ''v7.11.0-cjs'' should be replaced by actual value by @rollup/plugin-replace
|
|
@@ -640,6 +663,8 @@ const idResolvers = {
|
|
|
640
663
|
notificationTraySeen: ({ userId }) => userId,
|
|
641
664
|
invitation: ({ _id }) => _id,
|
|
642
665
|
joinRequest: ({ joinRequestId }) => joinRequestId,
|
|
666
|
+
event: ({ eventId }) => eventId,
|
|
667
|
+
discussionCommunity: ({ communityId }) => communityId,
|
|
643
668
|
};
|
|
644
669
|
/**
|
|
645
670
|
* Retrieve the id resolver matching a domain name
|
|
@@ -695,6 +720,8 @@ const PAYLOAD2MODEL = {
|
|
|
695
720
|
notificationTrayItems: 'notificationTrayItem',
|
|
696
721
|
invitations: 'invitation',
|
|
697
722
|
joinRequests: 'joinRequest',
|
|
723
|
+
events: 'event',
|
|
724
|
+
discussionCommunities: 'discussionCommunity',
|
|
698
725
|
};
|
|
699
726
|
/** hidden */
|
|
700
727
|
const isOutdated = (prevData, nextData) => {
|
|
@@ -10460,7 +10487,7 @@ const getUserUnread = (callback) => {
|
|
|
10460
10487
|
};
|
|
10461
10488
|
};
|
|
10462
10489
|
|
|
10463
|
-
var index$
|
|
10490
|
+
var index$p = /*#__PURE__*/Object.freeze({
|
|
10464
10491
|
__proto__: null,
|
|
10465
10492
|
getActiveClient: getActiveClient,
|
|
10466
10493
|
getActiveUser: getActiveUser,
|
|
@@ -11679,7 +11706,7 @@ const getMyFollowInfo = (callback) => {
|
|
|
11679
11706
|
};
|
|
11680
11707
|
/* end_public_function */
|
|
11681
11708
|
|
|
11682
|
-
var index$
|
|
11709
|
+
var index$o = /*#__PURE__*/Object.freeze({
|
|
11683
11710
|
__proto__: null,
|
|
11684
11711
|
blockUser: blockUser,
|
|
11685
11712
|
unBlockUser: unBlockUser,
|
|
@@ -13658,6 +13685,209 @@ const communityLinkedObject = (community) => {
|
|
|
13658
13685
|
} });
|
|
13659
13686
|
};
|
|
13660
13687
|
|
|
13688
|
+
const prepareEventPayload = (rawPayload) => {
|
|
13689
|
+
return Object.assign(Object.assign({}, rawPayload), { users: rawPayload.users.map(convertRawUserToInternalUser) });
|
|
13690
|
+
};
|
|
13691
|
+
|
|
13692
|
+
const createEventEventSubscriber = (event, callback) => {
|
|
13693
|
+
const client = getActiveClient();
|
|
13694
|
+
const filter = (payload) => {
|
|
13695
|
+
const unpackedPayload = prepareEventPayload(payload);
|
|
13696
|
+
if (!client.cache) {
|
|
13697
|
+
callback(unpackedPayload.events[0]);
|
|
13698
|
+
}
|
|
13699
|
+
else {
|
|
13700
|
+
ingestInCache(unpackedPayload);
|
|
13701
|
+
const event = pullFromCache([
|
|
13702
|
+
'event',
|
|
13703
|
+
'get',
|
|
13704
|
+
unpackedPayload.events[0].eventId,
|
|
13705
|
+
]);
|
|
13706
|
+
callback(event.data);
|
|
13707
|
+
}
|
|
13708
|
+
};
|
|
13709
|
+
return createEventSubscriber(client, event, event, filter);
|
|
13710
|
+
};
|
|
13711
|
+
|
|
13712
|
+
/* begin_public_function
|
|
13713
|
+
id: event.rsvp.create
|
|
13714
|
+
*/
|
|
13715
|
+
/**
|
|
13716
|
+
* ```js
|
|
13717
|
+
* import { event } from '@amityco/ts-sdk'
|
|
13718
|
+
* const response = await event.createRSVP(eventId, status)
|
|
13719
|
+
* ```
|
|
13720
|
+
*
|
|
13721
|
+
* Creates an {@link Amity.InternalEvent}
|
|
13722
|
+
*
|
|
13723
|
+
* @param bundle The data necessary to create a new {@link Amity.InternalEvent}
|
|
13724
|
+
* @returns The newly created {@link Amity.InternalEvent}
|
|
13725
|
+
*
|
|
13726
|
+
* @category Event API
|
|
13727
|
+
* @async
|
|
13728
|
+
*/
|
|
13729
|
+
const createRSVP = async (eventId, status) => {
|
|
13730
|
+
const client = getActiveClient();
|
|
13731
|
+
client.log('event/createRSVP', eventId, status);
|
|
13732
|
+
const { data: payload } = await client.http.post(`/api/v1/events/${eventId}/rsvp`, { status });
|
|
13733
|
+
fireEvent('local.rsvp.created', payload);
|
|
13734
|
+
const preparedPayload = prepareEventPayload(payload);
|
|
13735
|
+
const cachedAt = client.cache && Date.now();
|
|
13736
|
+
if (client.cache)
|
|
13737
|
+
ingestInCache(preparedPayload, { cachedAt });
|
|
13738
|
+
return {
|
|
13739
|
+
data: preparedPayload.events[0],
|
|
13740
|
+
cachedAt,
|
|
13741
|
+
};
|
|
13742
|
+
};
|
|
13743
|
+
/* end_public_function */
|
|
13744
|
+
|
|
13745
|
+
/* begin_public_function
|
|
13746
|
+
id: event.update
|
|
13747
|
+
*/
|
|
13748
|
+
/**
|
|
13749
|
+
* ```js
|
|
13750
|
+
* import { event } from '@amityco/ts-sdk'
|
|
13751
|
+
* const response = await event.updateRSVP(eventId, status)
|
|
13752
|
+
* ```
|
|
13753
|
+
*
|
|
13754
|
+
* Updates an {@link Amity.InternalEvent}
|
|
13755
|
+
*
|
|
13756
|
+
* @param eventId The ID of the {@link Amity.InternalEvent} to edit
|
|
13757
|
+
* @param bundle The data necessary to update an existing {@link Amity.InternalEvent}
|
|
13758
|
+
* @returns the updated {@link Amity.InternalEvent}
|
|
13759
|
+
*
|
|
13760
|
+
* @category Event API
|
|
13761
|
+
* @async
|
|
13762
|
+
*/
|
|
13763
|
+
const updateRSVP = async (eventId, status) => {
|
|
13764
|
+
const client = getActiveClient();
|
|
13765
|
+
client.log('event/updateRSVP', eventId, status);
|
|
13766
|
+
const { data: payload } = await client.http.put(`/api/v1/events/${eventId}/rsvp`, { status });
|
|
13767
|
+
fireEvent('local.rsvp.updated', payload);
|
|
13768
|
+
const preparedPayload = prepareEventPayload(payload);
|
|
13769
|
+
const cachedAt = client.cache && Date.now();
|
|
13770
|
+
if (client.cache)
|
|
13771
|
+
ingestInCache(preparedPayload, { cachedAt });
|
|
13772
|
+
return {
|
|
13773
|
+
data: preparedPayload.events.find(event => event.eventId === eventId),
|
|
13774
|
+
cachedAt,
|
|
13775
|
+
};
|
|
13776
|
+
};
|
|
13777
|
+
/* end_public_function */
|
|
13778
|
+
|
|
13779
|
+
/* begin_public_function
|
|
13780
|
+
id: event.rsvp.me
|
|
13781
|
+
*/
|
|
13782
|
+
/**
|
|
13783
|
+
* ```js
|
|
13784
|
+
* import { event } from '@amityco/ts-sdk'
|
|
13785
|
+
* const myRSVP = await event.getMyRSVP(eventId)
|
|
13786
|
+
* ```
|
|
13787
|
+
*
|
|
13788
|
+
* Joins a {@link Amity.InternalEvent} object
|
|
13789
|
+
*
|
|
13790
|
+
* @param eventId the {@link Amity.InternalEvent} to get RSVP for
|
|
13791
|
+
* @returns A success boolean if the {@link Amity.InternalEvent} RSVP was retrieved
|
|
13792
|
+
*
|
|
13793
|
+
* @category Event API
|
|
13794
|
+
* @async
|
|
13795
|
+
*/
|
|
13796
|
+
const getMyRSVP = async (eventId) => {
|
|
13797
|
+
const client = getActiveClient();
|
|
13798
|
+
client.log('event/getMyRSVP', eventId);
|
|
13799
|
+
const { data: payload } = await client.http.get(`/api/v1/events/${eventId}/me/rsvp`);
|
|
13800
|
+
const data = prepareEventPayload(payload);
|
|
13801
|
+
const cachedAt = client.cache && Date.now();
|
|
13802
|
+
if (client.cache)
|
|
13803
|
+
ingestInCache(data, { cachedAt });
|
|
13804
|
+
return {
|
|
13805
|
+
data: data.events.find(event => event.eventId === eventId),
|
|
13806
|
+
cachedAt,
|
|
13807
|
+
};
|
|
13808
|
+
};
|
|
13809
|
+
/* end_public_function */
|
|
13810
|
+
/**
|
|
13811
|
+
* ```js
|
|
13812
|
+
* import { event } from '@amityco/ts-sdk'
|
|
13813
|
+
* const event = event.getMyRSVP.locally(eventId)
|
|
13814
|
+
* ```
|
|
13815
|
+
*
|
|
13816
|
+
* Fetches a {@link Amity.InternalEvent} object in cache
|
|
13817
|
+
*
|
|
13818
|
+
* @param eventId the ID of the {@link Amity.InternalEvent} to fetch
|
|
13819
|
+
* @returns the associated {@link Amity.InternalEvent} object
|
|
13820
|
+
*
|
|
13821
|
+
* @category Event API
|
|
13822
|
+
*/
|
|
13823
|
+
getMyRSVP.locally = (eventId) => {
|
|
13824
|
+
const client = getActiveClient();
|
|
13825
|
+
client.log('event/getMyRSVP.locally', eventId);
|
|
13826
|
+
if (!client.cache)
|
|
13827
|
+
return;
|
|
13828
|
+
const cache = pullFromCache(['event', 'getMyRSVP', eventId]);
|
|
13829
|
+
if (!cache)
|
|
13830
|
+
return;
|
|
13831
|
+
return {
|
|
13832
|
+
data: cache.data,
|
|
13833
|
+
cachedAt: cache.cachedAt,
|
|
13834
|
+
};
|
|
13835
|
+
};
|
|
13836
|
+
|
|
13837
|
+
const eventLinkedObject = (event) => {
|
|
13838
|
+
return Object.assign(Object.assign({}, event), { get creator() {
|
|
13839
|
+
const cacheData = pullFromCache(['user', 'get', event.userId]);
|
|
13840
|
+
if (!(cacheData === null || cacheData === void 0 ? void 0 : cacheData.data))
|
|
13841
|
+
return;
|
|
13842
|
+
return userLinkedObject(cacheData.data);
|
|
13843
|
+
},
|
|
13844
|
+
get discussionCommunity() {
|
|
13845
|
+
if (!event.discussionCommunityId)
|
|
13846
|
+
return;
|
|
13847
|
+
const cacheData = pullFromCache([
|
|
13848
|
+
'discussionCommunity',
|
|
13849
|
+
'get',
|
|
13850
|
+
event.discussionCommunityId,
|
|
13851
|
+
]);
|
|
13852
|
+
if (!(cacheData === null || cacheData === void 0 ? void 0 : cacheData.data))
|
|
13853
|
+
return;
|
|
13854
|
+
return communityLinkedObject(cacheData.data);
|
|
13855
|
+
},
|
|
13856
|
+
get targetCommunity() {
|
|
13857
|
+
if (!event.originId)
|
|
13858
|
+
return;
|
|
13859
|
+
const cacheData = pullFromCache(['community', 'get', event.originId]);
|
|
13860
|
+
if (!(cacheData === null || cacheData === void 0 ? void 0 : cacheData.data))
|
|
13861
|
+
return;
|
|
13862
|
+
return communityLinkedObject(cacheData.data);
|
|
13863
|
+
},
|
|
13864
|
+
get coverImage() {
|
|
13865
|
+
if (!event.coverImageFileId)
|
|
13866
|
+
return;
|
|
13867
|
+
const cacheData = pullFromCache(['file', 'get', event.coverImageFileId]);
|
|
13868
|
+
if (!(cacheData === null || cacheData === void 0 ? void 0 : cacheData.data))
|
|
13869
|
+
return;
|
|
13870
|
+
return cacheData.data;
|
|
13871
|
+
},
|
|
13872
|
+
get liveStream() {
|
|
13873
|
+
if (!event.livestreamId)
|
|
13874
|
+
return;
|
|
13875
|
+
const cacheData = pullFromCache(['stream', 'get', event.livestreamId]);
|
|
13876
|
+
if (!(cacheData === null || cacheData === void 0 ? void 0 : cacheData.data))
|
|
13877
|
+
return;
|
|
13878
|
+
return cacheData.data;
|
|
13879
|
+
}, createRSVP: async (status) => {
|
|
13880
|
+
const { data } = await createRSVP(event.eventId, status);
|
|
13881
|
+
return data;
|
|
13882
|
+
}, updateRSVP: async (status) => {
|
|
13883
|
+
const { data } = await updateRSVP(event.eventId, status);
|
|
13884
|
+
return data;
|
|
13885
|
+
}, getMyRSVP: async () => {
|
|
13886
|
+
const { data } = await getMyRSVP(event.eventId);
|
|
13887
|
+
return data;
|
|
13888
|
+
} });
|
|
13889
|
+
};
|
|
13890
|
+
|
|
13661
13891
|
const LinkedObject = {
|
|
13662
13892
|
ad: adLinkedObject,
|
|
13663
13893
|
comment: commentLinkedObject,
|
|
@@ -13676,6 +13906,7 @@ const LinkedObject = {
|
|
|
13676
13906
|
invitation: invitationLinkedObject,
|
|
13677
13907
|
joinRequest: joinRequestLinkedObject,
|
|
13678
13908
|
channelMember: channelMemberLinkedObject,
|
|
13909
|
+
event: eventLinkedObject,
|
|
13679
13910
|
};
|
|
13680
13911
|
|
|
13681
13912
|
/* begin_public_function
|
|
@@ -14666,9 +14897,9 @@ var AmityUserSearchMatchType;
|
|
|
14666
14897
|
AmityUserSearchMatchType["PARTIAL"] = "partial";
|
|
14667
14898
|
})(AmityUserSearchMatchType || (AmityUserSearchMatchType = {}));
|
|
14668
14899
|
|
|
14669
|
-
var index$
|
|
14900
|
+
var index$n = /*#__PURE__*/Object.freeze({
|
|
14670
14901
|
__proto__: null,
|
|
14671
|
-
Relationship: index$
|
|
14902
|
+
Relationship: index$o,
|
|
14672
14903
|
getUserByIds: getUserByIds,
|
|
14673
14904
|
updateUser: updateUser,
|
|
14674
14905
|
flagUser: flagUser,
|
|
@@ -15071,7 +15302,7 @@ const uploadAudio = async (formData, onProgress) => {
|
|
|
15071
15302
|
};
|
|
15072
15303
|
/* end_public_function */
|
|
15073
15304
|
|
|
15074
|
-
var index$
|
|
15305
|
+
var index$m = /*#__PURE__*/Object.freeze({
|
|
15075
15306
|
__proto__: null,
|
|
15076
15307
|
getFile: getFile,
|
|
15077
15308
|
uploadFile: uploadFile,
|
|
@@ -16883,7 +17114,7 @@ const getReactions$1 = (params, callback, config) => {
|
|
|
16883
17114
|
};
|
|
16884
17115
|
/* end_public_function */
|
|
16885
17116
|
|
|
16886
|
-
var index$
|
|
17117
|
+
var index$l = /*#__PURE__*/Object.freeze({
|
|
16887
17118
|
__proto__: null,
|
|
16888
17119
|
addReaction: addReaction,
|
|
16889
17120
|
removeReaction: removeReaction,
|
|
@@ -18655,7 +18886,7 @@ const getMessages = (params, callback, config) => {
|
|
|
18655
18886
|
};
|
|
18656
18887
|
/* end_public_function */
|
|
18657
18888
|
|
|
18658
|
-
var index$
|
|
18889
|
+
var index$k = /*#__PURE__*/Object.freeze({
|
|
18659
18890
|
__proto__: null,
|
|
18660
18891
|
createMessage: createMessage,
|
|
18661
18892
|
updateMessage: updateMessage,
|
|
@@ -19181,7 +19412,7 @@ const stopMessageReceiptSync = (subChannelId) => {
|
|
|
19181
19412
|
};
|
|
19182
19413
|
/* end_public_function */
|
|
19183
19414
|
|
|
19184
|
-
var index$
|
|
19415
|
+
var index$j = /*#__PURE__*/Object.freeze({
|
|
19185
19416
|
__proto__: null,
|
|
19186
19417
|
getSubChannelByIds: getSubChannels$1,
|
|
19187
19418
|
createSubChannel: createSubChannel,
|
|
@@ -20508,7 +20739,7 @@ const searchMembers$1 = (params, callback, config) => {
|
|
|
20508
20739
|
};
|
|
20509
20740
|
/* end_public_function */
|
|
20510
20741
|
|
|
20511
|
-
var index$
|
|
20742
|
+
var index$i = /*#__PURE__*/Object.freeze({
|
|
20512
20743
|
__proto__: null,
|
|
20513
20744
|
addMembers: addMembers$1,
|
|
20514
20745
|
removeMembers: removeMembers$1,
|
|
@@ -20711,7 +20942,7 @@ const unmuteMembers = async (channelId, userIds) => {
|
|
|
20711
20942
|
};
|
|
20712
20943
|
/* end_public_function */
|
|
20713
20944
|
|
|
20714
|
-
var index$
|
|
20945
|
+
var index$h = /*#__PURE__*/Object.freeze({
|
|
20715
20946
|
__proto__: null,
|
|
20716
20947
|
addRole: addRole,
|
|
20717
20948
|
removeRole: removeRole,
|
|
@@ -20721,10 +20952,10 @@ var index$g = /*#__PURE__*/Object.freeze({
|
|
|
20721
20952
|
unmuteMembers: unmuteMembers
|
|
20722
20953
|
});
|
|
20723
20954
|
|
|
20724
|
-
var index$
|
|
20955
|
+
var index$g = /*#__PURE__*/Object.freeze({
|
|
20725
20956
|
__proto__: null,
|
|
20726
|
-
Membership: index$
|
|
20727
|
-
Moderation: index$
|
|
20957
|
+
Membership: index$i,
|
|
20958
|
+
Moderation: index$h,
|
|
20728
20959
|
getChannelByIds: getChannelByIds$1,
|
|
20729
20960
|
createChannel: createChannel,
|
|
20730
20961
|
updateChannel: updateChannel,
|
|
@@ -22127,7 +22358,7 @@ const searchMembers = (params, callback, config) => {
|
|
|
22127
22358
|
};
|
|
22128
22359
|
/* end_public_function */
|
|
22129
22360
|
|
|
22130
|
-
var index$
|
|
22361
|
+
var index$f = /*#__PURE__*/Object.freeze({
|
|
22131
22362
|
__proto__: null,
|
|
22132
22363
|
addMembers: addMembers,
|
|
22133
22364
|
removeMembers: removeMembers,
|
|
@@ -23378,7 +23609,7 @@ const unbanMembers = async (communityId, userIds) => {
|
|
|
23378
23609
|
};
|
|
23379
23610
|
/* end_public_function */
|
|
23380
23611
|
|
|
23381
|
-
var index$
|
|
23612
|
+
var index$e = /*#__PURE__*/Object.freeze({
|
|
23382
23613
|
__proto__: null,
|
|
23383
23614
|
addRoles: addRoles,
|
|
23384
23615
|
removeRoles: removeRoles,
|
|
@@ -23386,10 +23617,10 @@ var index$d = /*#__PURE__*/Object.freeze({
|
|
|
23386
23617
|
unbanMembers: unbanMembers
|
|
23387
23618
|
});
|
|
23388
23619
|
|
|
23389
|
-
var index$
|
|
23620
|
+
var index$d = /*#__PURE__*/Object.freeze({
|
|
23390
23621
|
__proto__: null,
|
|
23391
|
-
Moderation: index$
|
|
23392
|
-
Membership: index$
|
|
23622
|
+
Moderation: index$e,
|
|
23623
|
+
Membership: index$f,
|
|
23393
23624
|
getCommunityByIds: getCommunities$1,
|
|
23394
23625
|
createCommunity: createCommunity,
|
|
23395
23626
|
updateCommunity: updateCommunity,
|
|
@@ -23623,7 +23854,7 @@ const getCategories = (params, callback, config) => {
|
|
|
23623
23854
|
};
|
|
23624
23855
|
/* end_public_function */
|
|
23625
23856
|
|
|
23626
|
-
var index$
|
|
23857
|
+
var index$c = /*#__PURE__*/Object.freeze({
|
|
23627
23858
|
__proto__: null,
|
|
23628
23859
|
getCategory: getCategory,
|
|
23629
23860
|
getCategories: getCategories
|
|
@@ -24682,7 +24913,7 @@ const getComments = (params, callback, config) => {
|
|
|
24682
24913
|
};
|
|
24683
24914
|
/* end_public_function */
|
|
24684
24915
|
|
|
24685
|
-
var index$
|
|
24916
|
+
var index$b = /*#__PURE__*/Object.freeze({
|
|
24686
24917
|
__proto__: null,
|
|
24687
24918
|
getCommentByIds: getCommentByIds,
|
|
24688
24919
|
createComment: createComment,
|
|
@@ -25353,7 +25584,7 @@ const getUserFeed = (params, callback, config) => {
|
|
|
25353
25584
|
};
|
|
25354
25585
|
/* end_public_function */
|
|
25355
25586
|
|
|
25356
|
-
var index$
|
|
25587
|
+
var index$a = /*#__PURE__*/Object.freeze({
|
|
25357
25588
|
__proto__: null,
|
|
25358
25589
|
queryGlobalFeed: queryGlobalFeed,
|
|
25359
25590
|
getCustomRankingGlobalFeed: getCustomRankingGlobalFeed,
|
|
@@ -27034,7 +27265,7 @@ const searchPostsByHashtag = (params, callback, config) => {
|
|
|
27034
27265
|
};
|
|
27035
27266
|
/* end_public_function */
|
|
27036
27267
|
|
|
27037
|
-
var index$
|
|
27268
|
+
var index$9 = /*#__PURE__*/Object.freeze({
|
|
27038
27269
|
__proto__: null,
|
|
27039
27270
|
getPostByIds: getPostByIds,
|
|
27040
27271
|
createPost: createPost,
|
|
@@ -27642,7 +27873,7 @@ const getStreams = (params, callback, config) => {
|
|
|
27642
27873
|
};
|
|
27643
27874
|
};
|
|
27644
27875
|
|
|
27645
|
-
var index$
|
|
27876
|
+
var index$8 = /*#__PURE__*/Object.freeze({
|
|
27646
27877
|
__proto__: null,
|
|
27647
27878
|
createStream: createStream,
|
|
27648
27879
|
updateStream: updateStream,
|
|
@@ -27960,7 +28191,7 @@ const getPoll = (pollId, callback) => {
|
|
|
27960
28191
|
};
|
|
27961
28192
|
/* end_public_function */
|
|
27962
28193
|
|
|
27963
|
-
var index$
|
|
28194
|
+
var index$7 = /*#__PURE__*/Object.freeze({
|
|
27964
28195
|
__proto__: null,
|
|
27965
28196
|
createPoll: createPoll,
|
|
27966
28197
|
closePoll: closePoll,
|
|
@@ -27972,7 +28203,7 @@ var index$6 = /*#__PURE__*/Object.freeze({
|
|
|
27972
28203
|
getPoll: getPoll
|
|
27973
28204
|
});
|
|
27974
28205
|
|
|
27975
|
-
const privateKey = "-----BEGIN PRIVATE KEY-----\
|
|
28206
|
+
const privateKey = "-----BEGIN PRIVATE KEY-----\nMIIEvwIBADANBgkqhkiG9w0BAQEFAASCBKkwggSlAgEAAoIBAQDAARz+hmBgi8pJ\nQb8LeY41gtHhk+ACMwRfhsn7GqpqRQNG2qU0755mzZuVDUqjQMGSo8THJB7O+OJs\nflbZRkFXlFoFOVNw1UpNOgwEQZ6wB9oRwzepTJAfF1sVhm/o/ixvXh1zDFNDy6yZ\npXyiiJHUVxqyjllZhxnwdvjoVtDs6hW6awG09bB9nh/TTejlUKXoAgzqVwu/1QMu\nUVViET495elEe19aUarEy+oL2iKeXCEvqda/pWNBdbieFyJvvZ08HN8dPuT88wq2\njZLEAth1vrwQ2IAa4ktaLcBQdLJgIkrbDvAiVZ8lQAjS/bq5vXQikTGvoPlC5bbn\nvuOM/3eLAgMBAAECggEAVZ+peHAghq2QVj71nX5lxsNCKaCyYwixSJBpfouTt7Rz\nE6PpzMOXFi1W1o+I22jDakuSM2SOQKqI/u0QefB0r0O/KVk5NrZHXk0mkrdYtxOp\nUgaGyf8UvmjB+8VqHrNKyZdk9qtmbnNj01kTTcAtmE4H39zPR7eR/8Rul94vaZbs\nwCnKJS3mLT3JxyGug6lxanveKkjG+CKC1nJQYWaxCJxaFSzbwXQPvDhB+TvrIbee\npd5v4EAyEJohpr+T9oDGGJkb/KARBZCtwLyB976PKJwwBA8MRVL1i5QwawuMiMq5\nUtnOnbGKtCeFzaLbNU0Qi8bqyims84EQxC6DOu1fkQKBgQDdvsoBsEhsOXV7hlIJ\naEd0eSJZVkdqimxH8uGoMM2FeNaOrcB6yBXqTSP0R3OIyf8eaY6yjRvP30ZNXcll\n/gD3O1Mu6YmWQdt1W2WA6pKOsUuPXasf0pdOF7IiFZKlSabz5YHXFqwVuqm8loaj\nsXel3YWqPVdHiankE7tz+3ssnQKBgQDdqi4TNdD1MdEpihx19jr0QjUiXW3939FK\nqp30HESPEGDGQzXdmJgif9HhZb+cJSuWaHEbjgBrYahvgCF+y6LbEpOD+D/dmT+s\nDEAQaR84sah6dokwPjV8fjBSrcVFjCS+doxv0d3p/9OUEeyUhFrY03nxtIEYkLIE\n/Zvn37b4RwKBgQCLENVFe9XfsaVhQ5r9dV2iyTlmh7qgMZG5CbTFs12hQGhm8McO\n+Z7s41YSJCFr/yq1WwP4LJDtrBw99vyQr1zRsG35tNLp3gGRNzGQSQyC2uQFVHw2\np+7mNewsfhUK/gbrXNsyFnDz6635rPlhfbII3sWuP2wWXFqkxE9CbMwR7QKBgQC6\nawDMzxmo2/iYArrkyevSuEuPVxvFwpF1RgAI6C0QVCnPE38dmdN4UB7mfHekje4W\nVEercMURidPp0cxZolCYBQtilUjAyL0vqC3In1/Ogjq6oy3FEMxSop1pKxMY5j+Q\nnoqFD+6deLUrddeNH7J3X4LSr4dSbX4JjG+tlgt+yQKBgQCuwTL4hA6KqeInQ0Ta\n9VQX5Qr8hFlqJz1gpymi/k63tW/Ob8yedbg3WWNWyShwRMFYyY9S81ITFWM95uL6\nvF3x9rmRjwElJw9PMwVu6dmf/CO0Z1wzXSp2VVD12gbrUD/0/d7MUoJ9LgC8X8f/\nn0txLHYGHbx+nf95+JUg6lV3hg==\n-----END PRIVATE KEY-----";
|
|
27976
28207
|
/*
|
|
27977
28208
|
* The crypto algorithm used for importing key and signing string
|
|
27978
28209
|
*/
|
|
@@ -28343,7 +28574,7 @@ const getPlayer = async (parameters) => {
|
|
|
28343
28574
|
return video;
|
|
28344
28575
|
};
|
|
28345
28576
|
|
|
28346
|
-
var index$
|
|
28577
|
+
var index$6 = /*#__PURE__*/Object.freeze({
|
|
28347
28578
|
__proto__: null,
|
|
28348
28579
|
getPlayer: getPlayer
|
|
28349
28580
|
});
|
|
@@ -29516,7 +29747,7 @@ const getGlobalStoryTargets = (params, callback, config) => {
|
|
|
29516
29747
|
};
|
|
29517
29748
|
};
|
|
29518
29749
|
|
|
29519
|
-
var index$
|
|
29750
|
+
var index$5 = /*#__PURE__*/Object.freeze({
|
|
29520
29751
|
__proto__: null,
|
|
29521
29752
|
createImageStory: createImageStory,
|
|
29522
29753
|
createVideoStory: createVideoStory,
|
|
@@ -29553,7 +29784,7 @@ const getNetworkAds = async () => {
|
|
|
29553
29784
|
};
|
|
29554
29785
|
};
|
|
29555
29786
|
|
|
29556
|
-
var index$
|
|
29787
|
+
var index$4 = /*#__PURE__*/Object.freeze({
|
|
29557
29788
|
__proto__: null,
|
|
29558
29789
|
getNetworkAds: getNetworkAds
|
|
29559
29790
|
});
|
|
@@ -29944,7 +30175,7 @@ const markTraySeen = async (lastSeenAt) => {
|
|
|
29944
30175
|
};
|
|
29945
30176
|
/* end_public_function */
|
|
29946
30177
|
|
|
29947
|
-
var index$
|
|
30178
|
+
var index$3 = /*#__PURE__*/Object.freeze({
|
|
29948
30179
|
__proto__: null,
|
|
29949
30180
|
getNotificationTraySeen: getNotificationTraySeen,
|
|
29950
30181
|
getNotificationTrayItems: getNotificationTrayItems,
|
|
@@ -30145,7 +30376,7 @@ const getMyCommunityInvitations = (params, callback, config) => {
|
|
|
30145
30376
|
};
|
|
30146
30377
|
};
|
|
30147
30378
|
|
|
30148
|
-
var index$
|
|
30379
|
+
var index$2 = /*#__PURE__*/Object.freeze({
|
|
30149
30380
|
__proto__: null,
|
|
30150
30381
|
onLocalInvitationCreated: onLocalInvitationCreated,
|
|
30151
30382
|
onLocalInvitationUpdated: onLocalInvitationUpdated,
|
|
@@ -30286,42 +30517,837 @@ const getReactions = (postId, callback) => {
|
|
|
30286
30517
|
};
|
|
30287
30518
|
};
|
|
30288
30519
|
|
|
30289
|
-
var index = /*#__PURE__*/Object.freeze({
|
|
30520
|
+
var index$1 = /*#__PURE__*/Object.freeze({
|
|
30290
30521
|
__proto__: null,
|
|
30291
30522
|
createReaction: createReaction,
|
|
30292
30523
|
onLiveReactionCreated: onLiveReactionCreated,
|
|
30293
30524
|
getReactions: getReactions
|
|
30294
30525
|
});
|
|
30295
30526
|
|
|
30527
|
+
/* begin_public_function
|
|
30528
|
+
id: event.create
|
|
30529
|
+
*/
|
|
30530
|
+
/**
|
|
30531
|
+
* ```js
|
|
30532
|
+
* import { EventRepository } from '@amityco/ts-sdk'
|
|
30533
|
+
* const response = await EventRepository.createEvent(bundle)
|
|
30534
|
+
* ```
|
|
30535
|
+
*
|
|
30536
|
+
* Creates an {@link Amity.Event}
|
|
30537
|
+
*
|
|
30538
|
+
* @param bundle The data necessary to create a new {@link Amity.Event}
|
|
30539
|
+
* @returns The newly created {@link Amity.Event}
|
|
30540
|
+
*
|
|
30541
|
+
* @category Event API
|
|
30542
|
+
* @async
|
|
30543
|
+
*/
|
|
30544
|
+
const createEvent = async (bundle) => {
|
|
30545
|
+
const client = getActiveClient();
|
|
30546
|
+
client.log('event/createEvent', bundle);
|
|
30547
|
+
const { data: payload } = await client.http.post('/api/v1/events', bundle);
|
|
30548
|
+
fireEvent('local.event.created', payload);
|
|
30549
|
+
const preparedPayload = prepareEventPayload(payload);
|
|
30550
|
+
const cachedAt = client.cache && Date.now();
|
|
30551
|
+
if (client.cache)
|
|
30552
|
+
ingestInCache(preparedPayload, { cachedAt });
|
|
30553
|
+
return {
|
|
30554
|
+
data: eventLinkedObject(preparedPayload.events[0]),
|
|
30555
|
+
cachedAt,
|
|
30556
|
+
};
|
|
30557
|
+
};
|
|
30558
|
+
/* end_public_function */
|
|
30559
|
+
|
|
30560
|
+
/* begin_public_function
|
|
30561
|
+
id: event.update
|
|
30562
|
+
*/
|
|
30563
|
+
/**
|
|
30564
|
+
* ```js
|
|
30565
|
+
* import { EventRepository } from '@amityco/ts-sdk'
|
|
30566
|
+
* const response = await EventRepository.updateEvent(eventId, bundle)
|
|
30567
|
+
* ```
|
|
30568
|
+
*
|
|
30569
|
+
* Updates an {@link Amity.Event}
|
|
30570
|
+
*
|
|
30571
|
+
* @param eventId The ID of the {@link Amity.Event} to edit
|
|
30572
|
+
* @param bundle The data necessary to update an existing {@link Amity.Event}
|
|
30573
|
+
* @returns the updated {@link Amity.Event}
|
|
30574
|
+
*
|
|
30575
|
+
* @category Event API
|
|
30576
|
+
* @async
|
|
30577
|
+
*/
|
|
30578
|
+
const updateEvent = async (eventId, bundle) => {
|
|
30579
|
+
const client = getActiveClient();
|
|
30580
|
+
client.log('event/updateEvent', eventId, bundle);
|
|
30581
|
+
const { data: payload } = await client.http.put(`/api/v1/events/${eventId}`, bundle);
|
|
30582
|
+
fireEvent('local.event.updated', payload);
|
|
30583
|
+
const preparedPayload = prepareEventPayload(payload);
|
|
30584
|
+
const cachedAt = client.cache && Date.now();
|
|
30585
|
+
if (client.cache)
|
|
30586
|
+
ingestInCache(preparedPayload, { cachedAt });
|
|
30587
|
+
return {
|
|
30588
|
+
data: eventLinkedObject(preparedPayload.events.find(event => event.eventId === eventId)),
|
|
30589
|
+
cachedAt,
|
|
30590
|
+
};
|
|
30591
|
+
};
|
|
30592
|
+
/* end_public_function */
|
|
30593
|
+
|
|
30594
|
+
/* begin_public_function
|
|
30595
|
+
id: event.get
|
|
30596
|
+
*/
|
|
30597
|
+
/**
|
|
30598
|
+
* ```js
|
|
30599
|
+
* import { EventRepository } from '@amityco/ts-sdk'
|
|
30600
|
+
* const event = await EventRepository.getEvent(eventId)
|
|
30601
|
+
* ```
|
|
30602
|
+
*
|
|
30603
|
+
* Fetches a {@link Amity.Event} object
|
|
30604
|
+
*
|
|
30605
|
+
* @param eventId the ID of the {@link Amity.Event} to fetch
|
|
30606
|
+
* @returns the associated {@link Amity.Event} object
|
|
30607
|
+
*
|
|
30608
|
+
* @category Event API
|
|
30609
|
+
* @async
|
|
30610
|
+
*/
|
|
30611
|
+
const getEvent$1 = async (eventId) => {
|
|
30612
|
+
const client = getActiveClient();
|
|
30613
|
+
client.log('event/getEvent', eventId);
|
|
30614
|
+
const { data: payload } = await client.http.get(`/api/v1/events/${eventId}`);
|
|
30615
|
+
const data = prepareEventPayload(payload);
|
|
30616
|
+
const cachedAt = client.cache && Date.now();
|
|
30617
|
+
if (client.cache)
|
|
30618
|
+
ingestInCache(data, { cachedAt });
|
|
30619
|
+
return {
|
|
30620
|
+
data: data.events.find(event => event.eventId === eventId),
|
|
30621
|
+
cachedAt,
|
|
30622
|
+
};
|
|
30623
|
+
};
|
|
30624
|
+
/* end_public_function */
|
|
30625
|
+
/**
|
|
30626
|
+
* ```js
|
|
30627
|
+
* import { EventRepository } from '@amityco/ts-sdk'
|
|
30628
|
+
* const event = EventRepository.getEvent.locally(eventId)
|
|
30629
|
+
* ```
|
|
30630
|
+
*
|
|
30631
|
+
* Fetches a {@link Amity.Event} object in cache
|
|
30632
|
+
*
|
|
30633
|
+
* @param eventId the ID of the {@link Amity.Event} to fetch
|
|
30634
|
+
* @returns the associated {@link Amity.Event} object
|
|
30635
|
+
*
|
|
30636
|
+
* @category Event API
|
|
30637
|
+
*/
|
|
30638
|
+
getEvent$1.locally = (eventId) => {
|
|
30639
|
+
const client = getActiveClient();
|
|
30640
|
+
client.log('event/getEvent.locally', eventId);
|
|
30641
|
+
if (!client.cache)
|
|
30642
|
+
return;
|
|
30643
|
+
const cache = pullFromCache(['event', 'get', eventId]);
|
|
30644
|
+
if (!cache)
|
|
30645
|
+
return;
|
|
30646
|
+
return {
|
|
30647
|
+
data: cache.data,
|
|
30648
|
+
cachedAt: cache.cachedAt,
|
|
30649
|
+
};
|
|
30650
|
+
};
|
|
30651
|
+
|
|
30652
|
+
/* begin_public_function
|
|
30653
|
+
id: event.delete
|
|
30654
|
+
*/
|
|
30655
|
+
/**
|
|
30656
|
+
* ```js
|
|
30657
|
+
* import { EventRepository } from '@amityco/ts-sdk'
|
|
30658
|
+
* const { success } = await EventRepository.deleteEvent(eventId)
|
|
30659
|
+
* ```
|
|
30660
|
+
*
|
|
30661
|
+
* Deletes a {@link Amity.Event}
|
|
30662
|
+
*
|
|
30663
|
+
* @param eventId The {@link Amity.Event} ID to delete
|
|
30664
|
+
*
|
|
30665
|
+
* @category Event API
|
|
30666
|
+
* @async
|
|
30667
|
+
*/
|
|
30668
|
+
const deleteEvent = async (eventId) => {
|
|
30669
|
+
const client = getActiveClient();
|
|
30670
|
+
client.log('event/deleteEvent', eventId);
|
|
30671
|
+
const event = await getEvent$1(eventId);
|
|
30672
|
+
await client.http.delete(`/api/v1/events/${eventId}`);
|
|
30673
|
+
const deletedEvent = Object.assign(Object.assign({}, event.data), { isDeleted: true });
|
|
30674
|
+
upsertInCache(['event', 'get', eventId], deletedEvent);
|
|
30675
|
+
fireEvent('local.event.deleted', {
|
|
30676
|
+
users: [],
|
|
30677
|
+
files: [],
|
|
30678
|
+
communities: [],
|
|
30679
|
+
videoStreamings: [],
|
|
30680
|
+
events: [deletedEvent],
|
|
30681
|
+
discussionCommunities: [],
|
|
30682
|
+
});
|
|
30683
|
+
};
|
|
30684
|
+
/* end_public_function */
|
|
30685
|
+
|
|
30686
|
+
/**
|
|
30687
|
+
* ```js
|
|
30688
|
+
* import { EventRepository } from '@amityco/ts-sdk'
|
|
30689
|
+
* const dispose = EventRepository.onEventCreated(event => {
|
|
30690
|
+
* // ...
|
|
30691
|
+
* })
|
|
30692
|
+
* ```
|
|
30693
|
+
*
|
|
30694
|
+
* Fired when a {@link Amity.Event} has been created
|
|
30695
|
+
*
|
|
30696
|
+
* @param callback The function to call when the event was fired
|
|
30697
|
+
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
30698
|
+
*
|
|
30699
|
+
* @category Event Events
|
|
30700
|
+
*/
|
|
30701
|
+
const onEventCreated = (callback) => createEventEventSubscriber('event.created', callback);
|
|
30702
|
+
|
|
30703
|
+
/**
|
|
30704
|
+
* ```js
|
|
30705
|
+
* import { EventRepository } from '@amityco/ts-sdk'
|
|
30706
|
+
* const dispose = EventRepository.onEventUpdated(event => {
|
|
30707
|
+
* // ...
|
|
30708
|
+
* })
|
|
30709
|
+
* ```
|
|
30710
|
+
*
|
|
30711
|
+
* Fired when a {@link Amity.Event} has been updated
|
|
30712
|
+
*
|
|
30713
|
+
* @param callback The function to call when the event was fired
|
|
30714
|
+
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
30715
|
+
*
|
|
30716
|
+
* @category Event Events
|
|
30717
|
+
*/
|
|
30718
|
+
const onEventUpdated = (callback) => createEventEventSubscriber('event.updated', callback);
|
|
30719
|
+
|
|
30720
|
+
/**
|
|
30721
|
+
* ```js
|
|
30722
|
+
* import { EventRepository } from '@amityco/ts-sdk'
|
|
30723
|
+
* const dispose = EventRepository.onEventDeleted(event => {
|
|
30724
|
+
* // ...
|
|
30725
|
+
* })
|
|
30726
|
+
* ```
|
|
30727
|
+
*
|
|
30728
|
+
* Fired when a {@link Amity.Event} has been deleted
|
|
30729
|
+
*
|
|
30730
|
+
* @param callback The function to call when the event was fired
|
|
30731
|
+
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
30732
|
+
*
|
|
30733
|
+
* @category Event Events
|
|
30734
|
+
*/
|
|
30735
|
+
const onEventDeleted = (callback) => createEventEventSubscriber('event.deleted', callback);
|
|
30736
|
+
|
|
30737
|
+
/**
|
|
30738
|
+
* ```js
|
|
30739
|
+
* import { EventRepository } from '@amityco/ts-sdk'
|
|
30740
|
+
* const dispose = EventRepository.onLocalEventCreated(event => {
|
|
30741
|
+
* // ...
|
|
30742
|
+
* })
|
|
30743
|
+
* ```
|
|
30744
|
+
*
|
|
30745
|
+
* Fired when a {@link Amity.Event} has been created
|
|
30746
|
+
*
|
|
30747
|
+
* @param callback The function to call when the event was fired
|
|
30748
|
+
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
30749
|
+
*
|
|
30750
|
+
* @category Event Events
|
|
30751
|
+
*/
|
|
30752
|
+
const onLocalEventCreated = (callback) => createEventEventSubscriber('local.event.created', callback);
|
|
30753
|
+
|
|
30754
|
+
/**
|
|
30755
|
+
* ```js
|
|
30756
|
+
* import { EventRepository } from '@amityco/ts-sdk'
|
|
30757
|
+
* const dispose = EventRepository.onLocalEventUpdated(event => {
|
|
30758
|
+
* // ...
|
|
30759
|
+
* })
|
|
30760
|
+
* ```
|
|
30761
|
+
*
|
|
30762
|
+
* Fired when a {@link Amity.Event} has been updated
|
|
30763
|
+
*
|
|
30764
|
+
* @param callback The function to call when the event was fired
|
|
30765
|
+
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
30766
|
+
*
|
|
30767
|
+
* @category Event Events
|
|
30768
|
+
*/
|
|
30769
|
+
const onLocalEventUpdated = (callback) => createEventEventSubscriber('local.event.updated', callback);
|
|
30770
|
+
|
|
30771
|
+
/**
|
|
30772
|
+
* ```js
|
|
30773
|
+
* import { EventRepository } from '@amityco/ts-sdk'
|
|
30774
|
+
* const dispose = EventRepository.onLocalEventDeleted(event => {
|
|
30775
|
+
* // ...
|
|
30776
|
+
* })
|
|
30777
|
+
* ```
|
|
30778
|
+
*
|
|
30779
|
+
* Fired when a {@link Amity.Event} has been deleted
|
|
30780
|
+
*
|
|
30781
|
+
* @param callback The function to call when the event was fired
|
|
30782
|
+
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
30783
|
+
*
|
|
30784
|
+
* @category Event Events
|
|
30785
|
+
*/
|
|
30786
|
+
const onLocalEventDeleted = (callback) => createEventEventSubscriber('local.event.deleted', callback);
|
|
30787
|
+
|
|
30788
|
+
/**
|
|
30789
|
+
* ```js
|
|
30790
|
+
* import { EventRepository } from '@amityco/ts-sdk'
|
|
30791
|
+
* const dispose = EventRepository.onRSVPCreated(event => {
|
|
30792
|
+
* // ...
|
|
30793
|
+
* })
|
|
30794
|
+
* ```
|
|
30795
|
+
*
|
|
30796
|
+
* Fired when a {@link Amity.Event} has been created
|
|
30797
|
+
*
|
|
30798
|
+
* @param callback The function to call when the event was fired
|
|
30799
|
+
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
30800
|
+
*
|
|
30801
|
+
* @category Event Events
|
|
30802
|
+
*/
|
|
30803
|
+
const onRSVPCreated = (callback) => createEventEventSubscriber('event.rsvp.created', callback);
|
|
30804
|
+
|
|
30805
|
+
/**
|
|
30806
|
+
* ```js
|
|
30807
|
+
* import { EventRepository } from '@amityco/ts-sdk'
|
|
30808
|
+
* const dispose = EventRepository.onRSVPUpdated(event => {
|
|
30809
|
+
* // ...
|
|
30810
|
+
* })
|
|
30811
|
+
* ```
|
|
30812
|
+
*
|
|
30813
|
+
* Fired when a {@link Amity.Event} has been updated
|
|
30814
|
+
*
|
|
30815
|
+
* @param callback The function to call when the event was fired
|
|
30816
|
+
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
30817
|
+
*
|
|
30818
|
+
* @category Event Events
|
|
30819
|
+
*/
|
|
30820
|
+
const onRSVPUpdated = (callback) => createEventEventSubscriber('event.rsvp.updated', callback);
|
|
30821
|
+
|
|
30822
|
+
/**
|
|
30823
|
+
* ```js
|
|
30824
|
+
* import { EventRepository } from '@amityco/ts-sdk'
|
|
30825
|
+
* const dispose = EventRepository.onLocalRSVPCreated(event => {
|
|
30826
|
+
* // ...
|
|
30827
|
+
* })
|
|
30828
|
+
* ```
|
|
30829
|
+
*
|
|
30830
|
+
* Fired when a {@link Amity.Event} has been created
|
|
30831
|
+
*
|
|
30832
|
+
* @param callback The function to call when the event was fired
|
|
30833
|
+
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
30834
|
+
*
|
|
30835
|
+
* @category Event Events
|
|
30836
|
+
*/
|
|
30837
|
+
const onLocalRSVPCreated = (callback) => createEventEventSubscriber('local.rsvp.created', callback);
|
|
30838
|
+
|
|
30839
|
+
/**
|
|
30840
|
+
* ```js
|
|
30841
|
+
* import { EventRepository } from '@amityco/ts-sdk'
|
|
30842
|
+
* const dispose = EventRepository.onLocalEventUpdated(event => {
|
|
30843
|
+
* // ...
|
|
30844
|
+
* })
|
|
30845
|
+
* ```
|
|
30846
|
+
*
|
|
30847
|
+
* Fired when a {@link Amity.Event} has been updated
|
|
30848
|
+
*
|
|
30849
|
+
* @param callback The function to call when the event was fired
|
|
30850
|
+
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
30851
|
+
*
|
|
30852
|
+
* @category Event Events
|
|
30853
|
+
*/
|
|
30854
|
+
const onLocalRSVPUpdated = (callback) => createEventEventSubscriber('local.rsvp.updated', callback);
|
|
30855
|
+
|
|
30856
|
+
/* begin_public_function
|
|
30857
|
+
id: event.get
|
|
30858
|
+
*/
|
|
30859
|
+
/**
|
|
30860
|
+
* ```js
|
|
30861
|
+
* import { EventRepository } from '@amityco/ts-sdk';
|
|
30862
|
+
*
|
|
30863
|
+
* let event;
|
|
30864
|
+
*
|
|
30865
|
+
* const unsubscribe = EventRepository.getEvent(eventId, response => {
|
|
30866
|
+
* event = response.data;
|
|
30867
|
+
* });
|
|
30868
|
+
* ```
|
|
30869
|
+
*
|
|
30870
|
+
* Observe all mutation on a given {@link Amity.Event}
|
|
30871
|
+
*
|
|
30872
|
+
* @param eventId the ID of the event to observe
|
|
30873
|
+
* @param callback the function to call when new snapshot of event are available
|
|
30874
|
+
* @returns An {@link Amity.Unsubscriber} function to run when willing to stop observing the event
|
|
30875
|
+
*
|
|
30876
|
+
* @category Event Live Object
|
|
30877
|
+
*/
|
|
30878
|
+
const getEvent = (eventId, callback) => {
|
|
30879
|
+
return liveObject(eventId, callback, 'eventId', getEvent$1, [onEventUpdated, onEventDeleted, onLocalEventUpdated, onLocalEventDeleted], {
|
|
30880
|
+
callbackDataSelector: (data) => (data ? eventLinkedObject(data) : data),
|
|
30881
|
+
});
|
|
30882
|
+
};
|
|
30883
|
+
/* end_public_function */
|
|
30884
|
+
|
|
30885
|
+
var EventActionsEnum;
|
|
30886
|
+
(function (EventActionsEnum) {
|
|
30887
|
+
EventActionsEnum["OnEventCreated"] = "onEventCreated";
|
|
30888
|
+
EventActionsEnum["OnEventUpdated"] = "onEventUpdated";
|
|
30889
|
+
EventActionsEnum["OnEventDeleted"] = "onEventDeleted";
|
|
30890
|
+
EventActionsEnum["OnRSVPCreated"] = "onRSVPCreated";
|
|
30891
|
+
EventActionsEnum["OnRSVPUpdated"] = "onRSVPUpdated";
|
|
30892
|
+
})(EventActionsEnum || (EventActionsEnum = {}));
|
|
30893
|
+
|
|
30894
|
+
class EventPaginationController extends PaginationController {
|
|
30895
|
+
async getRequest(queryParams, token) {
|
|
30896
|
+
const { limit = COLLECTION_DEFAULT_PAGINATION_LIMIT } = queryParams, params = __rest(queryParams, ["limit"]);
|
|
30897
|
+
const options = token ? { token } : { limit };
|
|
30898
|
+
const { data: response } = await this.http.get(`/api/v1/events`, { params: Object.assign(Object.assign({}, params), { options }) });
|
|
30899
|
+
return response;
|
|
30900
|
+
}
|
|
30901
|
+
}
|
|
30902
|
+
|
|
30903
|
+
class EventQueryStreamController extends QueryStreamController {
|
|
30904
|
+
constructor(query, cacheKey, notifyChange, preparePayload) {
|
|
30905
|
+
super(query, cacheKey);
|
|
30906
|
+
this.notifyChange = notifyChange;
|
|
30907
|
+
this.preparePayload = preparePayload;
|
|
30908
|
+
}
|
|
30909
|
+
async saveToMainDB(response) {
|
|
30910
|
+
const processedPayload = this.preparePayload(response);
|
|
30911
|
+
const client = getActiveClient();
|
|
30912
|
+
const cachedAt = client.cache && Date.now();
|
|
30913
|
+
if (client.cache)
|
|
30914
|
+
ingestInCache(processedPayload, { cachedAt });
|
|
30915
|
+
}
|
|
30916
|
+
appendToQueryStream(response, direction, refresh = false) {
|
|
30917
|
+
var _a, _b;
|
|
30918
|
+
if (refresh) {
|
|
30919
|
+
pushToCache(this.cacheKey, { data: response.events.map(getResolver('event')) });
|
|
30920
|
+
}
|
|
30921
|
+
else {
|
|
30922
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
30923
|
+
const events = (_b = collection === null || collection === void 0 ? void 0 : collection.data) !== null && _b !== void 0 ? _b : [];
|
|
30924
|
+
pushToCache(this.cacheKey, Object.assign(Object.assign({}, collection), { data: [...new Set([...events, ...response.events.map(getResolver('event'))])] }));
|
|
30925
|
+
}
|
|
30926
|
+
}
|
|
30927
|
+
reactor(action) {
|
|
30928
|
+
return (event) => {
|
|
30929
|
+
var _a;
|
|
30930
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
30931
|
+
if (!collection)
|
|
30932
|
+
return;
|
|
30933
|
+
if (action === EventActionsEnum.OnEventCreated) {
|
|
30934
|
+
collection.data = [...new Set([event.eventId, ...collection.data])];
|
|
30935
|
+
}
|
|
30936
|
+
if (action === EventActionsEnum.OnEventDeleted) {
|
|
30937
|
+
collection.data = collection.data.filter(eventId => eventId !== event.eventId);
|
|
30938
|
+
}
|
|
30939
|
+
pushToCache(this.cacheKey, collection);
|
|
30940
|
+
this.notifyChange({ origin: "event" /* Amity.LiveDataOrigin.EVENT */, loading: false });
|
|
30941
|
+
};
|
|
30942
|
+
}
|
|
30943
|
+
subscribeRTE(createSubscriber) {
|
|
30944
|
+
return createSubscriber.map(subscriber => subscriber.fn(this.reactor(subscriber.action)));
|
|
30945
|
+
}
|
|
30946
|
+
}
|
|
30947
|
+
|
|
30948
|
+
class EventLiveCollectionController extends LiveCollectionController {
|
|
30949
|
+
constructor(query, callback) {
|
|
30950
|
+
const queryStreamId = hash__default["default"](query);
|
|
30951
|
+
const cacheKey = ['event', 'collection', queryStreamId];
|
|
30952
|
+
const paginationController = new EventPaginationController(query);
|
|
30953
|
+
super(paginationController, queryStreamId, cacheKey, callback);
|
|
30954
|
+
this.query = query;
|
|
30955
|
+
this.queryStreamController = new EventQueryStreamController(this.query, this.cacheKey, this.notifyChange.bind(this), prepareEventPayload);
|
|
30956
|
+
this.callback = callback.bind(this);
|
|
30957
|
+
this.loadPage({ initial: true });
|
|
30958
|
+
}
|
|
30959
|
+
setup() {
|
|
30960
|
+
var _a;
|
|
30961
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
30962
|
+
if (!collection)
|
|
30963
|
+
pushToCache(this.cacheKey, { data: [], params: {} });
|
|
30964
|
+
}
|
|
30965
|
+
async persistModel(queryPayload) {
|
|
30966
|
+
await this.queryStreamController.saveToMainDB(queryPayload);
|
|
30967
|
+
}
|
|
30968
|
+
persistQueryStream({ response, direction, refresh, }) {
|
|
30969
|
+
this.queryStreamController.appendToQueryStream(response, direction, refresh);
|
|
30970
|
+
}
|
|
30971
|
+
startSubscription() {
|
|
30972
|
+
return this.queryStreamController.subscribeRTE([
|
|
30973
|
+
{ fn: onEventCreated, action: EventActionsEnum.OnEventCreated },
|
|
30974
|
+
{ fn: onEventUpdated, action: EventActionsEnum.OnEventUpdated },
|
|
30975
|
+
{ fn: onEventDeleted, action: EventActionsEnum.OnEventDeleted },
|
|
30976
|
+
{ fn: onLocalEventCreated, action: EventActionsEnum.OnEventCreated },
|
|
30977
|
+
{ fn: onLocalEventUpdated, action: EventActionsEnum.OnEventUpdated },
|
|
30978
|
+
{ fn: onLocalEventDeleted, action: EventActionsEnum.OnEventDeleted },
|
|
30979
|
+
]);
|
|
30980
|
+
}
|
|
30981
|
+
notifyChange({ origin, loading, error }) {
|
|
30982
|
+
var _a, _b;
|
|
30983
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
30984
|
+
if (!collection)
|
|
30985
|
+
return;
|
|
30986
|
+
const data = ((_b = collection.data
|
|
30987
|
+
.map(eventId => pullFromCache(['event', 'get', eventId]))
|
|
30988
|
+
.filter(isNonNullable)
|
|
30989
|
+
.map(({ data }) => data)) !== null && _b !== void 0 ? _b : []).map(LinkedObject.event);
|
|
30990
|
+
if (!this.shouldNotify(data) && origin === "event" /* Amity.LiveDataOrigin.EVENT */)
|
|
30991
|
+
return;
|
|
30992
|
+
this.callback({
|
|
30993
|
+
data,
|
|
30994
|
+
error,
|
|
30995
|
+
loading,
|
|
30996
|
+
hasNextPage: !!this.paginationController.getNextToken(),
|
|
30997
|
+
onNextPage: () => this.loadPage({ direction: "next" /* Amity.LiveCollectionPageDirection.NEXT */ }),
|
|
30998
|
+
});
|
|
30999
|
+
}
|
|
31000
|
+
}
|
|
31001
|
+
|
|
31002
|
+
/**
|
|
31003
|
+
* Get events
|
|
31004
|
+
*
|
|
31005
|
+
* @param params the query parameters
|
|
31006
|
+
* @param callback the callback to be called when the events are updated
|
|
31007
|
+
* @returns events
|
|
31008
|
+
*
|
|
31009
|
+
* @category Event Live Collection
|
|
31010
|
+
*
|
|
31011
|
+
*/
|
|
31012
|
+
const getEvents = (params, callback, config) => {
|
|
31013
|
+
const { log, cache } = getActiveClient();
|
|
31014
|
+
if (!cache)
|
|
31015
|
+
console.log(ENABLE_CACHE_MESSAGE);
|
|
31016
|
+
const timestamp = Date.now();
|
|
31017
|
+
log(`getEvents: (tmpid: ${timestamp}) > listen`);
|
|
31018
|
+
const eventLiveCollection = new EventLiveCollectionController(params, callback);
|
|
31019
|
+
const disposers = eventLiveCollection.startSubscription();
|
|
31020
|
+
const cacheKey = eventLiveCollection.getCacheKey();
|
|
31021
|
+
disposers.push(() => dropFromCache(cacheKey));
|
|
31022
|
+
return () => {
|
|
31023
|
+
log(`getEvents (tmpid: ${timestamp}) > dispose`);
|
|
31024
|
+
disposers.forEach(fn => fn());
|
|
31025
|
+
};
|
|
31026
|
+
};
|
|
31027
|
+
|
|
31028
|
+
class MyEventPaginationController extends PaginationController {
|
|
31029
|
+
async getRequest(queryParams, token) {
|
|
31030
|
+
const { limit = COLLECTION_DEFAULT_PAGINATION_LIMIT } = queryParams, params = __rest(queryParams, ["limit"]);
|
|
31031
|
+
const options = token ? { token } : { limit };
|
|
31032
|
+
const { data: response } = await this.http.get(`/api/v1/events/me/rsvps`, { params: Object.assign(Object.assign({}, params), { options }) });
|
|
31033
|
+
return response;
|
|
31034
|
+
}
|
|
31035
|
+
}
|
|
31036
|
+
|
|
31037
|
+
class MyEventQueryStreamController extends QueryStreamController {
|
|
31038
|
+
constructor(query, cacheKey, notifyChange, preparePayload) {
|
|
31039
|
+
super(query, cacheKey);
|
|
31040
|
+
this.notifyChange = notifyChange;
|
|
31041
|
+
this.preparePayload = preparePayload;
|
|
31042
|
+
}
|
|
31043
|
+
async saveToMainDB(response) {
|
|
31044
|
+
const processedPayload = this.preparePayload(response);
|
|
31045
|
+
const client = getActiveClient();
|
|
31046
|
+
const cachedAt = client.cache && Date.now();
|
|
31047
|
+
if (client.cache)
|
|
31048
|
+
ingestInCache(processedPayload, { cachedAt });
|
|
31049
|
+
}
|
|
31050
|
+
appendToQueryStream(response, direction, refresh = false) {
|
|
31051
|
+
var _a, _b;
|
|
31052
|
+
if (refresh) {
|
|
31053
|
+
pushToCache(this.cacheKey, { data: response.events.map(getResolver('event')) });
|
|
31054
|
+
}
|
|
31055
|
+
else {
|
|
31056
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
31057
|
+
const events = (_b = collection === null || collection === void 0 ? void 0 : collection.data) !== null && _b !== void 0 ? _b : [];
|
|
31058
|
+
pushToCache(this.cacheKey, Object.assign(Object.assign({}, collection), { data: [...new Set([...events, ...response.events.map(getResolver('event'))])] }));
|
|
31059
|
+
}
|
|
31060
|
+
}
|
|
31061
|
+
reactor(action) {
|
|
31062
|
+
return (event) => {
|
|
31063
|
+
var _a;
|
|
31064
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
31065
|
+
if (!collection)
|
|
31066
|
+
return;
|
|
31067
|
+
if (action === EventActionsEnum.OnEventCreated) {
|
|
31068
|
+
const client = getActiveClient();
|
|
31069
|
+
if (client.userId !== event.userId)
|
|
31070
|
+
return;
|
|
31071
|
+
collection.data = [...new Set([event.eventId, ...collection.data])];
|
|
31072
|
+
}
|
|
31073
|
+
if (action === EventActionsEnum.OnEventDeleted) {
|
|
31074
|
+
collection.data = collection.data.filter(eventId => eventId !== event.eventId);
|
|
31075
|
+
}
|
|
31076
|
+
pushToCache(this.cacheKey, collection);
|
|
31077
|
+
this.notifyChange({ origin: "event" /* Amity.LiveDataOrigin.EVENT */, loading: false });
|
|
31078
|
+
};
|
|
31079
|
+
}
|
|
31080
|
+
subscribeRTE(createSubscriber) {
|
|
31081
|
+
return createSubscriber.map(subscriber => subscriber.fn(this.reactor(subscriber.action)));
|
|
31082
|
+
}
|
|
31083
|
+
}
|
|
31084
|
+
|
|
31085
|
+
class MyEventLiveCollectionController extends LiveCollectionController {
|
|
31086
|
+
constructor(query, callback) {
|
|
31087
|
+
const queryStreamId = hash__default["default"](query);
|
|
31088
|
+
const cacheKey = ['event', 'collection', queryStreamId];
|
|
31089
|
+
const paginationController = new MyEventPaginationController(query);
|
|
31090
|
+
super(paginationController, queryStreamId, cacheKey, callback);
|
|
31091
|
+
this.query = query;
|
|
31092
|
+
this.queryStreamController = new MyEventQueryStreamController(this.query, this.cacheKey, this.notifyChange.bind(this), prepareEventPayload);
|
|
31093
|
+
this.callback = callback.bind(this);
|
|
31094
|
+
this.loadPage({ initial: true });
|
|
31095
|
+
}
|
|
31096
|
+
setup() {
|
|
31097
|
+
var _a;
|
|
31098
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
31099
|
+
if (!collection)
|
|
31100
|
+
pushToCache(this.cacheKey, { data: [], params: {} });
|
|
31101
|
+
}
|
|
31102
|
+
async persistModel(queryPayload) {
|
|
31103
|
+
await this.queryStreamController.saveToMainDB(queryPayload);
|
|
31104
|
+
}
|
|
31105
|
+
persistQueryStream({ response, direction, refresh, }) {
|
|
31106
|
+
this.queryStreamController.appendToQueryStream(response, direction, refresh);
|
|
31107
|
+
}
|
|
31108
|
+
startSubscription() {
|
|
31109
|
+
return this.queryStreamController.subscribeRTE([
|
|
31110
|
+
{ fn: onEventCreated, action: EventActionsEnum.OnEventCreated },
|
|
31111
|
+
{ fn: onEventUpdated, action: EventActionsEnum.OnEventUpdated },
|
|
31112
|
+
{ fn: onEventDeleted, action: EventActionsEnum.OnEventDeleted },
|
|
31113
|
+
{ fn: onLocalEventCreated, action: EventActionsEnum.OnEventCreated },
|
|
31114
|
+
{ fn: onLocalEventUpdated, action: EventActionsEnum.OnEventUpdated },
|
|
31115
|
+
{ fn: onLocalEventDeleted, action: EventActionsEnum.OnEventDeleted },
|
|
31116
|
+
]);
|
|
31117
|
+
}
|
|
31118
|
+
notifyChange({ origin, loading, error }) {
|
|
31119
|
+
var _a, _b;
|
|
31120
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
31121
|
+
if (!collection)
|
|
31122
|
+
return;
|
|
31123
|
+
const data = ((_b = collection.data
|
|
31124
|
+
.map(eventId => pullFromCache(['event', 'get', eventId]))
|
|
31125
|
+
.filter(isNonNullable)
|
|
31126
|
+
.map(({ data }) => data)) !== null && _b !== void 0 ? _b : []).map(LinkedObject.event);
|
|
31127
|
+
if (!this.shouldNotify(data) && origin === "event" /* Amity.LiveDataOrigin.EVENT */)
|
|
31128
|
+
return;
|
|
31129
|
+
this.callback({
|
|
31130
|
+
data,
|
|
31131
|
+
error,
|
|
31132
|
+
loading,
|
|
31133
|
+
hasNextPage: !!this.paginationController.getNextToken(),
|
|
31134
|
+
onNextPage: () => this.loadPage({ direction: "next" /* Amity.LiveCollectionPageDirection.NEXT */ }),
|
|
31135
|
+
});
|
|
31136
|
+
}
|
|
31137
|
+
}
|
|
31138
|
+
|
|
31139
|
+
/**
|
|
31140
|
+
* Get my events
|
|
31141
|
+
*
|
|
31142
|
+
* @param params the query parameters
|
|
31143
|
+
* @param callback the callback to be called when the events are updated
|
|
31144
|
+
* @returns events
|
|
31145
|
+
*
|
|
31146
|
+
* @category Event Live Collection
|
|
31147
|
+
*
|
|
31148
|
+
*/
|
|
31149
|
+
const getMyEvents = (params, callback, config) => {
|
|
31150
|
+
const { log, cache } = getActiveClient();
|
|
31151
|
+
if (!cache)
|
|
31152
|
+
console.log(ENABLE_CACHE_MESSAGE);
|
|
31153
|
+
const timestamp = Date.now();
|
|
31154
|
+
log(`getMyEvents: (tmpid: ${timestamp}) > listen`);
|
|
31155
|
+
const myEventLiveCollection = new MyEventLiveCollectionController(params, callback);
|
|
31156
|
+
const disposers = myEventLiveCollection.startSubscription();
|
|
31157
|
+
const cacheKey = myEventLiveCollection.getCacheKey();
|
|
31158
|
+
disposers.push(() => dropFromCache(cacheKey));
|
|
31159
|
+
return () => {
|
|
31160
|
+
log(`getMyEvents (tmpid: ${timestamp}) > dispose`);
|
|
31161
|
+
disposers.forEach(fn => fn());
|
|
31162
|
+
};
|
|
31163
|
+
};
|
|
31164
|
+
|
|
31165
|
+
class RSVPPaginationController extends PaginationController {
|
|
31166
|
+
async getRequest(queryParams, token) {
|
|
31167
|
+
const { limit = COLLECTION_DEFAULT_PAGINATION_LIMIT, eventId } = queryParams, params = __rest(queryParams, ["limit", "eventId"]);
|
|
31168
|
+
const options = token ? { token } : { limit };
|
|
31169
|
+
const { data: response } = await this.http.get(`/api/v1/events/${eventId}/rsvps`, { params: Object.assign(Object.assign({}, params), { options }) });
|
|
31170
|
+
return response;
|
|
31171
|
+
}
|
|
31172
|
+
}
|
|
31173
|
+
|
|
31174
|
+
class RSVPQueryStreamController extends QueryStreamController {
|
|
31175
|
+
constructor(query, cacheKey, notifyChange, preparePayload) {
|
|
31176
|
+
super(query, cacheKey);
|
|
31177
|
+
this.notifyChange = notifyChange;
|
|
31178
|
+
this.preparePayload = preparePayload;
|
|
31179
|
+
}
|
|
31180
|
+
async saveToMainDB(response) {
|
|
31181
|
+
const processedPayload = this.preparePayload(response);
|
|
31182
|
+
const client = getActiveClient();
|
|
31183
|
+
const cachedAt = client.cache && Date.now();
|
|
31184
|
+
if (client.cache)
|
|
31185
|
+
ingestInCache(processedPayload, { cachedAt });
|
|
31186
|
+
}
|
|
31187
|
+
appendToQueryStream(response, direction, refresh = false) {
|
|
31188
|
+
var _a, _b;
|
|
31189
|
+
if (refresh) {
|
|
31190
|
+
pushToCache(this.cacheKey, { data: response.events.map(getResolver('event')) });
|
|
31191
|
+
}
|
|
31192
|
+
else {
|
|
31193
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
31194
|
+
const events = (_b = collection === null || collection === void 0 ? void 0 : collection.data) !== null && _b !== void 0 ? _b : [];
|
|
31195
|
+
pushToCache(this.cacheKey, Object.assign(Object.assign({}, collection), { data: [...new Set([...events, ...response.events.map(getResolver('event'))])] }));
|
|
31196
|
+
}
|
|
31197
|
+
}
|
|
31198
|
+
reactor(action) {
|
|
31199
|
+
return (event) => {
|
|
31200
|
+
var _a;
|
|
31201
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
31202
|
+
if (!collection)
|
|
31203
|
+
return;
|
|
31204
|
+
if (action === EventActionsEnum.OnEventCreated) {
|
|
31205
|
+
const client = getActiveClient();
|
|
31206
|
+
if (client.userId !== event.userId)
|
|
31207
|
+
return;
|
|
31208
|
+
collection.data = [...new Set([event.eventId, ...collection.data])];
|
|
31209
|
+
}
|
|
31210
|
+
if (action === EventActionsEnum.OnEventDeleted) {
|
|
31211
|
+
collection.data = collection.data.filter(eventId => eventId !== event.eventId);
|
|
31212
|
+
}
|
|
31213
|
+
pushToCache(this.cacheKey, collection);
|
|
31214
|
+
this.notifyChange({ origin: "event" /* Amity.LiveDataOrigin.EVENT */, loading: false });
|
|
31215
|
+
};
|
|
31216
|
+
}
|
|
31217
|
+
subscribeRTE(createSubscriber) {
|
|
31218
|
+
return createSubscriber.map(subscriber => subscriber.fn(this.reactor(subscriber.action)));
|
|
31219
|
+
}
|
|
31220
|
+
}
|
|
31221
|
+
|
|
31222
|
+
class RSVPLiveCollectionController extends LiveCollectionController {
|
|
31223
|
+
constructor(query, callback) {
|
|
31224
|
+
const queryStreamId = hash__default["default"](query);
|
|
31225
|
+
const cacheKey = ['event', 'collection', queryStreamId];
|
|
31226
|
+
const paginationController = new RSVPPaginationController(query);
|
|
31227
|
+
super(paginationController, queryStreamId, cacheKey, callback);
|
|
31228
|
+
this.query = query;
|
|
31229
|
+
this.queryStreamController = new RSVPQueryStreamController(this.query, this.cacheKey, this.notifyChange.bind(this), prepareEventPayload);
|
|
31230
|
+
this.callback = callback.bind(this);
|
|
31231
|
+
this.loadPage({ initial: true });
|
|
31232
|
+
}
|
|
31233
|
+
setup() {
|
|
31234
|
+
var _a;
|
|
31235
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
31236
|
+
if (!collection)
|
|
31237
|
+
pushToCache(this.cacheKey, { data: [], params: {} });
|
|
31238
|
+
}
|
|
31239
|
+
async persistModel(queryPayload) {
|
|
31240
|
+
await this.queryStreamController.saveToMainDB(queryPayload);
|
|
31241
|
+
}
|
|
31242
|
+
persistQueryStream({ response, direction, refresh, }) {
|
|
31243
|
+
this.queryStreamController.appendToQueryStream(response, direction, refresh);
|
|
31244
|
+
}
|
|
31245
|
+
startSubscription() {
|
|
31246
|
+
return this.queryStreamController.subscribeRTE([
|
|
31247
|
+
{ fn: onRSVPCreated, action: EventActionsEnum.OnRSVPCreated },
|
|
31248
|
+
{ fn: onRSVPUpdated, action: EventActionsEnum.OnRSVPUpdated },
|
|
31249
|
+
{ fn: onLocalRSVPCreated, action: EventActionsEnum.OnRSVPCreated },
|
|
31250
|
+
{ fn: onLocalRSVPUpdated, action: EventActionsEnum.OnRSVPUpdated },
|
|
31251
|
+
]);
|
|
31252
|
+
}
|
|
31253
|
+
notifyChange({ origin, loading, error }) {
|
|
31254
|
+
var _a, _b;
|
|
31255
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
31256
|
+
if (!collection)
|
|
31257
|
+
return;
|
|
31258
|
+
const data = ((_b = collection.data
|
|
31259
|
+
.map(eventId => pullFromCache(['event', 'get', eventId]))
|
|
31260
|
+
.filter(isNonNullable)
|
|
31261
|
+
.map(({ data }) => data)) !== null && _b !== void 0 ? _b : []).map(LinkedObject.event);
|
|
31262
|
+
if (!this.shouldNotify(data) && origin === "event" /* Amity.LiveDataOrigin.EVENT */)
|
|
31263
|
+
return;
|
|
31264
|
+
this.callback({
|
|
31265
|
+
data,
|
|
31266
|
+
error,
|
|
31267
|
+
loading,
|
|
31268
|
+
hasNextPage: !!this.paginationController.getNextToken(),
|
|
31269
|
+
onNextPage: () => this.loadPage({ direction: "next" /* Amity.LiveCollectionPageDirection.NEXT */ }),
|
|
31270
|
+
});
|
|
31271
|
+
}
|
|
31272
|
+
}
|
|
31273
|
+
|
|
31274
|
+
/**
|
|
31275
|
+
* Get events
|
|
31276
|
+
*
|
|
31277
|
+
* @param params the query parameters
|
|
31278
|
+
* @param callback the callback to be called when the events are updated
|
|
31279
|
+
* @returns events
|
|
31280
|
+
*
|
|
31281
|
+
* @category RSVP Live Collection
|
|
31282
|
+
*
|
|
31283
|
+
*/
|
|
31284
|
+
const getRSVPs = (params, callback, config) => {
|
|
31285
|
+
const { log, cache } = getActiveClient();
|
|
31286
|
+
if (!cache)
|
|
31287
|
+
console.log(ENABLE_CACHE_MESSAGE);
|
|
31288
|
+
const timestamp = Date.now();
|
|
31289
|
+
log(`getRSVPs: (tmpid: ${timestamp}) > listen`);
|
|
31290
|
+
const eventLiveCollection = new RSVPLiveCollectionController(params, callback);
|
|
31291
|
+
const disposers = eventLiveCollection.startSubscription();
|
|
31292
|
+
const cacheKey = eventLiveCollection.getCacheKey();
|
|
31293
|
+
disposers.push(() => dropFromCache(cacheKey));
|
|
31294
|
+
return () => {
|
|
31295
|
+
log(`getRSVPs (tmpid: ${timestamp}) > dispose`);
|
|
31296
|
+
disposers.forEach(fn => fn());
|
|
31297
|
+
};
|
|
31298
|
+
};
|
|
31299
|
+
|
|
31300
|
+
var index = /*#__PURE__*/Object.freeze({
|
|
31301
|
+
__proto__: null,
|
|
31302
|
+
createEvent: createEvent,
|
|
31303
|
+
updateEvent: updateEvent,
|
|
31304
|
+
deleteEvent: deleteEvent,
|
|
31305
|
+
onEventCreated: onEventCreated,
|
|
31306
|
+
onEventUpdated: onEventUpdated,
|
|
31307
|
+
onEventDeleted: onEventDeleted,
|
|
31308
|
+
onLocalEventCreated: onLocalEventCreated,
|
|
31309
|
+
onLocalEventUpdated: onLocalEventUpdated,
|
|
31310
|
+
onLocalEventDeleted: onLocalEventDeleted,
|
|
31311
|
+
onRSVPCreated: onRSVPCreated,
|
|
31312
|
+
onRSVPUpdated: onRSVPUpdated,
|
|
31313
|
+
onLocalRSVPCreated: onLocalRSVPCreated,
|
|
31314
|
+
onLocalRSVPUpdated: onLocalRSVPUpdated,
|
|
31315
|
+
getEvent: getEvent,
|
|
31316
|
+
getEvents: getEvents,
|
|
31317
|
+
getMyEvents: getMyEvents,
|
|
31318
|
+
getRSVPs: getRSVPs
|
|
31319
|
+
});
|
|
31320
|
+
|
|
30296
31321
|
exports.API_REGIONS = API_REGIONS;
|
|
30297
|
-
exports.AdRepository = index$
|
|
30298
|
-
exports.CategoryRepository = index$
|
|
30299
|
-
exports.ChannelRepository = index$
|
|
30300
|
-
exports.Client = index$
|
|
30301
|
-
exports.CommentRepository = index$
|
|
31322
|
+
exports.AdRepository = index$4;
|
|
31323
|
+
exports.CategoryRepository = index$c;
|
|
31324
|
+
exports.ChannelRepository = index$g;
|
|
31325
|
+
exports.Client = index$p;
|
|
31326
|
+
exports.CommentRepository = index$b;
|
|
30302
31327
|
exports.CommunityPostSettingMaps = CommunityPostSettingMaps;
|
|
30303
31328
|
exports.CommunityPostSettings = CommunityPostSettings;
|
|
30304
|
-
exports.CommunityRepository = index$
|
|
31329
|
+
exports.CommunityRepository = index$d;
|
|
30305
31330
|
exports.ContentFeedType = ContentFeedType;
|
|
30306
31331
|
exports.DefaultCommunityPostSetting = DefaultCommunityPostSetting;
|
|
30307
|
-
exports.
|
|
30308
|
-
exports.
|
|
31332
|
+
exports.EventRepository = index;
|
|
31333
|
+
exports.FeedRepository = index$a;
|
|
31334
|
+
exports.FileRepository = index$m;
|
|
30309
31335
|
exports.FileType = FileType;
|
|
30310
31336
|
exports.GET_WATCHER_URLS = GET_WATCHER_URLS;
|
|
30311
|
-
exports.InvitationRepository = index$
|
|
30312
|
-
exports.LiveReactionRepository = index;
|
|
30313
|
-
exports.LiveStreamPlayer = index$
|
|
31337
|
+
exports.InvitationRepository = index$2;
|
|
31338
|
+
exports.LiveReactionRepository = index$1;
|
|
31339
|
+
exports.LiveStreamPlayer = index$6;
|
|
30314
31340
|
exports.MessageContentType = MessageContentType;
|
|
30315
|
-
exports.MessageRepository = index$
|
|
30316
|
-
exports.PollRepository = index$
|
|
31341
|
+
exports.MessageRepository = index$k;
|
|
31342
|
+
exports.PollRepository = index$7;
|
|
30317
31343
|
exports.PostContentType = PostContentType;
|
|
30318
|
-
exports.PostRepository = index$
|
|
31344
|
+
exports.PostRepository = index$9;
|
|
30319
31345
|
exports.PostStructureType = PostStructureType;
|
|
30320
|
-
exports.ReactionRepository = index$
|
|
30321
|
-
exports.StoryRepository = index$
|
|
30322
|
-
exports.StreamRepository = index$
|
|
30323
|
-
exports.SubChannelRepository = index$
|
|
30324
|
-
exports.UserRepository = index$
|
|
31346
|
+
exports.ReactionRepository = index$l;
|
|
31347
|
+
exports.StoryRepository = index$5;
|
|
31348
|
+
exports.StreamRepository = index$8;
|
|
31349
|
+
exports.SubChannelRepository = index$j;
|
|
31350
|
+
exports.UserRepository = index$n;
|
|
30325
31351
|
exports.VERSION = VERSION;
|
|
30326
31352
|
exports.VideoResolution = VideoResolution;
|
|
30327
31353
|
exports.VideoSize = VideoSize;
|
|
@@ -30375,7 +31401,7 @@ exports.isPaged = isPaged;
|
|
|
30375
31401
|
exports.isReportedByMe = isReportedByMe;
|
|
30376
31402
|
exports.isSkip = isSkip;
|
|
30377
31403
|
exports.mergeInCache = mergeInCache;
|
|
30378
|
-
exports.notificationTray = index$
|
|
31404
|
+
exports.notificationTray = index$3;
|
|
30379
31405
|
exports.onChannelMarkerFetched = onChannelMarkerFetched;
|
|
30380
31406
|
exports.onFeedMarkerFetched = onFeedMarkerFetched;
|
|
30381
31407
|
exports.onFeedMarkerUpdated = onFeedMarkerUpdated;
|