@tracktor/shared-module 0.9.4 → 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 CHANGED
@@ -1,4 +1,5 @@
1
1
  # [Versions](https://github.com/Tracktor/shared-module/releases)
2
2
 
3
- ## v0.9.4
4
- - **[improvement]** : `SentryConfig` component
3
+ ## v0.10.0
4
+ - **[feat]** : Add new function `getOrvalConfig` to get orval config
5
+ - **[chore]** : Upgrade dev dependencies
@@ -7,6 +7,12 @@ interface MaskTextFieldProps<T> {
7
7
  * @see https://imask.js.org/guide.html#masked-pattern
8
8
  */
9
9
  mask?: unknown;
10
+ /**
11
+ * On accept callback. Should be used to get the value from the mask instead onChange for controlled components.
12
+ * @param value
13
+ * @param maskRef
14
+ */
15
+ onAccept?: (value: unknown, maskRef: unknown) => void;
10
16
  /**
11
17
  * Definitions.
12
18
  */
@@ -0,0 +1,2 @@
1
+ import Orval from "./orval";
2
+ export default Orval;
@@ -0,0 +1,5 @@
1
+ import { AxiosError } from "axios";
2
+ export declare const axiosCustomInstance: <T>(config: AxiosRequestConfig) => Promise<T>;
3
+ export default axiosCustomInstance;
4
+ export interface ErrorType<Error> extends AxiosError<Error> {
5
+ }
@@ -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 getOrvalOperationName } from './config/orval';
23
+ export { default as getOrvalConfig } from './config/orval';
24
24
  export * from './config/orval';