@amityco/ts-sdk 7.11.1-3b65d6ed.0 → 7.11.1-459a5ad.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 +49 -10
- package/dist/@types/core/events.d.ts.map +1 -1
- package/dist/@types/core/model.d.ts +4 -0
- package/dist/@types/core/model.d.ts.map +1 -1
- package/dist/@types/core/payload.d.ts +33 -0
- package/dist/@types/core/payload.d.ts.map +1 -1
- package/dist/@types/core/permissions.d.ts +5 -1
- package/dist/@types/core/permissions.d.ts.map +1 -1
- package/dist/@types/core/transport.d.ts +3 -0
- package/dist/@types/core/transport.d.ts.map +1 -1
- package/dist/@types/domains/channel.d.ts +1 -0
- package/dist/@types/domains/channel.d.ts.map +1 -1
- package/dist/@types/domains/community.d.ts +14 -1
- package/dist/@types/domains/community.d.ts.map +1 -1
- package/dist/@types/domains/event.d.ts +93 -0
- package/dist/@types/domains/event.d.ts.map +1 -0
- package/dist/@types/domains/invitation.d.ts +7 -2
- package/dist/@types/domains/invitation.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/room.d.ts +22 -4
- package/dist/@types/domains/room.d.ts.map +1 -1
- package/dist/@types/index.d.ts +1 -0
- package/dist/@types/index.d.ts.map +1 -1
- package/dist/client/api/getPresenceSetting.d.ts +2 -0
- package/dist/client/api/getPresenceSetting.d.ts.map +1 -0
- package/dist/client/api/resumeSession.d.ts.map +1 -1
- package/dist/client/events/onUserDeleted.d.ts +17 -0
- package/dist/client/events/onUserDeleted.d.ts.map +1 -0
- package/dist/client/services/ObjectResolver/objectResolverEngine.d.ts.map +1 -0
- package/dist/client/services/ObjectResolver/objectResolverEngineOnLoginHandler.d.ts.map +1 -0
- package/dist/client/services/ReadReceiptSync/legacyReadReceiptSyncEngine.d.ts.map +1 -0
- package/dist/client/services/ReadReceiptSync/legacyReadReceiptSyncEngineOnLoginHandler.d.ts.map +1 -0
- package/dist/client/services/ReadReceiptSync/readReceiptSyncEngine.d.ts.map +1 -0
- package/dist/client/services/ReadReceiptSync/readReceiptSyncEngineOnLoginHandler.d.ts.map +1 -0
- 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/core/subscription.d.ts +2 -0
- package/dist/core/subscription.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 +6 -0
- package/dist/eventRepository/events/enums.d.ts.map +1 -0
- package/dist/eventRepository/events/index.d.ts +7 -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/index.d.ts +4 -0
- package/dist/eventRepository/index.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/index.d.ts +2 -0
- package/dist/eventRepository/internalApi/index.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/index.d.ts +3 -0
- package/dist/eventRepository/observers/index.d.ts.map +1 -0
- package/dist/eventRepository/utils/createEventEventSubscriber.d.ts +2 -0
- package/dist/eventRepository/utils/createEventEventSubscriber.d.ts.map +1 -0
- package/dist/eventRepository/utils/index.d.ts +3 -0
- package/dist/eventRepository/utils/index.d.ts.map +1 -0
- package/dist/eventRepository/utils/prepareEventPayload.d.ts +2 -0
- package/dist/eventRepository/utils/prepareEventPayload.d.ts.map +1 -0
- package/dist/index.cjs.js +2926 -1716
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.esm.js +1785 -579
- package/dist/index.umd.js +3 -3
- package/dist/invitationRepository/api/cancelInvitation.d.ts +16 -0
- package/dist/invitationRepository/api/cancelInvitation.d.ts.map +1 -0
- package/dist/invitationRepository/api/index.d.ts +2 -0
- package/dist/invitationRepository/api/index.d.ts.map +1 -0
- package/dist/invitationRepository/events/index.d.ts +1 -1
- package/dist/invitationRepository/events/index.d.ts.map +1 -1
- package/dist/invitationRepository/events/onLocalInvitationCanceled.d.ts +17 -0
- package/dist/invitationRepository/events/onLocalInvitationCanceled.d.ts.map +1 -0
- package/dist/invitationRepository/index.d.ts +1 -0
- package/dist/invitationRepository/index.d.ts.map +1 -1
- package/dist/invitationRepository/internalApi/getInvitation.d.ts +1 -1
- package/dist/invitationRepository/internalApi/getInvitation.d.ts.map +1 -1
- package/dist/invitationRepository/internalObservers/getInvitations/InvitationsLiveCollectionController.d.ts.map +1 -0
- package/dist/invitationRepository/internalObservers/getInvitations/InvitationsPaginationController.d.ts.map +1 -0
- package/dist/invitationRepository/internalObservers/getInvitations/InvitationsQueryStreamController.d.ts.map +1 -0
- package/dist/invitationRepository/{observers → internalObservers}/getInvitations/enums.d.ts +1 -1
- package/dist/invitationRepository/internalObservers/getInvitations/enums.d.ts.map +1 -0
- package/dist/invitationRepository/internalObservers/getInvitations.d.ts +12 -0
- package/dist/invitationRepository/internalObservers/getInvitations.d.ts.map +1 -0
- package/dist/invitationRepository/observers/getInvitations.d.ts +28 -6
- package/dist/invitationRepository/observers/getInvitations.d.ts.map +1 -1
- package/dist/invitationRepository/observers/getMyInvitations/MyInvitationsQueryStreamController.d.ts +1 -1
- package/dist/invitationRepository/observers/getMyInvitations/MyInvitationsQueryStreamController.d.ts.map +1 -1
- package/dist/invitationRepository/observers/index.d.ts +1 -0
- package/dist/invitationRepository/observers/index.d.ts.map +1 -1
- package/dist/liveReactionRepository/api/createReaction.d.ts +2 -2
- package/dist/liveReactionRepository/api/createReaction.d.ts.map +1 -1
- package/dist/liveReactionRepository/service/ReactionSyncEngine.d.ts +1 -1
- package/dist/liveReactionRepository/service/ReactionSyncEngine.d.ts.map +1 -1
- package/dist/messagePreview/utils/getChannelMessagePreviewWithUser.d.ts +2 -1
- package/dist/messagePreview/utils/getChannelMessagePreviewWithUser.d.ts.map +1 -1
- package/dist/roomPresenceRepository/api/getRoomOnlineUsers.d.ts +18 -0
- package/dist/roomPresenceRepository/api/getRoomOnlineUsers.d.ts.map +1 -0
- package/dist/roomPresenceRepository/api/getRoomUserCount.d.ts +17 -0
- package/dist/roomPresenceRepository/api/getRoomUserCount.d.ts.map +1 -0
- package/dist/roomPresenceRepository/api/index.d.ts +5 -0
- package/dist/roomPresenceRepository/api/index.d.ts.map +1 -0
- package/dist/roomPresenceRepository/api/startHeartbeat.d.ts +15 -0
- package/dist/roomPresenceRepository/api/startHeartbeat.d.ts.map +1 -0
- package/dist/roomPresenceRepository/api/stopHeartbeat.d.ts +15 -0
- package/dist/roomPresenceRepository/api/stopHeartbeat.d.ts.map +1 -0
- package/dist/roomPresenceRepository/index.d.ts +2 -0
- package/dist/roomPresenceRepository/index.d.ts.map +1 -0
- package/dist/roomPresenceRepository/services/RoomPresenceSyncEngine/RoomPresenceSyncEngine.d.ts +38 -0
- package/dist/roomPresenceRepository/services/RoomPresenceSyncEngine/RoomPresenceSyncEngine.d.ts.map +1 -0
- package/dist/roomPresenceRepository/services/RoomPresenceSyncEngine/index.d.ts +2 -0
- package/dist/roomPresenceRepository/services/RoomPresenceSyncEngine/index.d.ts.map +1 -0
- package/dist/roomPresenceRepository/services/RoomPresenceSyncEngine/roomPresenceSyncEngineFactory.d.ts +32 -0
- package/dist/roomPresenceRepository/services/RoomPresenceSyncEngine/roomPresenceSyncEngineFactory.d.ts.map +1 -0
- package/dist/roomPresenceRepository/services/index.d.ts +2 -0
- package/dist/roomPresenceRepository/services/index.d.ts.map +1 -0
- package/dist/roomRepository/api/{getRoomToken.d.ts → getBroadcasterData.d.ts} +3 -3
- package/dist/roomRepository/api/getBroadcasterData.d.ts.map +1 -0
- package/dist/roomRepository/api/index.d.ts +3 -1
- package/dist/roomRepository/api/index.d.ts.map +1 -1
- package/dist/roomRepository/api/leaveRoom.d.ts +16 -0
- package/dist/roomRepository/api/leaveRoom.d.ts.map +1 -0
- package/dist/roomRepository/api/removeParticipant.d.ts +17 -0
- package/dist/roomRepository/api/removeParticipant.d.ts.map +1 -0
- package/dist/roomRepository/api/updateRoom.d.ts +1 -1
- package/dist/roomRepository/api/updateRoom.d.ts.map +1 -1
- package/dist/roomRepository/events/index.d.ts +6 -1
- package/dist/roomRepository/events/index.d.ts.map +1 -1
- package/dist/roomRepository/events/onRoomCoHostInviteAccepted.d.ts +17 -0
- package/dist/roomRepository/events/onRoomCoHostInviteAccepted.d.ts.map +1 -0
- package/dist/roomRepository/events/onRoomCoHostInviteCanceled.d.ts +17 -0
- package/dist/roomRepository/events/onRoomCoHostInviteCanceled.d.ts.map +1 -0
- package/dist/roomRepository/events/onRoomCoHostInviteRejected.d.ts +17 -0
- package/dist/roomRepository/events/onRoomCoHostInviteRejected.d.ts.map +1 -0
- package/dist/roomRepository/events/{onRoomParticipantInviting.d.ts → onRoomCoHostInvited.d.ts} +2 -2
- package/dist/roomRepository/events/onRoomCoHostInvited.d.ts.map +1 -0
- package/dist/roomRepository/events/onRoomEndBroadcasting.d.ts +1 -1
- package/dist/roomRepository/events/onRoomEndBroadcasting.d.ts.map +1 -1
- package/dist/roomRepository/events/onRoomLeft.d.ts +17 -0
- package/dist/roomRepository/events/onRoomLeft.d.ts.map +1 -0
- package/dist/roomRepository/events/onRoomParticipantJoined.d.ts +1 -1
- package/dist/roomRepository/events/onRoomParticipantJoined.d.ts.map +1 -1
- package/dist/roomRepository/events/onRoomParticipantLeft.d.ts +1 -1
- package/dist/roomRepository/events/onRoomParticipantLeft.d.ts.map +1 -1
- package/dist/roomRepository/events/onRoomParticipantRemoved.d.ts +17 -0
- package/dist/roomRepository/events/onRoomParticipantRemoved.d.ts.map +1 -0
- package/dist/roomRepository/events/onRoomParticipantRemovedLocal.d.ts +17 -0
- package/dist/roomRepository/events/onRoomParticipantRemovedLocal.d.ts.map +1 -0
- package/dist/roomRepository/events/onRoomRecordedAvailable.d.ts +1 -1
- package/dist/roomRepository/events/onRoomRecordedAvailable.d.ts.map +1 -1
- package/dist/roomRepository/events/onRoomStartBroadcasting.d.ts +1 -1
- package/dist/roomRepository/events/onRoomStartBroadcasting.d.ts.map +1 -1
- package/dist/roomRepository/events/onRoomWaitingReconnect.d.ts +1 -1
- package/dist/roomRepository/events/onRoomWaitingReconnect.d.ts.map +1 -1
- package/dist/roomRepository/observers/getRoom.d.ts.map +1 -1
- package/dist/roomRepository/observers/utils.d.ts +1 -1
- package/dist/utils/linkedObject/communityLinkedObject.d.ts.map +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 +2 -0
- package/dist/utils/linkedObject/index.d.ts.map +1 -1
- package/dist/utils/linkedObject/roomLinkedObject.d.ts.map +1 -1
- package/package.json +1 -1
- package/dist/client/utils/ObjectResolver/objectResolverEngine.d.ts.map +0 -1
- package/dist/client/utils/ObjectResolver/objectResolverEngineOnLoginHandler.d.ts.map +0 -1
- package/dist/client/utils/ReadReceiptSync/legacyReadReceiptSyncEngine.d.ts.map +0 -1
- package/dist/client/utils/ReadReceiptSync/legacyReadReceiptSyncEngineOnLoginHandler.d.ts.map +0 -1
- package/dist/client/utils/ReadReceiptSync/readReceiptSyncEngine.d.ts.map +0 -1
- package/dist/client/utils/ReadReceiptSync/readReceiptSyncEngineOnLoginHandler.d.ts.map +0 -1
- package/dist/invitationRepository/events/onLocalInvitationDeleted.d.ts +0 -17
- package/dist/invitationRepository/events/onLocalInvitationDeleted.d.ts.map +0 -1
- package/dist/invitationRepository/observers/getInvitations/InvitationsLiveCollectionController.d.ts.map +0 -1
- package/dist/invitationRepository/observers/getInvitations/InvitationsPaginationController.d.ts.map +0 -1
- package/dist/invitationRepository/observers/getInvitations/InvitationsQueryStreamController.d.ts.map +0 -1
- package/dist/invitationRepository/observers/getInvitations/enums.d.ts.map +0 -1
- package/dist/roomRepository/api/getRoomToken.d.ts.map +0 -1
- package/dist/roomRepository/events/onRoomParticipantInviting.d.ts.map +0 -1
- /package/dist/client/{utils → services}/ObjectResolver/objectResolverEngine.d.ts +0 -0
- /package/dist/client/{utils → services}/ObjectResolver/objectResolverEngineOnLoginHandler.d.ts +0 -0
- /package/dist/client/{utils → services}/ReadReceiptSync/legacyReadReceiptSyncEngine.d.ts +0 -0
- /package/dist/client/{utils → services}/ReadReceiptSync/legacyReadReceiptSyncEngineOnLoginHandler.d.ts +0 -0
- /package/dist/client/{utils → services}/ReadReceiptSync/readReceiptSyncEngine.d.ts +0 -0
- /package/dist/client/{utils → services}/ReadReceiptSync/readReceiptSyncEngineOnLoginHandler.d.ts +0 -0
- /package/dist/invitationRepository/{observers → internalObservers}/getInvitations/InvitationsLiveCollectionController.d.ts +0 -0
- /package/dist/invitationRepository/{observers → internalObservers}/getInvitations/InvitationsPaginationController.d.ts +0 -0
- /package/dist/invitationRepository/{observers → internalObservers}/getInvitations/InvitationsQueryStreamController.d.ts +0 -0
package/dist/index.esm.js
CHANGED
|
@@ -73,6 +73,11 @@ const CommunityPostSettingMaps = Object.freeze({
|
|
|
73
73
|
},
|
|
74
74
|
});
|
|
75
75
|
const DefaultCommunityPostSetting = 'ONLY_ADMIN_CAN_POST';
|
|
76
|
+
var AmityCommunityType;
|
|
77
|
+
(function (AmityCommunityType) {
|
|
78
|
+
AmityCommunityType["Default"] = "default";
|
|
79
|
+
AmityCommunityType["Event"] = "event";
|
|
80
|
+
})(AmityCommunityType || (AmityCommunityType = {}));
|
|
76
81
|
|
|
77
82
|
const ContentFeedType = Object.freeze({
|
|
78
83
|
STORY: 'story',
|
|
@@ -126,7 +131,7 @@ const PostStructureType = Object.freeze({
|
|
|
126
131
|
var InvitationTypeEnum;
|
|
127
132
|
(function (InvitationTypeEnum) {
|
|
128
133
|
InvitationTypeEnum["CommunityMemberInvite"] = "communityMemberInvite";
|
|
129
|
-
InvitationTypeEnum["
|
|
134
|
+
InvitationTypeEnum["LivestreamCohostInvite"] = "livestreamCohostInvite";
|
|
130
135
|
})(InvitationTypeEnum || (InvitationTypeEnum = {}));
|
|
131
136
|
var InvitationStatusEnum;
|
|
132
137
|
(function (InvitationStatusEnum) {
|
|
@@ -140,6 +145,11 @@ var InvitationSortByEnum;
|
|
|
140
145
|
InvitationSortByEnum["FirstCreated"] = "firstCreated";
|
|
141
146
|
InvitationSortByEnum["LastCreated"] = "lastCreated";
|
|
142
147
|
})(InvitationSortByEnum || (InvitationSortByEnum = {}));
|
|
148
|
+
var InvitationTargetTypeEnum;
|
|
149
|
+
(function (InvitationTargetTypeEnum) {
|
|
150
|
+
InvitationTargetTypeEnum["Community"] = "community";
|
|
151
|
+
InvitationTargetTypeEnum["Room"] = "room";
|
|
152
|
+
})(InvitationTargetTypeEnum || (InvitationTargetTypeEnum = {}));
|
|
143
153
|
|
|
144
154
|
var JoinRequestStatusEnum;
|
|
145
155
|
(function (JoinRequestStatusEnum) {
|
|
@@ -179,6 +189,40 @@ var FeedSourceEnum;
|
|
|
179
189
|
FeedSourceEnum["User"] = "user";
|
|
180
190
|
})(FeedSourceEnum || (FeedSourceEnum = {}));
|
|
181
191
|
|
|
192
|
+
var AmityEventType;
|
|
193
|
+
(function (AmityEventType) {
|
|
194
|
+
AmityEventType["Virtual"] = "virtual";
|
|
195
|
+
AmityEventType["InPerson"] = "in_person";
|
|
196
|
+
})(AmityEventType || (AmityEventType = {}));
|
|
197
|
+
var AmityEventOriginType;
|
|
198
|
+
(function (AmityEventOriginType) {
|
|
199
|
+
AmityEventOriginType["Community"] = "community";
|
|
200
|
+
AmityEventOriginType["User"] = "user";
|
|
201
|
+
})(AmityEventOriginType || (AmityEventOriginType = {}));
|
|
202
|
+
var AmityEventStatus;
|
|
203
|
+
(function (AmityEventStatus) {
|
|
204
|
+
AmityEventStatus["Scheduled"] = "scheduled";
|
|
205
|
+
AmityEventStatus["Live"] = "live";
|
|
206
|
+
AmityEventStatus["Ended"] = "ended";
|
|
207
|
+
AmityEventStatus["Cancelled"] = "cancelled";
|
|
208
|
+
})(AmityEventStatus || (AmityEventStatus = {}));
|
|
209
|
+
var AmityEventResponseStatus;
|
|
210
|
+
(function (AmityEventResponseStatus) {
|
|
211
|
+
AmityEventResponseStatus["Going"] = "going";
|
|
212
|
+
AmityEventResponseStatus["Interested"] = "interested";
|
|
213
|
+
AmityEventResponseStatus["NotGoing"] = "not_going";
|
|
214
|
+
})(AmityEventResponseStatus || (AmityEventResponseStatus = {}));
|
|
215
|
+
var AmityEventSortOption;
|
|
216
|
+
(function (AmityEventSortOption) {
|
|
217
|
+
AmityEventSortOption["StartTime"] = "startTime";
|
|
218
|
+
AmityEventSortOption["CreatedAt"] = "createdAt";
|
|
219
|
+
})(AmityEventSortOption || (AmityEventSortOption = {}));
|
|
220
|
+
var AmityEventOrderOption;
|
|
221
|
+
(function (AmityEventOrderOption) {
|
|
222
|
+
AmityEventOrderOption["Ascending"] = "asc";
|
|
223
|
+
AmityEventOrderOption["Descending"] = "desc";
|
|
224
|
+
})(AmityEventOrderOption || (AmityEventOrderOption = {}));
|
|
225
|
+
|
|
182
226
|
function getVersion() {
|
|
183
227
|
try {
|
|
184
228
|
// the string ''v7.11.0-esm'' should be replaced by actual value by @rollup/plugin-replace
|
|
@@ -628,6 +672,7 @@ const idResolvers = {
|
|
|
628
672
|
invitation: ({ _id }) => _id,
|
|
629
673
|
joinRequest: ({ joinRequestId }) => joinRequestId,
|
|
630
674
|
room: ({ roomId }) => roomId,
|
|
675
|
+
event: ({ eventId }) => eventId,
|
|
631
676
|
};
|
|
632
677
|
/**
|
|
633
678
|
* Retrieve the id resolver matching a domain name
|
|
@@ -684,6 +729,8 @@ const PAYLOAD2MODEL = {
|
|
|
684
729
|
invitations: 'invitation',
|
|
685
730
|
joinRequests: 'joinRequest',
|
|
686
731
|
rooms: 'room',
|
|
732
|
+
events: 'event',
|
|
733
|
+
viewers: 'viewer',
|
|
687
734
|
};
|
|
688
735
|
/** hidden */
|
|
689
736
|
const isOutdated = (prevData, nextData) => {
|
|
@@ -1483,6 +1530,37 @@ async function modifyMqttConnection() {
|
|
|
1483
1530
|
}
|
|
1484
1531
|
}
|
|
1485
1532
|
|
|
1533
|
+
const userLinkedObject = (user) => {
|
|
1534
|
+
return Object.assign(Object.assign({}, user), { get avatar() {
|
|
1535
|
+
var _a;
|
|
1536
|
+
if (!user.avatarFileId)
|
|
1537
|
+
return undefined;
|
|
1538
|
+
const avatar = (_a = pullFromCache([
|
|
1539
|
+
'file',
|
|
1540
|
+
'get',
|
|
1541
|
+
`${user.avatarFileId}`,
|
|
1542
|
+
])) === null || _a === void 0 ? void 0 : _a.data;
|
|
1543
|
+
return avatar;
|
|
1544
|
+
} });
|
|
1545
|
+
};
|
|
1546
|
+
|
|
1547
|
+
/* begin_public_function
|
|
1548
|
+
id: client.get_current_user
|
|
1549
|
+
*/
|
|
1550
|
+
const getCurrentUser = () => {
|
|
1551
|
+
var _a;
|
|
1552
|
+
const client = getActiveClient();
|
|
1553
|
+
if (!client) {
|
|
1554
|
+
throw new ASCError('Connect client first', 800000 /* Amity.ClientError.UNKNOWN_ERROR */, "fatal" /* Amity.ErrorLevel.FATAL */);
|
|
1555
|
+
}
|
|
1556
|
+
const cache = (_a = pullFromCache(['user', 'get', client.userId])) === null || _a === void 0 ? void 0 : _a.data;
|
|
1557
|
+
if (!cache) {
|
|
1558
|
+
throw new ASCError('Connect client first', 800000 /* Amity.ClientError.UNKNOWN_ERROR */, "fatal" /* Amity.ErrorLevel.FATAL */);
|
|
1559
|
+
}
|
|
1560
|
+
return userLinkedObject(cache);
|
|
1561
|
+
};
|
|
1562
|
+
/* end_public_function */
|
|
1563
|
+
|
|
1486
1564
|
var SubscriptionLevels;
|
|
1487
1565
|
(function (SubscriptionLevels) {
|
|
1488
1566
|
SubscriptionLevels["COMMUNITY"] = "community";
|
|
@@ -1588,6 +1666,14 @@ const getLiveStreamTopic = () => {
|
|
|
1588
1666
|
const getLiveReactionTopic = (post) => {
|
|
1589
1667
|
return `${post.path}/liveReaction`;
|
|
1590
1668
|
};
|
|
1669
|
+
const getRoomWatcherTopic = (room) => {
|
|
1670
|
+
const user = getCurrentUser();
|
|
1671
|
+
return `${getNetworkId(user)}/room/${room._id}`;
|
|
1672
|
+
};
|
|
1673
|
+
const getRoomStreamerTopic = (room) => {
|
|
1674
|
+
const user = getCurrentUser();
|
|
1675
|
+
return `${getNetworkId(user)}/room/${room.roomId}/streamer`;
|
|
1676
|
+
};
|
|
1591
1677
|
function subscribeTopic(topic, callback) {
|
|
1592
1678
|
const { mqtt } = getActiveClient();
|
|
1593
1679
|
if (!mqtt)
|
|
@@ -21014,20 +21100,6 @@ const getChannelMessagePreview = (channelId) => {
|
|
|
21014
21100
|
return ((_b = (_a = pullFromCache(['messagePreviewChannel', 'get', channelId])) === null || _a === void 0 ? void 0 : _a.data) !== null && _b !== void 0 ? _b : null);
|
|
21015
21101
|
};
|
|
21016
21102
|
|
|
21017
|
-
const userLinkedObject = (user) => {
|
|
21018
|
-
return Object.assign(Object.assign({}, user), { get avatar() {
|
|
21019
|
-
var _a;
|
|
21020
|
-
if (!user.avatarFileId)
|
|
21021
|
-
return undefined;
|
|
21022
|
-
const avatar = (_a = pullFromCache([
|
|
21023
|
-
'file',
|
|
21024
|
-
'get',
|
|
21025
|
-
`${user.avatarFileId}`,
|
|
21026
|
-
])) === null || _a === void 0 ? void 0 : _a.data;
|
|
21027
|
-
return avatar;
|
|
21028
|
-
} });
|
|
21029
|
-
};
|
|
21030
|
-
|
|
21031
21103
|
const getChannelMessagePreviewWithUser = (channel) => {
|
|
21032
21104
|
var _a;
|
|
21033
21105
|
const messagePreview = channel.messagePreviewId
|
|
@@ -24605,19 +24677,19 @@ class LiveReactionSyncEngine {
|
|
|
24605
24677
|
// Clear buffer
|
|
24606
24678
|
this.clearBuffer();
|
|
24607
24679
|
const payloads = reactions.reduce((prev, curr) => {
|
|
24608
|
-
const {
|
|
24609
|
-
if (!prev[
|
|
24680
|
+
const { roomId } = curr, rest = __rest(curr, ["roomId"]);
|
|
24681
|
+
if (!prev[roomId]) {
|
|
24610
24682
|
// eslint-disable-next-line no-param-reassign
|
|
24611
|
-
prev[
|
|
24683
|
+
prev[roomId] = [rest];
|
|
24612
24684
|
}
|
|
24613
24685
|
else
|
|
24614
|
-
prev[
|
|
24686
|
+
prev[roomId].push(rest);
|
|
24615
24687
|
return prev;
|
|
24616
24688
|
}, {});
|
|
24617
24689
|
// Call server api `POST /api/v1/reactions/live` to sync live reactions
|
|
24618
|
-
Object.entries(payloads).forEach(([
|
|
24690
|
+
Object.entries(payloads).forEach(([roomId, reactions]) => {
|
|
24619
24691
|
createLiveReaction({
|
|
24620
|
-
liveStreamId:
|
|
24692
|
+
liveStreamId: roomId,
|
|
24621
24693
|
reactions,
|
|
24622
24694
|
});
|
|
24623
24695
|
});
|
|
@@ -25110,23 +25182,6 @@ const loginAsVisitor = async (params) => {
|
|
|
25110
25182
|
};
|
|
25111
25183
|
/* end_public_function */
|
|
25112
25184
|
|
|
25113
|
-
/* begin_public_function
|
|
25114
|
-
id: client.get_current_user
|
|
25115
|
-
*/
|
|
25116
|
-
const getCurrentUser = () => {
|
|
25117
|
-
var _a;
|
|
25118
|
-
const client = getActiveClient();
|
|
25119
|
-
if (!client) {
|
|
25120
|
-
throw new ASCError('Connect client first', 800000 /* Amity.ClientError.UNKNOWN_ERROR */, "fatal" /* Amity.ErrorLevel.FATAL */);
|
|
25121
|
-
}
|
|
25122
|
-
const cache = (_a = pullFromCache(['user', 'get', client.userId])) === null || _a === void 0 ? void 0 : _a.data;
|
|
25123
|
-
if (!cache) {
|
|
25124
|
-
throw new ASCError('Connect client first', 800000 /* Amity.ClientError.UNKNOWN_ERROR */, "fatal" /* Amity.ErrorLevel.FATAL */);
|
|
25125
|
-
}
|
|
25126
|
-
return userLinkedObject(cache);
|
|
25127
|
-
};
|
|
25128
|
-
/* end_public_function */
|
|
25129
|
-
|
|
25130
25185
|
/* begin_public_function
|
|
25131
25186
|
id: client.renew_access_token
|
|
25132
25187
|
*/
|
|
@@ -26556,7 +26611,7 @@ const getUserUnread = (callback) => {
|
|
|
26556
26611
|
};
|
|
26557
26612
|
};
|
|
26558
26613
|
|
|
26559
|
-
var index$
|
|
26614
|
+
var index$r = /*#__PURE__*/Object.freeze({
|
|
26560
26615
|
__proto__: null,
|
|
26561
26616
|
getActiveClient: getActiveClient,
|
|
26562
26617
|
getActiveUser: getActiveUser,
|
|
@@ -27775,7 +27830,7 @@ const getMyFollowInfo = (callback) => {
|
|
|
27775
27830
|
};
|
|
27776
27831
|
/* end_public_function */
|
|
27777
27832
|
|
|
27778
|
-
var index$
|
|
27833
|
+
var index$q = /*#__PURE__*/Object.freeze({
|
|
27779
27834
|
__proto__: null,
|
|
27780
27835
|
blockUser: blockUser,
|
|
27781
27836
|
unBlockUser: unBlockUser,
|
|
@@ -28357,6 +28412,462 @@ const getLiveChat = async (room) => {
|
|
|
28357
28412
|
return undefined;
|
|
28358
28413
|
};
|
|
28359
28414
|
|
|
28415
|
+
const convertRawInvitationToInternalInvitation = (rawInvitation) => {
|
|
28416
|
+
return Object.assign(Object.assign({}, rawInvitation), { createdById: rawInvitation.createdBy });
|
|
28417
|
+
};
|
|
28418
|
+
|
|
28419
|
+
const prepareInvitationPayload = (rawPayload) => {
|
|
28420
|
+
return Object.assign(Object.assign({}, rawPayload), { invitations: rawPayload.invitations.map(convertRawInvitationToInternalInvitation), users: rawPayload.users.map(convertRawUserToInternalUser) });
|
|
28421
|
+
};
|
|
28422
|
+
|
|
28423
|
+
/* begin_public_function
|
|
28424
|
+
id: invitation.createInvitations
|
|
28425
|
+
*/
|
|
28426
|
+
/**
|
|
28427
|
+
* ```js
|
|
28428
|
+
* import { createInvitations } from '@amityco/ts-sdk'
|
|
28429
|
+
* const created = await createInvitations({
|
|
28430
|
+
* type: string,
|
|
28431
|
+
* targetType: string,
|
|
28432
|
+
* targetId: string,
|
|
28433
|
+
* userIds: string[]
|
|
28434
|
+
* }))
|
|
28435
|
+
* ```
|
|
28436
|
+
*
|
|
28437
|
+
* Creates an {@link Amity.Invitation}
|
|
28438
|
+
*
|
|
28439
|
+
* @param bundle The data necessary to create a new {@link Amity.Invitation}
|
|
28440
|
+
* @returns The newly created {@link Amity.Invitation}
|
|
28441
|
+
*
|
|
28442
|
+
* @category Invitation API
|
|
28443
|
+
* @async
|
|
28444
|
+
*/
|
|
28445
|
+
const createInvitations = async (bundle) => {
|
|
28446
|
+
const client = getActiveClient();
|
|
28447
|
+
client.log('invitation/createInvitations', bundle);
|
|
28448
|
+
const { data: payload } = await client.http.post('/api/v1/invitations', bundle);
|
|
28449
|
+
const data = prepareInvitationPayload(payload);
|
|
28450
|
+
const cachedAt = client.cache && Date.now();
|
|
28451
|
+
if (client.cache)
|
|
28452
|
+
ingestInCache(data, { cachedAt });
|
|
28453
|
+
fireEvent('local.invitation.created', data.invitations);
|
|
28454
|
+
return {
|
|
28455
|
+
data: data.invitations,
|
|
28456
|
+
cachedAt,
|
|
28457
|
+
};
|
|
28458
|
+
};
|
|
28459
|
+
/* end_public_function */
|
|
28460
|
+
|
|
28461
|
+
/* begin_public_function
|
|
28462
|
+
id: invitation.accept
|
|
28463
|
+
*/
|
|
28464
|
+
/**
|
|
28465
|
+
* ```js
|
|
28466
|
+
* import { acceptInvitation } from '@amityco/ts-sdk'
|
|
28467
|
+
* const isAccepted = await acceptInvitation(invitationId)
|
|
28468
|
+
* ```
|
|
28469
|
+
*
|
|
28470
|
+
* Accepts a {@link Amity.Invitation} object
|
|
28471
|
+
*
|
|
28472
|
+
* @param invitationId the {@link Amity.Invitation} to accept
|
|
28473
|
+
* @returns A success boolean if the {@link Amity.Invitation} was accepted
|
|
28474
|
+
*
|
|
28475
|
+
* @category Invitation API
|
|
28476
|
+
* @async
|
|
28477
|
+
*/
|
|
28478
|
+
const acceptInvitation = async (invitationId) => {
|
|
28479
|
+
var _a;
|
|
28480
|
+
const client = getActiveClient();
|
|
28481
|
+
client.log('invitation/acceptInvitation', invitationId);
|
|
28482
|
+
const { data } = await client.http.post(`/api/v1/invitations/${invitationId}/accept`);
|
|
28483
|
+
const invitation = (_a = pullFromCache([
|
|
28484
|
+
'invitation',
|
|
28485
|
+
'get',
|
|
28486
|
+
invitationId,
|
|
28487
|
+
])) === null || _a === void 0 ? void 0 : _a.data;
|
|
28488
|
+
if (invitation) {
|
|
28489
|
+
upsertInCache(['invitation', 'get', invitationId], { status: "approved" /* InvitationStatusEnum.Approved */ });
|
|
28490
|
+
fireEvent('local.invitation.updated', [invitation]);
|
|
28491
|
+
}
|
|
28492
|
+
return data.success;
|
|
28493
|
+
};
|
|
28494
|
+
/* end_public_function */
|
|
28495
|
+
|
|
28496
|
+
/* begin_public_function
|
|
28497
|
+
id: invitation.reject
|
|
28498
|
+
*/
|
|
28499
|
+
/**
|
|
28500
|
+
* ```js
|
|
28501
|
+
* import { rejectInvitation } from '@amityco/ts-sdk'
|
|
28502
|
+
* const isRejected = await rejectInvitation(invitationId)
|
|
28503
|
+
* ```
|
|
28504
|
+
*
|
|
28505
|
+
* Rejects a {@link Amity.Invitation} object
|
|
28506
|
+
*
|
|
28507
|
+
* @param invitationId the {@link Amity.Invitation} to reject
|
|
28508
|
+
* @returns A success boolean if the {@link Amity.Invitation} was rejected
|
|
28509
|
+
*
|
|
28510
|
+
* @category Invitation API
|
|
28511
|
+
* @async
|
|
28512
|
+
*/
|
|
28513
|
+
const rejectInvitation = async (invitationId) => {
|
|
28514
|
+
var _a;
|
|
28515
|
+
const client = getActiveClient();
|
|
28516
|
+
client.log('invitation/rejectInvitation', invitationId);
|
|
28517
|
+
const { data } = await client.http.post(`/api/v1/invitations/${invitationId}/reject`);
|
|
28518
|
+
const invitation = (_a = pullFromCache([
|
|
28519
|
+
'invitation',
|
|
28520
|
+
'get',
|
|
28521
|
+
invitationId,
|
|
28522
|
+
])) === null || _a === void 0 ? void 0 : _a.data;
|
|
28523
|
+
if (invitation) {
|
|
28524
|
+
upsertInCache(['invitation', 'get', invitationId], { status: "rejected" /* InvitationStatusEnum.Rejected */ });
|
|
28525
|
+
fireEvent('local.invitation.updated', [invitation]);
|
|
28526
|
+
}
|
|
28527
|
+
return data.success;
|
|
28528
|
+
};
|
|
28529
|
+
/* end_public_function */
|
|
28530
|
+
|
|
28531
|
+
var InvitationActionsEnum;
|
|
28532
|
+
(function (InvitationActionsEnum) {
|
|
28533
|
+
InvitationActionsEnum["OnLocalInvitationCreated"] = "onLocalInvitationCreated";
|
|
28534
|
+
InvitationActionsEnum["OnLocalInvitationUpdated"] = "onLocalInvitationUpdated";
|
|
28535
|
+
InvitationActionsEnum["OnLocalInvitationCanceled"] = "onLocalInvitationCanceled";
|
|
28536
|
+
})(InvitationActionsEnum || (InvitationActionsEnum = {}));
|
|
28537
|
+
|
|
28538
|
+
const invitationLinkedObject = (invitation) => {
|
|
28539
|
+
return Object.assign(Object.assign({}, invitation), { get user() {
|
|
28540
|
+
const cacheData = pullFromCache(['user', 'get', invitation.invitedUserPublicId]);
|
|
28541
|
+
if (cacheData === null || cacheData === void 0 ? void 0 : cacheData.data)
|
|
28542
|
+
return userLinkedObject(cacheData.data);
|
|
28543
|
+
return undefined;
|
|
28544
|
+
},
|
|
28545
|
+
get createdBy() {
|
|
28546
|
+
const cacheData = pullFromCache(['user', 'get', invitation.inviterUserPublicId]);
|
|
28547
|
+
if (cacheData === null || cacheData === void 0 ? void 0 : cacheData.data)
|
|
28548
|
+
return userLinkedObject(cacheData.data);
|
|
28549
|
+
return undefined;
|
|
28550
|
+
},
|
|
28551
|
+
get target() {
|
|
28552
|
+
if (invitation.targetType === 'community') {
|
|
28553
|
+
const cacheData = pullFromCache([
|
|
28554
|
+
'community',
|
|
28555
|
+
'get',
|
|
28556
|
+
invitation.targetId,
|
|
28557
|
+
]);
|
|
28558
|
+
if (cacheData === null || cacheData === void 0 ? void 0 : cacheData.data)
|
|
28559
|
+
return cacheData.data;
|
|
28560
|
+
return undefined;
|
|
28561
|
+
}
|
|
28562
|
+
return undefined;
|
|
28563
|
+
}, accept: async () => {
|
|
28564
|
+
await acceptInvitation(invitation._id);
|
|
28565
|
+
}, reject: async () => {
|
|
28566
|
+
await rejectInvitation(invitation._id);
|
|
28567
|
+
} });
|
|
28568
|
+
};
|
|
28569
|
+
|
|
28570
|
+
class InvitationsPaginationController extends PaginationController {
|
|
28571
|
+
async getRequest(queryParams, token) {
|
|
28572
|
+
const { limit = COLLECTION_DEFAULT_PAGINATION_LIMIT } = queryParams, params = __rest(queryParams, ["limit"]);
|
|
28573
|
+
const options = token ? { token } : { limit };
|
|
28574
|
+
const { data } = await this.http.get('/api/v1/invitations', { params: Object.assign(Object.assign({}, params), { options }) });
|
|
28575
|
+
return data;
|
|
28576
|
+
}
|
|
28577
|
+
}
|
|
28578
|
+
|
|
28579
|
+
class InvitationsQueryStreamController extends QueryStreamController {
|
|
28580
|
+
constructor(query, cacheKey, notifyChange, preparePayload) {
|
|
28581
|
+
super(query, cacheKey);
|
|
28582
|
+
this.notifyChange = notifyChange;
|
|
28583
|
+
this.preparePayload = preparePayload;
|
|
28584
|
+
}
|
|
28585
|
+
async saveToMainDB(response) {
|
|
28586
|
+
const processedPayload = await this.preparePayload(response);
|
|
28587
|
+
const client = getActiveClient();
|
|
28588
|
+
const cachedAt = client.cache && Date.now();
|
|
28589
|
+
if (client.cache) {
|
|
28590
|
+
ingestInCache(processedPayload, { cachedAt });
|
|
28591
|
+
}
|
|
28592
|
+
}
|
|
28593
|
+
appendToQueryStream(response, direction, refresh = false) {
|
|
28594
|
+
var _a, _b;
|
|
28595
|
+
if (refresh) {
|
|
28596
|
+
pushToCache(this.cacheKey, {
|
|
28597
|
+
data: response.invitations.map(getResolver('invitation')),
|
|
28598
|
+
});
|
|
28599
|
+
}
|
|
28600
|
+
else {
|
|
28601
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
28602
|
+
const invitations = (_b = collection === null || collection === void 0 ? void 0 : collection.data) !== null && _b !== void 0 ? _b : [];
|
|
28603
|
+
pushToCache(this.cacheKey, Object.assign(Object.assign({}, collection), { data: [
|
|
28604
|
+
...new Set([...invitations, ...response.invitations.map(getResolver('invitation'))]),
|
|
28605
|
+
] }));
|
|
28606
|
+
}
|
|
28607
|
+
}
|
|
28608
|
+
reactor(action) {
|
|
28609
|
+
return (invitations) => {
|
|
28610
|
+
var _a;
|
|
28611
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
28612
|
+
if (!collection)
|
|
28613
|
+
return;
|
|
28614
|
+
if (action === InvitationActionsEnum.OnLocalInvitationUpdated) {
|
|
28615
|
+
const isExist = collection.data.find(id => id === invitations[0].invitationId);
|
|
28616
|
+
if (!isExist)
|
|
28617
|
+
return;
|
|
28618
|
+
}
|
|
28619
|
+
if (action === InvitationActionsEnum.OnLocalInvitationCreated) {
|
|
28620
|
+
collection.data = [
|
|
28621
|
+
...new Set([
|
|
28622
|
+
...invitations.map(invitation => invitation.invitationId),
|
|
28623
|
+
...collection.data,
|
|
28624
|
+
]),
|
|
28625
|
+
];
|
|
28626
|
+
}
|
|
28627
|
+
if (action === InvitationActionsEnum.OnLocalInvitationDeleted) {
|
|
28628
|
+
collection.data = collection.data.filter(id => id !== invitations[0].invitationId);
|
|
28629
|
+
}
|
|
28630
|
+
pushToCache(this.cacheKey, collection);
|
|
28631
|
+
this.notifyChange({ origin: "event" /* Amity.LiveDataOrigin.EVENT */, loading: false });
|
|
28632
|
+
};
|
|
28633
|
+
}
|
|
28634
|
+
subscribeRTE(createSubscriber) {
|
|
28635
|
+
return createSubscriber.map(subscriber => subscriber.fn(this.reactor(subscriber.action)));
|
|
28636
|
+
}
|
|
28637
|
+
}
|
|
28638
|
+
|
|
28639
|
+
/**
|
|
28640
|
+
* ```js
|
|
28641
|
+
* import { onLocalInvitationCreated } from '@amityco/ts-sdk'
|
|
28642
|
+
* const dispose = onLocalInvitationCreated(data => {
|
|
28643
|
+
* // ...
|
|
28644
|
+
* })
|
|
28645
|
+
* ```
|
|
28646
|
+
*
|
|
28647
|
+
* Fired when an {@link Amity.InvitationPayload} has been created
|
|
28648
|
+
*
|
|
28649
|
+
* @param callback The function to call when the event was fired
|
|
28650
|
+
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
28651
|
+
*
|
|
28652
|
+
* @category Invitation Events
|
|
28653
|
+
*/
|
|
28654
|
+
const onLocalInvitationCreated = (callback) => {
|
|
28655
|
+
const client = getActiveClient();
|
|
28656
|
+
const disposers = [
|
|
28657
|
+
createEventSubscriber(client, 'onLocalInvitationCreated', 'local.invitation.created', payload => callback(payload)),
|
|
28658
|
+
];
|
|
28659
|
+
return () => {
|
|
28660
|
+
disposers.forEach(fn => fn());
|
|
28661
|
+
};
|
|
28662
|
+
};
|
|
28663
|
+
|
|
28664
|
+
/**
|
|
28665
|
+
* ```js
|
|
28666
|
+
* import { onLocalInvitationUpdated } from '@amityco/ts-sdk'
|
|
28667
|
+
* const dispose = onLocalInvitationUpdated(data => {
|
|
28668
|
+
* // ...
|
|
28669
|
+
* })
|
|
28670
|
+
* ```
|
|
28671
|
+
*
|
|
28672
|
+
* Fired when an {@link Amity.InvitationPayload} has been updated
|
|
28673
|
+
*
|
|
28674
|
+
* @param callback The function to call when the event was fired
|
|
28675
|
+
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
28676
|
+
*
|
|
28677
|
+
* @category Invitation Events
|
|
28678
|
+
*/
|
|
28679
|
+
const onLocalInvitationUpdated = (callback) => {
|
|
28680
|
+
const client = getActiveClient();
|
|
28681
|
+
const disposers = [
|
|
28682
|
+
createEventSubscriber(client, 'onLocalInvitationUpdated', 'local.invitation.updated', payload => callback(payload)),
|
|
28683
|
+
];
|
|
28684
|
+
return () => {
|
|
28685
|
+
disposers.forEach(fn => fn());
|
|
28686
|
+
};
|
|
28687
|
+
};
|
|
28688
|
+
|
|
28689
|
+
/**
|
|
28690
|
+
* ```js
|
|
28691
|
+
* import { onLocalInvitationCanceled } from '@amityco/ts-sdk'
|
|
28692
|
+
* const dispose = onLocalInvitationCanceled(data => {
|
|
28693
|
+
* // ...
|
|
28694
|
+
* })
|
|
28695
|
+
* ```
|
|
28696
|
+
*
|
|
28697
|
+
* Fired when an {@link Amity.InvitationPayload} has been deleted
|
|
28698
|
+
*
|
|
28699
|
+
* @param callback The function to call when the event was fired
|
|
28700
|
+
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
28701
|
+
*
|
|
28702
|
+
* @category Invitation Events
|
|
28703
|
+
*/
|
|
28704
|
+
const onLocalInvitationCanceled = (callback) => {
|
|
28705
|
+
const client = getActiveClient();
|
|
28706
|
+
const disposers = [
|
|
28707
|
+
createEventSubscriber(client, 'onLocalInvitationCanceled', 'local.invitation.canceled', payload => callback(payload)),
|
|
28708
|
+
];
|
|
28709
|
+
return () => {
|
|
28710
|
+
disposers.forEach(fn => fn());
|
|
28711
|
+
};
|
|
28712
|
+
};
|
|
28713
|
+
|
|
28714
|
+
class InvitationsLiveCollectionController extends LiveCollectionController {
|
|
28715
|
+
constructor(query, callback) {
|
|
28716
|
+
const queryStreamId = hash(query);
|
|
28717
|
+
const cacheKey = ['invitation', 'collection', queryStreamId];
|
|
28718
|
+
const paginationController = new InvitationsPaginationController(query);
|
|
28719
|
+
super(paginationController, queryStreamId, cacheKey, callback);
|
|
28720
|
+
this.query = query;
|
|
28721
|
+
this.queryStreamController = new InvitationsQueryStreamController(this.query, this.cacheKey, this.notifyChange.bind(this), prepareInvitationPayload);
|
|
28722
|
+
this.callback = callback.bind(this);
|
|
28723
|
+
this.loadPage({ initial: true });
|
|
28724
|
+
}
|
|
28725
|
+
setup() {
|
|
28726
|
+
var _a;
|
|
28727
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
28728
|
+
if (!collection) {
|
|
28729
|
+
pushToCache(this.cacheKey, {
|
|
28730
|
+
data: [],
|
|
28731
|
+
params: this.query,
|
|
28732
|
+
});
|
|
28733
|
+
}
|
|
28734
|
+
}
|
|
28735
|
+
async persistModel(queryPayload) {
|
|
28736
|
+
await this.queryStreamController.saveToMainDB(queryPayload);
|
|
28737
|
+
}
|
|
28738
|
+
persistQueryStream({ response, direction, refresh, }) {
|
|
28739
|
+
this.queryStreamController.appendToQueryStream(response, direction, refresh);
|
|
28740
|
+
}
|
|
28741
|
+
startSubscription() {
|
|
28742
|
+
return this.queryStreamController.subscribeRTE([
|
|
28743
|
+
{
|
|
28744
|
+
fn: onLocalInvitationCreated,
|
|
28745
|
+
action: InvitationActionsEnum.OnLocalInvitationCreated,
|
|
28746
|
+
},
|
|
28747
|
+
{
|
|
28748
|
+
fn: onLocalInvitationUpdated,
|
|
28749
|
+
action: InvitationActionsEnum.OnLocalInvitationUpdated,
|
|
28750
|
+
},
|
|
28751
|
+
{
|
|
28752
|
+
fn: onLocalInvitationCanceled,
|
|
28753
|
+
action: InvitationActionsEnum.OnLocalInvitationCanceled,
|
|
28754
|
+
},
|
|
28755
|
+
]);
|
|
28756
|
+
}
|
|
28757
|
+
notifyChange({ origin, loading, error }) {
|
|
28758
|
+
var _a, _b;
|
|
28759
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
28760
|
+
if (!collection)
|
|
28761
|
+
return;
|
|
28762
|
+
const data = this.applyFilter((_b = collection.data
|
|
28763
|
+
.map(id => pullFromCache(['invitation', 'get', id]))
|
|
28764
|
+
.filter(isNonNullable)
|
|
28765
|
+
.map(({ data }) => invitationLinkedObject(data))) !== null && _b !== void 0 ? _b : []);
|
|
28766
|
+
if (!this.shouldNotify(data) && origin === 'event')
|
|
28767
|
+
return;
|
|
28768
|
+
this.callback({
|
|
28769
|
+
onNextPage: () => this.loadPage({ direction: "next" /* Amity.LiveCollectionPageDirection.NEXT */ }),
|
|
28770
|
+
data,
|
|
28771
|
+
hasNextPage: !!this.paginationController.getNextToken(),
|
|
28772
|
+
loading,
|
|
28773
|
+
error,
|
|
28774
|
+
});
|
|
28775
|
+
}
|
|
28776
|
+
applyFilter(data) {
|
|
28777
|
+
let invitations = data;
|
|
28778
|
+
if (this.query.targetId) {
|
|
28779
|
+
invitations = invitations.filter(invitation => invitation.targetId === this.query.targetId);
|
|
28780
|
+
}
|
|
28781
|
+
if (this.query.statuses) {
|
|
28782
|
+
invitations = invitations.filter(invitation => { var _a; return (_a = this.query.statuses) === null || _a === void 0 ? void 0 : _a.includes(invitation.status); });
|
|
28783
|
+
}
|
|
28784
|
+
if (this.query.targetType) {
|
|
28785
|
+
invitations = invitations.filter(invitation => invitation.targetType === this.query.targetType);
|
|
28786
|
+
}
|
|
28787
|
+
if (this.query.type) {
|
|
28788
|
+
invitations = invitations.filter(invitation => invitation.type === this.query.type);
|
|
28789
|
+
}
|
|
28790
|
+
const sortFn = (() => {
|
|
28791
|
+
switch (this.query.sortBy) {
|
|
28792
|
+
case 'firstCreated':
|
|
28793
|
+
return sortByFirstCreated;
|
|
28794
|
+
case 'lastCreated':
|
|
28795
|
+
return sortByLastCreated;
|
|
28796
|
+
default:
|
|
28797
|
+
return sortByLastCreated;
|
|
28798
|
+
}
|
|
28799
|
+
})();
|
|
28800
|
+
invitations = invitations.sort(sortFn);
|
|
28801
|
+
return invitations;
|
|
28802
|
+
}
|
|
28803
|
+
}
|
|
28804
|
+
|
|
28805
|
+
/**
|
|
28806
|
+
* Get invitations
|
|
28807
|
+
*
|
|
28808
|
+
* @param params the query parameters
|
|
28809
|
+
* @param callback the callback to be called when the invitations are updated
|
|
28810
|
+
* @returns invitations
|
|
28811
|
+
*
|
|
28812
|
+
* @category Invitation Live Collection
|
|
28813
|
+
*
|
|
28814
|
+
*/
|
|
28815
|
+
const getInvitations$1 = (params, callback, config) => {
|
|
28816
|
+
const { log, cache } = getActiveClient();
|
|
28817
|
+
if (!cache) {
|
|
28818
|
+
console.log(ENABLE_CACHE_MESSAGE);
|
|
28819
|
+
}
|
|
28820
|
+
const timestamp = Date.now();
|
|
28821
|
+
log(`getInvitations: (tmpid: ${timestamp}) > listen`);
|
|
28822
|
+
const invitationsLiveCollection = new InvitationsLiveCollectionController(params, callback);
|
|
28823
|
+
const disposers = invitationsLiveCollection.startSubscription();
|
|
28824
|
+
const cacheKey = invitationsLiveCollection.getCacheKey();
|
|
28825
|
+
disposers.push(() => {
|
|
28826
|
+
dropFromCache(cacheKey);
|
|
28827
|
+
});
|
|
28828
|
+
return () => {
|
|
28829
|
+
log(`getInvitations (tmpid: ${timestamp}) > dispose`);
|
|
28830
|
+
disposers.forEach(fn => fn());
|
|
28831
|
+
};
|
|
28832
|
+
};
|
|
28833
|
+
|
|
28834
|
+
const prepareMyInvitationsPayload = (rawPayload) => {
|
|
28835
|
+
return Object.assign(Object.assign({}, rawPayload), { users: rawPayload.users.map(convertRawUserToInternalUser), invitations: rawPayload.invitations.map(convertRawInvitationToInternalInvitation) });
|
|
28836
|
+
};
|
|
28837
|
+
|
|
28838
|
+
/* begin_public_function
|
|
28839
|
+
id: invitation.get
|
|
28840
|
+
*/
|
|
28841
|
+
/**
|
|
28842
|
+
* ```js
|
|
28843
|
+
* import { getInvitation } from '@amityco/ts-sdk'
|
|
28844
|
+
* const { invitation } = await getInvitation(targetType, targetId)
|
|
28845
|
+
* ```
|
|
28846
|
+
*
|
|
28847
|
+
* Get a {@link Amity.Invitation} object
|
|
28848
|
+
*
|
|
28849
|
+
* @param targetType The type of the target of the {@link Amity.Invitation}
|
|
28850
|
+
* @param targetId The ID of the target of the {@link Amity.Invitation}
|
|
28851
|
+
* @returns A {@link Amity.Invitation} object
|
|
28852
|
+
*
|
|
28853
|
+
* @category Invitation API
|
|
28854
|
+
* @async
|
|
28855
|
+
*/
|
|
28856
|
+
const getInvitation = async (params) => {
|
|
28857
|
+
const client = getActiveClient();
|
|
28858
|
+
client.log('invitation/getInvitation', params.targetType, params.targetId, params.type);
|
|
28859
|
+
const { data: payload } = await client.http.get(`/api/v1/invitations/me`, { params });
|
|
28860
|
+
const data = prepareMyInvitationsPayload(payload);
|
|
28861
|
+
const cachedAt = client.cache && Date.now();
|
|
28862
|
+
if (client.cache)
|
|
28863
|
+
ingestInCache(data, { cachedAt });
|
|
28864
|
+
return {
|
|
28865
|
+
data: data.invitations[0] ? invitationLinkedObject(data.invitations[0]) : undefined,
|
|
28866
|
+
cachedAt,
|
|
28867
|
+
};
|
|
28868
|
+
};
|
|
28869
|
+
/* end_public_function */
|
|
28870
|
+
|
|
28360
28871
|
const roomLinkedObject = (room) => {
|
|
28361
28872
|
return Object.assign(Object.assign({}, room), { get moderation() {
|
|
28362
28873
|
var _a;
|
|
@@ -28376,7 +28887,8 @@ const roomLinkedObject = (room) => {
|
|
|
28376
28887
|
},
|
|
28377
28888
|
get user() {
|
|
28378
28889
|
var _a;
|
|
28379
|
-
|
|
28890
|
+
const user = (_a = pullFromCache(['user', 'get', room.createdBy])) === null || _a === void 0 ? void 0 : _a.data;
|
|
28891
|
+
return user ? userLinkedObject(user) : user;
|
|
28380
28892
|
},
|
|
28381
28893
|
get childRooms() {
|
|
28382
28894
|
if (!room.childRoomIds || room.childRoomIds.length === 0)
|
|
@@ -28390,7 +28902,23 @@ const roomLinkedObject = (room) => {
|
|
|
28390
28902
|
return roomLinkedObject(roomCache);
|
|
28391
28903
|
})
|
|
28392
28904
|
.filter(isNonNullable);
|
|
28393
|
-
},
|
|
28905
|
+
}, participants: room.participants.map(participant => (Object.assign(Object.assign({}, participant), { get user() {
|
|
28906
|
+
var _a;
|
|
28907
|
+
const user = (_a = pullFromCache(['user', 'get', participant.userId])) === null || _a === void 0 ? void 0 : _a.data;
|
|
28908
|
+
return user ? userLinkedObject(user) : user;
|
|
28909
|
+
} }))), getLiveChat: () => getLiveChat(room), createInvitation: (userId) => createInvitations({
|
|
28910
|
+
type: "livestreamCohostInvite" /* InvitationTypeEnum.LivestreamCohostInvite */,
|
|
28911
|
+
targetType: 'room',
|
|
28912
|
+
targetId: room.roomId,
|
|
28913
|
+
userIds: [userId],
|
|
28914
|
+
}), getInvitations: (params, callback) => getInvitations$1(Object.assign(Object.assign({}, params), { targetId: room.roomId, targetType: 'room', type: "livestreamCohostInvite" /* InvitationTypeEnum.LivestreamCohostInvite */ }), callback), getMyInvitation: async () => {
|
|
28915
|
+
const { data } = await getInvitation({
|
|
28916
|
+
targetId: room.roomId,
|
|
28917
|
+
targetType: 'room',
|
|
28918
|
+
type: "livestreamCohostInvite" /* InvitationTypeEnum.LivestreamCohostInvite */,
|
|
28919
|
+
});
|
|
28920
|
+
return data;
|
|
28921
|
+
} });
|
|
28394
28922
|
};
|
|
28395
28923
|
|
|
28396
28924
|
const postLinkedObject = (post) => {
|
|
@@ -29363,462 +29891,6 @@ const getJoinRequests = (params, callback, config) => {
|
|
|
29363
29891
|
};
|
|
29364
29892
|
};
|
|
29365
29893
|
|
|
29366
|
-
const convertRawInvitationToInternalInvitation = (rawInvitation) => {
|
|
29367
|
-
return Object.assign(Object.assign({}, rawInvitation), { createdById: rawInvitation.createdBy });
|
|
29368
|
-
};
|
|
29369
|
-
|
|
29370
|
-
const prepareInvitationPayload = (rawPayload) => {
|
|
29371
|
-
return Object.assign(Object.assign({}, rawPayload), { invitations: rawPayload.invitations.map(convertRawInvitationToInternalInvitation), users: rawPayload.users.map(convertRawUserToInternalUser) });
|
|
29372
|
-
};
|
|
29373
|
-
|
|
29374
|
-
/* begin_public_function
|
|
29375
|
-
id: invitation.createInvitations
|
|
29376
|
-
*/
|
|
29377
|
-
/**
|
|
29378
|
-
* ```js
|
|
29379
|
-
* import { createInvitations } from '@amityco/ts-sdk'
|
|
29380
|
-
* const created = await createInvitations({
|
|
29381
|
-
* type: string,
|
|
29382
|
-
* targetType: string,
|
|
29383
|
-
* targetId: string,
|
|
29384
|
-
* userIds: string[]
|
|
29385
|
-
* }))
|
|
29386
|
-
* ```
|
|
29387
|
-
*
|
|
29388
|
-
* Creates an {@link Amity.Invitation}
|
|
29389
|
-
*
|
|
29390
|
-
* @param bundle The data necessary to create a new {@link Amity.Invitation}
|
|
29391
|
-
* @returns The newly created {@link Amity.Invitation}
|
|
29392
|
-
*
|
|
29393
|
-
* @category Invitation API
|
|
29394
|
-
* @async
|
|
29395
|
-
*/
|
|
29396
|
-
const createInvitations = async (bundle) => {
|
|
29397
|
-
const client = getActiveClient();
|
|
29398
|
-
client.log('invitation/createInvitations', bundle);
|
|
29399
|
-
const { data: payload } = await client.http.post('/api/v1/invitations', bundle);
|
|
29400
|
-
const data = prepareInvitationPayload(payload);
|
|
29401
|
-
const cachedAt = client.cache && Date.now();
|
|
29402
|
-
if (client.cache)
|
|
29403
|
-
ingestInCache(data, { cachedAt });
|
|
29404
|
-
fireEvent('local.invitation.created', data.invitations);
|
|
29405
|
-
return {
|
|
29406
|
-
data: data.invitations,
|
|
29407
|
-
cachedAt,
|
|
29408
|
-
};
|
|
29409
|
-
};
|
|
29410
|
-
/* end_public_function */
|
|
29411
|
-
|
|
29412
|
-
/* begin_public_function
|
|
29413
|
-
id: invitation.accept
|
|
29414
|
-
*/
|
|
29415
|
-
/**
|
|
29416
|
-
* ```js
|
|
29417
|
-
* import { acceptInvitation } from '@amityco/ts-sdk'
|
|
29418
|
-
* const isAccepted = await acceptInvitation(invitationId)
|
|
29419
|
-
* ```
|
|
29420
|
-
*
|
|
29421
|
-
* Accepts a {@link Amity.Invitation} object
|
|
29422
|
-
*
|
|
29423
|
-
* @param invitationId the {@link Amity.Invitation} to accept
|
|
29424
|
-
* @returns A success boolean if the {@link Amity.Invitation} was accepted
|
|
29425
|
-
*
|
|
29426
|
-
* @category Invitation API
|
|
29427
|
-
* @async
|
|
29428
|
-
*/
|
|
29429
|
-
const acceptInvitation = async (invitationId) => {
|
|
29430
|
-
var _a;
|
|
29431
|
-
const client = getActiveClient();
|
|
29432
|
-
client.log('invitation/acceptInvitation', invitationId);
|
|
29433
|
-
const { data } = await client.http.post(`/api/v1/invitations/${invitationId}/accept`);
|
|
29434
|
-
const invitation = (_a = pullFromCache([
|
|
29435
|
-
'invitation',
|
|
29436
|
-
'get',
|
|
29437
|
-
invitationId,
|
|
29438
|
-
])) === null || _a === void 0 ? void 0 : _a.data;
|
|
29439
|
-
if (invitation) {
|
|
29440
|
-
upsertInCache(['invitation', 'get', invitationId], { status: "approved" /* InvitationStatusEnum.Approved */ });
|
|
29441
|
-
fireEvent('local.invitation.updated', [invitation]);
|
|
29442
|
-
}
|
|
29443
|
-
return data.success;
|
|
29444
|
-
};
|
|
29445
|
-
/* end_public_function */
|
|
29446
|
-
|
|
29447
|
-
/* begin_public_function
|
|
29448
|
-
id: invitation.reject
|
|
29449
|
-
*/
|
|
29450
|
-
/**
|
|
29451
|
-
* ```js
|
|
29452
|
-
* import { rejectInvitation } from '@amityco/ts-sdk'
|
|
29453
|
-
* const isRejected = await rejectInvitation(invitationId)
|
|
29454
|
-
* ```
|
|
29455
|
-
*
|
|
29456
|
-
* Rejects a {@link Amity.Invitation} object
|
|
29457
|
-
*
|
|
29458
|
-
* @param invitationId the {@link Amity.Invitation} to reject
|
|
29459
|
-
* @returns A success boolean if the {@link Amity.Invitation} was rejected
|
|
29460
|
-
*
|
|
29461
|
-
* @category Invitation API
|
|
29462
|
-
* @async
|
|
29463
|
-
*/
|
|
29464
|
-
const rejectInvitation = async (invitationId) => {
|
|
29465
|
-
var _a;
|
|
29466
|
-
const client = getActiveClient();
|
|
29467
|
-
client.log('invitation/rejectInvitation', invitationId);
|
|
29468
|
-
const { data } = await client.http.post(`/api/v1/invitations/${invitationId}/reject`);
|
|
29469
|
-
const invitation = (_a = pullFromCache([
|
|
29470
|
-
'invitation',
|
|
29471
|
-
'get',
|
|
29472
|
-
invitationId,
|
|
29473
|
-
])) === null || _a === void 0 ? void 0 : _a.data;
|
|
29474
|
-
if (invitation) {
|
|
29475
|
-
upsertInCache(['invitation', 'get', invitationId], { status: "rejected" /* InvitationStatusEnum.Rejected */ });
|
|
29476
|
-
fireEvent('local.invitation.updated', [invitation]);
|
|
29477
|
-
}
|
|
29478
|
-
return data.success;
|
|
29479
|
-
};
|
|
29480
|
-
/* end_public_function */
|
|
29481
|
-
|
|
29482
|
-
const prepareMyInvitationsPayload = (rawPayload) => {
|
|
29483
|
-
return Object.assign(Object.assign({}, rawPayload), { users: rawPayload.users.map(convertRawUserToInternalUser), invitations: rawPayload.invitations.map(convertRawInvitationToInternalInvitation) });
|
|
29484
|
-
};
|
|
29485
|
-
|
|
29486
|
-
const invitationLinkedObject = (invitation) => {
|
|
29487
|
-
return Object.assign(Object.assign({}, invitation), { get user() {
|
|
29488
|
-
const cacheData = pullFromCache(['user', 'get', invitation.invitedUserPublicId]);
|
|
29489
|
-
if (cacheData === null || cacheData === void 0 ? void 0 : cacheData.data)
|
|
29490
|
-
return userLinkedObject(cacheData.data);
|
|
29491
|
-
return undefined;
|
|
29492
|
-
},
|
|
29493
|
-
get createdBy() {
|
|
29494
|
-
const cacheData = pullFromCache(['user', 'get', invitation.inviterUserPublicId]);
|
|
29495
|
-
if (cacheData === null || cacheData === void 0 ? void 0 : cacheData.data)
|
|
29496
|
-
return userLinkedObject(cacheData.data);
|
|
29497
|
-
return undefined;
|
|
29498
|
-
},
|
|
29499
|
-
get target() {
|
|
29500
|
-
if (invitation.targetType === 'community') {
|
|
29501
|
-
const cacheData = pullFromCache([
|
|
29502
|
-
'community',
|
|
29503
|
-
'get',
|
|
29504
|
-
invitation.targetId,
|
|
29505
|
-
]);
|
|
29506
|
-
if (cacheData === null || cacheData === void 0 ? void 0 : cacheData.data)
|
|
29507
|
-
return cacheData.data;
|
|
29508
|
-
return undefined;
|
|
29509
|
-
}
|
|
29510
|
-
return undefined;
|
|
29511
|
-
}, accept: async () => {
|
|
29512
|
-
await acceptInvitation(invitation._id);
|
|
29513
|
-
}, reject: async () => {
|
|
29514
|
-
await rejectInvitation(invitation._id);
|
|
29515
|
-
} });
|
|
29516
|
-
};
|
|
29517
|
-
|
|
29518
|
-
/* begin_public_function
|
|
29519
|
-
id: invitation.get
|
|
29520
|
-
*/
|
|
29521
|
-
/**
|
|
29522
|
-
* ```js
|
|
29523
|
-
* import { getInvitation } from '@amityco/ts-sdk'
|
|
29524
|
-
* const { invitation } = await getInvitation(targetType, targetId)
|
|
29525
|
-
* ```
|
|
29526
|
-
*
|
|
29527
|
-
* Get a {@link Amity.Invitation} object
|
|
29528
|
-
*
|
|
29529
|
-
* @param targetType The type of the target of the {@link Amity.Invitation}
|
|
29530
|
-
* @param targetId The ID of the target of the {@link Amity.Invitation}
|
|
29531
|
-
* @returns A {@link Amity.Invitation} object
|
|
29532
|
-
*
|
|
29533
|
-
* @category Invitation API
|
|
29534
|
-
* @async
|
|
29535
|
-
*/
|
|
29536
|
-
const getInvitation = async (targetType, targetId) => {
|
|
29537
|
-
const client = getActiveClient();
|
|
29538
|
-
client.log('invitation/getInvitation', targetType, targetId);
|
|
29539
|
-
const { data: payload } = await client.http.get(`/api/v1/invitations/me`, { params: { targetType, targetId } });
|
|
29540
|
-
const data = prepareMyInvitationsPayload(payload);
|
|
29541
|
-
const cachedAt = client.cache && Date.now();
|
|
29542
|
-
if (client.cache)
|
|
29543
|
-
ingestInCache(data, { cachedAt });
|
|
29544
|
-
return {
|
|
29545
|
-
data: data.invitations[0] ? invitationLinkedObject(data.invitations[0]) : undefined,
|
|
29546
|
-
cachedAt,
|
|
29547
|
-
};
|
|
29548
|
-
};
|
|
29549
|
-
/* end_public_function */
|
|
29550
|
-
|
|
29551
|
-
var InvitationActionsEnum;
|
|
29552
|
-
(function (InvitationActionsEnum) {
|
|
29553
|
-
InvitationActionsEnum["OnLocalInvitationCreated"] = "onLocalInvitationCreated";
|
|
29554
|
-
InvitationActionsEnum["OnLocalInvitationUpdated"] = "onLocalInvitationUpdated";
|
|
29555
|
-
InvitationActionsEnum["OnLocalInvitationDeleted"] = "onLocalInvitationDeleted";
|
|
29556
|
-
})(InvitationActionsEnum || (InvitationActionsEnum = {}));
|
|
29557
|
-
|
|
29558
|
-
class InvitationsPaginationController extends PaginationController {
|
|
29559
|
-
async getRequest(queryParams, token) {
|
|
29560
|
-
const { limit = COLLECTION_DEFAULT_PAGINATION_LIMIT } = queryParams, params = __rest(queryParams, ["limit"]);
|
|
29561
|
-
const options = token ? { token } : { limit };
|
|
29562
|
-
const { data } = await this.http.get('/api/v1/invitations', { params: Object.assign(Object.assign({}, params), { options }) });
|
|
29563
|
-
return data;
|
|
29564
|
-
}
|
|
29565
|
-
}
|
|
29566
|
-
|
|
29567
|
-
class InvitationsQueryStreamController extends QueryStreamController {
|
|
29568
|
-
constructor(query, cacheKey, notifyChange, preparePayload) {
|
|
29569
|
-
super(query, cacheKey);
|
|
29570
|
-
this.notifyChange = notifyChange;
|
|
29571
|
-
this.preparePayload = preparePayload;
|
|
29572
|
-
}
|
|
29573
|
-
async saveToMainDB(response) {
|
|
29574
|
-
const processedPayload = await this.preparePayload(response);
|
|
29575
|
-
const client = getActiveClient();
|
|
29576
|
-
const cachedAt = client.cache && Date.now();
|
|
29577
|
-
if (client.cache) {
|
|
29578
|
-
ingestInCache(processedPayload, { cachedAt });
|
|
29579
|
-
}
|
|
29580
|
-
}
|
|
29581
|
-
appendToQueryStream(response, direction, refresh = false) {
|
|
29582
|
-
var _a, _b;
|
|
29583
|
-
if (refresh) {
|
|
29584
|
-
pushToCache(this.cacheKey, {
|
|
29585
|
-
data: response.invitations.map(getResolver('invitation')),
|
|
29586
|
-
});
|
|
29587
|
-
}
|
|
29588
|
-
else {
|
|
29589
|
-
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
29590
|
-
const invitations = (_b = collection === null || collection === void 0 ? void 0 : collection.data) !== null && _b !== void 0 ? _b : [];
|
|
29591
|
-
pushToCache(this.cacheKey, Object.assign(Object.assign({}, collection), { data: [
|
|
29592
|
-
...new Set([...invitations, ...response.invitations.map(getResolver('invitation'))]),
|
|
29593
|
-
] }));
|
|
29594
|
-
}
|
|
29595
|
-
}
|
|
29596
|
-
reactor(action) {
|
|
29597
|
-
return (invitations) => {
|
|
29598
|
-
var _a;
|
|
29599
|
-
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
29600
|
-
if (!collection)
|
|
29601
|
-
return;
|
|
29602
|
-
if (action === InvitationActionsEnum.OnLocalInvitationUpdated) {
|
|
29603
|
-
const isExist = collection.data.find(id => id === invitations[0].invitationId);
|
|
29604
|
-
if (!isExist)
|
|
29605
|
-
return;
|
|
29606
|
-
}
|
|
29607
|
-
if (action === InvitationActionsEnum.OnLocalInvitationCreated) {
|
|
29608
|
-
collection.data = [
|
|
29609
|
-
...new Set([
|
|
29610
|
-
...invitations.map(invitation => invitation.invitationId),
|
|
29611
|
-
...collection.data,
|
|
29612
|
-
]),
|
|
29613
|
-
];
|
|
29614
|
-
}
|
|
29615
|
-
if (action === InvitationActionsEnum.OnLocalInvitationDeleted) {
|
|
29616
|
-
collection.data = collection.data.filter(id => id !== invitations[0].invitationId);
|
|
29617
|
-
}
|
|
29618
|
-
pushToCache(this.cacheKey, collection);
|
|
29619
|
-
this.notifyChange({ origin: "event" /* Amity.LiveDataOrigin.EVENT */, loading: false });
|
|
29620
|
-
};
|
|
29621
|
-
}
|
|
29622
|
-
subscribeRTE(createSubscriber) {
|
|
29623
|
-
return createSubscriber.map(subscriber => subscriber.fn(this.reactor(subscriber.action)));
|
|
29624
|
-
}
|
|
29625
|
-
}
|
|
29626
|
-
|
|
29627
|
-
/**
|
|
29628
|
-
* ```js
|
|
29629
|
-
* import { onLocalInvitationCreated } from '@amityco/ts-sdk'
|
|
29630
|
-
* const dispose = onLocalInvitationCreated(data => {
|
|
29631
|
-
* // ...
|
|
29632
|
-
* })
|
|
29633
|
-
* ```
|
|
29634
|
-
*
|
|
29635
|
-
* Fired when an {@link Amity.InvitationPayload} has been created
|
|
29636
|
-
*
|
|
29637
|
-
* @param callback The function to call when the event was fired
|
|
29638
|
-
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
29639
|
-
*
|
|
29640
|
-
* @category Invitation Events
|
|
29641
|
-
*/
|
|
29642
|
-
const onLocalInvitationCreated = (callback) => {
|
|
29643
|
-
const client = getActiveClient();
|
|
29644
|
-
const disposers = [
|
|
29645
|
-
createEventSubscriber(client, 'onLocalInvitationCreated', 'local.invitation.created', payload => callback(payload)),
|
|
29646
|
-
];
|
|
29647
|
-
return () => {
|
|
29648
|
-
disposers.forEach(fn => fn());
|
|
29649
|
-
};
|
|
29650
|
-
};
|
|
29651
|
-
|
|
29652
|
-
/**
|
|
29653
|
-
* ```js
|
|
29654
|
-
* import { onLocalInvitationUpdated } from '@amityco/ts-sdk'
|
|
29655
|
-
* const dispose = onLocalInvitationUpdated(data => {
|
|
29656
|
-
* // ...
|
|
29657
|
-
* })
|
|
29658
|
-
* ```
|
|
29659
|
-
*
|
|
29660
|
-
* Fired when an {@link Amity.InvitationPayload} has been updated
|
|
29661
|
-
*
|
|
29662
|
-
* @param callback The function to call when the event was fired
|
|
29663
|
-
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
29664
|
-
*
|
|
29665
|
-
* @category Invitation Events
|
|
29666
|
-
*/
|
|
29667
|
-
const onLocalInvitationUpdated = (callback) => {
|
|
29668
|
-
const client = getActiveClient();
|
|
29669
|
-
const disposers = [
|
|
29670
|
-
createEventSubscriber(client, 'onLocalInvitationUpdated', 'local.invitation.updated', payload => callback(payload)),
|
|
29671
|
-
];
|
|
29672
|
-
return () => {
|
|
29673
|
-
disposers.forEach(fn => fn());
|
|
29674
|
-
};
|
|
29675
|
-
};
|
|
29676
|
-
|
|
29677
|
-
/**
|
|
29678
|
-
* ```js
|
|
29679
|
-
* import { onLocalInvitationDeleted } from '@amityco/ts-sdk'
|
|
29680
|
-
* const dispose = onLocalInvitationDeleted(data => {
|
|
29681
|
-
* // ...
|
|
29682
|
-
* })
|
|
29683
|
-
* ```
|
|
29684
|
-
*
|
|
29685
|
-
* Fired when an {@link Amity.InvitationPayload} has been deleted
|
|
29686
|
-
*
|
|
29687
|
-
* @param callback The function to call when the event was fired
|
|
29688
|
-
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
29689
|
-
*
|
|
29690
|
-
* @category Invitation Events
|
|
29691
|
-
*/
|
|
29692
|
-
const onLocalInvitationDeleted = (callback) => {
|
|
29693
|
-
const client = getActiveClient();
|
|
29694
|
-
const disposers = [
|
|
29695
|
-
createEventSubscriber(client, 'onLocalInvitationDeleted', 'local.invitation.deleted', payload => callback(payload)),
|
|
29696
|
-
];
|
|
29697
|
-
return () => {
|
|
29698
|
-
disposers.forEach(fn => fn());
|
|
29699
|
-
};
|
|
29700
|
-
};
|
|
29701
|
-
|
|
29702
|
-
class InvitationsLiveCollectionController extends LiveCollectionController {
|
|
29703
|
-
constructor(query, callback) {
|
|
29704
|
-
const queryStreamId = hash(query);
|
|
29705
|
-
const cacheKey = ['invitation', 'collection', queryStreamId];
|
|
29706
|
-
const paginationController = new InvitationsPaginationController(query);
|
|
29707
|
-
super(paginationController, queryStreamId, cacheKey, callback);
|
|
29708
|
-
this.query = query;
|
|
29709
|
-
this.queryStreamController = new InvitationsQueryStreamController(this.query, this.cacheKey, this.notifyChange.bind(this), prepareInvitationPayload);
|
|
29710
|
-
this.callback = callback.bind(this);
|
|
29711
|
-
this.loadPage({ initial: true });
|
|
29712
|
-
}
|
|
29713
|
-
setup() {
|
|
29714
|
-
var _a;
|
|
29715
|
-
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
29716
|
-
if (!collection) {
|
|
29717
|
-
pushToCache(this.cacheKey, {
|
|
29718
|
-
data: [],
|
|
29719
|
-
params: this.query,
|
|
29720
|
-
});
|
|
29721
|
-
}
|
|
29722
|
-
}
|
|
29723
|
-
async persistModel(queryPayload) {
|
|
29724
|
-
await this.queryStreamController.saveToMainDB(queryPayload);
|
|
29725
|
-
}
|
|
29726
|
-
persistQueryStream({ response, direction, refresh, }) {
|
|
29727
|
-
this.queryStreamController.appendToQueryStream(response, direction, refresh);
|
|
29728
|
-
}
|
|
29729
|
-
startSubscription() {
|
|
29730
|
-
return this.queryStreamController.subscribeRTE([
|
|
29731
|
-
{
|
|
29732
|
-
fn: onLocalInvitationCreated,
|
|
29733
|
-
action: InvitationActionsEnum.OnLocalInvitationCreated,
|
|
29734
|
-
},
|
|
29735
|
-
{
|
|
29736
|
-
fn: onLocalInvitationUpdated,
|
|
29737
|
-
action: InvitationActionsEnum.OnLocalInvitationUpdated,
|
|
29738
|
-
},
|
|
29739
|
-
{
|
|
29740
|
-
fn: onLocalInvitationDeleted,
|
|
29741
|
-
action: InvitationActionsEnum.OnLocalInvitationDeleted,
|
|
29742
|
-
},
|
|
29743
|
-
]);
|
|
29744
|
-
}
|
|
29745
|
-
notifyChange({ origin, loading, error }) {
|
|
29746
|
-
var _a, _b;
|
|
29747
|
-
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
29748
|
-
if (!collection)
|
|
29749
|
-
return;
|
|
29750
|
-
const data = this.applyFilter((_b = collection.data
|
|
29751
|
-
.map(id => pullFromCache(['invitation', 'get', id]))
|
|
29752
|
-
.filter(isNonNullable)
|
|
29753
|
-
.map(({ data }) => invitationLinkedObject(data))) !== null && _b !== void 0 ? _b : []);
|
|
29754
|
-
if (!this.shouldNotify(data) && origin === 'event')
|
|
29755
|
-
return;
|
|
29756
|
-
this.callback({
|
|
29757
|
-
onNextPage: () => this.loadPage({ direction: "next" /* Amity.LiveCollectionPageDirection.NEXT */ }),
|
|
29758
|
-
data,
|
|
29759
|
-
hasNextPage: !!this.paginationController.getNextToken(),
|
|
29760
|
-
loading,
|
|
29761
|
-
error,
|
|
29762
|
-
});
|
|
29763
|
-
}
|
|
29764
|
-
applyFilter(data) {
|
|
29765
|
-
let invitations = data;
|
|
29766
|
-
if (this.query.targetId) {
|
|
29767
|
-
invitations = invitations.filter(invitation => invitation.targetId === this.query.targetId);
|
|
29768
|
-
}
|
|
29769
|
-
if (this.query.statuses) {
|
|
29770
|
-
invitations = invitations.filter(invitation => { var _a; return (_a = this.query.statuses) === null || _a === void 0 ? void 0 : _a.includes(invitation.status); });
|
|
29771
|
-
}
|
|
29772
|
-
if (this.query.targetType) {
|
|
29773
|
-
invitations = invitations.filter(invitation => invitation.targetType === this.query.targetType);
|
|
29774
|
-
}
|
|
29775
|
-
if (this.query.type) {
|
|
29776
|
-
invitations = invitations.filter(invitation => invitation.type === this.query.type);
|
|
29777
|
-
}
|
|
29778
|
-
const sortFn = (() => {
|
|
29779
|
-
switch (this.query.sortBy) {
|
|
29780
|
-
case 'firstCreated':
|
|
29781
|
-
return sortByFirstCreated;
|
|
29782
|
-
case 'lastCreated':
|
|
29783
|
-
return sortByLastCreated;
|
|
29784
|
-
default:
|
|
29785
|
-
return sortByLastCreated;
|
|
29786
|
-
}
|
|
29787
|
-
})();
|
|
29788
|
-
invitations = invitations.sort(sortFn);
|
|
29789
|
-
return invitations;
|
|
29790
|
-
}
|
|
29791
|
-
}
|
|
29792
|
-
|
|
29793
|
-
/**
|
|
29794
|
-
* Get invitations
|
|
29795
|
-
*
|
|
29796
|
-
* @param params the query parameters
|
|
29797
|
-
* @param callback the callback to be called when the invitations are updated
|
|
29798
|
-
* @returns invitations
|
|
29799
|
-
*
|
|
29800
|
-
* @category Invitation Live Collection
|
|
29801
|
-
*
|
|
29802
|
-
*/
|
|
29803
|
-
const getInvitations = (params, callback, config) => {
|
|
29804
|
-
const { log, cache } = getActiveClient();
|
|
29805
|
-
if (!cache) {
|
|
29806
|
-
console.log(ENABLE_CACHE_MESSAGE);
|
|
29807
|
-
}
|
|
29808
|
-
const timestamp = Date.now();
|
|
29809
|
-
log(`getInvitations: (tmpid: ${timestamp}) > listen`);
|
|
29810
|
-
const invitationsLiveCollection = new InvitationsLiveCollectionController(params, callback);
|
|
29811
|
-
const disposers = invitationsLiveCollection.startSubscription();
|
|
29812
|
-
const cacheKey = invitationsLiveCollection.getCacheKey();
|
|
29813
|
-
disposers.push(() => {
|
|
29814
|
-
dropFromCache(cacheKey);
|
|
29815
|
-
});
|
|
29816
|
-
return () => {
|
|
29817
|
-
log(`getInvitations (tmpid: ${timestamp}) > dispose`);
|
|
29818
|
-
disposers.forEach(fn => fn());
|
|
29819
|
-
};
|
|
29820
|
-
};
|
|
29821
|
-
|
|
29822
29894
|
const communityLinkedObject = (community) => {
|
|
29823
29895
|
return Object.assign(Object.assign({}, community), { get categories() {
|
|
29824
29896
|
var _a;
|
|
@@ -29838,9 +29910,12 @@ const communityLinkedObject = (community) => {
|
|
|
29838
29910
|
userIds,
|
|
29839
29911
|
});
|
|
29840
29912
|
}, getMemberInvitations: (params, callback) => {
|
|
29841
|
-
return getInvitations(Object.assign(Object.assign({}, params), { targetId: community.communityId, targetType: 'community', type: "communityMemberInvite" /* InvitationTypeEnum.CommunityMemberInvite */ }), callback);
|
|
29913
|
+
return getInvitations$1(Object.assign(Object.assign({}, params), { targetId: community.communityId, targetType: 'community', type: "communityMemberInvite" /* InvitationTypeEnum.CommunityMemberInvite */ }), callback);
|
|
29842
29914
|
}, getInvitation: async () => {
|
|
29843
|
-
const { data } = await getInvitation(
|
|
29915
|
+
const { data } = await getInvitation({
|
|
29916
|
+
targetType: 'community',
|
|
29917
|
+
targetId: community.communityId,
|
|
29918
|
+
});
|
|
29844
29919
|
return data;
|
|
29845
29920
|
}, join: async () => joinRequest(community.communityId), getJoinRequests: (params, callback) => {
|
|
29846
29921
|
return getJoinRequests(Object.assign(Object.assign({}, params), { communityId: community.communityId }), callback);
|
|
@@ -29850,6 +29925,48 @@ const communityLinkedObject = (community) => {
|
|
|
29850
29925
|
} });
|
|
29851
29926
|
};
|
|
29852
29927
|
|
|
29928
|
+
const eventLinkedObject = (event) => {
|
|
29929
|
+
return Object.assign(Object.assign({}, event), { get creator() {
|
|
29930
|
+
const cacheData = pullFromCache(['user', 'get', event.userId]);
|
|
29931
|
+
if (!(cacheData === null || cacheData === void 0 ? void 0 : cacheData.data))
|
|
29932
|
+
return;
|
|
29933
|
+
return userLinkedObject(cacheData.data);
|
|
29934
|
+
},
|
|
29935
|
+
get targetCommunity() {
|
|
29936
|
+
if (!event.originId)
|
|
29937
|
+
return;
|
|
29938
|
+
const cacheData = pullFromCache(['community', 'get', event.originId]);
|
|
29939
|
+
if (!(cacheData === null || cacheData === void 0 ? void 0 : cacheData.data))
|
|
29940
|
+
return;
|
|
29941
|
+
return communityLinkedObject(cacheData.data);
|
|
29942
|
+
},
|
|
29943
|
+
get coverImage() {
|
|
29944
|
+
if (!event.coverImageFileId)
|
|
29945
|
+
return;
|
|
29946
|
+
const cacheData = pullFromCache(['file', 'get', event.coverImageFileId]);
|
|
29947
|
+
if (!(cacheData === null || cacheData === void 0 ? void 0 : cacheData.data))
|
|
29948
|
+
return;
|
|
29949
|
+
return cacheData.data;
|
|
29950
|
+
},
|
|
29951
|
+
get post() {
|
|
29952
|
+
if (!event.postId)
|
|
29953
|
+
return;
|
|
29954
|
+
const cacheData = pullFromCache(['post', 'get', event.postId]);
|
|
29955
|
+
if (!(cacheData === null || cacheData === void 0 ? void 0 : cacheData.data))
|
|
29956
|
+
return;
|
|
29957
|
+
return postLinkedObject(cacheData.data);
|
|
29958
|
+
},
|
|
29959
|
+
get room() {
|
|
29960
|
+
var _a;
|
|
29961
|
+
if (!event.postId)
|
|
29962
|
+
return;
|
|
29963
|
+
const cacheData = (_a = queryCache(['room', 'get'])) === null || _a === void 0 ? void 0 : _a.filter(room => room.data.referenceId === event.postId);
|
|
29964
|
+
if (!(cacheData === null || cacheData === void 0 ? void 0 : cacheData.length) || !cacheData[0].data)
|
|
29965
|
+
return;
|
|
29966
|
+
return roomLinkedObject(cacheData[0].data);
|
|
29967
|
+
} });
|
|
29968
|
+
};
|
|
29969
|
+
|
|
29853
29970
|
const LinkedObject = {
|
|
29854
29971
|
ad: adLinkedObject,
|
|
29855
29972
|
comment: commentLinkedObject,
|
|
@@ -29868,6 +29985,8 @@ const LinkedObject = {
|
|
|
29868
29985
|
invitation: invitationLinkedObject,
|
|
29869
29986
|
joinRequest: joinRequestLinkedObject,
|
|
29870
29987
|
channelMember: channelMemberLinkedObject,
|
|
29988
|
+
room: roomLinkedObject,
|
|
29989
|
+
event: eventLinkedObject,
|
|
29871
29990
|
};
|
|
29872
29991
|
|
|
29873
29992
|
/* begin_public_function
|
|
@@ -30858,9 +30977,9 @@ var AmityUserSearchMatchType;
|
|
|
30858
30977
|
AmityUserSearchMatchType["PARTIAL"] = "partial";
|
|
30859
30978
|
})(AmityUserSearchMatchType || (AmityUserSearchMatchType = {}));
|
|
30860
30979
|
|
|
30861
|
-
var index$
|
|
30980
|
+
var index$p = /*#__PURE__*/Object.freeze({
|
|
30862
30981
|
__proto__: null,
|
|
30863
|
-
Relationship: index$
|
|
30982
|
+
Relationship: index$q,
|
|
30864
30983
|
getUserByIds: getUserByIds,
|
|
30865
30984
|
updateUser: updateUser,
|
|
30866
30985
|
flagUser: flagUser,
|
|
@@ -31263,7 +31382,7 @@ const uploadAudio = async (formData, onProgress) => {
|
|
|
31263
31382
|
};
|
|
31264
31383
|
/* end_public_function */
|
|
31265
31384
|
|
|
31266
|
-
var index$
|
|
31385
|
+
var index$o = /*#__PURE__*/Object.freeze({
|
|
31267
31386
|
__proto__: null,
|
|
31268
31387
|
getFile: getFile,
|
|
31269
31388
|
uploadFile: uploadFile,
|
|
@@ -33075,7 +33194,7 @@ const getReactions$1 = (params, callback, config) => {
|
|
|
33075
33194
|
};
|
|
33076
33195
|
/* end_public_function */
|
|
33077
33196
|
|
|
33078
|
-
var index$
|
|
33197
|
+
var index$n = /*#__PURE__*/Object.freeze({
|
|
33079
33198
|
__proto__: null,
|
|
33080
33199
|
addReaction: addReaction,
|
|
33081
33200
|
removeReaction: removeReaction,
|
|
@@ -34847,7 +34966,7 @@ const getMessages = (params, callback, config) => {
|
|
|
34847
34966
|
};
|
|
34848
34967
|
/* end_public_function */
|
|
34849
34968
|
|
|
34850
|
-
var index$
|
|
34969
|
+
var index$m = /*#__PURE__*/Object.freeze({
|
|
34851
34970
|
__proto__: null,
|
|
34852
34971
|
createMessage: createMessage,
|
|
34853
34972
|
updateMessage: updateMessage,
|
|
@@ -35373,7 +35492,7 @@ const stopMessageReceiptSync = (subChannelId) => {
|
|
|
35373
35492
|
};
|
|
35374
35493
|
/* end_public_function */
|
|
35375
35494
|
|
|
35376
|
-
var index$
|
|
35495
|
+
var index$l = /*#__PURE__*/Object.freeze({
|
|
35377
35496
|
__proto__: null,
|
|
35378
35497
|
getSubChannelByIds: getSubChannels$1,
|
|
35379
35498
|
createSubChannel: createSubChannel,
|
|
@@ -36700,7 +36819,7 @@ const searchMembers$1 = (params, callback, config) => {
|
|
|
36700
36819
|
};
|
|
36701
36820
|
/* end_public_function */
|
|
36702
36821
|
|
|
36703
|
-
var index$
|
|
36822
|
+
var index$k = /*#__PURE__*/Object.freeze({
|
|
36704
36823
|
__proto__: null,
|
|
36705
36824
|
addMembers: addMembers$1,
|
|
36706
36825
|
removeMembers: removeMembers$1,
|
|
@@ -36903,7 +37022,7 @@ const unmuteMembers = async (channelId, userIds) => {
|
|
|
36903
37022
|
};
|
|
36904
37023
|
/* end_public_function */
|
|
36905
37024
|
|
|
36906
|
-
var index$
|
|
37025
|
+
var index$j = /*#__PURE__*/Object.freeze({
|
|
36907
37026
|
__proto__: null,
|
|
36908
37027
|
addRole: addRole,
|
|
36909
37028
|
removeRole: removeRole,
|
|
@@ -36913,10 +37032,10 @@ var index$h = /*#__PURE__*/Object.freeze({
|
|
|
36913
37032
|
unmuteMembers: unmuteMembers
|
|
36914
37033
|
});
|
|
36915
37034
|
|
|
36916
|
-
var index$
|
|
37035
|
+
var index$i = /*#__PURE__*/Object.freeze({
|
|
36917
37036
|
__proto__: null,
|
|
36918
|
-
Membership: index$
|
|
36919
|
-
Moderation: index$
|
|
37037
|
+
Membership: index$k,
|
|
37038
|
+
Moderation: index$j,
|
|
36920
37039
|
getChannelByIds: getChannelByIds$1,
|
|
36921
37040
|
createChannel: createChannel,
|
|
36922
37041
|
updateChannel: updateChannel,
|
|
@@ -38319,7 +38438,7 @@ const searchMembers = (params, callback, config) => {
|
|
|
38319
38438
|
};
|
|
38320
38439
|
/* end_public_function */
|
|
38321
38440
|
|
|
38322
|
-
var index$
|
|
38441
|
+
var index$h = /*#__PURE__*/Object.freeze({
|
|
38323
38442
|
__proto__: null,
|
|
38324
38443
|
addMembers: addMembers,
|
|
38325
38444
|
removeMembers: removeMembers,
|
|
@@ -39570,7 +39689,7 @@ const unbanMembers = async (communityId, userIds) => {
|
|
|
39570
39689
|
};
|
|
39571
39690
|
/* end_public_function */
|
|
39572
39691
|
|
|
39573
|
-
var index$
|
|
39692
|
+
var index$g = /*#__PURE__*/Object.freeze({
|
|
39574
39693
|
__proto__: null,
|
|
39575
39694
|
addRoles: addRoles,
|
|
39576
39695
|
removeRoles: removeRoles,
|
|
@@ -39578,10 +39697,10 @@ var index$e = /*#__PURE__*/Object.freeze({
|
|
|
39578
39697
|
unbanMembers: unbanMembers
|
|
39579
39698
|
});
|
|
39580
39699
|
|
|
39581
|
-
var index$
|
|
39700
|
+
var index$f = /*#__PURE__*/Object.freeze({
|
|
39582
39701
|
__proto__: null,
|
|
39583
|
-
Moderation: index$
|
|
39584
|
-
Membership: index$
|
|
39702
|
+
Moderation: index$g,
|
|
39703
|
+
Membership: index$h,
|
|
39585
39704
|
getCommunityByIds: getCommunities$1,
|
|
39586
39705
|
createCommunity: createCommunity,
|
|
39587
39706
|
updateCommunity: updateCommunity,
|
|
@@ -39815,7 +39934,7 @@ const getCategories = (params, callback, config) => {
|
|
|
39815
39934
|
};
|
|
39816
39935
|
/* end_public_function */
|
|
39817
39936
|
|
|
39818
|
-
var index$
|
|
39937
|
+
var index$e = /*#__PURE__*/Object.freeze({
|
|
39819
39938
|
__proto__: null,
|
|
39820
39939
|
getCategory: getCategory,
|
|
39821
39940
|
getCategories: getCategories
|
|
@@ -40874,7 +40993,7 @@ const getComments = (params, callback, config) => {
|
|
|
40874
40993
|
};
|
|
40875
40994
|
/* end_public_function */
|
|
40876
40995
|
|
|
40877
|
-
var index$
|
|
40996
|
+
var index$d = /*#__PURE__*/Object.freeze({
|
|
40878
40997
|
__proto__: null,
|
|
40879
40998
|
getCommentByIds: getCommentByIds,
|
|
40880
40999
|
createComment: createComment,
|
|
@@ -41545,7 +41664,7 @@ const getUserFeed = (params, callback, config) => {
|
|
|
41545
41664
|
};
|
|
41546
41665
|
/* end_public_function */
|
|
41547
41666
|
|
|
41548
|
-
var index$
|
|
41667
|
+
var index$c = /*#__PURE__*/Object.freeze({
|
|
41549
41668
|
__proto__: null,
|
|
41550
41669
|
queryGlobalFeed: queryGlobalFeed,
|
|
41551
41670
|
getCustomRankingGlobalFeed: getCustomRankingGlobalFeed,
|
|
@@ -43226,7 +43345,7 @@ const searchPostsByHashtag = (params, callback, config) => {
|
|
|
43226
43345
|
};
|
|
43227
43346
|
/* end_public_function */
|
|
43228
43347
|
|
|
43229
|
-
var index$
|
|
43348
|
+
var index$b = /*#__PURE__*/Object.freeze({
|
|
43230
43349
|
__proto__: null,
|
|
43231
43350
|
getPostByIds: getPostByIds,
|
|
43232
43351
|
createPost: createPost,
|
|
@@ -43834,7 +43953,7 @@ const getStreams = (params, callback, config) => {
|
|
|
43834
43953
|
};
|
|
43835
43954
|
};
|
|
43836
43955
|
|
|
43837
|
-
var index$
|
|
43956
|
+
var index$a = /*#__PURE__*/Object.freeze({
|
|
43838
43957
|
__proto__: null,
|
|
43839
43958
|
createStream: createStream,
|
|
43840
43959
|
updateStream: updateStream,
|
|
@@ -43914,7 +44033,7 @@ const updateRoom = async (roomId, bundle) => {
|
|
|
43914
44033
|
ingestInCache(data, { cachedAt });
|
|
43915
44034
|
const { rooms } = data;
|
|
43916
44035
|
return {
|
|
43917
|
-
data: rooms[0],
|
|
44036
|
+
data: roomLinkedObject(rooms[0]),
|
|
43918
44037
|
cachedAt,
|
|
43919
44038
|
};
|
|
43920
44039
|
};
|
|
@@ -43987,10 +44106,10 @@ const stopRoom = async (roomId) => {
|
|
|
43987
44106
|
* const token = await getBroadcasterData('roomId')
|
|
43988
44107
|
* ```
|
|
43989
44108
|
*
|
|
43990
|
-
* Gets
|
|
44109
|
+
* Gets broadcaster data for a room
|
|
43991
44110
|
*
|
|
43992
44111
|
* @param roomId The ID of the room to get token for
|
|
43993
|
-
* @returns The room
|
|
44112
|
+
* @returns The broadcaster data of the room including coHostToken, coHostUrl and direactStreamUrl
|
|
43994
44113
|
*
|
|
43995
44114
|
* @category Room API
|
|
43996
44115
|
* @async
|
|
@@ -44028,6 +44147,62 @@ const getRecordedUrl = async (roomId) => {
|
|
|
44028
44147
|
};
|
|
44029
44148
|
/* end_public_function */
|
|
44030
44149
|
|
|
44150
|
+
/* begin_public_function
|
|
44151
|
+
id: room.removeParticipant
|
|
44152
|
+
*/
|
|
44153
|
+
/**
|
|
44154
|
+
* ```js
|
|
44155
|
+
* import { removeParticipant } from '@amityco/ts-sdk'
|
|
44156
|
+
* const result = await removeParticipant('roomId', 'participantUserId')
|
|
44157
|
+
* ```
|
|
44158
|
+
*
|
|
44159
|
+
* Removes a participant from an {@link Amity.Room}
|
|
44160
|
+
*
|
|
44161
|
+
* @param roomId The ID of the room to remove participant from
|
|
44162
|
+
* @param participantUserId The ID of the user to remove as participant
|
|
44163
|
+
* @returns Promise that resolves when the participant is removed
|
|
44164
|
+
*
|
|
44165
|
+
* @category Room API
|
|
44166
|
+
* @async
|
|
44167
|
+
*/
|
|
44168
|
+
const removeParticipant = async (roomId, participantUserId) => {
|
|
44169
|
+
const client = getActiveClient();
|
|
44170
|
+
client.log('room/removeParticipant', { roomId, participantUserId });
|
|
44171
|
+
await client.http.delete(`/api/v1/rooms/${roomId}/participants/${participantUserId}`);
|
|
44172
|
+
fireEvent('local.room.participantRemoved', {
|
|
44173
|
+
rooms: [{ _id: roomId }],
|
|
44174
|
+
users: [{ _id: participantUserId }],
|
|
44175
|
+
});
|
|
44176
|
+
};
|
|
44177
|
+
/* end_public_function */
|
|
44178
|
+
|
|
44179
|
+
/* begin_public_function
|
|
44180
|
+
id: room.leave
|
|
44181
|
+
*/
|
|
44182
|
+
/**
|
|
44183
|
+
* ```js
|
|
44184
|
+
* import { leaveRoom } from '@amityco/ts-sdk'
|
|
44185
|
+
* const result = await leaveRoom('roomId')
|
|
44186
|
+
* ```
|
|
44187
|
+
*
|
|
44188
|
+
* Leaves an {@link Amity.Room}
|
|
44189
|
+
*
|
|
44190
|
+
* @param roomId The ID of the room to leave
|
|
44191
|
+
* @returns Promise that resolves when the user has left the room
|
|
44192
|
+
*
|
|
44193
|
+
* @category Room API
|
|
44194
|
+
* @async
|
|
44195
|
+
*/
|
|
44196
|
+
const leaveRoom = async (roomId) => {
|
|
44197
|
+
const client = getActiveClient();
|
|
44198
|
+
client.log('room/leaveRoom', { roomId });
|
|
44199
|
+
await client.http.post(`/api/v1/rooms/${roomId}/leave`);
|
|
44200
|
+
fireEvent('local.room.left', {
|
|
44201
|
+
rooms: [{ _id: roomId }],
|
|
44202
|
+
});
|
|
44203
|
+
};
|
|
44204
|
+
/* end_public_function */
|
|
44205
|
+
|
|
44031
44206
|
/**
|
|
44032
44207
|
* ```js
|
|
44033
44208
|
* import { onRoomStartBroadcasting } from '@amityco/ts-sdk'
|
|
@@ -44139,13 +44314,131 @@ const onRoomRecordedAvailable = (callback) => {
|
|
|
44139
44314
|
*
|
|
44140
44315
|
* @category Room Events
|
|
44141
44316
|
*/
|
|
44142
|
-
const
|
|
44317
|
+
const onRoomCoHostInvited = (callback) => {
|
|
44143
44318
|
const client = getActiveClient();
|
|
44144
44319
|
const filter = (payload) => {
|
|
44145
|
-
|
|
44146
|
-
|
|
44320
|
+
const data = prepareMyInvitationsPayload(payload);
|
|
44321
|
+
ingestInCache(data);
|
|
44322
|
+
callback(data.invitations);
|
|
44323
|
+
};
|
|
44324
|
+
return createEventSubscriber(client, 'room/onRoomCoHostInvited', 'room.didCohostInvite', filter);
|
|
44325
|
+
};
|
|
44326
|
+
|
|
44327
|
+
const getRoomById = async (roomId) => {
|
|
44328
|
+
const client = getActiveClient();
|
|
44329
|
+
client.log('room/getRoomById', roomId);
|
|
44330
|
+
// Check if room is in tombstone
|
|
44331
|
+
isInTombstone('room', roomId);
|
|
44332
|
+
let data;
|
|
44333
|
+
try {
|
|
44334
|
+
const response = await client.http.get(`/api/v1/rooms/${roomId}`);
|
|
44335
|
+
data = response.data;
|
|
44336
|
+
}
|
|
44337
|
+
catch (error) {
|
|
44338
|
+
if (checkIfShouldGoesToTombstone(error === null || error === void 0 ? void 0 : error.code)) {
|
|
44339
|
+
pushToTombstone('room', roomId);
|
|
44340
|
+
}
|
|
44341
|
+
throw error;
|
|
44342
|
+
}
|
|
44343
|
+
const cachedAt = client.cache && Date.now();
|
|
44344
|
+
if (client.cache) {
|
|
44345
|
+
ingestInCache(data, { cachedAt });
|
|
44346
|
+
}
|
|
44347
|
+
return {
|
|
44348
|
+
data: data.rooms[0],
|
|
44349
|
+
cachedAt,
|
|
44350
|
+
};
|
|
44351
|
+
};
|
|
44352
|
+
getRoomById.locally = (roomId) => {
|
|
44353
|
+
const client = getActiveClient();
|
|
44354
|
+
client.log('room/getRoomById.locally', roomId);
|
|
44355
|
+
// Check if room is in tombstone
|
|
44356
|
+
isInTombstone('room', roomId);
|
|
44357
|
+
const cachedAt = client.cache && Date.now();
|
|
44358
|
+
const roomCache = pullFromCache(['room', 'get', roomId]);
|
|
44359
|
+
if (!roomCache)
|
|
44360
|
+
return;
|
|
44361
|
+
return {
|
|
44362
|
+
data: roomCache.data,
|
|
44363
|
+
cachedAt,
|
|
44147
44364
|
};
|
|
44148
|
-
|
|
44365
|
+
};
|
|
44366
|
+
|
|
44367
|
+
/**
|
|
44368
|
+
* ```js
|
|
44369
|
+
* import { onRoomCoHostInviteAccepted } from '@amityco/ts-sdk'
|
|
44370
|
+
* const dispose = onRoomCoHostInviteAccepted(room => {
|
|
44371
|
+
* // ...
|
|
44372
|
+
* })
|
|
44373
|
+
* ```
|
|
44374
|
+
*
|
|
44375
|
+
* Fired when a co-host invitation is accepted for a {@link Amity.Room}
|
|
44376
|
+
*
|
|
44377
|
+
* @param callback The function to call when the event was fired
|
|
44378
|
+
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
44379
|
+
*
|
|
44380
|
+
* @category Room Events
|
|
44381
|
+
*/
|
|
44382
|
+
const onRoomCoHostInviteAccepted = (callback) => {
|
|
44383
|
+
const client = getActiveClient();
|
|
44384
|
+
const filter = async (payload) => {
|
|
44385
|
+
var _a;
|
|
44386
|
+
const data = prepareMyInvitationsPayload(payload);
|
|
44387
|
+
await getRoomById((_a = data.invitations) === null || _a === void 0 ? void 0 : _a[0].targetId);
|
|
44388
|
+
ingestInCache(data);
|
|
44389
|
+
callback(data.invitations[0]);
|
|
44390
|
+
};
|
|
44391
|
+
return createEventSubscriber(client, 'room/onRoomCoHostInviteAccepted', 'room.didCohostInviteAccept', filter);
|
|
44392
|
+
};
|
|
44393
|
+
|
|
44394
|
+
/**
|
|
44395
|
+
* ```js
|
|
44396
|
+
* import { onRoomCoHostInviteRejected } from '@amityco/ts-sdk'
|
|
44397
|
+
* const dispose = onRoomCoHostInviteRejected(room => {
|
|
44398
|
+
* // ...
|
|
44399
|
+
* })
|
|
44400
|
+
* ```
|
|
44401
|
+
*
|
|
44402
|
+
* Fired when a co-host invitation is rejected for a {@link Amity.Room}
|
|
44403
|
+
*
|
|
44404
|
+
* @param callback The function to call when the event was fired
|
|
44405
|
+
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
44406
|
+
*
|
|
44407
|
+
* @category Room Events
|
|
44408
|
+
*/
|
|
44409
|
+
const onRoomCoHostInviteRejected = (callback) => {
|
|
44410
|
+
const client = getActiveClient();
|
|
44411
|
+
const filter = (payload) => {
|
|
44412
|
+
const data = prepareMyInvitationsPayload(payload);
|
|
44413
|
+
ingestInCache(data);
|
|
44414
|
+
callback(data.invitations);
|
|
44415
|
+
};
|
|
44416
|
+
return createEventSubscriber(client, 'room/onRoomCoHostInviteRejected', 'room.didCohostInviteReject', filter);
|
|
44417
|
+
};
|
|
44418
|
+
|
|
44419
|
+
/**
|
|
44420
|
+
* ```js
|
|
44421
|
+
* import { onRoomCoHostInviteCanceled } from '@amityco/ts-sdk'
|
|
44422
|
+
* const dispose = onRoomCoHostInviteCanceled(room => {
|
|
44423
|
+
* // ...
|
|
44424
|
+
* })
|
|
44425
|
+
* ```
|
|
44426
|
+
*
|
|
44427
|
+
* Fired when a co-host invitation is canceled for a {@link Amity.Room}
|
|
44428
|
+
*
|
|
44429
|
+
* @param callback The function to call when the event was fired
|
|
44430
|
+
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
44431
|
+
*
|
|
44432
|
+
* @category Room Events
|
|
44433
|
+
*/
|
|
44434
|
+
const onRoomCoHostInviteCanceled = (callback) => {
|
|
44435
|
+
const client = getActiveClient();
|
|
44436
|
+
const filter = (payload) => {
|
|
44437
|
+
const data = prepareMyInvitationsPayload(payload);
|
|
44438
|
+
ingestInCache(data);
|
|
44439
|
+
callback(data.invitations);
|
|
44440
|
+
};
|
|
44441
|
+
return createEventSubscriber(client, 'room/onRoomCoHostInviteCanceled', 'room.didCohostInviteCancel', filter);
|
|
44149
44442
|
};
|
|
44150
44443
|
|
|
44151
44444
|
/**
|
|
@@ -44292,44 +44585,76 @@ const onRoomStopped = (callback) => {
|
|
|
44292
44585
|
return createEventSubscriber(client, 'room/onRoomStopped', 'local.room.stopped', filter);
|
|
44293
44586
|
};
|
|
44294
44587
|
|
|
44295
|
-
|
|
44588
|
+
/**
|
|
44589
|
+
* ```js
|
|
44590
|
+
* import { onRoomParticipantRemoved } from '@amityco/ts-sdk'
|
|
44591
|
+
* const dispose = onRoomParticipantRemoved(room => {
|
|
44592
|
+
* // ...
|
|
44593
|
+
* })
|
|
44594
|
+
* ```
|
|
44595
|
+
*
|
|
44596
|
+
* Fired when a participant has been removed from a {@link Amity.Room} locally
|
|
44597
|
+
*
|
|
44598
|
+
* @param callback The function to call when the event was fired
|
|
44599
|
+
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
44600
|
+
*
|
|
44601
|
+
* @category Room Events
|
|
44602
|
+
*/
|
|
44603
|
+
const onRoomParticipantRemoved = (callback) => {
|
|
44296
44604
|
const client = getActiveClient();
|
|
44297
|
-
|
|
44298
|
-
|
|
44299
|
-
|
|
44300
|
-
let data;
|
|
44301
|
-
try {
|
|
44302
|
-
const response = await client.http.get(`/api/v1/rooms/${roomId}`);
|
|
44303
|
-
data = response.data;
|
|
44304
|
-
}
|
|
44305
|
-
catch (error) {
|
|
44306
|
-
if (checkIfShouldGoesToTombstone(error === null || error === void 0 ? void 0 : error.code)) {
|
|
44307
|
-
pushToTombstone('room', roomId);
|
|
44308
|
-
}
|
|
44309
|
-
throw error;
|
|
44310
|
-
}
|
|
44311
|
-
const cachedAt = client.cache && Date.now();
|
|
44312
|
-
if (client.cache) {
|
|
44313
|
-
ingestInCache(data, { cachedAt });
|
|
44314
|
-
}
|
|
44315
|
-
return {
|
|
44316
|
-
data: data.rooms[0],
|
|
44317
|
-
cachedAt,
|
|
44605
|
+
const filter = (payload) => {
|
|
44606
|
+
ingestInCache(payload);
|
|
44607
|
+
callback(payload.rooms[0]);
|
|
44318
44608
|
};
|
|
44609
|
+
return createEventSubscriber(client, 'room/onRoomParticipantRemoved', 'room.participantRemoved', filter);
|
|
44319
44610
|
};
|
|
44320
|
-
|
|
44611
|
+
|
|
44612
|
+
/**
|
|
44613
|
+
* ```js
|
|
44614
|
+
* import { onRoomLeft } from '@amityco/ts-sdk'
|
|
44615
|
+
* const dispose = onRoomLeft(room => {
|
|
44616
|
+
* // ...
|
|
44617
|
+
* })
|
|
44618
|
+
* ```
|
|
44619
|
+
*
|
|
44620
|
+
* Fired when a user has left a {@link Amity.Room} locally
|
|
44621
|
+
*
|
|
44622
|
+
* @param callback The function to call when the event was fired
|
|
44623
|
+
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
44624
|
+
*
|
|
44625
|
+
* @category Room Events
|
|
44626
|
+
*/
|
|
44627
|
+
const onRoomLeft = (callback) => {
|
|
44321
44628
|
const client = getActiveClient();
|
|
44322
|
-
|
|
44323
|
-
|
|
44324
|
-
|
|
44325
|
-
|
|
44326
|
-
|
|
44327
|
-
|
|
44328
|
-
|
|
44329
|
-
|
|
44330
|
-
|
|
44331
|
-
|
|
44629
|
+
const filter = (payload) => {
|
|
44630
|
+
ingestInCache(payload);
|
|
44631
|
+
callback(payload.rooms[0]);
|
|
44632
|
+
};
|
|
44633
|
+
return createEventSubscriber(client, 'room/onRoomLeft', 'local.room.left', filter);
|
|
44634
|
+
};
|
|
44635
|
+
|
|
44636
|
+
/**
|
|
44637
|
+
* ```js
|
|
44638
|
+
* import { onRoomParticipantRemoved } from '@amityco/ts-sdk'
|
|
44639
|
+
* const dispose = onRoomParticipantRemoved(room => {
|
|
44640
|
+
* // ...
|
|
44641
|
+
* })
|
|
44642
|
+
* ```
|
|
44643
|
+
*
|
|
44644
|
+
* Fired when a participant has been removed from a {@link Amity.Room} locally
|
|
44645
|
+
*
|
|
44646
|
+
* @param callback The function to call when the event was fired
|
|
44647
|
+
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
44648
|
+
*
|
|
44649
|
+
* @category Room Events
|
|
44650
|
+
*/
|
|
44651
|
+
const onRoomParticipantRemovedLocal = (callback) => {
|
|
44652
|
+
const client = getActiveClient();
|
|
44653
|
+
const filter = (payload) => {
|
|
44654
|
+
ingestInCache(payload);
|
|
44655
|
+
callback(payload.rooms[0]);
|
|
44332
44656
|
};
|
|
44657
|
+
return createEventSubscriber(client, 'room/onRoomParticipantRemoved', 'local.room.participantRemoved', filter);
|
|
44333
44658
|
};
|
|
44334
44659
|
|
|
44335
44660
|
const getRoom = (roomId, callback) => {
|
|
@@ -44339,7 +44664,18 @@ const getRoom = (roomId, callback) => {
|
|
|
44339
44664
|
onRoomStartBroadcasting,
|
|
44340
44665
|
onRoomWaitingReconnect,
|
|
44341
44666
|
onRoomRecordedAvailable,
|
|
44342
|
-
|
|
44667
|
+
onRoomParticipantJoined,
|
|
44668
|
+
onRoomParticipantLeft,
|
|
44669
|
+
onRoomParticipantRemoved,
|
|
44670
|
+
onRoomParticipantRemovedLocal,
|
|
44671
|
+
convertEventPayload(onRoomCoHostInviteAccepted, 'targetId', 'room'),
|
|
44672
|
+
], {
|
|
44673
|
+
callbackDataSelector: (data) => {
|
|
44674
|
+
if (!data)
|
|
44675
|
+
return data;
|
|
44676
|
+
return LinkedObject.room(data);
|
|
44677
|
+
},
|
|
44678
|
+
});
|
|
44343
44679
|
};
|
|
44344
44680
|
|
|
44345
44681
|
class RoomPaginationController extends PaginationController {
|
|
@@ -44552,7 +44888,7 @@ const getRooms = (params, callback, config) => {
|
|
|
44552
44888
|
};
|
|
44553
44889
|
/* end_public_function */
|
|
44554
44890
|
|
|
44555
|
-
var index$
|
|
44891
|
+
var index$9 = /*#__PURE__*/Object.freeze({
|
|
44556
44892
|
__proto__: null,
|
|
44557
44893
|
createRoom: createRoom,
|
|
44558
44894
|
updateRoom: updateRoom,
|
|
@@ -44560,21 +44896,322 @@ var index$7 = /*#__PURE__*/Object.freeze({
|
|
|
44560
44896
|
stopRoom: stopRoom,
|
|
44561
44897
|
getBroadcasterData: getBroadcasterData,
|
|
44562
44898
|
getRecordedUrl: getRecordedUrl,
|
|
44899
|
+
removeParticipant: removeParticipant,
|
|
44900
|
+
leaveRoom: leaveRoom,
|
|
44563
44901
|
onRoomStartBroadcasting: onRoomStartBroadcasting,
|
|
44564
44902
|
onRoomWaitingReconnect: onRoomWaitingReconnect,
|
|
44565
44903
|
onRoomEndBroadcasting: onRoomEndBroadcasting,
|
|
44566
44904
|
onRoomRecordedAvailable: onRoomRecordedAvailable,
|
|
44567
|
-
|
|
44905
|
+
onRoomCoHostInvited: onRoomCoHostInvited,
|
|
44906
|
+
onRoomCoHostInviteAccepted: onRoomCoHostInviteAccepted,
|
|
44907
|
+
onRoomCoHostInviteRejected: onRoomCoHostInviteRejected,
|
|
44908
|
+
onRoomCoHostInviteCanceled: onRoomCoHostInviteCanceled,
|
|
44568
44909
|
onRoomParticipantJoined: onRoomParticipantJoined,
|
|
44569
44910
|
onRoomParticipantLeft: onRoomParticipantLeft,
|
|
44570
44911
|
onRoomCreated: onRoomCreated,
|
|
44571
44912
|
onRoomUpdated: onRoomUpdated,
|
|
44572
44913
|
onRoomDeleted: onRoomDeleted,
|
|
44573
44914
|
onRoomStopped: onRoomStopped,
|
|
44915
|
+
onRoomParticipantRemoved: onRoomParticipantRemoved,
|
|
44916
|
+
onRoomLeft: onRoomLeft,
|
|
44574
44917
|
getRoom: getRoom,
|
|
44575
44918
|
getRooms: getRooms
|
|
44576
44919
|
});
|
|
44577
44920
|
|
|
44921
|
+
/* begin_public_function
|
|
44922
|
+
id: roomPresence.getRoomOnlineUsers
|
|
44923
|
+
*/
|
|
44924
|
+
/**
|
|
44925
|
+
* ```js
|
|
44926
|
+
* import { getRoomOnlineUsers } from '@amityco/ts-sdk'
|
|
44927
|
+
* const result = await getRoomOnlineUsers('roomId')
|
|
44928
|
+
* ```
|
|
44929
|
+
*
|
|
44930
|
+
* Retrieves the list of users currently online in a specific room.
|
|
44931
|
+
* This function fetches all users who are actively watching or present in the room,
|
|
44932
|
+
* handling pagination automatically for large numbers of users.
|
|
44933
|
+
*
|
|
44934
|
+
* @param roomId The ID of the room to get online users for
|
|
44935
|
+
* @returns Promise that resolves with a cached list of online users
|
|
44936
|
+
*
|
|
44937
|
+
* @category Room Presence API
|
|
44938
|
+
* @async
|
|
44939
|
+
*/
|
|
44940
|
+
const getRoomOnlineUsers = async (roomId) => {
|
|
44941
|
+
var _a, _b, _c;
|
|
44942
|
+
const client = getActiveClient();
|
|
44943
|
+
client.log('room/getWatchingUsers', { roomId });
|
|
44944
|
+
const { data } = await client.http.get(`/api/v1/presence/rooms/${roomId}/users`);
|
|
44945
|
+
const viewerIds = (_a = data === null || data === void 0 ? void 0 : data.viewers.map(viewer => viewer.userId)) !== null && _a !== void 0 ? _a : [];
|
|
44946
|
+
// getUserByIds has a maximum limit of 100 users per call
|
|
44947
|
+
// Split into chunks of 100 if we have more than 100 users
|
|
44948
|
+
const BATCH_SIZE = 100;
|
|
44949
|
+
const batches = [];
|
|
44950
|
+
for (let i = 0; i < viewerIds.length; i += BATCH_SIZE) {
|
|
44951
|
+
batches.push(viewerIds.slice(i, i + BATCH_SIZE));
|
|
44952
|
+
}
|
|
44953
|
+
// Fetch all batches in parallel
|
|
44954
|
+
const batchResults = await Promise.all(batches.map(batch => getUserByIds(batch)));
|
|
44955
|
+
// Merge all results
|
|
44956
|
+
const allViewers = [];
|
|
44957
|
+
batchResults.forEach(result => {
|
|
44958
|
+
if (result.data) {
|
|
44959
|
+
allViewers.push(...result.data);
|
|
44960
|
+
}
|
|
44961
|
+
});
|
|
44962
|
+
// Return in the same format as getUserByIds
|
|
44963
|
+
return {
|
|
44964
|
+
data: allViewers,
|
|
44965
|
+
cachedAt: (_c = (_b = batchResults[0]) === null || _b === void 0 ? void 0 : _b.cachedAt) !== null && _c !== void 0 ? _c : Date.now(),
|
|
44966
|
+
};
|
|
44967
|
+
};
|
|
44968
|
+
/* end_public_function */
|
|
44969
|
+
|
|
44970
|
+
/* begin_public_function
|
|
44971
|
+
id: roomPresence.getRoomUserCount
|
|
44972
|
+
*/
|
|
44973
|
+
/**
|
|
44974
|
+
* ```js
|
|
44975
|
+
* import { getRoomUserCount } from '@amityco/ts-sdk'
|
|
44976
|
+
* const count = await getRoomUserCount('roomId')
|
|
44977
|
+
* ```
|
|
44978
|
+
*
|
|
44979
|
+
* Retrieves the count of users currently watching or present in a specific room.
|
|
44980
|
+
* This function returns the total number of online users without fetching their full user data.
|
|
44981
|
+
*
|
|
44982
|
+
* @param roomId The ID of the room to get the user count for
|
|
44983
|
+
* @returns Promise that resolves with the room watching count data
|
|
44984
|
+
*
|
|
44985
|
+
* @category Room Presence API
|
|
44986
|
+
* @async
|
|
44987
|
+
*/
|
|
44988
|
+
const getRoomUserCount = async (roomId) => {
|
|
44989
|
+
const client = getActiveClient();
|
|
44990
|
+
client.log('roomPresence/getRoomUserCount', { roomId });
|
|
44991
|
+
const { data } = await client.http.get(`/api/v1/presence/rooms/${roomId}/users/count`);
|
|
44992
|
+
pushToCache(['get', 'watchingCount', roomId], data);
|
|
44993
|
+
fireEvent('local.room.watchingCountUpdated', data);
|
|
44994
|
+
return data;
|
|
44995
|
+
};
|
|
44996
|
+
/* end_public_function */
|
|
44997
|
+
|
|
44998
|
+
const getPresenceSetting = async () => {
|
|
44999
|
+
const client = getActiveClient();
|
|
45000
|
+
client.log('presence/getPresenceSetting');
|
|
45001
|
+
const { data } = await client.http.get('/api/v1/presence/settings');
|
|
45002
|
+
pushToCache(['get', 'presenceSetting'], data);
|
|
45003
|
+
return data;
|
|
45004
|
+
};
|
|
45005
|
+
|
|
45006
|
+
class RoomPresenceSyncEngine {
|
|
45007
|
+
constructor(roomId) {
|
|
45008
|
+
this.isEnabled = false;
|
|
45009
|
+
this.config = {
|
|
45010
|
+
heartbeatInterval: 30 * SECOND$1,
|
|
45011
|
+
};
|
|
45012
|
+
this.roomId = roomId;
|
|
45013
|
+
// Initialize config asynchronously - don't await in constructor
|
|
45014
|
+
this.initializeConfig().catch(error => {
|
|
45015
|
+
console.error('Failed to initialize RoomPresenceSyncEngine config in constructor:', error);
|
|
45016
|
+
});
|
|
45017
|
+
}
|
|
45018
|
+
async initializeConfig() {
|
|
45019
|
+
try {
|
|
45020
|
+
// Get presence settings from API with retry logic
|
|
45021
|
+
const presenceSettings = await RoomPresenceSyncEngine.getPresenceSettingWithRetry();
|
|
45022
|
+
if (presenceSettings) {
|
|
45023
|
+
// Set intervals from network settings (convert from minutes to milliseconds)
|
|
45024
|
+
this.config = {
|
|
45025
|
+
heartbeatInterval: (presenceSettings.network.heartbeatInterval || 5) * 60 * 1000,
|
|
45026
|
+
};
|
|
45027
|
+
}
|
|
45028
|
+
else {
|
|
45029
|
+
// Use default intervals if all retries failed
|
|
45030
|
+
this.config.heartbeatInterval = 5 * 60 * 1000; // 5 minutes
|
|
45031
|
+
}
|
|
45032
|
+
}
|
|
45033
|
+
catch (error) {
|
|
45034
|
+
console.error('Failed to initialize RoomPresenceSyncEngine config:', error);
|
|
45035
|
+
// Use default intervals if settings fetch fails
|
|
45036
|
+
this.config.heartbeatInterval = 5 * 60 * 1000; // 5 minutes
|
|
45037
|
+
}
|
|
45038
|
+
}
|
|
45039
|
+
static async getPresenceSettingWithRetry(maxRetries = 5) {
|
|
45040
|
+
for (let attempt = 0; attempt < maxRetries; attempt += 1) {
|
|
45041
|
+
try {
|
|
45042
|
+
// eslint-disable-next-line no-await-in-loop
|
|
45043
|
+
const presenceSettings = await getPresenceSetting();
|
|
45044
|
+
return presenceSettings;
|
|
45045
|
+
}
|
|
45046
|
+
catch (error) {
|
|
45047
|
+
if (attempt >= maxRetries - 1) {
|
|
45048
|
+
console.error(`Failed to get presence setting after ${maxRetries} attempts:`, error);
|
|
45049
|
+
return null;
|
|
45050
|
+
}
|
|
45051
|
+
// Calculate delay: 20 seconds + random jitter (0-5 seconds)
|
|
45052
|
+
const jitter = Math.random() * 5000; // 0-5 seconds in milliseconds
|
|
45053
|
+
const delay = 20000 + jitter; // 20 seconds + jitter
|
|
45054
|
+
console.warn(`Failed to get presence setting (attempt ${attempt + 1}/${maxRetries}), retrying in ${Math.round(delay / 1000)}s:`, error);
|
|
45055
|
+
// Wait before retry
|
|
45056
|
+
// eslint-disable-next-line no-await-in-loop
|
|
45057
|
+
await new Promise(resolve => {
|
|
45058
|
+
setTimeout(resolve, delay);
|
|
45059
|
+
});
|
|
45060
|
+
}
|
|
45061
|
+
}
|
|
45062
|
+
return null;
|
|
45063
|
+
}
|
|
45064
|
+
/**
|
|
45065
|
+
* Start heartbeat for the room
|
|
45066
|
+
*/
|
|
45067
|
+
start() {
|
|
45068
|
+
if (this.isEnabled)
|
|
45069
|
+
return;
|
|
45070
|
+
this.isEnabled = true;
|
|
45071
|
+
// Send immediate heartbeat
|
|
45072
|
+
this.sendHeartbeat();
|
|
45073
|
+
// Start heartbeat timer
|
|
45074
|
+
this.heartbeatTimer = setInterval(() => {
|
|
45075
|
+
this.sendHeartbeat();
|
|
45076
|
+
}, this.config.heartbeatInterval);
|
|
45077
|
+
}
|
|
45078
|
+
/**
|
|
45079
|
+
* Stop heartbeat for the room
|
|
45080
|
+
*/
|
|
45081
|
+
stop() {
|
|
45082
|
+
this.isEnabled = false;
|
|
45083
|
+
// Stop heartbeat timer
|
|
45084
|
+
if (this.heartbeatTimer) {
|
|
45085
|
+
clearInterval(this.heartbeatTimer);
|
|
45086
|
+
this.heartbeatTimer = undefined;
|
|
45087
|
+
}
|
|
45088
|
+
}
|
|
45089
|
+
/**
|
|
45090
|
+
* Send heartbeat to the room
|
|
45091
|
+
*/
|
|
45092
|
+
async sendHeartbeat() {
|
|
45093
|
+
try {
|
|
45094
|
+
const client = getActiveClient();
|
|
45095
|
+
await client.http.post(`/api/v1/presence/rooms/${this.roomId}/heartbeat`);
|
|
45096
|
+
}
|
|
45097
|
+
catch (error) {
|
|
45098
|
+
console.error(`Heartbeat failed for room ${this.roomId}:`, error);
|
|
45099
|
+
}
|
|
45100
|
+
}
|
|
45101
|
+
/**
|
|
45102
|
+
* Get the room ID
|
|
45103
|
+
*/
|
|
45104
|
+
getRoomId() {
|
|
45105
|
+
return this.roomId;
|
|
45106
|
+
}
|
|
45107
|
+
/**
|
|
45108
|
+
* Check if the engine is enabled
|
|
45109
|
+
*/
|
|
45110
|
+
isActive() {
|
|
45111
|
+
return this.isEnabled;
|
|
45112
|
+
}
|
|
45113
|
+
/**
|
|
45114
|
+
* Cleanup method to stop all timers and release resources
|
|
45115
|
+
* Call this when the engine instance is no longer needed
|
|
45116
|
+
*/
|
|
45117
|
+
destroy() {
|
|
45118
|
+
// Stop the engine
|
|
45119
|
+
this.stop();
|
|
45120
|
+
}
|
|
45121
|
+
// Session Management
|
|
45122
|
+
onSessionDestroyed() {
|
|
45123
|
+
// Stop all timers when session is destroyed and cleanup
|
|
45124
|
+
this.destroy();
|
|
45125
|
+
}
|
|
45126
|
+
onTokenExpired() {
|
|
45127
|
+
// Stop engine when token expires
|
|
45128
|
+
this.stop();
|
|
45129
|
+
}
|
|
45130
|
+
}
|
|
45131
|
+
|
|
45132
|
+
// Map to store engine instances per roomId
|
|
45133
|
+
const engineInstances = new Map();
|
|
45134
|
+
/**
|
|
45135
|
+
* Get or create a RoomPresenceSyncEngine instance for a specific room
|
|
45136
|
+
*
|
|
45137
|
+
* @param roomId The room ID to get/create engine for
|
|
45138
|
+
* @returns RoomPresenceSyncEngine instance for the room
|
|
45139
|
+
*/
|
|
45140
|
+
const getRoomPresenceSyncEngine = (roomId) => {
|
|
45141
|
+
let engine = engineInstances.get(roomId);
|
|
45142
|
+
if (!engine) {
|
|
45143
|
+
engine = new RoomPresenceSyncEngine(roomId);
|
|
45144
|
+
engineInstances.set(roomId, engine);
|
|
45145
|
+
}
|
|
45146
|
+
return engine;
|
|
45147
|
+
};
|
|
45148
|
+
/**
|
|
45149
|
+
* Destroy the engine instance for a specific room
|
|
45150
|
+
*
|
|
45151
|
+
* @param roomId The room ID to destroy engine for
|
|
45152
|
+
*/
|
|
45153
|
+
const destroyRoomPresenceSyncEngine = (roomId) => {
|
|
45154
|
+
const engine = engineInstances.get(roomId);
|
|
45155
|
+
if (engine) {
|
|
45156
|
+
engine.destroy();
|
|
45157
|
+
engineInstances.delete(roomId);
|
|
45158
|
+
}
|
|
45159
|
+
};
|
|
45160
|
+
|
|
45161
|
+
/* begin_public_function
|
|
45162
|
+
id: roomPresence.startHeartbeat
|
|
45163
|
+
*/
|
|
45164
|
+
/**
|
|
45165
|
+
* ```js
|
|
45166
|
+
* import { startHeartbeat } from '@amityco/ts-sdk'
|
|
45167
|
+
* startHeartbeat('roomId')
|
|
45168
|
+
* ```
|
|
45169
|
+
*
|
|
45170
|
+
* Starts sending heartbeat signals for a specific room to maintain presence status.
|
|
45171
|
+
* This enables the room presence tracking and notifies the server that the user is actively viewing the room.
|
|
45172
|
+
*
|
|
45173
|
+
* @param roomId The ID of the room to start heartbeat for
|
|
45174
|
+
*
|
|
45175
|
+
* @category Room Presence API
|
|
45176
|
+
*/
|
|
45177
|
+
const startHeartbeat = (roomId) => {
|
|
45178
|
+
const engine = getRoomPresenceSyncEngine(roomId);
|
|
45179
|
+
engine.start();
|
|
45180
|
+
};
|
|
45181
|
+
/* end_public_function */
|
|
45182
|
+
|
|
45183
|
+
/* begin_public_function
|
|
45184
|
+
id: roomPresence.stopHeartbeat
|
|
45185
|
+
*/
|
|
45186
|
+
/**
|
|
45187
|
+
* ```js
|
|
45188
|
+
* import { stopHeartbeat } from '@amityco/ts-sdk'
|
|
45189
|
+
* stopHeartbeat('roomId')
|
|
45190
|
+
* ```
|
|
45191
|
+
*
|
|
45192
|
+
* Stops sending heartbeat signals for a specific room.
|
|
45193
|
+
* This disables the room presence tracking for the specified room and stops notifying the server of the user's presence.
|
|
45194
|
+
*
|
|
45195
|
+
* @param roomId The ID of the room to stop heartbeat for
|
|
45196
|
+
*
|
|
45197
|
+
* @category Room Presence API
|
|
45198
|
+
*/
|
|
45199
|
+
const stopHeartbeat = (roomId) => {
|
|
45200
|
+
const engine = getRoomPresenceSyncEngine(roomId);
|
|
45201
|
+
engine.stop();
|
|
45202
|
+
// Clean up the engine instance
|
|
45203
|
+
destroyRoomPresenceSyncEngine(roomId);
|
|
45204
|
+
};
|
|
45205
|
+
/* end_public_function */
|
|
45206
|
+
|
|
45207
|
+
var index$8 = /*#__PURE__*/Object.freeze({
|
|
45208
|
+
__proto__: null,
|
|
45209
|
+
getRoomOnlineUsers: getRoomOnlineUsers,
|
|
45210
|
+
getRoomUserCount: getRoomUserCount,
|
|
45211
|
+
startHeartbeat: startHeartbeat,
|
|
45212
|
+
stopHeartbeat: stopHeartbeat
|
|
45213
|
+
});
|
|
45214
|
+
|
|
44578
45215
|
/* begin_public_function
|
|
44579
45216
|
id: poll.create
|
|
44580
45217
|
*/
|
|
@@ -44875,7 +45512,7 @@ const getPoll = (pollId, callback) => {
|
|
|
44875
45512
|
};
|
|
44876
45513
|
/* end_public_function */
|
|
44877
45514
|
|
|
44878
|
-
var index$
|
|
45515
|
+
var index$7 = /*#__PURE__*/Object.freeze({
|
|
44879
45516
|
__proto__: null,
|
|
44880
45517
|
createPoll: createPoll,
|
|
44881
45518
|
closePoll: closePoll,
|
|
@@ -45258,7 +45895,7 @@ const getPlayer = async (parameters) => {
|
|
|
45258
45895
|
return video;
|
|
45259
45896
|
};
|
|
45260
45897
|
|
|
45261
|
-
var index$
|
|
45898
|
+
var index$6 = /*#__PURE__*/Object.freeze({
|
|
45262
45899
|
__proto__: null,
|
|
45263
45900
|
getPlayer: getPlayer
|
|
45264
45901
|
});
|
|
@@ -46431,7 +47068,7 @@ const getGlobalStoryTargets = (params, callback, config) => {
|
|
|
46431
47068
|
};
|
|
46432
47069
|
};
|
|
46433
47070
|
|
|
46434
|
-
var index$
|
|
47071
|
+
var index$5 = /*#__PURE__*/Object.freeze({
|
|
46435
47072
|
__proto__: null,
|
|
46436
47073
|
createImageStory: createImageStory,
|
|
46437
47074
|
createVideoStory: createVideoStory,
|
|
@@ -46468,7 +47105,7 @@ const getNetworkAds = async () => {
|
|
|
46468
47105
|
};
|
|
46469
47106
|
};
|
|
46470
47107
|
|
|
46471
|
-
var index$
|
|
47108
|
+
var index$4 = /*#__PURE__*/Object.freeze({
|
|
46472
47109
|
__proto__: null,
|
|
46473
47110
|
getNetworkAds: getNetworkAds
|
|
46474
47111
|
});
|
|
@@ -46859,7 +47496,7 @@ const markTraySeen = async (lastSeenAt) => {
|
|
|
46859
47496
|
};
|
|
46860
47497
|
/* end_public_function */
|
|
46861
47498
|
|
|
46862
|
-
var index$
|
|
47499
|
+
var index$3 = /*#__PURE__*/Object.freeze({
|
|
46863
47500
|
__proto__: null,
|
|
46864
47501
|
getNotificationTraySeen: getNotificationTraySeen,
|
|
46865
47502
|
getNotificationTrayItems: getNotificationTrayItems,
|
|
@@ -46868,6 +47505,40 @@ var index$2 = /*#__PURE__*/Object.freeze({
|
|
|
46868
47505
|
onNotificationTraySeenUpdated: onNotificationTraySeenUpdated
|
|
46869
47506
|
});
|
|
46870
47507
|
|
|
47508
|
+
/* begin_public_function
|
|
47509
|
+
id: invitation.reject
|
|
47510
|
+
*/
|
|
47511
|
+
/**
|
|
47512
|
+
* ```js
|
|
47513
|
+
* import { rejectInvitation } from '@amityco/ts-sdk'
|
|
47514
|
+
* const isRejected = await rejectInvitation(invitationId)
|
|
47515
|
+
* ```
|
|
47516
|
+
*
|
|
47517
|
+
* Rejects a {@link Amity.Invitation} object
|
|
47518
|
+
*
|
|
47519
|
+
* @param invitationId the {@link Amity.Invitation} to reject
|
|
47520
|
+
* @returns A success boolean if the {@link Amity.Invitation} was rejected
|
|
47521
|
+
*
|
|
47522
|
+
* @category Invitation API
|
|
47523
|
+
* @async
|
|
47524
|
+
*/
|
|
47525
|
+
const cancelInvitation = async (invitationId) => {
|
|
47526
|
+
var _a;
|
|
47527
|
+
const client = getActiveClient();
|
|
47528
|
+
client.log('invitation/cancelInvitation', invitationId);
|
|
47529
|
+
const { data } = await client.http.delete(`/api/v1/invitations/${invitationId}`);
|
|
47530
|
+
const invitation = (_a = pullFromCache([
|
|
47531
|
+
'invitation',
|
|
47532
|
+
'get',
|
|
47533
|
+
invitationId,
|
|
47534
|
+
])) === null || _a === void 0 ? void 0 : _a.data;
|
|
47535
|
+
pushToTombstone('invitation', invitationId);
|
|
47536
|
+
if (invitation)
|
|
47537
|
+
fireEvent('local.invitation.canceled', [invitation]);
|
|
47538
|
+
return data.success;
|
|
47539
|
+
};
|
|
47540
|
+
/* end_public_function */
|
|
47541
|
+
|
|
46871
47542
|
class MyInvitationsPaginationController extends PaginationController {
|
|
46872
47543
|
async getRequest(queryParams, token) {
|
|
46873
47544
|
const { limit = COLLECTION_DEFAULT_PAGINATION_LIMIT } = queryParams, params = __rest(queryParams, ["limit"]);
|
|
@@ -46928,7 +47599,7 @@ class MyInvitationsQueryStreamController extends QueryStreamController {
|
|
|
46928
47599
|
]),
|
|
46929
47600
|
];
|
|
46930
47601
|
}
|
|
46931
|
-
if (action === InvitationActionsEnum.
|
|
47602
|
+
if (action === InvitationActionsEnum.OnLocalInvitationCanceled) {
|
|
46932
47603
|
collection.data = collection.data.filter(id => id !== invitations[0].invitationId);
|
|
46933
47604
|
}
|
|
46934
47605
|
pushToCache(this.cacheKey, collection);
|
|
@@ -46978,8 +47649,8 @@ class MyInvitationsLiveCollectionController extends LiveCollectionController {
|
|
|
46978
47649
|
action: InvitationActionsEnum.OnLocalInvitationUpdated,
|
|
46979
47650
|
},
|
|
46980
47651
|
{
|
|
46981
|
-
fn:
|
|
46982
|
-
action: InvitationActionsEnum.
|
|
47652
|
+
fn: onLocalInvitationCanceled,
|
|
47653
|
+
action: InvitationActionsEnum.OnLocalInvitationCanceled,
|
|
46983
47654
|
},
|
|
46984
47655
|
]);
|
|
46985
47656
|
}
|
|
@@ -47060,12 +47731,77 @@ const getMyCommunityInvitations = (params, callback, config) => {
|
|
|
47060
47731
|
};
|
|
47061
47732
|
};
|
|
47062
47733
|
|
|
47063
|
-
|
|
47734
|
+
/* begin_public_function
|
|
47735
|
+
id: invitation.get_invitations
|
|
47736
|
+
*/
|
|
47737
|
+
/**
|
|
47738
|
+
*
|
|
47739
|
+
* ```js
|
|
47740
|
+
* import { InvitationRepository } from '@amityco/ts-sdk';
|
|
47741
|
+
*
|
|
47742
|
+
* // For room invitations
|
|
47743
|
+
* const unsubscribe = InvitationRepository.getInvitations(
|
|
47744
|
+
* { targetId: 'room123', targetType: 'room' },
|
|
47745
|
+
* response => {
|
|
47746
|
+
* console.log('Room invitation event:', response.room, response.users, response.eventType)
|
|
47747
|
+
* }
|
|
47748
|
+
* );
|
|
47749
|
+
*
|
|
47750
|
+
* // For community invitations (when implemented)
|
|
47751
|
+
* const unsubscribe2 = observeInvitations(
|
|
47752
|
+
* { targetId: 'community456', targetType: 'community' },
|
|
47753
|
+
* response => {
|
|
47754
|
+
* console.log('Community invitation event:', response.community, response.users, response.eventType)
|
|
47755
|
+
* }
|
|
47756
|
+
* );
|
|
47757
|
+
* ```
|
|
47758
|
+
*
|
|
47759
|
+
* Observe invitations events including invited, accepted, rejected, and canceled
|
|
47760
|
+
*
|
|
47761
|
+
* @param params The target ID and type to observe invitations for
|
|
47762
|
+
* @param callback The function to call when new invitation events are available
|
|
47763
|
+
* @returns An {@link Amity.Unsubscriber} function to run when willing to stop observing the events
|
|
47764
|
+
*
|
|
47765
|
+
* @category Invitation Observable
|
|
47766
|
+
*/
|
|
47767
|
+
const getInvitations = (params, callback) => {
|
|
47768
|
+
const { _id: userId } = getCurrentUser();
|
|
47769
|
+
if (!userId)
|
|
47770
|
+
throw new ASCError('The _id has not been defined in ActiveUser', 800000 /* Amity.ClientError.UNKNOWN_ERROR */, "error" /* Amity.ErrorLevel.ERROR */);
|
|
47771
|
+
const { log } = getActiveClient();
|
|
47772
|
+
const { targetId, targetType } = params;
|
|
47773
|
+
const timestamp = Date.now();
|
|
47774
|
+
log(`observeInvitations(tmpid: ${timestamp}) > listen for ${targetType}: ${targetId}`);
|
|
47775
|
+
const disposers = [];
|
|
47776
|
+
const dispatcher = (data) => {
|
|
47777
|
+
callback(data.map(LinkedObject.invitation));
|
|
47778
|
+
};
|
|
47779
|
+
const realtimeRouter = (data) => {
|
|
47780
|
+
const invitations = (Array.isArray(data) ? data : [data]).filter(({ targetId, targetType }) => targetId === params.targetId && targetType === params.targetType);
|
|
47781
|
+
dispatcher(invitations);
|
|
47782
|
+
};
|
|
47783
|
+
// Only subscribe to room co-host events for now (since that's what we have implemented)
|
|
47784
|
+
if (targetType === 'room') {
|
|
47785
|
+
// Create custom event subscribers that receive the full payload
|
|
47786
|
+
disposers.push(onRoomCoHostInvited(realtimeRouter));
|
|
47787
|
+
disposers.push(onRoomCoHostInviteAccepted(realtimeRouter));
|
|
47788
|
+
disposers.push(onRoomCoHostInviteRejected(realtimeRouter));
|
|
47789
|
+
disposers.push(onRoomCoHostInviteCanceled(realtimeRouter));
|
|
47790
|
+
}
|
|
47791
|
+
return () => {
|
|
47792
|
+
log(`getInvitations(tmpid: ${timestamp}) > dispose for ${targetType}: ${targetId}`);
|
|
47793
|
+
disposers.forEach(fn => fn());
|
|
47794
|
+
};
|
|
47795
|
+
};
|
|
47796
|
+
|
|
47797
|
+
var index$2 = /*#__PURE__*/Object.freeze({
|
|
47064
47798
|
__proto__: null,
|
|
47799
|
+
cancelInvitation: cancelInvitation,
|
|
47065
47800
|
onLocalInvitationCreated: onLocalInvitationCreated,
|
|
47066
47801
|
onLocalInvitationUpdated: onLocalInvitationUpdated,
|
|
47067
|
-
|
|
47068
|
-
getMyCommunityInvitations: getMyCommunityInvitations
|
|
47802
|
+
onLocalInvitationCanceled: onLocalInvitationCanceled,
|
|
47803
|
+
getMyCommunityInvitations: getMyCommunityInvitations,
|
|
47804
|
+
getInvitations: getInvitations
|
|
47069
47805
|
});
|
|
47070
47806
|
|
|
47071
47807
|
// TODO: confirm id
|
|
@@ -47093,7 +47829,7 @@ var index$1 = /*#__PURE__*/Object.freeze({
|
|
|
47093
47829
|
* @category Live Reaction API
|
|
47094
47830
|
* @async
|
|
47095
47831
|
*/
|
|
47096
|
-
const createReaction = async ({ referenceId, referenceType, reactionName,
|
|
47832
|
+
const createReaction = async ({ referenceId, referenceType, reactionName, roomId, }) => {
|
|
47097
47833
|
const client = getActiveClient();
|
|
47098
47834
|
client.log('live_reaction/createReaction', {
|
|
47099
47835
|
referenceId,
|
|
@@ -47105,7 +47841,7 @@ const createReaction = async ({ referenceId, referenceType, reactionName, stream
|
|
|
47105
47841
|
reactionName,
|
|
47106
47842
|
referencePublicId: referenceId,
|
|
47107
47843
|
referenceType,
|
|
47108
|
-
|
|
47844
|
+
roomId,
|
|
47109
47845
|
occurredAt: new Date().toISOString(),
|
|
47110
47846
|
};
|
|
47111
47847
|
reactionSynceEngine.createLiveReaction(reaction);
|
|
@@ -47201,11 +47937,481 @@ const getReactions = (postId, callback) => {
|
|
|
47201
47937
|
};
|
|
47202
47938
|
};
|
|
47203
47939
|
|
|
47204
|
-
var index = /*#__PURE__*/Object.freeze({
|
|
47940
|
+
var index$1 = /*#__PURE__*/Object.freeze({
|
|
47205
47941
|
__proto__: null,
|
|
47206
47942
|
createReaction: createReaction,
|
|
47207
47943
|
onLiveReactionCreated: onLiveReactionCreated,
|
|
47208
47944
|
getReactions: getReactions
|
|
47209
47945
|
});
|
|
47210
47946
|
|
|
47211
|
-
|
|
47947
|
+
const prepareEventPayload = (rawPayload) => {
|
|
47948
|
+
return Object.assign(Object.assign({}, rawPayload), { users: rawPayload.users.map(convertRawUserToInternalUser) });
|
|
47949
|
+
};
|
|
47950
|
+
|
|
47951
|
+
const createEventEventSubscriber = (event, callback) => {
|
|
47952
|
+
const client = getActiveClient();
|
|
47953
|
+
const filter = (payload) => {
|
|
47954
|
+
const unpackedPayload = prepareEventPayload(payload);
|
|
47955
|
+
if (!client.cache) {
|
|
47956
|
+
callback(unpackedPayload.events[0]);
|
|
47957
|
+
}
|
|
47958
|
+
else {
|
|
47959
|
+
ingestInCache(unpackedPayload);
|
|
47960
|
+
const event = pullFromCache([
|
|
47961
|
+
'event',
|
|
47962
|
+
'get',
|
|
47963
|
+
unpackedPayload.events[0].eventId,
|
|
47964
|
+
]);
|
|
47965
|
+
callback(event.data);
|
|
47966
|
+
}
|
|
47967
|
+
};
|
|
47968
|
+
return createEventSubscriber(client, event, event, filter);
|
|
47969
|
+
};
|
|
47970
|
+
|
|
47971
|
+
/* begin_public_function
|
|
47972
|
+
id: event.create
|
|
47973
|
+
*/
|
|
47974
|
+
/**
|
|
47975
|
+
* ```js
|
|
47976
|
+
* import { EventRepository } from '@amityco/ts-sdk'
|
|
47977
|
+
* const response = await EventRepository.createEvent(bundle)
|
|
47978
|
+
* ```
|
|
47979
|
+
*
|
|
47980
|
+
* Creates an {@link Amity.Event}
|
|
47981
|
+
*
|
|
47982
|
+
* @param bundle The data necessary to create a new {@link Amity.Event}
|
|
47983
|
+
* @returns The newly created {@link Amity.Event}
|
|
47984
|
+
*
|
|
47985
|
+
* @category Event API
|
|
47986
|
+
* @async
|
|
47987
|
+
*/
|
|
47988
|
+
const createEvent = async (bundle) => {
|
|
47989
|
+
const client = getActiveClient();
|
|
47990
|
+
client.log('event/createEvent', bundle);
|
|
47991
|
+
const { data: payload } = await client.http.post('/api/v1/events', bundle);
|
|
47992
|
+
fireEvent('local.event.created', payload);
|
|
47993
|
+
const preparedPayload = prepareEventPayload(payload);
|
|
47994
|
+
const cachedAt = client.cache && Date.now();
|
|
47995
|
+
if (client.cache)
|
|
47996
|
+
ingestInCache(preparedPayload, { cachedAt });
|
|
47997
|
+
return {
|
|
47998
|
+
data: eventLinkedObject(preparedPayload.events[0]),
|
|
47999
|
+
cachedAt,
|
|
48000
|
+
};
|
|
48001
|
+
};
|
|
48002
|
+
/* end_public_function */
|
|
48003
|
+
|
|
48004
|
+
/* begin_public_function
|
|
48005
|
+
id: event.update
|
|
48006
|
+
*/
|
|
48007
|
+
/**
|
|
48008
|
+
* ```js
|
|
48009
|
+
* import { EventRepository } from '@amityco/ts-sdk'
|
|
48010
|
+
* const response = await EventRepository.updateEvent(eventId, bundle)
|
|
48011
|
+
* ```
|
|
48012
|
+
*
|
|
48013
|
+
* Updates an {@link Amity.Event}
|
|
48014
|
+
*
|
|
48015
|
+
* @param eventId The ID of the {@link Amity.Event} to edit
|
|
48016
|
+
* @param bundle The data necessary to update an existing {@link Amity.Event}
|
|
48017
|
+
* @returns the updated {@link Amity.Event}
|
|
48018
|
+
*
|
|
48019
|
+
* @category Event API
|
|
48020
|
+
* @async
|
|
48021
|
+
*/
|
|
48022
|
+
const updateEvent = async (eventId, bundle) => {
|
|
48023
|
+
const client = getActiveClient();
|
|
48024
|
+
client.log('event/updateEvent', eventId, bundle);
|
|
48025
|
+
const { data: payload } = await client.http.put(`/api/v1/events/${eventId}`, bundle);
|
|
48026
|
+
fireEvent('local.event.updated', payload);
|
|
48027
|
+
const preparedPayload = prepareEventPayload(payload);
|
|
48028
|
+
const cachedAt = client.cache && Date.now();
|
|
48029
|
+
if (client.cache)
|
|
48030
|
+
ingestInCache(preparedPayload, { cachedAt });
|
|
48031
|
+
return {
|
|
48032
|
+
data: eventLinkedObject(preparedPayload.events.find(event => event.eventId === eventId)),
|
|
48033
|
+
cachedAt,
|
|
48034
|
+
};
|
|
48035
|
+
};
|
|
48036
|
+
/* end_public_function */
|
|
48037
|
+
|
|
48038
|
+
/* begin_public_function
|
|
48039
|
+
id: event.get
|
|
48040
|
+
*/
|
|
48041
|
+
/**
|
|
48042
|
+
* ```js
|
|
48043
|
+
* import { EventRepository } from '@amityco/ts-sdk'
|
|
48044
|
+
* const event = await EventRepository.getEvent(eventId)
|
|
48045
|
+
* ```
|
|
48046
|
+
*
|
|
48047
|
+
* Fetches a {@link Amity.Event} object
|
|
48048
|
+
*
|
|
48049
|
+
* @param eventId the ID of the {@link Amity.Event} to fetch
|
|
48050
|
+
* @returns the associated {@link Amity.Event} object
|
|
48051
|
+
*
|
|
48052
|
+
* @category Event API
|
|
48053
|
+
* @async
|
|
48054
|
+
*/
|
|
48055
|
+
const getEvent$1 = async (eventId) => {
|
|
48056
|
+
const client = getActiveClient();
|
|
48057
|
+
client.log('event/getEvent', eventId);
|
|
48058
|
+
const { data: payload } = await client.http.get(`/api/v1/events/${eventId}`);
|
|
48059
|
+
const data = prepareEventPayload(payload);
|
|
48060
|
+
const cachedAt = client.cache && Date.now();
|
|
48061
|
+
if (client.cache)
|
|
48062
|
+
ingestInCache(data, { cachedAt });
|
|
48063
|
+
return {
|
|
48064
|
+
data: data.events.find(event => event.eventId === eventId),
|
|
48065
|
+
cachedAt,
|
|
48066
|
+
};
|
|
48067
|
+
};
|
|
48068
|
+
/* end_public_function */
|
|
48069
|
+
/**
|
|
48070
|
+
* ```js
|
|
48071
|
+
* import { EventRepository } from '@amityco/ts-sdk'
|
|
48072
|
+
* const event = EventRepository.getEvent.locally(eventId)
|
|
48073
|
+
* ```
|
|
48074
|
+
*
|
|
48075
|
+
* Fetches a {@link Amity.Event} object in cache
|
|
48076
|
+
*
|
|
48077
|
+
* @param eventId the ID of the {@link Amity.Event} to fetch
|
|
48078
|
+
* @returns the associated {@link Amity.Event} object
|
|
48079
|
+
*
|
|
48080
|
+
* @category Event API
|
|
48081
|
+
*/
|
|
48082
|
+
getEvent$1.locally = (eventId) => {
|
|
48083
|
+
const client = getActiveClient();
|
|
48084
|
+
client.log('event/getEvent.locally', eventId);
|
|
48085
|
+
if (!client.cache)
|
|
48086
|
+
return;
|
|
48087
|
+
const cache = pullFromCache(['event', 'get', eventId]);
|
|
48088
|
+
if (!cache)
|
|
48089
|
+
return;
|
|
48090
|
+
return {
|
|
48091
|
+
data: cache.data,
|
|
48092
|
+
cachedAt: cache.cachedAt,
|
|
48093
|
+
};
|
|
48094
|
+
};
|
|
48095
|
+
|
|
48096
|
+
/* begin_public_function
|
|
48097
|
+
id: event.delete
|
|
48098
|
+
*/
|
|
48099
|
+
/**
|
|
48100
|
+
* ```js
|
|
48101
|
+
* import { EventRepository } from '@amityco/ts-sdk'
|
|
48102
|
+
* const { success } = await EventRepository.deleteEvent(eventId)
|
|
48103
|
+
* ```
|
|
48104
|
+
*
|
|
48105
|
+
* Deletes a {@link Amity.Event}
|
|
48106
|
+
*
|
|
48107
|
+
* @param eventId The {@link Amity.Event} ID to delete
|
|
48108
|
+
*
|
|
48109
|
+
* @category Event API
|
|
48110
|
+
* @async
|
|
48111
|
+
*/
|
|
48112
|
+
const deleteEvent = async (eventId) => {
|
|
48113
|
+
const client = getActiveClient();
|
|
48114
|
+
client.log('event/deleteEvent', eventId);
|
|
48115
|
+
const event = await getEvent$1(eventId);
|
|
48116
|
+
await client.http.delete(`/api/v1/events/${eventId}`);
|
|
48117
|
+
const deletedEvent = Object.assign(Object.assign({}, event.data), { isDeleted: true });
|
|
48118
|
+
upsertInCache(['event', 'get', eventId], deletedEvent);
|
|
48119
|
+
fireEvent('local.event.deleted', {
|
|
48120
|
+
users: [],
|
|
48121
|
+
files: [],
|
|
48122
|
+
communities: [],
|
|
48123
|
+
posts: [],
|
|
48124
|
+
rooms: [],
|
|
48125
|
+
events: [deletedEvent],
|
|
48126
|
+
});
|
|
48127
|
+
};
|
|
48128
|
+
/* end_public_function */
|
|
48129
|
+
|
|
48130
|
+
/**
|
|
48131
|
+
* ```js
|
|
48132
|
+
* import { EventRepository } from '@amityco/ts-sdk'
|
|
48133
|
+
* const dispose = EventRepository.onEventCreated(event => {
|
|
48134
|
+
* // ...
|
|
48135
|
+
* })
|
|
48136
|
+
* ```
|
|
48137
|
+
*
|
|
48138
|
+
* Fired when a {@link Amity.Event} has been created
|
|
48139
|
+
*
|
|
48140
|
+
* @param callback The function to call when the event was fired
|
|
48141
|
+
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
48142
|
+
*
|
|
48143
|
+
* @category Event Events
|
|
48144
|
+
*/
|
|
48145
|
+
const onEventCreated = (callback) => createEventEventSubscriber('event.created', callback);
|
|
48146
|
+
|
|
48147
|
+
/**
|
|
48148
|
+
* ```js
|
|
48149
|
+
* import { EventRepository } from '@amityco/ts-sdk'
|
|
48150
|
+
* const dispose = EventRepository.onEventUpdated(event => {
|
|
48151
|
+
* // ...
|
|
48152
|
+
* })
|
|
48153
|
+
* ```
|
|
48154
|
+
*
|
|
48155
|
+
* Fired when a {@link Amity.Event} has been updated
|
|
48156
|
+
*
|
|
48157
|
+
* @param callback The function to call when the event was fired
|
|
48158
|
+
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
48159
|
+
*
|
|
48160
|
+
* @category Event Events
|
|
48161
|
+
*/
|
|
48162
|
+
const onEventUpdated = (callback) => createEventEventSubscriber('event.updated', callback);
|
|
48163
|
+
|
|
48164
|
+
/**
|
|
48165
|
+
* ```js
|
|
48166
|
+
* import { EventRepository } from '@amityco/ts-sdk'
|
|
48167
|
+
* const dispose = EventRepository.onEventDeleted(event => {
|
|
48168
|
+
* // ...
|
|
48169
|
+
* })
|
|
48170
|
+
* ```
|
|
48171
|
+
*
|
|
48172
|
+
* Fired when a {@link Amity.Event} has been deleted
|
|
48173
|
+
*
|
|
48174
|
+
* @param callback The function to call when the event was fired
|
|
48175
|
+
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
48176
|
+
*
|
|
48177
|
+
* @category Event Events
|
|
48178
|
+
*/
|
|
48179
|
+
const onEventDeleted = (callback) => createEventEventSubscriber('event.deleted', callback);
|
|
48180
|
+
|
|
48181
|
+
/**
|
|
48182
|
+
* ```js
|
|
48183
|
+
* import { EventRepository } from '@amityco/ts-sdk'
|
|
48184
|
+
* const dispose = EventRepository.onLocalEventCreated(event => {
|
|
48185
|
+
* // ...
|
|
48186
|
+
* })
|
|
48187
|
+
* ```
|
|
48188
|
+
*
|
|
48189
|
+
* Fired when a {@link Amity.Event} has been created
|
|
48190
|
+
*
|
|
48191
|
+
* @param callback The function to call when the event was fired
|
|
48192
|
+
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
48193
|
+
*
|
|
48194
|
+
* @category Event Events
|
|
48195
|
+
*/
|
|
48196
|
+
const onLocalEventCreated = (callback) => createEventEventSubscriber('local.event.created', callback);
|
|
48197
|
+
|
|
48198
|
+
/**
|
|
48199
|
+
* ```js
|
|
48200
|
+
* import { EventRepository } from '@amityco/ts-sdk'
|
|
48201
|
+
* const dispose = EventRepository.onLocalEventUpdated(event => {
|
|
48202
|
+
* // ...
|
|
48203
|
+
* })
|
|
48204
|
+
* ```
|
|
48205
|
+
*
|
|
48206
|
+
* Fired when a {@link Amity.Event} has been updated
|
|
48207
|
+
*
|
|
48208
|
+
* @param callback The function to call when the event was fired
|
|
48209
|
+
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
48210
|
+
*
|
|
48211
|
+
* @category Event Events
|
|
48212
|
+
*/
|
|
48213
|
+
const onLocalEventUpdated = (callback) => createEventEventSubscriber('local.event.updated', callback);
|
|
48214
|
+
|
|
48215
|
+
/**
|
|
48216
|
+
* ```js
|
|
48217
|
+
* import { EventRepository } from '@amityco/ts-sdk'
|
|
48218
|
+
* const dispose = EventRepository.onLocalEventDeleted(event => {
|
|
48219
|
+
* // ...
|
|
48220
|
+
* })
|
|
48221
|
+
* ```
|
|
48222
|
+
*
|
|
48223
|
+
* Fired when a {@link Amity.Event} has been deleted
|
|
48224
|
+
*
|
|
48225
|
+
* @param callback The function to call when the event was fired
|
|
48226
|
+
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
48227
|
+
*
|
|
48228
|
+
* @category Event Events
|
|
48229
|
+
*/
|
|
48230
|
+
const onLocalEventDeleted = (callback) => createEventEventSubscriber('local.event.deleted', callback);
|
|
48231
|
+
|
|
48232
|
+
/* begin_public_function
|
|
48233
|
+
id: event.get
|
|
48234
|
+
*/
|
|
48235
|
+
/**
|
|
48236
|
+
* ```js
|
|
48237
|
+
* import { EventRepository } from '@amityco/ts-sdk';
|
|
48238
|
+
*
|
|
48239
|
+
* let event;
|
|
48240
|
+
*
|
|
48241
|
+
* const unsubscribe = EventRepository.getEvent(eventId, response => {
|
|
48242
|
+
* event = response.data;
|
|
48243
|
+
* });
|
|
48244
|
+
* ```
|
|
48245
|
+
*
|
|
48246
|
+
* Observe all mutation on a given {@link Amity.Event}
|
|
48247
|
+
*
|
|
48248
|
+
* @param eventId the ID of the event to observe
|
|
48249
|
+
* @param callback the function to call when new snapshot of event are available
|
|
48250
|
+
* @returns An {@link Amity.Unsubscriber} function to run when willing to stop observing the event
|
|
48251
|
+
*
|
|
48252
|
+
* @category Event Live Object
|
|
48253
|
+
*/
|
|
48254
|
+
const getEvent = (eventId, callback) => {
|
|
48255
|
+
return liveObject(eventId, callback, 'eventId', getEvent$1, [onEventUpdated, onEventDeleted, onLocalEventUpdated, onLocalEventDeleted], {
|
|
48256
|
+
callbackDataSelector: (data) => (data ? eventLinkedObject(data) : data),
|
|
48257
|
+
});
|
|
48258
|
+
};
|
|
48259
|
+
/* end_public_function */
|
|
48260
|
+
|
|
48261
|
+
var EventActionsEnum;
|
|
48262
|
+
(function (EventActionsEnum) {
|
|
48263
|
+
EventActionsEnum["OnEventCreated"] = "onEventCreated";
|
|
48264
|
+
EventActionsEnum["OnEventUpdated"] = "onEventUpdated";
|
|
48265
|
+
EventActionsEnum["OnEventDeleted"] = "onEventDeleted";
|
|
48266
|
+
})(EventActionsEnum || (EventActionsEnum = {}));
|
|
48267
|
+
|
|
48268
|
+
class EventPaginationController extends PaginationController {
|
|
48269
|
+
async getRequest(queryParams, token) {
|
|
48270
|
+
const { limit = COLLECTION_DEFAULT_PAGINATION_LIMIT } = queryParams, params = __rest(queryParams, ["limit"]);
|
|
48271
|
+
const options = token ? { token } : { limit };
|
|
48272
|
+
const { data: response } = await this.http.get(`/api/v1/events`, { params: Object.assign(Object.assign({}, params), { options }) });
|
|
48273
|
+
return response;
|
|
48274
|
+
}
|
|
48275
|
+
}
|
|
48276
|
+
|
|
48277
|
+
class EventQueryStreamController extends QueryStreamController {
|
|
48278
|
+
constructor(query, cacheKey, notifyChange, preparePayload) {
|
|
48279
|
+
super(query, cacheKey);
|
|
48280
|
+
this.notifyChange = notifyChange;
|
|
48281
|
+
this.preparePayload = preparePayload;
|
|
48282
|
+
}
|
|
48283
|
+
async saveToMainDB(response) {
|
|
48284
|
+
const processedPayload = this.preparePayload(response);
|
|
48285
|
+
const client = getActiveClient();
|
|
48286
|
+
const cachedAt = client.cache && Date.now();
|
|
48287
|
+
if (client.cache)
|
|
48288
|
+
ingestInCache(processedPayload, { cachedAt });
|
|
48289
|
+
}
|
|
48290
|
+
appendToQueryStream(response, direction, refresh = false) {
|
|
48291
|
+
var _a, _b;
|
|
48292
|
+
if (refresh) {
|
|
48293
|
+
pushToCache(this.cacheKey, { data: response.events.map(getResolver('event')) });
|
|
48294
|
+
}
|
|
48295
|
+
else {
|
|
48296
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
48297
|
+
const events = (_b = collection === null || collection === void 0 ? void 0 : collection.data) !== null && _b !== void 0 ? _b : [];
|
|
48298
|
+
pushToCache(this.cacheKey, Object.assign(Object.assign({}, collection), { data: [...new Set([...events, ...response.events.map(getResolver('event'))])] }));
|
|
48299
|
+
}
|
|
48300
|
+
}
|
|
48301
|
+
reactor(action) {
|
|
48302
|
+
return (event) => {
|
|
48303
|
+
var _a;
|
|
48304
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
48305
|
+
if (!collection)
|
|
48306
|
+
return;
|
|
48307
|
+
if (action === EventActionsEnum.OnEventCreated) {
|
|
48308
|
+
collection.data = [...new Set([event.eventId, ...collection.data])];
|
|
48309
|
+
}
|
|
48310
|
+
if (action === EventActionsEnum.OnEventDeleted) {
|
|
48311
|
+
collection.data = collection.data.filter(eventId => eventId !== event.eventId);
|
|
48312
|
+
}
|
|
48313
|
+
pushToCache(this.cacheKey, collection);
|
|
48314
|
+
this.notifyChange({ origin: "event" /* Amity.LiveDataOrigin.EVENT */, loading: false });
|
|
48315
|
+
};
|
|
48316
|
+
}
|
|
48317
|
+
subscribeRTE(createSubscriber) {
|
|
48318
|
+
return createSubscriber.map(subscriber => subscriber.fn(this.reactor(subscriber.action)));
|
|
48319
|
+
}
|
|
48320
|
+
}
|
|
48321
|
+
|
|
48322
|
+
class EventLiveCollectionController extends LiveCollectionController {
|
|
48323
|
+
constructor(query, callback) {
|
|
48324
|
+
const queryStreamId = hash(query);
|
|
48325
|
+
const cacheKey = ['event', 'collection', queryStreamId];
|
|
48326
|
+
const paginationController = new EventPaginationController(query);
|
|
48327
|
+
super(paginationController, queryStreamId, cacheKey, callback);
|
|
48328
|
+
this.query = query;
|
|
48329
|
+
this.queryStreamController = new EventQueryStreamController(this.query, this.cacheKey, this.notifyChange.bind(this), prepareEventPayload);
|
|
48330
|
+
this.callback = callback.bind(this);
|
|
48331
|
+
this.loadPage({ initial: true });
|
|
48332
|
+
}
|
|
48333
|
+
setup() {
|
|
48334
|
+
var _a;
|
|
48335
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
48336
|
+
if (!collection)
|
|
48337
|
+
pushToCache(this.cacheKey, { data: [], params: {} });
|
|
48338
|
+
}
|
|
48339
|
+
async persistModel(queryPayload) {
|
|
48340
|
+
await this.queryStreamController.saveToMainDB(queryPayload);
|
|
48341
|
+
}
|
|
48342
|
+
persistQueryStream({ response, direction, refresh, }) {
|
|
48343
|
+
this.queryStreamController.appendToQueryStream(response, direction, refresh);
|
|
48344
|
+
}
|
|
48345
|
+
startSubscription() {
|
|
48346
|
+
return this.queryStreamController.subscribeRTE([
|
|
48347
|
+
{ fn: onEventCreated, action: EventActionsEnum.OnEventCreated },
|
|
48348
|
+
{ fn: onEventUpdated, action: EventActionsEnum.OnEventUpdated },
|
|
48349
|
+
{ fn: onEventDeleted, action: EventActionsEnum.OnEventDeleted },
|
|
48350
|
+
{ fn: onLocalEventCreated, action: EventActionsEnum.OnEventCreated },
|
|
48351
|
+
{ fn: onLocalEventUpdated, action: EventActionsEnum.OnEventUpdated },
|
|
48352
|
+
{ fn: onLocalEventDeleted, action: EventActionsEnum.OnEventDeleted },
|
|
48353
|
+
]);
|
|
48354
|
+
}
|
|
48355
|
+
notifyChange({ origin, loading, error }) {
|
|
48356
|
+
var _a, _b;
|
|
48357
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
48358
|
+
if (!collection)
|
|
48359
|
+
return;
|
|
48360
|
+
const data = ((_b = collection.data
|
|
48361
|
+
.map(eventId => pullFromCache(['event', 'get', eventId]))
|
|
48362
|
+
.filter(isNonNullable)
|
|
48363
|
+
.map(({ data }) => data)) !== null && _b !== void 0 ? _b : []).map(LinkedObject.event);
|
|
48364
|
+
if (!this.shouldNotify(data) && origin === "event" /* Amity.LiveDataOrigin.EVENT */)
|
|
48365
|
+
return;
|
|
48366
|
+
this.callback({
|
|
48367
|
+
data,
|
|
48368
|
+
error,
|
|
48369
|
+
loading,
|
|
48370
|
+
hasNextPage: !!this.paginationController.getNextToken(),
|
|
48371
|
+
onNextPage: () => this.loadPage({ direction: "next" /* Amity.LiveCollectionPageDirection.NEXT */ }),
|
|
48372
|
+
});
|
|
48373
|
+
}
|
|
48374
|
+
}
|
|
48375
|
+
|
|
48376
|
+
/**
|
|
48377
|
+
* Get events
|
|
48378
|
+
*
|
|
48379
|
+
* @param params the query parameters
|
|
48380
|
+
* @param callback the callback to be called when the events are updated
|
|
48381
|
+
* @returns events
|
|
48382
|
+
*
|
|
48383
|
+
* @category Event Live Collection
|
|
48384
|
+
*
|
|
48385
|
+
*/
|
|
48386
|
+
const getEvents = (params, callback, config) => {
|
|
48387
|
+
const { log, cache } = getActiveClient();
|
|
48388
|
+
if (!cache)
|
|
48389
|
+
console.log(ENABLE_CACHE_MESSAGE);
|
|
48390
|
+
const timestamp = Date.now();
|
|
48391
|
+
log(`getEvents: (tmpid: ${timestamp}) > listen`);
|
|
48392
|
+
const eventLiveCollection = new EventLiveCollectionController(params, callback);
|
|
48393
|
+
const disposers = eventLiveCollection.startSubscription();
|
|
48394
|
+
const cacheKey = eventLiveCollection.getCacheKey();
|
|
48395
|
+
disposers.push(() => dropFromCache(cacheKey));
|
|
48396
|
+
return () => {
|
|
48397
|
+
log(`getEvents (tmpid: ${timestamp}) > dispose`);
|
|
48398
|
+
disposers.forEach(fn => fn());
|
|
48399
|
+
};
|
|
48400
|
+
};
|
|
48401
|
+
|
|
48402
|
+
var index = /*#__PURE__*/Object.freeze({
|
|
48403
|
+
__proto__: null,
|
|
48404
|
+
createEvent: createEvent,
|
|
48405
|
+
updateEvent: updateEvent,
|
|
48406
|
+
deleteEvent: deleteEvent,
|
|
48407
|
+
onEventCreated: onEventCreated,
|
|
48408
|
+
onEventUpdated: onEventUpdated,
|
|
48409
|
+
onEventDeleted: onEventDeleted,
|
|
48410
|
+
onLocalEventCreated: onLocalEventCreated,
|
|
48411
|
+
onLocalEventUpdated: onLocalEventUpdated,
|
|
48412
|
+
onLocalEventDeleted: onLocalEventDeleted,
|
|
48413
|
+
getEvent: getEvent,
|
|
48414
|
+
getEvents: getEvents
|
|
48415
|
+
});
|
|
48416
|
+
|
|
48417
|
+
export { API_REGIONS, index$4 as AdRepository, AmityCommunityType, AmityEventOrderOption, AmityEventOriginType, AmityEventResponseStatus, AmityEventSortOption, AmityEventStatus, AmityEventType, index$e as CategoryRepository, index$i as ChannelRepository, index$r as Client, index$d as CommentRepository, CommunityPostSettingMaps, CommunityPostSettings, index$f as CommunityRepository, ContentFeedType, ContentFlagReasonEnum, DefaultCommunityPostSetting, index as EventRepository, FeedDataTypeEnum, index$c as FeedRepository, FeedSortByEnum, FeedSourceEnum, FileAccessTypeEnum, index$o as FileRepository, FileType, GET_WATCHER_URLS, index$2 as InvitationRepository, InvitationSortByEnum, InvitationStatusEnum, InvitationTargetTypeEnum, InvitationTypeEnum, JoinRequestStatusEnum, JoinResultStatusEnum, index$1 as LiveReactionRepository, index$6 as LiveStreamPlayer, MembershipAcceptanceTypeEnum, MessageContentType, index$m as MessageRepository, index$7 as PollRepository, PostContentType, index$b as PostRepository, PostStructureType, index$n as ReactionRepository, index$8 as RoomPresenceRepository, index$9 as RoomRepository, index$5 as StoryRepository, index$a as StreamRepository, index$l as SubChannelRepository, SubscriptionLevels, index$p 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, getRoomStreamerTopic, getRoomWatcherTopic, 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 };
|