@nuvix/storage 1.0.1 → 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 -469
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +2 -7360
- package/dist/src/device/local.d.ts +49 -0
- package/dist/src/device/local.d.ts.map +1 -0
- package/dist/src/device/minio.d.ts +22 -0
- package/dist/src/device/minio.d.ts.map +1 -0
- package/dist/src/device/s3.d.ts +104 -0
- package/dist/src/device/s3.d.ts.map +1 -0
- package/dist/src/device/wasabi.d.ts +26 -0
- package/dist/src/device/wasabi.d.ts.map +1 -0
- package/dist/src/device.d.ts +118 -0
- package/dist/src/device.d.ts.map +1 -0
- package/dist/src/errors.d.ts +15 -0
- package/dist/src/errors.d.ts.map +1 -0
- package/dist/src/storage.d.ts +44 -0
- package/dist/src/storage.d.ts.map +1 -0
- package/dist/src/validator/file-ext.d.ts +15 -0
- package/dist/src/validator/file-ext.d.ts.map +1 -0
- package/dist/src/validator/file-name.d.ts +15 -0
- package/dist/src/validator/file-name.d.ts.map +1 -0
- package/dist/src/validator/file-size.d.ts +17 -0
- package/dist/src/validator/file-size.d.ts.map +1 -0
- package/dist/src/validator/file-type.d.ts +23 -0
- package/dist/src/validator/file-type.d.ts.map +1 -0
- package/dist/src/validator/file.d.ts +14 -0
- package/dist/src/validator/file.d.ts.map +1 -0
- package/dist/src/validator/upload.d.ts +15 -0
- package/dist/src/validator/upload.d.ts.map +1 -0
- package/dist/src/validator/validator.d.ts +8 -0
- package/dist/src/validator/validator.d.ts.map +1 -0
- package/package.json +22 -28
- package/dist/index.cjs +0 -7375
- package/dist/index.cjs.map +0 -1
- package/dist/index.d.cts +0 -469
- package/dist/index.js.map +0 -1
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { Device, DeviceMetadata, FileEntry, FileStat } from "../device.js";
|
|
2
|
+
/**
|
|
3
|
+
* Local filesystem storage device built on Bun's native file APIs
|
|
4
|
+
* (`Bun.file`, `Bun.write`). Directory operations use Bun's built-in
|
|
5
|
+
* Node-compatible `node:fs` module.
|
|
6
|
+
*/
|
|
7
|
+
export declare class Local extends Device {
|
|
8
|
+
protected root: string;
|
|
9
|
+
constructor(root?: string);
|
|
10
|
+
getName(): string;
|
|
11
|
+
getType(): string;
|
|
12
|
+
getDescription(): string;
|
|
13
|
+
getRoot(): string;
|
|
14
|
+
getPath(filename: string, _prefix?: string): string;
|
|
15
|
+
upload(source: string, filePath: string, chunk?: number, chunks?: number, _metadata?: DeviceMetadata): Promise<number>;
|
|
16
|
+
uploadData(data: string | Buffer, filePath: string, _contentType: string, chunk?: number, chunks?: number, _metadata?: DeviceMetadata): Promise<number>;
|
|
17
|
+
/**
|
|
18
|
+
* Abort a chunked upload: remove staged parts and any partial target.
|
|
19
|
+
*/
|
|
20
|
+
abort(filePath: string, _extra?: string): Promise<boolean>;
|
|
21
|
+
read(filePath: string, offset?: number, length?: number): Promise<Buffer>;
|
|
22
|
+
write(filePath: string, data: string | Buffer, _contentType?: string): Promise<boolean>;
|
|
23
|
+
/**
|
|
24
|
+
* Move a file within the local device using an atomic rename.
|
|
25
|
+
*/
|
|
26
|
+
move(source: string, target: string): Promise<boolean>;
|
|
27
|
+
delete(filePath: string, recursive?: boolean): Promise<boolean>;
|
|
28
|
+
deletePath(filePath: string): Promise<boolean>;
|
|
29
|
+
exists(filePath: string): Promise<boolean>;
|
|
30
|
+
getFileSize(filePath: string): Promise<number>;
|
|
31
|
+
getFileMimeType(filePath: string): Promise<string>;
|
|
32
|
+
getFileHash(filePath: string): Promise<string>;
|
|
33
|
+
stat(filePath: string): Promise<FileStat>;
|
|
34
|
+
createDirectory(dirPath: string): Promise<boolean>;
|
|
35
|
+
getDirectorySize(dirPath: string): Promise<number>;
|
|
36
|
+
getPartitionFreeSpace(): Promise<number>;
|
|
37
|
+
getPartitionTotalSpace(): Promise<number>;
|
|
38
|
+
getFiles(dir: string): Promise<FileEntry[]>;
|
|
39
|
+
/**
|
|
40
|
+
* Concatenate staged parts into the final file and clean up.
|
|
41
|
+
*/
|
|
42
|
+
private joinChunks;
|
|
43
|
+
/**
|
|
44
|
+
* Count staged part files for a target path.
|
|
45
|
+
*/
|
|
46
|
+
private listParts;
|
|
47
|
+
private rename;
|
|
48
|
+
}
|
|
49
|
+
//# sourceMappingURL=local.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"local.d.ts","sourceRoot":"","sources":["../../../src/device/local.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAM3E;;;;GAIG;AACH,qBAAa,KAAM,SAAQ,MAAM;IAC/B,SAAS,CAAC,IAAI,EAAE,MAAM,CAAC;gBAEX,IAAI,SAAK;IAKrB,OAAO,IAAI,MAAM;IAIjB,OAAO,IAAI,MAAM;IAIjB,cAAc,IAAI,MAAM;IAIxB,OAAO,IAAI,MAAM;IAIjB,OAAO,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM;IAI7C,MAAM,CACV,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,MAAM,EAChB,KAAK,SAAI,EACT,MAAM,SAAI,EACV,SAAS,GAAE,cAAmB,GAC7B,OAAO,CAAC,MAAM,CAAC;IA8BZ,UAAU,CACd,IAAI,EAAE,MAAM,GAAG,MAAM,EACrB,QAAQ,EAAE,MAAM,EAChB,YAAY,EAAE,MAAM,EACpB,KAAK,SAAI,EACT,MAAM,SAAI,EACV,SAAS,GAAE,cAAmB,GAC7B,OAAO,CAAC,MAAM,CAAC;IAuBlB;;OAEG;IACG,KAAK,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,SAAK,GAAG,OAAO,CAAC,OAAO,CAAC;IAetD,IAAI,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,SAAI,EAAE,MAAM,CA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
|
+
* MinIO-specific options.
|
|
4
|
+
*/
|
|
5
|
+
export interface MinIOOptions extends Omit<S3Options, "endpoint"> {
|
|
6
|
+
/** MinIO server host, e.g. `localhost:9000`. Protocol prefixes are stripped. */
|
|
7
|
+
endpoint?: string;
|
|
8
|
+
/** Use HTTPS instead of HTTP. Default: false. */
|
|
9
|
+
useSSL?: boolean;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* MinIO object storage — an S3-compatible device pointing at a self-hosted
|
|
13
|
+
* MinIO server. Bun's S3Client uses path-style URLs for custom endpoints,
|
|
14
|
+
* which is exactly what MinIO expects.
|
|
15
|
+
*/
|
|
16
|
+
export declare class MinIO extends S3 {
|
|
17
|
+
constructor(options: MinIOOptions);
|
|
18
|
+
getName(): string;
|
|
19
|
+
getDescription(): string;
|
|
20
|
+
getType(): string;
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=minio.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"minio.d.ts","sourceRoot":"","sources":["../../../src/device/minio.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAGxC;;GAEG;AACH,MAAM,WAAW,YAAa,SAAQ,IAAI,CAAC,SAAS,EAAE,UAAU,CAAC;IAC/D,gFAAgF;IAChF,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,iDAAiD;IACjD,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;AAED;;;;GAIG;AACH,qBAAa,KAAM,SAAQ,EAAE;gBACf,OAAO,EAAE,YAAY;IAWjC,OAAO,IAAI,MAAM;IAIjB,cAAc,IAAI,MAAM;IAIxB,OAAO,IAAI,MAAM;CAGlB"}
|
|
@@ -0,0 +1,104 @@
|
|
|
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
|
+
*/
|
|
30
|
+
export declare class S3 extends Device {
|
|
31
|
+
static readonly US_EAST_1 = "us-east-1";
|
|
32
|
+
static readonly US_EAST_2 = "us-east-2";
|
|
33
|
+
static readonly US_WEST_1 = "us-west-1";
|
|
34
|
+
static readonly US_WEST_2 = "us-west-2";
|
|
35
|
+
static readonly AF_SOUTH_1 = "af-south-1";
|
|
36
|
+
static readonly AP_EAST_1 = "ap-east-1";
|
|
37
|
+
static readonly AP_SOUTH_1 = "ap-south-1";
|
|
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";
|
|
41
|
+
static readonly AP_SOUTHEAST_1 = "ap-southeast-1";
|
|
42
|
+
static readonly AP_SOUTHEAST_2 = "ap-southeast-2";
|
|
43
|
+
static readonly CA_CENTRAL_1 = "ca-central-1";
|
|
44
|
+
static readonly EU_CENTRAL_1 = "eu-central-1";
|
|
45
|
+
static readonly EU_WEST_1 = "eu-west-1";
|
|
46
|
+
static readonly EU_WEST_2 = "eu-west-2";
|
|
47
|
+
static readonly EU_WEST_3 = "eu-west-3";
|
|
48
|
+
static readonly EU_SOUTH_1 = "eu-south-1";
|
|
49
|
+
static readonly EU_NORTH_1 = "eu-north-1";
|
|
50
|
+
static readonly SA_EAST_1 = "sa-east-1";
|
|
51
|
+
static readonly CN_NORTH_1 = "cn-north-1";
|
|
52
|
+
static readonly CN_NORTHWEST_1 = "cn-northwest-1";
|
|
53
|
+
static readonly ME_SOUTH_1 = "me-south-1";
|
|
54
|
+
static readonly US_GOV_EAST_1 = "us-gov-east-1";
|
|
55
|
+
static readonly US_GOV_WEST_1 = "us-gov-west-1";
|
|
56
|
+
static readonly ACL_PRIVATE = "private";
|
|
57
|
+
static readonly ACL_PUBLIC_READ = "public-read";
|
|
58
|
+
static readonly ACL_PUBLIC_READ_WRITE = "public-read-write";
|
|
59
|
+
static readonly ACL_AUTHENTICATED_READ = "authenticated-read";
|
|
60
|
+
protected static readonly MAX_PAGE_SIZE = 1000;
|
|
61
|
+
protected readonly client: S3Client;
|
|
62
|
+
protected readonly root: string;
|
|
63
|
+
private readonly writerOptions;
|
|
64
|
+
constructor(options: S3Options);
|
|
65
|
+
getName(): string;
|
|
66
|
+
getType(): string;
|
|
67
|
+
getDescription(): string;
|
|
68
|
+
getRoot(): string;
|
|
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>;
|
|
75
|
+
read(path: string, offset?: number, length?: number): Promise<Buffer>;
|
|
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>;
|
|
83
|
+
deletePath(path: string): Promise<boolean>;
|
|
84
|
+
exists(path: string): Promise<boolean>;
|
|
85
|
+
stat(path: string): Promise<FileStat>;
|
|
86
|
+
getFileSize(path: string): Promise<number>;
|
|
87
|
+
getFileMimeType(path: string): Promise<string>;
|
|
88
|
+
getFileHash(path: string): Promise<string>;
|
|
89
|
+
presign(path: string, options?: PresignOptions): string;
|
|
90
|
+
createDirectory(_path: string): Promise<boolean>;
|
|
91
|
+
getDirectorySize(path: string): Promise<number>;
|
|
92
|
+
getPartitionFreeSpace(): Promise<number>;
|
|
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;
|
|
103
|
+
}
|
|
104
|
+
//# sourceMappingURL=s3.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"s3.d.ts","sourceRoot":"","sources":["../../../src/device/s3.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,KAAK,CAAC;AAC/B,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,SAAS,EAAE,QAAQ,EAAE,cAAc,E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D,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"}
|
|
@@ -0,0 +1,26 @@
|
|
|
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
|
+
*/
|
|
10
|
+
export declare class Wasabi extends S3 {
|
|
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";
|
|
15
|
+
static readonly AP_NORTHEAST_1 = "ap-northeast-1";
|
|
16
|
+
static readonly AP_NORTHEAST_2 = "ap-northeast-2";
|
|
17
|
+
static readonly EU_CENTRAL_1 = "eu-central-1";
|
|
18
|
+
static readonly EU_CENTRAL_2 = "eu-central-2";
|
|
19
|
+
static readonly EU_WEST_1 = "eu-west-1";
|
|
20
|
+
static readonly EU_WEST_2 = "eu-west-2";
|
|
21
|
+
constructor(options: WasabiOptions);
|
|
22
|
+
getName(): string;
|
|
23
|
+
getDescription(): string;
|
|
24
|
+
getType(): string;
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=wasabi.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|
|
@@ -0,0 +1,118 @@
|
|
|
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;
|
|
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
|
+
*/
|
|
38
|
+
export declare abstract class Device {
|
|
39
|
+
/**
|
|
40
|
+
* Max chunk size while transferring a file from one device to another.
|
|
41
|
+
*/
|
|
42
|
+
protected transferChunkSize: number;
|
|
43
|
+
/**
|
|
44
|
+
* Set the maximum chunk size used by `transfer`.
|
|
45
|
+
*/
|
|
46
|
+
setTransferChunkSize(chunkSize: number): void;
|
|
47
|
+
getTransferChunkSize(): number;
|
|
48
|
+
/** Storage device name. */
|
|
49
|
+
abstract getName(): string;
|
|
50
|
+
/** Storage device type (one of `Storage.DEVICE_*`). */
|
|
51
|
+
abstract getType(): string;
|
|
52
|
+
/** Human-readable description of the device. */
|
|
53
|
+
abstract getDescription(): string;
|
|
54
|
+
/** Root path/prefix under which all files are stored. */
|
|
55
|
+
abstract getRoot(): string;
|
|
56
|
+
/** Build the full internal path for a filename. */
|
|
57
|
+
abstract getPath(filename: string, prefix?: string): string;
|
|
58
|
+
/**
|
|
59
|
+
* Upload a local file to the given path.
|
|
60
|
+
* Returns the number of chunks written, or 0 on failure.
|
|
61
|
+
*/
|
|
62
|
+
abstract upload(source: string, path: string, chunk?: number, chunks?: number, metadata?: DeviceMetadata): Promise<number>;
|
|
63
|
+
/**
|
|
64
|
+
* Upload raw data to the given path.
|
|
65
|
+
* Returns the number of chunks written, or 0 on failure.
|
|
66
|
+
*/
|
|
67
|
+
abstract uploadData(data: string | Buffer, path: string, contentType: string, chunk?: number, chunks?: number, metadata?: DeviceMetadata): Promise<number>;
|
|
68
|
+
/** Abort an in-progress chunked upload and clean staged parts. */
|
|
69
|
+
abstract abort(path: string, extra?: string): Promise<boolean>;
|
|
70
|
+
/** Read a file (optionally a byte range) into memory. */
|
|
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>;
|
|
74
|
+
/**
|
|
75
|
+
* Transfer a file from this device to another device.
|
|
76
|
+
* Files larger than `transferChunkSize` are streamed in chunks.
|
|
77
|
+
*/
|
|
78
|
+
transfer(filePath: string, destination: string, device: Device): Promise<boolean>;
|
|
79
|
+
/**
|
|
80
|
+
* Move a file within this device: transfer then delete the source.
|
|
81
|
+
*/
|
|
82
|
+
move(source: string, target: string): Promise<boolean>;
|
|
83
|
+
/** Delete a file (or directory when `recursive`). */
|
|
84
|
+
abstract delete(path: string, recursive?: boolean): Promise<boolean>;
|
|
85
|
+
/** Delete everything under a directory path. */
|
|
86
|
+
abstract deletePath(path: string): Promise<boolean>;
|
|
87
|
+
/** Check whether a file exists. */
|
|
88
|
+
abstract exists(path: string): Promise<boolean>;
|
|
89
|
+
/** Get file size in bytes. */
|
|
90
|
+
abstract getFileSize(path: string): Promise<number>;
|
|
91
|
+
/** Get file MIME type. */
|
|
92
|
+
abstract getFileMimeType(path: string): Promise<string>;
|
|
93
|
+
/** Get file MD5 hash as hex string. */
|
|
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>;
|
|
97
|
+
/**
|
|
98
|
+
* Generate a presigned URL for temporary access.
|
|
99
|
+
* Only supported by cloud devices; throws `UNSUPPORTED_OPERATION` otherwise.
|
|
100
|
+
*/
|
|
101
|
+
presign(_path: string, _options?: PresignOptions): string;
|
|
102
|
+
/** Create a directory (recursive). Returns true on success or if it exists. */
|
|
103
|
+
abstract createDirectory(path: string): Promise<boolean>;
|
|
104
|
+
/** Total size in bytes of all files under a directory. -1 on error. */
|
|
105
|
+
abstract getDirectorySize(path: string): Promise<number>;
|
|
106
|
+
/** Free space on the backing partition. -1 when not applicable. */
|
|
107
|
+
abstract getPartitionFreeSpace(): Promise<number>;
|
|
108
|
+
/** Total space on the backing partition. -1 when not applicable. */
|
|
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[]>;
|
|
112
|
+
/**
|
|
113
|
+
* Resolve `../`, `.`, duplicate and mixed separators to a canonical
|
|
114
|
+
* absolute-looking path. Works on paths that do not exist yet.
|
|
115
|
+
*/
|
|
116
|
+
getAbsolutePath(path: string): string;
|
|
117
|
+
}
|
|
118
|
+
//# sourceMappingURL=device.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"device.d.ts","sourceRoot":"","sources":["../../src/device.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAErD;;GAEG;AACH,MAAM,WAAW,QAAQ;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,YAAY,CAAC,EAAE,IAAI,CAAC;CACrB;AAED;;GAEG;AACH,MAAM,WAAW,SAAS;IACxB,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,YAAY,CAAC,EAAE,IAAI,CA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,GAAG,OAAO,CAAC,MAAM,CAAC;IAEnD,iEAAiE;IACjE,QAAQ,CAAC,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,QAAQ,CAAC;IAE9C;;;OAGG;IACI,OAAO,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,cAAc,GAAG,MAAM;IAOhE,+EAA+E;IAC/E,QAAQ,CAAC,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAExD,uEAAuE;IACvE,QAAQ,CAAC,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAExD,mEAAmE;IACnE,QAAQ,CAAC,qBAAqB,IAAI,OAAO,CAAC,MAAM,CAAC;IAEjD,oEAAoE;IACpE,QAAQ,CAAC,sBAAsB,IAAI,OAAO,CAAC,MAAM,CAAC;IAElD,6EAA6E;IAC7E,QAAQ,CAAC,QAAQ,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,MAAM,EAAE,iBAAiB,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,EAAE,CAAC;IAE9F;;;OAGG;IACI,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM;CAgB7C"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 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"}
|
|
@@ -0,0 +1,44 @@
|
|
|
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
|
+
*/
|
|
8
|
+
export declare class Storage {
|
|
9
|
+
static readonly DEVICE_LOCAL = "local";
|
|
10
|
+
static readonly DEVICE_S3 = "s3";
|
|
11
|
+
static readonly DEVICE_WASABI = "wasabi";
|
|
12
|
+
static readonly DEVICE_MINIO = "minio";
|
|
13
|
+
private static devices;
|
|
14
|
+
/**
|
|
15
|
+
* Register a device under a name (replaces any existing registration).
|
|
16
|
+
*/
|
|
17
|
+
static setDevice(name: string, device: Device): void;
|
|
18
|
+
/**
|
|
19
|
+
* Get a registered device by name.
|
|
20
|
+
* @throws StorageError with code `DEVICE_NOT_FOUND` when missing.
|
|
21
|
+
*/
|
|
22
|
+
static getDevice(name: string): Device;
|
|
23
|
+
/**
|
|
24
|
+
* Check whether a device name is registered.
|
|
25
|
+
*/
|
|
26
|
+
static exists(name: string): boolean;
|
|
27
|
+
/**
|
|
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.
|
|
37
|
+
*
|
|
38
|
+
* @example
|
|
39
|
+
* Storage.human(1024); // "1.00kB" (metric)
|
|
40
|
+
* Storage.human(1024, 2, "binary"); // "1.00KiB"
|
|
41
|
+
*/
|
|
42
|
+
static human(bytes: number, decimals?: number, system?: "binary" | "metric"): string;
|
|
43
|
+
}
|
|
44
|
+
//# sourceMappingURL=storage.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Validator } from "./validator.js";
|
|
2
|
+
export declare class FileExt extends Validator {
|
|
3
|
+
static readonly TYPE_JPEG = "jpeg";
|
|
4
|
+
static readonly TYPE_JPG = "jpg";
|
|
5
|
+
static readonly TYPE_GIF = "gif";
|
|
6
|
+
static readonly TYPE_PNG = "png";
|
|
7
|
+
static readonly TYPE_GZIP = "gz";
|
|
8
|
+
static readonly TYPE_ZIP = "zip";
|
|
9
|
+
private allowed;
|
|
10
|
+
constructor(allowed: string[]);
|
|
11
|
+
getDescription(): string;
|
|
12
|
+
isValid(filename: string): boolean;
|
|
13
|
+
private getFileExtension;
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=file-ext.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Validator } from "./validator.js";
|
|
2
|
+
export declare class FileName extends Validator {
|
|
3
|
+
/**
|
|
4
|
+
* Get Description
|
|
5
|
+
*/
|
|
6
|
+
getDescription(): string;
|
|
7
|
+
/**
|
|
8
|
+
* The file name can only contain "a-z", "A-Z", "0-9" and "." and not empty.
|
|
9
|
+
*
|
|
10
|
+
* @param name - The filename to validate
|
|
11
|
+
* @returns boolean indicating if the filename is valid
|
|
12
|
+
*/
|
|
13
|
+
isValid(name: any): boolean;
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=file-name.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Validator } from "./validator.js";
|
|
2
|
+
export declare class FileSize extends Validator {
|
|
3
|
+
private max;
|
|
4
|
+
/**
|
|
5
|
+
* Max size in bytes
|
|
6
|
+
*/
|
|
7
|
+
constructor(max: number);
|
|
8
|
+
/**
|
|
9
|
+
* Get Description
|
|
10
|
+
*/
|
|
11
|
+
getDescription(): string;
|
|
12
|
+
/**
|
|
13
|
+
* Finds whether a file size is smaller than required limit.
|
|
14
|
+
*/
|
|
15
|
+
isValid(fileSize: any): boolean;
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=file-size.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { Validator } from "./validator.js";
|
|
2
|
+
export declare class FileType extends Validator {
|
|
3
|
+
/**
|
|
4
|
+
* File Types Constants.
|
|
5
|
+
*/
|
|
6
|
+
static readonly FILE_TYPE_JPEG = "jpeg";
|
|
7
|
+
static readonly FILE_TYPE_GIF = "gif";
|
|
8
|
+
static readonly FILE_TYPE_PNG = "png";
|
|
9
|
+
static readonly FILE_TYPE_GZIP = "gz";
|
|
10
|
+
/**
|
|
11
|
+
* Magic-byte signatures used to identify file content.
|
|
12
|
+
*/
|
|
13
|
+
private readonly types;
|
|
14
|
+
private readonly allowed;
|
|
15
|
+
constructor(allowed: string[]);
|
|
16
|
+
getDescription(): string;
|
|
17
|
+
/**
|
|
18
|
+
* Binary signature check: reads only the first few bytes of the file
|
|
19
|
+
* (via Bun.file slice) instead of loading the whole file into memory.
|
|
20
|
+
*/
|
|
21
|
+
isValid(path: string): Promise<boolean>;
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=file-type.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"file-type.d.ts","sourceRoot":"","sources":["../../../src/validator/file-type.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAE3C,qBAAa,QAAS,SAAQ,SAAS;IACrC;;OAEG;IACH,MAAM,CAAC,QAAQ,CAAC,cAAc,UAAU;IACxC,MAAM,CAAC,QAAQ,CAAC,aAAa,SAAS;IACtC,MAAM,CAAC,QAAQ,CAAC,aAAa,SAAS;IACtC,MAAM,CAAC,QAAQ,CAAC,cAAc,QAAQ;IAEtC;;OAEG;IACH,OAAO,CAAC,QAAQ,CAAC,KAAK,CAKpB;IAEF,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAW;gBAEvB,OAAO,EAAE,MAAM,EAAE;IAY7B,cAAc,IAAI,MAAM;IAIxB;;;OAGG;IACG,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;CAkB9C"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Validator } from "./validator.js";
|
|
2
|
+
export declare class File extends Validator {
|
|
3
|
+
getDescription(): string;
|
|
4
|
+
/**
|
|
5
|
+
* NOT MUCH RIGHT NOW.
|
|
6
|
+
*
|
|
7
|
+
* TODO think what to do here, currently only used for parameter to be present in SDKs
|
|
8
|
+
*
|
|
9
|
+
* @param name
|
|
10
|
+
* @return boolean
|
|
11
|
+
*/
|
|
12
|
+
isValid(_name: any): boolean;
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=file.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"file.d.ts","sourceRoot":"","sources":["../../../src/validator/file.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAE3C,qBAAa,IAAK,SAAQ,SAAS;IAC1B,cAAc,IAAI,MAAM;IAI/B;;;;;;;OAOG;IACI,OAAO,CAAC,KAAK,EAAE,GAAG,GAAG,OAAO;CAGpC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Validator } from "./validator.js";
|
|
2
|
+
export declare class Upload extends Validator {
|
|
3
|
+
/**
|
|
4
|
+
* Get Description
|
|
5
|
+
*/
|
|
6
|
+
getDescription(): string;
|
|
7
|
+
/**
|
|
8
|
+
* Check if a file is a valid upload file
|
|
9
|
+
*
|
|
10
|
+
* @param path - The file path to validate
|
|
11
|
+
* @returns Promise that resolves to true if valid upload file, false otherwise
|
|
12
|
+
*/
|
|
13
|
+
isValid(path: unknown): Promise<boolean>;
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=upload.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"upload.d.ts","sourceRoot":"","sources":["../../../src/validator/upload.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAG3C,qBAAa,MAAO,SAAQ,SAAS;IACnC;;OAEG;IACH,cAAc,IAAI,MAAM;IAIxB;;;;;OAKG;IACG,OAAO,CAAC,IAAI,EAAE,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC;CAY/C"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export declare abstract class Validator {
|
|
2
|
+
static TYPE_STRING: string;
|
|
3
|
+
static TYPE_ARRAY: string;
|
|
4
|
+
static TYPE_INTEGER: string;
|
|
5
|
+
static TYPE_BOOLEAN: string;
|
|
6
|
+
abstract isValid(value: any): boolean | Promise<boolean>;
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=validator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validator.d.ts","sourceRoot":"","sources":["../../../src/validator/validator.ts"],"names":[],"mappings":"AAAA,8BAAsB,SAAS;IAC7B,MAAM,CAAC,WAAW,SAAY;IAC9B,MAAM,CAAC,UAAU,SAAW;IAC5B,MAAM,CAAC,YAAY,SAAa;IAChC,MAAM,CAAC,YAAY,SAAa;IAEhC,QAAQ,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,GAAG,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC;CACzD"}
|