import { Builder } from "./Builder"; import { JsonApiDoc } from "./JsonApiDoc"; import { PluralResponse } from "./response/PluralResponse"; import { SingularResponse } from "./response/SingularResponse"; import { PaginationStrategy } from "./PaginationStrategy"; import { SaveResponse } from "./response/SaveResponse"; import { ToManyRelation } from "./relation/ToManyRelation"; import { ToOneRelation } from "./relation/ToOneRelation"; import { HttpClient } from "./httpclient/HttpClient"; export declare abstract class Model { private type; /** * @type {string} The JSON-API type, choose plural, lowercase alphabetic only, e.g. 'artists' */ protected abstract jsonApiType: string; /** * @type {number} the page size */ protected static pageSize: number; /** * @type {PaginationStrategy} the pagination strategy */ protected static paginationStrategy: PaginationStrategy; /** * @type {string} The number query parameter name. By default: 'page[number]' */ protected static paginationPageNumberParamName: string; /** * @type {string} The size query parameter name. By default: 'page[size]' */ protected static paginationPageSizeParamName: string; /** * @type {string} The offset query parameter name. By default: 'page[offset]' */ protected static paginationOffsetParamName: string; /** * @type {string} The limit query parameter name. By default: 'page[limit]' */ protected static paginationLimitParName: string; private id; private relations; private attributes; private httpClient; protected readOnlyAttributes: string[]; protected dates: { [key: string]: string; }; private static dateFormatter; constructor(); private initHttpClient(); static get(page?: number): Promise; static first(): Promise; static find(id: string | number): Promise; static with(attribute: any): Builder; static where(attribute: string, value: string): Builder; static orderBy(attribute: string, direction?: string): Builder; static option(queryParameter: string, value: string): Builder; save(): Promise; create(): Promise; delete(): Promise; /** * @returns {string} e.g. 'http://www.foo.com/bar/' */ abstract getJsonApiBaseUrl(): string; /** * Allows you to get the current HTTP client (AxiosHttpClient by default), e.g. to alter its configuration. * @returns {HttpClient} */ getHttpClient(): HttpClient; /** * Allows you to use any HTTP client library, as long as you write a wrapper for it that implements the interfaces * HttpClient, HttpClientPromise and HttpClientResponse. * @param httpClient */ setHttpClient(httpClient: HttpClient): void; getJsonApiType(): string; populateFromJsonApiDoc(jsonApiDoc: JsonApiDoc): void; static getPageSize(): number; static getPaginationStrategy(): PaginationStrategy; static getPaginationPageNumberParamName(): string; static getPaginationPageSizeParamName(): string; static getPaginationOffsetParamName(): string; static getPaginationLimitParamName(): string; protected getRelation(relationName: string): any; setRelation(relationName: string, value: any): void; getAttributes(): { [key: string]: any; }; protected getAttribute(attributeName: string): any; protected getAttributeAsDate(attributeName: string): any; private isDateAttribute(attributeName); protected setAttribute(attributeName: string, value: any): void; /** * We use a single instance of DateFormatter, which is stored as a static property on Model, to minimize the number * of times we need to instantiate the DateFormatter class. By using this getter a DateFormatter is instantiated * only when it is used at least once. * * @returns DateFormatter */ private static getDateFormatter(); getApiId(): string; setApiId(id: string): void; protected hasMany(relatedType: typeof Model): ToManyRelation; protected hasMany(relatedType: typeof Model, relationName: string): ToManyRelation; protected hasOne(relatedType: typeof Model): ToOneRelation; protected hasOne(relatedType: typeof Model, relationName: string): ToOneRelation; }