| 
									
										
										
										
											2021-01-14 12:07:05 -06:00
										 |  |  | // Copyright 2020-2021 Signal Messenger, LLC
 | 
					
						
							| 
									
										
										
										
											2020-10-30 15:34:04 -05:00
										 |  |  | // SPDX-License-Identifier: AGPL-3.0-only
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-09-24 14:53:21 -07:00
										 |  |  | /* eslint-disable @typescript-eslint/ban-types */ | 
					
						
							|  |  |  | /* eslint-disable camelcase */ | 
					
						
							|  |  |  | /* eslint-disable @typescript-eslint/no-explicit-any */ | 
					
						
							| 
									
										
										
										
											2021-07-09 12:36:10 -07:00
										 |  |  | import type { | 
					
						
							| 
									
										
										
										
											2021-04-05 15:18:19 -07:00
										 |  |  |   ConversationAttributesType, | 
					
						
							| 
									
										
										
										
											2020-09-24 14:53:21 -07:00
										 |  |  |   ConversationModelCollectionType, | 
					
						
							| 
									
										
										
										
											2021-04-05 15:18:19 -07:00
										 |  |  |   MessageAttributesType, | 
					
						
							| 
									
										
										
										
											2020-09-24 14:53:21 -07:00
										 |  |  |   MessageModelCollectionType, | 
					
						
							|  |  |  | } from '../model-types.d'; | 
					
						
							| 
									
										
										
										
											2021-07-09 12:36:10 -07:00
										 |  |  | import type { MessageModel } from '../models/messages'; | 
					
						
							|  |  |  | import type { ConversationModel } from '../models/conversations'; | 
					
						
							|  |  |  | import type { StoredJob } from '../jobs/types'; | 
					
						
							|  |  |  | import type { ReactionType } from '../types/Reactions'; | 
					
						
							|  |  |  | import type { ConversationColorType, CustomColorType } from '../types/Colors'; | 
					
						
							| 
									
										
										
										
											2021-08-20 11:06:15 -05:00
										 |  |  | import type { ProcessGroupCallRingRequestResult } from '../types/Calling'; | 
					
						
							| 
									
										
										
										
											2021-06-14 17:09:37 -07:00
										 |  |  | import { StorageAccessType } from '../types/Storage.d'; | 
					
						
							| 
									
										
										
										
											2021-07-09 12:36:10 -07:00
										 |  |  | import type { AttachmentType } from '../types/Attachment'; | 
					
						
							| 
									
										
										
										
											2021-07-15 16:48:09 -07:00
										 |  |  | import { BodyRangesType } from '../types/Util'; | 
					
						
							| 
									
										
										
										
											2021-09-09 19:38:11 -07:00
										 |  |  | import type { QualifiedAddressStringType } from '../types/QualifiedAddress'; | 
					
						
							|  |  |  | import type { UUIDStringType } from '../types/UUID'; | 
					
						
							| 
									
										
										
										
											2021-08-30 14:39:57 -07:00
										 |  |  | import type { RemoveAllConfiguration } from '../types/RemoveAllConfiguration'; | 
					
						
							| 
									
										
										
										
											2021-09-16 14:54:06 -07:00
										 |  |  | import type { LoggerType } from '../types/Logging'; | 
					
						
							| 
									
										
										
										
											2021-06-17 10:15:10 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  | export type AttachmentDownloadJobTypeType = | 
					
						
							|  |  |  |   | 'long-message' | 
					
						
							|  |  |  |   | 'attachment' | 
					
						
							|  |  |  |   | 'preview' | 
					
						
							|  |  |  |   | 'contact' | 
					
						
							|  |  |  |   | 'quote' | 
					
						
							|  |  |  |   | 'sticker'; | 
					
						
							| 
									
										
										
										
											2020-09-24 14:53:21 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-04-05 15:18:19 -07:00
										 |  |  | export type AttachmentDownloadJobType = { | 
					
						
							| 
									
										
										
										
											2021-06-17 10:15:10 -07:00
										 |  |  |   attachment: AttachmentType; | 
					
						
							|  |  |  |   attempts: number; | 
					
						
							| 
									
										
										
										
											2021-04-05 15:18:19 -07:00
										 |  |  |   id: string; | 
					
						
							| 
									
										
										
										
											2021-06-17 10:15:10 -07:00
										 |  |  |   index: number; | 
					
						
							|  |  |  |   messageId: string; | 
					
						
							| 
									
										
										
										
											2021-04-05 15:18:19 -07:00
										 |  |  |   pending: number; | 
					
						
							| 
									
										
										
										
											2021-06-17 10:15:10 -07:00
										 |  |  |   timestamp: number; | 
					
						
							|  |  |  |   type: AttachmentDownloadJobTypeType; | 
					
						
							| 
									
										
										
										
											2021-04-05 15:18:19 -07:00
										 |  |  | }; | 
					
						
							|  |  |  | export type MessageMetricsType = { | 
					
						
							|  |  |  |   id: string; | 
					
						
							|  |  |  |   // eslint-disable-next-line camelcase
 | 
					
						
							|  |  |  |   received_at: number; | 
					
						
							|  |  |  |   // eslint-disable-next-line camelcase
 | 
					
						
							|  |  |  |   sent_at: number; | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | export type ConversationMetricsType = { | 
					
						
							|  |  |  |   oldest?: MessageMetricsType; | 
					
						
							|  |  |  |   newest?: MessageMetricsType; | 
					
						
							|  |  |  |   oldestUnread?: MessageMetricsType; | 
					
						
							|  |  |  |   totalUnread: number; | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 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; | 
					
						
							| 
									
										
										
										
											2021-09-09 19:38:11 -07:00
										 |  |  |   id: UUIDStringType | `conversation:${UUIDStringType}`; | 
					
						
							| 
									
										
										
										
											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; | 
					
						
							|  |  |  | }; | 
					
						
							| 
									
										
										
										
											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>; | 
					
						
							|  |  |  | export type ItemType<K extends ItemKeyType> = { | 
					
						
							|  |  |  |   id: K; | 
					
						
							|  |  |  |   value: StorageAccessType[K]; | 
					
						
							|  |  |  | }; | 
					
						
							| 
									
										
										
										
											2021-04-05 15:18:19 -07:00
										 |  |  | export type MessageType = MessageAttributesType; | 
					
						
							| 
									
										
										
										
											2021-07-12 16:51:45 -07:00
										 |  |  | export type MessageTypeUnhydrated = { | 
					
						
							|  |  |  |   json: string; | 
					
						
							|  |  |  | }; | 
					
						
							| 
									
										
										
										
											2021-04-05 15:18:19 -07:00
										 |  |  | export type PreKeyType = { | 
					
						
							| 
									
										
										
										
											2021-09-09 19:38:11 -07:00
										 |  |  |   id: `${UUIDStringType}:${number}`; | 
					
						
							|  |  |  |   keyId: number; | 
					
						
							|  |  |  |   ourUuid: UUIDStringType; | 
					
						
							| 
									
										
										
										
											2021-09-23 17:49:05 -07:00
										 |  |  |   privateKey: Uint8Array; | 
					
						
							|  |  |  |   publicKey: Uint8Array; | 
					
						
							| 
									
										
										
										
											2021-04-05 15:18:19 -07:00
										 |  |  | }; | 
					
						
							| 
									
										
										
										
											2021-09-09 19:38:11 -07:00
										 |  |  | export type PreKeyIdType = PreKeyType['id']; | 
					
						
							| 
									
										
										
										
											2021-07-12 16:51:45 -07:00
										 |  |  | export type SearchResultMessageType = { | 
					
						
							|  |  |  |   json: string; | 
					
						
							| 
									
										
										
										
											2021-04-05 15:18:19 -07:00
										 |  |  |   snippet: string; | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | export type ClientSearchResultMessageType = MessageType & { | 
					
						
							|  |  |  |   json: string; | 
					
						
							| 
									
										
										
										
											2021-07-15 16:48:09 -07:00
										 |  |  |   bodyRanges: BodyRangesType; | 
					
						
							| 
									
										
										
										
											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; | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | export type SentProtoWithMessageIdsType = SentProtoType & { | 
					
						
							|  |  |  |   messageIds: Array<string>; | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | export type SentRecipientsType = Record<string, Array<number>>; | 
					
						
							|  |  |  | export type SentMessagesType = Array<string>; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | // These two are for test only
 | 
					
						
							|  |  |  | export type SentRecipientsDBType = { | 
					
						
							|  |  |  |   payloadId: number; | 
					
						
							|  |  |  |   recipientUuid: string; | 
					
						
							|  |  |  |   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; | 
					
						
							|  |  |  |   ourUuid: UUIDStringType; | 
					
						
							|  |  |  |   uuid: UUIDStringType; | 
					
						
							| 
									
										
										
										
											2021-04-05 15:18:19 -07:00
										 |  |  |   conversationId: string; | 
					
						
							|  |  |  |   deviceId: number; | 
					
						
							|  |  |  |   record: string; | 
					
						
							| 
									
										
										
										
											2021-04-16 16:13:13 -07:00
										 |  |  |   version?: number; | 
					
						
							| 
									
										
										
										
											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; | 
					
						
							|  |  |  |   // eslint-disable-next-line camelcase
 | 
					
						
							|  |  |  |   created_at: number; | 
					
						
							| 
									
										
										
										
											2021-09-09 19:38:11 -07:00
										 |  |  |   ourUuid: UUIDStringType; | 
					
						
							|  |  |  |   id: `${UUIDStringType}:${number}`; | 
					
						
							|  |  |  |   keyId: number; | 
					
						
							| 
									
										
										
										
											2021-09-23 17:49:05 -07:00
										 |  |  |   privateKey: Uint8Array; | 
					
						
							|  |  |  |   publicKey: Uint8Array; | 
					
						
							| 
									
										
										
										
											2021-04-05 15:18:19 -07:00
										 |  |  | }; | 
					
						
							| 
									
										
										
										
											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; | 
					
						
							| 
									
										
										
										
											2021-07-09 12:36:10 -07:00
										 |  |  | }>; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | export const StickerPackStatuses = [ | 
					
						
							|  |  |  |   'known', | 
					
						
							|  |  |  |   'ephemeral', | 
					
						
							|  |  |  |   'downloaded', | 
					
						
							|  |  |  |   'installed', | 
					
						
							|  |  |  |   'pending', | 
					
						
							|  |  |  |   'error', | 
					
						
							|  |  |  | ] as const; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | export type StickerPackStatusType = typeof StickerPackStatuses[number]; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | export type StickerPackType = Readonly<{ | 
					
						
							| 
									
										
										
										
											2021-04-05 15:18:19 -07:00
										 |  |  |   id: string; | 
					
						
							|  |  |  |   key: string; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-07-09 12:36:10 -07:00
										 |  |  |   attemptedStatus?: 'downloaded' | 'installed' | 'ephemeral'; | 
					
						
							| 
									
										
										
										
											2021-04-05 15:18:19 -07:00
										 |  |  |   author: string; | 
					
						
							|  |  |  |   coverStickerId: number; | 
					
						
							|  |  |  |   createdAt: number; | 
					
						
							|  |  |  |   downloadAttempts: number; | 
					
						
							| 
									
										
										
										
											2021-07-09 12:36:10 -07:00
										 |  |  |   installedAt?: number; | 
					
						
							|  |  |  |   lastUsed?: number; | 
					
						
							| 
									
										
										
										
											2021-04-05 15:18:19 -07:00
										 |  |  |   status: StickerPackStatusType; | 
					
						
							|  |  |  |   stickerCount: number; | 
					
						
							| 
									
										
										
										
											2021-07-09 12:36:10 -07:00
										 |  |  |   stickers: Record<string, StickerType>; | 
					
						
							| 
									
										
										
										
											2021-04-05 15:18:19 -07:00
										 |  |  |   title: string; | 
					
						
							| 
									
										
										
										
											2021-07-09 12:36:10 -07:00
										 |  |  | }>; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-04-05 15:18:19 -07:00
										 |  |  | export type UnprocessedType = { | 
					
						
							|  |  |  |   id: string; | 
					
						
							|  |  |  |   timestamp: number; | 
					
						
							|  |  |  |   version: number; | 
					
						
							|  |  |  |   attempts: number; | 
					
						
							| 
									
										
										
										
											2021-05-17 11:03:42 -07:00
										 |  |  |   envelope?: string; | 
					
						
							| 
									
										
										
										
											2021-04-05 15:18:19 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  |   source?: string; | 
					
						
							|  |  |  |   sourceUuid?: string; | 
					
						
							| 
									
										
										
										
											2021-05-17 11:03:42 -07:00
										 |  |  |   sourceDevice?: number; | 
					
						
							| 
									
										
										
										
											2021-05-27 16:17:05 -04:00
										 |  |  |   serverGuid?: string; | 
					
						
							| 
									
										
										
										
											2021-04-05 15:18:19 -07:00
										 |  |  |   serverTimestamp?: number; | 
					
						
							|  |  |  |   decrypted?: string; | 
					
						
							|  |  |  | }; | 
					
						
							| 
									
										
										
										
											2020-04-01 11:59:11 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-04-16 16:13:13 -07:00
										 |  |  | export type UnprocessedUpdateType = { | 
					
						
							|  |  |  |   source?: string; | 
					
						
							|  |  |  |   sourceUuid?: string; | 
					
						
							| 
									
										
										
										
											2021-08-02 14:55:31 -07:00
										 |  |  |   sourceDevice?: number; | 
					
						
							| 
									
										
										
										
											2021-05-27 16:17:05 -04:00
										 |  |  |   serverGuid?: string; | 
					
						
							| 
									
										
										
										
											2021-04-16 16:13:13 -07:00
										 |  |  |   serverTimestamp?: number; | 
					
						
							|  |  |  |   decrypted?: string; | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-08-16 09:56:27 -07:00
										 |  |  | export type LastConversationMessagesServerType = { | 
					
						
							|  |  |  |   activity?: MessageType; | 
					
						
							|  |  |  |   preview?: MessageType; | 
					
						
							|  |  |  |   hasUserInitiatedMessages: boolean; | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | export type LastConversationMessagesType = { | 
					
						
							|  |  |  |   activity?: MessageModel; | 
					
						
							|  |  |  |   preview?: MessageModel; | 
					
						
							|  |  |  |   hasUserInitiatedMessages: boolean; | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-08-31 14:35:01 -07:00
										 |  |  | export type DeleteSentProtoRecipientOptionsType = Readonly<{ | 
					
						
							|  |  |  |   timestamp: number; | 
					
						
							|  |  |  |   recipientUuid: string; | 
					
						
							|  |  |  |   deviceId: number; | 
					
						
							|  |  |  | }>; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-01-14 12:07:05 -06:00
										 |  |  | export type DataInterface = { | 
					
						
							| 
									
										
										
										
											2020-04-01 11:59:11 -07:00
										 |  |  |   close: () => Promise<void>; | 
					
						
							|  |  |  |   removeDB: () => Promise<void>; | 
					
						
							|  |  |  |   removeIndexedDBFiles: () => Promise<void>; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   createOrUpdateIdentityKey: (data: IdentityKeyType) => Promise<void>; | 
					
						
							| 
									
										
										
										
											2021-09-09 19:38:11 -07:00
										 |  |  |   getIdentityKeyById: ( | 
					
						
							|  |  |  |     id: IdentityKeyIdType | 
					
						
							|  |  |  |   ) => Promise<IdentityKeyType | undefined>; | 
					
						
							| 
									
										
										
										
											2020-04-01 11:59:11 -07:00
										 |  |  |   bulkAddIdentityKeys: (array: Array<IdentityKeyType>) => Promise<void>; | 
					
						
							| 
									
										
										
										
											2021-09-09 19:38:11 -07:00
										 |  |  |   removeIdentityKeyById: (id: IdentityKeyIdType) => Promise<void>; | 
					
						
							| 
									
										
										
										
											2020-04-01 11:59:11 -07:00
										 |  |  |   removeAllIdentityKeys: () => Promise<void>; | 
					
						
							|  |  |  |   getAllIdentityKeys: () => Promise<Array<IdentityKeyType>>; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   createOrUpdatePreKey: (data: PreKeyType) => Promise<void>; | 
					
						
							| 
									
										
										
										
											2021-09-09 19:38:11 -07:00
										 |  |  |   getPreKeyById: (id: PreKeyIdType) => Promise<PreKeyType | undefined>; | 
					
						
							| 
									
										
										
										
											2020-04-01 11:59:11 -07:00
										 |  |  |   bulkAddPreKeys: (array: Array<PreKeyType>) => Promise<void>; | 
					
						
							| 
									
										
										
										
											2021-09-09 19:38:11 -07:00
										 |  |  |   removePreKeyById: (id: PreKeyIdType) => Promise<void>; | 
					
						
							| 
									
										
										
										
											2020-04-01 11:59:11 -07:00
										 |  |  |   removeAllPreKeys: () => Promise<void>; | 
					
						
							|  |  |  |   getAllPreKeys: () => Promise<Array<PreKeyType>>; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   createOrUpdateSignedPreKey: (data: SignedPreKeyType) => Promise<void>; | 
					
						
							| 
									
										
										
										
											2021-09-09 19:38:11 -07:00
										 |  |  |   getSignedPreKeyById: ( | 
					
						
							|  |  |  |     id: SignedPreKeyIdType | 
					
						
							|  |  |  |   ) => Promise<SignedPreKeyType | undefined>; | 
					
						
							| 
									
										
										
										
											2020-04-01 11:59:11 -07:00
										 |  |  |   bulkAddSignedPreKeys: (array: Array<SignedPreKeyType>) => Promise<void>; | 
					
						
							| 
									
										
										
										
											2021-09-09 19:38:11 -07:00
										 |  |  |   removeSignedPreKeyById: (id: SignedPreKeyIdType) => Promise<void>; | 
					
						
							| 
									
										
										
										
											2020-04-01 11:59:11 -07:00
										 |  |  |   removeAllSignedPreKeys: () => Promise<void>; | 
					
						
							|  |  |  |   getAllSignedPreKeys: () => Promise<Array<SignedPreKeyType>>; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-06-14 17:09:37 -07:00
										 |  |  |   createOrUpdateItem<K extends ItemKeyType>(data: ItemType<K>): Promise<void>; | 
					
						
							|  |  |  |   getItemById<K extends ItemKeyType>(id: K): Promise<ItemType<K> | undefined>; | 
					
						
							|  |  |  |   removeItemById: (id: ItemKeyType) => Promise<void>; | 
					
						
							| 
									
										
										
										
											2020-04-01 11:59:11 -07:00
										 |  |  |   removeAllItems: () => Promise<void>; | 
					
						
							| 
									
										
										
										
											2021-06-14 17:09:37 -07:00
										 |  |  |   getAllItems: () => Promise<AllItemsType>; | 
					
						
							| 
									
										
										
										
											2020-04-01 11:59:11 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-05-13 18:18:43 -07:00
										 |  |  |   createOrUpdateSenderKey: (key: SenderKeyType) => Promise<void>; | 
					
						
							| 
									
										
										
										
											2021-09-09 19:38:11 -07:00
										 |  |  |   getSenderKeyById: (id: SenderKeyIdType) => Promise<SenderKeyType | undefined>; | 
					
						
							| 
									
										
										
										
											2021-05-13 18:18:43 -07:00
										 |  |  |   removeAllSenderKeys: () => Promise<void>; | 
					
						
							|  |  |  |   getAllSenderKeys: () => Promise<Array<SenderKeyType>>; | 
					
						
							| 
									
										
										
										
											2021-09-09 19:38:11 -07:00
										 |  |  |   removeSenderKeyById: (id: SenderKeyIdType) => Promise<void>; | 
					
						
							| 
									
										
										
										
											2021-05-13 18:18:43 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-07-15 16:48:09 -07:00
										 |  |  |   insertSentProto: ( | 
					
						
							|  |  |  |     proto: SentProtoType, | 
					
						
							|  |  |  |     options: { | 
					
						
							|  |  |  |       recipients: SentRecipientsType; | 
					
						
							|  |  |  |       messageIds: SentMessagesType; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |   ) => Promise<number>; | 
					
						
							|  |  |  |   deleteSentProtosOlderThan: (timestamp: number) => Promise<void>; | 
					
						
							|  |  |  |   deleteSentProtoByMessageId: (messageId: string) => Promise<void>; | 
					
						
							|  |  |  |   insertProtoRecipients: (options: { | 
					
						
							|  |  |  |     id: number; | 
					
						
							|  |  |  |     recipientUuid: string; | 
					
						
							|  |  |  |     deviceIds: Array<number>; | 
					
						
							|  |  |  |   }) => Promise<void>; | 
					
						
							| 
									
										
										
										
											2021-08-31 14:35:01 -07:00
										 |  |  |   deleteSentProtoRecipient: ( | 
					
						
							|  |  |  |     options: | 
					
						
							|  |  |  |       | DeleteSentProtoRecipientOptionsType | 
					
						
							|  |  |  |       | ReadonlyArray<DeleteSentProtoRecipientOptionsType> | 
					
						
							|  |  |  |   ) => Promise<void>; | 
					
						
							| 
									
										
										
										
											2021-07-15 16:48:09 -07:00
										 |  |  |   getSentProtoByRecipient: (options: { | 
					
						
							|  |  |  |     now: number; | 
					
						
							|  |  |  |     recipientUuid: string; | 
					
						
							|  |  |  |     timestamp: number; | 
					
						
							|  |  |  |   }) => Promise<SentProtoWithMessageIdsType | undefined>; | 
					
						
							|  |  |  |   removeAllSentProtos: () => Promise<void>; | 
					
						
							|  |  |  |   getAllSentProtos: () => Promise<Array<SentProtoType>>; | 
					
						
							|  |  |  |   // Test-only
 | 
					
						
							|  |  |  |   _getAllSentProtoRecipients: () => Promise<Array<SentRecipientsDBType>>; | 
					
						
							|  |  |  |   _getAllSentProtoMessageIds: () => Promise<Array<SentMessageDBType>>; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-04-01 11:59:11 -07:00
										 |  |  |   createOrUpdateSession: (data: SessionType) => Promise<void>; | 
					
						
							|  |  |  |   createOrUpdateSessions: (array: Array<SessionType>) => Promise<void>; | 
					
						
							| 
									
										
										
										
											2021-05-17 11:03:42 -07:00
										 |  |  |   commitSessionsAndUnprocessed(options: { | 
					
						
							|  |  |  |     sessions: Array<SessionType>; | 
					
						
							|  |  |  |     unprocessed: Array<UnprocessedType>; | 
					
						
							|  |  |  |   }): Promise<void>; | 
					
						
							| 
									
										
										
										
											2020-04-01 11:59:11 -07:00
										 |  |  |   bulkAddSessions: (array: Array<SessionType>) => Promise<void>; | 
					
						
							| 
									
										
										
										
											2021-09-09 19:38:11 -07:00
										 |  |  |   removeSessionById: (id: SessionIdType) => Promise<void>; | 
					
						
							| 
									
										
										
										
											2020-04-01 11:59:11 -07:00
										 |  |  |   removeSessionsByConversation: (conversationId: string) => Promise<void>; | 
					
						
							|  |  |  |   removeAllSessions: () => Promise<void>; | 
					
						
							|  |  |  |   getAllSessions: () => Promise<Array<SessionType>>; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-09-08 20:56:23 -04:00
										 |  |  |   eraseStorageServiceStateFromConversations: () => Promise<void>; | 
					
						
							| 
									
										
										
										
											2020-04-01 11:59:11 -07:00
										 |  |  |   getConversationCount: () => Promise<number>; | 
					
						
							|  |  |  |   saveConversation: (data: ConversationType) => Promise<void>; | 
					
						
							|  |  |  |   saveConversations: (array: Array<ConversationType>) => Promise<void>; | 
					
						
							|  |  |  |   updateConversations: (array: Array<ConversationType>) => Promise<void>; | 
					
						
							|  |  |  |   getAllConversationIds: () => Promise<Array<string>>; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   searchConversations: ( | 
					
						
							|  |  |  |     query: string, | 
					
						
							|  |  |  |     options?: { limit?: number } | 
					
						
							|  |  |  |   ) => Promise<Array<ConversationType>>; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-08-31 15:58:39 -05:00
										 |  |  |   getMessagesById: (messageIds: Array<string>) => Promise<Array<MessageType>>; | 
					
						
							| 
									
										
										
										
											2021-07-19 13:45:18 -07:00
										 |  |  |   saveMessage: ( | 
					
						
							|  |  |  |     data: MessageType, | 
					
						
							| 
									
										
										
										
											2021-08-31 15:58:39 -05:00
										 |  |  |     options?: { | 
					
						
							|  |  |  |       jobToInsert?: StoredJob; | 
					
						
							|  |  |  |       forceSave?: boolean; | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2021-07-19 13:45:18 -07:00
										 |  |  |   ) => Promise<string>; | 
					
						
							|  |  |  |   saveMessages: ( | 
					
						
							|  |  |  |     arrayOfMessages: Array<MessageType>, | 
					
						
							|  |  |  |     options?: { forceSave?: boolean } | 
					
						
							|  |  |  |   ) => Promise<void>; | 
					
						
							| 
									
										
										
										
											2020-05-27 17:37:06 -04:00
										 |  |  |   getMessageCount: (conversationId?: string) => Promise<number>; | 
					
						
							| 
									
										
										
										
											2020-04-01 11:59:11 -07:00
										 |  |  |   getAllMessageIds: () => Promise<Array<string>>; | 
					
						
							|  |  |  |   getMessageMetricsForConversation: ( | 
					
						
							|  |  |  |     conversationId: string | 
					
						
							| 
									
										
										
										
											2021-04-05 15:18:19 -07:00
										 |  |  |   ) => Promise<ConversationMetricsType>; | 
					
						
							| 
									
										
										
										
											2020-12-07 14:43:19 -06:00
										 |  |  |   hasGroupCallHistoryMessage: ( | 
					
						
							|  |  |  |     conversationId: string, | 
					
						
							|  |  |  |     eraId: string | 
					
						
							|  |  |  |   ) => Promise<boolean>; | 
					
						
							| 
									
										
										
										
											2020-07-10 11:28:49 -07:00
										 |  |  |   migrateConversationMessages: ( | 
					
						
							|  |  |  |     obsoleteId: string, | 
					
						
							|  |  |  |     currentId: string | 
					
						
							|  |  |  |   ) => Promise<void>; | 
					
						
							| 
									
										
										
										
											2021-05-19 11:17:51 -05:00
										 |  |  |   getNextTapToViewMessageTimestampToAgeOut: () => Promise<undefined | number>; | 
					
						
							| 
									
										
										
										
											2020-04-01 11:59:11 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-07-15 16:48:09 -07:00
										 |  |  |   getUnreadCountForConversation: (conversationId: string) => Promise<number>; | 
					
						
							|  |  |  |   getUnreadByConversationAndMarkRead: ( | 
					
						
							|  |  |  |     conversationId: string, | 
					
						
							|  |  |  |     newestUnreadId: number, | 
					
						
							|  |  |  |     readAt?: number | 
					
						
							|  |  |  |   ) => Promise< | 
					
						
							|  |  |  |     Array< | 
					
						
							|  |  |  |       Pick<MessageType, 'id' | 'source' | 'sourceUuid' | 'sent_at' | 'type'> | 
					
						
							|  |  |  |     > | 
					
						
							|  |  |  |   >; | 
					
						
							|  |  |  |   getUnreadReactionsAndMarkRead: ( | 
					
						
							|  |  |  |     conversationId: string, | 
					
						
							|  |  |  |     newestUnreadId: number | 
					
						
							|  |  |  |   ) => Promise< | 
					
						
							|  |  |  |     Array< | 
					
						
							|  |  |  |       Pick<ReactionType, 'targetAuthorUuid' | 'targetTimestamp' | 'messageId'> | 
					
						
							|  |  |  |     > | 
					
						
							|  |  |  |   >; | 
					
						
							|  |  |  |   markReactionAsRead: ( | 
					
						
							|  |  |  |     targetAuthorUuid: string, | 
					
						
							|  |  |  |     targetTimestamp: number | 
					
						
							|  |  |  |   ) => Promise<ReactionType | undefined>; | 
					
						
							|  |  |  |   removeReactionFromConversation: (reaction: { | 
					
						
							|  |  |  |     emoji: string; | 
					
						
							|  |  |  |     fromId: string; | 
					
						
							|  |  |  |     targetAuthorUuid: string; | 
					
						
							|  |  |  |     targetTimestamp: number; | 
					
						
							|  |  |  |   }) => Promise<void>; | 
					
						
							|  |  |  |   addReaction: (reactionObj: ReactionType) => Promise<void>; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-04-01 11:59:11 -07:00
										 |  |  |   getUnprocessedCount: () => Promise<number>; | 
					
						
							|  |  |  |   getAllUnprocessed: () => Promise<Array<UnprocessedType>>; | 
					
						
							|  |  |  |   updateUnprocessedWithData: ( | 
					
						
							|  |  |  |     id: string, | 
					
						
							| 
									
										
										
										
											2021-04-16 16:13:13 -07:00
										 |  |  |     data: UnprocessedUpdateType | 
					
						
							| 
									
										
										
										
											2020-04-01 11:59:11 -07:00
										 |  |  |   ) => Promise<void>; | 
					
						
							| 
									
										
										
										
											2021-04-05 15:18:19 -07:00
										 |  |  |   updateUnprocessedsWithData: ( | 
					
						
							| 
									
										
										
										
											2021-04-16 16:13:13 -07:00
										 |  |  |     array: Array<{ id: string; data: UnprocessedUpdateType }> | 
					
						
							| 
									
										
										
										
											2021-04-05 15:18:19 -07:00
										 |  |  |   ) => Promise<void>; | 
					
						
							| 
									
										
										
										
											2020-04-01 11:59:11 -07:00
										 |  |  |   getUnprocessedById: (id: string) => Promise<UnprocessedType | undefined>; | 
					
						
							| 
									
										
										
										
											2021-02-26 15:42:45 -08:00
										 |  |  |   removeUnprocessed: (id: string | Array<string>) => Promise<void>; | 
					
						
							| 
									
										
										
										
											2020-04-01 11:59:11 -07:00
										 |  |  |   removeAllUnprocessed: () => Promise<void>; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   getNextAttachmentDownloadJobs: ( | 
					
						
							|  |  |  |     limit?: number, | 
					
						
							|  |  |  |     options?: { timestamp?: number } | 
					
						
							|  |  |  |   ) => Promise<Array<AttachmentDownloadJobType>>; | 
					
						
							|  |  |  |   saveAttachmentDownloadJob: (job: AttachmentDownloadJobType) => Promise<void>; | 
					
						
							|  |  |  |   setAttachmentDownloadJobPending: ( | 
					
						
							|  |  |  |     id: string, | 
					
						
							|  |  |  |     pending: boolean | 
					
						
							|  |  |  |   ) => Promise<void>; | 
					
						
							|  |  |  |   resetAttachmentDownloadPending: () => Promise<void>; | 
					
						
							|  |  |  |   removeAttachmentDownloadJob: (id: string) => Promise<void>; | 
					
						
							|  |  |  |   removeAllAttachmentDownloadJobs: () => Promise<void>; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   createOrUpdateStickerPack: (pack: StickerPackType) => Promise<void>; | 
					
						
							|  |  |  |   updateStickerPackStatus: ( | 
					
						
							|  |  |  |     id: string, | 
					
						
							|  |  |  |     status: StickerPackStatusType, | 
					
						
							|  |  |  |     options?: { timestamp: number } | 
					
						
							|  |  |  |   ) => Promise<void>; | 
					
						
							|  |  |  |   createOrUpdateSticker: (sticker: StickerType) => Promise<void>; | 
					
						
							|  |  |  |   updateStickerLastUsed: ( | 
					
						
							|  |  |  |     packId: string, | 
					
						
							|  |  |  |     stickerId: number, | 
					
						
							|  |  |  |     lastUsed: number | 
					
						
							|  |  |  |   ) => Promise<void>; | 
					
						
							|  |  |  |   addStickerPackReference: (messageId: string, packId: string) => Promise<void>; | 
					
						
							|  |  |  |   deleteStickerPackReference: ( | 
					
						
							|  |  |  |     messageId: string, | 
					
						
							|  |  |  |     packId: string | 
					
						
							| 
									
										
										
										
											2021-07-29 11:59:26 -07:00
										 |  |  |   ) => Promise<ReadonlyArray<string> | undefined>; | 
					
						
							| 
									
										
										
										
											2020-04-01 11:59:11 -07:00
										 |  |  |   getStickerCount: () => Promise<number>; | 
					
						
							|  |  |  |   deleteStickerPack: (packId: string) => Promise<Array<string>>; | 
					
						
							|  |  |  |   getAllStickerPacks: () => Promise<Array<StickerPackType>>; | 
					
						
							|  |  |  |   getAllStickers: () => Promise<Array<StickerType>>; | 
					
						
							|  |  |  |   getRecentStickers: (options?: { | 
					
						
							|  |  |  |     limit?: number; | 
					
						
							|  |  |  |   }) => Promise<Array<StickerType>>; | 
					
						
							| 
									
										
										
										
											2021-01-27 14:39:45 -08:00
										 |  |  |   clearAllErrorStickerPackAttempts: () => Promise<void>; | 
					
						
							| 
									
										
										
										
											2020-04-01 11:59:11 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  |   updateEmojiUsage: (shortName: string, timeUsed?: number) => Promise<void>; | 
					
						
							|  |  |  |   getRecentEmojis: (limit?: number) => Promise<Array<EmojiType>>; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   removeAll: () => Promise<void>; | 
					
						
							| 
									
										
										
										
											2021-08-30 14:39:57 -07:00
										 |  |  |   removeAllConfiguration: (type?: RemoveAllConfiguration) => Promise<void>; | 
					
						
							| 
									
										
										
										
											2020-04-01 11:59:11 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  |   getMessagesNeedingUpgrade: ( | 
					
						
							|  |  |  |     limit: number, | 
					
						
							|  |  |  |     options: { maxVersion: number } | 
					
						
							|  |  |  |   ) => Promise<Array<MessageType>>; | 
					
						
							|  |  |  |   getMessagesWithVisualMediaAttachments: ( | 
					
						
							|  |  |  |     conversationId: string, | 
					
						
							|  |  |  |     options: { limit: number } | 
					
						
							|  |  |  |   ) => Promise<Array<MessageType>>; | 
					
						
							|  |  |  |   getMessagesWithFileAttachments: ( | 
					
						
							|  |  |  |     conversationId: string, | 
					
						
							|  |  |  |     options: { limit: number } | 
					
						
							|  |  |  |   ) => Promise<Array<MessageType>>; | 
					
						
							| 
									
										
										
										
											2021-05-27 16:17:05 -04:00
										 |  |  |   getMessageServerGuidsForSpam: ( | 
					
						
							|  |  |  |     conversationId: string | 
					
						
							|  |  |  |   ) => Promise<Array<string>>; | 
					
						
							| 
									
										
										
										
											2021-06-18 14:12:04 -05:00
										 |  |  |   getMessagesUnexpectedlyMissingExpirationStartTimestamp: () => Promise< | 
					
						
							|  |  |  |     Array<MessageType> | 
					
						
							|  |  |  |   >; | 
					
						
							| 
									
										
										
										
											2021-06-16 17:20:17 -05:00
										 |  |  |   getSoonestMessageExpiry: () => Promise<undefined | number>; | 
					
						
							| 
									
										
										
										
											2021-04-29 18:02:27 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  |   getJobsInQueue(queueType: string): Promise<Array<StoredJob>>; | 
					
						
							|  |  |  |   insertJob(job: Readonly<StoredJob>): Promise<void>; | 
					
						
							|  |  |  |   deleteJob(id: string): Promise<void>; | 
					
						
							| 
									
										
										
										
											2021-05-28 12:15:17 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-08-20 11:06:15 -05:00
										 |  |  |   processGroupCallRingRequest( | 
					
						
							|  |  |  |     ringId: bigint | 
					
						
							|  |  |  |   ): Promise<ProcessGroupCallRingRequestResult>; | 
					
						
							|  |  |  |   processGroupCallRingCancelation(ringId: bigint): Promise<void>; | 
					
						
							|  |  |  |   cleanExpiredGroupCallRings(): Promise<void>; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-05-28 12:15:17 -04:00
										 |  |  |   updateAllConversationColors: ( | 
					
						
							|  |  |  |     conversationColor?: ConversationColorType, | 
					
						
							|  |  |  |     customColorData?: { | 
					
						
							|  |  |  |       id: string; | 
					
						
							|  |  |  |       value: CustomColorType; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |   ) => Promise<void>; | 
					
						
							| 
									
										
										
										
											2021-07-30 11:43:16 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-09-15 11:45:22 -07:00
										 |  |  |   getMaxMessageCounter(): Promise<number | undefined>; | 
					
						
							| 
									
										
										
										
											2021-07-30 11:43:16 -05:00
										 |  |  |   getStatisticsForLogging(): Promise<Record<string, string>>; | 
					
						
							| 
									
										
										
										
											2021-01-14 12:07:05 -06:00
										 |  |  | }; | 
					
						
							| 
									
										
										
										
											2020-04-01 11:59:11 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  | // The reason for client/server divergence is the need to inject Backbone models and
 | 
					
						
							|  |  |  | //   collections into data calls so those are the objects returned. This was necessary in
 | 
					
						
							|  |  |  | //   July 2018 when creating the Data API as a drop-in replacement for previous database
 | 
					
						
							|  |  |  | //   requests via ORM.
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | // Note: It is extremely important that items are duplicated between these two. Client.js
 | 
					
						
							|  |  |  | //   loops over all of its local functions to generate the server-side IPC-based API.
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | export type ServerInterface = DataInterface & { | 
					
						
							|  |  |  |   getAllConversations: () => Promise<Array<ConversationType>>; | 
					
						
							|  |  |  |   getAllGroupsInvolvingId: (id: string) => Promise<Array<ConversationType>>; | 
					
						
							|  |  |  |   getAllPrivateConversations: () => Promise<Array<ConversationType>>; | 
					
						
							| 
									
										
										
										
											2021-04-05 15:18:19 -07:00
										 |  |  |   getConversationById: (id: string) => Promise<ConversationType | undefined>; | 
					
						
							| 
									
										
										
										
											2020-04-01 11:59:11 -07:00
										 |  |  |   getExpiredMessages: () => Promise<Array<MessageType>>; | 
					
						
							|  |  |  |   getMessageById: (id: string) => Promise<MessageType | undefined>; | 
					
						
							|  |  |  |   getMessageBySender: (options: { | 
					
						
							|  |  |  |     source: string; | 
					
						
							|  |  |  |     sourceUuid: string; | 
					
						
							| 
									
										
										
										
											2021-08-02 14:55:31 -07:00
										 |  |  |     sourceDevice: number; | 
					
						
							| 
									
										
										
										
											2020-04-01 11:59:11 -07:00
										 |  |  |     sent_at: number; | 
					
						
							|  |  |  |   }) => Promise<Array<MessageType>>; | 
					
						
							|  |  |  |   getMessagesBySentAt: (sentAt: number) => Promise<Array<MessageType>>; | 
					
						
							|  |  |  |   getOlderMessagesByConversation: ( | 
					
						
							|  |  |  |     conversationId: string, | 
					
						
							| 
									
										
										
										
											2020-09-24 13:57:54 -07:00
										 |  |  |     options?: { | 
					
						
							|  |  |  |       limit?: number; | 
					
						
							|  |  |  |       receivedAt?: number; | 
					
						
							| 
									
										
										
										
											2021-01-13 08:32:18 -08:00
										 |  |  |       sentAt?: number; | 
					
						
							| 
									
										
										
										
											2020-09-24 13:57:54 -07:00
										 |  |  |       messageId?: string; | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2021-07-12 16:51:45 -07:00
										 |  |  |   ) => Promise<Array<MessageTypeUnhydrated>>; | 
					
						
							| 
									
										
										
										
											2020-04-01 11:59:11 -07:00
										 |  |  |   getNewerMessagesByConversation: ( | 
					
						
							|  |  |  |     conversationId: string, | 
					
						
							| 
									
										
										
										
											2021-01-13 08:32:18 -08:00
										 |  |  |     options?: { limit?: number; receivedAt?: number; sentAt?: number } | 
					
						
							| 
									
										
										
										
											2021-07-12 16:51:45 -07:00
										 |  |  |   ) => Promise<Array<MessageTypeUnhydrated>>; | 
					
						
							| 
									
										
										
										
											2021-08-16 09:56:27 -07:00
										 |  |  |   getLastConversationMessages: (options: { | 
					
						
							| 
									
										
										
										
											2021-01-20 09:31:44 -08:00
										 |  |  |     conversationId: string; | 
					
						
							|  |  |  |     ourConversationId: string; | 
					
						
							| 
									
										
										
										
											2021-08-16 09:56:27 -07:00
										 |  |  |   }) => Promise<LastConversationMessagesServerType>; | 
					
						
							| 
									
										
										
										
											2020-04-01 11:59:11 -07:00
										 |  |  |   getTapToViewMessagesNeedingErase: () => Promise<Array<MessageType>>; | 
					
						
							|  |  |  |   removeConversation: (id: Array<string> | string) => Promise<void>; | 
					
						
							| 
									
										
										
										
											2021-01-12 16:42:15 -08:00
										 |  |  |   removeMessage: (id: string) => Promise<void>; | 
					
						
							|  |  |  |   removeMessages: (ids: Array<string>) => Promise<void>; | 
					
						
							| 
									
										
										
										
											2021-04-05 15:18:19 -07:00
										 |  |  |   searchMessages: ( | 
					
						
							|  |  |  |     query: string, | 
					
						
							|  |  |  |     options?: { limit?: number } | 
					
						
							|  |  |  |   ) => Promise<Array<SearchResultMessageType>>; | 
					
						
							|  |  |  |   searchMessagesInConversation: ( | 
					
						
							|  |  |  |     query: string, | 
					
						
							|  |  |  |     conversationId: string, | 
					
						
							|  |  |  |     options?: { limit?: number } | 
					
						
							|  |  |  |   ) => Promise<Array<SearchResultMessageType>>; | 
					
						
							| 
									
										
										
										
											2020-04-01 11:59:11 -07:00
										 |  |  |   updateConversation: (data: ConversationType) => Promise<void>; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   // For testing only
 | 
					
						
							|  |  |  |   _getAllMessages: () => Promise<Array<MessageType>>; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   // Server-only
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-09-16 14:54:06 -07:00
										 |  |  |   initialize: (options: { | 
					
						
							|  |  |  |     configDir: string; | 
					
						
							|  |  |  |     key: string; | 
					
						
							|  |  |  |     logger: LoggerType; | 
					
						
							|  |  |  |   }) => Promise<void>; | 
					
						
							| 
									
										
										
										
											2021-03-04 16:44:57 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  |   initializeRenderer: (options: { | 
					
						
							|  |  |  |     configDir: string; | 
					
						
							|  |  |  |     key: string; | 
					
						
							|  |  |  |   }) => Promise<void>; | 
					
						
							| 
									
										
										
										
											2020-04-01 11:59:11 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  |   removeKnownAttachments: ( | 
					
						
							|  |  |  |     allAttachments: Array<string> | 
					
						
							|  |  |  |   ) => Promise<Array<string>>; | 
					
						
							|  |  |  |   removeKnownStickers: (allStickers: Array<string>) => Promise<Array<string>>; | 
					
						
							|  |  |  |   removeKnownDraftAttachments: ( | 
					
						
							|  |  |  |     allStickers: Array<string> | 
					
						
							|  |  |  |   ) => Promise<Array<string>>; | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | export type ClientInterface = DataInterface & { | 
					
						
							| 
									
										
										
										
											2021-01-12 16:42:15 -08:00
										 |  |  |   getAllConversations: (options: { | 
					
						
							| 
									
										
										
										
											2020-07-10 11:28:49 -07:00
										 |  |  |     ConversationCollection: typeof ConversationModelCollectionType; | 
					
						
							|  |  |  |   }) => Promise<ConversationModelCollectionType>; | 
					
						
							| 
									
										
										
										
											2020-04-01 11:59:11 -07:00
										 |  |  |   getAllGroupsInvolvingId: ( | 
					
						
							|  |  |  |     id: string, | 
					
						
							| 
									
										
										
										
											2021-01-12 16:42:15 -08:00
										 |  |  |     options: { | 
					
						
							| 
									
										
										
										
											2020-07-10 11:28:49 -07:00
										 |  |  |       ConversationCollection: typeof ConversationModelCollectionType; | 
					
						
							| 
									
										
										
										
											2020-04-01 11:59:11 -07:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2020-07-10 11:28:49 -07:00
										 |  |  |   ) => Promise<ConversationModelCollectionType>; | 
					
						
							| 
									
										
										
										
											2021-01-12 16:42:15 -08:00
										 |  |  |   getAllPrivateConversations: (options: { | 
					
						
							| 
									
										
										
										
											2020-07-10 11:28:49 -07:00
										 |  |  |     ConversationCollection: typeof ConversationModelCollectionType; | 
					
						
							|  |  |  |   }) => Promise<ConversationModelCollectionType>; | 
					
						
							| 
									
										
										
										
											2020-04-01 11:59:11 -07:00
										 |  |  |   getConversationById: ( | 
					
						
							|  |  |  |     id: string, | 
					
						
							| 
									
										
										
										
											2021-01-12 16:42:15 -08:00
										 |  |  |     options: { Conversation: typeof ConversationModel } | 
					
						
							| 
									
										
										
										
											2021-04-06 15:54:47 -07:00
										 |  |  |   ) => Promise<ConversationModel | undefined>; | 
					
						
							| 
									
										
										
										
											2021-01-12 16:42:15 -08:00
										 |  |  |   getExpiredMessages: (options: { | 
					
						
							| 
									
										
										
										
											2020-07-10 11:28:49 -07:00
										 |  |  |     MessageCollection: typeof MessageModelCollectionType; | 
					
						
							|  |  |  |   }) => Promise<MessageModelCollectionType>; | 
					
						
							| 
									
										
										
										
											2020-04-01 11:59:11 -07:00
										 |  |  |   getMessageById: ( | 
					
						
							|  |  |  |     id: string, | 
					
						
							| 
									
										
										
										
											2021-01-12 16:42:15 -08:00
										 |  |  |     options: { Message: typeof MessageModel } | 
					
						
							| 
									
										
										
										
											2021-04-05 15:18:19 -07:00
										 |  |  |   ) => Promise<MessageModel | undefined>; | 
					
						
							| 
									
										
										
										
											2020-04-01 11:59:11 -07:00
										 |  |  |   getMessageBySender: ( | 
					
						
							| 
									
										
										
										
											2021-01-12 16:42:15 -08:00
										 |  |  |     data: { | 
					
						
							| 
									
										
										
										
											2020-04-01 11:59:11 -07:00
										 |  |  |       source: string; | 
					
						
							|  |  |  |       sourceUuid: string; | 
					
						
							| 
									
										
										
										
											2021-08-02 14:55:31 -07:00
										 |  |  |       sourceDevice: number; | 
					
						
							| 
									
										
										
										
											2020-04-01 11:59:11 -07:00
										 |  |  |       sent_at: number; | 
					
						
							|  |  |  |     }, | 
					
						
							| 
									
										
										
										
											2021-01-12 16:42:15 -08:00
										 |  |  |     options: { Message: typeof MessageModel } | 
					
						
							| 
									
										
										
										
											2020-09-24 13:57:54 -07:00
										 |  |  |   ) => Promise<MessageModel | null>; | 
					
						
							| 
									
										
										
										
											2020-04-01 11:59:11 -07:00
										 |  |  |   getMessagesBySentAt: ( | 
					
						
							|  |  |  |     sentAt: number, | 
					
						
							| 
									
										
										
										
											2021-01-12 16:42:15 -08:00
										 |  |  |     options: { MessageCollection: typeof MessageModelCollectionType } | 
					
						
							| 
									
										
										
										
											2020-07-10 11:28:49 -07:00
										 |  |  |   ) => Promise<MessageModelCollectionType>; | 
					
						
							| 
									
										
										
										
											2020-04-01 11:59:11 -07:00
										 |  |  |   getOlderMessagesByConversation: ( | 
					
						
							|  |  |  |     conversationId: string, | 
					
						
							|  |  |  |     options: { | 
					
						
							|  |  |  |       limit?: number; | 
					
						
							| 
									
										
										
										
											2020-09-24 13:57:54 -07:00
										 |  |  |       messageId?: string; | 
					
						
							| 
									
										
										
										
											2020-04-01 11:59:11 -07:00
										 |  |  |       receivedAt?: number; | 
					
						
							| 
									
										
										
										
											2021-01-13 08:32:18 -08:00
										 |  |  |       sentAt?: number; | 
					
						
							| 
									
										
										
										
											2020-07-10 11:28:49 -07:00
										 |  |  |       MessageCollection: typeof MessageModelCollectionType; | 
					
						
							| 
									
										
										
										
											2020-04-01 11:59:11 -07:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2020-07-10 11:28:49 -07:00
										 |  |  |   ) => Promise<MessageModelCollectionType>; | 
					
						
							| 
									
										
										
										
											2020-04-01 11:59:11 -07:00
										 |  |  |   getNewerMessagesByConversation: ( | 
					
						
							|  |  |  |     conversationId: string, | 
					
						
							|  |  |  |     options: { | 
					
						
							|  |  |  |       limit?: number; | 
					
						
							|  |  |  |       receivedAt?: number; | 
					
						
							| 
									
										
										
										
											2021-01-13 08:32:18 -08:00
										 |  |  |       sentAt?: number; | 
					
						
							| 
									
										
										
										
											2020-07-10 11:28:49 -07:00
										 |  |  |       MessageCollection: typeof MessageModelCollectionType; | 
					
						
							| 
									
										
										
										
											2020-04-01 11:59:11 -07:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2020-07-10 11:28:49 -07:00
										 |  |  |   ) => Promise<MessageModelCollectionType>; | 
					
						
							| 
									
										
										
										
											2021-08-16 09:56:27 -07:00
										 |  |  |   getLastConversationMessages: (options: { | 
					
						
							| 
									
										
										
										
											2021-01-20 09:31:44 -08:00
										 |  |  |     conversationId: string; | 
					
						
							|  |  |  |     ourConversationId: string; | 
					
						
							|  |  |  |     Message: typeof MessageModel; | 
					
						
							| 
									
										
										
										
											2021-08-16 09:56:27 -07:00
										 |  |  |   }) => Promise<LastConversationMessagesType>; | 
					
						
							| 
									
										
										
										
											2021-01-12 16:42:15 -08:00
										 |  |  |   getTapToViewMessagesNeedingErase: (options: { | 
					
						
							| 
									
										
										
										
											2020-07-10 11:28:49 -07:00
										 |  |  |     MessageCollection: typeof MessageModelCollectionType; | 
					
						
							|  |  |  |   }) => Promise<MessageModelCollectionType>; | 
					
						
							| 
									
										
										
										
											2020-04-01 11:59:11 -07:00
										 |  |  |   removeConversation: ( | 
					
						
							|  |  |  |     id: string, | 
					
						
							| 
									
										
										
										
											2021-01-12 16:42:15 -08:00
										 |  |  |     options: { Conversation: typeof ConversationModel } | 
					
						
							| 
									
										
										
										
											2020-04-01 11:59:11 -07:00
										 |  |  |   ) => Promise<void>; | 
					
						
							|  |  |  |   removeMessage: ( | 
					
						
							|  |  |  |     id: string, | 
					
						
							| 
									
										
										
										
											2021-01-12 16:42:15 -08:00
										 |  |  |     options: { Message: typeof MessageModel } | 
					
						
							|  |  |  |   ) => Promise<void>; | 
					
						
							|  |  |  |   removeMessages: ( | 
					
						
							|  |  |  |     ids: Array<string>, | 
					
						
							|  |  |  |     options: { Message: typeof MessageModel } | 
					
						
							| 
									
										
										
										
											2020-04-01 11:59:11 -07:00
										 |  |  |   ) => Promise<void>; | 
					
						
							| 
									
										
										
										
											2021-04-05 15:18:19 -07:00
										 |  |  |   searchMessages: ( | 
					
						
							|  |  |  |     query: string, | 
					
						
							|  |  |  |     options?: { limit?: number } | 
					
						
							|  |  |  |   ) => Promise<Array<ClientSearchResultMessageType>>; | 
					
						
							|  |  |  |   searchMessagesInConversation: ( | 
					
						
							|  |  |  |     query: string, | 
					
						
							|  |  |  |     conversationId: string, | 
					
						
							|  |  |  |     options?: { limit?: number } | 
					
						
							|  |  |  |   ) => Promise<Array<ClientSearchResultMessageType>>; | 
					
						
							| 
									
										
										
										
											2020-09-24 13:57:54 -07:00
										 |  |  |   updateConversation: (data: ConversationType, extra?: unknown) => void; | 
					
						
							| 
									
										
										
										
											2020-04-01 11:59:11 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  |   // Test-only
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-01-12 16:42:15 -08:00
										 |  |  |   _getAllMessages: (options: { | 
					
						
							| 
									
										
										
										
											2020-07-10 11:28:49 -07:00
										 |  |  |     MessageCollection: typeof MessageModelCollectionType; | 
					
						
							|  |  |  |   }) => Promise<MessageModelCollectionType>; | 
					
						
							| 
									
										
										
										
											2020-04-01 11:59:11 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  |   // Client-side only
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   shutdown: () => Promise<void>; | 
					
						
							|  |  |  |   removeAllMessagesInConversation: ( | 
					
						
							|  |  |  |     conversationId: string, | 
					
						
							| 
									
										
										
										
											2021-01-12 16:42:15 -08:00
										 |  |  |     options: { | 
					
						
							|  |  |  |       logId: string; | 
					
						
							|  |  |  |       MessageCollection: typeof MessageModelCollectionType; | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2020-04-01 11:59:11 -07:00
										 |  |  |   ) => Promise<void>; | 
					
						
							|  |  |  |   removeOtherData: () => Promise<void>; | 
					
						
							|  |  |  |   cleanupOrphanedAttachments: () => Promise<void>; | 
					
						
							|  |  |  |   ensureFilePermissions: () => Promise<void>; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   // Client-side only, and test-only
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   _removeConversations: (ids: Array<string>) => Promise<void>; | 
					
						
							| 
									
										
										
										
											2021-03-10 17:25:57 -05:00
										 |  |  |   _jobs: { [id: string]: ClientJobType }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   // These are defined on the server-only and used in the client to determine
 | 
					
						
							|  |  |  |   // whether we should use IPC to use the database in the main process or
 | 
					
						
							|  |  |  |   // use the db already running in the renderer.
 | 
					
						
							| 
									
										
										
										
											2021-05-19 15:01:32 -07:00
										 |  |  |   goBackToMainProcess: () => Promise<void>; | 
					
						
							| 
									
										
										
										
											2020-04-01 11:59:11 -07:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | export type ClientJobType = { | 
					
						
							|  |  |  |   fnName: string; | 
					
						
							|  |  |  |   start: number; | 
					
						
							|  |  |  |   resolve?: Function; | 
					
						
							|  |  |  |   reject?: Function; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   // Only in DEBUG mode
 | 
					
						
							|  |  |  |   complete?: boolean; | 
					
						
							|  |  |  |   args?: Array<any>; | 
					
						
							|  |  |  | }; |