rest-client-sdk 7.0.0-rc.9 → 7.0.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.
@@ -72,6 +72,5 @@ declare class AbstractClient<D extends MetadataDefinition> {
72
72
  private _manageUnauthorized;
73
73
  private _doFetch;
74
74
  private _getEntityIdentifier;
75
- private _throwIfUnitOfWorkIsDisabled;
76
75
  }
77
76
  export default AbstractClient;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rest-client-sdk",
3
- "version": "7.0.0-rc.9",
3
+ "version": "7.0.0",
4
4
  "description": "Rest Client SDK for API",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.es.js",
@@ -27,7 +27,7 @@ class HttpError extends Error {
27
27
  /**
28
28
  * Get the JSON of the baseResponse directly, if possible
29
29
  */
30
- public async responseJson(): Promise<Record<string, unknown>> {
30
+ public responseJson(): Promise<Record<string, unknown>> {
31
31
  return this.baseResponse.json();
32
32
  }
33
33
  }
@@ -143,8 +143,6 @@ class AbstractClient<D extends MetadataDefinition> {
143
143
  pathParameters: Record<string, unknown> = {},
144
144
  requestParams: Record<string, unknown> = {}
145
145
  ): Promise<D['entity']> {
146
- this._throwIfUnitOfWorkIsDisabled();
147
-
148
146
  const url = new URI(this.getPathBase(pathParameters));
149
147
  url.addSearch(queryParam);
150
148
 
@@ -182,8 +180,6 @@ class AbstractClient<D extends MetadataDefinition> {
182
180
  queryParam: Record<string, unknown> = {},
183
181
  requestParams: Record<string, unknown> = {}
184
182
  ): Promise<D['entity']> {
185
- this._throwIfUnitOfWorkIsDisabled();
186
-
187
183
  const url = new URI(this.getEntityURI(entity));
188
184
  url.addSearch(queryParam);
189
185
 
@@ -223,8 +219,6 @@ class AbstractClient<D extends MetadataDefinition> {
223
219
  * @param {Record<string, unknown>} requestParams parameters that will be send as second parameter to the `fetch` call
224
220
  */
225
221
  delete(entity: D['entity'], requestParams = {}): Promise<Response> {
226
- this._throwIfUnitOfWorkIsDisabled();
227
-
228
222
  const url = this.getEntityURI(entity);
229
223
  const identifier = this._getEntityIdentifier(entity);
230
224
 
@@ -463,10 +457,13 @@ class AbstractClient<D extends MetadataDefinition> {
463
457
  requestParams: RequestInit
464
458
  ): Promise<Response> {
465
459
  let params = requestParams;
460
+ let baseHeaders: HeadersInit = {};
466
461
 
467
- const baseHeaders: HeadersInit = {
468
- 'Content-Type': 'application/json',
469
- };
462
+ if (params.method !== 'GET' || (params.method !== 'GET' && params.method !== 'DELETE')) {
463
+ baseHeaders = {
464
+ 'Content-Type': 'application/json',
465
+ };
466
+ }
470
467
 
471
468
  if (accessToken) {
472
469
  baseHeaders.Authorization = `${this.sdk.config.authorizationType} ${accessToken}`;
@@ -519,18 +516,6 @@ class AbstractClient<D extends MetadataDefinition> {
519
516
  // @ts-ignore
520
517
  return object[idKey];
521
518
  }
522
-
523
- private _throwIfUnitOfWorkIsDisabled(): void {
524
- if (!this.#isUnitOfWorkEnabled) {
525
- throw new Error(
526
- 'UnitOfWork can be deactivated only on find* methods (for now). If you think this should be authorized, please report in https://git.io/JkYTO'
527
- );
528
- }
529
- }
530
519
  }
531
520
 
532
- type Headers = {
533
- [key: string]: unknown;
534
- };
535
-
536
521
  export default AbstractClient;