BREAKING CHANGE(core): Make API strict-by-default: remove *Strict variants, throw on not-found/exists conflicts, add explicit exists() methods, update docs/tests and bump deps
This commit is contained in:
@@ -42,11 +42,12 @@ export class SmartBucket {
|
||||
return Bucket.getBucketByName(this, bucketNameArg);
|
||||
}
|
||||
|
||||
public async getBucketByNameStrict(...args: Parameters<SmartBucket['getBucketByName']>) {
|
||||
const bucket = await this.getBucketByName(...args);
|
||||
if (!bucket) {
|
||||
throw new Error(`Bucket ${args[0]} does not exist.`);
|
||||
}
|
||||
return bucket;
|
||||
/**
|
||||
* Check if a bucket exists
|
||||
*/
|
||||
public async bucketExists(bucketNameArg: string): Promise<boolean> {
|
||||
const command = new plugins.s3.ListBucketsCommand({});
|
||||
const buckets = await this.s3Client.send(command);
|
||||
return buckets.Buckets?.some(bucket => bucket.Name === bucketNameArg) ?? false;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user