@tracktor/shared-module 0.9.5 → 0.10.0
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 +3 -2
- package/dist/config/orval/index.d.ts +2 -0
- package/dist/config/orval/mutator/axiosCustomInstance.d.ts +5 -0
- package/dist/config/orval/mutator/axiosCustomInstance.ts +21 -0
- package/dist/config/orval/orval.d.ts +44 -0
- package/dist/main.d.ts +1 -1
- package/dist/main.js +302 -273
- package/dist/main.umd.cjs +9 -9
- package/package.json +11 -10
- package/dist/config/orval.d.ts +0 -8
- /package/dist/config/{orval.test.d.ts → orval/orval.test.d.ts} +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
// @ts-ignore
|
|
2
|
+
import axios, { AxiosError, AxiosRequestConfig } from "axios";
|
|
3
|
+
|
|
4
|
+
axios.create();
|
|
5
|
+
|
|
6
|
+
export const axiosCustomInstance = <T>(config: AxiosRequestConfig): Promise<T> => {
|
|
7
|
+
const source = axios.CancelToken.source();
|
|
8
|
+
// @ts-ignore
|
|
9
|
+
const promise = axios({ ...config, cancelToken: source.token }).then(({ data }) => data);
|
|
10
|
+
|
|
11
|
+
// @ts-ignore
|
|
12
|
+
promise.cancel = () => {
|
|
13
|
+
source.cancel("Query was cancelled.");
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
return promise;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export default axiosCustomInstance;
|
|
20
|
+
|
|
21
|
+
export interface ErrorType<Error> extends AxiosError<Error> {}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Convert a string to capitalize
|
|
3
|
+
* @param method
|
|
4
|
+
*/
|
|
5
|
+
export declare const convertToCapitalize: (method: string) => string;
|
|
6
|
+
/**
|
|
7
|
+
* Convert a route to camelCase
|
|
8
|
+
* @param route
|
|
9
|
+
*/
|
|
10
|
+
export declare const convertRouteToCamelCase: (route: string) => string;
|
|
11
|
+
/**
|
|
12
|
+
* Generate the operation name for orval output
|
|
13
|
+
* @param _
|
|
14
|
+
* @param route
|
|
15
|
+
* @param method
|
|
16
|
+
*/
|
|
17
|
+
export declare const getOrvalOperationName: (_: any, route: string, method: string) => string;
|
|
18
|
+
/**
|
|
19
|
+
* Get the orval config required for the generation
|
|
20
|
+
* @param operationsToUseInfiniteQuery
|
|
21
|
+
*/
|
|
22
|
+
export declare const getOrvalConfig: (operationsToUseInfiniteQuery?: string[]) => {
|
|
23
|
+
readonly api: {
|
|
24
|
+
readonly input: "./openapi.json";
|
|
25
|
+
readonly output: {
|
|
26
|
+
readonly client: "react-query";
|
|
27
|
+
readonly mode: "tags-split";
|
|
28
|
+
readonly override: {
|
|
29
|
+
readonly query: {
|
|
30
|
+
readonly useQuery: true;
|
|
31
|
+
};
|
|
32
|
+
readonly operations?: Record<string, {}> | undefined;
|
|
33
|
+
readonly mutator: {
|
|
34
|
+
readonly name: "axiosCustomInstance";
|
|
35
|
+
readonly path: `${string}/config/orval/mutator/axiosCustomInstance.ts`;
|
|
36
|
+
};
|
|
37
|
+
readonly operationName: (_: any, route: string, method: string) => string;
|
|
38
|
+
};
|
|
39
|
+
readonly schemas: "src/api/model";
|
|
40
|
+
readonly target: "src/api/services/api.ts";
|
|
41
|
+
};
|
|
42
|
+
};
|
|
43
|
+
};
|
|
44
|
+
export default getOrvalConfig;
|
package/dist/main.d.ts
CHANGED
|
@@ -20,5 +20,5 @@ export { default as useResponseError } from './hooks/useResponseError';
|
|
|
20
20
|
export * from './hooks/useResponseError';
|
|
21
21
|
export { default as useInfiniteDataGrid } from './hooks/useInfiniteDataGrid';
|
|
22
22
|
export * from './hooks/useInfiniteDataGrid';
|
|
23
|
-
export { default as
|
|
23
|
+
export { default as getOrvalConfig } from './config/orval';
|
|
24
24
|
export * from './config/orval';
|