import { Login, ProfileEntity, defaultProfileEntity, ConfigEntity, defaultConfigEntity } from './entities'; import type { ArticleDetail, ArticleItem, ChannelItem, CardItem, CardProfile, CardDetail, ChannelSummary, ChannelDetail } from './items'; import type { Logging } from './logging'; export interface Store { init(): Promise; setLogin(login: Login): Promise; clearLogin(): Promise; getSeal(guid: string): Promise<{ publicKey: string; privateKey: string } | null>; setSeal(guid: string, seal: { publicKey: string; privateKey: string }): Promise; clearSeal(guid: string): Promise; setMarker(guid: string, value: string): Promise; clearMarker(guid: string, value: string): Promise; getMarkers(guid: string): Promise; getProfileRevision(guid: string): Promise; setProfileRevision(guid: string, revision: number): Promise; getProfileData(guid: string): Promise; setProfileData(guid: string, data: ProfileEntity): Promise; getSettingsRevision(guid: string): Promise; setSettingsRevision(guid: string, revision: number): Promise; getSettingsData(guid: string): Promise; setSettingsData(guid: string, data: ConfigEntity): Promise; getContactRevision(guid: string): Promise; setContactRevision(guid: string, revision: number): Promise; getContacts(guid: string): Promise<{ cardId: string; item: CardItem }[]>; addContactCard(guid: string, cardId: string, item: CardItem): Promise; removeContactCard(guid: string, cardId: string): Promise; setContactCardRevision(guid: string, cardId: string, revision: number): Promise; setContactCardProfile(guid: string, cardId: string, profile: CardProfile): Promise; setContactCardDetail(guid: string, cardId: string, detail: CardDetail): Promise; setContactCardOffsyncProfile(guid: string, cardId: string, revision: number): Promise; clearContactCardOffsyncProfile(guid: string, cardId: string): Promise; setContactCardOffsyncArticle(guid: string, cardId: string, revision: number): Promise; clearContactCardOffsyncArticle(guid: string, cardId: string): Promise; setContactCardOffsyncChannel(guid: string, cardId: string, revision: number): Promise; clearContactCardOffsyncChannel(guid: string, cardId: string): Promise; setContactCardProfileRevision(guid: string, cardId: string, revision: number): Promise; setContactCardArticleRevision(guid: string, cardId: string, revision: number): Promise; setContactCardChannelRevision(guid: string, cardId: string, revision: number): Promise; getContactCardArticles(guid: string): Promise<{ cardId: string; articleId: string; item: ArticleItem }[]>; addContactCardArticle(guid: string, cardId: string, articleId: string, item: ArticleItem): Promise; removeContactCardArticle(guid: string, cardId: string, articleId: string): Promise; setContactCardArticleDetail(guid: string, cardId: string, articleId: string, detail: ChannelDetail, unsealedData: string | null): Promise; setContactCardArticleUnsealed(guid: string, cardId: string, articleId: string, unsealedData: string | null): Promise; getContactCardChannels(guid: string): Promise<{ cardId: string; channelId: string; item: ChannelItem }[]>; addContactCardChannel(guid: string, cardId: string, channelId: string, item: ChannelItem): Promise; removeContactCardChannel(guid: string, cardId: string, channelId: string): Promise; setContactCardChannelDetail(guid: string, cardId: string, channelId: string, detail: ChannelDetail, unsealedData: string): Promise; setContactCardChannelSummary(guid: string, cardId: string, channelId: string, summary: ChannelSummary, unsealedData: string): Promise; setContactCardChannelUnsealedDetail(guid: string, cardId: string, channelId: string, data: string | null): Promise; setContactCardChannelUnsealedSummary(guid: string, cardId: string, channelId: string, data: string | null): Promise; setContactCardChannelTopicSyncRevision(guid: string, cardId: string, channelId: string, revision: number): Promise; setContactCardChannelTopicRemoteRevision(guid: string, cardId: string, channelId: string, revision: number): Promise; getContentRevision(guid: string): Promise; setContentRevision(guid: string, revision: number): Promise; addContentChannel(guid: string, channelId: string, item: ChannelItem): Promise; removeContentChannel(guid: string, channelId: string): Promise; getContentChannels(guid: string): Promise<{ channelId: string; item: ChannelItem }[]>; setContentChannelRevision(guid: string, channelId: string): Promise; setContentChannelDetail(guid: string, channelId: string, detail: ChannelDetail, unsealedData: string): Promise; setContentChannelSummary(guid: string, channelId: string, summary: ChannelSummary, unsealedData: string): Promise; setContentChannelUnsealedDetail(guid: string, channelId: string, data: string | null): Promise; setContentChannelUnsealedSummary(guid: string, channelId: string, data: string | null): Promise; } export interface SqlStore { set(stmt: string, params?: (string | number | null)[]): Promise; get(stmt: string, params?: (string | number | null)[]): Promise; } export interface WebStore { getValue(key: string): Promise; setValue(key: string, value: string): Promise; clearValue(key: string): Promise; clearAll(): Promise; } export class OfflineStore implements Store { private sql: SqlStore; private log: Logging; constructor(log: Logging, sql: SqlStore) { this.sql = sql; this.log = log; } private async getValues(guid: string, table: string, fields: string[]): Promise { return await this.sql.get(`SELECT ${fields.join(', ')} FROM ${table}_${guid}`); } private async addValue(guid: string, table: string, fields: string[], value: (string | number | null)[]): Promise { return await this.sql.set(`INSERT INTO ${table}_${guid} (${fields.join(', ')}) VALUES (${fields.map((field) => '?').join(', ')})`, value); } private async setValue(guid: string, table: string, idFields: string[], fields: string[], idValues: string[], values: (string | number | null)[]): Promise { return await this.sql.set(`UPDATE ${table}_${guid} SET ${fields.map((field) => `${field}=?`).join(',')} WHERE ${idFields.map((idField) => `${idField}=?`).join(' AND ')}`, [ ...values, ...idValues, ]); } private async removeValue(guid: string, table: string, idFields: string[], idValues: (string | number)[]): Promise { return await this.sql.set(`DELETE FROM ${table}_${guid} WHERE ${idFields.map((idField) => `${idField}=?`).join(' AND ')}`, idValues); } private parse(value: string): any { try { return JSON.parse(value); } catch (err) { console.log(err); } return {}; } private async getAppValue(guid: string, id: string, unset: any): Promise { try { const rows = await this.sql.get(`SELECT * FROM app WHERE key='${guid}::${id}';`); if (rows.length == 1 && rows[0].value != null) { return JSON.parse(rows[0].value); } } catch (err) { console.log(err); } return unset; } private async setAppValue(guid: string, id: string, value: any): Promise { await this.sql.set('INSERT OR REPLACE INTO app (key, value) values (?, ?)', [`${guid}::${id}`, JSON.stringify(value)]); } private async clearAppValue(guid: string, id: string): Promise { await this.sql.set('INSERT OR REPLACE INTO app (key, value) values (?, null)', [`${guid}::${id}`]); } private async initLogin(guid: string): Promise { await this.sql.set( `CREATE TABLE IF NOT EXISTS channel_${guid} (channel_id text, detail text, unsealed_detail text, summary text, unsealed_summary text, topic_revision integer, sync_revision integer, topic_marker integer, unique(channel_id))`, ); await this.sql.set( `CREATE TABLE IF NOT EXISTS channel_topic_${guid} (channel_id text, topic_id text, revision integer, created integer, detail_revision integer, detail text, unsealed_detail text, unique(channel_id, topic_id))`, ); await this.sql.set( `CREATE TABLE IF NOT EXISTS card_${guid} (card_id text, revision integer, detail text, profile text, offsync_profile integer, offsync_article integer, offsync_channel integer, profile_revision, article_revision, channel_revision, unique(card_id))`, ); await this.sql.set( `CREATE TABLE IF NOT EXISTS card_channel_${guid} (card_id text, channel_id text, detail text, unsealed_detail text, summary text, unsealed_summary text, topic_revision integer, sync_revision integer, topic_marker integer, unique(card_id, channel_id))`, ); await this.sql.set( `CREATE TABLE IF NOT EXISTS card_channel_topic_${guid} (card_id text, channel_id text, topic_id text, revision integer, created integer, detail_revision integer, detail text, unsealed_detail text, unique(card_id, channel_id, topic_id))`, ); await this.sql.set(`CREATE TABLE IF NOT EXISTS marker_${guid} (value text)`); } public async init(): Promise { await this.sql.set('CREATE TABLE IF NOT EXISTS app (key text, value text, unique(key));'); return (await this.getAppValue('', 'login', null)) as Login | null; } public async setMarker(guid: string, value: string) { await this.addValue(guid, 'marker', ['value'], [value]); } public async clearMarker(guid: string, value: string) { await this.removeValue(guid, 'marker', ['value'], [value]); } public async getMarkers(guid: string): Promise { return (await this.getValues(guid, 'marker', ['value'])).map((marker) => marker.value); } public async setLogin(login: Login): Promise { await this.initLogin(login.guid); await this.setAppValue('', 'login', login); } public async clearLogin(): Promise { await this.clearAppValue('', 'login'); } public async getSeal(guid: string): Promise<{ publicKey: string; privateKey: string } | null> { return (await this.getAppValue(guid, 'seal', null)) as { publicKey: string; privateKey: string; } | null; } public async setSeal(guid: string, seal: { publicKey: string; privateKey: string }): Promise { await this.setAppValue(guid, 'seal', seal); } public async clearSeal(guid: string): Promise { await this.clearAppValue(guid, 'seal'); } public async getProfileRevision(guid: string): Promise { return (await this.getAppValue(guid, 'profile_revision', 0)) as number; } public async setProfileRevision(guid: string, revision: number): Promise { await this.setAppValue(guid, 'profile_revision', revision); } public async getProfileData(guid: string): Promise { return (await this.getAppValue(guid, 'profile_data', defaultProfileEntity)) as ProfileEntity; } public async setProfileData(guid: string, data: ProfileEntity): Promise { await this.setAppValue(guid, 'profile_data', data); } public async getSettingsRevision(guid: string): Promise { return (await this.getAppValue(guid, 'account_revision', 0)) as number; } public async setSettingsRevision(guid: string, revision: number): Promise { await this.setAppValue(guid, 'account_revision', revision); } public async getSettingsData(guid: string): Promise { return (await this.getAppValue(guid, 'account_data', defaultConfigEntity)) as ConfigEntity; } public async setSettingsData(guid: string, data: ConfigEntity): Promise { await this.setAppValue(guid, 'account_data', data); } public async getContactRevision(guid: string): Promise { return (await this.getAppValue(guid, 'contact_revision', 0)) as number; } public async setContactRevision(guid: string, revision: number): Promise { await this.setAppValue(guid, 'contact_revision', revision); } public async getContacts(guid: string): Promise<{ cardId: string; item: CardItem }[]> { const cards = await this.getValues(guid, 'card', [ 'offsync_profile', 'offsync_article', 'offsync_channel', 'revision', 'card_id', 'profile', 'detail', 'profile_revision', 'article_revision', 'channel_revision', ]); return cards.map((card) => ({ cardId: card.card_id, item: { offsyncProfile: card.offsync_profile, offsyncArticle: card.offsync_article, offsyncChannel: card.offsync_channel, revision: card.revision, profile: this.parse(card.profile), detail: this.parse(card.detail), profileRevision: card.profile_revision, articleRevision: card.article_revision, channelRevision: card.channel_revision, }, })); } public async addContactCard(guid: string, cardId: string, item: CardItem): Promise { const fields = ['card_id', 'offsync_profile', 'offsync_article', 'offsync_channel', 'revision', 'profile', 'detail', 'profile_revision', 'article_revision', 'channel_revision']; const { offsyncProfile, offsyncArticle, offsyncChannel, revision, profile, detail, profileRevision, articleRevision, channelRevision } = item; const value = [cardId, offsyncProfile, offsyncArticle, offsyncChannel, revision, JSON.stringify(profile), JSON.stringify(detail), profileRevision, articleRevision, channelRevision]; await this.addValue(guid, 'card', fields, value); } public async removeContactCard(guid: string, cardId: string): Promise { await this.removeValue(guid, 'card', ['card_id'], [cardId]); } public async setContactCardRevision(guid: string, cardId: string, revision: number): Promise { await this.setValue(guid, 'card', ['card_id'], ['revision'], [cardId], [revision]); } public async setContactCardProfile(guid: string, cardId: string, profile: CardProfile): Promise { await this.setValue(guid, 'card', ['card_id'], ['profile'], [cardId], [JSON.stringify(profile)]); } public async setContactCardDetail(guid: string, cardId: string, detail: CardDetail): Promise { await this.setValue(guid, 'card', ['card_id'], ['detail'], [cardId], [JSON.stringify(detail)]); } public async setContactCardOffsyncProfile(guid: string, cardId: string, revision: number): Promise { await this.setValue(guid, 'card', ['card_id'], ['offsync_profile'], [cardId], [revision]); } public async clearContactCardOffsyncProfile(guid: string, cardId: string): Promise { await this.setValue(guid, 'card', ['card_id'], ['offsync_profile'], [cardId], [null]); } public async setContactCardOffsyncArticle(guid: string, cardId: string, revision: number): Promise { await this.setValue(guid, 'card', ['card_id'], ['offsync_article'], [cardId], [revision]); } public async clearContactCardOffsyncArticle(guid: string, cardId: string): Promise { await this.setValue(guid, 'card', ['card_id'], ['offsync_article'], [cardId], [null]); } public async setContactCardOffsyncChannel(guid: string, cardId: string, revision: number): Promise { await this.setValue(guid, 'card', ['card_id'], ['offsync_channel'], [cardId], [revision]); } public async clearContactCardOffsyncChannel(guid: string, cardId: string): Promise { await this.setValue(guid, 'card', ['card_id'], ['offsync_channel'], [cardId], [null]); } public async setContactCardProfileRevision(guid: string, cardId: string, revision: number): Promise { await this.setValue(guid, 'card', ['card_id'], ['profile_revision'], [cardId], [revision]); } public async setContactCardArticleRevision(guid: string, cardId: string, revision: number): Promise { await this.setValue(guid, 'card', ['card_id'], ['article_revision'], [cardId], [revision]); } public async setContactCardChannelRevision(guid: string, cardId: string, revision: number): Promise { await this.setValue(guid, 'card', ['card_id'], ['channel_revision'], [cardId], [revision]); } public async getContactCardChannels(guid: string): Promise<{ cardId: string; channelId: string; item: ChannelItem }[]> { const channels = await this.getValues(guid, 'card_channel', ['card_id', 'channel_id', 'detail', 'unsealed_detail', 'summary', 'unsealed_summary']); return channels.map((channel) => ({ cardId: channel.card_id, channelId: channel.channel_id, item: { detail: this.parse(channel.detail), summary: this.parse(channel.summary), unsealedDetail: this.parse(channel.unsealed_detail), unsealedSummary: this.parse(channel.unsealed_summary), channelKey: null, }, })); } public async addContactCardChannel(guid: string, cardId: string, channelId: string, item: ChannelItem): Promise { const fields = ['card_id', 'channel_id', 'detail', 'unsealed_detail', 'summary', 'unsealed_summary', 'topic_revision', 'sync_revision']; const { detail, unsealedDetail, summary, unsealedSummary } = item; const value = [cardId, channelId, JSON.stringify(detail), JSON.stringify(unsealedDetail), JSON.stringify(summary), JSON.stringify(unsealedSummary), 0, 0]; await this.addValue(guid, 'card_channel', fields, value); } public async removeContactCardChannel(guid: string, cardId: string, channelId: string): Promise { await this.removeValue(guid, 'card_channel', ['card_id', 'channel_id'], [cardId, channelId]); } public async setContactCardChannelDetail(guid: string, cardId: string, channelId: string, detail: ChannelDetail, unsealedDetail: any): Promise { await this.setValue(guid, 'card_channel', ['card_id', 'channel_id'], ['detail', 'unsealed_detail'], [cardId, channelId], [JSON.stringify(detail), JSON.stringify(unsealedDetail)]); } public async setContactCardChannelSummary(guid: string, cardId: string, channelId: string, summary: ChannelSummary, unsealedSummary: any): Promise { await this.setValue(guid, 'card_channel', ['card_id', 'channel_id'], ['summary', 'unsealed_summary'], [cardId, channelId], [JSON.stringify(summary), JSON.stringify(unsealedSummary)]); } public async setContactCardChannelUnsealedDetail(guid: string, cardId: string, channelId: string, unsealedDetail: any): Promise { await this.setValue(guid, 'card_channel', ['card_id', 'channel_id'], ['unsealed_detail'], [cardId, channelId], [JSON.stringify(unsealedDetail)]); } public async setContactCardChannelUnsealedSummary(guid: string, cardId: string, channelId: string, unsealedSummary: any): Promise { await this.setValue(guid, 'card_channel', ['card_id', 'channel_id'], ['unsealed_summary'], [cardId, channelId], [JSON.stringify(unsealedSummary)]); } public async getContentRevision(guid: string): Promise { return (await this.getAppValue(guid, 'content_revision', 0)) as number; } public async setContentRevision(guid: string, revision: number): Promise { await this.setAppValue(guid, 'content_revision', revision); } public async getContentChannels(guid: string): Promise<{ channelId: string; item: ChannelItem }[]> { const channels = await this.getValues(guid, 'channel', ['channel_id', 'detail', 'unsealed_detail', 'summary', 'unsealed_summary']); return channels.map((channel) => ({ channelId: channel.channel_id, item: { detail: this.parse(channel.detail), summary: this.parse(channel.summary), unsealedDetail: this.parse(channel.unsealed_detail), unsealedSummary: this.parse(channel.unsealed_summary), channelKey: null, }, })); } public async addContentChannel(guid: string, channelId: string, item: ChannelItem): Promise { const fields = ['channel_id', 'detail', 'unsealed_detail', 'summary', 'unsealed_summary', 'topic_revision', 'sync_revision']; const { detail, unsealedDetail, summary, unsealedSummary } = item; const value = [channelId, JSON.stringify(detail), JSON.stringify(unsealedDetail), JSON.stringify(summary), JSON.stringify(unsealedSummary), 0, 0]; await this.addValue(guid, 'channel', fields, value); } public async removeContentChannel(guid: string, channelId: string): Promise { await this.removeValue(guid, 'channel', ['channel_id'], [channelId]); } public async setContentChannelDetail(guid: string, channelId: string, detail: ChannelDetail, unsealedDetail: any): Promise { await this.setValue(guid, 'channel', ['channel_id'], ['detail', 'unsealed_detail'], [channelId], [JSON.stringify(detail), JSON.stringify(unsealedDetail)]); } public async setContentChannelSummary(guid: string, channelId: string, summary: ChannelSummary, unsealedSummary: any): Promise { await this.setValue(guid, 'channel', ['channel_id'], ['summary', 'unsealed_summary'], [channelId], [JSON.stringify(summary), JSON.stringify(unsealedSummary)]); } public async setContentChannelUnsealedDetail(guid: string, channelId: string, unsealedDetail: any): Promise { await this.setValue(guid, 'channel', ['channel_id'], ['unsealed_detail'], [channelId], [JSON.stringify(unsealedDetail)]); } public async setContentChannelUnsealedSummary(guid: string, channelId: string, unsealedSummary: any): Promise { await this.setValue(guid, 'channel', ['channel_id'], ['unsealed_summary'], [channelId], [JSON.stringify(unsealedSummary)]); } public async getContactCardArticles(guid: string): Promise<{ cardId: string; articleId: string; item: ArticleItem }[]> { return []; } public async addContactCardArticle(guid: string, cardId: string, articleId: string, item: ArticleItem): Promise {} public async removeContactCardArticle(guid: string, cardId: string, articleId: string): Promise {} public async setContactCardArticleDetail(guid: string, cardId: string, articleId: string, detail: ChannelDetail, unsealedData: string | null): Promise {} public async setContactCardArticleUnsealed(guid: string, cardId: string, articleId: string, unsealedData: string | null): Promise {} public async setContactCardChannelTopicSyncRevision(guid: string, cardId: string, channelId: string, revision: number): Promise {} public async setContactCardChannelTopicRemoteRevision(guid: string, cardId: string, channelId: string, revision: number): Promise {} public async setContentChannelRevision(guid: string, channelId: string): Promise {} } export class OnlineStore implements Store { private web: WebStore; private log: Logging; constructor(log: Logging, web: WebStore) { this.web = web; this.log = log; } private async getAppValue(guid: string, id: string, unset: any): Promise { const value = await this.web.getValue(`${guid}::${id}`); if (value != null) { return JSON.parse(value); } return unset; } private async setAppValue(guid: string, id: string, value: any): Promise { await this.web.setValue(`${guid}::${id}`, JSON.stringify(value)); } private async clearAppValue(guid: string, id: string): Promise { await this.web.clearValue(`${guid}::${id}`); } public async init(): Promise { return (await this.getAppValue('', 'login', null)) as Login | null; } public async setMarker(guid: string, value: string) { const markers = await this.getAppValue(guid, 'marker', []); markers.push(value); this.setAppValue(guid, 'marker', markers); } public async clearMarker(guid: string, value: string) { const markers = (await this.getAppValue(guid, 'marker', [])) as string[]; this.setAppValue( guid, 'marker', markers.filter((marker) => value != marker), ); } public async getMarkers(guid: string): Promise { return (await this.getAppValue(guid, 'marker', [])) as string[]; } public async setLogin(login: Login): Promise { await this.setAppValue('', 'login', login); } public async clearLogin(): Promise { await this.clearAppValue('', 'login'); } public async getSeal(guid: string): Promise<{ publicKey: string; privateKey: string } | null> { return (await this.getAppValue(guid, 'seal', null)) as { publicKey: string; privateKey: string; } | null; } public async setSeal(guid: string, seal: { publicKey: string; privateKey: string }): Promise { await this.setAppValue(guid, 'seal', seal); } public async clearSeal(guid: string): Promise { await this.clearAppValue(guid, 'seal'); } public async getProfileRevision(guid: string): Promise { return 0; } public async setProfileRevision(guid: string, revision: number): Promise {} public async getProfileData(guid: string): Promise { return defaultProfileEntity; } public async setProfileData(guid: string, data: ProfileEntity): Promise {} public async getSettingsRevision(guid: string): Promise { return 0; } public async setSettingsRevision(guid: string, revision: number): Promise {} public async getSettingsData(guid: string): Promise { return defaultConfigEntity; } public async setSettingsData(guid: string, data: ConfigEntity): Promise {} public async getContactRevision(guid: string): Promise { return 0; } public async setContactRevision(guid: string, revision: number): Promise {} public async getContacts(guid: string): Promise<{ cardId: string; item: CardItem }[]> { return []; } public async addContactCard(guid: string, cardId: string, item: CardItem): Promise {} public async removeContactCard(guid: string, cardId: string): Promise {} public async setContactCardRevision(guid: string, cardId: string, revision: number): Promise {} public async setContactCardProfile(guid: string, cardId: string, profile: CardProfile): Promise {} public async setContactCardDetail(guid: string, cardId: string, detail: CardDetail): Promise {} public async setContactCardOffsyncProfile(guid: string, cardId: string, revision: number): Promise {} public async clearContactCardOffsyncProfile(guid: string, cardId: string): Promise {} public async setContactCardOffsyncArticle(guid: string, cardId: string, revision: number): Promise {} public async clearContactCardOffsyncArticle(guid: string, cardId: string): Promise {} public async setContactCardOffsyncChannel(guid: string, cardId: string, revision: number): Promise {} public async clearContactCardOffsyncChannel(guid: string, cardId: string): Promise {} public async setContactCardProfileRevision(guid: string, cardId: string, revision: number): Promise {} public async setContactCardArticleRevision(guid: string, cardId: string, revision: number): Promise {} public async setContactCardChannelRevision(guid: string, cardId: string, revision: number): Promise {} public async getContactCardArticles(guid: string): Promise<{ cardId: string; articleId: string; item: ArticleItem }[]> { return []; } public async addContactCardArticle(guid: string, cardId: string, articleId: string, item: ArticleItem): Promise {} public async removeContactCardArticle(guid: string, cardId: string, articleId: string): Promise {} public async setContactCardArticleDetail(guid: string, cardId: string, articleId: string, detail: ChannelDetail, unsealedData: string | null): Promise {} public async setContactCardArticleUnsealed(guid: string, cardId: string, articleId: string, unsealedData: string | null): Promise {} public async getContactCardChannels(guid: string): Promise<{ cardId: string; channelId: string; item: ChannelItem }[]> { return []; } public async addContactCardChannel(guid: string, cardId: string, channelId: string, item: ChannelItem): Promise {} public async removeContactCardChannel(guid: string, cardId: string, channelId: string): Promise {} public async setContactCardChannelDetail(guid: string, cardId: string, channelId: string, detail: ChannelDetail, unsealedDetail: any): Promise {} public async setContactCardChannelSummary(guid: string, cardId: string, channelId: string, summary: ChannelSummary, unsealedSummary: any): Promise {} public async setContactCardChannelUnsealedDetail(guid: string, cardId: string, channelId: string, unsealedDetail: any): Promise {} public async setContactCardChannelUnsealedSummary(guid: string, cardId: string, channelId: string, unsealedSummary: any): Promise {} public async setContactCardChannelTopicSyncRevision(guid: string, cardId: string, channelId: string, revision: number): Promise {} public async setContactCardChannelTopicRemoteRevision(guid: string, cardId: string, channelId: string, revision: number): Promise {} public async getContentRevision(guid: string): Promise { return 0; } public async setContentRevision(guid: string, revision: number): Promise {} public async addContentChannel(guid: string, channelId: string, item: ChannelItem): Promise {} public async removeContentChannel(guid: string, channelId: string): Promise {} public async getContentChannels(guid: string): Promise<{ channelId: string; item: ChannelItem }[]> { return []; } public async setContentChannelRevision(guid: string, channelId: string): Promise {} public async setContentChannelDetail(guid: string, channelId: string, detail: ChannelDetail, unsealedDetail: any): Promise {} public async setContentChannelSummary(guid: string, channelId: string, summary: ChannelSummary, unsealedSummary: any): Promise {} public async setContentChannelUnsealedDetail(guid: string, channelId: string, unsealedDetail: any): Promise {} public async setContentChannelUnsealedSummary(guid: string, channelId: string, unsealedSummary: any): Promise {} } export class NoStore implements Store { constructor() {} public async init(): Promise { return null; } public async setMarker(guid: string, marker: string): Promise {} public async clearMarker(guid: string, marker: string): Promise {} public async getMarkers(guid: string): Promise { return []; } public async setLogin(login: Login): Promise {} public async clearLogin(): Promise {} public async getSeal(guid: string): Promise<{ publicKey: string; privateKey: string } | null> { return null; } public async setSeal(guid: string, seal: { publicKey: string; privateKey: string }): Promise {} public async clearSeal(guid: string): Promise {} public async getProfileRevision(guid: string): Promise { return 0; } public async setProfileRevision(guid: string, revision: number): Promise {} public async getProfileData(guid: string): Promise { return defaultProfileEntity; } public async setProfileData(guid: string, data: ProfileEntity): Promise {} public async getSettingsRevision(guid: string): Promise { return 0; } public async setSettingsRevision(guid: string, revision: number): Promise {} public async getSettingsData(guid: string): Promise { return defaultConfigEntity; } public async setSettingsData(guid: string, data: ConfigEntity): Promise {} public async getContactRevision(guid: string): Promise { return 0; } public async setContactRevision(guid: string, revision: number): Promise {} public async getContacts(guid: string): Promise<{ cardId: string; item: CardItem }[]> { return []; } public async addContactCard(guid: string, cardId: string, item: CardItem): Promise {} public async removeContactCard(guid: string, cardId: string): Promise {} public async setContactCardRevision(guid: string, cardId: string, revision: number): Promise {} public async setContactCardProfile(guid: string, cardId: string, profile: CardProfile): Promise {} public async setContactCardDetail(guid: string, cardId: string, detail: CardDetail): Promise {} public async setContactCardOffsyncProfile(guid: string, cardId: string, revision: number): Promise {} public async clearContactCardOffsyncProfile(guid: string, cardId: string): Promise {} public async setContactCardOffsyncArticle(guid: string, cardId: string, revision: number): Promise {} public async clearContactCardOffsyncArticle(guid: string, cardId: string): Promise {} public async setContactCardOffsyncChannel(guid: string, cardId: string, revision: number): Promise {} public async clearContactCardOffsyncChannel(guid: string, cardId: string): Promise {} public async setContactCardProfileRevision(guid: string, cardId: string, revision: number): Promise {} public async setContactCardArticleRevision(guid: string, cardId: string, revision: number): Promise {} public async setContactCardChannelRevision(guid: string, cardId: string, revision: number): Promise {} public async getContactCardArticles(guid: string): Promise<{ cardId: string; articleId: string; item: ArticleItem }[]> { return []; } public async addContactCardArticle(guid: string, cardId: string, articleId: string, item: ArticleItem): Promise {} public async removeContactCardArticle(guid: string, cardId: string, articleId: string): Promise {} public async setContactCardArticleDetail(guid: string, cardId: string, articleId: string, detail: ChannelDetail, unsealedData: string | null): Promise {} public async setContactCardArticleUnsealed(guid: string, cardId: string, articleId: string, unsealedData: string | null): Promise {} public async getContactCardChannels(guid: string): Promise<{ cardId: string; channelId: string; item: ChannelItem }[]> { return []; } public async addContactCardChannel(guid: string, cardId: string, channelId: string, item: ChannelItem): Promise {} public async removeContactCardChannel(guid: string, cardId: string, channelId: string): Promise {} public async setContactCardChannelDetail(guid: string, cardId: string, channelId: string, detail: ChannelDetail, unsealedDetail: any): Promise {} public async setContactCardChannelSummary(guid: string, cardId: string, channelId: string, summary: ChannelSummary, unsealedSummary: any): Promise {} public async setContactCardChannelUnsealedDetail(guid: string, cardId: string, channelId: string, unsealedDetail: any): Promise {} public async setContactCardChannelUnsealedSummary(guid: string, cardId: string, channelId: string, unsealedSummary: any): Promise {} public async setContactCardChannelTopicSyncRevision(guid: string, cardId: string, channelId: string, revision: number): Promise {} public async setContactCardChannelTopicRemoteRevision(guid: string, cardId: string, channelId: string, revision: number): Promise {} public async getContentRevision(guid: string): Promise { return 0; } public async setContentRevision(guid: string, revision: number): Promise {} public async addContentChannel(guid: string, channelId: string, item: ChannelItem): Promise {} public async removeContentChannel(guid: string, channelId: string): Promise {} public async getContentChannels(guid: string): Promise<{ channelId: string; item: ChannelItem }[]> { return []; } public async setContentChannelRevision(guid: string, channelId: string): Promise {} public async setContentChannelDetail(guid: string, channelId: string, detail: ChannelDetail, unsealedDetail: any): Promise {} public async setContentChannelSummary(guid: string, channelId: string, summary: ChannelSummary, unsealedSummary: any): Promise {} public async setContentChannelUnsealedDetail(guid: string, channelId: string, unsealedDetail: any): Promise {} public async setContentChannelUnsealedSummary(guid: string, channelId: string, unsealedSummary: any): Promise {} }