@statewalker/webrun-files-s3 0.5.0 → 0.9.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/dist/index.d.ts CHANGED
@@ -1,6 +1,5 @@
1
1
  /**
2
- * webrun-files-s3 - S3-backed IFilesApi implementation
2
+ * webrun-files-s3 - S3-backed FilesApi implementation
3
3
  */
4
4
  export { S3FilesApi, type S3FilesApiOptions } from "./s3-files-api.js";
5
- export { S3FileHandle, type S3FileHandleOptions } from "./s3-file-handle.js";
6
5
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,UAAU,EAAE,KAAK,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AACvE,OAAO,EAAE,YAAY,EAAE,KAAK,mBAAmB,EAAE,MAAM,qBAAqB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,UAAU,EAAE,KAAK,iBAAiB,EAAE,MAAM,mBAAmB,CAAC"}
@@ -1,15 +1,13 @@
1
1
  /**
2
- * S3 implementation of IFilesApi
2
+ * S3 implementation of FilesApi
3
3
  *
4
4
  * Provides a filesystem-like interface over S3 object storage.
5
- * Supports all IFilesApi methods including the optional move, copy, and mkdir.
6
5
  */
7
6
  import type { S3Client } from "@aws-sdk/client-s3";
8
- import type { CopyOptions, FileHandle, FileInfo, FileRef, IFilesApi, ListOptions } from "@statewalker/webrun-files";
7
+ import type { FileInfo, FileStats, FilesApi, ListOptions, ReadOptions } from "@statewalker/webrun-files";
9
8
  export interface S3FilesApiOptions {
10
9
  /**
11
10
  * Pre-configured S3Client instance.
12
- * Allows full control over credentials, region, endpoint.
13
11
  */
14
12
  client: S3Client;
15
13
  /**
@@ -18,67 +16,38 @@ export interface S3FilesApiOptions {
18
16
  bucket: string;
19
17
  /**
20
18
  * Optional key prefix (acts as root directory).
21
- * All paths will be relative to this prefix.
22
19
  * @example "projects/my-app/data"
23
20
  */
24
21
  prefix?: string;
25
22
  /**
26
- * Minimum part size for multipart uploads (5MB minimum for S3).
27
- * @default 5 * 1024 * 1024 (5MB)
23
+ * Part size for multipart uploads in bytes.
24
+ * S3 requires minimum 5MB for all parts except the last.
25
+ * @default 5242880 (5MB)
28
26
  */
29
27
  multipartPartSize?: number;
30
28
  }
31
- export declare class S3FilesApi implements IFilesApi {
29
+ /**
30
+ * S3 filesystem implementation of FilesApi.
31
+ *
32
+ * Provides a filesystem-like interface over S3 object storage.
33
+ * Works with AWS S3 and S3-compatible services.
34
+ */
35
+ export declare class S3FilesApi implements FilesApi {
32
36
  private client;
33
37
  private bucket;
34
38
  private prefix;
35
- private multipartPartSize;
39
+ private partSize;
36
40
  constructor(options: S3FilesApiOptions);
37
- /**
38
- * Converts a virtual path to an S3 key.
39
- * @example resolveKey("/docs/file.txt") => "prefix/docs/file.txt"
40
- */
41
41
  private resolveKey;
42
- /**
43
- * Converts an S3 key back to a virtual path.
44
- */
45
42
  private keyToPath;
46
- /**
47
- * Lists objects in a virtual directory.
48
- *
49
- * Uses S3's delimiter feature to simulate directory listing.
50
- * CommonPrefixes represent subdirectories.
51
- */
52
- list(file: FileRef, options?: ListOptions): AsyncGenerator<FileInfo>;
53
- /**
54
- * Gets object metadata using HEAD request.
55
- */
56
- stats(file: FileRef): Promise<FileInfo | undefined>;
57
- /**
58
- * Deletes an object or all objects under a prefix (directory).
59
- */
60
- remove(file: FileRef): Promise<boolean>;
61
- /**
62
- * Opens an S3 object for random access.
63
- * Creates the object if it doesn't exist.
64
- */
65
- open(file: FileRef): Promise<FileHandle>;
66
- /**
67
- * Moves an object using Copy + Delete.
68
- */
69
- move(source: FileRef, target: FileRef): Promise<boolean>;
70
- /**
71
- * Copies an object or directory using S3 CopyObject.
72
- */
73
- copy(source: FileRef, target: FileRef, options?: CopyOptions): Promise<boolean>;
74
- /**
75
- * Creates a directory marker in S3.
76
- *
77
- * S3 doesn't have real directories, but some tools expect
78
- * a zero-byte object with trailing slash as a directory marker.
79
- * However, for our purposes we don't actually need to create markers
80
- * since directories are implied by files within them.
81
- */
82
- mkdir(file: FileRef): Promise<void>;
43
+ read(path: string, options?: ReadOptions): AsyncIterable<Uint8Array>;
44
+ write(path: string, content: Iterable<Uint8Array> | AsyncIterable<Uint8Array>): Promise<void>;
45
+ mkdir(path: string): Promise<void>;
46
+ list(path: string, options?: ListOptions): AsyncIterable<FileInfo>;
47
+ stats(path: string): Promise<FileStats | undefined>;
48
+ exists(path: string): Promise<boolean>;
49
+ remove(path: string): Promise<boolean>;
50
+ move(source: string, target: string): Promise<boolean>;
51
+ copy(source: string, target: string): Promise<boolean>;
83
52
  }
84
53
  //# sourceMappingURL=s3-files-api.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"s3-files-api.d.ts","sourceRoot":"","sources":["../src/s3-files-api.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAQnD,OAAO,KAAK,EACV,WAAW,EACX,UAAU,EACV,QAAQ,EACR,OAAO,EACP,SAAS,EACT,WAAW,EACZ,MAAM,2BAA2B,CAAC;AAInC,MAAM,WAAW,iBAAiB;IAChC;;;OAGG;IACH,MAAM,EAAE,QAAQ,CAAC;IAEjB;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC;IAEf;;;;OAIG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB;;;OAGG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC5B;AAED,qBAAa,UAAW,YAAW,SAAS;IAC1C,OAAO,CAAC,MAAM,CAAW;IACzB,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,iBAAiB,CAAS;gBAEtB,OAAO,EAAE,iB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 "version": "0.9.0",
4
4
  "private": false,
5
5
  "type": "module",
6
- "description": "S3-backed IFilesApi implementation for webrun-files",
6
+ "description": "S3-backed FilesApi implementation for webrun-files",
7
7
  "homepage": "https://github.com/statewalker/webrun-files",
8
8
  "author": {
9
9
  "name": "Mikhail Kotelnikov",
@@ -29,21 +29,20 @@
29
29
  "src"
30
30
  ],
31
31
  "dependencies": {
32
- "@statewalker/webrun-files": "0.5.0"
32
+ "@statewalker/webrun-files": "0.9.0"
33
33
  },
34
34
  "peerDependencies": {
35
- "@aws-sdk/client-s3": "^3.0.0"
35
+ "@aws-sdk/client-s3": "^3.1032.0"
36
36
  },
37
37
  "devDependencies": {
38
- "@aws-sdk/client-s3": "^3.0.0",
39
- "@testcontainers/minio": "^10.0.0",
40
- "@types/node": "^24.10.1",
41
- "rimraf": "^6.1.2",
42
- "rolldown": "^1.0.0-beta.53",
43
- "testcontainers": "^10.0.0",
44
- "typescript": "^5.6.0",
45
- "vitest": "^4.0.12",
46
- "@statewalker/webrun-files-tests": "1.0.0"
38
+ "@aws-sdk/client-s3": "^3.1110.0",
39
+ "@types/node": "^26.2.0",
40
+ "rimraf": "^6.1.3",
41
+ "rolldown": "^1.2.4",
42
+ "testcontainers": "^12.1.0",
43
+ "typescript": "^7.0.2",
44
+ "vitest": "^4.1.10",
45
+ "@statewalker/webrun-files-tests": "2.0.0"
47
46
  },
48
47
  "sideEffects": false,
49
48
  "publishConfig": {
@@ -51,7 +50,8 @@
51
50
  },
52
51
  "scripts": {
53
52
  "build": "rimraf dist && rolldown -c && tsc --emitDeclarationOnly --declaration",
54
- "test": "vitest run",
55
- "lint": "biome lint src tests"
53
+ "lint": "biome lint src tests",
54
+ "test": "vitest run --passWithNoTests",
55
+ "test:integration": "vitest run --config vitest.integration.config.ts"
56
56
  }
57
57
  }
package/src/index.ts CHANGED
@@ -1,6 +1,5 @@
1
1
  /**
2
- * webrun-files-s3 - S3-backed IFilesApi implementation
2
+ * webrun-files-s3 - S3-backed FilesApi implementation
3
3
  */
4
4
 
5
5
  export { S3FilesApi, type S3FilesApiOptions } from "./s3-files-api.js";
6
- export { S3FileHandle, type S3FileHandleOptions } from "./s3-file-handle.js";