fcr-core
Version:
Core APIs for building online scenes
1,236 lines (1,221 loc) • 31.6 kB
JavaScript
"use strict";
require("core-js/modules/es.array.push.js");
require("core-js/modules/esnext.iterator.filter.js");
require("core-js/modules/esnext.iterator.for-each.js");
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.FcrCoreServiceApi = void 0;
require("core-js/modules/esnext.iterator.constructor.js");
require("core-js/modules/esnext.iterator.map.js");
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
var _imports = require("../imports");
var _type = require("../room-control/privilege-control/type");
var _type2 = require("../room-control/user-control/type");
var _logger = require("../utilities/logger");
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
class FcrCoreServiceApi {
constructor(_client, appId, region) {
let pathIncludeRegion = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : true;
(0, _defineProperty2.default)(this, "logger", (0, _logger.getLogger)());
this._client = _client;
let pathPrefix = "/conference/apps/".concat(appId);
if (pathIncludeRegion) {
pathPrefix = "/".concat((0, _imports.toLower)(region)).concat(pathPrefix);
}
this.logger.info('[FcrCoreServiceApi] set path prefix for Core Service API:', pathPrefix);
this._pathPrefix = pathPrefix;
this._client.setPathPrefix(pathPrefix);
}
setRestfulClient(client) {
this._client = client;
this._client.setPathPrefix(this._pathPrefix);
}
async addGroups(params, opts) {
const {
data
} = await this._client.fetch({
path: "/v2/rooms/".concat(opts.roomId, "/groups"),
method: 'PUT',
data: {
groups: params.map(group => {
return {
groupName: group.groupName,
users: group.userList,
createGroupRequest: opts.startTime ? {
roomProperties: {
schedule: {
startTime: opts.startTime
}
}
} : undefined
};
})
}
});
}
async updateGroups(params, opts) {
const {
data
} = await this._client.fetch({
path: "/v2/rooms/".concat(opts.roomId, "/groups/info"),
method: 'PATCH',
data: {
groups: params.map(group => {
return {
groupUuid: group.groupId,
groupName: group.groupName
};
})
}
});
}
async deleteGroups(groupIds, opts) {
const {
data
} = await this._client.fetch({
path: "/v2/rooms/".concat(opts.roomId, "/groups/states/1"),
method: 'DELETE',
data: {
removeGroupUuids: groupIds
}
});
}
async deleteAllGroups(opts) {
const {
data
} = await this._client.fetch({
path: "/v2/rooms/".concat(opts.roomId, "/groups/all"),
method: 'DELETE'
});
}
async addUsers(userList, groupId, opts) {
const {
data
} = await this._client.fetch({
path: "/v2/rooms/".concat(opts.roomId, "/groups/users"),
method: 'PATCH',
data: {
groups: [{
groupUuid: groupId,
addUsers: userList
}],
inProgress: opts.inProgress
}
});
}
async removeUsers(userList, groupId, opts) {
const {
data
} = await this._client.fetch({
path: "/v2/rooms/".concat(opts.roomId, "/groups/users"),
method: 'PATCH',
data: {
groups: [{
groupUuid: groupId,
removeUsers: userList
}],
inProgress: opts.inProgress
}
});
}
async moveUsers(userList, fromGroupId, toGroupId, opts) {
const {
data
} = await this._client.fetch({
path: "/v2/rooms/".concat(opts.roomId, "/groups/users"),
method: 'PATCH',
data: {
groups: [{
groupUuid: toGroupId,
addUsers: userList
}],
inProgress: opts.inProgress
}
});
}
/*** merge audio ****/
async mergeAudioStream(userId, opts) {
const res = await this._client.fetch({
path: "/v1/rooms/".concat(opts.roomId, "/users/").concat(userId, "/call/merge"),
method: 'PUT',
data: {}
});
return res.data;
}
/*** split audio ****/
async splitAudioStream(userId, opts) {
const res = await this._client.fetch({
path: "/v1/rooms/".concat(opts.roomId, "/users/").concat(userId, "/call/split"),
method: 'PUT',
data: {}
});
return res.data;
}
/*** user control****/
async kickOut(userId, type, opts) {
const body = {};
if (type === _type2.FcrUserKickedOutType.Forever) {
body.duration = -1;
}
return this._client.fetch({
path: "/v1/rooms/".concat(opts.roomId, "/users/").concat(userId, "/ban/").concat(type === _type2.FcrUserKickedOutType.Forever ? 1 : 0),
method: 'PUT',
data: body
});
}
async kickOutByUserRoles(type, opts, userRoles) {
const body = {
toRoles: userRoles
};
if (type === _type2.FcrUserKickedOutType.Forever) {
body.duration = -1;
}
const {
data
} = await this._client.fetch({
path: "/v1/rooms/".concat(opts.roomId, "/users/ban/").concat(type === _type2.FcrUserKickedOutType.Forever ? 1 : 0),
method: 'PUT',
data: body
});
}
async kickOutByUserIds(userId, type, opts) {
const body = {
toUserUuids: userId
};
if (type === _type2.FcrUserKickedOutType.Forever) {
body.duration = -1;
}
const {
data
} = await this._client.fetch({
path: "/v1/rooms/".concat(opts.roomId, "/users/ban/").concat(type === _type2.FcrUserKickedOutType.Forever ? 1 : 0),
method: 'PUT',
data: body
});
}
/** room control **/
async startRoom(roomId) {
return this._client.fetch({
path: "/v1/rooms/".concat(roomId, "/states/1"),
method: 'PUT'
});
}
async endRoom(roomId) {
return this._client.fetch({
path: "/v1/rooms/".concat(roomId, "/states/2"),
method: 'PUT'
});
}
async closeRoom(roomId) {
return this._client.fetch({
path: "/v1/rooms/".concat(roomId, "/states/3"),
method: 'PUT'
});
}
async startCloudRecording(config, roomId) {
return this._client.fetch({
path: "/v1/rooms/".concat(roomId, "/records/states/1"),
method: 'PUT',
data: {
mode: 'web',
webRecordConfig: {
// rootUrl: config.url,
// audioProfile: config.audioProfile,
// videoBitrate: config.videoEncoderConfig.bitrate,
// videoWidth: config.videoEncoderConfig.dimensions.width,
// videoHeight: config.videoEncoderConfig.dimensions.height,
// videoFps: config.videoEncoderConfig.frameRate,
}
}
});
}
async pauseCloudRecording(roomId) {
return this._client.fetch({
path: "/v1/rooms/".concat(roomId, "/records/states/1"),
method: 'PATCH',
data: {
mode: 'web',
webRecordConfig: {
onhold: true
}
}
});
}
async resumeCloudRecording(roomId) {
return this._client.fetch({
path: "/v1/rooms/".concat(roomId, "/records/states/1"),
method: 'PATCH',
data: {
webRecordConfig: {
onhold: false
}
}
});
}
async stopCloudRecording(roomId) {
return this._client.fetch({
path: "/v1/rooms/".concat(roomId, "/records/states/0"),
method: 'PUT'
});
}
async setCloudRecordingReady(roomId) {
return this._client.fetch({
path: "/v1/rooms/".concat(roomId, "/records/ready"),
method: 'PUT'
});
}
// async entryRoom(params: EntryRequestParams): Promise<AgoraRteEntryRoomResponse> {
// this._observable.notifyObservers('beforeJoinRoom');
// const resp = await this._client.fetch({
// path: `/v2/rooms/${params.roomId}/users/${params.userId}/entry`,
// method: 'POST',
// data: params,
// retryFallbackDomainsWhenFail: true,
// });
// const statusCode = resp['__status'];
// const { code } = resp;
// this._observable.notifyObservers('afterJoinRoom', statusCode, code);
// return resp.data;
// }
/** room session */
async updateRoomSession(params) {
return this._client.fetch({
path: "/v1/users/".concat(params.userId, "/sessions/").concat(params.sessionKey, "/").concat(params.sessionId),
method: 'PUT',
data: {
target: 1,
targetUuids: [params.targetId],
targetRoles: params.targetRoles,
payload: params.payload,
duration: params.duration
}
});
}
async deleteRoomSession(params) {
return this._client.fetch({
path: "/v1/users/".concat(params.userId, "/sessions/").concat(params.sessionKey, "/").concat(params.sessionId),
method: 'DELETE',
data: {
target: params.target,
targetUuids: params.receiverIds,
action: params.action,
payload: params.payload
}
});
}
/** peer session */
async updatePeerSession(params) {
return this._client.fetch({
path: "/v1/users/".concat(params.userId, "/sessions/").concat(params.sessionKey, "/").concat(params.sessionId),
method: 'PUT',
data: {
target: 2,
targetUuids: [params.targetId],
payload: params.payload,
duration: params.duration
}
});
}
async deletePeerSession(params) {
return this._client.fetch({
path: "/v1/users/".concat(params.userId, "/sessions/").concat(params.sessionKey, "/").concat(params.sessionId),
method: 'DELETE',
data: {
target: 2,
targetUuids: params.receiverIds,
action: params.action,
payload: params.payload
}
});
}
async checkIn(params) {
const {
data,
ts
} = await this._client.fetch({
path: "/v1/rooms/".concat(params.roomId, "/users/").concat(params.userId, "/entry"),
method: 'PUT',
data: {
password: params.password,
stream: params.stream,
streams: params.streams,
platform: params.platform,
role: params.userRole,
userName: params.userName,
userProperties: params.userProperties,
version: params.version,
bypass: params.bypass,
avatar: params.avatar
},
retryFallbackDomainsWhenFail: true,
maxRetryTimes: 10
});
return {
data,
ts
};
}
async checkInInternal(params) {
const {
data,
ts
} = await this._client.fetch({
path: "/v1/rooms/".concat(params.roomId, "/users/").concat(params.userId, "/internal/entry"),
method: 'PUT',
data: {
password: params.password,
stream: params.stream,
streams: params.streams,
platform: params.platform,
role: params.userRole,
userName: params.userName,
userProperties: params.userProperties,
version: params.version,
ticket: params.ticket,
bypass: params.bypass
},
retryFallbackDomainsWhenFail: true,
maxRetryTimes: 10
});
return {
data,
ts
};
}
async updateUserName(params) {
const {
userName,
roomId,
userId
} = params;
const res = await this._client.fetch({
path: "/v1/rooms/".concat(roomId, "/users/").concat(userId, "/info"),
method: 'PATCH',
data: {
userName
}
});
return res.data;
}
async updateUserProperties(_ref) {
let {
roomId,
userUuid,
properties,
increments,
cause
} = _ref;
const data = {
properties,
cause,
increments
};
const res = await this._client.fetch({
path: "/v1/rooms/".concat(roomId, "/users/").concat(userUuid, "/properties"),
method: 'PUT',
data: data
});
return res.data;
}
async deleteUserProperties(_ref2) {
let {
roomId,
userUuid,
properties,
cause
} = _ref2;
const data = {
properties,
cause
};
const res = await this._client.fetch({
path: "/v1/rooms/".concat(roomId, "/users/").concat(userUuid, "/properties"),
method: 'DELETE',
data: {
users: data
}
});
return res.data;
}
async updateRoomProperties(_ref3) {
let {
roomId,
properties,
increments,
cause
} = _ref3;
const data = {
properties,
cause,
increments
};
const res = await this._client.fetch({
path: "/v1/rooms/".concat(roomId, "/properties"),
method: 'PUT',
data: data
});
return res.data;
}
async deleteRoomProperties(_ref4) {
let {
roomId,
properties,
cause
} = _ref4;
const data = {
properties,
cause
};
const res = await this._client.fetch({
path: "/v1/rooms/".concat(roomId, "/properties"),
method: 'DELETE',
data: data
});
return res.data;
}
async getChatRoomToken(roomId, userId) {
const res = await this._client.fetch({
path: "/v1/rooms/".concat(roomId, "/users/").concat(userId, "/widgets/easemobIM/token"),
method: 'GET'
});
return res.data;
}
async getUserToken(userId) {
const res = await this._client.fetch({
path: "/v1/users/".concat(userId, "/widgets/easemobIM/token"),
method: 'GET'
});
return res.data;
}
async enableLockedRoom(_ref5) {
let {
roomId,
enable,
targetRoles
} = _ref5;
const res = await this._client.fetch({
path: "/v1/rooms/".concat(roomId, "/lock/").concat(enable ? 1 : 0),
method: 'PUT',
data: {
targetRoles: targetRoles.map(role => _type.FcrPrivilegeUserRoleToStringMap[role])
}
});
return res.data;
}
async enablePassword(_ref6) {
let {
roomId,
enable,
password
} = _ref6;
const res = await this._client.fetch({
path: "/v1/rooms/".concat(roomId, "/password/").concat(enable ? 1 : 0),
method: 'PUT',
data: {
password
}
});
return res.data;
}
async enableWaitingRoom(_ref7) {
let {
roomId,
enable
} = _ref7;
const res = await this._client.fetch({
path: "/v1/rooms/".concat(roomId, "/waiting/").concat(enable ? 1 : 0),
method: 'PUT'
});
return res.data;
}
async moveToWaitingRoomByUserIds(userIds, roomId) {
const res = await this._client.fetch({
path: "/v1/rooms/".concat(roomId, "/waiting/users"),
method: 'PUT',
data: {
toUserUuids: userIds
}
});
return res.data;
}
async moveToWaitingRoomByUserRoles(toRoles, roomId) {
const res = await this._client.fetch({
path: "/v1/rooms/".concat(roomId, "/waiting/users"),
method: 'PUT',
data: {
toRoles
}
});
return res.data;
}
async moveToMainRoomByUserIds(userIds, roomId) {
const res = await this._client.fetch({
path: "/v1/rooms/".concat(roomId, "/waiting/users"),
method: 'DELETE',
data: {
toUserUuids: userIds
}
});
return res.data;
}
async moveToMainRoomByUserRoles(toRoles, roomId) {
const res = await this._client.fetch({
path: "/v1/rooms/".concat(roomId, "/waiting/users"),
method: 'DELETE',
data: {
toRoles
}
});
return res.data;
}
async allowSendChat(_ref8) {
let {
roomId,
enable,
targetRoles,
payload
} = _ref8;
const res = await this._client.fetch({
path: "/v1/rooms/".concat(roomId, "/security/chat/").concat(enable ? 1 : 0),
method: 'PUT',
data: {
targetRoles,
payload: {
public: (payload === null || payload === void 0 ? void 0 : payload.public) === undefined ? undefined : payload.public ? 1 : 0,
private: (payload === null || payload === void 0 ? void 0 : payload.private) === undefined ? undefined : {
host: payload.private.host ? 1 : 0,
cohost: payload.private.cohost ? 1 : 0,
participant: payload.private.participant ? 1 : 0
}
}
}
});
return res.data;
}
async allowChangeName(_ref9) {
let {
roomId,
enable,
targetRoles
} = _ref9;
const res = await this._client.fetch({
path: "/v1/rooms/".concat(roomId, "/security/changeName/").concat(enable ? 1 : 0),
method: 'PUT',
data: {
targetRoles
}
});
return res.data;
}
async allowStartAudio(_ref0) {
let {
roomId,
enable,
targetRoles
} = _ref0;
const res = await this._client.fetch({
path: "/v1/rooms/".concat(roomId, "/security/unmuteAudio/").concat(enable ? 1 : 0),
method: 'PUT',
data: {
targetRoles
}
});
return res.data;
}
async allowWatermark(params) {
const {
roomId,
enable,
targetRoles,
payload
} = params;
const res = await this._client.fetch({
path: "/v1/rooms/".concat(roomId, "/security/watermark/").concat(enable ? 1 : 0),
method: 'PUT',
data: {
targetRoles,
payload: _objectSpread({}, payload)
}
});
return res.data;
}
async allowChangeUserName(params) {
const {
roomId,
enable,
targetRoles
} = params;
const res = await this._client.fetch({
path: "/v1/rooms/".concat(roomId, "/security/changeName/").concat(enable ? 1 : 0),
method: 'PUT',
data: {
targetRoles
}
});
return res.data;
}
async allowJoinWithPromptSound(_ref1) {
let {
roomId,
enable,
targetRoles
} = _ref1;
const res = await this._client.fetch({
path: "/v1/rooms/".concat(roomId, "/security/joinWithPromptSound/").concat(enable ? 1 : 0),
method: 'PUT',
data: {
targetRoles
}
});
return res.data;
}
async allowStartVideo(_ref10) {
let {
roomId,
enable,
targetRoles
} = _ref10;
const res = await this._client.fetch({
path: "/v1/rooms/".concat(roomId, "/security/openVideo/").concat(enable ? 1 : 0),
method: 'PUT',
data: {
targetRoles
}
});
return res.data;
}
async allowJoinWithMuteAudio(_ref11) {
let {
roomId,
enable,
targetRoles
} = _ref11;
const res = await this._client.fetch({
path: "/v1/rooms/".concat(roomId, "/security/joinWithMuteAudio/").concat(enable ? 1 : 0),
method: 'PUT',
data: {
targetRoles
}
});
return res.data;
}
async allowJoinWithMutedVideo(_ref12) {
let {
roomId,
enable,
targetRoles
} = _ref12;
const res = await this._client.fetch({
path: "/v1/rooms/".concat(roomId, "/security/joinWithCloseVideo/").concat(enable ? 1 : 0),
method: 'PUT',
data: {
targetRoles
}
});
return res.data;
}
async updateUserRole(_ref13) {
let {
roomId,
localRole,
remoteRole,
userId
} = _ref13;
const res = await this._client.fetch({
path: "/v1/rooms/".concat(roomId, "/users/").concat(userId, "/role"),
method: 'PUT',
data: {
remoteRole,
localRole
}
});
return res.data;
}
async revokeUserRole(_ref14) {
let {
roomId,
remoteRole,
localRole,
userId
} = _ref14;
const res = await this._client.fetch({
path: "/v1/rooms/".concat(roomId, "/users/").concat(userId, "/role"),
method: 'DELETE',
data: {
remoteRole,
localRole
}
});
return res.data;
}
async claimHost(_ref15) {
let {
roomId,
userId,
hostKey
} = _ref15;
const res = await this._client.fetch({
path: "/v1/rooms/".concat(roomId, "/users/").concat(userId, "/claim/host"),
method: 'POST',
data: {
hostKey
}
});
return res.data;
}
async stopLiveStreaming(roomId) {
const res = await this._client.fetch({
path: "/v1/rooms/".concat(roomId, "/live/states/0"),
method: 'PUT'
});
return res;
}
async updateLiveStreamingLayout(roomId, layoutType) {
const res = await this._client.fetch({
path: "/v1/rooms/".concat(roomId, "/live/states/1"),
method: 'PATCH',
data: {
layoutType: layoutType
}
});
return res;
}
async startLiveStreaming(roomId, data) {
const res = await this._client.fetch({
path: "/v1/rooms/".concat(roomId, "/live/states/1"),
method: 'PUT',
data: {
streamUrl: data.pushStreamingUrl,
streamKey: data.pushStreamingKey,
pageUrl: data.pullStreamingUrl,
layoutType: data.layoutType
}
});
return res;
}
async callIp(_ref16) {
let {
roomId,
callType,
ipAddress
} = _ref16;
const res = await this._client.fetch({
path: "/v1/rooms/".concat(roomId, "/call/").concat(callType),
method: 'POST',
data: {
ipAddress
}
});
return res;
}
async callPstn(_ref17) {
let {
roomId,
userName,
userId,
callNumber
} = _ref17;
const res = await this._client.fetch({
path: "/v1/rooms/".concat(roomId, "/call/pstn"),
method: 'POST',
data: {
callNumber,
userName,
userUuid: userId
}
});
return res;
}
async hangup(_ref18) {
let {
roomId,
userId,
callId
} = _ref18;
const res = await this._client.fetch({
path: "/v1/rooms/".concat(roomId, "/users/").concat(userId, "/call/").concat(callId),
method: 'DELETE'
});
return res;
}
/**
* @description 获取白板信息
*/
async getWhiteboardToken(_ref19) {
let {
roomId,
userId
} = _ref19;
return this._client.fetch({
path: "/v1/rooms/".concat(roomId, "/users/").concat(userId, "/widgets/netlessBoard/token"),
method: 'GET'
});
}
/**
* @description 获取批注token
*/
async getAnnotationToken(_ref20) {
let {
roomId,
userId
} = _ref20;
return this._client.fetch({
path: "/v1/rooms/".concat(roomId, "/users/").concat(userId, "/widgets/annotation/token"),
method: 'GET'
});
}
/**
* @description 开启/关闭屏幕共享标注权限
*/
async toggleAnnotationActivityState(roomId, state) {
return this._client.fetch({
path: "/v1/rooms/".concat(roomId, "/widgets/annotation/states/").concat(state),
method: 'PUT'
});
}
/**
* @description 开启/关闭屏幕共享标注权限
*/
async syncScreenShareOwnerAnnotationOpenDone(roomId) {
return this._client.fetch({
path: "/v1/rooms/".concat(roomId, "/widgets/annotation/states/1"),
method: 'PUT',
retryFallbackDomainsWhenFail: true
});
}
/**
* @description 启用/禁用屏幕共享&白板
*/
async toggleShareEnable(params) {
const {
roomId,
enable,
targetRoles,
payload
} = params;
return this._client.fetch({
path: "/v1/rooms/".concat(roomId, "/security/sharing/").concat(enable ? 1 : 0),
method: 'PUT',
data: {
targetRoles,
payload: _objectSpread({}, payload)
}
});
}
/**
* @description 设置'启用/禁用屏幕共享&白板'的用户列表
*/
async toggleShareEnableByUserIds(params) {
const {
roomId,
enable,
toUserUuids,
payload
} = params;
return this._client.fetch({
path: "/v1/rooms/".concat(roomId, "/security/sharing/users/").concat(enable ? 1 : 0),
method: 'PUT',
data: {
toUserUuids,
payload: _objectSpread({}, payload)
}
});
}
/**
* @description 开启 / 关闭屏幕共享
*/
async toggleScreenShare(params) {
const {
roomId,
userId,
enable,
data
} = params;
return this._client.fetch({
path: "/v1/rooms/".concat(roomId, "/users/").concat(userId, "/streams/screen/states/").concat(enable ? 1 : 0),
method: 'PUT',
data
});
}
/**
* @description 开 / 关白板
*/
async toggleWhiteboardActivityState(roomId, state) {
return this._client.fetch({
path: "/v1/rooms/".concat(roomId, "/widgets/netlessBoard/states/").concat(state),
method: 'PUT'
});
}
/**
* @description 启用/禁用屏幕共享&白板
*/
async toggleAnnotation(params) {
const {
roomId,
enable,
payload,
targetRoles
} = params;
return this._client.fetch({
path: "/v1/rooms/".concat(roomId, "/security/annotation/", 1),
method: 'PUT',
data: {
targetRoles,
payload: _objectSpread({}, payload)
}
});
}
/**
* @description 修改白板背景
*/
async setBackgroundColor(params) {
const {
roomId,
backgroundColor
} = params;
return this._client.fetch({
path: "/v1/rooms/".concat(roomId, "/widgets/netlessBoard/info"),
method: 'PUT',
data: {
backgroundColor
}
});
}
async startShareScreen(params) {
const {
roomId,
userId,
config
} = params;
const res = this._client.fetch({
path: "/v1/rooms/".concat(roomId, "/users/").concat(userId, "/streams/screen/states/1"),
method: 'PUT',
data: config
});
return res;
}
async stopShareScreen(params) {
const {
roomId,
userId
} = params;
const res = this._client.fetch({
path: "/v1/rooms/".concat(roomId, "/users/").concat(userId, "/streams/screen/states/0"),
method: 'PUT'
});
return res;
}
async openInterpreter(params) {
const {
roomId,
data
} = params;
const res = this._client.fetch({
path: "/v1/rooms/".concat(roomId, "/interpreter/states/1"),
method: 'PUT',
data
});
return res;
}
async updateInterpreter(params) {
return this.openInterpreter(params);
}
async closeInterpreter(params) {
const {
roomId
} = params;
const res = this._client.fetch({
path: "/v1/rooms/".concat(roomId, "/interpreter/states/0"),
method: 'PUT',
data: {}
});
return res;
}
async createStreamBatch(roomUuid, streams) {
return await this._client.fetch({
path: "/v1/rooms/".concat(roomUuid, "/streams"),
method: 'POST',
data: {
streams
}
});
}
async updateStreamBatch(roomUuid, streams) {
return await this._client.fetch({
path: "/v1/rooms/".concat(roomUuid, "/streams"),
method: 'PUT',
data: {
streams
}
});
}
async updateStreamBatchByCondition(_ref21) {
let {
roomUuid,
videoState,
audioState,
includeRoles,
excludeRoles,
condition
} = _ref21;
return await this._client.fetch({
path: "/v1/rooms/".concat(roomUuid, "/conditions/streams"),
method: 'PUT',
data: {
includeRoles,
excludeRoles,
stream: {
videoState,
audioState
},
condition
}
});
}
async deleteStreamBatch(roomUuid, streams) {
return await this._client.fetch({
path: "/v1/rooms/".concat(roomUuid, "/streams"),
method: 'DELETE',
data: {
streams
}
});
}
async startCaption(params) {
const {
roomUuid,
userUuid,
config
} = params;
return await this._client.fetch({
path: "/v1/rooms/".concat(roomUuid, "/users/").concat(userUuid, "/widgets/stt/caption/states/1"),
method: 'PUT',
data: {
source: config.sourceLanguage,
target: config.targetLanguage ? [config.targetLanguage] : undefined
}
});
}
async stopCaption(params) {
const {
roomUuid,
userUuid
} = params;
return await this._client.fetch({
path: "/v1/rooms/".concat(roomUuid, "/users/").concat(userUuid, "/widgets/stt/caption/states/0"),
method: 'PUT'
});
}
async startTranscribing(params) {
const {
roomUuid,
userUuid,
config
} = params;
return await this._client.fetch({
path: "/v1/rooms/".concat(roomUuid, "/users/").concat(userUuid, "/widgets/stt/transcribe/states/1"),
method: 'PUT',
data: {
source: config.sourceLanguage,
target: config.targetLanguage ? [config.targetLanguage] : undefined
}
});
}
async stopTranscribing(params) {
const {
roomUuid,
userUuid
} = params;
return await this._client.fetch({
path: "/v1/rooms/".concat(roomUuid, "/users/").concat(userUuid, "/widgets/stt/transcribe/states/0"),
method: 'PUT'
});
}
async updateSourceLanguage(params) {
const {
roomUuid,
userUuid,
language
} = params;
return await this._client.fetch({
path: "/v1/rooms/".concat(roomUuid, "/users/").concat(userUuid, "/widgets/stt/language/speech"),
method: 'PATCH',
data: {
source: language
}
});
}
async subscribeTranscribingLanguage(params) {
const {
roomUuid,
userUuid,
language
} = params;
return await this._client.fetch({
path: "/v1/rooms/".concat(roomUuid, "/users/").concat(userUuid, "/widgets/stt/language/subscribe/1"),
method: 'PATCH',
data: {
target: [language]
}
});
}
async unsubscribeTranscribingLanguage(params) {
const {
roomUuid,
userUuid
} = params;
return await this._client.fetch({
path: "/v1/rooms/".concat(roomUuid, "/users/").concat(userUuid, "/widgets/stt/language/subscribe/0"),
method: 'PATCH'
});
}
async allowStartCaption(params) {
const {
roomUuid,
enable,
targetRoles
} = params;
return await this._client.fetch({
path: "/v1/rooms/".concat(roomUuid, "/security/caption/").concat(enable ? 1 : 0),
method: 'PUT',
data: {
targetRoles
}
});
}
async allowStartTranscribing(params) {
const {
roomUuid,
enable,
targetRoles
} = params;
return await this._client.fetch({
path: "/v1/rooms/".concat(roomUuid, "/security/transcribe/").concat(enable ? 1 : 0),
method: 'PUT',
data: {
targetRoles
}
});
}
async allowUpdateSttSourceLanguage(params) {
const {
roomUuid,
enable,
targetRoles
} = params;
return await this._client.fetch({
path: "/v1/rooms/".concat(roomUuid, "/security/stt/").concat(enable ? 1 : 0),
method: 'PUT',
data: {
targetRoles,
payload: {
modify: enable ? 1 : 0
}
}
});
}
}
exports.FcrCoreServiceApi = FcrCoreServiceApi;