import { Injector } from '@angular/core'; import { HttpClient } from '@angular/common/http'; import { Observable } from 'rxjs'; import { SerializerService } from './serializer.service'; import { Dictionary } from './utility-types'; import { AngularDjangoConfig } from './angular-django.module'; /** * Page returned by apì server */ interface ApiPage { count: number; page_size?: number; next: string | null; previous: string | null; results: object[]; } /** * POST Options returned by api server. It has info about serializer. */ export declare class OptionField { type: string; required: boolean; read_only: boolean; label: string; choices?: { value: string | number; display_name: string; }[]; children?: Dictionary; } export interface OptionFilterField { name: string; in: string; required: boolean; schema: { type: string; }; type?: string; label: string; read_only?: boolean; choices?: { value: string | number; display_name: string; }[]; } /** * Options returned by api server. */ export declare class Options { actions: { POST: Dictionary; description: string; name: string; }; filters: Dictionary; parsers: string[]; renders: string[]; constructor(options: any); get optionsField(): Dictionary; getField(fieldName: string): OptionField; getDisplay(fieldName: string, value: any): string; } /** * Iterable page. It has methods to get the current and next page. */ export declare class Page extends Array { apiService: ApiService; count: number; pagesCount: number | null; pagesSize: number | null; hasPreviousPage: boolean; hasNextPage: boolean; get currentPage(): number | null; constructor(apiService: ApiService, items?: Array); first(): any; previous(): Observable>; next(): Observable>; } /** * set serializer in Api class */ export declare function Api(serializer: any): (constructor: any) => void; export declare class ApiService { injector: Injector; http: HttpClient; angularDjangoConfig: AngularDjangoConfig; serializer: any; url: string; queryParams: any; constructor(injector: Injector); /** * Alias for retrieve. Retrieve a element by primary key. * * @param pk: element primary key */ get(pk: any): Observable; /** * Retrieve a element by primary key. * * @param pk: element primary key */ retrieve(pk: any): Observable; /** * Create a element using data * * @param data: a object with item parameters */ create(data: {}): Observable; /** * List elements with api filters. Only one page is returned, use `page()` for change the * api page. */ list(): Observable>; /** * List elements with api filters */ all(): Observable; /** * Get options from server. It has information about the api and the serializer. * Options are cached. */ options(): Observable; /** * Update a object by its id using data. All parameters are overwrite using * PUT method. * * @param pk: object primary key. * @param data: parameters for overwrite. */ update(pk: number | string, data: Dictionary): Observable; /** * Update a object by its id using data. All parameters are overwrite using * PATCH method. * * @param pk: object primary key. * @param data: parameters for overwrite. */ partial_update(pk: number | string, data: Dictionary): Observable; /** * Delete a object by its id. * * @param pk: object primary key. */ delete(pk: number | string): Observable; /** * Change the sort order for listings * @param orderList: column names */ orderBy(...orderList: string[]): ApiService; /** * Search in list using a query term * @param query: search term */ search(query: string): ApiService; /** * Filter on the listings using the set parameters * @param params: parameters dictionary */ filter(params: Dictionary): ApiService; /** * Set page for list * @param page: page number in list * @param pageSize: page size for pages returned by api */ page(page?: number, pageSize?: number | null): any; /** * Return a new apiService for not to change the original instance */ copy(): any; /** * Compare two ApiService instances * @param other: other ApiService */ isEqual(other: ApiService): boolean; getFormFields(fields?: any): any; getFilterFormFields(fields?: any, excludeFields?: string[]): any; defaultHttpOptions(): { headers: {}; }; /** * Transform the observable object or objects with the API serializer. * @param observable: observable to add the pipe to. * @param listMode: Apply the serializer to an object (retrieve) or several (list). */ pipeHttp(observable: Observable, listMode?: boolean): Observable>; convert(data: object | object[] | ApiPage, listMode: boolean): Page | SerializerService; setParams(params: any): void; get rootUrl(): string; get absoluteUrl(): string; get hasOptions(): boolean; get cachedOptions(): Options | null; private get optionsObserver(); getOptionField(name: any): null | OptionField; getFiltersOptionField(name: any): null | OptionFilterField; getUrlDetail(pk: string | number): string; getUrlList(): string; } export {};