@nuvix/storage 1.0.0 → 2.0.0
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 +141 -275
- package/dist/index.d.ts +14 -470
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/src/device/local.d.ts +28 -10
- package/dist/src/device/local.d.ts.map +1 -1
- package/dist/src/device/minio.d.ts +16 -10
- package/dist/src/device/minio.d.ts.map +1 -1
- package/dist/src/device/s3.d.ts +63 -53
- package/dist/src/device/s3.d.ts.map +1 -1
- package/dist/src/device/wasabi.d.ts +13 -11
- package/dist/src/device/wasabi.d.ts.map +1 -1
- package/dist/src/device.d.ts +74 -102
- package/dist/src/device.d.ts.map +1 -1
- package/dist/src/errors.d.ts +15 -0
- package/dist/src/errors.d.ts.map +1 -0
- package/dist/src/storage.d.ts +23 -36
- package/dist/src/storage.d.ts.map +1 -1
- package/dist/src/validator/file-ext.d.ts +1 -1
- package/dist/src/validator/file-ext.d.ts.map +1 -1
- package/dist/src/validator/file-name.d.ts +1 -1
- package/dist/src/validator/file-name.d.ts.map +1 -1
- package/dist/src/validator/file-size.d.ts +1 -1
- package/dist/src/validator/file-size.d.ts.map +1 -1
- package/dist/src/validator/file-type.d.ts +4 -8
- package/dist/src/validator/file-type.d.ts.map +1 -1
- package/dist/src/validator/file.d.ts +2 -2
- package/dist/src/validator/file.d.ts.map +1 -1
- package/dist/src/validator/upload.d.ts +1 -1
- package/dist/src/validator/upload.d.ts.map +1 -1
- package/package.json +23 -35
- package/dist/index.cjs.js +0 -1296
- package/dist/index.cjs.js.map +0 -1
- package/dist/index.esm.js +0 -1283
- package/dist/index.esm.js.map +0 -1
package/dist/src/device/s3.d.ts
CHANGED
|
@@ -1,14 +1,33 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { S3Client } from "bun";
|
|
2
|
+
import { Device, DeviceMetadata, FileEntry, FileStat, PresignOptions } from "../device.js";
|
|
3
|
+
/**
|
|
4
|
+
* Configuration for the S3 device (also used by Wasabi and MinIO).
|
|
5
|
+
*/
|
|
6
|
+
export interface S3Options {
|
|
7
|
+
accessKeyId: string;
|
|
8
|
+
secretAccessKey: string;
|
|
9
|
+
bucket: string;
|
|
10
|
+
/** Prefix under which all files are stored. */
|
|
11
|
+
root?: string;
|
|
12
|
+
region?: string;
|
|
13
|
+
acl?: string;
|
|
14
|
+
/** Custom S3-compatible endpoint (e.g. MinIO, Wasabi). Path-style URLs are used automatically. */
|
|
15
|
+
endpoint?: string;
|
|
16
|
+
sessionToken?: string;
|
|
17
|
+
/** Multipart part size in bytes when assembling chunked uploads (min 5 MiB). Default: 5 MiB. */
|
|
18
|
+
partSize?: number;
|
|
19
|
+
/** Number of parts uploaded in parallel during assembly. Default: 5. */
|
|
20
|
+
queueSize?: number;
|
|
21
|
+
/** Retry attempts for failed part uploads. Default: 3. */
|
|
22
|
+
retry?: number;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* S3-compatible storage device built on Bun's native `S3Client`.
|
|
26
|
+
*
|
|
27
|
+
* SigV4 signing, XML parsing and multipart uploads are handled by Bun itself,
|
|
28
|
+
* so this class only maps the unified `Device` API onto S3 semantics.
|
|
29
|
+
*/
|
|
2
30
|
export declare class S3 extends Device {
|
|
3
|
-
static readonly METHOD_GET = "GET";
|
|
4
|
-
static readonly METHOD_POST = "POST";
|
|
5
|
-
static readonly METHOD_PUT = "PUT";
|
|
6
|
-
static readonly METHOD_PATCH = "PATCH";
|
|
7
|
-
static readonly METHOD_DELETE = "DELETE";
|
|
8
|
-
static readonly METHOD_HEAD = "HEAD";
|
|
9
|
-
static readonly METHOD_OPTIONS = "OPTIONS";
|
|
10
|
-
static readonly METHOD_CONNECT = "CONNECT";
|
|
11
|
-
static readonly METHOD_TRACE = "TRACE";
|
|
12
31
|
static readonly US_EAST_1 = "us-east-1";
|
|
13
32
|
static readonly US_EAST_2 = "us-east-2";
|
|
14
33
|
static readonly US_WEST_1 = "us-west-1";
|
|
@@ -16,21 +35,20 @@ export declare class S3 extends Device {
|
|
|
16
35
|
static readonly AF_SOUTH_1 = "af-south-1";
|
|
17
36
|
static readonly AP_EAST_1 = "ap-east-1";
|
|
18
37
|
static readonly AP_SOUTH_1 = "ap-south-1";
|
|
19
|
-
static readonly AP_NORTHEAST_3 = "ap-northeast-3";
|
|
20
|
-
static readonly AP_NORTHEAST_2 = "ap-northeast-2";
|
|
21
38
|
static readonly AP_NORTHEAST_1 = "ap-northeast-1";
|
|
39
|
+
static readonly AP_NORTHEAST_2 = "ap-northeast-2";
|
|
40
|
+
static readonly AP_NORTHEAST_3 = "ap-northeast-3";
|
|
22
41
|
static readonly AP_SOUTHEAST_1 = "ap-southeast-1";
|
|
23
42
|
static readonly AP_SOUTHEAST_2 = "ap-southeast-2";
|
|
24
43
|
static readonly CA_CENTRAL_1 = "ca-central-1";
|
|
25
44
|
static readonly EU_CENTRAL_1 = "eu-central-1";
|
|
26
45
|
static readonly EU_WEST_1 = "eu-west-1";
|
|
27
|
-
static readonly EU_SOUTH_1 = "eu-south-1";
|
|
28
46
|
static readonly EU_WEST_2 = "eu-west-2";
|
|
29
47
|
static readonly EU_WEST_3 = "eu-west-3";
|
|
48
|
+
static readonly EU_SOUTH_1 = "eu-south-1";
|
|
30
49
|
static readonly EU_NORTH_1 = "eu-north-1";
|
|
31
|
-
static readonly SA_EAST_1 = "
|
|
50
|
+
static readonly SA_EAST_1 = "sa-east-1";
|
|
32
51
|
static readonly CN_NORTH_1 = "cn-north-1";
|
|
33
|
-
static readonly CN_NORTH_4 = "cn-north-4";
|
|
34
52
|
static readonly CN_NORTHWEST_1 = "cn-northwest-1";
|
|
35
53
|
static readonly ME_SOUTH_1 = "me-south-1";
|
|
36
54
|
static readonly US_GOV_EAST_1 = "us-gov-east-1";
|
|
@@ -40,55 +58,47 @@ export declare class S3 extends Device {
|
|
|
40
58
|
static readonly ACL_PUBLIC_READ_WRITE = "public-read-write";
|
|
41
59
|
static readonly ACL_AUTHENTICATED_READ = "authenticated-read";
|
|
42
60
|
protected static readonly MAX_PAGE_SIZE = 1000;
|
|
43
|
-
protected
|
|
44
|
-
protected
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
protected bucket: string;
|
|
48
|
-
protected region: string;
|
|
49
|
-
protected acl: string;
|
|
50
|
-
protected root: string;
|
|
51
|
-
protected headers: Record<string, string>;
|
|
52
|
-
protected amzHeaders: Record<string, string>;
|
|
53
|
-
constructor(root: string, accessKey: string, secretKey: string, bucket: string, region?: string, acl?: string, endpointUrl?: string);
|
|
61
|
+
protected readonly client: S3Client;
|
|
62
|
+
protected readonly root: string;
|
|
63
|
+
private readonly writerOptions;
|
|
64
|
+
constructor(options: S3Options);
|
|
54
65
|
getName(): string;
|
|
55
66
|
getType(): string;
|
|
56
67
|
getDescription(): string;
|
|
57
68
|
getRoot(): string;
|
|
58
|
-
getPath(filename: string,
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
transfer(path: string, destination: string, device: Device): Promise<boolean>;
|
|
65
|
-
protected createMultipartUpload(path: string, contentType: string): Promise<string>;
|
|
66
|
-
protected uploadPart(data: Buffer, path: string, contentType: string, chunk: number, uploadId: string): Promise<string>;
|
|
67
|
-
protected completeMultipartUpload(path: string, uploadId: string, parts: Record<number, string>): Promise<boolean>;
|
|
68
|
-
abort(path: string, extra?: string): Promise<boolean>;
|
|
69
|
+
getPath(filename: string, _prefix?: string): string;
|
|
70
|
+
/**
|
|
71
|
+
* Map a user path to a full object key (root prefix applied).
|
|
72
|
+
*/
|
|
73
|
+
protected key(path: string): string;
|
|
74
|
+
write(path: string, data: string | Buffer, contentType?: string): Promise<boolean>;
|
|
69
75
|
read(path: string, offset?: number, length?: number): Promise<Buffer>;
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
76
|
+
upload(source: string, path: string, chunk?: number, chunks?: number, metadata?: DeviceMetadata): Promise<number>;
|
|
77
|
+
uploadData(data: string | Buffer, path: string, contentType: string, chunk?: number, chunks?: number, metadata?: DeviceMetadata): Promise<number>;
|
|
78
|
+
/**
|
|
79
|
+
* Abort a chunked upload: remove any staged part objects.
|
|
80
|
+
*/
|
|
81
|
+
abort(path: string, _extra?: string): Promise<boolean>;
|
|
82
|
+
delete(path: string, _recursive?: boolean): Promise<boolean>;
|
|
73
83
|
deletePath(path: string): Promise<boolean>;
|
|
74
84
|
exists(path: string): Promise<boolean>;
|
|
85
|
+
stat(path: string): Promise<FileStat>;
|
|
75
86
|
getFileSize(path: string): Promise<number>;
|
|
76
87
|
getFileMimeType(path: string): Promise<string>;
|
|
77
88
|
getFileHash(path: string): Promise<string>;
|
|
78
|
-
|
|
89
|
+
presign(path: string, options?: PresignOptions): string;
|
|
90
|
+
createDirectory(_path: string): Promise<boolean>;
|
|
79
91
|
getDirectorySize(path: string): Promise<number>;
|
|
80
92
|
getPartitionFreeSpace(): Promise<number>;
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
protected sha256(data: string | Buffer): string;
|
|
92
|
-
protected hmacSha256(data: string | Buffer, key: string | Buffer, encoding?: "hex" | "binary"): string | Buffer;
|
|
93
|
+
getPartitionTotalSpace(): Promise<number>;
|
|
94
|
+
getFiles(dir: string, max?: number, continuationToken?: string): Promise<FileEntry[]>;
|
|
95
|
+
/**
|
|
96
|
+
* Remove staged part objects after assembly or failure.
|
|
97
|
+
*/
|
|
98
|
+
private deleteStagedParts;
|
|
99
|
+
/**
|
|
100
|
+
* List and delete all staged parts matching a prefix (used by `abort`).
|
|
101
|
+
*/
|
|
102
|
+
private deleteStagedPartsByPrefix;
|
|
93
103
|
}
|
|
94
104
|
//# sourceMappingURL=s3.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"s3.d.ts","sourceRoot":"","sources":["../../../src/device/s3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AAG,OAAO,CAAC,MAAM,CAAC;IAI9C,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAKhD,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,GAAE,cAAmB,GAAG,MAAM;IAIrD,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAIhD,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAqB/C,qBAAqB,IAAI,OAAO,CAAC,MAAM,CAAC;IAIxC,sBAAsB,IAAI,OAAO,CAAC,MAAM,CAAC;IAIzC,QAAQ,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,SAAmB,EAAE,iBAAiB,SAAK,GAAG,OAAO,CAAC,SAAS,EAAE,CAAC;IAejG;;OAEG;YACW,iBAAiB;IAQ/B;;OAEG;YACW,yBAAyB;CAQxC"}
|
|
@@ -1,22 +1,24 @@
|
|
|
1
|
-
import { S3 } from "./s3";
|
|
1
|
+
import { S3, S3Options } from "./s3.js";
|
|
2
|
+
/**
|
|
3
|
+
* Wasabi-specific options. The endpoint is derived from the region.
|
|
4
|
+
*/
|
|
5
|
+
export type WasabiOptions = Omit<S3Options, "endpoint">;
|
|
6
|
+
/**
|
|
7
|
+
* Wasabi hot cloud storage — an S3-compatible device that only overrides
|
|
8
|
+
* the endpoint (`https://s3.{region}.wasabisys.com`).
|
|
9
|
+
*/
|
|
2
10
|
export declare class Wasabi extends S3 {
|
|
3
|
-
/**
|
|
4
|
-
* Regions constants
|
|
5
|
-
*/
|
|
6
11
|
static readonly US_WEST_1 = "us-west-1";
|
|
12
|
+
static readonly US_CENTRAL_1 = "us-central-1";
|
|
13
|
+
static readonly US_EAST_1 = "us-east-1";
|
|
14
|
+
static readonly US_EAST_2 = "us-east-2";
|
|
7
15
|
static readonly AP_NORTHEAST_1 = "ap-northeast-1";
|
|
8
16
|
static readonly AP_NORTHEAST_2 = "ap-northeast-2";
|
|
9
17
|
static readonly EU_CENTRAL_1 = "eu-central-1";
|
|
10
18
|
static readonly EU_CENTRAL_2 = "eu-central-2";
|
|
11
19
|
static readonly EU_WEST_1 = "eu-west-1";
|
|
12
20
|
static readonly EU_WEST_2 = "eu-west-2";
|
|
13
|
-
|
|
14
|
-
static readonly US_EAST_1 = "us-east-1";
|
|
15
|
-
static readonly US_EAST_2 = "us-east-2";
|
|
16
|
-
/**
|
|
17
|
-
* Wasabi Constructor
|
|
18
|
-
*/
|
|
19
|
-
constructor(root: string, accessKey: string, secretKey: string, bucket: string, region?: string, acl?: string);
|
|
21
|
+
constructor(options: WasabiOptions);
|
|
20
22
|
getName(): string;
|
|
21
23
|
getDescription(): string;
|
|
22
24
|
getType(): string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wasabi.d.ts","sourceRoot":"","sources":["../../../src/device/wasabi.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"wasabi.d.ts","sourceRoot":"","sources":["../../../src/device/wasabi.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAGxC;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG,IAAI,CAAC,SAAS,EAAE,UAAU,CAAC,CAAC;AAExD;;;GAGG;AACH,qBAAa,MAAO,SAAQ,EAAE;IAE5B,MAAM,CAAC,QAAQ,CAAC,SAAS,eAAe;IACxC,MAAM,CAAC,QAAQ,CAAC,YAAY,kBAAkB;IAC9C,MAAM,CAAC,QAAQ,CAAC,SAAS,eAAe;IACxC,MAAM,CAAC,QAAQ,CAAC,SAAS,eAAe;IACxC,MAAM,CAAC,QAAQ,CAAC,cAAc,oBAAoB;IAClD,MAAM,CAAC,QAAQ,CAAC,cAAc,oBAAoB;IAClD,MAAM,CAAC,QAAQ,CAAC,YAAY,kBAAkB;IAC9C,MAAM,CAAC,QAAQ,CAAC,YAAY,kBAAkB;IAC9C,MAAM,CAAC,QAAQ,CAAC,SAAS,eAAe;IACxC,MAAM,CAAC,QAAQ,CAAC,SAAS,eAAe;gBAE5B,OAAO,EAAE,aAAa;IAKlC,OAAO,IAAI,MAAM;IAIjB,cAAc,IAAI,MAAM;IAIxB,OAAO,IAAI,MAAM;CAGlB"}
|
package/dist/src/device.d.ts
CHANGED
|
@@ -1,146 +1,118 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Arbitrary key/value metadata carried across chunked upload calls.
|
|
3
|
+
*/
|
|
4
|
+
export type DeviceMetadata = Record<string, unknown>;
|
|
5
|
+
/**
|
|
6
|
+
* Stat information for a stored file.
|
|
7
|
+
*/
|
|
8
|
+
export interface FileStat {
|
|
9
|
+
size: number;
|
|
10
|
+
mimeType: string;
|
|
11
|
+
etag?: string;
|
|
12
|
+
lastModified?: Date;
|
|
3
13
|
}
|
|
14
|
+
/**
|
|
15
|
+
* A single entry returned by `getFiles`.
|
|
16
|
+
*/
|
|
17
|
+
export interface FileEntry {
|
|
18
|
+
key: string;
|
|
19
|
+
size?: number;
|
|
20
|
+
lastModified?: Date;
|
|
21
|
+
etag?: string;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Options accepted by `presign` where supported.
|
|
25
|
+
*/
|
|
26
|
+
export interface PresignOptions {
|
|
27
|
+
expiresIn?: number;
|
|
28
|
+
method?: "GET" | "POST" | "PUT" | "DELETE" | "HEAD";
|
|
29
|
+
acl?: string;
|
|
30
|
+
type?: string;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Abstract storage device.
|
|
34
|
+
*
|
|
35
|
+
* Every backend (local disk, S3, Wasabi, MinIO, ...) implements this contract,
|
|
36
|
+
* so callers can swap devices without changing application code.
|
|
37
|
+
*/
|
|
4
38
|
export declare abstract class Device {
|
|
5
39
|
/**
|
|
6
|
-
* Max chunk size while transferring file from one device to another
|
|
40
|
+
* Max chunk size while transferring a file from one device to another.
|
|
7
41
|
*/
|
|
8
42
|
protected transferChunkSize: number;
|
|
9
43
|
/**
|
|
10
|
-
*
|
|
11
|
-
*/
|
|
12
|
-
protected static readonly MAX_PAGE_SIZE: number;
|
|
13
|
-
/**
|
|
14
|
-
* Set Transfer Chunk Size
|
|
44
|
+
* Set the maximum chunk size used by `transfer`.
|
|
15
45
|
*/
|
|
16
46
|
setTransferChunkSize(chunkSize: number): void;
|
|
17
|
-
/**
|
|
18
|
-
* Get Transfer Chunk Size
|
|
19
|
-
*/
|
|
20
47
|
getTransferChunkSize(): number;
|
|
21
|
-
/**
|
|
22
|
-
* Get Name.
|
|
23
|
-
*
|
|
24
|
-
* Get storage device name
|
|
25
|
-
*/
|
|
48
|
+
/** Storage device name. */
|
|
26
49
|
abstract getName(): string;
|
|
27
|
-
/**
|
|
28
|
-
* Get Type.
|
|
29
|
-
*
|
|
30
|
-
* Get storage device type
|
|
31
|
-
*/
|
|
50
|
+
/** Storage device type (one of `Storage.DEVICE_*`). */
|
|
32
51
|
abstract getType(): string;
|
|
33
|
-
/**
|
|
34
|
-
* Get Description.
|
|
35
|
-
*
|
|
36
|
-
* Get storage device description and purpose.
|
|
37
|
-
*/
|
|
52
|
+
/** Human-readable description of the device. */
|
|
38
53
|
abstract getDescription(): string;
|
|
39
|
-
/**
|
|
40
|
-
* Get Root.
|
|
41
|
-
*
|
|
42
|
-
* Get storage device root path
|
|
43
|
-
*/
|
|
54
|
+
/** Root path/prefix under which all files are stored. */
|
|
44
55
|
abstract getRoot(): string;
|
|
45
|
-
/**
|
|
46
|
-
* Get Path.
|
|
47
|
-
*
|
|
48
|
-
* Each device hold a complex directory structure that is being build in this method.
|
|
49
|
-
*/
|
|
56
|
+
/** Build the full internal path for a filename. */
|
|
50
57
|
abstract getPath(filename: string, prefix?: string): string;
|
|
51
58
|
/**
|
|
52
|
-
* Upload.
|
|
53
|
-
*
|
|
54
|
-
* Upload a file to desired destination in the selected disk
|
|
55
|
-
* return number of chunks uploaded or 0 if it fails.
|
|
59
|
+
* Upload a local file to the given path.
|
|
60
|
+
* Returns the number of chunks written, or 0 on failure.
|
|
56
61
|
*/
|
|
57
62
|
abstract upload(source: string, path: string, chunk?: number, chunks?: number, metadata?: DeviceMetadata): Promise<number>;
|
|
58
63
|
/**
|
|
59
|
-
* Upload
|
|
60
|
-
*
|
|
61
|
-
* Upload file contents to desired destination in the selected disk.
|
|
62
|
-
* return number of chunks uploaded or 0 if it fails.
|
|
64
|
+
* Upload raw data to the given path.
|
|
65
|
+
* Returns the number of chunks written, or 0 on failure.
|
|
63
66
|
*/
|
|
64
67
|
abstract uploadData(data: string | Buffer, path: string, contentType: string, chunk?: number, chunks?: number, metadata?: DeviceMetadata): Promise<number>;
|
|
65
|
-
/**
|
|
66
|
-
* Abort Chunked Upload
|
|
67
|
-
*/
|
|
68
|
+
/** Abort an in-progress chunked upload and clean staged parts. */
|
|
68
69
|
abstract abort(path: string, extra?: string): Promise<boolean>;
|
|
69
|
-
/**
|
|
70
|
-
* Read file by given path.
|
|
71
|
-
*/
|
|
70
|
+
/** Read a file (optionally a byte range) into memory. */
|
|
72
71
|
abstract read(path: string, offset?: number, length?: number): Promise<Buffer>;
|
|
72
|
+
/** Write data to a path. Throws `StorageError` on failure. */
|
|
73
|
+
abstract write(path: string, data: string | Buffer, contentType?: string): Promise<boolean>;
|
|
73
74
|
/**
|
|
74
|
-
* Transfer
|
|
75
|
-
*
|
|
76
|
-
*/
|
|
77
|
-
abstract transfer(path: string, destination: string, device: Device): Promise<boolean>;
|
|
78
|
-
/**
|
|
79
|
-
* Write file by given path.
|
|
75
|
+
* Transfer a file from this device to another device.
|
|
76
|
+
* Files larger than `transferChunkSize` are streamed in chunks.
|
|
80
77
|
*/
|
|
81
|
-
|
|
78
|
+
transfer(filePath: string, destination: string, device: Device): Promise<boolean>;
|
|
82
79
|
/**
|
|
83
|
-
* Move file
|
|
80
|
+
* Move a file within this device: transfer then delete the source.
|
|
84
81
|
*/
|
|
85
82
|
move(source: string, target: string): Promise<boolean>;
|
|
86
|
-
/**
|
|
87
|
-
* Delete file in given path return true on success and false on failure.
|
|
88
|
-
*/
|
|
83
|
+
/** Delete a file (or directory when `recursive`). */
|
|
89
84
|
abstract delete(path: string, recursive?: boolean): Promise<boolean>;
|
|
90
|
-
/**
|
|
91
|
-
* Delete files in given path, path must be a directory. return true on success and false on failure.
|
|
92
|
-
*/
|
|
85
|
+
/** Delete everything under a directory path. */
|
|
93
86
|
abstract deletePath(path: string): Promise<boolean>;
|
|
94
|
-
/**
|
|
95
|
-
* Check if file exists
|
|
96
|
-
*/
|
|
87
|
+
/** Check whether a file exists. */
|
|
97
88
|
abstract exists(path: string): Promise<boolean>;
|
|
98
|
-
/**
|
|
99
|
-
* Returns given file path its size.
|
|
100
|
-
*/
|
|
89
|
+
/** Get file size in bytes. */
|
|
101
90
|
abstract getFileSize(path: string): Promise<number>;
|
|
102
|
-
/**
|
|
103
|
-
* Returns given file path its mime type.
|
|
104
|
-
*/
|
|
91
|
+
/** Get file MIME type. */
|
|
105
92
|
abstract getFileMimeType(path: string): Promise<string>;
|
|
106
|
-
/**
|
|
107
|
-
* Returns given file path its MD5 hash value.
|
|
108
|
-
*/
|
|
93
|
+
/** Get file MD5 hash as hex string. */
|
|
109
94
|
abstract getFileHash(path: string): Promise<string>;
|
|
95
|
+
/** Get size, MIME type and (when available) ETag in one call. */
|
|
96
|
+
abstract stat(path: string): Promise<FileStat>;
|
|
110
97
|
/**
|
|
111
|
-
*
|
|
112
|
-
*
|
|
113
|
-
* Returns true on success or if the directory already exists and false on error
|
|
98
|
+
* Generate a presigned URL for temporary access.
|
|
99
|
+
* Only supported by cloud devices; throws `UNSUPPORTED_OPERATION` otherwise.
|
|
114
100
|
*/
|
|
101
|
+
presign(_path: string, _options?: PresignOptions): string;
|
|
102
|
+
/** Create a directory (recursive). Returns true on success or if it exists. */
|
|
115
103
|
abstract createDirectory(path: string): Promise<boolean>;
|
|
116
|
-
/**
|
|
117
|
-
* Get directory size in bytes.
|
|
118
|
-
*
|
|
119
|
-
* Return -1 on error
|
|
120
|
-
*/
|
|
104
|
+
/** Total size in bytes of all files under a directory. -1 on error. */
|
|
121
105
|
abstract getDirectorySize(path: string): Promise<number>;
|
|
122
|
-
/**
|
|
123
|
-
* Get Partition Free Space.
|
|
124
|
-
*
|
|
125
|
-
* Returns available space on filesystem or disk partition
|
|
126
|
-
*/
|
|
106
|
+
/** Free space on the backing partition. -1 when not applicable. */
|
|
127
107
|
abstract getPartitionFreeSpace(): Promise<number>;
|
|
128
|
-
/**
|
|
129
|
-
* Get Partition Total Space.
|
|
130
|
-
*
|
|
131
|
-
* Returns the total size of a filesystem or disk partition
|
|
132
|
-
*/
|
|
108
|
+
/** Total space on the backing partition. -1 when not applicable. */
|
|
133
109
|
abstract getPartitionTotalSpace(): Promise<number>;
|
|
110
|
+
/** List files under a directory, paginated where the backend supports it. */
|
|
111
|
+
abstract getFiles(dir: string, max?: number, continuationToken?: string): Promise<FileEntry[]>;
|
|
134
112
|
/**
|
|
135
|
-
*
|
|
136
|
-
|
|
137
|
-
abstract getFiles(dir: string, max?: number, continuationToken?: string): Promise<any[]>;
|
|
138
|
-
/**
|
|
139
|
-
* Get the absolute path by resolving strings like ../, .., //, /\ and so on.
|
|
140
|
-
*
|
|
141
|
-
* Works like the realpath function but works on files that does not exist
|
|
113
|
+
* Resolve `../`, `.`, duplicate and mixed separators to a canonical
|
|
114
|
+
* absolute-looking path. Works on paths that do not exist yet.
|
|
142
115
|
*/
|
|
143
116
|
getAbsolutePath(path: string): string;
|
|
144
|
-
protected getMimeType(filePath: string): Promise<string>;
|
|
145
117
|
}
|
|
146
118
|
//# sourceMappingURL=device.d.ts.map
|
package/dist/src/device.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"device.d.ts","sourceRoot":"","sources":["../../src/device.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"device.d.ts","sourceRoot":"","sources":["../../src/device.ts"],"names":[],"mappings":"AAEA;;GAEG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Error codes thrown by storage devices.
|
|
3
|
+
*/
|
|
4
|
+
export type StorageErrorCode = "DEVICE_NOT_FOUND" | "FILE_NOT_FOUND" | "WRITE_FAILED" | "READ_FAILED" | "DELETE_FAILED" | "UPLOAD_FAILED" | "TRANSFER_FAILED" | "UNSUPPORTED_OPERATION" | "INVALID_CONFIG";
|
|
5
|
+
/**
|
|
6
|
+
* Typed error thrown by all storage devices.
|
|
7
|
+
*
|
|
8
|
+
* Lets callers branch on `error.code` instead of parsing messages.
|
|
9
|
+
*/
|
|
10
|
+
export declare class StorageError extends Error {
|
|
11
|
+
readonly code: StorageErrorCode;
|
|
12
|
+
readonly path?: string;
|
|
13
|
+
constructor(code: StorageErrorCode, message: string, path?: string);
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/errors.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,MAAM,gBAAgB,GACxB,kBAAkB,GAClB,gBAAgB,GAChB,cAAc,GACd,aAAa,GACb,eAAe,GACf,eAAe,GACf,iBAAiB,GACjB,uBAAuB,GACvB,gBAAgB,CAAC;AAErB;;;;GAIG;AACH,qBAAa,YAAa,SAAQ,KAAK;IACrC,QAAQ,CAAC,IAAI,EAAE,gBAAgB,CAAC;IAChC,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;gBAEX,IAAI,EAAE,gBAAgB,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM;CAMnE"}
|
package/dist/src/storage.d.ts
CHANGED
|
@@ -1,56 +1,43 @@
|
|
|
1
|
-
import { Device } from "./device";
|
|
1
|
+
import { Device } from "./device.js";
|
|
2
|
+
/**
|
|
3
|
+
* Central device registry.
|
|
4
|
+
*
|
|
5
|
+
* Register devices by name once at startup, then resolve them anywhere
|
|
6
|
+
* in the application via `Storage.getDevice`.
|
|
7
|
+
*/
|
|
2
8
|
export declare class Storage {
|
|
3
|
-
/**
|
|
4
|
-
* Supported devices
|
|
5
|
-
*/
|
|
6
9
|
static readonly DEVICE_LOCAL = "local";
|
|
7
10
|
static readonly DEVICE_S3 = "s3";
|
|
8
11
|
static readonly DEVICE_WASABI = "wasabi";
|
|
9
12
|
static readonly DEVICE_MINIO = "minio";
|
|
10
|
-
/**
|
|
11
|
-
* Devices.
|
|
12
|
-
*
|
|
13
|
-
* List of all available storage devices
|
|
14
|
-
*/
|
|
15
13
|
private static devices;
|
|
16
14
|
/**
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
* Add device by name
|
|
20
|
-
*
|
|
21
|
-
* @param name
|
|
22
|
-
* @param device
|
|
23
|
-
* @throws Error
|
|
15
|
+
* Register a device under a name (replaces any existing registration).
|
|
24
16
|
*/
|
|
25
17
|
static setDevice(name: string, device: Device): void;
|
|
26
18
|
/**
|
|
27
|
-
* Get
|
|
28
|
-
*
|
|
29
|
-
* Get device by name
|
|
30
|
-
*
|
|
31
|
-
* @param name
|
|
32
|
-
* @returns Device
|
|
33
|
-
* @throws Error
|
|
19
|
+
* Get a registered device by name.
|
|
20
|
+
* @throws StorageError with code `DEVICE_NOT_FOUND` when missing.
|
|
34
21
|
*/
|
|
35
22
|
static getDevice(name: string): Device;
|
|
36
23
|
/**
|
|
37
|
-
*
|
|
38
|
-
*
|
|
39
|
-
* Checks if given storage name is registered or not
|
|
40
|
-
*
|
|
41
|
-
* @param name
|
|
42
|
-
* @returns boolean
|
|
24
|
+
* Check whether a device name is registered.
|
|
43
25
|
*/
|
|
44
26
|
static exists(name: string): boolean;
|
|
45
27
|
/**
|
|
46
|
-
*
|
|
47
|
-
|
|
48
|
-
|
|
28
|
+
* Unregister a device. Returns true if it was registered.
|
|
29
|
+
*/
|
|
30
|
+
static removeDevice(name: string): boolean;
|
|
31
|
+
/**
|
|
32
|
+
* Names of all registered devices.
|
|
33
|
+
*/
|
|
34
|
+
static listDevices(): string[];
|
|
35
|
+
/**
|
|
36
|
+
* Format bytes as a human-readable size string.
|
|
49
37
|
*
|
|
50
|
-
* @
|
|
51
|
-
*
|
|
52
|
-
*
|
|
53
|
-
* @returns string
|
|
38
|
+
* @example
|
|
39
|
+
* Storage.human(1024); // "1.00kB" (metric)
|
|
40
|
+
* Storage.human(1024, 2, "binary"); // "1.00KiB"
|
|
54
41
|
*/
|
|
55
42
|
static human(bytes: number, decimals?: number, system?: "binary" | "metric"): string;
|
|
56
43
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"storage.d.ts","sourceRoot":"","sources":["../../src/storage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"storage.d.ts","sourceRoot":"","sources":["../../src/storage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAGrC;;;;;GAKG;AACH,qBAAa,OAAO;IAClB,MAAM,CAAC,QAAQ,CAAC,YAAY,WAAW;IACvC,MAAM,CAAC,QAAQ,CAAC,SAAS,QAAQ;IACjC,MAAM,CAAC,QAAQ,CAAC,aAAa,YAAY;IACzC,MAAM,CAAC,QAAQ,CAAC,YAAY,WAAW;IAEvC,OAAO,CAAC,MAAM,CAAC,OAAO,CAAkC;IAExD;;OAEG;IACH,MAAM,CAAC,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,IAAI;IAIpD;;;OAGG;IACH,MAAM,CAAC,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM;IAQtC;;OAEG;IACH,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;IAIpC;;OAEG;IACH,MAAM,CAAC,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;IAI1C;;OAEG;IACH,MAAM,CAAC,WAAW,IAAI,MAAM,EAAE;IAI9B;;;;;;OAMG;IACH,MAAM,CAAC,KAAK,CACV,KAAK,EAAE,MAAM,EACb,QAAQ,SAAI,EACZ,MAAM,GAAE,QAAQ,GAAG,QAAmB,GACrC,MAAM;CAYV"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"file-ext.d.ts","sourceRoot":"","sources":["../../../src/validator/file-ext.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"file-ext.d.ts","sourceRoot":"","sources":["../../../src/validator/file-ext.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAE3C,qBAAa,OAAQ,SAAQ,SAAS;IACpC,MAAM,CAAC,QAAQ,CAAC,SAAS,UAAU;IACnC,MAAM,CAAC,QAAQ,CAAC,QAAQ,SAAS;IACjC,MAAM,CAAC,QAAQ,CAAC,QAAQ,SAAS;IACjC,MAAM,CAAC,QAAQ,CAAC,QAAQ,SAAS;IACjC,MAAM,CAAC,QAAQ,CAAC,SAAS,QAAQ;IACjC,MAAM,CAAC,QAAQ,CAAC,QAAQ,SAAS;IAEjC,OAAO,CAAC,OAAO,CAAW;gBAEd,OAAO,EAAE,MAAM,EAAE;IAK7B,cAAc,IAAI,MAAM;IAIxB,OAAO,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO;IAKlC,OAAO,CAAC,gBAAgB;CAIzB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"file-name.d.ts","sourceRoot":"","sources":["../../../src/validator/file-name.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"file-name.d.ts","sourceRoot":"","sources":["../../../src/validator/file-name.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAE3C,qBAAa,QAAS,SAAQ,SAAS;IACrC;;OAEG;IACH,cAAc,IAAI,MAAM;IAIxB;;;;;OAKG;IACH,OAAO,CAAC,IAAI,EAAE,GAAG,GAAG,OAAO;CAe5B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"file-size.d.ts","sourceRoot":"","sources":["../../../src/validator/file-size.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"file-size.d.ts","sourceRoot":"","sources":["../../../src/validator/file-size.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAE3C,qBAAa,QAAS,SAAQ,SAAS;IACrC,OAAO,CAAC,GAAG,CAAS;IAEpB;;OAEG;gBACS,GAAG,EAAE,MAAM;IAKvB;;OAEG;IACH,cAAc,IAAI,MAAM;IAIxB;;OAEG;IACH,OAAO,CAAC,QAAQ,EAAE,GAAG,GAAG,OAAO;CAWhC"}
|