import * as Tp from 'thingpedia'; export interface AbstractRow { uniqueId: string; } export interface AppRow { uniqueId: string; code: string; state: string; name: string; description: string; } export interface ChannelRow { uniqueId: string; value: string; } export interface DeviceRow { uniqueId: string; state: string; } export interface ConversationRow { uniqueId: string; conversationId: string; previousId: string | null; dialogueId: string; context: string | null; agent: string | null; agentTimestamp: string | null; agentTarget: string | null; intermediateContext: string | null; user: string; userTimestamp: string | null; userTarget: string; vote: string | null; comment: string | null; } export interface ConversationStateRow { uniqueId: string; dialogueState: string | null; lastMessageId: number; recording: boolean; } export interface ConversationHistoryRow { uniqueId: string; conversationId: string; messageId: number; message: string; } export interface LocalTables { app: AppRow; channel: ChannelRow; conversation: ConversationRow; conversation_state: ConversationStateRow; conversation_history: ConversationHistoryRow; } export interface SyncTables { device: DeviceRow; } export interface SearchParams { filter: Array<{ k: keyof RowType; o: '=' | '>=' | '<=' | '<' | '>'; v: string | number | boolean; }>; sort: [keyof RowType, 'asc' | 'desc']; limit: number; } export interface LocalTable { name: string; getAll(): Promise; getOne(uniqueId: string): Promise; getBy(field: keyof RowType, value: string): Promise; search(search: SearchParams): Promise; insertOne(uniqueId: string, row: Omit): Promise; deleteOne(uniqueId: string): Promise; } export declare type SyncRecord = { [K in keyof RowType]: RowType[K] | null; } & { uniqueId: string; lastModified: number; }; export interface SyncAtReply { lastModified: number; ourChanges: Array>; done: boolean[]; } export interface SyncTable { name: string; fields: ReadonlyArray; getAll(): Promise; getOne(uniqueId: string): Promise; insertOne(uniqueId: string, row: Omit): Promise; deleteOne(uniqueId: string): Promise; getRaw(): Promise>>; getChangesAfter(lastModified: number): Promise>>; handleChanges(changes: Array>): Promise; syncAt(lastModified: number, pushedChanges: Array>): Promise>; replaceAll(data: Array>): Promise; insertIfRecent(uniqueId: string, lastModified: number, row: Omit): Promise; deleteIfRecent(uniqueId: string, lastModified: number): Promise; } export interface AbstractDatabase { ensureSchema(): Promise; getLocalTable(name: T): LocalTable; getSyncTable(name: T): SyncTable; } export declare function createDB(platform: Tp.BasePlatform): AbstractDatabase;