import { App, Company, Config, Contact, Database, Interaction } from "../types"; /** * Typically a session is associated with a single operation / request */ export interface DatabaseSession { /** load the full content of the database */ dump(): Promise; // companies addCompany(company: Company): Promise; updateCompany(name: string, attributes: Partial): Promise; // indices findCompanyByName(name: string): Promise; findAppByName(appName: string): Promise<{company: Company, app: App} | undefined>; findAppByEmail(email: string): Promise<{company: Company, app: App} | undefined>; findContactByEmail(email: string): Promise<{company: Company, contact: Contact} | undefined>; /** find all followup due within a given date range */ findFollowups(startDate: string, endDate: string): Promise<(Interaction & { company: string })[]>; /** find all interactions within a given date range */ findInteractions(startDate: string, endDate: string): Promise<(Interaction & { company: string })[]>; searchCompanies(filter: string): Promise; // configuration loadConfig(): Promise; updateConfig(attributes: Partial): Promise; close(): Promise; } export interface DatabaseAdapter { create(initialData: Database): Promise; /** * Open a session, data will be cached for the duration of a session. * * Typically a session is associated with a single operation / request */ open(): Promise; }