@acrool/react-fetcher 0.0.2-alpha.1 → 0.0.2-alpha.11
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/README.md +79 -49
- package/dist/FetcherProvider/FetcherProvider.d.ts +14 -9
- 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 +2240 -2180
- package/dist/{FetcherProvider/config.d.ts → config/i18nDict.d.ts} +0 -1
- package/dist/createAxios.d.ts +2 -0
- package/dist/fetchers/config.d.ts +1 -0
- package/dist/fetchers/createGraphQLFetcher/createGraphQLFetcher.d.ts +11 -0
- package/dist/fetchers/createGraphQLFetcher/index.d.ts +2 -0
- package/dist/fetchers/createGraphQLFetcher/types.d.ts +8 -0
- package/dist/fetchers/createRestFulFetcher/createRestFulFetcher.d.ts +11 -0
- package/dist/fetchers/createRestFulFetcher/index.d.ts +2 -0
- package/dist/fetchers/createRestFulFetcher/types.d.ts +16 -0
- package/dist/fetchers/createRestFulFetcher/utils.d.ts +12 -0
- package/dist/fetchers/index.d.ts +3 -2
- package/dist/fetchers/types.d.ts +9 -7
- package/dist/index.d.ts +1 -0
- package/package.json +1 -1
- package/dist/fetchers/graphqlFetcher.d.ts +0 -4
- /package/dist/fetchers/{utils.d.ts → createGraphQLFetcher/utils.d.ts} +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const fetcherLeastTime = 400;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { AxiosInstance } from 'axios';
|
|
2
|
+
import { IUseFetcherArgs } from './types';
|
|
3
|
+
import { TFileMapVariables } from './utils';
|
|
4
|
+
/**
|
|
5
|
+
* GraphQL 的查詢器
|
|
6
|
+
* https://the-guild.dev/graphql/codegen/plugins/typescript/typescript-react-query#usage-example-isreacthook-true
|
|
7
|
+
* @param axiosInstance
|
|
8
|
+
* @param query
|
|
9
|
+
*/
|
|
10
|
+
declare const createGraphQLFetcher: <TData, TArgs extends IUseFetcherArgs<TFileMapVariables>>(axiosInstance: AxiosInstance, query: string) => ((args?: TArgs) => Promise<TData>);
|
|
11
|
+
export default createGraphQLFetcher;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { AxiosInstance } from 'axios';
|
|
2
|
+
import { IDocument, IUseFetcherArgs, TContentTypeResolver, TFileMapVariables } from './types';
|
|
3
|
+
/**
|
|
4
|
+
* RestFul 的查詢器
|
|
5
|
+
* https://the-guild.dev/graphql/codegen/plugins/typescript/typescript-react-query#usage-example-isreacthook-true
|
|
6
|
+
* @param axiosInstance
|
|
7
|
+
* @param document
|
|
8
|
+
* @param contentTypeResolver
|
|
9
|
+
*/
|
|
10
|
+
declare const createRestFulFetcher: <TData, TArgs extends IUseFetcherArgs<TFileMapVariables>>(axiosInstance: AxiosInstance, document: IDocument, contentTypeResolver?: TContentTypeResolver) => ((args?: TArgs) => Promise<TData>);
|
|
11
|
+
export default createRestFulFetcher;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { IRequestConfig } from '../types';
|
|
2
|
+
export type IUseFetcherArgs<TVariables> = TVariables | (TVariables & {
|
|
3
|
+
fetchOptions?: IRequestConfig;
|
|
4
|
+
});
|
|
5
|
+
export interface IDocument {
|
|
6
|
+
url: string;
|
|
7
|
+
method?: string;
|
|
8
|
+
}
|
|
9
|
+
export type TFileMapVariables = Record<string, any>;
|
|
10
|
+
export type TBody = Record<string, any> | FormData | File[] | File;
|
|
11
|
+
export type TContentTypeResolver = (method: string) => string;
|
|
12
|
+
export declare enum ERequestHeaderContentType {
|
|
13
|
+
formData = "multipart/form-data",
|
|
14
|
+
formUrlDecode = "application/x-www-form-urlencoded",
|
|
15
|
+
json = "application/json"
|
|
16
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { TBody, TContentTypeResolver, ERequestHeaderContentType } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* 依據 Content-Type 處理 body
|
|
4
|
+
* @param data
|
|
5
|
+
* @param contentType
|
|
6
|
+
*/
|
|
7
|
+
export declare const getDataWithContentType: (contentType: ERequestHeaderContentType, data?: TBody) => FormData | string;
|
|
8
|
+
/**
|
|
9
|
+
* 根據 method 取得 Content-Type
|
|
10
|
+
* @param method
|
|
11
|
+
*/
|
|
12
|
+
export declare const getContentTypeWithMethod: TContentTypeResolver;
|
package/dist/fetchers/index.d.ts
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
export
|
|
2
|
-
export
|
|
1
|
+
export * from './createGraphQLFetcher';
|
|
2
|
+
export * from './createRestFulFetcher';
|
|
3
|
+
export type { IRequestConfig } from './types';
|
package/dist/fetchers/types.d.ts
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
|
-
import { InternalAxiosRequestConfig } from 'axios';
|
|
2
|
-
|
|
1
|
+
import { AxiosRequestConfig, InternalAxiosRequestConfig } from 'axios';
|
|
2
|
+
interface IFetchOptions {
|
|
3
|
+
pendingRequest?: boolean;
|
|
3
4
|
requestCode?: string;
|
|
5
|
+
forceGuest?: boolean;
|
|
6
|
+
leastTime?: number;
|
|
7
|
+
timeout?: number;
|
|
4
8
|
}
|
|
5
|
-
export interface
|
|
6
|
-
variables?: TVariables;
|
|
7
|
-
fetchOptions?: IFetchOptions;
|
|
9
|
+
export interface IInternalRequestConfig extends InternalAxiosRequestConfig, IFetchOptions {
|
|
8
10
|
}
|
|
9
|
-
export interface
|
|
10
|
-
variables?: TVariables;
|
|
11
|
+
export interface IRequestConfig extends AxiosRequestConfig, IFetchOptions {
|
|
11
12
|
}
|
|
13
|
+
export {};
|
package/dist/index.d.ts
CHANGED
package/package.json
CHANGED
|
File without changes
|