mirror of
https://github.com/idanoo/GoScrobble.git
synced 2024-11-25 09:55:15 +00:00
2 lines
68 KiB
Plaintext
2 lines
68 KiB
Plaintext
{"version":3,"sources":["../../../src/query/react/index.ts","../../../src/query/react/buildHooks.ts","../../../src/query/react/useShallowStableValue.ts","../../../src/query/react/constants.ts","../../../src/query/endpointDefinitions.ts","../../../src/query/utils/capitalize.ts","../../../src/query/tsHelpers.ts","../../../src/query/react/module.ts","../../../src/query/react/ApiProvider.tsx","module.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA,OAAA,EAAA,UAAA,EAAA,cAAA,EAAA,MAAA,wBAAA,CAAA;;ACCA,OAAA,EAAA,cAAA,EAAA,MAAA,kBAAA,CAAA;AACA,OAAA,EAAA,WAAA,EAAA,SAAA,IAAA,UAAA,EAAA,eAAA,EAAA,OAAA,EAAA,MAAA,IAAA,OAAA,EAAA,QAAA,EAAA,MAAA,OAAA,CAAA;AAQA,OAAA,EAAA,WAAA,EAAA,SAAA,EAAA,MAAA,wBAAA,CAAA;AAuBA,OAAA,EAAA,YAAA,IAAA,aAAA,EAAA,MAAA,aAAA,CAAA;;ACjCA,OAAA,EAAA,SAAA,EAAA,MAAA,EAAA,MAAA,OAAA,CAAA;AACA,OAAA,EAAA,YAAA,EAAA,MAAA,aAAA,CAAA;AAEO,SAAA,qBAAA,CAAkC,KAAA;IACvC,MAAM,KAAA,GAAQ,MAAA,CAAO,KAAA,CAAA,CAAA;IACrB,SAAA,CAAU,GAAA,EAAA;QACR,IAAI,CAAC,YAAA,CAAa,KAAA,CAAM,OAAA,EAAS,KAAA,CAAA,EAAQ;YACvC,KAAA,CAAM,OAAA,GAAU,KAAA,CAAA;SAAA;IAAA,CAAA,EAEjB,CAAC,KAAA,CAAA,CAAA,CAAA;IAEJ,OAAO,YAAA,CAAa,KAAA,CAAM,OAAA,EAAS,KAAA,CAAA,CAAA,CAAA,CAAS,KAAA,CAAM,OAAA,CAAA,CAAA,CAAU,KAAA,CAAA;A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AW,YAAA,CAAA,UAAA,CAAA,GAA2B,WAAA,CAAA;iBAAA;YAAA,CAAA;SAAA,CAAA;IAAA,CAAA;CAAA,CAAA,CAAA;;APxIpE,cAAA,wBAAA,CAAA;;AQfA,OAAA,EAAA,cAAA,EAAA,MAAA,kBAAA,CAAA;AAEA,OAAA,KAAA,MAAA,OAAA,CAAA;AAEA,OAAA,EAAA,QAAA,EAAA,MAAA,aAAA,CAAA;AACA,OAAA,EAAA,cAAA,EAAA,MAAA,wBAAA,CAAA;AA2BO,SAAA,WAAA,CAAuD,KAAA;IAM5D,MAAM,CAAC,KAAA,CAAA,GAAS,KAAA,CAAM,QAAA,CAAS,GAAA,EAAA,CAC7B,cAAA,CAAe;QACb,OAAA,EAAS;YAAA,CACN,KAAA,CAAM,GAAA,CAAI,WAAA,CAAA,EAAc,KAAA,CAAM,GAAA,CAAI,OAAA;SAAA;QAErC,UAAA,EAAY,CAAC,GAAA,EAAA,EAAA,CAAQ,GAAA,EAAA,CAAM,MAAA,CAAO,KAAA,CAAM,GAAA,CAAI,UAAA,CAAA;KAAA,CAAA,CAAA,CAAA;IAIhD,cAAA,CAAe,KAAA,CAAM,QAAA,EAAU,KAAA,CAAM,cAAA,CAAA,CAAA;IAErC,OACE,eAAA,CAAA,KAAA,CAAA,aAAA,CAAC,QAAA,EAAD;QAAU,KAAA;QAAc,OAAA,EAAS,KAAA,CAAM,OAAA;KAAA,EACpC,KAAA,CAAM,QAAA,CAAA,CAAA;AAAA,CAAA;;ARjCb,IAAM,SAAA,GAA4B,eAAA,CAAA,cAAA,CAChC,UAAA,EAAA,EACA,gBAAA,EAAA,CAAA,CAAA","sourcesContent":["import { coreModule, buildCreateApi, CreateApi } from '@reduxjs/toolkit/query'\r\nimport { reactHooksModule, reactHooksModuleName } from './module'\r\n\r\nimport type { MutationHooks, QueryHooks } from './buildHooks'\r\nimport type {\r\n EndpointDefinitions,\r\n QueryDefinition,\r\n MutationDefinition,\r\n QueryArgFrom,\r\n} from '@reduxjs/toolkit/dist/query/endpointDefinitions'\r\nimport type { BaseQueryFn } from '@reduxjs/toolkit/dist/query/baseQueryTypes'\r\n\r\nimport type { QueryKeys } from '@reduxjs/toolkit/dist/query/core/apiState'\r\nimport type { PrefetchOptions } from '@reduxjs/toolkit/dist/query/core/module'\r\n\r\nexport * from '@reduxjs/toolkit/query'\r\nexport { ApiProvider } from './ApiProvider'\r\n\r\nconst createApi = /* @__PURE__ */ buildCreateApi(\r\n coreModule(),\r\n reactHooksModule()\r\n)\r\n\r\nexport { createApi, reactHooksModule }\r\n","import type { AnyAction, ThunkAction, ThunkDispatch } from '@reduxjs/toolkit'\r\nimport { createSelector } from '@reduxjs/toolkit'\r\nimport {\r\n useCallback,\r\n useEffect,\r\n useLayoutEffect,\r\n useMemo,\r\n useRef,\r\n useState,\r\n} from 'react'\r\nimport { QueryStatus, skipToken } from '@reduxjs/toolkit/query'\r\nimport type {\r\n QuerySubState,\r\n SubscriptionOptions,\r\n QueryKeys,\r\n RootState,\r\n} from '@reduxjs/toolkit/dist/query/core/apiState'\r\nimport type {\r\n EndpointDefinitions,\r\n MutationDefinition,\r\n QueryDefinition,\r\n QueryArgFrom,\r\n ResultTypeFrom,\r\n} from '@reduxjs/toolkit/dist/query/endpointDefinitions'\r\nimport type {\r\n QueryResultSelectorResult,\r\n MutationResultSelectorResult,\r\n SkipToken,\r\n} from '@reduxjs/toolkit/dist/query/core/buildSelectors'\r\nimport type {\r\n QueryActionCreatorResult,\r\n MutationActionCreatorResult,\r\n} from '@reduxjs/toolkit/dist/query/core/buildInitiate'\r\nimport { shallowEqual } from 'react-redux'\r\nimport type { Api } from '@reduxjs/toolkit/dist/query/apiTypes'\r\nimport type {\r\n Id,\r\n NoInfer,\r\n Override,\r\n} from '@reduxjs/toolkit/dist/query/tsHelpers'\r\nimport type {\r\n ApiEndpointMutation,\r\n ApiEndpointQuery,\r\n CoreModule,\r\n PrefetchOptions,\r\n} from '@reduxjs/toolkit/dist/query/core/module'\r\nimport type { ReactHooksModuleOptions } from './module'\r\nimport { useShallowStableValue } from './useShallowStableValue'\r\nimport type { UninitializedValue } from './constants'\r\nimport { UNINITIALIZED_VALUE } from './constants'\r\n\r\n// Copy-pasted from React-Redux\r\nexport const useIsomorphicLayoutEffect =\r\n typeof window !== 'undefined' &&\r\n typeof window.document !== 'undefined' &&\r\n typeof window.document.createElement !== 'undefined'\r\n ? useLayoutEffect\r\n : useEffect\r\n\r\nexport interface QueryHooks<\r\n Definition extends QueryDefinition<any, any, any, any, any>\r\n> {\r\n useQuery: UseQuery<Definition>\r\n useLazyQuery: UseLazyQuery<Definition>\r\n useQuerySubscription: UseQuerySubscription<Definition>\r\n useLazyQuerySubscription: UseLazyQuerySubscription<Definition>\r\n useQueryState: UseQueryState<Definition>\r\n}\r\n\r\nexport interface MutationHooks<\r\n Definition extends MutationDefinition<any, any, any, any, any>\r\n> {\r\n useMutation: UseMutation<Definition>\r\n}\r\n\r\n/**\r\n * A React hook that automatically triggers fetches of data from an endpoint, 'subscribes' the component to the cached data, and reads the request status and cached data from the Redux store. The component will re-render as the loading status changes and the data becomes available.\r\n *\r\n * The query arg is used as a cache key. Changing the query arg will tell the hook to re-fetch the data if it does not exist in the cache already, and the hook will return the data for that query arg once it's available.\r\n *\r\n * This hook combines the functionality of both [`useQueryState`](#usequerystate) and [`useQuerySubscription`](#usequerysubscription) together, and is intended to be used in the majority of situations.\r\n *\r\n * #### Features\r\n *\r\n * - Automatically triggers requests to retrieve data based on the hook argument and whether cached data exists by default\r\n * - 'Subscribes' the component to keep cached data in the store, and 'unsubscribes' when the component unmounts\r\n * - Accepts polling/re-fetching options to trigger automatic re-fetches when the corresponding criteria is met\r\n * - Returns the latest request status and cached data from the Redux store\r\n * - Re-renders as the request status changes and data becomes available\r\n */\r\nexport type UseQuery<D extends QueryDefinition<any, any, any, any>> = <\r\n R extends Record<string, any> = UseQueryStateDefaultResult<D>\r\n>(\r\n arg: QueryArgFrom<D> | SkipToken,\r\n options?: UseQuerySubscriptionOptions & UseQueryStateOptions<D, R>\r\n) => UseQueryStateResult<D, R> & ReturnType<UseQuerySubscription<D>>\r\n\r\ninterface UseQuerySubscriptionOptions extends SubscriptionOptions {\r\n /**\r\n * Prevents a query from automatically running.\r\n *\r\n * @remarks\r\n * When `skip` is true (or `skipToken` is passed in as `arg`):\r\n *\r\n * - **If the query has cached data:**\r\n * * The cached data **will not be used** on the initial load, and will ignore updates from any identical query until the `skip` condition is removed\r\n * * The query will have a status of `uninitialized`\r\n * * If `skip: false` is set after skipping the initial load, the cached result will be used\r\n * - **If the query does not have cached data:**\r\n * * The query will have a status of `uninitialized`\r\n * * The query will not exist in the state when viewed with the dev tools\r\n * * The query will not automatically fetch on mount\r\n * * The query will not automatically run when additional components with the same query are added that do run\r\n *\r\n * @example\r\n * ```tsx\r\n * // codeblock-meta title=\"Skip example\"\r\n * const Pokemon = ({ name, skip }: { name: string; skip: boolean }) => {\r\n * const { data, error, status } = useGetPokemonByNameQuery(name, {\r\n * skip,\r\n * });\r\n *\r\n * return (\r\n * <div>\r\n * {name} - {status}\r\n * </div>\r\n * );\r\n * };\r\n * ```\r\n */\r\n skip?: boolean\r\n /**\r\n * Defaults to `false`. This setting allows you to control whether if a cached result is already available, RTK Query will only serve a cached result, or if it should `refetch` when set to `true` or if an adequate amount of time has passed since the last successful query result.\r\n * - `false` - Will not cause a query to be performed _unless_ it does not exist yet.\r\n * - `true` - Will always refetch when a new subscriber to a query is added. Behaves the same as calling the `refetch` callback or passing `forceRefetch: true` in the action creator.\r\n * - `number` - **Value is in seconds**. If a number is provided and there is an existing query in the cache, it will compare the current time vs the last fulfilled timestamp, and only refetch if enough time has elapsed.\r\n *\r\n * If you specify this option alongside `skip: true`, this **will not be evaluated** until `skip` is false.\r\n */\r\n refetchOnMountOrArgChange?: boolean | number\r\n}\r\n\r\n/**\r\n * A React hook that automatically triggers fetches of data from an endpoint, and 'subscribes' the component to the cached data.\r\n *\r\n * The query arg is used as a cache key. Changing the query arg will tell the hook to re-fetch the data if it does not exist in the cache already.\r\n *\r\n * Note that this hook does not return a request status or cached data. For that use-case, see [`useQuery`](#usequery) or [`useQueryState`](#usequerystate).\r\n *\r\n * #### Features\r\n *\r\n * - Automatically triggers requests to retrieve data based on the hook argument and whether cached data exists by default\r\n * - 'Subscribes' the component to keep cached data in the store, and 'unsubscribes' when the component unmounts\r\n * - Accepts polling/re-fetching options to trigger automatic re-fetches when the corresponding criteria is met\r\n */\r\nexport type UseQuerySubscription<\r\n D extends QueryDefinition<any, any, any, any>\r\n> = (\r\n arg: QueryArgFrom<D> | SkipToken,\r\n options?: UseQuerySubscriptionOptions\r\n) => Pick<QueryActionCreatorResult<D>, 'refetch'>\r\n\r\nexport type UseLazyQueryLastPromiseInfo<\r\n D extends QueryDefinition<any, any, any, any>\r\n> = {\r\n lastArg: QueryArgFrom<D>\r\n}\r\n\r\n/**\r\n * A React hook similar to [`useQuery`](#usequery), but with manual control over when the data fetching occurs.\r\n *\r\n * This hook includes the functionality of [`useLazyQuerySubscription`](#uselazyquerysubscription).\r\n *\r\n * #### Features\r\n *\r\n * - Manual control over firing a request to retrieve data\r\n * - 'Subscribes' the component to keep cached data in the store, and 'unsubscribes' when the component unmounts\r\n * - Returns the latest request status and cached data from the Redux store\r\n * - Re-renders as the request status changes and data becomes available\r\n * - Accepts polling/re-fetching options to trigger automatic re-fetches when the corresponding criteria is met and the fetch has been manually called at least once\r\n *\r\n */\r\nexport type UseLazyQuery<D extends QueryDefinition<any, any, any, any>> = <\r\n R = UseQueryStateDefaultResult<D>\r\n>(\r\n options?: SubscriptionOptions & Omit<UseQueryStateOptions<D, R>, 'skip'>\r\n) => [\r\n (arg: QueryArgFrom<D>) => void,\r\n UseQueryStateResult<D, R>,\r\n UseLazyQueryLastPromiseInfo<D>\r\n]\r\n\r\n/**\r\n * A React hook similar to [`useQuerySubscription`](#usequerysubscription), but with manual control over when the data fetching occurs.\r\n *\r\n * Note that this hook does not return a request status or cached data. For that use-case, see [`useLazyQuery`](#uselazyquery).\r\n *\r\n * #### Features\r\n *\r\n * - Manual control over firing a request to retrieve data\r\n * - 'Subscribes' the component to keep cached data in the store, and 'unsubscribes' when the component unmounts\r\n * - Accepts polling/re-fetching options to trigger automatic re-fetches when the corresponding criteria is met and the fetch has been manually called at least once\r\n */\r\nexport type UseLazyQuerySubscription<\r\n D extends QueryDefinition<any, any, any, any>\r\n> = (\r\n options?: SubscriptionOptions\r\n) => [(arg: QueryArgFrom<D>) => void, QueryArgFrom<D> | UninitializedValue]\r\n\r\nexport type QueryStateSelector<\r\n R extends Record<string, any>,\r\n D extends QueryDefinition<any, any, any, any>\r\n> = (state: UseQueryStateDefaultResult<D>) => R\r\n\r\n/**\r\n * A React hook that reads the request status and cached data from the Redux store. The component will re-render as the loading status changes and the data becomes available.\r\n *\r\n * Note that this hook does not trigger fetching new data. For that use-case, see [`useQuery`](#usequery) or [`useQuerySubscription`](#usequerysubscription).\r\n *\r\n * #### Features\r\n *\r\n * - Returns the latest request status and cached data from the Redux store\r\n * - Re-renders as the request status changes and data becomes available\r\n */\r\nexport type UseQueryState<D extends QueryDefinition<any, any, any, any>> = <\r\n R = UseQueryStateDefaultResult<D>\r\n>(\r\n arg: QueryArgFrom<D> | SkipToken,\r\n options?: UseQueryStateOptions<D, R>\r\n) => UseQueryStateResult<D, R>\r\n\r\nexport type UseQueryStateOptions<\r\n D extends QueryDefinition<any, any, any, any>,\r\n R extends Record<string, any>\r\n> = {\r\n /**\r\n * Prevents a query from automatically running.\r\n *\r\n * @remarks\r\n * When skip is true:\r\n *\r\n * - **If the query has cached data:**\r\n * * The cached data **will not be used** on the initial load, and will ignore updates from any identical query until the `skip` condition is removed\r\n * * The query will have a status of `uninitialized`\r\n * * If `skip: false` is set after skipping the initial load, the cached result will be used\r\n * - **If the query does not have cached data:**\r\n * * The query will have a status of `uninitialized`\r\n * * The query will not exist in the state when viewed with the dev tools\r\n * * The query will not automatically fetch on mount\r\n * * The query will not automatically run when additional components with the same query are added that do run\r\n *\r\n * @example\r\n * ```ts\r\n * // codeblock-meta title=\"Skip example\"\r\n * const Pokemon = ({ name, skip }: { name: string; skip: boolean }) => {\r\n * const { data, error, status } = useGetPokemonByNameQuery(name, {\r\n * skip,\r\n * });\r\n *\r\n * return (\r\n * <div>\r\n * {name} - {status}\r\n * </div>\r\n * );\r\n * };\r\n * ```\r\n */\r\n skip?: boolean\r\n /**\r\n * `selectFromResult` allows you to get a specific segment from a query result in a performant manner.\r\n * When using this feature, the component will not rerender unless the underlying data of the selected item has changed.\r\n * If the selected item is one element in a larger collection, it will disregard changes to elements in the same collection.\r\n *\r\n * @example\r\n * ```ts\r\n * // codeblock-meta title=\"Using selectFromResult to extract a single result\"\r\n * function PostsList() {\r\n * const { data: posts } = api.useGetPostsQuery();\r\n *\r\n * return (\r\n * <ul>\r\n * {posts?.data?.map((post) => (\r\n * <PostById key={post.id} id={post.id} />\r\n * ))}\r\n * </ul>\r\n * );\r\n * }\r\n *\r\n * function PostById({ id }: { id: number }) {\r\n * // Will select the post with the given id, and will only rerender if the given posts data changes\r\n * const { post } = api.useGetPostsQuery(undefined, {\r\n * selectFromResult: ({ data }) => ({ post: data?.find((post) => post.id === id) }),\r\n * });\r\n *\r\n * return <li>{post?.name}</li>;\r\n * }\r\n * ```\r\n */\r\n selectFromResult?: QueryStateSelector<R, D>\r\n}\r\n\r\nexport type UseQueryStateResult<\r\n _ extends QueryDefinition<any, any, any, any>,\r\n R\r\n> = NoInfer<R>\r\n\r\ntype UseQueryStateBaseResult<D extends QueryDefinition<any, any, any, any>> =\r\n QuerySubState<D> & {\r\n /**\r\n * Query has not started yet.\r\n */\r\n isUninitialized: false\r\n /**\r\n * Query is currently loading for the first time. No data yet.\r\n */\r\n isLoading: false\r\n /**\r\n * Query is currently fetching, but might have data from an earlier request.\r\n */\r\n isFetching: false\r\n /**\r\n * Query has data from a successful load.\r\n */\r\n isSuccess: false\r\n /**\r\n * Query is currently in \"error\" state.\r\n */\r\n isError: false\r\n }\r\n\r\ntype UseQueryStateDefaultResult<D extends QueryDefinition<any, any, any, any>> =\r\n Id<\r\n | Override<\r\n Extract<\r\n UseQueryStateBaseResult<D>,\r\n { status: QueryStatus.uninitialized }\r\n >,\r\n { isUninitialized: true }\r\n >\r\n | Override<\r\n UseQueryStateBaseResult<D>,\r\n | { isLoading: true; isFetching: boolean; data: undefined }\r\n | ({\r\n isSuccess: true\r\n isFetching: boolean\r\n error: undefined\r\n } & Required<\r\n Pick<UseQueryStateBaseResult<D>, 'data' | 'fulfilledTimeStamp'>\r\n >)\r\n | ({ isError: true } & Required<\r\n Pick<UseQueryStateBaseResult<D>, 'error'>\r\n >)\r\n >\r\n > & {\r\n /**\r\n * @deprecated will be removed in the next version\r\n * please use the `isLoading`, `isFetching`, `isSuccess`, `isError`\r\n * and `isUninitialized` flags instead\r\n */\r\n status: QueryStatus\r\n }\r\n\r\nexport type MutationStateSelector<\r\n R extends Record<string, any>,\r\n D extends MutationDefinition<any, any, any, any>\r\n> = (state: MutationResultSelectorResult<D>) => R\r\n\r\nexport type UseMutationStateOptions<\r\n D extends MutationDefinition<any, any, any, any>,\r\n R extends Record<string, any>\r\n> = {\r\n selectFromResult?: MutationStateSelector<R, D>\r\n}\r\n\r\nexport type UseMutationStateResult<\r\n D extends MutationDefinition<any, any, any, any>,\r\n R\r\n> = NoInfer<R> & {\r\n originalArgs?: QueryArgFrom<D>\r\n}\r\n\r\n/**\r\n * A React hook that lets you trigger an update request for a given endpoint, and subscribes the component to read the request status from the Redux store. The component will re-render as the loading status changes.\r\n *\r\n * #### Features\r\n *\r\n * - Manual control over firing a request to alter data on the server or possibly invalidate the cache\r\n * - 'Subscribes' the component to keep cached data in the store, and 'unsubscribes' when the component unmounts\r\n * - Returns the latest request status and cached data from the Redux store\r\n * - Re-renders as the request status changes and data becomes available\r\n */\r\nexport type UseMutation<D extends MutationDefinition<any, any, any, any>> = <\r\n R extends Record<string, any> = MutationResultSelectorResult<D>\r\n>(\r\n options?: UseMutationStateOptions<D, R>\r\n) => [\r\n (arg: QueryArgFrom<D>) => MutationActionCreatorResult<D>,\r\n UseMutationStateResult<D, R>\r\n]\r\n\r\nconst defaultQueryStateSelector: QueryStateSelector<any, any> = (x) => x\r\nconst defaultMutationStateSelector: MutationStateSelector<any, any> = (x) => x\r\n\r\nconst queryStatePreSelector = (\r\n currentState: QueryResultSelectorResult<any>,\r\n lastResult: UseQueryStateDefaultResult<any>\r\n): UseQueryStateDefaultResult<any> => {\r\n // data is the last known good request result we have tracked - or if none has been tracked yet the last good result for the current args\r\n const data =\r\n (currentState.isSuccess ? currentState.data : lastResult?.data) ??\r\n currentState.data\r\n\r\n // isFetching = true any time a request is in flight\r\n const isFetching = currentState.isLoading\r\n // isLoading = true only when loading while no data is present yet (initial load with no data in the cache)\r\n const isLoading = !data && isFetching\r\n // isSuccess = true when data is present\r\n const isSuccess = currentState.isSuccess || (isFetching && !!data)\r\n\r\n return {\r\n ...currentState,\r\n data,\r\n isFetching,\r\n isLoading,\r\n isSuccess,\r\n } as UseQueryStateDefaultResult<any>\r\n}\r\n\r\n/**\r\n * Wrapper around `defaultQueryStateSelector` to be used in `useQuery`.\r\n * We want the initial render to already come back with\r\n * `{ isUninitialized: false, isFetching: true, isLoading: true }`\r\n * to prevent that the library user has to do an additional check for `isUninitialized`/\r\n */\r\nconst noPendingQueryStateSelector: QueryStateSelector<any, any> = (\r\n selected\r\n) => {\r\n if (selected.isUninitialized) {\r\n return {\r\n ...selected,\r\n isUninitialized: false,\r\n isFetching: true,\r\n isLoading: true,\r\n status: QueryStatus.pending,\r\n } as any\r\n }\r\n return selected\r\n}\r\n\r\ntype GenericPrefetchThunk = (\r\n endpointName: any,\r\n arg: any,\r\n options: PrefetchOptions\r\n) => ThunkAction<void, any, any, AnyAction>\r\n\r\n/**\r\n *\r\n * @param opts.api - An API with defined endpoints to create hooks for\r\n * @param opts.moduleOptions.batch - The version of the `batchedUpdates` function to be used\r\n * @param opts.moduleOptions.useDispatch - The version of the `useDispatch` hook to be used\r\n * @param opts.moduleOptions.useSelector - The version of the `useSelector` hook to be used\r\n * @returns An object containing functions to generate hooks based on an endpoint\r\n */\r\nexport function buildHooks<Definitions extends EndpointDefinitions>({\r\n api,\r\n moduleOptions: { batch, useDispatch, useSelector, useStore },\r\n}: {\r\n api: Api<any, Definitions, any, any, CoreModule>\r\n moduleOptions: Required<ReactHooksModuleOptions>\r\n}) {\r\n return { buildQueryHooks, buildMutationHook, usePrefetch }\r\n\r\n function usePrefetch<EndpointName extends QueryKeys<Definitions>>(\r\n endpointName: EndpointName,\r\n defaultOptions?: PrefetchOptions\r\n ) {\r\n const dispatch = useDispatch<ThunkDispatch<any, any, AnyAction>>()\r\n const stableDefaultOptions = useShallowStableValue(defaultOptions)\r\n\r\n return useCallback(\r\n (arg: any, options?: PrefetchOptions) =>\r\n dispatch(\r\n (api.util.prefetch as GenericPrefetchThunk)(endpointName, arg, {\r\n ...stableDefaultOptions,\r\n ...options,\r\n })\r\n ),\r\n [endpointName, dispatch, stableDefaultOptions]\r\n )\r\n }\r\n\r\n function buildQueryHooks(name: string): QueryHooks<any> {\r\n const useQuerySubscription: UseQuerySubscription<any> = (\r\n arg: any,\r\n {\r\n refetchOnReconnect,\r\n refetchOnFocus,\r\n refetchOnMountOrArgChange,\r\n skip = false,\r\n pollingInterval = 0,\r\n } = {}\r\n ) => {\r\n const { initiate } = api.endpoints[name] as ApiEndpointQuery<\r\n QueryDefinition<any, any, any, any, any>,\r\n Definitions\r\n >\r\n const dispatch = useDispatch<ThunkDispatch<any, any, AnyAction>>()\r\n const stableArg = useShallowStableValue(skip ? skipToken : arg)\r\n const stableSubscriptionOptions = useShallowStableValue({\r\n refetchOnReconnect,\r\n refetchOnFocus,\r\n pollingInterval,\r\n })\r\n\r\n const promiseRef = useRef<QueryActionCreatorResult<any>>()\r\n\r\n useEffect(() => {\r\n const lastPromise = promiseRef.current\r\n\r\n if (stableArg === skipToken) {\r\n lastPromise?.unsubscribe()\r\n promiseRef.current = undefined\r\n return\r\n }\r\n\r\n const lastSubscriptionOptions = promiseRef.current?.subscriptionOptions\r\n\r\n if (!lastPromise || lastPromise.arg !== stableArg) {\r\n lastPromise?.unsubscribe()\r\n const promise = dispatch(\r\n initiate(stableArg, {\r\n subscriptionOptions: stableSubscriptionOptions,\r\n forceRefetch: refetchOnMountOrArgChange,\r\n })\r\n )\r\n promiseRef.current = promise\r\n } else if (stableSubscriptionOptions !== lastSubscriptionOptions) {\r\n lastPromise.updateSubscriptionOptions(stableSubscriptionOptions)\r\n }\r\n }, [\r\n dispatch,\r\n initiate,\r\n refetchOnMountOrArgChange,\r\n stableArg,\r\n stableSubscriptionOptions,\r\n ])\r\n\r\n useEffect(() => {\r\n return () => {\r\n promiseRef.current?.unsubscribe()\r\n promiseRef.current = undefined\r\n }\r\n }, [])\r\n\r\n return useMemo(\r\n () => ({\r\n /**\r\n * A method to manually refetch data for the query\r\n */\r\n refetch: () => void promiseRef.current?.refetch(),\r\n }),\r\n []\r\n )\r\n }\r\n\r\n const useLazyQuerySubscription: UseLazyQuerySubscription<any> = ({\r\n refetchOnReconnect,\r\n refetchOnFocus,\r\n pollingInterval = 0,\r\n } = {}) => {\r\n const { initiate } = api.endpoints[name] as ApiEndpointQuery<\r\n QueryDefinition<any, any, any, any, any>,\r\n Definitions\r\n >\r\n const dispatch = useDispatch<ThunkDispatch<any, any, AnyAction>>()\r\n\r\n const [arg, setArg] = useState<any>(UNINITIALIZED_VALUE)\r\n const promiseRef = useRef<QueryActionCreatorResult<any> | undefined>()\r\n\r\n const stableSubscriptionOptions = useShallowStableValue({\r\n refetchOnReconnect,\r\n refetchOnFocus,\r\n pollingInterval,\r\n })\r\n\r\n useEffect(() => {\r\n const lastSubscriptionOptions = promiseRef.current?.subscriptionOptions\r\n\r\n if (stableSubscriptionOptions !== lastSubscriptionOptions) {\r\n promiseRef.current?.updateSubscriptionOptions(\r\n stableSubscriptionOptions\r\n )\r\n }\r\n }, [stableSubscriptionOptions])\r\n\r\n const subscriptionOptionsRef = useRef(stableSubscriptionOptions)\r\n useEffect(() => {\r\n subscriptionOptionsRef.current = stableSubscriptionOptions\r\n }, [stableSubscriptionOptions])\r\n\r\n const trigger = useCallback(\r\n function (arg: any, preferCacheValue = false) {\r\n batch(() => {\r\n promiseRef.current?.unsubscribe()\r\n\r\n promiseRef.current = dispatch(\r\n initiate(arg, {\r\n subscriptionOptions: subscriptionOptionsRef.current,\r\n forceRefetch: !preferCacheValue,\r\n })\r\n )\r\n setArg(arg)\r\n })\r\n },\r\n [dispatch, initiate]\r\n )\r\n\r\n /* cleanup on unmount */\r\n useEffect(() => {\r\n return () => {\r\n promiseRef?.current?.unsubscribe()\r\n }\r\n }, [])\r\n\r\n /* if \"cleanup on unmount\" was triggered from a fast refresh, we want to reinstate the query */\r\n useEffect(() => {\r\n if (arg !== UNINITIALIZED_VALUE && !promiseRef.current) {\r\n trigger(arg, true)\r\n }\r\n }, [arg, trigger])\r\n\r\n return useMemo(() => [trigger, arg], [trigger, arg])\r\n }\r\n\r\n const useQueryState: UseQueryState<any> = (\r\n arg: any,\r\n { skip = false, selectFromResult = defaultQueryStateSelector } = {}\r\n ) => {\r\n const { select } = api.endpoints[name] as ApiEndpointQuery<\r\n QueryDefinition<any, any, any, any, any>,\r\n Definitions\r\n >\r\n const stableArg = useShallowStableValue(skip ? skipToken : arg)\r\n\r\n const lastValue = useRef<any>()\r\n\r\n const selectDefaultResult = useMemo(\r\n () =>\r\n createSelector(\r\n [select(stableArg), (_: any, lastResult: any) => lastResult],\r\n queryStatePreSelector\r\n ),\r\n [select, stableArg]\r\n )\r\n\r\n const querySelector = useMemo(\r\n () => createSelector([selectDefaultResult], selectFromResult),\r\n [selectDefaultResult, selectFromResult]\r\n )\r\n\r\n const currentState = useSelector(\r\n (state: RootState<Definitions, any, any>) =>\r\n querySelector(state, lastValue.current),\r\n shallowEqual\r\n )\r\n\r\n const store = useStore()\r\n const newLastValue = selectDefaultResult(\r\n store.getState(),\r\n lastValue.current\r\n )\r\n useIsomorphicLayoutEffect(() => {\r\n lastValue.current = newLastValue\r\n }, [newLastValue])\r\n\r\n return currentState\r\n }\r\n\r\n return {\r\n useQueryState,\r\n useQuerySubscription,\r\n useLazyQuerySubscription,\r\n useLazyQuery(options) {\r\n const [trigger, arg] = useLazyQuerySubscription(options)\r\n const queryStateResults = useQueryState(arg, {\r\n ...options,\r\n skip: arg === UNINITIALIZED_VALUE,\r\n })\r\n\r\n const info = useMemo(() => ({ lastArg: arg }), [arg])\r\n return useMemo(\r\n () => [trigger, queryStateResults, info],\r\n [trigger, queryStateResults, info]\r\n )\r\n },\r\n useQuery(arg, options) {\r\n const querySubscriptionResults = useQuerySubscription(arg, options)\r\n const queryStateResults = useQueryState(arg, {\r\n selectFromResult:\r\n arg === skipToken || options?.skip\r\n ? undefined\r\n : noPendingQueryStateSelector,\r\n ...options,\r\n })\r\n return useMemo(\r\n () => ({ ...queryStateResults, ...querySubscriptionResults }),\r\n [queryStateResults, querySubscriptionResults]\r\n )\r\n },\r\n }\r\n }\r\n\r\n function buildMutationHook(name: string): UseMutation<any> {\r\n return ({ selectFromResult = defaultMutationStateSelector } = {}) => {\r\n const { select, initiate } = api.endpoints[name] as ApiEndpointMutation<\r\n MutationDefinition<any, any, any, any, any>,\r\n Definitions\r\n >\r\n const dispatch = useDispatch<ThunkDispatch<any, any, AnyAction>>()\r\n const [requestId, setRequestId] = useState<string>()\r\n\r\n const promiseRef = useRef<MutationActionCreatorResult<any>>()\r\n\r\n useEffect(() => {\r\n return () => {\r\n promiseRef.current?.unsubscribe()\r\n promiseRef.current = undefined\r\n }\r\n }, [])\r\n\r\n const triggerMutation = useCallback(\r\n function (arg) {\r\n let promise: MutationActionCreatorResult<any>\r\n batch(() => {\r\n promiseRef?.current?.unsubscribe()\r\n promise = dispatch(initiate(arg))\r\n promiseRef.current = promise\r\n setRequestId(promise.requestId)\r\n })\r\n return promise!\r\n },\r\n [dispatch, initiate]\r\n )\r\n\r\n const mutationSelector = useMemo(\r\n () =>\r\n createSelector([select(requestId || skipToken)], (subState) =>\r\n selectFromResult(subState)\r\n ),\r\n [select, requestId, selectFromResult]\r\n )\r\n\r\n const currentState = useSelector(mutationSelector, shallowEqual)\r\n const originalArgs = promiseRef.current?.arg.originalArgs\r\n const finalState = useMemo(\r\n () => ({\r\n ...currentState,\r\n originalArgs,\r\n }),\r\n [currentState, originalArgs]\r\n )\r\n\r\n return useMemo(\r\n () => [triggerMutation, finalState],\r\n [triggerMutation, finalState]\r\n )\r\n }\r\n }\r\n}\r\n","import { useEffect, useRef } from 'react'\r\nimport { shallowEqual } from 'react-redux'\r\n\r\nexport function useShallowStableValue<T>(value: T) {\r\n const cache = useRef(value)\r\n useEffect(() => {\r\n if (!shallowEqual(cache.current, value)) {\r\n cache.current = value\r\n }\r\n }, [value])\r\n\r\n return shallowEqual(cache.current, value) ? cache.current : value\r\n}\r\n","export const UNINITIALIZED_VALUE = Symbol()\r\nexport type UninitializedValue = typeof UNINITIALIZED_VALUE\r\n","import type { AnyAction, ThunkDispatch } from '@reduxjs/toolkit'\r\nimport type { RootState } from './core/apiState'\r\nimport type {\r\n BaseQueryExtraOptions,\r\n BaseQueryFn,\r\n BaseQueryResult,\r\n BaseQueryArg,\r\n BaseQueryApi,\r\n QueryReturnValue,\r\n BaseQueryError,\r\n BaseQueryMeta,\r\n} from './baseQueryTypes'\r\nimport type {\r\n HasRequiredProps,\r\n MaybePromise,\r\n OmitFromUnion,\r\n CastAny,\r\n} from './tsHelpers'\r\nimport type { NEVER } from './fakeBaseQuery'\r\n\r\nconst resultType = /* @__PURE__ */ Symbol()\r\nconst baseQuery = /* @__PURE__ */ Symbol()\r\n\r\ninterface EndpointDefinitionWithQuery<\r\n QueryArg,\r\n BaseQuery extends BaseQueryFn,\r\n ResultType\r\n> {\r\n /**\r\n * `query` can be a function that returns either a `string` or an `object` which is passed to your `baseQuery`. If you are using [fetchBaseQuery](./fetchBaseQuery), this can return either a `string` or an `object` of properties in `FetchArgs`. If you use your own custom [`baseQuery`](../../rtk-query/usage/customizing-queries), you can customize this behavior to your liking.\r\n *\r\n * @example\r\n *\r\n * ```ts\r\n * // codeblock-meta title=\"query example\"\r\n *\r\n * import { createApi, fetchBaseQuery } from '@reduxjs/toolkit/query/react'\r\n * interface Post {\r\n * id: number\r\n * name: string\r\n * }\r\n * type PostsResponse = Post[]\r\n *\r\n * const api = createApi({\r\n * baseQuery: fetchBaseQuery({ baseUrl: '/' }),\r\n * endpoints: (build) => ({\r\n * getPosts: build.query<PostsResponse, void>({\r\n * // highlight-start\r\n * query: () => 'posts',\r\n * // highlight-end\r\n * })\r\n * })\r\n * })\r\n * ```\r\n */\r\n query(arg: QueryArg): BaseQueryArg<BaseQuery>\r\n queryFn?: never\r\n /**\r\n * A function to manipulate the data returned by a query or mutation.\r\n */\r\n transformResponse?(\r\n baseQueryReturnValue: BaseQueryResult<BaseQuery>,\r\n meta: BaseQueryMeta<BaseQuery>\r\n ): ResultType | Promise<ResultType>\r\n}\r\n\r\ninterface EndpointDefinitionWithQueryFn<\r\n QueryArg,\r\n BaseQuery extends BaseQueryFn,\r\n ResultType\r\n> {\r\n /**\r\n * Can be used in place of `query` as an inline function that bypasses `baseQuery` completely for the endpoint.\r\n *\r\n * @example\r\n * ```ts\r\n * // codeblock-meta title=\"Basic queryFn example\"\r\n *\r\n * import { createApi, fetchBaseQuery } from '@reduxjs/toolkit/query/react'\r\n * interface Post {\r\n * id: number\r\n * name: string\r\n * }\r\n * type PostsResponse = Post[]\r\n *\r\n * const api = createApi({\r\n * baseQuery: fetchBaseQuery({ baseUrl: '/' }),\r\n * endpoints: (build) => ({\r\n * getPosts: build.query<PostsResponse, void>({\r\n * query: () => 'posts',\r\n * }),\r\n * flipCoin: build.query<'heads' | 'tails', void>({\r\n * // highlight-start\r\n * queryFn(arg, queryApi, extraOptions, baseQuery) {\r\n * const randomVal = Math.random()\r\n * if (randomVal < 0.45) {\r\n * return { data: 'heads' }\r\n * }\r\n * if (randomVal < 0.9) {\r\n * return { data: 'tails' }\r\n * }\r\n * return { error: { status: 500, data: \"Coin landed on it's edge!\" } }\r\n * }\r\n * // highlight-end\r\n * })\r\n * })\r\n * })\r\n * ```\r\n */\r\n queryFn(\r\n arg: QueryArg,\r\n api: BaseQueryApi,\r\n extraOptions: BaseQueryExtraOptions<BaseQuery>,\r\n baseQuery: (arg: Parameters<BaseQuery>[0]) => ReturnType<BaseQuery>\r\n ): MaybePromise<QueryReturnValue<ResultType, BaseQueryError<BaseQuery>>>\r\n query?: never\r\n transformResponse?: never\r\n}\r\n\r\nexport type BaseEndpointDefinition<\r\n QueryArg,\r\n BaseQuery extends BaseQueryFn,\r\n ResultType\r\n> = (\r\n | ([CastAny<BaseQueryResult<BaseQuery>, {}>] extends [NEVER]\r\n ? never\r\n : EndpointDefinitionWithQuery<QueryArg, BaseQuery, ResultType>)\r\n | EndpointDefinitionWithQueryFn<QueryArg, BaseQuery, ResultType>\r\n) & {\r\n /* phantom type */\r\n [resultType]?: ResultType\r\n /* phantom type */\r\n [baseQuery]?: BaseQuery\r\n} & HasRequiredProps<\r\n BaseQueryExtraOptions<BaseQuery>,\r\n { extraOptions: BaseQueryExtraOptions<BaseQuery> },\r\n { extraOptions?: BaseQueryExtraOptions<BaseQuery> }\r\n >\r\n\r\nexport enum DefinitionType {\r\n query = 'query',\r\n mutation = 'mutation',\r\n}\r\n\r\nexport type GetResultDescriptionFn<\r\n TagTypes extends string,\r\n ResultType,\r\n QueryArg,\r\n ErrorType\r\n> = (\r\n result: ResultType | undefined,\r\n error: ErrorType | undefined,\r\n arg: QueryArg\r\n) => ReadonlyArray<TagDescription<TagTypes>>\r\n\r\nexport type FullTagDescription<TagType> = {\r\n type: TagType\r\n id?: number | string\r\n}\r\nexport type TagDescription<TagType> = TagType | FullTagDescription<TagType>\r\nexport type ResultDescription<\r\n TagTypes extends string,\r\n ResultType,\r\n QueryArg,\r\n ErrorType\r\n> =\r\n | ReadonlyArray<TagDescription<TagTypes>>\r\n | GetResultDescriptionFn<TagTypes, ResultType, QueryArg, ErrorType>\r\n\r\n/** @deprecated please use `onQueryStarted` instead */\r\nexport interface QueryApi<ReducerPath extends string, Context extends {}> {\r\n /** @deprecated please use `onQueryStarted` instead */\r\n dispatch: ThunkDispatch<any, any, AnyAction>\r\n /** @deprecated please use `onQueryStarted` instead */\r\n getState(): RootState<any, any, ReducerPath>\r\n /** @deprecated please use `onQueryStarted` instead */\r\n extra: unknown\r\n /** @deprecated please use `onQueryStarted` instead */\r\n requestId: string\r\n /** @deprecated please use `onQueryStarted` instead */\r\n context: Context\r\n}\r\n\r\nexport interface QueryExtraOptions<\r\n TagTypes extends string,\r\n ResultType,\r\n QueryArg,\r\n BaseQuery extends BaseQueryFn,\r\n ReducerPath extends string = string\r\n> {\r\n type: DefinitionType.query\r\n /**\r\n * Used by `query` endpoints. Determines which 'tag' is attached to the cached data returned by the query.\r\n * Expects an array of tag type strings, an array of objects of tag types with ids, or a function that returns such an array.\r\n * 1. `['Post']` - equivalent to `2`\r\n * 2. `[{ type: 'Post' }]` - equivalent to `1`\r\n * 3. `[{ type: 'Post', id: 1 }]`\r\n * 4. `(result, error, arg) => ['Post']` - equivalent to `5`\r\n * 5. `(result, error, arg) => [{ type: 'Post' }]` - equivalent to `4`\r\n * 6. `(result, error, arg) => [{ type: 'Post', id: 1 }]`\r\n *\r\n * @example\r\n *\r\n * ```ts\r\n * // codeblock-meta title=\"providesTags example\"\r\n *\r\n * import { createApi, fetchBaseQuery } from '@reduxjs/toolkit/query/react'\r\n * interface Post {\r\n * id: number\r\n * name: string\r\n * }\r\n * type PostsResponse = Post[]\r\n *\r\n * const api = createApi({\r\n * baseQuery: fetchBaseQuery({ baseUrl: '/' }),\r\n * tagTypes: ['Posts'],\r\n * endpoints: (build) => ({\r\n * getPosts: build.query<PostsResponse, void>({\r\n * query: () => 'posts',\r\n * // highlight-start\r\n * providesTags: (result) =>\r\n * result\r\n * ? [\r\n * ...result.map(({ id }) => ({ type: 'Posts' as const, id })),\r\n * { type: 'Posts', id: 'LIST' },\r\n * ]\r\n * : [{ type: 'Posts', id: 'LIST' }],\r\n * // highlight-end\r\n * })\r\n * })\r\n * })\r\n * ```\r\n */\r\n providesTags?: ResultDescription<\r\n TagTypes,\r\n ResultType,\r\n QueryArg,\r\n BaseQueryError<BaseQuery>\r\n >\r\n /**\r\n * Not to be used. A query should not invalidate tags in the cache.\r\n */\r\n invalidatesTags?: never\r\n}\r\n\r\nexport type QueryDefinition<\r\n QueryArg,\r\n BaseQuery extends BaseQueryFn,\r\n TagTypes extends string,\r\n ResultType,\r\n ReducerPath extends string = string\r\n> = BaseEndpointDefinition<QueryArg, BaseQuery, ResultType> &\r\n QueryExtraOptions<TagTypes, ResultType, QueryArg, BaseQuery, ReducerPath>\r\n\r\nexport interface MutationExtraOptions<\r\n TagTypes extends string,\r\n ResultType,\r\n QueryArg,\r\n BaseQuery extends BaseQueryFn,\r\n ReducerPath extends string = string\r\n> {\r\n type: DefinitionType.mutation\r\n /**\r\n * Used by `mutation` endpoints. Determines which cached data should be either re-fetched or removed from the cache.\r\n * Expects the same shapes as `providesTags`.\r\n *\r\n * @example\r\n *\r\n * ```ts\r\n * // codeblock-meta title=\"invalidatesTags example\"\r\n * import { createApi, fetchBaseQuery } from '@reduxjs/toolkit/query/react'\r\n * interface Post {\r\n * id: number\r\n * name: string\r\n * }\r\n * type PostsResponse = Post[]\r\n *\r\n * const api = createApi({\r\n * baseQuery: fetchBaseQuery({ baseUrl: '/' }),\r\n * tagTypes: ['Posts'],\r\n * endpoints: (build) => ({\r\n * getPosts: build.query<PostsResponse, void>({\r\n * query: () => 'posts',\r\n * providesTags: (result) =>\r\n * result\r\n * ? [\r\n * ...result.map(({ id }) => ({ type: 'Posts' as const, id })),\r\n * { type: 'Posts', id: 'LIST' },\r\n * ]\r\n * : [{ type: 'Posts', id: 'LIST' }],\r\n * }),\r\n * addPost: build.mutation<Post, Partial<Post>>({\r\n * query(body) {\r\n * return {\r\n * url: `posts`,\r\n * method: 'POST',\r\n * body,\r\n * }\r\n * },\r\n * // highlight-start\r\n * invalidatesTags: [{ type: 'Posts', id: 'LIST' }],\r\n * // highlight-end\r\n * }),\r\n * })\r\n * })\r\n * ```\r\n */\r\n invalidatesTags?: ResultDescription<\r\n TagTypes,\r\n ResultType,\r\n QueryArg,\r\n BaseQueryError<BaseQuery>\r\n >\r\n /**\r\n * Not to be used. A mutation should not provide tags to the cache.\r\n */\r\n providesTags?: never\r\n}\r\n\r\nexport type MutationDefinition<\r\n QueryArg,\r\n BaseQuery extends BaseQueryFn,\r\n TagTypes extends string,\r\n ResultType,\r\n ReducerPath extends string = string\r\n> = BaseEndpointDefinition<QueryArg, BaseQuery, ResultType> &\r\n MutationExtraOptions<TagTypes, ResultType, QueryArg, BaseQuery, ReducerPath>\r\n\r\nexport type EndpointDefinition<\r\n QueryArg,\r\n BaseQuery extends BaseQueryFn,\r\n TagTypes extends string,\r\n ResultType,\r\n ReducerPath extends string = string\r\n> =\r\n | QueryDefinition<QueryArg, BaseQuery, TagTypes, ResultType, ReducerPath>\r\n | MutationDefinition<QueryArg, BaseQuery, TagTypes, ResultType, ReducerPath>\r\n\r\nexport type EndpointDefinitions = Record<\r\n string,\r\n EndpointDefinition<any, any, any, any>\r\n>\r\n\r\nexport function isQueryDefinition(\r\n e: EndpointDefinition<any, any, any, any>\r\n): e is QueryDefinition<any, any, any, any> {\r\n return e.type === DefinitionType.query\r\n}\r\n\r\nexport function isMutationDefinition(\r\n e: EndpointDefinition<any, any, any, any>\r\n): e is MutationDefinition<any, any, any, any> {\r\n return e.type === DefinitionType.mutation\r\n}\r\n\r\nexport type EndpointBuilder<\r\n BaseQuery extends BaseQueryFn,\r\n TagTypes extends string,\r\n ReducerPath extends string\r\n> = {\r\n /**\r\n * An endpoint definition that retrieves data, and may provide tags to the cache.\r\n *\r\n * @example\r\n * ```js\r\n * // codeblock-meta title=\"Example of all query endpoint options\"\r\n * const api = createApi({\r\n * baseQuery,\r\n * endpoints: (build) => ({\r\n * getPost: build.query({\r\n * query: (id) => ({ url: `post/${id}` }),\r\n * // Pick out data and prevent nested properties in a hook or selector\r\n * transformResponse: (response) => response.data,\r\n * // `result` is the server response\r\n * providesTags: (result, error, id) => [{ type: 'Post', id }],\r\n * // trigger side effects or optimistic updates\r\n * onQueryStarted(id, { dispatch, getState, extra, requestId, queryFulfilled, getCacheEntry, updateCachedData }) {},\r\n * // handle subscriptions etc\r\n * onCacheEntryAdded(id, { dispatch, getState, extra, requestId, cacheEntryRemoved, cacheDataLoaded, getCacheEntry, updateCachedData }) {},\r\n * }),\r\n * }),\r\n *});\r\n *```\r\n */\r\n query<ResultType, QueryArg>(\r\n definition: OmitFromUnion<\r\n QueryDefinition<QueryArg, BaseQuery, TagTypes, ResultType>,\r\n 'type'\r\n >\r\n ): QueryDefinition<QueryArg, BaseQuery, TagTypes, ResultType>\r\n /**\r\n * An endpoint definition that alters data on the server or will possibly invalidate the cache.\r\n *\r\n * @example\r\n * ```js\r\n * // codeblock-meta title=\"Example of all mutation endpoint options\"\r\n * const api = createApi({\r\n * baseQuery,\r\n * endpoints: (build) => ({\r\n * updatePost: build.mutation({\r\n * query: ({ id, ...patch }) => ({ url: `post/${id}`, method: 'PATCH', body: patch }),\r\n * // Pick out data and prevent nested properties in a hook or selector\r\n * transformResponse: (response) => response.data,\r\n * // `result` is the server response\r\n * invalidatesTags: (result, error, id) => [{ type: 'Post', id }],\r\n * // trigger side effects or optimistic updates\r\n * onQueryStarted(id, { dispatch, getState, extra, requestId, queryFulfilled, getCacheEntry }) {},\r\n * // handle subscriptions etc\r\n * onCacheEntryAdded(id, { dispatch, getState, extra, requestId, cacheEntryRemoved, cacheDataLoaded, getCacheEntry }) {},\r\n * }),\r\n * }),\r\n * });\r\n * ```\r\n */\r\n mutation<ResultType, QueryArg>(\r\n definition: OmitFromUnion<\r\n MutationDefinition<\r\n QueryArg,\r\n BaseQuery,\r\n TagTypes,\r\n ResultType,\r\n ReducerPath\r\n >,\r\n 'type'\r\n >\r\n ): MutationDefinition<QueryArg, BaseQuery, TagTypes, ResultType, ReducerPath>\r\n}\r\n\r\nexport type AssertTagTypes = <T extends FullTagDescription<string>>(t: T) => T\r\n\r\nexport function calculateProvidedBy<ResultType, QueryArg, ErrorType>(\r\n description:\r\n | ResultDescription<string, ResultType, QueryArg, ErrorType>\r\n | undefined,\r\n result: ResultType | undefined,\r\n error: ErrorType | undefined,\r\n queryArg: QueryArg,\r\n assertTagTypes: AssertTagTypes\r\n): readonly FullTagDescription<string>[] {\r\n if (isFunction(description)) {\r\n return description(result as ResultType, error as undefined, queryArg)\r\n .map(expandTagDescription)\r\n .map(assertTagTypes)\r\n }\r\n if (Array.isArray(description)) {\r\n return description.map(expandTagDescription).map(assertTagTypes)\r\n }\r\n return []\r\n}\r\n\r\nfunction isFunction<T>(t: T): t is Extract<T, Function> {\r\n return typeof t === 'function'\r\n}\r\n\r\nfunction expandTagDescription(\r\n description: TagDescription<string>\r\n): FullTagDescription<string> {\r\n return typeof description === 'string' ? { type: description } : description\r\n}\r\n\r\nexport type QueryArgFrom<D extends BaseEndpointDefinition<any, any, any>> =\r\n D extends BaseEndpointDefinition<infer QA, any, any> ? QA : unknown\r\nexport type ResultTypeFrom<D extends BaseEndpointDefinition<any, any, any>> =\r\n D extends BaseEndpointDefinition<any, any, infer RT> ? RT : unknown\r\n\r\nexport type ReducerPathFrom<D extends EndpointDefinition<any, any, any, any>> =\r\n D extends EndpointDefinition<any, any, any, infer RP> ? RP : unknown\r\n\r\nexport type TagTypesFrom<D extends EndpointDefinition<any, any, any, any>> =\r\n D extends EndpointDefinition<any, any, infer RP, any> ? RP : unknown\r\n\r\nexport type ReplaceTagTypes<\r\n Definitions extends EndpointDefinitions,\r\n NewTagTypes extends string\r\n> = {\r\n [K in keyof Definitions]: Definitions[K] extends QueryDefinition<\r\n infer QueryArg,\r\n infer BaseQuery,\r\n any,\r\n infer ResultType,\r\n infer ReducerPath\r\n >\r\n ? QueryDefinition<QueryArg, BaseQuery, NewTagTypes, ResultType, ReducerPath>\r\n : Definitions[K] extends MutationDefinition<\r\n infer QueryArg,\r\n infer BaseQuery,\r\n any,\r\n infer ResultType,\r\n infer ReducerPath\r\n >\r\n ? MutationDefinition<\r\n QueryArg,\r\n BaseQuery,\r\n NewTagTypes,\r\n ResultType,\r\n ReducerPath\r\n >\r\n : never\r\n}\r\n","export function capitalize(str: string) {\r\n return str.replace(str[0], str[0].toUpperCase())\r\n}\r\n","export type Id<T> = { [K in keyof T]: T[K] } & {}\r\nexport type WithRequiredProp<T, K extends keyof T> = Omit<T, K> &\r\n Required<Pick<T, K>>\r\nexport type Override<T1, T2> = T2 extends any ? Omit<T1, keyof T2> & T2 : never\r\nexport function assertCast<T>(v: any): asserts v is T {}\r\n\r\nexport function safeAssign<T extends object>(\r\n target: T,\r\n ...args: Array<Partial<NoInfer<T>>>\r\n) {\r\n Object.assign(target, ...args)\r\n}\r\n\r\n/**\r\n * Convert a Union type `(A|B)` to an intersection type `(A&B)`\r\n */\r\nexport type UnionToIntersection<U> = (\r\n U extends any ? (k: U) => void : never\r\n) extends (k: infer I) => void\r\n ? I\r\n : never\r\n\r\nexport type NonOptionalKeys<T> = {\r\n [K in keyof T]-?: undefined extends T[K] ? never : K\r\n}[keyof T]\r\n\r\nexport type HasRequiredProps<T, True, False> = NonOptionalKeys<T> extends never\r\n ? False\r\n : True\r\n\r\nexport type OptionalIfAllPropsOptional<T> = HasRequiredProps<T, T, T | never>\r\n\r\nexport type NoInfer<T> = [T][T extends any ? 0 : never]\r\n\r\nexport type UnwrapPromise<T> = T extends PromiseLike<infer V> ? V : T\r\n\r\nexport type MaybePromise<T> = T | PromiseLike<T>\r\n\r\nexport type OmitFromUnion<T, K extends keyof T> = T extends any\r\n ? Omit<T, K>\r\n : never\r\n\r\nexport type IsAny<T, True, False = never> = true | false extends (\r\n T extends never ? true : false\r\n)\r\n ? True\r\n : False\r\n\r\nexport type CastAny<T, CastTo> = IsAny<T, CastTo, T>\r\n","import type { MutationHooks, QueryHooks } from './buildHooks'\r\nimport { buildHooks } from './buildHooks'\r\nimport { isQueryDefinition, isMutationDefinition } from '../endpointDefinitions'\r\nimport type {\r\n EndpointDefinitions,\r\n QueryDefinition,\r\n MutationDefinition,\r\n QueryArgFrom,\r\n} from '@reduxjs/toolkit/dist/query/endpointDefinitions'\r\nimport type { Api, Module } from '../apiTypes'\r\nimport { capitalize } from '../utils'\r\nimport { safeAssign } from '../tsHelpers'\r\nimport type { BaseQueryFn } from '@reduxjs/toolkit/dist/query/baseQueryTypes'\r\n\r\nimport type { HooksWithUniqueNames } from './versionedTypes'\r\n\r\nimport {\r\n useDispatch as rrUseDispatch,\r\n useSelector as rrUseSelector,\r\n useStore as rrUseStore,\r\n batch as rrBatch,\r\n} from 'react-redux'\r\nimport type { QueryKeys } from '../core/apiState'\r\nimport type { PrefetchOptions } from '../core/module'\r\n\r\nexport const reactHooksModuleName = /* @__PURE__ */ Symbol()\r\nexport type ReactHooksModule = typeof reactHooksModuleName\r\n\r\ndeclare module '@reduxjs/toolkit/dist/query/apiTypes' {\r\n export interface ApiModules<\r\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\r\n BaseQuery extends BaseQueryFn,\r\n Definitions extends EndpointDefinitions,\r\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\r\n ReducerPath extends string,\r\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\r\n TagTypes extends string\r\n > {\r\n [reactHooksModuleName]: {\r\n /**\r\n * Endpoints based on the input endpoints provided to `createApi`, containing `select`, `hooks` and `action matchers`.\r\n */\r\n endpoints: {\r\n [K in keyof Definitions]: Definitions[K] extends QueryDefinition<\r\n any,\r\n any,\r\n any,\r\n any,\r\n any\r\n >\r\n ? QueryHooks<Definitions[K]>\r\n : Definitions[K] extends MutationDefinition<any, any, any, any, any>\r\n ? MutationHooks<Definitions[K]>\r\n : never\r\n }\r\n /**\r\n * A hook that accepts a string endpoint name, and provides a callback that when called, pre-fetches the data for that endpoint.\r\n */\r\n usePrefetch<EndpointName extends QueryKeys<Definitions>>(\r\n endpointName: EndpointName,\r\n options?: PrefetchOptions\r\n ): (\r\n arg: QueryArgFrom<Definitions[EndpointName]>,\r\n options?: PrefetchOptions\r\n ) => void\r\n } & HooksWithUniqueNames<Definitions>\r\n }\r\n}\r\n\r\ntype RR = typeof import('react-redux')\r\n\r\nexport interface ReactHooksModuleOptions {\r\n /**\r\n * The version of the `batchedUpdates` function to be used\r\n */\r\n batch?: RR['batch']\r\n /**\r\n * The version of the `useDispatch` hook to be used\r\n */\r\n useDispatch?: RR['useDispatch']\r\n /**\r\n * The version of the `useSelector` hook to be used\r\n */\r\n useSelector?: RR['useSelector']\r\n /**\r\n * The version of the `useStore` hook to be used\r\n */\r\n useStore?: RR['useStore']\r\n}\r\n\r\n/**\r\n * Creates a module that generates react hooks from endpoints, for use with `buildCreateApi`.\r\n *\r\n * @example\r\n * ```ts\r\n * const MyContext = React.createContext<ReactReduxContextValue>(null as any);\r\n * const customCreateApi = buildCreateApi(\r\n * coreModule(),\r\n * reactHooksModule({ useDispatch: createDispatchHook(MyContext) })\r\n * );\r\n * ```\r\n *\r\n * @returns A module for use with `buildCreateApi`\r\n */\r\nexport const reactHooksModule = ({\r\n batch = rrBatch,\r\n useDispatch = rrUseDispatch,\r\n useSelector = rrUseSelector,\r\n useStore = rrUseStore,\r\n}: ReactHooksModuleOptions = {}): Module<ReactHooksModule> => ({\r\n name: reactHooksModuleName,\r\n init(api, options, context) {\r\n const anyApi = api as any as Api<\r\n any,\r\n Record<string, any>,\r\n string,\r\n string,\r\n ReactHooksModule\r\n >\r\n const { buildQueryHooks, buildMutationHook, usePrefetch } = buildHooks({\r\n api,\r\n moduleOptions: { batch, useDispatch, useSelector, useStore },\r\n })\r\n safeAssign(anyApi, { usePrefetch })\r\n safeAssign(context, { batch })\r\n\r\n return {\r\n injectEndpoint(endpointName, definition) {\r\n if (isQueryDefinition(definition)) {\r\n const {\r\n useQuery,\r\n useLazyQuery,\r\n useLazyQuerySubscription,\r\n useQueryState,\r\n useQuerySubscription,\r\n } = buildQueryHooks(endpointName)\r\n safeAssign(anyApi.endpoints[endpointName], {\r\n useQuery,\r\n useLazyQuery,\r\n useLazyQuerySubscription,\r\n useQueryState,\r\n useQuerySubscription,\r\n })\r\n ;(api as any)[`use${capitalize(endpointName)}Query`] = useQuery\r\n ;(api as any)[`useLazy${capitalize(endpointName)}Query`] =\r\n useLazyQuery\r\n } else if (isMutationDefinition(definition)) {\r\n const useMutation = buildMutationHook(endpointName)\r\n safeAssign(anyApi.endpoints[endpointName], {\r\n useMutation,\r\n })\r\n ;(api as any)[`use${capitalize(endpointName)}Mutation`] = useMutation\r\n }\r\n },\r\n }\r\n },\r\n})\r\n","import { configureStore } from '@reduxjs/toolkit'\r\nimport type { Context } from 'react'\r\nimport React from 'react'\r\nimport type { ReactReduxContextValue } from 'react-redux'\r\nimport { Provider } from 'react-redux'\r\nimport { setupListeners } from '@reduxjs/toolkit/query'\r\nimport type { Api } from '@reduxjs/toolkit/dist/query/apiTypes'\r\n\r\n/**\r\n * Can be used as a `Provider` if you **do not already have a Redux store**.\r\n *\r\n * @example\r\n * ```tsx\r\n * // codeblock-meta title=\"Basic usage - wrap your App with ApiProvider\"\r\n * import * as React from 'react';\r\n * import { ApiProvider } from '@reduxjs/toolkit/query/react';\r\n * import { Pokemon } from './features/Pokemon';\r\n *\r\n * function App() {\r\n * return (\r\n * <ApiProvider api={api}>\r\n * <Pokemon />\r\n * </ApiProvider>\r\n * );\r\n * }\r\n * ```\r\n *\r\n * @remarks\r\n * Using this together with an existing redux store, both will\r\n * conflict with each other - please use the traditional redux setup\r\n * in that case.\r\n */\r\nexport function ApiProvider<A extends Api<any, {}, any, any>>(props: {\r\n children: any\r\n api: A\r\n setupListeners?: Parameters<typeof setupListeners>[1]\r\n context?: Context<ReactReduxContextValue>\r\n}) {\r\n const [store] = React.useState(() =>\r\n configureStore({\r\n reducer: {\r\n [props.api.reducerPath]: props.api.reducer,\r\n },\r\n middleware: (gDM) => gDM().concat(props.api.middleware),\r\n })\r\n )\r\n // Adds the event listeners for online/offline/focus/etc\r\n setupListeners(store.dispatch, props.setupListeners)\r\n\r\n return (\r\n <Provider store={store} context={props.context}>\r\n {props.children}\r\n </Provider>\r\n )\r\n}\r\n",null]}
|