import { L as LocalMetaStorageOptions, f as BaseStorageOptions, F as File, C as ConditionalSupport, M as MetaStorage, e as FileInit, g as ConditionalOptions, O as OperationOptions, h as FilePart, i as FileQuery, c as FileReturn, j as CopyConditionalOptions, S as StoredObject, B as BaseStorage } from "../../packem_shared/storage.d-Cnjmzau5.js"; import { L as LocalMetaStorage } from "../../packem_shared/local-meta-storage.d-DuAe8gC_.js"; import { Readable } from 'node:stream'; import "../../packem_shared/types.d-DFh9698o.js"; import 'node:crypto'; import 'node:http'; import 'lru-cache'; interface WebdavStorageOptions extends BaseStorageOptions { /** * Send the `Files` ETag predicates to the server (`If-Match` / `If-None-Match` on `PUT`, `GET` * and `DELETE`; `If-Match`, `Overwrite: F` and a tagged `If` header on `COPY`) and advertise them * in `Files.capabilities.conditional`. Off by default: RFC 4918 servers (Nextcloud, ownCloud, * Apache `mod_dav`) evaluate them, but some WebDAV servers silently ignore them, which would turn * a compare-and-set into an unconditional write. Reported ETags are the server's when this is on. */ conditional?: boolean; /** * Extra headers sent with every request (e.g. a custom auth scheme). */ headers?: Record; /** * Configure metafile storage. WebDAV has no portable arbitrary-metadata * field, so upload metadata is stored as sidecar JSON on the local disk * (defaults to the OS temp directory). */ metaStorageConfig?: LocalMetaStorageOptions; /** * Password for HTTP Basic auth. Falls back to `WEBDAV_PASSWORD`. */ password?: string; /** * Logical "bucket root" — virtual keys live under this collection, relative * to `url`. Missing collections are created on write. Leading/trailing * slashes are ignored. */ rootFolderPath?: string; /** * Bearer token, sent in an `Authorization: Bearer` header. Takes precedence * over `username` / `password`. Falls back to `WEBDAV_TOKEN`. */ token?: string; /** * WebDAV endpoint, e.g. `https://cloud.example.com/remote.php/dav/files/alice`. * Falls back to `WEBDAV_URL`. */ url?: string; /** * Username for HTTP Basic auth. Falls back to `WEBDAV_USERNAME`. */ username?: string; } declare class WebdavFile extends File { path?: string; } declare class WebdavMetaStorage extends LocalMetaStorage { constructor(config?: LocalMetaStorageOptions); } type RangeOptions = ConditionalOptions & OperationOptions & { range?: { end?: number; start: number; }; }; /** * WebDAV storage backend (Nextcloud, ownCloud, Apache `mod_dav`, nginx, rclone serve, …), * implemented on plain `fetch` with `PROPFIND`/`PUT`/`GET`/`DELETE`/`COPY`/`MOVE`/`MKCOL`. * * Keys map onto paths under `rootFolderPath`, relative to `url`. WebDAV has no portable * metadata store, so upload metadata is kept as sidecar JSON on the local disk (see * `WebdavMetaStorage`). * * **Limitations**: * - Partial `PUT` is not part of WebDAV (RFC 4918), so only a whole-file write at offset 0 is accepted; chunked writes are rejected with `METHOD_NOT_ALLOWED`. `write()` buffers the part in memory. * - `getReadUrl` / `getUploadUrl` are not supported — a WebDAV `GET` needs credentials that can't be signed into a URL. */ declare class WebdavStorage extends BaseStorage { static override readonly name: string; override readonly storageKind: string; /** Stores each object in a single request, so chunked/resumable uploads are rejected. */ override readonly supportsResumableWrites: boolean; override checksumTypes: string[]; override readonly supportsRange: boolean; /** Every predicate goes to the server as request headers; opt-in through the `conditional` option. */ override readonly conditionalSupport: ConditionalSupport; protected meta: MetaStorage; private readonly baseUrl; private readonly basePath; private readonly headers; private readonly rootFolderPath; constructor(config: WebdavStorageOptions); create(config: FileInit, options?: ConditionalOptions & OperationOptions): Promise; write(part: FilePart | FileQuery | WebdavFile, options?: ConditionalOptions & OperationOptions): Promise; get({ id }: FileQuery, options?: RangeOptions): Promise; override getStream({ id }: FileQuery, options?: RangeOptions): Promise<{ headers?: Record; size?: number; stream: Readable; }>; delete({ id }: FileQuery, options?: ConditionalOptions & OperationOptions): Promise; copy(name: string, destination: string, options?: CopyConditionalOptions & OperationOptions & { storageClass?: string; }): Promise; move(name: string, destination: string, options?: OperationOptions): Promise; /** * Walks the tree under `rootFolderPath` with `Depth: 1` PROPFINDs (`Depth: infinity` is * disabled on most servers), stopping once `limit` files are collected. */ override list(limit?: number, options?: OperationOptions): Promise; /** * Describes the remote file stored under a key (only its properties are requested). * @param id Remote key. * @param options Operation options. * @returns The file, or `undefined` when the server answers 404 or the path is a collection. */ protected override statObject(id: string, options?: OperationOptions): Promise; /** Asks the server for the file's ETag: the record's may predate a write by another client. */ protected override currentETag(file: WebdavFile, options?: OperationOptions): Promise; override exists({ id }: FileQuery, options?: OperationOptions): Promise; /** * Refuses a predicate this adapter would not enforce: with `conditional` off, the headers * reach servers that may ignore them, turning a compare-and-set into a plain write. * @param kind Kind of operation * @param options Predicates of the call */ private assertConditionSupported; private request; private download; /** * PUT, creating the missing parent collections when the server answers 409 (RFC 4918 §9.7.1). * @returns The ETag the server answered with, if any. */ private put; /** Server-side COPY / MOVE with overwrite, creating missing parent collections of the target. */ private transfer; /** MKCOL every ancestor collection of `path`, top-down; 405 means it already exists. */ private ensureCollections; /** * PROPFIND `path` at the given depth. * @returns The entries, or `undefined` when the resource does not exist (404). Other failures throw. */ private propfind; /** * Entries of a PROPFIND multistatus. * @param xml Response body * @param requestUrl URL the PROPFIND went to: a relative href resolves against it (RFC 4918 §8.3) * @returns The entries; one that can't be read is left out rather than failing the listing */ private parseMultistatus; private toUrl; private keyToPath; private pathToKey; } export { WebdavFile, WebdavMetaStorage, WebdavStorage, type WebdavStorageOptions };