@amityco/ts-sdk 7.11.1-10e0f4d8.0 → 7.11.1-140ac995.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 +4 -0
- 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 +13 -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/domains/community.d.ts +3 -0
- package/dist/@types/domains/community.d.ts.map +1 -1
- package/dist/@types/domains/event.d.ts +47 -10
- package/dist/@types/domains/event.d.ts.map +1 -1
- package/dist/@types/domains/notification.d.ts +3 -1
- package/dist/@types/domains/notification.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/events/enums.d.ts +3 -1
- package/dist/eventRepository/events/enums.d.ts.map +1 -1
- package/dist/eventRepository/events/index.d.ts +7 -0
- package/dist/eventRepository/events/index.d.ts.map +1 -1
- 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/internalApi/createRSVP.d.ts +16 -0
- package/dist/eventRepository/internalApi/createRSVP.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 +3 -0
- package/dist/eventRepository/internalApi/index.d.ts.map +1 -1
- 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.map +1 -1
- package/dist/eventRepository/observers/getEvents/LiveCollectionController.d.ts.map +1 -1
- 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 +2 -0
- package/dist/eventRepository/observers/index.d.ts.map +1 -1
- package/dist/eventRepository/utils/createEventEventSubscriber.d.ts +1 -1
- package/dist/eventRepository/utils/createEventEventSubscriber.d.ts.map +1 -1
- package/dist/eventRepository/utils/createEventResponseSubscriber.d.ts +2 -0
- package/dist/eventRepository/utils/createEventResponseSubscriber.d.ts.map +1 -0
- package/dist/eventRepository/utils/index.d.ts +2 -0
- package/dist/eventRepository/utils/index.d.ts.map +1 -1
- package/dist/eventRepository/utils/prepareEventResponsePayload.d.ts +2 -0
- package/dist/eventRepository/utils/prepareEventResponsePayload.d.ts.map +1 -0
- package/dist/index.cjs.js +626 -33
- package/dist/index.esm.js +627 -34
- package/dist/index.umd.js +3 -3
- package/dist/utils/linkedObject/eventLinkObject.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs.js
CHANGED
|
@@ -209,6 +209,11 @@ exports.AmityEventStatus = void 0;
|
|
|
209
209
|
AmityEventStatus["Ended"] = "ended";
|
|
210
210
|
AmityEventStatus["Cancelled"] = "cancelled";
|
|
211
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 = {}));
|
|
212
217
|
|
|
213
218
|
function getVersion() {
|
|
214
219
|
try {
|
|
@@ -659,6 +664,8 @@ const idResolvers = {
|
|
|
659
664
|
invitation: ({ _id }) => _id,
|
|
660
665
|
joinRequest: ({ joinRequestId }) => joinRequestId,
|
|
661
666
|
event: ({ eventId }) => eventId,
|
|
667
|
+
eventResponse: ({ eventId }) => eventId,
|
|
668
|
+
discussionCommunity: ({ communityId }) => communityId,
|
|
662
669
|
};
|
|
663
670
|
/**
|
|
664
671
|
* Retrieve the id resolver matching a domain name
|
|
@@ -715,7 +722,8 @@ const PAYLOAD2MODEL = {
|
|
|
715
722
|
invitations: 'invitation',
|
|
716
723
|
joinRequests: 'joinRequest',
|
|
717
724
|
events: 'event',
|
|
718
|
-
|
|
725
|
+
eventResponse: 'eventResponse',
|
|
726
|
+
discussionCommunities: 'discussionCommunity',
|
|
719
727
|
};
|
|
720
728
|
/** hidden */
|
|
721
729
|
const isOutdated = (prevData, nextData) => {
|
|
@@ -13679,6 +13687,185 @@ const communityLinkedObject = (community) => {
|
|
|
13679
13687
|
} });
|
|
13680
13688
|
};
|
|
13681
13689
|
|
|
13690
|
+
const prepareEventResponsePayload = (rawPayload) => {
|
|
13691
|
+
return {
|
|
13692
|
+
status: rawPayload.eventResponses[0].status,
|
|
13693
|
+
eventId: rawPayload.eventResponses[0].eventId,
|
|
13694
|
+
event: rawPayload.events,
|
|
13695
|
+
userId: rawPayload.eventResponses[0].userId,
|
|
13696
|
+
user: rawPayload.users.map(convertRawUserToInternalUser),
|
|
13697
|
+
};
|
|
13698
|
+
};
|
|
13699
|
+
|
|
13700
|
+
/* begin_public_function
|
|
13701
|
+
id: event.rsvp.create
|
|
13702
|
+
*/
|
|
13703
|
+
/**
|
|
13704
|
+
* ```js
|
|
13705
|
+
* import { event } from '@amityco/ts-sdk'
|
|
13706
|
+
* const response = await event.createRSVP(eventId, status)
|
|
13707
|
+
* ```
|
|
13708
|
+
*
|
|
13709
|
+
* Creates an {@link Amity.InternalEvent}
|
|
13710
|
+
*
|
|
13711
|
+
* @param bundle The data necessary to create a new {@link Amity.InternalEvent}
|
|
13712
|
+
* @returns The newly created {@link Amity.InternalEvent}
|
|
13713
|
+
*
|
|
13714
|
+
* @category Event API
|
|
13715
|
+
* @async
|
|
13716
|
+
*/
|
|
13717
|
+
const createRSVP = async (eventId, status) => {
|
|
13718
|
+
const client = getActiveClient();
|
|
13719
|
+
client.log('event/createRSVP', eventId, status);
|
|
13720
|
+
const { data: payload } = await client.http.post(`/api/v1/events/${eventId}/rsvp`, { status });
|
|
13721
|
+
fireEvent('local.rsvp.created', payload);
|
|
13722
|
+
const data = prepareEventResponsePayload(payload);
|
|
13723
|
+
const cachedAt = client.cache && Date.now();
|
|
13724
|
+
if (client.cache)
|
|
13725
|
+
ingestInCache({ eventResponses: [data] }, { cachedAt });
|
|
13726
|
+
return {
|
|
13727
|
+
data,
|
|
13728
|
+
cachedAt,
|
|
13729
|
+
};
|
|
13730
|
+
};
|
|
13731
|
+
/* end_public_function */
|
|
13732
|
+
|
|
13733
|
+
/* begin_public_function
|
|
13734
|
+
id: event.update
|
|
13735
|
+
*/
|
|
13736
|
+
/**
|
|
13737
|
+
* ```js
|
|
13738
|
+
* import { event } from '@amityco/ts-sdk'
|
|
13739
|
+
* const response = await event.updateRSVP(eventId, status)
|
|
13740
|
+
* ```
|
|
13741
|
+
*
|
|
13742
|
+
* Updates an {@link Amity.EventResponse}
|
|
13743
|
+
*
|
|
13744
|
+
* @param eventId The ID of the {@link Amity.EventResponse} to edit
|
|
13745
|
+
* @param bundle The data necessary to update an existing {@link Amity.EventResponse}
|
|
13746
|
+
* @returns the updated {@link Amity.EventResponse}
|
|
13747
|
+
*
|
|
13748
|
+
* @category Event API
|
|
13749
|
+
* @async
|
|
13750
|
+
*/
|
|
13751
|
+
const updateRSVP = async (eventId, status) => {
|
|
13752
|
+
const client = getActiveClient();
|
|
13753
|
+
client.log('event/updateRSVP', eventId, status);
|
|
13754
|
+
const { data: payload } = await client.http.put(`/api/v1/events/${eventId}/rsvp`, { status });
|
|
13755
|
+
fireEvent('local.rsvp.updated', payload);
|
|
13756
|
+
const data = prepareEventResponsePayload(payload);
|
|
13757
|
+
const cachedAt = client.cache && Date.now();
|
|
13758
|
+
if (client.cache)
|
|
13759
|
+
ingestInCache({ eventResponses: [data] }, { cachedAt });
|
|
13760
|
+
return {
|
|
13761
|
+
data,
|
|
13762
|
+
cachedAt,
|
|
13763
|
+
};
|
|
13764
|
+
};
|
|
13765
|
+
/* end_public_function */
|
|
13766
|
+
|
|
13767
|
+
const prepareEventPayload = (rawPayload) => {
|
|
13768
|
+
return Object.assign(Object.assign({}, rawPayload), { users: rawPayload.users.map(convertRawUserToInternalUser) });
|
|
13769
|
+
};
|
|
13770
|
+
|
|
13771
|
+
const createEventEventSubscriber = (event, callback) => {
|
|
13772
|
+
const client = getActiveClient();
|
|
13773
|
+
const filter = (payload) => {
|
|
13774
|
+
const unpackedPayload = prepareEventPayload(payload);
|
|
13775
|
+
if (!client.cache) {
|
|
13776
|
+
callback(unpackedPayload.events[0]);
|
|
13777
|
+
}
|
|
13778
|
+
else {
|
|
13779
|
+
ingestInCache(unpackedPayload);
|
|
13780
|
+
const event = pullFromCache([
|
|
13781
|
+
'event',
|
|
13782
|
+
'get',
|
|
13783
|
+
unpackedPayload.events[0].eventId,
|
|
13784
|
+
]);
|
|
13785
|
+
callback(event.data);
|
|
13786
|
+
}
|
|
13787
|
+
};
|
|
13788
|
+
return createEventSubscriber(client, event, event, filter);
|
|
13789
|
+
};
|
|
13790
|
+
|
|
13791
|
+
const createEventResponseSubscriber = (event, callback) => {
|
|
13792
|
+
const client = getActiveClient();
|
|
13793
|
+
const filter = (payload) => {
|
|
13794
|
+
const unpackedPayload = prepareEventResponsePayload(payload);
|
|
13795
|
+
if (!client.cache) {
|
|
13796
|
+
callback(unpackedPayload);
|
|
13797
|
+
}
|
|
13798
|
+
else {
|
|
13799
|
+
ingestInCache(unpackedPayload.event[0]);
|
|
13800
|
+
const eventResponse = pullFromCache([
|
|
13801
|
+
'eventResponse',
|
|
13802
|
+
'get',
|
|
13803
|
+
payload.eventResponses[0].eventId,
|
|
13804
|
+
]);
|
|
13805
|
+
callback(eventResponse.data);
|
|
13806
|
+
}
|
|
13807
|
+
};
|
|
13808
|
+
return createEventSubscriber(client, event, event, filter);
|
|
13809
|
+
};
|
|
13810
|
+
|
|
13811
|
+
/* begin_public_function
|
|
13812
|
+
id: event.rsvp.me
|
|
13813
|
+
*/
|
|
13814
|
+
/**
|
|
13815
|
+
* ```js
|
|
13816
|
+
* import { event } from '@amityco/ts-sdk'
|
|
13817
|
+
* const myRSVP = await event.getMyRSVP(eventId)
|
|
13818
|
+
* ```
|
|
13819
|
+
*
|
|
13820
|
+
* Joins a {@link Amity.EventResponse} object
|
|
13821
|
+
*
|
|
13822
|
+
* @param eventId the {@link Amity.EventResponse} to get RSVP for
|
|
13823
|
+
* @returns A success boolean if the {@link Amity.EventResponse} RSVP was retrieved
|
|
13824
|
+
*
|
|
13825
|
+
* @category Event API
|
|
13826
|
+
* @async
|
|
13827
|
+
*/
|
|
13828
|
+
const getMyRSVP = async (eventId) => {
|
|
13829
|
+
const client = getActiveClient();
|
|
13830
|
+
client.log('event/getMyRSVP', eventId);
|
|
13831
|
+
const { data: payload } = await client.http.get(`/api/v1/events/${eventId}/me/rsvp`);
|
|
13832
|
+
const data = prepareEventResponsePayload(payload);
|
|
13833
|
+
const cachedAt = client.cache && Date.now();
|
|
13834
|
+
if (client.cache)
|
|
13835
|
+
ingestInCache({ eventResponses: [data] }, { cachedAt });
|
|
13836
|
+
return {
|
|
13837
|
+
data,
|
|
13838
|
+
cachedAt,
|
|
13839
|
+
};
|
|
13840
|
+
};
|
|
13841
|
+
/* end_public_function */
|
|
13842
|
+
/**
|
|
13843
|
+
* ```js
|
|
13844
|
+
* import { event } from '@amityco/ts-sdk'
|
|
13845
|
+
* const event = event.getMyRSVP.locally(eventId)
|
|
13846
|
+
* ```
|
|
13847
|
+
*
|
|
13848
|
+
* Fetches a {@link Amity.InternalEvent} object in cache
|
|
13849
|
+
*
|
|
13850
|
+
* @param eventId the ID of the {@link Amity.InternalEvent} to fetch
|
|
13851
|
+
* @returns the associated {@link Amity.InternalEvent} object
|
|
13852
|
+
*
|
|
13853
|
+
* @category Event API
|
|
13854
|
+
*/
|
|
13855
|
+
getMyRSVP.locally = (eventId) => {
|
|
13856
|
+
const client = getActiveClient();
|
|
13857
|
+
client.log('event/getMyRSVP.locally', eventId);
|
|
13858
|
+
if (!client.cache)
|
|
13859
|
+
return;
|
|
13860
|
+
const cache = pullFromCache(['event', 'getMyRSVP', eventId]);
|
|
13861
|
+
if (!cache)
|
|
13862
|
+
return;
|
|
13863
|
+
return {
|
|
13864
|
+
data: cache.data,
|
|
13865
|
+
cachedAt: cache.cachedAt,
|
|
13866
|
+
};
|
|
13867
|
+
};
|
|
13868
|
+
|
|
13682
13869
|
const eventLinkedObject = (event) => {
|
|
13683
13870
|
return Object.assign(Object.assign({}, event), { get creator() {
|
|
13684
13871
|
const cacheData = pullFromCache(['user', 'get', event.userId]);
|
|
@@ -13690,7 +13877,7 @@ const eventLinkedObject = (event) => {
|
|
|
13690
13877
|
if (!event.discussionCommunityId)
|
|
13691
13878
|
return;
|
|
13692
13879
|
const cacheData = pullFromCache([
|
|
13693
|
-
'
|
|
13880
|
+
'discussionCommunity',
|
|
13694
13881
|
'get',
|
|
13695
13882
|
event.discussionCommunityId,
|
|
13696
13883
|
]);
|
|
@@ -13698,6 +13885,22 @@ const eventLinkedObject = (event) => {
|
|
|
13698
13885
|
return;
|
|
13699
13886
|
return communityLinkedObject(cacheData.data);
|
|
13700
13887
|
},
|
|
13888
|
+
get targetCommunity() {
|
|
13889
|
+
if (!event.originId)
|
|
13890
|
+
return;
|
|
13891
|
+
const cacheData = pullFromCache(['community', 'get', event.originId]);
|
|
13892
|
+
if (!(cacheData === null || cacheData === void 0 ? void 0 : cacheData.data))
|
|
13893
|
+
return;
|
|
13894
|
+
return communityLinkedObject(cacheData.data);
|
|
13895
|
+
},
|
|
13896
|
+
get coverImage() {
|
|
13897
|
+
if (!event.coverImageFileId)
|
|
13898
|
+
return;
|
|
13899
|
+
const cacheData = pullFromCache(['file', 'get', event.coverImageFileId]);
|
|
13900
|
+
if (!(cacheData === null || cacheData === void 0 ? void 0 : cacheData.data))
|
|
13901
|
+
return;
|
|
13902
|
+
return cacheData.data;
|
|
13903
|
+
},
|
|
13701
13904
|
get liveStream() {
|
|
13702
13905
|
if (!event.livestreamId)
|
|
13703
13906
|
return;
|
|
@@ -13705,6 +13908,15 @@ const eventLinkedObject = (event) => {
|
|
|
13705
13908
|
if (!(cacheData === null || cacheData === void 0 ? void 0 : cacheData.data))
|
|
13706
13909
|
return;
|
|
13707
13910
|
return cacheData.data;
|
|
13911
|
+
}, createRSVP: async (status) => {
|
|
13912
|
+
const { data } = await createRSVP(event.eventId, status);
|
|
13913
|
+
return data;
|
|
13914
|
+
}, updateRSVP: async (status) => {
|
|
13915
|
+
const { data } = await updateRSVP(event.eventId, status);
|
|
13916
|
+
return data;
|
|
13917
|
+
}, getMyRSVP: async () => {
|
|
13918
|
+
const { data } = await getMyRSVP(event.eventId);
|
|
13919
|
+
return data;
|
|
13708
13920
|
} });
|
|
13709
13921
|
};
|
|
13710
13922
|
|
|
@@ -30344,30 +30556,6 @@ var index$1 = /*#__PURE__*/Object.freeze({
|
|
|
30344
30556
|
getReactions: getReactions
|
|
30345
30557
|
});
|
|
30346
30558
|
|
|
30347
|
-
const prepareEventPayload = (rawPayload) => {
|
|
30348
|
-
return Object.assign(Object.assign({}, rawPayload), { users: rawPayload.users.map(convertRawUserToInternalUser) });
|
|
30349
|
-
};
|
|
30350
|
-
|
|
30351
|
-
const createEventEventSubscriber = (event, callback) => {
|
|
30352
|
-
const client = getActiveClient();
|
|
30353
|
-
const filter = (payload) => {
|
|
30354
|
-
const unpackedPayload = prepareEventPayload(payload);
|
|
30355
|
-
if (!client.cache) {
|
|
30356
|
-
callback(unpackedPayload.events[0]);
|
|
30357
|
-
}
|
|
30358
|
-
else {
|
|
30359
|
-
ingestInCache(unpackedPayload);
|
|
30360
|
-
const event = pullFromCache([
|
|
30361
|
-
'event',
|
|
30362
|
-
'get',
|
|
30363
|
-
unpackedPayload.events[0].eventId,
|
|
30364
|
-
]);
|
|
30365
|
-
callback(event.data);
|
|
30366
|
-
}
|
|
30367
|
-
};
|
|
30368
|
-
return createEventSubscriber(client, event, event, filter);
|
|
30369
|
-
};
|
|
30370
|
-
|
|
30371
30559
|
/* begin_public_function
|
|
30372
30560
|
id: event.create
|
|
30373
30561
|
*/
|
|
@@ -30389,7 +30577,7 @@ const createEvent = async (bundle) => {
|
|
|
30389
30577
|
const client = getActiveClient();
|
|
30390
30578
|
client.log('event/createEvent', bundle);
|
|
30391
30579
|
const { data: payload } = await client.http.post('/api/v1/events', bundle);
|
|
30392
|
-
fireEvent('event.created', payload);
|
|
30580
|
+
fireEvent('local.event.created', payload);
|
|
30393
30581
|
const preparedPayload = prepareEventPayload(payload);
|
|
30394
30582
|
const cachedAt = client.cache && Date.now();
|
|
30395
30583
|
if (client.cache)
|
|
@@ -30423,7 +30611,7 @@ const updateEvent = async (eventId, bundle) => {
|
|
|
30423
30611
|
const client = getActiveClient();
|
|
30424
30612
|
client.log('event/updateEvent', eventId, bundle);
|
|
30425
30613
|
const { data: payload } = await client.http.put(`/api/v1/events/${eventId}`, bundle);
|
|
30426
|
-
fireEvent('event.updated', payload);
|
|
30614
|
+
fireEvent('local.event.updated', payload);
|
|
30427
30615
|
const preparedPayload = prepareEventPayload(payload);
|
|
30428
30616
|
const cachedAt = client.cache && Date.now();
|
|
30429
30617
|
if (client.cache)
|
|
@@ -30455,7 +30643,7 @@ const updateEvent = async (eventId, bundle) => {
|
|
|
30455
30643
|
const getEvent$1 = async (eventId) => {
|
|
30456
30644
|
const client = getActiveClient();
|
|
30457
30645
|
client.log('event/getEvent', eventId);
|
|
30458
|
-
const { data: payload } = await client.http.get(`/api/
|
|
30646
|
+
const { data: payload } = await client.http.get(`/api/v1/events/${eventId}`);
|
|
30459
30647
|
const data = prepareEventPayload(payload);
|
|
30460
30648
|
const cachedAt = client.cache && Date.now();
|
|
30461
30649
|
if (client.cache)
|
|
@@ -30513,10 +30701,10 @@ const deleteEvent = async (eventId) => {
|
|
|
30513
30701
|
const client = getActiveClient();
|
|
30514
30702
|
client.log('event/deleteEvent', eventId);
|
|
30515
30703
|
const event = await getEvent$1(eventId);
|
|
30516
|
-
await client.http.delete(`/api/
|
|
30704
|
+
await client.http.delete(`/api/v1/events/${eventId}`);
|
|
30517
30705
|
const deletedEvent = Object.assign(Object.assign({}, event.data), { isDeleted: true });
|
|
30518
30706
|
upsertInCache(['event', 'get', eventId], deletedEvent);
|
|
30519
|
-
fireEvent('event.deleted', {
|
|
30707
|
+
fireEvent('local.event.deleted', {
|
|
30520
30708
|
users: [],
|
|
30521
30709
|
files: [],
|
|
30522
30710
|
communities: [],
|
|
@@ -30578,6 +30766,125 @@ const onEventUpdated = (callback) => createEventEventSubscriber('event.updated',
|
|
|
30578
30766
|
*/
|
|
30579
30767
|
const onEventDeleted = (callback) => createEventEventSubscriber('event.deleted', callback);
|
|
30580
30768
|
|
|
30769
|
+
/**
|
|
30770
|
+
* ```js
|
|
30771
|
+
* import { EventRepository } from '@amityco/ts-sdk'
|
|
30772
|
+
* const dispose = EventRepository.onLocalEventCreated(event => {
|
|
30773
|
+
* // ...
|
|
30774
|
+
* })
|
|
30775
|
+
* ```
|
|
30776
|
+
*
|
|
30777
|
+
* Fired when a {@link Amity.Event} has been created
|
|
30778
|
+
*
|
|
30779
|
+
* @param callback The function to call when the event was fired
|
|
30780
|
+
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
30781
|
+
*
|
|
30782
|
+
* @category Event Events
|
|
30783
|
+
*/
|
|
30784
|
+
const onLocalEventCreated = (callback) => createEventEventSubscriber('local.event.created', callback);
|
|
30785
|
+
|
|
30786
|
+
/**
|
|
30787
|
+
* ```js
|
|
30788
|
+
* import { EventRepository } from '@amityco/ts-sdk'
|
|
30789
|
+
* const dispose = EventRepository.onLocalEventUpdated(event => {
|
|
30790
|
+
* // ...
|
|
30791
|
+
* })
|
|
30792
|
+
* ```
|
|
30793
|
+
*
|
|
30794
|
+
* Fired when a {@link Amity.Event} has been updated
|
|
30795
|
+
*
|
|
30796
|
+
* @param callback The function to call when the event was fired
|
|
30797
|
+
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
30798
|
+
*
|
|
30799
|
+
* @category Event Events
|
|
30800
|
+
*/
|
|
30801
|
+
const onLocalEventUpdated = (callback) => createEventEventSubscriber('local.event.updated', callback);
|
|
30802
|
+
|
|
30803
|
+
/**
|
|
30804
|
+
* ```js
|
|
30805
|
+
* import { EventRepository } from '@amityco/ts-sdk'
|
|
30806
|
+
* const dispose = EventRepository.onLocalEventDeleted(event => {
|
|
30807
|
+
* // ...
|
|
30808
|
+
* })
|
|
30809
|
+
* ```
|
|
30810
|
+
*
|
|
30811
|
+
* Fired when a {@link Amity.Event} has been deleted
|
|
30812
|
+
*
|
|
30813
|
+
* @param callback The function to call when the event was fired
|
|
30814
|
+
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
30815
|
+
*
|
|
30816
|
+
* @category Event Events
|
|
30817
|
+
*/
|
|
30818
|
+
const onLocalEventDeleted = (callback) => createEventEventSubscriber('local.event.deleted', callback);
|
|
30819
|
+
|
|
30820
|
+
/**
|
|
30821
|
+
* ```js
|
|
30822
|
+
* import { EventRepository } from '@amityco/ts-sdk'
|
|
30823
|
+
* const dispose = EventRepository.onRSVPCreated(event => {
|
|
30824
|
+
* // ...
|
|
30825
|
+
* })
|
|
30826
|
+
* ```
|
|
30827
|
+
*
|
|
30828
|
+
* Fired when a {@link Amity.Event} has been created
|
|
30829
|
+
*
|
|
30830
|
+
* @param callback The function to call when the event was fired
|
|
30831
|
+
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
30832
|
+
*
|
|
30833
|
+
* @category Event Events
|
|
30834
|
+
*/
|
|
30835
|
+
const onRSVPCreated = (callback) => createEventResponseSubscriber('event.rsvp.created', callback);
|
|
30836
|
+
|
|
30837
|
+
/**
|
|
30838
|
+
* ```js
|
|
30839
|
+
* import { EventRepository } from '@amityco/ts-sdk'
|
|
30840
|
+
* const dispose = EventRepository.onRSVPUpdated(event => {
|
|
30841
|
+
* // ...
|
|
30842
|
+
* })
|
|
30843
|
+
* ```
|
|
30844
|
+
*
|
|
30845
|
+
* Fired when a {@link Amity.InternalEventResponse} has been updated
|
|
30846
|
+
*
|
|
30847
|
+
* @param callback The function to call when the event was fired
|
|
30848
|
+
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
30849
|
+
*
|
|
30850
|
+
* @category Event Events
|
|
30851
|
+
*/
|
|
30852
|
+
const onRSVPUpdated = (callback) => createEventResponseSubscriber('event.rsvp.updated', callback);
|
|
30853
|
+
|
|
30854
|
+
/**
|
|
30855
|
+
* ```js
|
|
30856
|
+
* import { EventRepository } from '@amityco/ts-sdk'
|
|
30857
|
+
* const dispose = EventRepository.onLocalRSVPCreated(event => {
|
|
30858
|
+
* // ...
|
|
30859
|
+
* })
|
|
30860
|
+
* ```
|
|
30861
|
+
*
|
|
30862
|
+
* Fired when a {@link Amity.Event} has been created
|
|
30863
|
+
*
|
|
30864
|
+
* @param callback The function to call when the event was fired
|
|
30865
|
+
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
30866
|
+
*
|
|
30867
|
+
* @category Event Events
|
|
30868
|
+
*/
|
|
30869
|
+
const onLocalRSVPCreated = (callback) => createEventResponseSubscriber('local.rsvp.created', callback);
|
|
30870
|
+
|
|
30871
|
+
/**
|
|
30872
|
+
* ```js
|
|
30873
|
+
* import { EventRepository } from '@amityco/ts-sdk'
|
|
30874
|
+
* const dispose = EventRepository.onLocalEventUpdated(event => {
|
|
30875
|
+
* // ...
|
|
30876
|
+
* })
|
|
30877
|
+
* ```
|
|
30878
|
+
*
|
|
30879
|
+
* Fired when a {@link Amity.Event} has been updated
|
|
30880
|
+
*
|
|
30881
|
+
* @param callback The function to call when the event was fired
|
|
30882
|
+
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
30883
|
+
*
|
|
30884
|
+
* @category Event Events
|
|
30885
|
+
*/
|
|
30886
|
+
const onLocalRSVPUpdated = (callback) => createEventResponseSubscriber('local.rsvp.updated', callback);
|
|
30887
|
+
|
|
30581
30888
|
/* begin_public_function
|
|
30582
30889
|
id: event.get
|
|
30583
30890
|
*/
|
|
@@ -30601,7 +30908,7 @@ const onEventDeleted = (callback) => createEventEventSubscriber('event.deleted',
|
|
|
30601
30908
|
* @category Event Live Object
|
|
30602
30909
|
*/
|
|
30603
30910
|
const getEvent = (eventId, callback) => {
|
|
30604
|
-
return liveObject(eventId, callback, 'eventId', getEvent$1, [
|
|
30911
|
+
return liveObject(eventId, callback, 'eventId', getEvent$1, [onEventUpdated, onEventDeleted, onLocalEventUpdated, onLocalEventDeleted], {
|
|
30605
30912
|
callbackDataSelector: (data) => (data ? eventLinkedObject(data) : data),
|
|
30606
30913
|
});
|
|
30607
30914
|
};
|
|
@@ -30612,6 +30919,8 @@ var EventActionsEnum;
|
|
|
30612
30919
|
EventActionsEnum["OnEventCreated"] = "onEventCreated";
|
|
30613
30920
|
EventActionsEnum["OnEventUpdated"] = "onEventUpdated";
|
|
30614
30921
|
EventActionsEnum["OnEventDeleted"] = "onEventDeleted";
|
|
30922
|
+
EventActionsEnum["OnRSVPCreated"] = "onRSVPCreated";
|
|
30923
|
+
EventActionsEnum["OnRSVPUpdated"] = "onRSVPUpdated";
|
|
30615
30924
|
})(EventActionsEnum || (EventActionsEnum = {}));
|
|
30616
30925
|
|
|
30617
30926
|
class EventPaginationController extends PaginationController {
|
|
@@ -30696,6 +31005,9 @@ class EventLiveCollectionController extends LiveCollectionController {
|
|
|
30696
31005
|
{ fn: onEventCreated, action: EventActionsEnum.OnEventCreated },
|
|
30697
31006
|
{ fn: onEventUpdated, action: EventActionsEnum.OnEventUpdated },
|
|
30698
31007
|
{ fn: onEventDeleted, action: EventActionsEnum.OnEventDeleted },
|
|
31008
|
+
{ fn: onLocalEventCreated, action: EventActionsEnum.OnEventCreated },
|
|
31009
|
+
{ fn: onLocalEventUpdated, action: EventActionsEnum.OnEventUpdated },
|
|
31010
|
+
{ fn: onLocalEventDeleted, action: EventActionsEnum.OnEventDeleted },
|
|
30699
31011
|
]);
|
|
30700
31012
|
}
|
|
30701
31013
|
notifyChange({ origin, loading, error }) {
|
|
@@ -30745,6 +31057,278 @@ const getEvents = (params, callback, config) => {
|
|
|
30745
31057
|
};
|
|
30746
31058
|
};
|
|
30747
31059
|
|
|
31060
|
+
class MyEventPaginationController extends PaginationController {
|
|
31061
|
+
async getRequest(queryParams, token) {
|
|
31062
|
+
const { limit = COLLECTION_DEFAULT_PAGINATION_LIMIT } = queryParams, params = __rest(queryParams, ["limit"]);
|
|
31063
|
+
const options = token ? { token } : { limit };
|
|
31064
|
+
const { data: response } = await this.http.get(`/api/v1/events/me/rsvps`, { params: Object.assign(Object.assign({}, params), { options }) });
|
|
31065
|
+
return response;
|
|
31066
|
+
}
|
|
31067
|
+
}
|
|
31068
|
+
|
|
31069
|
+
class MyEventQueryStreamController extends QueryStreamController {
|
|
31070
|
+
constructor(query, cacheKey, notifyChange, preparePayload) {
|
|
31071
|
+
super(query, cacheKey);
|
|
31072
|
+
this.notifyChange = notifyChange;
|
|
31073
|
+
this.preparePayload = preparePayload;
|
|
31074
|
+
}
|
|
31075
|
+
async saveToMainDB(response) {
|
|
31076
|
+
const processedPayload = this.preparePayload(response);
|
|
31077
|
+
const client = getActiveClient();
|
|
31078
|
+
const cachedAt = client.cache && Date.now();
|
|
31079
|
+
if (client.cache)
|
|
31080
|
+
ingestInCache(processedPayload, { cachedAt });
|
|
31081
|
+
}
|
|
31082
|
+
appendToQueryStream(response, direction, refresh = false) {
|
|
31083
|
+
var _a, _b;
|
|
31084
|
+
if (refresh) {
|
|
31085
|
+
pushToCache(this.cacheKey, { data: response.events.map(getResolver('event')) });
|
|
31086
|
+
}
|
|
31087
|
+
else {
|
|
31088
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
31089
|
+
const events = (_b = collection === null || collection === void 0 ? void 0 : collection.data) !== null && _b !== void 0 ? _b : [];
|
|
31090
|
+
pushToCache(this.cacheKey, Object.assign(Object.assign({}, collection), { data: [...new Set([...events, ...response.events.map(getResolver('event'))])] }));
|
|
31091
|
+
}
|
|
31092
|
+
}
|
|
31093
|
+
reactor(action) {
|
|
31094
|
+
return (event) => {
|
|
31095
|
+
var _a;
|
|
31096
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
31097
|
+
if (!collection)
|
|
31098
|
+
return;
|
|
31099
|
+
if (action === EventActionsEnum.OnEventCreated) {
|
|
31100
|
+
const client = getActiveClient();
|
|
31101
|
+
if (client.userId !== event.userId)
|
|
31102
|
+
return;
|
|
31103
|
+
collection.data = [...new Set([event.eventId, ...collection.data])];
|
|
31104
|
+
}
|
|
31105
|
+
if (action === EventActionsEnum.OnEventDeleted) {
|
|
31106
|
+
collection.data = collection.data.filter(eventId => eventId !== event.eventId);
|
|
31107
|
+
}
|
|
31108
|
+
pushToCache(this.cacheKey, collection);
|
|
31109
|
+
this.notifyChange({ origin: "event" /* Amity.LiveDataOrigin.EVENT */, loading: false });
|
|
31110
|
+
};
|
|
31111
|
+
}
|
|
31112
|
+
subscribeRTE(createSubscriber) {
|
|
31113
|
+
return createSubscriber.map(subscriber => subscriber.fn(this.reactor(subscriber.action)));
|
|
31114
|
+
}
|
|
31115
|
+
}
|
|
31116
|
+
|
|
31117
|
+
class MyEventLiveCollectionController extends LiveCollectionController {
|
|
31118
|
+
constructor(query, callback) {
|
|
31119
|
+
const queryStreamId = hash__default["default"](query);
|
|
31120
|
+
const cacheKey = ['event', 'collection', queryStreamId];
|
|
31121
|
+
const paginationController = new MyEventPaginationController(query);
|
|
31122
|
+
super(paginationController, queryStreamId, cacheKey, callback);
|
|
31123
|
+
this.query = query;
|
|
31124
|
+
this.queryStreamController = new MyEventQueryStreamController(this.query, this.cacheKey, this.notifyChange.bind(this), prepareEventPayload);
|
|
31125
|
+
this.callback = callback.bind(this);
|
|
31126
|
+
this.loadPage({ initial: true });
|
|
31127
|
+
}
|
|
31128
|
+
setup() {
|
|
31129
|
+
var _a;
|
|
31130
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
31131
|
+
if (!collection)
|
|
31132
|
+
pushToCache(this.cacheKey, { data: [], params: {} });
|
|
31133
|
+
}
|
|
31134
|
+
async persistModel(queryPayload) {
|
|
31135
|
+
await this.queryStreamController.saveToMainDB(queryPayload);
|
|
31136
|
+
}
|
|
31137
|
+
persistQueryStream({ response, direction, refresh, }) {
|
|
31138
|
+
this.queryStreamController.appendToQueryStream(response, direction, refresh);
|
|
31139
|
+
}
|
|
31140
|
+
startSubscription() {
|
|
31141
|
+
return this.queryStreamController.subscribeRTE([
|
|
31142
|
+
{ fn: onEventCreated, action: EventActionsEnum.OnEventCreated },
|
|
31143
|
+
{ fn: onEventUpdated, action: EventActionsEnum.OnEventUpdated },
|
|
31144
|
+
{ fn: onEventDeleted, action: EventActionsEnum.OnEventDeleted },
|
|
31145
|
+
{ fn: onLocalEventCreated, action: EventActionsEnum.OnEventCreated },
|
|
31146
|
+
{ fn: onLocalEventUpdated, action: EventActionsEnum.OnEventUpdated },
|
|
31147
|
+
{ fn: onLocalEventDeleted, action: EventActionsEnum.OnEventDeleted },
|
|
31148
|
+
]);
|
|
31149
|
+
}
|
|
31150
|
+
notifyChange({ origin, loading, error }) {
|
|
31151
|
+
var _a, _b;
|
|
31152
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
31153
|
+
if (!collection)
|
|
31154
|
+
return;
|
|
31155
|
+
const data = ((_b = collection.data
|
|
31156
|
+
.map(eventId => pullFromCache(['event', 'get', eventId]))
|
|
31157
|
+
.filter(isNonNullable)
|
|
31158
|
+
.map(({ data }) => data)) !== null && _b !== void 0 ? _b : []).map(LinkedObject.event);
|
|
31159
|
+
if (!this.shouldNotify(data) && origin === "event" /* Amity.LiveDataOrigin.EVENT */)
|
|
31160
|
+
return;
|
|
31161
|
+
this.callback({
|
|
31162
|
+
data,
|
|
31163
|
+
error,
|
|
31164
|
+
loading,
|
|
31165
|
+
hasNextPage: !!this.paginationController.getNextToken(),
|
|
31166
|
+
onNextPage: () => this.loadPage({ direction: "next" /* Amity.LiveCollectionPageDirection.NEXT */ }),
|
|
31167
|
+
});
|
|
31168
|
+
}
|
|
31169
|
+
}
|
|
31170
|
+
|
|
31171
|
+
/**
|
|
31172
|
+
* Get my events
|
|
31173
|
+
*
|
|
31174
|
+
* @param params the query parameters
|
|
31175
|
+
* @param callback the callback to be called when the events are updated
|
|
31176
|
+
* @returns events
|
|
31177
|
+
*
|
|
31178
|
+
* @category Event Live Collection
|
|
31179
|
+
*
|
|
31180
|
+
*/
|
|
31181
|
+
const getMyEvents = (params, callback, config) => {
|
|
31182
|
+
const { log, cache } = getActiveClient();
|
|
31183
|
+
if (!cache)
|
|
31184
|
+
console.log(ENABLE_CACHE_MESSAGE);
|
|
31185
|
+
const timestamp = Date.now();
|
|
31186
|
+
log(`getMyEvents: (tmpid: ${timestamp}) > listen`);
|
|
31187
|
+
const myEventLiveCollection = new MyEventLiveCollectionController(params, callback);
|
|
31188
|
+
const disposers = myEventLiveCollection.startSubscription();
|
|
31189
|
+
const cacheKey = myEventLiveCollection.getCacheKey();
|
|
31190
|
+
disposers.push(() => dropFromCache(cacheKey));
|
|
31191
|
+
return () => {
|
|
31192
|
+
log(`getMyEvents (tmpid: ${timestamp}) > dispose`);
|
|
31193
|
+
disposers.forEach(fn => fn());
|
|
31194
|
+
};
|
|
31195
|
+
};
|
|
31196
|
+
|
|
31197
|
+
class RSVPPaginationController extends PaginationController {
|
|
31198
|
+
async getRequest(queryParams, token) {
|
|
31199
|
+
const { limit = COLLECTION_DEFAULT_PAGINATION_LIMIT, eventId } = queryParams, params = __rest(queryParams, ["limit", "eventId"]);
|
|
31200
|
+
const options = token ? { token } : { limit };
|
|
31201
|
+
const { data: response } = await this.http.get(`/api/v1/events/${eventId}/rsvps`, { params: Object.assign(Object.assign({}, params), { options }) });
|
|
31202
|
+
return response;
|
|
31203
|
+
}
|
|
31204
|
+
}
|
|
31205
|
+
|
|
31206
|
+
class RSVPQueryStreamController extends QueryStreamController {
|
|
31207
|
+
constructor(query, cacheKey, notifyChange, preparePayload) {
|
|
31208
|
+
super(query, cacheKey);
|
|
31209
|
+
this.notifyChange = notifyChange;
|
|
31210
|
+
this.preparePayload = preparePayload;
|
|
31211
|
+
}
|
|
31212
|
+
async saveToMainDB(response) {
|
|
31213
|
+
const processedPayload = this.preparePayload(response);
|
|
31214
|
+
const client = getActiveClient();
|
|
31215
|
+
const cachedAt = client.cache && Date.now();
|
|
31216
|
+
if (client.cache)
|
|
31217
|
+
ingestInCache(processedPayload, { cachedAt });
|
|
31218
|
+
}
|
|
31219
|
+
appendToQueryStream(response, direction, refresh = false) {
|
|
31220
|
+
var _a, _b;
|
|
31221
|
+
if (refresh) {
|
|
31222
|
+
pushToCache(this.cacheKey, { data: response.events.map(getResolver('event')) });
|
|
31223
|
+
}
|
|
31224
|
+
else {
|
|
31225
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
31226
|
+
const events = (_b = collection === null || collection === void 0 ? void 0 : collection.data) !== null && _b !== void 0 ? _b : [];
|
|
31227
|
+
pushToCache(this.cacheKey, Object.assign(Object.assign({}, collection), { data: [...new Set([...events, ...response.events.map(getResolver('event'))])] }));
|
|
31228
|
+
}
|
|
31229
|
+
}
|
|
31230
|
+
reactor(action) {
|
|
31231
|
+
return (event) => {
|
|
31232
|
+
var _a;
|
|
31233
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
31234
|
+
if (!collection)
|
|
31235
|
+
return;
|
|
31236
|
+
if (action === EventActionsEnum.OnEventCreated) {
|
|
31237
|
+
const client = getActiveClient();
|
|
31238
|
+
if (client.userId !== event.userId)
|
|
31239
|
+
return;
|
|
31240
|
+
collection.data = [...new Set([event.eventId, ...collection.data])];
|
|
31241
|
+
}
|
|
31242
|
+
if (action === EventActionsEnum.OnEventDeleted) {
|
|
31243
|
+
collection.data = collection.data.filter(eventId => eventId !== event.eventId);
|
|
31244
|
+
}
|
|
31245
|
+
pushToCache(this.cacheKey, collection);
|
|
31246
|
+
this.notifyChange({ origin: "event" /* Amity.LiveDataOrigin.EVENT */, loading: false });
|
|
31247
|
+
};
|
|
31248
|
+
}
|
|
31249
|
+
subscribeRTE(createSubscriber) {
|
|
31250
|
+
return createSubscriber.map(subscriber => subscriber.fn(this.reactor(subscriber.action)));
|
|
31251
|
+
}
|
|
31252
|
+
}
|
|
31253
|
+
|
|
31254
|
+
class RSVPLiveCollectionController extends LiveCollectionController {
|
|
31255
|
+
constructor(query, callback) {
|
|
31256
|
+
const queryStreamId = hash__default["default"](query);
|
|
31257
|
+
const cacheKey = ['event', 'collection', queryStreamId];
|
|
31258
|
+
const paginationController = new RSVPPaginationController(query);
|
|
31259
|
+
super(paginationController, queryStreamId, cacheKey, callback);
|
|
31260
|
+
this.query = query;
|
|
31261
|
+
this.queryStreamController = new RSVPQueryStreamController(this.query, this.cacheKey, this.notifyChange.bind(this), prepareEventPayload);
|
|
31262
|
+
this.callback = callback.bind(this);
|
|
31263
|
+
this.loadPage({ initial: true });
|
|
31264
|
+
}
|
|
31265
|
+
setup() {
|
|
31266
|
+
var _a;
|
|
31267
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
31268
|
+
if (!collection)
|
|
31269
|
+
pushToCache(this.cacheKey, { data: [], params: {} });
|
|
31270
|
+
}
|
|
31271
|
+
async persistModel(queryPayload) {
|
|
31272
|
+
await this.queryStreamController.saveToMainDB(queryPayload);
|
|
31273
|
+
}
|
|
31274
|
+
persistQueryStream({ response, direction, refresh, }) {
|
|
31275
|
+
this.queryStreamController.appendToQueryStream(response, direction, refresh);
|
|
31276
|
+
}
|
|
31277
|
+
startSubscription() {
|
|
31278
|
+
return this.queryStreamController.subscribeRTE([
|
|
31279
|
+
{ fn: onRSVPCreated, action: EventActionsEnum.OnRSVPCreated },
|
|
31280
|
+
{ fn: onRSVPUpdated, action: EventActionsEnum.OnRSVPUpdated },
|
|
31281
|
+
{ fn: onLocalRSVPCreated, action: EventActionsEnum.OnRSVPCreated },
|
|
31282
|
+
{ fn: onLocalRSVPUpdated, action: EventActionsEnum.OnRSVPUpdated },
|
|
31283
|
+
]);
|
|
31284
|
+
}
|
|
31285
|
+
notifyChange({ origin, loading, error }) {
|
|
31286
|
+
var _a, _b;
|
|
31287
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
31288
|
+
if (!collection)
|
|
31289
|
+
return;
|
|
31290
|
+
const data = ((_b = collection.data
|
|
31291
|
+
.map(eventId => pullFromCache(['event', 'get', eventId]))
|
|
31292
|
+
.filter(isNonNullable)
|
|
31293
|
+
.map(({ data }) => data)) !== null && _b !== void 0 ? _b : []).map(LinkedObject.event);
|
|
31294
|
+
if (!this.shouldNotify(data) && origin === "event" /* Amity.LiveDataOrigin.EVENT */)
|
|
31295
|
+
return;
|
|
31296
|
+
this.callback({
|
|
31297
|
+
data,
|
|
31298
|
+
error,
|
|
31299
|
+
loading,
|
|
31300
|
+
hasNextPage: !!this.paginationController.getNextToken(),
|
|
31301
|
+
onNextPage: () => this.loadPage({ direction: "next" /* Amity.LiveCollectionPageDirection.NEXT */ }),
|
|
31302
|
+
});
|
|
31303
|
+
}
|
|
31304
|
+
}
|
|
31305
|
+
|
|
31306
|
+
/**
|
|
31307
|
+
* Get events
|
|
31308
|
+
*
|
|
31309
|
+
* @param params the query parameters
|
|
31310
|
+
* @param callback the callback to be called when the events are updated
|
|
31311
|
+
* @returns events
|
|
31312
|
+
*
|
|
31313
|
+
* @category RSVP Live Collection
|
|
31314
|
+
*
|
|
31315
|
+
*/
|
|
31316
|
+
const getRSVPs = (params, callback, config) => {
|
|
31317
|
+
const { log, cache } = getActiveClient();
|
|
31318
|
+
if (!cache)
|
|
31319
|
+
console.log(ENABLE_CACHE_MESSAGE);
|
|
31320
|
+
const timestamp = Date.now();
|
|
31321
|
+
log(`getRSVPs: (tmpid: ${timestamp}) > listen`);
|
|
31322
|
+
const eventLiveCollection = new RSVPLiveCollectionController(params, callback);
|
|
31323
|
+
const disposers = eventLiveCollection.startSubscription();
|
|
31324
|
+
const cacheKey = eventLiveCollection.getCacheKey();
|
|
31325
|
+
disposers.push(() => dropFromCache(cacheKey));
|
|
31326
|
+
return () => {
|
|
31327
|
+
log(`getRSVPs (tmpid: ${timestamp}) > dispose`);
|
|
31328
|
+
disposers.forEach(fn => fn());
|
|
31329
|
+
};
|
|
31330
|
+
};
|
|
31331
|
+
|
|
30748
31332
|
var index = /*#__PURE__*/Object.freeze({
|
|
30749
31333
|
__proto__: null,
|
|
30750
31334
|
createEvent: createEvent,
|
|
@@ -30753,8 +31337,17 @@ var index = /*#__PURE__*/Object.freeze({
|
|
|
30753
31337
|
onEventCreated: onEventCreated,
|
|
30754
31338
|
onEventUpdated: onEventUpdated,
|
|
30755
31339
|
onEventDeleted: onEventDeleted,
|
|
31340
|
+
onLocalEventCreated: onLocalEventCreated,
|
|
31341
|
+
onLocalEventUpdated: onLocalEventUpdated,
|
|
31342
|
+
onLocalEventDeleted: onLocalEventDeleted,
|
|
31343
|
+
onRSVPCreated: onRSVPCreated,
|
|
31344
|
+
onRSVPUpdated: onRSVPUpdated,
|
|
31345
|
+
onLocalRSVPCreated: onLocalRSVPCreated,
|
|
31346
|
+
onLocalRSVPUpdated: onLocalRSVPUpdated,
|
|
30756
31347
|
getEvent: getEvent,
|
|
30757
|
-
getEvents: getEvents
|
|
31348
|
+
getEvents: getEvents,
|
|
31349
|
+
getMyEvents: getMyEvents,
|
|
31350
|
+
getRSVPs: getRSVPs
|
|
30758
31351
|
});
|
|
30759
31352
|
|
|
30760
31353
|
exports.API_REGIONS = API_REGIONS;
|