@punks/backend-entity-manager 0.0.382 → 0.0.384

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
@@ -204,7 +204,7 @@ const DEFAULT_ARRAY_SEPARATOR = "|";
204
204
  const splitArrayColumn = (value, separator) => value
205
205
  ?.toString()
206
206
  .split(separator ?? DEFAULT_ARRAY_SEPARATOR)
207
- .filter((x) => x.trim());
207
+ .filter((x) => x.trim()) ?? [];
208
208
  const joinArrayColumn = (value, separator) => value
209
209
  ?.map((x) => x.toString().trim())
210
210
  .filter((x) => x)
@@ -22661,6 +22661,26 @@ exports.TypeormOperationLockRepository = __decorate([
22661
22661
  __metadata("design:paramtypes", [typeorm.Repository, Object])
22662
22662
  ], exports.TypeormOperationLockRepository);
22663
22663
 
22664
+ const normalizeAddress = (value) => {
22665
+ return value?.trim() ? value?.trim() : undefined;
22666
+ };
22667
+ const normalizeAddressField = (values, invalidValues) => {
22668
+ return backendCore.distinct(values
22669
+ ?.map(normalizeAddress)
22670
+ ?.filter((value) => value && !invalidValues?.map(normalizeAddress).includes(value)));
22671
+ };
22672
+ const normalizeAddresses = (input) => {
22673
+ return {
22674
+ ...input,
22675
+ to: normalizeAddressField(input.to, []),
22676
+ cc: normalizeAddressField(input.cc, [...(input.to ?? [])]),
22677
+ bcc: normalizeAddressField(input.bcc, [
22678
+ ...(input.to ?? []),
22679
+ ...(input.cc ?? []),
22680
+ ]),
22681
+ };
22682
+ };
22683
+
22664
22684
  exports.EmailService = class EmailService {
22665
22685
  constructor(registry) {
22666
22686
  this.registry = registry;
@@ -22671,6 +22691,7 @@ exports.EmailService = class EmailService {
22671
22691
  input.payload;
22672
22692
  const sendInput = {
22673
22693
  ...input,
22694
+ ...normalizeAddresses(input),
22674
22695
  payload: transformedPayload,
22675
22696
  };
22676
22697
  const transformedInput = (await this.templateMiddleware?.processInput(sendInput)) ?? sendInput;
@@ -40752,7 +40773,7 @@ const fieldOptionValidator = (item, selector, { availableOptions, required, }) =
40752
40773
  };
40753
40774
  };
40754
40775
  const fieldOptionsValidator = (item, selector, { availableOptions, minSelected, maxSelected, }) => {
40755
- const values = selector(item);
40776
+ const values = selector(item) ?? [];
40756
40777
  const errors = [];
40757
40778
  const invalidOptions = values.filter((x) => !availableOptions.includes(x));
40758
40779
  invalidOptions.forEach((x) => errors.push({ errorCode: "invalidOption", value: x }));