import { IModel, IFinderOptions, IndexAction, IRepoOptions, ISearchProvider, IPlugin, IModelMapper, ISearchOptions, IRepoPlugin, IFinderPlugin, ModelPersistenceEventType, IPredicate } from "./Types"; import { Coordinator } from './Coordinator'; import { IModelType } from "./ModelTypes"; import { IModelOptions, IKeyValue, TKeyValue, IModelAttributeOptions } from "./decorations/ModelDecorations"; /** * The core Repo implementation * * When requested from the coordinator, * it offers itself to all configured plugins for * them to attach to the model pipeline * * */ export declare class Repo { repoClazz: any; modelClazz: { new (): M; }; modelOpts: IModelOptions; repoOpts: IRepoOptions; modelType: IModelType; mapper: any; coordinator: Coordinator; protected plugins: IPlugin[]; /** * Core repo is instantiated by providing the implementing/extending * class and the model that will be supported * * @param repoClazz * @param modelClazz */ constructor(repoClazz: any, modelClazz: { new (): M; }); protected getRepoPlugins(): IRepoPlugin[]; protected getFinderPlugins(): IFinderPlugin[]; attr(name: string): IModelAttributeOptions; init(coordinator: any): void; start(): void; getMapper(clazz: { new (): M; }): IModelMapper; /** * Attach a plugin to the repo - could be a store, * indexer, etc, etc * * @param plugin * @returns {Repo} */ attach(plugin: IPlugin): this; getFinderOptions(finderKey: string): IFinderOptions; getPlugins: (predicate: IPredicate) => IPlugin[]; /** * Decorate finder by iterating all finder plugins * and trying until resolved * * @param finderKey */ decorateFinder(finderKey: any): void; /** * Decorate all finders on Repo */ decorateFinders(): void; /** * Create a generic finder, in order * to do this search options must have been * annotated on the model * * @param finderKey * @param searchProvider * @param searchOpts * @returns {any} */ makeGenericFinder(finderKey: string, searchProvider: ISearchProvider, searchOpts: ISearchOptions): (...args: any[]) => Promise[]>; /** * Set a finder function on the repo * * @param finderKey * @param finderFn */ protected setFinder(finderKey: string, finderFn: (...args) => any): void; /** * Triggers manually attached persistence callbacks * - works for internal indexing solutions, etc * * @param type * @param models */ triggerPersistenceEvent(type: ModelPersistenceEventType, ...models: any[]): void; supportPersistenceEvents(): boolean; /** * Call out to the indexers * * @param type * @param models * @returns {Bluebird} */ index(type: IndexAction, ...models: IModel[]): Promise; indexPromise(action: IndexAction): (models: M[]) => Promise; /** * Not implemented * * @param args * @returns {null} */ key(...args: any[]): IKeyValue; /** * Get one or more models with keys * * @param key * @returns {null} */ get(key: TKeyValue): Promise; /** * Save model * * @param o * @returns {null} */ save(o: M): Promise; /** * Remove a model * * @param key * @returns {null} */ remove(key: TKeyValue): Promise; /** * Count models * * @returns {null} */ count(): Promise; bulkGet(...keys: TKeyValue[]): Promise; bulkSave(...models: M[]): Promise; bulkRemove(...keys: TKeyValue[]): Promise; }