import Operation from '../Operation'; export interface EntityDefinition { [propKey: string]: Required | ParentId | ParentIds | CreatedAt | UpdatedAt | Count | Sum | DuplicateChildren; } export interface EntitiesDefinition { [entityType: string]: EntityDefinition; } export interface Options { fetchItemTimeout: number; } export declare type ConditionFunc = (beforeItem: any, afterItem: any) => boolean; export interface EntityItemCommon { id: string; } export interface Entity { byId: { [id: string]: EntityItemCommon; }; allIds: Array; orderedList: { [orderBy: string]: Array; }; queriedList: { [queryName: string]: Array; }; } export interface Entities { [entityType: string]: Entity; } export interface Constraints { unSettableOnAdd?: boolean; unSettableOnUpdate?: boolean; requiredOnAdd?: boolean; notNull?: boolean; } export interface ItemSelector { entityType: string; id: string; } export interface HandlerSetter { handlerHolder: 'SELF' | string; onAdd: Array; onUpdate: Array; onDelete: Array; } export interface EntityHandler { checkNeedUpdatingParents?: (childOperation: Operation, beforeParentItemSelectors: ItemSelector[], afterParentItemSelectors: ItemSelector[]) => boolean; updatingParentType: string | null; operationModifier: (selfOperation: Operation, beforeParentOperations: Array, afterParentOperations: Array) => void; } export interface BakedEntityHandler { childItemSelector: ItemSelector; beforeParentItemSelectors: Array; afterParentItemSelectors: Array; operationModifier: (selfOperation: Operation, beforeParentOperations: Array, afterParentOperations: Array) => void; } export interface PropValueCommon { constraints: Constraints; } export interface Required extends PropValueCommon { type: 'REQUIRED'; } export interface ParentId extends PropValueCommon { type: 'PARENT_ID'; parentEntityType: string; } export interface ParentIds extends PropValueCommon { type: 'PARENT_IDS'; parentEntityType: string; } export interface CreatedAt extends PropValueCommon { type: 'CREATED_AT'; } export interface UpdatedAt extends PropValueCommon { type: 'UPDATED_AT'; } export declare type AggregationCondition = [string, '==' | '!=' | '<' | '<=' | '>' | '>=', any]; export interface Count extends PropValueCommon { type: 'COUNT'; childEntityType: string; conditions: Array; } export interface Sum extends PropValueCommon { type: 'SUM'; childEntityType: string; childPropKey: string; conditions: Array; } export interface DuplicateChildren extends PropValueCommon { type: 'DUPLICATE_CHILDREN'; childEntityType: string; mapFunc: (entityItem: Object) => Object; limit: number; conditions: Array; }