/** * One parser for every shape the vault service uses to refuse a write because * the company (or personal vault) is over its plan limits. * * Shapes accepted: * * 1. The canonical hard-stop body, sent with HTTP 402: * `{ error: "plan_limit_reached", code: "PLAN_LIMIT_EXCEEDED", status: 402, * blocked, resources: [{ resource, used, limit }], message, fixOptions, * freeMonth?, upgradeUrl }` * 2. The legacy membership 402: * `{ code: "PLAN_LIMIT_EXCEEDED", resource, used, limit, requiredPlan, upgradeUrl }` * 3. A per-item presign row: `{ key, op, error, code: "PLAN_LIMIT_REACHED" | * "PLAN_LIMIT_EXCEEDED", upgradeUrl }`. Here `error` is either the machine * value `plan_limit_reached` or a human sentence. * 4. The sync mutation-prepare skip, sent with HTTP 200: * `{ skipped: true, code, message, error, blocked, resources, upgradeUrl }` * * A body is a plan-limit refusal only when it carries a plan-limit marker * (`error: "plan_limit_reached"`, or `code` of `PLAN_LIMIT_EXCEEDED` / * `PLAN_LIMIT_REACHED`) and an `https:` `upgradeUrl`. The HTTP status alone * never makes a body a plan-limit refusal: other 402s (billing, payment * method) keep their own handling. * * This module has no imports so the vault client, the presign transport and * the mutation client can all share it without a cycle. */ /** Machine `error` value of the canonical hard-stop body. */ export declare const PLAN_LIMIT_REACHED_ERROR = "plan_limit_reached"; /** Machine `code` values that mark a plan-limit refusal (current and legacy). */ export declare const PLAN_LIMIT_CODES: ReadonlySet; /** One over-limit resource from the refusal body. */ export interface PlanLimitResource { resource: string; used: number; limit: number; } /** * The parts of a plan-limit refusal a client can show: the server's sentence, * the upgrade link, and which resources are over. */ export interface PlanLimitRefusal { /** Server-selected billing destination. Always present. */ upgradeUrl: string; /** Customer-facing sentence from the server, when it sent one. */ message?: string; /** `PLAN_LIMIT_EXCEEDED` or `PLAN_LIMIT_REACHED` when the body carried one. */ code?: string; /** `plan_limit_reached` when the body carried the machine error value. */ error?: string; /** The refused action, e.g. `files.create`. */ blocked?: string; /** Over-limit resources with their usage and limit. */ resources?: PlanLimitResource[]; /** Trim-back target per resource. */ fixOptions?: Record; /** Free-month offer details, passed through as the server sent them. */ freeMonth?: Record; } /** * True for an absolute `https:` URL. Upgrade links are opened in a browser * or printed for the user to click, so any other scheme is rejected. */ export declare function isHttpsUpgradeUrl(value: unknown): value is string; /** True when `error` or `code` names a plan-limit refusal. */ export declare function hasPlanLimitMarker(fields: { error?: unknown; code?: unknown; }): boolean; /** * Parse a response body (already JSON-decoded), a per-item presign row, or a * stored refusal into a plan-limit refusal. Returns null unless the body has a * plan-limit marker and an `https:` upgrade link. */ export declare function parsePlanLimitRefusal(body: unknown): PlanLimitRefusal | null; /** Parse a raw response text; non-JSON text is never a plan-limit refusal. */ export declare function parsePlanLimitRefusalText(text: string): PlanLimitRefusal | null; /** * One console line for a `plan-limit` sync event: how many files were * refused, the server's sentence, and the upgrade link. */ export declare function formatPlanLimitNotice(event: { upgradeUrl: string; count?: number; message?: string; }): string; //# sourceMappingURL=plan-limit.d.ts.map