33 * SPDX-License-Identifier: AGPL-3.0-or-later
44 */
55
6+ import type { TFileType } from './fileType.ts'
7+
68import { basename , dirname , encodePath , extname } from '@nextcloud/paths'
79import { Permission } from '../permissions'
8- import { FileType } from './fileType'
910import { Attribute , fixDates , fixRegExp , isDavResource , NodeData , validateData } from './nodeData'
1011
11- export enum NodeStatus {
12+ export const NodeStatus = Object . freeze ( {
1213 /** This is a new node and it doesn't exists on the filesystem yet */
13- NEW = 'new' ,
14+ NEW : 'new' ,
1415 /** This node has failed and is unavailable */
15- FAILED = 'failed' ,
16+ FAILED : 'failed' ,
1617 /** This node is currently loading or have an operation in progress */
17- LOADING = 'loading' ,
18+ LOADING : 'loading' ,
1819 /** This node is locked and cannot be modified */
19- LOCKED = 'locked' ,
20- }
20+ LOCKED : 'locked' ,
21+ } )
22+
23+ export type TNodeStatus = typeof NodeStatus [ keyof typeof NodeStatus ]
2124
2225export type NodeConstructorData = [ NodeData , RegExp ?]
2326
@@ -147,7 +150,7 @@ export abstract class Node {
147150 /**
148151 * Is it a file or a folder ?
149152 */
150- abstract get type ( ) : FileType
153+ abstract get type ( ) : TFileType
151154
152155 /**
153156 * Get the file mime
@@ -217,7 +220,7 @@ export abstract class Node {
217220 /**
218221 * Get the file permissions
219222 */
220- get permissions ( ) : Permission {
223+ get permissions ( ) : number {
221224 // If this is not a dav resource, we can only read it
222225 if ( this . owner === null && ! this . isDavResource ) {
223226 return Permission . READ
@@ -232,7 +235,7 @@ export abstract class Node {
232235 /**
233236 * Set the file permissions
234237 */
235- set permissions ( permissions : Permission ) {
238+ set permissions ( permissions : number ) {
236239 validateData ( { ...this . _data , permissions } , this . _knownDavService )
237240 this . updateMtime ( )
238241 this . _data . permissions = permissions
@@ -307,14 +310,14 @@ export abstract class Node {
307310 /**
308311 * Get the node status.
309312 */
310- get status ( ) : NodeStatus | undefined {
313+ get status ( ) : TNodeStatus | undefined {
311314 return this . _data ?. status
312315 }
313316
314317 /**
315318 * Set the node status.
316319 */
317- set status ( status : NodeStatus | undefined ) {
320+ set status ( status : TNodeStatus | undefined ) {
318321 validateData ( { ...this . _data , status } , this . _knownDavService )
319322 this . _data . status = status
320323 }
0 commit comments