import { FetcherProps, RequestInfo, RequestParameter, RequestParams } from './Fetcher'; import { ObjectSchema } from 'yup'; import { ResourceType } from './ResourceType'; import { Store } from './Store'; export interface ResourceProps extends Pick, Pick { /** * Get json data form Response instance after fetch. * Will not used if Resource has own getResponseData method. * If this props has not set and no Resource's getResponseData, `await response.json()` will be use. * @param {Response} response - fetch Response instance. * @param {RequestInfo} requestInfo - object contains helpful infomation */ getResponseData?: (requestInfo: RequestInfo) => Promise; resourceType?: ResourceType; url: string; method?: string; mapDataToStore?: (data: R, resourceType: ResourceType, store: Store) => void; onRequestSuccess?: (requestInfo: RequestInfo) => void; onRequestFailed?: (requestInfo: RequestInfo) => void; getDefaultMeta?: (requestParams?: RequestParameter[]) => {}; getDefaultParams?: (requestParams: RequestParameter[]) => RequestParams; bodySchema?: ObjectSchema<{}>; innerMapping?: Partial<{ [K in keyof R]: (value: R[K], store: Store) => void; }>; } export declare class Resource { props: ResourceProps; /** * Ensure url will start with '/' */ static getUrl: (url: string) => string; constructor(props: ResourceProps | string); mixinWithDefaultParams: (requestParams: RequestParameter[]) => RequestParameter[]; urlReslover: (params?: RequestParameter[], parser?: ((value: any, params: RequestParameter) => any) | undefined) => string; requestInitReslover(params?: Array, requestBodyParser?: FetcherProps['requestBodyParser']): RequestInit | null; }