import type { fs } from './interfaces.js'; export type FsAccess = 'read' | 'stat' | 'list' | 'write' | 'delete' | 'share'; export type FsPathKind = 'file' | 'dir'; export interface FsTarget { readonly fs: fs; /** Normalised by normalizeFsPath against `fs.BasePath`; '' is the fs root. */ readonly path: string; readonly kind: FsPathKind; readonly access: readonly FsAccess[]; readonly role: 'source' | 'destination'; } export interface FsTargetSpec { /** Default: the fs the action runs on. */ readonly fs?: fs; readonly path: string; readonly kind: FsPathKind; readonly access: readonly FsAccess[]; readonly role?: 'source' | 'destination'; } export interface FsActionContext { readonly action: string; readonly fs: fs; readonly targets: readonly FsTarget[]; /** Non-path arguments; a middleware may replace entries (signedUrl options). */ args: unknown[]; readonly state: Map; /** Memoised per target; runs inside the action frame, so no middleware sees it. */ exists(target: FsTarget): Promise; /** Like `exists`: whether the target path is a directory now (an S3 key never is). */ isDir(target: FsTarget): Promise; /** Like `isDir`: `target.fs.hasEntries`; a failing probe rejects, so it never passes for a free path. */ hasEntries(target: FsTarget): Promise; } /** * Runs around every public file action of every fs provider. Lower `order` runs first; ties keep registration order. * `before` hooks run before any IO and abort the action by throwing; `after` hooks run in the same order once the IO * succeeded and may replace the result (not for stream actions, whose hooks run when the stream emits 'close'). */ export declare abstract class FsMiddleware { order: number; /** Asked for every distinct fs the action touches; the middleware runs when any answers true. Default: always. */ isEnabled?(fs: fs): boolean; abstract before(ctx: FsActionContext): Promise; after?(ctx: FsActionContext, result: unknown): Promise; } export declare function inFsAction(): boolean; export declare function fsTarget(owner: fs, spec: FsTargetSpec): FsTarget; export interface FsActionRun { readonly action: string; readonly owner: fs; readonly targets: readonly FsTarget[]; readonly args: unknown[]; readonly impl: (targets: readonly FsTarget[], args: unknown[]) => Promise; readonly stream?: boolean; } export declare function executeFsAction(run: FsActionRun): Promise; //# sourceMappingURL=actions.d.ts.map