@amityco/ts-sdk 7.11.1-4c3f6231.0 → 7.11.1-5f5a90da.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 +32 -13
- package/dist/@types/core/events.d.ts.map +1 -1
- package/dist/@types/core/model.d.ts +4 -3
- package/dist/@types/core/model.d.ts.map +1 -1
- package/dist/@types/core/payload.d.ts +15 -4
- package/dist/@types/core/payload.d.ts.map +1 -1
- package/dist/@types/core/permissions.d.ts +5 -1
- package/dist/@types/core/permissions.d.ts.map +1 -1
- package/dist/@types/core/transport.d.ts +3 -0
- package/dist/@types/core/transport.d.ts.map +1 -1
- package/dist/@types/domains/channel.d.ts +0 -1
- package/dist/@types/domains/channel.d.ts.map +1 -1
- package/dist/@types/domains/community.d.ts +11 -1
- package/dist/@types/domains/community.d.ts.map +1 -1
- package/dist/@types/domains/content.d.ts +1 -4
- package/dist/@types/domains/content.d.ts.map +1 -1
- package/dist/@types/domains/event.d.ts +81 -0
- package/dist/@types/domains/event.d.ts.map +1 -0
- package/dist/@types/domains/feed.d.ts +1 -2
- package/dist/@types/domains/feed.d.ts.map +1 -1
- package/dist/@types/domains/partials.d.ts +2 -2
- package/dist/@types/domains/partials.d.ts.map +1 -1
- package/dist/@types/domains/post.d.ts +0 -2
- package/dist/@types/domains/post.d.ts.map +1 -1
- package/dist/@types/index.d.ts +1 -2
- package/dist/@types/index.d.ts.map +1 -1
- package/dist/channelRepository/api/createChannel.d.ts +0 -1
- package/dist/channelRepository/api/createChannel.d.ts.map +1 -1
- package/dist/core/events.d.ts +3 -3
- package/dist/core/events.d.ts.map +1 -1
- package/dist/core/model/idResolvers.d.ts.map +1 -1
- package/dist/core/model/index.d.ts.map +1 -1
- package/dist/core/subscription.d.ts +0 -2
- 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.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/getMyEvents/LiveCollectionController.d.ts +13 -0
- package/dist/eventRepository/observers/getMyEvents/LiveCollectionController.d.ts.map +1 -0
- package/dist/eventRepository/observers/getMyEvents/PaginationController.d.ts +5 -0
- package/dist/eventRepository/observers/getMyEvents/PaginationController.d.ts.map +1 -0
- package/dist/eventRepository/observers/getMyEvents/QueryStreamController.d.ts +15 -0
- package/dist/eventRepository/observers/getMyEvents/QueryStreamController.d.ts.map +1 -0
- package/dist/eventRepository/observers/getMyEvents.d.ts +12 -0
- package/dist/eventRepository/observers/getMyEvents.d.ts.map +1 -0
- package/dist/eventRepository/observers/index.d.ts +4 -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 +2685 -2843
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.esm.js +733 -889
- package/dist/index.umd.js +3 -3
- package/dist/liveReactionRepository/api/createReaction.d.ts +2 -2
- package/dist/liveReactionRepository/api/createReaction.d.ts.map +1 -1
- package/dist/liveReactionRepository/internalApi/createLiveReaction.d.ts +2 -2
- package/dist/liveReactionRepository/internalApi/createLiveReaction.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 +1 -2
- package/dist/messagePreview/utils/getChannelMessagePreviewWithUser.d.ts.map +1 -1
- package/dist/messagePreview/utils/getSubChannelMessagePreviewWithUser.d.ts +1 -1
- package/dist/utils/linkedObject/eventLinkObject.d.ts +2 -0
- package/dist/utils/linkedObject/eventLinkObject.d.ts.map +1 -0
- package/dist/utils/linkedObject/index.d.ts +1 -1
- package/dist/utils/linkedObject/postLinkedObject.d.ts.map +1 -1
- package/dist/utils/postTypePredicate.d.ts +0 -1
- package/dist/utils/postTypePredicate.d.ts.map +1 -1
- package/dist/utils/tests/dummy/comment.d.ts +1 -1
- package/package.json +1 -1
- package/dist/@types/domains/room.d.ts +0 -77
- package/dist/@types/domains/room.d.ts.map +0 -1
- package/dist/roomRepository/api/createRoom.d.ts +0 -24
- package/dist/roomRepository/api/createRoom.d.ts.map +0 -1
- package/dist/roomRepository/api/deleteRoom.d.ts +0 -16
- package/dist/roomRepository/api/deleteRoom.d.ts.map +0 -1
- package/dist/roomRepository/api/getBroadcasterData.d.ts +0 -16
- package/dist/roomRepository/api/getBroadcasterData.d.ts.map +0 -1
- package/dist/roomRepository/api/getRecordedUrl.d.ts +0 -19
- package/dist/roomRepository/api/getRecordedUrl.d.ts.map +0 -1
- package/dist/roomRepository/api/index.d.ts +0 -7
- package/dist/roomRepository/api/index.d.ts.map +0 -1
- package/dist/roomRepository/api/stopRoom.d.ts +0 -16
- package/dist/roomRepository/api/stopRoom.d.ts.map +0 -1
- package/dist/roomRepository/api/updateRoom.d.ts +0 -24
- package/dist/roomRepository/api/updateRoom.d.ts.map +0 -1
- package/dist/roomRepository/events/index.d.ts +0 -12
- package/dist/roomRepository/events/index.d.ts.map +0 -1
- package/dist/roomRepository/events/onRoomCreated.d.ts +0 -17
- package/dist/roomRepository/events/onRoomCreated.d.ts.map +0 -1
- package/dist/roomRepository/events/onRoomDeleted.d.ts +0 -17
- package/dist/roomRepository/events/onRoomDeleted.d.ts.map +0 -1
- package/dist/roomRepository/events/onRoomEndBroadcasting.d.ts +0 -17
- package/dist/roomRepository/events/onRoomEndBroadcasting.d.ts.map +0 -1
- package/dist/roomRepository/events/onRoomParticipantInviting.d.ts +0 -17
- package/dist/roomRepository/events/onRoomParticipantInviting.d.ts.map +0 -1
- package/dist/roomRepository/events/onRoomParticipantJoined.d.ts +0 -17
- package/dist/roomRepository/events/onRoomParticipantJoined.d.ts.map +0 -1
- package/dist/roomRepository/events/onRoomParticipantLeft.d.ts +0 -17
- package/dist/roomRepository/events/onRoomParticipantLeft.d.ts.map +0 -1
- package/dist/roomRepository/events/onRoomRecordedAvailable.d.ts +0 -17
- package/dist/roomRepository/events/onRoomRecordedAvailable.d.ts.map +0 -1
- package/dist/roomRepository/events/onRoomStartBroadcasting.d.ts +0 -17
- package/dist/roomRepository/events/onRoomStartBroadcasting.d.ts.map +0 -1
- package/dist/roomRepository/events/onRoomStopped.d.ts +0 -17
- package/dist/roomRepository/events/onRoomStopped.d.ts.map +0 -1
- package/dist/roomRepository/events/onRoomUpdated.d.ts +0 -17
- package/dist/roomRepository/events/onRoomUpdated.d.ts.map +0 -1
- package/dist/roomRepository/events/onRoomWaitingReconnect.d.ts +0 -17
- package/dist/roomRepository/events/onRoomWaitingReconnect.d.ts.map +0 -1
- package/dist/roomRepository/index.d.ts.map +0 -1
- package/dist/roomRepository/internalApi/getLiveChat.d.ts +0 -16
- package/dist/roomRepository/internalApi/getLiveChat.d.ts.map +0 -1
- package/dist/roomRepository/internalApi/getRoomById.d.ts +0 -5
- package/dist/roomRepository/internalApi/getRoomById.d.ts.map +0 -1
- package/dist/roomRepository/internalApi/index.d.ts +0 -3
- package/dist/roomRepository/internalApi/index.d.ts.map +0 -1
- package/dist/roomRepository/observers/enums.d.ts +0 -10
- package/dist/roomRepository/observers/enums.d.ts.map +0 -1
- package/dist/roomRepository/observers/getRoom.d.ts +0 -2
- package/dist/roomRepository/observers/getRoom.d.ts.map +0 -1
- package/dist/roomRepository/observers/getRooms/RoomLiveCollectionController.d.ts +0 -14
- package/dist/roomRepository/observers/getRooms/RoomLiveCollectionController.d.ts.map +0 -1
- package/dist/roomRepository/observers/getRooms/RoomPaginationController.d.ts +0 -5
- package/dist/roomRepository/observers/getRooms/RoomPaginationController.d.ts.map +0 -1
- package/dist/roomRepository/observers/getRooms/RoomQueryStreamController.d.ts +0 -15
- package/dist/roomRepository/observers/getRooms/RoomQueryStreamController.d.ts.map +0 -1
- package/dist/roomRepository/observers/getRooms.d.ts +0 -29
- package/dist/roomRepository/observers/getRooms.d.ts.map +0 -1
- package/dist/roomRepository/observers/index.d.ts +0 -3
- package/dist/roomRepository/observers/index.d.ts.map +0 -1
- package/dist/roomRepository/observers/utils.d.ts +0 -6
- package/dist/roomRepository/observers/utils.d.ts.map +0 -1
- package/dist/utils/linkedObject/roomLinkedObject.d.ts +0 -2
- package/dist/utils/linkedObject/roomLinkedObject.d.ts.map +0 -1
- /package/dist/{roomRepository → eventRepository}/index.d.ts +0 -0
package/dist/index.esm.js
CHANGED
|
@@ -112,7 +112,6 @@ const PostContentType = Object.freeze({
|
|
|
112
112
|
POLL: 'poll',
|
|
113
113
|
CLIP: 'clip',
|
|
114
114
|
AUDIO: 'audio',
|
|
115
|
-
ROOM: 'room',
|
|
116
115
|
});
|
|
117
116
|
const PostStructureType = Object.freeze({
|
|
118
117
|
TEXT: 'text',
|
|
@@ -164,7 +163,6 @@ var FeedDataTypeEnum;
|
|
|
164
163
|
FeedDataTypeEnum["LiveStream"] = "liveStream";
|
|
165
164
|
FeedDataTypeEnum["Clip"] = "clip";
|
|
166
165
|
FeedDataTypeEnum["Poll"] = "poll";
|
|
167
|
-
FeedDataTypeEnum["Room"] = "room";
|
|
168
166
|
})(FeedDataTypeEnum || (FeedDataTypeEnum = {}));
|
|
169
167
|
var FeedSortByEnum;
|
|
170
168
|
(function (FeedSortByEnum) {
|
|
@@ -179,6 +177,30 @@ var FeedSourceEnum;
|
|
|
179
177
|
FeedSourceEnum["User"] = "user";
|
|
180
178
|
})(FeedSourceEnum || (FeedSourceEnum = {}));
|
|
181
179
|
|
|
180
|
+
var AmityEventType;
|
|
181
|
+
(function (AmityEventType) {
|
|
182
|
+
AmityEventType["Virtual"] = "virtual";
|
|
183
|
+
AmityEventType["InPerson"] = "in_person";
|
|
184
|
+
})(AmityEventType || (AmityEventType = {}));
|
|
185
|
+
var AmityEventOriginType;
|
|
186
|
+
(function (AmityEventOriginType) {
|
|
187
|
+
AmityEventOriginType["Community"] = "community";
|
|
188
|
+
AmityEventOriginType["User"] = "user";
|
|
189
|
+
})(AmityEventOriginType || (AmityEventOriginType = {}));
|
|
190
|
+
var AmityEventStatus;
|
|
191
|
+
(function (AmityEventStatus) {
|
|
192
|
+
AmityEventStatus["Scheduled"] = "scheduled";
|
|
193
|
+
AmityEventStatus["Live"] = "live";
|
|
194
|
+
AmityEventStatus["Ended"] = "ended";
|
|
195
|
+
AmityEventStatus["Cancelled"] = "cancelled";
|
|
196
|
+
})(AmityEventStatus || (AmityEventStatus = {}));
|
|
197
|
+
var AmityEventResponseStatus;
|
|
198
|
+
(function (AmityEventResponseStatus) {
|
|
199
|
+
AmityEventResponseStatus["Going"] = "going";
|
|
200
|
+
AmityEventResponseStatus["Interested"] = "interested";
|
|
201
|
+
AmityEventResponseStatus["NotGoing"] = "not_going";
|
|
202
|
+
})(AmityEventResponseStatus || (AmityEventResponseStatus = {}));
|
|
203
|
+
|
|
182
204
|
function getVersion() {
|
|
183
205
|
try {
|
|
184
206
|
// the string ''v7.11.0-esm'' should be replaced by actual value by @rollup/plugin-replace
|
|
@@ -627,7 +649,8 @@ const idResolvers = {
|
|
|
627
649
|
notificationTraySeen: ({ userId }) => userId,
|
|
628
650
|
invitation: ({ _id }) => _id,
|
|
629
651
|
joinRequest: ({ joinRequestId }) => joinRequestId,
|
|
630
|
-
|
|
652
|
+
event: ({ eventId }) => eventId,
|
|
653
|
+
discussionCommunity: ({ communityId }) => communityId,
|
|
631
654
|
};
|
|
632
655
|
/**
|
|
633
656
|
* Retrieve the id resolver matching a domain name
|
|
@@ -683,7 +706,8 @@ const PAYLOAD2MODEL = {
|
|
|
683
706
|
notificationTrayItems: 'notificationTrayItem',
|
|
684
707
|
invitations: 'invitation',
|
|
685
708
|
joinRequests: 'joinRequest',
|
|
686
|
-
|
|
709
|
+
events: 'event',
|
|
710
|
+
discussionCommunities: 'discussionCommunity',
|
|
687
711
|
};
|
|
688
712
|
/** hidden */
|
|
689
713
|
const isOutdated = (prevData, nextData) => {
|
|
@@ -1483,37 +1507,6 @@ async function modifyMqttConnection() {
|
|
|
1483
1507
|
}
|
|
1484
1508
|
}
|
|
1485
1509
|
|
|
1486
|
-
const userLinkedObject = (user) => {
|
|
1487
|
-
return Object.assign(Object.assign({}, user), { get avatar() {
|
|
1488
|
-
var _a;
|
|
1489
|
-
if (!user.avatarFileId)
|
|
1490
|
-
return undefined;
|
|
1491
|
-
const avatar = (_a = pullFromCache([
|
|
1492
|
-
'file',
|
|
1493
|
-
'get',
|
|
1494
|
-
`${user.avatarFileId}`,
|
|
1495
|
-
])) === null || _a === void 0 ? void 0 : _a.data;
|
|
1496
|
-
return avatar;
|
|
1497
|
-
} });
|
|
1498
|
-
};
|
|
1499
|
-
|
|
1500
|
-
/* begin_public_function
|
|
1501
|
-
id: client.get_current_user
|
|
1502
|
-
*/
|
|
1503
|
-
const getCurrentUser = () => {
|
|
1504
|
-
var _a;
|
|
1505
|
-
const client = getActiveClient();
|
|
1506
|
-
if (!client) {
|
|
1507
|
-
throw new ASCError('Connect client first', 800000 /* Amity.ClientError.UNKNOWN_ERROR */, "fatal" /* Amity.ErrorLevel.FATAL */);
|
|
1508
|
-
}
|
|
1509
|
-
const cache = (_a = pullFromCache(['user', 'get', client.userId])) === null || _a === void 0 ? void 0 : _a.data;
|
|
1510
|
-
if (!cache) {
|
|
1511
|
-
throw new ASCError('Connect client first', 800000 /* Amity.ClientError.UNKNOWN_ERROR */, "fatal" /* Amity.ErrorLevel.FATAL */);
|
|
1512
|
-
}
|
|
1513
|
-
return userLinkedObject(cache);
|
|
1514
|
-
};
|
|
1515
|
-
/* end_public_function */
|
|
1516
|
-
|
|
1517
1510
|
var SubscriptionLevels;
|
|
1518
1511
|
(function (SubscriptionLevels) {
|
|
1519
1512
|
SubscriptionLevels["COMMUNITY"] = "community";
|
|
@@ -1619,14 +1612,6 @@ const getLiveStreamTopic = () => {
|
|
|
1619
1612
|
const getLiveReactionTopic = (post) => {
|
|
1620
1613
|
return `${post.path}/liveReaction`;
|
|
1621
1614
|
};
|
|
1622
|
-
const getRoomWatcherTopic = (room) => {
|
|
1623
|
-
const user = getCurrentUser();
|
|
1624
|
-
return `${getNetworkId(user)}/room/${room._id}`;
|
|
1625
|
-
};
|
|
1626
|
-
const getRoomStreamerTopic = (room) => {
|
|
1627
|
-
const user = getCurrentUser();
|
|
1628
|
-
return `${getNetworkId(user)}/room/${room.roomId}/streamer`;
|
|
1629
|
-
};
|
|
1630
1615
|
function subscribeTopic(topic, callback) {
|
|
1631
1616
|
const { mqtt } = getActiveClient();
|
|
1632
1617
|
if (!mqtt)
|
|
@@ -21053,6 +21038,20 @@ const getChannelMessagePreview = (channelId) => {
|
|
|
21053
21038
|
return ((_b = (_a = pullFromCache(['messagePreviewChannel', 'get', channelId])) === null || _a === void 0 ? void 0 : _a.data) !== null && _b !== void 0 ? _b : null);
|
|
21054
21039
|
};
|
|
21055
21040
|
|
|
21041
|
+
const userLinkedObject = (user) => {
|
|
21042
|
+
return Object.assign(Object.assign({}, user), { get avatar() {
|
|
21043
|
+
var _a;
|
|
21044
|
+
if (!user.avatarFileId)
|
|
21045
|
+
return undefined;
|
|
21046
|
+
const avatar = (_a = pullFromCache([
|
|
21047
|
+
'file',
|
|
21048
|
+
'get',
|
|
21049
|
+
`${user.avatarFileId}`,
|
|
21050
|
+
])) === null || _a === void 0 ? void 0 : _a.data;
|
|
21051
|
+
return avatar;
|
|
21052
|
+
} });
|
|
21053
|
+
};
|
|
21054
|
+
|
|
21056
21055
|
const getChannelMessagePreviewWithUser = (channel) => {
|
|
21057
21056
|
var _a;
|
|
21058
21057
|
const messagePreview = channel.messagePreviewId
|
|
@@ -24568,11 +24567,11 @@ var objectResolverEngineOnLoginHandler = () => {
|
|
|
24568
24567
|
* @category Live Reaction API
|
|
24569
24568
|
* @async
|
|
24570
24569
|
*/
|
|
24571
|
-
const createLiveReaction = async ({ reactions,
|
|
24570
|
+
const createLiveReaction = async ({ reactions, liveStreamId, }) => {
|
|
24572
24571
|
const client = getActiveClient();
|
|
24573
24572
|
client.log('live_reaction/addReaction', reactions);
|
|
24574
24573
|
const { data } = await client.http.post(`/api/v1/reactions/live`, {
|
|
24575
|
-
|
|
24574
|
+
liveStreamId,
|
|
24576
24575
|
reactions,
|
|
24577
24576
|
});
|
|
24578
24577
|
return data;
|
|
@@ -24630,19 +24629,19 @@ class LiveReactionSyncEngine {
|
|
|
24630
24629
|
// Clear buffer
|
|
24631
24630
|
this.clearBuffer();
|
|
24632
24631
|
const payloads = reactions.reduce((prev, curr) => {
|
|
24633
|
-
const {
|
|
24634
|
-
if (!prev[
|
|
24632
|
+
const { streamId } = curr, rest = __rest(curr, ["streamId"]);
|
|
24633
|
+
if (!prev[streamId]) {
|
|
24635
24634
|
// eslint-disable-next-line no-param-reassign
|
|
24636
|
-
prev[
|
|
24635
|
+
prev[streamId] = [rest];
|
|
24637
24636
|
}
|
|
24638
24637
|
else
|
|
24639
|
-
prev[
|
|
24638
|
+
prev[streamId].push(rest);
|
|
24640
24639
|
return prev;
|
|
24641
24640
|
}, {});
|
|
24642
24641
|
// Call server api `POST /api/v1/reactions/live` to sync live reactions
|
|
24643
|
-
Object.entries(payloads).forEach(([
|
|
24642
|
+
Object.entries(payloads).forEach(([streamId, reactions]) => {
|
|
24644
24643
|
createLiveReaction({
|
|
24645
|
-
|
|
24644
|
+
liveStreamId: streamId,
|
|
24646
24645
|
reactions,
|
|
24647
24646
|
});
|
|
24648
24647
|
});
|
|
@@ -25135,6 +25134,23 @@ const loginAsVisitor = async (params) => {
|
|
|
25135
25134
|
};
|
|
25136
25135
|
/* end_public_function */
|
|
25137
25136
|
|
|
25137
|
+
/* begin_public_function
|
|
25138
|
+
id: client.get_current_user
|
|
25139
|
+
*/
|
|
25140
|
+
const getCurrentUser = () => {
|
|
25141
|
+
var _a;
|
|
25142
|
+
const client = getActiveClient();
|
|
25143
|
+
if (!client) {
|
|
25144
|
+
throw new ASCError('Connect client first', 800000 /* Amity.ClientError.UNKNOWN_ERROR */, "fatal" /* Amity.ErrorLevel.FATAL */);
|
|
25145
|
+
}
|
|
25146
|
+
const cache = (_a = pullFromCache(['user', 'get', client.userId])) === null || _a === void 0 ? void 0 : _a.data;
|
|
25147
|
+
if (!cache) {
|
|
25148
|
+
throw new ASCError('Connect client first', 800000 /* Amity.ClientError.UNKNOWN_ERROR */, "fatal" /* Amity.ErrorLevel.FATAL */);
|
|
25149
|
+
}
|
|
25150
|
+
return userLinkedObject(cache);
|
|
25151
|
+
};
|
|
25152
|
+
/* end_public_function */
|
|
25153
|
+
|
|
25138
25154
|
/* begin_public_function
|
|
25139
25155
|
id: client.renew_access_token
|
|
25140
25156
|
*/
|
|
@@ -28136,7 +28152,7 @@ getChannel$1.locally = (channelId) => {
|
|
|
28136
28152
|
* @category Stream API
|
|
28137
28153
|
* @async
|
|
28138
28154
|
*/
|
|
28139
|
-
const getLiveChat
|
|
28155
|
+
const getLiveChat = async (stream) => {
|
|
28140
28156
|
var _a;
|
|
28141
28157
|
const client = getActiveClient();
|
|
28142
28158
|
client.log('stream/getLiveChat', stream.streamId);
|
|
@@ -28203,7 +28219,7 @@ const streamLinkedObject = (stream) => {
|
|
|
28203
28219
|
return streamLinkedObject(streamCache);
|
|
28204
28220
|
})
|
|
28205
28221
|
.filter(isNonNullable);
|
|
28206
|
-
}, getLiveChat: () => getLiveChat
|
|
28222
|
+
}, getLiveChat: () => getLiveChat(stream), isBanned: !stream.watcherUrl, watcherUrl: null, get [GET_WATCHER_URLS]() {
|
|
28207
28223
|
return stream.watcherUrl;
|
|
28208
28224
|
} });
|
|
28209
28225
|
};
|
|
@@ -28311,95 +28327,6 @@ function isAmityAudioPost(post) {
|
|
|
28311
28327
|
'fileId' in post.data &&
|
|
28312
28328
|
post.dataType === 'audio');
|
|
28313
28329
|
}
|
|
28314
|
-
function isAmityRoomPost(post) {
|
|
28315
|
-
return !!(post.data &&
|
|
28316
|
-
typeof post.data !== 'string' &&
|
|
28317
|
-
'roomId' in post.data &&
|
|
28318
|
-
post.dataType === 'room');
|
|
28319
|
-
}
|
|
28320
|
-
|
|
28321
|
-
/**
|
|
28322
|
-
* ```js
|
|
28323
|
-
* import { RoomRepository } from '@amityco/ts-sdk'
|
|
28324
|
-
* const stream = await getStream('foobar')
|
|
28325
|
-
* ```
|
|
28326
|
-
*
|
|
28327
|
-
* Fetches a {@link Amity.Channel} object linked with a current stream
|
|
28328
|
-
*
|
|
28329
|
-
* @param stream {@link Amity.Stream} that has linked live channel
|
|
28330
|
-
* @returns the associated {@link Amity.Channel<'live'>} object
|
|
28331
|
-
*
|
|
28332
|
-
* @category Stream API
|
|
28333
|
-
* @async
|
|
28334
|
-
*/
|
|
28335
|
-
const getLiveChat = async (room) => {
|
|
28336
|
-
var _a;
|
|
28337
|
-
const client = getActiveClient();
|
|
28338
|
-
client.log('room/getLiveChat', room.roomId);
|
|
28339
|
-
if (room.liveChannelId) {
|
|
28340
|
-
const channel = (_a = pullFromCache([
|
|
28341
|
-
'channel',
|
|
28342
|
-
'get',
|
|
28343
|
-
room.liveChannelId,
|
|
28344
|
-
])) === null || _a === void 0 ? void 0 : _a.data;
|
|
28345
|
-
if (channel)
|
|
28346
|
-
return channelLinkedObject(constructChannelObject(channel));
|
|
28347
|
-
const { data } = await getChannel$1(room.liveChannelId);
|
|
28348
|
-
return channelLinkedObject(constructChannelObject(data));
|
|
28349
|
-
}
|
|
28350
|
-
// No Channel ID
|
|
28351
|
-
// streamer: create a new live channel
|
|
28352
|
-
if (room.createdBy === client.userId) {
|
|
28353
|
-
const { data: channel } = await createChannel({
|
|
28354
|
-
type: 'live',
|
|
28355
|
-
postId: room.referenceId,
|
|
28356
|
-
roomId: room.roomId,
|
|
28357
|
-
});
|
|
28358
|
-
// Update channelId to stream object in cache
|
|
28359
|
-
mergeInCache(['room', 'get', room.roomId], {
|
|
28360
|
-
liveChannelId: channel.channelId,
|
|
28361
|
-
});
|
|
28362
|
-
return channel;
|
|
28363
|
-
}
|
|
28364
|
-
// watcher: return undefined
|
|
28365
|
-
return undefined;
|
|
28366
|
-
};
|
|
28367
|
-
|
|
28368
|
-
const roomLinkedObject = (room) => {
|
|
28369
|
-
return Object.assign(Object.assign({}, room), { get moderation() {
|
|
28370
|
-
var _a;
|
|
28371
|
-
return (_a = pullFromCache(['roomModeration', 'get', room.roomId])) === null || _a === void 0 ? void 0 : _a.data;
|
|
28372
|
-
},
|
|
28373
|
-
get post() {
|
|
28374
|
-
var _a;
|
|
28375
|
-
if (room.referenceType !== 'post')
|
|
28376
|
-
return;
|
|
28377
|
-
return (_a = pullFromCache(['post', 'get', room.referenceId])) === null || _a === void 0 ? void 0 : _a.data;
|
|
28378
|
-
},
|
|
28379
|
-
get community() {
|
|
28380
|
-
var _a;
|
|
28381
|
-
if (room.targetType !== 'community')
|
|
28382
|
-
return;
|
|
28383
|
-
return (_a = pullFromCache(['community', 'get', room.targetId])) === null || _a === void 0 ? void 0 : _a.data;
|
|
28384
|
-
},
|
|
28385
|
-
get user() {
|
|
28386
|
-
var _a;
|
|
28387
|
-
return (_a = pullFromCache(['user', 'get', room.createdBy])) === null || _a === void 0 ? void 0 : _a.data;
|
|
28388
|
-
},
|
|
28389
|
-
get childRooms() {
|
|
28390
|
-
if (!room.childRoomIds || room.childRoomIds.length === 0)
|
|
28391
|
-
return [];
|
|
28392
|
-
return room.childRoomIds
|
|
28393
|
-
.map(id => {
|
|
28394
|
-
var _a;
|
|
28395
|
-
const roomCache = (_a = pullFromCache(['room', 'get', id])) === null || _a === void 0 ? void 0 : _a.data;
|
|
28396
|
-
if (!roomCache)
|
|
28397
|
-
return undefined;
|
|
28398
|
-
return roomLinkedObject(roomCache);
|
|
28399
|
-
})
|
|
28400
|
-
.filter(isNonNullable);
|
|
28401
|
-
}, getLiveChat: () => getLiveChat(room) });
|
|
28402
|
-
};
|
|
28403
28330
|
|
|
28404
28331
|
const postLinkedObject = (post) => {
|
|
28405
28332
|
return shallowClone(post, {
|
|
@@ -28494,13 +28421,6 @@ const postLinkedObject = (post) => {
|
|
|
28494
28421
|
? (_b = pullFromCache(['file', 'get', (_a = post === null || post === void 0 ? void 0 : post.data) === null || _a === void 0 ? void 0 : _a.fileId])) === null || _b === void 0 ? void 0 : _b.data
|
|
28495
28422
|
: undefined;
|
|
28496
28423
|
},
|
|
28497
|
-
getRoomInfo() {
|
|
28498
|
-
var _a, _b;
|
|
28499
|
-
if (!isAmityRoomPost(post))
|
|
28500
|
-
return;
|
|
28501
|
-
const room = (_b = pullFromCache(['room', 'get', (_a = post === null || post === void 0 ? void 0 : post.data) === null || _a === void 0 ? void 0 : _a.roomId])) === null || _b === void 0 ? void 0 : _b.data;
|
|
28502
|
-
return room ? roomLinkedObject(room) : undefined;
|
|
28503
|
-
},
|
|
28504
28424
|
});
|
|
28505
28425
|
};
|
|
28506
28426
|
|
|
@@ -29858,6 +29778,51 @@ const communityLinkedObject = (community) => {
|
|
|
29858
29778
|
} });
|
|
29859
29779
|
};
|
|
29860
29780
|
|
|
29781
|
+
const eventLinkedObject = (event) => {
|
|
29782
|
+
return Object.assign(Object.assign({}, event), { get creator() {
|
|
29783
|
+
const cacheData = pullFromCache(['user', 'get', event.userId]);
|
|
29784
|
+
if (!(cacheData === null || cacheData === void 0 ? void 0 : cacheData.data))
|
|
29785
|
+
return;
|
|
29786
|
+
return userLinkedObject(cacheData.data);
|
|
29787
|
+
},
|
|
29788
|
+
get discussionCommunity() {
|
|
29789
|
+
if (!event.discussionCommunityId)
|
|
29790
|
+
return;
|
|
29791
|
+
const cacheData = pullFromCache([
|
|
29792
|
+
'discussionCommunity',
|
|
29793
|
+
'get',
|
|
29794
|
+
event.discussionCommunityId,
|
|
29795
|
+
]);
|
|
29796
|
+
if (!(cacheData === null || cacheData === void 0 ? void 0 : cacheData.data))
|
|
29797
|
+
return;
|
|
29798
|
+
return communityLinkedObject(cacheData.data);
|
|
29799
|
+
},
|
|
29800
|
+
get targetCommunity() {
|
|
29801
|
+
if (!event.originId)
|
|
29802
|
+
return;
|
|
29803
|
+
const cacheData = pullFromCache(['community', 'get', event.originId]);
|
|
29804
|
+
if (!(cacheData === null || cacheData === void 0 ? void 0 : cacheData.data))
|
|
29805
|
+
return;
|
|
29806
|
+
return communityLinkedObject(cacheData.data);
|
|
29807
|
+
},
|
|
29808
|
+
get coverImage() {
|
|
29809
|
+
if (!event.coverImageFileId)
|
|
29810
|
+
return;
|
|
29811
|
+
const cacheData = pullFromCache(['file', 'get', event.coverImageFileId]);
|
|
29812
|
+
if (!(cacheData === null || cacheData === void 0 ? void 0 : cacheData.data))
|
|
29813
|
+
return;
|
|
29814
|
+
return cacheData.data;
|
|
29815
|
+
},
|
|
29816
|
+
get liveStream() {
|
|
29817
|
+
if (!event.livestreamId)
|
|
29818
|
+
return;
|
|
29819
|
+
const cacheData = pullFromCache(['stream', 'get', event.livestreamId]);
|
|
29820
|
+
if (!(cacheData === null || cacheData === void 0 ? void 0 : cacheData.data))
|
|
29821
|
+
return;
|
|
29822
|
+
return cacheData.data;
|
|
29823
|
+
} });
|
|
29824
|
+
};
|
|
29825
|
+
|
|
29861
29826
|
const LinkedObject = {
|
|
29862
29827
|
ad: adLinkedObject,
|
|
29863
29828
|
comment: commentLinkedObject,
|
|
@@ -29876,7 +29841,7 @@ const LinkedObject = {
|
|
|
29876
29841
|
invitation: invitationLinkedObject,
|
|
29877
29842
|
joinRequest: joinRequestLinkedObject,
|
|
29878
29843
|
channelMember: channelMemberLinkedObject,
|
|
29879
|
-
|
|
29844
|
+
event: eventLinkedObject,
|
|
29880
29845
|
};
|
|
29881
29846
|
|
|
29882
29847
|
/* begin_public_function
|
|
@@ -43861,735 +43826,6 @@ var index$8 = /*#__PURE__*/Object.freeze({
|
|
|
43861
43826
|
getStreams: getStreams
|
|
43862
43827
|
});
|
|
43863
43828
|
|
|
43864
|
-
/* begin_public_function
|
|
43865
|
-
id: room.create
|
|
43866
|
-
*/
|
|
43867
|
-
/**
|
|
43868
|
-
* ```js
|
|
43869
|
-
* import { createRoom } from '@amityco/ts-sdk'
|
|
43870
|
-
* const created = await createRoom({ title: 'my room', 'thumbnailFileId': fileId })
|
|
43871
|
-
* ```
|
|
43872
|
-
*
|
|
43873
|
-
* Creates an {@link Amity.Room}
|
|
43874
|
-
*
|
|
43875
|
-
* @param bundle The data necessary to create a new {@link Amity.Room}
|
|
43876
|
-
* @returns The newly created {@link Amity.Room}
|
|
43877
|
-
*
|
|
43878
|
-
* @category Room API
|
|
43879
|
-
* @async
|
|
43880
|
-
*/
|
|
43881
|
-
const createRoom = async (bundle) => {
|
|
43882
|
-
const client = getActiveClient();
|
|
43883
|
-
client.log('room/createRoom', bundle);
|
|
43884
|
-
const { data } = await client.http.post('/api/v1/rooms', bundle);
|
|
43885
|
-
fireEvent('local.room.created', data);
|
|
43886
|
-
const cachedAt = client.cache && Date.now();
|
|
43887
|
-
// TODO: check if should pick `users` filed which contains participants - if no need to ingest in the cache
|
|
43888
|
-
if (client.cache)
|
|
43889
|
-
ingestInCache(data, { cachedAt });
|
|
43890
|
-
const { rooms } = data;
|
|
43891
|
-
return {
|
|
43892
|
-
data: roomLinkedObject(rooms[0]),
|
|
43893
|
-
cachedAt,
|
|
43894
|
-
};
|
|
43895
|
-
};
|
|
43896
|
-
/* end_public_function */
|
|
43897
|
-
|
|
43898
|
-
/* begin_public_function
|
|
43899
|
-
id: room.update
|
|
43900
|
-
*/
|
|
43901
|
-
/**
|
|
43902
|
-
* ```js
|
|
43903
|
-
* import { updateRoom } from '@amityco/ts-sdk'
|
|
43904
|
-
* const updated = await updateRoom('roomId', { title: 'updated title' })
|
|
43905
|
-
* ```
|
|
43906
|
-
*
|
|
43907
|
-
* Updates an {@link Amity.InternalRoom}
|
|
43908
|
-
*
|
|
43909
|
-
* @param roomId The ID of the room to update
|
|
43910
|
-
* @param bundle The data to update the room with
|
|
43911
|
-
* @returns The updated {@link Amity.InternalRoom}
|
|
43912
|
-
*
|
|
43913
|
-
* @category Room API
|
|
43914
|
-
* @async
|
|
43915
|
-
*/
|
|
43916
|
-
const updateRoom = async (roomId, bundle) => {
|
|
43917
|
-
const client = getActiveClient();
|
|
43918
|
-
client.log('room/updateRoom', { roomId, bundle });
|
|
43919
|
-
const { data } = await client.http.put(`/api/v1/rooms/${roomId}`, bundle);
|
|
43920
|
-
fireEvent('local.room.updated', data);
|
|
43921
|
-
const cachedAt = client.cache && Date.now();
|
|
43922
|
-
if (client.cache)
|
|
43923
|
-
ingestInCache(data, { cachedAt });
|
|
43924
|
-
const { rooms } = data;
|
|
43925
|
-
return {
|
|
43926
|
-
data: roomLinkedObject(rooms[0]),
|
|
43927
|
-
cachedAt,
|
|
43928
|
-
};
|
|
43929
|
-
};
|
|
43930
|
-
/* end_public_function */
|
|
43931
|
-
|
|
43932
|
-
/* begin_public_function
|
|
43933
|
-
id: room.delete
|
|
43934
|
-
*/
|
|
43935
|
-
/**
|
|
43936
|
-
* ```js
|
|
43937
|
-
* import { deleteRoom } from '@amityco/ts-sdk'
|
|
43938
|
-
* const result = await deleteRoom('roomId')
|
|
43939
|
-
* ```
|
|
43940
|
-
*
|
|
43941
|
-
* Deletes an {@link Amity.Room}
|
|
43942
|
-
*
|
|
43943
|
-
* @param roomId The ID of the room to delete
|
|
43944
|
-
* @returns Promise that resolves when the room is deleted
|
|
43945
|
-
*
|
|
43946
|
-
* @category Room API
|
|
43947
|
-
* @async
|
|
43948
|
-
*/
|
|
43949
|
-
const deleteRoom = async (roomId) => {
|
|
43950
|
-
const client = getActiveClient();
|
|
43951
|
-
client.log('room/deleteRoom', { roomId });
|
|
43952
|
-
await client.http.delete(`/api/v1/rooms/${roomId}`);
|
|
43953
|
-
fireEvent('local.room.deleted', { rooms: [{ _id: roomId }] });
|
|
43954
|
-
};
|
|
43955
|
-
/* end_public_function */
|
|
43956
|
-
|
|
43957
|
-
/* begin_public_function
|
|
43958
|
-
id: room.stop
|
|
43959
|
-
*/
|
|
43960
|
-
/**
|
|
43961
|
-
* ```js
|
|
43962
|
-
* import { stopRoom } from '@amityco/ts-sdk'
|
|
43963
|
-
* const result = await stopRoom('roomId')
|
|
43964
|
-
* ```
|
|
43965
|
-
*
|
|
43966
|
-
* Stops a room's broadcasting
|
|
43967
|
-
*
|
|
43968
|
-
* @param roomId The ID of the room to stop
|
|
43969
|
-
* @returns The updated room data
|
|
43970
|
-
*
|
|
43971
|
-
* @category Room API
|
|
43972
|
-
* @async
|
|
43973
|
-
*/
|
|
43974
|
-
const stopRoom = async (roomId) => {
|
|
43975
|
-
const client = getActiveClient();
|
|
43976
|
-
client.log('room/stopRoom', { roomId });
|
|
43977
|
-
const { data } = await client.http.post(`/api/v1/rooms/${roomId}/stop`);
|
|
43978
|
-
fireEvent('local.room.stopped', data);
|
|
43979
|
-
const cachedAt = client.cache && Date.now();
|
|
43980
|
-
if (client.cache)
|
|
43981
|
-
ingestInCache(data, { cachedAt });
|
|
43982
|
-
const { rooms } = data;
|
|
43983
|
-
return {
|
|
43984
|
-
data: rooms[0],
|
|
43985
|
-
cachedAt,
|
|
43986
|
-
};
|
|
43987
|
-
};
|
|
43988
|
-
/* end_public_function */
|
|
43989
|
-
|
|
43990
|
-
/* begin_public_function
|
|
43991
|
-
id: room.getBroadcasterData
|
|
43992
|
-
*/
|
|
43993
|
-
/**
|
|
43994
|
-
* ```js
|
|
43995
|
-
* import { getBroadcasterData } from '@amityco/ts-sdk'
|
|
43996
|
-
* const token = await getBroadcasterData('roomId')
|
|
43997
|
-
* ```
|
|
43998
|
-
*
|
|
43999
|
-
* Gets broadcaster data for a room
|
|
44000
|
-
*
|
|
44001
|
-
* @param roomId The ID of the room to get token for
|
|
44002
|
-
* @returns The broadcaster data of the room including coHostToken, coHostUrl and direactStreamUrl
|
|
44003
|
-
*
|
|
44004
|
-
* @category Room API
|
|
44005
|
-
* @async
|
|
44006
|
-
*/
|
|
44007
|
-
const getBroadcasterData = async (roomId) => {
|
|
44008
|
-
const client = getActiveClient();
|
|
44009
|
-
client.log('room/getBroadcasterData', { roomId });
|
|
44010
|
-
const { data } = await client.http.get(`/api/v1/rooms/${roomId}/token`);
|
|
44011
|
-
return data;
|
|
44012
|
-
};
|
|
44013
|
-
/* end_public_function */
|
|
44014
|
-
|
|
44015
|
-
/* begin_public_function
|
|
44016
|
-
id: room.getRecordedUrl
|
|
44017
|
-
*/
|
|
44018
|
-
/**
|
|
44019
|
-
* ```js
|
|
44020
|
-
* import { getRecordedUrl } from '@amityco/ts-sdk'
|
|
44021
|
-
* const recordedUrl = await getRecordedUrl('roomId')
|
|
44022
|
-
* ```
|
|
44023
|
-
*
|
|
44024
|
-
* Gets the recorded URL for a room
|
|
44025
|
-
*
|
|
44026
|
-
* @param roomId The ID of the room to get recorded URL for
|
|
44027
|
-
* @returns The recorded URL information
|
|
44028
|
-
*
|
|
44029
|
-
* @category Room API
|
|
44030
|
-
* @async
|
|
44031
|
-
*/
|
|
44032
|
-
const getRecordedUrl = async (roomId) => {
|
|
44033
|
-
const client = getActiveClient();
|
|
44034
|
-
client.log('room/getRecordedUrl', { roomId });
|
|
44035
|
-
const { data } = await client.http.get(`/api/v1/rooms/${roomId}/recorded`);
|
|
44036
|
-
return data;
|
|
44037
|
-
};
|
|
44038
|
-
/* end_public_function */
|
|
44039
|
-
|
|
44040
|
-
/**
|
|
44041
|
-
* ```js
|
|
44042
|
-
* import { onRoomStartBroadcasting } from '@amityco/ts-sdk'
|
|
44043
|
-
* const dispose = onRoomStartBroadcasting(room => {
|
|
44044
|
-
* // ...
|
|
44045
|
-
* })
|
|
44046
|
-
* ```
|
|
44047
|
-
*
|
|
44048
|
-
* Fired when a {@link Amity.Room} has started broadcasting
|
|
44049
|
-
*
|
|
44050
|
-
* @param callback The function to call when the event was fired
|
|
44051
|
-
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
44052
|
-
*
|
|
44053
|
-
* @category Room Events
|
|
44054
|
-
*/
|
|
44055
|
-
const onRoomStartBroadcasting = (callback) => {
|
|
44056
|
-
const client = getActiveClient();
|
|
44057
|
-
const filter = (payload) => {
|
|
44058
|
-
ingestInCache(payload);
|
|
44059
|
-
callback(payload.rooms[0]);
|
|
44060
|
-
};
|
|
44061
|
-
return createEventSubscriber(client, 'room/onRoomStartBroadcasting', 'room.startBroadcasting', filter);
|
|
44062
|
-
};
|
|
44063
|
-
|
|
44064
|
-
/**
|
|
44065
|
-
* ```js
|
|
44066
|
-
* import { onRoomWaitingReconnect } from '@amityco/ts-sdk'
|
|
44067
|
-
* const dispose = onRoomWaitingReconnect(room => {
|
|
44068
|
-
* // ...
|
|
44069
|
-
* })
|
|
44070
|
-
* ```
|
|
44071
|
-
*
|
|
44072
|
-
* Fired when a {@link Amity.Room} is waiting for reconnection
|
|
44073
|
-
*
|
|
44074
|
-
* @param callback The function to call when the event was fired
|
|
44075
|
-
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
44076
|
-
*
|
|
44077
|
-
* @category Room Events
|
|
44078
|
-
*/
|
|
44079
|
-
const onRoomWaitingReconnect = (callback) => {
|
|
44080
|
-
const client = getActiveClient();
|
|
44081
|
-
const filter = (payload) => {
|
|
44082
|
-
ingestInCache(payload);
|
|
44083
|
-
callback(payload.rooms[0]);
|
|
44084
|
-
};
|
|
44085
|
-
return createEventSubscriber(client, 'room/onRoomWaitingReconnect', 'room.waitingReconnect', filter);
|
|
44086
|
-
};
|
|
44087
|
-
|
|
44088
|
-
/**
|
|
44089
|
-
* ```js
|
|
44090
|
-
* import { onRoomEndBroadcasting } from '@amityco/ts-sdk'
|
|
44091
|
-
* const dispose = onRoomEndBroadcasting(room => {
|
|
44092
|
-
* // ...
|
|
44093
|
-
* })
|
|
44094
|
-
* ```
|
|
44095
|
-
*
|
|
44096
|
-
* Fired when a {@link Amity.Room} has ended broadcasting
|
|
44097
|
-
*
|
|
44098
|
-
* @param callback The function to call when the event was fired
|
|
44099
|
-
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
44100
|
-
*
|
|
44101
|
-
* @category Room Events
|
|
44102
|
-
*/
|
|
44103
|
-
const onRoomEndBroadcasting = (callback) => {
|
|
44104
|
-
const client = getActiveClient();
|
|
44105
|
-
const filter = (payload) => {
|
|
44106
|
-
ingestInCache(payload);
|
|
44107
|
-
callback(payload.rooms[0]);
|
|
44108
|
-
};
|
|
44109
|
-
return createEventSubscriber(client, 'room/onRoomEndBroadcasting', 'room.endBroadcasting', filter);
|
|
44110
|
-
};
|
|
44111
|
-
|
|
44112
|
-
/**
|
|
44113
|
-
* ```js
|
|
44114
|
-
* import { onRoomRecordedAvailable } from '@amityco/ts-sdk'
|
|
44115
|
-
* const dispose = onRoomRecordedAvailable(room => {
|
|
44116
|
-
* // ...
|
|
44117
|
-
* })
|
|
44118
|
-
* ```
|
|
44119
|
-
*
|
|
44120
|
-
* Fired when a {@link Amity.Room} recorded content becomes available
|
|
44121
|
-
*
|
|
44122
|
-
* @param callback The function to call when the event was fired
|
|
44123
|
-
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
44124
|
-
*
|
|
44125
|
-
* @category Room Events
|
|
44126
|
-
*/
|
|
44127
|
-
const onRoomRecordedAvailable = (callback) => {
|
|
44128
|
-
const client = getActiveClient();
|
|
44129
|
-
const filter = (payload) => {
|
|
44130
|
-
ingestInCache(payload);
|
|
44131
|
-
callback(payload.rooms[0]);
|
|
44132
|
-
};
|
|
44133
|
-
return createEventSubscriber(client, 'room/onRoomRecordedAvailable', 'room.recordedAvailable', filter);
|
|
44134
|
-
};
|
|
44135
|
-
|
|
44136
|
-
/**
|
|
44137
|
-
* ```js
|
|
44138
|
-
* import { onRoomParticipantInviting } from '@amityco/ts-sdk'
|
|
44139
|
-
* const dispose = onRoomParticipantInviting(room => {
|
|
44140
|
-
* // ...
|
|
44141
|
-
* })
|
|
44142
|
-
* ```
|
|
44143
|
-
*
|
|
44144
|
-
* Fired when a participant is being invited to a {@link Amity.Room}
|
|
44145
|
-
*
|
|
44146
|
-
* @param callback The function to call when the event was fired
|
|
44147
|
-
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
44148
|
-
*
|
|
44149
|
-
* @category Room Events
|
|
44150
|
-
*/
|
|
44151
|
-
const onRoomParticipantInviting = (callback) => {
|
|
44152
|
-
const client = getActiveClient();
|
|
44153
|
-
const filter = (payload) => {
|
|
44154
|
-
ingestInCache(payload);
|
|
44155
|
-
callback(payload.rooms[0]);
|
|
44156
|
-
};
|
|
44157
|
-
return createEventSubscriber(client, 'room/onRoomParticipantInviting', 'room.participantInviting', filter);
|
|
44158
|
-
};
|
|
44159
|
-
|
|
44160
|
-
/**
|
|
44161
|
-
* ```js
|
|
44162
|
-
* import { onRoomParticipantJoined } from '@amityco/ts-sdk'
|
|
44163
|
-
* const dispose = onRoomParticipantJoined(room => {
|
|
44164
|
-
* // ...
|
|
44165
|
-
* })
|
|
44166
|
-
* ```
|
|
44167
|
-
*
|
|
44168
|
-
* Fired when a participant has joined a {@link Amity.Room}
|
|
44169
|
-
*
|
|
44170
|
-
* @param callback The function to call when the event was fired
|
|
44171
|
-
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
44172
|
-
*
|
|
44173
|
-
* @category Room Events
|
|
44174
|
-
*/
|
|
44175
|
-
const onRoomParticipantJoined = (callback) => {
|
|
44176
|
-
const client = getActiveClient();
|
|
44177
|
-
const filter = (payload) => {
|
|
44178
|
-
ingestInCache(payload);
|
|
44179
|
-
callback(payload.rooms[0]);
|
|
44180
|
-
};
|
|
44181
|
-
return createEventSubscriber(client, 'room/onRoomParticipantJoined', 'room.participantJoined', filter);
|
|
44182
|
-
};
|
|
44183
|
-
|
|
44184
|
-
/**
|
|
44185
|
-
* ```js
|
|
44186
|
-
* import { onRoomParticipantLeft } from '@amityco/ts-sdk'
|
|
44187
|
-
* const dispose = onRoomParticipantLeft(room => {
|
|
44188
|
-
* // ...
|
|
44189
|
-
* })
|
|
44190
|
-
* ```
|
|
44191
|
-
*
|
|
44192
|
-
* Fired when a participant has left a {@link Amity.Room}
|
|
44193
|
-
*
|
|
44194
|
-
* @param callback The function to call when the event was fired
|
|
44195
|
-
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
44196
|
-
*
|
|
44197
|
-
* @category Room Events
|
|
44198
|
-
*/
|
|
44199
|
-
const onRoomParticipantLeft = (callback) => {
|
|
44200
|
-
const client = getActiveClient();
|
|
44201
|
-
const filter = (payload) => {
|
|
44202
|
-
ingestInCache(payload);
|
|
44203
|
-
callback(payload.rooms[0]);
|
|
44204
|
-
};
|
|
44205
|
-
return createEventSubscriber(client, 'room/onRoomParticipantLeft', 'room.participantLeft', filter);
|
|
44206
|
-
};
|
|
44207
|
-
|
|
44208
|
-
/**
|
|
44209
|
-
* ```js
|
|
44210
|
-
* import { onRoomCreated } from '@amityco/ts-sdk'
|
|
44211
|
-
* const dispose = onRoomCreated(room => {
|
|
44212
|
-
* // ...
|
|
44213
|
-
* })
|
|
44214
|
-
* ```
|
|
44215
|
-
*
|
|
44216
|
-
* Fired when a {@link Amity.Room} has been created locally
|
|
44217
|
-
*
|
|
44218
|
-
* @param callback The function to call when the event was fired
|
|
44219
|
-
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
44220
|
-
*
|
|
44221
|
-
* @category Room Events
|
|
44222
|
-
*/
|
|
44223
|
-
const onRoomCreated = (callback) => {
|
|
44224
|
-
const client = getActiveClient();
|
|
44225
|
-
const filter = (payload) => {
|
|
44226
|
-
ingestInCache(payload);
|
|
44227
|
-
callback(payload.rooms[0]);
|
|
44228
|
-
};
|
|
44229
|
-
return createEventSubscriber(client, 'room/onRoomCreated', 'local.room.created', filter);
|
|
44230
|
-
};
|
|
44231
|
-
|
|
44232
|
-
/**
|
|
44233
|
-
* ```js
|
|
44234
|
-
* import { onRoomUpdated } from '@amityco/ts-sdk'
|
|
44235
|
-
* const dispose = onRoomUpdated(room => {
|
|
44236
|
-
* // ...
|
|
44237
|
-
* })
|
|
44238
|
-
* ```
|
|
44239
|
-
*
|
|
44240
|
-
* Fired when a {@link Amity.Room} has been updated locally
|
|
44241
|
-
*
|
|
44242
|
-
* @param callback The function to call when the event was fired
|
|
44243
|
-
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
44244
|
-
*
|
|
44245
|
-
* @category Room Events
|
|
44246
|
-
*/
|
|
44247
|
-
const onRoomUpdated = (callback) => {
|
|
44248
|
-
const client = getActiveClient();
|
|
44249
|
-
const filter = (payload) => {
|
|
44250
|
-
ingestInCache(payload);
|
|
44251
|
-
callback(payload.rooms[0]);
|
|
44252
|
-
};
|
|
44253
|
-
return createEventSubscriber(client, 'room/onRoomUpdated', 'local.room.updated', filter);
|
|
44254
|
-
};
|
|
44255
|
-
|
|
44256
|
-
/**
|
|
44257
|
-
* ```js
|
|
44258
|
-
* import { onRoomDeleted } from '@amityco/ts-sdk'
|
|
44259
|
-
* const dispose = onRoomDeleted(room => {
|
|
44260
|
-
* // ...
|
|
44261
|
-
* })
|
|
44262
|
-
* ```
|
|
44263
|
-
*
|
|
44264
|
-
* Fired when a {@link Amity.Room} has been deleted locally
|
|
44265
|
-
*
|
|
44266
|
-
* @param callback The function to call when the event was fired
|
|
44267
|
-
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
44268
|
-
*
|
|
44269
|
-
* @category Room Events
|
|
44270
|
-
*/
|
|
44271
|
-
const onRoomDeleted = (callback) => {
|
|
44272
|
-
const client = getActiveClient();
|
|
44273
|
-
const filter = (payload) => {
|
|
44274
|
-
ingestInCache(payload);
|
|
44275
|
-
callback(payload.rooms[0]);
|
|
44276
|
-
};
|
|
44277
|
-
return createEventSubscriber(client, 'room/onRoomDeleted', 'local.room.deleted', filter);
|
|
44278
|
-
};
|
|
44279
|
-
|
|
44280
|
-
/**
|
|
44281
|
-
* ```js
|
|
44282
|
-
* import { onRoomStopped } from '@amityco/ts-sdk'
|
|
44283
|
-
* const dispose = onRoomStopped(room => {
|
|
44284
|
-
* // ...
|
|
44285
|
-
* })
|
|
44286
|
-
* ```
|
|
44287
|
-
*
|
|
44288
|
-
* Fired when a {@link Amity.Room} has been stopped locally
|
|
44289
|
-
*
|
|
44290
|
-
* @param callback The function to call when the event was fired
|
|
44291
|
-
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
44292
|
-
*
|
|
44293
|
-
* @category Room Events
|
|
44294
|
-
*/
|
|
44295
|
-
const onRoomStopped = (callback) => {
|
|
44296
|
-
const client = getActiveClient();
|
|
44297
|
-
const filter = (payload) => {
|
|
44298
|
-
ingestInCache(payload);
|
|
44299
|
-
callback(payload.rooms[0]);
|
|
44300
|
-
};
|
|
44301
|
-
return createEventSubscriber(client, 'room/onRoomStopped', 'local.room.stopped', filter);
|
|
44302
|
-
};
|
|
44303
|
-
|
|
44304
|
-
const getRoomById = async (roomId) => {
|
|
44305
|
-
const client = getActiveClient();
|
|
44306
|
-
client.log('room/getRoomById', roomId);
|
|
44307
|
-
// Check if room is in tombstone
|
|
44308
|
-
isInTombstone('room', roomId);
|
|
44309
|
-
let data;
|
|
44310
|
-
try {
|
|
44311
|
-
const response = await client.http.get(`/api/v1/rooms/${roomId}`);
|
|
44312
|
-
data = response.data;
|
|
44313
|
-
}
|
|
44314
|
-
catch (error) {
|
|
44315
|
-
if (checkIfShouldGoesToTombstone(error === null || error === void 0 ? void 0 : error.code)) {
|
|
44316
|
-
pushToTombstone('room', roomId);
|
|
44317
|
-
}
|
|
44318
|
-
throw error;
|
|
44319
|
-
}
|
|
44320
|
-
const cachedAt = client.cache && Date.now();
|
|
44321
|
-
if (client.cache) {
|
|
44322
|
-
ingestInCache(data, { cachedAt });
|
|
44323
|
-
}
|
|
44324
|
-
return {
|
|
44325
|
-
data: data.rooms[0],
|
|
44326
|
-
cachedAt,
|
|
44327
|
-
};
|
|
44328
|
-
};
|
|
44329
|
-
getRoomById.locally = (roomId) => {
|
|
44330
|
-
const client = getActiveClient();
|
|
44331
|
-
client.log('room/getRoomById.locally', roomId);
|
|
44332
|
-
// Check if room is in tombstone
|
|
44333
|
-
isInTombstone('room', roomId);
|
|
44334
|
-
const cachedAt = client.cache && Date.now();
|
|
44335
|
-
const roomCache = pullFromCache(['room', 'get', roomId]);
|
|
44336
|
-
if (!roomCache)
|
|
44337
|
-
return;
|
|
44338
|
-
return {
|
|
44339
|
-
data: roomCache.data,
|
|
44340
|
-
cachedAt,
|
|
44341
|
-
};
|
|
44342
|
-
};
|
|
44343
|
-
|
|
44344
|
-
const getRoom = (roomId, callback) => {
|
|
44345
|
-
// TODO: add callbackDataSelector if there are linked object fields
|
|
44346
|
-
return liveObject(roomId, callback, '_id', getRoomById, [
|
|
44347
|
-
onRoomEndBroadcasting,
|
|
44348
|
-
onRoomStartBroadcasting,
|
|
44349
|
-
onRoomWaitingReconnect,
|
|
44350
|
-
onRoomRecordedAvailable,
|
|
44351
|
-
], {
|
|
44352
|
-
callbackDataSelector: (data) => {
|
|
44353
|
-
if (!data)
|
|
44354
|
-
return data;
|
|
44355
|
-
return LinkedObject.room(data);
|
|
44356
|
-
},
|
|
44357
|
-
});
|
|
44358
|
-
};
|
|
44359
|
-
|
|
44360
|
-
class RoomPaginationController extends PaginationController {
|
|
44361
|
-
async getRequest(queryParams, token) {
|
|
44362
|
-
const { limit = COLLECTION_DEFAULT_PAGINATION_LIMIT, includeDeleted } = queryParams, params = __rest(queryParams, ["limit", "includeDeleted"]);
|
|
44363
|
-
const baseOptions = {
|
|
44364
|
-
type: params.sortBy || queryParams.limit ? 'pagination' : undefined,
|
|
44365
|
-
};
|
|
44366
|
-
const options = token ? Object.assign(Object.assign({}, baseOptions), { token }) : Object.assign(Object.assign({}, baseOptions), { limit });
|
|
44367
|
-
const { data: queryResponse } = await this.http.get(`/api/v1/rooms`, {
|
|
44368
|
-
params: Object.assign(Object.assign({}, params), { isDeleted: inferIsDeleted(includeDeleted), options }),
|
|
44369
|
-
});
|
|
44370
|
-
return queryResponse;
|
|
44371
|
-
}
|
|
44372
|
-
}
|
|
44373
|
-
|
|
44374
|
-
var EnumRoomActions;
|
|
44375
|
-
(function (EnumRoomActions) {
|
|
44376
|
-
EnumRoomActions["OnRoomCreated"] = "OnRoomCreated";
|
|
44377
|
-
EnumRoomActions["OnRoomUpdated"] = "OnRoomUpdated";
|
|
44378
|
-
EnumRoomActions["OnRoomDeleted"] = "OnRoomDeleted";
|
|
44379
|
-
EnumRoomActions["OnRoomStartBroadcasting"] = "OnRoomStartBroadcasting";
|
|
44380
|
-
EnumRoomActions["OnRoomEndBroadcasting"] = "OnRoomEndBroadcasting";
|
|
44381
|
-
EnumRoomActions["OnRoomParticipantJoined"] = "OnRoomParticipantJoined";
|
|
44382
|
-
EnumRoomActions["OnRoomParticipantLeft"] = "OnRoomParticipantLeft";
|
|
44383
|
-
})(EnumRoomActions || (EnumRoomActions = {}));
|
|
44384
|
-
|
|
44385
|
-
class RoomQueryStreamController extends QueryStreamController {
|
|
44386
|
-
constructor(query, cacheKey, notifyChange, preparePayload) {
|
|
44387
|
-
super(query, cacheKey);
|
|
44388
|
-
this.notifyChange = notifyChange;
|
|
44389
|
-
this.preparePayload = preparePayload;
|
|
44390
|
-
}
|
|
44391
|
-
async saveToMainDB(response) {
|
|
44392
|
-
const processedPayload = await this.preparePayload(response);
|
|
44393
|
-
const client = getActiveClient();
|
|
44394
|
-
const cachedAt = client.cache && Date.now();
|
|
44395
|
-
if (client.cache) {
|
|
44396
|
-
ingestInCache(processedPayload, { cachedAt });
|
|
44397
|
-
}
|
|
44398
|
-
}
|
|
44399
|
-
appendToQueryStream(response, direction, refresh = false) {
|
|
44400
|
-
var _a, _b;
|
|
44401
|
-
if (refresh) {
|
|
44402
|
-
pushToCache(this.cacheKey, {
|
|
44403
|
-
data: response.rooms.map(getResolver('room')),
|
|
44404
|
-
});
|
|
44405
|
-
}
|
|
44406
|
-
else {
|
|
44407
|
-
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
44408
|
-
const rooms = (_b = collection === null || collection === void 0 ? void 0 : collection.data) !== null && _b !== void 0 ? _b : [];
|
|
44409
|
-
pushToCache(this.cacheKey, Object.assign(Object.assign({}, collection), { data: [...new Set([...rooms, ...response.rooms.map(getResolver('room'))])] }));
|
|
44410
|
-
}
|
|
44411
|
-
}
|
|
44412
|
-
reactor(action) {
|
|
44413
|
-
return (room) => {
|
|
44414
|
-
var _a;
|
|
44415
|
-
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
44416
|
-
if (!collection)
|
|
44417
|
-
return;
|
|
44418
|
-
if (action === EnumRoomActions.OnRoomDeleted) {
|
|
44419
|
-
collection.data = collection.data.filter(roomId => roomId !== room._id);
|
|
44420
|
-
}
|
|
44421
|
-
if (action === EnumRoomActions.OnRoomCreated) {
|
|
44422
|
-
collection.data = [...new Set([room._id, ...collection.data])];
|
|
44423
|
-
}
|
|
44424
|
-
pushToCache(this.cacheKey, collection);
|
|
44425
|
-
this.notifyChange({ origin: "event" /* Amity.LiveDataOrigin.EVENT */, loading: false });
|
|
44426
|
-
};
|
|
44427
|
-
}
|
|
44428
|
-
subscribeRTE(createSubscriber) {
|
|
44429
|
-
return createSubscriber.map(subscriber => subscriber.fn(this.reactor(subscriber.action)));
|
|
44430
|
-
}
|
|
44431
|
-
}
|
|
44432
|
-
|
|
44433
|
-
// TODO: confirm related events
|
|
44434
|
-
const getRoomSubscription = () => [
|
|
44435
|
-
{
|
|
44436
|
-
fn: onRoomStartBroadcasting,
|
|
44437
|
-
action: EnumRoomActions.OnRoomStartBroadcasting,
|
|
44438
|
-
},
|
|
44439
|
-
{
|
|
44440
|
-
fn: onRoomEndBroadcasting,
|
|
44441
|
-
action: EnumRoomActions.OnRoomEndBroadcasting,
|
|
44442
|
-
},
|
|
44443
|
-
{
|
|
44444
|
-
fn: onRoomRecordedAvailable,
|
|
44445
|
-
action: EnumRoomActions.OnRoomUpdated,
|
|
44446
|
-
},
|
|
44447
|
-
];
|
|
44448
|
-
|
|
44449
|
-
class RoomLiveCollectionController extends LiveCollectionController {
|
|
44450
|
-
constructor(query, callback) {
|
|
44451
|
-
const queryStreamId = hash(query);
|
|
44452
|
-
const cacheKey = ['rooms', 'collection', queryStreamId];
|
|
44453
|
-
const paginationController = new RoomPaginationController(query);
|
|
44454
|
-
super(paginationController, queryStreamId, cacheKey, callback);
|
|
44455
|
-
this.query = query;
|
|
44456
|
-
this.queryStreamController = new RoomQueryStreamController(this.query, this.cacheKey, this.notifyChange.bind(this), response => response);
|
|
44457
|
-
this.callback = callback.bind(this);
|
|
44458
|
-
this.loadPage({ initial: true });
|
|
44459
|
-
}
|
|
44460
|
-
setup() {
|
|
44461
|
-
var _a;
|
|
44462
|
-
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
44463
|
-
if (!collection) {
|
|
44464
|
-
pushToCache(this.cacheKey, {
|
|
44465
|
-
data: [],
|
|
44466
|
-
params: {},
|
|
44467
|
-
});
|
|
44468
|
-
}
|
|
44469
|
-
}
|
|
44470
|
-
async persistModel(queryPayload) {
|
|
44471
|
-
await this.queryStreamController.saveToMainDB(queryPayload);
|
|
44472
|
-
}
|
|
44473
|
-
persistQueryStream({ response, direction, refresh, }) {
|
|
44474
|
-
this.queryStreamController.appendToQueryStream(response, direction, refresh);
|
|
44475
|
-
}
|
|
44476
|
-
startSubscription() {
|
|
44477
|
-
return this.queryStreamController.subscribeRTE(getRoomSubscription());
|
|
44478
|
-
}
|
|
44479
|
-
notifyChange({ origin, loading, error }) {
|
|
44480
|
-
var _a, _b;
|
|
44481
|
-
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
44482
|
-
if (!collection)
|
|
44483
|
-
return;
|
|
44484
|
-
const data = this.applyFilter((_b = collection.data
|
|
44485
|
-
.map(id => pullFromCache(['room', 'get', id]))
|
|
44486
|
-
.filter(isNonNullable)
|
|
44487
|
-
.map(({ data }) => data)) !== null && _b !== void 0 ? _b : []).map(room => room); // Since Room is same as InternalRoom, no transformation needed
|
|
44488
|
-
if (!this.shouldNotify(data) && origin === 'event')
|
|
44489
|
-
return;
|
|
44490
|
-
this.callback({
|
|
44491
|
-
onNextPage: () => this.loadPage({ direction: "next" /* Amity.LiveCollectionPageDirection.NEXT */ }),
|
|
44492
|
-
data,
|
|
44493
|
-
hasNextPage: !!this.paginationController.getNextToken(),
|
|
44494
|
-
loading,
|
|
44495
|
-
error,
|
|
44496
|
-
});
|
|
44497
|
-
}
|
|
44498
|
-
applyFilter(data) {
|
|
44499
|
-
let rooms = data;
|
|
44500
|
-
if (!this.query.includeDeleted) {
|
|
44501
|
-
rooms = filterByPropEquality(rooms, 'isDeleted', false);
|
|
44502
|
-
}
|
|
44503
|
-
if (this.query.statuses && this.query.statuses.length > 0) {
|
|
44504
|
-
rooms = rooms.filter(room => { var _a; return (_a = this.query.statuses) === null || _a === void 0 ? void 0 : _a.includes(room.status); });
|
|
44505
|
-
}
|
|
44506
|
-
if (this.query.type) {
|
|
44507
|
-
rooms = filterByPropEquality(rooms, 'type', this.query.type);
|
|
44508
|
-
}
|
|
44509
|
-
switch (this.query.sortBy) {
|
|
44510
|
-
case 'firstCreated':
|
|
44511
|
-
rooms = rooms.sort(sortByFirstCreated);
|
|
44512
|
-
break;
|
|
44513
|
-
case 'lastCreated':
|
|
44514
|
-
default:
|
|
44515
|
-
rooms = rooms.sort(sortByLastCreated);
|
|
44516
|
-
break;
|
|
44517
|
-
}
|
|
44518
|
-
return rooms;
|
|
44519
|
-
}
|
|
44520
|
-
}
|
|
44521
|
-
|
|
44522
|
-
/* begin_public_function
|
|
44523
|
-
id: room.get_rooms
|
|
44524
|
-
*/
|
|
44525
|
-
/**
|
|
44526
|
-
* ```js
|
|
44527
|
-
* import { RoomRepository } from '@amityco/ts-sdk'
|
|
44528
|
-
*
|
|
44529
|
-
* let rooms = []
|
|
44530
|
-
* const unsub = RoomRepository.getRooms({
|
|
44531
|
-
* type: 'direct_streaming',
|
|
44532
|
-
* statuses: ['live', 'idle'],
|
|
44533
|
-
* sortBy: 'lastCreated',
|
|
44534
|
-
* limit: 20,
|
|
44535
|
-
* includeDeleted: false
|
|
44536
|
-
* }, response => merge(rooms, response.data))
|
|
44537
|
-
* ```
|
|
44538
|
-
*
|
|
44539
|
-
* Observe all mutations on a list of {@link Amity.Room} for a given query
|
|
44540
|
-
*
|
|
44541
|
-
* @param params.type the type of rooms to filter by ('direct_streaming' | 'co_hosts')
|
|
44542
|
-
* @param params.statuses array of room statuses to filter by (['idle', 'live', 'waiting_reconnect', 'ended', 'recorded'])
|
|
44543
|
-
* @param params.sortBy sort rooms by creation time ('firstCreated' | 'lastCreated')
|
|
44544
|
-
* @param params.limit maximum number of rooms to retrieve per page
|
|
44545
|
-
* @param params.includeDeleted whether to include deleted rooms in the results
|
|
44546
|
-
* @param callback the function to call when new data are available
|
|
44547
|
-
* @param config optional configuration for the live collection
|
|
44548
|
-
* @returns An {@link Amity.Unsubscriber} function to run when willing to stop observing the rooms
|
|
44549
|
-
*
|
|
44550
|
-
* @category Rooms Live Collection
|
|
44551
|
-
*/
|
|
44552
|
-
const getRooms = (params, callback, config) => {
|
|
44553
|
-
const { log, cache } = getActiveClient();
|
|
44554
|
-
if (!cache) {
|
|
44555
|
-
console.log(ENABLE_CACHE_MESSAGE);
|
|
44556
|
-
}
|
|
44557
|
-
const timestamp = Date.now();
|
|
44558
|
-
log(`getRooms(tmpid: ${timestamp}) > listen`);
|
|
44559
|
-
const roomsLiveCollection = new RoomLiveCollectionController(params, callback);
|
|
44560
|
-
const disposers = roomsLiveCollection.startSubscription();
|
|
44561
|
-
const cacheKey = roomsLiveCollection.getCacheKey();
|
|
44562
|
-
disposers.push(() => dropFromCache(cacheKey));
|
|
44563
|
-
return () => {
|
|
44564
|
-
log(`getRooms(tmpid: ${timestamp}) > dispose`);
|
|
44565
|
-
disposers.forEach(fn => fn());
|
|
44566
|
-
};
|
|
44567
|
-
};
|
|
44568
|
-
/* end_public_function */
|
|
44569
|
-
|
|
44570
|
-
var index$7 = /*#__PURE__*/Object.freeze({
|
|
44571
|
-
__proto__: null,
|
|
44572
|
-
createRoom: createRoom,
|
|
44573
|
-
updateRoom: updateRoom,
|
|
44574
|
-
deleteRoom: deleteRoom,
|
|
44575
|
-
stopRoom: stopRoom,
|
|
44576
|
-
getBroadcasterData: getBroadcasterData,
|
|
44577
|
-
getRecordedUrl: getRecordedUrl,
|
|
44578
|
-
onRoomStartBroadcasting: onRoomStartBroadcasting,
|
|
44579
|
-
onRoomWaitingReconnect: onRoomWaitingReconnect,
|
|
44580
|
-
onRoomEndBroadcasting: onRoomEndBroadcasting,
|
|
44581
|
-
onRoomRecordedAvailable: onRoomRecordedAvailable,
|
|
44582
|
-
onRoomParticipantInviting: onRoomParticipantInviting,
|
|
44583
|
-
onRoomParticipantJoined: onRoomParticipantJoined,
|
|
44584
|
-
onRoomParticipantLeft: onRoomParticipantLeft,
|
|
44585
|
-
onRoomCreated: onRoomCreated,
|
|
44586
|
-
onRoomUpdated: onRoomUpdated,
|
|
44587
|
-
onRoomDeleted: onRoomDeleted,
|
|
44588
|
-
onRoomStopped: onRoomStopped,
|
|
44589
|
-
getRoom: getRoom,
|
|
44590
|
-
getRooms: getRooms
|
|
44591
|
-
});
|
|
44592
|
-
|
|
44593
43829
|
/* begin_public_function
|
|
44594
43830
|
id: poll.create
|
|
44595
43831
|
*/
|
|
@@ -44890,7 +44126,7 @@ const getPoll = (pollId, callback) => {
|
|
|
44890
44126
|
};
|
|
44891
44127
|
/* end_public_function */
|
|
44892
44128
|
|
|
44893
|
-
var index$
|
|
44129
|
+
var index$7 = /*#__PURE__*/Object.freeze({
|
|
44894
44130
|
__proto__: null,
|
|
44895
44131
|
createPoll: createPoll,
|
|
44896
44132
|
closePoll: closePoll,
|
|
@@ -45273,7 +44509,7 @@ const getPlayer = async (parameters) => {
|
|
|
45273
44509
|
return video;
|
|
45274
44510
|
};
|
|
45275
44511
|
|
|
45276
|
-
var index$
|
|
44512
|
+
var index$6 = /*#__PURE__*/Object.freeze({
|
|
45277
44513
|
__proto__: null,
|
|
45278
44514
|
getPlayer: getPlayer
|
|
45279
44515
|
});
|
|
@@ -46446,7 +45682,7 @@ const getGlobalStoryTargets = (params, callback, config) => {
|
|
|
46446
45682
|
};
|
|
46447
45683
|
};
|
|
46448
45684
|
|
|
46449
|
-
var index$
|
|
45685
|
+
var index$5 = /*#__PURE__*/Object.freeze({
|
|
46450
45686
|
__proto__: null,
|
|
46451
45687
|
createImageStory: createImageStory,
|
|
46452
45688
|
createVideoStory: createVideoStory,
|
|
@@ -46483,7 +45719,7 @@ const getNetworkAds = async () => {
|
|
|
46483
45719
|
};
|
|
46484
45720
|
};
|
|
46485
45721
|
|
|
46486
|
-
var index$
|
|
45722
|
+
var index$4 = /*#__PURE__*/Object.freeze({
|
|
46487
45723
|
__proto__: null,
|
|
46488
45724
|
getNetworkAds: getNetworkAds
|
|
46489
45725
|
});
|
|
@@ -46874,7 +46110,7 @@ const markTraySeen = async (lastSeenAt) => {
|
|
|
46874
46110
|
};
|
|
46875
46111
|
/* end_public_function */
|
|
46876
46112
|
|
|
46877
|
-
var index$
|
|
46113
|
+
var index$3 = /*#__PURE__*/Object.freeze({
|
|
46878
46114
|
__proto__: null,
|
|
46879
46115
|
getNotificationTraySeen: getNotificationTraySeen,
|
|
46880
46116
|
getNotificationTrayItems: getNotificationTrayItems,
|
|
@@ -47075,7 +46311,7 @@ const getMyCommunityInvitations = (params, callback, config) => {
|
|
|
47075
46311
|
};
|
|
47076
46312
|
};
|
|
47077
46313
|
|
|
47078
|
-
var index$
|
|
46314
|
+
var index$2 = /*#__PURE__*/Object.freeze({
|
|
47079
46315
|
__proto__: null,
|
|
47080
46316
|
onLocalInvitationCreated: onLocalInvitationCreated,
|
|
47081
46317
|
onLocalInvitationUpdated: onLocalInvitationUpdated,
|
|
@@ -47108,7 +46344,7 @@ var index$1 = /*#__PURE__*/Object.freeze({
|
|
|
47108
46344
|
* @category Live Reaction API
|
|
47109
46345
|
* @async
|
|
47110
46346
|
*/
|
|
47111
|
-
const createReaction = async ({ referenceId, referenceType, reactionName,
|
|
46347
|
+
const createReaction = async ({ referenceId, referenceType, reactionName, streamId, }) => {
|
|
47112
46348
|
const client = getActiveClient();
|
|
47113
46349
|
client.log('live_reaction/createReaction', {
|
|
47114
46350
|
referenceId,
|
|
@@ -47120,7 +46356,7 @@ const createReaction = async ({ referenceId, referenceType, reactionName, roomId
|
|
|
47120
46356
|
reactionName,
|
|
47121
46357
|
referencePublicId: referenceId,
|
|
47122
46358
|
referenceType,
|
|
47123
|
-
|
|
46359
|
+
streamId,
|
|
47124
46360
|
occurredAt: new Date().toISOString(),
|
|
47125
46361
|
};
|
|
47126
46362
|
reactionSynceEngine.createLiveReaction(reaction);
|
|
@@ -47216,11 +46452,619 @@ const getReactions = (postId, callback) => {
|
|
|
47216
46452
|
};
|
|
47217
46453
|
};
|
|
47218
46454
|
|
|
47219
|
-
var index = /*#__PURE__*/Object.freeze({
|
|
46455
|
+
var index$1 = /*#__PURE__*/Object.freeze({
|
|
47220
46456
|
__proto__: null,
|
|
47221
46457
|
createReaction: createReaction,
|
|
47222
46458
|
onLiveReactionCreated: onLiveReactionCreated,
|
|
47223
46459
|
getReactions: getReactions
|
|
47224
46460
|
});
|
|
47225
46461
|
|
|
47226
|
-
|
|
46462
|
+
const prepareEventPayload = (rawPayload) => {
|
|
46463
|
+
return Object.assign(Object.assign({}, rawPayload), { users: rawPayload.users.map(convertRawUserToInternalUser) });
|
|
46464
|
+
};
|
|
46465
|
+
|
|
46466
|
+
const createEventEventSubscriber = (event, callback) => {
|
|
46467
|
+
const client = getActiveClient();
|
|
46468
|
+
const filter = (payload) => {
|
|
46469
|
+
const unpackedPayload = prepareEventPayload(payload);
|
|
46470
|
+
if (!client.cache) {
|
|
46471
|
+
callback(unpackedPayload.events[0]);
|
|
46472
|
+
}
|
|
46473
|
+
else {
|
|
46474
|
+
ingestInCache(unpackedPayload);
|
|
46475
|
+
const event = pullFromCache([
|
|
46476
|
+
'event',
|
|
46477
|
+
'get',
|
|
46478
|
+
unpackedPayload.events[0].eventId,
|
|
46479
|
+
]);
|
|
46480
|
+
callback(event.data);
|
|
46481
|
+
}
|
|
46482
|
+
};
|
|
46483
|
+
return createEventSubscriber(client, event, event, filter);
|
|
46484
|
+
};
|
|
46485
|
+
|
|
46486
|
+
/* begin_public_function
|
|
46487
|
+
id: event.create
|
|
46488
|
+
*/
|
|
46489
|
+
/**
|
|
46490
|
+
* ```js
|
|
46491
|
+
* import { EventRepository } from '@amityco/ts-sdk'
|
|
46492
|
+
* const response = await EventRepository.createEvent(bundle)
|
|
46493
|
+
* ```
|
|
46494
|
+
*
|
|
46495
|
+
* Creates an {@link Amity.Event}
|
|
46496
|
+
*
|
|
46497
|
+
* @param bundle The data necessary to create a new {@link Amity.Event}
|
|
46498
|
+
* @returns The newly created {@link Amity.Event}
|
|
46499
|
+
*
|
|
46500
|
+
* @category Event API
|
|
46501
|
+
* @async
|
|
46502
|
+
*/
|
|
46503
|
+
const createEvent = async (bundle) => {
|
|
46504
|
+
const client = getActiveClient();
|
|
46505
|
+
client.log('event/createEvent', bundle);
|
|
46506
|
+
const { data: payload } = await client.http.post('/api/v1/events', bundle);
|
|
46507
|
+
fireEvent('local.event.created', payload);
|
|
46508
|
+
const preparedPayload = prepareEventPayload(payload);
|
|
46509
|
+
const cachedAt = client.cache && Date.now();
|
|
46510
|
+
if (client.cache)
|
|
46511
|
+
ingestInCache(preparedPayload, { cachedAt });
|
|
46512
|
+
return {
|
|
46513
|
+
data: eventLinkedObject(preparedPayload.events[0]),
|
|
46514
|
+
cachedAt,
|
|
46515
|
+
};
|
|
46516
|
+
};
|
|
46517
|
+
/* end_public_function */
|
|
46518
|
+
|
|
46519
|
+
/* begin_public_function
|
|
46520
|
+
id: event.update
|
|
46521
|
+
*/
|
|
46522
|
+
/**
|
|
46523
|
+
* ```js
|
|
46524
|
+
* import { EventRepository } from '@amityco/ts-sdk'
|
|
46525
|
+
* const response = await EventRepository.updateEvent(eventId, bundle)
|
|
46526
|
+
* ```
|
|
46527
|
+
*
|
|
46528
|
+
* Updates an {@link Amity.Event}
|
|
46529
|
+
*
|
|
46530
|
+
* @param eventId The ID of the {@link Amity.Event} to edit
|
|
46531
|
+
* @param bundle The data necessary to update an existing {@link Amity.Event}
|
|
46532
|
+
* @returns the updated {@link Amity.Event}
|
|
46533
|
+
*
|
|
46534
|
+
* @category Event API
|
|
46535
|
+
* @async
|
|
46536
|
+
*/
|
|
46537
|
+
const updateEvent = async (eventId, bundle) => {
|
|
46538
|
+
const client = getActiveClient();
|
|
46539
|
+
client.log('event/updateEvent', eventId, bundle);
|
|
46540
|
+
const { data: payload } = await client.http.put(`/api/v1/events/${eventId}`, bundle);
|
|
46541
|
+
fireEvent('local.event.updated', payload);
|
|
46542
|
+
const preparedPayload = prepareEventPayload(payload);
|
|
46543
|
+
const cachedAt = client.cache && Date.now();
|
|
46544
|
+
if (client.cache)
|
|
46545
|
+
ingestInCache(preparedPayload, { cachedAt });
|
|
46546
|
+
return {
|
|
46547
|
+
data: eventLinkedObject(preparedPayload.events.find(event => event.eventId === eventId)),
|
|
46548
|
+
cachedAt,
|
|
46549
|
+
};
|
|
46550
|
+
};
|
|
46551
|
+
/* end_public_function */
|
|
46552
|
+
|
|
46553
|
+
/* begin_public_function
|
|
46554
|
+
id: event.get
|
|
46555
|
+
*/
|
|
46556
|
+
/**
|
|
46557
|
+
* ```js
|
|
46558
|
+
* import { EventRepository } from '@amityco/ts-sdk'
|
|
46559
|
+
* const event = await EventRepository.getEvent(eventId)
|
|
46560
|
+
* ```
|
|
46561
|
+
*
|
|
46562
|
+
* Fetches a {@link Amity.Event} object
|
|
46563
|
+
*
|
|
46564
|
+
* @param eventId the ID of the {@link Amity.Event} to fetch
|
|
46565
|
+
* @returns the associated {@link Amity.Event} object
|
|
46566
|
+
*
|
|
46567
|
+
* @category Event API
|
|
46568
|
+
* @async
|
|
46569
|
+
*/
|
|
46570
|
+
const getEvent$1 = async (eventId) => {
|
|
46571
|
+
const client = getActiveClient();
|
|
46572
|
+
client.log('event/getEvent', eventId);
|
|
46573
|
+
const { data: payload } = await client.http.get(`/api/v1/events/${eventId}`);
|
|
46574
|
+
const data = prepareEventPayload(payload);
|
|
46575
|
+
const cachedAt = client.cache && Date.now();
|
|
46576
|
+
if (client.cache)
|
|
46577
|
+
ingestInCache(data, { cachedAt });
|
|
46578
|
+
return {
|
|
46579
|
+
data: data.events.find(event => event.eventId === eventId),
|
|
46580
|
+
cachedAt,
|
|
46581
|
+
};
|
|
46582
|
+
};
|
|
46583
|
+
/* end_public_function */
|
|
46584
|
+
/**
|
|
46585
|
+
* ```js
|
|
46586
|
+
* import { EventRepository } from '@amityco/ts-sdk'
|
|
46587
|
+
* const event = EventRepository.getEvent.locally(eventId)
|
|
46588
|
+
* ```
|
|
46589
|
+
*
|
|
46590
|
+
* Fetches a {@link Amity.Event} object in cache
|
|
46591
|
+
*
|
|
46592
|
+
* @param eventId the ID of the {@link Amity.Event} to fetch
|
|
46593
|
+
* @returns the associated {@link Amity.Event} object
|
|
46594
|
+
*
|
|
46595
|
+
* @category Event API
|
|
46596
|
+
*/
|
|
46597
|
+
getEvent$1.locally = (eventId) => {
|
|
46598
|
+
const client = getActiveClient();
|
|
46599
|
+
client.log('event/getEvent.locally', eventId);
|
|
46600
|
+
if (!client.cache)
|
|
46601
|
+
return;
|
|
46602
|
+
const cache = pullFromCache(['event', 'get', eventId]);
|
|
46603
|
+
if (!cache)
|
|
46604
|
+
return;
|
|
46605
|
+
return {
|
|
46606
|
+
data: cache.data,
|
|
46607
|
+
cachedAt: cache.cachedAt,
|
|
46608
|
+
};
|
|
46609
|
+
};
|
|
46610
|
+
|
|
46611
|
+
/* begin_public_function
|
|
46612
|
+
id: event.delete
|
|
46613
|
+
*/
|
|
46614
|
+
/**
|
|
46615
|
+
* ```js
|
|
46616
|
+
* import { EventRepository } from '@amityco/ts-sdk'
|
|
46617
|
+
* const { success } = await EventRepository.deleteEvent(eventId)
|
|
46618
|
+
* ```
|
|
46619
|
+
*
|
|
46620
|
+
* Deletes a {@link Amity.Event}
|
|
46621
|
+
*
|
|
46622
|
+
* @param eventId The {@link Amity.Event} ID to delete
|
|
46623
|
+
*
|
|
46624
|
+
* @category Event API
|
|
46625
|
+
* @async
|
|
46626
|
+
*/
|
|
46627
|
+
const deleteEvent = async (eventId) => {
|
|
46628
|
+
const client = getActiveClient();
|
|
46629
|
+
client.log('event/deleteEvent', eventId);
|
|
46630
|
+
const event = await getEvent$1(eventId);
|
|
46631
|
+
await client.http.delete(`/api/v1/events/${eventId}`);
|
|
46632
|
+
const deletedEvent = Object.assign(Object.assign({}, event.data), { isDeleted: true });
|
|
46633
|
+
upsertInCache(['event', 'get', eventId], deletedEvent);
|
|
46634
|
+
fireEvent('local.event.deleted', {
|
|
46635
|
+
users: [],
|
|
46636
|
+
files: [],
|
|
46637
|
+
communities: [],
|
|
46638
|
+
videoStreamings: [],
|
|
46639
|
+
events: [deletedEvent],
|
|
46640
|
+
discussionCommunities: [],
|
|
46641
|
+
});
|
|
46642
|
+
};
|
|
46643
|
+
/* end_public_function */
|
|
46644
|
+
|
|
46645
|
+
/**
|
|
46646
|
+
* ```js
|
|
46647
|
+
* import { EventRepository } from '@amityco/ts-sdk'
|
|
46648
|
+
* const dispose = EventRepository.onEventCreated(event => {
|
|
46649
|
+
* // ...
|
|
46650
|
+
* })
|
|
46651
|
+
* ```
|
|
46652
|
+
*
|
|
46653
|
+
* Fired when a {@link Amity.Event} has been created
|
|
46654
|
+
*
|
|
46655
|
+
* @param callback The function to call when the event was fired
|
|
46656
|
+
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
46657
|
+
*
|
|
46658
|
+
* @category Event Events
|
|
46659
|
+
*/
|
|
46660
|
+
const onEventCreated = (callback) => createEventEventSubscriber('event.created', callback);
|
|
46661
|
+
|
|
46662
|
+
/**
|
|
46663
|
+
* ```js
|
|
46664
|
+
* import { EventRepository } from '@amityco/ts-sdk'
|
|
46665
|
+
* const dispose = EventRepository.onEventUpdated(event => {
|
|
46666
|
+
* // ...
|
|
46667
|
+
* })
|
|
46668
|
+
* ```
|
|
46669
|
+
*
|
|
46670
|
+
* Fired when a {@link Amity.Event} has been updated
|
|
46671
|
+
*
|
|
46672
|
+
* @param callback The function to call when the event was fired
|
|
46673
|
+
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
46674
|
+
*
|
|
46675
|
+
* @category Event Events
|
|
46676
|
+
*/
|
|
46677
|
+
const onEventUpdated = (callback) => createEventEventSubscriber('event.updated', callback);
|
|
46678
|
+
|
|
46679
|
+
/**
|
|
46680
|
+
* ```js
|
|
46681
|
+
* import { EventRepository } from '@amityco/ts-sdk'
|
|
46682
|
+
* const dispose = EventRepository.onEventDeleted(event => {
|
|
46683
|
+
* // ...
|
|
46684
|
+
* })
|
|
46685
|
+
* ```
|
|
46686
|
+
*
|
|
46687
|
+
* Fired when a {@link Amity.Event} has been deleted
|
|
46688
|
+
*
|
|
46689
|
+
* @param callback The function to call when the event was fired
|
|
46690
|
+
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
46691
|
+
*
|
|
46692
|
+
* @category Event Events
|
|
46693
|
+
*/
|
|
46694
|
+
const onEventDeleted = (callback) => createEventEventSubscriber('event.deleted', callback);
|
|
46695
|
+
|
|
46696
|
+
/**
|
|
46697
|
+
* ```js
|
|
46698
|
+
* import { EventRepository } from '@amityco/ts-sdk'
|
|
46699
|
+
* const dispose = EventRepository.onLocalEventCreated(event => {
|
|
46700
|
+
* // ...
|
|
46701
|
+
* })
|
|
46702
|
+
* ```
|
|
46703
|
+
*
|
|
46704
|
+
* Fired when a {@link Amity.Event} has been created
|
|
46705
|
+
*
|
|
46706
|
+
* @param callback The function to call when the event was fired
|
|
46707
|
+
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
46708
|
+
*
|
|
46709
|
+
* @category Event Events
|
|
46710
|
+
*/
|
|
46711
|
+
const onLocalEventCreated = (callback) => createEventEventSubscriber('local.event.created', callback);
|
|
46712
|
+
|
|
46713
|
+
/**
|
|
46714
|
+
* ```js
|
|
46715
|
+
* import { EventRepository } from '@amityco/ts-sdk'
|
|
46716
|
+
* const dispose = EventRepository.onLocalEventUpdated(event => {
|
|
46717
|
+
* // ...
|
|
46718
|
+
* })
|
|
46719
|
+
* ```
|
|
46720
|
+
*
|
|
46721
|
+
* Fired when a {@link Amity.Event} has been updated
|
|
46722
|
+
*
|
|
46723
|
+
* @param callback The function to call when the event was fired
|
|
46724
|
+
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
46725
|
+
*
|
|
46726
|
+
* @category Event Events
|
|
46727
|
+
*/
|
|
46728
|
+
const onLocalEventUpdated = (callback) => createEventEventSubscriber('local.event.updated', callback);
|
|
46729
|
+
|
|
46730
|
+
/**
|
|
46731
|
+
* ```js
|
|
46732
|
+
* import { EventRepository } from '@amityco/ts-sdk'
|
|
46733
|
+
* const dispose = EventRepository.onLocalEventDeleted(event => {
|
|
46734
|
+
* // ...
|
|
46735
|
+
* })
|
|
46736
|
+
* ```
|
|
46737
|
+
*
|
|
46738
|
+
* Fired when a {@link Amity.Event} has been deleted
|
|
46739
|
+
*
|
|
46740
|
+
* @param callback The function to call when the event was fired
|
|
46741
|
+
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
46742
|
+
*
|
|
46743
|
+
* @category Event Events
|
|
46744
|
+
*/
|
|
46745
|
+
const onLocalEventDeleted = (callback) => createEventEventSubscriber('local.event.deleted', callback);
|
|
46746
|
+
|
|
46747
|
+
/* begin_public_function
|
|
46748
|
+
id: event.get
|
|
46749
|
+
*/
|
|
46750
|
+
/**
|
|
46751
|
+
* ```js
|
|
46752
|
+
* import { EventRepository } from '@amityco/ts-sdk';
|
|
46753
|
+
*
|
|
46754
|
+
* let event;
|
|
46755
|
+
*
|
|
46756
|
+
* const unsubscribe = EventRepository.getEvent(eventId, response => {
|
|
46757
|
+
* event = response.data;
|
|
46758
|
+
* });
|
|
46759
|
+
* ```
|
|
46760
|
+
*
|
|
46761
|
+
* Observe all mutation on a given {@link Amity.Event}
|
|
46762
|
+
*
|
|
46763
|
+
* @param eventId the ID of the event to observe
|
|
46764
|
+
* @param callback the function to call when new snapshot of event are available
|
|
46765
|
+
* @returns An {@link Amity.Unsubscriber} function to run when willing to stop observing the event
|
|
46766
|
+
*
|
|
46767
|
+
* @category Event Live Object
|
|
46768
|
+
*/
|
|
46769
|
+
const getEvent = (eventId, callback) => {
|
|
46770
|
+
return liveObject(eventId, callback, 'eventId', getEvent$1, [onEventUpdated, onEventDeleted, onLocalEventUpdated, onLocalEventDeleted], {
|
|
46771
|
+
callbackDataSelector: (data) => (data ? eventLinkedObject(data) : data),
|
|
46772
|
+
});
|
|
46773
|
+
};
|
|
46774
|
+
/* end_public_function */
|
|
46775
|
+
|
|
46776
|
+
var EventActionsEnum;
|
|
46777
|
+
(function (EventActionsEnum) {
|
|
46778
|
+
EventActionsEnum["OnEventCreated"] = "onEventCreated";
|
|
46779
|
+
EventActionsEnum["OnEventUpdated"] = "onEventUpdated";
|
|
46780
|
+
EventActionsEnum["OnEventDeleted"] = "onEventDeleted";
|
|
46781
|
+
})(EventActionsEnum || (EventActionsEnum = {}));
|
|
46782
|
+
|
|
46783
|
+
class EventPaginationController extends PaginationController {
|
|
46784
|
+
async getRequest(queryParams, token) {
|
|
46785
|
+
const { limit = COLLECTION_DEFAULT_PAGINATION_LIMIT } = queryParams, params = __rest(queryParams, ["limit"]);
|
|
46786
|
+
const options = token ? { token } : { limit };
|
|
46787
|
+
const { data: response } = await this.http.get(`/api/v1/events`, { params: Object.assign(Object.assign({}, params), { options }) });
|
|
46788
|
+
return response;
|
|
46789
|
+
}
|
|
46790
|
+
}
|
|
46791
|
+
|
|
46792
|
+
class EventQueryStreamController extends QueryStreamController {
|
|
46793
|
+
constructor(query, cacheKey, notifyChange, preparePayload) {
|
|
46794
|
+
super(query, cacheKey);
|
|
46795
|
+
this.notifyChange = notifyChange;
|
|
46796
|
+
this.preparePayload = preparePayload;
|
|
46797
|
+
}
|
|
46798
|
+
async saveToMainDB(response) {
|
|
46799
|
+
const processedPayload = this.preparePayload(response);
|
|
46800
|
+
const client = getActiveClient();
|
|
46801
|
+
const cachedAt = client.cache && Date.now();
|
|
46802
|
+
if (client.cache)
|
|
46803
|
+
ingestInCache(processedPayload, { cachedAt });
|
|
46804
|
+
}
|
|
46805
|
+
appendToQueryStream(response, direction, refresh = false) {
|
|
46806
|
+
var _a, _b;
|
|
46807
|
+
if (refresh) {
|
|
46808
|
+
pushToCache(this.cacheKey, { data: response.events.map(getResolver('event')) });
|
|
46809
|
+
}
|
|
46810
|
+
else {
|
|
46811
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
46812
|
+
const events = (_b = collection === null || collection === void 0 ? void 0 : collection.data) !== null && _b !== void 0 ? _b : [];
|
|
46813
|
+
pushToCache(this.cacheKey, Object.assign(Object.assign({}, collection), { data: [...new Set([...events, ...response.events.map(getResolver('event'))])] }));
|
|
46814
|
+
}
|
|
46815
|
+
}
|
|
46816
|
+
reactor(action) {
|
|
46817
|
+
return (event) => {
|
|
46818
|
+
var _a;
|
|
46819
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
46820
|
+
if (!collection)
|
|
46821
|
+
return;
|
|
46822
|
+
if (action === EventActionsEnum.OnEventCreated) {
|
|
46823
|
+
collection.data = [...new Set([event.eventId, ...collection.data])];
|
|
46824
|
+
}
|
|
46825
|
+
if (action === EventActionsEnum.OnEventDeleted) {
|
|
46826
|
+
collection.data = collection.data.filter(eventId => eventId !== event.eventId);
|
|
46827
|
+
}
|
|
46828
|
+
pushToCache(this.cacheKey, collection);
|
|
46829
|
+
this.notifyChange({ origin: "event" /* Amity.LiveDataOrigin.EVENT */, loading: false });
|
|
46830
|
+
};
|
|
46831
|
+
}
|
|
46832
|
+
subscribeRTE(createSubscriber) {
|
|
46833
|
+
return createSubscriber.map(subscriber => subscriber.fn(this.reactor(subscriber.action)));
|
|
46834
|
+
}
|
|
46835
|
+
}
|
|
46836
|
+
|
|
46837
|
+
class EventLiveCollectionController extends LiveCollectionController {
|
|
46838
|
+
constructor(query, callback) {
|
|
46839
|
+
const queryStreamId = hash(query);
|
|
46840
|
+
const cacheKey = ['event', 'collection', queryStreamId];
|
|
46841
|
+
const paginationController = new EventPaginationController(query);
|
|
46842
|
+
super(paginationController, queryStreamId, cacheKey, callback);
|
|
46843
|
+
this.query = query;
|
|
46844
|
+
this.queryStreamController = new EventQueryStreamController(this.query, this.cacheKey, this.notifyChange.bind(this), prepareEventPayload);
|
|
46845
|
+
this.callback = callback.bind(this);
|
|
46846
|
+
this.loadPage({ initial: true });
|
|
46847
|
+
}
|
|
46848
|
+
setup() {
|
|
46849
|
+
var _a;
|
|
46850
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
46851
|
+
if (!collection)
|
|
46852
|
+
pushToCache(this.cacheKey, { data: [], params: {} });
|
|
46853
|
+
}
|
|
46854
|
+
async persistModel(queryPayload) {
|
|
46855
|
+
await this.queryStreamController.saveToMainDB(queryPayload);
|
|
46856
|
+
}
|
|
46857
|
+
persistQueryStream({ response, direction, refresh, }) {
|
|
46858
|
+
this.queryStreamController.appendToQueryStream(response, direction, refresh);
|
|
46859
|
+
}
|
|
46860
|
+
startSubscription() {
|
|
46861
|
+
return this.queryStreamController.subscribeRTE([
|
|
46862
|
+
{ fn: onEventCreated, action: EventActionsEnum.OnEventCreated },
|
|
46863
|
+
{ fn: onEventUpdated, action: EventActionsEnum.OnEventUpdated },
|
|
46864
|
+
{ fn: onEventDeleted, action: EventActionsEnum.OnEventDeleted },
|
|
46865
|
+
{ fn: onLocalEventCreated, action: EventActionsEnum.OnEventCreated },
|
|
46866
|
+
{ fn: onLocalEventUpdated, action: EventActionsEnum.OnEventUpdated },
|
|
46867
|
+
{ fn: onLocalEventDeleted, action: EventActionsEnum.OnEventDeleted },
|
|
46868
|
+
]);
|
|
46869
|
+
}
|
|
46870
|
+
notifyChange({ origin, loading, error }) {
|
|
46871
|
+
var _a, _b;
|
|
46872
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
46873
|
+
if (!collection)
|
|
46874
|
+
return;
|
|
46875
|
+
const data = ((_b = collection.data
|
|
46876
|
+
.map(eventId => pullFromCache(['event', 'get', eventId]))
|
|
46877
|
+
.filter(isNonNullable)
|
|
46878
|
+
.map(({ data }) => data)) !== null && _b !== void 0 ? _b : []).map(LinkedObject.event);
|
|
46879
|
+
if (!this.shouldNotify(data) && origin === "event" /* Amity.LiveDataOrigin.EVENT */)
|
|
46880
|
+
return;
|
|
46881
|
+
this.callback({
|
|
46882
|
+
data,
|
|
46883
|
+
error,
|
|
46884
|
+
loading,
|
|
46885
|
+
hasNextPage: !!this.paginationController.getNextToken(),
|
|
46886
|
+
onNextPage: () => this.loadPage({ direction: "next" /* Amity.LiveCollectionPageDirection.NEXT */ }),
|
|
46887
|
+
});
|
|
46888
|
+
}
|
|
46889
|
+
}
|
|
46890
|
+
|
|
46891
|
+
/**
|
|
46892
|
+
* Get events
|
|
46893
|
+
*
|
|
46894
|
+
* @param params the query parameters
|
|
46895
|
+
* @param callback the callback to be called when the events are updated
|
|
46896
|
+
* @returns events
|
|
46897
|
+
*
|
|
46898
|
+
* @category Event Live Collection
|
|
46899
|
+
*
|
|
46900
|
+
*/
|
|
46901
|
+
const getEvents = (params, callback, config) => {
|
|
46902
|
+
const { log, cache } = getActiveClient();
|
|
46903
|
+
if (!cache)
|
|
46904
|
+
console.log(ENABLE_CACHE_MESSAGE);
|
|
46905
|
+
const timestamp = Date.now();
|
|
46906
|
+
log(`getEvents: (tmpid: ${timestamp}) > listen`);
|
|
46907
|
+
const eventLiveCollection = new EventLiveCollectionController(params, callback);
|
|
46908
|
+
const disposers = eventLiveCollection.startSubscription();
|
|
46909
|
+
const cacheKey = eventLiveCollection.getCacheKey();
|
|
46910
|
+
disposers.push(() => dropFromCache(cacheKey));
|
|
46911
|
+
return () => {
|
|
46912
|
+
log(`getEvents (tmpid: ${timestamp}) > dispose`);
|
|
46913
|
+
disposers.forEach(fn => fn());
|
|
46914
|
+
};
|
|
46915
|
+
};
|
|
46916
|
+
|
|
46917
|
+
class MyEventPaginationController extends PaginationController {
|
|
46918
|
+
async getRequest(queryParams, token) {
|
|
46919
|
+
const { limit = COLLECTION_DEFAULT_PAGINATION_LIMIT } = queryParams, params = __rest(queryParams, ["limit"]);
|
|
46920
|
+
const options = token ? { token } : { limit };
|
|
46921
|
+
const { data: response } = await this.http.get(`/api/v1/events/me/rsvps`, { params: Object.assign(Object.assign({}, params), { options }) });
|
|
46922
|
+
return response;
|
|
46923
|
+
}
|
|
46924
|
+
}
|
|
46925
|
+
|
|
46926
|
+
class MyEventQueryStreamController extends QueryStreamController {
|
|
46927
|
+
constructor(query, cacheKey, notifyChange, preparePayload) {
|
|
46928
|
+
super(query, cacheKey);
|
|
46929
|
+
this.notifyChange = notifyChange;
|
|
46930
|
+
this.preparePayload = preparePayload;
|
|
46931
|
+
}
|
|
46932
|
+
async saveToMainDB(response) {
|
|
46933
|
+
const processedPayload = this.preparePayload(response);
|
|
46934
|
+
const client = getActiveClient();
|
|
46935
|
+
const cachedAt = client.cache && Date.now();
|
|
46936
|
+
if (client.cache)
|
|
46937
|
+
ingestInCache(processedPayload, { cachedAt });
|
|
46938
|
+
}
|
|
46939
|
+
appendToQueryStream(response, direction, refresh = false) {
|
|
46940
|
+
var _a, _b;
|
|
46941
|
+
if (refresh) {
|
|
46942
|
+
pushToCache(this.cacheKey, { data: response.events.map(getResolver('event')) });
|
|
46943
|
+
}
|
|
46944
|
+
else {
|
|
46945
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
46946
|
+
const events = (_b = collection === null || collection === void 0 ? void 0 : collection.data) !== null && _b !== void 0 ? _b : [];
|
|
46947
|
+
pushToCache(this.cacheKey, Object.assign(Object.assign({}, collection), { data: [...new Set([...events, ...response.events.map(getResolver('event'))])] }));
|
|
46948
|
+
}
|
|
46949
|
+
}
|
|
46950
|
+
reactor(action) {
|
|
46951
|
+
return (event) => {
|
|
46952
|
+
var _a;
|
|
46953
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
46954
|
+
if (!collection)
|
|
46955
|
+
return;
|
|
46956
|
+
if (action === EventActionsEnum.OnEventCreated) {
|
|
46957
|
+
const client = getActiveClient();
|
|
46958
|
+
if (client.userId !== event.userId)
|
|
46959
|
+
return;
|
|
46960
|
+
collection.data = [...new Set([event.eventId, ...collection.data])];
|
|
46961
|
+
}
|
|
46962
|
+
if (action === EventActionsEnum.OnEventDeleted) {
|
|
46963
|
+
collection.data = collection.data.filter(eventId => eventId !== event.eventId);
|
|
46964
|
+
}
|
|
46965
|
+
pushToCache(this.cacheKey, collection);
|
|
46966
|
+
this.notifyChange({ origin: "event" /* Amity.LiveDataOrigin.EVENT */, loading: false });
|
|
46967
|
+
};
|
|
46968
|
+
}
|
|
46969
|
+
subscribeRTE(createSubscriber) {
|
|
46970
|
+
return createSubscriber.map(subscriber => subscriber.fn(this.reactor(subscriber.action)));
|
|
46971
|
+
}
|
|
46972
|
+
}
|
|
46973
|
+
|
|
46974
|
+
class MyEventLiveCollectionController extends LiveCollectionController {
|
|
46975
|
+
constructor(query, callback) {
|
|
46976
|
+
const queryStreamId = hash(query);
|
|
46977
|
+
const cacheKey = ['event', 'collection', queryStreamId];
|
|
46978
|
+
const paginationController = new MyEventPaginationController(query);
|
|
46979
|
+
super(paginationController, queryStreamId, cacheKey, callback);
|
|
46980
|
+
this.query = query;
|
|
46981
|
+
this.queryStreamController = new MyEventQueryStreamController(this.query, this.cacheKey, this.notifyChange.bind(this), prepareEventPayload);
|
|
46982
|
+
this.callback = callback.bind(this);
|
|
46983
|
+
this.loadPage({ initial: true });
|
|
46984
|
+
}
|
|
46985
|
+
setup() {
|
|
46986
|
+
var _a;
|
|
46987
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
46988
|
+
if (!collection)
|
|
46989
|
+
pushToCache(this.cacheKey, { data: [], params: {} });
|
|
46990
|
+
}
|
|
46991
|
+
async persistModel(queryPayload) {
|
|
46992
|
+
await this.queryStreamController.saveToMainDB(queryPayload);
|
|
46993
|
+
}
|
|
46994
|
+
persistQueryStream({ response, direction, refresh, }) {
|
|
46995
|
+
this.queryStreamController.appendToQueryStream(response, direction, refresh);
|
|
46996
|
+
}
|
|
46997
|
+
startSubscription() {
|
|
46998
|
+
return this.queryStreamController.subscribeRTE([
|
|
46999
|
+
{ fn: onEventCreated, action: EventActionsEnum.OnEventCreated },
|
|
47000
|
+
{ fn: onEventUpdated, action: EventActionsEnum.OnEventUpdated },
|
|
47001
|
+
{ fn: onEventDeleted, action: EventActionsEnum.OnEventDeleted },
|
|
47002
|
+
{ fn: onLocalEventCreated, action: EventActionsEnum.OnEventCreated },
|
|
47003
|
+
{ fn: onLocalEventUpdated, action: EventActionsEnum.OnEventUpdated },
|
|
47004
|
+
{ fn: onLocalEventDeleted, action: EventActionsEnum.OnEventDeleted },
|
|
47005
|
+
]);
|
|
47006
|
+
}
|
|
47007
|
+
notifyChange({ origin, loading, error }) {
|
|
47008
|
+
var _a, _b;
|
|
47009
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
47010
|
+
if (!collection)
|
|
47011
|
+
return;
|
|
47012
|
+
const data = ((_b = collection.data
|
|
47013
|
+
.map(eventId => pullFromCache(['event', 'get', eventId]))
|
|
47014
|
+
.filter(isNonNullable)
|
|
47015
|
+
.map(({ data }) => data)) !== null && _b !== void 0 ? _b : []).map(LinkedObject.event);
|
|
47016
|
+
if (!this.shouldNotify(data) && origin === "event" /* Amity.LiveDataOrigin.EVENT */)
|
|
47017
|
+
return;
|
|
47018
|
+
this.callback({
|
|
47019
|
+
data,
|
|
47020
|
+
error,
|
|
47021
|
+
loading,
|
|
47022
|
+
hasNextPage: !!this.paginationController.getNextToken(),
|
|
47023
|
+
onNextPage: () => this.loadPage({ direction: "next" /* Amity.LiveCollectionPageDirection.NEXT */ }),
|
|
47024
|
+
});
|
|
47025
|
+
}
|
|
47026
|
+
}
|
|
47027
|
+
|
|
47028
|
+
/**
|
|
47029
|
+
* Get my events
|
|
47030
|
+
*
|
|
47031
|
+
* @param params the query parameters
|
|
47032
|
+
* @param callback the callback to be called when the events are updated
|
|
47033
|
+
* @returns events
|
|
47034
|
+
*
|
|
47035
|
+
* @category Event Live Collection
|
|
47036
|
+
*
|
|
47037
|
+
*/
|
|
47038
|
+
const getMyEvents = (params, callback, config) => {
|
|
47039
|
+
const { log, cache } = getActiveClient();
|
|
47040
|
+
if (!cache)
|
|
47041
|
+
console.log(ENABLE_CACHE_MESSAGE);
|
|
47042
|
+
const timestamp = Date.now();
|
|
47043
|
+
log(`getMyEvents: (tmpid: ${timestamp}) > listen`);
|
|
47044
|
+
const myEventLiveCollection = new MyEventLiveCollectionController(params, callback);
|
|
47045
|
+
const disposers = myEventLiveCollection.startSubscription();
|
|
47046
|
+
const cacheKey = myEventLiveCollection.getCacheKey();
|
|
47047
|
+
disposers.push(() => dropFromCache(cacheKey));
|
|
47048
|
+
return () => {
|
|
47049
|
+
log(`getMyEvents (tmpid: ${timestamp}) > dispose`);
|
|
47050
|
+
disposers.forEach(fn => fn());
|
|
47051
|
+
};
|
|
47052
|
+
};
|
|
47053
|
+
|
|
47054
|
+
var index = /*#__PURE__*/Object.freeze({
|
|
47055
|
+
__proto__: null,
|
|
47056
|
+
createEvent: createEvent,
|
|
47057
|
+
updateEvent: updateEvent,
|
|
47058
|
+
deleteEvent: deleteEvent,
|
|
47059
|
+
onEventCreated: onEventCreated,
|
|
47060
|
+
onEventUpdated: onEventUpdated,
|
|
47061
|
+
onEventDeleted: onEventDeleted,
|
|
47062
|
+
onLocalEventCreated: onLocalEventCreated,
|
|
47063
|
+
onLocalEventUpdated: onLocalEventUpdated,
|
|
47064
|
+
onLocalEventDeleted: onLocalEventDeleted,
|
|
47065
|
+
getEvent: getEvent,
|
|
47066
|
+
getEvents: getEvents,
|
|
47067
|
+
getMyEvents: getMyEvents
|
|
47068
|
+
});
|
|
47069
|
+
|
|
47070
|
+
export { API_REGIONS, index$4 as AdRepository, AmityEventOriginType, AmityEventResponseStatus, AmityEventStatus, AmityEventType, index$c as CategoryRepository, index$g as ChannelRepository, index$p as Client, index$b as CommentRepository, CommunityPostSettingMaps, CommunityPostSettings, index$d as CommunityRepository, ContentFeedType, ContentFlagReasonEnum, DefaultCommunityPostSetting, index as EventRepository, FeedDataTypeEnum, index$a as FeedRepository, FeedSortByEnum, FeedSourceEnum, FileAccessTypeEnum, index$m as FileRepository, FileType, GET_WATCHER_URLS, index$2 as InvitationRepository, InvitationSortByEnum, InvitationStatusEnum, InvitationTypeEnum, JoinRequestStatusEnum, JoinResultStatusEnum, index$1 as LiveReactionRepository, index$6 as LiveStreamPlayer, MembershipAcceptanceTypeEnum, MessageContentType, index$k as MessageRepository, index$7 as PollRepository, PostContentType, index$9 as PostRepository, PostStructureType, index$l as ReactionRepository, index$5 as StoryRepository, index$8 as StreamRepository, index$j as SubChannelRepository, SubscriptionLevels, index$n as UserRepository, UserTypeEnum, VERSION, VideoResolution, VideoSize, VideoTranscodingStatus, backupCache, createQuery, createReport, createUserToken, deleteReport, disableCache, dropFromCache, enableCache, filterByChannelMembership, filterByCommunityMembership, filterByFeedType, filterByPostDataTypes, filterByPropEquality, filterByPropInclusion, filterByPropIntersection, filterBySearchTerm, filterByStringComparePartially, getChannelTopic, getCommentTopic, getCommunityStoriesTopic, getCommunityTopic, getLiveReactionTopic, getLiveStreamTopic, getMarkedMessageTopic, getMarkerUserFeedTopic, getMessageTopic, getMyFollowersTopic, getMyFollowingsTopic, getNetworkTopic, getPostTopic, getRole, getSmartFeedChannelTopic, getSmartFeedMessageTopic, getSmartFeedSubChannelTopic, getStoryTopic, getSubChannelTopic, getUserTopic, isAfterBefore, isAfterBeforeRaw, isCachable, isFetcher, isFresh, isLocal, isMutator, isOffline, isPaged, isReportedByMe, isSkip, mergeInCache, index$3 as notificationTray, onChannelMarkerFetched, onFeedMarkerFetched, onFeedMarkerUpdated, onMessageMarked, onMessageMarkerFetched, onSubChannelMarkerFetched, onSubChannelMarkerUpdated, onUserMarkerFetched, onUserMarkerFetchedLegacy, pullFromCache, pushToCache, queryCache, queryOptions, queryRoles, restoreCache, runQuery, sortByChannelSegment, sortByDisplayName, sortByFirstCreated, sortByFirstUpdated, sortByLastActivity, sortByLastCreated, sortByLastUpdated, sortByLocalSortingDate, sortByName, sortBySegmentNumber, subscribeTopic, toPage, toPageRaw, toToken, upsertInCache, wipeCache };
|