UNPKG

@mgrcto/angular-odata-v401

Version:

Odata Library for Angular made with Angular CLI

271 lines (259 loc) 9.99 kB
import * as i0 from '@angular/core'; import { ModuleWithProviders } from '@angular/core'; import * as i1 from '@angular/common'; import { Observable } from 'rxjs'; import { HttpHeaders, HttpParams, HttpResponse, HttpClient } from '@angular/common/http'; declare class AngularOdataV401Module { static forRoot(): ModuleWithProviders<AngularOdataV401Module>; static ɵfac: i0.ɵɵFactoryDeclaration<AngularOdataV401Module, never>; static ɵmod: i0.ɵɵNgModuleDeclaration<AngularOdataV401Module, never, [typeof i1.CommonModule], never>; static ɵinj: i0.ɵɵInjectorDeclaration<AngularOdataV401Module>; } interface ODataMetadataResult<T> { data: T[]; count: number; nextLink: string; deltaLink: string; id: string; etag: string; readLink: string; editLink: string; navigationLink: string; associationLink: string; type: string; } interface ODataPagedResult<T> { data: T[]; count: number; nextLink: string; } interface IODataResponseModel<T> { [name: string]: any; value: T[]; } declare class KeyConfigs { filter: string; top: string; skip: string; orderBy: string; select: string; search: string; expand: string; apply: string; count: string; maxPerPage: string; metadata: string; responseCount: string; responseNextLink: string; } declare class ODataConfiguration { private readonly _postHeaders; private _baseUrl; keys: KeyConfigs; defaultRequestOptions: { headers: HttpHeaders; observe: 'response'; params?: HttpParams; reportProgress?: boolean; responseType?: 'json'; withCredentials?: boolean; }; postRequestOptions: { headers: HttpHeaders; observe: 'response'; params?: HttpParams; reportProgress?: boolean; responseType?: 'json'; withCredentials?: boolean; }; customRequestOptions: { headers: HttpHeaders; observe: 'response'; params?: HttpParams; reportProgress?: boolean; responseType?: 'json'; withCredentials?: boolean; }; set baseUrl(baseUrl: string); get baseUrl(): string; getEntitiesUri(typeName: string): string; getEntityUri(key: any, typeName: string): string; getEntityPath(key: any, typeName: string): string; handleError(err: any, caught: any): void; extractQueryResultDataAsNumber(res: HttpResponse<number>): number; extractQueryResultData<T>(res: HttpResponse<IODataResponseModel<T>>): T[]; extractQueryResultDataWithCount<T>(res: HttpResponse<IODataResponseModel<T>>): ODataPagedResult<T>; extractQueryResultDataWithMetadata<T>(res: HttpResponse<IODataResponseModel<T>>): ODataMetadataResult<T>; private sanitizeTypeName; static ɵfac: i0.ɵɵFactoryDeclaration<ODataConfiguration, never>; static ɵprov: i0.ɵɵInjectableDeclaration<ODataConfiguration>; } declare abstract class ODataOperation<T> { protected typeName: string; protected config: ODataConfiguration; protected http: HttpClient; private _expand; private _select; constructor(typeName: string, config: ODataConfiguration, http: HttpClient); Expand(expand: string | string[]): this; /** * Selects Entities. If String is separated by "/" the first part will be expanded and the second part will be selected in the expand. * @param select * @returns ODataOperation<T> */ Select(select: string | string[]): this; protected getParams(aParams?: HttpParams): HttpParams; protected handleResponse(entity: Observable<HttpResponse<T>>): Observable<T>; protected getDefaultRequestOptions(): { headers?: HttpHeaders; observe: 'response'; params?: HttpParams; reportProgress?: boolean; responseType?: 'json'; withCredentials?: boolean; }; protected getPostRequestOptions(): { headers?: HttpHeaders; observe: 'response'; params?: HttpParams; reportProgress?: boolean; responseType?: 'json'; withCredentials?: boolean; }; protected abstract Exec(): Observable<any>; protected abstract GetUrl(): string; protected GeneratePostUrl(entitiesUri: string): string; protected GenerateUrl(entitiesUri: string): string; protected toStringArray(input: string | string[]): string[]; protected toCommaString(input: string | string[]): string; private extractData; } declare abstract class OperationWithKey<T> extends ODataOperation<T> { protected _typeName: string; protected config: ODataConfiguration; protected http: HttpClient; protected entityKey: any; constructor(_typeName: string, config: ODataConfiguration, http: HttpClient, entityKey: any); protected getEntityUri(): string; GetUrl(): string; } declare abstract class OperationWithEntity<T> extends ODataOperation<T> { protected _typeName: string; protected config: ODataConfiguration; protected http: HttpClient; protected entity: T; constructor(_typeName: string, config: ODataConfiguration, http: HttpClient, entity: T); protected getEntitiesUri(): string; GetUrl(): string; } declare abstract class OperationWithKeyAndEntity<T> extends OperationWithKey<T> { protected _typeName: string; protected config: ODataConfiguration; protected http: HttpClient; protected entityKey: string; protected entity: T; constructor(_typeName: string, config: ODataConfiguration, http: HttpClient, entityKey: string, entity: T); protected getEntityUri(): string; } declare class GetOperation<T> extends OperationWithKey<T> { Exec(): Observable<T>; } declare class PostOperation<T> extends OperationWithEntity<T> { Exec(): Observable<T>; GetUrl(): string; } declare class PatchOperation<T> extends OperationWithKeyAndEntity<T> { Exec(): Observable<T>; GetUrl(): string; } declare class PutOperation<T> extends OperationWithKeyAndEntity<T> { Exec(): Observable<T>; GetUrl(): string; } declare class DeleteOperation<T> extends OperationWithKey<T> { Exec(): Observable<T>; } declare enum ODataExecReturnType { Array = 0, Count = 1, PagedResult = 2, MetadataResult = 3 } interface CustomOption { key: string; value: any; } declare class ODataQuery<T> extends ODataOperation<T> { private _filter; private _top; private _skip; private _search; private _orderBy; private _apply; private _entitiesUri; private _maxPerPage; private _customQueryOptions; private _customQueryHeaders; constructor(typeName: string, config: ODataConfiguration, http: HttpClient); Filter(filter: string): ODataQuery<T>; Search(search: string): ODataQuery<T>; Top(top: number): ODataQuery<T>; Skip(skip: number): ODataQuery<T>; OrderBy(orderBy: string | string[]): ODataQuery<T>; MaxPerPage(maxPerPage: number): ODataQuery<T>; Apply(apply: string | string[]): ODataQuery<T>; CustomQueryOptions(customOptions: CustomOption | CustomOption[]): ODataQuery<T>; CustomQueryHeaders(customHeaders: CustomOption | CustomOption[]): ODataQuery<T>; GetUrl(returnType?: ODataExecReturnType): string; Exec(): Observable<T[]>; Exec(returnType: ODataExecReturnType.Count): Observable<number>; Exec(returnType: ODataExecReturnType.PagedResult): Observable<ODataPagedResult<T>>; Exec(returnType: ODataExecReturnType.MetadataResult): Observable<ODataMetadataResult<T>>; ExecWithCount(): Observable<ODataPagedResult<T>>; NextPage(pagedResult: ODataPagedResult<T>): Observable<ODataPagedResult<T>>; private execGetCount; private execGetArrayDataWithCount; private execGetArrayDataWithMetadata; private execGetArrayData; private getQueryRequestOptions; private getQueryHeaders; private getQueryParams; private extractDataAsNumber; private extractArrayData; private extractArrayDataWithCount; private extractArrayDataWithMetadata; private checkReservedCustomQueryOptionKey; } declare class ODataService<T> { private _typeName; private _http; private config; private _entitiesUri; constructor(_typeName: string, _http: HttpClient, config: ODataConfiguration); get TypeName(): string; Get(key: any): GetOperation<T>; Post<T>(entity: T): PostOperation<T>; Patch<T>(entity: T, key: any): PatchOperation<T>; Put<T>(entity: T, key: any): PutOperation<T>; Delete(key: any): DeleteOperation<T>; CustomAction(key: any, actionName: string, postdata: any): Observable<any>; CustomCollectionAction(actionName: string, postdata: any): Observable<any>; CustomFunction(key: any, functionName: string, parameters?: any): Observable<any>; CustomCollectionFunction(functionName: string, parameters?: any): Observable<any>; getNestedEntityService<U>(key: string, typeName: string): ODataService<U>; ItemProperty<T = any>(key: string, propertyName: string): Observable<T | null>; Query(): ODataQuery<T>; protected getEntityUri(key: any): string; protected handleResponse<TResponse>(entity: Observable<HttpResponse<TResponse>>): Observable<TResponse>; private extractData; } declare class ODataServiceFactory { private http; private config; constructor(http: HttpClient, config: ODataConfiguration); CreateService<T>(typeName: string, config?: ODataConfiguration): ODataService<T>; static ɵfac: i0.ɵɵFactoryDeclaration<ODataServiceFactory, never>; static ɵprov: i0.ɵɵInjectableDeclaration<ODataServiceFactory>; } export { AngularOdataV401Module, DeleteOperation, GetOperation, ODataConfiguration, ODataExecReturnType, ODataOperation, ODataQuery, ODataService, ODataServiceFactory, OperationWithEntity, OperationWithKey, OperationWithKeyAndEntity, PatchOperation, PostOperation, PutOperation }; export type { IODataResponseModel, ODataMetadataResult, ODataPagedResult };