@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.
- package/dist/cjs/index.js +19 -10
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/types/abstractions/serializer.d.ts +1 -0
- package/dist/esm/index.js +19 -10
- 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/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
|
|
190
|
-
|
|
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
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
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 }));
|