@synet/fs
Version:
Robust, battle-tested filesystem abstraction for Node.js
113 lines (112 loc) • 3.12 kB
TypeScript
/**
* Async Filesystem Unit - Pure Asynchronous Operations
*
* This unit provides asynchronous filesystem operations with direct method access.
* No async/sync mixing, no runtime type checks, no zalgo.
*/
import { Unit, Capabilities, Schema, Validator, type TeachingContract, type UnitCore, type UnitProps } from "@synet/unit";
import type { FileStats, IAsyncFileSystem } from "./async-filesystem.interface";
/**
* Async filesystem creation configuration
*/
export interface AsyncFilesystemConfig {
adapter: IAsyncFileSystem;
}
/**
* Async Filesystem Unit properties following Unit Architecture
*/
interface AsyncFileSystemProps extends UnitProps {
backend: IAsyncFileSystem;
config: AsyncFilesystemConfig;
}
/**
* Async Filesystem Unit - Pure asynchronous filesystem operations
*/
export declare class AsyncFileSystem extends Unit<AsyncFileSystemProps> implements IAsyncFileSystem {
protected constructor(props: AsyncFileSystemProps);
/**
* Build consciousness trinity - creates living instances once
*/
protected build(): UnitCore;
/**
* CREATE - Create a new async Filesystem Unit
*/
static create(config: AsyncFilesystemConfig): AsyncFileSystem;
/**
* Get capabilities consciousness - returns living instance
*/
capabilities(): Capabilities;
/**
* Get schema consciousness - returns living instance
*/
schema(): Schema;
/**
* Get validator consciousness - returns living instance
*/
validator(): Validator;
/**
* Normalize path for backend compatibility
*/
private normalizePath;
/**
* Read file content asynchronously
*/
readFile(path: string): Promise<string>;
/**
* Write file content asynchronously
*/
writeFile(path: string, data: string): Promise<void>;
/**
* Check if file/directory exists asynchronously
*/
exists(path: string): Promise<boolean>;
/**
* Delete file asynchronously
*/
deleteFile(path: string): Promise<void>;
/**
* Read directory contents asynchronously
*/
readDir(path: string): Promise<string[]>;
/**
* Ensure directory exists asynchronously
*/
ensureDir(path: string): Promise<void>;
/**
* Delete directory asynchronously
*/
deleteDir(path: string): Promise<void>;
/**
* Set file permissions asynchronously
*/
chmod(path: string, mode: number): Promise<void>;
/**
* Get file statistics asynchronously
*/
stat(path: string): Promise<FileStats>;
/**
* Clear directory contents asynchronously
*/
clear(dirPath: string): Promise<void>;
/**
* TEACH - Provide filesystem capabilities to other units
*/
teach(): TeachingContract;
whoami(): string;
help(): void;
/**
* Get operation statistics
*/
/**
* Get configuration
*/
getConfig(): {
adapter: IAsyncFileSystem;
};
/**
* Get direct access to the backend (escape hatch)
*/
getBackend(): IAsyncFileSystem;
isAsync(): boolean;
}
export {};