Skip to content

Latest commit

 

History

History
331 lines (302 loc) · 8.38 KB

rtk-query.api.md

File metadata and controls

331 lines (302 loc) · 8.38 KB

API Report File for "@reduxjs/toolkit"

Do not edit this file. It is a report generated by API Extractor.

import type { ActionCreatorWithoutPayload } from '@reduxjs/toolkit'
import type { UnknownAction } from '@reduxjs/toolkit'
import type { SerializedError } from '@reduxjs/toolkit'
import type { ThunkDispatch } from '@reduxjs/toolkit'

// @public (undocumented)
export type Api<
  BaseQuery extends BaseQueryFn,
  Definitions extends EndpointDefinitions,
  ReducerPath extends string,
  TagTypes extends string,
  Enhancers extends ModuleName = CoreModule,
> = UnionToIntersection<
  ApiModules<BaseQuery, Definitions, ReducerPath, TagTypes>[Enhancers]
> & {
  injectEndpoints<NewDefinitions extends EndpointDefinitions>(_: {
    endpoints: (
      build: EndpointBuilder<BaseQuery, TagTypes, ReducerPath>,
    ) => NewDefinitions
    overrideExisting?: boolean
  }): Api<
    BaseQuery,
    Definitions & NewDefinitions,
    ReducerPath,
    TagTypes,
    Enhancers
  >
  enhanceEndpoints<NewTagTypes extends string = never>(_: {
    addTagTypes?: readonly NewTagTypes[]
    endpoints?: ReplaceTagTypes<
      Definitions,
      TagTypes | NoInfer<NewTagTypes>
    > extends infer NewDefinitions
      ? {
          [K in keyof NewDefinitions]?:
            | Partial<NewDefinitions[K]>
            | ((definition: NewDefinitions[K]) => void)
        }
      : never
  }): Api<
    BaseQuery,
    ReplaceTagTypes<Definitions, TagTypes | NewTagTypes>,
    ReducerPath,
    TagTypes | NewTagTypes,
    Enhancers
  >
}

// @public (undocumented)
export interface ApiModules<
  BaseQuery extends BaseQueryFn,
  Definitions extends EndpointDefinitions,
  ReducerPath extends string,
  TagTypes extends string,
> {}

// @public (undocumented)
export type BaseQueryEnhancer<
  AdditionalArgs = unknown,
  AdditionalDefinitionExtraOptions = unknown,
  Config = void,
> = <BaseQuery extends BaseQueryFn>(
  baseQuery: BaseQuery,
  config: Config,
) => BaseQueryFn<
  BaseQueryArg<BaseQuery> & AdditionalArgs,
  BaseQueryResult<BaseQuery>,
  BaseQueryError<BaseQuery>,
  BaseQueryExtraOptions<BaseQuery> & AdditionalDefinitionExtraOptions
>

// @public (undocumented)
export type BaseQueryFn<
  Args = any,
  Result = unknown,
  Error = unknown,
  DefinitionExtraOptions = {
    copyWithStructuralSharing?: boolean
  },
  Meta = {},
> = (
  args: Args,
  api: BaseQueryApi,
  extraOptions: DefinitionExtraOptions,
) => MaybePromise<QueryReturnValue<Result, Error, Meta>>

// @public
export function buildCreateApi<Modules extends [Module<any>, ...Module<any>[]]>(
  ...modules: Modules
): CreateApi<Modules[number]['name']>

// @public (undocumented)
export function copyWithStructuralSharing<T>(oldObj: any, newObj: T): T

// @public
export const coreModule: () => Module<CoreModule>

// @public (undocumented)
export type CreateApi<Modules extends ModuleName> = {
  <
    BaseQuery extends BaseQueryFn,
    Definitions extends EndpointDefinitions,
    ReducerPath extends string = 'api',
    TagTypes extends string = never,
  >(
    options: CreateApiOptions<BaseQuery, Definitions, ReducerPath, TagTypes>,
  ): Api<BaseQuery, Definitions, ReducerPath, TagTypes, Modules>
}

// @public (undocumented)
export const createApi: CreateApi<typeof coreModuleName>

// @public (undocumented)
export interface CreateApiOptions<
  BaseQuery extends BaseQueryFn,
  Definitions extends EndpointDefinitions,
  ReducerPath extends string = 'api',
  TagTypes extends string = never,
> {
  baseQuery: BaseQuery
  endpoints(
    build: EndpointBuilder<BaseQuery, TagTypes, ReducerPath>,
  ): Definitions
  extractRehydrationInfo?: (
    action: UnknownAction,
    {
      reducerPath,
    }: {
      reducerPath: ReducerPath
    },
  ) =>
    | undefined
    | CombinedState<
        NoInfer<Definitions>,
        NoInfer<TagTypes>,
        NoInfer<ReducerPath>
      >
  keepUnusedDataFor?: number
  reducerPath?: ReducerPath
  refetchOnFocus?: boolean
  refetchOnMountOrArgChange?: boolean | number
  refetchOnReconnect?: boolean
  serializeQueryArgs?: SerializeQueryArgs<BaseQueryArg<BaseQuery>>
  structuralSharing?: boolean
  tagTypes?: readonly TagTypes[]
}

// @public (undocumented)
export type EndpointDefinition<
  QueryArg,
  BaseQuery extends BaseQueryFn,
  TagTypes extends string,
  ResultType,
  ReducerPath extends string = string,
> =
  | QueryDefinition<QueryArg, BaseQuery, TagTypes, ResultType, ReducerPath>
  | MutationDefinition<QueryArg, BaseQuery, TagTypes, ResultType, ReducerPath>

// @public (undocumented)
export type EndpointDefinitions = Record<
  string,
  EndpointDefinition<any, any, any, any>
>

// @public
export function fakeBaseQuery<ErrorType>(): BaseQueryFn<
  void,
  NEVER,
  ErrorType,
  {}
>

// @public (undocumented)
export interface FetchArgs extends CustomRequestInit {
  // (undocumented)
  body?: any
  // (undocumented)
  params?: Record<string, any>
  // (undocumented)
  responseHandler?: ResponseHandler
  // (undocumented)
  url: string
  // (undocumented)
  validateStatus?: (response: Response, body: any) => boolean
}

// @public
export function fetchBaseQuery({
  baseUrl,
  prepareHeaders,
  fetchFn,
  paramsSerializer,
  ...baseFetchOptions
}?: FetchBaseQueryArgs): BaseQueryFn<
  string | FetchArgs,
  unknown,
  FetchBaseQueryError,
  {},
  FetchBaseQueryMeta
>

// @public (undocumented)
export type FetchBaseQueryError =
  | {
      status: number
      data: unknown
    }
  | {
      status: 'FETCH_ERROR'
      data?: undefined
      error: string
    }
  | {
      status: 'PARSING_ERROR'
      originalStatus: number
      data: string
      error: string
    }
  | {
      status: 'CUSTOM_ERROR'
      data?: unknown
      error: string
    }

// @public (undocumented)
export type FetchBaseQueryMeta = {
  request: Request
  response?: Response
}

// @public (undocumented)
export type Module<Name extends ModuleName> = {
  name: Name
  init<
    BaseQuery extends BaseQueryFn,
    Definitions extends EndpointDefinitions,
    ReducerPath extends string,
    TagTypes extends string,
  >(
    api: Api<BaseQuery, EndpointDefinitions, ReducerPath, TagTypes, ModuleName>,
    options: WithRequiredProp<
      CreateApiOptions<BaseQuery, Definitions, ReducerPath, TagTypes>,
      | 'reducerPath'
      | 'serializeQueryArgs'
      | 'keepUnusedDataFor'
      | 'refetchOnMountOrArgChange'
      | 'refetchOnFocus'
      | 'refetchOnReconnect'
      | 'tagTypes'
      | 'structuralSharing'
    >,
    context: ApiContext<Definitions>,
  ): {
    injectEndpoint(
      endpointName: string,
      definition: EndpointDefinition<any, any, any, any>,
    ): void
  }
}

// @public (undocumented)
export type MutationDefinition<
  QueryArg,
  BaseQuery extends BaseQueryFn,
  TagTypes extends string,
  ResultType,
  ReducerPath extends string = string,
> = BaseEndpointDefinition<QueryArg, BaseQuery, ResultType> &
  MutationExtraOptions<TagTypes, ResultType, QueryArg, BaseQuery, ReducerPath>

// @public (undocumented)
export type QueryDefinition<
  QueryArg,
  BaseQuery extends BaseQueryFn,
  TagTypes extends string,
  ResultType,
  ReducerPath extends string = string,
> = BaseEndpointDefinition<QueryArg, BaseQuery, ResultType> &
  QueryExtraOptions<TagTypes, ResultType, QueryArg, BaseQuery, ReducerPath>

// @public
export enum QueryStatus {
  // (undocumented)
  fulfilled = 'fulfilled',
  // (undocumented)
  pending = 'pending',
  // (undocumented)
  rejected = 'rejected',
  // (undocumented)
  uninitialized = 'uninitialized',
}

// @public
export const retry: BaseQueryEnhancer<
  unknown,
  RetryOptions,
  void | RetryOptions
> & {
  fail: typeof fail_2
}

// @public
export function setupListeners(
  dispatch: ThunkDispatch<any, any, any>,
  customHandler?: (
    dispatch: ThunkDispatch<any, any, any>,
    actions: {
      onFocus: typeof onFocus
      onFocusLost: typeof onFocusLost
      onOnline: typeof onOnline
      onOffline: typeof onOffline
    },
  ) => () => void,
): () => void

// @public @deprecated (undocumented)
export const skipSelector: symbol

// @public (undocumented)
export type SkipToken = typeof skipToken

// @public
export const skipToken: unique symbol

// (No @packageDocumentation comment for this package)