@great-detail/support-sdk 0.7.6 → 0.8.0

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/index.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";var se=Object.create;var qt=Object.defineProperty;var oe=Object.getOwnPropertyDescriptor;var ie=Object.getOwnPropertyNames;var ae=Object.getPrototypeOf,pe=Object.prototype.hasOwnProperty;var Wt=(r,t)=>{for(var e in t)qt(r,e,{get:t[e],enumerable:!0})},Yt=(r,t,e,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of ie(t))!pe.call(r,s)&&s!==e&&qt(r,s,{get:()=>t[s],enumerable:!(n=oe(t,s))||n.enumerable});return r};var $t=(r,t,e)=>(e=r!=null?se(ae(r)):{},Yt(t||!r||!r.__esModule?qt(e,"default",{value:r,enumerable:!0}):e,r)),ce=r=>Yt(qt({},"__esModule",{value:!0}),r);var de={};Wt(de,{Client:()=>R,DEFAULT_SUPPORT_BASE_URL:()=>Ht,Error:()=>Kt,KeyAuthentication:()=>It,PublicAuthentication:()=>Ut,TokenAuthentication:()=>Ft,default:()=>R});module.exports=ce(de);var Ht="https://api.support.greatdetail.com",Jt={"X-Powered-By":"GDSupport/JavaScript"},Xt="api-key";var y=class{constructor(t){this._transport=t}async send({request:t={}}={}){return this._transport.send("v1/actions",{...t,method:"GET"})}};var C=require("zod"),T=class r{constructor(t){this._transport=t}static SCHEMA=C.z.object({title:C.z.string(),content:C.z.string(),account:C.z.string(),boilerplateCategory:C.z.string()});async send({body:t,request:e={}}){return this._transport.send("v1/boilerplates",{...e,method:"POST",headers:{...e.headers,"Content-Type":"application/json"},json:r.SCHEMA.parse(t)})}};var E=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 S=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 Lt=require("zod"),v=class r{constructor(t){this._transport=t}static SCHEMA=Lt.z.object({title:Lt.z.string().optional(),content:Lt.z.string().optional()});async send({id:t,body:e,request:n={}}){return this._transport.send("v1/boilerplates/"+encodeURIComponent(t),{...n,method:"PATCH",headers:{...n.headers,"Content-Type":"application/json"},json:r.SCHEMA.parse(e)})}};var O=require("zod"),w=class r{constructor(t){this._transport=t}static SCHEMA=O.z.object({title:O.z.string(),description:O.z.string().optional(),account:O.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 I=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({include:t,request:e={}}={}){let n=[];for(let s of Object.keys(t??{}))n.push(["include",s]);return this._transport.send("v1/boilerplate-categories",{...e,method:"GET",searchParams:n})}};var Mt=require("zod"),U=class r{constructor(t){this._transport=t}static SCHEMA=Mt.z.object({title:Mt.z.string().optional(),description:Mt.z.string().optional()});async send({id:t,body:e,request:n={}}){return this._transport.send("v1/boilerplate-categories/"+encodeURIComponent(t),{...n,method:"PATCH",headers:{...n.headers,"Content-Type":"application/json"},json:r.SCHEMA.parse(e)})}};var o=require("zod"),q=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 H=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 Gt=require("zod"),M=class r{constructor(t){this._transport=t}static SCHEMA=Gt.z.object({overwrite:Gt.z.boolean().optional()});async send({id:t,body:e,request:n={}}){return this._transport.send("v1/sources/twilio-sendgrid/channels/"+encodeURIComponent(t)+"/sync",{...n,method:"POST",headers:{...n.headers,"Content-Type":"application/json"},json:r.SCHEMA.parse(e)})}};var i=require("zod"),j=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:n={}}){return this._transport.send("v1/channels/"+encodeURIComponent(t),{...n,method:"PATCH",headers:{...n.headers,"Content-Type":"application/json"},json:r.SCHEMA.parse(e)})}};var b=require("zod"),N=class r{constructor(t){this._transport=t}static SCHEMA=b.z.object({account:b.z.string(),channel:b.z.string().optional(),location:b.z.enum(["header","footer"]),content:b.z.string()});async send({body:t,request:e={}}){return this._transport.send("v1/composition-sections",{...e,method:"POST",headers:{...e.headers,"Content-Type":"application/json"},json:r.SCHEMA.parse(t)})}};var P=class{constructor(t){this._transport=t}async send({id:t,request:e={}}){return this._transport.send("v1/composition-sections/"+encodeURIComponent(t),{...e,method:"GET"})}};var G=class{constructor(t){this._transport=t}async send({id:t,request:e={}}){return this._transport.send("v1/channels/"+encodeURIComponent(t)+"/composition-sections",{...e,method:"GET"})}};var z=class{constructor(t){this._transport=t}async send({request:t={}}={}){return this._transport.send("v1/composition-sections",{...t,method:"GET"})}};var zt=require("zod"),D=class r{constructor(t){this._transport=t}static SCHEMA=zt.z.object({content:zt.z.string()});async send({id:t,body:e,request:n={}}){return this._transport.send("v1/composition-sections/"+encodeURIComponent(t),{...n,method:"PATCH",headers:{...n.headers,"Content-Type":"application/json"},json:r.SCHEMA.parse(e)})}};var Qt="SUPPORT_ACCESS_TOKEN",Zt="SUPPORT_API_KEY",te="SUPPORT_KEY_NAME",ee="SUPPORT_BASE_URL";var B=class{constructor(t){this._transport=t}getRelativeURL({id:t,vcf:e={}}){let n=e.variant??"vcard",s=e.format??(e.variant==="vcard"?"vcf":"json");return"v1/contacts/"+encodeURIComponent(t)+"/vcf?variant="+encodeURIComponent(n)+"&format="+encodeURIComponent(s)}getURL(t){return this._transport.getURL(this.getRelativeURL(t))}};var A=require("zod"),k=class r{constructor(t){this._transport=t}static SCHEMA=A.z.object({name:A.z.string(),account:A.z.string(),emailAddress:A.z.string().email().optional(),telephoneNumber:A.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 K=class{constructor(t){this._transport=t}async send({id:t,include:e,request:n={}}){let s=[];for(let c of Object.keys(e??{}))s.push(["include",c]);return this._transport.send("v1/contacts/"+encodeURIComponent(t),{...n,method:"GET",searchParams:s})}};var V=class{constructor(t){this._transport=t}async send({request:t={}}={}){return this._transport.send("v1/contacts",{...t,method:"GET"})}};var W=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 Y=require("zod"),$=class r{constructor(t){this._transport=t}static SCHEMA=Y.z.object({name:Y.z.string().optional(),emailAddress:Y.z.string().email().optional(),telephoneNumber:Y.z.string().optional()});async send({id:t,body:e,request:n={}}){return this._transport.send("v1/contacts/"+encodeURIComponent(t),{...n,method:"PATCH",headers:{...n.headers,"Content-Type":"application/json"},json:r.SCHEMA.parse(e)})}};var J=class{constructor(t){this._transport=t}async send({id:t,include:e,request:n={}}){let s=[];for(let c of Object.keys(e??{}))s.push(["include",c]);return this._transport.send("v1/conversations/"+encodeURIComponent(t),{...n,method:"GET",searchParams:s})}};var X=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 Q=class{constructor(t){this._transport=t}async send({filter:t,include:e,request:n={}}={}){let s=[];t&&s.push(["filter",t]);for(let c of Object.keys(e??{}))s.push(["include",c]);return this._transport.send("v1/conversations",{...n,method:"GET",searchParams:s})}};var Z=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 jt=require("zod"),tt=class r{constructor(t){this._transport=t}static SCHEMA=jt.z.object({status:jt.z.enum(["AwaitingContactConversationStatus","AwaitingAgentConversationStatus","ResolvedConversationStatus","ClosedConversationStatus"]).optional(),hasEnded:jt.z.boolean().optional()});async send({id:t,body:e,request:n={}}){return this._transport.send("v1/conversations/"+encodeURIComponent(t),{...n,method:"PATCH",headers:{...n.headers,"Content-Type":"application/json"},json:r.SCHEMA.parse(e)})}};var et=require("zod"),rt=class r{constructor(t){this._transport=t}static SCHEMA=et.z.object({title:et.z.string(),description:et.z.string().optional(),account:et.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 nt=class{constructor(t){this._transport=t}async send({id:t,request:e={}}){return this._transport.send("v1/labels/"+encodeURIComponent(t),{...e,method:"DELETE"})}};var st=class{constructor(t){this._transport=t}async send({id:t,request:e={}}){return this._transport.send("v1/labels/"+encodeURIComponent(t),{...e,method:"GET"})}};var ot=class{constructor(t){this._transport=t}async send({include:t,request:e={}}={}){let n=[];for(let s of Object.keys(t??{}))n.push(["include",s]);return this._transport.send("v1/labels",{...e,method:"GET",searchParams:n})}};var Nt=require("zod"),it=class r{constructor(t){this._transport=t}static SCHEMA=Nt.z.object({title:Nt.z.string().optional(),description:Nt.z.string().optional()});async send({id:t,body:e,request:n={}}){return this._transport.send("v1/labels/"+encodeURIComponent(t),{...n,method:"PATCH",headers:{...n.headers,"Content-Type":"application/json"},json:r.SCHEMA.parse(e)})}};var at=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 pt=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 ct=class{constructor(t){this._transport=t}async send({request:t={}}={}){return this._transport.send("v1/messages",{...t,method:"GET"})}};var dt=require("zod"),ut=class r{constructor(t){this._transport=t}static SCHEMA=dt.z.object({input:dt.z.string().max(65536),original:dt.z.string().max(65536),correction:dt.z.string().max(65536)});async send({id:t,body:e,request:n={}}){return this._transport.send("v1/models/"+encodeURIComponent(t)+"/correction",{...n,method:"POST",headers:{...n.headers,"Content-Type":"application/json"},json:r.SCHEMA.parse(e)})}};var lt=class{constructor(t){this._transport=t}async send({id:t,request:e={}}){return this._transport.send("v1/models/"+encodeURIComponent(t),{...e,method:"GET"})}};var gt=class{constructor(t){this._transport=t}async send({request:t={}}={}){return this._transport.send("v1/models",{...t,method:"GET"})}};var mt=require("zod"),ht=class r{constructor(t){this._transport=t}static SCHEMA=mt.z.array(mt.z.object({role:mt.z.enum(["user","assistant"]),content:mt.z.string().max(65536).nullable()})).min(1);async send({id:t,body:e,request:n={}}){return this._transport.send("v1/models/"+encodeURIComponent(t)+"/response",{...n,method:"POST",headers:{...n.headers,"Content-Type":"application/json"},json:r.SCHEMA.parse(e)})}};var Dt=require("zod"),ft=class r{constructor(t){this._transport=t}static SCHEMA=Dt.z.object({content:Dt.z.string()});async send({id:t,body:e,request:n={}}){return this._transport.send("v1/contacts/"+encodeURIComponent(t)+"/notes",{...n,method:"POST",headers:{...n.headers,"Content-Type":"application/json"},json:r.SCHEMA.parse(e)})}};var Bt=require("zod"),x=class r{constructor(t){this._transport=t}static SCHEMA=Bt.z.object({content:Bt.z.string()});async send({id:t,body:e,request:n={}}){return this._transport.send("v1/conversations/"+encodeURIComponent(t)+"/notes",{...n,method:"POST",headers:{...n.headers,"Content-Type":"application/json"},json: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 bt=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 At=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 kt=require("zod"),xt=class r{constructor(t){this._transport=t}static SCHEMA=kt.z.object({content:kt.z.string().optional()});async send({id:t,body:e,request:n={}}){return this._transport.send("v1/notes/"+encodeURIComponent(t),{...n,method:"PATCH",headers:{...n.headers,"Content-Type":"application/json"},json:r.SCHEMA.parse(e)})}};var u=require("zod"),Rt=class r{constructor(t){this._transport=t}static SCHEMA=u.z.discriminatedUnion("type",[u.z.object({type:u.z.literal("vapid"),endpoint:u.z.string().url(),keys:u.z.object({p256dh:u.z.string(),auth:u.z.string()})})]);async send({id:t,body:e,request:n={}}){return this._transport.send("v1/contacts/"+encodeURIComponent(t)+"/notification-subscriptions",{...n,method:"POST",headers:{...n.headers,"Content-Type":"application/json"},json:r.SCHEMA.parse(e)})}};var yt=class r{constructor(t=r.STANDARD_HEADERS){this._standardHeaders=t}static STANDARD_HEADERS=Jt;async filter(){return{headers:this.getHeaders()}}getHeaders(){return this._standardHeaders}};var Tt=class{constructor(t){this._transport=t}async send({id:t,request:e={}}){return this._transport.send("v1/sources/"+encodeURIComponent(t),{...e,method:"GET"})}};var Et=class{constructor(t){this._transport=t}async send({category:t,request:e={}}={}){let n=[];if(t){let s=Array.isArray(t)?t:[t];for(let c of s)n.push(["category",c])}return this._transport.send("v1/sources",{...e,method:"GET",searchParams:n})}};var re=$t(require("is-network-error"),1),Pt=$t(require("ky"),1);var a=class extends Error{};var d=class extends a{};var g=class extends d{static unauthenticated(){return new this("An unauthenticated request occurred")}};var m=class extends d{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 h=class extends a{};var f=class extends a{static badRequest(){return new this("Bad request")}};var _t=class{client;options;constructor({baseURL:t,...e}){this.options={...e,baseURL:t},this.client=Pt.default.create({prefixUrl:this.options.baseURL,hooks:{beforeRequest:[n=>{for(let s of this.options.requestFilterables){let c=s.getHeaders();for(let[Vt,ne]of Object.entries(c))n.headers.has(Vt)||n.headers.set(Vt,ne)}}]}})}getURL(t){return new URL(t,this.options.baseURL).toString()}async send(t,e){return await this.client(t,e).catch(n=>{if((0,re.default)(n))throw new h("A network error occurred",{cause:n});if(n instanceof Pt.HTTPError){let s=n.response.status;switch(console.error(JSON.stringify(n.response)),s){case 400:throw f.badRequest();case 401:throw g.unauthenticated();case 403:throw m.forbidden();case 404:throw l.notFound(t);case 405:throw l.forbiddenMethod(t,e.method??"GET")}}throw n})}};var St=class{constructor(t){this._transport=t}async send({account:t,files:e,request:n={}}){let s=new FormData;for(let c of e)s.append("file",c);return this._transport.send("v1/uploads",{...n,method:"POST",body:s,searchParams:{account:t}})}};var vt=class{constructor(t){this._transport=t}async send({id:t,request:e={}}){return this._transport.send("v1/uploads/"+encodeURIComponent(t),{...e,method:"DELETE"})}};var Ot=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"),wt=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 R=class r{static DEFAULT_BASE_URL=Ht;_transport;constructor(t,{baseURL:e,...n}={}){this._transport=new _t({requestFilterables:[new yt,t],...n,baseURL:e?.toString()??r.getBaseURL()})}static getBaseURL(){return process.env[ee]??this.DEFAULT_BASE_URL}get action(){return{list:new y(this._transport)}}get boilerplate(){return{get:new E(this._transport),list:new S(this._transport),update:new v(this._transport),create:new T(this._transport)}}get boilerplateCategory(){return{get:new I(this._transport),list:new F(this._transport),create:new w(this._transport),update:new U(this._transport),boilerplate:{list:new _(this._transport)}}}get channel(){return{get:new H(this._transport),list:new L(this._transport),update:new j(this._transport),create:new q(this._transport),compositionSection:{list:new G(this._transport)},message:{list:new at(this._transport)},twilioSendgrid:{sync:new M(this._transport)}}}get compositionSection(){return{get:new P(this._transport),list:new z(this._transport),create:new N(this._transport),update:new D(this._transport)}}get contact(){return{get:new K(this._transport),list:new V(this._transport),update:new $(this._transport),create:new k(this._transport),conversation:{list:new X(this._transport)},note:{list:new bt(this._transport),create:new ft(this._transport)},notificationSubscription:{create:new Rt(this._transport)},vcf:{get:new B(this._transport)}}}get conversation(){return{get:new J(this._transport),list:new Q(this._transport),update:new tt(this._transport),create:new x(this._transport),message:{list:new pt(this._transport)},note:{list:new At(this._transport),create:new x(this._transport)}}}get label(){return{create:new rt(this._transport),get:new st(this._transport),list:new ot(this._transport),update:new it(this._transport),delete:new nt(this._transport),contact:{list:new W(this._transport)},conversation:{list:new Z(this._transport)}}}get message(){return{list:new ct(this._transport)}}get model(){return{get:new lt(this._transport),list:new gt(this._transport),response:{create:new ht(this._transport)},correction:{create:new ut(this._transport)}}}get note(){return{get:new Ct(this._transport),update:new xt(this._transport)}}get source(){return{get:new Tt(this._transport),list:new Et(this._transport)}}get upload(){return{get:new Ot(this._transport),create:new St(this._transport),delete:new vt(this._transport)}}get webhook(){return new wt(this)}};var Kt={};Wt(Kt,{AuthError:()=>d,AuthenticationError:()=>g,AuthorizationError:()=>m,LogicError:()=>l,NetworkError:()=>h,SupportError:()=>a,ValidationError:()=>f});var It=class r{static DEFAULT_NAME=Xt;name;#t;constructor({name:t=process.env[te]??r.DEFAULT_NAME,key:e=process.env[Zt]}={}){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 Ft=class{#t;constructor({token:t=process.env[Qt]}={}){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 Ut=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 jt=Object.create;var Tt=Object.defineProperty;var Mt=Object.getOwnPropertyDescriptor;var Ht=Object.getOwnPropertyNames;var Dt=Object.getPrototypeOf,kt=Object.prototype.hasOwnProperty;var Ut=(o,t)=>{for(var e in t)Tt(o,e,{get:t[e],enumerable:!0})},Et=(o,t,e,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of Ht(t))!kt.call(o,n)&&n!==e&&Tt(o,n,{get:()=>t[n],enumerable:!(r=Mt(t,n))||r.enumerable});return o};var St=(o,t,e)=>(e=o!=null?jt(Dt(o)):{},Et(t||!o||!o.__esModule?Tt(e,"default",{value:o,enumerable:!0}):e,o)),Vt=o=>Et(Tt({},"__esModule",{value:!0}),o);var Kt={};Ut(Kt,{Client:()=>h,DEFAULT_SUPPORT_BASE_URL:()=>_t,Error:()=>Ft,KeyAuthentication:()=>Rt,PublicAuthentication:()=>bt,TokenAuthentication:()=>gt,default:()=>h});module.exports=Vt(Kt);var _t="https://api.support.greatdetail.com",wt={"X-Powered-By":"GDSupport/JavaScript"},qt="api-key";var C=class{constructor(t){this._transport=t}async send({request:t={}}={}){return this._transport.send("v1/actions",{...t,method:"GET"})}};var y=class{constructor(t){this._transport=t}async send({body:t,request:e={}}){return this._transport.send("v1/boilerplates",{...e,method:"POST",headers:{...e.headers,"Content-Type":"application/json"},json:t})}};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 R=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 g=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 b=class{constructor(t){this._transport=t}async send({id:t,body:e,request:r={}}){return this._transport.send("v1/boilerplates/"+encodeURIComponent(t),{...r,method:"PATCH",headers:{...r.headers,"Content-Type":"application/json"},json:e})}};var T=class{constructor(t){this._transport=t}async send({body:t,request:e={}}){return this._transport.send("v1/boilerplate-categories",{...e,method:"POST",headers:{...e.headers,"Content-Type":"application/json"},json:t})}};var _=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 O=class{constructor(t){this._transport=t}async send({include:t,request:e={}}={}){return this._transport.send("v1/boilerplate-categories",{...e,method:"GET",searchParams:[...this._transport.includeQuery(t??{})]})}};var v=class{constructor(t){this._transport=t}async send({id:t,body:e,request:r={}}){return this._transport.send("v1/boilerplate-categories/"+encodeURIComponent(t),{...r,method:"PATCH",headers:{...r.headers,"Content-Type":"application/json"},json:e})}};var F=class{constructor(t){this._transport=t}async send({body:t,request:e={}}){return this._transport.send("v1/channels",{...e,method:"POST",headers:{...e.headers,"Content-Type":"application/json"},json: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 U=class{constructor(t){this._transport=t}async send({request:t={}}={}){return this._transport.send("v1/channels",{...t,method:"GET"})}};var vt=require("zod"),E=class o{constructor(t){this._transport=t}static SCHEMA=vt.z.object({overwrite:vt.z.boolean().optional()});async send({id:t,body:e,request:r={}}){return this._transport.send("v1/sources/twilio-sendgrid/channels/"+encodeURIComponent(t)+"/sync",{...r,method:"POST",headers:{...r.headers,"Content-Type":"application/json"},json:o.SCHEMA.parse(e)})}};var S=class{constructor(t){this._transport=t}async send({id:t,body:e,request:r={}}){return this._transport.send("v1/channels/"+encodeURIComponent(t),{...r,method:"PATCH",headers:{...r.headers,"Content-Type":"application/json"},json:e})}};var w=class{constructor(t){this._transport=t}async send({body:t,request:e={}}){return this._transport.send("v1/composition-sections",{...e,method:"POST",headers:{...e.headers,"Content-Type":"application/json"},json:t})}};var q=class{constructor(t){this._transport=t}async send({id:t,request:e={}}){return this._transport.send("v1/composition-sections/"+encodeURIComponent(t),{...e,method:"GET"})}};var L=class{constructor(t){this._transport=t}async send({id:t,request:e={}}){return this._transport.send("v1/channels/"+encodeURIComponent(t)+"/composition-sections",{...e,method:"GET"})}};var A=class{constructor(t){this._transport=t}async send({request:t={}}={}){return this._transport.send("v1/composition-sections",{...t,method:"GET"})}};var P=class{constructor(t){this._transport=t}async send({id:t,body:e,request:r={}}){return this._transport.send("v1/composition-sections/"+encodeURIComponent(t),{...r,method:"PATCH",headers:{...r.headers,"Content-Type":"application/json"},json:e})}};var Lt="SUPPORT_ACCESS_TOKEN",At="SUPPORT_API_KEY",Pt="SUPPORT_KEY_NAME",Nt="SUPPORT_BASE_URL";var N=class{constructor(t){this._transport=t}getRelativeURL({id:t,vcf:e={}}){let r=e.variant??"vcard",n=e.format??(e.variant==="vcard"?"vcf":"json");return"v1/contacts/"+encodeURIComponent(t)+"/vcf?variant="+encodeURIComponent(r)+"&format="+encodeURIComponent(n)}getURL(t){return this._transport.getURL(this.getRelativeURL(t))}};var B=class{constructor(t){this._transport=t}async send({body:t,request:e={}}){return this._transport.send("v1/contacts",{...e,method:"POST",headers:{...e.headers,"Content-Type":"application/json"},json:t})}};var G=class{constructor(t){this._transport=t}async send({id:t,include:e,request:r={}}){return this._transport.send("v1/contacts/"+encodeURIComponent(t),{...r,method:"GET",searchParams:[...this._transport.includeQuery(e??{})]})}};var j=class{constructor(t){this._transport=t}async send({request:t={}}={}){return this._transport.send("v1/contacts",{...t,method:"GET"})}};var M=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 H=class{constructor(t){this._transport=t}async send({id:t,body:e,request:r={}}){return this._transport.send("v1/contacts/"+encodeURIComponent(t),{...r,method:"PATCH",headers:{...r.headers,"Content-Type":"application/json"},json:e})}};var D=class{constructor(t){this._transport=t}async send({id:t,include:e,request:r={}}){return this._transport.send("v1/conversations/"+encodeURIComponent(t),{...r,method:"GET",searchParams:[...this._transport.includeQuery(e??{})]})}};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 V=class{constructor(t){this._transport=t}async send({filter:t,include:e,request:r={}}={}){return this._transport.send("v1/conversations",{...r,method:"GET",searchParams:[...t?[["filter",t]]:[],...this._transport.includeQuery(e??{})]})}};var K=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 z=class{constructor(t){this._transport=t}async send({id:t,body:e,request:r={}}){return this._transport.send("v1/conversations/"+encodeURIComponent(t),{...r,method:"PATCH",headers:{...r.headers,"Content-Type":"application/json"},json:e})}};var Q=class{constructor(t){this._transport=t}async send({body:t,request:e={}}){return this._transport.send("v1/labels",{...e,method:"POST",headers:{...e.headers,"Content-Type":"application/json"},json: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 W=class{constructor(t){this._transport=t}async send({include:t,request:e={}}={}){return this._transport.send("v1/labels",{...e,method:"GET",searchParams:[...this._transport.includeQuery(t??{})]})}};var J=class{constructor(t){this._transport=t}async send({id:t,body:e,request:r={}}){return this._transport.send("v1/labels/"+encodeURIComponent(t),{...r,method:"PATCH",headers:{...r.headers,"Content-Type":"application/json"},json:e})}};var X=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 Z=class{constructor(t){this._transport=t}async send({id:t,include:e,request:r={}}){return this._transport.send("v1/conversations/"+encodeURIComponent(t)+"/messages",{...r,method:"GET",searchParams:[...this._transport.includeQuery(e??{})]})}};var tt=class{constructor(t){this._transport=t}async send({request:t={}}={}){return this._transport.send("v1/messages",{...t,method:"GET"})}};var et=class{constructor(t){this._transport=t}async send({id:t,body:e,request:r={}}){return this._transport.send("v1/models/"+encodeURIComponent(t)+"/correction",{...r,method:"POST",headers:{...r.headers,"Content-Type":"application/json"},json: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 rt=class{constructor(t){this._transport=t}async send({request:t={}}={}){return this._transport.send("v1/models",{...t,method:"GET"})}};var nt=class{constructor(t){this._transport=t}async send({id:t,body:e,request:r={}}){return this._transport.send("v1/models/"+encodeURIComponent(t)+"/response",{...r,method:"POST",headers:{...r.headers,"Content-Type":"application/json"},json:e})}};var st=class{constructor(t){this._transport=t}async send({id:t,body:e,request:r={}}){return this._transport.send("v1/contacts/"+encodeURIComponent(t)+"/notes",{...r,method:"POST",headers:{...r.headers,"Content-Type":"application/json"},json:e})}};var m=class{constructor(t){this._transport=t}async send({id:t,body:e,request:r={}}){return this._transport.send("v1/conversations/"+encodeURIComponent(t)+"/notes",{...r,method:"POST",headers:{...r.headers,"Content-Type":"application/json"},json:e})}};var pt=class{constructor(t){this._transport=t}async send({id:t,request:e={}}){return this._transport.send("v1/notes/"+encodeURIComponent(t),{...e,method:"GET"})}};var at=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 it=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 ct=class{constructor(t){this._transport=t}async send({id:t,body:e,request:r={}}){return this._transport.send("v1/notes/"+encodeURIComponent(t),{...r,method:"PATCH",headers:{...r.headers,"Content-Type":"application/json"},json:e})}};var dt=class{constructor(t){this._transport=t}async send({id:t,body:e,request:r={}}){return this._transport.send("v1/contacts/"+encodeURIComponent(t)+"/notification-subscriptions",{...r,method:"POST",headers:{...r.headers,"Content-Type":"application/json"},json:e})}};var lt=class o{constructor(t=o.STANDARD_HEADERS){this._standardHeaders=t}static STANDARD_HEADERS=wt;async filter(){return{headers:this.getHeaders()}}getHeaders(){return this._standardHeaders}};var ut=class{constructor(t){this._transport=t}async send({id:t,request:e={}}){return this._transport.send("v1/sources/"+encodeURIComponent(t),{...e,method:"GET"})}};var mt=class{constructor(t){this._transport=t}async send({category:t,request:e={}}={}){let r=[];if(t){let n=Array.isArray(t)?t:[t];for(let f of n)r.push(["category",f])}return this._transport.send("v1/sources",{...e,method:"GET",searchParams:r})}};var Bt=St(require("is-network-error"),1),Ot=St(require("ky"),1);var s=class extends Error{static serverError(t){return new this("Server Error: "+t)}};var i=class extends s{};var d=class extends i{static unauthenticated(){return new this("An unauthenticated request occurred")}};var l=class extends i{static forbidden(){return new this("A forbidden request occurred")}};var a=class extends s{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}`)}static teapot(){return new this("I'm a teapot")}static rateLimited(){return new this("Request has been rate-limited")}};var u=class extends s{};var c=class extends s{static badRequest(){return new this("Bad request")}static unsupportedMediaType(){return new this("Unsupported Media Type")}};var ht=class{client;options;constructor({baseURL:t,...e}){this.options={...e,baseURL:t},this.client=Ot.default.create({prefixUrl:this.options.baseURL,hooks:{beforeRequest:[r=>{for(let n of this.options.requestFilterables){let f=n.getHeaders();for(let[It,Gt]of Object.entries(f))r.headers.has(It)||r.headers.set(It,Gt)}}]}})}getURL(t){return new URL(t,this.options.baseURL).toString()}includeQuery(t){let e=[];for(let r of Object.keys(t))e.push(["include",r]);return e}async send(t,e){return await this.client(t,e).catch(r=>{if((0,Bt.default)(r))throw new u("A network error occurred",{cause:r});if(r instanceof Ot.HTTPError){let n=r.response.status;switch(console.error(JSON.stringify(r.response)),n){case 400:throw c.badRequest();case 401:throw d.unauthenticated();case 403:throw l.forbidden();case 404:throw a.notFound(t);case 405:throw a.forbiddenMethod(t,e.method??"GET");case 415:throw c.unsupportedMediaType();case 418:throw a.teapot();case 429:throw a.rateLimited()}if(n>=500&&n<600)throw s.serverError(n)}throw r})}};var ft=class{constructor(t){this._transport=t}async send({account:t,files:e,request:r={}}){let n=new FormData;for(let f of e)n.append("file",f);return this._transport.send("v1/uploads",{...r,method:"POST",body:n,searchParams:{account:t}})}};var Ct=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 o{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}=o.SCHEMA.parse(t.body);return{event:e}}};var h=class o{static DEFAULT_BASE_URL=_t;_transport;constructor(t,{baseURL:e,...r}={}){this._transport=new ht({requestFilterables:[new lt,t],...r,baseURL:e?.toString()??o.getBaseURL()})}static getBaseURL(){return process.env[Nt]??this.DEFAULT_BASE_URL}get action(){return{list:new C(this._transport)}}get boilerplate(){return{get:new x(this._transport),list:new g(this._transport),update:new b(this._transport),create:new y(this._transport)}}get boilerplateCategory(){return{get:new _(this._transport),list:new O(this._transport),create:new T(this._transport),update:new v(this._transport),boilerplate:{list:new R(this._transport)}}}get channel(){return{get:new I(this._transport),list:new U(this._transport),update:new S(this._transport),create:new F(this._transport),compositionSection:{list:new L(this._transport)},message:{list:new X(this._transport)},twilioSendgrid:{sync:new E(this._transport)}}}get compositionSection(){return{get:new q(this._transport),list:new A(this._transport),create:new w(this._transport),update:new P(this._transport)}}get contact(){return{get:new G(this._transport),list:new j(this._transport),update:new H(this._transport),create:new B(this._transport),conversation:{list:new k(this._transport)},note:{list:new at(this._transport),create:new st(this._transport)},notificationSubscription:{create:new dt(this._transport)},vcf:{get:new N(this._transport)}}}get conversation(){return{get:new D(this._transport),list:new V(this._transport),update:new z(this._transport),create:new m(this._transport),message:{list:new Z(this._transport)},note:{list:new it(this._transport),create:new m(this._transport)}}}get label(){return{create:new Q(this._transport),get:new $(this._transport),list:new W(this._transport),update:new J(this._transport),delete:new Y(this._transport),contact:{list:new M(this._transport)},conversation:{list:new K(this._transport)}}}get message(){return{list:new tt(this._transport)}}get model(){return{get:new ot(this._transport),list:new rt(this._transport),response:{create:new nt(this._transport)},correction:{create:new et(this._transport)}}}get note(){return{get:new pt(this._transport),update:new ct(this._transport)}}get source(){return{get:new ut(this._transport),list:new mt(this._transport)}}get upload(){return{get:new yt(this._transport),create:new ft(this._transport),delete:new Ct(this._transport)}}get webhook(){return new xt(this)}};var Ft={};Ut(Ft,{AuthError:()=>i,AuthenticationError:()=>d,AuthorizationError:()=>l,LogicError:()=>a,NetworkError:()=>u,SupportError:()=>s,ValidationError:()=>c});var Rt=class o{static DEFAULT_NAME=qt;name;#t;constructor({name:t=process.env[Pt]??o.DEFAULT_NAME,key:e=process.env[At]}={}){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 gt=class{#t;constructor({token:t=process.env[Lt]}={}){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 bt=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-B76Jqu_N.cjs';
2
- export { C as Client, e as CreateBoilerplateCategoryResponse, b as CreateBoilerplateResponse, l as CreateChannelResponse, o as CreateCompositionSectionResponse, V as CreateContactNoteResponse, a2 as CreateContactNotificationSubscriptionResponse, r as CreateContactResponse, X as CreateConversationNoteResponse, Q as CreateCorrectionResponse, D as CreateLabelResponse, S as CreateResponseResponse, a3 as CreateUploadResponse, E as DeleteLabelResponse, a5 as DeleteUploadResponse, f as GetBoilerplateCategoryResponse, G as GetBoilerplateResponse, j as GetChannelResponse, m as GetCompositionSectionResponse, s as GetContactResponse, w as GetConversationResponse, F as GetLabelResponse, N as GetModelResponse, Y as GetNoteResponse, a0 as GetSourceResponse, a4 as GetUploadResponse, L as ListActionsResponse, g as ListBoilerplateCategoriesResponse, c as ListBoilerplateCategoryBoilerplatesResponse, d as ListBoilerplatesResponse, p as ListChannelCompositionSectionsResponse, M as ListChannelMessagesResponse, i as ListChannelsResponse, n as ListCompositionSectionsResponse, B as ListContactConversationsResponse, Z as ListContactNotesResponse, t as ListContactsResponse, J as ListConversationMessagesResponse, _ as ListConversationNotesResponse, x as ListConversationsResponse, u as ListLabelContactsResponse, y as ListLabelConversationsResponse, H as ListLabelsResponse, K as ListMessagesResponse, P as ListModelsResponse, a1 as ListSourcesResponse, O as Options, R as RequestFilterable, a as TransportOptions, T as TwilioSendgridChannelSyncResponse, h as UpdateBoilerplateCategoryResponse, U as UpdateBoilerplateResponse, k as UpdateChannelResponse, q as UpdateCompositionSectionResponse, v as UpdateContactResponse, z as UpdateConversationResponse, I as UpdateLabelResponse, $ as UpdateNoteResponse, W as WebhookResponse, C as default } from './index-B76Jqu_N.cjs';
1
+ import { A as Authentication, a as Conversation } from './index-CoYBLOpO.cjs';
2
+ export { c as Action, B as Boilerplate, g as BoilerplateCategory, l as Channel, C as Client, q as CompositionSection, w as Contact, h as CreateBoilerplateCategoryResponse, d as CreateBoilerplateResponse, p as CreateChannelResponse, t as CreateCompositionSectionResponse, a5 as CreateContactNoteResponse, af as CreateContactNotificationSubscriptionResponse, x as CreateContactResponse, a6 as CreateConversationNoteResponse, a2 as CreateCorrectionResponse, N as CreateLabelResponse, a3 as CreateResponseResponse, ah as CreateUploadResponse, P as DeleteLabelResponse, aj as DeleteUploadResponse, i as GetBoilerplateCategoryResponse, G as GetBoilerplateResponse, n as GetChannelResponse, r as GetCompositionSectionResponse, y as GetContactResponse, F as GetConversationResponse, Q as GetLabelResponse, a0 as GetModelResponse, a7 as GetNoteResponse, ac as GetSourceResponse, ai as GetUploadResponse, M as Label, L as ListActionsResponse, j as ListBoilerplateCategoriesResponse, e as ListBoilerplateCategoryBoilerplatesResponse, f as ListBoilerplatesResponse, u as ListChannelCompositionSectionsResponse, _ as ListChannelMessagesResponse, m as ListChannelsResponse, s as ListCompositionSectionsResponse, K as ListContactConversationsResponse, a8 as ListContactNotesResponse, z as ListContactsResponse, Y as ListConversationMessagesResponse, a9 as ListConversationNotesResponse, H as ListConversationsResponse, D as ListLabelContactsResponse, I as ListLabelConversationsResponse, S as ListLabelsResponse, Z as ListMessagesResponse, a1 as ListModelsResponse, ad as ListSourcesResponse, X as Message, $ as Model, a4 as Note, ae as NotificationSubscription, O as Options, R as RequestFilterable, ab as Source, b as TransportOptions, T as TwilioSendgridChannelSyncResponse, k as UpdateBoilerplateCategoryResponse, U as UpdateBoilerplateResponse, o as UpdateChannelResponse, v as UpdateCompositionSectionResponse, E as UpdateContactResponse, J as UpdateConversationResponse, V as UpdateLabelResponse, aa as UpdateNoteResponse, ag as Upload, W as WebhookResponse, C as default } from './index-CoYBLOpO.cjs';
3
3
  import 'ky';
4
4
  import 'zod';
5
5
 
@@ -27,6 +27,7 @@ declare const DEFAULT_SUPPORT_BASE_URL = "https://api.support.greatdetail.com";
27
27
  * @see https://greatdetail.com
28
28
  */
29
29
  declare class SupportError extends Error {
30
+ static serverError(status: number): SupportError;
30
31
  }
31
32
 
32
33
  /**
@@ -90,6 +91,7 @@ declare class AuthorizationError extends AuthError {
90
91
 
91
92
  declare class ValidationError extends SupportError {
92
93
  static badRequest(): ValidationError;
94
+ static unsupportedMediaType(): ValidationError;
93
95
  }
94
96
 
95
97
  /**
@@ -104,6 +106,8 @@ declare class ValidationError extends SupportError {
104
106
  declare class LogicError extends SupportError {
105
107
  static notFound(url: string): LogicError;
106
108
  static forbiddenMethod(method: string, url: string): LogicError;
109
+ static teapot(): LogicError;
110
+ static rateLimited(): LogicError;
107
111
  }
108
112
 
109
113
  /**
@@ -214,17 +218,8 @@ declare class PublicAuthentication implements Authentication {
214
218
 
215
219
  type CreateConversationResponse = {
216
220
  data: {
217
- conversation: {
218
- id: string;
219
- name?: string;
220
- hasEnded: boolean;
221
- contacts: string[];
222
- status: "AwaitingContactConversationStatus" | "AwaitingAgentConversationStatus" | "ResolvedConversationStatus" | "ClosedConversationStatus";
223
- channel: string;
224
- createdAt: string;
225
- updatedAt: string;
226
- };
221
+ conversation: Conversation;
227
222
  };
228
223
  };
229
224
 
230
- export { type CreateConversationResponse, DEFAULT_SUPPORT_BASE_URL, index as Error, KeyAuthentication, PublicAuthentication, TokenAuthentication };
225
+ export { Conversation, type CreateConversationResponse, DEFAULT_SUPPORT_BASE_URL, index as Error, KeyAuthentication, PublicAuthentication, TokenAuthentication };
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { A as Authentication } from './index-B76Jqu_N.js';
2
- export { C as Client, e as CreateBoilerplateCategoryResponse, b as CreateBoilerplateResponse, l as CreateChannelResponse, o as CreateCompositionSectionResponse, V as CreateContactNoteResponse, a2 as CreateContactNotificationSubscriptionResponse, r as CreateContactResponse, X as CreateConversationNoteResponse, Q as CreateCorrectionResponse, D as CreateLabelResponse, S as CreateResponseResponse, a3 as CreateUploadResponse, E as DeleteLabelResponse, a5 as DeleteUploadResponse, f as GetBoilerplateCategoryResponse, G as GetBoilerplateResponse, j as GetChannelResponse, m as GetCompositionSectionResponse, s as GetContactResponse, w as GetConversationResponse, F as GetLabelResponse, N as GetModelResponse, Y as GetNoteResponse, a0 as GetSourceResponse, a4 as GetUploadResponse, L as ListActionsResponse, g as ListBoilerplateCategoriesResponse, c as ListBoilerplateCategoryBoilerplatesResponse, d as ListBoilerplatesResponse, p as ListChannelCompositionSectionsResponse, M as ListChannelMessagesResponse, i as ListChannelsResponse, n as ListCompositionSectionsResponse, B as ListContactConversationsResponse, Z as ListContactNotesResponse, t as ListContactsResponse, J as ListConversationMessagesResponse, _ as ListConversationNotesResponse, x as ListConversationsResponse, u as ListLabelContactsResponse, y as ListLabelConversationsResponse, H as ListLabelsResponse, K as ListMessagesResponse, P as ListModelsResponse, a1 as ListSourcesResponse, O as Options, R as RequestFilterable, a as TransportOptions, T as TwilioSendgridChannelSyncResponse, h as UpdateBoilerplateCategoryResponse, U as UpdateBoilerplateResponse, k as UpdateChannelResponse, q as UpdateCompositionSectionResponse, v as UpdateContactResponse, z as UpdateConversationResponse, I as UpdateLabelResponse, $ as UpdateNoteResponse, W as WebhookResponse, C as default } from './index-B76Jqu_N.js';
1
+ import { A as Authentication, a as Conversation } from './index-CoYBLOpO.js';
2
+ export { c as Action, B as Boilerplate, g as BoilerplateCategory, l as Channel, C as Client, q as CompositionSection, w as Contact, h as CreateBoilerplateCategoryResponse, d as CreateBoilerplateResponse, p as CreateChannelResponse, t as CreateCompositionSectionResponse, a5 as CreateContactNoteResponse, af as CreateContactNotificationSubscriptionResponse, x as CreateContactResponse, a6 as CreateConversationNoteResponse, a2 as CreateCorrectionResponse, N as CreateLabelResponse, a3 as CreateResponseResponse, ah as CreateUploadResponse, P as DeleteLabelResponse, aj as DeleteUploadResponse, i as GetBoilerplateCategoryResponse, G as GetBoilerplateResponse, n as GetChannelResponse, r as GetCompositionSectionResponse, y as GetContactResponse, F as GetConversationResponse, Q as GetLabelResponse, a0 as GetModelResponse, a7 as GetNoteResponse, ac as GetSourceResponse, ai as GetUploadResponse, M as Label, L as ListActionsResponse, j as ListBoilerplateCategoriesResponse, e as ListBoilerplateCategoryBoilerplatesResponse, f as ListBoilerplatesResponse, u as ListChannelCompositionSectionsResponse, _ as ListChannelMessagesResponse, m as ListChannelsResponse, s as ListCompositionSectionsResponse, K as ListContactConversationsResponse, a8 as ListContactNotesResponse, z as ListContactsResponse, Y as ListConversationMessagesResponse, a9 as ListConversationNotesResponse, H as ListConversationsResponse, D as ListLabelContactsResponse, I as ListLabelConversationsResponse, S as ListLabelsResponse, Z as ListMessagesResponse, a1 as ListModelsResponse, ad as ListSourcesResponse, X as Message, $ as Model, a4 as Note, ae as NotificationSubscription, O as Options, R as RequestFilterable, ab as Source, b as TransportOptions, T as TwilioSendgridChannelSyncResponse, k as UpdateBoilerplateCategoryResponse, U as UpdateBoilerplateResponse, o as UpdateChannelResponse, v as UpdateCompositionSectionResponse, E as UpdateContactResponse, J as UpdateConversationResponse, V as UpdateLabelResponse, aa as UpdateNoteResponse, ag as Upload, W as WebhookResponse, C as default } from './index-CoYBLOpO.js';
3
3
  import 'ky';
4
4
  import 'zod';
5
5
 
@@ -27,6 +27,7 @@ declare const DEFAULT_SUPPORT_BASE_URL = "https://api.support.greatdetail.com";
27
27
  * @see https://greatdetail.com
28
28
  */
29
29
  declare class SupportError extends Error {
30
+ static serverError(status: number): SupportError;
30
31
  }
31
32
 
32
33
  /**
@@ -90,6 +91,7 @@ declare class AuthorizationError extends AuthError {
90
91
 
91
92
  declare class ValidationError extends SupportError {
92
93
  static badRequest(): ValidationError;
94
+ static unsupportedMediaType(): ValidationError;
93
95
  }
94
96
 
95
97
  /**
@@ -104,6 +106,8 @@ declare class ValidationError extends SupportError {
104
106
  declare class LogicError extends SupportError {
105
107
  static notFound(url: string): LogicError;
106
108
  static forbiddenMethod(method: string, url: string): LogicError;
109
+ static teapot(): LogicError;
110
+ static rateLimited(): LogicError;
107
111
  }
108
112
 
109
113
  /**
@@ -214,17 +218,8 @@ declare class PublicAuthentication implements Authentication {
214
218
 
215
219
  type CreateConversationResponse = {
216
220
  data: {
217
- conversation: {
218
- id: string;
219
- name?: string;
220
- hasEnded: boolean;
221
- contacts: string[];
222
- status: "AwaitingContactConversationStatus" | "AwaitingAgentConversationStatus" | "ResolvedConversationStatus" | "ClosedConversationStatus";
223
- channel: string;
224
- createdAt: string;
225
- updatedAt: string;
226
- };
221
+ conversation: Conversation;
227
222
  };
228
223
  };
229
224
 
230
- export { type CreateConversationResponse, DEFAULT_SUPPORT_BASE_URL, index as Error, KeyAuthentication, PublicAuthentication, TokenAuthentication };
225
+ export { Conversation, type CreateConversationResponse, DEFAULT_SUPPORT_BASE_URL, index as Error, KeyAuthentication, PublicAuthentication, TokenAuthentication };
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-AIPFHQNB.js";var E={};d(E,{AuthError:()=>m,AuthenticationError:()=>u,AuthorizationError:()=>c,LogicError:()=>x,NetworkError:()=>l,SupportError:()=>f,ValidationError:()=>h});var t=class e{static DEFAULT_NAME=a;name;#r;constructor({name:r=process.env[n]??e.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 o=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,o as TokenAuthentication,A as default};
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-AIEPNO2T.js";var E={};d(E,{AuthError:()=>m,AuthenticationError:()=>u,AuthorizationError:()=>c,LogicError:()=>x,NetworkError:()=>l,SupportError:()=>f,ValidationError:()=>h});var t=class e{static DEFAULT_NAME=a;name;#r;constructor({name:r=process.env[n]??e.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 o=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,o as TokenAuthentication,A as default};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@great-detail/support-sdk",
3
- "version": "0.7.6",
3
+ "version": "0.8.0",
4
4
  "type": "module",
5
5
  "description": "JavaScript SDK for the Great Detail Support System",
6
6
  "author": "Great Detail Ltd <info@greatdetail.com>",
@@ -74,7 +74,7 @@
74
74
  "cross-env": "^7.0.3",
75
75
  "eslint": "^9.12.0",
76
76
  "jest": "^29.7.0",
77
- "npm-run-all": "^4.1.5",
77
+ "npm-run-all2": "^6.0.0",
78
78
  "openapi-typescript": "^7.4.1",
79
79
  "prettier": "^3.3.3",
80
80
  "publint": "^0.2.11",
@@ -1 +0,0 @@
1
- var Kt=Object.defineProperty;var $t=(n,t)=>{for(var e in t)Kt(n,e,{get:t[e],enumerable:!0})};var wt=class{async filter(){return{headers:this.getHeaders()}}getHeaders(){return{}}};var Mt="https://api.support.greatdetail.com",jt={"X-Powered-By":"GDSupport/JavaScript"},Qt="api-key";import{z as a}from"zod";var m=class n{constructor(t){this._client=t}static SCHEMA=a.object({event:a.intersection(a.object({id:a.string(),createdAt:a.string().datetime()}),a.discriminatedUnion("type",[a.object({type:a.literal("contact.created"),contact:a.string()}),a.object({type:a.literal("message.created"),message:a.string()})]))});async event({request:t}){let{event:e}=n.SCHEMA.parse(t.body);return{event:e}}};var h=class{constructor(t){this._transport=t}async send({request:t={}}={}){return this._transport.send("v1/actions",{...t,method:"GET"})}};import{z as f}from"zod";var C=class n{constructor(t){this._transport=t}static SCHEMA=f.object({title:f.string(),content:f.string(),account:f.string(),boilerplateCategory:f.string()});async send({body:t,request:e={}}){return this._transport.send("v1/boilerplates",{...e,method:"POST",headers:{...e.headers,"Content-Type":"application/json"},json:n.SCHEMA.parse(t)})}};var b=class{constructor(t){this._transport=t}async send({id:t,request:e={}}){return this._transport.send("v1/boilerplates/"+encodeURIComponent(t),{...e,method:"GET"})}};var A=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 R=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 It}from"zod";var y=class n{constructor(t){this._transport=t}static SCHEMA=It.object({title:It.string().optional(),content:It.string().optional()});async send({id:t,body:e,request:r={}}){return this._transport.send("v1/boilerplates/"+encodeURIComponent(t),{...r,method:"PATCH",headers:{...r.headers,"Content-Type":"application/json"},json:n.SCHEMA.parse(e)})}};import{z as St}from"zod";var x=class n{constructor(t){this._transport=t}static SCHEMA=St.object({title:St.string(),description:St.string().optional(),account:St.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:n.SCHEMA.parse(t)})}};var T=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 S=class{constructor(t){this._transport=t}async send({include:t,request:e={}}={}){let r=[];for(let s of Object.keys(t??{}))r.push(["include",s]);return this._transport.send("v1/boilerplate-categories",{...e,method:"GET",searchParams:r})}};import{z as Ft}from"zod";var _=class n{constructor(t){this._transport=t}static SCHEMA=Ft.object({title:Ft.string().optional(),description:Ft.string().optional()});async send({id:t,body:e,request:r={}}){return this._transport.send("v1/boilerplate-categories/"+encodeURIComponent(t),{...r,method:"PATCH",headers:{...r.headers,"Content-Type":"application/json"},json:n.SCHEMA.parse(e)})}};import{z as o}from"zod";var v=class n{constructor(t){this._transport=t}static SCHEMA=o.intersection(o.object({name:o.string().optional(),account:o.string()}),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(),replyEmailAddress:o.string().optional(),inboundHostname:o.string(),apiKey:o.string()})})]));async send({body:t,request:e={}}){return this._transport.send("v1/channels",{...e,method:"POST",headers:{...e.headers,"Content-Type":"application/json"},json:n.SCHEMA.parse(t)})}};var E=class{constructor(t){this._transport=t}async send({id:t,request:e={}}){return this._transport.send("v1/channels/"+encodeURIComponent(t),{...e,method:"GET"})}};var O=class{constructor(t){this._transport=t}async send({request:t={}}={}){return this._transport.send("v1/channels",{...t,method:"GET"})}};import{z as Nt}from"zod";var w=class n{constructor(t){this._transport=t}static SCHEMA=Nt.object({overwrite:Nt.boolean().optional()});async send({id:t,body:e,request:r={}}){return this._transport.send("v1/sources/twilio-sendgrid/channels/"+encodeURIComponent(t)+"/sync",{...r,method:"POST",headers:{...r.headers,"Content-Type":"application/json"},json:n.SCHEMA.parse(e)})}};import{z as i}from"zod";var I=class n{constructor(t){this._transport=t}static SCHEMA=i.intersection(i.object({name:i.string().optional()}),i.discriminatedUnion("source",[i.object({source:i.literal("meta-whatsapp")}),i.object({source:i.literal("twilio-sendgrid"),twilioSendgrid:i.object({displayName:i.string().optional(),outboundEmailAddress:i.string().email().optional(),replyEmailAddress:i.string().optional(),inboundHostname:i.string().optional(),apiKey:i.string().optional()})})]));async send({id:t,body:e,request:r={}}){return this._transport.send("v1/channels/"+encodeURIComponent(t),{...r,method:"PATCH",headers:{...r.headers,"Content-Type":"application/json"},json:n.SCHEMA.parse(e)})}};import{z as F}from"zod";var U=class n{constructor(t){this._transport=t}static SCHEMA=F.object({account:F.string(),channel:F.string().optional(),location:F.enum(["header","footer"]),content:F.string()});async send({body:t,request:e={}}){return this._transport.send("v1/composition-sections",{...e,method:"POST",headers:{...e.headers,"Content-Type":"application/json"},json:n.SCHEMA.parse(t)})}};var q=class{constructor(t){this._transport=t}async send({id:t,request:e={}}){return this._transport.send("v1/composition-sections/"+encodeURIComponent(t),{...e,method:"GET"})}};var H=class{constructor(t){this._transport=t}async send({id:t,request:e={}}){return this._transport.send("v1/channels/"+encodeURIComponent(t)+"/composition-sections",{...e,method:"GET"})}};var L=class{constructor(t){this._transport=t}async send({request:t={}}={}){return this._transport.send("v1/composition-sections",{...t,method:"GET"})}};import{z as Gt}from"zod";var M=class n{constructor(t){this._transport=t}static SCHEMA=Gt.object({content:Gt.string()});async send({id:t,body:e,request:r={}}){return this._transport.send("v1/composition-sections/"+encodeURIComponent(t),{...r,method:"PATCH",headers:{...r.headers,"Content-Type":"application/json"},json:n.SCHEMA.parse(e)})}};var Fe="SUPPORT_ACCESS_TOKEN",Ue="SUPPORT_API_KEY",qe="SUPPORT_KEY_NAME",Pt="SUPPORT_BASE_URL";var j=class{constructor(t){this._transport=t}getRelativeURL({id:t,vcf:e={}}){let r=e.variant??"vcard",s=e.format??(e.variant==="vcard"?"vcf":"json");return"v1/contacts/"+encodeURIComponent(t)+"/vcf?variant="+encodeURIComponent(r)+"&format="+encodeURIComponent(s)}getURL(t){return this._transport.getURL(this.getRelativeURL(t))}};import{z as N}from"zod";var G=class n{constructor(t){this._transport=t}static SCHEMA=N.object({name:N.string(),account:N.string(),emailAddress:N.string().email().optional(),telephoneNumber:N.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:n.SCHEMA.parse(t)})}};var P=class{constructor(t){this._transport=t}async send({id:t,include:e,request:r={}}){let s=[];for(let p of Object.keys(e??{}))s.push(["include",p]);return this._transport.send("v1/contacts/"+encodeURIComponent(t),{...r,method:"GET",searchParams:s})}};var z=class{constructor(t){this._transport=t}async send({request:t={}}={}){return this._transport.send("v1/contacts",{...t,method:"GET"})}};var D=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 _t}from"zod";var B=class n{constructor(t){this._transport=t}static SCHEMA=_t.object({name:_t.string().optional(),emailAddress:_t.string().email().optional(),telephoneNumber:_t.string().optional()});async send({id:t,body:e,request:r={}}){return this._transport.send("v1/contacts/"+encodeURIComponent(t),{...r,method:"PATCH",headers:{...r.headers,"Content-Type":"application/json"},json:n.SCHEMA.parse(e)})}};var k=class{constructor(t){this._transport=t}async send({id:t,include:e,request:r={}}){let s=[];for(let p of Object.keys(e??{}))s.push(["include",p]);return this._transport.send("v1/conversations/"+encodeURIComponent(t),{...r,method:"GET",searchParams:s})}};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 V=class{constructor(t){this._transport=t}async send({filter:t,include:e,request:r={}}={}){let s=[];t&&s.push(["filter",t]);for(let p of Object.keys(e??{}))s.push(["include",p]);return this._transport.send("v1/conversations",{...r,method:"GET",searchParams:s})}};var W=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 Ut}from"zod";var Y=class n{constructor(t){this._transport=t}static SCHEMA=Ut.object({status:Ut.enum(["AwaitingContactConversationStatus","AwaitingAgentConversationStatus","ResolvedConversationStatus","ClosedConversationStatus"]).optional(),hasEnded:Ut.boolean().optional()});async send({id:t,body:e,request:r={}}){return this._transport.send("v1/conversations/"+encodeURIComponent(t),{...r,method:"PATCH",headers:{...r.headers,"Content-Type":"application/json"},json:n.SCHEMA.parse(e)})}};import{z as vt}from"zod";var $=class n{constructor(t){this._transport=t}static SCHEMA=vt.object({title:vt.string(),description:vt.string().optional(),account:vt.string()});async send({body:t,request:e={}}){return this._transport.send("v1/labels",{...e,method:"POST",headers:{...e.headers,"Content-Type":"application/json"},json:n.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({include:t,request:e={}}={}){let r=[];for(let s of Object.keys(t??{}))r.push(["include",s]);return this._transport.send("v1/labels",{...e,method:"GET",searchParams:r})}};import{z as qt}from"zod";var Z=class n{constructor(t){this._transport=t}static SCHEMA=qt.object({title:qt.string().optional(),description:qt.string().optional()});async send({id:t,body:e,request:r={}}){return this._transport.send("v1/labels/"+encodeURIComponent(t),{...r,method:"PATCH",headers:{...r.headers,"Content-Type":"application/json"},json:n.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 nt=class{constructor(t){this._transport=t}async send({request:t={}}={}){return this._transport.send("v1/messages",{...t,method:"GET"})}};import{z as Et}from"zod";var rt=class n{constructor(t){this._transport=t}static SCHEMA=Et.object({input:Et.string().max(65536),original:Et.string().max(65536),correction:Et.string().max(65536)});async send({id:t,body:e,request:r={}}){return this._transport.send("v1/models/"+encodeURIComponent(t)+"/correction",{...r,method:"POST",headers:{...r.headers,"Content-Type":"application/json"},json:n.SCHEMA.parse(e)})}};var st=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"})}};import{z as Ot}from"zod";var it=class n{constructor(t){this._transport=t}static SCHEMA=Ot.array(Ot.object({role:Ot.enum(["user","assistant"]),content:Ot.string().max(65536).nullable()})).min(1);async send({id:t,body:e,request:r={}}){return this._transport.send("v1/models/"+encodeURIComponent(t)+"/response",{...r,method:"POST",headers:{...r.headers,"Content-Type":"application/json"},json:n.SCHEMA.parse(e)})}};import{z as zt}from"zod";var at=class n{constructor(t){this._transport=t}static SCHEMA=zt.object({content:zt.string()});async send({id:t,body:e,request:r={}}){return this._transport.send("v1/contacts/"+encodeURIComponent(t)+"/notes",{...r,method:"POST",headers:{...r.headers,"Content-Type":"application/json"},json:n.SCHEMA.parse(e)})}};import{z as Dt}from"zod";var u=class n{constructor(t){this._transport=t}static SCHEMA=Dt.object({content:Dt.string()});async send({id:t,body:e,request:r={}}){return this._transport.send("v1/conversations/"+encodeURIComponent(t)+"/notes",{...r,method:"POST",headers:{...r.headers,"Content-Type":"application/json"},json:n.SCHEMA.parse(e)})}};var pt=class{constructor(t){this._transport=t}async send({id:t,request:e={}}){return this._transport.send("v1/notes/"+encodeURIComponent(t),{...e,method:"GET"})}};var ct=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 dt=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 Bt}from"zod";var lt=class n{constructor(t){this._transport=t}static SCHEMA=Bt.object({content:Bt.string().optional()});async send({id:t,body:e,request:r={}}){return this._transport.send("v1/notes/"+encodeURIComponent(t),{...r,method:"PATCH",headers:{...r.headers,"Content-Type":"application/json"},json:n.SCHEMA.parse(e)})}};import{z as d}from"zod";var ut=class n{constructor(t){this._transport=t}static SCHEMA=d.discriminatedUnion("type",[d.object({type:d.literal("vapid"),endpoint:d.string().url(),keys:d.object({p256dh:d.string(),auth:d.string()})})]);async send({id:t,body:e,request:r={}}){return this._transport.send("v1/contacts/"+encodeURIComponent(t)+"/notification-subscriptions",{...r,method:"POST",headers:{...r.headers,"Content-Type":"application/json"},json:n.SCHEMA.parse(e)})}};var gt=class n{constructor(t=n.STANDARD_HEADERS){this._standardHeaders=t}static STANDARD_HEADERS=jt;async filter(){return{headers:this.getHeaders()}}getHeaders(){return this._standardHeaders}};var mt=class{constructor(t){this._transport=t}async send({id:t,request:e={}}){return this._transport.send("v1/sources/"+encodeURIComponent(t),{...e,method:"GET"})}};var ht=class{constructor(t){this._transport=t}async send({category:t,request:e={}}={}){let r=[];if(t){let s=Array.isArray(t)?t:[t];for(let p of s)r.push(["category",p])}return this._transport.send("v1/sources",{...e,method:"GET",searchParams:r})}};import Vt from"is-network-error";import Wt,{HTTPError as Yt}from"ky";var c=class extends Error{};var l=class extends c{};var ft=class extends l{static unauthenticated(){return new this("An unauthenticated request occurred")}};var Ct=class extends l{static forbidden(){return new this("A forbidden request occurred")}};var g=class extends c{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 bt=class extends c{};var At=class extends c{static badRequest(){return new this("Bad request")}};var Rt=class{client;options;constructor({baseURL:t,...e}){this.options={...e,baseURL:t},this.client=Wt.create({prefixUrl:this.options.baseURL,hooks:{beforeRequest:[r=>{for(let s of this.options.requestFilterables){let p=s.getHeaders();for(let[Lt,kt]of Object.entries(p))r.headers.has(Lt)||r.headers.set(Lt,kt)}}]}})}getURL(t){return new URL(t,this.options.baseURL).toString()}async send(t,e){return await this.client(t,e).catch(r=>{if(Vt(r))throw new bt("A network error occurred",{cause:r});if(r instanceof Yt){let s=r.response.status;switch(console.error(JSON.stringify(r.response)),s){case 400:throw At.badRequest();case 401:throw ft.unauthenticated();case 403:throw Ct.forbidden();case 404:throw g.notFound(t);case 405:throw g.forbiddenMethod(t,e.method??"GET")}}throw r})}};var yt=class{constructor(t){this._transport=t}async send({account:t,files:e,request:r={}}){let s=new FormData;for(let p of e)s.append("file",p);return this._transport.send("v1/uploads",{...r,method:"POST",body:s,searchParams:{account:t}})}};var xt=class{constructor(t){this._transport=t}async send({id:t,request:e={}}){return this._transport.send("v1/uploads/"+encodeURIComponent(t),{...e,method:"DELETE"})}};var Tt=class{constructor(t){this._transport=t}async send({id:t,request:e={}}){return this._transport.send("v1/uploads/"+encodeURIComponent(t),{...e,method:"GET"})}};var Ht=class n{static DEFAULT_BASE_URL=Mt;_transport;constructor(t,{baseURL:e,...r}={}){this._transport=new Rt({requestFilterables:[new gt,t],...r,baseURL:e?.toString()??n.getBaseURL()})}static getBaseURL(){return process.env[Pt]??this.DEFAULT_BASE_URL}get action(){return{list:new h(this._transport)}}get boilerplate(){return{get:new b(this._transport),list:new R(this._transport),update:new y(this._transport),create:new C(this._transport)}}get boilerplateCategory(){return{get:new T(this._transport),list:new S(this._transport),create:new x(this._transport),update:new _(this._transport),boilerplate:{list:new A(this._transport)}}}get channel(){return{get:new E(this._transport),list:new O(this._transport),update:new I(this._transport),create:new v(this._transport),compositionSection:{list:new H(this._transport)},message:{list:new tt(this._transport)},twilioSendgrid:{sync:new w(this._transport)}}}get compositionSection(){return{get:new q(this._transport),list:new L(this._transport),create:new U(this._transport),update:new M(this._transport)}}get contact(){return{get:new P(this._transport),list:new z(this._transport),update:new B(this._transport),create:new G(this._transport),conversation:{list:new K(this._transport)},note:{list:new ct(this._transport),create:new at(this._transport)},notificationSubscription:{create:new ut(this._transport)},vcf:{get:new j(this._transport)}}}get conversation(){return{get:new k(this._transport),list:new V(this._transport),update:new Y(this._transport),create:new u(this._transport),message:{list:new et(this._transport)},note:{list:new dt(this._transport),create:new u(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 D(this._transport)},conversation:{list:new W(this._transport)}}}get message(){return{list:new nt(this._transport)}}get model(){return{get:new st(this._transport),list:new ot(this._transport),response:{create:new it(this._transport)},correction:{create:new rt(this._transport)}}}get note(){return{get:new pt(this._transport),update:new lt(this._transport)}}get source(){return{get:new mt(this._transport),list:new ht(this._transport)}}get upload(){return{get:new Tt(this._transport),create:new yt(this._transport),delete:new xt(this._transport)}}get webhook(){return new m(this)}};export{$t as a,wt as b,Fe as c,Ue as d,qe as e,Mt as f,Qt as g,c as h,l as i,ft as j,Ct as k,g as l,bt as m,At as n,Ht as o};