@clairejs/client 3.4.0 → 3.4.2

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,9 @@
1
1
  ## Change Log
2
2
 
3
- #### 3.4.0:
3
+ #### 3.4.2:
4
4
 
5
+ - fix http client cache headers
6
+ - update claire core
5
7
  - apply LogHandler to some implementations
6
8
 
7
9
  #### 3.3.3:
@@ -1,9 +1,12 @@
1
+ import { LogHandler } from "@clairejs/core";
1
2
  export interface RequestOptions {
2
3
  noAuthorization?: boolean;
3
4
  withCredentials?: boolean;
4
5
  noErrorHandling?: boolean;
5
6
  }
6
7
  export declare abstract class AbstractHttpClient {
8
+ protected readonly logger?: LogHandler | undefined;
9
+ constructor(logger?: LogHandler | undefined);
7
10
  protected issuedGetRequests: Record<string, boolean>;
8
11
  resetCache(pattern: string): void;
9
12
  protected abstract doGet<T = any>(url: string, headers?: object, options?: RequestOptions): Promise<T | undefined>;
@@ -1,4 +1,9 @@
1
+ import { LogLevel } from "@clairejs/core";
1
2
  export class AbstractHttpClient {
3
+ logger;
4
+ constructor(logger) {
5
+ this.logger = logger;
6
+ }
2
7
  issuedGetRequests = {};
3
8
  /*
4
9
  Keep track off all get request had been sent and allow decache (using regex pattern) those requests
@@ -14,7 +19,8 @@ export class AbstractHttpClient {
14
19
  //-- has intercepted and decided to return nothing
15
20
  async get(url, headers, options) {
16
21
  const shouldUseCache = this.issuedGetRequests[url];
17
- const result = await this.doGet(url, { ...headers, ...(shouldUseCache ? {} : { "cache-control": "no-cache" }) }, options);
22
+ this.logger?.log(LogLevel.DEBUG, `[cache:${!!shouldUseCache}] Request: ${url}`);
23
+ const result = await this.doGet(url, { ...(!shouldUseCache && { "cache-control": "no-cache" }), ...headers }, options);
18
24
  this.issuedGetRequests[url] = true;
19
25
  return result;
20
26
  }
@@ -9,7 +9,7 @@ export class DefaultHttpClient extends AbstractHttpClient {
9
9
  storage;
10
10
  api = axios.create();
11
11
  constructor(apiServerUrl, logger, maxRetryCount = 2, delayMsBetweenRetry = 200, storage) {
12
- super();
12
+ super(logger);
13
13
  this.apiServerUrl = apiServerUrl;
14
14
  this.logger = logger;
15
15
  this.maxRetryCount = maxRetryCount;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@clairejs/client",
3
- "version": "3.4.0",
3
+ "version": "3.4.2",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "type": "module",
@@ -13,7 +13,7 @@
13
13
  "axios": "^1.3.4"
14
14
  },
15
15
  "peerDependencies": {
16
- "@clairejs/core": "^3.6.5"
16
+ "@clairejs/core": "^3.8.3"
17
17
  },
18
18
  "devDependencies": {
19
19
  "@types/mocha": "^10.0.1",