@alepha/bucket-s3 0.14.2 → 0.14.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/dist/index.d.ts
CHANGED
|
@@ -460,6 +460,7 @@ declare class EventManager {
|
|
|
460
460
|
protected events: Record<string, Array<Hook>>;
|
|
461
461
|
constructor(logFn?: () => LoggerInterface | undefined);
|
|
462
462
|
protected get log(): LoggerInterface | undefined;
|
|
463
|
+
clear(): void;
|
|
463
464
|
/**
|
|
464
465
|
* Registers a hook for the specified event.
|
|
465
466
|
*/
|
|
@@ -992,6 +993,34 @@ interface State {
|
|
|
992
993
|
"alepha.logger"?: LoggerInterface;
|
|
993
994
|
/**
|
|
994
995
|
* If defined, the Alepha container will only register this service and its dependencies.
|
|
996
|
+
*
|
|
997
|
+
* @example
|
|
998
|
+
* ```ts
|
|
999
|
+
* class MigrateCmd {
|
|
1000
|
+
* db = $inject(DatabaseProvider);
|
|
1001
|
+
* alepha = $inject(Alepha);
|
|
1002
|
+
* env = $env(
|
|
1003
|
+
* t.object({
|
|
1004
|
+
* MIGRATE: t.optional(t.boolean()),
|
|
1005
|
+
* }),
|
|
1006
|
+
* );
|
|
1007
|
+
*
|
|
1008
|
+
* constructor() {
|
|
1009
|
+
* if (this.env.MIGRATE) {
|
|
1010
|
+
* this.alepha.set("alepha.target", MigrateCmd);
|
|
1011
|
+
* }
|
|
1012
|
+
* }
|
|
1013
|
+
*
|
|
1014
|
+
* ready = $hook({
|
|
1015
|
+
* on: "ready",
|
|
1016
|
+
* handler: async () => {
|
|
1017
|
+
* if (this.env.MIGRATE) {
|
|
1018
|
+
* await this.db.migrate();
|
|
1019
|
+
* }
|
|
1020
|
+
* },
|
|
1021
|
+
* });
|
|
1022
|
+
* }
|
|
1023
|
+
* ```
|
|
995
1024
|
*/
|
|
996
1025
|
"alepha.target"?: Service;
|
|
997
1026
|
/**
|
|
@@ -1539,6 +1568,13 @@ interface LsOptions {
|
|
|
1539
1568
|
* FileSystem interface providing utilities for working with files.
|
|
1540
1569
|
*/
|
|
1541
1570
|
declare abstract class FileSystemProvider {
|
|
1571
|
+
/**
|
|
1572
|
+
* Joins multiple path segments into a single path.
|
|
1573
|
+
*
|
|
1574
|
+
* @param paths - The path segments to join
|
|
1575
|
+
* @returns The joined path
|
|
1576
|
+
*/
|
|
1577
|
+
abstract join(...paths: string[]): string;
|
|
1542
1578
|
/**
|
|
1543
1579
|
* Creates a FileLike object from various sources.
|
|
1544
1580
|
*
|
package/package.json
CHANGED
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
"minio"
|
|
14
14
|
],
|
|
15
15
|
"author": "Nicolas Foures",
|
|
16
|
-
"version": "0.14.
|
|
16
|
+
"version": "0.14.3",
|
|
17
17
|
"type": "module",
|
|
18
18
|
"engines": {
|
|
19
19
|
"node": ">=22.0.0"
|
|
@@ -26,17 +26,17 @@
|
|
|
26
26
|
"src"
|
|
27
27
|
],
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@aws-sdk/client-s3": "^3.
|
|
29
|
+
"@aws-sdk/client-s3": "^3.965.0"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
32
|
"@biomejs/biome": "^2.3.11",
|
|
33
|
-
"alepha": "0.14.
|
|
34
|
-
"tsdown": "^0.19.0-beta.
|
|
33
|
+
"alepha": "0.14.3",
|
|
34
|
+
"tsdown": "^0.19.0-beta.5",
|
|
35
35
|
"typescript": "^5.9.3",
|
|
36
36
|
"vitest": "^4.0.16"
|
|
37
37
|
},
|
|
38
38
|
"peerDependencies": {
|
|
39
|
-
"alepha": "0.14.
|
|
39
|
+
"alepha": "0.14.3"
|
|
40
40
|
},
|
|
41
41
|
"scripts": {
|
|
42
42
|
"lint": "alepha lint",
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { Alepha } from "alepha";
|
|
2
|
+
import { describe, test } from "vitest";
|
|
3
|
+
import {
|
|
4
|
+
TestApp,
|
|
5
|
+
testCustomFileId,
|
|
6
|
+
testDeleteFile,
|
|
7
|
+
testDeleteNonExistentFile,
|
|
8
|
+
testDownloadAndMetadata,
|
|
9
|
+
testEmptyFiles,
|
|
10
|
+
testFileExistence,
|
|
11
|
+
testFileStream,
|
|
12
|
+
testNonExistentFile,
|
|
13
|
+
testNonExistentFileError,
|
|
14
|
+
testUploadAndExistence,
|
|
15
|
+
testUploadIntoBuckets,
|
|
16
|
+
} from "../../../alepha/src/bucket/__tests__/shared.ts";
|
|
17
|
+
import { AlephaBucketS3, S3FileStorageProvider } from "../index.ts";
|
|
18
|
+
|
|
19
|
+
const alepha = Alepha.create().with(AlephaBucketS3).with(TestApp);
|
|
20
|
+
|
|
21
|
+
const provider = alepha.inject(S3FileStorageProvider);
|
|
22
|
+
|
|
23
|
+
describe("S3FileStorageProvider", () => {
|
|
24
|
+
test("should upload a file and return a fileId", async () => {
|
|
25
|
+
await testUploadAndExistence(provider);
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
test("should download a file and restore its metadata", async () => {
|
|
29
|
+
await testDownloadAndMetadata(provider);
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
test("exists() should return false for a non-existent file", async () => {
|
|
33
|
+
await testNonExistentFile(provider);
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
test("exists() should return true for an existing file", async () => {
|
|
37
|
+
await testFileExistence(provider);
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
test("should delete a file", async () => {
|
|
41
|
+
await testDeleteFile(provider);
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
test("delete() should not throw for a non-existent file", async () => {
|
|
45
|
+
await testDeleteNonExistentFile(provider);
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
test("download() should throw FileNotFoundError for a non-existent file", async () => {
|
|
49
|
+
await testNonExistentFileError(provider);
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
test("should handle uploading to different buckets", async () => {
|
|
53
|
+
await testUploadIntoBuckets(provider);
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
test("should handle empty files correctly", async () => {
|
|
57
|
+
await testEmptyFiles(provider);
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
test("should be able to upload with a specific fileId", async () => {
|
|
61
|
+
await testCustomFileId(provider);
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
test("should be able to upload, stream with metadata", async () => {
|
|
65
|
+
await testFileStream(provider);
|
|
66
|
+
});
|
|
67
|
+
});
|