@great-detail/support-sdk 0.4.5 → 0.4.7
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-23BXD6T5.js → chunk-K37WTNB5.js} +1 -1
- package/dist/{chunk-F67NJYPP.js → chunk-WMMLOVBE.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-CV2Xq9A0.d.cts → index-DNJOlCyr.d.cts} +136 -90
- package/dist/{index-CV2Xq9A0.d.ts → index-DNJOlCyr.d.ts} +136 -90
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var jt=Object.create;var ht=Object.defineProperty;var zt=Object.getOwnPropertyDescriptor;var Pt=Object.getOwnPropertyNames;var Dt=Object.getPrototypeOf,kt=Object.prototype.hasOwnProperty;var Ot=(r,t)=>{for(var e in t)ht(r,e,{get:t[e],enumerable:!0})},Ft=(r,t,e,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of Pt(t))!kt.call(r,i)&&i!==e&&ht(r,i,{get:()=>t[i],enumerable:!(s=zt(t,i))||s.enumerable});return r};var Ut=(r,t,e)=>(e=r!=null?jt(Dt(r)):{},Ft(t||!r||!r.__esModule?ht(e,"default",{value:r,enumerable:!0}):e,r)),Vt=r=>Ft(ht({},"__esModule",{value:!0}),r);var Jt={};Ot(Jt,{Client:()=>h,DEFAULT_SUPPORT_BASE_URL:()=>bt,Error:()=>St,KeyAuthentication:()=>gt,PublicAuthentication:()=>ft,TokenAuthentication:()=>mt,default:()=>h});module.exports=Vt(Jt);var bt="https://api.support.greatdetail.com",wt={"X-Powered-By":"GDSupport/JavaScript"},It="api-key";var b=class{constructor(t){this._transport=t}async send({request:t={}}={}){return this._transport.send("v1/actions",{...t,method:"GET"})}};var C=require("zod"),A=class r{constructor(t){this._transport=t}static SCHEMA=C.z.object({title:C.z.string(),content:C.z.string(),account:C.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 R=class{constructor(t){this._transport=t}async send({id:t,request:e={}}){return this._transport.send("v1/boilerplates/"+encodeURIComponent(t),{...e,method:"GET"})}};var y=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 x=class{constructor(t){this._transport=t}async send({request:t={}}={}){return this._transport.send("v1/boilerplates",{...t,method:"GET"})}};var Ct=require("zod"),T=class r{constructor(t){this._transport=t}static SCHEMA=Ct.z.object({title:Ct.z.string().optional(),content:Ct.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 _=require("zod"),E=class r{constructor(t){this._transport=t}static SCHEMA=_.z.object({title:_.z.string(),description:_.z.string().optional(),account:_.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 S=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 v=class{constructor(t){this._transport=t}async send({request:t={}}={}){return this._transport.send("v1/boilerplate-categories",{...t,method:"GET"})}};var At=require("zod"),O=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/boilerplate-categories/"+encodeURIComponent(t),{...s,method:"PATCH",headers:{...s.headers,"Content-Type":"application/json"},body:JSON.stringify(r.SCHEMA.parse(e))})}};var F=class{constructor(t){this._transport=t}async send({request:t={}}={}){return this._transport.send("v1/channels",{...t,method:"GET"})}};var Lt="SUPPORT_ACCESS_TOKEN",qt="SUPPORT_API_KEY",Ht="SUPPORT_KEY_NAME",Nt="SUPPORT_BASE_URL";var U=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 m=require("zod"),w=class r{constructor(t){this._transport=t}static SCHEMA=m.z.object({name:m.z.string(),account:m.z.string(),emailAddress:m.z.string().email().optional(),telephoneNumber:m.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 I=class{constructor(t){this._transport=t}async send({id:t,request:e={}}){return this._transport.send("v1/contacts/"+encodeURIComponent(t),{...e,method:"GET"})}};var L=class{constructor(t){this._transport=t}async send({request:t={}}={}){return this._transport.send("v1/contacts",{...t,method:"GET"})}};var q=class{constructor(t){this._transport=t}async send({id:t,request:e={}}){return this._transport.send("v1/labels/"+encodeURIComponent(t)+"/contacts",{...e,method:"GET"})}};var H=require("zod"),N=class r{constructor(t){this._transport=t}static SCHEMA=H.z.object({name:H.z.string().optional(),emailAddress:H.z.string().email().optional(),telephoneNumber:H.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 M=class{constructor(t){this._transport=t}async send({id:t,request:e={}}){return this._transport.send("v1/conversations/"+encodeURIComponent(t),{...e,method:"GET"})}};var G=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 B=class{constructor(t){this._transport=t}async send({request:t={}}={}){return this._transport.send("v1/conversations",{...t,method:"GET"})}};var j=class{constructor(t){this._transport=t}async send({id:t,request:e={}}){return this._transport.send("v1/labels/"+encodeURIComponent(t)+"/conversations",{...e,method:"GET"})}};var Rt=require("zod"),z=class r{constructor(t){this._transport=t}static SCHEMA=Rt.z.object({conversationStatus:Rt.z.enum(["AwaitingContactConversationStatus","AwaitingAgentConversationStatus","ResolvedConversationStatus","ClosedConversationStatus"]).optional(),hasEnded:Rt.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"),D=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 k=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 J=class{constructor(t){this._transport=t}async send({request:t={}}={}){return this._transport.send("v1/labels",{...t,method:"GET"})}};var yt=require("zod"),K=class r{constructor(t){this._transport=t}static SCHEMA=yt.z.object({title:yt.z.string().optional(),description:yt.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 Y=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 $=class{constructor(t){this._transport=t}async send({request:t={}}={}){return this._transport.send("v1/messages",{...t,method:"GET"})}};var W=require("zod"),X=class r{constructor(t){this._transport=t}static SCHEMA=W.z.object({input:W.z.string().max(65536),original:W.z.string().max(65536),correction:W.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 Q=class{constructor(t){this._transport=t}async send({id:t,request:e={}}){return this._transport.send("v1/models/"+encodeURIComponent(t),{...e,method:"GET"})}};var Z=class{constructor(t){this._transport=t}async send({request:t={}}={}){return this._transport.send("v1/models",{...t,method:"GET"})}};var tt=require("zod"),et=class r{constructor(t){this._transport=t}static SCHEMA=tt.z.array(tt.z.object({role:tt.z.enum(["user","assistant"]),content:tt.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 Tt=require("zod"),rt=class r{constructor(t){this._transport=t}static SCHEMA=Tt.z.object({content:Tt.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 _t=require("zod"),f=class r{constructor(t){this._transport=t}static SCHEMA=_t.z.object({content:_t.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 st=class{constructor(t){this._transport=t}async send({id:t,request:e={}}){return this._transport.send("v1/notes/"+encodeURIComponent(t),{...e,method:"GET"})}};var ot=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 Et=require("zod"),it=class r{constructor(t){this._transport=t}static SCHEMA=Et.z.object({content:Et.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 p=require("zod"),at=class r{constructor(t){this._transport=t}static SCHEMA=p.z.discriminatedUnion("type",[p.z.object({type:p.z.literal("vapid"),endpoint:p.z.string().url(),keys:p.z.object({p256dh:p.z.string(),auth:p.z.string()})})]);async send({id:t,body:e,request:s={}}){return this._transport.send("v1/contacts/"+encodeURIComponent(t)+"/notification-subscriptions",{...s,method:"POST",headers:{...s.headers,"Content-Type":"application/json"},body:JSON.stringify(r.SCHEMA.parse(e))})}};var pt=class r{constructor(t=r.STANDARD_HEADERS){this._standardHeaders=t}static STANDARD_HEADERS=wt;async filter(){return{headers:this.getHeaders()}}getHeaders(){return this._standardHeaders}};var ct=class{constructor(t){this._transport=t}async send({id:t,request:e={}}){return this._transport.send("v1/sources/"+encodeURIComponent(t),{...e,method:"GET"})}};var dt=class{constructor(t){this._transport=t}async send({request:t={}}={}){return this._transport.send("v1/sources",{...t,method:"GET"})}};var Mt=Ut(require("is-network-error"),1),xt=Ut(require("ky"),1);var o=class extends Error{};var a=class extends o{};var d=class extends a{static unauthenticated(){return new this("An unauthenticated request occurred")}};var u=class extends a{static forbidden(){return new this("A forbidden request occurred")}};var c=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 l=class extends o{};var g=class extends o{static badRequest(){return new this("Bad request")}};var ut=class{client;options;constructor({baseURL:t,...e}){this.options={...e,baseURL:t},this.client=xt.default.create({prefixUrl:this.options.baseURL,hooks:{beforeRequest:[s=>{for(let i of this.options.requestFilterables){let Gt=i.getHeaders();for(let[vt,Bt]of Object.entries(Gt))s.headers.has(vt)||s.headers.set(vt,Bt)}}]}})}getURL(t){return new URL(t,this.options.baseURL).toString()}async send(t,e){return await this.client(t,e).catch(s=>{if((0,Mt.default)(s))throw new l("A network error occurred",{cause:s});if(s instanceof xt.HTTPError){let i=s.response.status;switch(console.error(JSON.stringify(s.response)),i){case 400:throw g.badRequest();case 401:throw d.unauthenticated();case 403:throw u.forbidden();case 404:throw c.notFound(t);case 405:throw c.forbiddenMethod(t,e.method??"GET")}}throw s})}};var n=require("zod"),lt=class r{constructor(t){this._client=t}static SCHEMA=n.z.object({event:n.z.intersection(n.z.object({id:n.z.string(),createdAt:n.z.string().datetime()}),n.z.discriminatedUnion("type",[n.z.object({type:n.z.literal("contact.created"),contact:n.z.string()}),n.z.object({type:n.z.literal("message.created"),message:n.z.string()})]))});async event({request:t}){let{event:e}=r.SCHEMA.parse(t.body);return{event:e}}};var h=class r{static DEFAULT_BASE_URL=bt;_transport;constructor(t,{baseURL:e,...s}={}){this._transport=new ut({requestFilterables:[new pt,t],...s,baseURL:e?.toString()??r.getBaseURL()})}static getBaseURL(){return process.env[Nt]??this.DEFAULT_BASE_URL}get action(){return{list:new b(this._transport)}}get boilerplate(){return{get:new R(this._transport),list:new x(this._transport),update:new T(this._transport)}}get boilerplateCategory(){return{get:new S(this._transport),list:new v(this._transport),create:new E(this._transport),update:new O(this._transport),boilerplate:{list:new y(this._transport),create:new A(this._transport)}}}get channel(){return{list:new F(this._transport)}}get contact(){return{get:new I(this._transport),list:new L(this._transport),update:new N(this._transport),create:new w(this._transport),conversation:{list:new G(this._transport)},note:{list:new ot(this._transport),create:new rt(this._transport)},notificationSubscription:{create:new at(this._transport)},vcf:{get:new U(this._transport)}}}get conversation(){return{get:new M(this._transport),list:new B(this._transport),update:new z(this._transport),create:new f(this._transport),message:{list:new Y(this._transport)},note:{list:new nt(this._transport),create:new f(this._transport)}}}get label(){return{create:new D(this._transport),get:new V(this._transport),list:new J(this._transport),update:new K(this._transport),delete:new k(this._transport),contact:{list:new q(this._transport)},conversation:{list:new j(this._transport)}}}get message(){return{list:new $(this._transport)}}get model(){return{get:new Q(this._transport),list:new Z(this._transport),response:{create:new et(this._transport)},correction:{create:new X(this._transport)}}}get note(){return{get:new st(this._transport),update:new it(this._transport)}}get source(){return{get:new ct(this._transport),list:new dt(this._transport)}}get webhook(){return new lt(this)}};var St={};Ot(St,{AuthError:()=>a,AuthenticationError:()=>d,AuthorizationError:()=>u,LogicError:()=>c,NetworkError:()=>l,SupportError:()=>o,ValidationError:()=>g});var gt=class r{static DEFAULT_NAME=It;name;#t;constructor({name:t=process.env[Ht]??r.DEFAULT_NAME,key:e=process.env[qt]}={}){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 mt=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 ft=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 Pt=Object.create;var Ct=Object.defineProperty;var Dt=Object.getOwnPropertyDescriptor;var kt=Object.getOwnPropertyNames;var Vt=Object.getPrototypeOf,Jt=Object.prototype.hasOwnProperty;var Ut=(r,t)=>{for(var e in t)Ct(r,e,{get:t[e],enumerable:!0})},wt=(r,t,e,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of kt(t))!Jt.call(r,o)&&o!==e&&Ct(r,o,{get:()=>t[o],enumerable:!(s=Dt(t,o))||s.enumerable});return r};var It=(r,t,e)=>(e=r!=null?Pt(Vt(r)):{},wt(t||!r||!r.__esModule?Ct(e,"default",{value:r,enumerable:!0}):e,r)),Kt=r=>wt(Ct({},"__esModule",{value:!0}),r);var Yt={};Ut(Yt,{Client:()=>h,DEFAULT_SUPPORT_BASE_URL:()=>Rt,Error:()=>Ot,KeyAuthentication:()=>ft,PublicAuthentication:()=>bt,TokenAuthentication:()=>ht,default:()=>h});module.exports=Kt(Yt);var Rt="https://api.support.greatdetail.com",qt={"X-Powered-By":"GDSupport/JavaScript"},Lt="api-key";var b=class{constructor(t){this._transport=t}async send({request:t={}}={}){return this._transport.send("v1/actions",{...t,method:"GET"})}};var C=require("zod"),R=class r{constructor(t){this._transport=t}static SCHEMA=C.z.object({title:C.z.string(),content:C.z.string(),account:C.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 y=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 x=class{constructor(t){this._transport=t}async send({request:t={}}={}){return this._transport.send("v1/boilerplates",{...t,method:"GET"})}};var At=require("zod"),T=class r{constructor(t){this._transport=t}static SCHEMA=At.z.object({title:At.z.string().optional(),content:At.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 _=require("zod"),E=class r{constructor(t){this._transport=t}static SCHEMA=_.z.object({title:_.z.string(),description:_.z.string().optional(),account:_.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 S=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 v=class{constructor(t){this._transport=t}async send({request:t={}}={}){return this._transport.send("v1/boilerplate-categories",{...t,method:"GET"})}};var yt=require("zod"),O=class r{constructor(t){this._transport=t}static SCHEMA=yt.z.object({title:yt.z.string().optional(),description:yt.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 F=class{constructor(t){this._transport=t}async send({request:t={}}={}){return this._transport.send("v1/channels",{...t,method:"GET"})}};var Ht="SUPPORT_ACCESS_TOKEN",Nt="SUPPORT_API_KEY",Mt="SUPPORT_KEY_NAME",Gt="SUPPORT_BASE_URL";var U=class{constructor(t){this._transport=t}getRelativeURL({id:t,vcf:e={}}){let s=e.variant??"vcard",o=e.format??(e.variant==="vcard"?"vcf":"json");return"v1/contacts/"+encodeURIComponent(t)+"/vcf?variant="+encodeURIComponent(s)+"&format="+encodeURIComponent(o)}getURL(t){return this._transport.getURL(this.getRelativeURL(t))}};var m=require("zod"),w=class r{constructor(t){this._transport=t}static SCHEMA=m.z.object({name:m.z.string(),account:m.z.string(),emailAddress:m.z.string().email().optional(),telephoneNumber:m.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 I=class{constructor(t){this._transport=t}async send({id:t,request:e={}}){return this._transport.send("v1/contacts/"+encodeURIComponent(t),{...e,method:"GET"})}};var q=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 H=require("zod"),N=class r{constructor(t){this._transport=t}static SCHEMA=H.z.object({name:H.z.string().optional(),emailAddress:H.z.string().email().optional(),telephoneNumber:H.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 M=class{constructor(t){this._transport=t}async send({id:t,request:e={}}){return this._transport.send("v1/conversations/"+encodeURIComponent(t),{...e,method:"GET"})}};var G=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 B=class{constructor(t){this._transport=t}async send({request:t={}}={}){return this._transport.send("v1/conversations",{...t,method:"GET"})}};var j=class{constructor(t){this._transport=t}async send({id:t,request:e={}}){return this._transport.send("v1/labels/"+encodeURIComponent(t)+"/conversations",{...e,method:"GET"})}};var xt=require("zod"),z=class r{constructor(t){this._transport=t}static SCHEMA=xt.z.object({conversationStatus:xt.z.enum(["AwaitingContactConversationStatus","AwaitingAgentConversationStatus","ResolvedConversationStatus","ClosedConversationStatus"]).optional(),hasEnded:xt.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"),D=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 k=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 J=class{constructor(t){this._transport=t}async send({request:t={}}={}){return this._transport.send("v1/labels",{...t,method:"GET"})}};var Tt=require("zod"),K=class r{constructor(t){this._transport=t}static SCHEMA=Tt.z.object({title:Tt.z.string().optional(),description:Tt.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 Y=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 $=class{constructor(t){this._transport=t}async send({request:t={}}={}){return this._transport.send("v1/messages",{...t,method:"GET"})}};var W=require("zod"),X=class r{constructor(t){this._transport=t}static SCHEMA=W.z.object({input:W.z.string().max(65536),original:W.z.string().max(65536),correction:W.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 Q=class{constructor(t){this._transport=t}async send({id:t,request:e={}}){return this._transport.send("v1/models/"+encodeURIComponent(t),{...e,method:"GET"})}};var Z=class{constructor(t){this._transport=t}async send({request:t={}}={}){return this._transport.send("v1/models",{...t,method:"GET"})}};var tt=require("zod"),et=class r{constructor(t){this._transport=t}static SCHEMA=tt.z.array(tt.z.object({role:tt.z.enum(["user","assistant"]),content:tt.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 Et=require("zod"),rt=class r{constructor(t){this._transport=t}static SCHEMA=Et.z.object({content:Et.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 St=require("zod"),f=class r{constructor(t){this._transport=t}static SCHEMA=St.z.object({content:St.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 st=class{constructor(t){this._transport=t}async send({id:t,request:e={}}){return this._transport.send("v1/notes/"+encodeURIComponent(t),{...e,method:"GET"})}};var ot=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 vt=require("zod"),it=class r{constructor(t){this._transport=t}static SCHEMA=vt.z.object({content:vt.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 p=require("zod"),at=class r{constructor(t){this._transport=t}static SCHEMA=p.z.discriminatedUnion("type",[p.z.object({type:p.z.literal("vapid"),endpoint:p.z.string().url(),keys:p.z.object({p256dh:p.z.string(),auth:p.z.string()})})]);async send({id:t,body:e,request:s={}}){return this._transport.send("v1/contacts/"+encodeURIComponent(t)+"/notification-subscriptions",{...s,method:"POST",headers:{...s.headers,"Content-Type":"application/json"},body:JSON.stringify(r.SCHEMA.parse(e))})}};var pt=class r{constructor(t=r.STANDARD_HEADERS){this._standardHeaders=t}static STANDARD_HEADERS=qt;async filter(){return{headers:this.getHeaders()}}getHeaders(){return this._standardHeaders}};var ct=class{constructor(t){this._transport=t}async send({id:t,request:e={}}){return this._transport.send("v1/sources/"+encodeURIComponent(t),{...e,method:"GET"})}};var dt=class{constructor(t){this._transport=t}async send({request:t={}}={}){return this._transport.send("v1/sources",{...t,method:"GET"})}};var Bt=It(require("is-network-error"),1),_t=It(require("ky"),1);var n=class extends Error{};var a=class extends n{};var d=class extends a{static unauthenticated(){return new this("An unauthenticated request occurred")}};var u=class extends a{static forbidden(){return new this("A forbidden request occurred")}};var c=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 l=class extends n{};var g=class extends n{static badRequest(){return new this("Bad request")}};var ut=class{client;options;constructor({baseURL:t,...e}){this.options={...e,baseURL:t},this.client=_t.default.create({prefixUrl:this.options.baseURL,hooks:{beforeRequest:[s=>{for(let o of this.options.requestFilterables){let jt=o.getHeaders();for(let[Ft,zt]of Object.entries(jt))s.headers.has(Ft)||s.headers.set(Ft,zt)}}]}})}getURL(t){return new URL(t,this.options.baseURL).toString()}async send(t,e){return await this.client(t,e).catch(s=>{if((0,Bt.default)(s))throw new l("A network error occurred",{cause:s});if(s instanceof _t.HTTPError){let o=s.response.status;switch(console.error(JSON.stringify(s.response)),o){case 400:throw g.badRequest();case 401:throw d.unauthenticated();case 403:throw u.forbidden();case 404:throw c.notFound(t);case 405:throw c.forbiddenMethod(t,e.method??"GET")}}throw s})}};var lt=class{constructor(t){this._transport=t}async send({files:t,request:e={}}){let s=new FormData;for(let o of t)s.append("file",o);return this._transport.send("v1/uploads",{...e,method:"POST",body:s})}};var gt=class{constructor(t){this._transport=t}async send({id:t,request:e={}}){return this._transport.send("v1/uploads/"+encodeURIComponent(t),{...e,method:"GET"})}};var i=require("zod"),mt=class r{constructor(t){this._client=t}static SCHEMA=i.z.object({event:i.z.intersection(i.z.object({id:i.z.string(),createdAt:i.z.string().datetime()}),i.z.discriminatedUnion("type",[i.z.object({type:i.z.literal("contact.created"),contact:i.z.string()}),i.z.object({type:i.z.literal("message.created"),message:i.z.string()})]))});async event({request:t}){let{event:e}=r.SCHEMA.parse(t.body);return{event:e}}};var h=class r{static DEFAULT_BASE_URL=Rt;_transport;constructor(t,{baseURL:e,...s}={}){this._transport=new ut({requestFilterables:[new pt,t],...s,baseURL:e?.toString()??r.getBaseURL()})}static getBaseURL(){return process.env[Gt]??this.DEFAULT_BASE_URL}get action(){return{list:new b(this._transport)}}get boilerplate(){return{get:new A(this._transport),list:new x(this._transport),update:new T(this._transport)}}get boilerplateCategory(){return{get:new S(this._transport),list:new v(this._transport),create:new E(this._transport),update:new O(this._transport),boilerplate:{list:new y(this._transport),create:new R(this._transport)}}}get channel(){return{list:new F(this._transport)}}get contact(){return{get:new I(this._transport),list:new q(this._transport),update:new N(this._transport),create:new w(this._transport),conversation:{list:new G(this._transport)},note:{list:new ot(this._transport),create:new rt(this._transport)},notificationSubscription:{create:new at(this._transport)},vcf:{get:new U(this._transport)}}}get conversation(){return{get:new M(this._transport),list:new B(this._transport),update:new z(this._transport),create:new f(this._transport),message:{list:new Y(this._transport)},note:{list:new nt(this._transport),create:new f(this._transport)}}}get label(){return{create:new D(this._transport),get:new V(this._transport),list:new J(this._transport),update:new K(this._transport),delete:new k(this._transport),contact:{list:new L(this._transport)},conversation:{list:new j(this._transport)}}}get message(){return{list:new $(this._transport)}}get model(){return{get:new Q(this._transport),list:new Z(this._transport),response:{create:new et(this._transport)},correction:{create:new X(this._transport)}}}get note(){return{get:new st(this._transport),update:new it(this._transport)}}get source(){return{get:new ct(this._transport),list:new dt(this._transport)}}get upload(){return{get:new gt(this._transport),create:new lt(this._transport)}}get webhook(){return new mt(this)}};var Ot={};Ut(Ot,{AuthError:()=>a,AuthenticationError:()=>d,AuthorizationError:()=>u,LogicError:()=>c,NetworkError:()=>l,SupportError:()=>n,ValidationError:()=>g});var ft=class r{static DEFAULT_NAME=Lt;name;#t;constructor({name:t=process.env[Mt]??r.DEFAULT_NAME,key:e=process.env[Nt]}={}){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 ht=class{#t;constructor({token:t=process.env[Ht]}={}){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-
|
|
2
|
-
export { C as Client, b as CreateBoilerplateCategoryBoilerplateResponse, e as CreateBoilerplateCategoryResponse, H as CreateContactNoteResponse, S as CreateContactNotificationSubscriptionResponse, 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, W as WebhookResponse, C as default } from './index-
|
|
1
|
+
import { A as Authentication } from './index-DNJOlCyr.cjs';
|
|
2
|
+
export { C as Client, b as CreateBoilerplateCategoryBoilerplateResponse, e as CreateBoilerplateCategoryResponse, H as CreateContactNoteResponse, S as CreateContactNotificationSubscriptionResponse, j as CreateContactResponse, I as CreateConversationNoteResponse, E as CreateCorrectionResponse, t as CreateLabelResponse, F as CreateResponseResponse, T as CreateUploadResponse, 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, V as GetUploadResponse, 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, W as WebhookResponse, C as default } from './index-DNJOlCyr.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, S as CreateContactNotificationSubscriptionResponse, 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, W as WebhookResponse, C as default } from './index-
|
|
1
|
+
import { A as Authentication } from './index-DNJOlCyr.js';
|
|
2
|
+
export { C as Client, b as CreateBoilerplateCategoryBoilerplateResponse, e as CreateBoilerplateCategoryResponse, H as CreateContactNoteResponse, S as CreateContactNotificationSubscriptionResponse, j as CreateContactResponse, I as CreateConversationNoteResponse, E as CreateCorrectionResponse, t as CreateLabelResponse, F as CreateResponseResponse, T as CreateUploadResponse, 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, V as GetUploadResponse, 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, W as WebhookResponse, C as default } from './index-DNJOlCyr.js';
|
|
3
3
|
import 'ky';
|
|
4
4
|
import 'zod';
|
|
5
5
|
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as d,b as g,c as s,d as p,e as n,f as a,g as f,h as m,i as u,j as c,k as
|
|
1
|
+
import{a as d,b as g,c as s,d as p,e as n,f as a,g as f,h as m,i as u,j as c,k as x,l,m as h,n as A,o as _}from"./chunk-K37WTNB5.js";var E={};d(E,{AuthError:()=>m,AuthenticationError:()=>u,AuthorizationError:()=>c,LogicError:()=>x,NetworkError:()=>l,SupportError:()=>f,ValidationError:()=>h});var t=class o{static DEFAULT_NAME=s;name;#r;constructor({name:r=process.env[a]??o.DEFAULT_NAME,key:i=process.env[n]}={}){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[p]}={}){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,g as DEFAULT_SUPPORT_BASE_URL,E as Error,t as KeyAuthentication,_ as PublicAuthentication,e as TokenAuthentication,A as default};
|