@nextcloud/files 3.0.0-beta.13 → 3.0.0-beta.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/fileListHeaders.d.ts +46 -0
- package/dist/index.cjs +3 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +5 -3
- package/dist/index.mjs +102 -57
- package/dist/index.mjs.map +1 -1
- package/dist/newFileMenu.d.ts +9 -3
- package/package.json +8 -8
|
@@ -0,0 +1,46 @@
|
|
|
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
|
+
export interface HeaderData {
|
|
24
|
+
/** Unique ID */
|
|
25
|
+
id: string;
|
|
26
|
+
/** Order */
|
|
27
|
+
order: number;
|
|
28
|
+
/** Condition wether this header is shown or not */
|
|
29
|
+
enabled?: (folder: Folder, view: any) => boolean;
|
|
30
|
+
/** Executed when file list is initialized */
|
|
31
|
+
render: (el: HTMLElement, folder: Folder, view: any) => void;
|
|
32
|
+
/** Executed when root folder changed */
|
|
33
|
+
updated(folder: Folder, view: any): any;
|
|
34
|
+
}
|
|
35
|
+
export declare class Header {
|
|
36
|
+
private _header;
|
|
37
|
+
constructor(header: HeaderData);
|
|
38
|
+
get id(): string;
|
|
39
|
+
get order(): number;
|
|
40
|
+
get enabled(): ((folder: Folder, view: any) => boolean) | undefined;
|
|
41
|
+
get render(): (el: HTMLElement, folder: Folder, view: any) => void;
|
|
42
|
+
get updated(): (folder: Folder, view: any) => any;
|
|
43
|
+
private validateHeader;
|
|
44
|
+
}
|
|
45
|
+
export declare const registerFileListHeaders: (header: Header) => void;
|
|
46
|
+
export declare const getFileListHeaders: () => Header[];
|
package/dist/index.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("@nextcloud/auth"),y=require("@nextcloud/logger"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("@nextcloud/auth"),y=require("@nextcloud/logger"),L=require("@nextcloud/l10n"),a=require("path"),I=require("@nextcloud/router"),E=require("webdav"),q=require("webdav/dist/node/request.js"),B=e=>e===null?y.getLoggerBuilder().setApp("files").build():y.getLoggerBuilder().setApp("files").setUid(e.uid).build(),s=B(c.getCurrentUser());class M{_entries=[];registerEntry(t){this.validateEntry(t),this._entries.push(t)}unregisterEntry(t){const r=typeof t=="string"?this.getEntryIndex(t):this.getEntryIndex(t.id);if(r===-1){s.warn("Entry not found, nothing removed",{entry:t,entries:this.getEntries()});return}this._entries.splice(r,1)}getEntries(t){return t?this._entries.filter(r=>typeof r.if=="function"?r.if(t):!0):this._entries}getEntryIndex(t){return this._entries.findIndex(r=>r.id===t)}validateEntry(t){if(!t.id||!t.displayName||!(t.iconSvgInline||t.iconClass))throw new Error("Invalid entry");if(typeof t.id!="string"||typeof t.displayName!="string")throw new Error("Invalid id or displayName property");if(t.iconClass&&typeof t.iconClass!="string"||t.iconSvgInline&&typeof t.iconSvgInline!="string")throw new Error("Invalid icon provided");if(t.if!==void 0&&typeof t.if!="function")throw new Error("Invalid if property");if(t.templateName&&typeof t.templateName!="string")throw new Error("Invalid templateName property");if(t.handler&&typeof t.handler!="function")throw new Error("Invalid handler property");if(!t.templateName&&!t.handler)throw new Error("At least a templateName or a handler must be provided");if(this.getEntryIndex(t.id)!==-1)throw new Error("Duplicate entry")}}const w=function(){return typeof window._nc_newfilemenu>"u"&&(window._nc_newfilemenu=new M,s.debug("NewFileMenu initialized")),window._nc_newfilemenu},h=["B","KB","MB","GB","TB","PB"],f=["B","KiB","MiB","GiB","TiB","PiB"];function T(e,t=!1,r=!1){typeof e=="string"&&(e=Number(e));let n=e>0?Math.floor(Math.log(e)/Math.log(r?1024:1e3)):0;n=Math.min((r?f.length:h.length)-1,n);const d=r?f[n]:h[n];let i=(e/Math.pow(r?1024:1e3,n)).toFixed(1);return t===!0&&n===0?(i!=="0.0"?"< 1 ":"0 ")+(r?f[1]:h[1]):(n<2?i=parseFloat(i).toFixed(0):i=parseFloat(i).toLocaleString(L.getCanonicalLocale()),i+" "+d)}class z{_action;constructor(t){this.validateAction(t),this._action=t}get id(){return this._action.id}get displayName(){return this._action.displayName}get iconSvgInline(){return this._action.iconSvgInline}get enabled(){return this._action.enabled}get exec(){return this._action.exec}get execBatch(){return this._action.execBatch}get order(){return this._action.order}get default(){return this._action.default}get inline(){return this._action.inline}get renderInline(){return this._action.renderInline}validateAction(t){if(!t.id||typeof t.id!="string")throw new Error("Invalid id");if(!t.displayName||typeof t.displayName!="function")throw new Error("Invalid displayName function");if(!t.iconSvgInline||typeof t.iconSvgInline!="function")throw new Error("Invalid iconSvgInline function");if(!t.exec||typeof t.exec!="function")throw new Error("Invalid exec function");if("enabled"in t&&typeof t.enabled!="function")throw new Error("Invalid enabled function");if("execBatch"in t&&typeof t.execBatch!="function")throw new Error("Invalid execBatch function");if("order"in t&&typeof t.order!="number")throw new Error("Invalid order");if("default"in t&&typeof t.default!="boolean")throw new Error("Invalid default");if("inline"in t&&typeof t.inline!="function")throw new Error("Invalid inline function");if("renderInline"in t&&typeof t.renderInline!="function")throw new Error("Invalid renderInline function")}}const C=function(e){if(typeof window._nc_fileactions>"u"&&(window._nc_fileactions=[],s.debug("FileActions initialized")),window._nc_fileactions.find(t=>t.id===e.id)){s.error(`FileAction ${e.id} already registered`,{action:e});return}window._nc_fileactions.push(e)},U=function(){return typeof window._nc_fileactions>"u"&&(window._nc_fileactions=[],s.debug("FileActions initialized")),window._nc_fileactions};class H{_header;constructor(t){this.validateHeader(t),this._header=t}get id(){return this._header.id}get order(){return this._header.order}get enabled(){return this._header.enabled}get render(){return this._header.render}get updated(){return this._header.updated}validateHeader(t){if(!t.id||!t.render||!t.updated)throw new Error("Invalid header: id, render and updated are required");if(typeof t.id!="string")throw new Error("Invalid id property");if(t.enabled!==void 0&&typeof t.enabled!="function")throw new Error("Invalid enabled property");if(t.render&&typeof t.render!="function")throw new Error("Invalid render property");if(t.updated&&typeof t.updated!="function")throw new Error("Invalid updated property")}}const O=function(e){if(typeof window._nc_filelistheader>"u"&&(window._nc_filelistheader=[],s.debug("FileListHeaders initialized")),window._nc_filelistheader.find(t=>t.id===e.id)){s.error(`Header ${e.id} already registered`,{header:e});return}window._nc_filelistheader.push(e)},k=function(){return typeof window._nc_filelistheader>"u"&&(window._nc_filelistheader=[],s.debug("FileListHeaders initialized")),window._nc_filelistheader};var o=(e=>(e[e.NONE=0]="NONE",e[e.CREATE=4]="CREATE",e[e.READ=1]="READ",e[e.UPDATE=2]="UPDATE",e[e.DELETE=8]="DELETE",e[e.SHARE=16]="SHARE",e[e.ALL=31]="ALL",e))(o||{});const m=["d:getcontentlength","d:getcontenttype","d:getetag","d:getlastmodified","d:quota-available-bytes","d:resourcetype","nc:has-preview","nc:is-encrypted","nc:mount-type","nc:share-attributes","oc:comments-unread","oc:favorite","oc:fileid","oc:owner-display-name","oc:owner-id","oc:permissions","oc:share-types","oc:size","ocs:share-permissions"],g={d:"DAV:",nc:"http://nextcloud.org/ns",oc:"http://owncloud.org/ns",ocs:"http://open-collaboration-services.org/ns"},G=function(e,t={nc:"http://nextcloud.org/ns"}){typeof window._nc_dav_properties>"u"&&(window._nc_dav_properties=[...m],window._nc_dav_namespaces={...g});const r={...window._nc_dav_namespaces,...t};if(window._nc_dav_properties.find(d=>d===e))return s.error(`${e} already registered`,{prop:e}),!1;if(e.startsWith("<")||e.split(":").length!==2)return s.error(`${e} is not valid. See example: 'oc:fileid'`,{prop:e}),!1;const n=e.split(":")[0];return r[n]?(window._nc_dav_properties.push(e),window._nc_dav_namespaces=r,!0):(s.error(`${e} namespace unknown`,{prop:e,namespaces:r}),!1)},l=function(){return typeof window._nc_dav_properties>"u"&&(window._nc_dav_properties=[...m]),window._nc_dav_properties.map(e=>`<${e} />`).join(" ")},u=function(){return typeof window._nc_dav_namespaces>"u"&&(window._nc_dav_namespaces={...g}),Object.keys(window._nc_dav_namespaces).map(e=>`xmlns:${e}="${window._nc_dav_namespaces?.[e]}"`).join(" ")},D=function(){return`<?xml version="1.0"?>
|
|
2
2
|
<d:propfind ${u()}>
|
|
3
3
|
<d:prop>
|
|
4
4
|
${l()}
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
<oc:filter-rules>
|
|
12
12
|
<oc:favorite>1</oc:favorite>
|
|
13
13
|
</oc:filter-rules>
|
|
14
|
-
</oc:filter-files>`},
|
|
14
|
+
</oc:filter-files>`},j=function(e){return`<?xml version="1.0" encoding="UTF-8"?>
|
|
15
15
|
<d:searchrequest ${u()}
|
|
16
16
|
xmlns:ns="https://github.com/icewind1991/SearchDAV/ns">
|
|
17
17
|
<d:basicsearch>
|
|
@@ -65,4 +65,4 @@
|
|
|
65
65
|
<ns:firstresult>0</ns:firstresult>
|
|
66
66
|
</d:limit>
|
|
67
67
|
</d:basicsearch>
|
|
68
|
-
</d:searchrequest>`},N=function(e=""){let t=o.NONE;return e&&((e.includes("C")||e.includes("K"))&&(t|=o.CREATE),e.includes("G")&&(t|=o.READ),(e.includes("W")||e.includes("N")||e.includes("V"))&&(t|=o.UPDATE),e.includes("D")&&(t|=o.DELETE),e.includes("R")&&(t|=o.SHARE)),t};var p=(e=>(e.Folder="folder",e.File="file",e))(p||{});const R=function(e,t){return e.match(t)!==null},b=(e,t)=>{if(e.id&&typeof e.id!="number")throw new Error("Invalid id type of value");if(!e.source)throw new Error("Missing mandatory source");try{new URL(e.source)}catch{throw new Error("Invalid source format, source must be a valid URL")}if(!e.source.startsWith("http"))throw new Error("Invalid source format, only http(s) is supported");if(e.mtime&&!(e.mtime instanceof Date))throw new Error("Invalid mtime type");if(e.crtime&&!(e.crtime instanceof Date))throw new Error("Invalid crtime type");if(!e.mime||typeof e.mime!="string"||!e.mime.match(/^[-\w.]+\/[-+\w.]+$/gi))throw new Error("Missing or invalid mandatory mime");if("size"in e&&typeof e.size!="number"&&e.size!==void 0)throw new Error("Invalid size type");if("permissions"in e&&e.permissions!==void 0&&!(typeof e.permissions=="number"&&e.permissions>=o.NONE&&e.permissions<=o.ALL))throw new Error("Invalid permissions");if(e.owner&&e.owner!==null&&typeof e.owner!="string")throw new Error("Invalid owner type");if(e.attributes&&typeof e.attributes!="object")throw new Error("Invalid attributes type");if(e.root&&typeof e.root!="string")throw new Error("Invalid root type");if(e.root&&!e.root.startsWith("/"))throw new Error("Root must start with a leading slash");if(e.root&&!e.source.includes(e.root))throw new Error("Root must be part of the source");if(e.root&&R(e.source,t)){const r=e.source.match(t)[0];if(!e.source.includes(a.join(r,e.root)))throw new Error("The root must be relative to the service. e.g /files/emma")}};class
|
|
68
|
+
</d:searchrequest>`},N=function(e=""){let t=o.NONE;return e&&((e.includes("C")||e.includes("K"))&&(t|=o.CREATE),e.includes("G")&&(t|=o.READ),(e.includes("W")||e.includes("N")||e.includes("V"))&&(t|=o.UPDATE),e.includes("D")&&(t|=o.DELETE),e.includes("R")&&(t|=o.SHARE)),t};var p=(e=>(e.Folder="folder",e.File="file",e))(p||{});const R=function(e,t){return e.match(t)!==null},b=(e,t)=>{if(e.id&&typeof e.id!="number")throw new Error("Invalid id type of value");if(!e.source)throw new Error("Missing mandatory source");try{new URL(e.source)}catch{throw new Error("Invalid source format, source must be a valid URL")}if(!e.source.startsWith("http"))throw new Error("Invalid source format, only http(s) is supported");if(e.mtime&&!(e.mtime instanceof Date))throw new Error("Invalid mtime type");if(e.crtime&&!(e.crtime instanceof Date))throw new Error("Invalid crtime type");if(!e.mime||typeof e.mime!="string"||!e.mime.match(/^[-\w.]+\/[-+\w.]+$/gi))throw new Error("Missing or invalid mandatory mime");if("size"in e&&typeof e.size!="number"&&e.size!==void 0)throw new Error("Invalid size type");if("permissions"in e&&e.permissions!==void 0&&!(typeof e.permissions=="number"&&e.permissions>=o.NONE&&e.permissions<=o.ALL))throw new Error("Invalid permissions");if(e.owner&&e.owner!==null&&typeof e.owner!="string")throw new Error("Invalid owner type");if(e.attributes&&typeof e.attributes!="object")throw new Error("Invalid attributes type");if(e.root&&typeof e.root!="string")throw new Error("Invalid root type");if(e.root&&!e.root.startsWith("/"))throw new Error("Root must start with a leading slash");if(e.root&&!e.source.includes(e.root))throw new Error("Root must be part of the source");if(e.root&&R(e.source,t)){const r=e.source.match(t)[0];if(!e.source.includes(a.join(r,e.root)))throw new Error("The root must be relative to the service. e.g /files/emma")}};class _{_data;_attributes;_knownDavService=/(remote|public)\.php\/(web)?dav/i;constructor(t,r){b(t,r||this._knownDavService),this._data=t;const n={set:(d,i,$)=>(this.updateMtime(),Reflect.set(d,i,$)),deleteProperty:(d,i)=>(this.updateMtime(),Reflect.deleteProperty(d,i))};this._attributes=new Proxy(t.attributes||{},n),delete this._data.attributes,r&&(this._knownDavService=r)}get source(){return this._data.source.replace(/\/$/i,"")}get basename(){return a.basename(this.source)}get extension(){return a.extname(this.source)}get dirname(){if(this.root){const r=this.source.indexOf(this.root);return a.dirname(this.source.slice(r+this.root.length)||"/")}const t=new URL(this.source);return a.dirname(t.pathname)}get mime(){return this._data.mime}get mtime(){return this._data.mtime}get crtime(){return this._data.crtime}get size(){return this._data.size}get attributes(){return this._attributes}get permissions(){return this.owner===null&&!this.isDavRessource?o.READ:this._data.permissions!==void 0?this._data.permissions:o.NONE}get owner(){return this.isDavRessource?this._data.owner:null}get isDavRessource(){return R(this.source,this._knownDavService)}get root(){return this._data.root?this._data.root.replace(/^(.+)\/$/,"$1"):this.isDavRessource&&a.dirname(this.source).split(this._knownDavService).pop()||null}get path(){if(this.root){const t=this.source.indexOf(this.root);return this.source.slice(t+this.root.length)||"/"}return(this.dirname+"/"+this.basename).replace(/\/\//g,"/")}get fileid(){return this._data?.id||this.attributes?.fileid}move(t){b({...this._data,source:t},this._knownDavService),this._data.source=t,this.updateMtime()}rename(t){if(t.includes("/"))throw new Error("Invalid basename");this.move(a.dirname(this.source)+"/"+t)}updateMtime(){this._data.mtime&&(this._data.mtime=new Date)}}class F extends _{get type(){return p.File}}class A extends _{constructor(t){super({...t,mime:"httpd/unix-directory"})}get type(){return p.Folder}get extension(){return null}get mime(){return"httpd/unix-directory"}}const v=`/files/${c.getCurrentUser()?.uid}`,S=I.generateRemoteUrl("dav"+v),W=function(e=S){const t=E.createClient(e,{headers:{requesttoken:c.getRequestToken()||""}});return E.getPatcher().patch("request",r=>(r.headers?.method&&(r.method=r.headers.method,delete r.headers.method),q.request(r))),t},K=async(e,t="/")=>(await e.getDirectoryContents(t,{details:!0,data:t==="/"?x():D(),headers:{method:t==="/"?"REPORT":"PROPFIND"},includeSelf:!0})).data.filter(r=>r.filename!==t).map(r=>P(r)),P=function(e,t=v){const r=e.props,n=N(r?.permissions),d=c.getCurrentUser()?.uid,i={id:r?.fileid||0,source:I.generateRemoteUrl(`dav${t}${e.filename}`),mtime:new Date(Date.parse(e.lastmod)),mime:e.mime,size:r?.size||0,permissions:n,owner:d,root:t,attributes:{...e,...r,hasPreview:r?.["has-preview"]}};return delete i.attributes?.props,e.type==="file"?new F(i):new A(i)},V=function(e){return w().registerEntry(e)},J=function(e){return w().unregisterEntry(e)},Q=function(e){return w().getEntries(e)};exports.File=F,exports.FileAction=z,exports.FileType=p,exports.Folder=A,exports.Header=H,exports.Node=_,exports.Permission=o,exports.addNewFileMenuEntry=V,exports.davDefaultRootUrl=S,exports.davGetClient=W,exports.davGetDefaultPropfind=D,exports.davGetFavoritesReport=x,exports.davGetRecentSearch=j,exports.davParsePermissions=N,exports.davResultToNode=P,exports.davRootPath=v,exports.defaultDavNamespaces=g,exports.defaultDavProperties=m,exports.formatFileSize=T,exports.getDavNameSpaces=u,exports.getDavProperties=l,exports.getFavoriteNodes=K,exports.getFileActions=U,exports.getFileListHeaders=k,exports.getNewFileMenuEntries=Q,exports.registerDavProperty=G,exports.registerFileAction=C,exports.registerFileListHeaders=O,exports.removeNewFileMenuEntry=J;
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":["../lib/utils/logger.ts","../lib/newFileMenu.ts","../lib/humanfilesize.ts","../lib/fileAction.ts","../lib/permissions.ts","../lib/dav/davProperties.ts","../lib/dav/davPermissions.ts","../lib/files/fileType.ts","../lib/files/nodeData.ts","../lib/files/node.ts","../lib/files/file.ts","../lib/files/folder.ts","../lib/dav/dav.ts","../lib/index.ts"],"sourcesContent":["/**\n * @copyright 2019 Christoph Wurst <christoph@winzerhof-wurst.at>\n *\n * @author Christoph Wurst <christoph@winzerhof-wurst.at>\n *\n * @license AGPL-3.0-or-later\n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n *\n */\n\nimport { getCurrentUser } from '@nextcloud/auth'\nimport { getLoggerBuilder } from '@nextcloud/logger'\n\nconst getLogger = user => {\n\tif (user === null) {\n\t\treturn getLoggerBuilder()\n\t\t\t.setApp('files')\n\t\t\t.build()\n\t}\n\treturn getLoggerBuilder()\n\t\t.setApp('files')\n\t\t.setUid(user.uid)\n\t\t.build()\n}\n\nexport default getLogger(getCurrentUser())\n","/**\n * @copyright Copyright (c) 2021 John Molakvoæ <skjnldsv@protonmail.com>\n *\n * @author John Molakvoæ <skjnldsv@protonmail.com>\n *\n * @license AGPL-3.0-or-later\n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n *\n */\n\nimport logger from './utils/logger'\n\nexport interface Entry {\n\t/** Unique ID */\n\tid: string\n\t/** Translatable string displayed in the menu */\n\tdisplayName: string\n\t// Default new file name\n\ttemplateName?: string\n\t// Condition wether this entry is shown or not\n\tif?: (context: object) => boolean\n\t/**\n\t * Either iconSvgInline or iconClass must be defined\n\t * Svg as inline string. <svg><path fill=\"...\" /></svg>\n\t */\n\ticonSvgInline?: string\n\t/** Existing icon css class */\n\ticonClass?: string\n\t/** Function to be run after creation */\n\thandler?: () => void\n}\n\nexport class NewFileMenu {\n\n\tprivate _entries: Array<Entry> = []\n\n\tpublic registerEntry(entry: Entry) {\n\t\tthis.validateEntry(entry)\n\t\tthis._entries.push(entry)\n\t}\n\n\tpublic unregisterEntry(entry: Entry | string) {\n\t\tconst entryIndex = typeof entry === 'string'\n\t\t\t? this.getEntryIndex(entry)\n\t\t\t: this.getEntryIndex(entry.id)\n\n\t\tif (entryIndex === -1) {\n\t\t\tlogger.warn('Entry not found, nothing removed', { entry, entries: this.getEntries() })\n\t\t\treturn\n\t\t}\n\n\t\tthis._entries.splice(entryIndex, 1)\n\t}\n\n\t/**\n\t * Get the list of registered entries\n\t *\n\t * @param {FileInfo} context the creation context. Usually the current folder FileInfo\n\t */\n\tpublic getEntries(context?: object): Array<Entry> {\n\t\tif (context) {\n\t\t\treturn this._entries\n\t\t\t\t.filter(entry => typeof entry.if === 'function' ? entry.if(context) : true)\n\t\t}\n\t\treturn this._entries\n\t}\n\n\tprivate getEntryIndex(id: string): number {\n\t\treturn this._entries.findIndex(entry => entry.id === id)\n\t}\n\n\tprivate validateEntry(entry: Entry) {\n\t\tif (!entry.id || !entry.displayName || !(entry.iconSvgInline || entry.iconClass)) {\n\t\t\tthrow new Error('Invalid entry')\n\t\t}\n\n\t\tif (typeof entry.id !== 'string'\n\t\t\t|| typeof entry.displayName !== 'string') {\n\t\t\tthrow new Error('Invalid id or displayName property')\n\t\t}\n\n\t\tif ((entry.iconClass && typeof entry.iconClass !== 'string')\n\t\t\t|| (entry.iconSvgInline && typeof entry.iconSvgInline !== 'string')) {\n\t\t\tthrow new Error('Invalid icon provided')\n\t\t}\n\n\t\tif (entry.if !== undefined && typeof entry.if !== 'function') {\n\t\t\tthrow new Error('Invalid if property')\n\t\t}\n\n\t\tif (entry.templateName && typeof entry.templateName !== 'string') {\n\t\t\tthrow new Error('Invalid templateName property')\n\t\t}\n\n\t\tif (entry.handler && typeof entry.handler !== 'function') {\n\t\t\tthrow new Error('Invalid handler property')\n\t\t}\n\n\t\tif (!entry.templateName && !entry.handler) {\n\t\t\tthrow new Error('At least a templateName or a handler must be provided')\n\t\t}\n\n\t\tif (this.getEntryIndex(entry.id) !== -1) {\n\t\t\tthrow new Error('Duplicate entry')\n\t\t}\n\t}\n\n}\n\nexport const getNewFileMenu = function(): NewFileMenu {\n\tif (typeof window._nc_newfilemenu === 'undefined') {\n\t\twindow._nc_newfilemenu = new NewFileMenu()\n\t\tlogger.debug('NewFileMenu initialized')\n\t}\n\treturn window._nc_newfilemenu\n}\n","/**\n * @copyright 2019 Christoph Wurst <christoph@winzerhof-wurst.at>\n *\n * @author Christoph Wurst <christoph@winzerhof-wurst.at>\n * @author John Molakvoæ <skjnldsv@protonmail.com>\n *\n * @license AGPL-3.0-or-later\n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n *\n */\n\nimport { getCanonicalLocale } from '@nextcloud/l10n'\n\nconst humanList = ['B', 'KB', 'MB', 'GB', 'TB', 'PB']\nconst humanListBinary = ['B', 'KiB', 'MiB', 'GiB', 'TiB', 'PiB']\n\n/**\n * Format a file size in a human-like format. e.g. 42GB\n *\n * @param size in bytes\n * @param skipSmallSizes avoid rendering tiny sizes and return '< 1 KB' instead\n * @param binaryPrefixes True if binary prefixes like `KiB` should be used (size base 2)\n */\nexport function formatFileSize(size: number|string, skipSmallSizes = false, binaryPrefixes = false): string {\n\n\tif (typeof size === 'string') {\n\t\tsize = Number(size)\n\t}\n\n\t/*\n\t* @note This block previously used Log base 1024, per IEC 80000-13;\n\t* however, the wrong prefix was used. Now we use decimal calculation\n\t* with base 1000 per the SI. Base 1024 calculation with binary\n\t* prefixes is optional, but has yet to be added to the UI.\n\t*/\n\t// Calculate Log with base 1024 or 1000: size = base ** order\n\tlet order = size > 0 ? Math.floor(Math.log(size) / Math.log(binaryPrefixes ? 1024 : 1000)) : 0\n\t// Stay in range of the byte sizes that are defined\n\torder = Math.min((binaryPrefixes ? humanListBinary.length : humanList.length) - 1, order)\n\tconst readableFormat = binaryPrefixes ? humanListBinary[order] : humanList[order]\n\tlet relativeSize = (size / Math.pow(binaryPrefixes ? 1024 : 1000, order)).toFixed(1)\n\n\tif (skipSmallSizes === true && order === 0) {\n\t\treturn (relativeSize !== '0.0' ? '< 1 ' : '0 ') + (binaryPrefixes ? humanListBinary[1] : humanList[1])\n\t}\n\n\tif (order < 2) {\n\t\trelativeSize = parseFloat(relativeSize).toFixed(0)\n\t} else {\n\t\trelativeSize = parseFloat(relativeSize).toLocaleString(getCanonicalLocale())\n\t}\n\n\treturn relativeSize + ' ' + readableFormat\n}\n","/**\n * @copyright Copyright (c) 2021 John Molakvoæ <skjnldsv@protonmail.com>\n *\n * @author John Molakvoæ <skjnldsv@protonmail.com>\n *\n * @license AGPL-3.0-or-later\n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n *\n */\n\nimport { Node } from './files/node'\nimport logger from './utils/logger'\n\ninterface FileActionData {\n\t/** Unique ID */\n\tid: string\n\t/** Translatable string displayed in the menu */\n\tdisplayName: (files: Node[], view) => string\n\t/** Svg as inline string. <svg><path fill=\"...\" /></svg> */\n\ticonSvgInline: (files: Node[], view) => string\n\t/** Condition wether this action is shown or not */\n\tenabled?: (files: Node[], view) => boolean\n\t/**\n\t * Function executed on single file action\n\t * @return true if the action was executed successfully,\n\t * false otherwise and null if the action is silent/undefined.\n\t * @throws Error if the action failed\n\t */\n\texec: (file: Node, view, dir: string) => Promise<boolean|null>,\n\t/**\n\t * Function executed on multiple files action\n\t * @return true if the action was executed successfully,\n\t * false otherwise and null if the action is silent/undefined.\n\t * @throws Error if the action failed\n\t */\n\texecBatch?: (files: Node[], view, dir: string) => Promise<(boolean|null)[]>\n\t/** This action order in the list */\n\torder?: number,\n\t/** Make this action the default */\n\tdefault?: boolean,\n\t/**\n\t * If true, the renderInline function will be called\n\t */\n\tinline?: (file: Node, view) => boolean,\n\t/**\n\t * If defined, the returned html element will be\n\t * appended before the actions menu.\n\t */\n\trenderInline?: (file: Node, view) => HTMLElement,\n}\n\nexport class FileAction {\n\n\tprivate _action: FileActionData\n\n\tconstructor(action: FileActionData) {\n\t\tthis.validateAction(action)\n\t\tthis._action = action\n\t}\n\n\tget id() {\n\t\treturn this._action.id\n\t}\n\n\tget displayName() {\n\t\treturn this._action.displayName\n\t}\n\n\tget iconSvgInline() {\n\t\treturn this._action.iconSvgInline\n\t}\n\n\tget enabled() {\n\t\treturn this._action.enabled\n\t}\n\n\tget exec() {\n\t\treturn this._action.exec\n\t}\n\n\tget execBatch() {\n\t\treturn this._action.execBatch\n\t}\n\n\tget order() {\n\t\treturn this._action.order\n\t}\n\n\tget default() {\n\t\treturn this._action.default\n\t}\n\n\tget inline() {\n\t\treturn this._action.inline\n\t}\n\n\tget renderInline() {\n\t\treturn this._action.renderInline\n\t}\n\n\tprivate validateAction(action: FileActionData) {\n\t\tif (!action.id || typeof action.id !== 'string') {\n\t\t\tthrow new Error('Invalid id')\n\t\t}\n\n\t\tif (!action.displayName || typeof action.displayName !== 'function') {\n\t\t\tthrow new Error('Invalid displayName function')\n\t\t}\n\n\t\tif (!action.iconSvgInline || typeof action.iconSvgInline !== 'function') {\n\t\t\tthrow new Error('Invalid iconSvgInline function')\n\t\t}\n\n\t\tif (!action.exec || typeof action.exec !== 'function') {\n\t\t\tthrow new Error('Invalid exec function')\n\t\t}\n\n\t\t// Optional properties --------------------------------------------\n\t\tif ('enabled' in action && typeof action.enabled !== 'function') {\n\t\t\tthrow new Error('Invalid enabled function')\n\t\t}\n\n\t\tif ('execBatch' in action && typeof action.execBatch !== 'function') {\n\t\t\tthrow new Error('Invalid execBatch function')\n\t\t}\n\n\t\tif ('order' in action && typeof action.order !== 'number') {\n\t\t\tthrow new Error('Invalid order')\n\t\t}\n\n\t\tif ('default' in action && typeof action.default !== 'boolean') {\n\t\t\tthrow new Error('Invalid default')\n\t\t}\n\n\t\tif ('inline' in action && typeof action.inline !== 'function') {\n\t\t\tthrow new Error('Invalid inline function')\n\t\t}\n\n\t\tif ('renderInline' in action && typeof action.renderInline !== 'function') {\n\t\t\tthrow new Error('Invalid renderInline function')\n\t\t}\n\t}\n\n}\n\nexport const registerFileAction = function(action: FileAction): void {\n\tif (typeof window._nc_fileactions === 'undefined') {\n\t\twindow._nc_fileactions = []\n\t\tlogger.debug('FileActions initialized')\n\t}\n\n\t// Check duplicates\n\tif (window._nc_fileactions.find(search => search.id === action.id)) {\n\t\tlogger.error(`FileAction ${action.id} already registered`, { action })\n\t\treturn\n\t}\n\n\twindow._nc_fileactions.push(action)\n}\n\nexport const getFileActions = function(): FileAction[] {\n\treturn window._nc_fileactions || []\n}\n","/**\n * @copyright Copyright (c) 2022 John Molakvoæ <skjnldsv@protonmail.com>\n *\n * @author John Molakvoæ <skjnldsv@protonmail.com>\n *\n * @license AGPL-3.0-or-later\n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n *\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 * @copyright Copyright (c) 2023 John Molakvoæ <skjnldsv@protonmail.com>\n *\n * @author John Molakvoæ <skjnldsv@protonmail.com>\n * @author Ferdinand Thiessen <opensource@fthiessen.de>\n *\n * @license AGPL-3.0-or-later\n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n *\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:quota-available-bytes',\n\t'd:resourcetype',\n\t'nc:has-preview',\n\t'nc:is-encrypted',\n\t'nc:mount-type',\n\t'nc:share-attributes',\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:share-types',\n\t'oc:size',\n\t'ocs:share-permissions',\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.error(`${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 davGetDefaultPropfind = 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 davGetFavoritesReport = 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 davGetRecentSearch = 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 * @copyright Copyright (c) 2023 John Molakvoæ <skjnldsv@protonmail.com>\n *\n * @author John Molakvoæ <skjnldsv@protonmail.com>\n * @author Ferdinand Thiessen <opensource@fthiessen.de>\n *\n * @license AGPL-3.0-or-later\n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n *\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 davParsePermissions = 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 * @copyright Copyright (c) 2022 John Molakvoæ <skjnldsv@protonmail.com>\n *\n * @author John Molakvoæ <skjnldsv@protonmail.com>\n *\n * @license AGPL-3.0-or-later\n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n *\n */\nexport enum FileType {\n\tFolder = 'folder',\n\tFile = 'file',\n}\n","/**\n * @copyright Copyright (c) 2022 John Molakvoæ <skjnldsv@protonmail.com>\n *\n * @author John Molakvoæ <skjnldsv@protonmail.com>\n *\n * @license AGPL-3.0-or-later\n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n *\n */\n\nimport { join } from 'path'\nimport { Permission } from '../permissions'\n\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 ressource.\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\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\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 ressource\n */\nexport const isDavRessource = 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.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 && isDavRessource(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","/**\n * @copyright Copyright (c) 2022 John Molakvoæ <skjnldsv@protonmail.com>\n *\n * @author John Molakvoæ <skjnldsv@protonmail.com>\n *\n * @license AGPL-3.0-or-later\n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n *\n */\nimport { basename, extname, dirname } from 'path'\nimport { Permission } from '../permissions'\nimport { FileType } from './fileType'\nimport { Attribute, NodeData, isDavRessource, validateData } from './nodeData'\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\tconstructor(data: NodeData, davService?: RegExp) {\n\t\t// Validate data\n\t\tvalidateData(data, davService || this._knownDavService)\n\n\t\tthis._data = data\n\n\t\tconst handler = {\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\t\t\tset: (target: Attribute, prop: string, value: any): any => {\n\t\t\t\t// Edit modification time\n\t\t\t\tthis.updateMtime()\n\t\t\t\t// Apply original changes\n\t\t\t\treturn Reflect.set(target, prop, value)\n\t\t\t},\n\t\t\tdeleteProperty: (target: Attribute, prop: string) => {\n\t\t\t\t// Edit modification time\n\t\t\t\tthis.updateMtime()\n\t\t\t\t// Apply original changes\n\t\t\t\treturn Reflect.deleteProperty(target, prop)\n\t\t\t},\n\t\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\t\t} as ProxyHandler<any>\n\n\t\t// Proxy the attributes to update the mtime on change\n\t\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\t\tthis._attributes = new Proxy(data.attributes || {} as any, handler)\n\t\tdelete this._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 */\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 this object name\n\t */\n\tget basename(): string {\n\t\treturn basename(this.source)\n\t}\n\n\t/**\n\t * Get this object's extension\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\tget dirname(): string {\n\t\tif (this.root) {\n\t\t\t// Using replace would remove all part matching root\n\t\t\tconst firstMatch = this.source.indexOf(this.root)\n\t\t\treturn dirname(this.source.slice(firstMatch + this.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 */\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 * Get the file creation time\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 * Get the file attribute\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 ressource, we can only read it\n\t\tif (this.owner === null && !this.isDavRessource) {\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 * Get the file owner\n\t */\n\tget owner(): string|null {\n\t\t// Remote ressources have no owner\n\t\tif (!this.isDavRessource) {\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 ressource ?\n\t */\n\tget isDavRessource(): boolean {\n\t\treturn isDavRessource(this.source, this._knownDavService)\n\t}\n\n\t/**\n\t * Get the dav root of this object\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.isDavRessource) {\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\t// Using replace would remove all part matching root\n\t\t\tconst firstMatch = this.source.indexOf(this.root)\n\t\t\treturn this.source.slice(firstMatch + this.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 * Will look for the fileid in attributes if undefined.\n\t */\n\tget fileid(): number|undefined {\n\t\treturn this._data?.id || this.attributes?.fileid\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\tthis._data.source = destination\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\tprivate updateMtime() {\n\t\tif (this._data.mtime) {\n\t\t\tthis._data.mtime = new Date()\n\t\t}\n\t}\n\n}\n","/**\n * @copyright Copyright (c) 2022 John Molakvoæ <skjnldsv@protonmail.com>\n *\n * @author John Molakvoæ <skjnldsv@protonmail.com>\n *\n * @license AGPL-3.0-or-later\n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n *\n */\nimport { FileType } from './fileType'\nimport { Node } from './node'\n\nexport class File extends Node {\n\n\tget type(): FileType {\n\t\treturn FileType.File\n\t}\n\n}\n","/**\n * @copyright Copyright (c) 2022 John Molakvoæ <skjnldsv@protonmail.com>\n *\n * @author John Molakvoæ <skjnldsv@protonmail.com>\n *\n * @license AGPL-3.0-or-later\n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n *\n */\nimport { FileType } from './fileType'\nimport { Node } from './node'\nimport { NodeData } from './nodeData'\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 {\n\t\treturn FileType.Folder\n\t}\n\n\tget extension(): string|null {\n\t\treturn null\n\t}\n\n\tget mime(): string {\n\t\treturn 'httpd/unix-directory'\n\t}\n\n}\n","/**\n * @copyright Copyright (c) 2023 John Molakvoæ <skjnldsv@protonmail.com>\n *\n * @author John Molakvoæ <skjnldsv@protonmail.com>\n * @author Ferdinand Thiessen <opensource@fthiessen.de>\n *\n * @license AGPL-3.0-or-later\n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n *\n */\nimport type { DAVResultResponseProps, FileStat, Response, ResponseDataDetailed, WebDAVClient } from 'webdav'\nimport type { Node } from '../files/node'\n\nimport { File } from '../files/file'\nimport { Folder } from '../files/folder'\nimport { NodeData } from '../files/nodeData'\nimport { davParsePermissions } from './davPermissions'\nimport { davGetDefaultPropfind, davGetFavoritesReport } from './davProperties'\n\nimport { getCurrentUser, getRequestToken } from '@nextcloud/auth'\nimport { generateRemoteUrl } from '@nextcloud/router'\nimport { createClient, getPatcher, RequestOptions } from 'webdav'\nimport { request } from 'webdav/dist/node/request.js'\n\n/**\n * Nextcloud DAV result response\n */\ninterface ResponseProps extends DAVResultResponseProps {\n\tpermissions: string\n\tfileid: number\n\tsize: number\n}\n\nexport const davRootPath = `/files/${getCurrentUser()?.uid}`\nexport const davDefaultRootUrl = generateRemoteUrl('dav' + davRootPath)\n\n/**\n * Get a WebDAV client configured to include the Nextcloud request token\n *\n * @param davURL The DAV root URL\n */\nexport const davGetClient = function(davURL = davDefaultRootUrl) {\n\tconst client = createClient(davURL, {\n\t\theaders: {\n\t\t\trequesttoken: getRequestToken() || '',\n\t\t},\n\t})\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// https://github.com/perry-mitchell/hot-patcher/issues/6\n\t// eslint-disable-next-line @typescript-eslint/ban-ts-comment\n\t// @ts-ignore\n\tpatcher.patch('request', (options: RequestOptions): Promise<Response> => {\n\t\tif (options.headers?.method) {\n\t\t\toptions.method = options.headers.method\n\t\t\tdelete options.headers.method\n\t\t}\n\t\treturn request(options)\n\t})\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 */\nexport const getFavoriteNodes = async (davClient: WebDAVClient, path = '/') => {\n\tconst contentsResponse = await davClient.getDirectoryContents(path, {\n\t\tdetails: true,\n\t\t// Only filter favorites if we're at the root\n\t\tdata: path === '/' ? davGetFavoritesReport() : davGetDefaultPropfind(),\n\t\theaders: {\n\t\t\t// Patched in WebdavClient.ts\n\t\t\tmethod: path === '/' ? 'REPORT' : 'PROPFIND',\n\t\t},\n\t\tincludeSelf: true,\n\t}) as ResponseDataDetailed<FileStat[]>\n\n\treturn contentsResponse.data.filter(node => node.filename !== path).map((result) => davResultToNode(result))\n}\n\n/**\n * Covert DAV result `FileStat` to `Node`\n *\n * @param node The DAV result\n * @param davRoot The DAV root path\n */\nexport const davResultToNode = function(node: FileStat, davRoot = davRootPath): Node {\n\tconst props = node.props as ResponseProps\n\tconst permissions = davParsePermissions(props?.permissions)\n\tconst owner = getCurrentUser()?.uid as string\n\n\tconst nodeData: NodeData = {\n\t\tid: (props?.fileid as number) || 0,\n\t\tsource: generateRemoteUrl(`dav${davRoot}${node.filename}`),\n\t\tmtime: new Date(Date.parse(node.lastmod)),\n\t\tmime: node.mime as string,\n\t\tsize: (props?.size as number) || 0,\n\t\tpermissions,\n\t\towner,\n\t\troot: davRoot,\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","/**\n * @copyright 2019 Christoph Wurst <christoph@winzerhof-wurst.at>\n *\n * @author Christoph Wurst <christoph@winzerhof-wurst.at>\n * @author John Molakvoæ <skjnldsv@protonmail.com>\n *\n * @license AGPL-3.0-or-later\n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n *\n */\n\nimport { type Entry, getNewFileMenu } from './newFileMenu'\n\nexport { formatFileSize } from './humanfilesize'\nexport { FileAction, registerFileAction, getFileActions } from './fileAction'\nexport { type Entry } from './newFileMenu'\nexport { Permission } from './permissions'\n\nexport * from './dav/davProperties'\nexport * from './dav/davPermissions'\nexport * from './dav/dav'\n\nexport { FileType } from './files/fileType'\nexport { File } from './files/file'\nexport { Folder } from './files/folder'\nexport { Node } from './files/node'\n\n// TODO: Add FileInfo type!\n\n/**\n * Add a new menu entry to the upload manager menu\n *\n * @param entry The new file menu entry\n */\nexport const addNewFileMenuEntry = function(entry: Entry) {\n\tconst newFileMenu = getNewFileMenu()\n\treturn newFileMenu.registerEntry(entry)\n}\n\n/**\n * Remove a previously registered entry from the upload menu\n *\n * @param entry Entry to remove (or name of entry)\n */\nexport const removeNewFileMenuEntry = function(entry: Entry | string) {\n\tconst newFileMenu = getNewFileMenu()\n\treturn newFileMenu.unregisterEntry(entry)\n}\n\n/**\n * Get the list of registered entries from the upload menu\n *\n * @param {FileInfo} context the creation context. Usually the current folder FileInfo\n */\nexport const getNewFileMenuEntries = function(context?: object) {\n\tconst newFileMenu = getNewFileMenu()\n\treturn newFileMenu.getEntries(context)\n}\n"],"names":["getLogger","user","getLoggerBuilder","logger","getCurrentUser","NewFileMenu","entry","entryIndex","context","id","getNewFileMenu","humanList","humanListBinary","formatFileSize","size","skipSmallSizes","binaryPrefixes","order","readableFormat","relativeSize","getCanonicalLocale","FileAction","action","registerFileAction","search","getFileActions","Permission","defaultDavProperties","defaultDavNamespaces","registerDavProperty","prop","namespace","namespaces","ns","getDavProperties","getDavNameSpaces","davGetDefaultPropfind","davGetFavoritesReport","davGetRecentSearch","lastModified","davParsePermissions","permString","permissions","FileType","isDavRessource","source","davService","validateData","data","service","join","Node","handler","target","value","basename","extname","firstMatch","dirname","url","destination","File","Folder","davRootPath","davDefaultRootUrl","generateRemoteUrl","davGetClient","davURL","client","createClient","getRequestToken","getPatcher","options","request","getFavoriteNodes","davClient","path","node","result","davResultToNode","davRoot","props","owner","nodeData","addNewFileMenuEntry","removeNewFileMenuEntry","getNewFileMenu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GAAGI,EACH,WAAYA,IAAQ,aAAa,CAClC,CAAA,EAGD,OAAOE,OAAAA,EAAS,YAAY,MAErBN,EAAK,OAAS,OAAS,IAAIhB,EAAKsB,CAAQ,EAAI,IAAIrB,EAAOqB,CAAQ,CACvE,ECpFaC,EAAsB,SAAS9E,EAAc,CAElD,OADaI,IACD,cAAcJ,CAAK,CACvC,EAOa+E,EAAyB,SAAS/E,EAAuB,CAE9D,OADaI,IACD,gBAAgBJ,CAAK,CACzC,EAOagF,EAAwB,SAAS9E,EAAkB,CAExD,OADaE,IACD,WAAWF,CAAO,CACtC"}
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../lib/utils/logger.ts","../lib/newFileMenu.ts","../lib/humanfilesize.ts","../lib/fileAction.ts","../lib/fileListHeaders.ts","../lib/permissions.ts","../lib/dav/davProperties.ts","../lib/dav/davPermissions.ts","../lib/files/fileType.ts","../lib/files/nodeData.ts","../lib/files/node.ts","../lib/files/file.ts","../lib/files/folder.ts","../lib/dav/dav.ts","../lib/index.ts"],"sourcesContent":["/**\n * @copyright 2019 Christoph Wurst <christoph@winzerhof-wurst.at>\n *\n * @author Christoph Wurst <christoph@winzerhof-wurst.at>\n *\n * @license AGPL-3.0-or-later\n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n *\n */\n\nimport { getCurrentUser } from '@nextcloud/auth'\nimport { getLoggerBuilder } from '@nextcloud/logger'\n\nconst getLogger = user => {\n\tif (user === null) {\n\t\treturn getLoggerBuilder()\n\t\t\t.setApp('files')\n\t\t\t.build()\n\t}\n\treturn getLoggerBuilder()\n\t\t.setApp('files')\n\t\t.setUid(user.uid)\n\t\t.build()\n}\n\nexport default getLogger(getCurrentUser())\n","/**\n * @copyright Copyright (c) 2021 John Molakvoæ <skjnldsv@protonmail.com>\n *\n * @author John Molakvoæ <skjnldsv@protonmail.com>\n *\n * @license AGPL-3.0-or-later\n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n *\n */\n\nimport { Folder } from '.'\nimport logger from './utils/logger'\n\nexport interface Entry {\n\t/** Unique ID */\n\tid: string\n\t/** Translatable string displayed in the menu */\n\tdisplayName: string\n\t/** Default new file name */\n\ttemplateName?: string\n\t/**\n\t * Condition wether this entry is shown or not\n\t * @param {Folder} context the creation context. Usually the current folder\n\t */\n\tif?: (context: Folder) => boolean\n\t/**\n\t * Either iconSvgInline or iconClass must be defined\n\t * Svg as inline string. <svg><path fill=\"...\" /></svg>\n\t */\n\ticonSvgInline?: string\n\t/** Existing icon css class */\n\ticonClass?: string\n\t/** Function to be run after creation */\n\thandler?: () => void\n}\n\nexport class NewFileMenu {\n\n\tprivate _entries: Array<Entry> = []\n\n\tpublic registerEntry(entry: Entry) {\n\t\tthis.validateEntry(entry)\n\t\tthis._entries.push(entry)\n\t}\n\n\tpublic unregisterEntry(entry: Entry | string) {\n\t\tconst entryIndex = typeof entry === 'string'\n\t\t\t? this.getEntryIndex(entry)\n\t\t\t: this.getEntryIndex(entry.id)\n\n\t\tif (entryIndex === -1) {\n\t\t\tlogger.warn('Entry not found, nothing removed', { entry, entries: this.getEntries() })\n\t\t\treturn\n\t\t}\n\n\t\tthis._entries.splice(entryIndex, 1)\n\t}\n\n\t/**\n\t * Get the list of registered entries\n\t *\n\t * @param {Folder} context the creation context. Usually the current folder FileInfo\n\t */\n\tpublic getEntries(context?: Folder): Array<Entry> {\n\t\tif (context) {\n\t\t\treturn this._entries\n\t\t\t\t.filter(entry => typeof entry.if === 'function' ? entry.if(context) : true)\n\t\t}\n\t\treturn this._entries\n\t}\n\n\tprivate getEntryIndex(id: string): number {\n\t\treturn this._entries.findIndex(entry => entry.id === id)\n\t}\n\n\tprivate validateEntry(entry: Entry) {\n\t\tif (!entry.id || !entry.displayName || !(entry.iconSvgInline || entry.iconClass)) {\n\t\t\tthrow new Error('Invalid entry')\n\t\t}\n\n\t\tif (typeof entry.id !== 'string'\n\t\t\t|| typeof entry.displayName !== 'string') {\n\t\t\tthrow new Error('Invalid id or displayName property')\n\t\t}\n\n\t\tif ((entry.iconClass && typeof entry.iconClass !== 'string')\n\t\t\t|| (entry.iconSvgInline && typeof entry.iconSvgInline !== 'string')) {\n\t\t\tthrow new Error('Invalid icon provided')\n\t\t}\n\n\t\tif (entry.if !== undefined && typeof entry.if !== 'function') {\n\t\t\tthrow new Error('Invalid if property')\n\t\t}\n\n\t\tif (entry.templateName && typeof entry.templateName !== 'string') {\n\t\t\tthrow new Error('Invalid templateName property')\n\t\t}\n\n\t\tif (entry.handler && typeof entry.handler !== 'function') {\n\t\t\tthrow new Error('Invalid handler property')\n\t\t}\n\n\t\tif (!entry.templateName && !entry.handler) {\n\t\t\tthrow new Error('At least a templateName or a handler must be provided')\n\t\t}\n\n\t\tif (this.getEntryIndex(entry.id) !== -1) {\n\t\t\tthrow new Error('Duplicate entry')\n\t\t}\n\t}\n\n}\n\nexport const getNewFileMenu = function(): NewFileMenu {\n\tif (typeof window._nc_newfilemenu === 'undefined') {\n\t\twindow._nc_newfilemenu = new NewFileMenu()\n\t\tlogger.debug('NewFileMenu initialized')\n\t}\n\treturn window._nc_newfilemenu\n}\n","/**\n * @copyright 2019 Christoph Wurst <christoph@winzerhof-wurst.at>\n *\n * @author Christoph Wurst <christoph@winzerhof-wurst.at>\n * @author John Molakvoæ <skjnldsv@protonmail.com>\n *\n * @license AGPL-3.0-or-later\n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n *\n */\n\nimport { getCanonicalLocale } from '@nextcloud/l10n'\n\nconst humanList = ['B', 'KB', 'MB', 'GB', 'TB', 'PB']\nconst humanListBinary = ['B', 'KiB', 'MiB', 'GiB', 'TiB', 'PiB']\n\n/**\n * Format a file size in a human-like format. e.g. 42GB\n *\n * @param size in bytes\n * @param skipSmallSizes avoid rendering tiny sizes and return '< 1 KB' instead\n * @param binaryPrefixes True if binary prefixes like `KiB` should be used (size base 2)\n */\nexport function formatFileSize(size: number|string, skipSmallSizes = false, binaryPrefixes = false): string {\n\n\tif (typeof size === 'string') {\n\t\tsize = Number(size)\n\t}\n\n\t/*\n\t* @note This block previously used Log base 1024, per IEC 80000-13;\n\t* however, the wrong prefix was used. Now we use decimal calculation\n\t* with base 1000 per the SI. Base 1024 calculation with binary\n\t* prefixes is optional, but has yet to be added to the UI.\n\t*/\n\t// Calculate Log with base 1024 or 1000: size = base ** order\n\tlet order = size > 0 ? Math.floor(Math.log(size) / Math.log(binaryPrefixes ? 1024 : 1000)) : 0\n\t// Stay in range of the byte sizes that are defined\n\torder = Math.min((binaryPrefixes ? humanListBinary.length : humanList.length) - 1, order)\n\tconst readableFormat = binaryPrefixes ? humanListBinary[order] : humanList[order]\n\tlet relativeSize = (size / Math.pow(binaryPrefixes ? 1024 : 1000, order)).toFixed(1)\n\n\tif (skipSmallSizes === true && order === 0) {\n\t\treturn (relativeSize !== '0.0' ? '< 1 ' : '0 ') + (binaryPrefixes ? humanListBinary[1] : humanList[1])\n\t}\n\n\tif (order < 2) {\n\t\trelativeSize = parseFloat(relativeSize).toFixed(0)\n\t} else {\n\t\trelativeSize = parseFloat(relativeSize).toLocaleString(getCanonicalLocale())\n\t}\n\n\treturn relativeSize + ' ' + readableFormat\n}\n","/**\n * @copyright Copyright (c) 2021 John Molakvoæ <skjnldsv@protonmail.com>\n *\n * @author John Molakvoæ <skjnldsv@protonmail.com>\n *\n * @license AGPL-3.0-or-later\n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n *\n */\n\nimport { Node } from './files/node'\nimport logger from './utils/logger'\n\ninterface FileActionData {\n\t/** Unique ID */\n\tid: string\n\t/** Translatable string displayed in the menu */\n\tdisplayName: (files: Node[], view) => string\n\t/** Svg as inline string. <svg><path fill=\"...\" /></svg> */\n\ticonSvgInline: (files: Node[], view) => string\n\t/** Condition wether this action is shown or not */\n\tenabled?: (files: Node[], view) => boolean\n\t/**\n\t * Function executed on single file action\n\t * @return true if the action was executed successfully,\n\t * false otherwise and null if the action is silent/undefined.\n\t * @throws Error if the action failed\n\t */\n\texec: (file: Node, view, dir: string) => Promise<boolean|null>,\n\t/**\n\t * Function executed on multiple files action\n\t * @return true if the action was executed successfully,\n\t * false otherwise and null if the action is silent/undefined.\n\t * @throws Error if the action failed\n\t */\n\texecBatch?: (files: Node[], view, dir: string) => Promise<(boolean|null)[]>\n\t/** This action order in the list */\n\torder?: number,\n\t/** Make this action the default */\n\tdefault?: boolean,\n\t/**\n\t * If true, the renderInline function will be called\n\t */\n\tinline?: (file: Node, view) => boolean,\n\t/**\n\t * If defined, the returned html element will be\n\t * appended before the actions menu.\n\t */\n\trenderInline?: (file: Node, view) => HTMLElement,\n}\n\nexport class FileAction {\n\n\tprivate _action: FileActionData\n\n\tconstructor(action: FileActionData) {\n\t\tthis.validateAction(action)\n\t\tthis._action = action\n\t}\n\n\tget id() {\n\t\treturn this._action.id\n\t}\n\n\tget displayName() {\n\t\treturn this._action.displayName\n\t}\n\n\tget iconSvgInline() {\n\t\treturn this._action.iconSvgInline\n\t}\n\n\tget enabled() {\n\t\treturn this._action.enabled\n\t}\n\n\tget exec() {\n\t\treturn this._action.exec\n\t}\n\n\tget execBatch() {\n\t\treturn this._action.execBatch\n\t}\n\n\tget order() {\n\t\treturn this._action.order\n\t}\n\n\tget default() {\n\t\treturn this._action.default\n\t}\n\n\tget inline() {\n\t\treturn this._action.inline\n\t}\n\n\tget renderInline() {\n\t\treturn this._action.renderInline\n\t}\n\n\tprivate validateAction(action: FileActionData) {\n\t\tif (!action.id || typeof action.id !== 'string') {\n\t\t\tthrow new Error('Invalid id')\n\t\t}\n\n\t\tif (!action.displayName || typeof action.displayName !== 'function') {\n\t\t\tthrow new Error('Invalid displayName function')\n\t\t}\n\n\t\tif (!action.iconSvgInline || typeof action.iconSvgInline !== 'function') {\n\t\t\tthrow new Error('Invalid iconSvgInline function')\n\t\t}\n\n\t\tif (!action.exec || typeof action.exec !== 'function') {\n\t\t\tthrow new Error('Invalid exec function')\n\t\t}\n\n\t\t// Optional properties --------------------------------------------\n\t\tif ('enabled' in action && typeof action.enabled !== 'function') {\n\t\t\tthrow new Error('Invalid enabled function')\n\t\t}\n\n\t\tif ('execBatch' in action && typeof action.execBatch !== 'function') {\n\t\t\tthrow new Error('Invalid execBatch function')\n\t\t}\n\n\t\tif ('order' in action && typeof action.order !== 'number') {\n\t\t\tthrow new Error('Invalid order')\n\t\t}\n\n\t\tif ('default' in action && typeof action.default !== 'boolean') {\n\t\t\tthrow new Error('Invalid default')\n\t\t}\n\n\t\tif ('inline' in action && typeof action.inline !== 'function') {\n\t\t\tthrow new Error('Invalid inline function')\n\t\t}\n\n\t\tif ('renderInline' in action && typeof action.renderInline !== 'function') {\n\t\t\tthrow new Error('Invalid renderInline function')\n\t\t}\n\t}\n\n}\n\nexport const registerFileAction = function(action: FileAction): void {\n\tif (typeof window._nc_fileactions === 'undefined') {\n\t\twindow._nc_fileactions = []\n\t\tlogger.debug('FileActions initialized')\n\t}\n\n\t// Check duplicates\n\tif (window._nc_fileactions.find(search => search.id === action.id)) {\n\t\tlogger.error(`FileAction ${action.id} already registered`, { action })\n\t\treturn\n\t}\n\n\twindow._nc_fileactions.push(action)\n}\n\nexport const getFileActions = function(): FileAction[] {\n\tif (typeof window._nc_fileactions === 'undefined') {\n\t\twindow._nc_fileactions = []\n\t\tlogger.debug('FileActions initialized')\n\t}\n\n\treturn window._nc_fileactions\n}\n","/**\n * @copyright Copyright (c) 2023 John Molakvoæ <skjnldsv@protonmail.com>\n *\n * @author John Molakvoæ <skjnldsv@protonmail.com>\n *\n * @license AGPL-3.0-or-later\n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n *\n */\n\nimport { Folder } from './files/folder'\nimport logger from './utils/logger'\n\nexport interface HeaderData {\n\t/** Unique ID */\n\tid: string\n\t/** Order */\n\torder: number\n\t/** Condition wether this header is shown or not */\n\tenabled?: (folder: Folder, view) => boolean\n\t/** Executed when file list is initialized */\n\trender: (el: HTMLElement, folder: Folder, view) => void\n\t/** Executed when root folder changed */\n\tupdated(folder: Folder, view)\n}\n\nexport class Header {\n\n\tprivate _header: HeaderData\n\n\tconstructor(header: HeaderData) {\n\t\tthis.validateHeader(header)\n\t\tthis._header = header\n\t}\n\n\tget id() {\n\t\treturn this._header.id\n\t}\n\n\tget order() {\n\t\treturn this._header.order\n\t}\n\n\tget enabled() {\n\t\treturn this._header.enabled\n\t}\n\n\tget render() {\n\t\treturn this._header.render\n\t}\n\n\tget updated() {\n\t\treturn this._header.updated\n\t}\n\n\tprivate validateHeader(header: HeaderData) {\n\t\tif (!header.id || !header.render || !header.updated) {\n\t\t\tthrow new Error('Invalid header: id, render and updated are required')\n\t\t}\n\n\t\tif (typeof header.id !== 'string') {\n\t\t\tthrow new Error('Invalid id property')\n\t\t}\n\n\t\tif (header.enabled !== undefined && typeof header.enabled !== 'function') {\n\t\t\tthrow new Error('Invalid enabled property')\n\t\t}\n\n\t\tif (header.render && typeof header.render !== 'function') {\n\t\t\tthrow new Error('Invalid render property')\n\t\t}\n\n\t\tif (header.updated && typeof header.updated !== 'function') {\n\t\t\tthrow new Error('Invalid updated property')\n\t\t}\n\t}\n\n}\n\nexport const registerFileListHeaders = function(header: Header): void {\n\tif (typeof window._nc_filelistheader === 'undefined') {\n\t\twindow._nc_filelistheader = []\n\t\tlogger.debug('FileListHeaders initialized')\n\t}\n\n\t// Check duplicates\n\tif (window._nc_filelistheader.find(search => search.id === header.id)) {\n\t\tlogger.error(`Header ${header.id} already registered`, { header })\n\t\treturn\n\t}\n\n\twindow._nc_filelistheader.push(header)\n}\n\nexport const getFileListHeaders = function(): Header[] {\n\tif (typeof window._nc_filelistheader === 'undefined') {\n\t\twindow._nc_filelistheader = []\n\t\tlogger.debug('FileListHeaders initialized')\n\t}\n\n\treturn window._nc_filelistheader\n}\n","/**\n * @copyright Copyright (c) 2022 John Molakvoæ <skjnldsv@protonmail.com>\n *\n * @author John Molakvoæ <skjnldsv@protonmail.com>\n *\n * @license AGPL-3.0-or-later\n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n *\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 * @copyright Copyright (c) 2023 John Molakvoæ <skjnldsv@protonmail.com>\n *\n * @author John Molakvoæ <skjnldsv@protonmail.com>\n * @author Ferdinand Thiessen <opensource@fthiessen.de>\n *\n * @license AGPL-3.0-or-later\n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n *\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:quota-available-bytes',\n\t'd:resourcetype',\n\t'nc:has-preview',\n\t'nc:is-encrypted',\n\t'nc:mount-type',\n\t'nc:share-attributes',\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:share-types',\n\t'oc:size',\n\t'ocs:share-permissions',\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.error(`${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 davGetDefaultPropfind = 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 davGetFavoritesReport = 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 davGetRecentSearch = 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 * @copyright Copyright (c) 2023 John Molakvoæ <skjnldsv@protonmail.com>\n *\n * @author John Molakvoæ <skjnldsv@protonmail.com>\n * @author Ferdinand Thiessen <opensource@fthiessen.de>\n *\n * @license AGPL-3.0-or-later\n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n *\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 davParsePermissions = 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 * @copyright Copyright (c) 2022 John Molakvoæ <skjnldsv@protonmail.com>\n *\n * @author John Molakvoæ <skjnldsv@protonmail.com>\n *\n * @license AGPL-3.0-or-later\n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n *\n */\nexport enum FileType {\n\tFolder = 'folder',\n\tFile = 'file',\n}\n","/**\n * @copyright Copyright (c) 2022 John Molakvoæ <skjnldsv@protonmail.com>\n *\n * @author John Molakvoæ <skjnldsv@protonmail.com>\n *\n * @license AGPL-3.0-or-later\n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n *\n */\n\nimport { join } from 'path'\nimport { Permission } from '../permissions'\n\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 ressource.\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\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\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 ressource\n */\nexport const isDavRessource = 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.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 && isDavRessource(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","/**\n * @copyright Copyright (c) 2022 John Molakvoæ <skjnldsv@protonmail.com>\n *\n * @author John Molakvoæ <skjnldsv@protonmail.com>\n *\n * @license AGPL-3.0-or-later\n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n *\n */\nimport { basename, extname, dirname } from 'path'\nimport { Permission } from '../permissions'\nimport { FileType } from './fileType'\nimport { Attribute, NodeData, isDavRessource, validateData } from './nodeData'\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\tconstructor(data: NodeData, davService?: RegExp) {\n\t\t// Validate data\n\t\tvalidateData(data, davService || this._knownDavService)\n\n\t\tthis._data = data\n\n\t\tconst handler = {\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\t\t\tset: (target: Attribute, prop: string, value: any): any => {\n\t\t\t\t// Edit modification time\n\t\t\t\tthis.updateMtime()\n\t\t\t\t// Apply original changes\n\t\t\t\treturn Reflect.set(target, prop, value)\n\t\t\t},\n\t\t\tdeleteProperty: (target: Attribute, prop: string) => {\n\t\t\t\t// Edit modification time\n\t\t\t\tthis.updateMtime()\n\t\t\t\t// Apply original changes\n\t\t\t\treturn Reflect.deleteProperty(target, prop)\n\t\t\t},\n\t\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\t\t} as ProxyHandler<any>\n\n\t\t// Proxy the attributes to update the mtime on change\n\t\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\t\tthis._attributes = new Proxy(data.attributes || {} as any, handler)\n\t\tdelete this._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 */\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 this object name\n\t */\n\tget basename(): string {\n\t\treturn basename(this.source)\n\t}\n\n\t/**\n\t * Get this object's extension\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\tget dirname(): string {\n\t\tif (this.root) {\n\t\t\t// Using replace would remove all part matching root\n\t\t\tconst firstMatch = this.source.indexOf(this.root)\n\t\t\treturn dirname(this.source.slice(firstMatch + this.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 */\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 * Get the file creation time\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 * Get the file attribute\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 ressource, we can only read it\n\t\tif (this.owner === null && !this.isDavRessource) {\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 * Get the file owner\n\t */\n\tget owner(): string|null {\n\t\t// Remote ressources have no owner\n\t\tif (!this.isDavRessource) {\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 ressource ?\n\t */\n\tget isDavRessource(): boolean {\n\t\treturn isDavRessource(this.source, this._knownDavService)\n\t}\n\n\t/**\n\t * Get the dav root of this object\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.isDavRessource) {\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\t// Using replace would remove all part matching root\n\t\t\tconst firstMatch = this.source.indexOf(this.root)\n\t\t\treturn this.source.slice(firstMatch + this.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 * Will look for the fileid in attributes if undefined.\n\t */\n\tget fileid(): number|undefined {\n\t\treturn this._data?.id || this.attributes?.fileid\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\tthis._data.source = destination\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\tprivate updateMtime() {\n\t\tif (this._data.mtime) {\n\t\t\tthis._data.mtime = new Date()\n\t\t}\n\t}\n\n}\n","/**\n * @copyright Copyright (c) 2022 John Molakvoæ <skjnldsv@protonmail.com>\n *\n * @author John Molakvoæ <skjnldsv@protonmail.com>\n *\n * @license AGPL-3.0-or-later\n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n *\n */\nimport { FileType } from './fileType'\nimport { Node } from './node'\n\nexport class File extends Node {\n\n\tget type(): FileType {\n\t\treturn FileType.File\n\t}\n\n}\n","/**\n * @copyright Copyright (c) 2022 John Molakvoæ <skjnldsv@protonmail.com>\n *\n * @author John Molakvoæ <skjnldsv@protonmail.com>\n *\n * @license AGPL-3.0-or-later\n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n *\n */\nimport { FileType } from './fileType'\nimport { Node } from './node'\nimport { NodeData } from './nodeData'\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 {\n\t\treturn FileType.Folder\n\t}\n\n\tget extension(): string|null {\n\t\treturn null\n\t}\n\n\tget mime(): string {\n\t\treturn 'httpd/unix-directory'\n\t}\n\n}\n","/**\n * @copyright Copyright (c) 2023 John Molakvoæ <skjnldsv@protonmail.com>\n *\n * @author John Molakvoæ <skjnldsv@protonmail.com>\n * @author Ferdinand Thiessen <opensource@fthiessen.de>\n *\n * @license AGPL-3.0-or-later\n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n *\n */\nimport type { DAVResultResponseProps, FileStat, Response, ResponseDataDetailed, WebDAVClient } from 'webdav'\nimport type { Node } from '../files/node'\n\nimport { File } from '../files/file'\nimport { Folder } from '../files/folder'\nimport { NodeData } from '../files/nodeData'\nimport { davParsePermissions } from './davPermissions'\nimport { davGetDefaultPropfind, davGetFavoritesReport } from './davProperties'\n\nimport { getCurrentUser, getRequestToken } from '@nextcloud/auth'\nimport { generateRemoteUrl } from '@nextcloud/router'\nimport { createClient, getPatcher, RequestOptions } from 'webdav'\nimport { request } from 'webdav/dist/node/request.js'\n\n/**\n * Nextcloud DAV result response\n */\ninterface ResponseProps extends DAVResultResponseProps {\n\tpermissions: string\n\tfileid: number\n\tsize: number\n}\n\nexport const davRootPath = `/files/${getCurrentUser()?.uid}`\nexport const davDefaultRootUrl = generateRemoteUrl('dav' + davRootPath)\n\n/**\n * Get a WebDAV client configured to include the Nextcloud request token\n *\n * @param davURL The DAV root URL\n */\nexport const davGetClient = function(davURL = davDefaultRootUrl) {\n\tconst client = createClient(davURL, {\n\t\theaders: {\n\t\t\trequesttoken: getRequestToken() || '',\n\t\t},\n\t})\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// https://github.com/perry-mitchell/hot-patcher/issues/6\n\t// eslint-disable-next-line @typescript-eslint/ban-ts-comment\n\t// @ts-ignore\n\tpatcher.patch('request', (options: RequestOptions): Promise<Response> => {\n\t\tif (options.headers?.method) {\n\t\t\toptions.method = options.headers.method\n\t\t\tdelete options.headers.method\n\t\t}\n\t\treturn request(options)\n\t})\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 */\nexport const getFavoriteNodes = async (davClient: WebDAVClient, path = '/') => {\n\tconst contentsResponse = await davClient.getDirectoryContents(path, {\n\t\tdetails: true,\n\t\t// Only filter favorites if we're at the root\n\t\tdata: path === '/' ? davGetFavoritesReport() : davGetDefaultPropfind(),\n\t\theaders: {\n\t\t\t// Patched in WebdavClient.ts\n\t\t\tmethod: path === '/' ? 'REPORT' : 'PROPFIND',\n\t\t},\n\t\tincludeSelf: true,\n\t}) as ResponseDataDetailed<FileStat[]>\n\n\treturn contentsResponse.data.filter(node => node.filename !== path).map((result) => davResultToNode(result))\n}\n\n/**\n * Covert DAV result `FileStat` to `Node`\n *\n * @param node The DAV result\n * @param davRoot The DAV root path\n */\nexport const davResultToNode = function(node: FileStat, davRoot = davRootPath): Node {\n\tconst props = node.props as ResponseProps\n\tconst permissions = davParsePermissions(props?.permissions)\n\tconst owner = getCurrentUser()?.uid as string\n\n\tconst nodeData: NodeData = {\n\t\tid: (props?.fileid as number) || 0,\n\t\tsource: generateRemoteUrl(`dav${davRoot}${node.filename}`),\n\t\tmtime: new Date(Date.parse(node.lastmod)),\n\t\tmime: node.mime as string,\n\t\tsize: (props?.size as number) || 0,\n\t\tpermissions,\n\t\towner,\n\t\troot: davRoot,\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","/**\n * @copyright 2019 Christoph Wurst <christoph@winzerhof-wurst.at>\n *\n * @author Christoph Wurst <christoph@winzerhof-wurst.at>\n * @author John Molakvoæ <skjnldsv@protonmail.com>\n *\n * @license AGPL-3.0-or-later\n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n *\n */\n\nimport { type Entry, getNewFileMenu } from './newFileMenu'\nimport { Folder } from './files/folder'\n\nexport { formatFileSize } from './humanfilesize'\nexport { FileAction, getFileActions, registerFileAction } from './fileAction'\nexport { Header, getFileListHeaders, registerFileListHeaders } from './fileListHeaders'\nexport { type Entry } from './newFileMenu'\nexport { Permission } from './permissions'\n\nexport * from './dav/davProperties'\nexport * from './dav/davPermissions'\nexport * from './dav/dav'\n\nexport { FileType } from './files/fileType'\nexport { File } from './files/file'\nexport { Folder } from './files/folder'\nexport { Node } from './files/node'\n\n// TODO: Add FileInfo type!\n\n/**\n * Add a new menu entry to the upload manager menu\n *\n * @param entry The new file menu entry\n */\nexport const addNewFileMenuEntry = function(entry: Entry) {\n\tconst newFileMenu = getNewFileMenu()\n\treturn newFileMenu.registerEntry(entry)\n}\n\n/**\n * Remove a previously registered entry from the upload menu\n *\n * @param entry Entry to remove (or name of entry)\n */\nexport const removeNewFileMenuEntry = function(entry: Entry | string) {\n\tconst newFileMenu = getNewFileMenu()\n\treturn newFileMenu.unregisterEntry(entry)\n}\n\n/**\n * Get the list of registered entries from the upload menu\n *\n * @param {Folder} context the creation context. Usually the current folder FileInfo\n */\nexport const getNewFileMenuEntries = function(context?: Folder) {\n\tconst newFileMenu = getNewFileMenu()\n\treturn newFileMenu.getEntries(context)\n}\n"],"names":["getLogger","user","getLoggerBuilder","logger","getCurrentUser","NewFileMenu","entry","entryIndex","context","id","getNewFileMenu","humanList","humanListBinary","formatFileSize","size","skipSmallSizes","binaryPrefixes","order","readableFormat","relativeSize","getCanonicalLocale","FileAction","action","registerFileAction","search","getFileActions","Header","header","registerFileListHeaders","getFileListHeaders","Permission","defaultDavProperties","defaultDavNamespaces","registerDavProperty","prop","namespace","namespaces","ns","getDavProperties","getDavNameSpaces","davGetDefaultPropfind","davGetFavoritesReport","davGetRecentSearch","lastModified","davParsePermissions","permString","permissions","FileType","isDavRessource","source","davService","validateData","data","service","join","Node","handler","target","value","basename","extname","firstMatch","dirname","url","destination","File","Folder","davRootPath","davDefaultRootUrl","generateRemoteUrl","davGetClient","davURL","client","createClient","getRequestToken","getPatcher","options","request","getFavoriteNodes","davClient","path","node","result","davResultToNode","davRoot","props","owner","nodeData","addNewFileMenuEntry","removeNewFileMenuEntry","getNewFileMenuEntries"],"mappings":"6RAyBMA,EAAoBC,GACrBA,IAAS,KACLC,EAAiB,iBAAA,EACtB,OAAO,OAAO,EACd,MAAM,EAEFA,EAAA,iBAAA,EACL,OAAO,OAAO,EACd,OAAOD,EAAK,GAAG,EACf,QAGHE,EAAeH,EAAUI,kBAAgB,ECWlC,MAAMC,CAAY,CAEhB,SAAyB,CAAA,EAE1B,cAAcC,EAAc,CAClC,KAAK,cAAcA,CAAK,EACnB,KAAA,SAAS,KAAKA,CAAK,CACzB,CAEO,gBAAgBA,EAAuB,CACvC,MAAAC,EAAa,OAAOD,GAAU,SACjC,KAAK,cAAcA,CAAK,EACxB,KAAK,cAAcA,EAAM,EAAE,EAE9B,GAAIC,IAAe,GAAI,CACfJ,EAAA,KAAK,mCAAoC,CAAE,MAAAG,EAAO,QAAS,KAAK,aAAc,EACrF,OAGI,KAAA,SAAS,OAAOC,EAAY,CAAC,CACnC,CAOO,WAAWC,EAAgC,CACjD,OAAIA,EACI,KAAK,SACV,OAAOF,GAAS,OAAOA,EAAM,IAAO,WA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S,IAAMvC,EAAA,EAA0BD,EAAsB,EACrE,QAAS,CAER,OAAQwC,IAAS,IAAM,SAAW,UACnC,EACA,YAAa,EAAA,CACb,GAEuB,KAAK,OAAOC,GAAQA,EAAK,WAAaD,CAAI,EAAE,IAAKE,GAAWC,EAAgBD,CAAM,CAAC,EAS/FC,EAAkB,SAASF,EAAgBG,EAAUjB,EAAmB,CACpF,MAAMkB,EAAQJ,EAAK,MACbnC,EAAcF,EAAoByC,GAAO,WAAW,EACpDC,EAAQlF,iBAAkB,GAAA,IAE1BmF,EAAqB,CAC1B,GAAKF,GAAO,QAAqB,EACjC,OAAQhB,EAAkB,kBAAA,MAAMe,CAAUH,GAAAA,EAAK,QAAU,EAAA,EACzD,MAAO,IAAI,KAAK,KAAK,MAAMA,EAAK,OAAO,CAAC,EACxC,KAAMA,EAAK,KACX,KAAOI,GAAO,MAAmB,EACjC,YAAAvC,EACA,MAAAwC,EACA,KAAMF,EACN,WAAY,CACX,GAAGH,EACH,GAAGI,EACH,WAAYA,IAAQ,aAAa,CAClC,CAAA,EAGD,OAAA,OAAOE,EAAS,YAAY,MAErBN,EAAK,OAAS,OAAS,IAAIhB,EAAKsB,CAAQ,EAAI,IAAIrB,EAAOqB,CAAQ,CACvE,EClFaC,EAAsB,SAASlF,EAAc,CAElD,OADaI,IACD,cAAcJ,CAAK,CACvC,EAOamF,EAAyB,SAASnF,EAAuB,CAE9D,OADaI,IACD,gBAAgBJ,CAAK,CACzC,EAOaoF,EAAwB,SAASlF,EAAkB,CAExD,OADaE,IACD,WAAWF,CAAO,CACtC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -21,8 +21,10 @@
|
|
|
21
21
|
*
|
|
22
22
|
*/
|
|
23
23
|
import { type Entry } from './newFileMenu';
|
|
24
|
+
import { Folder } from './files/folder';
|
|
24
25
|
export { formatFileSize } from './humanfilesize';
|
|
25
|
-
export { FileAction,
|
|
26
|
+
export { FileAction, getFileActions, registerFileAction } from './fileAction';
|
|
27
|
+
export { Header, getFileListHeaders, registerFileListHeaders } from './fileListHeaders';
|
|
26
28
|
export { type Entry } from './newFileMenu';
|
|
27
29
|
export { Permission } from './permissions';
|
|
28
30
|
export * from './dav/davProperties';
|
|
@@ -47,6 +49,6 @@ export declare const removeNewFileMenuEntry: (entry: Entry | string) => void;
|
|
|
47
49
|
/**
|
|
48
50
|
* Get the list of registered entries from the upload menu
|
|
49
51
|
*
|
|
50
|
-
* @param {
|
|
52
|
+
* @param {Folder} context the creation context. Usually the current folder FileInfo
|
|
51
53
|
*/
|
|
52
|
-
export declare const getNewFileMenuEntries: (context?:
|
|
54
|
+
export declare const getNewFileMenuEntries: (context?: Folder) => Entry[];
|
package/dist/index.mjs
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { getCurrentUser as c, getRequestToken as x } from "@nextcloud/auth";
|
|
2
|
-
import { getLoggerBuilder as
|
|
2
|
+
import { getLoggerBuilder as m } from "@nextcloud/logger";
|
|
3
3
|
import { getCanonicalLocale as N } from "@nextcloud/l10n";
|
|
4
|
-
import { join as R, basename as
|
|
4
|
+
import { join as R, basename as F, extname as A, dirname as d } from "path";
|
|
5
5
|
import { generateRemoteUrl as g } from "@nextcloud/router";
|
|
6
|
-
import { createClient as S, getPatcher as
|
|
7
|
-
import { request as
|
|
8
|
-
const
|
|
9
|
-
class
|
|
6
|
+
import { createClient as S, getPatcher as $ } from "webdav";
|
|
7
|
+
import { request as P } from "webdav/dist/node/request.js";
|
|
8
|
+
const L = (e) => e === null ? m().setApp("files").build() : m().setApp("files").setUid(e.uid).build(), s = L(c());
|
|
9
|
+
class B {
|
|
10
10
|
_entries = [];
|
|
11
11
|
registerEntry(t) {
|
|
12
12
|
this.validateEntry(t), this._entries.push(t);
|
|
@@ -14,7 +14,7 @@ class M {
|
|
|
14
14
|
unregisterEntry(t) {
|
|
15
15
|
const r = typeof t == "string" ? this.getEntryIndex(t) : this.getEntryIndex(t.id);
|
|
16
16
|
if (r === -1) {
|
|
17
|
-
|
|
17
|
+
s.warn("Entry not found, nothing removed", { entry: t, entries: this.getEntries() });
|
|
18
18
|
return;
|
|
19
19
|
}
|
|
20
20
|
this._entries.splice(r, 1);
|
|
@@ -45,15 +45,15 @@ class M {
|
|
|
45
45
|
}
|
|
46
46
|
}
|
|
47
47
|
const p = function() {
|
|
48
|
-
return typeof window._nc_newfilemenu > "u" && (window._nc_newfilemenu = new
|
|
48
|
+
return typeof window._nc_newfilemenu > "u" && (window._nc_newfilemenu = new B(), s.debug("NewFileMenu initialized")), window._nc_newfilemenu;
|
|
49
49
|
}, l = ["B", "KB", "MB", "GB", "TB", "PB"], u = ["B", "KiB", "MiB", "GiB", "TiB", "PiB"];
|
|
50
50
|
function J(e, t = !1, r = !1) {
|
|
51
51
|
typeof e == "string" && (e = Number(e));
|
|
52
52
|
let n = e > 0 ? Math.floor(Math.log(e) / Math.log(r ? 1024 : 1e3)) : 0;
|
|
53
53
|
n = Math.min((r ? u.length : l.length) - 1, n);
|
|
54
|
-
const
|
|
54
|
+
const a = r ? u[n] : l[n];
|
|
55
55
|
let i = (e / Math.pow(r ? 1024 : 1e3, n)).toFixed(1);
|
|
56
|
-
return t === !0 && n === 0 ? (i !== "0.0" ? "< 1 " : "0 ") + (r ? u[1] : l[1]) : (n < 2 ? i = parseFloat(i).toFixed(0) : i = parseFloat(i).toLocaleString(N()), i + " " +
|
|
56
|
+
return t === !0 && n === 0 ? (i !== "0.0" ? "< 1 " : "0 ") + (r ? u[1] : l[1]) : (n < 2 ? i = parseFloat(i).toFixed(0) : i = parseFloat(i).toLocaleString(N()), i + " " + a);
|
|
57
57
|
}
|
|
58
58
|
class Q {
|
|
59
59
|
_action;
|
|
@@ -114,36 +114,78 @@ class Q {
|
|
|
114
114
|
}
|
|
115
115
|
}
|
|
116
116
|
const X = function(e) {
|
|
117
|
-
if (typeof window._nc_fileactions > "u" && (window._nc_fileactions = [],
|
|
118
|
-
|
|
117
|
+
if (typeof window._nc_fileactions > "u" && (window._nc_fileactions = [], s.debug("FileActions initialized")), window._nc_fileactions.find((t) => t.id === e.id)) {
|
|
118
|
+
s.error(`FileAction ${e.id} already registered`, { action: e });
|
|
119
119
|
return;
|
|
120
120
|
}
|
|
121
121
|
window._nc_fileactions.push(e);
|
|
122
122
|
}, Y = function() {
|
|
123
|
-
return window._nc_fileactions
|
|
123
|
+
return typeof window._nc_fileactions > "u" && (window._nc_fileactions = [], s.debug("FileActions initialized")), window._nc_fileactions;
|
|
124
|
+
};
|
|
125
|
+
class Z {
|
|
126
|
+
_header;
|
|
127
|
+
constructor(t) {
|
|
128
|
+
this.validateHeader(t), this._header = t;
|
|
129
|
+
}
|
|
130
|
+
get id() {
|
|
131
|
+
return this._header.id;
|
|
132
|
+
}
|
|
133
|
+
get order() {
|
|
134
|
+
return this._header.order;
|
|
135
|
+
}
|
|
136
|
+
get enabled() {
|
|
137
|
+
return this._header.enabled;
|
|
138
|
+
}
|
|
139
|
+
get render() {
|
|
140
|
+
return this._header.render;
|
|
141
|
+
}
|
|
142
|
+
get updated() {
|
|
143
|
+
return this._header.updated;
|
|
144
|
+
}
|
|
145
|
+
validateHeader(t) {
|
|
146
|
+
if (!t.id || !t.render || !t.updated)
|
|
147
|
+
throw new Error("Invalid header: id, render and updated are required");
|
|
148
|
+
if (typeof t.id != "string")
|
|
149
|
+
throw new Error("Invalid id property");
|
|
150
|
+
if (t.enabled !== void 0 && typeof t.enabled != "function")
|
|
151
|
+
throw new Error("Invalid enabled property");
|
|
152
|
+
if (t.render && typeof t.render != "function")
|
|
153
|
+
throw new Error("Invalid render property");
|
|
154
|
+
if (t.updated && typeof t.updated != "function")
|
|
155
|
+
throw new Error("Invalid updated property");
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
const ee = function(e) {
|
|
159
|
+
if (typeof window._nc_filelistheader > "u" && (window._nc_filelistheader = [], s.debug("FileListHeaders initialized")), window._nc_filelistheader.find((t) => t.id === e.id)) {
|
|
160
|
+
s.error(`Header ${e.id} already registered`, { header: e });
|
|
161
|
+
return;
|
|
162
|
+
}
|
|
163
|
+
window._nc_filelistheader.push(e);
|
|
164
|
+
}, te = function() {
|
|
165
|
+
return typeof window._nc_filelistheader > "u" && (window._nc_filelistheader = [], s.debug("FileListHeaders initialized")), window._nc_filelistheader;
|
|
124
166
|
};
|
|
125
167
|
var o = ((e) => (e[e.NONE = 0] = "NONE", e[e.CREATE = 4] = "CREATE", e[e.READ = 1] = "READ", e[e.UPDATE = 2] = "UPDATE", e[e.DELETE = 8] = "DELETE", e[e.SHARE = 16] = "SHARE", e[e.ALL = 31] = "ALL", e))(o || {});
|
|
126
|
-
const
|
|
127
|
-
typeof window._nc_dav_properties > "u" && (window._nc_dav_properties = [...
|
|
168
|
+
const v = ["d:getcontentlength", "d:getcontenttype", "d:getetag", "d:getlastmodified", "d:quota-available-bytes", "d:resourcetype", "nc:has-preview", "nc:is-encrypted", "nc:mount-type", "nc:share-attributes", "oc:comments-unread", "oc:favorite", "oc:fileid", "oc:owner-display-name", "oc:owner-id", "oc:permissions", "oc:share-types", "oc:size", "ocs:share-permissions"], y = { d: "DAV:", nc: "http://nextcloud.org/ns", oc: "http://owncloud.org/ns", ocs: "http://open-collaboration-services.org/ns" }, re = function(e, t = { nc: "http://nextcloud.org/ns" }) {
|
|
169
|
+
typeof window._nc_dav_properties > "u" && (window._nc_dav_properties = [...v], window._nc_dav_namespaces = { ...y });
|
|
128
170
|
const r = { ...window._nc_dav_namespaces, ...t };
|
|
129
|
-
if (window._nc_dav_properties.find((
|
|
130
|
-
return
|
|
171
|
+
if (window._nc_dav_properties.find((a) => a === e))
|
|
172
|
+
return s.error(`${e} already registered`, { prop: e }), !1;
|
|
131
173
|
if (e.startsWith("<") || e.split(":").length !== 2)
|
|
132
|
-
return
|
|
174
|
+
return s.error(`${e} is not valid. See example: 'oc:fileid'`, { prop: e }), !1;
|
|
133
175
|
const n = e.split(":")[0];
|
|
134
|
-
return r[n] ? (window._nc_dav_properties.push(e), window._nc_dav_namespaces = r, !0) : (
|
|
176
|
+
return r[n] ? (window._nc_dav_properties.push(e), window._nc_dav_namespaces = r, !0) : (s.error(`${e} namespace unknown`, { prop: e, namespaces: r }), !1);
|
|
135
177
|
}, f = function() {
|
|
136
|
-
return typeof window._nc_dav_properties > "u" && (window._nc_dav_properties = [...
|
|
178
|
+
return typeof window._nc_dav_properties > "u" && (window._nc_dav_properties = [...v]), window._nc_dav_properties.map((e) => `<${e} />`).join(" ");
|
|
137
179
|
}, h = function() {
|
|
138
180
|
return typeof window._nc_dav_namespaces > "u" && (window._nc_dav_namespaces = { ...y }), Object.keys(window._nc_dav_namespaces).map((e) => `xmlns:${e}="${window._nc_dav_namespaces?.[e]}"`).join(" ");
|
|
139
|
-
},
|
|
181
|
+
}, M = function() {
|
|
140
182
|
return `<?xml version="1.0"?>
|
|
141
183
|
<d:propfind ${h()}>
|
|
142
184
|
<d:prop>
|
|
143
185
|
${f()}
|
|
144
186
|
</d:prop>
|
|
145
187
|
</d:propfind>`;
|
|
146
|
-
},
|
|
188
|
+
}, T = function() {
|
|
147
189
|
return `<?xml version="1.0"?>
|
|
148
190
|
<oc:filter-files ${h()}>
|
|
149
191
|
<d:prop>
|
|
@@ -153,7 +195,7 @@ const _ = ["d:getcontentlength", "d:getcontenttype", "d:getetag", "d:getlastmodi
|
|
|
153
195
|
<oc:favorite>1</oc:favorite>
|
|
154
196
|
</oc:filter-rules>
|
|
155
197
|
</oc:filter-files>`;
|
|
156
|
-
},
|
|
198
|
+
}, ie = function(e) {
|
|
157
199
|
return `<?xml version="1.0" encoding="UTF-8"?>
|
|
158
200
|
<d:searchrequest ${h()}
|
|
159
201
|
xmlns:ns="https://github.com/icewind1991/SearchDAV/ns">
|
|
@@ -213,10 +255,10 @@ const _ = ["d:getcontentlength", "d:getcontenttype", "d:getetag", "d:getlastmodi
|
|
|
213
255
|
let t = o.NONE;
|
|
214
256
|
return e && ((e.includes("C") || e.includes("K")) && (t |= o.CREATE), e.includes("G") && (t |= o.READ), (e.includes("W") || e.includes("N") || e.includes("V")) && (t |= o.UPDATE), e.includes("D") && (t |= o.DELETE), e.includes("R") && (t |= o.SHARE)), t;
|
|
215
257
|
};
|
|
216
|
-
var
|
|
258
|
+
var w = ((e) => (e.Folder = "folder", e.File = "file", e))(w || {});
|
|
217
259
|
const E = function(e, t) {
|
|
218
260
|
return e.match(t) !== null;
|
|
219
|
-
},
|
|
261
|
+
}, _ = (e, t) => {
|
|
220
262
|
if (e.id && typeof e.id != "number")
|
|
221
263
|
throw new Error("Invalid id type of value");
|
|
222
264
|
if (!e.source)
|
|
@@ -259,18 +301,18 @@ class b {
|
|
|
259
301
|
_attributes;
|
|
260
302
|
_knownDavService = /(remote|public)\.php\/(web)?dav/i;
|
|
261
303
|
constructor(t, r) {
|
|
262
|
-
|
|
263
|
-
const n = { set: (
|
|
304
|
+
_(t, r || this._knownDavService), this._data = t;
|
|
305
|
+
const n = { set: (a, i, D) => (this.updateMtime(), Reflect.set(a, i, D)), deleteProperty: (a, i) => (this.updateMtime(), Reflect.deleteProperty(a, i)) };
|
|
264
306
|
this._attributes = new Proxy(t.attributes || {}, n), delete this._data.attributes, r && (this._knownDavService = r);
|
|
265
307
|
}
|
|
266
308
|
get source() {
|
|
267
309
|
return this._data.source.replace(/\/$/i, "");
|
|
268
310
|
}
|
|
269
311
|
get basename() {
|
|
270
|
-
return
|
|
312
|
+
return F(this.source);
|
|
271
313
|
}
|
|
272
314
|
get extension() {
|
|
273
|
-
return
|
|
315
|
+
return A(this.source);
|
|
274
316
|
}
|
|
275
317
|
get dirname() {
|
|
276
318
|
if (this.root) {
|
|
@@ -318,7 +360,7 @@ class b {
|
|
|
318
360
|
return this._data?.id || this.attributes?.fileid;
|
|
319
361
|
}
|
|
320
362
|
move(t) {
|
|
321
|
-
|
|
363
|
+
_({ ...this._data, source: t }, this._knownDavService), this._data.source = t, this.updateMtime();
|
|
322
364
|
}
|
|
323
365
|
rename(t) {
|
|
324
366
|
if (t.includes("/"))
|
|
@@ -329,17 +371,17 @@ class b {
|
|
|
329
371
|
this._data.mtime && (this._data.mtime = /* @__PURE__ */ new Date());
|
|
330
372
|
}
|
|
331
373
|
}
|
|
332
|
-
class
|
|
374
|
+
class q extends b {
|
|
333
375
|
get type() {
|
|
334
|
-
return
|
|
376
|
+
return w.File;
|
|
335
377
|
}
|
|
336
378
|
}
|
|
337
|
-
class
|
|
379
|
+
class C extends b {
|
|
338
380
|
constructor(t) {
|
|
339
381
|
super({ ...t, mime: "httpd/unix-directory" });
|
|
340
382
|
}
|
|
341
383
|
get type() {
|
|
342
|
-
return
|
|
384
|
+
return w.Folder;
|
|
343
385
|
}
|
|
344
386
|
get extension() {
|
|
345
387
|
return null;
|
|
@@ -348,44 +390,47 @@ class q extends b {
|
|
|
348
390
|
return "httpd/unix-directory";
|
|
349
391
|
}
|
|
350
392
|
}
|
|
351
|
-
const I = `/files/${c()?.uid}`,
|
|
393
|
+
const I = `/files/${c()?.uid}`, H = g("dav" + I), ne = function(e = H) {
|
|
352
394
|
const t = S(e, { headers: { requesttoken: x() || "" } });
|
|
353
|
-
return
|
|
354
|
-
},
|
|
355
|
-
const r = e.props, n = z(r?.permissions),
|
|
356
|
-
return delete i.attributes?.props, e.type === "file" ? new
|
|
357
|
-
},
|
|
395
|
+
return $().patch("request", (r) => (r.headers?.method && (r.method = r.headers.method, delete r.headers.method), P(r))), t;
|
|
396
|
+
}, oe = async (e, t = "/") => (await e.getDirectoryContents(t, { details: !0, data: t === "/" ? T() : M(), headers: { method: t === "/" ? "REPORT" : "PROPFIND" }, includeSelf: !0 })).data.filter((r) => r.filename !== t).map((r) => U(r)), U = function(e, t = I) {
|
|
397
|
+
const r = e.props, n = z(r?.permissions), a = c()?.uid, i = { id: r?.fileid || 0, source: g(`dav${t}${e.filename}`), mtime: new Date(Date.parse(e.lastmod)), mime: e.mime, size: r?.size || 0, permissions: n, owner: a, root: t, attributes: { ...e, ...r, hasPreview: r?.["has-preview"] } };
|
|
398
|
+
return delete i.attributes?.props, e.type === "file" ? new q(i) : new C(i);
|
|
399
|
+
}, se = function(e) {
|
|
358
400
|
return p().registerEntry(e);
|
|
359
|
-
},
|
|
401
|
+
}, ae = function(e) {
|
|
360
402
|
return p().unregisterEntry(e);
|
|
361
|
-
},
|
|
403
|
+
}, de = function(e) {
|
|
362
404
|
return p().getEntries(e);
|
|
363
405
|
};
|
|
364
406
|
export {
|
|
365
|
-
|
|
407
|
+
q as File,
|
|
366
408
|
Q as FileAction,
|
|
367
|
-
|
|
368
|
-
|
|
409
|
+
w as FileType,
|
|
410
|
+
C as Folder,
|
|
411
|
+
Z as Header,
|
|
369
412
|
b as Node,
|
|
370
413
|
o as Permission,
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
414
|
+
se as addNewFileMenuEntry,
|
|
415
|
+
H as davDefaultRootUrl,
|
|
416
|
+
ne as davGetClient,
|
|
417
|
+
M as davGetDefaultPropfind,
|
|
418
|
+
T as davGetFavoritesReport,
|
|
419
|
+
ie as davGetRecentSearch,
|
|
377
420
|
z as davParsePermissions,
|
|
378
|
-
|
|
421
|
+
U as davResultToNode,
|
|
379
422
|
I as davRootPath,
|
|
380
423
|
y as defaultDavNamespaces,
|
|
381
|
-
|
|
424
|
+
v as defaultDavProperties,
|
|
382
425
|
J as formatFileSize,
|
|
383
426
|
h as getDavNameSpaces,
|
|
384
427
|
f as getDavProperties,
|
|
385
|
-
|
|
428
|
+
oe as getFavoriteNodes,
|
|
386
429
|
Y as getFileActions,
|
|
387
|
-
|
|
388
|
-
|
|
430
|
+
te as getFileListHeaders,
|
|
431
|
+
de as getNewFileMenuEntries,
|
|
432
|
+
re as registerDavProperty,
|
|
389
433
|
X as registerFileAction,
|
|
390
|
-
|
|
434
|
+
ee as registerFileListHeaders,
|
|
435
|
+
ae as removeNewFileMenuEntry
|
|
391
436
|
};
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sources":["../lib/utils/logger.ts","../lib/newFileMenu.ts","../lib/humanfilesize.ts","../lib/fileAction.ts","../lib/permissions.ts","../lib/dav/davProperties.ts","../lib/dav/davPermissions.ts","../lib/files/fileType.ts","../lib/files/nodeData.ts","../lib/files/node.ts","../lib/files/file.ts","../lib/files/folder.ts","../lib/dav/dav.ts","../lib/index.ts"],"sourcesContent":["/**\n * @copyright 2019 Christoph Wurst <christoph@winzerhof-wurst.at>\n *\n * @author Christoph Wurst <christoph@winzerhof-wurst.at>\n *\n * @license AGPL-3.0-or-later\n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n *\n */\n\nimport { getCurrentUser } from '@nextcloud/auth'\nimport { getLoggerBuilder } from '@nextcloud/logger'\n\nconst getLogger = user => {\n\tif (user === null) {\n\t\treturn getLoggerBuilder()\n\t\t\t.setApp('files')\n\t\t\t.build()\n\t}\n\treturn getLoggerBuilder()\n\t\t.setApp('files')\n\t\t.setUid(user.uid)\n\t\t.build()\n}\n\nexport default getLogger(getCurrentUser())\n","/**\n * @copyright Copyright (c) 2021 John Molakvoæ <skjnldsv@protonmail.com>\n *\n * @author John Molakvoæ <skjnldsv@protonmail.com>\n *\n * @license AGPL-3.0-or-later\n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n *\n */\n\nimport logger from './utils/logger'\n\nexport interface Entry {\n\t/** Unique ID */\n\tid: string\n\t/** Translatable string displayed in the menu */\n\tdisplayName: string\n\t// Default new file name\n\ttemplateName?: string\n\t// Condition wether this entry is shown or not\n\tif?: (context: object) => boolean\n\t/**\n\t * Either iconSvgInline or iconClass must be defined\n\t * Svg as inline string. <svg><path fill=\"...\" /></svg>\n\t */\n\ticonSvgInline?: string\n\t/** Existing icon css class */\n\ticonClass?: string\n\t/** Function to be run after creation */\n\thandler?: () => void\n}\n\nexport class NewFileMenu {\n\n\tprivate _entries: Array<Entry> = []\n\n\tpublic registerEntry(entry: Entry) {\n\t\tthis.validateEntry(entry)\n\t\tthis._entries.push(entry)\n\t}\n\n\tpublic unregisterEntry(entry: Entry | string) {\n\t\tconst entryIndex = typeof entry === 'string'\n\t\t\t? this.getEntryIndex(entry)\n\t\t\t: this.getEntryIndex(entry.id)\n\n\t\tif (entryIndex === -1) {\n\t\t\tlogger.warn('Entry not found, nothing removed', { entry, entries: this.getEntries() })\n\t\t\treturn\n\t\t}\n\n\t\tthis._entries.splice(entryIndex, 1)\n\t}\n\n\t/**\n\t * Get the list of registered entries\n\t *\n\t * @param {FileInfo} context the creation context. Usually the current folder FileInfo\n\t */\n\tpublic getEntries(context?: object): Array<Entry> {\n\t\tif (context) {\n\t\t\treturn this._entries\n\t\t\t\t.filter(entry => typeof entry.if === 'function' ? entry.if(context) : true)\n\t\t}\n\t\treturn this._entries\n\t}\n\n\tprivate getEntryIndex(id: string): number {\n\t\treturn this._entries.findIndex(entry => entry.id === id)\n\t}\n\n\tprivate validateEntry(entry: Entry) {\n\t\tif (!entry.id || !entry.displayName || !(entry.iconSvgInline || entry.iconClass)) {\n\t\t\tthrow new Error('Invalid entry')\n\t\t}\n\n\t\tif (typeof entry.id !== 'string'\n\t\t\t|| typeof entry.displayName !== 'string') {\n\t\t\tthrow new Error('Invalid id or displayName property')\n\t\t}\n\n\t\tif ((entry.iconClass && typeof entry.iconClass !== 'string')\n\t\t\t|| (entry.iconSvgInline && typeof entry.iconSvgInline !== 'string')) {\n\t\t\tthrow new Error('Invalid icon provided')\n\t\t}\n\n\t\tif (entry.if !== undefined && typeof entry.if !== 'function') {\n\t\t\tthrow new Error('Invalid if property')\n\t\t}\n\n\t\tif (entry.templateName && typeof entry.templateName !== 'string') {\n\t\t\tthrow new Error('Invalid templateName property')\n\t\t}\n\n\t\tif (entry.handler && typeof entry.handler !== 'function') {\n\t\t\tthrow new Error('Invalid handler property')\n\t\t}\n\n\t\tif (!entry.templateName && !entry.handler) {\n\t\t\tthrow new Error('At least a templateName or a handler must be provided')\n\t\t}\n\n\t\tif (this.getEntryIndex(entry.id) !== -1) {\n\t\t\tthrow new Error('Duplicate entry')\n\t\t}\n\t}\n\n}\n\nexport const getNewFileMenu = function(): NewFileMenu {\n\tif (typeof window._nc_newfilemenu === 'undefined') {\n\t\twindow._nc_newfilemenu = new NewFileMenu()\n\t\tlogger.debug('NewFileMenu initialized')\n\t}\n\treturn window._nc_newfilemenu\n}\n","/**\n * @copyright 2019 Christoph Wurst <christoph@winzerhof-wurst.at>\n *\n * @author Christoph Wurst <christoph@winzerhof-wurst.at>\n * @author John Molakvoæ <skjnldsv@protonmail.com>\n *\n * @license AGPL-3.0-or-later\n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n *\n */\n\nimport { getCanonicalLocale } from '@nextcloud/l10n'\n\nconst humanList = ['B', 'KB', 'MB', 'GB', 'TB', 'PB']\nconst humanListBinary = ['B', 'KiB', 'MiB', 'GiB', 'TiB', 'PiB']\n\n/**\n * Format a file size in a human-like format. e.g. 42GB\n *\n * @param size in bytes\n * @param skipSmallSizes avoid rendering tiny sizes and return '< 1 KB' instead\n * @param binaryPrefixes True if binary prefixes like `KiB` should be used (size base 2)\n */\nexport function formatFileSize(size: number|string, skipSmallSizes = false, binaryPrefixes = false): string {\n\n\tif (typeof size === 'string') {\n\t\tsize = Number(size)\n\t}\n\n\t/*\n\t* @note This block previously used Log base 1024, per IEC 80000-13;\n\t* however, the wrong prefix was used. Now we use decimal calculation\n\t* with base 1000 per the SI. Base 1024 calculation with binary\n\t* prefixes is optional, but has yet to be added to the UI.\n\t*/\n\t// Calculate Log with base 1024 or 1000: size = base ** order\n\tlet order = size > 0 ? Math.floor(Math.log(size) / Math.log(binaryPrefixes ? 1024 : 1000)) : 0\n\t// Stay in range of the byte sizes that are defined\n\torder = Math.min((binaryPrefixes ? humanListBinary.length : humanList.length) - 1, order)\n\tconst readableFormat = binaryPrefixes ? humanListBinary[order] : humanList[order]\n\tlet relativeSize = (size / Math.pow(binaryPrefixes ? 1024 : 1000, order)).toFixed(1)\n\n\tif (skipSmallSizes === true && order === 0) {\n\t\treturn (relativeSize !== '0.0' ? '< 1 ' : '0 ') + (binaryPrefixes ? humanListBinary[1] : humanList[1])\n\t}\n\n\tif (order < 2) {\n\t\trelativeSize = parseFloat(relativeSize).toFixed(0)\n\t} else {\n\t\trelativeSize = parseFloat(relativeSize).toLocaleString(getCanonicalLocale())\n\t}\n\n\treturn relativeSize + ' ' + readableFormat\n}\n","/**\n * @copyright Copyright (c) 2021 John Molakvoæ <skjnldsv@protonmail.com>\n *\n * @author John Molakvoæ <skjnldsv@protonmail.com>\n *\n * @license AGPL-3.0-or-later\n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n *\n */\n\nimport { Node } from './files/node'\nimport logger from './utils/logger'\n\ninterface FileActionData {\n\t/** Unique ID */\n\tid: string\n\t/** Translatable string displayed in the menu */\n\tdisplayName: (files: Node[], view) => string\n\t/** Svg as inline string. <svg><path fill=\"...\" /></svg> */\n\ticonSvgInline: (files: Node[], view) => string\n\t/** Condition wether this action is shown or not */\n\tenabled?: (files: Node[], view) => boolean\n\t/**\n\t * Function executed on single file action\n\t * @return true if the action was executed successfully,\n\t * false otherwise and null if the action is silent/undefined.\n\t * @throws Error if the action failed\n\t */\n\texec: (file: Node, view, dir: string) => Promise<boolean|null>,\n\t/**\n\t * Function executed on multiple files action\n\t * @return true if the action was executed successfully,\n\t * false otherwise and null if the action is silent/undefined.\n\t * @throws Error if the action failed\n\t */\n\texecBatch?: (files: Node[], view, dir: string) => Promise<(boolean|null)[]>\n\t/** This action order in the list */\n\torder?: number,\n\t/** Make this action the default */\n\tdefault?: boolean,\n\t/**\n\t * If true, the renderInline function will be called\n\t */\n\tinline?: (file: Node, view) => boolean,\n\t/**\n\t * If defined, the returned html element will be\n\t * appended before the actions menu.\n\t */\n\trenderInline?: (file: Node, view) => HTMLElement,\n}\n\nexport class FileAction {\n\n\tprivate _action: FileActionData\n\n\tconstructor(action: FileActionData) {\n\t\tthis.validateAction(action)\n\t\tthis._action = action\n\t}\n\n\tget id() {\n\t\treturn this._action.id\n\t}\n\n\tget displayName() {\n\t\treturn this._action.displayName\n\t}\n\n\tget iconSvgInline() {\n\t\treturn this._action.iconSvgInline\n\t}\n\n\tget enabled() {\n\t\treturn this._action.enabled\n\t}\n\n\tget exec() {\n\t\treturn this._action.exec\n\t}\n\n\tget execBatch() {\n\t\treturn this._action.execBatch\n\t}\n\n\tget order() {\n\t\treturn this._action.order\n\t}\n\n\tget default() {\n\t\treturn this._action.default\n\t}\n\n\tget inline() {\n\t\treturn this._action.inline\n\t}\n\n\tget renderInline() {\n\t\treturn this._action.renderInline\n\t}\n\n\tprivate validateAction(action: FileActionData) {\n\t\tif (!action.id || typeof action.id !== 'string') {\n\t\t\tthrow new Error('Invalid id')\n\t\t}\n\n\t\tif (!action.displayName || typeof action.displayName !== 'function') {\n\t\t\tthrow new Error('Invalid displayName function')\n\t\t}\n\n\t\tif (!action.iconSvgInline || typeof action.iconSvgInline !== 'function') {\n\t\t\tthrow new Error('Invalid iconSvgInline function')\n\t\t}\n\n\t\tif (!action.exec || typeof action.exec !== 'function') {\n\t\t\tthrow new Error('Invalid exec function')\n\t\t}\n\n\t\t// Optional properties --------------------------------------------\n\t\tif ('enabled' in action && typeof action.enabled !== 'function') {\n\t\t\tthrow new Error('Invalid enabled function')\n\t\t}\n\n\t\tif ('execBatch' in action && typeof action.execBatch !== 'function') {\n\t\t\tthrow new Error('Invalid execBatch function')\n\t\t}\n\n\t\tif ('order' in action && typeof action.order !== 'number') {\n\t\t\tthrow new Error('Invalid order')\n\t\t}\n\n\t\tif ('default' in action && typeof action.default !== 'boolean') {\n\t\t\tthrow new Error('Invalid default')\n\t\t}\n\n\t\tif ('inline' in action && typeof action.inline !== 'function') {\n\t\t\tthrow new Error('Invalid inline function')\n\t\t}\n\n\t\tif ('renderInline' in action && typeof action.renderInline !== 'function') {\n\t\t\tthrow new Error('Invalid renderInline function')\n\t\t}\n\t}\n\n}\n\nexport const registerFileAction = function(action: FileAction): void {\n\tif (typeof window._nc_fileactions === 'undefined') {\n\t\twindow._nc_fileactions = []\n\t\tlogger.debug('FileActions initialized')\n\t}\n\n\t// Check duplicates\n\tif (window._nc_fileactions.find(search => search.id === action.id)) {\n\t\tlogger.error(`FileAction ${action.id} already registered`, { action })\n\t\treturn\n\t}\n\n\twindow._nc_fileactions.push(action)\n}\n\nexport const getFileActions = function(): FileAction[] {\n\treturn window._nc_fileactions || []\n}\n","/**\n * @copyright Copyright (c) 2022 John Molakvoæ <skjnldsv@protonmail.com>\n *\n * @author John Molakvoæ <skjnldsv@protonmail.com>\n *\n * @license AGPL-3.0-or-later\n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n *\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 * @copyright Copyright (c) 2023 John Molakvoæ <skjnldsv@protonmail.com>\n *\n * @author John Molakvoæ <skjnldsv@protonmail.com>\n * @author Ferdinand Thiessen <opensource@fthiessen.de>\n *\n * @license AGPL-3.0-or-later\n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n *\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:quota-available-bytes',\n\t'd:resourcetype',\n\t'nc:has-preview',\n\t'nc:is-encrypted',\n\t'nc:mount-type',\n\t'nc:share-attributes',\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:share-types',\n\t'oc:size',\n\t'ocs:share-permissions',\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.error(`${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 davGetDefaultPropfind = 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 davGetFavoritesReport = 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 davGetRecentSearch = 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 * @copyright Copyright (c) 2023 John Molakvoæ <skjnldsv@protonmail.com>\n *\n * @author John Molakvoæ <skjnldsv@protonmail.com>\n * @author Ferdinand Thiessen <opensource@fthiessen.de>\n *\n * @license AGPL-3.0-or-later\n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n *\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 davParsePermissions = 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 * @copyright Copyright (c) 2022 John Molakvoæ <skjnldsv@protonmail.com>\n *\n * @author John Molakvoæ <skjnldsv@protonmail.com>\n *\n * @license AGPL-3.0-or-later\n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n *\n */\nexport enum FileType {\n\tFolder = 'folder',\n\tFile = 'file',\n}\n","/**\n * @copyright Copyright (c) 2022 John Molakvoæ <skjnldsv@protonmail.com>\n *\n * @author John Molakvoæ <skjnldsv@protonmail.com>\n *\n * @license AGPL-3.0-or-later\n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n *\n */\n\nimport { join } from 'path'\nimport { Permission } from '../permissions'\n\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 ressource.\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\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\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 ressource\n */\nexport const isDavRessource = 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.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 && isDavRessource(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","/**\n * @copyright Copyright (c) 2022 John Molakvoæ <skjnldsv@protonmail.com>\n *\n * @author John Molakvoæ <skjnldsv@protonmail.com>\n *\n * @license AGPL-3.0-or-later\n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n *\n */\nimport { basename, extname, dirname } from 'path'\nimport { Permission } from '../permissions'\nimport { FileType } from './fileType'\nimport { Attribute, NodeData, isDavRessource, validateData } from './nodeData'\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\tconstructor(data: NodeData, davService?: RegExp) {\n\t\t// Validate data\n\t\tvalidateData(data, davService || this._knownDavService)\n\n\t\tthis._data = data\n\n\t\tconst handler = {\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\t\t\tset: (target: Attribute, prop: string, value: any): any => {\n\t\t\t\t// Edit modification time\n\t\t\t\tthis.updateMtime()\n\t\t\t\t// Apply original changes\n\t\t\t\treturn Reflect.set(target, prop, value)\n\t\t\t},\n\t\t\tdeleteProperty: (target: Attribute, prop: string) => {\n\t\t\t\t// Edit modification time\n\t\t\t\tthis.updateMtime()\n\t\t\t\t// Apply original changes\n\t\t\t\treturn Reflect.deleteProperty(target, prop)\n\t\t\t},\n\t\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\t\t} as ProxyHandler<any>\n\n\t\t// Proxy the attributes to update the mtime on change\n\t\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\t\tthis._attributes = new Proxy(data.attributes || {} as any, handler)\n\t\tdelete this._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 */\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 this object name\n\t */\n\tget basename(): string {\n\t\treturn basename(this.source)\n\t}\n\n\t/**\n\t * Get this object's extension\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\tget dirname(): string {\n\t\tif (this.root) {\n\t\t\t// Using replace would remove all part matching root\n\t\t\tconst firstMatch = this.source.indexOf(this.root)\n\t\t\treturn dirname(this.source.slice(firstMatch + this.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 */\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 * Get the file creation time\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 * Get the file attribute\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 ressource, we can only read it\n\t\tif (this.owner === null && !this.isDavRessource) {\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 * Get the file owner\n\t */\n\tget owner(): string|null {\n\t\t// Remote ressources have no owner\n\t\tif (!this.isDavRessource) {\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 ressource ?\n\t */\n\tget isDavRessource(): boolean {\n\t\treturn isDavRessource(this.source, this._knownDavService)\n\t}\n\n\t/**\n\t * Get the dav root of this object\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.isDavRessource) {\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\t// Using replace would remove all part matching root\n\t\t\tconst firstMatch = this.source.indexOf(this.root)\n\t\t\treturn this.source.slice(firstMatch + this.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 * Will look for the fileid in attributes if undefined.\n\t */\n\tget fileid(): number|undefined {\n\t\treturn this._data?.id || this.attributes?.fileid\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\tthis._data.source = destination\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\tprivate updateMtime() {\n\t\tif (this._data.mtime) {\n\t\t\tthis._data.mtime = new Date()\n\t\t}\n\t}\n\n}\n","/**\n * @copyright Copyright (c) 2022 John Molakvoæ <skjnldsv@protonmail.com>\n *\n * @author John Molakvoæ <skjnldsv@protonmail.com>\n *\n * @license AGPL-3.0-or-later\n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n *\n */\nimport { FileType } from './fileType'\nimport { Node } from './node'\n\nexport class File extends Node {\n\n\tget type(): FileType {\n\t\treturn FileType.File\n\t}\n\n}\n","/**\n * @copyright Copyright (c) 2022 John Molakvoæ <skjnldsv@protonmail.com>\n *\n * @author John Molakvoæ <skjnldsv@protonmail.com>\n *\n * @license AGPL-3.0-or-later\n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n *\n */\nimport { FileType } from './fileType'\nimport { Node } from './node'\nimport { NodeData } from './nodeData'\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 {\n\t\treturn FileType.Folder\n\t}\n\n\tget extension(): string|null {\n\t\treturn null\n\t}\n\n\tget mime(): string {\n\t\treturn 'httpd/unix-directory'\n\t}\n\n}\n","/**\n * @copyright Copyright (c) 2023 John Molakvoæ <skjnldsv@protonmail.com>\n *\n * @author John Molakvoæ <skjnldsv@protonmail.com>\n * @author Ferdinand Thiessen <opensource@fthiessen.de>\n *\n * @license AGPL-3.0-or-later\n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n *\n */\nimport type { DAVResultResponseProps, FileStat, Response, ResponseDataDetailed, WebDAVClient } from 'webdav'\nimport type { Node } from '../files/node'\n\nimport { File } from '../files/file'\nimport { Folder } from '../files/folder'\nimport { NodeData } from '../files/nodeData'\nimport { davParsePermissions } from './davPermissions'\nimport { davGetDefaultPropfind, davGetFavoritesReport } from './davProperties'\n\nimport { getCurrentUser, getRequestToken } from '@nextcloud/auth'\nimport { generateRemoteUrl } from '@nextcloud/router'\nimport { createClient, getPatcher, RequestOptions } from 'webdav'\nimport { request } from 'webdav/dist/node/request.js'\n\n/**\n * Nextcloud DAV result response\n */\ninterface ResponseProps extends DAVResultResponseProps {\n\tpermissions: string\n\tfileid: number\n\tsize: number\n}\n\nexport const davRootPath = `/files/${getCurrentUser()?.uid}`\nexport const davDefaultRootUrl = generateRemoteUrl('dav' + davRootPath)\n\n/**\n * Get a WebDAV client configured to include the Nextcloud request token\n *\n * @param davURL The DAV root URL\n */\nexport const davGetClient = function(davURL = davDefaultRootUrl) {\n\tconst client = createClient(davURL, {\n\t\theaders: {\n\t\t\trequesttoken: getRequestToken() || '',\n\t\t},\n\t})\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// https://github.com/perry-mitchell/hot-patcher/issues/6\n\t// eslint-disable-next-line @typescript-eslint/ban-ts-comment\n\t// @ts-ignore\n\tpatcher.patch('request', (options: RequestOptions): Promise<Response> => {\n\t\tif (options.headers?.method) {\n\t\t\toptions.method = options.headers.method\n\t\t\tdelete options.headers.method\n\t\t}\n\t\treturn request(options)\n\t})\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 */\nexport const getFavoriteNodes = async (davClient: WebDAVClient, path = '/') => {\n\tconst contentsResponse = await davClient.getDirectoryContents(path, {\n\t\tdetails: true,\n\t\t// Only filter favorites if we're at the root\n\t\tdata: path === '/' ? davGetFavoritesReport() : davGetDefaultPropfind(),\n\t\theaders: {\n\t\t\t// Patched in WebdavClient.ts\n\t\t\tmethod: path === '/' ? 'REPORT' : 'PROPFIND',\n\t\t},\n\t\tincludeSelf: true,\n\t}) as ResponseDataDetailed<FileStat[]>\n\n\treturn contentsResponse.data.filter(node => node.filename !== path).map((result) => davResultToNode(result))\n}\n\n/**\n * Covert DAV result `FileStat` to `Node`\n *\n * @param node The DAV result\n * @param davRoot The DAV root path\n */\nexport const davResultToNode = function(node: FileStat, davRoot = davRootPath): Node {\n\tconst props = node.props as ResponseProps\n\tconst permissions = davParsePermissions(props?.permissions)\n\tconst owner = getCurrentUser()?.uid as string\n\n\tconst nodeData: NodeData = {\n\t\tid: (props?.fileid as number) || 0,\n\t\tsource: generateRemoteUrl(`dav${davRoot}${node.filename}`),\n\t\tmtime: new Date(Date.parse(node.lastmod)),\n\t\tmime: node.mime as string,\n\t\tsize: (props?.size as number) || 0,\n\t\tpermissions,\n\t\towner,\n\t\troot: davRoot,\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","/**\n * @copyright 2019 Christoph Wurst <christoph@winzerhof-wurst.at>\n *\n * @author Christoph Wurst <christoph@winzerhof-wurst.at>\n * @author John Molakvoæ <skjnldsv@protonmail.com>\n *\n * @license AGPL-3.0-or-later\n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n *\n */\n\nimport { type Entry, getNewFileMenu } from './newFileMenu'\n\nexport { formatFileSize } from './humanfilesize'\nexport { FileAction, registerFileAction, getFileActions } from './fileAction'\nexport { type Entry } from './newFileMenu'\nexport { Permission } from './permissions'\n\nexport * from './dav/davProperties'\nexport * from './dav/davPermissions'\nexport * from './dav/dav'\n\nexport { FileType } from './files/fileType'\nexport { File } from './files/file'\nexport { Folder } from './files/folder'\nexport { Node } from './files/node'\n\n// TODO: Add FileInfo type!\n\n/**\n * Add a new menu entry to the upload manager menu\n *\n * @param entry The new file menu entry\n */\nexport const addNewFileMenuEntry = function(entry: Entry) {\n\tconst newFileMenu = getNewFileMenu()\n\treturn newFileMenu.registerEntry(entry)\n}\n\n/**\n * Remove a previously registered entry from the upload menu\n *\n * @param entry Entry to remove (or name of entry)\n */\nexport const removeNewFileMenuEntry = function(entry: Entry | string) {\n\tconst newFileMenu = getNewFileMenu()\n\treturn newFileMenu.unregisterEntry(entry)\n}\n\n/**\n * Get the list of registered entries from the upload menu\n *\n * @param {FileInfo} context the creation context. Usually the current folder FileInfo\n */\nexport const getNewFileMenuEntries = function(context?: object) {\n\tconst newFileMenu = getNewFileMenu()\n\treturn newFileMenu.getEntries(context)\n}\n"],"names":["getLogger","user","getLoggerBuilder","logger","getCurrentUser","NewFileMenu","entry","entryIndex","context","id","getNewFileMenu","humanList","humanListBinary","formatFileSize","size","skipSmallSizes","binaryPrefixes","order","readableFormat","relativeSize","getCanonicalLocale","FileAction","action","registerFileAction","search","getFileActions","Permission","defaultDavProperties","defaultDavNamespaces","registerDavProperty","prop","namespace","namespaces","ns","getDavProperties","getDavNameSpaces","davGetDefaultPropfind","davGetFavoritesReport","davGetRecentSearch","lastModified","davParsePermissions","permString","permissions","FileType","isDavRessource","source","davService","validateData","data","service","join","Node","handler","target","value","basename","extname","firstMatch","dirname","url","destination","File","Folder","davRootPath","davDefaultRootUrl","generateRemoteUrl","davGetClient","davURL","client","createClient","getRequestToken","getPatcher","options","request","getFavoriteNodes","davClient","path","node","result","davResultToNode","davRoot","props","owner","nodeData","addNewFileMenuEntry","removeNewFileMenuEntry","getNewFileMenuEntries"],"mappings":";;;;;;;AAyBA,MAAMA,IAAoBC,OACrBA,MAAS,OACLC,EAAiB,EACtB,OAAO,OAAO,EACd,MAAM,IAEFA,EAAA,EACL,OAAO,OAAO,EACd,OAAOD,EAAK,GAAG,EACf,SAGHE,IAAeH,EAAUI,GAAgB;ACOlC,MAAMC,EAAY;AAAA,EAEhB,WAAyB,CAAA;AAAA,EAE1B,cAAcC,GAAc;AAClC,SAAK,cAAcA,CAAK,GACnB,KAAA,SAAS,KAAKA,CAAK;AAAA,EACzB;AAAA,EAEO,gBAAgBA,GAAuB;AACvC,UAAAC,IAAa,OAAOD,KAAU,WACjC,KAAK,cAAcA,CAAK,IACxB,KAAK,cAAcA,EAAM,EAAE;AAE9B,QAAIC,MAAe,IAAI;AACfJ,MAAAA,EAAA,KAAK,oCAAoC,EAAE,OAAAG,GAAO,SAAS,KAAK,cAAc;AACrF;AAAA;AAGI,SAAA,SAAS,OAAO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,aAAa,EAClC,EAAA;AAGD,SAAA,OAAOE,EAAS,YAAY,OAErBN,EAAK,SAAS,SAAS,IAAIhB,EAAKsB,CAAQ,IAAI,IAAIrB,EAAOqB,CAAQ;AACvE,GCpFaC,KAAsB,SAAS9E,GAAc;AAElD,SADaI,IACD,cAAcJ,CAAK;AACvC,GAOa+E,KAAyB,SAAS/E,GAAuB;AAE9D,SADaI,IACD,gBAAgBJ,CAAK;AACzC,GAOagF,KAAwB,SAAS9E,GAAkB;AAExD,SADaE,IACD,WAAWF,CAAO;AACtC;"}
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":["../lib/utils/logger.ts","../lib/newFileMenu.ts","../lib/humanfilesize.ts","../lib/fileAction.ts","../lib/fileListHeaders.ts","../lib/permissions.ts","../lib/dav/davProperties.ts","../lib/dav/davPermissions.ts","../lib/files/fileType.ts","../lib/files/nodeData.ts","../lib/files/node.ts","../lib/files/file.ts","../lib/files/folder.ts","../lib/dav/dav.ts","../lib/index.ts"],"sourcesContent":["/**\n * @copyright 2019 Christoph Wurst <christoph@winzerhof-wurst.at>\n *\n * @author Christoph Wurst <christoph@winzerhof-wurst.at>\n *\n * @license AGPL-3.0-or-later\n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n *\n */\n\nimport { getCurrentUser } from '@nextcloud/auth'\nimport { getLoggerBuilder } from '@nextcloud/logger'\n\nconst getLogger = user => {\n\tif (user === null) {\n\t\treturn getLoggerBuilder()\n\t\t\t.setApp('files')\n\t\t\t.build()\n\t}\n\treturn getLoggerBuilder()\n\t\t.setApp('files')\n\t\t.setUid(user.uid)\n\t\t.build()\n}\n\nexport default getLogger(getCurrentUser())\n","/**\n * @copyright Copyright (c) 2021 John Molakvoæ <skjnldsv@protonmail.com>\n *\n * @author John Molakvoæ <skjnldsv@protonmail.com>\n *\n * @license AGPL-3.0-or-later\n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n *\n */\n\nimport { Folder } from '.'\nimport logger from './utils/logger'\n\nexport interface Entry {\n\t/** Unique ID */\n\tid: string\n\t/** Translatable string displayed in the menu */\n\tdisplayName: string\n\t/** Default new file name */\n\ttemplateName?: string\n\t/**\n\t * Condition wether this entry is shown or not\n\t * @param {Folder} context the creation context. Usually the current folder\n\t */\n\tif?: (context: Folder) => boolean\n\t/**\n\t * Either iconSvgInline or iconClass must be defined\n\t * Svg as inline string. <svg><path fill=\"...\" /></svg>\n\t */\n\ticonSvgInline?: string\n\t/** Existing icon css class */\n\ticonClass?: string\n\t/** Function to be run after creation */\n\thandler?: () => void\n}\n\nexport class NewFileMenu {\n\n\tprivate _entries: Array<Entry> = []\n\n\tpublic registerEntry(entry: Entry) {\n\t\tthis.validateEntry(entry)\n\t\tthis._entries.push(entry)\n\t}\n\n\tpublic unregisterEntry(entry: Entry | string) {\n\t\tconst entryIndex = typeof entry === 'string'\n\t\t\t? this.getEntryIndex(entry)\n\t\t\t: this.getEntryIndex(entry.id)\n\n\t\tif (entryIndex === -1) {\n\t\t\tlogger.warn('Entry not found, nothing removed', { entry, entries: this.getEntries() })\n\t\t\treturn\n\t\t}\n\n\t\tthis._entries.splice(entryIndex, 1)\n\t}\n\n\t/**\n\t * Get the list of registered entries\n\t *\n\t * @param {Folder} context the creation context. Usually the current folder FileInfo\n\t */\n\tpublic getEntries(context?: Folder): Array<Entry> {\n\t\tif (context) {\n\t\t\treturn this._entries\n\t\t\t\t.filter(entry => typeof entry.if === 'function' ? entry.if(context) : true)\n\t\t}\n\t\treturn this._entries\n\t}\n\n\tprivate getEntryIndex(id: string): number {\n\t\treturn this._entries.findIndex(entry => entry.id === id)\n\t}\n\n\tprivate validateEntry(entry: Entry) {\n\t\tif (!entry.id || !entry.displayName || !(entry.iconSvgInline || entry.iconClass)) {\n\t\t\tthrow new Error('Invalid entry')\n\t\t}\n\n\t\tif (typeof entry.id !== 'string'\n\t\t\t|| typeof entry.displayName !== 'string') {\n\t\t\tthrow new Error('Invalid id or displayName property')\n\t\t}\n\n\t\tif ((entry.iconClass && typeof entry.iconClass !== 'string')\n\t\t\t|| (entry.iconSvgInline && typeof entry.iconSvgInline !== 'string')) {\n\t\t\tthrow new Error('Invalid icon provided')\n\t\t}\n\n\t\tif (entry.if !== undefined && typeof entry.if !== 'function') {\n\t\t\tthrow new Error('Invalid if property')\n\t\t}\n\n\t\tif (entry.templateName && typeof entry.templateName !== 'string') {\n\t\t\tthrow new Error('Invalid templateName property')\n\t\t}\n\n\t\tif (entry.handler && typeof entry.handler !== 'function') {\n\t\t\tthrow new Error('Invalid handler property')\n\t\t}\n\n\t\tif (!entry.templateName && !entry.handler) {\n\t\t\tthrow new Error('At least a templateName or a handler must be provided')\n\t\t}\n\n\t\tif (this.getEntryIndex(entry.id) !== -1) {\n\t\t\tthrow new Error('Duplicate entry')\n\t\t}\n\t}\n\n}\n\nexport const getNewFileMenu = function(): NewFileMenu {\n\tif (typeof window._nc_newfilemenu === 'undefined') {\n\t\twindow._nc_newfilemenu = new NewFileMenu()\n\t\tlogger.debug('NewFileMenu initialized')\n\t}\n\treturn window._nc_newfilemenu\n}\n","/**\n * @copyright 2019 Christoph Wurst <christoph@winzerhof-wurst.at>\n *\n * @author Christoph Wurst <christoph@winzerhof-wurst.at>\n * @author John Molakvoæ <skjnldsv@protonmail.com>\n *\n * @license AGPL-3.0-or-later\n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n *\n */\n\nimport { getCanonicalLocale } from '@nextcloud/l10n'\n\nconst humanList = ['B', 'KB', 'MB', 'GB', 'TB', 'PB']\nconst humanListBinary = ['B', 'KiB', 'MiB', 'GiB', 'TiB', 'PiB']\n\n/**\n * Format a file size in a human-like format. e.g. 42GB\n *\n * @param size in bytes\n * @param skipSmallSizes avoid rendering tiny sizes and return '< 1 KB' instead\n * @param binaryPrefixes True if binary prefixes like `KiB` should be used (size base 2)\n */\nexport function formatFileSize(size: number|string, skipSmallSizes = false, binaryPrefixes = false): string {\n\n\tif (typeof size === 'string') {\n\t\tsize = Number(size)\n\t}\n\n\t/*\n\t* @note This block previously used Log base 1024, per IEC 80000-13;\n\t* however, the wrong prefix was used. Now we use decimal calculation\n\t* with base 1000 per the SI. Base 1024 calculation with binary\n\t* prefixes is optional, but has yet to be added to the UI.\n\t*/\n\t// Calculate Log with base 1024 or 1000: size = base ** order\n\tlet order = size > 0 ? Math.floor(Math.log(size) / Math.log(binaryPrefixes ? 1024 : 1000)) : 0\n\t// Stay in range of the byte sizes that are defined\n\torder = Math.min((binaryPrefixes ? humanListBinary.length : humanList.length) - 1, order)\n\tconst readableFormat = binaryPrefixes ? humanListBinary[order] : humanList[order]\n\tlet relativeSize = (size / Math.pow(binaryPrefixes ? 1024 : 1000, order)).toFixed(1)\n\n\tif (skipSmallSizes === true && order === 0) {\n\t\treturn (relativeSize !== '0.0' ? '< 1 ' : '0 ') + (binaryPrefixes ? humanListBinary[1] : humanList[1])\n\t}\n\n\tif (order < 2) {\n\t\trelativeSize = parseFloat(relativeSize).toFixed(0)\n\t} else {\n\t\trelativeSize = parseFloat(relativeSize).toLocaleString(getCanonicalLocale())\n\t}\n\n\treturn relativeSize + ' ' + readableFormat\n}\n","/**\n * @copyright Copyright (c) 2021 John Molakvoæ <skjnldsv@protonmail.com>\n *\n * @author John Molakvoæ <skjnldsv@protonmail.com>\n *\n * @license AGPL-3.0-or-later\n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n *\n */\n\nimport { Node } from './files/node'\nimport logger from './utils/logger'\n\ninterface FileActionData {\n\t/** Unique ID */\n\tid: string\n\t/** Translatable string displayed in the menu */\n\tdisplayName: (files: Node[], view) => string\n\t/** Svg as inline string. <svg><path fill=\"...\" /></svg> */\n\ticonSvgInline: (files: Node[], view) => string\n\t/** Condition wether this action is shown or not */\n\tenabled?: (files: Node[], view) => boolean\n\t/**\n\t * Function executed on single file action\n\t * @return true if the action was executed successfully,\n\t * false otherwise and null if the action is silent/undefined.\n\t * @throws Error if the action failed\n\t */\n\texec: (file: Node, view, dir: string) => Promise<boolean|null>,\n\t/**\n\t * Function executed on multiple files action\n\t * @return true if the action was executed successfully,\n\t * false otherwise and null if the action is silent/undefined.\n\t * @throws Error if the action failed\n\t */\n\texecBatch?: (files: Node[], view, dir: string) => Promise<(boolean|null)[]>\n\t/** This action order in the list */\n\torder?: number,\n\t/** Make this action the default */\n\tdefault?: boolean,\n\t/**\n\t * If true, the renderInline function will be called\n\t */\n\tinline?: (file: Node, view) => boolean,\n\t/**\n\t * If defined, the returned html element will be\n\t * appended before the actions menu.\n\t */\n\trenderInline?: (file: Node, view) => HTMLElement,\n}\n\nexport class FileAction {\n\n\tprivate _action: FileActionData\n\n\tconstructor(action: FileActionData) {\n\t\tthis.validateAction(action)\n\t\tthis._action = action\n\t}\n\n\tget id() {\n\t\treturn this._action.id\n\t}\n\n\tget displayName() {\n\t\treturn this._action.displayName\n\t}\n\n\tget iconSvgInline() {\n\t\treturn this._action.iconSvgInline\n\t}\n\n\tget enabled() {\n\t\treturn this._action.enabled\n\t}\n\n\tget exec() {\n\t\treturn this._action.exec\n\t}\n\n\tget execBatch() {\n\t\treturn this._action.execBatch\n\t}\n\n\tget order() {\n\t\treturn this._action.order\n\t}\n\n\tget default() {\n\t\treturn this._action.default\n\t}\n\n\tget inline() {\n\t\treturn this._action.inline\n\t}\n\n\tget renderInline() {\n\t\treturn this._action.renderInline\n\t}\n\n\tprivate validateAction(action: FileActionData) {\n\t\tif (!action.id || typeof action.id !== 'string') {\n\t\t\tthrow new Error('Invalid id')\n\t\t}\n\n\t\tif (!action.displayName || typeof action.displayName !== 'function') {\n\t\t\tthrow new Error('Invalid displayName function')\n\t\t}\n\n\t\tif (!action.iconSvgInline || typeof action.iconSvgInline !== 'function') {\n\t\t\tthrow new Error('Invalid iconSvgInline function')\n\t\t}\n\n\t\tif (!action.exec || typeof action.exec !== 'function') {\n\t\t\tthrow new Error('Invalid exec function')\n\t\t}\n\n\t\t// Optional properties --------------------------------------------\n\t\tif ('enabled' in action && typeof action.enabled !== 'function') {\n\t\t\tthrow new Error('Invalid enabled function')\n\t\t}\n\n\t\tif ('execBatch' in action && typeof action.execBatch !== 'function') {\n\t\t\tthrow new Error('Invalid execBatch function')\n\t\t}\n\n\t\tif ('order' in action && typeof action.order !== 'number') {\n\t\t\tthrow new Error('Invalid order')\n\t\t}\n\n\t\tif ('default' in action && typeof action.default !== 'boolean') {\n\t\t\tthrow new Error('Invalid default')\n\t\t}\n\n\t\tif ('inline' in action && typeof action.inline !== 'function') {\n\t\t\tthrow new Error('Invalid inline function')\n\t\t}\n\n\t\tif ('renderInline' in action && typeof action.renderInline !== 'function') {\n\t\t\tthrow new Error('Invalid renderInline function')\n\t\t}\n\t}\n\n}\n\nexport const registerFileAction = function(action: FileAction): void {\n\tif (typeof window._nc_fileactions === 'undefined') {\n\t\twindow._nc_fileactions = []\n\t\tlogger.debug('FileActions initialized')\n\t}\n\n\t// Check duplicates\n\tif (window._nc_fileactions.find(search => search.id === action.id)) {\n\t\tlogger.error(`FileAction ${action.id} already registered`, { action })\n\t\treturn\n\t}\n\n\twindow._nc_fileactions.push(action)\n}\n\nexport const getFileActions = function(): FileAction[] {\n\tif (typeof window._nc_fileactions === 'undefined') {\n\t\twindow._nc_fileactions = []\n\t\tlogger.debug('FileActions initialized')\n\t}\n\n\treturn window._nc_fileactions\n}\n","/**\n * @copyright Copyright (c) 2023 John Molakvoæ <skjnldsv@protonmail.com>\n *\n * @author John Molakvoæ <skjnldsv@protonmail.com>\n *\n * @license AGPL-3.0-or-later\n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n *\n */\n\nimport { Folder } from './files/folder'\nimport logger from './utils/logger'\n\nexport interface HeaderData {\n\t/** Unique ID */\n\tid: string\n\t/** Order */\n\torder: number\n\t/** Condition wether this header is shown or not */\n\tenabled?: (folder: Folder, view) => boolean\n\t/** Executed when file list is initialized */\n\trender: (el: HTMLElement, folder: Folder, view) => void\n\t/** Executed when root folder changed */\n\tupdated(folder: Folder, view)\n}\n\nexport class Header {\n\n\tprivate _header: HeaderData\n\n\tconstructor(header: HeaderData) {\n\t\tthis.validateHeader(header)\n\t\tthis._header = header\n\t}\n\n\tget id() {\n\t\treturn this._header.id\n\t}\n\n\tget order() {\n\t\treturn this._header.order\n\t}\n\n\tget enabled() {\n\t\treturn this._header.enabled\n\t}\n\n\tget render() {\n\t\treturn this._header.render\n\t}\n\n\tget updated() {\n\t\treturn this._header.updated\n\t}\n\n\tprivate validateHeader(header: HeaderData) {\n\t\tif (!header.id || !header.render || !header.updated) {\n\t\t\tthrow new Error('Invalid header: id, render and updated are required')\n\t\t}\n\n\t\tif (typeof header.id !== 'string') {\n\t\t\tthrow new Error('Invalid id property')\n\t\t}\n\n\t\tif (header.enabled !== undefined && typeof header.enabled !== 'function') {\n\t\t\tthrow new Error('Invalid enabled property')\n\t\t}\n\n\t\tif (header.render && typeof header.render !== 'function') {\n\t\t\tthrow new Error('Invalid render property')\n\t\t}\n\n\t\tif (header.updated && typeof header.updated !== 'function') {\n\t\t\tthrow new Error('Invalid updated property')\n\t\t}\n\t}\n\n}\n\nexport const registerFileListHeaders = function(header: Header): void {\n\tif (typeof window._nc_filelistheader === 'undefined') {\n\t\twindow._nc_filelistheader = []\n\t\tlogger.debug('FileListHeaders initialized')\n\t}\n\n\t// Check duplicates\n\tif (window._nc_filelistheader.find(search => search.id === header.id)) {\n\t\tlogger.error(`Header ${header.id} already registered`, { header })\n\t\treturn\n\t}\n\n\twindow._nc_filelistheader.push(header)\n}\n\nexport const getFileListHeaders = function(): Header[] {\n\tif (typeof window._nc_filelistheader === 'undefined') {\n\t\twindow._nc_filelistheader = []\n\t\tlogger.debug('FileListHeaders initialized')\n\t}\n\n\treturn window._nc_filelistheader\n}\n","/**\n * @copyright Copyright (c) 2022 John Molakvoæ <skjnldsv@protonmail.com>\n *\n * @author John Molakvoæ <skjnldsv@protonmail.com>\n *\n * @license AGPL-3.0-or-later\n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n *\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 * @copyright Copyright (c) 2023 John Molakvoæ <skjnldsv@protonmail.com>\n *\n * @author John Molakvoæ <skjnldsv@protonmail.com>\n * @author Ferdinand Thiessen <opensource@fthiessen.de>\n *\n * @license AGPL-3.0-or-later\n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n *\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:quota-available-bytes',\n\t'd:resourcetype',\n\t'nc:has-preview',\n\t'nc:is-encrypted',\n\t'nc:mount-type',\n\t'nc:share-attributes',\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:share-types',\n\t'oc:size',\n\t'ocs:share-permissions',\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.error(`${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 davGetDefaultPropfind = 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 davGetFavoritesReport = 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 davGetRecentSearch = 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 * @copyright Copyright (c) 2023 John Molakvoæ <skjnldsv@protonmail.com>\n *\n * @author John Molakvoæ <skjnldsv@protonmail.com>\n * @author Ferdinand Thiessen <opensource@fthiessen.de>\n *\n * @license AGPL-3.0-or-later\n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n *\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 davParsePermissions = 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 * @copyright Copyright (c) 2022 John Molakvoæ <skjnldsv@protonmail.com>\n *\n * @author John Molakvoæ <skjnldsv@protonmail.com>\n *\n * @license AGPL-3.0-or-later\n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n *\n */\nexport enum FileType {\n\tFolder = 'folder',\n\tFile = 'file',\n}\n","/**\n * @copyright Copyright (c) 2022 John Molakvoæ <skjnldsv@protonmail.com>\n *\n * @author John Molakvoæ <skjnldsv@protonmail.com>\n *\n * @license AGPL-3.0-or-later\n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n *\n */\n\nimport { join } from 'path'\nimport { Permission } from '../permissions'\n\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 ressource.\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\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\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 ressource\n */\nexport const isDavRessource = 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.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 && isDavRessource(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","/**\n * @copyright Copyright (c) 2022 John Molakvoæ <skjnldsv@protonmail.com>\n *\n * @author John Molakvoæ <skjnldsv@protonmail.com>\n *\n * @license AGPL-3.0-or-later\n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n *\n */\nimport { basename, extname, dirname } from 'path'\nimport { Permission } from '../permissions'\nimport { FileType } from './fileType'\nimport { Attribute, NodeData, isDavRessource, validateData } from './nodeData'\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\tconstructor(data: NodeData, davService?: RegExp) {\n\t\t// Validate data\n\t\tvalidateData(data, davService || this._knownDavService)\n\n\t\tthis._data = data\n\n\t\tconst handler = {\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\t\t\tset: (target: Attribute, prop: string, value: any): any => {\n\t\t\t\t// Edit modification time\n\t\t\t\tthis.updateMtime()\n\t\t\t\t// Apply original changes\n\t\t\t\treturn Reflect.set(target, prop, value)\n\t\t\t},\n\t\t\tdeleteProperty: (target: Attribute, prop: string) => {\n\t\t\t\t// Edit modification time\n\t\t\t\tthis.updateMtime()\n\t\t\t\t// Apply original changes\n\t\t\t\treturn Reflect.deleteProperty(target, prop)\n\t\t\t},\n\t\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\t\t} as ProxyHandler<any>\n\n\t\t// Proxy the attributes to update the mtime on change\n\t\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\t\tthis._attributes = new Proxy(data.attributes || {} as any, handler)\n\t\tdelete this._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 */\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 this object name\n\t */\n\tget basename(): string {\n\t\treturn basename(this.source)\n\t}\n\n\t/**\n\t * Get this object's extension\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\tget dirname(): string {\n\t\tif (this.root) {\n\t\t\t// Using replace would remove all part matching root\n\t\t\tconst firstMatch = this.source.indexOf(this.root)\n\t\t\treturn dirname(this.source.slice(firstMatch + this.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 */\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 * Get the file creation time\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 * Get the file attribute\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 ressource, we can only read it\n\t\tif (this.owner === null && !this.isDavRessource) {\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 * Get the file owner\n\t */\n\tget owner(): string|null {\n\t\t// Remote ressources have no owner\n\t\tif (!this.isDavRessource) {\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 ressource ?\n\t */\n\tget isDavRessource(): boolean {\n\t\treturn isDavRessource(this.source, this._knownDavService)\n\t}\n\n\t/**\n\t * Get the dav root of this object\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.isDavRessource) {\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\t// Using replace would remove all part matching root\n\t\t\tconst firstMatch = this.source.indexOf(this.root)\n\t\t\treturn this.source.slice(firstMatch + this.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 * Will look for the fileid in attributes if undefined.\n\t */\n\tget fileid(): number|undefined {\n\t\treturn this._data?.id || this.attributes?.fileid\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\tthis._data.source = destination\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\tprivate updateMtime() {\n\t\tif (this._data.mtime) {\n\t\t\tthis._data.mtime = new Date()\n\t\t}\n\t}\n\n}\n","/**\n * @copyright Copyright (c) 2022 John Molakvoæ <skjnldsv@protonmail.com>\n *\n * @author John Molakvoæ <skjnldsv@protonmail.com>\n *\n * @license AGPL-3.0-or-later\n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n *\n */\nimport { FileType } from './fileType'\nimport { Node } from './node'\n\nexport class File extends Node {\n\n\tget type(): FileType {\n\t\treturn FileType.File\n\t}\n\n}\n","/**\n * @copyright Copyright (c) 2022 John Molakvoæ <skjnldsv@protonmail.com>\n *\n * @author John Molakvoæ <skjnldsv@protonmail.com>\n *\n * @license AGPL-3.0-or-later\n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n *\n */\nimport { FileType } from './fileType'\nimport { Node } from './node'\nimport { NodeData } from './nodeData'\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 {\n\t\treturn FileType.Folder\n\t}\n\n\tget extension(): string|null {\n\t\treturn null\n\t}\n\n\tget mime(): string {\n\t\treturn 'httpd/unix-directory'\n\t}\n\n}\n","/**\n * @copyright Copyright (c) 2023 John Molakvoæ <skjnldsv@protonmail.com>\n *\n * @author John Molakvoæ <skjnldsv@protonmail.com>\n * @author Ferdinand Thiessen <opensource@fthiessen.de>\n *\n * @license AGPL-3.0-or-later\n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n *\n */\nimport type { DAVResultResponseProps, FileStat, Response, ResponseDataDetailed, WebDAVClient } from 'webdav'\nimport type { Node } from '../files/node'\n\nimport { File } from '../files/file'\nimport { Folder } from '../files/folder'\nimport { NodeData } from '../files/nodeData'\nimport { davParsePermissions } from './davPermissions'\nimport { davGetDefaultPropfind, davGetFavoritesReport } from './davProperties'\n\nimport { getCurrentUser, getRequestToken } from '@nextcloud/auth'\nimport { generateRemoteUrl } from '@nextcloud/router'\nimport { createClient, getPatcher, RequestOptions } from 'webdav'\nimport { request } from 'webdav/dist/node/request.js'\n\n/**\n * Nextcloud DAV result response\n */\ninterface ResponseProps extends DAVResultResponseProps {\n\tpermissions: string\n\tfileid: number\n\tsize: number\n}\n\nexport const davRootPath = `/files/${getCurrentUser()?.uid}`\nexport const davDefaultRootUrl = generateRemoteUrl('dav' + davRootPath)\n\n/**\n * Get a WebDAV client configured to include the Nextcloud request token\n *\n * @param davURL The DAV root URL\n */\nexport const davGetClient = function(davURL = davDefaultRootUrl) {\n\tconst client = createClient(davURL, {\n\t\theaders: {\n\t\t\trequesttoken: getRequestToken() || '',\n\t\t},\n\t})\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// https://github.com/perry-mitchell/hot-patcher/issues/6\n\t// eslint-disable-next-line @typescript-eslint/ban-ts-comment\n\t// @ts-ignore\n\tpatcher.patch('request', (options: RequestOptions): Promise<Response> => {\n\t\tif (options.headers?.method) {\n\t\t\toptions.method = options.headers.method\n\t\t\tdelete options.headers.method\n\t\t}\n\t\treturn request(options)\n\t})\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 */\nexport const getFavoriteNodes = async (davClient: WebDAVClient, path = '/') => {\n\tconst contentsResponse = await davClient.getDirectoryContents(path, {\n\t\tdetails: true,\n\t\t// Only filter favorites if we're at the root\n\t\tdata: path === '/' ? davGetFavoritesReport() : davGetDefaultPropfind(),\n\t\theaders: {\n\t\t\t// Patched in WebdavClient.ts\n\t\t\tmethod: path === '/' ? 'REPORT' : 'PROPFIND',\n\t\t},\n\t\tincludeSelf: true,\n\t}) as ResponseDataDetailed<FileStat[]>\n\n\treturn contentsResponse.data.filter(node => node.filename !== path).map((result) => davResultToNode(result))\n}\n\n/**\n * Covert DAV result `FileStat` to `Node`\n *\n * @param node The DAV result\n * @param davRoot The DAV root path\n */\nexport const davResultToNode = function(node: FileStat, davRoot = davRootPath): Node {\n\tconst props = node.props as ResponseProps\n\tconst permissions = davParsePermissions(props?.permissions)\n\tconst owner = getCurrentUser()?.uid as string\n\n\tconst nodeData: NodeData = {\n\t\tid: (props?.fileid as number) || 0,\n\t\tsource: generateRemoteUrl(`dav${davRoot}${node.filename}`),\n\t\tmtime: new Date(Date.parse(node.lastmod)),\n\t\tmime: node.mime as string,\n\t\tsize: (props?.size as number) || 0,\n\t\tpermissions,\n\t\towner,\n\t\troot: davRoot,\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","/**\n * @copyright 2019 Christoph Wurst <christoph@winzerhof-wurst.at>\n *\n * @author Christoph Wurst <christoph@winzerhof-wurst.at>\n * @author John Molakvoæ <skjnldsv@protonmail.com>\n *\n * @license AGPL-3.0-or-later\n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n *\n */\n\nimport { type Entry, getNewFileMenu } from './newFileMenu'\nimport { Folder } from './files/folder'\n\nexport { formatFileSize } from './humanfilesize'\nexport { FileAction, getFileActions, registerFileAction } from './fileAction'\nexport { Header, getFileListHeaders, registerFileListHeaders } from './fileListHeaders'\nexport { type Entry } from './newFileMenu'\nexport { Permission } from './permissions'\n\nexport * from './dav/davProperties'\nexport * from './dav/davPermissions'\nexport * from './dav/dav'\n\nexport { FileType } from './files/fileType'\nexport { File } from './files/file'\nexport { Folder } from './files/folder'\nexport { Node } from './files/node'\n\n// TODO: Add FileInfo type!\n\n/**\n * Add a new menu entry to the upload manager menu\n *\n * @param entry The new file menu entry\n */\nexport const addNewFileMenuEntry = function(entry: Entry) {\n\tconst newFileMenu = getNewFileMenu()\n\treturn newFileMenu.registerEntry(entry)\n}\n\n/**\n * Remove a previously registered entry from the upload menu\n *\n * @param entry Entry to remove (or name of entry)\n */\nexport const removeNewFileMenuEntry = function(entry: Entry | string) {\n\tconst newFileMenu = getNewFileMenu()\n\treturn newFileMenu.unregisterEntry(entry)\n}\n\n/**\n * Get the list of registered entries from the upload menu\n *\n * @param {Folder} context the creation context. Usually the current folder FileInfo\n */\nexport const getNewFileMenuEntries = function(context?: Folder) {\n\tconst newFileMenu = getNewFileMenu()\n\treturn newFileMenu.getEntries(context)\n}\n"],"names":["getLogger","user","getLoggerBuilder","logger","getCurrentUser","NewFileMenu","entry","entryIndex","context","id","getNewFileMenu","humanList","humanListBinary","formatFileSize","size","skipSmallSizes","binaryPrefixes","order","readableFormat","relativeSize","getCanonicalLocale","FileAction","action","registerFileAction","search","getFileActions","Header","header","registerFileListHeaders","getFileListHeaders","Permission","defaultDavProperties","defaultDavNamespaces","registerDavProperty","prop","namespace","namespaces","ns","getDavProperties","getDavNameSpaces","davGetDefaultPropfind","davGetFavoritesReport","davGetRecentSearch","lastModified","davParsePermissions","permString","permissions","FileType","isDavRessource","source","davService","validateData","data","service","join","Node","handler","target","value","basename","extname","firstMatch","dirname","url","destination","File","Folder","davRootPath","davDefaultRootUrl","generateRemoteUrl","davGetClient","davURL","client","createClient","getRequestToken","getPatcher","options","request","getFavoriteNodes","davClient","path","node","result","davResultToNode","davRoot","props","owner","nodeData","addNewFileMenuEntry","removeNewFileMenuEntry","getNewFileMenuEntries"],"mappings":";;;;;;;AAyBA,MAAMA,IAAoBC,OACrBA,MAAS,OACLC,EAAiB,EACtB,OAAO,OAAO,EACd,MAAM,IAEFA,EAAA,EACL,OAAO,OAAO,EACd,OAAOD,EAAK,GAAG,EACf,SAGHE,IAAeH,EAAUI,GAAgB;ACWlC,MAAMC,EAAY;AAAA,EAEhB,WAAyB,CAAA;AAAA,EAE1B,cAAcC,GAAc;AAClC,SAAK,cAAcA,CAAK,GACnB,KAAA,SAAS,KAAKA,CAAK;AAAA,EACzB;AAAA,EAEO,gBAAgBA,GAAuB;AACvC,UAAAC,IAAa,OAAOD,KAAU,WACjC,KAAK,cAAcA,CAAK,IACxB,KAAK,cAAcA,EAAM,EAAE;AAE9B,QAAIC,MAAe,IAAI;AACfJ,QAAA,KAAK,oCAAoC,EAAE,OAAAG,GAAO,SAAS,KAAK,cAAc;AACrF;AAAA,IAAA;AAGI,SAAA,SAAS,OAAOC,GAAY,CAAC;AAAA,EACnC;AAAA,EAOO,WAAWC,GAAgC;AACjD,WAAIA,IACI,KAAK,SACV,OAAOF,OAAS,O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Y,EACX,GAAGH,GACH,GAAGI,GACH,YAAYA,IAAQ,aAAa,EAClC,EAAA;AAGD,SAAOE,OAAAA,EAAS,YAAY,OAErBN,EAAK,SAAS,SAAS,IAAIhB,EAAKsB,CAAQ,IAAI,IAAIrB,EAAOqB,CAAQ;AACvE,GClFaC,KAAsB,SAASlF,GAAc;AAElD,SADaI,IACD,cAAcJ,CAAK;AACvC,GAOamF,KAAyB,SAASnF,GAAuB;AAE9D,SADaI,IACD,gBAAgBJ,CAAK;AACzC,GAOaoF,KAAwB,SAASlF,GAAkB;AAExD,SADaE,IACD,WAAWF,CAAO;AACtC;"}
|
package/dist/newFileMenu.d.ts
CHANGED
|
@@ -19,13 +19,19 @@
|
|
|
19
19
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
20
20
|
*
|
|
21
21
|
*/
|
|
22
|
+
import { Folder } from '.';
|
|
22
23
|
export interface Entry {
|
|
23
24
|
/** Unique ID */
|
|
24
25
|
id: string;
|
|
25
26
|
/** Translatable string displayed in the menu */
|
|
26
27
|
displayName: string;
|
|
28
|
+
/** Default new file name */
|
|
27
29
|
templateName?: string;
|
|
28
|
-
|
|
30
|
+
/**
|
|
31
|
+
* Condition wether this entry is shown or not
|
|
32
|
+
* @param {Folder} context the creation context. Usually the current folder
|
|
33
|
+
*/
|
|
34
|
+
if?: (context: Folder) => boolean;
|
|
29
35
|
/**
|
|
30
36
|
* Either iconSvgInline or iconClass must be defined
|
|
31
37
|
* Svg as inline string. <svg><path fill="..." /></svg>
|
|
@@ -43,9 +49,9 @@ export declare class NewFileMenu {
|
|
|
43
49
|
/**
|
|
44
50
|
* Get the list of registered entries
|
|
45
51
|
*
|
|
46
|
-
* @param {
|
|
52
|
+
* @param {Folder} context the creation context. Usually the current folder FileInfo
|
|
47
53
|
*/
|
|
48
|
-
getEntries(context?:
|
|
54
|
+
getEntries(context?: Folder): Array<Entry>;
|
|
49
55
|
private getEntryIndex;
|
|
50
56
|
private validateEntry;
|
|
51
57
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nextcloud/files",
|
|
3
|
-
"version": "3.0.0-beta.
|
|
3
|
+
"version": "3.0.0-beta.15",
|
|
4
4
|
"description": "Nextcloud files utils",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.cjs",
|
|
@@ -55,18 +55,18 @@
|
|
|
55
55
|
"@nextcloud/typings": "^1.7.0",
|
|
56
56
|
"@nextcloud/vite-config": "^1.0.0-beta.18",
|
|
57
57
|
"@rollup-extras/plugin-clean": "^1.3.6",
|
|
58
|
-
"@rollup/plugin-commonjs": "^25.0.
|
|
58
|
+
"@rollup/plugin-commonjs": "^25.0.4",
|
|
59
59
|
"@rollup/plugin-node-resolve": "^15.1.0",
|
|
60
60
|
"@rollup/plugin-typescript": "^11.1.2",
|
|
61
|
-
"@types/node": "^20.4.
|
|
62
|
-
"@vitest/coverage-istanbul": "^0.
|
|
63
|
-
"fast-xml-parser": "^4.2.
|
|
64
|
-
"rollup": "^3.
|
|
61
|
+
"@types/node": "^20.4.10",
|
|
62
|
+
"@vitest/coverage-istanbul": "^0.34.1",
|
|
63
|
+
"fast-xml-parser": "^4.2.7",
|
|
64
|
+
"rollup": "^3.28.0",
|
|
65
65
|
"tslib": "^2.6.1",
|
|
66
66
|
"typedoc": "^0.24.8",
|
|
67
67
|
"typescript": "^5.0.4",
|
|
68
|
-
"vite": "^4.4.
|
|
69
|
-
"vitest": "^0.
|
|
68
|
+
"vite": "^4.4.9",
|
|
69
|
+
"vitest": "^0.34.1"
|
|
70
70
|
},
|
|
71
71
|
"dependencies": {
|
|
72
72
|
"@nextcloud/auth": "^2.1.0",
|