core-3nweb-client-lib 0.24.1 → 0.24.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/api-defs/asmail.d.ts +292 -0
- package/build/api-defs/common-caps.d.ts +81 -0
- package/build/api-defs/files.d.ts +1037 -0
- package/build/api-defs/mailerid.d.ts +29 -0
- package/build/api-defs/startup.d.ts +121 -0
- package/build/api-defs/storage.d.ts +69 -0
- package/build/api-defs/web3n.d.ts +50 -0
- package/build/lib-index.d.ts +1 -0
- package/package.json +2 -2
|
@@ -0,0 +1,1037 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright (C) 2016 - 2018, 2020, 2022 3NSoft Inc.
|
|
3
|
+
|
|
4
|
+
This program is free software: you can redistribute it and/or modify it under
|
|
5
|
+
the terms of the GNU General Public License as published by the Free Software
|
|
6
|
+
Foundation, either version 3 of the License, or (at your option) any later
|
|
7
|
+
version.
|
|
8
|
+
|
|
9
|
+
This program is distributed in the hope that it will be useful, but
|
|
10
|
+
WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
11
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
12
|
+
See the GNU General Public License for more details.
|
|
13
|
+
|
|
14
|
+
You should have received a copy of the GNU General Public License along with
|
|
15
|
+
this program. If not, see <http://www.gnu.org/licenses/>.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
declare namespace web3n.files {
|
|
20
|
+
|
|
21
|
+
interface FileException extends RuntimeException {
|
|
22
|
+
type: 'file';
|
|
23
|
+
code: string|undefined;
|
|
24
|
+
path: string;
|
|
25
|
+
notFound?: true;
|
|
26
|
+
alreadyExists?: true;
|
|
27
|
+
notDirectory?: true;
|
|
28
|
+
notFile?: true;
|
|
29
|
+
notLink?: true;
|
|
30
|
+
isDirectory?: true;
|
|
31
|
+
notEmpty?: true;
|
|
32
|
+
endOfFile?: true;
|
|
33
|
+
opNotPermitted?: true;
|
|
34
|
+
busy?: true;
|
|
35
|
+
ioError?: true;
|
|
36
|
+
inconsistentStateOfFS?: true;
|
|
37
|
+
concurrentUpdate?: true;
|
|
38
|
+
parsingError?: true;
|
|
39
|
+
notImplemented?: true;
|
|
40
|
+
attrsNotEnabledInFS?: true;
|
|
41
|
+
versionMismatch?: true;
|
|
42
|
+
isEndless?: true;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
interface exceptionCode {
|
|
46
|
+
notFound: 'ENOENT';
|
|
47
|
+
alreadyExists: 'EEXIST';
|
|
48
|
+
notDirectory: 'ENOTDIR';
|
|
49
|
+
notFile: 'ENOTFILE';
|
|
50
|
+
notLink: 'not-link';
|
|
51
|
+
isDirectory: 'EISDIR';
|
|
52
|
+
notEmpty: 'ENOTEMPTY';
|
|
53
|
+
endOfFile: 'EEOF';
|
|
54
|
+
opNotPermitted: 'EPERM';
|
|
55
|
+
busy: 'EBUSY';
|
|
56
|
+
ioError: 'EIO';
|
|
57
|
+
concurrentUpdate: 'concurrent-update';
|
|
58
|
+
parsingError: 'parsing-error';
|
|
59
|
+
notImplemented: 'ENOSYS';
|
|
60
|
+
isEndless: 'is-endless';
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Instances of this interface are produced by folder listing method(s).
|
|
65
|
+
*/
|
|
66
|
+
interface ListingEntry {
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* This is name of an entity in its parent folder.
|
|
70
|
+
*/
|
|
71
|
+
name: string;
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* When present with true value, it indicates that an entity is a folder.
|
|
75
|
+
*/
|
|
76
|
+
isFolder?: boolean;
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* When present with true value, it indicates that an entity is a file.
|
|
80
|
+
*/
|
|
81
|
+
isFile?: boolean;
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* When present with true value, it indicates that an entity is a link.
|
|
85
|
+
*/
|
|
86
|
+
isLink?: boolean;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
interface Stats {
|
|
90
|
+
|
|
91
|
+
isFile?: boolean;
|
|
92
|
+
|
|
93
|
+
isFolder?: boolean;
|
|
94
|
+
|
|
95
|
+
isLink?: boolean;
|
|
96
|
+
|
|
97
|
+
writable: boolean;
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* File size in bytes.
|
|
101
|
+
*/
|
|
102
|
+
size?: number;
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* Flag indicating if file is an endless (unknown place of end) stream.
|
|
106
|
+
*/
|
|
107
|
+
isEndless?: boolean;
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* Last content modification time stamp.
|
|
111
|
+
* If such information cannot be provided, this field will be absent.
|
|
112
|
+
*/
|
|
113
|
+
mtime?: Date;
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* Last change of metadata time stamp.
|
|
117
|
+
* If such information cannot be provided, this field will be absent.
|
|
118
|
+
*/
|
|
119
|
+
ctime?: Date;
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* This tells object's version.
|
|
123
|
+
* If such information cannot be provided, this field will be absent.
|
|
124
|
+
*/
|
|
125
|
+
version?: number;
|
|
126
|
+
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
interface FileByteSource {
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* This reads file bytes from a current position. Read advances current
|
|
133
|
+
* position. Seek method sets position to a particular value. Initial
|
|
134
|
+
* value of current read position is zero.
|
|
135
|
+
* Returned promise resolves to either read bytes, or undefined.
|
|
136
|
+
* If byte array has same length as given read limit, there may be more
|
|
137
|
+
* bytes to read. Otherwise, all bytes are read to the end of file.
|
|
138
|
+
* Undefined is returned when there are no bytes to read, starting from
|
|
139
|
+
* the current read position.
|
|
140
|
+
* @param len maximum number of bytes to read from file. If undefine is
|
|
141
|
+
* given, all bytes are read from current postion to the end of file.
|
|
142
|
+
*/
|
|
143
|
+
read(len: number|undefined): Promise<Uint8Array|undefined>;
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* This returns a promise, resolvable to the size of this file.
|
|
147
|
+
*/
|
|
148
|
+
getSize(): Promise<number>;
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* This sets read position to a given value.
|
|
152
|
+
* @param offset is new read position
|
|
153
|
+
*/
|
|
154
|
+
seek(offset: number): Promise<void>;
|
|
155
|
+
|
|
156
|
+
/**
|
|
157
|
+
* This returns a promise, resolvable to current read position.
|
|
158
|
+
*/
|
|
159
|
+
getPosition(): Promise<number>;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
interface LayoutSection {
|
|
163
|
+
src: 'new' | 'base' | 'empty';
|
|
164
|
+
ofs: number;
|
|
165
|
+
len: number;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
interface FileLayout {
|
|
169
|
+
base?: number;
|
|
170
|
+
sections: LayoutSection[];
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
interface FileByteSink {
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
* This returns a promise, resolvable to current size. This size changes
|
|
177
|
+
* when sink is splice and truncated.
|
|
178
|
+
*/
|
|
179
|
+
getSize(): Promise<number>;
|
|
180
|
+
|
|
181
|
+
/**
|
|
182
|
+
* This splices file. It removes bytes, and inserts new ones. Note that
|
|
183
|
+
* it is an insertion of bytes, and not over-writing.
|
|
184
|
+
* @param pos in file at which deletion should occur, followed by
|
|
185
|
+
* insertion of given bytes, if any given. If position is greater than
|
|
186
|
+
* current size, empty section will be inserted up to it.
|
|
187
|
+
* @param del number of bytes to cut at given position.
|
|
188
|
+
* @param bytes when given, these bytes are inserted into file at given
|
|
189
|
+
* position, after deletion.
|
|
190
|
+
*/
|
|
191
|
+
splice(pos: number, del: number, bytes?: Uint8Array): Promise<void>;
|
|
192
|
+
|
|
193
|
+
/**
|
|
194
|
+
* This truncates file to a given size. If size is reduced, bytes are cut.
|
|
195
|
+
* If size grows, empty section is added up to new end of file.
|
|
196
|
+
* @param size
|
|
197
|
+
*/
|
|
198
|
+
truncate(size: number): Promise<void>;
|
|
199
|
+
|
|
200
|
+
/**
|
|
201
|
+
* This returns a promise, resolvable to current file layout. Returned
|
|
202
|
+
* layout is not a shared object, and any new changes will be reflected
|
|
203
|
+
* in layouts from following calls of this method.
|
|
204
|
+
*/
|
|
205
|
+
showLayout(): Promise<FileLayout>;
|
|
206
|
+
|
|
207
|
+
/**
|
|
208
|
+
* This completes sink. Completion with error cancels file writing.
|
|
209
|
+
* Regular completion may get an error thrown back, while canceling will
|
|
210
|
+
* not.
|
|
211
|
+
* @param err an optional error, presence of which indicates closing of
|
|
212
|
+
* sink with this error. When err is given, no errors will be thrown back
|
|
213
|
+
* to this call.
|
|
214
|
+
*/
|
|
215
|
+
done(err?: any): Promise<void>;
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
type Linkable = File | FS;
|
|
219
|
+
|
|
220
|
+
/**
|
|
221
|
+
* This is an interface for a symbolic link.
|
|
222
|
+
* In unix file systems there are both symbolic and hard links. We do not
|
|
223
|
+
* have hard links here, but we need to highlight that nature of links here
|
|
224
|
+
* is symbolic. For example, when a target is deleted, symbolic link becomes
|
|
225
|
+
* broken.
|
|
226
|
+
*/
|
|
227
|
+
interface SymLink {
|
|
228
|
+
|
|
229
|
+
/**
|
|
230
|
+
* Flag that indicates if access to link's target is readonly (true), or
|
|
231
|
+
* can be writable (false value).
|
|
232
|
+
*/
|
|
233
|
+
readonly: boolean;
|
|
234
|
+
|
|
235
|
+
/**
|
|
236
|
+
* Indicates with true value if target is a file
|
|
237
|
+
*/
|
|
238
|
+
isFile?: boolean;
|
|
239
|
+
|
|
240
|
+
/**
|
|
241
|
+
* Indicates with true value if target is a folder
|
|
242
|
+
*/
|
|
243
|
+
isFolder?: boolean;
|
|
244
|
+
|
|
245
|
+
target(): Promise<Linkable>;
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
type File = ReadonlyFile | WritableFile;
|
|
249
|
+
|
|
250
|
+
interface ReadonlyFile {
|
|
251
|
+
|
|
252
|
+
writable: boolean;
|
|
253
|
+
|
|
254
|
+
v?: ReadonlyFileVersionedAPI;
|
|
255
|
+
|
|
256
|
+
/**
|
|
257
|
+
* Is a file name, given by the outside to this file. It may, or may not,
|
|
258
|
+
* be the same as an actual file name in the file system. It may also be
|
|
259
|
+
* null.
|
|
260
|
+
*/
|
|
261
|
+
name: string;
|
|
262
|
+
|
|
263
|
+
/**
|
|
264
|
+
* Is a flag that says, whether file existed at the moment of this
|
|
265
|
+
* object's creation.
|
|
266
|
+
*/
|
|
267
|
+
isNew: boolean;
|
|
268
|
+
|
|
269
|
+
/**
|
|
270
|
+
* This returns a promise, resolvable to file stats.
|
|
271
|
+
*/
|
|
272
|
+
stat(): Promise<Stats>;
|
|
273
|
+
|
|
274
|
+
/**
|
|
275
|
+
* This returns an extended attribute value. Undefined is returned when
|
|
276
|
+
* attribute is not known.
|
|
277
|
+
* @param xaName
|
|
278
|
+
*/
|
|
279
|
+
getXAttr(xaName: string): Promise<any>;
|
|
280
|
+
|
|
281
|
+
/**
|
|
282
|
+
* This returns an array of set extended attributes.
|
|
283
|
+
*/
|
|
284
|
+
listXAttrs(): Promise<string[]>;
|
|
285
|
+
|
|
286
|
+
/**
|
|
287
|
+
* This returns a promise, resolvable to either non-empty byte array, or
|
|
288
|
+
* undefined.
|
|
289
|
+
* @param start optional parameter, setting a beginning of read. If
|
|
290
|
+
* missing, read will be done as if neither start, nor end parameters
|
|
291
|
+
* are given.
|
|
292
|
+
* @param end optional parameter, setting an end of read. If end is
|
|
293
|
+
* greater than file length, all available bytes are read. If parameter
|
|
294
|
+
* is missing, read will be done to file's end.
|
|
295
|
+
*/
|
|
296
|
+
readBytes(start?: number, end?: number): Promise<Uint8Array|undefined>;
|
|
297
|
+
|
|
298
|
+
/**
|
|
299
|
+
* This returns a promise, resolvable to text, read from file, assuming
|
|
300
|
+
* utf8 encoding.
|
|
301
|
+
*/
|
|
302
|
+
readTxt(): Promise<string>;
|
|
303
|
+
|
|
304
|
+
/**
|
|
305
|
+
* This returns a promise, resolvable to json, read from file
|
|
306
|
+
*/
|
|
307
|
+
readJSON<T>(): Promise<T>;
|
|
308
|
+
|
|
309
|
+
/**
|
|
310
|
+
* This returns a promise, resolvable to bytes source with seek, which
|
|
311
|
+
* allows random reads.
|
|
312
|
+
*/
|
|
313
|
+
getByteSource(): Promise<FileByteSource>;
|
|
314
|
+
|
|
315
|
+
watch(observer: Observer<FileEvent>): () => void;
|
|
316
|
+
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
interface WritableFile extends ReadonlyFile {
|
|
320
|
+
|
|
321
|
+
v?: WritableFileVersionedAPI;
|
|
322
|
+
|
|
323
|
+
/**
|
|
324
|
+
* This updates extended attributes.
|
|
325
|
+
* @param changes is an object with changes to attributes. Note these are
|
|
326
|
+
* explicit changes of extended attributes, not an implicit replacement.
|
|
327
|
+
*/
|
|
328
|
+
updateXAttrs(changes: XAttrsChanges): Promise<void>;
|
|
329
|
+
|
|
330
|
+
/**
|
|
331
|
+
* This returns a promise, resolvable when file is written
|
|
332
|
+
* @param bytes is a complete file content to write
|
|
333
|
+
*/
|
|
334
|
+
writeBytes(bytes: Uint8Array): Promise<void>;
|
|
335
|
+
|
|
336
|
+
/**
|
|
337
|
+
* This returns a promise, resolvable when file is written
|
|
338
|
+
* @param txt to write to file, using utf8 encoding
|
|
339
|
+
*/
|
|
340
|
+
writeTxt(txt: string): Promise<void>;
|
|
341
|
+
|
|
342
|
+
/**
|
|
343
|
+
* This returns a promise, resolvable when file is written
|
|
344
|
+
* @param json
|
|
345
|
+
*/
|
|
346
|
+
writeJSON(json: any): Promise<void>;
|
|
347
|
+
|
|
348
|
+
/**
|
|
349
|
+
* This returns a promise, resolvable to byte sink with seek
|
|
350
|
+
* @param truncateFile is an optional flag that truncates file content
|
|
351
|
+
* before any bytes are writen to produced sink. When flag is false,
|
|
352
|
+
* produced sink updates existing bytes. Default value is true.
|
|
353
|
+
*/
|
|
354
|
+
getByteSink(truncateFile?: boolean): Promise<FileByteSink>;
|
|
355
|
+
|
|
356
|
+
/**
|
|
357
|
+
* This returns a promise, resolvable when copying is done.
|
|
358
|
+
* @param file which content will be copied into this file
|
|
359
|
+
*/
|
|
360
|
+
copy(file: File): Promise<void>;
|
|
361
|
+
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
interface XAttrsChanges {
|
|
365
|
+
set?: { [xaName: string]: any|undefined; };
|
|
366
|
+
remove?: string[];
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
interface ReadonlyFileVersionedAPI {
|
|
370
|
+
|
|
371
|
+
getXAttr(xaName: string): Promise<{ attr: any; version: number; }>;
|
|
372
|
+
|
|
373
|
+
listXAttrs(): Promise<{ lst: string[]; version: number; }>;
|
|
374
|
+
|
|
375
|
+
/**
|
|
376
|
+
* This returns a promise, resolvable to either non-empty byte array, or
|
|
377
|
+
* undefined.
|
|
378
|
+
* @param start optional parameter, setting a beginning of read. If
|
|
379
|
+
* missing, read will be done as if neither start, nor end parameters
|
|
380
|
+
* are given.
|
|
381
|
+
* @param end optional parameter, setting an end of read. If end is
|
|
382
|
+
* greater than file length, all available bytes are read. If parameter
|
|
383
|
+
* is missing, read will be done to file's end.
|
|
384
|
+
*/
|
|
385
|
+
readBytes(start?: number, end?: number):
|
|
386
|
+
Promise<{ bytes: Uint8Array|undefined; version: number; }>;
|
|
387
|
+
|
|
388
|
+
/**
|
|
389
|
+
* This returns a promise, resolvable to text, read from file, assuming
|
|
390
|
+
* utf8 encoding.
|
|
391
|
+
*/
|
|
392
|
+
readTxt(): Promise<{ txt: string; version: number; }>;
|
|
393
|
+
|
|
394
|
+
/**
|
|
395
|
+
* This returns a promise, resolvable to json, read from file
|
|
396
|
+
*/
|
|
397
|
+
readJSON<T>(): Promise<{ json: T; version: number; }>;
|
|
398
|
+
|
|
399
|
+
/**
|
|
400
|
+
* This returns a promise, resolvable to bytes source with seek, which
|
|
401
|
+
* allows random reads, and a file version
|
|
402
|
+
*/
|
|
403
|
+
getByteSource(): Promise<{ src: FileByteSource; version: number; }>;
|
|
404
|
+
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
interface WritableFileVersionedAPI extends ReadonlyFileVersionedAPI {
|
|
408
|
+
|
|
409
|
+
/**
|
|
410
|
+
* This updates extended attributes.
|
|
411
|
+
* @param changes is an object with changes to attributes. Note these are
|
|
412
|
+
* explicit changes of extended attributes, not an implicit replacement.
|
|
413
|
+
*/
|
|
414
|
+
updateXAttrs(changes: XAttrsChanges): Promise<number>;
|
|
415
|
+
|
|
416
|
+
/**
|
|
417
|
+
* This returns a promise, resolvable to new file's version when file is
|
|
418
|
+
* written
|
|
419
|
+
* @param bytes is a complete file content to write
|
|
420
|
+
*/
|
|
421
|
+
writeBytes(bytes: Uint8Array): Promise<number>;
|
|
422
|
+
|
|
423
|
+
/**
|
|
424
|
+
* This returns a promise, resolvable to new file's version when file is
|
|
425
|
+
* written
|
|
426
|
+
* @param txt to write to file, using utf8 encoding
|
|
427
|
+
*/
|
|
428
|
+
writeTxt(txt: string): Promise<number>;
|
|
429
|
+
|
|
430
|
+
/**
|
|
431
|
+
* This returns a promise, resolvable to new file's version when file is
|
|
432
|
+
* written
|
|
433
|
+
* @param json
|
|
434
|
+
*/
|
|
435
|
+
writeJSON(json: any): Promise<number>;
|
|
436
|
+
|
|
437
|
+
/**
|
|
438
|
+
* This returns a promise, resolvable to byte sink with seek, and a file
|
|
439
|
+
* version
|
|
440
|
+
* @param truncateFile is an optional flag that truncates file content
|
|
441
|
+
* before any bytes are writen to produced sink. When flag is false,
|
|
442
|
+
* produced sink updates existing bytes. Default value is true.
|
|
443
|
+
* @param currentVersion is an optional parameter, for non-truncated sink.
|
|
444
|
+
* When current version is given, an error is thrown, if file version at
|
|
445
|
+
* the moment of writing is different.
|
|
446
|
+
*/
|
|
447
|
+
getByteSink(truncateFile?: boolean, currentVersion?: number):
|
|
448
|
+
Promise<{ sink: FileByteSink; version: number; }>;
|
|
449
|
+
|
|
450
|
+
/**
|
|
451
|
+
* This returns a promise, resolvable to new file's version when copying
|
|
452
|
+
* is done.
|
|
453
|
+
* @param file which content will be copied into this file
|
|
454
|
+
*/
|
|
455
|
+
copy(file: File): Promise<number>;
|
|
456
|
+
|
|
457
|
+
}
|
|
458
|
+
|
|
459
|
+
type FSType = 'device' | 'synced' | 'local' | 'share' | 'asmail-msg';
|
|
460
|
+
|
|
461
|
+
type FS = ReadonlyFS | WritableFS;
|
|
462
|
+
|
|
463
|
+
interface ReadonlyFS {
|
|
464
|
+
|
|
465
|
+
type: FSType;
|
|
466
|
+
|
|
467
|
+
v?: ReadonlyFSVersionedAPI;
|
|
468
|
+
|
|
469
|
+
writable: boolean;
|
|
470
|
+
|
|
471
|
+
/**
|
|
472
|
+
* Is a folder name, given by the outside to this file system. It may, or
|
|
473
|
+
* may not, be the same as an actual folder name. It may also be null.
|
|
474
|
+
*/
|
|
475
|
+
name: string;
|
|
476
|
+
|
|
477
|
+
/**
|
|
478
|
+
* This returns a promise, resolvable to true, if folder exists, and to
|
|
479
|
+
* false, if folder is not found.
|
|
480
|
+
* @param path of a folder, which presence we want to check
|
|
481
|
+
* @param throwIfMissing is an optional flag, which forces with true value
|
|
482
|
+
* throwing of an exception, when folder does not exist. Default value is
|
|
483
|
+
* false.
|
|
484
|
+
*/
|
|
485
|
+
checkFolderPresence(path: string, throwIfMissing?: boolean):
|
|
486
|
+
Promise<boolean>;
|
|
487
|
+
|
|
488
|
+
/**
|
|
489
|
+
* This returns a promise, resolvable to true, if file exists, and to
|
|
490
|
+
* false, if file is not found.
|
|
491
|
+
* @param path of a file, which presence we want to check
|
|
492
|
+
* @param throwIfMissing is an optional flag, which forces with true value
|
|
493
|
+
* throwing of an exception, when file does not exist. Default value is
|
|
494
|
+
* false.
|
|
495
|
+
*/
|
|
496
|
+
checkFilePresence(path: string, throwIfMissing?: boolean):
|
|
497
|
+
Promise<boolean>;
|
|
498
|
+
|
|
499
|
+
/**
|
|
500
|
+
* This returns a promise, resolvable to true, if link exists, and to
|
|
501
|
+
* false, if link is not found.
|
|
502
|
+
* @param path of a link, which presence we want to check
|
|
503
|
+
* @param throwIfMissing is an optional flag, which forces with true value
|
|
504
|
+
* throwing of an exception, when link does not exist. Default value is
|
|
505
|
+
* false.
|
|
506
|
+
*/
|
|
507
|
+
checkLinkPresence(path: string, throwIfMissing?: boolean):
|
|
508
|
+
Promise<boolean>;
|
|
509
|
+
|
|
510
|
+
/**
|
|
511
|
+
* This returns a promise, resolvable to stats of an entity at a given
|
|
512
|
+
* path.
|
|
513
|
+
* @param path
|
|
514
|
+
*/
|
|
515
|
+
stat(path: string): Promise<Stats>;
|
|
516
|
+
|
|
517
|
+
/**
|
|
518
|
+
* This returns an extended attribute value. Undefined is returned when
|
|
519
|
+
* attribute is not known.
|
|
520
|
+
* @param path
|
|
521
|
+
* @param xaName
|
|
522
|
+
*/
|
|
523
|
+
getXAttr(path: string, xaName: string): Promise<any>;
|
|
524
|
+
|
|
525
|
+
/**
|
|
526
|
+
* This returns an array of set extended attributes.
|
|
527
|
+
* @param path
|
|
528
|
+
*/
|
|
529
|
+
listXAttrs(path: string): Promise<string[]>;
|
|
530
|
+
|
|
531
|
+
readLink(path: string): Promise<SymLink>;
|
|
532
|
+
|
|
533
|
+
watchFolder(path: string, observer: Observer<FolderEvent>): () => void;
|
|
534
|
+
|
|
535
|
+
watchFile(path: string, observer: Observer<FileEvent>): () => void;
|
|
536
|
+
|
|
537
|
+
watchTree(path: string, observer: Observer<FolderEvent|FileEvent>):
|
|
538
|
+
() => void;
|
|
539
|
+
|
|
540
|
+
close(): Promise<void>;
|
|
541
|
+
|
|
542
|
+
/**
|
|
543
|
+
* This returns a promise, resolvable to a file system object, rooted to a
|
|
544
|
+
* given folder.
|
|
545
|
+
* @param folder is a path of a root folder.
|
|
546
|
+
*/
|
|
547
|
+
readonlySubRoot(folder: string): Promise<ReadonlyFS>;
|
|
548
|
+
|
|
549
|
+
/**
|
|
550
|
+
* This returns a promise, resolvable to a list of informational objects
|
|
551
|
+
* for entries in the folder.
|
|
552
|
+
* @param path of a folder that should be listed
|
|
553
|
+
*/
|
|
554
|
+
listFolder(folder: string): Promise<ListingEntry[]>;
|
|
555
|
+
|
|
556
|
+
/**
|
|
557
|
+
* This returns a promise, resolvable to json, read from file
|
|
558
|
+
* @param path of a file from which to read json
|
|
559
|
+
*/
|
|
560
|
+
readJSONFile<T>(path: string): Promise<T>;
|
|
561
|
+
|
|
562
|
+
/**
|
|
563
|
+
* This returns a promise, resolvable to text, read from file, assuming
|
|
564
|
+
* utf8 encoding.
|
|
565
|
+
* @param path of a file from which to read text
|
|
566
|
+
*/
|
|
567
|
+
readTxtFile(path: string): Promise<string>;
|
|
568
|
+
|
|
569
|
+
/**
|
|
570
|
+
* This returns a promise, resolvable to either non-empty byte array, or
|
|
571
|
+
* undefined.
|
|
572
|
+
* @param path of a file from which to read bytes
|
|
573
|
+
* @param start optional parameter, setting a beginning of read. If
|
|
574
|
+
* missing, read will be done as if neither start, nor end parameters
|
|
575
|
+
* are given.
|
|
576
|
+
* @param end optional parameter, setting an end of read. If end is
|
|
577
|
+
* greater than file length, all available bytes are read. If parameter
|
|
578
|
+
* is missing, read will be done to file's end.
|
|
579
|
+
*/
|
|
580
|
+
readBytes(path: string, start?: number, end?: number):
|
|
581
|
+
Promise<Uint8Array|undefined>;
|
|
582
|
+
|
|
583
|
+
/**
|
|
584
|
+
* This returns a promise, resolvable to bytes source with seek, which
|
|
585
|
+
* allows random reads.
|
|
586
|
+
* @param path of a file from which to read bytes
|
|
587
|
+
*/
|
|
588
|
+
getByteSource(path: string): Promise<FileByteSource>;
|
|
589
|
+
|
|
590
|
+
/**
|
|
591
|
+
* This returns a promise, resolvable to readonly file object.
|
|
592
|
+
* @param path
|
|
593
|
+
*/
|
|
594
|
+
readonlyFile(path: string): Promise<ReadonlyFile>;
|
|
595
|
+
|
|
596
|
+
/**
|
|
597
|
+
* This function selects items inside given path, following given
|
|
598
|
+
* criteria. It start selection process, which may be long, and returns a
|
|
599
|
+
* promise, resolvable to items collection into selected items will
|
|
600
|
+
* eventually be placed, and a completion promise, that resolves when
|
|
601
|
+
* selection/search process completes.
|
|
602
|
+
* Note that collection can be watched for changes as they happen.
|
|
603
|
+
* @param path
|
|
604
|
+
* @param criteria
|
|
605
|
+
*/
|
|
606
|
+
select(path: string, criteria: SelectCriteria):
|
|
607
|
+
Promise<{ items: FSCollection; completion: Promise<void>; }>;
|
|
608
|
+
|
|
609
|
+
}
|
|
610
|
+
|
|
611
|
+
interface SelectCriteria {
|
|
612
|
+
|
|
613
|
+
/**
|
|
614
|
+
* This is a match for name. There are three match types:
|
|
615
|
+
* pattern, regexp and exact.
|
|
616
|
+
* 1) Pattern is a common cli search like "*.png" that treats *-symbol as
|
|
617
|
+
* standing for anything. Search isn't case-sensitive.
|
|
618
|
+
* When name field is a string, it is assumed to be this pattern type.
|
|
619
|
+
* 2) Regexp is used directly to make a match.
|
|
620
|
+
* 3) Exact matches given string exactly to names of fs items.
|
|
621
|
+
*/
|
|
622
|
+
name: string | {
|
|
623
|
+
p: string;
|
|
624
|
+
type: 'pattern' | 'regexp' | 'exact';
|
|
625
|
+
};
|
|
626
|
+
|
|
627
|
+
/**
|
|
628
|
+
* depth number, if present, limits search to folder depth in a file tree.
|
|
629
|
+
*/
|
|
630
|
+
depth?: number;
|
|
631
|
+
|
|
632
|
+
/**
|
|
633
|
+
* type identifies type or types of elements this criteria should match.
|
|
634
|
+
* If missing, all fs types are considered for further matching.
|
|
635
|
+
*/
|
|
636
|
+
type?: FSItemType | FSItemType[];
|
|
637
|
+
|
|
638
|
+
/**
|
|
639
|
+
* action specifies what happens with items that match given criteria:
|
|
640
|
+
* include or exclude from search results. Selection with include action
|
|
641
|
+
* returns only items that match criteria. Selection with exclude action
|
|
642
|
+
* returns all items that don't match criteria.
|
|
643
|
+
*/
|
|
644
|
+
action: 'include' | 'exclude';
|
|
645
|
+
}
|
|
646
|
+
|
|
647
|
+
type FSItemType = 'folder' | 'file' | 'link';
|
|
648
|
+
|
|
649
|
+
interface FSItem {
|
|
650
|
+
isFile?: boolean;
|
|
651
|
+
isFolder?: boolean;
|
|
652
|
+
isLink?: boolean;
|
|
653
|
+
isCollection?: boolean;
|
|
654
|
+
item?: FS|File|FSCollection;
|
|
655
|
+
location?: {
|
|
656
|
+
fs: FS;
|
|
657
|
+
path: string;
|
|
658
|
+
storageUse?: storage.StorageUse;
|
|
659
|
+
storageType?: storage.StorageType;
|
|
660
|
+
};
|
|
661
|
+
}
|
|
662
|
+
|
|
663
|
+
interface FSCollection {
|
|
664
|
+
get(name: string): Promise<FSItem|undefined>;
|
|
665
|
+
getAll(): Promise<[ string, FSItem ][]>;
|
|
666
|
+
entries(): Promise<AsyncIterator<[ string, FSItem ]>>;
|
|
667
|
+
watch(observer: Observer<CollectionEvent>): () => void;
|
|
668
|
+
set?: (name: string, f: FSItem) => Promise<void>;
|
|
669
|
+
remove?: (name: string) => Promise<boolean>;
|
|
670
|
+
clear?: () => Promise<void>;
|
|
671
|
+
}
|
|
672
|
+
|
|
673
|
+
interface CollectionItemRemovalEvent {
|
|
674
|
+
type: 'entry-removal';
|
|
675
|
+
path?: string;
|
|
676
|
+
}
|
|
677
|
+
|
|
678
|
+
interface CollectionItemAdditionEvent {
|
|
679
|
+
type: 'entry-addition';
|
|
680
|
+
path: string;
|
|
681
|
+
item: FSItem;
|
|
682
|
+
}
|
|
683
|
+
|
|
684
|
+
type CollectionEvent = CollectionItemAdditionEvent |
|
|
685
|
+
CollectionItemRemovalEvent;
|
|
686
|
+
|
|
687
|
+
interface WritableFS extends ReadonlyFS {
|
|
688
|
+
|
|
689
|
+
v?: WritableFSVersionedAPI;
|
|
690
|
+
|
|
691
|
+
/**
|
|
692
|
+
* This updates extended attributes.
|
|
693
|
+
* @param path
|
|
694
|
+
* @param changes is an object with changes to attributes. Note these are
|
|
695
|
+
* explicit changes of extended attributes, not an implicit replacement.
|
|
696
|
+
*/
|
|
697
|
+
updateXAttrs(path: string, changes: XAttrsChanges): Promise<void>;
|
|
698
|
+
|
|
699
|
+
/**
|
|
700
|
+
* This either finds existing, or creates new folder, asynchronously.
|
|
701
|
+
* @param path of a folder that should be created
|
|
702
|
+
* @param exclusive is an optional flag, which when set to true, throws
|
|
703
|
+
* if folder already exists. Default value is false, i.e. if folder
|
|
704
|
+
* exists, nothing happens.
|
|
705
|
+
*/
|
|
706
|
+
makeFolder(path: string, exclusive?: boolean): Promise<void>;
|
|
707
|
+
|
|
708
|
+
/**
|
|
709
|
+
* This returns a promise, resolvable when folder has been removed
|
|
710
|
+
* @param path of a folder that should be removed
|
|
711
|
+
* @param removeContent is an optional flag, which true values forces
|
|
712
|
+
* recursive removal of all content in the folder. Default value is false.
|
|
713
|
+
* If folder is not empty, and content removal flag is not set, then an
|
|
714
|
+
* error is thrown.
|
|
715
|
+
*/
|
|
716
|
+
deleteFolder(path: string, removeContent?: boolean): Promise<void>;
|
|
717
|
+
|
|
718
|
+
/**
|
|
719
|
+
* This returns a promise, resolvable when file has been removed
|
|
720
|
+
* @param path of a file that should be removed
|
|
721
|
+
*/
|
|
722
|
+
deleteFile(path: string): Promise<void>;
|
|
723
|
+
|
|
724
|
+
/**
|
|
725
|
+
* This returns a promise, resolvable when file (or folder) has been
|
|
726
|
+
* moved.
|
|
727
|
+
* @param src is an initial path of a file (or folder)
|
|
728
|
+
* @param dst is a new path of a file (or folder)
|
|
729
|
+
*/
|
|
730
|
+
move(src: string, dst: string): Promise<void>;
|
|
731
|
+
|
|
732
|
+
/**
|
|
733
|
+
* This returns a promise, resolvable when file has been copied.
|
|
734
|
+
* @param src is an initial path of a file
|
|
735
|
+
* @param dst is a path of a file
|
|
736
|
+
* @param overwrite is a flag that with a true value allows
|
|
737
|
+
* overwrite of existing dst file. Default value is false.
|
|
738
|
+
*/
|
|
739
|
+
copyFile(src: string, dst: string, overwrite?: boolean):
|
|
740
|
+
Promise<void>;
|
|
741
|
+
|
|
742
|
+
/**
|
|
743
|
+
* This returns a promise, resolvable when folder has been recursively
|
|
744
|
+
* copied.
|
|
745
|
+
* @param src is an initial path of a folder
|
|
746
|
+
* @param dst is a path of a folder
|
|
747
|
+
* @param mergeAndOverwrite is a flag that with true value allows
|
|
748
|
+
* merge into existing folder and files overwriting inside. Default
|
|
749
|
+
* value is false.
|
|
750
|
+
*/
|
|
751
|
+
copyFolder(src: string, dst: string, mergeAndOverwrite?: boolean):
|
|
752
|
+
Promise<void>;
|
|
753
|
+
|
|
754
|
+
/**
|
|
755
|
+
* This returns a promise, resolvable when file has been saved.
|
|
756
|
+
* @param file is a file to save
|
|
757
|
+
* @param dst is a path where to save given file
|
|
758
|
+
* @param overwrite is a flag that with a true value allows
|
|
759
|
+
* overwrite of existing dst file. Default value is false.
|
|
760
|
+
*/
|
|
761
|
+
saveFile(file: File, dst: string, overwrite?: boolean): Promise<void>;
|
|
762
|
+
|
|
763
|
+
/**
|
|
764
|
+
* This returns a promise, resolvable when folder has been recursively
|
|
765
|
+
* saved.
|
|
766
|
+
* @param folder is a folder to save
|
|
767
|
+
* @param dst is a path where to save given folder
|
|
768
|
+
* @param mergeAndOverwrite is a flag that with true value allows
|
|
769
|
+
* merge into existing folder and files overwriting inside. Default
|
|
770
|
+
* value is false.
|
|
771
|
+
*/
|
|
772
|
+
saveFolder(folder: FS, dst: string, mergeAndOverwrite?: boolean):
|
|
773
|
+
Promise<void>;
|
|
774
|
+
|
|
775
|
+
/**
|
|
776
|
+
* This returns a promise, resolvable when file has been removed
|
|
777
|
+
* @param path of a link that should be removed
|
|
778
|
+
*/
|
|
779
|
+
deleteLink(path: string): Promise<void>;
|
|
780
|
+
|
|
781
|
+
link(path: string, target: File | FS): Promise<void>;
|
|
782
|
+
|
|
783
|
+
/**
|
|
784
|
+
* This returns a promise, resolvable to a file system object, rooted to a
|
|
785
|
+
* given folder.
|
|
786
|
+
* @param folder is a path of a root folder.
|
|
787
|
+
* @param flags are optional flags. Default flags are create=true,
|
|
788
|
+
* exclusive=false.
|
|
789
|
+
*/
|
|
790
|
+
writableSubRoot(folder: string, flags?: FileFlags): Promise<WritableFS>;
|
|
791
|
+
|
|
792
|
+
/**
|
|
793
|
+
* This returns a promise, resolvable when file is written
|
|
794
|
+
* @param path of a file to write given json
|
|
795
|
+
* @param json
|
|
796
|
+
* @param flags are optional flags. Default flags are create=true,
|
|
797
|
+
* exclusive=false.
|
|
798
|
+
*/
|
|
799
|
+
writeJSONFile(path: string, json: any, flags?: FileFlags): Promise<void>;
|
|
800
|
+
|
|
801
|
+
/**
|
|
802
|
+
* This returns a promise, resolvable when file is written
|
|
803
|
+
* @param path of a file to write given text
|
|
804
|
+
* @param txt to write to file, using utf8 encoding
|
|
805
|
+
* @param flags are optional flags. Default flags are create=true,
|
|
806
|
+
* exclusive=false.
|
|
807
|
+
*/
|
|
808
|
+
writeTxtFile(path: string, txt: string, flags?: FileFlags): Promise<void>;
|
|
809
|
+
|
|
810
|
+
/**
|
|
811
|
+
* This returns a promise, resolvable when file is written
|
|
812
|
+
* @param path of a file to write
|
|
813
|
+
* @param bytes to write to file. This is a whole of file content.
|
|
814
|
+
* @param flags are optional flags. Default flags are create=true,
|
|
815
|
+
* exclusive=false.
|
|
816
|
+
*/
|
|
817
|
+
writeBytes(path: string, bytes: Uint8Array, flags?: FileFlags):
|
|
818
|
+
Promise<void>;
|
|
819
|
+
|
|
820
|
+
/**
|
|
821
|
+
* This returns a promise, resolvable to byte sink with seek
|
|
822
|
+
* @param path of a file for which we want to get a writable byte sink
|
|
823
|
+
* @param flags are optional flags. Default flags are create=true,
|
|
824
|
+
* exclusive=false, truncate=true.
|
|
825
|
+
*/
|
|
826
|
+
getByteSink(path: string, flags?: FileFlags): Promise<FileByteSink>;
|
|
827
|
+
|
|
828
|
+
/**
|
|
829
|
+
* This returns a promise, resolvable to file object.
|
|
830
|
+
* @param path
|
|
831
|
+
* @param flags are optional flags. Default flags are create=true,
|
|
832
|
+
* exclusive=false.
|
|
833
|
+
*/
|
|
834
|
+
writableFile(path: string, flags?: FileFlags): Promise<WritableFile>;
|
|
835
|
+
|
|
836
|
+
}
|
|
837
|
+
|
|
838
|
+
interface FileFlags {
|
|
839
|
+
|
|
840
|
+
/**
|
|
841
|
+
* truncate flag is optional. True value forces truncation of file, if it
|
|
842
|
+
* already exists. Default value is true.
|
|
843
|
+
*/
|
|
844
|
+
truncate?: boolean;
|
|
845
|
+
|
|
846
|
+
/**
|
|
847
|
+
* create flag is optional. True value forces creation of file, if it is
|
|
848
|
+
* missing. Default value is true.
|
|
849
|
+
*/
|
|
850
|
+
create?: boolean;
|
|
851
|
+
|
|
852
|
+
/**
|
|
853
|
+
* exclusive flag is optional. This flag is applicable when create is
|
|
854
|
+
* true. True value ensures that file doesn't exist, and an error is
|
|
855
|
+
* thrown, when file exists. Default value is false.
|
|
856
|
+
*/
|
|
857
|
+
exclusive?: boolean;
|
|
858
|
+
|
|
859
|
+
}
|
|
860
|
+
|
|
861
|
+
interface VersionedFileFlags extends FileFlags {
|
|
862
|
+
|
|
863
|
+
/**
|
|
864
|
+
* currentVersion flag is optional. This flag is applicable to existing
|
|
865
|
+
* file. An error is thrown when at the time of writing current file
|
|
866
|
+
* version is different from a given value.
|
|
867
|
+
*/
|
|
868
|
+
currentVersion?: number;
|
|
869
|
+
|
|
870
|
+
}
|
|
871
|
+
|
|
872
|
+
interface ReadonlyFSVersionedAPI {
|
|
873
|
+
|
|
874
|
+
getXAttr(path: string, xaName: string):
|
|
875
|
+
Promise<{ attr: any; version: number; }>;
|
|
876
|
+
|
|
877
|
+
listXAttrs(path: string): Promise<{ lst: string[]; version: number; }>;
|
|
878
|
+
|
|
879
|
+
/**
|
|
880
|
+
* This returns a promise, resolvable to a list of informational objects
|
|
881
|
+
* for entries in the folder, and a folder's version.
|
|
882
|
+
* @param path of a folder that should be listed
|
|
883
|
+
*/
|
|
884
|
+
listFolder(path: string):
|
|
885
|
+
Promise<{ lst: ListingEntry[]; version: number; }>;
|
|
886
|
+
|
|
887
|
+
/**
|
|
888
|
+
* This returns a promise, resolvable to json, read from file, and a
|
|
889
|
+
* version of file.
|
|
890
|
+
* @param path of a file from which to read json
|
|
891
|
+
*/
|
|
892
|
+
readJSONFile<T>(path: string): Promise<{ json: T; version: number; }>;
|
|
893
|
+
|
|
894
|
+
/**
|
|
895
|
+
* This returns a promise, resolvable to text, read from file, assuming
|
|
896
|
+
* utf8 encoding, and version of file.
|
|
897
|
+
* @param path of a file from which to read text
|
|
898
|
+
*/
|
|
899
|
+
readTxtFile(path: string): Promise<{ txt: string; version: number; }>;
|
|
900
|
+
|
|
901
|
+
/**
|
|
902
|
+
* This returns a promise, resolvable to bytes, that is either non-empty
|
|
903
|
+
* byte array, or an undefined, and version of file.
|
|
904
|
+
* @param path of a file from which to read bytes
|
|
905
|
+
* @param start optional parameter, setting a beginning of read. If
|
|
906
|
+
* missing, read will be done as if neither start, nor end parameters
|
|
907
|
+
* are given.
|
|
908
|
+
* @param end optional parameter, setting an end of read. If end is
|
|
909
|
+
* greater than file length, all available bytes are read. If parameter
|
|
910
|
+
* is missing, read will be done to file's end.
|
|
911
|
+
*/
|
|
912
|
+
readBytes(path: string, start?: number, end?: number):
|
|
913
|
+
Promise<{ bytes: Uint8Array|undefined; version: number; }>;
|
|
914
|
+
|
|
915
|
+
/**
|
|
916
|
+
* This returns a promise, resolvable to bytes source with seek, which
|
|
917
|
+
* allows random reads, and a file version
|
|
918
|
+
* @param path of a file from which to read bytes
|
|
919
|
+
*/
|
|
920
|
+
getByteSource(path: string):
|
|
921
|
+
Promise<{ src: FileByteSource; version: number; }>;
|
|
922
|
+
|
|
923
|
+
}
|
|
924
|
+
|
|
925
|
+
interface WritableFSVersionedAPI extends ReadonlyFSVersionedAPI {
|
|
926
|
+
|
|
927
|
+
/**
|
|
928
|
+
* This updates extended attributes.
|
|
929
|
+
* @param path
|
|
930
|
+
* @param changes is an object with changes to attributes. Note these are
|
|
931
|
+
* explicit changes of extended attributes, not an implicit replacement.
|
|
932
|
+
*/
|
|
933
|
+
updateXAttrs(path: string, changes: XAttrsChanges): Promise<number>;
|
|
934
|
+
|
|
935
|
+
/**
|
|
936
|
+
* This returns a promise, resolvable to new file's version when file is
|
|
937
|
+
* written.
|
|
938
|
+
* @param path of a file to write given json
|
|
939
|
+
* @param json
|
|
940
|
+
* @param flags are optional flags. Default flags are create=true,
|
|
941
|
+
* exclusive=false.
|
|
942
|
+
*/
|
|
943
|
+
writeJSONFile(path: string, json: any, flags?: VersionedFileFlags):
|
|
944
|
+
Promise<number>;
|
|
945
|
+
|
|
946
|
+
/**
|
|
947
|
+
* This returns a promise, resolvable to new file's version when file is
|
|
948
|
+
* written
|
|
949
|
+
* @param path of a file to write given text
|
|
950
|
+
* @param txt to write to file, using utf8 encoding
|
|
951
|
+
* @param flags are optional flags. Default flags are create=true,
|
|
952
|
+
* exclusive=false.
|
|
953
|
+
*/
|
|
954
|
+
writeTxtFile(path: string, txt: string, flags?: VersionedFileFlags):
|
|
955
|
+
Promise<number>;
|
|
956
|
+
|
|
957
|
+
/**
|
|
958
|
+
* This returns a promise, resolvable to new file's version when file is
|
|
959
|
+
* written
|
|
960
|
+
* @param path of a file to write
|
|
961
|
+
* @param bytes to write to file. This is a whole of file content.
|
|
962
|
+
* @param flags are optional flags. Default flags are create=true,
|
|
963
|
+
* exclusive=false.
|
|
964
|
+
*/
|
|
965
|
+
writeBytes(path: string, bytes: Uint8Array, flags?: VersionedFileFlags):
|
|
966
|
+
Promise<number>;
|
|
967
|
+
|
|
968
|
+
/**
|
|
969
|
+
* This returns a promise, resolvable to byte sink with seek, and a file
|
|
970
|
+
* version
|
|
971
|
+
* @param path of a file for which we want to get a writable byte sink
|
|
972
|
+
* @param flags are optional flags. Default flags are create=true,
|
|
973
|
+
* exclusive=false, truncate=true.
|
|
974
|
+
*/
|
|
975
|
+
getByteSink(path: string, flags?: VersionedFileFlags):
|
|
976
|
+
Promise<{ sink: FileByteSink; version: number; }>;
|
|
977
|
+
|
|
978
|
+
}
|
|
979
|
+
|
|
980
|
+
interface FSEvent {
|
|
981
|
+
type: string;
|
|
982
|
+
path: string;
|
|
983
|
+
isRemote?: boolean;
|
|
984
|
+
newVersion?: number;
|
|
985
|
+
}
|
|
986
|
+
|
|
987
|
+
interface RemovedEvent extends FSEvent {
|
|
988
|
+
type: 'removed';
|
|
989
|
+
}
|
|
990
|
+
|
|
991
|
+
interface MovedEvent extends FSEvent {
|
|
992
|
+
type: 'moved';
|
|
993
|
+
}
|
|
994
|
+
|
|
995
|
+
interface SyncedEvent extends FSEvent {
|
|
996
|
+
type: 'synced';
|
|
997
|
+
current: number;
|
|
998
|
+
}
|
|
999
|
+
|
|
1000
|
+
interface UnsyncedEvent extends FSEvent {
|
|
1001
|
+
type: 'unsynced';
|
|
1002
|
+
lastSynced: number;
|
|
1003
|
+
}
|
|
1004
|
+
|
|
1005
|
+
interface ConflictEvent extends FSEvent {
|
|
1006
|
+
type: 'conflicting';
|
|
1007
|
+
remoteVersion: number;
|
|
1008
|
+
}
|
|
1009
|
+
|
|
1010
|
+
type FolderEvent = EntryRemovalEvent | EntryAdditionEvent |
|
|
1011
|
+
EntryRenamingEvent | RemovedEvent | MovedEvent |
|
|
1012
|
+
SyncedEvent | UnsyncedEvent | ConflictEvent;
|
|
1013
|
+
|
|
1014
|
+
interface EntryRemovalEvent extends FSEvent {
|
|
1015
|
+
type: 'entry-removal';
|
|
1016
|
+
name: string;
|
|
1017
|
+
}
|
|
1018
|
+
|
|
1019
|
+
interface EntryAdditionEvent extends FSEvent {
|
|
1020
|
+
type: 'entry-addition';
|
|
1021
|
+
entry: ListingEntry;
|
|
1022
|
+
}
|
|
1023
|
+
|
|
1024
|
+
interface EntryRenamingEvent extends FSEvent {
|
|
1025
|
+
type: 'entry-renaming';
|
|
1026
|
+
oldName: string;
|
|
1027
|
+
newName: string;
|
|
1028
|
+
}
|
|
1029
|
+
|
|
1030
|
+
type FileEvent = FileChangeEvent | RemovedEvent | MovedEvent |
|
|
1031
|
+
SyncedEvent | UnsyncedEvent | ConflictEvent;
|
|
1032
|
+
|
|
1033
|
+
interface FileChangeEvent extends FSEvent {
|
|
1034
|
+
type: 'file-change';
|
|
1035
|
+
}
|
|
1036
|
+
|
|
1037
|
+
}
|