@nextcloud/files 3.9.2 → 3.10.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,710 @@
1
+ import { join, basename, extname, dirname } from "path";
2
+ import { encodePath } from "@nextcloud/paths";
3
+ import { getLoggerBuilder } from "@nextcloud/logger";
4
+ import { getCurrentUser, onRequestTokenUpdate, getRequestToken } from "@nextcloud/auth";
5
+ import { generateRemoteUrl } from "@nextcloud/router";
6
+ import { CancelablePromise } from "cancelable-promise";
7
+ import { createClient, getPatcher } from "webdav";
8
+ import { isPublicShare, getSharingToken } from "@nextcloud/sharing/public";
9
+ const logger = getLoggerBuilder().setApp("@nextcloud/files").detectUser().build();
10
+ var Permission = /* @__PURE__ */ ((Permission2) => {
11
+ Permission2[Permission2["NONE"] = 0] = "NONE";
12
+ Permission2[Permission2["CREATE"] = 4] = "CREATE";
13
+ Permission2[Permission2["READ"] = 1] = "READ";
14
+ Permission2[Permission2["UPDATE"] = 2] = "UPDATE";
15
+ Permission2[Permission2["DELETE"] = 8] = "DELETE";
16
+ Permission2[Permission2["SHARE"] = 16] = "SHARE";
17
+ Permission2[Permission2["ALL"] = 31] = "ALL";
18
+ return Permission2;
19
+ })(Permission || {});
20
+ var FileType = /* @__PURE__ */ ((FileType2) => {
21
+ FileType2["Folder"] = "folder";
22
+ FileType2["File"] = "file";
23
+ return FileType2;
24
+ })(FileType || {});
25
+ const isDavResource = function(source, davService) {
26
+ return source.match(davService) !== null;
27
+ };
28
+ const validateData = (data, davService) => {
29
+ if (data.id && typeof data.id !== "number") {
30
+ throw new Error("Invalid id type of value");
31
+ }
32
+ if (!data.source) {
33
+ throw new Error("Missing mandatory source");
34
+ }
35
+ try {
36
+ new URL(data.source);
37
+ } catch (e) {
38
+ throw new Error("Invalid source format, source must be a valid URL");
39
+ }
40
+ if (!data.source.startsWith("http")) {
41
+ throw new Error("Invalid source format, only http(s) is supported");
42
+ }
43
+ if (data.displayname && typeof data.displayname !== "string") {
44
+ throw new Error("Invalid displayname type");
45
+ }
46
+ if (data.mtime && !(data.mtime instanceof Date)) {
47
+ throw new Error("Invalid mtime type");
48
+ }
49
+ if (data.crtime && !(data.crtime instanceof Date)) {
50
+ throw new Error("Invalid crtime type");
51
+ }
52
+ if (!data.mime || typeof data.mime !== "string" || !data.mime.match(/^[-\w.]+\/[-+\w.]+$/gi)) {
53
+ throw new Error("Missing or invalid mandatory mime");
54
+ }
55
+ if ("size" in data && typeof data.size !== "number" && data.size !== void 0) {
56
+ throw new Error("Invalid size type");
57
+ }
58
+ if ("permissions" in data && data.permissions !== void 0 && !(typeof data.permissions === "number" && data.permissions >= Permission.NONE && data.permissions <= Permission.ALL)) {
59
+ throw new Error("Invalid permissions");
60
+ }
61
+ if (data.owner && data.owner !== null && typeof data.owner !== "string") {
62
+ throw new Error("Invalid owner type");
63
+ }
64
+ if (data.attributes && typeof data.attributes !== "object") {
65
+ throw new Error("Invalid attributes type");
66
+ }
67
+ if (data.root && typeof data.root !== "string") {
68
+ throw new Error("Invalid root type");
69
+ }
70
+ if (data.root && !data.root.startsWith("/")) {
71
+ throw new Error("Root must start with a leading slash");
72
+ }
73
+ if (data.root && !data.source.includes(data.root)) {
74
+ throw new Error("Root must be part of the source");
75
+ }
76
+ if (data.root && isDavResource(data.source, davService)) {
77
+ const service = data.source.match(davService)[0];
78
+ if (!data.source.includes(join(service, data.root))) {
79
+ throw new Error("The root must be relative to the service. e.g /files/emma");
80
+ }
81
+ }
82
+ if (data.status && !Object.values(NodeStatus).includes(data.status)) {
83
+ throw new Error("Status must be a valid NodeStatus");
84
+ }
85
+ };
86
+ var NodeStatus = /* @__PURE__ */ ((NodeStatus2) => {
87
+ NodeStatus2["NEW"] = "new";
88
+ NodeStatus2["FAILED"] = "failed";
89
+ NodeStatus2["LOADING"] = "loading";
90
+ NodeStatus2["LOCKED"] = "locked";
91
+ return NodeStatus2;
92
+ })(NodeStatus || {});
93
+ class Node {
94
+ _data;
95
+ _attributes;
96
+ _knownDavService = /(remote|public)\.php\/(web)?dav/i;
97
+ readonlyAttributes = Object.entries(Object.getOwnPropertyDescriptors(Node.prototype)).filter((e) => typeof e[1].get === "function" && e[0] !== "__proto__").map((e) => e[0]);
98
+ handler = {
99
+ set: (target, prop, value) => {
100
+ if (this.readonlyAttributes.includes(prop)) {
101
+ return false;
102
+ }
103
+ return Reflect.set(target, prop, value);
104
+ },
105
+ deleteProperty: (target, prop) => {
106
+ if (this.readonlyAttributes.includes(prop)) {
107
+ return false;
108
+ }
109
+ return Reflect.deleteProperty(target, prop);
110
+ },
111
+ // TODO: This is deprecated and only needed for files v3
112
+ get: (target, prop, receiver) => {
113
+ if (this.readonlyAttributes.includes(prop)) {
114
+ logger.warn(`Accessing "Node.attributes.${prop}" is deprecated, access it directly on the Node instance.`);
115
+ return Reflect.get(this, prop);
116
+ }
117
+ return Reflect.get(target, prop, receiver);
118
+ }
119
+ };
120
+ constructor(data, davService) {
121
+ validateData(data, davService || this._knownDavService);
122
+ this._data = {
123
+ // TODO: Remove with next major release, this is just for compatibility
124
+ displayname: data.attributes?.displayname,
125
+ ...data,
126
+ attributes: {}
127
+ };
128
+ this._attributes = new Proxy(this._data.attributes, this.handler);
129
+ this.update(data.attributes ?? {});
130
+ if (davService) {
131
+ this._knownDavService = davService;
132
+ }
133
+ }
134
+ /**
135
+ * Get the source url to this object
136
+ * There is no setter as the source is not meant to be changed manually.
137
+ * You can use the rename or move method to change the source.
138
+ */
139
+ get source() {
140
+ return this._data.source.replace(/\/$/i, "");
141
+ }
142
+ /**
143
+ * Get the encoded source url to this object for requests purposes
144
+ */
145
+ get encodedSource() {
146
+ const { origin } = new URL(this.source);
147
+ return origin + encodePath(this.source.slice(origin.length));
148
+ }
149
+ /**
150
+ * Get this object name
151
+ * There is no setter as the source is not meant to be changed manually.
152
+ * You can use the rename or move method to change the source.
153
+ */
154
+ get basename() {
155
+ return basename(this.source);
156
+ }
157
+ /**
158
+ * The nodes displayname
159
+ * By default the display name and the `basename` are identical,
160
+ * but it is possible to have a different name. This happens
161
+ * on the files app for example for shared folders.
162
+ */
163
+ get displayname() {
164
+ return this._data.displayname || this.basename;
165
+ }
166
+ /**
167
+ * Set the displayname
168
+ */
169
+ set displayname(displayname) {
170
+ this._data.displayname = displayname;
171
+ }
172
+ /**
173
+ * Get this object's extension
174
+ * There is no setter as the source is not meant to be changed manually.
175
+ * You can use the rename or move method to change the source.
176
+ */
177
+ get extension() {
178
+ return extname(this.source);
179
+ }
180
+ /**
181
+ * Get the directory path leading to this object
182
+ * Will use the relative path to root if available
183
+ *
184
+ * There is no setter as the source is not meant to be changed manually.
185
+ * You can use the rename or move method to change the source.
186
+ */
187
+ get dirname() {
188
+ if (this.root) {
189
+ let source = this.source;
190
+ if (this.isDavResource) {
191
+ source = source.split(this._knownDavService).pop();
192
+ }
193
+ const firstMatch = source.indexOf(this.root);
194
+ const root = this.root.replace(/\/$/, "");
195
+ return dirname(source.slice(firstMatch + root.length) || "/");
196
+ }
197
+ const url = new URL(this.source);
198
+ return dirname(url.pathname);
199
+ }
200
+ /**
201
+ * Get the file mime
202
+ * There is no setter as the mime is not meant to be changed
203
+ */
204
+ get mime() {
205
+ return this._data.mime;
206
+ }
207
+ /**
208
+ * Get the file modification time
209
+ */
210
+ get mtime() {
211
+ return this._data.mtime;
212
+ }
213
+ /**
214
+ * Set the file modification time
215
+ */
216
+ set mtime(mtime) {
217
+ this._data.mtime = mtime;
218
+ }
219
+ /**
220
+ * Get the file creation time
221
+ * There is no setter as the creation time is not meant to be changed
222
+ */
223
+ get crtime() {
224
+ return this._data.crtime;
225
+ }
226
+ /**
227
+ * Get the file size
228
+ */
229
+ get size() {
230
+ return this._data.size;
231
+ }
232
+ /**
233
+ * Set the file size
234
+ */
235
+ set size(size) {
236
+ this.updateMtime();
237
+ this._data.size = size;
238
+ }
239
+ /**
240
+ * Get the file attribute
241
+ * This contains all additional attributes not provided by the Node class
242
+ */
243
+ get attributes() {
244
+ return this._attributes;
245
+ }
246
+ /**
247
+ * Get the file permissions
248
+ */
249
+ get permissions() {
250
+ if (this.owner === null && !this.isDavResource) {
251
+ return Permission.READ;
252
+ }
253
+ return this._data.permissions !== void 0 ? this._data.permissions : Permission.NONE;
254
+ }
255
+ /**
256
+ * Set the file permissions
257
+ */
258
+ set permissions(permissions) {
259
+ this.updateMtime();
260
+ this._data.permissions = permissions;
261
+ }
262
+ /**
263
+ * Get the file owner
264
+ * There is no setter as the owner is not meant to be changed
265
+ */
266
+ get owner() {
267
+ if (!this.isDavResource) {
268
+ return null;
269
+ }
270
+ return this._data.owner;
271
+ }
272
+ /**
273
+ * Is this a dav-related resource ?
274
+ */
275
+ get isDavResource() {
276
+ return isDavResource(this.source, this._knownDavService);
277
+ }
278
+ /**
279
+ * @deprecated use `isDavResource` instead - will be removed in next major version.
280
+ */
281
+ get isDavRessource() {
282
+ return this.isDavResource;
283
+ }
284
+ /**
285
+ * Get the dav root of this object
286
+ * There is no setter as the root is not meant to be changed
287
+ */
288
+ get root() {
289
+ if (this._data.root) {
290
+ return this._data.root.replace(/^(.+)\/$/, "$1");
291
+ }
292
+ if (this.isDavResource) {
293
+ const root = dirname(this.source);
294
+ return root.split(this._knownDavService).pop() || null;
295
+ }
296
+ return null;
297
+ }
298
+ /**
299
+ * Get the absolute path of this object relative to the root
300
+ */
301
+ get path() {
302
+ if (this.root) {
303
+ let source = this.source;
304
+ if (this.isDavResource) {
305
+ source = source.split(this._knownDavService).pop();
306
+ }
307
+ const firstMatch = source.indexOf(this.root);
308
+ const root = this.root.replace(/\/$/, "");
309
+ return source.slice(firstMatch + root.length) || "/";
310
+ }
311
+ return (this.dirname + "/" + this.basename).replace(/\/\//g, "/");
312
+ }
313
+ /**
314
+ * Get the node id if defined.
315
+ * There is no setter as the fileid is not meant to be changed
316
+ */
317
+ get fileid() {
318
+ return this._data?.id;
319
+ }
320
+ /**
321
+ * Get the node status.
322
+ */
323
+ get status() {
324
+ return this._data?.status;
325
+ }
326
+ /**
327
+ * Set the node status.
328
+ */
329
+ set status(status) {
330
+ this._data.status = status;
331
+ }
332
+ /**
333
+ * Get the node data
334
+ */
335
+ get data() {
336
+ return structuredClone(this._data);
337
+ }
338
+ /**
339
+ * Move the node to a new destination
340
+ *
341
+ * @param {string} destination the new source.
342
+ * e.g. https://cloud.domain.com/remote.php/dav/files/emma/Photos/picture.jpg
343
+ */
344
+ move(destination) {
345
+ validateData({ ...this._data, source: destination }, this._knownDavService);
346
+ const oldBasename = this.basename;
347
+ this._data.source = destination;
348
+ if (this.displayname === oldBasename && this.basename !== oldBasename) {
349
+ this.displayname = this.basename;
350
+ }
351
+ this.updateMtime();
352
+ }
353
+ /**
354
+ * Rename the node
355
+ * This aliases the move method for easier usage
356
+ *
357
+ * @param basename The new name of the node
358
+ */
359
+ rename(basename2) {
360
+ if (basename2.includes("/")) {
361
+ throw new Error("Invalid basename");
362
+ }
363
+ this.move(dirname(this.source) + "/" + basename2);
364
+ }
365
+ /**
366
+ * Update the mtime if exists
367
+ */
368
+ updateMtime() {
369
+ if (this._data.mtime) {
370
+ this._data.mtime = /* @__PURE__ */ new Date();
371
+ }
372
+ }
373
+ /**
374
+ * Update the attributes of the node
375
+ * Warning, updating attributes will NOT automatically update the mtime.
376
+ *
377
+ * @param attributes The new attributes to update on the Node attributes
378
+ */
379
+ update(attributes) {
380
+ for (const [name, value] of Object.entries(attributes)) {
381
+ try {
382
+ if (value === void 0) {
383
+ delete this.attributes[name];
384
+ } else {
385
+ this.attributes[name] = value;
386
+ }
387
+ } catch (e) {
388
+ if (e instanceof TypeError) {
389
+ continue;
390
+ }
391
+ throw e;
392
+ }
393
+ }
394
+ }
395
+ }
396
+ class File extends Node {
397
+ get type() {
398
+ return FileType.File;
399
+ }
400
+ /**
401
+ * Returns a clone of the file
402
+ */
403
+ clone() {
404
+ return new File(this.data);
405
+ }
406
+ }
407
+ class Folder extends Node {
408
+ constructor(data) {
409
+ super({
410
+ ...data,
411
+ mime: "httpd/unix-directory"
412
+ });
413
+ }
414
+ get type() {
415
+ return FileType.Folder;
416
+ }
417
+ get extension() {
418
+ return null;
419
+ }
420
+ get mime() {
421
+ return "httpd/unix-directory";
422
+ }
423
+ /**
424
+ * Returns a clone of the folder
425
+ */
426
+ clone() {
427
+ return new Folder(this.data);
428
+ }
429
+ }
430
+ const parsePermissions = function(permString = "") {
431
+ let permissions = Permission.NONE;
432
+ if (!permString) {
433
+ return permissions;
434
+ }
435
+ if (permString.includes("C") || permString.includes("K")) {
436
+ permissions |= Permission.CREATE;
437
+ }
438
+ if (permString.includes("G")) {
439
+ permissions |= Permission.READ;
440
+ }
441
+ if (permString.includes("W") || permString.includes("N") || permString.includes("V")) {
442
+ permissions |= Permission.UPDATE;
443
+ }
444
+ if (permString.includes("D")) {
445
+ permissions |= Permission.DELETE;
446
+ }
447
+ if (permString.includes("R")) {
448
+ permissions |= Permission.SHARE;
449
+ }
450
+ return permissions;
451
+ };
452
+ const defaultDavProperties = [
453
+ "d:getcontentlength",
454
+ "d:getcontenttype",
455
+ "d:getetag",
456
+ "d:getlastmodified",
457
+ "d:creationdate",
458
+ "d:displayname",
459
+ "d:quota-available-bytes",
460
+ "d:resourcetype",
461
+ "nc:has-preview",
462
+ "nc:is-encrypted",
463
+ "nc:mount-type",
464
+ "oc:comments-unread",
465
+ "oc:favorite",
466
+ "oc:fileid",
467
+ "oc:owner-display-name",
468
+ "oc:owner-id",
469
+ "oc:permissions",
470
+ "oc:size"
471
+ ];
472
+ const defaultDavNamespaces = {
473
+ d: "DAV:",
474
+ nc: "http://nextcloud.org/ns",
475
+ oc: "http://owncloud.org/ns",
476
+ ocs: "http://open-collaboration-services.org/ns"
477
+ };
478
+ const registerDavProperty = function(prop, namespace = { nc: "http://nextcloud.org/ns" }) {
479
+ if (typeof window._nc_dav_properties === "undefined") {
480
+ window._nc_dav_properties = [...defaultDavProperties];
481
+ window._nc_dav_namespaces = { ...defaultDavNamespaces };
482
+ }
483
+ const namespaces = { ...window._nc_dav_namespaces, ...namespace };
484
+ if (window._nc_dav_properties.find((search) => search === prop)) {
485
+ logger.warn(`${prop} already registered`, { prop });
486
+ return false;
487
+ }
488
+ if (prop.startsWith("<") || prop.split(":").length !== 2) {
489
+ logger.error(`${prop} is not valid. See example: 'oc:fileid'`, { prop });
490
+ return false;
491
+ }
492
+ const ns = prop.split(":")[0];
493
+ if (!namespaces[ns]) {
494
+ logger.error(`${prop} namespace unknown`, { prop, namespaces });
495
+ return false;
496
+ }
497
+ window._nc_dav_properties.push(prop);
498
+ window._nc_dav_namespaces = namespaces;
499
+ return true;
500
+ };
501
+ const getDavProperties = function() {
502
+ if (typeof window._nc_dav_properties === "undefined") {
503
+ window._nc_dav_properties = [...defaultDavProperties];
504
+ }
505
+ return window._nc_dav_properties.map((prop) => `<${prop} />`).join(" ");
506
+ };
507
+ const getDavNameSpaces = function() {
508
+ if (typeof window._nc_dav_namespaces === "undefined") {
509
+ window._nc_dav_namespaces = { ...defaultDavNamespaces };
510
+ }
511
+ return Object.keys(window._nc_dav_namespaces).map((ns) => `xmlns:${ns}="${window._nc_dav_namespaces?.[ns]}"`).join(" ");
512
+ };
513
+ const getDefaultPropfind = function() {
514
+ return `<?xml version="1.0"?>
515
+ <d:propfind ${getDavNameSpaces()}>
516
+ <d:prop>
517
+ ${getDavProperties()}
518
+ </d:prop>
519
+ </d:propfind>`;
520
+ };
521
+ const getFavoritesReport = function() {
522
+ return `<?xml version="1.0"?>
523
+ <oc:filter-files ${getDavNameSpaces()}>
524
+ <d:prop>
525
+ ${getDavProperties()}
526
+ </d:prop>
527
+ <oc:filter-rules>
528
+ <oc:favorite>1</oc:favorite>
529
+ </oc:filter-rules>
530
+ </oc:filter-files>`;
531
+ };
532
+ const getRecentSearch = function(lastModified) {
533
+ return `<?xml version="1.0" encoding="UTF-8"?>
534
+ <d:searchrequest ${getDavNameSpaces()}
535
+ xmlns:ns="https://github.com/icewind1991/SearchDAV/ns">
536
+ <d:basicsearch>
537
+ <d:select>
538
+ <d:prop>
539
+ ${getDavProperties()}
540
+ </d:prop>
541
+ </d:select>
542
+ <d:from>
543
+ <d:scope>
544
+ <d:href>/files/${getCurrentUser()?.uid}/</d:href>
545
+ <d:depth>infinity</d:depth>
546
+ </d:scope>
547
+ </d:from>
548
+ <d:where>
549
+ <d:and>
550
+ <d:or>
551
+ <d:not>
552
+ <d:eq>
553
+ <d:prop>
554
+ <d:getcontenttype/>
555
+ </d:prop>
556
+ <d:literal>httpd/unix-directory</d:literal>
557
+ </d:eq>
558
+ </d:not>
559
+ <d:eq>
560
+ <d:prop>
561
+ <oc:size/>
562
+ </d:prop>
563
+ <d:literal>0</d:literal>
564
+ </d:eq>
565
+ </d:or>
566
+ <d:gt>
567
+ <d:prop>
568
+ <d:getlastmodified/>
569
+ </d:prop>
570
+ <d:literal>${lastModified}</d:literal>
571
+ </d:gt>
572
+ </d:and>
573
+ </d:where>
574
+ <d:orderby>
575
+ <d:order>
576
+ <d:prop>
577
+ <d:getlastmodified/>
578
+ </d:prop>
579
+ <d:descending/>
580
+ </d:order>
581
+ </d:orderby>
582
+ <d:limit>
583
+ <d:nresults>100</d:nresults>
584
+ <ns:firstresult>0</ns:firstresult>
585
+ </d:limit>
586
+ </d:basicsearch>
587
+ </d:searchrequest>`;
588
+ };
589
+ function getRootPath() {
590
+ if (isPublicShare()) {
591
+ return `/files/${getSharingToken()}`;
592
+ }
593
+ return `/files/${getCurrentUser()?.uid}`;
594
+ }
595
+ const defaultRootPath = getRootPath();
596
+ function getRemoteURL() {
597
+ const url = generateRemoteUrl("dav");
598
+ if (isPublicShare()) {
599
+ return url.replace("remote.php", "public.php");
600
+ }
601
+ return url;
602
+ }
603
+ const defaultRemoteURL = getRemoteURL();
604
+ const getClient = function(remoteURL = defaultRemoteURL, headers = {}) {
605
+ const client = createClient(remoteURL, { headers });
606
+ function setHeaders(token) {
607
+ client.setHeaders({
608
+ ...headers,
609
+ // Add this so the server knows it is an request from the browser
610
+ "X-Requested-With": "XMLHttpRequest",
611
+ // Inject user auth
612
+ requesttoken: token ?? ""
613
+ });
614
+ }
615
+ onRequestTokenUpdate(setHeaders);
616
+ setHeaders(getRequestToken());
617
+ const patcher = getPatcher();
618
+ patcher.patch("fetch", (url, options) => {
619
+ const headers2 = options.headers;
620
+ if (headers2?.method) {
621
+ options.method = headers2.method;
622
+ delete headers2.method;
623
+ }
624
+ return fetch(url, options);
625
+ });
626
+ return client;
627
+ };
628
+ const getFavoriteNodes = (davClient, path = "/", davRoot = defaultRootPath) => {
629
+ const controller = new AbortController();
630
+ return new CancelablePromise(async (resolve, reject, onCancel) => {
631
+ onCancel(() => controller.abort());
632
+ try {
633
+ const contentsResponse = await davClient.getDirectoryContents(`${davRoot}${path}`, {
634
+ signal: controller.signal,
635
+ details: true,
636
+ data: getFavoritesReport(),
637
+ headers: {
638
+ // see getClient for patched webdav client
639
+ method: "REPORT"
640
+ },
641
+ includeSelf: true
642
+ });
643
+ const nodes = contentsResponse.data.filter((node) => node.filename !== path).map((result) => resultToNode(result, davRoot));
644
+ resolve(nodes);
645
+ } catch (error) {
646
+ reject(error);
647
+ }
648
+ });
649
+ };
650
+ const resultToNode = function(node, filesRoot = defaultRootPath, remoteURL = defaultRemoteURL) {
651
+ let userId = getCurrentUser()?.uid;
652
+ if (isPublicShare()) {
653
+ userId = userId ?? "anonymous";
654
+ } else if (!userId) {
655
+ throw new Error("No user id found");
656
+ }
657
+ const props = node.props;
658
+ const permissions = parsePermissions(props?.permissions);
659
+ const owner = String(props?.["owner-id"] || userId);
660
+ const id = props.fileid || 0;
661
+ const mtime = new Date(Date.parse(node.lastmod));
662
+ const crtime = new Date(Date.parse(props.creationdate));
663
+ const nodeData = {
664
+ id,
665
+ source: `${remoteURL}${node.filename}`,
666
+ mtime: !isNaN(mtime.getTime()) && mtime.getTime() !== 0 ? mtime : void 0,
667
+ crtime: !isNaN(crtime.getTime()) && crtime.getTime() !== 0 ? crtime : void 0,
668
+ mime: node.mime || "application/octet-stream",
669
+ // Manually cast to work around for https://github.com/perry-mitchell/webdav-client/pull/380
670
+ displayname: props.displayname !== void 0 ? String(props.displayname) : void 0,
671
+ size: props?.size || Number.parseInt(props.getcontentlength || "0"),
672
+ // The fileid is set to -1 for failed requests
673
+ status: id < 0 ? NodeStatus.FAILED : void 0,
674
+ permissions,
675
+ owner,
676
+ root: filesRoot,
677
+ attributes: {
678
+ ...node,
679
+ ...props,
680
+ hasPreview: props?.["has-preview"]
681
+ }
682
+ };
683
+ delete nodeData.attributes?.props;
684
+ return node.type === "file" ? new File(nodeData) : new Folder(nodeData);
685
+ };
686
+ export {
687
+ FileType as F,
688
+ Node as N,
689
+ Permission as P,
690
+ getRemoteURL as a,
691
+ defaultRemoteURL as b,
692
+ getClient as c,
693
+ defaultRootPath as d,
694
+ getFavoriteNodes as e,
695
+ defaultDavProperties as f,
696
+ getRootPath as g,
697
+ defaultDavNamespaces as h,
698
+ registerDavProperty as i,
699
+ getDavProperties as j,
700
+ getDavNameSpaces as k,
701
+ getDefaultPropfind as l,
702
+ getFavoritesReport as m,
703
+ getRecentSearch as n,
704
+ logger as o,
705
+ parsePermissions as p,
706
+ File as q,
707
+ resultToNode as r,
708
+ Folder as s,
709
+ NodeStatus as t
710
+ };