/** * Quota error detection utilities. * * Backend services return HTTP 429 with GraphQL error code `QUOTA_EXHAUSTED` * (and extension fields like `field`, `quotaName`, `limitLeft`) when an * `@usage`-annotated mutation exceeds its quota. Apollo Client surfaces this * shape through one of three paths depending on whether the response was * parsed as a network error or as GraphQL errors. * * See: ~/products/dev/platform/context/usage/HOW_TO_INTEGRATE_USAGE_MICROFE.md */ export declare const QUOTA_EXHAUSTED_CODE: "QUOTA_EXHAUSTED"; export declare const STORAGE_QUOTA_EXCEEDED_CODE: "STORAGE_QUOTA_EXCEEDED"; export declare const RESOURCE_CAP_EXCEEDED_CODE: "RESOURCE_CAP_EXCEEDED"; /** * All upgrade-eligible error codes the gateway/subgraphs may emit when a * plan limit is hit. Any error with one of these codes should surface the * shared `UpgradePromptModal` via `dispatchUpgradePrompt`. */ export declare const UPGRADE_ERROR_CODES: readonly ["QUOTA_EXHAUSTED", "STORAGE_QUOTA_EXCEEDED", "RESOURCE_CAP_EXCEEDED"]; export type UpgradeErrorCode = (typeof UPGRADE_ERROR_CODES)[number]; export interface QuotaExhaustedExtensions { code: typeof QUOTA_EXHAUSTED_CODE; field?: string; quotaName?: string; limitLeft?: number; limit?: number; used?: number; } /** * Extensions emitted by storage / resource cap errors. Storage backends set * `currentBytes/limitBytes`; resource-cap backends set `currentCount/limit`. * Both carry `planName` and `resource`. */ export interface UpgradeErrorExtensions { code: UpgradeErrorCode; resource?: string; planName?: string; currentBytes?: number; limitBytes?: number; currentCount?: number; limit?: number; field?: string; quotaName?: string; used?: number; limitLeft?: number; } /** * Returns true if the error matches any upgrade-eligible code * (QUOTA_EXHAUSTED, STORAGE_QUOTA_EXCEEDED, RESOURCE_CAP_EXCEEDED). */ export declare function isUpgradeError(err: unknown): boolean; /** * Extract upgrade-eligible error extensions from any Apollo error shape. */ export declare function extractUpgradeErrorExtensions(err: unknown): UpgradeErrorExtensions | null; /** * Resolve current/limit numerics for display, abstracting over storage-vs-count. */ export declare function resolveUpgradeUsage(ext: UpgradeErrorExtensions | null): { current: number | null; limit: number | null; unit: 'bytes' | 'count'; }; /** * Returns true if the given error is a `QUOTA_EXHAUSTED` response from any * gateway path Apollo may surface it through. */ export declare function isQuotaExhaustedError(err: unknown): boolean; /** * Extracts the QUOTA_EXHAUSTED extensions object from any Apollo error shape, * or returns `null` if the error is not a quota-exhausted error. */ export declare function extractQuotaExhaustedExtensions(err: unknown): QuotaExhaustedExtensions | null; /** * Build a user-facing toast message for a quota-exhausted error. Uses * `quotaName` (preferred) or `field` from the extensions when available, and * falls back to a generic message otherwise. */ export declare function buildQuotaExhaustedMessage(ext: QuotaExhaustedExtensions | null): string; //# sourceMappingURL=quotaErrors.d.ts.map