import { AccountSession } from './accountSession'; import { AdminSession } from './adminSession'; export interface SqlStore { set(stmt: string, params: (string | number)[]): Promise; get(stmt: string, params: (string | number)[]): Promise; } export interface WebStore { getValue(key: string): Promise; setValue(key: string, value: string): Promise; clearValue(key: string): Promise; clearAll(): Promise; } export class DatabagSDK { private sqlStore: SqlStore | null = null; private webStore: WebStore | null = null; constructor() { console.log("databag sdk"); } public async initOfflineStore(sql: SqlStore): Promise { this.sqlStore = sql; // initialize return new AccountSession(this.sqlStore, this.webStore); } public async initOnlineStore(web: WebStore): Promise { this.webStore = web; // initialize return new AccountSession(this.sqlStore, this.webStore); } public async accountLogin(): Promise { return new AccountSession(this.sqlStore, this.webStore); } public async accountAccess(): Promise { return new AccountSession(this.sqlStore, this.webStore); } public async accountCreate(): Promise { return new AccountSession(this.sqlStore, this.webStore); } public async accountLogout(session: AccountSession): Promise { } public async adminLogin(): Promise { return new AdminSession(); } public async adminLogout(session: AdminSession): Promise { } }