@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.
@@ -0,0 +1,2 @@
1
+ import { TemplatedEmailInput } from "../../../../abstractions";
2
+ export declare const normalizeAddresses: <TPayload>(input: TemplatedEmailInput<TPayload>) => TemplatedEmailInput<TPayload>;
package/dist/esm/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { Log, csvParse, excelParse, ExcelKeyTransform, excelBuild, csvBuild, mapAsync, isNullOrUndefined, addTime, newUuid as newUuid$1, buildObject, toDict, sleep, sort, byField, toArrayDict, toItemsDict, floorDateToSecond, ensureTailingSlash, ensureStartSlash, removeUndefinedProps } from '@punks/backend-core';
1
+ import { Log, csvParse, excelParse, ExcelKeyTransform, excelBuild, csvBuild, mapAsync, isNullOrUndefined, addTime, newUuid as newUuid$1, buildObject, toDict, sleep, distinct, sort, byField, toArrayDict, toItemsDict, floorDateToSecond, ensureTailingSlash, ensureStartSlash, removeUndefinedProps } from '@punks/backend-core';
2
2
  import { QueryCommand, ScanCommand, GetItemCommand, PutItemCommand, DeleteItemCommand, DynamoDBClient } from '@aws-sdk/client-dynamodb';
3
3
  import { unmarshall, marshall } from '@aws-sdk/util-dynamodb';
4
4
  import { Module, applyDecorators, Injectable, SetMetadata, createParamDecorator, Global, Scope, Inject, Logger, StreamableFile, HttpException, HttpStatus } from '@nestjs/common';
@@ -189,7 +189,7 @@ const DEFAULT_ARRAY_SEPARATOR = "|";
189
189
  const splitArrayColumn = (value, separator) => value
190
190
  ?.toString()
191
191
  .split(separator ?? DEFAULT_ARRAY_SEPARATOR)
192
- .filter((x) => x.trim());
192
+ .filter((x) => x.trim()) ?? [];
193
193
  const joinArrayColumn = (value, separator) => value
194
194
  ?.map((x) => x.toString().trim())
195
195
  .filter((x) => x)
@@ -22646,6 +22646,26 @@ TypeormOperationLockRepository = __decorate([
22646
22646
  __metadata("design:paramtypes", [Repository, Object])
22647
22647
  ], TypeormOperationLockRepository);
22648
22648
 
22649
+ const normalizeAddress = (value) => {
22650
+ return value?.trim() ? value?.trim() : undefined;
22651
+ };
22652
+ const normalizeAddressField = (values, invalidValues) => {
22653
+ return distinct(values
22654
+ ?.map(normalizeAddress)
22655
+ ?.filter((value) => value && !invalidValues?.map(normalizeAddress).includes(value)));
22656
+ };
22657
+ const normalizeAddresses = (input) => {
22658
+ return {
22659
+ ...input,
22660
+ to: normalizeAddressField(input.to, []),
22661
+ cc: normalizeAddressField(input.cc, [...(input.to ?? [])]),
22662
+ bcc: normalizeAddressField(input.bcc, [
22663
+ ...(input.to ?? []),
22664
+ ...(input.cc ?? []),
22665
+ ]),
22666
+ };
22667
+ };
22668
+
22649
22669
  let EmailService = class EmailService {
22650
22670
  constructor(registry) {
22651
22671
  this.registry = registry;
@@ -22656,6 +22676,7 @@ let EmailService = class EmailService {
22656
22676
  input.payload;
22657
22677
  const sendInput = {
22658
22678
  ...input,
22679
+ ...normalizeAddresses(input),
22659
22680
  payload: transformedPayload,
22660
22681
  };
22661
22682
  const transformedInput = (await this.templateMiddleware?.processInput(sendInput)) ?? sendInput;
@@ -40737,7 +40758,7 @@ const fieldOptionValidator = (item, selector, { availableOptions, required, }) =
40737
40758
  };
40738
40759
  };
40739
40760
  const fieldOptionsValidator = (item, selector, { availableOptions, minSelected, maxSelected, }) => {
40740
- const values = selector(item);
40761
+ const values = selector(item) ?? [];
40741
40762
  const errors = [];
40742
40763
  const invalidOptions = values.filter((x) => !availableOptions.includes(x));
40743
40764
  invalidOptions.forEach((x) => errors.push({ errorCode: "invalidOption", value: x }));