import { SWRResponse } from 'swr'; import { ResourceAdapter } from './adapter'; import { useRestClientHook } from './client'; /** * Parameters needed to create a new set of RESTful SWR hooks. * * @template RT Resource type. * @template CT Collection type. * @template LP List params. * @template CP Create params. * @template UP Update params. */ export declare type CreateRESTfulSWRParams = { /** * Adapter for this RESTful SWR hook. * * See {@link ResourceAdapter | ResourceAdapter}. */ adapter: ResourceAdapter; /** * Rest client hook for this RESTful SWR hook. * * See {@link useRestClientHook | useRestClientHook}. */ useRestClient: useRestClientHook; }; /** * Result of RESTful SWR hook for managing a collection. * * @template RT Resource type. * @template CT Collection type. * @template LP List params. * @template CP Create params. * @template UP Update params. * @template E SWR error. */ export declare type RESTfulSWRCollection = { /** * SWR response. * * The is the result of calling `useSWR` for the collection. */ response: SWRResponse; /** * API for interacting with the collection. * * See {@link RestClient | RestClient} for info about these methods. */ api: { list(params?: LP): Promise; create(params: CP): Promise; view(id: string): Promise; update(id: string, params: UP): Promise; partial(id: string, params: Partial): Promise; remove(id: string): Promise; }; }; /** * Hook for interacting with a collection. * * @template RT Resource type. * @template CT Collection type. * @template LP List params. * @template CP Create params. * @template UP Update params. * @template E SWR error. */ export declare type UseRESTfulSWRCollection = (params?: LP) => RESTfulSWRCollection; /** * Result of RESTful SWR hook for managing a resource. * * @template RT Resource type. * @template CP Create params. * @template UP Update params. * @template E SWR error. */ export declare type RESTfulSWRResource = { /** * SWR response. * * The is the result of calling `useSWR` for the resource. */ response: SWRResponse; /** * API for interacting with the resource. * * See {@link RestClient | RestClient} for info about these methods. */ api: { create(params: CP): Promise; view(): Promise; update(params: UP): Promise; partial(params: Partial): Promise; remove(): Promise; }; }; /** * Hook for interacting with a resource. * * @template RT Resource type. * @template CP Create params. * @template UP Update params. * @template E SWR error. */ export declare type UseRESTfulSWRResource = (id?: string) => RESTfulSWRResource; /** * Hooks created by {@link createRESTfulSWR | createRESTfulSWR}. * * @template RT Resource type. * @template CT Collection type. * @template LP List params. * @template CP Create params. * @template UP Update params. * @template E SWR error. */ export declare type RESTfulSWR = { useSWRCollection: UseRESTfulSWRCollection; useSWRResource: UseRESTfulSWRResource; };