prime-sdk 1.2.1 → 1.3.1
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/dist/external/aws/s3/s3.service.d.ts +4 -2
- package/dist/external/aws/s3/s3.service.js +14 -0
- package/dist/external/aws/s3/s3.service.js.map +1 -1
- package/dist/lib/storage/interfaces/storage.interface.d.ts +4 -2
- package/dist/lib/storage/interfaces/storage.interface.js.map +1 -1
- package/dist/lib/storage/storage.d.ts +4 -2
- package/dist/lib/storage/storage.js +6 -0
- package/dist/lib/storage/storage.js.map +1 -1
- package/dist/lib/storage/types/storage.type.d.ts +12 -0
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/external/aws/s3/s3.service.ts +26 -0
- package/src/lib/storage/interfaces/storage.interface.ts +6 -0
- package/src/lib/storage/storage.ts +12 -0
- package/src/lib/storage/types/storage.type.ts +15 -0
package/package.json
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
|
+
CopyObjectCommand,
|
|
3
|
+
CopyObjectCommandOutput,
|
|
2
4
|
DeleteObjectCommand,
|
|
3
5
|
DeleteObjectCommandOutput,
|
|
6
|
+
DeleteObjectsCommand,
|
|
7
|
+
DeleteObjectsOutput,
|
|
4
8
|
GetObjectCommand,
|
|
5
9
|
GetObjectCommandOutput,
|
|
6
10
|
ListObjectsV2Command,
|
|
@@ -13,7 +17,9 @@ import { Inject, Injectable } from '@nestjs/common';
|
|
|
13
17
|
import { getSignedUrl } from '@aws-sdk/s3-request-presigner';
|
|
14
18
|
import { IStorage } from '../../../lib/storage/interfaces/storage.interface';
|
|
15
19
|
import {
|
|
20
|
+
CopyFile,
|
|
16
21
|
DeleteFile,
|
|
22
|
+
DeleteFiles,
|
|
17
23
|
GetFile,
|
|
18
24
|
ListFiles,
|
|
19
25
|
UploadFile,
|
|
@@ -83,4 +89,24 @@ export class S3 implements IStorage {
|
|
|
83
89
|
|
|
84
90
|
return await this.client.send(command);
|
|
85
91
|
}
|
|
92
|
+
|
|
93
|
+
async deleteFiles(data: DeleteFiles): Promise<DeleteObjectsOutput> {
|
|
94
|
+
const params = { Bucket: data.bucket, Delete: { Objects: data.objects } };
|
|
95
|
+
|
|
96
|
+
const command = new DeleteObjectsCommand(params);
|
|
97
|
+
|
|
98
|
+
return await this.client.send(command);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
async copyFile(data: CopyFile): Promise<CopyObjectCommandOutput> {
|
|
102
|
+
const params = {
|
|
103
|
+
Bucket: data.bucket,
|
|
104
|
+
CopySource: data.copySource,
|
|
105
|
+
Key: data.key,
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
const command = new CopyObjectCommand(params);
|
|
109
|
+
|
|
110
|
+
return await this.client.send(command);
|
|
111
|
+
}
|
|
86
112
|
}
|
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
import {
|
|
2
|
+
CopyObjectCommandOutput,
|
|
2
3
|
DeleteObjectCommandOutput,
|
|
4
|
+
DeleteObjectsOutput,
|
|
3
5
|
GetObjectCommandOutput,
|
|
4
6
|
ListObjectsV2CommandOutput,
|
|
5
7
|
PutObjectCommandOutput,
|
|
6
8
|
} from '@aws-sdk/client-s3';
|
|
7
9
|
import {
|
|
10
|
+
CopyFile,
|
|
8
11
|
DeleteFile,
|
|
12
|
+
DeleteFiles,
|
|
9
13
|
GetFile,
|
|
10
14
|
ListFiles,
|
|
11
15
|
UploadFile,
|
|
@@ -17,6 +21,8 @@ export interface IStorage {
|
|
|
17
21
|
getFile(file: GetFile): Promise<GetObjectCommandOutput>;
|
|
18
22
|
listFiles(data: ListFiles): Promise<ListObjectsV2CommandOutput>;
|
|
19
23
|
deleteFile(file: DeleteFile): Promise<DeleteObjectCommandOutput>;
|
|
24
|
+
deleteFiles(data: DeleteFiles): Promise<DeleteObjectsOutput>;
|
|
25
|
+
copyFile(data: CopyFile): Promise<CopyObjectCommandOutput>;
|
|
20
26
|
}
|
|
21
27
|
|
|
22
28
|
export const IStorage = Symbol('IStorage');
|
|
@@ -1,13 +1,17 @@
|
|
|
1
1
|
import { Inject, Injectable } from '@nestjs/common';
|
|
2
2
|
import { IStorage } from './interfaces/storage.interface';
|
|
3
3
|
import {
|
|
4
|
+
CopyObjectCommandOutput,
|
|
4
5
|
DeleteObjectCommandOutput,
|
|
6
|
+
DeleteObjectsOutput,
|
|
5
7
|
GetObjectCommandOutput,
|
|
6
8
|
ListObjectsV2CommandOutput,
|
|
7
9
|
PutObjectCommandOutput,
|
|
8
10
|
} from '@aws-sdk/client-s3';
|
|
9
11
|
import {
|
|
12
|
+
CopyFile,
|
|
10
13
|
DeleteFile,
|
|
14
|
+
DeleteFiles,
|
|
11
15
|
GetFile,
|
|
12
16
|
ListFiles,
|
|
13
17
|
UploadFile,
|
|
@@ -36,4 +40,12 @@ export class Storage {
|
|
|
36
40
|
async deleteFile(data: DeleteFile): Promise<DeleteObjectCommandOutput> {
|
|
37
41
|
return this.storage.deleteFile(data);
|
|
38
42
|
}
|
|
43
|
+
|
|
44
|
+
async deleteFiles(data: DeleteFiles): Promise<DeleteObjectsOutput> {
|
|
45
|
+
return this.storage.deleteFiles(data);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
async copyFile(data: CopyFile): Promise<CopyObjectCommandOutput> {
|
|
49
|
+
return this.storage.copyFile(data);
|
|
50
|
+
}
|
|
39
51
|
}
|
|
@@ -22,3 +22,18 @@ export type DeleteFile = {
|
|
|
22
22
|
bucket: string;
|
|
23
23
|
key: string;
|
|
24
24
|
};
|
|
25
|
+
|
|
26
|
+
export type ObjectsDelete = {
|
|
27
|
+
Key: string;
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
export type DeleteFiles = {
|
|
31
|
+
bucket: string;
|
|
32
|
+
objects: Array<ObjectsDelete>;
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
export type CopyFile = {
|
|
36
|
+
bucket: string;
|
|
37
|
+
copySource: string;
|
|
38
|
+
key: string;
|
|
39
|
+
};
|