@punks/backend-entity-manager 0.0.434 → 0.0.436

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.
@@ -32,6 +32,7 @@ export type EntitySerializerSheetCustomParser = "date";
32
32
  export type EntitySerializerColumnModifier = "trim" | "lowercase" | "uppercase";
33
33
  export type EntitySerializerColumnDefinition<TSheetItem> = {
34
34
  name: string;
35
+ aliases?: string[];
35
36
  key: string;
36
37
  selector: keyof TSheetItem | ((item: TSheetItem) => any);
37
38
  colSpan?: number;
package/dist/esm/index.js CHANGED
@@ -274,11 +274,11 @@ class EntitySerializer {
274
274
  }
275
275
  const entity = (definition.autoColumns ? { ...record } : {});
276
276
  for (const column of definition.columns) {
277
- const columnName = normalizeSheetColumn(column.name);
278
- if (!(column.name in record))
277
+ const columnName = [column.name, ...(column?.aliases ?? [])].find((x) => x in record) ?? "";
278
+ if (!columnName)
279
279
  continue;
280
280
  if (column.parseAction) {
281
- column.parseAction(record[columnName], entity);
281
+ column.parseAction(record[normalizeSheetColumn(columnName)], entity);
282
282
  continue;
283
283
  }
284
284
  if (typeof column.selector === "function") {
@@ -290,9 +290,7 @@ class EntitySerializer {
290
290
  .map((x) => applyModifiers(x, column.modifiers))
291
291
  .filter((x) => isValidValue(x))
292
292
  : applyModifiers(parsedColumn, column.modifiers);
293
- console.log("name", column.name);
294
- console.log("entity", entity);
295
- // delete entity[column.name]
293
+ delete entity[column.name];
296
294
  }
297
295
  const validationErrors = [];
298
296
  for (const column of definition.columns) {