/** * Objectstore client for uploading files, such as snapshot images, through the * service that Sentry's upload-options endpoints return * (e.g. `snapshots/upload-options/`). * * Implements the subset of the `objectstore-client` protocol * (getsentry/objectstore) that uploads need: find which objects already exist, * then upload the missing ones. The service URL, scopes, auth token, and * expiration policy come from the Sentry API; this client never signs tokens. * * Object path layout: `{url}/v1/objects/{usecase}/{scope}/{key}`, where `scope` * is a `;`-joined list of ordered `key=value` pairs. Auth is carried in the * `x-os-auth: Bearer ` header, not `Authorization`. * * Like the Rust client's `Session::many()`, HEADs and small inserts are grouped * into multipart requests to `{url}/v1/objects:batch/{usecase}/{scope}/`. The * Sentry proxy in front of Objectstore rate-limits each HTTP request, so one * request per object trips it (HTTP 429) on larger uploads. Batches use the * JSON layout of the batch endpoint, which carries all operation data in form * fields, so requests and responses go through web-standard `FormData`. * * Uses only web-standard APIs. Hosts supply file contents through * {@link ObjectUpload.read} and may inject `fetch` (e.g. for custom CAs). */ import { ApiError } from "./errors.js"; /** * Objectstore upload configuration, as returned (camelCase) by the Sentry * upload-options endpoints. */ export type ObjectstoreConfig = { /** Base service URL (may include a path prefix). */ url: string; usecase: string; /** Ordered scope pairs (e.g. `[["org","1"],["project","2"]]`). */ scopes: [string, string][]; /** Pre-signed bearer token, or null/absent for unauthenticated stores. */ authToken?: string | null; /** Expiration policy string applied to uploaded objects. */ expirationPolicy: string; }; /** Host capabilities for Objectstore requests. */ export type ObjectstoreOptions = { /** Fetch to send requests with. Defaults to `globalThis.fetch`. */ fetch?: (input: string, init?: RequestInit) => Promise; }; /** A file to upload under an object key. */ export type ObjectUpload = { key: string; /** Size in bytes, used to group uploads before any file is read. */ size: number; /** Read the file's bytes. Called once, when its request starts. */ read: () => Promise>; }; /** * A failed Objectstore request or operation. `url` is the object URL for a * failed operation, or the request URL for a failed request. */ export declare class ObjectstoreError extends ApiError { readonly url: string; constructor(message: string, status: number, detail: string, url: string); } /** * Find which keys already exist, using batched HEAD operations (one request * per {@link MAX_BATCH_OPS} keys, up to {@link BATCH_CONCURRENCY} at once). * * @returns The subset of `keys` that exist. * @throws {ObjectstoreError} On a failed batch, or any HEAD result other than 2xx/404. */ export declare function findExistingObjects(config: ObjectstoreConfig, keys: string[], options?: ObjectstoreOptions): Promise>; /** * Upload objects. Uploads up to {@link MAX_BATCH_PART_SIZE} are sent in batch * requests, up to {@link BATCH_CONCURRENCY} at once; larger ones are PUT * individually, up to {@link INDIVIDUAL_CONCURRENCY} at once. Both run in * parallel. Each upload is read only when its request starts. * * @throws {ObjectstoreError} On a failed batch, or any failed insert. */ export declare function putObjects(config: ObjectstoreConfig, uploads: ObjectUpload[], options?: ObjectstoreOptions): Promise;