feat(storage): generalize S3 client and watcher interfaces to storage-oriented naming with backward compatibility

This commit is contained in:
2026-03-14 19:24:36 +00:00
parent 7959fa6296
commit 18bdb5c7c2
15 changed files with 3598 additions and 3202 deletions

View File

@@ -2,26 +2,28 @@
import * as plugins from './plugins.js';
import { Bucket } from './classes.bucket.js';
import { normalizeS3Descriptor } from './helpers.js';
import { normalizeStorageDescriptor } from './helpers.js';
export class SmartBucket {
public config: plugins.tsclass.storage.IS3Descriptor;
public config: plugins.tsclass.storage.IStorageDescriptor;
public s3Client: plugins.s3.S3Client;
public storageClient: plugins.s3.S3Client;
/** @deprecated Use storageClient instead */
public get s3Client(): plugins.s3.S3Client {
return this.storageClient;
}
/**
* the constructor of SmartBucket
*/
/**
* the constructor of SmartBucket
*/
constructor(configArg: plugins.tsclass.storage.IS3Descriptor) {
constructor(configArg: plugins.tsclass.storage.IStorageDescriptor) {
this.config = configArg;
// Use the normalizer to handle various endpoint formats
const { normalized } = normalizeS3Descriptor(configArg);
const { normalized } = normalizeStorageDescriptor(configArg);
this.s3Client = new plugins.s3.S3Client({
this.storageClient = new plugins.s3.S3Client({
endpoint: normalized.endpointUrl,
region: normalized.region,
credentials: normalized.credentials,
@@ -47,7 +49,7 @@ export class SmartBucket {
*/
public async bucketExists(bucketNameArg: string): Promise<boolean> {
const command = new plugins.s3.ListBucketsCommand({});
const buckets = await this.s3Client.send(command);
const buckets = await this.storageClient.send(command);
return buckets.Buckets?.some(bucket => bucket.Name === bucketNameArg) ?? false;
}
}