| 
									
										
										
										
											2023-01-03 11:55:46 -08:00
										 |  |  | // Copyright 2020 Signal Messenger, LLC
 | 
					
						
							| 
									
										
										
										
											2020-10-30 15:34:04 -05:00
										 |  |  | // SPDX-License-Identifier: AGPL-3.0-only
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-08-20 13:00:14 -07:00
										 |  |  | import type { Database, RowType } from '@signalapp/sqlcipher'; | 
					
						
							| 
									
										
										
										
											2024-07-24 13:14:11 -07:00
										 |  |  | import type { ReadonlyDeep } from 'type-fest'; | 
					
						
							| 
									
										
										
										
											2025-06-17 05:33:00 +10:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-09-16 17:39:03 -07:00
										 |  |  | import { strictAssert } from '../util/assert.js'; | 
					
						
							| 
									
										
										
										
											2025-06-17 05:33:00 +10:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-07-09 12:36:10 -07:00
										 |  |  | import type { | 
					
						
							| 
									
										
										
										
											2021-04-05 15:18:19 -07:00
										 |  |  |   ConversationAttributesType, | 
					
						
							|  |  |  |   MessageAttributesType, | 
					
						
							| 
									
										
										
										
											2021-12-08 11:52:46 -08:00
										 |  |  |   SenderKeyInfoType, | 
					
						
							| 
									
										
										
										
											2025-09-16 17:39:03 -07:00
										 |  |  | } from '../model-types.d.ts'; | 
					
						
							|  |  |  | import type { StoredJob } from '../jobs/types.js'; | 
					
						
							|  |  |  | import type { ReactionType, ReactionReadStatus } from '../types/Reactions.js'; | 
					
						
							|  |  |  | import type { | 
					
						
							|  |  |  |   ConversationColorType, | 
					
						
							|  |  |  |   CustomColorType, | 
					
						
							|  |  |  | } from '../types/Colors.js'; | 
					
						
							|  |  |  | import type { StorageAccessType } from '../types/Storage.d.ts'; | 
					
						
							|  |  |  | import type { BytesToStrings } from '../types/Util.js'; | 
					
						
							|  |  |  | import type { QualifiedAddressStringType } from '../types/QualifiedAddress.js'; | 
					
						
							|  |  |  | import type { StoryDistributionIdString } from '../types/StoryDistributionId.js'; | 
					
						
							|  |  |  | import type { | 
					
						
							|  |  |  |   AciString, | 
					
						
							|  |  |  |   PniString, | 
					
						
							|  |  |  |   ServiceIdString, | 
					
						
							|  |  |  | } from '../types/ServiceId.js'; | 
					
						
							|  |  |  | import type { BadgeType } from '../badges/types.js'; | 
					
						
							|  |  |  | import type { ReadStatus } from '../messages/MessageReadStatus.js'; | 
					
						
							|  |  |  | import type { RawBodyRange } from '../types/BodyRange.js'; | 
					
						
							| 
									
										
										
										
											2024-02-08 10:01:30 -08:00
										 |  |  | import type { | 
					
						
							|  |  |  |   GetMessagesBetweenOptions, | 
					
						
							|  |  |  |   MaybeStaleCallHistory, | 
					
						
							| 
									
										
										
										
											2025-09-16 17:39:03 -07:00
										 |  |  | } from './Server.js'; | 
					
						
							|  |  |  | import type { MessageTimestamps } from '../state/ducks/conversations.js'; | 
					
						
							| 
									
										
										
										
											2023-08-08 17:53:06 -07:00
										 |  |  | import type { | 
					
						
							|  |  |  |   CallHistoryDetails, | 
					
						
							|  |  |  |   CallHistoryFilter, | 
					
						
							|  |  |  |   CallHistoryGroup, | 
					
						
							|  |  |  |   CallHistoryPagination, | 
					
						
							| 
									
										
										
										
											2024-06-25 17:58:38 -07:00
										 |  |  |   CallLogEventTarget, | 
					
						
							| 
									
										
										
										
											2025-09-16 17:39:03 -07:00
										 |  |  | } from '../types/CallDisposition.js'; | 
					
						
							| 
									
										
										
										
											2024-09-04 11:06:06 -07:00
										 |  |  | import type { | 
					
						
							|  |  |  |   CallLinkRecord, | 
					
						
							|  |  |  |   CallLinkStateType, | 
					
						
							|  |  |  |   CallLinkType, | 
					
						
							| 
									
										
										
										
											2024-10-15 11:49:32 -07:00
										 |  |  |   DefunctCallLinkType, | 
					
						
							| 
									
										
										
										
											2025-09-16 17:39:03 -07:00
										 |  |  | } from '../types/CallLink.js'; | 
					
						
							| 
									
										
										
										
											2025-05-22 21:09:54 -04:00
										 |  |  | import type { | 
					
						
							|  |  |  |   AttachmentDownloadJobType, | 
					
						
							| 
									
										
										
										
											2025-09-24 10:55:08 -04:00
										 |  |  |   MessageAttachmentType, | 
					
						
							| 
									
										
										
										
											2025-09-16 17:39:03 -07:00
										 |  |  | } from '../types/AttachmentDownload.js'; | 
					
						
							| 
									
										
										
										
											2024-09-06 10:52:19 -07:00
										 |  |  | import type { | 
					
						
							|  |  |  |   GroupSendEndorsementsData, | 
					
						
							|  |  |  |   GroupSendMemberEndorsementRecord, | 
					
						
							| 
									
										
										
										
											2025-09-16 17:39:03 -07:00
										 |  |  | } from '../types/GroupSendEndorsements.js'; | 
					
						
							|  |  |  | import type { SyncTaskType } from '../util/syncTasks.js'; | 
					
						
							|  |  |  | import type { AttachmentBackupJobType } from '../types/AttachmentBackup.js'; | 
					
						
							|  |  |  | import type { AttachmentType } from '../types/Attachment.js'; | 
					
						
							|  |  |  | import type { MediaItemMessageType } from '../types/MediaItem.js'; | 
					
						
							|  |  |  | import type { GifType } from '../components/fun/panels/FunPanelGifs.js'; | 
					
						
							|  |  |  | import type { NotificationProfileType } from '../types/NotificationProfile.js'; | 
					
						
							|  |  |  | import type { DonationReceipt } from '../types/Donations.js'; | 
					
						
							|  |  |  | import type { InsertOrUpdateCallLinkFromSyncResult } from './server/callLinks.js'; | 
					
						
							|  |  |  | import type { ChatFolderId, ChatFolder } from '../types/ChatFolder.js'; | 
					
						
							| 
									
										
										
										
											2021-06-17 10:15:10 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-07-22 11:16:33 -07:00
										 |  |  | export type ReadableDB = Database & { __readable_db: never }; | 
					
						
							|  |  |  | export type WritableDB = ReadableDB & { __writable_db: never }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-03-03 19:03:15 -08:00
										 |  |  | export type AdjacentMessagesByConversationOptionsType = Readonly<{ | 
					
						
							|  |  |  |   conversationId: string; | 
					
						
							|  |  |  |   messageId?: string; | 
					
						
							|  |  |  |   includeStoryReplies: boolean; | 
					
						
							|  |  |  |   limit?: number; | 
					
						
							|  |  |  |   receivedAt?: number; | 
					
						
							|  |  |  |   sentAt?: number; | 
					
						
							|  |  |  |   storyId: string | undefined; | 
					
						
							|  |  |  |   requireVisualMediaAttachments?: boolean; | 
					
						
							| 
									
										
										
										
											2024-09-05 07:15:30 +10:00
										 |  |  |   requireFileAttachments?: boolean; | 
					
						
							| 
									
										
										
										
											2023-03-03 19:03:15 -08:00
										 |  |  | }>; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-03-20 15:23:53 -07:00
										 |  |  | export type GetNearbyMessageFromDeletedSetOptionsType = Readonly<{ | 
					
						
							|  |  |  |   conversationId: string; | 
					
						
							|  |  |  |   lastSelectedMessage: MessageTimestamps; | 
					
						
							|  |  |  |   deletedMessageIds: ReadonlyArray<string>; | 
					
						
							|  |  |  |   storyId: string | undefined; | 
					
						
							|  |  |  |   includeStoryReplies: boolean; | 
					
						
							|  |  |  | }>; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-04-05 15:18:19 -07:00
										 |  |  | export type MessageMetricsType = { | 
					
						
							|  |  |  |   id: string; | 
					
						
							|  |  |  |   received_at: number; | 
					
						
							|  |  |  |   sent_at: number; | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | export type ConversationMetricsType = { | 
					
						
							|  |  |  |   oldest?: MessageMetricsType; | 
					
						
							|  |  |  |   newest?: MessageMetricsType; | 
					
						
							| 
									
										
										
										
											2022-04-22 11:35:14 -07:00
										 |  |  |   oldestUnseen?: MessageMetricsType; | 
					
						
							|  |  |  |   totalUnseen: number; | 
					
						
							| 
									
										
										
										
											2021-04-05 15:18:19 -07:00
										 |  |  | }; | 
					
						
							|  |  |  | export type ConversationType = ConversationAttributesType; | 
					
						
							|  |  |  | export type EmojiType = { | 
					
						
							|  |  |  |   shortName: string; | 
					
						
							|  |  |  |   lastUsage: number; | 
					
						
							|  |  |  | }; | 
					
						
							| 
									
										
										
										
											2021-09-09 19:38:11 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-04-05 15:18:19 -07:00
										 |  |  | export type IdentityKeyType = { | 
					
						
							|  |  |  |   firstUse: boolean; | 
					
						
							| 
									
										
										
										
											2023-08-10 18:43:33 +02:00
										 |  |  |   id: ServiceIdString | `conversation:${string}`; | 
					
						
							| 
									
										
										
										
											2021-04-05 15:18:19 -07:00
										 |  |  |   nonblockingApproval: boolean; | 
					
						
							| 
									
										
										
										
											2021-09-23 17:49:05 -07:00
										 |  |  |   publicKey: Uint8Array; | 
					
						
							| 
									
										
										
										
											2021-04-05 15:18:19 -07:00
										 |  |  |   timestamp: number; | 
					
						
							|  |  |  |   verified: number; | 
					
						
							|  |  |  | }; | 
					
						
							| 
									
										
										
										
											2022-07-28 09:35:29 -07:00
										 |  |  | export type StoredIdentityKeyType = { | 
					
						
							|  |  |  |   firstUse: boolean; | 
					
						
							| 
									
										
										
										
											2023-08-10 18:43:33 +02:00
										 |  |  |   id: ServiceIdString | `conversation:${string}`; | 
					
						
							| 
									
										
										
										
											2022-07-28 09:35:29 -07:00
										 |  |  |   nonblockingApproval: boolean; | 
					
						
							|  |  |  |   publicKey: string; | 
					
						
							|  |  |  |   timestamp: number; | 
					
						
							|  |  |  |   verified: number; | 
					
						
							|  |  |  | }; | 
					
						
							| 
									
										
										
										
											2021-09-09 19:38:11 -07:00
										 |  |  | export type IdentityKeyIdType = IdentityKeyType['id']; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-06-14 17:09:37 -07:00
										 |  |  | export type ItemKeyType = keyof StorageAccessType; | 
					
						
							|  |  |  | export type AllItemsType = Partial<StorageAccessType>; | 
					
						
							| 
									
										
										
										
											2022-07-28 09:35:29 -07:00
										 |  |  | export type StoredAllItemsType = Partial<BytesToStrings<StorageAccessType>>; | 
					
						
							| 
									
										
										
										
											2021-06-14 17:09:37 -07:00
										 |  |  | export type ItemType<K extends ItemKeyType> = { | 
					
						
							|  |  |  |   id: K; | 
					
						
							|  |  |  |   value: StorageAccessType[K]; | 
					
						
							|  |  |  | }; | 
					
						
							| 
									
										
										
										
											2022-07-28 09:35:29 -07:00
										 |  |  | export type StoredItemType<K extends ItemKeyType> = { | 
					
						
							|  |  |  |   id: K; | 
					
						
							|  |  |  |   value: BytesToStrings<StorageAccessType[K]>; | 
					
						
							|  |  |  | }; | 
					
						
							| 
									
										
										
										
											2021-04-05 15:18:19 -07:00
										 |  |  | export type MessageType = MessageAttributesType; | 
					
						
							| 
									
										
										
										
											2025-01-16 13:34:35 -08:00
										 |  |  | 
 | 
					
						
							|  |  |  | // See: ts/sql/Interface.ts
 | 
					
						
							|  |  |  | //
 | 
					
						
							|  |  |  | // When adding a new column:
 | 
					
						
							|  |  |  | //
 | 
					
						
							|  |  |  | // - Make sure the name matches the one in `MessageAttributeTypes`
 | 
					
						
							|  |  |  | // - Update `hydrateMessage`
 | 
					
						
							|  |  |  | //
 | 
					
						
							| 
									
										
										
										
											2025-06-02 17:16:37 -04:00
										 |  |  | const MESSAGE_PRIMARY_KEY_COLUMNS = ['id'] as const; | 
					
						
							|  |  |  | export const MESSAGE_NON_PRIMARY_KEY_COLUMNS = [ | 
					
						
							| 
									
										
										
										
											2025-01-16 13:34:35 -08:00
										 |  |  |   'json', | 
					
						
							|  |  |  |   'body', | 
					
						
							|  |  |  |   'conversationId', | 
					
						
							|  |  |  |   'expirationStartTimestamp', | 
					
						
							|  |  |  |   'expireTimer', | 
					
						
							|  |  |  |   'hasAttachments', | 
					
						
							|  |  |  |   'hasFileAttachments', | 
					
						
							|  |  |  |   'hasVisualMediaAttachments', | 
					
						
							|  |  |  |   'isChangeCreatedByUs', | 
					
						
							|  |  |  |   'isErased', | 
					
						
							|  |  |  |   'isViewOnce', | 
					
						
							|  |  |  |   'mentionsMe', | 
					
						
							|  |  |  |   'received_at', | 
					
						
							|  |  |  |   'received_at_ms', | 
					
						
							|  |  |  |   'schemaVersion', | 
					
						
							|  |  |  |   'serverGuid', | 
					
						
							|  |  |  |   'sent_at', | 
					
						
							|  |  |  |   'source', | 
					
						
							|  |  |  |   'sourceServiceId', | 
					
						
							|  |  |  |   'sourceDevice', | 
					
						
							|  |  |  |   'storyId', | 
					
						
							|  |  |  |   'type', | 
					
						
							|  |  |  |   'readStatus', | 
					
						
							|  |  |  |   'seenStatus', | 
					
						
							|  |  |  |   'serverTimestamp', | 
					
						
							|  |  |  |   'timestamp', | 
					
						
							|  |  |  |   'unidentifiedDeliveryReceived', | 
					
						
							|  |  |  | ] as const; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-06-02 17:16:37 -04:00
										 |  |  | export const MESSAGE_COLUMNS = [ | 
					
						
							|  |  |  |   ...MESSAGE_PRIMARY_KEY_COLUMNS, | 
					
						
							|  |  |  |   ...MESSAGE_NON_PRIMARY_KEY_COLUMNS, | 
					
						
							|  |  |  | ] as const; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-07-12 16:51:45 -07:00
										 |  |  | export type MessageTypeUnhydrated = { | 
					
						
							|  |  |  |   json: string; | 
					
						
							| 
									
										
										
										
											2025-01-16 13:34:35 -08:00
										 |  |  | 
 | 
					
						
							|  |  |  |   id: string; | 
					
						
							|  |  |  |   body: string | null; | 
					
						
							|  |  |  |   conversationId: string | null; | 
					
						
							|  |  |  |   expirationStartTimestamp: number | null; | 
					
						
							|  |  |  |   expireTimer: number | null; | 
					
						
							|  |  |  |   hasAttachments: 0 | 1 | null; | 
					
						
							|  |  |  |   hasFileAttachments: 0 | 1 | null; | 
					
						
							|  |  |  |   hasVisualMediaAttachments: 0 | 1 | null; | 
					
						
							|  |  |  |   isChangeCreatedByUs: 0 | 1 | null; | 
					
						
							|  |  |  |   isErased: 0 | 1 | null; | 
					
						
							|  |  |  |   isViewOnce: 0 | 1 | null; | 
					
						
							|  |  |  |   mentionsMe: 0 | 1 | null; | 
					
						
							|  |  |  |   received_at: number | null; | 
					
						
							|  |  |  |   received_at_ms: number | null; | 
					
						
							|  |  |  |   schemaVersion: number | null; | 
					
						
							|  |  |  |   serverGuid: string | null; | 
					
						
							|  |  |  |   sent_at: number | null; | 
					
						
							|  |  |  |   source: string | null; | 
					
						
							|  |  |  |   sourceServiceId: string | null; | 
					
						
							|  |  |  |   sourceDevice: number | null; | 
					
						
							|  |  |  |   serverTimestamp: number | null; | 
					
						
							|  |  |  |   storyId: string | null; | 
					
						
							|  |  |  |   type: string; | 
					
						
							|  |  |  |   timestamp: number | null; | 
					
						
							|  |  |  |   readStatus: number | null; | 
					
						
							|  |  |  |   seenStatus: number | null; | 
					
						
							|  |  |  |   unidentifiedDeliveryReceived: 0 | 1 | null; | 
					
						
							| 
									
										
										
										
											2021-07-12 16:51:45 -07:00
										 |  |  | }; | 
					
						
							| 
									
										
										
										
											2023-07-14 09:53:20 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-08-10 18:43:33 +02:00
										 |  |  | export type PreKeyIdType = `${ServiceIdString}:${number}`; | 
					
						
							| 
									
										
										
										
											2023-07-14 09:53:20 -07:00
										 |  |  | export type KyberPreKeyType = { | 
					
						
							|  |  |  |   id: PreKeyIdType; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   createdAt: number; | 
					
						
							|  |  |  |   data: Uint8Array; | 
					
						
							|  |  |  |   isConfirmed: boolean; | 
					
						
							|  |  |  |   isLastResort: boolean; | 
					
						
							|  |  |  |   keyId: number; | 
					
						
							| 
									
										
										
										
											2023-08-16 22:54:39 +02:00
										 |  |  |   ourServiceId: ServiceIdString; | 
					
						
							| 
									
										
										
										
											2023-07-14 09:53:20 -07:00
										 |  |  | }; | 
					
						
							|  |  |  | export type StoredKyberPreKeyType = KyberPreKeyType & { | 
					
						
							|  |  |  |   data: string; | 
					
						
							|  |  |  | }; | 
					
						
							| 
									
										
										
										
											2021-04-05 15:18:19 -07:00
										 |  |  | export type PreKeyType = { | 
					
						
							| 
									
										
										
										
											2023-07-14 09:53:20 -07:00
										 |  |  |   id: PreKeyIdType; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   createdAt: number; | 
					
						
							| 
									
										
										
										
											2021-09-09 19:38:11 -07:00
										 |  |  |   keyId: number; | 
					
						
							| 
									
										
										
										
											2023-08-16 22:54:39 +02:00
										 |  |  |   ourServiceId: ServiceIdString; | 
					
						
							| 
									
										
										
										
											2021-09-23 17:49:05 -07:00
										 |  |  |   privateKey: Uint8Array; | 
					
						
							|  |  |  |   publicKey: Uint8Array; | 
					
						
							| 
									
										
										
										
											2021-04-05 15:18:19 -07:00
										 |  |  | }; | 
					
						
							| 
									
										
										
										
											2023-07-14 09:53:20 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  | export type StoredPreKeyType = PreKeyType & { | 
					
						
							| 
									
										
										
										
											2022-07-28 09:35:29 -07:00
										 |  |  |   privateKey: string; | 
					
						
							|  |  |  |   publicKey: string; | 
					
						
							|  |  |  | }; | 
					
						
							| 
									
										
										
										
											2025-05-22 21:09:54 -04:00
										 |  |  | export type ServerSearchResultMessageType = MessageType & | 
					
						
							|  |  |  |   ServerMessageSearchResultType; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | export type ServerMessageSearchResultType = { | 
					
						
							| 
									
										
										
										
											2023-06-26 14:25:48 -04:00
										 |  |  |   // If the FTS matches text in message.body, snippet will be populated
 | 
					
						
							|  |  |  |   ftsSnippet: string | null; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   // Otherwise, a matching mention will be returned
 | 
					
						
							| 
									
										
										
										
											2023-08-16 22:54:39 +02:00
										 |  |  |   mentionAci: string | null; | 
					
						
							| 
									
										
										
										
											2023-06-26 14:25:48 -04:00
										 |  |  |   mentionStart: number | null; | 
					
						
							|  |  |  |   mentionLength: number | null; | 
					
						
							| 
									
										
										
										
											2021-04-05 15:18:19 -07:00
										 |  |  | }; | 
					
						
							|  |  |  | export type ClientSearchResultMessageType = MessageType & { | 
					
						
							| 
									
										
										
										
											2023-04-10 09:31:45 -07:00
										 |  |  |   bodyRanges: ReadonlyArray<RawBodyRange>; | 
					
						
							| 
									
										
										
										
											2021-04-05 15:18:19 -07:00
										 |  |  |   snippet: string; | 
					
						
							|  |  |  | }; | 
					
						
							| 
									
										
										
										
											2021-07-15 16:48:09 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  | export type SentProtoType = { | 
					
						
							|  |  |  |   contentHint: number; | 
					
						
							| 
									
										
										
										
											2021-09-23 17:49:05 -07:00
										 |  |  |   proto: Uint8Array; | 
					
						
							| 
									
										
										
										
											2021-07-15 16:48:09 -07:00
										 |  |  |   timestamp: number; | 
					
						
							| 
									
										
										
										
											2022-07-01 09:55:13 -07:00
										 |  |  |   urgent: boolean; | 
					
						
							| 
									
										
										
										
											2022-08-15 14:53:33 -07:00
										 |  |  |   hasPniSignatureMessage: boolean; | 
					
						
							| 
									
										
										
										
											2021-07-15 16:48:09 -07:00
										 |  |  | }; | 
					
						
							| 
									
										
										
										
											2025-03-12 14:45:54 -07:00
										 |  |  | export type SentProtoDBType = { | 
					
						
							|  |  |  |   contentHint: number; | 
					
						
							|  |  |  |   proto: Uint8Array; | 
					
						
							|  |  |  |   timestamp: number; | 
					
						
							|  |  |  |   urgent: number; | 
					
						
							|  |  |  |   hasPniSignatureMessage: number; | 
					
						
							|  |  |  | }; | 
					
						
							| 
									
										
										
										
											2021-07-15 16:48:09 -07:00
										 |  |  | export type SentProtoWithMessageIdsType = SentProtoType & { | 
					
						
							|  |  |  |   messageIds: Array<string>; | 
					
						
							|  |  |  | }; | 
					
						
							| 
									
										
										
										
											2023-08-10 18:43:33 +02:00
										 |  |  | export type SentRecipientsType = Record<ServiceIdString, Array<number>>; | 
					
						
							| 
									
										
										
										
											2021-07-15 16:48:09 -07:00
										 |  |  | export type SentMessagesType = Array<string>; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | // These two are for test only
 | 
					
						
							|  |  |  | export type SentRecipientsDBType = { | 
					
						
							|  |  |  |   payloadId: number; | 
					
						
							| 
									
										
										
										
											2023-08-16 22:54:39 +02:00
										 |  |  |   recipientServiceId: ServiceIdString; | 
					
						
							| 
									
										
										
										
											2021-07-15 16:48:09 -07:00
										 |  |  |   deviceId: number; | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | export type SentMessageDBType = { | 
					
						
							|  |  |  |   payloadId: number; | 
					
						
							|  |  |  |   messageId: string; | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-05-13 18:18:43 -07:00
										 |  |  | export type SenderKeyType = { | 
					
						
							|  |  |  |   // Primary key
 | 
					
						
							| 
									
										
										
										
											2021-09-09 19:38:11 -07:00
										 |  |  |   id: `${QualifiedAddressStringType}--${string}`; | 
					
						
							| 
									
										
										
										
											2021-05-13 18:18:43 -07:00
										 |  |  |   // These two are combined into one string to give us the final id
 | 
					
						
							|  |  |  |   senderId: string; | 
					
						
							|  |  |  |   distributionId: string; | 
					
						
							|  |  |  |   // Raw data to serialize/deserialize into signal-client SenderKeyRecord
 | 
					
						
							| 
									
										
										
										
											2021-09-23 17:49:05 -07:00
										 |  |  |   data: Uint8Array; | 
					
						
							| 
									
										
										
										
											2021-05-13 18:18:43 -07:00
										 |  |  |   lastUpdatedDate: number; | 
					
						
							|  |  |  | }; | 
					
						
							| 
									
										
										
										
											2021-09-09 19:38:11 -07:00
										 |  |  | export type SenderKeyIdType = SenderKeyType['id']; | 
					
						
							| 
									
										
										
										
											2021-04-05 15:18:19 -07:00
										 |  |  | export type SessionType = { | 
					
						
							| 
									
										
										
										
											2021-09-09 19:38:11 -07:00
										 |  |  |   id: QualifiedAddressStringType; | 
					
						
							| 
									
										
										
										
											2023-08-16 22:54:39 +02:00
										 |  |  |   ourServiceId: ServiceIdString; | 
					
						
							|  |  |  |   serviceId: ServiceIdString; | 
					
						
							| 
									
										
										
										
											2021-04-05 15:18:19 -07:00
										 |  |  |   conversationId: string; | 
					
						
							|  |  |  |   deviceId: number; | 
					
						
							| 
									
										
										
										
											2024-10-02 17:23:00 -07:00
										 |  |  |   record: Uint8Array; | 
					
						
							| 
									
										
										
										
											2021-04-05 15:18:19 -07:00
										 |  |  | }; | 
					
						
							| 
									
										
										
										
											2021-09-09 19:38:11 -07:00
										 |  |  | export type SessionIdType = SessionType['id']; | 
					
						
							| 
									
										
										
										
											2021-04-05 15:18:19 -07:00
										 |  |  | export type SignedPreKeyType = { | 
					
						
							|  |  |  |   confirmed: boolean; | 
					
						
							|  |  |  |   created_at: number; | 
					
						
							| 
									
										
										
										
											2023-08-16 22:54:39 +02:00
										 |  |  |   ourServiceId: ServiceIdString; | 
					
						
							| 
									
										
										
										
											2023-08-10 18:43:33 +02:00
										 |  |  |   id: `${ServiceIdString}:${number}`; | 
					
						
							| 
									
										
										
										
											2021-09-09 19:38:11 -07:00
										 |  |  |   keyId: number; | 
					
						
							| 
									
										
										
										
											2021-09-23 17:49:05 -07:00
										 |  |  |   privateKey: Uint8Array; | 
					
						
							|  |  |  |   publicKey: Uint8Array; | 
					
						
							| 
									
										
										
										
											2021-04-05 15:18:19 -07:00
										 |  |  | }; | 
					
						
							| 
									
										
										
										
											2022-07-28 09:35:29 -07:00
										 |  |  | export type StoredSignedPreKeyType = { | 
					
						
							|  |  |  |   confirmed: boolean; | 
					
						
							|  |  |  |   created_at: number; | 
					
						
							| 
									
										
										
										
											2023-08-16 22:54:39 +02:00
										 |  |  |   ourServiceId: ServiceIdString; | 
					
						
							| 
									
										
										
										
											2023-08-10 18:43:33 +02:00
										 |  |  |   id: `${ServiceIdString}:${number}`; | 
					
						
							| 
									
										
										
										
											2022-07-28 09:35:29 -07:00
										 |  |  |   keyId: number; | 
					
						
							|  |  |  |   privateKey: string; | 
					
						
							|  |  |  |   publicKey: string; | 
					
						
							|  |  |  | }; | 
					
						
							| 
									
										
										
										
											2021-09-09 19:38:11 -07:00
										 |  |  | export type SignedPreKeyIdType = SignedPreKeyType['id']; | 
					
						
							| 
									
										
										
										
											2021-04-05 15:18:19 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-07-09 12:36:10 -07:00
										 |  |  | export type StickerType = Readonly<{ | 
					
						
							| 
									
										
										
										
											2021-04-05 15:18:19 -07:00
										 |  |  |   id: number; | 
					
						
							|  |  |  |   packId: string; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-07-09 12:36:10 -07:00
										 |  |  |   emoji?: string; | 
					
						
							| 
									
										
										
										
											2021-04-07 13:00:22 -07:00
										 |  |  |   isCoverOnly: boolean; | 
					
						
							|  |  |  |   lastUsed?: number; | 
					
						
							| 
									
										
										
										
											2021-04-05 15:18:19 -07:00
										 |  |  |   path: string; | 
					
						
							| 
									
										
										
										
											2021-07-09 12:36:10 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-04-05 15:18:19 -07:00
										 |  |  |   width: number; | 
					
						
							|  |  |  |   height: number; | 
					
						
							| 
									
										
										
										
											2024-07-11 12:44:09 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  |   version: 1 | 2; | 
					
						
							|  |  |  |   localKey?: string; | 
					
						
							|  |  |  |   size?: number; | 
					
						
							| 
									
										
										
										
											2021-07-09 12:36:10 -07:00
										 |  |  | }>; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | export const StickerPackStatuses = [ | 
					
						
							|  |  |  |   'known', | 
					
						
							|  |  |  |   'ephemeral', | 
					
						
							|  |  |  |   'downloaded', | 
					
						
							|  |  |  |   'installed', | 
					
						
							|  |  |  |   'pending', | 
					
						
							|  |  |  |   'error', | 
					
						
							|  |  |  | ] as const; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-07-23 17:31:40 -07:00
										 |  |  | export type StickerPackStatusType = (typeof StickerPackStatuses)[number]; | 
					
						
							| 
									
										
										
										
											2021-07-09 12:36:10 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-08-03 10:10:49 -07:00
										 |  |  | export type StorageServiceFieldsType = Readonly<{ | 
					
						
							| 
									
										
										
										
											2025-08-25 18:02:05 -07:00
										 |  |  |   storageID?: string | null; | 
					
						
							|  |  |  |   storageVersion?: number | null; | 
					
						
							| 
									
										
										
										
											2022-08-03 10:10:49 -07:00
										 |  |  |   storageUnknownFields?: Uint8Array | null; | 
					
						
							|  |  |  |   storageNeedsSync: boolean; | 
					
						
							|  |  |  | }>; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | export type InstalledStickerPackType = Readonly<{ | 
					
						
							| 
									
										
										
										
											2021-04-05 15:18:19 -07:00
										 |  |  |   id: string; | 
					
						
							|  |  |  |   key: string; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-08-03 10:10:49 -07:00
										 |  |  |   uninstalledAt?: undefined; | 
					
						
							|  |  |  |   position?: number | null; | 
					
						
							|  |  |  | }> & | 
					
						
							|  |  |  |   StorageServiceFieldsType; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | export type UninstalledStickerPackType = Readonly<{ | 
					
						
							|  |  |  |   id: string; | 
					
						
							|  |  |  |   key?: undefined; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   uninstalledAt: number; | 
					
						
							|  |  |  |   position?: undefined; | 
					
						
							|  |  |  | }> & | 
					
						
							|  |  |  |   StorageServiceFieldsType; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | export type StickerPackInfoType = | 
					
						
							|  |  |  |   | InstalledStickerPackType | 
					
						
							|  |  |  |   | UninstalledStickerPackType; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | export type StickerPackType = InstalledStickerPackType & | 
					
						
							|  |  |  |   Readonly<{ | 
					
						
							|  |  |  |     attemptedStatus?: 'downloaded' | 'installed' | 'ephemeral'; | 
					
						
							|  |  |  |     author: string; | 
					
						
							|  |  |  |     coverStickerId: number; | 
					
						
							|  |  |  |     createdAt: number; | 
					
						
							|  |  |  |     downloadAttempts: number; | 
					
						
							|  |  |  |     installedAt?: number; | 
					
						
							|  |  |  |     lastUsed?: number; | 
					
						
							|  |  |  |     status: StickerPackStatusType; | 
					
						
							|  |  |  |     stickerCount: number; | 
					
						
							|  |  |  |     stickers: Record<string, StickerType>; | 
					
						
							|  |  |  |     title: string; | 
					
						
							|  |  |  |   }>; | 
					
						
							| 
									
										
										
										
											2021-07-09 12:36:10 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-01-28 13:57:19 -08:00
										 |  |  | export type StickerPackRefType = Readonly<{ | 
					
						
							|  |  |  |   packId: string; | 
					
						
							|  |  |  |   messageId: string; | 
					
						
							|  |  |  |   stickerId: number; | 
					
						
							|  |  |  |   isUnresolved: boolean; | 
					
						
							|  |  |  | }>; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-04-05 15:18:19 -07:00
										 |  |  | export type UnprocessedType = { | 
					
						
							|  |  |  |   id: string; | 
					
						
							|  |  |  |   timestamp: number; | 
					
						
							| 
									
										
										
										
											2025-02-10 12:44:59 -08:00
										 |  |  |   /* | 
					
						
							|  |  |  |    * A client generated date used for removing old envelopes from the table | 
					
						
							|  |  |  |    * on startup. | 
					
						
							|  |  |  |    */ | 
					
						
							|  |  |  |   receivedAtDate: number; | 
					
						
							| 
									
										
										
										
											2025-01-21 13:42:14 -08:00
										 |  |  |   receivedAtCounter: number; | 
					
						
							| 
									
										
										
										
											2021-04-05 15:18:19 -07:00
										 |  |  |   attempts: number; | 
					
						
							| 
									
										
										
										
											2025-01-21 13:42:14 -08:00
										 |  |  |   type: number; | 
					
						
							|  |  |  |   isEncrypted: boolean; | 
					
						
							|  |  |  |   content: Uint8Array; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   messageAgeSec: number; | 
					
						
							|  |  |  |   source: string | undefined; | 
					
						
							|  |  |  |   sourceServiceId: ServiceIdString | undefined; | 
					
						
							|  |  |  |   sourceDevice: number | undefined; | 
					
						
							|  |  |  |   destinationServiceId: ServiceIdString; | 
					
						
							|  |  |  |   updatedPni: PniString | undefined; | 
					
						
							|  |  |  |   serverGuid: string; | 
					
						
							|  |  |  |   serverTimestamp: number; | 
					
						
							|  |  |  |   urgent: boolean; | 
					
						
							|  |  |  |   story: boolean; | 
					
						
							|  |  |  |   reportingToken: Uint8Array | undefined; | 
					
						
							|  |  |  |   groupId: string | undefined; | 
					
						
							| 
									
										
										
										
											2021-04-16 16:13:13 -07:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-03-15 17:11:28 -07:00
										 |  |  | export type ConversationMessageStatsType = { | 
					
						
							| 
									
										
										
										
											2021-08-16 09:56:27 -07:00
										 |  |  |   activity?: MessageType; | 
					
						
							|  |  |  |   preview?: MessageType; | 
					
						
							|  |  |  |   hasUserInitiatedMessages: boolean; | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-08-31 14:35:01 -07:00
										 |  |  | export type DeleteSentProtoRecipientOptionsType = Readonly<{ | 
					
						
							|  |  |  |   timestamp: number; | 
					
						
							| 
									
										
										
										
											2023-08-10 18:43:33 +02:00
										 |  |  |   recipientServiceId: ServiceIdString; | 
					
						
							| 
									
										
										
										
											2021-08-31 14:35:01 -07:00
										 |  |  |   deviceId: number; | 
					
						
							|  |  |  | }>; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-08-15 14:53:33 -07:00
										 |  |  | export type DeleteSentProtoRecipientResultType = Readonly<{ | 
					
						
							| 
									
										
										
										
											2023-08-16 22:54:39 +02:00
										 |  |  |   successfulPhoneNumberShares: ReadonlyArray<ServiceIdString>; | 
					
						
							| 
									
										
										
										
											2022-08-15 14:53:33 -07:00
										 |  |  | }>; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-12-08 11:52:46 -08:00
										 |  |  | export type StoryDistributionType = Readonly<{ | 
					
						
							| 
									
										
										
										
											2023-08-10 18:43:33 +02:00
										 |  |  |   id: StoryDistributionIdString; | 
					
						
							| 
									
										
										
										
											2021-12-08 11:52:46 -08:00
										 |  |  |   name: string; | 
					
						
							| 
									
										
										
										
											2022-06-30 20:52:03 -04:00
										 |  |  |   deletedAtTimestamp?: number; | 
					
						
							|  |  |  |   allowsReplies: boolean; | 
					
						
							|  |  |  |   isBlockList: boolean; | 
					
						
							| 
									
										
										
										
											2021-12-08 11:52:46 -08:00
										 |  |  |   senderKeyInfo: SenderKeyInfoType | undefined; | 
					
						
							| 
									
										
										
										
											2022-08-03 10:10:49 -07:00
										 |  |  | }> & | 
					
						
							|  |  |  |   StorageServiceFieldsType; | 
					
						
							| 
									
										
										
										
											2021-12-08 11:52:46 -08:00
										 |  |  | export type StoryDistributionMemberType = Readonly<{ | 
					
						
							| 
									
										
										
										
											2023-08-10 18:43:33 +02:00
										 |  |  |   listId: StoryDistributionIdString; | 
					
						
							| 
									
										
										
										
											2023-08-16 22:54:39 +02:00
										 |  |  |   serviceId: ServiceIdString; | 
					
						
							| 
									
										
										
										
											2021-12-08 11:52:46 -08:00
										 |  |  | }>; | 
					
						
							|  |  |  | export type StoryDistributionWithMembersType = Readonly< | 
					
						
							|  |  |  |   { | 
					
						
							| 
									
										
										
										
											2023-08-10 18:43:33 +02:00
										 |  |  |     members: Array<ServiceIdString>; | 
					
						
							| 
									
										
										
										
											2021-12-08 11:52:46 -08:00
										 |  |  |   } & StoryDistributionType | 
					
						
							|  |  |  | >; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | export type StoryReadType = Readonly<{ | 
					
						
							| 
									
										
										
										
											2023-08-10 18:43:33 +02:00
										 |  |  |   authorId: ServiceIdString; | 
					
						
							| 
									
										
										
										
											2022-07-08 13:46:25 -07:00
										 |  |  |   conversationId: string; | 
					
						
							|  |  |  |   storyId: string; | 
					
						
							| 
									
										
										
										
											2021-12-08 11:52:46 -08:00
										 |  |  |   storyReadDate: number; | 
					
						
							|  |  |  | }>; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-07-28 09:35:29 -07:00
										 |  |  | export type ReactionResultType = Pick< | 
					
						
							|  |  |  |   ReactionType, | 
					
						
							| 
									
										
										
										
											2023-08-16 22:54:39 +02:00
										 |  |  |   'targetAuthorAci' | 'targetTimestamp' | 'messageId' | 
					
						
							| 
									
										
										
										
											2022-07-28 09:35:29 -07:00
										 |  |  | > & { rowid: number }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | export type GetUnreadByConversationAndMarkReadResultType = Array< | 
					
						
							|  |  |  |   { originalReadStatus: ReadStatus | undefined } & Pick< | 
					
						
							|  |  |  |     MessageType, | 
					
						
							|  |  |  |     | 'id' | 
					
						
							|  |  |  |     | 'source' | 
					
						
							| 
									
										
										
										
											2023-08-16 22:54:39 +02:00
										 |  |  |     | 'sourceServiceId' | 
					
						
							| 
									
										
										
										
											2022-07-28 09:35:29 -07:00
										 |  |  |     | 'sent_at' | 
					
						
							|  |  |  |     | 'type' | 
					
						
							|  |  |  |     | 'readStatus' | 
					
						
							|  |  |  |     | 'seenStatus' | 
					
						
							| 
									
										
										
										
											2024-06-26 16:51:11 -04:00
										 |  |  |     | 'expirationStartTimestamp' | 
					
						
							| 
									
										
										
										
											2022-07-28 09:35:29 -07:00
										 |  |  |   > | 
					
						
							|  |  |  | >; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | export type GetConversationRangeCenteredOnMessageResultType<Message> = | 
					
						
							|  |  |  |   Readonly<{ | 
					
						
							|  |  |  |     older: Array<Message>; | 
					
						
							|  |  |  |     newer: Array<Message>; | 
					
						
							|  |  |  |     metrics: ConversationMetricsType; | 
					
						
							|  |  |  |   }>; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-03-15 07:20:33 -07:00
										 |  |  | export type MessageCursorType = Readonly<{ | 
					
						
							| 
									
										
										
										
											2022-11-16 16:29:15 -08:00
										 |  |  |   done: boolean; | 
					
						
							|  |  |  |   runId: string; | 
					
						
							|  |  |  |   count: number; | 
					
						
							|  |  |  | }>; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-03-15 07:20:33 -07:00
										 |  |  | export type MessageAttachmentsCursorType = MessageCursorType & | 
					
						
							|  |  |  |   Readonly<{ | 
					
						
							|  |  |  |     __message_attachments_cursor: never; | 
					
						
							|  |  |  |   }>; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-11-16 16:29:15 -08:00
										 |  |  | export type GetKnownMessageAttachmentsResultType = Readonly<{ | 
					
						
							|  |  |  |   cursor: MessageAttachmentsCursorType; | 
					
						
							|  |  |  |   attachments: ReadonlyArray<string>; | 
					
						
							| 
									
										
										
										
											2024-08-19 13:05:35 -07:00
										 |  |  |   downloads: ReadonlyArray<string>; | 
					
						
							| 
									
										
										
										
											2022-11-16 16:29:15 -08:00
										 |  |  | }>; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-03-15 07:20:33 -07:00
										 |  |  | export type PageMessagesCursorType = MessageCursorType & | 
					
						
							|  |  |  |   Readonly<{ | 
					
						
							|  |  |  |     __page_messages_cursor: never; | 
					
						
							|  |  |  |   }>; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | export type PageMessagesResultType = Readonly<{ | 
					
						
							|  |  |  |   cursor: PageMessagesCursorType; | 
					
						
							|  |  |  |   messages: ReadonlyArray<MessageAttributesType>; | 
					
						
							|  |  |  | }>; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-11-28 09:19:48 -08:00
										 |  |  | export type GetAllStoriesResultType = ReadonlyArray< | 
					
						
							|  |  |  |   MessageType & { | 
					
						
							|  |  |  |     hasReplies: boolean; | 
					
						
							|  |  |  |     hasRepliesFromSelf: boolean; | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | >; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-03-27 19:48:57 -04:00
										 |  |  | export type EditedMessageType = Readonly<{ | 
					
						
							| 
									
										
										
										
											2023-05-16 10:37:12 -07:00
										 |  |  |   conversationId: string; | 
					
						
							| 
									
										
										
										
											2023-03-27 19:48:57 -04:00
										 |  |  |   messageId: string; | 
					
						
							|  |  |  |   sentAt: number; | 
					
						
							|  |  |  |   readStatus: MessageType['readStatus']; | 
					
						
							|  |  |  | }>; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-05-29 19:46:43 -04:00
										 |  |  | export type BackupCdnMediaObjectType = { | 
					
						
							|  |  |  |   mediaId: string; | 
					
						
							|  |  |  |   cdnNumber: number; | 
					
						
							|  |  |  |   sizeOnBackupCdn: number; | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-07-22 11:16:33 -07:00
										 |  |  | export type GetRecentStoryRepliesOptionsType = { | 
					
						
							|  |  |  |   limit?: number; | 
					
						
							|  |  |  |   messageId?: string; | 
					
						
							|  |  |  |   receivedAt?: number; | 
					
						
							|  |  |  |   sentAt?: number; | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-09-03 18:00:51 -04:00
										 |  |  | export enum AttachmentDownloadSource { | 
					
						
							| 
									
										
										
										
											2025-09-10 16:16:46 -04:00
										 |  |  |   // Imported when paid (media) backups were enabled, or from a local backup
 | 
					
						
							|  |  |  |   BACKUP_IMPORT_WITH_MEDIA = 'backup_import', | 
					
						
							|  |  |  |   // Imported when paid (media) backups were not enabled
 | 
					
						
							|  |  |  |   BACKUP_IMPORT_NO_MEDIA = 'backup_import_no_media', | 
					
						
							| 
									
										
										
										
											2024-09-03 18:00:51 -04:00
										 |  |  |   STANDARD = 'standard', | 
					
						
							| 
									
										
										
										
											2025-03-24 23:34:58 -07:00
										 |  |  |   BACKFILL = 'backfill', | 
					
						
							| 
									
										
										
										
											2024-09-03 18:00:51 -04:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-06-02 17:20:06 -04:00
										 |  |  | export type MessageCountBySchemaVersionType = Array<{ | 
					
						
							|  |  |  |   schemaVersion: number; | 
					
						
							|  |  |  |   count: number; | 
					
						
							|  |  |  | }>; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-07-18 14:21:15 -04:00
										 |  |  | export type BackupAttachmentDownloadProgress = { | 
					
						
							|  |  |  |   totalBytes: number; | 
					
						
							|  |  |  |   completedBytes: number; | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-09-10 13:25:21 -07:00
										 |  |  | export type GetOlderMediaOptionsType = Readonly<{ | 
					
						
							|  |  |  |   conversationId: string; | 
					
						
							|  |  |  |   limit: number; | 
					
						
							|  |  |  |   messageId?: string; | 
					
						
							|  |  |  |   receivedAt?: number; | 
					
						
							|  |  |  |   sentAt?: number; | 
					
						
							| 
									
										
										
										
											2025-09-23 11:53:41 -07:00
										 |  |  |   type: 'media' | 'files'; | 
					
						
							| 
									
										
										
										
											2025-09-10 13:25:21 -07:00
										 |  |  | }>; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | export type MediaItemDBType = Readonly<{ | 
					
						
							|  |  |  |   attachment: AttachmentType; | 
					
						
							|  |  |  |   index: number; | 
					
						
							|  |  |  |   message: MediaItemMessageType; | 
					
						
							|  |  |  | }>; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-09-29 16:23:41 -07:00
										 |  |  | export type KyberPreKeyTripleType = Readonly<{ | 
					
						
							|  |  |  |   id: PreKeyIdType; | 
					
						
							|  |  |  |   signedPreKeyId: number; | 
					
						
							|  |  |  |   baseKey: Uint8Array; | 
					
						
							|  |  |  | }>; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-05-22 21:09:54 -04:00
										 |  |  | export const MESSAGE_ATTACHMENT_COLUMNS = [ | 
					
						
							|  |  |  |   'messageId', | 
					
						
							|  |  |  |   'conversationId', | 
					
						
							| 
									
										
										
										
											2025-09-10 13:25:21 -07:00
										 |  |  |   'messageType', | 
					
						
							|  |  |  |   'receivedAt', | 
					
						
							|  |  |  |   'receivedAtMs', | 
					
						
							| 
									
										
										
										
											2025-05-22 21:09:54 -04:00
										 |  |  |   'sentAt', | 
					
						
							|  |  |  |   'attachmentType', | 
					
						
							|  |  |  |   'orderInMessage', | 
					
						
							|  |  |  |   'editHistoryIndex', | 
					
						
							|  |  |  |   'clientUuid', | 
					
						
							|  |  |  |   'size', | 
					
						
							| 
									
										
										
										
											2025-09-15 10:37:40 -07:00
										 |  |  |   'duration', | 
					
						
							| 
									
										
										
										
											2025-05-22 21:09:54 -04:00
										 |  |  |   'contentType', | 
					
						
							|  |  |  |   'path', | 
					
						
							|  |  |  |   'localKey', | 
					
						
							|  |  |  |   'plaintextHash', | 
					
						
							|  |  |  |   'caption', | 
					
						
							|  |  |  |   'fileName', | 
					
						
							|  |  |  |   'blurHash', | 
					
						
							|  |  |  |   'height', | 
					
						
							|  |  |  |   'width', | 
					
						
							|  |  |  |   'digest', | 
					
						
							|  |  |  |   'key', | 
					
						
							|  |  |  |   'flags', | 
					
						
							|  |  |  |   'downloadPath', | 
					
						
							|  |  |  |   'transitCdnKey', | 
					
						
							|  |  |  |   'transitCdnNumber', | 
					
						
							|  |  |  |   'transitCdnUploadTimestamp', | 
					
						
							|  |  |  |   'backupCdnNumber', | 
					
						
							|  |  |  |   'incrementalMac', | 
					
						
							|  |  |  |   'incrementalMacChunkSize', | 
					
						
							|  |  |  |   'thumbnailPath', | 
					
						
							|  |  |  |   'thumbnailSize', | 
					
						
							|  |  |  |   'thumbnailContentType', | 
					
						
							|  |  |  |   'thumbnailLocalKey', | 
					
						
							|  |  |  |   'thumbnailVersion', | 
					
						
							|  |  |  |   'screenshotPath', | 
					
						
							|  |  |  |   'screenshotSize', | 
					
						
							|  |  |  |   'screenshotContentType', | 
					
						
							|  |  |  |   'screenshotLocalKey', | 
					
						
							|  |  |  |   'screenshotVersion', | 
					
						
							|  |  |  |   'backupThumbnailPath', | 
					
						
							|  |  |  |   'backupThumbnailSize', | 
					
						
							|  |  |  |   'backupThumbnailContentType', | 
					
						
							|  |  |  |   'backupThumbnailLocalKey', | 
					
						
							|  |  |  |   'backupThumbnailVersion', | 
					
						
							|  |  |  |   'storyTextAttachmentJson', | 
					
						
							|  |  |  |   'localBackupPath', | 
					
						
							|  |  |  |   'isCorrupted', | 
					
						
							| 
									
										
										
										
											2025-09-10 13:25:21 -07:00
										 |  |  |   'isViewOnce', | 
					
						
							| 
									
										
										
										
											2025-05-22 21:09:54 -04:00
										 |  |  |   'backfillError', | 
					
						
							|  |  |  |   'error', | 
					
						
							|  |  |  |   'wasTooBig', | 
					
						
							|  |  |  |   'copiedFromQuotedAttachment', | 
					
						
							|  |  |  |   'version', | 
					
						
							|  |  |  |   'pending', | 
					
						
							|  |  |  | ] as const satisfies Array<keyof MessageAttachmentDBType>; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | export type MessageAttachmentDBType = { | 
					
						
							|  |  |  |   messageId: string; | 
					
						
							| 
									
										
										
										
											2025-09-24 10:55:08 -04:00
										 |  |  |   attachmentType: MessageAttachmentType; | 
					
						
							| 
									
										
										
										
											2025-05-22 21:09:54 -04:00
										 |  |  |   orderInMessage: number; | 
					
						
							|  |  |  |   editHistoryIndex: number | null; | 
					
						
							|  |  |  |   conversationId: string; | 
					
						
							| 
									
										
										
										
											2025-09-10 13:25:21 -07:00
										 |  |  |   messageType: string; | 
					
						
							|  |  |  |   receivedAt: number; | 
					
						
							|  |  |  |   receivedAtMs: number | null; | 
					
						
							| 
									
										
										
										
											2025-05-22 21:09:54 -04:00
										 |  |  |   sentAt: number; | 
					
						
							|  |  |  |   clientUuid: string | null; | 
					
						
							|  |  |  |   size: number; | 
					
						
							| 
									
										
										
										
											2025-09-15 10:37:40 -07:00
										 |  |  |   duration: number | null; | 
					
						
							| 
									
										
										
										
											2025-05-22 21:09:54 -04:00
										 |  |  |   contentType: string; | 
					
						
							|  |  |  |   path: string | null; | 
					
						
							|  |  |  |   plaintextHash: string | null; | 
					
						
							|  |  |  |   downloadPath: string | null; | 
					
						
							|  |  |  |   caption: string | null; | 
					
						
							|  |  |  |   blurHash: string | null; | 
					
						
							|  |  |  |   width: number | null; | 
					
						
							|  |  |  |   height: number | null; | 
					
						
							|  |  |  |   flags: number | null; | 
					
						
							|  |  |  |   key: string | null; | 
					
						
							|  |  |  |   digest: string | null; | 
					
						
							|  |  |  |   fileName: string | null; | 
					
						
							|  |  |  |   incrementalMac: string | null; | 
					
						
							|  |  |  |   incrementalMacChunkSize: number | null; | 
					
						
							|  |  |  |   localKey: string | null; | 
					
						
							|  |  |  |   version: 1 | 2 | null; | 
					
						
							|  |  |  |   transitCdnKey: string | null; | 
					
						
							|  |  |  |   transitCdnNumber: number | null; | 
					
						
							|  |  |  |   transitCdnUploadTimestamp: number | null; | 
					
						
							|  |  |  |   backupCdnNumber: number | null; | 
					
						
							|  |  |  |   thumbnailPath: string | null; | 
					
						
							|  |  |  |   thumbnailSize: number | null; | 
					
						
							|  |  |  |   thumbnailContentType: string | null; | 
					
						
							|  |  |  |   thumbnailLocalKey: string | null; | 
					
						
							|  |  |  |   thumbnailVersion: 1 | 2 | null; | 
					
						
							|  |  |  |   screenshotPath: string | null; | 
					
						
							|  |  |  |   screenshotSize: number | null; | 
					
						
							|  |  |  |   screenshotContentType: string | null; | 
					
						
							|  |  |  |   screenshotLocalKey: string | null; | 
					
						
							|  |  |  |   screenshotVersion: 1 | 2 | null; | 
					
						
							|  |  |  |   backupThumbnailPath: string | null; | 
					
						
							|  |  |  |   backupThumbnailSize: number | null; | 
					
						
							|  |  |  |   backupThumbnailContentType: string | null; | 
					
						
							|  |  |  |   backupThumbnailLocalKey: string | null; | 
					
						
							|  |  |  |   backupThumbnailVersion: 1 | 2 | null; | 
					
						
							|  |  |  |   storyTextAttachmentJson: string | null; | 
					
						
							|  |  |  |   localBackupPath: string | null; | 
					
						
							|  |  |  |   isCorrupted: 1 | 0 | null; | 
					
						
							| 
									
										
										
										
											2025-09-10 13:25:21 -07:00
										 |  |  |   isViewOnce: 1 | 0 | null; | 
					
						
							| 
									
										
										
										
											2025-05-22 21:09:54 -04:00
										 |  |  |   backfillError: 1 | 0 | null; | 
					
						
							|  |  |  |   error: 1 | 0 | null; | 
					
						
							|  |  |  |   wasTooBig: 1 | 0 | null; | 
					
						
							|  |  |  |   pending: 1 | 0 | null; | 
					
						
							|  |  |  |   copiedFromQuotedAttachment: 1 | 0 | null; | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | // Test to make sure that MESSAGE_ATTACHMENT_COLUMNS &
 | 
					
						
							|  |  |  | // MessageAttachmentDBReferenceType remain in sync!
 | 
					
						
							|  |  |  | const testDBRefTypeMatchesColumnNames = true as unknown as [ | 
					
						
							|  |  |  |   keyof MessageAttachmentDBType, | 
					
						
							|  |  |  | ] satisfies [(typeof MESSAGE_ATTACHMENT_COLUMNS)[number]]; | 
					
						
							|  |  |  | strictAssert( | 
					
						
							|  |  |  |   testDBRefTypeMatchesColumnNames, | 
					
						
							|  |  |  |   'attachment_columns must match DB fields type' | 
					
						
							|  |  |  | ); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-07-22 11:16:33 -07:00
										 |  |  | type ReadableInterface = { | 
					
						
							|  |  |  |   close: () => void; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   getSenderKeyById: (id: SenderKeyIdType) => SenderKeyType | undefined; | 
					
						
							|  |  |  |   getAllSenderKeys: () => Array<SenderKeyType>; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   getAllSentProtos: () => Array<SentProtoType>; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   // Test-only
 | 
					
						
							|  |  |  |   _getAllSentProtoRecipients: () => Array<SentRecipientsDBType>; | 
					
						
							|  |  |  |   _getAllSentProtoMessageIds: () => Array<SentMessageDBType>; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   getAllSessions: () => Array<SessionType>; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-09-30 15:53:46 -07:00
										 |  |  |   getAllKyberTriples: () => Array<KyberPreKeyTripleType>; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-07-22 11:16:33 -07:00
										 |  |  |   getConversationCount: () => number; | 
					
						
							|  |  |  |   getConversationById: (id: string) => ConversationType | undefined; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   getAllConversations: () => Array<ConversationType>; | 
					
						
							|  |  |  |   getAllConversationIds: () => Array<string>; | 
					
						
							|  |  |  |   getGroupSendCombinedEndorsementExpiration: (groupId: string) => number | null; | 
					
						
							| 
									
										
										
										
											2024-09-06 10:52:19 -07:00
										 |  |  |   getGroupSendEndorsementsData: ( | 
					
						
							|  |  |  |     groupId: string | 
					
						
							|  |  |  |   ) => GroupSendEndorsementsData | null; | 
					
						
							|  |  |  |   getGroupSendMemberEndorsement: ( | 
					
						
							|  |  |  |     groupId: string, | 
					
						
							|  |  |  |     memberAci: AciString | 
					
						
							|  |  |  |   ) => GroupSendMemberEndorsementRecord | null; | 
					
						
							| 
									
										
										
										
											2024-07-22 11:16:33 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  |   getMessageCount: (conversationId?: string) => number; | 
					
						
							|  |  |  |   getStoryCount: (conversationId: string) => number; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   pageMessages: (cursor?: PageMessagesCursorType) => PageMessagesResultType; | 
					
						
							|  |  |  |   finishPageMessages: (cursor: PageMessagesCursorType) => void; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   getTotalUnreadForConversation: ( | 
					
						
							|  |  |  |     conversationId: string, | 
					
						
							|  |  |  |     options: { | 
					
						
							|  |  |  |       storyId: string | undefined; | 
					
						
							|  |  |  |       includeStoryReplies: boolean; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |   ) => number; | 
					
						
							|  |  |  |   getTotalUnreadMentionsOfMeForConversation: ( | 
					
						
							|  |  |  |     conversationId: string, | 
					
						
							|  |  |  |     options: { | 
					
						
							|  |  |  |       storyId?: string; | 
					
						
							|  |  |  |       includeStoryReplies: boolean; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |   ) => number; | 
					
						
							|  |  |  |   getOldestUnreadMentionOfMeForConversation( | 
					
						
							|  |  |  |     conversationId: string, | 
					
						
							|  |  |  |     options: { | 
					
						
							|  |  |  |       storyId?: string; | 
					
						
							|  |  |  |       includeStoryReplies: boolean; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |   ): MessageMetricsType | undefined; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   getReactionByTimestamp: ( | 
					
						
							|  |  |  |     fromId: string, | 
					
						
							|  |  |  |     timestamp: number | 
					
						
							|  |  |  |   ) => ReactionType | undefined; | 
					
						
							|  |  |  |   _getAllReactions: () => Array<ReactionType>; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   getMessageBySender: (options: { | 
					
						
							|  |  |  |     source?: string; | 
					
						
							|  |  |  |     sourceServiceId?: ServiceIdString; | 
					
						
							|  |  |  |     sourceDevice?: number; | 
					
						
							|  |  |  |     sent_at: number; | 
					
						
							|  |  |  |   }) => MessageType | undefined; | 
					
						
							|  |  |  |   getMessageById: (id: string) => MessageType | undefined; | 
					
						
							|  |  |  |   getMessagesById: (messageIds: ReadonlyArray<string>) => Array<MessageType>; | 
					
						
							|  |  |  |   _getAllMessages: () => Array<MessageType>; | 
					
						
							|  |  |  |   _getAllEditedMessages: () => Array<{ messageId: string; sentAt: number }>; | 
					
						
							|  |  |  |   getAllMessageIds: () => Array<string>; | 
					
						
							|  |  |  |   getMessagesBySentAt: (sentAt: number) => Array<MessageType>; | 
					
						
							|  |  |  |   getExpiredMessages: () => Array<MessageType>; | 
					
						
							|  |  |  |   getMessagesUnexpectedlyMissingExpirationStartTimestamp: () => Array<MessageType>; | 
					
						
							|  |  |  |   getSoonestMessageExpiry: () => undefined | number; | 
					
						
							|  |  |  |   getNextTapToViewMessageTimestampToAgeOut: () => undefined | number; | 
					
						
							| 
									
										
										
										
											2024-10-15 15:43:06 -07:00
										 |  |  |   getTapToViewMessagesNeedingErase: ( | 
					
						
							|  |  |  |     maxTimestamp: number | 
					
						
							|  |  |  |   ) => Array<MessageType>; | 
					
						
							| 
									
										
										
										
											2024-07-22 11:16:33 -07:00
										 |  |  |   // getOlderMessagesByConversation is JSON on server, full message on Client
 | 
					
						
							| 
									
										
										
										
											2025-09-10 13:25:21 -07:00
										 |  |  |   hasMedia: (conversationId: string) => boolean; | 
					
						
							|  |  |  |   getOlderMedia: (options: GetOlderMediaOptionsType) => Array<MediaItemDBType>; | 
					
						
							| 
									
										
										
										
											2024-07-22 11:16:33 -07:00
										 |  |  |   getAllStories: (options: { | 
					
						
							|  |  |  |     conversationId?: string; | 
					
						
							|  |  |  |     sourceServiceId?: ServiceIdString; | 
					
						
							|  |  |  |   }) => GetAllStoriesResultType; | 
					
						
							|  |  |  |   // getNewerMessagesByConversation is JSON on server, full message on Client
 | 
					
						
							|  |  |  |   getMessageMetricsForConversation: (options: { | 
					
						
							|  |  |  |     conversationId: string; | 
					
						
							|  |  |  |     storyId?: string; | 
					
						
							|  |  |  |     includeStoryReplies: boolean; | 
					
						
							|  |  |  |   }) => ConversationMetricsType; | 
					
						
							|  |  |  |   // getConversationRangeCenteredOnMessage is JSON on server, full message on client
 | 
					
						
							|  |  |  |   getConversationMessageStats: (options: { | 
					
						
							|  |  |  |     conversationId: string; | 
					
						
							|  |  |  |     includeStoryReplies: boolean; | 
					
						
							|  |  |  |   }) => ConversationMessageStatsType; | 
					
						
							|  |  |  |   getLastConversationMessage(options: { | 
					
						
							|  |  |  |     conversationId: string; | 
					
						
							|  |  |  |   }): MessageType | undefined; | 
					
						
							|  |  |  |   getAllCallHistory: () => ReadonlyArray<CallHistoryDetails>; | 
					
						
							|  |  |  |   getCallHistoryUnreadCount(): number; | 
					
						
							|  |  |  |   getCallHistoryMessageByCallId(options: { | 
					
						
							|  |  |  |     conversationId: string; | 
					
						
							|  |  |  |     callId: string; | 
					
						
							|  |  |  |   }): MessageType | undefined; | 
					
						
							|  |  |  |   getCallHistory( | 
					
						
							|  |  |  |     callId: string, | 
					
						
							|  |  |  |     peerId: ServiceIdString | string | 
					
						
							|  |  |  |   ): CallHistoryDetails | undefined; | 
					
						
							|  |  |  |   getCallHistoryGroupsCount(filter: CallHistoryFilter): number; | 
					
						
							|  |  |  |   getCallHistoryGroups( | 
					
						
							|  |  |  |     filter: CallHistoryFilter, | 
					
						
							|  |  |  |     pagination: CallHistoryPagination | 
					
						
							|  |  |  |   ): Array<CallHistoryGroup>; | 
					
						
							|  |  |  |   hasGroupCallHistoryMessage: ( | 
					
						
							|  |  |  |     conversationId: string, | 
					
						
							|  |  |  |     eraId: string | 
					
						
							|  |  |  |   ) => boolean; | 
					
						
							|  |  |  |   callLinkExists(roomId: string): boolean; | 
					
						
							| 
									
										
										
										
											2024-10-15 11:49:32 -07:00
										 |  |  |   defunctCallLinkExists(roomId: string): boolean; | 
					
						
							| 
									
										
										
										
											2024-07-22 11:16:33 -07:00
										 |  |  |   getAllCallLinks: () => ReadonlyArray<CallLinkType>; | 
					
						
							|  |  |  |   getCallLinkByRoomId: (roomId: string) => CallLinkType | undefined; | 
					
						
							| 
									
										
										
										
											2024-09-04 11:06:06 -07:00
										 |  |  |   getCallLinkRecordByRoomId: (roomId: string) => CallLinkRecord | undefined; | 
					
						
							| 
									
										
										
										
											2024-10-09 09:35:24 -07:00
										 |  |  |   getAllAdminCallLinks(): ReadonlyArray<CallLinkType>; | 
					
						
							| 
									
										
										
										
											2024-09-04 11:06:06 -07:00
										 |  |  |   getAllCallLinkRecordsWithAdminKey(): ReadonlyArray<CallLinkRecord>; | 
					
						
							| 
									
										
										
										
											2024-10-22 11:20:35 -07:00
										 |  |  |   getAllDefunctCallLinksWithAdminKey(): ReadonlyArray<DefunctCallLinkType>; | 
					
						
							| 
									
										
										
										
											2024-09-16 12:22:01 -07:00
										 |  |  |   getAllMarkedDeletedCallLinkRoomIds(): ReadonlyArray<string>; | 
					
						
							| 
									
										
										
										
											2024-07-22 11:16:33 -07:00
										 |  |  |   getMessagesBetween: ( | 
					
						
							|  |  |  |     conversationId: string, | 
					
						
							|  |  |  |     options: GetMessagesBetweenOptions | 
					
						
							|  |  |  |   ) => Array<string>; | 
					
						
							|  |  |  |   getNearbyMessageFromDeletedSet: ( | 
					
						
							|  |  |  |     options: GetNearbyMessageFromDeletedSetOptionsType | 
					
						
							|  |  |  |   ) => string | null; | 
					
						
							|  |  |  |   getMostRecentAddressableMessages: ( | 
					
						
							|  |  |  |     conversationId: string, | 
					
						
							|  |  |  |     limit?: number | 
					
						
							|  |  |  |   ) => Array<MessageType>; | 
					
						
							|  |  |  |   getMostRecentAddressableNondisappearingMessages: ( | 
					
						
							|  |  |  |     conversationId: string, | 
					
						
							|  |  |  |     limit?: number | 
					
						
							|  |  |  |   ) => Array<MessageType>; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   getUnprocessedCount: () => number; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-03-12 14:45:54 -07:00
										 |  |  |   // Test-only
 | 
					
						
							|  |  |  |   _getAttachmentDownloadJob( | 
					
						
							| 
									
										
										
										
											2024-07-22 11:16:33 -07:00
										 |  |  |     job: Pick< | 
					
						
							|  |  |  |       AttachmentDownloadJobType, | 
					
						
							| 
									
										
										
										
											2025-06-18 13:16:29 -04:00
										 |  |  |       'messageId' | 'attachmentType' | 'attachmentSignature' | 
					
						
							| 
									
										
										
										
											2024-07-22 11:16:33 -07:00
										 |  |  |     > | 
					
						
							| 
									
										
										
										
											2025-03-12 14:45:54 -07:00
										 |  |  |   ): AttachmentDownloadJobType | undefined; | 
					
						
							| 
									
										
										
										
											2024-07-22 11:16:33 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  |   getBackupCdnObjectMetadata: ( | 
					
						
							|  |  |  |     mediaId: string | 
					
						
							|  |  |  |   ) => BackupCdnMediaObjectType | undefined; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   getStickerCount: () => number; | 
					
						
							|  |  |  |   getAllStickerPacks: () => Array<StickerPackType>; | 
					
						
							|  |  |  |   getInstalledStickerPacks: () => Array<StickerPackType>; | 
					
						
							|  |  |  |   getUninstalledStickerPacks: () => Array<UninstalledStickerPackType>; | 
					
						
							|  |  |  |   getStickerPackInfo: (packId: string) => StickerPackInfoType | undefined; | 
					
						
							|  |  |  |   getAllStickers: () => Array<StickerType>; | 
					
						
							|  |  |  |   getRecentStickers: (options?: { limit?: number }) => Array<StickerType>; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   getRecentEmojis: (limit?: number) => Array<EmojiType>; | 
					
						
							| 
									
										
										
										
											2025-04-10 12:32:36 -07:00
										 |  |  |   getRecentGifs: (limit: number) => ReadonlyArray<GifType>; | 
					
						
							| 
									
										
										
										
											2024-07-22 11:16:33 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  |   getAllBadges(): Array<BadgeType>; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   _getAllStoryDistributions(): Array<StoryDistributionType>; | 
					
						
							|  |  |  |   _getAllStoryDistributionMembers(): Array<StoryDistributionMemberType>; | 
					
						
							|  |  |  |   getAllStoryDistributionsWithMembers(): Array<StoryDistributionWithMembersType>; | 
					
						
							|  |  |  |   getStoryDistributionWithMembers( | 
					
						
							|  |  |  |     id: string | 
					
						
							|  |  |  |   ): StoryDistributionWithMembersType | undefined; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   _getAllStoryReads(): Array<StoryReadType>; | 
					
						
							|  |  |  |   getLastStoryReadsForAuthor(options: { | 
					
						
							|  |  |  |     authorId: ServiceIdString; | 
					
						
							|  |  |  |     conversationId?: string; | 
					
						
							|  |  |  |     limit?: number; | 
					
						
							|  |  |  |   }): Array<StoryReadType>; | 
					
						
							|  |  |  |   countStoryReadsByConversation(conversationId: string): number; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-05-06 00:39:04 +10:00
										 |  |  |   getAllNotificationProfiles(): Array<NotificationProfileType>; | 
					
						
							|  |  |  |   getNotificationProfileById(id: string): NotificationProfileType | undefined; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-06-17 05:33:00 +10:00
										 |  |  |   getAllDonationReceipts(): Array<DonationReceipt>; | 
					
						
							|  |  |  |   getDonationReceiptById(id: string): DonationReceipt | undefined; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-08-25 18:02:05 -07:00
										 |  |  |   getAllChatFolders: () => ReadonlyArray<ChatFolder>; | 
					
						
							|  |  |  |   getCurrentChatFolders: () => ReadonlyArray<ChatFolder>; | 
					
						
							|  |  |  |   getChatFolder: (id: ChatFolderId) => ChatFolder | null; | 
					
						
							|  |  |  |   getOldestDeletedChatFolder: () => ChatFolder | null; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-07-22 11:16:33 -07:00
										 |  |  |   getMessagesNeedingUpgrade: ( | 
					
						
							|  |  |  |     limit: number, | 
					
						
							|  |  |  |     options: { maxVersion: number } | 
					
						
							|  |  |  |   ) => Array<MessageType>; | 
					
						
							|  |  |  |   getMessageServerGuidsForSpam: (conversationId: string) => Array<string>; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   getJobsInQueue(queueType: string): Array<StoredJob>; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   wasGroupCallRingPreviouslyCanceled(ringId: bigint): boolean; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   getMaxMessageCounter(): number | undefined; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   getStatisticsForLogging(): Record<string, string>; | 
					
						
							| 
									
										
										
										
											2025-07-18 14:21:15 -04:00
										 |  |  |   getBackupAttachmentDownloadProgress(): BackupAttachmentDownloadProgress; | 
					
						
							| 
									
										
										
										
											2025-05-22 21:09:54 -04:00
										 |  |  |   getAttachmentReferencesForMessages: ( | 
					
						
							|  |  |  |     messageIds: Array<string> | 
					
						
							|  |  |  |   ) => Array<MessageAttachmentDBType>; | 
					
						
							| 
									
										
										
										
											2025-06-02 17:20:06 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  |   getMessageCountBySchemaVersion: () => MessageCountBySchemaVersionType; | 
					
						
							|  |  |  |   getMessageSampleForSchemaVersion: ( | 
					
						
							|  |  |  |     version: number | 
					
						
							|  |  |  |   ) => Array<MessageAttributesType>; | 
					
						
							| 
									
										
										
										
											2025-08-20 13:00:14 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  |   __dangerouslyRunAbitraryReadOnlySqlQuery: ( | 
					
						
							|  |  |  |     readOnlySqlQuery: string | 
					
						
							|  |  |  |   ) => ReadonlyArray<RowType<object>>; | 
					
						
							| 
									
										
										
										
											2024-07-22 11:16:33 -07:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | type WritableInterface = { | 
					
						
							|  |  |  |   close: () => void; | 
					
						
							| 
									
										
										
										
											2024-03-15 07:20:33 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-07-22 11:16:33 -07:00
										 |  |  |   removeIndexedDBFiles: () => void; | 
					
						
							| 
									
										
										
										
											2020-04-01 11:59:11 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-07-22 11:16:33 -07:00
										 |  |  |   removeIdentityKeyById: (id: IdentityKeyIdType) => number; | 
					
						
							|  |  |  |   removeAllIdentityKeys: () => number; | 
					
						
							| 
									
										
										
										
											2023-07-14 09:53:20 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-07-22 11:16:33 -07:00
										 |  |  |   removeKyberPreKeyById: (id: PreKeyIdType | Array<PreKeyIdType>) => number; | 
					
						
							|  |  |  |   removeKyberPreKeysByServiceId: (serviceId: ServiceIdString) => void; | 
					
						
							|  |  |  |   removeAllKyberPreKeys: () => number; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   removePreKeyById: (id: PreKeyIdType | Array<PreKeyIdType>) => number; | 
					
						
							|  |  |  |   removePreKeysByServiceId: (serviceId: ServiceIdString) => void; | 
					
						
							|  |  |  |   removeAllPreKeys: () => number; | 
					
						
							| 
									
										
										
										
											2020-04-01 11:59:11 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-07-14 09:53:20 -07:00
										 |  |  |   removeSignedPreKeyById: ( | 
					
						
							|  |  |  |     id: SignedPreKeyIdType | Array<SignedPreKeyIdType> | 
					
						
							| 
									
										
										
										
											2024-07-22 11:16:33 -07:00
										 |  |  |   ) => number; | 
					
						
							|  |  |  |   removeSignedPreKeysByServiceId: (serviceId: ServiceIdString) => void; | 
					
						
							|  |  |  |   removeAllSignedPreKeys: () => number; | 
					
						
							| 
									
										
										
										
											2020-04-01 11:59:11 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-07-22 11:16:33 -07:00
										 |  |  |   removeAllItems: () => number; | 
					
						
							|  |  |  |   removeItemById: (id: ItemKeyType | Array<ItemKeyType>) => number; | 
					
						
							| 
									
										
										
										
											2020-04-01 11:59:11 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-07-22 11:16:33 -07:00
										 |  |  |   createOrUpdateSenderKey: (key: SenderKeyType) => void; | 
					
						
							|  |  |  |   removeAllSenderKeys: () => void; | 
					
						
							|  |  |  |   removeSenderKeyById: (id: SenderKeyIdType) => void; | 
					
						
							| 
									
										
										
										
											2021-05-13 18:18:43 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-07-22 11:16:33 -07:00
										 |  |  |   getSentProtoByRecipient: (options: { | 
					
						
							|  |  |  |     now: number; | 
					
						
							|  |  |  |     recipientServiceId: ServiceIdString; | 
					
						
							|  |  |  |     timestamp: number; | 
					
						
							|  |  |  |   }) => SentProtoWithMessageIdsType | undefined; | 
					
						
							| 
									
										
										
										
											2021-07-15 16:48:09 -07:00
										 |  |  |   insertSentProto: ( | 
					
						
							|  |  |  |     proto: SentProtoType, | 
					
						
							|  |  |  |     options: { | 
					
						
							|  |  |  |       recipients: SentRecipientsType; | 
					
						
							|  |  |  |       messageIds: SentMessagesType; | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2024-07-22 11:16:33 -07:00
										 |  |  |   ) => number; | 
					
						
							|  |  |  |   deleteSentProtosOlderThan: (timestamp: number) => void; | 
					
						
							|  |  |  |   deleteSentProtoByMessageId: (messageId: string) => void; | 
					
						
							| 
									
										
										
										
											2021-07-15 16:48:09 -07:00
										 |  |  |   insertProtoRecipients: (options: { | 
					
						
							|  |  |  |     id: number; | 
					
						
							| 
									
										
										
										
											2023-08-10 18:43:33 +02:00
										 |  |  |     recipientServiceId: ServiceIdString; | 
					
						
							| 
									
										
										
										
											2021-07-15 16:48:09 -07:00
										 |  |  |     deviceIds: Array<number>; | 
					
						
							| 
									
										
										
										
											2024-07-22 11:16:33 -07:00
										 |  |  |   }) => void; | 
					
						
							| 
									
										
										
										
											2021-08-31 14:35:01 -07:00
										 |  |  |   deleteSentProtoRecipient: ( | 
					
						
							|  |  |  |     options: | 
					
						
							|  |  |  |       | DeleteSentProtoRecipientOptionsType | 
					
						
							|  |  |  |       | ReadonlyArray<DeleteSentProtoRecipientOptionsType> | 
					
						
							| 
									
										
										
										
											2024-07-22 11:16:33 -07:00
										 |  |  |   ) => DeleteSentProtoRecipientResultType; | 
					
						
							|  |  |  |   removeAllSentProtos: () => void; | 
					
						
							| 
									
										
										
										
											2021-07-15 16:48:09 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-07-22 11:16:33 -07:00
										 |  |  |   createOrUpdateSession: (data: SessionType) => void; | 
					
						
							|  |  |  |   createOrUpdateSessions: (array: Array<SessionType>) => void; | 
					
						
							| 
									
										
										
										
											2022-01-07 18:12:13 -08:00
										 |  |  |   commitDecryptResult(options: { | 
					
						
							| 
									
										
										
										
											2025-08-05 05:19:24 +10:00
										 |  |  |     kyberPreKeysToRemove: Array<PreKeyIdType>; | 
					
						
							|  |  |  |     preKeysToRemove: Array<PreKeyIdType>; | 
					
						
							| 
									
										
										
										
											2022-01-07 18:12:13 -08:00
										 |  |  |     senderKeys: Array<SenderKeyType>; | 
					
						
							| 
									
										
										
										
											2021-05-17 11:03:42 -07:00
										 |  |  |     sessions: Array<SessionType>; | 
					
						
							|  |  |  |     unprocessed: Array<UnprocessedType>; | 
					
						
							| 
									
										
										
										
											2025-09-30 15:53:46 -07:00
										 |  |  |     kyberTriples: Array<KyberPreKeyTripleType>; | 
					
						
							| 
									
										
										
										
											2024-07-22 11:16:33 -07:00
										 |  |  |   }): void; | 
					
						
							|  |  |  |   removeSessionById: (id: SessionIdType) => number; | 
					
						
							|  |  |  |   removeSessionsByConversation: (conversationId: string) => void; | 
					
						
							|  |  |  |   removeSessionsByServiceId: (serviceId: ServiceIdString) => void; | 
					
						
							|  |  |  |   removeAllSessions: () => number; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   saveConversation: (data: ConversationType) => void; | 
					
						
							|  |  |  |   saveConversations: (array: Array<ConversationType>) => void; | 
					
						
							| 
									
										
										
										
											2021-12-10 14:51:54 -08:00
										 |  |  |   // updateConversation is a normal data method on Server, a sync batch-add on Client
 | 
					
						
							| 
									
										
										
										
											2024-07-22 11:16:33 -07:00
										 |  |  |   updateConversations: (array: Array<ConversationType>) => void; | 
					
						
							| 
									
										
										
										
											2021-12-10 14:51:54 -08:00
										 |  |  |   // removeConversation handles either one id or an array on Server, and one id on Client
 | 
					
						
							| 
									
										
										
										
											2024-07-22 11:16:33 -07:00
										 |  |  |   _removeAllConversations: () => void; | 
					
						
							| 
									
										
										
										
											2021-12-10 14:51:54 -08:00
										 |  |  |   updateAllConversationColors: ( | 
					
						
							|  |  |  |     conversationColor?: ConversationColorType, | 
					
						
							|  |  |  |     customColorData?: { | 
					
						
							|  |  |  |       id: string; | 
					
						
							|  |  |  |       value: CustomColorType; | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2024-07-22 11:16:33 -07:00
										 |  |  |   ) => void; | 
					
						
							|  |  |  |   removeAllProfileKeyCredentials: () => void; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   replaceAllEndorsementsForGroup: (data: GroupSendEndorsementsData) => void; | 
					
						
							|  |  |  |   deleteAllEndorsementsForGroup: (groupId: string) => void; | 
					
						
							| 
									
										
										
										
											2021-12-10 14:51:54 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-12-08 11:52:46 -08:00
										 |  |  |   getUnreadByConversationAndMarkRead: (options: { | 
					
						
							|  |  |  |     conversationId: string; | 
					
						
							| 
									
										
										
										
											2022-09-29 20:57:11 -04:00
										 |  |  |     includeStoryReplies: boolean; | 
					
						
							| 
									
										
										
										
											2025-07-16 13:47:07 -04:00
										 |  |  |     readMessageReceivedAt: number; | 
					
						
							| 
									
										
										
										
											2022-09-22 16:49:06 -07:00
										 |  |  |     now?: number; | 
					
						
							| 
									
										
										
										
											2021-12-08 11:52:46 -08:00
										 |  |  |     readAt?: number; | 
					
						
							| 
									
										
										
										
											2023-03-03 19:03:15 -08:00
										 |  |  |     storyId?: string; | 
					
						
							| 
									
										
										
										
											2024-07-22 11:16:33 -07:00
										 |  |  |   }) => GetUnreadByConversationAndMarkReadResultType; | 
					
						
							| 
									
										
										
										
											2023-03-27 19:48:57 -04:00
										 |  |  |   getUnreadEditedMessagesAndMarkRead: (options: { | 
					
						
							| 
									
										
										
										
											2023-05-16 10:37:12 -07:00
										 |  |  |     conversationId: string; | 
					
						
							| 
									
										
										
										
											2025-07-16 13:47:07 -04:00
										 |  |  |     readMessageReceivedAt: number; | 
					
						
							| 
									
										
										
										
											2024-07-22 11:16:33 -07:00
										 |  |  |   }) => GetUnreadByConversationAndMarkReadResultType; | 
					
						
							| 
									
										
										
										
											2021-12-08 11:52:46 -08:00
										 |  |  |   getUnreadReactionsAndMarkRead: (options: { | 
					
						
							|  |  |  |     conversationId: string; | 
					
						
							| 
									
										
										
										
											2025-07-16 13:47:07 -04:00
										 |  |  |     readMessageReceivedAt: number; | 
					
						
							| 
									
										
										
										
											2023-03-03 19:03:15 -08:00
										 |  |  |     storyId?: string; | 
					
						
							| 
									
										
										
										
											2024-07-22 11:16:33 -07:00
										 |  |  |   }) => Array<ReactionResultType>; | 
					
						
							| 
									
										
										
										
											2021-07-15 16:48:09 -07:00
										 |  |  |   markReactionAsRead: ( | 
					
						
							| 
									
										
										
										
											2023-08-10 18:43:33 +02:00
										 |  |  |     targetAuthorServiceId: ServiceIdString, | 
					
						
							| 
									
										
										
										
											2021-07-15 16:48:09 -07:00
										 |  |  |     targetTimestamp: number | 
					
						
							| 
									
										
										
										
											2024-07-22 11:16:33 -07:00
										 |  |  |   ) => ReactionType | undefined; | 
					
						
							| 
									
										
										
										
											2021-07-15 16:48:09 -07:00
										 |  |  |   removeReactionFromConversation: (reaction: { | 
					
						
							|  |  |  |     emoji: string; | 
					
						
							|  |  |  |     fromId: string; | 
					
						
							| 
									
										
										
										
											2023-08-10 18:43:33 +02:00
										 |  |  |     targetAuthorServiceId: ServiceIdString; | 
					
						
							| 
									
										
										
										
											2021-07-15 16:48:09 -07:00
										 |  |  |     targetTimestamp: number; | 
					
						
							| 
									
										
										
										
											2024-07-22 11:16:33 -07:00
										 |  |  |   }) => void; | 
					
						
							| 
									
										
										
										
											2023-12-19 15:57:15 +01:00
										 |  |  |   addReaction: ( | 
					
						
							|  |  |  |     reactionObj: ReactionType, | 
					
						
							|  |  |  |     options: { | 
					
						
							|  |  |  |       readStatus: ReactionReadStatus; | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2024-07-22 11:16:33 -07:00
										 |  |  |   ) => void; | 
					
						
							|  |  |  |   _removeAllReactions: () => void; | 
					
						
							|  |  |  |   _removeAllMessages: () => void; | 
					
						
							| 
									
										
										
										
											2025-05-22 21:09:54 -04:00
										 |  |  |   _removeMessage: (id: string) => void; | 
					
						
							| 
									
										
										
										
											2024-08-22 11:12:00 -07:00
										 |  |  |   incrementMessagesMigrationAttempts: ( | 
					
						
							|  |  |  |     messageIds: ReadonlyArray<string> | 
					
						
							|  |  |  |   ) => void; | 
					
						
							| 
									
										
										
										
											2024-07-22 11:16:33 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  |   clearCallHistory: (target: CallLogEventTarget) => ReadonlyArray<string>; | 
					
						
							| 
									
										
										
										
											2024-08-14 04:39:04 +10:00
										 |  |  |   _removeAllCallHistory: () => void; | 
					
						
							| 
									
										
										
										
											2024-07-22 11:16:33 -07:00
										 |  |  |   markCallHistoryDeleted: (callId: string) => void; | 
					
						
							|  |  |  |   cleanupCallHistoryMessages: () => void; | 
					
						
							|  |  |  |   markCallHistoryRead(callId: string): void; | 
					
						
							| 
									
										
										
										
											2024-08-27 06:20:23 -07:00
										 |  |  |   markAllCallHistoryRead(target: CallLogEventTarget): number; | 
					
						
							|  |  |  |   markAllCallHistoryReadInConversation(target: CallLogEventTarget): number; | 
					
						
							| 
									
										
										
										
											2024-07-22 11:16:33 -07:00
										 |  |  |   saveCallHistory(callHistory: CallHistoryDetails): void; | 
					
						
							|  |  |  |   markCallHistoryMissed(callIds: ReadonlyArray<string>): void; | 
					
						
							|  |  |  |   getRecentStaleRingsAndMarkOlderMissed(): ReadonlyArray<MaybeStaleCallHistory>; | 
					
						
							|  |  |  |   insertCallLink(callLink: CallLinkType): void; | 
					
						
							| 
									
										
										
										
											2025-06-30 16:58:26 -07:00
										 |  |  |   insertOrUpdateCallLinkFromSync( | 
					
						
							|  |  |  |     callLink: CallLinkType | 
					
						
							|  |  |  |   ): InsertOrUpdateCallLinkFromSyncResult; | 
					
						
							| 
									
										
										
										
											2024-09-04 11:06:06 -07:00
										 |  |  |   updateCallLink(callLink: CallLinkType): void; | 
					
						
							| 
									
										
										
										
											2024-04-01 12:19:35 -07:00
										 |  |  |   updateCallLinkState( | 
					
						
							|  |  |  |     roomId: string, | 
					
						
							| 
									
										
										
										
											2024-04-25 10:09:05 -07:00
										 |  |  |     callLinkState: CallLinkStateType | 
					
						
							| 
									
										
										
										
											2024-07-22 11:16:33 -07:00
										 |  |  |   ): CallLinkType; | 
					
						
							| 
									
										
										
										
											2025-08-07 15:12:56 -04:00
										 |  |  |   updateCallLinkStateAndEpoch( | 
					
						
							|  |  |  |     roomId: string, | 
					
						
							|  |  |  |     callLinkState: CallLinkStateType, | 
					
						
							|  |  |  |     epoch: string | null | 
					
						
							|  |  |  |   ): CallLinkType; | 
					
						
							| 
									
										
										
										
											2024-10-09 09:35:24 -07:00
										 |  |  |   beginDeleteAllCallLinks(): boolean; | 
					
						
							|  |  |  |   beginDeleteCallLink(roomId: string): boolean; | 
					
						
							|  |  |  |   deleteCallHistoryByRoomId(roomid: string): void; | 
					
						
							|  |  |  |   deleteCallLinkAndHistory(roomId: string): void; | 
					
						
							| 
									
										
										
										
											2024-08-06 12:29:13 -07:00
										 |  |  |   finalizeDeleteCallLink(roomId: string): void; | 
					
						
							| 
									
										
										
										
											2024-08-14 04:39:04 +10:00
										 |  |  |   _removeAllCallLinks(): void; | 
					
						
							| 
									
										
										
										
											2024-10-22 11:20:35 -07:00
										 |  |  |   insertDefunctCallLink(defunctCallLink: DefunctCallLinkType): void; | 
					
						
							|  |  |  |   updateDefunctCallLink(defunctCallLink: DefunctCallLinkType): void; | 
					
						
							| 
									
										
										
										
											2024-08-06 12:29:13 -07:00
										 |  |  |   deleteCallLinkFromSync(roomId: string): void; | 
					
						
							| 
									
										
										
										
											2024-07-22 11:16:33 -07:00
										 |  |  |   migrateConversationMessages: (obsoleteId: string, currentId: string) => void; | 
					
						
							| 
									
										
										
										
											2023-03-27 19:48:57 -04:00
										 |  |  |   saveEditedMessage: ( | 
					
						
							| 
									
										
										
										
											2024-07-24 13:14:11 -07:00
										 |  |  |     mainMessage: ReadonlyDeep<MessageType>, | 
					
						
							| 
									
										
										
										
											2023-08-10 18:43:33 +02:00
										 |  |  |     ourAci: AciString, | 
					
						
							| 
									
										
										
										
											2024-07-24 13:14:11 -07:00
										 |  |  |     opts: ReadonlyDeep<EditedMessageType> | 
					
						
							| 
									
										
										
										
											2024-07-22 11:16:33 -07:00
										 |  |  |   ) => void; | 
					
						
							| 
									
										
										
										
											2024-06-03 10:02:25 -07:00
										 |  |  |   saveEditedMessages: ( | 
					
						
							| 
									
										
										
										
											2024-07-24 13:14:11 -07:00
										 |  |  |     mainMessage: ReadonlyDeep<MessageType>, | 
					
						
							| 
									
										
										
										
											2024-06-03 10:02:25 -07:00
										 |  |  |     ourAci: AciString, | 
					
						
							| 
									
										
										
										
											2024-07-24 13:14:11 -07:00
										 |  |  |     history: ReadonlyArray<ReadonlyDeep<EditedMessageType>> | 
					
						
							| 
									
										
										
										
											2024-07-22 11:16:33 -07:00
										 |  |  |   ) => void; | 
					
						
							| 
									
										
										
										
											2024-05-29 01:56:00 +10:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-07-22 11:16:33 -07:00
										 |  |  |   removeSyncTaskById: (id: string) => void; | 
					
						
							| 
									
										
										
										
											2025-03-19 08:44:33 +10:00
										 |  |  |   removeSyncTasks: (ids: ReadonlyArray<string>) => void; | 
					
						
							| 
									
										
										
										
											2024-07-22 11:16:33 -07:00
										 |  |  |   saveSyncTasks: (tasks: Array<SyncTaskType>) => void; | 
					
						
							| 
									
										
										
										
											2025-02-25 09:18:42 -06:00
										 |  |  | 
 | 
					
						
							|  |  |  |   incrementAllSyncTaskAttempts: () => void; | 
					
						
							|  |  |  |   dequeueOldestSyncTasks: (options: { | 
					
						
							|  |  |  |     previousRowId: number | null; | 
					
						
							|  |  |  |     incrementAttempts?: boolean; | 
					
						
							|  |  |  |     syncTaskTypes?: Array<SyncTaskType['type']>; | 
					
						
							|  |  |  |   }) => { | 
					
						
							| 
									
										
										
										
											2024-12-04 14:03:29 -08:00
										 |  |  |     tasks: Array<SyncTaskType>; | 
					
						
							|  |  |  |     lastRowId: number | null; | 
					
						
							|  |  |  |   }; | 
					
						
							| 
									
										
										
										
											2024-05-29 01:56:00 +10:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-07-22 11:16:33 -07:00
										 |  |  |   getAllUnprocessedIds: () => Array<string>; | 
					
						
							| 
									
										
										
										
											2023-02-02 12:39:07 -07:00
										 |  |  |   getUnprocessedByIdsAndIncrementAttempts: ( | 
					
						
							|  |  |  |     ids: ReadonlyArray<string> | 
					
						
							| 
									
										
										
										
											2024-07-22 11:16:33 -07:00
										 |  |  |   ) => Array<UnprocessedType>; | 
					
						
							|  |  |  |   removeUnprocessed: (id: string | Array<string>) => void; | 
					
						
							| 
									
										
										
										
											2023-02-02 12:39:07 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  |   /** only for testing */ | 
					
						
							| 
									
										
										
										
											2024-07-22 11:16:33 -07:00
										 |  |  |   removeAllUnprocessed: () => void; | 
					
						
							| 
									
										
										
										
											2020-04-01 11:59:11 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-04-15 20:11:48 -04:00
										 |  |  |   getNextAttachmentDownloadJobs: (options: { | 
					
						
							|  |  |  |     limit: number; | 
					
						
							|  |  |  |     prioritizeMessageIds?: Array<string>; | 
					
						
							| 
									
										
										
										
											2024-09-16 15:38:12 -04:00
										 |  |  |     sources?: Array<AttachmentDownloadSource>; | 
					
						
							| 
									
										
										
										
											2024-04-15 20:11:48 -04:00
										 |  |  |     timestamp?: number; | 
					
						
							| 
									
										
										
										
											2024-07-22 11:16:33 -07:00
										 |  |  |   }) => Array<AttachmentDownloadJobType>; | 
					
						
							|  |  |  |   saveAttachmentDownloadJob: (job: AttachmentDownloadJobType) => void; | 
					
						
							| 
									
										
										
										
											2024-10-28 18:25:15 -04:00
										 |  |  |   saveAttachmentDownloadJobs: (jobs: Array<AttachmentDownloadJobType>) => void; | 
					
						
							| 
									
										
										
										
											2024-07-22 11:16:33 -07:00
										 |  |  |   resetAttachmentDownloadActive: () => void; | 
					
						
							| 
									
										
										
										
											2025-08-18 13:53:04 -04:00
										 |  |  |   resetBackupAttachmentDownloadJobsRetryAfter: () => void; | 
					
						
							| 
									
										
										
										
											2024-07-22 11:16:33 -07:00
										 |  |  |   removeAttachmentDownloadJob: (job: AttachmentDownloadJobType) => void; | 
					
						
							| 
									
										
										
										
											2024-12-10 08:54:18 +10:00
										 |  |  |   removeAttachmentDownloadJobsForMessage: (messageId: string) => void; | 
					
						
							| 
									
										
										
										
											2024-09-03 18:00:51 -04:00
										 |  |  |   removeAllBackupAttachmentDownloadJobs: () => void; | 
					
						
							| 
									
										
										
										
											2025-07-18 14:21:15 -04:00
										 |  |  |   resetBackupAttachmentDownloadStats: () => void; | 
					
						
							| 
									
										
										
										
											2020-04-01 11:59:11 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-05-29 19:46:43 -04:00
										 |  |  |   getNextAttachmentBackupJobs: (options: { | 
					
						
							|  |  |  |     limit: number; | 
					
						
							|  |  |  |     timestamp?: number; | 
					
						
							| 
									
										
										
										
											2024-07-22 11:16:33 -07:00
										 |  |  |   }) => Array<AttachmentBackupJobType>; | 
					
						
							|  |  |  |   saveAttachmentBackupJob: (job: AttachmentBackupJobType) => void; | 
					
						
							|  |  |  |   markAllAttachmentBackupJobsInactive: () => void; | 
					
						
							|  |  |  |   removeAttachmentBackupJob: (job: AttachmentBackupJobType) => void; | 
					
						
							|  |  |  |   clearAllAttachmentBackupJobs: () => void; | 
					
						
							| 
									
										
										
										
											2024-05-29 19:46:43 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-07-22 11:16:33 -07:00
										 |  |  |   clearAllBackupCdnObjectMetadata: () => void; | 
					
						
							| 
									
										
										
										
											2024-05-29 19:46:43 -04:00
										 |  |  |   saveBackupCdnObjectMetadata: ( | 
					
						
							|  |  |  |     mediaObjects: Array<BackupCdnMediaObjectType> | 
					
						
							| 
									
										
										
										
											2024-07-22 11:16:33 -07:00
										 |  |  |   ) => void; | 
					
						
							| 
									
										
										
										
											2024-05-29 19:46:43 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-07-22 11:16:33 -07:00
										 |  |  |   createOrUpdateStickerPack: (pack: StickerPackType) => void; | 
					
						
							| 
									
										
										
										
											2024-09-16 17:40:52 -07:00
										 |  |  |   createOrUpdateStickerPacks: (packs: ReadonlyArray<StickerPackType>) => void; | 
					
						
							| 
									
										
										
										
											2025-02-06 11:00:55 -08:00
										 |  |  |   // Returns previous sticker pack status
 | 
					
						
							| 
									
										
										
										
											2020-04-01 11:59:11 -07:00
										 |  |  |   updateStickerPackStatus: ( | 
					
						
							|  |  |  |     id: string, | 
					
						
							|  |  |  |     status: StickerPackStatusType, | 
					
						
							|  |  |  |     options?: { timestamp: number } | 
					
						
							| 
									
										
										
										
											2025-02-06 11:00:55 -08:00
										 |  |  |   ) => StickerPackStatusType | null; | 
					
						
							| 
									
										
										
										
											2024-07-22 11:16:33 -07:00
										 |  |  |   updateStickerPackInfo: (info: StickerPackInfoType) => void; | 
					
						
							|  |  |  |   createOrUpdateSticker: (sticker: StickerType) => void; | 
					
						
							|  |  |  |   createOrUpdateStickers: (sticker: ReadonlyArray<StickerType>) => void; | 
					
						
							| 
									
										
										
										
											2020-04-01 11:59:11 -07:00
										 |  |  |   updateStickerLastUsed: ( | 
					
						
							|  |  |  |     packId: string, | 
					
						
							|  |  |  |     stickerId: number, | 
					
						
							|  |  |  |     lastUsed: number | 
					
						
							| 
									
										
										
										
											2024-07-22 11:16:33 -07:00
										 |  |  |   ) => void; | 
					
						
							| 
									
										
										
										
											2025-01-28 13:57:19 -08:00
										 |  |  |   addStickerPackReference: (ref: StickerPackRefType) => void; | 
					
						
							| 
									
										
										
										
											2020-04-01 11:59:11 -07:00
										 |  |  |   deleteStickerPackReference: ( | 
					
						
							| 
									
										
										
										
											2025-01-28 13:57:19 -08:00
										 |  |  |     ref: Pick<StickerPackRefType, 'messageId' | 'packId'> | 
					
						
							| 
									
										
										
										
											2024-07-22 11:16:33 -07:00
										 |  |  |   ) => ReadonlyArray<string> | undefined; | 
					
						
							|  |  |  |   deleteStickerPack: (packId: string) => Array<string>; | 
					
						
							| 
									
										
										
										
											2025-01-28 13:57:19 -08:00
										 |  |  |   getUnresolvedStickerPackReferences: ( | 
					
						
							|  |  |  |     packId: string | 
					
						
							|  |  |  |   ) => Array<StickerPackRefType>; | 
					
						
							| 
									
										
										
										
											2024-07-22 11:16:33 -07:00
										 |  |  |   addUninstalledStickerPack: (pack: UninstalledStickerPackType) => void; | 
					
						
							| 
									
										
										
										
											2024-09-16 17:40:52 -07:00
										 |  |  |   addUninstalledStickerPacks: ( | 
					
						
							|  |  |  |     pack: ReadonlyArray<UninstalledStickerPackType> | 
					
						
							|  |  |  |   ) => void; | 
					
						
							| 
									
										
										
										
											2025-02-06 11:00:55 -08:00
										 |  |  |   // Returns `true` if sticker pack was previously uninstalled
 | 
					
						
							|  |  |  |   installStickerPack: (packId: string, timestamp: number) => boolean; | 
					
						
							|  |  |  |   // Returns `true` if sticker pack was not previously uninstalled
 | 
					
						
							|  |  |  |   uninstallStickerPack: (packId: string, timestamp: number) => boolean; | 
					
						
							| 
									
										
										
										
											2024-07-22 11:16:33 -07:00
										 |  |  |   clearAllErrorStickerPackAttempts: () => void; | 
					
						
							| 
									
										
										
										
											2020-04-01 11:59:11 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-07-22 11:16:33 -07:00
										 |  |  |   updateEmojiUsage: (shortName: string, timeUsed?: number) => void; | 
					
						
							| 
									
										
										
										
											2020-04-01 11:59:11 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-04-10 12:32:36 -07:00
										 |  |  |   addRecentGif: (gif: GifType, lastUsedAt: number, maxRecents: number) => void; | 
					
						
							|  |  |  |   removeRecentGif: (gif: Pick<GifType, 'id'>) => void; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-07-22 11:16:33 -07:00
										 |  |  |   updateOrCreateBadges(badges: ReadonlyArray<BadgeType>): void; | 
					
						
							|  |  |  |   badgeImageFileDownloaded(url: string, localPath: string): void; | 
					
						
							| 
									
										
										
										
											2021-11-02 18:01:13 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-07-22 11:16:33 -07:00
										 |  |  |   _deleteAllStoryDistributions(): void; | 
					
						
							| 
									
										
										
										
											2021-12-08 11:52:46 -08:00
										 |  |  |   createNewStoryDistribution( | 
					
						
							| 
									
										
										
										
											2021-12-09 18:15:59 -08:00
										 |  |  |     distribution: StoryDistributionWithMembersType | 
					
						
							| 
									
										
										
										
											2024-07-22 11:16:33 -07:00
										 |  |  |   ): void; | 
					
						
							|  |  |  |   modifyStoryDistribution(distribution: StoryDistributionType): void; | 
					
						
							| 
									
										
										
										
											2021-12-08 11:52:46 -08:00
										 |  |  |   modifyStoryDistributionMembers( | 
					
						
							| 
									
										
										
										
											2022-06-30 20:52:03 -04:00
										 |  |  |     listId: string, | 
					
						
							|  |  |  |     options: { | 
					
						
							| 
									
										
										
										
											2023-08-10 18:43:33 +02:00
										 |  |  |       toAdd: Array<ServiceIdString>; | 
					
						
							|  |  |  |       toRemove: Array<ServiceIdString>; | 
					
						
							| 
									
										
										
										
											2022-06-30 20:52:03 -04:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2024-07-22 11:16:33 -07:00
										 |  |  |   ): void; | 
					
						
							| 
									
										
										
										
											2022-06-30 20:52:03 -04:00
										 |  |  |   modifyStoryDistributionWithMembers( | 
					
						
							|  |  |  |     distribution: StoryDistributionType, | 
					
						
							| 
									
										
										
										
											2021-12-08 11:52:46 -08:00
										 |  |  |     options: { | 
					
						
							| 
									
										
										
										
											2023-08-10 18:43:33 +02:00
										 |  |  |       toAdd: Array<ServiceIdString>; | 
					
						
							|  |  |  |       toRemove: Array<ServiceIdString>; | 
					
						
							| 
									
										
										
										
											2021-12-08 11:52:46 -08:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2024-07-22 11:16:33 -07:00
										 |  |  |   ): void; | 
					
						
							|  |  |  |   deleteStoryDistribution(id: StoryDistributionIdString): void; | 
					
						
							| 
									
										
										
										
											2021-04-29 18:02:27 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-07-22 11:16:33 -07:00
										 |  |  |   _deleteAllStoryReads(): void; | 
					
						
							|  |  |  |   addNewStoryRead(read: StoryReadType): void; | 
					
						
							| 
									
										
										
										
											2021-05-28 12:15:17 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-05-06 00:39:04 +10:00
										 |  |  |   _deleteAllNotificationProfiles(): void; | 
					
						
							|  |  |  |   deleteNotificationProfileById(id: string): void; | 
					
						
							|  |  |  |   markNotificationProfileDeleted(id: string): number | undefined; | 
					
						
							|  |  |  |   createNotificationProfile(profile: NotificationProfileType): void; | 
					
						
							|  |  |  |   updateNotificationProfile(profile: NotificationProfileType): void; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-06-17 05:33:00 +10:00
										 |  |  |   _deleteAllDonationReceipts(): void; | 
					
						
							|  |  |  |   deleteDonationReceiptById(id: string): void; | 
					
						
							|  |  |  |   createDonationReceipt(profile: DonationReceipt): void; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-08-25 18:02:05 -07:00
										 |  |  |   createChatFolder: (chatFolder: ChatFolder) => void; | 
					
						
							| 
									
										
										
										
											2025-09-29 15:34:24 -07:00
										 |  |  |   createAllChatsChatFolder: () => ChatFolder; | 
					
						
							| 
									
										
										
										
											2025-08-25 18:02:05 -07:00
										 |  |  |   updateChatFolder: (chatFolder: ChatFolder) => void; | 
					
						
							|  |  |  |   updateChatFolderPositions: (chatFolders: ReadonlyArray<ChatFolder>) => void; | 
					
						
							|  |  |  |   updateChatFolderDeletedAtTimestampMsFromSync: ( | 
					
						
							|  |  |  |     chatFolderId: ChatFolderId, | 
					
						
							|  |  |  |     deletedAtTimestampMs: number | 
					
						
							|  |  |  |   ) => void; | 
					
						
							|  |  |  |   markChatFolderDeleted: ( | 
					
						
							|  |  |  |     chatFolderId: ChatFolderId, | 
					
						
							|  |  |  |     deletedAtTimestampMs: number, | 
					
						
							|  |  |  |     storageNeedsSync: boolean | 
					
						
							|  |  |  |   ) => void; | 
					
						
							|  |  |  |   deleteExpiredChatFolders: ( | 
					
						
							|  |  |  |     messageQueueTime: number | 
					
						
							|  |  |  |   ) => ReadonlyArray<ChatFolderId>; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-07-22 11:16:33 -07:00
										 |  |  |   removeAll: () => void; | 
					
						
							|  |  |  |   removeAllConfiguration: () => void; | 
					
						
							|  |  |  |   eraseStorageServiceState: () => void; | 
					
						
							| 
									
										
										
										
											2021-08-20 11:06:15 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-07-22 11:16:33 -07:00
										 |  |  |   insertJob(job: Readonly<StoredJob>): void; | 
					
						
							|  |  |  |   deleteJob(id: string): void; | 
					
						
							| 
									
										
										
										
											2021-12-10 14:51:54 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-11-27 13:34:02 -05:00
										 |  |  |   disableMessageInsertTriggers(): void; | 
					
						
							|  |  |  |   enableMessageInsertTriggersAndBackfill(): void; | 
					
						
							|  |  |  |   ensureMessageInsertTriggersAreEnabled(): void; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-02-12 10:37:51 -08:00
										 |  |  |   disableFSync(): void; | 
					
						
							|  |  |  |   enableFSyncAndCheckpoint(): void; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-07-22 11:16:33 -07:00
										 |  |  |   processGroupCallRingCancellation(ringId: bigint): void; | 
					
						
							|  |  |  |   cleanExpiredGroupCallRingCancellations(): void; | 
					
						
							| 
									
										
										
										
											2025-08-26 23:20:14 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  |   _testOnlyRemoveMessageAttachments(timestamp: number): void; | 
					
						
							| 
									
										
										
										
											2024-07-22 11:16:33 -07:00
										 |  |  | }; | 
					
						
							| 
									
										
										
										
											2023-10-11 01:55:32 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-07-22 11:16:33 -07:00
										 |  |  | // Adds a database argument
 | 
					
						
							|  |  |  | type AddReadonlyDB<I> = { | 
					
						
							|  |  |  |   [Key in keyof I]: I[Key] extends (...args: infer Args) => infer R | 
					
						
							|  |  |  |     ? (db: ReadableDB, ...args: Args) => R | 
					
						
							|  |  |  |     : never; | 
					
						
							| 
									
										
										
										
											2021-01-14 12:07:05 -06:00
										 |  |  | }; | 
					
						
							| 
									
										
										
										
											2020-04-01 11:59:11 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-07-22 11:16:33 -07:00
										 |  |  | export type ServerReadableDirectInterface = ReadableInterface & { | 
					
						
							| 
									
										
										
										
											2021-12-10 14:51:54 -08:00
										 |  |  |   // Differing signature on client/server
 | 
					
						
							| 
									
										
										
										
											2023-06-26 14:25:48 -04:00
										 |  |  |   searchMessages: ({ | 
					
						
							|  |  |  |     query, | 
					
						
							|  |  |  |     conversationId, | 
					
						
							|  |  |  |     options, | 
					
						
							| 
									
										
										
										
											2023-08-16 22:54:39 +02:00
										 |  |  |     contactServiceIdsMatchingQuery, | 
					
						
							| 
									
										
										
										
											2023-06-26 14:25:48 -04:00
										 |  |  |   }: { | 
					
						
							|  |  |  |     query: string; | 
					
						
							|  |  |  |     conversationId?: string; | 
					
						
							|  |  |  |     options?: { limit?: number }; | 
					
						
							| 
									
										
										
										
											2023-08-16 22:54:39 +02:00
										 |  |  |     contactServiceIdsMatchingQuery?: Array<ServiceIdString>; | 
					
						
							| 
									
										
										
										
											2024-07-22 11:16:33 -07:00
										 |  |  |   }) => Array<ServerSearchResultMessageType>; | 
					
						
							| 
									
										
										
										
											2023-07-21 15:10:32 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  |   getRecentStoryReplies( | 
					
						
							|  |  |  |     storyId: string, | 
					
						
							|  |  |  |     options?: GetRecentStoryRepliesOptionsType | 
					
						
							| 
									
										
										
										
											2025-05-22 21:09:54 -04:00
										 |  |  |   ): Array<MessageType>; | 
					
						
							| 
									
										
										
										
											2020-04-01 11:59:11 -07:00
										 |  |  |   getOlderMessagesByConversation: ( | 
					
						
							| 
									
										
										
										
											2023-03-03 19:03:15 -08:00
										 |  |  |     options: AdjacentMessagesByConversationOptionsType | 
					
						
							| 
									
										
										
										
											2025-05-22 21:09:54 -04:00
										 |  |  |   ) => Array<MessageType>; | 
					
						
							| 
									
										
										
										
											2020-04-01 11:59:11 -07:00
										 |  |  |   getNewerMessagesByConversation: ( | 
					
						
							| 
									
										
										
										
											2023-03-03 19:03:15 -08:00
										 |  |  |     options: AdjacentMessagesByConversationOptionsType | 
					
						
							| 
									
										
										
										
											2025-05-22 21:09:54 -04:00
										 |  |  |   ) => Array<MessageType>; | 
					
						
							| 
									
										
										
										
											2023-03-03 19:03:15 -08:00
										 |  |  |   getConversationRangeCenteredOnMessage: ( | 
					
						
							|  |  |  |     options: AdjacentMessagesByConversationOptionsType | 
					
						
							| 
									
										
										
										
											2025-05-22 21:09:54 -04:00
										 |  |  |   ) => GetConversationRangeCenteredOnMessageResultType<MessageType>; | 
					
						
							| 
									
										
										
										
											2022-07-28 09:35:29 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  |   getIdentityKeyById: ( | 
					
						
							|  |  |  |     id: IdentityKeyIdType | 
					
						
							| 
									
										
										
										
											2024-07-22 11:16:33 -07:00
										 |  |  |   ) => StoredIdentityKeyType | undefined; | 
					
						
							|  |  |  |   getAllIdentityKeys: () => Array<StoredIdentityKeyType>; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   getKyberPreKeyById: (id: PreKeyIdType) => StoredKyberPreKeyType | undefined; | 
					
						
							|  |  |  |   getAllKyberPreKeys: () => Array<StoredKyberPreKeyType>; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   getPreKeyById: (id: PreKeyIdType) => StoredPreKeyType | undefined; | 
					
						
							|  |  |  |   getAllPreKeys: () => Array<StoredPreKeyType>; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-07-28 09:35:29 -07:00
										 |  |  |   getSignedPreKeyById: ( | 
					
						
							|  |  |  |     id: SignedPreKeyIdType | 
					
						
							| 
									
										
										
										
											2024-07-22 11:16:33 -07:00
										 |  |  |   ) => StoredSignedPreKeyType | undefined; | 
					
						
							|  |  |  |   getAllSignedPreKeys: () => Array<StoredSignedPreKeyType>; | 
					
						
							| 
									
										
										
										
											2020-04-01 11:59:11 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-07-22 11:16:33 -07:00
										 |  |  |   getItemById<K extends ItemKeyType>(id: K): StoredItemType<K> | undefined; | 
					
						
							|  |  |  |   getAllItems: () => StoredAllItemsType; | 
					
						
							| 
									
										
										
										
											2020-04-01 11:59:11 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-07-22 11:16:33 -07:00
										 |  |  |   // Server-only
 | 
					
						
							| 
									
										
										
										
											2020-04-01 11:59:11 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-11-16 16:29:15 -08:00
										 |  |  |   getKnownMessageAttachments: ( | 
					
						
							|  |  |  |     cursor?: MessageAttachmentsCursorType | 
					
						
							| 
									
										
										
										
											2024-07-22 11:16:33 -07:00
										 |  |  |   ) => GetKnownMessageAttachmentsResultType; | 
					
						
							| 
									
										
										
										
											2022-11-16 16:29:15 -08:00
										 |  |  |   finishGetKnownMessageAttachments: ( | 
					
						
							|  |  |  |     cursor: MessageAttachmentsCursorType | 
					
						
							| 
									
										
										
										
											2024-07-22 11:16:33 -07:00
										 |  |  |   ) => void; | 
					
						
							| 
									
										
										
										
											2024-08-27 17:00:41 -04:00
										 |  |  |   getKnownDownloads: () => Array<string>; | 
					
						
							| 
									
										
										
										
											2024-07-22 11:16:33 -07:00
										 |  |  |   getKnownConversationAttachments: () => Array<string>; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   getAllBadgeImageFileLocalPaths: () => Set<string>; | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | export type ServerReadableInterface = | 
					
						
							|  |  |  |   AddReadonlyDB<ServerReadableDirectInterface>; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | // Adds a database argument
 | 
					
						
							|  |  |  | type AddWritableDB<I> = { | 
					
						
							|  |  |  |   [Key in keyof I]: I[Key] extends (...args: infer Args) => infer R | 
					
						
							|  |  |  |     ? (db: WritableDB, ...args: Args) => R | 
					
						
							|  |  |  |     : never; | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | export type ServerWritableDirectInterface = WritableInterface & { | 
					
						
							|  |  |  |   // Differing signature on client/server
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   updateConversation: (data: ConversationType) => void; | 
					
						
							|  |  |  |   removeConversation: (id: Array<string> | string) => void; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-01-10 08:18:32 +10:00
										 |  |  |   saveMessage: ( | 
					
						
							|  |  |  |     data: ReadonlyDeep<MessageType>, | 
					
						
							|  |  |  |     options: { | 
					
						
							|  |  |  |       jobToInsert?: StoredJob; | 
					
						
							|  |  |  |       forceSave?: boolean; | 
					
						
							|  |  |  |       ourAci: AciString; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |   ) => string; | 
					
						
							|  |  |  |   saveMessages: ( | 
					
						
							|  |  |  |     arrayOfMessages: ReadonlyArray<ReadonlyDeep<MessageType>>, | 
					
						
							| 
									
										
										
										
											2025-05-22 21:09:54 -04:00
										 |  |  |     options: { | 
					
						
							|  |  |  |       forceSave?: boolean; | 
					
						
							|  |  |  |       ourAci: AciString; | 
					
						
							|  |  |  |       _testOnlyAvoidNormalizingAttachments?: boolean; | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2025-01-10 08:18:32 +10:00
										 |  |  |   ) => Array<string>; | 
					
						
							|  |  |  |   saveMessagesIndividually: ( | 
					
						
							|  |  |  |     arrayOfMessages: ReadonlyArray<ReadonlyDeep<MessageType>>, | 
					
						
							|  |  |  |     options: { forceSave?: boolean; ourAci: AciString } | 
					
						
							|  |  |  |   ) => { failedIndices: Array<number> }; | 
					
						
							| 
									
										
										
										
											2024-07-22 11:16:33 -07:00
										 |  |  |   removeMessage: (id: string) => void; | 
					
						
							|  |  |  |   removeMessages: (ids: ReadonlyArray<string>) => void; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   createOrUpdateIdentityKey: (data: StoredIdentityKeyType) => void; | 
					
						
							|  |  |  |   bulkAddIdentityKeys: (array: Array<StoredIdentityKeyType>) => void; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   createOrUpdateKyberPreKey: (data: StoredKyberPreKeyType) => void; | 
					
						
							|  |  |  |   bulkAddKyberPreKeys: (array: Array<StoredKyberPreKeyType>) => void; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   createOrUpdatePreKey: (data: StoredPreKeyType) => void; | 
					
						
							|  |  |  |   bulkAddPreKeys: (array: Array<StoredPreKeyType>) => void; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   createOrUpdateSignedPreKey: (data: StoredSignedPreKeyType) => void; | 
					
						
							|  |  |  |   bulkAddSignedPreKeys: (array: Array<StoredSignedPreKeyType>) => void; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   createOrUpdateItem<K extends ItemKeyType>(data: StoredItemType<K>): void; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   // Server-only
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   removeKnownStickers: (allStickers: ReadonlyArray<string>) => Array<string>; | 
					
						
							| 
									
										
										
										
											2020-04-01 11:59:11 -07:00
										 |  |  |   removeKnownDraftAttachments: ( | 
					
						
							| 
									
										
										
										
											2022-11-16 16:29:15 -08:00
										 |  |  |     allStickers: ReadonlyArray<string> | 
					
						
							| 
									
										
										
										
											2024-07-22 11:16:33 -07:00
										 |  |  |   ) => Array<string>; | 
					
						
							| 
									
										
										
										
											2023-10-11 01:19:11 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-02-20 20:05:15 -07:00
										 |  |  |   runCorruptionChecks: () => boolean; | 
					
						
							| 
									
										
										
										
											2020-04-01 11:59:11 -07:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-07-22 11:16:33 -07:00
										 |  |  | export type ServerWritableInterface = | 
					
						
							|  |  |  |   AddWritableDB<ServerWritableDirectInterface>; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | // Makes sync calls - async
 | 
					
						
							|  |  |  | export type ClientInterfaceWrap<I> = { | 
					
						
							|  |  |  |   [Key in keyof I]: I[Key] extends (...args: infer Args) => infer R | 
					
						
							|  |  |  |     ? (...args: Args) => Promise<R> | 
					
						
							|  |  |  |     : never; | 
					
						
							| 
									
										
										
										
											2023-07-21 15:10:32 -07:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-07-22 11:16:33 -07:00
										 |  |  | export type ClientOnlyReadableInterface = ClientInterfaceWrap<{ | 
					
						
							| 
									
										
										
										
											2021-12-10 14:51:54 -08:00
										 |  |  |   // Differing signature on client/server
 | 
					
						
							| 
									
										
										
										
											2023-06-26 14:25:48 -04:00
										 |  |  |   searchMessages: ({ | 
					
						
							|  |  |  |     query, | 
					
						
							|  |  |  |     conversationId, | 
					
						
							|  |  |  |     options, | 
					
						
							| 
									
										
										
										
											2023-08-16 22:54:39 +02:00
										 |  |  |     contactServiceIdsMatchingQuery, | 
					
						
							| 
									
										
										
										
											2023-06-26 14:25:48 -04:00
										 |  |  |   }: { | 
					
						
							|  |  |  |     query: string; | 
					
						
							|  |  |  |     conversationId?: string; | 
					
						
							|  |  |  |     options?: { limit?: number }; | 
					
						
							| 
									
										
										
										
											2023-08-16 22:54:39 +02:00
										 |  |  |     contactServiceIdsMatchingQuery?: Array<ServiceIdString>; | 
					
						
							| 
									
										
										
										
											2024-07-22 11:16:33 -07:00
										 |  |  |   }) => Array<ClientSearchResultMessageType>; | 
					
						
							| 
									
										
										
										
											2023-07-21 15:10:32 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  |   getRecentStoryReplies( | 
					
						
							|  |  |  |     storyId: string, | 
					
						
							|  |  |  |     options?: GetRecentStoryRepliesOptionsType | 
					
						
							| 
									
										
										
										
											2024-07-24 13:14:11 -07:00
										 |  |  |   ): Array<MessageType>; | 
					
						
							| 
									
										
										
										
											2020-04-01 11:59:11 -07:00
										 |  |  |   getOlderMessagesByConversation: ( | 
					
						
							| 
									
										
										
										
											2023-03-03 19:03:15 -08:00
										 |  |  |     options: AdjacentMessagesByConversationOptionsType | 
					
						
							| 
									
										
										
										
											2024-07-24 13:14:11 -07:00
										 |  |  |   ) => Array<MessageType>; | 
					
						
							| 
									
										
										
										
											2020-04-01 11:59:11 -07:00
										 |  |  |   getNewerMessagesByConversation: ( | 
					
						
							| 
									
										
										
										
											2023-03-03 19:03:15 -08:00
										 |  |  |     options: AdjacentMessagesByConversationOptionsType | 
					
						
							| 
									
										
										
										
											2024-07-24 13:14:11 -07:00
										 |  |  |   ) => Array<MessageType>; | 
					
						
							| 
									
										
										
										
											2023-03-03 19:03:15 -08:00
										 |  |  |   getConversationRangeCenteredOnMessage: ( | 
					
						
							|  |  |  |     options: AdjacentMessagesByConversationOptionsType | 
					
						
							| 
									
										
										
										
											2024-07-22 11:16:33 -07:00
										 |  |  |   ) => GetConversationRangeCenteredOnMessageResultType<MessageType>; | 
					
						
							| 
									
										
										
										
											2022-07-28 09:35:29 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-07-22 11:16:33 -07:00
										 |  |  |   getIdentityKeyById: (id: IdentityKeyIdType) => IdentityKeyType | undefined; | 
					
						
							|  |  |  |   getAllIdentityKeys: () => Array<IdentityKeyType>; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   getKyberPreKeyById: (id: PreKeyIdType) => KyberPreKeyType | undefined; | 
					
						
							|  |  |  |   getAllKyberPreKeys: () => Array<KyberPreKeyType>; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   getPreKeyById: (id: PreKeyIdType) => PreKeyType | undefined; | 
					
						
							|  |  |  |   getAllPreKeys: () => Array<PreKeyType>; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   getSignedPreKeyById: (id: SignedPreKeyIdType) => SignedPreKeyType | undefined; | 
					
						
							|  |  |  |   getAllSignedPreKeys: () => Array<SignedPreKeyType>; | 
					
						
							| 
									
										
										
										
											2022-07-28 09:35:29 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-07-22 11:16:33 -07:00
										 |  |  |   getItemById<K extends ItemKeyType>(id: K): ItemType<K> | undefined; | 
					
						
							|  |  |  |   getAllItems: () => AllItemsType; | 
					
						
							|  |  |  | }>; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | export type ClientOnlyWritableInterface = ClientInterfaceWrap<{ | 
					
						
							|  |  |  |   // Differing signature on client/server
 | 
					
						
							|  |  |  |   updateConversation: (data: ConversationType) => void; | 
					
						
							|  |  |  |   removeConversation: (id: string) => void; | 
					
						
							|  |  |  |   flushUpdateConversationBatcher: () => void; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-01-10 08:18:32 +10:00
										 |  |  |   saveMessage: ( | 
					
						
							|  |  |  |     data: ReadonlyDeep<MessageType>, | 
					
						
							|  |  |  |     options: { | 
					
						
							|  |  |  |       jobToInsert?: StoredJob; | 
					
						
							|  |  |  |       forceSave?: boolean; | 
					
						
							|  |  |  |       ourAci: AciString; | 
					
						
							|  |  |  |       postSaveUpdates: () => Promise<void>; | 
					
						
							| 
									
										
										
										
											2025-05-22 21:09:54 -04:00
										 |  |  |       _testOnlyAvoidNormalizingAttachments?: boolean; | 
					
						
							| 
									
										
										
										
											2025-01-10 08:18:32 +10:00
										 |  |  |     } | 
					
						
							|  |  |  |   ) => string; | 
					
						
							|  |  |  |   saveMessages: ( | 
					
						
							|  |  |  |     arrayOfMessages: ReadonlyArray<ReadonlyDeep<MessageType>>, | 
					
						
							|  |  |  |     options: { | 
					
						
							|  |  |  |       forceSave?: boolean; | 
					
						
							|  |  |  |       ourAci: AciString; | 
					
						
							|  |  |  |       postSaveUpdates: () => Promise<void>; | 
					
						
							| 
									
										
										
										
											2025-05-22 21:09:54 -04:00
										 |  |  |       _testOnlyAvoidNormalizingAttachments?: boolean; | 
					
						
							| 
									
										
										
										
											2025-01-10 08:18:32 +10:00
										 |  |  |     } | 
					
						
							|  |  |  |   ) => Array<string>; | 
					
						
							|  |  |  |   saveMessagesIndividually: ( | 
					
						
							|  |  |  |     arrayOfMessages: ReadonlyArray<ReadonlyDeep<MessageType>>, | 
					
						
							|  |  |  |     options: { | 
					
						
							|  |  |  |       forceSave?: boolean; | 
					
						
							|  |  |  |       ourAci: AciString; | 
					
						
							|  |  |  |       postSaveUpdates: () => Promise<void>; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |   ) => { failedIndices: Array<number> }; | 
					
						
							| 
									
										
										
										
											2024-07-22 11:16:33 -07:00
										 |  |  |   removeMessage: ( | 
					
						
							|  |  |  |     id: string, | 
					
						
							|  |  |  |     options: { | 
					
						
							|  |  |  |       fromSync?: boolean; | 
					
						
							| 
									
										
										
										
											2025-01-10 08:18:32 +10:00
										 |  |  |       cleanupMessages: ( | 
					
						
							|  |  |  |         messages: ReadonlyArray<MessageAttributesType>, | 
					
						
							|  |  |  |         options: { fromSync?: boolean | undefined } | 
					
						
							|  |  |  |       ) => Promise<void>; | 
					
						
							| 
									
										
										
										
											2024-07-22 11:16:33 -07:00
										 |  |  |     } | 
					
						
							|  |  |  |   ) => void; | 
					
						
							|  |  |  |   removeMessages: ( | 
					
						
							|  |  |  |     ids: ReadonlyArray<string>, | 
					
						
							|  |  |  |     options: { | 
					
						
							|  |  |  |       fromSync?: boolean; | 
					
						
							| 
									
										
										
										
											2025-01-10 08:18:32 +10:00
										 |  |  |       cleanupMessages: ( | 
					
						
							|  |  |  |         messages: ReadonlyArray<MessageAttributesType>, | 
					
						
							|  |  |  |         options: { fromSync?: boolean | undefined } | 
					
						
							|  |  |  |       ) => Promise<void>; | 
					
						
							| 
									
										
										
										
											2024-07-22 11:16:33 -07:00
										 |  |  |     } | 
					
						
							|  |  |  |   ) => void; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   createOrUpdateIdentityKey: (data: IdentityKeyType) => void; | 
					
						
							|  |  |  |   bulkAddIdentityKeys: (array: Array<IdentityKeyType>) => void; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   createOrUpdateKyberPreKey: (data: KyberPreKeyType) => void; | 
					
						
							|  |  |  |   bulkAddKyberPreKeys: (array: Array<KyberPreKeyType>) => void; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   createOrUpdatePreKey: (data: PreKeyType) => void; | 
					
						
							|  |  |  |   bulkAddPreKeys: (array: Array<PreKeyType>) => void; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   createOrUpdateSignedPreKey: (data: SignedPreKeyType) => void; | 
					
						
							|  |  |  |   bulkAddSignedPreKeys: (array: Array<SignedPreKeyType>) => void; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   createOrUpdateItem<K extends ItemKeyType>(data: ItemType<K>): void; | 
					
						
							| 
									
										
										
										
											2020-04-01 11:59:11 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  |   // Client-side only
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-07-22 11:16:33 -07:00
										 |  |  |   shutdown: () => void; | 
					
						
							| 
									
										
										
										
											2024-08-12 12:54:24 -07:00
										 |  |  |   removeDB: () => void; | 
					
						
							| 
									
										
										
										
											2024-05-29 01:56:00 +10:00
										 |  |  |   removeMessagesInConversation: ( | 
					
						
							| 
									
										
										
										
											2020-04-01 11:59:11 -07:00
										 |  |  |     conversationId: string, | 
					
						
							| 
									
										
										
										
											2021-01-12 16:42:15 -08:00
										 |  |  |     options: { | 
					
						
							| 
									
										
										
										
											2025-01-10 08:18:32 +10:00
										 |  |  |       cleanupMessages: ( | 
					
						
							|  |  |  |         messages: ReadonlyArray<MessageAttributesType>, | 
					
						
							|  |  |  |         options: { fromSync?: boolean | undefined } | 
					
						
							|  |  |  |       ) => Promise<void>; | 
					
						
							| 
									
										
										
										
											2024-06-17 12:24:39 -07:00
										 |  |  |       fromSync?: boolean; | 
					
						
							| 
									
										
										
										
											2021-01-12 16:42:15 -08:00
										 |  |  |       logId: string; | 
					
						
							| 
									
										
										
										
											2024-05-29 01:56:00 +10:00
										 |  |  |       receivedAt?: number; | 
					
						
							| 
									
										
										
										
											2021-01-12 16:42:15 -08:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2024-07-22 11:16:33 -07:00
										 |  |  |   ) => void; | 
					
						
							|  |  |  |   removeOtherData: () => void; | 
					
						
							| 
									
										
										
										
											2025-05-22 21:09:54 -04:00
										 |  |  |   cleanupOrphanedAttachments: (options?: { _block: boolean }) => void; | 
					
						
							| 
									
										
										
										
											2024-07-22 11:16:33 -07:00
										 |  |  |   ensureFilePermissions: () => void; | 
					
						
							|  |  |  | }>; | 
					
						
							| 
									
										
										
										
											2020-04-01 11:59:11 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-07-22 11:16:33 -07:00
										 |  |  | export type ClientReadableInterface = ClientInterfaceWrap<ReadableInterface> & | 
					
						
							|  |  |  |   ClientOnlyReadableInterface; | 
					
						
							|  |  |  | export type ClientWritableInterface = ClientInterfaceWrap<WritableInterface> & | 
					
						
							|  |  |  |   ClientOnlyWritableInterface; |