@sisense/sdk-rest-client 0.14.0 → 0.15.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.
@@ -1,13 +1,16 @@
1
1
  /// <reference lib="dom" />
2
2
  import { Authenticator } from './interfaces.js';
3
+ export interface HttpClientRequestConfig {
4
+ skipTrackingParam: boolean;
5
+ }
3
6
  export declare class HttpClient {
4
7
  readonly auth: Authenticator;
5
8
  readonly url: string;
6
9
  readonly env: string;
7
10
  constructor(url: string, auth: Authenticator, env: string);
8
11
  login(): Promise<boolean>;
9
- call<T = unknown>(url: string, config: RequestInit): Promise<T>;
10
- post<T = unknown>(endpoint: string, data: unknown, options?: RequestInit, abortSignal?: AbortSignal): Promise<T>;
11
- get<T = unknown>(endpoint: string, request?: RequestInit): Promise<T>;
12
- delete<T = void>(endpoint: string, request?: RequestInit): Promise<T>;
12
+ call<T = unknown>(url: string, config: RequestInit, requestConfig?: HttpClientRequestConfig): Promise<T>;
13
+ post<T = unknown>(endpoint: string, data: unknown, options?: RequestInit, abortSignal?: AbortSignal, config?: HttpClientRequestConfig): Promise<T>;
14
+ get<T = unknown>(endpoint: string, request?: RequestInit, config?: HttpClientRequestConfig): Promise<T>;
15
+ delete<T = void>(endpoint: string, request?: RequestInit, config?: HttpClientRequestConfig): Promise<T>;
13
16
  }
@@ -42,7 +42,7 @@ export class HttpClient {
42
42
  return this.auth.authenticate();
43
43
  });
44
44
  }
45
- call(url, config) {
45
+ call(url, config, requestConfig) {
46
46
  return __awaiter(this, void 0, void 0, function* () {
47
47
  if (this.auth.isAuthenticating()) {
48
48
  return new Promise((res) => {
@@ -52,7 +52,7 @@ export class HttpClient {
52
52
  setTimeout(retry, 10);
53
53
  return;
54
54
  }
55
- void this.call(url, config).then((r) => res(r));
55
+ void this.call(url, config, requestConfig).then((r) => res(r));
56
56
  };
57
57
  retry();
58
58
  });
@@ -67,7 +67,7 @@ export class HttpClient {
67
67
  const trackedUrl = addQueryParamsToUrl(url, {
68
68
  trc: this.env,
69
69
  });
70
- const response = yield fetch(trackedUrl, config);
70
+ const response = yield fetch((requestConfig === null || requestConfig === void 0 ? void 0 : requestConfig.skipTrackingParam) ? url : trackedUrl, config);
71
71
  if (response.status === 204 || // No content
72
72
  response.status === 304 // Not modified
73
73
  ) {
@@ -89,25 +89,25 @@ export class HttpClient {
89
89
  });
90
90
  }
91
91
  // eslint-disable-next-line max-params
92
- post(endpoint, data, options = {}, abortSignal) {
92
+ post(endpoint, data, options = {}, abortSignal, config) {
93
93
  return __awaiter(this, void 0, void 0, function* () {
94
94
  const request = Object.assign({ method: 'POST', body: JSON.stringify(data), headers: {
95
95
  Accept: 'application/json, text/plain, */*',
96
96
  'Content-Type': 'application/json;charset=UTF-8',
97
97
  }, signal: abortSignal }, options);
98
- return this.call(this.url + endpoint, request);
98
+ return this.call(this.url + endpoint, request, config);
99
99
  });
100
100
  }
101
- get(endpoint, request = {}) {
101
+ get(endpoint, request = {}, config) {
102
102
  return __awaiter(this, void 0, void 0, function* () {
103
103
  request.method = 'GET';
104
- return this.call(this.url + endpoint, request);
104
+ return this.call(this.url + endpoint, request, config);
105
105
  });
106
106
  }
107
- delete(endpoint, request = {}) {
107
+ delete(endpoint, request = {}, config) {
108
108
  return __awaiter(this, void 0, void 0, function* () {
109
109
  request.method = 'DELETE';
110
- return this.call(this.url + endpoint, request);
110
+ return this.call(this.url + endpoint, request, config);
111
111
  });
112
112
  }
113
113
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sisense/sdk-rest-client",
3
- "version": "0.14.0",
3
+ "version": "0.15.0",
4
4
  "type": "module",
5
5
  "exports": "./dist/index.js",
6
6
  "main": "./dist/index.js",