import { InitConfig, Options } from "../resources/Initialize"; export interface GeneralObject { [index: string]: string; } export interface HeaderParams { Authorization: string; } export interface HeadersResponse { connection: string; server: string; 'x-frame-options': string; 'x-xss-protection': string; 'x-content-type-options': string; 'x-download-options': string; 'x-permitted-cross-domain-policies': string; 'referrer-policy': string; 'x-ratelimit-limit': string; 'x-ratelimit-count': string; 'x-ratelimit-period': string; 'content-type': string; etag: string; 'cache-control': string; 'x-request-id': string; 'strict-transport-security': string; via: string; 'accept-ranges': string; age: string; date: string; 'x-served-by': string; 'x-cache': string; 'x-cache-hits': string; 'x-timer': string; vary: string; 'transfer-encoding': string; } declare type JSONAPIResource = { attributes: Record; id: string; links: { self: string; }; meta: { mode: 'test' | 'live'; }; type: string; }; export interface JSONAPIResponse { data: JSONAPIResource[] & JSONAPIResource; included?: JSONAPIResource[]; links?: { first: string; last: string; next: string; }; meta?: { page_count: number; record_count: number; }; } export interface JSONAPIRequest { data: Omit & Partial> & { relationships?: Record; }>; }; } export interface BaseConfig { className?: string; polymorphic?: boolean; as?: string; inverseOf?: string; autosave?: boolean; } export interface Base { resourceLibrary: { endpoint: string; baseUrl: string; headers: { Authorization: string; }; }; __links: { related: string; }; new (): Base; attributes(...attribute: string[]): void; hasOne(queryName: string, config: BaseConfig): void; hasMany(queryName: string, config: BaseConfig): void; belongsTo(queryName: string, config: BaseConfig): void; define(): void; className: string; queryName: string; __queryParams: object; __newRelation(r: any): any; __extendObjectParam(type: string, options: object): any; afterRequest(callback: () => void): void; afterBuild(callback: () => void): void; afterCreate(callback: () => void): void; update(attrs: object, callback?: (res: any) => any): any; destroy(): Promise; withCredentials({ accessToken, endpoint }: InitConfig): Base; find(primaryKey: string, options?: Options): Promise; errors(): Errors; setCustomInterceptors(interceptors: InitConfig['interceptors']): Base; } export interface BaseResource extends Omit { (): BaseResource; all(options?: Options): Promise & JSONAPIResponse> & SingleRelationship>; assignQueryParams(queryParams: object): object; assignResourceRelatedQueryParams(queryParams: object): object; assignAttributes(values: object): object; attributes(): { all: any; read: any; readWrite: any; }; build(params?: object): Collection & BaseResource; create(attributes: object): Promise; each(iteratee: any): any; fields(): Collection; find(primaryKey: string, options?: Options): Promise; findBy(conditions: object): Promise>; first(n?: number, options?: Options): Promise & JSONAPIResponse>>; includes(...attribute: string[]): BaseResource; isA(klass: BaseResource): boolean; klass(): BaseResource; last(n?: number, options?: Options): Promise & JSONAPIResponse>>; limit(n?: number): BaseResource; links(): { related: string; }; offset(n?: number): BaseResource; order(args: object): BaseResource; page(n: number): BaseResource; perPage(n: number): BaseResource; primaryKey: string; queryParams(): object; resetQueryParams(): object; select(...params: Array>): BaseResource; where(options?: object): BaseResource; update(attrs: object, callback?: any): Promise; withCredentials({ accessToken, endpoint }: InitConfig): BaseResource; setCustomInterceptors(interceptors: InitConfig['interceptors']): BaseResource; } export interface Relation extends Collection { base: Base; define(): any; queryName: string; __queryParams: { include: any[]; }; } export interface LinksRelationships { first: string; next: string; last: string; } export declare type MetaInformation = { pageCount?: number; mode?: string; recordCount?: number; }; export interface CollectionResponse { __collection: Collection[]; __links: LinksRelationships; hasNextPage: () => boolean; hasPrevPage: () => boolean; links(): LinksRelationships | null; nextPage(): Promise>; prevPage(): Promise>; toCollection(): Collection; all(): T[]; clear(): []; clone(): T[]; compact(iteratee: any): any; delete(): any; detect(predicate: any): any; each(iteratee: any): any; empty(): boolean; first(): T; first(n: number): T[]; flatten(): any; get(index: number): T; includes(...attribute: string[]): CollectionResponse; load(): Promise>; indexOf(item: any): any; inject(memo: object, interatee: any): any; join(): string; last(): T; last(n: number): T[]; map(iteratee: (param: T) => any): void; pop(): T; push(): number; replace(original: any, next: any): any; select(predicate?: any): CollectionResponse; set(index: number, item: BaseResource): Collection; shift(): T; toArray(): T[]; unshift(): T; size(): number; getHeaders(): HeadersResponse; getMetaInfo(): MetaInformation; pageCount(): MetaInformation['pageCount']; recordCount(): MetaInformation['recordCount']; withCredentials({ accessToken, endpoint }: InitConfig): CollectionResponse; } export interface CollectionProxy

extends Pick, 'where'> { all(): Promise>; load(): Promise>; empty(): boolean; size(): boolean; target(): CollectionResponse

; toArray(): P[]; find(primaryKey: string): Promise

; findBy(conditions: object): Promise

; includes(...attribute: string[]): CollectionProxy

; } export interface Collection { association(name: string): any; attributes(): object; changed(): boolean; changedFields(): Collection; clone(): Collection; destroy(): Collection; errors(): Errors; hasAttribute(attribute: string): boolean; isA(klass: BaseResource): boolean; klass(): BaseResource; links(): { related: string; self: string; }; newResource(): boolean; map(iteratee: (param: Collection) => any): void; persisted(): any; queryParams(): object; queryParamsForReflection(): any; reload(): any; save(callback?: any): any; update(attrs: object, callback?: any): Collection; valid(): boolean; } export declare type SingleRelationship = (R & Promise) | null; export declare type MultiRelationship = (CollectionProxy & Promise>) | null; export interface CreateResource { createResource(resource: Base): BaseResource; } export interface Errors { (): T; base: T; empty(): boolean; toArray(): T[]; toCollection(): Collection; } export default interface Library extends CreateResource { customRequests: { [key: string]: { [key: string]: { [key: string]: object; }; }; }; interface: { toCamelCase: (value: T) => T; }; singleRequest: boolean; baseUrl: string; headers: { Authorization: string; }; Base: Base; customInterceptors?: InitConfig['interceptors']; options?: Options; } export {};