@punks/backend-entity-manager 0.0.489 → 0.0.491

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 CHANGED
@@ -22888,12 +22888,18 @@ exports.DataSerializationFormat = void 0;
22888
22888
  DataSerializationFormat["Xlsx"] = "xlsx";
22889
22889
  })(exports.DataSerializationFormat || (exports.DataSerializationFormat = {}));
22890
22890
 
22891
- const DEFAULT_DELIMITER = ";";
22891
+ const getColumnValue = (item, definition) => {
22892
+ return typeof definition.selector === "function"
22893
+ ? definition.selector(item)
22894
+ : item[definition.selector];
22895
+ };
22892
22896
  const DEFAULT_ARRAY_SEPARATOR = "|";
22893
22897
  const joinArrayColumn = (value, separator) => value
22894
22898
  ?.map((x) => x.toString().trim())
22895
22899
  .filter((x) => x)
22896
22900
  .join(separator ?? DEFAULT_ARRAY_SEPARATOR);
22901
+
22902
+ const DEFAULT_DELIMITER = ";";
22897
22903
  class DataExportSerializer {
22898
22904
  serialize(items, exportParams) {
22899
22905
  switch (exportParams.format) {
@@ -22903,7 +22909,7 @@ class DataExportSerializer {
22903
22909
  content: Buffer.from(backendCore.csvBuild(items, exportParams.columns.map((c) => ({
22904
22910
  name: c.name,
22905
22911
  value: (item) => {
22906
- const value = this.getColumnValue(item, c);
22912
+ const value = getColumnValue(item, c);
22907
22913
  return c.array
22908
22914
  ? joinArrayColumn(value, c.arraySeparator)
22909
22915
  : value;
@@ -22921,7 +22927,7 @@ class DataExportSerializer {
22921
22927
  columns: exportParams.columns.map((c) => ({
22922
22928
  header: c.name,
22923
22929
  value: (item) => {
22924
- const value = this.getColumnValue(item, c);
22930
+ const value = getColumnValue(item, c);
22925
22931
  return c.array
22926
22932
  ? joinArrayColumn(value, c.arraySeparator)
22927
22933
  : value;
@@ -22937,11 +22943,6 @@ class DataExportSerializer {
22937
22943
  };
22938
22944
  }
22939
22945
  }
22940
- getColumnValue(item, definition) {
22941
- return typeof definition.selector === "function"
22942
- ? definition.selector(item)
22943
- : item[definition.selector];
22944
- }
22945
22946
  }
22946
22947
 
22947
22948
  exports.DataExportService = class DataExportService {
@@ -23016,6 +23017,42 @@ exports.DataExportService = __decorate([
23016
23017
  __metadata("design:paramtypes", [exports.EntityManagerRegistry])
23017
23018
  ], exports.DataExportService);
23018
23019
 
23020
+ class DataSheetsBuilder {
23021
+ constructor() {
23022
+ this.sheets = [];
23023
+ }
23024
+ addSheet(sheet) {
23025
+ this.sheets.push(sheet);
23026
+ }
23027
+ async build() {
23028
+ return {
23029
+ contentType: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
23030
+ content: Buffer.from(backendCore.excelBuild(...this.sheets.map((s) => ({
23031
+ data: s.data,
23032
+ sheetName: s.name,
23033
+ columns: s.columns.map((c) => ({
23034
+ header: c.name,
23035
+ value: (item) => {
23036
+ const value = getColumnValue(item, c);
23037
+ return c.array
23038
+ ? joinArrayColumn(value, c.arraySeparator)
23039
+ : value;
23040
+ },
23041
+ headerSize: c.colSpan,
23042
+ })),
23043
+ })))),
23044
+ };
23045
+ }
23046
+ }
23047
+ exports.DataSheetsExporterService = class DataSheetsExporterService {
23048
+ createBuilder() {
23049
+ return new DataSheetsBuilder();
23050
+ }
23051
+ };
23052
+ exports.DataSheetsExporterService = __decorate([
23053
+ common.Injectable()
23054
+ ], exports.DataSheetsExporterService);
23055
+
23019
23056
  exports.CacheService = class CacheService {
23020
23057
  constructor(registry) {
23021
23058
  this.registry = registry;
@@ -23999,6 +24036,7 @@ const Services$1 = [
23999
24036
  exports.AppHashingService,
24000
24037
  exports.CacheService,
24001
24038
  exports.DataExportService,
24039
+ exports.DataSheetsExporterService,
24002
24040
  exports.EntityManagerService,
24003
24041
  exports.EmailService,
24004
24042
  exports.EventsService,
@@ -45397,6 +45435,7 @@ exports.AwsS3BucketError = AwsS3BucketError;
45397
45435
  exports.AwsS3MediaError = AwsS3MediaError;
45398
45436
  exports.AwsSesEmailTemplate = AwsSesEmailTemplate;
45399
45437
  exports.CurrentUser = CurrentUser;
45438
+ exports.DataSheetsBuilder = DataSheetsBuilder;
45400
45439
  exports.DynamoDbCacheInstance = DynamoDbCacheInstance;
45401
45440
  exports.DynamoDbCollection = DynamoDbCollection;
45402
45441
  exports.EntityManagerConfigurationError = EntityManagerConfigurationError;