@punks/backend-entity-manager 0.0.364 → 0.0.365

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
@@ -192,6 +192,7 @@ class EntitySeeder {
192
192
  }
193
193
  }
194
194
 
195
+ const normalizeSheetColumn = (column) => column.replace(/ /g, "").toLowerCase();
195
196
  const DEFAULT_DELIMITER = ";";
196
197
  class EntitySerializer {
197
198
  constructor(services, options) {
@@ -230,7 +231,9 @@ class EntitySerializer {
230
231
  return records.map((x, i) => this.convertSheetRecord(x, definition, i));
231
232
  }
232
233
  parseXlsx(data, definition) {
233
- const records = backendCore.excelParse(data);
234
+ const records = backendCore.excelParse(data, {
235
+ keysTransform: backendCore.ExcelKeyTransform.Lower,
236
+ });
234
237
  return records.map((x, i) => this.convertSheetRecord(x, definition, i));
235
238
  }
236
239
  convertSheetRecord(record, definition, rowIndex) {
@@ -240,8 +243,9 @@ class EntitySerializer {
240
243
  }
241
244
  const entity = {};
242
245
  for (const column of definition.columns) {
246
+ const columnName = normalizeSheetColumn(column.name);
243
247
  if (column.parseAction) {
244
- column.parseAction(record[column.name], entity);
248
+ column.parseAction(record[columnName], entity);
245
249
  continue;
246
250
  }
247
251
  if (typeof column.selector === "function") {
@@ -278,7 +282,8 @@ class EntitySerializer {
278
282
  };
279
283
  }
280
284
  parseColumnValue(row, definition) {
281
- const rawValue = row[definition.name];
285
+ const columnName = normalizeSheetColumn(definition.name);
286
+ const rawValue = row[columnName];
282
287
  return definition.parser ? definition.parser(rawValue) : rawValue;
283
288
  }
284
289
  async createSample(format) {