@kadi.build/local-remote-file-manager-ability
Version:
Local & Remote File Management System with S3-compatible container registry, HTTP server provider, file streaming, comprehensive tunnel services (ngrok, serveo, localtunnel, localhost.run, pinggy), and comprehensive testing suite
285 lines (249 loc) • 7.76 kB
TypeScript
// Type definitions for local-remote-file-manager
// Project: local-remote-file-manager
// Definitions by: Auto-generated
import { EventEmitter } from 'events';
export interface LocalConfig {
basePath?: string;
enableBackup?: boolean;
backupPath?: string;
maxFileSize?: number;
allowedExtensions?: string[];
}
export interface WatchConfig {
debounceMs?: number;
maxWatchers?: number;
recursive?: boolean;
ignored?: string[];
followSymlinks?: boolean;
}
export interface CompressionConfig {
defaultFormat?: 'zip' | 'tar.gz';
defaultLevel?: number;
maxFileSize?: number;
tempDir?: string;
}
export interface TunnelConfig {
subdomain?: string;
region?: string;
timeout?: number;
}
export interface ServerConfig {
port?: number;
host?: string;
rootDirectory?: string;
enableRangeRequests?: boolean;
enableCompression?: boolean;
cors?: {
enabled: boolean;
origins?: string[];
};
}
export interface S3ServerConfig extends ServerConfig {
serverName?: string;
bucketMapping?: Map<string, string>;
bucketAccessControl?: Map<string, any>;
defaultBucketPermissions?: { read: boolean; write: boolean };
allowNewBuckets?: boolean;
maxPathDepth?: number;
authentication?: {
enabled: boolean;
tempCredentials?: boolean;
};
monitoring?: {
enabled: boolean;
dashboard?: boolean;
};
autoShutdown?: {
enabled: boolean;
timeout?: number;
};
}
export interface FileInfo {
path: string;
size: number;
modified: Date;
created: Date;
isDirectory: boolean;
isFile: boolean;
extension?: string;
mimeType?: string;
}
export interface ProgressData {
percent: number;
transferred: number;
total: number;
speed?: number;
eta?: number;
}
export interface FileEvent {
type: 'add' | 'change' | 'unlink' | 'addDir' | 'unlinkDir';
path: string;
relativePath?: string;
timestamp: number;
size?: number;
}
export interface CompressionResult {
success: boolean;
outputPath: string;
originalSize: number;
compressedSize: number;
compressionRatio: number;
format: string;
duration: number;
}
export interface DecompressionResult {
success: boolean;
outputDir: string;
extractedFiles: string[];
totalSize: number;
duration: number;
}
export class ConfigManager {
localConfig: LocalConfig;
watchConfig: WatchConfig;
compressionConfig: CompressionConfig;
tunnelConfig: TunnelConfig;
constructor();
load(): Promise<void>;
save(): Promise<void>;
getLocalConfig(): LocalConfig;
getWatchConfig(): WatchConfig;
getCompressionConfig(): CompressionConfig;
getTunnelConfig(): TunnelConfig;
}
export class LocalProvider {
constructor(config: LocalConfig);
list(dirPath: string): Promise<string[]>;
copy(sourcePath: string, destPath: string): Promise<void>;
move(sourcePath: string, destPath: string): Promise<void>;
remove(filePath: string): Promise<void>;
exists(filePath: string): Promise<boolean>;
getFileInfo(filePath: string): Promise<FileInfo>;
createDirectory(dirPath: string): Promise<void>;
}
export class WatchProvider extends EventEmitter {
constructor(config: WatchConfig);
startWatch(watchPath: string, options?: any): Promise<any>;
stopWatch(watchId: string): Promise<void>;
listActiveWatches(): any[];
getWatchStatus(watchId: string): any;
}
export class CompressionProvider extends EventEmitter {
constructor(config: CompressionConfig);
compress(sourcePath: string, outputPath: string, options?: any): Promise<CompressionResult>;
decompress(archivePath: string, outputDir: string, options?: any): Promise<DecompressionResult>;
getCompressionStatus(): any;
validateArchive(archivePath: string): Promise<boolean>;
}
export class TunnelProvider extends EventEmitter {
constructor(config: TunnelConfig);
createTunnel(options: { port: number; subdomain?: string }): Promise<string>;
closeTunnel(tunnelId: string): Promise<void>;
listActiveTunnels(): any[];
getTunnelStatus(tunnelId: string): any;
}
export class HttpServerProvider extends EventEmitter {
constructor(config: ServerConfig);
start(): Promise<void>;
stop(): Promise<void>;
isRunning(): boolean;
getServerInfo(): any;
}
export class LocalRemoteManager extends EventEmitter {
constructor(config: ConfigManager);
getProvider(providerName?: string): LocalProvider | WatchProvider | CompressionProvider | TunnelProvider;
getCompressionProvider(): CompressionProvider;
validateProvider(providerName: string): boolean;
// Event handlers
on(event: 'fileEvent', listener: (data: FileEvent) => void): this;
on(event: 'watcherError', listener: (data: any) => void): this;
on(event: string, listener: (...args: any[]) => void): this;
}
export class S3HttpServer extends EventEmitter {
constructor(config: S3ServerConfig);
start(): Promise<void>;
stop(): Promise<void>;
isRunning(): boolean;
getServerInfo(): any;
generateTempCredentials(): any;
// Event handlers
on(event: 'request', listener: (data: any) => void): this;
on(event: 'download', listener: (data: any) => void): this;
on(event: 'error', listener: (error: Error) => void): this;
on(event: string, listener: (...args: any[]) => void): this;
}
export class LocalRemoteCLI {
constructor();
initialize(): Promise<void>;
}
export class FileStreamingUtils {
static createReadStream(filePath: string, options?: any): NodeJS.ReadableStream;
static createWriteStream(filePath: string, options?: any): NodeJS.WritableStream;
static streamFile(sourcePath: string, destPath: string, options?: any): Promise<void>;
}
export class FileStreamer extends EventEmitter {
constructor(filePath: string, options?: any);
start(): Promise<void>;
stop(): void;
pause(): void;
resume(): void;
}
export class DownloadMonitor extends EventEmitter {
constructor();
trackDownload(downloadId: string, options?: any): void;
getDownloadStatus(downloadId: string): any;
getAllDownloads(): any[];
}
export class ShutdownManager extends EventEmitter {
constructor(options?: any);
scheduleShutdown(delay: number): void;
cancelShutdown(): void;
isShutdownScheduled(): boolean;
}
export class MonitoringDashboard extends EventEmitter {
constructor(options?: any);
start(): Promise<void>;
stop(): Promise<void>;
getStats(): any;
}
export class EventNotifier extends EventEmitter {
constructor(options?: any);
notify(event: string, data?: any): void;
subscribe(event: string, callback: Function): void;
unsubscribe(event: string, callback: Function): void;
}
// Factory functions
export interface ManagerOptions {
localConfig?: LocalConfig;
watchConfig?: WatchConfig;
compressionConfig?: CompressionConfig;
tunnelConfig?: TunnelConfig;
}
export function createManager(options?: ManagerOptions): Promise<LocalRemoteManager>;
export function createS3Server(config?: S3ServerConfig): S3HttpServer;
export function createHttpServer(config?: ServerConfig): HttpServerProvider;
// Convenience functions
export function compressFile(sourcePath: string, outputPath: string, options?: any): Promise<CompressionResult>;
export function decompressFile(archivePath: string, outputDir: string, options?: any): Promise<DecompressionResult>;
export function watchDirectory(watchPath: string, options?: any): Promise<any>;
// Default export
declare const _default: typeof LocalRemoteManager;
export default _default;
// Re-export everything for CommonJS compatibility
export {
LocalRemoteManager,
ConfigManager,
S3HttpServer,
LocalProvider,
WatchProvider,
CompressionProvider,
TunnelProvider,
HttpServerProvider,
FileStreamingUtils,
FileStreamer,
DownloadMonitor,
ShutdownManager,
MonitoringDashboard,
EventNotifier,
LocalRemoteCLI
};