@poolse/react 3.7.1 → 3.9.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/CHANGELOG.md +39 -0
- package/README.md +56 -25
- package/dist/index.cjs +958 -52
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +354 -8
- package/dist/index.d.ts +354 -8
- package/dist/index.js +878 -56
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.d.cts
CHANGED
|
@@ -1,9 +1,27 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
-
import { PoolseConfig, TrackActivityOptions,
|
|
3
|
-
export { ApiError, ApiErrorCode, AppEvent, Attachment, AttachmentStatus, AttachmentUploadInput, AttachmentUploadRequest, AttachmentUploadResponse, AuthError, CallEndReason, CallLog, CallLogDisplay, CallLogEntry, CallLogMedia, CallMissedEntry, CallParticipantStatus, Conversation, ConversationCreateRequest, ConversationReadEvent, DeviceKind, LinkPreview, LinkPreviewType, LiveCall, LiveCallMember, Me, MemberRole, Membership, Message, MessageCreateRequest, MessageEdit, MessageEditList, MessageType, MessageUpdateRequest, NetworkError, NotificationPreferences, NotifyLevel, OwnMembership, OwnMembershipUpdateRequest, PoolseConfig, PoolseError, PoolseUserProfile, Presence, PresenceActivity, PresenceChangedEvent, PresenceState, RateLimitedError, ReadReceiptsState, RealtimeStatus, RoomSession, ThreadParticipant, ThreadUpdatedEvent, TrackActivityOptions, Uuid, callLogDisplayFor, describeCallLog, formatCallDuration, formatCallLogPreview, isCallLogMessage, isMessageVisibleTo, isTombstone, mergeMessage, parseCallLog, parseCallLogBody, toTombstone } from '@poolse/sdk';
|
|
2
|
+
import { Poolse, PoolseConfig, TrackActivityOptions, Conversation, Uuid, UnreadTotals, OutboxEntry, Me, ConversationCreateRequest, Membership, MemberRole, Message, MessageCreateRequest, Presence, RealtimeStatus, Attachment, AttachmentUploadInput, PoolseUserProfile, AppEvent, CallRoomStatus, CallParticipant, CameraFacing, CallDeviceKind, CallDevice, LiveKitModule, LiveCall, CallRecordingState, CallTranscriptionState, ConsentDecision, Recording, RecordingMode, LiveTranscriptSegment, Transcript, TranscriptWithSegments, RecordingStartedEvent, RecordingChangedEvent, RecordingConsentEvent, TranscriptChangedEvent } from '@poolse/sdk';
|
|
3
|
+
export { ApiError, ApiErrorCode, AppEvent, Attachment, AttachmentStatus, AttachmentUploadInput, AttachmentUploadRequest, AttachmentUploadResponse, AuthError, CallEndReason, CallLog, CallLogDisplay, CallLogEntry, CallLogMedia, CallMissedEntry, CallParticipantStatus, CallRecordingState, CallTranscriptionState, ConsentDecision, Conversation, ConversationCreateRequest, ConversationReadEvent, ConversationRecordingSettings, DestroyOptions, DeviceKind, LinkPreview, LinkPreviewType, LiveCall, LiveCallMember, LiveTranscriptSegment, LocalMessageStatus, Me, MemberRole, Membership, Message, MessageCreateRequest, MessageDiscardedError, MessageEdit, MessageEditList, MessageQueuedError, MessageType, MessageUpdateRequest, NetworkError, NotificationPreferences, NotifyLevel, OutboxEntry, OwnMembership, OwnMembershipUpdateRequest, POOLSE_SERVICE_IDENTITY_PREFIX, Poolse, PoolseConfig, PoolseError, PoolseStorage, PoolseUserProfile, Presence, PresenceActivity, PresenceChangedEvent, PresenceState, RateLimitedError, ReadReceiptsState, RealtimeStatus, Recording, RecordingDownload, RecordingMode, RecordingNotice, RecordingNoticeDisplay, RecordingStatus, RoomSession, ThreadParticipant, ThreadUpdatedEvent, TimingEvent, TrackActivityOptions, Transcript, TranscriptBlock, TranscriptSegment, TranscriptSpeaker, TranscriptWithSegments, UnreadSummary, UnreadTotals, Uuid, applyLiveSegment, callLogDisplayFor, captureErrorMessage, captureLabel, createIndexedDbStorage, describeCallLog, describeRecordingNotice, findInText, formatCallDuration, formatCallLogPreview, formatRecordingNoticePreview, groupTranscript, isCallLogMessage, isMessageVisibleTo, isServiceParticipant, isTombstone, memoryStorage, mergeMessage, parseCallLog, parseCallLogBody, parseRecordingNotice, parseRecordingNoticeBody, recordingNoticeDisplayFor, speakerName, toTombstone } from '@poolse/sdk';
|
|
4
4
|
import { ReactNode } from 'react';
|
|
5
5
|
|
|
6
6
|
interface PoolseProviderProps {
|
|
7
|
+
/**
|
|
8
|
+
* A client you created yourself (`new Poolse(config)`) — for several
|
|
9
|
+
* workspaces, keep one client per workspace outside React and hand
|
|
10
|
+
* each to its own provider. Providers side by side never share
|
|
11
|
+
* state. The provider does NOT destroy a client it was given: it
|
|
12
|
+
* stays connected and warm while its provider is unmounted or hidden,
|
|
13
|
+
* so switching back is a view change. Destroy it yourself on
|
|
14
|
+
* sign-out (`client.destroy({ clearStorage: true })`).
|
|
15
|
+
*
|
|
16
|
+
* Takes precedence over `config`.
|
|
17
|
+
*/
|
|
18
|
+
client?: Poolse;
|
|
19
|
+
/**
|
|
20
|
+
* Put the client in the background while `true` (socket closed,
|
|
21
|
+
* reconnects when it turns `false`) — for a workspace that isn't on
|
|
22
|
+
* screen on a phone. See `Poolse.setBackground`.
|
|
23
|
+
*/
|
|
24
|
+
background?: boolean;
|
|
7
25
|
/**
|
|
8
26
|
* SDK configuration. The provider builds the `Poolse` instance ONCE
|
|
9
27
|
* per mount and reads `getToken` (and the other function-typed
|
|
@@ -16,7 +34,7 @@ interface PoolseProviderProps {
|
|
|
16
34
|
* after mount is a no-op (the values are captured at construction
|
|
17
35
|
* time); dev mode logs a warning when this happens.
|
|
18
36
|
*/
|
|
19
|
-
config
|
|
37
|
+
config?: PoolseConfig;
|
|
20
38
|
/**
|
|
21
39
|
* Report this device `active` / `idle` for presence from the browser
|
|
22
40
|
* (`poolse.presence.trackActivity`): idle while the page is hidden,
|
|
@@ -39,10 +57,21 @@ interface PoolseProviderProps {
|
|
|
39
57
|
* </PoolseProvider>
|
|
40
58
|
* ```
|
|
41
59
|
*
|
|
42
|
-
*
|
|
43
|
-
* and drops every joined channel.
|
|
60
|
+
* A `Poolse` instance the provider built from `config` is destroyed on
|
|
61
|
+
* unmount — closes the WebSocket and drops every joined channel. One
|
|
62
|
+
* passed as `client` is left running.
|
|
63
|
+
*
|
|
64
|
+
* Several workspaces, side by side:
|
|
65
|
+
*
|
|
66
|
+
* ```tsx
|
|
67
|
+
* const acme = new Poolse({ apiUrl: 'https://chat.acme.example', getToken: acmeToken });
|
|
68
|
+
* const beta = new Poolse({ apiUrl: 'https://chat.beta.example', getToken: betaToken });
|
|
69
|
+
*
|
|
70
|
+
* <PoolseProvider client={acme}><Workspace /></PoolseProvider>
|
|
71
|
+
* <PoolseProvider client={beta}><Workspace /></PoolseProvider>
|
|
72
|
+
* ```
|
|
44
73
|
*/
|
|
45
|
-
declare function PoolseProvider({ config, trackActivity, children }: PoolseProviderProps): react_jsx_runtime.JSX.Element;
|
|
74
|
+
declare function PoolseProvider({ client, config: configProp, background, trackActivity, children, }: PoolseProviderProps): react_jsx_runtime.JSX.Element;
|
|
46
75
|
/**
|
|
47
76
|
* Access the underlying `Poolse` instance. Most app code should prefer
|
|
48
77
|
* higher-level hooks (`useMessages`, `useTyping`, etc.) but the raw
|
|
@@ -51,6 +80,111 @@ declare function PoolseProvider({ config, trackActivity, children }: PoolseProvi
|
|
|
51
80
|
*/
|
|
52
81
|
declare function usePoolse(): Poolse;
|
|
53
82
|
|
|
83
|
+
interface UseUnreadTotals extends UnreadTotals {
|
|
84
|
+
/** Fetch the totals again. */
|
|
85
|
+
refresh: () => Promise<void>;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Unread and mention totals for one client — every conversation on
|
|
89
|
+
* that server, not just the loaded ones — kept live from realtime.
|
|
90
|
+
*
|
|
91
|
+
* Inside a provider it reads that provider's client; pass a client to
|
|
92
|
+
* read another one (a workspace rail outside every workspace's
|
|
93
|
+
* provider):
|
|
94
|
+
*
|
|
95
|
+
* ```tsx
|
|
96
|
+
* function RailIcon({ client }: { client: Poolse }) {
|
|
97
|
+
* const { unread, mentions } = useUnreadTotals(client);
|
|
98
|
+
* return <Badge count={mentions || unread} strong={mentions > 0} />;
|
|
99
|
+
* }
|
|
100
|
+
* ```
|
|
101
|
+
*
|
|
102
|
+
* Needs the server's `GET /v1/me/unread`; on a server without it the
|
|
103
|
+
* totals are the sum of the loaded conversation list (`source: 'local'`).
|
|
104
|
+
*/
|
|
105
|
+
declare function useUnreadTotals(client?: Poolse): UseUnreadTotals;
|
|
106
|
+
interface UseUnreadQueueOptions {
|
|
107
|
+
/** Conversations with unread mentions come first. Default `false`. */
|
|
108
|
+
mentionsFirst?: boolean;
|
|
109
|
+
/** Leave some conversations out (muted ones, say). */
|
|
110
|
+
filter?: (conversation: Conversation) => boolean;
|
|
111
|
+
}
|
|
112
|
+
interface UseUnreadQueue {
|
|
113
|
+
/** Unread conversations in walk-through order (most recent activity first). */
|
|
114
|
+
queue: Conversation[];
|
|
115
|
+
/** The conversation being read now: stays put after it's marked read, until `next()`. */
|
|
116
|
+
current: Conversation | null;
|
|
117
|
+
/** How many unread conversations remain after `current`. */
|
|
118
|
+
remaining: number;
|
|
119
|
+
/** Mark `current` read and move to the next one. Returns it (null when caught up). */
|
|
120
|
+
next: () => Conversation | null;
|
|
121
|
+
/** Move to the next one without marking `current` read; it's not offered again until `reset()`. */
|
|
122
|
+
skip: () => Conversation | null;
|
|
123
|
+
/** Mark one conversation read up to its latest message. */
|
|
124
|
+
markRead: (conversationId: Uuid) => Promise<void>;
|
|
125
|
+
/** Offer skipped conversations again. */
|
|
126
|
+
reset: () => void;
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Catch up on unreads: the unread conversations one after another —
|
|
130
|
+
* j/k on desktop, a swipe on phones — marking each read as you go.
|
|
131
|
+
* Built on the shared conversation list, so badges everywhere follow.
|
|
132
|
+
*
|
|
133
|
+
* ```tsx
|
|
134
|
+
* const { current, next, skip, remaining } = useUnreadQueue({ mentionsFirst: true });
|
|
135
|
+
* if (!current) return <p>All caught up.</p>;
|
|
136
|
+
* return <CatchUp conversation={current} onNext={next} onSkip={skip} left={remaining} />;
|
|
137
|
+
* ```
|
|
138
|
+
*/
|
|
139
|
+
declare function useUnreadQueue(opts?: UseUnreadQueueOptions): UseUnreadQueue;
|
|
140
|
+
/** Unread conversations, most recent activity first (mentions first if asked). */
|
|
141
|
+
declare function orderUnread(conversations: ReadonlyArray<Conversation>, opts?: UseUnreadQueueOptions): Conversation[];
|
|
142
|
+
|
|
143
|
+
interface UseOutbox {
|
|
144
|
+
/** Unsent messages, oldest first: `queued` (offline), `sending`, `failed`. */
|
|
145
|
+
entries: OutboxEntry[];
|
|
146
|
+
/** How many are `queued` or `sending`. */
|
|
147
|
+
pending: number;
|
|
148
|
+
/** How many the server refused. */
|
|
149
|
+
failed: number;
|
|
150
|
+
/** Send one again now. A still-offline retry stays queued. */
|
|
151
|
+
retry: (id: Uuid) => Promise<void>;
|
|
152
|
+
/** Drop one that hasn't been sent. */
|
|
153
|
+
remove: (id: Uuid) => void;
|
|
154
|
+
/** Try every queued one now. */
|
|
155
|
+
flush: () => Promise<void>;
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* The client's outbox — for an "N messages waiting to send" banner or a
|
|
159
|
+
* list of failed sends. `useMessages` already shows these rows in their
|
|
160
|
+
* conversation; this is the cross-conversation view.
|
|
161
|
+
*/
|
|
162
|
+
declare function useOutbox(opts?: {
|
|
163
|
+
conversationId?: Uuid;
|
|
164
|
+
client?: Poolse;
|
|
165
|
+
}): UseOutbox;
|
|
166
|
+
|
|
167
|
+
/**
|
|
168
|
+
* The client's timings so far, by name (`connect`, `firstConversations`,
|
|
169
|
+
* `firstMessages`, `cachedMessages`, `reconnect`, and the app's own),
|
|
170
|
+
* in milliseconds — re-rendering as new ones are recorded.
|
|
171
|
+
*/
|
|
172
|
+
declare function useClientTimings(client?: Poolse): Record<string, number>;
|
|
173
|
+
|
|
174
|
+
interface ConversationSearchOptions {
|
|
175
|
+
/** Your own external id — left out of a direct chat's names. */
|
|
176
|
+
meExternalId?: string | null;
|
|
177
|
+
/** Names for members' external ids (what the list shows). */
|
|
178
|
+
labelFor?: (externalId: string) => string;
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* Conversations matching `query` (case-insensitive) by name, the other
|
|
182
|
+
* members' names in `labelFor` / external ids, and the last message.
|
|
183
|
+
* An empty query returns the list as is. What `<ConversationList query>`
|
|
184
|
+
* uses on web and React Native.
|
|
185
|
+
*/
|
|
186
|
+
declare function filterConversations<T extends Conversation>(conversations: ReadonlyArray<T>, query: string, opts?: ConversationSearchOptions): T[];
|
|
187
|
+
|
|
54
188
|
interface UseMeState {
|
|
55
189
|
me: Me | null;
|
|
56
190
|
loading: boolean;
|
|
@@ -195,8 +329,24 @@ interface UseMessagesState {
|
|
|
195
329
|
hasMore: boolean;
|
|
196
330
|
/** Load an older page (lower sequence numbers). Idempotent if no older messages exist. */
|
|
197
331
|
loadMore: () => Promise<void>;
|
|
198
|
-
/**
|
|
332
|
+
/**
|
|
333
|
+
* Optimistically append + POST. Replaces the optimistic row with the
|
|
334
|
+
* server response on success.
|
|
335
|
+
*
|
|
336
|
+
* With the client's outbox on (the default), a send that can't reach
|
|
337
|
+
* the server stays in the list as `local_status: 'queued'` and goes
|
|
338
|
+
* out by itself on reconnect (same id, so never twice); the promise
|
|
339
|
+
* rejects with `MessageQueuedError`, which is not a failure to show.
|
|
340
|
+
* A send the server refuses stays as `local_status: 'failed'` (with
|
|
341
|
+
* `local_error`) until `retry(id)` or `discard(id)`; the promise
|
|
342
|
+
* rejects with the server's error. With `outbox: false` a failed
|
|
343
|
+
* send is removed from the list and rejects, as before.
|
|
344
|
+
*/
|
|
199
345
|
send: (attrs: MessageCreateRequest) => Promise<Message>;
|
|
346
|
+
/** Send a queued or failed message again now (the Retry on a failed row). */
|
|
347
|
+
retry: (messageId: Uuid) => Promise<void>;
|
|
348
|
+
/** Remove a queued or failed message that hasn't been sent (the Delete on a failed row). */
|
|
349
|
+
discard: (messageId: Uuid) => void;
|
|
200
350
|
/**
|
|
201
351
|
* Edit a message you previously sent. Optimistically updates the
|
|
202
352
|
* local row, rolls back on server error. Server enforces
|
|
@@ -227,6 +377,11 @@ interface UseMessagesState {
|
|
|
227
377
|
* the user's devices).
|
|
228
378
|
*/
|
|
229
379
|
markReadUpTo: (messageId: Uuid) => Promise<void>;
|
|
380
|
+
/**
|
|
381
|
+
* The messages shown came from the local cache and the server hasn't
|
|
382
|
+
* answered yet (or can't be reached: offline).
|
|
383
|
+
*/
|
|
384
|
+
fromCache: boolean;
|
|
230
385
|
/**
|
|
231
386
|
* Re-fetch the newest page (PAGE_SIZE) and replace the cached
|
|
232
387
|
* messages. Useful when the app returns from background or the
|
|
@@ -256,6 +411,13 @@ interface UseMessagesState {
|
|
|
256
411
|
*
|
|
257
412
|
* Re-mounting with the same `conversationId` reuses the underlying
|
|
258
413
|
* channel — no extra socket traffic.
|
|
414
|
+
*
|
|
415
|
+
* The newest messages of every conversation opened are kept in the
|
|
416
|
+
* client's warm cache (`chat.cache`): opening it again — or switching
|
|
417
|
+
* back to its workspace — shows them at once while the page refetches
|
|
418
|
+
* quietly. With `config.storage` they are also stored, so the history
|
|
419
|
+
* is readable offline and right after a restart. Unsent messages from
|
|
420
|
+
* the outbox show at the end with their `local_status`.
|
|
259
421
|
*/
|
|
260
422
|
declare function useMessages(conversationId: string): UseMessagesState;
|
|
261
423
|
|
|
@@ -631,6 +793,12 @@ interface UseCallRoomOptions {
|
|
|
631
793
|
* Pass `0` to never report it.
|
|
632
794
|
*/
|
|
633
795
|
aloneGraceMs?: number;
|
|
796
|
+
/**
|
|
797
|
+
* Bring the microphone and camera back by themselves when publish
|
|
798
|
+
* permission returns (after accepting recording consent). Defaults to
|
|
799
|
+
* true; false: call `republish` yourself.
|
|
800
|
+
*/
|
|
801
|
+
republishOnPermission?: boolean;
|
|
634
802
|
}
|
|
635
803
|
interface UseCallRoom {
|
|
636
804
|
status: CallRoomStatus;
|
|
@@ -712,6 +880,18 @@ interface UseCallRoom {
|
|
|
712
880
|
/** Share a screen (the platform's picker opens) or stop sharing. */
|
|
713
881
|
setScreenShareEnabled: (enabled: boolean) => Promise<void>;
|
|
714
882
|
toggleScreenShare: () => Promise<void>;
|
|
883
|
+
/**
|
|
884
|
+
* The SFU lets you publish. False while the call is recorded or
|
|
885
|
+
* transcribed under `consent: "required"` and you haven't accepted —
|
|
886
|
+
* show the consent prompt; you still hear and see everyone.
|
|
887
|
+
*/
|
|
888
|
+
canPublish: boolean;
|
|
889
|
+
/**
|
|
890
|
+
* Turn the microphone and camera back on as you last had them. Done
|
|
891
|
+
* for you when publish permission returns unless
|
|
892
|
+
* `republishOnPermission: false`.
|
|
893
|
+
*/
|
|
894
|
+
republish: () => Promise<void>;
|
|
715
895
|
}
|
|
716
896
|
/**
|
|
717
897
|
* A call's media, carried by the SFU.
|
|
@@ -791,6 +971,172 @@ interface UseRoom {
|
|
|
791
971
|
*/
|
|
792
972
|
declare function useRoom(conversationId: string | null, opts: UseRoomOptions): UseRoom;
|
|
793
973
|
|
|
974
|
+
interface UseRecording {
|
|
975
|
+
/** This server can record (LiveKit Egress). False: hide the Record button. */
|
|
976
|
+
available: boolean;
|
|
977
|
+
/** The call is being recorded right now. */
|
|
978
|
+
active: boolean;
|
|
979
|
+
/** The snapshot's recording state, kept live; null until read. */
|
|
980
|
+
recording: CallRecordingState | null;
|
|
981
|
+
/** The live-transcript state, kept live; null until read. */
|
|
982
|
+
transcription: CallTranscriptionState | null;
|
|
983
|
+
/** Something is capturing the call: a recording or a live transcript. */
|
|
984
|
+
capturing: boolean;
|
|
985
|
+
/**
|
|
986
|
+
* Capture needs everyone's consent: whoever hasn't accepted may not
|
|
987
|
+
* publish (the workspace's or room's `consent: "required"`).
|
|
988
|
+
*/
|
|
989
|
+
consentRequired: boolean;
|
|
990
|
+
/** Your answer for this call; `accepted` too when you started the recording. */
|
|
991
|
+
myConsent: ConsentDecision | null;
|
|
992
|
+
/**
|
|
993
|
+
* Show the consent prompt: the call is captured, consent is required
|
|
994
|
+
* and you haven't accepted. Declining keeps it true — you stay
|
|
995
|
+
* listen-only and may change your mind.
|
|
996
|
+
*/
|
|
997
|
+
needsConsent: boolean;
|
|
998
|
+
/**
|
|
999
|
+
* How people were told when the recording started here: `spoken` (the
|
|
1000
|
+
* assistant said it aloud) or `banner` (no speech on this server — your
|
|
1001
|
+
* banner is the notice). Null until a start was seen on this screen.
|
|
1002
|
+
*/
|
|
1003
|
+
notice: 'spoken' | 'banner' | null;
|
|
1004
|
+
/** The latest recording of this call seen in an event (its `status` moves to `ready` or `failed`). */
|
|
1005
|
+
lastRecording: Recording | null;
|
|
1006
|
+
/** A start, stop or consent request is in flight. */
|
|
1007
|
+
pending: boolean;
|
|
1008
|
+
/** The last request's failure (`ApiError.code`: `not_allowed`, `egress_failed`, …), cleared by the next. */
|
|
1009
|
+
error: Error | null;
|
|
1010
|
+
/** Start recording (`mode` defaults to the room's). Resolves false on failure (see `error`). */
|
|
1011
|
+
start: (mode?: RecordingMode) => Promise<boolean>;
|
|
1012
|
+
stop: () => Promise<boolean>;
|
|
1013
|
+
/**
|
|
1014
|
+
* Answer the consent prompt. After `accepted`, the SFU lets you publish
|
|
1015
|
+
* again: `CallRoom` republishes by itself (or use `useCallRoom().republish`).
|
|
1016
|
+
*/
|
|
1017
|
+
consent: (decision: ConsentDecision) => Promise<boolean>;
|
|
1018
|
+
/** Re-read the call snapshot. */
|
|
1019
|
+
refresh: () => void;
|
|
1020
|
+
}
|
|
1021
|
+
/**
|
|
1022
|
+
* A call's recording and consent state, with the actions — what a Record
|
|
1023
|
+
* button, a "Recording" banner and a consent prompt need. Reads the call
|
|
1024
|
+
* snapshot on mount (so a late joiner sees it at once) and after every
|
|
1025
|
+
* reconnect, then follows `recording:*` / `transcript:*` events.
|
|
1026
|
+
*
|
|
1027
|
+
* const rec = useRecording(call.id, call.conversation_id);
|
|
1028
|
+
* {rec.active && <RecordingBanner … />}
|
|
1029
|
+
* {rec.needsConsent && <ConsentPrompt onAnswer={rec.consent} />}
|
|
1030
|
+
*
|
|
1031
|
+
* Pass `initial` (e.g. `useLiveCall().call`) to skip the first read.
|
|
1032
|
+
*/
|
|
1033
|
+
declare function useRecording(callId: string | null, conversationId: string | null, initial?: {
|
|
1034
|
+
id: string;
|
|
1035
|
+
recording?: CallRecordingState;
|
|
1036
|
+
transcription?: CallTranscriptionState;
|
|
1037
|
+
} | null): UseRecording;
|
|
1038
|
+
|
|
1039
|
+
interface UseLiveTranscriptOptions {
|
|
1040
|
+
/** Open the transcript topic. Defaults to true; false leaves it (e.g. the panel is closed). */
|
|
1041
|
+
enabled?: boolean;
|
|
1042
|
+
/** How many final segments to keep. Defaults to 1000. */
|
|
1043
|
+
maxSegments?: number;
|
|
1044
|
+
}
|
|
1045
|
+
interface UseLiveTranscript {
|
|
1046
|
+
/** Final segments in time order, then each speaker's interim one. */
|
|
1047
|
+
segments: LiveTranscriptSegment[];
|
|
1048
|
+
/** Only the final segments. */
|
|
1049
|
+
finals: LiveTranscriptSegment[];
|
|
1050
|
+
/** The speakers' current interim segments (still talking). */
|
|
1051
|
+
interim: LiveTranscriptSegment[];
|
|
1052
|
+
/** The transcript, once one exists for the call (kept live by `transcript:*` events). */
|
|
1053
|
+
transcript: Transcript | null;
|
|
1054
|
+
/** Transcription is running now. */
|
|
1055
|
+
live: boolean;
|
|
1056
|
+
/** The topic is joined and the catch-up has arrived. */
|
|
1057
|
+
joined: boolean;
|
|
1058
|
+
/** The join was refused (`forbidden`, `not_found`), or a start/stop failed. */
|
|
1059
|
+
error: Error | null;
|
|
1060
|
+
pending: boolean;
|
|
1061
|
+
/**
|
|
1062
|
+
* Start (or resume) transcription — someone in the call. Errors:
|
|
1063
|
+
* `not_in_call`, `transcription_disabled`, `transcription_unavailable`.
|
|
1064
|
+
*/
|
|
1065
|
+
start: () => Promise<boolean>;
|
|
1066
|
+
stop: () => Promise<boolean>;
|
|
1067
|
+
}
|
|
1068
|
+
/**
|
|
1069
|
+
* A call's live transcript: joins `transcript:<call_id>` (opening the
|
|
1070
|
+
* transcript — only those who do get the stream), takes the last 200
|
|
1071
|
+
* final segments as catch-up, then folds in each pushed segment, an
|
|
1072
|
+
* interim one replacing the speaker's previous interim. Re-syncs on
|
|
1073
|
+
* every rejoin. `start` / `stop` switch transcription itself on and off.
|
|
1074
|
+
*/
|
|
1075
|
+
declare function useLiveTranscript(callId: string | null, opts?: UseLiveTranscriptOptions): UseLiveTranscript;
|
|
1076
|
+
|
|
1077
|
+
interface UseTranscript {
|
|
1078
|
+
/** The transcript with speakers and segments; null while loading or when there is none. */
|
|
1079
|
+
transcript: TranscriptWithSegments | null;
|
|
1080
|
+
loading: boolean;
|
|
1081
|
+
/** The call was never transcribed (`not_found`). */
|
|
1082
|
+
missing: boolean;
|
|
1083
|
+
error: Error | null;
|
|
1084
|
+
/**
|
|
1085
|
+
* Correct speaker names: key → name, or null to put back the person's
|
|
1086
|
+
* own. For someone who took part in the call or the conversation's
|
|
1087
|
+
* owners and admins — otherwise rejects with `ApiError` `forbidden`.
|
|
1088
|
+
*/
|
|
1089
|
+
renameSpeakers: (names: Record<string, string | null>) => Promise<void>;
|
|
1090
|
+
refresh: () => void;
|
|
1091
|
+
}
|
|
1092
|
+
/**
|
|
1093
|
+
* A call's stored transcript (`GET /v1/calls/:id/transcript`), for a
|
|
1094
|
+
* viewer: speakers, every segment, speaker renames — kept live by
|
|
1095
|
+
* `transcript:speakers` (someone else renaming) and re-read on
|
|
1096
|
+
* `transcript:ready` (the call ended and the transcript is complete).
|
|
1097
|
+
*/
|
|
1098
|
+
declare function useTranscript(callId: string | null): UseTranscript;
|
|
1099
|
+
interface UseCaptureList<T> {
|
|
1100
|
+
items: T[];
|
|
1101
|
+
loading: boolean;
|
|
1102
|
+
error: Error | null;
|
|
1103
|
+
refresh: () => void;
|
|
1104
|
+
}
|
|
1105
|
+
/** A conversation's transcripts, newest first (no segments) — re-read when one becomes ready. */
|
|
1106
|
+
declare function useTranscripts(conversationId: string | null, opts?: {
|
|
1107
|
+
limit?: number;
|
|
1108
|
+
}): UseCaptureList<Transcript>;
|
|
1109
|
+
/**
|
|
1110
|
+
* A conversation's recordings, newest first — re-read as one starts and
|
|
1111
|
+
* finishes. Play or save one with `poolse.calls.recording.downloadUrl(id)`.
|
|
1112
|
+
*/
|
|
1113
|
+
declare function useRecordings(conversationId: string | null, opts?: {
|
|
1114
|
+
limit?: number;
|
|
1115
|
+
}): UseCaptureList<Recording>;
|
|
1116
|
+
|
|
1117
|
+
interface CaptureState {
|
|
1118
|
+
recording: CallRecordingState | null;
|
|
1119
|
+
transcription: CallTranscriptionState | null;
|
|
1120
|
+
}
|
|
1121
|
+
type CaptureEvent = {
|
|
1122
|
+
type: 'recording:started';
|
|
1123
|
+
evt: RecordingStartedEvent;
|
|
1124
|
+
} | {
|
|
1125
|
+
type: 'recording:stopped';
|
|
1126
|
+
evt: RecordingChangedEvent;
|
|
1127
|
+
} | {
|
|
1128
|
+
type: 'recording:ready';
|
|
1129
|
+
evt: RecordingChangedEvent;
|
|
1130
|
+
} | {
|
|
1131
|
+
type: 'recording:consent';
|
|
1132
|
+
evt: RecordingConsentEvent;
|
|
1133
|
+
} | {
|
|
1134
|
+
type: 'transcript:changed';
|
|
1135
|
+
evt: TranscriptChangedEvent;
|
|
1136
|
+
};
|
|
1137
|
+
/** The capture state after one event (pure). */
|
|
1138
|
+
declare function applyCaptureEvent(state: CaptureState, e: CaptureEvent): CaptureState;
|
|
1139
|
+
|
|
794
1140
|
interface UseReadReceipts {
|
|
795
1141
|
/**
|
|
796
1142
|
* Whether this user sees other people's read state. False → show no
|
|
@@ -830,4 +1176,4 @@ declare function canEditOwnMessage(args: {
|
|
|
830
1176
|
now?: number;
|
|
831
1177
|
}): boolean;
|
|
832
1178
|
|
|
833
|
-
export { EDIT_WINDOW_MS, type GroupPosition, type MessageStream, PoolseProvider, type PoolseProviderProps, type ReactionMap, type UploadItem, type UploadItemStatus, type UseCallRoom, type UseCallRoomOptions, type UseLiveCall, type UseReadReceipts, type UseRoom, type UseRoomOptions, type UseUserState, canEditOwnMessage, computeGroupPosition, formatDayLabel, receiptsOf, sameDay, sameGroup, useAppEvent, useAttachmentUpload, useAttachmentUrl, useCallRoom, useConversation, useConversationPresence, useConversations, useLiveCall, useMe, useMembers, useMessageStreams, useMessages, usePoolse, usePresence, usePresenceMany, useReactions, useReadReceipts, useRealtimeStatus, useRoom, useThread, useTyping, useUser, useUserPresence };
|
|
1179
|
+
export { type CaptureEvent, type CaptureState, type ConversationSearchOptions, EDIT_WINDOW_MS, type GroupPosition, type MessageStream, PoolseProvider, type PoolseProviderProps, type ReactionMap, type UploadItem, type UploadItemStatus, type UseCallRoom, type UseCallRoomOptions, type UseCaptureList, type UseLiveCall, type UseLiveTranscript, type UseLiveTranscriptOptions, type UseOutbox, type UseReadReceipts, type UseRecording, type UseRoom, type UseRoomOptions, type UseTranscript, type UseUnreadQueue, type UseUnreadQueueOptions, type UseUnreadTotals, type UseUserState, applyCaptureEvent, canEditOwnMessage, computeGroupPosition, filterConversations, formatDayLabel, orderUnread, receiptsOf, sameDay, sameGroup, useAppEvent, useAttachmentUpload, useAttachmentUrl, useCallRoom, useClientTimings, useConversation, useConversationPresence, useConversations, useLiveCall, useLiveTranscript, useMe, useMembers, useMessageStreams, useMessages, useOutbox, usePoolse, usePresence, usePresenceMany, useReactions, useReadReceipts, useRealtimeStatus, useRecording, useRecordings, useRoom, useThread, useTranscript, useTranscripts, useTyping, useUnreadQueue, useUnreadTotals, useUser, useUserPresence };
|