@nextcloud/files 3.10.0 → 3.10.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/dist/chunks/{dav-DxfiR0wZ.mjs → dav-Co9y-hkg.mjs} +15 -9
- package/dist/chunks/dav-Co9y-hkg.mjs.map +1 -0
- package/dist/chunks/{dav-BBwoJ8WE.cjs → dav-CtqjqS4O.cjs} +15 -9
- package/dist/chunks/dav-CtqjqS4O.cjs.map +1 -0
- package/dist/dav/dav.d.ts +55 -0
- package/dist/dav/davPermissions.d.ts +6 -0
- package/dist/dav/davProperties.d.ts +57 -0
- package/dist/dav/index.d.ts +13 -0
- package/dist/dav.cjs +1 -1
- package/dist/dav.mjs +1 -1
- package/dist/fileAction.d.ts +83 -0
- package/dist/fileListAction.d.ts +41 -0
- package/dist/fileListFilters.d.ts +100 -0
- package/dist/fileListHeaders.d.ts +26 -0
- package/dist/files/file.d.ts +13 -0
- package/dist/files/fileType.d.ts +8 -0
- package/dist/files/folder.d.ts +17 -0
- package/dist/files/node.d.ts +177 -0
- package/dist/files/nodeData.d.ts +53 -0
- package/dist/index.cjs +1956 -1805
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +118 -1099
- package/dist/index.mjs +1957 -1806
- package/dist/index.mjs.map +1 -1
- package/dist/navigation/column.d.ts +27 -0
- package/dist/navigation/index.d.ts +7 -0
- package/dist/navigation/navigation.d.ts +73 -0
- package/dist/navigation/view.d.ts +91 -0
- package/dist/newFileMenu.d.ts +65 -0
- package/dist/permissions.d.ts +16 -0
- package/dist/utils/fileSize.d.ts +25 -0
- package/dist/utils/fileSorting.d.ts +34 -0
- package/dist/utils/filename-validation.d.ts +51 -0
- package/dist/utils/filename.d.ts +24 -0
- package/dist/utils/logger.d.ts +2 -0
- package/dist/utils/sorting.d.ts +12 -0
- package/dist/vendor.LICENSE.txt +1 -1
- package/package.json +14 -14
- package/dist/chunks/dav-BBwoJ8WE.cjs.map +0 -1
- package/dist/chunks/dav-DxfiR0wZ.mjs.map +0 -1
- package/dist/dav.d.ts +0 -370
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { Folder } from './files/folder.ts';
|
|
2
|
+
import { Node } from './files/node.ts';
|
|
3
|
+
import { View } from './navigation/view.ts';
|
|
4
|
+
interface FileListActionData {
|
|
5
|
+
/** Unique ID */
|
|
6
|
+
id: string;
|
|
7
|
+
/** Translated name of the action */
|
|
8
|
+
displayName: (view: View) => string;
|
|
9
|
+
/** Raw svg string */
|
|
10
|
+
iconSvgInline?: (view: View) => string;
|
|
11
|
+
/** Sort order */
|
|
12
|
+
order: number;
|
|
13
|
+
/**
|
|
14
|
+
* Condition whether this action is shown or not
|
|
15
|
+
* @param view The current view
|
|
16
|
+
* @param nodes The nodes in the current directory
|
|
17
|
+
* @param folder The current folder
|
|
18
|
+
*/
|
|
19
|
+
enabled?: (view: View, nodes: Node[], folder: Folder) => boolean;
|
|
20
|
+
/**
|
|
21
|
+
* Function executed on single file action
|
|
22
|
+
* @return true if the action was executed successfully,
|
|
23
|
+
* false otherwise and null if the action is silent/undefined.
|
|
24
|
+
* @throws Error if the action failed
|
|
25
|
+
*/
|
|
26
|
+
exec: (view: View, nodes: Node[], folder: Folder) => Promise<boolean | null>;
|
|
27
|
+
}
|
|
28
|
+
export declare class FileListAction {
|
|
29
|
+
private _action;
|
|
30
|
+
constructor(action: FileListActionData);
|
|
31
|
+
get id(): string;
|
|
32
|
+
get displayName(): (view: View) => string;
|
|
33
|
+
get iconSvgInline(): ((view: View) => string) | undefined;
|
|
34
|
+
get order(): number;
|
|
35
|
+
get enabled(): ((view: View, nodes: Node[], folder: Folder) => boolean) | undefined;
|
|
36
|
+
get exec(): (view: View, nodes: Node[], folder: Folder) => Promise<boolean | null>;
|
|
37
|
+
private validateAction;
|
|
38
|
+
}
|
|
39
|
+
export declare const registerFileListAction: (action: FileListAction) => void;
|
|
40
|
+
export declare const getFileListActions: () => FileListAction[];
|
|
41
|
+
export {};
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { TypedEventTarget } from 'typescript-event-target';
|
|
2
|
+
import { INode } from './files/node';
|
|
3
|
+
/**
|
|
4
|
+
* Active filters can provide one or more "chips" to show the currently active state.
|
|
5
|
+
* Must at least provide a text representing the filters state and a callback to unset that state (disable this filter).
|
|
6
|
+
*/
|
|
7
|
+
export interface IFileListFilterChip {
|
|
8
|
+
/**
|
|
9
|
+
* Text of the chip
|
|
10
|
+
*/
|
|
11
|
+
text: string;
|
|
12
|
+
/**
|
|
13
|
+
* Optional icon to be used on the chip (inline SVG as string)
|
|
14
|
+
*/
|
|
15
|
+
icon?: string;
|
|
16
|
+
/**
|
|
17
|
+
* Optional pass a user id to use a user avatar instead of an icon
|
|
18
|
+
*/
|
|
19
|
+
user?: string;
|
|
20
|
+
/**
|
|
21
|
+
* Handler to be called on click
|
|
22
|
+
*/
|
|
23
|
+
onclick: () => void;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* This event is emitted when the the filter value changed and the file list needs to be updated
|
|
27
|
+
*/
|
|
28
|
+
export interface FilterUpdateEvent extends CustomEvent<never> {
|
|
29
|
+
type: 'update:filter';
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* This event is emitted when the the filter value changed and the file list needs to be updated
|
|
33
|
+
*/
|
|
34
|
+
export interface FilterUpdateChipsEvent extends CustomEvent<IFileListFilterChip[]> {
|
|
35
|
+
type: 'update:chips';
|
|
36
|
+
}
|
|
37
|
+
interface IFileListFilterEvents {
|
|
38
|
+
[name: string]: CustomEvent;
|
|
39
|
+
'update:filter': FilterUpdateEvent;
|
|
40
|
+
'update:chips': FilterUpdateChipsEvent;
|
|
41
|
+
}
|
|
42
|
+
export interface IFileListFilter extends TypedEventTarget<IFileListFilterEvents> {
|
|
43
|
+
/**
|
|
44
|
+
* Unique ID of this filter
|
|
45
|
+
*/
|
|
46
|
+
readonly id: string;
|
|
47
|
+
/**
|
|
48
|
+
* Order of the filter
|
|
49
|
+
*
|
|
50
|
+
* Use a low number to make this filter ordered in front.
|
|
51
|
+
*/
|
|
52
|
+
readonly order: number;
|
|
53
|
+
/**
|
|
54
|
+
* Filter function to decide if a node is shown.
|
|
55
|
+
*
|
|
56
|
+
* @param nodes Nodes to filter
|
|
57
|
+
* @return Subset of the `nodes` parameter to show
|
|
58
|
+
*/
|
|
59
|
+
filter(nodes: INode[]): INode[];
|
|
60
|
+
/**
|
|
61
|
+
* If the filter needs a visual element for settings it can provide a function to mount it.
|
|
62
|
+
* @param el The DOM element to mount to
|
|
63
|
+
*/
|
|
64
|
+
mount?(el: HTMLElement): void;
|
|
65
|
+
/**
|
|
66
|
+
* Reset the filter to the initial state.
|
|
67
|
+
* This is called by the files app.
|
|
68
|
+
* Implementations should make sure,that if they provide chips they need to emit the `update:chips` event.
|
|
69
|
+
*
|
|
70
|
+
* @since 3.10.0
|
|
71
|
+
*/
|
|
72
|
+
reset?(): void;
|
|
73
|
+
}
|
|
74
|
+
export declare class FileListFilter extends TypedEventTarget<IFileListFilterEvents> implements IFileListFilter {
|
|
75
|
+
id: string;
|
|
76
|
+
order: number;
|
|
77
|
+
constructor(id: string, order?: number);
|
|
78
|
+
filter(nodes: INode[]): INode[];
|
|
79
|
+
protected updateChips(chips: IFileListFilterChip[]): void;
|
|
80
|
+
protected filterUpdated(): void;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Register a new filter on the file list
|
|
84
|
+
*
|
|
85
|
+
* This only must be called once to register the filter,
|
|
86
|
+
* when the filter state changes you need to call `filterUpdated` on the filter instead.
|
|
87
|
+
*
|
|
88
|
+
* @param filter The filter to register on the file list
|
|
89
|
+
*/
|
|
90
|
+
export declare function registerFileListFilter(filter: IFileListFilter): void;
|
|
91
|
+
/**
|
|
92
|
+
* Remove a registered filter from the file list
|
|
93
|
+
* @param filterId The unique ID of the filter to remove
|
|
94
|
+
*/
|
|
95
|
+
export declare function unregisterFileListFilter(filterId: string): void;
|
|
96
|
+
/**
|
|
97
|
+
* Get all registered file list filters
|
|
98
|
+
*/
|
|
99
|
+
export declare function getFileListFilters(): IFileListFilter[];
|
|
100
|
+
export {};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { Folder } from './files/folder';
|
|
2
|
+
import { View } from './navigation/view';
|
|
3
|
+
export interface HeaderData {
|
|
4
|
+
/** Unique ID */
|
|
5
|
+
id: string;
|
|
6
|
+
/** Order */
|
|
7
|
+
order: number;
|
|
8
|
+
/** Condition wether this header is shown or not */
|
|
9
|
+
enabled?: (folder: Folder, view: View) => boolean;
|
|
10
|
+
/** Executed when file list is initialized */
|
|
11
|
+
render: (el: HTMLElement, folder: Folder, view: View) => void;
|
|
12
|
+
/** Executed when root folder changed */
|
|
13
|
+
updated(folder: Folder, view: View): any;
|
|
14
|
+
}
|
|
15
|
+
export declare class Header {
|
|
16
|
+
private _header;
|
|
17
|
+
constructor(header: HeaderData);
|
|
18
|
+
get id(): string;
|
|
19
|
+
get order(): number;
|
|
20
|
+
get enabled(): ((folder: Folder, view: View) => boolean) | undefined;
|
|
21
|
+
get render(): (el: HTMLElement, folder: Folder, view: View) => void;
|
|
22
|
+
get updated(): (folder: Folder, view: View) => any;
|
|
23
|
+
private validateHeader;
|
|
24
|
+
}
|
|
25
|
+
export declare const registerFileListHeaders: (header: Header) => void;
|
|
26
|
+
export declare const getFileListHeaders: () => Header[];
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { FileType } from './fileType';
|
|
2
|
+
import { Node } from './node';
|
|
3
|
+
export declare class File extends Node {
|
|
4
|
+
get type(): FileType.File;
|
|
5
|
+
/**
|
|
6
|
+
* Returns a clone of the file
|
|
7
|
+
*/
|
|
8
|
+
clone(): File;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Interface of the File class
|
|
12
|
+
*/
|
|
13
|
+
export type IFile = Pick<File, keyof File>;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { NodeData } from './nodeData';
|
|
2
|
+
import { FileType } from './fileType';
|
|
3
|
+
import { Node } from './node';
|
|
4
|
+
export declare class Folder extends Node {
|
|
5
|
+
constructor(data: NodeData);
|
|
6
|
+
get type(): FileType.Folder;
|
|
7
|
+
get extension(): null;
|
|
8
|
+
get mime(): 'httpd/unix-directory';
|
|
9
|
+
/**
|
|
10
|
+
* Returns a clone of the folder
|
|
11
|
+
*/
|
|
12
|
+
clone(): Folder;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Interface of the folder class
|
|
16
|
+
*/
|
|
17
|
+
export type IFolder = Pick<Folder, keyof Folder>;
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
import { Permission } from '../permissions';
|
|
2
|
+
import { FileType } from './fileType';
|
|
3
|
+
import { Attribute, NodeData } from './nodeData';
|
|
4
|
+
export declare enum NodeStatus {
|
|
5
|
+
/** This is a new node and it doesn't exists on the filesystem yet */
|
|
6
|
+
NEW = "new",
|
|
7
|
+
/** This node has failed and is unavailable */
|
|
8
|
+
FAILED = "failed",
|
|
9
|
+
/** This node is currently loading or have an operation in progress */
|
|
10
|
+
LOADING = "loading",
|
|
11
|
+
/** This node is locked and cannot be modified */
|
|
12
|
+
LOCKED = "locked"
|
|
13
|
+
}
|
|
14
|
+
export declare abstract class Node {
|
|
15
|
+
private _data;
|
|
16
|
+
private _attributes;
|
|
17
|
+
private _knownDavService;
|
|
18
|
+
private readonlyAttributes;
|
|
19
|
+
private handler;
|
|
20
|
+
constructor(data: NodeData, davService?: RegExp);
|
|
21
|
+
/**
|
|
22
|
+
* Get the source url to this object
|
|
23
|
+
* There is no setter as the source is not meant to be changed manually.
|
|
24
|
+
* You can use the rename or move method to change the source.
|
|
25
|
+
*/
|
|
26
|
+
get source(): string;
|
|
27
|
+
/**
|
|
28
|
+
* Get the encoded source url to this object for requests purposes
|
|
29
|
+
*/
|
|
30
|
+
get encodedSource(): string;
|
|
31
|
+
/**
|
|
32
|
+
* Get this object name
|
|
33
|
+
* There is no setter as the source is not meant to be changed manually.
|
|
34
|
+
* You can use the rename or move method to change the source.
|
|
35
|
+
*/
|
|
36
|
+
get basename(): string;
|
|
37
|
+
/**
|
|
38
|
+
* The nodes displayname
|
|
39
|
+
* By default the display name and the `basename` are identical,
|
|
40
|
+
* but it is possible to have a different name. This happens
|
|
41
|
+
* on the files app for example for shared folders.
|
|
42
|
+
*/
|
|
43
|
+
get displayname(): string;
|
|
44
|
+
/**
|
|
45
|
+
* Set the displayname
|
|
46
|
+
*/
|
|
47
|
+
set displayname(displayname: string);
|
|
48
|
+
/**
|
|
49
|
+
* Get this object's extension
|
|
50
|
+
* There is no setter as the source is not meant to be changed manually.
|
|
51
|
+
* You can use the rename or move method to change the source.
|
|
52
|
+
*/
|
|
53
|
+
get extension(): string | null;
|
|
54
|
+
/**
|
|
55
|
+
* Get the directory path leading to this object
|
|
56
|
+
* Will use the relative path to root if available
|
|
57
|
+
*
|
|
58
|
+
* There is no setter as the source is not meant to be changed manually.
|
|
59
|
+
* You can use the rename or move method to change the source.
|
|
60
|
+
*/
|
|
61
|
+
get dirname(): string;
|
|
62
|
+
/**
|
|
63
|
+
* Is it a file or a folder ?
|
|
64
|
+
*/
|
|
65
|
+
abstract get type(): FileType;
|
|
66
|
+
/**
|
|
67
|
+
* Get the file mime
|
|
68
|
+
* There is no setter as the mime is not meant to be changed
|
|
69
|
+
*/
|
|
70
|
+
get mime(): string | undefined;
|
|
71
|
+
/**
|
|
72
|
+
* Get the file modification time
|
|
73
|
+
*/
|
|
74
|
+
get mtime(): Date | undefined;
|
|
75
|
+
/**
|
|
76
|
+
* Set the file modification time
|
|
77
|
+
*/
|
|
78
|
+
set mtime(mtime: Date | undefined);
|
|
79
|
+
/**
|
|
80
|
+
* Get the file creation time
|
|
81
|
+
* There is no setter as the creation time is not meant to be changed
|
|
82
|
+
*/
|
|
83
|
+
get crtime(): Date | undefined;
|
|
84
|
+
/**
|
|
85
|
+
* Get the file size
|
|
86
|
+
*/
|
|
87
|
+
get size(): number | undefined;
|
|
88
|
+
/**
|
|
89
|
+
* Set the file size
|
|
90
|
+
*/
|
|
91
|
+
set size(size: number | undefined);
|
|
92
|
+
/**
|
|
93
|
+
* Get the file attribute
|
|
94
|
+
* This contains all additional attributes not provided by the Node class
|
|
95
|
+
*/
|
|
96
|
+
get attributes(): Attribute;
|
|
97
|
+
/**
|
|
98
|
+
* Get the file permissions
|
|
99
|
+
*/
|
|
100
|
+
get permissions(): Permission;
|
|
101
|
+
/**
|
|
102
|
+
* Set the file permissions
|
|
103
|
+
*/
|
|
104
|
+
set permissions(permissions: Permission);
|
|
105
|
+
/**
|
|
106
|
+
* Get the file owner
|
|
107
|
+
* There is no setter as the owner is not meant to be changed
|
|
108
|
+
*/
|
|
109
|
+
get owner(): string | null;
|
|
110
|
+
/**
|
|
111
|
+
* Is this a dav-related resource ?
|
|
112
|
+
*/
|
|
113
|
+
get isDavResource(): boolean;
|
|
114
|
+
/**
|
|
115
|
+
* @deprecated use `isDavResource` instead - will be removed in next major version.
|
|
116
|
+
*/
|
|
117
|
+
get isDavRessource(): boolean;
|
|
118
|
+
/**
|
|
119
|
+
* Get the dav root of this object
|
|
120
|
+
* There is no setter as the root is not meant to be changed
|
|
121
|
+
*/
|
|
122
|
+
get root(): string | null;
|
|
123
|
+
/**
|
|
124
|
+
* Get the absolute path of this object relative to the root
|
|
125
|
+
*/
|
|
126
|
+
get path(): string;
|
|
127
|
+
/**
|
|
128
|
+
* Get the node id if defined.
|
|
129
|
+
* There is no setter as the fileid is not meant to be changed
|
|
130
|
+
*/
|
|
131
|
+
get fileid(): number | undefined;
|
|
132
|
+
/**
|
|
133
|
+
* Get the node status.
|
|
134
|
+
*/
|
|
135
|
+
get status(): NodeStatus | undefined;
|
|
136
|
+
/**
|
|
137
|
+
* Set the node status.
|
|
138
|
+
*/
|
|
139
|
+
set status(status: NodeStatus | undefined);
|
|
140
|
+
/**
|
|
141
|
+
* Get the node data
|
|
142
|
+
*/
|
|
143
|
+
get data(): NodeData;
|
|
144
|
+
/**
|
|
145
|
+
* Move the node to a new destination
|
|
146
|
+
*
|
|
147
|
+
* @param {string} destination the new source.
|
|
148
|
+
* e.g. https://cloud.domain.com/remote.php/dav/files/emma/Photos/picture.jpg
|
|
149
|
+
*/
|
|
150
|
+
move(destination: string): void;
|
|
151
|
+
/**
|
|
152
|
+
* Rename the node
|
|
153
|
+
* This aliases the move method for easier usage
|
|
154
|
+
*
|
|
155
|
+
* @param basename The new name of the node
|
|
156
|
+
*/
|
|
157
|
+
rename(basename: string): void;
|
|
158
|
+
/**
|
|
159
|
+
* Update the mtime if exists
|
|
160
|
+
*/
|
|
161
|
+
updateMtime(): void;
|
|
162
|
+
/**
|
|
163
|
+
* Update the attributes of the node
|
|
164
|
+
* Warning, updating attributes will NOT automatically update the mtime.
|
|
165
|
+
*
|
|
166
|
+
* @param attributes The new attributes to update on the Node attributes
|
|
167
|
+
*/
|
|
168
|
+
update(attributes: Attribute): void;
|
|
169
|
+
/**
|
|
170
|
+
* Returns a clone of the node
|
|
171
|
+
*/
|
|
172
|
+
abstract clone(): Node;
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* Interface of the node class
|
|
176
|
+
*/
|
|
177
|
+
export type INode = Pick<Node, keyof Node>;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { Permission } from '../permissions';
|
|
2
|
+
import { NodeStatus } from './node';
|
|
3
|
+
export interface Attribute {
|
|
4
|
+
[key: string]: any;
|
|
5
|
+
}
|
|
6
|
+
export interface NodeData {
|
|
7
|
+
/** Unique ID */
|
|
8
|
+
id?: number;
|
|
9
|
+
/**
|
|
10
|
+
* URL to the resource.
|
|
11
|
+
* e.g. https://cloud.domain.com/remote.php/dav/files/emma/Photos/picture.jpg
|
|
12
|
+
* or https://domain.com/Photos/picture.jpg
|
|
13
|
+
*/
|
|
14
|
+
source: string;
|
|
15
|
+
/** Last modified time */
|
|
16
|
+
mtime?: Date;
|
|
17
|
+
/** Creation time */
|
|
18
|
+
crtime?: Date;
|
|
19
|
+
/** The mime type Optional for folders only */
|
|
20
|
+
mime?: string;
|
|
21
|
+
/** The node size type */
|
|
22
|
+
size?: number;
|
|
23
|
+
/** The node permissions */
|
|
24
|
+
permissions?: Permission;
|
|
25
|
+
/** The owner UID of this node */
|
|
26
|
+
owner: string | null;
|
|
27
|
+
/** Optional the displayname of this node */
|
|
28
|
+
displayname?: string;
|
|
29
|
+
/** The node attributes */
|
|
30
|
+
attributes?: Attribute;
|
|
31
|
+
/**
|
|
32
|
+
* The absolute root of the home relative to the service.
|
|
33
|
+
* It is highly recommended to provide that information.
|
|
34
|
+
* e.g. /files/emma
|
|
35
|
+
*/
|
|
36
|
+
root?: string;
|
|
37
|
+
/** The node status */
|
|
38
|
+
status?: NodeStatus;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Check if a node source is from a specific DAV service
|
|
42
|
+
*
|
|
43
|
+
* @param source The source to check
|
|
44
|
+
* @param davService Pattern to check if source is DAV resource
|
|
45
|
+
*/
|
|
46
|
+
export declare const isDavResource: (source: string, davService: RegExp) => boolean;
|
|
47
|
+
/**
|
|
48
|
+
* Validate Node construct data
|
|
49
|
+
*
|
|
50
|
+
* @param data The node data
|
|
51
|
+
* @param davService Pattern to check if source is DAV ressource
|
|
52
|
+
*/
|
|
53
|
+
export declare const validateData: (data: NodeData, davService: RegExp) => void;
|