/** * Databricks {@link FileSystem} backed by {@link WorkspaceClient}. * * Extends {@link BaseFileSystem}. Routes I/O by absolute path: * - `/Workspace`, `/Users`, `/Repos`, `/Shared` → workspace objects API * - `/Volumes/...` (or `catalog.schema.volume` roots) → Unity Catalog Files API * - `/dbfs/...` → DBFS API * * Every primitive picks its API through {@link DatabricksFileSystem.dispatch} * rather than re-branching by hand, and error normalization is inherited from * {@link BaseFileSystem}, so a primitive here is just the SDK call. * * @module */ import { BaseFileSystem, type CopyOptions, type FileEntry, type FileStat, type WriteFileOptions } from "@dbx-tools/shared-fs"; import { type WorkspaceClient } from "./workspace.ts"; /** Options for {@link DatabricksFileSystem}. */ export interface DatabricksFileSystemOptions { /** Unique identifier. Defaults to a stable hash of the normalized root. */ id?: string; /** * Filesystem root. Accepts: * - `/Volumes/catalog/schema/volume` (also `/Volume/...`) * - `catalog.schema.volume` * - `~` / `~/...` → `/Workspace/Users//...` (needs {@link userName}, * or use {@link DatabricksFileSystem.create}) * - `/Workspace/...`, `/Users/...`, `/Repos/...`, `/Shared/...` * - `/dbfs/...` */ root: string; /** * Username for expanding `~`. When omitted and {@link root} is home-relative, * prefer {@link DatabricksFileSystem.create} which resolves it via * `getCurrentUserName`. */ userName?: string; /** * Databricks workspace client. Defaults to `tryGetWorkspaceClient()`, otherwise * a default {@link WorkspaceClient} from env / profile auth. */ client?: WorkspaceClient; /** Block all write operations. Defaults to false. */ readOnly?: boolean; /** * Create {@link root} (and parents) during init. Defaults to false (volume * and workspace roots are usually provisioned out of band). */ createRoot?: boolean; } /** * {@link FileSystem} implementation over Databricks workspace files, UC * volumes, and DBFS. * * @example * ```ts * const fs = new DatabricksFileSystem({ root: "main.default.assets" }); * await fs.writeFile("notes/hello.txt", "hi"); * * const home = await DatabricksFileSystem.create({ root: "~" }); * const listing = await home.readdir("."); * ``` */ export declare class DatabricksFileSystem extends BaseFileSystem<"databricks"> { private client; private readonly clientOption; constructor(options: DatabricksFileSystemOptions); /** * Construct a {@link DatabricksFileSystem}, resolving `~` roots via the * workspace current user when needed. */ static create(options: DatabricksFileSystemOptions): Promise; protected onInit(): Promise; /** Run the handler for `absolutePath`'s Databricks API with the live client. */ private dispatch; protected createRootDirectory(): Promise; protected readBytesAt(resolvedPath: string): Promise; protected writeBytesAt(resolvedPath: string, content: Uint8Array, options: Required): Promise; protected deleteFileAt(resolvedPath: string): Promise; protected createDirectoryAt(resolvedPath: string): Promise; protected removeDirectoryAt(resolvedPath: string): Promise; protected listDirectoryAt(resolvedPath: string): Promise; protected statAt(resolvedPath: string): Promise>; protected tryMoveFileAt(sourcePath: string, destinationPath: string, _options: Required): Promise; /** * UC `createDirectory` is single-level, so walk the path creating each level * below the volume itself. A level that already exists is not an error. */ private createVolumeDirectories; /** Stat a UC path: file metadata first, then a directory probe. */ private statVolumePath; private readDbfsFile; private writeDbfsFile; }