import { Repo } from "./Repo"; import { IModel, IModelType } from "./ModelTypes"; import { IIndexOptions, IPlugin } from "./PluginTypes"; export * from './ModelTypes'; export * from './PluginTypes'; export declare enum ModelPersistenceEventType { Save = 1, Remove = 2, } export declare type ModelPersistenceEventCallback = (type: ModelPersistenceEventType, ...models: M[]) => void; /** * Options for repo decorations */ export interface IRepoOptions { indexes?: Array; } /** * Options for finder decorations */ export interface IFinderOptions { optional?: boolean; single?: boolean; } /** * Finder request for paging, etc */ export declare class FinderRequest { extra: any; limit: number; offset: number; sort: string[]; sortDirection: 'desc' | 'asc'; includeModels: boolean; constructor(obj: any); constructor(limit: number, offset: number, includeModels?: boolean, sort?: string[], sortDirection?: 'asc' | 'desc', extra?: any); } export interface IFinderItemMetadata { score?: number; finderName?: string; } /** * Finder result array - not implemented yet, mostly */ export declare class FinderResultArray extends Array { total: number; request: FinderRequest; itemMetadata: IFinderItemMetadata[]; pageNumber: number; pageCount: number; constructor(items: T[], total: number, request?: FinderRequest, itemMetadata?: IFinderItemMetadata[]); } /** * Simple base model implementation * uses reflection to determine type */ export declare class DefaultModel implements IModel { readonly clazzType: any; } /** * Sync strategy for updating models in the store */ export declare enum SyncStrategy { Overwrite = 0, Update = 1, None = 2, } export declare namespace SyncStrategy { const toString: (strategy: SyncStrategy) => string; } /** * Coordinator configuration, this is usually extend * by individual store providers */ export interface ICoordinatorOptions { immutable?: boolean; syncStrategy?: SyncStrategy; autoRegisterModels?: boolean; } /** * Coordinator options default implementation */ export declare class CoordinatorOptions implements ICoordinatorOptions { /** * Default manager options * * @type {{autoRegisterModules: boolean, syncStrategy: SyncStrategy, immutable: boolean}} */ static Defaults: { autoRegisterModules: boolean; syncStrategy: SyncStrategy; immutable: boolean; }; constructor(opts?: {}); } export interface IModelMapperDecorator { (json: any, model: M): M; } /** * Mapper interface for transforming objects back and forth between json * and their respective models */ export interface IModelMapper { toObject(o: M): Object; toJson(o: M): string; fromObject(json: Object, decorator?: IModelMapperDecorator): M; fromJson(json: string, decorator?: IModelMapperDecorator): M; } /** * Predicate for searching */ export interface IPredicate { (val: any): boolean; } /** * Makes a predicate for reuse */ export interface IPredicateFactory { (...args: any[]): IPredicate; } /** * Predicate for searching */ export interface ITypedPredicate { (val: T): boolean; } /** * Makes a predicate for reuse */ export interface ITypedPredicateFactory { (type: { new (): T; }, ...args: any[]): ITypedPredicate; } /** * Coordinator interface for store provider development * and end user management * * TODO: Rename coordinator */ export interface ICoordinator { getOptions(): ICoordinatorOptions; getModels(): IModelType[]; getModel(clazz: any): IModelType; getModelByName(name: string): any; start(...models: any[]): Promise; init(opts: ICoordinatorOptions, ...plugins: IPlugin[]): Promise; reset(): Promise; getRepo, M extends IModel>(clazz: { new (): T; }): T; }