UNPKG

pretur.clay

Version:
26 lines (25 loc) 1.11 kB
import { SpecType, Model } from 'pretur.spec'; import { ValidationError } from 'pretur.validation'; import { Reducible, Dispatch } from 'reducible-node'; import { Value } from './Value'; import { Record } from './Record'; import { Set } from './Set'; import { Querier } from './Querier'; export declare type State = 'normal' | 'new' | 'removed'; export declare type Clay<T extends Reducible<any>> = Reducible<T> & { readonly identifier: symbol; readonly original: Clay<T>; readonly state: State; readonly error: ValidationError; readonly modified: boolean; readonly valid: boolean; setError(dispatch: Dispatch, error: ValidationError): void; setState(dispatch: Dispatch, state: State): void; }; export declare function refresh<T extends SpecType>(dispatch: Dispatch, set: Set<T>, querier: Querier<T>, payload: { data: Set<T>; count: number; }): void; export declare function toPlain<T extends SpecType>(set: Set<T>): Model<T>[]; export declare function toPlain<T extends SpecType>(record: Record<T>): Model<T>; export declare function toPlain<T>(value: Value<T>): T;