UNPKG

@mgrcto/angular-odata-v401

Version:

Odata Library for Angular made with Angular CLI

1 lines 62.4 kB
{"version":3,"file":"mgrcto-angular-odata-v401.mjs","sources":["../../../projects/angular-odata-v401/src/lib/angular-odata-v401.module.ts","../../../projects/angular-odata-v401/src/lib/odata/angularODataOperation.ts","../../../projects/angular-odata-v401/src/lib/odata/angularODataEnums.ts","../../../projects/angular-odata-v401/src/lib/odata/angularODataQuery.ts","../../../projects/angular-odata-v401/src/lib/odata/angularODataUtils.ts","../../../projects/angular-odata-v401/src/lib/odata/angularODataService.ts","../../../projects/angular-odata-v401/src/lib/odata/angularODataConfiguration.ts","../../../projects/angular-odata-v401/src/lib/odata/angularODataServiceFactory.ts","../../../projects/angular-odata-v401/src/public-api.ts","../../../projects/angular-odata-v401/src/mgrcto-angular-odata-v401.ts"],"sourcesContent":["import { CommonModule } from '@angular/common';\r\nimport { ModuleWithProviders, NgModule } from '@angular/core';\r\n\r\n\r\n\r\n@NgModule({\r\n declarations: [\r\n ],\r\n imports: [ CommonModule\r\n ],\r\n exports: [\r\n ]\r\n})\r\nexport class AngularOdataV401Module { \r\n\r\n public static forRoot(): ModuleWithProviders<AngularOdataV401Module> {\r\n return {\r\n ngModule: AngularOdataV401Module\r\n };\r\n }\r\n\r\n}\r\n","import { HttpClient, HttpHeaders, HttpParams, HttpResponse } from '@angular/common/http';\r\nimport { Observable, throwError } from 'rxjs';\r\nimport { catchError, map } from 'rxjs/operators';\r\nimport { ODataConfiguration } from './angularODataConfiguration';\r\n\r\nexport abstract class ODataOperation<T> {\r\n private _expand: string[] = [];\r\n private _select: string[] = [];\r\n\r\n constructor(protected typeName: string, protected config: ODataConfiguration, protected http: HttpClient) {\r\n }\r\n \r\n public Expand(expand: string | string[]) {\r\n if (expand) {\r\n this._expand = this.toStringArray(expand);\r\n }\r\n return this;\r\n }\r\n /**\r\n * Selects Entities. If String is separated by \"/\" the first part will be expanded and the second part will be selected in the expand.\r\n * @param select \r\n * @returns ODataOperation<T>\r\n */ \r\n public Select(select: string | string[]) {\r\n if (select) {\r\n this._select = this.toStringArray(select);\r\n }\r\n return this;\r\n }\r\n \r\n protected getParams(aParams? : HttpParams): HttpParams {\r\n const expandData = new Map<string, Array<string>>();\r\n const normalSelects: Array<string> = [];\r\n \r\n\r\n this._expand.forEach((name) => expandData.set(name, []));\r\n\r\n this._select.forEach((select: string) => {\r\n const items: string[] = select.split('/');\r\n\r\n // Select contains string like: `Boss/Name`\r\n if (items.length > 1) {\r\n const expandName = items[0];\r\n const propertyName = items[1];\r\n\r\n if (!expandData.has(expandName)) {\r\n expandData.set(expandName, []);\r\n }\r\n \r\n expandData.get(expandName)!.push(propertyName);\r\n }\r\n else {\r\n // Select is just a simple string like: `Boss`\r\n normalSelects.push(select);\r\n }\r\n });\r\n\r\n let params = (aParams && Object.keys(aParams).length>0)?aParams:new HttpParams();\r\n\r\n const expands: Array<string> = [];\r\n expandData.forEach((val,key)=>{\r\n if (val.length) {\r\n expands.push(`${key}(${this.config.keys.select}=${this.toCommaString(val)})`);\r\n return;\r\n }\r\n expands.push(key);\r\n });\r\n\r\n if (expands.length) {\r\n params = params.append(this.config.keys.expand, this.toCommaString(expands));\r\n }\r\n\r\n if (normalSelects.length) {\r\n params = params.append(this.config.keys.select, this.toCommaString(normalSelects));\r\n }\r\n\r\n return params;\r\n }\r\n\r\n protected handleResponse(entity: Observable<HttpResponse<T>>): Observable<T> {\r\n return entity\r\n .pipe(\r\n map(this.extractData),\r\n catchError((err: any, caught: Observable<T>) => {\r\n if (this.config.handleError) {\r\n this.config.handleError(err, caught);\r\n }\r\n return throwError(err);\r\n })\r\n );\r\n }\r\n\r\n protected getDefaultRequestOptions(): {\r\n headers?: HttpHeaders;\r\n observe: 'response';\r\n params?: HttpParams;\r\n reportProgress?: boolean;\r\n responseType?: 'json';\r\n withCredentials?: boolean;\r\n } {\r\n const options = Object.assign({}, this.config.defaultRequestOptions);\r\n options.params = this.getParams(options.params);\r\n\r\n return options;\r\n }\r\n\r\n protected getPostRequestOptions(): {\r\n headers?: HttpHeaders;\r\n observe: 'response';\r\n params?: HttpParams;\r\n reportProgress?: boolean;\r\n responseType?: 'json';\r\n withCredentials?: boolean;\r\n } {\r\n const options = Object.assign({}, this.config.postRequestOptions);\r\n options.params = this.getParams(options.params);\r\n\r\n return options;\r\n }\r\n\r\n protected abstract Exec(): Observable<any>;\r\n\r\n protected abstract GetUrl(): string;\r\n\r\n protected GeneratePostUrl(entitiesUri: string): string {\r\n const params: HttpParams = this.getParams(this.config.postRequestOptions.params);\r\n if (params.keys().length > 0) {\r\n return `${entitiesUri}?${params}`;\r\n }\r\n\r\n return entitiesUri;\r\n }\r\n protected GenerateUrl(entitiesUri: string): string {\r\n const params: HttpParams = this.getParams( this.config.defaultRequestOptions.params);\r\n if (params.keys().length > 0) {\r\n return `${entitiesUri}?${params}`;\r\n }\r\n\r\n return entitiesUri;\r\n }\r\n\r\n protected toStringArray(input: string | string[]): string[] {\r\n if (!input) {\r\n return [];\r\n }\r\n\r\n if (input instanceof String || typeof input === 'string') {\r\n return input.split(',').map(s => s.trim());\r\n }\r\n\r\n if (input instanceof Array) {\r\n return input;\r\n }\r\n\r\n return [];\r\n }\r\n\r\n protected toCommaString(input: string | string[]): string {\r\n if (input instanceof String || typeof input === 'string') {\r\n return input as string;\r\n }\r\n\r\n if (input instanceof Array) {\r\n return input.join();\r\n }\r\n \r\n return \"\";\r\n }\r\n\r\n private extractData(res: HttpResponse<T>): T {\r\n if (res.status < 200 || res.status >= 300) {\r\n throw new Error('Bad response status: ' + res.status);\r\n }\r\n\r\n const body: any = res.body;\r\n return body || {};\r\n }\r\n}\r\n\r\nexport abstract class OperationWithKey<T> extends ODataOperation<T> {\r\n constructor(protected _typeName: string,\r\n protected override config: ODataConfiguration,\r\n protected override http: HttpClient,\r\n protected entityKey: any) {\r\n super(_typeName, config, http);\r\n }\r\n\r\n protected getEntityUri(): string {\r\n return this.config.getEntityUri(this.entityKey, this.typeName);\r\n }\r\n\r\n public GetUrl(): string {\r\n return this.GenerateUrl(this.getEntityUri());\r\n }\r\n}\r\n\r\nexport abstract class OperationWithEntity<T> extends ODataOperation<T> {\r\n constructor(protected _typeName: string,\r\n protected override config: ODataConfiguration,\r\n protected override http: HttpClient,\r\n protected entity: T) {\r\n super(_typeName, config, http);\r\n }\r\n\r\n protected getEntitiesUri(): string {\r\n return this.config.getEntitiesUri(this._typeName);\r\n }\r\n\r\n public GetUrl(): string {\r\n return this.GenerateUrl(this.getEntitiesUri());\r\n }\r\n}\r\n\r\nexport abstract class OperationWithKeyAndEntity<T> extends OperationWithKey<T> {\r\n constructor(protected override _typeName: string,\r\n protected override config: ODataConfiguration,\r\n protected override http: HttpClient,\r\n protected override entityKey: string,\r\n protected entity: T) {\r\n super(_typeName, config, http, entityKey);\r\n }\r\n\r\n protected override getEntityUri(): string {\r\n return this.config.getEntityUri(this.entityKey, this._typeName);\r\n }\r\n}\r\n\r\nexport class GetOperation<T> extends OperationWithKey<T> {\r\n public Exec(): Observable<T> {\r\n return super.handleResponse(this.http.get<T>(this.getEntityUri(), this.getDefaultRequestOptions()));\r\n }\r\n}\r\n\r\nexport class PostOperation<T> extends OperationWithEntity<T> {\r\n public Exec(): Observable<T> {\r\n const body = this.entity ? JSON.stringify(this.entity) : null;\r\n\r\n return super.handleResponse(this.http.post<T>(this.getEntitiesUri(), body, this.getPostRequestOptions()));\r\n }\r\n public override GetUrl(): string {\r\n return this.GeneratePostUrl(this.getEntitiesUri());\r\n }\r\n}\r\n\r\nexport class PatchOperation<T> extends OperationWithKeyAndEntity<T> {\r\n public Exec(): Observable<T> {\r\n const body = this.entity ? JSON.stringify(this.entity) : null;\r\n\r\n return super.handleResponse(this.http.patch<T>(this.getEntityUri(), body, this.getPostRequestOptions()));\r\n }\r\n public override GetUrl(): string {\r\n return this.GeneratePostUrl(this.getEntityUri());\r\n }\r\n}\r\n\r\nexport class PutOperation<T> extends OperationWithKeyAndEntity<T> {\r\n public Exec(): Observable<T> {\r\n const body = this.entity ? JSON.stringify(this.entity) : null;\r\n\r\n return super.handleResponse(this.http.put<T>(this.getEntityUri(), body, this.getPostRequestOptions()));\r\n }\r\n public override GetUrl(): string {\r\n return this.GeneratePostUrl(this.getEntityUri());\r\n }\r\n}\r\n\r\nexport class DeleteOperation<T> extends OperationWithKey<T>{\r\n public Exec(): Observable<T> {\r\n return super.handleResponse(this.http.delete<T>(this.getEntityUri(), this.config.defaultRequestOptions));\r\n }\r\n}\r\n","export enum ODataExecReturnType {\r\n\r\n // Default\r\n Array = 0,\r\n\r\n Count = 1,\r\n\r\n PagedResult = 2,\r\n\r\n MetadataResult = 3\r\n}\r\n","import { Observable, throwError } from 'rxjs';\r\nimport { catchError, map } from 'rxjs/operators';\r\n\r\nimport { HttpClient, HttpErrorResponse, HttpHeaders, HttpParams, HttpResponse } from '@angular/common/http';\r\n\r\nimport { ODataConfiguration } from './angularODataConfiguration';\r\nimport { ODataExecReturnType } from './angularODataEnums';\r\nimport { ODataMetadataResult } from './angularODataMetadataResult';\r\nimport { ODataOperation } from './angularODataOperation';\r\nimport { ODataPagedResult } from './angularODataPagedResult';\r\nimport { IODataResponseModel } from './angularODataResponseModel';\r\n\r\nexport interface CustomOption{\r\n key:string;\r\n value:any;\r\n}\r\n\r\nexport class ODataQuery<T> extends ODataOperation<T> {\r\n\r\n private _filter: string = \"\";\r\n private _top: number = 0;\r\n private _skip: number = 0;\r\n private _search: string = \"\";\r\n private _orderBy: string[] = [];\r\n private _apply: string[] = [];\r\n private _entitiesUri: string;\r\n private _maxPerPage: number = 0;\r\n private _customQueryOptions: CustomOption[] = [];\r\n private _customQueryHeaders: CustomOption[] = [];\r\n\r\n constructor(typeName: string, config: ODataConfiguration, http: HttpClient) {\r\n super(typeName, config, http);\r\n\r\n this._entitiesUri = config.getEntitiesUri(this.typeName);\r\n }\r\n\r\n public Filter(filter: string): ODataQuery<T> {\r\n if (filter) {\r\n this._filter = filter;\r\n }\r\n return this;\r\n }\r\n\r\n public Search(search: string): ODataQuery<T> {\r\n if (search) {\r\n this._search = search;\r\n }\r\n return this;\r\n }\r\n\r\n public Top(top: number): ODataQuery<T> {\r\n if (top > -1) {\r\n this._top = top;\r\n }\r\n return this;\r\n }\r\n\r\n public Skip(skip: number): ODataQuery<T> {\r\n if (skip > -1) {\r\n this._skip = skip;\r\n }\r\n return this;\r\n }\r\n\r\n public OrderBy(orderBy: string | string[]): ODataQuery<T> {\r\n if (orderBy) {\r\n this._orderBy = this.toStringArray(orderBy);\r\n }\r\n return this;\r\n }\r\n\r\n public MaxPerPage(maxPerPage: number): ODataQuery<T> {\r\n if (maxPerPage > -1) {\r\n this._maxPerPage = maxPerPage;\r\n }\r\n return this;\r\n }\r\n\r\n public Apply(apply: string | string[]): ODataQuery<T> {\r\n if (apply) {\r\n this._apply = this.toStringArray(apply);\r\n }\r\n return this;\r\n }\r\n\r\n public CustomQueryOptions(customOptions: CustomOption | CustomOption[]): ODataQuery<T> {\r\n if (customOptions) {\r\n this._customQueryOptions = Array.isArray(customOptions) ? customOptions : [customOptions];\r\n }\r\n return this;\r\n }\r\n\r\n public CustomQueryHeaders(customHeaders: CustomOption | CustomOption[]): ODataQuery<T> {\r\n if (customHeaders) {\r\n this._customQueryHeaders = Array.isArray(customHeaders) ? customHeaders : [customHeaders];\r\n }\r\n return this;\r\n }\r\n\r\n public GetUrl(returnType?: ODataExecReturnType): string {\r\n let url: string = this._entitiesUri;\r\n if (returnType === ODataExecReturnType.Count) {\r\n url = `${url}/${this.config.keys.count}`;\r\n }\r\n const params: HttpParams = this.getQueryParams(this.config.defaultRequestOptions.params);\r\n if (params.keys().length > 0) {\r\n return `${url}?${params}`;\r\n }\r\n\r\n return url;\r\n }\r\n\r\n public Exec(): Observable<T[]>;\r\n public Exec(returnType: ODataExecReturnType.Count): Observable<number>;\r\n public Exec(returnType: ODataExecReturnType.PagedResult): Observable<ODataPagedResult<T>>;\r\n public Exec(returnType: ODataExecReturnType.MetadataResult): Observable<ODataMetadataResult<T>>;\r\n public Exec(returnType?: ODataExecReturnType): Observable<T[] | ODataPagedResult<T> | ODataMetadataResult<T> | number> {\r\n const requestOptions: {\r\n headers?: HttpHeaders;\r\n observe: 'response';\r\n params?: HttpParams;\r\n reportProgress?: boolean;\r\n responseType?: 'json';\r\n withCredentials?: boolean;\r\n } = this.getQueryRequestOptions(returnType);\r\n switch (returnType) {\r\n case ODataExecReturnType.Count:\r\n return this.execGetCount(requestOptions);\r\n\r\n case ODataExecReturnType.PagedResult:\r\n return this.execGetArrayDataWithCount(this._entitiesUri, requestOptions);\r\n\r\n case ODataExecReturnType.MetadataResult:\r\n return this.execGetArrayDataWithMetadata(this._entitiesUri, requestOptions);\r\n\r\n default:\r\n return this.execGetArrayData(requestOptions);\r\n }\r\n }\r\n\r\n public ExecWithCount(): Observable<ODataPagedResult<T>> {\r\n return this.Exec(ODataExecReturnType.PagedResult);\r\n }\r\n\r\n public NextPage(pagedResult: ODataPagedResult<T>): Observable<ODataPagedResult<T>> {\r\n const requestOptions: {\r\n headers?: HttpHeaders;\r\n observe: 'response';\r\n params?: HttpParams;\r\n reportProgress?: boolean;\r\n responseType?: 'json';\r\n withCredentials?: boolean;\r\n } = this.getQueryRequestOptions(ODataExecReturnType.PagedResult);\r\n\r\n return this.execGetArrayDataWithCount(pagedResult.nextLink, requestOptions);\r\n }\r\n\r\n private execGetCount(requestOptions: {\r\n headers?: HttpHeaders;\r\n observe: 'response';\r\n params?: HttpParams;\r\n reportProgress?: boolean;\r\n responseType?: 'json';\r\n withCredentials?: boolean;\r\n }): Observable<number> {\r\n const countUrl = `${this._entitiesUri}/${this.config.keys.count}`;\r\n return this.http.get<number>(countUrl, requestOptions)\r\n .pipe(\r\n map(res => this.extractDataAsNumber(res, this.config)),\r\n catchError((err: any, caught: Observable<number>) => {\r\n if (this.config.handleError) {\r\n this.config.handleError(err, caught);\r\n }\r\n return throwError(err);\r\n })\r\n );\r\n }\r\n\r\n private execGetArrayDataWithCount(url: string, requestOptions: {\r\n headers?: HttpHeaders;\r\n observe: 'response';\r\n params?: HttpParams;\r\n reportProgress?: boolean;\r\n responseType?: 'json';\r\n withCredentials?: boolean;\r\n }): Observable<ODataPagedResult<T>> {\r\n return this.http.get<IODataResponseModel<T>>(url, requestOptions)\r\n .pipe(\r\n map(res => this.extractArrayDataWithCount(res, this.config)),\r\n catchError((err: any, caught: Observable<ODataPagedResult<T>>) => {\r\n if (this.config.handleError) {\r\n this.config.handleError(err, caught);\r\n }\r\n return throwError(err);\r\n })\r\n );\r\n }\r\n\r\n private execGetArrayDataWithMetadata(url: string, requestOptions: {\r\n headers?: HttpHeaders;\r\n observe: 'response';\r\n params?: HttpParams;\r\n reportProgress?: boolean;\r\n responseType?: 'json';\r\n withCredentials?: boolean;\r\n }): Observable<ODataMetadataResult<T>> {\r\n return this.http.get<IODataResponseModel<T>>(url, requestOptions)\r\n .pipe(\r\n map(res => this.extractArrayDataWithMetadata(res, this.config)),\r\n catchError((err: HttpErrorResponse, caught: Observable<ODataMetadataResult<T>>) => {\r\n if (this.config.handleError) {\r\n this.config.handleError(err, caught);\r\n }\r\n return throwError(err);\r\n })\r\n );\r\n }\r\n\r\n private execGetArrayData(requestOptions: {\r\n headers?: HttpHeaders;\r\n observe: 'response';\r\n params?: HttpParams;\r\n reportProgress?: boolean;\r\n responseType?: 'json';\r\n withCredentials?: boolean;\r\n }): Observable<T[]> {\r\n return this.http.get<IODataResponseModel<T>>(this._entitiesUri, requestOptions)\r\n .pipe(\r\n map(res => this.extractArrayData(res, this.config)),\r\n catchError((err: any, caught: Observable<Array<T>>) => {\r\n if (this.config.handleError) {\r\n this.config.handleError(err, caught);\r\n }\r\n return throwError(err);\r\n })\r\n );\r\n }\r\n\r\n private getQueryRequestOptions(returnType? : ODataExecReturnType): {\r\n headers?: HttpHeaders;\r\n observe: 'response';\r\n params?: HttpParams;\r\n reportProgress?: boolean;\r\n responseType?: 'json';\r\n withCredentials?: boolean;\r\n } {\r\n const options = Object.assign({}, this.config.defaultRequestOptions);\r\n options.params = this.getQueryParams(options.params);\r\n options.headers = this.getQueryHeaders(options.headers, returnType);\r\n return options;\r\n }\r\n\r\n private getQueryHeaders(headers: HttpHeaders, returnType?: ODataExecReturnType): HttpHeaders {\r\n if (!headers) {\r\n headers = new HttpHeaders();\r\n }\r\n if(this._maxPerPage > 0){\r\n headers = headers.set('Prefer', `${this.config.keys.maxPerPage}=${this._maxPerPage}`);\r\n }\r\n headers = headers.set(`${this.config.keys.metadata}`, `${(returnType && returnType >= ODataExecReturnType.PagedResult)? 'full' : 'none'}`);\r\n if (this._customQueryHeaders.length > 0) {\r\n this._customQueryHeaders.forEach(customQueryHeader => {\r\n headers = headers.set(customQueryHeader.key, customQueryHeader.value);\r\n });\r\n }\r\n return headers;\r\n }\r\n\r\n private getQueryParams(aParams?:HttpParams): HttpParams {\r\n let params = super.getParams(aParams);\r\n\r\n if (this._filter) {\r\n params = params.append(this.config.keys.filter, this._filter);\r\n }\r\n\r\n if (this._search) {\r\n params = params.append(this.config.keys.search, this._search);\r\n }\r\n\r\n if (this._top > 0) {\r\n params = params.append(this.config.keys.top, this._top.toString());\r\n }\r\n\r\n if (this._skip > 0) {\r\n params = params.append(this.config.keys.skip, this._skip.toString());\r\n }\r\n\r\n if (this._orderBy.length > 0) {\r\n params = params.append(this.config.keys.orderBy, this.toCommaString(this._orderBy));\r\n }\r\n\r\n if (this._apply.length > 0) {\r\n params = params.append(this.config.keys.apply, this.toCommaString(this._apply));\r\n }\r\n\r\n if (this._customQueryOptions.length > 0) {\r\n this._customQueryOptions.forEach(customQueryOption => (params = params.append(\r\n this.checkReservedCustomQueryOptionKey(customQueryOption.key), customQueryOption.value)\r\n ));\r\n }\r\n\r\n return params;\r\n }\r\n\r\n private extractDataAsNumber(res: HttpResponse<number>, config: ODataConfiguration): number {\r\n return config.extractQueryResultDataAsNumber(res);\r\n }\r\n\r\n private extractArrayData(res: HttpResponse<IODataResponseModel<T>>, config: ODataConfiguration): T[] {\r\n return config.extractQueryResultData(res);\r\n }\r\n\r\n private extractArrayDataWithCount(res: HttpResponse<IODataResponseModel<T>>, config: ODataConfiguration): ODataPagedResult<T> {\r\n return config.extractQueryResultDataWithCount(res);\r\n }\r\n\r\n private extractArrayDataWithMetadata(res: HttpResponse<IODataResponseModel<T>>, config: ODataConfiguration): ODataMetadataResult<T> {\r\n return config.extractQueryResultDataWithMetadata(res);\r\n }\r\n\r\n private checkReservedCustomQueryOptionKey(key: string): string {\r\n if (key === null || key === undefined){\r\n throw new Error('Custom query options MUST NOT be null or undefined.');\r\n }\r\n if (key.indexOf('$') === 0 || key.indexOf('@') === 0) {\r\n throw new Error('Custom query options MUST NOT begin with a $ or @ character.');\r\n }\r\n return key;\r\n }\r\n}\r\n","export class ODataUtils {\r\n public static convertObjectToString(obj: any): string {\r\n const properties: string[] = [];\r\n\r\n for (const prop in obj) {\r\n if (obj.hasOwnProperty(prop) && obj[prop] !== undefined) {\r\n const value: any = ODataUtils.quoteValue(obj[prop]);\r\n\r\n properties.push(`${prop}=${value}`);\r\n }\r\n }\r\n return properties.join(', ');\r\n }\r\n\r\n public static quoteValue(value: number | string | boolean | any): string {\r\n // check if GUID (UUID) type\r\n if (/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(value)) {\r\n return value;\r\n }\r\n\r\n // check if string\r\n if (typeof value === 'string') {\r\n const escaped = value.replace(/'/g, '\\'\\'');\r\n return `'${escaped}'`;\r\n }\r\n\r\n // check if boolean or number\r\n if (typeof value === 'boolean' || typeof value === 'number') {\r\n return `${value}`;\r\n }\r\n\r\n const parts: string[] = [];\r\n Object.getOwnPropertyNames(value).forEach((propertyName: string) => {\r\n const propertyValue: any = value[propertyName];\r\n parts.push(`${propertyName}=${ODataUtils.quoteValue(propertyValue)}`);\r\n });\r\n\r\n return parts.length > 0 ? parts.join(', ') : `${value}`;\r\n }\r\n\r\n public static tryParseInt(input?: any): { valid: boolean, value: number } {\r\n if (input !== null && !isNaN(input)) {\r\n const parsed: number = parseInt(input, 10);\r\n return {\r\n valid: !isNaN(parsed),\r\n value: parsed\r\n };\r\n }\r\n\r\n return {\r\n valid: false,\r\n value: NaN\r\n };\r\n }\r\n}\r\n","import { Observable, throwError } from 'rxjs';\r\nimport { catchError, map } from 'rxjs/operators';\r\n\r\nimport { HttpClient, HttpResponse } from '@angular/common/http';\r\n\r\nimport { ODataConfiguration } from './angularODataConfiguration';\r\nimport { DeleteOperation, GetOperation, PatchOperation, PostOperation, PutOperation } from './angularODataOperation';\r\nimport { ODataQuery } from './angularODataQuery';\r\nimport { ODataUtils } from './angularODataUtils';\r\n\r\nexport class ODataService<T> {\r\n private _entitiesUri: string;\r\n\r\n constructor(private _typeName: string, private _http: HttpClient, private config: ODataConfiguration) {\r\n this._entitiesUri = config.getEntitiesUri(_typeName);\r\n }\r\n\r\n public get TypeName(): string {\r\n return this._typeName;\r\n }\r\n\r\n public Get(key: any): GetOperation<T> {\r\n return new GetOperation<T>(this._typeName, this.config, this._http, key);\r\n }\r\n\r\n public Post<T>(entity: T): PostOperation<T> {\r\n return new PostOperation<T>(this._typeName, this.config, this._http, entity);\r\n }\r\n\r\n public Patch<T>(entity: T, key: any): PatchOperation<T> {\r\n return new PatchOperation<T>(this._typeName, this.config, this._http, key, entity);\r\n }\r\n\r\n public Put<T>(entity: T, key: any): PutOperation<T> {\r\n return new PutOperation<T>(this._typeName, this.config, this._http, key, entity);\r\n }\r\n\r\n public Delete(key: any): DeleteOperation<T> {\r\n return new DeleteOperation<T>(this._typeName, this.config, this._http, key);\r\n }\r\n\r\n public CustomAction(key: any, actionName: string, postdata: any): Observable<any> {\r\n const body = postdata ? JSON.stringify(postdata) : null;\r\n return this._http.post(`${this.getEntityUri(key)}/${actionName}`, body, this.config.customRequestOptions).pipe(map(resp => resp));\r\n }\r\n\r\n public CustomCollectionAction(actionName: string, postdata: any): Observable<any> {\r\n const body = postdata ? JSON.stringify(postdata) : null;\r\n return this._http.post(`${this._entitiesUri}/${actionName}`, body, this.config.customRequestOptions).pipe(map(resp => resp));\r\n }\r\n\r\n public CustomFunction(key: any, functionName: string, parameters?: any): Observable<any> {\r\n if (parameters) {\r\n const params: string = ODataUtils.convertObjectToString(parameters);\r\n functionName = `${functionName}(${params})`;\r\n } else if (!functionName.endsWith(')') && !functionName.endsWith('()')) {\r\n functionName = `${functionName}()`;\r\n }\r\n return this._http.get(`${this.getEntityUri(key)}/${functionName}`, this.config.defaultRequestOptions).pipe(map(resp => resp));\r\n }\r\n\r\n public CustomCollectionFunction(functionName: string, parameters?: any): Observable<any> {\r\n if (parameters) {\r\n const params: string = ODataUtils.convertObjectToString(parameters);\r\n functionName = `${functionName}(${params})`;\r\n } else if (!functionName.endsWith(')') && !functionName.endsWith('()')) {\r\n functionName = `${functionName}()`;\r\n }\r\n return this._http.get(`${this._entitiesUri}/${functionName}`, this.config.defaultRequestOptions).pipe(map(resp => resp));\r\n }\r\n\r\n public getNestedEntityService<U>(key:string,typeName:string):ODataService<U>{\r\n let nestedTypeName = `${this.config.getEntityPath(key,this._typeName)}/${typeName}`;\r\n return new ODataService<U>(nestedTypeName,this._http,this.config);\r\n }\r\n\r\n public ItemProperty<T = any>(key: string, propertyName: string): Observable<T | null> {\r\n return this._http.get<T>(`${this.getEntityUri(key)}/${propertyName}`, this.config.defaultRequestOptions)\r\n .pipe(map(r => r.body));\r\n }\r\n\r\n public Query(): ODataQuery<T> {\r\n return new ODataQuery<T>(this.TypeName, this.config, this._http);\r\n }\r\n\r\n protected getEntityUri(key: any): string {\r\n return this.config.getEntityUri(key, this._typeName);\r\n }\r\n\r\n protected handleResponse<TResponse>(entity: Observable<HttpResponse<TResponse>>): Observable<TResponse> {\r\n return entity\r\n .pipe(\r\n map(this.extractData),\r\n catchError((err: any, caught: Observable<TResponse>) => {\r\n if (this.config.handleError) {\r\n this.config.handleError(err, caught);\r\n }\r\n return throwError(err);\r\n })\r\n );\r\n }\r\n\r\n private extractData<TResponse>(res: HttpResponse<TResponse>): TResponse {\r\n if (res.status < 200 || res.status >= 300) {\r\n throw new Error('Bad response status: ' + res.status);\r\n }\r\n const body: any = res.body;\r\n return body || {};\r\n }\r\n}\r\n","import { HttpHeaders, HttpParams, HttpResponse } from '@angular/common/http';\r\nimport { Injectable } from '@angular/core';\r\n\r\nimport { ODataMetadataResult } from './angularODataMetadataResult';\r\nimport { ODataPagedResult } from './angularODataPagedResult';\r\nimport { IODataResponseModel } from './angularODataResponseModel';\r\nimport { ODataUtils } from './angularODataUtils';\r\n\r\nexport class KeyConfigs {\r\n public filter = '$filter';\r\n public top = '$top';\r\n public skip = '$skip';\r\n public orderBy = '$orderby';\r\n public select = '$select';\r\n public search = '$search';\r\n public expand = '$expand';\r\n public apply = '$apply';\r\n public count = '$count';\r\n public maxPerPage = 'odata.maxpagesize';\r\n public metadata = 'odata.metadata';\r\n public responseCount = '@odata.count';\r\n public responseNextLink = '@odata.nextLink';\r\n}\r\n\r\n@Injectable()\r\nexport class ODataConfiguration {\r\n private readonly _postHeaders = new HttpHeaders({ 'Content-Type': 'application/json; charset=utf-8' });\r\n private _baseUrl = 'http://localhost/odata';\r\n\r\n public keys: KeyConfigs = new KeyConfigs();\r\n\r\n public defaultRequestOptions: {\r\n headers: HttpHeaders;\r\n observe: 'response';\r\n params?: HttpParams;\r\n reportProgress?: boolean;\r\n responseType?: 'json';\r\n withCredentials?: boolean;\r\n } = { headers: new HttpHeaders(), observe: 'response' };\r\n\r\n public postRequestOptions: {\r\n headers: HttpHeaders;\r\n observe: 'response';\r\n params?: HttpParams;\r\n reportProgress?: boolean;\r\n responseType?: 'json';\r\n withCredentials?: boolean;\r\n } = { headers: this._postHeaders, observe: 'response' };\r\n\r\n public customRequestOptions: {\r\n headers: HttpHeaders;\r\n observe: 'response';\r\n params?: HttpParams;\r\n reportProgress?: boolean;\r\n responseType?: 'json';\r\n withCredentials?: boolean;\r\n } = { headers: new HttpHeaders(), observe: 'response' };\r\n\r\n set baseUrl(baseUrl: string) {\r\n this._baseUrl = baseUrl.replace(/\\/+$/, '');\r\n }\r\n\r\n get baseUrl(): string {\r\n return this._baseUrl;\r\n }\r\n\r\n public getEntitiesUri(typeName: string): string {\r\n if (typeName) {\r\n return `${this.baseUrl}/${this.sanitizeTypeName(typeName)}`;\r\n }\r\n return this.baseUrl;\r\n }\r\n\r\n public getEntityUri(key: any, typeName: string): string {\r\n return `${this.getEntitiesUri(typeName)}(${ODataUtils.quoteValue(key)})`;\r\n }\r\n\r\n public getEntityPath(key:any, typeName:string):string{\r\n return `${this.sanitizeTypeName(typeName)}(${ODataUtils.quoteValue(key)})`;\r\n }\r\n\r\n public handleError(err: any, caught: any): void {\r\n console.warn('OData error: ', err, caught);\r\n }\r\n\r\n public extractQueryResultDataAsNumber(res: HttpResponse<number>): number {\r\n if (res.status < 200 || res.status >= 300) {\r\n throw new Error('Bad response status: ' + res.status);\r\n }\r\n\r\n return (res && res.body) as number;\r\n }\r\n\r\n public extractQueryResultData<T>(res: HttpResponse<IODataResponseModel<T>>): T[] {\r\n if (res.status < 200 || res.status >= 300) {\r\n throw new Error('Bad response status: ' + res.status);\r\n }\r\n\r\n return (res && res.body && res.body.value) as T[];\r\n }\r\n\r\n public extractQueryResultDataWithCount<T>(res: HttpResponse<IODataResponseModel<T>>): ODataPagedResult<T> {\r\n let pagedResult: ODataPagedResult<T>;\r\n\r\n if (res.status < 200 || res.status >= 300) {\r\n throw new Error('Bad response status: ' + res.status);\r\n }\r\n\r\n const body: any = res.body;\r\n let entities: T[] = body.value;\r\n delete body.value;\r\n if(!Array.isArray(entities)){\r\n entities = [];\r\n }\r\n pagedResult = body;\r\n pagedResult.data = entities;\r\n\r\n const parseResult = ODataUtils.tryParseInt(body[`${this.keys.responseCount}`]);\r\n if (parseResult.valid) {\r\n pagedResult.count = parseResult.value;\r\n } else {\r\n console.warn('Cannot determine OData entities count. Falling back to collection length.');\r\n pagedResult.count = entities.length;\r\n }\r\n\r\n if (body[`${this.keys.responseNextLink}`]) {\r\n pagedResult.nextLink = body[`${this.keys.responseNextLink}`];\r\n }\r\n\r\n return pagedResult;\r\n }\r\n\r\n public extractQueryResultDataWithMetadata<T>(res: HttpResponse<IODataResponseModel<T>>): ODataMetadataResult<T> {\r\n let result: ODataMetadataResult<T>; \r\n\r\n if (res.status < 200 || res.status >= 300) {\r\n throw new Error('Bad response status: ' + res.status);\r\n }\r\n\r\n const body: any = res.body;\r\n let entities: T[] = body.value;\r\n delete body.value;\r\n if(!Array.isArray(entities)){\r\n entities = [];\r\n }\r\n result = body;\r\n result.data = entities;\r\n\r\n const parseResult = ODataUtils.tryParseInt(body[`${this.keys.responseCount}`]);\r\n if (parseResult.valid) {\r\n result.count = parseResult.value;\r\n } else {\r\n console.warn('Cannot determine OData entities count. Falling back to collection length.');\r\n result.count = entities.length;\r\n }\r\n\r\n if (body[`${this.keys.responseNextLink}`]) {\r\n result.nextLink = body[`${this.keys.responseNextLink}`];\r\n }\r\n\r\n return result;\r\n }\r\n\r\n private sanitizeTypeName(typeName: string): string {\r\n return typeName.replace(/\\/+$/, '').replace(/^\\/+/, '');\r\n }\r\n}\r\n","import { HttpClient } from '@angular/common/http';\r\nimport { Injectable } from '@angular/core';\r\n\r\nimport { ODataConfiguration } from './angularODataConfiguration';\r\nimport { ODataService } from './angularODataService';\r\n\r\n@Injectable()\r\nexport class ODataServiceFactory {\r\n\r\n constructor(private http: HttpClient, private config: ODataConfiguration) {\r\n }\r\n\r\n public CreateService<T>(typeName: string, config?: ODataConfiguration): ODataService<T> {\r\n return new ODataService<T>(typeName, this.http, config ? config : this.config);\r\n }\r\n}\r\n","/*\r\n * Public API Surface of angular-odata-v401\r\n */\r\n\r\nexport * from './lib/angular-odata-v401.module';\r\nexport * from './lib/odata'","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":["i2.ODataConfiguration"],"mappings":";;;;;;;;MAaa,sBAAsB,CAAA;AAE1B,IAAA,OAAO,OAAO,GAAA;QACnB,OAAO;AACL,YAAA,QAAQ,EAAE;SACX;;8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