UNPKG

ngx-airbrush

Version:

Angular client for jsonapi/Graphiti backends

45 lines (44 loc) 1.84 kB
import { HttpClient, HttpResponse, HttpParams } from '@angular/common/http'; import { Observable } from 'rxjs'; import { ServiceDecoratorOptions, ModelDecoratorOptions } from './decorators/option.interfaces'; import { ResourceBase } from './resource-base.model'; import { JsonapiResponse } from './interfaces/jsonapi.interface'; import { Scope } from './scope'; import { SortScope, FieldScope, FilterScope, StatsScope, IncludeScope } from './interfaces/query.interface'; export interface Response extends HttpResponse<JsonapiResponse> { } export declare abstract class JsonapiBaseService<T extends ResourceBase> { protected http: HttpClient; abstract baseUrl: string; abstract className: any; constructor(http: HttpClient); all(options?: { params?: HttpParams; }): Observable<T[]>; all(options: { params?: HttpParams; metadata: true; }): Observable<{ data: T[]; meta: any; }>; find(id: string, params?: HttpParams): Observable<T>; save(model: T): Observable<T>; delete(id: string): Observable<any>; protected extractMeta(response: Response): Record<string, any>; protected extract(response: Response): T | T[]; protected deserializeModel(data: any): T; protected handleError(error: any): Observable<any>; protected buildUrl(id?: string): string; private getModelType; getModelConfig(): ModelDecoratorOptions; getServiceConfig(): ServiceDecoratorOptions; protected successful(response: Response): Response; page(pageNumber: number): Scope<T>; per(size: number): Scope<T>; where(clause: FilterScope): Scope<T>; stats(clause: StatsScope): Scope<T>; order(clause: SortScope | string): Scope<T>; select(clause: FieldScope | string | string[]): Scope<T>; includes(clause: IncludeScope): Scope<T>; }