@amityco/ts-sdk 7.11.1-c23e18e.0 → 7.11.1-c8b7189a.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.esm.js
CHANGED
|
@@ -112,6 +112,7 @@ const PostContentType = Object.freeze({
|
|
|
112
112
|
POLL: 'poll',
|
|
113
113
|
CLIP: 'clip',
|
|
114
114
|
AUDIO: 'audio',
|
|
115
|
+
ROOM: 'room',
|
|
115
116
|
});
|
|
116
117
|
const PostStructureType = Object.freeze({
|
|
117
118
|
TEXT: 'text',
|
|
@@ -163,6 +164,7 @@ var FeedDataTypeEnum;
|
|
|
163
164
|
FeedDataTypeEnum["LiveStream"] = "liveStream";
|
|
164
165
|
FeedDataTypeEnum["Clip"] = "clip";
|
|
165
166
|
FeedDataTypeEnum["Poll"] = "poll";
|
|
167
|
+
FeedDataTypeEnum["Room"] = "room";
|
|
166
168
|
})(FeedDataTypeEnum || (FeedDataTypeEnum = {}));
|
|
167
169
|
var FeedSortByEnum;
|
|
168
170
|
(function (FeedSortByEnum) {
|
|
@@ -625,6 +627,7 @@ const idResolvers = {
|
|
|
625
627
|
notificationTraySeen: ({ userId }) => userId,
|
|
626
628
|
invitation: ({ _id }) => _id,
|
|
627
629
|
joinRequest: ({ joinRequestId }) => joinRequestId,
|
|
630
|
+
room: ({ roomId }) => roomId,
|
|
628
631
|
};
|
|
629
632
|
/**
|
|
630
633
|
* Retrieve the id resolver matching a domain name
|
|
@@ -680,6 +683,7 @@ const PAYLOAD2MODEL = {
|
|
|
680
683
|
notificationTrayItems: 'notificationTrayItem',
|
|
681
684
|
invitations: 'invitation',
|
|
682
685
|
joinRequests: 'joinRequest',
|
|
686
|
+
rooms: 'room',
|
|
683
687
|
};
|
|
684
688
|
/** hidden */
|
|
685
689
|
const isOutdated = (prevData, nextData) => {
|
|
@@ -26552,7 +26556,7 @@ const getUserUnread = (callback) => {
|
|
|
26552
26556
|
};
|
|
26553
26557
|
};
|
|
26554
26558
|
|
|
26555
|
-
var index$
|
|
26559
|
+
var index$p = /*#__PURE__*/Object.freeze({
|
|
26556
26560
|
__proto__: null,
|
|
26557
26561
|
getActiveClient: getActiveClient,
|
|
26558
26562
|
getActiveUser: getActiveUser,
|
|
@@ -27771,7 +27775,7 @@ const getMyFollowInfo = (callback) => {
|
|
|
27771
27775
|
};
|
|
27772
27776
|
/* end_public_function */
|
|
27773
27777
|
|
|
27774
|
-
var index$
|
|
27778
|
+
var index$o = /*#__PURE__*/Object.freeze({
|
|
27775
27779
|
__proto__: null,
|
|
27776
27780
|
blockUser: blockUser,
|
|
27777
27781
|
unBlockUser: unBlockUser,
|
|
@@ -28124,7 +28128,7 @@ getChannel$1.locally = (channelId) => {
|
|
|
28124
28128
|
* @category Stream API
|
|
28125
28129
|
* @async
|
|
28126
28130
|
*/
|
|
28127
|
-
const getLiveChat = async (stream) => {
|
|
28131
|
+
const getLiveChat$1 = async (stream) => {
|
|
28128
28132
|
var _a;
|
|
28129
28133
|
const client = getActiveClient();
|
|
28130
28134
|
client.log('stream/getLiveChat', stream.streamId);
|
|
@@ -28191,7 +28195,7 @@ const streamLinkedObject = (stream) => {
|
|
|
28191
28195
|
return streamLinkedObject(streamCache);
|
|
28192
28196
|
})
|
|
28193
28197
|
.filter(isNonNullable);
|
|
28194
|
-
}, getLiveChat: () => getLiveChat(stream), isBanned: !stream.watcherUrl, watcherUrl: null, get [GET_WATCHER_URLS]() {
|
|
28198
|
+
}, getLiveChat: () => getLiveChat$1(stream), isBanned: !stream.watcherUrl, watcherUrl: null, get [GET_WATCHER_URLS]() {
|
|
28195
28199
|
return stream.watcherUrl;
|
|
28196
28200
|
} });
|
|
28197
28201
|
};
|
|
@@ -28299,6 +28303,95 @@ function isAmityAudioPost(post) {
|
|
|
28299
28303
|
'fileId' in post.data &&
|
|
28300
28304
|
post.dataType === 'audio');
|
|
28301
28305
|
}
|
|
28306
|
+
function isAmityRoomPost(post) {
|
|
28307
|
+
return !!(post.data &&
|
|
28308
|
+
typeof post.data !== 'string' &&
|
|
28309
|
+
'roomId' in post.data &&
|
|
28310
|
+
post.dataType === 'room');
|
|
28311
|
+
}
|
|
28312
|
+
|
|
28313
|
+
/**
|
|
28314
|
+
* ```js
|
|
28315
|
+
* import { RoomRepository } from '@amityco/ts-sdk'
|
|
28316
|
+
* const stream = await getStream('foobar')
|
|
28317
|
+
* ```
|
|
28318
|
+
*
|
|
28319
|
+
* Fetches a {@link Amity.Channel} object linked with a current stream
|
|
28320
|
+
*
|
|
28321
|
+
* @param stream {@link Amity.Stream} that has linked live channel
|
|
28322
|
+
* @returns the associated {@link Amity.Channel<'live'>} object
|
|
28323
|
+
*
|
|
28324
|
+
* @category Stream API
|
|
28325
|
+
* @async
|
|
28326
|
+
*/
|
|
28327
|
+
const getLiveChat = async (room) => {
|
|
28328
|
+
var _a;
|
|
28329
|
+
const client = getActiveClient();
|
|
28330
|
+
client.log('room/getLiveChat', room.roomId);
|
|
28331
|
+
if (room.liveChannelId) {
|
|
28332
|
+
const channel = (_a = pullFromCache([
|
|
28333
|
+
'channel',
|
|
28334
|
+
'get',
|
|
28335
|
+
room.liveChannelId,
|
|
28336
|
+
])) === null || _a === void 0 ? void 0 : _a.data;
|
|
28337
|
+
if (channel)
|
|
28338
|
+
return channelLinkedObject(constructChannelObject(channel));
|
|
28339
|
+
const { data } = await getChannel$1(room.liveChannelId);
|
|
28340
|
+
return channelLinkedObject(constructChannelObject(data));
|
|
28341
|
+
}
|
|
28342
|
+
// No Channel ID
|
|
28343
|
+
// streamer: create a new live channel
|
|
28344
|
+
if (room.createdBy === client.userId) {
|
|
28345
|
+
const { data: channel } = await createChannel({
|
|
28346
|
+
type: 'live',
|
|
28347
|
+
postId: room.referenceId,
|
|
28348
|
+
roomId: room.roomId,
|
|
28349
|
+
});
|
|
28350
|
+
// Update channelId to stream object in cache
|
|
28351
|
+
mergeInCache(['room', 'get', room.roomId], {
|
|
28352
|
+
liveChannelId: channel.channelId,
|
|
28353
|
+
});
|
|
28354
|
+
return channel;
|
|
28355
|
+
}
|
|
28356
|
+
// watcher: return undefined
|
|
28357
|
+
return undefined;
|
|
28358
|
+
};
|
|
28359
|
+
|
|
28360
|
+
const roomLinkedObject = (room) => {
|
|
28361
|
+
return Object.assign(Object.assign({}, room), { get moderation() {
|
|
28362
|
+
var _a;
|
|
28363
|
+
return (_a = pullFromCache(['roomModeration', 'get', room.roomId])) === null || _a === void 0 ? void 0 : _a.data;
|
|
28364
|
+
},
|
|
28365
|
+
get post() {
|
|
28366
|
+
var _a;
|
|
28367
|
+
if (room.referenceType !== 'post')
|
|
28368
|
+
return;
|
|
28369
|
+
return (_a = pullFromCache(['post', 'get', room.referenceId])) === null || _a === void 0 ? void 0 : _a.data;
|
|
28370
|
+
},
|
|
28371
|
+
get community() {
|
|
28372
|
+
var _a;
|
|
28373
|
+
if (room.targetType !== 'community')
|
|
28374
|
+
return;
|
|
28375
|
+
return (_a = pullFromCache(['community', 'get', room.targetId])) === null || _a === void 0 ? void 0 : _a.data;
|
|
28376
|
+
},
|
|
28377
|
+
get user() {
|
|
28378
|
+
var _a;
|
|
28379
|
+
return (_a = pullFromCache(['user', 'get', room.createdBy])) === null || _a === void 0 ? void 0 : _a.data;
|
|
28380
|
+
},
|
|
28381
|
+
get childRooms() {
|
|
28382
|
+
if (!room.childRoomIds || room.childRoomIds.length === 0)
|
|
28383
|
+
return [];
|
|
28384
|
+
return room.childRoomIds
|
|
28385
|
+
.map(id => {
|
|
28386
|
+
var _a;
|
|
28387
|
+
const roomCache = (_a = pullFromCache(['room', 'get', id])) === null || _a === void 0 ? void 0 : _a.data;
|
|
28388
|
+
if (!roomCache)
|
|
28389
|
+
return undefined;
|
|
28390
|
+
return roomLinkedObject(roomCache);
|
|
28391
|
+
})
|
|
28392
|
+
.filter(isNonNullable);
|
|
28393
|
+
}, getLiveChat: () => getLiveChat(room) });
|
|
28394
|
+
};
|
|
28302
28395
|
|
|
28303
28396
|
const postLinkedObject = (post) => {
|
|
28304
28397
|
return shallowClone(post, {
|
|
@@ -28393,6 +28486,13 @@ const postLinkedObject = (post) => {
|
|
|
28393
28486
|
? (_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
|
|
28394
28487
|
: undefined;
|
|
28395
28488
|
},
|
|
28489
|
+
getRoomInfo() {
|
|
28490
|
+
var _a, _b;
|
|
28491
|
+
if (!isAmityRoomPost(post))
|
|
28492
|
+
return;
|
|
28493
|
+
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;
|
|
28494
|
+
return room ? roomLinkedObject(room) : undefined;
|
|
28495
|
+
},
|
|
28396
28496
|
});
|
|
28397
28497
|
};
|
|
28398
28498
|
|
|
@@ -30758,9 +30858,9 @@ var AmityUserSearchMatchType;
|
|
|
30758
30858
|
AmityUserSearchMatchType["PARTIAL"] = "partial";
|
|
30759
30859
|
})(AmityUserSearchMatchType || (AmityUserSearchMatchType = {}));
|
|
30760
30860
|
|
|
30761
|
-
var index$
|
|
30861
|
+
var index$n = /*#__PURE__*/Object.freeze({
|
|
30762
30862
|
__proto__: null,
|
|
30763
|
-
Relationship: index$
|
|
30863
|
+
Relationship: index$o,
|
|
30764
30864
|
getUserByIds: getUserByIds,
|
|
30765
30865
|
updateUser: updateUser,
|
|
30766
30866
|
flagUser: flagUser,
|
|
@@ -31163,7 +31263,7 @@ const uploadAudio = async (formData, onProgress) => {
|
|
|
31163
31263
|
};
|
|
31164
31264
|
/* end_public_function */
|
|
31165
31265
|
|
|
31166
|
-
var index$
|
|
31266
|
+
var index$m = /*#__PURE__*/Object.freeze({
|
|
31167
31267
|
__proto__: null,
|
|
31168
31268
|
getFile: getFile,
|
|
31169
31269
|
uploadFile: uploadFile,
|
|
@@ -32975,7 +33075,7 @@ const getReactions$1 = (params, callback, config) => {
|
|
|
32975
33075
|
};
|
|
32976
33076
|
/* end_public_function */
|
|
32977
33077
|
|
|
32978
|
-
var index$
|
|
33078
|
+
var index$l = /*#__PURE__*/Object.freeze({
|
|
32979
33079
|
__proto__: null,
|
|
32980
33080
|
addReaction: addReaction,
|
|
32981
33081
|
removeReaction: removeReaction,
|
|
@@ -34747,7 +34847,7 @@ const getMessages = (params, callback, config) => {
|
|
|
34747
34847
|
};
|
|
34748
34848
|
/* end_public_function */
|
|
34749
34849
|
|
|
34750
|
-
var index$
|
|
34850
|
+
var index$k = /*#__PURE__*/Object.freeze({
|
|
34751
34851
|
__proto__: null,
|
|
34752
34852
|
createMessage: createMessage,
|
|
34753
34853
|
updateMessage: updateMessage,
|
|
@@ -35273,7 +35373,7 @@ const stopMessageReceiptSync = (subChannelId) => {
|
|
|
35273
35373
|
};
|
|
35274
35374
|
/* end_public_function */
|
|
35275
35375
|
|
|
35276
|
-
var index$
|
|
35376
|
+
var index$j = /*#__PURE__*/Object.freeze({
|
|
35277
35377
|
__proto__: null,
|
|
35278
35378
|
getSubChannelByIds: getSubChannels$1,
|
|
35279
35379
|
createSubChannel: createSubChannel,
|
|
@@ -36600,7 +36700,7 @@ const searchMembers$1 = (params, callback, config) => {
|
|
|
36600
36700
|
};
|
|
36601
36701
|
/* end_public_function */
|
|
36602
36702
|
|
|
36603
|
-
var index$
|
|
36703
|
+
var index$i = /*#__PURE__*/Object.freeze({
|
|
36604
36704
|
__proto__: null,
|
|
36605
36705
|
addMembers: addMembers$1,
|
|
36606
36706
|
removeMembers: removeMembers$1,
|
|
@@ -36803,7 +36903,7 @@ const unmuteMembers = async (channelId, userIds) => {
|
|
|
36803
36903
|
};
|
|
36804
36904
|
/* end_public_function */
|
|
36805
36905
|
|
|
36806
|
-
var index$
|
|
36906
|
+
var index$h = /*#__PURE__*/Object.freeze({
|
|
36807
36907
|
__proto__: null,
|
|
36808
36908
|
addRole: addRole,
|
|
36809
36909
|
removeRole: removeRole,
|
|
@@ -36813,10 +36913,10 @@ var index$g = /*#__PURE__*/Object.freeze({
|
|
|
36813
36913
|
unmuteMembers: unmuteMembers
|
|
36814
36914
|
});
|
|
36815
36915
|
|
|
36816
|
-
var index$
|
|
36916
|
+
var index$g = /*#__PURE__*/Object.freeze({
|
|
36817
36917
|
__proto__: null,
|
|
36818
|
-
Membership: index$
|
|
36819
|
-
Moderation: index$
|
|
36918
|
+
Membership: index$i,
|
|
36919
|
+
Moderation: index$h,
|
|
36820
36920
|
getChannelByIds: getChannelByIds$1,
|
|
36821
36921
|
createChannel: createChannel,
|
|
36822
36922
|
updateChannel: updateChannel,
|
|
@@ -38219,7 +38319,7 @@ const searchMembers = (params, callback, config) => {
|
|
|
38219
38319
|
};
|
|
38220
38320
|
/* end_public_function */
|
|
38221
38321
|
|
|
38222
|
-
var index$
|
|
38322
|
+
var index$f = /*#__PURE__*/Object.freeze({
|
|
38223
38323
|
__proto__: null,
|
|
38224
38324
|
addMembers: addMembers,
|
|
38225
38325
|
removeMembers: removeMembers,
|
|
@@ -39470,7 +39570,7 @@ const unbanMembers = async (communityId, userIds) => {
|
|
|
39470
39570
|
};
|
|
39471
39571
|
/* end_public_function */
|
|
39472
39572
|
|
|
39473
|
-
var index$
|
|
39573
|
+
var index$e = /*#__PURE__*/Object.freeze({
|
|
39474
39574
|
__proto__: null,
|
|
39475
39575
|
addRoles: addRoles,
|
|
39476
39576
|
removeRoles: removeRoles,
|
|
@@ -39478,10 +39578,10 @@ var index$d = /*#__PURE__*/Object.freeze({
|
|
|
39478
39578
|
unbanMembers: unbanMembers
|
|
39479
39579
|
});
|
|
39480
39580
|
|
|
39481
|
-
var index$
|
|
39581
|
+
var index$d = /*#__PURE__*/Object.freeze({
|
|
39482
39582
|
__proto__: null,
|
|
39483
|
-
Moderation: index$
|
|
39484
|
-
Membership: index$
|
|
39583
|
+
Moderation: index$e,
|
|
39584
|
+
Membership: index$f,
|
|
39485
39585
|
getCommunityByIds: getCommunities$1,
|
|
39486
39586
|
createCommunity: createCommunity,
|
|
39487
39587
|
updateCommunity: updateCommunity,
|
|
@@ -39715,7 +39815,7 @@ const getCategories = (params, callback, config) => {
|
|
|
39715
39815
|
};
|
|
39716
39816
|
/* end_public_function */
|
|
39717
39817
|
|
|
39718
|
-
var index$
|
|
39818
|
+
var index$c = /*#__PURE__*/Object.freeze({
|
|
39719
39819
|
__proto__: null,
|
|
39720
39820
|
getCategory: getCategory,
|
|
39721
39821
|
getCategories: getCategories
|
|
@@ -40774,7 +40874,7 @@ const getComments = (params, callback, config) => {
|
|
|
40774
40874
|
};
|
|
40775
40875
|
/* end_public_function */
|
|
40776
40876
|
|
|
40777
|
-
var index$
|
|
40877
|
+
var index$b = /*#__PURE__*/Object.freeze({
|
|
40778
40878
|
__proto__: null,
|
|
40779
40879
|
getCommentByIds: getCommentByIds,
|
|
40780
40880
|
createComment: createComment,
|
|
@@ -41445,7 +41545,7 @@ const getUserFeed = (params, callback, config) => {
|
|
|
41445
41545
|
};
|
|
41446
41546
|
/* end_public_function */
|
|
41447
41547
|
|
|
41448
|
-
var index$
|
|
41548
|
+
var index$a = /*#__PURE__*/Object.freeze({
|
|
41449
41549
|
__proto__: null,
|
|
41450
41550
|
queryGlobalFeed: queryGlobalFeed,
|
|
41451
41551
|
getCustomRankingGlobalFeed: getCustomRankingGlobalFeed,
|
|
@@ -43126,7 +43226,7 @@ const searchPostsByHashtag = (params, callback, config) => {
|
|
|
43126
43226
|
};
|
|
43127
43227
|
/* end_public_function */
|
|
43128
43228
|
|
|
43129
|
-
var index$
|
|
43229
|
+
var index$9 = /*#__PURE__*/Object.freeze({
|
|
43130
43230
|
__proto__: null,
|
|
43131
43231
|
getPostByIds: getPostByIds,
|
|
43132
43232
|
createPost: createPost,
|
|
@@ -43734,7 +43834,7 @@ const getStreams = (params, callback, config) => {
|
|
|
43734
43834
|
};
|
|
43735
43835
|
};
|
|
43736
43836
|
|
|
43737
|
-
var index$
|
|
43837
|
+
var index$8 = /*#__PURE__*/Object.freeze({
|
|
43738
43838
|
__proto__: null,
|
|
43739
43839
|
createStream: createStream,
|
|
43740
43840
|
updateStream: updateStream,
|
|
@@ -43752,6 +43852,729 @@ var index$7 = /*#__PURE__*/Object.freeze({
|
|
|
43752
43852
|
getStreams: getStreams
|
|
43753
43853
|
});
|
|
43754
43854
|
|
|
43855
|
+
/* begin_public_function
|
|
43856
|
+
id: room.create
|
|
43857
|
+
*/
|
|
43858
|
+
/**
|
|
43859
|
+
* ```js
|
|
43860
|
+
* import { createRoom } from '@amityco/ts-sdk'
|
|
43861
|
+
* const created = await createRoom({ title: 'my room', 'thumbnailFileId': fileId })
|
|
43862
|
+
* ```
|
|
43863
|
+
*
|
|
43864
|
+
* Creates an {@link Amity.Room}
|
|
43865
|
+
*
|
|
43866
|
+
* @param bundle The data necessary to create a new {@link Amity.Room}
|
|
43867
|
+
* @returns The newly created {@link Amity.Room}
|
|
43868
|
+
*
|
|
43869
|
+
* @category Room API
|
|
43870
|
+
* @async
|
|
43871
|
+
*/
|
|
43872
|
+
const createRoom = async (bundle) => {
|
|
43873
|
+
const client = getActiveClient();
|
|
43874
|
+
client.log('room/createRoom', bundle);
|
|
43875
|
+
const { data } = await client.http.post('/api/v1/rooms', bundle);
|
|
43876
|
+
fireEvent('local.room.created', data);
|
|
43877
|
+
const cachedAt = client.cache && Date.now();
|
|
43878
|
+
// TODO: check if should pick `users` filed which contains participants - if no need to ingest in the cache
|
|
43879
|
+
if (client.cache)
|
|
43880
|
+
ingestInCache(data, { cachedAt });
|
|
43881
|
+
const { rooms } = data;
|
|
43882
|
+
return {
|
|
43883
|
+
data: roomLinkedObject(rooms[0]),
|
|
43884
|
+
cachedAt,
|
|
43885
|
+
};
|
|
43886
|
+
};
|
|
43887
|
+
/* end_public_function */
|
|
43888
|
+
|
|
43889
|
+
/* begin_public_function
|
|
43890
|
+
id: room.update
|
|
43891
|
+
*/
|
|
43892
|
+
/**
|
|
43893
|
+
* ```js
|
|
43894
|
+
* import { updateRoom } from '@amityco/ts-sdk'
|
|
43895
|
+
* const updated = await updateRoom('roomId', { title: 'updated title' })
|
|
43896
|
+
* ```
|
|
43897
|
+
*
|
|
43898
|
+
* Updates an {@link Amity.InternalRoom}
|
|
43899
|
+
*
|
|
43900
|
+
* @param roomId The ID of the room to update
|
|
43901
|
+
* @param bundle The data to update the room with
|
|
43902
|
+
* @returns The updated {@link Amity.InternalRoom}
|
|
43903
|
+
*
|
|
43904
|
+
* @category Room API
|
|
43905
|
+
* @async
|
|
43906
|
+
*/
|
|
43907
|
+
const updateRoom = async (roomId, bundle) => {
|
|
43908
|
+
const client = getActiveClient();
|
|
43909
|
+
client.log('room/updateRoom', { roomId, bundle });
|
|
43910
|
+
const { data } = await client.http.put(`/api/v1/rooms/${roomId}`, bundle);
|
|
43911
|
+
fireEvent('local.room.updated', data);
|
|
43912
|
+
const cachedAt = client.cache && Date.now();
|
|
43913
|
+
if (client.cache)
|
|
43914
|
+
ingestInCache(data, { cachedAt });
|
|
43915
|
+
const { rooms } = data;
|
|
43916
|
+
return {
|
|
43917
|
+
data: rooms[0],
|
|
43918
|
+
cachedAt,
|
|
43919
|
+
};
|
|
43920
|
+
};
|
|
43921
|
+
/* end_public_function */
|
|
43922
|
+
|
|
43923
|
+
/* begin_public_function
|
|
43924
|
+
id: room.delete
|
|
43925
|
+
*/
|
|
43926
|
+
/**
|
|
43927
|
+
* ```js
|
|
43928
|
+
* import { deleteRoom } from '@amityco/ts-sdk'
|
|
43929
|
+
* const result = await deleteRoom('roomId')
|
|
43930
|
+
* ```
|
|
43931
|
+
*
|
|
43932
|
+
* Deletes an {@link Amity.Room}
|
|
43933
|
+
*
|
|
43934
|
+
* @param roomId The ID of the room to delete
|
|
43935
|
+
* @returns Promise that resolves when the room is deleted
|
|
43936
|
+
*
|
|
43937
|
+
* @category Room API
|
|
43938
|
+
* @async
|
|
43939
|
+
*/
|
|
43940
|
+
const deleteRoom = async (roomId) => {
|
|
43941
|
+
const client = getActiveClient();
|
|
43942
|
+
client.log('room/deleteRoom', { roomId });
|
|
43943
|
+
await client.http.delete(`/api/v1/rooms/${roomId}`);
|
|
43944
|
+
fireEvent('local.room.deleted', { rooms: [{ _id: roomId }] });
|
|
43945
|
+
};
|
|
43946
|
+
/* end_public_function */
|
|
43947
|
+
|
|
43948
|
+
/* begin_public_function
|
|
43949
|
+
id: room.stop
|
|
43950
|
+
*/
|
|
43951
|
+
/**
|
|
43952
|
+
* ```js
|
|
43953
|
+
* import { stopRoom } from '@amityco/ts-sdk'
|
|
43954
|
+
* const result = await stopRoom('roomId')
|
|
43955
|
+
* ```
|
|
43956
|
+
*
|
|
43957
|
+
* Stops a room's broadcasting
|
|
43958
|
+
*
|
|
43959
|
+
* @param roomId The ID of the room to stop
|
|
43960
|
+
* @returns The updated room data
|
|
43961
|
+
*
|
|
43962
|
+
* @category Room API
|
|
43963
|
+
* @async
|
|
43964
|
+
*/
|
|
43965
|
+
const stopRoom = async (roomId) => {
|
|
43966
|
+
const client = getActiveClient();
|
|
43967
|
+
client.log('room/stopRoom', { roomId });
|
|
43968
|
+
const { data } = await client.http.post(`/api/v1/rooms/${roomId}/stop`);
|
|
43969
|
+
fireEvent('local.room.stopped', data);
|
|
43970
|
+
const cachedAt = client.cache && Date.now();
|
|
43971
|
+
if (client.cache)
|
|
43972
|
+
ingestInCache(data, { cachedAt });
|
|
43973
|
+
const { rooms } = data;
|
|
43974
|
+
return {
|
|
43975
|
+
data: rooms[0],
|
|
43976
|
+
cachedAt,
|
|
43977
|
+
};
|
|
43978
|
+
};
|
|
43979
|
+
/* end_public_function */
|
|
43980
|
+
|
|
43981
|
+
/* begin_public_function
|
|
43982
|
+
id: room.getBroadcasterData
|
|
43983
|
+
*/
|
|
43984
|
+
/**
|
|
43985
|
+
* ```js
|
|
43986
|
+
* import { getBroadcasterData } from '@amityco/ts-sdk'
|
|
43987
|
+
* const token = await getBroadcasterData('roomId')
|
|
43988
|
+
* ```
|
|
43989
|
+
*
|
|
43990
|
+
* Gets broadcaster data for a room
|
|
43991
|
+
*
|
|
43992
|
+
* @param roomId The ID of the room to get token for
|
|
43993
|
+
* @returns The broadcaster data of the room including coHostToken, coHostUrl and direactStreamUrl
|
|
43994
|
+
*
|
|
43995
|
+
* @category Room API
|
|
43996
|
+
* @async
|
|
43997
|
+
*/
|
|
43998
|
+
const getBroadcasterData = async (roomId) => {
|
|
43999
|
+
const client = getActiveClient();
|
|
44000
|
+
client.log('room/getBroadcasterData', { roomId });
|
|
44001
|
+
const { data } = await client.http.get(`/api/v1/rooms/${roomId}/token`);
|
|
44002
|
+
return data;
|
|
44003
|
+
};
|
|
44004
|
+
/* end_public_function */
|
|
44005
|
+
|
|
44006
|
+
/* begin_public_function
|
|
44007
|
+
id: room.getRecordedUrl
|
|
44008
|
+
*/
|
|
44009
|
+
/**
|
|
44010
|
+
* ```js
|
|
44011
|
+
* import { getRecordedUrl } from '@amityco/ts-sdk'
|
|
44012
|
+
* const recordedUrl = await getRecordedUrl('roomId')
|
|
44013
|
+
* ```
|
|
44014
|
+
*
|
|
44015
|
+
* Gets the recorded URL for a room
|
|
44016
|
+
*
|
|
44017
|
+
* @param roomId The ID of the room to get recorded URL for
|
|
44018
|
+
* @returns The recorded URL information
|
|
44019
|
+
*
|
|
44020
|
+
* @category Room API
|
|
44021
|
+
* @async
|
|
44022
|
+
*/
|
|
44023
|
+
const getRecordedUrl = async (roomId) => {
|
|
44024
|
+
const client = getActiveClient();
|
|
44025
|
+
client.log('room/getRecordedUrl', { roomId });
|
|
44026
|
+
const { data } = await client.http.get(`/api/v1/rooms/${roomId}/recorded`);
|
|
44027
|
+
return data;
|
|
44028
|
+
};
|
|
44029
|
+
/* end_public_function */
|
|
44030
|
+
|
|
44031
|
+
/**
|
|
44032
|
+
* ```js
|
|
44033
|
+
* import { onRoomStartBroadcasting } from '@amityco/ts-sdk'
|
|
44034
|
+
* const dispose = onRoomStartBroadcasting(room => {
|
|
44035
|
+
* // ...
|
|
44036
|
+
* })
|
|
44037
|
+
* ```
|
|
44038
|
+
*
|
|
44039
|
+
* Fired when a {@link Amity.Room} has started broadcasting
|
|
44040
|
+
*
|
|
44041
|
+
* @param callback The function to call when the event was fired
|
|
44042
|
+
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
44043
|
+
*
|
|
44044
|
+
* @category Room Events
|
|
44045
|
+
*/
|
|
44046
|
+
const onRoomStartBroadcasting = (callback) => {
|
|
44047
|
+
const client = getActiveClient();
|
|
44048
|
+
const filter = (payload) => {
|
|
44049
|
+
ingestInCache(payload);
|
|
44050
|
+
callback(payload.rooms[0]);
|
|
44051
|
+
};
|
|
44052
|
+
return createEventSubscriber(client, 'room/onRoomStartBroadcasting', 'room.startBroadcasting', filter);
|
|
44053
|
+
};
|
|
44054
|
+
|
|
44055
|
+
/**
|
|
44056
|
+
* ```js
|
|
44057
|
+
* import { onRoomWaitingReconnect } from '@amityco/ts-sdk'
|
|
44058
|
+
* const dispose = onRoomWaitingReconnect(room => {
|
|
44059
|
+
* // ...
|
|
44060
|
+
* })
|
|
44061
|
+
* ```
|
|
44062
|
+
*
|
|
44063
|
+
* Fired when a {@link Amity.Room} is waiting for reconnection
|
|
44064
|
+
*
|
|
44065
|
+
* @param callback The function to call when the event was fired
|
|
44066
|
+
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
44067
|
+
*
|
|
44068
|
+
* @category Room Events
|
|
44069
|
+
*/
|
|
44070
|
+
const onRoomWaitingReconnect = (callback) => {
|
|
44071
|
+
const client = getActiveClient();
|
|
44072
|
+
const filter = (payload) => {
|
|
44073
|
+
ingestInCache(payload);
|
|
44074
|
+
callback(payload.rooms[0]);
|
|
44075
|
+
};
|
|
44076
|
+
return createEventSubscriber(client, 'room/onRoomWaitingReconnect', 'room.waitingReconnect', filter);
|
|
44077
|
+
};
|
|
44078
|
+
|
|
44079
|
+
/**
|
|
44080
|
+
* ```js
|
|
44081
|
+
* import { onRoomEndBroadcasting } from '@amityco/ts-sdk'
|
|
44082
|
+
* const dispose = onRoomEndBroadcasting(room => {
|
|
44083
|
+
* // ...
|
|
44084
|
+
* })
|
|
44085
|
+
* ```
|
|
44086
|
+
*
|
|
44087
|
+
* Fired when a {@link Amity.Room} has ended broadcasting
|
|
44088
|
+
*
|
|
44089
|
+
* @param callback The function to call when the event was fired
|
|
44090
|
+
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
44091
|
+
*
|
|
44092
|
+
* @category Room Events
|
|
44093
|
+
*/
|
|
44094
|
+
const onRoomEndBroadcasting = (callback) => {
|
|
44095
|
+
const client = getActiveClient();
|
|
44096
|
+
const filter = (payload) => {
|
|
44097
|
+
ingestInCache(payload);
|
|
44098
|
+
callback(payload.rooms[0]);
|
|
44099
|
+
};
|
|
44100
|
+
return createEventSubscriber(client, 'room/onRoomEndBroadcasting', 'room.endBroadcasting', filter);
|
|
44101
|
+
};
|
|
44102
|
+
|
|
44103
|
+
/**
|
|
44104
|
+
* ```js
|
|
44105
|
+
* import { onRoomRecordedAvailable } from '@amityco/ts-sdk'
|
|
44106
|
+
* const dispose = onRoomRecordedAvailable(room => {
|
|
44107
|
+
* // ...
|
|
44108
|
+
* })
|
|
44109
|
+
* ```
|
|
44110
|
+
*
|
|
44111
|
+
* Fired when a {@link Amity.Room} recorded content becomes available
|
|
44112
|
+
*
|
|
44113
|
+
* @param callback The function to call when the event was fired
|
|
44114
|
+
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
44115
|
+
*
|
|
44116
|
+
* @category Room Events
|
|
44117
|
+
*/
|
|
44118
|
+
const onRoomRecordedAvailable = (callback) => {
|
|
44119
|
+
const client = getActiveClient();
|
|
44120
|
+
const filter = (payload) => {
|
|
44121
|
+
ingestInCache(payload);
|
|
44122
|
+
callback(payload.rooms[0]);
|
|
44123
|
+
};
|
|
44124
|
+
return createEventSubscriber(client, 'room/onRoomRecordedAvailable', 'room.recordedAvailable', filter);
|
|
44125
|
+
};
|
|
44126
|
+
|
|
44127
|
+
/**
|
|
44128
|
+
* ```js
|
|
44129
|
+
* import { onRoomParticipantInviting } from '@amityco/ts-sdk'
|
|
44130
|
+
* const dispose = onRoomParticipantInviting(room => {
|
|
44131
|
+
* // ...
|
|
44132
|
+
* })
|
|
44133
|
+
* ```
|
|
44134
|
+
*
|
|
44135
|
+
* Fired when a participant is being invited to a {@link Amity.Room}
|
|
44136
|
+
*
|
|
44137
|
+
* @param callback The function to call when the event was fired
|
|
44138
|
+
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
44139
|
+
*
|
|
44140
|
+
* @category Room Events
|
|
44141
|
+
*/
|
|
44142
|
+
const onRoomParticipantInviting = (callback) => {
|
|
44143
|
+
const client = getActiveClient();
|
|
44144
|
+
const filter = (payload) => {
|
|
44145
|
+
ingestInCache(payload);
|
|
44146
|
+
callback(payload.rooms[0]);
|
|
44147
|
+
};
|
|
44148
|
+
return createEventSubscriber(client, 'room/onRoomParticipantInviting', 'room.participantInviting', filter);
|
|
44149
|
+
};
|
|
44150
|
+
|
|
44151
|
+
/**
|
|
44152
|
+
* ```js
|
|
44153
|
+
* import { onRoomParticipantJoined } from '@amityco/ts-sdk'
|
|
44154
|
+
* const dispose = onRoomParticipantJoined(room => {
|
|
44155
|
+
* // ...
|
|
44156
|
+
* })
|
|
44157
|
+
* ```
|
|
44158
|
+
*
|
|
44159
|
+
* Fired when a participant has joined a {@link Amity.Room}
|
|
44160
|
+
*
|
|
44161
|
+
* @param callback The function to call when the event was fired
|
|
44162
|
+
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
44163
|
+
*
|
|
44164
|
+
* @category Room Events
|
|
44165
|
+
*/
|
|
44166
|
+
const onRoomParticipantJoined = (callback) => {
|
|
44167
|
+
const client = getActiveClient();
|
|
44168
|
+
const filter = (payload) => {
|
|
44169
|
+
ingestInCache(payload);
|
|
44170
|
+
callback(payload.rooms[0]);
|
|
44171
|
+
};
|
|
44172
|
+
return createEventSubscriber(client, 'room/onRoomParticipantJoined', 'room.participantJoined', filter);
|
|
44173
|
+
};
|
|
44174
|
+
|
|
44175
|
+
/**
|
|
44176
|
+
* ```js
|
|
44177
|
+
* import { onRoomParticipantLeft } from '@amityco/ts-sdk'
|
|
44178
|
+
* const dispose = onRoomParticipantLeft(room => {
|
|
44179
|
+
* // ...
|
|
44180
|
+
* })
|
|
44181
|
+
* ```
|
|
44182
|
+
*
|
|
44183
|
+
* Fired when a participant has left a {@link Amity.Room}
|
|
44184
|
+
*
|
|
44185
|
+
* @param callback The function to call when the event was fired
|
|
44186
|
+
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
44187
|
+
*
|
|
44188
|
+
* @category Room Events
|
|
44189
|
+
*/
|
|
44190
|
+
const onRoomParticipantLeft = (callback) => {
|
|
44191
|
+
const client = getActiveClient();
|
|
44192
|
+
const filter = (payload) => {
|
|
44193
|
+
ingestInCache(payload);
|
|
44194
|
+
callback(payload.rooms[0]);
|
|
44195
|
+
};
|
|
44196
|
+
return createEventSubscriber(client, 'room/onRoomParticipantLeft', 'room.participantLeft', filter);
|
|
44197
|
+
};
|
|
44198
|
+
|
|
44199
|
+
/**
|
|
44200
|
+
* ```js
|
|
44201
|
+
* import { onRoomCreated } from '@amityco/ts-sdk'
|
|
44202
|
+
* const dispose = onRoomCreated(room => {
|
|
44203
|
+
* // ...
|
|
44204
|
+
* })
|
|
44205
|
+
* ```
|
|
44206
|
+
*
|
|
44207
|
+
* Fired when a {@link Amity.Room} has been created locally
|
|
44208
|
+
*
|
|
44209
|
+
* @param callback The function to call when the event was fired
|
|
44210
|
+
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
44211
|
+
*
|
|
44212
|
+
* @category Room Events
|
|
44213
|
+
*/
|
|
44214
|
+
const onRoomCreated = (callback) => {
|
|
44215
|
+
const client = getActiveClient();
|
|
44216
|
+
const filter = (payload) => {
|
|
44217
|
+
ingestInCache(payload);
|
|
44218
|
+
callback(payload.rooms[0]);
|
|
44219
|
+
};
|
|
44220
|
+
return createEventSubscriber(client, 'room/onRoomCreated', 'local.room.created', filter);
|
|
44221
|
+
};
|
|
44222
|
+
|
|
44223
|
+
/**
|
|
44224
|
+
* ```js
|
|
44225
|
+
* import { onRoomUpdated } from '@amityco/ts-sdk'
|
|
44226
|
+
* const dispose = onRoomUpdated(room => {
|
|
44227
|
+
* // ...
|
|
44228
|
+
* })
|
|
44229
|
+
* ```
|
|
44230
|
+
*
|
|
44231
|
+
* Fired when a {@link Amity.Room} has been updated locally
|
|
44232
|
+
*
|
|
44233
|
+
* @param callback The function to call when the event was fired
|
|
44234
|
+
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
44235
|
+
*
|
|
44236
|
+
* @category Room Events
|
|
44237
|
+
*/
|
|
44238
|
+
const onRoomUpdated = (callback) => {
|
|
44239
|
+
const client = getActiveClient();
|
|
44240
|
+
const filter = (payload) => {
|
|
44241
|
+
ingestInCache(payload);
|
|
44242
|
+
callback(payload.rooms[0]);
|
|
44243
|
+
};
|
|
44244
|
+
return createEventSubscriber(client, 'room/onRoomUpdated', 'local.room.updated', filter);
|
|
44245
|
+
};
|
|
44246
|
+
|
|
44247
|
+
/**
|
|
44248
|
+
* ```js
|
|
44249
|
+
* import { onRoomDeleted } from '@amityco/ts-sdk'
|
|
44250
|
+
* const dispose = onRoomDeleted(room => {
|
|
44251
|
+
* // ...
|
|
44252
|
+
* })
|
|
44253
|
+
* ```
|
|
44254
|
+
*
|
|
44255
|
+
* Fired when a {@link Amity.Room} has been deleted locally
|
|
44256
|
+
*
|
|
44257
|
+
* @param callback The function to call when the event was fired
|
|
44258
|
+
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
44259
|
+
*
|
|
44260
|
+
* @category Room Events
|
|
44261
|
+
*/
|
|
44262
|
+
const onRoomDeleted = (callback) => {
|
|
44263
|
+
const client = getActiveClient();
|
|
44264
|
+
const filter = (payload) => {
|
|
44265
|
+
ingestInCache(payload);
|
|
44266
|
+
callback(payload.rooms[0]);
|
|
44267
|
+
};
|
|
44268
|
+
return createEventSubscriber(client, 'room/onRoomDeleted', 'local.room.deleted', filter);
|
|
44269
|
+
};
|
|
44270
|
+
|
|
44271
|
+
/**
|
|
44272
|
+
* ```js
|
|
44273
|
+
* import { onRoomStopped } from '@amityco/ts-sdk'
|
|
44274
|
+
* const dispose = onRoomStopped(room => {
|
|
44275
|
+
* // ...
|
|
44276
|
+
* })
|
|
44277
|
+
* ```
|
|
44278
|
+
*
|
|
44279
|
+
* Fired when a {@link Amity.Room} has been stopped locally
|
|
44280
|
+
*
|
|
44281
|
+
* @param callback The function to call when the event was fired
|
|
44282
|
+
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
44283
|
+
*
|
|
44284
|
+
* @category Room Events
|
|
44285
|
+
*/
|
|
44286
|
+
const onRoomStopped = (callback) => {
|
|
44287
|
+
const client = getActiveClient();
|
|
44288
|
+
const filter = (payload) => {
|
|
44289
|
+
ingestInCache(payload);
|
|
44290
|
+
callback(payload.rooms[0]);
|
|
44291
|
+
};
|
|
44292
|
+
return createEventSubscriber(client, 'room/onRoomStopped', 'local.room.stopped', filter);
|
|
44293
|
+
};
|
|
44294
|
+
|
|
44295
|
+
const getRoomById = async (roomId) => {
|
|
44296
|
+
const client = getActiveClient();
|
|
44297
|
+
client.log('room/getRoomById', roomId);
|
|
44298
|
+
// Check if room is in tombstone
|
|
44299
|
+
isInTombstone('room', roomId);
|
|
44300
|
+
let data;
|
|
44301
|
+
try {
|
|
44302
|
+
const response = await client.http.get(`/api/v1/rooms/${roomId}`);
|
|
44303
|
+
data = response.data;
|
|
44304
|
+
}
|
|
44305
|
+
catch (error) {
|
|
44306
|
+
if (checkIfShouldGoesToTombstone(error === null || error === void 0 ? void 0 : error.code)) {
|
|
44307
|
+
pushToTombstone('room', roomId);
|
|
44308
|
+
}
|
|
44309
|
+
throw error;
|
|
44310
|
+
}
|
|
44311
|
+
const cachedAt = client.cache && Date.now();
|
|
44312
|
+
if (client.cache) {
|
|
44313
|
+
ingestInCache(data, { cachedAt });
|
|
44314
|
+
}
|
|
44315
|
+
return {
|
|
44316
|
+
data: data.rooms[0],
|
|
44317
|
+
cachedAt,
|
|
44318
|
+
};
|
|
44319
|
+
};
|
|
44320
|
+
getRoomById.locally = (roomId) => {
|
|
44321
|
+
const client = getActiveClient();
|
|
44322
|
+
client.log('room/getRoomById.locally', roomId);
|
|
44323
|
+
// Check if room is in tombstone
|
|
44324
|
+
isInTombstone('room', roomId);
|
|
44325
|
+
const cachedAt = client.cache && Date.now();
|
|
44326
|
+
const roomCache = pullFromCache(['room', 'get', roomId]);
|
|
44327
|
+
if (!roomCache)
|
|
44328
|
+
return;
|
|
44329
|
+
return {
|
|
44330
|
+
data: roomCache.data,
|
|
44331
|
+
cachedAt,
|
|
44332
|
+
};
|
|
44333
|
+
};
|
|
44334
|
+
|
|
44335
|
+
const getRoom = (roomId, callback) => {
|
|
44336
|
+
// TODO: add callbackDataSelector if there are linked object fields
|
|
44337
|
+
return liveObject(roomId, callback, '_id', getRoomById, [
|
|
44338
|
+
onRoomEndBroadcasting,
|
|
44339
|
+
onRoomStartBroadcasting,
|
|
44340
|
+
onRoomWaitingReconnect,
|
|
44341
|
+
onRoomRecordedAvailable,
|
|
44342
|
+
]);
|
|
44343
|
+
};
|
|
44344
|
+
|
|
44345
|
+
class RoomPaginationController extends PaginationController {
|
|
44346
|
+
async getRequest(queryParams, token) {
|
|
44347
|
+
const { limit = COLLECTION_DEFAULT_PAGINATION_LIMIT, includeDeleted } = queryParams, params = __rest(queryParams, ["limit", "includeDeleted"]);
|
|
44348
|
+
const baseOptions = {
|
|
44349
|
+
type: params.sortBy || queryParams.limit ? 'pagination' : undefined,
|
|
44350
|
+
};
|
|
44351
|
+
const options = token ? Object.assign(Object.assign({}, baseOptions), { token }) : Object.assign(Object.assign({}, baseOptions), { limit });
|
|
44352
|
+
const { data: queryResponse } = await this.http.get(`/api/v1/rooms`, {
|
|
44353
|
+
params: Object.assign(Object.assign({}, params), { isDeleted: inferIsDeleted(includeDeleted), options }),
|
|
44354
|
+
});
|
|
44355
|
+
return queryResponse;
|
|
44356
|
+
}
|
|
44357
|
+
}
|
|
44358
|
+
|
|
44359
|
+
var EnumRoomActions;
|
|
44360
|
+
(function (EnumRoomActions) {
|
|
44361
|
+
EnumRoomActions["OnRoomCreated"] = "OnRoomCreated";
|
|
44362
|
+
EnumRoomActions["OnRoomUpdated"] = "OnRoomUpdated";
|
|
44363
|
+
EnumRoomActions["OnRoomDeleted"] = "OnRoomDeleted";
|
|
44364
|
+
EnumRoomActions["OnRoomStartBroadcasting"] = "OnRoomStartBroadcasting";
|
|
44365
|
+
EnumRoomActions["OnRoomEndBroadcasting"] = "OnRoomEndBroadcasting";
|
|
44366
|
+
EnumRoomActions["OnRoomParticipantJoined"] = "OnRoomParticipantJoined";
|
|
44367
|
+
EnumRoomActions["OnRoomParticipantLeft"] = "OnRoomParticipantLeft";
|
|
44368
|
+
})(EnumRoomActions || (EnumRoomActions = {}));
|
|
44369
|
+
|
|
44370
|
+
class RoomQueryStreamController extends QueryStreamController {
|
|
44371
|
+
constructor(query, cacheKey, notifyChange, preparePayload) {
|
|
44372
|
+
super(query, cacheKey);
|
|
44373
|
+
this.notifyChange = notifyChange;
|
|
44374
|
+
this.preparePayload = preparePayload;
|
|
44375
|
+
}
|
|
44376
|
+
async saveToMainDB(response) {
|
|
44377
|
+
const processedPayload = await this.preparePayload(response);
|
|
44378
|
+
const client = getActiveClient();
|
|
44379
|
+
const cachedAt = client.cache && Date.now();
|
|
44380
|
+
if (client.cache) {
|
|
44381
|
+
ingestInCache(processedPayload, { cachedAt });
|
|
44382
|
+
}
|
|
44383
|
+
}
|
|
44384
|
+
appendToQueryStream(response, direction, refresh = false) {
|
|
44385
|
+
var _a, _b;
|
|
44386
|
+
if (refresh) {
|
|
44387
|
+
pushToCache(this.cacheKey, {
|
|
44388
|
+
data: response.rooms.map(getResolver('room')),
|
|
44389
|
+
});
|
|
44390
|
+
}
|
|
44391
|
+
else {
|
|
44392
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
44393
|
+
const rooms = (_b = collection === null || collection === void 0 ? void 0 : collection.data) !== null && _b !== void 0 ? _b : [];
|
|
44394
|
+
pushToCache(this.cacheKey, Object.assign(Object.assign({}, collection), { data: [...new Set([...rooms, ...response.rooms.map(getResolver('room'))])] }));
|
|
44395
|
+
}
|
|
44396
|
+
}
|
|
44397
|
+
reactor(action) {
|
|
44398
|
+
return (room) => {
|
|
44399
|
+
var _a;
|
|
44400
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
44401
|
+
if (!collection)
|
|
44402
|
+
return;
|
|
44403
|
+
if (action === EnumRoomActions.OnRoomDeleted) {
|
|
44404
|
+
collection.data = collection.data.filter(roomId => roomId !== room._id);
|
|
44405
|
+
}
|
|
44406
|
+
if (action === EnumRoomActions.OnRoomCreated) {
|
|
44407
|
+
collection.data = [...new Set([room._id, ...collection.data])];
|
|
44408
|
+
}
|
|
44409
|
+
pushToCache(this.cacheKey, collection);
|
|
44410
|
+
this.notifyChange({ origin: "event" /* Amity.LiveDataOrigin.EVENT */, loading: false });
|
|
44411
|
+
};
|
|
44412
|
+
}
|
|
44413
|
+
subscribeRTE(createSubscriber) {
|
|
44414
|
+
return createSubscriber.map(subscriber => subscriber.fn(this.reactor(subscriber.action)));
|
|
44415
|
+
}
|
|
44416
|
+
}
|
|
44417
|
+
|
|
44418
|
+
// TODO: confirm related events
|
|
44419
|
+
const getRoomSubscription = () => [
|
|
44420
|
+
{
|
|
44421
|
+
fn: onRoomStartBroadcasting,
|
|
44422
|
+
action: EnumRoomActions.OnRoomStartBroadcasting,
|
|
44423
|
+
},
|
|
44424
|
+
{
|
|
44425
|
+
fn: onRoomEndBroadcasting,
|
|
44426
|
+
action: EnumRoomActions.OnRoomEndBroadcasting,
|
|
44427
|
+
},
|
|
44428
|
+
{
|
|
44429
|
+
fn: onRoomRecordedAvailable,
|
|
44430
|
+
action: EnumRoomActions.OnRoomUpdated,
|
|
44431
|
+
},
|
|
44432
|
+
];
|
|
44433
|
+
|
|
44434
|
+
class RoomLiveCollectionController extends LiveCollectionController {
|
|
44435
|
+
constructor(query, callback) {
|
|
44436
|
+
const queryStreamId = hash(query);
|
|
44437
|
+
const cacheKey = ['rooms', 'collection', queryStreamId];
|
|
44438
|
+
const paginationController = new RoomPaginationController(query);
|
|
44439
|
+
super(paginationController, queryStreamId, cacheKey, callback);
|
|
44440
|
+
this.query = query;
|
|
44441
|
+
this.queryStreamController = new RoomQueryStreamController(this.query, this.cacheKey, this.notifyChange.bind(this), response => response);
|
|
44442
|
+
this.callback = callback.bind(this);
|
|
44443
|
+
this.loadPage({ initial: true });
|
|
44444
|
+
}
|
|
44445
|
+
setup() {
|
|
44446
|
+
var _a;
|
|
44447
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
44448
|
+
if (!collection) {
|
|
44449
|
+
pushToCache(this.cacheKey, {
|
|
44450
|
+
data: [],
|
|
44451
|
+
params: {},
|
|
44452
|
+
});
|
|
44453
|
+
}
|
|
44454
|
+
}
|
|
44455
|
+
async persistModel(queryPayload) {
|
|
44456
|
+
await this.queryStreamController.saveToMainDB(queryPayload);
|
|
44457
|
+
}
|
|
44458
|
+
persistQueryStream({ response, direction, refresh, }) {
|
|
44459
|
+
this.queryStreamController.appendToQueryStream(response, direction, refresh);
|
|
44460
|
+
}
|
|
44461
|
+
startSubscription() {
|
|
44462
|
+
return this.queryStreamController.subscribeRTE(getRoomSubscription());
|
|
44463
|
+
}
|
|
44464
|
+
notifyChange({ origin, loading, error }) {
|
|
44465
|
+
var _a, _b;
|
|
44466
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
44467
|
+
if (!collection)
|
|
44468
|
+
return;
|
|
44469
|
+
const data = this.applyFilter((_b = collection.data
|
|
44470
|
+
.map(id => pullFromCache(['room', 'get', id]))
|
|
44471
|
+
.filter(isNonNullable)
|
|
44472
|
+
.map(({ data }) => data)) !== null && _b !== void 0 ? _b : []).map(room => room); // Since Room is same as InternalRoom, no transformation needed
|
|
44473
|
+
if (!this.shouldNotify(data) && origin === 'event')
|
|
44474
|
+
return;
|
|
44475
|
+
this.callback({
|
|
44476
|
+
onNextPage: () => this.loadPage({ direction: "next" /* Amity.LiveCollectionPageDirection.NEXT */ }),
|
|
44477
|
+
data,
|
|
44478
|
+
hasNextPage: !!this.paginationController.getNextToken(),
|
|
44479
|
+
loading,
|
|
44480
|
+
error,
|
|
44481
|
+
});
|
|
44482
|
+
}
|
|
44483
|
+
applyFilter(data) {
|
|
44484
|
+
let rooms = data;
|
|
44485
|
+
if (!this.query.includeDeleted) {
|
|
44486
|
+
rooms = filterByPropEquality(rooms, 'isDeleted', false);
|
|
44487
|
+
}
|
|
44488
|
+
if (this.query.statuses && this.query.statuses.length > 0) {
|
|
44489
|
+
rooms = rooms.filter(room => { var _a; return (_a = this.query.statuses) === null || _a === void 0 ? void 0 : _a.includes(room.status); });
|
|
44490
|
+
}
|
|
44491
|
+
if (this.query.type) {
|
|
44492
|
+
rooms = filterByPropEquality(rooms, 'type', this.query.type);
|
|
44493
|
+
}
|
|
44494
|
+
switch (this.query.sortBy) {
|
|
44495
|
+
case 'firstCreated':
|
|
44496
|
+
rooms = rooms.sort(sortByFirstCreated);
|
|
44497
|
+
break;
|
|
44498
|
+
case 'lastCreated':
|
|
44499
|
+
default:
|
|
44500
|
+
rooms = rooms.sort(sortByLastCreated);
|
|
44501
|
+
break;
|
|
44502
|
+
}
|
|
44503
|
+
return rooms;
|
|
44504
|
+
}
|
|
44505
|
+
}
|
|
44506
|
+
|
|
44507
|
+
/* begin_public_function
|
|
44508
|
+
id: room.get_rooms
|
|
44509
|
+
*/
|
|
44510
|
+
/**
|
|
44511
|
+
* ```js
|
|
44512
|
+
* import { RoomRepository } from '@amityco/ts-sdk'
|
|
44513
|
+
*
|
|
44514
|
+
* let rooms = []
|
|
44515
|
+
* const unsub = RoomRepository.getRooms({
|
|
44516
|
+
* type: 'direct_streaming',
|
|
44517
|
+
* statuses: ['live', 'idle'],
|
|
44518
|
+
* sortBy: 'lastCreated',
|
|
44519
|
+
* limit: 20,
|
|
44520
|
+
* includeDeleted: false
|
|
44521
|
+
* }, response => merge(rooms, response.data))
|
|
44522
|
+
* ```
|
|
44523
|
+
*
|
|
44524
|
+
* Observe all mutations on a list of {@link Amity.Room} for a given query
|
|
44525
|
+
*
|
|
44526
|
+
* @param params.type the type of rooms to filter by ('direct_streaming' | 'co_hosts')
|
|
44527
|
+
* @param params.statuses array of room statuses to filter by (['idle', 'live', 'waiting_reconnect', 'ended', 'recorded'])
|
|
44528
|
+
* @param params.sortBy sort rooms by creation time ('firstCreated' | 'lastCreated')
|
|
44529
|
+
* @param params.limit maximum number of rooms to retrieve per page
|
|
44530
|
+
* @param params.includeDeleted whether to include deleted rooms in the results
|
|
44531
|
+
* @param callback the function to call when new data are available
|
|
44532
|
+
* @param config optional configuration for the live collection
|
|
44533
|
+
* @returns An {@link Amity.Unsubscriber} function to run when willing to stop observing the rooms
|
|
44534
|
+
*
|
|
44535
|
+
* @category Rooms Live Collection
|
|
44536
|
+
*/
|
|
44537
|
+
const getRooms = (params, callback, config) => {
|
|
44538
|
+
const { log, cache } = getActiveClient();
|
|
44539
|
+
if (!cache) {
|
|
44540
|
+
console.log(ENABLE_CACHE_MESSAGE);
|
|
44541
|
+
}
|
|
44542
|
+
const timestamp = Date.now();
|
|
44543
|
+
log(`getRooms(tmpid: ${timestamp}) > listen`);
|
|
44544
|
+
const roomsLiveCollection = new RoomLiveCollectionController(params, callback);
|
|
44545
|
+
const disposers = roomsLiveCollection.startSubscription();
|
|
44546
|
+
const cacheKey = roomsLiveCollection.getCacheKey();
|
|
44547
|
+
disposers.push(() => dropFromCache(cacheKey));
|
|
44548
|
+
return () => {
|
|
44549
|
+
log(`getRooms(tmpid: ${timestamp}) > dispose`);
|
|
44550
|
+
disposers.forEach(fn => fn());
|
|
44551
|
+
};
|
|
44552
|
+
};
|
|
44553
|
+
/* end_public_function */
|
|
44554
|
+
|
|
44555
|
+
var index$7 = /*#__PURE__*/Object.freeze({
|
|
44556
|
+
__proto__: null,
|
|
44557
|
+
createRoom: createRoom,
|
|
44558
|
+
updateRoom: updateRoom,
|
|
44559
|
+
deleteRoom: deleteRoom,
|
|
44560
|
+
stopRoom: stopRoom,
|
|
44561
|
+
getBroadcasterData: getBroadcasterData,
|
|
44562
|
+
getRecordedUrl: getRecordedUrl,
|
|
44563
|
+
onRoomStartBroadcasting: onRoomStartBroadcasting,
|
|
44564
|
+
onRoomWaitingReconnect: onRoomWaitingReconnect,
|
|
44565
|
+
onRoomEndBroadcasting: onRoomEndBroadcasting,
|
|
44566
|
+
onRoomRecordedAvailable: onRoomRecordedAvailable,
|
|
44567
|
+
onRoomParticipantInviting: onRoomParticipantInviting,
|
|
44568
|
+
onRoomParticipantJoined: onRoomParticipantJoined,
|
|
44569
|
+
onRoomParticipantLeft: onRoomParticipantLeft,
|
|
44570
|
+
onRoomCreated: onRoomCreated,
|
|
44571
|
+
onRoomUpdated: onRoomUpdated,
|
|
44572
|
+
onRoomDeleted: onRoomDeleted,
|
|
44573
|
+
onRoomStopped: onRoomStopped,
|
|
44574
|
+
getRoom: getRoom,
|
|
44575
|
+
getRooms: getRooms
|
|
44576
|
+
});
|
|
44577
|
+
|
|
43755
44578
|
/* begin_public_function
|
|
43756
44579
|
id: poll.create
|
|
43757
44580
|
*/
|
|
@@ -46385,4 +47208,4 @@ var index = /*#__PURE__*/Object.freeze({
|
|
|
46385
47208
|
getReactions: getReactions
|
|
46386
47209
|
});
|
|
46387
47210
|
|
|
46388
|
-
export { API_REGIONS, index$3 as AdRepository, index$
|
|
47211
|
+
export { API_REGIONS, index$3 as AdRepository, 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, FeedDataTypeEnum, index$a as FeedRepository, FeedSortByEnum, FeedSourceEnum, FileAccessTypeEnum, index$m as FileRepository, FileType, GET_WATCHER_URLS, index$1 as InvitationRepository, InvitationSortByEnum, InvitationStatusEnum, InvitationTypeEnum, JoinRequestStatusEnum, JoinResultStatusEnum, index as LiveReactionRepository, index$5 as LiveStreamPlayer, MembershipAcceptanceTypeEnum, MessageContentType, index$k as MessageRepository, index$6 as PollRepository, PostContentType, index$9 as PostRepository, PostStructureType, index$l as ReactionRepository, index$7 as RoomRepository, index$4 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$2 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 };
|