@nextcloud/files 3.0.0-beta.16 → 3.0.0-beta.17
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/index.cjs +6 -6
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +4 -2
- package/dist/index.mjs +14 -2
- package/dist/index.mjs.map +1 -1
- package/dist/navigation/view.d.ts +4 -0
- package/package.json +5 -5
package/dist/index.cjs
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("@nextcloud/auth"),E=require("@nextcloud/logger"),T=require("@nextcloud/l10n"),d=require("path"),x=require("@nextcloud/router"),b=require("webdav"),L=require("webdav/dist/node/request.js"),P=require("is-svg"),B=e=>e===null?E.getLoggerBuilder().setApp("files").build():E.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,r){return t&&r?this._entries.filter(i=>typeof i.if=="function"?i.if(t,r):!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 f=function(){return typeof window._nc_newfilemenu>"u"&&(window._nc_newfilemenu=new M,s.debug("NewFileMenu initialized")),window._nc_newfilemenu},w=["B","KB","MB","GB","TB","PB"],h=["B","KiB","MiB","GiB","TiB","PiB"];function z(e,t=!1,r=!1){typeof e=="string"&&(e=Number(e));let i=e>0?Math.floor(Math.log(e)/Math.log(r?1024:1e3)):0;i=Math.min((r?h.length:w.length)-1,i);const a=r?h[i]:w[i];let n=(e/Math.pow(r?1024:1e3,i)).toFixed(1);return t===!0&&i===0?(n!=="0.0"?"< 1 ":"0 ")+(r?h[1]:w[1]):(i<2?n=parseFloat(n).toFixed(0):n=parseFloat(n).toLocaleString(T.getCanonicalLocale()),n+" "+a)}var m=(e=>(e.DEFAULT="default",e.HIDDEN="hidden",e))(m||{});class U{_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(t.default&&!Object.values(m).includes(t.default))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 k=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)},H=function(){return typeof window._nc_fileactions>"u"&&(window._nc_fileactions=[],s.debug("FileActions initialized")),window._nc_fileactions};class O{_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 K=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)},j=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 g=["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"],_={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=[...g],window._nc_dav_namespaces={..._});const r={...window._nc_dav_namespaces,...t};if(window._nc_dav_properties.find(a=>a===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 i=e.split(":")[0];return r[i]?(window._nc_dav_properties.push(e),window._nc_dav_namespaces=r,!0):(s.error(`${e} namespace unknown`,{prop:e,namespaces:r}),!1)},u=function(){return typeof window._nc_dav_properties>"u"&&(window._nc_dav_properties=[...g]),window._nc_dav_properties.map(e=>`<${e} />`).join(" ")},l=function(){return typeof window._nc_dav_namespaces>"u"&&(window._nc_dav_namespaces={..._}),Object.keys(window._nc_dav_namespaces).map(e=>`xmlns:${e}="${window._nc_dav_namespaces?.[e]}"`).join(" ")},W=function(){return`<?xml version="1.0"?>
|
|
2
2
|
<d:propfind ${l()}>
|
|
3
3
|
<d:prop>
|
|
4
|
-
${
|
|
4
|
+
${u()}
|
|
5
5
|
</d:prop>
|
|
6
6
|
</d:propfind>`},D=function(){return`<?xml version="1.0"?>
|
|
7
7
|
<oc:filter-files ${l()}>
|
|
8
8
|
<d:prop>
|
|
9
|
-
${
|
|
9
|
+
${u()}
|
|
10
10
|
</d:prop>
|
|
11
11
|
<oc:filter-rules>
|
|
12
12
|
<oc:favorite>1</oc:favorite>
|
|
@@ -17,12 +17,12 @@
|
|
|
17
17
|
<d:basicsearch>
|
|
18
18
|
<d:select>
|
|
19
19
|
<d:prop>
|
|
20
|
-
${
|
|
20
|
+
${u()}
|
|
21
21
|
</d:prop>
|
|
22
22
|
</d:select>
|
|
23
23
|
<d:from>
|
|
24
24
|
<d:scope>
|
|
25
|
-
<d:href>/files/${
|
|
25
|
+
<d:href>/files/${c.getCurrentUser()?.uid}/</d:href>
|
|
26
26
|
<d:depth>infinity</d:depth>
|
|
27
27
|
</d:scope>
|
|
28
28
|
</d:from>
|
|
@@ -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 A=function(e,t){return e.match(t)!==null},I=(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&&A(e.source,t)){const r=e.source.match(t)[0];if(!e.source.includes(d.join(r,e.root)))throw new Error("The root must be relative to the service. e.g /files/emma")}};class v{_data;_attributes;_knownDavService=/(remote|public)\.php\/(web)?dav/i;constructor(t,r){I(t,r||this._knownDavService),this._data=t;const i={set:(a,n,V)=>(this.updateMtime(),Reflect.set(a,n,V)),deleteProperty:(a,n)=>(this.updateMtime(),Reflect.deleteProperty(a,n))};this._attributes=new Proxy(t.attributes||{},i),delete this._data.attributes,r&&(this._knownDavService=r)}get source(){return this._data.source.replace(/\/$/i,"")}get basename(){return d.basename(this.source)}get extension(){return d.extname(this.source)}get dirname(){if(this.root){const r=this.source.indexOf(this.root);return d.dirname(this.source.slice(r+this.root.length)||"/")}const t=new URL(this.source);return d.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 A(this.source,this._knownDavService)}get root(){return this._data.root?this._data.root.replace(/^(.+)\/$/,"$1"):this.isDavRessource&&d.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){I({...this._data,source:t},this._knownDavService),this._data.source=t,this.updateMtime()}rename(t){if(t.includes("/"))throw new Error("Invalid basename");this.move(d.dirname(this.source)+"/"+t)}updateMtime(){this._data.mtime&&(this._data.mtime=new Date)}}class R extends v{get type(){return p.File}}class F extends v{constructor(t){super({...t,mime:"httpd/unix-directory"})}get type(){return p.Folder}get extension(){return null}get mime(){return"httpd/unix-directory"}}const y=`/files/${
|
|
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 A=function(e,t){return e.match(t)!==null},I=(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&&A(e.source,t)){const r=e.source.match(t)[0];if(!e.source.includes(d.join(r,e.root)))throw new Error("The root must be relative to the service. e.g /files/emma")}};class v{_data;_attributes;_knownDavService=/(remote|public)\.php\/(web)?dav/i;constructor(t,r){I(t,r||this._knownDavService),this._data=t;const i={set:(a,n,V)=>(this.updateMtime(),Reflect.set(a,n,V)),deleteProperty:(a,n)=>(this.updateMtime(),Reflect.deleteProperty(a,n))};this._attributes=new Proxy(t.attributes||{},i),delete this._data.attributes,r&&(this._knownDavService=r)}get source(){return this._data.source.replace(/\/$/i,"")}get basename(){return d.basename(this.source)}get extension(){return d.extname(this.source)}get dirname(){if(this.root){const r=this.source.indexOf(this.root);return d.dirname(this.source.slice(r+this.root.length)||"/")}const t=new URL(this.source);return d.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 A(this.source,this._knownDavService)}get root(){return this._data.root?this._data.root.replace(/^(.+)\/$/,"$1"):this.isDavRessource&&d.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){I({...this._data,source:t},this._knownDavService),this._data.source=t,this.updateMtime()}rename(t){if(t.includes("/"))throw new Error("Invalid basename");this.move(d.dirname(this.source)+"/"+t)}updateMtime(){this._data.mtime&&(this._data.mtime=new Date)}}class R extends v{get type(){return p.File}}class F extends v{constructor(t){super({...t,mime:"httpd/unix-directory"})}get type(){return p.Folder}get extension(){return null}get mime(){return"httpd/unix-directory"}}const y=`/files/${c.getCurrentUser()?.uid}`,S=x.generateRemoteUrl("dav"),Q=function(e=S){const t=b.createClient(e,{headers:{requesttoken:c.getRequestToken()||""}});return b.getPatcher().patch("request",r=>(r.headers?.method&&(r.method=r.headers.method,delete r.headers.method),L.request(r))),t},X=async(e,t="/",r=y)=>(await e.getDirectoryContents(`${r}${t}`,{details:!0,data:D(),headers:{method:"REPORT"},includeSelf:!0})).data.filter(i=>i.filename!==t).map(i=>q(i,r)),q=function(e,t=y){const r=e.props,i=N(r?.permissions),a=c.getCurrentUser()?.uid,n={id:r?.fileid||0,source:x.generateRemoteUrl(`dav${t}${e.filename}`),mtime:new Date(Date.parse(e.lastmod)),mime:e.mime,size:r?.size||Number.parseInt(r.getcontentlength||"0"),permissions:i,owner:a,root:t,attributes:{...e,...r,hasPreview:r?.["has-preview"]}};return delete n.attributes?.props,e.type==="file"?new R(n):new F(n)};class C{_views=[];_currentView=null;register(t){if(this._views.find(r=>r.id===t.id))throw new Error(`View id ${t.id} is already registered`);this._views.push(t)}remove(t){const r=this._views.findIndex(i=>i.id===t);r!==-1&&this._views.splice(r,1)}get views(){return this._views}setActive(t){this._currentView=t}get active(){return this._currentView}}const Y=function(){return typeof window._nc_navigation>"u"&&(window._nc_navigation=new C,s.debug("Navigation service initialized")),window._nc_navigation};class ${_column;constructor(t){Z(t),this._column=t}get id(){return this._column.id}get title(){return this._column.title}get render(){return this._column.render}get sort(){return this._column.sort}get summary(){return this._column.summary}}const Z=function(e){if(!e.id||typeof e.id!="string")throw new Error("A column id is required");if(!e.title||typeof e.title!="string")throw new Error("A column title is required");if(!e.render||typeof e.render!="function")throw new Error("A render function is required");if(e.sort&&typeof e.sort!="function")throw new Error("Column sortFunction must be a function");if(e.summary&&typeof e.summary!="function")throw new Error("Column summary must be a function");return!0};class ee{_view;constructor(t){te(t),this._view=t}get id(){return this._view.id}get name(){return this._view.name}get caption(){return this._view.caption}get emptyTitle(){return this._view.emptyTitle}get emptyCaption(){return this._view.emptyCaption}get getContents(){return this._view.getContents}get icon(){return this._view.icon}set icon(t){this._view.icon=t}get order(){return this._view.order}set order(t){this._view.order=t}get params(){return this._view.params}set params(t){this._view.params=t}get columns(){return this._view.columns}get emptyView(){return this._view.emptyView}get parent(){return this._view.parent}get sticky(){return this._view.sticky}get expanded(){return this._view.expanded}set expanded(t){this._view.expanded=t}get defaultSortKey(){return this._view.defaultSortKey}}const te=function(e){if(!e.id||typeof e.id!="string")throw new Error("View id is required and must be a string");if(!e.name||typeof e.name!="string")throw new Error("View name is required and must be a string");if(e.columns&&e.columns.length>0&&(!e.caption||typeof e.caption!="string"))throw new Error("View caption is required for top-level views and must be a string");if(!e.getContents||typeof e.getContents!="function")throw new Error("View getContents is required and must be a function");if(!e.icon||typeof e.icon!="string"||!P(e.icon))throw new Error("View icon is required and must be a valid svg string");if(!("order"in e)||typeof e.order!="number")throw new Error("View order is required and must be a number");if(e.columns&&e.columns.forEach(t=>{if(!(t instanceof $))throw new Error("View columns must be an array of Column. Invalid column found")}),e.emptyView&&typeof e.emptyView!="function")throw new Error("View emptyView must be a function");if(e.parent&&typeof e.parent!="string")throw new Error("View parent must be a string");if("sticky"in e&&typeof e.sticky!="boolean")throw new Error("View sticky must be a boolean");if("expanded"in e&&typeof e.expanded!="boolean")throw new Error("View expanded must be a boolean");if(e.defaultSortKey&&typeof e.defaultSortKey!="string")throw new Error("View defaultSortKey must be a string");return!0},re=function(e){return f().registerEntry(e)},ie=function(e){return f().unregisterEntry(e)},ne=function(e,t){return f().getEntries(e,t)};exports.Column=$,exports.DefaultType=m,exports.File=R,exports.FileAction=U,exports.FileType=p,exports.Folder=F,exports.Header=O,exports.Navigation=C,exports.Node=v,exports.Permission=o,exports.View=ee,exports.addNewFileMenuEntry=re,exports.davGetClient=Q,exports.davGetDefaultPropfind=W,exports.davGetFavoritesReport=D,exports.davGetRecentSearch=J,exports.davParsePermissions=N,exports.davRemoteURL=S,exports.davResultToNode=q,exports.davRootPath=y,exports.defaultDavNamespaces=_,exports.defaultDavProperties=g,exports.formatFileSize=z,exports.getDavNameSpaces=l,exports.getDavProperties=u,exports.getFavoriteNodes=X,exports.getFileActions=H,exports.getFileListHeaders=j,exports.getNavigation=Y,exports.getNewFileMenuEntries=ne,exports.registerDavProperty=G,exports.registerFileAction=k,exports.registerFileListHeaders=K,exports.removeNewFileMenuEntry=ie;
|
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/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/navigation/navigation.ts","../lib/navigation/column.ts","../lib/navigation/view.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 './files/folder'\nimport { View } from './navigation/view'\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, view: View) => 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?: (context: Folder, view: View) => 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\n\t * @param {View} view the current view\n\t */\n\tpublic getEntries(context?: Folder, view?: View): Array<Entry> {\n\t\tif (context && view) {\n\t\t\treturn this._entries\n\t\t\t\t.filter(entry => typeof entry.if === 'function' ? entry.if(context, view) : 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) 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 { Node } from './files/node'\nimport { View } from './navigation/view'\nimport logger from './utils/logger'\n\nexport enum DefaultType {\n\tDEFAULT = 'default',\n\tHIDDEN = 'hidden',\n}\n\ninterface FileActionData {\n\t/** Unique ID */\n\tid: string\n\t/** Translatable string displayed in the menu */\n\tdisplayName: (files: Node[], view: View) => string\n\t/** Svg as inline string. <svg><path fill=\"...\" /></svg> */\n\ticonSvgInline: (files: Node[], view: View) => string\n\t/** Condition wether this action is shown or not */\n\tenabled?: (files: Node[], view: 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: 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: View, dir: string) => Promise<(boolean|null)[]>\n\t/** This action order in the list */\n\torder?: number,\n\n\t/**\n\t * Make this action the default.\n\t * If multiple actions are default, the first one\n\t * will be used. The other ones will be put as first\n\t * entries in the actions menu iff DefaultType.Hidden is not used.\n\t * A DefaultType.Hidden action will never be shown\n\t * in the actions menu even if another action takes\n\t * its place as default.\n\t */\n\tdefault?: DefaultType,\n\t/**\n\t * If true, the renderInline function will be called\n\t */\n\tinline?: (file: Node, view: 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: View) => Promise<HTMLElement | null>,\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 (action.default && !Object.values(DefaultType).includes(action.default)) {\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 { View } from './navigation/view'\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: View) => boolean\n\t/** Executed when file list is initialized */\n\trender: (el: HTMLElement, folder: Folder, view: View) => void\n\t/** Executed when root folder changed */\n\tupdated(folder: Folder, view: 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 { 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\n/**\n * The DAV root path for the current user\n */\nexport const davRootPath = `/files/${getCurrentUser()?.uid}`\n\n/**\n * The DAV remote URL used as base URL for the WebDAV client\n */\nexport const davRemoteURL = generateRemoteUrl('dav')\n\n/**\n * Get a WebDAV client configured to include the Nextcloud request token\n *\n * @param davURL The DAV remote URL\n */\nexport const davGetClient = function(davURL = davRemoteURL) {\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 * @param davRoot The root path for the DAV user (defaults to `davRootPath`)\n * @example\n * ```js\n * import { davGetClient, davRootPath, getFavoriteNodes } from '@nextcloud/files'\n *\n * const client = davGetClient()\n * // query favorites for the root\n * const favorites = await getFavoriteNodes(client)\n * // which is the same as writing:\n * const favorites = await getFavoriteNodes(client, '/', davRootPath)\n * ```\n */\nexport const getFavoriteNodes = async (davClient: WebDAVClient, path = '/', davRoot = davRootPath) => {\n\tconst contentsResponse = await davClient.getDirectoryContents(`${davRoot}${path}`, {\n\t\tdetails: true,\n\t\tdata: davGetFavoritesReport(),\n\t\theaders: {\n\t\t\t// see davGetClient for patched webdav client\n\t\t\tmethod: 'REPORT',\n\t\t},\n\t\tincludeSelf: true,\n\t}) as ResponseDataDetailed<FileStat[]>\n\n\treturn contentsResponse.data\n\t\t.filter(node => node.filename !== path) // exclude current dir\n\t\t.map((result) => davResultToNode(result, davRoot))\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 || Number.parseInt(props.getcontentlength || '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 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 { View } from './view'\nimport logger from '../utils/logger'\n\nexport class Navigation {\n\n\tprivate _views: View[] = []\n\tprivate _currentView: View | null = null\n\n\tregister(view: View) {\n\t\tif (this._views.find(search => search.id === view.id)) {\n\t\t\tthrow new Error(`View id ${view.id} is already registered`)\n\t\t}\n\n\t\tthis._views.push(view)\n\t}\n\n\tremove(id: string) {\n\t\tconst index = this._views.findIndex(view => view.id === id)\n\t\tif (index !== -1) {\n\t\t\tthis._views.splice(index, 1)\n\t\t}\n\t}\n\n\tget views(): View[] {\n\t\treturn this._views\n\t}\n\n\tsetActive(view: View | null) {\n\t\tthis._currentView = view\n\t}\n\n\tget active(): View | null {\n\t\treturn this._currentView\n\t}\n\n}\n\nexport const getNavigation = function(): Navigation {\n\tif (typeof window._nc_navigation === 'undefined') {\n\t\twindow._nc_navigation = new Navigation()\n\t\tlogger.debug('Navigation service initialized')\n\t}\n\n\treturn window._nc_navigation\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 { View } from './view'\nimport { Node } from '../files/node'\n\ninterface ColumnData {\n\t/** Unique column ID */\n\tid: string\n\t/** Translated column title */\n\ttitle: string\n\t/** The content of the cell. The element will be appended within */\n\trender: (node: Node, view: View) => HTMLElement\n\t/** Function used to sort Nodes between them */\n\tsort?: (nodeA: Node, nodeB: Node) => number\n\t/**\n\t * Custom summary of the column to display at the end of the list.\n\t * Will not be displayed if nothing is provided\n\t */\n\tsummary?: (node: Node[], view: View) => string\n}\n\nexport class Column implements ColumnData {\n\n\tprivate _column: ColumnData\n\n\tconstructor(column: ColumnData) {\n\t\tisValidColumn(column)\n\t\tthis._column = column\n\t}\n\n\tget id() {\n\t\treturn this._column.id\n\t}\n\n\tget title() {\n\t\treturn this._column.title\n\t}\n\n\tget render() {\n\t\treturn this._column.render\n\t}\n\n\tget sort() {\n\t\treturn this._column.sort\n\t}\n\n\tget summary() {\n\t\treturn this._column.summary\n\t}\n\n}\n\n/**\n * Typescript cannot validate an interface.\n * Please keep in sync with the Column interface requirements.\n *\n * @param {ColumnData} column the column to check\n * @return {boolean} true if the column is valid\n */\nconst isValidColumn = function(column: ColumnData): boolean {\n\tif (!column.id || typeof column.id !== 'string') {\n\t\tthrow new Error('A column id is required')\n\t}\n\n\tif (!column.title || typeof column.title !== 'string') {\n\t\tthrow new Error('A column title is required')\n\t}\n\n\tif (!column.render || typeof column.render !== 'function') {\n\t\tthrow new Error('A render function is required')\n\t}\n\n\t// Optional properties\n\tif (column.sort && typeof column.sort !== 'function') {\n\t\tthrow new Error('Column sortFunction must be a function')\n\t}\n\n\tif (column.summary && typeof column.summary !== 'function') {\n\t\tthrow new Error('Column summary must be a function')\n\t}\n\n\treturn true\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/* eslint-disable no-use-before-define */\nimport type { Folder, Node } from '@nextcloud/files'\nimport isSvg from 'is-svg'\n\nimport { Column } from './column.js'\n\nexport type ContentsWithRoot = {\n\tfolder: Folder,\n\tcontents: Node[]\n}\n\ninterface ViewData {\n\t/** Unique view ID */\n\tid: string\n\t/** Translated view name */\n\tname: string\n\t/** Translated accessible description of the view */\n\tcaption?: string\n\n\t/** Translated title of the empty view */\n\temptyTitle?: string\n\t/** Translated description of the empty view */\n\temptyCaption?: string\n\n\t/**\n\t * Method return the content of the provided path\n\t * This ideally should be a cancellable promise.\n\t * promise.cancel(reason) will be called when the directory\n\t * change and the promise is not resolved yet.\n\t * You _must_ also return the current directory\n\t * information alongside with its content.\n\t */\n\tgetContents: (path: string) => Promise<ContentsWithRoot>\n\t/** The view icon as an inline svg */\n\ticon: string\n\t/** The view order */\n\torder: number\n\n\t/**\n\t * Custom params to give to the router on click\n\t * If defined, will be treated as a dummy view and\n\t * will just redirect and not fetch any contents.\n\t */\n\tparams?: Record<string, string>\n\n\t/**\n\t * This view column(s). Name and actions are\n\t * by default always included\n\t */\n\tcolumns?: Column[]\n\t/** The empty view element to render your empty content into */\n\temptyView?: (div: HTMLDivElement) => void\n\t/** The parent unique ID */\n\tparent?: string\n\t/** This view is sticky (sent at the bottom) */\n\tsticky?: boolean\n\n\t/**\n\t * This view has children and is expanded (by default)\n\t * or not. This will be overridden by user config.\n\t */\n\texpanded?: boolean\n\n\t/**\n\t * Will be used as default if the user\n\t * haven't customized their sorting column\n\t */\n\tdefaultSortKey?: string\n}\n\nexport class View implements ViewData {\n\n\tprivate _view: ViewData\n\n\tconstructor(view: ViewData) {\n\t\tisValidView(view)\n\t\tthis._view = view\n\t}\n\n\tget id() {\n\t\treturn this._view.id\n\t}\n\n\tget name() {\n\t\treturn this._view.name\n\t}\n\n\tget caption() {\n\t\treturn this._view.caption\n\t}\n\n\tget emptyTitle() {\n\t\treturn this._view.emptyTitle\n\t}\n\n\tget emptyCaption() {\n\t\treturn this._view.emptyCaption\n\t}\n\n\tget getContents() {\n\t\treturn this._view.getContents\n\t}\n\n\tget icon() {\n\t\treturn this._view.icon\n\t}\n\n\tget order() {\n\t\treturn this._view.order\n\t}\n\n\tget params() {\n\t\treturn this._view.params\n\t}\n\n\tget columns() {\n\t\treturn this._view.columns\n\t}\n\n\tget emptyView() {\n\t\treturn this._view.emptyView\n\t}\n\n\tget parent() {\n\t\treturn this._view.parent\n\t}\n\n\tget sticky() {\n\t\treturn this._view.sticky\n\t}\n\n\tget expanded() {\n\t\treturn this._view.expanded\n\t}\n\n\tget defaultSortKey() {\n\t\treturn this._view.defaultSortKey\n\t}\n\n}\n\n/**\n * Typescript cannot validate an interface.\n * Please keep in sync with the View interface requirements.\n *\n * @param {ViewData} view the view to check\n * @return {boolean} true if the column is valid\n * @throws {Error} if the view is not valid\n */\nconst isValidView = function(view: ViewData): boolean {\n\tif (!view.id || typeof view.id !== 'string') {\n\t\tthrow new Error('View id is required and must be a string')\n\t}\n\n\tif (!view.name || typeof view.name !== 'string') {\n\t\tthrow new Error('View name is required and must be a string')\n\t}\n\n\tif (view.columns && view.columns.length > 0\n\t\t&& (!view.caption || typeof view.caption !== 'string')) {\n\t\tthrow new Error('View caption is required for top-level views and must be a string')\n\t}\n\n\tif (!view.getContents || typeof view.getContents !== 'function') {\n\t\tthrow new Error('View getContents is required and must be a function')\n\t}\n\n\tif (!view.icon || typeof view.icon !== 'string' || !isSvg(view.icon)) {\n\t\tthrow new Error('View icon is required and must be a valid svg string')\n\t}\n\n\tif (!('order' in view) || typeof view.order !== 'number') {\n\t\tthrow new Error('View order is required and must be a number')\n\t}\n\n\t// Optional properties\n\tif (view.columns) {\n\t\tview.columns.forEach((column) => {\n\t\t\tif (!(column instanceof Column)) {\n\t\t\t\tthrow new Error('View columns must be an array of Column. Invalid column found')\n\t\t\t}\n\t\t})\n\t}\n\n\tif (view.emptyView && typeof view.emptyView !== 'function') {\n\t\tthrow new Error('View emptyView must be a function')\n\t}\n\n\tif (view.parent && typeof view.parent !== 'string') {\n\t\tthrow new Error('View parent must be a string')\n\t}\n\n\tif ('sticky' in view && typeof view.sticky !== 'boolean') {\n\t\tthrow new Error('View sticky must be a boolean')\n\t}\n\n\tif ('expanded' in view && typeof view.expanded !== 'boolean') {\n\t\tthrow new Error('View expanded must be a boolean')\n\t}\n\n\tif (view.defaultSortKey && typeof view.defaultSortKey !== 'string') {\n\t\tthrow new Error('View defaultSortKey must be a string')\n\t}\n\n\treturn true\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, DefaultType } 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\nexport * from './navigation/navigation'\nexport * from './navigation/column'\nexport * from './navigation/view'\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","view","id","getNewFileMenu","humanList","humanListBinary","formatFileSize","size","skipSmallSizes","binaryPrefixes","order","readableFormat","relativeSize","getCanonicalLocale","DefaultType","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","davRemoteURL","generateRemoteUrl","davGetClient","davURL","client","createClient","getRequestToken","getPatcher","options","request","getFavoriteNodes","davClient","path","davRoot","node","result","davResultToNode","props","owner","nodeData","Navigation","index","getNavigation","Column","column","isValidColumn","View","isValidView","isSvg","addNewFileMenuEntry","removeNewFileMenuEntry","getNewFileMenuEntries"],"mappings":"iTAyBMA,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,ECYlC,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,MAAA,CAGI,KAAA,SAAS,OAAOC,EAAY,CAAC,CACnC,CAQO,WAAWC,EAAkBC,EAA2B,CAC9D,OAAID,GAAWC,EACP,KAAK,SACV,OAAOH,GAAS,OAAOA,EAAM,IAAO,WAAaA,EAAM,GAAGE,EAASC,CAAI,EAAI,EAAI,EAE3E,KAAK,QACb,CAEQ,cAAcC,EAAoB,CACzC,OAAO,KAAK,SAAS,UAAmBJ,GAAAA,EAAM,KAAOI,CAAE,CACxD,CAEQ,cAAcJ,EAAc,CAC/B,GAAA,CAACA,EAAM,IAAM,CAACA,EAAM,aAAe,EAAEA,EAAM,eAAiBA,EAAM,WAC/D,MAAA,IAAI,MAAM,eAAe,EAGhC,GAAI,OAAOA,EAAM,IAAO,UACpB,OAAOA,EAAM,aAAgB,SAC1B,MAAA,IAAI,MAAM,oCAAoC,EAGhD,GAAAA,EAAM,WAAa,OAAOA,EAAM,WAAc,UAC9CA,EAAM,eAAiB,OAA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EAGhD,GAAI,aAAcA,GAAQ,OAAOA,EAAK,UAAa,UAC5C,MAAA,IAAI,MAAM,iCAAiC,EAGlD,GAAIA,EAAK,gBAAkB,OAAOA,EAAK,gBAAmB,SACnD,MAAA,IAAI,MAAM,sCAAsC,EAGhD,MAAA,EACR,EChLa0F,GAAsB,SAAS7F,EAAc,CAElD,OADaK,IACD,cAAcL,CAAK,CACvC,EAOa8F,GAAyB,SAAS9F,EAAuB,CAE9D,OADaK,IACD,gBAAgBL,CAAK,CACzC,EAOa+F,GAAwB,SAAS7F,EAAkB,CAExD,OADaG,IACD,WAAWH,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/navigation/navigation.ts","../lib/navigation/column.ts","../lib/navigation/view.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 './files/folder'\nimport { View } from './navigation/view'\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, view: View) => 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?: (context: Folder, view: View) => 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\n\t * @param {View} view the current view\n\t */\n\tpublic getEntries(context?: Folder, view?: View): Array<Entry> {\n\t\tif (context && view) {\n\t\t\treturn this._entries\n\t\t\t\t.filter(entry => typeof entry.if === 'function' ? entry.if(context, view) : 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) 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 { Node } from './files/node'\nimport { View } from './navigation/view'\nimport logger from './utils/logger'\n\nexport enum DefaultType {\n\tDEFAULT = 'default',\n\tHIDDEN = 'hidden',\n}\n\ninterface FileActionData {\n\t/** Unique ID */\n\tid: string\n\t/** Translatable string displayed in the menu */\n\tdisplayName: (files: Node[], view: View) => string\n\t/** Svg as inline string. <svg><path fill=\"...\" /></svg> */\n\ticonSvgInline: (files: Node[], view: View) => string\n\t/** Condition wether this action is shown or not */\n\tenabled?: (files: Node[], view: 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: 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: View, dir: string) => Promise<(boolean|null)[]>\n\t/** This action order in the list */\n\torder?: number,\n\n\t/**\n\t * Make this action the default.\n\t * If multiple actions are default, the first one\n\t * will be used. The other ones will be put as first\n\t * entries in the actions menu iff DefaultType.Hidden is not used.\n\t * A DefaultType.Hidden action will never be shown\n\t * in the actions menu even if another action takes\n\t * its place as default.\n\t */\n\tdefault?: DefaultType,\n\t/**\n\t * If true, the renderInline function will be called\n\t */\n\tinline?: (file: Node, view: 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: View) => Promise<HTMLElement | null>,\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 (action.default && !Object.values(DefaultType).includes(action.default)) {\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 { View } from './navigation/view'\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: View) => boolean\n\t/** Executed when file list is initialized */\n\trender: (el: HTMLElement, folder: Folder, view: View) => void\n\t/** Executed when root folder changed */\n\tupdated(folder: Folder, view: 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 { 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\n/**\n * The DAV root path for the current user\n */\nexport const davRootPath = `/files/${getCurrentUser()?.uid}`\n\n/**\n * The DAV remote URL used as base URL for the WebDAV client\n */\nexport const davRemoteURL = generateRemoteUrl('dav')\n\n/**\n * Get a WebDAV client configured to include the Nextcloud request token\n *\n * @param davURL The DAV remote URL\n */\nexport const davGetClient = function(davURL = davRemoteURL) {\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 * @param davRoot The root path for the DAV user (defaults to `davRootPath`)\n * @example\n * ```js\n * import { davGetClient, davRootPath, getFavoriteNodes } from '@nextcloud/files'\n *\n * const client = davGetClient()\n * // query favorites for the root\n * const favorites = await getFavoriteNodes(client)\n * // which is the same as writing:\n * const favorites = await getFavoriteNodes(client, '/', davRootPath)\n * ```\n */\nexport const getFavoriteNodes = async (davClient: WebDAVClient, path = '/', davRoot = davRootPath) => {\n\tconst contentsResponse = await davClient.getDirectoryContents(`${davRoot}${path}`, {\n\t\tdetails: true,\n\t\tdata: davGetFavoritesReport(),\n\t\theaders: {\n\t\t\t// see davGetClient for patched webdav client\n\t\t\tmethod: 'REPORT',\n\t\t},\n\t\tincludeSelf: true,\n\t}) as ResponseDataDetailed<FileStat[]>\n\n\treturn contentsResponse.data\n\t\t.filter(node => node.filename !== path) // exclude current dir\n\t\t.map((result) => davResultToNode(result, davRoot))\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 || Number.parseInt(props.getcontentlength || '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 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 { View } from './view'\nimport logger from '../utils/logger'\n\nexport class Navigation {\n\n\tprivate _views: View[] = []\n\tprivate _currentView: View | null = null\n\n\tregister(view: View) {\n\t\tif (this._views.find(search => search.id === view.id)) {\n\t\t\tthrow new Error(`View id ${view.id} is already registered`)\n\t\t}\n\n\t\tthis._views.push(view)\n\t}\n\n\tremove(id: string) {\n\t\tconst index = this._views.findIndex(view => view.id === id)\n\t\tif (index !== -1) {\n\t\t\tthis._views.splice(index, 1)\n\t\t}\n\t}\n\n\tget views(): View[] {\n\t\treturn this._views\n\t}\n\n\tsetActive(view: View | null) {\n\t\tthis._currentView = view\n\t}\n\n\tget active(): View | null {\n\t\treturn this._currentView\n\t}\n\n}\n\nexport const getNavigation = function(): Navigation {\n\tif (typeof window._nc_navigation === 'undefined') {\n\t\twindow._nc_navigation = new Navigation()\n\t\tlogger.debug('Navigation service initialized')\n\t}\n\n\treturn window._nc_navigation\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 { View } from './view'\nimport { Node } from '../files/node'\n\ninterface ColumnData {\n\t/** Unique column ID */\n\tid: string\n\t/** Translated column title */\n\ttitle: string\n\t/** The content of the cell. The element will be appended within */\n\trender: (node: Node, view: View) => HTMLElement\n\t/** Function used to sort Nodes between them */\n\tsort?: (nodeA: Node, nodeB: Node) => number\n\t/**\n\t * Custom summary of the column to display at the end of the list.\n\t * Will not be displayed if nothing is provided\n\t */\n\tsummary?: (node: Node[], view: View) => string\n}\n\nexport class Column implements ColumnData {\n\n\tprivate _column: ColumnData\n\n\tconstructor(column: ColumnData) {\n\t\tisValidColumn(column)\n\t\tthis._column = column\n\t}\n\n\tget id() {\n\t\treturn this._column.id\n\t}\n\n\tget title() {\n\t\treturn this._column.title\n\t}\n\n\tget render() {\n\t\treturn this._column.render\n\t}\n\n\tget sort() {\n\t\treturn this._column.sort\n\t}\n\n\tget summary() {\n\t\treturn this._column.summary\n\t}\n\n}\n\n/**\n * Typescript cannot validate an interface.\n * Please keep in sync with the Column interface requirements.\n *\n * @param {ColumnData} column the column to check\n * @return {boolean} true if the column is valid\n */\nconst isValidColumn = function(column: ColumnData): boolean {\n\tif (!column.id || typeof column.id !== 'string') {\n\t\tthrow new Error('A column id is required')\n\t}\n\n\tif (!column.title || typeof column.title !== 'string') {\n\t\tthrow new Error('A column title is required')\n\t}\n\n\tif (!column.render || typeof column.render !== 'function') {\n\t\tthrow new Error('A render function is required')\n\t}\n\n\t// Optional properties\n\tif (column.sort && typeof column.sort !== 'function') {\n\t\tthrow new Error('Column sortFunction must be a function')\n\t}\n\n\tif (column.summary && typeof column.summary !== 'function') {\n\t\tthrow new Error('Column summary must be a function')\n\t}\n\n\treturn true\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/* eslint-disable no-use-before-define */\nimport type { Folder, Node } from '@nextcloud/files'\nimport isSvg from 'is-svg'\n\nimport { Column } from './column.js'\n\nexport type ContentsWithRoot = {\n\tfolder: Folder,\n\tcontents: Node[]\n}\n\ninterface ViewData {\n\t/** Unique view ID */\n\tid: string\n\t/** Translated view name */\n\tname: string\n\t/** Translated accessible description of the view */\n\tcaption?: string\n\n\t/** Translated title of the empty view */\n\temptyTitle?: string\n\t/** Translated description of the empty view */\n\temptyCaption?: string\n\n\t/**\n\t * Method return the content of the provided path\n\t * This ideally should be a cancellable promise.\n\t * promise.cancel(reason) will be called when the directory\n\t * change and the promise is not resolved yet.\n\t * You _must_ also return the current directory\n\t * information alongside with its content.\n\t */\n\tgetContents: (path: string) => Promise<ContentsWithRoot>\n\t/** The view icon as an inline svg */\n\ticon: string\n\t/** The view order */\n\torder: number\n\n\t/**\n\t * Custom params to give to the router on click\n\t * If defined, will be treated as a dummy view and\n\t * will just redirect and not fetch any contents.\n\t */\n\tparams?: Record<string, string>\n\n\t/**\n\t * This view column(s). Name and actions are\n\t * by default always included\n\t */\n\tcolumns?: Column[]\n\t/** The empty view element to render your empty content into */\n\temptyView?: (div: HTMLDivElement) => void\n\t/** The parent unique ID */\n\tparent?: string\n\t/** This view is sticky (sent at the bottom) */\n\tsticky?: boolean\n\n\t/**\n\t * This view has children and is expanded (by default)\n\t * or not. This will be overridden by user config.\n\t */\n\texpanded?: boolean\n\n\t/**\n\t * Will be used as default if the user\n\t * haven't customized their sorting column\n\t */\n\tdefaultSortKey?: string\n}\n\nexport class View implements ViewData {\n\n\tprivate _view: ViewData\n\n\tconstructor(view: ViewData) {\n\t\tisValidView(view)\n\t\tthis._view = view\n\t}\n\n\tget id() {\n\t\treturn this._view.id\n\t}\n\n\tget name() {\n\t\treturn this._view.name\n\t}\n\n\tget caption() {\n\t\treturn this._view.caption\n\t}\n\n\tget emptyTitle() {\n\t\treturn this._view.emptyTitle\n\t}\n\n\tget emptyCaption() {\n\t\treturn this._view.emptyCaption\n\t}\n\n\tget getContents() {\n\t\treturn this._view.getContents\n\t}\n\n\tget icon() {\n\t\treturn this._view.icon\n\t}\n\n\tset icon(icon) {\n\t\tthis._view.icon = icon\n\t}\n\n\tget order() {\n\t\treturn this._view.order\n\t}\n\n\tset order(order) {\n\t\tthis._view.order = order\n\t}\n\n\tget params() {\n\t\treturn this._view.params\n\t}\n\n\tset params(params) {\n\t\tthis._view.params = params\n\t}\n\n\tget columns() {\n\t\treturn this._view.columns\n\t}\n\n\tget emptyView() {\n\t\treturn this._view.emptyView\n\t}\n\n\tget parent() {\n\t\treturn this._view.parent\n\t}\n\n\tget sticky() {\n\t\treturn this._view.sticky\n\t}\n\n\tget expanded() {\n\t\treturn this._view.expanded\n\t}\n\n\tset expanded(expanded: boolean | undefined) {\n\t\tthis._view.expanded = expanded\n\t}\n\n\tget defaultSortKey() {\n\t\treturn this._view.defaultSortKey\n\t}\n\n}\n\n/**\n * Typescript cannot validate an interface.\n * Please keep in sync with the View interface requirements.\n *\n * @param {ViewData} view the view to check\n * @return {boolean} true if the column is valid\n * @throws {Error} if the view is not valid\n */\nconst isValidView = function(view: ViewData): boolean {\n\tif (!view.id || typeof view.id !== 'string') {\n\t\tthrow new Error('View id is required and must be a string')\n\t}\n\n\tif (!view.name || typeof view.name !== 'string') {\n\t\tthrow new Error('View name is required and must be a string')\n\t}\n\n\tif (view.columns && view.columns.length > 0\n\t\t&& (!view.caption || typeof view.caption !== 'string')) {\n\t\tthrow new Error('View caption is required for top-level views and must be a string')\n\t}\n\n\tif (!view.getContents || typeof view.getContents !== 'function') {\n\t\tthrow new Error('View getContents is required and must be a function')\n\t}\n\n\tif (!view.icon || typeof view.icon !== 'string' || !isSvg(view.icon)) {\n\t\tthrow new Error('View icon is required and must be a valid svg string')\n\t}\n\n\tif (!('order' in view) || typeof view.order !== 'number') {\n\t\tthrow new Error('View order is required and must be a number')\n\t}\n\n\t// Optional properties\n\tif (view.columns) {\n\t\tview.columns.forEach((column) => {\n\t\t\tif (!(column instanceof Column)) {\n\t\t\t\tthrow new Error('View columns must be an array of Column. Invalid column found')\n\t\t\t}\n\t\t})\n\t}\n\n\tif (view.emptyView && typeof view.emptyView !== 'function') {\n\t\tthrow new Error('View emptyView must be a function')\n\t}\n\n\tif (view.parent && typeof view.parent !== 'string') {\n\t\tthrow new Error('View parent must be a string')\n\t}\n\n\tif ('sticky' in view && typeof view.sticky !== 'boolean') {\n\t\tthrow new Error('View sticky must be a boolean')\n\t}\n\n\tif ('expanded' in view && typeof view.expanded !== 'boolean') {\n\t\tthrow new Error('View expanded must be a boolean')\n\t}\n\n\tif (view.defaultSortKey && typeof view.defaultSortKey !== 'string') {\n\t\tthrow new Error('View defaultSortKey must be a string')\n\t}\n\n\treturn true\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 { type Folder } from './files/folder'\nimport { type View } from './navigation/view'\n\nexport { formatFileSize } from './humanfilesize'\nexport { FileAction, getFileActions, registerFileAction, DefaultType } 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\nexport * from './navigation/navigation'\nexport * from './navigation/column'\nexport * from './navigation/view'\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 * @param {View} view the current view\n */\nexport const getNewFileMenuEntries = function(context?: Folder, view?: View) {\n\tconst newFileMenu = getNewFileMenu()\n\treturn newFileMenu.getEntries(context, view)\n}\n"],"names":["getLogger","user","getLoggerBuilder","logger","getCurrentUser","NewFileMenu","entry","entryIndex","context","view","id","getNewFileMenu","humanList","humanListBinary","formatFileSize","size","skipSmallSizes","binaryPrefixes","order","readableFormat","relativeSize","getCanonicalLocale","DefaultType","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","davRemoteURL","generateRemoteUrl","davGetClient","davURL","client","createClient","getRequestToken","getPatcher","options","request","getFavoriteNodes","davClient","path","davRoot","node","result","davResultToNode","props","owner","nodeData","Navigation","index","getNavigation","Column","column","isValidColumn","View","isValidView","icon","params","expanded","isSvg","addNewFileMenuEntry","removeNewFileMenuEntry","getNewFileMenuEntries"],"mappings":"iTAyBMA,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,ECY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AiC,EAGlD,GAAIA,EAAK,gBAAkB,OAAOA,EAAK,gBAAmB,SACnD,MAAA,IAAI,MAAM,sCAAsC,EAGhD,MAAA,EACR,EC/La6F,GAAsB,SAAShG,EAAc,CAElD,OADaK,IACD,cAAcL,CAAK,CACvC,EAOaiG,GAAyB,SAASjG,EAAuB,CAE9D,OADaK,IACD,gBAAgBL,CAAK,CACzC,EAQakG,GAAwB,SAAShG,EAAkBC,EAAa,CAErE,OADaE,IACD,WAAWH,EAASC,CAAI,CAC5C"}
|
package/dist/index.d.ts
CHANGED
|
@@ -21,7 +21,8 @@
|
|
|
21
21
|
*
|
|
22
22
|
*/
|
|
23
23
|
import { type Entry } from './newFileMenu';
|
|
24
|
-
import { Folder } from './files/folder';
|
|
24
|
+
import { type Folder } from './files/folder';
|
|
25
|
+
import { type View } from './navigation/view';
|
|
25
26
|
export { formatFileSize } from './humanfilesize';
|
|
26
27
|
export { FileAction, getFileActions, registerFileAction, DefaultType } from './fileAction';
|
|
27
28
|
export { Header, getFileListHeaders, registerFileListHeaders } from './fileListHeaders';
|
|
@@ -53,5 +54,6 @@ export declare const removeNewFileMenuEntry: (entry: Entry | string) => void;
|
|
|
53
54
|
* Get the list of registered entries from the upload menu
|
|
54
55
|
*
|
|
55
56
|
* @param {Folder} context the creation context. Usually the current folder FileInfo
|
|
57
|
+
* @param {View} view the current view
|
|
56
58
|
*/
|
|
57
|
-
export declare const getNewFileMenuEntries: (context?: Folder) => Entry[];
|
|
59
|
+
export declare const getNewFileMenuEntries: (context?: Folder, view?: View) => Entry[];
|
package/dist/index.mjs
CHANGED
|
@@ -484,12 +484,21 @@ class we {
|
|
|
484
484
|
get icon() {
|
|
485
485
|
return this._view.icon;
|
|
486
486
|
}
|
|
487
|
+
set icon(t) {
|
|
488
|
+
this._view.icon = t;
|
|
489
|
+
}
|
|
487
490
|
get order() {
|
|
488
491
|
return this._view.order;
|
|
489
492
|
}
|
|
493
|
+
set order(t) {
|
|
494
|
+
this._view.order = t;
|
|
495
|
+
}
|
|
490
496
|
get params() {
|
|
491
497
|
return this._view.params;
|
|
492
498
|
}
|
|
499
|
+
set params(t) {
|
|
500
|
+
this._view.params = t;
|
|
501
|
+
}
|
|
493
502
|
get columns() {
|
|
494
503
|
return this._view.columns;
|
|
495
504
|
}
|
|
@@ -505,6 +514,9 @@ class we {
|
|
|
505
514
|
get expanded() {
|
|
506
515
|
return this._view.expanded;
|
|
507
516
|
}
|
|
517
|
+
set expanded(t) {
|
|
518
|
+
this._view.expanded = t;
|
|
519
|
+
}
|
|
508
520
|
get defaultSortKey() {
|
|
509
521
|
return this._view.defaultSortKey;
|
|
510
522
|
}
|
|
@@ -540,8 +552,8 @@ const G = function(e) {
|
|
|
540
552
|
return p().registerEntry(e);
|
|
541
553
|
}, me = function(e) {
|
|
542
554
|
return p().unregisterEntry(e);
|
|
543
|
-
}, ge = function(e) {
|
|
544
|
-
return p().getEntries(e);
|
|
555
|
+
}, ge = function(e, t) {
|
|
556
|
+
return p().getEntries(e, t);
|
|
545
557
|
};
|
|
546
558
|
export {
|
|
547
559
|
O as Column,
|
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/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/navigation/navigation.ts","../lib/navigation/column.ts","../lib/navigation/view.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 './files/folder'\nimport { View } from './navigation/view'\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, view: View) => 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?: (context: Folder, view: View) => 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\n\t * @param {View} view the current view\n\t */\n\tpublic getEntries(context?: Folder, view?: View): Array<Entry> {\n\t\tif (context && view) {\n\t\t\treturn this._entries\n\t\t\t\t.filter(entry => typeof entry.if === 'function' ? entry.if(context, view) : 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) 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 { Node } from './files/node'\nimport { View } from './navigation/view'\nimport logger from './utils/logger'\n\nexport enum DefaultType {\n\tDEFAULT = 'default',\n\tHIDDEN = 'hidden',\n}\n\ninterface FileActionData {\n\t/** Unique ID */\n\tid: string\n\t/** Translatable string displayed in the menu */\n\tdisplayName: (files: Node[], view: View) => string\n\t/** Svg as inline string. <svg><path fill=\"...\" /></svg> */\n\ticonSvgInline: (files: Node[], view: View) => string\n\t/** Condition wether this action is shown or not */\n\tenabled?: (files: Node[], view: 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: 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: View, dir: string) => Promise<(boolean|null)[]>\n\t/** This action order in the list */\n\torder?: number,\n\n\t/**\n\t * Make this action the default.\n\t * If multiple actions are default, the first one\n\t * will be used. The other ones will be put as first\n\t * entries in the actions menu iff DefaultType.Hidden is not used.\n\t * A DefaultType.Hidden action will never be shown\n\t * in the actions menu even if another action takes\n\t * its place as default.\n\t */\n\tdefault?: DefaultType,\n\t/**\n\t * If true, the renderInline function will be called\n\t */\n\tinline?: (file: Node, view: 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: View) => Promise<HTMLElement | null>,\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 (action.default && !Object.values(DefaultType).includes(action.default)) {\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 { View } from './navigation/view'\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: View) => boolean\n\t/** Executed when file list is initialized */\n\trender: (el: HTMLElement, folder: Folder, view: View) => void\n\t/** Executed when root folder changed */\n\tupdated(folder: Folder, view: 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 { 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\n/**\n * The DAV root path for the current user\n */\nexport const davRootPath = `/files/${getCurrentUser()?.uid}`\n\n/**\n * The DAV remote URL used as base URL for the WebDAV client\n */\nexport const davRemoteURL = generateRemoteUrl('dav')\n\n/**\n * Get a WebDAV client configured to include the Nextcloud request token\n *\n * @param davURL The DAV remote URL\n */\nexport const davGetClient = function(davURL = davRemoteURL) {\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 * @param davRoot The root path for the DAV user (defaults to `davRootPath`)\n * @example\n * ```js\n * import { davGetClient, davRootPath, getFavoriteNodes } from '@nextcloud/files'\n *\n * const client = davGetClient()\n * // query favorites for the root\n * const favorites = await getFavoriteNodes(client)\n * // which is the same as writing:\n * const favorites = await getFavoriteNodes(client, '/', davRootPath)\n * ```\n */\nexport const getFavoriteNodes = async (davClient: WebDAVClient, path = '/', davRoot = davRootPath) => {\n\tconst contentsResponse = await davClient.getDirectoryContents(`${davRoot}${path}`, {\n\t\tdetails: true,\n\t\tdata: davGetFavoritesReport(),\n\t\theaders: {\n\t\t\t// see davGetClient for patched webdav client\n\t\t\tmethod: 'REPORT',\n\t\t},\n\t\tincludeSelf: true,\n\t}) as ResponseDataDetailed<FileStat[]>\n\n\treturn contentsResponse.data\n\t\t.filter(node => node.filename !== path) // exclude current dir\n\t\t.map((result) => davResultToNode(result, davRoot))\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 || Number.parseInt(props.getcontentlength || '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 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 { View } from './view'\nimport logger from '../utils/logger'\n\nexport class Navigation {\n\n\tprivate _views: View[] = []\n\tprivate _currentView: View | null = null\n\n\tregister(view: View) {\n\t\tif (this._views.find(search => search.id === view.id)) {\n\t\t\tthrow new Error(`View id ${view.id} is already registered`)\n\t\t}\n\n\t\tthis._views.push(view)\n\t}\n\n\tremove(id: string) {\n\t\tconst index = this._views.findIndex(view => view.id === id)\n\t\tif (index !== -1) {\n\t\t\tthis._views.splice(index, 1)\n\t\t}\n\t}\n\n\tget views(): View[] {\n\t\treturn this._views\n\t}\n\n\tsetActive(view: View | null) {\n\t\tthis._currentView = view\n\t}\n\n\tget active(): View | null {\n\t\treturn this._currentView\n\t}\n\n}\n\nexport const getNavigation = function(): Navigation {\n\tif (typeof window._nc_navigation === 'undefined') {\n\t\twindow._nc_navigation = new Navigation()\n\t\tlogger.debug('Navigation service initialized')\n\t}\n\n\treturn window._nc_navigation\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 { View } from './view'\nimport { Node } from '../files/node'\n\ninterface ColumnData {\n\t/** Unique column ID */\n\tid: string\n\t/** Translated column title */\n\ttitle: string\n\t/** The content of the cell. The element will be appended within */\n\trender: (node: Node, view: View) => HTMLElement\n\t/** Function used to sort Nodes between them */\n\tsort?: (nodeA: Node, nodeB: Node) => number\n\t/**\n\t * Custom summary of the column to display at the end of the list.\n\t * Will not be displayed if nothing is provided\n\t */\n\tsummary?: (node: Node[], view: View) => string\n}\n\nexport class Column implements ColumnData {\n\n\tprivate _column: ColumnData\n\n\tconstructor(column: ColumnData) {\n\t\tisValidColumn(column)\n\t\tthis._column = column\n\t}\n\n\tget id() {\n\t\treturn this._column.id\n\t}\n\n\tget title() {\n\t\treturn this._column.title\n\t}\n\n\tget render() {\n\t\treturn this._column.render\n\t}\n\n\tget sort() {\n\t\treturn this._column.sort\n\t}\n\n\tget summary() {\n\t\treturn this._column.summary\n\t}\n\n}\n\n/**\n * Typescript cannot validate an interface.\n * Please keep in sync with the Column interface requirements.\n *\n * @param {ColumnData} column the column to check\n * @return {boolean} true if the column is valid\n */\nconst isValidColumn = function(column: ColumnData): boolean {\n\tif (!column.id || typeof column.id !== 'string') {\n\t\tthrow new Error('A column id is required')\n\t}\n\n\tif (!column.title || typeof column.title !== 'string') {\n\t\tthrow new Error('A column title is required')\n\t}\n\n\tif (!column.render || typeof column.render !== 'function') {\n\t\tthrow new Error('A render function is required')\n\t}\n\n\t// Optional properties\n\tif (column.sort && typeof column.sort !== 'function') {\n\t\tthrow new Error('Column sortFunction must be a function')\n\t}\n\n\tif (column.summary && typeof column.summary !== 'function') {\n\t\tthrow new Error('Column summary must be a function')\n\t}\n\n\treturn true\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/* eslint-disable no-use-before-define */\nimport type { Folder, Node } from '@nextcloud/files'\nimport isSvg from 'is-svg'\n\nimport { Column } from './column.js'\n\nexport type ContentsWithRoot = {\n\tfolder: Folder,\n\tcontents: Node[]\n}\n\ninterface ViewData {\n\t/** Unique view ID */\n\tid: string\n\t/** Translated view name */\n\tname: string\n\t/** Translated accessible description of the view */\n\tcaption?: string\n\n\t/** Translated title of the empty view */\n\temptyTitle?: string\n\t/** Translated description of the empty view */\n\temptyCaption?: string\n\n\t/**\n\t * Method return the content of the provided path\n\t * This ideally should be a cancellable promise.\n\t * promise.cancel(reason) will be called when the directory\n\t * change and the promise is not resolved yet.\n\t * You _must_ also return the current directory\n\t * information alongside with its content.\n\t */\n\tgetContents: (path: string) => Promise<ContentsWithRoot>\n\t/** The view icon as an inline svg */\n\ticon: string\n\t/** The view order */\n\torder: number\n\n\t/**\n\t * Custom params to give to the router on click\n\t * If defined, will be treated as a dummy view and\n\t * will just redirect and not fetch any contents.\n\t */\n\tparams?: Record<string, string>\n\n\t/**\n\t * This view column(s). Name and actions are\n\t * by default always included\n\t */\n\tcolumns?: Column[]\n\t/** The empty view element to render your empty content into */\n\temptyView?: (div: HTMLDivElement) => void\n\t/** The parent unique ID */\n\tparent?: string\n\t/** This view is sticky (sent at the bottom) */\n\tsticky?: boolean\n\n\t/**\n\t * This view has children and is expanded (by default)\n\t * or not. This will be overridden by user config.\n\t */\n\texpanded?: boolean\n\n\t/**\n\t * Will be used as default if the user\n\t * haven't customized their sorting column\n\t */\n\tdefaultSortKey?: string\n}\n\nexport class View implements ViewData {\n\n\tprivate _view: ViewData\n\n\tconstructor(view: ViewData) {\n\t\tisValidView(view)\n\t\tthis._view = view\n\t}\n\n\tget id() {\n\t\treturn this._view.id\n\t}\n\n\tget name() {\n\t\treturn this._view.name\n\t}\n\n\tget caption() {\n\t\treturn this._view.caption\n\t}\n\n\tget emptyTitle() {\n\t\treturn this._view.emptyTitle\n\t}\n\n\tget emptyCaption() {\n\t\treturn this._view.emptyCaption\n\t}\n\n\tget getContents() {\n\t\treturn this._view.getContents\n\t}\n\n\tget icon() {\n\t\treturn this._view.icon\n\t}\n\n\tget order() {\n\t\treturn this._view.order\n\t}\n\n\tget params() {\n\t\treturn this._view.params\n\t}\n\n\tget columns() {\n\t\treturn this._view.columns\n\t}\n\n\tget emptyView() {\n\t\treturn this._view.emptyView\n\t}\n\n\tget parent() {\n\t\treturn this._view.parent\n\t}\n\n\tget sticky() {\n\t\treturn this._view.sticky\n\t}\n\n\tget expanded() {\n\t\treturn this._view.expanded\n\t}\n\n\tget defaultSortKey() {\n\t\treturn this._view.defaultSortKey\n\t}\n\n}\n\n/**\n * Typescript cannot validate an interface.\n * Please keep in sync with the View interface requirements.\n *\n * @param {ViewData} view the view to check\n * @return {boolean} true if the column is valid\n * @throws {Error} if the view is not valid\n */\nconst isValidView = function(view: ViewData): boolean {\n\tif (!view.id || typeof view.id !== 'string') {\n\t\tthrow new Error('View id is required and must be a string')\n\t}\n\n\tif (!view.name || typeof view.name !== 'string') {\n\t\tthrow new Error('View name is required and must be a string')\n\t}\n\n\tif (view.columns && view.columns.length > 0\n\t\t&& (!view.caption || typeof view.caption !== 'string')) {\n\t\tthrow new Error('View caption is required for top-level views and must be a string')\n\t}\n\n\tif (!view.getContents || typeof view.getContents !== 'function') {\n\t\tthrow new Error('View getContents is required and must be a function')\n\t}\n\n\tif (!view.icon || typeof view.icon !== 'string' || !isSvg(view.icon)) {\n\t\tthrow new Error('View icon is required and must be a valid svg string')\n\t}\n\n\tif (!('order' in view) || typeof view.order !== 'number') {\n\t\tthrow new Error('View order is required and must be a number')\n\t}\n\n\t// Optional properties\n\tif (view.columns) {\n\t\tview.columns.forEach((column) => {\n\t\t\tif (!(column instanceof Column)) {\n\t\t\t\tthrow new Error('View columns must be an array of Column. Invalid column found')\n\t\t\t}\n\t\t})\n\t}\n\n\tif (view.emptyView && typeof view.emptyView !== 'function') {\n\t\tthrow new Error('View emptyView must be a function')\n\t}\n\n\tif (view.parent && typeof view.parent !== 'string') {\n\t\tthrow new Error('View parent must be a string')\n\t}\n\n\tif ('sticky' in view && typeof view.sticky !== 'boolean') {\n\t\tthrow new Error('View sticky must be a boolean')\n\t}\n\n\tif ('expanded' in view && typeof view.expanded !== 'boolean') {\n\t\tthrow new Error('View expanded must be a boolean')\n\t}\n\n\tif (view.defaultSortKey && typeof view.defaultSortKey !== 'string') {\n\t\tthrow new Error('View defaultSortKey must be a string')\n\t}\n\n\treturn true\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, DefaultType } 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\nexport * from './navigation/navigation'\nexport * from './navigation/column'\nexport * from './navigation/view'\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","view","id","getNewFileMenu","humanList","humanListBinary","formatFileSize","size","skipSmallSizes","binaryPrefixes","order","readableFormat","relativeSize","getCanonicalLocale","DefaultType","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","davRemoteURL","generateRemoteUrl","davGetClient","davURL","client","createClient","getRequestToken","getPatcher","options","request","getFavoriteNodes","davClient","path","davRoot","node","result","davResultToNode","props","owner","nodeData","Navigation","index","getNavigation","Column","column","isValidColumn","View","isValidView","isSvg","addNewFileMenuEntry","removeNewFileMenuEntry","getNewFileMenuEntries"],"mappings":";;;;;;;;AAyBA,MAAMA,IAAoBC,OACrBA,MAAS,OACLC,EAAiB,EACtB,OAAO,OAAO,EAC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;"}
|
|
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/navigation/navigation.ts","../lib/navigation/column.ts","../lib/navigation/view.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 './files/folder'\nimport { View } from './navigation/view'\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, view: View) => 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?: (context: Folder, view: View) => 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\n\t * @param {View} view the current view\n\t */\n\tpublic getEntries(context?: Folder, view?: View): Array<Entry> {\n\t\tif (context && view) {\n\t\t\treturn this._entries\n\t\t\t\t.filter(entry => typeof entry.if === 'function' ? entry.if(context, view) : 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) 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 { Node } from './files/node'\nimport { View } from './navigation/view'\nimport logger from './utils/logger'\n\nexport enum DefaultType {\n\tDEFAULT = 'default',\n\tHIDDEN = 'hidden',\n}\n\ninterface FileActionData {\n\t/** Unique ID */\n\tid: string\n\t/** Translatable string displayed in the menu */\n\tdisplayName: (files: Node[], view: View) => string\n\t/** Svg as inline string. <svg><path fill=\"...\" /></svg> */\n\ticonSvgInline: (files: Node[], view: View) => string\n\t/** Condition wether this action is shown or not */\n\tenabled?: (files: Node[], view: 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: 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: View, dir: string) => Promise<(boolean|null)[]>\n\t/** This action order in the list */\n\torder?: number,\n\n\t/**\n\t * Make this action the default.\n\t * If multiple actions are default, the first one\n\t * will be used. The other ones will be put as first\n\t * entries in the actions menu iff DefaultType.Hidden is not used.\n\t * A DefaultType.Hidden action will never be shown\n\t * in the actions menu even if another action takes\n\t * its place as default.\n\t */\n\tdefault?: DefaultType,\n\t/**\n\t * If true, the renderInline function will be called\n\t */\n\tinline?: (file: Node, view: 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: View) => Promise<HTMLElement | null>,\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 (action.default && !Object.values(DefaultType).includes(action.default)) {\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 { View } from './navigation/view'\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: View) => boolean\n\t/** Executed when file list is initialized */\n\trender: (el: HTMLElement, folder: Folder, view: View) => void\n\t/** Executed when root folder changed */\n\tupdated(folder: Folder, view: 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 { 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\n/**\n * The DAV root path for the current user\n */\nexport const davRootPath = `/files/${getCurrentUser()?.uid}`\n\n/**\n * The DAV remote URL used as base URL for the WebDAV client\n */\nexport const davRemoteURL = generateRemoteUrl('dav')\n\n/**\n * Get a WebDAV client configured to include the Nextcloud request token\n *\n * @param davURL The DAV remote URL\n */\nexport const davGetClient = function(davURL = davRemoteURL) {\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 * @param davRoot The root path for the DAV user (defaults to `davRootPath`)\n * @example\n * ```js\n * import { davGetClient, davRootPath, getFavoriteNodes } from '@nextcloud/files'\n *\n * const client = davGetClient()\n * // query favorites for the root\n * const favorites = await getFavoriteNodes(client)\n * // which is the same as writing:\n * const favorites = await getFavoriteNodes(client, '/', davRootPath)\n * ```\n */\nexport const getFavoriteNodes = async (davClient: WebDAVClient, path = '/', davRoot = davRootPath) => {\n\tconst contentsResponse = await davClient.getDirectoryContents(`${davRoot}${path}`, {\n\t\tdetails: true,\n\t\tdata: davGetFavoritesReport(),\n\t\theaders: {\n\t\t\t// see davGetClient for patched webdav client\n\t\t\tmethod: 'REPORT',\n\t\t},\n\t\tincludeSelf: true,\n\t}) as ResponseDataDetailed<FileStat[]>\n\n\treturn contentsResponse.data\n\t\t.filter(node => node.filename !== path) // exclude current dir\n\t\t.map((result) => davResultToNode(result, davRoot))\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 || Number.parseInt(props.getcontentlength || '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 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 { View } from './view'\nimport logger from '../utils/logger'\n\nexport class Navigation {\n\n\tprivate _views: View[] = []\n\tprivate _currentView: View | null = null\n\n\tregister(view: View) {\n\t\tif (this._views.find(search => search.id === view.id)) {\n\t\t\tthrow new Error(`View id ${view.id} is already registered`)\n\t\t}\n\n\t\tthis._views.push(view)\n\t}\n\n\tremove(id: string) {\n\t\tconst index = this._views.findIndex(view => view.id === id)\n\t\tif (index !== -1) {\n\t\t\tthis._views.splice(index, 1)\n\t\t}\n\t}\n\n\tget views(): View[] {\n\t\treturn this._views\n\t}\n\n\tsetActive(view: View | null) {\n\t\tthis._currentView = view\n\t}\n\n\tget active(): View | null {\n\t\treturn this._currentView\n\t}\n\n}\n\nexport const getNavigation = function(): Navigation {\n\tif (typeof window._nc_navigation === 'undefined') {\n\t\twindow._nc_navigation = new Navigation()\n\t\tlogger.debug('Navigation service initialized')\n\t}\n\n\treturn window._nc_navigation\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 { View } from './view'\nimport { Node } from '../files/node'\n\ninterface ColumnData {\n\t/** Unique column ID */\n\tid: string\n\t/** Translated column title */\n\ttitle: string\n\t/** The content of the cell. The element will be appended within */\n\trender: (node: Node, view: View) => HTMLElement\n\t/** Function used to sort Nodes between them */\n\tsort?: (nodeA: Node, nodeB: Node) => number\n\t/**\n\t * Custom summary of the column to display at the end of the list.\n\t * Will not be displayed if nothing is provided\n\t */\n\tsummary?: (node: Node[], view: View) => string\n}\n\nexport class Column implements ColumnData {\n\n\tprivate _column: ColumnData\n\n\tconstructor(column: ColumnData) {\n\t\tisValidColumn(column)\n\t\tthis._column = column\n\t}\n\n\tget id() {\n\t\treturn this._column.id\n\t}\n\n\tget title() {\n\t\treturn this._column.title\n\t}\n\n\tget render() {\n\t\treturn this._column.render\n\t}\n\n\tget sort() {\n\t\treturn this._column.sort\n\t}\n\n\tget summary() {\n\t\treturn this._column.summary\n\t}\n\n}\n\n/**\n * Typescript cannot validate an interface.\n * Please keep in sync with the Column interface requirements.\n *\n * @param {ColumnData} column the column to check\n * @return {boolean} true if the column is valid\n */\nconst isValidColumn = function(column: ColumnData): boolean {\n\tif (!column.id || typeof column.id !== 'string') {\n\t\tthrow new Error('A column id is required')\n\t}\n\n\tif (!column.title || typeof column.title !== 'string') {\n\t\tthrow new Error('A column title is required')\n\t}\n\n\tif (!column.render || typeof column.render !== 'function') {\n\t\tthrow new Error('A render function is required')\n\t}\n\n\t// Optional properties\n\tif (column.sort && typeof column.sort !== 'function') {\n\t\tthrow new Error('Column sortFunction must be a function')\n\t}\n\n\tif (column.summary && typeof column.summary !== 'function') {\n\t\tthrow new Error('Column summary must be a function')\n\t}\n\n\treturn true\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/* eslint-disable no-use-before-define */\nimport type { Folder, Node } from '@nextcloud/files'\nimport isSvg from 'is-svg'\n\nimport { Column } from './column.js'\n\nexport type ContentsWithRoot = {\n\tfolder: Folder,\n\tcontents: Node[]\n}\n\ninterface ViewData {\n\t/** Unique view ID */\n\tid: string\n\t/** Translated view name */\n\tname: string\n\t/** Translated accessible description of the view */\n\tcaption?: string\n\n\t/** Translated title of the empty view */\n\temptyTitle?: string\n\t/** Translated description of the empty view */\n\temptyCaption?: string\n\n\t/**\n\t * Method return the content of the provided path\n\t * This ideally should be a cancellable promise.\n\t * promise.cancel(reason) will be called when the directory\n\t * change and the promise is not resolved yet.\n\t * You _must_ also return the current directory\n\t * information alongside with its content.\n\t */\n\tgetContents: (path: string) => Promise<ContentsWithRoot>\n\t/** The view icon as an inline svg */\n\ticon: string\n\t/** The view order */\n\torder: number\n\n\t/**\n\t * Custom params to give to the router on click\n\t * If defined, will be treated as a dummy view and\n\t * will just redirect and not fetch any contents.\n\t */\n\tparams?: Record<string, string>\n\n\t/**\n\t * This view column(s). Name and actions are\n\t * by default always included\n\t */\n\tcolumns?: Column[]\n\t/** The empty view element to render your empty content into */\n\temptyView?: (div: HTMLDivElement) => void\n\t/** The parent unique ID */\n\tparent?: string\n\t/** This view is sticky (sent at the bottom) */\n\tsticky?: boolean\n\n\t/**\n\t * This view has children and is expanded (by default)\n\t * or not. This will be overridden by user config.\n\t */\n\texpanded?: boolean\n\n\t/**\n\t * Will be used as default if the user\n\t * haven't customized their sorting column\n\t */\n\tdefaultSortKey?: string\n}\n\nexport class View implements ViewData {\n\n\tprivate _view: ViewData\n\n\tconstructor(view: ViewData) {\n\t\tisValidView(view)\n\t\tthis._view = view\n\t}\n\n\tget id() {\n\t\treturn this._view.id\n\t}\n\n\tget name() {\n\t\treturn this._view.name\n\t}\n\n\tget caption() {\n\t\treturn this._view.caption\n\t}\n\n\tget emptyTitle() {\n\t\treturn this._view.emptyTitle\n\t}\n\n\tget emptyCaption() {\n\t\treturn this._view.emptyCaption\n\t}\n\n\tget getContents() {\n\t\treturn this._view.getContents\n\t}\n\n\tget icon() {\n\t\treturn this._view.icon\n\t}\n\n\tset icon(icon) {\n\t\tthis._view.icon = icon\n\t}\n\n\tget order() {\n\t\treturn this._view.order\n\t}\n\n\tset order(order) {\n\t\tthis._view.order = order\n\t}\n\n\tget params() {\n\t\treturn this._view.params\n\t}\n\n\tset params(params) {\n\t\tthis._view.params = params\n\t}\n\n\tget columns() {\n\t\treturn this._view.columns\n\t}\n\n\tget emptyView() {\n\t\treturn this._view.emptyView\n\t}\n\n\tget parent() {\n\t\treturn this._view.parent\n\t}\n\n\tget sticky() {\n\t\treturn this._view.sticky\n\t}\n\n\tget expanded() {\n\t\treturn this._view.expanded\n\t}\n\n\tset expanded(expanded: boolean | undefined) {\n\t\tthis._view.expanded = expanded\n\t}\n\n\tget defaultSortKey() {\n\t\treturn this._view.defaultSortKey\n\t}\n\n}\n\n/**\n * Typescript cannot validate an interface.\n * Please keep in sync with the View interface requirements.\n *\n * @param {ViewData} view the view to check\n * @return {boolean} true if the column is valid\n * @throws {Error} if the view is not valid\n */\nconst isValidView = function(view: ViewData): boolean {\n\tif (!view.id || typeof view.id !== 'string') {\n\t\tthrow new Error('View id is required and must be a string')\n\t}\n\n\tif (!view.name || typeof view.name !== 'string') {\n\t\tthrow new Error('View name is required and must be a string')\n\t}\n\n\tif (view.columns && view.columns.length > 0\n\t\t&& (!view.caption || typeof view.caption !== 'string')) {\n\t\tthrow new Error('View caption is required for top-level views and must be a string')\n\t}\n\n\tif (!view.getContents || typeof view.getContents !== 'function') {\n\t\tthrow new Error('View getContents is required and must be a function')\n\t}\n\n\tif (!view.icon || typeof view.icon !== 'string' || !isSvg(view.icon)) {\n\t\tthrow new Error('View icon is required and must be a valid svg string')\n\t}\n\n\tif (!('order' in view) || typeof view.order !== 'number') {\n\t\tthrow new Error('View order is required and must be a number')\n\t}\n\n\t// Optional properties\n\tif (view.columns) {\n\t\tview.columns.forEach((column) => {\n\t\t\tif (!(column instanceof Column)) {\n\t\t\t\tthrow new Error('View columns must be an array of Column. Invalid column found')\n\t\t\t}\n\t\t})\n\t}\n\n\tif (view.emptyView && typeof view.emptyView !== 'function') {\n\t\tthrow new Error('View emptyView must be a function')\n\t}\n\n\tif (view.parent && typeof view.parent !== 'string') {\n\t\tthrow new Error('View parent must be a string')\n\t}\n\n\tif ('sticky' in view && typeof view.sticky !== 'boolean') {\n\t\tthrow new Error('View sticky must be a boolean')\n\t}\n\n\tif ('expanded' in view && typeof view.expanded !== 'boolean') {\n\t\tthrow new Error('View expanded must be a boolean')\n\t}\n\n\tif (view.defaultSortKey && typeof view.defaultSortKey !== 'string') {\n\t\tthrow new Error('View defaultSortKey must be a string')\n\t}\n\n\treturn true\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 { type Folder } from './files/folder'\nimport { type View } from './navigation/view'\n\nexport { formatFileSize } from './humanfilesize'\nexport { FileAction, getFileActions, registerFileAction, DefaultType } 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\nexport * from './navigation/navigation'\nexport * from './navigation/column'\nexport * from './navigation/view'\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 * @param {View} view the current view\n */\nexport const getNewFileMenuEntries = function(context?: Folder, view?: View) {\n\tconst newFileMenu = getNewFileMenu()\n\treturn newFileMenu.getEntries(context, view)\n}\n"],"names":["getLogger","user","getLoggerBuilder","logger","getCurrentUser","NewFileMenu","entry","entryIndex","context","view","id","getNewFileMenu","humanList","humanListBinary","formatFileSize","size","skipSmallSizes","binaryPrefixes","order","readableFormat","relativeSize","getCanonicalLocale","DefaultType","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","davRemoteURL","generateRemoteUrl","davGetClient","davURL","client","createClient","getRequestToken","getPatcher","options","request","getFavoriteNodes","davClient","path","davRoot","node","result","davResultToNode","props","owner","nodeData","Navigation","index","getNavigation","Column","column","isValidColumn","View","isValidView","icon","params","expanded","isSvg","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;ACYlC,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,IAGI;AAAA,SAAA,S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EAAmE;AAGpF,MAAI,CAACA,EAAK,eAAe,OAAOA,EAAK,eAAgB;AAC9C,UAAA,IAAI,MAAM,qDAAqD;AAGlE,MAAA,CAACA,EAAK,QAAQ,OAAOA,EAAK,QAAS,YAAY,CAAC4F,EAAM5F,EAAK,IAAI;AAC5D,UAAA,IAAI,MAAM,sDAAsD;AAGvE,MAAI,EAAE,WAAWA,MAAS,OAAOA,EAAK,SAAU;AACzC,UAAA,IAAI,MAAM,6CAA6C;AAY9D,MARIA,EAAK,WACHA,EAAA,QAAQ,QAASqF,OAAW;AAC5B,QAAA,EAAEA,aAAkBD;AACjB,YAAA,IAAI,MAAM,+DAA+D;AAAA,EAChF,CACA,GAGEpF,EAAK,aAAa,OAAOA,EAAK,aAAc;AACzC,UAAA,IAAI,MAAM,mCAAmC;AAGpD,MAAIA,EAAK,UAAU,OAAOA,EAAK,UAAW;AACnC,UAAA,IAAI,MAAM,8BAA8B;AAG/C,MAAI,YAAYA,KAAQ,OAAOA,EAAK,UAAW;AACxC,UAAA,IAAI,MAAM,+BAA+B;AAGhD,MAAI,cAAcA,KAAQ,OAAOA,EAAK,YAAa;AAC5C,UAAA,IAAI,MAAM,iCAAiC;AAGlD,MAAIA,EAAK,kBAAkB,OAAOA,EAAK,kBAAmB;AACnD,UAAA,IAAI,MAAM,sCAAsC;AAGhD,SAAA;AACR,GC/La6F,KAAsB,SAAShG,GAAc;AAElD,SADaK,IACD,cAAcL,CAAK;AACvC,GAOaiG,KAAyB,SAASjG,GAAuB;AAE9D,SADaK,IACD,gBAAgBL,CAAK;AACzC,GAQakG,KAAwB,SAAShG,GAAkBC,GAAa;AAErE,SADaE,IACD,WAAWH,GAASC,CAAI;AAC5C;"}
|
|
@@ -87,13 +87,17 @@ export declare class View implements ViewData {
|
|
|
87
87
|
get emptyCaption(): string | undefined;
|
|
88
88
|
get getContents(): (path: string) => Promise<ContentsWithRoot>;
|
|
89
89
|
get icon(): string;
|
|
90
|
+
set icon(icon: string);
|
|
90
91
|
get order(): number;
|
|
92
|
+
set order(order: number);
|
|
91
93
|
get params(): Record<string, string> | undefined;
|
|
94
|
+
set params(params: Record<string, string> | undefined);
|
|
92
95
|
get columns(): Column[] | undefined;
|
|
93
96
|
get emptyView(): ((div: HTMLDivElement) => void) | undefined;
|
|
94
97
|
get parent(): string | undefined;
|
|
95
98
|
get sticky(): boolean | undefined;
|
|
96
99
|
get expanded(): boolean | undefined;
|
|
100
|
+
set expanded(expanded: boolean | undefined);
|
|
97
101
|
get defaultSortKey(): string | undefined;
|
|
98
102
|
}
|
|
99
103
|
export {};
|
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.17",
|
|
4
4
|
"description": "Nextcloud files utils",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.cjs",
|
|
@@ -56,13 +56,13 @@
|
|
|
56
56
|
"@nextcloud/vite-config": "^1.0.0-beta.18",
|
|
57
57
|
"@rollup-extras/plugin-clean": "^1.3.6",
|
|
58
58
|
"@rollup/plugin-commonjs": "^25.0.4",
|
|
59
|
-
"@rollup/plugin-node-resolve": "^15.
|
|
59
|
+
"@rollup/plugin-node-resolve": "^15.2.0",
|
|
60
60
|
"@rollup/plugin-typescript": "^11.1.2",
|
|
61
|
-
"@types/node": "^20.
|
|
62
|
-
"@vitest/coverage-istanbul": "^0.34.
|
|
61
|
+
"@types/node": "^20.5.1",
|
|
62
|
+
"@vitest/coverage-istanbul": "^0.34.2",
|
|
63
63
|
"fast-xml-parser": "^4.2.7",
|
|
64
64
|
"rollup": "^3.28.0",
|
|
65
|
-
"tslib": "^2.6.
|
|
65
|
+
"tslib": "^2.6.2",
|
|
66
66
|
"typedoc": "^0.24.8",
|
|
67
67
|
"typescript": "^5.0.4",
|
|
68
68
|
"vite": "^4.4.9",
|