@punks/backend-entity-manager 0.0.457 → 0.0.459
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/cjs/index.js +13 -6
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/types/abstractions/actions.d.ts +5 -0
- package/dist/cjs/types/abstractions/commands.d.ts +1 -1
- package/dist/cjs/types/abstractions/files.d.ts +5 -0
- package/dist/cjs/types/platforms/nest/plugins/buckets/aws-s3/provider/files.d.ts +1 -0
- package/dist/esm/index.js +13 -6
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/types/abstractions/actions.d.ts +5 -0
- package/dist/esm/types/abstractions/commands.d.ts +1 -1
- package/dist/esm/types/abstractions/files.d.ts +5 -0
- package/dist/esm/types/platforms/nest/plugins/buckets/aws-s3/provider/files.d.ts +1 -0
- package/dist/index.d.ts +11 -1
- package/package.json +1 -1
|
@@ -19,6 +19,11 @@ export interface IEntitiesDeleteAction<TEntity, TEntitiesDeleteParameters extend
|
|
|
19
19
|
export interface IEntityGetAction<TEntity, TEntityId, TEntityDto> {
|
|
20
20
|
execute(id: TEntityId): Promise<TEntityDto | undefined>;
|
|
21
21
|
}
|
|
22
|
+
export interface IEntityGetAction<TEntity, TEntityId, TEntityDto> {
|
|
23
|
+
execute(id: TEntityId, options?: {
|
|
24
|
+
relations?: string[];
|
|
25
|
+
}): Promise<TEntityDto | undefined>;
|
|
26
|
+
}
|
|
22
27
|
export interface IEntityExistsAction<TEntity, TEntityFilters extends ISearchFilters> {
|
|
23
28
|
execute(filters: TEntityFilters): Promise<boolean>;
|
|
24
29
|
}
|
|
@@ -49,7 +49,7 @@ export interface IEntitiesSampleDownloadCommand<TEntity> {
|
|
|
49
49
|
}
|
|
50
50
|
export interface IEntityUpsertByParameters<TEntity, TEntityFilters extends ISearchFilters> {
|
|
51
51
|
filter: TEntityFilters;
|
|
52
|
-
data: Partial<
|
|
52
|
+
data: Partial<TEntity>;
|
|
53
53
|
}
|
|
54
54
|
export interface IEntityUpsertByResult {
|
|
55
55
|
id: string;
|
|
@@ -5,6 +5,8 @@ export type FileData = {
|
|
|
5
5
|
contentType: string;
|
|
6
6
|
fileName: string;
|
|
7
7
|
folderPath: string;
|
|
8
|
+
storageFilePath?: string;
|
|
9
|
+
storageBucket?: string;
|
|
8
10
|
metadata?: Record<string, any>;
|
|
9
11
|
};
|
|
10
12
|
export type FileDownloadUrl = {
|
|
@@ -50,12 +52,15 @@ export interface IFilesReferenceRepository {
|
|
|
50
52
|
}
|
|
51
53
|
export type FileProviderReference = {
|
|
52
54
|
reference: string;
|
|
55
|
+
bucket?: string;
|
|
53
56
|
};
|
|
54
57
|
export type FileProviderUploadData = {
|
|
55
58
|
fileId?: string;
|
|
56
59
|
fileName: string;
|
|
60
|
+
filePath?: string;
|
|
57
61
|
content: Buffer;
|
|
58
62
|
contentType: string;
|
|
63
|
+
bucket?: string;
|
|
59
64
|
};
|
|
60
65
|
export type FileProviderDownloadData = {
|
|
61
66
|
content: Buffer;
|
|
@@ -9,5 +9,6 @@ export declare class AwsS3FileProvider implements IFileProvider {
|
|
|
9
9
|
downloadFile(reference: FileProviderReference): Promise<FileProviderDownloadData>;
|
|
10
10
|
getFileProviderDownloadUrl(reference: FileProviderReference): Promise<FileProviderDownloadUrl>;
|
|
11
11
|
private getBucketFileUploadPath;
|
|
12
|
+
private getBucketFileUploadDayPath;
|
|
12
13
|
get defaultBucket(): string;
|
|
13
14
|
}
|
package/dist/esm/index.js
CHANGED
|
@@ -22994,6 +22994,8 @@ let FilesManager = class FilesManager {
|
|
|
22994
22994
|
content: file.content,
|
|
22995
22995
|
contentType: file.contentType,
|
|
22996
22996
|
fileName: file.fileName,
|
|
22997
|
+
filePath: file.storageFilePath,
|
|
22998
|
+
bucket: file.storageBucket,
|
|
22997
22999
|
});
|
|
22998
23000
|
const record = await this.referencesRepo.createReference({
|
|
22999
23001
|
fileId: file.fileId,
|
|
@@ -35824,9 +35826,11 @@ let AwsS3FileProvider = class AwsS3FileProvider {
|
|
|
35824
35826
|
return "awsS3";
|
|
35825
35827
|
}
|
|
35826
35828
|
async uploadFile(file) {
|
|
35827
|
-
const path =
|
|
35829
|
+
const path = file.filePath
|
|
35830
|
+
? this.getBucketFileUploadPath(file.fileName, file.filePath)
|
|
35831
|
+
: this.getBucketFileUploadDayPath(file.fileName, new Date());
|
|
35828
35832
|
await this.bucket.fileUpload({
|
|
35829
|
-
bucket: this.defaultBucket,
|
|
35833
|
+
bucket: file.bucket ?? this.defaultBucket,
|
|
35830
35834
|
filePath: path,
|
|
35831
35835
|
content: file.content,
|
|
35832
35836
|
contentType: file.contentType,
|
|
@@ -35837,13 +35841,13 @@ let AwsS3FileProvider = class AwsS3FileProvider {
|
|
|
35837
35841
|
}
|
|
35838
35842
|
async deleteFile(reference) {
|
|
35839
35843
|
await this.bucket.fileDelete({
|
|
35840
|
-
bucket: this.defaultBucket,
|
|
35844
|
+
bucket: reference.bucket ?? this.defaultBucket,
|
|
35841
35845
|
filePath: reference.reference,
|
|
35842
35846
|
});
|
|
35843
35847
|
}
|
|
35844
35848
|
async downloadFile(reference) {
|
|
35845
35849
|
const content = await this.bucket.fileDownload({
|
|
35846
|
-
bucket: this.defaultBucket,
|
|
35850
|
+
bucket: reference.bucket ?? this.defaultBucket,
|
|
35847
35851
|
filePath: reference.reference,
|
|
35848
35852
|
});
|
|
35849
35853
|
return {
|
|
@@ -35852,7 +35856,7 @@ let AwsS3FileProvider = class AwsS3FileProvider {
|
|
|
35852
35856
|
}
|
|
35853
35857
|
async getFileProviderDownloadUrl(reference) {
|
|
35854
35858
|
const url = await this.bucket.filePublicUrlCreate({
|
|
35855
|
-
bucket: this.defaultBucket,
|
|
35859
|
+
bucket: reference.bucket ?? this.defaultBucket,
|
|
35856
35860
|
expirationMinutes: awsBucketSettings.value.publicLinksExpirationMinutes,
|
|
35857
35861
|
filePath: reference.reference,
|
|
35858
35862
|
});
|
|
@@ -35860,7 +35864,10 @@ let AwsS3FileProvider = class AwsS3FileProvider {
|
|
|
35860
35864
|
downloadUrl: url,
|
|
35861
35865
|
};
|
|
35862
35866
|
}
|
|
35863
|
-
getBucketFileUploadPath(fileName,
|
|
35867
|
+
getBucketFileUploadPath(fileName, filePath) {
|
|
35868
|
+
return `${ensureTailingSlash(filePath)}${ensureStartSlash(fileName)}`;
|
|
35869
|
+
}
|
|
35870
|
+
getBucketFileUploadDayPath(fileName, date) {
|
|
35864
35871
|
return `${ensureTailingSlash(awsBucketSettings.value.paths.filesUpload)}${createDayPath(date)}${ensureStartSlash(newUuid$1())}_${fileName}`;
|
|
35865
35872
|
}
|
|
35866
35873
|
get defaultBucket() {
|