@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
|
@@ -2,7 +2,8 @@ import { AxiosInstance } from 'axios';
|
|
|
2
2
|
import { IUseFetcherArgs } from './types';
|
|
3
3
|
import { TFileMapVariables } from './utils';
|
|
4
4
|
/**
|
|
5
|
-
*
|
|
5
|
+
* GraphQL 的查詢器
|
|
6
|
+
* https://the-guild.dev/graphql/codegen/plugins/typescript/typescript-react-query#usage-example-isreacthook-true
|
|
6
7
|
* @param axiosInstance
|
|
7
8
|
* @param query
|
|
8
9
|
*/
|
|
@@ -1,5 +1,12 @@
|
|
|
1
|
-
export declare enum
|
|
1
|
+
export declare enum ERequestContentType {
|
|
2
2
|
formData = "multipart/form-data",
|
|
3
3
|
formUrlDecode = "application/x-www-form-urlencoded",
|
|
4
4
|
json = "application/json"
|
|
5
5
|
}
|
|
6
|
+
export declare enum ERequestMethod {
|
|
7
|
+
GET = "GET",
|
|
8
|
+
POST = "POST",
|
|
9
|
+
PUT = "PUT",
|
|
10
|
+
DELETE = "DELETE",
|
|
11
|
+
PATCH = "PATCH"
|
|
12
|
+
}
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { AxiosInstance } from 'axios';
|
|
2
|
-
import { IDocument, IUseFetcherArgs, TFileMapVariables } from './types';
|
|
2
|
+
import { IDocument, IUseFetcherArgs, TContentTypeResolver, TFileMapVariables } from './types';
|
|
3
3
|
/**
|
|
4
4
|
* RestFul 的查詢器
|
|
5
|
+
* https://the-guild.dev/graphql/codegen/plugins/typescript/typescript-react-query#usage-example-isreacthook-true
|
|
5
6
|
* @param axiosInstance
|
|
6
7
|
* @param document
|
|
8
|
+
* @param contentTypeResolver
|
|
7
9
|
*/
|
|
8
|
-
declare const createRestFulFetcher: <TData, TArgs extends IUseFetcherArgs<TFileMapVariables>>(axiosInstance: AxiosInstance, document: IDocument) => ((args?: TArgs) => Promise<TData>);
|
|
10
|
+
declare const createRestFulFetcher: <TData, TArgs extends IUseFetcherArgs<TFileMapVariables>>(axiosInstance: AxiosInstance, document: IDocument, contentTypeResolver?: TContentTypeResolver) => ((args?: TArgs) => Promise<TData>);
|
|
9
11
|
export default createRestFulFetcher;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export { default as createRestFulFetcher } from './createRestFulFetcher';
|
|
2
|
-
export type { IUseFetcherArgs as IUseRestFulFetcherArgs } from './types';
|
|
3
|
-
export
|
|
2
|
+
export type { IUseFetcherArgs as IUseRestFulFetcherArgs, TContentTypeResolver } from './types';
|
|
3
|
+
export * from './config';
|
|
@@ -1,17 +1,12 @@
|
|
|
1
1
|
import { IRequestConfig } from '../types';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
body?: TVariables['body'];
|
|
5
|
-
variables?: TVariables['variables'];
|
|
2
|
+
import { ERequestMethod } from './config';
|
|
3
|
+
export type IUseFetcherArgs<TVariables> = TVariables | (TVariables & {
|
|
6
4
|
fetchOptions?: IRequestConfig;
|
|
7
|
-
}
|
|
8
|
-
export interface IObjectArgs {
|
|
9
|
-
params?: unknown;
|
|
10
|
-
variables?: unknown;
|
|
11
|
-
body?: unknown;
|
|
12
|
-
}
|
|
5
|
+
});
|
|
13
6
|
export interface IDocument {
|
|
14
7
|
url: string;
|
|
15
8
|
method?: string;
|
|
16
9
|
}
|
|
17
10
|
export type TFileMapVariables = Record<string, any>;
|
|
11
|
+
export type TBody = Record<string, any> | FormData | File[] | File;
|
|
12
|
+
export type TContentTypeResolver = (method: ERequestMethod) => string;
|
|
@@ -1,10 +1,13 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ERequestContentType } from './config';
|
|
2
|
+
import { TBody, TContentTypeResolver } from './types';
|
|
2
3
|
/**
|
|
3
|
-
*
|
|
4
|
-
* @param
|
|
4
|
+
* 依據 Content-Type 處理 body
|
|
5
|
+
* @param data
|
|
5
6
|
* @param contentType
|
|
6
7
|
*/
|
|
7
|
-
export declare
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
export declare const getDataWithContentType: (contentType: ERequestContentType, data?: TBody) => FormData | string;
|
|
9
|
+
/**
|
|
10
|
+
* 根據 method 取得 Content-Type
|
|
11
|
+
* @param method
|
|
12
|
+
*/
|
|
13
|
+
export declare const getContentTypeWithMethod: TContentTypeResolver;
|