@amityco/ts-sdk 7.11.1-9f733521.0 → 7.11.1-b4621cc1.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 +37 -11
- 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.map +1 -1
- 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 +1 -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 +486 -34
- package/dist/index.esm.js +486 -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.esm.js
CHANGED
|
@@ -197,7 +197,6 @@ var AmityEventStatus;
|
|
|
197
197
|
var AmityEventResponseStatus;
|
|
198
198
|
(function (AmityEventResponseStatus) {
|
|
199
199
|
AmityEventResponseStatus["Going"] = "going";
|
|
200
|
-
AmityEventResponseStatus["Interested"] = "interested";
|
|
201
200
|
AmityEventResponseStatus["NotGoing"] = "not_going";
|
|
202
201
|
})(AmityEventResponseStatus || (AmityEventResponseStatus = {}));
|
|
203
202
|
|
|
@@ -650,6 +649,8 @@ const idResolvers = {
|
|
|
650
649
|
invitation: ({ _id }) => _id,
|
|
651
650
|
joinRequest: ({ joinRequestId }) => joinRequestId,
|
|
652
651
|
event: ({ eventId }) => eventId,
|
|
652
|
+
eventResponse: ({ eventId }) => eventId,
|
|
653
|
+
discussionCommunity: ({ communityId }) => communityId,
|
|
653
654
|
};
|
|
654
655
|
/**
|
|
655
656
|
* Retrieve the id resolver matching a domain name
|
|
@@ -706,7 +707,8 @@ const PAYLOAD2MODEL = {
|
|
|
706
707
|
invitations: 'invitation',
|
|
707
708
|
joinRequests: 'joinRequest',
|
|
708
709
|
events: 'event',
|
|
709
|
-
|
|
710
|
+
eventResponse: 'eventResponse',
|
|
711
|
+
discussionCommunities: 'discussionCommunity',
|
|
710
712
|
};
|
|
711
713
|
/** hidden */
|
|
712
714
|
const isOutdated = (prevData, nextData) => {
|
|
@@ -29777,6 +29779,185 @@ const communityLinkedObject = (community) => {
|
|
|
29777
29779
|
} });
|
|
29778
29780
|
};
|
|
29779
29781
|
|
|
29782
|
+
const prepareEventResponsePayload = (rawPayload) => {
|
|
29783
|
+
return {
|
|
29784
|
+
status: rawPayload.eventResponses[0].status,
|
|
29785
|
+
eventId: rawPayload.eventResponses[0].eventId,
|
|
29786
|
+
event: rawPayload.events,
|
|
29787
|
+
userId: rawPayload.eventResponses[0].userId,
|
|
29788
|
+
user: rawPayload.users.map(convertRawUserToInternalUser),
|
|
29789
|
+
};
|
|
29790
|
+
};
|
|
29791
|
+
|
|
29792
|
+
/* begin_public_function
|
|
29793
|
+
id: event.rsvp.create
|
|
29794
|
+
*/
|
|
29795
|
+
/**
|
|
29796
|
+
* ```js
|
|
29797
|
+
* import { event } from '@amityco/ts-sdk'
|
|
29798
|
+
* const response = await event.createRSVP(eventId, status)
|
|
29799
|
+
* ```
|
|
29800
|
+
*
|
|
29801
|
+
* Creates an {@link Amity.InternalEvent}
|
|
29802
|
+
*
|
|
29803
|
+
* @param bundle The data necessary to create a new {@link Amity.InternalEvent}
|
|
29804
|
+
* @returns The newly created {@link Amity.InternalEvent}
|
|
29805
|
+
*
|
|
29806
|
+
* @category Event API
|
|
29807
|
+
* @async
|
|
29808
|
+
*/
|
|
29809
|
+
const createRSVP = async (eventId, status) => {
|
|
29810
|
+
const client = getActiveClient();
|
|
29811
|
+
client.log('event/createRSVP', eventId, status);
|
|
29812
|
+
const { data: payload } = await client.http.post(`/api/v1/events/${eventId}/rsvp`, { status });
|
|
29813
|
+
fireEvent('local.rsvp.created', payload);
|
|
29814
|
+
const data = prepareEventResponsePayload(payload);
|
|
29815
|
+
const cachedAt = client.cache && Date.now();
|
|
29816
|
+
if (client.cache)
|
|
29817
|
+
ingestInCache({ eventResponses: [data] }, { cachedAt });
|
|
29818
|
+
return {
|
|
29819
|
+
data,
|
|
29820
|
+
cachedAt,
|
|
29821
|
+
};
|
|
29822
|
+
};
|
|
29823
|
+
/* end_public_function */
|
|
29824
|
+
|
|
29825
|
+
/* begin_public_function
|
|
29826
|
+
id: event.update
|
|
29827
|
+
*/
|
|
29828
|
+
/**
|
|
29829
|
+
* ```js
|
|
29830
|
+
* import { event } from '@amityco/ts-sdk'
|
|
29831
|
+
* const response = await event.updateRSVP(eventId, status)
|
|
29832
|
+
* ```
|
|
29833
|
+
*
|
|
29834
|
+
* Updates an {@link Amity.EventResponse}
|
|
29835
|
+
*
|
|
29836
|
+
* @param eventId The ID of the {@link Amity.EventResponse} to edit
|
|
29837
|
+
* @param bundle The data necessary to update an existing {@link Amity.EventResponse}
|
|
29838
|
+
* @returns the updated {@link Amity.EventResponse}
|
|
29839
|
+
*
|
|
29840
|
+
* @category Event API
|
|
29841
|
+
* @async
|
|
29842
|
+
*/
|
|
29843
|
+
const updateRSVP = async (eventId, status) => {
|
|
29844
|
+
const client = getActiveClient();
|
|
29845
|
+
client.log('event/updateRSVP', eventId, status);
|
|
29846
|
+
const { data: payload } = await client.http.put(`/api/v1/events/${eventId}/rsvp`, { status });
|
|
29847
|
+
fireEvent('local.rsvp.updated', payload);
|
|
29848
|
+
const data = prepareEventResponsePayload(payload);
|
|
29849
|
+
const cachedAt = client.cache && Date.now();
|
|
29850
|
+
if (client.cache)
|
|
29851
|
+
ingestInCache({ eventResponses: [data] }, { cachedAt });
|
|
29852
|
+
return {
|
|
29853
|
+
data,
|
|
29854
|
+
cachedAt,
|
|
29855
|
+
};
|
|
29856
|
+
};
|
|
29857
|
+
/* end_public_function */
|
|
29858
|
+
|
|
29859
|
+
const prepareEventPayload = (rawPayload) => {
|
|
29860
|
+
return Object.assign(Object.assign({}, rawPayload), { users: rawPayload.users.map(convertRawUserToInternalUser) });
|
|
29861
|
+
};
|
|
29862
|
+
|
|
29863
|
+
const createEventEventSubscriber = (event, callback) => {
|
|
29864
|
+
const client = getActiveClient();
|
|
29865
|
+
const filter = (payload) => {
|
|
29866
|
+
const unpackedPayload = prepareEventPayload(payload);
|
|
29867
|
+
if (!client.cache) {
|
|
29868
|
+
callback(unpackedPayload.events[0]);
|
|
29869
|
+
}
|
|
29870
|
+
else {
|
|
29871
|
+
ingestInCache(unpackedPayload);
|
|
29872
|
+
const event = pullFromCache([
|
|
29873
|
+
'event',
|
|
29874
|
+
'get',
|
|
29875
|
+
unpackedPayload.events[0].eventId,
|
|
29876
|
+
]);
|
|
29877
|
+
callback(event.data);
|
|
29878
|
+
}
|
|
29879
|
+
};
|
|
29880
|
+
return createEventSubscriber(client, event, event, filter);
|
|
29881
|
+
};
|
|
29882
|
+
|
|
29883
|
+
const createEventResponseSubscriber = (event, callback) => {
|
|
29884
|
+
const client = getActiveClient();
|
|
29885
|
+
const filter = (payload) => {
|
|
29886
|
+
const unpackedPayload = prepareEventResponsePayload(payload);
|
|
29887
|
+
if (!client.cache) {
|
|
29888
|
+
callback(unpackedPayload);
|
|
29889
|
+
}
|
|
29890
|
+
else {
|
|
29891
|
+
ingestInCache(unpackedPayload.event[0]);
|
|
29892
|
+
const eventResponse = pullFromCache([
|
|
29893
|
+
'eventResponse',
|
|
29894
|
+
'get',
|
|
29895
|
+
payload.eventResponses[0].eventId,
|
|
29896
|
+
]);
|
|
29897
|
+
callback(eventResponse.data);
|
|
29898
|
+
}
|
|
29899
|
+
};
|
|
29900
|
+
return createEventSubscriber(client, event, event, filter);
|
|
29901
|
+
};
|
|
29902
|
+
|
|
29903
|
+
/* begin_public_function
|
|
29904
|
+
id: event.rsvp.me
|
|
29905
|
+
*/
|
|
29906
|
+
/**
|
|
29907
|
+
* ```js
|
|
29908
|
+
* import { event } from '@amityco/ts-sdk'
|
|
29909
|
+
* const myRSVP = await event.getMyRSVP()
|
|
29910
|
+
* ```
|
|
29911
|
+
*
|
|
29912
|
+
* Joins a {@link Amity.EventResponse} object
|
|
29913
|
+
*
|
|
29914
|
+
* @param eventId the {@link Amity.EventResponse} to get RSVP for
|
|
29915
|
+
* @returns A success boolean if the {@link Amity.EventResponse} RSVP was retrieved
|
|
29916
|
+
*
|
|
29917
|
+
* @category Event API
|
|
29918
|
+
* @async
|
|
29919
|
+
*/
|
|
29920
|
+
const getMyRSVP = async (eventId) => {
|
|
29921
|
+
const client = getActiveClient();
|
|
29922
|
+
client.log('event/getMyRSVP', eventId);
|
|
29923
|
+
const { data: payload } = await client.http.get(`/api/v1/events/${eventId}/me/rsvp`);
|
|
29924
|
+
const data = prepareEventResponsePayload(payload);
|
|
29925
|
+
const cachedAt = client.cache && Date.now();
|
|
29926
|
+
if (client.cache)
|
|
29927
|
+
ingestInCache({ eventResponses: [data] }, { cachedAt });
|
|
29928
|
+
return {
|
|
29929
|
+
data,
|
|
29930
|
+
cachedAt,
|
|
29931
|
+
};
|
|
29932
|
+
};
|
|
29933
|
+
/* end_public_function */
|
|
29934
|
+
/**
|
|
29935
|
+
* ```js
|
|
29936
|
+
* import { event } from '@amityco/ts-sdk'
|
|
29937
|
+
* const event = event.getMyRSVP.locally(eventId)
|
|
29938
|
+
* ```
|
|
29939
|
+
*
|
|
29940
|
+
* Fetches a {@link Amity.EventResponse} object in cache
|
|
29941
|
+
*
|
|
29942
|
+
* @param eventId the ID of the {@link Amity.EventResponse} to fetch
|
|
29943
|
+
* @returns the associated {@link Amity.EventResponse} object
|
|
29944
|
+
*
|
|
29945
|
+
* @category Event API
|
|
29946
|
+
*/
|
|
29947
|
+
getMyRSVP.locally = (eventId) => {
|
|
29948
|
+
const client = getActiveClient();
|
|
29949
|
+
client.log('event/getMyRSVP.locally', eventId);
|
|
29950
|
+
if (!client.cache)
|
|
29951
|
+
return;
|
|
29952
|
+
const cache = pullFromCache(['event', 'getMyRSVP', eventId]);
|
|
29953
|
+
if (!cache)
|
|
29954
|
+
return;
|
|
29955
|
+
return {
|
|
29956
|
+
data: cache.data,
|
|
29957
|
+
cachedAt: cache.cachedAt,
|
|
29958
|
+
};
|
|
29959
|
+
};
|
|
29960
|
+
|
|
29780
29961
|
const eventLinkedObject = (event) => {
|
|
29781
29962
|
return Object.assign(Object.assign({}, event), { get creator() {
|
|
29782
29963
|
const cacheData = pullFromCache(['user', 'get', event.userId]);
|
|
@@ -29788,7 +29969,7 @@ const eventLinkedObject = (event) => {
|
|
|
29788
29969
|
if (!event.discussionCommunityId)
|
|
29789
29970
|
return;
|
|
29790
29971
|
const cacheData = pullFromCache([
|
|
29791
|
-
'
|
|
29972
|
+
'discussionCommunity',
|
|
29792
29973
|
'get',
|
|
29793
29974
|
event.discussionCommunityId,
|
|
29794
29975
|
]);
|
|
@@ -29796,6 +29977,22 @@ const eventLinkedObject = (event) => {
|
|
|
29796
29977
|
return;
|
|
29797
29978
|
return communityLinkedObject(cacheData.data);
|
|
29798
29979
|
},
|
|
29980
|
+
get targetCommunity() {
|
|
29981
|
+
if (!event.originId)
|
|
29982
|
+
return;
|
|
29983
|
+
const cacheData = pullFromCache(['community', 'get', event.originId]);
|
|
29984
|
+
if (!(cacheData === null || cacheData === void 0 ? void 0 : cacheData.data))
|
|
29985
|
+
return;
|
|
29986
|
+
return communityLinkedObject(cacheData.data);
|
|
29987
|
+
},
|
|
29988
|
+
get coverImage() {
|
|
29989
|
+
if (!event.coverImageFileId)
|
|
29990
|
+
return;
|
|
29991
|
+
const cacheData = pullFromCache(['file', 'get', event.coverImageFileId]);
|
|
29992
|
+
if (!(cacheData === null || cacheData === void 0 ? void 0 : cacheData.data))
|
|
29993
|
+
return;
|
|
29994
|
+
return cacheData.data;
|
|
29995
|
+
},
|
|
29799
29996
|
get liveStream() {
|
|
29800
29997
|
if (!event.livestreamId)
|
|
29801
29998
|
return;
|
|
@@ -29803,6 +30000,15 @@ const eventLinkedObject = (event) => {
|
|
|
29803
30000
|
if (!(cacheData === null || cacheData === void 0 ? void 0 : cacheData.data))
|
|
29804
30001
|
return;
|
|
29805
30002
|
return cacheData.data;
|
|
30003
|
+
}, createRSVP: async (status) => {
|
|
30004
|
+
const { data } = await createRSVP(event.eventId, status);
|
|
30005
|
+
return data;
|
|
30006
|
+
}, updateRSVP: async (status) => {
|
|
30007
|
+
const { data } = await updateRSVP(event.eventId, status);
|
|
30008
|
+
return data;
|
|
30009
|
+
}, getMyRSVP: async () => {
|
|
30010
|
+
const { data } = await getMyRSVP(event.eventId);
|
|
30011
|
+
return data;
|
|
29806
30012
|
} });
|
|
29807
30013
|
};
|
|
29808
30014
|
|
|
@@ -46442,30 +46648,6 @@ var index$1 = /*#__PURE__*/Object.freeze({
|
|
|
46442
46648
|
getReactions: getReactions
|
|
46443
46649
|
});
|
|
46444
46650
|
|
|
46445
|
-
const prepareEventPayload = (rawPayload) => {
|
|
46446
|
-
return Object.assign(Object.assign({}, rawPayload), { users: rawPayload.users.map(convertRawUserToInternalUser) });
|
|
46447
|
-
};
|
|
46448
|
-
|
|
46449
|
-
const createEventEventSubscriber = (event, callback) => {
|
|
46450
|
-
const client = getActiveClient();
|
|
46451
|
-
const filter = (payload) => {
|
|
46452
|
-
const unpackedPayload = prepareEventPayload(payload);
|
|
46453
|
-
if (!client.cache) {
|
|
46454
|
-
callback(unpackedPayload.events[0]);
|
|
46455
|
-
}
|
|
46456
|
-
else {
|
|
46457
|
-
ingestInCache(unpackedPayload);
|
|
46458
|
-
const event = pullFromCache([
|
|
46459
|
-
'event',
|
|
46460
|
-
'get',
|
|
46461
|
-
unpackedPayload.events[0].eventId,
|
|
46462
|
-
]);
|
|
46463
|
-
callback(event.data);
|
|
46464
|
-
}
|
|
46465
|
-
};
|
|
46466
|
-
return createEventSubscriber(client, event, event, filter);
|
|
46467
|
-
};
|
|
46468
|
-
|
|
46469
46651
|
/* begin_public_function
|
|
46470
46652
|
id: event.create
|
|
46471
46653
|
*/
|
|
@@ -46487,7 +46669,7 @@ const createEvent = async (bundle) => {
|
|
|
46487
46669
|
const client = getActiveClient();
|
|
46488
46670
|
client.log('event/createEvent', bundle);
|
|
46489
46671
|
const { data: payload } = await client.http.post('/api/v1/events', bundle);
|
|
46490
|
-
fireEvent('event.created', payload);
|
|
46672
|
+
fireEvent('local.event.created', payload);
|
|
46491
46673
|
const preparedPayload = prepareEventPayload(payload);
|
|
46492
46674
|
const cachedAt = client.cache && Date.now();
|
|
46493
46675
|
if (client.cache)
|
|
@@ -46521,7 +46703,7 @@ const updateEvent = async (eventId, bundle) => {
|
|
|
46521
46703
|
const client = getActiveClient();
|
|
46522
46704
|
client.log('event/updateEvent', eventId, bundle);
|
|
46523
46705
|
const { data: payload } = await client.http.put(`/api/v1/events/${eventId}`, bundle);
|
|
46524
|
-
fireEvent('event.updated', payload);
|
|
46706
|
+
fireEvent('local.event.updated', payload);
|
|
46525
46707
|
const preparedPayload = prepareEventPayload(payload);
|
|
46526
46708
|
const cachedAt = client.cache && Date.now();
|
|
46527
46709
|
if (client.cache)
|
|
@@ -46553,7 +46735,7 @@ const updateEvent = async (eventId, bundle) => {
|
|
|
46553
46735
|
const getEvent$1 = async (eventId) => {
|
|
46554
46736
|
const client = getActiveClient();
|
|
46555
46737
|
client.log('event/getEvent', eventId);
|
|
46556
|
-
const { data: payload } = await client.http.get(`/api/
|
|
46738
|
+
const { data: payload } = await client.http.get(`/api/v1/events/${eventId}`);
|
|
46557
46739
|
const data = prepareEventPayload(payload);
|
|
46558
46740
|
const cachedAt = client.cache && Date.now();
|
|
46559
46741
|
if (client.cache)
|
|
@@ -46611,10 +46793,10 @@ const deleteEvent = async (eventId) => {
|
|
|
46611
46793
|
const client = getActiveClient();
|
|
46612
46794
|
client.log('event/deleteEvent', eventId);
|
|
46613
46795
|
const event = await getEvent$1(eventId);
|
|
46614
|
-
await client.http.delete(`/api/
|
|
46796
|
+
await client.http.delete(`/api/v1/events/${eventId}`);
|
|
46615
46797
|
const deletedEvent = Object.assign(Object.assign({}, event.data), { isDeleted: true });
|
|
46616
46798
|
upsertInCache(['event', 'get', eventId], deletedEvent);
|
|
46617
|
-
fireEvent('event.deleted', {
|
|
46799
|
+
fireEvent('local.event.deleted', {
|
|
46618
46800
|
users: [],
|
|
46619
46801
|
files: [],
|
|
46620
46802
|
communities: [],
|
|
@@ -46676,6 +46858,125 @@ const onEventUpdated = (callback) => createEventEventSubscriber('event.updated',
|
|
|
46676
46858
|
*/
|
|
46677
46859
|
const onEventDeleted = (callback) => createEventEventSubscriber('event.deleted', callback);
|
|
46678
46860
|
|
|
46861
|
+
/**
|
|
46862
|
+
* ```js
|
|
46863
|
+
* import { EventRepository } from '@amityco/ts-sdk'
|
|
46864
|
+
* const dispose = EventRepository.onLocalEventCreated(event => {
|
|
46865
|
+
* // ...
|
|
46866
|
+
* })
|
|
46867
|
+
* ```
|
|
46868
|
+
*
|
|
46869
|
+
* Fired when a {@link Amity.Event} has been created
|
|
46870
|
+
*
|
|
46871
|
+
* @param callback The function to call when the event was fired
|
|
46872
|
+
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
46873
|
+
*
|
|
46874
|
+
* @category Event Events
|
|
46875
|
+
*/
|
|
46876
|
+
const onLocalEventCreated = (callback) => createEventEventSubscriber('local.event.created', callback);
|
|
46877
|
+
|
|
46878
|
+
/**
|
|
46879
|
+
* ```js
|
|
46880
|
+
* import { EventRepository } from '@amityco/ts-sdk'
|
|
46881
|
+
* const dispose = EventRepository.onLocalEventUpdated(event => {
|
|
46882
|
+
* // ...
|
|
46883
|
+
* })
|
|
46884
|
+
* ```
|
|
46885
|
+
*
|
|
46886
|
+
* Fired when a {@link Amity.Event} has been updated
|
|
46887
|
+
*
|
|
46888
|
+
* @param callback The function to call when the event was fired
|
|
46889
|
+
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
46890
|
+
*
|
|
46891
|
+
* @category Event Events
|
|
46892
|
+
*/
|
|
46893
|
+
const onLocalEventUpdated = (callback) => createEventEventSubscriber('local.event.updated', callback);
|
|
46894
|
+
|
|
46895
|
+
/**
|
|
46896
|
+
* ```js
|
|
46897
|
+
* import { EventRepository } from '@amityco/ts-sdk'
|
|
46898
|
+
* const dispose = EventRepository.onLocalEventDeleted(event => {
|
|
46899
|
+
* // ...
|
|
46900
|
+
* })
|
|
46901
|
+
* ```
|
|
46902
|
+
*
|
|
46903
|
+
* Fired when a {@link Amity.Event} has been deleted
|
|
46904
|
+
*
|
|
46905
|
+
* @param callback The function to call when the event was fired
|
|
46906
|
+
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
46907
|
+
*
|
|
46908
|
+
* @category Event Events
|
|
46909
|
+
*/
|
|
46910
|
+
const onLocalEventDeleted = (callback) => createEventEventSubscriber('local.event.deleted', callback);
|
|
46911
|
+
|
|
46912
|
+
/**
|
|
46913
|
+
* ```js
|
|
46914
|
+
* import { EventRepository } from '@amityco/ts-sdk'
|
|
46915
|
+
* const dispose = EventRepository.onRSVPCreated(event => {
|
|
46916
|
+
* // ...
|
|
46917
|
+
* })
|
|
46918
|
+
* ```
|
|
46919
|
+
*
|
|
46920
|
+
* Fired when a {@link Amity.Event} has been created
|
|
46921
|
+
*
|
|
46922
|
+
* @param callback The function to call when the event was fired
|
|
46923
|
+
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
46924
|
+
*
|
|
46925
|
+
* @category Event Events
|
|
46926
|
+
*/
|
|
46927
|
+
const onRSVPCreated = (callback) => createEventResponseSubscriber('event.rsvp.created', callback);
|
|
46928
|
+
|
|
46929
|
+
/**
|
|
46930
|
+
* ```js
|
|
46931
|
+
* import { EventRepository } from '@amityco/ts-sdk'
|
|
46932
|
+
* const dispose = EventRepository.onRSVPUpdated(event => {
|
|
46933
|
+
* // ...
|
|
46934
|
+
* })
|
|
46935
|
+
* ```
|
|
46936
|
+
*
|
|
46937
|
+
* Fired when a {@link Amity.InternalEventResponse} has been updated
|
|
46938
|
+
*
|
|
46939
|
+
* @param callback The function to call when the event was fired
|
|
46940
|
+
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
46941
|
+
*
|
|
46942
|
+
* @category Event Events
|
|
46943
|
+
*/
|
|
46944
|
+
const onRSVPUpdated = (callback) => createEventResponseSubscriber('event.rsvp.updated', callback);
|
|
46945
|
+
|
|
46946
|
+
/**
|
|
46947
|
+
* ```js
|
|
46948
|
+
* import { EventRepository } from '@amityco/ts-sdk'
|
|
46949
|
+
* const dispose = EventRepository.onLocalRSVPCreated(event => {
|
|
46950
|
+
* // ...
|
|
46951
|
+
* })
|
|
46952
|
+
* ```
|
|
46953
|
+
*
|
|
46954
|
+
* Fired when a {@link Amity.Event} has been created
|
|
46955
|
+
*
|
|
46956
|
+
* @param callback The function to call when the event was fired
|
|
46957
|
+
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
46958
|
+
*
|
|
46959
|
+
* @category Event Events
|
|
46960
|
+
*/
|
|
46961
|
+
const onLocalRSVPCreated = (callback) => createEventResponseSubscriber('local.rsvp.created', callback);
|
|
46962
|
+
|
|
46963
|
+
/**
|
|
46964
|
+
* ```js
|
|
46965
|
+
* import { EventRepository } from '@amityco/ts-sdk'
|
|
46966
|
+
* const dispose = EventRepository.onLocalEventUpdated(event => {
|
|
46967
|
+
* // ...
|
|
46968
|
+
* })
|
|
46969
|
+
* ```
|
|
46970
|
+
*
|
|
46971
|
+
* Fired when a {@link Amity.Event} has been updated
|
|
46972
|
+
*
|
|
46973
|
+
* @param callback The function to call when the event was fired
|
|
46974
|
+
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
46975
|
+
*
|
|
46976
|
+
* @category Event Events
|
|
46977
|
+
*/
|
|
46978
|
+
const onLocalRSVPUpdated = (callback) => createEventResponseSubscriber('local.rsvp.updated', callback);
|
|
46979
|
+
|
|
46679
46980
|
/* begin_public_function
|
|
46680
46981
|
id: event.get
|
|
46681
46982
|
*/
|
|
@@ -46699,7 +47000,7 @@ const onEventDeleted = (callback) => createEventEventSubscriber('event.deleted',
|
|
|
46699
47000
|
* @category Event Live Object
|
|
46700
47001
|
*/
|
|
46701
47002
|
const getEvent = (eventId, callback) => {
|
|
46702
|
-
return liveObject(eventId, callback, 'eventId', getEvent$1, [
|
|
47003
|
+
return liveObject(eventId, callback, 'eventId', getEvent$1, [onEventUpdated, onEventDeleted, onLocalEventUpdated, onLocalEventDeleted], {
|
|
46703
47004
|
callbackDataSelector: (data) => (data ? eventLinkedObject(data) : data),
|
|
46704
47005
|
});
|
|
46705
47006
|
};
|
|
@@ -46710,6 +47011,8 @@ var EventActionsEnum;
|
|
|
46710
47011
|
EventActionsEnum["OnEventCreated"] = "onEventCreated";
|
|
46711
47012
|
EventActionsEnum["OnEventUpdated"] = "onEventUpdated";
|
|
46712
47013
|
EventActionsEnum["OnEventDeleted"] = "onEventDeleted";
|
|
47014
|
+
EventActionsEnum["OnRSVPCreated"] = "onRSVPCreated";
|
|
47015
|
+
EventActionsEnum["OnRSVPUpdated"] = "onRSVPUpdated";
|
|
46713
47016
|
})(EventActionsEnum || (EventActionsEnum = {}));
|
|
46714
47017
|
|
|
46715
47018
|
class EventPaginationController extends PaginationController {
|
|
@@ -46794,6 +47097,9 @@ class EventLiveCollectionController extends LiveCollectionController {
|
|
|
46794
47097
|
{ fn: onEventCreated, action: EventActionsEnum.OnEventCreated },
|
|
46795
47098
|
{ fn: onEventUpdated, action: EventActionsEnum.OnEventUpdated },
|
|
46796
47099
|
{ fn: onEventDeleted, action: EventActionsEnum.OnEventDeleted },
|
|
47100
|
+
{ fn: onLocalEventCreated, action: EventActionsEnum.OnEventCreated },
|
|
47101
|
+
{ fn: onLocalEventUpdated, action: EventActionsEnum.OnEventUpdated },
|
|
47102
|
+
{ fn: onLocalEventDeleted, action: EventActionsEnum.OnEventDeleted },
|
|
46797
47103
|
]);
|
|
46798
47104
|
}
|
|
46799
47105
|
notifyChange({ origin, loading, error }) {
|
|
@@ -46928,6 +47234,9 @@ class MyEventLiveCollectionController extends LiveCollectionController {
|
|
|
46928
47234
|
{ fn: onEventCreated, action: EventActionsEnum.OnEventCreated },
|
|
46929
47235
|
{ fn: onEventUpdated, action: EventActionsEnum.OnEventUpdated },
|
|
46930
47236
|
{ fn: onEventDeleted, action: EventActionsEnum.OnEventDeleted },
|
|
47237
|
+
{ fn: onLocalEventCreated, action: EventActionsEnum.OnEventCreated },
|
|
47238
|
+
{ fn: onLocalEventUpdated, action: EventActionsEnum.OnEventUpdated },
|
|
47239
|
+
{ fn: onLocalEventDeleted, action: EventActionsEnum.OnEventDeleted },
|
|
46931
47240
|
]);
|
|
46932
47241
|
}
|
|
46933
47242
|
notifyChange({ origin, loading, error }) {
|
|
@@ -46977,6 +47286,141 @@ const getMyEvents = (params, callback, config) => {
|
|
|
46977
47286
|
};
|
|
46978
47287
|
};
|
|
46979
47288
|
|
|
47289
|
+
class RSVPPaginationController extends PaginationController {
|
|
47290
|
+
async getRequest(queryParams, token) {
|
|
47291
|
+
const { limit = COLLECTION_DEFAULT_PAGINATION_LIMIT, eventId } = queryParams, params = __rest(queryParams, ["limit", "eventId"]);
|
|
47292
|
+
const options = token ? { token } : { limit };
|
|
47293
|
+
const { data: response } = await this.http.get(`/api/v1/events/${eventId}/rsvps`, { params: Object.assign(Object.assign({}, params), { options }) });
|
|
47294
|
+
return response;
|
|
47295
|
+
}
|
|
47296
|
+
}
|
|
47297
|
+
|
|
47298
|
+
class RSVPQueryStreamController extends QueryStreamController {
|
|
47299
|
+
constructor(query, cacheKey, notifyChange, preparePayload) {
|
|
47300
|
+
super(query, cacheKey);
|
|
47301
|
+
this.notifyChange = notifyChange;
|
|
47302
|
+
this.preparePayload = preparePayload;
|
|
47303
|
+
}
|
|
47304
|
+
async saveToMainDB(response) {
|
|
47305
|
+
const processedPayload = this.preparePayload(response);
|
|
47306
|
+
const client = getActiveClient();
|
|
47307
|
+
const cachedAt = client.cache && Date.now();
|
|
47308
|
+
if (client.cache)
|
|
47309
|
+
ingestInCache(processedPayload, { cachedAt });
|
|
47310
|
+
}
|
|
47311
|
+
appendToQueryStream(response, direction, refresh = false) {
|
|
47312
|
+
var _a, _b;
|
|
47313
|
+
if (refresh) {
|
|
47314
|
+
pushToCache(this.cacheKey, { data: response.events.map(getResolver('event')) });
|
|
47315
|
+
}
|
|
47316
|
+
else {
|
|
47317
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
47318
|
+
const events = (_b = collection === null || collection === void 0 ? void 0 : collection.data) !== null && _b !== void 0 ? _b : [];
|
|
47319
|
+
pushToCache(this.cacheKey, Object.assign(Object.assign({}, collection), { data: [...new Set([...events, ...response.events.map(getResolver('event'))])] }));
|
|
47320
|
+
}
|
|
47321
|
+
}
|
|
47322
|
+
reactor(action) {
|
|
47323
|
+
return (event) => {
|
|
47324
|
+
var _a;
|
|
47325
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
47326
|
+
if (!collection)
|
|
47327
|
+
return;
|
|
47328
|
+
if (action === EventActionsEnum.OnEventCreated) {
|
|
47329
|
+
const client = getActiveClient();
|
|
47330
|
+
if (client.userId !== event.userId)
|
|
47331
|
+
return;
|
|
47332
|
+
collection.data = [...new Set([event.eventId, ...collection.data])];
|
|
47333
|
+
}
|
|
47334
|
+
if (action === EventActionsEnum.OnEventDeleted) {
|
|
47335
|
+
collection.data = collection.data.filter(eventId => eventId !== event.eventId);
|
|
47336
|
+
}
|
|
47337
|
+
pushToCache(this.cacheKey, collection);
|
|
47338
|
+
this.notifyChange({ origin: "event" /* Amity.LiveDataOrigin.EVENT */, loading: false });
|
|
47339
|
+
};
|
|
47340
|
+
}
|
|
47341
|
+
subscribeRTE(createSubscriber) {
|
|
47342
|
+
return createSubscriber.map(subscriber => subscriber.fn(this.reactor(subscriber.action)));
|
|
47343
|
+
}
|
|
47344
|
+
}
|
|
47345
|
+
|
|
47346
|
+
class RSVPLiveCollectionController extends LiveCollectionController {
|
|
47347
|
+
constructor(query, callback) {
|
|
47348
|
+
const queryStreamId = hash(query);
|
|
47349
|
+
const cacheKey = ['event', 'collection', queryStreamId];
|
|
47350
|
+
const paginationController = new RSVPPaginationController(query);
|
|
47351
|
+
super(paginationController, queryStreamId, cacheKey, callback);
|
|
47352
|
+
this.query = query;
|
|
47353
|
+
this.queryStreamController = new RSVPQueryStreamController(this.query, this.cacheKey, this.notifyChange.bind(this), prepareEventPayload);
|
|
47354
|
+
this.callback = callback.bind(this);
|
|
47355
|
+
this.loadPage({ initial: true });
|
|
47356
|
+
}
|
|
47357
|
+
setup() {
|
|
47358
|
+
var _a;
|
|
47359
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
47360
|
+
if (!collection)
|
|
47361
|
+
pushToCache(this.cacheKey, { data: [], params: {} });
|
|
47362
|
+
}
|
|
47363
|
+
async persistModel(queryPayload) {
|
|
47364
|
+
await this.queryStreamController.saveToMainDB(queryPayload);
|
|
47365
|
+
}
|
|
47366
|
+
persistQueryStream({ response, direction, refresh, }) {
|
|
47367
|
+
this.queryStreamController.appendToQueryStream(response, direction, refresh);
|
|
47368
|
+
}
|
|
47369
|
+
startSubscription() {
|
|
47370
|
+
return this.queryStreamController.subscribeRTE([
|
|
47371
|
+
{ fn: onRSVPCreated, action: EventActionsEnum.OnRSVPCreated },
|
|
47372
|
+
{ fn: onRSVPUpdated, action: EventActionsEnum.OnRSVPUpdated },
|
|
47373
|
+
{ fn: onLocalRSVPCreated, action: EventActionsEnum.OnRSVPCreated },
|
|
47374
|
+
{ fn: onLocalRSVPUpdated, action: EventActionsEnum.OnRSVPUpdated },
|
|
47375
|
+
]);
|
|
47376
|
+
}
|
|
47377
|
+
notifyChange({ origin, loading, error }) {
|
|
47378
|
+
var _a, _b;
|
|
47379
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
47380
|
+
if (!collection)
|
|
47381
|
+
return;
|
|
47382
|
+
const data = ((_b = collection.data
|
|
47383
|
+
.map(eventId => pullFromCache(['event', 'get', eventId]))
|
|
47384
|
+
.filter(isNonNullable)
|
|
47385
|
+
.map(({ data }) => data)) !== null && _b !== void 0 ? _b : []).map(LinkedObject.event);
|
|
47386
|
+
if (!this.shouldNotify(data) && origin === "event" /* Amity.LiveDataOrigin.EVENT */)
|
|
47387
|
+
return;
|
|
47388
|
+
this.callback({
|
|
47389
|
+
data,
|
|
47390
|
+
error,
|
|
47391
|
+
loading,
|
|
47392
|
+
hasNextPage: !!this.paginationController.getNextToken(),
|
|
47393
|
+
onNextPage: () => this.loadPage({ direction: "next" /* Amity.LiveCollectionPageDirection.NEXT */ }),
|
|
47394
|
+
});
|
|
47395
|
+
}
|
|
47396
|
+
}
|
|
47397
|
+
|
|
47398
|
+
/**
|
|
47399
|
+
* Get events
|
|
47400
|
+
*
|
|
47401
|
+
* @param params the query parameters
|
|
47402
|
+
* @param callback the callback to be called when the events are updated
|
|
47403
|
+
* @returns events
|
|
47404
|
+
*
|
|
47405
|
+
* @category RSVP Live Collection
|
|
47406
|
+
*
|
|
47407
|
+
*/
|
|
47408
|
+
const getRSVPs = (params, callback, config) => {
|
|
47409
|
+
const { log, cache } = getActiveClient();
|
|
47410
|
+
if (!cache)
|
|
47411
|
+
console.log(ENABLE_CACHE_MESSAGE);
|
|
47412
|
+
const timestamp = Date.now();
|
|
47413
|
+
log(`getRSVPs: (tmpid: ${timestamp}) > listen`);
|
|
47414
|
+
const eventLiveCollection = new RSVPLiveCollectionController(params, callback);
|
|
47415
|
+
const disposers = eventLiveCollection.startSubscription();
|
|
47416
|
+
const cacheKey = eventLiveCollection.getCacheKey();
|
|
47417
|
+
disposers.push(() => dropFromCache(cacheKey));
|
|
47418
|
+
return () => {
|
|
47419
|
+
log(`getRSVPs (tmpid: ${timestamp}) > dispose`);
|
|
47420
|
+
disposers.forEach(fn => fn());
|
|
47421
|
+
};
|
|
47422
|
+
};
|
|
47423
|
+
|
|
46980
47424
|
var index = /*#__PURE__*/Object.freeze({
|
|
46981
47425
|
__proto__: null,
|
|
46982
47426
|
createEvent: createEvent,
|
|
@@ -46985,9 +47429,17 @@ var index = /*#__PURE__*/Object.freeze({
|
|
|
46985
47429
|
onEventCreated: onEventCreated,
|
|
46986
47430
|
onEventUpdated: onEventUpdated,
|
|
46987
47431
|
onEventDeleted: onEventDeleted,
|
|
47432
|
+
onLocalEventCreated: onLocalEventCreated,
|
|
47433
|
+
onLocalEventUpdated: onLocalEventUpdated,
|
|
47434
|
+
onLocalEventDeleted: onLocalEventDeleted,
|
|
47435
|
+
onRSVPCreated: onRSVPCreated,
|
|
47436
|
+
onRSVPUpdated: onRSVPUpdated,
|
|
47437
|
+
onLocalRSVPCreated: onLocalRSVPCreated,
|
|
47438
|
+
onLocalRSVPUpdated: onLocalRSVPUpdated,
|
|
46988
47439
|
getEvent: getEvent,
|
|
46989
47440
|
getEvents: getEvents,
|
|
46990
|
-
getMyEvents: getMyEvents
|
|
47441
|
+
getMyEvents: getMyEvents,
|
|
47442
|
+
getRSVPs: getRSVPs
|
|
46991
47443
|
});
|
|
46992
47444
|
|
|
46993
47445
|
export { API_REGIONS, index$4 as AdRepository, AmityEventOriginType, AmityEventResponseStatus, AmityEventStatus, AmityEventType, index$c as CategoryRepository, index$g as ChannelRepository, index$p as Client, index$b as CommentRepository, CommunityPostSettingMaps, CommunityPostSettings, index$d as CommunityRepository, ContentFeedType, ContentFlagReasonEnum, DefaultCommunityPostSetting, index as EventRepository, FeedDataTypeEnum, index$a as FeedRepository, FeedSortByEnum, FeedSourceEnum, FileAccessTypeEnum, index$m as FileRepository, FileType, GET_WATCHER_URLS, index$2 as InvitationRepository, InvitationSortByEnum, InvitationStatusEnum, InvitationTypeEnum, JoinRequestStatusEnum, JoinResultStatusEnum, index$1 as LiveReactionRepository, index$6 as LiveStreamPlayer, MembershipAcceptanceTypeEnum, MessageContentType, index$k as MessageRepository, index$7 as PollRepository, PostContentType, index$9 as PostRepository, PostStructureType, index$l as ReactionRepository, index$5 as StoryRepository, index$8 as StreamRepository, index$j as SubChannelRepository, SubscriptionLevels, index$n as UserRepository, UserTypeEnum, VERSION, VideoResolution, VideoSize, VideoTranscodingStatus, backupCache, createQuery, createReport, createUserToken, deleteReport, disableCache, dropFromCache, enableCache, filterByChannelMembership, filterByCommunityMembership, filterByFeedType, filterByPostDataTypes, filterByPropEquality, filterByPropInclusion, filterByPropIntersection, filterBySearchTerm, filterByStringComparePartially, getChannelTopic, getCommentTopic, getCommunityStoriesTopic, getCommunityTopic, getLiveReactionTopic, getLiveStreamTopic, getMarkedMessageTopic, getMarkerUserFeedTopic, getMessageTopic, getMyFollowersTopic, getMyFollowingsTopic, getNetworkTopic, getPostTopic, getRole, getSmartFeedChannelTopic, getSmartFeedMessageTopic, getSmartFeedSubChannelTopic, getStoryTopic, getSubChannelTopic, getUserTopic, isAfterBefore, isAfterBeforeRaw, isCachable, isFetcher, isFresh, isLocal, isMutator, isOffline, isPaged, isReportedByMe, isSkip, mergeInCache, index$3 as notificationTray, onChannelMarkerFetched, onFeedMarkerFetched, onFeedMarkerUpdated, onMessageMarked, onMessageMarkerFetched, onSubChannelMarkerFetched, onSubChannelMarkerUpdated, onUserMarkerFetched, onUserMarkerFetchedLegacy, pullFromCache, pushToCache, queryCache, queryOptions, queryRoles, restoreCache, runQuery, sortByChannelSegment, sortByDisplayName, sortByFirstCreated, sortByFirstUpdated, sortByLastActivity, sortByLastCreated, sortByLastUpdated, sortByLocalSortingDate, sortByName, sortBySegmentNumber, subscribeTopic, toPage, toPageRaw, toToken, upsertInCache, wipeCache };
|