@poolse/sdk 2.19.0 → 2.21.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 +8 -0
- package/dist/index.cjs +95 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +84 -2
- package/dist/index.d.ts +84 -2
- package/dist/index.js +88 -2
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -2025,8 +2025,90 @@ declare class AuthError extends ApiError {
|
|
|
2025
2025
|
declare function isWebRtcAvailable(): boolean;
|
|
2026
2026
|
declare function createBrowserWebRtcAdapter(): WebRtcAdapter;
|
|
2027
2027
|
|
|
2028
|
-
declare const version = "2.
|
|
2028
|
+
declare const version = "2.20.0";
|
|
2029
|
+
|
|
2030
|
+
type CallLogMedia = 'audio' | 'video';
|
|
2031
|
+
/** A completed (answered or unanswered) call. */
|
|
2032
|
+
interface CallLogEntry {
|
|
2033
|
+
kind: 'call';
|
|
2034
|
+
callId: string;
|
|
2035
|
+
media: CallLogMedia;
|
|
2036
|
+
/** Talk time in ms; `null` when nobody answered. */
|
|
2037
|
+
durationMs: number | null;
|
|
2038
|
+
joinedUserIds: Uuid[];
|
|
2039
|
+
}
|
|
2040
|
+
/** Per-callee "you missed this call" marker. */
|
|
2041
|
+
interface CallMissedEntry {
|
|
2042
|
+
kind: 'call_missed';
|
|
2043
|
+
callId: string;
|
|
2044
|
+
/** The callee who missed the call — the only user who should see it. */
|
|
2045
|
+
userId: Uuid;
|
|
2046
|
+
/** Present when the server includes it; defaults to `'audio'` for display. */
|
|
2047
|
+
media: CallLogMedia | null;
|
|
2048
|
+
}
|
|
2049
|
+
type CallLog = CallLogEntry | CallMissedEntry;
|
|
2050
|
+
/**
|
|
2051
|
+
* Parse a raw message body (or a conversation's `last_message_preview`)
|
|
2052
|
+
* into a call log. Returns null for non-JSON or unknown shapes.
|
|
2053
|
+
*/
|
|
2054
|
+
declare function parseCallLogBody(body: string | null | undefined): CallLog | null;
|
|
2055
|
+
/**
|
|
2056
|
+
* Parse a message into a call log. Only `system` / `custom` messages
|
|
2057
|
+
* are considered; text messages that happen to contain JSON are
|
|
2058
|
+
* never treated as call logs. Deleted messages return null.
|
|
2059
|
+
*/
|
|
2060
|
+
declare function parseCallLog(message: Pick<Message, 'type' | 'body'> & {
|
|
2061
|
+
deleted_at?: string | null;
|
|
2062
|
+
}): CallLog | null;
|
|
2063
|
+
/** True when the message is a call log of either kind. */
|
|
2064
|
+
declare function isCallLogMessage(message: Pick<Message, 'type' | 'body'> & {
|
|
2065
|
+
deleted_at?: string | null;
|
|
2066
|
+
}): boolean;
|
|
2067
|
+
/** `3:12`, `0:05`, `1:02:03`. Rounds to the nearest second. */
|
|
2068
|
+
declare function formatCallDuration(ms: number): string;
|
|
2069
|
+
/** Render-ready description of a call log for one viewer. */
|
|
2070
|
+
interface CallLogDisplay {
|
|
2071
|
+
media: CallLogMedia;
|
|
2072
|
+
/** "Voice call" / "Video call" / "Missed call". */
|
|
2073
|
+
title: string;
|
|
2074
|
+
/** "3:12" when answered, "No answer" when not, null for missed markers. */
|
|
2075
|
+
detail: string | null;
|
|
2076
|
+
/** True for the viewer's own missed-call marker — render in the error tone. */
|
|
2077
|
+
missed: boolean;
|
|
2078
|
+
/** Short one-line form for list previews ("Video call · 3:12"). */
|
|
2079
|
+
summary: string;
|
|
2080
|
+
}
|
|
2081
|
+
/**
|
|
2082
|
+
* Turn a call log into display copy for `currentUserId`. Returns null
|
|
2083
|
+
* when the entry should be hidden for this viewer (a `call_missed`
|
|
2084
|
+
* marker addressed to someone else).
|
|
2085
|
+
*/
|
|
2086
|
+
declare function describeCallLog(log: CallLog, currentUserId: string | null): CallLogDisplay | null;
|
|
2087
|
+
/**
|
|
2088
|
+
* Convenience: parse + describe a message in one go. Returns
|
|
2089
|
+
* `undefined` when the message isn't a call log at all, `null` when
|
|
2090
|
+
* it IS one but is hidden for this viewer, otherwise the display.
|
|
2091
|
+
*/
|
|
2092
|
+
declare function callLogDisplayFor(message: Pick<Message, 'type' | 'body'> & {
|
|
2093
|
+
deleted_at?: string | null;
|
|
2094
|
+
}, currentUserId: string | null): CallLogDisplay | null | undefined;
|
|
2095
|
+
/**
|
|
2096
|
+
* Message filter for list rendering: drops call-log markers that are
|
|
2097
|
+
* hidden for this viewer so they don't affect grouping or day
|
|
2098
|
+
* separators. Every other message passes through untouched.
|
|
2099
|
+
*/
|
|
2100
|
+
declare function isMessageVisibleTo(message: Pick<Message, 'type' | 'body'> & {
|
|
2101
|
+
deleted_at?: string | null;
|
|
2102
|
+
}, currentUserId: string | null): boolean;
|
|
2103
|
+
/**
|
|
2104
|
+
* Conversation-list preview text for a raw body / `last_message_preview`
|
|
2105
|
+
* string. Returns null when the string isn't a call log (show it as-is).
|
|
2106
|
+
* A missed-call marker addressed to someone else reads as a neutral
|
|
2107
|
+
* "Voice call" / "Video call" / "Call" instead of being hidden, since
|
|
2108
|
+
* the list row still needs some text.
|
|
2109
|
+
*/
|
|
2110
|
+
declare function formatCallLogPreview(preview: string | null | undefined, currentUserId: string | null): string | null;
|
|
2029
2111
|
|
|
2030
2112
|
declare function safeUuid(): string;
|
|
2031
2113
|
|
|
2032
|
-
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 CallEnded, type CallMedia, type CallParticipant, CallRoom, type CallRoomOptions, type CallRoomStatus, 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 DevicePlatform, DevicesResource, type ErrorEnvelope, type IceServerResponse, IceServersResource, type IncomingCall, type IsoDateTime, 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, createBrowserWebRtcAdapter, isWebRtcAvailable, safeUuid, version };
|
|
2114
|
+
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 CallEnded, type CallLog, type CallLogDisplay, type CallLogEntry, type CallLogMedia, type CallMedia, type CallMissedEntry, type CallParticipant, CallRoom, type CallRoomOptions, type CallRoomStatus, 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 DevicePlatform, DevicesResource, type ErrorEnvelope, type IceServerResponse, IceServersResource, type IncomingCall, type IsoDateTime, 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 };
|
package/dist/index.d.ts
CHANGED
|
@@ -2025,8 +2025,90 @@ declare class AuthError extends ApiError {
|
|
|
2025
2025
|
declare function isWebRtcAvailable(): boolean;
|
|
2026
2026
|
declare function createBrowserWebRtcAdapter(): WebRtcAdapter;
|
|
2027
2027
|
|
|
2028
|
-
declare const version = "2.
|
|
2028
|
+
declare const version = "2.20.0";
|
|
2029
|
+
|
|
2030
|
+
type CallLogMedia = 'audio' | 'video';
|
|
2031
|
+
/** A completed (answered or unanswered) call. */
|
|
2032
|
+
interface CallLogEntry {
|
|
2033
|
+
kind: 'call';
|
|
2034
|
+
callId: string;
|
|
2035
|
+
media: CallLogMedia;
|
|
2036
|
+
/** Talk time in ms; `null` when nobody answered. */
|
|
2037
|
+
durationMs: number | null;
|
|
2038
|
+
joinedUserIds: Uuid[];
|
|
2039
|
+
}
|
|
2040
|
+
/** Per-callee "you missed this call" marker. */
|
|
2041
|
+
interface CallMissedEntry {
|
|
2042
|
+
kind: 'call_missed';
|
|
2043
|
+
callId: string;
|
|
2044
|
+
/** The callee who missed the call — the only user who should see it. */
|
|
2045
|
+
userId: Uuid;
|
|
2046
|
+
/** Present when the server includes it; defaults to `'audio'` for display. */
|
|
2047
|
+
media: CallLogMedia | null;
|
|
2048
|
+
}
|
|
2049
|
+
type CallLog = CallLogEntry | CallMissedEntry;
|
|
2050
|
+
/**
|
|
2051
|
+
* Parse a raw message body (or a conversation's `last_message_preview`)
|
|
2052
|
+
* into a call log. Returns null for non-JSON or unknown shapes.
|
|
2053
|
+
*/
|
|
2054
|
+
declare function parseCallLogBody(body: string | null | undefined): CallLog | null;
|
|
2055
|
+
/**
|
|
2056
|
+
* Parse a message into a call log. Only `system` / `custom` messages
|
|
2057
|
+
* are considered; text messages that happen to contain JSON are
|
|
2058
|
+
* never treated as call logs. Deleted messages return null.
|
|
2059
|
+
*/
|
|
2060
|
+
declare function parseCallLog(message: Pick<Message, 'type' | 'body'> & {
|
|
2061
|
+
deleted_at?: string | null;
|
|
2062
|
+
}): CallLog | null;
|
|
2063
|
+
/** True when the message is a call log of either kind. */
|
|
2064
|
+
declare function isCallLogMessage(message: Pick<Message, 'type' | 'body'> & {
|
|
2065
|
+
deleted_at?: string | null;
|
|
2066
|
+
}): boolean;
|
|
2067
|
+
/** `3:12`, `0:05`, `1:02:03`. Rounds to the nearest second. */
|
|
2068
|
+
declare function formatCallDuration(ms: number): string;
|
|
2069
|
+
/** Render-ready description of a call log for one viewer. */
|
|
2070
|
+
interface CallLogDisplay {
|
|
2071
|
+
media: CallLogMedia;
|
|
2072
|
+
/** "Voice call" / "Video call" / "Missed call". */
|
|
2073
|
+
title: string;
|
|
2074
|
+
/** "3:12" when answered, "No answer" when not, null for missed markers. */
|
|
2075
|
+
detail: string | null;
|
|
2076
|
+
/** True for the viewer's own missed-call marker — render in the error tone. */
|
|
2077
|
+
missed: boolean;
|
|
2078
|
+
/** Short one-line form for list previews ("Video call · 3:12"). */
|
|
2079
|
+
summary: string;
|
|
2080
|
+
}
|
|
2081
|
+
/**
|
|
2082
|
+
* Turn a call log into display copy for `currentUserId`. Returns null
|
|
2083
|
+
* when the entry should be hidden for this viewer (a `call_missed`
|
|
2084
|
+
* marker addressed to someone else).
|
|
2085
|
+
*/
|
|
2086
|
+
declare function describeCallLog(log: CallLog, currentUserId: string | null): CallLogDisplay | null;
|
|
2087
|
+
/**
|
|
2088
|
+
* Convenience: parse + describe a message in one go. Returns
|
|
2089
|
+
* `undefined` when the message isn't a call log at all, `null` when
|
|
2090
|
+
* it IS one but is hidden for this viewer, otherwise the display.
|
|
2091
|
+
*/
|
|
2092
|
+
declare function callLogDisplayFor(message: Pick<Message, 'type' | 'body'> & {
|
|
2093
|
+
deleted_at?: string | null;
|
|
2094
|
+
}, currentUserId: string | null): CallLogDisplay | null | undefined;
|
|
2095
|
+
/**
|
|
2096
|
+
* Message filter for list rendering: drops call-log markers that are
|
|
2097
|
+
* hidden for this viewer so they don't affect grouping or day
|
|
2098
|
+
* separators. Every other message passes through untouched.
|
|
2099
|
+
*/
|
|
2100
|
+
declare function isMessageVisibleTo(message: Pick<Message, 'type' | 'body'> & {
|
|
2101
|
+
deleted_at?: string | null;
|
|
2102
|
+
}, currentUserId: string | null): boolean;
|
|
2103
|
+
/**
|
|
2104
|
+
* Conversation-list preview text for a raw body / `last_message_preview`
|
|
2105
|
+
* string. Returns null when the string isn't a call log (show it as-is).
|
|
2106
|
+
* A missed-call marker addressed to someone else reads as a neutral
|
|
2107
|
+
* "Voice call" / "Video call" / "Call" instead of being hidden, since
|
|
2108
|
+
* the list row still needs some text.
|
|
2109
|
+
*/
|
|
2110
|
+
declare function formatCallLogPreview(preview: string | null | undefined, currentUserId: string | null): string | null;
|
|
2029
2111
|
|
|
2030
2112
|
declare function safeUuid(): string;
|
|
2031
2113
|
|
|
2032
|
-
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 CallEnded, type CallMedia, type CallParticipant, CallRoom, type CallRoomOptions, type CallRoomStatus, 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 DevicePlatform, DevicesResource, type ErrorEnvelope, type IceServerResponse, IceServersResource, type IncomingCall, type IsoDateTime, 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, createBrowserWebRtcAdapter, isWebRtcAvailable, safeUuid, version };
|
|
2114
|
+
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 CallEnded, type CallLog, type CallLogDisplay, type CallLogEntry, type CallLogMedia, type CallMedia, type CallMissedEntry, type CallParticipant, CallRoom, type CallRoomOptions, type CallRoomStatus, 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 DevicePlatform, DevicesResource, type ErrorEnvelope, type IceServerResponse, IceServersResource, type IncomingCall, type IsoDateTime, 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 };
|
package/dist/index.js
CHANGED
|
@@ -2453,8 +2453,94 @@ var Poolse = class {
|
|
|
2453
2453
|
};
|
|
2454
2454
|
|
|
2455
2455
|
// src/version.ts
|
|
2456
|
-
var version = "2.
|
|
2456
|
+
var version = "2.20.0";
|
|
2457
2457
|
|
|
2458
|
-
|
|
2458
|
+
// src/call-log.ts
|
|
2459
|
+
function parseCallLogBody(body) {
|
|
2460
|
+
if (typeof body !== "string") return null;
|
|
2461
|
+
const trimmed = body.trim();
|
|
2462
|
+
if (!trimmed.startsWith("{") || !trimmed.includes('"kind"')) return null;
|
|
2463
|
+
let raw;
|
|
2464
|
+
try {
|
|
2465
|
+
raw = JSON.parse(trimmed);
|
|
2466
|
+
} catch {
|
|
2467
|
+
return null;
|
|
2468
|
+
}
|
|
2469
|
+
if (!raw || typeof raw !== "object" || Array.isArray(raw)) return null;
|
|
2470
|
+
const obj = raw;
|
|
2471
|
+
const callId = typeof obj.call_id === "string" ? obj.call_id : null;
|
|
2472
|
+
if (!callId) return null;
|
|
2473
|
+
const media = obj.media === "audio" || obj.media === "video" ? obj.media : null;
|
|
2474
|
+
if (obj.kind === "call") {
|
|
2475
|
+
const d = obj.duration_ms;
|
|
2476
|
+
const durationMs = typeof d === "number" && Number.isFinite(d) && d >= 0 ? d : null;
|
|
2477
|
+
const joined = Array.isArray(obj.joined_user_ids) ? obj.joined_user_ids.filter((u) => typeof u === "string") : [];
|
|
2478
|
+
return {
|
|
2479
|
+
kind: "call",
|
|
2480
|
+
callId,
|
|
2481
|
+
media: media ?? "audio",
|
|
2482
|
+
durationMs,
|
|
2483
|
+
joinedUserIds: joined
|
|
2484
|
+
};
|
|
2485
|
+
}
|
|
2486
|
+
if (obj.kind === "call_missed") {
|
|
2487
|
+
if (typeof obj.user_id !== "string" || obj.user_id === "") return null;
|
|
2488
|
+
return { kind: "call_missed", callId, userId: obj.user_id, media };
|
|
2489
|
+
}
|
|
2490
|
+
return null;
|
|
2491
|
+
}
|
|
2492
|
+
function parseCallLog(message) {
|
|
2493
|
+
if (message.type !== "system" && message.type !== "custom") return null;
|
|
2494
|
+
if (message.deleted_at) return null;
|
|
2495
|
+
return parseCallLogBody(message.body);
|
|
2496
|
+
}
|
|
2497
|
+
function isCallLogMessage(message) {
|
|
2498
|
+
return parseCallLog(message) !== null;
|
|
2499
|
+
}
|
|
2500
|
+
function formatCallDuration(ms) {
|
|
2501
|
+
const total = Math.max(0, Math.round(ms / 1e3));
|
|
2502
|
+
const h = Math.floor(total / 3600);
|
|
2503
|
+
const m = Math.floor(total % 3600 / 60);
|
|
2504
|
+
const s = total % 60;
|
|
2505
|
+
const ss = String(s).padStart(2, "0");
|
|
2506
|
+
if (h > 0) return `${h}:${String(m).padStart(2, "0")}:${ss}`;
|
|
2507
|
+
return `${m}:${ss}`;
|
|
2508
|
+
}
|
|
2509
|
+
function describeCallLog(log, currentUserId) {
|
|
2510
|
+
if (log.kind === "call_missed") {
|
|
2511
|
+
if (currentUserId === null || log.userId !== currentUserId) return null;
|
|
2512
|
+
const media = log.media ?? "audio";
|
|
2513
|
+
return { media, title: "Missed call", detail: null, missed: true, summary: "Missed call" };
|
|
2514
|
+
}
|
|
2515
|
+
const title = log.media === "video" ? "Video call" : "Voice call";
|
|
2516
|
+
const detail = log.durationMs !== null ? formatCallDuration(log.durationMs) : "No answer";
|
|
2517
|
+
return {
|
|
2518
|
+
media: log.media,
|
|
2519
|
+
title,
|
|
2520
|
+
detail,
|
|
2521
|
+
missed: false,
|
|
2522
|
+
summary: `${title} \xB7 ${detail}`
|
|
2523
|
+
};
|
|
2524
|
+
}
|
|
2525
|
+
function callLogDisplayFor(message, currentUserId) {
|
|
2526
|
+
const log = parseCallLog(message);
|
|
2527
|
+
if (!log) return void 0;
|
|
2528
|
+
return describeCallLog(log, currentUserId);
|
|
2529
|
+
}
|
|
2530
|
+
function isMessageVisibleTo(message, currentUserId) {
|
|
2531
|
+
return callLogDisplayFor(message, currentUserId) !== null;
|
|
2532
|
+
}
|
|
2533
|
+
function formatCallLogPreview(preview, currentUserId) {
|
|
2534
|
+
const log = parseCallLogBody(preview);
|
|
2535
|
+
if (!log) return null;
|
|
2536
|
+
const display = describeCallLog(log, currentUserId);
|
|
2537
|
+
if (display) return display.summary;
|
|
2538
|
+
if (log.kind === "call_missed" && log.media) {
|
|
2539
|
+
return log.media === "video" ? "Video call" : "Voice call";
|
|
2540
|
+
}
|
|
2541
|
+
return "Call";
|
|
2542
|
+
}
|
|
2543
|
+
|
|
2544
|
+
export { ApiError, AttachmentHandle, AttachmentsResource, AuthError, CallRoom, CallTokensResource, CallsResource, ConversationChannel, ConversationHandle, ConversationMessages, ConversationsResource, DevicesResource, IceServersResource, 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 };
|
|
2459
2545
|
//# sourceMappingURL=index.js.map
|
|
2460
2546
|
//# sourceMappingURL=index.js.map
|