@nextcloud/files 3.10.0 → 3.10.1

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