UNPKG

@mussnad/frappe-react-query

Version:
55 lines (54 loc) 2.72 kB
import { FrappeError, GetCountResponse, GetDocListArgs } from '../types'; import { UseQueryOptions } from '@tanstack/react-query'; import { GetCountArgs, GetDocArgs } from '@mussnad/frappe-js-client/dist/client/types'; import { FrappeDoc } from '@mussnad/frappe-js-client/dist/frappe/types'; /** * Fetches a list of documents from the Frappe database. * * @param doctype - The name of the document type to fetch * @param args - The arguments for the fetch operation * @param queryKey - The query key for the fetch operation * @param options - The options for the fetch operation * * @returns An object with the following properties: * * @typeParam T - The type definition of the document object * @typeParam K - The type of the document for args * * @example * const { data, error, isFetching, mutate } = useGetList('DocType', { filters: [{ field: 'name', operator: 'like', value: 'test' }] }) */ export declare const useGetList: <T extends FrappeDoc<object>>(doctype: string, args?: GetDocListArgs<T>, queryKey?: readonly any[], options?: UseQueryOptions<T[], FrappeError>) => import('@tanstack/react-query').UseQueryResult<T[], FrappeError>; /** * Fetches the count of documents from the Frappe database. * * @param doctype - The name of the document type to fetch * @param args - The arguments for the fetch operation * @param queryKey - The query key for the fetch operation * @param options - The options for the fetch operation * * @returns An object with the following properties: * * @typeParam T - The type definition of the document object * @typeParam K - The type of the document for args * * @example * const { data, error, isFetching, mutate } = useGetCount('DocType', { filters: [{ field: 'name', operator: 'like', value: 'test' }] }) */ export declare const useGetCount: (doctype: string, args?: GetCountArgs, options?: UseQueryOptions<GetCountResponse, FrappeError>) => import('@tanstack/react-query').UseQueryResult<GetCountResponse, FrappeError>; /** * Fetches a single document from the Frappe database. * * @param doctype - The name of the document type to fetch * @param name - The name of the document to fetch * @param options - The options for the fetch operation * * @returns An object with the following properties: * * @typeParam T - The type definition of the document object * @typeParam K - The type of the document for args * * @example * const { data, error, isFetching, mutate } = useGetDoc('DocType', 'name') */ export declare const useGetDoc: <T extends FrappeDoc<object>>(doctype: string, name: string, args?: GetDocArgs<T>, options?: UseQueryOptions<T, FrappeError>) => import('@tanstack/react-query').UseQueryResult<T, FrappeError>;