@punks/backend-entity-manager 0.0.354 → 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 +12 -6
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/index.js +12 -6
- package/dist/esm/index.js.map +1 -1
- package/package.json +1 -1
package/dist/esm/index.js
CHANGED
|
@@ -219,7 +219,8 @@ class EntitySerializer {
|
|
|
219
219
|
return records.map((x, i) => this.convertSheetRecord(x, definition, i));
|
|
220
220
|
}
|
|
221
221
|
convertSheetRecord(record, definition, rowIndex) {
|
|
222
|
-
if (
|
|
222
|
+
if (this.options?.useTypeColumn &&
|
|
223
|
+
(!record._type || record._type !== this.entityName)) {
|
|
223
224
|
throw new Error(`Invalid record type ${record._type} -> record: \n${JSON.stringify(record)}`);
|
|
224
225
|
}
|
|
225
226
|
const entity = {};
|
|
@@ -339,10 +340,14 @@ class EntitySerializer {
|
|
|
339
340
|
fileName,
|
|
340
341
|
contentType: "text/csv",
|
|
341
342
|
content: Buffer.from(csvBuild(data, [
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
343
|
+
...(this.options?.useTypeColumn
|
|
344
|
+
? [
|
|
345
|
+
{
|
|
346
|
+
name: "_type",
|
|
347
|
+
value: () => this.entityName,
|
|
348
|
+
},
|
|
349
|
+
]
|
|
350
|
+
: []),
|
|
346
351
|
...definition.columns.map((c) => ({
|
|
347
352
|
name: c.name,
|
|
348
353
|
value: (item) => this.getColumnValue(item, c),
|
|
@@ -40324,8 +40329,9 @@ const newUuid = newUuid$1;
|
|
|
40324
40329
|
|
|
40325
40330
|
const fieldRequiredValidator = (item, selector) => {
|
|
40326
40331
|
const value = selector(item);
|
|
40332
|
+
const isValid = typeof value === "string" ? value.trim().length > 0 : !!value;
|
|
40327
40333
|
return {
|
|
40328
|
-
isValid
|
|
40334
|
+
isValid,
|
|
40329
40335
|
validationErrors: value ? [] : [{ errorCode: "required" }],
|
|
40330
40336
|
};
|
|
40331
40337
|
};
|