UNPKG

2.19 kBTypeScriptView Raw
1/**
2 * The file class represents a file in nextcloud.
3 * It exposes file properties and content handling, commenting and tagging
4 */
5export default abstract class FileSystemElement {
6 /**
7 * The name of the file system element including the path
8 * The name is readonly
9 */
10 abstract get name(): string;
11 /**
12 * The base name of the file system element (name without path)
13 * The base name is readonly
14 */
15 abstract get baseName(): string;
16 /**
17 * The timestamp of the last file system element change
18 * readonly
19 */
20 abstract get lastmod(): Date;
21 /**
22 * The unique id of the file system element.
23 */
24 abstract get id(): number;
25 /**
26 * deletes a file system element
27 * @throws Error
28 */
29 abstract delete(): Promise<void>;
30 /**
31 * moves or renames the current file system element to the new location
32 * target folder must exists
33 * @param targetFileName the name of the target file /f1/f2/myfile.txt
34 * @throws Error
35 */
36 abstract move(targetName: string): Promise<FileSystemElement>;
37 /**
38 * @returns the url of the file sytsem element
39 * @throws Error
40 */
41 abstract getUrl(): string;
42 /**
43 * @returns the url of the file system element in the UI
44 * @throws Error
45 */
46 abstract getUIUrl(): string;
47 /**
48 * adds a tag name to the file system element
49 * @param tagName name of the tag
50 */
51 abstract addTag(tagName: string): Promise<void>;
52 /**
53 * get tag names
54 * @returns array of tag names
55 */
56 abstract getTags(): Promise<string[]>;
57 /**
58 * removes a tag of the file system element
59 * @param tagName the name of the tag
60 */
61 abstract removeTag(tagName: string): Promise<void>;
62 /**
63 * add comment to file
64 * @param comment the comment
65 */
66 abstract addComment(comment: string): Promise<void>;
67 /**
68 * get list of comments of file
69 * @param top number of comments to return
70 * @param skip the offset
71 * @returns array of comment strings
72 * @throws Exception
73 */
74 abstract getComments(top?: number, skip?: number): Promise<string[]>;
75}