@antzsoft/chat-core 1.3.7 → 1.3.9
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/README.md +95 -1
- package/dist/index.cjs +89 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +63 -3
- package/dist/index.d.ts +63 -3
- package/dist/index.js +83 -1
- package/dist/index.js.map +1 -1
- package/dist/internal.d.cts +1 -1
- package/dist/internal.d.ts +1 -1
- package/dist/{storage-DJh54pps.d.cts → storage-C_b-SFFH.d.cts} +29 -1
- package/dist/{storage-DJh54pps.d.ts → storage-C_b-SFFH.d.ts} +29 -1
- package/docs/integration-guide.html +68 -3
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { R as ResolvedCompressionConfig, L as LoginCredentials, A as AuthResponse, a as RegisterData, b as AuthTokens, U as User, C as CrossConversationSyncResponse, c as ConversationSyncResponse, d as AppConfig, S as SendMessagePayload, e as CursorPaginatedResponse, M as Message, f as MessageReactionsResponse, P as PaginatedResponse, g as MessageReceiptsResponse, h as ConversationListParams, i as Conversation, j as Participant, k as ConversationUnreadCount, l as UnreadSummary, m as UserPreferences, n as ResolvedConfig, o as PersistStorage, p as PresignedUrlRequest, q as PresignedUrlResponse, F as FileResponse, r as CompletedPart, s as FileType, t as AntzChatConfig, u as UploadableFile, B as BatchUploadResult } from './storage-
|
|
2
|
-
export { v as Attachment, w as CompressedFile, x as CompressionAlgorithm, y as CompressionConfig, z as ConversationType, D as ConversationUpdatedEvent, E as FileSizeLimits, G as LastReaction, H as
|
|
1
|
+
import { R as ResolvedCompressionConfig, L as LoginCredentials, A as AuthResponse, a as RegisterData, b as AuthTokens, U as User, C as CrossConversationSyncResponse, c as ConversationSyncResponse, d as AppConfig, S as SendMessagePayload, e as CursorPaginatedResponse, M as Message, f as MessageReactionsResponse, P as PaginatedResponse, g as MessageReceiptsResponse, h as ConversationListParams, i as Conversation, j as Participant, k as ConversationUnreadCount, l as UnreadSummary, m as UserPreferences, n as ResolvedConfig, o as PersistStorage, p as PresignedUrlRequest, q as PresignedUrlResponse, F as FileResponse, r as CompletedPart, s as FileType, t as AntzChatConfig, u as UploadableFile, B as BatchUploadResult } from './storage-C_b-SFFH.cjs';
|
|
2
|
+
export { v as Attachment, w as CompressedFile, x as CompressionAlgorithm, y as CompressionConfig, z as ConversationType, D as ConversationUpdatedEvent, E as FileSizeLimits, G as LastReaction, H as MENTION_ALL_ID, I as MessageAckEvent, J as MessageContent, K as MessageDeletedEvent, N as MessageDeletedForMeEvent, O as MessageDeliveredEvent, Q as MessageMetadata, T as MessageReaction, V as MessageReceiptEntry, W as MessageReplyReference, X as MessageStarUpdatedEvent, Y as MessageUpdatedEvent, Z as MessagesDeliveredEvent, _ as MultipartPartUrl, $ as MultipartUploadInfo, a0 as NewMessageEvent, a1 as OptimisticAttachment, a2 as PlatformCompressFn, a3 as PlatformUploadFn, a4 as PlatformUploadPartFn, a5 as QuietHours, a6 as ReactionGroup, a7 as ReactionUpdatedEvent, a8 as ReactionUser, a9 as ReadReceiptEvent, aa as ReplyAttachmentSnapshot, ab as ResolvedFileSizeLimits, ac as SendMessageAttachment, ad as SyncDeletedForMe, ae as SyncDeliveredReceipt, af as SyncParticipantChange, ag as SyncReactionEntry, ah as SyncReactions, ai as SyncReadReceipt, aj as SyncStarEntry, ak as SystemMessageMetadata, al as TypingIndicatorEvent, am as UploadConfig, an as UploadProgress, ao as UserStatusEvent, ap as resolveConfig, aq as storageApi, ar as uploadBatch } from './storage-C_b-SFFH.cjs';
|
|
3
3
|
import { AxiosInstance } from 'axios';
|
|
4
4
|
import { Socket } from 'socket.io-client';
|
|
5
5
|
import * as zustand_middleware from 'zustand/middleware';
|
|
@@ -536,6 +536,66 @@ declare function normalizeAxiosError(error: unknown): AntzChatError;
|
|
|
536
536
|
*/
|
|
537
537
|
declare function resolveSystemMessageText(message: Message, currentUserId: string): string;
|
|
538
538
|
|
|
539
|
+
interface ParsedMention {
|
|
540
|
+
/** userId, or "all" */
|
|
541
|
+
id: string;
|
|
542
|
+
/** display name captured from the token (fallback for rendering) */
|
|
543
|
+
displayName: string;
|
|
544
|
+
/** start index of the whole token in the text (UTF-16) */
|
|
545
|
+
start: number;
|
|
546
|
+
/** end index (exclusive) of the whole token in the text (UTF-16) */
|
|
547
|
+
end: number;
|
|
548
|
+
}
|
|
549
|
+
/** A segment of a message: either plain text or a mention to render specially. */
|
|
550
|
+
type MentionPart = {
|
|
551
|
+
type: 'text';
|
|
552
|
+
text: string;
|
|
553
|
+
} | {
|
|
554
|
+
type: 'mention';
|
|
555
|
+
id: string;
|
|
556
|
+
displayName: string;
|
|
557
|
+
};
|
|
558
|
+
/**
|
|
559
|
+
* A piece used to compose outgoing text. Plain strings pass through verbatim;
|
|
560
|
+
* mention objects are serialized to `@[displayName](id)` tokens.
|
|
561
|
+
*/
|
|
562
|
+
type MentionSegment = string | {
|
|
563
|
+
id: string;
|
|
564
|
+
displayName: string;
|
|
565
|
+
};
|
|
566
|
+
/**
|
|
567
|
+
* Finds every `@[name](id)` mention token in the text, in order of appearance.
|
|
568
|
+
* Pure/computed — nothing is stored. Safe to call on every render.
|
|
569
|
+
*/
|
|
570
|
+
declare function parseMentions(text: string | undefined | null): ParsedMention[];
|
|
571
|
+
/**
|
|
572
|
+
* Splits text into ordered parts (plain text + mentions) for rendering.
|
|
573
|
+
* The caller supplies `resolveName(id, fallbackName)` to look up the current
|
|
574
|
+
* display name from its own directory; return the fallback when unresolvable.
|
|
575
|
+
* When no resolver is given, the token's embedded name is used.
|
|
576
|
+
*/
|
|
577
|
+
declare function renderMentionParts(text: string | undefined | null, resolveName?: (id: string, fallbackName: string) => string): MentionPart[];
|
|
578
|
+
/**
|
|
579
|
+
* Builds outgoing message text + the `mentions` id array from composer segments.
|
|
580
|
+
* Deduplicates ids (a user mentioned twice is fanned out once).
|
|
581
|
+
*
|
|
582
|
+
* Example:
|
|
583
|
+
* buildMentionText(['Hey ', { id: 'u1', displayName: 'Alice' }, ', look'])
|
|
584
|
+
* → { text: 'Hey @[Alice](u1), look', mentions: ['u1'] }
|
|
585
|
+
*/
|
|
586
|
+
declare function buildMentionText(segments: MentionSegment[]): {
|
|
587
|
+
text: string;
|
|
588
|
+
mentions: string[];
|
|
589
|
+
};
|
|
590
|
+
/**
|
|
591
|
+
* Re-derives the `mentions` id array from message text — the source of truth is
|
|
592
|
+
* always the tokens present in the text. Use this after an edit so a mention whose
|
|
593
|
+
* token was removed drops out of the array (FR-10).
|
|
594
|
+
*/
|
|
595
|
+
declare function extractMentionIds(text: string | undefined | null): string[];
|
|
596
|
+
/** True when the mentions list targets everyone (@all). */
|
|
597
|
+
declare function isMentionAll(mentions: string[] | undefined): boolean;
|
|
598
|
+
|
|
539
599
|
interface ClientSocketHandle {
|
|
540
600
|
emit: typeof socketEmit;
|
|
541
601
|
on(event: string, handler: (...args: unknown[]) => void): void;
|
|
@@ -667,4 +727,4 @@ declare class AntzChatClient {
|
|
|
667
727
|
uploadIcon(conversationId: string, file: UploadableFile): Promise<Conversation>;
|
|
668
728
|
}
|
|
669
729
|
|
|
670
|
-
export { AntzChatAuthError, AntzChatClient, AntzChatConfig, AntzChatError, AntzChatNetworkError, AntzChatPermissionError, AntzChatServerError, AntzChatValidationError, AppConfig, AuthResponse, AuthTokens, BatchUploadResult, CompletedPart, Conversation, ConversationListParams, ConversationSyncResponse, ConversationUnreadCount, type CreateDirectData, type CreateGroupData, CrossConversationSyncResponse, CursorPaginatedResponse, FileResponse, FileType, type LastReadEntry, type ListMessagesParams, LoginCredentials, Message, MessageReactionsResponse, MessageReceiptsResponse, type MobileDeviceToken, PaginatedResponse, Participant, PersistStorage, PresignedUrlRequest, PresignedUrlResponse, RegisterData, type RegisterDeviceTokenPayload, ResolvedCompressionConfig, ResolvedConfig, type SearchParams, type SendData, SendMessagePayload, type SocketStatus, type StatusListener, type TokenStore, UnreadSummary, type UpdateConversationData, type UpdateProfilePayload, UploadableFile, User, UserPreferences, type WebPushDeviceToken, appConfigApi, authApi, connectSocket, conversationsApi, createAuthStore, createRestTransitSession, decryptPayload, devicesApi, disconnectSocket, encryptPayload, fetchServerKeys, generateEphemeralKey, getApiClient, getAuthStore, getCompressionStrategy, getSessionId, getSessionKey, getSocket, getSocketStatus, initApiClient, initAuthStore, isTransitEnvelope, messagesApi, normalizeAxiosError, normalizeConversation, onSocketStatus, performHandshake, reconnectSocket, refreshSocketAuth, resetAuthStore, resolveSystemMessageText, setApiClientInstance, setTransitSession, socketEmit, syncApi, tryGetSocket, useChatStore, usersApi };
|
|
730
|
+
export { AntzChatAuthError, AntzChatClient, AntzChatConfig, AntzChatError, AntzChatNetworkError, AntzChatPermissionError, AntzChatServerError, AntzChatValidationError, AppConfig, AuthResponse, AuthTokens, BatchUploadResult, CompletedPart, Conversation, ConversationListParams, ConversationSyncResponse, ConversationUnreadCount, type CreateDirectData, type CreateGroupData, CrossConversationSyncResponse, CursorPaginatedResponse, FileResponse, FileType, type LastReadEntry, type ListMessagesParams, LoginCredentials, type MentionPart, type MentionSegment, Message, MessageReactionsResponse, MessageReceiptsResponse, type MobileDeviceToken, PaginatedResponse, type ParsedMention, Participant, PersistStorage, PresignedUrlRequest, PresignedUrlResponse, RegisterData, type RegisterDeviceTokenPayload, ResolvedCompressionConfig, ResolvedConfig, type SearchParams, type SendData, SendMessagePayload, type SocketStatus, type StatusListener, type TokenStore, UnreadSummary, type UpdateConversationData, type UpdateProfilePayload, UploadableFile, User, UserPreferences, type WebPushDeviceToken, appConfigApi, authApi, buildMentionText, connectSocket, conversationsApi, createAuthStore, createRestTransitSession, decryptPayload, devicesApi, disconnectSocket, encryptPayload, extractMentionIds, fetchServerKeys, generateEphemeralKey, getApiClient, getAuthStore, getCompressionStrategy, getSessionId, getSessionKey, getSocket, getSocketStatus, initApiClient, initAuthStore, isMentionAll, isTransitEnvelope, messagesApi, normalizeAxiosError, normalizeConversation, onSocketStatus, parseMentions, performHandshake, reconnectSocket, refreshSocketAuth, renderMentionParts, resetAuthStore, resolveSystemMessageText, setApiClientInstance, setTransitSession, socketEmit, syncApi, tryGetSocket, useChatStore, usersApi };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { R as ResolvedCompressionConfig, L as LoginCredentials, A as AuthResponse, a as RegisterData, b as AuthTokens, U as User, C as CrossConversationSyncResponse, c as ConversationSyncResponse, d as AppConfig, S as SendMessagePayload, e as CursorPaginatedResponse, M as Message, f as MessageReactionsResponse, P as PaginatedResponse, g as MessageReceiptsResponse, h as ConversationListParams, i as Conversation, j as Participant, k as ConversationUnreadCount, l as UnreadSummary, m as UserPreferences, n as ResolvedConfig, o as PersistStorage, p as PresignedUrlRequest, q as PresignedUrlResponse, F as FileResponse, r as CompletedPart, s as FileType, t as AntzChatConfig, u as UploadableFile, B as BatchUploadResult } from './storage-
|
|
2
|
-
export { v as Attachment, w as CompressedFile, x as CompressionAlgorithm, y as CompressionConfig, z as ConversationType, D as ConversationUpdatedEvent, E as FileSizeLimits, G as LastReaction, H as
|
|
1
|
+
import { R as ResolvedCompressionConfig, L as LoginCredentials, A as AuthResponse, a as RegisterData, b as AuthTokens, U as User, C as CrossConversationSyncResponse, c as ConversationSyncResponse, d as AppConfig, S as SendMessagePayload, e as CursorPaginatedResponse, M as Message, f as MessageReactionsResponse, P as PaginatedResponse, g as MessageReceiptsResponse, h as ConversationListParams, i as Conversation, j as Participant, k as ConversationUnreadCount, l as UnreadSummary, m as UserPreferences, n as ResolvedConfig, o as PersistStorage, p as PresignedUrlRequest, q as PresignedUrlResponse, F as FileResponse, r as CompletedPart, s as FileType, t as AntzChatConfig, u as UploadableFile, B as BatchUploadResult } from './storage-C_b-SFFH.js';
|
|
2
|
+
export { v as Attachment, w as CompressedFile, x as CompressionAlgorithm, y as CompressionConfig, z as ConversationType, D as ConversationUpdatedEvent, E as FileSizeLimits, G as LastReaction, H as MENTION_ALL_ID, I as MessageAckEvent, J as MessageContent, K as MessageDeletedEvent, N as MessageDeletedForMeEvent, O as MessageDeliveredEvent, Q as MessageMetadata, T as MessageReaction, V as MessageReceiptEntry, W as MessageReplyReference, X as MessageStarUpdatedEvent, Y as MessageUpdatedEvent, Z as MessagesDeliveredEvent, _ as MultipartPartUrl, $ as MultipartUploadInfo, a0 as NewMessageEvent, a1 as OptimisticAttachment, a2 as PlatformCompressFn, a3 as PlatformUploadFn, a4 as PlatformUploadPartFn, a5 as QuietHours, a6 as ReactionGroup, a7 as ReactionUpdatedEvent, a8 as ReactionUser, a9 as ReadReceiptEvent, aa as ReplyAttachmentSnapshot, ab as ResolvedFileSizeLimits, ac as SendMessageAttachment, ad as SyncDeletedForMe, ae as SyncDeliveredReceipt, af as SyncParticipantChange, ag as SyncReactionEntry, ah as SyncReactions, ai as SyncReadReceipt, aj as SyncStarEntry, ak as SystemMessageMetadata, al as TypingIndicatorEvent, am as UploadConfig, an as UploadProgress, ao as UserStatusEvent, ap as resolveConfig, aq as storageApi, ar as uploadBatch } from './storage-C_b-SFFH.js';
|
|
3
3
|
import { AxiosInstance } from 'axios';
|
|
4
4
|
import { Socket } from 'socket.io-client';
|
|
5
5
|
import * as zustand_middleware from 'zustand/middleware';
|
|
@@ -536,6 +536,66 @@ declare function normalizeAxiosError(error: unknown): AntzChatError;
|
|
|
536
536
|
*/
|
|
537
537
|
declare function resolveSystemMessageText(message: Message, currentUserId: string): string;
|
|
538
538
|
|
|
539
|
+
interface ParsedMention {
|
|
540
|
+
/** userId, or "all" */
|
|
541
|
+
id: string;
|
|
542
|
+
/** display name captured from the token (fallback for rendering) */
|
|
543
|
+
displayName: string;
|
|
544
|
+
/** start index of the whole token in the text (UTF-16) */
|
|
545
|
+
start: number;
|
|
546
|
+
/** end index (exclusive) of the whole token in the text (UTF-16) */
|
|
547
|
+
end: number;
|
|
548
|
+
}
|
|
549
|
+
/** A segment of a message: either plain text or a mention to render specially. */
|
|
550
|
+
type MentionPart = {
|
|
551
|
+
type: 'text';
|
|
552
|
+
text: string;
|
|
553
|
+
} | {
|
|
554
|
+
type: 'mention';
|
|
555
|
+
id: string;
|
|
556
|
+
displayName: string;
|
|
557
|
+
};
|
|
558
|
+
/**
|
|
559
|
+
* A piece used to compose outgoing text. Plain strings pass through verbatim;
|
|
560
|
+
* mention objects are serialized to `@[displayName](id)` tokens.
|
|
561
|
+
*/
|
|
562
|
+
type MentionSegment = string | {
|
|
563
|
+
id: string;
|
|
564
|
+
displayName: string;
|
|
565
|
+
};
|
|
566
|
+
/**
|
|
567
|
+
* Finds every `@[name](id)` mention token in the text, in order of appearance.
|
|
568
|
+
* Pure/computed — nothing is stored. Safe to call on every render.
|
|
569
|
+
*/
|
|
570
|
+
declare function parseMentions(text: string | undefined | null): ParsedMention[];
|
|
571
|
+
/**
|
|
572
|
+
* Splits text into ordered parts (plain text + mentions) for rendering.
|
|
573
|
+
* The caller supplies `resolveName(id, fallbackName)` to look up the current
|
|
574
|
+
* display name from its own directory; return the fallback when unresolvable.
|
|
575
|
+
* When no resolver is given, the token's embedded name is used.
|
|
576
|
+
*/
|
|
577
|
+
declare function renderMentionParts(text: string | undefined | null, resolveName?: (id: string, fallbackName: string) => string): MentionPart[];
|
|
578
|
+
/**
|
|
579
|
+
* Builds outgoing message text + the `mentions` id array from composer segments.
|
|
580
|
+
* Deduplicates ids (a user mentioned twice is fanned out once).
|
|
581
|
+
*
|
|
582
|
+
* Example:
|
|
583
|
+
* buildMentionText(['Hey ', { id: 'u1', displayName: 'Alice' }, ', look'])
|
|
584
|
+
* → { text: 'Hey @[Alice](u1), look', mentions: ['u1'] }
|
|
585
|
+
*/
|
|
586
|
+
declare function buildMentionText(segments: MentionSegment[]): {
|
|
587
|
+
text: string;
|
|
588
|
+
mentions: string[];
|
|
589
|
+
};
|
|
590
|
+
/**
|
|
591
|
+
* Re-derives the `mentions` id array from message text — the source of truth is
|
|
592
|
+
* always the tokens present in the text. Use this after an edit so a mention whose
|
|
593
|
+
* token was removed drops out of the array (FR-10).
|
|
594
|
+
*/
|
|
595
|
+
declare function extractMentionIds(text: string | undefined | null): string[];
|
|
596
|
+
/** True when the mentions list targets everyone (@all). */
|
|
597
|
+
declare function isMentionAll(mentions: string[] | undefined): boolean;
|
|
598
|
+
|
|
539
599
|
interface ClientSocketHandle {
|
|
540
600
|
emit: typeof socketEmit;
|
|
541
601
|
on(event: string, handler: (...args: unknown[]) => void): void;
|
|
@@ -667,4 +727,4 @@ declare class AntzChatClient {
|
|
|
667
727
|
uploadIcon(conversationId: string, file: UploadableFile): Promise<Conversation>;
|
|
668
728
|
}
|
|
669
729
|
|
|
670
|
-
export { AntzChatAuthError, AntzChatClient, AntzChatConfig, AntzChatError, AntzChatNetworkError, AntzChatPermissionError, AntzChatServerError, AntzChatValidationError, AppConfig, AuthResponse, AuthTokens, BatchUploadResult, CompletedPart, Conversation, ConversationListParams, ConversationSyncResponse, ConversationUnreadCount, type CreateDirectData, type CreateGroupData, CrossConversationSyncResponse, CursorPaginatedResponse, FileResponse, FileType, type LastReadEntry, type ListMessagesParams, LoginCredentials, Message, MessageReactionsResponse, MessageReceiptsResponse, type MobileDeviceToken, PaginatedResponse, Participant, PersistStorage, PresignedUrlRequest, PresignedUrlResponse, RegisterData, type RegisterDeviceTokenPayload, ResolvedCompressionConfig, ResolvedConfig, type SearchParams, type SendData, SendMessagePayload, type SocketStatus, type StatusListener, type TokenStore, UnreadSummary, type UpdateConversationData, type UpdateProfilePayload, UploadableFile, User, UserPreferences, type WebPushDeviceToken, appConfigApi, authApi, connectSocket, conversationsApi, createAuthStore, createRestTransitSession, decryptPayload, devicesApi, disconnectSocket, encryptPayload, fetchServerKeys, generateEphemeralKey, getApiClient, getAuthStore, getCompressionStrategy, getSessionId, getSessionKey, getSocket, getSocketStatus, initApiClient, initAuthStore, isTransitEnvelope, messagesApi, normalizeAxiosError, normalizeConversation, onSocketStatus, performHandshake, reconnectSocket, refreshSocketAuth, resetAuthStore, resolveSystemMessageText, setApiClientInstance, setTransitSession, socketEmit, syncApi, tryGetSocket, useChatStore, usersApi };
|
|
730
|
+
export { AntzChatAuthError, AntzChatClient, AntzChatConfig, AntzChatError, AntzChatNetworkError, AntzChatPermissionError, AntzChatServerError, AntzChatValidationError, AppConfig, AuthResponse, AuthTokens, BatchUploadResult, CompletedPart, Conversation, ConversationListParams, ConversationSyncResponse, ConversationUnreadCount, type CreateDirectData, type CreateGroupData, CrossConversationSyncResponse, CursorPaginatedResponse, FileResponse, FileType, type LastReadEntry, type ListMessagesParams, LoginCredentials, type MentionPart, type MentionSegment, Message, MessageReactionsResponse, MessageReceiptsResponse, type MobileDeviceToken, PaginatedResponse, type ParsedMention, Participant, PersistStorage, PresignedUrlRequest, PresignedUrlResponse, RegisterData, type RegisterDeviceTokenPayload, ResolvedCompressionConfig, ResolvedConfig, type SearchParams, type SendData, SendMessagePayload, type SocketStatus, type StatusListener, type TokenStore, UnreadSummary, type UpdateConversationData, type UpdateProfilePayload, UploadableFile, User, UserPreferences, type WebPushDeviceToken, appConfigApi, authApi, buildMentionText, connectSocket, conversationsApi, createAuthStore, createRestTransitSession, decryptPayload, devicesApi, disconnectSocket, encryptPayload, extractMentionIds, fetchServerKeys, generateEphemeralKey, getApiClient, getAuthStore, getCompressionStrategy, getSessionId, getSessionKey, getSocket, getSocketStatus, initApiClient, initAuthStore, isMentionAll, isTransitEnvelope, messagesApi, normalizeAxiosError, normalizeConversation, onSocketStatus, parseMentions, performHandshake, reconnectSocket, refreshSocketAuth, renderMentionParts, resetAuthStore, resolveSystemMessageText, setApiClientInstance, setTransitSession, socketEmit, syncApi, tryGetSocket, useChatStore, usersApi };
|
package/dist/index.js
CHANGED
|
@@ -401,11 +401,13 @@ function normalizeParticipant(p) {
|
|
|
401
401
|
const hasUserDetails = p.displayName || p.username || p.avatarUrl;
|
|
402
402
|
return {
|
|
403
403
|
userId: p.userId,
|
|
404
|
+
externalId: p.externalId ?? p.user?.externalId,
|
|
404
405
|
role: p.role,
|
|
405
406
|
joinedAt: p.joinedAt,
|
|
406
407
|
isActive: p.isActive,
|
|
407
408
|
user: hasUserDetails ? {
|
|
408
409
|
id: p.userId,
|
|
410
|
+
externalId: p.externalId,
|
|
409
411
|
tenantId: "",
|
|
410
412
|
email: "",
|
|
411
413
|
username: p.username ?? "",
|
|
@@ -513,7 +515,7 @@ var conversationsApi = {
|
|
|
513
515
|
`/conversations/${conversationId}/participants`,
|
|
514
516
|
filter ? { params: { filter } } : void 0
|
|
515
517
|
);
|
|
516
|
-
return data;
|
|
518
|
+
return (data ?? []).map(normalizeParticipant);
|
|
517
519
|
},
|
|
518
520
|
/**
|
|
519
521
|
* Get unread message count for a single conversation.
|
|
@@ -1062,6 +1064,80 @@ var socketEmit = {
|
|
|
1062
1064
|
}
|
|
1063
1065
|
};
|
|
1064
1066
|
|
|
1067
|
+
// src/types/index.ts
|
|
1068
|
+
var MENTION_ALL_ID = "all";
|
|
1069
|
+
|
|
1070
|
+
// src/utils/mentions.ts
|
|
1071
|
+
var MENTION_TOKEN_SOURCE = "@\\[([^\\]]+)\\]\\((all|[a-fA-F0-9]{24})\\)";
|
|
1072
|
+
function sanitizeDisplayName(name) {
|
|
1073
|
+
return name.replace(/[\[\]()]/g, "").trim() || "user";
|
|
1074
|
+
}
|
|
1075
|
+
function parseMentions(text) {
|
|
1076
|
+
if (!text) return [];
|
|
1077
|
+
const re = new RegExp(MENTION_TOKEN_SOURCE, "g");
|
|
1078
|
+
const out = [];
|
|
1079
|
+
let m;
|
|
1080
|
+
while ((m = re.exec(text)) !== null) {
|
|
1081
|
+
out.push({
|
|
1082
|
+
id: m[2],
|
|
1083
|
+
displayName: m[1],
|
|
1084
|
+
start: m.index,
|
|
1085
|
+
end: m.index + m[0].length
|
|
1086
|
+
});
|
|
1087
|
+
}
|
|
1088
|
+
return out;
|
|
1089
|
+
}
|
|
1090
|
+
function renderMentionParts(text, resolveName) {
|
|
1091
|
+
if (!text) return [];
|
|
1092
|
+
const mentions = parseMentions(text);
|
|
1093
|
+
if (mentions.length === 0) return [{ type: "text", text }];
|
|
1094
|
+
const parts = [];
|
|
1095
|
+
let cursor = 0;
|
|
1096
|
+
for (const mn of mentions) {
|
|
1097
|
+
if (mn.start > cursor) {
|
|
1098
|
+
parts.push({ type: "text", text: text.slice(cursor, mn.start) });
|
|
1099
|
+
}
|
|
1100
|
+
const displayName = resolveName ? resolveName(mn.id, mn.displayName) : mn.displayName;
|
|
1101
|
+
parts.push({ type: "mention", id: mn.id, displayName });
|
|
1102
|
+
cursor = mn.end;
|
|
1103
|
+
}
|
|
1104
|
+
if (cursor < text.length) {
|
|
1105
|
+
parts.push({ type: "text", text: text.slice(cursor) });
|
|
1106
|
+
}
|
|
1107
|
+
return parts;
|
|
1108
|
+
}
|
|
1109
|
+
function buildMentionText(segments) {
|
|
1110
|
+
let text = "";
|
|
1111
|
+
const ids = [];
|
|
1112
|
+
const seen = /* @__PURE__ */ new Set();
|
|
1113
|
+
for (const seg of segments) {
|
|
1114
|
+
if (typeof seg === "string") {
|
|
1115
|
+
text += seg;
|
|
1116
|
+
} else {
|
|
1117
|
+
text += `@[${sanitizeDisplayName(seg.displayName)}](${seg.id})`;
|
|
1118
|
+
if (!seen.has(seg.id)) {
|
|
1119
|
+
seen.add(seg.id);
|
|
1120
|
+
ids.push(seg.id);
|
|
1121
|
+
}
|
|
1122
|
+
}
|
|
1123
|
+
}
|
|
1124
|
+
return { text, mentions: ids };
|
|
1125
|
+
}
|
|
1126
|
+
function extractMentionIds(text) {
|
|
1127
|
+
const ids = [];
|
|
1128
|
+
const seen = /* @__PURE__ */ new Set();
|
|
1129
|
+
for (const mn of parseMentions(text)) {
|
|
1130
|
+
if (!seen.has(mn.id)) {
|
|
1131
|
+
seen.add(mn.id);
|
|
1132
|
+
ids.push(mn.id);
|
|
1133
|
+
}
|
|
1134
|
+
}
|
|
1135
|
+
return ids;
|
|
1136
|
+
}
|
|
1137
|
+
function isMentionAll(mentions) {
|
|
1138
|
+
return !!mentions?.includes(MENTION_ALL_ID);
|
|
1139
|
+
}
|
|
1140
|
+
|
|
1065
1141
|
// src/client-facade.ts
|
|
1066
1142
|
var AntzChatClient = class {
|
|
1067
1143
|
constructor(rawConfig) {
|
|
@@ -1119,8 +1195,10 @@ export {
|
|
|
1119
1195
|
AntzChatPermissionError,
|
|
1120
1196
|
AntzChatServerError,
|
|
1121
1197
|
AntzChatValidationError,
|
|
1198
|
+
MENTION_ALL_ID,
|
|
1122
1199
|
appConfigApi,
|
|
1123
1200
|
authApi,
|
|
1201
|
+
buildMentionText,
|
|
1124
1202
|
connectSocket,
|
|
1125
1203
|
conversationsApi,
|
|
1126
1204
|
createAuthStore,
|
|
@@ -1129,6 +1207,7 @@ export {
|
|
|
1129
1207
|
devicesApi,
|
|
1130
1208
|
disconnectSocket,
|
|
1131
1209
|
encryptPayload,
|
|
1210
|
+
extractMentionIds,
|
|
1132
1211
|
fetchServerKeys,
|
|
1133
1212
|
generateEphemeralKey,
|
|
1134
1213
|
getApiClient,
|
|
@@ -1140,14 +1219,17 @@ export {
|
|
|
1140
1219
|
getSocketStatus,
|
|
1141
1220
|
initApiClient,
|
|
1142
1221
|
initAuthStore,
|
|
1222
|
+
isMentionAll,
|
|
1143
1223
|
isTransitEnvelope,
|
|
1144
1224
|
messagesApi,
|
|
1145
1225
|
normalizeAxiosError,
|
|
1146
1226
|
normalizeConversation,
|
|
1147
1227
|
onSocketStatus,
|
|
1228
|
+
parseMentions,
|
|
1148
1229
|
performHandshake,
|
|
1149
1230
|
reconnectSocket,
|
|
1150
1231
|
refreshSocketAuth,
|
|
1232
|
+
renderMentionParts,
|
|
1151
1233
|
resetAuthStore,
|
|
1152
1234
|
resolveConfig,
|
|
1153
1235
|
resolveSystemMessageText,
|