@constructive-io/s3-utils 2.31.0 → 2.33.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 +4 -4
- package/client.d.ts +4 -2
- package/client.js +3 -1
- package/esm/client.js +3 -1
- package/package.json +3 -3
- package/policies.d.ts +1 -1
package/README.md
CHANGED
|
@@ -16,7 +16,7 @@ Unified S3 utilities for the Constructive ecosystem — client factory, file ope
|
|
|
16
16
|
|
|
17
17
|
## Features
|
|
18
18
|
|
|
19
|
-
- **Multi-provider support** — AWS S3, MinIO, Cloudflare R2, Google Cloud Storage, DigitalOcean Spaces
|
|
19
|
+
- **Multi-provider support** — AWS S3, MinIO, RustFS, Cloudflare R2, Google Cloud Storage, DigitalOcean Spaces
|
|
20
20
|
- **Presigned URLs** — generate secure PUT and GET URLs with configurable expiry
|
|
21
21
|
- **File operations** — streaming upload, download, existence checks, and metadata retrieval
|
|
22
22
|
- **Bucket management** — create buckets with provider-appropriate policies and CORS
|
|
@@ -88,14 +88,14 @@ const client = createS3Client({
|
|
|
88
88
|
|
|
89
89
|
| Field | Type | Required | Description |
|
|
90
90
|
|---|---|---|---|
|
|
91
|
-
| `provider` | `'s3' \| 'minio' \| 'r2' \| 'gcs' \| 'spaces'` | yes | Storage provider |
|
|
91
|
+
| `provider` | `'s3' \| 'minio' \| 'rustfs' \| 'r2' \| 'gcs' \| 'spaces'` | yes | Storage provider |
|
|
92
92
|
| `region` | `string` | yes | S3 region (e.g. `"us-east-1"`) |
|
|
93
93
|
| `endpoint` | `string` | non-AWS | Endpoint URL (required for all providers except `s3`) |
|
|
94
94
|
| `accessKeyId` | `string` | yes | Access key ID |
|
|
95
95
|
| `secretAccessKey` | `string` | yes | Secret access key |
|
|
96
96
|
| `forcePathStyle` | `boolean` | no | Override path-style URL behavior |
|
|
97
97
|
|
|
98
|
-
Path-style URLs are enabled automatically for `minio`, `r2`, and `gcs`. Virtual-hosted style is used for `s3` and `spaces`.
|
|
98
|
+
Path-style URLs are enabled automatically for `minio`, `rustfs`, `r2`, and `gcs`. Virtual-hosted style is used for `s3` and `spaces`.
|
|
99
99
|
|
|
100
100
|
Throws `S3ConfigError` on invalid configuration.
|
|
101
101
|
|
|
@@ -199,7 +199,7 @@ someReadable.pipe(pass);
|
|
|
199
199
|
Creates a bucket with provider-appropriate policies and CORS configuration.
|
|
200
200
|
|
|
201
201
|
- **MinIO**: read-only public access policy (list + get)
|
|
202
|
-
- **S3/GCS**: full-access policy with CORS rules for browser uploads
|
|
202
|
+
- **RustFS/S3/GCS**: full-access policy with CORS rules for browser uploads
|
|
203
203
|
|
|
204
204
|
```typescript
|
|
205
205
|
const { success } = await createS3Bucket(client, 'my-bucket', {
|
package/client.d.ts
CHANGED
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
*
|
|
8
8
|
* Handles provider-specific defaults:
|
|
9
9
|
* - minio: forces path-style URLs, requires endpoint
|
|
10
|
+
* - rustfs: forces path-style URLs, requires endpoint
|
|
10
11
|
* - r2: forces path-style URLs, requires endpoint
|
|
11
12
|
* - gcs: forces path-style URLs, requires endpoint
|
|
12
13
|
* - s3: virtual-hosted style (AWS default)
|
|
@@ -32,13 +33,13 @@ import { S3Client } from '@aws-sdk/client-s3';
|
|
|
32
33
|
* Used to select provider-specific behavior (e.g., path-style URLs for MinIO,
|
|
33
34
|
* jurisdiction headers for R2).
|
|
34
35
|
*/
|
|
35
|
-
export type StorageProvider = 's3' | 'minio' | 'r2' | 'gcs' | 'spaces';
|
|
36
|
+
export type StorageProvider = 's3' | 'minio' | 'rustfs' | 'r2' | 'gcs' | 'spaces';
|
|
36
37
|
/**
|
|
37
38
|
* Connection configuration for an S3-compatible storage backend.
|
|
38
39
|
*
|
|
39
40
|
* This is the input you provide to connect to your storage provider.
|
|
40
41
|
* For AWS S3, only `region` and credentials are needed.
|
|
41
|
-
* For MinIO/R2/etc., also provide `endpoint`.
|
|
42
|
+
* For MinIO/RustFS/R2/etc., also provide `endpoint`.
|
|
42
43
|
*/
|
|
43
44
|
export interface StorageConnectionConfig {
|
|
44
45
|
/** Storage provider type */
|
|
@@ -66,6 +67,7 @@ export declare class S3ConfigError extends Error {
|
|
|
66
67
|
*
|
|
67
68
|
* Provider-specific defaults:
|
|
68
69
|
* - `minio`: forces path-style URLs (required by MinIO)
|
|
70
|
+
* - `rustfs`: forces path-style URLs
|
|
69
71
|
* - `r2`: forces path-style URLs (required by Cloudflare R2)
|
|
70
72
|
* - `s3`: uses virtual-hosted style (AWS default)
|
|
71
73
|
* - `gcs`: forces path-style URLs (GCS S3-compatible API)
|
package/client.js
CHANGED
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
*
|
|
9
9
|
* Handles provider-specific defaults:
|
|
10
10
|
* - minio: forces path-style URLs, requires endpoint
|
|
11
|
+
* - rustfs: forces path-style URLs, requires endpoint
|
|
11
12
|
* - r2: forces path-style URLs, requires endpoint
|
|
12
13
|
* - gcs: forces path-style URLs, requires endpoint
|
|
13
14
|
* - s3: virtual-hosted style (AWS default)
|
|
@@ -49,6 +50,7 @@ exports.S3ConfigError = S3ConfigError;
|
|
|
49
50
|
*
|
|
50
51
|
* Provider-specific defaults:
|
|
51
52
|
* - `minio`: forces path-style URLs (required by MinIO)
|
|
53
|
+
* - `rustfs`: forces path-style URLs
|
|
52
54
|
* - `r2`: forces path-style URLs (required by Cloudflare R2)
|
|
53
55
|
* - `s3`: uses virtual-hosted style (AWS default)
|
|
54
56
|
* - `gcs`: forces path-style URLs (GCS S3-compatible API)
|
|
@@ -62,7 +64,7 @@ function createS3Client(config) {
|
|
|
62
64
|
throw new S3ConfigError('INVALID_CONFIG', 'region is required');
|
|
63
65
|
}
|
|
64
66
|
// Providers that require path-style URLs
|
|
65
|
-
const pathStyleProviders = new Set(['minio', 'r2', 'gcs']);
|
|
67
|
+
const pathStyleProviders = new Set(['minio', 'rustfs', 'r2', 'gcs']);
|
|
66
68
|
const forcePathStyle = config.forcePathStyle ?? pathStyleProviders.has(config.provider);
|
|
67
69
|
// Non-AWS providers require an endpoint
|
|
68
70
|
if (config.provider !== 's3' && !config.endpoint) {
|
package/esm/client.js
CHANGED
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
*
|
|
8
8
|
* Handles provider-specific defaults:
|
|
9
9
|
* - minio: forces path-style URLs, requires endpoint
|
|
10
|
+
* - rustfs: forces path-style URLs, requires endpoint
|
|
10
11
|
* - r2: forces path-style URLs, requires endpoint
|
|
11
12
|
* - gcs: forces path-style URLs, requires endpoint
|
|
12
13
|
* - s3: virtual-hosted style (AWS default)
|
|
@@ -44,6 +45,7 @@ export class S3ConfigError extends Error {
|
|
|
44
45
|
*
|
|
45
46
|
* Provider-specific defaults:
|
|
46
47
|
* - `minio`: forces path-style URLs (required by MinIO)
|
|
48
|
+
* - `rustfs`: forces path-style URLs
|
|
47
49
|
* - `r2`: forces path-style URLs (required by Cloudflare R2)
|
|
48
50
|
* - `s3`: uses virtual-hosted style (AWS default)
|
|
49
51
|
* - `gcs`: forces path-style URLs (GCS S3-compatible API)
|
|
@@ -57,7 +59,7 @@ export function createS3Client(config) {
|
|
|
57
59
|
throw new S3ConfigError('INVALID_CONFIG', 'region is required');
|
|
58
60
|
}
|
|
59
61
|
// Providers that require path-style URLs
|
|
60
|
-
const pathStyleProviders = new Set(['minio', 'r2', 'gcs']);
|
|
62
|
+
const pathStyleProviders = new Set(['minio', 'rustfs', 'r2', 'gcs']);
|
|
61
63
|
const forcePathStyle = config.forcePathStyle ?? pathStyleProviders.has(config.provider);
|
|
62
64
|
// Non-AWS providers require an endpoint
|
|
63
65
|
if (config.provider !== 's3' && !config.endpoint) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@constructive-io/s3-utils",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.33.0",
|
|
4
4
|
"author": "Constructive <developers@constructive.io>",
|
|
5
5
|
"description": "Unified S3 utilities — client factory, file operations, presigned URLs",
|
|
6
6
|
"main": "index.js",
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
38
|
"@types/node": "^22.19.11",
|
|
39
|
-
"makage": "^0.
|
|
39
|
+
"makage": "^0.8.0"
|
|
40
40
|
},
|
|
41
|
-
"gitHead": "
|
|
41
|
+
"gitHead": "5e0bfead2856d1a062b495d343a43e543343f9b8"
|
|
42
42
|
}
|
package/policies.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { S3Client } from '@aws-sdk/client-s3';
|
|
2
2
|
export interface CreateS3BucketOptions {
|
|
3
|
-
provider: 'minio' | 's3' | 'gcs';
|
|
3
|
+
provider: 'minio' | 'rustfs' | 's3' | 'gcs';
|
|
4
4
|
}
|
|
5
5
|
export declare function createS3Bucket(client: S3Client, Bucket: string, options: CreateS3BucketOptions): Promise<{
|
|
6
6
|
success: boolean;
|