@amityco/ts-sdk 7.11.1-c23e18e.0 → 7.11.1-c511b906.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 +11 -0
- package/dist/@types/core/events.d.ts.map +1 -1
- package/dist/@types/core/model.d.ts +3 -0
- package/dist/@types/core/model.d.ts.map +1 -1
- package/dist/@types/core/payload.d.ts +6 -0
- package/dist/@types/core/payload.d.ts.map +1 -1
- package/dist/@types/domains/content.d.ts +4 -1
- package/dist/@types/domains/content.d.ts.map +1 -1
- package/dist/@types/domains/feed.d.ts +2 -1
- package/dist/@types/domains/feed.d.ts.map +1 -1
- package/dist/@types/domains/post.d.ts +2 -0
- package/dist/@types/domains/post.d.ts.map +1 -1
- package/dist/@types/domains/room.d.ts +77 -0
- package/dist/@types/domains/room.d.ts.map +1 -0
- package/dist/@types/index.d.ts +2 -0
- package/dist/@types/index.d.ts.map +1 -1
- package/dist/channelRepository/api/createChannel.d.ts +1 -0
- 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/index.cjs.js +862 -38
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.esm.js +849 -26
- package/dist/index.umd.js +3 -3
- package/dist/messagePreview/utils/getSubChannelMessagePreviewWithUser.d.ts +1 -1
- package/dist/roomRepository/api/createRoom.d.ts +24 -0
- package/dist/roomRepository/api/createRoom.d.ts.map +1 -0
- package/dist/roomRepository/api/deleteRoom.d.ts +16 -0
- package/dist/roomRepository/api/deleteRoom.d.ts.map +1 -0
- package/dist/roomRepository/api/getBroadcasterData.d.ts +16 -0
- package/dist/roomRepository/api/getBroadcasterData.d.ts.map +1 -0
- package/dist/roomRepository/api/getRecordedUrl.d.ts +19 -0
- package/dist/roomRepository/api/getRecordedUrl.d.ts.map +1 -0
- package/dist/roomRepository/api/index.d.ts +7 -0
- package/dist/roomRepository/api/index.d.ts.map +1 -0
- package/dist/roomRepository/api/stopRoom.d.ts +16 -0
- package/dist/roomRepository/api/stopRoom.d.ts.map +1 -0
- package/dist/roomRepository/api/updateRoom.d.ts +24 -0
- package/dist/roomRepository/api/updateRoom.d.ts.map +1 -0
- package/dist/roomRepository/events/index.d.ts +12 -0
- package/dist/roomRepository/events/index.d.ts.map +1 -0
- package/dist/roomRepository/events/onRoomCreated.d.ts +17 -0
- package/dist/roomRepository/events/onRoomCreated.d.ts.map +1 -0
- package/dist/roomRepository/events/onRoomDeleted.d.ts +17 -0
- package/dist/roomRepository/events/onRoomDeleted.d.ts.map +1 -0
- package/dist/roomRepository/events/onRoomEndBroadcasting.d.ts +17 -0
- package/dist/roomRepository/events/onRoomEndBroadcasting.d.ts.map +1 -0
- package/dist/roomRepository/events/onRoomParticipantInviting.d.ts +17 -0
- package/dist/roomRepository/events/onRoomParticipantInviting.d.ts.map +1 -0
- package/dist/roomRepository/events/onRoomParticipantJoined.d.ts +17 -0
- package/dist/roomRepository/events/onRoomParticipantJoined.d.ts.map +1 -0
- package/dist/roomRepository/events/onRoomParticipantLeft.d.ts +17 -0
- package/dist/roomRepository/events/onRoomParticipantLeft.d.ts.map +1 -0
- package/dist/roomRepository/events/onRoomRecordedAvailable.d.ts +17 -0
- package/dist/roomRepository/events/onRoomRecordedAvailable.d.ts.map +1 -0
- package/dist/roomRepository/events/onRoomStartBroadcasting.d.ts +17 -0
- package/dist/roomRepository/events/onRoomStartBroadcasting.d.ts.map +1 -0
- package/dist/roomRepository/events/onRoomStopped.d.ts +17 -0
- package/dist/roomRepository/events/onRoomStopped.d.ts.map +1 -0
- package/dist/roomRepository/events/onRoomUpdated.d.ts +17 -0
- package/dist/roomRepository/events/onRoomUpdated.d.ts.map +1 -0
- package/dist/roomRepository/events/onRoomWaitingReconnect.d.ts +17 -0
- package/dist/roomRepository/events/onRoomWaitingReconnect.d.ts.map +1 -0
- package/dist/roomRepository/index.d.ts +4 -0
- package/dist/roomRepository/index.d.ts.map +1 -0
- package/dist/roomRepository/internalApi/getLiveChat.d.ts +16 -0
- package/dist/roomRepository/internalApi/getLiveChat.d.ts.map +1 -0
- package/dist/roomRepository/internalApi/getRoomById.d.ts +5 -0
- package/dist/roomRepository/internalApi/getRoomById.d.ts.map +1 -0
- package/dist/roomRepository/internalApi/index.d.ts +3 -0
- package/dist/roomRepository/internalApi/index.d.ts.map +1 -0
- package/dist/roomRepository/observers/enums.d.ts +10 -0
- package/dist/roomRepository/observers/enums.d.ts.map +1 -0
- package/dist/roomRepository/observers/getRoom.d.ts +2 -0
- package/dist/roomRepository/observers/getRoom.d.ts.map +1 -0
- package/dist/roomRepository/observers/getRooms/RoomLiveCollectionController.d.ts +14 -0
- package/dist/roomRepository/observers/getRooms/RoomLiveCollectionController.d.ts.map +1 -0
- package/dist/roomRepository/observers/getRooms/RoomPaginationController.d.ts +5 -0
- package/dist/roomRepository/observers/getRooms/RoomPaginationController.d.ts.map +1 -0
- package/dist/roomRepository/observers/getRooms/RoomQueryStreamController.d.ts +15 -0
- package/dist/roomRepository/observers/getRooms/RoomQueryStreamController.d.ts.map +1 -0
- package/dist/roomRepository/observers/getRooms.d.ts +29 -0
- package/dist/roomRepository/observers/getRooms.d.ts.map +1 -0
- package/dist/roomRepository/observers/index.d.ts +3 -0
- package/dist/roomRepository/observers/index.d.ts.map +1 -0
- package/dist/roomRepository/observers/utils.d.ts +6 -0
- package/dist/roomRepository/observers/utils.d.ts.map +1 -0
- package/dist/utils/linkedObject/postLinkedObject.d.ts.map +1 -1
- package/dist/utils/linkedObject/roomLinkedObject.d.ts +2 -0
- package/dist/utils/linkedObject/roomLinkedObject.d.ts.map +1 -0
- package/dist/utils/postTypePredicate.d.ts +1 -0
- 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/index.cjs.js
CHANGED
|
@@ -127,6 +127,7 @@ const PostContentType = Object.freeze({
|
|
|
127
127
|
POLL: 'poll',
|
|
128
128
|
CLIP: 'clip',
|
|
129
129
|
AUDIO: 'audio',
|
|
130
|
+
ROOM: 'room',
|
|
130
131
|
});
|
|
131
132
|
const PostStructureType = Object.freeze({
|
|
132
133
|
TEXT: 'text',
|
|
@@ -178,6 +179,7 @@ exports.FeedDataTypeEnum = void 0;
|
|
|
178
179
|
FeedDataTypeEnum["LiveStream"] = "liveStream";
|
|
179
180
|
FeedDataTypeEnum["Clip"] = "clip";
|
|
180
181
|
FeedDataTypeEnum["Poll"] = "poll";
|
|
182
|
+
FeedDataTypeEnum["Room"] = "room";
|
|
181
183
|
})(exports.FeedDataTypeEnum || (exports.FeedDataTypeEnum = {}));
|
|
182
184
|
exports.FeedSortByEnum = void 0;
|
|
183
185
|
(function (FeedSortByEnum) {
|
|
@@ -640,6 +642,7 @@ const idResolvers = {
|
|
|
640
642
|
notificationTraySeen: ({ userId }) => userId,
|
|
641
643
|
invitation: ({ _id }) => _id,
|
|
642
644
|
joinRequest: ({ joinRequestId }) => joinRequestId,
|
|
645
|
+
room: ({ roomId }) => roomId,
|
|
643
646
|
};
|
|
644
647
|
/**
|
|
645
648
|
* Retrieve the id resolver matching a domain name
|
|
@@ -695,6 +698,7 @@ const PAYLOAD2MODEL = {
|
|
|
695
698
|
notificationTrayItems: 'notificationTrayItem',
|
|
696
699
|
invitations: 'invitation',
|
|
697
700
|
joinRequests: 'joinRequest',
|
|
701
|
+
rooms: 'room',
|
|
698
702
|
};
|
|
699
703
|
/** hidden */
|
|
700
704
|
const isOutdated = (prevData, nextData) => {
|
|
@@ -10460,7 +10464,7 @@ const getUserUnread = (callback) => {
|
|
|
10460
10464
|
};
|
|
10461
10465
|
};
|
|
10462
10466
|
|
|
10463
|
-
var index$
|
|
10467
|
+
var index$p = /*#__PURE__*/Object.freeze({
|
|
10464
10468
|
__proto__: null,
|
|
10465
10469
|
getActiveClient: getActiveClient,
|
|
10466
10470
|
getActiveUser: getActiveUser,
|
|
@@ -11679,7 +11683,7 @@ const getMyFollowInfo = (callback) => {
|
|
|
11679
11683
|
};
|
|
11680
11684
|
/* end_public_function */
|
|
11681
11685
|
|
|
11682
|
-
var index$
|
|
11686
|
+
var index$o = /*#__PURE__*/Object.freeze({
|
|
11683
11687
|
__proto__: null,
|
|
11684
11688
|
blockUser: blockUser,
|
|
11685
11689
|
unBlockUser: unBlockUser,
|
|
@@ -12032,7 +12036,7 @@ getChannel$1.locally = (channelId) => {
|
|
|
12032
12036
|
* @category Stream API
|
|
12033
12037
|
* @async
|
|
12034
12038
|
*/
|
|
12035
|
-
const getLiveChat = async (stream) => {
|
|
12039
|
+
const getLiveChat$1 = async (stream) => {
|
|
12036
12040
|
var _a;
|
|
12037
12041
|
const client = getActiveClient();
|
|
12038
12042
|
client.log('stream/getLiveChat', stream.streamId);
|
|
@@ -12099,7 +12103,7 @@ const streamLinkedObject = (stream) => {
|
|
|
12099
12103
|
return streamLinkedObject(streamCache);
|
|
12100
12104
|
})
|
|
12101
12105
|
.filter(isNonNullable);
|
|
12102
|
-
}, getLiveChat: () => getLiveChat(stream), isBanned: !stream.watcherUrl, watcherUrl: null, get [GET_WATCHER_URLS]() {
|
|
12106
|
+
}, getLiveChat: () => getLiveChat$1(stream), isBanned: !stream.watcherUrl, watcherUrl: null, get [GET_WATCHER_URLS]() {
|
|
12103
12107
|
return stream.watcherUrl;
|
|
12104
12108
|
} });
|
|
12105
12109
|
};
|
|
@@ -12207,6 +12211,95 @@ function isAmityAudioPost(post) {
|
|
|
12207
12211
|
'fileId' in post.data &&
|
|
12208
12212
|
post.dataType === 'audio');
|
|
12209
12213
|
}
|
|
12214
|
+
function isAmityRoomPost(post) {
|
|
12215
|
+
return !!(post.data &&
|
|
12216
|
+
typeof post.data !== 'string' &&
|
|
12217
|
+
'roomId' in post.data &&
|
|
12218
|
+
post.dataType === 'room');
|
|
12219
|
+
}
|
|
12220
|
+
|
|
12221
|
+
/**
|
|
12222
|
+
* ```js
|
|
12223
|
+
* import { RoomRepository } from '@amityco/ts-sdk'
|
|
12224
|
+
* const stream = await getStream('foobar')
|
|
12225
|
+
* ```
|
|
12226
|
+
*
|
|
12227
|
+
* Fetches a {@link Amity.Channel} object linked with a current stream
|
|
12228
|
+
*
|
|
12229
|
+
* @param stream {@link Amity.Stream} that has linked live channel
|
|
12230
|
+
* @returns the associated {@link Amity.Channel<'live'>} object
|
|
12231
|
+
*
|
|
12232
|
+
* @category Stream API
|
|
12233
|
+
* @async
|
|
12234
|
+
*/
|
|
12235
|
+
const getLiveChat = async (room) => {
|
|
12236
|
+
var _a;
|
|
12237
|
+
const client = getActiveClient();
|
|
12238
|
+
client.log('room/getLiveChat', room.roomId);
|
|
12239
|
+
if (room.liveChannelId) {
|
|
12240
|
+
const channel = (_a = pullFromCache([
|
|
12241
|
+
'channel',
|
|
12242
|
+
'get',
|
|
12243
|
+
room.liveChannelId,
|
|
12244
|
+
])) === null || _a === void 0 ? void 0 : _a.data;
|
|
12245
|
+
if (channel)
|
|
12246
|
+
return channelLinkedObject(constructChannelObject(channel));
|
|
12247
|
+
const { data } = await getChannel$1(room.liveChannelId);
|
|
12248
|
+
return channelLinkedObject(constructChannelObject(data));
|
|
12249
|
+
}
|
|
12250
|
+
// No Channel ID
|
|
12251
|
+
// streamer: create a new live channel
|
|
12252
|
+
if (room.createdBy === client.userId) {
|
|
12253
|
+
const { data: channel } = await createChannel({
|
|
12254
|
+
type: 'live',
|
|
12255
|
+
postId: room.referenceId,
|
|
12256
|
+
roomId: room.roomId,
|
|
12257
|
+
});
|
|
12258
|
+
// Update channelId to stream object in cache
|
|
12259
|
+
mergeInCache(['room', 'get', room.roomId], {
|
|
12260
|
+
liveChannelId: channel.channelId,
|
|
12261
|
+
});
|
|
12262
|
+
return channel;
|
|
12263
|
+
}
|
|
12264
|
+
// watcher: return undefined
|
|
12265
|
+
return undefined;
|
|
12266
|
+
};
|
|
12267
|
+
|
|
12268
|
+
const roomLinkedObject = (room) => {
|
|
12269
|
+
return Object.assign(Object.assign({}, room), { get moderation() {
|
|
12270
|
+
var _a;
|
|
12271
|
+
return (_a = pullFromCache(['roomModeration', 'get', room.roomId])) === null || _a === void 0 ? void 0 : _a.data;
|
|
12272
|
+
},
|
|
12273
|
+
get post() {
|
|
12274
|
+
var _a;
|
|
12275
|
+
if (room.referenceType !== 'post')
|
|
12276
|
+
return;
|
|
12277
|
+
return (_a = pullFromCache(['post', 'get', room.referenceId])) === null || _a === void 0 ? void 0 : _a.data;
|
|
12278
|
+
},
|
|
12279
|
+
get community() {
|
|
12280
|
+
var _a;
|
|
12281
|
+
if (room.targetType !== 'community')
|
|
12282
|
+
return;
|
|
12283
|
+
return (_a = pullFromCache(['community', 'get', room.targetId])) === null || _a === void 0 ? void 0 : _a.data;
|
|
12284
|
+
},
|
|
12285
|
+
get user() {
|
|
12286
|
+
var _a;
|
|
12287
|
+
return (_a = pullFromCache(['user', 'get', room.createdBy])) === null || _a === void 0 ? void 0 : _a.data;
|
|
12288
|
+
},
|
|
12289
|
+
get childRooms() {
|
|
12290
|
+
if (!room.childRoomIds || room.childRoomIds.length === 0)
|
|
12291
|
+
return [];
|
|
12292
|
+
return room.childRoomIds
|
|
12293
|
+
.map(id => {
|
|
12294
|
+
var _a;
|
|
12295
|
+
const roomCache = (_a = pullFromCache(['room', 'get', id])) === null || _a === void 0 ? void 0 : _a.data;
|
|
12296
|
+
if (!roomCache)
|
|
12297
|
+
return undefined;
|
|
12298
|
+
return roomLinkedObject(roomCache);
|
|
12299
|
+
})
|
|
12300
|
+
.filter(isNonNullable);
|
|
12301
|
+
}, getLiveChat: () => getLiveChat(room) });
|
|
12302
|
+
};
|
|
12210
12303
|
|
|
12211
12304
|
const postLinkedObject = (post) => {
|
|
12212
12305
|
return shallowClone(post, {
|
|
@@ -12301,6 +12394,13 @@ const postLinkedObject = (post) => {
|
|
|
12301
12394
|
? (_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
|
|
12302
12395
|
: undefined;
|
|
12303
12396
|
},
|
|
12397
|
+
getRoomInfo() {
|
|
12398
|
+
var _a, _b;
|
|
12399
|
+
if (!isAmityRoomPost(post))
|
|
12400
|
+
return;
|
|
12401
|
+
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;
|
|
12402
|
+
return room ? roomLinkedObject(room) : undefined;
|
|
12403
|
+
},
|
|
12304
12404
|
});
|
|
12305
12405
|
};
|
|
12306
12406
|
|
|
@@ -14666,9 +14766,9 @@ var AmityUserSearchMatchType;
|
|
|
14666
14766
|
AmityUserSearchMatchType["PARTIAL"] = "partial";
|
|
14667
14767
|
})(AmityUserSearchMatchType || (AmityUserSearchMatchType = {}));
|
|
14668
14768
|
|
|
14669
|
-
var index$
|
|
14769
|
+
var index$n = /*#__PURE__*/Object.freeze({
|
|
14670
14770
|
__proto__: null,
|
|
14671
|
-
Relationship: index$
|
|
14771
|
+
Relationship: index$o,
|
|
14672
14772
|
getUserByIds: getUserByIds,
|
|
14673
14773
|
updateUser: updateUser,
|
|
14674
14774
|
flagUser: flagUser,
|
|
@@ -15071,7 +15171,7 @@ const uploadAudio = async (formData, onProgress) => {
|
|
|
15071
15171
|
};
|
|
15072
15172
|
/* end_public_function */
|
|
15073
15173
|
|
|
15074
|
-
var index$
|
|
15174
|
+
var index$m = /*#__PURE__*/Object.freeze({
|
|
15075
15175
|
__proto__: null,
|
|
15076
15176
|
getFile: getFile,
|
|
15077
15177
|
uploadFile: uploadFile,
|
|
@@ -16883,7 +16983,7 @@ const getReactions$1 = (params, callback, config) => {
|
|
|
16883
16983
|
};
|
|
16884
16984
|
/* end_public_function */
|
|
16885
16985
|
|
|
16886
|
-
var index$
|
|
16986
|
+
var index$l = /*#__PURE__*/Object.freeze({
|
|
16887
16987
|
__proto__: null,
|
|
16888
16988
|
addReaction: addReaction,
|
|
16889
16989
|
removeReaction: removeReaction,
|
|
@@ -18655,7 +18755,7 @@ const getMessages = (params, callback, config) => {
|
|
|
18655
18755
|
};
|
|
18656
18756
|
/* end_public_function */
|
|
18657
18757
|
|
|
18658
|
-
var index$
|
|
18758
|
+
var index$k = /*#__PURE__*/Object.freeze({
|
|
18659
18759
|
__proto__: null,
|
|
18660
18760
|
createMessage: createMessage,
|
|
18661
18761
|
updateMessage: updateMessage,
|
|
@@ -19181,7 +19281,7 @@ const stopMessageReceiptSync = (subChannelId) => {
|
|
|
19181
19281
|
};
|
|
19182
19282
|
/* end_public_function */
|
|
19183
19283
|
|
|
19184
|
-
var index$
|
|
19284
|
+
var index$j = /*#__PURE__*/Object.freeze({
|
|
19185
19285
|
__proto__: null,
|
|
19186
19286
|
getSubChannelByIds: getSubChannels$1,
|
|
19187
19287
|
createSubChannel: createSubChannel,
|
|
@@ -20508,7 +20608,7 @@ const searchMembers$1 = (params, callback, config) => {
|
|
|
20508
20608
|
};
|
|
20509
20609
|
/* end_public_function */
|
|
20510
20610
|
|
|
20511
|
-
var index$
|
|
20611
|
+
var index$i = /*#__PURE__*/Object.freeze({
|
|
20512
20612
|
__proto__: null,
|
|
20513
20613
|
addMembers: addMembers$1,
|
|
20514
20614
|
removeMembers: removeMembers$1,
|
|
@@ -20711,7 +20811,7 @@ const unmuteMembers = async (channelId, userIds) => {
|
|
|
20711
20811
|
};
|
|
20712
20812
|
/* end_public_function */
|
|
20713
20813
|
|
|
20714
|
-
var index$
|
|
20814
|
+
var index$h = /*#__PURE__*/Object.freeze({
|
|
20715
20815
|
__proto__: null,
|
|
20716
20816
|
addRole: addRole,
|
|
20717
20817
|
removeRole: removeRole,
|
|
@@ -20721,10 +20821,10 @@ var index$g = /*#__PURE__*/Object.freeze({
|
|
|
20721
20821
|
unmuteMembers: unmuteMembers
|
|
20722
20822
|
});
|
|
20723
20823
|
|
|
20724
|
-
var index$
|
|
20824
|
+
var index$g = /*#__PURE__*/Object.freeze({
|
|
20725
20825
|
__proto__: null,
|
|
20726
|
-
Membership: index$
|
|
20727
|
-
Moderation: index$
|
|
20826
|
+
Membership: index$i,
|
|
20827
|
+
Moderation: index$h,
|
|
20728
20828
|
getChannelByIds: getChannelByIds$1,
|
|
20729
20829
|
createChannel: createChannel,
|
|
20730
20830
|
updateChannel: updateChannel,
|
|
@@ -22127,7 +22227,7 @@ const searchMembers = (params, callback, config) => {
|
|
|
22127
22227
|
};
|
|
22128
22228
|
/* end_public_function */
|
|
22129
22229
|
|
|
22130
|
-
var index$
|
|
22230
|
+
var index$f = /*#__PURE__*/Object.freeze({
|
|
22131
22231
|
__proto__: null,
|
|
22132
22232
|
addMembers: addMembers,
|
|
22133
22233
|
removeMembers: removeMembers,
|
|
@@ -23378,7 +23478,7 @@ const unbanMembers = async (communityId, userIds) => {
|
|
|
23378
23478
|
};
|
|
23379
23479
|
/* end_public_function */
|
|
23380
23480
|
|
|
23381
|
-
var index$
|
|
23481
|
+
var index$e = /*#__PURE__*/Object.freeze({
|
|
23382
23482
|
__proto__: null,
|
|
23383
23483
|
addRoles: addRoles,
|
|
23384
23484
|
removeRoles: removeRoles,
|
|
@@ -23386,10 +23486,10 @@ var index$d = /*#__PURE__*/Object.freeze({
|
|
|
23386
23486
|
unbanMembers: unbanMembers
|
|
23387
23487
|
});
|
|
23388
23488
|
|
|
23389
|
-
var index$
|
|
23489
|
+
var index$d = /*#__PURE__*/Object.freeze({
|
|
23390
23490
|
__proto__: null,
|
|
23391
|
-
Moderation: index$
|
|
23392
|
-
Membership: index$
|
|
23491
|
+
Moderation: index$e,
|
|
23492
|
+
Membership: index$f,
|
|
23393
23493
|
getCommunityByIds: getCommunities$1,
|
|
23394
23494
|
createCommunity: createCommunity,
|
|
23395
23495
|
updateCommunity: updateCommunity,
|
|
@@ -23623,7 +23723,7 @@ const getCategories = (params, callback, config) => {
|
|
|
23623
23723
|
};
|
|
23624
23724
|
/* end_public_function */
|
|
23625
23725
|
|
|
23626
|
-
var index$
|
|
23726
|
+
var index$c = /*#__PURE__*/Object.freeze({
|
|
23627
23727
|
__proto__: null,
|
|
23628
23728
|
getCategory: getCategory,
|
|
23629
23729
|
getCategories: getCategories
|
|
@@ -24682,7 +24782,7 @@ const getComments = (params, callback, config) => {
|
|
|
24682
24782
|
};
|
|
24683
24783
|
/* end_public_function */
|
|
24684
24784
|
|
|
24685
|
-
var index$
|
|
24785
|
+
var index$b = /*#__PURE__*/Object.freeze({
|
|
24686
24786
|
__proto__: null,
|
|
24687
24787
|
getCommentByIds: getCommentByIds,
|
|
24688
24788
|
createComment: createComment,
|
|
@@ -25353,7 +25453,7 @@ const getUserFeed = (params, callback, config) => {
|
|
|
25353
25453
|
};
|
|
25354
25454
|
/* end_public_function */
|
|
25355
25455
|
|
|
25356
|
-
var index$
|
|
25456
|
+
var index$a = /*#__PURE__*/Object.freeze({
|
|
25357
25457
|
__proto__: null,
|
|
25358
25458
|
queryGlobalFeed: queryGlobalFeed,
|
|
25359
25459
|
getCustomRankingGlobalFeed: getCustomRankingGlobalFeed,
|
|
@@ -27034,7 +27134,7 @@ const searchPostsByHashtag = (params, callback, config) => {
|
|
|
27034
27134
|
};
|
|
27035
27135
|
/* end_public_function */
|
|
27036
27136
|
|
|
27037
|
-
var index$
|
|
27137
|
+
var index$9 = /*#__PURE__*/Object.freeze({
|
|
27038
27138
|
__proto__: null,
|
|
27039
27139
|
getPostByIds: getPostByIds,
|
|
27040
27140
|
createPost: createPost,
|
|
@@ -27642,7 +27742,7 @@ const getStreams = (params, callback, config) => {
|
|
|
27642
27742
|
};
|
|
27643
27743
|
};
|
|
27644
27744
|
|
|
27645
|
-
var index$
|
|
27745
|
+
var index$8 = /*#__PURE__*/Object.freeze({
|
|
27646
27746
|
__proto__: null,
|
|
27647
27747
|
createStream: createStream,
|
|
27648
27748
|
updateStream: updateStream,
|
|
@@ -27660,6 +27760,729 @@ var index$7 = /*#__PURE__*/Object.freeze({
|
|
|
27660
27760
|
getStreams: getStreams
|
|
27661
27761
|
});
|
|
27662
27762
|
|
|
27763
|
+
/* begin_public_function
|
|
27764
|
+
id: room.create
|
|
27765
|
+
*/
|
|
27766
|
+
/**
|
|
27767
|
+
* ```js
|
|
27768
|
+
* import { createRoom } from '@amityco/ts-sdk'
|
|
27769
|
+
* const created = await createRoom({ title: 'my room', 'thumbnailFileId': fileId })
|
|
27770
|
+
* ```
|
|
27771
|
+
*
|
|
27772
|
+
* Creates an {@link Amity.Room}
|
|
27773
|
+
*
|
|
27774
|
+
* @param bundle The data necessary to create a new {@link Amity.Room}
|
|
27775
|
+
* @returns The newly created {@link Amity.Room}
|
|
27776
|
+
*
|
|
27777
|
+
* @category Room API
|
|
27778
|
+
* @async
|
|
27779
|
+
*/
|
|
27780
|
+
const createRoom = async (bundle) => {
|
|
27781
|
+
const client = getActiveClient();
|
|
27782
|
+
client.log('room/createRoom', bundle);
|
|
27783
|
+
const { data } = await client.http.post('/api/v1/rooms', bundle);
|
|
27784
|
+
fireEvent('local.room.created', data);
|
|
27785
|
+
const cachedAt = client.cache && Date.now();
|
|
27786
|
+
// TODO: check if should pick `users` filed which contains participants - if no need to ingest in the cache
|
|
27787
|
+
if (client.cache)
|
|
27788
|
+
ingestInCache(data, { cachedAt });
|
|
27789
|
+
const { rooms } = data;
|
|
27790
|
+
return {
|
|
27791
|
+
data: roomLinkedObject(rooms[0]),
|
|
27792
|
+
cachedAt,
|
|
27793
|
+
};
|
|
27794
|
+
};
|
|
27795
|
+
/* end_public_function */
|
|
27796
|
+
|
|
27797
|
+
/* begin_public_function
|
|
27798
|
+
id: room.update
|
|
27799
|
+
*/
|
|
27800
|
+
/**
|
|
27801
|
+
* ```js
|
|
27802
|
+
* import { updateRoom } from '@amityco/ts-sdk'
|
|
27803
|
+
* const updated = await updateRoom('roomId', { title: 'updated title' })
|
|
27804
|
+
* ```
|
|
27805
|
+
*
|
|
27806
|
+
* Updates an {@link Amity.InternalRoom}
|
|
27807
|
+
*
|
|
27808
|
+
* @param roomId The ID of the room to update
|
|
27809
|
+
* @param bundle The data to update the room with
|
|
27810
|
+
* @returns The updated {@link Amity.InternalRoom}
|
|
27811
|
+
*
|
|
27812
|
+
* @category Room API
|
|
27813
|
+
* @async
|
|
27814
|
+
*/
|
|
27815
|
+
const updateRoom = async (roomId, bundle) => {
|
|
27816
|
+
const client = getActiveClient();
|
|
27817
|
+
client.log('room/updateRoom', { roomId, bundle });
|
|
27818
|
+
const { data } = await client.http.put(`/api/v1/rooms/${roomId}`, bundle);
|
|
27819
|
+
fireEvent('local.room.updated', data);
|
|
27820
|
+
const cachedAt = client.cache && Date.now();
|
|
27821
|
+
if (client.cache)
|
|
27822
|
+
ingestInCache(data, { cachedAt });
|
|
27823
|
+
const { rooms } = data;
|
|
27824
|
+
return {
|
|
27825
|
+
data: rooms[0],
|
|
27826
|
+
cachedAt,
|
|
27827
|
+
};
|
|
27828
|
+
};
|
|
27829
|
+
/* end_public_function */
|
|
27830
|
+
|
|
27831
|
+
/* begin_public_function
|
|
27832
|
+
id: room.delete
|
|
27833
|
+
*/
|
|
27834
|
+
/**
|
|
27835
|
+
* ```js
|
|
27836
|
+
* import { deleteRoom } from '@amityco/ts-sdk'
|
|
27837
|
+
* const result = await deleteRoom('roomId')
|
|
27838
|
+
* ```
|
|
27839
|
+
*
|
|
27840
|
+
* Deletes an {@link Amity.Room}
|
|
27841
|
+
*
|
|
27842
|
+
* @param roomId The ID of the room to delete
|
|
27843
|
+
* @returns Promise that resolves when the room is deleted
|
|
27844
|
+
*
|
|
27845
|
+
* @category Room API
|
|
27846
|
+
* @async
|
|
27847
|
+
*/
|
|
27848
|
+
const deleteRoom = async (roomId) => {
|
|
27849
|
+
const client = getActiveClient();
|
|
27850
|
+
client.log('room/deleteRoom', { roomId });
|
|
27851
|
+
await client.http.delete(`/api/v1/rooms/${roomId}`);
|
|
27852
|
+
fireEvent('local.room.deleted', { rooms: [{ _id: roomId }] });
|
|
27853
|
+
};
|
|
27854
|
+
/* end_public_function */
|
|
27855
|
+
|
|
27856
|
+
/* begin_public_function
|
|
27857
|
+
id: room.stop
|
|
27858
|
+
*/
|
|
27859
|
+
/**
|
|
27860
|
+
* ```js
|
|
27861
|
+
* import { stopRoom } from '@amityco/ts-sdk'
|
|
27862
|
+
* const result = await stopRoom('roomId')
|
|
27863
|
+
* ```
|
|
27864
|
+
*
|
|
27865
|
+
* Stops a room's broadcasting
|
|
27866
|
+
*
|
|
27867
|
+
* @param roomId The ID of the room to stop
|
|
27868
|
+
* @returns The updated room data
|
|
27869
|
+
*
|
|
27870
|
+
* @category Room API
|
|
27871
|
+
* @async
|
|
27872
|
+
*/
|
|
27873
|
+
const stopRoom = async (roomId) => {
|
|
27874
|
+
const client = getActiveClient();
|
|
27875
|
+
client.log('room/stopRoom', { roomId });
|
|
27876
|
+
const { data } = await client.http.post(`/api/v1/rooms/${roomId}/stop`);
|
|
27877
|
+
fireEvent('local.room.stopped', data);
|
|
27878
|
+
const cachedAt = client.cache && Date.now();
|
|
27879
|
+
if (client.cache)
|
|
27880
|
+
ingestInCache(data, { cachedAt });
|
|
27881
|
+
const { rooms } = data;
|
|
27882
|
+
return {
|
|
27883
|
+
data: rooms[0],
|
|
27884
|
+
cachedAt,
|
|
27885
|
+
};
|
|
27886
|
+
};
|
|
27887
|
+
/* end_public_function */
|
|
27888
|
+
|
|
27889
|
+
/* begin_public_function
|
|
27890
|
+
id: room.getBroadcasterData
|
|
27891
|
+
*/
|
|
27892
|
+
/**
|
|
27893
|
+
* ```js
|
|
27894
|
+
* import { getBroadcasterData } from '@amityco/ts-sdk'
|
|
27895
|
+
* const token = await getBroadcasterData('roomId')
|
|
27896
|
+
* ```
|
|
27897
|
+
*
|
|
27898
|
+
* Gets broadcaster data for a room
|
|
27899
|
+
*
|
|
27900
|
+
* @param roomId The ID of the room to get token for
|
|
27901
|
+
* @returns The broadcaster data of the room including coHostToken, coHostUrl and direactStreamUrl
|
|
27902
|
+
*
|
|
27903
|
+
* @category Room API
|
|
27904
|
+
* @async
|
|
27905
|
+
*/
|
|
27906
|
+
const getBroadcasterData = async (roomId) => {
|
|
27907
|
+
const client = getActiveClient();
|
|
27908
|
+
client.log('room/getBroadcasterData', { roomId });
|
|
27909
|
+
const { data } = await client.http.get(`/api/v1/rooms/${roomId}/token`);
|
|
27910
|
+
return data;
|
|
27911
|
+
};
|
|
27912
|
+
/* end_public_function */
|
|
27913
|
+
|
|
27914
|
+
/* begin_public_function
|
|
27915
|
+
id: room.getRecordedUrl
|
|
27916
|
+
*/
|
|
27917
|
+
/**
|
|
27918
|
+
* ```js
|
|
27919
|
+
* import { getRecordedUrl } from '@amityco/ts-sdk'
|
|
27920
|
+
* const recordedUrl = await getRecordedUrl('roomId')
|
|
27921
|
+
* ```
|
|
27922
|
+
*
|
|
27923
|
+
* Gets the recorded URL for a room
|
|
27924
|
+
*
|
|
27925
|
+
* @param roomId The ID of the room to get recorded URL for
|
|
27926
|
+
* @returns The recorded URL information
|
|
27927
|
+
*
|
|
27928
|
+
* @category Room API
|
|
27929
|
+
* @async
|
|
27930
|
+
*/
|
|
27931
|
+
const getRecordedUrl = async (roomId) => {
|
|
27932
|
+
const client = getActiveClient();
|
|
27933
|
+
client.log('room/getRecordedUrl', { roomId });
|
|
27934
|
+
const { data } = await client.http.get(`/api/v1/rooms/${roomId}/recorded`);
|
|
27935
|
+
return data;
|
|
27936
|
+
};
|
|
27937
|
+
/* end_public_function */
|
|
27938
|
+
|
|
27939
|
+
/**
|
|
27940
|
+
* ```js
|
|
27941
|
+
* import { onRoomStartBroadcasting } from '@amityco/ts-sdk'
|
|
27942
|
+
* const dispose = onRoomStartBroadcasting(room => {
|
|
27943
|
+
* // ...
|
|
27944
|
+
* })
|
|
27945
|
+
* ```
|
|
27946
|
+
*
|
|
27947
|
+
* Fired when a {@link Amity.Room} has started broadcasting
|
|
27948
|
+
*
|
|
27949
|
+
* @param callback The function to call when the event was fired
|
|
27950
|
+
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
27951
|
+
*
|
|
27952
|
+
* @category Room Events
|
|
27953
|
+
*/
|
|
27954
|
+
const onRoomStartBroadcasting = (callback) => {
|
|
27955
|
+
const client = getActiveClient();
|
|
27956
|
+
const filter = (payload) => {
|
|
27957
|
+
ingestInCache(payload);
|
|
27958
|
+
callback(payload.rooms[0]);
|
|
27959
|
+
};
|
|
27960
|
+
return createEventSubscriber(client, 'room/onRoomStartBroadcasting', 'room.startBroadcasting', filter);
|
|
27961
|
+
};
|
|
27962
|
+
|
|
27963
|
+
/**
|
|
27964
|
+
* ```js
|
|
27965
|
+
* import { onRoomWaitingReconnect } from '@amityco/ts-sdk'
|
|
27966
|
+
* const dispose = onRoomWaitingReconnect(room => {
|
|
27967
|
+
* // ...
|
|
27968
|
+
* })
|
|
27969
|
+
* ```
|
|
27970
|
+
*
|
|
27971
|
+
* Fired when a {@link Amity.Room} is waiting for reconnection
|
|
27972
|
+
*
|
|
27973
|
+
* @param callback The function to call when the event was fired
|
|
27974
|
+
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
27975
|
+
*
|
|
27976
|
+
* @category Room Events
|
|
27977
|
+
*/
|
|
27978
|
+
const onRoomWaitingReconnect = (callback) => {
|
|
27979
|
+
const client = getActiveClient();
|
|
27980
|
+
const filter = (payload) => {
|
|
27981
|
+
ingestInCache(payload);
|
|
27982
|
+
callback(payload.rooms[0]);
|
|
27983
|
+
};
|
|
27984
|
+
return createEventSubscriber(client, 'room/onRoomWaitingReconnect', 'room.waitingReconnect', filter);
|
|
27985
|
+
};
|
|
27986
|
+
|
|
27987
|
+
/**
|
|
27988
|
+
* ```js
|
|
27989
|
+
* import { onRoomEndBroadcasting } from '@amityco/ts-sdk'
|
|
27990
|
+
* const dispose = onRoomEndBroadcasting(room => {
|
|
27991
|
+
* // ...
|
|
27992
|
+
* })
|
|
27993
|
+
* ```
|
|
27994
|
+
*
|
|
27995
|
+
* Fired when a {@link Amity.Room} has ended broadcasting
|
|
27996
|
+
*
|
|
27997
|
+
* @param callback The function to call when the event was fired
|
|
27998
|
+
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
27999
|
+
*
|
|
28000
|
+
* @category Room Events
|
|
28001
|
+
*/
|
|
28002
|
+
const onRoomEndBroadcasting = (callback) => {
|
|
28003
|
+
const client = getActiveClient();
|
|
28004
|
+
const filter = (payload) => {
|
|
28005
|
+
ingestInCache(payload);
|
|
28006
|
+
callback(payload.rooms[0]);
|
|
28007
|
+
};
|
|
28008
|
+
return createEventSubscriber(client, 'room/onRoomEndBroadcasting', 'room.endBroadcasting', filter);
|
|
28009
|
+
};
|
|
28010
|
+
|
|
28011
|
+
/**
|
|
28012
|
+
* ```js
|
|
28013
|
+
* import { onRoomRecordedAvailable } from '@amityco/ts-sdk'
|
|
28014
|
+
* const dispose = onRoomRecordedAvailable(room => {
|
|
28015
|
+
* // ...
|
|
28016
|
+
* })
|
|
28017
|
+
* ```
|
|
28018
|
+
*
|
|
28019
|
+
* Fired when a {@link Amity.Room} recorded content becomes available
|
|
28020
|
+
*
|
|
28021
|
+
* @param callback The function to call when the event was fired
|
|
28022
|
+
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
28023
|
+
*
|
|
28024
|
+
* @category Room Events
|
|
28025
|
+
*/
|
|
28026
|
+
const onRoomRecordedAvailable = (callback) => {
|
|
28027
|
+
const client = getActiveClient();
|
|
28028
|
+
const filter = (payload) => {
|
|
28029
|
+
ingestInCache(payload);
|
|
28030
|
+
callback(payload.rooms[0]);
|
|
28031
|
+
};
|
|
28032
|
+
return createEventSubscriber(client, 'room/onRoomRecordedAvailable', 'room.recordedAvailable', filter);
|
|
28033
|
+
};
|
|
28034
|
+
|
|
28035
|
+
/**
|
|
28036
|
+
* ```js
|
|
28037
|
+
* import { onRoomParticipantInviting } from '@amityco/ts-sdk'
|
|
28038
|
+
* const dispose = onRoomParticipantInviting(room => {
|
|
28039
|
+
* // ...
|
|
28040
|
+
* })
|
|
28041
|
+
* ```
|
|
28042
|
+
*
|
|
28043
|
+
* Fired when a participant is being invited to a {@link Amity.Room}
|
|
28044
|
+
*
|
|
28045
|
+
* @param callback The function to call when the event was fired
|
|
28046
|
+
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
28047
|
+
*
|
|
28048
|
+
* @category Room Events
|
|
28049
|
+
*/
|
|
28050
|
+
const onRoomParticipantInviting = (callback) => {
|
|
28051
|
+
const client = getActiveClient();
|
|
28052
|
+
const filter = (payload) => {
|
|
28053
|
+
ingestInCache(payload);
|
|
28054
|
+
callback(payload.rooms[0]);
|
|
28055
|
+
};
|
|
28056
|
+
return createEventSubscriber(client, 'room/onRoomParticipantInviting', 'room.participantInviting', filter);
|
|
28057
|
+
};
|
|
28058
|
+
|
|
28059
|
+
/**
|
|
28060
|
+
* ```js
|
|
28061
|
+
* import { onRoomParticipantJoined } from '@amityco/ts-sdk'
|
|
28062
|
+
* const dispose = onRoomParticipantJoined(room => {
|
|
28063
|
+
* // ...
|
|
28064
|
+
* })
|
|
28065
|
+
* ```
|
|
28066
|
+
*
|
|
28067
|
+
* Fired when a participant has joined a {@link Amity.Room}
|
|
28068
|
+
*
|
|
28069
|
+
* @param callback The function to call when the event was fired
|
|
28070
|
+
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
28071
|
+
*
|
|
28072
|
+
* @category Room Events
|
|
28073
|
+
*/
|
|
28074
|
+
const onRoomParticipantJoined = (callback) => {
|
|
28075
|
+
const client = getActiveClient();
|
|
28076
|
+
const filter = (payload) => {
|
|
28077
|
+
ingestInCache(payload);
|
|
28078
|
+
callback(payload.rooms[0]);
|
|
28079
|
+
};
|
|
28080
|
+
return createEventSubscriber(client, 'room/onRoomParticipantJoined', 'room.participantJoined', filter);
|
|
28081
|
+
};
|
|
28082
|
+
|
|
28083
|
+
/**
|
|
28084
|
+
* ```js
|
|
28085
|
+
* import { onRoomParticipantLeft } from '@amityco/ts-sdk'
|
|
28086
|
+
* const dispose = onRoomParticipantLeft(room => {
|
|
28087
|
+
* // ...
|
|
28088
|
+
* })
|
|
28089
|
+
* ```
|
|
28090
|
+
*
|
|
28091
|
+
* Fired when a participant has left a {@link Amity.Room}
|
|
28092
|
+
*
|
|
28093
|
+
* @param callback The function to call when the event was fired
|
|
28094
|
+
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
28095
|
+
*
|
|
28096
|
+
* @category Room Events
|
|
28097
|
+
*/
|
|
28098
|
+
const onRoomParticipantLeft = (callback) => {
|
|
28099
|
+
const client = getActiveClient();
|
|
28100
|
+
const filter = (payload) => {
|
|
28101
|
+
ingestInCache(payload);
|
|
28102
|
+
callback(payload.rooms[0]);
|
|
28103
|
+
};
|
|
28104
|
+
return createEventSubscriber(client, 'room/onRoomParticipantLeft', 'room.participantLeft', filter);
|
|
28105
|
+
};
|
|
28106
|
+
|
|
28107
|
+
/**
|
|
28108
|
+
* ```js
|
|
28109
|
+
* import { onRoomCreated } from '@amityco/ts-sdk'
|
|
28110
|
+
* const dispose = onRoomCreated(room => {
|
|
28111
|
+
* // ...
|
|
28112
|
+
* })
|
|
28113
|
+
* ```
|
|
28114
|
+
*
|
|
28115
|
+
* Fired when a {@link Amity.Room} has been created locally
|
|
28116
|
+
*
|
|
28117
|
+
* @param callback The function to call when the event was fired
|
|
28118
|
+
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
28119
|
+
*
|
|
28120
|
+
* @category Room Events
|
|
28121
|
+
*/
|
|
28122
|
+
const onRoomCreated = (callback) => {
|
|
28123
|
+
const client = getActiveClient();
|
|
28124
|
+
const filter = (payload) => {
|
|
28125
|
+
ingestInCache(payload);
|
|
28126
|
+
callback(payload.rooms[0]);
|
|
28127
|
+
};
|
|
28128
|
+
return createEventSubscriber(client, 'room/onRoomCreated', 'local.room.created', filter);
|
|
28129
|
+
};
|
|
28130
|
+
|
|
28131
|
+
/**
|
|
28132
|
+
* ```js
|
|
28133
|
+
* import { onRoomUpdated } from '@amityco/ts-sdk'
|
|
28134
|
+
* const dispose = onRoomUpdated(room => {
|
|
28135
|
+
* // ...
|
|
28136
|
+
* })
|
|
28137
|
+
* ```
|
|
28138
|
+
*
|
|
28139
|
+
* Fired when a {@link Amity.Room} has been updated locally
|
|
28140
|
+
*
|
|
28141
|
+
* @param callback The function to call when the event was fired
|
|
28142
|
+
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
28143
|
+
*
|
|
28144
|
+
* @category Room Events
|
|
28145
|
+
*/
|
|
28146
|
+
const onRoomUpdated = (callback) => {
|
|
28147
|
+
const client = getActiveClient();
|
|
28148
|
+
const filter = (payload) => {
|
|
28149
|
+
ingestInCache(payload);
|
|
28150
|
+
callback(payload.rooms[0]);
|
|
28151
|
+
};
|
|
28152
|
+
return createEventSubscriber(client, 'room/onRoomUpdated', 'local.room.updated', filter);
|
|
28153
|
+
};
|
|
28154
|
+
|
|
28155
|
+
/**
|
|
28156
|
+
* ```js
|
|
28157
|
+
* import { onRoomDeleted } from '@amityco/ts-sdk'
|
|
28158
|
+
* const dispose = onRoomDeleted(room => {
|
|
28159
|
+
* // ...
|
|
28160
|
+
* })
|
|
28161
|
+
* ```
|
|
28162
|
+
*
|
|
28163
|
+
* Fired when a {@link Amity.Room} has been deleted locally
|
|
28164
|
+
*
|
|
28165
|
+
* @param callback The function to call when the event was fired
|
|
28166
|
+
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
28167
|
+
*
|
|
28168
|
+
* @category Room Events
|
|
28169
|
+
*/
|
|
28170
|
+
const onRoomDeleted = (callback) => {
|
|
28171
|
+
const client = getActiveClient();
|
|
28172
|
+
const filter = (payload) => {
|
|
28173
|
+
ingestInCache(payload);
|
|
28174
|
+
callback(payload.rooms[0]);
|
|
28175
|
+
};
|
|
28176
|
+
return createEventSubscriber(client, 'room/onRoomDeleted', 'local.room.deleted', filter);
|
|
28177
|
+
};
|
|
28178
|
+
|
|
28179
|
+
/**
|
|
28180
|
+
* ```js
|
|
28181
|
+
* import { onRoomStopped } from '@amityco/ts-sdk'
|
|
28182
|
+
* const dispose = onRoomStopped(room => {
|
|
28183
|
+
* // ...
|
|
28184
|
+
* })
|
|
28185
|
+
* ```
|
|
28186
|
+
*
|
|
28187
|
+
* Fired when a {@link Amity.Room} has been stopped locally
|
|
28188
|
+
*
|
|
28189
|
+
* @param callback The function to call when the event was fired
|
|
28190
|
+
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
28191
|
+
*
|
|
28192
|
+
* @category Room Events
|
|
28193
|
+
*/
|
|
28194
|
+
const onRoomStopped = (callback) => {
|
|
28195
|
+
const client = getActiveClient();
|
|
28196
|
+
const filter = (payload) => {
|
|
28197
|
+
ingestInCache(payload);
|
|
28198
|
+
callback(payload.rooms[0]);
|
|
28199
|
+
};
|
|
28200
|
+
return createEventSubscriber(client, 'room/onRoomStopped', 'local.room.stopped', filter);
|
|
28201
|
+
};
|
|
28202
|
+
|
|
28203
|
+
const getRoomById = async (roomId) => {
|
|
28204
|
+
const client = getActiveClient();
|
|
28205
|
+
client.log('room/getRoomById', roomId);
|
|
28206
|
+
// Check if room is in tombstone
|
|
28207
|
+
isInTombstone('room', roomId);
|
|
28208
|
+
let data;
|
|
28209
|
+
try {
|
|
28210
|
+
const response = await client.http.get(`/api/v1/rooms/${roomId}`);
|
|
28211
|
+
data = response.data;
|
|
28212
|
+
}
|
|
28213
|
+
catch (error) {
|
|
28214
|
+
if (checkIfShouldGoesToTombstone(error === null || error === void 0 ? void 0 : error.code)) {
|
|
28215
|
+
pushToTombstone('room', roomId);
|
|
28216
|
+
}
|
|
28217
|
+
throw error;
|
|
28218
|
+
}
|
|
28219
|
+
const cachedAt = client.cache && Date.now();
|
|
28220
|
+
if (client.cache) {
|
|
28221
|
+
ingestInCache(data, { cachedAt });
|
|
28222
|
+
}
|
|
28223
|
+
return {
|
|
28224
|
+
data: data.rooms[0],
|
|
28225
|
+
cachedAt,
|
|
28226
|
+
};
|
|
28227
|
+
};
|
|
28228
|
+
getRoomById.locally = (roomId) => {
|
|
28229
|
+
const client = getActiveClient();
|
|
28230
|
+
client.log('room/getRoomById.locally', roomId);
|
|
28231
|
+
// Check if room is in tombstone
|
|
28232
|
+
isInTombstone('room', roomId);
|
|
28233
|
+
const cachedAt = client.cache && Date.now();
|
|
28234
|
+
const roomCache = pullFromCache(['room', 'get', roomId]);
|
|
28235
|
+
if (!roomCache)
|
|
28236
|
+
return;
|
|
28237
|
+
return {
|
|
28238
|
+
data: roomCache.data,
|
|
28239
|
+
cachedAt,
|
|
28240
|
+
};
|
|
28241
|
+
};
|
|
28242
|
+
|
|
28243
|
+
const getRoom = (roomId, callback) => {
|
|
28244
|
+
// TODO: add callbackDataSelector if there are linked object fields
|
|
28245
|
+
return liveObject(roomId, callback, '_id', getRoomById, [
|
|
28246
|
+
onRoomEndBroadcasting,
|
|
28247
|
+
onRoomStartBroadcasting,
|
|
28248
|
+
onRoomWaitingReconnect,
|
|
28249
|
+
onRoomRecordedAvailable,
|
|
28250
|
+
]);
|
|
28251
|
+
};
|
|
28252
|
+
|
|
28253
|
+
class RoomPaginationController extends PaginationController {
|
|
28254
|
+
async getRequest(queryParams, token) {
|
|
28255
|
+
const { limit = COLLECTION_DEFAULT_PAGINATION_LIMIT, includeDeleted } = queryParams, params = __rest(queryParams, ["limit", "includeDeleted"]);
|
|
28256
|
+
const baseOptions = {
|
|
28257
|
+
type: params.sortBy || queryParams.limit ? 'pagination' : undefined,
|
|
28258
|
+
};
|
|
28259
|
+
const options = token ? Object.assign(Object.assign({}, baseOptions), { token }) : Object.assign(Object.assign({}, baseOptions), { limit });
|
|
28260
|
+
const { data: queryResponse } = await this.http.get(`/api/v1/rooms`, {
|
|
28261
|
+
params: Object.assign(Object.assign({}, params), { isDeleted: inferIsDeleted(includeDeleted), options }),
|
|
28262
|
+
});
|
|
28263
|
+
return queryResponse;
|
|
28264
|
+
}
|
|
28265
|
+
}
|
|
28266
|
+
|
|
28267
|
+
var EnumRoomActions;
|
|
28268
|
+
(function (EnumRoomActions) {
|
|
28269
|
+
EnumRoomActions["OnRoomCreated"] = "OnRoomCreated";
|
|
28270
|
+
EnumRoomActions["OnRoomUpdated"] = "OnRoomUpdated";
|
|
28271
|
+
EnumRoomActions["OnRoomDeleted"] = "OnRoomDeleted";
|
|
28272
|
+
EnumRoomActions["OnRoomStartBroadcasting"] = "OnRoomStartBroadcasting";
|
|
28273
|
+
EnumRoomActions["OnRoomEndBroadcasting"] = "OnRoomEndBroadcasting";
|
|
28274
|
+
EnumRoomActions["OnRoomParticipantJoined"] = "OnRoomParticipantJoined";
|
|
28275
|
+
EnumRoomActions["OnRoomParticipantLeft"] = "OnRoomParticipantLeft";
|
|
28276
|
+
})(EnumRoomActions || (EnumRoomActions = {}));
|
|
28277
|
+
|
|
28278
|
+
class RoomQueryStreamController extends QueryStreamController {
|
|
28279
|
+
constructor(query, cacheKey, notifyChange, preparePayload) {
|
|
28280
|
+
super(query, cacheKey);
|
|
28281
|
+
this.notifyChange = notifyChange;
|
|
28282
|
+
this.preparePayload = preparePayload;
|
|
28283
|
+
}
|
|
28284
|
+
async saveToMainDB(response) {
|
|
28285
|
+
const processedPayload = await this.preparePayload(response);
|
|
28286
|
+
const client = getActiveClient();
|
|
28287
|
+
const cachedAt = client.cache && Date.now();
|
|
28288
|
+
if (client.cache) {
|
|
28289
|
+
ingestInCache(processedPayload, { cachedAt });
|
|
28290
|
+
}
|
|
28291
|
+
}
|
|
28292
|
+
appendToQueryStream(response, direction, refresh = false) {
|
|
28293
|
+
var _a, _b;
|
|
28294
|
+
if (refresh) {
|
|
28295
|
+
pushToCache(this.cacheKey, {
|
|
28296
|
+
data: response.rooms.map(getResolver('room')),
|
|
28297
|
+
});
|
|
28298
|
+
}
|
|
28299
|
+
else {
|
|
28300
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
28301
|
+
const rooms = (_b = collection === null || collection === void 0 ? void 0 : collection.data) !== null && _b !== void 0 ? _b : [];
|
|
28302
|
+
pushToCache(this.cacheKey, Object.assign(Object.assign({}, collection), { data: [...new Set([...rooms, ...response.rooms.map(getResolver('room'))])] }));
|
|
28303
|
+
}
|
|
28304
|
+
}
|
|
28305
|
+
reactor(action) {
|
|
28306
|
+
return (room) => {
|
|
28307
|
+
var _a;
|
|
28308
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
28309
|
+
if (!collection)
|
|
28310
|
+
return;
|
|
28311
|
+
if (action === EnumRoomActions.OnRoomDeleted) {
|
|
28312
|
+
collection.data = collection.data.filter(roomId => roomId !== room._id);
|
|
28313
|
+
}
|
|
28314
|
+
if (action === EnumRoomActions.OnRoomCreated) {
|
|
28315
|
+
collection.data = [...new Set([room._id, ...collection.data])];
|
|
28316
|
+
}
|
|
28317
|
+
pushToCache(this.cacheKey, collection);
|
|
28318
|
+
this.notifyChange({ origin: "event" /* Amity.LiveDataOrigin.EVENT */, loading: false });
|
|
28319
|
+
};
|
|
28320
|
+
}
|
|
28321
|
+
subscribeRTE(createSubscriber) {
|
|
28322
|
+
return createSubscriber.map(subscriber => subscriber.fn(this.reactor(subscriber.action)));
|
|
28323
|
+
}
|
|
28324
|
+
}
|
|
28325
|
+
|
|
28326
|
+
// TODO: confirm related events
|
|
28327
|
+
const getRoomSubscription = () => [
|
|
28328
|
+
{
|
|
28329
|
+
fn: onRoomStartBroadcasting,
|
|
28330
|
+
action: EnumRoomActions.OnRoomStartBroadcasting,
|
|
28331
|
+
},
|
|
28332
|
+
{
|
|
28333
|
+
fn: onRoomEndBroadcasting,
|
|
28334
|
+
action: EnumRoomActions.OnRoomEndBroadcasting,
|
|
28335
|
+
},
|
|
28336
|
+
{
|
|
28337
|
+
fn: onRoomRecordedAvailable,
|
|
28338
|
+
action: EnumRoomActions.OnRoomUpdated,
|
|
28339
|
+
},
|
|
28340
|
+
];
|
|
28341
|
+
|
|
28342
|
+
class RoomLiveCollectionController extends LiveCollectionController {
|
|
28343
|
+
constructor(query, callback) {
|
|
28344
|
+
const queryStreamId = hash__default["default"](query);
|
|
28345
|
+
const cacheKey = ['rooms', 'collection', queryStreamId];
|
|
28346
|
+
const paginationController = new RoomPaginationController(query);
|
|
28347
|
+
super(paginationController, queryStreamId, cacheKey, callback);
|
|
28348
|
+
this.query = query;
|
|
28349
|
+
this.queryStreamController = new RoomQueryStreamController(this.query, this.cacheKey, this.notifyChange.bind(this), response => response);
|
|
28350
|
+
this.callback = callback.bind(this);
|
|
28351
|
+
this.loadPage({ initial: true });
|
|
28352
|
+
}
|
|
28353
|
+
setup() {
|
|
28354
|
+
var _a;
|
|
28355
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
28356
|
+
if (!collection) {
|
|
28357
|
+
pushToCache(this.cacheKey, {
|
|
28358
|
+
data: [],
|
|
28359
|
+
params: {},
|
|
28360
|
+
});
|
|
28361
|
+
}
|
|
28362
|
+
}
|
|
28363
|
+
async persistModel(queryPayload) {
|
|
28364
|
+
await this.queryStreamController.saveToMainDB(queryPayload);
|
|
28365
|
+
}
|
|
28366
|
+
persistQueryStream({ response, direction, refresh, }) {
|
|
28367
|
+
this.queryStreamController.appendToQueryStream(response, direction, refresh);
|
|
28368
|
+
}
|
|
28369
|
+
startSubscription() {
|
|
28370
|
+
return this.queryStreamController.subscribeRTE(getRoomSubscription());
|
|
28371
|
+
}
|
|
28372
|
+
notifyChange({ origin, loading, error }) {
|
|
28373
|
+
var _a, _b;
|
|
28374
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
28375
|
+
if (!collection)
|
|
28376
|
+
return;
|
|
28377
|
+
const data = this.applyFilter((_b = collection.data
|
|
28378
|
+
.map(id => pullFromCache(['room', 'get', id]))
|
|
28379
|
+
.filter(isNonNullable)
|
|
28380
|
+
.map(({ data }) => data)) !== null && _b !== void 0 ? _b : []).map(room => room); // Since Room is same as InternalRoom, no transformation needed
|
|
28381
|
+
if (!this.shouldNotify(data) && origin === 'event')
|
|
28382
|
+
return;
|
|
28383
|
+
this.callback({
|
|
28384
|
+
onNextPage: () => this.loadPage({ direction: "next" /* Amity.LiveCollectionPageDirection.NEXT */ }),
|
|
28385
|
+
data,
|
|
28386
|
+
hasNextPage: !!this.paginationController.getNextToken(),
|
|
28387
|
+
loading,
|
|
28388
|
+
error,
|
|
28389
|
+
});
|
|
28390
|
+
}
|
|
28391
|
+
applyFilter(data) {
|
|
28392
|
+
let rooms = data;
|
|
28393
|
+
if (!this.query.includeDeleted) {
|
|
28394
|
+
rooms = filterByPropEquality(rooms, 'isDeleted', false);
|
|
28395
|
+
}
|
|
28396
|
+
if (this.query.statuses && this.query.statuses.length > 0) {
|
|
28397
|
+
rooms = rooms.filter(room => { var _a; return (_a = this.query.statuses) === null || _a === void 0 ? void 0 : _a.includes(room.status); });
|
|
28398
|
+
}
|
|
28399
|
+
if (this.query.type) {
|
|
28400
|
+
rooms = filterByPropEquality(rooms, 'type', this.query.type);
|
|
28401
|
+
}
|
|
28402
|
+
switch (this.query.sortBy) {
|
|
28403
|
+
case 'firstCreated':
|
|
28404
|
+
rooms = rooms.sort(sortByFirstCreated);
|
|
28405
|
+
break;
|
|
28406
|
+
case 'lastCreated':
|
|
28407
|
+
default:
|
|
28408
|
+
rooms = rooms.sort(sortByLastCreated);
|
|
28409
|
+
break;
|
|
28410
|
+
}
|
|
28411
|
+
return rooms;
|
|
28412
|
+
}
|
|
28413
|
+
}
|
|
28414
|
+
|
|
28415
|
+
/* begin_public_function
|
|
28416
|
+
id: room.get_rooms
|
|
28417
|
+
*/
|
|
28418
|
+
/**
|
|
28419
|
+
* ```js
|
|
28420
|
+
* import { RoomRepository } from '@amityco/ts-sdk'
|
|
28421
|
+
*
|
|
28422
|
+
* let rooms = []
|
|
28423
|
+
* const unsub = RoomRepository.getRooms({
|
|
28424
|
+
* type: 'direct_streaming',
|
|
28425
|
+
* statuses: ['live', 'idle'],
|
|
28426
|
+
* sortBy: 'lastCreated',
|
|
28427
|
+
* limit: 20,
|
|
28428
|
+
* includeDeleted: false
|
|
28429
|
+
* }, response => merge(rooms, response.data))
|
|
28430
|
+
* ```
|
|
28431
|
+
*
|
|
28432
|
+
* Observe all mutations on a list of {@link Amity.Room} for a given query
|
|
28433
|
+
*
|
|
28434
|
+
* @param params.type the type of rooms to filter by ('direct_streaming' | 'co_hosts')
|
|
28435
|
+
* @param params.statuses array of room statuses to filter by (['idle', 'live', 'waiting_reconnect', 'ended', 'recorded'])
|
|
28436
|
+
* @param params.sortBy sort rooms by creation time ('firstCreated' | 'lastCreated')
|
|
28437
|
+
* @param params.limit maximum number of rooms to retrieve per page
|
|
28438
|
+
* @param params.includeDeleted whether to include deleted rooms in the results
|
|
28439
|
+
* @param callback the function to call when new data are available
|
|
28440
|
+
* @param config optional configuration for the live collection
|
|
28441
|
+
* @returns An {@link Amity.Unsubscriber} function to run when willing to stop observing the rooms
|
|
28442
|
+
*
|
|
28443
|
+
* @category Rooms Live Collection
|
|
28444
|
+
*/
|
|
28445
|
+
const getRooms = (params, callback, config) => {
|
|
28446
|
+
const { log, cache } = getActiveClient();
|
|
28447
|
+
if (!cache) {
|
|
28448
|
+
console.log(ENABLE_CACHE_MESSAGE);
|
|
28449
|
+
}
|
|
28450
|
+
const timestamp = Date.now();
|
|
28451
|
+
log(`getRooms(tmpid: ${timestamp}) > listen`);
|
|
28452
|
+
const roomsLiveCollection = new RoomLiveCollectionController(params, callback);
|
|
28453
|
+
const disposers = roomsLiveCollection.startSubscription();
|
|
28454
|
+
const cacheKey = roomsLiveCollection.getCacheKey();
|
|
28455
|
+
disposers.push(() => dropFromCache(cacheKey));
|
|
28456
|
+
return () => {
|
|
28457
|
+
log(`getRooms(tmpid: ${timestamp}) > dispose`);
|
|
28458
|
+
disposers.forEach(fn => fn());
|
|
28459
|
+
};
|
|
28460
|
+
};
|
|
28461
|
+
/* end_public_function */
|
|
28462
|
+
|
|
28463
|
+
var index$7 = /*#__PURE__*/Object.freeze({
|
|
28464
|
+
__proto__: null,
|
|
28465
|
+
createRoom: createRoom,
|
|
28466
|
+
updateRoom: updateRoom,
|
|
28467
|
+
deleteRoom: deleteRoom,
|
|
28468
|
+
stopRoom: stopRoom,
|
|
28469
|
+
getBroadcasterData: getBroadcasterData,
|
|
28470
|
+
getRecordedUrl: getRecordedUrl,
|
|
28471
|
+
onRoomStartBroadcasting: onRoomStartBroadcasting,
|
|
28472
|
+
onRoomWaitingReconnect: onRoomWaitingReconnect,
|
|
28473
|
+
onRoomEndBroadcasting: onRoomEndBroadcasting,
|
|
28474
|
+
onRoomRecordedAvailable: onRoomRecordedAvailable,
|
|
28475
|
+
onRoomParticipantInviting: onRoomParticipantInviting,
|
|
28476
|
+
onRoomParticipantJoined: onRoomParticipantJoined,
|
|
28477
|
+
onRoomParticipantLeft: onRoomParticipantLeft,
|
|
28478
|
+
onRoomCreated: onRoomCreated,
|
|
28479
|
+
onRoomUpdated: onRoomUpdated,
|
|
28480
|
+
onRoomDeleted: onRoomDeleted,
|
|
28481
|
+
onRoomStopped: onRoomStopped,
|
|
28482
|
+
getRoom: getRoom,
|
|
28483
|
+
getRooms: getRooms
|
|
28484
|
+
});
|
|
28485
|
+
|
|
27663
28486
|
/* begin_public_function
|
|
27664
28487
|
id: poll.create
|
|
27665
28488
|
*/
|
|
@@ -30295,33 +31118,34 @@ var index = /*#__PURE__*/Object.freeze({
|
|
|
30295
31118
|
|
|
30296
31119
|
exports.API_REGIONS = API_REGIONS;
|
|
30297
31120
|
exports.AdRepository = index$3;
|
|
30298
|
-
exports.CategoryRepository = index$
|
|
30299
|
-
exports.ChannelRepository = index$
|
|
30300
|
-
exports.Client = index$
|
|
30301
|
-
exports.CommentRepository = index$
|
|
31121
|
+
exports.CategoryRepository = index$c;
|
|
31122
|
+
exports.ChannelRepository = index$g;
|
|
31123
|
+
exports.Client = index$p;
|
|
31124
|
+
exports.CommentRepository = index$b;
|
|
30302
31125
|
exports.CommunityPostSettingMaps = CommunityPostSettingMaps;
|
|
30303
31126
|
exports.CommunityPostSettings = CommunityPostSettings;
|
|
30304
|
-
exports.CommunityRepository = index$
|
|
31127
|
+
exports.CommunityRepository = index$d;
|
|
30305
31128
|
exports.ContentFeedType = ContentFeedType;
|
|
30306
31129
|
exports.DefaultCommunityPostSetting = DefaultCommunityPostSetting;
|
|
30307
|
-
exports.FeedRepository = index$
|
|
30308
|
-
exports.FileRepository = index$
|
|
31130
|
+
exports.FeedRepository = index$a;
|
|
31131
|
+
exports.FileRepository = index$m;
|
|
30309
31132
|
exports.FileType = FileType;
|
|
30310
31133
|
exports.GET_WATCHER_URLS = GET_WATCHER_URLS;
|
|
30311
31134
|
exports.InvitationRepository = index$1;
|
|
30312
31135
|
exports.LiveReactionRepository = index;
|
|
30313
31136
|
exports.LiveStreamPlayer = index$5;
|
|
30314
31137
|
exports.MessageContentType = MessageContentType;
|
|
30315
|
-
exports.MessageRepository = index$
|
|
31138
|
+
exports.MessageRepository = index$k;
|
|
30316
31139
|
exports.PollRepository = index$6;
|
|
30317
31140
|
exports.PostContentType = PostContentType;
|
|
30318
|
-
exports.PostRepository = index$
|
|
31141
|
+
exports.PostRepository = index$9;
|
|
30319
31142
|
exports.PostStructureType = PostStructureType;
|
|
30320
|
-
exports.ReactionRepository = index$
|
|
31143
|
+
exports.ReactionRepository = index$l;
|
|
31144
|
+
exports.RoomRepository = index$7;
|
|
30321
31145
|
exports.StoryRepository = index$4;
|
|
30322
|
-
exports.StreamRepository = index$
|
|
30323
|
-
exports.SubChannelRepository = index$
|
|
30324
|
-
exports.UserRepository = index$
|
|
31146
|
+
exports.StreamRepository = index$8;
|
|
31147
|
+
exports.SubChannelRepository = index$j;
|
|
31148
|
+
exports.UserRepository = index$n;
|
|
30325
31149
|
exports.VERSION = VERSION;
|
|
30326
31150
|
exports.VideoResolution = VideoResolution;
|
|
30327
31151
|
exports.VideoSize = VideoSize;
|