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