@punks/backend-entity-manager 0.0.242 → 0.0.244

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.
@@ -48,6 +48,18 @@ export type BucketFileDeleteInput = {
48
48
  bucket: string;
49
49
  filePath: string;
50
50
  };
51
+ export type BucketFileCopyInput = {
52
+ bucket: string;
53
+ filePath: string;
54
+ targetBucket: string;
55
+ targetPath: string;
56
+ };
57
+ export type BucketFileMoveInput = {
58
+ bucket: string;
59
+ filePath: string;
60
+ targetBucket: string;
61
+ targetPath: string;
62
+ };
51
63
  export interface IBucketProvider {
52
64
  folderList(input: BucketFolderListInput): Promise<BucketFolderListResult>;
53
65
  folderEnsure(input: BucketFolderEnsureInput): Promise<void>;
@@ -1,5 +1,5 @@
1
1
  /// <reference types="node" />
2
- import { BucketFileDeleteInput, BucketFileDownloadInput, BucketFilePublicUrlCreateInput, BucketFileUploadInput, BucketFolderEnsureInput, BucketFolderExistsInput, BucketFolderListInput, BucketFolderListResult, IBucketProvider } from "../../../../../../abstractions/buckets";
2
+ import { BucketFileCopyInput, BucketFileDeleteInput, BucketFileDownloadInput, BucketFileMoveInput, BucketFilePublicUrlCreateInput, BucketFileUploadInput, BucketFolderEnsureInput, BucketFolderExistsInput, BucketFolderListInput, BucketFolderListResult, IBucketProvider } from "../../../../../../abstractions/buckets";
3
3
  export declare class AwsS3BucketProvider implements IBucketProvider {
4
4
  private readonly client;
5
5
  constructor();
@@ -11,4 +11,6 @@ export declare class AwsS3BucketProvider implements IBucketProvider {
11
11
  filePublicUrlCreate(input: BucketFilePublicUrlCreateInput): Promise<string>;
12
12
  fileUpload(input: BucketFileUploadInput): Promise<void>;
13
13
  fileDelete(input: BucketFileDeleteInput): Promise<void>;
14
+ fileCopy(input: BucketFileCopyInput): Promise<void>;
15
+ fileMove(input: BucketFileMoveInput): Promise<void>;
14
16
  }
package/dist/esm/index.js CHANGED
@@ -9,7 +9,7 @@ import { STATIC_CONTEXT } from '@nestjs/core/injector/constants';
9
9
  import { MetadataScanner } from '@nestjs/core/metadata-scanner';
10
10
  import { JwtService, JwtModule } from '@nestjs/jwt';
11
11
  import { EventEmitter2, EventEmitterModule } from '@nestjs/event-emitter';
12
- import { ListObjectsCommand, PutObjectCommand, GetObjectCommand, DeleteObjectCommand, S3Client } from '@aws-sdk/client-s3';
12
+ import { ListObjectsCommand, PutObjectCommand, GetObjectCommand, DeleteObjectCommand, CopyObjectCommand, S3Client } from '@aws-sdk/client-s3';
13
13
  import { getSignedUrl } from '@aws-sdk/s3-request-presigner';
14
14
  import { SendEmailCommand, SESClient } from '@aws-sdk/client-ses';
15
15
  import require$$2 from 'fs';
@@ -23749,6 +23749,34 @@ let AwsS3BucketProvider = class AwsS3BucketProvider {
23749
23749
  throw new AwsS3BucketError(`AwsS3Bucket | fileDelete | ${input.bucket} | ${input.filePath} | Error -> ${e.message}`);
23750
23750
  }
23751
23751
  }
23752
+ async fileCopy(input) {
23753
+ try {
23754
+ await this.client.send(new CopyObjectCommand({
23755
+ CopySource: `${input.bucket}/${input.filePath}`,
23756
+ Bucket: input.targetBucket,
23757
+ Key: input.targetPath,
23758
+ }));
23759
+ }
23760
+ catch (e) {
23761
+ throw new AwsS3BucketError(`AwsS3Bucket | fileCopy | ${input.bucket} | ${input.filePath} | Error -> ${e.message}`);
23762
+ }
23763
+ }
23764
+ async fileMove(input) {
23765
+ try {
23766
+ await this.client.send(new CopyObjectCommand({
23767
+ CopySource: `${input.bucket}/${input.filePath}`,
23768
+ Bucket: input.targetBucket,
23769
+ Key: input.targetPath,
23770
+ }));
23771
+ await this.client.send(new DeleteObjectCommand({
23772
+ Bucket: input.bucket,
23773
+ Key: input.filePath,
23774
+ }));
23775
+ }
23776
+ catch (e) {
23777
+ throw new AwsS3BucketError(`AwsS3Bucket | fileMove | ${input.bucket} | ${input.filePath} | Error -> ${e.message}`);
23778
+ }
23779
+ }
23752
23780
  };
23753
23781
  AwsS3BucketProvider = __decorate([
23754
23782
  WpBucketProvider("awsS3"),
@@ -23815,6 +23843,7 @@ AwsS3FileProvider = __decorate([
23815
23843
  var AwsBucketModule_1;
23816
23844
  const ModuleData$5 = {
23817
23845
  providers: [AwsS3BucketProvider, AwsS3FileProvider],
23846
+ exports: [AwsS3BucketProvider, AwsS3FileProvider],
23818
23847
  };
23819
23848
  let AwsBucketModule = AwsBucketModule_1 = class AwsBucketModule {
23820
23849
  static forRoot(input) {