@amityco/ts-sdk 7.11.1-8ef0bbb7.0 → 7.11.1-909f8206.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 -13
- package/dist/@types/core/events.d.ts.map +1 -1
- package/dist/@types/core/model.d.ts +6 -3
- package/dist/@types/core/model.d.ts.map +1 -1
- package/dist/@types/core/payload.d.ts +29 -4
- 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/content.d.ts +1 -4
- package/dist/@types/domains/content.d.ts.map +1 -1
- package/dist/@types/domains/event.d.ts +109 -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/domains/post.d.ts +0 -2
- package/dist/@types/domains/post.d.ts.map +1 -1
- package/dist/@types/index.d.ts +1 -2
- 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.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/createEventResponseSubscriber.d.ts +2 -0
- package/dist/eventRepository/utils/createEventResponseSubscriber.d.ts.map +1 -0
- package/dist/eventRepository/utils/index.d.ts +5 -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/eventRepository/utils/prepareEventResponsePayload.d.ts +2 -0
- package/dist/eventRepository/utils/prepareEventResponsePayload.d.ts.map +1 -0
- package/dist/index.cjs.js +13042 -12717
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.esm.js +1071 -746
- package/dist/index.umd.js +3 -3
- package/dist/messagePreview/utils/getChannelMessagePreviewWithUser.d.ts +1 -1
- package/dist/messagePreview/utils/getSubChannelMessagePreviewWithUser.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/dist/utils/linkedObject/postLinkedObject.d.ts.map +1 -1
- package/dist/utils/postTypePredicate.d.ts +0 -1
- package/dist/utils/postTypePredicate.d.ts.map +1 -1
- package/dist/utils/tests/dummy/comment.d.ts +1 -1
- package/package.json +1 -1
- package/dist/@types/domains/room.d.ts +0 -71
- package/dist/@types/domains/room.d.ts.map +0 -1
- package/dist/roomRepository/api/createRoom.d.ts +0 -24
- package/dist/roomRepository/api/createRoom.d.ts.map +0 -1
- package/dist/roomRepository/api/deleteRoom.d.ts +0 -16
- package/dist/roomRepository/api/deleteRoom.d.ts.map +0 -1
- package/dist/roomRepository/api/getRecordedUrl.d.ts +0 -19
- package/dist/roomRepository/api/getRecordedUrl.d.ts.map +0 -1
- package/dist/roomRepository/api/getRoomToken.d.ts +0 -16
- package/dist/roomRepository/api/getRoomToken.d.ts.map +0 -1
- package/dist/roomRepository/api/index.d.ts +0 -7
- package/dist/roomRepository/api/index.d.ts.map +0 -1
- package/dist/roomRepository/api/stopRoom.d.ts +0 -16
- package/dist/roomRepository/api/stopRoom.d.ts.map +0 -1
- package/dist/roomRepository/api/updateRoom.d.ts +0 -24
- package/dist/roomRepository/api/updateRoom.d.ts.map +0 -1
- package/dist/roomRepository/events/index.d.ts +0 -12
- package/dist/roomRepository/events/index.d.ts.map +0 -1
- package/dist/roomRepository/events/onRoomCreated.d.ts +0 -17
- package/dist/roomRepository/events/onRoomCreated.d.ts.map +0 -1
- package/dist/roomRepository/events/onRoomDeleted.d.ts +0 -17
- package/dist/roomRepository/events/onRoomDeleted.d.ts.map +0 -1
- package/dist/roomRepository/events/onRoomEndBroadcasting.d.ts +0 -17
- package/dist/roomRepository/events/onRoomEndBroadcasting.d.ts.map +0 -1
- package/dist/roomRepository/events/onRoomParticipantInviting.d.ts +0 -17
- package/dist/roomRepository/events/onRoomParticipantInviting.d.ts.map +0 -1
- package/dist/roomRepository/events/onRoomParticipantJoined.d.ts +0 -17
- package/dist/roomRepository/events/onRoomParticipantJoined.d.ts.map +0 -1
- package/dist/roomRepository/events/onRoomParticipantLeft.d.ts +0 -17
- package/dist/roomRepository/events/onRoomParticipantLeft.d.ts.map +0 -1
- package/dist/roomRepository/events/onRoomRecordedAvailable.d.ts +0 -17
- package/dist/roomRepository/events/onRoomRecordedAvailable.d.ts.map +0 -1
- package/dist/roomRepository/events/onRoomStartBroadcasting.d.ts +0 -17
- package/dist/roomRepository/events/onRoomStartBroadcasting.d.ts.map +0 -1
- package/dist/roomRepository/events/onRoomStopped.d.ts +0 -17
- package/dist/roomRepository/events/onRoomStopped.d.ts.map +0 -1
- package/dist/roomRepository/events/onRoomUpdated.d.ts +0 -17
- package/dist/roomRepository/events/onRoomUpdated.d.ts.map +0 -1
- package/dist/roomRepository/events/onRoomWaitingReconnect.d.ts +0 -17
- package/dist/roomRepository/events/onRoomWaitingReconnect.d.ts.map +0 -1
- package/dist/roomRepository/index.d.ts.map +0 -1
- package/dist/roomRepository/internalApi/getRoomById.d.ts +0 -5
- package/dist/roomRepository/internalApi/getRoomById.d.ts.map +0 -1
- package/dist/roomRepository/internalApi/index.d.ts +0 -2
- package/dist/roomRepository/internalApi/index.d.ts.map +0 -1
- package/dist/roomRepository/observers/enums.d.ts +0 -10
- package/dist/roomRepository/observers/enums.d.ts.map +0 -1
- package/dist/roomRepository/observers/getRoom.d.ts +0 -2
- package/dist/roomRepository/observers/getRoom.d.ts.map +0 -1
- package/dist/roomRepository/observers/getRooms/RoomLiveCollectionController.d.ts +0 -14
- package/dist/roomRepository/observers/getRooms/RoomLiveCollectionController.d.ts.map +0 -1
- package/dist/roomRepository/observers/getRooms/RoomPaginationController.d.ts +0 -5
- package/dist/roomRepository/observers/getRooms/RoomPaginationController.d.ts.map +0 -1
- package/dist/roomRepository/observers/getRooms/RoomQueryStreamController.d.ts +0 -15
- package/dist/roomRepository/observers/getRooms/RoomQueryStreamController.d.ts.map +0 -1
- package/dist/roomRepository/observers/getRooms.d.ts +0 -29
- package/dist/roomRepository/observers/getRooms.d.ts.map +0 -1
- package/dist/roomRepository/observers/index.d.ts +0 -3
- package/dist/roomRepository/observers/index.d.ts.map +0 -1
- package/dist/roomRepository/observers/utils.d.ts +0 -6
- package/dist/roomRepository/observers/utils.d.ts.map +0 -1
- /package/dist/{roomRepository → eventRepository}/index.d.ts +0 -0
package/dist/index.esm.js
CHANGED
|
@@ -112,7 +112,6 @@ const PostContentType = Object.freeze({
|
|
|
112
112
|
POLL: 'poll',
|
|
113
113
|
CLIP: 'clip',
|
|
114
114
|
AUDIO: 'audio',
|
|
115
|
-
ROOM: 'room',
|
|
116
115
|
});
|
|
117
116
|
const PostStructureType = Object.freeze({
|
|
118
117
|
TEXT: 'text',
|
|
@@ -178,6 +177,29 @@ var FeedSourceEnum;
|
|
|
178
177
|
FeedSourceEnum["User"] = "user";
|
|
179
178
|
})(FeedSourceEnum || (FeedSourceEnum = {}));
|
|
180
179
|
|
|
180
|
+
var AmityEventType;
|
|
181
|
+
(function (AmityEventType) {
|
|
182
|
+
AmityEventType["Virtual"] = "virtual";
|
|
183
|
+
AmityEventType["InPerson"] = "in_person";
|
|
184
|
+
})(AmityEventType || (AmityEventType = {}));
|
|
185
|
+
var AmityEventOriginType;
|
|
186
|
+
(function (AmityEventOriginType) {
|
|
187
|
+
AmityEventOriginType["Community"] = "community";
|
|
188
|
+
AmityEventOriginType["User"] = "user";
|
|
189
|
+
})(AmityEventOriginType || (AmityEventOriginType = {}));
|
|
190
|
+
var AmityEventStatus;
|
|
191
|
+
(function (AmityEventStatus) {
|
|
192
|
+
AmityEventStatus["Scheduled"] = "scheduled";
|
|
193
|
+
AmityEventStatus["Live"] = "live";
|
|
194
|
+
AmityEventStatus["Ended"] = "ended";
|
|
195
|
+
AmityEventStatus["Cancelled"] = "cancelled";
|
|
196
|
+
})(AmityEventStatus || (AmityEventStatus = {}));
|
|
197
|
+
var AmityEventResponseStatus;
|
|
198
|
+
(function (AmityEventResponseStatus) {
|
|
199
|
+
AmityEventResponseStatus["Going"] = "going";
|
|
200
|
+
AmityEventResponseStatus["NotGoing"] = "not_going";
|
|
201
|
+
})(AmityEventResponseStatus || (AmityEventResponseStatus = {}));
|
|
202
|
+
|
|
181
203
|
function getVersion() {
|
|
182
204
|
try {
|
|
183
205
|
// the string ''v7.11.0-esm'' should be replaced by actual value by @rollup/plugin-replace
|
|
@@ -626,7 +648,9 @@ const idResolvers = {
|
|
|
626
648
|
notificationTraySeen: ({ userId }) => userId,
|
|
627
649
|
invitation: ({ _id }) => _id,
|
|
628
650
|
joinRequest: ({ joinRequestId }) => joinRequestId,
|
|
629
|
-
|
|
651
|
+
event: ({ eventId }) => eventId,
|
|
652
|
+
eventResponse: ({ eventId }) => eventId,
|
|
653
|
+
discussionCommunity: ({ communityId }) => communityId,
|
|
630
654
|
};
|
|
631
655
|
/**
|
|
632
656
|
* Retrieve the id resolver matching a domain name
|
|
@@ -682,7 +706,9 @@ const PAYLOAD2MODEL = {
|
|
|
682
706
|
notificationTrayItems: 'notificationTrayItem',
|
|
683
707
|
invitations: 'invitation',
|
|
684
708
|
joinRequests: 'joinRequest',
|
|
685
|
-
|
|
709
|
+
events: 'event',
|
|
710
|
+
eventResponse: 'eventResponse',
|
|
711
|
+
discussionCommunities: 'discussionCommunity',
|
|
686
712
|
};
|
|
687
713
|
/** hidden */
|
|
688
714
|
const isOutdated = (prevData, nextData) => {
|
|
@@ -28302,12 +28328,6 @@ function isAmityAudioPost(post) {
|
|
|
28302
28328
|
'fileId' in post.data &&
|
|
28303
28329
|
post.dataType === 'audio');
|
|
28304
28330
|
}
|
|
28305
|
-
function isAmityRoomPost(post) {
|
|
28306
|
-
return !!(post.data &&
|
|
28307
|
-
typeof post.data !== 'string' &&
|
|
28308
|
-
'roomId' in post.data &&
|
|
28309
|
-
post.dataType === 'room');
|
|
28310
|
-
}
|
|
28311
28331
|
|
|
28312
28332
|
const postLinkedObject = (post) => {
|
|
28313
28333
|
return shallowClone(post, {
|
|
@@ -28402,12 +28422,6 @@ const postLinkedObject = (post) => {
|
|
|
28402
28422
|
? (_b = pullFromCache(['file', 'get', (_a = post === null || post === void 0 ? void 0 : post.data) === null || _a === void 0 ? void 0 : _a.fileId])) === null || _b === void 0 ? void 0 : _b.data
|
|
28403
28423
|
: undefined;
|
|
28404
28424
|
},
|
|
28405
|
-
getRoomInfo() {
|
|
28406
|
-
var _a, _b;
|
|
28407
|
-
if (!isAmityRoomPost(post))
|
|
28408
|
-
return;
|
|
28409
|
-
return (_b = pullFromCache(['room', 'get', (_a = post === null || post === void 0 ? void 0 : post.data) === null || _a === void 0 ? void 0 : _a.roomId])) === null || _b === void 0 ? void 0 : _b.data;
|
|
28410
|
-
},
|
|
28411
28425
|
});
|
|
28412
28426
|
};
|
|
28413
28427
|
|
|
@@ -29765,6 +29779,559 @@ const communityLinkedObject = (community) => {
|
|
|
29765
29779
|
} });
|
|
29766
29780
|
};
|
|
29767
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
|
+
|
|
29961
|
+
var EventActionsEnum;
|
|
29962
|
+
(function (EventActionsEnum) {
|
|
29963
|
+
EventActionsEnum["OnEventCreated"] = "onEventCreated";
|
|
29964
|
+
EventActionsEnum["OnEventUpdated"] = "onEventUpdated";
|
|
29965
|
+
EventActionsEnum["OnEventDeleted"] = "onEventDeleted";
|
|
29966
|
+
EventActionsEnum["OnRSVPCreated"] = "onRSVPCreated";
|
|
29967
|
+
EventActionsEnum["OnRSVPUpdated"] = "onRSVPUpdated";
|
|
29968
|
+
})(EventActionsEnum || (EventActionsEnum = {}));
|
|
29969
|
+
|
|
29970
|
+
class RSVPPaginationController extends PaginationController {
|
|
29971
|
+
async getRequest(queryParams, token) {
|
|
29972
|
+
const { limit = COLLECTION_DEFAULT_PAGINATION_LIMIT, eventId } = queryParams, params = __rest(queryParams, ["limit", "eventId"]);
|
|
29973
|
+
const options = token ? { token } : { limit };
|
|
29974
|
+
const { data: response } = await this.http.get(`/api/v1/events/${eventId}/rsvps`, { params: Object.assign(Object.assign({}, params), { options }) });
|
|
29975
|
+
return response;
|
|
29976
|
+
}
|
|
29977
|
+
}
|
|
29978
|
+
|
|
29979
|
+
class RSVPQueryStreamController extends QueryStreamController {
|
|
29980
|
+
constructor(query, cacheKey, notifyChange, preparePayload) {
|
|
29981
|
+
super(query, cacheKey);
|
|
29982
|
+
this.notifyChange = notifyChange;
|
|
29983
|
+
this.preparePayload = preparePayload;
|
|
29984
|
+
}
|
|
29985
|
+
async saveToMainDB(response) {
|
|
29986
|
+
const processedPayload = this.preparePayload(response);
|
|
29987
|
+
const client = getActiveClient();
|
|
29988
|
+
const cachedAt = client.cache && Date.now();
|
|
29989
|
+
if (client.cache)
|
|
29990
|
+
ingestInCache({ eventResponses: [processedPayload] }, { cachedAt });
|
|
29991
|
+
}
|
|
29992
|
+
appendToQueryStream(response, direction, refresh = false) {
|
|
29993
|
+
var _a, _b;
|
|
29994
|
+
if (refresh) {
|
|
29995
|
+
pushToCache(this.cacheKey, {
|
|
29996
|
+
data: response.eventResponses.map(getResolver('eventResponse')),
|
|
29997
|
+
});
|
|
29998
|
+
}
|
|
29999
|
+
else {
|
|
30000
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
30001
|
+
const events = (_b = collection === null || collection === void 0 ? void 0 : collection.data) !== null && _b !== void 0 ? _b : [];
|
|
30002
|
+
pushToCache(this.cacheKey, Object.assign(Object.assign({}, collection), { data: [
|
|
30003
|
+
...new Set([...events, ...response.eventResponses.map(getResolver('eventResponse'))]),
|
|
30004
|
+
] }));
|
|
30005
|
+
}
|
|
30006
|
+
}
|
|
30007
|
+
reactor(action) {
|
|
30008
|
+
return (event) => {
|
|
30009
|
+
var _a;
|
|
30010
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
30011
|
+
if (!collection)
|
|
30012
|
+
return;
|
|
30013
|
+
if (action === EventActionsEnum.OnRSVPCreated) {
|
|
30014
|
+
const client = getActiveClient();
|
|
30015
|
+
if (client.userId !== event.userId)
|
|
30016
|
+
return;
|
|
30017
|
+
collection.data = [...new Set([event.eventId, ...collection.data])];
|
|
30018
|
+
}
|
|
30019
|
+
if (action === EventActionsEnum.OnEventDeleted) {
|
|
30020
|
+
collection.data = collection.data.filter(eventId => eventId !== event.eventId);
|
|
30021
|
+
}
|
|
30022
|
+
pushToCache(this.cacheKey, collection);
|
|
30023
|
+
this.notifyChange({ origin: "event" /* Amity.LiveDataOrigin.EVENT */, loading: false });
|
|
30024
|
+
};
|
|
30025
|
+
}
|
|
30026
|
+
subscribeRTE(createSubscriber) {
|
|
30027
|
+
return createSubscriber.map(subscriber => subscriber.fn(this.reactor(subscriber.action)));
|
|
30028
|
+
}
|
|
30029
|
+
}
|
|
30030
|
+
|
|
30031
|
+
/**
|
|
30032
|
+
* ```js
|
|
30033
|
+
* import { EventRepository } from '@amityco/ts-sdk'
|
|
30034
|
+
* const dispose = EventRepository.onEventCreated(event => {
|
|
30035
|
+
* // ...
|
|
30036
|
+
* })
|
|
30037
|
+
* ```
|
|
30038
|
+
*
|
|
30039
|
+
* Fired when a {@link Amity.Event} has been created
|
|
30040
|
+
*
|
|
30041
|
+
* @param callback The function to call when the event was fired
|
|
30042
|
+
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
30043
|
+
*
|
|
30044
|
+
* @category Event Events
|
|
30045
|
+
*/
|
|
30046
|
+
const onEventCreated = (callback) => createEventEventSubscriber('event.created', callback);
|
|
30047
|
+
|
|
30048
|
+
/**
|
|
30049
|
+
* ```js
|
|
30050
|
+
* import { EventRepository } from '@amityco/ts-sdk'
|
|
30051
|
+
* const dispose = EventRepository.onEventUpdated(event => {
|
|
30052
|
+
* // ...
|
|
30053
|
+
* })
|
|
30054
|
+
* ```
|
|
30055
|
+
*
|
|
30056
|
+
* Fired when a {@link Amity.Event} has been updated
|
|
30057
|
+
*
|
|
30058
|
+
* @param callback The function to call when the event was fired
|
|
30059
|
+
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
30060
|
+
*
|
|
30061
|
+
* @category Event Events
|
|
30062
|
+
*/
|
|
30063
|
+
const onEventUpdated = (callback) => createEventEventSubscriber('event.updated', callback);
|
|
30064
|
+
|
|
30065
|
+
/**
|
|
30066
|
+
* ```js
|
|
30067
|
+
* import { EventRepository } from '@amityco/ts-sdk'
|
|
30068
|
+
* const dispose = EventRepository.onEventDeleted(event => {
|
|
30069
|
+
* // ...
|
|
30070
|
+
* })
|
|
30071
|
+
* ```
|
|
30072
|
+
*
|
|
30073
|
+
* Fired when a {@link Amity.Event} has been deleted
|
|
30074
|
+
*
|
|
30075
|
+
* @param callback The function to call when the event was fired
|
|
30076
|
+
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
30077
|
+
*
|
|
30078
|
+
* @category Event Events
|
|
30079
|
+
*/
|
|
30080
|
+
const onEventDeleted = (callback) => createEventEventSubscriber('event.deleted', callback);
|
|
30081
|
+
|
|
30082
|
+
/**
|
|
30083
|
+
* ```js
|
|
30084
|
+
* import { EventRepository } from '@amityco/ts-sdk'
|
|
30085
|
+
* const dispose = EventRepository.onLocalEventCreated(event => {
|
|
30086
|
+
* // ...
|
|
30087
|
+
* })
|
|
30088
|
+
* ```
|
|
30089
|
+
*
|
|
30090
|
+
* Fired when a {@link Amity.Event} has been created
|
|
30091
|
+
*
|
|
30092
|
+
* @param callback The function to call when the event was fired
|
|
30093
|
+
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
30094
|
+
*
|
|
30095
|
+
* @category Event Events
|
|
30096
|
+
*/
|
|
30097
|
+
const onLocalEventCreated = (callback) => createEventEventSubscriber('local.event.created', callback);
|
|
30098
|
+
|
|
30099
|
+
/**
|
|
30100
|
+
* ```js
|
|
30101
|
+
* import { EventRepository } from '@amityco/ts-sdk'
|
|
30102
|
+
* const dispose = EventRepository.onLocalEventUpdated(event => {
|
|
30103
|
+
* // ...
|
|
30104
|
+
* })
|
|
30105
|
+
* ```
|
|
30106
|
+
*
|
|
30107
|
+
* Fired when a {@link Amity.Event} has been updated
|
|
30108
|
+
*
|
|
30109
|
+
* @param callback The function to call when the event was fired
|
|
30110
|
+
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
30111
|
+
*
|
|
30112
|
+
* @category Event Events
|
|
30113
|
+
*/
|
|
30114
|
+
const onLocalEventUpdated = (callback) => createEventEventSubscriber('local.event.updated', callback);
|
|
30115
|
+
|
|
30116
|
+
/**
|
|
30117
|
+
* ```js
|
|
30118
|
+
* import { EventRepository } from '@amityco/ts-sdk'
|
|
30119
|
+
* const dispose = EventRepository.onLocalEventDeleted(event => {
|
|
30120
|
+
* // ...
|
|
30121
|
+
* })
|
|
30122
|
+
* ```
|
|
30123
|
+
*
|
|
30124
|
+
* Fired when a {@link Amity.Event} has been deleted
|
|
30125
|
+
*
|
|
30126
|
+
* @param callback The function to call when the event was fired
|
|
30127
|
+
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
30128
|
+
*
|
|
30129
|
+
* @category Event Events
|
|
30130
|
+
*/
|
|
30131
|
+
const onLocalEventDeleted = (callback) => createEventEventSubscriber('local.event.deleted', callback);
|
|
30132
|
+
|
|
30133
|
+
/**
|
|
30134
|
+
* ```js
|
|
30135
|
+
* import { EventRepository } from '@amityco/ts-sdk'
|
|
30136
|
+
* const dispose = EventRepository.onRSVPCreated(event => {
|
|
30137
|
+
* // ...
|
|
30138
|
+
* })
|
|
30139
|
+
* ```
|
|
30140
|
+
*
|
|
30141
|
+
* Fired when a {@link Amity.Event} has been created
|
|
30142
|
+
*
|
|
30143
|
+
* @param callback The function to call when the event was fired
|
|
30144
|
+
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
30145
|
+
*
|
|
30146
|
+
* @category Event Events
|
|
30147
|
+
*/
|
|
30148
|
+
const onRSVPCreated = (callback) => createEventResponseSubscriber('event.rsvp.created', callback);
|
|
30149
|
+
|
|
30150
|
+
/**
|
|
30151
|
+
* ```js
|
|
30152
|
+
* import { EventRepository } from '@amityco/ts-sdk'
|
|
30153
|
+
* const dispose = EventRepository.onRSVPUpdated(event => {
|
|
30154
|
+
* // ...
|
|
30155
|
+
* })
|
|
30156
|
+
* ```
|
|
30157
|
+
*
|
|
30158
|
+
* Fired when a {@link Amity.InternalEventResponse} has been updated
|
|
30159
|
+
*
|
|
30160
|
+
* @param callback The function to call when the event was fired
|
|
30161
|
+
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
30162
|
+
*
|
|
30163
|
+
* @category Event Events
|
|
30164
|
+
*/
|
|
30165
|
+
const onRSVPUpdated = (callback) => createEventResponseSubscriber('event.rsvp.updated', callback);
|
|
30166
|
+
|
|
30167
|
+
/**
|
|
30168
|
+
* ```js
|
|
30169
|
+
* import { EventRepository } from '@amityco/ts-sdk'
|
|
30170
|
+
* const dispose = EventRepository.onLocalRSVPCreated(event => {
|
|
30171
|
+
* // ...
|
|
30172
|
+
* })
|
|
30173
|
+
* ```
|
|
30174
|
+
*
|
|
30175
|
+
* Fired when a {@link Amity.Event} has been created
|
|
30176
|
+
*
|
|
30177
|
+
* @param callback The function to call when the event was fired
|
|
30178
|
+
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
30179
|
+
*
|
|
30180
|
+
* @category Event Events
|
|
30181
|
+
*/
|
|
30182
|
+
const onLocalRSVPCreated = (callback) => createEventResponseSubscriber('local.rsvp.created', callback);
|
|
30183
|
+
|
|
30184
|
+
/**
|
|
30185
|
+
* ```js
|
|
30186
|
+
* import { EventRepository } from '@amityco/ts-sdk'
|
|
30187
|
+
* const dispose = EventRepository.onLocalEventUpdated(event => {
|
|
30188
|
+
* // ...
|
|
30189
|
+
* })
|
|
30190
|
+
* ```
|
|
30191
|
+
*
|
|
30192
|
+
* Fired when a {@link Amity.Event} has been updated
|
|
30193
|
+
*
|
|
30194
|
+
* @param callback The function to call when the event was fired
|
|
30195
|
+
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
30196
|
+
*
|
|
30197
|
+
* @category Event Events
|
|
30198
|
+
*/
|
|
30199
|
+
const onLocalRSVPUpdated = (callback) => createEventResponseSubscriber('local.rsvp.updated', callback);
|
|
30200
|
+
|
|
30201
|
+
class RSVPLiveCollectionController extends LiveCollectionController {
|
|
30202
|
+
constructor(query, callback) {
|
|
30203
|
+
const queryStreamId = hash(query);
|
|
30204
|
+
const cacheKey = ['eventResponse', 'collection', queryStreamId];
|
|
30205
|
+
const paginationController = new RSVPPaginationController(query);
|
|
30206
|
+
super(paginationController, queryStreamId, cacheKey, callback);
|
|
30207
|
+
this.query = query;
|
|
30208
|
+
this.queryStreamController = new RSVPQueryStreamController(this.query, this.cacheKey, this.notifyChange.bind(this), prepareEventResponsePayload);
|
|
30209
|
+
this.callback = callback.bind(this);
|
|
30210
|
+
this.loadPage({ initial: true });
|
|
30211
|
+
}
|
|
30212
|
+
setup() {
|
|
30213
|
+
var _a;
|
|
30214
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
30215
|
+
if (!collection)
|
|
30216
|
+
pushToCache(this.cacheKey, { data: [], params: this.query });
|
|
30217
|
+
}
|
|
30218
|
+
async persistModel(queryPayload) {
|
|
30219
|
+
await this.queryStreamController.saveToMainDB(queryPayload);
|
|
30220
|
+
}
|
|
30221
|
+
persistQueryStream({ response, direction, refresh, }) {
|
|
30222
|
+
this.queryStreamController.appendToQueryStream(response, direction, refresh);
|
|
30223
|
+
}
|
|
30224
|
+
startSubscription() {
|
|
30225
|
+
return this.queryStreamController.subscribeRTE([
|
|
30226
|
+
{ fn: onRSVPCreated, action: EventActionsEnum.OnRSVPCreated },
|
|
30227
|
+
{ fn: onRSVPUpdated, action: EventActionsEnum.OnRSVPUpdated },
|
|
30228
|
+
{ fn: onLocalRSVPCreated, action: EventActionsEnum.OnRSVPCreated },
|
|
30229
|
+
{ fn: onLocalRSVPUpdated, action: EventActionsEnum.OnRSVPUpdated },
|
|
30230
|
+
]);
|
|
30231
|
+
}
|
|
30232
|
+
notifyChange({ origin, loading, error }) {
|
|
30233
|
+
var _a, _b;
|
|
30234
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
30235
|
+
if (!collection)
|
|
30236
|
+
return;
|
|
30237
|
+
const data = (_b = collection.data
|
|
30238
|
+
.map(eventId => pullFromCache(['eventResponse', 'get', eventId]))
|
|
30239
|
+
.filter(isNonNullable)
|
|
30240
|
+
.map(({ data }) => data)) !== null && _b !== void 0 ? _b : [];
|
|
30241
|
+
if (!this.shouldNotify(data) && origin === "event" /* Amity.LiveDataOrigin.EVENT */)
|
|
30242
|
+
return;
|
|
30243
|
+
this.callback({
|
|
30244
|
+
data,
|
|
30245
|
+
error,
|
|
30246
|
+
loading,
|
|
30247
|
+
hasNextPage: !!this.paginationController.getNextToken(),
|
|
30248
|
+
onNextPage: () => this.loadPage({ direction: "next" /* Amity.LiveCollectionPageDirection.NEXT */ }),
|
|
30249
|
+
});
|
|
30250
|
+
}
|
|
30251
|
+
}
|
|
30252
|
+
|
|
30253
|
+
/**
|
|
30254
|
+
* Get events
|
|
30255
|
+
*
|
|
30256
|
+
* @param params the query parameters
|
|
30257
|
+
* @param callback the callback to be called when the events are updated
|
|
30258
|
+
* @returns events
|
|
30259
|
+
*
|
|
30260
|
+
* @category RSVP Live Collection
|
|
30261
|
+
*
|
|
30262
|
+
*/
|
|
30263
|
+
const getRSVPs = (params, callback, config) => {
|
|
30264
|
+
const { log, cache } = getActiveClient();
|
|
30265
|
+
if (!cache)
|
|
30266
|
+
console.log(ENABLE_CACHE_MESSAGE);
|
|
30267
|
+
const timestamp = Date.now();
|
|
30268
|
+
log(`getRSVPs: (tmpid: ${timestamp}) > listen`);
|
|
30269
|
+
const eventLiveCollection = new RSVPLiveCollectionController(params, callback);
|
|
30270
|
+
const disposers = eventLiveCollection.startSubscription();
|
|
30271
|
+
const cacheKey = eventLiveCollection.getCacheKey();
|
|
30272
|
+
disposers.push(() => dropFromCache(cacheKey));
|
|
30273
|
+
return () => {
|
|
30274
|
+
log(`getRSVPs (tmpid: ${timestamp}) > dispose`);
|
|
30275
|
+
disposers.forEach(fn => fn());
|
|
30276
|
+
};
|
|
30277
|
+
};
|
|
30278
|
+
|
|
30279
|
+
const eventLinkedObject = (event) => {
|
|
30280
|
+
return Object.assign(Object.assign({}, event), { get creator() {
|
|
30281
|
+
const cacheData = pullFromCache(['user', 'get', event.userId]);
|
|
30282
|
+
if (!(cacheData === null || cacheData === void 0 ? void 0 : cacheData.data))
|
|
30283
|
+
return;
|
|
30284
|
+
return userLinkedObject(cacheData.data);
|
|
30285
|
+
},
|
|
30286
|
+
get discussionCommunity() {
|
|
30287
|
+
if (!event.discussionCommunityId)
|
|
30288
|
+
return;
|
|
30289
|
+
const cacheData = pullFromCache([
|
|
30290
|
+
'discussionCommunity',
|
|
30291
|
+
'get',
|
|
30292
|
+
event.discussionCommunityId,
|
|
30293
|
+
]);
|
|
30294
|
+
if (!(cacheData === null || cacheData === void 0 ? void 0 : cacheData.data))
|
|
30295
|
+
return;
|
|
30296
|
+
return communityLinkedObject(cacheData.data);
|
|
30297
|
+
},
|
|
30298
|
+
get targetCommunity() {
|
|
30299
|
+
if (!event.originId)
|
|
30300
|
+
return;
|
|
30301
|
+
const cacheData = pullFromCache(['community', 'get', event.originId]);
|
|
30302
|
+
if (!(cacheData === null || cacheData === void 0 ? void 0 : cacheData.data))
|
|
30303
|
+
return;
|
|
30304
|
+
return communityLinkedObject(cacheData.data);
|
|
30305
|
+
},
|
|
30306
|
+
get coverImage() {
|
|
30307
|
+
if (!event.coverImageFileId)
|
|
30308
|
+
return;
|
|
30309
|
+
const cacheData = pullFromCache(['file', 'get', event.coverImageFileId]);
|
|
30310
|
+
if (!(cacheData === null || cacheData === void 0 ? void 0 : cacheData.data))
|
|
30311
|
+
return;
|
|
30312
|
+
return cacheData.data;
|
|
30313
|
+
},
|
|
30314
|
+
get liveStream() {
|
|
30315
|
+
if (!event.livestreamId)
|
|
30316
|
+
return;
|
|
30317
|
+
const cacheData = pullFromCache(['stream', 'get', event.livestreamId]);
|
|
30318
|
+
if (!(cacheData === null || cacheData === void 0 ? void 0 : cacheData.data))
|
|
30319
|
+
return;
|
|
30320
|
+
return cacheData.data;
|
|
30321
|
+
}, createRSVP: async (status) => {
|
|
30322
|
+
const { data } = await createRSVP(event.eventId, status);
|
|
30323
|
+
return data;
|
|
30324
|
+
}, updateRSVP: async (status) => {
|
|
30325
|
+
const { data } = await updateRSVP(event.eventId, status);
|
|
30326
|
+
return data;
|
|
30327
|
+
}, getMyRSVP: async () => {
|
|
30328
|
+
const { data } = await getMyRSVP(event.eventId);
|
|
30329
|
+
return data;
|
|
30330
|
+
}, getRSVPs: (params, callback) => {
|
|
30331
|
+
return getRSVPs(Object.assign({ eventId: event.eventId }, params), callback);
|
|
30332
|
+
} });
|
|
30333
|
+
};
|
|
30334
|
+
|
|
29768
30335
|
const LinkedObject = {
|
|
29769
30336
|
ad: adLinkedObject,
|
|
29770
30337
|
comment: commentLinkedObject,
|
|
@@ -29783,6 +30350,7 @@ const LinkedObject = {
|
|
|
29783
30350
|
invitation: invitationLinkedObject,
|
|
29784
30351
|
joinRequest: joinRequestLinkedObject,
|
|
29785
30352
|
channelMember: channelMemberLinkedObject,
|
|
30353
|
+
event: eventLinkedObject,
|
|
29786
30354
|
};
|
|
29787
30355
|
|
|
29788
30356
|
/* begin_public_function
|
|
@@ -43767,729 +44335,6 @@ var index$8 = /*#__PURE__*/Object.freeze({
|
|
|
43767
44335
|
getStreams: getStreams
|
|
43768
44336
|
});
|
|
43769
44337
|
|
|
43770
|
-
/* begin_public_function
|
|
43771
|
-
id: room.create
|
|
43772
|
-
*/
|
|
43773
|
-
/**
|
|
43774
|
-
* ```js
|
|
43775
|
-
* import { createRoom } from '@amityco/ts-sdk'
|
|
43776
|
-
* const created = await createRoom({ title: 'my room', 'thumbnailFileId': fileId })
|
|
43777
|
-
* ```
|
|
43778
|
-
*
|
|
43779
|
-
* Creates an {@link Amity.Room}
|
|
43780
|
-
*
|
|
43781
|
-
* @param bundle The data necessary to create a new {@link Amity.Room}
|
|
43782
|
-
* @returns The newly created {@link Amity.Room}
|
|
43783
|
-
*
|
|
43784
|
-
* @category Room API
|
|
43785
|
-
* @async
|
|
43786
|
-
*/
|
|
43787
|
-
const createRoom = async (bundle) => {
|
|
43788
|
-
const client = getActiveClient();
|
|
43789
|
-
client.log('room/createRoom', bundle);
|
|
43790
|
-
const { data } = await client.http.post('/api/v1/rooms', bundle);
|
|
43791
|
-
fireEvent('local.room.created', data);
|
|
43792
|
-
const cachedAt = client.cache && Date.now();
|
|
43793
|
-
// TODO: check if should pick `users` filed which contains participants - if no need to ingest in the cache
|
|
43794
|
-
if (client.cache)
|
|
43795
|
-
ingestInCache(data, { cachedAt });
|
|
43796
|
-
const { rooms } = data;
|
|
43797
|
-
return {
|
|
43798
|
-
data: rooms[0],
|
|
43799
|
-
cachedAt,
|
|
43800
|
-
};
|
|
43801
|
-
};
|
|
43802
|
-
/* end_public_function */
|
|
43803
|
-
|
|
43804
|
-
/* begin_public_function
|
|
43805
|
-
id: room.update
|
|
43806
|
-
*/
|
|
43807
|
-
/**
|
|
43808
|
-
* ```js
|
|
43809
|
-
* import { updateRoom } from '@amityco/ts-sdk'
|
|
43810
|
-
* const updated = await updateRoom('roomId', { title: 'updated title' })
|
|
43811
|
-
* ```
|
|
43812
|
-
*
|
|
43813
|
-
* Updates an {@link Amity.InternalRoom}
|
|
43814
|
-
*
|
|
43815
|
-
* @param roomId The ID of the room to update
|
|
43816
|
-
* @param bundle The data to update the room with
|
|
43817
|
-
* @returns The updated {@link Amity.InternalRoom}
|
|
43818
|
-
*
|
|
43819
|
-
* @category Room API
|
|
43820
|
-
* @async
|
|
43821
|
-
*/
|
|
43822
|
-
const updateRoom = async (roomId, bundle) => {
|
|
43823
|
-
const client = getActiveClient();
|
|
43824
|
-
client.log('room/updateRoom', { roomId, bundle });
|
|
43825
|
-
const { data } = await client.http.put(`/api/v1/rooms/${roomId}`, bundle);
|
|
43826
|
-
fireEvent('local.room.updated', data);
|
|
43827
|
-
const cachedAt = client.cache && Date.now();
|
|
43828
|
-
if (client.cache)
|
|
43829
|
-
ingestInCache(data, { cachedAt });
|
|
43830
|
-
const { rooms } = data;
|
|
43831
|
-
return {
|
|
43832
|
-
data: rooms[0],
|
|
43833
|
-
cachedAt,
|
|
43834
|
-
};
|
|
43835
|
-
};
|
|
43836
|
-
/* end_public_function */
|
|
43837
|
-
|
|
43838
|
-
/* begin_public_function
|
|
43839
|
-
id: room.delete
|
|
43840
|
-
*/
|
|
43841
|
-
/**
|
|
43842
|
-
* ```js
|
|
43843
|
-
* import { deleteRoom } from '@amityco/ts-sdk'
|
|
43844
|
-
* const result = await deleteRoom('roomId')
|
|
43845
|
-
* ```
|
|
43846
|
-
*
|
|
43847
|
-
* Deletes an {@link Amity.Room}
|
|
43848
|
-
*
|
|
43849
|
-
* @param roomId The ID of the room to delete
|
|
43850
|
-
* @returns Promise that resolves when the room is deleted
|
|
43851
|
-
*
|
|
43852
|
-
* @category Room API
|
|
43853
|
-
* @async
|
|
43854
|
-
*/
|
|
43855
|
-
const deleteRoom = async (roomId) => {
|
|
43856
|
-
const client = getActiveClient();
|
|
43857
|
-
client.log('room/deleteRoom', { roomId });
|
|
43858
|
-
await client.http.delete(`/api/v1/rooms/${roomId}`);
|
|
43859
|
-
fireEvent('local.room.deleted', { rooms: [{ _id: roomId }] });
|
|
43860
|
-
};
|
|
43861
|
-
/* end_public_function */
|
|
43862
|
-
|
|
43863
|
-
/* begin_public_function
|
|
43864
|
-
id: room.stop
|
|
43865
|
-
*/
|
|
43866
|
-
/**
|
|
43867
|
-
* ```js
|
|
43868
|
-
* import { stopRoom } from '@amityco/ts-sdk'
|
|
43869
|
-
* const result = await stopRoom('roomId')
|
|
43870
|
-
* ```
|
|
43871
|
-
*
|
|
43872
|
-
* Stops a room's broadcasting
|
|
43873
|
-
*
|
|
43874
|
-
* @param roomId The ID of the room to stop
|
|
43875
|
-
* @returns The updated room data
|
|
43876
|
-
*
|
|
43877
|
-
* @category Room API
|
|
43878
|
-
* @async
|
|
43879
|
-
*/
|
|
43880
|
-
const stopRoom = async (roomId) => {
|
|
43881
|
-
const client = getActiveClient();
|
|
43882
|
-
client.log('room/stopRoom', { roomId });
|
|
43883
|
-
const { data } = await client.http.post(`/api/v1/rooms/${roomId}/stop`);
|
|
43884
|
-
fireEvent('local.room.stopped', data);
|
|
43885
|
-
const cachedAt = client.cache && Date.now();
|
|
43886
|
-
if (client.cache)
|
|
43887
|
-
ingestInCache(data, { cachedAt });
|
|
43888
|
-
const { rooms } = data;
|
|
43889
|
-
return {
|
|
43890
|
-
data: rooms[0],
|
|
43891
|
-
cachedAt,
|
|
43892
|
-
};
|
|
43893
|
-
};
|
|
43894
|
-
/* end_public_function */
|
|
43895
|
-
|
|
43896
|
-
/* begin_public_function
|
|
43897
|
-
id: room.getToken
|
|
43898
|
-
*/
|
|
43899
|
-
/**
|
|
43900
|
-
* ```js
|
|
43901
|
-
* import { getRoomToken } from '@amityco/ts-sdk'
|
|
43902
|
-
* const token = await getRoomToken('roomId')
|
|
43903
|
-
* ```
|
|
43904
|
-
*
|
|
43905
|
-
* Gets an access token for a room
|
|
43906
|
-
*
|
|
43907
|
-
* @param roomId The ID of the room to get token for
|
|
43908
|
-
* @returns The room access token
|
|
43909
|
-
*
|
|
43910
|
-
* @category Room API
|
|
43911
|
-
* @async
|
|
43912
|
-
*/
|
|
43913
|
-
const getRoomToken = async (roomId) => {
|
|
43914
|
-
const client = getActiveClient();
|
|
43915
|
-
client.log('room/getRoomToken', { roomId });
|
|
43916
|
-
const { data } = await client.http.get(`/api/v1/rooms/${roomId}/token`);
|
|
43917
|
-
return data;
|
|
43918
|
-
};
|
|
43919
|
-
/* end_public_function */
|
|
43920
|
-
|
|
43921
|
-
/* begin_public_function
|
|
43922
|
-
id: room.getRecordedUrl
|
|
43923
|
-
*/
|
|
43924
|
-
/**
|
|
43925
|
-
* ```js
|
|
43926
|
-
* import { getRecordedUrl } from '@amityco/ts-sdk'
|
|
43927
|
-
* const recordedUrl = await getRecordedUrl('roomId')
|
|
43928
|
-
* ```
|
|
43929
|
-
*
|
|
43930
|
-
* Gets the recorded URL for a room
|
|
43931
|
-
*
|
|
43932
|
-
* @param roomId The ID of the room to get recorded URL for
|
|
43933
|
-
* @returns The recorded URL information
|
|
43934
|
-
*
|
|
43935
|
-
* @category Room API
|
|
43936
|
-
* @async
|
|
43937
|
-
*/
|
|
43938
|
-
const getRecordedUrl = async (roomId) => {
|
|
43939
|
-
const client = getActiveClient();
|
|
43940
|
-
client.log('room/getRecordedUrl', { roomId });
|
|
43941
|
-
const { data } = await client.http.get(`/api/v1/rooms/${roomId}/recorded`);
|
|
43942
|
-
return data;
|
|
43943
|
-
};
|
|
43944
|
-
/* end_public_function */
|
|
43945
|
-
|
|
43946
|
-
/**
|
|
43947
|
-
* ```js
|
|
43948
|
-
* import { onRoomStartBroadcasting } from '@amityco/ts-sdk'
|
|
43949
|
-
* const dispose = onRoomStartBroadcasting(room => {
|
|
43950
|
-
* // ...
|
|
43951
|
-
* })
|
|
43952
|
-
* ```
|
|
43953
|
-
*
|
|
43954
|
-
* Fired when a {@link Amity.Room} has started broadcasting
|
|
43955
|
-
*
|
|
43956
|
-
* @param callback The function to call when the event was fired
|
|
43957
|
-
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
43958
|
-
*
|
|
43959
|
-
* @category Room Events
|
|
43960
|
-
*/
|
|
43961
|
-
const onRoomStartBroadcasting = (callback) => {
|
|
43962
|
-
const client = getActiveClient();
|
|
43963
|
-
const filter = (payload) => {
|
|
43964
|
-
ingestInCache(payload);
|
|
43965
|
-
callback(payload.rooms[0]);
|
|
43966
|
-
};
|
|
43967
|
-
return createEventSubscriber(client, 'room/onRoomStartBroadcasting', 'room.startBroadcasting', filter);
|
|
43968
|
-
};
|
|
43969
|
-
|
|
43970
|
-
/**
|
|
43971
|
-
* ```js
|
|
43972
|
-
* import { onRoomWaitingReconnect } from '@amityco/ts-sdk'
|
|
43973
|
-
* const dispose = onRoomWaitingReconnect(room => {
|
|
43974
|
-
* // ...
|
|
43975
|
-
* })
|
|
43976
|
-
* ```
|
|
43977
|
-
*
|
|
43978
|
-
* Fired when a {@link Amity.Room} is waiting for reconnection
|
|
43979
|
-
*
|
|
43980
|
-
* @param callback The function to call when the event was fired
|
|
43981
|
-
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
43982
|
-
*
|
|
43983
|
-
* @category Room Events
|
|
43984
|
-
*/
|
|
43985
|
-
const onRoomWaitingReconnect = (callback) => {
|
|
43986
|
-
const client = getActiveClient();
|
|
43987
|
-
const filter = (payload) => {
|
|
43988
|
-
ingestInCache(payload);
|
|
43989
|
-
callback(payload.rooms[0]);
|
|
43990
|
-
};
|
|
43991
|
-
return createEventSubscriber(client, 'room/onRoomWaitingReconnect', 'room.waitingReconnect', filter);
|
|
43992
|
-
};
|
|
43993
|
-
|
|
43994
|
-
/**
|
|
43995
|
-
* ```js
|
|
43996
|
-
* import { onRoomEndBroadcasting } from '@amityco/ts-sdk'
|
|
43997
|
-
* const dispose = onRoomEndBroadcasting(room => {
|
|
43998
|
-
* // ...
|
|
43999
|
-
* })
|
|
44000
|
-
* ```
|
|
44001
|
-
*
|
|
44002
|
-
* Fired when a {@link Amity.Room} has ended broadcasting
|
|
44003
|
-
*
|
|
44004
|
-
* @param callback The function to call when the event was fired
|
|
44005
|
-
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
44006
|
-
*
|
|
44007
|
-
* @category Room Events
|
|
44008
|
-
*/
|
|
44009
|
-
const onRoomEndBroadcasting = (callback) => {
|
|
44010
|
-
const client = getActiveClient();
|
|
44011
|
-
const filter = (payload) => {
|
|
44012
|
-
ingestInCache(payload);
|
|
44013
|
-
callback(payload.rooms[0]);
|
|
44014
|
-
};
|
|
44015
|
-
return createEventSubscriber(client, 'room/onRoomEndBroadcasting', 'room.endBroadcasting', filter);
|
|
44016
|
-
};
|
|
44017
|
-
|
|
44018
|
-
/**
|
|
44019
|
-
* ```js
|
|
44020
|
-
* import { onRoomRecordedAvailable } from '@amityco/ts-sdk'
|
|
44021
|
-
* const dispose = onRoomRecordedAvailable(room => {
|
|
44022
|
-
* // ...
|
|
44023
|
-
* })
|
|
44024
|
-
* ```
|
|
44025
|
-
*
|
|
44026
|
-
* Fired when a {@link Amity.Room} recorded content becomes available
|
|
44027
|
-
*
|
|
44028
|
-
* @param callback The function to call when the event was fired
|
|
44029
|
-
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
44030
|
-
*
|
|
44031
|
-
* @category Room Events
|
|
44032
|
-
*/
|
|
44033
|
-
const onRoomRecordedAvailable = (callback) => {
|
|
44034
|
-
const client = getActiveClient();
|
|
44035
|
-
const filter = (payload) => {
|
|
44036
|
-
ingestInCache(payload);
|
|
44037
|
-
callback(payload.rooms[0]);
|
|
44038
|
-
};
|
|
44039
|
-
return createEventSubscriber(client, 'room/onRoomRecordedAvailable', 'room.recordedAvailable', filter);
|
|
44040
|
-
};
|
|
44041
|
-
|
|
44042
|
-
/**
|
|
44043
|
-
* ```js
|
|
44044
|
-
* import { onRoomParticipantInviting } from '@amityco/ts-sdk'
|
|
44045
|
-
* const dispose = onRoomParticipantInviting(room => {
|
|
44046
|
-
* // ...
|
|
44047
|
-
* })
|
|
44048
|
-
* ```
|
|
44049
|
-
*
|
|
44050
|
-
* Fired when a participant is being invited to a {@link Amity.Room}
|
|
44051
|
-
*
|
|
44052
|
-
* @param callback The function to call when the event was fired
|
|
44053
|
-
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
44054
|
-
*
|
|
44055
|
-
* @category Room Events
|
|
44056
|
-
*/
|
|
44057
|
-
const onRoomParticipantInviting = (callback) => {
|
|
44058
|
-
const client = getActiveClient();
|
|
44059
|
-
const filter = (payload) => {
|
|
44060
|
-
ingestInCache(payload);
|
|
44061
|
-
callback(payload.rooms[0]);
|
|
44062
|
-
};
|
|
44063
|
-
return createEventSubscriber(client, 'room/onRoomParticipantInviting', 'room.participantInviting', filter);
|
|
44064
|
-
};
|
|
44065
|
-
|
|
44066
|
-
/**
|
|
44067
|
-
* ```js
|
|
44068
|
-
* import { onRoomParticipantJoined } from '@amityco/ts-sdk'
|
|
44069
|
-
* const dispose = onRoomParticipantJoined(room => {
|
|
44070
|
-
* // ...
|
|
44071
|
-
* })
|
|
44072
|
-
* ```
|
|
44073
|
-
*
|
|
44074
|
-
* Fired when a participant has joined a {@link Amity.Room}
|
|
44075
|
-
*
|
|
44076
|
-
* @param callback The function to call when the event was fired
|
|
44077
|
-
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
44078
|
-
*
|
|
44079
|
-
* @category Room Events
|
|
44080
|
-
*/
|
|
44081
|
-
const onRoomParticipantJoined = (callback) => {
|
|
44082
|
-
const client = getActiveClient();
|
|
44083
|
-
const filter = (payload) => {
|
|
44084
|
-
ingestInCache(payload);
|
|
44085
|
-
callback(payload.rooms[0]);
|
|
44086
|
-
};
|
|
44087
|
-
return createEventSubscriber(client, 'room/onRoomParticipantJoined', 'room.participantJoined', filter);
|
|
44088
|
-
};
|
|
44089
|
-
|
|
44090
|
-
/**
|
|
44091
|
-
* ```js
|
|
44092
|
-
* import { onRoomParticipantLeft } from '@amityco/ts-sdk'
|
|
44093
|
-
* const dispose = onRoomParticipantLeft(room => {
|
|
44094
|
-
* // ...
|
|
44095
|
-
* })
|
|
44096
|
-
* ```
|
|
44097
|
-
*
|
|
44098
|
-
* Fired when a participant has left a {@link Amity.Room}
|
|
44099
|
-
*
|
|
44100
|
-
* @param callback The function to call when the event was fired
|
|
44101
|
-
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
44102
|
-
*
|
|
44103
|
-
* @category Room Events
|
|
44104
|
-
*/
|
|
44105
|
-
const onRoomParticipantLeft = (callback) => {
|
|
44106
|
-
const client = getActiveClient();
|
|
44107
|
-
const filter = (payload) => {
|
|
44108
|
-
ingestInCache(payload);
|
|
44109
|
-
callback(payload.rooms[0]);
|
|
44110
|
-
};
|
|
44111
|
-
return createEventSubscriber(client, 'room/onRoomParticipantLeft', 'room.participantLeft', filter);
|
|
44112
|
-
};
|
|
44113
|
-
|
|
44114
|
-
/**
|
|
44115
|
-
* ```js
|
|
44116
|
-
* import { onRoomCreated } from '@amityco/ts-sdk'
|
|
44117
|
-
* const dispose = onRoomCreated(room => {
|
|
44118
|
-
* // ...
|
|
44119
|
-
* })
|
|
44120
|
-
* ```
|
|
44121
|
-
*
|
|
44122
|
-
* Fired when a {@link Amity.Room} has been created locally
|
|
44123
|
-
*
|
|
44124
|
-
* @param callback The function to call when the event was fired
|
|
44125
|
-
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
44126
|
-
*
|
|
44127
|
-
* @category Room Events
|
|
44128
|
-
*/
|
|
44129
|
-
const onRoomCreated = (callback) => {
|
|
44130
|
-
const client = getActiveClient();
|
|
44131
|
-
const filter = (payload) => {
|
|
44132
|
-
ingestInCache(payload);
|
|
44133
|
-
callback(payload.rooms[0]);
|
|
44134
|
-
};
|
|
44135
|
-
return createEventSubscriber(client, 'room/onRoomCreated', 'local.room.created', filter);
|
|
44136
|
-
};
|
|
44137
|
-
|
|
44138
|
-
/**
|
|
44139
|
-
* ```js
|
|
44140
|
-
* import { onRoomUpdated } from '@amityco/ts-sdk'
|
|
44141
|
-
* const dispose = onRoomUpdated(room => {
|
|
44142
|
-
* // ...
|
|
44143
|
-
* })
|
|
44144
|
-
* ```
|
|
44145
|
-
*
|
|
44146
|
-
* Fired when a {@link Amity.Room} has been updated locally
|
|
44147
|
-
*
|
|
44148
|
-
* @param callback The function to call when the event was fired
|
|
44149
|
-
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
44150
|
-
*
|
|
44151
|
-
* @category Room Events
|
|
44152
|
-
*/
|
|
44153
|
-
const onRoomUpdated = (callback) => {
|
|
44154
|
-
const client = getActiveClient();
|
|
44155
|
-
const filter = (payload) => {
|
|
44156
|
-
ingestInCache(payload);
|
|
44157
|
-
callback(payload.rooms[0]);
|
|
44158
|
-
};
|
|
44159
|
-
return createEventSubscriber(client, 'room/onRoomUpdated', 'local.room.updated', filter);
|
|
44160
|
-
};
|
|
44161
|
-
|
|
44162
|
-
/**
|
|
44163
|
-
* ```js
|
|
44164
|
-
* import { onRoomDeleted } from '@amityco/ts-sdk'
|
|
44165
|
-
* const dispose = onRoomDeleted(room => {
|
|
44166
|
-
* // ...
|
|
44167
|
-
* })
|
|
44168
|
-
* ```
|
|
44169
|
-
*
|
|
44170
|
-
* Fired when a {@link Amity.Room} has been deleted locally
|
|
44171
|
-
*
|
|
44172
|
-
* @param callback The function to call when the event was fired
|
|
44173
|
-
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
44174
|
-
*
|
|
44175
|
-
* @category Room Events
|
|
44176
|
-
*/
|
|
44177
|
-
const onRoomDeleted = (callback) => {
|
|
44178
|
-
const client = getActiveClient();
|
|
44179
|
-
const filter = (payload) => {
|
|
44180
|
-
ingestInCache(payload);
|
|
44181
|
-
callback(payload.rooms[0]);
|
|
44182
|
-
};
|
|
44183
|
-
return createEventSubscriber(client, 'room/onRoomDeleted', 'local.room.deleted', filter);
|
|
44184
|
-
};
|
|
44185
|
-
|
|
44186
|
-
/**
|
|
44187
|
-
* ```js
|
|
44188
|
-
* import { onRoomStopped } from '@amityco/ts-sdk'
|
|
44189
|
-
* const dispose = onRoomStopped(room => {
|
|
44190
|
-
* // ...
|
|
44191
|
-
* })
|
|
44192
|
-
* ```
|
|
44193
|
-
*
|
|
44194
|
-
* Fired when a {@link Amity.Room} has been stopped locally
|
|
44195
|
-
*
|
|
44196
|
-
* @param callback The function to call when the event was fired
|
|
44197
|
-
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
44198
|
-
*
|
|
44199
|
-
* @category Room Events
|
|
44200
|
-
*/
|
|
44201
|
-
const onRoomStopped = (callback) => {
|
|
44202
|
-
const client = getActiveClient();
|
|
44203
|
-
const filter = (payload) => {
|
|
44204
|
-
ingestInCache(payload);
|
|
44205
|
-
callback(payload.rooms[0]);
|
|
44206
|
-
};
|
|
44207
|
-
return createEventSubscriber(client, 'room/onRoomStopped', 'local.room.stopped', filter);
|
|
44208
|
-
};
|
|
44209
|
-
|
|
44210
|
-
const getRoomById = async (roomId) => {
|
|
44211
|
-
const client = getActiveClient();
|
|
44212
|
-
client.log('room/getRoomById', roomId);
|
|
44213
|
-
// Check if room is in tombstone
|
|
44214
|
-
isInTombstone('room', roomId);
|
|
44215
|
-
let data;
|
|
44216
|
-
try {
|
|
44217
|
-
const response = await client.http.get(`/api/v1/rooms/${roomId}`);
|
|
44218
|
-
data = response.data;
|
|
44219
|
-
}
|
|
44220
|
-
catch (error) {
|
|
44221
|
-
if (checkIfShouldGoesToTombstone(error === null || error === void 0 ? void 0 : error.code)) {
|
|
44222
|
-
pushToTombstone('room', roomId);
|
|
44223
|
-
}
|
|
44224
|
-
throw error;
|
|
44225
|
-
}
|
|
44226
|
-
const cachedAt = client.cache && Date.now();
|
|
44227
|
-
if (client.cache) {
|
|
44228
|
-
ingestInCache(data, { cachedAt });
|
|
44229
|
-
}
|
|
44230
|
-
return {
|
|
44231
|
-
data: data.rooms[0],
|
|
44232
|
-
cachedAt,
|
|
44233
|
-
};
|
|
44234
|
-
};
|
|
44235
|
-
getRoomById.locally = (roomId) => {
|
|
44236
|
-
const client = getActiveClient();
|
|
44237
|
-
client.log('room/getRoomById.locally', roomId);
|
|
44238
|
-
// Check if room is in tombstone
|
|
44239
|
-
isInTombstone('room', roomId);
|
|
44240
|
-
const cachedAt = client.cache && Date.now();
|
|
44241
|
-
const roomCache = pullFromCache(['room', 'get', roomId]);
|
|
44242
|
-
if (!roomCache)
|
|
44243
|
-
return;
|
|
44244
|
-
return {
|
|
44245
|
-
data: roomCache.data,
|
|
44246
|
-
cachedAt,
|
|
44247
|
-
};
|
|
44248
|
-
};
|
|
44249
|
-
|
|
44250
|
-
const getRoom = (roomId, callback) => {
|
|
44251
|
-
// TODO: add callbackDataSelector if there are linked object fields
|
|
44252
|
-
return liveObject(roomId, callback, '_id', getRoomById, [
|
|
44253
|
-
onRoomEndBroadcasting,
|
|
44254
|
-
onRoomStartBroadcasting,
|
|
44255
|
-
onRoomWaitingReconnect,
|
|
44256
|
-
onRoomRecordedAvailable,
|
|
44257
|
-
]);
|
|
44258
|
-
};
|
|
44259
|
-
|
|
44260
|
-
class RoomPaginationController extends PaginationController {
|
|
44261
|
-
async getRequest(queryParams, token) {
|
|
44262
|
-
const { limit = COLLECTION_DEFAULT_PAGINATION_LIMIT, includeDeleted } = queryParams, params = __rest(queryParams, ["limit", "includeDeleted"]);
|
|
44263
|
-
const baseOptions = {
|
|
44264
|
-
type: params.sortBy || queryParams.limit ? 'pagination' : undefined,
|
|
44265
|
-
};
|
|
44266
|
-
const options = token ? Object.assign(Object.assign({}, baseOptions), { token }) : Object.assign(Object.assign({}, baseOptions), { limit });
|
|
44267
|
-
const { data: queryResponse } = await this.http.get(`/api/v1/rooms`, {
|
|
44268
|
-
params: Object.assign(Object.assign({}, params), { isDeleted: inferIsDeleted(includeDeleted), options }),
|
|
44269
|
-
});
|
|
44270
|
-
return queryResponse;
|
|
44271
|
-
}
|
|
44272
|
-
}
|
|
44273
|
-
|
|
44274
|
-
var EnumRoomActions;
|
|
44275
|
-
(function (EnumRoomActions) {
|
|
44276
|
-
EnumRoomActions["OnRoomCreated"] = "OnRoomCreated";
|
|
44277
|
-
EnumRoomActions["OnRoomUpdated"] = "OnRoomUpdated";
|
|
44278
|
-
EnumRoomActions["OnRoomDeleted"] = "OnRoomDeleted";
|
|
44279
|
-
EnumRoomActions["OnRoomStartBroadcasting"] = "OnRoomStartBroadcasting";
|
|
44280
|
-
EnumRoomActions["OnRoomEndBroadcasting"] = "OnRoomEndBroadcasting";
|
|
44281
|
-
EnumRoomActions["OnRoomParticipantJoined"] = "OnRoomParticipantJoined";
|
|
44282
|
-
EnumRoomActions["OnRoomParticipantLeft"] = "OnRoomParticipantLeft";
|
|
44283
|
-
})(EnumRoomActions || (EnumRoomActions = {}));
|
|
44284
|
-
|
|
44285
|
-
class RoomQueryStreamController extends QueryStreamController {
|
|
44286
|
-
constructor(query, cacheKey, notifyChange, preparePayload) {
|
|
44287
|
-
super(query, cacheKey);
|
|
44288
|
-
this.notifyChange = notifyChange;
|
|
44289
|
-
this.preparePayload = preparePayload;
|
|
44290
|
-
}
|
|
44291
|
-
async saveToMainDB(response) {
|
|
44292
|
-
const processedPayload = await this.preparePayload(response);
|
|
44293
|
-
const client = getActiveClient();
|
|
44294
|
-
const cachedAt = client.cache && Date.now();
|
|
44295
|
-
if (client.cache) {
|
|
44296
|
-
ingestInCache(processedPayload, { cachedAt });
|
|
44297
|
-
}
|
|
44298
|
-
}
|
|
44299
|
-
appendToQueryStream(response, direction, refresh = false) {
|
|
44300
|
-
var _a, _b;
|
|
44301
|
-
if (refresh) {
|
|
44302
|
-
pushToCache(this.cacheKey, {
|
|
44303
|
-
data: response.rooms.map(getResolver('room')),
|
|
44304
|
-
});
|
|
44305
|
-
}
|
|
44306
|
-
else {
|
|
44307
|
-
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
44308
|
-
const rooms = (_b = collection === null || collection === void 0 ? void 0 : collection.data) !== null && _b !== void 0 ? _b : [];
|
|
44309
|
-
pushToCache(this.cacheKey, Object.assign(Object.assign({}, collection), { data: [...new Set([...rooms, ...response.rooms.map(getResolver('room'))])] }));
|
|
44310
|
-
}
|
|
44311
|
-
}
|
|
44312
|
-
reactor(action) {
|
|
44313
|
-
return (room) => {
|
|
44314
|
-
var _a;
|
|
44315
|
-
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
44316
|
-
if (!collection)
|
|
44317
|
-
return;
|
|
44318
|
-
if (action === EnumRoomActions.OnRoomDeleted) {
|
|
44319
|
-
collection.data = collection.data.filter(roomId => roomId !== room._id);
|
|
44320
|
-
}
|
|
44321
|
-
if (action === EnumRoomActions.OnRoomCreated) {
|
|
44322
|
-
collection.data = [...new Set([room._id, ...collection.data])];
|
|
44323
|
-
}
|
|
44324
|
-
pushToCache(this.cacheKey, collection);
|
|
44325
|
-
this.notifyChange({ origin: "event" /* Amity.LiveDataOrigin.EVENT */, loading: false });
|
|
44326
|
-
};
|
|
44327
|
-
}
|
|
44328
|
-
subscribeRTE(createSubscriber) {
|
|
44329
|
-
return createSubscriber.map(subscriber => subscriber.fn(this.reactor(subscriber.action)));
|
|
44330
|
-
}
|
|
44331
|
-
}
|
|
44332
|
-
|
|
44333
|
-
// TODO: confirm related events
|
|
44334
|
-
const getRoomSubscription = () => [
|
|
44335
|
-
{
|
|
44336
|
-
fn: onRoomStartBroadcasting,
|
|
44337
|
-
action: EnumRoomActions.OnRoomStartBroadcasting,
|
|
44338
|
-
},
|
|
44339
|
-
{
|
|
44340
|
-
fn: onRoomEndBroadcasting,
|
|
44341
|
-
action: EnumRoomActions.OnRoomEndBroadcasting,
|
|
44342
|
-
},
|
|
44343
|
-
{
|
|
44344
|
-
fn: onRoomRecordedAvailable,
|
|
44345
|
-
action: EnumRoomActions.OnRoomUpdated,
|
|
44346
|
-
},
|
|
44347
|
-
];
|
|
44348
|
-
|
|
44349
|
-
class RoomLiveCollectionController extends LiveCollectionController {
|
|
44350
|
-
constructor(query, callback) {
|
|
44351
|
-
const queryStreamId = hash(query);
|
|
44352
|
-
const cacheKey = ['rooms', 'collection', queryStreamId];
|
|
44353
|
-
const paginationController = new RoomPaginationController(query);
|
|
44354
|
-
super(paginationController, queryStreamId, cacheKey, callback);
|
|
44355
|
-
this.query = query;
|
|
44356
|
-
this.queryStreamController = new RoomQueryStreamController(this.query, this.cacheKey, this.notifyChange.bind(this), response => response);
|
|
44357
|
-
this.callback = callback.bind(this);
|
|
44358
|
-
this.loadPage({ initial: true });
|
|
44359
|
-
}
|
|
44360
|
-
setup() {
|
|
44361
|
-
var _a;
|
|
44362
|
-
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
44363
|
-
if (!collection) {
|
|
44364
|
-
pushToCache(this.cacheKey, {
|
|
44365
|
-
data: [],
|
|
44366
|
-
params: {},
|
|
44367
|
-
});
|
|
44368
|
-
}
|
|
44369
|
-
}
|
|
44370
|
-
async persistModel(queryPayload) {
|
|
44371
|
-
await this.queryStreamController.saveToMainDB(queryPayload);
|
|
44372
|
-
}
|
|
44373
|
-
persistQueryStream({ response, direction, refresh, }) {
|
|
44374
|
-
this.queryStreamController.appendToQueryStream(response, direction, refresh);
|
|
44375
|
-
}
|
|
44376
|
-
startSubscription() {
|
|
44377
|
-
return this.queryStreamController.subscribeRTE(getRoomSubscription());
|
|
44378
|
-
}
|
|
44379
|
-
notifyChange({ origin, loading, error }) {
|
|
44380
|
-
var _a, _b;
|
|
44381
|
-
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
44382
|
-
if (!collection)
|
|
44383
|
-
return;
|
|
44384
|
-
const data = this.applyFilter((_b = collection.data
|
|
44385
|
-
.map(id => pullFromCache(['room', 'get', id]))
|
|
44386
|
-
.filter(isNonNullable)
|
|
44387
|
-
.map(({ data }) => data)) !== null && _b !== void 0 ? _b : []).map(room => room); // Since Room is same as InternalRoom, no transformation needed
|
|
44388
|
-
if (!this.shouldNotify(data) && origin === 'event')
|
|
44389
|
-
return;
|
|
44390
|
-
this.callback({
|
|
44391
|
-
onNextPage: () => this.loadPage({ direction: "next" /* Amity.LiveCollectionPageDirection.NEXT */ }),
|
|
44392
|
-
data,
|
|
44393
|
-
hasNextPage: !!this.paginationController.getNextToken(),
|
|
44394
|
-
loading,
|
|
44395
|
-
error,
|
|
44396
|
-
});
|
|
44397
|
-
}
|
|
44398
|
-
applyFilter(data) {
|
|
44399
|
-
let rooms = data;
|
|
44400
|
-
if (!this.query.includeDeleted) {
|
|
44401
|
-
rooms = filterByPropEquality(rooms, 'isDeleted', false);
|
|
44402
|
-
}
|
|
44403
|
-
if (this.query.statuses && this.query.statuses.length > 0) {
|
|
44404
|
-
rooms = rooms.filter(room => { var _a; return (_a = this.query.statuses) === null || _a === void 0 ? void 0 : _a.includes(room.status); });
|
|
44405
|
-
}
|
|
44406
|
-
if (this.query.type) {
|
|
44407
|
-
rooms = filterByPropEquality(rooms, 'type', this.query.type);
|
|
44408
|
-
}
|
|
44409
|
-
switch (this.query.sortBy) {
|
|
44410
|
-
case 'firstCreated':
|
|
44411
|
-
rooms = rooms.sort(sortByFirstCreated);
|
|
44412
|
-
break;
|
|
44413
|
-
case 'lastCreated':
|
|
44414
|
-
default:
|
|
44415
|
-
rooms = rooms.sort(sortByLastCreated);
|
|
44416
|
-
break;
|
|
44417
|
-
}
|
|
44418
|
-
return rooms;
|
|
44419
|
-
}
|
|
44420
|
-
}
|
|
44421
|
-
|
|
44422
|
-
/* begin_public_function
|
|
44423
|
-
id: room.get_rooms
|
|
44424
|
-
*/
|
|
44425
|
-
/**
|
|
44426
|
-
* ```js
|
|
44427
|
-
* import { RoomRepository } from '@amityco/ts-sdk'
|
|
44428
|
-
*
|
|
44429
|
-
* let rooms = []
|
|
44430
|
-
* const unsub = RoomRepository.getRooms({
|
|
44431
|
-
* type: 'direct_streaming',
|
|
44432
|
-
* statuses: ['live', 'idle'],
|
|
44433
|
-
* sortBy: 'lastCreated',
|
|
44434
|
-
* limit: 20,
|
|
44435
|
-
* includeDeleted: false
|
|
44436
|
-
* }, response => merge(rooms, response.data))
|
|
44437
|
-
* ```
|
|
44438
|
-
*
|
|
44439
|
-
* Observe all mutations on a list of {@link Amity.Room} for a given query
|
|
44440
|
-
*
|
|
44441
|
-
* @param params.type the type of rooms to filter by ('direct_streaming' | 'co_hosts')
|
|
44442
|
-
* @param params.statuses array of room statuses to filter by (['idle', 'live', 'waiting_reconnect', 'ended', 'recorded'])
|
|
44443
|
-
* @param params.sortBy sort rooms by creation time ('firstCreated' | 'lastCreated')
|
|
44444
|
-
* @param params.limit maximum number of rooms to retrieve per page
|
|
44445
|
-
* @param params.includeDeleted whether to include deleted rooms in the results
|
|
44446
|
-
* @param callback the function to call when new data are available
|
|
44447
|
-
* @param config optional configuration for the live collection
|
|
44448
|
-
* @returns An {@link Amity.Unsubscriber} function to run when willing to stop observing the rooms
|
|
44449
|
-
*
|
|
44450
|
-
* @category Rooms Live Collection
|
|
44451
|
-
*/
|
|
44452
|
-
const getRooms = (params, callback, config) => {
|
|
44453
|
-
const { log, cache } = getActiveClient();
|
|
44454
|
-
if (!cache) {
|
|
44455
|
-
console.log(ENABLE_CACHE_MESSAGE);
|
|
44456
|
-
}
|
|
44457
|
-
const timestamp = Date.now();
|
|
44458
|
-
log(`getRooms(tmpid: ${timestamp}) > listen`);
|
|
44459
|
-
const roomsLiveCollection = new RoomLiveCollectionController(params, callback);
|
|
44460
|
-
const disposers = roomsLiveCollection.startSubscription();
|
|
44461
|
-
const cacheKey = roomsLiveCollection.getCacheKey();
|
|
44462
|
-
disposers.push(() => dropFromCache(cacheKey));
|
|
44463
|
-
return () => {
|
|
44464
|
-
log(`getRooms(tmpid: ${timestamp}) > dispose`);
|
|
44465
|
-
disposers.forEach(fn => fn());
|
|
44466
|
-
};
|
|
44467
|
-
};
|
|
44468
|
-
/* end_public_function */
|
|
44469
|
-
|
|
44470
|
-
var index$7 = /*#__PURE__*/Object.freeze({
|
|
44471
|
-
__proto__: null,
|
|
44472
|
-
createRoom: createRoom,
|
|
44473
|
-
updateRoom: updateRoom,
|
|
44474
|
-
deleteRoom: deleteRoom,
|
|
44475
|
-
stopRoom: stopRoom,
|
|
44476
|
-
getRoomToken: getRoomToken,
|
|
44477
|
-
getRecordedUrl: getRecordedUrl,
|
|
44478
|
-
onRoomStartBroadcasting: onRoomStartBroadcasting,
|
|
44479
|
-
onRoomWaitingReconnect: onRoomWaitingReconnect,
|
|
44480
|
-
onRoomEndBroadcasting: onRoomEndBroadcasting,
|
|
44481
|
-
onRoomRecordedAvailable: onRoomRecordedAvailable,
|
|
44482
|
-
onRoomParticipantInviting: onRoomParticipantInviting,
|
|
44483
|
-
onRoomParticipantJoined: onRoomParticipantJoined,
|
|
44484
|
-
onRoomParticipantLeft: onRoomParticipantLeft,
|
|
44485
|
-
onRoomCreated: onRoomCreated,
|
|
44486
|
-
onRoomUpdated: onRoomUpdated,
|
|
44487
|
-
onRoomDeleted: onRoomDeleted,
|
|
44488
|
-
onRoomStopped: onRoomStopped,
|
|
44489
|
-
getRoom: getRoom,
|
|
44490
|
-
getRooms: getRooms
|
|
44491
|
-
});
|
|
44492
|
-
|
|
44493
44338
|
/* begin_public_function
|
|
44494
44339
|
id: poll.create
|
|
44495
44340
|
*/
|
|
@@ -44790,7 +44635,7 @@ const getPoll = (pollId, callback) => {
|
|
|
44790
44635
|
};
|
|
44791
44636
|
/* end_public_function */
|
|
44792
44637
|
|
|
44793
|
-
var index$
|
|
44638
|
+
var index$7 = /*#__PURE__*/Object.freeze({
|
|
44794
44639
|
__proto__: null,
|
|
44795
44640
|
createPoll: createPoll,
|
|
44796
44641
|
closePoll: closePoll,
|
|
@@ -45173,7 +45018,7 @@ const getPlayer = async (parameters) => {
|
|
|
45173
45018
|
return video;
|
|
45174
45019
|
};
|
|
45175
45020
|
|
|
45176
|
-
var index$
|
|
45021
|
+
var index$6 = /*#__PURE__*/Object.freeze({
|
|
45177
45022
|
__proto__: null,
|
|
45178
45023
|
getPlayer: getPlayer
|
|
45179
45024
|
});
|
|
@@ -46346,7 +46191,7 @@ const getGlobalStoryTargets = (params, callback, config) => {
|
|
|
46346
46191
|
};
|
|
46347
46192
|
};
|
|
46348
46193
|
|
|
46349
|
-
var index$
|
|
46194
|
+
var index$5 = /*#__PURE__*/Object.freeze({
|
|
46350
46195
|
__proto__: null,
|
|
46351
46196
|
createImageStory: createImageStory,
|
|
46352
46197
|
createVideoStory: createVideoStory,
|
|
@@ -46383,7 +46228,7 @@ const getNetworkAds = async () => {
|
|
|
46383
46228
|
};
|
|
46384
46229
|
};
|
|
46385
46230
|
|
|
46386
|
-
var index$
|
|
46231
|
+
var index$4 = /*#__PURE__*/Object.freeze({
|
|
46387
46232
|
__proto__: null,
|
|
46388
46233
|
getNetworkAds: getNetworkAds
|
|
46389
46234
|
});
|
|
@@ -46774,7 +46619,7 @@ const markTraySeen = async (lastSeenAt) => {
|
|
|
46774
46619
|
};
|
|
46775
46620
|
/* end_public_function */
|
|
46776
46621
|
|
|
46777
|
-
var index$
|
|
46622
|
+
var index$3 = /*#__PURE__*/Object.freeze({
|
|
46778
46623
|
__proto__: null,
|
|
46779
46624
|
getNotificationTraySeen: getNotificationTraySeen,
|
|
46780
46625
|
getNotificationTrayItems: getNotificationTrayItems,
|
|
@@ -46975,7 +46820,7 @@ const getMyCommunityInvitations = (params, callback, config) => {
|
|
|
46975
46820
|
};
|
|
46976
46821
|
};
|
|
46977
46822
|
|
|
46978
|
-
var index$
|
|
46823
|
+
var index$2 = /*#__PURE__*/Object.freeze({
|
|
46979
46824
|
__proto__: null,
|
|
46980
46825
|
onLocalInvitationCreated: onLocalInvitationCreated,
|
|
46981
46826
|
onLocalInvitationUpdated: onLocalInvitationUpdated,
|
|
@@ -47116,11 +46961,491 @@ const getReactions = (postId, callback) => {
|
|
|
47116
46961
|
};
|
|
47117
46962
|
};
|
|
47118
46963
|
|
|
47119
|
-
var index = /*#__PURE__*/Object.freeze({
|
|
46964
|
+
var index$1 = /*#__PURE__*/Object.freeze({
|
|
47120
46965
|
__proto__: null,
|
|
47121
46966
|
createReaction: createReaction,
|
|
47122
46967
|
onLiveReactionCreated: onLiveReactionCreated,
|
|
47123
46968
|
getReactions: getReactions
|
|
47124
46969
|
});
|
|
47125
46970
|
|
|
47126
|
-
|
|
46971
|
+
/* begin_public_function
|
|
46972
|
+
id: event.create
|
|
46973
|
+
*/
|
|
46974
|
+
/**
|
|
46975
|
+
* ```js
|
|
46976
|
+
* import { EventRepository } from '@amityco/ts-sdk'
|
|
46977
|
+
* const response = await EventRepository.createEvent(bundle)
|
|
46978
|
+
* ```
|
|
46979
|
+
*
|
|
46980
|
+
* Creates an {@link Amity.Event}
|
|
46981
|
+
*
|
|
46982
|
+
* @param bundle The data necessary to create a new {@link Amity.Event}
|
|
46983
|
+
* @returns The newly created {@link Amity.Event}
|
|
46984
|
+
*
|
|
46985
|
+
* @category Event API
|
|
46986
|
+
* @async
|
|
46987
|
+
*/
|
|
46988
|
+
const createEvent = async (bundle) => {
|
|
46989
|
+
const client = getActiveClient();
|
|
46990
|
+
client.log('event/createEvent', bundle);
|
|
46991
|
+
const { data: payload } = await client.http.post('/api/v1/events', bundle);
|
|
46992
|
+
fireEvent('local.event.created', payload);
|
|
46993
|
+
const preparedPayload = prepareEventPayload(payload);
|
|
46994
|
+
const cachedAt = client.cache && Date.now();
|
|
46995
|
+
if (client.cache)
|
|
46996
|
+
ingestInCache(preparedPayload, { cachedAt });
|
|
46997
|
+
return {
|
|
46998
|
+
data: eventLinkedObject(preparedPayload.events[0]),
|
|
46999
|
+
cachedAt,
|
|
47000
|
+
};
|
|
47001
|
+
};
|
|
47002
|
+
/* end_public_function */
|
|
47003
|
+
|
|
47004
|
+
/* begin_public_function
|
|
47005
|
+
id: event.update
|
|
47006
|
+
*/
|
|
47007
|
+
/**
|
|
47008
|
+
* ```js
|
|
47009
|
+
* import { EventRepository } from '@amityco/ts-sdk'
|
|
47010
|
+
* const response = await EventRepository.updateEvent(eventId, bundle)
|
|
47011
|
+
* ```
|
|
47012
|
+
*
|
|
47013
|
+
* Updates an {@link Amity.Event}
|
|
47014
|
+
*
|
|
47015
|
+
* @param eventId The ID of the {@link Amity.Event} to edit
|
|
47016
|
+
* @param bundle The data necessary to update an existing {@link Amity.Event}
|
|
47017
|
+
* @returns the updated {@link Amity.Event}
|
|
47018
|
+
*
|
|
47019
|
+
* @category Event API
|
|
47020
|
+
* @async
|
|
47021
|
+
*/
|
|
47022
|
+
const updateEvent = async (eventId, bundle) => {
|
|
47023
|
+
const client = getActiveClient();
|
|
47024
|
+
client.log('event/updateEvent', eventId, bundle);
|
|
47025
|
+
const { data: payload } = await client.http.put(`/api/v1/events/${eventId}`, bundle);
|
|
47026
|
+
fireEvent('local.event.updated', payload);
|
|
47027
|
+
const preparedPayload = prepareEventPayload(payload);
|
|
47028
|
+
const cachedAt = client.cache && Date.now();
|
|
47029
|
+
if (client.cache)
|
|
47030
|
+
ingestInCache(preparedPayload, { cachedAt });
|
|
47031
|
+
return {
|
|
47032
|
+
data: eventLinkedObject(preparedPayload.events.find(event => event.eventId === eventId)),
|
|
47033
|
+
cachedAt,
|
|
47034
|
+
};
|
|
47035
|
+
};
|
|
47036
|
+
/* end_public_function */
|
|
47037
|
+
|
|
47038
|
+
/* begin_public_function
|
|
47039
|
+
id: event.get
|
|
47040
|
+
*/
|
|
47041
|
+
/**
|
|
47042
|
+
* ```js
|
|
47043
|
+
* import { EventRepository } from '@amityco/ts-sdk'
|
|
47044
|
+
* const event = await EventRepository.getEvent(eventId)
|
|
47045
|
+
* ```
|
|
47046
|
+
*
|
|
47047
|
+
* Fetches a {@link Amity.Event} object
|
|
47048
|
+
*
|
|
47049
|
+
* @param eventId the ID of the {@link Amity.Event} to fetch
|
|
47050
|
+
* @returns the associated {@link Amity.Event} object
|
|
47051
|
+
*
|
|
47052
|
+
* @category Event API
|
|
47053
|
+
* @async
|
|
47054
|
+
*/
|
|
47055
|
+
const getEvent$1 = async (eventId) => {
|
|
47056
|
+
const client = getActiveClient();
|
|
47057
|
+
client.log('event/getEvent', eventId);
|
|
47058
|
+
const { data: payload } = await client.http.get(`/api/v1/events/${eventId}`);
|
|
47059
|
+
const data = prepareEventPayload(payload);
|
|
47060
|
+
const cachedAt = client.cache && Date.now();
|
|
47061
|
+
if (client.cache)
|
|
47062
|
+
ingestInCache(data, { cachedAt });
|
|
47063
|
+
return {
|
|
47064
|
+
data: data.events.find(event => event.eventId === eventId),
|
|
47065
|
+
cachedAt,
|
|
47066
|
+
};
|
|
47067
|
+
};
|
|
47068
|
+
/* end_public_function */
|
|
47069
|
+
/**
|
|
47070
|
+
* ```js
|
|
47071
|
+
* import { EventRepository } from '@amityco/ts-sdk'
|
|
47072
|
+
* const event = EventRepository.getEvent.locally(eventId)
|
|
47073
|
+
* ```
|
|
47074
|
+
*
|
|
47075
|
+
* Fetches a {@link Amity.Event} object in cache
|
|
47076
|
+
*
|
|
47077
|
+
* @param eventId the ID of the {@link Amity.Event} to fetch
|
|
47078
|
+
* @returns the associated {@link Amity.Event} object
|
|
47079
|
+
*
|
|
47080
|
+
* @category Event API
|
|
47081
|
+
*/
|
|
47082
|
+
getEvent$1.locally = (eventId) => {
|
|
47083
|
+
const client = getActiveClient();
|
|
47084
|
+
client.log('event/getEvent.locally', eventId);
|
|
47085
|
+
if (!client.cache)
|
|
47086
|
+
return;
|
|
47087
|
+
const cache = pullFromCache(['event', 'get', eventId]);
|
|
47088
|
+
if (!cache)
|
|
47089
|
+
return;
|
|
47090
|
+
return {
|
|
47091
|
+
data: cache.data,
|
|
47092
|
+
cachedAt: cache.cachedAt,
|
|
47093
|
+
};
|
|
47094
|
+
};
|
|
47095
|
+
|
|
47096
|
+
/* begin_public_function
|
|
47097
|
+
id: event.delete
|
|
47098
|
+
*/
|
|
47099
|
+
/**
|
|
47100
|
+
* ```js
|
|
47101
|
+
* import { EventRepository } from '@amityco/ts-sdk'
|
|
47102
|
+
* const { success } = await EventRepository.deleteEvent(eventId)
|
|
47103
|
+
* ```
|
|
47104
|
+
*
|
|
47105
|
+
* Deletes a {@link Amity.Event}
|
|
47106
|
+
*
|
|
47107
|
+
* @param eventId The {@link Amity.Event} ID to delete
|
|
47108
|
+
*
|
|
47109
|
+
* @category Event API
|
|
47110
|
+
* @async
|
|
47111
|
+
*/
|
|
47112
|
+
const deleteEvent = async (eventId) => {
|
|
47113
|
+
const client = getActiveClient();
|
|
47114
|
+
client.log('event/deleteEvent', eventId);
|
|
47115
|
+
const event = await getEvent$1(eventId);
|
|
47116
|
+
await client.http.delete(`/api/v1/events/${eventId}`);
|
|
47117
|
+
const deletedEvent = Object.assign(Object.assign({}, event.data), { isDeleted: true });
|
|
47118
|
+
upsertInCache(['event', 'get', eventId], deletedEvent);
|
|
47119
|
+
fireEvent('local.event.deleted', {
|
|
47120
|
+
users: [],
|
|
47121
|
+
files: [],
|
|
47122
|
+
communities: [],
|
|
47123
|
+
videoStreamings: [],
|
|
47124
|
+
events: [deletedEvent],
|
|
47125
|
+
discussionCommunities: [],
|
|
47126
|
+
});
|
|
47127
|
+
};
|
|
47128
|
+
/* end_public_function */
|
|
47129
|
+
|
|
47130
|
+
/* begin_public_function
|
|
47131
|
+
id: event.get
|
|
47132
|
+
*/
|
|
47133
|
+
/**
|
|
47134
|
+
* ```js
|
|
47135
|
+
* import { EventRepository } from '@amityco/ts-sdk';
|
|
47136
|
+
*
|
|
47137
|
+
* let event;
|
|
47138
|
+
*
|
|
47139
|
+
* const unsubscribe = EventRepository.getEvent(eventId, response => {
|
|
47140
|
+
* event = response.data;
|
|
47141
|
+
* });
|
|
47142
|
+
* ```
|
|
47143
|
+
*
|
|
47144
|
+
* Observe all mutation on a given {@link Amity.Event}
|
|
47145
|
+
*
|
|
47146
|
+
* @param eventId the ID of the event to observe
|
|
47147
|
+
* @param callback the function to call when new snapshot of event are available
|
|
47148
|
+
* @returns An {@link Amity.Unsubscriber} function to run when willing to stop observing the event
|
|
47149
|
+
*
|
|
47150
|
+
* @category Event Live Object
|
|
47151
|
+
*/
|
|
47152
|
+
const getEvent = (eventId, callback) => {
|
|
47153
|
+
return liveObject(eventId, callback, 'eventId', getEvent$1, [onEventUpdated, onEventDeleted, onLocalEventUpdated, onLocalEventDeleted], {
|
|
47154
|
+
callbackDataSelector: (data) => (data ? eventLinkedObject(data) : data),
|
|
47155
|
+
});
|
|
47156
|
+
};
|
|
47157
|
+
/* end_public_function */
|
|
47158
|
+
|
|
47159
|
+
class EventPaginationController extends PaginationController {
|
|
47160
|
+
async getRequest(queryParams, token) {
|
|
47161
|
+
const { limit = COLLECTION_DEFAULT_PAGINATION_LIMIT } = queryParams, params = __rest(queryParams, ["limit"]);
|
|
47162
|
+
const options = token ? { token } : { limit };
|
|
47163
|
+
const { data: response } = await this.http.get(`/api/v1/events`, { params: Object.assign(Object.assign({}, params), { options }) });
|
|
47164
|
+
return response;
|
|
47165
|
+
}
|
|
47166
|
+
}
|
|
47167
|
+
|
|
47168
|
+
class EventQueryStreamController extends QueryStreamController {
|
|
47169
|
+
constructor(query, cacheKey, notifyChange, preparePayload) {
|
|
47170
|
+
super(query, cacheKey);
|
|
47171
|
+
this.notifyChange = notifyChange;
|
|
47172
|
+
this.preparePayload = preparePayload;
|
|
47173
|
+
}
|
|
47174
|
+
async saveToMainDB(response) {
|
|
47175
|
+
const processedPayload = this.preparePayload(response);
|
|
47176
|
+
const client = getActiveClient();
|
|
47177
|
+
const cachedAt = client.cache && Date.now();
|
|
47178
|
+
if (client.cache)
|
|
47179
|
+
ingestInCache(processedPayload, { cachedAt });
|
|
47180
|
+
}
|
|
47181
|
+
appendToQueryStream(response, direction, refresh = false) {
|
|
47182
|
+
var _a, _b;
|
|
47183
|
+
if (refresh) {
|
|
47184
|
+
pushToCache(this.cacheKey, { data: response.events.map(getResolver('event')) });
|
|
47185
|
+
}
|
|
47186
|
+
else {
|
|
47187
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
47188
|
+
const events = (_b = collection === null || collection === void 0 ? void 0 : collection.data) !== null && _b !== void 0 ? _b : [];
|
|
47189
|
+
pushToCache(this.cacheKey, Object.assign(Object.assign({}, collection), { data: [...new Set([...events, ...response.events.map(getResolver('event'))])] }));
|
|
47190
|
+
}
|
|
47191
|
+
}
|
|
47192
|
+
reactor(action) {
|
|
47193
|
+
return (event) => {
|
|
47194
|
+
var _a;
|
|
47195
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
47196
|
+
if (!collection)
|
|
47197
|
+
return;
|
|
47198
|
+
if (action === EventActionsEnum.OnEventCreated) {
|
|
47199
|
+
collection.data = [...new Set([event.eventId, ...collection.data])];
|
|
47200
|
+
}
|
|
47201
|
+
if (action === EventActionsEnum.OnEventDeleted) {
|
|
47202
|
+
collection.data = collection.data.filter(eventId => eventId !== event.eventId);
|
|
47203
|
+
}
|
|
47204
|
+
pushToCache(this.cacheKey, collection);
|
|
47205
|
+
this.notifyChange({ origin: "event" /* Amity.LiveDataOrigin.EVENT */, loading: false });
|
|
47206
|
+
};
|
|
47207
|
+
}
|
|
47208
|
+
subscribeRTE(createSubscriber) {
|
|
47209
|
+
return createSubscriber.map(subscriber => subscriber.fn(this.reactor(subscriber.action)));
|
|
47210
|
+
}
|
|
47211
|
+
}
|
|
47212
|
+
|
|
47213
|
+
class EventLiveCollectionController extends LiveCollectionController {
|
|
47214
|
+
constructor(query, callback) {
|
|
47215
|
+
const queryStreamId = hash(query);
|
|
47216
|
+
const cacheKey = ['event', 'collection', queryStreamId];
|
|
47217
|
+
const paginationController = new EventPaginationController(query);
|
|
47218
|
+
super(paginationController, queryStreamId, cacheKey, callback);
|
|
47219
|
+
this.query = query;
|
|
47220
|
+
this.queryStreamController = new EventQueryStreamController(this.query, this.cacheKey, this.notifyChange.bind(this), prepareEventPayload);
|
|
47221
|
+
this.callback = callback.bind(this);
|
|
47222
|
+
this.loadPage({ initial: true });
|
|
47223
|
+
}
|
|
47224
|
+
setup() {
|
|
47225
|
+
var _a;
|
|
47226
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
47227
|
+
if (!collection)
|
|
47228
|
+
pushToCache(this.cacheKey, { data: [], params: {} });
|
|
47229
|
+
}
|
|
47230
|
+
async persistModel(queryPayload) {
|
|
47231
|
+
await this.queryStreamController.saveToMainDB(queryPayload);
|
|
47232
|
+
}
|
|
47233
|
+
persistQueryStream({ response, direction, refresh, }) {
|
|
47234
|
+
this.queryStreamController.appendToQueryStream(response, direction, refresh);
|
|
47235
|
+
}
|
|
47236
|
+
startSubscription() {
|
|
47237
|
+
return this.queryStreamController.subscribeRTE([
|
|
47238
|
+
{ fn: onEventCreated, action: EventActionsEnum.OnEventCreated },
|
|
47239
|
+
{ fn: onEventUpdated, action: EventActionsEnum.OnEventUpdated },
|
|
47240
|
+
{ fn: onEventDeleted, action: EventActionsEnum.OnEventDeleted },
|
|
47241
|
+
{ fn: onLocalEventCreated, action: EventActionsEnum.OnEventCreated },
|
|
47242
|
+
{ fn: onLocalEventUpdated, action: EventActionsEnum.OnEventUpdated },
|
|
47243
|
+
{ fn: onLocalEventDeleted, action: EventActionsEnum.OnEventDeleted },
|
|
47244
|
+
]);
|
|
47245
|
+
}
|
|
47246
|
+
notifyChange({ origin, loading, error }) {
|
|
47247
|
+
var _a, _b;
|
|
47248
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
47249
|
+
if (!collection)
|
|
47250
|
+
return;
|
|
47251
|
+
const data = ((_b = collection.data
|
|
47252
|
+
.map(eventId => pullFromCache(['event', 'get', eventId]))
|
|
47253
|
+
.filter(isNonNullable)
|
|
47254
|
+
.map(({ data }) => data)) !== null && _b !== void 0 ? _b : []).map(LinkedObject.event);
|
|
47255
|
+
if (!this.shouldNotify(data) && origin === "event" /* Amity.LiveDataOrigin.EVENT */)
|
|
47256
|
+
return;
|
|
47257
|
+
this.callback({
|
|
47258
|
+
data,
|
|
47259
|
+
error,
|
|
47260
|
+
loading,
|
|
47261
|
+
hasNextPage: !!this.paginationController.getNextToken(),
|
|
47262
|
+
onNextPage: () => this.loadPage({ direction: "next" /* Amity.LiveCollectionPageDirection.NEXT */ }),
|
|
47263
|
+
});
|
|
47264
|
+
}
|
|
47265
|
+
}
|
|
47266
|
+
|
|
47267
|
+
/**
|
|
47268
|
+
* Get events
|
|
47269
|
+
*
|
|
47270
|
+
* @param params the query parameters
|
|
47271
|
+
* @param callback the callback to be called when the events are updated
|
|
47272
|
+
* @returns events
|
|
47273
|
+
*
|
|
47274
|
+
* @category Event Live Collection
|
|
47275
|
+
*
|
|
47276
|
+
*/
|
|
47277
|
+
const getEvents = (params, callback, config) => {
|
|
47278
|
+
const { log, cache } = getActiveClient();
|
|
47279
|
+
if (!cache)
|
|
47280
|
+
console.log(ENABLE_CACHE_MESSAGE);
|
|
47281
|
+
const timestamp = Date.now();
|
|
47282
|
+
log(`getEvents: (tmpid: ${timestamp}) > listen`);
|
|
47283
|
+
const eventLiveCollection = new EventLiveCollectionController(params, callback);
|
|
47284
|
+
const disposers = eventLiveCollection.startSubscription();
|
|
47285
|
+
const cacheKey = eventLiveCollection.getCacheKey();
|
|
47286
|
+
disposers.push(() => dropFromCache(cacheKey));
|
|
47287
|
+
return () => {
|
|
47288
|
+
log(`getEvents (tmpid: ${timestamp}) > dispose`);
|
|
47289
|
+
disposers.forEach(fn => fn());
|
|
47290
|
+
};
|
|
47291
|
+
};
|
|
47292
|
+
|
|
47293
|
+
class MyEventPaginationController extends PaginationController {
|
|
47294
|
+
async getRequest(queryParams, token) {
|
|
47295
|
+
const { limit = COLLECTION_DEFAULT_PAGINATION_LIMIT } = queryParams, params = __rest(queryParams, ["limit"]);
|
|
47296
|
+
const options = token ? { token } : { limit };
|
|
47297
|
+
const { data: response } = await this.http.get(`/api/v1/events/me/rsvps`, { params: Object.assign(Object.assign({}, params), { options }) });
|
|
47298
|
+
return response;
|
|
47299
|
+
}
|
|
47300
|
+
}
|
|
47301
|
+
|
|
47302
|
+
class MyEventQueryStreamController extends QueryStreamController {
|
|
47303
|
+
constructor(query, cacheKey, notifyChange, preparePayload) {
|
|
47304
|
+
super(query, cacheKey);
|
|
47305
|
+
this.notifyChange = notifyChange;
|
|
47306
|
+
this.preparePayload = preparePayload;
|
|
47307
|
+
}
|
|
47308
|
+
async saveToMainDB(response) {
|
|
47309
|
+
const processedPayload = this.preparePayload(response);
|
|
47310
|
+
const client = getActiveClient();
|
|
47311
|
+
const cachedAt = client.cache && Date.now();
|
|
47312
|
+
if (client.cache)
|
|
47313
|
+
ingestInCache(processedPayload, { cachedAt });
|
|
47314
|
+
}
|
|
47315
|
+
appendToQueryStream(response, direction, refresh = false) {
|
|
47316
|
+
var _a, _b;
|
|
47317
|
+
if (refresh) {
|
|
47318
|
+
pushToCache(this.cacheKey, { data: response.events.map(getResolver('event')) });
|
|
47319
|
+
}
|
|
47320
|
+
else {
|
|
47321
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
47322
|
+
const events = (_b = collection === null || collection === void 0 ? void 0 : collection.data) !== null && _b !== void 0 ? _b : [];
|
|
47323
|
+
pushToCache(this.cacheKey, Object.assign(Object.assign({}, collection), { data: [...new Set([...events, ...response.events.map(getResolver('event'))])] }));
|
|
47324
|
+
}
|
|
47325
|
+
}
|
|
47326
|
+
reactor(action) {
|
|
47327
|
+
return (event) => {
|
|
47328
|
+
var _a;
|
|
47329
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
47330
|
+
if (!collection)
|
|
47331
|
+
return;
|
|
47332
|
+
if (action === EventActionsEnum.OnEventCreated) {
|
|
47333
|
+
const client = getActiveClient();
|
|
47334
|
+
if (client.userId !== event.userId)
|
|
47335
|
+
return;
|
|
47336
|
+
collection.data = [...new Set([event.eventId, ...collection.data])];
|
|
47337
|
+
}
|
|
47338
|
+
if (action === EventActionsEnum.OnEventDeleted) {
|
|
47339
|
+
collection.data = collection.data.filter(eventId => eventId !== event.eventId);
|
|
47340
|
+
}
|
|
47341
|
+
pushToCache(this.cacheKey, collection);
|
|
47342
|
+
this.notifyChange({ origin: "event" /* Amity.LiveDataOrigin.EVENT */, loading: false });
|
|
47343
|
+
};
|
|
47344
|
+
}
|
|
47345
|
+
subscribeRTE(createSubscriber) {
|
|
47346
|
+
return createSubscriber.map(subscriber => subscriber.fn(this.reactor(subscriber.action)));
|
|
47347
|
+
}
|
|
47348
|
+
}
|
|
47349
|
+
|
|
47350
|
+
class MyEventLiveCollectionController extends LiveCollectionController {
|
|
47351
|
+
constructor(query, callback) {
|
|
47352
|
+
const queryStreamId = hash(query);
|
|
47353
|
+
const cacheKey = ['event', 'collection', queryStreamId];
|
|
47354
|
+
const paginationController = new MyEventPaginationController(query);
|
|
47355
|
+
super(paginationController, queryStreamId, cacheKey, callback);
|
|
47356
|
+
this.query = query;
|
|
47357
|
+
this.queryStreamController = new MyEventQueryStreamController(this.query, this.cacheKey, this.notifyChange.bind(this), prepareEventPayload);
|
|
47358
|
+
this.callback = callback.bind(this);
|
|
47359
|
+
this.loadPage({ initial: true });
|
|
47360
|
+
}
|
|
47361
|
+
setup() {
|
|
47362
|
+
var _a;
|
|
47363
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
47364
|
+
if (!collection)
|
|
47365
|
+
pushToCache(this.cacheKey, { data: [], params: {} });
|
|
47366
|
+
}
|
|
47367
|
+
async persistModel(queryPayload) {
|
|
47368
|
+
await this.queryStreamController.saveToMainDB(queryPayload);
|
|
47369
|
+
}
|
|
47370
|
+
persistQueryStream({ response, direction, refresh, }) {
|
|
47371
|
+
this.queryStreamController.appendToQueryStream(response, direction, refresh);
|
|
47372
|
+
}
|
|
47373
|
+
startSubscription() {
|
|
47374
|
+
return this.queryStreamController.subscribeRTE([
|
|
47375
|
+
{ fn: onEventCreated, action: EventActionsEnum.OnEventCreated },
|
|
47376
|
+
{ fn: onEventUpdated, action: EventActionsEnum.OnEventUpdated },
|
|
47377
|
+
{ fn: onEventDeleted, action: EventActionsEnum.OnEventDeleted },
|
|
47378
|
+
{ fn: onLocalEventCreated, action: EventActionsEnum.OnEventCreated },
|
|
47379
|
+
{ fn: onLocalEventUpdated, action: EventActionsEnum.OnEventUpdated },
|
|
47380
|
+
{ fn: onLocalEventDeleted, action: EventActionsEnum.OnEventDeleted },
|
|
47381
|
+
]);
|
|
47382
|
+
}
|
|
47383
|
+
notifyChange({ origin, loading, error }) {
|
|
47384
|
+
var _a, _b;
|
|
47385
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
47386
|
+
if (!collection)
|
|
47387
|
+
return;
|
|
47388
|
+
const data = ((_b = collection.data
|
|
47389
|
+
.map(eventId => pullFromCache(['event', 'get', eventId]))
|
|
47390
|
+
.filter(isNonNullable)
|
|
47391
|
+
.map(({ data }) => data)) !== null && _b !== void 0 ? _b : []).map(LinkedObject.event);
|
|
47392
|
+
if (!this.shouldNotify(data) && origin === "event" /* Amity.LiveDataOrigin.EVENT */)
|
|
47393
|
+
return;
|
|
47394
|
+
this.callback({
|
|
47395
|
+
data,
|
|
47396
|
+
error,
|
|
47397
|
+
loading,
|
|
47398
|
+
hasNextPage: !!this.paginationController.getNextToken(),
|
|
47399
|
+
onNextPage: () => this.loadPage({ direction: "next" /* Amity.LiveCollectionPageDirection.NEXT */ }),
|
|
47400
|
+
});
|
|
47401
|
+
}
|
|
47402
|
+
}
|
|
47403
|
+
|
|
47404
|
+
/**
|
|
47405
|
+
* Get my events
|
|
47406
|
+
*
|
|
47407
|
+
* @param params the query parameters
|
|
47408
|
+
* @param callback the callback to be called when the events are updated
|
|
47409
|
+
* @returns events
|
|
47410
|
+
*
|
|
47411
|
+
* @category Event Live Collection
|
|
47412
|
+
*
|
|
47413
|
+
*/
|
|
47414
|
+
const getMyEvents = (params, callback, config) => {
|
|
47415
|
+
const { log, cache } = getActiveClient();
|
|
47416
|
+
if (!cache)
|
|
47417
|
+
console.log(ENABLE_CACHE_MESSAGE);
|
|
47418
|
+
const timestamp = Date.now();
|
|
47419
|
+
log(`getMyEvents: (tmpid: ${timestamp}) > listen`);
|
|
47420
|
+
const myEventLiveCollection = new MyEventLiveCollectionController(params, callback);
|
|
47421
|
+
const disposers = myEventLiveCollection.startSubscription();
|
|
47422
|
+
const cacheKey = myEventLiveCollection.getCacheKey();
|
|
47423
|
+
disposers.push(() => dropFromCache(cacheKey));
|
|
47424
|
+
return () => {
|
|
47425
|
+
log(`getMyEvents (tmpid: ${timestamp}) > dispose`);
|
|
47426
|
+
disposers.forEach(fn => fn());
|
|
47427
|
+
};
|
|
47428
|
+
};
|
|
47429
|
+
|
|
47430
|
+
var index = /*#__PURE__*/Object.freeze({
|
|
47431
|
+
__proto__: null,
|
|
47432
|
+
createEvent: createEvent,
|
|
47433
|
+
updateEvent: updateEvent,
|
|
47434
|
+
deleteEvent: deleteEvent,
|
|
47435
|
+
onEventCreated: onEventCreated,
|
|
47436
|
+
onEventUpdated: onEventUpdated,
|
|
47437
|
+
onEventDeleted: onEventDeleted,
|
|
47438
|
+
onLocalEventCreated: onLocalEventCreated,
|
|
47439
|
+
onLocalEventUpdated: onLocalEventUpdated,
|
|
47440
|
+
onLocalEventDeleted: onLocalEventDeleted,
|
|
47441
|
+
onRSVPCreated: onRSVPCreated,
|
|
47442
|
+
onRSVPUpdated: onRSVPUpdated,
|
|
47443
|
+
onLocalRSVPCreated: onLocalRSVPCreated,
|
|
47444
|
+
onLocalRSVPUpdated: onLocalRSVPUpdated,
|
|
47445
|
+
getEvent: getEvent,
|
|
47446
|
+
getEvents: getEvents,
|
|
47447
|
+
getMyEvents: getMyEvents,
|
|
47448
|
+
getRSVPs: getRSVPs
|
|
47449
|
+
});
|
|
47450
|
+
|
|
47451
|
+
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 };
|