@punks/backend-entity-manager 0.0.437 → 0.0.440
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
|
@@ -289,7 +289,7 @@ class EntitySerializer {
|
|
|
289
289
|
}
|
|
290
290
|
const entity = (definition.autoColumns ? { ...record } : {});
|
|
291
291
|
for (const column of definition.columns) {
|
|
292
|
-
const columnName = [column.name, ...(column?.aliases ?? [])].find((x) => x in record) ??
|
|
292
|
+
const columnName = [column.name, ...(column?.aliases ?? [])].find((x) => normalizeSheetColumn(x) in record) ?? null;
|
|
293
293
|
console.log("name", columnName);
|
|
294
294
|
console.log("record", entity);
|
|
295
295
|
if (!columnName)
|
|
@@ -301,13 +301,17 @@ class EntitySerializer {
|
|
|
301
301
|
if (typeof column.selector === "function") {
|
|
302
302
|
throw new Error("Function selectors are not supported with parseAction specified");
|
|
303
303
|
}
|
|
304
|
-
const parsedColumn = this.parseColumnValue(
|
|
304
|
+
const parsedColumn = this.parseColumnValue({
|
|
305
|
+
row: record,
|
|
306
|
+
columnName,
|
|
307
|
+
parser: column.parser,
|
|
308
|
+
});
|
|
305
309
|
entity[column.selector] = column.array
|
|
306
310
|
? splitArrayColumn(parsedColumn, column.arraySeparator)
|
|
307
311
|
.map((x) => applyModifiers(x, column.modifiers))
|
|
308
312
|
.filter((x) => isValidValue(x))
|
|
309
313
|
: applyModifiers(parsedColumn, column.modifiers);
|
|
310
|
-
delete entity[
|
|
314
|
+
delete entity[columnName];
|
|
311
315
|
}
|
|
312
316
|
const validationErrors = [];
|
|
313
317
|
for (const column of definition.columns) {
|
|
@@ -340,10 +344,9 @@ class EntitySerializer {
|
|
|
340
344
|
},
|
|
341
345
|
};
|
|
342
346
|
}
|
|
343
|
-
parseColumnValue(row,
|
|
344
|
-
const
|
|
345
|
-
|
|
346
|
-
return definition.parser ? definition.parser(rawValue) : rawValue;
|
|
347
|
+
parseColumnValue({ row, columnName, parser, }) {
|
|
348
|
+
const value = row[normalizeSheetColumn(columnName)];
|
|
349
|
+
return parser ? parser(value) : value;
|
|
347
350
|
}
|
|
348
351
|
async createSample(format) {
|
|
349
352
|
return await this.buildSampleFile(format);
|