UNPKG

@rep2recall/r2r-sqlite

Version:
106 lines (105 loc) 3.38 kB
import Anki from "ankisync"; import R2rSqlite from "."; export declare type ISortedData = Array<{ key: string; value: any; }>; export interface IEntry { front: string; deck: string; back?: string; mnemonic?: string; srsLevel?: number; nextReview?: Date | string; tag?: string[]; created?: Date | string; modified?: Date | string; stat?: { streak: { right: number; wrong: number; }; }; template?: string; tFront?: string; tBack?: string; css?: string; js?: string; data?: ISortedData; source?: string; sH?: string; sCreated?: Date | string; } export interface IRender { front: string; back?: string; mnemonic?: string; tFront?: string; tBack?: string; data: ISortedData; css?: string; js?: string; } export interface ICondOptions<T extends Record<string, any>> { offset?: number; limit?: number; sortBy?: keyof T | "random"; desc?: boolean; fields?: Array<keyof T> | "*"; } export interface IPagedOutput<T> { data: T[]; count: number; } declare abstract class R2rFormat { abstract build(): Promise<this>; abstract close(): Promise<this>; abstract reset(): Promise<this>; abstract parseCond(q: string, options: ICondOptions<IEntry>): Promise<IPagedOutput<Partial<IEntry>>>; abstract insertMany(entries: IEntry[]): Promise<string[]>; abstract updateMany(ids: string[], u: Partial<IEntry>): Promise<void>; abstract addTags(ids: string[], tags: string[]): Promise<void>; abstract removeTags(ids: string[], tags: string[]): Promise<void>; abstract deleteMany(ids: string[]): Promise<void>; abstract render(cardId: string): Promise<IRender>; abstract getMedia(h: string): Promise<ArrayBuffer | null>; abstract fromR2r(r2r: R2rSqlite, options?: { filename?: string; callback?: (p: IProgress) => void; }): Promise<void>; abstract export(r2r: R2rSqlite, q: string, options?: { callback?: (p: IProgress) => void; }): Promise<void>; abstract fromAnki(anki: Anki, options?: { filename?: string; callback?: (p: IProgress) => void; }): Promise<void>; protected abstract updateSrsLevel(dSrsLevel: number, cardId: string): Promise<void>; protected abstract transformCreateOrUpdate(cardId: string | null, u: Partial<IEntry>, timestamp: Date): Promise<Partial<IEntry>>; protected abstract getOrCreateDeck(name: string): Promise<number>; protected abstract getData(cardId: string): Promise<ISortedData | null>; protected abstract getFront(cardId: string): Promise<string>; fromSortedData(sd: ISortedData): { data: Record<string, any>; order: Record<string, number>; }; toSortedData(d: { data: Record<string, any>; order: Record<string, number>; }): ISortedData; markRight(cardId: string): Promise<void>; markWrong(cardId: string): Promise<void>; getTemplateKey(t: any): string; getNoteKey(data: Record<string, any>): string; } export declare abstract class R2rLocal extends R2rFormat { protected filename: string; constructor(filename: string); } export interface IProgress { text: string; current?: number; max?: number; } export declare function toDate(s?: Date | string): Date | undefined; export {};