@nextcloud/files 3.0.0-beta.4 → 3.0.0-beta.5
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/files/file.d.ts +26 -0
- package/dist/files/fileType.d.ts +25 -0
- package/dist/files/folder.d.ts +30 -0
- package/dist/files/node.d.ts +69 -0
- package/dist/files/nodeData.d.ts +51 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.esm.js +324 -1
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +388 -0
- package/dist/index.js.map +1 -1
- package/dist/permissions.d.ts +30 -0
- package/package.json +1 -1
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @copyright Copyright (c) 2022 John Molakvoæ <skjnldsv@protonmail.com>
|
|
3
|
+
*
|
|
4
|
+
* @author John Molakvoæ <skjnldsv@protonmail.com>
|
|
5
|
+
*
|
|
6
|
+
* @license AGPL-3.0-or-later
|
|
7
|
+
*
|
|
8
|
+
* This program is free software: you can redistribute it and/or modify
|
|
9
|
+
* it under the terms of the GNU Affero General Public License as
|
|
10
|
+
* published by the Free Software Foundation, either version 3 of the
|
|
11
|
+
* License, or (at your option) any later version.
|
|
12
|
+
*
|
|
13
|
+
* This program is distributed in the hope that it will be useful,
|
|
14
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
15
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
16
|
+
* GNU Affero General Public License for more details.
|
|
17
|
+
*
|
|
18
|
+
* You should have received a copy of the GNU Affero General Public License
|
|
19
|
+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
20
|
+
*
|
|
21
|
+
*/
|
|
22
|
+
import { FileType } from './fileType';
|
|
23
|
+
import Node from './node';
|
|
24
|
+
export declare class File extends Node {
|
|
25
|
+
get type(): FileType;
|
|
26
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @copyright Copyright (c) 2022 John Molakvoæ <skjnldsv@protonmail.com>
|
|
3
|
+
*
|
|
4
|
+
* @author John Molakvoæ <skjnldsv@protonmail.com>
|
|
5
|
+
*
|
|
6
|
+
* @license AGPL-3.0-or-later
|
|
7
|
+
*
|
|
8
|
+
* This program is free software: you can redistribute it and/or modify
|
|
9
|
+
* it under the terms of the GNU Affero General Public License as
|
|
10
|
+
* published by the Free Software Foundation, either version 3 of the
|
|
11
|
+
* License, or (at your option) any later version.
|
|
12
|
+
*
|
|
13
|
+
* This program is distributed in the hope that it will be useful,
|
|
14
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
15
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
16
|
+
* GNU Affero General Public License for more details.
|
|
17
|
+
*
|
|
18
|
+
* You should have received a copy of the GNU Affero General Public License
|
|
19
|
+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
20
|
+
*
|
|
21
|
+
*/
|
|
22
|
+
export declare enum FileType {
|
|
23
|
+
Folder = "folder",
|
|
24
|
+
File = "file"
|
|
25
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @copyright Copyright (c) 2022 John Molakvoæ <skjnldsv@protonmail.com>
|
|
3
|
+
*
|
|
4
|
+
* @author John Molakvoæ <skjnldsv@protonmail.com>
|
|
5
|
+
*
|
|
6
|
+
* @license AGPL-3.0-or-later
|
|
7
|
+
*
|
|
8
|
+
* This program is free software: you can redistribute it and/or modify
|
|
9
|
+
* it under the terms of the GNU Affero General Public License as
|
|
10
|
+
* published by the Free Software Foundation, either version 3 of the
|
|
11
|
+
* License, or (at your option) any later version.
|
|
12
|
+
*
|
|
13
|
+
* This program is distributed in the hope that it will be useful,
|
|
14
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
15
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
16
|
+
* GNU Affero General Public License for more details.
|
|
17
|
+
*
|
|
18
|
+
* You should have received a copy of the GNU Affero General Public License
|
|
19
|
+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
20
|
+
*
|
|
21
|
+
*/
|
|
22
|
+
import { FileType } from './fileType';
|
|
23
|
+
import Node from './node';
|
|
24
|
+
import NodeData from './nodeData';
|
|
25
|
+
export declare class Folder extends Node {
|
|
26
|
+
constructor(data: NodeData);
|
|
27
|
+
get type(): FileType;
|
|
28
|
+
get extension(): string | null;
|
|
29
|
+
get mime(): string;
|
|
30
|
+
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { Permission } from '../permissions';
|
|
2
|
+
import { FileType } from './fileType';
|
|
3
|
+
import NodeData, { Attribute } from './nodeData';
|
|
4
|
+
export default abstract class Node {
|
|
5
|
+
private _data;
|
|
6
|
+
private _attributes;
|
|
7
|
+
private _knownDavService;
|
|
8
|
+
constructor(data: NodeData, davService?: RegExp);
|
|
9
|
+
/**
|
|
10
|
+
* Get the source url to this object
|
|
11
|
+
*/
|
|
12
|
+
get source(): string;
|
|
13
|
+
/**
|
|
14
|
+
* Get this object name
|
|
15
|
+
*/
|
|
16
|
+
get basename(): string;
|
|
17
|
+
/**
|
|
18
|
+
* Get this object's extension
|
|
19
|
+
*/
|
|
20
|
+
get extension(): string | null;
|
|
21
|
+
/**
|
|
22
|
+
* Get the directory path leading to this object
|
|
23
|
+
*/
|
|
24
|
+
get dirname(): string;
|
|
25
|
+
/**
|
|
26
|
+
* Is it a file or a folder ?
|
|
27
|
+
*/
|
|
28
|
+
abstract get type(): FileType;
|
|
29
|
+
/**
|
|
30
|
+
* Get the file mime
|
|
31
|
+
*/
|
|
32
|
+
get mime(): string | undefined;
|
|
33
|
+
/**
|
|
34
|
+
* Get the file size
|
|
35
|
+
*/
|
|
36
|
+
get size(): number | undefined;
|
|
37
|
+
/**
|
|
38
|
+
* Get the file attribute
|
|
39
|
+
*/
|
|
40
|
+
get attributes(): Attribute;
|
|
41
|
+
/**
|
|
42
|
+
* Get the file permissions
|
|
43
|
+
*/
|
|
44
|
+
get permissions(): Permission;
|
|
45
|
+
/**
|
|
46
|
+
* Get the file owner
|
|
47
|
+
*/
|
|
48
|
+
get owner(): string | null;
|
|
49
|
+
/**
|
|
50
|
+
* Is this a dav-related ressource ?
|
|
51
|
+
*/
|
|
52
|
+
get isDavRessource(): boolean;
|
|
53
|
+
/**
|
|
54
|
+
* Get the dav root of this object
|
|
55
|
+
*/
|
|
56
|
+
get root(): string | null;
|
|
57
|
+
/**
|
|
58
|
+
* Move the node to a new destination
|
|
59
|
+
*
|
|
60
|
+
* @param {string} destination the new source.
|
|
61
|
+
* e.g. https://cloud.domain.com/remote.php/dav/files/emma/Photos/picture.jpg
|
|
62
|
+
*/
|
|
63
|
+
move(destination: string): void;
|
|
64
|
+
/**
|
|
65
|
+
* Rename the node
|
|
66
|
+
* This aliases the move method for easier usage
|
|
67
|
+
*/
|
|
68
|
+
rename(basename: any): void;
|
|
69
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @copyright Copyright (c) 2022 John Molakvoæ <skjnldsv@protonmail.com>
|
|
3
|
+
*
|
|
4
|
+
* @author John Molakvoæ <skjnldsv@protonmail.com>
|
|
5
|
+
*
|
|
6
|
+
* @license AGPL-3.0-or-later
|
|
7
|
+
*
|
|
8
|
+
* This program is free software: you can redistribute it and/or modify
|
|
9
|
+
* it under the terms of the GNU Affero General Public License as
|
|
10
|
+
* published by the Free Software Foundation, either version 3 of the
|
|
11
|
+
* License, or (at your option) any later version.
|
|
12
|
+
*
|
|
13
|
+
* This program is distributed in the hope that it will be useful,
|
|
14
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
15
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
16
|
+
* GNU Affero General Public License for more details.
|
|
17
|
+
*
|
|
18
|
+
* You should have received a copy of the GNU Affero General Public License
|
|
19
|
+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
20
|
+
*
|
|
21
|
+
*/
|
|
22
|
+
import { Permission } from "../permissions";
|
|
23
|
+
export interface Attribute {
|
|
24
|
+
[key: string]: any;
|
|
25
|
+
}
|
|
26
|
+
export default interface NodeData {
|
|
27
|
+
/** Unique ID */
|
|
28
|
+
id?: number;
|
|
29
|
+
/** URL to the ressource
|
|
30
|
+
* e.g. https://cloud.domain.com/remote.php/dav/files/emma/Photos/picture.jpg
|
|
31
|
+
* or https://domain.com/Photos/picture.jpg
|
|
32
|
+
*/
|
|
33
|
+
source: string;
|
|
34
|
+
/** Last modified time */
|
|
35
|
+
mtime?: Date;
|
|
36
|
+
/** Creation time */
|
|
37
|
+
crtime?: Date;
|
|
38
|
+
/** The mime type */
|
|
39
|
+
mime?: string;
|
|
40
|
+
/** The node size type */
|
|
41
|
+
size?: number;
|
|
42
|
+
/** The node permissions */
|
|
43
|
+
permissions?: Permission;
|
|
44
|
+
/** The owner UID of this node */
|
|
45
|
+
owner: string | null;
|
|
46
|
+
attributes?: Attribute;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Validate Node construct data
|
|
50
|
+
*/
|
|
51
|
+
export declare const validateData: (data: NodeData) => void;
|
package/dist/index.d.ts
CHANGED
|
@@ -23,6 +23,10 @@
|
|
|
23
23
|
export { formatFileSize } from './humanfilesize';
|
|
24
24
|
export { type Entry } from './newFileMenu';
|
|
25
25
|
import { type Entry, NewFileMenu } from './newFileMenu';
|
|
26
|
+
export { FileType } from './files/fileType';
|
|
27
|
+
export { File } from './files/file';
|
|
28
|
+
export { Folder } from './files/folder';
|
|
29
|
+
export { Permission } from './permissions';
|
|
26
30
|
declare global {
|
|
27
31
|
interface Window {
|
|
28
32
|
OC: any;
|
package/dist/index.esm.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { getCanonicalLocale } from '@nextcloud/l10n';
|
|
2
2
|
import { getCurrentUser } from '@nextcloud/auth';
|
|
3
3
|
import { getLoggerBuilder } from '@nextcloud/logger';
|
|
4
|
+
import { basename, extname, dirname } from 'path';
|
|
4
5
|
|
|
5
6
|
/**
|
|
6
7
|
* @copyright 2019 Christoph Wurst <christoph@winzerhof-wurst.at>
|
|
@@ -181,6 +182,328 @@ const getNewFileMenu = function () {
|
|
|
181
182
|
return window._nc_newfilemenu;
|
|
182
183
|
};
|
|
183
184
|
|
|
185
|
+
/**
|
|
186
|
+
* @copyright Copyright (c) 2022 John Molakvoæ <skjnldsv@protonmail.com>
|
|
187
|
+
*
|
|
188
|
+
* @author John Molakvoæ <skjnldsv@protonmail.com>
|
|
189
|
+
*
|
|
190
|
+
* @license AGPL-3.0-or-later
|
|
191
|
+
*
|
|
192
|
+
* This program is free software: you can redistribute it and/or modify
|
|
193
|
+
* it under the terms of the GNU Affero General Public License as
|
|
194
|
+
* published by the Free Software Foundation, either version 3 of the
|
|
195
|
+
* License, or (at your option) any later version.
|
|
196
|
+
*
|
|
197
|
+
* This program is distributed in the hope that it will be useful,
|
|
198
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
199
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
200
|
+
* GNU Affero General Public License for more details.
|
|
201
|
+
*
|
|
202
|
+
* You should have received a copy of the GNU Affero General Public License
|
|
203
|
+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
204
|
+
*
|
|
205
|
+
*/
|
|
206
|
+
var FileType;
|
|
207
|
+
(function (FileType) {
|
|
208
|
+
FileType["Folder"] = "folder";
|
|
209
|
+
FileType["File"] = "file";
|
|
210
|
+
})(FileType || (FileType = {}));
|
|
211
|
+
|
|
212
|
+
/**
|
|
213
|
+
* @copyright Copyright (c) 2022 John Molakvoæ <skjnldsv@protonmail.com>
|
|
214
|
+
*
|
|
215
|
+
* @author John Molakvoæ <skjnldsv@protonmail.com>
|
|
216
|
+
*
|
|
217
|
+
* @license AGPL-3.0-or-later
|
|
218
|
+
*
|
|
219
|
+
* This program is free software: you can redistribute it and/or modify
|
|
220
|
+
* it under the terms of the GNU Affero General Public License as
|
|
221
|
+
* published by the Free Software Foundation, either version 3 of the
|
|
222
|
+
* License, or (at your option) any later version.
|
|
223
|
+
*
|
|
224
|
+
* This program is distributed in the hope that it will be useful,
|
|
225
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
226
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
227
|
+
* GNU Affero General Public License for more details.
|
|
228
|
+
*
|
|
229
|
+
* You should have received a copy of the GNU Affero General Public License
|
|
230
|
+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
231
|
+
*
|
|
232
|
+
*/
|
|
233
|
+
var Permission;
|
|
234
|
+
(function (Permission) {
|
|
235
|
+
Permission[Permission["NONE"] = 0] = "NONE";
|
|
236
|
+
Permission[Permission["CREATE"] = 4] = "CREATE";
|
|
237
|
+
Permission[Permission["READ"] = 1] = "READ";
|
|
238
|
+
Permission[Permission["UPDATE"] = 2] = "UPDATE";
|
|
239
|
+
Permission[Permission["DELETE"] = 8] = "DELETE";
|
|
240
|
+
Permission[Permission["SHARE"] = 16] = "SHARE";
|
|
241
|
+
Permission[Permission["ALL"] = 31] = "ALL";
|
|
242
|
+
})(Permission || (Permission = {}));
|
|
243
|
+
|
|
244
|
+
/**
|
|
245
|
+
* @copyright Copyright (c) 2022 John Molakvoæ <skjnldsv@protonmail.com>
|
|
246
|
+
*
|
|
247
|
+
* @author John Molakvoæ <skjnldsv@protonmail.com>
|
|
248
|
+
*
|
|
249
|
+
* @license AGPL-3.0-or-later
|
|
250
|
+
*
|
|
251
|
+
* This program is free software: you can redistribute it and/or modify
|
|
252
|
+
* it under the terms of the GNU Affero General Public License as
|
|
253
|
+
* published by the Free Software Foundation, either version 3 of the
|
|
254
|
+
* License, or (at your option) any later version.
|
|
255
|
+
*
|
|
256
|
+
* This program is distributed in the hope that it will be useful,
|
|
257
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
258
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
259
|
+
* GNU Affero General Public License for more details.
|
|
260
|
+
*
|
|
261
|
+
* You should have received a copy of the GNU Affero General Public License
|
|
262
|
+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
263
|
+
*
|
|
264
|
+
*/
|
|
265
|
+
/**
|
|
266
|
+
* Validate Node construct data
|
|
267
|
+
*/
|
|
268
|
+
const validateData = (data) => {
|
|
269
|
+
if ('id' in data && (typeof data.id !== 'number' || data.id < 0)) {
|
|
270
|
+
throw new Error('Invalid id type of value');
|
|
271
|
+
}
|
|
272
|
+
if (!data.source) {
|
|
273
|
+
throw new Error('Missing mandatory source');
|
|
274
|
+
}
|
|
275
|
+
if (!data.source.startsWith('http')) {
|
|
276
|
+
throw new Error('Invalid source format');
|
|
277
|
+
}
|
|
278
|
+
if ('mtime' in data && !(data.mtime instanceof Date)) {
|
|
279
|
+
throw new Error('Invalid mtime type');
|
|
280
|
+
}
|
|
281
|
+
if ('crtime' in data && !(data.crtime instanceof Date)) {
|
|
282
|
+
throw new Error('Invalid crtime type');
|
|
283
|
+
}
|
|
284
|
+
if (!data.mime || typeof data.mime !== 'string'
|
|
285
|
+
|| !data.mime.match(/^[-\w.]+\/[-+\w.]+$/gi)) {
|
|
286
|
+
throw new Error('Missing or invalid mandatory mime');
|
|
287
|
+
}
|
|
288
|
+
if ('size' in data && typeof data.size !== 'number') {
|
|
289
|
+
throw new Error('Invalid size type');
|
|
290
|
+
}
|
|
291
|
+
if ('permissions' in data && !(typeof data.permissions === 'number'
|
|
292
|
+
&& data.permissions >= Permission.NONE
|
|
293
|
+
&& data.permissions <= Permission.ALL)) {
|
|
294
|
+
throw new Error('Invalid permissions');
|
|
295
|
+
}
|
|
296
|
+
if ('owner' in data
|
|
297
|
+
&& data.owner !== null
|
|
298
|
+
&& typeof data.owner !== 'string') {
|
|
299
|
+
throw new Error('Invalid owner type');
|
|
300
|
+
}
|
|
301
|
+
if ('attributes' in data && typeof data.attributes !== 'object') {
|
|
302
|
+
throw new Error('Invalid attributes format');
|
|
303
|
+
}
|
|
304
|
+
};
|
|
305
|
+
|
|
306
|
+
/**
|
|
307
|
+
* @copyright Copyright (c) 2022 John Molakvoæ <skjnldsv@protonmail.com>
|
|
308
|
+
*
|
|
309
|
+
* @author John Molakvoæ <skjnldsv@protonmail.com>
|
|
310
|
+
*
|
|
311
|
+
* @license AGPL-3.0-or-later
|
|
312
|
+
*
|
|
313
|
+
* This program is free software: you can redistribute it and/or modify
|
|
314
|
+
* it under the terms of the GNU Affero General Public License as
|
|
315
|
+
* published by the Free Software Foundation, either version 3 of the
|
|
316
|
+
* License, or (at your option) any later version.
|
|
317
|
+
*
|
|
318
|
+
* This program is distributed in the hope that it will be useful,
|
|
319
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
320
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
321
|
+
* GNU Affero General Public License for more details.
|
|
322
|
+
*
|
|
323
|
+
* You should have received a copy of the GNU Affero General Public License
|
|
324
|
+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
325
|
+
*
|
|
326
|
+
*/
|
|
327
|
+
class Node {
|
|
328
|
+
_data;
|
|
329
|
+
_attributes;
|
|
330
|
+
_knownDavService = /(remote|public)\.php\/(web)?dav/i;
|
|
331
|
+
constructor(data, davService) {
|
|
332
|
+
// Validate data
|
|
333
|
+
validateData(data);
|
|
334
|
+
this._data = data;
|
|
335
|
+
this._attributes = data.attributes || {};
|
|
336
|
+
delete this._data.attributes;
|
|
337
|
+
if (davService) {
|
|
338
|
+
this._knownDavService = davService;
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
/**
|
|
342
|
+
* Get the source url to this object
|
|
343
|
+
*/
|
|
344
|
+
get source() {
|
|
345
|
+
// strip any ending slash
|
|
346
|
+
return this._data.source.replace(/\/$/i, '');
|
|
347
|
+
}
|
|
348
|
+
/**
|
|
349
|
+
* Get this object name
|
|
350
|
+
*/
|
|
351
|
+
get basename() {
|
|
352
|
+
return basename(this.source);
|
|
353
|
+
}
|
|
354
|
+
/**
|
|
355
|
+
* Get this object's extension
|
|
356
|
+
*/
|
|
357
|
+
get extension() {
|
|
358
|
+
return extname(this.source);
|
|
359
|
+
}
|
|
360
|
+
/**
|
|
361
|
+
* Get the directory path leading to this object
|
|
362
|
+
*/
|
|
363
|
+
get dirname() {
|
|
364
|
+
return dirname(this.source);
|
|
365
|
+
}
|
|
366
|
+
/**
|
|
367
|
+
* Get the file mime
|
|
368
|
+
*/
|
|
369
|
+
get mime() {
|
|
370
|
+
return this._data.mime;
|
|
371
|
+
}
|
|
372
|
+
/**
|
|
373
|
+
* Get the file size
|
|
374
|
+
*/
|
|
375
|
+
get size() {
|
|
376
|
+
return this._data.size;
|
|
377
|
+
}
|
|
378
|
+
/**
|
|
379
|
+
* Get the file attribute
|
|
380
|
+
*/
|
|
381
|
+
get attributes() {
|
|
382
|
+
return this._attributes;
|
|
383
|
+
}
|
|
384
|
+
/**
|
|
385
|
+
* Get the file permissions
|
|
386
|
+
*/
|
|
387
|
+
get permissions() {
|
|
388
|
+
// If this is not a dav ressource, we can only read it
|
|
389
|
+
if (this.owner === null && !this.isDavRessource) {
|
|
390
|
+
return Permission.READ;
|
|
391
|
+
}
|
|
392
|
+
return this._data.permissions || Permission.READ;
|
|
393
|
+
}
|
|
394
|
+
/**
|
|
395
|
+
* Get the file owner
|
|
396
|
+
*/
|
|
397
|
+
get owner() {
|
|
398
|
+
// Remote ressources have no owner
|
|
399
|
+
if (!this.isDavRessource) {
|
|
400
|
+
return null;
|
|
401
|
+
}
|
|
402
|
+
return this._data.owner;
|
|
403
|
+
}
|
|
404
|
+
/**
|
|
405
|
+
* Is this a dav-related ressource ?
|
|
406
|
+
*/
|
|
407
|
+
get isDavRessource() {
|
|
408
|
+
return this.source.match(this._knownDavService) !== null;
|
|
409
|
+
}
|
|
410
|
+
/**
|
|
411
|
+
* Get the dav root of this object
|
|
412
|
+
*/
|
|
413
|
+
get root() {
|
|
414
|
+
if (this.isDavRessource) {
|
|
415
|
+
return this.dirname.split(this._knownDavService).pop() || null;
|
|
416
|
+
}
|
|
417
|
+
return null;
|
|
418
|
+
}
|
|
419
|
+
/**
|
|
420
|
+
* Move the node to a new destination
|
|
421
|
+
*
|
|
422
|
+
* @param {string} destination the new source.
|
|
423
|
+
* e.g. https://cloud.domain.com/remote.php/dav/files/emma/Photos/picture.jpg
|
|
424
|
+
*/
|
|
425
|
+
move(destination) {
|
|
426
|
+
this._data.source = destination;
|
|
427
|
+
}
|
|
428
|
+
/**
|
|
429
|
+
* Rename the node
|
|
430
|
+
* This aliases the move method for easier usage
|
|
431
|
+
*/
|
|
432
|
+
rename(basename) {
|
|
433
|
+
if (basename.includes('/')) {
|
|
434
|
+
throw new Error('Invalid basename');
|
|
435
|
+
}
|
|
436
|
+
this.move(this.dirname + '/' + basename);
|
|
437
|
+
}
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
/**
|
|
441
|
+
* @copyright Copyright (c) 2022 John Molakvoæ <skjnldsv@protonmail.com>
|
|
442
|
+
*
|
|
443
|
+
* @author John Molakvoæ <skjnldsv@protonmail.com>
|
|
444
|
+
*
|
|
445
|
+
* @license AGPL-3.0-or-later
|
|
446
|
+
*
|
|
447
|
+
* This program is free software: you can redistribute it and/or modify
|
|
448
|
+
* it under the terms of the GNU Affero General Public License as
|
|
449
|
+
* published by the Free Software Foundation, either version 3 of the
|
|
450
|
+
* License, or (at your option) any later version.
|
|
451
|
+
*
|
|
452
|
+
* This program is distributed in the hope that it will be useful,
|
|
453
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
454
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
455
|
+
* GNU Affero General Public License for more details.
|
|
456
|
+
*
|
|
457
|
+
* You should have received a copy of the GNU Affero General Public License
|
|
458
|
+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
459
|
+
*
|
|
460
|
+
*/
|
|
461
|
+
class File extends Node {
|
|
462
|
+
get type() {
|
|
463
|
+
return FileType.File;
|
|
464
|
+
}
|
|
465
|
+
}
|
|
466
|
+
|
|
467
|
+
/**
|
|
468
|
+
* @copyright Copyright (c) 2022 John Molakvoæ <skjnldsv@protonmail.com>
|
|
469
|
+
*
|
|
470
|
+
* @author John Molakvoæ <skjnldsv@protonmail.com>
|
|
471
|
+
*
|
|
472
|
+
* @license AGPL-3.0-or-later
|
|
473
|
+
*
|
|
474
|
+
* This program is free software: you can redistribute it and/or modify
|
|
475
|
+
* it under the terms of the GNU Affero General Public License as
|
|
476
|
+
* published by the Free Software Foundation, either version 3 of the
|
|
477
|
+
* License, or (at your option) any later version.
|
|
478
|
+
*
|
|
479
|
+
* This program is distributed in the hope that it will be useful,
|
|
480
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
481
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
482
|
+
* GNU Affero General Public License for more details.
|
|
483
|
+
*
|
|
484
|
+
* You should have received a copy of the GNU Affero General Public License
|
|
485
|
+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
486
|
+
*
|
|
487
|
+
*/
|
|
488
|
+
class Folder extends Node {
|
|
489
|
+
constructor(data) {
|
|
490
|
+
// enforcing mimes
|
|
491
|
+
super({
|
|
492
|
+
...data,
|
|
493
|
+
mime: 'httpd/unix-directory'
|
|
494
|
+
});
|
|
495
|
+
}
|
|
496
|
+
get type() {
|
|
497
|
+
return FileType.Folder;
|
|
498
|
+
}
|
|
499
|
+
get extension() {
|
|
500
|
+
return null;
|
|
501
|
+
}
|
|
502
|
+
get mime() {
|
|
503
|
+
return 'httpd/unix-directory';
|
|
504
|
+
}
|
|
505
|
+
}
|
|
506
|
+
|
|
184
507
|
/**
|
|
185
508
|
* @copyright 2019 Christoph Wurst <christoph@winzerhof-wurst.at>
|
|
186
509
|
*
|
|
@@ -227,5 +550,5 @@ const getNewFileMenuEntries = function (context) {
|
|
|
227
550
|
return newFileMenu.getEntries(context);
|
|
228
551
|
};
|
|
229
552
|
|
|
230
|
-
export { addNewFileMenuEntry, formatFileSize, getNewFileMenuEntries, removeNewFileMenuEntry };
|
|
553
|
+
export { File, FileType, Folder, Permission, addNewFileMenuEntry, formatFileSize, getNewFileMenuEntries, removeNewFileMenuEntry };
|
|
231
554
|
//# sourceMappingURL=index.esm.js.map
|
package/dist/index.esm.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.esm.js","sources":["../lib/humanfilesize.ts","../lib/utils/logger.ts","../lib/newFileMenu.ts","../lib/index.ts"],"sourcesContent":["/**\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'];\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 */\nexport function formatFileSize(size: number|string, skipSmallSizes: boolean = false): string {\n\n\tif (typeof size === 'string') {\n\t\tsize = Number(size)\n\t}\n\n\t// Calculate Log with base 1024: size = 1024 ** order\n\tlet order = size > 0 ? Math.floor(Math.log(size) / Math.log(1024)) : 0;\n\t// Stay in range of the byte sizes that are defined\n\torder = Math.min(humanList.length - 1, order);\n\tconst readableFormat = humanList[order];\n\tlet relativeSize = (size / Math.pow(1024, order)).toFixed(1);\n\n\tif (skipSmallSizes === true && order === 0) {\n\t\tif (relativeSize !== '0.0') {\n\t\t\treturn '< 1 KB';\n\t\t} else {\n\t\t\treturn '0 KB';\n\t\t}\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 2019 Christoph Wurst <christoph@winzerhof-wurst.at>\n *\n * @author Christoph Wurst <christoph@winzerhof-wurst.at>\n *\n * @license AGPL-3.0-or-later\n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n *\n */\n\nimport { getCurrentUser } from '@nextcloud/auth'\nimport { getLoggerBuilder } from '@nextcloud/logger'\n\nconst getLogger = user => {\n\tif (user === null) {\n\t\treturn getLoggerBuilder()\n\t\t\t.setApp('files')\n\t\t\t.build()\n\t}\n\treturn getLoggerBuilder()\n\t\t.setApp('files')\n\t\t.setUid(user.uid)\n\t\t.build()\n}\n\nexport default getLogger(getCurrentUser())\n","/**\n * @copyright Copyright (c) 2021 John Molakvoæ <skjnldsv@protonmail.com>\n *\n * @author John Molakvoæ <skjnldsv@protonmail.com>\n *\n * @license AGPL-3.0-or-later\n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n *\n */\n\nimport logger from \"./utils/logger\"\n\nexport interface Entry {\n\t/** Unique ID */\n\tid: string\n\t/** Translatable string displayed in the menu */\n\tdisplayName: string\n\t// Default new file name\n\ttemplateName?: string\n\t// Condition wether this entry is shown or not\n\tif?: (context: Object) => Boolean\n\t/**\n\t * Either iconSvgInline or iconClass must be defined\n\t * Svg as inline string. <svg><path fill=\"...\" /></svg>\n\t */\n\ticonSvgInline?: string\n\t/** Existing icon css class */\n\ticonClass?: string\n\t/** Function to be run after creation */\n\thandler?: Function\n}\n\nexport class NewFileMenu {\n\tprivate _entries: Array<Entry> = []\n\t\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\t\t\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\t\n\t/**\n\t * Get the list of registered entries\n\t * \n\t * @param {FileInfo} context the creation context. Usually the current folder FileInfo\n\t */\n\tpublic getEntries(context?: Object): Array<Entry> {\n\t\tif (context) {\n\t\t\treturn this._entries\n\t\t\t\t.filter(entry => typeof entry.if === 'function' ? entry.if(context) : true)\n\t\t}\n\t\treturn this._entries\n\t}\n\n\tprivate getEntryIndex(id: string): number {\n\t\treturn this._entries.findIndex(entry => entry.id === id)\n\t}\n\n\tprivate validateEntry(entry: Entry) {\n\t\tif (!entry.id || !entry.displayName || !(entry.iconSvgInline || entry.iconClass)) {\n\t\t\tthrow new Error('Invalid entry')\n\t\t}\n\n\t\tif (typeof entry.id !== 'string'\n\t\t\t|| typeof entry.displayName !== 'string') {\n\t\t\tthrow new Error('Invalid id or displayName property')\n\t\t}\n\n\t\tif ((entry.iconClass && typeof entry.iconClass !== 'string')\n\t\t\t|| (entry.iconSvgInline && typeof entry.iconSvgInline !== 'string')) {\n\t\t\tthrow new Error('Invalid icon provided')\n\t\t}\n\n\t\tif (entry.if !== undefined && typeof entry.if !== 'function') {\n\t\t\tthrow new Error('Invalid if property')\n\t\t}\n\n\t\tif (entry.templateName && typeof entry.templateName !== 'string') {\n\t\t\tthrow new Error('Invalid templateName property')\n\t\t}\n\n\t\tif (entry.handler && typeof entry.handler !== 'function') {\n\t\t\tthrow new Error('Invalid handler property')\n\t\t}\n\n\t\tif (!entry.templateName && !entry.handler) {\n\t\t\tthrow new Error('At least a templateName or a handler must be provided')\n\t\t}\n\n\t\tif (this.getEntryIndex(entry.id) !== -1) {\n\t\t\tthrow new Error('Duplicate entry')\n\t\t}\n\t}\n}\n\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 * @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\nexport { formatFileSize } from './humanfilesize'\nexport { type Entry } from './newFileMenu'\nimport { type Entry, getNewFileMenu, NewFileMenu } from './newFileMenu'\n\ndeclare global {\n\tinterface Window {\n\t\tOC: any;\n\t\t_nc_newfilemenu: NewFileMenu;\n\t}\n}\n\n/**\n * Add a new menu entry to the upload manager menu\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 */\nexport const removeNewFileMenuEntry = function(entry: Entry | string) {\n\tconst newFileMenu = getNewFileMenu()\n\treturn newFileMenu.unregisterEntry(entry)\n}\n\n/**\n * Get the list of registered entries from the upload menu\n *\n * @param {FileInfo} context the creation context. Usually the current folder FileInfo\n */\nexport const getNewFileMenuEntries = function(context?: Object) {\n\tconst newFileMenu = getNewFileMenu()\n\treturn newFileMenu.getEntries(context)\n}\n"],"names":[],"mappings":";;;;AAAA;;;;;;;;;;;;;;;;;;;;;AAqBG;AAIH,MAAM,SAAS,GAAG,CAAC,GAAG,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;AAEhD;;;;;AAKG;SACa,cAAc,CAAC,IAAmB,EAAE,iBAA0B,KAAK,EAAA;AAElF,IAAA,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE;AAC7B,QAAA,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,CAAA;AACnB,KAAA;;AAGD,IAAA,IAAI,KAAK,GAAG,IAAI,GAAG,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC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AAC,KAAK,CAAC,CAAC,EAAE;AACxC,YAAA,MAAM,IAAI,KAAK,CAAC,iBAAiB,CAAC,CAAA;AAClC,SAAA;KACD;AACD,CAAA;AAEM,MAAM,cAAc,GAAG,YAAA;AAC7B,IAAA,IAAI,OAAO,MAAM,CAAC,eAAe,KAAK,WAAW,EAAE;AAClD,QAAA,MAAM,CAAC,eAAe,GAAG,IAAI,WAAW,EAAE,CAAA;AAC1C,QAAA,MAAM,CAAC,KAAK,CAAC,yBAAyB,CAAC,CAAA;AACvC,KAAA;IACD,OAAO,MAAM,CAAC,eAAe,CAAA;AAC9B,CAAC;;AC7HD;;;;;;;;;;;;;;;;;;;;;AAqBG;AAaH;;AAEG;AACI,MAAM,mBAAmB,GAAG,UAAS,KAAY,EAAA;AACvD,IAAA,MAAM,WAAW,GAAG,cAAc,EAAE,CAAA;AACpC,IAAA,OAAO,WAAW,CAAC,aAAa,CAAC,KAAK,CAAC,CAAA;AACxC,EAAC;AAED;;AAEG;AACI,MAAM,sBAAsB,GAAG,UAAS,KAAqB,EAAA;AACnE,IAAA,MAAM,WAAW,GAAG,cAAc,EAAE,CAAA;AACpC,IAAA,OAAO,WAAW,CAAC,eAAe,CAAC,KAAK,CAAC,CAAA;AAC1C,EAAC;AAED;;;;AAIG;AACI,MAAM,qBAAqB,GAAG,UAAS,OAAgB,EAAA;AAC7D,IAAA,MAAM,WAAW,GAAG,cAAc,EAAE,CAAA;AACpC,IAAA,OAAO,WAAW,CAAC,UAAU,CAAC,OAAO,CAAC,CAAA;AACvC;;;;"}
|
|
1
|
+
{"version":3,"file":"index.esm.js","sources":["../lib/humanfilesize.ts","../lib/utils/logger.ts","../lib/newFileMenu.ts","../lib/files/fileType.ts","../lib/permissions.ts","../lib/files/nodeData.ts","../lib/files/node.ts","../lib/files/file.ts","../lib/files/folder.ts","../lib/index.ts"],"sourcesContent":["/**\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'];\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 */\nexport function formatFileSize(size: number|string, skipSmallSizes: boolean = false): string {\n\n\tif (typeof size === 'string') {\n\t\tsize = Number(size)\n\t}\n\n\t// Calculate Log with base 1024: size = 1024 ** order\n\tlet order = size > 0 ? Math.floor(Math.log(size) / Math.log(1024)) : 0;\n\t// Stay in range of the byte sizes that are defined\n\torder = Math.min(humanList.length - 1, order);\n\tconst readableFormat = humanList[order];\n\tlet relativeSize = (size / Math.pow(1024, order)).toFixed(1);\n\n\tif (skipSmallSizes === true && order === 0) {\n\t\tif (relativeSize !== '0.0') {\n\t\t\treturn '< 1 KB';\n\t\t} else {\n\t\t\treturn '0 KB';\n\t\t}\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 2019 Christoph Wurst <christoph@winzerhof-wurst.at>\n *\n * @author Christoph Wurst <christoph@winzerhof-wurst.at>\n *\n * @license AGPL-3.0-or-later\n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n *\n */\n\nimport { getCurrentUser } from '@nextcloud/auth'\nimport { getLoggerBuilder } from '@nextcloud/logger'\n\nconst getLogger = user => {\n\tif (user === null) {\n\t\treturn getLoggerBuilder()\n\t\t\t.setApp('files')\n\t\t\t.build()\n\t}\n\treturn getLoggerBuilder()\n\t\t.setApp('files')\n\t\t.setUid(user.uid)\n\t\t.build()\n}\n\nexport default getLogger(getCurrentUser())\n","/**\n * @copyright Copyright (c) 2021 John Molakvoæ <skjnldsv@protonmail.com>\n *\n * @author John Molakvoæ <skjnldsv@protonmail.com>\n *\n * @license AGPL-3.0-or-later\n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n *\n */\n\nimport logger from \"./utils/logger\"\n\nexport interface Entry {\n\t/** Unique ID */\n\tid: string\n\t/** Translatable string displayed in the menu */\n\tdisplayName: string\n\t// Default new file name\n\ttemplateName?: string\n\t// Condition wether this entry is shown or not\n\tif?: (context: Object) => Boolean\n\t/**\n\t * Either iconSvgInline or iconClass must be defined\n\t * Svg as inline string. <svg><path fill=\"...\" /></svg>\n\t */\n\ticonSvgInline?: string\n\t/** Existing icon css class */\n\ticonClass?: string\n\t/** Function to be run after creation */\n\thandler?: Function\n}\n\nexport class NewFileMenu {\n\tprivate _entries: Array<Entry> = []\n\t\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\t\t\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\t\n\t/**\n\t * Get the list of registered entries\n\t * \n\t * @param {FileInfo} context the creation context. Usually the current folder FileInfo\n\t */\n\tpublic getEntries(context?: Object): Array<Entry> {\n\t\tif (context) {\n\t\t\treturn this._entries\n\t\t\t\t.filter(entry => typeof entry.if === 'function' ? entry.if(context) : true)\n\t\t}\n\t\treturn this._entries\n\t}\n\n\tprivate getEntryIndex(id: string): number {\n\t\treturn this._entries.findIndex(entry => entry.id === id)\n\t}\n\n\tprivate validateEntry(entry: Entry) {\n\t\tif (!entry.id || !entry.displayName || !(entry.iconSvgInline || entry.iconClass)) {\n\t\t\tthrow new Error('Invalid entry')\n\t\t}\n\n\t\tif (typeof entry.id !== 'string'\n\t\t\t|| typeof entry.displayName !== 'string') {\n\t\t\tthrow new Error('Invalid id or displayName property')\n\t\t}\n\n\t\tif ((entry.iconClass && typeof entry.iconClass !== 'string')\n\t\t\t|| (entry.iconSvgInline && typeof entry.iconSvgInline !== 'string')) {\n\t\t\tthrow new Error('Invalid icon provided')\n\t\t}\n\n\t\tif (entry.if !== undefined && typeof entry.if !== 'function') {\n\t\t\tthrow new Error('Invalid if property')\n\t\t}\n\n\t\tif (entry.templateName && typeof entry.templateName !== 'string') {\n\t\t\tthrow new Error('Invalid templateName property')\n\t\t}\n\n\t\tif (entry.handler && typeof entry.handler !== 'function') {\n\t\t\tthrow new Error('Invalid handler property')\n\t\t}\n\n\t\tif (!entry.templateName && !entry.handler) {\n\t\t\tthrow new Error('At least a templateName or a handler must be provided')\n\t\t}\n\n\t\tif (this.getEntryIndex(entry.id) !== -1) {\n\t\t\tthrow new Error('Duplicate entry')\n\t\t}\n\t}\n}\n\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 * @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/**\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\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) 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 { Permission } from \"../permissions\"\n\nexport interface Attribute { [key: string]: any }\n\nexport default interface NodeData {\n\t/** Unique ID */\n\tid?: number\n\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 */\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 \n/**\n * Validate Node construct data\n */\nexport const validateData = (data: NodeData) => {\n\tif ('id' in data && (typeof data.id !== 'number' || data.id < 0)) {\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\tif (!data.source.startsWith('http')) {\n\t\tthrow new Error('Invalid source format')\n\t}\n\n\tif ('mtime' in data && !(data.mtime instanceof Date)) {\n\t\tthrow new Error('Invalid mtime type')\n\t}\n\n\tif ('crtime' in data && !(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\tif ('size' in data && typeof data.size !== 'number') {\n\t\tthrow new Error('Invalid size type')\n\t}\n\n\tif ('permissions' in data && !(\n\t\t\ttypeof 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 ('owner' in data\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 ('attributes' in data && typeof data.attributes !== 'object') {\n\t\tthrow new Error('Invalid attributes format')\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 NodeData, { Attribute, validateData } from './nodeData'\n\nexport default abstract class Node {\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)\n\n\t\tthis._data = data\n\t\tthis._attributes = data.attributes || {} as any\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 */\n\tget dirname(): string {\n\t\treturn dirname(this.source)\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 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\treturn this._data.permissions || Permission.READ\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 this.source.match(this._knownDavService) !== null\n\t}\n\n\t/**\n\t * Get the dav root of this object\n\t */\n\tget root(): string|null {\n\t\tif (this.isDavRessource) {\n\t\t\treturn this.dirname.split(this._knownDavService).pop() || null\n\t\t}\n\t\treturn null\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\tthis._data.source = destination\n\t}\n\n\t/**\n\t * Rename the node\n\t * This aliases the move method for easier usage\n\t */\n\trename(basename) {\n\t\tif (basename.includes('/')) {\n\t\t\tthrow new Error('Invalid basename')\n\t\t}\n\t\tthis.move(this.dirname + '/' + basename)\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 { FileType } from './fileType'\nimport Node from './node'\n\nexport class File extends Node {\n\tget type(): FileType {\n\t\treturn FileType.File\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 { FileType } from './fileType'\nimport Node from './node'\nimport NodeData from './nodeData'\n\nexport class Folder extends Node {\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 * @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\nexport { formatFileSize } from './humanfilesize'\nexport { type Entry } from './newFileMenu'\nimport { type Entry, getNewFileMenu, NewFileMenu } from './newFileMenu'\n\nexport { FileType } from './files/fileType'\nexport { File } from './files/file'\nexport { Folder } from './files/folder'\nexport { Permission } from './permissions'\n\ndeclare global {\n\tinterface Window {\n\t\tOC: any;\n\t\t_nc_newfilemenu: NewFileMenu;\n\t}\n}\n\n/**\n * Add a new menu entry to the upload manager menu\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 */\nexport const removeNewFileMenuEntry = function(entry: Entry | string) {\n\tconst newFileMenu = getNewFileMenu()\n\treturn newFileMenu.unregisterEntry(entry)\n}\n\n/**\n * Get the list of registered entries from the upload menu\n *\n * @param {FileInfo} context the creation context. Usually the current folder FileInfo\n */\nexport const getNewFileMenuEntries = function(context?: Object) {\n\tconst newFileMenu = getNewFileMenu()\n\treturn newFileMenu.getEntries(context)\n}\n"],"names":[],"mappings":";;;;;AAAA;;;;;;;;;;;;;;;;;;;;;AAqBG;AAIH,MAAM,SAAS,GAAG,CAAC,GAAG,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;AAEhD;;;;;AAKG;SACa,cAAc,CAAC,IAAmB,EAAE,iBAA0B,KAAK,EAAA;AAElF,IAAA,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE;AAC7B,QAAA,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,CAAA;AACnB,KAAA;;AAGD,IAAA,IAAI,KAAK,GAAG,IAAI,GAAG,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC;;AAEvE,IAAA,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,SAAS,CAAC,MAAM,GAAG,CAAC,EAAE,KAAK,CAAC,CAAC;AAC9C,IAAA,MAAM,cAAc,GAAG,SAAS,CAAC,KAAK,CAAC,CAAC;AACxC,IAAA,IAAI,YAAY,GAAG,CAAC,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE,KAAK,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC;AAE7D,IAAA,IAAI,cAAc,KAAK,IAAI,IAAI,KAAK,KAAK,CAAC,EAAE;QAC3C,IAAI,YAAY,KAAK,KAAK,EAAE;AAC3B,YAAA,OAAO,QAAQ,CAAC;AAChB,SAAA;AAAM,aAAA;AACN,YAAA,OAAO,MAAM,CAAC;AACd,SAAA;AACD,KAAA;IAED,IAAI,KAAK,GAAG,CAAC,EAAE;QACd,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AAA,MAAM,WAAW,GAAG,cAAc,EAAE,CAAA;AACpC,IAAA,OAAO,WAAW,CAAC,UAAU,CAAC,OAAO,CAAC,CAAA;AACvC;;;;"}
|
package/dist/index.js
CHANGED
|
@@ -5,6 +5,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
5
5
|
var l10n = require('@nextcloud/l10n');
|
|
6
6
|
var auth = require('@nextcloud/auth');
|
|
7
7
|
var logger$1 = require('@nextcloud/logger');
|
|
8
|
+
var path = require('path');
|
|
8
9
|
|
|
9
10
|
/**
|
|
10
11
|
* @copyright 2019 Christoph Wurst <christoph@winzerhof-wurst.at>
|
|
@@ -189,6 +190,391 @@ var getNewFileMenu = function () {
|
|
|
189
190
|
return window._nc_newfilemenu;
|
|
190
191
|
};
|
|
191
192
|
|
|
193
|
+
/**
|
|
194
|
+
* @copyright Copyright (c) 2022 John Molakvoæ <skjnldsv@protonmail.com>
|
|
195
|
+
*
|
|
196
|
+
* @author John Molakvoæ <skjnldsv@protonmail.com>
|
|
197
|
+
*
|
|
198
|
+
* @license AGPL-3.0-or-later
|
|
199
|
+
*
|
|
200
|
+
* This program is free software: you can redistribute it and/or modify
|
|
201
|
+
* it under the terms of the GNU Affero General Public License as
|
|
202
|
+
* published by the Free Software Foundation, either version 3 of the
|
|
203
|
+
* License, or (at your option) any later version.
|
|
204
|
+
*
|
|
205
|
+
* This program is distributed in the hope that it will be useful,
|
|
206
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
207
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
208
|
+
* GNU Affero General Public License for more details.
|
|
209
|
+
*
|
|
210
|
+
* You should have received a copy of the GNU Affero General Public License
|
|
211
|
+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
212
|
+
*
|
|
213
|
+
*/
|
|
214
|
+
exports.FileType = void 0;
|
|
215
|
+
(function (FileType) {
|
|
216
|
+
FileType["Folder"] = "folder";
|
|
217
|
+
FileType["File"] = "file";
|
|
218
|
+
})(exports.FileType || (exports.FileType = {}));
|
|
219
|
+
|
|
220
|
+
/******************************************************************************
|
|
221
|
+
Copyright (c) Microsoft Corporation.
|
|
222
|
+
|
|
223
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
224
|
+
purpose with or without fee is hereby granted.
|
|
225
|
+
|
|
226
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
227
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
228
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
229
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
230
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
231
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
232
|
+
PERFORMANCE OF THIS SOFTWARE.
|
|
233
|
+
***************************************************************************** */
|
|
234
|
+
/* global Reflect, Promise */
|
|
235
|
+
|
|
236
|
+
var extendStatics = function(d, b) {
|
|
237
|
+
extendStatics = Object.setPrototypeOf ||
|
|
238
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
239
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
240
|
+
return extendStatics(d, b);
|
|
241
|
+
};
|
|
242
|
+
|
|
243
|
+
function __extends(d, b) {
|
|
244
|
+
if (typeof b !== "function" && b !== null)
|
|
245
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
246
|
+
extendStatics(d, b);
|
|
247
|
+
function __() { this.constructor = d; }
|
|
248
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
var __assign = function() {
|
|
252
|
+
__assign = Object.assign || function __assign(t) {
|
|
253
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
254
|
+
s = arguments[i];
|
|
255
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
|
256
|
+
}
|
|
257
|
+
return t;
|
|
258
|
+
};
|
|
259
|
+
return __assign.apply(this, arguments);
|
|
260
|
+
};
|
|
261
|
+
|
|
262
|
+
/**
|
|
263
|
+
* @copyright Copyright (c) 2022 John Molakvoæ <skjnldsv@protonmail.com>
|
|
264
|
+
*
|
|
265
|
+
* @author John Molakvoæ <skjnldsv@protonmail.com>
|
|
266
|
+
*
|
|
267
|
+
* @license AGPL-3.0-or-later
|
|
268
|
+
*
|
|
269
|
+
* This program is free software: you can redistribute it and/or modify
|
|
270
|
+
* it under the terms of the GNU Affero General Public License as
|
|
271
|
+
* published by the Free Software Foundation, either version 3 of the
|
|
272
|
+
* License, or (at your option) any later version.
|
|
273
|
+
*
|
|
274
|
+
* This program is distributed in the hope that it will be useful,
|
|
275
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
276
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
277
|
+
* GNU Affero General Public License for more details.
|
|
278
|
+
*
|
|
279
|
+
* You should have received a copy of the GNU Affero General Public License
|
|
280
|
+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
281
|
+
*
|
|
282
|
+
*/
|
|
283
|
+
exports.Permission = void 0;
|
|
284
|
+
(function (Permission) {
|
|
285
|
+
Permission[Permission["NONE"] = 0] = "NONE";
|
|
286
|
+
Permission[Permission["CREATE"] = 4] = "CREATE";
|
|
287
|
+
Permission[Permission["READ"] = 1] = "READ";
|
|
288
|
+
Permission[Permission["UPDATE"] = 2] = "UPDATE";
|
|
289
|
+
Permission[Permission["DELETE"] = 8] = "DELETE";
|
|
290
|
+
Permission[Permission["SHARE"] = 16] = "SHARE";
|
|
291
|
+
Permission[Permission["ALL"] = 31] = "ALL";
|
|
292
|
+
})(exports.Permission || (exports.Permission = {}));
|
|
293
|
+
|
|
294
|
+
/**
|
|
295
|
+
* @copyright Copyright (c) 2022 John Molakvoæ <skjnldsv@protonmail.com>
|
|
296
|
+
*
|
|
297
|
+
* @author John Molakvoæ <skjnldsv@protonmail.com>
|
|
298
|
+
*
|
|
299
|
+
* @license AGPL-3.0-or-later
|
|
300
|
+
*
|
|
301
|
+
* This program is free software: you can redistribute it and/or modify
|
|
302
|
+
* it under the terms of the GNU Affero General Public License as
|
|
303
|
+
* published by the Free Software Foundation, either version 3 of the
|
|
304
|
+
* License, or (at your option) any later version.
|
|
305
|
+
*
|
|
306
|
+
* This program is distributed in the hope that it will be useful,
|
|
307
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
308
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
309
|
+
* GNU Affero General Public License for more details.
|
|
310
|
+
*
|
|
311
|
+
* You should have received a copy of the GNU Affero General Public License
|
|
312
|
+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
313
|
+
*
|
|
314
|
+
*/
|
|
315
|
+
/**
|
|
316
|
+
* Validate Node construct data
|
|
317
|
+
*/
|
|
318
|
+
var validateData = function (data) {
|
|
319
|
+
if ('id' in data && (typeof data.id !== 'number' || data.id < 0)) {
|
|
320
|
+
throw new Error('Invalid id type of value');
|
|
321
|
+
}
|
|
322
|
+
if (!data.source) {
|
|
323
|
+
throw new Error('Missing mandatory source');
|
|
324
|
+
}
|
|
325
|
+
if (!data.source.startsWith('http')) {
|
|
326
|
+
throw new Error('Invalid source format');
|
|
327
|
+
}
|
|
328
|
+
if ('mtime' in data && !(data.mtime instanceof Date)) {
|
|
329
|
+
throw new Error('Invalid mtime type');
|
|
330
|
+
}
|
|
331
|
+
if ('crtime' in data && !(data.crtime instanceof Date)) {
|
|
332
|
+
throw new Error('Invalid crtime type');
|
|
333
|
+
}
|
|
334
|
+
if (!data.mime || typeof data.mime !== 'string'
|
|
335
|
+
|| !data.mime.match(/^[-\w.]+\/[-+\w.]+$/gi)) {
|
|
336
|
+
throw new Error('Missing or invalid mandatory mime');
|
|
337
|
+
}
|
|
338
|
+
if ('size' in data && typeof data.size !== 'number') {
|
|
339
|
+
throw new Error('Invalid size type');
|
|
340
|
+
}
|
|
341
|
+
if ('permissions' in data && !(typeof data.permissions === 'number'
|
|
342
|
+
&& data.permissions >= exports.Permission.NONE
|
|
343
|
+
&& data.permissions <= exports.Permission.ALL)) {
|
|
344
|
+
throw new Error('Invalid permissions');
|
|
345
|
+
}
|
|
346
|
+
if ('owner' in data
|
|
347
|
+
&& data.owner !== null
|
|
348
|
+
&& typeof data.owner !== 'string') {
|
|
349
|
+
throw new Error('Invalid owner type');
|
|
350
|
+
}
|
|
351
|
+
if ('attributes' in data && typeof data.attributes !== 'object') {
|
|
352
|
+
throw new Error('Invalid attributes format');
|
|
353
|
+
}
|
|
354
|
+
};
|
|
355
|
+
|
|
356
|
+
/**
|
|
357
|
+
* @copyright Copyright (c) 2022 John Molakvoæ <skjnldsv@protonmail.com>
|
|
358
|
+
*
|
|
359
|
+
* @author John Molakvoæ <skjnldsv@protonmail.com>
|
|
360
|
+
*
|
|
361
|
+
* @license AGPL-3.0-or-later
|
|
362
|
+
*
|
|
363
|
+
* This program is free software: you can redistribute it and/or modify
|
|
364
|
+
* it under the terms of the GNU Affero General Public License as
|
|
365
|
+
* published by the Free Software Foundation, either version 3 of the
|
|
366
|
+
* License, or (at your option) any later version.
|
|
367
|
+
*
|
|
368
|
+
* This program is distributed in the hope that it will be useful,
|
|
369
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
370
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
371
|
+
* GNU Affero General Public License for more details.
|
|
372
|
+
*
|
|
373
|
+
* You should have received a copy of the GNU Affero General Public License
|
|
374
|
+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
375
|
+
*
|
|
376
|
+
*/
|
|
377
|
+
var Node = /** @class */ (function () {
|
|
378
|
+
function Node(data, davService) {
|
|
379
|
+
this._knownDavService = /(remote|public)\.php\/(web)?dav/i;
|
|
380
|
+
// Validate data
|
|
381
|
+
validateData(data);
|
|
382
|
+
this._data = data;
|
|
383
|
+
this._attributes = data.attributes || {};
|
|
384
|
+
delete this._data.attributes;
|
|
385
|
+
if (davService) {
|
|
386
|
+
this._knownDavService = davService;
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
Object.defineProperty(Node.prototype, "source", {
|
|
390
|
+
/**
|
|
391
|
+
* Get the source url to this object
|
|
392
|
+
*/
|
|
393
|
+
get: function () {
|
|
394
|
+
// strip any ending slash
|
|
395
|
+
return this._data.source.replace(/\/$/i, '');
|
|
396
|
+
},
|
|
397
|
+
enumerable: false,
|
|
398
|
+
configurable: true
|
|
399
|
+
});
|
|
400
|
+
Object.defineProperty(Node.prototype, "basename", {
|
|
401
|
+
/**
|
|
402
|
+
* Get this object name
|
|
403
|
+
*/
|
|
404
|
+
get: function () {
|
|
405
|
+
return path.basename(this.source);
|
|
406
|
+
},
|
|
407
|
+
enumerable: false,
|
|
408
|
+
configurable: true
|
|
409
|
+
});
|
|
410
|
+
Object.defineProperty(Node.prototype, "extension", {
|
|
411
|
+
/**
|
|
412
|
+
* Get this object's extension
|
|
413
|
+
*/
|
|
414
|
+
get: function () {
|
|
415
|
+
return path.extname(this.source);
|
|
416
|
+
},
|
|
417
|
+
enumerable: false,
|
|
418
|
+
configurable: true
|
|
419
|
+
});
|
|
420
|
+
Object.defineProperty(Node.prototype, "dirname", {
|
|
421
|
+
/**
|
|
422
|
+
* Get the directory path leading to this object
|
|
423
|
+
*/
|
|
424
|
+
get: function () {
|
|
425
|
+
return path.dirname(this.source);
|
|
426
|
+
},
|
|
427
|
+
enumerable: false,
|
|
428
|
+
configurable: true
|
|
429
|
+
});
|
|
430
|
+
Object.defineProperty(Node.prototype, "mime", {
|
|
431
|
+
/**
|
|
432
|
+
* Get the file mime
|
|
433
|
+
*/
|
|
434
|
+
get: function () {
|
|
435
|
+
return this._data.mime;
|
|
436
|
+
},
|
|
437
|
+
enumerable: false,
|
|
438
|
+
configurable: true
|
|
439
|
+
});
|
|
440
|
+
Object.defineProperty(Node.prototype, "size", {
|
|
441
|
+
/**
|
|
442
|
+
* Get the file size
|
|
443
|
+
*/
|
|
444
|
+
get: function () {
|
|
445
|
+
return this._data.size;
|
|
446
|
+
},
|
|
447
|
+
enumerable: false,
|
|
448
|
+
configurable: true
|
|
449
|
+
});
|
|
450
|
+
Object.defineProperty(Node.prototype, "attributes", {
|
|
451
|
+
/**
|
|
452
|
+
* Get the file attribute
|
|
453
|
+
*/
|
|
454
|
+
get: function () {
|
|
455
|
+
return this._attributes;
|
|
456
|
+
},
|
|
457
|
+
enumerable: false,
|
|
458
|
+
configurable: true
|
|
459
|
+
});
|
|
460
|
+
Object.defineProperty(Node.prototype, "permissions", {
|
|
461
|
+
/**
|
|
462
|
+
* Get the file permissions
|
|
463
|
+
*/
|
|
464
|
+
get: function () {
|
|
465
|
+
// If this is not a dav ressource, we can only read it
|
|
466
|
+
if (this.owner === null && !this.isDavRessource) {
|
|
467
|
+
return exports.Permission.READ;
|
|
468
|
+
}
|
|
469
|
+
return this._data.permissions || exports.Permission.READ;
|
|
470
|
+
},
|
|
471
|
+
enumerable: false,
|
|
472
|
+
configurable: true
|
|
473
|
+
});
|
|
474
|
+
Object.defineProperty(Node.prototype, "owner", {
|
|
475
|
+
/**
|
|
476
|
+
* Get the file owner
|
|
477
|
+
*/
|
|
478
|
+
get: function () {
|
|
479
|
+
// Remote ressources have no owner
|
|
480
|
+
if (!this.isDavRessource) {
|
|
481
|
+
return null;
|
|
482
|
+
}
|
|
483
|
+
return this._data.owner;
|
|
484
|
+
},
|
|
485
|
+
enumerable: false,
|
|
486
|
+
configurable: true
|
|
487
|
+
});
|
|
488
|
+
Object.defineProperty(Node.prototype, "isDavRessource", {
|
|
489
|
+
/**
|
|
490
|
+
* Is this a dav-related ressource ?
|
|
491
|
+
*/
|
|
492
|
+
get: function () {
|
|
493
|
+
return this.source.match(this._knownDavService) !== null;
|
|
494
|
+
},
|
|
495
|
+
enumerable: false,
|
|
496
|
+
configurable: true
|
|
497
|
+
});
|
|
498
|
+
Object.defineProperty(Node.prototype, "root", {
|
|
499
|
+
/**
|
|
500
|
+
* Get the dav root of this object
|
|
501
|
+
*/
|
|
502
|
+
get: function () {
|
|
503
|
+
if (this.isDavRessource) {
|
|
504
|
+
return this.dirname.split(this._knownDavService).pop() || null;
|
|
505
|
+
}
|
|
506
|
+
return null;
|
|
507
|
+
},
|
|
508
|
+
enumerable: false,
|
|
509
|
+
configurable: true
|
|
510
|
+
});
|
|
511
|
+
/**
|
|
512
|
+
* Move the node to a new destination
|
|
513
|
+
*
|
|
514
|
+
* @param {string} destination the new source.
|
|
515
|
+
* e.g. https://cloud.domain.com/remote.php/dav/files/emma/Photos/picture.jpg
|
|
516
|
+
*/
|
|
517
|
+
Node.prototype.move = function (destination) {
|
|
518
|
+
this._data.source = destination;
|
|
519
|
+
};
|
|
520
|
+
/**
|
|
521
|
+
* Rename the node
|
|
522
|
+
* This aliases the move method for easier usage
|
|
523
|
+
*/
|
|
524
|
+
Node.prototype.rename = function (basename) {
|
|
525
|
+
if (basename.includes('/')) {
|
|
526
|
+
throw new Error('Invalid basename');
|
|
527
|
+
}
|
|
528
|
+
this.move(this.dirname + '/' + basename);
|
|
529
|
+
};
|
|
530
|
+
return Node;
|
|
531
|
+
}());
|
|
532
|
+
|
|
533
|
+
var File = /** @class */ (function (_super) {
|
|
534
|
+
__extends(File, _super);
|
|
535
|
+
function File() {
|
|
536
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
537
|
+
}
|
|
538
|
+
Object.defineProperty(File.prototype, "type", {
|
|
539
|
+
get: function () {
|
|
540
|
+
return exports.FileType.File;
|
|
541
|
+
},
|
|
542
|
+
enumerable: false,
|
|
543
|
+
configurable: true
|
|
544
|
+
});
|
|
545
|
+
return File;
|
|
546
|
+
}(Node));
|
|
547
|
+
|
|
548
|
+
var Folder = /** @class */ (function (_super) {
|
|
549
|
+
__extends(Folder, _super);
|
|
550
|
+
function Folder(data) {
|
|
551
|
+
// enforcing mimes
|
|
552
|
+
return _super.call(this, __assign(__assign({}, data), { mime: 'httpd/unix-directory' })) || this;
|
|
553
|
+
}
|
|
554
|
+
Object.defineProperty(Folder.prototype, "type", {
|
|
555
|
+
get: function () {
|
|
556
|
+
return exports.FileType.Folder;
|
|
557
|
+
},
|
|
558
|
+
enumerable: false,
|
|
559
|
+
configurable: true
|
|
560
|
+
});
|
|
561
|
+
Object.defineProperty(Folder.prototype, "extension", {
|
|
562
|
+
get: function () {
|
|
563
|
+
return null;
|
|
564
|
+
},
|
|
565
|
+
enumerable: false,
|
|
566
|
+
configurable: true
|
|
567
|
+
});
|
|
568
|
+
Object.defineProperty(Folder.prototype, "mime", {
|
|
569
|
+
get: function () {
|
|
570
|
+
return 'httpd/unix-directory';
|
|
571
|
+
},
|
|
572
|
+
enumerable: false,
|
|
573
|
+
configurable: true
|
|
574
|
+
});
|
|
575
|
+
return Folder;
|
|
576
|
+
}(Node));
|
|
577
|
+
|
|
192
578
|
/**
|
|
193
579
|
* @copyright 2019 Christoph Wurst <christoph@winzerhof-wurst.at>
|
|
194
580
|
*
|
|
@@ -235,6 +621,8 @@ var getNewFileMenuEntries = function (context) {
|
|
|
235
621
|
return newFileMenu.getEntries(context);
|
|
236
622
|
};
|
|
237
623
|
|
|
624
|
+
exports.File = File;
|
|
625
|
+
exports.Folder = Folder;
|
|
238
626
|
exports.addNewFileMenuEntry = addNewFileMenuEntry;
|
|
239
627
|
exports.formatFileSize = formatFileSize;
|
|
240
628
|
exports.getNewFileMenuEntries = getNewFileMenuEntries;
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../lib/humanfilesize.ts","../lib/utils/logger.ts","../lib/newFileMenu.ts","../lib/index.ts"],"sourcesContent":["/**\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'];\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 */\nexport function formatFileSize(size: number|string, skipSmallSizes: boolean = false): string {\n\n\tif (typeof size === 'string') {\n\t\tsize = Number(size)\n\t}\n\n\t// Calculate Log with base 1024: size = 1024 ** order\n\tlet order = size > 0 ? Math.floor(Math.log(size) / Math.log(1024)) : 0;\n\t// Stay in range of the byte sizes that are defined\n\torder = Math.min(humanList.length - 1, order);\n\tconst readableFormat = humanList[order];\n\tlet relativeSize = (size / Math.pow(1024, order)).toFixed(1);\n\n\tif (skipSmallSizes === true && order === 0) {\n\t\tif (relativeSize !== '0.0') {\n\t\t\treturn '< 1 KB';\n\t\t} else {\n\t\t\treturn '0 KB';\n\t\t}\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 2019 Christoph Wurst <christoph@winzerhof-wurst.at>\n *\n * @author Christoph Wurst <christoph@winzerhof-wurst.at>\n *\n * @license AGPL-3.0-or-later\n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n *\n */\n\nimport { getCurrentUser } from '@nextcloud/auth'\nimport { getLoggerBuilder } from '@nextcloud/logger'\n\nconst getLogger = user => {\n\tif (user === null) {\n\t\treturn getLoggerBuilder()\n\t\t\t.setApp('files')\n\t\t\t.build()\n\t}\n\treturn getLoggerBuilder()\n\t\t.setApp('files')\n\t\t.setUid(user.uid)\n\t\t.build()\n}\n\nexport default getLogger(getCurrentUser())\n","/**\n * @copyright Copyright (c) 2021 John Molakvoæ <skjnldsv@protonmail.com>\n *\n * @author John Molakvoæ <skjnldsv@protonmail.com>\n *\n * @license AGPL-3.0-or-later\n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n *\n */\n\nimport logger from \"./utils/logger\"\n\nexport interface Entry {\n\t/** Unique ID */\n\tid: string\n\t/** Translatable string displayed in the menu */\n\tdisplayName: string\n\t// Default new file name\n\ttemplateName?: string\n\t// Condition wether this entry is shown or not\n\tif?: (context: Object) => Boolean\n\t/**\n\t * Either iconSvgInline or iconClass must be defined\n\t * Svg as inline string. <svg><path fill=\"...\" /></svg>\n\t */\n\ticonSvgInline?: string\n\t/** Existing icon css class */\n\ticonClass?: string\n\t/** Function to be run after creation */\n\thandler?: Function\n}\n\nexport class NewFileMenu {\n\tprivate _entries: Array<Entry> = []\n\t\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\t\t\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\t\n\t/**\n\t * Get the list of registered entries\n\t * \n\t * @param {FileInfo} context the creation context. Usually the current folder FileInfo\n\t */\n\tpublic getEntries(context?: Object): Array<Entry> {\n\t\tif (context) {\n\t\t\treturn this._entries\n\t\t\t\t.filter(entry => typeof entry.if === 'function' ? entry.if(context) : true)\n\t\t}\n\t\treturn this._entries\n\t}\n\n\tprivate getEntryIndex(id: string): number {\n\t\treturn this._entries.findIndex(entry => entry.id === id)\n\t}\n\n\tprivate validateEntry(entry: Entry) {\n\t\tif (!entry.id || !entry.displayName || !(entry.iconSvgInline || entry.iconClass)) {\n\t\t\tthrow new Error('Invalid entry')\n\t\t}\n\n\t\tif (typeof entry.id !== 'string'\n\t\t\t|| typeof entry.displayName !== 'string') {\n\t\t\tthrow new Error('Invalid id or displayName property')\n\t\t}\n\n\t\tif ((entry.iconClass && typeof entry.iconClass !== 'string')\n\t\t\t|| (entry.iconSvgInline && typeof entry.iconSvgInline !== 'string')) {\n\t\t\tthrow new Error('Invalid icon provided')\n\t\t}\n\n\t\tif (entry.if !== undefined && typeof entry.if !== 'function') {\n\t\t\tthrow new Error('Invalid if property')\n\t\t}\n\n\t\tif (entry.templateName && typeof entry.templateName !== 'string') {\n\t\t\tthrow new Error('Invalid templateName property')\n\t\t}\n\n\t\tif (entry.handler && typeof entry.handler !== 'function') {\n\t\t\tthrow new Error('Invalid handler property')\n\t\t}\n\n\t\tif (!entry.templateName && !entry.handler) {\n\t\t\tthrow new Error('At least a templateName or a handler must be provided')\n\t\t}\n\n\t\tif (this.getEntryIndex(entry.id) !== -1) {\n\t\t\tthrow new Error('Duplicate entry')\n\t\t}\n\t}\n}\n\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 * @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\nexport { formatFileSize } from './humanfilesize'\nexport { type Entry } from './newFileMenu'\nimport { type Entry, getNewFileMenu, NewFileMenu } from './newFileMenu'\n\ndeclare global {\n\tinterface Window {\n\t\tOC: any;\n\t\t_nc_newfilemenu: NewFileMenu;\n\t}\n}\n\n/**\n * Add a new menu entry to the upload manager menu\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 */\nexport const removeNewFileMenuEntry = function(entry: Entry | string) {\n\tconst newFileMenu = getNewFileMenu()\n\treturn newFileMenu.unregisterEntry(entry)\n}\n\n/**\n * Get the list of registered entries from the upload menu\n *\n * @param {FileInfo} context the creation context. Usually the current folder FileInfo\n */\nexport const getNewFileMenuEntries = function(context?: Object) {\n\tconst newFileMenu = getNewFileMenu()\n\treturn newFileMenu.getEntries(context)\n}\n"],"names":["getCanonicalLocale","getLoggerBuilder","getCurrentUser"],"mappings":";;;;;;;;AAAA;;;;;;;;;;;;;;;;;;;;;AAqBG;AAIH,IAAM,SAAS,GAAG,CAAC,GAAG,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;AAEhD;;;;;AAKG;AACa,SAAA,cAAc,CAAC,IAAmB,EAAE,cAA+B,EAAA;AAA/B,IAAA,IAAA,cAAA,KAAA,KAAA,CAAA,EAAA,EAAA,cAA+B,GAAA,KAAA,CAAA,EAAA;AAElF,IAAA,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE;AAC7B,QAAA,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,CAAA;AACnB,KAAA;;AAGD,IAAA,IAAI,KAAK,GAAG,IAAI,GAAG,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC;;AAEvE,IAAA,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,SAAS,CAAC,MAAM,GAAG,CAAC,EAAE,KAAK,CAAC,CAAC;AAC9C,IAAA,IAAM,cAAc,GAAG,SAAS,CAAC,KAAK,CAAC,CAAC;AACxC,IAAA,IAAI,YAAY,GAAG,CAAC,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE,KAAK,C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I,CAAC,aAAa,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,EAAE;AACxC,YAAA,MAAM,IAAI,KAAK,CAAC,iBAAiB,CAAC,CAAA;AAClC,SAAA;KACD,CAAA;IACF,OAAC,WAAA,CAAA;AAAD,CAAC,EAAA,CAAA,CAAA;AAEM,IAAM,cAAc,GAAG,YAAA;AAC7B,IAAA,IAAI,OAAO,MAAM,CAAC,eAAe,KAAK,WAAW,EAAE;AAClD,QAAA,MAAM,CAAC,eAAe,GAAG,IAAI,WAAW,EAAE,CAAA;AAC1C,QAAA,MAAM,CAAC,KAAK,CAAC,yBAAyB,CAAC,CAAA;AACvC,KAAA;IACD,OAAO,MAAM,CAAC,eAAe,CAAA;AAC9B,CAAC;;AC7HD;;;;;;;;;;;;;;;;;;;;;AAqBG;AAaH;;AAEG;AACI,IAAM,mBAAmB,GAAG,UAAS,KAAY,EAAA;AACvD,IAAA,IAAM,WAAW,GAAG,cAAc,EAAE,CAAA;AACpC,IAAA,OAAO,WAAW,CAAC,aAAa,CAAC,KAAK,CAAC,CAAA;AACxC,EAAC;AAED;;AAEG;AACI,IAAM,sBAAsB,GAAG,UAAS,KAAqB,EAAA;AACnE,IAAA,IAAM,WAAW,GAAG,cAAc,EAAE,CAAA;AACpC,IAAA,OAAO,WAAW,CAAC,eAAe,CAAC,KAAK,CAAC,CAAA;AAC1C,EAAC;AAED;;;;AAIG;AACI,IAAM,qBAAqB,GAAG,UAAS,OAAgB,EAAA;AAC7D,IAAA,IAAM,WAAW,GAAG,cAAc,EAAE,CAAA;AACpC,IAAA,OAAO,WAAW,CAAC,UAAU,CAAC,OAAO,CAAC,CAAA;AACvC;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../lib/humanfilesize.ts","../lib/utils/logger.ts","../lib/newFileMenu.ts","../lib/files/fileType.ts","../node_modules/tslib/tslib.es6.js","../lib/permissions.ts","../lib/files/nodeData.ts","../lib/files/node.ts","../lib/files/file.ts","../lib/files/folder.ts","../lib/index.ts"],"sourcesContent":["/**\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'];\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 */\nexport function formatFileSize(size: number|string, skipSmallSizes: boolean = false): string {\n\n\tif (typeof size === 'string') {\n\t\tsize = Number(size)\n\t}\n\n\t// Calculate Log with base 1024: size = 1024 ** order\n\tlet order = size > 0 ? Math.floor(Math.log(size) / Math.log(1024)) : 0;\n\t// Stay in range of the byte sizes that are defined\n\torder = Math.min(humanList.length - 1, order);\n\tconst readableFormat = humanList[order];\n\tlet relativeSize = (size / Math.pow(1024, order)).toFixed(1);\n\n\tif (skipSmallSizes === true && order === 0) {\n\t\tif (relativeSize !== '0.0') {\n\t\t\treturn '< 1 KB';\n\t\t} else {\n\t\t\treturn '0 KB';\n\t\t}\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 2019 Christoph Wurst <christoph@winzerhof-wurst.at>\n *\n * @author Christoph Wurst <christoph@winzerhof-wurst.at>\n *\n * @license AGPL-3.0-or-later\n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n *\n */\n\nimport { getCurrentUser } from '@nextcloud/auth'\nimport { getLoggerBuilder } from '@nextcloud/logger'\n\nconst getLogger = user => {\n\tif (user === null) {\n\t\treturn getLoggerBuilder()\n\t\t\t.setApp('files')\n\t\t\t.build()\n\t}\n\treturn getLoggerBuilder()\n\t\t.setApp('files')\n\t\t.setUid(user.uid)\n\t\t.build()\n}\n\nexport default getLogger(getCurrentUser())\n","/**\n * @copyright Copyright (c) 2021 John Molakvoæ <skjnldsv@protonmail.com>\n *\n * @author John Molakvoæ <skjnldsv@protonmail.com>\n *\n * @license AGPL-3.0-or-later\n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n *\n */\n\nimport logger from \"./utils/logger\"\n\nexport interface Entry {\n\t/** Unique ID */\n\tid: string\n\t/** Translatable string displayed in the menu */\n\tdisplayName: string\n\t// Default new file name\n\ttemplateName?: string\n\t// Condition wether this entry is shown or not\n\tif?: (context: Object) => Boolean\n\t/**\n\t * Either iconSvgInline or iconClass must be defined\n\t * Svg as inline string. <svg><path fill=\"...\" /></svg>\n\t */\n\ticonSvgInline?: string\n\t/** Existing icon css class */\n\ticonClass?: string\n\t/** Function to be run after creation */\n\thandler?: Function\n}\n\nexport class NewFileMenu {\n\tprivate _entries: Array<Entry> = []\n\t\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\t\t\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\t\n\t/**\n\t * Get the list of registered entries\n\t * \n\t * @param {FileInfo} context the creation context. Usually the current folder FileInfo\n\t */\n\tpublic getEntries(context?: Object): Array<Entry> {\n\t\tif (context) {\n\t\t\treturn this._entries\n\t\t\t\t.filter(entry => typeof entry.if === 'function' ? entry.if(context) : true)\n\t\t}\n\t\treturn this._entries\n\t}\n\n\tprivate getEntryIndex(id: string): number {\n\t\treturn this._entries.findIndex(entry => entry.id === id)\n\t}\n\n\tprivate validateEntry(entry: Entry) {\n\t\tif (!entry.id || !entry.displayName || !(entry.iconSvgInline || entry.iconClass)) {\n\t\t\tthrow new Error('Invalid entry')\n\t\t}\n\n\t\tif (typeof entry.id !== 'string'\n\t\t\t|| typeof entry.displayName !== 'string') {\n\t\t\tthrow new Error('Invalid id or displayName property')\n\t\t}\n\n\t\tif ((entry.iconClass && typeof entry.iconClass !== 'string')\n\t\t\t|| (entry.iconSvgInline && typeof entry.iconSvgInline !== 'string')) {\n\t\t\tthrow new Error('Invalid icon provided')\n\t\t}\n\n\t\tif (entry.if !== undefined && typeof entry.if !== 'function') {\n\t\t\tthrow new Error('Invalid if property')\n\t\t}\n\n\t\tif (entry.templateName && typeof entry.templateName !== 'string') {\n\t\t\tthrow new Error('Invalid templateName property')\n\t\t}\n\n\t\tif (entry.handler && typeof entry.handler !== 'function') {\n\t\t\tthrow new Error('Invalid handler property')\n\t\t}\n\n\t\tif (!entry.templateName && !entry.handler) {\n\t\t\tthrow new Error('At least a templateName or a handler must be provided')\n\t\t}\n\n\t\tif (this.getEntryIndex(entry.id) !== -1) {\n\t\t\tthrow new Error('Duplicate entry')\n\t\t}\n\t}\n}\n\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 * @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","/******************************************************************************\r\nCopyright (c) Microsoft Corporation.\r\n\r\nPermission to use, copy, modify, and/or distribute this software for any\r\npurpose with or without fee is hereby granted.\r\n\r\nTHE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\r\nREGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY\r\nAND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\r\nINDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM\r\nLOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR\r\nOTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\r\nPERFORMANCE OF THIS SOFTWARE.\r\n***************************************************************************** */\r\n/* global Reflect, Promise */\r\n\r\nvar extendStatics = function(d, b) {\r\n extendStatics = Object.setPrototypeOf ||\r\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\r\n function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };\r\n return extendStatics(d, b);\r\n};\r\n\r\nexport function __extends(d, b) {\r\n if (typeof b !== \"function\" && b !== null)\r\n throw new TypeError(\"Class extends value \" + String(b) + \" is not a constructor or null\");\r\n extendStatics(d, b);\r\n function __() { this.constructor = d; }\r\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\r\n}\r\n\r\nexport var __assign = function() {\r\n __assign = Object.assign || function __assign(t) {\r\n for (var s, i = 1, n = arguments.length; i < n; i++) {\r\n s = arguments[i];\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];\r\n }\r\n return t;\r\n }\r\n return __assign.apply(this, arguments);\r\n}\r\n\r\nexport function __rest(s, e) {\r\n var t = {};\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)\r\n t[p] = s[p];\r\n if (s != null && typeof Object.getOwnPropertySymbols === \"function\")\r\n for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {\r\n if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))\r\n t[p[i]] = s[p[i]];\r\n }\r\n return t;\r\n}\r\n\r\nexport function __decorate(decorators, target, key, desc) {\r\n var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;\r\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") r = Reflect.decorate(decorators, target, key, desc);\r\n else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\r\n return c > 3 && r && Object.defineProperty(target, key, r), r;\r\n}\r\n\r\nexport function __param(paramIndex, decorator) {\r\n return function (target, key) { decorator(target, key, paramIndex); }\r\n}\r\n\r\nexport function __metadata(metadataKey, metadataValue) {\r\n if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(metadataKey, metadataValue);\r\n}\r\n\r\nexport function __awaiter(thisArg, _arguments, P, generator) {\r\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\r\n return new (P || (P = Promise))(function (resolve, reject) {\r\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\r\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\r\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\r\n step((generator = generator.apply(thisArg, _arguments || [])).next());\r\n });\r\n}\r\n\r\nexport function __generator(thisArg, body) {\r\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\r\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\r\n function verb(n) { return function (v) { return step([n, v]); }; }\r\n function step(op) {\r\n if (f) throw new TypeError(\"Generator is already executing.\");\r\n while (_) try {\r\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\r\n if (y = 0, t) op = [op[0] & 2, t.value];\r\n switch (op[0]) {\r\n case 0: case 1: t = op; break;\r\n case 4: _.label++; return { value: op[1], done: false };\r\n case 5: _.label++; y = op[1]; op = [0]; continue;\r\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\r\n default:\r\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\r\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\r\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\r\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\r\n if (t[2]) _.ops.pop();\r\n _.trys.pop(); continue;\r\n }\r\n op = body.call(thisArg, _);\r\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\r\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\r\n }\r\n}\r\n\r\nexport var __createBinding = Object.create ? (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n var desc = Object.getOwnPropertyDescriptor(m, k);\r\n if (!desc || (\"get\" in desc ? !m.__esModule : desc.writable || desc.configurable)) {\r\n desc = { enumerable: true, get: function() { return m[k]; } };\r\n }\r\n Object.defineProperty(o, k2, desc);\r\n}) : (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n o[k2] = m[k];\r\n});\r\n\r\nexport function __exportStar(m, o) {\r\n for (var p in m) if (p !== \"default\" && !Object.prototype.hasOwnProperty.call(o, p)) __createBinding(o, m, p);\r\n}\r\n\r\nexport function __values(o) {\r\n var s = typeof Symbol === \"function\" && Symbol.iterator, m = s && o[s], i = 0;\r\n if (m) return m.call(o);\r\n if (o && typeof o.length === \"number\") return {\r\n next: function () {\r\n if (o && i >= o.length) o = void 0;\r\n return { value: o && o[i++], done: !o };\r\n }\r\n };\r\n throw new TypeError(s ? \"Object is not iterable.\" : \"Symbol.iterator is not defined.\");\r\n}\r\n\r\nexport function __read(o, n) {\r\n var m = typeof Symbol === \"function\" && o[Symbol.iterator];\r\n if (!m) return o;\r\n var i = m.call(o), r, ar = [], e;\r\n try {\r\n while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);\r\n }\r\n catch (error) { e = { error: error }; }\r\n finally {\r\n try {\r\n if (r && !r.done && (m = i[\"return\"])) m.call(i);\r\n }\r\n finally { if (e) throw e.error; }\r\n }\r\n return ar;\r\n}\r\n\r\n/** @deprecated */\r\nexport function __spread() {\r\n for (var ar = [], i = 0; i < arguments.length; i++)\r\n ar = ar.concat(__read(arguments[i]));\r\n return ar;\r\n}\r\n\r\n/** @deprecated */\r\nexport function __spreadArrays() {\r\n for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;\r\n for (var r = Array(s), k = 0, i = 0; i < il; i++)\r\n for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)\r\n r[k] = a[j];\r\n return r;\r\n}\r\n\r\nexport function __spreadArray(to, from, pack) {\r\n if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {\r\n if (ar || !(i in from)) {\r\n if (!ar) ar = Array.prototype.slice.call(from, 0, i);\r\n ar[i] = from[i];\r\n }\r\n }\r\n return to.concat(ar || Array.prototype.slice.call(from));\r\n}\r\n\r\nexport function __await(v) {\r\n return this instanceof __await ? (this.v = v, this) : new __await(v);\r\n}\r\n\r\nexport function __asyncGenerator(thisArg, _arguments, generator) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var g = generator.apply(thisArg, _arguments || []), i, q = [];\r\n return i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i;\r\n function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }\r\n function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }\r\n function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }\r\n function fulfill(value) { resume(\"next\", value); }\r\n function reject(value) { resume(\"throw\", value); }\r\n function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }\r\n}\r\n\r\nexport function __asyncDelegator(o) {\r\n var i, p;\r\n return i = {}, verb(\"next\"), verb(\"throw\", function (e) { throw e; }), verb(\"return\"), i[Symbol.iterator] = function () { return this; }, i;\r\n function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === \"return\" } : f ? f(v) : v; } : f; }\r\n}\r\n\r\nexport function __asyncValues(o) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var m = o[Symbol.asyncIterator], i;\r\n return m ? m.call(o) : (o = typeof __values === \"function\" ? __values(o) : o[Symbol.iterator](), i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i);\r\n function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }\r\n function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }\r\n}\r\n\r\nexport function __makeTemplateObject(cooked, raw) {\r\n if (Object.defineProperty) { Object.defineProperty(cooked, \"raw\", { value: raw }); } else { cooked.raw = raw; }\r\n return cooked;\r\n};\r\n\r\nvar __setModuleDefault = Object.create ? (function(o, v) {\r\n Object.defineProperty(o, \"default\", { enumerable: true, value: v });\r\n}) : function(o, v) {\r\n o[\"default\"] = v;\r\n};\r\n\r\nexport function __importStar(mod) {\r\n if (mod && mod.__esModule) return mod;\r\n var result = {};\r\n if (mod != null) for (var k in mod) if (k !== \"default\" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);\r\n __setModuleDefault(result, mod);\r\n return result;\r\n}\r\n\r\nexport function __importDefault(mod) {\r\n return (mod && mod.__esModule) ? mod : { default: mod };\r\n}\r\n\r\nexport function __classPrivateFieldGet(receiver, state, kind, f) {\r\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a getter\");\r\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot read private member from an object whose class did not declare it\");\r\n return kind === \"m\" ? f : kind === \"a\" ? f.call(receiver) : f ? f.value : state.get(receiver);\r\n}\r\n\r\nexport function __classPrivateFieldSet(receiver, state, value, kind, f) {\r\n if (kind === \"m\") throw new TypeError(\"Private method is not writable\");\r\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a setter\");\r\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot write private member to an object whose class did not declare it\");\r\n return (kind === \"a\" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;\r\n}\r\n\r\nexport function __classPrivateFieldIn(state, receiver) {\r\n if (receiver === null || (typeof receiver !== \"object\" && typeof receiver !== \"function\")) throw new TypeError(\"Cannot use 'in' operator on non-object\");\r\n return typeof state === \"function\" ? receiver === state : state.has(receiver);\r\n}\r\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\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) 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 { Permission } from \"../permissions\"\n\nexport interface Attribute { [key: string]: any }\n\nexport default interface NodeData {\n\t/** Unique ID */\n\tid?: number\n\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 */\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 \n/**\n * Validate Node construct data\n */\nexport const validateData = (data: NodeData) => {\n\tif ('id' in data && (typeof data.id !== 'number' || data.id < 0)) {\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\tif (!data.source.startsWith('http')) {\n\t\tthrow new Error('Invalid source format')\n\t}\n\n\tif ('mtime' in data && !(data.mtime instanceof Date)) {\n\t\tthrow new Error('Invalid mtime type')\n\t}\n\n\tif ('crtime' in data && !(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\tif ('size' in data && typeof data.size !== 'number') {\n\t\tthrow new Error('Invalid size type')\n\t}\n\n\tif ('permissions' in data && !(\n\t\t\ttypeof 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 ('owner' in data\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 ('attributes' in data && typeof data.attributes !== 'object') {\n\t\tthrow new Error('Invalid attributes format')\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 NodeData, { Attribute, validateData } from './nodeData'\n\nexport default abstract class Node {\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)\n\n\t\tthis._data = data\n\t\tthis._attributes = data.attributes || {} as any\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 */\n\tget dirname(): string {\n\t\treturn dirname(this.source)\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 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\treturn this._data.permissions || Permission.READ\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 this.source.match(this._knownDavService) !== null\n\t}\n\n\t/**\n\t * Get the dav root of this object\n\t */\n\tget root(): string|null {\n\t\tif (this.isDavRessource) {\n\t\t\treturn this.dirname.split(this._knownDavService).pop() || null\n\t\t}\n\t\treturn null\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\tthis._data.source = destination\n\t}\n\n\t/**\n\t * Rename the node\n\t * This aliases the move method for easier usage\n\t */\n\trename(basename) {\n\t\tif (basename.includes('/')) {\n\t\t\tthrow new Error('Invalid basename')\n\t\t}\n\t\tthis.move(this.dirname + '/' + basename)\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 { FileType } from './fileType'\nimport Node from './node'\n\nexport class File extends Node {\n\tget type(): FileType {\n\t\treturn FileType.File\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 { FileType } from './fileType'\nimport Node from './node'\nimport NodeData from './nodeData'\n\nexport class Folder extends Node {\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 * @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\nexport { formatFileSize } from './humanfilesize'\nexport { type Entry } from './newFileMenu'\nimport { type Entry, getNewFileMenu, NewFileMenu } from './newFileMenu'\n\nexport { FileType } from './files/fileType'\nexport { File } from './files/file'\nexport { Folder } from './files/folder'\nexport { Permission } from './permissions'\n\ndeclare global {\n\tinterface Window {\n\t\tOC: any;\n\t\t_nc_newfilemenu: NewFileMenu;\n\t}\n}\n\n/**\n * Add a new menu entry to the upload manager menu\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 */\nexport const removeNewFileMenuEntry = function(entry: Entry | string) {\n\tconst newFileMenu = getNewFileMenu()\n\treturn newFileMenu.unregisterEntry(entry)\n}\n\n/**\n * Get the list of registered entries from the upload menu\n *\n * @param {FileInfo} context the creation context. Usually the current folder FileInfo\n */\nexport const getNewFileMenuEntries = function(context?: Object) {\n\tconst newFileMenu = getNewFileMenu()\n\treturn newFileMenu.getEntries(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AAE,CAAA;AACpC,IAAA,OAAO,WAAW,CAAC,aAAa,CAAC,KAAK,CAAC,CAAA;AACxC,EAAC;AAED;;AAEG;AACI,IAAM,sBAAsB,GAAG,UAAS,KAAqB,EAAA;AACnE,IAAA,IAAM,WAAW,GAAG,cAAc,EAAE,CAAA;AACpC,IAAA,OAAO,WAAW,CAAC,eAAe,CAAC,KAAK,CAAC,CAAA;AAC1C,EAAC;AAED;;;;AAIG;AACI,IAAM,qBAAqB,GAAG,UAAS,OAAgB,EAAA;AAC7D,IAAA,IAAM,WAAW,GAAG,cAAc,EAAE,CAAA;AACpC,IAAA,OAAO,WAAW,CAAC,UAAU,CAAC,OAAO,CAAC,CAAA;AACvC;;;;;;;;;"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @copyright Copyright (c) 2022 John Molakvoæ <skjnldsv@protonmail.com>
|
|
3
|
+
*
|
|
4
|
+
* @author John Molakvoæ <skjnldsv@protonmail.com>
|
|
5
|
+
*
|
|
6
|
+
* @license AGPL-3.0-or-later
|
|
7
|
+
*
|
|
8
|
+
* This program is free software: you can redistribute it and/or modify
|
|
9
|
+
* it under the terms of the GNU Affero General Public License as
|
|
10
|
+
* published by the Free Software Foundation, either version 3 of the
|
|
11
|
+
* License, or (at your option) any later version.
|
|
12
|
+
*
|
|
13
|
+
* This program is distributed in the hope that it will be useful,
|
|
14
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
15
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
16
|
+
* GNU Affero General Public License for more details.
|
|
17
|
+
*
|
|
18
|
+
* You should have received a copy of the GNU Affero General Public License
|
|
19
|
+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
20
|
+
*
|
|
21
|
+
*/
|
|
22
|
+
export declare enum Permission {
|
|
23
|
+
NONE = 0,
|
|
24
|
+
CREATE = 4,
|
|
25
|
+
READ = 1,
|
|
26
|
+
UPDATE = 2,
|
|
27
|
+
DELETE = 8,
|
|
28
|
+
SHARE = 16,
|
|
29
|
+
ALL = 31
|
|
30
|
+
}
|