Refactor: Move data-access code to Typescript w/ shared interface
This commit is contained in:
parent
9ab54b9b83
commit
6b094e1514
35 changed files with 1695 additions and 598 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -12,7 +12,7 @@ release/
|
||||||
/dev-app-update.yml
|
/dev-app-update.yml
|
||||||
.nyc_output/
|
.nyc_output/
|
||||||
*.sublime*
|
*.sublime*
|
||||||
sql/
|
/sql/
|
||||||
|
|
||||||
# generated files
|
# generated files
|
||||||
js/components.js
|
js/components.js
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
const electron = require('electron');
|
const electron = require('electron');
|
||||||
const Queue = require('p-queue').default;
|
const Queue = require('p-queue').default;
|
||||||
const sql = require('./sql');
|
const sql = require('../ts/sql/Server').default;
|
||||||
const { remove: removeUserConfig } = require('./user_config');
|
const { remove: removeUserConfig } = require('./user_config');
|
||||||
const { remove: removeEphemeralConfig } = require('./ephemeral_config');
|
const { remove: removeEphemeralConfig } = require('./ephemeral_config');
|
||||||
|
|
||||||
|
|
1
app/user_config.d.ts
vendored
Normal file
1
app/user_config.d.ts
vendored
Normal file
|
@ -0,0 +1 @@
|
||||||
|
export function remove(): void;
|
|
@ -1996,10 +1996,7 @@
|
||||||
conversation.set({ avatar: null });
|
conversation.set({ avatar: null });
|
||||||
}
|
}
|
||||||
|
|
||||||
window.Signal.Data.updateConversation(
|
window.Signal.Data.updateConversation(conversation.attributes);
|
||||||
details.number || details.uuid,
|
|
||||||
conversation.attributes
|
|
||||||
);
|
|
||||||
|
|
||||||
const { expireTimer } = details;
|
const { expireTimer } = details;
|
||||||
const isValidExpireTimer = typeof expireTimer === 'number';
|
const isValidExpireTimer = typeof expireTimer === 'number';
|
||||||
|
@ -2108,7 +2105,7 @@
|
||||||
conversation.set(newAttributes);
|
conversation.set(newAttributes);
|
||||||
}
|
}
|
||||||
|
|
||||||
window.Signal.Data.updateConversation(id, conversation.attributes);
|
window.Signal.Data.updateConversation(conversation.attributes);
|
||||||
|
|
||||||
const { appView } = window.owsDesktopApp;
|
const { appView } = window.owsDesktopApp;
|
||||||
if (appView && appView.installView && appView.installView.didLink) {
|
if (appView && appView.installView && appView.installView.didLink) {
|
||||||
|
@ -2240,7 +2237,7 @@
|
||||||
);
|
);
|
||||||
|
|
||||||
conversation.set({ profileSharing: true });
|
conversation.set({ profileSharing: true });
|
||||||
window.Signal.Data.updateConversation(id, conversation.attributes);
|
window.Signal.Data.updateConversation(conversation.attributes);
|
||||||
|
|
||||||
// Then we update our own profileKey if it's different from what we have
|
// Then we update our own profileKey if it's different from what we have
|
||||||
const ourNumber = textsecure.storage.user.getNumber();
|
const ourNumber = textsecure.storage.user.getNumber();
|
||||||
|
@ -2518,10 +2515,7 @@
|
||||||
ev.confirm();
|
ev.confirm();
|
||||||
}
|
}
|
||||||
|
|
||||||
window.Signal.Data.updateConversation(
|
window.Signal.Data.updateConversation(conversation.attributes);
|
||||||
conversationId,
|
|
||||||
conversation.attributes
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -240,10 +240,7 @@
|
||||||
this.model.set({
|
this.model.set({
|
||||||
draft: draft.slice(0, MAX_MESSAGE_BODY_LENGTH),
|
draft: draft.slice(0, MAX_MESSAGE_BODY_LENGTH),
|
||||||
});
|
});
|
||||||
window.Signal.Data.updateConversation(
|
window.Signal.Data.updateConversation(conversation.attributes);
|
||||||
conversation.id,
|
|
||||||
conversation.attributes
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
|
@ -60,16 +60,15 @@
|
||||||
let timeout;
|
let timeout;
|
||||||
async function checkExpiringMessages() {
|
async function checkExpiringMessages() {
|
||||||
// Look up the next expiring message and set a timer to destroy it
|
// Look up the next expiring message and set a timer to destroy it
|
||||||
const messages = await window.Signal.Data.getNextExpiringMessage({
|
const message = await window.Signal.Data.getNextExpiringMessage({
|
||||||
MessageCollection: Whisper.MessageCollection,
|
Message: Whisper.Message,
|
||||||
});
|
});
|
||||||
|
|
||||||
const next = messages.at(0);
|
if (!message) {
|
||||||
if (!next) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const expiresAt = next.get('expires_at');
|
const expiresAt = message.get('expires_at');
|
||||||
Whisper.ExpiringMessagesListener.nextExpiration = expiresAt;
|
Whisper.ExpiringMessagesListener.nextExpiration = expiresAt;
|
||||||
window.log.info('next message expires', new Date(expiresAt).toISOString());
|
window.log.info('next message expires', new Date(expiresAt).toISOString());
|
||||||
|
|
||||||
|
|
|
@ -424,7 +424,7 @@
|
||||||
const oldValue = this.get('e164');
|
const oldValue = this.get('e164');
|
||||||
if (e164 !== oldValue) {
|
if (e164 !== oldValue) {
|
||||||
this.set('e164', e164);
|
this.set('e164', e164);
|
||||||
window.Signal.Data.updateConversation(this.id, this.attributes);
|
window.Signal.Data.updateConversation(this.attributes);
|
||||||
this.trigger('idUpdated', this, 'e164', oldValue);
|
this.trigger('idUpdated', this, 'e164', oldValue);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -432,7 +432,7 @@
|
||||||
const oldValue = this.get('uuid');
|
const oldValue = this.get('uuid');
|
||||||
if (uuid !== oldValue) {
|
if (uuid !== oldValue) {
|
||||||
this.set('uuid', uuid);
|
this.set('uuid', uuid);
|
||||||
window.Signal.Data.updateConversation(this.id, this.attributes);
|
window.Signal.Data.updateConversation(this.attributes);
|
||||||
this.trigger('idUpdated', this, 'uuid', oldValue);
|
this.trigger('idUpdated', this, 'uuid', oldValue);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -440,7 +440,7 @@
|
||||||
const oldValue = this.get('groupId');
|
const oldValue = this.get('groupId');
|
||||||
if (groupId !== oldValue) {
|
if (groupId !== oldValue) {
|
||||||
this.set('groupId', groupId);
|
this.set('groupId', groupId);
|
||||||
window.Signal.Data.updateConversation(this.id, this.attributes);
|
window.Signal.Data.updateConversation(this.attributes);
|
||||||
this.trigger('idUpdated', this, 'groupId', oldValue);
|
this.trigger('idUpdated', this, 'groupId', oldValue);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -461,7 +461,7 @@
|
||||||
|
|
||||||
if (this.get('verified') !== verified) {
|
if (this.get('verified') !== verified) {
|
||||||
this.set({ verified });
|
this.set({ verified });
|
||||||
window.Signal.Data.updateConversation(this.id, this.attributes);
|
window.Signal.Data.updateConversation(this.attributes);
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
@ -525,7 +525,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
this.set({ verified });
|
this.set({ verified });
|
||||||
window.Signal.Data.updateConversation(this.id, this.attributes);
|
window.Signal.Data.updateConversation(this.attributes);
|
||||||
|
|
||||||
// Three situations result in a verification notice in the conversation:
|
// Three situations result in a verification notice in the conversation:
|
||||||
// 1) The message came from an explicit verification in another client (not
|
// 1) The message came from an explicit verification in another client (not
|
||||||
|
@ -1222,7 +1222,7 @@
|
||||||
draft: null,
|
draft: null,
|
||||||
draftTimestamp: null,
|
draftTimestamp: null,
|
||||||
});
|
});
|
||||||
window.Signal.Data.updateConversation(this.id, this.attributes);
|
window.Signal.Data.updateConversation(this.attributes);
|
||||||
|
|
||||||
// We're offline!
|
// We're offline!
|
||||||
if (!textsecure.messaging) {
|
if (!textsecure.messaging) {
|
||||||
|
@ -1354,10 +1354,7 @@
|
||||||
conversation.set({
|
conversation.set({
|
||||||
sealedSender: SEALED_SENDER.DISABLED,
|
sealedSender: SEALED_SENDER.DISABLED,
|
||||||
});
|
});
|
||||||
window.Signal.Data.updateConversation(
|
window.Signal.Data.updateConversation(conversation.attributes);
|
||||||
conversation.id,
|
|
||||||
conversation.attributes
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
@ -1385,10 +1382,7 @@
|
||||||
sealedSender: SEALED_SENDER.UNRESTRICTED,
|
sealedSender: SEALED_SENDER.UNRESTRICTED,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
window.Signal.Data.updateConversation(
|
window.Signal.Data.updateConversation(conversation.attributes);
|
||||||
conversation.id,
|
|
||||||
conversation.attributes
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
@ -1530,7 +1524,7 @@
|
||||||
this.set(lastMessageUpdate);
|
this.set(lastMessageUpdate);
|
||||||
|
|
||||||
if (this.hasChanged()) {
|
if (this.hasChanged()) {
|
||||||
window.Signal.Data.updateConversation(this.id, this.attributes, {
|
window.Signal.Data.updateConversation(this.attributes, {
|
||||||
Conversation: Whisper.Conversation,
|
Conversation: Whisper.Conversation,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -1538,7 +1532,7 @@
|
||||||
|
|
||||||
async setArchived(isArchived) {
|
async setArchived(isArchived) {
|
||||||
this.set({ isArchived });
|
this.set({ isArchived });
|
||||||
window.Signal.Data.updateConversation(this.id, this.attributes);
|
window.Signal.Data.updateConversation(this.attributes);
|
||||||
},
|
},
|
||||||
|
|
||||||
async updateExpirationTimer(
|
async updateExpirationTimer(
|
||||||
|
@ -1581,7 +1575,7 @@
|
||||||
const timestamp = (receivedAt || Date.now()) - 1;
|
const timestamp = (receivedAt || Date.now()) - 1;
|
||||||
|
|
||||||
this.set({ expireTimer });
|
this.set({ expireTimer });
|
||||||
window.Signal.Data.updateConversation(this.id, this.attributes);
|
window.Signal.Data.updateConversation(this.attributes);
|
||||||
|
|
||||||
const model = new Whisper.Message({
|
const model = new Whisper.Message({
|
||||||
// Even though this isn't reflected to the user, we want to place the last seen
|
// Even though this isn't reflected to the user, we want to place the last seen
|
||||||
|
@ -1787,7 +1781,7 @@
|
||||||
if (this.get('type') === 'group') {
|
if (this.get('type') === 'group') {
|
||||||
const groupNumbers = this.getRecipients();
|
const groupNumbers = this.getRecipients();
|
||||||
this.set({ left: true });
|
this.set({ left: true });
|
||||||
window.Signal.Data.updateConversation(this.id, this.attributes);
|
window.Signal.Data.updateConversation(this.attributes);
|
||||||
|
|
||||||
const model = new Whisper.Message({
|
const model = new Whisper.Message({
|
||||||
group_update: { left: 'You' },
|
group_update: { left: 'You' },
|
||||||
|
@ -1852,7 +1846,7 @@
|
||||||
|
|
||||||
const unreadCount = unreadMessages.length - read.length;
|
const unreadCount = unreadMessages.length - read.length;
|
||||||
this.set({ unreadCount });
|
this.set({ unreadCount });
|
||||||
window.Signal.Data.updateConversation(this.id, this.attributes);
|
window.Signal.Data.updateConversation(this.attributes);
|
||||||
|
|
||||||
// If a message has errors, we don't want to send anything out about it.
|
// If a message has errors, we don't want to send anything out about it.
|
||||||
// read syncs - let's wait for a client that really understands the message
|
// read syncs - let's wait for a client that really understands the message
|
||||||
|
@ -2055,7 +2049,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
if (c.hasChanged()) {
|
if (c.hasChanged()) {
|
||||||
window.Signal.Data.updateConversation(id, c.attributes);
|
window.Signal.Data.updateConversation(c.attributes);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
async setProfileName(encryptedName) {
|
async setProfileName(encryptedName) {
|
||||||
|
@ -2135,7 +2129,7 @@
|
||||||
|
|
||||||
await this.deriveAccessKeyIfNeeded();
|
await this.deriveAccessKeyIfNeeded();
|
||||||
|
|
||||||
window.Signal.Data.updateConversation(this.id, this.attributes, {
|
window.Signal.Data.updateConversation(this.attributes, {
|
||||||
Conversation: Whisper.Conversation,
|
Conversation: Whisper.Conversation,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -2159,7 +2153,7 @@
|
||||||
sealedSender: SEALED_SENDER.UNKNOWN,
|
sealedSender: SEALED_SENDER.UNKNOWN,
|
||||||
});
|
});
|
||||||
|
|
||||||
window.Signal.Data.updateConversation(this.id, this.attributes);
|
window.Signal.Data.updateConversation(this.attributes);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -2219,7 +2213,7 @@
|
||||||
timestamp: null,
|
timestamp: null,
|
||||||
active_at: null,
|
active_at: null,
|
||||||
});
|
});
|
||||||
window.Signal.Data.updateConversation(this.id, this.attributes);
|
window.Signal.Data.updateConversation(this.attributes);
|
||||||
|
|
||||||
await window.Signal.Data.removeAllMessagesInConversation(this.id, {
|
await window.Signal.Data.removeAllMessagesInConversation(this.id, {
|
||||||
MessageCollection: Whisper.MessageCollection,
|
MessageCollection: Whisper.MessageCollection,
|
||||||
|
|
|
@ -2437,10 +2437,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
MessageController.register(message.id, message);
|
MessageController.register(message.id, message);
|
||||||
window.Signal.Data.updateConversation(
|
window.Signal.Data.updateConversation(conversation.attributes);
|
||||||
conversationId,
|
|
||||||
conversation.attributes
|
|
||||||
);
|
|
||||||
|
|
||||||
await message.queueAttachmentDownloads();
|
await message.queueAttachmentDownloads();
|
||||||
await window.Signal.Data.saveMessage(message.attributes, {
|
await window.Signal.Data.saveMessage(message.attributes, {
|
||||||
|
|
|
@ -18,7 +18,7 @@ const {
|
||||||
saveAttachmentDownloadJob,
|
saveAttachmentDownloadJob,
|
||||||
saveMessage,
|
saveMessage,
|
||||||
setAttachmentDownloadJobPending,
|
setAttachmentDownloadJobPending,
|
||||||
} = require('./data');
|
} = require('../../ts/sql/Client').default;
|
||||||
const { stringFromBytes } = require('../../ts/Crypto');
|
const { stringFromBytes } = require('../../ts/Crypto');
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
|
@ -445,7 +445,7 @@ async function _addAttachmentToMessage(message, attachment, { type, index }) {
|
||||||
hash,
|
hash,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
Signal.Data.updateConversation(conversationId, conversation.attributes);
|
Signal.Data.updateConversation(conversation.attributes);
|
||||||
|
|
||||||
message.set({
|
message.set({
|
||||||
group_update: {
|
group_update: {
|
||||||
|
|
|
@ -50,7 +50,7 @@ exports.createConversation = async ({
|
||||||
unread: numMessages,
|
unread: numMessages,
|
||||||
});
|
});
|
||||||
const conversationId = conversation.get('id');
|
const conversationId = conversation.get('id');
|
||||||
Signal.Data.updateConversation(conversationId, conversation.attributes);
|
Signal.Data.updateConversation(conversation.attributes);
|
||||||
|
|
||||||
await Promise.all(
|
await Promise.all(
|
||||||
range(0, numMessages).map(async index => {
|
range(0, numMessages).map(async index => {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
const { take } = require('lodash');
|
const { take } = require('lodash');
|
||||||
const { getRecentEmojis } = require('./data');
|
const { getRecentEmojis } = require('../../ts/sql/Client').default;
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
getInitialState,
|
getInitialState,
|
||||||
|
|
|
@ -22,7 +22,7 @@ const {
|
||||||
|
|
||||||
saveConversations,
|
saveConversations,
|
||||||
_removeConversations,
|
_removeConversations,
|
||||||
} = require('./data');
|
} = require('../../ts/sql/Client').default;
|
||||||
const {
|
const {
|
||||||
getMessageExportLastIndex,
|
getMessageExportLastIndex,
|
||||||
setMessageExportLastIndex,
|
setMessageExportLastIndex,
|
||||||
|
|
1
js/modules/privacy.d.ts
vendored
Normal file
1
js/modules/privacy.d.ts
vendored
Normal file
|
@ -0,0 +1 @@
|
||||||
|
export function redactAll(log: string): string;
|
|
@ -3,7 +3,7 @@
|
||||||
const { bindActionCreators } = require('redux');
|
const { bindActionCreators } = require('redux');
|
||||||
const Backbone = require('../../ts/backbone');
|
const Backbone = require('../../ts/backbone');
|
||||||
const Crypto = require('../../ts/Crypto');
|
const Crypto = require('../../ts/Crypto');
|
||||||
const Data = require('./data');
|
const Data = require('../../ts/sql/Client').default;
|
||||||
const Database = require('./database');
|
const Database = require('./database');
|
||||||
const Emojis = require('./emojis');
|
const Emojis = require('./emojis');
|
||||||
const EmojiLib = require('../../ts/components/emoji/lib');
|
const EmojiLib = require('../../ts/components/emoji/lib');
|
||||||
|
|
|
@ -47,7 +47,7 @@ const {
|
||||||
getAllStickers,
|
getAllStickers,
|
||||||
getRecentStickers,
|
getRecentStickers,
|
||||||
updateStickerPackStatus,
|
updateStickerPackStatus,
|
||||||
} = require('./data');
|
} = require('../../ts/sql/Client').default;
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
BLESSED_PACKS,
|
BLESSED_PACKS,
|
||||||
|
|
1
js/modules/types/message.d.ts
vendored
Normal file
1
js/modules/types/message.d.ts
vendored
Normal file
|
@ -0,0 +1 @@
|
||||||
|
export const CURRENT_SCHEMA_VERSION: number;
|
|
@ -431,7 +431,7 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
await window.Signal.Data.removeSessionsById(identifier);
|
await window.Signal.Data.removeSessionsByConversation(identifier);
|
||||||
},
|
},
|
||||||
async archiveSiblingSessions(identifier) {
|
async archiveSiblingSessions(identifier) {
|
||||||
const address = libsignal.SignalProtocolAddress.fromString(identifier);
|
const address = libsignal.SignalProtocolAddress.fromString(identifier);
|
||||||
|
|
|
@ -1123,13 +1123,7 @@
|
||||||
},
|
},
|
||||||
|
|
||||||
async saveModel() {
|
async saveModel() {
|
||||||
window.Signal.Data.updateConversation(
|
window.Signal.Data.updateConversation(this.model.attributes);
|
||||||
this.model.id,
|
|
||||||
this.model.attributes,
|
|
||||||
{
|
|
||||||
Conversation: Whisper.Conversation,
|
|
||||||
}
|
|
||||||
);
|
|
||||||
},
|
},
|
||||||
|
|
||||||
async addAttachment(attachment) {
|
async addAttachment(attachment) {
|
||||||
|
|
2
main.js
2
main.js
|
@ -87,7 +87,7 @@ const createTrayIcon = require('./app/tray_icon');
|
||||||
const dockIcon = require('./app/dock_icon');
|
const dockIcon = require('./app/dock_icon');
|
||||||
const ephemeralConfig = require('./app/ephemeral_config');
|
const ephemeralConfig = require('./app/ephemeral_config');
|
||||||
const logging = require('./app/logging');
|
const logging = require('./app/logging');
|
||||||
const sql = require('./app/sql');
|
const sql = require('./ts/sql/Server').default;
|
||||||
const sqlChannels = require('./app/sql_channel');
|
const sqlChannels = require('./app/sql_channel');
|
||||||
const windowState = require('./app/window_state');
|
const windowState = require('./app/window_state');
|
||||||
const { createTemplate } = require('./app/menu');
|
const { createTemplate } = require('./app/menu');
|
||||||
|
|
|
@ -570,7 +570,7 @@ describe('Backup', () => {
|
||||||
);
|
);
|
||||||
|
|
||||||
console.log('Backup test: Check messages');
|
console.log('Backup test: Check messages');
|
||||||
const messageCollection = await window.Signal.Data.getAllMessages({
|
const messageCollection = await window.Signal.Data._getAllMessages({
|
||||||
MessageCollection: Whisper.MessageCollection,
|
MessageCollection: Whisper.MessageCollection,
|
||||||
});
|
});
|
||||||
assert.strictEqual(messageCollection.length, MESSAGE_COUNT);
|
assert.strictEqual(messageCollection.length, MESSAGE_COUNT);
|
||||||
|
|
File diff suppressed because it is too large
Load diff
382
ts/sql/Interface.ts
Normal file
382
ts/sql/Interface.ts
Normal file
|
@ -0,0 +1,382 @@
|
||||||
|
import { LocaleMessagesType } from '../types/I18N';
|
||||||
|
|
||||||
|
export type AttachmentDownloadJobType = any;
|
||||||
|
export type ConverationMetricsType = any;
|
||||||
|
export type ConversationType = any;
|
||||||
|
export type EmojiType = any;
|
||||||
|
export type IdentityKeyType = any;
|
||||||
|
export type ItemType = any;
|
||||||
|
export type MessageType = any;
|
||||||
|
export type MessageTypeUnhydrated = any;
|
||||||
|
export type PreKeyType = any;
|
||||||
|
export type SearchResultMessageType = any;
|
||||||
|
export type SessionType = any;
|
||||||
|
export type SignedPreKeyType = any;
|
||||||
|
export type StickerPackStatusType = string;
|
||||||
|
export type StickerPackType = any;
|
||||||
|
export type StickerType = any;
|
||||||
|
export type UnprocessedType = any;
|
||||||
|
|
||||||
|
export type BackboneConversationModelType = any;
|
||||||
|
export type BackboneConversationCollectionType = any;
|
||||||
|
export type BackboneMessageModelType = any;
|
||||||
|
export type BackboneMessageCollectionType = any;
|
||||||
|
|
||||||
|
export interface DataInterface {
|
||||||
|
close: () => Promise<void>;
|
||||||
|
removeDB: () => Promise<void>;
|
||||||
|
removeIndexedDBFiles: () => Promise<void>;
|
||||||
|
|
||||||
|
createOrUpdateIdentityKey: (data: IdentityKeyType) => Promise<void>;
|
||||||
|
getIdentityKeyById: (id: string) => Promise<IdentityKeyType | undefined>;
|
||||||
|
bulkAddIdentityKeys: (array: Array<IdentityKeyType>) => Promise<void>;
|
||||||
|
removeIdentityKeyById: (id: string) => Promise<void>;
|
||||||
|
removeAllIdentityKeys: () => Promise<void>;
|
||||||
|
getAllIdentityKeys: () => Promise<Array<IdentityKeyType>>;
|
||||||
|
|
||||||
|
createOrUpdatePreKey: (data: PreKeyType) => Promise<void>;
|
||||||
|
getPreKeyById: (id: number) => Promise<PreKeyType | undefined>;
|
||||||
|
bulkAddPreKeys: (array: Array<PreKeyType>) => Promise<void>;
|
||||||
|
removePreKeyById: (id: number) => Promise<void>;
|
||||||
|
removeAllPreKeys: () => Promise<void>;
|
||||||
|
getAllPreKeys: () => Promise<Array<PreKeyType>>;
|
||||||
|
|
||||||
|
createOrUpdateSignedPreKey: (data: SignedPreKeyType) => Promise<void>;
|
||||||
|
getSignedPreKeyById: (id: number) => Promise<SignedPreKeyType | undefined>;
|
||||||
|
bulkAddSignedPreKeys: (array: Array<SignedPreKeyType>) => Promise<void>;
|
||||||
|
removeSignedPreKeyById: (id: number) => Promise<void>;
|
||||||
|
removeAllSignedPreKeys: () => Promise<void>;
|
||||||
|
getAllSignedPreKeys: () => Promise<Array<SignedPreKeyType>>;
|
||||||
|
|
||||||
|
createOrUpdateItem: (data: ItemType) => Promise<void>;
|
||||||
|
getItemById: (id: string) => Promise<ItemType | undefined>;
|
||||||
|
bulkAddItems: (array: Array<ItemType>) => Promise<void>;
|
||||||
|
removeItemById: (id: string) => Promise<void>;
|
||||||
|
removeAllItems: () => Promise<void>;
|
||||||
|
getAllItems: () => Promise<Array<ItemType>>;
|
||||||
|
|
||||||
|
createOrUpdateSession: (data: SessionType) => Promise<void>;
|
||||||
|
createOrUpdateSessions: (array: Array<SessionType>) => Promise<void>;
|
||||||
|
getSessionById: (id: string) => Promise<SessionType | undefined>;
|
||||||
|
getSessionsById: (conversationId: string) => Promise<Array<SessionType>>;
|
||||||
|
bulkAddSessions: (array: Array<SessionType>) => Promise<void>;
|
||||||
|
removeSessionById: (id: string) => Promise<void>;
|
||||||
|
removeSessionsByConversation: (conversationId: string) => Promise<void>;
|
||||||
|
removeAllSessions: () => Promise<void>;
|
||||||
|
getAllSessions: () => Promise<Array<SessionType>>;
|
||||||
|
|
||||||
|
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>>;
|
||||||
|
searchMessages: (
|
||||||
|
query: string,
|
||||||
|
options?: { limit?: number }
|
||||||
|
) => Promise<Array<SearchResultMessageType>>;
|
||||||
|
searchMessagesInConversation: (
|
||||||
|
query: string,
|
||||||
|
conversationId: string,
|
||||||
|
options?: { limit?: number }
|
||||||
|
) => Promise<Array<SearchResultMessageType>>;
|
||||||
|
|
||||||
|
getMessageCount: () => Promise<number>;
|
||||||
|
saveMessages: (
|
||||||
|
arrayOfMessages: Array<MessageType>,
|
||||||
|
options: { forceSave?: boolean }
|
||||||
|
) => Promise<void>;
|
||||||
|
getAllMessageIds: () => Promise<Array<string>>;
|
||||||
|
getMessageMetricsForConversation: (
|
||||||
|
conversationId: string
|
||||||
|
) => Promise<ConverationMetricsType>;
|
||||||
|
|
||||||
|
getUnprocessedCount: () => Promise<number>;
|
||||||
|
getAllUnprocessed: () => Promise<Array<UnprocessedType>>;
|
||||||
|
saveUnprocessed: (
|
||||||
|
data: UnprocessedType,
|
||||||
|
options?: { forceSave?: boolean }
|
||||||
|
) => Promise<number>;
|
||||||
|
updateUnprocessedAttempts: (id: string, attempts: number) => Promise<void>;
|
||||||
|
updateUnprocessedWithData: (
|
||||||
|
id: string,
|
||||||
|
data: UnprocessedType
|
||||||
|
) => Promise<void>;
|
||||||
|
updateUnprocessedsWithData: (array: Array<UnprocessedType>) => Promise<void>;
|
||||||
|
getUnprocessedById: (id: string) => Promise<UnprocessedType | undefined>;
|
||||||
|
saveUnprocesseds: (
|
||||||
|
arrayOfUnprocessed: Array<UnprocessedType>,
|
||||||
|
options?: { forceSave?: boolean }
|
||||||
|
) => Promise<void>;
|
||||||
|
removeUnprocessed: (id: string) => Promise<void>;
|
||||||
|
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
|
||||||
|
) => Promise<Array<string>>;
|
||||||
|
getStickerCount: () => Promise<number>;
|
||||||
|
deleteStickerPack: (packId: string) => Promise<Array<string>>;
|
||||||
|
getAllStickerPacks: () => Promise<Array<StickerPackType>>;
|
||||||
|
getAllStickers: () => Promise<Array<StickerType>>;
|
||||||
|
getRecentStickers: (options?: {
|
||||||
|
limit?: number;
|
||||||
|
}) => Promise<Array<StickerType>>;
|
||||||
|
|
||||||
|
updateEmojiUsage: (shortName: string, timeUsed?: number) => Promise<void>;
|
||||||
|
getRecentEmojis: (limit?: number) => Promise<Array<EmojiType>>;
|
||||||
|
|
||||||
|
removeAll: () => Promise<void>;
|
||||||
|
removeAllConfiguration: () => Promise<void>;
|
||||||
|
|
||||||
|
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>>;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 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>>;
|
||||||
|
getConversationById: (id: string) => Promise<ConversationType>;
|
||||||
|
getExpiredMessages: () => Promise<Array<MessageType>>;
|
||||||
|
getMessageById: (id: string) => Promise<MessageType | undefined>;
|
||||||
|
getMessageBySender: (options: {
|
||||||
|
source: string;
|
||||||
|
sourceUuid: string;
|
||||||
|
sourceDevice: string;
|
||||||
|
sent_at: number;
|
||||||
|
}) => Promise<Array<MessageType>>;
|
||||||
|
getMessagesBySentAt: (sentAt: number) => Promise<Array<MessageType>>;
|
||||||
|
getOlderMessagesByConversation: (
|
||||||
|
conversationId: string,
|
||||||
|
options?: { limit?: number; receivedAt?: number }
|
||||||
|
) => Promise<Array<MessageTypeUnhydrated>>;
|
||||||
|
getNewerMessagesByConversation: (
|
||||||
|
conversationId: string,
|
||||||
|
options?: { limit?: number; receivedAt?: number }
|
||||||
|
) => Promise<Array<MessageTypeUnhydrated>>;
|
||||||
|
getNextExpiringMessage: () => Promise<MessageType>;
|
||||||
|
getNextTapToViewMessageToAgeOut: () => Promise<MessageType>;
|
||||||
|
getOutgoingWithoutExpiresAt: () => Promise<Array<MessageType>>;
|
||||||
|
getTapToViewMessagesNeedingErase: () => Promise<Array<MessageType>>;
|
||||||
|
getUnreadByConversation: (
|
||||||
|
conversationId: string
|
||||||
|
) => Promise<Array<MessageType>>;
|
||||||
|
removeConversation: (id: Array<string> | string) => Promise<void>;
|
||||||
|
removeMessage: (id: Array<string> | string) => Promise<void>;
|
||||||
|
saveMessage: (
|
||||||
|
data: MessageType,
|
||||||
|
options: { forceSave?: boolean }
|
||||||
|
) => Promise<number>;
|
||||||
|
updateConversation: (data: ConversationType) => Promise<void>;
|
||||||
|
|
||||||
|
// For testing only
|
||||||
|
_getAllMessages: () => Promise<Array<MessageType>>;
|
||||||
|
|
||||||
|
// Server-only
|
||||||
|
|
||||||
|
initialize: (options: {
|
||||||
|
configDir: string;
|
||||||
|
key: string;
|
||||||
|
messages: LocaleMessagesType;
|
||||||
|
}) => Promise<boolean>;
|
||||||
|
|
||||||
|
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 & {
|
||||||
|
getAllConversations: ({
|
||||||
|
ConversationCollection,
|
||||||
|
}: {
|
||||||
|
ConversationCollection: BackboneConversationCollectionType;
|
||||||
|
}) => Promise<Array<ConversationType>>;
|
||||||
|
getAllGroupsInvolvingId: (
|
||||||
|
id: string,
|
||||||
|
{
|
||||||
|
ConversationCollection,
|
||||||
|
}: {
|
||||||
|
ConversationCollection: BackboneConversationCollectionType;
|
||||||
|
}
|
||||||
|
) => Promise<Array<ConversationType>>;
|
||||||
|
getAllPrivateConversations: ({
|
||||||
|
ConversationCollection,
|
||||||
|
}: {
|
||||||
|
ConversationCollection: BackboneConversationCollectionType;
|
||||||
|
}) => Promise<Array<ConversationType>>;
|
||||||
|
getConversationById: (
|
||||||
|
id: string,
|
||||||
|
{ Conversation }: { Conversation: BackboneConversationModelType }
|
||||||
|
) => Promise<ConversationType>;
|
||||||
|
getExpiredMessages: ({
|
||||||
|
MessageCollection,
|
||||||
|
}: {
|
||||||
|
MessageCollection: BackboneMessageCollectionType;
|
||||||
|
}) => Promise<Array<MessageType>>;
|
||||||
|
getMessageById: (
|
||||||
|
id: string,
|
||||||
|
{ Message }: { Message: BackboneMessageModelType }
|
||||||
|
) => Promise<MessageType | undefined>;
|
||||||
|
getMessageBySender: (
|
||||||
|
options: {
|
||||||
|
source: string;
|
||||||
|
sourceUuid: string;
|
||||||
|
sourceDevice: string;
|
||||||
|
sent_at: number;
|
||||||
|
},
|
||||||
|
{ Message }: { Message: BackboneMessageModelType }
|
||||||
|
) => Promise<Array<MessageType>>;
|
||||||
|
getMessagesBySentAt: (
|
||||||
|
sentAt: number,
|
||||||
|
{ MessageCollection }: { MessageCollection: BackboneMessageCollectionType }
|
||||||
|
) => Promise<Array<MessageType>>;
|
||||||
|
getOlderMessagesByConversation: (
|
||||||
|
conversationId: string,
|
||||||
|
options: {
|
||||||
|
limit?: number;
|
||||||
|
receivedAt?: number;
|
||||||
|
MessageCollection: BackboneMessageCollectionType;
|
||||||
|
}
|
||||||
|
) => Promise<Array<MessageTypeUnhydrated>>;
|
||||||
|
getNewerMessagesByConversation: (
|
||||||
|
conversationId: string,
|
||||||
|
options: {
|
||||||
|
limit?: number;
|
||||||
|
receivedAt?: number;
|
||||||
|
MessageCollection: BackboneMessageCollectionType;
|
||||||
|
}
|
||||||
|
) => Promise<Array<MessageTypeUnhydrated>>;
|
||||||
|
getNextExpiringMessage: ({
|
||||||
|
Message,
|
||||||
|
}: {
|
||||||
|
Message: BackboneMessageModelType;
|
||||||
|
}) => Promise<MessageType>;
|
||||||
|
getNextTapToViewMessageToAgeOut: ({
|
||||||
|
Message,
|
||||||
|
}: {
|
||||||
|
Message: BackboneMessageModelType;
|
||||||
|
}) => Promise<MessageType>;
|
||||||
|
getOutgoingWithoutExpiresAt: ({
|
||||||
|
MessageCollection,
|
||||||
|
}: {
|
||||||
|
MessageCollection: BackboneMessageCollectionType;
|
||||||
|
}) => Promise<Array<MessageType>>;
|
||||||
|
getTapToViewMessagesNeedingErase: ({
|
||||||
|
MessageCollection,
|
||||||
|
}: {
|
||||||
|
MessageCollection: BackboneMessageCollectionType;
|
||||||
|
}) => Promise<Array<MessageType>>;
|
||||||
|
getUnreadByConversation: (
|
||||||
|
conversationId: string,
|
||||||
|
{ MessageCollection }: { MessageCollection: BackboneMessageCollectionType }
|
||||||
|
) => Promise<Array<MessageType>>;
|
||||||
|
removeConversation: (
|
||||||
|
id: string,
|
||||||
|
{ Conversation }: { Conversation: BackboneConversationModelType }
|
||||||
|
) => Promise<void>;
|
||||||
|
removeMessage: (
|
||||||
|
id: string,
|
||||||
|
{ Message }: { Message: BackboneMessageModelType }
|
||||||
|
) => Promise<void>;
|
||||||
|
saveMessage: (
|
||||||
|
data: MessageType,
|
||||||
|
options: { forceSave?: boolean; Message: BackboneMessageModelType }
|
||||||
|
) => Promise<number>;
|
||||||
|
updateConversation: (data: ConversationType) => void;
|
||||||
|
|
||||||
|
// Test-only
|
||||||
|
|
||||||
|
_getAllMessages: ({
|
||||||
|
MessageCollection,
|
||||||
|
}: {
|
||||||
|
MessageCollection: BackboneMessageCollectionType;
|
||||||
|
}) => Promise<Array<MessageType>>;
|
||||||
|
|
||||||
|
// Client-side only
|
||||||
|
|
||||||
|
shutdown: () => Promise<void>;
|
||||||
|
removeAllMessagesInConversation: (
|
||||||
|
conversationId: string,
|
||||||
|
{ MessageCollection }: { MessageCollection: BackboneMessageCollectionType }
|
||||||
|
) => Promise<void>;
|
||||||
|
removeOtherData: () => Promise<void>;
|
||||||
|
cleanupOrphanedAttachments: () => Promise<void>;
|
||||||
|
ensureFilePermissions: () => Promise<void>;
|
||||||
|
|
||||||
|
getLegacyMessagesNeedingUpgrade: (
|
||||||
|
limit: number,
|
||||||
|
options: { maxVersion: number }
|
||||||
|
) => Promise<Array<MessageType>>;
|
||||||
|
saveLegacyMessage: (data: MessageType) => Promise<void>;
|
||||||
|
|
||||||
|
// Client-side only, and test-only
|
||||||
|
|
||||||
|
_removeConversations: (ids: Array<string>) => Promise<void>;
|
||||||
|
_removeMessages: (ids: Array<string>) => Promise<void>;
|
||||||
|
_cleanData: (data: any, path?: string) => any;
|
||||||
|
_jobs: { [id: string]: ClientJobType };
|
||||||
|
};
|
||||||
|
|
||||||
|
export type ClientJobType = {
|
||||||
|
fnName: string;
|
||||||
|
start: number;
|
||||||
|
resolve?: Function;
|
||||||
|
reject?: Function;
|
||||||
|
|
||||||
|
// Only in DEBUG mode
|
||||||
|
complete?: boolean;
|
||||||
|
args?: Array<any>;
|
||||||
|
};
|
File diff suppressed because it is too large
Load diff
181
ts/sqlcipher.d.ts
vendored
Normal file
181
ts/sqlcipher.d.ts
vendored
Normal file
|
@ -0,0 +1,181 @@
|
||||||
|
// Taken from:
|
||||||
|
// https://github.com/DefinitelyTyped/DefinitelyTyped/blob/8bf8aedba75ada257428c4846d2bc7d14e3b4be8/types/sqlite3/index.d.ts
|
||||||
|
|
||||||
|
declare module '@journeyapps/sqlcipher' {
|
||||||
|
// Type definitions for sqlite3 3.1
|
||||||
|
// Project: http://github.com/mapbox/node-sqlite3
|
||||||
|
// Definitions by: Nick Malaguti <https://github.com/nmalaguti>
|
||||||
|
// Sumant Manne <https://github.com/dpyro>
|
||||||
|
// Behind The Math <https://github.com/BehindTheMath>
|
||||||
|
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||||
|
|
||||||
|
/// <reference types="node" />
|
||||||
|
|
||||||
|
import events = require('events');
|
||||||
|
|
||||||
|
export const OPEN_READONLY: number;
|
||||||
|
export const OPEN_READWRITE: number;
|
||||||
|
export const OPEN_CREATE: number;
|
||||||
|
export const OPEN_SHAREDCACHE: number;
|
||||||
|
export const OPEN_PRIVATECACHE: number;
|
||||||
|
export const OPEN_URI: number;
|
||||||
|
|
||||||
|
export const cached: {
|
||||||
|
Database(
|
||||||
|
filename: string,
|
||||||
|
callback?: (this: Database, err: Error | null) => void
|
||||||
|
): Database;
|
||||||
|
Database(
|
||||||
|
filename: string,
|
||||||
|
mode?: number,
|
||||||
|
callback?: (this: Database, err: Error | null) => void
|
||||||
|
): Database;
|
||||||
|
};
|
||||||
|
|
||||||
|
export interface RunResult extends Statement {
|
||||||
|
lastID: number;
|
||||||
|
changes: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
export class Statement {
|
||||||
|
bind(callback?: (err: Error | null) => void): this;
|
||||||
|
bind(...params: any[]): this;
|
||||||
|
|
||||||
|
reset(callback?: (err: null) => void): this;
|
||||||
|
|
||||||
|
finalize(callback?: (err: Error) => void): Database;
|
||||||
|
|
||||||
|
run(callback?: (err: Error | null) => void): this;
|
||||||
|
run(
|
||||||
|
params: any,
|
||||||
|
callback?: (this: RunResult, err: Error | null) => void
|
||||||
|
): this;
|
||||||
|
run(...params: any[]): this;
|
||||||
|
|
||||||
|
get(callback?: (err: Error | null, row?: any) => void): this;
|
||||||
|
get(
|
||||||
|
params: any,
|
||||||
|
callback?: (this: RunResult, err: Error | null, row?: any) => void
|
||||||
|
): this;
|
||||||
|
get(...params: any[]): this;
|
||||||
|
|
||||||
|
all(callback?: (err: Error | null, rows: any[]) => void): this;
|
||||||
|
all(
|
||||||
|
params: any,
|
||||||
|
callback?: (this: RunResult, err: Error | null, rows: any[]) => void
|
||||||
|
): this;
|
||||||
|
all(...params: any[]): this;
|
||||||
|
|
||||||
|
each(
|
||||||
|
callback?: (err: Error | null, row: any) => void,
|
||||||
|
complete?: (err: Error | null, count: number) => void
|
||||||
|
): this;
|
||||||
|
each(
|
||||||
|
params: any,
|
||||||
|
callback?: (this: RunResult, err: Error | null, row: any) => void,
|
||||||
|
complete?: (err: Error | null, count: number) => void
|
||||||
|
): this;
|
||||||
|
each(...params: any[]): this;
|
||||||
|
}
|
||||||
|
|
||||||
|
export class Database extends events.EventEmitter {
|
||||||
|
constructor(filename: string, callback?: (err: Error | null) => void);
|
||||||
|
constructor(
|
||||||
|
filename: string,
|
||||||
|
mode?: number,
|
||||||
|
callback?: (err: Error | null) => void
|
||||||
|
);
|
||||||
|
|
||||||
|
close(callback?: (err: Error | null) => void): void;
|
||||||
|
|
||||||
|
run(
|
||||||
|
sql: string,
|
||||||
|
callback?: (this: RunResult, err: Error | null) => void
|
||||||
|
): this;
|
||||||
|
run(
|
||||||
|
sql: string,
|
||||||
|
params: any,
|
||||||
|
callback?: (this: RunResult, err: Error | null) => void
|
||||||
|
): this;
|
||||||
|
run(sql: string, ...params: any[]): this;
|
||||||
|
|
||||||
|
get(
|
||||||
|
sql: string,
|
||||||
|
callback?: (this: Statement, err: Error | null, row: any) => void
|
||||||
|
): this;
|
||||||
|
get(
|
||||||
|
sql: string,
|
||||||
|
params: any,
|
||||||
|
callback?: (this: Statement, err: Error | null, row: any) => void
|
||||||
|
): this;
|
||||||
|
get(sql: string, ...params: any[]): this;
|
||||||
|
|
||||||
|
all(
|
||||||
|
sql: string,
|
||||||
|
callback?: (this: Statement, err: Error | null, rows: any[]) => void
|
||||||
|
): this;
|
||||||
|
all(
|
||||||
|
sql: string,
|
||||||
|
params: any,
|
||||||
|
callback?: (this: Statement, err: Error | null, rows: any[]) => void
|
||||||
|
): this;
|
||||||
|
all(sql: string, ...params: any[]): this;
|
||||||
|
|
||||||
|
each(
|
||||||
|
sql: string,
|
||||||
|
callback?: (this: Statement, err: Error | null, row: any) => void,
|
||||||
|
complete?: (err: Error | null, count: number) => void
|
||||||
|
): this;
|
||||||
|
each(
|
||||||
|
sql: string,
|
||||||
|
params: any,
|
||||||
|
callback?: (this: Statement, err: Error | null, row: any) => void,
|
||||||
|
complete?: (err: Error | null, count: number) => void
|
||||||
|
): this;
|
||||||
|
each(sql: string, ...params: any[]): this;
|
||||||
|
|
||||||
|
exec(
|
||||||
|
sql: string,
|
||||||
|
callback?: (this: Statement, err: Error | null) => void
|
||||||
|
): this;
|
||||||
|
|
||||||
|
prepare(
|
||||||
|
sql: string,
|
||||||
|
callback?: (this: Statement, err: Error | null) => void
|
||||||
|
): Statement;
|
||||||
|
prepare(
|
||||||
|
sql: string,
|
||||||
|
params: any,
|
||||||
|
callback?: (this: Statement, err: Error | null) => void
|
||||||
|
): Statement;
|
||||||
|
prepare(sql: string, ...params: any[]): Statement;
|
||||||
|
|
||||||
|
serialize(callback?: () => void): void;
|
||||||
|
parallelize(callback?: () => void): void;
|
||||||
|
|
||||||
|
on(event: 'trace', listener: (sql: string) => void): this;
|
||||||
|
on(event: 'profile', listener: (sql: string, time: number) => void): this;
|
||||||
|
on(event: 'error', listener: (err: Error) => void): this;
|
||||||
|
on(event: 'open' | 'close', listener: () => void): this;
|
||||||
|
on(event: string, listener: (...args: any[]) => void): this;
|
||||||
|
|
||||||
|
configure(option: 'busyTimeout', value: number): void;
|
||||||
|
interrupt(): void;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function verbose(): sqlite3;
|
||||||
|
|
||||||
|
export interface sqlite3 {
|
||||||
|
OPEN_READONLY: number;
|
||||||
|
OPEN_READWRITE: number;
|
||||||
|
OPEN_CREATE: number;
|
||||||
|
OPEN_SHAREDCACHE: number;
|
||||||
|
OPEN_PRIVATECACHE: number;
|
||||||
|
OPEN_URI: number;
|
||||||
|
cached: typeof cached;
|
||||||
|
RunResult: RunResult;
|
||||||
|
Statement: typeof Statement;
|
||||||
|
Database: typeof Database;
|
||||||
|
verbose(): this;
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,6 +1,8 @@
|
||||||
import { take, uniq } from 'lodash';
|
import { take, uniq } from 'lodash';
|
||||||
import { EmojiPickDataType } from '../../components/emoji/EmojiPicker';
|
import { EmojiPickDataType } from '../../components/emoji/EmojiPicker';
|
||||||
import { updateEmojiUsage } from '../../../js/modules/data';
|
import dataInterface from '../../sql/Client';
|
||||||
|
|
||||||
|
const { updateEmojiUsage } = dataInterface;
|
||||||
|
|
||||||
// State
|
// State
|
||||||
|
|
||||||
|
|
|
@ -3,11 +3,7 @@ import { omit, reject } from 'lodash';
|
||||||
import { normalize } from '../../types/PhoneNumber';
|
import { normalize } from '../../types/PhoneNumber';
|
||||||
import { trigger } from '../../shims/events';
|
import { trigger } from '../../shims/events';
|
||||||
import { cleanSearchTerm } from '../../util/cleanSearchTerm';
|
import { cleanSearchTerm } from '../../util/cleanSearchTerm';
|
||||||
import {
|
import dataInterface from '../../sql/Client';
|
||||||
searchConversations as dataSearchConversations,
|
|
||||||
searchMessages as dataSearchMessages,
|
|
||||||
searchMessagesInConversation,
|
|
||||||
} from '../../../js/modules/data';
|
|
||||||
import { makeLookup } from '../../util/makeLookup';
|
import { makeLookup } from '../../util/makeLookup';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
|
@ -20,6 +16,12 @@ import {
|
||||||
ShowArchivedConversationsActionType,
|
ShowArchivedConversationsActionType,
|
||||||
} from './conversations';
|
} from './conversations';
|
||||||
|
|
||||||
|
const {
|
||||||
|
searchConversations: dataSearchConversations,
|
||||||
|
searchMessages: dataSearchMessages,
|
||||||
|
searchMessagesInConversation,
|
||||||
|
} = dataInterface;
|
||||||
|
|
||||||
// State
|
// State
|
||||||
|
|
||||||
export type MessageSearchResultType = MessageType & {
|
export type MessageSearchResultType = MessageType & {
|
||||||
|
|
|
@ -1,9 +1,5 @@
|
||||||
import { Dictionary, omit, reject } from 'lodash';
|
import { Dictionary, omit, reject } from 'lodash';
|
||||||
import {
|
import dataInterface from '../../sql/Client';
|
||||||
getRecentStickers,
|
|
||||||
updateStickerLastUsed,
|
|
||||||
updateStickerPackStatus,
|
|
||||||
} from '../../../js/modules/data';
|
|
||||||
import {
|
import {
|
||||||
downloadStickerPack as externalDownloadStickerPack,
|
downloadStickerPack as externalDownloadStickerPack,
|
||||||
maybeDeletePack,
|
maybeDeletePack,
|
||||||
|
@ -13,6 +9,12 @@ import { trigger } from '../../shims/events';
|
||||||
|
|
||||||
import { NoopActionType } from './noop';
|
import { NoopActionType } from './noop';
|
||||||
|
|
||||||
|
const {
|
||||||
|
getRecentStickers,
|
||||||
|
updateStickerLastUsed,
|
||||||
|
updateStickerPackStatus,
|
||||||
|
} = dataInterface;
|
||||||
|
|
||||||
// State
|
// State
|
||||||
|
|
||||||
export type StickerDBType = {
|
export type StickerDBType = {
|
||||||
|
|
11
ts/types/I18N.ts
Normal file
11
ts/types/I18N.ts
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
export type LocaleMessagesType = {
|
||||||
|
[key: string]: {
|
||||||
|
message: string;
|
||||||
|
description?: string;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
export type LocaleType = {
|
||||||
|
i18n: (key: string, placeholders: Array<string>) => string;
|
||||||
|
messages: LocaleMessagesType;
|
||||||
|
};
|
10
ts/types/Logging.ts
Normal file
10
ts/types/Logging.ts
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
type LogFunction = (...args: Array<any>) => void;
|
||||||
|
|
||||||
|
export type LoggerType = {
|
||||||
|
fatal: LogFunction;
|
||||||
|
error: LogFunction;
|
||||||
|
warn: LogFunction;
|
||||||
|
info: LogFunction;
|
||||||
|
debug: LogFunction;
|
||||||
|
trace: LogFunction;
|
||||||
|
};
|
|
@ -27,26 +27,8 @@ import { Dialogs } from '../types/Dialogs';
|
||||||
import * as packageJson from '../../package.json';
|
import * as packageJson from '../../package.json';
|
||||||
import { getSignatureFileName } from './signature';
|
import { getSignatureFileName } from './signature';
|
||||||
|
|
||||||
export type LocaleType = {
|
import { LocaleType } from '../types/I18N';
|
||||||
i18n: (key: string, placeholders: Array<string>) => string;
|
import { LoggerType } from '../types/Logging';
|
||||||
messages: {
|
|
||||||
[key: string]: {
|
|
||||||
message: string;
|
|
||||||
description?: string;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
type LogFunction = (...args: Array<any>) => void;
|
|
||||||
|
|
||||||
export type LoggerType = {
|
|
||||||
fatal: LogFunction;
|
|
||||||
error: LogFunction;
|
|
||||||
warn: LogFunction;
|
|
||||||
info: LogFunction;
|
|
||||||
debug: LogFunction;
|
|
||||||
trace: LogFunction;
|
|
||||||
};
|
|
||||||
|
|
||||||
const writeFile = pify(writeFileCallback);
|
const writeFile = pify(writeFileCallback);
|
||||||
const mkdirpPromise = pify(mkdirp);
|
const mkdirpPromise = pify(mkdirp);
|
||||||
|
|
|
@ -3,7 +3,8 @@ import { BrowserWindow } from 'electron';
|
||||||
|
|
||||||
import { start as startMacOS } from './macos';
|
import { start as startMacOS } from './macos';
|
||||||
import { start as startWindows } from './windows';
|
import { start as startWindows } from './windows';
|
||||||
import { LocaleType, LoggerType } from './common';
|
import { LocaleType } from '../types/I18N';
|
||||||
|
import { LoggerType } from '../types/Logging';
|
||||||
|
|
||||||
let initialized = false;
|
let initialized = false;
|
||||||
|
|
||||||
|
|
|
@ -15,11 +15,11 @@ import {
|
||||||
deleteTempDir,
|
deleteTempDir,
|
||||||
downloadUpdate,
|
downloadUpdate,
|
||||||
getPrintableError,
|
getPrintableError,
|
||||||
LocaleType,
|
|
||||||
LoggerType,
|
|
||||||
showCannotUpdateDialog,
|
showCannotUpdateDialog,
|
||||||
showUpdateDialog,
|
showUpdateDialog,
|
||||||
} from './common';
|
} from './common';
|
||||||
|
import { LocaleType } from '../types/I18N';
|
||||||
|
import { LoggerType } from '../types/Logging';
|
||||||
import { hexToBinary, verifySignature } from './signature';
|
import { hexToBinary, verifySignature } from './signature';
|
||||||
import { markShouldQuit } from '../../app/window_state';
|
import { markShouldQuit } from '../../app/window_state';
|
||||||
import { Dialogs } from '../types/Dialogs';
|
import { Dialogs } from '../types/Dialogs';
|
||||||
|
|
|
@ -12,11 +12,11 @@ import {
|
||||||
deleteTempDir,
|
deleteTempDir,
|
||||||
downloadUpdate,
|
downloadUpdate,
|
||||||
getPrintableError,
|
getPrintableError,
|
||||||
LocaleType,
|
|
||||||
LoggerType,
|
|
||||||
showCannotUpdateDialog,
|
showCannotUpdateDialog,
|
||||||
showUpdateDialog,
|
showUpdateDialog,
|
||||||
} from './common';
|
} from './common';
|
||||||
|
import { LocaleType } from '../types/I18N';
|
||||||
|
import { LoggerType } from '../types/Logging';
|
||||||
import { hexToBinary, verifySignature } from './signature';
|
import { hexToBinary, verifySignature } from './signature';
|
||||||
import { markShouldQuit } from '../../app/window_state';
|
import { markShouldQuit } from '../../app/window_state';
|
||||||
|
|
||||||
|
|
|
@ -172,7 +172,7 @@
|
||||||
"rule": "jQuery-load(",
|
"rule": "jQuery-load(",
|
||||||
"path": "js/conversation_controller.js",
|
"path": "js/conversation_controller.js",
|
||||||
"line": " this._initialPromise = load();",
|
"line": " this._initialPromise = load();",
|
||||||
"lineNumber": 260,
|
"lineNumber": 257,
|
||||||
"reasonCategory": "falseMatch",
|
"reasonCategory": "falseMatch",
|
||||||
"updated": "2020-03-24T20:06:31.391Z"
|
"updated": "2020-03-24T20:06:31.391Z"
|
||||||
},
|
},
|
||||||
|
|
10
ts/window.d.ts
vendored
10
ts/window.d.ts
vendored
|
@ -12,6 +12,7 @@ declare global {
|
||||||
warn: LoggerType;
|
warn: LoggerType;
|
||||||
error: LoggerType;
|
error: LoggerType;
|
||||||
};
|
};
|
||||||
|
restart: () => void;
|
||||||
storage: {
|
storage: {
|
||||||
put: (key: string, value: any) => void;
|
put: (key: string, value: any) => void;
|
||||||
remove: (key: string) => void;
|
remove: (key: string) => void;
|
||||||
|
@ -25,6 +26,7 @@ declare global {
|
||||||
}
|
}
|
||||||
|
|
||||||
export type ConversationControllerType = {
|
export type ConversationControllerType = {
|
||||||
|
getConversationId: (identifier: string) => string | null;
|
||||||
prepareForSend: (
|
prepareForSend: (
|
||||||
id: string,
|
id: string,
|
||||||
options: Object
|
options: Object
|
||||||
|
@ -95,4 +97,12 @@ export type WhisperType = {
|
||||||
events: {
|
events: {
|
||||||
trigger: (name: string, param1: any, param2: any) => void;
|
trigger: (name: string, param1: any, param2: any) => void;
|
||||||
};
|
};
|
||||||
|
Database: {
|
||||||
|
open: () => Promise<IDBDatabase>;
|
||||||
|
handleDOMException: (
|
||||||
|
context: string,
|
||||||
|
error: DOMException | null,
|
||||||
|
reject: Function
|
||||||
|
) => void;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Reference in a new issue