@acrool/react-fetcher 0.0.2-alpha.3 → 0.0.2-alpha.5

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,2 +1 @@
1
- export declare const axiosInstance: import('axios').AxiosInstance;
2
1
  export declare const defaultI18nDict: Record<string, Record<string, string>>;
@@ -0,0 +1,4 @@
1
+ import { default as axios } from 'axios';
2
+ type TCreateAxiosInstanceConfig = ReturnType<typeof axios.create>;
3
+ export declare const createAxiosInstance: (config?: TCreateAxiosInstanceConfig) => import('axios').AxiosInstance;
4
+ export {};
@@ -0,0 +1 @@
1
+ export declare const fetcherLeastTime = 400;
@@ -0,0 +1,10 @@
1
+ import { AxiosInstance } from 'axios';
2
+ import { IUseFetcherArgs } from './types';
3
+ import { TFileMapVariables } from './utils';
4
+ /**
5
+ * GrqpahQL 的查詢氣
6
+ * @param axiosInstance
7
+ * @param query
8
+ */
9
+ declare const createGraphQL2Fetcher: <TData, TArgs extends IUseFetcherArgs<TFileMapVariables>>(axiosInstance: AxiosInstance, query: string) => ((args?: TArgs) => Promise<TData>);
10
+ export default createGraphQL2Fetcher;
@@ -0,0 +1 @@
1
+ export { default as createGraphQLFetcher } from './createGraphQL2Fetcher';
@@ -0,0 +1,8 @@
1
+ import { IRequestConfig } from '../types';
2
+ export interface IUseFetcherArgs<TVariables = {}> {
3
+ variables?: TVariables;
4
+ fetchOptions?: IRequestConfig;
5
+ }
6
+ export interface IUseSubscriptionArgs<TVariables> {
7
+ variables?: TVariables;
8
+ }
@@ -0,0 +1,5 @@
1
+ export declare enum ERequestHeader {
2
+ formData = "multipart/form-data",
3
+ formUrlDecode = "application/x-www-form-urlencoded",
4
+ json = "application/json"
5
+ }
@@ -0,0 +1,9 @@
1
+ import { AxiosInstance } from 'axios';
2
+ import { IDocument, IUseFetcherArgs, TFileMapVariables } from './types';
3
+ /**
4
+ * RestFul 的查詢器
5
+ * @param axiosInstance
6
+ * @param document
7
+ */
8
+ declare const createRestFulFetcher: <TData, TArgs extends IUseFetcherArgs<TFileMapVariables>>(axiosInstance: AxiosInstance, document: IDocument) => ((args?: TArgs) => Promise<TData>);
9
+ export default createRestFulFetcher;
@@ -0,0 +1 @@
1
+ export { default as createRestFulFetcher } from './createRestFulFetcher';
@@ -0,0 +1,17 @@
1
+ import { IRequestConfig } from '../types';
2
+ export interface IUseFetcherArgs<TVariables extends IObjectArgs> {
3
+ params?: TVariables['params'];
4
+ body?: TVariables['body'];
5
+ variables?: TVariables['variables'];
6
+ fetchOptions?: IRequestConfig;
7
+ }
8
+ export interface IObjectArgs {
9
+ params?: unknown;
10
+ variables?: unknown;
11
+ body?: unknown;
12
+ }
13
+ export interface IDocument {
14
+ url: string;
15
+ method?: string;
16
+ }
17
+ export type TFileMapVariables = Record<string, any>;
@@ -0,0 +1,10 @@
1
+ import { ERequestHeader } from './config';
2
+ /**
3
+ *
4
+ * @param obj 送出物件
5
+ * @param contentType
6
+ */
7
+ export declare function flattenObjectToFormData(obj: Record<string, any>, contentType: ERequestHeader): {
8
+ body: FormData | string;
9
+ contentType: string;
10
+ };
@@ -1,2 +1,3 @@
1
- export { default as graphqlFetcher } from './graphqlFetcher';
2
- export type { IFetchOptions, IUseFetcherArgs, IUseSubscriptionArgs } from './types';
1
+ export * from './createGraphQL2Fetcher';
2
+ export * from './createRestFulFetcher';
3
+ export type { IRequestConfig } from './types';
@@ -1,11 +1,12 @@
1
- import { InternalAxiosRequestConfig } from 'axios';
2
- export interface IFetchOptions extends InternalAxiosRequestConfig {
1
+ import { AxiosRequestConfig, InternalAxiosRequestConfig } from 'axios';
2
+ export interface IFetchOptions {
3
+ pendingRequest?: boolean;
3
4
  requestCode?: string;
5
+ forceGuest?: boolean;
6
+ leastTime?: number;
7
+ timeout?: number;
4
8
  }
5
- export interface IUseFetcherArgs<TVariables = {}> {
6
- variables?: TVariables;
7
- fetchOptions?: IFetchOptions;
9
+ export interface IInternalRequestConfig extends InternalAxiosRequestConfig, IFetchOptions {
8
10
  }
9
- export interface IUseSubscriptionArgs<TVariables> {
10
- variables?: TVariables;
11
+ export interface IRequestConfig extends AxiosRequestConfig, IFetchOptions {
11
12
  }
package/dist/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
1
  export * from './fetchers';
2
2
  export * from './FetcherProvider';
3
3
  export * from './AuthStateProvider';
4
+ export * from './createAxios';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@acrool/react-fetcher",
3
- "version": "0.0.2-alpha.3",
3
+ "version": "0.0.2-alpha.5",
4
4
  "description": "Fetcher library based for Reactjs",
5
5
  "keywords": [
6
6
  "acrool",
@@ -1,4 +0,0 @@
1
- import { IUseFetcherArgs } from './types';
2
- import { TFileMapVariables } from './utils';
3
- declare const graphqlFetcher: <TData, TArgs extends IUseFetcherArgs<TFileMapVariables>>(query: string) => ((args?: TArgs) => Promise<TData>);
4
- export default graphqlFetcher;