import { FetchConfigType, FetchConfigTypeNoUrl, FetchContextType, FetchInit, ImperativeFetch, TimeSpan } from '../types'; /** * Get the current fetcher config */ export declare function useFetchConfig(id?: unknown): FetchInit & FetchContextType; export declare function useFetchSuspense(init: FetchConfigType | string, options?: FetchConfigTypeNoUrl): { refresh(): void; resetError(): void; formProps: { action: (form: FormData) => Promise; ref: import("react").RefObject; }; formRef: import("react").RefObject; hasData: boolean; revalidating: boolean; success: boolean; loadingFirst: boolean; isLoadingFirst: boolean; expiration: Date; data: FetchDataType; isPending?: boolean; loading: boolean; isLoading: boolean; isRevalidating: boolean; error: any; online: boolean; code: number; reFetch: () => Promise; submit: (submitData: any) => Promise; mutate: (update: FetchDataType | ((prev: FetchDataType) => FetchDataType), callback?: ((data: FetchDataType, fetcher: ImperativeFetch) => void) | undefined) => FetchDataType; fetcher: ImperativeFetch; abort: () => void; config: Required> & { baseUrl: string; url: string; rawUrl: string; }; response: import("../types").CustomResponse; id: any; key: string; responseTime: number; requestStart: Date; requestEnd: Date; }; /** * Get the data state of a request using its id */ export declare function useFetchData(id: ResponseType extends { value: ResponseType; variables: VT; errors?: any[]; } ? { value: ResponseType; variables: VT; errors?: any[]; } : string | number | object, onResolve?: (data: typeof id extends { variables: any; } ? { data: (Required & { value: ResponseType; variables: VT; })['value']; variables: (Required & { value: ResponseType; variables: VT; })['variables']; } : ResponseType, res: Response) => void): ResponseType; export declare function useFetchCode(id: any): number; /** * Get the loading state of a request using its id */ export declare function useFetchLoading(id: any): boolean; /** * Get the error state of a request using its id */ export declare function useFetchError(id: any, onError?: (err?: any) => void): any; /** * Get the mutate the request data using its id */ export declare function useFetchMutate( /** * The id of the `useFetch` call */ id: T extends typeof undefined ? any : FetchInit, /** * The function to run after mutating */ onMutate?: (data: T, /** * An imperative version of `useFetch` */ fetcher: ImperativeFetch) => void): (update: T | ((prev: T) => T), callback?: ((data: T, fetcher: ImperativeFetch) => void) | undefined) => T; export declare function useOnline(id: any): boolean; export declare function useLoadingFirst(id: any): boolean; export declare function useReFetch(id: any): () => Promise; export declare function useRevalidating(id: any): boolean; export declare function useExpiration(id: any): Date; export declare function useHasData(id: any): boolean; export declare function useSuccess(id: any): boolean; /** * @deprecated - Use the useFetch hook instead * Get everything from a `useFetch` call using its id */ export declare function useFetchId(id: any): { refresh(): void; resetError(): void; formProps: { action: (form: FormData) => Promise; ref: import("react").RefObject; }; formRef: import("react").RefObject; hasData: boolean; revalidating: boolean; success: boolean; loadingFirst: boolean; isLoadingFirst: boolean; expiration: Date; data: ResponseType; isPending?: boolean; loading: boolean; isLoading: boolean; isRevalidating: boolean; error: any; online: boolean; code: number; reFetch: () => Promise; submit: (submitData: any) => Promise; mutate: (update: ResponseType | ((prev: ResponseType) => ResponseType), callback?: ((data: ResponseType, fetcher: ImperativeFetch) => void) | undefined) => ResponseType; fetcher: ImperativeFetch; abort: () => void; config: Required> & { baseUrl: string; url: string; rawUrl: string; }; response: import("../types").CustomResponse; id: any; key: string; responseTime: number; requestStart: Date; requestEnd: Date; }; /** * Create an effect for when the request completes */ export declare function useResolve(id: ResponseType extends { variables: any; } ? string | number | object : { value: ResponseType; variables: VT; errors?: any[]; }, onResolve: (data: typeof id extends { variables: any; } ? { data: (Required & { value: ResponseType; })['value']; variables: (Required & { variables: VT; })['variables']; errors: (Required & { errors?: any[]; })['errors']; } : ResponseType, res: Response) => void): any; /** * User a `GET` request */ export declare function useGET(init: FetchConfigType | string, options?: FetchConfigTypeNoUrl): { refresh(): void; resetError(): void; formProps: { action: (form: FormData) => Promise; ref: import("react").RefObject; }; formRef: import("react").RefObject; hasData: boolean; revalidating: boolean; success: boolean; loadingFirst: boolean; isLoadingFirst: boolean; expiration: Date; data: FetchDataType; isPending?: boolean; loading: boolean; isLoading: boolean; isRevalidating: boolean; error: any; online: boolean; code: number; reFetch: () => Promise; submit: (submitData: any) => Promise; mutate: (update: FetchDataType | ((prev: FetchDataType) => FetchDataType), callback?: ((data: FetchDataType, fetcher: ImperativeFetch) => void) | undefined) => FetchDataType; fetcher: ImperativeFetch; abort: () => void; config: Required> & { baseUrl: string; url: string; rawUrl: string; }; response: import("../types").CustomResponse; id: any; key: string; responseTime: number; requestStart: Date; requestEnd: Date; }; /** * Use a `DELETE` request */ export declare function useDELETE(init: FetchConfigType | string, options?: FetchConfigTypeNoUrl): { refresh(): void; resetError(): void; formProps: { action: (form: FormData) => Promise; ref: import("react").RefObject; }; formRef: import("react").RefObject; hasData: boolean; revalidating: boolean; success: boolean; loadingFirst: boolean; isLoadingFirst: boolean; expiration: Date; data: FetchDataType; isPending?: boolean; loading: boolean; isLoading: boolean; isRevalidating: boolean; error: any; online: boolean; code: number; reFetch: () => Promise; submit: (submitData: any) => Promise; mutate: (update: FetchDataType | ((prev: FetchDataType) => FetchDataType), callback?: ((data: FetchDataType, fetcher: ImperativeFetch) => void) | undefined) => FetchDataType; fetcher: ImperativeFetch; abort: () => void; config: Required> & { baseUrl: string; url: string; rawUrl: string; }; response: import("../types").CustomResponse; id: any; key: string; responseTime: number; requestStart: Date; requestEnd: Date; }; /** * Use a `HEAD` request */ export declare function useHEAD(init: FetchConfigType | string, options?: FetchConfigTypeNoUrl): { refresh(): void; resetError(): void; formProps: { action: (form: FormData) => Promise; ref: import("react").RefObject; }; formRef: import("react").RefObject; hasData: boolean; revalidating: boolean; success: boolean; loadingFirst: boolean; isLoadingFirst: boolean; expiration: Date; data: FetchDataType; isPending?: boolean; loading: boolean; isLoading: boolean; isRevalidating: boolean; error: any; online: boolean; code: number; reFetch: () => Promise; submit: (submitData: any) => Promise; mutate: (update: FetchDataType | ((prev: FetchDataType) => FetchDataType), callback?: ((data: FetchDataType, fetcher: ImperativeFetch) => void) | undefined) => FetchDataType; fetcher: ImperativeFetch; abort: () => void; config: Required> & { baseUrl: string; url: string; rawUrl: string; }; response: import("../types").CustomResponse; id: any; key: string; responseTime: number; requestStart: Date; requestEnd: Date; }; /** * Use an `OPTIONS` request */ export declare function useOPTIONS(init: FetchConfigType | string, options?: FetchConfigTypeNoUrl): { refresh(): void; resetError(): void; formProps: { action: (form: FormData) => Promise; ref: import("react").RefObject; }; formRef: import("react").RefObject; hasData: boolean; revalidating: boolean; success: boolean; loadingFirst: boolean; isLoadingFirst: boolean; expiration: Date; data: FetchDataType; isPending?: boolean; loading: boolean; isLoading: boolean; isRevalidating: boolean; error: any; online: boolean; code: number; reFetch: () => Promise; submit: (submitData: any) => Promise; mutate: (update: FetchDataType | ((prev: FetchDataType) => FetchDataType), callback?: ((data: FetchDataType, fetcher: ImperativeFetch) => void) | undefined) => FetchDataType; fetcher: ImperativeFetch; abort: () => void; config: Required> & { baseUrl: string; url: string; rawUrl: string; }; response: import("../types").CustomResponse; id: any; key: string; responseTime: number; requestStart: Date; requestEnd: Date; }; /** * Use a `POST` request */ export declare function usePOST(init: FetchConfigType | string, options?: FetchConfigTypeNoUrl): { refresh(): void; resetError(): void; formProps: { action: (form: FormData) => Promise; ref: import("react").RefObject; }; formRef: import("react").RefObject; hasData: boolean; revalidating: boolean; success: boolean; loadingFirst: boolean; isLoadingFirst: boolean; expiration: Date; data: FetchDataType; isPending?: boolean; loading: boolean; isLoading: boolean; isRevalidating: boolean; error: any; online: boolean; code: number; reFetch: () => Promise; submit: (submitData: any) => Promise; mutate: (update: FetchDataType | ((prev: FetchDataType) => FetchDataType), callback?: ((data: FetchDataType, fetcher: ImperativeFetch) => void) | undefined) => FetchDataType; fetcher: ImperativeFetch; abort: () => void; config: Required> & { baseUrl: string; url: string; rawUrl: string; }; response: import("../types").CustomResponse; id: any; key: string; responseTime: number; requestStart: Date; requestEnd: Date; }; /** * Use a `PUT` request */ export declare function usePUT(init: FetchConfigType | string, options?: FetchConfigTypeNoUrl): { refresh(): void; resetError(): void; formProps: { action: (form: FormData) => Promise; ref: import("react").RefObject; }; formRef: import("react").RefObject; hasData: boolean; revalidating: boolean; success: boolean; loadingFirst: boolean; isLoadingFirst: boolean; expiration: Date; data: FetchDataType; isPending?: boolean; loading: boolean; isLoading: boolean; isRevalidating: boolean; error: any; online: boolean; code: number; reFetch: () => Promise; submit: (submitData: any) => Promise; mutate: (update: FetchDataType | ((prev: FetchDataType) => FetchDataType), callback?: ((data: FetchDataType, fetcher: ImperativeFetch) => void) | undefined) => FetchDataType; fetcher: ImperativeFetch; abort: () => void; config: Required> & { baseUrl: string; url: string; rawUrl: string; }; response: import("../types").CustomResponse; id: any; key: string; responseTime: number; requestStart: Date; requestEnd: Date; }; /** * Use a `PATCH` request */ export declare function usePATCH(init: FetchConfigType | string, options?: FetchConfigTypeNoUrl): { refresh(): void; resetError(): void; formProps: { action: (form: FormData) => Promise; ref: import("react").RefObject; }; formRef: import("react").RefObject; hasData: boolean; revalidating: boolean; success: boolean; loadingFirst: boolean; isLoadingFirst: boolean; expiration: Date; data: FetchDataType; isPending?: boolean; loading: boolean; isLoading: boolean; isRevalidating: boolean; error: any; online: boolean; code: number; reFetch: () => Promise; submit: (submitData: any) => Promise; mutate: (update: FetchDataType | ((prev: FetchDataType) => FetchDataType), callback?: ((data: FetchDataType, fetcher: ImperativeFetch) => void) | undefined) => FetchDataType; fetcher: ImperativeFetch; abort: () => void; config: Required> & { baseUrl: string; url: string; rawUrl: string; }; response: import("../types").CustomResponse; id: any; key: string; responseTime: number; requestStart: Date; requestEnd: Date; }; /** * Use a `PURGE` request */ export declare function usePURGE(init: FetchConfigType | string, options?: FetchConfigTypeNoUrl): { refresh(): void; resetError(): void; formProps: { action: (form: FormData) => Promise; ref: import("react").RefObject; }; formRef: import("react").RefObject; hasData: boolean; revalidating: boolean; success: boolean; loadingFirst: boolean; isLoadingFirst: boolean; expiration: Date; data: FetchDataType; isPending?: boolean; loading: boolean; isLoading: boolean; isRevalidating: boolean; error: any; online: boolean; code: number; reFetch: () => Promise; submit: (submitData: any) => Promise; mutate: (update: FetchDataType | ((prev: FetchDataType) => FetchDataType), callback?: ((data: FetchDataType, fetcher: ImperativeFetch) => void) | undefined) => FetchDataType; fetcher: ImperativeFetch; abort: () => void; config: Required> & { baseUrl: string; url: string; rawUrl: string; }; response: import("../types").CustomResponse; id: any; key: string; responseTime: number; requestStart: Date; requestEnd: Date; }; /** * Use a `LINK` request */ export declare function useLINK(init: FetchConfigType | string, options?: FetchConfigTypeNoUrl): { refresh(): void; resetError(): void; formProps: { action: (form: FormData) => Promise; ref: import("react").RefObject; }; formRef: import("react").RefObject; hasData: boolean; revalidating: boolean; success: boolean; loadingFirst: boolean; isLoadingFirst: boolean; expiration: Date; data: FetchDataType; isPending?: boolean; loading: boolean; isLoading: boolean; isRevalidating: boolean; error: any; online: boolean; code: number; reFetch: () => Promise; submit: (submitData: any) => Promise; mutate: (update: FetchDataType | ((prev: FetchDataType) => FetchDataType), callback?: ((data: FetchDataType, fetcher: ImperativeFetch) => void) | undefined) => FetchDataType; fetcher: ImperativeFetch; abort: () => void; config: Required> & { baseUrl: string; url: string; rawUrl: string; }; response: import("../types").CustomResponse; id: any; key: string; responseTime: number; requestStart: Date; requestEnd: Date; }; /** * Use an `UNLINK` request */ export declare function useUNLINK(init: FetchConfigType | string, options?: FetchConfigTypeNoUrl): { refresh(): void; resetError(): void; formProps: { action: (form: FormData) => Promise; ref: import("react").RefObject; }; formRef: import("react").RefObject; hasData: boolean; revalidating: boolean; success: boolean; loadingFirst: boolean; isLoadingFirst: boolean; expiration: Date; data: FetchDataType; isPending?: boolean; loading: boolean; isLoading: boolean; isRevalidating: boolean; error: any; online: boolean; code: number; reFetch: () => Promise; submit: (submitData: any) => Promise; mutate: (update: FetchDataType | ((prev: FetchDataType) => FetchDataType), callback?: ((data: FetchDataType, fetcher: ImperativeFetch) => void) | undefined) => FetchDataType; fetcher: ImperativeFetch; abort: () => void; config: Required> & { baseUrl: string; url: string; rawUrl: string; }; response: import("../types").CustomResponse; id: any; key: string; responseTime: number; requestStart: Date; requestEnd: Date; }; /** * Use a request without making it automatically */ export declare function useManualFetch(init: FetchConfigType | string, options?: FetchConfigTypeNoUrl): { refresh(): void; resetError(): void; formProps: { action: (form: FormData) => Promise; ref: import("react").RefObject; }; formRef: import("react").RefObject; hasData: boolean; revalidating: boolean; success: boolean; loadingFirst: boolean; isLoadingFirst: boolean; expiration: Date; data: FetchDataType; isPending?: boolean; loading: boolean; isLoading: boolean; isRevalidating: boolean; error: any; online: boolean; code: number; reFetch: () => Promise; submit: (submitData: any) => Promise; mutate: (update: FetchDataType | ((prev: FetchDataType) => FetchDataType), callback?: ((data: FetchDataType, fetcher: ImperativeFetch) => void) | undefined) => FetchDataType; fetcher: ImperativeFetch; abort: () => void; config: Required> & { baseUrl: string; url: string; rawUrl: string; }; response: import("../types").CustomResponse; id: any; key: string; responseTime: number; requestStart: Date; requestEnd: Date; }; /** * Get a blob of the response. You can pass an `objectURL` property that will convet that blob into a string using `URL.createObjectURL` */ export declare function useFetchBlob(init: (FetchConfigType & { objectURL?: boolean; }) | string, options?: FetchConfigTypeNoUrl & { objectURL?: boolean; }): { refresh(): void; resetError(): void; formProps: { action: (form: FormData) => Promise; ref: import("react").RefObject; }; formRef: import("react").RefObject; hasData: boolean; revalidating: boolean; success: boolean; loadingFirst: boolean; isLoadingFirst: boolean; expiration: Date; data: FetchDataType; isPending?: boolean; loading: boolean; isLoading: boolean; isRevalidating: boolean; error: any; online: boolean; code: number; reFetch: () => Promise; submit: (submitData: any) => Promise; mutate: (update: FetchDataType | ((prev: FetchDataType) => FetchDataType), callback?: ((data: FetchDataType, fetcher: ImperativeFetch) => void) | undefined) => FetchDataType; fetcher: ImperativeFetch; abort: () => void; config: Required> & { baseUrl: string; url: string; rawUrl: string; }; response: import("../types").CustomResponse; id: any; key: string; responseTime: number; requestStart: Date; requestEnd: Date; }; /** * Get a text of the response */ export declare function useFetchText(init: FetchConfigType | string, options?: FetchConfigTypeNoUrl): { refresh(): void; resetError(): void; formProps: { action: (form: FormData) => Promise; ref: import("react").RefObject; }; formRef: import("react").RefObject; hasData: boolean; revalidating: boolean; success: boolean; loadingFirst: boolean; isLoadingFirst: boolean; expiration: Date; data: string; isPending?: boolean; loading: boolean; isLoading: boolean; isRevalidating: boolean; error: any; online: boolean; code: number; reFetch: () => Promise; submit: (submitData: any) => Promise; mutate: (update: string | ((prev: string) => string), callback?: ((data: string, fetcher: ImperativeFetch) => void) | undefined) => string; fetcher: ImperativeFetch; abort: () => void; config: Required> & { baseUrl: string; url: string; rawUrl: string; }; response: import("../types").CustomResponse; id: any; key: string; responseTime: number; requestStart: Date; requestEnd: Date; }; export declare function useFetchResponseTime(id: any): number; /** * Get the `Date` the request started */ export declare function useRequestStart(id: any): Date; /** * Get the `Date` the request finished */ export declare function useRequestEnd(id: any): Date; /** * Debounce a fetch by the time given */ export declare function useDebounceFetch(init: (Omit, 'debounce'> & { debounce?: TimeSpan; }) | string | Request, options?: Omit, 'debounce'> & { debounce?: TimeSpan; }): { refresh(): void; resetError(): void; formProps: { action: (form: FormData) => Promise; ref: import("react").RefObject; }; formRef: import("react").RefObject; hasData: boolean; revalidating: boolean; success: boolean; loadingFirst: boolean; isLoadingFirst: boolean; expiration: Date; data: FetchDataType; isPending?: boolean; loading: boolean; isLoading: boolean; isRevalidating: boolean; error: any; online: boolean; code: number; reFetch: () => Promise; submit: (submitData: any) => Promise; mutate: (update: FetchDataType | ((prev: FetchDataType) => FetchDataType), callback?: ((data: FetchDataType, fetcher: ImperativeFetch) => void) | undefined) => FetchDataType; fetcher: ImperativeFetch; abort: () => void; config: Required> & { baseUrl: string; url: string; rawUrl: string; }; response: import("../types").CustomResponse; id: any; key: string; responseTime: number; requestStart: Date; requestEnd: Date; }; /** * Make a graphQL request */ export declare function useGql(arg1: undefined | { value: T; variables: VT; }, cfg?: FetchConfigTypeNoUrl & { /** * GraphQL variables */ variables?: typeof arg1 extends undefined ? VT : (typeof arg1 & { value: T; variables: VT; })['variables']; /** * Override the GraphQL path * * (default is `'/graphql'`) */ graphqlPath?: string; }): Omit<{ refresh(): void; resetError(): void; formProps: { action: (form: FormData) => Promise; ref: import("react").RefObject; }; formRef: import("react").RefObject; hasData: boolean; revalidating: boolean; success: boolean; loadingFirst: boolean; isLoadingFirst: boolean; expiration: Date; data: any; isPending?: boolean; loading: boolean; isLoading: boolean; isRevalidating: boolean; error: any; online: boolean; code: number; reFetch: () => Promise; submit: (submitData: any) => Promise; mutate: (update: any, callback?: ((data: any, fetcher: ImperativeFetch) => void) | undefined) => any; fetcher: ImperativeFetch; abort: () => void; config: Required> & { baseUrl: string; url: string; rawUrl: string; }; response: import("../types").CustomResponse; id: any; key: string; responseTime: number; requestStart: Date; requestEnd: Date; }, "data"> & { data: { data: T; errors: any[]; variables: VT; }; }; /** * Use an imperative version of the fetcher (similarly to Axios, it returns an object with `get`, `post`, etc) */ export declare function useImperative(): ImperativeFetch; export declare function useServerAction any>(action: T, config?: Omit>['data']>, 'params' | 'onSubmit'> & { onSubmit?: 'reset' | ((form: HTMLFormElement, formData: Parameters[0]) => void); } & (Parameters[0] extends typeof undefined ? {} : { params?: Parameters[0]; })): Omit<{ refresh(): void; resetError(): void; formProps: { action: (form: FormData) => Promise; ref: import("react").RefObject; }; formRef: import("react").RefObject; hasData: boolean; revalidating: boolean; success: boolean; loadingFirst: boolean; isLoadingFirst: boolean; expiration: Date; data: Awaited>["data"]; isPending?: boolean; loading: boolean; isLoading: boolean; isRevalidating: boolean; error: any; online: boolean; code: number; reFetch: () => Promise; submit: (submitData: any) => Promise; mutate: (update: Awaited>["data"] | ((prev: Awaited>["data"]) => Awaited>["data"]), callback?: ((data: Awaited>["data"], fetcher: ImperativeFetch) => void) | undefined) => Awaited>["data"]; fetcher: ImperativeFetch; abort: () => void; config: Required>["data"], any>> & { baseUrl: string; url: string; rawUrl: string; }; response: import("../types").CustomResponse>["data"]>; id: any; key: string; responseTime: number; requestStart: Date; requestEnd: Date; }, "submit"> & { submit: (submitData: Parameters[0]) => void; }; /** * `useServerMutation` works exactly like `useServerAction` except it is not automatic */ export declare function useServerMutation any>(action: T, config?: Omit>['data']>, 'params' | 'onSubmit'> & { onSubmit?: 'reset' | ((form: HTMLFormElement, formData: Parameters[0]) => void); } & (Parameters[0] extends typeof undefined ? {} : { params?: Parameters[0]; })): Omit<{ refresh(): void; resetError(): void; formProps: { action: (form: FormData) => Promise; ref: import("react").RefObject; }; formRef: import("react").RefObject; hasData: boolean; revalidating: boolean; success: boolean; loadingFirst: boolean; isLoadingFirst: boolean; expiration: Date; data: Awaited>["data"]; isPending?: boolean; loading: boolean; isLoading: boolean; isRevalidating: boolean; error: any; online: boolean; code: number; reFetch: () => Promise; submit: (submitData: any) => Promise; mutate: (update: Awaited>["data"] | ((prev: Awaited>["data"]) => Awaited>["data"]), callback?: ((data: Awaited>["data"], fetcher: ImperativeFetch) => void) | undefined) => Awaited>["data"]; fetcher: ImperativeFetch; abort: () => void; config: Required>["data"], any>> & { baseUrl: string; url: string; rawUrl: string; }; response: import("../types").CustomResponse>["data"]>; id: any; key: string; responseTime: number; requestStart: Date; requestEnd: Date; }, "submit"> & { submit: (submitData: Parameters[0]) => void; }; export declare const useAction: typeof useServerAction; export declare const useMutation: typeof useServerMutation; export declare const useFetchMutation: typeof useManualFetch;