@punks/backend-entity-manager 0.0.406 → 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.
@@ -1,3 +1,4 @@
1
+ /// <reference types="node" />
1
2
  import { DataExportFile, DataExportInput } from "./types";
2
3
  import { EntityManagerRegistry } from "../../ioc/registry";
3
4
  export declare class DataExportService {
@@ -5,10 +6,15 @@ export declare class DataExportService {
5
6
  constructor(registry: EntityManagerRegistry);
6
7
  exportData<TSheetItem>(data: TSheetItem[], input: DataExportInput<TSheetItem>): Promise<{
7
8
  downloadUrl: import("../../../../abstractions/files").FileProviderDownloadUrl;
8
- file: DataExportFile;
9
+ file: {
10
+ fileName: string;
11
+ content: Buffer;
12
+ contentType: string;
13
+ };
9
14
  }>;
10
15
  extractData<TSheetItem>(data: TSheetItem[], input: Omit<DataExportInput<TSheetItem>, "fileName">): Promise<DataExportFile>;
11
16
  private uploadExportFile;
17
+ private buildExportFileName;
12
18
  private buildExportFilePath;
13
19
  private get defaultFileProvider();
14
20
  private get defaultBucketProvider();
package/dist/esm/index.js CHANGED
@@ -22850,14 +22850,18 @@ let DataExportService = class DataExportService {
22850
22850
  }
22851
22851
  async exportData(data, input) {
22852
22852
  const file = await this.extractData(data, input);
22853
- const downloadUrl = await this.uploadExportFile(file, {
22853
+ const { downloadUrl, fileName } = await this.uploadExportFile(file, {
22854
22854
  dataName: input.dataName,
22855
22855
  fileName: input.fileName,
22856
22856
  format: input.format,
22857
22857
  });
22858
22858
  return {
22859
22859
  downloadUrl,
22860
- file,
22860
+ file: {
22861
+ fileName,
22862
+ content: file.content,
22863
+ contentType: file.contentType,
22864
+ },
22861
22865
  };
22862
22866
  }
22863
22867
  async extractData(data, input) {
@@ -22872,19 +22876,27 @@ let DataExportService = class DataExportService {
22872
22876
  };
22873
22877
  }
22874
22878
  async uploadExportFile(file, { dataName, fileName, format, }) {
22875
- const filePath = this.buildExportFilePath(dataName, fileName, format);
22879
+ const fileNameWithExtension = this.buildExportFileName(fileName, format);
22880
+ const filePath = this.buildExportFilePath(dataName, fileNameWithExtension);
22876
22881
  await this.defaultBucketProvider.fileUpload({
22877
22882
  bucket: this.defaultFileProvider.defaultBucket,
22878
22883
  filePath,
22879
22884
  content: file.content,
22880
22885
  contentType: file.contentType,
22881
22886
  });
22882
- return await this.defaultFileProvider.getFileProviderDownloadUrl({
22887
+ const downloadUrl = await this.defaultFileProvider.getFileProviderDownloadUrl({
22883
22888
  reference: filePath,
22884
22889
  });
22890
+ return {
22891
+ downloadUrl,
22892
+ fileName: fileNameWithExtension,
22893
+ };
22894
+ }
22895
+ buildExportFileName(fileName, format) {
22896
+ return `${fileName}.${format}`;
22885
22897
  }
22886
- buildExportFilePath(dataName, fileName, format) {
22887
- return `/data-export/${dataName}/${createDayPath$2(new Date())}/${newUuid$1()}_${fileName}.${format}`;
22898
+ buildExportFilePath(dataName, fileName) {
22899
+ return `/data-export/${dataName}/${createDayPath$2(new Date())}/${newUuid$1()}_${fileName}`;
22888
22900
  }
22889
22901
  get defaultFileProvider() {
22890
22902
  return this.registry