import type { FileSourceWire } from '../contracts/not-front-v2.wire'; /** * Typed clients of piper-lite's pre-generated report files (`/api/v1/files/`, * task 07). The front knows the protocol (ADR-SVC-0011): the wire only says * where the file is. Both clients resolve to a typed outcome, never throw, and * never expose the server's text. A signed URL is returned to the caller once * and is never kept, logged or put in an error here. */ export type FileFormat = 'xlsx' | 'csv'; export declare const LATEST_VERSION = "latest"; export declare const isVersionToken: (value: unknown) => value is string; export type SignedFile = { /** A short-lived bearer credential: open it once, never keep it. */ url: string; fileName: string | null; sizeBytes: number | null; rows: number | null; version: string | null; generatedAt: string | null; }; export type SignFailure = 'notFound' | 'forbidden' | 'failed' | 'aborted'; export type SignResult = { ok: true; file: SignedFile; } | { ok: false; failure: SignFailure; }; export type SignChoice = { format: FileFormat; /** `latest` or a `YYYYMMDDTHHMMSSZ` token; anything else is never sent. */ version: string; }; /** * `POST sign/` with the closed body `{pipeline_code, file, format, * version, title}` (`title` is the wire's `fileTitle`). `userFlow` rides in the * config so a 401 reaches the token-refresh interceptor V1 uses. */ export declare const signFile: (source: FileSourceWire, { format, version }: SignChoice, userFlow: string | undefined, signal?: AbortSignal) => Promise; export type VersionStatus = 'ready' | 'generating' | 'failed' | 'unknown'; export type VersionErrorCode = 'pipeline_failed' | 'timeout' | 'too_large' | 'empty' | 'unknown'; export type VersionFile = { format: FileFormat; available: boolean; sizeBytes: number | null; unavailableReason: 'excel_row_limit' | null; }; export type FileVersion = { /** Raw from the listing: compare with `isVersionToken` before signing it. */ version: string; status: VersionStatus; startedAt: string | null; generatedAt: string | null; durationMs: number | null; rows: number | null; files: VersionFile[]; errorCode: VersionErrorCode | null; }; export type VersionsListing = { keep: number | null; stale: boolean; versions: FileVersion[]; }; export type ListFailure = 'unavailable' | 'forbidden' | 'failed' | 'aborted'; export type ListResult = { ok: true; listing: VersionsListing; } | { ok: false; failure: ListFailure; }; /** * `GET versions/?pipeline_code=&file=`, validated against the task 07 * contract. In R11 the route does not exist: a 404 or 405 is `unavailable` * (the card still downloads the latest file), not an error. */ export declare const listVersions: (source: FileSourceWire, userFlow: string | undefined, signal?: AbortSignal) => Promise;