@comasoft/nestjs 0.1.45 → 0.1.46

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.
@@ -1 +1 @@
1
- var e=this&&this.__decorate||function(e,t,r,o){var i,n=arguments.length,s=n<3?t:null===o?o=Object.getOwnPropertyDescriptor(t,r):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,r,o);else for(var c=e.length-1;c>=0;c--)(i=e[c])&&(s=(n<3?i(s):n>3?i(t,r,s):i(t,r))||s);return n>3&&s&&Object.defineProperty(t,r,s),s};Object.defineProperty(exports,"__esModule",{value:!0}),exports.EventBusModule=void 0;const t=require("@nestjs/common"),r=require("@nestjs/event-emitter"),o=require("@nestjs/typeorm"),i=require("../database/entities"),n=require("../notifications/notification.module"),s=require("./listeners"),c=require("./services");let u=class EventBusModule{};exports.EventBusModule=u,exports.EventBusModule=u=e([(0,t.Global)(),(0,t.Module)({imports:[o.TypeOrmModule.forFeature([i.LogsAudit,i.LogsEvent]),r.EventEmitterModule.forRoot({wildcard:!0,delimiter:".",newListener:!1,removeListener:!1,maxListeners:20,verboseMemoryLeak:!1,ignoreErrors:!1}),n.NotificationModule],providers:[c.EventLoggerService,c.EventStorageService,c.EventNotificationService,s.AuditEventListener],exports:[c.EventLoggerService,c.EventStorageService,c.EventNotificationService]})],u);
1
+ var e=this&&this.__decorate||function(e,t,r,o){var i,n=arguments.length,s=n<3?t:null===o?o=Object.getOwnPropertyDescriptor(t,r):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,r,o);else for(var c=e.length-1;c>=0;c--)(i=e[c])&&(s=(n<3?i(s):n>3?i(t,r,s):i(t,r))||s);return n>3&&s&&Object.defineProperty(t,r,s),s};Object.defineProperty(exports,"__esModule",{value:!0}),exports.EventBusModule=void 0;const t=require("@nestjs/common"),r=require("@nestjs/event-emitter"),o=require("@nestjs/typeorm"),i=require("../database/entities"),n=require("../notifications/notification.module"),s=require("./listeners"),c=require("./services");let v=class EventBusModule{};exports.EventBusModule=v,exports.EventBusModule=v=e([(0,t.Global)(),(0,t.Module)({imports:[o.TypeOrmModule.forFeature([i.LogsAudit,i.LogsEvent]),r.EventEmitterModule.forRoot({wildcard:!0,delimiter:".",newListener:!1,removeListener:!1,maxListeners:20,verboseMemoryLeak:!1,ignoreErrors:!1}),n.NotificationModule],providers:[c.EventLoggerService,c.EventStorageService,c.EventNotificationService,s.AuditEventListener,s.NotificationEventListener],exports:[c.EventLoggerService,c.EventStorageService,c.EventNotificationService]})],v);
@@ -1 +1,2 @@
1
1
  export * from './audit-event.listener';
2
+ export * from './notification-event.listener';
@@ -1 +1 @@
1
- var e=this&&this.__createBinding||(Object.create?function(e,t,r,i){void 0===i&&(i=r);var n=Object.getOwnPropertyDescriptor(t,r);n&&!("get"in n?!t.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,i,n)}:function(e,t,r,i){void 0===i&&(i=r),e[i]=t[r]}),t=this&&this.__exportStar||function(t,r){for(var i in t)"default"===i||Object.prototype.hasOwnProperty.call(r,i)||e(r,t,i)};Object.defineProperty(exports,"__esModule",{value:!0}),t(require("./audit-event.listener"),exports);
1
+ var e=this&&this.__createBinding||(Object.create?function(e,t,r,i){void 0===i&&(i=r);var n=Object.getOwnPropertyDescriptor(t,r);n&&!("get"in n?!t.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,i,n)}:function(e,t,r,i){void 0===i&&(i=r),e[i]=t[r]}),t=this&&this.__exportStar||function(t,r){for(var i in t)"default"===i||Object.prototype.hasOwnProperty.call(r,i)||e(r,t,i)};Object.defineProperty(exports,"__esModule",{value:!0}),t(require("./audit-event.listener"),exports),t(require("./notification-event.listener"),exports);
@@ -0,0 +1,7 @@
1
+ import { NotificationOptions } from '../../notifications';
2
+ import { EventNotificationService } from '../services';
3
+ export declare class NotificationEventListener {
4
+ private readonly eventNotificationService;
5
+ constructor(eventNotificationService: EventNotificationService);
6
+ handleNotificationEvent(event: NotificationOptions): Promise<void>;
7
+ }
@@ -0,0 +1 @@
1
+ var e=this&&this.__decorate||function(e,t,n,i){var o,r=arguments.length,c=r<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,n):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)c=Reflect.decorate(e,t,n,i);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(c=(r<3?o(c):r>3?o(t,n,c):o(t,n))||c);return r>3&&c&&Object.defineProperty(t,n,c),c},t=this&&this.__metadata||function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},n=this&&this.__awaiter||function(e,t,n,i){return new(n||(n=Promise))(function(o,r){function fulfilled(e){try{step(i.next(e))}catch(e){r(e)}}function rejected(e){try{step(i.throw(e))}catch(e){r(e)}}function step(e){e.done?o(e.value):function adopt(e){return e instanceof n?e:new n(function(t){t(e)})}(e.value).then(fulfilled,rejected)}step((i=i.apply(e,t||[])).next())})};Object.defineProperty(exports,"__esModule",{value:!0}),exports.NotificationEventListener=void 0;const i=require("@nestjs/common"),o=require("@nestjs/event-emitter"),r=require("../services");let c=class NotificationEventListener{constructor(e){this.eventNotificationService=e}handleNotificationEvent(e){return n(this,void 0,void 0,function*(){yield this.eventNotificationService.send(e)})}};exports.NotificationEventListener=c,e([(0,o.OnEvent)("notification.**",{async:!0}),t("design:type",Function),t("design:paramtypes",[Object]),t("design:returntype",Promise)],c.prototype,"handleNotificationEvent",null),exports.NotificationEventListener=c=e([(0,i.Injectable)(),t("design:paramtypes",[r.EventNotificationService])],c);
@@ -9,12 +9,24 @@ export declare class EmailService {
9
9
  subject: string;
10
10
  text: string;
11
11
  variables?: Record<string, any>;
12
- }>): Promise<void | any[]>;
12
+ }>): Promise<{
13
+ user_id: number;
14
+ recipient: string;
15
+ success: boolean;
16
+ messageId: string;
17
+ status: string;
18
+ }[] | import("@aws-sdk/client-ses").SendEmailCommandOutput>;
13
19
  sendAws(recipients: Array<{
14
20
  recipient: string;
15
21
  user_id: number;
16
22
  subject: string;
17
23
  text: string;
18
24
  variables?: Record<string, any>;
19
- }>): Promise<void>;
25
+ }>): Promise<{
26
+ user_id: number;
27
+ recipient: string;
28
+ success: boolean;
29
+ messageId: string;
30
+ status: string;
31
+ }[] | import("@aws-sdk/client-ses").SendEmailCommandOutput>;
20
32
  }
@@ -1 +1 @@
1
- var e=this&&this.__decorate||function(e,t,i,n){var s,o=arguments.length,c=o<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,i):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)c=Reflect.decorate(e,t,i,n);else for(var r=e.length-1;r>=0;r--)(s=e[r])&&(c=(o<3?s(c):o>3?s(t,i,c):s(t,i))||c);return o>3&&c&&Object.defineProperty(t,i,c),c},t=this&&this.__metadata||function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},i=this&&this.__awaiter||function(e,t,i,n){return new(i||(i=Promise))(function(s,o){function fulfilled(e){try{step(n.next(e))}catch(e){o(e)}}function rejected(e){try{step(n.throw(e))}catch(e){o(e)}}function step(e){e.done?s(e.value):function adopt(e){return e instanceof i?e:new i(function(t){t(e)})}(e.value).then(fulfilled,rejected)}step((n=n.apply(e,t||[])).next())})};Object.defineProperty(exports,"__esModule",{value:!0}),exports.EmailService=void 0;const n=require("@aws-sdk/client-ses"),s=require("@nestjs/common"),o=require("@nestjs/config");let c=class EmailService{constructor(e){this.configService=e,"aws"===this.configService.get("EMAIL_PROVIDER")&&(this.sesClient=new n.SESClient({region:this.configService.get("AWS_REGION"),credentials:{accessKeyId:this.configService.get("AWS_ACCESS_KEY_ID"),secretAccessKey:this.configService.get("AWS_SECRET_ACCESS_KEY")}}))}send(e){return i(this,void 0,void 0,function*(){const t=this.configService.get("EMAIL_PROVIDER");if(!t||!this.configService.get("EMAIL_FROM"))throw new Error("EMAIL_PROVIDER or EMAIL_FROM is not set");return"aws"===t?this.sendAws(e):[]})}sendAws(e){return i(this,void 0,void 0,function*(){if("production"===process.env.NODE_ENV){console.log("sendAws",e);for(const t of e){const e=new n.SendEmailCommand({Source:this.configService.get("EMAIL_NOREPLY_SOURCE"),Destination:{ToAddresses:[t.recipient]},Message:{Subject:{Data:t.subject,Charset:"UTF-8"},Body:{Html:{Data:t.text,Charset:"UTF-8"}}}}),i=yield this.sesClient.send(e);console.log(i)}}else console.log("sendAws",e)})}};exports.EmailService=c,exports.EmailService=c=e([(0,s.Injectable)(),t("design:paramtypes",[o.ConfigService])],c);
1
+ var e=this&&this.__decorate||function(e,t,i,n){var s,r=arguments.length,c=r<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,i):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)c=Reflect.decorate(e,t,i,n);else for(var o=e.length-1;o>=0;o--)(s=e[o])&&(c=(r<3?s(c):r>3?s(t,i,c):s(t,i))||c);return r>3&&c&&Object.defineProperty(t,i,c),c},t=this&&this.__metadata||function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},i=this&&this.__awaiter||function(e,t,i,n){return new(i||(i=Promise))(function(s,r){function fulfilled(e){try{step(n.next(e))}catch(e){r(e)}}function rejected(e){try{step(n.throw(e))}catch(e){r(e)}}function step(e){e.done?s(e.value):function adopt(e){return e instanceof i?e:new i(function(t){t(e)})}(e.value).then(fulfilled,rejected)}step((n=n.apply(e,t||[])).next())})};Object.defineProperty(exports,"__esModule",{value:!0}),exports.EmailService=void 0;const n=require("@aws-sdk/client-ses"),s=require("@nestjs/common"),r=require("@nestjs/config");let c=class EmailService{constructor(e){this.configService=e,"aws"===this.configService.get("EMAIL_PROVIDER")&&(this.sesClient=new n.SESClient({region:this.configService.get("AWS_REGION"),credentials:{accessKeyId:this.configService.get("AWS_ACCESS_KEY_ID"),secretAccessKey:this.configService.get("AWS_SECRET_ACCESS_KEY")}}))}send(e){return i(this,void 0,void 0,function*(){const t=this.configService.get("EMAIL_PROVIDER");if(!t||!this.configService.get("EMAIL_FROM"))throw new Error("EMAIL_PROVIDER or EMAIL_FROM is not set");return"aws"===t?this.sendAws(e):[]})}sendAws(e){return i(this,void 0,void 0,function*(){if("production"!==process.env.NODE_ENV)return e.map(e=>({user_id:e.user_id,recipient:e.recipient,success:!0,messageId:`aws-${Date.now()}-${e.user_id}`,status:"sent"}));for(const t of e){const e=new n.SendEmailCommand({Source:this.configService.get("EMAIL_NOREPLY_SOURCE"),Destination:{ToAddresses:[t.recipient]},Message:{Subject:{Data:t.subject,Charset:"UTF-8"},Body:{Html:{Data:t.text,Charset:"UTF-8"}}}});return yield this.sesClient.send(e)}})}};exports.EmailService=c,exports.EmailService=c=e([(0,s.Injectable)(),t("design:paramtypes",[r.ConfigService])],c);
@@ -10,13 +10,7 @@ export declare class KakaoService {
10
10
  sender_key: string;
11
11
  template_code: string;
12
12
  message: string;
13
- }>): Promise<{
14
- user_id: number;
15
- recipient: string;
16
- success: boolean;
17
- messageId: string;
18
- status: string;
19
- }[]>;
13
+ }>): Promise<any[]>;
20
14
  sendAligo(recipients: Array<{
21
15
  recipient: string;
22
16
  user_id: number;
@@ -43,11 +37,5 @@ export declare class KakaoService {
43
37
  sender_key: string;
44
38
  template_code: string;
45
39
  message: string;
46
- }>): Promise<{
47
- user_id: number;
48
- recipient: string;
49
- success: boolean;
50
- messageId: string;
51
- status: string;
52
- }[]>;
40
+ }>): Promise<any[]>;
53
41
  }
@@ -1 +1 @@
1
- var e=this&&this.__decorate||function(e,t,i,o){var r,n=arguments.length,s=n<3?t:null===o?o=Object.getOwnPropertyDescriptor(t,i):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,i,o);else for(var c=e.length-1;c>=0;c--)(r=e[c])&&(s=(n<3?r(s):n>3?r(t,i,s):r(t,i))||s);return n>3&&s&&Object.defineProperty(t,i,s),s},t=this&&this.__metadata||function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},i=this&&this.__awaiter||function(e,t,i,o){return new(i||(i=Promise))(function(r,n){function fulfilled(e){try{step(o.next(e))}catch(e){n(e)}}function rejected(e){try{step(o.throw(e))}catch(e){n(e)}}function step(e){e.done?r(e.value):function adopt(e){return e instanceof i?e:new i(function(t){t(e)})}(e.value).then(fulfilled,rejected)}step((o=o.apply(e,t||[])).next())})};Object.defineProperty(exports,"__esModule",{value:!0}),exports.KakaoService=void 0;const o=require("@nestjs/common"),r=require("@nestjs/config"),n=require("../../redis");let s=class KakaoService{constructor(e,t){this.configService=e,this.redis=t}send(e){return i(this,void 0,void 0,function*(){const t=this.configService.get("KAKAO_PROVIDER");if(!t||!this.configService.get("KAKAO_FROM"))throw new Error("KAKAO_PROVIDER or KAKAO_FROM is not set");return"aligo"===t?this.sendAligo(e):"ppurio"===t?this.sendPpurio(e):[]})}sendAligo(e){return i(this,void 0,void 0,function*(){return console.log("📱 [KAKAO] Aligo 배열 발송:",{count:e.length,from:this.configService.get("KAKAO_FROM"),provider:"aligo",recipients:e.map(e=>({user_id:e.user_id,recipient:e.recipient,template_code:e.template_code,variables:e.variables})),timestamp:(new Date).toISOString()}),e.map(e=>({user_id:e.user_id,recipient:e.recipient,success:!0,messageId:`aligo-${Date.now()}-${e.user_id}`,status:"sent"}))})}getPpurioToken(){return i(this,void 0,void 0,function*(){if(yield this.redis.get("ppurio_token"))return yield this.redis.get("ppurio_token");const e=this.configService.get("PPURIO_ACCOUNT"),t=this.configService.get("PPURIO_PASSWORD"),i=btoa(`${e}:${t}`),o=yield fetch("https://api.bizppurio.com/v1/token",{method:"POST",headers:{"Content-Type":"application/json; charset=utf-8",Authorization:`Basic ${i}`},body:JSON.stringify({grant_type:"client_credentials"})}),r=yield o.json();if(r.accesstoken)return yield this.redis.set("ppurio_token",r.accesstoken,86e3),yield this.redis.get("ppurio_token");throw new Error(`cannot get ppurio access token: ${JSON.stringify(r)}`)})}sendPpurioMessage(e){return i(this,void 0,void 0,function*(){const t=yield this.getPpurioToken(),i=yield fetch("https://api.bizppurio.com/v3/message",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${t}`},body:JSON.stringify({account:this.configService.get("PPURIO_ACCOUNT"),refkey:this.configService.get("PPURIO_PASSWORD"),type:"at",from:this.configService.get("SMS_FROM"),to:e.recipient,content:{at:{senderkey:e.sender_key,templatecode:e.template_code,message:e.message}}})});return yield i.json()})}sendPpurio(e){return i(this,void 0,void 0,function*(){if("production"!==process.env.NODE_ENV)return void console.log("📱 [KAKAO] Ppurio 발송:",{count:e.length,from:this.configService.get("KAKAO_FROM"),provider:"ppurio",recipients:e.map(e=>({user_id:e.user_id,recipient:e.recipient,sender_key:e.sender_key,template_code:e.template_code,message:e.message})),timestamp:(new Date).toISOString()});const t=yield Promise.all(e.map(e=>this.sendPpurioMessage(e)));return console.log(t),e.map(e=>({user_id:e.user_id,recipient:e.recipient,success:!0,messageId:`ppurio-${Date.now()}-${e.user_id}`,status:"sent"}))})}};exports.KakaoService=s,exports.KakaoService=s=e([(0,o.Injectable)(),t("design:paramtypes",[r.ConfigService,n.RedisService])],s);
1
+ var e=this&&this.__decorate||function(e,t,i,r){var o,n=arguments.length,s=n<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,i):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,i,r);else for(var c=e.length-1;c>=0;c--)(o=e[c])&&(s=(n<3?o(s):n>3?o(t,i,s):o(t,i))||s);return n>3&&s&&Object.defineProperty(t,i,s),s},t=this&&this.__metadata||function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},i=this&&this.__awaiter||function(e,t,i,r){return new(i||(i=Promise))(function(o,n){function fulfilled(e){try{step(r.next(e))}catch(e){n(e)}}function rejected(e){try{step(r.throw(e))}catch(e){n(e)}}function step(e){e.done?o(e.value):function adopt(e){return e instanceof i?e:new i(function(t){t(e)})}(e.value).then(fulfilled,rejected)}step((r=r.apply(e,t||[])).next())})};Object.defineProperty(exports,"__esModule",{value:!0}),exports.KakaoService=void 0;const r=require("@nestjs/common"),o=require("@nestjs/config"),n=require("../../redis");let s=class KakaoService{constructor(e,t){this.configService=e,this.redis=t}send(e){return i(this,void 0,void 0,function*(){const t=this.configService.get("KAKAO_PROVIDER");if(!t||!this.configService.get("KAKAO_FROM"))throw new Error("KAKAO_PROVIDER or KAKAO_FROM is not set");return"aligo"===t?this.sendAligo(e):"ppurio"===t?this.sendPpurio(e):[]})}sendAligo(e){return i(this,void 0,void 0,function*(){return console.log("📱 [KAKAO] Aligo 배열 발송:",{count:e.length,from:this.configService.get("KAKAO_FROM"),provider:"aligo",recipients:e.map(e=>({user_id:e.user_id,recipient:e.recipient,template_code:e.template_code,variables:e.variables})),timestamp:(new Date).toISOString()}),e.map(e=>({user_id:e.user_id,recipient:e.recipient,success:!0,messageId:`aligo-${Date.now()}-${e.user_id}`,status:"sent"}))})}getPpurioToken(){return i(this,void 0,void 0,function*(){if(yield this.redis.get("ppurio_token"))return yield this.redis.get("ppurio_token");const e=this.configService.get("PPURIO_ACCOUNT"),t=this.configService.get("PPURIO_PASSWORD"),i=btoa(`${e}:${t}`),r=yield fetch("https://api.bizppurio.com/v1/token",{method:"POST",headers:{"Content-Type":"application/json; charset=utf-8",Authorization:`Basic ${i}`},body:JSON.stringify({grant_type:"client_credentials"})}),o=yield r.json();if(o.accesstoken)return yield this.redis.set("ppurio_token",o.accesstoken,86e3),yield this.redis.get("ppurio_token");throw new Error(`cannot get ppurio access token: ${JSON.stringify(o)}`)})}sendPpurioMessage(e){return i(this,void 0,void 0,function*(){const t=yield this.getPpurioToken(),i=yield fetch("https://api.bizppurio.com/v3/message",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${t}`},body:JSON.stringify({account:this.configService.get("PPURIO_ACCOUNT"),refkey:this.configService.get("PPURIO_PASSWORD"),type:"at",from:this.configService.get("SMS_FROM"),to:e.recipient,content:{at:{senderkey:e.sender_key,templatecode:e.template_code,message:e.message}}})});return yield i.json()})}sendPpurio(e){return i(this,void 0,void 0,function*(){if("production"!==process.env.NODE_ENV)return e.map(e=>({user_id:e.user_id,recipient:e.recipient,success:!0,messageId:`ppurio-${Date.now()}-${e.user_id}`,message:e.message,status:"sent"}));return yield Promise.all(e.map(e=>this.sendPpurioMessage(e)))})}};exports.KakaoService=s,exports.KakaoService=s=e([(0,r.Injectable)(),t("design:paramtypes",[o.ConfigService,n.RedisService])],s);
@@ -11,7 +11,7 @@ export declare class NotificationSendService {
11
11
  private readonly slackService;
12
12
  private readonly messageTemplateService;
13
13
  constructor(emailService: EmailService, smsService: SmsService, kakaoService: KakaoService, slackService: SlackService, messageTemplateService: MessageTemplateService);
14
- send(payload: NotificationPayload): Promise<void | any[]>;
14
+ send(payload: NotificationPayload): Promise<any[] | import("@aws-sdk/client-ses").SendEmailCommandOutput>;
15
15
  private sendEmail;
16
16
  private sendSms;
17
17
  private sendKakao;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@comasoft/nestjs",
3
- "version": "0.1.45",
3
+ "version": "0.1.46",
4
4
  "description": "",
5
5
  "private": false,
6
6
  "exports": {