@amityco/ts-sdk-react-native 7.11.0 → 7.11.1-16808a2d.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/post.d.ts +2 -0
- package/dist/@types/domains/post.d.ts.map +1 -1
- package/dist/@types/domains/room.d.ts +71 -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/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 +776 -37
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.esm.js +763 -25
- 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/getRecordedUrl.d.ts +19 -0
- package/dist/roomRepository/api/getRecordedUrl.d.ts.map +1 -0
- package/dist/roomRepository/api/getRoomToken.d.ts +16 -0
- package/dist/roomRepository/api/getRoomToken.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/getRoomById.d.ts +5 -0
- package/dist/roomRepository/internalApi/getRoomById.d.ts.map +1 -0
- package/dist/roomRepository/internalApi/index.d.ts +2 -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/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
|
@@ -148,6 +148,7 @@ const PostContentType = Object.freeze({
|
|
|
148
148
|
POLL: 'poll',
|
|
149
149
|
CLIP: 'clip',
|
|
150
150
|
AUDIO: 'audio',
|
|
151
|
+
ROOM: 'room',
|
|
151
152
|
});
|
|
152
153
|
const PostStructureType = Object.freeze({
|
|
153
154
|
TEXT: 'text',
|
|
@@ -661,6 +662,7 @@ const idResolvers = {
|
|
|
661
662
|
notificationTraySeen: ({ userId }) => userId,
|
|
662
663
|
invitation: ({ _id }) => _id,
|
|
663
664
|
joinRequest: ({ joinRequestId }) => joinRequestId,
|
|
665
|
+
room: ({ roomId }) => roomId,
|
|
664
666
|
};
|
|
665
667
|
/**
|
|
666
668
|
* Retrieve the id resolver matching a domain name
|
|
@@ -716,6 +718,7 @@ const PAYLOAD2MODEL = {
|
|
|
716
718
|
notificationTrayItems: 'notificationTrayItem',
|
|
717
719
|
invitations: 'invitation',
|
|
718
720
|
joinRequests: 'joinRequest',
|
|
721
|
+
rooms: 'room',
|
|
719
722
|
};
|
|
720
723
|
/** hidden */
|
|
721
724
|
const isOutdated = (prevData, nextData) => {
|
|
@@ -10624,7 +10627,7 @@ const getUserUnread = (callback) => {
|
|
|
10624
10627
|
};
|
|
10625
10628
|
};
|
|
10626
10629
|
|
|
10627
|
-
var index$
|
|
10630
|
+
var index$p = /*#__PURE__*/Object.freeze({
|
|
10628
10631
|
__proto__: null,
|
|
10629
10632
|
getActiveClient: getActiveClient,
|
|
10630
10633
|
getActiveUser: getActiveUser,
|
|
@@ -11846,7 +11849,7 @@ const getMyFollowInfo = (callback) => {
|
|
|
11846
11849
|
};
|
|
11847
11850
|
/* end_public_function */
|
|
11848
11851
|
|
|
11849
|
-
var index$
|
|
11852
|
+
var index$o = /*#__PURE__*/Object.freeze({
|
|
11850
11853
|
__proto__: null,
|
|
11851
11854
|
blockUser: blockUser,
|
|
11852
11855
|
unBlockUser: unBlockUser,
|
|
@@ -12374,6 +12377,12 @@ function isAmityAudioPost(post) {
|
|
|
12374
12377
|
'fileId' in post.data &&
|
|
12375
12378
|
post.dataType === 'audio');
|
|
12376
12379
|
}
|
|
12380
|
+
function isAmityRoomPost(post) {
|
|
12381
|
+
return !!(post.data &&
|
|
12382
|
+
typeof post.data !== 'string' &&
|
|
12383
|
+
'roomId' in post.data &&
|
|
12384
|
+
post.dataType === 'room');
|
|
12385
|
+
}
|
|
12377
12386
|
|
|
12378
12387
|
const postLinkedObject = (post) => {
|
|
12379
12388
|
return shallowClone(post, {
|
|
@@ -12468,6 +12477,12 @@ const postLinkedObject = (post) => {
|
|
|
12468
12477
|
? (_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
|
|
12469
12478
|
: undefined;
|
|
12470
12479
|
},
|
|
12480
|
+
getRoomInfo() {
|
|
12481
|
+
var _a, _b;
|
|
12482
|
+
if (!isAmityRoomPost(post))
|
|
12483
|
+
return;
|
|
12484
|
+
return (_b = pullFromCache(['room', 'get', (_a = post === null || post === void 0 ? void 0 : post.data) === null || _a === void 0 ? void 0 : _a.roomId])) === null || _b === void 0 ? void 0 : _b.data;
|
|
12485
|
+
},
|
|
12471
12486
|
});
|
|
12472
12487
|
};
|
|
12473
12488
|
|
|
@@ -14833,9 +14848,9 @@ var AmityUserSearchMatchType;
|
|
|
14833
14848
|
AmityUserSearchMatchType["PARTIAL"] = "partial";
|
|
14834
14849
|
})(AmityUserSearchMatchType || (AmityUserSearchMatchType = {}));
|
|
14835
14850
|
|
|
14836
|
-
var index$
|
|
14851
|
+
var index$n = /*#__PURE__*/Object.freeze({
|
|
14837
14852
|
__proto__: null,
|
|
14838
|
-
Relationship: index$
|
|
14853
|
+
Relationship: index$o,
|
|
14839
14854
|
getUserByIds: getUserByIds,
|
|
14840
14855
|
updateUser: updateUser,
|
|
14841
14856
|
flagUser: flagUser,
|
|
@@ -15238,7 +15253,7 @@ const uploadAudio = async (formData, onProgress) => {
|
|
|
15238
15253
|
};
|
|
15239
15254
|
/* end_public_function */
|
|
15240
15255
|
|
|
15241
|
-
var index$
|
|
15256
|
+
var index$m = /*#__PURE__*/Object.freeze({
|
|
15242
15257
|
__proto__: null,
|
|
15243
15258
|
getFile: getFile,
|
|
15244
15259
|
uploadFile: uploadFile,
|
|
@@ -17050,7 +17065,7 @@ const getReactions$1 = (params, callback, config) => {
|
|
|
17050
17065
|
};
|
|
17051
17066
|
/* end_public_function */
|
|
17052
17067
|
|
|
17053
|
-
var index$
|
|
17068
|
+
var index$l = /*#__PURE__*/Object.freeze({
|
|
17054
17069
|
__proto__: null,
|
|
17055
17070
|
addReaction: addReaction,
|
|
17056
17071
|
removeReaction: removeReaction,
|
|
@@ -18822,7 +18837,7 @@ const getMessages = (params, callback, config) => {
|
|
|
18822
18837
|
};
|
|
18823
18838
|
/* end_public_function */
|
|
18824
18839
|
|
|
18825
|
-
var index$
|
|
18840
|
+
var index$k = /*#__PURE__*/Object.freeze({
|
|
18826
18841
|
__proto__: null,
|
|
18827
18842
|
createMessage: createMessage,
|
|
18828
18843
|
updateMessage: updateMessage,
|
|
@@ -19348,7 +19363,7 @@ const stopMessageReceiptSync = (subChannelId) => {
|
|
|
19348
19363
|
};
|
|
19349
19364
|
/* end_public_function */
|
|
19350
19365
|
|
|
19351
|
-
var index$
|
|
19366
|
+
var index$j = /*#__PURE__*/Object.freeze({
|
|
19352
19367
|
__proto__: null,
|
|
19353
19368
|
getSubChannelByIds: getSubChannels$1,
|
|
19354
19369
|
createSubChannel: createSubChannel,
|
|
@@ -20675,7 +20690,7 @@ const searchMembers$1 = (params, callback, config) => {
|
|
|
20675
20690
|
};
|
|
20676
20691
|
/* end_public_function */
|
|
20677
20692
|
|
|
20678
|
-
var index$
|
|
20693
|
+
var index$i = /*#__PURE__*/Object.freeze({
|
|
20679
20694
|
__proto__: null,
|
|
20680
20695
|
addMembers: addMembers$1,
|
|
20681
20696
|
removeMembers: removeMembers$1,
|
|
@@ -20878,7 +20893,7 @@ const unmuteMembers = async (channelId, userIds) => {
|
|
|
20878
20893
|
};
|
|
20879
20894
|
/* end_public_function */
|
|
20880
20895
|
|
|
20881
|
-
var index$
|
|
20896
|
+
var index$h = /*#__PURE__*/Object.freeze({
|
|
20882
20897
|
__proto__: null,
|
|
20883
20898
|
addRole: addRole,
|
|
20884
20899
|
removeRole: removeRole,
|
|
@@ -20888,10 +20903,10 @@ var index$g = /*#__PURE__*/Object.freeze({
|
|
|
20888
20903
|
unmuteMembers: unmuteMembers
|
|
20889
20904
|
});
|
|
20890
20905
|
|
|
20891
|
-
var index$
|
|
20906
|
+
var index$g = /*#__PURE__*/Object.freeze({
|
|
20892
20907
|
__proto__: null,
|
|
20893
|
-
Membership: index$
|
|
20894
|
-
Moderation: index$
|
|
20908
|
+
Membership: index$i,
|
|
20909
|
+
Moderation: index$h,
|
|
20895
20910
|
getChannelByIds: getChannelByIds$1,
|
|
20896
20911
|
createChannel: createChannel,
|
|
20897
20912
|
updateChannel: updateChannel,
|
|
@@ -22294,7 +22309,7 @@ const searchMembers = (params, callback, config) => {
|
|
|
22294
22309
|
};
|
|
22295
22310
|
/* end_public_function */
|
|
22296
22311
|
|
|
22297
|
-
var index$
|
|
22312
|
+
var index$f = /*#__PURE__*/Object.freeze({
|
|
22298
22313
|
__proto__: null,
|
|
22299
22314
|
addMembers: addMembers,
|
|
22300
22315
|
removeMembers: removeMembers,
|
|
@@ -23545,7 +23560,7 @@ const unbanMembers = async (communityId, userIds) => {
|
|
|
23545
23560
|
};
|
|
23546
23561
|
/* end_public_function */
|
|
23547
23562
|
|
|
23548
|
-
var index$
|
|
23563
|
+
var index$e = /*#__PURE__*/Object.freeze({
|
|
23549
23564
|
__proto__: null,
|
|
23550
23565
|
addRoles: addRoles,
|
|
23551
23566
|
removeRoles: removeRoles,
|
|
@@ -23553,10 +23568,10 @@ var index$d = /*#__PURE__*/Object.freeze({
|
|
|
23553
23568
|
unbanMembers: unbanMembers
|
|
23554
23569
|
});
|
|
23555
23570
|
|
|
23556
|
-
var index$
|
|
23571
|
+
var index$d = /*#__PURE__*/Object.freeze({
|
|
23557
23572
|
__proto__: null,
|
|
23558
|
-
Moderation: index$
|
|
23559
|
-
Membership: index$
|
|
23573
|
+
Moderation: index$e,
|
|
23574
|
+
Membership: index$f,
|
|
23560
23575
|
getCommunityByIds: getCommunities$1,
|
|
23561
23576
|
createCommunity: createCommunity,
|
|
23562
23577
|
updateCommunity: updateCommunity,
|
|
@@ -23790,7 +23805,7 @@ const getCategories = (params, callback, config) => {
|
|
|
23790
23805
|
};
|
|
23791
23806
|
/* end_public_function */
|
|
23792
23807
|
|
|
23793
|
-
var index$
|
|
23808
|
+
var index$c = /*#__PURE__*/Object.freeze({
|
|
23794
23809
|
__proto__: null,
|
|
23795
23810
|
getCategory: getCategory,
|
|
23796
23811
|
getCategories: getCategories
|
|
@@ -24849,7 +24864,7 @@ const getComments = (params, callback, config) => {
|
|
|
24849
24864
|
};
|
|
24850
24865
|
/* end_public_function */
|
|
24851
24866
|
|
|
24852
|
-
var index$
|
|
24867
|
+
var index$b = /*#__PURE__*/Object.freeze({
|
|
24853
24868
|
__proto__: null,
|
|
24854
24869
|
getCommentByIds: getCommentByIds,
|
|
24855
24870
|
createComment: createComment,
|
|
@@ -25520,7 +25535,7 @@ const getUserFeed = (params, callback, config) => {
|
|
|
25520
25535
|
};
|
|
25521
25536
|
/* end_public_function */
|
|
25522
25537
|
|
|
25523
|
-
var index$
|
|
25538
|
+
var index$a = /*#__PURE__*/Object.freeze({
|
|
25524
25539
|
__proto__: null,
|
|
25525
25540
|
queryGlobalFeed: queryGlobalFeed,
|
|
25526
25541
|
getCustomRankingGlobalFeed: getCustomRankingGlobalFeed,
|
|
@@ -27201,7 +27216,7 @@ const searchPostsByHashtag = (params, callback, config) => {
|
|
|
27201
27216
|
};
|
|
27202
27217
|
/* end_public_function */
|
|
27203
27218
|
|
|
27204
|
-
var index$
|
|
27219
|
+
var index$9 = /*#__PURE__*/Object.freeze({
|
|
27205
27220
|
__proto__: null,
|
|
27206
27221
|
getPostByIds: getPostByIds,
|
|
27207
27222
|
createPost: createPost,
|
|
@@ -27802,7 +27817,7 @@ const getStreams = (params, callback, config) => {
|
|
|
27802
27817
|
};
|
|
27803
27818
|
/* end_public_function */
|
|
27804
27819
|
|
|
27805
|
-
var index$
|
|
27820
|
+
var index$8 = /*#__PURE__*/Object.freeze({
|
|
27806
27821
|
__proto__: null,
|
|
27807
27822
|
createStream: createStream,
|
|
27808
27823
|
updateStream: updateStream,
|
|
@@ -27820,6 +27835,729 @@ var index$7 = /*#__PURE__*/Object.freeze({
|
|
|
27820
27835
|
getStreams: getStreams
|
|
27821
27836
|
});
|
|
27822
27837
|
|
|
27838
|
+
/* begin_public_function
|
|
27839
|
+
id: room.create
|
|
27840
|
+
*/
|
|
27841
|
+
/**
|
|
27842
|
+
* ```js
|
|
27843
|
+
* import { createRoom } from '@amityco/ts-sdk'
|
|
27844
|
+
* const created = await createRoom({ title: 'my room', 'thumbnailFileId': fileId })
|
|
27845
|
+
* ```
|
|
27846
|
+
*
|
|
27847
|
+
* Creates an {@link Amity.Room}
|
|
27848
|
+
*
|
|
27849
|
+
* @param bundle The data necessary to create a new {@link Amity.Room}
|
|
27850
|
+
* @returns The newly created {@link Amity.Room}
|
|
27851
|
+
*
|
|
27852
|
+
* @category Room API
|
|
27853
|
+
* @async
|
|
27854
|
+
*/
|
|
27855
|
+
const createRoom = async (bundle) => {
|
|
27856
|
+
const client = getActiveClient();
|
|
27857
|
+
client.log('room/createRoom', bundle);
|
|
27858
|
+
const { data } = await client.http.post('/api/v1/rooms', bundle);
|
|
27859
|
+
fireEvent('local.room.created', data);
|
|
27860
|
+
const cachedAt = client.cache && Date.now();
|
|
27861
|
+
// TODO: check if should pick `users` filed which contains participants - if no need to ingest in the cache
|
|
27862
|
+
if (client.cache)
|
|
27863
|
+
ingestInCache(data, { cachedAt });
|
|
27864
|
+
const { rooms } = data;
|
|
27865
|
+
return {
|
|
27866
|
+
data: rooms[0],
|
|
27867
|
+
cachedAt,
|
|
27868
|
+
};
|
|
27869
|
+
};
|
|
27870
|
+
/* end_public_function */
|
|
27871
|
+
|
|
27872
|
+
/* begin_public_function
|
|
27873
|
+
id: room.update
|
|
27874
|
+
*/
|
|
27875
|
+
/**
|
|
27876
|
+
* ```js
|
|
27877
|
+
* import { updateRoom } from '@amityco/ts-sdk'
|
|
27878
|
+
* const updated = await updateRoom('roomId', { title: 'updated title' })
|
|
27879
|
+
* ```
|
|
27880
|
+
*
|
|
27881
|
+
* Updates an {@link Amity.InternalRoom}
|
|
27882
|
+
*
|
|
27883
|
+
* @param roomId The ID of the room to update
|
|
27884
|
+
* @param bundle The data to update the room with
|
|
27885
|
+
* @returns The updated {@link Amity.InternalRoom}
|
|
27886
|
+
*
|
|
27887
|
+
* @category Room API
|
|
27888
|
+
* @async
|
|
27889
|
+
*/
|
|
27890
|
+
const updateRoom = async (roomId, bundle) => {
|
|
27891
|
+
const client = getActiveClient();
|
|
27892
|
+
client.log('room/updateRoom', { roomId, bundle });
|
|
27893
|
+
const { data } = await client.http.put(`/api/v1/rooms/${roomId}`, bundle);
|
|
27894
|
+
fireEvent('local.room.updated', data);
|
|
27895
|
+
const cachedAt = client.cache && Date.now();
|
|
27896
|
+
if (client.cache)
|
|
27897
|
+
ingestInCache(data, { cachedAt });
|
|
27898
|
+
const { rooms } = data;
|
|
27899
|
+
return {
|
|
27900
|
+
data: rooms[0],
|
|
27901
|
+
cachedAt,
|
|
27902
|
+
};
|
|
27903
|
+
};
|
|
27904
|
+
/* end_public_function */
|
|
27905
|
+
|
|
27906
|
+
/* begin_public_function
|
|
27907
|
+
id: room.delete
|
|
27908
|
+
*/
|
|
27909
|
+
/**
|
|
27910
|
+
* ```js
|
|
27911
|
+
* import { deleteRoom } from '@amityco/ts-sdk'
|
|
27912
|
+
* const result = await deleteRoom('roomId')
|
|
27913
|
+
* ```
|
|
27914
|
+
*
|
|
27915
|
+
* Deletes an {@link Amity.Room}
|
|
27916
|
+
*
|
|
27917
|
+
* @param roomId The ID of the room to delete
|
|
27918
|
+
* @returns Promise that resolves when the room is deleted
|
|
27919
|
+
*
|
|
27920
|
+
* @category Room API
|
|
27921
|
+
* @async
|
|
27922
|
+
*/
|
|
27923
|
+
const deleteRoom = async (roomId) => {
|
|
27924
|
+
const client = getActiveClient();
|
|
27925
|
+
client.log('room/deleteRoom', { roomId });
|
|
27926
|
+
await client.http.delete(`/api/v1/rooms/${roomId}`);
|
|
27927
|
+
fireEvent('local.room.deleted', { rooms: [{ _id: roomId }] });
|
|
27928
|
+
};
|
|
27929
|
+
/* end_public_function */
|
|
27930
|
+
|
|
27931
|
+
/* begin_public_function
|
|
27932
|
+
id: room.stop
|
|
27933
|
+
*/
|
|
27934
|
+
/**
|
|
27935
|
+
* ```js
|
|
27936
|
+
* import { stopRoom } from '@amityco/ts-sdk'
|
|
27937
|
+
* const result = await stopRoom('roomId')
|
|
27938
|
+
* ```
|
|
27939
|
+
*
|
|
27940
|
+
* Stops a room's broadcasting
|
|
27941
|
+
*
|
|
27942
|
+
* @param roomId The ID of the room to stop
|
|
27943
|
+
* @returns The updated room data
|
|
27944
|
+
*
|
|
27945
|
+
* @category Room API
|
|
27946
|
+
* @async
|
|
27947
|
+
*/
|
|
27948
|
+
const stopRoom = async (roomId) => {
|
|
27949
|
+
const client = getActiveClient();
|
|
27950
|
+
client.log('room/stopRoom', { roomId });
|
|
27951
|
+
const { data } = await client.http.post(`/api/v1/rooms/${roomId}/stop`);
|
|
27952
|
+
fireEvent('local.room.stopped', data);
|
|
27953
|
+
const cachedAt = client.cache && Date.now();
|
|
27954
|
+
if (client.cache)
|
|
27955
|
+
ingestInCache(data, { cachedAt });
|
|
27956
|
+
const { rooms } = data;
|
|
27957
|
+
return {
|
|
27958
|
+
data: rooms[0],
|
|
27959
|
+
cachedAt,
|
|
27960
|
+
};
|
|
27961
|
+
};
|
|
27962
|
+
/* end_public_function */
|
|
27963
|
+
|
|
27964
|
+
/* begin_public_function
|
|
27965
|
+
id: room.getToken
|
|
27966
|
+
*/
|
|
27967
|
+
/**
|
|
27968
|
+
* ```js
|
|
27969
|
+
* import { getRoomToken } from '@amityco/ts-sdk'
|
|
27970
|
+
* const token = await getRoomToken('roomId')
|
|
27971
|
+
* ```
|
|
27972
|
+
*
|
|
27973
|
+
* Gets an access token for a room
|
|
27974
|
+
*
|
|
27975
|
+
* @param roomId The ID of the room to get token for
|
|
27976
|
+
* @returns The room access token
|
|
27977
|
+
*
|
|
27978
|
+
* @category Room API
|
|
27979
|
+
* @async
|
|
27980
|
+
*/
|
|
27981
|
+
const getRoomToken = async (roomId) => {
|
|
27982
|
+
const client = getActiveClient();
|
|
27983
|
+
client.log('room/getRoomToken', { roomId });
|
|
27984
|
+
const { data } = await client.http.get(`/api/v1/rooms/${roomId}/token`);
|
|
27985
|
+
return data;
|
|
27986
|
+
};
|
|
27987
|
+
/* end_public_function */
|
|
27988
|
+
|
|
27989
|
+
/* begin_public_function
|
|
27990
|
+
id: room.getRecordedUrl
|
|
27991
|
+
*/
|
|
27992
|
+
/**
|
|
27993
|
+
* ```js
|
|
27994
|
+
* import { getRecordedUrl } from '@amityco/ts-sdk'
|
|
27995
|
+
* const recordedUrl = await getRecordedUrl('roomId')
|
|
27996
|
+
* ```
|
|
27997
|
+
*
|
|
27998
|
+
* Gets the recorded URL for a room
|
|
27999
|
+
*
|
|
28000
|
+
* @param roomId The ID of the room to get recorded URL for
|
|
28001
|
+
* @returns The recorded URL information
|
|
28002
|
+
*
|
|
28003
|
+
* @category Room API
|
|
28004
|
+
* @async
|
|
28005
|
+
*/
|
|
28006
|
+
const getRecordedUrl = async (roomId) => {
|
|
28007
|
+
const client = getActiveClient();
|
|
28008
|
+
client.log('room/getRecordedUrl', { roomId });
|
|
28009
|
+
const { data } = await client.http.get(`/api/v1/rooms/${roomId}/recorded`);
|
|
28010
|
+
return data;
|
|
28011
|
+
};
|
|
28012
|
+
/* end_public_function */
|
|
28013
|
+
|
|
28014
|
+
/**
|
|
28015
|
+
* ```js
|
|
28016
|
+
* import { onRoomStartBroadcasting } from '@amityco/ts-sdk'
|
|
28017
|
+
* const dispose = onRoomStartBroadcasting(room => {
|
|
28018
|
+
* // ...
|
|
28019
|
+
* })
|
|
28020
|
+
* ```
|
|
28021
|
+
*
|
|
28022
|
+
* Fired when a {@link Amity.Room} has started broadcasting
|
|
28023
|
+
*
|
|
28024
|
+
* @param callback The function to call when the event was fired
|
|
28025
|
+
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
28026
|
+
*
|
|
28027
|
+
* @category Room Events
|
|
28028
|
+
*/
|
|
28029
|
+
const onRoomStartBroadcasting = (callback) => {
|
|
28030
|
+
const client = getActiveClient();
|
|
28031
|
+
const filter = (payload) => {
|
|
28032
|
+
ingestInCache(payload);
|
|
28033
|
+
callback(payload.rooms[0]);
|
|
28034
|
+
};
|
|
28035
|
+
return createEventSubscriber(client, 'room/onRoomStartBroadcasting', 'room.startBroadcasting', filter);
|
|
28036
|
+
};
|
|
28037
|
+
|
|
28038
|
+
/**
|
|
28039
|
+
* ```js
|
|
28040
|
+
* import { onRoomWaitingReconnect } from '@amityco/ts-sdk'
|
|
28041
|
+
* const dispose = onRoomWaitingReconnect(room => {
|
|
28042
|
+
* // ...
|
|
28043
|
+
* })
|
|
28044
|
+
* ```
|
|
28045
|
+
*
|
|
28046
|
+
* Fired when a {@link Amity.Room} is waiting for reconnection
|
|
28047
|
+
*
|
|
28048
|
+
* @param callback The function to call when the event was fired
|
|
28049
|
+
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
28050
|
+
*
|
|
28051
|
+
* @category Room Events
|
|
28052
|
+
*/
|
|
28053
|
+
const onRoomWaitingReconnect = (callback) => {
|
|
28054
|
+
const client = getActiveClient();
|
|
28055
|
+
const filter = (payload) => {
|
|
28056
|
+
ingestInCache(payload);
|
|
28057
|
+
callback(payload.rooms[0]);
|
|
28058
|
+
};
|
|
28059
|
+
return createEventSubscriber(client, 'room/onRoomWaitingReconnect', 'room.waitingReconnect', filter);
|
|
28060
|
+
};
|
|
28061
|
+
|
|
28062
|
+
/**
|
|
28063
|
+
* ```js
|
|
28064
|
+
* import { onRoomEndBroadcasting } from '@amityco/ts-sdk'
|
|
28065
|
+
* const dispose = onRoomEndBroadcasting(room => {
|
|
28066
|
+
* // ...
|
|
28067
|
+
* })
|
|
28068
|
+
* ```
|
|
28069
|
+
*
|
|
28070
|
+
* Fired when a {@link Amity.Room} has ended broadcasting
|
|
28071
|
+
*
|
|
28072
|
+
* @param callback The function to call when the event was fired
|
|
28073
|
+
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
28074
|
+
*
|
|
28075
|
+
* @category Room Events
|
|
28076
|
+
*/
|
|
28077
|
+
const onRoomEndBroadcasting = (callback) => {
|
|
28078
|
+
const client = getActiveClient();
|
|
28079
|
+
const filter = (payload) => {
|
|
28080
|
+
ingestInCache(payload);
|
|
28081
|
+
callback(payload.rooms[0]);
|
|
28082
|
+
};
|
|
28083
|
+
return createEventSubscriber(client, 'room/onRoomEndBroadcasting', 'room.endBroadcasting', filter);
|
|
28084
|
+
};
|
|
28085
|
+
|
|
28086
|
+
/**
|
|
28087
|
+
* ```js
|
|
28088
|
+
* import { onRoomRecordedAvailable } from '@amityco/ts-sdk'
|
|
28089
|
+
* const dispose = onRoomRecordedAvailable(room => {
|
|
28090
|
+
* // ...
|
|
28091
|
+
* })
|
|
28092
|
+
* ```
|
|
28093
|
+
*
|
|
28094
|
+
* Fired when a {@link Amity.Room} recorded content becomes available
|
|
28095
|
+
*
|
|
28096
|
+
* @param callback The function to call when the event was fired
|
|
28097
|
+
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
28098
|
+
*
|
|
28099
|
+
* @category Room Events
|
|
28100
|
+
*/
|
|
28101
|
+
const onRoomRecordedAvailable = (callback) => {
|
|
28102
|
+
const client = getActiveClient();
|
|
28103
|
+
const filter = (payload) => {
|
|
28104
|
+
ingestInCache(payload);
|
|
28105
|
+
callback(payload.rooms[0]);
|
|
28106
|
+
};
|
|
28107
|
+
return createEventSubscriber(client, 'room/onRoomRecordedAvailable', 'room.recordedAvailable', filter);
|
|
28108
|
+
};
|
|
28109
|
+
|
|
28110
|
+
/**
|
|
28111
|
+
* ```js
|
|
28112
|
+
* import { onRoomParticipantInviting } from '@amityco/ts-sdk'
|
|
28113
|
+
* const dispose = onRoomParticipantInviting(room => {
|
|
28114
|
+
* // ...
|
|
28115
|
+
* })
|
|
28116
|
+
* ```
|
|
28117
|
+
*
|
|
28118
|
+
* Fired when a participant is being invited to a {@link Amity.Room}
|
|
28119
|
+
*
|
|
28120
|
+
* @param callback The function to call when the event was fired
|
|
28121
|
+
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
28122
|
+
*
|
|
28123
|
+
* @category Room Events
|
|
28124
|
+
*/
|
|
28125
|
+
const onRoomParticipantInviting = (callback) => {
|
|
28126
|
+
const client = getActiveClient();
|
|
28127
|
+
const filter = (payload) => {
|
|
28128
|
+
ingestInCache(payload);
|
|
28129
|
+
callback(payload.rooms[0]);
|
|
28130
|
+
};
|
|
28131
|
+
return createEventSubscriber(client, 'room/onRoomParticipantInviting', 'room.participantInviting', filter);
|
|
28132
|
+
};
|
|
28133
|
+
|
|
28134
|
+
/**
|
|
28135
|
+
* ```js
|
|
28136
|
+
* import { onRoomParticipantJoined } from '@amityco/ts-sdk'
|
|
28137
|
+
* const dispose = onRoomParticipantJoined(room => {
|
|
28138
|
+
* // ...
|
|
28139
|
+
* })
|
|
28140
|
+
* ```
|
|
28141
|
+
*
|
|
28142
|
+
* Fired when a participant has joined a {@link Amity.Room}
|
|
28143
|
+
*
|
|
28144
|
+
* @param callback The function to call when the event was fired
|
|
28145
|
+
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
28146
|
+
*
|
|
28147
|
+
* @category Room Events
|
|
28148
|
+
*/
|
|
28149
|
+
const onRoomParticipantJoined = (callback) => {
|
|
28150
|
+
const client = getActiveClient();
|
|
28151
|
+
const filter = (payload) => {
|
|
28152
|
+
ingestInCache(payload);
|
|
28153
|
+
callback(payload.rooms[0]);
|
|
28154
|
+
};
|
|
28155
|
+
return createEventSubscriber(client, 'room/onRoomParticipantJoined', 'room.participantJoined', filter);
|
|
28156
|
+
};
|
|
28157
|
+
|
|
28158
|
+
/**
|
|
28159
|
+
* ```js
|
|
28160
|
+
* import { onRoomParticipantLeft } from '@amityco/ts-sdk'
|
|
28161
|
+
* const dispose = onRoomParticipantLeft(room => {
|
|
28162
|
+
* // ...
|
|
28163
|
+
* })
|
|
28164
|
+
* ```
|
|
28165
|
+
*
|
|
28166
|
+
* Fired when a participant has left a {@link Amity.Room}
|
|
28167
|
+
*
|
|
28168
|
+
* @param callback The function to call when the event was fired
|
|
28169
|
+
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
28170
|
+
*
|
|
28171
|
+
* @category Room Events
|
|
28172
|
+
*/
|
|
28173
|
+
const onRoomParticipantLeft = (callback) => {
|
|
28174
|
+
const client = getActiveClient();
|
|
28175
|
+
const filter = (payload) => {
|
|
28176
|
+
ingestInCache(payload);
|
|
28177
|
+
callback(payload.rooms[0]);
|
|
28178
|
+
};
|
|
28179
|
+
return createEventSubscriber(client, 'room/onRoomParticipantLeft', 'room.participantLeft', filter);
|
|
28180
|
+
};
|
|
28181
|
+
|
|
28182
|
+
/**
|
|
28183
|
+
* ```js
|
|
28184
|
+
* import { onRoomCreated } from '@amityco/ts-sdk'
|
|
28185
|
+
* const dispose = onRoomCreated(room => {
|
|
28186
|
+
* // ...
|
|
28187
|
+
* })
|
|
28188
|
+
* ```
|
|
28189
|
+
*
|
|
28190
|
+
* Fired when a {@link Amity.Room} has been created locally
|
|
28191
|
+
*
|
|
28192
|
+
* @param callback The function to call when the event was fired
|
|
28193
|
+
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
28194
|
+
*
|
|
28195
|
+
* @category Room Events
|
|
28196
|
+
*/
|
|
28197
|
+
const onRoomCreated = (callback) => {
|
|
28198
|
+
const client = getActiveClient();
|
|
28199
|
+
const filter = (payload) => {
|
|
28200
|
+
ingestInCache(payload);
|
|
28201
|
+
callback(payload.rooms[0]);
|
|
28202
|
+
};
|
|
28203
|
+
return createEventSubscriber(client, 'room/onRoomCreated', 'local.room.created', filter);
|
|
28204
|
+
};
|
|
28205
|
+
|
|
28206
|
+
/**
|
|
28207
|
+
* ```js
|
|
28208
|
+
* import { onRoomUpdated } from '@amityco/ts-sdk'
|
|
28209
|
+
* const dispose = onRoomUpdated(room => {
|
|
28210
|
+
* // ...
|
|
28211
|
+
* })
|
|
28212
|
+
* ```
|
|
28213
|
+
*
|
|
28214
|
+
* Fired when a {@link Amity.Room} has been updated locally
|
|
28215
|
+
*
|
|
28216
|
+
* @param callback The function to call when the event was fired
|
|
28217
|
+
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
28218
|
+
*
|
|
28219
|
+
* @category Room Events
|
|
28220
|
+
*/
|
|
28221
|
+
const onRoomUpdated = (callback) => {
|
|
28222
|
+
const client = getActiveClient();
|
|
28223
|
+
const filter = (payload) => {
|
|
28224
|
+
ingestInCache(payload);
|
|
28225
|
+
callback(payload.rooms[0]);
|
|
28226
|
+
};
|
|
28227
|
+
return createEventSubscriber(client, 'room/onRoomUpdated', 'local.room.updated', filter);
|
|
28228
|
+
};
|
|
28229
|
+
|
|
28230
|
+
/**
|
|
28231
|
+
* ```js
|
|
28232
|
+
* import { onRoomDeleted } from '@amityco/ts-sdk'
|
|
28233
|
+
* const dispose = onRoomDeleted(room => {
|
|
28234
|
+
* // ...
|
|
28235
|
+
* })
|
|
28236
|
+
* ```
|
|
28237
|
+
*
|
|
28238
|
+
* Fired when a {@link Amity.Room} has been deleted locally
|
|
28239
|
+
*
|
|
28240
|
+
* @param callback The function to call when the event was fired
|
|
28241
|
+
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
28242
|
+
*
|
|
28243
|
+
* @category Room Events
|
|
28244
|
+
*/
|
|
28245
|
+
const onRoomDeleted = (callback) => {
|
|
28246
|
+
const client = getActiveClient();
|
|
28247
|
+
const filter = (payload) => {
|
|
28248
|
+
ingestInCache(payload);
|
|
28249
|
+
callback(payload.rooms[0]);
|
|
28250
|
+
};
|
|
28251
|
+
return createEventSubscriber(client, 'room/onRoomDeleted', 'local.room.deleted', filter);
|
|
28252
|
+
};
|
|
28253
|
+
|
|
28254
|
+
/**
|
|
28255
|
+
* ```js
|
|
28256
|
+
* import { onRoomStopped } from '@amityco/ts-sdk'
|
|
28257
|
+
* const dispose = onRoomStopped(room => {
|
|
28258
|
+
* // ...
|
|
28259
|
+
* })
|
|
28260
|
+
* ```
|
|
28261
|
+
*
|
|
28262
|
+
* Fired when a {@link Amity.Room} has been stopped locally
|
|
28263
|
+
*
|
|
28264
|
+
* @param callback The function to call when the event was fired
|
|
28265
|
+
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
28266
|
+
*
|
|
28267
|
+
* @category Room Events
|
|
28268
|
+
*/
|
|
28269
|
+
const onRoomStopped = (callback) => {
|
|
28270
|
+
const client = getActiveClient();
|
|
28271
|
+
const filter = (payload) => {
|
|
28272
|
+
ingestInCache(payload);
|
|
28273
|
+
callback(payload.rooms[0]);
|
|
28274
|
+
};
|
|
28275
|
+
return createEventSubscriber(client, 'room/onRoomStopped', 'local.room.stopped', filter);
|
|
28276
|
+
};
|
|
28277
|
+
|
|
28278
|
+
const getRoomById = async (roomId) => {
|
|
28279
|
+
const client = getActiveClient();
|
|
28280
|
+
client.log('room/getRoomById', roomId);
|
|
28281
|
+
// Check if room is in tombstone
|
|
28282
|
+
isInTombstone('room', roomId);
|
|
28283
|
+
let data;
|
|
28284
|
+
try {
|
|
28285
|
+
const response = await client.http.get(`/api/v1/rooms/${roomId}`);
|
|
28286
|
+
data = response.data;
|
|
28287
|
+
}
|
|
28288
|
+
catch (error) {
|
|
28289
|
+
if (checkIfShouldGoesToTombstone(error === null || error === void 0 ? void 0 : error.code)) {
|
|
28290
|
+
pushToTombstone('room', roomId);
|
|
28291
|
+
}
|
|
28292
|
+
throw error;
|
|
28293
|
+
}
|
|
28294
|
+
const cachedAt = client.cache && Date.now();
|
|
28295
|
+
if (client.cache) {
|
|
28296
|
+
ingestInCache(data, { cachedAt });
|
|
28297
|
+
}
|
|
28298
|
+
return {
|
|
28299
|
+
data: data.rooms[0],
|
|
28300
|
+
cachedAt,
|
|
28301
|
+
};
|
|
28302
|
+
};
|
|
28303
|
+
getRoomById.locally = (roomId) => {
|
|
28304
|
+
const client = getActiveClient();
|
|
28305
|
+
client.log('room/getRoomById.locally', roomId);
|
|
28306
|
+
// Check if room is in tombstone
|
|
28307
|
+
isInTombstone('room', roomId);
|
|
28308
|
+
const cachedAt = client.cache && Date.now();
|
|
28309
|
+
const roomCache = pullFromCache(['room', 'get', roomId]);
|
|
28310
|
+
if (!roomCache)
|
|
28311
|
+
return;
|
|
28312
|
+
return {
|
|
28313
|
+
data: roomCache.data,
|
|
28314
|
+
cachedAt,
|
|
28315
|
+
};
|
|
28316
|
+
};
|
|
28317
|
+
|
|
28318
|
+
const getRoom = (roomId, callback) => {
|
|
28319
|
+
// TODO: add callbackDataSelector if there are linked object fields
|
|
28320
|
+
return liveObject(roomId, callback, '_id', getRoomById, [
|
|
28321
|
+
onRoomEndBroadcasting,
|
|
28322
|
+
onRoomStartBroadcasting,
|
|
28323
|
+
onRoomWaitingReconnect,
|
|
28324
|
+
onRoomRecordedAvailable,
|
|
28325
|
+
]);
|
|
28326
|
+
};
|
|
28327
|
+
|
|
28328
|
+
class RoomPaginationController extends PaginationController {
|
|
28329
|
+
async getRequest(queryParams, token) {
|
|
28330
|
+
const { limit = COLLECTION_DEFAULT_PAGINATION_LIMIT, includeDeleted } = queryParams, params = __rest(queryParams, ["limit", "includeDeleted"]);
|
|
28331
|
+
const baseOptions = {
|
|
28332
|
+
type: params.sortBy || queryParams.limit ? 'pagination' : undefined,
|
|
28333
|
+
};
|
|
28334
|
+
const options = token ? Object.assign(Object.assign({}, baseOptions), { token }) : Object.assign(Object.assign({}, baseOptions), { limit });
|
|
28335
|
+
const { data: queryResponse } = await this.http.get(`/api/v1/rooms`, {
|
|
28336
|
+
params: Object.assign(Object.assign({}, params), { isDeleted: inferIsDeleted(includeDeleted), options }),
|
|
28337
|
+
});
|
|
28338
|
+
return queryResponse;
|
|
28339
|
+
}
|
|
28340
|
+
}
|
|
28341
|
+
|
|
28342
|
+
var EnumRoomActions;
|
|
28343
|
+
(function (EnumRoomActions) {
|
|
28344
|
+
EnumRoomActions["OnRoomCreated"] = "OnRoomCreated";
|
|
28345
|
+
EnumRoomActions["OnRoomUpdated"] = "OnRoomUpdated";
|
|
28346
|
+
EnumRoomActions["OnRoomDeleted"] = "OnRoomDeleted";
|
|
28347
|
+
EnumRoomActions["OnRoomStartBroadcasting"] = "OnRoomStartBroadcasting";
|
|
28348
|
+
EnumRoomActions["OnRoomEndBroadcasting"] = "OnRoomEndBroadcasting";
|
|
28349
|
+
EnumRoomActions["OnRoomParticipantJoined"] = "OnRoomParticipantJoined";
|
|
28350
|
+
EnumRoomActions["OnRoomParticipantLeft"] = "OnRoomParticipantLeft";
|
|
28351
|
+
})(EnumRoomActions || (EnumRoomActions = {}));
|
|
28352
|
+
|
|
28353
|
+
class RoomQueryStreamController extends QueryStreamController {
|
|
28354
|
+
constructor(query, cacheKey, notifyChange, preparePayload) {
|
|
28355
|
+
super(query, cacheKey);
|
|
28356
|
+
this.notifyChange = notifyChange;
|
|
28357
|
+
this.preparePayload = preparePayload;
|
|
28358
|
+
}
|
|
28359
|
+
async saveToMainDB(response) {
|
|
28360
|
+
const processedPayload = await this.preparePayload(response);
|
|
28361
|
+
const client = getActiveClient();
|
|
28362
|
+
const cachedAt = client.cache && Date.now();
|
|
28363
|
+
if (client.cache) {
|
|
28364
|
+
ingestInCache(processedPayload, { cachedAt });
|
|
28365
|
+
}
|
|
28366
|
+
}
|
|
28367
|
+
appendToQueryStream(response, direction, refresh = false) {
|
|
28368
|
+
var _a, _b;
|
|
28369
|
+
if (refresh) {
|
|
28370
|
+
pushToCache(this.cacheKey, {
|
|
28371
|
+
data: response.rooms.map(getResolver('room')),
|
|
28372
|
+
});
|
|
28373
|
+
}
|
|
28374
|
+
else {
|
|
28375
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
28376
|
+
const rooms = (_b = collection === null || collection === void 0 ? void 0 : collection.data) !== null && _b !== void 0 ? _b : [];
|
|
28377
|
+
pushToCache(this.cacheKey, Object.assign(Object.assign({}, collection), { data: [...new Set([...rooms, ...response.rooms.map(getResolver('room'))])] }));
|
|
28378
|
+
}
|
|
28379
|
+
}
|
|
28380
|
+
reactor(action) {
|
|
28381
|
+
return (room) => {
|
|
28382
|
+
var _a;
|
|
28383
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
28384
|
+
if (!collection)
|
|
28385
|
+
return;
|
|
28386
|
+
if (action === EnumRoomActions.OnRoomDeleted) {
|
|
28387
|
+
collection.data = collection.data.filter(roomId => roomId !== room._id);
|
|
28388
|
+
}
|
|
28389
|
+
if (action === EnumRoomActions.OnRoomCreated) {
|
|
28390
|
+
collection.data = [...new Set([room._id, ...collection.data])];
|
|
28391
|
+
}
|
|
28392
|
+
pushToCache(this.cacheKey, collection);
|
|
28393
|
+
this.notifyChange({ origin: "event" /* Amity.LiveDataOrigin.EVENT */, loading: false });
|
|
28394
|
+
};
|
|
28395
|
+
}
|
|
28396
|
+
subscribeRTE(createSubscriber) {
|
|
28397
|
+
return createSubscriber.map(subscriber => subscriber.fn(this.reactor(subscriber.action)));
|
|
28398
|
+
}
|
|
28399
|
+
}
|
|
28400
|
+
|
|
28401
|
+
// TODO: confirm related events
|
|
28402
|
+
const getRoomSubscription = () => [
|
|
28403
|
+
{
|
|
28404
|
+
fn: onRoomStartBroadcasting,
|
|
28405
|
+
action: EnumRoomActions.OnRoomStartBroadcasting,
|
|
28406
|
+
},
|
|
28407
|
+
{
|
|
28408
|
+
fn: onRoomEndBroadcasting,
|
|
28409
|
+
action: EnumRoomActions.OnRoomEndBroadcasting,
|
|
28410
|
+
},
|
|
28411
|
+
{
|
|
28412
|
+
fn: onRoomRecordedAvailable,
|
|
28413
|
+
action: EnumRoomActions.OnRoomUpdated,
|
|
28414
|
+
},
|
|
28415
|
+
];
|
|
28416
|
+
|
|
28417
|
+
class RoomLiveCollectionController extends LiveCollectionController {
|
|
28418
|
+
constructor(query, callback) {
|
|
28419
|
+
const queryStreamId = hash__default["default"](query);
|
|
28420
|
+
const cacheKey = ['rooms', 'collection', queryStreamId];
|
|
28421
|
+
const paginationController = new RoomPaginationController(query);
|
|
28422
|
+
super(paginationController, queryStreamId, cacheKey, callback);
|
|
28423
|
+
this.query = query;
|
|
28424
|
+
this.queryStreamController = new RoomQueryStreamController(this.query, this.cacheKey, this.notifyChange.bind(this), response => response);
|
|
28425
|
+
this.callback = callback.bind(this);
|
|
28426
|
+
this.loadPage({ initial: true });
|
|
28427
|
+
}
|
|
28428
|
+
setup() {
|
|
28429
|
+
var _a;
|
|
28430
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
28431
|
+
if (!collection) {
|
|
28432
|
+
pushToCache(this.cacheKey, {
|
|
28433
|
+
data: [],
|
|
28434
|
+
params: {},
|
|
28435
|
+
});
|
|
28436
|
+
}
|
|
28437
|
+
}
|
|
28438
|
+
async persistModel(queryPayload) {
|
|
28439
|
+
await this.queryStreamController.saveToMainDB(queryPayload);
|
|
28440
|
+
}
|
|
28441
|
+
persistQueryStream({ response, direction, refresh, }) {
|
|
28442
|
+
this.queryStreamController.appendToQueryStream(response, direction, refresh);
|
|
28443
|
+
}
|
|
28444
|
+
startSubscription() {
|
|
28445
|
+
return this.queryStreamController.subscribeRTE(getRoomSubscription());
|
|
28446
|
+
}
|
|
28447
|
+
notifyChange({ origin, loading, error }) {
|
|
28448
|
+
var _a, _b;
|
|
28449
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
28450
|
+
if (!collection)
|
|
28451
|
+
return;
|
|
28452
|
+
const data = this.applyFilter((_b = collection.data
|
|
28453
|
+
.map(id => pullFromCache(['room', 'get', id]))
|
|
28454
|
+
.filter(isNonNullable)
|
|
28455
|
+
.map(({ data }) => data)) !== null && _b !== void 0 ? _b : []).map(room => room); // Since Room is same as InternalRoom, no transformation needed
|
|
28456
|
+
if (!this.shouldNotify(data) && origin === 'event')
|
|
28457
|
+
return;
|
|
28458
|
+
this.callback({
|
|
28459
|
+
onNextPage: () => this.loadPage({ direction: "next" /* Amity.LiveCollectionPageDirection.NEXT */ }),
|
|
28460
|
+
data,
|
|
28461
|
+
hasNextPage: !!this.paginationController.getNextToken(),
|
|
28462
|
+
loading,
|
|
28463
|
+
error,
|
|
28464
|
+
});
|
|
28465
|
+
}
|
|
28466
|
+
applyFilter(data) {
|
|
28467
|
+
let rooms = data;
|
|
28468
|
+
if (!this.query.includeDeleted) {
|
|
28469
|
+
rooms = filterByPropEquality(rooms, 'isDeleted', false);
|
|
28470
|
+
}
|
|
28471
|
+
if (this.query.statuses && this.query.statuses.length > 0) {
|
|
28472
|
+
rooms = rooms.filter(room => { var _a; return (_a = this.query.statuses) === null || _a === void 0 ? void 0 : _a.includes(room.status); });
|
|
28473
|
+
}
|
|
28474
|
+
if (this.query.type) {
|
|
28475
|
+
rooms = filterByPropEquality(rooms, 'type', this.query.type);
|
|
28476
|
+
}
|
|
28477
|
+
switch (this.query.sortBy) {
|
|
28478
|
+
case 'firstCreated':
|
|
28479
|
+
rooms = rooms.sort(sortByFirstCreated);
|
|
28480
|
+
break;
|
|
28481
|
+
case 'lastCreated':
|
|
28482
|
+
default:
|
|
28483
|
+
rooms = rooms.sort(sortByLastCreated);
|
|
28484
|
+
break;
|
|
28485
|
+
}
|
|
28486
|
+
return rooms;
|
|
28487
|
+
}
|
|
28488
|
+
}
|
|
28489
|
+
|
|
28490
|
+
/* begin_public_function
|
|
28491
|
+
id: room.get_rooms
|
|
28492
|
+
*/
|
|
28493
|
+
/**
|
|
28494
|
+
* ```js
|
|
28495
|
+
* import { RoomRepository } from '@amityco/ts-sdk'
|
|
28496
|
+
*
|
|
28497
|
+
* let rooms = []
|
|
28498
|
+
* const unsub = RoomRepository.getRooms({
|
|
28499
|
+
* type: 'direct_streaming',
|
|
28500
|
+
* statuses: ['live', 'idle'],
|
|
28501
|
+
* sortBy: 'lastCreated',
|
|
28502
|
+
* limit: 20,
|
|
28503
|
+
* includeDeleted: false
|
|
28504
|
+
* }, response => merge(rooms, response.data))
|
|
28505
|
+
* ```
|
|
28506
|
+
*
|
|
28507
|
+
* Observe all mutations on a list of {@link Amity.Room} for a given query
|
|
28508
|
+
*
|
|
28509
|
+
* @param params.type the type of rooms to filter by ('direct_streaming' | 'co_hosts')
|
|
28510
|
+
* @param params.statuses array of room statuses to filter by (['idle', 'live', 'waiting_reconnect', 'ended', 'recorded'])
|
|
28511
|
+
* @param params.sortBy sort rooms by creation time ('firstCreated' | 'lastCreated')
|
|
28512
|
+
* @param params.limit maximum number of rooms to retrieve per page
|
|
28513
|
+
* @param params.includeDeleted whether to include deleted rooms in the results
|
|
28514
|
+
* @param callback the function to call when new data are available
|
|
28515
|
+
* @param config optional configuration for the live collection
|
|
28516
|
+
* @returns An {@link Amity.Unsubscriber} function to run when willing to stop observing the rooms
|
|
28517
|
+
*
|
|
28518
|
+
* @category Rooms Live Collection
|
|
28519
|
+
*/
|
|
28520
|
+
const getRooms = (params, callback, config) => {
|
|
28521
|
+
const { log, cache } = getActiveClient();
|
|
28522
|
+
if (!cache) {
|
|
28523
|
+
console.log(ENABLE_CACHE_MESSAGE);
|
|
28524
|
+
}
|
|
28525
|
+
const timestamp = Date.now();
|
|
28526
|
+
log(`getRooms(tmpid: ${timestamp}) > listen`);
|
|
28527
|
+
const roomsLiveCollection = new RoomLiveCollectionController(params, callback);
|
|
28528
|
+
const disposers = roomsLiveCollection.startSubscription();
|
|
28529
|
+
const cacheKey = roomsLiveCollection.getCacheKey();
|
|
28530
|
+
disposers.push(() => dropFromCache(cacheKey));
|
|
28531
|
+
return () => {
|
|
28532
|
+
log(`getRooms(tmpid: ${timestamp}) > dispose`);
|
|
28533
|
+
disposers.forEach(fn => fn());
|
|
28534
|
+
};
|
|
28535
|
+
};
|
|
28536
|
+
/* end_public_function */
|
|
28537
|
+
|
|
28538
|
+
var index$7 = /*#__PURE__*/Object.freeze({
|
|
28539
|
+
__proto__: null,
|
|
28540
|
+
createRoom: createRoom,
|
|
28541
|
+
updateRoom: updateRoom,
|
|
28542
|
+
deleteRoom: deleteRoom,
|
|
28543
|
+
stopRoom: stopRoom,
|
|
28544
|
+
getRoomToken: getRoomToken,
|
|
28545
|
+
getRecordedUrl: getRecordedUrl,
|
|
28546
|
+
onRoomStartBroadcasting: onRoomStartBroadcasting,
|
|
28547
|
+
onRoomWaitingReconnect: onRoomWaitingReconnect,
|
|
28548
|
+
onRoomEndBroadcasting: onRoomEndBroadcasting,
|
|
28549
|
+
onRoomRecordedAvailable: onRoomRecordedAvailable,
|
|
28550
|
+
onRoomParticipantInviting: onRoomParticipantInviting,
|
|
28551
|
+
onRoomParticipantJoined: onRoomParticipantJoined,
|
|
28552
|
+
onRoomParticipantLeft: onRoomParticipantLeft,
|
|
28553
|
+
onRoomCreated: onRoomCreated,
|
|
28554
|
+
onRoomUpdated: onRoomUpdated,
|
|
28555
|
+
onRoomDeleted: onRoomDeleted,
|
|
28556
|
+
onRoomStopped: onRoomStopped,
|
|
28557
|
+
getRoom: getRoom,
|
|
28558
|
+
getRooms: getRooms
|
|
28559
|
+
});
|
|
28560
|
+
|
|
27823
28561
|
/* begin_public_function
|
|
27824
28562
|
id: poll.create
|
|
27825
28563
|
*/
|
|
@@ -28132,7 +28870,7 @@ var index$6 = /*#__PURE__*/Object.freeze({
|
|
|
28132
28870
|
getPoll: getPoll
|
|
28133
28871
|
});
|
|
28134
28872
|
|
|
28135
|
-
const privateKey = "-----BEGIN PRIVATE KEY-----\
|
|
28873
|
+
const privateKey = "-----BEGIN PRIVATE KEY-----\nMIIEvwIBADANBgkqhkiG9w0BAQEFAASCBKkwggSlAgEAAoIBAQDAARz+hmBgi8pJ\nQb8LeY41gtHhk+ACMwRfhsn7GqpqRQNG2qU0755mzZuVDUqjQMGSo8THJB7O+OJs\nflbZRkFXlFoFOVNw1UpNOgwEQZ6wB9oRwzepTJAfF1sVhm/o/ixvXh1zDFNDy6yZ\npXyiiJHUVxqyjllZhxnwdvjoVtDs6hW6awG09bB9nh/TTejlUKXoAgzqVwu/1QMu\nUVViET495elEe19aUarEy+oL2iKeXCEvqda/pWNBdbieFyJvvZ08HN8dPuT88wq2\njZLEAth1vrwQ2IAa4ktaLcBQdLJgIkrbDvAiVZ8lQAjS/bq5vXQikTGvoPlC5bbn\nvuOM/3eLAgMBAAECggEAVZ+peHAghq2QVj71nX5lxsNCKaCyYwixSJBpfouTt7Rz\nE6PpzMOXFi1W1o+I22jDakuSM2SOQKqI/u0QefB0r0O/KVk5NrZHXk0mkrdYtxOp\nUgaGyf8UvmjB+8VqHrNKyZdk9qtmbnNj01kTTcAtmE4H39zPR7eR/8Rul94vaZbs\nwCnKJS3mLT3JxyGug6lxanveKkjG+CKC1nJQYWaxCJxaFSzbwXQPvDhB+TvrIbee\npd5v4EAyEJohpr+T9oDGGJkb/KARBZCtwLyB976PKJwwBA8MRVL1i5QwawuMiMq5\nUtnOnbGKtCeFzaLbNU0Qi8bqyims84EQxC6DOu1fkQKBgQDdvsoBsEhsOXV7hlIJ\naEd0eSJZVkdqimxH8uGoMM2FeNaOrcB6yBXqTSP0R3OIyf8eaY6yjRvP30ZNXcll\n/gD3O1Mu6YmWQdt1W2WA6pKOsUuPXasf0pdOF7IiFZKlSabz5YHXFqwVuqm8loaj\nsXel3YWqPVdHiankE7tz+3ssnQKBgQDdqi4TNdD1MdEpihx19jr0QjUiXW3939FK\nqp30HESPEGDGQzXdmJgif9HhZb+cJSuWaHEbjgBrYahvgCF+y6LbEpOD+D/dmT+s\nDEAQaR84sah6dokwPjV8fjBSrcVFjCS+doxv0d3p/9OUEeyUhFrY03nxtIEYkLIE\n/Zvn37b4RwKBgQCLENVFe9XfsaVhQ5r9dV2iyTlmh7qgMZG5CbTFs12hQGhm8McO\n+Z7s41YSJCFr/yq1WwP4LJDtrBw99vyQr1zRsG35tNLp3gGRNzGQSQyC2uQFVHw2\np+7mNewsfhUK/gbrXNsyFnDz6635rPlhfbII3sWuP2wWXFqkxE9CbMwR7QKBgQC6\nawDMzxmo2/iYArrkyevSuEuPVxvFwpF1RgAI6C0QVCnPE38dmdN4UB7mfHekje4W\nVEercMURidPp0cxZolCYBQtilUjAyL0vqC3In1/Ogjq6oy3FEMxSop1pKxMY5j+Q\nnoqFD+6deLUrddeNH7J3X4LSr4dSbX4JjG+tlgt+yQKBgQCuwTL4hA6KqeInQ0Ta\n9VQX5Qr8hFlqJz1gpymi/k63tW/Ob8yedbg3WWNWyShwRMFYyY9S81ITFWM95uL6\nvF3x9rmRjwElJw9PMwVu6dmf/CO0Z1wzXSp2VVD12gbrUD/0/d7MUoJ9LgC8X8f/\nn0txLHYGHbx+nf95+JUg6lV3hg==\n-----END PRIVATE KEY-----";
|
|
28136
28874
|
/*
|
|
28137
28875
|
* The crypto algorithm used for importing key and signing string
|
|
28138
28876
|
*/
|
|
@@ -30454,33 +31192,34 @@ var index = /*#__PURE__*/Object.freeze({
|
|
|
30454
31192
|
|
|
30455
31193
|
exports.API_REGIONS = API_REGIONS;
|
|
30456
31194
|
exports.AdRepository = index$3;
|
|
30457
|
-
exports.CategoryRepository = index$
|
|
30458
|
-
exports.ChannelRepository = index$
|
|
30459
|
-
exports.Client = index$
|
|
30460
|
-
exports.CommentRepository = index$
|
|
31195
|
+
exports.CategoryRepository = index$c;
|
|
31196
|
+
exports.ChannelRepository = index$g;
|
|
31197
|
+
exports.Client = index$p;
|
|
31198
|
+
exports.CommentRepository = index$b;
|
|
30461
31199
|
exports.CommunityPostSettingMaps = CommunityPostSettingMaps;
|
|
30462
31200
|
exports.CommunityPostSettings = CommunityPostSettings;
|
|
30463
|
-
exports.CommunityRepository = index$
|
|
31201
|
+
exports.CommunityRepository = index$d;
|
|
30464
31202
|
exports.ContentFeedType = ContentFeedType;
|
|
30465
31203
|
exports.DefaultCommunityPostSetting = DefaultCommunityPostSetting;
|
|
30466
|
-
exports.FeedRepository = index$
|
|
30467
|
-
exports.FileRepository = index$
|
|
31204
|
+
exports.FeedRepository = index$a;
|
|
31205
|
+
exports.FileRepository = index$m;
|
|
30468
31206
|
exports.FileType = FileType;
|
|
30469
31207
|
exports.GET_WATCHER_URLS = GET_WATCHER_URLS;
|
|
30470
31208
|
exports.InvitationRepository = index$1;
|
|
30471
31209
|
exports.LiveReactionRepository = index;
|
|
30472
31210
|
exports.LiveStreamPlayer = index$5;
|
|
30473
31211
|
exports.MessageContentType = MessageContentType;
|
|
30474
|
-
exports.MessageRepository = index$
|
|
31212
|
+
exports.MessageRepository = index$k;
|
|
30475
31213
|
exports.PollRepository = index$6;
|
|
30476
31214
|
exports.PostContentType = PostContentType;
|
|
30477
|
-
exports.PostRepository = index$
|
|
31215
|
+
exports.PostRepository = index$9;
|
|
30478
31216
|
exports.PostStructureType = PostStructureType;
|
|
30479
|
-
exports.ReactionRepository = index$
|
|
31217
|
+
exports.ReactionRepository = index$l;
|
|
31218
|
+
exports.RoomRepository = index$7;
|
|
30480
31219
|
exports.StoryRepository = index$4;
|
|
30481
|
-
exports.StreamRepository = index$
|
|
30482
|
-
exports.SubChannelRepository = index$
|
|
30483
|
-
exports.UserRepository = index$
|
|
31220
|
+
exports.StreamRepository = index$8;
|
|
31221
|
+
exports.SubChannelRepository = index$j;
|
|
31222
|
+
exports.UserRepository = index$n;
|
|
30484
31223
|
exports.VERSION = VERSION;
|
|
30485
31224
|
exports.VideoResolution = VideoResolution;
|
|
30486
31225
|
exports.VideoSize = VideoSize;
|