rest-client-sdk 7.0.0-rc.9 → 7.0.1
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.
- package/README.md +1 -1
- package/dist/index.es.js +10 -77
- package/dist/index.es.js.map +1 -1
- package/dist/index.js +10 -77
- package/dist/index.js.map +1 -1
- package/dist/types/client/AbstractClient.d.ts +0 -1
- package/package.json +5 -2
- package/src/ErrorFactory.ts +1 -1
- package/src/client/AbstractClient.ts +6 -21
package/package.json
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rest-client-sdk",
|
|
3
|
-
"version": "7.0.
|
|
3
|
+
"version": "7.0.1",
|
|
4
4
|
"description": "Rest Client SDK for API",
|
|
5
|
+
"type": "module",
|
|
5
6
|
"main": "dist/index.js",
|
|
6
|
-
"
|
|
7
|
+
"exports": {
|
|
8
|
+
".": "./dist/index.es.js"
|
|
9
|
+
},
|
|
7
10
|
"types": "dist/types/index.d.ts",
|
|
8
11
|
"files": [
|
|
9
12
|
"dist",
|
package/src/ErrorFactory.ts
CHANGED
|
@@ -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
|
|
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
|
-
|
|
468
|
-
|
|
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;
|