@servicelabsco/nestjs-utility-services 1.2.91 → 1.2.93

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.
Files changed (61) hide show
  1. package/dist/migrations/1710834052315-AddTrackingIdentifierSysMailLogsTable.d.ts +5 -0
  2. package/dist/migrations/1710834052315-AddTrackingIdentifierSysMailLogsTable.js +17 -0
  3. package/dist/migrations/1710834052315-AddTrackingIdentifierSysMailLogsTable.js.map +1 -0
  4. package/dist/migrations/1717761722433-AddTrackColumnsSysMailRecipientsTable.d.ts +5 -0
  5. package/dist/migrations/1717761722433-AddTrackColumnsSysMailRecipientsTable.js +17 -0
  6. package/dist/migrations/1717761722433-AddTrackColumnsSysMailRecipientsTable.js.map +1 -0
  7. package/dist/platformUtility/dtos/mail.options.dto.d.ts +2 -0
  8. package/dist/platformUtility/dtos/mail.options.dto.js +10 -0
  9. package/dist/platformUtility/dtos/mail.options.dto.js.map +1 -1
  10. package/dist/platformUtility/es6.classes.d.ts +7 -3
  11. package/dist/platformUtility/es6.classes.js +9 -1
  12. package/dist/platformUtility/es6.classes.js.map +1 -1
  13. package/dist/platformUtility/jobs/index.d.ts +2 -0
  14. package/dist/platformUtility/jobs/index.js +2 -0
  15. package/dist/platformUtility/jobs/index.js.map +1 -1
  16. package/dist/platformUtility/jobs/process.ses.delivery.webhook.job.d.ts +9 -0
  17. package/dist/platformUtility/jobs/process.ses.delivery.webhook.job.js +44 -0
  18. package/dist/platformUtility/jobs/process.ses.delivery.webhook.job.js.map +1 -0
  19. package/dist/platformUtility/jobs/process.tracking.webhook.job.d.ts +8 -0
  20. package/dist/platformUtility/jobs/process.tracking.webhook.job.js +41 -0
  21. package/dist/platformUtility/jobs/process.tracking.webhook.job.js.map +1 -0
  22. package/dist/platformUtility/libraries/index.d.ts +2 -0
  23. package/dist/platformUtility/libraries/index.js +2 -0
  24. package/dist/platformUtility/libraries/index.js.map +1 -1
  25. package/dist/platformUtility/libraries/process.common.mail.d.ts +1 -0
  26. package/dist/platformUtility/libraries/process.common.mail.js +9 -0
  27. package/dist/platformUtility/libraries/process.common.mail.js.map +1 -1
  28. package/dist/platformUtility/libraries/process.common.ses.mail.d.ts +15 -0
  29. package/dist/platformUtility/libraries/process.common.ses.mail.js +40 -0
  30. package/dist/platformUtility/libraries/process.common.ses.mail.js.map +1 -0
  31. package/dist/platformUtility/libraries/process.common.smtp.mail.d.ts +6 -3
  32. package/dist/platformUtility/libraries/process.common.smtp.mail.js +0 -38
  33. package/dist/platformUtility/libraries/process.common.smtp.mail.js.map +1 -1
  34. package/dist/platformUtility/libraries/process.ses.mail.d.ts +13 -4
  35. package/dist/platformUtility/libraries/process.ses.mail.js +79 -6
  36. package/dist/platformUtility/libraries/process.ses.mail.js.map +1 -1
  37. package/dist/platformUtility/libraries/process.ses.raw.mail.d.ts +33 -0
  38. package/dist/platformUtility/libraries/process.ses.raw.mail.js +129 -0
  39. package/dist/platformUtility/libraries/process.ses.raw.mail.js.map +1 -0
  40. package/dist/platformUtility/libraries/process.smtp.mail.d.ts +11 -1
  41. package/dist/platformUtility/libraries/process.smtp.mail.js +97 -5
  42. package/dist/platformUtility/libraries/process.smtp.mail.js.map +1 -1
  43. package/dist/platformUtility/services/es6.jobs.service.d.ts +5 -1
  44. package/dist/platformUtility/services/es6.jobs.service.js +9 -1
  45. package/dist/platformUtility/services/es6.jobs.service.js.map +1 -1
  46. package/dist/platformUtility/services/index.d.ts +1 -0
  47. package/dist/platformUtility/services/index.js +1 -0
  48. package/dist/platformUtility/services/index.js.map +1 -1
  49. package/dist/platformUtility/services/mail.service.d.ts +4 -1
  50. package/dist/platformUtility/services/mail.service.js +30 -14
  51. package/dist/platformUtility/services/mail.service.js.map +1 -1
  52. package/dist/platformUtility/services/ses.mail.notification.service.d.ts +10 -0
  53. package/dist/platformUtility/services/ses.mail.notification.service.js +53 -0
  54. package/dist/platformUtility/services/ses.mail.notification.service.js.map +1 -0
  55. package/dist/system/entities/mail.log.entity.d.ts +3 -0
  56. package/dist/system/entities/mail.log.entity.js +12 -0
  57. package/dist/system/entities/mail.log.entity.js.map +1 -1
  58. package/dist/system/entities/mail.recipient.entity.d.ts +3 -0
  59. package/dist/system/entities/mail.recipient.entity.js +12 -0
  60. package/dist/system/entities/mail.recipient.entity.js.map +1 -1
  61. package/package.json +4 -2
@@ -18,28 +18,30 @@ const mail_recipient_entity_1 = require("../../system/entities/mail.recipient.en
18
18
  const property_service_1 = require("../../system/services/property.service");
19
19
  const upload_service_1 = require("../../system/services/upload.service");
20
20
  const process_ses_mail_1 = require("../libraries/process.ses.mail");
21
+ const process_ses_raw_mail_1 = require("../libraries/process.ses.raw.mail");
21
22
  const process_smtp_mail_1 = require("../libraries/process.smtp.mail");
22
23
  const mail_log_entity_1 = require("./../../system/entities/mail.log.entity");
24
+ const aws_config_service_1 = require("./aws.config.service");
23
25
  let MailService = class MailService {
24
- constructor(propertyService, uploadService) {
26
+ constructor(propertyService, uploadService, awsConfigService) {
25
27
  this.propertyService = propertyService;
26
28
  this.uploadService = uploadService;
29
+ this.awsConfigService = awsConfigService;
27
30
  this.refreshTime = {};
28
31
  this.gateway = null;
29
32
  }
30
33
  async send(options, metadata) {
31
- const response = await this.processMail(options);
32
- global.console.log('response', response);
33
- const { identifier, attributes } = response;
34
- const gateway = this.gateway;
34
+ const { identifier, trackingId, attributes, track_pairs } = await this.processMail(options);
35
+ const gateway = options.gateway || this.gateway;
35
36
  const body = { gateway, identifier };
36
37
  const log = (0, class_transformer_1.plainToClass)(mail_log_entity_1.MailLogEntity, { ...body, ...metadata });
37
38
  log.attributes = { ...attributes, attachments: options.files || {} };
38
39
  log.processed_on = new Date();
39
40
  log.body = await this.getBody(options);
40
41
  log.subject = options.subject;
42
+ log.tracking_identifier = trackingId;
41
43
  await log.save();
42
- await this.setRecipients(log, options);
44
+ await this.setRecipients(log, options, trackingId, track_pairs);
43
45
  return log;
44
46
  }
45
47
  async getBody(options) {
@@ -47,27 +49,33 @@ let MailService = class MailService {
47
49
  const buffer = Buffer.from(str, 'utf-8');
48
50
  return this.uploadService.upload({ buffer, originalname: `mail.body.${platform_utility_1.PlatformUtility.generateRandomAlpha(16)}.html` });
49
51
  }
50
- async setRecipients(mail, options) {
52
+ async setRecipients(mail, options, trackingId, track_pairs) {
51
53
  const nodes = ['cc', 'bcc', 'to'];
52
54
  for (const node of nodes) {
53
55
  if (options[node])
54
- await this.setRecipient(mail, node, options[node]);
56
+ await this.setRecipient(mail, node, options[node], trackingId, track_pairs);
55
57
  }
56
58
  }
57
- async setRecipient(mail, type, email) {
59
+ async setRecipient(mail, type, email, trackingId, track_pairs) {
58
60
  const emails = Array.isArray(email) ? email : [email];
59
61
  for (const email of emails) {
60
62
  const r = mail_recipient_entity_1.MailRecipientEntity.create({ mail_id: mail.id, type, email });
63
+ if (!(track_pairs && track_pairs[email]))
64
+ return r.save();
65
+ r.tracking_identifier = trackingId;
66
+ r.tracking_pixel_id = track_pairs[email];
61
67
  await r.save();
62
68
  }
63
69
  }
64
70
  async processMail(options) {
65
- const gateway = await this.getDefaultGateway();
66
- global.console.log('gateway', gateway);
71
+ const gateway = options.gateway || (await this.getDefaultGateway());
72
+ this.gateway = gateway;
67
73
  if (gateway === 'smtp')
68
- return new process_smtp_mail_1.ProcessSmtpMail(this.propertyService, options).process();
74
+ return new process_smtp_mail_1.ProcessSmtpMail(this.propertyService, options, this).process();
69
75
  if (gateway === 'ses')
70
- return new process_ses_mail_1.ProcessSesMail(this.propertyService, options).process();
76
+ return new process_ses_mail_1.ProcessSesMail(this.propertyService, options, this.awsConfigService, this).process();
77
+ if (gateway === 'sesRaw')
78
+ return new process_ses_raw_mail_1.ProcessSesRawMail(this.propertyService, options, this.awsConfigService, this).process();
71
79
  global.console.log('No mail gateway defined in the system');
72
80
  }
73
81
  async getDefaultGateway() {
@@ -78,11 +86,19 @@ let MailService = class MailService {
78
86
  this.gateway = await this.propertyService.get('mail.outbound.gateway', false);
79
87
  return this.gateway;
80
88
  }
89
+ async getTrackingPixel(trackingId, trackingPixel) {
90
+ let trackBackBase = await this.propertyService.get('email.track.webhook', 'https://ddebug.finnoto.dev/email-track');
91
+ if (!trackBackBase)
92
+ return;
93
+ const trackBackUrl = `${trackBackBase}?t=${encodeURIComponent(trackingId)}&px=${trackingPixel}`;
94
+ return `<img width="0" height="0" alt="" style="display:flex" src="${trackBackUrl}">`;
95
+ }
81
96
  };
82
97
  exports.MailService = MailService;
83
98
  exports.MailService = MailService = __decorate([
84
99
  (0, common_1.Injectable)(),
85
100
  __metadata("design:paramtypes", [property_service_1.PropertyService,
86
- upload_service_1.UploadService])
101
+ upload_service_1.UploadService,
102
+ aws_config_service_1.AwsConfigService])
87
103
  ], MailService);
88
104
  //# sourceMappingURL=mail.service.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"mail.service.js","sourceRoot":"","sources":["../../../src/platformUtility/services/mail.service.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAA4C;AAC5C,yDAAiD;AACjD,uCAAsC;AACtC,8EAA0E;AAC1E,uFAAkF;AAClF,6EAAyE;AACzE,yEAAqE;AACrE,oEAA+D;AAC/D,sEAAiE;AACjE,6EAAwE;AAUjE,IAAM,WAAW,GAAjB,MAAM,WAAW;IAqBpB,YACqB,eAAgC,EAChC,aAA4B;QAD5B,oBAAe,GAAf,eAAe,CAAiB;QAChC,kBAAa,GAAb,aAAa,CAAe;QAjBzC,gBAAW,GAA2C,EAAE,CAAC;QAOzD,YAAO,GAAG,IAAI,CAAC;IAWpB,CAAC;IASJ,KAAK,CAAC,IAAI,CAAC,OAAuB,EAAE,QAAc;QAC9C,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;QACjD,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC;QAEzC,MAAM,EAAE,UAAU,EAAE,UAAU,EAAE,GAAG,QAAQ,CAAC;QAC5C,MAAM,OAAO,GAAG,IAAI,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otificationService {
3
+ constructor();
4
+ getNotificationPayload(payload: any): Promise<{
5
+ notificationPayload: any;
6
+ mailLogEntity: MailLogEntity;
7
+ }>;
8
+ processSesDeliveryData(notificationPayload: any, mailLogEntity: MailLogEntity): Promise<MailLogEntity>;
9
+ processSesBounceData(notificationPayload: any, mailLogEntity: MailLogEntity): Promise<MailLogEntity>;
10
+ }
@@ -0,0 +1,53 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.SesMailNotificationService = void 0;
13
+ const common_1 = require("@nestjs/common");
14
+ const mail_log_entity_1 = require("../../system/entities/mail.log.entity");
15
+ let SesMailNotificationService = class SesMailNotificationService {
16
+ constructor() { }
17
+ async getNotificationPayload(payload) {
18
+ if (payload.Type !== 'Notification')
19
+ return;
20
+ const notificationPayload = JSON.parse(payload.Message);
21
+ if (!notificationPayload)
22
+ return;
23
+ let identifier = notificationPayload.mail.headers.find((header) => header.name === 'References')?.value;
24
+ if (!identifier)
25
+ identifier = notificationPayload.mail.messageId;
26
+ if (!identifier)
27
+ return;
28
+ let mailLogEntity = await mail_log_entity_1.MailLogEntity.findOne({ where: { identifier: identifier } });
29
+ if (!mailLogEntity)
30
+ return;
31
+ return { notificationPayload, mailLogEntity };
32
+ }
33
+ async processSesDeliveryData(notificationPayload, mailLogEntity) {
34
+ const deliveries = mailLogEntity.tracking_attributes?.deliveries || [];
35
+ const data = { emails: notificationPayload.delivery.recipients, delivered_at: notificationPayload.delivery.timestamp };
36
+ deliveries.push(data);
37
+ mailLogEntity.tracking_attributes = { ...mailLogEntity.tracking_attributes, deliveries };
38
+ return mailLogEntity.save();
39
+ }
40
+ async processSesBounceData(notificationPayload, mailLogEntity) {
41
+ const data = { emails: notificationPayload.bounce.bouncedRecipients, bounced_at: notificationPayload.bounce.timestamp };
42
+ const bounces = mailLogEntity.tracking_attributes?.bounces || [];
43
+ bounces.push(data);
44
+ mailLogEntity.tracking_attributes = { ...mailLogEntity.tracking_attributes, bounces };
45
+ return mailLogEntity.save();
46
+ }
47
+ };
48
+ exports.SesMailNotificationService = SesMailNotificationService;
49
+ exports.SesMailNotificationService = SesMailNotificationService = __decorate([
50
+ (0, common_1.Injectable)(),
51
+ __metadata("design:paramtypes", [])
52
+ ], SesMailNotificationService);
53
+ //# sourceMappingURL=ses.mail.notification.service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ses.mail.notification.service.js","sourceRoot":"","sources":["../../../src/platformUtility/services/ses.mail.notification.service.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAAiD;AACjD,2EAAsE;AAQ/D,IAAM,0BAA0B,GAAhC,MAAM,0BAA0B;IACnC,gBAAe,CAAC;IAEhB,KAAK,CAAC,sBAAsB,CAAC,OAAY;QACrC,IAAI,OAAO,CAAC,IAAI,KAAK,cAAc;YAAE,OAAO;QAE5C,MAAM,mBAAmB,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;QAExD,IAAI,CAAC,mBAAmB;YAAE,OAAO;QAEjC,IAAI,UAAU,GAAG,mBAAmB,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,KAAK,YAAY,CAAC,EAAE,KAAK,CAAC;QAExG,I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AI,EAAE,CAAC;IAChC,CAAC;CACJ,CAAA;AA9CY,gEAA0B;qCAA1B,0BAA0B;IADtC,IAAA,mBAAU,GAAE;;GACA,0BAA0B,CA8CtC"}
@@ -4,10 +4,13 @@ export declare class MailLogEntity extends CommonEntity {
4
4
  source_id: number;
5
5
  gateway: string;
6
6
  identifier: string;
7
+ tracking_identifier: string;
7
8
  body: string;
8
9
  subject: string;
9
10
  processed_on: Date;
10
11
  delivered_on: Date;
11
12
  opened_on: Date;
13
+ last_opened_at: Date;
12
14
  attributes: any;
15
+ tracking_attributes: any;
13
16
  }
@@ -31,6 +31,10 @@ __decorate([
31
31
  (0, typeorm_1.Column)(),
32
32
  __metadata("design:type", String)
33
33
  ], MailLogEntity.prototype, "identifier", void 0);
34
+ __decorate([
35
+ (0, typeorm_1.Column)(),
36
+ __metadata("design:type", String)
37
+ ], MailLogEntity.prototype, "tracking_identifier", void 0);
34
38
  __decorate([
35
39
  (0, typeorm_1.Column)(),
36
40
  __metadata("design:type", String)
@@ -51,10 +55,18 @@ __decorate([
51
55
  (0, typeorm_1.Column)(),
52
56
  __metadata("design:type", Date)
53
57
  ], MailLogEntity.prototype, "opened_on", void 0);
58
+ __decorate([
59
+ (0, typeorm_1.Column)(),
60
+ __metadata("design:type", Date)
61
+ ], MailLogEntity.prototype, "last_opened_at", void 0);
54
62
  __decorate([
55
63
  (0, typeorm_1.Column)('json'),
56
64
  __metadata("design:type", Object)
57
65
  ], MailLogEntity.prototype, "attributes", void 0);
66
+ __decorate([
67
+ (0, typeorm_1.Column)('json'),
68
+ __metadata("design:type", Object)
69
+ ], MailLogEntity.prototype, "tracking_attributes", void 0);
58
70
  exports.MailLogEntity = MailLogEntity = __decorate([
59
71
  (0, typeorm_1.Entity)('sys_mail_logs')
60
72
  ], MailLogEntity);
@@ -1 +1 @@
1
- {"version":3,"file":"mail.log.entity.js","sourceRoot":"","sources":["../../../src/system/entities/mail.log.entity.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qCAAyC;AACzC,0EAAsE;AAS/D,IAAM,aAAa,GAAnB,MAAM,aAAc,SAAQ,4BAAY;CAgC9C,CAAA;AAhCY,sCAAa;AAEtB;IADC,IAAA,gBAAM,GAAE;;kDACW;AAGpB;IADC,IAAA,gBAAM,GAAE;;gDACS;AAGlB;IADC,IAAA,gBAAM,GAAE;;8CACO;AAGhB;IADC,IAAA,gBAAM,GAAE;;iDACU;AAGnB;IADC,IAAA,gBAAM,GAAE;;2CACI;AAGb;IADC,IAAA,gBAAM,GAAE;;8CACO;AAGhB;IADC,IAAA,gBAAM,GAAE;8BACK,IAAI;mDAAC;AAGnB;IADC,IAAA,gBAAM,GAAE;8BACK,IAAI;mDAAC;AAGnB;IADC,IAAA,gBAAM,GAAE;8BACE,IAAI;gDAAC;AAGhB;IADC,IAAA,gBAAM,EAAC,MAAM,CAAC;;iDACC;wBA7BP,aAAa;IADzB,IAAA,gBAAM,EAAC,eAAe,CAAC;GACX,aAAa,CAgCzB"}
1
+ {"version":3,"file":"mail.log.entity.js","sourceRoot":"","sources":["../../../src/system/entities/mail.log.entity.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qCAAyC;AACzC,0EAAsE;AAS/D,IAAM,aAAa,GAAnB,MAAM,aAAc,SAAQ,4BAAY;CAyC9C,CAAA;AAzCY,sCAAa;AAEtB;IADC,IAAA,gBAAM,GAAE;;kDACW;AAGpB;IADC,IAAA,gBAAM,GAAE;;gDACS;AAGlB;IADC,IAAA,gBAAM,GAAE;;8CACO;AAGhB;IADC,IAAA,gBAAM,GAAE;;iDACU;AAGnB;IADC,IAAA,gBAAM,GAAE;;0DACmB;AAG5B;IADC,IAAA,gBAAM,GAAE;;2CACI;AAGb;IADC,IAAA,gBAAM,GAAE;;8CACO;AAGhB;IADC,IAAA,gBAAM,GAAE;8BACK,IAAI;mDAAC;AAGnB;IADC,IAAA,gBAAM,GAAE;8BACK,IAAI;mDAAC;AAGnB;IADC,IAAA,gBAAM,GAAE;8BACE,IAAI;gDAAC;AAGhB;IADC,IAAA,gBAAM,GAAE;8BACO,IAAI;qDAAC;AAGrB;IADC,IAAA,gBAAM,EAAC,MAAM,CAAC;;iDACC;AAGhB;IADC,IAAA,gBAAM,EAAC,MAAM,CAAC;;0DACU;wBAtChB,aAAa;IADzB,IAAA,gBAAM,EAAC,eAAe,CAAC;GACX,aAAa,CAyCzB"}
@@ -5,6 +5,9 @@ export declare class MailRecipientEntity extends CommonEntity {
5
5
  mail_id: number;
6
6
  type: string;
7
7
  email: string;
8
+ tracking_identifier: string;
9
+ tracking_pixel_id: string;
10
+ tracking_attributes: any;
8
11
  attributes: MailRecipientAttributesDto;
9
12
  mail: MailLogEntity;
10
13
  }
@@ -29,6 +29,18 @@ __decorate([
29
29
  (0, typeorm_1.Column)(),
30
30
  __metadata("design:type", String)
31
31
  ], MailRecipientEntity.prototype, "email", void 0);
32
+ __decorate([
33
+ (0, typeorm_1.Column)(),
34
+ __metadata("design:type", String)
35
+ ], MailRecipientEntity.prototype, "tracking_identifier", void 0);
36
+ __decorate([
37
+ (0, typeorm_1.Column)(),
38
+ __metadata("design:type", String)
39
+ ], MailRecipientEntity.prototype, "tracking_pixel_id", void 0);
40
+ __decorate([
41
+ (0, typeorm_1.Column)('json'),
42
+ __metadata("design:type", Object)
43
+ ], MailRecipientEntity.prototype, "tracking_attributes", void 0);
32
44
  __decorate([
33
45
  (0, typeorm_1.Column)('json'),
34
46
  __metadata("design:type", mail_recipient_attributes_dto_1.MailRecipientAttributesDto)
@@ -1 +1 @@
1
- {"version":3,"file":"mail.recipient.entity.js","sourceRoot":"","sources":["../../../src/system/entities/mail.recipient.entity.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qCAAgE;AAChE,wEAAoE;AACpE,yFAAmF;AACnF,uDAAkD;AAS3C,IAAM,mBAAmB,GAAzB,MAAM,mBAAoB,SAAQ,4BAAY;CAepD,CAAA;AAfY,kDAAmB;AAE5B;IADC,IAAA,gBAAM,GAAE;;oDACO;AAGhB;IADC,IAAA,gBAAM,GAAE;;iDACI;AAGb;IADC,IAAA,gBAAM,GAAE;;kDACK;AAGd;IADC,IAAA,gBAAM,EAAC,MAAM,CAAC;8BACH,0DAA0B;uDAAC;AAG0B;IAAhE,IAAA,mBAAS,EAAC,GAAG,EAAE,CAAC,+BAAa,CAAC;IAAE,IAAA,oBAAU,EAAC,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC;8BAAO,+BAAa;iDAAC;8BAd5E,mBAAmB;IAD/B,IAAA,gBAAM,EAAC,qBAAqB,CAAC;GACjB,mBAAmB,CAe/B"}
1
+ {"version":3,"file":"mail.recipient.entity.js","sourceRoot":"","sources":["../../../src/system/entities/mail.recipient.entity.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qCAAgE;AAChE,wEAAoE;AACpE,yFAAmF;AACnF,uDAAkD;AAS3C,IAAM,mBAAmB,GAAzB,MAAM,mBAAoB,SAAQ,4BAAY;CAwBpD,CAAA;AAxBY,kDAAmB;AAE5B;IADC,IAAA,gBAAM,GAAE;;oDACO;AAGhB;IADC,IAAA,gBAAM,GAAE;;iDACI;AAGb;IADC,IAAA,gBAAM,GAAE;;kDACK;AAGd;IADC,IAAA,gBAAM,GAAE;;gEACmB;AAG5B;IADC,IAAA,gBAAM,GAAE;;8DACiB;AAG1B;IADC,IAAA,gBAAM,EAAC,MAAM,CAAC;;gEACU;AAGzB;IADC,IAAA,gBAAM,EAAC,MAAM,CAAC;8BACH,0DAA0B;uDAAC;AAG0B;IAAhE,IAAA,mBAAS,EAAC,GAAG,EAAE,CAAC,+BAAa,CAAC;IAAE,IAAA,oBAAU,EAAC,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC;8BAAO,+BAAa;iDAAC;8BAvB5E,mBAAmB;IAD/B,IAAA,gBAAM,EAAC,qBAAqB,CAAC;GACjB,mBAAmB,CAwB/B"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@servicelabsco/nestjs-utility-services",
3
- "version": "1.2.91",
3
+ "version": "1.2.93",
4
4
  "description": "NestJS generic packages to support development",
5
5
  "author": "Hemant Kumar Sah <hemantanshu@gmail.com>",
6
6
  "license": "MIT",
@@ -31,7 +31,8 @@
31
31
  "m:c": "./node_modules/.bin/ts-node ./node_modules/.bin/typeorm migration:create -d src/config/orm.config.ts",
32
32
  "m:rev": "./node_modules/.bin/ts-node ./node_modules/.bin/typeorm migration:revert -d src/config/orm.config.ts",
33
33
  "command": "npx nestjs-command",
34
- "console": "node dist/console.js"
34
+ "console": "node dist/console.js",
35
+ "save": "bash ./commit.sh"
35
36
  },
36
37
  "keywords": [
37
38
  "nestjs"
@@ -48,6 +49,7 @@
48
49
  "@aws-sdk/client-dynamodb": "^3.414.0",
49
50
  "@aws-sdk/client-s3": "^3.414.0",
50
51
  "@aws-sdk/client-secrets-manager": "^3.433.0",
52
+ "@aws-sdk/client-ses": "^3.556.0",
51
53
  "@aws-sdk/client-sqs": "^3.414.0",
52
54
  "@aws-sdk/lib-storage": "^3.414.0",
53
55
  "@aws-sdk/s3-request-presigner": "^3.414.0",