{"version":3,"file":"retry-policy.cjs","names":[],"sources":["../../src/query/retry-policy.ts"],"sourcesContent":["import { isApiError, isRetriableStatus } from \"../http/errors\";\n\n/** How many times a retriable failure is replayed. */\nconst MAX_RETRIES = 1;\n\n/**\n * Default `retry` for SDK queries: replay transport and server failures, never a\n * deliberate client-side refusal.\n *\n * A flat `retry: 1` replays a 403 on an admin-only listing and a 404 for a record\n * somebody deleted. The server meant both — the second attempt returns the same\n * answer, doubles the network log and holds the spinner on screen for the length\n * of another round trip. A network failure or a 5xx is a different thing: it may\n * well succeed on the next try, so those keep the previous behaviour.\n *\n * The status list is {@link isRetriableStatus}, shared with the client's own\n * policy. It used to be a second copy here, and the copy was missing `425` — so\n * a `425 Too Early` was replayed by `createApiClient({ retry: true })` and not\n * by a query, for the same error in the same app.\n *\n * @example\n * new QueryClient({ defaultOptions: { queries: { retry: shouldRetryQuery } } });\n *\n * @param failureCount - Attempts already made, as react-query counts them.\n * @param error - The rejection value from the query function.\n * @returns Whether react-query should try again.\n */\nexport function shouldRetryQuery(failureCount: number, error: unknown): boolean {\n    if (failureCount >= MAX_RETRIES) return false;\n    if (!isApiError(error)) return true;\n    return isRetriableStatus(error.status);\n}\n"],"mappings":"sCAGA,IAAM,EAAc,EAwBpB,SAAgB,EAAiB,EAAsB,EAAyB,CAG5E,OAFI,GAAgB,EAAoB,GACxC,CAAK,EAAA,WAAW,CAAK,GACd,EAAA,kBAAkB,EAAM,MAAM,CACzC"}