import { type RetryOptions } from "../helpers/retryWithBackoff.js"; import type { Logger } from "../types/Logger.js"; import type { FetchClientOptions } from "./fetchClientTypes.js"; /** * Métodos que se pueden repetir tras un fallo sin respuesta (#222). En * POST/PUT/PATCH/DELETE no se sabe si el servidor aplicó la petición, y * repetirla puede duplicar una escritura (en Modyo `alternatives` es * incremental, #235). Los reintentos por status (429/503/504) siguen igual * para todos los métodos; el 504 en escrituras tiene la misma ambigüedad y * queda para 0.6.0. Una petición puede acotarlos con `retryableStatusCodes` * (la creación de entradas de `content-spaces-copy`, #248). */ /** Tiempos de reintento ajustables, solo para tests (ver el constructor). */ export type RetryTimingOverrides = Pick; export declare class FetchClient { baseUrl: string; options: RequestInit; log: Logger; private debugMode; private retryOverrides; /** * @param retryOverrides Solo para tests: acorta `maxRetries` y los * retardos para probar los reintentos contra servidores locales sin * esperar segundos. En producción no se pasa y rigen los valores por * defecto (3 reintentos, 1000 ms iniciales, 30000 ms de tope). */ constructor(baseUrl: string, options: FetchClientOptions | undefined, log: Logger, debugMode?: boolean, retryOverrides?: RetryTimingOverrides); private LogAction; /** * Sanitizes sensitive headers and body fields from options before logging. * Redacts Authorization header values and, in the JSON body, every secret * by key name (#276), while preserving other data. */ private sanitizeOptionsForLogging; private getFullPath; fetch(path: string, options?: FetchClientOptions): Promise; /** * Parses a response body as JSON, tolerating responses without one. * * Returns `{ empty: true }` for `204 No Content`, for `Content-Length: 0` * and for a body that is empty or whitespace only. A body with the JSON * literal `null` is not empty: it returns `{ empty: false, value: null }`. * A non-empty body that is not valid JSON throws an error with the status, * the content type and the length. The body text is left out of the error: * secret redaction works on parsed JSON, so an unparseable body could carry * a secret into the message. */ private parseBody; /** Sends a JSON write and parses the body, keeping empty apart from null. */ private sendJson; /** * Reads a resource. A read without a body is anomalous: an empty response * throws an error that names the method and the path. */ get(path: string, options?: FetchClientOptions): Promise; /** * Sends a JSON write and returns the status and the parsed body. * * A write may return the entity, a receipt (for example `{ id }`) or no * body at all (`body: null`, typically with status 204). Callers that need * the resulting state must read the resource after writing. */ write(method: "POST" | "PUT" | "PATCH", path: string, body: Request, options?: FetchClientOptions): Promise<{ status: number; body: Result | null; }>; /** * POST with a JSON body. A write may return the entity, a receipt (for * example `{ id }`) or no body at all; callers that need the resulting * state must read the resource after writing. This method expects a body: * an empty response throws an error saying the write may have been * applied. Use `write()` to accept an empty body. */ post(path: string, body: Request, options?: FetchClientOptions): Promise; /** * POST with a multipart body. A write may return the entity, a receipt * (for example `{ id }`) or no body at all; callers that need the * resulting state must read the resource after writing. This method * expects a body: an empty response throws an error saying the write may * have been applied. */ postFormData(path: string, formData: FormData, options?: FetchClientOptions): Promise; /** * PUT with a multipart body. A write may return the entity, a receipt * (for example `{ id }`) or no body at all; callers that need the * resulting state must read the resource after writing. This method * expects a body: an empty response throws an error saying the write may * have been applied. */ putFormData(path: string, formData: FormData, options?: FetchClientOptions): Promise; /** * PUT with a JSON body. A write may return the entity, a receipt (for * example `{ id }`) or no body at all; callers that need the resulting * state must read the resource after writing. This method expects a body: * an empty response throws an error saying the write may have been * applied. Use `write()` to accept an empty body. */ put(path: string, body: Request, options?: FetchClientOptions): Promise; /** * PATCH with a JSON body. A write may return the entity, a receipt (for * example `{ id }`) or no body at all; callers that need the resulting * state must read the resource after writing. This method expects a body: * an empty response throws an error saying the write may have been * applied. Use `write()` to accept an empty body. */ patch(path: string, body: Request, options?: FetchClientOptions): Promise; delete(path: string, options?: FetchClientOptions, body?: Request): Promise; } //# sourceMappingURL=fetchClient.d.ts.map