livekit-server-sdk
Advanced tools
Comparing version 2.5.1 to 2.6.0
@@ -59,2 +59,12 @@ import type { DataPacket_Kind, RoomEgress, TrackInfo } from '@livekit/protocol'; | ||
}; | ||
export type UpdateParticipantOptions = { | ||
/** only attributes you'd want to update should be set, set value to empty string to remove it */ | ||
attributes?: { | ||
[key: string]: string; | ||
}; | ||
metadata?: string; | ||
/** permissions are updated atomically - all desired permissions would need to be set */ | ||
permission?: Partial<ParticipantPermission>; | ||
name?: string; | ||
}; | ||
/** | ||
@@ -67,5 +77,5 @@ * Client to access Room APIs | ||
* | ||
* @param host hostname including protocol. i.e. 'https://cluster.livekit.io' | ||
* @param apiKey API Key, can be set in env var LIVEKIT_API_KEY | ||
* @param secret API Secret, can be set in env var LIVEKIT_API_SECRET | ||
* @param host - hostname including protocol. i.e. 'https://cluster.livekit.io' | ||
* @param apiKey - API Key, can be set in env var LIVEKIT_API_KEY | ||
* @param secret - API Secret, can be set in env var LIVEKIT_API_SECRET | ||
*/ | ||
@@ -82,4 +92,4 @@ constructor(host: string, apiKey?: string, secret?: string); | ||
* List active rooms | ||
* @param names when undefined or empty, list all rooms. | ||
* otherwise returns rooms with matching names | ||
* @param names - when undefined or empty, list all rooms. | ||
* otherwise returns rooms with matching names | ||
* @returns | ||
@@ -124,9 +134,14 @@ */ | ||
/** | ||
* Updates a participant's metadata or permissions | ||
* @param room | ||
* @param identity | ||
* @param metadata optional, metadata to update | ||
* @param permission optional, new permissions to assign to participant | ||
* @param name optional, new name for participant | ||
* Updates a participant's state or permissions | ||
* @param room - target room | ||
* @param identity - participant identity | ||
* @param options - participant fields to update | ||
*/ | ||
updateParticipant(room: string, identity: string, options: UpdateParticipantOptions): Promise<ParticipantInfo>; | ||
/** | ||
* Updates a participant's state or permissions | ||
* @param room - target room | ||
* @param identity - participant identity | ||
* @param options - participant fields to update | ||
*/ | ||
updateParticipant(room: string, identity: string, metadata?: string, permission?: Partial<ParticipantPermission>, name?: string): Promise<ParticipantInfo>; | ||
@@ -133,0 +148,0 @@ /** |
@@ -11,5 +11,5 @@ import { CreateRoomRequest, DeleteRoomRequest, ListParticipantsRequest, ListParticipantsResponse, ListRoomsRequest, ListRoomsResponse, MuteRoomTrackRequest, MuteRoomTrackResponse, ParticipantInfo, ParticipantPermission, Room, RoomParticipantIdentity, SendDataRequest, UpdateParticipantRequest, UpdateRoomMetadataRequest, UpdateSubscriptionsRequest, } from '@livekit/protocol'; | ||
* | ||
* @param host hostname including protocol. i.e. 'https://cluster.livekit.io' | ||
* @param apiKey API Key, can be set in env var LIVEKIT_API_KEY | ||
* @param secret API Secret, can be set in env var LIVEKIT_API_SECRET | ||
* @param host - hostname including protocol. i.e. 'https://cluster.livekit.io' | ||
* @param apiKey - API Key, can be set in env var LIVEKIT_API_KEY | ||
* @param secret - API Secret, can be set in env var LIVEKIT_API_SECRET | ||
*/ | ||
@@ -32,4 +32,4 @@ constructor(host, apiKey, secret) { | ||
* List active rooms | ||
* @param names when undefined or empty, list all rooms. | ||
* otherwise returns rooms with matching names | ||
* @param names - when undefined or empty, list all rooms. | ||
* otherwise returns rooms with matching names | ||
* @returns | ||
@@ -103,16 +103,16 @@ */ | ||
} | ||
/** | ||
* Updates a participant's metadata or permissions | ||
* @param room | ||
* @param identity | ||
* @param metadata optional, metadata to update | ||
* @param permission optional, new permissions to assign to participant | ||
* @param name optional, new name for participant | ||
*/ | ||
async updateParticipant(room, identity, metadata, permission, name) { | ||
async updateParticipant(room, identity, metadataOrOptions, maybePermission, maybeName) { | ||
const hasOptions = typeof metadataOrOptions === 'object'; | ||
const metadata = hasOptions ? metadataOrOptions === null || metadataOrOptions === void 0 ? void 0 : metadataOrOptions.metadata : metadataOrOptions; | ||
const permission = hasOptions ? metadataOrOptions.permission : maybePermission; | ||
const name = hasOptions ? metadataOrOptions.name : maybeName; | ||
const attributes = hasOptions | ||
? metadataOrOptions.attributes | ||
: {}; | ||
const req = new UpdateParticipantRequest({ | ||
room, | ||
identity, | ||
metadata: metadata || '', | ||
name: name || '', | ||
attributes, | ||
metadata, | ||
name, | ||
}); | ||
@@ -119,0 +119,0 @@ if (permission) { |
{ | ||
"name": "livekit-server-sdk", | ||
"version": "2.5.1", | ||
"version": "2.6.0", | ||
"description": "Server-side SDK for LiveKit", | ||
@@ -28,6 +28,6 @@ "main": "dist/index.js", | ||
"prettier": "^3.0.0", | ||
"typedoc": "^0.25.13", | ||
"typescript": "5.4.x", | ||
"typedoc": "^0.26.0", | ||
"typescript": "5.5.x", | ||
"vite": "^5.2.9", | ||
"vitest": "^1.5.0" | ||
"vitest": "^2.0.0" | ||
}, | ||
@@ -34,0 +34,0 @@ "engines": { |
@@ -93,2 +93,11 @@ // SPDX-FileCopyrightText: 2024 LiveKit, Inc. | ||
export type UpdateParticipantOptions = { | ||
/** only attributes you'd want to update should be set, set value to empty string to remove it */ | ||
attributes?: { [key: string]: string }; | ||
metadata?: string; | ||
/** permissions are updated atomically - all desired permissions would need to be set */ | ||
permission?: Partial<ParticipantPermission>; | ||
name?: string; | ||
}; | ||
const svc = 'RoomService'; | ||
@@ -104,5 +113,5 @@ | ||
* | ||
* @param host hostname including protocol. i.e. 'https://cluster.livekit.io' | ||
* @param apiKey API Key, can be set in env var LIVEKIT_API_KEY | ||
* @param secret API Secret, can be set in env var LIVEKIT_API_SECRET | ||
* @param host - hostname including protocol. i.e. 'https://cluster.livekit.io' | ||
* @param apiKey - API Key, can be set in env var LIVEKIT_API_KEY | ||
* @param secret - API Secret, can be set in env var LIVEKIT_API_SECRET | ||
*/ | ||
@@ -132,4 +141,4 @@ constructor(host: string, apiKey?: string, secret?: string) { | ||
* List active rooms | ||
* @param names when undefined or empty, list all rooms. | ||
* otherwise returns rooms with matching names | ||
* @param names - when undefined or empty, list all rooms. | ||
* otherwise returns rooms with matching names | ||
* @returns | ||
@@ -250,8 +259,6 @@ */ | ||
/** | ||
* Updates a participant's metadata or permissions | ||
* @param room | ||
* @param identity | ||
* @param metadata optional, metadata to update | ||
* @param permission optional, new permissions to assign to participant | ||
* @param name optional, new name for participant | ||
* Updates a participant's state or permissions | ||
* @param room - target room | ||
* @param identity - participant identity | ||
* @param options - participant fields to update | ||
*/ | ||
@@ -261,11 +268,38 @@ async updateParticipant( | ||
identity: string, | ||
options: UpdateParticipantOptions, | ||
): Promise<ParticipantInfo>; | ||
/** | ||
* Updates a participant's state or permissions | ||
* @param room - target room | ||
* @param identity - participant identity | ||
* @param options - participant fields to update | ||
*/ | ||
async updateParticipant( | ||
room: string, | ||
identity: string, | ||
metadata?: string, | ||
permission?: Partial<ParticipantPermission>, | ||
name?: string, | ||
): Promise<ParticipantInfo>; | ||
async updateParticipant( | ||
room: string, | ||
identity: string, | ||
metadataOrOptions?: string | UpdateParticipantOptions, | ||
maybePermission?: Partial<ParticipantPermission>, | ||
maybeName?: string, | ||
): Promise<ParticipantInfo> { | ||
const hasOptions = typeof metadataOrOptions === 'object'; | ||
const metadata = hasOptions ? metadataOrOptions?.metadata : metadataOrOptions; | ||
const permission = hasOptions ? metadataOrOptions.permission : maybePermission; | ||
const name = hasOptions ? metadataOrOptions.name : maybeName; | ||
const attributes: Record<string, string> | undefined = hasOptions | ||
? metadataOrOptions.attributes | ||
: {}; | ||
const req = new UpdateParticipantRequest({ | ||
room, | ||
identity, | ||
metadata: metadata || '', | ||
name: name || '', | ||
attributes, | ||
metadata, | ||
name, | ||
}); | ||
@@ -272,0 +306,0 @@ if (permission) { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
209503
4032