@corva/chat-core 0.1.5 → 0.1.7
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.d.ts +42 -3
- package/dist/index.js +307 -73
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -497,6 +497,10 @@ interface TypingEventData {
|
|
|
497
497
|
isTyping: boolean;
|
|
498
498
|
roomId: string;
|
|
499
499
|
}
|
|
500
|
+
interface ReadyServerData {
|
|
501
|
+
_id: string;
|
|
502
|
+
name?: string;
|
|
503
|
+
}
|
|
500
504
|
interface ReadyChannelData {
|
|
501
505
|
_id: string;
|
|
502
506
|
channel_type: string;
|
|
@@ -514,7 +518,7 @@ interface RevoltSocketEventHandlers {
|
|
|
514
518
|
onAuthenticated?: () => void;
|
|
515
519
|
onDisconnected?: () => void;
|
|
516
520
|
onInvalidSession?: () => void;
|
|
517
|
-
onReady?: (channels: ReadyChannelData[], channelUnreads?: ChannelUnread[]) => void;
|
|
521
|
+
onReady?: (channels: ReadyChannelData[], channelUnreads?: ChannelUnread[], servers?: ReadyServerData[]) => void;
|
|
518
522
|
onMessage?: (message: Message) => void;
|
|
519
523
|
onMessageUpdate?: (messageId: string, channelId: string, data: {
|
|
520
524
|
content?: string;
|
|
@@ -582,6 +586,7 @@ interface User {
|
|
|
582
586
|
roles?: string[];
|
|
583
587
|
active?: boolean;
|
|
584
588
|
isBot?: boolean;
|
|
589
|
+
nickname?: string;
|
|
585
590
|
displayName?: string;
|
|
586
591
|
displayAvatar?: string;
|
|
587
592
|
email?: string;
|
|
@@ -1172,6 +1177,8 @@ interface CorvaRevoltAuthResponse {
|
|
|
1172
1177
|
revolt_user_id: string;
|
|
1173
1178
|
revolt_company_server_id: string;
|
|
1174
1179
|
revolt_channel_id: string;
|
|
1180
|
+
revolt_channel_server_id?: string;
|
|
1181
|
+
revolt_channel_company_id?: number;
|
|
1175
1182
|
revolt_chat_channels?: AssetChatChannel[];
|
|
1176
1183
|
chat_used?: boolean | null;
|
|
1177
1184
|
}
|
|
@@ -1233,6 +1240,18 @@ declare function isValidPausePreset(value: unknown): value is PausePreset;
|
|
|
1233
1240
|
|
|
1234
1241
|
declare function waitForNextPaint(): Promise<void>;
|
|
1235
1242
|
|
|
1243
|
+
/**
|
|
1244
|
+
* Asset Chats API Module
|
|
1245
|
+
*
|
|
1246
|
+
* Fetches or creates a Revolt channel for a specific rig / frac fleet /
|
|
1247
|
+
* intervention unit. The backend will return the associated revolt_channel_id.
|
|
1248
|
+
*/
|
|
1249
|
+
interface AssetChatSession {
|
|
1250
|
+
channelId: string;
|
|
1251
|
+
serverId: string | null;
|
|
1252
|
+
companyId: number | null;
|
|
1253
|
+
}
|
|
1254
|
+
declare function getAssetChatSession(assetId: string, assetType: ChatAssetType): Promise<AssetChatSession>;
|
|
1236
1255
|
declare function getAssetChatChannel(assetId: string, assetType: ChatAssetType): Promise<string>;
|
|
1237
1256
|
|
|
1238
1257
|
type StoredCorvaUser = CorvaUser | CorvaAPIUser;
|
|
@@ -1282,9 +1301,16 @@ declare const sharedRefs: SharedRefs;
|
|
|
1282
1301
|
*/
|
|
1283
1302
|
declare const initChat: () => void;
|
|
1284
1303
|
|
|
1304
|
+
interface ExternalChannel {
|
|
1305
|
+
serverId: string;
|
|
1306
|
+
companyId: number | null;
|
|
1307
|
+
}
|
|
1285
1308
|
interface AuthStore {
|
|
1286
1309
|
user: User | null;
|
|
1287
1310
|
serverId: string | null;
|
|
1311
|
+
corvaCompanyId: number | null;
|
|
1312
|
+
externalChannels: Record<string, ExternalChannel>;
|
|
1313
|
+
serverNames: string[] | null;
|
|
1288
1314
|
isConnected: boolean;
|
|
1289
1315
|
hasEverConnected: boolean;
|
|
1290
1316
|
connectionGaveUp: boolean;
|
|
@@ -1294,6 +1320,8 @@ interface AuthStore {
|
|
|
1294
1320
|
setConnected: (connected: boolean) => void;
|
|
1295
1321
|
setHasEverConnected: (hasConnected: boolean) => void;
|
|
1296
1322
|
addAssetChatChannel: (channel: AssetChatChannel) => void;
|
|
1323
|
+
setChannelServer: (channelId: string, serverId: string | null, companyId: number | null) => void;
|
|
1324
|
+
setServerNames: (names: string[]) => void;
|
|
1297
1325
|
markChatUsed: () => void;
|
|
1298
1326
|
login: (credentials: LoginCredentials) => Promise<{
|
|
1299
1327
|
success: boolean;
|
|
@@ -1312,6 +1340,9 @@ interface AuthStore {
|
|
|
1312
1340
|
}
|
|
1313
1341
|
declare function keepChatUsed(current: boolean | null, incoming: boolean | null | undefined): boolean | null;
|
|
1314
1342
|
declare const authStore: zustand_vanilla.StoreApi<AuthStore>;
|
|
1343
|
+
declare const getExternalChannel: (roomId: string | null | undefined) => ExternalChannel | null;
|
|
1344
|
+
declare const waitForServerNames: (timeoutMs: number) => Promise<string[] | null>;
|
|
1345
|
+
declare const isExternalServerChannel: (roomId: string | null | undefined) => boolean;
|
|
1315
1346
|
/** @public */
|
|
1316
1347
|
declare const resetAuthStore: () => void;
|
|
1317
1348
|
|
|
@@ -1494,6 +1525,12 @@ interface UIStore {
|
|
|
1494
1525
|
declare const uiStore: zustand_vanilla.StoreApi<UIStore>;
|
|
1495
1526
|
declare const resetUIStore: () => void;
|
|
1496
1527
|
|
|
1528
|
+
interface JoinRequired {
|
|
1529
|
+
assetId: string;
|
|
1530
|
+
assetType: ChatAssetType;
|
|
1531
|
+
companyId: number;
|
|
1532
|
+
companyName: string | null;
|
|
1533
|
+
}
|
|
1497
1534
|
type LockedAsset = ChatAsset & {
|
|
1498
1535
|
type: ChatAssetType;
|
|
1499
1536
|
};
|
|
@@ -1504,6 +1541,7 @@ interface AssetStore {
|
|
|
1504
1541
|
currentAssetStatus: string | null;
|
|
1505
1542
|
assetChatId: string | null;
|
|
1506
1543
|
assetChatError: string | null;
|
|
1544
|
+
joinRequired: JoinRequired | null;
|
|
1507
1545
|
knownAssetChatIds: Set<string>;
|
|
1508
1546
|
panelSyncedAssetId: string | null;
|
|
1509
1547
|
isAssetLocked: boolean;
|
|
@@ -1511,6 +1549,7 @@ interface AssetStore {
|
|
|
1511
1549
|
isAssetSwitching: boolean;
|
|
1512
1550
|
setAssetContext: (assetId: string, assetType: ChatAssetType, assetName?: string, assetStatus?: string, skipAutoSelect?: boolean) => Promise<void>;
|
|
1513
1551
|
clearAssetContext: () => void;
|
|
1552
|
+
joinAssetChat: () => Promise<void>;
|
|
1514
1553
|
ensureAssetChatSubscription: () => Promise<Subscription | null>;
|
|
1515
1554
|
toggleAssetLock: () => void;
|
|
1516
1555
|
relockToAsset: (assetId: string, assetType: ChatAssetType, assetName: string) => Promise<void>;
|
|
@@ -1677,7 +1716,7 @@ declare const createSocketEventHandlers: (config: SocketEventHandlersConfig) =>
|
|
|
1677
1716
|
onConnected: () => void;
|
|
1678
1717
|
onAuthenticated: () => void;
|
|
1679
1718
|
onDisconnected: () => void;
|
|
1680
|
-
onReady: (channels: ReadyChannelData[], channelUnreads?: ChannelUnread[]) => void;
|
|
1719
|
+
onReady: (channels: ReadyChannelData[], channelUnreads?: ChannelUnread[], servers?: ReadyServerData[]) => void;
|
|
1681
1720
|
onChannelAck: (channelId: string, messageId: string) => void;
|
|
1682
1721
|
onMessage: (message: Message) => void;
|
|
1683
1722
|
onRoomChange: (roomId: string, change: unknown) => void;
|
|
@@ -1699,4 +1738,4 @@ declare const createSocketEventHandlers: (config: SocketEventHandlersConfig) =>
|
|
|
1699
1738
|
|
|
1700
1739
|
declare const installUnreadWatcher: () => void;
|
|
1701
1740
|
|
|
1702
|
-
export { ALERT_SEVERITY, ASSET_API_FIELDS, ASSET_CHAT_PREFIXES, ASSET_NOUN, type AckScheduler, type AlertData, type AlertSeverity, type AlertWirePayload, type AppCommentAttachment, type AppCommentData, type AppCommentWirePayload, type AppStateAdapter, type AskCorvaData, type AskCorvaWirePayload, type AssetChatChannel, type AssetStore, type Attachment, type AuthStore, CHANNEL_NAME_MAX_LENGTH, CHANNEL_TYPES, CORVA_MESSAGE_TYPES, CORVA_SYS_PREFIX, type ChannelAsset, type ChannelContentFilter, type ChannelContentFilterStore, type ChannelContentFilters, type ChannelNameValidation, type ChannelNotificationPreference, type ChannelNotificationSetting, type ChannelUnread, type ChatAsset, type ChatAssetIdentity, type ChatAssetType, type ChatDates, type ChatHost, type ChatNotifier, type ChatPlatform, type CorvaAPIUser, type CorvaApiAdapter, type CorvaRevoltAuthResponse, type CorvaSystemMessage, type CorvaUser, type CorvaUserService, DATE_SEPARATOR_LABELS, DEFAULT_CHANNEL_CONTENT_FILTER, DEFAULT_CHANNEL_CONTENT_FILTERS, DEFAULT_CHANNEL_PREFERENCE, DEFAULT_FAVORITE_ROOMS_SETTINGS, DEFAULT_HIDDEN_ROOMS_SETTINGS, DEFAULT_NOTIFICATION_PREFERENCES, DEFAULT_NOTIFICATION_SETTINGS, DEFAULT_ROOM_LIST_ORDER, DIRECT_MESSAGE_PLACEHOLDER, type FavoriteRoomsSettings, type FavoriteRoomsStore, type FeedItemData, type FeedWirePayload, type FileAttachment, type FilterEntityWindow, type ForwardWirePayload, type ForwardedFrom, GENERAL_CHAT_NAME, type HiddenRoomsSettings, type HttpClient, type HttpClientConfig, HttpError, type HttpRequestInit, type HttpResponseLike, type KeyValueStorage, type LocatorContext, type LoginCredentials, MAX_ATTACHMENT_SIZE_BYTES, MAX_ATTACHMENT_SIZE_MB, MAX_NAVIGATION_HISTORY, MENTION_REPLACE_PATTERN, MENTION_SPLIT_PATTERN, MUTE_PRESET_OPTIONS, type MemberStore, type Message, type MessageCache, type MessageFormData, type MessageStore, NOTIFICATION_DESTINATIONS, NOTIFICATION_SETTING_ALL, NOTIFICATION_SETTING_MENTIONS, NOTIFICATION_SETTING_NOTHING, type NavigationEntry, type NavigationHistoryStore, type NotificationDestination, type NotificationPreferences, type NotificationSettings, type NotificationStore, PAUSE_INDEFINITELY, PAUSE_PRESETS, PAUSE_PRESET_OPTIONS, type PausePreset, type PausePresetOption, REVOLT_SYSTEM_USER_ID, ROOM_LIST_ORDER, type ReadyChannelData, type RevoltAPIInstance, type RevoltChannel, type RevoltIncomingMessagePayload, type RevoltLoginResponse, type RevoltMessage, type RevoltMessageResponse, type RevoltSocketConfig, type RevoltSocketEventHandlers, type RevoltSocketInstance, type RevoltUploadResponse, type RevoltUserResponse, type Room, type RoomListOrder, type RoomStore, type RoomType, SESSION_STORAGE_KEY, SIDEBAR_SECTIONS, SIDEBAR_TABS, SOFT_DELETE_MARKER, SYSTEM_MESSAGE_TEXTS, type SaveSessionParams, type SelectableAssetType, type SessionData, SessionManager, type SharedFile, type SharedRefs, type SidebarSectionKey, type SidebarTabKey, type SocketCloseEventLike, type SocketEventHandlersConfig, type StoredChannelPreference, type Subscription, type TracesViewportRequest, type TypingManager, type UIStore, type UploadAndSendResult, type UploadFile, type UploadedFile, type User, type UserStatus, type ViewportDeepLink, type ViewportIndexCurve, type ViewportMode, WEBSOCKET_CONNECTING, WEBSOCKET_OPEN, type WebSocketLike, type WireSeverity, addMessage, addOrUpdateSubscription, alertMessageAsText, assetStore, authStore, buildAppCommentMessageContent, buildAskCorvaMessageContent, buildFinalMessage, buildForwardMessageContent, buildGroupChannelName, canDeleteMessage, canEditMessage, channelContentFilterStore, channelToAsset, chatToastStore, clearLastOpenedRoom, compareByActivity, compareByName, compareByRecencyDesc, configureChat, configureChatStorage, createAckScheduler, createCorvaUserService, createDMSubscription, createGroupSubscription, createHttpClient, createLatestWinsQueue, createMemoryStorage, createMessageCache, createRevoltAPI, createRevoltSocket, createRoomTaskQueue, createSocketEventHandlers, createSoftDeletedMessage, createTypingManager, deriveAllowedChatAsset, enrichWithCorvaData, ensureChatSession, extractTimestampFromULID, failOptimisticMessage, favoriteRoomsStore, findGeneralRoom, formatAssetChatName, getAppCommentAttachments, getAssetChatChannel, getAssetTypeFromDisplayName, getChatHost, getChatStorage, getCorvaUserFields, getLastOpenedRoom, getMessageTimestamp, getPauseUntil, getReactionCount, getRoomDisplayName, getSystemMessageWithCorvaNames, getUserDisplayName, getUserSecondaryText, handleUnauthorized, hasReactions, hasUserReacted, initChat, installUnreadWatcher, isAlertMessage, isAppCommentMessage, isAskCorvaMessage, isChannelMuted, isChatAssetTypeAllowed, isChatStorageConfigured, isCurrentRoomSelection, isDeepEqual, isDefaultChannelPreference, isDisallowedAssetChatRoom, isDmGroup, isForwardedMessage, isGeneralRoom, isNotificationsPaused, isPauseActive, isSoftDeletedMessage, isSystemMessage, isUnread, isUserOnline, isValidPausePreset, isVisibleUnread, keepChatUsed, loadUntilFound, memberStore, messageStore, navigationHistoryStore, notificationStore, onChatStorageConfigured, parseCorvaSystemMessage, prepareRoomSelection, removeMessageFromList, removeSubscription, resetAssetStore, resetAuthStore, resetChannelContentFilterStore, resetChatAssetPermissionsSnapshot, resetChatHost, resetFavoriteRoomsStore, resetMemberStore, resetMessageStore, resetNavigationHistoryStore, resetNotificationStore, resetRoomStore, resetUIStore, roomStore, saveLastChatActivity, saveLastOpenedRoom, searchMessages, searchRooms, searchUsers, selectCanGoBack, selectCanGoForward, setAllowedChatAssetTypes, settleOptimisticMessage, sharedRefs, sortChannels, sortDMs, sortMessagesByTime, sortUsersByStatus, stripPlatformMentions, uiStore, updateMessageInList, uploadAndSend, validateChannelName, waitForNextPaint, wasRecentlyActive, withChannelPreferenceDefaults };
|
|
1741
|
+
export { ALERT_SEVERITY, ASSET_API_FIELDS, ASSET_CHAT_PREFIXES, ASSET_NOUN, type AckScheduler, type AlertData, type AlertSeverity, type AlertWirePayload, type AppCommentAttachment, type AppCommentData, type AppCommentWirePayload, type AppStateAdapter, type AskCorvaData, type AskCorvaWirePayload, type AssetChatChannel, type AssetChatSession, type AssetStore, type Attachment, type AuthStore, CHANNEL_NAME_MAX_LENGTH, CHANNEL_TYPES, CORVA_MESSAGE_TYPES, CORVA_SYS_PREFIX, type ChannelAsset, type ChannelContentFilter, type ChannelContentFilterStore, type ChannelContentFilters, type ChannelNameValidation, type ChannelNotificationPreference, type ChannelNotificationSetting, type ChannelUnread, type ChatAsset, type ChatAssetIdentity, type ChatAssetType, type ChatDates, type ChatHost, type ChatNotifier, type ChatPlatform, type CorvaAPIUser, type CorvaApiAdapter, type CorvaRevoltAuthResponse, type CorvaSystemMessage, type CorvaUser, type CorvaUserService, DATE_SEPARATOR_LABELS, DEFAULT_CHANNEL_CONTENT_FILTER, DEFAULT_CHANNEL_CONTENT_FILTERS, DEFAULT_CHANNEL_PREFERENCE, DEFAULT_FAVORITE_ROOMS_SETTINGS, DEFAULT_HIDDEN_ROOMS_SETTINGS, DEFAULT_NOTIFICATION_PREFERENCES, DEFAULT_NOTIFICATION_SETTINGS, DEFAULT_ROOM_LIST_ORDER, DIRECT_MESSAGE_PLACEHOLDER, type ExternalChannel, type FavoriteRoomsSettings, type FavoriteRoomsStore, type FeedItemData, type FeedWirePayload, type FileAttachment, type FilterEntityWindow, type ForwardWirePayload, type ForwardedFrom, GENERAL_CHAT_NAME, type HiddenRoomsSettings, type HttpClient, type HttpClientConfig, HttpError, type HttpRequestInit, type HttpResponseLike, type JoinRequired, type KeyValueStorage, type LocatorContext, type LoginCredentials, MAX_ATTACHMENT_SIZE_BYTES, MAX_ATTACHMENT_SIZE_MB, MAX_NAVIGATION_HISTORY, MENTION_REPLACE_PATTERN, MENTION_SPLIT_PATTERN, MUTE_PRESET_OPTIONS, type MemberStore, type Message, type MessageCache, type MessageFormData, type MessageStore, NOTIFICATION_DESTINATIONS, NOTIFICATION_SETTING_ALL, NOTIFICATION_SETTING_MENTIONS, NOTIFICATION_SETTING_NOTHING, type NavigationEntry, type NavigationHistoryStore, type NotificationDestination, type NotificationPreferences, type NotificationSettings, type NotificationStore, PAUSE_INDEFINITELY, PAUSE_PRESETS, PAUSE_PRESET_OPTIONS, type PausePreset, type PausePresetOption, REVOLT_SYSTEM_USER_ID, ROOM_LIST_ORDER, type ReadyChannelData, type ReadyServerData, type RevoltAPIInstance, type RevoltChannel, type RevoltIncomingMessagePayload, type RevoltLoginResponse, type RevoltMessage, type RevoltMessageResponse, type RevoltSocketConfig, type RevoltSocketEventHandlers, type RevoltSocketInstance, type RevoltUploadResponse, type RevoltUserResponse, type Room, type RoomListOrder, type RoomStore, type RoomType, SESSION_STORAGE_KEY, SIDEBAR_SECTIONS, SIDEBAR_TABS, SOFT_DELETE_MARKER, SYSTEM_MESSAGE_TEXTS, type SaveSessionParams, type SelectableAssetType, type SessionData, SessionManager, type SharedFile, type SharedRefs, type SidebarSectionKey, type SidebarTabKey, type SocketCloseEventLike, type SocketEventHandlersConfig, type StoredChannelPreference, type Subscription, type TracesViewportRequest, type TypingManager, type UIStore, type UploadAndSendResult, type UploadFile, type UploadedFile, type User, type UserStatus, type ViewportDeepLink, type ViewportIndexCurve, type ViewportMode, WEBSOCKET_CONNECTING, WEBSOCKET_OPEN, type WebSocketLike, type WireSeverity, addMessage, addOrUpdateSubscription, alertMessageAsText, assetStore, authStore, buildAppCommentMessageContent, buildAskCorvaMessageContent, buildFinalMessage, buildForwardMessageContent, buildGroupChannelName, canDeleteMessage, canEditMessage, channelContentFilterStore, channelToAsset, chatToastStore, clearLastOpenedRoom, compareByActivity, compareByName, compareByRecencyDesc, configureChat, configureChatStorage, createAckScheduler, createCorvaUserService, createDMSubscription, createGroupSubscription, createHttpClient, createLatestWinsQueue, createMemoryStorage, createMessageCache, createRevoltAPI, createRevoltSocket, createRoomTaskQueue, createSocketEventHandlers, createSoftDeletedMessage, createTypingManager, deriveAllowedChatAsset, enrichWithCorvaData, ensureChatSession, extractTimestampFromULID, failOptimisticMessage, favoriteRoomsStore, findGeneralRoom, formatAssetChatName, getAppCommentAttachments, getAssetChatChannel, getAssetChatSession, getAssetTypeFromDisplayName, getChatHost, getChatStorage, getCorvaUserFields, getExternalChannel, getLastOpenedRoom, getMessageTimestamp, getPauseUntil, getReactionCount, getRoomDisplayName, getSystemMessageWithCorvaNames, getUserDisplayName, getUserSecondaryText, handleUnauthorized, hasReactions, hasUserReacted, initChat, installUnreadWatcher, isAlertMessage, isAppCommentMessage, isAskCorvaMessage, isChannelMuted, isChatAssetTypeAllowed, isChatStorageConfigured, isCurrentRoomSelection, isDeepEqual, isDefaultChannelPreference, isDisallowedAssetChatRoom, isDmGroup, isExternalServerChannel, isForwardedMessage, isGeneralRoom, isNotificationsPaused, isPauseActive, isSoftDeletedMessage, isSystemMessage, isUnread, isUserOnline, isValidPausePreset, isVisibleUnread, keepChatUsed, loadUntilFound, memberStore, messageStore, navigationHistoryStore, notificationStore, onChatStorageConfigured, parseCorvaSystemMessage, prepareRoomSelection, removeMessageFromList, removeSubscription, resetAssetStore, resetAuthStore, resetChannelContentFilterStore, resetChatAssetPermissionsSnapshot, resetChatHost, resetFavoriteRoomsStore, resetMemberStore, resetMessageStore, resetNavigationHistoryStore, resetNotificationStore, resetRoomStore, resetUIStore, roomStore, saveLastChatActivity, saveLastOpenedRoom, searchMessages, searchRooms, searchUsers, selectCanGoBack, selectCanGoForward, setAllowedChatAssetTypes, settleOptimisticMessage, sharedRefs, sortChannels, sortDMs, sortMessagesByTime, sortUsersByStatus, stripPlatformMentions, uiStore, updateMessageInList, uploadAndSend, validateChannelName, waitForNextPaint, waitForServerNames, wasRecentlyActive, withChannelPreferenceDefaults };
|