import { IClientRequest } from "../common/ClientRequest"; import { TConstructor } from "../types"; import { IRequestOptions, ObjectKey } from "./common"; import { IEventEmitter } from "../common/EventEmitter"; import { IClient } from "../Client"; import { IEntityConstructors } from "../api/activeRecords"; import { IFactoryConstructors } from "../api/factories"; import { IEntityCriteriaBuilder } from "../api/activeRecords/common/EntityCriteriaBuilder"; import { IFactoryCriteriaBuilder } from "../api/factories/common/FactoryCriteriaBuilder"; export interface IClientConstructors { entities: IEntityConstructors; factories: IFactoryConstructors; } export interface IResourceFactory>> extends IEventEmitter { criteriaBuilder: IFactoryCriteriaBuilder; getClient(): IClient; getEntityClass(): TConstructor; createEntity(): T; from(attributes?: IEntityAttributes): T; getRequest(): IClientRequest; getEmbeddedKey(): ObjectKey; getEmbedded(data: ICollectionResponse): A[]; getUrl(path?: string): string; getEntityCriteria(criteriaData: (object)[]): IEntityAttributes[]; getEntityCriteria(criteriaData: (object)[]): R[]; } export declare type EntityAttributes>> = ReturnType; export interface IResourceEntity>> extends IEventEmitter { id?: number; updated_at?: number; criteriaBuilder: IEntityCriteriaBuilder; isNew(): boolean; getFactory(): T; getAttributes(): IEntityAttributes; setAttributes(attributes?: IEntityAttributes): void; } export interface ISelfResponse { id: number; updated_at: number; _links: { href: string; }; } export interface ICollectionResponse { _links: { href: string; }; _embedded: { [index: string]: T[]; }; } export interface IPaginationLinks { current?: string; next?: string; prev?: string; first?: string; } export interface IResourcePaginationParams>> { url: string; criteria?: object; factory: IResourceFactory; embedded: string; options?: IRequestOptions; } export interface ITimestampRangeCriteria { from?: number; to?: number; } export interface ILinkResponse { href: string; } export interface IPaginatedResponse { _page: number; _links: { self?: ILinkResponse; next?: ILinkResponse; first?: ILinkResponse; prev?: ILinkResponse; }; _embedded: { [index: string]: IEntityAttributes[]; }; } export interface IEntityAttributes { id?: number; _embedded?: object; } export interface IEmbeddedEntity { id?: number; } export interface IEmbedded { [index: string]: T[]; }