@constructive-io/bucket-provisioner 0.3.0 → 0.4.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/client.d.ts CHANGED
@@ -1,19 +1,20 @@
1
1
  /**
2
2
  * S3 client factory.
3
3
  *
4
- * Creates a configured S3Client from a StorageConnectionConfig.
5
- * Handles provider-specific settings (path-style for MinIO, etc.).
4
+ * Delegates to @constructive-io/s3-utils for the actual S3Client creation.
5
+ * Re-exports createS3Client so existing consumers of bucket-provisioner
6
+ * continue to work without changes.
6
7
  */
7
- import { S3Client } from '@aws-sdk/client-s3';
8
+ import type { S3Client } from '@aws-sdk/client-s3';
8
9
  import type { StorageConnectionConfig } from './types';
9
10
  /**
10
11
  * Create an S3Client from a storage connection config.
11
12
  *
12
- * Provider-specific defaults:
13
- * - `minio`: forces path-style URLs (required by MinIO)
14
- * - `r2`: forces path-style URLs (required by Cloudflare R2)
15
- * - `s3`: uses virtual-hosted style (AWS default)
16
- * - `gcs`: forces path-style URLs (GCS S3-compatible API)
17
- * - `spaces`: uses virtual-hosted style (DigitalOcean default)
13
+ * Delegates to @constructive-io/s3-utils/createS3Client.
14
+ * This wrapper exists for backward compatibility — new code should
15
+ * import createS3Client from @constructive-io/s3-utils directly.
16
+ *
17
+ * Catches S3ConfigError from s3-utils and re-throws as ProvisionerError
18
+ * so existing consumers that catch ProvisionerError continue to work.
18
19
  */
19
20
  export declare function createS3Client(config: StorageConnectionConfig): S3Client;
package/client.js CHANGED
@@ -2,44 +2,32 @@
2
2
  /**
3
3
  * S3 client factory.
4
4
  *
5
- * Creates a configured S3Client from a StorageConnectionConfig.
6
- * Handles provider-specific settings (path-style for MinIO, etc.).
5
+ * Delegates to @constructive-io/s3-utils for the actual S3Client creation.
6
+ * Re-exports createS3Client so existing consumers of bucket-provisioner
7
+ * continue to work without changes.
7
8
  */
8
9
  Object.defineProperty(exports, "__esModule", { value: true });
9
10
  exports.createS3Client = createS3Client;
10
- const client_s3_1 = require("@aws-sdk/client-s3");
11
+ const s3_utils_1 = require("@constructive-io/s3-utils");
11
12
  const types_1 = require("./types");
12
13
  /**
13
14
  * Create an S3Client from a storage connection config.
14
15
  *
15
- * Provider-specific defaults:
16
- * - `minio`: forces path-style URLs (required by MinIO)
17
- * - `r2`: forces path-style URLs (required by Cloudflare R2)
18
- * - `s3`: uses virtual-hosted style (AWS default)
19
- * - `gcs`: forces path-style URLs (GCS S3-compatible API)
20
- * - `spaces`: uses virtual-hosted style (DigitalOcean default)
16
+ * Delegates to @constructive-io/s3-utils/createS3Client.
17
+ * This wrapper exists for backward compatibility — new code should
18
+ * import createS3Client from @constructive-io/s3-utils directly.
19
+ *
20
+ * Catches S3ConfigError from s3-utils and re-throws as ProvisionerError
21
+ * so existing consumers that catch ProvisionerError continue to work.
21
22
  */
22
23
  function createS3Client(config) {
23
- if (!config.accessKeyId || !config.secretAccessKey) {
24
- throw new types_1.ProvisionerError('INVALID_CONFIG', 'accessKeyId and secretAccessKey are required');
25
- }
26
- if (!config.region) {
27
- throw new types_1.ProvisionerError('INVALID_CONFIG', 'region is required');
24
+ try {
25
+ return (0, s3_utils_1.createS3Client)(config);
28
26
  }
29
- // Providers that require path-style URLs
30
- const pathStyleProviders = new Set(['minio', 'r2', 'gcs']);
31
- const forcePathStyle = config.forcePathStyle ?? pathStyleProviders.has(config.provider);
32
- // Non-AWS providers require an endpoint
33
- if (config.provider !== 's3' && !config.endpoint) {
34
- throw new types_1.ProvisionerError('INVALID_CONFIG', `endpoint is required for provider '${config.provider}'`);
27
+ catch (err) {
28
+ if (err instanceof s3_utils_1.S3ConfigError) {
29
+ throw new types_1.ProvisionerError(err.code, err.message);
30
+ }
31
+ throw err;
35
32
  }
36
- return new client_s3_1.S3Client({
37
- region: config.region,
38
- endpoint: config.endpoint,
39
- forcePathStyle,
40
- credentials: {
41
- accessKeyId: config.accessKeyId,
42
- secretAccessKey: config.secretAccessKey,
43
- },
44
- });
45
33
  }
package/esm/client.d.ts CHANGED
@@ -1,19 +1,20 @@
1
1
  /**
2
2
  * S3 client factory.
3
3
  *
4
- * Creates a configured S3Client from a StorageConnectionConfig.
5
- * Handles provider-specific settings (path-style for MinIO, etc.).
4
+ * Delegates to @constructive-io/s3-utils for the actual S3Client creation.
5
+ * Re-exports createS3Client so existing consumers of bucket-provisioner
6
+ * continue to work without changes.
6
7
  */
7
- import { S3Client } from '@aws-sdk/client-s3';
8
+ import type { S3Client } from '@aws-sdk/client-s3';
8
9
  import type { StorageConnectionConfig } from './types';
9
10
  /**
10
11
  * Create an S3Client from a storage connection config.
11
12
  *
12
- * Provider-specific defaults:
13
- * - `minio`: forces path-style URLs (required by MinIO)
14
- * - `r2`: forces path-style URLs (required by Cloudflare R2)
15
- * - `s3`: uses virtual-hosted style (AWS default)
16
- * - `gcs`: forces path-style URLs (GCS S3-compatible API)
17
- * - `spaces`: uses virtual-hosted style (DigitalOcean default)
13
+ * Delegates to @constructive-io/s3-utils/createS3Client.
14
+ * This wrapper exists for backward compatibility — new code should
15
+ * import createS3Client from @constructive-io/s3-utils directly.
16
+ *
17
+ * Catches S3ConfigError from s3-utils and re-throws as ProvisionerError
18
+ * so existing consumers that catch ProvisionerError continue to work.
18
19
  */
19
20
  export declare function createS3Client(config: StorageConnectionConfig): S3Client;
package/esm/client.js CHANGED
@@ -1,42 +1,30 @@
1
1
  /**
2
2
  * S3 client factory.
3
3
  *
4
- * Creates a configured S3Client from a StorageConnectionConfig.
5
- * Handles provider-specific settings (path-style for MinIO, etc.).
4
+ * Delegates to @constructive-io/s3-utils for the actual S3Client creation.
5
+ * Re-exports createS3Client so existing consumers of bucket-provisioner
6
+ * continue to work without changes.
6
7
  */
7
- import { S3Client } from '@aws-sdk/client-s3';
8
+ import { createS3Client as createS3ClientFromUtils, S3ConfigError } from '@constructive-io/s3-utils';
8
9
  import { ProvisionerError } from './types';
9
10
  /**
10
11
  * Create an S3Client from a storage connection config.
11
12
  *
12
- * Provider-specific defaults:
13
- * - `minio`: forces path-style URLs (required by MinIO)
14
- * - `r2`: forces path-style URLs (required by Cloudflare R2)
15
- * - `s3`: uses virtual-hosted style (AWS default)
16
- * - `gcs`: forces path-style URLs (GCS S3-compatible API)
17
- * - `spaces`: uses virtual-hosted style (DigitalOcean default)
13
+ * Delegates to @constructive-io/s3-utils/createS3Client.
14
+ * This wrapper exists for backward compatibility — new code should
15
+ * import createS3Client from @constructive-io/s3-utils directly.
16
+ *
17
+ * Catches S3ConfigError from s3-utils and re-throws as ProvisionerError
18
+ * so existing consumers that catch ProvisionerError continue to work.
18
19
  */
19
20
  export function createS3Client(config) {
20
- if (!config.accessKeyId || !config.secretAccessKey) {
21
- throw new ProvisionerError('INVALID_CONFIG', 'accessKeyId and secretAccessKey are required');
22
- }
23
- if (!config.region) {
24
- throw new ProvisionerError('INVALID_CONFIG', 'region is required');
21
+ try {
22
+ return createS3ClientFromUtils(config);
25
23
  }
26
- // Providers that require path-style URLs
27
- const pathStyleProviders = new Set(['minio', 'r2', 'gcs']);
28
- const forcePathStyle = config.forcePathStyle ?? pathStyleProviders.has(config.provider);
29
- // Non-AWS providers require an endpoint
30
- if (config.provider !== 's3' && !config.endpoint) {
31
- throw new ProvisionerError('INVALID_CONFIG', `endpoint is required for provider '${config.provider}'`);
24
+ catch (err) {
25
+ if (err instanceof S3ConfigError) {
26
+ throw new ProvisionerError(err.code, err.message);
27
+ }
28
+ throw err;
32
29
  }
33
- return new S3Client({
34
- region: config.region,
35
- endpoint: config.endpoint,
36
- forcePathStyle,
37
- credentials: {
38
- accessKeyId: config.accessKeyId,
39
- secretAccessKey: config.secretAccessKey,
40
- },
41
- });
42
30
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@constructive-io/bucket-provisioner",
3
- "version": "0.3.0",
3
+ "version": "0.4.0",
4
4
  "author": "Constructive <developers@constructive.io>",
5
5
  "description": "S3-compatible bucket provisioning library — create buckets, configure privacy policies, CORS, and access controls",
6
6
  "main": "index.js",
@@ -29,7 +29,8 @@
29
29
  "test:watch": "jest --watch"
30
30
  },
31
31
  "dependencies": {
32
- "@aws-sdk/client-s3": "^3.1009.0"
32
+ "@aws-sdk/client-s3": "^3.1009.0",
33
+ "@constructive-io/s3-utils": "^2.12.0"
33
34
  },
34
35
  "devDependencies": {
35
36
  "makage": "^0.3.0"
@@ -43,5 +44,5 @@
43
44
  "storage",
44
45
  "constructive"
45
46
  ],
46
- "gitHead": "1b3af3c5189b9ca2e765b9239a4b287099e64a03"
47
+ "gitHead": "434a578648cb04d3ed25e79a75c654f71573292f"
47
48
  }