@punks/backend-entity-manager 0.0.428 → 0.0.430
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 +5 -4
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/types/abstractions/serializer.d.ts +1 -0
- package/dist/esm/index.js +5 -4
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/types/abstractions/serializer.d.ts +1 -0
- package/dist/index.d.ts +1 -0
- package/package.json +1 -1
package/dist/cjs/index.js
CHANGED
|
@@ -283,15 +283,14 @@ class EntitySerializer {
|
|
|
283
283
|
return records.map((x, i) => this.convertSheetRecord(x, definition, i));
|
|
284
284
|
}
|
|
285
285
|
convertSheetRecord(record, definition, rowIndex) {
|
|
286
|
-
console.log("record", record);
|
|
287
|
-
console.log("definition", definition);
|
|
288
|
-
console.log("rowIndex", rowIndex);
|
|
289
286
|
if (definition.sheet?.useTypeColumn &&
|
|
290
287
|
(!record._type || record._type !== this.entityName)) {
|
|
291
288
|
throw new Error(`Invalid record type ${record._type} -> record: \n${JSON.stringify(record)}`);
|
|
292
289
|
}
|
|
293
|
-
const entity = {};
|
|
290
|
+
const entity = (definition.autoColumns ? { ...record } : {});
|
|
294
291
|
for (const column of definition.columns) {
|
|
292
|
+
if (!(column.name in record))
|
|
293
|
+
continue;
|
|
295
294
|
const columnName = normalizeSheetColumn(column.name);
|
|
296
295
|
if (column.parseAction) {
|
|
297
296
|
column.parseAction(record[columnName], entity);
|
|
@@ -309,6 +308,8 @@ class EntitySerializer {
|
|
|
309
308
|
}
|
|
310
309
|
const validationErrors = [];
|
|
311
310
|
for (const column of definition.columns) {
|
|
311
|
+
if (!(column.name in record))
|
|
312
|
+
continue;
|
|
312
313
|
for (const validator of column.validators ?? []) {
|
|
313
314
|
const result = validator.fn(entity);
|
|
314
315
|
if (!result.isValid) {
|