@comasoft/nestjs 0.1.51 → 0.1.52

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,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);
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=e.recipient.trim().replace(/-/g,"");if(t.startsWith("0100")&&t.length<=10)return;const i=yield this.getPpurioToken(),r=yield fetch("https://api.bizppurio.com/v3/message",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${i}`},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 r.json()})}sendPpurio(e){return i(this,void 0,void 0,function*(){if("production"!==process.env.NODE_ENV)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,sender_key:e.sender_key,template_code:e.template_code,message:e.message})),timestamp:(new Date).toISOString()}),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);
@@ -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=[];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);
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:r.template_code,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.51",
3
+ "version": "0.1.52",
4
4
  "description": "",
5
5
  "private": false,
6
6
  "exports": {