@tracktor/shared-module 2.1.2 → 2.1.4

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/CHANGELOG.md CHANGED
@@ -1,4 +1,4 @@
1
1
  # [Versions](https://github.com/Tracktor/shared-module/releases)
2
2
 
3
- ## v2.1.2
4
- - **[feat]** - orval config return type
3
+ ## v2.1.4
4
+ - **[fix]** - axios use now same instance than orval
@@ -1,5 +1,6 @@
1
1
  import { AxiosError, AxiosRequestConfig } from "axios";
2
- export declare const axiosCustomInstance: <T>(config: AxiosRequestConfig) => Promise<T>;
2
+ export declare const AXIOS_INSTANCE: import("axios").AxiosInstance;
3
+ export declare const axiosCustomInstance: <T>(config: AxiosRequestConfig, options?: AxiosRequestConfig) => Promise<T>;
3
4
  export default axiosCustomInstance;
4
- export interface ErrorType<Error> extends AxiosError<Error> {
5
- }
5
+ export type ErrorType<Error> = AxiosError<Error>;
6
+ export type BodyType<BodyData> = BodyData;
@@ -1,15 +1,19 @@
1
1
  import axios, { AxiosError, AxiosRequestConfig } from "axios";
2
2
 
3
- axios.create();
3
+ export const AXIOS_INSTANCE = axios.create();
4
4
 
5
- export const axiosCustomInstance = <T>(config: AxiosRequestConfig): Promise<T> => {
5
+ export const axiosCustomInstance = <T>(config: AxiosRequestConfig, options?: AxiosRequestConfig): Promise<T> => {
6
6
  const source = axios.CancelToken.source();
7
- // @ts-ignore
8
- const promise = axios({ ...config, cancelToken: source.token }).then(({ data }) => data);
7
+
8
+ const promise = AXIOS_INSTANCE({
9
+ ...config,
10
+ ...options,
11
+ cancelToken: source.token,
12
+ }).then(({ data }) => data);
9
13
 
10
14
  // @ts-ignore
11
15
  promise.cancel = () => {
12
- source.cancel("Query was cancelled.");
16
+ source.cancel("Query was cancelled");
13
17
  };
14
18
 
15
19
  return promise;
@@ -17,4 +21,5 @@ export const axiosCustomInstance = <T>(config: AxiosRequestConfig): Promise<T> =
17
21
 
18
22
  export default axiosCustomInstance;
19
23
 
20
- export interface ErrorType<Error> extends AxiosError<Error> {}
24
+ export type ErrorType<Error> = AxiosError<Error>;
25
+ export type BodyType<BodyData> = BodyData;
@@ -18,6 +18,10 @@ interface CustomOrvalConfig {
18
18
  * @default "src/api/services/api.ts"
19
19
  */
20
20
  target?: string;
21
+ /**
22
+ * Give you the possibility to set base url to your mock handlers.
23
+ */
24
+ baseUrl?: string;
21
25
  };
22
26
  /**
23
27
  * List of operations to use infinite query