@arkstack/filesystem 0.19.1 → 0.19.3
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/README.md +6 -6
- package/dist/commands/StorageLinkCommand.js +1 -1
- package/dist/index.d.ts +4 -4
- package/dist/index.js +1 -1
- package/dist/{src-T2_ZZzAi.js → src-Ctmf9SXu.js} +83 -83
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -11,8 +11,8 @@ Filesystem module for Arkstack, providing shared file storage and filesystem uti
|
|
|
11
11
|
**CloudinaryFileDriver.ts**
|
|
12
12
|
|
|
13
13
|
```ts
|
|
14
|
-
import type { DriverContract, ObjectVisibility } from 'flydrive/types'
|
|
15
|
-
import type { CustomDiskConfig } from '@arkstack/filesystem'
|
|
14
|
+
import type { DriverContract, ObjectVisibility } from 'flydrive/types'
|
|
15
|
+
import type { CustomDiskConfig } from '@arkstack/filesystem'
|
|
16
16
|
|
|
17
17
|
export class CloudinaryFileDriver implements DriverContract {
|
|
18
18
|
constructor(private config?: CustomDiskConfig) {}
|
|
@@ -40,7 +40,7 @@ export class CloudinaryFileDriver implements DriverContract {
|
|
|
40
40
|
**src/config/filesystem.ts**
|
|
41
41
|
|
|
42
42
|
```ts
|
|
43
|
-
import { CloudinaryFileDriver } from '../CloudinaryFileDriver'
|
|
43
|
+
import { CloudinaryFileDriver } from '../CloudinaryFileDriver'
|
|
44
44
|
export default () => {
|
|
45
45
|
return {
|
|
46
46
|
default: 'images',
|
|
@@ -54,8 +54,8 @@ export default () => {
|
|
|
54
54
|
custom_drivers: {
|
|
55
55
|
cloudinary: CloudinaryFileDriver,
|
|
56
56
|
},
|
|
57
|
-
}
|
|
58
|
-
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
59
|
```
|
|
60
60
|
|
|
61
61
|
To improve type safety and auto complete, you may augment the `CustomDiskDriverRegistry`
|
|
@@ -65,7 +65,7 @@ To improve type safety and auto complete, you may augment the `CustomDiskDriverR
|
|
|
65
65
|
```ts
|
|
66
66
|
declare module '@arkstack/filesystem' {
|
|
67
67
|
interface CustomDiskDriverRegistry {
|
|
68
|
-
cloudinary: { cloud_name: string; api_key: string; api_secret: string }
|
|
68
|
+
cloudinary: { cloud_name: string; api_key: string; api_secret: string }
|
|
69
69
|
}
|
|
70
70
|
}
|
|
71
71
|
```
|
package/dist/index.d.ts
CHANGED
|
@@ -47,13 +47,13 @@ type CustomDiskConfig = keyof CustomDiskDriverRegistry extends never ? {
|
|
|
47
47
|
} : { [K in keyof CustomDiskDriverRegistry]: CustomDiskDriverRegistry[K] & {
|
|
48
48
|
driver: K;
|
|
49
49
|
}; }[keyof CustomDiskDriverRegistry];
|
|
50
|
-
type DiskConfig = LocalDriverConfig & {
|
|
50
|
+
type DiskConfig = (LocalDriverConfig & {
|
|
51
51
|
driver: 'local' | 'public';
|
|
52
|
-
} | FtpDriverConfig & {
|
|
52
|
+
}) | (FtpDriverConfig & {
|
|
53
53
|
driver: 'ftp';
|
|
54
|
-
} | S3DriverConfig & {
|
|
54
|
+
}) | (S3DriverConfig & {
|
|
55
55
|
driver: 's3';
|
|
56
|
-
} | CustomDiskConfig;
|
|
56
|
+
}) | CustomDiskConfig;
|
|
57
57
|
type DriverConfig<K extends 'ftp' | 'local' | 'gcs' | 's3' | (string & {}) = string & {}> = K extends 'ftp' ? FtpDriverConfig : K extends 's3' ? S3DriverConfig : K extends 'gcs' ? GcsDiskDriverConfig : K extends 'local' ? LocalDriverConfig : K extends keyof CustomDiskDriverRegistry ? CustomDiskDriverRegistry[K] : DiskConfig;
|
|
58
58
|
type KnownDisks = {
|
|
59
59
|
local: LocalDriverConfig & {
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as FtpDriver, t as Storage } from "./src-
|
|
1
|
+
import { n as FtpDriver, t as Storage } from "./src-Ctmf9SXu.js";
|
|
2
2
|
export { FtpDriver, Storage };
|
|
@@ -313,17 +313,17 @@ var Driver = class Driver {
|
|
|
313
313
|
}
|
|
314
314
|
/**
|
|
315
315
|
* Register a new custom driver
|
|
316
|
-
*
|
|
317
|
-
* @param name
|
|
318
|
-
* @param driver
|
|
316
|
+
*
|
|
317
|
+
* @param name
|
|
318
|
+
* @param driver
|
|
319
319
|
*/
|
|
320
320
|
static registerDriver(name, driver) {
|
|
321
321
|
Driver.customDrivers.set(name, driver);
|
|
322
322
|
}
|
|
323
323
|
/**
|
|
324
324
|
* Unregister a new custom driver
|
|
325
|
-
*
|
|
326
|
-
* @param name
|
|
325
|
+
*
|
|
326
|
+
* @param name
|
|
327
327
|
*/
|
|
328
328
|
static removeDriver(name) {
|
|
329
329
|
Driver.customDrivers.delete(name);
|
|
@@ -350,7 +350,7 @@ var Storage = class Storage {
|
|
|
350
350
|
}
|
|
351
351
|
/**
|
|
352
352
|
* Static method to get a disk instance directly from the Storage class without needing to instantiate it first.
|
|
353
|
-
*
|
|
353
|
+
*
|
|
354
354
|
* @param diskName The name of the disk to use. If not provided, the default disk will be used.
|
|
355
355
|
* @returns A Storage instance
|
|
356
356
|
*/
|
|
@@ -368,7 +368,7 @@ var Storage = class Storage {
|
|
|
368
368
|
}
|
|
369
369
|
/**
|
|
370
370
|
* Generate a unique name for the file based on random numbers and original extension
|
|
371
|
-
*
|
|
371
|
+
*
|
|
372
372
|
* @param file The file object containing the original name
|
|
373
373
|
* @returns A unique file name
|
|
374
374
|
*/
|
|
@@ -379,7 +379,7 @@ var Storage = class Storage {
|
|
|
379
379
|
};
|
|
380
380
|
/**
|
|
381
381
|
* Save the file to the storage and return the public URL and the file path
|
|
382
|
-
*
|
|
382
|
+
*
|
|
383
383
|
* @param file The file object containing the file data
|
|
384
384
|
* @param filePath The path where the file should be saved
|
|
385
385
|
* @param fileName The name to save the file as (optional)
|
|
@@ -390,7 +390,7 @@ var Storage = class Storage {
|
|
|
390
390
|
};
|
|
391
391
|
/**
|
|
392
392
|
* Save the file to the storage and return the public URL and the file path
|
|
393
|
-
*
|
|
393
|
+
*
|
|
394
394
|
* @param file The file object containing the file data
|
|
395
395
|
* @param filePath The path where the file should be saved
|
|
396
396
|
* @param fileName The name to save the file as (optional)
|
|
@@ -406,9 +406,9 @@ var Storage = class Storage {
|
|
|
406
406
|
};
|
|
407
407
|
/**
|
|
408
408
|
* Return a boolean indicating if the file exists
|
|
409
|
-
*
|
|
410
|
-
* @param key
|
|
411
|
-
* @returns
|
|
409
|
+
*
|
|
410
|
+
* @param key
|
|
411
|
+
* @returns
|
|
412
412
|
*/
|
|
413
413
|
exists(key) {
|
|
414
414
|
return this.driver.use().exists(key);
|
|
@@ -417,33 +417,33 @@ var Storage = class Storage {
|
|
|
417
417
|
* Return contents of a object for the given key as a UTF-8 string.
|
|
418
418
|
* Should throw "E_CANNOT_READ_FILE" error when the file
|
|
419
419
|
* does not exists.
|
|
420
|
-
*
|
|
421
|
-
* @param key
|
|
422
|
-
* @returns
|
|
420
|
+
*
|
|
421
|
+
* @param key
|
|
422
|
+
* @returns
|
|
423
423
|
*/
|
|
424
424
|
get(key) {
|
|
425
425
|
return this.driver.use().get(key);
|
|
426
426
|
}
|
|
427
427
|
/**
|
|
428
428
|
* Get the name of the disk currently in use.
|
|
429
|
-
*
|
|
430
|
-
* @returns
|
|
429
|
+
*
|
|
430
|
+
* @returns
|
|
431
431
|
*/
|
|
432
432
|
getDiskName() {
|
|
433
433
|
return this.diskName;
|
|
434
434
|
}
|
|
435
435
|
/**
|
|
436
436
|
* Get the name of the driver currently in use.
|
|
437
|
-
*
|
|
438
|
-
* @returns
|
|
437
|
+
*
|
|
438
|
+
* @returns
|
|
439
439
|
*/
|
|
440
440
|
getDriverName() {
|
|
441
441
|
return this.driverName;
|
|
442
442
|
}
|
|
443
443
|
/**
|
|
444
444
|
* Get the driver currently in use.
|
|
445
|
-
*
|
|
446
|
-
* @returns
|
|
445
|
+
*
|
|
446
|
+
* @returns
|
|
447
447
|
*/
|
|
448
448
|
getDriver() {
|
|
449
449
|
return this.driver;
|
|
@@ -452,9 +452,9 @@ var Storage = class Storage {
|
|
|
452
452
|
* Return contents of a object for the given key as a Readable stream.
|
|
453
453
|
* Should throw "E_CANNOT_READ_FILE" error when the file
|
|
454
454
|
* does not exists.
|
|
455
|
-
*
|
|
456
|
-
* @param key
|
|
457
|
-
* @returns
|
|
455
|
+
*
|
|
456
|
+
* @param key
|
|
457
|
+
* @returns
|
|
458
458
|
*/
|
|
459
459
|
getStream(key) {
|
|
460
460
|
return this.driver.use().getStream(key);
|
|
@@ -463,46 +463,46 @@ var Storage = class Storage {
|
|
|
463
463
|
* Return contents of an object for the given key as an Uint8Array.
|
|
464
464
|
* Should throw "E_CANNOT_READ_FILE" error when the file
|
|
465
465
|
* does not exists.
|
|
466
|
-
*
|
|
467
|
-
* @param key
|
|
468
|
-
* @returns
|
|
466
|
+
*
|
|
467
|
+
* @param key
|
|
468
|
+
* @returns
|
|
469
469
|
*/
|
|
470
470
|
getBytes(key) {
|
|
471
471
|
return this.driver.use().getBytes(key);
|
|
472
472
|
}
|
|
473
473
|
/**
|
|
474
474
|
* Return metadata of an object for the given key.
|
|
475
|
-
*
|
|
476
|
-
* @param key
|
|
477
|
-
* @returns
|
|
475
|
+
*
|
|
476
|
+
* @param key
|
|
477
|
+
* @returns
|
|
478
478
|
*/
|
|
479
479
|
getMetaData(key) {
|
|
480
480
|
return this.driver.use().getMetaData(key);
|
|
481
481
|
}
|
|
482
482
|
/**
|
|
483
483
|
* Return the visibility of the file
|
|
484
|
-
*
|
|
485
|
-
* @param key
|
|
486
|
-
* @returns
|
|
484
|
+
*
|
|
485
|
+
* @param key
|
|
486
|
+
* @returns
|
|
487
487
|
*/
|
|
488
488
|
getVisibility(key) {
|
|
489
489
|
return this.driver.use().getVisibility(key);
|
|
490
490
|
}
|
|
491
491
|
/**
|
|
492
492
|
* Return the public URL to access the file
|
|
493
|
-
*
|
|
494
|
-
* @param key
|
|
495
|
-
* @returns
|
|
493
|
+
*
|
|
494
|
+
* @param key
|
|
495
|
+
* @returns
|
|
496
496
|
*/
|
|
497
497
|
getUrl(key) {
|
|
498
498
|
return this.driver.use().getUrl(key);
|
|
499
499
|
}
|
|
500
500
|
/**
|
|
501
501
|
* Return the signed/temporary URL to access the file
|
|
502
|
-
*
|
|
503
|
-
* @param key
|
|
504
|
-
* @param options
|
|
505
|
-
* @returns
|
|
502
|
+
*
|
|
503
|
+
* @param key
|
|
504
|
+
* @param options
|
|
505
|
+
* @returns
|
|
506
506
|
*/
|
|
507
507
|
getSignedUrl(key, options) {
|
|
508
508
|
return this.driver.use().getSignedUrl(key, options);
|
|
@@ -510,20 +510,20 @@ var Storage = class Storage {
|
|
|
510
510
|
/**
|
|
511
511
|
* Return the signed/temporary URL that can be used to directly upload
|
|
512
512
|
* the file contents to the storage.
|
|
513
|
-
*
|
|
514
|
-
* @param key
|
|
515
|
-
* @param options
|
|
516
|
-
* @returns
|
|
513
|
+
*
|
|
514
|
+
* @param key
|
|
515
|
+
* @param options
|
|
516
|
+
* @returns
|
|
517
517
|
*/
|
|
518
518
|
getSignedUploadUrl(key, options) {
|
|
519
519
|
return this.driver.use().getSignedUploadUrl(key, options);
|
|
520
520
|
}
|
|
521
521
|
/**
|
|
522
522
|
* Update the visibility of the file
|
|
523
|
-
*
|
|
524
|
-
* @param key
|
|
525
|
-
* @param visibility
|
|
526
|
-
* @returns
|
|
523
|
+
*
|
|
524
|
+
* @param key
|
|
525
|
+
* @param visibility
|
|
526
|
+
* @returns
|
|
527
527
|
*/
|
|
528
528
|
setVisibility(key, visibility) {
|
|
529
529
|
return this.driver.use().setVisibility(key, visibility);
|
|
@@ -531,11 +531,11 @@ var Storage = class Storage {
|
|
|
531
531
|
/**
|
|
532
532
|
* Write object to the destination with the provided
|
|
533
533
|
* contents.
|
|
534
|
-
*
|
|
535
|
-
* @param key
|
|
536
|
-
* @param contents
|
|
537
|
-
* @param options
|
|
538
|
-
* @returns
|
|
534
|
+
*
|
|
535
|
+
* @param key
|
|
536
|
+
* @param contents
|
|
537
|
+
* @param options
|
|
538
|
+
* @returns
|
|
539
539
|
*/
|
|
540
540
|
put(key, contents, options) {
|
|
541
541
|
if (!(contents instanceof Uint8Array) && typeof contents !== "string") contents = contents.buffer;
|
|
@@ -544,11 +544,11 @@ var Storage = class Storage {
|
|
|
544
544
|
/**
|
|
545
545
|
* Write object to the destination with the provided
|
|
546
546
|
* contents as a readable stream
|
|
547
|
-
*
|
|
548
|
-
* @param key
|
|
549
|
-
* @param contents
|
|
550
|
-
* @param options
|
|
551
|
-
* @returns
|
|
547
|
+
*
|
|
548
|
+
* @param key
|
|
549
|
+
* @param contents
|
|
550
|
+
* @param options
|
|
551
|
+
* @returns
|
|
552
552
|
*/
|
|
553
553
|
putStream(key, contents, options) {
|
|
554
554
|
return this.driver.use().putStream(key, contents, options);
|
|
@@ -557,11 +557,11 @@ var Storage = class Storage {
|
|
|
557
557
|
* Copy the file from within the disk root location. Both
|
|
558
558
|
* the "source" and "destination" will be the key names
|
|
559
559
|
* and not absolute paths.
|
|
560
|
-
*
|
|
561
|
-
* @param source
|
|
562
|
-
* @param destination
|
|
563
|
-
* @param options
|
|
564
|
-
* @returns
|
|
560
|
+
*
|
|
561
|
+
* @param source
|
|
562
|
+
* @param destination
|
|
563
|
+
* @param options
|
|
564
|
+
* @returns
|
|
565
565
|
*/
|
|
566
566
|
copy(source, destination, options) {
|
|
567
567
|
return this.driver.use().copy(source, destination, options);
|
|
@@ -570,11 +570,11 @@ var Storage = class Storage {
|
|
|
570
570
|
* Move the file from within the disk root location. Both
|
|
571
571
|
* the "source" and "destination" will be the key names
|
|
572
572
|
* and not absolute paths.
|
|
573
|
-
*
|
|
574
|
-
* @param source
|
|
575
|
-
* @param destination
|
|
576
|
-
* @param options
|
|
577
|
-
* @returns
|
|
573
|
+
*
|
|
574
|
+
* @param source
|
|
575
|
+
* @param destination
|
|
576
|
+
* @param options
|
|
577
|
+
* @returns
|
|
578
578
|
*/
|
|
579
579
|
move(source, destination, options) {
|
|
580
580
|
return this.driver.use().move(source, destination, options);
|
|
@@ -582,18 +582,18 @@ var Storage = class Storage {
|
|
|
582
582
|
/**
|
|
583
583
|
* Delete the file for the given key. Should not throw
|
|
584
584
|
* error when file does not exist in first place
|
|
585
|
-
*
|
|
586
|
-
* @param key
|
|
587
|
-
* @returns
|
|
585
|
+
*
|
|
586
|
+
* @param key
|
|
587
|
+
* @returns
|
|
588
588
|
*/
|
|
589
589
|
delete(key) {
|
|
590
590
|
return this.driver.use().delete(key);
|
|
591
591
|
}
|
|
592
592
|
/**
|
|
593
593
|
* Delete the files and directories matching the provided prefix.
|
|
594
|
-
*
|
|
595
|
-
* @param prefix
|
|
596
|
-
* @returns
|
|
594
|
+
*
|
|
595
|
+
* @param prefix
|
|
596
|
+
* @returns
|
|
597
597
|
*/
|
|
598
598
|
deleteAll(prefix) {
|
|
599
599
|
return this.driver.use().deleteAll(prefix);
|
|
@@ -601,27 +601,27 @@ var Storage = class Storage {
|
|
|
601
601
|
/**
|
|
602
602
|
* The list all method must return an array of objects with
|
|
603
603
|
* the ability to paginate results (if supported).
|
|
604
|
-
*
|
|
605
|
-
* @param prefix
|
|
606
|
-
* @param options
|
|
607
|
-
* @returns
|
|
604
|
+
*
|
|
605
|
+
* @param prefix
|
|
606
|
+
* @param options
|
|
607
|
+
* @returns
|
|
608
608
|
*/
|
|
609
609
|
listAll(prefix, options) {
|
|
610
610
|
return this.driver.use().listAll(prefix, options);
|
|
611
611
|
}
|
|
612
612
|
/**
|
|
613
613
|
* Switch bucket at runtime if supported.
|
|
614
|
-
*
|
|
615
|
-
* @param bucket
|
|
616
|
-
* @returns
|
|
614
|
+
*
|
|
615
|
+
* @param bucket
|
|
616
|
+
* @returns
|
|
617
617
|
*/
|
|
618
618
|
bucket(bucket) {
|
|
619
619
|
return this.driver.use().bucket(bucket);
|
|
620
620
|
}
|
|
621
621
|
/**
|
|
622
622
|
* Create symbolic links for all configured links in the application configuration.
|
|
623
|
-
*
|
|
624
|
-
* @param param0
|
|
623
|
+
*
|
|
624
|
+
* @param param0
|
|
625
625
|
*/
|
|
626
626
|
static link({ force = false } = {}) {
|
|
627
627
|
for (const link in config("filesystem.links")) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@arkstack/filesystem",
|
|
3
|
-
"version": "0.19.
|
|
3
|
+
"version": "0.19.3",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Filesystem module for Arkstack, providing shared file storage and filesystem utitlities for the framework.",
|
|
6
6
|
"homepage": "https://arkstack.toneflix.net",
|
|
@@ -41,8 +41,8 @@
|
|
|
41
41
|
"@aws-sdk/s3-request-presigner": "^3.1011.0",
|
|
42
42
|
"flydrive": "^2.0.0",
|
|
43
43
|
"ssh2-sftp-client": "^12.1.0",
|
|
44
|
-
"@arkstack/common": "^0.19.
|
|
45
|
-
"@arkstack/contract": "^0.19.
|
|
44
|
+
"@arkstack/common": "^0.19.3",
|
|
45
|
+
"@arkstack/contract": "^0.19.3"
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
48
48
|
"@types/ssh2-sftp-client": "^9.0.6"
|