import { Constructor } from "../utils/mixins.js";
import { BaseRecord, TagsBase } from "./BaseRecord.js";
import { AgentContext } from "../agent/context/AgentContext.js";

//#region src/storage/StorageService.d.ts
type SimpleQuery<T extends BaseRecord<any, any, any>> = T extends BaseRecord<infer DefaultTags, infer CustomTags> ? DefaultTags extends TagsBase ? Partial<ReturnType<T['getTags']>> & TagsBase : CustomTags extends TagsBase ? Partial<ReturnType<T['getTags']>> & TagsBase : Partial<DefaultTags & CustomTags> & TagsBase : Partial<ReturnType<T['getTags']>> & TagsBase;
interface AdvancedQuery<T extends BaseRecord<any, any, any>> {
  $and?: Query<T>[];
  $or?: Query<T>[];
  $not?: Query<T>;
}
type QueryOptions = {
  limit?: number;
  offset?: number;
};
type Query<T extends BaseRecord<any, any, any>> = AdvancedQuery<T> | SimpleQuery<T>;
interface BaseRecordConstructor<T> extends Constructor<T> {
  type: string;
  allowCache: boolean;
}
interface StorageService<T extends BaseRecord<any, any, any>> {
  /**
   * 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<void>;
  /**
   * 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<void>;
  /**
   * 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<void>;
  /**
   * 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<T>, id: string): Promise<void>;
  /**
   * 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<T>, id: string): Promise<T>;
  /**
   * Get all records by specified record class.
   *
   * @param recordClass the record class to get records for
   */
  getAll(agentContext: AgentContext, recordClass: BaseRecordConstructor<T>): Promise<T[]>;
  /**
   * 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
   * @param queryOptions optional parameters to customize the query execution (e.g., limit, offset)
   *
   */
  findByQuery(agentContext: AgentContext, recordClass: BaseRecordConstructor<T>, query: Query<T>, queryOptions?: QueryOptions): Promise<T[]>;
}
//#endregion
export { BaseRecordConstructor, Query, QueryOptions, SimpleQuery, StorageService };
//# sourceMappingURL=StorageService.d.ts.map