@punks/backend-entity-manager 0.0.355 → 0.0.356
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 +10 -5
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/index.js +10 -5
- package/dist/esm/index.js.map +1 -1
- package/package.json +1 -1
package/dist/cjs/index.js
CHANGED
|
@@ -234,7 +234,8 @@ class EntitySerializer {
|
|
|
234
234
|
return records.map((x, i) => this.convertSheetRecord(x, definition, i));
|
|
235
235
|
}
|
|
236
236
|
convertSheetRecord(record, definition, rowIndex) {
|
|
237
|
-
if (
|
|
237
|
+
if (this.options?.useTypeColumn &&
|
|
238
|
+
(!record._type || record._type !== this.entityName)) {
|
|
238
239
|
throw new Error(`Invalid record type ${record._type} -> record: \n${JSON.stringify(record)}`);
|
|
239
240
|
}
|
|
240
241
|
const entity = {};
|
|
@@ -354,10 +355,14 @@ class EntitySerializer {
|
|
|
354
355
|
fileName,
|
|
355
356
|
contentType: "text/csv",
|
|
356
357
|
content: Buffer.from(backendCore.csvBuild(data, [
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
358
|
+
...(this.options?.useTypeColumn
|
|
359
|
+
? [
|
|
360
|
+
{
|
|
361
|
+
name: "_type",
|
|
362
|
+
value: () => this.entityName,
|
|
363
|
+
},
|
|
364
|
+
]
|
|
365
|
+
: []),
|
|
361
366
|
...definition.columns.map((c) => ({
|
|
362
367
|
name: c.name,
|
|
363
368
|
value: (item) => this.getColumnValue(item, c),
|