@tyvm/knowhow-api-client 0.0.2 → 0.0.3

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/dist/client.d.ts CHANGED
@@ -21,6 +21,11 @@ export declare class KnowhowClientFactory {
21
21
  setToken(token: string): void;
22
22
  getToken(): string | undefined;
23
23
  clearToken(): void;
24
+ /**
25
+ * Dispose of the client and clear all cached data
26
+ * Call this in test cleanup to prevent memory leaks
27
+ */
28
+ dispose(): void;
24
29
  updateConfig(config: Partial<ClientConfig>): void;
25
30
  request(config: any): Promise<import("axios").AxiosResponse<any, any, {}>>;
26
31
  }
package/dist/client.js CHANGED
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.KnowhowClientFactory = void 0;
7
7
  const axios_1 = __importDefault(require("axios"));
8
8
  const openapi_client_axios_1 = __importDefault(require("openapi-client-axios"));
9
+ const openapi_json_1 = __importDefault(require("./generated/openapi.json"));
9
10
  class KnowhowClientFactory {
10
11
  constructor(config, tokenStorage) {
11
12
  this.config = config;
@@ -33,7 +34,7 @@ class KnowhowClientFactory {
33
34
  if (this._client)
34
35
  return this._client;
35
36
  const initClient = new openapi_client_axios_1.default({
36
- definition: this.config.baseURL + "/docs/swagger.json",
37
+ definition: openapi_json_1.default,
37
38
  axiosConfigDefaults: {
38
39
  baseURL: this.config.baseURL + "/api",
39
40
  headers: {
@@ -74,6 +75,15 @@ class KnowhowClientFactory {
74
75
  this.tokenStorage.clearToken();
75
76
  }
76
77
  }
78
+ /**
79
+ * Dispose of the client and clear all cached data
80
+ * Call this in test cleanup to prevent memory leaks
81
+ */
82
+ dispose() {
83
+ this.clearToken();
84
+ this.client = undefined;
85
+ this._client = undefined;
86
+ }
77
87
  updateConfig(config) {
78
88
  this.config = { ...this.config, ...config };
79
89
  if (config.baseURL) {