@nextcloud/files 3.0.0-beta.1 → 3.0.0-beta.11
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/dist/fileAction.d.ts +77 -0
- package/dist/files/file.d.ts +26 -0
- package/dist/files/fileType.d.ts +25 -0
- package/dist/files/folder.d.ts +30 -0
- package/dist/files/node.d.ts +87 -0
- package/dist/files/nodeData.d.ts +59 -0
- package/dist/humanfilesize.d.ts +1 -1
- package/dist/index.d.ts +11 -9
- package/dist/index.esm.js +585 -35
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +698 -36
- package/dist/index.js.map +1 -1
- package/dist/newFileMenu.d.ts +8 -7
- package/dist/permissions.d.ts +35 -0
- package/dist/utils/logger.d.ts +1 -1
- package/package.json +20 -18
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @copyright Copyright (c) 2021 John Molakvoæ <skjnldsv@protonmail.com>
|
|
3
|
+
*
|
|
4
|
+
* @author John Molakvoæ <skjnldsv@protonmail.com>
|
|
5
|
+
*
|
|
6
|
+
* @license AGPL-3.0-or-later
|
|
7
|
+
*
|
|
8
|
+
* This program is free software: you can redistribute it and/or modify
|
|
9
|
+
* it under the terms of the GNU Affero General Public License as
|
|
10
|
+
* published by the Free Software Foundation, either version 3 of the
|
|
11
|
+
* License, or (at your option) any later version.
|
|
12
|
+
*
|
|
13
|
+
* This program is distributed in the hope that it will be useful,
|
|
14
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
15
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
16
|
+
* GNU Affero General Public License for more details.
|
|
17
|
+
*
|
|
18
|
+
* You should have received a copy of the GNU Affero General Public License
|
|
19
|
+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
20
|
+
*
|
|
21
|
+
*/
|
|
22
|
+
import { Node } from "./files/node";
|
|
23
|
+
interface FileActionData {
|
|
24
|
+
/** Unique ID */
|
|
25
|
+
id: string;
|
|
26
|
+
/** Translatable string displayed in the menu */
|
|
27
|
+
displayName: (files: Node[], view: any) => string;
|
|
28
|
+
/** Svg as inline string. <svg><path fill="..." /></svg> */
|
|
29
|
+
iconSvgInline: (files: Node[], view: any) => string;
|
|
30
|
+
/** Condition wether this action is shown or not */
|
|
31
|
+
enabled?: (files: Node[], view: any) => boolean;
|
|
32
|
+
/**
|
|
33
|
+
* Function executed on single file action
|
|
34
|
+
* @returns true if the action was executed successfully,
|
|
35
|
+
* false otherwise and null if the action is silent/undefined.
|
|
36
|
+
* @throws Error if the action failed
|
|
37
|
+
*/
|
|
38
|
+
exec: (file: Node, view: any, dir: string) => Promise<boolean | null>;
|
|
39
|
+
/**
|
|
40
|
+
* Function executed on multiple files action
|
|
41
|
+
* @returns true if the action was executed successfully,
|
|
42
|
+
* false otherwise and null if the action is silent/undefined.
|
|
43
|
+
* @throws Error if the action failed
|
|
44
|
+
*/
|
|
45
|
+
execBatch?: (files: Node[], view: any, dir: string) => Promise<(boolean | null)[]>;
|
|
46
|
+
/** This action order in the list */
|
|
47
|
+
order?: number;
|
|
48
|
+
/** Make this action the default */
|
|
49
|
+
default?: boolean;
|
|
50
|
+
/**
|
|
51
|
+
* If true, the renderInline function will be called
|
|
52
|
+
*/
|
|
53
|
+
inline?: (file: Node, view: any) => boolean;
|
|
54
|
+
/**
|
|
55
|
+
* If defined, the returned html element will be
|
|
56
|
+
* appended before the actions menu.
|
|
57
|
+
*/
|
|
58
|
+
renderInline?: (file: Node, view: any) => HTMLElement;
|
|
59
|
+
}
|
|
60
|
+
export declare class FileAction {
|
|
61
|
+
private _action;
|
|
62
|
+
constructor(action: FileActionData);
|
|
63
|
+
get id(): string;
|
|
64
|
+
get displayName(): (files: Node[], view: any) => string;
|
|
65
|
+
get iconSvgInline(): (files: Node[], view: any) => string;
|
|
66
|
+
get enabled(): ((files: Node[], view: any) => boolean) | undefined;
|
|
67
|
+
get exec(): (file: Node, view: any, dir: string) => Promise<boolean | null>;
|
|
68
|
+
get execBatch(): ((files: Node[], view: any, dir: string) => Promise<(boolean | null)[]>) | undefined;
|
|
69
|
+
get order(): number | undefined;
|
|
70
|
+
get default(): boolean | undefined;
|
|
71
|
+
get inline(): ((file: Node, view: any) => boolean) | undefined;
|
|
72
|
+
get renderInline(): ((file: Node, view: any) => HTMLElement) | undefined;
|
|
73
|
+
private validateAction;
|
|
74
|
+
}
|
|
75
|
+
export declare const registerFileAction: (action: FileAction) => void;
|
|
76
|
+
export declare const getFileActions: () => FileAction[];
|
|
77
|
+
export {};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @copyright Copyright (c) 2022 John Molakvoæ <skjnldsv@protonmail.com>
|
|
3
|
+
*
|
|
4
|
+
* @author John Molakvoæ <skjnldsv@protonmail.com>
|
|
5
|
+
*
|
|
6
|
+
* @license AGPL-3.0-or-later
|
|
7
|
+
*
|
|
8
|
+
* This program is free software: you can redistribute it and/or modify
|
|
9
|
+
* it under the terms of the GNU Affero General Public License as
|
|
10
|
+
* published by the Free Software Foundation, either version 3 of the
|
|
11
|
+
* License, or (at your option) any later version.
|
|
12
|
+
*
|
|
13
|
+
* This program is distributed in the hope that it will be useful,
|
|
14
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
15
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
16
|
+
* GNU Affero General Public License for more details.
|
|
17
|
+
*
|
|
18
|
+
* You should have received a copy of the GNU Affero General Public License
|
|
19
|
+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
20
|
+
*
|
|
21
|
+
*/
|
|
22
|
+
import { FileType } from './fileType';
|
|
23
|
+
import { Node } from './node';
|
|
24
|
+
export declare class File extends Node {
|
|
25
|
+
get type(): FileType;
|
|
26
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @copyright Copyright (c) 2022 John Molakvoæ <skjnldsv@protonmail.com>
|
|
3
|
+
*
|
|
4
|
+
* @author John Molakvoæ <skjnldsv@protonmail.com>
|
|
5
|
+
*
|
|
6
|
+
* @license AGPL-3.0-or-later
|
|
7
|
+
*
|
|
8
|
+
* This program is free software: you can redistribute it and/or modify
|
|
9
|
+
* it under the terms of the GNU Affero General Public License as
|
|
10
|
+
* published by the Free Software Foundation, either version 3 of the
|
|
11
|
+
* License, or (at your option) any later version.
|
|
12
|
+
*
|
|
13
|
+
* This program is distributed in the hope that it will be useful,
|
|
14
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
15
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
16
|
+
* GNU Affero General Public License for more details.
|
|
17
|
+
*
|
|
18
|
+
* You should have received a copy of the GNU Affero General Public License
|
|
19
|
+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
20
|
+
*
|
|
21
|
+
*/
|
|
22
|
+
export declare enum FileType {
|
|
23
|
+
Folder = "folder",
|
|
24
|
+
File = "file"
|
|
25
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @copyright Copyright (c) 2022 John Molakvoæ <skjnldsv@protonmail.com>
|
|
3
|
+
*
|
|
4
|
+
* @author John Molakvoæ <skjnldsv@protonmail.com>
|
|
5
|
+
*
|
|
6
|
+
* @license AGPL-3.0-or-later
|
|
7
|
+
*
|
|
8
|
+
* This program is free software: you can redistribute it and/or modify
|
|
9
|
+
* it under the terms of the GNU Affero General Public License as
|
|
10
|
+
* published by the Free Software Foundation, either version 3 of the
|
|
11
|
+
* License, or (at your option) any later version.
|
|
12
|
+
*
|
|
13
|
+
* This program is distributed in the hope that it will be useful,
|
|
14
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
15
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
16
|
+
* GNU Affero General Public License for more details.
|
|
17
|
+
*
|
|
18
|
+
* You should have received a copy of the GNU Affero General Public License
|
|
19
|
+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
20
|
+
*
|
|
21
|
+
*/
|
|
22
|
+
import { FileType } from './fileType';
|
|
23
|
+
import { Node } from './node';
|
|
24
|
+
import NodeData from './nodeData';
|
|
25
|
+
export declare class Folder extends Node {
|
|
26
|
+
constructor(data: NodeData);
|
|
27
|
+
get type(): FileType;
|
|
28
|
+
get extension(): string | null;
|
|
29
|
+
get mime(): string;
|
|
30
|
+
}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { Permission } from '../permissions';
|
|
2
|
+
import { FileType } from './fileType';
|
|
3
|
+
import NodeData, { Attribute } from './nodeData';
|
|
4
|
+
export declare abstract class Node {
|
|
5
|
+
private _data;
|
|
6
|
+
private _attributes;
|
|
7
|
+
private _knownDavService;
|
|
8
|
+
constructor(data: NodeData, davService?: RegExp);
|
|
9
|
+
/**
|
|
10
|
+
* Get the source url to this object
|
|
11
|
+
*/
|
|
12
|
+
get source(): string;
|
|
13
|
+
/**
|
|
14
|
+
* Get this object name
|
|
15
|
+
*/
|
|
16
|
+
get basename(): string;
|
|
17
|
+
/**
|
|
18
|
+
* Get this object's extension
|
|
19
|
+
*/
|
|
20
|
+
get extension(): string | null;
|
|
21
|
+
/**
|
|
22
|
+
* Get the directory path leading to this object
|
|
23
|
+
* Will use the relative path to root if available
|
|
24
|
+
*/
|
|
25
|
+
get dirname(): string;
|
|
26
|
+
/**
|
|
27
|
+
* Is it a file or a folder ?
|
|
28
|
+
*/
|
|
29
|
+
abstract get type(): FileType;
|
|
30
|
+
/**
|
|
31
|
+
* Get the file mime
|
|
32
|
+
*/
|
|
33
|
+
get mime(): string | undefined;
|
|
34
|
+
/**
|
|
35
|
+
* Get the file modification time
|
|
36
|
+
*/
|
|
37
|
+
get mtime(): Date | undefined;
|
|
38
|
+
/**
|
|
39
|
+
* Get the file creation time
|
|
40
|
+
*/
|
|
41
|
+
get crtime(): Date | undefined;
|
|
42
|
+
/**
|
|
43
|
+
* Get the file size
|
|
44
|
+
*/
|
|
45
|
+
get size(): number | undefined;
|
|
46
|
+
/**
|
|
47
|
+
* Get the file attribute
|
|
48
|
+
*/
|
|
49
|
+
get attributes(): Attribute;
|
|
50
|
+
/**
|
|
51
|
+
* Get the file permissions
|
|
52
|
+
*/
|
|
53
|
+
get permissions(): Permission;
|
|
54
|
+
/**
|
|
55
|
+
* Get the file owner
|
|
56
|
+
*/
|
|
57
|
+
get owner(): string | null;
|
|
58
|
+
/**
|
|
59
|
+
* Is this a dav-related ressource ?
|
|
60
|
+
*/
|
|
61
|
+
get isDavRessource(): boolean;
|
|
62
|
+
/**
|
|
63
|
+
* Get the dav root of this object
|
|
64
|
+
*/
|
|
65
|
+
get root(): string | null;
|
|
66
|
+
/**
|
|
67
|
+
* Get the absolute path of this object relative to the root
|
|
68
|
+
*/
|
|
69
|
+
get path(): string;
|
|
70
|
+
/**
|
|
71
|
+
* Get the node id if defined.
|
|
72
|
+
* Will look for the fileid in attributes if undefined.
|
|
73
|
+
*/
|
|
74
|
+
get fileid(): number | undefined;
|
|
75
|
+
/**
|
|
76
|
+
* Move the node to a new destination
|
|
77
|
+
*
|
|
78
|
+
* @param {string} destination the new source.
|
|
79
|
+
* e.g. https://cloud.domain.com/remote.php/dav/files/emma/Photos/picture.jpg
|
|
80
|
+
*/
|
|
81
|
+
move(destination: string): void;
|
|
82
|
+
/**
|
|
83
|
+
* Rename the node
|
|
84
|
+
* This aliases the move method for easier usage
|
|
85
|
+
*/
|
|
86
|
+
rename(basename: any): void;
|
|
87
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @copyright Copyright (c) 2022 John Molakvoæ <skjnldsv@protonmail.com>
|
|
3
|
+
*
|
|
4
|
+
* @author John Molakvoæ <skjnldsv@protonmail.com>
|
|
5
|
+
*
|
|
6
|
+
* @license AGPL-3.0-or-later
|
|
7
|
+
*
|
|
8
|
+
* This program is free software: you can redistribute it and/or modify
|
|
9
|
+
* it under the terms of the GNU Affero General Public License as
|
|
10
|
+
* published by the Free Software Foundation, either version 3 of the
|
|
11
|
+
* License, or (at your option) any later version.
|
|
12
|
+
*
|
|
13
|
+
* This program is distributed in the hope that it will be useful,
|
|
14
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
15
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
16
|
+
* GNU Affero General Public License for more details.
|
|
17
|
+
*
|
|
18
|
+
* You should have received a copy of the GNU Affero General Public License
|
|
19
|
+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
20
|
+
*
|
|
21
|
+
*/
|
|
22
|
+
import { Permission } from "../permissions";
|
|
23
|
+
export interface Attribute {
|
|
24
|
+
[key: string]: any;
|
|
25
|
+
}
|
|
26
|
+
export default interface NodeData {
|
|
27
|
+
/** Unique ID */
|
|
28
|
+
id?: number;
|
|
29
|
+
/**
|
|
30
|
+
* URL to the ressource.
|
|
31
|
+
* e.g. https://cloud.domain.com/remote.php/dav/files/emma/Photos/picture.jpg
|
|
32
|
+
* or https://domain.com/Photos/picture.jpg
|
|
33
|
+
*/
|
|
34
|
+
source: string;
|
|
35
|
+
/** Last modified time */
|
|
36
|
+
mtime?: Date;
|
|
37
|
+
/** Creation time */
|
|
38
|
+
crtime?: Date;
|
|
39
|
+
/** The mime type */
|
|
40
|
+
mime?: string;
|
|
41
|
+
/** The node size type */
|
|
42
|
+
size?: number;
|
|
43
|
+
/** The node permissions */
|
|
44
|
+
permissions?: Permission;
|
|
45
|
+
/** The owner UID of this node */
|
|
46
|
+
owner: string | null;
|
|
47
|
+
attributes?: Attribute;
|
|
48
|
+
/**
|
|
49
|
+
* The absolute root of the home relative to the service.
|
|
50
|
+
* It is highly recommended to provide that information.
|
|
51
|
+
* e.g. /files/emma
|
|
52
|
+
*/
|
|
53
|
+
root?: string;
|
|
54
|
+
}
|
|
55
|
+
export declare const isDavRessource: (source: string, davService: RegExp) => boolean;
|
|
56
|
+
/**
|
|
57
|
+
* Validate Node construct data
|
|
58
|
+
*/
|
|
59
|
+
export declare const validateData: (data: NodeData, davService: RegExp) => void;
|
package/dist/humanfilesize.d.ts
CHANGED
|
@@ -26,4 +26,4 @@
|
|
|
26
26
|
* @param size in bytes
|
|
27
27
|
* @param skipSmallSizes avoid rendering tiny sizes and return '< 1 KB' instead
|
|
28
28
|
*/
|
|
29
|
-
export declare function formatFileSize(size: number | string, skipSmallSizes?: boolean): string;
|
|
29
|
+
export declare function formatFileSize(size: number | string, skipSmallSizes?: boolean, binaryPrefixes?: boolean): string;
|
package/dist/index.d.ts
CHANGED
|
@@ -21,14 +21,14 @@
|
|
|
21
21
|
*
|
|
22
22
|
*/
|
|
23
23
|
export { formatFileSize } from './humanfilesize';
|
|
24
|
-
export {
|
|
25
|
-
import { type Entry
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
}
|
|
24
|
+
export { type Entry } from './newFileMenu';
|
|
25
|
+
import { type Entry } from './newFileMenu';
|
|
26
|
+
export { FileType } from './files/fileType';
|
|
27
|
+
export { File } from './files/file';
|
|
28
|
+
export { Folder } from './files/folder';
|
|
29
|
+
export { Node } from './files/node';
|
|
30
|
+
export { Permission, parseWebdavPermissions } from './permissions';
|
|
31
|
+
export { FileAction, registerFileAction, getFileActions } from './fileAction';
|
|
32
32
|
/**
|
|
33
33
|
* Add a new menu entry to the upload manager menu
|
|
34
34
|
*/
|
|
@@ -39,5 +39,7 @@ export declare const addNewFileMenuEntry: (entry: Entry) => void;
|
|
|
39
39
|
export declare const removeNewFileMenuEntry: (entry: Entry | string) => void;
|
|
40
40
|
/**
|
|
41
41
|
* Get the list of registered entries from the upload menu
|
|
42
|
+
*
|
|
43
|
+
* @param {FileInfo} context the creation context. Usually the current folder FileInfo
|
|
42
44
|
*/
|
|
43
|
-
export declare const getNewFileMenuEntries: () => Entry[];
|
|
45
|
+
export declare const getNewFileMenuEntries: (context?: Object) => Entry[];
|