@nextcloud/files 3.9.2 → 3.10.0
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/README.md +63 -26
- package/dist/chunks/dav-BBwoJ8WE.cjs +703 -0
- package/dist/chunks/dav-BBwoJ8WE.cjs.map +1 -0
- package/dist/chunks/dav-DxfiR0wZ.mjs +704 -0
- package/dist/chunks/dav-DxfiR0wZ.mjs.map +1 -0
- package/dist/dav.cjs +19 -0
- package/dist/dav.cjs.map +1 -0
- package/dist/dav.d.ts +370 -0
- package/dist/dav.mjs +19 -0
- package/dist/dav.mjs.map +1 -0
- package/dist/index.cjs +106 -692
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1099 -39
- package/dist/index.mjs +410 -995
- package/dist/index.mjs.map +1 -1
- package/package.json +15 -10
- package/dist/dav/dav.d.ts +0 -56
- package/dist/dav/davPermissions.d.ts +0 -6
- package/dist/dav/davProperties.d.ts +0 -57
- package/dist/fileAction.d.ts +0 -79
- package/dist/fileListFilters.d.ts +0 -86
- package/dist/fileListHeaders.d.ts +0 -27
- package/dist/files/file.d.ts +0 -12
- package/dist/files/fileType.d.ts +0 -8
- package/dist/files/folder.d.ts +0 -18
- package/dist/files/node.d.ts +0 -166
- package/dist/files/nodeData.d.ts +0 -54
- package/dist/navigation/column.d.ts +0 -28
- package/dist/navigation/index.d.ts +0 -7
- package/dist/navigation/navigation.d.ts +0 -74
- package/dist/navigation/view.d.ts +0 -92
- package/dist/newFileMenu.d.ts +0 -66
- package/dist/permissions.d.ts +0 -16
- package/dist/utils/fileSize.d.ts +0 -25
- package/dist/utils/fileSorting.d.ts +0 -35
- package/dist/utils/filename-validation.d.ts +0 -51
- package/dist/utils/filename.d.ts +0 -24
- package/dist/utils/logger.d.ts +0 -2
- package/dist/utils/sorting.d.ts +0 -12
package/dist/index.d.ts
CHANGED
|
@@ -1,39 +1,1099 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
export
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
export
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
*/
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
*/
|
|
39
|
-
|
|
1
|
+
import { CancelablePromise } from 'cancelable-promise';
|
|
2
|
+
import { FileStat } from 'webdav';
|
|
3
|
+
import { TypedEventTarget } from 'typescript-event-target';
|
|
4
|
+
import { WebDAVClient } from 'webdav';
|
|
5
|
+
|
|
6
|
+
declare interface ActionContext {
|
|
7
|
+
folder: Folder;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Add a new menu entry to the upload manager menu
|
|
12
|
+
*
|
|
13
|
+
* @param entry The new file menu entry
|
|
14
|
+
*/
|
|
15
|
+
export declare const addNewFileMenuEntry: (entry: Entry) => void;
|
|
16
|
+
|
|
17
|
+
declare interface Attribute {
|
|
18
|
+
[key: string]: any;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export declare class Column implements ColumnData {
|
|
22
|
+
private _column;
|
|
23
|
+
constructor(column: ColumnData);
|
|
24
|
+
get id(): string;
|
|
25
|
+
get title(): string;
|
|
26
|
+
get render(): (node: Node_2, view: View) => HTMLElement;
|
|
27
|
+
get sort(): ((nodeA: Node_2, nodeB: Node_2) => number) | undefined;
|
|
28
|
+
get summary(): ((node: Node_2[], view: View) => string) | undefined;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
declare interface ColumnData {
|
|
32
|
+
/** Unique column ID */
|
|
33
|
+
id: string;
|
|
34
|
+
/** Translated column title */
|
|
35
|
+
title: string;
|
|
36
|
+
/** The content of the cell. The element will be appended within */
|
|
37
|
+
render: (node: Node_2, view: View) => HTMLElement;
|
|
38
|
+
/** Function used to sort Nodes between them */
|
|
39
|
+
sort?: (nodeA: Node_2, nodeB: Node_2) => number;
|
|
40
|
+
/**
|
|
41
|
+
* Custom summary of the column to display at the end of the list.
|
|
42
|
+
* Will not be displayed if nothing is provided
|
|
43
|
+
*/
|
|
44
|
+
summary?: (node: Node_2[], view: View) => string;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export declare type ContentsWithRoot = {
|
|
48
|
+
folder: Folder;
|
|
49
|
+
contents: Node_2[];
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Get a WebDAV client configured to include the Nextcloud request token
|
|
54
|
+
*
|
|
55
|
+
* @param remoteURL The DAV server remote URL
|
|
56
|
+
* @param headers Optional additional headers to set for every request
|
|
57
|
+
*/
|
|
58
|
+
export declare const davGetClient: (remoteURL?: string, headers?: Record<string, string>) => WebDAVClient;
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Get the default PROPFIND request body
|
|
62
|
+
*/
|
|
63
|
+
export declare const davGetDefaultPropfind: () => string;
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Get the REPORT body to filter for favorite nodes
|
|
67
|
+
*/
|
|
68
|
+
export declare const davGetFavoritesReport: () => string;
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Get the SEARCH body to search for recently modified files
|
|
72
|
+
*
|
|
73
|
+
* @param lastModified Oldest timestamp to include (Unix timestamp)
|
|
74
|
+
* @example
|
|
75
|
+
* ```ts
|
|
76
|
+
* // SEARCH for recent files need a different DAV endpoint
|
|
77
|
+
* const client = davGetClient(generateRemoteUrl('dav'))
|
|
78
|
+
* // Timestamp of last week
|
|
79
|
+
* const lastWeek = Math.round(Date.now() / 1000) - (60 * 60 * 24 * 7)
|
|
80
|
+
* const contentsResponse = await client.getDirectoryContents(path, {
|
|
81
|
+
* details: true,
|
|
82
|
+
* data: davGetRecentSearch(lastWeek),
|
|
83
|
+
* headers: {
|
|
84
|
+
* method: 'SEARCH',
|
|
85
|
+
* 'Content-Type': 'application/xml; charset=utf-8',
|
|
86
|
+
* },
|
|
87
|
+
* deep: true,
|
|
88
|
+
* }) as ResponseDataDetailed<FileStat[]>
|
|
89
|
+
* ```
|
|
90
|
+
*/
|
|
91
|
+
export declare const davGetRecentSearch: (lastModified: number) => string;
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Get the DAV remote URL used as base URL for the WebDAV client
|
|
95
|
+
* It also handles public shares
|
|
96
|
+
*/
|
|
97
|
+
export declare function davGetRemoteURL(): string;
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Get the DAV root path for the current user or public share
|
|
101
|
+
*/
|
|
102
|
+
export declare function davGetRootPath(): string;
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* Parse the WebDAV permission string to a permission enum
|
|
106
|
+
*
|
|
107
|
+
* @param permString The DAV permission string
|
|
108
|
+
*/
|
|
109
|
+
export declare const davParsePermissions: (permString?: string) => number;
|
|
110
|
+
|
|
111
|
+
export declare type DavProperty = {
|
|
112
|
+
[key: string]: string;
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* The DAV remote URL used as base URL for the WebDAV client
|
|
117
|
+
* This is a cached version of `getRemoteURL`
|
|
118
|
+
*/
|
|
119
|
+
export declare const davRemoteURL: string;
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* Covert DAV result `FileStat` to `Node`
|
|
123
|
+
*
|
|
124
|
+
* @param node The DAV result
|
|
125
|
+
* @param filesRoot The DAV files root path
|
|
126
|
+
* @param remoteURL The DAV server remote URL (same as on `getClient`)
|
|
127
|
+
*/
|
|
128
|
+
export declare const davResultToNode: (node: FileStat, filesRoot?: string, remoteURL?: string) => Node_2;
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* The DAV root path for the current user
|
|
132
|
+
* This is a cached version of `getRemoteURL`
|
|
133
|
+
*/
|
|
134
|
+
export declare const davRootPath: string;
|
|
135
|
+
|
|
136
|
+
export declare const defaultDavNamespaces: {
|
|
137
|
+
d: string;
|
|
138
|
+
nc: string;
|
|
139
|
+
oc: string;
|
|
140
|
+
ocs: string;
|
|
141
|
+
};
|
|
142
|
+
|
|
143
|
+
export declare const defaultDavProperties: string[];
|
|
144
|
+
|
|
145
|
+
export declare enum DefaultType {
|
|
146
|
+
DEFAULT = "default",
|
|
147
|
+
HIDDEN = "hidden"
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
export declare interface Entry {
|
|
151
|
+
/** Unique ID */
|
|
152
|
+
id: string;
|
|
153
|
+
/**
|
|
154
|
+
* Category to put this entry in
|
|
155
|
+
* (supported since Nextcloud 30)
|
|
156
|
+
* @since 3.3.0
|
|
157
|
+
* @default NewMenuEntryCategory.CreateNew
|
|
158
|
+
*/
|
|
159
|
+
category?: NewMenuEntryCategory;
|
|
160
|
+
/** Translatable string displayed in the menu */
|
|
161
|
+
displayName: string;
|
|
162
|
+
/**
|
|
163
|
+
* Condition wether this entry is shown or not
|
|
164
|
+
* @param context the creation context. Usually the current folder
|
|
165
|
+
*/
|
|
166
|
+
enabled?: (context: Folder) => boolean;
|
|
167
|
+
/**
|
|
168
|
+
* Either iconSvgInline or iconClass must be defined
|
|
169
|
+
* Svg as inline string. <svg><path fill="..." /></svg>
|
|
170
|
+
*/
|
|
171
|
+
iconSvgInline?: string;
|
|
172
|
+
/**
|
|
173
|
+
* Existing icon css class
|
|
174
|
+
* @deprecated use iconSvgInline instead
|
|
175
|
+
*/
|
|
176
|
+
iconClass?: string;
|
|
177
|
+
/** Order of the entry in the menu */
|
|
178
|
+
order?: number;
|
|
179
|
+
/**
|
|
180
|
+
* Function to be run after creation
|
|
181
|
+
* @param context the creation context. Usually the current folder
|
|
182
|
+
* @param content list of file/folders present in the context folder
|
|
183
|
+
*/
|
|
184
|
+
handler: (context: Folder, content: Node_2[]) => void;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
declare class File_2 extends Node_2 {
|
|
188
|
+
get type(): FileType;
|
|
189
|
+
/**
|
|
190
|
+
* Returns a clone of the file
|
|
191
|
+
*/
|
|
192
|
+
clone(): File_2;
|
|
193
|
+
}
|
|
194
|
+
export { File_2 as File }
|
|
195
|
+
|
|
196
|
+
export declare class FileAction {
|
|
197
|
+
private _action;
|
|
198
|
+
constructor(action: FileActionData);
|
|
199
|
+
get id(): string;
|
|
200
|
+
get displayName(): (files: Node_2[], view: View) => string;
|
|
201
|
+
get title(): ((files: Node_2[], view: View) => string) | undefined;
|
|
202
|
+
get iconSvgInline(): (files: Node_2[], view: View) => string;
|
|
203
|
+
get enabled(): ((files: Node_2[], view: View) => boolean) | undefined;
|
|
204
|
+
get exec(): (file: Node_2, view: View, dir: string) => Promise<boolean | null>;
|
|
205
|
+
get execBatch(): ((files: Node_2[], view: View, dir: string) => Promise<(boolean | null)[]>) | undefined;
|
|
206
|
+
get order(): number | undefined;
|
|
207
|
+
get parent(): string | undefined;
|
|
208
|
+
get default(): DefaultType | undefined;
|
|
209
|
+
get destructive(): boolean | undefined;
|
|
210
|
+
get inline(): ((file: Node_2, view: View) => boolean) | undefined;
|
|
211
|
+
get renderInline(): ((file: Node_2, view: View) => Promise<HTMLElement | null>) | undefined;
|
|
212
|
+
private validateAction;
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
declare interface FileActionData {
|
|
216
|
+
/** Unique ID */
|
|
217
|
+
id: string;
|
|
218
|
+
/** Translatable string displayed in the menu */
|
|
219
|
+
displayName: (files: Node_2[], view: View) => string;
|
|
220
|
+
/** Translatable title for of the action */
|
|
221
|
+
title?: (files: Node_2[], view: View) => string;
|
|
222
|
+
/** Svg as inline string. <svg><path fill="..." /></svg> */
|
|
223
|
+
iconSvgInline: (files: Node_2[], view: View) => string;
|
|
224
|
+
/** Condition wether this action is shown or not */
|
|
225
|
+
enabled?: (files: Node_2[], view: View) => boolean;
|
|
226
|
+
/**
|
|
227
|
+
* Function executed on single file action
|
|
228
|
+
* @return true if the action was executed successfully,
|
|
229
|
+
* false otherwise and null if the action is silent/undefined.
|
|
230
|
+
* @throws Error if the action failed
|
|
231
|
+
*/
|
|
232
|
+
exec: (file: Node_2, view: View, dir: string) => Promise<boolean | null>;
|
|
233
|
+
/**
|
|
234
|
+
* Function executed on multiple files action
|
|
235
|
+
* @return true if the action was executed successfully,
|
|
236
|
+
* false otherwise and null if the action is silent/undefined.
|
|
237
|
+
* @throws Error if the action failed
|
|
238
|
+
*/
|
|
239
|
+
execBatch?: (files: Node_2[], view: View, dir: string) => Promise<(boolean | null)[]>;
|
|
240
|
+
/** This action order in the list */
|
|
241
|
+
order?: number;
|
|
242
|
+
/**
|
|
243
|
+
* Set to true if this action is a destructive action, like "delete".
|
|
244
|
+
* This will change the appearance in the action menu more prominent (e.g. red colored)
|
|
245
|
+
*/
|
|
246
|
+
destructive?: boolean;
|
|
247
|
+
/**
|
|
248
|
+
* This action's parent id in the list.
|
|
249
|
+
* If none found, will be displayed as a top-level action.
|
|
250
|
+
*/
|
|
251
|
+
parent?: string;
|
|
252
|
+
/**
|
|
253
|
+
* Make this action the default.
|
|
254
|
+
* If multiple actions are default, the first one
|
|
255
|
+
* will be used. The other ones will be put as first
|
|
256
|
+
* entries in the actions menu iff DefaultType.Hidden is not used.
|
|
257
|
+
* A DefaultType.Hidden action will never be shown
|
|
258
|
+
* in the actions menu even if another action takes
|
|
259
|
+
* its place as default.
|
|
260
|
+
*/
|
|
261
|
+
default?: DefaultType;
|
|
262
|
+
/**
|
|
263
|
+
* If true, the renderInline function will be called
|
|
264
|
+
*/
|
|
265
|
+
inline?: (file: Node_2, view: View) => boolean;
|
|
266
|
+
/**
|
|
267
|
+
* If defined, the returned html element will be
|
|
268
|
+
* appended before the actions menu.
|
|
269
|
+
*/
|
|
270
|
+
renderInline?: (file: Node_2, view: View) => Promise<HTMLElement | null>;
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
export declare class FileListAction {
|
|
274
|
+
private _action;
|
|
275
|
+
constructor(action: FileListActionData);
|
|
276
|
+
get id(): string;
|
|
277
|
+
get displayName(): (view: View) => string;
|
|
278
|
+
get iconSvgInline(): (view: View) => string;
|
|
279
|
+
get order(): number;
|
|
280
|
+
get enabled(): ((view: View, nodes: Node_2[], context: ActionContext) => boolean) | undefined;
|
|
281
|
+
get exec(): (view: View, nodes: Node_2[], context: ActionContext) => Promise<void>;
|
|
282
|
+
private validateAction;
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
declare interface FileListActionData {
|
|
286
|
+
/** Unique ID */
|
|
287
|
+
id: string;
|
|
288
|
+
/** Translated name of the action */
|
|
289
|
+
displayName: (view: View) => string;
|
|
290
|
+
/** Raw svg string */
|
|
291
|
+
iconSvgInline: (view: View) => string;
|
|
292
|
+
/** Sort order */
|
|
293
|
+
order: number;
|
|
294
|
+
/**
|
|
295
|
+
* Returns true if this action shoud be shown
|
|
296
|
+
*
|
|
297
|
+
* @param nodes The nodes in the current directory
|
|
298
|
+
* @param context The context
|
|
299
|
+
* @param context.folder The current folder
|
|
300
|
+
*/
|
|
301
|
+
enabled?: (view: View, nodes: Node_2[], context: ActionContext) => boolean;
|
|
302
|
+
/**
|
|
303
|
+
* Function to execute
|
|
304
|
+
*
|
|
305
|
+
* @param nodes The nodes in the current directory
|
|
306
|
+
* @param context The context
|
|
307
|
+
* @param context.folder The current folder
|
|
308
|
+
*/
|
|
309
|
+
exec: (view: View, nodes: Node_2[], context: ActionContext) => Promise<void>;
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
export declare class FileListFilter extends TypedEventTarget<IFileListFilterEvents> implements IFileListFilter {
|
|
313
|
+
id: string;
|
|
314
|
+
order: number;
|
|
315
|
+
constructor(id: string, order?: number);
|
|
316
|
+
filter(nodes: INode[]): INode[];
|
|
317
|
+
protected updateChips(chips: IFileListFilterChip[]): void;
|
|
318
|
+
protected filterUpdated(): void;
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
export declare enum FilesSortingMode {
|
|
322
|
+
Name = "basename",
|
|
323
|
+
Modified = "mtime",
|
|
324
|
+
Size = "size"
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
export declare interface FilesSortingOptions {
|
|
328
|
+
/**
|
|
329
|
+
* They key to order the files by
|
|
330
|
+
* @default FilesSortingMode.Name
|
|
331
|
+
*/
|
|
332
|
+
sortingMode?: FilesSortingMode;
|
|
333
|
+
/**
|
|
334
|
+
* @default 'asc'
|
|
335
|
+
*/
|
|
336
|
+
sortingOrder?: SortingOrder;
|
|
337
|
+
/**
|
|
338
|
+
* If set to true nodes marked as favorites are ordered on top of all other nodes
|
|
339
|
+
* @default false
|
|
340
|
+
*/
|
|
341
|
+
sortFavoritesFirst?: boolean;
|
|
342
|
+
/**
|
|
343
|
+
* If set to true folders are ordered on top of files
|
|
344
|
+
* @default false
|
|
345
|
+
*/
|
|
346
|
+
sortFoldersFirst?: boolean;
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
/**
|
|
350
|
+
* SPDX-FileCopyrightText: 2022 Nextcloud GmbH and Nextcloud contributors
|
|
351
|
+
* SPDX-License-Identifier: AGPL-3.0-or-later
|
|
352
|
+
*/
|
|
353
|
+
export declare enum FileType {
|
|
354
|
+
Folder = "folder",
|
|
355
|
+
File = "file"
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
/**
|
|
359
|
+
* This event is emitted when the the filter value changed and the file list needs to be updated
|
|
360
|
+
*/
|
|
361
|
+
export declare interface FilterUpdateChipsEvent extends CustomEvent<IFileListFilterChip[]> {
|
|
362
|
+
type: 'update:chips';
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
/**
|
|
366
|
+
* This event is emitted when the the filter value changed and the file list needs to be updated
|
|
367
|
+
*/
|
|
368
|
+
export declare interface FilterUpdateEvent extends CustomEvent<never> {
|
|
369
|
+
type: 'update:filter';
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
export declare class Folder extends Node_2 {
|
|
373
|
+
constructor(data: NodeData);
|
|
374
|
+
get type(): FileType;
|
|
375
|
+
get extension(): string | null;
|
|
376
|
+
get mime(): string;
|
|
377
|
+
/**
|
|
378
|
+
* Returns a clone of the folder
|
|
379
|
+
*/
|
|
380
|
+
clone(): Node_2;
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
/**
|
|
384
|
+
* SPDX-FileCopyrightText: 2019 Nextcloud GmbH and Nextcloud contributors
|
|
385
|
+
* SPDX-License-Identifier: AGPL-3.0-or-later
|
|
386
|
+
*/
|
|
387
|
+
/**
|
|
388
|
+
* Format a file size in a human-like format. e.g. 42GB
|
|
389
|
+
*
|
|
390
|
+
* The default for Nextcloud is like Windows using binary sizes but showing decimal units,
|
|
391
|
+
* meaning 1024 bytes will show as 1KB instead of 1KiB or like on Apple 1.02 KB
|
|
392
|
+
*
|
|
393
|
+
* @param size in bytes
|
|
394
|
+
* @param skipSmallSizes avoid rendering tiny sizes and return '< 1 KB' instead
|
|
395
|
+
* @param binaryPrefixes True if size binary prefixes like `KiB` should be used as per IEC 80000-13
|
|
396
|
+
* @param base1000 Set to true to use base 1000 as per SI or used by Apple (default is base 1024 like Linux or Windows)
|
|
397
|
+
*/
|
|
398
|
+
export declare function formatFileSize(size: number | string, skipSmallSizes?: boolean, binaryPrefixes?: boolean, base1000?: boolean): string;
|
|
399
|
+
|
|
400
|
+
/**
|
|
401
|
+
* Get the registered dav namespaces
|
|
402
|
+
*/
|
|
403
|
+
export declare const getDavNameSpaces: () => string;
|
|
404
|
+
|
|
405
|
+
/**
|
|
406
|
+
* Get the registered dav properties
|
|
407
|
+
*/
|
|
408
|
+
export declare const getDavProperties: () => string;
|
|
409
|
+
|
|
410
|
+
/**
|
|
411
|
+
* Use WebDAV to query for favorite Nodes
|
|
412
|
+
*
|
|
413
|
+
* @param davClient The WebDAV client to use for performing the request
|
|
414
|
+
* @param path Base path for the favorites, if unset all favorites are queried
|
|
415
|
+
* @param davRoot The root path for the DAV user (defaults to `defaultRootPath`)
|
|
416
|
+
* @example
|
|
417
|
+
* ```js
|
|
418
|
+
* import { getClient, defaultRootPath, getFavoriteNodes } from '@nextcloud/files'
|
|
419
|
+
*
|
|
420
|
+
* const client = getClient()
|
|
421
|
+
* // query favorites for the root
|
|
422
|
+
* const favorites = await getFavoriteNodes(client)
|
|
423
|
+
* // which is the same as writing:
|
|
424
|
+
* const favorites = await getFavoriteNodes(client, '/', defaultRootPath)
|
|
425
|
+
* ```
|
|
426
|
+
*/
|
|
427
|
+
export declare const getFavoriteNodes: (davClient: WebDAVClient, path?: string, davRoot?: string) => CancelablePromise<Node_2[]>;
|
|
428
|
+
|
|
429
|
+
export declare const getFileActions: () => FileAction[];
|
|
430
|
+
|
|
431
|
+
export declare const getFileListActions: () => FileListAction[];
|
|
432
|
+
|
|
433
|
+
/**
|
|
434
|
+
* Get all registered file list filters
|
|
435
|
+
*/
|
|
436
|
+
export declare function getFileListFilters(): IFileListFilter[];
|
|
437
|
+
|
|
438
|
+
export declare const getFileListHeaders: () => Header[];
|
|
439
|
+
|
|
440
|
+
/**
|
|
441
|
+
* Get the current files navigation
|
|
442
|
+
*/
|
|
443
|
+
export declare const getNavigation: () => Navigation;
|
|
444
|
+
|
|
445
|
+
/**
|
|
446
|
+
* Get the list of registered entries from the upload menu
|
|
447
|
+
*
|
|
448
|
+
* @param {Folder} context the creation context. Usually the current folder FileInfo
|
|
449
|
+
*/
|
|
450
|
+
export declare const getNewFileMenuEntries: (context?: Folder) => Entry[];
|
|
451
|
+
|
|
452
|
+
/**
|
|
453
|
+
* Create an unique file name
|
|
454
|
+
* @param name The initial name to use
|
|
455
|
+
* @param otherNames Other names that are already used
|
|
456
|
+
* @param options Optional parameters for tuning the behavior
|
|
457
|
+
* @return {string} Either the initial name, if unique, or the name with the suffix so that the name is unique
|
|
458
|
+
*/
|
|
459
|
+
export declare function getUniqueName(name: string, otherNames: string[], options?: UniqueNameOptions): string;
|
|
460
|
+
|
|
461
|
+
export declare class Header {
|
|
462
|
+
private _header;
|
|
463
|
+
constructor(header: HeaderData);
|
|
464
|
+
get id(): string;
|
|
465
|
+
get order(): number;
|
|
466
|
+
get enabled(): ((folder: Folder, view: View) => boolean) | undefined;
|
|
467
|
+
get render(): (el: HTMLElement, folder: Folder, view: View) => void;
|
|
468
|
+
get updated(): (folder: Folder, view: View) => any;
|
|
469
|
+
private validateHeader;
|
|
470
|
+
}
|
|
471
|
+
|
|
472
|
+
declare interface HeaderData {
|
|
473
|
+
/** Unique ID */
|
|
474
|
+
id: string;
|
|
475
|
+
/** Order */
|
|
476
|
+
order: number;
|
|
477
|
+
/** Condition wether this header is shown or not */
|
|
478
|
+
enabled?: (folder: Folder, view: View) => boolean;
|
|
479
|
+
/** Executed when file list is initialized */
|
|
480
|
+
render: (el: HTMLElement, folder: Folder, view: View) => void;
|
|
481
|
+
/** Executed when root folder changed */
|
|
482
|
+
updated(folder: Folder, view: View): any;
|
|
483
|
+
}
|
|
484
|
+
|
|
485
|
+
declare type IdentifierFn<T> = (v: T) => unknown;
|
|
486
|
+
|
|
487
|
+
/**
|
|
488
|
+
* Interface of the File class
|
|
489
|
+
*/
|
|
490
|
+
export declare interface IFile extends INode {
|
|
491
|
+
readonly type: FileType.File;
|
|
492
|
+
}
|
|
493
|
+
|
|
494
|
+
export declare interface IFileListFilter extends TypedEventTarget<IFileListFilterEvents> {
|
|
495
|
+
/**
|
|
496
|
+
* Unique ID of this filter
|
|
497
|
+
*/
|
|
498
|
+
readonly id: string;
|
|
499
|
+
/**
|
|
500
|
+
* Order of the filter
|
|
501
|
+
*
|
|
502
|
+
* Use a low number to make this filter ordered in front.
|
|
503
|
+
*/
|
|
504
|
+
readonly order: number;
|
|
505
|
+
/**
|
|
506
|
+
* Filter function to decide if a node is shown.
|
|
507
|
+
*
|
|
508
|
+
* @param nodes Nodes to filter
|
|
509
|
+
* @return Subset of the `nodes` parameter to show
|
|
510
|
+
*/
|
|
511
|
+
filter(nodes: INode[]): INode[];
|
|
512
|
+
/**
|
|
513
|
+
* If the filter needs a visual element for settings it can provide a function to mount it.
|
|
514
|
+
* @param el The DOM element to mount to
|
|
515
|
+
*/
|
|
516
|
+
mount?(el: HTMLElement): void;
|
|
517
|
+
/**
|
|
518
|
+
* Reset the filter to the initial state.
|
|
519
|
+
* This is called by the files app.
|
|
520
|
+
* Implementations should make sure,that if they provide chips they need to emit the `update:chips` event.
|
|
521
|
+
*
|
|
522
|
+
* @since 3.10.0
|
|
523
|
+
*/
|
|
524
|
+
reset?(): void;
|
|
525
|
+
}
|
|
526
|
+
|
|
527
|
+
/**
|
|
528
|
+
* Active filters can provide one or more "chips" to show the currently active state.
|
|
529
|
+
* Must at least provide a text representing the filters state and a callback to unset that state (disable this filter).
|
|
530
|
+
*/
|
|
531
|
+
export declare interface IFileListFilterChip {
|
|
532
|
+
/**
|
|
533
|
+
* Text of the chip
|
|
534
|
+
*/
|
|
535
|
+
text: string;
|
|
536
|
+
/**
|
|
537
|
+
* Optional icon to be used on the chip (inline SVG as string)
|
|
538
|
+
*/
|
|
539
|
+
icon?: string;
|
|
540
|
+
/**
|
|
541
|
+
* Optional pass a user id to use a user avatar instead of an icon
|
|
542
|
+
*/
|
|
543
|
+
user?: string;
|
|
544
|
+
/**
|
|
545
|
+
* Handler to be called on click
|
|
546
|
+
*/
|
|
547
|
+
onclick: () => void;
|
|
548
|
+
}
|
|
549
|
+
|
|
550
|
+
declare interface IFileListFilterEvents {
|
|
551
|
+
[name: string]: CustomEvent;
|
|
552
|
+
'update:filter': FilterUpdateEvent;
|
|
553
|
+
'update:chips': FilterUpdateChipsEvent;
|
|
554
|
+
}
|
|
555
|
+
|
|
556
|
+
/**
|
|
557
|
+
* Interface of the folder class
|
|
558
|
+
*/
|
|
559
|
+
export declare interface IFolder extends INode {
|
|
560
|
+
readonly type: FileType.Folder;
|
|
561
|
+
readonly extension: null;
|
|
562
|
+
readonly mime: 'httpd/unix-directory';
|
|
563
|
+
}
|
|
564
|
+
|
|
565
|
+
/**
|
|
566
|
+
* Interface of the node class
|
|
567
|
+
*/
|
|
568
|
+
export declare type INode = Pick<Node_2, keyof Node_2>;
|
|
569
|
+
|
|
570
|
+
export declare class InvalidFilenameError extends Error {
|
|
571
|
+
constructor(options: InvalidFilenameErrorOptions);
|
|
572
|
+
/**
|
|
573
|
+
* The filename that was validated
|
|
574
|
+
*/
|
|
575
|
+
get filename(): string;
|
|
576
|
+
/**
|
|
577
|
+
* Reason why the validation failed
|
|
578
|
+
*/
|
|
579
|
+
get reason(): InvalidFilenameErrorReason;
|
|
580
|
+
/**
|
|
581
|
+
* Part of the filename that caused this error
|
|
582
|
+
*/
|
|
583
|
+
get segment(): string;
|
|
584
|
+
}
|
|
585
|
+
|
|
586
|
+
declare interface InvalidFilenameErrorOptions {
|
|
587
|
+
/**
|
|
588
|
+
* The filename that was validated
|
|
589
|
+
*/
|
|
590
|
+
filename: string;
|
|
591
|
+
/**
|
|
592
|
+
* Reason why the validation failed
|
|
593
|
+
*/
|
|
594
|
+
reason: InvalidFilenameErrorReason;
|
|
595
|
+
/**
|
|
596
|
+
* Part of the filename that caused this error
|
|
597
|
+
*/
|
|
598
|
+
segment: string;
|
|
599
|
+
}
|
|
600
|
+
|
|
601
|
+
/**
|
|
602
|
+
* SPDX-FileCopyrightText: Nextcloud GmbH and Nextcloud contributors
|
|
603
|
+
* SPDX-License-Identifier: AGPL-3.0-or-later or LGPL-3.0-or-later
|
|
604
|
+
*/
|
|
605
|
+
export declare enum InvalidFilenameErrorReason {
|
|
606
|
+
ReservedName = "reserved name",
|
|
607
|
+
Character = "character",
|
|
608
|
+
Extension = "extension"
|
|
609
|
+
}
|
|
610
|
+
|
|
611
|
+
/**
|
|
612
|
+
* Check the validity of a filename
|
|
613
|
+
* This is a convinient wrapper for `checkFilenameValidity` to only return a boolean for the valid
|
|
614
|
+
* @param filename Filename to check validity
|
|
615
|
+
*/
|
|
616
|
+
export declare function isFilenameValid(filename: string): boolean;
|
|
617
|
+
|
|
618
|
+
/**
|
|
619
|
+
* The files navigation manages the available and active views
|
|
620
|
+
*
|
|
621
|
+
* Custom views for the files app can be registered (examples are the favorites views or the shared-with-you view).
|
|
622
|
+
* It is also possible to listen on changes of the registered views or when the current active view is changed.
|
|
623
|
+
* @example
|
|
624
|
+
* ```js
|
|
625
|
+
* const navigation = getNavigation()
|
|
626
|
+
* navigation.addEventListener('update', () => {
|
|
627
|
+
* // This will be called whenever a new view is registered or a view is removed
|
|
628
|
+
* const viewNames = navigation.views.map((view) => view.name)
|
|
629
|
+
* console.warn('Registered views changed', viewNames)
|
|
630
|
+
* })
|
|
631
|
+
* // Or you can react to changes of the current active view
|
|
632
|
+
* navigation.addEventListener('updateActive', (event) => {
|
|
633
|
+
* // This will be called whenever the active view changed
|
|
634
|
+
* const newView = event.detail // you could also use `navigation.active`
|
|
635
|
+
* console.warn('Active view changed to ' + newView.name)
|
|
636
|
+
* })
|
|
637
|
+
* ```
|
|
638
|
+
*/
|
|
639
|
+
export declare class Navigation extends TypedEventTarget<{
|
|
640
|
+
updateActive: UpdateActiveViewEvent;
|
|
641
|
+
update: UpdateViewsEvent;
|
|
642
|
+
}> {
|
|
643
|
+
private _views;
|
|
644
|
+
private _currentView;
|
|
645
|
+
/**
|
|
646
|
+
* Register a new view on the navigation
|
|
647
|
+
* @param view The view to register
|
|
648
|
+
* @throws `Error` is thrown if a view with the same id is already registered
|
|
649
|
+
*/
|
|
650
|
+
register(view: View): void;
|
|
651
|
+
/**
|
|
652
|
+
* Remove a registered view
|
|
653
|
+
* @param id The id of the view to remove
|
|
654
|
+
*/
|
|
655
|
+
remove(id: string): void;
|
|
656
|
+
/**
|
|
657
|
+
* Set the currently active view
|
|
658
|
+
* @fires UpdateActiveViewEvent
|
|
659
|
+
* @param view New active view
|
|
660
|
+
*/
|
|
661
|
+
setActive(view: View | null): void;
|
|
662
|
+
/**
|
|
663
|
+
* The currently active files view
|
|
664
|
+
*/
|
|
665
|
+
get active(): View | null;
|
|
666
|
+
/**
|
|
667
|
+
* All registered views
|
|
668
|
+
*/
|
|
669
|
+
get views(): View[];
|
|
670
|
+
}
|
|
671
|
+
|
|
672
|
+
export declare enum NewMenuEntryCategory {
|
|
673
|
+
/**
|
|
674
|
+
* For actions where the user is intended to upload from their device
|
|
675
|
+
*/
|
|
676
|
+
UploadFromDevice = 0,
|
|
677
|
+
/**
|
|
678
|
+
* For actions that create new nodes on the server without uploading
|
|
679
|
+
*/
|
|
680
|
+
CreateNew = 1,
|
|
681
|
+
/**
|
|
682
|
+
* For everything not matching the other categories
|
|
683
|
+
*/
|
|
684
|
+
Other = 2
|
|
685
|
+
}
|
|
686
|
+
|
|
687
|
+
declare abstract class Node_2 {
|
|
688
|
+
private _data;
|
|
689
|
+
private _attributes;
|
|
690
|
+
private _knownDavService;
|
|
691
|
+
private readonlyAttributes;
|
|
692
|
+
private handler;
|
|
693
|
+
constructor(data: NodeData, davService?: RegExp);
|
|
694
|
+
/**
|
|
695
|
+
* Get the source url to this object
|
|
696
|
+
* There is no setter as the source is not meant to be changed manually.
|
|
697
|
+
* You can use the rename or move method to change the source.
|
|
698
|
+
*/
|
|
699
|
+
get source(): string;
|
|
700
|
+
/**
|
|
701
|
+
* Get the encoded source url to this object for requests purposes
|
|
702
|
+
*/
|
|
703
|
+
get encodedSource(): string;
|
|
704
|
+
/**
|
|
705
|
+
* Get this object name
|
|
706
|
+
* There is no setter as the source is not meant to be changed manually.
|
|
707
|
+
* You can use the rename or move method to change the source.
|
|
708
|
+
*/
|
|
709
|
+
get basename(): string;
|
|
710
|
+
/**
|
|
711
|
+
* The nodes displayname
|
|
712
|
+
* By default the display name and the `basename` are identical,
|
|
713
|
+
* but it is possible to have a different name. This happens
|
|
714
|
+
* on the files app for example for shared folders.
|
|
715
|
+
*/
|
|
716
|
+
get displayname(): string;
|
|
717
|
+
/**
|
|
718
|
+
* Set the displayname
|
|
719
|
+
*/
|
|
720
|
+
set displayname(displayname: string);
|
|
721
|
+
/**
|
|
722
|
+
* Get this object's extension
|
|
723
|
+
* There is no setter as the source is not meant to be changed manually.
|
|
724
|
+
* You can use the rename or move method to change the source.
|
|
725
|
+
*/
|
|
726
|
+
get extension(): string | null;
|
|
727
|
+
/**
|
|
728
|
+
* Get the directory path leading to this object
|
|
729
|
+
* Will use the relative path to root if available
|
|
730
|
+
*
|
|
731
|
+
* There is no setter as the source is not meant to be changed manually.
|
|
732
|
+
* You can use the rename or move method to change the source.
|
|
733
|
+
*/
|
|
734
|
+
get dirname(): string;
|
|
735
|
+
/**
|
|
736
|
+
* Is it a file or a folder ?
|
|
737
|
+
*/
|
|
738
|
+
abstract get type(): FileType;
|
|
739
|
+
/**
|
|
740
|
+
* Get the file mime
|
|
741
|
+
* There is no setter as the mime is not meant to be changed
|
|
742
|
+
*/
|
|
743
|
+
get mime(): string | undefined;
|
|
744
|
+
/**
|
|
745
|
+
* Get the file modification time
|
|
746
|
+
*/
|
|
747
|
+
get mtime(): Date | undefined;
|
|
748
|
+
/**
|
|
749
|
+
* Set the file modification time
|
|
750
|
+
*/
|
|
751
|
+
set mtime(mtime: Date | undefined);
|
|
752
|
+
/**
|
|
753
|
+
* Get the file creation time
|
|
754
|
+
* There is no setter as the creation time is not meant to be changed
|
|
755
|
+
*/
|
|
756
|
+
get crtime(): Date | undefined;
|
|
757
|
+
/**
|
|
758
|
+
* Get the file size
|
|
759
|
+
*/
|
|
760
|
+
get size(): number | undefined;
|
|
761
|
+
/**
|
|
762
|
+
* Set the file size
|
|
763
|
+
*/
|
|
764
|
+
set size(size: number | undefined);
|
|
765
|
+
/**
|
|
766
|
+
* Get the file attribute
|
|
767
|
+
* This contains all additional attributes not provided by the Node class
|
|
768
|
+
*/
|
|
769
|
+
get attributes(): Attribute;
|
|
770
|
+
/**
|
|
771
|
+
* Get the file permissions
|
|
772
|
+
*/
|
|
773
|
+
get permissions(): Permission;
|
|
774
|
+
/**
|
|
775
|
+
* Set the file permissions
|
|
776
|
+
*/
|
|
777
|
+
set permissions(permissions: Permission);
|
|
778
|
+
/**
|
|
779
|
+
* Get the file owner
|
|
780
|
+
* There is no setter as the owner is not meant to be changed
|
|
781
|
+
*/
|
|
782
|
+
get owner(): string | null;
|
|
783
|
+
/**
|
|
784
|
+
* Is this a dav-related ressource ?
|
|
785
|
+
*/
|
|
786
|
+
get isDavRessource(): boolean;
|
|
787
|
+
/**
|
|
788
|
+
* Get the dav root of this object
|
|
789
|
+
* There is no setter as the root is not meant to be changed
|
|
790
|
+
*/
|
|
791
|
+
get root(): string | null;
|
|
792
|
+
/**
|
|
793
|
+
* Get the absolute path of this object relative to the root
|
|
794
|
+
*/
|
|
795
|
+
get path(): string;
|
|
796
|
+
/**
|
|
797
|
+
* Get the node id if defined.
|
|
798
|
+
* There is no setter as the fileid is not meant to be changed
|
|
799
|
+
*/
|
|
800
|
+
get fileid(): number | undefined;
|
|
801
|
+
/**
|
|
802
|
+
* Get the node status.
|
|
803
|
+
*/
|
|
804
|
+
get status(): NodeStatus | undefined;
|
|
805
|
+
/**
|
|
806
|
+
* Set the node status.
|
|
807
|
+
*/
|
|
808
|
+
set status(status: NodeStatus | undefined);
|
|
809
|
+
/**
|
|
810
|
+
* Get the node data
|
|
811
|
+
*/
|
|
812
|
+
get data(): NodeData;
|
|
813
|
+
/**
|
|
814
|
+
* Move the node to a new destination
|
|
815
|
+
*
|
|
816
|
+
* @param {string} destination the new source.
|
|
817
|
+
* e.g. https://cloud.domain.com/remote.php/dav/files/emma/Photos/picture.jpg
|
|
818
|
+
*/
|
|
819
|
+
move(destination: string): void;
|
|
820
|
+
/**
|
|
821
|
+
* Rename the node
|
|
822
|
+
* This aliases the move method for easier usage
|
|
823
|
+
*
|
|
824
|
+
* @param basename The new name of the node
|
|
825
|
+
*/
|
|
826
|
+
rename(basename: string): void;
|
|
827
|
+
/**
|
|
828
|
+
* Update the mtime if exists
|
|
829
|
+
*/
|
|
830
|
+
updateMtime(): void;
|
|
831
|
+
/**
|
|
832
|
+
* Update the attributes of the node
|
|
833
|
+
* Warning, updating attributes will NOT automatically update the mtime.
|
|
834
|
+
*
|
|
835
|
+
* @param attributes The new attributes to update on the Node attributes
|
|
836
|
+
*/
|
|
837
|
+
update(attributes: Attribute): void;
|
|
838
|
+
/**
|
|
839
|
+
* Returns a clone of the node
|
|
840
|
+
*/
|
|
841
|
+
abstract clone(): Node_2;
|
|
842
|
+
}
|
|
843
|
+
export { Node_2 as Node }
|
|
844
|
+
|
|
845
|
+
export declare interface NodeData {
|
|
846
|
+
/** Unique ID */
|
|
847
|
+
id?: number;
|
|
848
|
+
/**
|
|
849
|
+
* URL to the ressource.
|
|
850
|
+
* e.g. https://cloud.domain.com/remote.php/dav/files/emma/Photos/picture.jpg
|
|
851
|
+
* or https://domain.com/Photos/picture.jpg
|
|
852
|
+
*/
|
|
853
|
+
source: string;
|
|
854
|
+
/** Last modified time */
|
|
855
|
+
mtime?: Date;
|
|
856
|
+
/** Creation time */
|
|
857
|
+
crtime?: Date;
|
|
858
|
+
/** The mime type Optional for folders only */
|
|
859
|
+
mime?: string;
|
|
860
|
+
/** The node size type */
|
|
861
|
+
size?: number;
|
|
862
|
+
/** The node permissions */
|
|
863
|
+
permissions?: Permission;
|
|
864
|
+
/** The owner UID of this node */
|
|
865
|
+
owner: string | null;
|
|
866
|
+
/** Optional the displayname of this node */
|
|
867
|
+
displayname?: string;
|
|
868
|
+
/** The node attributes */
|
|
869
|
+
attributes?: Attribute;
|
|
870
|
+
/**
|
|
871
|
+
* The absolute root of the home relative to the service.
|
|
872
|
+
* It is highly recommended to provide that information.
|
|
873
|
+
* e.g. /files/emma
|
|
874
|
+
*/
|
|
875
|
+
root?: string;
|
|
876
|
+
/** The node status */
|
|
877
|
+
status?: NodeStatus;
|
|
878
|
+
}
|
|
879
|
+
|
|
880
|
+
export declare enum NodeStatus {
|
|
881
|
+
/** This is a new node and it doesn't exists on the filesystem yet */
|
|
882
|
+
NEW = "new",
|
|
883
|
+
/** This node has failed and is unavailable */
|
|
884
|
+
FAILED = "failed",
|
|
885
|
+
/** This node is currently loading or have an operation in progress */
|
|
886
|
+
LOADING = "loading",
|
|
887
|
+
/** This node is locked and cannot be modified */
|
|
888
|
+
LOCKED = "locked"
|
|
889
|
+
}
|
|
890
|
+
|
|
891
|
+
/**
|
|
892
|
+
* Natural order a collection
|
|
893
|
+
* You can define identifiers as callback functions, that get the element and return the value to sort.
|
|
894
|
+
*
|
|
895
|
+
* @param collection The collection to order
|
|
896
|
+
* @param identifiers An array of identifiers to use, by default the identity of the element is used
|
|
897
|
+
* @param orders Array of orders, by default all identifiers are sorted ascening
|
|
898
|
+
*/
|
|
899
|
+
export declare function orderBy<T>(collection: readonly T[], identifiers?: IdentifierFn<T>[], orders?: SortingOrder[]): T[];
|
|
900
|
+
|
|
901
|
+
/**
|
|
902
|
+
* Returns a file size in bytes from a humanly readable string
|
|
903
|
+
* Note: `b` and `B` are both parsed as bytes and not as bit or byte.
|
|
904
|
+
*
|
|
905
|
+
* @param {string} value file size in human-readable format
|
|
906
|
+
* @param {boolean} forceBinary for backwards compatibility this allows values to be base 2 (so 2KB means 2048 bytes instead of 2000 bytes)
|
|
907
|
+
* @return {number} or null if string could not be parsed
|
|
908
|
+
*/
|
|
909
|
+
export declare function parseFileSize(value: string, forceBinary?: boolean): number | null;
|
|
910
|
+
|
|
911
|
+
/**
|
|
912
|
+
* SPDX-FileCopyrightText: 2022 Nextcloud GmbH and Nextcloud contributors
|
|
913
|
+
* SPDX-License-Identifier: AGPL-3.0-or-later
|
|
914
|
+
*/
|
|
915
|
+
/**
|
|
916
|
+
* Node permissions
|
|
917
|
+
*/
|
|
918
|
+
export declare enum Permission {
|
|
919
|
+
NONE = 0,
|
|
920
|
+
CREATE = 4,
|
|
921
|
+
READ = 1,
|
|
922
|
+
UPDATE = 2,
|
|
923
|
+
DELETE = 8,
|
|
924
|
+
SHARE = 16,
|
|
925
|
+
ALL = 31
|
|
926
|
+
}
|
|
927
|
+
|
|
928
|
+
/**
|
|
929
|
+
* Register custom DAV properties
|
|
930
|
+
*
|
|
931
|
+
* Can be used if your app introduces custom DAV properties, so e.g. the files app can make use of it.
|
|
932
|
+
*
|
|
933
|
+
* @param prop The property
|
|
934
|
+
* @param namespace The namespace of the property
|
|
935
|
+
*/
|
|
936
|
+
export declare const registerDavProperty: (prop: string, namespace?: DavProperty) => boolean;
|
|
937
|
+
|
|
938
|
+
export declare const registerFileAction: (action: FileAction) => void;
|
|
939
|
+
|
|
940
|
+
export declare const registerFileListAction: (action: FileListAction) => void;
|
|
941
|
+
|
|
942
|
+
/**
|
|
943
|
+
* Register a new filter on the file list
|
|
944
|
+
*
|
|
945
|
+
* This only must be called once to register the filter,
|
|
946
|
+
* when the filter state changes you need to call `filterUpdated` on the filter instead.
|
|
947
|
+
*
|
|
948
|
+
* @param filter The filter to register on the file list
|
|
949
|
+
*/
|
|
950
|
+
export declare function registerFileListFilter(filter: IFileListFilter): void;
|
|
951
|
+
|
|
952
|
+
export declare const registerFileListHeaders: (header: Header) => void;
|
|
953
|
+
|
|
954
|
+
/**
|
|
955
|
+
* Remove a previously registered entry from the upload menu
|
|
956
|
+
*
|
|
957
|
+
* @param entry Entry to remove (or name of entry)
|
|
958
|
+
*/
|
|
959
|
+
export declare const removeNewFileMenuEntry: (entry: Entry | string) => void;
|
|
960
|
+
|
|
961
|
+
export declare type SortingOrder = 'asc' | 'desc';
|
|
962
|
+
|
|
963
|
+
/**
|
|
964
|
+
* Sort files and folders according to the sorting options
|
|
965
|
+
* @param nodes Nodes to sort
|
|
966
|
+
* @param options Sorting options
|
|
967
|
+
*/
|
|
968
|
+
export declare function sortNodes(nodes: readonly INode[], options?: FilesSortingOptions): INode[];
|
|
969
|
+
|
|
970
|
+
/**
|
|
971
|
+
* SPDX-FileCopyrightText: Ferdinand Thiessen <opensource@fthiessen.de>
|
|
972
|
+
* SPDX-License-Identifier: AGPL-3.0-or-later or LGPL-3.0-or-later
|
|
973
|
+
*/
|
|
974
|
+
declare interface UniqueNameOptions {
|
|
975
|
+
/**
|
|
976
|
+
* A function that takes an index and returns a suffix to add to the file name, defaults to '(index)'
|
|
977
|
+
* @param index The current index to add
|
|
978
|
+
*/
|
|
979
|
+
suffix?: (index: number) => string;
|
|
980
|
+
/**
|
|
981
|
+
* Set to true to ignore the file extension when adding the suffix (when getting a unique directory name)
|
|
982
|
+
*/
|
|
983
|
+
ignoreFileExtension?: boolean;
|
|
984
|
+
}
|
|
985
|
+
|
|
986
|
+
/**
|
|
987
|
+
* Remove a registered filter from the file list
|
|
988
|
+
* @param filterId The unique ID of the filter to remove
|
|
989
|
+
*/
|
|
990
|
+
export declare function unregisterFileListFilter(filterId: string): void;
|
|
991
|
+
|
|
992
|
+
/**
|
|
993
|
+
* The event is emitted when the navigation view was updated.
|
|
994
|
+
* It contains the new active view in the `detail` attribute.
|
|
995
|
+
*/
|
|
996
|
+
declare interface UpdateActiveViewEvent extends CustomEvent<View | null> {
|
|
997
|
+
type: 'updateActive';
|
|
998
|
+
}
|
|
999
|
+
|
|
1000
|
+
/**
|
|
1001
|
+
* This event is emitted when the list of registered views is changed
|
|
1002
|
+
*/
|
|
1003
|
+
declare interface UpdateViewsEvent extends CustomEvent<never> {
|
|
1004
|
+
type: 'update';
|
|
1005
|
+
}
|
|
1006
|
+
|
|
1007
|
+
/**
|
|
1008
|
+
* Validate a given filename
|
|
1009
|
+
* @param filename The filename to check
|
|
1010
|
+
* @throws {InvalidFilenameError}
|
|
1011
|
+
*/
|
|
1012
|
+
export declare function validateFilename(filename: string): void;
|
|
1013
|
+
|
|
1014
|
+
export declare class View implements ViewData {
|
|
1015
|
+
private _view;
|
|
1016
|
+
constructor(view: ViewData);
|
|
1017
|
+
get id(): string;
|
|
1018
|
+
get name(): string;
|
|
1019
|
+
get caption(): string | undefined;
|
|
1020
|
+
get emptyTitle(): string | undefined;
|
|
1021
|
+
get emptyCaption(): string | undefined;
|
|
1022
|
+
get getContents(): (path: string) => Promise<ContentsWithRoot>;
|
|
1023
|
+
get icon(): string;
|
|
1024
|
+
set icon(icon: string);
|
|
1025
|
+
get order(): number | undefined;
|
|
1026
|
+
set order(order: number | undefined);
|
|
1027
|
+
get params(): Record<string, string> | undefined;
|
|
1028
|
+
set params(params: Record<string, string> | undefined);
|
|
1029
|
+
get columns(): Column[] | undefined;
|
|
1030
|
+
get emptyView(): ((div: HTMLDivElement) => void) | undefined;
|
|
1031
|
+
get parent(): string | undefined;
|
|
1032
|
+
get sticky(): boolean | undefined;
|
|
1033
|
+
get expanded(): boolean | undefined;
|
|
1034
|
+
set expanded(expanded: boolean | undefined);
|
|
1035
|
+
get defaultSortKey(): string | undefined;
|
|
1036
|
+
get loadChildViews(): ((view: View) => Promise<void>) | undefined;
|
|
1037
|
+
}
|
|
1038
|
+
|
|
1039
|
+
declare interface ViewData {
|
|
1040
|
+
/** Unique view ID */
|
|
1041
|
+
id: string;
|
|
1042
|
+
/** Translated view name */
|
|
1043
|
+
name: string;
|
|
1044
|
+
/** Translated accessible description of the view */
|
|
1045
|
+
caption?: string;
|
|
1046
|
+
/** Translated title of the empty view */
|
|
1047
|
+
emptyTitle?: string;
|
|
1048
|
+
/** Translated description of the empty view */
|
|
1049
|
+
emptyCaption?: string;
|
|
1050
|
+
/**
|
|
1051
|
+
* Method return the content of the provided path
|
|
1052
|
+
* This ideally should be a cancellable promise.
|
|
1053
|
+
* promise.cancel(reason) will be called when the directory
|
|
1054
|
+
* change and the promise is not resolved yet.
|
|
1055
|
+
* You _must_ also return the current directory
|
|
1056
|
+
* information alongside with its content.
|
|
1057
|
+
*/
|
|
1058
|
+
getContents: (path: string) => Promise<ContentsWithRoot>;
|
|
1059
|
+
/** The view icon as an inline svg */
|
|
1060
|
+
icon: string;
|
|
1061
|
+
/**
|
|
1062
|
+
* The view order.
|
|
1063
|
+
* If not set will be natural sorted by view name.
|
|
1064
|
+
*/
|
|
1065
|
+
order?: number;
|
|
1066
|
+
/**
|
|
1067
|
+
* Custom params to give to the router on click
|
|
1068
|
+
* If defined, will be treated as a dummy view and
|
|
1069
|
+
* will just redirect and not fetch any contents.
|
|
1070
|
+
*/
|
|
1071
|
+
params?: Record<string, string>;
|
|
1072
|
+
/**
|
|
1073
|
+
* This view column(s). Name and actions are
|
|
1074
|
+
* by default always included
|
|
1075
|
+
*/
|
|
1076
|
+
columns?: Column[];
|
|
1077
|
+
/** The empty view element to render your empty content into */
|
|
1078
|
+
emptyView?: (div: HTMLDivElement) => void;
|
|
1079
|
+
/** The parent unique ID */
|
|
1080
|
+
parent?: string;
|
|
1081
|
+
/** This view is sticky (sent at the bottom) */
|
|
1082
|
+
sticky?: boolean;
|
|
1083
|
+
/**
|
|
1084
|
+
* This view has children and is expanded (by default)
|
|
1085
|
+
* or not. This will be overridden by user config.
|
|
1086
|
+
*/
|
|
1087
|
+
expanded?: boolean;
|
|
1088
|
+
/**
|
|
1089
|
+
* Will be used as default if the user
|
|
1090
|
+
* haven't customized their sorting column
|
|
1091
|
+
*/
|
|
1092
|
+
defaultSortKey?: string;
|
|
1093
|
+
/**
|
|
1094
|
+
* Method called to load child views if any
|
|
1095
|
+
*/
|
|
1096
|
+
loadChildViews?: (view: View) => Promise<void>;
|
|
1097
|
+
}
|
|
1098
|
+
|
|
1099
|
+
export { }
|