@acrool/react-fetcher 0.0.2-alpha.7 → 0.0.2-alpha.9

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.
@@ -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 { IResponseFirstError } from './types';
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
- onError?: (error: IResponseFirstError) => void;
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;
@@ -1,2 +1,3 @@
1
1
  export { default as FetcherProvider } from './FetcherProvider';
2
- export type { IResponseFirstError } from './types';
2
+ export { getGraphQLResponseFormatError, getRestFulResponseFormatError } from './utils';
3
+ export type { TGetResponseFormatError } from './types';
@@ -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 IResponseFirstError {
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 { AxiosResponse } from 'axios';
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 getResponseFirstError: (response?: AxiosResponse) => IResponseFirstError;
7
+ export declare const getGraphQLResponseFormatError: TGetResponseFormatError;
8
+ /**
9
+ * 返回 Axios 格式錯誤 with RestFul
10
+ * @param response
11
+ */
12
+ export declare const getRestFulResponseFormatError: TGetResponseFormatError;