@nextcloud/files 3.9.2 → 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.
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dav-CtqjqS4O.cjs","sources":["../../lib/utils/logger.ts","../../lib/permissions.ts","../../lib/files/fileType.ts","../../lib/files/nodeData.ts","../../lib/files/node.ts","../../lib/files/file.ts","../../lib/files/folder.ts","../../lib/dav/davPermissions.ts","../../lib/dav/davProperties.ts","../../lib/dav/dav.ts"],"sourcesContent":["/**\n * SPDX-FileCopyrightText: 2019 Nextcloud GmbH and Nextcloud contributors\n * SPDX-License-Identifier: AGPL-3.0-or-later\n */\nimport { getLoggerBuilder } from '@nextcloud/logger'\n\nexport default getLoggerBuilder()\n\t.setApp('@nextcloud/files')\n\t.detectUser()\n\t.build()\n","/**\n * SPDX-FileCopyrightText: 2022 Nextcloud GmbH and Nextcloud contributors\n * SPDX-License-Identifier: AGPL-3.0-or-later\n */\n\n/**\n * Node permissions\n */\nexport enum Permission {\n\tNONE = 0,\n\tCREATE = 4,\n\tREAD = 1,\n\tUPDATE = 2,\n\tDELETE = 8,\n\tSHARE = 16,\n\tALL = 31,\n}\n","/**\n * SPDX-FileCopyrightText: 2022 Nextcloud GmbH and Nextcloud contributors\n * SPDX-License-Identifier: AGPL-3.0-or-later\n */\nexport enum FileType {\n\tFolder = 'folder',\n\tFile = 'file',\n}\n","/**\n * SPDX-FileCopyrightText: 2022 Nextcloud GmbH and Nextcloud contributors\n * SPDX-License-Identifier: AGPL-3.0-or-later\n */\n\nimport { join } from 'path'\nimport { Permission } from '../permissions'\nimport { NodeStatus } from './node'\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport interface Attribute { [key: string]: any }\n\nexport interface NodeData {\n\t/** Unique ID */\n\tid?: number\n\n\t/**\n\t * URL to the resource.\n\t * e.g. https://cloud.domain.com/remote.php/dav/files/emma/Photos/picture.jpg\n\t * or https://domain.com/Photos/picture.jpg\n\t */\n\tsource: string\n\n\t/** Last modified time */\n\tmtime?: Date\n\n\t/** Creation time */\n\tcrtime?: Date\n\n\t/** The mime type Optional for folders only */\n\tmime?: string\n\n\t/** The node size type */\n\tsize?: number\n\n\t/** The node permissions */\n\tpermissions?: Permission\n\n\t/** The owner UID of this node */\n\towner: string|null\n\n\t/** Optional the displayname of this node */\n\tdisplayname?: string\n\n\t/** The node attributes */\n\tattributes?: Attribute\n\n\t/**\n\t * The absolute root of the home relative to the service.\n\t * It is highly recommended to provide that information.\n\t * e.g. /files/emma\n\t */\n\troot?: string\n\n\t/** The node status */\n\tstatus?: NodeStatus\n}\n\n/**\n * Check if a node source is from a specific DAV service\n *\n * @param source The source to check\n * @param davService Pattern to check if source is DAV resource\n */\nexport const isDavResource = function(source: string, davService: RegExp): boolean {\n\treturn source.match(davService) !== null\n}\n\n/**\n * Validate Node construct data\n *\n * @param data The node data\n * @param davService Pattern to check if source is DAV ressource\n */\nexport const validateData = (data: NodeData, davService: RegExp) => {\n\tif (data.id && typeof data.id !== 'number') {\n\t\tthrow new Error('Invalid id type of value')\n\t}\n\n\tif (!data.source) {\n\t\tthrow new Error('Missing mandatory source')\n\t}\n\n\ttry {\n\t\t// eslint-disable-next-line no-new\n\t\tnew URL(data.source)\n\t} catch (e) {\n\t\tthrow new Error('Invalid source format, source must be a valid URL')\n\t}\n\n\tif (!data.source.startsWith('http')) {\n\t\tthrow new Error('Invalid source format, only http(s) is supported')\n\t}\n\n\tif (data.displayname && typeof data.displayname !== 'string') {\n\t\tthrow new Error('Invalid displayname type')\n\t}\n\n\tif (data.mtime && !(data.mtime instanceof Date)) {\n\t\tthrow new Error('Invalid mtime type')\n\t}\n\n\tif (data.crtime && !(data.crtime instanceof Date)) {\n\t\tthrow new Error('Invalid crtime type')\n\t}\n\n\tif (!data.mime || typeof data.mime !== 'string'\n\t\t|| !data.mime.match(/^[-\\w.]+\\/[-+\\w.]+$/gi)) {\n\t\tthrow new Error('Missing or invalid mandatory mime')\n\t}\n\n\t// Allow size to be 0\n\tif ('size' in data && typeof data.size !== 'number' && data.size !== undefined) {\n\t\tthrow new Error('Invalid size type')\n\t}\n\n\t// Allow permissions to be 0\n\tif ('permissions' in data\n\t\t&& data.permissions !== undefined\n\t\t&& !(typeof data.permissions === 'number'\n\t\t\t&& data.permissions >= Permission.NONE\n\t\t\t&& data.permissions <= Permission.ALL\n\t\t)) {\n\t\tthrow new Error('Invalid permissions')\n\t}\n\n\tif (data.owner\n\t\t&& data.owner !== null\n\t\t&& typeof data.owner !== 'string') {\n\t\tthrow new Error('Invalid owner type')\n\t}\n\n\tif (data.attributes && typeof data.attributes !== 'object') {\n\t\tthrow new Error('Invalid attributes type')\n\t}\n\n\tif (data.root && typeof data.root !== 'string') {\n\t\tthrow new Error('Invalid root type')\n\t}\n\n\tif (data.root && !data.root.startsWith('/')) {\n\t\tthrow new Error('Root must start with a leading slash')\n\t}\n\n\tif (data.root && !data.source.includes(data.root)) {\n\t\tthrow new Error('Root must be part of the source')\n\t}\n\n\tif (data.root && isDavResource(data.source, davService)) {\n\t\tconst service = data.source.match(davService)![0]\n\t\tif (!data.source.includes(join(service, data.root))) {\n\t\t\tthrow new Error('The root must be relative to the service. e.g /files/emma')\n\t\t}\n\t}\n\n\tif (data.status && !Object.values(NodeStatus).includes(data.status)) {\n\t\tthrow new Error('Status must be a valid NodeStatus')\n\t}\n}\n","/**\n * SPDX-FileCopyrightText: 2022 Nextcloud GmbH and Nextcloud contributors\n * SPDX-License-Identifier: AGPL-3.0-or-later\n */\nimport { basename, extname, dirname } from 'path'\nimport { encodePath } from '@nextcloud/paths'\n\nimport { Permission } from '../permissions'\nimport { FileType } from './fileType'\nimport { Attribute, isDavResource, NodeData, validateData } from './nodeData'\nimport logger from '../utils/logger'\n\nexport enum NodeStatus {\n\t/** This is a new node and it doesn't exists on the filesystem yet */\n\tNEW = 'new',\n\t/** This node has failed and is unavailable */\n\tFAILED = 'failed',\n\t/** This node is currently loading or have an operation in progress */\n\tLOADING = 'loading',\n\t/** This node is locked and cannot be modified */\n\tLOCKED = 'locked',\n}\n\nexport abstract class Node {\n\n\tprivate _data: NodeData\n\tprivate _attributes: Attribute\n\tprivate _knownDavService = /(remote|public)\\.php\\/(web)?dav/i\n\n\tprivate readonlyAttributes = Object.entries(Object.getOwnPropertyDescriptors(Node.prototype))\n\t\t.filter(e => typeof e[1].get === 'function' && e[0] !== '__proto__')\n\t\t.map(e => e[0])\n\n\tprivate handler = {\n\t\tset: (target: Attribute, prop: string, value: unknown): boolean => {\n\t\t\tif (this.readonlyAttributes.includes(prop)) {\n\t\t\t\treturn false\n\t\t\t}\n\n\t\t\t// Apply original changes\n\t\t\treturn Reflect.set(target, prop, value)\n\t\t},\n\t\tdeleteProperty: (target: Attribute, prop: string): boolean => {\n\t\t\tif (this.readonlyAttributes.includes(prop)) {\n\t\t\t\treturn false\n\t\t\t}\n\n\t\t\t// Apply original changes\n\t\t\treturn Reflect.deleteProperty(target, prop)\n\t\t},\n\t\t// TODO: This is deprecated and only needed for files v3\n\t\tget: (target: Attribute, prop: string, receiver) => {\n\t\t\tif (this.readonlyAttributes.includes(prop)) {\n\t\t\t\tlogger.warn(`Accessing \"Node.attributes.${prop}\" is deprecated, access it directly on the Node instance.`)\n\t\t\t\treturn Reflect.get(this, prop)\n\t\t\t}\n\t\t\treturn Reflect.get(target, prop, receiver)\n\t\t},\n\t} as ProxyHandler<Attribute>\n\n\tconstructor(data: NodeData, davService?: RegExp) {\n\t\t// Validate data\n\t\tvalidateData(data, davService || this._knownDavService)\n\n\t\tthis._data = {\n\t\t\t// TODO: Remove with next major release, this is just for compatibility\n\t\t\tdisplayname: data.attributes?.displayname,\n\t\t\t...data,\n\t\t\tattributes: {},\n\t\t}\n\n\t\t// Proxy the attributes to update the mtime on change\n\t\tthis._attributes = new Proxy(this._data.attributes!, this.handler)\n\n\t\t// Update attributes, this sanitizes the attributes to only contain valid attributes\n\t\tthis.update(data.attributes ?? {})\n\n\t\tif (davService) {\n\t\t\tthis._knownDavService = davService\n\t\t}\n\t}\n\n\t/**\n\t * Get the source url to this object\n\t * There is no setter as the source is not meant to be changed manually.\n\t * You can use the rename or move method to change the source.\n\t */\n\tget source(): string {\n\t\t// strip any ending slash\n\t\treturn this._data.source.replace(/\\/$/i, '')\n\t}\n\n\t/**\n\t * Get the encoded source url to this object for requests purposes\n\t */\n\tget encodedSource(): string {\n\t\tconst { origin } = new URL(this.source)\n\t\treturn origin + encodePath(this.source.slice(origin.length))\n\t}\n\n\t/**\n\t * Get this object name\n\t * There is no setter as the source is not meant to be changed manually.\n\t * You can use the rename or move method to change the source.\n\t */\n\tget basename(): string {\n\t\treturn basename(this.source)\n\t}\n\n\t/**\n\t * The nodes displayname\n\t * By default the display name and the `basename` are identical,\n\t * but it is possible to have a different name. This happens\n\t * on the files app for example for shared folders.\n\t */\n\tget displayname(): string {\n\t\treturn this._data.displayname || this.basename\n\t}\n\n\t/**\n\t * Set the displayname\n\t */\n\tset displayname(displayname: string) {\n\t\tthis._data.displayname = displayname\n\t}\n\n\t/**\n\t * Get this object's extension\n\t * There is no setter as the source is not meant to be changed manually.\n\t * You can use the rename or move method to change the source.\n\t */\n\tget extension(): string|null {\n\t\treturn extname(this.source)\n\t}\n\n\t/**\n\t * Get the directory path leading to this object\n\t * Will use the relative path to root if available\n\t *\n\t * There is no setter as the source is not meant to be changed manually.\n\t * You can use the rename or move method to change the source.\n\t */\n\tget dirname(): string {\n\t\tif (this.root) {\n\t\t\tlet source = this.source\n\t\t\tif (this.isDavResource) {\n\t\t\t\t// ensure we only work on the real path in case root is not distinct\n\t\t\t\tsource = source.split(this._knownDavService).pop()!\n\t\t\t}\n\t\t\t// Using replace would remove all part matching root\n\t\t\tconst firstMatch = source.indexOf(this.root)\n\t\t\t// Ensure we do not remove the leading slash\n\t\t\tconst root = this.root.replace(/\\/$/, '')\n\t\t\treturn dirname(source.slice(firstMatch + root.length) || '/')\n\t\t}\n\n\t\t// This should always be a valid URL\n\t\t// as this is tested in the constructor\n\t\tconst url = new URL(this.source)\n\t\treturn dirname(url.pathname)\n\t}\n\n\t/**\n\t * Is it a file or a folder ?\n\t */\n\tabstract get type(): FileType\n\n\t/**\n\t * Get the file mime\n\t * There is no setter as the mime is not meant to be changed\n\t */\n\tget mime(): string|undefined {\n\t\treturn this._data.mime\n\t}\n\n\t/**\n\t * Get the file modification time\n\t */\n\tget mtime(): Date|undefined {\n\t\treturn this._data.mtime\n\t}\n\n\t/**\n\t * Set the file modification time\n\t */\n\tset mtime(mtime: Date|undefined) {\n\t\tthis._data.mtime = mtime\n\t}\n\n\t/**\n\t * Get the file creation time\n\t * There is no setter as the creation time is not meant to be changed\n\t */\n\tget crtime(): Date|undefined {\n\t\treturn this._data.crtime\n\t}\n\n\t/**\n\t * Get the file size\n\t */\n\tget size(): number|undefined {\n\t\treturn this._data.size\n\t}\n\n\t/**\n\t * Set the file size\n\t */\n\tset size(size: number|undefined) {\n\t\tthis.updateMtime()\n\t\tthis._data.size = size\n\t}\n\n\t/**\n\t * Get the file attribute\n\t * This contains all additional attributes not provided by the Node class\n\t */\n\tget attributes(): Attribute {\n\t\treturn this._attributes\n\t}\n\n\t/**\n\t * Get the file permissions\n\t */\n\tget permissions(): Permission {\n\t\t// If this is not a dav resource, we can only read it\n\t\tif (this.owner === null && !this.isDavResource) {\n\t\t\treturn Permission.READ\n\t\t}\n\n\t\t// If the permissions are not defined, we have none\n\t\treturn this._data.permissions !== undefined\n\t\t\t? this._data.permissions\n\t\t\t: Permission.NONE\n\t}\n\n\t/**\n\t * Set the file permissions\n\t */\n\tset permissions(permissions: Permission) {\n\t\tthis.updateMtime()\n\t\tthis._data.permissions = permissions\n\t}\n\n\t/**\n\t * Get the file owner\n\t * There is no setter as the owner is not meant to be changed\n\t */\n\tget owner(): string|null {\n\t\t// Remote resources have no owner\n\t\tif (!this.isDavResource) {\n\t\t\treturn null\n\t\t}\n\t\treturn this._data.owner\n\t}\n\n\t/**\n\t * Is this a dav-related resource ?\n\t */\n\tget isDavResource(): boolean {\n\t\treturn isDavResource(this.source, this._knownDavService)\n\t}\n\n\t/**\n\t * @deprecated use `isDavResource` instead - will be removed in next major version.\n\t */\n\tget isDavRessource(): boolean {\n\t\treturn this.isDavResource\n\t}\n\n\t/**\n\t * Get the dav root of this object\n\t * There is no setter as the root is not meant to be changed\n\t */\n\tget root(): string|null {\n\t\t// If provided (recommended), use the root and strip away the ending slash\n\t\tif (this._data.root) {\n\t\t\treturn this._data.root.replace(/^(.+)\\/$/, '$1')\n\t\t}\n\n\t\t// Use the source to get the root from the dav service\n\t\tif (this.isDavResource) {\n\t\t\tconst root = dirname(this.source)\n\t\t\treturn root.split(this._knownDavService).pop() || null\n\t\t}\n\n\t\treturn null\n\t}\n\n\t/**\n\t * Get the absolute path of this object relative to the root\n\t */\n\tget path(): string {\n\t\tif (this.root) {\n\t\t\tlet source = this.source\n\t\t\tif (this.isDavResource) {\n\t\t\t\t// ensure we only work on the real path in case root is not distinct\n\t\t\t\tsource = source.split(this._knownDavService).pop()!\n\t\t\t}\n\t\t\t// Using replace would remove all part matching root\n\t\t\tconst firstMatch = source.indexOf(this.root)\n\t\t\t// Ensure we do not remove the leading slash\n\t\t\tconst root = this.root.replace(/\\/$/, '')\n\t\t\treturn source.slice(firstMatch + root.length) || '/'\n\t\t}\n\t\treturn (this.dirname + '/' + this.basename).replace(/\\/\\//g, '/')\n\t}\n\n\t/**\n\t * Get the node id if defined.\n\t * There is no setter as the fileid is not meant to be changed\n\t */\n\tget fileid(): number|undefined {\n\t\treturn this._data?.id\n\t}\n\n\t/**\n\t * Get the node status.\n\t */\n\tget status(): NodeStatus|undefined {\n\t\treturn this._data?.status\n\t}\n\n\t/**\n\t * Set the node status.\n\t */\n\tset status(status: NodeStatus|undefined) {\n\t\tthis._data.status = status\n\t}\n\n\t/**\n\t * Get the node data\n\t */\n\tget data(): NodeData {\n\t\treturn structuredClone(this._data)\n\t}\n\n\t/**\n\t * Move the node to a new destination\n\t *\n\t * @param {string} destination the new source.\n\t * e.g. https://cloud.domain.com/remote.php/dav/files/emma/Photos/picture.jpg\n\t */\n\tmove(destination: string) {\n\t\tvalidateData({ ...this._data, source: destination }, this._knownDavService)\n\t\tconst oldBasename = this.basename\n\n\t\tthis._data.source = destination\n\t\t// Check if the displayname and the (old) basename were the same\n\t\t// meaning no special displayname was set but just a fallback to the basename by Nextcloud's WebDAV server\n\t\tif (this.displayname === oldBasename\n\t\t\t&& this.basename !== oldBasename) {\n\t\t\t// We have to assume that the displayname was not set but just a copy of the basename\n\t\t\t// this can not be guaranteed, so to be sure users should better refetch the node\n\t\t\tthis.displayname = this.basename\n\t\t}\n\t\tthis.updateMtime()\n\t}\n\n\t/**\n\t * Rename the node\n\t * This aliases the move method for easier usage\n\t *\n\t * @param basename The new name of the node\n\t */\n\trename(basename: string) {\n\t\tif (basename.includes('/')) {\n\t\t\tthrow new Error('Invalid basename')\n\t\t}\n\t\tthis.move(dirname(this.source) + '/' + basename)\n\t}\n\n\t/**\n\t * Update the mtime if exists\n\t */\n\tupdateMtime() {\n\t\tif (this._data.mtime) {\n\t\t\tthis._data.mtime = new Date()\n\t\t}\n\t}\n\n\t/**\n\t * Update the attributes of the node\n\t * Warning, updating attributes will NOT automatically update the mtime.\n\t *\n\t * @param attributes The new attributes to update on the Node attributes\n\t */\n\tupdate(attributes: Attribute) {\n\t\tfor (const [name, value] of Object.entries(attributes)) {\n\t\t\ttry {\n\t\t\t\tif (value === undefined) {\n\t\t\t\t\tdelete this.attributes[name]\n\t\t\t\t} else {\n\t\t\t\t\tthis.attributes[name] = value\n\t\t\t\t}\n\t\t\t} catch (e) {\n\t\t\t\t// Ignore readonly attributes\n\t\t\t\tif (e instanceof TypeError) {\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\t// Throw all other exceptions\n\t\t\t\tthrow e\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Returns a clone of the node\n\t */\n\tabstract clone(): Node\n\n}\n\n/**\n * Interface of the node class\n */\nexport type INode = Pick<Node, keyof Node>\n","/**\n * SPDX-FileCopyrightText: 2022 Nextcloud GmbH and Nextcloud contributors\n * SPDX-License-Identifier: AGPL-3.0-or-later\n */\nimport { FileType } from './fileType'\nimport { Node } from './node'\n\nexport class File extends Node {\n\n\tget type(): FileType.File {\n\t\treturn FileType.File\n\t}\n\n\t/**\n\t * Returns a clone of the file\n\t */\n\tclone(): File {\n\t\treturn new File(this.data)\n\t}\n\n}\n\n/**\n * Interface of the File class\n */\nexport type IFile = Pick<File, keyof File>\n","/**\n * SPDX-FileCopyrightText: 2022 Nextcloud GmbH and Nextcloud contributors\n * SPDX-License-Identifier: AGPL-3.0-or-later\n */\nimport type { NodeData } from './nodeData'\nimport { FileType } from './fileType'\nimport { Node } from './node'\n\nexport class Folder extends Node {\n\n\tconstructor(data: NodeData) {\n\t\t// enforcing mimes\n\t\tsuper({\n\t\t\t...data,\n\t\t\tmime: 'httpd/unix-directory',\n\t\t})\n\t}\n\n\tget type(): FileType.Folder {\n\t\treturn FileType.Folder\n\t}\n\n\tget extension(): null {\n\t\treturn null\n\t}\n\n\tget mime(): 'httpd/unix-directory' {\n\t\treturn 'httpd/unix-directory'\n\t}\n\n\t/**\n\t * Returns a clone of the folder\n\t */\n\tclone(): Folder {\n\t\treturn new Folder(this.data)\n\t}\n\n}\n\n/**\n * Interface of the folder class\n */\nexport type IFolder = Pick<Folder, keyof Folder>\n","/**\n * SPDX-FileCopyrightText: 2023 Nextcloud GmbH and Nextcloud contributors\n * SPDX-License-Identifier: AGPL-3.0-or-later\n */\nimport { Permission } from '../permissions'\n\n/**\n * Parse the WebDAV permission string to a permission enum\n *\n * @param permString The DAV permission string\n */\nexport const parsePermissions = function(permString = ''): number {\n\tlet permissions = Permission.NONE\n\n\tif (!permString) { return permissions }\n\n\tif (permString.includes('C') || permString.includes('K')) { permissions |= Permission.CREATE }\n\n\tif (permString.includes('G')) { permissions |= Permission.READ }\n\n\tif (permString.includes('W') || permString.includes('N') || permString.includes('V')) { permissions |= Permission.UPDATE }\n\n\tif (permString.includes('D')) { permissions |= Permission.DELETE }\n\n\tif (permString.includes('R')) { permissions |= Permission.SHARE }\n\n\treturn permissions\n}\n","/**\n * SPDX-FileCopyrightText: 2023 Nextcloud GmbH and Nextcloud contributors\n * SPDX-License-Identifier: AGPL-3.0-or-later\n */\nimport { getCurrentUser } from '@nextcloud/auth'\nimport logger from '../utils/logger'\n\nexport type DavProperty = { [key: string]: string }\n\nexport const defaultDavProperties = [\n\t'd:getcontentlength',\n\t'd:getcontenttype',\n\t'd:getetag',\n\t'd:getlastmodified',\n\t'd:creationdate',\n\t'd:displayname',\n\t'd:quota-available-bytes',\n\t'd:resourcetype',\n\t'nc:has-preview',\n\t'nc:is-encrypted',\n\t'nc:mount-type',\n\t'oc:comments-unread',\n\t'oc:favorite',\n\t'oc:fileid',\n\t'oc:owner-display-name',\n\t'oc:owner-id',\n\t'oc:permissions',\n\t'oc:size',\n]\n\nexport const defaultDavNamespaces = {\n\td: 'DAV:',\n\tnc: 'http://nextcloud.org/ns',\n\toc: 'http://owncloud.org/ns',\n\tocs: 'http://open-collaboration-services.org/ns',\n}\n\n/**\n * Register custom DAV properties\n *\n * Can be used if your app introduces custom DAV properties, so e.g. the files app can make use of it.\n *\n * @param prop The property\n * @param namespace The namespace of the property\n */\nexport const registerDavProperty = function(prop: string, namespace: DavProperty = { nc: 'http://nextcloud.org/ns' }): boolean {\n\tif (typeof window._nc_dav_properties === 'undefined') {\n\t\twindow._nc_dav_properties = [...defaultDavProperties]\n\t\twindow._nc_dav_namespaces = { ...defaultDavNamespaces }\n\t}\n\n\tconst namespaces = { ...window._nc_dav_namespaces, ...namespace }\n\n\t// Check duplicates\n\tif (window._nc_dav_properties.find((search) => search === prop)) {\n\t\tlogger.warn(`${prop} already registered`, { prop })\n\t\treturn false\n\t}\n\n\tif (prop.startsWith('<') || prop.split(':').length !== 2) {\n\t\tlogger.error(`${prop} is not valid. See example: 'oc:fileid'`, { prop })\n\t\treturn false\n\t}\n\n\tconst ns = prop.split(':')[0]\n\tif (!namespaces[ns]) {\n\t\tlogger.error(`${prop} namespace unknown`, { prop, namespaces })\n\t\treturn false\n\t}\n\n\twindow._nc_dav_properties.push(prop)\n\twindow._nc_dav_namespaces = namespaces\n\treturn true\n}\n\n/**\n * Get the registered dav properties\n */\nexport const getDavProperties = function(): string {\n\tif (typeof window._nc_dav_properties === 'undefined') {\n\t\twindow._nc_dav_properties = [...defaultDavProperties]\n\t}\n\n\treturn window._nc_dav_properties.map((prop) => `<${prop} />`).join(' ')\n}\n\n/**\n * Get the registered dav namespaces\n */\nexport const getDavNameSpaces = function(): string {\n\tif (typeof window._nc_dav_namespaces === 'undefined') {\n\t\twindow._nc_dav_namespaces = { ...defaultDavNamespaces }\n\t}\n\n\treturn Object.keys(window._nc_dav_namespaces)\n\t\t.map((ns) => `xmlns:${ns}=\"${window._nc_dav_namespaces?.[ns]}\"`)\n\t\t.join(' ')\n}\n\n/**\n * Get the default PROPFIND request body\n */\nexport const getDefaultPropfind = function(): string {\n\treturn `<?xml version=\"1.0\"?>\n\t\t<d:propfind ${getDavNameSpaces()}>\n\t\t\t<d:prop>\n\t\t\t\t${getDavProperties()}\n\t\t\t</d:prop>\n\t\t</d:propfind>`\n}\n\n/**\n * Get the REPORT body to filter for favorite nodes\n */\nexport const getFavoritesReport = function(): string {\n\treturn `<?xml version=\"1.0\"?>\n\t\t<oc:filter-files ${getDavNameSpaces()}>\n\t\t\t<d:prop>\n\t\t\t\t${getDavProperties()}\n\t\t\t</d:prop>\n\t\t\t<oc:filter-rules>\n\t\t\t\t<oc:favorite>1</oc:favorite>\n\t\t\t</oc:filter-rules>\n\t\t</oc:filter-files>`\n}\n\n/**\n * Get the SEARCH body to search for recently modified files\n *\n * @param lastModified Oldest timestamp to include (Unix timestamp)\n * @example\n * ```ts\n * // SEARCH for recent files need a different DAV endpoint\n * const client = davGetClient(generateRemoteUrl('dav'))\n * // Timestamp of last week\n * const lastWeek = Math.round(Date.now() / 1000) - (60 * 60 * 24 * 7)\n * const contentsResponse = await client.getDirectoryContents(path, {\n * details: true,\n * data: davGetRecentSearch(lastWeek),\n * headers: {\n * method: 'SEARCH',\n * 'Content-Type': 'application/xml; charset=utf-8',\n * },\n * deep: true,\n * }) as ResponseDataDetailed<FileStat[]>\n * ```\n */\nexport const getRecentSearch = function(lastModified: number): string {\n\treturn `<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<d:searchrequest ${getDavNameSpaces()}\n\txmlns:ns=\"https://github.com/icewind1991/SearchDAV/ns\">\n\t<d:basicsearch>\n\t\t<d:select>\n\t\t\t<d:prop>\n\t\t\t\t${getDavProperties()}\n\t\t\t</d:prop>\n\t\t</d:select>\n\t\t<d:from>\n\t\t\t<d:scope>\n\t\t\t\t<d:href>/files/${getCurrentUser()?.uid}/</d:href>\n\t\t\t\t<d:depth>infinity</d:depth>\n\t\t\t</d:scope>\n\t\t</d:from>\n\t\t<d:where>\n\t\t\t<d:and>\n\t\t\t\t<d:or>\n\t\t\t\t\t<d:not>\n\t\t\t\t\t\t<d:eq>\n\t\t\t\t\t\t\t<d:prop>\n\t\t\t\t\t\t\t\t<d:getcontenttype/>\n\t\t\t\t\t\t\t</d:prop>\n\t\t\t\t\t\t\t<d:literal>httpd/unix-directory</d:literal>\n\t\t\t\t\t\t</d:eq>\n\t\t\t\t\t</d:not>\n\t\t\t\t\t<d:eq>\n\t\t\t\t\t\t<d:prop>\n\t\t\t\t\t\t\t<oc:size/>\n\t\t\t\t\t\t</d:prop>\n\t\t\t\t\t\t<d:literal>0</d:literal>\n\t\t\t\t\t</d:eq>\n\t\t\t\t</d:or>\n\t\t\t\t<d:gt>\n\t\t\t\t\t<d:prop>\n\t\t\t\t\t\t<d:getlastmodified/>\n\t\t\t\t\t</d:prop>\n\t\t\t\t\t<d:literal>${lastModified}</d:literal>\n\t\t\t\t</d:gt>\n\t\t\t</d:and>\n\t\t</d:where>\n\t\t<d:orderby>\n\t\t\t<d:order>\n\t\t\t\t<d:prop>\n\t\t\t\t\t<d:getlastmodified/>\n\t\t\t\t</d:prop>\n\t\t\t\t<d:descending/>\n\t\t\t</d:order>\n\t\t</d:orderby>\n\t\t<d:limit>\n\t\t\t<d:nresults>100</d:nresults>\n\t\t\t<ns:firstresult>0</ns:firstresult>\n\t\t</d:limit>\n\t</d:basicsearch>\n</d:searchrequest>`\n}\n","/**\n * SPDX-FileCopyrightText: 2023 Nextcloud GmbH and Nextcloud contributors\n * SPDX-License-Identifier: AGPL-3.0-or-later\n */\nimport type { DAVResultResponseProps, FileStat, ResponseDataDetailed, WebDAVClient } from 'webdav'\nimport type { Node } from '../files/node'\n\nimport { File } from '../files/file'\nimport { Folder } from '../files/folder'\nimport { NodeStatus } from '../files/node'\nimport { NodeData } from '../files/nodeData'\nimport { parsePermissions } from './davPermissions'\nimport { getFavoritesReport } from './davProperties'\n\nimport { getCurrentUser, getRequestToken, onRequestTokenUpdate } from '@nextcloud/auth'\nimport { generateRemoteUrl } from '@nextcloud/router'\nimport { CancelablePromise } from 'cancelable-promise'\nimport { createClient, getPatcher } from 'webdav'\nimport { getSharingToken, isPublicShare } from '@nextcloud/sharing/public'\n\n/**\n * Nextcloud DAV result response\n */\ninterface ResponseProps extends DAVResultResponseProps {\n\tcreationdate: string\n\tpermissions: string\n\tmime: string\n\tfileid: number\n\tsize: number\n\t'owner-id': string | number\n}\n\n/**\n * Get the DAV root path for the current user or public share\n */\nexport function getRootPath(): string {\n\tif (isPublicShare()) {\n\t\treturn `/files/${getSharingToken()}`\n\t}\n\treturn `/files/${getCurrentUser()?.uid}`\n}\n\n/**\n * The DAV root path for the current user\n * This is a cached version of `getRemoteURL`\n */\nexport const defaultRootPath = getRootPath()\n\n/**\n * Get the DAV remote URL used as base URL for the WebDAV client\n * It also handles public shares\n */\nexport function getRemoteURL(): string {\n\tconst url = generateRemoteUrl('dav')\n\tif (isPublicShare()) {\n\t\treturn url.replace('remote.php', 'public.php')\n\t}\n\treturn url\n}\n\n/**\n * The DAV remote URL used as base URL for the WebDAV client\n * This is a cached version of `getRemoteURL`\n */\nexport const defaultRemoteURL = getRemoteURL()\n\n/**\n * Get a WebDAV client configured to include the Nextcloud request token\n *\n * @param remoteURL The DAV server remote URL\n * @param headers Optional additional headers to set for every request\n */\nexport const getClient = function(remoteURL = defaultRemoteURL, headers: Record<string, string> = {}) {\n\tconst client = createClient(remoteURL, { headers })\n\n\t/**\n\t * Set headers for DAV requests\n\t * @param token CSRF token\n\t */\n\tfunction setHeaders(token: string | null) {\n\t\tclient.setHeaders({\n\t\t\t...headers,\n\t\t\t// Add this so the server knows it is an request from the browser\n\t\t\t'X-Requested-With': 'XMLHttpRequest',\n\t\t\t// Inject user auth\n\t\t\trequesttoken: token ?? '',\n\t\t})\n\t}\n\n\t// refresh headers when request token changes\n\tonRequestTokenUpdate(setHeaders)\n\tsetHeaders(getRequestToken())\n\n\t/**\n\t * Allow to override the METHOD to support dav REPORT\n\t *\n\t * @see https://github.com/perry-mitchell/webdav-client/blob/8d9694613c978ce7404e26a401c39a41f125f87f/source/request.ts\n\t */\n\tconst patcher = getPatcher()\n\t// eslint-disable-next-line @typescript-eslint/ban-ts-comment\n\t// @ts-ignore\n\t// https://github.com/perry-mitchell/hot-patcher/issues/6\n\tpatcher.patch('fetch', (url: string, options: RequestInit): Promise<Response> => {\n\t\tconst headers = options.headers as Record<string, string>\n\t\tif (headers?.method) {\n\t\t\toptions.method = headers.method\n\t\t\tdelete headers.method\n\t\t}\n\t\treturn fetch(url, options)\n\t})\n\n\treturn client\n}\n\n/**\n * Use WebDAV to query for favorite Nodes\n *\n * @param davClient The WebDAV client to use for performing the request\n * @param path Base path for the favorites, if unset all favorites are queried\n * @param davRoot The root path for the DAV user (defaults to `defaultRootPath`)\n * @example\n * ```js\n * import { getClient, defaultRootPath, getFavoriteNodes } from '@nextcloud/files'\n *\n * const client = getClient()\n * // query favorites for the root\n * const favorites = await getFavoriteNodes(client)\n * // which is the same as writing:\n * const favorites = await getFavoriteNodes(client, '/', defaultRootPath)\n * ```\n */\nexport const getFavoriteNodes = (davClient: WebDAVClient, path = '/', davRoot = defaultRootPath): CancelablePromise<Node[]> => {\n\tconst controller = new AbortController()\n\treturn new CancelablePromise(async (resolve, reject, onCancel) => {\n\t\tonCancel(() => controller.abort())\n\t\ttry {\n\t\t\tconst contentsResponse = await davClient.getDirectoryContents(`${davRoot}${path}`, {\n\t\t\t\tsignal: controller.signal,\n\t\t\t\tdetails: true,\n\t\t\t\tdata: getFavoritesReport(),\n\t\t\t\theaders: {\n\t\t\t\t\t// see getClient for patched webdav client\n\t\t\t\t\tmethod: 'REPORT',\n\t\t\t\t},\n\t\t\t\tincludeSelf: true,\n\t\t\t}) as ResponseDataDetailed<FileStat[]>\n\n\t\t\tconst nodes = contentsResponse.data\n\t\t\t\t.filter(node => node.filename !== path) // exclude current dir\n\t\t\t\t.map((result) => resultToNode(result, davRoot))\n\t\t\tresolve(nodes)\n\t\t} catch (error) {\n\t\t\treject(error)\n\t\t}\n\t})\n}\n\n/**\n * Covert DAV result `FileStat` to `Node`\n *\n * @param node The DAV result\n * @param filesRoot The DAV files root path\n * @param remoteURL The DAV server remote URL (same as on `getClient`)\n */\nexport const resultToNode = function(node: FileStat, filesRoot = defaultRootPath, remoteURL = defaultRemoteURL): Node {\n\tlet userId = getCurrentUser()?.uid\n\tif (isPublicShare()) {\n\t\tuserId = userId ?? 'anonymous'\n\t} else if (!userId) {\n\t\tthrow new Error('No user id found')\n\t}\n\n\tconst props = node.props as ResponseProps\n\tconst permissions = parsePermissions(props?.permissions)\n\tconst owner = String(props?.['owner-id'] || userId)\n\tconst id = props.fileid || 0\n\n\tconst mtime = new Date(Date.parse(node.lastmod))\n\tconst crtime = new Date(Date.parse(props.creationdate))\n\n\tconst nodeData: NodeData = {\n\t\tid,\n\t\tsource: `${remoteURL}${node.filename}`,\n\t\tmtime: !isNaN(mtime.getTime()) && mtime.getTime() !== 0 ? mtime : undefined,\n\t\tcrtime: !isNaN(crtime.getTime()) && crtime.getTime() !== 0 ? crtime : undefined,\n\t\tmime: node.mime || 'application/octet-stream',\n\t\t// Manually cast to work around for https://github.com/perry-mitchell/webdav-client/pull/380\n\t\tdisplayname: props.displayname !== undefined ? String(props.displayname) : undefined,\n\t\tsize: props?.size || Number.parseInt(props.getcontentlength || '0'),\n\t\t// The fileid is set to -1 for failed requests\n\t\tstatus: id < 0 ? NodeStatus.FAILED : undefined,\n\t\tpermissions,\n\t\towner,\n\t\troot: filesRoot,\n\t\tattributes: {\n\t\t\t...node,\n\t\t\t...props,\n\t\t\thasPreview: props?.['has-preview'],\n\t\t},\n\t}\n\n\tdelete nodeData.attributes?.props\n\n\treturn node.type === 'file' ? new File(nodeData) : new Folder(nodeData)\n}\n"],"names":["getLoggerBuilder","Permission","FileType","join","NodeStatus","encodePath","basename","extname","dirname","getCurrentUser","isPublicShare","getSharingToken","generateRemoteUrl","createClient","onRequestTokenUpdate","getRequestToken","getPatcher","headers","path","CancelablePromise"],"mappings":";;;;;;;;;AAMA,MAAA,SAAeA,4BACb,OAAO,kBAAkB,EACzB,WAAA,EACA,MAAM;ACDI,IAAA,+BAAAC,gBAAL;AACNA,cAAAA,YAAA,UAAO,CAAP,IAAA;AACAA,cAAAA,YAAA,YAAS,CAAT,IAAA;AACAA,cAAAA,YAAA,UAAO,CAAP,IAAA;AACAA,cAAAA,YAAA,YAAS,CAAT,IAAA;AACAA,cAAAA,YAAA,YAAS,CAAT,IAAA;AACAA,cAAAA,YAAA,WAAQ,EAAR,IAAA;AACAA,cAAAA,YAAA,SAAM,EAAN,IAAA;AAPWA,SAAAA;AAAA,GAAA,cAAA,CAAA,CAAA;ACJA,IAAA,6BAAAC,cAAL;AACNA,YAAA,QAAS,IAAA;AACTA,YAAA,MAAO,IAAA;AAFIA,SAAAA;AAAA,GAAA,YAAA,CAAA,CAAA;AC4DC,MAAA,gBAAgB,SAAS,QAAgB,YAA6B;AAC3E,SAAA,OAAO,MAAM,UAAU,MAAM;AACrC;AAQa,MAAA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S;AAAA,IACrC;AAAA,IACA;AAAA,IACA,MAAM;AAAA,IACN,YAAY;AAAA,MACX,GAAG;AAAA,MACH,GAAG;AAAA,MACH,YAAY,QAAQ,aAAa;AAAA,IAClC;AAAA,EAAA;AAGD,SAAO,SAAS,YAAY;AAErB,SAAA,KAAK,SAAS,SAAS,IAAI,KAAK,QAAQ,IAAI,IAAI,OAAO,QAAQ;AACvE;;;;;;;;;;;;;;;;;;;;;;;;"}
package/dist/dav/dav.d.ts CHANGED
@@ -5,44 +5,44 @@ import { CancelablePromise } from 'cancelable-promise';
5
5
  /**
6
6
  * Get the DAV root path for the current user or public share
7
7
  */
8
- export declare function davGetRootPath(): string;
8
+ export declare function getRootPath(): string;
9
9
  /**
10
10
  * The DAV root path for the current user
11
- * This is a cached version of `davGetRemoteURL`
11
+ * This is a cached version of `getRemoteURL`
12
12
  */
13
- export declare const davRootPath: string;
13
+ export declare const defaultRootPath: string;
14
14
  /**
15
15
  * Get the DAV remote URL used as base URL for the WebDAV client
16
16
  * It also handles public shares
17
17
  */
18
- export declare function davGetRemoteURL(): string;
18
+ export declare function getRemoteURL(): string;
19
19
  /**
20
20
  * The DAV remote URL used as base URL for the WebDAV client
21
- * This is a cached version of `davGetRemoteURL`
21
+ * This is a cached version of `getRemoteURL`
22
22
  */
23
- export declare const davRemoteURL: string;
23
+ export declare const defaultRemoteURL: string;
24
24
  /**
25
25
  * Get a WebDAV client configured to include the Nextcloud request token
26
26
  *
27
27
  * @param remoteURL The DAV server remote URL
28
28
  * @param headers Optional additional headers to set for every request
29
29
  */
30
- export declare const davGetClient: (remoteURL?: string, headers?: Record<string, string>) => WebDAVClient;
30
+ export declare const getClient: (remoteURL?: string, headers?: Record<string, string>) => WebDAVClient;
31
31
  /**
32
32
  * Use WebDAV to query for favorite Nodes
33
33
  *
34
34
  * @param davClient The WebDAV client to use for performing the request
35
35
  * @param path Base path for the favorites, if unset all favorites are queried
36
- * @param davRoot The root path for the DAV user (defaults to `davRootPath`)
36
+ * @param davRoot The root path for the DAV user (defaults to `defaultRootPath`)
37
37
  * @example
38
38
  * ```js
39
- * import { davGetClient, davRootPath, getFavoriteNodes } from '@nextcloud/files'
39
+ * import { getClient, defaultRootPath, getFavoriteNodes } from '@nextcloud/files'
40
40
  *
41
- * const client = davGetClient()
41
+ * const client = getClient()
42
42
  * // query favorites for the root
43
43
  * const favorites = await getFavoriteNodes(client)
44
44
  * // which is the same as writing:
45
- * const favorites = await getFavoriteNodes(client, '/', davRootPath)
45
+ * const favorites = await getFavoriteNodes(client, '/', defaultRootPath)
46
46
  * ```
47
47
  */
48
48
  export declare const getFavoriteNodes: (davClient: WebDAVClient, path?: string, davRoot?: string) => CancelablePromise<Node[]>;
@@ -51,6 +51,6 @@ export declare const getFavoriteNodes: (davClient: WebDAVClient, path?: string,
51
51
  *
52
52
  * @param node The DAV result
53
53
  * @param filesRoot The DAV files root path
54
- * @param remoteURL The DAV server remote URL (same as on `davGetClient`)
54
+ * @param remoteURL The DAV server remote URL (same as on `getClient`)
55
55
  */
56
- export declare const davResultToNode: (node: FileStat, filesRoot?: string, remoteURL?: string) => Node;
56
+ export declare const resultToNode: (node: FileStat, filesRoot?: string, remoteURL?: string) => Node;
@@ -1,6 +1,6 @@
1
1
  /**
2
- * Parse the webdav permission string to a permission enum
2
+ * Parse the WebDAV permission string to a permission enum
3
3
  *
4
4
  * @param permString The DAV permission string
5
5
  */
6
- export declare const davParsePermissions: (permString?: string) => number;
6
+ export declare const parsePermissions: (permString?: string) => number;
@@ -28,11 +28,11 @@ export declare const getDavNameSpaces: () => string;
28
28
  /**
29
29
  * Get the default PROPFIND request body
30
30
  */
31
- export declare const davGetDefaultPropfind: () => string;
31
+ export declare const getDefaultPropfind: () => string;
32
32
  /**
33
33
  * Get the REPORT body to filter for favorite nodes
34
34
  */
35
- export declare const davGetFavoritesReport: () => string;
35
+ export declare const getFavoritesReport: () => string;
36
36
  /**
37
37
  * Get the SEARCH body to search for recently modified files
38
38
  *
@@ -54,4 +54,4 @@ export declare const davGetFavoritesReport: () => string;
54
54
  * }) as ResponseDataDetailed<FileStat[]>
55
55
  * ```
56
56
  */
57
- export declare const davGetRecentSearch: (lastModified: number) => string;
57
+ export declare const getRecentSearch: (lastModified: number) => string;
@@ -0,0 +1,13 @@
1
+ /*!
2
+ * SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors
3
+ * SPDX-License-Identifier: AGPL-3.0-or-later
4
+ */
5
+ /**
6
+ * This module provides utils to work with the Nextcloud WebDAV interface.
7
+ *
8
+ * The DAV functions are based on the [`webdav`](https://www.npmjs.com/package/webdav) package.
9
+ * @packageDocumentation
10
+ */
11
+ export * from './dav';
12
+ export * from './davPermissions';
13
+ export * from './davProperties';
package/dist/dav.cjs ADDED
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const dav = require("./chunks/dav-CtqjqS4O.cjs");
4
+ exports.defaultDavNamespaces = dav.defaultDavNamespaces;
5
+ exports.defaultDavProperties = dav.defaultDavProperties;
6
+ exports.defaultRemoteURL = dav.defaultRemoteURL;
7
+ exports.defaultRootPath = dav.defaultRootPath;
8
+ exports.getClient = dav.getClient;
9
+ exports.getDavNameSpaces = dav.getDavNameSpaces;
10
+ exports.getDavProperties = dav.getDavProperties;
11
+ exports.getDefaultPropfind = dav.getDefaultPropfind;
12
+ exports.getFavoriteNodes = dav.getFavoriteNodes;
13
+ exports.getFavoritesReport = dav.getFavoritesReport;
14
+ exports.getRecentSearch = dav.getRecentSearch;
15
+ exports.getRemoteURL = dav.getRemoteURL;
16
+ exports.getRootPath = dav.getRootPath;
17
+ exports.parsePermissions = dav.parsePermissions;
18
+ exports.registerDavProperty = dav.registerDavProperty;
19
+ exports.resultToNode = dav.resultToNode;
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dav.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;"}
package/dist/dav.mjs ADDED
@@ -0,0 +1,19 @@
1
+ import { h, f, b, d, c, k, j, l, e, m, n, a, g, p, i, r } from "./chunks/dav-Co9y-hkg.mjs";
2
+ export {
3
+ h as defaultDavNamespaces,
4
+ f as defaultDavProperties,
5
+ b as defaultRemoteURL,
6
+ d as defaultRootPath,
7
+ c as getClient,
8
+ k as getDavNameSpaces,
9
+ j as getDavProperties,
10
+ l as getDefaultPropfind,
11
+ e as getFavoriteNodes,
12
+ m as getFavoritesReport,
13
+ n as getRecentSearch,
14
+ a as getRemoteURL,
15
+ g as getRootPath,
16
+ p as parsePermissions,
17
+ i as registerDavProperty,
18
+ r as resultToNode
19
+ };
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dav.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
@@ -5,7 +5,7 @@ export declare enum DefaultType {
5
5
  DEFAULT = "default",
6
6
  HIDDEN = "hidden"
7
7
  }
8
- interface FileActionData {
8
+ export interface FileActionData {
9
9
  /** Unique ID */
10
10
  id: string;
11
11
  /** Translatable string displayed in the menu */
@@ -32,6 +32,11 @@ interface FileActionData {
32
32
  execBatch?: (files: Node[], view: View, dir: string) => Promise<(boolean | null)[]>;
33
33
  /** This action order in the list */
34
34
  order?: number;
35
+ /**
36
+ * Set to true if this action is a destructive action, like "delete".
37
+ * This will change the appearance in the action menu more prominent (e.g. red colored)
38
+ */
39
+ destructive?: boolean;
35
40
  /**
36
41
  * This action's parent id in the list.
37
42
  * If none found, will be displayed as a top-level action.
@@ -70,10 +75,10 @@ export declare class FileAction {
70
75
  get order(): number | undefined;
71
76
  get parent(): string | undefined;
72
77
  get default(): DefaultType | undefined;
78
+ get destructive(): boolean | undefined;
73
79
  get inline(): ((file: Node, view: View) => boolean) | undefined;
74
80
  get renderInline(): ((file: Node, view: View) => Promise<HTMLElement | null>) | undefined;
75
81
  private validateAction;
76
82
  }
77
83
  export declare const registerFileAction: (action: FileAction) => void;
78
84
  export declare const getFileActions: () => FileAction[];
79
- export {};
@@ -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 {};
@@ -14,6 +14,10 @@ export interface IFileListFilterChip {
14
14
  * Optional icon to be used on the chip (inline SVG as string)
15
15
  */
16
16
  icon?: string;
17
+ /**
18
+ * Optional pass a user id to use a user avatar instead of an icon
19
+ */
20
+ user?: string;
17
21
  /**
18
22
  * Handler to be called on click
19
23
  */
@@ -47,15 +51,26 @@ export interface IFileListFilter extends TypedEventTarget<IFileListFilterEvents>
47
51
  * Use a low number to make this filter ordered in front.
48
52
  */
49
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[];
50
61
  /**
51
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
52
64
  */
53
- readonly mount?: (el: HTMLElement) => void;
65
+ mount?(el: HTMLElement): void;
54
66
  /**
55
- * Filter function to decide if a node is shown
56
- * @return The nodes to be shown
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
57
72
  */
58
- filter(node: INode[]): INode[];
73
+ reset?(): void;
59
74
  }
60
75
  export declare class FileListFilter extends TypedEventTarget<IFileListFilterEvents> implements IFileListFilter {
61
76
  id: string;
@@ -1,12 +1,14 @@
1
1
  import { FileType } from './fileType';
2
- import { INode, Node } from './node';
2
+ import { Node } from './node';
3
3
 
4
4
  export declare class File extends Node {
5
- get type(): FileType;
5
+ get type(): FileType.File;
6
+ /**
7
+ * Returns a clone of the file
8
+ */
9
+ clone(): File;
6
10
  }
7
11
  /**
8
12
  * Interface of the File class
9
13
  */
10
- export interface IFile extends INode {
11
- readonly type: FileType.File;
12
- }
14
+ export type IFile = Pick<File, keyof File>;
@@ -1,18 +1,18 @@
1
- import { FileType } from './fileType';
2
- import { INode, Node } from './node';
3
1
  import { NodeData } from './nodeData';
2
+ import { FileType } from './fileType';
3
+ import { Node } from './node';
4
4
 
5
5
  export declare class Folder extends Node {
6
6
  constructor(data: NodeData);
7
- get type(): FileType;
8
- get extension(): string | null;
9
- get mime(): string;
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;
10
14
  }
11
15
  /**
12
16
  * Interface of the folder class
13
17
  */
14
- export interface IFolder extends INode {
15
- readonly type: FileType.Folder;
16
- readonly extension: null;
17
- readonly mime: 'httpd/unix-directory';
18
- }
18
+ export type IFolder = Pick<Folder, keyof Folder>;
@@ -109,7 +109,11 @@ export declare abstract class Node {
109
109
  */
110
110
  get owner(): string | null;
111
111
  /**
112
- * Is this a dav-related ressource ?
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.
113
117
  */
114
118
  get isDavRessource(): boolean;
115
119
  /**
@@ -134,6 +138,10 @@ export declare abstract class Node {
134
138
  * Set the node status.
135
139
  */
136
140
  set status(status: NodeStatus | undefined);
141
+ /**
142
+ * Get the node data
143
+ */
144
+ get data(): NodeData;
137
145
  /**
138
146
  * Move the node to a new destination
139
147
  *
@@ -159,6 +167,10 @@ export declare abstract class Node {
159
167
  * @param attributes The new attributes to update on the Node attributes
160
168
  */
161
169
  update(attributes: Attribute): void;
170
+ /**
171
+ * Returns a clone of the node
172
+ */
173
+ abstract clone(): Node;
162
174
  }
163
175
  /**
164
176
  * Interface of the node class
@@ -8,7 +8,7 @@ export interface NodeData {
8
8
  /** Unique ID */
9
9
  id?: number;
10
10
  /**
11
- * URL to the ressource.
11
+ * URL to the resource.
12
12
  * e.g. https://cloud.domain.com/remote.php/dav/files/emma/Photos/picture.jpg
13
13
  * or https://domain.com/Photos/picture.jpg
14
14
  */
@@ -42,9 +42,9 @@ export interface NodeData {
42
42
  * Check if a node source is from a specific DAV service
43
43
  *
44
44
  * @param source The source to check
45
- * @param davService Pattern to check if source is DAV ressource
45
+ * @param davService Pattern to check if source is DAV resource
46
46
  */
47
- export declare const isDavRessource: (source: string, davService: RegExp) => boolean;
47
+ export declare const isDavResource: (source: string, davService: RegExp) => boolean;
48
48
  /**
49
49
  * Validate Node construct data
50
50
  *