@great-detail/support-sdk 0.5.0 → 0.5.2
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.
- package/dist/{chunk-CW7PHX4M.js → chunk-PMX7HD2W.js} +1 -1
- package/dist/chunk-ZQ7XANXZ.js +1 -0
- package/dist/cli/index.cjs +1 -1
- package/dist/cli/index.d.cts +1 -1
- package/dist/cli/index.d.ts +1 -1
- package/dist/cli/index.js +1 -1
- package/dist/cli.cjs +1 -1
- package/dist/cli.js +1 -1
- package/dist/{index-Bq6gR7Jn.d.cts → index-D5mrSUtT.d.cts} +116 -102
- package/dist/{index-Bq6gR7Jn.d.ts → index-D5mrSUtT.d.ts} +116 -102
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-T3S2HA4R.js +0 -1
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var Wt=Object.create;var _t=Object.defineProperty;var Yt=Object.getOwnPropertyDescriptor;var $t=Object.getOwnPropertyNames;var Xt=Object.getPrototypeOf,Qt=Object.prototype.hasOwnProperty;var Mt=(r,t)=>{for(var e in t)_t(r,e,{get:t[e],enumerable:!0})},jt=(r,t,e,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of $t(t))!Qt.call(r,i)&&i!==e&&_t(r,i,{get:()=>t[i],enumerable:!(s=Yt(t,i))||s.enumerable});return r};var Gt=(r,t,e)=>(e=r!=null?Wt(Xt(r)):{},jt(t||!r||!r.__esModule?_t(e,"default",{value:r,enumerable:!0}):e,r)),Zt=r=>jt(_t({},"__esModule",{value:!0}),r);var te={};Mt(te,{Client:()=>C,DEFAULT_SUPPORT_BASE_URL:()=>Et,Error:()=>Lt,KeyAuthentication:()=>Rt,PublicAuthentication:()=>Tt,TokenAuthentication:()=>xt,default:()=>C});module.exports=Zt(te);var Et="https://api.support.greatdetail.com",Pt={"X-Powered-By":"GDSupport/JavaScript"},zt="api-key";var A=class{constructor(t){this._transport=t}async send({request:t={}}={}){return this._transport.send("v1/actions",{...t,method:"GET"})}};var y=require("zod"),R=class r{constructor(t){this._transport=t}static SCHEMA=y.z.object({title:y.z.string(),content:y.z.string(),account:y.z.string()});async send({id:t,body:e,request:s={}}){return this._transport.send("v1/boilerplate-categories/"+encodeURIComponent(t)+"/boilerplates",{...s,method:"POST",headers:{...s.headers,"Content-Type":"application/json"},body:JSON.stringify(r.SCHEMA.parse(e))})}};var x=class{constructor(t){this._transport=t}async send({id:t,request:e={}}){return this._transport.send("v1/boilerplates/"+encodeURIComponent(t),{...e,method:"GET"})}};var T=class{constructor(t){this._transport=t}async send({id:t,request:e={}}){return this._transport.send("v1/boilerplate-categories/"+encodeURIComponent(t)+"/boilerplates",{...e,method:"GET"})}};var _=class{constructor(t){this._transport=t}async send({query:t,request:e={}}={}){return this._transport.send("v1/boilerplates"+(t?"?query="+encodeURIComponent(t):""),{...e,method:"GET"})}};var St=require("zod"),E=class r{constructor(t){this._transport=t}static SCHEMA=St.z.object({title:St.z.string().optional(),content:St.z.string().optional()});async send({id:t,body:e,request:s={}}){return this._transport.send("v1/boilerplates/"+encodeURIComponent(t),{...s,method:"PATCH",headers:{...s.headers,"Content-Type":"application/json"},body:JSON.stringify(r.SCHEMA.parse(e))})}};var S=require("zod"),O=class r{constructor(t){this._transport=t}static SCHEMA=S.z.object({title:S.z.string(),description:S.z.string().optional(),account:S.z.string()});async send({body:t,request:e={}}){return this._transport.send("v1/boilerplate-categories",{...e,method:"POST",headers:{...e.headers,"Content-Type":"application/json"},body:JSON.stringify(r.SCHEMA.parse(t))})}};var v=class{constructor(t){this._transport=t}async send({id:t,request:e={}}){return this._transport.send("v1/boilerplate-categories/"+encodeURIComponent(t),{...e,method:"GET"})}};var w=class{constructor(t){this._transport=t}async send({request:t={}}={}){return this._transport.send("v1/boilerplate-categories",{...t,method:"GET"})}};var Ot=require("zod"),F=class r{constructor(t){this._transport=t}static SCHEMA=Ot.z.object({title:Ot.z.string().optional(),description:Ot.z.string().optional()});async send({id:t,body:e,request:s={}}){return this._transport.send("v1/boilerplate-categories/"+encodeURIComponent(t),{...s,method:"PATCH",headers:{...s.headers,"Content-Type":"application/json"},body:JSON.stringify(r.SCHEMA.parse(e))})}};var n=require("zod"),U=class r{constructor(t){this._transport=t}static SCHEMA=n.z.intersection(n.z.object({name:n.z.string().optional(),account:n.z.string()}),n.z.discriminatedUnion("source",[n.z.object({source:n.z.literal("meta-whatsapp")}),n.z.object({source:n.z.literal("twilio-sendgrid"),twilioSendgrid:n.z.object({displayName:n.z.string().optional(),outboundEmailAddress:n.z.string().email(),replyEmailAddress:n.z.string().optional(),inboundHostname:n.z.string(),apiKey:n.z.string()})})]));async send({body:t,request:e={}}){return this._transport.send("v1/channels",{...e,method:"POST",headers:{...e.headers,"Content-Type":"application/json"},body:JSON.stringify(r.SCHEMA.parse(t))})}};var I=class{constructor(t){this._transport=t}async send({id:t,request:e={}}){return this._transport.send("v1/channels/"+encodeURIComponent(t),{...e,method:"GET"})}};var q=class{constructor(t){this._transport=t}async send({request:t={}}={}){return this._transport.send("v1/channels",{...t,method:"GET"})}};var o=require("zod"),H=class r{constructor(t){this._transport=t}static SCHEMA=o.z.intersection(o.z.object({name:o.z.string().optional()}),o.z.discriminatedUnion("source",[o.z.object({source:o.z.literal("meta-whatsapp")}),o.z.object({source:o.z.literal("twilio-sendgrid"),twilioSendgrid:o.z.object({displayName:o.z.string().optional(),outboundEmailAddress:o.z.string().email().optional(),replyEmailAddress:o.z.string().optional(),inboundHostname:o.z.string().optional(),apiKey:o.z.string().optional()})})]));async send({id:t,body:e,request:s={}}){return this._transport.send("v1/channels/"+encodeURIComponent(t),{...s,method:"PATCH",headers:{...s.headers,"Content-Type":"application/json"},body:JSON.stringify(r.SCHEMA.parse(e))})}};var Bt="SUPPORT_ACCESS_TOKEN",Dt="SUPPORT_API_KEY",kt="SUPPORT_KEY_NAME",Jt="SUPPORT_BASE_URL";var L=class{constructor(t){this._transport=t}getRelativeURL({id:t,vcf:e={}}){let s=e.variant??"vcard",i=e.format??(e.variant==="vcard"?"vcf":"json");return"v1/contacts/"+encodeURIComponent(t)+"/vcf?variant="+encodeURIComponent(s)+"&format="+encodeURIComponent(i)}getURL(t){return this._transport.getURL(this.getRelativeURL(t))}};var f=require("zod"),N=class r{constructor(t){this._transport=t}static SCHEMA=f.z.object({name:f.z.string(),account:f.z.string(),emailAddress:f.z.string().email().optional(),telephoneNumber:f.z.string().optional()});async send({body:t,request:e={}}){return this._transport.send("v1/contacts",{...e,method:"POST",headers:{...e.headers,"Content-Type":"application/json"},body:JSON.stringify(r.SCHEMA.parse(t))})}};var M=class{constructor(t){this._transport=t}async send({id:t,request:e={}}){return this._transport.send("v1/contacts/"+encodeURIComponent(t),{...e,method:"GET"})}};var j=class{constructor(t){this._transport=t}async send({request:t={}}={}){return this._transport.send("v1/contacts",{...t,method:"GET"})}};var G=class{constructor(t){this._transport=t}async send({id:t,request:e={}}){return this._transport.send("v1/labels/"+encodeURIComponent(t)+"/contacts",{...e,method:"GET"})}};var P=require("zod"),z=class r{constructor(t){this._transport=t}static SCHEMA=P.z.object({name:P.z.string().optional(),emailAddress:P.z.string().email().optional(),telephoneNumber:P.z.string().optional()});async send({id:t,body:e,request:s={}}){return this._transport.send("v1/contacts/"+encodeURIComponent(t),{...s,method:"PATCH",headers:{...s.headers,"Content-Type":"application/json"},body:JSON.stringify(r.SCHEMA.parse(e))})}};var B=class{constructor(t){this._transport=t}async send({id:t,request:e={}}){return this._transport.send("v1/conversations/"+encodeURIComponent(t),{...e,method:"GET"})}};var D=class{constructor(t){this._transport=t}async send({id:t,request:e={}}){return this._transport.send("v1/contacts/"+encodeURIComponent(t)+"/conversations",{...e,method:"GET"})}};var k=class{constructor(t){this._transport=t}async send({request:t={}}={}){return this._transport.send("v1/conversations",{...t,method:"GET"})}};var J=class{constructor(t){this._transport=t}async send({id:t,request:e={}}){return this._transport.send("v1/labels/"+encodeURIComponent(t)+"/conversations",{...e,method:"GET"})}};var vt=require("zod"),K=class r{constructor(t){this._transport=t}static SCHEMA=vt.z.object({status:vt.z.enum(["AwaitingContactConversationStatus","AwaitingAgentConversationStatus","ResolvedConversationStatus","ClosedConversationStatus"]).optional(),hasEnded:vt.z.boolean().optional()});async send({id:t,body:e,request:s={}}){return this._transport.send("v1/conversations/"+encodeURIComponent(t),{...s,method:"PATCH",headers:{...s.headers,"Content-Type":"application/json"},body:JSON.stringify(r.SCHEMA.parse(e))})}};var V=require("zod"),W=class r{constructor(t){this._transport=t}static SCHEMA=V.z.object({title:V.z.string(),description:V.z.string().optional(),account:V.z.string()});async send({body:t,request:e={}}){return this._transport.send("v1/labels",{...e,method:"POST",headers:{...e.headers,"Content-Type":"application/json"},body:JSON.stringify(r.SCHEMA.parse(t))})}};var Y=class{constructor(t){this._transport=t}async send({id:t,request:e={}}){return this._transport.send("v1/labels/"+encodeURIComponent(t),{...e,method:"DELETE"})}};var $=class{constructor(t){this._transport=t}async send({id:t,request:e={}}){return this._transport.send("v1/labels/"+encodeURIComponent(t),{...e,method:"GET"})}};var X=class{constructor(t){this._transport=t}async send({request:t={}}={}){return this._transport.send("v1/labels",{...t,method:"GET"})}};var wt=require("zod"),Q=class r{constructor(t){this._transport=t}static SCHEMA=wt.z.object({title:wt.z.string().optional(),description:wt.z.string().optional()});async send({id:t,body:e,request:s={}}){return this._transport.send("v1/labels/"+encodeURIComponent(t),{...s,method:"PATCH",headers:{...s.headers,"Content-Type":"application/json"},body:JSON.stringify(r.SCHEMA.parse(e))})}};var Z=class{constructor(t){this._transport=t}async send({id:t,request:e={}}){return this._transport.send("v1/channels/"+encodeURIComponent(t)+"/messages",{...e,method:"GET"})}};var tt=class{constructor(t){this._transport=t}async send({id:t,request:e={}}){return this._transport.send("v1/conversations/"+encodeURIComponent(t)+"/messages",{...e,method:"GET"})}};var et=class{constructor(t){this._transport=t}async send({request:t={}}={}){return this._transport.send("v1/messages",{...t,method:"GET"})}};var rt=require("zod"),st=class r{constructor(t){this._transport=t}static SCHEMA=rt.z.object({input:rt.z.string().max(65536),original:rt.z.string().max(65536),correction:rt.z.string().max(65536)});async send({id:t,body:e,request:s={}}){return this._transport.send("v1/models/"+encodeURIComponent(t)+"/correction",{...s,method:"POST",headers:{...s.headers,"Content-Type":"application/json"},body:JSON.stringify(r.SCHEMA.parse(e))})}};var nt=class{constructor(t){this._transport=t}async send({id:t,request:e={}}){return this._transport.send("v1/models/"+encodeURIComponent(t),{...e,method:"GET"})}};var ot=class{constructor(t){this._transport=t}async send({request:t={}}={}){return this._transport.send("v1/models",{...t,method:"GET"})}};var it=require("zod"),at=class r{constructor(t){this._transport=t}static SCHEMA=it.z.array(it.z.object({role:it.z.enum(["user","assistant"]),content:it.z.string().max(65536).nullable()})).min(1);async send({id:t,body:e,request:s={}}){return this._transport.send("v1/models/"+encodeURIComponent(t)+"/response",{...s,method:"POST",headers:{...s.headers,"Content-Type":"application/json"},body:JSON.stringify(r.SCHEMA.parse(e))})}};var It=require("zod"),pt=class r{constructor(t){this._transport=t}static SCHEMA=It.z.object({content:It.z.string()});async send({id:t,body:e,request:s={}}){return this._transport.send("v1/contacts/"+encodeURIComponent(t)+"/notes",{...s,method:"POST",headers:{...s.headers,"Content-Type":"application/json"},body:JSON.stringify(r.SCHEMA.parse(e))})}};var qt=require("zod"),b=class r{constructor(t){this._transport=t}static SCHEMA=qt.z.object({content:qt.z.string()});async send({id:t,body:e,request:s={}}){return this._transport.send("v1/conversations/"+encodeURIComponent(t)+"/notes",{...s,method:"POST",headers:{...s.headers,"Content-Type":"application/json"},body:JSON.stringify(r.SCHEMA.parse(e))})}};var ct=class{constructor(t){this._transport=t}async send({id:t,request:e={}}){return this._transport.send("v1/notes/"+encodeURIComponent(t),{...e,method:"GET"})}};var dt=class{constructor(t){this._transport=t}async send({id:t,request:e={}}){return this._transport.send("v1/contacts/"+encodeURIComponent(t)+"/notes",{...e,method:"GET"})}};var lt=class{constructor(t){this._transport=t}async send({id:t,request:e={}}){return this._transport.send("v1/conversations/"+encodeURIComponent(t)+"/notes",{...e,method:"GET"})}};var Ht=require("zod"),ut=class r{constructor(t){this._transport=t}static SCHEMA=Ht.z.object({content:Ht.z.string().optional()});async send({id:t,body:e,request:s={}}){return this._transport.send("v1/notes/"+encodeURIComponent(t),{...s,method:"PATCH",headers:{...s.headers,"Content-Type":"application/json"},body:JSON.stringify(r.SCHEMA.parse(e))})}};var d=require("zod"),gt=class r{constructor(t){this._transport=t}static SCHEMA=d.z.discriminatedUnion("type",[d.z.object({type:d.z.literal("vapid"),endpoint:d.z.string().url(),keys:d.z.object({p256dh:d.z.string(),auth:d.z.string()})})]);async send({id:t,body:e,request:s={}}){return this._transport.send("v1/contacts/"+encodeURIComponent(t)+"/notification-subscriptions",{...s,method:"POST",headers:{...s.headers,"Content-Type":"application/json"},body:JSON.stringify(r.SCHEMA.parse(e))})}};var mt=class r{constructor(t=r.STANDARD_HEADERS){this._standardHeaders=t}static STANDARD_HEADERS=Pt;async filter(){return{headers:this.getHeaders()}}getHeaders(){return this._standardHeaders}};var ht=class{constructor(t){this._transport=t}async send({id:t,request:e={}}){return this._transport.send("v1/sources/"+encodeURIComponent(t),{...e,method:"GET"})}};var ft=class{constructor(t){this._transport=t}async send({request:t={}}={}){return this._transport.send("v1/sources",{...t,method:"GET"})}};var Kt=Gt(require("is-network-error"),1),Ft=Gt(require("ky"),1);var a=class extends Error{};var c=class extends a{};var u=class extends c{static unauthenticated(){return new this("An unauthenticated request occurred")}};var g=class extends c{static forbidden(){return new this("A forbidden request occurred")}};var l=class extends a{static notFound(t){return new this(`Record not found for request: ${t}`)}static forbiddenMethod(t,e){return new this(`Forbidden method for request: ${t} ${e}`)}};var m=class extends a{};var h=class extends a{static badRequest(){return new this("Bad request")}};var bt=class{client;options;constructor({baseURL:t,...e}){this.options={...e,baseURL:t},this.client=Ft.default.create({prefixUrl:this.options.baseURL,hooks:{beforeRequest:[s=>{for(let i of this.options.requestFilterables){let Ut=i.getHeaders();for(let[Nt,Vt]of Object.entries(Ut))s.headers.has(Nt)||s.headers.set(Nt,Vt)}}]}})}getURL(t){return new URL(t,this.options.baseURL).toString()}async send(t,e){return await this.client(t,e).catch(s=>{if((0,Kt.default)(s))throw new m("A network error occurred",{cause:s});if(s instanceof Ft.HTTPError){let i=s.response.status;switch(console.error(JSON.stringify(s.response)),i){case 400:throw h.badRequest();case 401:throw u.unauthenticated();case 403:throw g.forbidden();case 404:throw l.notFound(t);case 405:throw l.forbiddenMethod(t,e.method??"GET")}}throw s})}};var Ct=class{constructor(t){this._transport=t}async send({account:t,files:e,request:s={}}){let i=new FormData;for(let Ut of e)i.append("file",Ut);return this._transport.send("v1/uploads?account="+encodeURIComponent(t),{...s,method:"POST",body:i})}};var At=class{constructor(t){this._transport=t}async send({id:t,request:e={}}){return this._transport.send("v1/uploads/"+encodeURIComponent(t),{...e,method:"GET"})}};var p=require("zod"),yt=class r{constructor(t){this._client=t}static SCHEMA=p.z.object({event:p.z.intersection(p.z.object({id:p.z.string(),createdAt:p.z.string().datetime()}),p.z.discriminatedUnion("type",[p.z.object({type:p.z.literal("contact.created"),contact:p.z.string()}),p.z.object({type:p.z.literal("message.created"),message:p.z.string()})]))});async event({request:t}){let{event:e}=r.SCHEMA.parse(t.body);return{event:e}}};var C=class r{static DEFAULT_BASE_URL=Et;_transport;constructor(t,{baseURL:e,...s}={}){this._transport=new bt({requestFilterables:[new mt,t],...s,baseURL:e?.toString()??r.getBaseURL()})}static getBaseURL(){return process.env[Jt]??this.DEFAULT_BASE_URL}get action(){return{list:new A(this._transport)}}get boilerplate(){return{get:new x(this._transport),list:new _(this._transport),update:new E(this._transport)}}get boilerplateCategory(){return{get:new v(this._transport),list:new w(this._transport),create:new O(this._transport),update:new F(this._transport),boilerplate:{list:new T(this._transport),create:new R(this._transport)}}}get channel(){return{get:new I(this._transport),list:new q(this._transport),update:new H(this._transport),create:new U(this._transport),message:{list:new Z(this._transport)}}}get contact(){return{get:new M(this._transport),list:new j(this._transport),update:new z(this._transport),create:new N(this._transport),conversation:{list:new D(this._transport)},note:{list:new dt(this._transport),create:new pt(this._transport)},notificationSubscription:{create:new gt(this._transport)},vcf:{get:new L(this._transport)}}}get conversation(){return{get:new B(this._transport),list:new k(this._transport),update:new K(this._transport),create:new b(this._transport),message:{list:new tt(this._transport)},note:{list:new lt(this._transport),create:new b(this._transport)}}}get label(){return{create:new W(this._transport),get:new $(this._transport),list:new X(this._transport),update:new Q(this._transport),delete:new Y(this._transport),contact:{list:new G(this._transport)},conversation:{list:new J(this._transport)}}}get message(){return{list:new et(this._transport)}}get model(){return{get:new nt(this._transport),list:new ot(this._transport),response:{create:new at(this._transport)},correction:{create:new st(this._transport)}}}get note(){return{get:new ct(this._transport),update:new ut(this._transport)}}get source(){return{get:new ht(this._transport),list:new ft(this._transport)}}get upload(){return{get:new At(this._transport),create:new Ct(this._transport)}}get webhook(){return new yt(this)}};var Lt={};Mt(Lt,{AuthError:()=>c,AuthenticationError:()=>u,AuthorizationError:()=>g,LogicError:()=>l,NetworkError:()=>m,SupportError:()=>a,ValidationError:()=>h});var Rt=class r{static DEFAULT_NAME=zt;name;#t;constructor({name:t=process.env[kt]??r.DEFAULT_NAME,key:e=process.env[Dt]}={}){if(!e)throw new Error("API Key option must be specified when using Key Authentication");this.name=t,this.#t=e}async filter(){return{headers:this.getHeaders()}}getHeaders(){return{Authorization:`Basic ${btoa(this.name+":"+this.#t)}`}}};var xt=class{#t;constructor({token:t=process.env[Bt]}={}){if(!t)throw new Error("Access Token option must be specified when using Token Authentication");this.#t=t}async filter(){return{headers:this.getHeaders()}}getHeaders(){return{Authorization:`Bearer ${this.#t}`}}};var Tt=class{async filter(){return{headers:this.getHeaders()}}getHeaders(){return{}}};0&&(module.exports={Client,DEFAULT_SUPPORT_BASE_URL,Error,KeyAuthentication,PublicAuthentication,TokenAuthentication});
|
|
1
|
+
"use strict";var $t=Object.create;var vt=Object.defineProperty;var Jt=Object.getOwnPropertyDescriptor;var Xt=Object.getOwnPropertyNames;var Qt=Object.getPrototypeOf,Zt=Object.prototype.hasOwnProperty;var Nt=(r,t)=>{for(var e in t)vt(r,e,{get:t[e],enumerable:!0})},Gt=(r,t,e,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of Xt(t))!Zt.call(r,n)&&n!==e&&vt(r,n,{get:()=>t[n],enumerable:!(s=Jt(t,n))||s.enumerable});return r};var Pt=(r,t,e)=>(e=r!=null?$t(Qt(r)):{},Gt(t||!r||!r.__esModule?vt(e,"default",{value:r,enumerable:!0}):e,r)),te=r=>Gt(vt({},"__esModule",{value:!0}),r);var ee={};Nt(ee,{Client:()=>C,DEFAULT_SUPPORT_BASE_URL:()=>St,Error:()=>Mt,KeyAuthentication:()=>Tt,PublicAuthentication:()=>Et,TokenAuthentication:()=>_t,default:()=>C});module.exports=te(ee);var St="https://api.support.greatdetail.com",zt={"X-Powered-By":"GDSupport/JavaScript"},Bt="api-key";var R=class{constructor(t){this._transport=t}async send({request:t={}}={}){return this._transport.send("v1/actions",{...t,method:"GET"})}};var y=require("zod"),x=class r{constructor(t){this._transport=t}static SCHEMA=y.z.object({title:y.z.string(),content:y.z.string(),account:y.z.string()});async send({id:t,body:e,request:s={}}){return this._transport.send("v1/boilerplate-categories/"+encodeURIComponent(t)+"/boilerplates",{...s,method:"POST",headers:{...s.headers,"Content-Type":"application/json"},json:r.SCHEMA.parse(e)})}};var T=class{constructor(t){this._transport=t}async send({id:t,request:e={}}){return this._transport.send("v1/boilerplates/"+encodeURIComponent(t),{...e,method:"GET"})}};var _=class{constructor(t){this._transport=t}async send({id:t,request:e={}}){return this._transport.send("v1/boilerplate-categories/"+encodeURIComponent(t)+"/boilerplates",{...e,method:"GET"})}};var E=class{constructor(t){this._transport=t}async send({query:t,request:e={}}={}){return this._transport.send("v1/boilerplates"+(t?"?query="+encodeURIComponent(t):""),{...e,method:"GET"})}};var Ot=require("zod"),v=class r{constructor(t){this._transport=t}static SCHEMA=Ot.z.object({title:Ot.z.string().optional(),content:Ot.z.string().optional()});async send({id:t,body:e,request:s={}}){return this._transport.send("v1/boilerplates/"+encodeURIComponent(t),{...s,method:"PATCH",headers:{...s.headers,"Content-Type":"application/json"},json:r.SCHEMA.parse(e)})}};var S=require("zod"),O=class r{constructor(t){this._transport=t}static SCHEMA=S.z.object({title:S.z.string(),description:S.z.string().optional(),account:S.z.string()});async send({body:t,request:e={}}){return this._transport.send("v1/boilerplate-categories",{...e,method:"POST",headers:{...e.headers,"Content-Type":"application/json"},json:r.SCHEMA.parse(t)})}};var w=class{constructor(t){this._transport=t}async send({id:t,request:e={}}){return this._transport.send("v1/boilerplate-categories/"+encodeURIComponent(t),{...e,method:"GET"})}};var F=class{constructor(t){this._transport=t}async send({request:t={}}={}){return this._transport.send("v1/boilerplate-categories",{...t,method:"GET"})}};var wt=require("zod"),U=class r{constructor(t){this._transport=t}static SCHEMA=wt.z.object({title:wt.z.string().optional(),description:wt.z.string().optional()});async send({id:t,body:e,request:s={}}){return this._transport.send("v1/boilerplate-categories/"+encodeURIComponent(t),{...s,method:"PATCH",headers:{...s.headers,"Content-Type":"application/json"},json:r.SCHEMA.parse(e)})}};var o=require("zod"),I=class r{constructor(t){this._transport=t}static SCHEMA=o.z.intersection(o.z.object({name:o.z.string().optional(),account:o.z.string()}),o.z.discriminatedUnion("source",[o.z.object({source:o.z.literal("meta-whatsapp")}),o.z.object({source:o.z.literal("twilio-sendgrid"),twilioSendgrid:o.z.object({displayName:o.z.string().optional(),outboundEmailAddress:o.z.string().email(),replyEmailAddress:o.z.string().optional(),inboundHostname:o.z.string(),apiKey:o.z.string()})})]));async send({body:t,request:e={}}){return this._transport.send("v1/channels",{...e,method:"POST",headers:{...e.headers,"Content-Type":"application/json"},json:r.SCHEMA.parse(t)})}};var q=class{constructor(t){this._transport=t}async send({id:t,request:e={}}){return this._transport.send("v1/channels/"+encodeURIComponent(t),{...e,method:"GET"})}};var L=class{constructor(t){this._transport=t}async send({request:t={}}={}){return this._transport.send("v1/channels",{...t,method:"GET"})}};var i=require("zod"),H=class r{constructor(t){this._transport=t}static SCHEMA=i.z.intersection(i.z.object({name:i.z.string().optional()}),i.z.discriminatedUnion("source",[i.z.object({source:i.z.literal("meta-whatsapp")}),i.z.object({source:i.z.literal("twilio-sendgrid"),twilioSendgrid:i.z.object({displayName:i.z.string().optional(),outboundEmailAddress:i.z.string().email().optional(),replyEmailAddress:i.z.string().optional(),inboundHostname:i.z.string().optional(),apiKey:i.z.string().optional()})})]));async send({id:t,body:e,request:s={}}){return this._transport.send("v1/channels/"+encodeURIComponent(t),{...s,method:"PATCH",headers:{...s.headers,"Content-Type":"application/json"},json:r.SCHEMA.parse(e)})}};var Dt="SUPPORT_ACCESS_TOKEN",kt="SUPPORT_API_KEY",Kt="SUPPORT_KEY_NAME",Vt="SUPPORT_BASE_URL";var M=class{constructor(t){this._transport=t}getRelativeURL({id:t,vcf:e={}}){let s=e.variant??"vcard",n=e.format??(e.variant==="vcard"?"vcf":"json");return"v1/contacts/"+encodeURIComponent(t)+"/vcf?variant="+encodeURIComponent(s)+"&format="+encodeURIComponent(n)}getURL(t){return this._transport.getURL(this.getRelativeURL(t))}};var f=require("zod"),j=class r{constructor(t){this._transport=t}static SCHEMA=f.z.object({name:f.z.string(),account:f.z.string(),emailAddress:f.z.string().email().optional(),telephoneNumber:f.z.string().optional()});async send({body:t,request:e={}}){return this._transport.send("v1/contacts",{...e,method:"POST",headers:{...e.headers,"Content-Type":"application/json"},json:r.SCHEMA.parse(t)})}};var N=class{constructor(t){this._transport=t}async send({id:t,request:e={}}){return this._transport.send("v1/contacts/"+encodeURIComponent(t),{...e,method:"GET"})}};var G=class{constructor(t){this._transport=t}async send({request:t={}}={}){return this._transport.send("v1/contacts",{...t,method:"GET"})}};var P=class{constructor(t){this._transport=t}async send({id:t,request:e={}}){return this._transport.send("v1/labels/"+encodeURIComponent(t)+"/contacts",{...e,method:"GET"})}};var z=require("zod"),B=class r{constructor(t){this._transport=t}static SCHEMA=z.z.object({name:z.z.string().optional(),emailAddress:z.z.string().email().optional(),telephoneNumber:z.z.string().optional()});async send({id:t,body:e,request:s={}}){return this._transport.send("v1/contacts/"+encodeURIComponent(t),{...s,method:"PATCH",headers:{...s.headers,"Content-Type":"application/json"},json:r.SCHEMA.parse(e)})}};var D=class{constructor(t){this._transport=t}async send({id:t,request:e={}}){return this._transport.send("v1/conversations/"+encodeURIComponent(t),{...e,method:"GET"})}};var k=class{constructor(t){this._transport=t}async send({id:t,request:e={}}){return this._transport.send("v1/contacts/"+encodeURIComponent(t)+"/conversations",{...e,method:"GET"})}};var K=class{constructor(t){this._transport=t}async send({filter:t,request:e={}}={}){let s=[];return t&&s.push(["filter",t]),this._transport.send("v1/conversations",{...e,method:"GET",searchParams:s})}};var V=class{constructor(t){this._transport=t}async send({id:t,request:e={}}){return this._transport.send("v1/labels/"+encodeURIComponent(t)+"/conversations",{...e,method:"GET"})}};var Ft=require("zod"),W=class r{constructor(t){this._transport=t}static SCHEMA=Ft.z.object({status:Ft.z.enum(["AwaitingContactConversationStatus","AwaitingAgentConversationStatus","ResolvedConversationStatus","ClosedConversationStatus"]).optional(),hasEnded:Ft.z.boolean().optional()});async send({id:t,body:e,request:s={}}){return this._transport.send("v1/conversations/"+encodeURIComponent(t),{...s,method:"PATCH",headers:{...s.headers,"Content-Type":"application/json"},json:r.SCHEMA.parse(e)})}};var Y=require("zod"),$=class r{constructor(t){this._transport=t}static SCHEMA=Y.z.object({title:Y.z.string(),description:Y.z.string().optional(),account:Y.z.string()});async send({body:t,request:e={}}){return this._transport.send("v1/labels",{...e,method:"POST",headers:{...e.headers,"Content-Type":"application/json"},json:r.SCHEMA.parse(t)})}};var J=class{constructor(t){this._transport=t}async send({id:t,request:e={}}){return this._transport.send("v1/labels/"+encodeURIComponent(t),{...e,method:"DELETE"})}};var X=class{constructor(t){this._transport=t}async send({id:t,request:e={}}){return this._transport.send("v1/labels/"+encodeURIComponent(t),{...e,method:"GET"})}};var Q=class{constructor(t){this._transport=t}async send({request:t={}}={}){return this._transport.send("v1/labels",{...t,method:"GET"})}};var Ut=require("zod"),Z=class r{constructor(t){this._transport=t}static SCHEMA=Ut.z.object({title:Ut.z.string().optional(),description:Ut.z.string().optional()});async send({id:t,body:e,request:s={}}){return this._transport.send("v1/labels/"+encodeURIComponent(t),{...s,method:"PATCH",headers:{...s.headers,"Content-Type":"application/json"},json:r.SCHEMA.parse(e)})}};var tt=class{constructor(t){this._transport=t}async send({id:t,request:e={}}){return this._transport.send("v1/channels/"+encodeURIComponent(t)+"/messages",{...e,method:"GET"})}};var et=class{constructor(t){this._transport=t}async send({id:t,request:e={}}){return this._transport.send("v1/conversations/"+encodeURIComponent(t)+"/messages",{...e,method:"GET"})}};var rt=class{constructor(t){this._transport=t}async send({request:t={}}={}){return this._transport.send("v1/messages",{...t,method:"GET"})}};var st=require("zod"),nt=class r{constructor(t){this._transport=t}static SCHEMA=st.z.object({input:st.z.string().max(65536),original:st.z.string().max(65536),correction:st.z.string().max(65536)});async send({id:t,body:e,request:s={}}){return this._transport.send("v1/models/"+encodeURIComponent(t)+"/correction",{...s,method:"POST",headers:{...s.headers,"Content-Type":"application/json"},json:r.SCHEMA.parse(e)})}};var ot=class{constructor(t){this._transport=t}async send({id:t,request:e={}}){return this._transport.send("v1/models/"+encodeURIComponent(t),{...e,method:"GET"})}};var it=class{constructor(t){this._transport=t}async send({request:t={}}={}){return this._transport.send("v1/models",{...t,method:"GET"})}};var at=require("zod"),pt=class r{constructor(t){this._transport=t}static SCHEMA=at.z.array(at.z.object({role:at.z.enum(["user","assistant"]),content:at.z.string().max(65536).nullable()})).min(1);async send({id:t,body:e,request:s={}}){return this._transport.send("v1/models/"+encodeURIComponent(t)+"/response",{...s,method:"POST",headers:{...s.headers,"Content-Type":"application/json"},json:r.SCHEMA.parse(e)})}};var qt=require("zod"),ct=class r{constructor(t){this._transport=t}static SCHEMA=qt.z.object({content:qt.z.string()});async send({id:t,body:e,request:s={}}){return this._transport.send("v1/contacts/"+encodeURIComponent(t)+"/notes",{...s,method:"POST",headers:{...s.headers,"Content-Type":"application/json"},json:r.SCHEMA.parse(e)})}};var Lt=require("zod"),b=class r{constructor(t){this._transport=t}static SCHEMA=Lt.z.object({content:Lt.z.string()});async send({id:t,body:e,request:s={}}){return this._transport.send("v1/conversations/"+encodeURIComponent(t)+"/notes",{...s,method:"POST",headers:{...s.headers,"Content-Type":"application/json"},json:r.SCHEMA.parse(e)})}};var dt=class{constructor(t){this._transport=t}async send({id:t,request:e={}}){return this._transport.send("v1/notes/"+encodeURIComponent(t),{...e,method:"GET"})}};var lt=class{constructor(t){this._transport=t}async send({id:t,request:e={}}){return this._transport.send("v1/contacts/"+encodeURIComponent(t)+"/notes",{...e,method:"GET"})}};var ut=class{constructor(t){this._transport=t}async send({id:t,request:e={}}){return this._transport.send("v1/conversations/"+encodeURIComponent(t)+"/notes",{...e,method:"GET"})}};var Ht=require("zod"),gt=class r{constructor(t){this._transport=t}static SCHEMA=Ht.z.object({content:Ht.z.string().optional()});async send({id:t,body:e,request:s={}}){return this._transport.send("v1/notes/"+encodeURIComponent(t),{...s,method:"PATCH",headers:{...s.headers,"Content-Type":"application/json"},json:r.SCHEMA.parse(e)})}};var d=require("zod"),mt=class r{constructor(t){this._transport=t}static SCHEMA=d.z.discriminatedUnion("type",[d.z.object({type:d.z.literal("vapid"),endpoint:d.z.string().url(),keys:d.z.object({p256dh:d.z.string(),auth:d.z.string()})})]);async send({id:t,body:e,request:s={}}){return this._transport.send("v1/contacts/"+encodeURIComponent(t)+"/notification-subscriptions",{...s,method:"POST",headers:{...s.headers,"Content-Type":"application/json"},json:r.SCHEMA.parse(e)})}};var ht=class r{constructor(t=r.STANDARD_HEADERS){this._standardHeaders=t}static STANDARD_HEADERS=zt;async filter(){return{headers:this.getHeaders()}}getHeaders(){return this._standardHeaders}};var ft=class{constructor(t){this._transport=t}async send({id:t,request:e={}}){return this._transport.send("v1/sources/"+encodeURIComponent(t),{...e,method:"GET"})}};var bt=class{constructor(t){this._transport=t}async send({category:t,request:e={}}={}){let s=[];if(t){let n=Array.isArray(t)?t:[t];for(let A of n)s.push(["category",A])}return this._transport.send("v1/sources",{...e,method:"GET",searchParams:s})}};var Wt=Pt(require("is-network-error"),1),It=Pt(require("ky"),1);var a=class extends Error{};var c=class extends a{};var u=class extends c{static unauthenticated(){return new this("An unauthenticated request occurred")}};var g=class extends c{static forbidden(){return new this("A forbidden request occurred")}};var l=class extends a{static notFound(t){return new this(`Record not found for request: ${t}`)}static forbiddenMethod(t,e){return new this(`Forbidden method for request: ${t} ${e}`)}};var m=class extends a{};var h=class extends a{static badRequest(){return new this("Bad request")}};var Ct=class{client;options;constructor({baseURL:t,...e}){this.options={...e,baseURL:t},this.client=It.default.create({prefixUrl:this.options.baseURL,hooks:{beforeRequest:[s=>{for(let n of this.options.requestFilterables){let A=n.getHeaders();for(let[jt,Yt]of Object.entries(A))s.headers.has(jt)||s.headers.set(jt,Yt)}}]}})}getURL(t){return new URL(t,this.options.baseURL).toString()}async send(t,e){return await this.client(t,e).catch(s=>{if((0,Wt.default)(s))throw new m("A network error occurred",{cause:s});if(s instanceof It.HTTPError){let n=s.response.status;switch(console.error(JSON.stringify(s.response)),n){case 400:throw h.badRequest();case 401:throw u.unauthenticated();case 403:throw g.forbidden();case 404:throw l.notFound(t);case 405:throw l.forbiddenMethod(t,e.method??"GET")}}throw s})}};var At=class{constructor(t){this._transport=t}async send({account:t,files:e,request:s={}}){let n=new FormData;for(let A of e)n.append("file",A);return this._transport.send("v1/uploads",{...s,method:"POST",body:n,searchParams:{account:t}})}};var Rt=class{constructor(t){this._transport=t}async send({id:t,request:e={}}){return this._transport.send("v1/uploads/"+encodeURIComponent(t),{...e,method:"DELETE"})}};var yt=class{constructor(t){this._transport=t}async send({id:t,request:e={}}){return this._transport.send("v1/uploads/"+encodeURIComponent(t),{...e,method:"GET"})}};var p=require("zod"),xt=class r{constructor(t){this._client=t}static SCHEMA=p.z.object({event:p.z.intersection(p.z.object({id:p.z.string(),createdAt:p.z.string().datetime()}),p.z.discriminatedUnion("type",[p.z.object({type:p.z.literal("contact.created"),contact:p.z.string()}),p.z.object({type:p.z.literal("message.created"),message:p.z.string()})]))});async event({request:t}){let{event:e}=r.SCHEMA.parse(t.body);return{event:e}}};var C=class r{static DEFAULT_BASE_URL=St;_transport;constructor(t,{baseURL:e,...s}={}){this._transport=new Ct({requestFilterables:[new ht,t],...s,baseURL:e?.toString()??r.getBaseURL()})}static getBaseURL(){return process.env[Vt]??this.DEFAULT_BASE_URL}get action(){return{list:new R(this._transport)}}get boilerplate(){return{get:new T(this._transport),list:new E(this._transport),update:new v(this._transport)}}get boilerplateCategory(){return{get:new w(this._transport),list:new F(this._transport),create:new O(this._transport),update:new U(this._transport),boilerplate:{list:new _(this._transport),create:new x(this._transport)}}}get channel(){return{get:new q(this._transport),list:new L(this._transport),update:new H(this._transport),create:new I(this._transport),message:{list:new tt(this._transport)}}}get contact(){return{get:new N(this._transport),list:new G(this._transport),update:new B(this._transport),create:new j(this._transport),conversation:{list:new k(this._transport)},note:{list:new lt(this._transport),create:new ct(this._transport)},notificationSubscription:{create:new mt(this._transport)},vcf:{get:new M(this._transport)}}}get conversation(){return{get:new D(this._transport),list:new K(this._transport),update:new W(this._transport),create:new b(this._transport),message:{list:new et(this._transport)},note:{list:new ut(this._transport),create:new b(this._transport)}}}get label(){return{create:new $(this._transport),get:new X(this._transport),list:new Q(this._transport),update:new Z(this._transport),delete:new J(this._transport),contact:{list:new P(this._transport)},conversation:{list:new V(this._transport)}}}get message(){return{list:new rt(this._transport)}}get model(){return{get:new ot(this._transport),list:new it(this._transport),response:{create:new pt(this._transport)},correction:{create:new nt(this._transport)}}}get note(){return{get:new dt(this._transport),update:new gt(this._transport)}}get source(){return{get:new ft(this._transport),list:new bt(this._transport)}}get upload(){return{get:new yt(this._transport),create:new At(this._transport),delete:new Rt(this._transport)}}get webhook(){return new xt(this)}};var Mt={};Nt(Mt,{AuthError:()=>c,AuthenticationError:()=>u,AuthorizationError:()=>g,LogicError:()=>l,NetworkError:()=>m,SupportError:()=>a,ValidationError:()=>h});var Tt=class r{static DEFAULT_NAME=Bt;name;#t;constructor({name:t=process.env[Kt]??r.DEFAULT_NAME,key:e=process.env[kt]}={}){if(!e)throw new Error("API Key option must be specified when using Key Authentication");this.name=t,this.#t=e}async filter(){return{headers:this.getHeaders()}}getHeaders(){return{Authorization:`Basic ${btoa(this.name+":"+this.#t)}`}}};var _t=class{#t;constructor({token:t=process.env[Dt]}={}){if(!t)throw new Error("Access Token option must be specified when using Token Authentication");this.#t=t}async filter(){return{headers:this.getHeaders()}}getHeaders(){return{Authorization:`Bearer ${this.#t}`}}};var Et=class{async filter(){return{headers:this.getHeaders()}}getHeaders(){return{}}};0&&(module.exports={Client,DEFAULT_SUPPORT_BASE_URL,Error,KeyAuthentication,PublicAuthentication,TokenAuthentication});
|
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { A as Authentication } from './index-
|
|
2
|
-
export { C as Client, b as CreateBoilerplateCategoryBoilerplateResponse, e as CreateBoilerplateCategoryResponse, l as CreateChannelResponse, M as CreateContactNoteResponse, Y as CreateContactNotificationSubscriptionResponse, m as CreateContactResponse, N as CreateConversationNoteResponse, J as CreateCorrectionResponse, w as CreateLabelResponse, K as CreateResponseResponse, Z as CreateUploadResponse, D as DeleteLabelResponse, f as GetBoilerplateCategoryResponse, G as GetBoilerplateResponse, j as GetChannelResponse, n as GetContactResponse, r as GetConversationResponse, x as GetLabelResponse, H as GetModelResponse, P as GetNoteResponse, V as GetSourceResponse, _ as GetUploadResponse, L as ListActionsResponse, g as ListBoilerplateCategoriesResponse, c as ListBoilerplateCategoryBoilerplatesResponse, d as ListBoilerplatesResponse, F as ListChannelMessagesResponse, i as ListChannelsResponse, v as ListContactConversationsResponse, Q as ListContactNotesResponse, o as ListContactsResponse, B as ListConversationMessagesResponse, S as ListConversationNotesResponse, s as ListConversationsResponse, p as ListLabelContactsResponse, t as ListLabelConversationsResponse, y as ListLabelsResponse, E as ListMessagesResponse, I as ListModelsResponse, X as ListSourcesResponse, O as Options, R as RequestFilterable, a as TransportOptions, h as UpdateBoilerplateCategoryResponse, U as UpdateBoilerplateResponse, k as UpdateChannelResponse, q as UpdateContactResponse, u as UpdateConversationResponse, z as UpdateLabelResponse, T as UpdateNoteResponse, W as WebhookResponse, C as default } from './index-
|
|
1
|
+
import { A as Authentication } from './index-D5mrSUtT.cjs';
|
|
2
|
+
export { C as Client, b as CreateBoilerplateCategoryBoilerplateResponse, e as CreateBoilerplateCategoryResponse, l as CreateChannelResponse, M as CreateContactNoteResponse, Y as CreateContactNotificationSubscriptionResponse, m as CreateContactResponse, N as CreateConversationNoteResponse, J as CreateCorrectionResponse, w as CreateLabelResponse, K as CreateResponseResponse, Z as CreateUploadResponse, D as DeleteLabelResponse, $ as DeleteUploadResponse, f as GetBoilerplateCategoryResponse, G as GetBoilerplateResponse, j as GetChannelResponse, n as GetContactResponse, r as GetConversationResponse, x as GetLabelResponse, H as GetModelResponse, P as GetNoteResponse, V as GetSourceResponse, _ as GetUploadResponse, L as ListActionsResponse, g as ListBoilerplateCategoriesResponse, c as ListBoilerplateCategoryBoilerplatesResponse, d as ListBoilerplatesResponse, F as ListChannelMessagesResponse, i as ListChannelsResponse, v as ListContactConversationsResponse, Q as ListContactNotesResponse, o as ListContactsResponse, B as ListConversationMessagesResponse, S as ListConversationNotesResponse, s as ListConversationsResponse, p as ListLabelContactsResponse, t as ListLabelConversationsResponse, y as ListLabelsResponse, E as ListMessagesResponse, I as ListModelsResponse, X as ListSourcesResponse, O as Options, R as RequestFilterable, a as TransportOptions, h as UpdateBoilerplateCategoryResponse, U as UpdateBoilerplateResponse, k as UpdateChannelResponse, q as UpdateContactResponse, u as UpdateConversationResponse, z as UpdateLabelResponse, T as UpdateNoteResponse, W as WebhookResponse, C as default } from './index-D5mrSUtT.cjs';
|
|
3
3
|
import 'ky';
|
|
4
4
|
import 'zod';
|
|
5
5
|
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { A as Authentication } from './index-
|
|
2
|
-
export { C as Client, b as CreateBoilerplateCategoryBoilerplateResponse, e as CreateBoilerplateCategoryResponse, l as CreateChannelResponse, M as CreateContactNoteResponse, Y as CreateContactNotificationSubscriptionResponse, m as CreateContactResponse, N as CreateConversationNoteResponse, J as CreateCorrectionResponse, w as CreateLabelResponse, K as CreateResponseResponse, Z as CreateUploadResponse, D as DeleteLabelResponse, f as GetBoilerplateCategoryResponse, G as GetBoilerplateResponse, j as GetChannelResponse, n as GetContactResponse, r as GetConversationResponse, x as GetLabelResponse, H as GetModelResponse, P as GetNoteResponse, V as GetSourceResponse, _ as GetUploadResponse, L as ListActionsResponse, g as ListBoilerplateCategoriesResponse, c as ListBoilerplateCategoryBoilerplatesResponse, d as ListBoilerplatesResponse, F as ListChannelMessagesResponse, i as ListChannelsResponse, v as ListContactConversationsResponse, Q as ListContactNotesResponse, o as ListContactsResponse, B as ListConversationMessagesResponse, S as ListConversationNotesResponse, s as ListConversationsResponse, p as ListLabelContactsResponse, t as ListLabelConversationsResponse, y as ListLabelsResponse, E as ListMessagesResponse, I as ListModelsResponse, X as ListSourcesResponse, O as Options, R as RequestFilterable, a as TransportOptions, h as UpdateBoilerplateCategoryResponse, U as UpdateBoilerplateResponse, k as UpdateChannelResponse, q as UpdateContactResponse, u as UpdateConversationResponse, z as UpdateLabelResponse, T as UpdateNoteResponse, W as WebhookResponse, C as default } from './index-
|
|
1
|
+
import { A as Authentication } from './index-D5mrSUtT.js';
|
|
2
|
+
export { C as Client, b as CreateBoilerplateCategoryBoilerplateResponse, e as CreateBoilerplateCategoryResponse, l as CreateChannelResponse, M as CreateContactNoteResponse, Y as CreateContactNotificationSubscriptionResponse, m as CreateContactResponse, N as CreateConversationNoteResponse, J as CreateCorrectionResponse, w as CreateLabelResponse, K as CreateResponseResponse, Z as CreateUploadResponse, D as DeleteLabelResponse, $ as DeleteUploadResponse, f as GetBoilerplateCategoryResponse, G as GetBoilerplateResponse, j as GetChannelResponse, n as GetContactResponse, r as GetConversationResponse, x as GetLabelResponse, H as GetModelResponse, P as GetNoteResponse, V as GetSourceResponse, _ as GetUploadResponse, L as ListActionsResponse, g as ListBoilerplateCategoriesResponse, c as ListBoilerplateCategoryBoilerplatesResponse, d as ListBoilerplatesResponse, F as ListChannelMessagesResponse, i as ListChannelsResponse, v as ListContactConversationsResponse, Q as ListContactNotesResponse, o as ListContactsResponse, B as ListConversationMessagesResponse, S as ListConversationNotesResponse, s as ListConversationsResponse, p as ListLabelContactsResponse, t as ListLabelConversationsResponse, y as ListLabelsResponse, E as ListMessagesResponse, I as ListModelsResponse, X as ListSourcesResponse, O as Options, R as RequestFilterable, a as TransportOptions, h as UpdateBoilerplateCategoryResponse, U as UpdateBoilerplateResponse, k as UpdateChannelResponse, q as UpdateContactResponse, u as UpdateConversationResponse, z as UpdateLabelResponse, T as UpdateNoteResponse, W as WebhookResponse, C as default } from './index-D5mrSUtT.js';
|
|
3
3
|
import 'ky';
|
|
4
4
|
import 'zod';
|
|
5
5
|
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as d,b as g,c as s,d as p,e as n,f as _,g as a,h as f,i as m,j as u,k as c,l as x,m as l,n as h,o as A}from"./chunk-
|
|
1
|
+
import{a as d,b as g,c as s,d as p,e as n,f as _,g as a,h as f,i as m,j as u,k as c,l as x,m as l,n as h,o as A}from"./chunk-ZQ7XANXZ.js";var E={};d(E,{AuthError:()=>m,AuthenticationError:()=>u,AuthorizationError:()=>c,LogicError:()=>x,NetworkError:()=>l,SupportError:()=>f,ValidationError:()=>h});var t=class o{static DEFAULT_NAME=a;name;#r;constructor({name:r=process.env[n]??o.DEFAULT_NAME,key:i=process.env[p]}={}){if(!i)throw new Error("API Key option must be specified when using Key Authentication");this.name=r,this.#r=i}async filter(){return{headers:this.getHeaders()}}getHeaders(){return{Authorization:`Basic ${btoa(this.name+":"+this.#r)}`}}};var e=class{#r;constructor({token:r=process.env[s]}={}){if(!r)throw new Error("Access Token option must be specified when using Token Authentication");this.#r=r}async filter(){return{headers:this.getHeaders()}}getHeaders(){return{Authorization:`Bearer ${this.#r}`}}};export{A as Client,_ as DEFAULT_SUPPORT_BASE_URL,E as Error,t as KeyAuthentication,g as PublicAuthentication,e as TokenAuthentication,A as default};
|
package/package.json
CHANGED
package/dist/chunk-T3S2HA4R.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var Lt=Object.defineProperty;var Gt=(r,t)=>{for(var e in t)Lt(r,e,{get:t[e],enumerable:!0})};var Rt=class{async filter(){return{headers:this.getHeaders()}}getHeaders(){return{}}};var Ot="https://api.support.greatdetail.com",wt={"X-Powered-By":"GDSupport/JavaScript"},Bt="api-key";import{z as i}from"zod";var g=class r{constructor(t){this._client=t}static SCHEMA=i.object({event:i.intersection(i.object({id:i.string(),createdAt:i.string().datetime()}),i.discriminatedUnion("type",[i.object({type:i.literal("contact.created"),contact:i.string()}),i.object({type:i.literal("message.created"),message:i.string()})]))});async event({request:t}){let{event:e}=r.SCHEMA.parse(t.body);return{event:e}}};var m=class{constructor(t){this._transport=t}async send({request:t={}}={}){return this._transport.send("v1/actions",{...t,method:"GET"})}};import{z as mt}from"zod";var h=class r{constructor(t){this._transport=t}static SCHEMA=mt.object({title:mt.string(),content:mt.string(),account:mt.string()});async send({id:t,body:e,request:s={}}){return this._transport.send("v1/boilerplate-categories/"+encodeURIComponent(t)+"/boilerplates",{...s,method:"POST",headers:{...s.headers,"Content-Type":"application/json"},body:JSON.stringify(r.SCHEMA.parse(e))})}};var f=class{constructor(t){this._transport=t}async send({id:t,request:e={}}){return this._transport.send("v1/boilerplates/"+encodeURIComponent(t),{...e,method:"GET"})}};var b=class{constructor(t){this._transport=t}async send({id:t,request:e={}}){return this._transport.send("v1/boilerplate-categories/"+encodeURIComponent(t)+"/boilerplates",{...e,method:"GET"})}};var C=class{constructor(t){this._transport=t}async send({query:t,request:e={}}={}){return this._transport.send("v1/boilerplates"+(t?"?query="+encodeURIComponent(t):""),{...e,method:"GET"})}};import{z as Tt}from"zod";var y=class r{constructor(t){this._transport=t}static SCHEMA=Tt.object({title:Tt.string().optional(),content:Tt.string().optional()});async send({id:t,body:e,request:s={}}){return this._transport.send("v1/boilerplates/"+encodeURIComponent(t),{...s,method:"PATCH",headers:{...s.headers,"Content-Type":"application/json"},body:JSON.stringify(r.SCHEMA.parse(e))})}};import{z as ht}from"zod";var A=class r{constructor(t){this._transport=t}static SCHEMA=ht.object({title:ht.string(),description:ht.string().optional(),account:ht.string()});async send({body:t,request:e={}}){return this._transport.send("v1/boilerplate-categories",{...e,method:"POST",headers:{...e.headers,"Content-Type":"application/json"},body:JSON.stringify(r.SCHEMA.parse(t))})}};var R=class{constructor(t){this._transport=t}async send({id:t,request:e={}}){return this._transport.send("v1/boilerplate-categories/"+encodeURIComponent(t),{...e,method:"GET"})}};var T=class{constructor(t){this._transport=t}async send({request:t={}}={}){return this._transport.send("v1/boilerplate-categories",{...t,method:"GET"})}};import{z as xt}from"zod";var x=class r{constructor(t){this._transport=t}static SCHEMA=xt.object({title:xt.string().optional(),description:xt.string().optional()});async send({id:t,body:e,request:s={}}){return this._transport.send("v1/boilerplate-categories/"+encodeURIComponent(t),{...s,method:"PATCH",headers:{...s.headers,"Content-Type":"application/json"},body:JSON.stringify(r.SCHEMA.parse(e))})}};import{z as n}from"zod";var _=class r{constructor(t){this._transport=t}static SCHEMA=n.intersection(n.object({name:n.string().optional(),account:n.string()}),n.discriminatedUnion("source",[n.object({source:n.literal("meta-whatsapp")}),n.object({source:n.literal("twilio-sendgrid"),twilioSendgrid:n.object({displayName:n.string().optional(),outboundEmailAddress:n.string().email(),replyEmailAddress:n.string().optional(),inboundHostname:n.string(),apiKey:n.string()})})]));async send({body:t,request:e={}}){return this._transport.send("v1/channels",{...e,method:"POST",headers:{...e.headers,"Content-Type":"application/json"},body:JSON.stringify(r.SCHEMA.parse(t))})}};var S=class{constructor(t){this._transport=t}async send({id:t,request:e={}}){return this._transport.send("v1/channels/"+encodeURIComponent(t),{...e,method:"GET"})}};var E=class{constructor(t){this._transport=t}async send({request:t={}}={}){return this._transport.send("v1/channels",{...t,method:"GET"})}};import{z as o}from"zod";var v=class r{constructor(t){this._transport=t}static SCHEMA=o.intersection(o.object({name:o.string().optional()}),o.discriminatedUnion("source",[o.object({source:o.literal("meta-whatsapp")}),o.object({source:o.literal("twilio-sendgrid"),twilioSendgrid:o.object({displayName:o.string().optional(),outboundEmailAddress:o.string().email().optional(),replyEmailAddress:o.string().optional(),inboundHostname:o.string().optional(),apiKey:o.string().optional()})})]));async send({id:t,body:e,request:s={}}){return this._transport.send("v1/channels/"+encodeURIComponent(t),{...s,method:"PATCH",headers:{...s.headers,"Content-Type":"application/json"},body:JSON.stringify(r.SCHEMA.parse(e))})}};var ue="SUPPORT_ACCESS_TOKEN",ge="SUPPORT_API_KEY",me="SUPPORT_KEY_NAME",Ft="SUPPORT_BASE_URL";var O=class{constructor(t){this._transport=t}getRelativeURL({id:t,vcf:e={}}){let s=e.variant??"vcard",p=e.format??(e.variant==="vcard"?"vcf":"json");return"v1/contacts/"+encodeURIComponent(t)+"/vcf?variant="+encodeURIComponent(s)+"&format="+encodeURIComponent(p)}getURL(t){return this._transport.getURL(this.getRelativeURL(t))}};import{z as w}from"zod";var F=class r{constructor(t){this._transport=t}static SCHEMA=w.object({name:w.string(),account:w.string(),emailAddress:w.string().email().optional(),telephoneNumber:w.string().optional()});async send({body:t,request:e={}}){return this._transport.send("v1/contacts",{...e,method:"POST",headers:{...e.headers,"Content-Type":"application/json"},body:JSON.stringify(r.SCHEMA.parse(t))})}};var I=class{constructor(t){this._transport=t}async send({id:t,request:e={}}){return this._transport.send("v1/contacts/"+encodeURIComponent(t),{...e,method:"GET"})}};var U=class{constructor(t){this._transport=t}async send({request:t={}}={}){return this._transport.send("v1/contacts",{...t,method:"GET"})}};var q=class{constructor(t){this._transport=t}async send({id:t,request:e={}}){return this._transport.send("v1/labels/"+encodeURIComponent(t)+"/contacts",{...e,method:"GET"})}};import{z as ft}from"zod";var H=class r{constructor(t){this._transport=t}static SCHEMA=ft.object({name:ft.string().optional(),emailAddress:ft.string().email().optional(),telephoneNumber:ft.string().optional()});async send({id:t,body:e,request:s={}}){return this._transport.send("v1/contacts/"+encodeURIComponent(t),{...s,method:"PATCH",headers:{...s.headers,"Content-Type":"application/json"},body:JSON.stringify(r.SCHEMA.parse(e))})}};var L=class{constructor(t){this._transport=t}async send({id:t,request:e={}}){return this._transport.send("v1/conversations/"+encodeURIComponent(t),{...e,method:"GET"})}};var N=class{constructor(t){this._transport=t}async send({id:t,request:e={}}){return this._transport.send("v1/contacts/"+encodeURIComponent(t)+"/conversations",{...e,method:"GET"})}};var M=class{constructor(t){this._transport=t}async send({request:t={}}={}){return this._transport.send("v1/conversations",{...t,method:"GET"})}};var j=class{constructor(t){this._transport=t}async send({id:t,request:e={}}){return this._transport.send("v1/labels/"+encodeURIComponent(t)+"/conversations",{...e,method:"GET"})}};import{z as _t}from"zod";var G=class r{constructor(t){this._transport=t}static SCHEMA=_t.object({status:_t.enum(["AwaitingContactConversationStatus","AwaitingAgentConversationStatus","ResolvedConversationStatus","ClosedConversationStatus"]).optional(),hasEnded:_t.boolean().optional()});async send({id:t,body:e,request:s={}}){return this._transport.send("v1/conversations/"+encodeURIComponent(t),{...s,method:"PATCH",headers:{...s.headers,"Content-Type":"application/json"},body:JSON.stringify(r.SCHEMA.parse(e))})}};import{z as bt}from"zod";var P=class r{constructor(t){this._transport=t}static SCHEMA=bt.object({title:bt.string(),description:bt.string().optional(),account:bt.string()});async send({body:t,request:e={}}){return this._transport.send("v1/labels",{...e,method:"POST",headers:{...e.headers,"Content-Type":"application/json"},body:JSON.stringify(r.SCHEMA.parse(t))})}};var z=class{constructor(t){this._transport=t}async send({id:t,request:e={}}){return this._transport.send("v1/labels/"+encodeURIComponent(t),{...e,method:"DELETE"})}};var B=class{constructor(t){this._transport=t}async send({id:t,request:e={}}){return this._transport.send("v1/labels/"+encodeURIComponent(t),{...e,method:"GET"})}};var D=class{constructor(t){this._transport=t}async send({request:t={}}={}){return this._transport.send("v1/labels",{...t,method:"GET"})}};import{z as St}from"zod";var J=class r{constructor(t){this._transport=t}static SCHEMA=St.object({title:St.string().optional(),description:St.string().optional()});async send({id:t,body:e,request:s={}}){return this._transport.send("v1/labels/"+encodeURIComponent(t),{...s,method:"PATCH",headers:{...s.headers,"Content-Type":"application/json"},body:JSON.stringify(r.SCHEMA.parse(e))})}};var k=class{constructor(t){this._transport=t}async send({id:t,request:e={}}){return this._transport.send("v1/channels/"+encodeURIComponent(t)+"/messages",{...e,method:"GET"})}};var K=class{constructor(t){this._transport=t}async send({id:t,request:e={}}){return this._transport.send("v1/conversations/"+encodeURIComponent(t)+"/messages",{...e,method:"GET"})}};var V=class{constructor(t){this._transport=t}async send({request:t={}}={}){return this._transport.send("v1/messages",{...t,method:"GET"})}};import{z as Ct}from"zod";var W=class r{constructor(t){this._transport=t}static SCHEMA=Ct.object({input:Ct.string().max(65536),original:Ct.string().max(65536),correction:Ct.string().max(65536)});async send({id:t,body:e,request:s={}}){return this._transport.send("v1/models/"+encodeURIComponent(t)+"/correction",{...s,method:"POST",headers:{...s.headers,"Content-Type":"application/json"},body:JSON.stringify(r.SCHEMA.parse(e))})}};var Y=class{constructor(t){this._transport=t}async send({id:t,request:e={}}){return this._transport.send("v1/models/"+encodeURIComponent(t),{...e,method:"GET"})}};var $=class{constructor(t){this._transport=t}async send({request:t={}}={}){return this._transport.send("v1/models",{...t,method:"GET"})}};import{z as yt}from"zod";var X=class r{constructor(t){this._transport=t}static SCHEMA=yt.array(yt.object({role:yt.enum(["user","assistant"]),content:yt.string().max(65536).nullable()})).min(1);async send({id:t,body:e,request:s={}}){return this._transport.send("v1/models/"+encodeURIComponent(t)+"/response",{...s,method:"POST",headers:{...s.headers,"Content-Type":"application/json"},body:JSON.stringify(r.SCHEMA.parse(e))})}};import{z as It}from"zod";var Q=class r{constructor(t){this._transport=t}static SCHEMA=It.object({content:It.string()});async send({id:t,body:e,request:s={}}){return this._transport.send("v1/contacts/"+encodeURIComponent(t)+"/notes",{...s,method:"POST",headers:{...s.headers,"Content-Type":"application/json"},body:JSON.stringify(r.SCHEMA.parse(e))})}};import{z as Ut}from"zod";var l=class r{constructor(t){this._transport=t}static SCHEMA=Ut.object({content:Ut.string()});async send({id:t,body:e,request:s={}}){return this._transport.send("v1/conversations/"+encodeURIComponent(t)+"/notes",{...s,method:"POST",headers:{...s.headers,"Content-Type":"application/json"},body:JSON.stringify(r.SCHEMA.parse(e))})}};var Z=class{constructor(t){this._transport=t}async send({id:t,request:e={}}){return this._transport.send("v1/notes/"+encodeURIComponent(t),{...e,method:"GET"})}};var tt=class{constructor(t){this._transport=t}async send({id:t,request:e={}}){return this._transport.send("v1/contacts/"+encodeURIComponent(t)+"/notes",{...e,method:"GET"})}};var et=class{constructor(t){this._transport=t}async send({id:t,request:e={}}){return this._transport.send("v1/conversations/"+encodeURIComponent(t)+"/notes",{...e,method:"GET"})}};import{z as qt}from"zod";var rt=class r{constructor(t){this._transport=t}static SCHEMA=qt.object({content:qt.string().optional()});async send({id:t,body:e,request:s={}}){return this._transport.send("v1/notes/"+encodeURIComponent(t),{...s,method:"PATCH",headers:{...s.headers,"Content-Type":"application/json"},body:JSON.stringify(r.SCHEMA.parse(e))})}};import{z as c}from"zod";var st=class r{constructor(t){this._transport=t}static SCHEMA=c.discriminatedUnion("type",[c.object({type:c.literal("vapid"),endpoint:c.string().url(),keys:c.object({p256dh:c.string(),auth:c.string()})})]);async send({id:t,body:e,request:s={}}){return this._transport.send("v1/contacts/"+encodeURIComponent(t)+"/notification-subscriptions",{...s,method:"POST",headers:{...s.headers,"Content-Type":"application/json"},body:JSON.stringify(r.SCHEMA.parse(e))})}};var nt=class r{constructor(t=r.STANDARD_HEADERS){this._standardHeaders=t}static STANDARD_HEADERS=wt;async filter(){return{headers:this.getHeaders()}}getHeaders(){return this._standardHeaders}};var ot=class{constructor(t){this._transport=t}async send({id:t,request:e={}}){return this._transport.send("v1/sources/"+encodeURIComponent(t),{...e,method:"GET"})}};var it=class{constructor(t){this._transport=t}async send({request:t={}}={}){return this._transport.send("v1/sources",{...t,method:"GET"})}};import Nt from"is-network-error";import Mt,{HTTPError as jt}from"ky";var a=class extends Error{};var d=class extends a{};var at=class extends d{static unauthenticated(){return new this("An unauthenticated request occurred")}};var pt=class extends d{static forbidden(){return new this("A forbidden request occurred")}};var u=class extends a{static notFound(t){return new this(`Record not found for request: ${t}`)}static forbiddenMethod(t,e){return new this(`Forbidden method for request: ${t} ${e}`)}};var ct=class extends a{};var dt=class extends a{static badRequest(){return new this("Bad request")}};var lt=class{client;options;constructor({baseURL:t,...e}){this.options={...e,baseURL:t},this.client=Mt.create({prefixUrl:this.options.baseURL,hooks:{beforeRequest:[s=>{for(let p of this.options.requestFilterables){let At=p.getHeaders();for(let[vt,Ht]of Object.entries(At))s.headers.has(vt)||s.headers.set(vt,Ht)}}]}})}getURL(t){return new URL(t,this.options.baseURL).toString()}async send(t,e){return await this.client(t,e).catch(s=>{if(Nt(s))throw new ct("A network error occurred",{cause:s});if(s instanceof jt){let p=s.response.status;switch(console.error(JSON.stringify(s.response)),p){case 400:throw dt.badRequest();case 401:throw at.unauthenticated();case 403:throw pt.forbidden();case 404:throw u.notFound(t);case 405:throw u.forbiddenMethod(t,e.method??"GET")}}throw s})}};var ut=class{constructor(t){this._transport=t}async send({account:t,files:e,request:s={}}){let p=new FormData;for(let At of e)p.append("file",At);return this._transport.send("v1/uploads?account="+encodeURIComponent(t),{...s,method:"POST",body:p})}};var gt=class{constructor(t){this._transport=t}async send({id:t,request:e={}}){return this._transport.send("v1/uploads/"+encodeURIComponent(t),{...e,method:"GET"})}};var Et=class r{static DEFAULT_BASE_URL=Ot;_transport;constructor(t,{baseURL:e,...s}={}){this._transport=new lt({requestFilterables:[new nt,t],...s,baseURL:e?.toString()??r.getBaseURL()})}static getBaseURL(){return process.env[Ft]??this.DEFAULT_BASE_URL}get action(){return{list:new m(this._transport)}}get boilerplate(){return{get:new f(this._transport),list:new C(this._transport),update:new y(this._transport)}}get boilerplateCategory(){return{get:new R(this._transport),list:new T(this._transport),create:new A(this._transport),update:new x(this._transport),boilerplate:{list:new b(this._transport),create:new h(this._transport)}}}get channel(){return{get:new S(this._transport),list:new E(this._transport),update:new v(this._transport),create:new _(this._transport),message:{list:new k(this._transport)}}}get contact(){return{get:new I(this._transport),list:new U(this._transport),update:new H(this._transport),create:new F(this._transport),conversation:{list:new N(this._transport)},note:{list:new tt(this._transport),create:new Q(this._transport)},notificationSubscription:{create:new st(this._transport)},vcf:{get:new O(this._transport)}}}get conversation(){return{get:new L(this._transport),list:new M(this._transport),update:new G(this._transport),create:new l(this._transport),message:{list:new K(this._transport)},note:{list:new et(this._transport),create:new l(this._transport)}}}get label(){return{create:new P(this._transport),get:new B(this._transport),list:new D(this._transport),update:new J(this._transport),delete:new z(this._transport),contact:{list:new q(this._transport)},conversation:{list:new j(this._transport)}}}get message(){return{list:new V(this._transport)}}get model(){return{get:new Y(this._transport),list:new $(this._transport),response:{create:new X(this._transport)},correction:{create:new W(this._transport)}}}get note(){return{get:new Z(this._transport),update:new rt(this._transport)}}get source(){return{get:new ot(this._transport),list:new it(this._transport)}}get upload(){return{get:new gt(this._transport),create:new ut(this._transport)}}get webhook(){return new g(this)}};export{Gt as a,Rt as b,ue as c,ge as d,me as e,Ot as f,Bt as g,a as h,d as i,at as j,pt as k,u as l,ct as m,dt as n,Et as o};
|