@punks/backend-entity-manager 0.0.437 → 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,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,18 @@ 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
|
+
});
|
|
309
|
+
console.log("parsed", parsedColumn);
|
|
305
310
|
entity[column.selector] = column.array
|
|
306
311
|
? splitArrayColumn(parsedColumn, column.arraySeparator)
|
|
307
312
|
.map((x) => applyModifiers(x, column.modifiers))
|
|
308
313
|
.filter((x) => isValidValue(x))
|
|
309
314
|
: applyModifiers(parsedColumn, column.modifiers);
|
|
310
|
-
delete entity[
|
|
315
|
+
delete entity[columnName];
|
|
311
316
|
}
|
|
312
317
|
const validationErrors = [];
|
|
313
318
|
for (const column of definition.columns) {
|
|
@@ -340,10 +345,9 @@ class EntitySerializer {
|
|
|
340
345
|
},
|
|
341
346
|
};
|
|
342
347
|
}
|
|
343
|
-
parseColumnValue(row,
|
|
344
|
-
const
|
|
345
|
-
|
|
346
|
-
return definition.parser ? definition.parser(rawValue) : rawValue;
|
|
348
|
+
parseColumnValue({ row, columnName, parser, }) {
|
|
349
|
+
const value = row[normalizeSheetColumn(columnName)];
|
|
350
|
+
return parser ? parser(value) : value;
|
|
347
351
|
}
|
|
348
352
|
async createSample(format) {
|
|
349
353
|
return await this.buildSampleFile(format);
|