import type { BaseRecord, TagsBase } from './BaseRecord'; import type { AgentContext } from '../agent'; import type { Constructor } from '../utils/mixins'; export type SimpleQuery> = Partial> & TagsBase; interface AdvancedQuery { $and?: Query[]; $or?: Query[]; $not?: Query; } export type Query> = AdvancedQuery | SimpleQuery; export interface BaseRecordConstructor extends Constructor { type: string; } export interface StorageService> { /** * Save record in storage * * @param record the record to store * @throws {RecordDuplicateError} if a record with this id already exists */ save(agentContext: AgentContext, record: T): Promise; /** * Update record in storage * * @param record the record to update * @throws {RecordNotFoundError} if a record with this id and type does not exist */ update(agentContext: AgentContext, record: T): Promise; /** * Delete record from storage * * @param record the record to delete * @throws {RecordNotFoundError} if a record with this id and type does not exist */ delete(agentContext: AgentContext, record: T): Promise; /** * Delete record by id. * * @param recordClass the record class to delete the record for * @param id the id of the record to delete from storage * @throws {RecordNotFoundError} if a record with this id and type does not exist */ deleteById(agentContext: AgentContext, recordClass: BaseRecordConstructor, id: string): Promise; /** * Get record by id. * * @param recordClass the record class to get the record for * @param id the id of the record to retrieve from storage * @throws {RecordNotFoundError} if a record with this id and type does not exist */ getById(agentContext: AgentContext, recordClass: BaseRecordConstructor, id: string): Promise; /** * Get all records by specified record class. * * @param recordClass the record class to get records for */ getAll(agentContext: AgentContext, recordClass: BaseRecordConstructor): Promise; /** * Find all records by specified record class and query. * * @param recordClass the record class to find records for * @param query the query to use for finding records */ findByQuery(agentContext: AgentContext, recordClass: BaseRecordConstructor, query: Query): Promise; } export {};