@comasoft/nestjs 0.1.44 → 0.1.45

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 t=this&&this.__decorate||function(t,e,o,i){var n,r=arguments.length,a=r<3?e:null===i?i=Object.getOwnPropertyDescriptor(e,o):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(t,e,o,i);else for(var p=t.length-1;p>=0;p--)(n=t[p])&&(a=(r<3?n(a):r>3?n(e,o,a):n(e,o))||a);return r>3&&a&&Object.defineProperty(e,o,a),a},e=this&&this.__metadata||function(t,e){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(t,e)};Object.defineProperty(exports,"__esModule",{value:!0}),exports.Notification=void 0;const o=require("typeorm"),i=require("../../enums.common"),n=require("./notification-recipient.entity");class Relations{}t([(0,o.OneToMany)(()=>n.NotificationRecipient,t=>t.notification),e("design:type",Array)],Relations.prototype,"recipients",void 0);let r=class Notification extends Relations{};exports.Notification=r,t([(0,o.PrimaryGeneratedColumn)(),e("design:type",Number)],r.prototype,"id",void 0),t([(0,o.Column)("varchar",{length:25}),e("design:type",String)],r.prototype,"type",void 0),t([(0,o.Column)("varchar",{length:25}),e("design:type",String)],r.prototype,"template_key",void 0),t([(0,o.Column)("enum",{enum:i.NOTIFICATION_STATUS}),e("design:type",String)],r.prototype,"status",void 0),t([(0,o.Column)("varchar",{length:25,nullable:!0}),e("design:type",String)],r.prototype,"sender",void 0),t([(0,o.Column)("varchar",{length:100,nullable:!0}),e("design:type",String)],r.prototype,"title",void 0),t([(0,o.Column)("text",{nullable:!0}),e("design:type",String)],r.prototype,"content",void 0),t([(0,o.CreateDateColumn)({type:"timestamptz"}),e("design:type",Date)],r.prototype,"created_at",void 0),t([(0,o.UpdateDateColumn)({type:"timestamptz"}),e("design:type",Date)],r.prototype,"updated_at",void 0),t([(0,o.DeleteDateColumn)({type:"timestamptz"}),e("design:type",Date)],r.prototype,"deleted_at",void 0),exports.Notification=r=t([(0,o.Entity)("notifications"),(0,o.Index)(["id"],{where:"deleted_at IS NULL"}),(0,o.Index)(["status"])],r);
1
+ var t=this&&this.__decorate||function(t,e,o,i){var n,r=arguments.length,a=r<3?e:null===i?i=Object.getOwnPropertyDescriptor(e,o):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(t,e,o,i);else for(var p=t.length-1;p>=0;p--)(n=t[p])&&(a=(r<3?n(a):r>3?n(e,o,a):n(e,o))||a);return r>3&&a&&Object.defineProperty(e,o,a),a},e=this&&this.__metadata||function(t,e){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(t,e)};Object.defineProperty(exports,"__esModule",{value:!0}),exports.Notification=void 0;const o=require("typeorm"),i=require("../../enums.common"),n=require("./notification-recipient.entity");class Relations{}t([(0,o.OneToMany)(()=>n.NotificationRecipient,t=>t.notification),e("design:type",Array)],Relations.prototype,"recipients",void 0);let r=class Notification extends Relations{};exports.Notification=r,t([(0,o.PrimaryGeneratedColumn)(),e("design:type",Number)],r.prototype,"id",void 0),t([(0,o.Column)("varchar",{length:25}),e("design:type",String)],r.prototype,"type",void 0),t([(0,o.Column)("varchar",{length:50}),e("design:type",String)],r.prototype,"template_key",void 0),t([(0,o.Column)("enum",{enum:i.NOTIFICATION_STATUS}),e("design:type",String)],r.prototype,"status",void 0),t([(0,o.Column)("varchar",{length:50,nullable:!0}),e("design:type",String)],r.prototype,"sender",void 0),t([(0,o.Column)("varchar",{length:100,nullable:!0}),e("design:type",String)],r.prototype,"title",void 0),t([(0,o.Column)("text",{nullable:!0}),e("design:type",String)],r.prototype,"content",void 0),t([(0,o.CreateDateColumn)({type:"timestamptz"}),e("design:type",Date)],r.prototype,"created_at",void 0),t([(0,o.UpdateDateColumn)({type:"timestamptz"}),e("design:type",Date)],r.prototype,"updated_at",void 0),t([(0,o.DeleteDateColumn)({type:"timestamptz"}),e("design:type",Date)],r.prototype,"deleted_at",void 0),exports.Notification=r=t([(0,o.Entity)("notifications"),(0,o.Index)(["id"],{where:"deleted_at IS NULL"}),(0,o.Index)(["status"])],r);
@@ -1,12 +1,15 @@
1
1
  import { ConfigService } from '@nestjs/config';
2
+ import { RedisService } from '../../redis';
2
3
  export declare class KakaoService {
3
4
  private readonly configService;
4
- constructor(configService: ConfigService);
5
+ private readonly redis;
6
+ constructor(configService: ConfigService, redis: RedisService);
5
7
  send(recipients: Array<{
6
8
  recipient: string;
7
9
  user_id: number;
10
+ sender_key: string;
8
11
  template_code: string;
9
- variables?: Record<string, any>;
12
+ message: string;
10
13
  }>): Promise<{
11
14
  user_id: number;
12
15
  recipient: string;
@@ -26,11 +29,20 @@ export declare class KakaoService {
26
29
  messageId: string;
27
30
  status: string;
28
31
  }[]>;
32
+ private getPpurioToken;
33
+ sendPpurioMessage(recipient: {
34
+ recipient: string;
35
+ user_id: number;
36
+ sender_key: string;
37
+ template_code: string;
38
+ message: string;
39
+ }): Promise<any>;
29
40
  sendPpurio(recipients: Array<{
30
41
  recipient: string;
31
42
  user_id: number;
43
+ sender_key: string;
32
44
  template_code: string;
33
- variables?: Record<string, any>;
45
+ message: string;
34
46
  }>): Promise<{
35
47
  user_id: number;
36
48
  recipient: string;
@@ -1 +1 @@
1
- var e=this&&this.__decorate||function(e,t,i,r){var n,o=arguments.length,s=o<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--)(n=e[c])&&(s=(o<3?n(s):o>3?n(t,i,s):n(t,i))||s);return o>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(n,o){function fulfilled(e){try{step(r.next(e))}catch(e){o(e)}}function rejected(e){try{step(r.throw(e))}catch(e){o(e)}}function step(e){e.done?n(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"),n=require("@nestjs/config");let o=class KakaoService{constructor(e){this.configService=e}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"}))})}sendPpurio(e){return i(this,void 0,void 0,function*(){return 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,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:`ppurio-${Date.now()}-${e.user_id}`,status:"sent"}))})}};exports.KakaoService=o,exports.KakaoService=o=e([(0,r.Injectable)(),t("design:paramtypes",[n.ConfigService])],o);
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 +1 @@
1
- var e=this&&this.__decorate||function(e,t,i,s){var r,a=arguments.length,n=a<3?t:null===s?s=Object.getOwnPropertyDescriptor(t,i):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,i,s);else for(var c=e.length-1;c>=0;c--)(r=e[c])&&(n=(a<3?r(n):a>3?r(t,i,n):r(t,i))||n);return a>3&&n&&Object.defineProperty(t,i,n),n},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,s){return new(i||(i=Promise))(function(r,a){function fulfilled(e){try{step(s.next(e))}catch(e){a(e)}}function rejected(e){try{step(s.throw(e))}catch(e){a(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((s=s.apply(e,t||[])).next())})};Object.defineProperty(exports,"__esModule",{value:!0}),exports.NotificationSendService=void 0;const s=require("@nestjs/common"),r=require("./email.service"),a=require("./kakao.service"),n=require("./message-template.service"),c=require("./slack.service"),o=require("./sms.service");let l=class NotificationSendService{constructor(e,t,i,s,r){this.emailService=e,this.smsService=t,this.kakaoService=i,this.slackService=s,this.messageTemplateService=r}send(e){return i(this,void 0,void 0,function*(){switch(e.type){case"email":return this.sendEmail(e);case"sms":return this.sendSms(e);case"kakao":return this.sendKakao(e);case"slack":return this.sendSlack(e)}})}sendEmail(e){return i(this,void 0,void 0,function*(){const t=[];for(const i of e.recipients){let s,r;if(e.template_key){const t=yield this.messageTemplateService.getTemplate("email",e.template_key);if(!t)throw new Error("Template not found");const a=Object.assign(Object.assign({},e.variables),i.variables);s=this.messageTemplateService.renderTemplate(t,a),r=t.subject}else{if(!e.subject||!e.body)throw new Error("subject, body is required");s=e.body,r=e.subject}t.push({recipient:i.recipient,user_id:i.user_id,subject:r,text:s,variables:i.variables})}return yield this.emailService.send(t)})}sendSms(e){return i(this,void 0,void 0,function*(){const t=[];for(const i of e.recipients){let s;if(e.template_key){const t=yield this.messageTemplateService.getTemplate("sms",e.template_key);if(!t)throw new Error("Template not found");const r=Object.assign(Object.assign({},e.variables),i.variables);s=this.messageTemplateService.renderTemplate(t,r)}else{if(!e.message)throw new Error("message is required");s=e.message}t.push({recipient:i.recipient,user_id:i.user_id,message:s,variables:i.variables})}return yield this.smsService.send(t)})}sendKakao(e){return i(this,void 0,void 0,function*(){const t=e.recipients.map(t=>({recipient:t.recipient,user_id:t.user_id,template_code:e.template_key,variables:Object.assign(Object.assign({},e.variables),t.variables)}));return yield this.kakaoService.send(t)})}sendSlack(e){return i(this,void 0,void 0,function*(){let t;if(e.template_key){const i=yield this.messageTemplateService.getTemplate("slack",e.template_key);if(!i)throw new Error("Template not found");t=this.messageTemplateService.renderTemplate(i,e.variables||{})}else{if(!e.message)throw new Error("message is required");t=e.message}return[yield this.slackService.send(e.channel,t)]})}};exports.NotificationSendService=l,exports.NotificationSendService=l=e([(0,s.Injectable)(),t("design:paramtypes",[r.EmailService,o.SmsService,a.KakaoService,c.SlackService,n.MessageTemplateService])],l);
1
+ var e=this&&this.__decorate||function(e,t,i,s){var r,a=arguments.length,n=a<3?t:null===s?s=Object.getOwnPropertyDescriptor(t,i):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,i,s);else for(var c=e.length-1;c>=0;c--)(r=e[c])&&(n=(a<3?r(n):a>3?r(t,i,n):r(t,i))||n);return a>3&&n&&Object.defineProperty(t,i,n),n},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,s){return new(i||(i=Promise))(function(r,a){function fulfilled(e){try{step(s.next(e))}catch(e){a(e)}}function rejected(e){try{step(s.throw(e))}catch(e){a(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((s=s.apply(e,t||[])).next())})};Object.defineProperty(exports,"__esModule",{value:!0}),exports.NotificationSendService=void 0;const s=require("@nestjs/common"),r=require("./email.service"),a=require("./kakao.service"),n=require("./message-template.service"),c=require("./slack.service"),o=require("./sms.service");let l=class NotificationSendService{constructor(e,t,i,s,r){this.emailService=e,this.smsService=t,this.kakaoService=i,this.slackService=s,this.messageTemplateService=r}send(e){return i(this,void 0,void 0,function*(){switch(e.type){case"email":return this.sendEmail(e);case"sms":return this.sendSms(e);case"kakao":return this.sendKakao(e);case"slack":return this.sendSlack(e)}})}sendEmail(e){return i(this,void 0,void 0,function*(){const t=[];for(const i of e.recipients){let s,r;if(e.template_key){const t=yield this.messageTemplateService.getTemplate("email",e.template_key);if(!t)throw new Error("Template not found");const a=Object.assign(Object.assign({},e.variables),i.variables);s=this.messageTemplateService.renderTemplate(t,a),r=t.subject}else{if(!e.subject||!e.body)throw new Error("subject, body is required");s=e.body,r=e.subject}t.push({recipient:i.recipient,user_id:i.user_id,subject:r,text:s,variables:i.variables})}return yield this.emailService.send(t)})}sendSms(e){return i(this,void 0,void 0,function*(){const t=[];for(const i of e.recipients){let s;if(e.template_key){const t=yield this.messageTemplateService.getTemplate("sms",e.template_key);if(!t)throw new Error("Template not found");const r=Object.assign(Object.assign({},e.variables),i.variables);s=this.messageTemplateService.renderTemplate(t,r)}else{if(!e.message)throw new Error("message is required");s=e.message}t.push({recipient:i.recipient,user_id:i.user_id,message:s,variables:i.variables})}return yield this.smsService.send(t)})}sendKakao(e){return i(this,void 0,void 0,function*(){const t=[];for(const i of e.recipients){let s;if(!e.template_key)throw new Error("template_key is required");const r=yield this.messageTemplateService.getTemplate("kakao",e.template_key);if(!r)throw new Error("Template not found");const a=Object.assign(Object.assign({},e.variables),i.variables);s=this.messageTemplateService.renderTemplate(r,a),t.push({recipient:i.recipient,user_id:i.user_id,sender_key:r.sender_key,template_code:e.template_key,message:s})}return yield this.kakaoService.send(t)})}sendSlack(e){return i(this,void 0,void 0,function*(){let t;if(e.template_key){const i=yield this.messageTemplateService.getTemplate("slack",e.template_key);if(!i)throw new Error("Template not found");t=this.messageTemplateService.renderTemplate(i,e.variables||{})}else{if(!e.message)throw new Error("message is required");t=e.message}return[yield this.slackService.send(e.channel,t)]})}};exports.NotificationSendService=l,exports.NotificationSendService=l=e([(0,s.Injectable)(),t("design:paramtypes",[r.EmailService,o.SmsService,a.KakaoService,c.SlackService,n.MessageTemplateService])],l);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@comasoft/nestjs",
3
- "version": "0.1.44",
3
+ "version": "0.1.45",
4
4
  "description": "",
5
5
  "private": false,
6
6
  "exports": {