export declare type State = { [type: string]: EntityState; }; export interface EntityState { resources: ResourcesState; ids: IdsState; } export declare type ResourcesState = { [id in Id]: Data; }; export declare type IdsState = Id[]; export declare type Id = number | string; export declare type Type = string; export declare type RelationKey = string; export declare type RelationName = string; export declare type Data = { [s in string]: any; }; export declare type Cardinality = 'many' | 'one'; export declare type Index = number; export declare type CidString = string; export declare type CidObject = { type: Type; id: Id; }; export declare type CidTuple = [Type, Id]; export declare type CompositeId = CidString | CidObject | CidTuple; export interface Link { linkedId: Id; relatedType: Type; relationName: RelationName; relationKey: RelationKey; index?: Index; } export interface LinkRemovalCallback { (): LinkRemovalSchema; } export declare type LinkRemovalSchema = { [s in RelationKey | RelationName]: LinkRemovalSchema | LinkRemovalCallback; }; export interface Action { type: string; } export declare type OpId = string; export declare type Operator = 'add' | 'edit' | 'remove'; export declare type IndicesByRelation = { [s in RelationName | RelationKey]: Index; }; export declare type IndicesByRelationKey = { [s in RelationKey]: Index; }; export declare type OperationsByType = { [type in Type]: Map; }; export interface Operation { type: Type; id: Id; operator: Operator; data: Data; } export interface AddOperation extends Operation { options: AddOptions; operator: 'add'; } export interface RemoveOperation extends Operation { options: RemoveOptions; operator: 'remove'; } export interface EditOperation extends Operation { options: EditOptions; operator: 'edit'; } export interface AddOptions { index?: Index; indicesByRelation?: IndicesByRelation; ignoreIdIndex?: boolean; } export interface RemoveOptions { removalSchema?: LinkRemovalSchema; } export interface EditOptions { index?: Index; } export interface LinkDefinition { type: Type; id: Id; relation: RelationName | RelationKey; linkedId: Id; indices: [Index?, Index?]; } export interface UnlinkDefinition { type: Type; id: Id; relation: RelationName | RelationKey; linkedId: Id; } export interface Selectors { getResource: (state: State, cid: CompositeId) => Data; getEntityResources: (state: State, { type }: { type: Type; }) => ResourcesState; getEntityIds: (state: State, { type }: { type: Type; }) => Id[]; }