hivessh
Version:
HiveSsh is an innovative library designed to streamline SSH2 connections and simplify task execution on Linux servers.
222 lines • 7.94 kB
TypeScript
import { FileEntryWithStats, InputAttributes, OpenMode, ReadFileOptions, SFTPWrapper, Stats, TransferOptions, WriteFileOptions } from "ssh2";
export interface FileStat {
path: string;
filename: string;
mode: number;
uid: number;
gid: number;
size: number;
atime: number;
mtime: number;
isDirectory: boolean;
isFile: boolean;
isBlockDevice: boolean;
isCharacterDevice: boolean;
isSymbolicLink: boolean;
isFIFO: boolean;
isSocket: boolean;
}
export declare function convertFileEntryState(path: string, stats: FileEntryWithStats): FileStat;
export interface SFTPPromiseInterface {
/**
* (Client-only)
* Downloads a file at `remotePath` to `localPath` using parallel reads for faster throughput.
*/
fastGet(remotePath: string, localPath: string, options?: TransferOptions): Promise<void>;
/**
* (Client-only)
* Uploads a file from `localPath` to `remotePath` using parallel reads for faster throughput.
*/
fastPut(localPath: string, remotePath: string, options?: TransferOptions): Promise<void>;
/**
* (Client-only)
* Reads a file in memory and returns its contents
*/
readFile<O extends ReadFileOptions | BufferEncoding>(remotePath: string, options?: O): Promise<O extends BufferEncoding ? string : O extends {
encodeing: BufferEncoding;
} ? string : Buffer>;
/**
* (Client-only)
* Writes data to a file
*/
writeFile<O extends WriteFileOptions | BufferEncoding>(remotePath: string, data: (O extends BufferEncoding ? string : O extends {
encodeing: BufferEncoding;
} ? string : Buffer), options?: WriteFileOptions | BufferEncoding): Promise<void>;
/**
* (Client-only)
* Appends data to a file
*/
appendFile<O extends WriteFileOptions | BufferEncoding>(remotePath: string, data: (O extends BufferEncoding ? string : O extends {
encodeing: BufferEncoding;
} ? string : Buffer), options?: WriteFileOptions): Promise<void>;
/**
* (Client-only)
* Opens a file `filename` for `mode` with optional `attributes`.
*/
open(filename: string, mode: number | OpenMode, attributes: InputAttributes | string | number): Promise<Buffer>;
/**
* (Client-only)
* Reads `length` bytes from the resource associated with `handle` starting at `position`
* and stores the bytes in `buffer` starting at `offset`.
*/
read(handle: Buffer, buffer: Buffer, offset: number, length: number, position: number): Promise<[number, Buffer, number]>;
/**
* (Client-only)
*/
write(handle: Buffer, buffer: Buffer, offset: number, length: number, position: number): Promise<void>;
/**
* (Client-only)
* Retrieves attributes for the resource associated with `handle`.
*/
fstat(handle: Buffer): Promise<Stats>;
/**
* (Client-only)
* Sets the attributes defined in `attributes` for the resource associated with `handle`.
*/
fsetstat(handle: Buffer, attributes: InputAttributes): Promise<void>;
/**
* (Client-only)
* Sets the access time and modified time for the resource associated with `handle`.
*/
futimes(handle: Buffer, atime: number | Date, mtime: number | Date): Promise<void>;
/**
* (Client-only)
* Sets the owner for the resource associated with `handle`.
*/
fchown(handle: Buffer, uid: number, gid: number): Promise<void>;
/**
* (Client-only)
* Sets the mode for the resource associated with `handle`.
*/
fchmod(handle: Buffer, mode: number | string): Promise<void>;
/**
* (Client-only)
* Opens a directory `path`.
*/
opendir(path: string): Promise<Buffer>;
/**
* (Client-only)
* Retrieves a directory listing.
*/
readdir(location: string | Buffer): Promise<FileStat[]>;
/**
* (Client-only)
* Removes the file/symlink at `path`.
*/
unlink(path: string): Promise<void>;
/**
* (Client-only)
* Renames/moves `srcPath` to `destPath`.
*/
rename(srcPath: string, destPath: string): Promise<void>;
/**
* (Client-only)
* Creates a new directory `path`.
*/
mkdir(path: string, attributes: InputAttributes): Promise<void>;
/**
* (Client-only)
* Creates a new directory `path`.
*/
mkdir(path: string): Promise<void>;
/**
* (Client-only)
* Removes the directory at `path`.
*/
rmdir(path: string): Promise<void>;
/**
* (Client-only)
* Retrieves attributes for `path`.
*/
stat(path: string): Promise<Stats>;
/**
* (Client-only)
* `path` exists.
*/
exists(path: string): Promise<boolean>;
/**
* (Client-only)
* Retrieves attributes for `path`. If `path` is a symlink, the link itself is stat'ed
* instead of the resource it refers to.
*/
lstat(path: string): Promise<Stats>;
/**
* (Client-only)
* Sets the attributes defined in `attributes` for `path`.
*/
setstat(path: string, attributes: InputAttributes): Promise<void>;
/**
* (Client-only)
* Sets the access time and modified time for `path`.
*/
utimes(path: string, atime: number | Date, mtime: number | Date): Promise<void>;
/**
* (Client-only)
* Sets the owner for `path`.
*/
chown(path: string, uid: number, gid: number): Promise<void>;
/**
* (Client-only)
* Sets the mode for `path`.
*/
chmod(path: string, mode: number | string): Promise<void>;
/**
* (Client-only)
* Retrieves the target for a symlink at `path`.
*/
readlink(path: string): Promise<string>;
/**
* (Client-only)
* Creates a symlink at `linkPath` to `targetPath`.
*/
symlink(targetPath: string, linkPath: string): Promise<void>;
/**
* (Client-only)
* Resolves `path` to an absolute path.
*/
realpath(path: string): Promise<string>;
/**
* (Client-only, OpenSSH extension)
* Performs POSIX rename(3) from `srcPath` to `destPath`.
*/
ext_openssh_rename(srcPath: string, destPath: string): Promise<void>;
/**
* (Client-only, OpenSSH extension)
* Performs POSIX statvfs(2) on `path`.
*/
ext_openssh_statvfs(path: string): Promise<any>;
/**
* (Client-only, OpenSSH extension)
* Performs POSIX fstatvfs(2) on open handle `handle`.
*/
ext_openssh_fstatvfs(handle: Buffer): Promise<any>;
/**
* (Client-only, OpenSSH extension)
* Performs POSIX link(2) to create a hard link to `targetPath` at `linkPath`.
*/
ext_openssh_hardlink(targetPath: string, linkPath: string): Promise<void>;
/**
* (Client-only, OpenSSH extension)
* Performs POSIX fsync(3) on the open handle `handle`.
*/
ext_openssh_fsync(handle: Buffer): Promise<any>;
/**
* (Client-only, OpenSSH extension)
* Similar to setstat(), but instead sets attributes on symlinks.
*/
ext_openssh_lsetstat(path: string, attrs: InputAttributes): Promise<void>;
ext_openssh_lsetstat(path: string): Promise<void>;
/**
* (Client-only, OpenSSH extension)
* Similar to realpath(), but supports tilde-expansion, i.e. "~", "~/..." and "~user/...". These paths are expanded using shell-like rules.
*/
ext_openssh_expandPath(path: string): Promise<string>;
/**
* (Client-only)
* Performs a remote file copy. If length is 0, then the server will read from srcHandle until EOF is reached.
*/
ext_copy_data(handle: Buffer, srcOffset: number, len: number, dstHandle: Buffer, dstOffset: number): Promise<void>;
}
export type SFTPPromiseWrapper = SFTPPromiseInterface & Omit<SFTPWrapper, keyof SFTPPromiseInterface>;
export declare function createSFTPPromiseWrapper(sourceWrapper: SFTPWrapper): SFTPPromiseWrapper;
//# sourceMappingURL=SftpPromiseWrapper.d.ts.map