@clairejs/client 3.5.7 → 3.5.8
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
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Method } from "axios";
|
|
2
2
|
import { LogHandler } from "@clairejs/core";
|
|
3
|
-
import { AbstractHttpClient, RequestOptions } from "./AbstractHttpClient";
|
|
4
3
|
import { AbstractStorage } from "../system/AbstractStorage";
|
|
4
|
+
import { AbstractHttpClient, RequestOptions } from "./AbstractHttpClient";
|
|
5
5
|
export interface RequestData {
|
|
6
6
|
method: Method;
|
|
7
7
|
url: string;
|
|
@@ -9,7 +9,7 @@ export interface RequestData {
|
|
|
9
9
|
headers?: object;
|
|
10
10
|
options?: RequestOptions;
|
|
11
11
|
}
|
|
12
|
-
export declare
|
|
12
|
+
export declare class DefaultHttpClient extends AbstractHttpClient {
|
|
13
13
|
protected readonly apiServerUrl: string;
|
|
14
14
|
protected readonly logger?: LogHandler | undefined;
|
|
15
15
|
protected readonly maxRetryCount: number;
|
|
@@ -20,8 +20,8 @@ export declare abstract class DefaultHttpClient extends AbstractHttpClient {
|
|
|
20
20
|
constructor(apiServerUrl: string, logger?: LogHandler | undefined, maxRetryCount?: number, delayMsBetweenRetry?: number, storage?: AbstractStorage | undefined);
|
|
21
21
|
resetCache(pattern: string): void;
|
|
22
22
|
protected resolveUrl(url: string): Promise<string>;
|
|
23
|
-
protected
|
|
24
|
-
protected
|
|
23
|
+
protected getAuthorizationHeader(): Promise<Record<string, string>>;
|
|
24
|
+
protected errorHandler<T = any>(_operation: () => Promise<T>, err: any): Promise<T | undefined>;
|
|
25
25
|
protected retry<T = any>(apiCall: () => Promise<T>, retryCount?: number): Promise<T | undefined>;
|
|
26
26
|
protected performRequest<T = any>(data: RequestData): Promise<T | undefined>;
|
|
27
27
|
get<T = any>(url: string, headers?: object, options?: RequestOptions): Promise<T | undefined>;
|
|
@@ -64,6 +64,12 @@ export class DefaultHttpClient extends AbstractHttpClient {
|
|
|
64
64
|
async resolveUrl(url) {
|
|
65
65
|
return this.apiServerUrl + url;
|
|
66
66
|
}
|
|
67
|
+
async getAuthorizationHeader() {
|
|
68
|
+
return {};
|
|
69
|
+
}
|
|
70
|
+
errorHandler(_operation, err) {
|
|
71
|
+
throw err;
|
|
72
|
+
}
|
|
67
73
|
async retry(apiCall, retryCount = 0) {
|
|
68
74
|
try {
|
|
69
75
|
return await apiCall();
|
|
@@ -147,7 +153,6 @@ export class DefaultHttpClient extends AbstractHttpClient {
|
|
|
147
153
|
});
|
|
148
154
|
}
|
|
149
155
|
clone(apiServerUrl) {
|
|
150
|
-
|
|
151
|
-
return new Ctor(apiServerUrl, this.logger, this.maxRetryCount, this.delayMsBetweenRetry, this.storage);
|
|
156
|
+
return new DefaultHttpClient(apiServerUrl, this.logger, this.maxRetryCount, this.delayMsBetweenRetry, this.storage);
|
|
152
157
|
}
|
|
153
158
|
}
|