import { Observable } from 'rxjs'; import { EntityAction, EntityActions } from './entityActions'; import { EntityStore } from './entityStore'; import { Query } from './query'; import { QueryConfigOptions } from './queryConfig'; import { SelectAllOptionsA, SelectAllOptionsB, SelectAllOptionsC, SelectAllOptionsD, SelectAllOptionsE } from './selectAllOverloads'; import { EntityState, getEntityType, getIDType, HashMap, ItemPredicate } from './types'; /** * * The Entity Query is similar to the general Query, with additional functionality tailored for EntityStores. * * class WidgetsQuery extends QueryEntity { * constructor(protected store: WidgetsStore) { * super(store); * } * } * * * */ export declare class QueryEntity, IDType = getIDType> extends Query { private options; ui: EntityUIQuery; protected store: EntityStore; __store__: any; constructor(store: EntityStore, options?: QueryConfigOptions); /** * Select the entire store's entity collection * * @example * * this.query.selectAll() * * this.query.selectAll({ * limitTo: 5 * filterBy: entity => entity.completed === true * }) * * this.query.selectAll({ * asObject: true, * limitTo: 3 * }) * * this.query.selectAll({ * sortBy: 'price', * sortByOrder: Order.DESC * }) * */ selectAll(options: SelectAllOptionsA): Observable>; selectAll(options: SelectAllOptionsB): Observable; selectAll(options: SelectAllOptionsC): Observable>; selectAll(options: SelectAllOptionsD): Observable; selectAll(options: SelectAllOptionsE): Observable; selectAll(): Observable; /** * Get the entire store's entity collection * * @example * * this.query.getAll() * * this.query.getAll({ * limitTo: 5 * filterBy: entity => entity.completed === true * }) * * this.query.getAll({ * asObject: true, * limitTo: 3 * }) * * this.query.getAll({ * sortBy: 'price', * sortByOrder: Order.DESC * }) */ getAll(options: SelectAllOptionsA): HashMap; getAll(options: SelectAllOptionsB): EntityType[]; getAll(options: SelectAllOptionsC): HashMap; getAll(options: SelectAllOptionsD): EntityType[]; getAll(options: SelectAllOptionsE): EntityType[]; getAll(): EntityType[]; /** * Select multiple entities from the store * * @example * * this.query.selectMany([1,2,3]) * this.query.selectMany([1,2], entity => entity.title) */ selectMany(ids: IDType[]): Observable; selectMany(ids: IDType[], project: (entity: EntityType) => R): Observable; /** * Select an entity or a slice of an entity * * @example * * this.query.selectEntity(1) * this.query.selectEntity(1, entity => entity.config.date) * this.query.selectEntity(1, 'comments') * this.query.selectEntity(e => e.title === 'title') * */ selectEntity(id: IDType): Observable; selectEntity(id: IDType, project?: K): Observable; selectEntity(id: IDType, project: (entity?: EntityType) => R): Observable; selectEntity(predicate: ItemPredicate): Observable; /** * Get an entity by id * * @example * * this.query.getEntity(1); */ getEntity(id: IDType): EntityType | undefined; /** * Select the active entity's id * * @example * * this.query.selectActiveId() */ selectActiveId(): Observable; /** * Get the active id * * @example * * this.query.getActiveId() */ getActiveId(): S['active'] | undefined; /** * Select the active entity * * @example * * this.query.selectActive() * this.query.selectActive(entity => entity.title) */ selectActive(): S['active'] extends any[] ? Observable : Observable; selectActive(project?: (entity: EntityType) => R): S['active'] extends any[] ? Observable : Observable; /** * Get the active entity * * @example * * this.query.getActive() */ getActive(): S['active'] extends any[] ? EntityType[] : EntityType | undefined; /** * Select the store's entity collection length * * @example * * this.query.selectCount() * this.query.selectCount(entity => entity.completed) */ selectCount(predicate?: (entity: EntityType, index: number) => boolean): Observable; /** * Get the store's entity collection length * * @example * * this.query.getCount() * this.query.getCount(entity => entity.completed) */ getCount(predicate?: (entity: EntityType, index: number) => boolean): number; /** * * Select the last entity from the store * * @example * * this.query.selectLast() * this.query.selectLast(todo => todo.title) */ selectLast(): Observable; selectLast(project: (entity?: EntityType) => R): Observable; /** * * Select the first entity from the store * * @example * * this.query.selectFirst() * this.query.selectFirst(todo => todo.title) */ selectFirst(): Observable; selectFirst(project: (entity?: EntityType) => R): Observable; /** * * Listen for entity actions * * @example * this.query.selectEntityAction(EntityActions.Add); * this.query.selectEntityAction(EntityActions.Update); * this.query.selectEntityAction(EntityActions.Remove); * * this.query.selectEntityAction([EntityActions.Add, EntityActions.Update, EntityActions.Remove]) * * this.query.selectEntityAction(); */ selectEntityAction(action: EntityActions): Observable; selectEntityAction(actions: EntityActions[]): Observable>; selectEntityAction(): Observable>; /** * Returns whether entity exists * * @example * * this.query.hasEntity(2) * this.query.hasEntity(entity => entity.completed) * this.query.hasEntity([1, 2, 33]) * */ hasEntity(id: IDType): boolean; hasEntity(id: IDType[]): boolean; hasEntity(project: (entity: EntityType) => boolean): boolean; hasEntity(): boolean; /** * Returns whether entity store has an active entity * * @example * * this.query.hasActive() * this.query.hasActive(3) * */ hasActive(id?: IDType): boolean; /** * * Create sub UI query for querying Entity's UI state * * @example * * * export class ProductsQuery extends QueryEntity { * ui: EntityUIQuery; * * constructor(protected store: ProductsStore) { * super(store); * this.createUIQuery(); * } * * } */ createUIQuery(): void; private selectAt; } export declare class EntityUIQuery extends QueryEntity { constructor(store: any); }