@poolse/sdk 2.23.0 → 2.25.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/index.cjs +67 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +65 -4
- package/dist/index.d.ts +65 -4
- package/dist/index.js +67 -6
- package/dist/index.js.map +1 -1
- package/package.json +10 -10
package/dist/index.d.cts
CHANGED
|
@@ -866,6 +866,13 @@ interface RequestOptions {
|
|
|
866
866
|
maxRetries?: number;
|
|
867
867
|
/** AbortSignal for caller-driven cancellation. */
|
|
868
868
|
signal?: AbortSignal;
|
|
869
|
+
/**
|
|
870
|
+
* Authorize with this token instead of the user's session — for the
|
|
871
|
+
* endpoints a call-scoped token authorizes (a call's control token).
|
|
872
|
+
* A 401 then surfaces at once: refreshing the session cannot fix a
|
|
873
|
+
* token the caller supplied.
|
|
874
|
+
*/
|
|
875
|
+
bearer?: string;
|
|
869
876
|
}
|
|
870
877
|
declare class RestClient {
|
|
871
878
|
private readonly config;
|
|
@@ -893,13 +900,18 @@ interface LiveCall {
|
|
|
893
900
|
conversation_id: string;
|
|
894
901
|
conversation_name: string | null;
|
|
895
902
|
media: 'audio' | 'video';
|
|
903
|
+
/** `room` rang nobody (a drop-in meeting); `call` rang the members. Absent on older servers: call. */
|
|
904
|
+
kind?: 'call' | 'room';
|
|
896
905
|
state: 'live' | 'finished';
|
|
897
906
|
started_by: LiveCallMember;
|
|
898
907
|
started_at: string | null;
|
|
899
908
|
ended_at: string | null;
|
|
900
909
|
participants: LiveCallMember[];
|
|
901
|
-
/**
|
|
902
|
-
|
|
910
|
+
/**
|
|
911
|
+
* Callee user id → `ringing` (their ring is out right now) | `answered`
|
|
912
|
+
* | `declined` | `missed` (rang out unanswered).
|
|
913
|
+
*/
|
|
914
|
+
ring_states: Record<string, 'ringing' | 'answered' | 'declined' | 'missed'>;
|
|
903
915
|
}
|
|
904
916
|
/**
|
|
905
917
|
* `/v1/conversations/:id/call` — whether a call is running on a
|
|
@@ -1831,6 +1843,51 @@ declare class CallTokensResource {
|
|
|
1831
1843
|
create(conversationId: string, signal?: AbortSignal): Promise<CallConnection | null>;
|
|
1832
1844
|
}
|
|
1833
1845
|
|
|
1846
|
+
/** What starting or joining a room returns (the call contract's session bundle). */
|
|
1847
|
+
interface RoomSession {
|
|
1848
|
+
cv: number;
|
|
1849
|
+
/** True when this request started the room; false when it joined one already live. */
|
|
1850
|
+
created: boolean;
|
|
1851
|
+
/** The live room — or call: a ringing call already live there is joined instead. */
|
|
1852
|
+
call: LiveCall;
|
|
1853
|
+
/** SFU credentials for this participant. */
|
|
1854
|
+
livekit: {
|
|
1855
|
+
url: string;
|
|
1856
|
+
token: string;
|
|
1857
|
+
};
|
|
1858
|
+
/** Authorizes leaving (`leave`); scoped to this call. */
|
|
1859
|
+
control_token: string;
|
|
1860
|
+
}
|
|
1861
|
+
/**
|
|
1862
|
+
* A conversation's room — the Meet-style way to talk: anyone in the
|
|
1863
|
+
* conversation drops in for voice or video while the chat carries on,
|
|
1864
|
+
* and nobody's phone rings. One room per conversation; starting one
|
|
1865
|
+
* while it is live (or while a call is) joins that instead.
|
|
1866
|
+
*
|
|
1867
|
+
* Members see it the same way as a call — `liveCalls.get`, the
|
|
1868
|
+
* `call:started` / `call:participants` / `call:finished` events, a Join
|
|
1869
|
+
* banner — and phones join it like any call. It ends once it has been
|
|
1870
|
+
* empty for a short grace, and leaves one line in the chat history.
|
|
1871
|
+
*/
|
|
1872
|
+
declare class RoomsResource {
|
|
1873
|
+
private readonly client;
|
|
1874
|
+
constructor(client: RestClient);
|
|
1875
|
+
/** POST /v1/conversations/:id/room — start the room, or join what is live. */
|
|
1876
|
+
start(conversationId: string, media?: 'audio' | 'video', signal?: AbortSignal): Promise<RoomSession>;
|
|
1877
|
+
/**
|
|
1878
|
+
* POST /v1/conversations/:id/calls — like `start`, but RINGS the other
|
|
1879
|
+
* members' phones (a support desk calling a customer). Off by default
|
|
1880
|
+
* in the room UI; an app opts in. Joins whatever is live instead, the
|
|
1881
|
+
* same as `start`.
|
|
1882
|
+
*/
|
|
1883
|
+
ring(conversationId: string, media?: 'audio' | 'video', signal?: AbortSignal): Promise<RoomSession>;
|
|
1884
|
+
/**
|
|
1885
|
+
* POST /v1/calls/:id/hangup — leave. Never ends the room for the others;
|
|
1886
|
+
* it ends once empty. Authorized by the session's control token.
|
|
1887
|
+
*/
|
|
1888
|
+
leave(session: Pick<RoomSession, 'call' | 'control_token'>): Promise<void>;
|
|
1889
|
+
}
|
|
1890
|
+
|
|
1834
1891
|
type Unsubscribe = () => void;
|
|
1835
1892
|
declare class CallRoom {
|
|
1836
1893
|
private readonly livekit;
|
|
@@ -2060,6 +2117,8 @@ declare class Poolse {
|
|
|
2060
2117
|
readonly callTokens: CallTokensResource;
|
|
2061
2118
|
/** Whether a call is running on a conversation — for a Join banner. */
|
|
2062
2119
|
readonly liveCalls: LiveCallsResource;
|
|
2120
|
+
/** A conversation's drop-in room: voice or video, nobody rung. */
|
|
2121
|
+
readonly rooms: RoomsResource;
|
|
2063
2122
|
private readonly resolved;
|
|
2064
2123
|
private readonly tokenCache;
|
|
2065
2124
|
constructor(config: PoolseConfig);
|
|
@@ -2141,7 +2200,7 @@ declare class AuthError extends ApiError {
|
|
|
2141
2200
|
declare function isWebRtcAvailable(): boolean;
|
|
2142
2201
|
declare function createBrowserWebRtcAdapter(): WebRtcAdapter;
|
|
2143
2202
|
|
|
2144
|
-
declare const version = "2.
|
|
2203
|
+
declare const version = "2.24.0";
|
|
2145
2204
|
|
|
2146
2205
|
type CallLogMedia = 'audio' | 'video';
|
|
2147
2206
|
/** What became of one person a call involved (the caller excluded). */
|
|
@@ -2158,6 +2217,8 @@ interface CallLogEntry {
|
|
|
2158
2217
|
joinedUserIds: Uuid[];
|
|
2159
2218
|
/** `2` for the one-record-per-call shape; `1` for older history. */
|
|
2160
2219
|
version: 1 | 2;
|
|
2220
|
+
/** `room`: a drop-in meeting that rang nobody; `call`: rang the members. */
|
|
2221
|
+
callKind: 'call' | 'room';
|
|
2161
2222
|
/** Who placed the call. `null` on v1 records. */
|
|
2162
2223
|
callerUserId: Uuid | null;
|
|
2163
2224
|
/** Everyone else the call involved, with their outcome. Empty on v1. */
|
|
@@ -2251,4 +2312,4 @@ declare function formatCallLogPreview(preview: string | null | undefined, curren
|
|
|
2251
2312
|
|
|
2252
2313
|
declare function safeUuid(): string;
|
|
2253
2314
|
|
|
2254
|
-
export { type AddMemberOptions, ApiError, type Attachment, type AttachmentDownloadResponse, AttachmentHandle, type AttachmentOptions, type AttachmentProgressEvent, type AttachmentStatus, type AttachmentUploadInput, type AttachmentUploadRequest, type AttachmentUploadResponse, AttachmentsResource, AuthError, type CallAccepted, type CallBusy, type CallCancelled, type CallConnection, type CallDeclined, type CallDevice, type CallDeviceKind, type CallEndReason, type CallEnded, type CallFinishedEvent, type CallLog, type CallLogDisplay, type CallLogEntry, type CallLogMedia, type CallMedia, type CallMissedEntry, type CallParticipant, type CallParticipantStatus, type CallParticipantsEvent, CallRoom, type CallRoomOptions, type CallRoomStatus, type CallStartedEvent, CallTokensResource, CallsResource, type CameraFacing, type CheckedLiveKitModule, type Conversation, ConversationChannel, type ConversationCreateRequest, type ConversationCreatedEvent, ConversationHandle, type ConversationList, ConversationMessages, type ConversationType, type ConversationUpdateRequest, type ConversationUpdatedEvent, ConversationsResource, type Device, type DeviceEnvironment, type DeviceKind, type DevicePlatform, DevicesResource, type ErrorEnvelope, type IceServerResponse, IceServersResource, type IncomingCall, type IsoDateTime, type LiveCall, type LiveCallMember, LiveCallsResource, type LiveKitLocalVideoTrack, type LiveKitModule, type LiveKitParticipant, type LiveKitPublication, type LiveKitRoomHandle, type LiveKitTrack, type LiveKitTrackReference, type Me, MeResource, type MemberReadEvent, type MemberRole, type Membership, type MembershipCreateRequest, type MembershipList, type MentionEvent, type Message, type MessageCreateRequest, type MessageDeletedEvent, MessageHandle, type MessageList, type MessageNewEvent, type MessageType, type MessageUpdateRequest, type MessageUpdatedEvent, MessagesResource, NetworkError, type OutgoingCall, POOLSE_API_URL, Poolse, type PoolseConfig, PoolseError, PoolseRealtime, type PoolseUserProfile, type PresenceSnapshot, type QuotedMessagePreview, RateLimitedError, type ReactionEvent, type ReactionRequest, type ReadReceiptsState, type ReadRequest, type RealtimeStatus, type RegisterDeviceRequest, type TypingEvent, type Unsubscribe$1 as Unsubscribe, type UpdateMeRequest, UserChannel, UsersResource, type Uuid, type VoiceCandidate, type VoiceDescription, type VoiceIceServer, type VoiceParticipant, type VoicePeerConnection, VoiceRoom, type VoiceRoomOptions, type VoiceStatus, type VoiceStream, type VoiceTrack, type WebRtcAdapter, callLogDisplayFor, createBrowserWebRtcAdapter, describeCallLog, formatCallDuration, formatCallLogPreview, isCallLogMessage, isMessageVisibleTo, isWebRtcAvailable, parseCallLog, parseCallLogBody, safeUuid, version };
|
|
2315
|
+
export { type AddMemberOptions, ApiError, type Attachment, type AttachmentDownloadResponse, AttachmentHandle, type AttachmentOptions, type AttachmentProgressEvent, type AttachmentStatus, type AttachmentUploadInput, type AttachmentUploadRequest, type AttachmentUploadResponse, AttachmentsResource, AuthError, type CallAccepted, type CallBusy, type CallCancelled, type CallConnection, type CallDeclined, type CallDevice, type CallDeviceKind, type CallEndReason, type CallEnded, type CallFinishedEvent, type CallLog, type CallLogDisplay, type CallLogEntry, type CallLogMedia, type CallMedia, type CallMissedEntry, type CallParticipant, type CallParticipantStatus, type CallParticipantsEvent, CallRoom, type CallRoomOptions, type CallRoomStatus, type CallStartedEvent, CallTokensResource, CallsResource, type CameraFacing, type CheckedLiveKitModule, type Conversation, ConversationChannel, type ConversationCreateRequest, type ConversationCreatedEvent, ConversationHandle, type ConversationList, ConversationMessages, type ConversationType, type ConversationUpdateRequest, type ConversationUpdatedEvent, ConversationsResource, type Device, type DeviceEnvironment, type DeviceKind, type DevicePlatform, DevicesResource, type ErrorEnvelope, type IceServerResponse, IceServersResource, type IncomingCall, type IsoDateTime, type LiveCall, type LiveCallMember, LiveCallsResource, type LiveKitLocalVideoTrack, type LiveKitModule, type LiveKitParticipant, type LiveKitPublication, type LiveKitRoomHandle, type LiveKitTrack, type LiveKitTrackReference, type Me, MeResource, type MemberReadEvent, type MemberRole, type Membership, type MembershipCreateRequest, type MembershipList, type MentionEvent, type Message, type MessageCreateRequest, type MessageDeletedEvent, MessageHandle, type MessageList, type MessageNewEvent, type MessageType, type MessageUpdateRequest, type MessageUpdatedEvent, MessagesResource, NetworkError, type OutgoingCall, POOLSE_API_URL, Poolse, type PoolseConfig, PoolseError, PoolseRealtime, type PoolseUserProfile, type PresenceSnapshot, type QuotedMessagePreview, RateLimitedError, type ReactionEvent, type ReactionRequest, type ReadReceiptsState, type ReadRequest, type RealtimeStatus, type RegisterDeviceRequest, type RoomSession, RoomsResource, type TypingEvent, type Unsubscribe$1 as Unsubscribe, type UpdateMeRequest, UserChannel, UsersResource, type Uuid, type VoiceCandidate, type VoiceDescription, type VoiceIceServer, type VoiceParticipant, type VoicePeerConnection, VoiceRoom, type VoiceRoomOptions, type VoiceStatus, type VoiceStream, type VoiceTrack, type WebRtcAdapter, callLogDisplayFor, createBrowserWebRtcAdapter, describeCallLog, formatCallDuration, formatCallLogPreview, isCallLogMessage, isMessageVisibleTo, isWebRtcAvailable, parseCallLog, parseCallLogBody, safeUuid, version };
|
package/dist/index.d.ts
CHANGED
|
@@ -866,6 +866,13 @@ interface RequestOptions {
|
|
|
866
866
|
maxRetries?: number;
|
|
867
867
|
/** AbortSignal for caller-driven cancellation. */
|
|
868
868
|
signal?: AbortSignal;
|
|
869
|
+
/**
|
|
870
|
+
* Authorize with this token instead of the user's session — for the
|
|
871
|
+
* endpoints a call-scoped token authorizes (a call's control token).
|
|
872
|
+
* A 401 then surfaces at once: refreshing the session cannot fix a
|
|
873
|
+
* token the caller supplied.
|
|
874
|
+
*/
|
|
875
|
+
bearer?: string;
|
|
869
876
|
}
|
|
870
877
|
declare class RestClient {
|
|
871
878
|
private readonly config;
|
|
@@ -893,13 +900,18 @@ interface LiveCall {
|
|
|
893
900
|
conversation_id: string;
|
|
894
901
|
conversation_name: string | null;
|
|
895
902
|
media: 'audio' | 'video';
|
|
903
|
+
/** `room` rang nobody (a drop-in meeting); `call` rang the members. Absent on older servers: call. */
|
|
904
|
+
kind?: 'call' | 'room';
|
|
896
905
|
state: 'live' | 'finished';
|
|
897
906
|
started_by: LiveCallMember;
|
|
898
907
|
started_at: string | null;
|
|
899
908
|
ended_at: string | null;
|
|
900
909
|
participants: LiveCallMember[];
|
|
901
|
-
/**
|
|
902
|
-
|
|
910
|
+
/**
|
|
911
|
+
* Callee user id → `ringing` (their ring is out right now) | `answered`
|
|
912
|
+
* | `declined` | `missed` (rang out unanswered).
|
|
913
|
+
*/
|
|
914
|
+
ring_states: Record<string, 'ringing' | 'answered' | 'declined' | 'missed'>;
|
|
903
915
|
}
|
|
904
916
|
/**
|
|
905
917
|
* `/v1/conversations/:id/call` — whether a call is running on a
|
|
@@ -1831,6 +1843,51 @@ declare class CallTokensResource {
|
|
|
1831
1843
|
create(conversationId: string, signal?: AbortSignal): Promise<CallConnection | null>;
|
|
1832
1844
|
}
|
|
1833
1845
|
|
|
1846
|
+
/** What starting or joining a room returns (the call contract's session bundle). */
|
|
1847
|
+
interface RoomSession {
|
|
1848
|
+
cv: number;
|
|
1849
|
+
/** True when this request started the room; false when it joined one already live. */
|
|
1850
|
+
created: boolean;
|
|
1851
|
+
/** The live room — or call: a ringing call already live there is joined instead. */
|
|
1852
|
+
call: LiveCall;
|
|
1853
|
+
/** SFU credentials for this participant. */
|
|
1854
|
+
livekit: {
|
|
1855
|
+
url: string;
|
|
1856
|
+
token: string;
|
|
1857
|
+
};
|
|
1858
|
+
/** Authorizes leaving (`leave`); scoped to this call. */
|
|
1859
|
+
control_token: string;
|
|
1860
|
+
}
|
|
1861
|
+
/**
|
|
1862
|
+
* A conversation's room — the Meet-style way to talk: anyone in the
|
|
1863
|
+
* conversation drops in for voice or video while the chat carries on,
|
|
1864
|
+
* and nobody's phone rings. One room per conversation; starting one
|
|
1865
|
+
* while it is live (or while a call is) joins that instead.
|
|
1866
|
+
*
|
|
1867
|
+
* Members see it the same way as a call — `liveCalls.get`, the
|
|
1868
|
+
* `call:started` / `call:participants` / `call:finished` events, a Join
|
|
1869
|
+
* banner — and phones join it like any call. It ends once it has been
|
|
1870
|
+
* empty for a short grace, and leaves one line in the chat history.
|
|
1871
|
+
*/
|
|
1872
|
+
declare class RoomsResource {
|
|
1873
|
+
private readonly client;
|
|
1874
|
+
constructor(client: RestClient);
|
|
1875
|
+
/** POST /v1/conversations/:id/room — start the room, or join what is live. */
|
|
1876
|
+
start(conversationId: string, media?: 'audio' | 'video', signal?: AbortSignal): Promise<RoomSession>;
|
|
1877
|
+
/**
|
|
1878
|
+
* POST /v1/conversations/:id/calls — like `start`, but RINGS the other
|
|
1879
|
+
* members' phones (a support desk calling a customer). Off by default
|
|
1880
|
+
* in the room UI; an app opts in. Joins whatever is live instead, the
|
|
1881
|
+
* same as `start`.
|
|
1882
|
+
*/
|
|
1883
|
+
ring(conversationId: string, media?: 'audio' | 'video', signal?: AbortSignal): Promise<RoomSession>;
|
|
1884
|
+
/**
|
|
1885
|
+
* POST /v1/calls/:id/hangup — leave. Never ends the room for the others;
|
|
1886
|
+
* it ends once empty. Authorized by the session's control token.
|
|
1887
|
+
*/
|
|
1888
|
+
leave(session: Pick<RoomSession, 'call' | 'control_token'>): Promise<void>;
|
|
1889
|
+
}
|
|
1890
|
+
|
|
1834
1891
|
type Unsubscribe = () => void;
|
|
1835
1892
|
declare class CallRoom {
|
|
1836
1893
|
private readonly livekit;
|
|
@@ -2060,6 +2117,8 @@ declare class Poolse {
|
|
|
2060
2117
|
readonly callTokens: CallTokensResource;
|
|
2061
2118
|
/** Whether a call is running on a conversation — for a Join banner. */
|
|
2062
2119
|
readonly liveCalls: LiveCallsResource;
|
|
2120
|
+
/** A conversation's drop-in room: voice or video, nobody rung. */
|
|
2121
|
+
readonly rooms: RoomsResource;
|
|
2063
2122
|
private readonly resolved;
|
|
2064
2123
|
private readonly tokenCache;
|
|
2065
2124
|
constructor(config: PoolseConfig);
|
|
@@ -2141,7 +2200,7 @@ declare class AuthError extends ApiError {
|
|
|
2141
2200
|
declare function isWebRtcAvailable(): boolean;
|
|
2142
2201
|
declare function createBrowserWebRtcAdapter(): WebRtcAdapter;
|
|
2143
2202
|
|
|
2144
|
-
declare const version = "2.
|
|
2203
|
+
declare const version = "2.24.0";
|
|
2145
2204
|
|
|
2146
2205
|
type CallLogMedia = 'audio' | 'video';
|
|
2147
2206
|
/** What became of one person a call involved (the caller excluded). */
|
|
@@ -2158,6 +2217,8 @@ interface CallLogEntry {
|
|
|
2158
2217
|
joinedUserIds: Uuid[];
|
|
2159
2218
|
/** `2` for the one-record-per-call shape; `1` for older history. */
|
|
2160
2219
|
version: 1 | 2;
|
|
2220
|
+
/** `room`: a drop-in meeting that rang nobody; `call`: rang the members. */
|
|
2221
|
+
callKind: 'call' | 'room';
|
|
2161
2222
|
/** Who placed the call. `null` on v1 records. */
|
|
2162
2223
|
callerUserId: Uuid | null;
|
|
2163
2224
|
/** Everyone else the call involved, with their outcome. Empty on v1. */
|
|
@@ -2251,4 +2312,4 @@ declare function formatCallLogPreview(preview: string | null | undefined, curren
|
|
|
2251
2312
|
|
|
2252
2313
|
declare function safeUuid(): string;
|
|
2253
2314
|
|
|
2254
|
-
export { type AddMemberOptions, ApiError, type Attachment, type AttachmentDownloadResponse, AttachmentHandle, type AttachmentOptions, type AttachmentProgressEvent, type AttachmentStatus, type AttachmentUploadInput, type AttachmentUploadRequest, type AttachmentUploadResponse, AttachmentsResource, AuthError, type CallAccepted, type CallBusy, type CallCancelled, type CallConnection, type CallDeclined, type CallDevice, type CallDeviceKind, type CallEndReason, type CallEnded, type CallFinishedEvent, type CallLog, type CallLogDisplay, type CallLogEntry, type CallLogMedia, type CallMedia, type CallMissedEntry, type CallParticipant, type CallParticipantStatus, type CallParticipantsEvent, CallRoom, type CallRoomOptions, type CallRoomStatus, type CallStartedEvent, CallTokensResource, CallsResource, type CameraFacing, type CheckedLiveKitModule, type Conversation, ConversationChannel, type ConversationCreateRequest, type ConversationCreatedEvent, ConversationHandle, type ConversationList, ConversationMessages, type ConversationType, type ConversationUpdateRequest, type ConversationUpdatedEvent, ConversationsResource, type Device, type DeviceEnvironment, type DeviceKind, type DevicePlatform, DevicesResource, type ErrorEnvelope, type IceServerResponse, IceServersResource, type IncomingCall, type IsoDateTime, type LiveCall, type LiveCallMember, LiveCallsResource, type LiveKitLocalVideoTrack, type LiveKitModule, type LiveKitParticipant, type LiveKitPublication, type LiveKitRoomHandle, type LiveKitTrack, type LiveKitTrackReference, type Me, MeResource, type MemberReadEvent, type MemberRole, type Membership, type MembershipCreateRequest, type MembershipList, type MentionEvent, type Message, type MessageCreateRequest, type MessageDeletedEvent, MessageHandle, type MessageList, type MessageNewEvent, type MessageType, type MessageUpdateRequest, type MessageUpdatedEvent, MessagesResource, NetworkError, type OutgoingCall, POOLSE_API_URL, Poolse, type PoolseConfig, PoolseError, PoolseRealtime, type PoolseUserProfile, type PresenceSnapshot, type QuotedMessagePreview, RateLimitedError, type ReactionEvent, type ReactionRequest, type ReadReceiptsState, type ReadRequest, type RealtimeStatus, type RegisterDeviceRequest, type TypingEvent, type Unsubscribe$1 as Unsubscribe, type UpdateMeRequest, UserChannel, UsersResource, type Uuid, type VoiceCandidate, type VoiceDescription, type VoiceIceServer, type VoiceParticipant, type VoicePeerConnection, VoiceRoom, type VoiceRoomOptions, type VoiceStatus, type VoiceStream, type VoiceTrack, type WebRtcAdapter, callLogDisplayFor, createBrowserWebRtcAdapter, describeCallLog, formatCallDuration, formatCallLogPreview, isCallLogMessage, isMessageVisibleTo, isWebRtcAvailable, parseCallLog, parseCallLogBody, safeUuid, version };
|
|
2315
|
+
export { type AddMemberOptions, ApiError, type Attachment, type AttachmentDownloadResponse, AttachmentHandle, type AttachmentOptions, type AttachmentProgressEvent, type AttachmentStatus, type AttachmentUploadInput, type AttachmentUploadRequest, type AttachmentUploadResponse, AttachmentsResource, AuthError, type CallAccepted, type CallBusy, type CallCancelled, type CallConnection, type CallDeclined, type CallDevice, type CallDeviceKind, type CallEndReason, type CallEnded, type CallFinishedEvent, type CallLog, type CallLogDisplay, type CallLogEntry, type CallLogMedia, type CallMedia, type CallMissedEntry, type CallParticipant, type CallParticipantStatus, type CallParticipantsEvent, CallRoom, type CallRoomOptions, type CallRoomStatus, type CallStartedEvent, CallTokensResource, CallsResource, type CameraFacing, type CheckedLiveKitModule, type Conversation, ConversationChannel, type ConversationCreateRequest, type ConversationCreatedEvent, ConversationHandle, type ConversationList, ConversationMessages, type ConversationType, type ConversationUpdateRequest, type ConversationUpdatedEvent, ConversationsResource, type Device, type DeviceEnvironment, type DeviceKind, type DevicePlatform, DevicesResource, type ErrorEnvelope, type IceServerResponse, IceServersResource, type IncomingCall, type IsoDateTime, type LiveCall, type LiveCallMember, LiveCallsResource, type LiveKitLocalVideoTrack, type LiveKitModule, type LiveKitParticipant, type LiveKitPublication, type LiveKitRoomHandle, type LiveKitTrack, type LiveKitTrackReference, type Me, MeResource, type MemberReadEvent, type MemberRole, type Membership, type MembershipCreateRequest, type MembershipList, type MentionEvent, type Message, type MessageCreateRequest, type MessageDeletedEvent, MessageHandle, type MessageList, type MessageNewEvent, type MessageType, type MessageUpdateRequest, type MessageUpdatedEvent, MessagesResource, NetworkError, type OutgoingCall, POOLSE_API_URL, Poolse, type PoolseConfig, PoolseError, PoolseRealtime, type PoolseUserProfile, type PresenceSnapshot, type QuotedMessagePreview, RateLimitedError, type ReactionEvent, type ReactionRequest, type ReadReceiptsState, type ReadRequest, type RealtimeStatus, type RegisterDeviceRequest, type RoomSession, RoomsResource, type TypingEvent, type Unsubscribe$1 as Unsubscribe, type UpdateMeRequest, UserChannel, UsersResource, type Uuid, type VoiceCandidate, type VoiceDescription, type VoiceIceServer, type VoiceParticipant, type VoicePeerConnection, VoiceRoom, type VoiceRoomOptions, type VoiceStatus, type VoiceStream, type VoiceTrack, type WebRtcAdapter, callLogDisplayFor, createBrowserWebRtcAdapter, describeCallLog, formatCallDuration, formatCallLogPreview, isCallLogMessage, isMessageVisibleTo, isWebRtcAvailable, parseCallLog, parseCallLogBody, safeUuid, version };
|
package/dist/index.js
CHANGED
|
@@ -1721,6 +1721,49 @@ var LiveCallsResource = class {
|
|
|
1721
1721
|
}
|
|
1722
1722
|
};
|
|
1723
1723
|
|
|
1724
|
+
// src/resources/rooms.ts
|
|
1725
|
+
var RoomsResource = class {
|
|
1726
|
+
constructor(client) {
|
|
1727
|
+
this.client = client;
|
|
1728
|
+
}
|
|
1729
|
+
client;
|
|
1730
|
+
/** POST /v1/conversations/:id/room — start the room, or join what is live. */
|
|
1731
|
+
start(conversationId, media = "audio", signal) {
|
|
1732
|
+
return this.client.request({
|
|
1733
|
+
method: "POST",
|
|
1734
|
+
path: `/v1/conversations/${encodeURIComponent(conversationId)}/room`,
|
|
1735
|
+
body: { media },
|
|
1736
|
+
...signal ? { signal } : {}
|
|
1737
|
+
});
|
|
1738
|
+
}
|
|
1739
|
+
/**
|
|
1740
|
+
* POST /v1/conversations/:id/calls — like `start`, but RINGS the other
|
|
1741
|
+
* members' phones (a support desk calling a customer). Off by default
|
|
1742
|
+
* in the room UI; an app opts in. Joins whatever is live instead, the
|
|
1743
|
+
* same as `start`.
|
|
1744
|
+
*/
|
|
1745
|
+
ring(conversationId, media = "audio", signal) {
|
|
1746
|
+
return this.client.request({
|
|
1747
|
+
method: "POST",
|
|
1748
|
+
path: `/v1/conversations/${encodeURIComponent(conversationId)}/calls`,
|
|
1749
|
+
body: { media },
|
|
1750
|
+
...signal ? { signal } : {}
|
|
1751
|
+
});
|
|
1752
|
+
}
|
|
1753
|
+
/**
|
|
1754
|
+
* POST /v1/calls/:id/hangup — leave. Never ends the room for the others;
|
|
1755
|
+
* it ends once empty. Authorized by the session's control token.
|
|
1756
|
+
*/
|
|
1757
|
+
leave(session) {
|
|
1758
|
+
return this.client.request({
|
|
1759
|
+
method: "POST",
|
|
1760
|
+
path: `/v1/calls/${encodeURIComponent(session.call.id)}/hangup`,
|
|
1761
|
+
bearer: session.control_token,
|
|
1762
|
+
idempotencyKey: null
|
|
1763
|
+
});
|
|
1764
|
+
}
|
|
1765
|
+
};
|
|
1766
|
+
|
|
1724
1767
|
// src/voice/call-room.ts
|
|
1725
1768
|
function toDevices(raw, kind) {
|
|
1726
1769
|
const out = [];
|
|
@@ -2220,7 +2263,12 @@ var RestClient = class {
|
|
|
2220
2263
|
let triedAuthRefresh = false;
|
|
2221
2264
|
for (; ; ) {
|
|
2222
2265
|
const body = opts.body === void 0 ? void 0 : JSON.stringify(opts.body);
|
|
2223
|
-
const headers = await this.buildHeaders(
|
|
2266
|
+
const headers = await this.buildHeaders(
|
|
2267
|
+
opts.method,
|
|
2268
|
+
idempotencyKey,
|
|
2269
|
+
body !== void 0,
|
|
2270
|
+
opts.bearer
|
|
2271
|
+
);
|
|
2224
2272
|
let response;
|
|
2225
2273
|
try {
|
|
2226
2274
|
const init = { method: opts.method, headers };
|
|
@@ -2242,7 +2290,7 @@ var RestClient = class {
|
|
|
2242
2290
|
return await parseJsonOrNull(response);
|
|
2243
2291
|
}
|
|
2244
2292
|
if (response.status === 401) {
|
|
2245
|
-
if (!triedAuthRefresh) {
|
|
2293
|
+
if (!triedAuthRefresh && opts.bearer === void 0) {
|
|
2246
2294
|
this.tokenCache.invalidate();
|
|
2247
2295
|
triedAuthRefresh = true;
|
|
2248
2296
|
continue;
|
|
@@ -2280,10 +2328,10 @@ var RestClient = class {
|
|
|
2280
2328
|
const qs = params.toString();
|
|
2281
2329
|
return qs ? `${base}?${qs}` : base;
|
|
2282
2330
|
}
|
|
2283
|
-
async buildHeaders(method, idempotencyKey, hasBody) {
|
|
2331
|
+
async buildHeaders(method, idempotencyKey, hasBody, bearer) {
|
|
2284
2332
|
const headers = { Accept: "application/json" };
|
|
2285
2333
|
if (hasBody) headers["Content-Type"] = "application/json";
|
|
2286
|
-
const token = await this.config.getToken();
|
|
2334
|
+
const token = bearer ?? await this.config.getToken();
|
|
2287
2335
|
if (token) headers["Authorization"] = `Bearer ${token}`;
|
|
2288
2336
|
if (!IDEMPOTENT_METHODS.has(method) && idempotencyKey) {
|
|
2289
2337
|
headers["Idempotency-Key"] = idempotencyKey;
|
|
@@ -2459,6 +2507,8 @@ var Poolse = class {
|
|
|
2459
2507
|
callTokens;
|
|
2460
2508
|
/** Whether a call is running on a conversation — for a Join banner. */
|
|
2461
2509
|
liveCalls;
|
|
2510
|
+
/** A conversation's drop-in room: voice or video, nobody rung. */
|
|
2511
|
+
rooms;
|
|
2462
2512
|
resolved;
|
|
2463
2513
|
tokenCache;
|
|
2464
2514
|
constructor(config) {
|
|
@@ -2478,6 +2528,7 @@ var Poolse = class {
|
|
|
2478
2528
|
this.iceServers = new IceServersResource(this.rest);
|
|
2479
2529
|
this.callTokens = new CallTokensResource(this.rest);
|
|
2480
2530
|
this.liveCalls = new LiveCallsResource(this.rest);
|
|
2531
|
+
this.rooms = new RoomsResource(this.rest);
|
|
2481
2532
|
this.realtime = new PoolseRealtime(cachedConfig, this.tokenCache, {
|
|
2482
2533
|
...this.resolved.wsUrl !== void 0 ? { wsUrl: this.resolved.wsUrl } : {},
|
|
2483
2534
|
socketPath: this.resolved.socketPath,
|
|
@@ -2520,7 +2571,7 @@ var Poolse = class {
|
|
|
2520
2571
|
};
|
|
2521
2572
|
|
|
2522
2573
|
// src/version.ts
|
|
2523
|
-
var version = "2.
|
|
2574
|
+
var version = "2.24.0";
|
|
2524
2575
|
|
|
2525
2576
|
// src/call-log.ts
|
|
2526
2577
|
function parseCallLogBody(body) {
|
|
@@ -2556,6 +2607,7 @@ function parseCallLogBody(body) {
|
|
|
2556
2607
|
durationMs,
|
|
2557
2608
|
joinedUserIds: joined,
|
|
2558
2609
|
version: obj.v === 2 ? 2 : 1,
|
|
2610
|
+
callKind: obj.call_kind === "room" ? "room" : "call",
|
|
2559
2611
|
callerUserId: typeof obj.caller_user_id === "string" ? obj.caller_user_id : null,
|
|
2560
2612
|
participants,
|
|
2561
2613
|
endReason: isEndReason(obj.end_reason) ? obj.end_reason : null,
|
|
@@ -2606,6 +2658,15 @@ function describeCallLog(log, currentUserId) {
|
|
|
2606
2658
|
const duration = log.durationMs !== null ? formatCallDuration(log.durationMs) : null;
|
|
2607
2659
|
const group = log.participants.length > 1;
|
|
2608
2660
|
const me = currentUserId;
|
|
2661
|
+
if (log.callKind === "room") {
|
|
2662
|
+
const n = (/* @__PURE__ */ new Set([...log.joinedUserIds, ...log.participants.map((p) => p.userId)])).size;
|
|
2663
|
+
const title = log.media === "video" ? "Video room" : "Voice room";
|
|
2664
|
+
const people = n > 0 ? `${n} joined` : null;
|
|
2665
|
+
return display(log.media, title, [duration, people].filter(Boolean).join(" \xB7 ") || null, {
|
|
2666
|
+
direction: null,
|
|
2667
|
+
callBack: false
|
|
2668
|
+
});
|
|
2669
|
+
}
|
|
2609
2670
|
const mine = me !== null ? log.participants.find((p) => p.userId === me) : void 0;
|
|
2610
2671
|
const isCaller = me !== null && log.callerUserId === me;
|
|
2611
2672
|
if (log.version === 1 || !isCaller && !mine) {
|
|
@@ -2675,6 +2736,6 @@ function formatCallLogPreview(preview, currentUserId) {
|
|
|
2675
2736
|
return "Call";
|
|
2676
2737
|
}
|
|
2677
2738
|
|
|
2678
|
-
export { ApiError, AttachmentHandle, AttachmentsResource, AuthError, CallRoom, CallTokensResource, CallsResource, ConversationChannel, ConversationHandle, ConversationMessages, ConversationsResource, DevicesResource, IceServersResource, LiveCallsResource, MeResource, MessageHandle, MessagesResource, NetworkError, POOLSE_API_URL, Poolse, PoolseError, PoolseRealtime, RateLimitedError, UserChannel, UsersResource, VoiceRoom, callLogDisplayFor, createBrowserWebRtcAdapter, describeCallLog, formatCallDuration, formatCallLogPreview, isCallLogMessage, isMessageVisibleTo, isWebRtcAvailable, parseCallLog, parseCallLogBody, safeUuid, version };
|
|
2739
|
+
export { ApiError, AttachmentHandle, AttachmentsResource, AuthError, CallRoom, CallTokensResource, CallsResource, ConversationChannel, ConversationHandle, ConversationMessages, ConversationsResource, DevicesResource, IceServersResource, LiveCallsResource, MeResource, MessageHandle, MessagesResource, NetworkError, POOLSE_API_URL, Poolse, PoolseError, PoolseRealtime, RateLimitedError, RoomsResource, UserChannel, UsersResource, VoiceRoom, callLogDisplayFor, createBrowserWebRtcAdapter, describeCallLog, formatCallDuration, formatCallLogPreview, isCallLogMessage, isMessageVisibleTo, isWebRtcAvailable, parseCallLog, parseCallLogBody, safeUuid, version };
|
|
2679
2740
|
//# sourceMappingURL=index.js.map
|
|
2680
2741
|
//# sourceMappingURL=index.js.map
|