@poolse/sdk 2.22.0 → 2.24.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 +99 -7
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +102 -3
- package/dist/index.d.ts +102 -3
- package/dist/index.js +99 -8
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -11,6 +11,23 @@ interface Me {
|
|
|
11
11
|
is_blocked: boolean;
|
|
12
12
|
inserted_at: IsoDateTime;
|
|
13
13
|
updated_at: IsoDateTime;
|
|
14
|
+
/** Where read receipts stand for this user. Absent on older servers (treat as on). */
|
|
15
|
+
read_receipts?: ReadReceiptsState;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* The workspace's read-receipt setting, as it applies to one user.
|
|
19
|
+
* `visible: false` means the app shows no check marks at all — the
|
|
20
|
+
* server withholds other members' read state anyway.
|
|
21
|
+
*/
|
|
22
|
+
interface ReadReceiptsState {
|
|
23
|
+
/** `on`: everyone sees them; `off`: nobody; `user`: each user decides (reciprocal). */
|
|
24
|
+
mode: 'on' | 'off' | 'user';
|
|
25
|
+
/** Whether others see when this user reads. */
|
|
26
|
+
shared: boolean;
|
|
27
|
+
/** True only in `user` mode — the app may offer a switch (`me.update`). */
|
|
28
|
+
can_change: boolean;
|
|
29
|
+
/** Whether this user sees other people's read state. */
|
|
30
|
+
visible: boolean;
|
|
14
31
|
}
|
|
15
32
|
type ConversationType = 'direct' | 'group';
|
|
16
33
|
interface Conversation {
|
|
@@ -849,6 +866,13 @@ interface RequestOptions {
|
|
|
849
866
|
maxRetries?: number;
|
|
850
867
|
/** AbortSignal for caller-driven cancellation. */
|
|
851
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;
|
|
852
876
|
}
|
|
853
877
|
declare class RestClient {
|
|
854
878
|
private readonly config;
|
|
@@ -876,6 +900,8 @@ interface LiveCall {
|
|
|
876
900
|
conversation_id: string;
|
|
877
901
|
conversation_name: string | null;
|
|
878
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';
|
|
879
905
|
state: 'live' | 'finished';
|
|
880
906
|
started_by: LiveCallMember;
|
|
881
907
|
started_at: string | null;
|
|
@@ -1463,12 +1489,36 @@ declare class DevicesResource {
|
|
|
1463
1489
|
unregister(token: string, signal?: AbortSignal): Promise<void>;
|
|
1464
1490
|
}
|
|
1465
1491
|
|
|
1466
|
-
|
|
1492
|
+
interface UpdateMeRequest {
|
|
1493
|
+
/**
|
|
1494
|
+
* Whether others see when this user reads their messages. Accepted
|
|
1495
|
+
* only while the workspace lets users decide (`read_receipts.can_change`);
|
|
1496
|
+
* otherwise the server answers 409 `read_receipts_fixed`. Reciprocal:
|
|
1497
|
+
* turning it off also hides other people's.
|
|
1498
|
+
*/
|
|
1499
|
+
read_receipts?: boolean;
|
|
1500
|
+
}
|
|
1501
|
+
/**
|
|
1502
|
+
* `/v1/me` — the End-User identity behind the presented JWT.
|
|
1503
|
+
*
|
|
1504
|
+
* Keeps the last-known user so every screen agrees: a change made
|
|
1505
|
+
* through `update` (say, turning read receipts off) reaches every
|
|
1506
|
+
* `onChange` subscriber at once instead of waiting for a remount.
|
|
1507
|
+
*/
|
|
1467
1508
|
declare class MeResource {
|
|
1468
1509
|
private readonly client;
|
|
1510
|
+
private current;
|
|
1511
|
+
private readonly listeners;
|
|
1469
1512
|
constructor(client: RestClient);
|
|
1470
1513
|
/** GET /v1/me */
|
|
1471
1514
|
show(signal?: AbortSignal): Promise<Me>;
|
|
1515
|
+
/** PATCH /v1/me — the user's own preferences. */
|
|
1516
|
+
update(body: UpdateMeRequest, signal?: AbortSignal): Promise<Me>;
|
|
1517
|
+
/** The last user `show` / `update` returned, or null before the first. */
|
|
1518
|
+
peek(): Me | null;
|
|
1519
|
+
/** Called with the user whenever `show` or `update` returns a new one. */
|
|
1520
|
+
onChange(fn: (me: Me) => void): () => void;
|
|
1521
|
+
private set;
|
|
1472
1522
|
}
|
|
1473
1523
|
|
|
1474
1524
|
type Listener = () => void;
|
|
@@ -1790,6 +1840,51 @@ declare class CallTokensResource {
|
|
|
1790
1840
|
create(conversationId: string, signal?: AbortSignal): Promise<CallConnection | null>;
|
|
1791
1841
|
}
|
|
1792
1842
|
|
|
1843
|
+
/** What starting or joining a room returns (the call contract's session bundle). */
|
|
1844
|
+
interface RoomSession {
|
|
1845
|
+
cv: number;
|
|
1846
|
+
/** True when this request started the room; false when it joined one already live. */
|
|
1847
|
+
created: boolean;
|
|
1848
|
+
/** The live room — or call: a ringing call already live there is joined instead. */
|
|
1849
|
+
call: LiveCall;
|
|
1850
|
+
/** SFU credentials for this participant. */
|
|
1851
|
+
livekit: {
|
|
1852
|
+
url: string;
|
|
1853
|
+
token: string;
|
|
1854
|
+
};
|
|
1855
|
+
/** Authorizes leaving (`leave`); scoped to this call. */
|
|
1856
|
+
control_token: string;
|
|
1857
|
+
}
|
|
1858
|
+
/**
|
|
1859
|
+
* A conversation's room — the Meet-style way to talk: anyone in the
|
|
1860
|
+
* conversation drops in for voice or video while the chat carries on,
|
|
1861
|
+
* and nobody's phone rings. One room per conversation; starting one
|
|
1862
|
+
* while it is live (or while a call is) joins that instead.
|
|
1863
|
+
*
|
|
1864
|
+
* Members see it the same way as a call — `liveCalls.get`, the
|
|
1865
|
+
* `call:started` / `call:participants` / `call:finished` events, a Join
|
|
1866
|
+
* banner — and phones join it like any call. It ends once it has been
|
|
1867
|
+
* empty for a short grace, and leaves one line in the chat history.
|
|
1868
|
+
*/
|
|
1869
|
+
declare class RoomsResource {
|
|
1870
|
+
private readonly client;
|
|
1871
|
+
constructor(client: RestClient);
|
|
1872
|
+
/** POST /v1/conversations/:id/room — start the room, or join what is live. */
|
|
1873
|
+
start(conversationId: string, media?: 'audio' | 'video', signal?: AbortSignal): Promise<RoomSession>;
|
|
1874
|
+
/**
|
|
1875
|
+
* POST /v1/conversations/:id/calls — like `start`, but RINGS the other
|
|
1876
|
+
* members' phones (a support desk calling a customer). Off by default
|
|
1877
|
+
* in the room UI; an app opts in. Joins whatever is live instead, the
|
|
1878
|
+
* same as `start`.
|
|
1879
|
+
*/
|
|
1880
|
+
ring(conversationId: string, media?: 'audio' | 'video', signal?: AbortSignal): Promise<RoomSession>;
|
|
1881
|
+
/**
|
|
1882
|
+
* POST /v1/calls/:id/hangup — leave. Never ends the room for the others;
|
|
1883
|
+
* it ends once empty. Authorized by the session's control token.
|
|
1884
|
+
*/
|
|
1885
|
+
leave(session: Pick<RoomSession, 'call' | 'control_token'>): Promise<void>;
|
|
1886
|
+
}
|
|
1887
|
+
|
|
1793
1888
|
type Unsubscribe = () => void;
|
|
1794
1889
|
declare class CallRoom {
|
|
1795
1890
|
private readonly livekit;
|
|
@@ -2019,6 +2114,8 @@ declare class Poolse {
|
|
|
2019
2114
|
readonly callTokens: CallTokensResource;
|
|
2020
2115
|
/** Whether a call is running on a conversation — for a Join banner. */
|
|
2021
2116
|
readonly liveCalls: LiveCallsResource;
|
|
2117
|
+
/** A conversation's drop-in room: voice or video, nobody rung. */
|
|
2118
|
+
readonly rooms: RoomsResource;
|
|
2022
2119
|
private readonly resolved;
|
|
2023
2120
|
private readonly tokenCache;
|
|
2024
2121
|
constructor(config: PoolseConfig);
|
|
@@ -2100,7 +2197,7 @@ declare class AuthError extends ApiError {
|
|
|
2100
2197
|
declare function isWebRtcAvailable(): boolean;
|
|
2101
2198
|
declare function createBrowserWebRtcAdapter(): WebRtcAdapter;
|
|
2102
2199
|
|
|
2103
|
-
declare const version = "2.
|
|
2200
|
+
declare const version = "2.24.0";
|
|
2104
2201
|
|
|
2105
2202
|
type CallLogMedia = 'audio' | 'video';
|
|
2106
2203
|
/** What became of one person a call involved (the caller excluded). */
|
|
@@ -2117,6 +2214,8 @@ interface CallLogEntry {
|
|
|
2117
2214
|
joinedUserIds: Uuid[];
|
|
2118
2215
|
/** `2` for the one-record-per-call shape; `1` for older history. */
|
|
2119
2216
|
version: 1 | 2;
|
|
2217
|
+
/** `room`: a drop-in meeting that rang nobody; `call`: rang the members. */
|
|
2218
|
+
callKind: 'call' | 'room';
|
|
2120
2219
|
/** Who placed the call. `null` on v1 records. */
|
|
2121
2220
|
callerUserId: Uuid | null;
|
|
2122
2221
|
/** Everyone else the call involved, with their outcome. Empty on v1. */
|
|
@@ -2210,4 +2309,4 @@ declare function formatCallLogPreview(preview: string | null | undefined, curren
|
|
|
2210
2309
|
|
|
2211
2310
|
declare function safeUuid(): string;
|
|
2212
2311
|
|
|
2213
|
-
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 ReadRequest, type RealtimeStatus, type RegisterDeviceRequest, type TypingEvent, type Unsubscribe$1 as Unsubscribe, 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 };
|
|
2312
|
+
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
|
@@ -11,6 +11,23 @@ interface Me {
|
|
|
11
11
|
is_blocked: boolean;
|
|
12
12
|
inserted_at: IsoDateTime;
|
|
13
13
|
updated_at: IsoDateTime;
|
|
14
|
+
/** Where read receipts stand for this user. Absent on older servers (treat as on). */
|
|
15
|
+
read_receipts?: ReadReceiptsState;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* The workspace's read-receipt setting, as it applies to one user.
|
|
19
|
+
* `visible: false` means the app shows no check marks at all — the
|
|
20
|
+
* server withholds other members' read state anyway.
|
|
21
|
+
*/
|
|
22
|
+
interface ReadReceiptsState {
|
|
23
|
+
/** `on`: everyone sees them; `off`: nobody; `user`: each user decides (reciprocal). */
|
|
24
|
+
mode: 'on' | 'off' | 'user';
|
|
25
|
+
/** Whether others see when this user reads. */
|
|
26
|
+
shared: boolean;
|
|
27
|
+
/** True only in `user` mode — the app may offer a switch (`me.update`). */
|
|
28
|
+
can_change: boolean;
|
|
29
|
+
/** Whether this user sees other people's read state. */
|
|
30
|
+
visible: boolean;
|
|
14
31
|
}
|
|
15
32
|
type ConversationType = 'direct' | 'group';
|
|
16
33
|
interface Conversation {
|
|
@@ -849,6 +866,13 @@ interface RequestOptions {
|
|
|
849
866
|
maxRetries?: number;
|
|
850
867
|
/** AbortSignal for caller-driven cancellation. */
|
|
851
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;
|
|
852
876
|
}
|
|
853
877
|
declare class RestClient {
|
|
854
878
|
private readonly config;
|
|
@@ -876,6 +900,8 @@ interface LiveCall {
|
|
|
876
900
|
conversation_id: string;
|
|
877
901
|
conversation_name: string | null;
|
|
878
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';
|
|
879
905
|
state: 'live' | 'finished';
|
|
880
906
|
started_by: LiveCallMember;
|
|
881
907
|
started_at: string | null;
|
|
@@ -1463,12 +1489,36 @@ declare class DevicesResource {
|
|
|
1463
1489
|
unregister(token: string, signal?: AbortSignal): Promise<void>;
|
|
1464
1490
|
}
|
|
1465
1491
|
|
|
1466
|
-
|
|
1492
|
+
interface UpdateMeRequest {
|
|
1493
|
+
/**
|
|
1494
|
+
* Whether others see when this user reads their messages. Accepted
|
|
1495
|
+
* only while the workspace lets users decide (`read_receipts.can_change`);
|
|
1496
|
+
* otherwise the server answers 409 `read_receipts_fixed`. Reciprocal:
|
|
1497
|
+
* turning it off also hides other people's.
|
|
1498
|
+
*/
|
|
1499
|
+
read_receipts?: boolean;
|
|
1500
|
+
}
|
|
1501
|
+
/**
|
|
1502
|
+
* `/v1/me` — the End-User identity behind the presented JWT.
|
|
1503
|
+
*
|
|
1504
|
+
* Keeps the last-known user so every screen agrees: a change made
|
|
1505
|
+
* through `update` (say, turning read receipts off) reaches every
|
|
1506
|
+
* `onChange` subscriber at once instead of waiting for a remount.
|
|
1507
|
+
*/
|
|
1467
1508
|
declare class MeResource {
|
|
1468
1509
|
private readonly client;
|
|
1510
|
+
private current;
|
|
1511
|
+
private readonly listeners;
|
|
1469
1512
|
constructor(client: RestClient);
|
|
1470
1513
|
/** GET /v1/me */
|
|
1471
1514
|
show(signal?: AbortSignal): Promise<Me>;
|
|
1515
|
+
/** PATCH /v1/me — the user's own preferences. */
|
|
1516
|
+
update(body: UpdateMeRequest, signal?: AbortSignal): Promise<Me>;
|
|
1517
|
+
/** The last user `show` / `update` returned, or null before the first. */
|
|
1518
|
+
peek(): Me | null;
|
|
1519
|
+
/** Called with the user whenever `show` or `update` returns a new one. */
|
|
1520
|
+
onChange(fn: (me: Me) => void): () => void;
|
|
1521
|
+
private set;
|
|
1472
1522
|
}
|
|
1473
1523
|
|
|
1474
1524
|
type Listener = () => void;
|
|
@@ -1790,6 +1840,51 @@ declare class CallTokensResource {
|
|
|
1790
1840
|
create(conversationId: string, signal?: AbortSignal): Promise<CallConnection | null>;
|
|
1791
1841
|
}
|
|
1792
1842
|
|
|
1843
|
+
/** What starting or joining a room returns (the call contract's session bundle). */
|
|
1844
|
+
interface RoomSession {
|
|
1845
|
+
cv: number;
|
|
1846
|
+
/** True when this request started the room; false when it joined one already live. */
|
|
1847
|
+
created: boolean;
|
|
1848
|
+
/** The live room — or call: a ringing call already live there is joined instead. */
|
|
1849
|
+
call: LiveCall;
|
|
1850
|
+
/** SFU credentials for this participant. */
|
|
1851
|
+
livekit: {
|
|
1852
|
+
url: string;
|
|
1853
|
+
token: string;
|
|
1854
|
+
};
|
|
1855
|
+
/** Authorizes leaving (`leave`); scoped to this call. */
|
|
1856
|
+
control_token: string;
|
|
1857
|
+
}
|
|
1858
|
+
/**
|
|
1859
|
+
* A conversation's room — the Meet-style way to talk: anyone in the
|
|
1860
|
+
* conversation drops in for voice or video while the chat carries on,
|
|
1861
|
+
* and nobody's phone rings. One room per conversation; starting one
|
|
1862
|
+
* while it is live (or while a call is) joins that instead.
|
|
1863
|
+
*
|
|
1864
|
+
* Members see it the same way as a call — `liveCalls.get`, the
|
|
1865
|
+
* `call:started` / `call:participants` / `call:finished` events, a Join
|
|
1866
|
+
* banner — and phones join it like any call. It ends once it has been
|
|
1867
|
+
* empty for a short grace, and leaves one line in the chat history.
|
|
1868
|
+
*/
|
|
1869
|
+
declare class RoomsResource {
|
|
1870
|
+
private readonly client;
|
|
1871
|
+
constructor(client: RestClient);
|
|
1872
|
+
/** POST /v1/conversations/:id/room — start the room, or join what is live. */
|
|
1873
|
+
start(conversationId: string, media?: 'audio' | 'video', signal?: AbortSignal): Promise<RoomSession>;
|
|
1874
|
+
/**
|
|
1875
|
+
* POST /v1/conversations/:id/calls — like `start`, but RINGS the other
|
|
1876
|
+
* members' phones (a support desk calling a customer). Off by default
|
|
1877
|
+
* in the room UI; an app opts in. Joins whatever is live instead, the
|
|
1878
|
+
* same as `start`.
|
|
1879
|
+
*/
|
|
1880
|
+
ring(conversationId: string, media?: 'audio' | 'video', signal?: AbortSignal): Promise<RoomSession>;
|
|
1881
|
+
/**
|
|
1882
|
+
* POST /v1/calls/:id/hangup — leave. Never ends the room for the others;
|
|
1883
|
+
* it ends once empty. Authorized by the session's control token.
|
|
1884
|
+
*/
|
|
1885
|
+
leave(session: Pick<RoomSession, 'call' | 'control_token'>): Promise<void>;
|
|
1886
|
+
}
|
|
1887
|
+
|
|
1793
1888
|
type Unsubscribe = () => void;
|
|
1794
1889
|
declare class CallRoom {
|
|
1795
1890
|
private readonly livekit;
|
|
@@ -2019,6 +2114,8 @@ declare class Poolse {
|
|
|
2019
2114
|
readonly callTokens: CallTokensResource;
|
|
2020
2115
|
/** Whether a call is running on a conversation — for a Join banner. */
|
|
2021
2116
|
readonly liveCalls: LiveCallsResource;
|
|
2117
|
+
/** A conversation's drop-in room: voice or video, nobody rung. */
|
|
2118
|
+
readonly rooms: RoomsResource;
|
|
2022
2119
|
private readonly resolved;
|
|
2023
2120
|
private readonly tokenCache;
|
|
2024
2121
|
constructor(config: PoolseConfig);
|
|
@@ -2100,7 +2197,7 @@ declare class AuthError extends ApiError {
|
|
|
2100
2197
|
declare function isWebRtcAvailable(): boolean;
|
|
2101
2198
|
declare function createBrowserWebRtcAdapter(): WebRtcAdapter;
|
|
2102
2199
|
|
|
2103
|
-
declare const version = "2.
|
|
2200
|
+
declare const version = "2.24.0";
|
|
2104
2201
|
|
|
2105
2202
|
type CallLogMedia = 'audio' | 'video';
|
|
2106
2203
|
/** What became of one person a call involved (the caller excluded). */
|
|
@@ -2117,6 +2214,8 @@ interface CallLogEntry {
|
|
|
2117
2214
|
joinedUserIds: Uuid[];
|
|
2118
2215
|
/** `2` for the one-record-per-call shape; `1` for older history. */
|
|
2119
2216
|
version: 1 | 2;
|
|
2217
|
+
/** `room`: a drop-in meeting that rang nobody; `call`: rang the members. */
|
|
2218
|
+
callKind: 'call' | 'room';
|
|
2120
2219
|
/** Who placed the call. `null` on v1 records. */
|
|
2121
2220
|
callerUserId: Uuid | null;
|
|
2122
2221
|
/** Everyone else the call involved, with their outcome. Empty on v1. */
|
|
@@ -2210,4 +2309,4 @@ declare function formatCallLogPreview(preview: string | null | undefined, curren
|
|
|
2210
2309
|
|
|
2211
2310
|
declare function safeUuid(): string;
|
|
2212
2311
|
|
|
2213
|
-
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 ReadRequest, type RealtimeStatus, type RegisterDeviceRequest, type TypingEvent, type Unsubscribe$1 as Unsubscribe, 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 };
|
|
2312
|
+
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
|
@@ -1537,13 +1537,43 @@ var MeResource = class {
|
|
|
1537
1537
|
this.client = client;
|
|
1538
1538
|
}
|
|
1539
1539
|
client;
|
|
1540
|
+
current = null;
|
|
1541
|
+
listeners = /* @__PURE__ */ new Set();
|
|
1540
1542
|
/** GET /v1/me */
|
|
1541
|
-
show(signal) {
|
|
1542
|
-
|
|
1543
|
+
async show(signal) {
|
|
1544
|
+
const me = await this.client.request({
|
|
1543
1545
|
method: "GET",
|
|
1544
1546
|
path: "/v1/me",
|
|
1545
1547
|
...signal ? { signal } : {}
|
|
1546
1548
|
});
|
|
1549
|
+
this.set(me);
|
|
1550
|
+
return me;
|
|
1551
|
+
}
|
|
1552
|
+
/** PATCH /v1/me — the user's own preferences. */
|
|
1553
|
+
async update(body, signal) {
|
|
1554
|
+
const me = await this.client.request({
|
|
1555
|
+
method: "PATCH",
|
|
1556
|
+
path: "/v1/me",
|
|
1557
|
+
body,
|
|
1558
|
+
...signal ? { signal } : {}
|
|
1559
|
+
});
|
|
1560
|
+
this.set(me);
|
|
1561
|
+
return me;
|
|
1562
|
+
}
|
|
1563
|
+
/** The last user `show` / `update` returned, or null before the first. */
|
|
1564
|
+
peek() {
|
|
1565
|
+
return this.current;
|
|
1566
|
+
}
|
|
1567
|
+
/** Called with the user whenever `show` or `update` returns a new one. */
|
|
1568
|
+
onChange(fn) {
|
|
1569
|
+
this.listeners.add(fn);
|
|
1570
|
+
return () => {
|
|
1571
|
+
this.listeners.delete(fn);
|
|
1572
|
+
};
|
|
1573
|
+
}
|
|
1574
|
+
set(me) {
|
|
1575
|
+
this.current = me;
|
|
1576
|
+
for (const fn of this.listeners) fn(me);
|
|
1547
1577
|
}
|
|
1548
1578
|
};
|
|
1549
1579
|
|
|
@@ -1691,6 +1721,49 @@ var LiveCallsResource = class {
|
|
|
1691
1721
|
}
|
|
1692
1722
|
};
|
|
1693
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
|
+
|
|
1694
1767
|
// src/voice/call-room.ts
|
|
1695
1768
|
function toDevices(raw, kind) {
|
|
1696
1769
|
const out = [];
|
|
@@ -2190,7 +2263,12 @@ var RestClient = class {
|
|
|
2190
2263
|
let triedAuthRefresh = false;
|
|
2191
2264
|
for (; ; ) {
|
|
2192
2265
|
const body = opts.body === void 0 ? void 0 : JSON.stringify(opts.body);
|
|
2193
|
-
const headers = await this.buildHeaders(
|
|
2266
|
+
const headers = await this.buildHeaders(
|
|
2267
|
+
opts.method,
|
|
2268
|
+
idempotencyKey,
|
|
2269
|
+
body !== void 0,
|
|
2270
|
+
opts.bearer
|
|
2271
|
+
);
|
|
2194
2272
|
let response;
|
|
2195
2273
|
try {
|
|
2196
2274
|
const init = { method: opts.method, headers };
|
|
@@ -2212,7 +2290,7 @@ var RestClient = class {
|
|
|
2212
2290
|
return await parseJsonOrNull(response);
|
|
2213
2291
|
}
|
|
2214
2292
|
if (response.status === 401) {
|
|
2215
|
-
if (!triedAuthRefresh) {
|
|
2293
|
+
if (!triedAuthRefresh && opts.bearer === void 0) {
|
|
2216
2294
|
this.tokenCache.invalidate();
|
|
2217
2295
|
triedAuthRefresh = true;
|
|
2218
2296
|
continue;
|
|
@@ -2250,10 +2328,10 @@ var RestClient = class {
|
|
|
2250
2328
|
const qs = params.toString();
|
|
2251
2329
|
return qs ? `${base}?${qs}` : base;
|
|
2252
2330
|
}
|
|
2253
|
-
async buildHeaders(method, idempotencyKey, hasBody) {
|
|
2331
|
+
async buildHeaders(method, idempotencyKey, hasBody, bearer) {
|
|
2254
2332
|
const headers = { Accept: "application/json" };
|
|
2255
2333
|
if (hasBody) headers["Content-Type"] = "application/json";
|
|
2256
|
-
const token = await this.config.getToken();
|
|
2334
|
+
const token = bearer ?? await this.config.getToken();
|
|
2257
2335
|
if (token) headers["Authorization"] = `Bearer ${token}`;
|
|
2258
2336
|
if (!IDEMPOTENT_METHODS.has(method) && idempotencyKey) {
|
|
2259
2337
|
headers["Idempotency-Key"] = idempotencyKey;
|
|
@@ -2429,6 +2507,8 @@ var Poolse = class {
|
|
|
2429
2507
|
callTokens;
|
|
2430
2508
|
/** Whether a call is running on a conversation — for a Join banner. */
|
|
2431
2509
|
liveCalls;
|
|
2510
|
+
/** A conversation's drop-in room: voice or video, nobody rung. */
|
|
2511
|
+
rooms;
|
|
2432
2512
|
resolved;
|
|
2433
2513
|
tokenCache;
|
|
2434
2514
|
constructor(config) {
|
|
@@ -2448,6 +2528,7 @@ var Poolse = class {
|
|
|
2448
2528
|
this.iceServers = new IceServersResource(this.rest);
|
|
2449
2529
|
this.callTokens = new CallTokensResource(this.rest);
|
|
2450
2530
|
this.liveCalls = new LiveCallsResource(this.rest);
|
|
2531
|
+
this.rooms = new RoomsResource(this.rest);
|
|
2451
2532
|
this.realtime = new PoolseRealtime(cachedConfig, this.tokenCache, {
|
|
2452
2533
|
...this.resolved.wsUrl !== void 0 ? { wsUrl: this.resolved.wsUrl } : {},
|
|
2453
2534
|
socketPath: this.resolved.socketPath,
|
|
@@ -2490,7 +2571,7 @@ var Poolse = class {
|
|
|
2490
2571
|
};
|
|
2491
2572
|
|
|
2492
2573
|
// src/version.ts
|
|
2493
|
-
var version = "2.
|
|
2574
|
+
var version = "2.24.0";
|
|
2494
2575
|
|
|
2495
2576
|
// src/call-log.ts
|
|
2496
2577
|
function parseCallLogBody(body) {
|
|
@@ -2526,6 +2607,7 @@ function parseCallLogBody(body) {
|
|
|
2526
2607
|
durationMs,
|
|
2527
2608
|
joinedUserIds: joined,
|
|
2528
2609
|
version: obj.v === 2 ? 2 : 1,
|
|
2610
|
+
callKind: obj.call_kind === "room" ? "room" : "call",
|
|
2529
2611
|
callerUserId: typeof obj.caller_user_id === "string" ? obj.caller_user_id : null,
|
|
2530
2612
|
participants,
|
|
2531
2613
|
endReason: isEndReason(obj.end_reason) ? obj.end_reason : null,
|
|
@@ -2576,6 +2658,15 @@ function describeCallLog(log, currentUserId) {
|
|
|
2576
2658
|
const duration = log.durationMs !== null ? formatCallDuration(log.durationMs) : null;
|
|
2577
2659
|
const group = log.participants.length > 1;
|
|
2578
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
|
+
}
|
|
2579
2670
|
const mine = me !== null ? log.participants.find((p) => p.userId === me) : void 0;
|
|
2580
2671
|
const isCaller = me !== null && log.callerUserId === me;
|
|
2581
2672
|
if (log.version === 1 || !isCaller && !mine) {
|
|
@@ -2645,6 +2736,6 @@ function formatCallLogPreview(preview, currentUserId) {
|
|
|
2645
2736
|
return "Call";
|
|
2646
2737
|
}
|
|
2647
2738
|
|
|
2648
|
-
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 };
|
|
2649
2740
|
//# sourceMappingURL=index.js.map
|
|
2650
2741
|
//# sourceMappingURL=index.js.map
|