+Object.defineProperty(exports,"__esModule",{value:!0});var e=require("./lib/__bundle-a6c826ee.cjs"),t=require("./lib/__bundle-a7cea5ad.cjs");class s extends e.APIRequestCommand{constructor({aiAgentId:t,userId:s,language:n,country:r,context:i,forceCreateChannel:o}){super(),this.method=e.APIRequestMethod.POST,this.path=`${e.API_PATH_AI_AGENT}/ai_agents/${encodeURIComponent(t)}/messenger_settings`,this.requireAuth=!1,this.params=e.deundefined({user_id:s,country:r,language:n,context:i,force_create:o})}}class n extends e.APIResponseCommand{constructor(e,t){super(e,t),this.settings=t}}class r extends e.APIRequestCommand{constructor(t){const{token:s,limit:n,aiAgentId:r,status:i,reverse:o,order:a}=t;super(),this.method=e.APIRequestMethod.GET,this.path=`${e.API_PATH_AI_AGENT}/my_conversations`,this.params=e.deundefined({token:s,limit:n,reverse:o,order:a,status:i,bot_userid:r})}}class i extends e.APIResponseCommand{constructor(e,s){super(e,s),this.conversations=[];const{next_token:n,conversations:r}=s;this.token=n,r&&r.length>0&&(this.conversations=r.map((e=>new t.Conversation(e))))}}const o={limit:10};class a extends e.APIRequestCommand{constructor(t){const{limit:s=o.limit,keys:n,token:r}=t;super(),this.method=e.APIRequestMethod.GET,this.path=`${e.API_PATH_AI_AGENT}/sdk_message_templates`,this.params=e.deundefined({limit:s,keys:n,token:r})}}class u extends e.APIResponseCommand{constructor(e,t){super(e,t);const{templates:s,template_list_token:n}=t;this.token=n,this.templates=s.map((e=>({template:JSON.stringify(e)})))}}class d extends e.APIRequestCommand{constructor(t){const{key:s}=t;super(),this.method=e.APIRequestMethod.GET,this.path=`${e.API_PATH_AI_AGENT}/sdk_message_templates/${s}`}}class c extends e.APIResponseCommand{constructor(e,t){super(e,t),this.template=JSON.stringify(t)}}const l={};class h{constructor(e,{sdkState:t,requestQueue:s,logger:n}){this._iid=e,this._sdkState=t,this._requestQueue=s,this._logger=n,l[e]=this}static of(e){return l[e]}requestMessengerSettings(t){return e.__awaiter(this,void 0,void 0,(function*(){const{requestQueue:r}=e.Vault.of(this._iid),i=new s(t),o=yield r.commandRouter.send(i),{settings:a}=o.as(n);return a}))}getConversations(t,s,n){return e.__awaiter(this,void 0,void 0,(function*(){const{requestQueue:o}=e.Vault.of(this._iid),a=new r(Object.assign(Object.assign({},s),{token:t,limit:n})),u=yield o.send(a),{conversations:d,token:c}=u.as(i);return{conversations:d,token:c}}))}getMessageTemplates(t={}){return e.__awaiter(this,void 0,void 0,(function*(){const{keys:e,limit:s}=t,n=new a({keys:e,limit:s}),r=yield this._requestQueue.send(n),{templates:i,token:o}=r.as(u);return{templates:i,token:o}}))}getMessageTemplate(t){return e.__awaiter(this,void 0,void 0,(function*(){const e=new d({key:t}),s=yield this._requestQueue.send(e),{template:n}=s.as(c);return{template:n}}))}}var g;exports.ConversationListOrder=void 0,(g=exports.ConversationListOrder||(exports.ConversationListOrder={})).CREATED_AT="created_at",g.UPDATED_AT="updated_at";const p={status:void 0,aiAgentId:void 0,reverse:!1,order:exports.ConversationListOrder.UPDATED_AT};class _ extends e.BaseListQuery{constructor(e,t){var s,n,r,i;super(e,t),this.status=null!==(s=t.status)&&void 0!==s?s:void 0,this.aiAgentId=null!==(n=t.aiAgentId)&&void 0!==n?n:void 0,this.reverse=null!==(r=t.reverse)&&void 0!==r?r:p.reverse,this.order=null!==(i=t.order)&&void 0!==i?i:p.order}_validate(){return super._validate()&&e.isEnumOf(t.ConversationStatus,this.status,!0)&&e.isTypeOf("string",this.aiAgentId,!0)&&e.isTypeOf("boolean",this.reverse)&&e.isEnumOf(exports.ConversationListOrder,this.order)}serialize(){return e.serialize(this)}next(){return e.__awaiter(this,void 0,void 0,(function*(){const t=h.of(this._iid);if(this._validate()){if(this._isLoading)throw e.SendbirdError.queryInProgress;if(this._hasNext){this._isLoading=!0;const{conversations:s,token:n}=yield t.getConversations(this._token,e.undefineNullProps(Object.assign({},this)),this.limit);return this._token=n,this._hasNext=!!n,this._isLoading=!1,s}return[]}throw e.SendbirdError.invalidParameters}))}}class m extends e.Module{constructor(){super(...arguments),this.name="aiAgent"}init(e,{sdkState:t,dispatcher:s,sessionManager:n,requestQueue:r,logger:i,onlineDetector:o,cacheContext:a}){super.init(e,{sdkState:t,dispatcher:s,sessionManager:n,requestQueue:r,logger:i,onlineDetector:o,cacheContext:a}),this._manager=new h(e,{sdkState:t,requestQueue:r,logger:i})}requestMessengerSettings(t){return e.__awaiter(this,void 0,void 0,(function*(){const{aiAgentId:s,userId:n,language:r,country:i,context:o,forceCreateChannel:a}=t;return e.unless(e.isTypeOf("string",s)&&e.isTypeOf("string",n,!0)&&e.isTypeOf("string",r,!0)&&e.isTypeOf("string",i,!0)&&e.isTypeOf("object",o,!0)&&e.isTypeOf("boolean",a,!0)).throw(e.SendbirdError.invalidParameters),this._manager.requestMessengerSettings(t)}))}createConversationListQuery(e={}){return new _(this._iid,e)}getMessageTemplates(t={}){return e.__awaiter(this,void 0,void 0,(function*(){const s=Object.assign(Object.assign({},o),t);return e.unless((t=>e.isTypeOf("number",t.limit,!0)&&e.isArrayOf("string",t.keys,!0))(s)).throw(e.SendbirdError.invalidParameters),this._manager.getMessageTemplates(t)}))}getMessageTemplate(t){return e.__awaiter(this,void 0,void 0,(function*(){return e.unless(e.isTypeOf("string",t)).throw(e.SendbirdError.invalidParameters),this._manager.getMessageTemplate(t)}))}}exports.AIAgentInfo=e.AIAgentInfo,exports.Conversation=t.Conversation,exports.ConversationChannelInfo=t.ConversationChannelInfo,exports.ConversationHandoff=t.ConversationHandoff,exports.ConversationResolution=t.ConversationResolution,Object.defineProperty(exports,"ConversationStatus",{enumerable:!0,get:function(){return t.ConversationStatus}}),Object.defineProperty(exports,"ConversationType",{enumerable:!0,get:function(){return t.ConversationType}}),exports.AIAgentModule=m,exports.ConversationListQuery=_;
0 commit comments