@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 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 (!record._type || record._type !== this.entityName) {
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
- name: "_type",
359
- value: () => this.entityName,
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),
@@ -40339,8 +40344,9 @@ const newUuid = backendCore.newUuid;
40339
40344
 
40340
40345
  const fieldRequiredValidator = (item, selector) => {
40341
40346
  const value = selector(item);
40347
+ const isValid = typeof value === "string" ? value.trim().length > 0 : !!value;
40342
40348
  return {
40343
- isValid: !!value,
40349
+ isValid,
40344
40350
  validationErrors: value ? [] : [{ errorCode: "required" }],
40345
40351
  };
40346
40352
  };