@constructive-io/s3-utils 2.32.0 → 2.33.1

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 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, RustFS (or any S3-compatible store), MinIO, 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
@@ -43,9 +43,9 @@ import {
43
43
  const client = createS3Client({
44
44
  provider: 'minio',
45
45
  region: 'us-east-1',
46
- endpoint: 'http://minio:9000',
47
- accessKeyId: 'minioadmin',
48
- secretAccessKey: 'minioadmin',
46
+ endpoint: 'http://rustfs:9000',
47
+ accessKeyId: 'constructive',
48
+ secretAccessKey: 'constructive-dev-secret',
49
49
  });
50
50
 
51
51
  // 2. Upload a file via stream
@@ -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
 
@@ -198,8 +198,8 @@ someReadable.pipe(pass);
198
198
 
199
199
  Creates a bucket with provider-appropriate policies and CORS configuration.
200
200
 
201
- - **MinIO**: read-only public access policy (list + get)
202
- - **S3/GCS**: full-access policy with CORS rules for browser uploads
201
+ - **Path-style S3-compatible (`minio`, covering RustFS and MinIO)**: read-only public access policy (list + get)
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
@@ -6,7 +6,8 @@
6
6
  * instead of wiring up @aws-sdk/client-s3 directly.
7
7
  *
8
8
  * Handles provider-specific defaults:
9
- * - minio: forces path-style URLs, requires endpoint
9
+ * - minio: forces path-style URLs, requires endpoint (RustFS or MinIO)
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)
@@ -19,9 +20,9 @@
19
20
  * const client = createS3Client({
20
21
  * provider: 'minio',
21
22
  * region: 'us-east-1',
22
- * endpoint: 'http://minio:9000',
23
- * accessKeyId: 'minioadmin',
24
- * secretAccessKey: 'minioadmin',
23
+ * endpoint: 'http://rustfs:9000',
24
+ * accessKeyId: 'constructive',
25
+ * secretAccessKey: 'constructive-dev-secret',
25
26
  * });
26
27
  * ```
27
28
  */
@@ -29,29 +30,29 @@ import { S3Client } from '@aws-sdk/client-s3';
29
30
  /**
30
31
  * Supported storage provider identifiers.
31
32
  *
32
- * Used to select provider-specific behavior (e.g., path-style URLs for MinIO,
33
+ * Used to select provider-specific behavior (e.g., path-style URLs for RustFS or 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 RustFS/MinIO/R2/etc., also provide `endpoint`.
42
43
  */
43
44
  export interface StorageConnectionConfig {
44
45
  /** Storage provider type */
45
46
  provider: StorageProvider;
46
47
  /** S3 region (e.g., "us-east-1"). Required for AWS S3. */
47
48
  region: string;
48
- /** S3-compatible endpoint URL (e.g., "http://minio:9000"). Required for non-AWS providers. */
49
+ /** S3-compatible endpoint URL (e.g., "http://rustfs:9000"). Required for non-AWS providers. */
49
50
  endpoint?: string;
50
51
  /** AWS access key ID */
51
52
  accessKeyId: string;
52
53
  /** AWS secret access key */
53
54
  secretAccessKey: string;
54
- /** Use path-style URLs (required for MinIO, optional for others) */
55
+ /** Use path-style URLs (required for RustFS and MinIO, optional for others) */
55
56
  forcePathStyle?: boolean;
56
57
  }
57
58
  /**
@@ -65,7 +66,8 @@ export declare class S3ConfigError extends Error {
65
66
  * Create an S3Client from a storage connection config.
66
67
  *
67
68
  * Provider-specific defaults:
68
- * - `minio`: forces path-style URLs (required by MinIO)
69
+ * - `minio`: path-style S3-compatible storage (RustFS or 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
@@ -7,7 +7,8 @@
7
7
  * instead of wiring up @aws-sdk/client-s3 directly.
8
8
  *
9
9
  * Handles provider-specific defaults:
10
- * - minio: forces path-style URLs, requires endpoint
10
+ * - minio: forces path-style URLs, requires endpoint (RustFS or MinIO)
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)
@@ -20,9 +21,9 @@
20
21
  * const client = createS3Client({
21
22
  * provider: 'minio',
22
23
  * region: 'us-east-1',
23
- * endpoint: 'http://minio:9000',
24
- * accessKeyId: 'minioadmin',
25
- * secretAccessKey: 'minioadmin',
24
+ * endpoint: 'http://rustfs:9000',
25
+ * accessKeyId: 'constructive',
26
+ * secretAccessKey: 'constructive-dev-secret',
26
27
  * });
27
28
  * ```
28
29
  */
@@ -48,7 +49,8 @@ exports.S3ConfigError = S3ConfigError;
48
49
  * Create an S3Client from a storage connection config.
49
50
  *
50
51
  * Provider-specific defaults:
51
- * - `minio`: forces path-style URLs (required by MinIO)
52
+ * - `minio`: path-style S3-compatible storage (RustFS or 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
@@ -6,7 +6,8 @@
6
6
  * instead of wiring up @aws-sdk/client-s3 directly.
7
7
  *
8
8
  * Handles provider-specific defaults:
9
- * - minio: forces path-style URLs, requires endpoint
9
+ * - minio: forces path-style URLs, requires endpoint (RustFS or MinIO)
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)
@@ -19,9 +20,9 @@
19
20
  * const client = createS3Client({
20
21
  * provider: 'minio',
21
22
  * region: 'us-east-1',
22
- * endpoint: 'http://minio:9000',
23
- * accessKeyId: 'minioadmin',
24
- * secretAccessKey: 'minioadmin',
23
+ * endpoint: 'http://rustfs:9000',
24
+ * accessKeyId: 'constructive',
25
+ * secretAccessKey: 'constructive-dev-secret',
25
26
  * });
26
27
  * ```
27
28
  */
@@ -43,7 +44,8 @@ export class S3ConfigError extends Error {
43
44
  * Create an S3Client from a storage connection config.
44
45
  *
45
46
  * Provider-specific defaults:
46
- * - `minio`: forces path-style URLs (required by MinIO)
47
+ * - `minio`: path-style S3-compatible storage (RustFS or 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.32.0",
3
+ "version": "2.33.1",
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.3.0"
39
+ "makage": "^0.8.0"
40
40
  },
41
- "gitHead": "b5b6b9f05276b7e9cbd3d1f4acd31dd315c353ea"
41
+ "gitHead": "9bba983b38395277e0400294aaa380e586b049d4"
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;