@nextcloud/files 3.0.0-beta.8 → 3.0.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 +53 -1
- package/dist/dav/dav.d.ts +64 -0
- package/dist/dav/davPermissions.d.ts +6 -0
- package/dist/dav/davProperties.d.ts +57 -0
- package/dist/fileAction.d.ts +45 -21
- package/dist/fileListHeaders.d.ts +47 -0
- package/dist/files/folder.d.ts +1 -1
- package/dist/files/node.d.ts +41 -4
- package/dist/files/nodeData.d.ts +18 -4
- package/dist/humanfilesize.d.ts +15 -1
- package/dist/index.cjs +2189 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +19 -15
- package/dist/index.mjs +2195 -0
- package/dist/index.mjs.map +1 -0
- package/dist/navigation/column.d.ts +48 -0
- package/dist/navigation/navigation.d.ts +32 -0
- package/dist/navigation/view.d.ts +103 -0
- package/dist/newFileMenu.d.ts +20 -7
- package/dist/permissions.d.ts +3 -5
- package/dist/utils/logger.d.ts +1 -1
- package/dist/vendor.LICENSE.txt +13 -0
- package/package.json +45 -37
- package/dist/index.esm.js +0 -711
- package/dist/index.esm.js.map +0 -1
- package/dist/index.js +0 -841
- package/dist/index.js.map +0 -1
package/README.md
CHANGED
|
@@ -1,3 +1,55 @@
|
|
|
1
|
-
# @nextcloud/files
|
|
1
|
+
# @nextcloud/files
|
|
2
|
+
[](https://www.npmjs.com/package/@nextcloud/files) [](https://app.codecov.io/gh/nextcloud-libraries/nextcloud-files) [](https://nextcloud-libraries.github.io/nextcloud-files/)
|
|
2
3
|
|
|
3
4
|
Nextcloud Files helpers for Nextcloud apps and libraries
|
|
5
|
+
|
|
6
|
+
## Usage example
|
|
7
|
+
|
|
8
|
+
### Using WebDAV to query favorite nodes
|
|
9
|
+
|
|
10
|
+
```ts
|
|
11
|
+
import { davGetClient, davRootPath, getFavoriteNodes } from '@nextcloud/files'
|
|
12
|
+
|
|
13
|
+
const client = davGetClient()
|
|
14
|
+
// query favorites for the root folder (meaning all favorites)
|
|
15
|
+
const favorites = await getFavoriteNodes(client)
|
|
16
|
+
// which is the same as writing:
|
|
17
|
+
const favorites = await getFavoriteNodes(client, '/', davRootPath)
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
### Using WebDAV to list all nodes in directory
|
|
21
|
+
|
|
22
|
+
```ts
|
|
23
|
+
import {
|
|
24
|
+
davGetClient,
|
|
25
|
+
davGetDefaultPropfind,
|
|
26
|
+
davResultToNode,
|
|
27
|
+
davRootPath,
|
|
28
|
+
davRemoteURL
|
|
29
|
+
} from '@nextcloud/files'
|
|
30
|
+
|
|
31
|
+
// Get the DAV client for the default remote
|
|
32
|
+
const client = davGetClient()
|
|
33
|
+
// which is the same as writing
|
|
34
|
+
const client = davGetClient(davRemoteURL)
|
|
35
|
+
// of cause you can also configure another WebDAV remote
|
|
36
|
+
const client = davGetClient('https://example.com/dav')
|
|
37
|
+
|
|
38
|
+
const path = '/my-folder/' // the directory you want to list
|
|
39
|
+
|
|
40
|
+
// Query the directory content using the webdav library
|
|
41
|
+
// `davRootPath` is the files root, for Nextcloud this is '/files/USERID', by default the current user is used
|
|
42
|
+
const results = client.getDirectoryContents(`${davRootPath}${path}`, {
|
|
43
|
+
details: true,
|
|
44
|
+
// Query all required properties for a Node
|
|
45
|
+
data: davGetDefaultPropfind()
|
|
46
|
+
})
|
|
47
|
+
|
|
48
|
+
// Convert the result to an array of Node
|
|
49
|
+
const nodes = results.data.map((result) => davResultToNode(r))
|
|
50
|
+
// If you specified a different root in the `getDirectoryContents` you must add this also on the `davResultToNode` call:
|
|
51
|
+
const nodes = results.data.map((result) => davResultToNode(r, myRoot))
|
|
52
|
+
// Same if you used a different remote URL:
|
|
53
|
+
const nodes = results.data.map((result) => davResultToNode(r, myRoot, myRemoteURL))
|
|
54
|
+
|
|
55
|
+
```
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @copyright Copyright (c) 2023 John Molakvoæ <skjnldsv@protonmail.com>
|
|
3
|
+
*
|
|
4
|
+
* @author John Molakvoæ <skjnldsv@protonmail.com>
|
|
5
|
+
* @author Ferdinand Thiessen <opensource@fthiessen.de>
|
|
6
|
+
*
|
|
7
|
+
* @license AGPL-3.0-or-later
|
|
8
|
+
*
|
|
9
|
+
* This program is free software: you can redistribute it and/or modify
|
|
10
|
+
* it under the terms of the GNU Affero General Public License as
|
|
11
|
+
* published by the Free Software Foundation, either version 3 of the
|
|
12
|
+
* License, or (at your option) any later version.
|
|
13
|
+
*
|
|
14
|
+
* This program is distributed in the hope that it will be useful,
|
|
15
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
16
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
17
|
+
* GNU Affero General Public License for more details.
|
|
18
|
+
*
|
|
19
|
+
* You should have received a copy of the GNU Affero General Public License
|
|
20
|
+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
21
|
+
*
|
|
22
|
+
*/
|
|
23
|
+
import type { FileStat, WebDAVClient } from 'webdav';
|
|
24
|
+
import type { Node } from '../files/node';
|
|
25
|
+
/**
|
|
26
|
+
* The DAV root path for the current user
|
|
27
|
+
*/
|
|
28
|
+
export declare const davRootPath: string;
|
|
29
|
+
/**
|
|
30
|
+
* The DAV remote URL used as base URL for the WebDAV client
|
|
31
|
+
*/
|
|
32
|
+
export declare const davRemoteURL: string;
|
|
33
|
+
/**
|
|
34
|
+
* Get a WebDAV client configured to include the Nextcloud request token
|
|
35
|
+
*
|
|
36
|
+
* @param remoteURL The DAV server remote URL
|
|
37
|
+
*/
|
|
38
|
+
export declare const davGetClient: (remoteURL?: string) => WebDAVClient;
|
|
39
|
+
/**
|
|
40
|
+
* Use WebDAV to query for favorite Nodes
|
|
41
|
+
*
|
|
42
|
+
* @param davClient The WebDAV client to use for performing the request
|
|
43
|
+
* @param path Base path for the favorites, if unset all favorites are queried
|
|
44
|
+
* @param davRoot The root path for the DAV user (defaults to `davRootPath`)
|
|
45
|
+
* @example
|
|
46
|
+
* ```js
|
|
47
|
+
* import { davGetClient, davRootPath, getFavoriteNodes } from '@nextcloud/files'
|
|
48
|
+
*
|
|
49
|
+
* const client = davGetClient()
|
|
50
|
+
* // query favorites for the root
|
|
51
|
+
* const favorites = await getFavoriteNodes(client)
|
|
52
|
+
* // which is the same as writing:
|
|
53
|
+
* const favorites = await getFavoriteNodes(client, '/', davRootPath)
|
|
54
|
+
* ```
|
|
55
|
+
*/
|
|
56
|
+
export declare const getFavoriteNodes: (davClient: WebDAVClient, path?: string, davRoot?: string) => Promise<Node[]>;
|
|
57
|
+
/**
|
|
58
|
+
* Covert DAV result `FileStat` to `Node`
|
|
59
|
+
*
|
|
60
|
+
* @param node The DAV result
|
|
61
|
+
* @param filesRoot The DAV files root path
|
|
62
|
+
* @param remoteURL The DAV server remote URL (same as on `davGetClient`)
|
|
63
|
+
*/
|
|
64
|
+
export declare const davResultToNode: (node: FileStat, filesRoot?: string, remoteURL?: string) => Node;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
export type DavProperty = {
|
|
2
|
+
[key: string]: string;
|
|
3
|
+
};
|
|
4
|
+
export declare const defaultDavProperties: string[];
|
|
5
|
+
export declare const defaultDavNamespaces: {
|
|
6
|
+
d: string;
|
|
7
|
+
nc: string;
|
|
8
|
+
oc: string;
|
|
9
|
+
ocs: string;
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* Register custom DAV properties
|
|
13
|
+
*
|
|
14
|
+
* Can be used if your app introduces custom DAV properties, so e.g. the files app can make use of it.
|
|
15
|
+
*
|
|
16
|
+
* @param prop The property
|
|
17
|
+
* @param namespace The namespace of the property
|
|
18
|
+
*/
|
|
19
|
+
export declare const registerDavProperty: (prop: string, namespace?: DavProperty) => boolean;
|
|
20
|
+
/**
|
|
21
|
+
* Get the registered dav properties
|
|
22
|
+
*/
|
|
23
|
+
export declare const getDavProperties: () => string;
|
|
24
|
+
/**
|
|
25
|
+
* Get the registered dav namespaces
|
|
26
|
+
*/
|
|
27
|
+
export declare const getDavNameSpaces: () => string;
|
|
28
|
+
/**
|
|
29
|
+
* Get the default PROPFIND request body
|
|
30
|
+
*/
|
|
31
|
+
export declare const davGetDefaultPropfind: () => string;
|
|
32
|
+
/**
|
|
33
|
+
* Get the REPORT body to filter for favorite nodes
|
|
34
|
+
*/
|
|
35
|
+
export declare const davGetFavoritesReport: () => string;
|
|
36
|
+
/**
|
|
37
|
+
* Get the SEARCH body to search for recently modified files
|
|
38
|
+
*
|
|
39
|
+
* @param lastModified Oldest timestamp to include (Unix timestamp)
|
|
40
|
+
* @example
|
|
41
|
+
* ```ts
|
|
42
|
+
* // SEARCH for recent files need a different DAV endpoint
|
|
43
|
+
* const client = davGetClient(generateRemoteUrl('dav'))
|
|
44
|
+
* // Timestamp of last week
|
|
45
|
+
* const lastWeek = Math.round(Date.now() / 1000) - (60 * 60 * 24 * 7)
|
|
46
|
+
* const contentsResponse = await client.getDirectoryContents(path, {
|
|
47
|
+
* details: true,
|
|
48
|
+
* data: davGetRecentSearch(lastWeek),
|
|
49
|
+
* headers: {
|
|
50
|
+
* method: 'SEARCH',
|
|
51
|
+
* 'Content-Type': 'application/xml; charset=utf-8',
|
|
52
|
+
* },
|
|
53
|
+
* deep: true,
|
|
54
|
+
* }) as ResponseDataDetailed<FileStat[]>
|
|
55
|
+
* ```
|
|
56
|
+
*/
|
|
57
|
+
export declare const davGetRecentSearch: (lastModified: number) => string;
|
package/dist/fileAction.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @copyright Copyright (c)
|
|
2
|
+
* @copyright Copyright (c) 2023 John Molakvoæ <skjnldsv@protonmail.com>
|
|
3
3
|
*
|
|
4
4
|
* @author John Molakvoæ <skjnldsv@protonmail.com>
|
|
5
5
|
*
|
|
@@ -19,55 +19,79 @@
|
|
|
19
19
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
20
20
|
*
|
|
21
21
|
*/
|
|
22
|
-
import { Node } from
|
|
22
|
+
import { Node } from './files/node';
|
|
23
|
+
import { View } from './navigation/view';
|
|
24
|
+
export declare enum DefaultType {
|
|
25
|
+
DEFAULT = "default",
|
|
26
|
+
HIDDEN = "hidden"
|
|
27
|
+
}
|
|
23
28
|
interface FileActionData {
|
|
24
29
|
/** Unique ID */
|
|
25
30
|
id: string;
|
|
26
31
|
/** Translatable string displayed in the menu */
|
|
27
|
-
displayName: (files: Node[], view:
|
|
32
|
+
displayName: (files: Node[], view: View) => string;
|
|
33
|
+
/** Translatable title for of the action */
|
|
34
|
+
title?: (files: Node[], view: View) => string;
|
|
28
35
|
/** Svg as inline string. <svg><path fill="..." /></svg> */
|
|
29
|
-
iconSvgInline: (files: Node[], view:
|
|
36
|
+
iconSvgInline: (files: Node[], view: View) => string;
|
|
30
37
|
/** Condition wether this action is shown or not */
|
|
31
|
-
enabled?: (files: Node[], view:
|
|
38
|
+
enabled?: (files: Node[], view: View) => boolean;
|
|
32
39
|
/**
|
|
33
40
|
* Function executed on single file action
|
|
34
|
-
* @
|
|
41
|
+
* @return true if the action was executed successfully,
|
|
42
|
+
* false otherwise and null if the action is silent/undefined.
|
|
35
43
|
* @throws Error if the action failed
|
|
36
44
|
*/
|
|
37
|
-
exec: (file: Node, view:
|
|
45
|
+
exec: (file: Node, view: View, dir: string) => Promise<boolean | null>;
|
|
38
46
|
/**
|
|
39
47
|
* Function executed on multiple files action
|
|
40
|
-
* @
|
|
48
|
+
* @return true if the action was executed successfully,
|
|
49
|
+
* false otherwise and null if the action is silent/undefined.
|
|
41
50
|
* @throws Error if the action failed
|
|
42
51
|
*/
|
|
43
|
-
execBatch?: (files: Node[], view:
|
|
52
|
+
execBatch?: (files: Node[], view: View, dir: string) => Promise<(boolean | null)[]>;
|
|
44
53
|
/** This action order in the list */
|
|
45
54
|
order?: number;
|
|
46
|
-
/**
|
|
47
|
-
|
|
55
|
+
/**
|
|
56
|
+
* This action's parent id in the list.
|
|
57
|
+
* If none found, will be displayed as a top-level action.
|
|
58
|
+
*/
|
|
59
|
+
parent?: string;
|
|
60
|
+
/**
|
|
61
|
+
* Make this action the default.
|
|
62
|
+
* If multiple actions are default, the first one
|
|
63
|
+
* will be used. The other ones will be put as first
|
|
64
|
+
* entries in the actions menu iff DefaultType.Hidden is not used.
|
|
65
|
+
* A DefaultType.Hidden action will never be shown
|
|
66
|
+
* in the actions menu even if another action takes
|
|
67
|
+
* its place as default.
|
|
68
|
+
*/
|
|
69
|
+
default?: DefaultType;
|
|
48
70
|
/**
|
|
49
71
|
* If true, the renderInline function will be called
|
|
50
72
|
*/
|
|
51
|
-
inline?: (file: Node, view:
|
|
73
|
+
inline?: (file: Node, view: View) => boolean;
|
|
52
74
|
/**
|
|
53
75
|
* If defined, the returned html element will be
|
|
54
76
|
* appended before the actions menu.
|
|
55
77
|
*/
|
|
56
|
-
renderInline?: (file: Node, view:
|
|
78
|
+
renderInline?: (file: Node, view: View) => Promise<HTMLElement | null>;
|
|
57
79
|
}
|
|
58
80
|
export declare class FileAction {
|
|
59
81
|
private _action;
|
|
60
82
|
constructor(action: FileActionData);
|
|
61
83
|
get id(): string;
|
|
62
|
-
get displayName(): (files: Node[], view:
|
|
63
|
-
get
|
|
64
|
-
get
|
|
65
|
-
get
|
|
66
|
-
get
|
|
84
|
+
get displayName(): (files: Node[], view: View) => string;
|
|
85
|
+
get title(): ((files: Node[], view: View) => string) | undefined;
|
|
86
|
+
get iconSvgInline(): (files: Node[], view: View) => string;
|
|
87
|
+
get enabled(): ((files: Node[], view: View) => boolean) | undefined;
|
|
88
|
+
get exec(): (file: Node, view: View, dir: string) => Promise<boolean | null>;
|
|
89
|
+
get execBatch(): ((files: Node[], view: View, dir: string) => Promise<(boolean | null)[]>) | undefined;
|
|
67
90
|
get order(): number | undefined;
|
|
68
|
-
get
|
|
69
|
-
get
|
|
70
|
-
get
|
|
91
|
+
get parent(): string | undefined;
|
|
92
|
+
get default(): DefaultType | undefined;
|
|
93
|
+
get inline(): ((file: Node, view: View) => boolean) | undefined;
|
|
94
|
+
get renderInline(): ((file: Node, view: View) => Promise<HTMLElement | null>) | undefined;
|
|
71
95
|
private validateAction;
|
|
72
96
|
}
|
|
73
97
|
export declare const registerFileAction: (action: FileAction) => void;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @copyright Copyright (c) 2023 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 { Folder } from './files/folder';
|
|
23
|
+
import { View } from './navigation/view';
|
|
24
|
+
export interface HeaderData {
|
|
25
|
+
/** Unique ID */
|
|
26
|
+
id: string;
|
|
27
|
+
/** Order */
|
|
28
|
+
order: number;
|
|
29
|
+
/** Condition wether this header is shown or not */
|
|
30
|
+
enabled?: (folder: Folder, view: View) => boolean;
|
|
31
|
+
/** Executed when file list is initialized */
|
|
32
|
+
render: (el: HTMLElement, folder: Folder, view: View) => void;
|
|
33
|
+
/** Executed when root folder changed */
|
|
34
|
+
updated(folder: Folder, view: View): any;
|
|
35
|
+
}
|
|
36
|
+
export declare class Header {
|
|
37
|
+
private _header;
|
|
38
|
+
constructor(header: HeaderData);
|
|
39
|
+
get id(): string;
|
|
40
|
+
get order(): number;
|
|
41
|
+
get enabled(): ((folder: Folder, view: View) => boolean) | undefined;
|
|
42
|
+
get render(): (el: HTMLElement, folder: Folder, view: View) => void;
|
|
43
|
+
get updated(): (folder: Folder, view: View) => any;
|
|
44
|
+
private validateHeader;
|
|
45
|
+
}
|
|
46
|
+
export declare const registerFileListHeaders: (header: Header) => void;
|
|
47
|
+
export declare const getFileListHeaders: () => Header[];
|
package/dist/files/folder.d.ts
CHANGED
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
*/
|
|
22
22
|
import { FileType } from './fileType';
|
|
23
23
|
import { Node } from './node';
|
|
24
|
-
import NodeData from './nodeData';
|
|
24
|
+
import { NodeData } from './nodeData';
|
|
25
25
|
export declare class Folder extends Node {
|
|
26
26
|
constructor(data: NodeData);
|
|
27
27
|
get type(): FileType;
|
package/dist/files/node.d.ts
CHANGED
|
@@ -1,6 +1,16 @@
|
|
|
1
1
|
import { Permission } from '../permissions';
|
|
2
2
|
import { FileType } from './fileType';
|
|
3
|
-
import
|
|
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
|
+
}
|
|
4
14
|
export declare abstract class Node {
|
|
5
15
|
private _data;
|
|
6
16
|
private _attributes;
|
|
@@ -10,6 +20,10 @@ export declare abstract class Node {
|
|
|
10
20
|
* Get the source url to this object
|
|
11
21
|
*/
|
|
12
22
|
get source(): string;
|
|
23
|
+
/**
|
|
24
|
+
* Get the encoded source url to this object for requests purposes
|
|
25
|
+
*/
|
|
26
|
+
get encodedSource(): string;
|
|
13
27
|
/**
|
|
14
28
|
* Get this object name
|
|
15
29
|
*/
|
|
@@ -31,6 +45,14 @@ export declare abstract class Node {
|
|
|
31
45
|
* Get the file mime
|
|
32
46
|
*/
|
|
33
47
|
get mime(): string | undefined;
|
|
48
|
+
/**
|
|
49
|
+
* Get the file modification time
|
|
50
|
+
*/
|
|
51
|
+
get mtime(): Date | undefined;
|
|
52
|
+
/**
|
|
53
|
+
* Get the file creation time
|
|
54
|
+
*/
|
|
55
|
+
get crtime(): Date | undefined;
|
|
34
56
|
/**
|
|
35
57
|
* Get the file size
|
|
36
58
|
*/
|
|
@@ -58,11 +80,20 @@ export declare abstract class Node {
|
|
|
58
80
|
/**
|
|
59
81
|
* Get the absolute path of this object relative to the root
|
|
60
82
|
*/
|
|
61
|
-
get path(): string
|
|
83
|
+
get path(): string;
|
|
62
84
|
/**
|
|
63
|
-
* Get the
|
|
85
|
+
* Get the node id if defined.
|
|
86
|
+
* Will look for the fileid in attributes if undefined.
|
|
64
87
|
*/
|
|
65
88
|
get fileid(): number | undefined;
|
|
89
|
+
/**
|
|
90
|
+
* Get the node status.
|
|
91
|
+
*/
|
|
92
|
+
get status(): NodeStatus | undefined;
|
|
93
|
+
/**
|
|
94
|
+
* Set the node status.
|
|
95
|
+
*/
|
|
96
|
+
set status(status: NodeStatus | undefined);
|
|
66
97
|
/**
|
|
67
98
|
* Move the node to a new destination
|
|
68
99
|
*
|
|
@@ -73,6 +104,12 @@ export declare abstract class Node {
|
|
|
73
104
|
/**
|
|
74
105
|
* Rename the node
|
|
75
106
|
* This aliases the move method for easier usage
|
|
107
|
+
*
|
|
108
|
+
* @param basename The new name of the node
|
|
109
|
+
*/
|
|
110
|
+
rename(basename: string): void;
|
|
111
|
+
/**
|
|
112
|
+
* Update the mtime if exists.
|
|
76
113
|
*/
|
|
77
|
-
|
|
114
|
+
private updateMtime;
|
|
78
115
|
}
|
package/dist/files/nodeData.d.ts
CHANGED
|
@@ -19,11 +19,12 @@
|
|
|
19
19
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
20
20
|
*
|
|
21
21
|
*/
|
|
22
|
-
import { Permission } from
|
|
22
|
+
import { Permission } from '../permissions';
|
|
23
|
+
import { NodeStatus } from './node';
|
|
23
24
|
export interface Attribute {
|
|
24
25
|
[key: string]: any;
|
|
25
26
|
}
|
|
26
|
-
export
|
|
27
|
+
export interface NodeData {
|
|
27
28
|
/** Unique ID */
|
|
28
29
|
id?: number;
|
|
29
30
|
/**
|
|
@@ -36,7 +37,7 @@ export default interface NodeData {
|
|
|
36
37
|
mtime?: Date;
|
|
37
38
|
/** Creation time */
|
|
38
39
|
crtime?: Date;
|
|
39
|
-
/** The mime type */
|
|
40
|
+
/** The mime type Optional for folders only */
|
|
40
41
|
mime?: string;
|
|
41
42
|
/** The node size type */
|
|
42
43
|
size?: number;
|
|
@@ -44,6 +45,7 @@ export default interface NodeData {
|
|
|
44
45
|
permissions?: Permission;
|
|
45
46
|
/** The owner UID of this node */
|
|
46
47
|
owner: string | null;
|
|
48
|
+
/** The node attributes */
|
|
47
49
|
attributes?: Attribute;
|
|
48
50
|
/**
|
|
49
51
|
* The absolute root of the home relative to the service.
|
|
@@ -51,8 +53,20 @@ export default interface NodeData {
|
|
|
51
53
|
* e.g. /files/emma
|
|
52
54
|
*/
|
|
53
55
|
root?: string;
|
|
56
|
+
/** The node status */
|
|
57
|
+
status?: NodeStatus;
|
|
54
58
|
}
|
|
59
|
+
/**
|
|
60
|
+
* Check if a node source is from a specific DAV service
|
|
61
|
+
*
|
|
62
|
+
* @param source The source to check
|
|
63
|
+
* @param davService Pattern to check if source is DAV ressource
|
|
64
|
+
*/
|
|
65
|
+
export declare const isDavRessource: (source: string, davService: RegExp) => boolean;
|
|
55
66
|
/**
|
|
56
67
|
* Validate Node construct data
|
|
68
|
+
*
|
|
69
|
+
* @param data The node data
|
|
70
|
+
* @param davService Pattern to check if source is DAV ressource
|
|
57
71
|
*/
|
|
58
|
-
export declare const validateData: (data: NodeData) => void;
|
|
72
|
+
export declare const validateData: (data: NodeData, davService: RegExp) => void;
|
package/dist/humanfilesize.d.ts
CHANGED
|
@@ -23,7 +23,21 @@
|
|
|
23
23
|
/**
|
|
24
24
|
* Format a file size in a human-like format. e.g. 42GB
|
|
25
25
|
*
|
|
26
|
+
* The default for Nextcloud is like Windows using binary sizes but showing decimal units,
|
|
27
|
+
* meaning 1024 bytes will show as 1KB instead of 1KiB or like on Apple 1.02 KB
|
|
28
|
+
*
|
|
26
29
|
* @param size in bytes
|
|
27
30
|
* @param skipSmallSizes avoid rendering tiny sizes and return '< 1 KB' instead
|
|
31
|
+
* @param binaryPrefixes True if size binary prefixes like `KiB` should be used as per IEC 80000-13
|
|
32
|
+
* @param base1000 Set to true to use base 1000 as per SI or used by Apple (default is base 1024 like Linux or Windows)
|
|
33
|
+
*/
|
|
34
|
+
export declare function formatFileSize(size: number | string, skipSmallSizes?: boolean, binaryPrefixes?: boolean, base1000?: boolean): string;
|
|
35
|
+
/**
|
|
36
|
+
* Returns a file size in bytes from a humanly readable string
|
|
37
|
+
* Note: `b` and `B` are both parsed as bytes and not as bit or byte.
|
|
38
|
+
*
|
|
39
|
+
* @param {string} value file size in human-readable format
|
|
40
|
+
* @param {boolean} forceBinary for backwards compatibility this allows values to be base 2 (so 2KB means 2048 bytes instead of 2000 bytes)
|
|
41
|
+
* @return {number} or null if string could not be parsed
|
|
28
42
|
*/
|
|
29
|
-
export declare function
|
|
43
|
+
export declare function parseFileSize(value: string, forceBinary?: boolean): number | null;
|