import { L as LocalMetaStorageOptions, i as BaseStorageOptions, F as File, M as MetaStorage, d as FileInit, O as OperationOptions, e as FilePart, f as FileQuery, g as FileReturn, B as BaseStorage } from "../../packem_shared/storage.d-C9EdfTf1.js"; import { L as LocalMetaStorage } from "../../packem_shared/local-meta-storage.d-CYWYyCUo.js"; import { copy, del, list, put } from '@vercel/blob'; import 'node:stream'; import 'node:timers'; import 'node:crypto'; import 'node:http'; import 'lru-cache'; interface VercelBlobStorageOptions extends BaseStorageOptions { /** * Visibility for uploaded blobs. Vercel Blob currently exposes only * `"public"` in its SDK, but this option is here so callers can pass * through any future value without forking. Defaults to `"public"`. */ access?: "public"; /** * Configure metafiles storage * @example * Using local metafiles * ```ts * const storage = new VercelBlobStorage({ * token: process.env.BLOB_READ_WRITE_TOKEN, * metaStorageConfig: { directory: '/tmp/upload-metafiles' } * }) * ``` */ metaStorageConfig?: LocalMetaStorageOptions; /** * Enable multipart uploads for large files * Can be a boolean to always use multipart, or a number (in bytes) as threshold * @default false * @example * // Always use multipart uploads * multipart: true * // Use multipart for files larger than 100MB * multipart: 100 * 1024 * 1024 */ multipart?: boolean | number; /** * Vercel OIDC token (`VERCEL_OIDC_TOKEN`). Short-lived, auto-rotated, and the * recommended auth path for projects running on Vercel. Must be paired with * {@link VercelBlobStorageOptions.storeId} (or `BLOB_STORE_ID` env). Provide * explicitly for runtimes that don't expose `process.env` (e.g. Vite). * @see https://vercel.com/docs/vercel-blob/using-blob-sdk#oidc-tokens-recommended */ oidcToken?: string; /** * Vercel Blob store ID (`BLOB_STORE_ID`). Accepted in either `store_{id}` * or `{id}` form — the `store_` prefix is stripped automatically. Required * when authenticating via {@link VercelBlobStorageOptions.oidcToken}. */ storeId?: string; /** * Vercel Blob read-write token (`BLOB_READ_WRITE_TOKEN`). Long-lived; prefer * {@link VercelBlobStorageOptions.oidcToken} on Vercel. Always wins over OIDC * when both are supplied. */ token?: string; } declare class VercelBlobFile extends File { /** * The blob's public URL */ url?: string; /** * The blob's download URL (may be different from url for private blobs) */ downloadUrl?: string; /** * The blob's pathname within the store */ pathname?: string; } declare class VercelBlobMetaStorage extends LocalMetaStorage { constructor(config?: LocalMetaStorageOptions); } /** * Vercel Blob storage based backend. * @example * ```ts * const storage = new VercelBlobStorage({ * token: process.env.BLOB_READ_WRITE_TOKEN, * metaStorageConfig: { directory: '/tmp/upload-metafiles' } * }); * ``` * @remarks * ## Supported Operations * - ✅ create, write, delete, get, copy, move * - ✅ Batch operations: deleteBatch, copyBatch, moveBatch (inherited from BaseStorage) * - ✅ exists: Implemented (checks metadata and Vercel Blob) * - ❌ getStream: Not implemented (use get() for file retrieval) * - ❌ list: Not implemented (Vercel Blob API doesn't support listing) * - ❌ update: Not implemented (Vercel Blob API doesn't support metadata updates) * - ❌ getUrl: Not implemented (Vercel Blob URLs available via Vercel Blob API) * - ❌ getUploadUrl: Not implemented (Vercel Blob upload URLs handled internally) * - ⚠️ Per-operation `signal`/`timeout` are best-effort: the underlying SDK does not support request cancellation, so an in-flight call may complete server-side even after abort. `retries` is honored. */ /** * Auth credentials resolved at construction and forwarded verbatim to every * `@vercel/blob` SDK call. Mirrors the SDK's `BlobCommandOptions` shape so * env-based auto-pickup is never required. */ type VercelBlobCredentials = { oidcToken: string; storeId: string; token?: never; } | { oidcToken?: never; storeId?: never; token: string; }; declare class VercelBlobStorage extends BaseStorage { static override readonly name: string; override checksumTypes: string[]; override get raw(): { copy: typeof copy; credentials: VercelBlobCredentials; del: typeof del; list: typeof list; put: typeof put; }; protected meta: MetaStorage; private readonly credentials; private readonly multipart; private readonly access; constructor(config: VercelBlobStorageOptions); /** * Resolves auth credentials in the same precedence as `@vercel/blob`: * * 1. Explicit `token` (RW or client token) — always wins. * 2. OIDC pair (`oidcToken` + `storeId`), from options or env. * 3. `BLOB_READ_WRITE_TOKEN` / `VERCEL_BLOB_TOKEN` env. * * Throws if no credentials are found, or if OIDC config is partial (one of * the two values present without the other) so callers fail loudly instead * of silently dropping to anonymous calls that 401 at runtime. */ private static resolveCredentials; create(config: FileInit, _options?: OperationOptions): Promise; write(part: FilePart | FileQuery | VercelBlobFile, options?: OperationOptions): Promise; /** * Deletes an upload and its metadata. * @param query File query containing the file ID to delete. * @param query.id File ID to delete. * @returns Promise resolving to the deleted file object with status: "deleted". * @throws {UploadError} If the file metadata cannot be found. */ delete({ id }: FileQuery, options?: OperationOptions): Promise; /** * Checks if a file exists by verifying both metadata and the actual Vercel Blob. * Returns true only if both the metadata and the blob exist. * @param query File query containing the file ID to check. * @returns Promise resolving to true if both metadata and blob exist, false otherwise. */ override exists({ id }: FileQuery, options?: OperationOptions): Promise; get({ id }: FileQuery, options?: OperationOptions): Promise; /** * Copies an upload file to a new location. * @param name Source file name/ID. * @param destination Destination file name/ID. * @returns Promise resolving to the copied file object. * @throws {UploadError} If the source file cannot be found. */ copy(name: string, destination: string, options?: OperationOptions & { storageClass?: string; }): Promise; /** * Moves an upload file to a new location. * @param name Source file name/ID. * @param destination Destination file name/ID. * @returns Promise resolving to the moved file object. * @throws {UploadError} If the source file cannot be found. */ move(name: string, destination: string, options?: OperationOptions): Promise; override list(limit?: number, options?: OperationOptions): Promise; private internalOnComplete; /** * Determines if multipart upload should be used for the given file. * @param file File object to check. * @returns True if multipart upload should be used, false otherwise. */ private shouldUseMultipart; } export { VercelBlobFile, VercelBlobMetaStorage, VercelBlobStorage, type VercelBlobStorageOptions };