@punks/backend-entity-manager 0.0.482 → 0.0.484
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 +24 -0
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/types/abstractions/buckets.d.ts +5 -0
- package/dist/cjs/types/platforms/nest/plugins/buckets/aws-s3/provider/bucket.d.ts +2 -1
- package/dist/cjs/types/platforms/nest/plugins/buckets/testing/mock.d.ts +2 -1
- package/dist/esm/index.js +24 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/types/abstractions/buckets.d.ts +5 -0
- package/dist/esm/types/platforms/nest/plugins/buckets/aws-s3/provider/bucket.d.ts +2 -1
- package/dist/esm/types/platforms/nest/plugins/buckets/testing/mock.d.ts +2 -1
- package/dist/index.d.ts +8 -1
- package/package.json +1 -1
|
@@ -29,6 +29,10 @@ export type BucketFolderExistsInput = {
|
|
|
29
29
|
bucket: string;
|
|
30
30
|
path: string;
|
|
31
31
|
};
|
|
32
|
+
export type BucketFileExistsInput = {
|
|
33
|
+
bucket: string;
|
|
34
|
+
filePath: string;
|
|
35
|
+
};
|
|
32
36
|
export type BucketFileDownloadInput = {
|
|
33
37
|
bucket: string;
|
|
34
38
|
filePath: string;
|
|
@@ -64,6 +68,7 @@ export interface IBucketProvider {
|
|
|
64
68
|
folderList(input: BucketFolderListInput): Promise<BucketFolderListResult>;
|
|
65
69
|
folderEnsure(input: BucketFolderEnsureInput): Promise<void>;
|
|
66
70
|
folderExists(input: BucketFolderExistsInput): Promise<boolean>;
|
|
71
|
+
fileExists(input: BucketFileExistsInput): Promise<boolean>;
|
|
67
72
|
fileDownload(input: BucketFileDownloadInput): Promise<Buffer>;
|
|
68
73
|
filePublicUrlCreate(input: BucketFilePublicUrlCreateInput): Promise<string>;
|
|
69
74
|
fileUpload(input: BucketFileUploadInput): Promise<void>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
-
import { BucketFileCopyInput, BucketFileDeleteInput, BucketFileDownloadInput, BucketFileMoveInput, BucketFilePublicUrlCreateInput, BucketFileUploadInput, BucketFolderEnsureInput, BucketFolderExistsInput, BucketFolderListInput, BucketFolderListResult, IBucketProvider } from "../../../../../../abstractions/buckets";
|
|
2
|
+
import { BucketFileCopyInput, BucketFileDeleteInput, BucketFileDownloadInput, BucketFileExistsInput, 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();
|
|
@@ -8,6 +8,7 @@ export declare class AwsS3BucketProvider implements IBucketProvider {
|
|
|
8
8
|
folderCreate(input: BucketFolderEnsureInput): Promise<void>;
|
|
9
9
|
folderExists(input: BucketFolderExistsInput): Promise<boolean>;
|
|
10
10
|
fileDownload(input: BucketFileDownloadInput): Promise<Buffer>;
|
|
11
|
+
fileExists(input: BucketFileExistsInput): Promise<boolean>;
|
|
11
12
|
filePublicUrlCreate(input: BucketFilePublicUrlCreateInput): Promise<string>;
|
|
12
13
|
fileUpload(input: BucketFileUploadInput): Promise<void>;
|
|
13
14
|
fileDelete(input: BucketFileDeleteInput): Promise<void>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import { FileProviderDownloadData, FileProviderDownloadUrl, FileProviderReference, FileProviderUploadData, IFileProvider } from "../../../../../abstractions";
|
|
3
|
-
import { BucketFileDeleteInput, BucketFileDownloadInput, BucketFilePublicUrlCreateInput, BucketFileUploadInput, BucketFolderEnsureInput, BucketFolderExistsInput, BucketFolderListInput, BucketFolderListResult, IBucketProvider } from "../../../../../abstractions/buckets";
|
|
3
|
+
import { BucketFileDeleteInput, BucketFileDownloadInput, BucketFileExistsInput, BucketFilePublicUrlCreateInput, BucketFileUploadInput, BucketFolderEnsureInput, BucketFolderExistsInput, BucketFolderListInput, BucketFolderListResult, IBucketProvider } from "../../../../../abstractions/buckets";
|
|
4
4
|
export declare class InMemoryFileProvider implements IFileProvider {
|
|
5
5
|
private readonly provider;
|
|
6
6
|
constructor();
|
|
@@ -17,6 +17,7 @@ export declare class InMemoryBucketProvider implements IBucketProvider {
|
|
|
17
17
|
folderList(input: BucketFolderListInput): Promise<BucketFolderListResult>;
|
|
18
18
|
folderEnsure(input: BucketFolderEnsureInput): Promise<void>;
|
|
19
19
|
folderExists(input: BucketFolderExistsInput): Promise<boolean>;
|
|
20
|
+
fileExists(input: BucketFileExistsInput): Promise<boolean>;
|
|
20
21
|
fileDownload(input: BucketFileDownloadInput): Promise<Buffer>;
|
|
21
22
|
filePublicUrlCreate(input: BucketFilePublicUrlCreateInput): Promise<string>;
|
|
22
23
|
fileUpload(input: BucketFileUploadInput): Promise<void>;
|
package/dist/esm/index.js
CHANGED
|
@@ -35757,6 +35757,9 @@ let AwsS3BucketProvider = class AwsS3BucketProvider {
|
|
|
35757
35757
|
return (result.ContentLength ?? 0) > 0;
|
|
35758
35758
|
}
|
|
35759
35759
|
catch (e) {
|
|
35760
|
+
if (e.Code === "NoSuchKey") {
|
|
35761
|
+
return false;
|
|
35762
|
+
}
|
|
35760
35763
|
throw new AwsS3BucketError(`AwsS3Bucket | folderExists | Error -> ${e.message}`);
|
|
35761
35764
|
}
|
|
35762
35765
|
}
|
|
@@ -35772,6 +35775,21 @@ let AwsS3BucketProvider = class AwsS3BucketProvider {
|
|
|
35772
35775
|
throw new AwsS3BucketError(`AWS BUCKET | downloadFile | ${input.bucket} | ${input.filePath} | Error -> ${e.message}`);
|
|
35773
35776
|
}
|
|
35774
35777
|
}
|
|
35778
|
+
async fileExists(input) {
|
|
35779
|
+
try {
|
|
35780
|
+
const result = await this.client.send(new GetObjectCommand({
|
|
35781
|
+
Bucket: input.bucket,
|
|
35782
|
+
Key: input.filePath,
|
|
35783
|
+
}));
|
|
35784
|
+
return (result.ContentLength ?? 0) > 0;
|
|
35785
|
+
}
|
|
35786
|
+
catch (e) {
|
|
35787
|
+
if (e.Code === "NoSuchKey") {
|
|
35788
|
+
return false;
|
|
35789
|
+
}
|
|
35790
|
+
throw new AwsS3BucketError(`AwsS3Bucket | fileExists | Error -> ${e.message}`);
|
|
35791
|
+
}
|
|
35792
|
+
}
|
|
35775
35793
|
async filePublicUrlCreate(input) {
|
|
35776
35794
|
try {
|
|
35777
35795
|
return await getSignedUrl(this.client, new GetObjectCommand({
|
|
@@ -36011,6 +36029,12 @@ let InMemoryBucketProvider = class InMemoryBucketProvider {
|
|
|
36011
36029
|
const folderKey = `${input.bucket}/${input.path}`;
|
|
36012
36030
|
return !!this.inMemoryFolders[folderKey];
|
|
36013
36031
|
}
|
|
36032
|
+
async fileExists(input) {
|
|
36033
|
+
// Implement fileExists logic here
|
|
36034
|
+
// Check if the file exists in inMemoryStorage
|
|
36035
|
+
const fileKey = `${input.bucket}/${input.filePath}`;
|
|
36036
|
+
return !!this.inMemoryStorage[fileKey];
|
|
36037
|
+
}
|
|
36014
36038
|
async fileDownload(input) {
|
|
36015
36039
|
// Implement fileDownload logic here
|
|
36016
36040
|
// Retrieve the file content from inMemoryStorage based on the filePath
|