forked from theophilusx/ssh2-sftp-client
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.d.ts
186 lines (141 loc) · 5.19 KB
/
index.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
import * as ssh2 from "ssh2";
export = sftp;
type FileInfoType = "d" | "-" | "l";
declare class sftp {
constructor(name?: string);
connect(options: sftp.ConnectOptions): Promise<ssh2.SFTPWrapper>;
list(remoteFilePath: string, filter?: sftp.ListFilterFunction): Promise<sftp.FileInfo[]>;
exists(remotePath: string): Promise<false | FileInfoType>;
stat(remotePath: string): Promise<sftp.FileStats>;
realPath(remotePath: string): Promise<string>;
get(
path: string,
dst?: string | NodeJS.WritableStream,
options?: sftp.TransferOptions,
): Promise<string | NodeJS.WritableStream | Buffer>;
fastGet(remoteFilePath: string, localPath: string, options?: sftp.FastGetTransferOptions): Promise<string>;
put(
input: string | Buffer | NodeJS.ReadableStream,
remoteFilePath: string,
options?: sftp.TransferOptions,
): Promise<string>;
fastPut(localPath: string, remoteFilePath: string, options?: sftp.FastPutTransferOptions): Promise<string>;
cwd(): Promise<string>;
mkdir(remoteFilePath: string, recursive?: boolean): Promise<string>;
rmdir(remoteFilePath: string, recursive?: boolean): Promise<string>;
delete(remoteFilePath: string, noErrorOK?: boolean): Promise<string>;
rename(remoteSourcePath: string, remoteDestPath: string): Promise<string>;
chmod(remotePath: string, mode: number | string): Promise<string>;
append(
input: Buffer | NodeJS.ReadableStream,
remotePath: string,
options?: sftp.WriteStreamOptions,
): Promise<string>;
uploadDir(srcDir: string, destDir: string, options?: sftp.UploadDirOptions): Promise<string>;
downloadDir(srcDir: string, destDir: string, options?: sftp.DownloadDirOptions): Promise<string>;
end(): Promise<void>;
on(event: string, callback: (...args: any[]) => void): void;
removeListener(event: string, callback: (...args: any[]) => void): void;
posixRename(fromPath: string, toPath: string): Promise<string>;
rcopy(srcPath: string, dstPath: string): Promise<string>;
createReadStream(remotePath: string, options?: ssh2.ReadStreamOptions): ssh2.ReadStream;
createWriteStream(remotePath: string, options?: ssh2.WriteStreamOptions): ssh2.WriteStream;
df(removePath: string): Promise<sftp.FilesystemStats>;
}
declare namespace sftp {
interface ConnectOptions extends ssh2.ConnectConfig {
retries?: number;
retry_factor?: number;
retry_minTimeout?: number;
}
interface ModeOption {
mode?: number | string;
}
interface PipeOptions {
/**
* @deprecated this option is ignored in v9.x. raw stream operations should use {@link createReadStream} or {@link createWriteStream} instead
*/
end?: boolean;
}
interface ReadStreamOptions extends ModeOption {
flags?: "r";
encoding?: null | string;
handle?: null | string;
/**
* @deprecated this option is ignored in v9.x. raw stream operations should use {@link createReadStream} instead
*/
autoClose?: boolean;
}
interface WriteStreamOptions extends ModeOption {
flags?: "w" | "a";
encoding?: null | string;
/**
* @deprecated this option is ignored in v9.x. raw stream operations should use {@link createWriteStream} instead
*/
autoClose?: boolean;
}
interface TransferOptions {
pipeOptions?: PipeOptions;
writeStreamOptions?: WriteStreamOptions;
readStreamOptions?: ReadStreamOptions;
}
interface FastGetTransferOptions {
concurrency?: number;
chunkSize?: number;
step?: (totalTransferred: number, chunk: number, total: number) => void;
}
interface FastPutTransferOptions extends FastGetTransferOptions, ModeOption {}
interface FileInfo {
type: FileInfoType;
name: string;
size: number;
modifyTime: number;
accessTime: number;
rights: {
user: string;
group: string;
other: string;
};
owner: number;
group: number;
}
interface FileStats {
mode: number;
uid: number;
gid: number;
size: number;
accessTime: number;
modifyTime: number;
isDirectory: boolean;
isFile: boolean;
isBlockDevice: boolean;
isCharacterDevice: boolean;
isSymbolicLink: boolean;
isFIFO: boolean;
isSocket: boolean;
}
type ListFilterFunction = (fileInfo: FileInfo) => boolean;
type DirFilterFunction = (filePath: string, isDirectory: boolean) => boolean;
interface DirOptions {
filter?: DirFilterFunction;
}
interface UploadDirOptions extends DirOptions {
useFastput?: boolean;
}
interface DownloadDirOptions extends DirOptions {
useFastget?: boolean;
}
interface FilesystemStats {
blockSize: number,
fragSize: number,
fsSize: number,
freeSize: number,
freeUserSize: number,
numFiles: number,
freeFiles: number,
freeUserFiles: number,
fsid: number,
flag: number,
maxNameLen: number,
}
}