import { Action, Task } from "./index"; export function Task(): Task; export function Task( options: TaskOptions & { start(task?: Task): TResult } ): TResult; export function Entities< TEntity = any, TId extends string | number = any, TSlice extends { [key in keyof TEntity]: (entity: TEntity) => any } = any >( initial?: TEntity[], options?: { selectId?(entity: TEntity): TId; slice?: TSlice; equal?: EqualityComparer; } ): EntitiesStoreModel; export function List(items?: TItem[]): ListStoreModel; export interface TaskOptions { last?: Task; } export interface EntitiesStoreModel< TEntity = any, TId extends string | number = any, TSlice = any > { state: { get(): TEntity[]; get( sliceName: TName ): SliceResultInfer; ids: TId[]; entities: { [key in TId]: TEntity }; }; actions: { update: Action | Partial[]>; remove: Action | Action; }; } export type EqualityComparer = (a: T, b: T) => boolean; export type SliceResultInfer = TSelector extends ( entity?: TEntity ) => infer TResult ? TResult[] : never; export interface ListStoreModel { state: { items: TItem[]; }; actions: { push: Action, TItem>; pushArray: Action, TItem[]>; pop: Action, TItem | undefined>; shift: Action, TItem | undefined>; unshiftArray: Action, TItem[]>; unshift: Action, TItem>; sort: Action, (a: TItem, b: TItem) => any>; orderBy: Action, (item: TItem) => any>; swap: Action, { from: number; to: number }>; splice: Action< ListStoreModel, { index: number; length?: number; items?: TItem[] }, TItem[] >; set: Action, { index: number; value: TItem }>; }; } export function History( prop: string, options?: HistoryStoreOptions ): HistoryStoreModel; export function History( props: (keyof TEntry)[], options?: HistoryStoreOptions ): HistoryStoreModel; export interface HistoryStoreOptions { entries?: TEntry[]; index?: number; /** * indicate the history add current state as first entry (def = true), unless no entry added */ initial?: boolean; /** * indicate the history is isolated (def = true) */ isolate?: boolean; } export interface HistoryStoreModel { state: { current: TEntry; next: TEntry; prev: TEntry; entries: TEntry[]; index: number; prevEntries: TEntry[]; nextEntries: TEntry[]; }; actions: { go: Action, number, void>; back: Action, never, void>; forward: Action, never, void>; clear: Action, boolean, void>; }; }