@punks/backend-entity-manager 0.0.383 → 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
@@ -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;