@punks/backend-entity-manager 0.0.405 → 0.0.407
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 +22 -9
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/types/platforms/nest/services/export/service.d.ts +8 -2
- package/dist/cjs/types/platforms/nest/services/export/types.d.ts +2 -1
- package/dist/esm/index.js +22 -9
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/types/platforms/nest/services/export/service.d.ts +8 -2
- package/dist/esm/types/platforms/nest/services/export/types.d.ts +2 -1
- package/dist/index.d.ts +9 -3
- package/package.json +1 -1
package/dist/cjs/index.js
CHANGED
|
@@ -22865,40 +22865,53 @@ exports.DataExportService = class DataExportService {
|
|
|
22865
22865
|
}
|
|
22866
22866
|
async exportData(data, input) {
|
|
22867
22867
|
const file = await this.extractData(data, input);
|
|
22868
|
-
const downloadUrl = await this.uploadExportFile(file, {
|
|
22869
|
-
dataName: input.
|
|
22868
|
+
const { downloadUrl, fileName } = await this.uploadExportFile(file, {
|
|
22869
|
+
dataName: input.dataName,
|
|
22870
|
+
fileName: input.fileName,
|
|
22870
22871
|
format: input.format,
|
|
22871
22872
|
});
|
|
22872
22873
|
return {
|
|
22873
22874
|
downloadUrl,
|
|
22874
|
-
file
|
|
22875
|
+
file: {
|
|
22876
|
+
fileName,
|
|
22877
|
+
content: file.content,
|
|
22878
|
+
contentType: file.contentType,
|
|
22879
|
+
},
|
|
22875
22880
|
};
|
|
22876
22881
|
}
|
|
22877
22882
|
async extractData(data, input) {
|
|
22878
22883
|
const content = new DataExportSerializer().serialize(data, {
|
|
22879
22884
|
columns: input.columns,
|
|
22880
22885
|
format: input.format,
|
|
22881
|
-
name: input.
|
|
22886
|
+
name: input.dataName,
|
|
22882
22887
|
});
|
|
22883
22888
|
return {
|
|
22884
22889
|
content: content.content,
|
|
22885
22890
|
contentType: content.contentType,
|
|
22886
22891
|
};
|
|
22887
22892
|
}
|
|
22888
|
-
async uploadExportFile(file, { dataName, format, }) {
|
|
22889
|
-
const
|
|
22893
|
+
async uploadExportFile(file, { dataName, fileName, format, }) {
|
|
22894
|
+
const fileNameWithExtension = this.buildExportFileName(fileName, format);
|
|
22895
|
+
const filePath = this.buildExportFilePath(dataName, fileNameWithExtension);
|
|
22890
22896
|
await this.defaultBucketProvider.fileUpload({
|
|
22891
22897
|
bucket: this.defaultFileProvider.defaultBucket,
|
|
22892
22898
|
filePath,
|
|
22893
22899
|
content: file.content,
|
|
22894
22900
|
contentType: file.contentType,
|
|
22895
22901
|
});
|
|
22896
|
-
|
|
22902
|
+
const downloadUrl = await this.defaultFileProvider.getFileProviderDownloadUrl({
|
|
22897
22903
|
reference: filePath,
|
|
22898
22904
|
});
|
|
22905
|
+
return {
|
|
22906
|
+
downloadUrl,
|
|
22907
|
+
fileName: fileNameWithExtension,
|
|
22908
|
+
};
|
|
22909
|
+
}
|
|
22910
|
+
buildExportFileName(fileName, format) {
|
|
22911
|
+
return `${fileName}.${format}`;
|
|
22899
22912
|
}
|
|
22900
|
-
buildExportFilePath(dataName,
|
|
22901
|
-
return `/data-export/${dataName}/${backendCore.createDayPath(new Date())}/${backendCore.newUuid()}_${
|
|
22913
|
+
buildExportFilePath(dataName, fileName) {
|
|
22914
|
+
return `/data-export/${dataName}/${backendCore.createDayPath(new Date())}/${backendCore.newUuid()}_${fileName}`;
|
|
22902
22915
|
}
|
|
22903
22916
|
get defaultFileProvider() {
|
|
22904
22917
|
return this.registry
|