plenna_utilities 1.13.10 → 1.14.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.
@@ -1,4 +1,4 @@
1
- import { type ObjectCannedACL, type PutObjectCommandInput, type S3ClientConfig } from '@aws-sdk/client-s3';
1
+ import { type ObjectCannedACL, type PutObjectCommandInput, type S3ClientConfig, type DeleteObjectCommandOutput, type DeleteObjectsCommandOutput } from '@aws-sdk/client-s3';
2
2
  export declare class PlennaS3Service {
3
3
  private readonly bucket;
4
4
  private readonly acl;
@@ -6,4 +6,6 @@ export declare class PlennaS3Service {
6
6
  constructor(bucket: string, acl: ObjectCannedACL, options?: Partial<PutObjectCommandInput>);
7
7
  getPresignedUrl(keyName: string, clientConfig?: S3ClientConfig): Promise<string>;
8
8
  upload(fileName: string, file: PutObjectCommandInput['Body'], options?: Partial<PutObjectCommandInput>): Promise<string>;
9
+ deleteObject(key: string): Promise<DeleteObjectCommandOutput>;
10
+ deleteObjects(keys: string[]): Promise<DeleteObjectsCommandOutput>;
9
11
  }
@@ -40,5 +40,24 @@ class PlennaS3Service {
40
40
  const fileS3Url = `https://${this.bucket}.s3.${REGION}.amazonaws.com/${fileName}`;
41
41
  return fileS3Url;
42
42
  }
43
+ async deleteObject(key) {
44
+ const s3 = new client_s3_1.S3Client({ region: REGION });
45
+ const response = await s3.send(new client_s3_1.DeleteObjectCommand({
46
+ Bucket: this.bucket,
47
+ Key: key
48
+ }));
49
+ return response;
50
+ }
51
+ async deleteObjects(keys) {
52
+ const s3 = new client_s3_1.S3Client({ region: REGION });
53
+ const response = await s3.send(new client_s3_1.DeleteObjectsCommand({
54
+ Bucket: this.bucket,
55
+ Delete: {
56
+ Objects: keys.map(key => ({ Key: key })),
57
+ Quiet: false
58
+ }
59
+ }));
60
+ return response;
61
+ }
43
62
  }
44
63
  exports.PlennaS3Service = PlennaS3Service;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "plenna_utilities",
3
- "version": "1.13.10",
3
+ "version": "1.14.0",
4
4
  "description": "plenna's utils for backend projects",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",