Comparing version
@@ -1,2 +0,2 @@ | ||
var t,e,s=require("date-fns"),a=require("image-to-base64"),r=require("qs"),i=require("node:crypto");function n(t){return t&&t.__esModule?t.default:t}function o(t,e,s,a){Object.defineProperty(t,e,{get:s,set:a,enumerable:!0,configurable:!0})}o(module.exports,"SolapiMessageService",()=>B);class h{constructor(t){this.pfId=t.pfId,this.templateId=t.templateId,this.variables=t.variables,this.disableSms=t.disableSms,this.adFlag=t.adFlag,this.buttons=t.buttons,this.imageId=t.imageId}}class l{constructor(t){this.brandId=t.brandId,this.templateId=t.templateId,this.copyAllowed=t.copyAllowed,this.mmsType=t.mmsType,this.commercialType=t.commercialType,this.variables=t.variables,this.disableSms=t.disableSms,this.additionalBody=t.additionalBody,this.buttons=t.buttons}}class u{constructor(t){this.to=t.to,this.from=t.from,this.text=t.text,this.imageId=t.imageId,this.type=t.type,this.subject=t.subject,this.autoTypeDetect=t.autoTypeDetect,this.country=t.country,void 0!=t.kakaoOptions&&(this.kakaoOptions=new h(t.kakaoOptions)),void 0!=t.rcsOptions&&(this.rcsOptions=new l(t.rcsOptions)),this.customFields=t.customFields,this.replacements=t.replacements,this.faxOptions=t.faxOptions}}var d={};o(d,"InvalidDateError",()=>c),o(d,"ApiKeyError",()=>m),o(d,"DefaultError",()=>p),o(d,"MessageNotReceivedError",()=>y),o(d,"BadRequestError",()=>g);class c extends Error{constructor(t){super(t),this.name="InvalidDateError"}}class m extends Error{constructor(t){super(t),this.name="InvalidApiKeyError"}}class p extends Error{constructor(t,e){super(e),this.name=t}}class y extends Error{constructor(t){super(`${t.length}\u{AC1C}\u{C758} \u{BA54}\u{C2DC}\u{C9C0}\u{AC00} \u{C811}\u{C218}\u{B418}\u{C9C0} \u{BABB}\u{D588}\u{C2B5}\u{B2C8}\u{B2E4}. \u{C790}\u{C138}\u{D55C} \u{C5D0}\u{B7EC} \u{BA54}\u{C2DC}\u{C9C0}\u{B294} \u{D574}\u{B2F9} \u{C5D0}\u{B7EC} \u{B0B4} failedMessageList\u{B97C} \u{D655}\u{C778}\u{D574}\u{C8FC}\u{C138}\u{C694}.`),this.name="MessagesNotReceivedError",this.failedMessageList=t}}class g extends Error{constructor(t){super(t),this.name="BadRequestError"}}function f(t){return(0,s.formatISO)(I(t))}function I(t){if("string"==typeof t){t=(0,s.parseISO)(t);let e="Invalid Date";if(t.toString()===e)throw new c(e)}return t}const b={sdkVersion:"nodejs/5.4.0-beta.0",osPlatform:`${process.platform} | ${process.version}`};class k{constructor(){this.agent=b,this.allowDuplicates=!1}}class v extends k{constructor(t,e,s){super(),this.message=t,"boolean"==typeof e&&(this.allowDuplicates=e),s&&(this.agent.appId=s)}}class w extends k{constructor(t,e,s,a,r){super(),this.messages=t,e&&(this.allowDuplicates=e),s&&(this.agent.appId=s),a&&(this.scheduledDate=f(a)),r&&(this.showMessageList=r)}}class T{constructor(t){this.messages=t}}var C=((t=C||{})[t.API_KEY=0]="API_KEY",t);async function $(t,e,a){let r=function(t,e=0){let{apiKey:a,apiSecret:r}=t;{let t=function(t,e){let s=(0,i.randomBytes)(32),a="";for(let e=0;e<32;e++)a+=t[s[e]%t.length];return a}("1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ",32),e=(0,s.formatISO)(new Date);if(!a||!r||""===a||""===r)throw new m("Invalid API Key Error");let n=(0,i.createHmac)("sha256",r);n.update(e+t);let o=n.digest("hex");return`HMAC-SHA256 apiKey=${a}, date=${e}, salt=${t}, signature=${o}`}}(t);return await fetch(e.url,{headers:{Authorization:r,"Content-Type":"application/json"},body:JSON.stringify(a),method:e.method}).then(async t=>{if(t.status>=400&&t.status<500){let e=await t.json();throw new p(e.errorCode,e.errorMessage)}if(t.status>=500)throw new p("UnknownError",await t.text());try{return t.json()}catch(e){throw console.error(e),Error(await t.text())}})}class D{constructor(t){this.channelId=t.channelId,this.searchId=t.searchId,this.accountId=t.accountId,this.phoneNumber=t.phoneNumber,this.sharedAccountIds=t.sharedAccountIds,void 0!=t.dateCreated&&(this.dateCreated=I(t.dateCreated)),void 0!=t.dateUpdated&&(this.dateUpdated=I(t.dateUpdated))}}class E{constructor(t){this.channelId=t.channelId,this.channelGroupId=t.channelGroupId,this.name=t.name,this.content=t.content,this.ad=t.ad,this.assignType=t.assignType,this.buttons=t.buttons,this.templateId=t.templateId,this.header=t.header,this.item=t.item,this.highlight=t.highlight,this.securityFlag=t.securityFlag,this.isHidden=t.isHidden,this.messageType=t.messageType,this.emphasizeType=t.emphasizeType,this.extra=t.extra,this.emphasizeTitle=t.emphasizeTitle,this.emphasizeSubtitle=t.emphasizeSubtitle,this.imageId=t.imageId,this.quickReplies=t.quickReplies,this.comments=t.comments,this.commentable=t.commentable,this.code=t.code,this.status=t.status,"dateCreated"in t&&(this.dateCreated=I(t.dateCreated)),"dateUpdated"in t&&(this.dateUpdated=I(t.dateUpdated))}}class K{constructor(t){this.channelId=t.channelId,this.isHidden=t.isHidden,void 0!=t.name&&("string"==typeof t.name?this.name={like:t.name}:"object"==typeof t.name&&(this.name=t.name)),this.startKey=t.startKey,this.status=t.status,this.limit=t.limit,void 0!=t.startDate&&(this.dateCreated=Object.assign(this.dateCreated??{},{gte:f(t.startDate)})),void 0!=t.endDate&&(this.dateCreated=Object.assign(this.dateCreated??{},{lte:f(t.endDate)}))}}class U{constructor(t){this.channelId=t.channelId,this.searchId=t.searchId,this.phoneNumber=t.phoneNumber,this.categoryCode=t.categoryCode,this.startKey=t.startKey,this.limit=t.limit,this.isMine=t.isMine,void 0!=t.startDate&&(this.dateCreated=Object.assign(this.dateCreated??{},{gte:f(t.startDate)})),void 0!=t.endDate&&(this.dateCreated=Object.assign(this.dateCreated??{},{lte:f(t.endDate)}))}}class A{constructor(t){t.groupId&&(this.criteria="groupId",this.cond="eq",this.value=t.groupId),this.startKey=t.startKey,this.limit=t.limit,t.startDate&&(this.startDate=f(t.startDate)),t.endDate&&(this.endDate=f(t.endDate))}}class G{constructor(t){this.type="DENIAL",this.type="DENIAL",this.senderNumber=t.senderNumber,this.startKey=t.startKey,this.limit=t.limit,void 0!=t.startDate&&(this.dateCreated=Object.assign(this.dateCreated??{},{gte:f(t.startDate)})),void 0!=t.endDate&&(this.dateCreated=Object.assign(this.dateCreated??{},{lte:f(t.endDate)}))}}class O{constructor(t){this.blockGroupId=t.blockGroupId,this.useAll=t.useAll,this.senderNumber=t.senderNumber,void 0!=t.name&&("string"==typeof t.name?this.name={like:t.name}:this.name=t.name),this.status=t.status,this.startKey=t.startKey,this.limit=t.limit}}class P{constructor(t){this.blockNumberId=t.blockNumberId,this.phoneNumber=t.phoneNumber,this.blockGroupId=t.blockGroupId,void 0!=t.memo&&("string"==typeof t.memo?this.memo={like:t.memo}:this.memo=t.memo),this.startKey=t.startKey,this.limit=t.limit}}class x{constructor(t){this.dateType="CREATED",this.startKey=t.startKey,this.limit=t.limit,t.dateType&&(this.dateType=t.dateType),t.startDate&&(this.startDate=f(t.startDate)),t.endDate&&(this.endDate=f(t.endDate)),this.messageId=t.messageId,this.messageIds=t.messageIds,this.groupId=t.groupId,this.to=t.to,this.from=t.from,this.type=t.type,this.statusCode=t.statusCode}}class S{constructor(t){t.startDate&&(this.startDate=f(t.startDate)),t.endDate&&(this.endDate=f(t.endDate)),this.masterAccountId=t.masterAccountId}}class B{constructor(t,e){this.baseUrl="https://api.solapi.com",this.authInfo={apiKey:t,apiSecret:e}}async send(t,e){let s=[];if(Array.isArray(t))t.forEach(t=>{s.push(new u(t))});else if(Array.isArray(t))throw new g("잘못된 값이 입력되었습니다.");else s.push(new u(t));if(0===s.length)throw new g("데이터가 반드시 1건 이상 기입되어 있어야 합니다.");let a=new w(s,e?.allowDuplicates,e?.appId,e?.scheduledDate,e?.showMessageList),r={method:"POST",url:`${this.baseUrl}/messages/v4/send-many/detail`};return $(this.authInfo,r,a).then(t=>{let e=t.groupInfo.count;if(t.failedMessageList.length>0&&e.total===e.registeredFailed)throw new y(t.failedMessageList);return t})}async sendOne(t,e){let s=new v(t,!1,e),a={method:"POST",url:`${this.baseUrl}/messages/v4/send`};return $(this.authInfo,a,s)}async sendOneFuture(t,e){let s=await this.createGroup();return await this.addMessagesToGroup(s,[t]),e=I(e),this.reserveGroup(s,e)}async createGroup(t,e,s){t=t??!1;let{sdkVersion:a,osPlatform:r}=b,i={method:"POST",url:`${this.baseUrl}/messages/v4/groups`};return $(this.authInfo,i,{sdkVersion:a,osPlatform:r,allowDuplicates:t,appId:e,customFields:s}).then(t=>t.groupId)}async addMessagesToGroup(t,e){let s={method:"PUT",url:`${this.baseUrl}/messages/v4/groups/${t}/messages`};return $(this.authInfo,s,new T(e))}async sendGroup(t){let e={method:"POST",url:`${this.baseUrl}/messages/v4/groups/${t}/send`};return $(this.authInfo,e)}async reserveGroup(t,e){let a={method:"POST",url:`${this.baseUrl}/messages/v4/groups/${t}/schedule`},r=(0,s.formatISO)(e);return $(this.authInfo,a,{scheduledDate:r})}async getGroup(t){let e={method:"GET",url:`${this.baseUrl}/messages/v4/groups/${t}`};return $(this.authInfo,e)}async getGroups(t){let e={};t&&(e=new A(t));let s=n(r).stringify(e,{indices:!1,addQueryPrefix:!0}),a=`${this.baseUrl}/messages/v4/groups${s}`;return $(this.authInfo,{method:"GET",url:a})}async getGroupMessages(t,e){let s=n(r).stringify(e,{indices:!1,addQueryPrefix:!0}),a=`${this.baseUrl}/messages/v4/groups/${t}/messages${s}`;return $(this.authInfo,{method:"GET",url:a})}async removeGroupMessages(t,e){let s={method:"DELETE",url:`${this.baseUrl}/messages/v4/groups/${t}/messages`};return $(this.authInfo,s,{messageIds:e})}async removeReservationToGroup(t){let e={method:"DELETE",url:`${this.baseUrl}/messages/v4/groups/${t}/schedule`};return $(this.authInfo,e)}async removeGroup(t){let e={method:"DELETE",url:`${this.baseUrl}/messages/v4/groups/${t}`};return $(this.authInfo,e)}async getMessages(t){let e={};t&&(e=new x(t));let s=n(r).stringify(e,{indices:!1,addQueryPrefix:!0}),a=`${this.baseUrl}/messages/v4/list${s}`;return $(this.authInfo,{method:"GET",url:a})}async getStatistics(t){let e={};t&&(e=new S(t));let s=n(r).stringify(e,{indices:!1,addQueryPrefix:!0}),a=`${this.baseUrl}/messages/v4/statistics${s}`;return $(this.authInfo,{method:"GET",url:a})}async getBalance(){let t={method:"GET",url:`${this.baseUrl}/cash/v1/balance`},e=await $(this.authInfo,t);return{balance:e.balance,point:e.point}}async uploadFile(t,e,s,r){let i=await n(a)(t),o={method:"POST",url:`${this.baseUrl}/storage/v1/files`};return $(this.authInfo,o,{file:i,type:e,name:s,link:r})}async getKakaoChannelCategories(){let t={method:"GET",url:`${this.baseUrl}/kakao/v2/channels/categories`};return $(this.authInfo,t)}async getKakaoChannels(t){let e={};t&&(e=new U(t));let s=n(r).stringify(e,{indices:!1}),a=`${this.baseUrl}/kakao/v2/channels?${s}`,i=await $(this.authInfo,{method:"GET",url:a}),o=[];for(let t of i.channelList)o.push(new D(t));return{limit:i.limit,nextKey:i.nextKey,startKey:i.startKey,channelList:o}}async getKakaoChannel(t){let e={method:"GET",url:`${this.baseUrl}/kakao/v2/channels/${t}`};return new D(await $(this.authInfo,e))}async requestKakaoChannelToken(t){let e={method:"POST",url:`${this.baseUrl}/kakao/v2/channels/token`};return $(this.authInfo,e,t)}async createKakaoChannel(t){let e={method:"POST",url:`${this.baseUrl}/kakao/v2/channels`};return $(this.authInfo,e,t)}async removeKakaoChannel(t){let e={method:"DELETE",url:`${this.baseUrl}/kakao/v2/channels/${t}`};return $(this.authInfo,e)}async getKakaoAlimtalkTemplates(t){let e={};t&&(e=new K(t));let s=n(r).stringify(e,{indices:!1}),a=`${this.baseUrl}/kakao/v2/templates?${s}`,i=await $(this.authInfo,{method:"GET",url:a}),o=[];for(let t of i.templateList)o.push(new E(t));return{limit:i.limit,nextKey:i.nextKey,startKey:i.startKey,templateList:o}}async getKakaoAlimtalkTemplate(t){let e={method:"GET",url:`${this.baseUrl}/kakao/v2/templates/${t}`};return new E(await $(this.authInfo,e))}async getKakaoAlimtalkTemplateCategories(){let t={method:"GET",url:`${this.baseUrl}/kakao/v2/templates/categories`};return $(this.authInfo,t)}async createKakaoAlimtalkTemplate(t){let e={method:"POST",url:`${this.baseUrl}/kakao/v2/templates`};return new E(await $(this.authInfo,e,t))}async requestInspectionKakaoAlimtalkTemplate(t){let e={method:"PUT",url:`${this.baseUrl}/kakao/v2/templates/${t}/inspection`};return new E(await $(this.authInfo,e))}async cancelInspectionKakaoAlimtalkTemplate(t){let e={method:"PUT",url:`${this.baseUrl}/kakao/v2/templates/${t}/inspection/cancel`};return new E(await $(this.authInfo,e))}async updateKakaoAlimtalkTemplate(t,e){let s={method:"PUT",url:`${this.baseUrl}/kakao/v2/templates/${t}`};return new E(await $(this.authInfo,s,e))}async updateKakaoAlimtalkTemplateName(t,e){let s={method:"PUT",url:`${this.baseUrl}/kakao/v2/templates/${t}/name`};return new E(await $(this.authInfo,s,{name:e}))}async deleteKakaoAlimtalkTemplate(t){return this.removeKakaoAlimtalkTemplate(t)}async removeKakaoAlimtalkTemplate(t){let e={method:"DELETE",url:`${this.baseUrl}/kakao/v2/templates/${t}`};return new E(await $(this.authInfo,e))}async getBlacks(t){let e={type:"DENIAL"};t&&(e=new G(t));let s=n(r).stringify(e,{indices:!1,addQueryPrefix:!0}),a=`${this.baseUrl}/iam/v1/black${s}`;return $(this.authInfo,{method:"GET",url:a})}async getBlockGroups(t){let e={};t&&(e=new O(t));let s=n(r).stringify(e,{indices:!1,addQueryPrefix:!0}),a=`${this.baseUrl}/iam/v1/block/groups${s}`;return $(this.authInfo,{method:"GET",url:a})}async getBlockNumbers(t){let e={};t&&(e=new P(t));let s=n(r).stringify(e,{indices:!1,addQueryPrefix:!0}),a=`${this.baseUrl}/iam/v1/block/numbers${s}`;return $(this.authInfo,{method:"GET",url:a})}}e=module.exports,Object.keys(d).forEach(function(t){!("default"===t||"__esModule"===t||Object.prototype.hasOwnProperty.call(e,t))&&Object.defineProperty(e,t,{enumerable:!0,get:function(){return d[t]}})}); | ||
var t,e,s=require("date-fns"),a=require("image-to-base64"),r=require("qs"),i=require("node:crypto");function n(t){return t&&t.__esModule?t.default:t}function o(t,e,s,a){Object.defineProperty(t,e,{get:s,set:a,enumerable:!0,configurable:!0})}o(module.exports,"SolapiMessageService",()=>B);class h{constructor(t){this.pfId=t.pfId,this.templateId=t.templateId,this.variables=t.variables,this.disableSms=t.disableSms,this.adFlag=t.adFlag,this.buttons=t.buttons,this.imageId=t.imageId}}class l{constructor(t){this.brandId=t.brandId,this.templateId=t.templateId,this.copyAllowed=t.copyAllowed,this.mmsType=t.mmsType,this.commercialType=t.commercialType,this.variables=t.variables,this.disableSms=t.disableSms,this.additionalBody=t.additionalBody,this.buttons=t.buttons}}class u{constructor(t){this.to=t.to,this.from=t.from,this.text=t.text,this.imageId=t.imageId,this.type=t.type,this.subject=t.subject,this.autoTypeDetect=t.autoTypeDetect,this.country=t.country,void 0!=t.kakaoOptions&&(this.kakaoOptions=new h(t.kakaoOptions)),void 0!=t.rcsOptions&&(this.rcsOptions=new l(t.rcsOptions)),this.customFields=t.customFields,this.replacements=t.replacements,this.faxOptions=t.faxOptions}}var d={};o(d,"InvalidDateError",()=>c),o(d,"ApiKeyError",()=>m),o(d,"DefaultError",()=>p),o(d,"MessageNotReceivedError",()=>y),o(d,"BadRequestError",()=>g);class c extends Error{constructor(t){super(t),this.name="InvalidDateError"}}class m extends Error{constructor(t){super(t),this.name="InvalidApiKeyError"}}class p extends Error{constructor(t,e){super(e),this.name=t}}class y extends Error{constructor(t){super(`${t.length}\u{AC1C}\u{C758} \u{BA54}\u{C2DC}\u{C9C0}\u{AC00} \u{C811}\u{C218}\u{B418}\u{C9C0} \u{BABB}\u{D588}\u{C2B5}\u{B2C8}\u{B2E4}. \u{C790}\u{C138}\u{D55C} \u{C5D0}\u{B7EC} \u{BA54}\u{C2DC}\u{C9C0}\u{B294} \u{D574}\u{B2F9} \u{C5D0}\u{B7EC} \u{B0B4} failedMessageList\u{B97C} \u{D655}\u{C778}\u{D574}\u{C8FC}\u{C138}\u{C694}.`),this.name="MessagesNotReceivedError",this.failedMessageList=t}}class g extends Error{constructor(t){super(t),this.name="BadRequestError"}}function f(t){return(0,s.formatISO)(I(t))}function I(t){if("string"==typeof t){t=(0,s.parseISO)(t);let e="Invalid Date";if(t.toString()===e)throw new c(e)}return t}const b={sdkVersion:"nodejs/5.4.0",osPlatform:`${process.platform} | ${process.version}`};class k{constructor(){this.agent=b,this.allowDuplicates=!1}}class v extends k{constructor(t,e,s){super(),this.message=t,"boolean"==typeof e&&(this.allowDuplicates=e),s&&(this.agent.appId=s)}}class w extends k{constructor(t,e,s,a,r){super(),this.messages=t,e&&(this.allowDuplicates=e),s&&(this.agent.appId=s),a&&(this.scheduledDate=f(a)),r&&(this.showMessageList=r)}}class T{constructor(t){this.messages=t}}var C=((t=C||{})[t.API_KEY=0]="API_KEY",t);async function $(t,e,a){let r=function(t,e=0){let{apiKey:a,apiSecret:r}=t;{let t=function(t,e){let s=(0,i.randomBytes)(32),a="";for(let e=0;e<32;e++)a+=t[s[e]%t.length];return a}("1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ",32),e=(0,s.formatISO)(new Date);if(!a||!r||""===a||""===r)throw new m("Invalid API Key Error");let n=(0,i.createHmac)("sha256",r);n.update(e+t);let o=n.digest("hex");return`HMAC-SHA256 apiKey=${a}, date=${e}, salt=${t}, signature=${o}`}}(t);return await fetch(e.url,{headers:{Authorization:r,"Content-Type":"application/json"},body:JSON.stringify(a),method:e.method}).then(async t=>{if(t.status>=400&&t.status<500){let e=await t.json();throw new p(e.errorCode,e.errorMessage)}if(t.status>=500)throw new p("UnknownError",await t.text());try{return t.json()}catch(e){throw console.error(e),Error(await t.text())}})}class D{constructor(t){this.channelId=t.channelId,this.searchId=t.searchId,this.accountId=t.accountId,this.phoneNumber=t.phoneNumber,this.sharedAccountIds=t.sharedAccountIds,void 0!=t.dateCreated&&(this.dateCreated=I(t.dateCreated)),void 0!=t.dateUpdated&&(this.dateUpdated=I(t.dateUpdated))}}class E{constructor(t){this.channelId=t.channelId,this.channelGroupId=t.channelGroupId,this.name=t.name,this.content=t.content,this.ad=t.ad,this.assignType=t.assignType,this.buttons=t.buttons,this.templateId=t.templateId,this.header=t.header,this.item=t.item,this.highlight=t.highlight,this.securityFlag=t.securityFlag,this.isHidden=t.isHidden,this.messageType=t.messageType,this.emphasizeType=t.emphasizeType,this.extra=t.extra,this.emphasizeTitle=t.emphasizeTitle,this.emphasizeSubtitle=t.emphasizeSubtitle,this.imageId=t.imageId,this.quickReplies=t.quickReplies,this.comments=t.comments,this.commentable=t.commentable,this.code=t.code,this.status=t.status,"dateCreated"in t&&(this.dateCreated=I(t.dateCreated)),"dateUpdated"in t&&(this.dateUpdated=I(t.dateUpdated))}}class K{constructor(t){this.channelId=t.channelId,this.isHidden=t.isHidden,void 0!=t.name&&("string"==typeof t.name?this.name={like:t.name}:"object"==typeof t.name&&(this.name=t.name)),this.startKey=t.startKey,this.status=t.status,this.limit=t.limit,void 0!=t.startDate&&(this.dateCreated=Object.assign(this.dateCreated??{},{gte:f(t.startDate)})),void 0!=t.endDate&&(this.dateCreated=Object.assign(this.dateCreated??{},{lte:f(t.endDate)}))}}class U{constructor(t){this.channelId=t.channelId,this.searchId=t.searchId,this.phoneNumber=t.phoneNumber,this.categoryCode=t.categoryCode,this.startKey=t.startKey,this.limit=t.limit,this.isMine=t.isMine,void 0!=t.startDate&&(this.dateCreated=Object.assign(this.dateCreated??{},{gte:f(t.startDate)})),void 0!=t.endDate&&(this.dateCreated=Object.assign(this.dateCreated??{},{lte:f(t.endDate)}))}}class A{constructor(t){t.groupId&&(this.criteria="groupId",this.cond="eq",this.value=t.groupId),this.startKey=t.startKey,this.limit=t.limit,t.startDate&&(this.startDate=f(t.startDate)),t.endDate&&(this.endDate=f(t.endDate))}}class G{constructor(t){this.type="DENIAL",this.type="DENIAL",this.senderNumber=t.senderNumber,this.startKey=t.startKey,this.limit=t.limit,void 0!=t.startDate&&(this.dateCreated=Object.assign(this.dateCreated??{},{gte:f(t.startDate)})),void 0!=t.endDate&&(this.dateCreated=Object.assign(this.dateCreated??{},{lte:f(t.endDate)}))}}class O{constructor(t){this.blockGroupId=t.blockGroupId,this.useAll=t.useAll,this.senderNumber=t.senderNumber,void 0!=t.name&&("string"==typeof t.name?this.name={like:t.name}:this.name=t.name),this.status=t.status,this.startKey=t.startKey,this.limit=t.limit}}class P{constructor(t){this.blockNumberId=t.blockNumberId,this.phoneNumber=t.phoneNumber,this.blockGroupId=t.blockGroupId,void 0!=t.memo&&("string"==typeof t.memo?this.memo={like:t.memo}:this.memo=t.memo),this.startKey=t.startKey,this.limit=t.limit}}class x{constructor(t){this.dateType="CREATED",this.startKey=t.startKey,this.limit=t.limit,t.dateType&&(this.dateType=t.dateType),t.startDate&&(this.startDate=f(t.startDate)),t.endDate&&(this.endDate=f(t.endDate)),this.messageId=t.messageId,this.messageIds=t.messageIds,this.groupId=t.groupId,this.to=t.to,this.from=t.from,this.type=t.type,this.statusCode=t.statusCode}}class S{constructor(t){t.startDate&&(this.startDate=f(t.startDate)),t.endDate&&(this.endDate=f(t.endDate)),this.masterAccountId=t.masterAccountId}}class B{constructor(t,e){this.baseUrl="https://api.solapi.com",this.authInfo={apiKey:t,apiSecret:e}}async send(t,e){let s=[];if(Array.isArray(t))t.forEach(t=>{s.push(new u(t))});else if(Array.isArray(t))throw new g("잘못된 값이 입력되었습니다.");else s.push(new u(t));if(0===s.length)throw new g("데이터가 반드시 1건 이상 기입되어 있어야 합니다.");let a=new w(s,e?.allowDuplicates,e?.appId,e?.scheduledDate,e?.showMessageList),r={method:"POST",url:`${this.baseUrl}/messages/v4/send-many/detail`};return $(this.authInfo,r,a).then(t=>{let e=t.groupInfo.count;if(t.failedMessageList.length>0&&e.total===e.registeredFailed)throw new y(t.failedMessageList);return t})}async sendOne(t,e){let s=new v(t,!1,e),a={method:"POST",url:`${this.baseUrl}/messages/v4/send`};return $(this.authInfo,a,s)}async sendOneFuture(t,e){let s=await this.createGroup();return await this.addMessagesToGroup(s,[t]),e=I(e),this.reserveGroup(s,e)}async createGroup(t,e,s){t=t??!1;let{sdkVersion:a,osPlatform:r}=b,i={method:"POST",url:`${this.baseUrl}/messages/v4/groups`};return $(this.authInfo,i,{sdkVersion:a,osPlatform:r,allowDuplicates:t,appId:e,customFields:s}).then(t=>t.groupId)}async addMessagesToGroup(t,e){let s={method:"PUT",url:`${this.baseUrl}/messages/v4/groups/${t}/messages`};return $(this.authInfo,s,new T(e))}async sendGroup(t){let e={method:"POST",url:`${this.baseUrl}/messages/v4/groups/${t}/send`};return $(this.authInfo,e)}async reserveGroup(t,e){let a={method:"POST",url:`${this.baseUrl}/messages/v4/groups/${t}/schedule`},r=(0,s.formatISO)(e);return $(this.authInfo,a,{scheduledDate:r})}async getGroup(t){let e={method:"GET",url:`${this.baseUrl}/messages/v4/groups/${t}`};return $(this.authInfo,e)}async getGroups(t){let e={};t&&(e=new A(t));let s=n(r).stringify(e,{indices:!1,addQueryPrefix:!0}),a=`${this.baseUrl}/messages/v4/groups${s}`;return $(this.authInfo,{method:"GET",url:a})}async getGroupMessages(t,e){let s=n(r).stringify(e,{indices:!1,addQueryPrefix:!0}),a=`${this.baseUrl}/messages/v4/groups/${t}/messages${s}`;return $(this.authInfo,{method:"GET",url:a})}async removeGroupMessages(t,e){let s={method:"DELETE",url:`${this.baseUrl}/messages/v4/groups/${t}/messages`};return $(this.authInfo,s,{messageIds:e})}async removeReservationToGroup(t){let e={method:"DELETE",url:`${this.baseUrl}/messages/v4/groups/${t}/schedule`};return $(this.authInfo,e)}async removeGroup(t){let e={method:"DELETE",url:`${this.baseUrl}/messages/v4/groups/${t}`};return $(this.authInfo,e)}async getMessages(t){let e={};t&&(e=new x(t));let s=n(r).stringify(e,{indices:!1,addQueryPrefix:!0}),a=`${this.baseUrl}/messages/v4/list${s}`;return $(this.authInfo,{method:"GET",url:a})}async getStatistics(t){let e={};t&&(e=new S(t));let s=n(r).stringify(e,{indices:!1,addQueryPrefix:!0}),a=`${this.baseUrl}/messages/v4/statistics${s}`;return $(this.authInfo,{method:"GET",url:a})}async getBalance(){let t={method:"GET",url:`${this.baseUrl}/cash/v1/balance`},e=await $(this.authInfo,t);return{balance:e.balance,point:e.point}}async uploadFile(t,e,s,r){let i=await n(a)(t),o={method:"POST",url:`${this.baseUrl}/storage/v1/files`};return $(this.authInfo,o,{file:i,type:e,name:s,link:r})}async getKakaoChannelCategories(){let t={method:"GET",url:`${this.baseUrl}/kakao/v2/channels/categories`};return $(this.authInfo,t)}async getKakaoChannels(t){let e={};t&&(e=new U(t));let s=n(r).stringify(e,{indices:!1}),a=`${this.baseUrl}/kakao/v2/channels?${s}`,i=await $(this.authInfo,{method:"GET",url:a}),o=[];for(let t of i.channelList)o.push(new D(t));return{limit:i.limit,nextKey:i.nextKey,startKey:i.startKey,channelList:o}}async getKakaoChannel(t){let e={method:"GET",url:`${this.baseUrl}/kakao/v2/channels/${t}`};return new D(await $(this.authInfo,e))}async requestKakaoChannelToken(t){let e={method:"POST",url:`${this.baseUrl}/kakao/v2/channels/token`};return $(this.authInfo,e,t)}async createKakaoChannel(t){let e={method:"POST",url:`${this.baseUrl}/kakao/v2/channels`};return $(this.authInfo,e,t)}async removeKakaoChannel(t){let e={method:"DELETE",url:`${this.baseUrl}/kakao/v2/channels/${t}`};return $(this.authInfo,e)}async getKakaoAlimtalkTemplates(t){let e={};t&&(e=new K(t));let s=n(r).stringify(e,{indices:!1}),a=`${this.baseUrl}/kakao/v2/templates?${s}`,i=await $(this.authInfo,{method:"GET",url:a}),o=[];for(let t of i.templateList)o.push(new E(t));return{limit:i.limit,nextKey:i.nextKey,startKey:i.startKey,templateList:o}}async getKakaoAlimtalkTemplate(t){let e={method:"GET",url:`${this.baseUrl}/kakao/v2/templates/${t}`};return new E(await $(this.authInfo,e))}async getKakaoAlimtalkTemplateCategories(){let t={method:"GET",url:`${this.baseUrl}/kakao/v2/templates/categories`};return $(this.authInfo,t)}async createKakaoAlimtalkTemplate(t){let e={method:"POST",url:`${this.baseUrl}/kakao/v2/templates`};return new E(await $(this.authInfo,e,t))}async requestInspectionKakaoAlimtalkTemplate(t){let e={method:"PUT",url:`${this.baseUrl}/kakao/v2/templates/${t}/inspection`};return new E(await $(this.authInfo,e))}async cancelInspectionKakaoAlimtalkTemplate(t){let e={method:"PUT",url:`${this.baseUrl}/kakao/v2/templates/${t}/inspection/cancel`};return new E(await $(this.authInfo,e))}async updateKakaoAlimtalkTemplate(t,e){let s={method:"PUT",url:`${this.baseUrl}/kakao/v2/templates/${t}`};return new E(await $(this.authInfo,s,e))}async updateKakaoAlimtalkTemplateName(t,e){let s={method:"PUT",url:`${this.baseUrl}/kakao/v2/templates/${t}/name`};return new E(await $(this.authInfo,s,{name:e}))}async deleteKakaoAlimtalkTemplate(t){return this.removeKakaoAlimtalkTemplate(t)}async removeKakaoAlimtalkTemplate(t){let e={method:"DELETE",url:`${this.baseUrl}/kakao/v2/templates/${t}`};return new E(await $(this.authInfo,e))}async getBlacks(t){let e={type:"DENIAL"};t&&(e=new G(t));let s=n(r).stringify(e,{indices:!1,addQueryPrefix:!0}),a=`${this.baseUrl}/iam/v1/black${s}`;return $(this.authInfo,{method:"GET",url:a})}async getBlockGroups(t){let e={};t&&(e=new O(t));let s=n(r).stringify(e,{indices:!1,addQueryPrefix:!0}),a=`${this.baseUrl}/iam/v1/block/groups${s}`;return $(this.authInfo,{method:"GET",url:a})}async getBlockNumbers(t){let e={};t&&(e=new P(t));let s=n(r).stringify(e,{indices:!1,addQueryPrefix:!0}),a=`${this.baseUrl}/iam/v1/block/numbers${s}`;return $(this.authInfo,{method:"GET",url:a})}}e=module.exports,Object.keys(d).forEach(function(t){!("default"===t||"__esModule"===t||Object.prototype.hasOwnProperty.call(e,t))&&Object.defineProperty(e,t,{enumerable:!0,get:function(){return d[t]}})}); | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "solapi", | ||
"version": "5.4.0-beta.0", | ||
"version": "5.4.0", | ||
"description": "SOLAPI SDK for Node.js(Server Side Only)", | ||
@@ -31,3 +31,3 @@ "keywords": [ | ||
"types": "dist/index.d.ts", | ||
"module": "dist/index.module.js", | ||
"module": "dist/index.mjs", | ||
"files": [ | ||
@@ -50,4 +50,4 @@ "/dist" | ||
"devDependencies": { | ||
"@eslint/eslintrc": "^3.3.0", | ||
"@eslint/js": "^9.21.0", | ||
"@eslint/eslintrc": "^3", | ||
"@eslint/js": "^9", | ||
"@parcel/packager-ts": "^2.13.3", | ||
@@ -59,7 +59,7 @@ "@parcel/transformer-typescript-tsc": "^2.13.3", | ||
"@types/image-to-base64": "^2.1.2", | ||
"@types/node": "^22.13.5", | ||
"@types/node": "^18", | ||
"@types/qs": "^6.9.18", | ||
"@typescript-eslint/eslint-plugin": "^8.25.0", | ||
"@typescript-eslint/parser": "^8.25.0", | ||
"eslint": "^9.21.0", | ||
"@typescript-eslint/eslint-plugin": "^8.26.0", | ||
"@typescript-eslint/parser": "^8.26.0", | ||
"eslint": "^9", | ||
"eslint-plugin-tsdoc": "^0.4.0", | ||
@@ -69,6 +69,6 @@ "eslint-plugin-unused-imports": "^4.1.4", | ||
"parcel": "^2.13.3", | ||
"prettier": "^3.5.2", | ||
"prettier": "^3.5.3", | ||
"rimraf": "^6.0.1", | ||
"typedoc": "^0.27.9", | ||
"typescript": "^5.7.3" | ||
"typescript": "^5.8.2" | ||
}, | ||
@@ -75,0 +75,0 @@ "packageManager": "yarn@4.6.0", |
# SOLAPI SDK for Node.js(Server Side Only) | ||
[](https://app.fossa.com/projects/git%2Bgithub.com%2Fsolapi%2Fsolapi-nodejs?ref=badge_shield) | ||
You can send text messages(SMS, LMS, MMS), Kakao friendtalk(include notification friendtalk) in Korea using this | ||
@@ -41,4 +39,1 @@ package. | ||
Licensed under the MIT License. | ||
[](https://app.fossa.com/projects/git%2Bgithub.com%2Fsolapi%2Fsolapi-nodejs?ref=badge_large) |
Sorry, the diff of this file is not supported yet
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
2
-33.33%398246
-0.13%39
-11.36%