@tracktor/shared-module 2.12.1 → 2.12.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/CHANGELOG.md
CHANGED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
// eslint-disable-next-line import/no-extraneous-dependencies
|
|
2
|
+
import axios, { AxiosError, AxiosRequestConfig } from "axios";
|
|
3
|
+
|
|
4
|
+
export const axiosCustomInstance = <T>(config: AxiosRequestConfig, options?: AxiosRequestConfig): Promise<T> => {
|
|
5
|
+
const source = axios.CancelToken.source();
|
|
6
|
+
|
|
7
|
+
const promise = axios({
|
|
8
|
+
...config,
|
|
9
|
+
...options,
|
|
10
|
+
cancelToken: source.token,
|
|
11
|
+
}).then(({ data }) => data);
|
|
12
|
+
|
|
13
|
+
// @ts-ignore
|
|
14
|
+
promise.cancel = () => {
|
|
15
|
+
source.cancel("Query was cancelled");
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
return promise;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export default axiosCustomInstance;
|
|
22
|
+
|
|
23
|
+
export type ErrorType<Error> = AxiosError<Error>;
|
|
24
|
+
export type BodyType<BodyData> = BodyData;
|
package/dist/main.d.ts
CHANGED
|
@@ -35,4 +35,4 @@ export * from './config/orval';
|
|
|
35
35
|
export { default as dateAdapter } from './utils/adapter/dateAdapter';
|
|
36
36
|
export { default as distanceAdapter } from './utils/adapter/distanceAdapter';
|
|
37
37
|
export { default as worksiteNameAdapter } from './utils/adapter/worksiteNameAdapter/worksiteNameAdapter';
|
|
38
|
-
export { axiosCustomInstance, type ErrorType, type BodyType } from './axiosCustomInstance';
|
|
38
|
+
export { axiosCustomInstance, type ErrorType, type BodyType } from './config/orval/axiosCustomInstance';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tracktor/shared-module",
|
|
3
|
-
"version": "2.12.
|
|
3
|
+
"version": "2.12.3",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"types": "./dist/main.d.ts",
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
},
|
|
27
27
|
"scripts": {
|
|
28
28
|
"dev": "vite",
|
|
29
|
-
"build": "
|
|
29
|
+
"build": "vite build && cp src/config/orval/axiosCustomInstance.ts dist/config/orval/axiosCustomInstance.ts",
|
|
30
30
|
"lint": "eslint . --max-warnings=0 && tsc --noEmit",
|
|
31
31
|
"preview": "vite preview",
|
|
32
32
|
"test": "yarn lint && vitest",
|
|
File without changes
|