/** * Databricks path recognition and normalization for {@link DatabricksFileSystem}. * * Roots may be written as: * - Unity Catalog volume: `/Volumes/catalog/schema/volume` (also accepts `/Volume/...`) * - Three-part volume id: `catalog.schema.volume` → `/Volumes/catalog/schema/volume` * - Home shorthand: `~` / `~/...` → `/Workspace/Users//...` * - Workspace tree: `/Workspace/...`, `/Users/...`, `/Repos/...`, `/Shared/...` * - DBFS: `/dbfs/...` * * @module */ import { posixPath } from "@dbx-tools/shared-fs"; import { type WorkspaceClient } from "./workspace.ts"; /** Which Databricks Files API serves an absolute path. */ export type DatabricksFilesBackend = "workspace" | "volumes" | "dbfs"; /** Options for synchronous {@link normalizeDatabricksRoot}. */ export interface NormalizeDatabricksRootOptions { /** * Username used to expand `~` → `/Workspace/Users/`. * Required when {@link root} is `~` or `~/...`. Prefer * {@link resolveDatabricksRoot} when the name should come from the workspace * client. */ userName?: string; } /** Options for async {@link resolveDatabricksRoot}. */ export interface ResolveDatabricksRootOptions { /** Client used to resolve the current username for `~` expansion. */ client?: WorkspaceClient; } /** True when {@link input} is `~` or a path under `~/`. See {@link posixPath.isHomeRelativePath}. */ export declare const isHomeRelativePath: typeof posixPath.isHomeRelativePath; /** * Expand `~` / `~/...` to `/Workspace/Users//...`. * Non-home inputs are returned unchanged (POSIX separators only). */ export declare function expandHomePath(input: string, userName: string): string; /** * Normalize a Databricks filesystem root to an absolute POSIX path. * * - `catalog.schema.volume` → `/Volumes/catalog/schema/volume` * - `/Volume/...` → `/Volumes/...` (singular typo / shorthand) * - `~` / `~/...` → `/Workspace/Users//...` (needs {@link NormalizeDatabricksRootOptions.userName}) * - strips trailing slashes (except `/`) * * For `~` without a known username, use {@link resolveDatabricksRoot}. */ export declare function normalizeDatabricksRoot(root: string, options?: NormalizeDatabricksRootOptions): string; /** * Like {@link normalizeDatabricksRoot}, but resolves `~` via * {@link getCurrentUserName} (AppKit context user, else `currentUser.me()`). */ export declare function resolveDatabricksRoot(root: string, options?: ResolveDatabricksRootOptions): Promise; /** True when {@link absolutePath} is served by the workspace objects API. */ export declare function isWorkspaceFilesPath(absolutePath: string): boolean; /** True when {@link absolutePath} is a Unity Catalog volume path. */ export declare function isVolumesPath(absolutePath: string): boolean; /** True when {@link absolutePath} is a DBFS path. */ export declare function isDbfsPath(absolutePath: string): boolean; /** * Pick the Databricks API backend for an absolute path. * * Volume three-part roots are normalized before this runs, so callers should * pass paths from {@link normalizeDatabricksRoot} / {@link BaseFileSystem.resolvePath}. */ export declare function resolveDatabricksFilesBackend(absolutePath: string): DatabricksFilesBackend;