netstorage
Version:
A TypeScript API and CLI for the Akamai NetStorage REST interface
46 lines (45 loc) • 1.75 kB
TypeScript
import { type RemoteWalkEntry, type NetStorageClientConfig } from '../../index';
/**
* Represents the result of a single remove operation (file or directory).
*
* @property remotePath - The full NetStorage path of the removed entry.
* @property status - Status metadata from the NetStorage API response.
*/
export interface RemoveResult {
remotePath: string;
status: {
code: number;
};
}
/**
* Parameters for removing a directory from NetStorage.
*
* @property remotePath - Remote directory path to remove.
* @property dryRun - If true, simulates removal without executing.
* @property onRemove - Callback invoked for each successfully removed path.
* @property onSkip - Callback for each skipped path with reason and optional error.
* @property shouldRemove - Optional predicate to filter which entries should be removed.
*/
export interface RemoveDirectoryParams {
remotePath: string;
dryRun?: boolean;
onRemove?: (info: {
remotePath: string;
}) => void;
onSkip?: (info: {
remotePath: string;
reason: 'dryRun' | 'error' | 'filtered';
error?: unknown;
}) => void;
shouldRemove?: (entry: RemoteWalkEntry) => boolean | Promise<boolean>;
}
/**
* Recursively removes a directory and its contents from NetStorage.
*
* Walks all remote entries under the specified path and deletes them in reverse order.
* Honors dryRun, filtering, and error handling via callbacks.
*
* @param config - NetStorage client config.
* @param params - Configuration parameters for removal behavior.
*/
export declare function removeDirectory(config: NetStorageClientConfig, { remotePath, dryRun, onRemove, onSkip, shouldRemove, }: RemoveDirectoryParams): Promise<RemoveResult[]>;