@punks/backend-entity-manager 0.0.379 → 0.0.381

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.
@@ -12,6 +12,7 @@ export type ImportEntryValidationError = {
12
12
  column: {
13
13
  name: string;
14
14
  key: string;
15
+ value?: any;
15
16
  };
16
17
  };
17
18
  export type ImportEntryValidationResult = {
package/dist/esm/index.js CHANGED
@@ -186,8 +186,14 @@ class EntitySeeder {
186
186
  const normalizeSheetColumn = (column) => column.replace(/ /g, "").toLowerCase();
187
187
  const DEFAULT_DELIMITER = ";";
188
188
  const DEFAULT_ARRAY_SEPARATOR = "|";
189
- const splitArrayColumn = (value, separator) => value?.toString().split(separator ?? DEFAULT_ARRAY_SEPARATOR);
190
- const joinArrayColumn = (value, separator) => value?.map((x) => x.toString()).join(separator ?? DEFAULT_ARRAY_SEPARATOR);
189
+ const splitArrayColumn = (value, separator) => value
190
+ ?.toString()
191
+ .split(separator ?? DEFAULT_ARRAY_SEPARATOR)
192
+ .filter((x) => x.trim());
193
+ const joinArrayColumn = (value, separator) => value
194
+ ?.map((x) => x.toString().trim())
195
+ .filter((x) => x)
196
+ .join(separator ?? DEFAULT_ARRAY_SEPARATOR);
191
197
  class EntitySerializer {
192
198
  constructor(services, options) {
193
199
  this.services = services;
@@ -257,13 +263,16 @@ class EntitySerializer {
257
263
  for (const validator of column.validators ?? []) {
258
264
  const result = validator.fn(entity);
259
265
  if (!result.isValid) {
260
- validationErrors.push({
261
- errorCode: validator.key,
262
- column: {
263
- name: column.name,
264
- key: column.key,
265
- },
266
- });
266
+ for (const error of result.validationErrors) {
267
+ validationErrors.push({
268
+ errorCode: error.errorCode,
269
+ column: {
270
+ name: column.name,
271
+ key: column.key,
272
+ value: error.value,
273
+ },
274
+ });
275
+ }
267
276
  }
268
277
  }
269
278
  }
@@ -40728,7 +40737,7 @@ const fieldOptionValidator = (item, selector, { availableOptions, required, }) =
40728
40737
  };
40729
40738
  };
40730
40739
  const fieldOptionsValidator = (item, selector, { availableOptions, minSelected, maxSelected, }) => {
40731
- const values = selector(item);
40740
+ const values = selector(item).filter((x) => x) ?? [];
40732
40741
  const errors = [];
40733
40742
  const invalidOptions = values.filter((x) => !availableOptions.includes(x));
40734
40743
  invalidOptions.forEach((x) => errors.push({ errorCode: "invalidOption", value: x }));