import { BrainerceError } from 'brainerce'; /** * True when a reviews call failed because the merchant switched reviews off. * * Branch on the stable `details.code`, never on the message wording: a bare 403 * is also what the origin check and a suspended store answer. Any other failure * (network, 5xx) is a real error and must not be treated as "reviews are off". * * Prefer reading `storeInfo.reviewsEnabled` first (see `reviewsAreOn`); this * covers a backend too old to send the flag. */ export function isReviewsDisabledError(err: unknown): boolean { return ( err instanceof BrainerceError && err.statusCode === 403 && (err.details as { code?: string } | undefined)?.code === 'REVIEWS_DISABLED' ); }