@acrool/react-fetcher 0.0.2-alpha.9 → 0.0.3-alpha.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/dist/AuthStateProvider/AuthStateProvider.d.ts +2 -1
- package/dist/acrool-react-fetcher.es.js +852 -895
- package/dist/fetchers/createGraphQLFetcher/createGraphQLFetcher.d.ts +4 -3
- package/dist/fetchers/createGraphQLFetcher/index.d.ts +1 -1
- package/dist/fetchers/createGraphQLFetcher/types.d.ts +1 -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 +10 -2
- package/dist/fetchers/createRestFulFetcher/utils.d.ts +10 -7
- package/package.json +1 -1
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { AxiosInstance } from 'axios';
|
|
2
|
-
import {
|
|
2
|
+
import { IUseGraphQLFetcherArgs } 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
|
*/
|
|
9
|
-
declare const createGraphQLFetcher: <TData, TArgs extends
|
|
10
|
+
declare const createGraphQLFetcher: <TData, TArgs extends IUseGraphQLFetcherArgs<TFileMapVariables>>(axiosInstance: AxiosInstance, query: string) => ((args?: TArgs) => Promise<TData>);
|
|
10
11
|
export default createGraphQLFetcher;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export { default as createGraphQLFetcher } from './createGraphQLFetcher';
|
|
2
|
-
export type {
|
|
2
|
+
export type { IUseGraphQLFetcherArgs } from './types';
|
|
@@ -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,
|
|
2
|
+
import { IDocument, IUseRestFulFetcherArgs, 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
|
|
10
|
+
declare const createRestFulFetcher: <TData, TArgs extends IUseRestFulFetcherArgs<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 {
|
|
3
|
-
export
|
|
2
|
+
export type { IUseRestFulFetcherArgs, TContentTypeResolver } from './types';
|
|
3
|
+
export * from './config';
|
|
@@ -1,9 +1,17 @@
|
|
|
1
1
|
import { IRequestConfig } from '../types';
|
|
2
|
-
|
|
2
|
+
import { ERequestMethod } from './config';
|
|
3
|
+
export type IUseRestFulFetcherArgs<TVariables> = [
|
|
4
|
+
TVariables
|
|
5
|
+
] extends [void] ? void | {
|
|
3
6
|
fetchOptions?: IRequestConfig;
|
|
4
|
-
}
|
|
7
|
+
} : {
|
|
8
|
+
variables: TVariables;
|
|
9
|
+
fetchOptions?: IRequestConfig;
|
|
10
|
+
};
|
|
5
11
|
export interface IDocument {
|
|
6
12
|
url: string;
|
|
7
13
|
method?: string;
|
|
8
14
|
}
|
|
9
15
|
export type TFileMapVariables = Record<string, any>;
|
|
16
|
+
export type TBody = Record<string, any> | FormData | File[] | File;
|
|
17
|
+
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;
|