@takaro/apiclient 0.0.0-dev.d495c77 → 0.0.0-dev.d4ad6b4

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,6 +1,6 @@
1
1
  import { DomainApi } from '../generated/index.js';
2
- import { BaseApiClient, IBaseApiClientConfig } from './baseClient.js';
3
- import { AxiosInstance } from 'axios';
2
+ import { BaseApiClient, type IBaseApiClientConfig } from './baseClient.js';
3
+ import { type AxiosInstance } from 'axios';
4
4
 
5
5
  export interface IAdminApiClientConfig extends IBaseApiClientConfig {
6
6
  auth: {
@@ -16,7 +16,9 @@ export class AdminClient extends BaseApiClient<IAdminApiClientConfig> {
16
16
 
17
17
  private addAuthInterceptor(token: string, axios: AxiosInstance): AxiosInstance {
18
18
  axios.interceptors.request.use(async (request) => {
19
- if (request.url?.includes('health')) return request;
19
+ if (request.url?.includes('health')) {
20
+ return request;
21
+ }
20
22
 
21
23
  request.headers['X-Takaro-Admin-Token'] = token;
22
24
  return request;
@@ -1,5 +1,5 @@
1
1
  import { MetaApi } from '../generated/api.js';
2
- import axios, { AxiosError, AxiosInstance, AxiosRequestConfig } from 'axios';
2
+ import axios, { type AxiosError, type AxiosInstance, type AxiosRequestConfig } from 'axios';
3
3
 
4
4
  /**
5
5
  * Axios defaults to NO timeout, so a request whose TCP connection stalls blocks its
@@ -42,8 +42,8 @@ export class BaseApiClient<T extends IBaseApiClientConfig> {
42
42
  // Only include it when running outside a browser context (Node.js / server-side).
43
43
  // Use globalThis so this compiles under both DOM and non-DOM TypeScript lib targets.
44
44
  const isBrowser =
45
- typeof (globalThis as Record<string, unknown>)['window'] !== 'undefined' &&
46
- typeof (globalThis as Record<string, unknown>)['document'] !== 'undefined';
45
+ (globalThis as Record<string, unknown>).window !== undefined &&
46
+ (globalThis as Record<string, unknown>).document !== undefined;
47
47
  const axiosConfig: AxiosRequestConfig = {
48
48
  baseURL: this.config.url,
49
49
  headers: {
@@ -55,7 +55,9 @@ export class BaseApiClient<T extends IBaseApiClientConfig> {
55
55
  };
56
56
  this.axios = this.addLoggers(axios.create(axiosConfig));
57
57
 
58
- if (this.config.log) this.log = this.config.log;
58
+ if (this.config.log) {
59
+ this.log = this.config.log;
60
+ }
59
61
  }
60
62
 
61
63
  setHeader(key: string, value: string) {
package/src/lib/client.ts CHANGED
@@ -23,7 +23,7 @@ import {
23
23
  AnalyticsApi,
24
24
  InviteLinkApi,
25
25
  } from '../generated/api.js';
26
- import { BaseApiClient, IBaseApiClientConfig } from './baseClient.js';
26
+ import { BaseApiClient, type IBaseApiClientConfig } from './baseClient.js';
27
27
 
28
28
  export interface IApiClientConfig extends IBaseApiClientConfig {
29
29
  auth: {
@@ -64,13 +64,13 @@ export class Client extends BaseApiClient<IApiClientConfig> {
64
64
  this.config.auth.token = loginRes.data.data.token;
65
65
  this.token = loginRes.data.data.token;
66
66
 
67
- this.axios.defaults.headers.common['Authorization'] = `Bearer ${loginRes.data.data.token}`;
67
+ this.axios.defaults.headers.common.Authorization = `Bearer ${loginRes.data.data.token}`;
68
68
 
69
69
  return loginRes.data.data.token;
70
70
  }
71
71
 
72
72
  public logout() {
73
- delete this.axios.defaults.headers.common['Authorization'];
73
+ delete this.axios.defaults.headers.common.Authorization;
74
74
  }
75
75
 
76
76
  public async permissionCodesToInputs(permissions: string[]) {
@@ -81,8 +81,9 @@ export class Client extends BaseApiClient<IApiClientConfig> {
81
81
  permissionId: p.id,
82
82
  }));
83
83
 
84
- if (records.length !== permissions.length)
84
+ if (records.length !== permissions.length) {
85
85
  throw new Error(`Not all permissions were found: ${permissions.join(', ')}`);
86
+ }
86
87
 
87
88
  return records;
88
89
  }
package/src/main.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { AxiosResponse } from 'axios';
1
+ import { type AxiosResponse } from 'axios';
2
2
 
3
3
  export { AxiosResponse } from 'axios';
4
4
  export { isAxiosError } from 'axios';