@acrool/react-fetcher 0.0.2-alpha.8 → 0.0.2
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/dist/FetcherProvider/FetcherProvider.d.ts +4 -3
- package/dist/FetcherProvider/index.d.ts +2 -1
- package/dist/FetcherProvider/types.d.ts +2 -1
- package/dist/FetcherProvider/utils.d.ts +9 -4
- package/dist/acrool-react-fetcher.es.js +854 -893
- package/dist/fetchers/createGraphQLFetcher/createGraphQLFetcher.d.ts +2 -1
- package/dist/fetchers/createRestFulFetcher/config.d.ts +8 -1
- package/dist/fetchers/createRestFulFetcher/createRestFulFetcher.d.ts +4 -2
- package/dist/fetchers/createRestFulFetcher/index.d.ts +2 -2
- package/dist/fetchers/createRestFulFetcher/types.d.ts +5 -10
- package/dist/fetchers/createRestFulFetcher/utils.d.ts +10 -7
- package/package.json +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { AxiosInstance } from 'axios';
|
|
2
2
|
import { default as React } from 'react';
|
|
3
3
|
import { IInternalRequestConfig } from '../fetchers/types';
|
|
4
|
-
import {
|
|
4
|
+
import { IFormatResponseErrorReturn, TGetResponseFormatError } from './types';
|
|
5
5
|
export declare const AxiosClientContext: React.Context<AxiosInstance | null>;
|
|
6
6
|
export declare const useAxiosClient: () => null;
|
|
7
7
|
interface IProps {
|
|
@@ -9,7 +9,8 @@ interface IProps {
|
|
|
9
9
|
axiosInstance: AxiosInstance;
|
|
10
10
|
checkIsRefreshTokenRequest?: (config: IInternalRequestConfig) => boolean;
|
|
11
11
|
locale?: string;
|
|
12
|
-
|
|
12
|
+
getResponseFormatError?: TGetResponseFormatError;
|
|
13
|
+
onError?: (error: IFormatResponseErrorReturn) => void;
|
|
13
14
|
authorizationPrefix?: string;
|
|
14
15
|
i18nDict?: Record<string, Record<number, string>>;
|
|
15
16
|
isDebug?: boolean;
|
|
@@ -21,5 +22,5 @@ interface IProps {
|
|
|
21
22
|
* @param locale
|
|
22
23
|
* @param onError
|
|
23
24
|
*/
|
|
24
|
-
declare const FetcherProvider: ({ children, axiosInstance, locale, onError, checkIsRefreshTokenRequest, authorizationPrefix, i18nDict, isDebug, }: IProps) => import("react/jsx-runtime").JSX.Element;
|
|
25
|
+
declare const FetcherProvider: ({ children, axiosInstance, locale, getResponseFormatError, onError, checkIsRefreshTokenRequest, authorizationPrefix, i18nDict, isDebug, }: IProps) => import("react/jsx-runtime").JSX.Element;
|
|
25
26
|
export default FetcherProvider;
|
|
@@ -2,9 +2,10 @@ import { AxiosError, AxiosResponse, InternalAxiosRequestConfig } from 'axios';
|
|
|
2
2
|
export type TInterceptorRequest = (value: InternalAxiosRequestConfig<any>) => InternalAxiosRequestConfig<any> | Promise<InternalAxiosRequestConfig<any>>;
|
|
3
3
|
export type TInterceptorResponseSuccess = (value: AxiosResponse<any>) => AxiosResponse<any> | Promise<AxiosResponse<any>>;
|
|
4
4
|
export type TInterceptorResponseError = (error: AxiosError<any>) => AxiosResponse<any> | Promise<AxiosResponse<any>>;
|
|
5
|
-
export interface
|
|
5
|
+
export interface IFormatResponseErrorReturn {
|
|
6
6
|
message: string;
|
|
7
7
|
code: string;
|
|
8
8
|
path?: string;
|
|
9
9
|
args?: any;
|
|
10
10
|
}
|
|
11
|
+
export type TGetResponseFormatError = (response?: AxiosResponse) => IFormatResponseErrorReturn;
|
|
@@ -1,7 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { IResponseFirstError } from './types';
|
|
1
|
+
import { TGetResponseFormatError } from './types';
|
|
3
2
|
/**
|
|
4
|
-
* 返回 Axios 格式錯誤
|
|
3
|
+
* 返回 Axios 格式錯誤 With GraphQL
|
|
4
|
+
* 針對 GraphQL多錯誤格式
|
|
5
5
|
* @param response
|
|
6
6
|
*/
|
|
7
|
-
export declare const
|
|
7
|
+
export declare const getGraphQLResponseFormatError: TGetResponseFormatError;
|
|
8
|
+
/**
|
|
9
|
+
* 返回 Axios 格式錯誤 with RestFul
|
|
10
|
+
* @param response
|
|
11
|
+
*/
|
|
12
|
+
export declare const getRestFulResponseFormatError: TGetResponseFormatError;
|