angular-odata 0.149.0 → 0.150.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -5934,44 +5934,46 @@ class ODataRequest {
5934
5934
  this.reportProgress = init.reportProgress;
5935
5935
  this.observe = init.observe;
5936
5936
  this.context = init.context;
5937
+ // Options
5938
+ const apiOptions = this.api.options;
5939
+ const parserOptions = Objects.merge(apiOptions.parserOptions, init.parserOptions ?? {});
5937
5940
  // Response Type
5938
5941
  this._responseType = init.responseType;
5939
5942
  // The Body
5940
5943
  this._body = init.body !== undefined ? init.body : null;
5941
5944
  if (this._body !== null)
5942
- this._body = this.resource.serialize(this._body, init.parserOptions);
5943
- this.withCredentials =
5944
- init.withCredentials === undefined ? this.api.options.withCredentials : init.withCredentials;
5945
- this.fetchPolicy = init.fetchPolicy ?? this.api.options.fetchPolicy;
5945
+ this._body = this.resource.serialize(this._body, parserOptions);
5946
+ this.withCredentials = init.withCredentials ?? apiOptions.withCredentials;
5947
+ this.fetchPolicy = init.fetchPolicy ?? apiOptions.fetchPolicy;
5946
5948
  this.maxAge = init.maxAge;
5947
5949
  this.bodyQueryOptions = [
5948
- ...(this.api.options.bodyQueryOptions || []),
5949
- ...(init.bodyQueryOptions || []),
5950
+ ...(apiOptions.bodyQueryOptions ?? []),
5951
+ ...(init.bodyQueryOptions ?? []),
5950
5952
  ];
5951
5953
  // The Path and Params from resource
5952
- const [resourcePath, resourceParams] = this.resource.pathAndParams(init.parserOptions);
5954
+ const [resourcePath, resourceParams] = this.resource.pathAndParams(parserOptions);
5953
5955
  this._path = resourcePath;
5954
5956
  //#region Headers
5955
5957
  const customHeaders = {};
5956
5958
  if (typeof init.etag === 'string') {
5957
- if (this.api.options.etag.ifMatch && ['PUT', 'PATCH', 'DELETE'].indexOf(this._method) !== -1)
5959
+ if (apiOptions.etag.ifMatch && ['PUT', 'PATCH', 'DELETE'].indexOf(this._method) !== -1)
5958
5960
  customHeaders[IF_MATCH_HEADER] = init.etag;
5959
- else if (this.api.options.etag.ifNoneMatch && ['GET'].indexOf(this._method) !== -1)
5961
+ else if (apiOptions.etag.ifNoneMatch && ['GET'].indexOf(this._method) !== -1)
5960
5962
  customHeaders[IF_NONE_MATCH_HEADER] = init.etag;
5961
5963
  }
5962
5964
  const accept = [];
5963
5965
  // Metadata
5964
- if (this.api.options.accept?.metadata !== undefined)
5965
- accept.push(`odata.metadata=${this.api.options.accept?.metadata}`);
5966
+ if (apiOptions.accept?.metadata !== undefined)
5967
+ accept.push(`odata.metadata=${apiOptions.accept?.metadata}`);
5966
5968
  // IEEE754
5967
- if (this.api.options.accept?.ieee754Compatible !== undefined)
5968
- accept.push(`IEEE754Compatible=${this.api.options.accept?.ieee754Compatible}`);
5969
+ if (apiOptions.accept?.ieee754Compatible !== undefined)
5970
+ accept.push(`IEEE754Compatible=${apiOptions.accept?.ieee754Compatible}`);
5969
5971
  // streaming
5970
- if (this.api.options.accept?.streaming !== undefined)
5971
- accept.push(`streaming=${this.api.options.accept?.streaming}`);
5972
+ if (apiOptions.accept?.streaming !== undefined)
5973
+ accept.push(`streaming=${apiOptions.accept?.streaming}`);
5972
5974
  // ExponentialDecimals
5973
- if (this.api.options.accept?.exponentialDecimals !== undefined)
5974
- accept.push(`ExponentialDecimals=${this.api.options.accept?.exponentialDecimals}`);
5975
+ if (apiOptions.accept?.exponentialDecimals !== undefined)
5976
+ accept.push(`ExponentialDecimals=${apiOptions.accept?.exponentialDecimals}`);
5975
5977
  if (accept.length > 0)
5976
5978
  customHeaders[ACCEPT] = [
5977
5979
  `${APPLICATION_JSON};${accept.join(';')}`,
@@ -5980,25 +5982,25 @@ class ODataRequest {
5980
5982
  ];
5981
5983
  const prefer = [];
5982
5984
  // Return
5983
- if (this.api.options.prefer?.return !== undefined &&
5985
+ if (apiOptions.prefer?.return !== undefined &&
5984
5986
  ['POST', 'PUT', 'PATCH'].indexOf(this._method) !== -1)
5985
- prefer.push(`return=${this.api.options.prefer?.return}`);
5987
+ prefer.push(`return=${apiOptions.prefer?.return}`);
5986
5988
  // MaxPageSize
5987
- if (this.api.options.prefer?.maxPageSize !== undefined && ['GET'].indexOf(this._method) !== -1)
5988
- prefer.push(`odata.maxpagesize=${this.api.options.prefer?.maxPageSize}`);
5989
+ if (apiOptions.prefer?.maxPageSize !== undefined && ['GET'].indexOf(this._method) !== -1)
5990
+ prefer.push(`odata.maxpagesize=${apiOptions.prefer?.maxPageSize}`);
5989
5991
  // Annotations
5990
- if (this.api.options.prefer?.includeAnnotations !== undefined &&
5992
+ if (apiOptions.prefer?.includeAnnotations !== undefined &&
5991
5993
  ['GET'].indexOf(this._method) !== -1)
5992
- prefer.push(`odata.include-annotations=${this.api.options.prefer?.includeAnnotations}`);
5994
+ prefer.push(`odata.include-annotations=${apiOptions.prefer?.includeAnnotations}`);
5993
5995
  // Omit Null Values
5994
- if (this.api.options.prefer?.omitNullValues === true && ['GET'].indexOf(this._method) !== -1)
5996
+ if (apiOptions.prefer?.omitNullValues === true && ['GET'].indexOf(this._method) !== -1)
5995
5997
  prefer.push(`omit-values=nulls`);
5996
5998
  // Continue on Error
5997
- if (this.api.options.prefer?.continueOnError === true && ['POST'].indexOf(this._method) !== -1)
5999
+ if (apiOptions.prefer?.continueOnError === true && ['POST'].indexOf(this._method) !== -1)
5998
6000
  prefer.push(`odata.continue-on-error`);
5999
6001
  if (prefer.length > 0)
6000
6002
  customHeaders[PREFER] = prefer;
6001
- this._headers = Http.mergeHttpHeaders(this.api.options.headers, customHeaders, init.headers || {});
6003
+ this._headers = Http.mergeHttpHeaders(apiOptions.headers, customHeaders, init.headers || {});
6002
6004
  //#endregion
6003
6005
  //#region Params
6004
6006
  const customParams = {};
@@ -6011,7 +6013,7 @@ class ODataRequest {
6011
6013
  if (['GET'].indexOf(this._method) !== -1) {
6012
6014
  Object.assign(customParams, resourceParams);
6013
6015
  }
6014
- const params = Http.mergeHttpParams(this.api.options.params, customParams, init.params || {});
6016
+ const params = Http.mergeHttpParams(apiOptions.params, customParams, init.params || {});
6015
6017
  this._params =
6016
6018
  this._responseType === 'entity'
6017
6019
  ? Http.withoutHttpParams(params, ['$filter', '$orderby', '$count', '$skip', '$top'])
@@ -6019,6 +6021,7 @@ class ODataRequest {
6019
6021
  //#endregion
6020
6022
  }
6021
6023
  static factory(api, method, resource, options) {
6024
+ // Options
6022
6025
  const apiOptions = api.options;
6023
6026
  let params = options.params || {};
6024
6027
  if (options.withCount) {