@great-detail/support-sdk 0.4.1 → 0.4.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-26EGNRYZ.js +1 -0
- package/dist/{chunk-2WFTGNNI.js → chunk-SBUYZAKJ.js} +1 -1
- 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-DCOax1hX.d.cts → index-17htgcwf.d.cts} +187 -88
- package/dist/{index-DCOax1hX.d.ts → index-17htgcwf.d.ts} +187 -88
- 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/src/Client/index.ts +5 -0
- package/src/Transport/FetchTransport.ts +0 -1
- package/src/Webhook/index.ts +67 -0
- package/dist/chunk-ILW336CI.js +0 -1
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var Nt=Object.create;var lt=Object.defineProperty;var Mt=Object.getOwnPropertyDescriptor;var Gt=Object.getOwnPropertyNames;var Bt=Object.getPrototypeOf,Pt=Object.prototype.hasOwnProperty;var _t=(r,t)=>{for(var e in t)lt(r,e,{get:t[e],enumerable:!0})},Et=(r,t,e,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of Gt(t))!Pt.call(r,n)&&n!==e&<(r,n,{get:()=>t[n],enumerable:!(s=Mt(t,n))||s.enumerable});return r};var St=(r,t,e)=>(e=r!=null?Nt(Bt(r)):{},Et(t||!r||!r.__esModule?lt(e,"default",{value:r,enumerable:!0}):e,r)),jt=r=>Et(lt({},"__esModule",{value:!0}),r);var zt={};_t(zt,{Client:()=>m,DEFAULT_SUPPORT_BASE_URL:()=>gt,Error:()=>xt,KeyAuthentication:()=>ct,PublicAuthentication:()=>ut,TokenAuthentication:()=>dt,default:()=>m});module.exports=jt(zt);var gt="https://api.support.greatdetail.com",vt={"X-Powered-By":"GDSupport/JavaScript"},Ot="api-key";var f=class{constructor(t){this._transport=t}async send({request:t={}}={}){return this._transport.send("v1/actions",{...t,method:"GET"})}};var h=require("zod"),b=class r{constructor(t){this._transport=t}static SCHEMA=h.z.object({title:h.z.string(),content:h.z.string(),account:h.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 C=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({request:t={}}={}){return this._transport.send("v1/boilerplates",{...t,method:"GET"})}};var mt=require("zod"),y=class r{constructor(t){this._transport=t}static SCHEMA=mt.z.object({title:mt.z.string().optional(),content:mt.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 x=require("zod"),T=class r{constructor(t){this._transport=t}static SCHEMA=x.z.object({title:x.z.string(),description:x.z.string().optional(),account:x.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 _=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 E=class{constructor(t){this._transport=t}async send({request:t={}}={}){return this._transport.send("v1/boilerplate-categories",{...t,method:"GET"})}};var ft=require("zod"),S=class r{constructor(t){this._transport=t}static SCHEMA=ft.z.object({title:ft.z.string().optional(),description:ft.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 v=class{constructor(t){this._transport=t}async send({request:t={}}={}){return this._transport.send("v1/channels",{...t,method:"GET"})}};var Ft="SUPPORT_ACCESS_TOKEN",Ut="SUPPORT_API_KEY",wt="SUPPORT_KEY_NAME",It="SUPPORT_BASE_URL";var O=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 l=require("zod"),F=class r{constructor(t){this._transport=t}static SCHEMA=l.z.object({name:l.z.string(),account:l.z.string(),emailAddress:l.z.string().email().optional(),telephoneNumber:l.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 U=class{constructor(t){this._transport=t}async send({id:t,request:e={}}){return this._transport.send("v1/contacts/"+encodeURIComponent(t),{...e,method:"GET"})}};var w=class{constructor(t){this._transport=t}async send({request:t={}}={}){return this._transport.send("v1/contacts",{...t,method:"GET"})}};var I=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 L=require("zod"),q=class r{constructor(t){this._transport=t}static SCHEMA=L.z.object({name:L.z.string().optional(),emailAddress:L.z.string().email().optional(),telephoneNumber:L.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 H=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 G=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 ht=require("zod"),B=class r{constructor(t){this._transport=t}static SCHEMA=ht.z.object({conversationStatus:ht.z.enum(["AwaitingContactConversationStatus","AwaitingAgentConversationStatus","ResolvedConversationStatus","ClosedConversationStatus"]).optional(),hasEnded:ht.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 P=require("zod"),j=class r{constructor(t){this._transport=t}static SCHEMA=P.z.object({title:P.z.string(),description:P.z.string().optional(),account:P.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 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 D=class{constructor(t){this._transport=t}async send({id:t,request:e={}}){return this._transport.send("v1/labels/"+encodeURIComponent(t),{...e,method:"GET"})}};var V=class{constructor(t){this._transport=t}async send({request:t={}}={}){return this._transport.send("v1/labels",{...t,method:"GET"})}};var bt=require("zod"),J=class r{constructor(t){this._transport=t}static SCHEMA=bt.z.object({title:bt.z.string().optional(),description:bt.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 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 k=class{constructor(t){this._transport=t}async send({request:t={}}={}){return this._transport.send("v1/messages",{...t,method:"GET"})}};var Y=require("zod"),$=class r{constructor(t){this._transport=t}static SCHEMA=Y.z.object({input:Y.z.string().max(65536),original:Y.z.string().max(65536),correction:Y.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 W=class{constructor(t){this._transport=t}async send({id:t,request:e={}}){return this._transport.send("v1/models/"+encodeURIComponent(t),{...e,method:"GET"})}};var X=class{constructor(t){this._transport=t}async send({request:t={}}={}){return this._transport.send("v1/models",{...t,method:"GET"})}};var Q=require("zod"),Z=class r{constructor(t){this._transport=t}static SCHEMA=Q.z.array(Q.z.object({role:Q.z.enum(["user","assistant"]),content:Q.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 At=require("zod"),tt=class r{constructor(t){this._transport=t}static SCHEMA=At.z.object({content:At.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 Rt=require("zod"),g=class r{constructor(t){this._transport=t}static SCHEMA=Rt.z.object({content:Rt.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 et=class{constructor(t){this._transport=t}async send({id:t,request:e={}}){return this._transport.send("v1/notes/"+encodeURIComponent(t),{...e,method:"GET"})}};var rt=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 st=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 yt=require("zod"),ot=class r{constructor(t){this._transport=t}static SCHEMA=yt.z.object({content:yt.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 nt=class r{constructor(t=r.STANDARD_HEADERS){this._standardHeaders=t}static STANDARD_HEADERS=vt;async filter(){return{headers:this.getHeaders()}}getHeaders(){return this._standardHeaders}};var it=class{constructor(t){this._transport=t}async send({id:t,request:e={}}){return this._transport.send("v1/sources/"+encodeURIComponent(t),{...e,method:"GET"})}};var at=class{constructor(t){this._transport=t}async send({request:t={}}={}){return this._transport.send("v1/sources",{...t,method:"GET"})}};var Lt=St(require("is-network-error"),1),Ct=St(require("ky"),1);var o=class extends Error{};var i=class extends o{};var p=class extends i{static unauthenticated(){return new this("An unauthenticated request occurred")}};var c=class extends i{static forbidden(){return new this("A forbidden request occurred")}};var a=class extends o{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 d=class extends o{};var u=class extends o{static badRequest(){return new this("Bad request")}};var pt=class{client;options;constructor({baseURL:t,...e}){this.options={...e,baseURL:t},this.client=Ct.default.create({prefixUrl:this.options.baseURL,hooks:{beforeRequest:[s=>{for(let n of this.options.requestFilterables){let qt=n.getHeaders();for(let[Tt,Ht]of Object.entries(qt))s.headers.has(Tt)||s.headers.set(Tt,Ht)}}]}})}getURL(t){return new URL(t,this.options.baseURL).toString()}async send(t,e){return await this.client(t,e).catch(s=>{if((0,Lt.default)(s))throw new d("A network error occurred",{cause:s});if(s instanceof Ct.HTTPError){let n=s.response.status;switch(console.error(JSON.stringify(s.response)),n){case 400:throw u.badRequest();case 401:throw p.unauthenticated();case 403:throw c.forbidden();case 404:throw a.notFound(t);case 405:throw a.forbiddenMethod(t,e.method??"GET")}}throw s})}};var m=class r{static DEFAULT_BASE_URL=gt;_transport;constructor(t,{baseURL:e,...s}={}){this._transport=new pt({requestFilterables:[new nt,t],...s,baseURL:e?.toString()??r.getBaseURL()})}static getBaseURL(){return process.env[It]??this.DEFAULT_BASE_URL}get action(){return{list:new f(this._transport)}}get boilerplate(){return{get:new C(this._transport),list:new R(this._transport),update:new y(this._transport)}}get boilerplateCategory(){return{get:new _(this._transport),list:new E(this._transport),create:new T(this._transport),update:new S(this._transport),boilerplate:{list:new A(this._transport),create:new b(this._transport)}}}get channel(){return{list:new v(this._transport)}}get contact(){return{get:new U(this._transport),list:new w(this._transport),update:new q(this._transport),create:new F(this._transport),conversation:{list:new N(this._transport)},note:{list:new rt(this._transport),create:new tt(this._transport)},vcf:{get:new O(this._transport)}}}get conversation(){return{get:new H(this._transport),list:new M(this._transport),update:new B(this._transport),create:new g(this._transport),message:{list:new K(this._transport)},note:{list:new st(this._transport),create:new g(this._transport)}}}get label(){return{create:new j(this._transport),get:new D(this._transport),list:new V(this._transport),update:new J(this._transport),delete:new z(this._transport),contact:{list:new I(this._transport)},conversation:{list:new G(this._transport)}}}get message(){return{list:new k(this._transport)}}get model(){return{get:new W(this._transport),list:new X(this._transport),response:{create:new Z(this._transport)},correction:{create:new $(this._transport)}}}get note(){return{get:new et(this._transport),update:new ot(this._transport)}}get source(){return{get:new it(this._transport),list:new at(this._transport)}}};var xt={};_t(xt,{AuthError:()=>i,AuthenticationError:()=>p,AuthorizationError:()=>c,LogicError:()=>a,NetworkError:()=>d,SupportError:()=>o,ValidationError:()=>u});var ct=class r{static DEFAULT_NAME=Ot;name;#t;constructor({name:t=process.env[wt]??r.DEFAULT_NAME,key:e=process.env[Ut]}={}){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 dt=class{#t;constructor({token:t=process.env[Ft]}={}){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 Gt=Object.create;var mt=Object.defineProperty;var Bt=Object.getOwnPropertyDescriptor;var jt=Object.getOwnPropertyNames;var Pt=Object.getPrototypeOf,zt=Object.prototype.hasOwnProperty;var St=(r,t)=>{for(var e in t)mt(r,e,{get:t[e],enumerable:!0})},vt=(r,t,e,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of jt(t))!zt.call(r,i)&&i!==e&&mt(r,i,{get:()=>t[i],enumerable:!(s=Bt(t,i))||s.enumerable});return r};var Ot=(r,t,e)=>(e=r!=null?Gt(Pt(r)):{},vt(t||!r||!r.__esModule?mt(e,"default",{value:r,enumerable:!0}):e,r)),Dt=r=>vt(mt({},"__esModule",{value:!0}),r);var Vt={};St(Vt,{Client:()=>f,DEFAULT_SUPPORT_BASE_URL:()=>ft,Error:()=>_t,KeyAuthentication:()=>ut,PublicAuthentication:()=>gt,TokenAuthentication:()=>lt,default:()=>f});module.exports=Dt(Vt);var ft="https://api.support.greatdetail.com",Ft={"X-Powered-By":"GDSupport/JavaScript"},wt="api-key";var h=class{constructor(t){this._transport=t}async send({request:t={}}={}){return this._transport.send("v1/actions",{...t,method:"GET"})}};var b=require("zod"),C=class r{constructor(t){this._transport=t}static SCHEMA=b.z.object({title:b.z.string(),content:b.z.string(),account:b.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 A=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 y=class{constructor(t){this._transport=t}async send({request:t={}}={}){return this._transport.send("v1/boilerplates",{...t,method:"GET"})}};var ht=require("zod"),x=class r{constructor(t){this._transport=t}static SCHEMA=ht.z.object({title:ht.z.string().optional(),content:ht.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 T=require("zod"),_=class r{constructor(t){this._transport=t}static SCHEMA=T.z.object({title:T.z.string(),description:T.z.string().optional(),account:T.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 E=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({request:t={}}={}){return this._transport.send("v1/boilerplate-categories",{...t,method:"GET"})}};var bt=require("zod"),v=class r{constructor(t){this._transport=t}static SCHEMA=bt.z.object({title:bt.z.string().optional(),description:bt.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 O=class{constructor(t){this._transport=t}async send({request:t={}}={}){return this._transport.send("v1/channels",{...t,method:"GET"})}};var Ut="SUPPORT_ACCESS_TOKEN",It="SUPPORT_API_KEY",Lt="SUPPORT_KEY_NAME",qt="SUPPORT_BASE_URL";var F=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 g=require("zod"),w=class r{constructor(t){this._transport=t}static SCHEMA=g.z.object({name:g.z.string(),account:g.z.string(),emailAddress:g.z.string().email().optional(),telephoneNumber:g.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 U=class{constructor(t){this._transport=t}async send({id:t,request:e={}}){return this._transport.send("v1/contacts/"+encodeURIComponent(t),{...e,method:"GET"})}};var I=class{constructor(t){this._transport=t}async send({request:t={}}={}){return this._transport.send("v1/contacts",{...t,method:"GET"})}};var L=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 q=require("zod"),H=class r{constructor(t){this._transport=t}static SCHEMA=q.z.object({name:q.z.string().optional(),emailAddress:q.z.string().email().optional(),telephoneNumber:q.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 N=class{constructor(t){this._transport=t}async send({id:t,request:e={}}){return this._transport.send("v1/conversations/"+encodeURIComponent(t),{...e,method:"GET"})}};var M=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 G=class{constructor(t){this._transport=t}async send({request:t={}}={}){return this._transport.send("v1/conversations",{...t,method:"GET"})}};var B=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 Ct=require("zod"),j=class r{constructor(t){this._transport=t}static SCHEMA=Ct.z.object({conversationStatus:Ct.z.enum(["AwaitingContactConversationStatus","AwaitingAgentConversationStatus","ResolvedConversationStatus","ClosedConversationStatus"]).optional(),hasEnded:Ct.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 P=require("zod"),z=class r{constructor(t){this._transport=t}static SCHEMA=P.z.object({title:P.z.string(),description:P.z.string().optional(),account:P.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 D=class{constructor(t){this._transport=t}async send({id:t,request:e={}}){return this._transport.send("v1/labels/"+encodeURIComponent(t),{...e,method:"DELETE"})}};var V=class{constructor(t){this._transport=t}async send({id:t,request:e={}}){return this._transport.send("v1/labels/"+encodeURIComponent(t),{...e,method:"GET"})}};var k=class{constructor(t){this._transport=t}async send({request:t={}}={}){return this._transport.send("v1/labels",{...t,method:"GET"})}};var At=require("zod"),J=class r{constructor(t){this._transport=t}static SCHEMA=At.z.object({title:At.z.string().optional(),description:At.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 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 Y=class{constructor(t){this._transport=t}async send({request:t={}}={}){return this._transport.send("v1/messages",{...t,method:"GET"})}};var $=require("zod"),W=class r{constructor(t){this._transport=t}static SCHEMA=$.z.object({input:$.z.string().max(65536),original:$.z.string().max(65536),correction:$.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 X=class{constructor(t){this._transport=t}async send({id:t,request:e={}}){return this._transport.send("v1/models/"+encodeURIComponent(t),{...e,method:"GET"})}};var Q=class{constructor(t){this._transport=t}async send({request:t={}}={}){return this._transport.send("v1/models",{...t,method:"GET"})}};var Z=require("zod"),tt=class r{constructor(t){this._transport=t}static SCHEMA=Z.z.array(Z.z.object({role:Z.z.enum(["user","assistant"]),content:Z.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 yt=require("zod"),et=class r{constructor(t){this._transport=t}static SCHEMA=yt.z.object({content:yt.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 xt=require("zod"),m=class r{constructor(t){this._transport=t}static SCHEMA=xt.z.object({content:xt.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 rt=class{constructor(t){this._transport=t}async send({id:t,request:e={}}){return this._transport.send("v1/notes/"+encodeURIComponent(t),{...e,method:"GET"})}};var st=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 nt=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 Tt=require("zod"),ot=class r{constructor(t){this._transport=t}static SCHEMA=Tt.z.object({content:Tt.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 it=class r{constructor(t=r.STANDARD_HEADERS){this._standardHeaders=t}static STANDARD_HEADERS=Ft;async filter(){return{headers:this.getHeaders()}}getHeaders(){return this._standardHeaders}};var at=class{constructor(t){this._transport=t}async send({id:t,request:e={}}){return this._transport.send("v1/sources/"+encodeURIComponent(t),{...e,method:"GET"})}};var pt=class{constructor(t){this._transport=t}async send({request:t={}}={}){return this._transport.send("v1/sources",{...t,method:"GET"})}};var Ht=Ot(require("is-network-error"),1),Rt=Ot(require("ky"),1);var n=class extends Error{};var a=class extends n{};var c=class extends a{static unauthenticated(){return new this("An unauthenticated request occurred")}};var d=class extends a{static forbidden(){return new this("A forbidden request occurred")}};var p=class extends n{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 u=class extends n{};var l=class extends n{static badRequest(){return new this("Bad request")}};var ct=class{client;options;constructor({baseURL:t,...e}){this.options={...e,baseURL:t},this.client=Rt.default.create({prefixUrl:this.options.baseURL,hooks:{beforeRequest:[s=>{for(let i of this.options.requestFilterables){let Nt=i.getHeaders();for(let[Et,Mt]of Object.entries(Nt))s.headers.has(Et)||s.headers.set(Et,Mt)}}]}})}getURL(t){return new URL(t,this.options.baseURL).toString()}async send(t,e){return await this.client(t,e).catch(s=>{if((0,Ht.default)(s))throw new u("A network error occurred",{cause:s});if(s instanceof Rt.HTTPError){let i=s.response.status;switch(console.error(JSON.stringify(s.response)),i){case 400:throw l.badRequest();case 401:throw c.unauthenticated();case 403:throw d.forbidden();case 404:throw p.notFound(t);case 405:throw p.forbiddenMethod(t,e.method??"GET")}}throw s})}};var o=require("zod"),dt=class r{constructor(t){this._client=t}static SCHEMA=o.z.object({event:o.z.intersection(o.z.object({id:o.z.string(),createdAt:o.z.string().datetime()}),o.z.discriminatedUnion("type",[o.z.object({type:o.z.literal("contact.created"),contact:o.z.string()}),o.z.object({type:o.z.literal("message.created"),message:o.z.string()})]))});async event({request:t}){let e=r.SCHEMA.parse(t.body);if(e.event.type==="contact.created"){let s=e.event.contact;return{body:e,related:async()=>({contact:await this._client.contact.get.send({id:s})})}}return{body:e}}};var f=class r{static DEFAULT_BASE_URL=ft;_transport;constructor(t,{baseURL:e,...s}={}){this._transport=new ct({requestFilterables:[new it,t],...s,baseURL:e?.toString()??r.getBaseURL()})}static getBaseURL(){return process.env[qt]??this.DEFAULT_BASE_URL}get action(){return{list:new h(this._transport)}}get boilerplate(){return{get:new A(this._transport),list:new y(this._transport),update:new x(this._transport)}}get boilerplateCategory(){return{get:new E(this._transport),list:new S(this._transport),create:new _(this._transport),update:new v(this._transport),boilerplate:{list:new R(this._transport),create:new C(this._transport)}}}get channel(){return{list:new O(this._transport)}}get contact(){return{get:new U(this._transport),list:new I(this._transport),update:new H(this._transport),create:new w(this._transport),conversation:{list:new M(this._transport)},note:{list:new st(this._transport),create:new et(this._transport)},vcf:{get:new F(this._transport)}}}get conversation(){return{get:new N(this._transport),list:new G(this._transport),update:new j(this._transport),create:new m(this._transport),message:{list:new K(this._transport)},note:{list:new nt(this._transport),create:new m(this._transport)}}}get label(){return{create:new z(this._transport),get:new V(this._transport),list:new k(this._transport),update:new J(this._transport),delete:new D(this._transport),contact:{list:new L(this._transport)},conversation:{list:new B(this._transport)}}}get message(){return{list:new Y(this._transport)}}get model(){return{get:new X(this._transport),list:new Q(this._transport),response:{create:new tt(this._transport)},correction:{create:new W(this._transport)}}}get note(){return{get:new rt(this._transport),update:new ot(this._transport)}}get source(){return{get:new at(this._transport),list:new pt(this._transport)}}get webhook(){return new dt(this)}};var _t={};St(_t,{AuthError:()=>a,AuthenticationError:()=>c,AuthorizationError:()=>d,LogicError:()=>p,NetworkError:()=>u,SupportError:()=>n,ValidationError:()=>l});var ut=class r{static DEFAULT_NAME=wt;name;#t;constructor({name:t=process.env[Lt]??r.DEFAULT_NAME,key:e=process.env[It]}={}){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 lt=class{#t;constructor({token:t=process.env[Ut]}={}){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 gt=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, H as CreateContactNoteResponse, j as CreateContactResponse, I as CreateConversationNoteResponse, E as CreateCorrectionResponse, t as CreateLabelResponse, F as CreateResponseResponse, D as DeleteLabelResponse, f as GetBoilerplateCategoryResponse, G as GetBoilerplateResponse, k as GetContactResponse, o as GetConversationResponse, u as GetLabelResponse, z as GetModelResponse, J as GetNoteResponse, P as GetSourceResponse, L as ListActionsResponse, g as ListBoilerplateCategoriesResponse, c as ListBoilerplateCategoryBoilerplatesResponse, d as ListBoilerplatesResponse, i as ListChannelsResponse, s as ListContactConversationsResponse, K as ListContactNotesResponse, l as ListContactsResponse, x as ListConversationMessagesResponse, M as ListConversationNotesResponse, p as ListConversationsResponse, m as ListLabelContactsResponse, q as ListLabelConversationsResponse, v as ListLabelsResponse, y as ListMessagesResponse, B as ListModelsResponse, Q as ListSourcesResponse, O as Options, R as RequestFilterable, a as TransportOptions, h as UpdateBoilerplateCategoryResponse, U as UpdateBoilerplateResponse, n as UpdateContactResponse, r as UpdateConversationResponse, w as UpdateLabelResponse, N as UpdateNoteResponse, C as default } from './index-
|
|
1
|
+
import { A as Authentication } from './index-17htgcwf.cjs';
|
|
2
|
+
export { C as Client, b as CreateBoilerplateCategoryBoilerplateResponse, e as CreateBoilerplateCategoryResponse, H as CreateContactNoteResponse, j as CreateContactResponse, I as CreateConversationNoteResponse, E as CreateCorrectionResponse, t as CreateLabelResponse, F as CreateResponseResponse, D as DeleteLabelResponse, f as GetBoilerplateCategoryResponse, G as GetBoilerplateResponse, k as GetContactResponse, o as GetConversationResponse, u as GetLabelResponse, z as GetModelResponse, J as GetNoteResponse, P as GetSourceResponse, L as ListActionsResponse, g as ListBoilerplateCategoriesResponse, c as ListBoilerplateCategoryBoilerplatesResponse, d as ListBoilerplatesResponse, i as ListChannelsResponse, s as ListContactConversationsResponse, K as ListContactNotesResponse, l as ListContactsResponse, x as ListConversationMessagesResponse, M as ListConversationNotesResponse, p as ListConversationsResponse, m as ListLabelContactsResponse, q as ListLabelConversationsResponse, v as ListLabelsResponse, y as ListMessagesResponse, B as ListModelsResponse, Q as ListSourcesResponse, O as Options, R as RequestFilterable, a as TransportOptions, h as UpdateBoilerplateCategoryResponse, U as UpdateBoilerplateResponse, n as UpdateContactResponse, r as UpdateConversationResponse, w as UpdateLabelResponse, N as UpdateNoteResponse, C as default } from './index-17htgcwf.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, H as CreateContactNoteResponse, j as CreateContactResponse, I as CreateConversationNoteResponse, E as CreateCorrectionResponse, t as CreateLabelResponse, F as CreateResponseResponse, D as DeleteLabelResponse, f as GetBoilerplateCategoryResponse, G as GetBoilerplateResponse, k as GetContactResponse, o as GetConversationResponse, u as GetLabelResponse, z as GetModelResponse, J as GetNoteResponse, P as GetSourceResponse, L as ListActionsResponse, g as ListBoilerplateCategoriesResponse, c as ListBoilerplateCategoryBoilerplatesResponse, d as ListBoilerplatesResponse, i as ListChannelsResponse, s as ListContactConversationsResponse, K as ListContactNotesResponse, l as ListContactsResponse, x as ListConversationMessagesResponse, M as ListConversationNotesResponse, p as ListConversationsResponse, m as ListLabelContactsResponse, q as ListLabelConversationsResponse, v as ListLabelsResponse, y as ListMessagesResponse, B as ListModelsResponse, Q as ListSourcesResponse, O as Options, R as RequestFilterable, a as TransportOptions, h as UpdateBoilerplateCategoryResponse, U as UpdateBoilerplateResponse, n as UpdateContactResponse, r as UpdateConversationResponse, w as UpdateLabelResponse, N as UpdateNoteResponse, C as default } from './index-
|
|
1
|
+
import { A as Authentication } from './index-17htgcwf.js';
|
|
2
|
+
export { C as Client, b as CreateBoilerplateCategoryBoilerplateResponse, e as CreateBoilerplateCategoryResponse, H as CreateContactNoteResponse, j as CreateContactResponse, I as CreateConversationNoteResponse, E as CreateCorrectionResponse, t as CreateLabelResponse, F as CreateResponseResponse, D as DeleteLabelResponse, f as GetBoilerplateCategoryResponse, G as GetBoilerplateResponse, k as GetContactResponse, o as GetConversationResponse, u as GetLabelResponse, z as GetModelResponse, J as GetNoteResponse, P as GetSourceResponse, L as ListActionsResponse, g as ListBoilerplateCategoriesResponse, c as ListBoilerplateCategoryBoilerplatesResponse, d as ListBoilerplatesResponse, i as ListChannelsResponse, s as ListContactConversationsResponse, K as ListContactNotesResponse, l as ListContactsResponse, x as ListConversationMessagesResponse, M as ListConversationNotesResponse, p as ListConversationsResponse, m as ListLabelContactsResponse, q as ListLabelConversationsResponse, v as ListLabelsResponse, y as ListMessagesResponse, B as ListModelsResponse, Q as ListSourcesResponse, O as Options, R as RequestFilterable, a as TransportOptions, h as UpdateBoilerplateCategoryResponse, U as UpdateBoilerplateResponse, n as UpdateContactResponse, r as UpdateConversationResponse, w as UpdateLabelResponse, N as UpdateNoteResponse, C as default } from './index-17htgcwf.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 n,e as a,f as p,g as f,h as m,i as u,j as c,k as l,l as x,m as A,n as h,o as _}from"./chunk-
|
|
1
|
+
import{a as d,b as g,c as s,d as n,e as a,f as p,g as f,h as m,i as u,j as c,k as l,l as x,m as A,n as h,o as _}from"./chunk-26EGNRYZ.js";var E={};d(E,{AuthError:()=>m,AuthenticationError:()=>u,AuthorizationError:()=>c,LogicError:()=>l,NetworkError:()=>x,SupportError:()=>f,ValidationError:()=>A});var t=class o{static DEFAULT_NAME=s;name;#r;constructor({name:r=process.env[p]??o.DEFAULT_NAME,key:i=process.env[a]}={}){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[n]}={}){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{h as Client,g as DEFAULT_SUPPORT_BASE_URL,E as Error,t as KeyAuthentication,_ as PublicAuthentication,e as TokenAuthentication,h as default};
|
package/package.json
CHANGED
package/src/Client/index.ts
CHANGED
|
@@ -53,6 +53,7 @@ import RequestStandardHeaders from "../Request/RequestStandardHeaders.js";
|
|
|
53
53
|
import GetSource from "../Source/GetSource.js";
|
|
54
54
|
import ListSources from "../Source/ListSources.js";
|
|
55
55
|
import FetchTransport from "../Transport/FetchTransport.js";
|
|
56
|
+
import Webhook from "../Webhook/index.js";
|
|
56
57
|
|
|
57
58
|
export interface Options {
|
|
58
59
|
baseURL?: string | URL;
|
|
@@ -194,4 +195,8 @@ export default class Client {
|
|
|
194
195
|
list: new ListSources(this._transport),
|
|
195
196
|
};
|
|
196
197
|
}
|
|
198
|
+
|
|
199
|
+
public get webhook() {
|
|
200
|
+
return new Webhook(this);
|
|
201
|
+
}
|
|
197
202
|
}
|
|
@@ -62,7 +62,6 @@ export default class FetchTransport implements Transport {
|
|
|
62
62
|
}
|
|
63
63
|
|
|
64
64
|
public async send<T = unknown>(url: string, request: RequestInit) {
|
|
65
|
-
// See: https://github.com/node-fetch/node-fetch/issues/481#issuecomment-592491825
|
|
66
65
|
return await this.client<T>(url, request).catch((error) => {
|
|
67
66
|
if (isNetworkError(error)) {
|
|
68
67
|
throw new NetworkError("A network error occurred", { cause: error });
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Great Detail Support System.
|
|
3
|
+
*
|
|
4
|
+
* @copyright 2024 Great Detail Ltd
|
|
5
|
+
* @author Great Detail Ltd <info@greatdetail.com>
|
|
6
|
+
* @author Dom Webber <dom.webber@greatdetail.com>
|
|
7
|
+
* @see https://greatdetail.com
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import { z } from "zod";
|
|
11
|
+
import Client from "../Client/index.js";
|
|
12
|
+
|
|
13
|
+
export type Options = {
|
|
14
|
+
request: {
|
|
15
|
+
body: unknown;
|
|
16
|
+
headers: Record<string, string | string[]>;
|
|
17
|
+
[key: string]: unknown | undefined;
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export default class Webhook {
|
|
22
|
+
public static SCHEMA = z.object({
|
|
23
|
+
event: z.intersection(
|
|
24
|
+
z.object({
|
|
25
|
+
id: z.string(),
|
|
26
|
+
createdAt: z.string().datetime(),
|
|
27
|
+
}),
|
|
28
|
+
z.discriminatedUnion("type", [
|
|
29
|
+
z.object({
|
|
30
|
+
type: z.literal("contact.created"),
|
|
31
|
+
contact: z.string(),
|
|
32
|
+
}),
|
|
33
|
+
z.object({
|
|
34
|
+
type: z.literal("message.created"),
|
|
35
|
+
message: z.string(),
|
|
36
|
+
}),
|
|
37
|
+
]),
|
|
38
|
+
),
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
constructor(protected _client: Client) {}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* @deprecated Pre-release Functionality
|
|
45
|
+
*/
|
|
46
|
+
public async event({ request }: Options) {
|
|
47
|
+
const body = Webhook.SCHEMA.parse(request.body);
|
|
48
|
+
|
|
49
|
+
if (body.event.type === "contact.created") {
|
|
50
|
+
const id = body.event.contact;
|
|
51
|
+
return {
|
|
52
|
+
body,
|
|
53
|
+
related: async () => {
|
|
54
|
+
return {
|
|
55
|
+
contact: await this._client.contact.get.send({
|
|
56
|
+
id,
|
|
57
|
+
}),
|
|
58
|
+
};
|
|
59
|
+
},
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
return {
|
|
64
|
+
body,
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
}
|
package/dist/chunk-ILW336CI.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var xt=Object.defineProperty;var Ot=(r,t)=>{for(var e in t)xt(r,e,{get:t[e],enumerable:!0})};var ht="https://api.support.greatdetail.com",ft={"X-Powered-By":"GDSupport/JavaScript"},Ft="api-key";var c=class{constructor(t){this._transport=t}async send({request:t={}}={}){return this._transport.send("v1/actions",{...t,method:"GET"})}};import{z as rt}from"zod";var d=class r{constructor(t){this._transport=t}static SCHEMA=rt.object({title:rt.string(),content:rt.string(),account:rt.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 l=class{constructor(t){this._transport=t}async send({id:t,request:e={}}){return this._transport.send("v1/boilerplates/"+encodeURIComponent(t),{...e,method:"GET"})}};var u=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({request:t={}}={}){return this._transport.send("v1/boilerplates",{...t,method:"GET"})}};import{z as pt}from"zod";var m=class r{constructor(t){this._transport=t}static SCHEMA=pt.object({title:pt.string().optional(),content:pt.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 st}from"zod";var h=class r{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"},body:JSON.stringify(r.SCHEMA.parse(t))})}};var f=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 C=class{constructor(t){this._transport=t}async send({request:t={}}={}){return this._transport.send("v1/boilerplate-categories",{...t,method:"GET"})}};import{z as ct}from"zod";var b=class r{constructor(t){this._transport=t}static SCHEMA=ct.object({title:ct.string().optional(),description:ct.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 R=class{constructor(t){this._transport=t}async send({request:t={}}={}){return this._transport.send("v1/channels",{...t,method:"GET"})}};var Kt="SUPPORT_ACCESS_TOKEN",kt="SUPPORT_API_KEY",Yt="SUPPORT_KEY_NAME",Ct="SUPPORT_BASE_URL";var A=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 y}from"zod";var T=class r{constructor(t){this._transport=t}static SCHEMA=y.object({name:y.string(),account:y.string(),emailAddress:y.string().email().optional(),telephoneNumber:y.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 x=class{constructor(t){this._transport=t}async send({id:t,request:e={}}){return this._transport.send("v1/contacts/"+encodeURIComponent(t),{...e,method:"GET"})}};var _=class{constructor(t){this._transport=t}async send({request:t={}}={}){return this._transport.send("v1/contacts",{...t,method:"GET"})}};var S=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 nt}from"zod";var v=class r{constructor(t){this._transport=t}static SCHEMA=nt.object({name:nt.string().optional(),emailAddress:nt.string().email().optional(),telephoneNumber:nt.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 O=class{constructor(t){this._transport=t}async send({id:t,request:e={}}){return this._transport.send("v1/conversations/"+encodeURIComponent(t),{...e,method:"GET"})}};var E=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 F=class{constructor(t){this._transport=t}async send({request:t={}}={}){return this._transport.send("v1/conversations",{...t,method:"GET"})}};var U=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 dt}from"zod";var w=class r{constructor(t){this._transport=t}static SCHEMA=dt.object({conversationStatus:dt.enum(["AwaitingContactConversationStatus","AwaitingAgentConversationStatus","ResolvedConversationStatus","ClosedConversationStatus"]).optional(),hasEnded:dt.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 ot}from"zod";var I=class r{constructor(t){this._transport=t}static SCHEMA=ot.object({title:ot.string(),description:ot.string().optional(),account:ot.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 q=class{constructor(t){this._transport=t}async send({id:t,request:e={}}){return this._transport.send("v1/labels/"+encodeURIComponent(t),{...e,method:"DELETE"})}};var L=class{constructor(t){this._transport=t}async send({id:t,request:e={}}){return this._transport.send("v1/labels/"+encodeURIComponent(t),{...e,method:"GET"})}};var H=class{constructor(t){this._transport=t}async send({request:t={}}={}){return this._transport.send("v1/labels",{...t,method:"GET"})}};import{z as lt}from"zod";var M=class r{constructor(t){this._transport=t}static SCHEMA=lt.object({title:lt.string().optional(),description:lt.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 N=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 G=class{constructor(t){this._transport=t}async send({request:t={}}={}){return this._transport.send("v1/messages",{...t,method:"GET"})}};import{z as it}from"zod";var B=class r{constructor(t){this._transport=t}static SCHEMA=it.object({input:it.string().max(65536),original:it.string().max(65536),correction:it.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 j=class{constructor(t){this._transport=t}async send({id:t,request:e={}}){return this._transport.send("v1/models/"+encodeURIComponent(t),{...e,method:"GET"})}};var P=class{constructor(t){this._transport=t}async send({request:t={}}={}){return this._transport.send("v1/models",{...t,method:"GET"})}};import{z as at}from"zod";var z=class r{constructor(t){this._transport=t}static SCHEMA=at.array(at.object({role:at.enum(["user","assistant"]),content:at.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 bt}from"zod";var D=class r{constructor(t){this._transport=t}static SCHEMA=bt.object({content:bt.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 Rt}from"zod";var i=class r{constructor(t){this._transport=t}static SCHEMA=Rt.object({content:Rt.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 J=class{constructor(t){this._transport=t}async send({id:t,request:e={}}){return this._transport.send("v1/notes/"+encodeURIComponent(t),{...e,method:"GET"})}};var V=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 K=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 At}from"zod";var k=class r{constructor(t){this._transport=t}static SCHEMA=At.object({content:At.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 Y=class r{constructor(t=r.STANDARD_HEADERS){this._standardHeaders=t}static STANDARD_HEADERS=ft;async filter(){return{headers:this.getHeaders()}}getHeaders(){return this._standardHeaders}};var $=class{constructor(t){this._transport=t}async send({id:t,request:e={}}){return this._transport.send("v1/sources/"+encodeURIComponent(t),{...e,method:"GET"})}};var W=class{constructor(t){this._transport=t}async send({request:t={}}={}){return this._transport.send("v1/sources",{...t,method:"GET"})}};import _t from"is-network-error";import St,{HTTPError as vt}from"ky";var n=class extends Error{};var o=class extends n{};var X=class extends o{static unauthenticated(){return new this("An unauthenticated request occurred")}};var Q=class extends o{static forbidden(){return new this("A forbidden request occurred")}};var a=class extends n{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 Z=class extends n{};var tt=class extends n{static badRequest(){return new this("Bad request")}};var et=class{client;options;constructor({baseURL:t,...e}){this.options={...e,baseURL:t},this.client=St.create({prefixUrl:this.options.baseURL,hooks:{beforeRequest:[s=>{for(let p of this.options.requestFilterables){let yt=p.getHeaders();for(let[mt,Tt]of Object.entries(yt))s.headers.has(mt)||s.headers.set(mt,Tt)}}]}})}getURL(t){return new URL(t,this.options.baseURL).toString()}async send(t,e){return await this.client(t,e).catch(s=>{if(_t(s))throw new Z("A network error occurred",{cause:s});if(s instanceof vt){let p=s.response.status;switch(console.error(JSON.stringify(s.response)),p){case 400:throw tt.badRequest();case 401:throw X.unauthenticated();case 403:throw Q.forbidden();case 404:throw a.notFound(t);case 405:throw a.forbiddenMethod(t,e.method??"GET")}}throw s})}};var ut=class r{static DEFAULT_BASE_URL=ht;_transport;constructor(t,{baseURL:e,...s}={}){this._transport=new et({requestFilterables:[new Y,t],...s,baseURL:e?.toString()??r.getBaseURL()})}static getBaseURL(){return process.env[Ct]??this.DEFAULT_BASE_URL}get action(){return{list:new c(this._transport)}}get boilerplate(){return{get:new l(this._transport),list:new g(this._transport),update:new m(this._transport)}}get boilerplateCategory(){return{get:new f(this._transport),list:new C(this._transport),create:new h(this._transport),update:new b(this._transport),boilerplate:{list:new u(this._transport),create:new d(this._transport)}}}get channel(){return{list:new R(this._transport)}}get contact(){return{get:new x(this._transport),list:new _(this._transport),update:new v(this._transport),create:new T(this._transport),conversation:{list:new E(this._transport)},note:{list:new V(this._transport),create:new D(this._transport)},vcf:{get:new A(this._transport)}}}get conversation(){return{get:new O(this._transport),list:new F(this._transport),update:new w(this._transport),create:new i(this._transport),message:{list:new N(this._transport)},note:{list:new K(this._transport),create:new i(this._transport)}}}get label(){return{create:new I(this._transport),get:new L(this._transport),list:new H(this._transport),update:new M(this._transport),delete:new q(this._transport),contact:{list:new S(this._transport)},conversation:{list:new U(this._transport)}}}get message(){return{list:new G(this._transport)}}get model(){return{get:new j(this._transport),list:new P(this._transport),response:{create:new z(this._transport)},correction:{create:new B(this._transport)}}}get note(){return{get:new J(this._transport),update:new k(this._transport)}}get source(){return{get:new $(this._transport),list:new W(this._transport)}}};var gt=class{async filter(){return{headers:this.getHeaders()}}getHeaders(){return{}}};export{Ot as a,ht as b,Ft as c,Kt as d,kt as e,Yt as f,n as g,o as h,X as i,Q as j,a as k,Z as l,tt as m,ut as n,gt as o};
|