@great-detail/support-sdk 0.15.1 → 0.15.3

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.
@@ -0,0 +1 @@
1
+ var le=Object.defineProperty;var he=(o,t)=>{for(var e in t)le(o,e,{get:t[e],enumerable:!0})};var m=class{getHeaders(){return{}}};var oe="SUPPORT_ACCESS_TOKEN",re="SUPPORT_KEY_NAME",ne="SUPPORT_KEY_PASSWORD",te="SUPPORT_SIGNING_KEY",se="SUPPORT_BASE_URL";var h=class{name;#t;constructor({name:t=process.env[re],password:e=process.env[ne]}={}){if(!t)throw new Error("Name option must be specified when using Basic Authentication");if(!e)throw new Error("Password option must be specified when using Basic Authentication");this.name=t,this.#t=e}getHeaders(){return{Authorization:`Basic ${btoa(this.name+":"+this.#t)}`}}};var f=class{#t;constructor({token:t=process.env[oe]}={}){if(!t)throw new Error("Access Token option must be specified when using Token Authentication");this.#t=t}getHeaders(){return{Authorization:`Bearer ${this.#t}`}}};var ie="https://api.support.greatdetail.com",pe={"X-Powered-By":"GDSupport/JavaScript"};import{z as n}from"zod";var C=class o{constructor(t){this._client=t}static SCHEMA=n.object({data:n.object({event:n.intersection(n.object({id:n.string(),createdAt:n.string().datetime()}),n.union([n.object({type:n.union([n.literal("account.created"),n.literal("account.updated")]),payload:n.object({account:n.string()})}),n.object({type:n.union([n.literal("accountAccessToken.created"),n.literal("accountAccessToken.deleted")]),payload:n.object({accountAccessToken:n.string()})}),n.object({type:n.union([n.literal("contact.created"),n.literal("contact.updated")]),payload:n.object({contact:n.string()})}),n.object({type:n.union([n.literal("conversation.created"),n.literal("conversation.updated"),n.literal("conversation.closed"),n.literal("conversation.received"),n.literal("conversation.resolved"),n.literal("conversation.sent")]),payload:n.object({conversation:n.string()})}),n.object({type:n.union([n.literal("message.created"),n.literal("message.updated"),n.literal("message.delivered"),n.literal("message.failed"),n.literal("message.read"),n.literal("message.received"),n.literal("message.sent")]),payload:n.object({message:n.string()})})]))})});async event({key:t=process.env[te],maxSignatures:e=3,request:r}){let s=r.headers["gds-signature"];if(t!==!1){if(t===void 0)throw new Error("Missing webhook signing key in process.env."+te);if(!s)throw new Error("Missing signature header");if(!this._verifySignature(t,r.body,Array.isArray(s)?s.slice(0,e):[s]))throw new Error("Untrusted signature")}let{data:i}=o.SCHEMA.parse(r.body);return{event:i.event}}async _verifySignature(t,e,r){let s=await crypto.subtle.importKey("raw",new TextEncoder().encode(t),{name:"HMAC",hash:"SHA-256"},!1,["sign","verify"]);for(let i of r)if(await crypto.subtle.verify("HMAC",s,new TextEncoder().encode(atob(i)),new TextEncoder().encode(JSON.stringify(e))))return!0;return!1}};var g=class o{constructor(t=o.STANDARD_HEADERS){this._standardHeaders=t}static STANDARD_HEADERS=pe;async filter(){return{headers:this.getHeaders()}}getHeaders(){return this._standardHeaders}};import de from"is-network-error";import ue,{HTTPError as me}from"ky";var p=class extends Error{static serverError(t){return new this("Server Error: "+t)}};var c=class extends p{};var b=class extends c{static unauthenticated(){return new this("An unauthenticated request occurred")}};var _=class extends c{static forbidden(){return new this("A forbidden request occurred")}};var a=class extends p{static notFound(t){return new this(`Record not found for request: ${t}`)}static forbiddenMethod(t,e){return new this(`Forbidden method for request: ${t} ${e}`)}static teapot(){return new this("I'm a teapot")}static rateLimited(){return new this("Request has been rate-limited")}};var O=class extends p{};var d=class extends p{static badRequest(){return new this("Bad request")}static unsupportedMediaType(){return new this("Unsupported Media Type")}};var y=class{client;options;constructor({baseURL:t,...e}){this.options={...e,baseURL:t},this.client=ue.create({prefixUrl:this.options.baseURL,timeout:12e3,hooks:{beforeRequest:[r=>{for(let s of this.options.requestFilterables){let i=s.getHeaders();for(let[l,ce]of Object.entries(i))r.headers.has(l)||r.headers.set(l,ce)}}]}})}getURL(t){return new URL(t,this.options.baseURL).toString()}sortQuery(t){let e=[];if(t===void 0)return e;for(let[r,s]of Object.entries(t))s!==void 0&&e.push(["sort",s+r]);return e}limitQuery(t){let e=[];return t===void 0||e.push(["limit",t.toString()]),e}includeQuery(t){let e=[];if(t===void 0)return e;for(let r of Object.keys(t))e.push(["include",r]);return e}queryQuery(t){let e=[];return t===void 0||e.push(["query",t]),e}send(t,e={}){let r=this.client(t,e).catch(s=>{if(de(s))throw new O("A network error occurred",{cause:s});if(s instanceof me){let i=s.response.status;switch(console.error(JSON.stringify(s.response)),i){case 400:throw d.badRequest();case 401:throw b.unauthenticated();case 403:throw _.forbidden();case 404:throw a.notFound(t);case 405:throw a.forbiddenMethod(t,e.method??"GET");case 415:throw d.unsupportedMediaType();case 418:throw a.teapot();case 429:throw a.rateLimited()}if(i>=500&&i<600)throw p.serverError(i)}throw s});return{response:()=>r,json:async()=>(await r).json()}}};var x=class{constructor(t){this._transport=t}send(t,{body:e={},request:r={}}={}){return this._transport.send("v1/accounts/"+encodeURIComponent(t)+"/access-tokens",{...r,method:"POST",json:e})}};var S=class{constructor(t){this._transport=t}send(t,e,{body:r,request:s={}}={}){return this._transport.send("v1/accounts/"+encodeURIComponent(t)+"/access-tokens/"+encodeURIComponent(e),{...s,method:"DELETE",json:r})}};var T=class{constructor(t){this._transport=t}send(t,e,{request:r={}}={}){return this._transport.send("v1/accounts/"+encodeURIComponent(t)+"/access-tokens/"+encodeURIComponent(e),{...r,method:"GET"})}};var R=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/accounts/"+encodeURIComponent(t)+"/access-tokens",{...e,method:"GET"})}};var v=class{constructor(t){this._transport=t}get api(){return{get:new T(this._transport),list:new R(this._transport),create:new x(this._transport),delete:new S(this._transport)}}};var F=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/accounts/"+encodeURIComponent(t),{...e,method:"GET"})}};var A=class{constructor(t){this._transport=t}send(t,{body:e,request:r={}}){return this._transport.send("v1/accounts/"+encodeURIComponent(t),{...r,method:"PATCH",json:e})}};var w=class{constructor(t){this._transport=t}get api(){return{get:new F(this._transport),update:new A(this._transport)}}};var L=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/accounts/"+encodeURIComponent(t)+"/conversation-settings",{...e,method:"GET"})}};var U=class{constructor(t){this._transport=t}send(t,{body:e,request:r={}}){return this._transport.send("v1/accounts/"+encodeURIComponent(t)+"/conversation-settings",{...r,method:"PATCH",json:e})}};var E=class{constructor(t){this._transport=t}get api(){return{get:new L(this._transport),update:new U(this._transport)}}};var N=class{constructor(t){this._transport=t}send({limit:t,sort:e,request:r={}}={}){return this._transport.send("v1/actions",{...r,method:"GET",searchParams:[...this._transport.limitQuery(t),...this._transport.sortQuery(e)]})}};var G=class{constructor(t){this._transport=t}get api(){return{list:new N(this._transport)}}};var P=class{constructor(t){this._transport=t}send({body:t,request:e={}}){return this._transport.send("v1/boilerplates/categories",{...e,method:"POST",json:t})}};var q=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/boilerplates/categories/"+encodeURIComponent(t),{...e,method:"GET"})}};var I=class{constructor(t){this._transport=t}send({limit:t,include:e,request:r={}}={}){return this._transport.send("v1/boilerplates/categories",{...r,method:"GET",searchParams:[...this._transport.limitQuery(t),...this._transport.includeQuery(e)]})}};var B=class{constructor(t){this._transport=t}send(t,{body:e,request:r={}}){return this._transport.send("v1/boilerplates/categories/"+encodeURIComponent(t),{...r,method:"PATCH",json:e})}};var M=class{constructor(t){this._transport=t}send(t,{limit:e,request:r={}}={}){return this._transport.send("v1/boilerplates/categories/"+encodeURIComponent(t)+"/contents",{...r,method:"GET",searchParams:[...this._transport.limitQuery(e)]})}};var k=class{constructor(t){this._transport=t}get api(){return{get:new q(this._transport),list:new I(this._transport),create:new P(this._transport),update:new B(this._transport),boilerplate:{list:new M(this._transport)}}}};var j=class{constructor(t){this._transport=t}send({body:t,request:e={}}){return this._transport.send("v1/boilerplates/contents",{...e,method:"POST",json:t})}};var Q=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/boilerplates/contents/"+encodeURIComponent(t),{...e,method:"GET"})}};var D=class{constructor(t){this._transport=t}send({limit:t,query:e,request:r={}}={}){return this._transport.send("v1/boilerplates/contents",{...r,method:"GET",searchParams:[...this._transport.limitQuery(t),...this._transport.queryQuery(e)]})}};var H=class{constructor(t){this._transport=t}send(t,{body:e,request:r={}}){return this._transport.send("v1/boilerplates/contents/"+encodeURIComponent(t),{...r,method:"PATCH",json:e})}};var K=class{constructor(t){this._transport=t}get api(){return{get:new Q(this._transport),list:new D(this._transport),update:new H(this._transport),create:new j(this._transport)}}};var V=class{constructor(t){this._transport=t}send({body:t,request:e={}}){return this._transport.send("v1/channels",{...e,method:"POST",json:t})}};var W=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/channels/"+encodeURIComponent(t),{...e,method:"GET"})}};var Y=class{constructor(t){this._transport=t}send({limit:t,request:e={}}={}){return this._transport.send("v1/channels",{...e,method:"GET",searchParams:[...this._transport.limitQuery(t)]})}};var z=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/channels/"+encodeURIComponent(t)+"/meta-whatsapp/business-profile",{...e,method:"GET"})}};import{z as ae}from"zod";var $=class o{constructor(t){this._transport=t}static SCHEMA=ae.object({overwrite:ae.boolean().optional()});send(t,{body:e,request:r={}}){return this._transport.send("v1/channels/"+encodeURIComponent(t)+"/twilio-sendgrid/sync",{...r,method:"POST",json:o.SCHEMA.parse(e)})}};var J=class{constructor(t){this._transport=t}send(t,{body:e,request:r={}}){return this._transport.send("v1/channels/"+encodeURIComponent(t),{...r,method:"PATCH",json:e})}};var X=class{constructor(t){this._transport=t}send(t,{limit:e,request:r={}}={}){return this._transport.send("v1/channels/"+encodeURIComponent(t)+"/composition-sections",{...r,method:"GET",searchParams:[...this._transport.limitQuery(e)]})}};var Z=class{constructor(t){this._transport=t}send(t,{limit:e,include:r,request:s={}}={}){return this._transport.send("v1/channels/"+encodeURIComponent(t)+"/messages",{...s,method:"GET",searchParams:[...this._transport.limitQuery(e),...this._transport.includeQuery(r)]})}};var tt=class{constructor(t){this._transport=t}get api(){return{get:new W(this._transport),list:new Y(this._transport),update:new J(this._transport),create:new V(this._transport),compositionSection:{list:new X(this._transport)},message:{list:new Z(this._transport)},metaWhatsapp:{getBusinessProfile:new z(this._transport)},twilioSendgrid:{sync:new $(this._transport)}}}};var et=class{constructor(t){this._transport=t}send({body:t,request:e={}}){return this._transport.send("v1/composition-sections",{...e,method:"POST",json:t})}};var ot=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/composition-sections/"+encodeURIComponent(t),{...e,method:"GET"})}};var rt=class{constructor(t){this._transport=t}send({limit:t,request:e={}}={}){return this._transport.send("v1/composition-sections",{...e,method:"GET",searchParams:[...this._transport.limitQuery(t)]})}};var nt=class{constructor(t){this._transport=t}send(t,{body:e,request:r={}}){return this._transport.send("v1/composition-sections/"+encodeURIComponent(t),{...r,method:"PATCH",json:e})}};var st=class{constructor(t){this._transport=t}get api(){return{get:new ot(this._transport),list:new rt(this._transport),create:new et(this._transport),update:new nt(this._transport)}}};var it=class{constructor(t){this._transport=t}getRelativeURL({id:t,vcf:e={}}){let r=e.variant??"vcard",s=e.format??(r==="vcard"?"vcf":"json");return"v1/contacts/"+encodeURIComponent(t)+"/vcf?variant="+encodeURIComponent(r)+"&format="+encodeURIComponent(s)}getURL(t){return this._transport.getURL(this.getRelativeURL(t))}send(t){return this._transport.send(this.getURL(t),{method:"GET"})}};var pt=class{constructor(t){this._transport=t}send({body:t,request:e={}}){return this._transport.send("v1/contacts",{...e,method:"POST",json:t})}};var at=class{constructor(t){this._transport=t}send(t,{include:e,request:r={}}={}){return this._transport.send("v1/contacts/"+encodeURIComponent(t),{...r,method:"GET",searchParams:[...this._transport.includeQuery(e??{})]})}};var ct=class{constructor(t){this._transport=t}send({limit:t,query:e,request:r={}}={}){return this._transport.send("v1/contacts",{...r,method:"GET",searchParams:[...this._transport.limitQuery(t),...this._transport.queryQuery(e)]})}};var lt=class{constructor(t){this._transport=t}send(t,{body:e,request:r={}}){return this._transport.send("v1/contacts/"+encodeURIComponent(t),{...r,method:"PATCH",json:e})}};var dt=class{constructor(t){this._transport=t}send(t,{limit:e,request:r={}}={}){return this._transport.send("v1/contacts/"+encodeURIComponent(t)+"/conversations",{...r,method:"GET",searchParams:[...this._transport.limitQuery(e)]})}};var ut=class{constructor(t){this._transport=t}send(t,{limit:e,request:r={}}={}){return this._transport.send("v1/contacts/"+encodeURIComponent(t)+"/labels",{...r,method:"GET",searchParams:[...this._transport.limitQuery(e)]})}};var mt=class{constructor(t){this._transport=t}send(t,{body:e,request:r={}}){return this._transport.send("v1/contacts/"+encodeURIComponent(t)+"/notes",{...r,method:"POST",json:e})}};var ht=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/contacts/"+encodeURIComponent(t)+"/notes",{...e,method:"GET"})}};var ft=class{constructor(t){this._transport=t}send(t,{body:e,request:r={}}){return this._transport.send("v1/contacts/"+encodeURIComponent(t)+"/notification-subscriptions",{...r,method:"POST",json:e})}};var Ct=class{constructor(t){this._transport=t}get api(){return{get:new at(this._transport),list:new ct(this._transport),update:new lt(this._transport),create:new pt(this._transport),conversation:{list:new dt(this._transport)},label:{list:new ut(this._transport)},note:{list:new ht(this._transport),create:new mt(this._transport)},notificationSubscription:{create:new ft(this._transport)},vcf:{get:new it(this._transport)}}}};var gt=class{constructor(t){this._transport=t}send(t,{include:e,request:r={}}={}){return this._transport.send("v1/conversations/"+encodeURIComponent(t),{...r,method:"GET",searchParams:[...this._transport.includeQuery(e??{})]})}};var bt=class{constructor(t){this._transport=t}send({limit:t,filter:e,include:r,request:s={}}={}){return this._transport.send("v1/conversations",{...s,method:"GET",searchParams:[...this._transport.limitQuery(t),...e?[["filter",e]]:[],...this._transport.includeQuery(r??{})]})}};var _t=class{constructor(t){this._transport=t}send(t,{body:e,request:r={}}){return this._transport.send("v1/conversations/"+encodeURIComponent(t),{...r,method:"PATCH",json:e})}};var Ot=class{constructor(t){this._transport=t}send(t,{limit:e,request:r={}}={}){return this._transport.send("v1/conversations/"+encodeURIComponent(t)+"/labels",{...r,method:"GET",searchParams:[...this._transport.limitQuery(e)]})}};var yt=class{constructor(t){this._transport=t}send(t,{limit:e,include:r,request:s={}}={}){return this._transport.send("v1/conversations/"+encodeURIComponent(t)+"/messages",{...s,method:"GET",searchParams:[...this._transport.limitQuery(e),...this._transport.includeQuery(r??{})]})}};var u=class{constructor(t){this._transport=t}send(t,{body:e,request:r={}}){return this._transport.send("v1/conversations/"+encodeURIComponent(t)+"/notes",{...r,method:"POST",json:e})}};var xt=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/conversations/"+encodeURIComponent(t)+"/notes",{...e,method:"GET"})}};var St=class{constructor(t){this._transport=t}get api(){return{get:new gt(this._transport),list:new bt(this._transport),update:new _t(this._transport),create:new u(this._transport),label:{list:new Ot(this._transport)},message:{list:new yt(this._transport)},note:{list:new xt(this._transport),create:new u(this._transport)}}}};var Tt=class{constructor(t){this._transport=t}send(t,{limit:e,request:r={}}={}){return this._transport.send("v1/labels/"+encodeURIComponent(t)+"/contacts",{...r,method:"GET",searchParams:[...this._transport.limitQuery(e)]})}};var Rt=class{constructor(t){this._transport=t}send(t,{limit:e,request:r={}}={}){return this._transport.send("v1/labels/"+encodeURIComponent(t)+"/conversations",{...r,method:"GET",searchParams:[...this._transport.limitQuery(e)]})}};var vt=class{constructor(t){this._transport=t}send({body:t,request:e={}}){return this._transport.send("v1/labels",{...e,method:"POST",json:t})}};var Ft=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/labels/"+encodeURIComponent(t),{...e,method:"DELETE"})}};var At=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/labels/"+encodeURIComponent(t),{...e,method:"GET"})}};var wt=class{constructor(t){this._transport=t}send({limit:t,query:e,include:r,request:s={}}={}){return this._transport.send("v1/labels",{...s,method:"GET",searchParams:[...this._transport.limitQuery(t),...this._transport.queryQuery(e),...this._transport.includeQuery(r??{})]})}};var Lt=class{constructor(t){this._transport=t}send(t,{body:e,request:r={}}){return this._transport.send("v1/labels/"+encodeURIComponent(t),{...r,method:"PATCH",json:e})}};var Ut=class{constructor(t){this._transport=t}get api(){return{create:new vt(this._transport),get:new At(this._transport),list:new wt(this._transport),update:new Lt(this._transport),delete:new Ft(this._transport),contact:{list:new Tt(this._transport)},conversation:{list:new Rt(this._transport)}}}};var Et=class{constructor(t){this._transport=t}send({limit:t,include:e,request:r={}}={}){return this._transport.send("v1/messages",{...r,method:"GET",searchParams:[...this._transport.limitQuery(t),...this._transport.includeQuery(e??{})]})}};var Nt=class{constructor(t){this._transport=t}get api(){return{list:new Et(this._transport)}}};var Gt=class{constructor(t){this._transport=t}send(t,{body:e,request:r={}}){return this._transport.send("v1/models/"+encodeURIComponent(t)+"/correction",{...r,method:"POST",json:e})}};var Pt=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/models/"+encodeURIComponent(t),{...e,method:"GET"})}};var qt=class{constructor(t){this._transport=t}send({request:t={}}={}){return this._transport.send("v1/models",{...t,method:"GET"})}};var It=class{constructor(t){this._transport=t}send(t,{body:e,request:r={}}){return this._transport.send("v1/models/"+encodeURIComponent(t)+"/response",{...r,method:"POST",timeout:12e4,json:e})}};var Bt=class{constructor(t){this._transport=t}get api(){return{get:new Pt(this._transport),list:new qt(this._transport),response:{create:new It(this._transport)},correction:{create:new Gt(this._transport)}}}};var Mt=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/notes/"+encodeURIComponent(t),{...e,method:"GET"})}};var kt=class{constructor(t){this._transport=t}send(t,{body:e,request:r={}}){return this._transport.send("v1/notes/"+encodeURIComponent(t),{...r,method:"PATCH",json:e})}};var jt=class{constructor(t){this._transport=t}get api(){return{get:new Mt(this._transport),update:new kt(this._transport)}}};var Qt=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/sources/"+encodeURIComponent(t),{...e,method:"GET"})}};var Dt=class{constructor(t){this._transport=t}send({featured:t,category:e,request:r={}}={}){let s=[];if(e){let i=Array.isArray(e)?e:[e];for(let l of i)s.push(["category",l])}return t!==void 0&&s.push(["featured",String(t)]),this._transport.send("v1/sources",{...r,method:"GET",searchParams:s})}};var Ht=class{constructor(t){this._transport=t}get api(){return{get:new Qt(this._transport),list:new Dt(this._transport)}}};var Kt=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/channels/"+encodeURIComponent(t)+"/statistics/message-frequency",{...e,method:"GET"})}};var Vt=class{constructor(t){this._transport=t}send({request:t={}}={}){return this._transport.send("v1/statistics/message-frequency",{...t,method:"GET"})}};var Wt=class{constructor(t){this._transport=t}get api(){return{messageFrequency:new Vt(this._transport),channelMessageFrequency:new Kt(this._transport)}}};var Yt=class{constructor(t){this._transport=t}send({account:t,files:e,request:r={}}){let s=new FormData;for(let i of e)s.append("file",i);return this._transport.send("v1/uploads",{...r,method:"POST",body:s,searchParams:{account:t}})}};var zt=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/uploads/"+encodeURIComponent(t),{...e,method:"DELETE"})}};var $t=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/uploads/"+encodeURIComponent(t),{...e,method:"GET"})}};var Jt=class{constructor(t){this._transport=t}get api(){return{get:new $t(this._transport),create:new Yt(this._transport),delete:new zt(this._transport)}}};var Xt=class{constructor(t){this._transport=t}send({request:t={}}={}){return this._transport.send(".well-known/notifications",{...t,method:"GET"})}};var Zt=class{constructor(t){this._transport=t}get api(){return{notification:{get:new Xt(this._transport)}}}};var ee=class o{static DEFAULT_BASE_URL=ie;static PublicAuthentication=m;static BasicAuthentication=h;static BearerAuthentication=f;_transport;_account;_accountAccessToken;_accountConversationSettings;_action;_boilerplateContent;_boilerplateCategory;_channel;_compositionSection;_contact;_conversation;_label;_message;_model;_note;_source;_statistics;_upload;_webhook;_wellKnown;constructor(t,{baseURL:e,...r}={}){this._transport=new y({requestFilterables:[new g,t],...r,baseURL:e?.toString()??o.getBaseURL()}),this._account=new w(this._transport),this._accountAccessToken=new v(this._transport),this._accountConversationSettings=new E(this._transport),this._action=new G(this._transport),this._boilerplateContent=new K(this._transport),this._boilerplateCategory=new k(this._transport),this._channel=new tt(this._transport),this._compositionSection=new st(this._transport),this._contact=new Ct(this._transport),this._conversation=new St(this._transport),this._label=new Ut(this._transport),this._message=new Nt(this._transport),this._model=new Bt(this._transport),this._note=new jt(this._transport),this._source=new Ht(this._transport),this._statistics=new Wt(this._transport),this._upload=new Jt(this._transport),this._webhook=new C(this),this._wellKnown=new Zt(this._transport)}static getBaseURL(){return process.env[se]??this.DEFAULT_BASE_URL}get account(){return this._account.api}get accountAccessToken(){return this._accountAccessToken.api}get accountConversationSettings(){return this._accountConversationSettings.api}get action(){return this._action.api}get boilerplate(){return this._boilerplateContent.api}get boilerplateContent(){return this._boilerplateContent.api}get boilerplateCategory(){return this._boilerplateCategory.api}get channel(){return this._channel.api}get compositionSection(){return this._compositionSection.api}get contact(){return this._contact.api}get conversation(){return this._conversation.api}get label(){return this._label.api}get message(){return this._message.api}get model(){return this._model.api}get note(){return this._note.api}get source(){return this._source.api}get statistics(){return this._statistics.api}get upload(){return this._upload.api}get webhook(){return this._webhook}get wellKnown(){return this._wellKnown.api}};export{he as a,m as b,h as c,f as d,ie as e,p as f,c as g,b as h,_ as i,a as j,O as k,d as l,ee as m};
@@ -1 +1 @@
1
- import{b as v,m as b}from"./chunk-HR2YP6TH.js";import{Command as G}from"commander";import{Command as L}from"commander";import{oraPromise as N}from"ora";function r({client:t,ora:s}){let o=new L("actions").description("Actions");return o.addCommand(new L("list").description("List actions").action(async()=>{let n=await N(()=>t.action.list.send().json(),{...s,text:"Finding actions"});console.log(n)})),o}import{Command as D}from"commander";import{oraPromise as M}from"ora";function d({client:t,ora:s}){let o=new D("channels").description("Channels");return o.addCommand(new D("list").description("List channels").action(async()=>{let n=await M(()=>t.channel.list.send().json(),{...s,text:"Finding channels"});console.log(n)})),o}import{Command as a}from"commander";import{oraPromise as c}from"ora";function p({client:t,ora:s}){let o=new a("contacts").description("Contacts");return o.addCommand(new a("get").description("Find contact").argument("<contact>","Contact ID").action(async n=>{let i=await c(()=>t.contact.get.send(n).json(),{...s,text:"Finding contact"});console.log(i)})),o.addCommand(new a("list").description("List contacts").action(async()=>{let n=await c(()=>t.contact.list.send().json(),{...s,text:"Finding contacts"});console.log(n)})),o.addCommand(new a("get-vcf").description("Export Contact as VCF").argument("<contact>","Contact ID").action(async n=>{let i=await c(()=>t.contact.vcf.get.send({id:n}).response(),{...s,text:"Exporting contact"});console.log(i)})),o}import{Command as l}from"commander";import{oraPromise as I}from"ora";function f({client:t,ora:s}){let o=new l("conversations").description("Conversations");return o.addCommand(new l("get").description("Find conversation").argument("<conversation>","Conversation ID").action(async n=>{let i=await I(()=>t.conversation.get.send(n).json(),{...s,text:"Finding conversation"});console.log(i)})),o.addCommand(new l("list").description("List conversations").action(async()=>{let n=await I(()=>t.conversation.list.send().json(),{...s,text:"Finding conversations"});console.log(n)})),o}import{Command as m}from"commander";import{oraPromise as u}from"ora";function C({client:t,ora:s}){let o=new m("labels").description("Labels");return o.addCommand(new m("get").description("Find label").argument("<label>","Label ID").action(async n=>{let i=await u(()=>t.label.get.send(n).json(),{...s,text:"Finding label"});console.log(i)})),o.addCommand(new m("list").description("List labels").action(async()=>{let n=await u(()=>t.label.list.send().json(),{...s,text:"Finding labels"});console.log(n)})),o.addCommand(new m("conversations").description("Find label conversations").argument("<label>","Label ID").action(async n=>{let i=await u(()=>t.label.conversation.list.send(n).json(),{...s,text:"Finding conversations"});console.log(i)})),o}import{Command as P}from"commander";import{oraPromise as W}from"ora";function g({client:t,ora:s}){let o=new P("messages").description("Messages");return o.addCommand(new P("list").description("List messages").action(async()=>{let n=await W(()=>t.message.list.send().json(),{...s,text:"Finding messages"});console.log(n)})),o}import{Command as w}from"commander";import{oraPromise as K}from"ora";function O({client:t,ora:s}){let o=new w("models").description("Models");return o.addCommand(new w("get").description("Find model").argument("<model>","Model ID").action(async n=>{let i=await K(()=>t.model.get.send(n).json(),{...s,text:"Finding model"});console.log(i)})),o.addCommand(new w("list").description("List models").action(async()=>{let n=await K(()=>t.model.list.send().json(),{...s,text:"Finding models"});console.log(n)})),o}import{Command as x}from"commander";import{oraPromise as h}from"ora";function y({client:t,ora:s}){let o=new x("sources").description("Sources");return o.addCommand(new x("get").description("Find source").argument("<source>","Source ID").action(async n=>{let i=await h(()=>t.source.get.send(n).json(),{...s,text:"Finding source"});console.log(i)})),o.addCommand(new x("list").description("List sources").action(async()=>{let n=await h(()=>t.source.list.send().json(),{...s,text:"Finding sources"});console.log(n)})),o}import{Command as E}from"commander";import{Command as S}from"commander";import{oraPromise as A}from"ora";function j({client:t,ora:s}){let o=new S("notifications").description("Well-Known Notifications Details");return o.addCommand(new S("get").description("Get Notifications Server Well-Known Info").action(async()=>{let n=await A(()=>t.wellKnown.notification.get.send().json(),{...s,text:"Finding Notifications Well-Known Info"});console.log(n)})),o}function F({client:t,ora:s}){let o=new E("well-known").description("Well-Known Metadata & Info");return o.addCommand(j({client:t,ora:s})),o}var e={ora:{spinner:"simpleDotsScrolling"},client:new b(new v)},k=new G("gds").description("Great Detail Support System").addCommand(r(e)).addCommand(d(e)).addCommand(p(e)).addCommand(f(e)).addCommand(C(e)).addCommand(g(e)).addCommand(O(e)).addCommand(y(e)).addCommand(F(e)),Po=k;export{Po as a};
1
+ import{b as v,m as b}from"./chunk-AOL7NCTI.js";import{Command as G}from"commander";import{Command as L}from"commander";import{oraPromise as N}from"ora";function r({client:t,ora:s}){let o=new L("actions").description("Actions");return o.addCommand(new L("list").description("List actions").action(async()=>{let n=await N(()=>t.action.list.send().json(),{...s,text:"Finding actions"});console.log(n)})),o}import{Command as D}from"commander";import{oraPromise as M}from"ora";function d({client:t,ora:s}){let o=new D("channels").description("Channels");return o.addCommand(new D("list").description("List channels").action(async()=>{let n=await M(()=>t.channel.list.send().json(),{...s,text:"Finding channels"});console.log(n)})),o}import{Command as a}from"commander";import{oraPromise as c}from"ora";function p({client:t,ora:s}){let o=new a("contacts").description("Contacts");return o.addCommand(new a("get").description("Find contact").argument("<contact>","Contact ID").action(async n=>{let i=await c(()=>t.contact.get.send(n).json(),{...s,text:"Finding contact"});console.log(i)})),o.addCommand(new a("list").description("List contacts").action(async()=>{let n=await c(()=>t.contact.list.send().json(),{...s,text:"Finding contacts"});console.log(n)})),o.addCommand(new a("get-vcf").description("Export Contact as VCF").argument("<contact>","Contact ID").action(async n=>{let i=await c(()=>t.contact.vcf.get.send({id:n}).response(),{...s,text:"Exporting contact"});console.log(i)})),o}import{Command as l}from"commander";import{oraPromise as I}from"ora";function f({client:t,ora:s}){let o=new l("conversations").description("Conversations");return o.addCommand(new l("get").description("Find conversation").argument("<conversation>","Conversation ID").action(async n=>{let i=await I(()=>t.conversation.get.send(n).json(),{...s,text:"Finding conversation"});console.log(i)})),o.addCommand(new l("list").description("List conversations").action(async()=>{let n=await I(()=>t.conversation.list.send().json(),{...s,text:"Finding conversations"});console.log(n)})),o}import{Command as m}from"commander";import{oraPromise as u}from"ora";function C({client:t,ora:s}){let o=new m("labels").description("Labels");return o.addCommand(new m("get").description("Find label").argument("<label>","Label ID").action(async n=>{let i=await u(()=>t.label.get.send(n).json(),{...s,text:"Finding label"});console.log(i)})),o.addCommand(new m("list").description("List labels").action(async()=>{let n=await u(()=>t.label.list.send().json(),{...s,text:"Finding labels"});console.log(n)})),o.addCommand(new m("conversations").description("Find label conversations").argument("<label>","Label ID").action(async n=>{let i=await u(()=>t.label.conversation.list.send(n).json(),{...s,text:"Finding conversations"});console.log(i)})),o}import{Command as P}from"commander";import{oraPromise as W}from"ora";function g({client:t,ora:s}){let o=new P("messages").description("Messages");return o.addCommand(new P("list").description("List messages").action(async()=>{let n=await W(()=>t.message.list.send().json(),{...s,text:"Finding messages"});console.log(n)})),o}import{Command as w}from"commander";import{oraPromise as K}from"ora";function O({client:t,ora:s}){let o=new w("models").description("Models");return o.addCommand(new w("get").description("Find model").argument("<model>","Model ID").action(async n=>{let i=await K(()=>t.model.get.send(n).json(),{...s,text:"Finding model"});console.log(i)})),o.addCommand(new w("list").description("List models").action(async()=>{let n=await K(()=>t.model.list.send().json(),{...s,text:"Finding models"});console.log(n)})),o}import{Command as x}from"commander";import{oraPromise as h}from"ora";function y({client:t,ora:s}){let o=new x("sources").description("Sources");return o.addCommand(new x("get").description("Find source").argument("<source>","Source ID").action(async n=>{let i=await h(()=>t.source.get.send(n).json(),{...s,text:"Finding source"});console.log(i)})),o.addCommand(new x("list").description("List sources").action(async()=>{let n=await h(()=>t.source.list.send().json(),{...s,text:"Finding sources"});console.log(n)})),o}import{Command as E}from"commander";import{Command as S}from"commander";import{oraPromise as A}from"ora";function j({client:t,ora:s}){let o=new S("notifications").description("Well-Known Notifications Details");return o.addCommand(new S("get").description("Get Notifications Server Well-Known Info").action(async()=>{let n=await A(()=>t.wellKnown.notification.get.send().json(),{...s,text:"Finding Notifications Well-Known Info"});console.log(n)})),o}function F({client:t,ora:s}){let o=new E("well-known").description("Well-Known Metadata & Info");return o.addCommand(j({client:t,ora:s})),o}var e={ora:{spinner:"simpleDotsScrolling"},client:new b(new v)},k=new G("gds").description("Great Detail Support System").addCommand(r(e)).addCommand(d(e)).addCommand(p(e)).addCommand(f(e)).addCommand(C(e)).addCommand(g(e)).addCommand(O(e)).addCommand(y(e)).addCommand(F(e)),Po=k;export{Po as a};
@@ -1 +1 @@
1
- "use strict";var Ve=Object.create;var re=Object.defineProperty;var We=Object.getOwnPropertyDescriptor;var Ye=Object.getOwnPropertyNames;var ze=Object.getPrototypeOf,$e=Object.prototype.hasOwnProperty;var Je=(o,t)=>{for(var e in t)re(o,e,{get:t[e],enumerable:!0})},Le=(o,t,e,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of Ye(t))!$e.call(o,r)&&r!==e&&re(o,r,{get:()=>t[r],enumerable:!(n=We(t,r))||n.enumerable});return o};var Ue=(o,t,e)=>(e=o!=null?Ve(ze(o)):{},Le(t||!o||!o.__esModule?re(e,"default",{value:o,enumerable:!0}):e,o)),Xe=o=>Le(re({},"__esModule",{value:!0}),o);var eo={};Je(eo,{default:()=>to});module.exports=Xe(eo);var He=require("commander");var d=class{getHeaders(){return{}}};var Ne="SUPPORT_ACCESS_TOKEN",Ee="SUPPORT_KEY_NAME",Ge="SUPPORT_KEY_PASSWORD",le="SUPPORT_SIGNING_KEY",Pe="SUPPORT_BASE_URL";var h=class{name;#t;constructor({name:t=process.env[Ee],password:e=process.env[Ge]}={}){if(!t)throw new Error("Name option must be specified when using Basic Authentication");if(!e)throw new Error("Password option must be specified when using Basic Authentication");this.name=t,this.#t=e}getHeaders(){return{Authorization:`Basic ${btoa(this.name+":"+this.#t)}`}}};var f=class{#t;constructor({token:t=process.env[Ne]}={}){if(!t)throw new Error("Access Token option must be specified when using Token Authentication");this.#t=t}getHeaders(){return{Authorization:`Bearer ${this.#t}`}}};var qe="https://api.support.greatdetail.com",Ie={"X-Powered-By":"GDSupport/JavaScript"};var C=class o{constructor(t=o.STANDARD_HEADERS){this._standardHeaders=t}static STANDARD_HEADERS=Ie;async filter(){return{headers:this.getHeaders()}}getHeaders(){return this._standardHeaders}};var Be=Ue(require("is-network-error"),1),se=Ue(require("ky"),1);var a=class extends Error{static serverError(t){return new this("Server Error: "+t)}};var l=class extends a{};var g=class extends l{static unauthenticated(){return new this("An unauthenticated request occurred")}};var b=class extends l{static forbidden(){return new this("A forbidden request occurred")}};var c=class extends a{static notFound(t){return new this(`Record not found for request: ${t}`)}static forbiddenMethod(t,e){return new this(`Forbidden method for request: ${t} ${e}`)}static teapot(){return new this("I'm a teapot")}static rateLimited(){return new this("Request has been rate-limited")}};var O=class extends a{};var m=class extends a{static badRequest(){return new this("Bad request")}static unsupportedMediaType(){return new this("Unsupported Media Type")}};var x=class{client;options;constructor({baseURL:t,...e}){this.options={...e,baseURL:t},this.client=se.default.create({prefixUrl:this.options.baseURL,timeout:12e3,hooks:{beforeRequest:[n=>{for(let r of this.options.requestFilterables){let i=r.getHeaders();for(let[ne,Ke]of Object.entries(i))n.headers.has(ne)||n.headers.set(ne,Ke)}}]}})}getURL(t){return new URL(t,this.options.baseURL).toString()}sortQuery(t){let e=[];if(t===void 0)return e;for(let[n,r]of Object.entries(t))r!==void 0&&e.push(["sort",r+n]);return e}limitQuery(t){let e=[];return t===void 0||e.push(["limit",t.toString()]),e}includeQuery(t){let e=[];if(t===void 0)return e;for(let n of Object.keys(t))e.push(["include",n]);return e}queryQuery(t){let e=[];return t===void 0||e.push(["query",t]),e}send(t,e={}){let n=this.client(t,e).catch(r=>{if((0,Be.default)(r))throw new O("A network error occurred",{cause:r});if(r instanceof se.HTTPError){let i=r.response.status;switch(console.error(JSON.stringify(r.response)),i){case 400:throw m.badRequest();case 401:throw g.unauthenticated();case 403:throw b.forbidden();case 404:throw c.notFound(t);case 405:throw c.forbiddenMethod(t,e.method??"GET");case 415:throw m.unsupportedMediaType();case 418:throw c.teapot();case 429:throw c.rateLimited()}if(i>=500&&i<600)throw a.serverError(i)}throw r});return{response:()=>n,json:async()=>(await n).json()}}};var s=require("zod");var _=class o{constructor(t){this._client=t}static SCHEMA=s.z.object({data:s.z.object({event:s.z.intersection(s.z.object({id:s.z.string(),createdAt:s.z.string().datetime()}),s.z.union([s.z.object({type:s.z.union([s.z.literal("account.created"),s.z.literal("account.updated")]),payload:s.z.object({account:s.z.string()})}),s.z.object({type:s.z.union([s.z.literal("accountAccessToken.created"),s.z.literal("accountAccessToken.deleted")]),payload:s.z.object({accountAccessToken:s.z.string()})}),s.z.object({type:s.z.union([s.z.literal("contact.created"),s.z.literal("contact.updated")]),payload:s.z.object({contact:s.z.string()})}),s.z.object({type:s.z.union([s.z.literal("conversation.created"),s.z.literal("conversation.updated"),s.z.literal("conversation.closed"),s.z.literal("conversation.received"),s.z.literal("conversation.resolved"),s.z.literal("conversation.sent")]),payload:s.z.object({conversation:s.z.string()})}),s.z.object({type:s.z.union([s.z.literal("message.created"),s.z.literal("message.updated"),s.z.literal("message.delivered"),s.z.literal("message.failed"),s.z.literal("message.read"),s.z.literal("message.received"),s.z.literal("message.sent")]),payload:s.z.object({message:s.z.string()})})]))})});async event({key:t=process.env[le],maxSignatures:e=3,request:n}){let r=n.headers["gds-signature"];if(t!==!1){if(t===void 0)throw new Error("Missing webhook signing key in process.env."+le);if(!r)throw new Error("Missing signature header");if(!this._verifySignature(t,n.body,Array.isArray(r)?r.slice(0,e):[r]))throw new Error("Untrusted signature")}let{data:i}=o.SCHEMA.parse(n.body);return{event:i.event}}async _verifySignature(t,e,n){let r=await crypto.subtle.importKey("raw",new TextEncoder().encode(t),{name:"HMAC",hash:"SHA-256"},!1,["sign","verify"]);for(let i of n)if(await crypto.subtle.verify("HMAC",r,new TextEncoder().encode(atob(i)),new TextEncoder().encode(JSON.stringify(e))))return!0;return!1}};var y=class{constructor(t){this._transport=t}send(t,{body:e={},request:n={}}={}){return this._transport.send("v1/accounts/"+encodeURIComponent(t)+"/access-tokens",{...n,method:"POST",json:e})}};var S=class{constructor(t){this._transport=t}send(t,e,{body:n,request:r={}}={}){return this._transport.send("v1/accounts/"+encodeURIComponent(t)+"/access-tokens/"+encodeURIComponent(e),{...r,method:"DELETE",json:n})}};var T=class{constructor(t){this._transport=t}send(t,e,{request:n={}}={}){return this._transport.send("v1/accounts/"+encodeURIComponent(t)+"/access-tokens/"+encodeURIComponent(e),{...n,method:"GET"})}};var R=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/accounts/"+encodeURIComponent(t)+"/access-tokens",{...e,method:"GET"})}};var v=class{constructor(t){this._transport=t}get api(){return{get:new T(this._transport),list:new R(this._transport),create:new y(this._transport),delete:new S(this._transport)}}};var w=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/accounts/"+encodeURIComponent(t),{...e,method:"GET"})}};var F=class{constructor(t){this._transport=t}send(t,{body:e,request:n={}}){return this._transport.send("v1/accounts/"+encodeURIComponent(t),{...n,method:"PATCH",json:e})}};var A=class{constructor(t){this._transport=t}get api(){return{get:new w(this._transport),update:new F(this._transport)}}};var L=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/accounts/"+encodeURIComponent(t)+"/conversation-settings",{...e,method:"GET"})}};var U=class{constructor(t){this._transport=t}send(t,{body:e,request:n={}}){return this._transport.send("v1/accounts/"+encodeURIComponent(t)+"/conversation-settings",{...n,method:"PATCH",json:e})}};var N=class{constructor(t){this._transport=t}get api(){return{get:new L(this._transport),update:new U(this._transport)}}};var E=class{constructor(t){this._transport=t}send({limit:t,sort:e,request:n={}}={}){return this._transport.send("v1/actions",{...n,method:"GET",searchParams:[...this._transport.limitQuery(t),...this._transport.sortQuery(e)]})}};var G=class{constructor(t){this._transport=t}get api(){return{list:new E(this._transport)}}};var P=class{constructor(t){this._transport=t}send({body:t,request:e={}}){return this._transport.send("v1/boilerplates/categories",{...e,method:"POST",json:t})}};var q=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/boilerplates/categories/"+encodeURIComponent(t),{...e,method:"GET"})}};var I=class{constructor(t){this._transport=t}send({limit:t,include:e,request:n={}}={}){return this._transport.send("v1/boilerplates/categories",{...n,method:"GET",searchParams:[...this._transport.limitQuery(t),...this._transport.includeQuery(e)]})}};var B=class{constructor(t){this._transport=t}send(t,{body:e,request:n={}}){return this._transport.send("v1/boilerplates/categories/"+encodeURIComponent(t),{...n,method:"PATCH",json:e})}};var M=class{constructor(t){this._transport=t}send(t,{limit:e,request:n={}}={}){return this._transport.send("v1/boilerplates/categories/"+encodeURIComponent(t)+"/contents",{...n,method:"GET",searchParams:[...this._transport.limitQuery(e)]})}};var k=class{constructor(t){this._transport=t}get api(){return{get:new q(this._transport),list:new I(this._transport),create:new P(this._transport),update:new B(this._transport),boilerplate:{list:new M(this._transport)}}}};var j=class{constructor(t){this._transport=t}send({body:t,request:e={}}){return this._transport.send("v1/boilerplates/contents",{...e,method:"POST",json:t})}};var D=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/boilerplates/contents/"+encodeURIComponent(t),{...e,method:"GET"})}};var Q=class{constructor(t){this._transport=t}send({limit:t,query:e,request:n={}}={}){return this._transport.send("v1/boilerplates/contents",{...n,method:"GET",searchParams:[...this._transport.limitQuery(t),...this._transport.queryQuery(e)]})}};var H=class{constructor(t){this._transport=t}send(t,{body:e,request:n={}}){return this._transport.send("v1/boilerplates/contents/"+encodeURIComponent(t),{...n,method:"PATCH",json:e})}};var K=class{constructor(t){this._transport=t}get api(){return{get:new D(this._transport),list:new Q(this._transport),update:new H(this._transport),create:new j(this._transport)}}};var V=class{constructor(t){this._transport=t}send({body:t,request:e={}}){return this._transport.send("v1/channels",{...e,method:"POST",json:t})}};var W=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/channels/"+encodeURIComponent(t),{...e,method:"GET"})}};var Y=class{constructor(t){this._transport=t}send({limit:t,request:e={}}={}){return this._transport.send("v1/channels",{...e,method:"GET",searchParams:[...this._transport.limitQuery(t)]})}};var z=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/channels/"+encodeURIComponent(t)+"/meta-whatsapp/business-profile",{...e,method:"GET"})}};var me=require("zod"),$=class o{constructor(t){this._transport=t}static SCHEMA=me.z.object({overwrite:me.z.boolean().optional()});send(t,{body:e,request:n={}}){return this._transport.send("v1/channels/"+encodeURIComponent(t)+"/twilio-sendgrid/sync",{...n,method:"POST",json:o.SCHEMA.parse(e)})}};var J=class{constructor(t){this._transport=t}send(t,{body:e,request:n={}}){return this._transport.send("v1/channels/"+encodeURIComponent(t),{...n,method:"PATCH",json:e})}};var X=class{constructor(t){this._transport=t}send(t,{limit:e,request:n={}}={}){return this._transport.send("v1/channels/"+encodeURIComponent(t)+"/composition-sections",{...n,method:"GET",searchParams:[...this._transport.limitQuery(e)]})}};var Z=class{constructor(t){this._transport=t}send(t,{limit:e,include:n,request:r={}}={}){return this._transport.send("v1/channels/"+encodeURIComponent(t)+"/messages",{...r,method:"GET",searchParams:[...this._transport.limitQuery(e),...this._transport.includeQuery(n)]})}};var tt=class{constructor(t){this._transport=t}get api(){return{get:new W(this._transport),list:new Y(this._transport),update:new J(this._transport),create:new V(this._transport),compositionSection:{list:new X(this._transport)},message:{list:new Z(this._transport)},metaWhatsapp:{getBusinessProfile:new z(this._transport)},twilioSendgrid:{sync:new $(this._transport)}}}};var et=class{constructor(t){this._transport=t}send({body:t,request:e={}}){return this._transport.send("v1/composition-sections",{...e,method:"POST",json:t})}};var ot=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/composition-sections/"+encodeURIComponent(t),{...e,method:"GET"})}};var nt=class{constructor(t){this._transport=t}send({limit:t,request:e={}}={}){return this._transport.send("v1/composition-sections",{...e,method:"GET",searchParams:[...this._transport.limitQuery(t)]})}};var rt=class{constructor(t){this._transport=t}send(t,{body:e,request:n={}}){return this._transport.send("v1/composition-sections/"+encodeURIComponent(t),{...n,method:"PATCH",json:e})}};var st=class{constructor(t){this._transport=t}get api(){return{get:new ot(this._transport),list:new nt(this._transport),create:new et(this._transport),update:new rt(this._transport)}}};var it=class{constructor(t){this._transport=t}getRelativeURL({id:t,vcf:e={}}){let n=e.variant??"vcard",r=e.format??(n==="vcard"?"vcf":"json");return"v1/contacts/"+encodeURIComponent(t)+"/vcf?variant="+encodeURIComponent(n)+"&format="+encodeURIComponent(r)}getURL(t){return this._transport.getURL(this.getRelativeURL(t))}send(t){return this._transport.send(this.getURL(t),{method:"GET"})}};var at=class{constructor(t){this._transport=t}send({body:t,request:e={}}){return this._transport.send("v1/contacts",{...e,method:"POST",json:t})}};var pt=class{constructor(t){this._transport=t}send(t,{include:e,request:n={}}={}){return this._transport.send("v1/contacts/"+encodeURIComponent(t),{...n,method:"GET",searchParams:[...this._transport.includeQuery(e??{})]})}};var ct=class{constructor(t){this._transport=t}send({limit:t,query:e,request:n={}}={}){return this._transport.send("v1/contacts",{...n,method:"GET",searchParams:[...this._transport.limitQuery(t),...this._transport.queryQuery(e)]})}};var dt=class{constructor(t){this._transport=t}send(t,{body:e,request:n={}}){return this._transport.send("v1/contacts/"+encodeURIComponent(t),{...n,method:"PATCH",json:e})}};var lt=class{constructor(t){this._transport=t}send(t,{limit:e,request:n={}}={}){return this._transport.send("v1/contacts/"+encodeURIComponent(t)+"/conversations",{...n,method:"GET",searchParams:[...this._transport.limitQuery(e)]})}};var mt=class{constructor(t){this._transport=t}send(t,{limit:e,request:n={}}={}){return this._transport.send("v1/contacts/"+encodeURIComponent(t)+"/labels",{...n,method:"GET",searchParams:[...this._transport.limitQuery(e)]})}};var ut=class{constructor(t){this._transport=t}send(t,{body:e,request:n={}}){return this._transport.send("v1/contacts/"+encodeURIComponent(t)+"/notes",{...n,method:"POST",json:e})}};var ht=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/contacts/"+encodeURIComponent(t)+"/notes",{...e,method:"GET"})}};var ft=class{constructor(t){this._transport=t}send(t,{body:e,request:n={}}){return this._transport.send("v1/contacts/"+encodeURIComponent(t)+"/notification-subscriptions",{...n,method:"POST",json:e})}};var Ct=class{constructor(t){this._transport=t}get api(){return{get:new pt(this._transport),list:new ct(this._transport),update:new dt(this._transport),create:new at(this._transport),conversation:{list:new lt(this._transport)},label:{list:new mt(this._transport)},note:{list:new ht(this._transport),create:new ut(this._transport)},notificationSubscription:{create:new ft(this._transport)},vcf:{get:new it(this._transport)}}}};var gt=class{constructor(t){this._transport=t}send(t,{include:e,request:n={}}={}){return this._transport.send("v1/conversations/"+encodeURIComponent(t),{...n,method:"GET",searchParams:[...this._transport.includeQuery(e??{})]})}};var bt=class{constructor(t){this._transport=t}send({limit:t,filter:e,include:n,request:r={}}={}){return this._transport.send("v1/conversations",{...r,method:"GET",searchParams:[...this._transport.limitQuery(t),...e?[["filter",e]]:[],...this._transport.includeQuery(n??{})]})}};var Ot=class{constructor(t){this._transport=t}send(t,{body:e,request:n={}}){return this._transport.send("v1/conversations/"+encodeURIComponent(t),{...n,method:"PATCH",json:e})}};var xt=class{constructor(t){this._transport=t}send(t,{limit:e,request:n={}}={}){return this._transport.send("v1/conversations/"+encodeURIComponent(t)+"/labels",{...n,method:"GET",searchParams:[...this._transport.limitQuery(e)]})}};var _t=class{constructor(t){this._transport=t}send(t,{limit:e,include:n,request:r={}}={}){return this._transport.send("v1/conversations/"+encodeURIComponent(t)+"/messages",{...r,method:"GET",searchParams:[...this._transport.limitQuery(e),...this._transport.includeQuery(n??{})]})}};var u=class{constructor(t){this._transport=t}send(t,{body:e,request:n={}}){return this._transport.send("v1/conversations/"+encodeURIComponent(t)+"/notes",{...n,method:"POST",json:e})}};var yt=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/conversations/"+encodeURIComponent(t)+"/notes",{...e,method:"GET"})}};var St=class{constructor(t){this._transport=t}get api(){return{get:new gt(this._transport),list:new bt(this._transport),update:new Ot(this._transport),create:new u(this._transport),label:{list:new xt(this._transport)},message:{list:new _t(this._transport)},note:{list:new yt(this._transport),create:new u(this._transport)}}}};var Tt=class{constructor(t){this._transport=t}send(t,{limit:e,request:n={}}={}){return this._transport.send("v1/labels/"+encodeURIComponent(t)+"/contacts",{...n,method:"GET",searchParams:[...this._transport.limitQuery(e)]})}};var Rt=class{constructor(t){this._transport=t}send(t,{limit:e,request:n={}}={}){return this._transport.send("v1/labels/"+encodeURIComponent(t)+"/conversations",{...n,method:"GET",searchParams:[...this._transport.limitQuery(e)]})}};var vt=class{constructor(t){this._transport=t}send({body:t,request:e={}}){return this._transport.send("v1/labels",{...e,method:"POST",json:t})}};var wt=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/labels/"+encodeURIComponent(t),{...e,method:"DELETE"})}};var Ft=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/labels/"+encodeURIComponent(t),{...e,method:"GET"})}};var At=class{constructor(t){this._transport=t}send({limit:t,query:e,include:n,request:r={}}={}){return this._transport.send("v1/labels",{...r,method:"GET",searchParams:[...this._transport.limitQuery(t),...this._transport.queryQuery(e),...this._transport.includeQuery(n??{})]})}};var Lt=class{constructor(t){this._transport=t}send(t,{body:e,request:n={}}){return this._transport.send("v1/labels/"+encodeURIComponent(t),{...n,method:"PATCH",json:e})}};var Ut=class{constructor(t){this._transport=t}get api(){return{create:new vt(this._transport),get:new Ft(this._transport),list:new At(this._transport),update:new Lt(this._transport),delete:new wt(this._transport),contact:{list:new Tt(this._transport)},conversation:{list:new Rt(this._transport)}}}};var Nt=class{constructor(t){this._transport=t}send({limit:t,include:e,request:n={}}={}){return this._transport.send("v1/messages",{...n,method:"GET",searchParams:[...this._transport.limitQuery(t),...this._transport.includeQuery(e??{})]})}};var Et=class{constructor(t){this._transport=t}get api(){return{list:new Nt(this._transport)}}};var Gt=class{constructor(t){this._transport=t}send(t,{body:e,request:n={}}){return this._transport.send("v1/models/"+encodeURIComponent(t)+"/correction",{...n,method:"POST",json:e})}};var Pt=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/models/"+encodeURIComponent(t),{...e,method:"GET"})}};var qt=class{constructor(t){this._transport=t}send({request:t={}}={}){return this._transport.send("v1/models",{...t,method:"GET"})}};var It=class{constructor(t){this._transport=t}send(t,{body:e,request:n={}}){return this._transport.send("v1/models/"+encodeURIComponent(t)+"/response",{...n,method:"POST",timeout:12e4,json:e})}};var Bt=class{constructor(t){this._transport=t}get api(){return{get:new Pt(this._transport),list:new qt(this._transport),response:{create:new It(this._transport)},correction:{create:new Gt(this._transport)}}}};var Mt=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/notes/"+encodeURIComponent(t),{...e,method:"GET"})}};var kt=class{constructor(t){this._transport=t}send(t,{body:e,request:n={}}){return this._transport.send("v1/notes/"+encodeURIComponent(t),{...n,method:"PATCH",json:e})}};var jt=class{constructor(t){this._transport=t}get api(){return{get:new Mt(this._transport),update:new kt(this._transport)}}};var Dt=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/sources/"+encodeURIComponent(t),{...e,method:"GET"})}};var Qt=class{constructor(t){this._transport=t}send({category:t,request:e={}}={}){let n=[];if(t){let r=Array.isArray(t)?t:[t];for(let i of r)n.push(["category",i])}return this._transport.send("v1/sources",{...e,method:"GET",searchParams:n})}};var Ht=class{constructor(t){this._transport=t}get api(){return{get:new Dt(this._transport),list:new Qt(this._transport)}}};var Kt=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/channels/"+encodeURIComponent(t)+"/statistics/message-frequency",{...e,method:"GET"})}};var Vt=class{constructor(t){this._transport=t}send({request:t={}}={}){return this._transport.send("v1/statistics/message-frequency",{...t,method:"GET"})}};var Wt=class{constructor(t){this._transport=t}get api(){return{messageFrequency:new Vt(this._transport),channelMessageFrequency:new Kt(this._transport)}}};var Yt=class{constructor(t){this._transport=t}send({account:t,files:e,request:n={}}){let r=new FormData;for(let i of e)r.append("file",i);return this._transport.send("v1/uploads",{...n,method:"POST",body:r,searchParams:{account:t}})}};var zt=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/uploads/"+encodeURIComponent(t),{...e,method:"DELETE"})}};var $t=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/uploads/"+encodeURIComponent(t),{...e,method:"GET"})}};var Jt=class{constructor(t){this._transport=t}get api(){return{get:new $t(this._transport),create:new Yt(this._transport),delete:new zt(this._transport)}}};var Xt=class{constructor(t){this._transport=t}send({request:t={}}={}){return this._transport.send(".well-known/notifications",{...t,method:"GET"})}};var Zt=class{constructor(t){this._transport=t}get api(){return{notification:{get:new Xt(this._transport)}}}};var te=class o{static DEFAULT_BASE_URL=qe;static PublicAuthentication=d;static BasicAuthentication=h;static BearerAuthentication=f;_transport;_account;_accountAccessToken;_accountConversationSettings;_action;_boilerplateContent;_boilerplateCategory;_channel;_compositionSection;_contact;_conversation;_label;_message;_model;_note;_source;_statistics;_upload;_webhook;_wellKnown;constructor(t,{baseURL:e,...n}={}){this._transport=new x({requestFilterables:[new C,t],...n,baseURL:e?.toString()??o.getBaseURL()}),this._account=new A(this._transport),this._accountAccessToken=new v(this._transport),this._accountConversationSettings=new N(this._transport),this._action=new G(this._transport),this._boilerplateContent=new K(this._transport),this._boilerplateCategory=new k(this._transport),this._channel=new tt(this._transport),this._compositionSection=new st(this._transport),this._contact=new Ct(this._transport),this._conversation=new St(this._transport),this._label=new Ut(this._transport),this._message=new Et(this._transport),this._model=new Bt(this._transport),this._note=new jt(this._transport),this._source=new Ht(this._transport),this._statistics=new Wt(this._transport),this._upload=new Jt(this._transport),this._webhook=new _(this),this._wellKnown=new Zt(this._transport)}static getBaseURL(){return process.env[Pe]??this.DEFAULT_BASE_URL}get account(){return this._account.api}get accountAccessToken(){return this._accountAccessToken.api}get accountConversationSettings(){return this._accountConversationSettings.api}get action(){return this._action.api}get boilerplate(){return this._boilerplateContent.api}get boilerplateContent(){return this._boilerplateContent.api}get boilerplateCategory(){return this._boilerplateCategory.api}get channel(){return this._channel.api}get compositionSection(){return this._compositionSection.api}get contact(){return this._contact.api}get conversation(){return this._conversation.api}get label(){return this._label.api}get message(){return this._message.api}get model(){return this._model.api}get note(){return this._note.api}get source(){return this._source.api}get statistics(){return this._statistics.api}get upload(){return this._upload.api}get webhook(){return this._webhook}get wellKnown(){return this._wellKnown.api}};var ue=require("commander"),Me=require("ora");function he({client:o,ora:t}){let e=new ue.Command("actions").description("Actions");return e.addCommand(new ue.Command("list").description("List actions").action(async()=>{let n=await(0,Me.oraPromise)(()=>o.action.list.send().json(),{...t,text:"Finding actions"});console.log(n)})),e}var fe=require("commander"),ke=require("ora");function Ce({client:o,ora:t}){let e=new fe.Command("channels").description("Channels");return e.addCommand(new fe.Command("list").description("List channels").action(async()=>{let n=await(0,ke.oraPromise)(()=>o.channel.list.send().json(),{...t,text:"Finding channels"});console.log(n)})),e}var ee=require("commander"),ie=require("ora");function ge({client:o,ora:t}){let e=new ee.Command("contacts").description("Contacts");return e.addCommand(new ee.Command("get").description("Find contact").argument("<contact>","Contact ID").action(async n=>{let r=await(0,ie.oraPromise)(()=>o.contact.get.send(n).json(),{...t,text:"Finding contact"});console.log(r)})),e.addCommand(new ee.Command("list").description("List contacts").action(async()=>{let n=await(0,ie.oraPromise)(()=>o.contact.list.send().json(),{...t,text:"Finding contacts"});console.log(n)})),e.addCommand(new ee.Command("get-vcf").description("Export Contact as VCF").argument("<contact>","Contact ID").action(async n=>{let r=await(0,ie.oraPromise)(()=>o.contact.vcf.get.send({id:n}).response(),{...t,text:"Exporting contact"});console.log(r)})),e}var ae=require("commander"),be=require("ora");function Oe({client:o,ora:t}){let e=new ae.Command("conversations").description("Conversations");return e.addCommand(new ae.Command("get").description("Find conversation").argument("<conversation>","Conversation ID").action(async n=>{let r=await(0,be.oraPromise)(()=>o.conversation.get.send(n).json(),{...t,text:"Finding conversation"});console.log(r)})),e.addCommand(new ae.Command("list").description("List conversations").action(async()=>{let n=await(0,be.oraPromise)(()=>o.conversation.list.send().json(),{...t,text:"Finding conversations"});console.log(n)})),e}var oe=require("commander"),pe=require("ora");function xe({client:o,ora:t}){let e=new oe.Command("labels").description("Labels");return e.addCommand(new oe.Command("get").description("Find label").argument("<label>","Label ID").action(async n=>{let r=await(0,pe.oraPromise)(()=>o.label.get.send(n).json(),{...t,text:"Finding label"});console.log(r)})),e.addCommand(new oe.Command("list").description("List labels").action(async()=>{let n=await(0,pe.oraPromise)(()=>o.label.list.send().json(),{...t,text:"Finding labels"});console.log(n)})),e.addCommand(new oe.Command("conversations").description("Find label conversations").argument("<label>","Label ID").action(async n=>{let r=await(0,pe.oraPromise)(()=>o.label.conversation.list.send(n).json(),{...t,text:"Finding conversations"});console.log(r)})),e}var _e=require("commander"),je=require("ora");function ye({client:o,ora:t}){let e=new _e.Command("messages").description("Messages");return e.addCommand(new _e.Command("list").description("List messages").action(async()=>{let n=await(0,je.oraPromise)(()=>o.message.list.send().json(),{...t,text:"Finding messages"});console.log(n)})),e}var ce=require("commander"),Se=require("ora");function Te({client:o,ora:t}){let e=new ce.Command("models").description("Models");return e.addCommand(new ce.Command("get").description("Find model").argument("<model>","Model ID").action(async n=>{let r=await(0,Se.oraPromise)(()=>o.model.get.send(n).json(),{...t,text:"Finding model"});console.log(r)})),e.addCommand(new ce.Command("list").description("List models").action(async()=>{let n=await(0,Se.oraPromise)(()=>o.model.list.send().json(),{...t,text:"Finding models"});console.log(n)})),e}var de=require("commander"),Re=require("ora");function ve({client:o,ora:t}){let e=new de.Command("sources").description("Sources");return e.addCommand(new de.Command("get").description("Find source").argument("<source>","Source ID").action(async n=>{let r=await(0,Re.oraPromise)(()=>o.source.get.send(n).json(),{...t,text:"Finding source"});console.log(r)})),e.addCommand(new de.Command("list").description("List sources").action(async()=>{let n=await(0,Re.oraPromise)(()=>o.source.list.send().json(),{...t,text:"Finding sources"});console.log(n)})),e}var Qe=require("commander");var we=require("commander"),De=require("ora");function Fe({client:o,ora:t}){let e=new we.Command("notifications").description("Well-Known Notifications Details");return e.addCommand(new we.Command("get").description("Get Notifications Server Well-Known Info").action(async()=>{let n=await(0,De.oraPromise)(()=>o.wellKnown.notification.get.send().json(),{...t,text:"Finding Notifications Well-Known Info"});console.log(n)})),e}function Ae({client:o,ora:t}){let e=new Qe.Command("well-known").description("Well-Known Metadata & Info");return e.addCommand(Fe({client:o,ora:t})),e}var p={ora:{spinner:"simpleDotsScrolling"},client:new te(new d)},Ze=new He.Command("gds").description("Great Detail Support System").addCommand(he(p)).addCommand(Ce(p)).addCommand(ge(p)).addCommand(Oe(p)).addCommand(xe(p)).addCommand(ye(p)).addCommand(Te(p)).addCommand(ve(p)).addCommand(Ae(p)),to=Ze;
1
+ "use strict";var Ve=Object.create;var re=Object.defineProperty;var We=Object.getOwnPropertyDescriptor;var Ye=Object.getOwnPropertyNames;var ze=Object.getPrototypeOf,$e=Object.prototype.hasOwnProperty;var Je=(o,t)=>{for(var e in t)re(o,e,{get:t[e],enumerable:!0})},Le=(o,t,e,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of Ye(t))!$e.call(o,r)&&r!==e&&re(o,r,{get:()=>t[r],enumerable:!(n=We(t,r))||n.enumerable});return o};var Ue=(o,t,e)=>(e=o!=null?Ve(ze(o)):{},Le(t||!o||!o.__esModule?re(e,"default",{value:o,enumerable:!0}):e,o)),Xe=o=>Le(re({},"__esModule",{value:!0}),o);var eo={};Je(eo,{default:()=>to});module.exports=Xe(eo);var He=require("commander");var d=class{getHeaders(){return{}}};var Ne="SUPPORT_ACCESS_TOKEN",Ee="SUPPORT_KEY_NAME",Ge="SUPPORT_KEY_PASSWORD",le="SUPPORT_SIGNING_KEY",Pe="SUPPORT_BASE_URL";var f=class{name;#t;constructor({name:t=process.env[Ee],password:e=process.env[Ge]}={}){if(!t)throw new Error("Name option must be specified when using Basic Authentication");if(!e)throw new Error("Password option must be specified when using Basic Authentication");this.name=t,this.#t=e}getHeaders(){return{Authorization:`Basic ${btoa(this.name+":"+this.#t)}`}}};var C=class{#t;constructor({token:t=process.env[Ne]}={}){if(!t)throw new Error("Access Token option must be specified when using Token Authentication");this.#t=t}getHeaders(){return{Authorization:`Bearer ${this.#t}`}}};var qe="https://api.support.greatdetail.com",Ie={"X-Powered-By":"GDSupport/JavaScript"};var g=class o{constructor(t=o.STANDARD_HEADERS){this._standardHeaders=t}static STANDARD_HEADERS=Ie;async filter(){return{headers:this.getHeaders()}}getHeaders(){return this._standardHeaders}};var Be=Ue(require("is-network-error"),1),se=Ue(require("ky"),1);var a=class extends Error{static serverError(t){return new this("Server Error: "+t)}};var l=class extends a{};var b=class extends l{static unauthenticated(){return new this("An unauthenticated request occurred")}};var O=class extends l{static forbidden(){return new this("A forbidden request occurred")}};var c=class extends a{static notFound(t){return new this(`Record not found for request: ${t}`)}static forbiddenMethod(t,e){return new this(`Forbidden method for request: ${t} ${e}`)}static teapot(){return new this("I'm a teapot")}static rateLimited(){return new this("Request has been rate-limited")}};var x=class extends a{};var u=class extends a{static badRequest(){return new this("Bad request")}static unsupportedMediaType(){return new this("Unsupported Media Type")}};var _=class{client;options;constructor({baseURL:t,...e}){this.options={...e,baseURL:t},this.client=se.default.create({prefixUrl:this.options.baseURL,timeout:12e3,hooks:{beforeRequest:[n=>{for(let r of this.options.requestFilterables){let i=r.getHeaders();for(let[m,Ke]of Object.entries(i))n.headers.has(m)||n.headers.set(m,Ke)}}]}})}getURL(t){return new URL(t,this.options.baseURL).toString()}sortQuery(t){let e=[];if(t===void 0)return e;for(let[n,r]of Object.entries(t))r!==void 0&&e.push(["sort",r+n]);return e}limitQuery(t){let e=[];return t===void 0||e.push(["limit",t.toString()]),e}includeQuery(t){let e=[];if(t===void 0)return e;for(let n of Object.keys(t))e.push(["include",n]);return e}queryQuery(t){let e=[];return t===void 0||e.push(["query",t]),e}send(t,e={}){let n=this.client(t,e).catch(r=>{if((0,Be.default)(r))throw new x("A network error occurred",{cause:r});if(r instanceof se.HTTPError){let i=r.response.status;switch(console.error(JSON.stringify(r.response)),i){case 400:throw u.badRequest();case 401:throw b.unauthenticated();case 403:throw O.forbidden();case 404:throw c.notFound(t);case 405:throw c.forbiddenMethod(t,e.method??"GET");case 415:throw u.unsupportedMediaType();case 418:throw c.teapot();case 429:throw c.rateLimited()}if(i>=500&&i<600)throw a.serverError(i)}throw r});return{response:()=>n,json:async()=>(await n).json()}}};var s=require("zod");var y=class o{constructor(t){this._client=t}static SCHEMA=s.z.object({data:s.z.object({event:s.z.intersection(s.z.object({id:s.z.string(),createdAt:s.z.string().datetime()}),s.z.union([s.z.object({type:s.z.union([s.z.literal("account.created"),s.z.literal("account.updated")]),payload:s.z.object({account:s.z.string()})}),s.z.object({type:s.z.union([s.z.literal("accountAccessToken.created"),s.z.literal("accountAccessToken.deleted")]),payload:s.z.object({accountAccessToken:s.z.string()})}),s.z.object({type:s.z.union([s.z.literal("contact.created"),s.z.literal("contact.updated")]),payload:s.z.object({contact:s.z.string()})}),s.z.object({type:s.z.union([s.z.literal("conversation.created"),s.z.literal("conversation.updated"),s.z.literal("conversation.closed"),s.z.literal("conversation.received"),s.z.literal("conversation.resolved"),s.z.literal("conversation.sent")]),payload:s.z.object({conversation:s.z.string()})}),s.z.object({type:s.z.union([s.z.literal("message.created"),s.z.literal("message.updated"),s.z.literal("message.delivered"),s.z.literal("message.failed"),s.z.literal("message.read"),s.z.literal("message.received"),s.z.literal("message.sent")]),payload:s.z.object({message:s.z.string()})})]))})});async event({key:t=process.env[le],maxSignatures:e=3,request:n}){let r=n.headers["gds-signature"];if(t!==!1){if(t===void 0)throw new Error("Missing webhook signing key in process.env."+le);if(!r)throw new Error("Missing signature header");if(!this._verifySignature(t,n.body,Array.isArray(r)?r.slice(0,e):[r]))throw new Error("Untrusted signature")}let{data:i}=o.SCHEMA.parse(n.body);return{event:i.event}}async _verifySignature(t,e,n){let r=await crypto.subtle.importKey("raw",new TextEncoder().encode(t),{name:"HMAC",hash:"SHA-256"},!1,["sign","verify"]);for(let i of n)if(await crypto.subtle.verify("HMAC",r,new TextEncoder().encode(atob(i)),new TextEncoder().encode(JSON.stringify(e))))return!0;return!1}};var S=class{constructor(t){this._transport=t}send(t,{body:e={},request:n={}}={}){return this._transport.send("v1/accounts/"+encodeURIComponent(t)+"/access-tokens",{...n,method:"POST",json:e})}};var T=class{constructor(t){this._transport=t}send(t,e,{body:n,request:r={}}={}){return this._transport.send("v1/accounts/"+encodeURIComponent(t)+"/access-tokens/"+encodeURIComponent(e),{...r,method:"DELETE",json:n})}};var R=class{constructor(t){this._transport=t}send(t,e,{request:n={}}={}){return this._transport.send("v1/accounts/"+encodeURIComponent(t)+"/access-tokens/"+encodeURIComponent(e),{...n,method:"GET"})}};var v=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/accounts/"+encodeURIComponent(t)+"/access-tokens",{...e,method:"GET"})}};var w=class{constructor(t){this._transport=t}get api(){return{get:new R(this._transport),list:new v(this._transport),create:new S(this._transport),delete:new T(this._transport)}}};var F=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/accounts/"+encodeURIComponent(t),{...e,method:"GET"})}};var A=class{constructor(t){this._transport=t}send(t,{body:e,request:n={}}){return this._transport.send("v1/accounts/"+encodeURIComponent(t),{...n,method:"PATCH",json:e})}};var L=class{constructor(t){this._transport=t}get api(){return{get:new F(this._transport),update:new A(this._transport)}}};var U=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/accounts/"+encodeURIComponent(t)+"/conversation-settings",{...e,method:"GET"})}};var N=class{constructor(t){this._transport=t}send(t,{body:e,request:n={}}){return this._transport.send("v1/accounts/"+encodeURIComponent(t)+"/conversation-settings",{...n,method:"PATCH",json:e})}};var E=class{constructor(t){this._transport=t}get api(){return{get:new U(this._transport),update:new N(this._transport)}}};var G=class{constructor(t){this._transport=t}send({limit:t,sort:e,request:n={}}={}){return this._transport.send("v1/actions",{...n,method:"GET",searchParams:[...this._transport.limitQuery(t),...this._transport.sortQuery(e)]})}};var P=class{constructor(t){this._transport=t}get api(){return{list:new G(this._transport)}}};var q=class{constructor(t){this._transport=t}send({body:t,request:e={}}){return this._transport.send("v1/boilerplates/categories",{...e,method:"POST",json:t})}};var I=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/boilerplates/categories/"+encodeURIComponent(t),{...e,method:"GET"})}};var B=class{constructor(t){this._transport=t}send({limit:t,include:e,request:n={}}={}){return this._transport.send("v1/boilerplates/categories",{...n,method:"GET",searchParams:[...this._transport.limitQuery(t),...this._transport.includeQuery(e)]})}};var M=class{constructor(t){this._transport=t}send(t,{body:e,request:n={}}){return this._transport.send("v1/boilerplates/categories/"+encodeURIComponent(t),{...n,method:"PATCH",json:e})}};var k=class{constructor(t){this._transport=t}send(t,{limit:e,request:n={}}={}){return this._transport.send("v1/boilerplates/categories/"+encodeURIComponent(t)+"/contents",{...n,method:"GET",searchParams:[...this._transport.limitQuery(e)]})}};var j=class{constructor(t){this._transport=t}get api(){return{get:new I(this._transport),list:new B(this._transport),create:new q(this._transport),update:new M(this._transport),boilerplate:{list:new k(this._transport)}}}};var D=class{constructor(t){this._transport=t}send({body:t,request:e={}}){return this._transport.send("v1/boilerplates/contents",{...e,method:"POST",json:t})}};var Q=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/boilerplates/contents/"+encodeURIComponent(t),{...e,method:"GET"})}};var H=class{constructor(t){this._transport=t}send({limit:t,query:e,request:n={}}={}){return this._transport.send("v1/boilerplates/contents",{...n,method:"GET",searchParams:[...this._transport.limitQuery(t),...this._transport.queryQuery(e)]})}};var K=class{constructor(t){this._transport=t}send(t,{body:e,request:n={}}){return this._transport.send("v1/boilerplates/contents/"+encodeURIComponent(t),{...n,method:"PATCH",json:e})}};var V=class{constructor(t){this._transport=t}get api(){return{get:new Q(this._transport),list:new H(this._transport),update:new K(this._transport),create:new D(this._transport)}}};var W=class{constructor(t){this._transport=t}send({body:t,request:e={}}){return this._transport.send("v1/channels",{...e,method:"POST",json:t})}};var Y=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/channels/"+encodeURIComponent(t),{...e,method:"GET"})}};var z=class{constructor(t){this._transport=t}send({limit:t,request:e={}}={}){return this._transport.send("v1/channels",{...e,method:"GET",searchParams:[...this._transport.limitQuery(t)]})}};var $=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/channels/"+encodeURIComponent(t)+"/meta-whatsapp/business-profile",{...e,method:"GET"})}};var me=require("zod"),J=class o{constructor(t){this._transport=t}static SCHEMA=me.z.object({overwrite:me.z.boolean().optional()});send(t,{body:e,request:n={}}){return this._transport.send("v1/channels/"+encodeURIComponent(t)+"/twilio-sendgrid/sync",{...n,method:"POST",json:o.SCHEMA.parse(e)})}};var X=class{constructor(t){this._transport=t}send(t,{body:e,request:n={}}){return this._transport.send("v1/channels/"+encodeURIComponent(t),{...n,method:"PATCH",json:e})}};var Z=class{constructor(t){this._transport=t}send(t,{limit:e,request:n={}}={}){return this._transport.send("v1/channels/"+encodeURIComponent(t)+"/composition-sections",{...n,method:"GET",searchParams:[...this._transport.limitQuery(e)]})}};var tt=class{constructor(t){this._transport=t}send(t,{limit:e,include:n,request:r={}}={}){return this._transport.send("v1/channels/"+encodeURIComponent(t)+"/messages",{...r,method:"GET",searchParams:[...this._transport.limitQuery(e),...this._transport.includeQuery(n)]})}};var et=class{constructor(t){this._transport=t}get api(){return{get:new Y(this._transport),list:new z(this._transport),update:new X(this._transport),create:new W(this._transport),compositionSection:{list:new Z(this._transport)},message:{list:new tt(this._transport)},metaWhatsapp:{getBusinessProfile:new $(this._transport)},twilioSendgrid:{sync:new J(this._transport)}}}};var ot=class{constructor(t){this._transport=t}send({body:t,request:e={}}){return this._transport.send("v1/composition-sections",{...e,method:"POST",json:t})}};var nt=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/composition-sections/"+encodeURIComponent(t),{...e,method:"GET"})}};var rt=class{constructor(t){this._transport=t}send({limit:t,request:e={}}={}){return this._transport.send("v1/composition-sections",{...e,method:"GET",searchParams:[...this._transport.limitQuery(t)]})}};var st=class{constructor(t){this._transport=t}send(t,{body:e,request:n={}}){return this._transport.send("v1/composition-sections/"+encodeURIComponent(t),{...n,method:"PATCH",json:e})}};var it=class{constructor(t){this._transport=t}get api(){return{get:new nt(this._transport),list:new rt(this._transport),create:new ot(this._transport),update:new st(this._transport)}}};var at=class{constructor(t){this._transport=t}getRelativeURL({id:t,vcf:e={}}){let n=e.variant??"vcard",r=e.format??(n==="vcard"?"vcf":"json");return"v1/contacts/"+encodeURIComponent(t)+"/vcf?variant="+encodeURIComponent(n)+"&format="+encodeURIComponent(r)}getURL(t){return this._transport.getURL(this.getRelativeURL(t))}send(t){return this._transport.send(this.getURL(t),{method:"GET"})}};var pt=class{constructor(t){this._transport=t}send({body:t,request:e={}}){return this._transport.send("v1/contacts",{...e,method:"POST",json:t})}};var ct=class{constructor(t){this._transport=t}send(t,{include:e,request:n={}}={}){return this._transport.send("v1/contacts/"+encodeURIComponent(t),{...n,method:"GET",searchParams:[...this._transport.includeQuery(e??{})]})}};var dt=class{constructor(t){this._transport=t}send({limit:t,query:e,request:n={}}={}){return this._transport.send("v1/contacts",{...n,method:"GET",searchParams:[...this._transport.limitQuery(t),...this._transport.queryQuery(e)]})}};var lt=class{constructor(t){this._transport=t}send(t,{body:e,request:n={}}){return this._transport.send("v1/contacts/"+encodeURIComponent(t),{...n,method:"PATCH",json:e})}};var mt=class{constructor(t){this._transport=t}send(t,{limit:e,request:n={}}={}){return this._transport.send("v1/contacts/"+encodeURIComponent(t)+"/conversations",{...n,method:"GET",searchParams:[...this._transport.limitQuery(e)]})}};var ut=class{constructor(t){this._transport=t}send(t,{limit:e,request:n={}}={}){return this._transport.send("v1/contacts/"+encodeURIComponent(t)+"/labels",{...n,method:"GET",searchParams:[...this._transport.limitQuery(e)]})}};var ht=class{constructor(t){this._transport=t}send(t,{body:e,request:n={}}){return this._transport.send("v1/contacts/"+encodeURIComponent(t)+"/notes",{...n,method:"POST",json:e})}};var ft=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/contacts/"+encodeURIComponent(t)+"/notes",{...e,method:"GET"})}};var Ct=class{constructor(t){this._transport=t}send(t,{body:e,request:n={}}){return this._transport.send("v1/contacts/"+encodeURIComponent(t)+"/notification-subscriptions",{...n,method:"POST",json:e})}};var gt=class{constructor(t){this._transport=t}get api(){return{get:new ct(this._transport),list:new dt(this._transport),update:new lt(this._transport),create:new pt(this._transport),conversation:{list:new mt(this._transport)},label:{list:new ut(this._transport)},note:{list:new ft(this._transport),create:new ht(this._transport)},notificationSubscription:{create:new Ct(this._transport)},vcf:{get:new at(this._transport)}}}};var bt=class{constructor(t){this._transport=t}send(t,{include:e,request:n={}}={}){return this._transport.send("v1/conversations/"+encodeURIComponent(t),{...n,method:"GET",searchParams:[...this._transport.includeQuery(e??{})]})}};var Ot=class{constructor(t){this._transport=t}send({limit:t,filter:e,include:n,request:r={}}={}){return this._transport.send("v1/conversations",{...r,method:"GET",searchParams:[...this._transport.limitQuery(t),...e?[["filter",e]]:[],...this._transport.includeQuery(n??{})]})}};var xt=class{constructor(t){this._transport=t}send(t,{body:e,request:n={}}){return this._transport.send("v1/conversations/"+encodeURIComponent(t),{...n,method:"PATCH",json:e})}};var _t=class{constructor(t){this._transport=t}send(t,{limit:e,request:n={}}={}){return this._transport.send("v1/conversations/"+encodeURIComponent(t)+"/labels",{...n,method:"GET",searchParams:[...this._transport.limitQuery(e)]})}};var yt=class{constructor(t){this._transport=t}send(t,{limit:e,include:n,request:r={}}={}){return this._transport.send("v1/conversations/"+encodeURIComponent(t)+"/messages",{...r,method:"GET",searchParams:[...this._transport.limitQuery(e),...this._transport.includeQuery(n??{})]})}};var h=class{constructor(t){this._transport=t}send(t,{body:e,request:n={}}){return this._transport.send("v1/conversations/"+encodeURIComponent(t)+"/notes",{...n,method:"POST",json:e})}};var St=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/conversations/"+encodeURIComponent(t)+"/notes",{...e,method:"GET"})}};var Tt=class{constructor(t){this._transport=t}get api(){return{get:new bt(this._transport),list:new Ot(this._transport),update:new xt(this._transport),create:new h(this._transport),label:{list:new _t(this._transport)},message:{list:new yt(this._transport)},note:{list:new St(this._transport),create:new h(this._transport)}}}};var Rt=class{constructor(t){this._transport=t}send(t,{limit:e,request:n={}}={}){return this._transport.send("v1/labels/"+encodeURIComponent(t)+"/contacts",{...n,method:"GET",searchParams:[...this._transport.limitQuery(e)]})}};var vt=class{constructor(t){this._transport=t}send(t,{limit:e,request:n={}}={}){return this._transport.send("v1/labels/"+encodeURIComponent(t)+"/conversations",{...n,method:"GET",searchParams:[...this._transport.limitQuery(e)]})}};var wt=class{constructor(t){this._transport=t}send({body:t,request:e={}}){return this._transport.send("v1/labels",{...e,method:"POST",json:t})}};var Ft=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/labels/"+encodeURIComponent(t),{...e,method:"DELETE"})}};var At=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/labels/"+encodeURIComponent(t),{...e,method:"GET"})}};var Lt=class{constructor(t){this._transport=t}send({limit:t,query:e,include:n,request:r={}}={}){return this._transport.send("v1/labels",{...r,method:"GET",searchParams:[...this._transport.limitQuery(t),...this._transport.queryQuery(e),...this._transport.includeQuery(n??{})]})}};var Ut=class{constructor(t){this._transport=t}send(t,{body:e,request:n={}}){return this._transport.send("v1/labels/"+encodeURIComponent(t),{...n,method:"PATCH",json:e})}};var Nt=class{constructor(t){this._transport=t}get api(){return{create:new wt(this._transport),get:new At(this._transport),list:new Lt(this._transport),update:new Ut(this._transport),delete:new Ft(this._transport),contact:{list:new Rt(this._transport)},conversation:{list:new vt(this._transport)}}}};var Et=class{constructor(t){this._transport=t}send({limit:t,include:e,request:n={}}={}){return this._transport.send("v1/messages",{...n,method:"GET",searchParams:[...this._transport.limitQuery(t),...this._transport.includeQuery(e??{})]})}};var Gt=class{constructor(t){this._transport=t}get api(){return{list:new Et(this._transport)}}};var Pt=class{constructor(t){this._transport=t}send(t,{body:e,request:n={}}){return this._transport.send("v1/models/"+encodeURIComponent(t)+"/correction",{...n,method:"POST",json:e})}};var qt=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/models/"+encodeURIComponent(t),{...e,method:"GET"})}};var It=class{constructor(t){this._transport=t}send({request:t={}}={}){return this._transport.send("v1/models",{...t,method:"GET"})}};var Bt=class{constructor(t){this._transport=t}send(t,{body:e,request:n={}}){return this._transport.send("v1/models/"+encodeURIComponent(t)+"/response",{...n,method:"POST",timeout:12e4,json:e})}};var Mt=class{constructor(t){this._transport=t}get api(){return{get:new qt(this._transport),list:new It(this._transport),response:{create:new Bt(this._transport)},correction:{create:new Pt(this._transport)}}}};var kt=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/notes/"+encodeURIComponent(t),{...e,method:"GET"})}};var jt=class{constructor(t){this._transport=t}send(t,{body:e,request:n={}}){return this._transport.send("v1/notes/"+encodeURIComponent(t),{...n,method:"PATCH",json:e})}};var Dt=class{constructor(t){this._transport=t}get api(){return{get:new kt(this._transport),update:new jt(this._transport)}}};var Qt=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/sources/"+encodeURIComponent(t),{...e,method:"GET"})}};var Ht=class{constructor(t){this._transport=t}send({featured:t,category:e,request:n={}}={}){let r=[];if(e){let i=Array.isArray(e)?e:[e];for(let m of i)r.push(["category",m])}return t!==void 0&&r.push(["featured",String(t)]),this._transport.send("v1/sources",{...n,method:"GET",searchParams:r})}};var Kt=class{constructor(t){this._transport=t}get api(){return{get:new Qt(this._transport),list:new Ht(this._transport)}}};var Vt=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/channels/"+encodeURIComponent(t)+"/statistics/message-frequency",{...e,method:"GET"})}};var Wt=class{constructor(t){this._transport=t}send({request:t={}}={}){return this._transport.send("v1/statistics/message-frequency",{...t,method:"GET"})}};var Yt=class{constructor(t){this._transport=t}get api(){return{messageFrequency:new Wt(this._transport),channelMessageFrequency:new Vt(this._transport)}}};var zt=class{constructor(t){this._transport=t}send({account:t,files:e,request:n={}}){let r=new FormData;for(let i of e)r.append("file",i);return this._transport.send("v1/uploads",{...n,method:"POST",body:r,searchParams:{account:t}})}};var $t=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/uploads/"+encodeURIComponent(t),{...e,method:"DELETE"})}};var Jt=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/uploads/"+encodeURIComponent(t),{...e,method:"GET"})}};var Xt=class{constructor(t){this._transport=t}get api(){return{get:new Jt(this._transport),create:new zt(this._transport),delete:new $t(this._transport)}}};var Zt=class{constructor(t){this._transport=t}send({request:t={}}={}){return this._transport.send(".well-known/notifications",{...t,method:"GET"})}};var te=class{constructor(t){this._transport=t}get api(){return{notification:{get:new Zt(this._transport)}}}};var ee=class o{static DEFAULT_BASE_URL=qe;static PublicAuthentication=d;static BasicAuthentication=f;static BearerAuthentication=C;_transport;_account;_accountAccessToken;_accountConversationSettings;_action;_boilerplateContent;_boilerplateCategory;_channel;_compositionSection;_contact;_conversation;_label;_message;_model;_note;_source;_statistics;_upload;_webhook;_wellKnown;constructor(t,{baseURL:e,...n}={}){this._transport=new _({requestFilterables:[new g,t],...n,baseURL:e?.toString()??o.getBaseURL()}),this._account=new L(this._transport),this._accountAccessToken=new w(this._transport),this._accountConversationSettings=new E(this._transport),this._action=new P(this._transport),this._boilerplateContent=new V(this._transport),this._boilerplateCategory=new j(this._transport),this._channel=new et(this._transport),this._compositionSection=new it(this._transport),this._contact=new gt(this._transport),this._conversation=new Tt(this._transport),this._label=new Nt(this._transport),this._message=new Gt(this._transport),this._model=new Mt(this._transport),this._note=new Dt(this._transport),this._source=new Kt(this._transport),this._statistics=new Yt(this._transport),this._upload=new Xt(this._transport),this._webhook=new y(this),this._wellKnown=new te(this._transport)}static getBaseURL(){return process.env[Pe]??this.DEFAULT_BASE_URL}get account(){return this._account.api}get accountAccessToken(){return this._accountAccessToken.api}get accountConversationSettings(){return this._accountConversationSettings.api}get action(){return this._action.api}get boilerplate(){return this._boilerplateContent.api}get boilerplateContent(){return this._boilerplateContent.api}get boilerplateCategory(){return this._boilerplateCategory.api}get channel(){return this._channel.api}get compositionSection(){return this._compositionSection.api}get contact(){return this._contact.api}get conversation(){return this._conversation.api}get label(){return this._label.api}get message(){return this._message.api}get model(){return this._model.api}get note(){return this._note.api}get source(){return this._source.api}get statistics(){return this._statistics.api}get upload(){return this._upload.api}get webhook(){return this._webhook}get wellKnown(){return this._wellKnown.api}};var ue=require("commander"),Me=require("ora");function he({client:o,ora:t}){let e=new ue.Command("actions").description("Actions");return e.addCommand(new ue.Command("list").description("List actions").action(async()=>{let n=await(0,Me.oraPromise)(()=>o.action.list.send().json(),{...t,text:"Finding actions"});console.log(n)})),e}var fe=require("commander"),ke=require("ora");function Ce({client:o,ora:t}){let e=new fe.Command("channels").description("Channels");return e.addCommand(new fe.Command("list").description("List channels").action(async()=>{let n=await(0,ke.oraPromise)(()=>o.channel.list.send().json(),{...t,text:"Finding channels"});console.log(n)})),e}var oe=require("commander"),ie=require("ora");function ge({client:o,ora:t}){let e=new oe.Command("contacts").description("Contacts");return e.addCommand(new oe.Command("get").description("Find contact").argument("<contact>","Contact ID").action(async n=>{let r=await(0,ie.oraPromise)(()=>o.contact.get.send(n).json(),{...t,text:"Finding contact"});console.log(r)})),e.addCommand(new oe.Command("list").description("List contacts").action(async()=>{let n=await(0,ie.oraPromise)(()=>o.contact.list.send().json(),{...t,text:"Finding contacts"});console.log(n)})),e.addCommand(new oe.Command("get-vcf").description("Export Contact as VCF").argument("<contact>","Contact ID").action(async n=>{let r=await(0,ie.oraPromise)(()=>o.contact.vcf.get.send({id:n}).response(),{...t,text:"Exporting contact"});console.log(r)})),e}var ae=require("commander"),be=require("ora");function Oe({client:o,ora:t}){let e=new ae.Command("conversations").description("Conversations");return e.addCommand(new ae.Command("get").description("Find conversation").argument("<conversation>","Conversation ID").action(async n=>{let r=await(0,be.oraPromise)(()=>o.conversation.get.send(n).json(),{...t,text:"Finding conversation"});console.log(r)})),e.addCommand(new ae.Command("list").description("List conversations").action(async()=>{let n=await(0,be.oraPromise)(()=>o.conversation.list.send().json(),{...t,text:"Finding conversations"});console.log(n)})),e}var ne=require("commander"),pe=require("ora");function xe({client:o,ora:t}){let e=new ne.Command("labels").description("Labels");return e.addCommand(new ne.Command("get").description("Find label").argument("<label>","Label ID").action(async n=>{let r=await(0,pe.oraPromise)(()=>o.label.get.send(n).json(),{...t,text:"Finding label"});console.log(r)})),e.addCommand(new ne.Command("list").description("List labels").action(async()=>{let n=await(0,pe.oraPromise)(()=>o.label.list.send().json(),{...t,text:"Finding labels"});console.log(n)})),e.addCommand(new ne.Command("conversations").description("Find label conversations").argument("<label>","Label ID").action(async n=>{let r=await(0,pe.oraPromise)(()=>o.label.conversation.list.send(n).json(),{...t,text:"Finding conversations"});console.log(r)})),e}var _e=require("commander"),je=require("ora");function ye({client:o,ora:t}){let e=new _e.Command("messages").description("Messages");return e.addCommand(new _e.Command("list").description("List messages").action(async()=>{let n=await(0,je.oraPromise)(()=>o.message.list.send().json(),{...t,text:"Finding messages"});console.log(n)})),e}var ce=require("commander"),Se=require("ora");function Te({client:o,ora:t}){let e=new ce.Command("models").description("Models");return e.addCommand(new ce.Command("get").description("Find model").argument("<model>","Model ID").action(async n=>{let r=await(0,Se.oraPromise)(()=>o.model.get.send(n).json(),{...t,text:"Finding model"});console.log(r)})),e.addCommand(new ce.Command("list").description("List models").action(async()=>{let n=await(0,Se.oraPromise)(()=>o.model.list.send().json(),{...t,text:"Finding models"});console.log(n)})),e}var de=require("commander"),Re=require("ora");function ve({client:o,ora:t}){let e=new de.Command("sources").description("Sources");return e.addCommand(new de.Command("get").description("Find source").argument("<source>","Source ID").action(async n=>{let r=await(0,Re.oraPromise)(()=>o.source.get.send(n).json(),{...t,text:"Finding source"});console.log(r)})),e.addCommand(new de.Command("list").description("List sources").action(async()=>{let n=await(0,Re.oraPromise)(()=>o.source.list.send().json(),{...t,text:"Finding sources"});console.log(n)})),e}var Qe=require("commander");var we=require("commander"),De=require("ora");function Fe({client:o,ora:t}){let e=new we.Command("notifications").description("Well-Known Notifications Details");return e.addCommand(new we.Command("get").description("Get Notifications Server Well-Known Info").action(async()=>{let n=await(0,De.oraPromise)(()=>o.wellKnown.notification.get.send().json(),{...t,text:"Finding Notifications Well-Known Info"});console.log(n)})),e}function Ae({client:o,ora:t}){let e=new Qe.Command("well-known").description("Well-Known Metadata & Info");return e.addCommand(Fe({client:o,ora:t})),e}var p={ora:{spinner:"simpleDotsScrolling"},client:new ee(new d)},Ze=new He.Command("gds").description("Great Detail Support System").addCommand(he(p)).addCommand(Ce(p)).addCommand(ge(p)).addCommand(Oe(p)).addCommand(xe(p)).addCommand(ye(p)).addCommand(Te(p)).addCommand(ve(p)).addCommand(Ae(p)),to=Ze;
@@ -1,5 +1,5 @@
1
1
  import { Command } from 'commander';
2
- import { C as Client } from '../index-CGgn2yv_.cjs';
2
+ import { C as Client } from '../index-D-0Ds3Qp.cjs';
3
3
  import { Options as Options$1 } from 'ora';
4
4
  import 'ky';
5
5
  import 'zod';
@@ -1,5 +1,5 @@
1
1
  import { Command } from 'commander';
2
- import { C as Client } from '../index-CGgn2yv_.js';
2
+ import { C as Client } from '../index-D-0Ds3Qp.js';
3
3
  import { Options as Options$1 } from 'ora';
4
4
  import 'ky';
5
5
  import 'zod';
package/dist/cli/index.js CHANGED
@@ -1 +1 @@
1
- import{a}from"../chunk-25FMSKID.js";import"../chunk-HR2YP6TH.js";export{a as default};
1
+ import{a}from"../chunk-XAL5XNRO.js";import"../chunk-AOL7NCTI.js";export{a as default};
package/dist/cli.cjs CHANGED
@@ -1,2 +1,2 @@
1
1
  #!/usr/bin/env node
2
- "use strict";var Ve=Object.create;var Ae=Object.defineProperty;var We=Object.getOwnPropertyDescriptor;var Ye=Object.getOwnPropertyNames;var ze=Object.getPrototypeOf,$e=Object.prototype.hasOwnProperty;var Je=(o,t,e,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of Ye(t))!$e.call(o,r)&&r!==e&&Ae(o,r,{get:()=>t[r],enumerable:!(n=We(t,r))||n.enumerable});return o};var Le=(o,t,e)=>(e=o!=null?Ve(ze(o)):{},Je(t||!o||!o.__esModule?Ae(e,"default",{value:o,enumerable:!0}):e,o));var Qe=require("commander");var d=class{getHeaders(){return{}}};var Ue="SUPPORT_ACCESS_TOKEN",Ne="SUPPORT_KEY_NAME",Ee="SUPPORT_KEY_PASSWORD",de="SUPPORT_SIGNING_KEY",Ge="SUPPORT_BASE_URL";var h=class{name;#t;constructor({name:t=process.env[Ne],password:e=process.env[Ee]}={}){if(!t)throw new Error("Name option must be specified when using Basic Authentication");if(!e)throw new Error("Password option must be specified when using Basic Authentication");this.name=t,this.#t=e}getHeaders(){return{Authorization:`Basic ${btoa(this.name+":"+this.#t)}`}}};var f=class{#t;constructor({token:t=process.env[Ue]}={}){if(!t)throw new Error("Access Token option must be specified when using Token Authentication");this.#t=t}getHeaders(){return{Authorization:`Bearer ${this.#t}`}}};var Pe="https://api.support.greatdetail.com",qe={"X-Powered-By":"GDSupport/JavaScript"};var C=class o{constructor(t=o.STANDARD_HEADERS){this._standardHeaders=t}static STANDARD_HEADERS=qe;async filter(){return{headers:this.getHeaders()}}getHeaders(){return this._standardHeaders}};var Ie=Le(require("is-network-error"),1),re=Le(require("ky"),1);var a=class extends Error{static serverError(t){return new this("Server Error: "+t)}};var l=class extends a{};var g=class extends l{static unauthenticated(){return new this("An unauthenticated request occurred")}};var b=class extends l{static forbidden(){return new this("A forbidden request occurred")}};var c=class extends a{static notFound(t){return new this(`Record not found for request: ${t}`)}static forbiddenMethod(t,e){return new this(`Forbidden method for request: ${t} ${e}`)}static teapot(){return new this("I'm a teapot")}static rateLimited(){return new this("Request has been rate-limited")}};var O=class extends a{};var m=class extends a{static badRequest(){return new this("Bad request")}static unsupportedMediaType(){return new this("Unsupported Media Type")}};var x=class{client;options;constructor({baseURL:t,...e}){this.options={...e,baseURL:t},this.client=re.default.create({prefixUrl:this.options.baseURL,timeout:12e3,hooks:{beforeRequest:[n=>{for(let r of this.options.requestFilterables){let i=r.getHeaders();for(let[ne,Ke]of Object.entries(i))n.headers.has(ne)||n.headers.set(ne,Ke)}}]}})}getURL(t){return new URL(t,this.options.baseURL).toString()}sortQuery(t){let e=[];if(t===void 0)return e;for(let[n,r]of Object.entries(t))r!==void 0&&e.push(["sort",r+n]);return e}limitQuery(t){let e=[];return t===void 0||e.push(["limit",t.toString()]),e}includeQuery(t){let e=[];if(t===void 0)return e;for(let n of Object.keys(t))e.push(["include",n]);return e}queryQuery(t){let e=[];return t===void 0||e.push(["query",t]),e}send(t,e={}){let n=this.client(t,e).catch(r=>{if((0,Ie.default)(r))throw new O("A network error occurred",{cause:r});if(r instanceof re.HTTPError){let i=r.response.status;switch(console.error(JSON.stringify(r.response)),i){case 400:throw m.badRequest();case 401:throw g.unauthenticated();case 403:throw b.forbidden();case 404:throw c.notFound(t);case 405:throw c.forbiddenMethod(t,e.method??"GET");case 415:throw m.unsupportedMediaType();case 418:throw c.teapot();case 429:throw c.rateLimited()}if(i>=500&&i<600)throw a.serverError(i)}throw r});return{response:()=>n,json:async()=>(await n).json()}}};var s=require("zod");var y=class o{constructor(t){this._client=t}static SCHEMA=s.z.object({data:s.z.object({event:s.z.intersection(s.z.object({id:s.z.string(),createdAt:s.z.string().datetime()}),s.z.union([s.z.object({type:s.z.union([s.z.literal("account.created"),s.z.literal("account.updated")]),payload:s.z.object({account:s.z.string()})}),s.z.object({type:s.z.union([s.z.literal("accountAccessToken.created"),s.z.literal("accountAccessToken.deleted")]),payload:s.z.object({accountAccessToken:s.z.string()})}),s.z.object({type:s.z.union([s.z.literal("contact.created"),s.z.literal("contact.updated")]),payload:s.z.object({contact:s.z.string()})}),s.z.object({type:s.z.union([s.z.literal("conversation.created"),s.z.literal("conversation.updated"),s.z.literal("conversation.closed"),s.z.literal("conversation.received"),s.z.literal("conversation.resolved"),s.z.literal("conversation.sent")]),payload:s.z.object({conversation:s.z.string()})}),s.z.object({type:s.z.union([s.z.literal("message.created"),s.z.literal("message.updated"),s.z.literal("message.delivered"),s.z.literal("message.failed"),s.z.literal("message.read"),s.z.literal("message.received"),s.z.literal("message.sent")]),payload:s.z.object({message:s.z.string()})})]))})});async event({key:t=process.env[de],maxSignatures:e=3,request:n}){let r=n.headers["gds-signature"];if(t!==!1){if(t===void 0)throw new Error("Missing webhook signing key in process.env."+de);if(!r)throw new Error("Missing signature header");if(!this._verifySignature(t,n.body,Array.isArray(r)?r.slice(0,e):[r]))throw new Error("Untrusted signature")}let{data:i}=o.SCHEMA.parse(n.body);return{event:i.event}}async _verifySignature(t,e,n){let r=await crypto.subtle.importKey("raw",new TextEncoder().encode(t),{name:"HMAC",hash:"SHA-256"},!1,["sign","verify"]);for(let i of n)if(await crypto.subtle.verify("HMAC",r,new TextEncoder().encode(atob(i)),new TextEncoder().encode(JSON.stringify(e))))return!0;return!1}};var _=class{constructor(t){this._transport=t}send(t,{body:e={},request:n={}}={}){return this._transport.send("v1/accounts/"+encodeURIComponent(t)+"/access-tokens",{...n,method:"POST",json:e})}};var S=class{constructor(t){this._transport=t}send(t,e,{body:n,request:r={}}={}){return this._transport.send("v1/accounts/"+encodeURIComponent(t)+"/access-tokens/"+encodeURIComponent(e),{...r,method:"DELETE",json:n})}};var T=class{constructor(t){this._transport=t}send(t,e,{request:n={}}={}){return this._transport.send("v1/accounts/"+encodeURIComponent(t)+"/access-tokens/"+encodeURIComponent(e),{...n,method:"GET"})}};var R=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/accounts/"+encodeURIComponent(t)+"/access-tokens",{...e,method:"GET"})}};var v=class{constructor(t){this._transport=t}get api(){return{get:new T(this._transport),list:new R(this._transport),create:new _(this._transport),delete:new S(this._transport)}}};var w=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/accounts/"+encodeURIComponent(t),{...e,method:"GET"})}};var F=class{constructor(t){this._transport=t}send(t,{body:e,request:n={}}){return this._transport.send("v1/accounts/"+encodeURIComponent(t),{...n,method:"PATCH",json:e})}};var A=class{constructor(t){this._transport=t}get api(){return{get:new w(this._transport),update:new F(this._transport)}}};var L=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/accounts/"+encodeURIComponent(t)+"/conversation-settings",{...e,method:"GET"})}};var U=class{constructor(t){this._transport=t}send(t,{body:e,request:n={}}){return this._transport.send("v1/accounts/"+encodeURIComponent(t)+"/conversation-settings",{...n,method:"PATCH",json:e})}};var N=class{constructor(t){this._transport=t}get api(){return{get:new L(this._transport),update:new U(this._transport)}}};var E=class{constructor(t){this._transport=t}send({limit:t,sort:e,request:n={}}={}){return this._transport.send("v1/actions",{...n,method:"GET",searchParams:[...this._transport.limitQuery(t),...this._transport.sortQuery(e)]})}};var G=class{constructor(t){this._transport=t}get api(){return{list:new E(this._transport)}}};var P=class{constructor(t){this._transport=t}send({body:t,request:e={}}){return this._transport.send("v1/boilerplates/categories",{...e,method:"POST",json:t})}};var q=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/boilerplates/categories/"+encodeURIComponent(t),{...e,method:"GET"})}};var I=class{constructor(t){this._transport=t}send({limit:t,include:e,request:n={}}={}){return this._transport.send("v1/boilerplates/categories",{...n,method:"GET",searchParams:[...this._transport.limitQuery(t),...this._transport.includeQuery(e)]})}};var B=class{constructor(t){this._transport=t}send(t,{body:e,request:n={}}){return this._transport.send("v1/boilerplates/categories/"+encodeURIComponent(t),{...n,method:"PATCH",json:e})}};var M=class{constructor(t){this._transport=t}send(t,{limit:e,request:n={}}={}){return this._transport.send("v1/boilerplates/categories/"+encodeURIComponent(t)+"/contents",{...n,method:"GET",searchParams:[...this._transport.limitQuery(e)]})}};var k=class{constructor(t){this._transport=t}get api(){return{get:new q(this._transport),list:new I(this._transport),create:new P(this._transport),update:new B(this._transport),boilerplate:{list:new M(this._transport)}}}};var j=class{constructor(t){this._transport=t}send({body:t,request:e={}}){return this._transport.send("v1/boilerplates/contents",{...e,method:"POST",json:t})}};var D=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/boilerplates/contents/"+encodeURIComponent(t),{...e,method:"GET"})}};var Q=class{constructor(t){this._transport=t}send({limit:t,query:e,request:n={}}={}){return this._transport.send("v1/boilerplates/contents",{...n,method:"GET",searchParams:[...this._transport.limitQuery(t),...this._transport.queryQuery(e)]})}};var H=class{constructor(t){this._transport=t}send(t,{body:e,request:n={}}){return this._transport.send("v1/boilerplates/contents/"+encodeURIComponent(t),{...n,method:"PATCH",json:e})}};var K=class{constructor(t){this._transport=t}get api(){return{get:new D(this._transport),list:new Q(this._transport),update:new H(this._transport),create:new j(this._transport)}}};var V=class{constructor(t){this._transport=t}send({body:t,request:e={}}){return this._transport.send("v1/channels",{...e,method:"POST",json:t})}};var W=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/channels/"+encodeURIComponent(t),{...e,method:"GET"})}};var Y=class{constructor(t){this._transport=t}send({limit:t,request:e={}}={}){return this._transport.send("v1/channels",{...e,method:"GET",searchParams:[...this._transport.limitQuery(t)]})}};var z=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/channels/"+encodeURIComponent(t)+"/meta-whatsapp/business-profile",{...e,method:"GET"})}};var le=require("zod"),$=class o{constructor(t){this._transport=t}static SCHEMA=le.z.object({overwrite:le.z.boolean().optional()});send(t,{body:e,request:n={}}){return this._transport.send("v1/channels/"+encodeURIComponent(t)+"/twilio-sendgrid/sync",{...n,method:"POST",json:o.SCHEMA.parse(e)})}};var J=class{constructor(t){this._transport=t}send(t,{body:e,request:n={}}){return this._transport.send("v1/channels/"+encodeURIComponent(t),{...n,method:"PATCH",json:e})}};var X=class{constructor(t){this._transport=t}send(t,{limit:e,request:n={}}={}){return this._transport.send("v1/channels/"+encodeURIComponent(t)+"/composition-sections",{...n,method:"GET",searchParams:[...this._transport.limitQuery(e)]})}};var Z=class{constructor(t){this._transport=t}send(t,{limit:e,include:n,request:r={}}={}){return this._transport.send("v1/channels/"+encodeURIComponent(t)+"/messages",{...r,method:"GET",searchParams:[...this._transport.limitQuery(e),...this._transport.includeQuery(n)]})}};var tt=class{constructor(t){this._transport=t}get api(){return{get:new W(this._transport),list:new Y(this._transport),update:new J(this._transport),create:new V(this._transport),compositionSection:{list:new X(this._transport)},message:{list:new Z(this._transport)},metaWhatsapp:{getBusinessProfile:new z(this._transport)},twilioSendgrid:{sync:new $(this._transport)}}}};var et=class{constructor(t){this._transport=t}send({body:t,request:e={}}){return this._transport.send("v1/composition-sections",{...e,method:"POST",json:t})}};var ot=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/composition-sections/"+encodeURIComponent(t),{...e,method:"GET"})}};var nt=class{constructor(t){this._transport=t}send({limit:t,request:e={}}={}){return this._transport.send("v1/composition-sections",{...e,method:"GET",searchParams:[...this._transport.limitQuery(t)]})}};var rt=class{constructor(t){this._transport=t}send(t,{body:e,request:n={}}){return this._transport.send("v1/composition-sections/"+encodeURIComponent(t),{...n,method:"PATCH",json:e})}};var st=class{constructor(t){this._transport=t}get api(){return{get:new ot(this._transport),list:new nt(this._transport),create:new et(this._transport),update:new rt(this._transport)}}};var it=class{constructor(t){this._transport=t}getRelativeURL({id:t,vcf:e={}}){let n=e.variant??"vcard",r=e.format??(n==="vcard"?"vcf":"json");return"v1/contacts/"+encodeURIComponent(t)+"/vcf?variant="+encodeURIComponent(n)+"&format="+encodeURIComponent(r)}getURL(t){return this._transport.getURL(this.getRelativeURL(t))}send(t){return this._transport.send(this.getURL(t),{method:"GET"})}};var at=class{constructor(t){this._transport=t}send({body:t,request:e={}}){return this._transport.send("v1/contacts",{...e,method:"POST",json:t})}};var pt=class{constructor(t){this._transport=t}send(t,{include:e,request:n={}}={}){return this._transport.send("v1/contacts/"+encodeURIComponent(t),{...n,method:"GET",searchParams:[...this._transport.includeQuery(e??{})]})}};var ct=class{constructor(t){this._transport=t}send({limit:t,query:e,request:n={}}={}){return this._transport.send("v1/contacts",{...n,method:"GET",searchParams:[...this._transport.limitQuery(t),...this._transport.queryQuery(e)]})}};var dt=class{constructor(t){this._transport=t}send(t,{body:e,request:n={}}){return this._transport.send("v1/contacts/"+encodeURIComponent(t),{...n,method:"PATCH",json:e})}};var lt=class{constructor(t){this._transport=t}send(t,{limit:e,request:n={}}={}){return this._transport.send("v1/contacts/"+encodeURIComponent(t)+"/conversations",{...n,method:"GET",searchParams:[...this._transport.limitQuery(e)]})}};var mt=class{constructor(t){this._transport=t}send(t,{limit:e,request:n={}}={}){return this._transport.send("v1/contacts/"+encodeURIComponent(t)+"/labels",{...n,method:"GET",searchParams:[...this._transport.limitQuery(e)]})}};var ut=class{constructor(t){this._transport=t}send(t,{body:e,request:n={}}){return this._transport.send("v1/contacts/"+encodeURIComponent(t)+"/notes",{...n,method:"POST",json:e})}};var ht=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/contacts/"+encodeURIComponent(t)+"/notes",{...e,method:"GET"})}};var ft=class{constructor(t){this._transport=t}send(t,{body:e,request:n={}}){return this._transport.send("v1/contacts/"+encodeURIComponent(t)+"/notification-subscriptions",{...n,method:"POST",json:e})}};var Ct=class{constructor(t){this._transport=t}get api(){return{get:new pt(this._transport),list:new ct(this._transport),update:new dt(this._transport),create:new at(this._transport),conversation:{list:new lt(this._transport)},label:{list:new mt(this._transport)},note:{list:new ht(this._transport),create:new ut(this._transport)},notificationSubscription:{create:new ft(this._transport)},vcf:{get:new it(this._transport)}}}};var gt=class{constructor(t){this._transport=t}send(t,{include:e,request:n={}}={}){return this._transport.send("v1/conversations/"+encodeURIComponent(t),{...n,method:"GET",searchParams:[...this._transport.includeQuery(e??{})]})}};var bt=class{constructor(t){this._transport=t}send({limit:t,filter:e,include:n,request:r={}}={}){return this._transport.send("v1/conversations",{...r,method:"GET",searchParams:[...this._transport.limitQuery(t),...e?[["filter",e]]:[],...this._transport.includeQuery(n??{})]})}};var Ot=class{constructor(t){this._transport=t}send(t,{body:e,request:n={}}){return this._transport.send("v1/conversations/"+encodeURIComponent(t),{...n,method:"PATCH",json:e})}};var xt=class{constructor(t){this._transport=t}send(t,{limit:e,request:n={}}={}){return this._transport.send("v1/conversations/"+encodeURIComponent(t)+"/labels",{...n,method:"GET",searchParams:[...this._transport.limitQuery(e)]})}};var yt=class{constructor(t){this._transport=t}send(t,{limit:e,include:n,request:r={}}={}){return this._transport.send("v1/conversations/"+encodeURIComponent(t)+"/messages",{...r,method:"GET",searchParams:[...this._transport.limitQuery(e),...this._transport.includeQuery(n??{})]})}};var u=class{constructor(t){this._transport=t}send(t,{body:e,request:n={}}){return this._transport.send("v1/conversations/"+encodeURIComponent(t)+"/notes",{...n,method:"POST",json:e})}};var _t=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/conversations/"+encodeURIComponent(t)+"/notes",{...e,method:"GET"})}};var St=class{constructor(t){this._transport=t}get api(){return{get:new gt(this._transport),list:new bt(this._transport),update:new Ot(this._transport),create:new u(this._transport),label:{list:new xt(this._transport)},message:{list:new yt(this._transport)},note:{list:new _t(this._transport),create:new u(this._transport)}}}};var Tt=class{constructor(t){this._transport=t}send(t,{limit:e,request:n={}}={}){return this._transport.send("v1/labels/"+encodeURIComponent(t)+"/contacts",{...n,method:"GET",searchParams:[...this._transport.limitQuery(e)]})}};var Rt=class{constructor(t){this._transport=t}send(t,{limit:e,request:n={}}={}){return this._transport.send("v1/labels/"+encodeURIComponent(t)+"/conversations",{...n,method:"GET",searchParams:[...this._transport.limitQuery(e)]})}};var vt=class{constructor(t){this._transport=t}send({body:t,request:e={}}){return this._transport.send("v1/labels",{...e,method:"POST",json:t})}};var wt=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/labels/"+encodeURIComponent(t),{...e,method:"DELETE"})}};var Ft=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/labels/"+encodeURIComponent(t),{...e,method:"GET"})}};var At=class{constructor(t){this._transport=t}send({limit:t,query:e,include:n,request:r={}}={}){return this._transport.send("v1/labels",{...r,method:"GET",searchParams:[...this._transport.limitQuery(t),...this._transport.queryQuery(e),...this._transport.includeQuery(n??{})]})}};var Lt=class{constructor(t){this._transport=t}send(t,{body:e,request:n={}}){return this._transport.send("v1/labels/"+encodeURIComponent(t),{...n,method:"PATCH",json:e})}};var Ut=class{constructor(t){this._transport=t}get api(){return{create:new vt(this._transport),get:new Ft(this._transport),list:new At(this._transport),update:new Lt(this._transport),delete:new wt(this._transport),contact:{list:new Tt(this._transport)},conversation:{list:new Rt(this._transport)}}}};var Nt=class{constructor(t){this._transport=t}send({limit:t,include:e,request:n={}}={}){return this._transport.send("v1/messages",{...n,method:"GET",searchParams:[...this._transport.limitQuery(t),...this._transport.includeQuery(e??{})]})}};var Et=class{constructor(t){this._transport=t}get api(){return{list:new Nt(this._transport)}}};var Gt=class{constructor(t){this._transport=t}send(t,{body:e,request:n={}}){return this._transport.send("v1/models/"+encodeURIComponent(t)+"/correction",{...n,method:"POST",json:e})}};var Pt=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/models/"+encodeURIComponent(t),{...e,method:"GET"})}};var qt=class{constructor(t){this._transport=t}send({request:t={}}={}){return this._transport.send("v1/models",{...t,method:"GET"})}};var It=class{constructor(t){this._transport=t}send(t,{body:e,request:n={}}){return this._transport.send("v1/models/"+encodeURIComponent(t)+"/response",{...n,method:"POST",timeout:12e4,json:e})}};var Bt=class{constructor(t){this._transport=t}get api(){return{get:new Pt(this._transport),list:new qt(this._transport),response:{create:new It(this._transport)},correction:{create:new Gt(this._transport)}}}};var Mt=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/notes/"+encodeURIComponent(t),{...e,method:"GET"})}};var kt=class{constructor(t){this._transport=t}send(t,{body:e,request:n={}}){return this._transport.send("v1/notes/"+encodeURIComponent(t),{...n,method:"PATCH",json:e})}};var jt=class{constructor(t){this._transport=t}get api(){return{get:new Mt(this._transport),update:new kt(this._transport)}}};var Dt=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/sources/"+encodeURIComponent(t),{...e,method:"GET"})}};var Qt=class{constructor(t){this._transport=t}send({category:t,request:e={}}={}){let n=[];if(t){let r=Array.isArray(t)?t:[t];for(let i of r)n.push(["category",i])}return this._transport.send("v1/sources",{...e,method:"GET",searchParams:n})}};var Ht=class{constructor(t){this._transport=t}get api(){return{get:new Dt(this._transport),list:new Qt(this._transport)}}};var Kt=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/channels/"+encodeURIComponent(t)+"/statistics/message-frequency",{...e,method:"GET"})}};var Vt=class{constructor(t){this._transport=t}send({request:t={}}={}){return this._transport.send("v1/statistics/message-frequency",{...t,method:"GET"})}};var Wt=class{constructor(t){this._transport=t}get api(){return{messageFrequency:new Vt(this._transport),channelMessageFrequency:new Kt(this._transport)}}};var Yt=class{constructor(t){this._transport=t}send({account:t,files:e,request:n={}}){let r=new FormData;for(let i of e)r.append("file",i);return this._transport.send("v1/uploads",{...n,method:"POST",body:r,searchParams:{account:t}})}};var zt=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/uploads/"+encodeURIComponent(t),{...e,method:"DELETE"})}};var $t=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/uploads/"+encodeURIComponent(t),{...e,method:"GET"})}};var Jt=class{constructor(t){this._transport=t}get api(){return{get:new $t(this._transport),create:new Yt(this._transport),delete:new zt(this._transport)}}};var Xt=class{constructor(t){this._transport=t}send({request:t={}}={}){return this._transport.send(".well-known/notifications",{...t,method:"GET"})}};var Zt=class{constructor(t){this._transport=t}get api(){return{notification:{get:new Xt(this._transport)}}}};var te=class o{static DEFAULT_BASE_URL=Pe;static PublicAuthentication=d;static BasicAuthentication=h;static BearerAuthentication=f;_transport;_account;_accountAccessToken;_accountConversationSettings;_action;_boilerplateContent;_boilerplateCategory;_channel;_compositionSection;_contact;_conversation;_label;_message;_model;_note;_source;_statistics;_upload;_webhook;_wellKnown;constructor(t,{baseURL:e,...n}={}){this._transport=new x({requestFilterables:[new C,t],...n,baseURL:e?.toString()??o.getBaseURL()}),this._account=new A(this._transport),this._accountAccessToken=new v(this._transport),this._accountConversationSettings=new N(this._transport),this._action=new G(this._transport),this._boilerplateContent=new K(this._transport),this._boilerplateCategory=new k(this._transport),this._channel=new tt(this._transport),this._compositionSection=new st(this._transport),this._contact=new Ct(this._transport),this._conversation=new St(this._transport),this._label=new Ut(this._transport),this._message=new Et(this._transport),this._model=new Bt(this._transport),this._note=new jt(this._transport),this._source=new Ht(this._transport),this._statistics=new Wt(this._transport),this._upload=new Jt(this._transport),this._webhook=new y(this),this._wellKnown=new Zt(this._transport)}static getBaseURL(){return process.env[Ge]??this.DEFAULT_BASE_URL}get account(){return this._account.api}get accountAccessToken(){return this._accountAccessToken.api}get accountConversationSettings(){return this._accountConversationSettings.api}get action(){return this._action.api}get boilerplate(){return this._boilerplateContent.api}get boilerplateContent(){return this._boilerplateContent.api}get boilerplateCategory(){return this._boilerplateCategory.api}get channel(){return this._channel.api}get compositionSection(){return this._compositionSection.api}get contact(){return this._contact.api}get conversation(){return this._conversation.api}get label(){return this._label.api}get message(){return this._message.api}get model(){return this._model.api}get note(){return this._note.api}get source(){return this._source.api}get statistics(){return this._statistics.api}get upload(){return this._upload.api}get webhook(){return this._webhook}get wellKnown(){return this._wellKnown.api}};var me=require("commander"),Be=require("ora");function ue({client:o,ora:t}){let e=new me.Command("actions").description("Actions");return e.addCommand(new me.Command("list").description("List actions").action(async()=>{let n=await(0,Be.oraPromise)(()=>o.action.list.send().json(),{...t,text:"Finding actions"});console.log(n)})),e}var he=require("commander"),Me=require("ora");function fe({client:o,ora:t}){let e=new he.Command("channels").description("Channels");return e.addCommand(new he.Command("list").description("List channels").action(async()=>{let n=await(0,Me.oraPromise)(()=>o.channel.list.send().json(),{...t,text:"Finding channels"});console.log(n)})),e}var ee=require("commander"),se=require("ora");function Ce({client:o,ora:t}){let e=new ee.Command("contacts").description("Contacts");return e.addCommand(new ee.Command("get").description("Find contact").argument("<contact>","Contact ID").action(async n=>{let r=await(0,se.oraPromise)(()=>o.contact.get.send(n).json(),{...t,text:"Finding contact"});console.log(r)})),e.addCommand(new ee.Command("list").description("List contacts").action(async()=>{let n=await(0,se.oraPromise)(()=>o.contact.list.send().json(),{...t,text:"Finding contacts"});console.log(n)})),e.addCommand(new ee.Command("get-vcf").description("Export Contact as VCF").argument("<contact>","Contact ID").action(async n=>{let r=await(0,se.oraPromise)(()=>o.contact.vcf.get.send({id:n}).response(),{...t,text:"Exporting contact"});console.log(r)})),e}var ie=require("commander"),ge=require("ora");function be({client:o,ora:t}){let e=new ie.Command("conversations").description("Conversations");return e.addCommand(new ie.Command("get").description("Find conversation").argument("<conversation>","Conversation ID").action(async n=>{let r=await(0,ge.oraPromise)(()=>o.conversation.get.send(n).json(),{...t,text:"Finding conversation"});console.log(r)})),e.addCommand(new ie.Command("list").description("List conversations").action(async()=>{let n=await(0,ge.oraPromise)(()=>o.conversation.list.send().json(),{...t,text:"Finding conversations"});console.log(n)})),e}var oe=require("commander"),ae=require("ora");function Oe({client:o,ora:t}){let e=new oe.Command("labels").description("Labels");return e.addCommand(new oe.Command("get").description("Find label").argument("<label>","Label ID").action(async n=>{let r=await(0,ae.oraPromise)(()=>o.label.get.send(n).json(),{...t,text:"Finding label"});console.log(r)})),e.addCommand(new oe.Command("list").description("List labels").action(async()=>{let n=await(0,ae.oraPromise)(()=>o.label.list.send().json(),{...t,text:"Finding labels"});console.log(n)})),e.addCommand(new oe.Command("conversations").description("Find label conversations").argument("<label>","Label ID").action(async n=>{let r=await(0,ae.oraPromise)(()=>o.label.conversation.list.send(n).json(),{...t,text:"Finding conversations"});console.log(r)})),e}var xe=require("commander"),ke=require("ora");function ye({client:o,ora:t}){let e=new xe.Command("messages").description("Messages");return e.addCommand(new xe.Command("list").description("List messages").action(async()=>{let n=await(0,ke.oraPromise)(()=>o.message.list.send().json(),{...t,text:"Finding messages"});console.log(n)})),e}var pe=require("commander"),_e=require("ora");function Se({client:o,ora:t}){let e=new pe.Command("models").description("Models");return e.addCommand(new pe.Command("get").description("Find model").argument("<model>","Model ID").action(async n=>{let r=await(0,_e.oraPromise)(()=>o.model.get.send(n).json(),{...t,text:"Finding model"});console.log(r)})),e.addCommand(new pe.Command("list").description("List models").action(async()=>{let n=await(0,_e.oraPromise)(()=>o.model.list.send().json(),{...t,text:"Finding models"});console.log(n)})),e}var ce=require("commander"),Te=require("ora");function Re({client:o,ora:t}){let e=new ce.Command("sources").description("Sources");return e.addCommand(new ce.Command("get").description("Find source").argument("<source>","Source ID").action(async n=>{let r=await(0,Te.oraPromise)(()=>o.source.get.send(n).json(),{...t,text:"Finding source"});console.log(r)})),e.addCommand(new ce.Command("list").description("List sources").action(async()=>{let n=await(0,Te.oraPromise)(()=>o.source.list.send().json(),{...t,text:"Finding sources"});console.log(n)})),e}var De=require("commander");var ve=require("commander"),je=require("ora");function we({client:o,ora:t}){let e=new ve.Command("notifications").description("Well-Known Notifications Details");return e.addCommand(new ve.Command("get").description("Get Notifications Server Well-Known Info").action(async()=>{let n=await(0,je.oraPromise)(()=>o.wellKnown.notification.get.send().json(),{...t,text:"Finding Notifications Well-Known Info"});console.log(n)})),e}function Fe({client:o,ora:t}){let e=new De.Command("well-known").description("Well-Known Metadata & Info");return e.addCommand(we({client:o,ora:t})),e}var p={ora:{spinner:"simpleDotsScrolling"},client:new te(new d)},Xe=new Qe.Command("gds").description("Great Detail Support System").addCommand(ue(p)).addCommand(fe(p)).addCommand(Ce(p)).addCommand(be(p)).addCommand(Oe(p)).addCommand(ye(p)).addCommand(Se(p)).addCommand(Re(p)).addCommand(Fe(p)),He=Xe;He.parseAsync(process.argv);
2
+ "use strict";var Ve=Object.create;var Ae=Object.defineProperty;var We=Object.getOwnPropertyDescriptor;var Ye=Object.getOwnPropertyNames;var ze=Object.getPrototypeOf,$e=Object.prototype.hasOwnProperty;var Je=(o,t,e,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of Ye(t))!$e.call(o,r)&&r!==e&&Ae(o,r,{get:()=>t[r],enumerable:!(n=We(t,r))||n.enumerable});return o};var Le=(o,t,e)=>(e=o!=null?Ve(ze(o)):{},Je(t||!o||!o.__esModule?Ae(e,"default",{value:o,enumerable:!0}):e,o));var Qe=require("commander");var d=class{getHeaders(){return{}}};var Ue="SUPPORT_ACCESS_TOKEN",Ne="SUPPORT_KEY_NAME",Ee="SUPPORT_KEY_PASSWORD",de="SUPPORT_SIGNING_KEY",Ge="SUPPORT_BASE_URL";var f=class{name;#t;constructor({name:t=process.env[Ne],password:e=process.env[Ee]}={}){if(!t)throw new Error("Name option must be specified when using Basic Authentication");if(!e)throw new Error("Password option must be specified when using Basic Authentication");this.name=t,this.#t=e}getHeaders(){return{Authorization:`Basic ${btoa(this.name+":"+this.#t)}`}}};var C=class{#t;constructor({token:t=process.env[Ue]}={}){if(!t)throw new Error("Access Token option must be specified when using Token Authentication");this.#t=t}getHeaders(){return{Authorization:`Bearer ${this.#t}`}}};var Pe="https://api.support.greatdetail.com",qe={"X-Powered-By":"GDSupport/JavaScript"};var g=class o{constructor(t=o.STANDARD_HEADERS){this._standardHeaders=t}static STANDARD_HEADERS=qe;async filter(){return{headers:this.getHeaders()}}getHeaders(){return this._standardHeaders}};var Ie=Le(require("is-network-error"),1),re=Le(require("ky"),1);var a=class extends Error{static serverError(t){return new this("Server Error: "+t)}};var l=class extends a{};var b=class extends l{static unauthenticated(){return new this("An unauthenticated request occurred")}};var O=class extends l{static forbidden(){return new this("A forbidden request occurred")}};var c=class extends a{static notFound(t){return new this(`Record not found for request: ${t}`)}static forbiddenMethod(t,e){return new this(`Forbidden method for request: ${t} ${e}`)}static teapot(){return new this("I'm a teapot")}static rateLimited(){return new this("Request has been rate-limited")}};var x=class extends a{};var u=class extends a{static badRequest(){return new this("Bad request")}static unsupportedMediaType(){return new this("Unsupported Media Type")}};var y=class{client;options;constructor({baseURL:t,...e}){this.options={...e,baseURL:t},this.client=re.default.create({prefixUrl:this.options.baseURL,timeout:12e3,hooks:{beforeRequest:[n=>{for(let r of this.options.requestFilterables){let i=r.getHeaders();for(let[m,Ke]of Object.entries(i))n.headers.has(m)||n.headers.set(m,Ke)}}]}})}getURL(t){return new URL(t,this.options.baseURL).toString()}sortQuery(t){let e=[];if(t===void 0)return e;for(let[n,r]of Object.entries(t))r!==void 0&&e.push(["sort",r+n]);return e}limitQuery(t){let e=[];return t===void 0||e.push(["limit",t.toString()]),e}includeQuery(t){let e=[];if(t===void 0)return e;for(let n of Object.keys(t))e.push(["include",n]);return e}queryQuery(t){let e=[];return t===void 0||e.push(["query",t]),e}send(t,e={}){let n=this.client(t,e).catch(r=>{if((0,Ie.default)(r))throw new x("A network error occurred",{cause:r});if(r instanceof re.HTTPError){let i=r.response.status;switch(console.error(JSON.stringify(r.response)),i){case 400:throw u.badRequest();case 401:throw b.unauthenticated();case 403:throw O.forbidden();case 404:throw c.notFound(t);case 405:throw c.forbiddenMethod(t,e.method??"GET");case 415:throw u.unsupportedMediaType();case 418:throw c.teapot();case 429:throw c.rateLimited()}if(i>=500&&i<600)throw a.serverError(i)}throw r});return{response:()=>n,json:async()=>(await n).json()}}};var s=require("zod");var _=class o{constructor(t){this._client=t}static SCHEMA=s.z.object({data:s.z.object({event:s.z.intersection(s.z.object({id:s.z.string(),createdAt:s.z.string().datetime()}),s.z.union([s.z.object({type:s.z.union([s.z.literal("account.created"),s.z.literal("account.updated")]),payload:s.z.object({account:s.z.string()})}),s.z.object({type:s.z.union([s.z.literal("accountAccessToken.created"),s.z.literal("accountAccessToken.deleted")]),payload:s.z.object({accountAccessToken:s.z.string()})}),s.z.object({type:s.z.union([s.z.literal("contact.created"),s.z.literal("contact.updated")]),payload:s.z.object({contact:s.z.string()})}),s.z.object({type:s.z.union([s.z.literal("conversation.created"),s.z.literal("conversation.updated"),s.z.literal("conversation.closed"),s.z.literal("conversation.received"),s.z.literal("conversation.resolved"),s.z.literal("conversation.sent")]),payload:s.z.object({conversation:s.z.string()})}),s.z.object({type:s.z.union([s.z.literal("message.created"),s.z.literal("message.updated"),s.z.literal("message.delivered"),s.z.literal("message.failed"),s.z.literal("message.read"),s.z.literal("message.received"),s.z.literal("message.sent")]),payload:s.z.object({message:s.z.string()})})]))})});async event({key:t=process.env[de],maxSignatures:e=3,request:n}){let r=n.headers["gds-signature"];if(t!==!1){if(t===void 0)throw new Error("Missing webhook signing key in process.env."+de);if(!r)throw new Error("Missing signature header");if(!this._verifySignature(t,n.body,Array.isArray(r)?r.slice(0,e):[r]))throw new Error("Untrusted signature")}let{data:i}=o.SCHEMA.parse(n.body);return{event:i.event}}async _verifySignature(t,e,n){let r=await crypto.subtle.importKey("raw",new TextEncoder().encode(t),{name:"HMAC",hash:"SHA-256"},!1,["sign","verify"]);for(let i of n)if(await crypto.subtle.verify("HMAC",r,new TextEncoder().encode(atob(i)),new TextEncoder().encode(JSON.stringify(e))))return!0;return!1}};var S=class{constructor(t){this._transport=t}send(t,{body:e={},request:n={}}={}){return this._transport.send("v1/accounts/"+encodeURIComponent(t)+"/access-tokens",{...n,method:"POST",json:e})}};var T=class{constructor(t){this._transport=t}send(t,e,{body:n,request:r={}}={}){return this._transport.send("v1/accounts/"+encodeURIComponent(t)+"/access-tokens/"+encodeURIComponent(e),{...r,method:"DELETE",json:n})}};var R=class{constructor(t){this._transport=t}send(t,e,{request:n={}}={}){return this._transport.send("v1/accounts/"+encodeURIComponent(t)+"/access-tokens/"+encodeURIComponent(e),{...n,method:"GET"})}};var v=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/accounts/"+encodeURIComponent(t)+"/access-tokens",{...e,method:"GET"})}};var w=class{constructor(t){this._transport=t}get api(){return{get:new R(this._transport),list:new v(this._transport),create:new S(this._transport),delete:new T(this._transport)}}};var F=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/accounts/"+encodeURIComponent(t),{...e,method:"GET"})}};var A=class{constructor(t){this._transport=t}send(t,{body:e,request:n={}}){return this._transport.send("v1/accounts/"+encodeURIComponent(t),{...n,method:"PATCH",json:e})}};var L=class{constructor(t){this._transport=t}get api(){return{get:new F(this._transport),update:new A(this._transport)}}};var U=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/accounts/"+encodeURIComponent(t)+"/conversation-settings",{...e,method:"GET"})}};var N=class{constructor(t){this._transport=t}send(t,{body:e,request:n={}}){return this._transport.send("v1/accounts/"+encodeURIComponent(t)+"/conversation-settings",{...n,method:"PATCH",json:e})}};var E=class{constructor(t){this._transport=t}get api(){return{get:new U(this._transport),update:new N(this._transport)}}};var G=class{constructor(t){this._transport=t}send({limit:t,sort:e,request:n={}}={}){return this._transport.send("v1/actions",{...n,method:"GET",searchParams:[...this._transport.limitQuery(t),...this._transport.sortQuery(e)]})}};var P=class{constructor(t){this._transport=t}get api(){return{list:new G(this._transport)}}};var q=class{constructor(t){this._transport=t}send({body:t,request:e={}}){return this._transport.send("v1/boilerplates/categories",{...e,method:"POST",json:t})}};var I=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/boilerplates/categories/"+encodeURIComponent(t),{...e,method:"GET"})}};var B=class{constructor(t){this._transport=t}send({limit:t,include:e,request:n={}}={}){return this._transport.send("v1/boilerplates/categories",{...n,method:"GET",searchParams:[...this._transport.limitQuery(t),...this._transport.includeQuery(e)]})}};var M=class{constructor(t){this._transport=t}send(t,{body:e,request:n={}}){return this._transport.send("v1/boilerplates/categories/"+encodeURIComponent(t),{...n,method:"PATCH",json:e})}};var k=class{constructor(t){this._transport=t}send(t,{limit:e,request:n={}}={}){return this._transport.send("v1/boilerplates/categories/"+encodeURIComponent(t)+"/contents",{...n,method:"GET",searchParams:[...this._transport.limitQuery(e)]})}};var j=class{constructor(t){this._transport=t}get api(){return{get:new I(this._transport),list:new B(this._transport),create:new q(this._transport),update:new M(this._transport),boilerplate:{list:new k(this._transport)}}}};var D=class{constructor(t){this._transport=t}send({body:t,request:e={}}){return this._transport.send("v1/boilerplates/contents",{...e,method:"POST",json:t})}};var Q=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/boilerplates/contents/"+encodeURIComponent(t),{...e,method:"GET"})}};var H=class{constructor(t){this._transport=t}send({limit:t,query:e,request:n={}}={}){return this._transport.send("v1/boilerplates/contents",{...n,method:"GET",searchParams:[...this._transport.limitQuery(t),...this._transport.queryQuery(e)]})}};var K=class{constructor(t){this._transport=t}send(t,{body:e,request:n={}}){return this._transport.send("v1/boilerplates/contents/"+encodeURIComponent(t),{...n,method:"PATCH",json:e})}};var V=class{constructor(t){this._transport=t}get api(){return{get:new Q(this._transport),list:new H(this._transport),update:new K(this._transport),create:new D(this._transport)}}};var W=class{constructor(t){this._transport=t}send({body:t,request:e={}}){return this._transport.send("v1/channels",{...e,method:"POST",json:t})}};var Y=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/channels/"+encodeURIComponent(t),{...e,method:"GET"})}};var z=class{constructor(t){this._transport=t}send({limit:t,request:e={}}={}){return this._transport.send("v1/channels",{...e,method:"GET",searchParams:[...this._transport.limitQuery(t)]})}};var $=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/channels/"+encodeURIComponent(t)+"/meta-whatsapp/business-profile",{...e,method:"GET"})}};var le=require("zod"),J=class o{constructor(t){this._transport=t}static SCHEMA=le.z.object({overwrite:le.z.boolean().optional()});send(t,{body:e,request:n={}}){return this._transport.send("v1/channels/"+encodeURIComponent(t)+"/twilio-sendgrid/sync",{...n,method:"POST",json:o.SCHEMA.parse(e)})}};var X=class{constructor(t){this._transport=t}send(t,{body:e,request:n={}}){return this._transport.send("v1/channels/"+encodeURIComponent(t),{...n,method:"PATCH",json:e})}};var Z=class{constructor(t){this._transport=t}send(t,{limit:e,request:n={}}={}){return this._transport.send("v1/channels/"+encodeURIComponent(t)+"/composition-sections",{...n,method:"GET",searchParams:[...this._transport.limitQuery(e)]})}};var tt=class{constructor(t){this._transport=t}send(t,{limit:e,include:n,request:r={}}={}){return this._transport.send("v1/channels/"+encodeURIComponent(t)+"/messages",{...r,method:"GET",searchParams:[...this._transport.limitQuery(e),...this._transport.includeQuery(n)]})}};var et=class{constructor(t){this._transport=t}get api(){return{get:new Y(this._transport),list:new z(this._transport),update:new X(this._transport),create:new W(this._transport),compositionSection:{list:new Z(this._transport)},message:{list:new tt(this._transport)},metaWhatsapp:{getBusinessProfile:new $(this._transport)},twilioSendgrid:{sync:new J(this._transport)}}}};var ot=class{constructor(t){this._transport=t}send({body:t,request:e={}}){return this._transport.send("v1/composition-sections",{...e,method:"POST",json:t})}};var nt=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/composition-sections/"+encodeURIComponent(t),{...e,method:"GET"})}};var rt=class{constructor(t){this._transport=t}send({limit:t,request:e={}}={}){return this._transport.send("v1/composition-sections",{...e,method:"GET",searchParams:[...this._transport.limitQuery(t)]})}};var st=class{constructor(t){this._transport=t}send(t,{body:e,request:n={}}){return this._transport.send("v1/composition-sections/"+encodeURIComponent(t),{...n,method:"PATCH",json:e})}};var it=class{constructor(t){this._transport=t}get api(){return{get:new nt(this._transport),list:new rt(this._transport),create:new ot(this._transport),update:new st(this._transport)}}};var at=class{constructor(t){this._transport=t}getRelativeURL({id:t,vcf:e={}}){let n=e.variant??"vcard",r=e.format??(n==="vcard"?"vcf":"json");return"v1/contacts/"+encodeURIComponent(t)+"/vcf?variant="+encodeURIComponent(n)+"&format="+encodeURIComponent(r)}getURL(t){return this._transport.getURL(this.getRelativeURL(t))}send(t){return this._transport.send(this.getURL(t),{method:"GET"})}};var pt=class{constructor(t){this._transport=t}send({body:t,request:e={}}){return this._transport.send("v1/contacts",{...e,method:"POST",json:t})}};var ct=class{constructor(t){this._transport=t}send(t,{include:e,request:n={}}={}){return this._transport.send("v1/contacts/"+encodeURIComponent(t),{...n,method:"GET",searchParams:[...this._transport.includeQuery(e??{})]})}};var dt=class{constructor(t){this._transport=t}send({limit:t,query:e,request:n={}}={}){return this._transport.send("v1/contacts",{...n,method:"GET",searchParams:[...this._transport.limitQuery(t),...this._transport.queryQuery(e)]})}};var lt=class{constructor(t){this._transport=t}send(t,{body:e,request:n={}}){return this._transport.send("v1/contacts/"+encodeURIComponent(t),{...n,method:"PATCH",json:e})}};var mt=class{constructor(t){this._transport=t}send(t,{limit:e,request:n={}}={}){return this._transport.send("v1/contacts/"+encodeURIComponent(t)+"/conversations",{...n,method:"GET",searchParams:[...this._transport.limitQuery(e)]})}};var ut=class{constructor(t){this._transport=t}send(t,{limit:e,request:n={}}={}){return this._transport.send("v1/contacts/"+encodeURIComponent(t)+"/labels",{...n,method:"GET",searchParams:[...this._transport.limitQuery(e)]})}};var ht=class{constructor(t){this._transport=t}send(t,{body:e,request:n={}}){return this._transport.send("v1/contacts/"+encodeURIComponent(t)+"/notes",{...n,method:"POST",json:e})}};var ft=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/contacts/"+encodeURIComponent(t)+"/notes",{...e,method:"GET"})}};var Ct=class{constructor(t){this._transport=t}send(t,{body:e,request:n={}}){return this._transport.send("v1/contacts/"+encodeURIComponent(t)+"/notification-subscriptions",{...n,method:"POST",json:e})}};var gt=class{constructor(t){this._transport=t}get api(){return{get:new ct(this._transport),list:new dt(this._transport),update:new lt(this._transport),create:new pt(this._transport),conversation:{list:new mt(this._transport)},label:{list:new ut(this._transport)},note:{list:new ft(this._transport),create:new ht(this._transport)},notificationSubscription:{create:new Ct(this._transport)},vcf:{get:new at(this._transport)}}}};var bt=class{constructor(t){this._transport=t}send(t,{include:e,request:n={}}={}){return this._transport.send("v1/conversations/"+encodeURIComponent(t),{...n,method:"GET",searchParams:[...this._transport.includeQuery(e??{})]})}};var Ot=class{constructor(t){this._transport=t}send({limit:t,filter:e,include:n,request:r={}}={}){return this._transport.send("v1/conversations",{...r,method:"GET",searchParams:[...this._transport.limitQuery(t),...e?[["filter",e]]:[],...this._transport.includeQuery(n??{})]})}};var xt=class{constructor(t){this._transport=t}send(t,{body:e,request:n={}}){return this._transport.send("v1/conversations/"+encodeURIComponent(t),{...n,method:"PATCH",json:e})}};var yt=class{constructor(t){this._transport=t}send(t,{limit:e,request:n={}}={}){return this._transport.send("v1/conversations/"+encodeURIComponent(t)+"/labels",{...n,method:"GET",searchParams:[...this._transport.limitQuery(e)]})}};var _t=class{constructor(t){this._transport=t}send(t,{limit:e,include:n,request:r={}}={}){return this._transport.send("v1/conversations/"+encodeURIComponent(t)+"/messages",{...r,method:"GET",searchParams:[...this._transport.limitQuery(e),...this._transport.includeQuery(n??{})]})}};var h=class{constructor(t){this._transport=t}send(t,{body:e,request:n={}}){return this._transport.send("v1/conversations/"+encodeURIComponent(t)+"/notes",{...n,method:"POST",json:e})}};var St=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/conversations/"+encodeURIComponent(t)+"/notes",{...e,method:"GET"})}};var Tt=class{constructor(t){this._transport=t}get api(){return{get:new bt(this._transport),list:new Ot(this._transport),update:new xt(this._transport),create:new h(this._transport),label:{list:new yt(this._transport)},message:{list:new _t(this._transport)},note:{list:new St(this._transport),create:new h(this._transport)}}}};var Rt=class{constructor(t){this._transport=t}send(t,{limit:e,request:n={}}={}){return this._transport.send("v1/labels/"+encodeURIComponent(t)+"/contacts",{...n,method:"GET",searchParams:[...this._transport.limitQuery(e)]})}};var vt=class{constructor(t){this._transport=t}send(t,{limit:e,request:n={}}={}){return this._transport.send("v1/labels/"+encodeURIComponent(t)+"/conversations",{...n,method:"GET",searchParams:[...this._transport.limitQuery(e)]})}};var wt=class{constructor(t){this._transport=t}send({body:t,request:e={}}){return this._transport.send("v1/labels",{...e,method:"POST",json:t})}};var Ft=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/labels/"+encodeURIComponent(t),{...e,method:"DELETE"})}};var At=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/labels/"+encodeURIComponent(t),{...e,method:"GET"})}};var Lt=class{constructor(t){this._transport=t}send({limit:t,query:e,include:n,request:r={}}={}){return this._transport.send("v1/labels",{...r,method:"GET",searchParams:[...this._transport.limitQuery(t),...this._transport.queryQuery(e),...this._transport.includeQuery(n??{})]})}};var Ut=class{constructor(t){this._transport=t}send(t,{body:e,request:n={}}){return this._transport.send("v1/labels/"+encodeURIComponent(t),{...n,method:"PATCH",json:e})}};var Nt=class{constructor(t){this._transport=t}get api(){return{create:new wt(this._transport),get:new At(this._transport),list:new Lt(this._transport),update:new Ut(this._transport),delete:new Ft(this._transport),contact:{list:new Rt(this._transport)},conversation:{list:new vt(this._transport)}}}};var Et=class{constructor(t){this._transport=t}send({limit:t,include:e,request:n={}}={}){return this._transport.send("v1/messages",{...n,method:"GET",searchParams:[...this._transport.limitQuery(t),...this._transport.includeQuery(e??{})]})}};var Gt=class{constructor(t){this._transport=t}get api(){return{list:new Et(this._transport)}}};var Pt=class{constructor(t){this._transport=t}send(t,{body:e,request:n={}}){return this._transport.send("v1/models/"+encodeURIComponent(t)+"/correction",{...n,method:"POST",json:e})}};var qt=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/models/"+encodeURIComponent(t),{...e,method:"GET"})}};var It=class{constructor(t){this._transport=t}send({request:t={}}={}){return this._transport.send("v1/models",{...t,method:"GET"})}};var Bt=class{constructor(t){this._transport=t}send(t,{body:e,request:n={}}){return this._transport.send("v1/models/"+encodeURIComponent(t)+"/response",{...n,method:"POST",timeout:12e4,json:e})}};var Mt=class{constructor(t){this._transport=t}get api(){return{get:new qt(this._transport),list:new It(this._transport),response:{create:new Bt(this._transport)},correction:{create:new Pt(this._transport)}}}};var kt=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/notes/"+encodeURIComponent(t),{...e,method:"GET"})}};var jt=class{constructor(t){this._transport=t}send(t,{body:e,request:n={}}){return this._transport.send("v1/notes/"+encodeURIComponent(t),{...n,method:"PATCH",json:e})}};var Dt=class{constructor(t){this._transport=t}get api(){return{get:new kt(this._transport),update:new jt(this._transport)}}};var Qt=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/sources/"+encodeURIComponent(t),{...e,method:"GET"})}};var Ht=class{constructor(t){this._transport=t}send({featured:t,category:e,request:n={}}={}){let r=[];if(e){let i=Array.isArray(e)?e:[e];for(let m of i)r.push(["category",m])}return t!==void 0&&r.push(["featured",String(t)]),this._transport.send("v1/sources",{...n,method:"GET",searchParams:r})}};var Kt=class{constructor(t){this._transport=t}get api(){return{get:new Qt(this._transport),list:new Ht(this._transport)}}};var Vt=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/channels/"+encodeURIComponent(t)+"/statistics/message-frequency",{...e,method:"GET"})}};var Wt=class{constructor(t){this._transport=t}send({request:t={}}={}){return this._transport.send("v1/statistics/message-frequency",{...t,method:"GET"})}};var Yt=class{constructor(t){this._transport=t}get api(){return{messageFrequency:new Wt(this._transport),channelMessageFrequency:new Vt(this._transport)}}};var zt=class{constructor(t){this._transport=t}send({account:t,files:e,request:n={}}){let r=new FormData;for(let i of e)r.append("file",i);return this._transport.send("v1/uploads",{...n,method:"POST",body:r,searchParams:{account:t}})}};var $t=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/uploads/"+encodeURIComponent(t),{...e,method:"DELETE"})}};var Jt=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/uploads/"+encodeURIComponent(t),{...e,method:"GET"})}};var Xt=class{constructor(t){this._transport=t}get api(){return{get:new Jt(this._transport),create:new zt(this._transport),delete:new $t(this._transport)}}};var Zt=class{constructor(t){this._transport=t}send({request:t={}}={}){return this._transport.send(".well-known/notifications",{...t,method:"GET"})}};var te=class{constructor(t){this._transport=t}get api(){return{notification:{get:new Zt(this._transport)}}}};var ee=class o{static DEFAULT_BASE_URL=Pe;static PublicAuthentication=d;static BasicAuthentication=f;static BearerAuthentication=C;_transport;_account;_accountAccessToken;_accountConversationSettings;_action;_boilerplateContent;_boilerplateCategory;_channel;_compositionSection;_contact;_conversation;_label;_message;_model;_note;_source;_statistics;_upload;_webhook;_wellKnown;constructor(t,{baseURL:e,...n}={}){this._transport=new y({requestFilterables:[new g,t],...n,baseURL:e?.toString()??o.getBaseURL()}),this._account=new L(this._transport),this._accountAccessToken=new w(this._transport),this._accountConversationSettings=new E(this._transport),this._action=new P(this._transport),this._boilerplateContent=new V(this._transport),this._boilerplateCategory=new j(this._transport),this._channel=new et(this._transport),this._compositionSection=new it(this._transport),this._contact=new gt(this._transport),this._conversation=new Tt(this._transport),this._label=new Nt(this._transport),this._message=new Gt(this._transport),this._model=new Mt(this._transport),this._note=new Dt(this._transport),this._source=new Kt(this._transport),this._statistics=new Yt(this._transport),this._upload=new Xt(this._transport),this._webhook=new _(this),this._wellKnown=new te(this._transport)}static getBaseURL(){return process.env[Ge]??this.DEFAULT_BASE_URL}get account(){return this._account.api}get accountAccessToken(){return this._accountAccessToken.api}get accountConversationSettings(){return this._accountConversationSettings.api}get action(){return this._action.api}get boilerplate(){return this._boilerplateContent.api}get boilerplateContent(){return this._boilerplateContent.api}get boilerplateCategory(){return this._boilerplateCategory.api}get channel(){return this._channel.api}get compositionSection(){return this._compositionSection.api}get contact(){return this._contact.api}get conversation(){return this._conversation.api}get label(){return this._label.api}get message(){return this._message.api}get model(){return this._model.api}get note(){return this._note.api}get source(){return this._source.api}get statistics(){return this._statistics.api}get upload(){return this._upload.api}get webhook(){return this._webhook}get wellKnown(){return this._wellKnown.api}};var me=require("commander"),Be=require("ora");function ue({client:o,ora:t}){let e=new me.Command("actions").description("Actions");return e.addCommand(new me.Command("list").description("List actions").action(async()=>{let n=await(0,Be.oraPromise)(()=>o.action.list.send().json(),{...t,text:"Finding actions"});console.log(n)})),e}var he=require("commander"),Me=require("ora");function fe({client:o,ora:t}){let e=new he.Command("channels").description("Channels");return e.addCommand(new he.Command("list").description("List channels").action(async()=>{let n=await(0,Me.oraPromise)(()=>o.channel.list.send().json(),{...t,text:"Finding channels"});console.log(n)})),e}var oe=require("commander"),se=require("ora");function Ce({client:o,ora:t}){let e=new oe.Command("contacts").description("Contacts");return e.addCommand(new oe.Command("get").description("Find contact").argument("<contact>","Contact ID").action(async n=>{let r=await(0,se.oraPromise)(()=>o.contact.get.send(n).json(),{...t,text:"Finding contact"});console.log(r)})),e.addCommand(new oe.Command("list").description("List contacts").action(async()=>{let n=await(0,se.oraPromise)(()=>o.contact.list.send().json(),{...t,text:"Finding contacts"});console.log(n)})),e.addCommand(new oe.Command("get-vcf").description("Export Contact as VCF").argument("<contact>","Contact ID").action(async n=>{let r=await(0,se.oraPromise)(()=>o.contact.vcf.get.send({id:n}).response(),{...t,text:"Exporting contact"});console.log(r)})),e}var ie=require("commander"),ge=require("ora");function be({client:o,ora:t}){let e=new ie.Command("conversations").description("Conversations");return e.addCommand(new ie.Command("get").description("Find conversation").argument("<conversation>","Conversation ID").action(async n=>{let r=await(0,ge.oraPromise)(()=>o.conversation.get.send(n).json(),{...t,text:"Finding conversation"});console.log(r)})),e.addCommand(new ie.Command("list").description("List conversations").action(async()=>{let n=await(0,ge.oraPromise)(()=>o.conversation.list.send().json(),{...t,text:"Finding conversations"});console.log(n)})),e}var ne=require("commander"),ae=require("ora");function Oe({client:o,ora:t}){let e=new ne.Command("labels").description("Labels");return e.addCommand(new ne.Command("get").description("Find label").argument("<label>","Label ID").action(async n=>{let r=await(0,ae.oraPromise)(()=>o.label.get.send(n).json(),{...t,text:"Finding label"});console.log(r)})),e.addCommand(new ne.Command("list").description("List labels").action(async()=>{let n=await(0,ae.oraPromise)(()=>o.label.list.send().json(),{...t,text:"Finding labels"});console.log(n)})),e.addCommand(new ne.Command("conversations").description("Find label conversations").argument("<label>","Label ID").action(async n=>{let r=await(0,ae.oraPromise)(()=>o.label.conversation.list.send(n).json(),{...t,text:"Finding conversations"});console.log(r)})),e}var xe=require("commander"),ke=require("ora");function ye({client:o,ora:t}){let e=new xe.Command("messages").description("Messages");return e.addCommand(new xe.Command("list").description("List messages").action(async()=>{let n=await(0,ke.oraPromise)(()=>o.message.list.send().json(),{...t,text:"Finding messages"});console.log(n)})),e}var pe=require("commander"),_e=require("ora");function Se({client:o,ora:t}){let e=new pe.Command("models").description("Models");return e.addCommand(new pe.Command("get").description("Find model").argument("<model>","Model ID").action(async n=>{let r=await(0,_e.oraPromise)(()=>o.model.get.send(n).json(),{...t,text:"Finding model"});console.log(r)})),e.addCommand(new pe.Command("list").description("List models").action(async()=>{let n=await(0,_e.oraPromise)(()=>o.model.list.send().json(),{...t,text:"Finding models"});console.log(n)})),e}var ce=require("commander"),Te=require("ora");function Re({client:o,ora:t}){let e=new ce.Command("sources").description("Sources");return e.addCommand(new ce.Command("get").description("Find source").argument("<source>","Source ID").action(async n=>{let r=await(0,Te.oraPromise)(()=>o.source.get.send(n).json(),{...t,text:"Finding source"});console.log(r)})),e.addCommand(new ce.Command("list").description("List sources").action(async()=>{let n=await(0,Te.oraPromise)(()=>o.source.list.send().json(),{...t,text:"Finding sources"});console.log(n)})),e}var De=require("commander");var ve=require("commander"),je=require("ora");function we({client:o,ora:t}){let e=new ve.Command("notifications").description("Well-Known Notifications Details");return e.addCommand(new ve.Command("get").description("Get Notifications Server Well-Known Info").action(async()=>{let n=await(0,je.oraPromise)(()=>o.wellKnown.notification.get.send().json(),{...t,text:"Finding Notifications Well-Known Info"});console.log(n)})),e}function Fe({client:o,ora:t}){let e=new De.Command("well-known").description("Well-Known Metadata & Info");return e.addCommand(we({client:o,ora:t})),e}var p={ora:{spinner:"simpleDotsScrolling"},client:new ee(new d)},Xe=new Qe.Command("gds").description("Great Detail Support System").addCommand(ue(p)).addCommand(fe(p)).addCommand(Ce(p)).addCommand(be(p)).addCommand(Oe(p)).addCommand(ye(p)).addCommand(Se(p)).addCommand(Re(p)).addCommand(Fe(p)),He=Xe;He.parseAsync(process.argv);
package/dist/cli.js CHANGED
@@ -1,2 +1,2 @@
1
1
  #!/usr/bin/env node
2
- import{a as r}from"./chunk-25FMSKID.js";import"./chunk-HR2YP6TH.js";r.parseAsync(process.argv);
2
+ import{a as r}from"./chunk-XAL5XNRO.js";import"./chunk-AOL7NCTI.js";r.parseAsync(process.argv);
@@ -209,16 +209,32 @@ declare class GetMessageFrequencyStatistics {
209
209
  * @author Dom Webber <dom.webber@greatdetail.com>
210
210
  * @see https://greatdetail.com
211
211
  */
212
+ type Nullable<T> = T | null;
213
+
214
+ /**
215
+ * Great Detail Support System.
216
+ *
217
+ * @copyright 2024 Great Detail Ltd
218
+ * @author Great Detail Ltd <info@greatdetail.com>
219
+ * @author Dom Webber <dom.webber@greatdetail.com>
220
+ * @see https://greatdetail.com
221
+ */
222
+
212
223
  type Source = {
213
224
  id: string;
214
225
  name: string;
215
226
  category: string;
216
- url?: string;
217
- icon?: string;
227
+ url?: Nullable<string>;
218
228
  disambiguatingDescription: string;
229
+ adornment?: Nullable<"popular" | "sponsored" | "new" | (string & NonNullable<unknown>)>;
230
+ /**
231
+ * @deprecated Since 2024-12-04
232
+ */
233
+ icon?: Nullable<never>;
219
234
  };
220
235
 
221
236
  interface ListSourcesOptions {
237
+ featured?: boolean;
222
238
  category?: string | string[];
223
239
  request?: SendOptions;
224
240
  }
@@ -230,7 +246,7 @@ type ListSourcesResponse = {
230
246
  declare class ListSources {
231
247
  protected _transport: FetchTransport;
232
248
  constructor(_transport: FetchTransport);
233
- send({ category, request }?: ListSourcesOptions): {
249
+ send({ featured, category, request }?: ListSourcesOptions): {
234
250
  response: () => Promise<ky.KyResponse<ListSourcesResponse>>;
235
251
  json: () => Promise<ListSourcesResponse>;
236
252
  };
@@ -398,16 +414,6 @@ declare class GetModel {
398
414
  };
399
415
  }
400
416
 
401
- /**
402
- * Great Detail Support System.
403
- *
404
- * @copyright 2024 Great Detail Ltd
405
- * @author Great Detail Ltd <info@greatdetail.com>
406
- * @author Dom Webber <dom.webber@greatdetail.com>
407
- * @see https://greatdetail.com
408
- */
409
- type Nullable<T> = T | null;
410
-
411
417
  /**
412
418
  * Great Detail Support System.
413
419
  *
@@ -209,16 +209,32 @@ declare class GetMessageFrequencyStatistics {
209
209
  * @author Dom Webber <dom.webber@greatdetail.com>
210
210
  * @see https://greatdetail.com
211
211
  */
212
+ type Nullable<T> = T | null;
213
+
214
+ /**
215
+ * Great Detail Support System.
216
+ *
217
+ * @copyright 2024 Great Detail Ltd
218
+ * @author Great Detail Ltd <info@greatdetail.com>
219
+ * @author Dom Webber <dom.webber@greatdetail.com>
220
+ * @see https://greatdetail.com
221
+ */
222
+
212
223
  type Source = {
213
224
  id: string;
214
225
  name: string;
215
226
  category: string;
216
- url?: string;
217
- icon?: string;
227
+ url?: Nullable<string>;
218
228
  disambiguatingDescription: string;
229
+ adornment?: Nullable<"popular" | "sponsored" | "new" | (string & NonNullable<unknown>)>;
230
+ /**
231
+ * @deprecated Since 2024-12-04
232
+ */
233
+ icon?: Nullable<never>;
219
234
  };
220
235
 
221
236
  interface ListSourcesOptions {
237
+ featured?: boolean;
222
238
  category?: string | string[];
223
239
  request?: SendOptions;
224
240
  }
@@ -230,7 +246,7 @@ type ListSourcesResponse = {
230
246
  declare class ListSources {
231
247
  protected _transport: FetchTransport;
232
248
  constructor(_transport: FetchTransport);
233
- send({ category, request }?: ListSourcesOptions): {
249
+ send({ featured, category, request }?: ListSourcesOptions): {
234
250
  response: () => Promise<ky.KyResponse<ListSourcesResponse>>;
235
251
  json: () => Promise<ListSourcesResponse>;
236
252
  };
@@ -398,16 +414,6 @@ declare class GetModel {
398
414
  };
399
415
  }
400
416
 
401
- /**
402
- * Great Detail Support System.
403
- *
404
- * @copyright 2024 Great Detail Ltd
405
- * @author Great Detail Ltd <info@greatdetail.com>
406
- * @author Dom Webber <dom.webber@greatdetail.com>
407
- * @see https://greatdetail.com
408
- */
409
- type Nullable<T> = T | null;
410
-
411
417
  /**
412
418
  * Great Detail Support System.
413
419
  *
package/dist/index.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";var ge=Object.create;var ee=Object.defineProperty;var be=Object.getOwnPropertyDescriptor;var _e=Object.getOwnPropertyNames;var Oe=Object.getPrototypeOf,xe=Object.prototype.hasOwnProperty;var pe=(o,t)=>{for(var e in t)ee(o,e,{get:t[e],enumerable:!0})},ae=(o,t,e,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of _e(t))!xe.call(o,s)&&s!==e&&ee(o,s,{get:()=>t[s],enumerable:!(r=be(t,s))||r.enumerable});return o};var ce=(o,t,e)=>(e=o!=null?ge(Oe(o)):{},ae(t||!o||!o.__esModule?ee(e,"default",{value:o,enumerable:!0}):e,o)),ye=o=>ae(ee({},"__esModule",{value:!0}),o);var Se={};pe(Se,{BasicAuthentication:()=>l,BearerAuthentication:()=>u,Client:()=>b,DEFAULT_SUPPORT_BASE_URL:()=>oe,Error:()=>ie,KeyAuthentication:()=>l,PublicAuthentication:()=>m,default:()=>b});module.exports=ye(Se);var oe="https://api.support.greatdetail.com",le={"X-Powered-By":"GDSupport/JavaScript"};var de="SUPPORT_ACCESS_TOKEN",ue="SUPPORT_KEY_NAME",me="SUPPORT_KEY_PASSWORD",ne="SUPPORT_SIGNING_KEY",he="SUPPORT_BASE_URL";var l=class{name;#t;constructor({name:t=process.env[ue],password:e=process.env[me]}={}){if(!t)throw new Error("Name option must be specified when using Basic Authentication");if(!e)throw new Error("Password option must be specified when using Basic Authentication");this.name=t,this.#t=e}getHeaders(){return{Authorization:`Basic ${btoa(this.name+":"+this.#t)}`}}};var u=class{#t;constructor({token:t=process.env[de]}={}){if(!t)throw new Error("Access Token option must be specified when using Token Authentication");this.#t=t}getHeaders(){return{Authorization:`Bearer ${this.#t}`}}};var m=class{getHeaders(){return{}}};var _=class o{constructor(t=o.STANDARD_HEADERS){this._standardHeaders=t}static STANDARD_HEADERS=le;async filter(){return{headers:this.getHeaders()}}getHeaders(){return this._standardHeaders}};var fe=ce(require("is-network-error"),1),re=ce(require("ky"),1);var i=class extends Error{static serverError(t){return new this("Server Error: "+t)}};var c=class extends i{};var h=class extends c{static unauthenticated(){return new this("An unauthenticated request occurred")}};var f=class extends c{static forbidden(){return new this("A forbidden request occurred")}};var a=class extends i{static notFound(t){return new this(`Record not found for request: ${t}`)}static forbiddenMethod(t,e){return new this(`Forbidden method for request: ${t} ${e}`)}static teapot(){return new this("I'm a teapot")}static rateLimited(){return new this("Request has been rate-limited")}};var C=class extends i{};var d=class extends i{static badRequest(){return new this("Bad request")}static unsupportedMediaType(){return new this("Unsupported Media Type")}};var O=class{client;options;constructor({baseURL:t,...e}){this.options={...e,baseURL:t},this.client=re.default.create({prefixUrl:this.options.baseURL,timeout:12e3,hooks:{beforeRequest:[r=>{for(let s of this.options.requestFilterables){let p=s.getHeaders();for(let[te,Ce]of Object.entries(p))r.headers.has(te)||r.headers.set(te,Ce)}}]}})}getURL(t){return new URL(t,this.options.baseURL).toString()}sortQuery(t){let e=[];if(t===void 0)return e;for(let[r,s]of Object.entries(t))s!==void 0&&e.push(["sort",s+r]);return e}limitQuery(t){let e=[];return t===void 0||e.push(["limit",t.toString()]),e}includeQuery(t){let e=[];if(t===void 0)return e;for(let r of Object.keys(t))e.push(["include",r]);return e}queryQuery(t){let e=[];return t===void 0||e.push(["query",t]),e}send(t,e={}){let r=this.client(t,e).catch(s=>{if((0,fe.default)(s))throw new C("A network error occurred",{cause:s});if(s instanceof re.HTTPError){let p=s.response.status;switch(console.error(JSON.stringify(s.response)),p){case 400:throw d.badRequest();case 401:throw h.unauthenticated();case 403:throw f.forbidden();case 404:throw a.notFound(t);case 405:throw a.forbiddenMethod(t,e.method??"GET");case 415:throw d.unsupportedMediaType();case 418:throw a.teapot();case 429:throw a.rateLimited()}if(p>=500&&p<600)throw i.serverError(p)}throw s});return{response:()=>r,json:async()=>(await r).json()}}};var n=require("zod");var x=class o{constructor(t){this._client=t}static SCHEMA=n.z.object({data:n.z.object({event:n.z.intersection(n.z.object({id:n.z.string(),createdAt:n.z.string().datetime()}),n.z.union([n.z.object({type:n.z.union([n.z.literal("account.created"),n.z.literal("account.updated")]),payload:n.z.object({account:n.z.string()})}),n.z.object({type:n.z.union([n.z.literal("accountAccessToken.created"),n.z.literal("accountAccessToken.deleted")]),payload:n.z.object({accountAccessToken:n.z.string()})}),n.z.object({type:n.z.union([n.z.literal("contact.created"),n.z.literal("contact.updated")]),payload:n.z.object({contact:n.z.string()})}),n.z.object({type:n.z.union([n.z.literal("conversation.created"),n.z.literal("conversation.updated"),n.z.literal("conversation.closed"),n.z.literal("conversation.received"),n.z.literal("conversation.resolved"),n.z.literal("conversation.sent")]),payload:n.z.object({conversation:n.z.string()})}),n.z.object({type:n.z.union([n.z.literal("message.created"),n.z.literal("message.updated"),n.z.literal("message.delivered"),n.z.literal("message.failed"),n.z.literal("message.read"),n.z.literal("message.received"),n.z.literal("message.sent")]),payload:n.z.object({message:n.z.string()})})]))})});async event({key:t=process.env[ne],maxSignatures:e=3,request:r}){let s=r.headers["gds-signature"];if(t!==!1){if(t===void 0)throw new Error("Missing webhook signing key in process.env."+ne);if(!s)throw new Error("Missing signature header");if(!this._verifySignature(t,r.body,Array.isArray(s)?s.slice(0,e):[s]))throw new Error("Untrusted signature")}let{data:p}=o.SCHEMA.parse(r.body);return{event:p.event}}async _verifySignature(t,e,r){let s=await crypto.subtle.importKey("raw",new TextEncoder().encode(t),{name:"HMAC",hash:"SHA-256"},!1,["sign","verify"]);for(let p of r)if(await crypto.subtle.verify("HMAC",s,new TextEncoder().encode(atob(p)),new TextEncoder().encode(JSON.stringify(e))))return!0;return!1}};var y=class{constructor(t){this._transport=t}send(t,{body:e={},request:r={}}={}){return this._transport.send("v1/accounts/"+encodeURIComponent(t)+"/access-tokens",{...r,method:"POST",json:e})}};var S=class{constructor(t){this._transport=t}send(t,e,{body:r,request:s={}}={}){return this._transport.send("v1/accounts/"+encodeURIComponent(t)+"/access-tokens/"+encodeURIComponent(e),{...s,method:"DELETE",json:r})}};var T=class{constructor(t){this._transport=t}send(t,e,{request:r={}}={}){return this._transport.send("v1/accounts/"+encodeURIComponent(t)+"/access-tokens/"+encodeURIComponent(e),{...r,method:"GET"})}};var R=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/accounts/"+encodeURIComponent(t)+"/access-tokens",{...e,method:"GET"})}};var v=class{constructor(t){this._transport=t}get api(){return{get:new T(this._transport),list:new R(this._transport),create:new y(this._transport),delete:new S(this._transport)}}};var F=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/accounts/"+encodeURIComponent(t),{...e,method:"GET"})}};var A=class{constructor(t){this._transport=t}send(t,{body:e,request:r={}}){return this._transport.send("v1/accounts/"+encodeURIComponent(t),{...r,method:"PATCH",json:e})}};var w=class{constructor(t){this._transport=t}get api(){return{get:new F(this._transport),update:new A(this._transport)}}};var L=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/accounts/"+encodeURIComponent(t)+"/conversation-settings",{...e,method:"GET"})}};var U=class{constructor(t){this._transport=t}send(t,{body:e,request:r={}}){return this._transport.send("v1/accounts/"+encodeURIComponent(t)+"/conversation-settings",{...r,method:"PATCH",json:e})}};var E=class{constructor(t){this._transport=t}get api(){return{get:new L(this._transport),update:new U(this._transport)}}};var N=class{constructor(t){this._transport=t}send({limit:t,sort:e,request:r={}}={}){return this._transport.send("v1/actions",{...r,method:"GET",searchParams:[...this._transport.limitQuery(t),...this._transport.sortQuery(e)]})}};var G=class{constructor(t){this._transport=t}get api(){return{list:new N(this._transport)}}};var P=class{constructor(t){this._transport=t}send({body:t,request:e={}}){return this._transport.send("v1/boilerplates/categories",{...e,method:"POST",json:t})}};var q=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/boilerplates/categories/"+encodeURIComponent(t),{...e,method:"GET"})}};var I=class{constructor(t){this._transport=t}send({limit:t,include:e,request:r={}}={}){return this._transport.send("v1/boilerplates/categories",{...r,method:"GET",searchParams:[...this._transport.limitQuery(t),...this._transport.includeQuery(e)]})}};var B=class{constructor(t){this._transport=t}send(t,{body:e,request:r={}}){return this._transport.send("v1/boilerplates/categories/"+encodeURIComponent(t),{...r,method:"PATCH",json:e})}};var k=class{constructor(t){this._transport=t}send(t,{limit:e,request:r={}}={}){return this._transport.send("v1/boilerplates/categories/"+encodeURIComponent(t)+"/contents",{...r,method:"GET",searchParams:[...this._transport.limitQuery(e)]})}};var M=class{constructor(t){this._transport=t}get api(){return{get:new q(this._transport),list:new I(this._transport),create:new P(this._transport),update:new B(this._transport),boilerplate:{list:new k(this._transport)}}}};var j=class{constructor(t){this._transport=t}send({body:t,request:e={}}){return this._transport.send("v1/boilerplates/contents",{...e,method:"POST",json:t})}};var Q=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/boilerplates/contents/"+encodeURIComponent(t),{...e,method:"GET"})}};var D=class{constructor(t){this._transport=t}send({limit:t,query:e,request:r={}}={}){return this._transport.send("v1/boilerplates/contents",{...r,method:"GET",searchParams:[...this._transport.limitQuery(t),...this._transport.queryQuery(e)]})}};var H=class{constructor(t){this._transport=t}send(t,{body:e,request:r={}}){return this._transport.send("v1/boilerplates/contents/"+encodeURIComponent(t),{...r,method:"PATCH",json:e})}};var K=class{constructor(t){this._transport=t}get api(){return{get:new Q(this._transport),list:new D(this._transport),update:new H(this._transport),create:new j(this._transport)}}};var V=class{constructor(t){this._transport=t}send({body:t,request:e={}}){return this._transport.send("v1/channels",{...e,method:"POST",json:t})}};var W=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/channels/"+encodeURIComponent(t),{...e,method:"GET"})}};var z=class{constructor(t){this._transport=t}send({limit:t,request:e={}}={}){return this._transport.send("v1/channels",{...e,method:"GET",searchParams:[...this._transport.limitQuery(t)]})}};var Y=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/channels/"+encodeURIComponent(t)+"/meta-whatsapp/business-profile",{...e,method:"GET"})}};var se=require("zod"),$=class o{constructor(t){this._transport=t}static SCHEMA=se.z.object({overwrite:se.z.boolean().optional()});send(t,{body:e,request:r={}}){return this._transport.send("v1/channels/"+encodeURIComponent(t)+"/twilio-sendgrid/sync",{...r,method:"POST",json:o.SCHEMA.parse(e)})}};var J=class{constructor(t){this._transport=t}send(t,{body:e,request:r={}}){return this._transport.send("v1/channels/"+encodeURIComponent(t),{...r,method:"PATCH",json:e})}};var X=class{constructor(t){this._transport=t}send(t,{limit:e,request:r={}}={}){return this._transport.send("v1/channels/"+encodeURIComponent(t)+"/composition-sections",{...r,method:"GET",searchParams:[...this._transport.limitQuery(e)]})}};var Z=class{constructor(t){this._transport=t}send(t,{limit:e,include:r,request:s={}}={}){return this._transport.send("v1/channels/"+encodeURIComponent(t)+"/messages",{...s,method:"GET",searchParams:[...this._transport.limitQuery(e),...this._transport.includeQuery(r)]})}};var tt=class{constructor(t){this._transport=t}get api(){return{get:new W(this._transport),list:new z(this._transport),update:new J(this._transport),create:new V(this._transport),compositionSection:{list:new X(this._transport)},message:{list:new Z(this._transport)},metaWhatsapp:{getBusinessProfile:new Y(this._transport)},twilioSendgrid:{sync:new $(this._transport)}}}};var et=class{constructor(t){this._transport=t}send({body:t,request:e={}}){return this._transport.send("v1/composition-sections",{...e,method:"POST",json:t})}};var ot=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/composition-sections/"+encodeURIComponent(t),{...e,method:"GET"})}};var rt=class{constructor(t){this._transport=t}send({limit:t,request:e={}}={}){return this._transport.send("v1/composition-sections",{...e,method:"GET",searchParams:[...this._transport.limitQuery(t)]})}};var nt=class{constructor(t){this._transport=t}send(t,{body:e,request:r={}}){return this._transport.send("v1/composition-sections/"+encodeURIComponent(t),{...r,method:"PATCH",json:e})}};var st=class{constructor(t){this._transport=t}get api(){return{get:new ot(this._transport),list:new rt(this._transport),create:new et(this._transport),update:new nt(this._transport)}}};var it=class{constructor(t){this._transport=t}getRelativeURL({id:t,vcf:e={}}){let r=e.variant??"vcard",s=e.format??(r==="vcard"?"vcf":"json");return"v1/contacts/"+encodeURIComponent(t)+"/vcf?variant="+encodeURIComponent(r)+"&format="+encodeURIComponent(s)}getURL(t){return this._transport.getURL(this.getRelativeURL(t))}send(t){return this._transport.send(this.getURL(t),{method:"GET"})}};var pt=class{constructor(t){this._transport=t}send({body:t,request:e={}}){return this._transport.send("v1/contacts",{...e,method:"POST",json:t})}};var at=class{constructor(t){this._transport=t}send(t,{include:e,request:r={}}={}){return this._transport.send("v1/contacts/"+encodeURIComponent(t),{...r,method:"GET",searchParams:[...this._transport.includeQuery(e??{})]})}};var ct=class{constructor(t){this._transport=t}send({limit:t,query:e,request:r={}}={}){return this._transport.send("v1/contacts",{...r,method:"GET",searchParams:[...this._transport.limitQuery(t),...this._transport.queryQuery(e)]})}};var lt=class{constructor(t){this._transport=t}send(t,{body:e,request:r={}}){return this._transport.send("v1/contacts/"+encodeURIComponent(t),{...r,method:"PATCH",json:e})}};var dt=class{constructor(t){this._transport=t}send(t,{limit:e,request:r={}}={}){return this._transport.send("v1/contacts/"+encodeURIComponent(t)+"/conversations",{...r,method:"GET",searchParams:[...this._transport.limitQuery(e)]})}};var ut=class{constructor(t){this._transport=t}send(t,{limit:e,request:r={}}={}){return this._transport.send("v1/contacts/"+encodeURIComponent(t)+"/labels",{...r,method:"GET",searchParams:[...this._transport.limitQuery(e)]})}};var mt=class{constructor(t){this._transport=t}send(t,{body:e,request:r={}}){return this._transport.send("v1/contacts/"+encodeURIComponent(t)+"/notes",{...r,method:"POST",json:e})}};var ht=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/contacts/"+encodeURIComponent(t)+"/notes",{...e,method:"GET"})}};var ft=class{constructor(t){this._transport=t}send(t,{body:e,request:r={}}){return this._transport.send("v1/contacts/"+encodeURIComponent(t)+"/notification-subscriptions",{...r,method:"POST",json:e})}};var Ct=class{constructor(t){this._transport=t}get api(){return{get:new at(this._transport),list:new ct(this._transport),update:new lt(this._transport),create:new pt(this._transport),conversation:{list:new dt(this._transport)},label:{list:new ut(this._transport)},note:{list:new ht(this._transport),create:new mt(this._transport)},notificationSubscription:{create:new ft(this._transport)},vcf:{get:new it(this._transport)}}}};var gt=class{constructor(t){this._transport=t}send(t,{include:e,request:r={}}={}){return this._transport.send("v1/conversations/"+encodeURIComponent(t),{...r,method:"GET",searchParams:[...this._transport.includeQuery(e??{})]})}};var bt=class{constructor(t){this._transport=t}send({limit:t,filter:e,include:r,request:s={}}={}){return this._transport.send("v1/conversations",{...s,method:"GET",searchParams:[...this._transport.limitQuery(t),...e?[["filter",e]]:[],...this._transport.includeQuery(r??{})]})}};var _t=class{constructor(t){this._transport=t}send(t,{body:e,request:r={}}){return this._transport.send("v1/conversations/"+encodeURIComponent(t),{...r,method:"PATCH",json:e})}};var Ot=class{constructor(t){this._transport=t}send(t,{limit:e,request:r={}}={}){return this._transport.send("v1/conversations/"+encodeURIComponent(t)+"/labels",{...r,method:"GET",searchParams:[...this._transport.limitQuery(e)]})}};var xt=class{constructor(t){this._transport=t}send(t,{limit:e,include:r,request:s={}}={}){return this._transport.send("v1/conversations/"+encodeURIComponent(t)+"/messages",{...s,method:"GET",searchParams:[...this._transport.limitQuery(e),...this._transport.includeQuery(r??{})]})}};var g=class{constructor(t){this._transport=t}send(t,{body:e,request:r={}}){return this._transport.send("v1/conversations/"+encodeURIComponent(t)+"/notes",{...r,method:"POST",json:e})}};var yt=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/conversations/"+encodeURIComponent(t)+"/notes",{...e,method:"GET"})}};var St=class{constructor(t){this._transport=t}get api(){return{get:new gt(this._transport),list:new bt(this._transport),update:new _t(this._transport),create:new g(this._transport),label:{list:new Ot(this._transport)},message:{list:new xt(this._transport)},note:{list:new yt(this._transport),create:new g(this._transport)}}}};var Tt=class{constructor(t){this._transport=t}send(t,{limit:e,request:r={}}={}){return this._transport.send("v1/labels/"+encodeURIComponent(t)+"/contacts",{...r,method:"GET",searchParams:[...this._transport.limitQuery(e)]})}};var Rt=class{constructor(t){this._transport=t}send(t,{limit:e,request:r={}}={}){return this._transport.send("v1/labels/"+encodeURIComponent(t)+"/conversations",{...r,method:"GET",searchParams:[...this._transport.limitQuery(e)]})}};var vt=class{constructor(t){this._transport=t}send({body:t,request:e={}}){return this._transport.send("v1/labels",{...e,method:"POST",json:t})}};var Ft=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/labels/"+encodeURIComponent(t),{...e,method:"DELETE"})}};var At=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/labels/"+encodeURIComponent(t),{...e,method:"GET"})}};var wt=class{constructor(t){this._transport=t}send({limit:t,query:e,include:r,request:s={}}={}){return this._transport.send("v1/labels",{...s,method:"GET",searchParams:[...this._transport.limitQuery(t),...this._transport.queryQuery(e),...this._transport.includeQuery(r??{})]})}};var Lt=class{constructor(t){this._transport=t}send(t,{body:e,request:r={}}){return this._transport.send("v1/labels/"+encodeURIComponent(t),{...r,method:"PATCH",json:e})}};var Ut=class{constructor(t){this._transport=t}get api(){return{create:new vt(this._transport),get:new At(this._transport),list:new wt(this._transport),update:new Lt(this._transport),delete:new Ft(this._transport),contact:{list:new Tt(this._transport)},conversation:{list:new Rt(this._transport)}}}};var Et=class{constructor(t){this._transport=t}send({limit:t,include:e,request:r={}}={}){return this._transport.send("v1/messages",{...r,method:"GET",searchParams:[...this._transport.limitQuery(t),...this._transport.includeQuery(e??{})]})}};var Nt=class{constructor(t){this._transport=t}get api(){return{list:new Et(this._transport)}}};var Gt=class{constructor(t){this._transport=t}send(t,{body:e,request:r={}}){return this._transport.send("v1/models/"+encodeURIComponent(t)+"/correction",{...r,method:"POST",json:e})}};var Pt=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/models/"+encodeURIComponent(t),{...e,method:"GET"})}};var qt=class{constructor(t){this._transport=t}send({request:t={}}={}){return this._transport.send("v1/models",{...t,method:"GET"})}};var It=class{constructor(t){this._transport=t}send(t,{body:e,request:r={}}){return this._transport.send("v1/models/"+encodeURIComponent(t)+"/response",{...r,method:"POST",timeout:12e4,json:e})}};var Bt=class{constructor(t){this._transport=t}get api(){return{get:new Pt(this._transport),list:new qt(this._transport),response:{create:new It(this._transport)},correction:{create:new Gt(this._transport)}}}};var kt=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/notes/"+encodeURIComponent(t),{...e,method:"GET"})}};var Mt=class{constructor(t){this._transport=t}send(t,{body:e,request:r={}}){return this._transport.send("v1/notes/"+encodeURIComponent(t),{...r,method:"PATCH",json:e})}};var jt=class{constructor(t){this._transport=t}get api(){return{get:new kt(this._transport),update:new Mt(this._transport)}}};var Qt=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/sources/"+encodeURIComponent(t),{...e,method:"GET"})}};var Dt=class{constructor(t){this._transport=t}send({category:t,request:e={}}={}){let r=[];if(t){let s=Array.isArray(t)?t:[t];for(let p of s)r.push(["category",p])}return this._transport.send("v1/sources",{...e,method:"GET",searchParams:r})}};var Ht=class{constructor(t){this._transport=t}get api(){return{get:new Qt(this._transport),list:new Dt(this._transport)}}};var Kt=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/channels/"+encodeURIComponent(t)+"/statistics/message-frequency",{...e,method:"GET"})}};var Vt=class{constructor(t){this._transport=t}send({request:t={}}={}){return this._transport.send("v1/statistics/message-frequency",{...t,method:"GET"})}};var Wt=class{constructor(t){this._transport=t}get api(){return{messageFrequency:new Vt(this._transport),channelMessageFrequency:new Kt(this._transport)}}};var zt=class{constructor(t){this._transport=t}send({account:t,files:e,request:r={}}){let s=new FormData;for(let p of e)s.append("file",p);return this._transport.send("v1/uploads",{...r,method:"POST",body:s,searchParams:{account:t}})}};var Yt=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/uploads/"+encodeURIComponent(t),{...e,method:"DELETE"})}};var $t=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/uploads/"+encodeURIComponent(t),{...e,method:"GET"})}};var Jt=class{constructor(t){this._transport=t}get api(){return{get:new $t(this._transport),create:new zt(this._transport),delete:new Yt(this._transport)}}};var Xt=class{constructor(t){this._transport=t}send({request:t={}}={}){return this._transport.send(".well-known/notifications",{...t,method:"GET"})}};var Zt=class{constructor(t){this._transport=t}get api(){return{notification:{get:new Xt(this._transport)}}}};var b=class o{static DEFAULT_BASE_URL=oe;static PublicAuthentication=m;static BasicAuthentication=l;static BearerAuthentication=u;_transport;_account;_accountAccessToken;_accountConversationSettings;_action;_boilerplateContent;_boilerplateCategory;_channel;_compositionSection;_contact;_conversation;_label;_message;_model;_note;_source;_statistics;_upload;_webhook;_wellKnown;constructor(t,{baseURL:e,...r}={}){this._transport=new O({requestFilterables:[new _,t],...r,baseURL:e?.toString()??o.getBaseURL()}),this._account=new w(this._transport),this._accountAccessToken=new v(this._transport),this._accountConversationSettings=new E(this._transport),this._action=new G(this._transport),this._boilerplateContent=new K(this._transport),this._boilerplateCategory=new M(this._transport),this._channel=new tt(this._transport),this._compositionSection=new st(this._transport),this._contact=new Ct(this._transport),this._conversation=new St(this._transport),this._label=new Ut(this._transport),this._message=new Nt(this._transport),this._model=new Bt(this._transport),this._note=new jt(this._transport),this._source=new Ht(this._transport),this._statistics=new Wt(this._transport),this._upload=new Jt(this._transport),this._webhook=new x(this),this._wellKnown=new Zt(this._transport)}static getBaseURL(){return process.env[he]??this.DEFAULT_BASE_URL}get account(){return this._account.api}get accountAccessToken(){return this._accountAccessToken.api}get accountConversationSettings(){return this._accountConversationSettings.api}get action(){return this._action.api}get boilerplate(){return this._boilerplateContent.api}get boilerplateContent(){return this._boilerplateContent.api}get boilerplateCategory(){return this._boilerplateCategory.api}get channel(){return this._channel.api}get compositionSection(){return this._compositionSection.api}get contact(){return this._contact.api}get conversation(){return this._conversation.api}get label(){return this._label.api}get message(){return this._message.api}get model(){return this._model.api}get note(){return this._note.api}get source(){return this._source.api}get statistics(){return this._statistics.api}get upload(){return this._upload.api}get webhook(){return this._webhook}get wellKnown(){return this._wellKnown.api}};var ie={};pe(ie,{AuthError:()=>c,AuthenticationError:()=>h,AuthorizationError:()=>f,LogicError:()=>a,NetworkError:()=>C,SupportError:()=>i,ValidationError:()=>d});0&&(module.exports={BasicAuthentication,BearerAuthentication,Client,DEFAULT_SUPPORT_BASE_URL,Error,KeyAuthentication,PublicAuthentication});
1
+ "use strict";var ge=Object.create;var ee=Object.defineProperty;var be=Object.getOwnPropertyDescriptor;var _e=Object.getOwnPropertyNames;var Oe=Object.getPrototypeOf,xe=Object.prototype.hasOwnProperty;var pe=(o,t)=>{for(var e in t)ee(o,e,{get:t[e],enumerable:!0})},ae=(o,t,e,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of _e(t))!xe.call(o,s)&&s!==e&&ee(o,s,{get:()=>t[s],enumerable:!(r=be(t,s))||r.enumerable});return o};var ce=(o,t,e)=>(e=o!=null?ge(Oe(o)):{},ae(t||!o||!o.__esModule?ee(e,"default",{value:o,enumerable:!0}):e,o)),ye=o=>ae(ee({},"__esModule",{value:!0}),o);var Se={};pe(Se,{BasicAuthentication:()=>l,BearerAuthentication:()=>u,Client:()=>_,DEFAULT_SUPPORT_BASE_URL:()=>oe,Error:()=>ie,KeyAuthentication:()=>l,PublicAuthentication:()=>m,default:()=>_});module.exports=ye(Se);var oe="https://api.support.greatdetail.com",le={"X-Powered-By":"GDSupport/JavaScript"};var de="SUPPORT_ACCESS_TOKEN",ue="SUPPORT_KEY_NAME",me="SUPPORT_KEY_PASSWORD",ne="SUPPORT_SIGNING_KEY",he="SUPPORT_BASE_URL";var l=class{name;#t;constructor({name:t=process.env[ue],password:e=process.env[me]}={}){if(!t)throw new Error("Name option must be specified when using Basic Authentication");if(!e)throw new Error("Password option must be specified when using Basic Authentication");this.name=t,this.#t=e}getHeaders(){return{Authorization:`Basic ${btoa(this.name+":"+this.#t)}`}}};var u=class{#t;constructor({token:t=process.env[de]}={}){if(!t)throw new Error("Access Token option must be specified when using Token Authentication");this.#t=t}getHeaders(){return{Authorization:`Bearer ${this.#t}`}}};var m=class{getHeaders(){return{}}};var O=class o{constructor(t=o.STANDARD_HEADERS){this._standardHeaders=t}static STANDARD_HEADERS=le;async filter(){return{headers:this.getHeaders()}}getHeaders(){return this._standardHeaders}};var fe=ce(require("is-network-error"),1),re=ce(require("ky"),1);var i=class extends Error{static serverError(t){return new this("Server Error: "+t)}};var c=class extends i{};var h=class extends c{static unauthenticated(){return new this("An unauthenticated request occurred")}};var f=class extends c{static forbidden(){return new this("A forbidden request occurred")}};var a=class extends i{static notFound(t){return new this(`Record not found for request: ${t}`)}static forbiddenMethod(t,e){return new this(`Forbidden method for request: ${t} ${e}`)}static teapot(){return new this("I'm a teapot")}static rateLimited(){return new this("Request has been rate-limited")}};var C=class extends i{};var d=class extends i{static badRequest(){return new this("Bad request")}static unsupportedMediaType(){return new this("Unsupported Media Type")}};var x=class{client;options;constructor({baseURL:t,...e}){this.options={...e,baseURL:t},this.client=re.default.create({prefixUrl:this.options.baseURL,timeout:12e3,hooks:{beforeRequest:[r=>{for(let s of this.options.requestFilterables){let p=s.getHeaders();for(let[g,Ce]of Object.entries(p))r.headers.has(g)||r.headers.set(g,Ce)}}]}})}getURL(t){return new URL(t,this.options.baseURL).toString()}sortQuery(t){let e=[];if(t===void 0)return e;for(let[r,s]of Object.entries(t))s!==void 0&&e.push(["sort",s+r]);return e}limitQuery(t){let e=[];return t===void 0||e.push(["limit",t.toString()]),e}includeQuery(t){let e=[];if(t===void 0)return e;for(let r of Object.keys(t))e.push(["include",r]);return e}queryQuery(t){let e=[];return t===void 0||e.push(["query",t]),e}send(t,e={}){let r=this.client(t,e).catch(s=>{if((0,fe.default)(s))throw new C("A network error occurred",{cause:s});if(s instanceof re.HTTPError){let p=s.response.status;switch(console.error(JSON.stringify(s.response)),p){case 400:throw d.badRequest();case 401:throw h.unauthenticated();case 403:throw f.forbidden();case 404:throw a.notFound(t);case 405:throw a.forbiddenMethod(t,e.method??"GET");case 415:throw d.unsupportedMediaType();case 418:throw a.teapot();case 429:throw a.rateLimited()}if(p>=500&&p<600)throw i.serverError(p)}throw s});return{response:()=>r,json:async()=>(await r).json()}}};var n=require("zod");var y=class o{constructor(t){this._client=t}static SCHEMA=n.z.object({data:n.z.object({event:n.z.intersection(n.z.object({id:n.z.string(),createdAt:n.z.string().datetime()}),n.z.union([n.z.object({type:n.z.union([n.z.literal("account.created"),n.z.literal("account.updated")]),payload:n.z.object({account:n.z.string()})}),n.z.object({type:n.z.union([n.z.literal("accountAccessToken.created"),n.z.literal("accountAccessToken.deleted")]),payload:n.z.object({accountAccessToken:n.z.string()})}),n.z.object({type:n.z.union([n.z.literal("contact.created"),n.z.literal("contact.updated")]),payload:n.z.object({contact:n.z.string()})}),n.z.object({type:n.z.union([n.z.literal("conversation.created"),n.z.literal("conversation.updated"),n.z.literal("conversation.closed"),n.z.literal("conversation.received"),n.z.literal("conversation.resolved"),n.z.literal("conversation.sent")]),payload:n.z.object({conversation:n.z.string()})}),n.z.object({type:n.z.union([n.z.literal("message.created"),n.z.literal("message.updated"),n.z.literal("message.delivered"),n.z.literal("message.failed"),n.z.literal("message.read"),n.z.literal("message.received"),n.z.literal("message.sent")]),payload:n.z.object({message:n.z.string()})})]))})});async event({key:t=process.env[ne],maxSignatures:e=3,request:r}){let s=r.headers["gds-signature"];if(t!==!1){if(t===void 0)throw new Error("Missing webhook signing key in process.env."+ne);if(!s)throw new Error("Missing signature header");if(!this._verifySignature(t,r.body,Array.isArray(s)?s.slice(0,e):[s]))throw new Error("Untrusted signature")}let{data:p}=o.SCHEMA.parse(r.body);return{event:p.event}}async _verifySignature(t,e,r){let s=await crypto.subtle.importKey("raw",new TextEncoder().encode(t),{name:"HMAC",hash:"SHA-256"},!1,["sign","verify"]);for(let p of r)if(await crypto.subtle.verify("HMAC",s,new TextEncoder().encode(atob(p)),new TextEncoder().encode(JSON.stringify(e))))return!0;return!1}};var S=class{constructor(t){this._transport=t}send(t,{body:e={},request:r={}}={}){return this._transport.send("v1/accounts/"+encodeURIComponent(t)+"/access-tokens",{...r,method:"POST",json:e})}};var T=class{constructor(t){this._transport=t}send(t,e,{body:r,request:s={}}={}){return this._transport.send("v1/accounts/"+encodeURIComponent(t)+"/access-tokens/"+encodeURIComponent(e),{...s,method:"DELETE",json:r})}};var R=class{constructor(t){this._transport=t}send(t,e,{request:r={}}={}){return this._transport.send("v1/accounts/"+encodeURIComponent(t)+"/access-tokens/"+encodeURIComponent(e),{...r,method:"GET"})}};var v=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/accounts/"+encodeURIComponent(t)+"/access-tokens",{...e,method:"GET"})}};var F=class{constructor(t){this._transport=t}get api(){return{get:new R(this._transport),list:new v(this._transport),create:new S(this._transport),delete:new T(this._transport)}}};var A=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/accounts/"+encodeURIComponent(t),{...e,method:"GET"})}};var w=class{constructor(t){this._transport=t}send(t,{body:e,request:r={}}){return this._transport.send("v1/accounts/"+encodeURIComponent(t),{...r,method:"PATCH",json:e})}};var L=class{constructor(t){this._transport=t}get api(){return{get:new A(this._transport),update:new w(this._transport)}}};var U=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/accounts/"+encodeURIComponent(t)+"/conversation-settings",{...e,method:"GET"})}};var E=class{constructor(t){this._transport=t}send(t,{body:e,request:r={}}){return this._transport.send("v1/accounts/"+encodeURIComponent(t)+"/conversation-settings",{...r,method:"PATCH",json:e})}};var N=class{constructor(t){this._transport=t}get api(){return{get:new U(this._transport),update:new E(this._transport)}}};var G=class{constructor(t){this._transport=t}send({limit:t,sort:e,request:r={}}={}){return this._transport.send("v1/actions",{...r,method:"GET",searchParams:[...this._transport.limitQuery(t),...this._transport.sortQuery(e)]})}};var P=class{constructor(t){this._transport=t}get api(){return{list:new G(this._transport)}}};var q=class{constructor(t){this._transport=t}send({body:t,request:e={}}){return this._transport.send("v1/boilerplates/categories",{...e,method:"POST",json:t})}};var I=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/boilerplates/categories/"+encodeURIComponent(t),{...e,method:"GET"})}};var B=class{constructor(t){this._transport=t}send({limit:t,include:e,request:r={}}={}){return this._transport.send("v1/boilerplates/categories",{...r,method:"GET",searchParams:[...this._transport.limitQuery(t),...this._transport.includeQuery(e)]})}};var k=class{constructor(t){this._transport=t}send(t,{body:e,request:r={}}){return this._transport.send("v1/boilerplates/categories/"+encodeURIComponent(t),{...r,method:"PATCH",json:e})}};var M=class{constructor(t){this._transport=t}send(t,{limit:e,request:r={}}={}){return this._transport.send("v1/boilerplates/categories/"+encodeURIComponent(t)+"/contents",{...r,method:"GET",searchParams:[...this._transport.limitQuery(e)]})}};var j=class{constructor(t){this._transport=t}get api(){return{get:new I(this._transport),list:new B(this._transport),create:new q(this._transport),update:new k(this._transport),boilerplate:{list:new M(this._transport)}}}};var Q=class{constructor(t){this._transport=t}send({body:t,request:e={}}){return this._transport.send("v1/boilerplates/contents",{...e,method:"POST",json:t})}};var D=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/boilerplates/contents/"+encodeURIComponent(t),{...e,method:"GET"})}};var H=class{constructor(t){this._transport=t}send({limit:t,query:e,request:r={}}={}){return this._transport.send("v1/boilerplates/contents",{...r,method:"GET",searchParams:[...this._transport.limitQuery(t),...this._transport.queryQuery(e)]})}};var K=class{constructor(t){this._transport=t}send(t,{body:e,request:r={}}){return this._transport.send("v1/boilerplates/contents/"+encodeURIComponent(t),{...r,method:"PATCH",json:e})}};var V=class{constructor(t){this._transport=t}get api(){return{get:new D(this._transport),list:new H(this._transport),update:new K(this._transport),create:new Q(this._transport)}}};var W=class{constructor(t){this._transport=t}send({body:t,request:e={}}){return this._transport.send("v1/channels",{...e,method:"POST",json:t})}};var z=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/channels/"+encodeURIComponent(t),{...e,method:"GET"})}};var Y=class{constructor(t){this._transport=t}send({limit:t,request:e={}}={}){return this._transport.send("v1/channels",{...e,method:"GET",searchParams:[...this._transport.limitQuery(t)]})}};var $=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/channels/"+encodeURIComponent(t)+"/meta-whatsapp/business-profile",{...e,method:"GET"})}};var se=require("zod"),J=class o{constructor(t){this._transport=t}static SCHEMA=se.z.object({overwrite:se.z.boolean().optional()});send(t,{body:e,request:r={}}){return this._transport.send("v1/channels/"+encodeURIComponent(t)+"/twilio-sendgrid/sync",{...r,method:"POST",json:o.SCHEMA.parse(e)})}};var X=class{constructor(t){this._transport=t}send(t,{body:e,request:r={}}){return this._transport.send("v1/channels/"+encodeURIComponent(t),{...r,method:"PATCH",json:e})}};var Z=class{constructor(t){this._transport=t}send(t,{limit:e,request:r={}}={}){return this._transport.send("v1/channels/"+encodeURIComponent(t)+"/composition-sections",{...r,method:"GET",searchParams:[...this._transport.limitQuery(e)]})}};var tt=class{constructor(t){this._transport=t}send(t,{limit:e,include:r,request:s={}}={}){return this._transport.send("v1/channels/"+encodeURIComponent(t)+"/messages",{...s,method:"GET",searchParams:[...this._transport.limitQuery(e),...this._transport.includeQuery(r)]})}};var et=class{constructor(t){this._transport=t}get api(){return{get:new z(this._transport),list:new Y(this._transport),update:new X(this._transport),create:new W(this._transport),compositionSection:{list:new Z(this._transport)},message:{list:new tt(this._transport)},metaWhatsapp:{getBusinessProfile:new $(this._transport)},twilioSendgrid:{sync:new J(this._transport)}}}};var ot=class{constructor(t){this._transport=t}send({body:t,request:e={}}){return this._transport.send("v1/composition-sections",{...e,method:"POST",json:t})}};var rt=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/composition-sections/"+encodeURIComponent(t),{...e,method:"GET"})}};var nt=class{constructor(t){this._transport=t}send({limit:t,request:e={}}={}){return this._transport.send("v1/composition-sections",{...e,method:"GET",searchParams:[...this._transport.limitQuery(t)]})}};var st=class{constructor(t){this._transport=t}send(t,{body:e,request:r={}}){return this._transport.send("v1/composition-sections/"+encodeURIComponent(t),{...r,method:"PATCH",json:e})}};var it=class{constructor(t){this._transport=t}get api(){return{get:new rt(this._transport),list:new nt(this._transport),create:new ot(this._transport),update:new st(this._transport)}}};var pt=class{constructor(t){this._transport=t}getRelativeURL({id:t,vcf:e={}}){let r=e.variant??"vcard",s=e.format??(r==="vcard"?"vcf":"json");return"v1/contacts/"+encodeURIComponent(t)+"/vcf?variant="+encodeURIComponent(r)+"&format="+encodeURIComponent(s)}getURL(t){return this._transport.getURL(this.getRelativeURL(t))}send(t){return this._transport.send(this.getURL(t),{method:"GET"})}};var at=class{constructor(t){this._transport=t}send({body:t,request:e={}}){return this._transport.send("v1/contacts",{...e,method:"POST",json:t})}};var ct=class{constructor(t){this._transport=t}send(t,{include:e,request:r={}}={}){return this._transport.send("v1/contacts/"+encodeURIComponent(t),{...r,method:"GET",searchParams:[...this._transport.includeQuery(e??{})]})}};var lt=class{constructor(t){this._transport=t}send({limit:t,query:e,request:r={}}={}){return this._transport.send("v1/contacts",{...r,method:"GET",searchParams:[...this._transport.limitQuery(t),...this._transport.queryQuery(e)]})}};var dt=class{constructor(t){this._transport=t}send(t,{body:e,request:r={}}){return this._transport.send("v1/contacts/"+encodeURIComponent(t),{...r,method:"PATCH",json:e})}};var ut=class{constructor(t){this._transport=t}send(t,{limit:e,request:r={}}={}){return this._transport.send("v1/contacts/"+encodeURIComponent(t)+"/conversations",{...r,method:"GET",searchParams:[...this._transport.limitQuery(e)]})}};var mt=class{constructor(t){this._transport=t}send(t,{limit:e,request:r={}}={}){return this._transport.send("v1/contacts/"+encodeURIComponent(t)+"/labels",{...r,method:"GET",searchParams:[...this._transport.limitQuery(e)]})}};var ht=class{constructor(t){this._transport=t}send(t,{body:e,request:r={}}){return this._transport.send("v1/contacts/"+encodeURIComponent(t)+"/notes",{...r,method:"POST",json:e})}};var ft=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/contacts/"+encodeURIComponent(t)+"/notes",{...e,method:"GET"})}};var Ct=class{constructor(t){this._transport=t}send(t,{body:e,request:r={}}){return this._transport.send("v1/contacts/"+encodeURIComponent(t)+"/notification-subscriptions",{...r,method:"POST",json:e})}};var gt=class{constructor(t){this._transport=t}get api(){return{get:new ct(this._transport),list:new lt(this._transport),update:new dt(this._transport),create:new at(this._transport),conversation:{list:new ut(this._transport)},label:{list:new mt(this._transport)},note:{list:new ft(this._transport),create:new ht(this._transport)},notificationSubscription:{create:new Ct(this._transport)},vcf:{get:new pt(this._transport)}}}};var bt=class{constructor(t){this._transport=t}send(t,{include:e,request:r={}}={}){return this._transport.send("v1/conversations/"+encodeURIComponent(t),{...r,method:"GET",searchParams:[...this._transport.includeQuery(e??{})]})}};var _t=class{constructor(t){this._transport=t}send({limit:t,filter:e,include:r,request:s={}}={}){return this._transport.send("v1/conversations",{...s,method:"GET",searchParams:[...this._transport.limitQuery(t),...e?[["filter",e]]:[],...this._transport.includeQuery(r??{})]})}};var Ot=class{constructor(t){this._transport=t}send(t,{body:e,request:r={}}){return this._transport.send("v1/conversations/"+encodeURIComponent(t),{...r,method:"PATCH",json:e})}};var xt=class{constructor(t){this._transport=t}send(t,{limit:e,request:r={}}={}){return this._transport.send("v1/conversations/"+encodeURIComponent(t)+"/labels",{...r,method:"GET",searchParams:[...this._transport.limitQuery(e)]})}};var yt=class{constructor(t){this._transport=t}send(t,{limit:e,include:r,request:s={}}={}){return this._transport.send("v1/conversations/"+encodeURIComponent(t)+"/messages",{...s,method:"GET",searchParams:[...this._transport.limitQuery(e),...this._transport.includeQuery(r??{})]})}};var b=class{constructor(t){this._transport=t}send(t,{body:e,request:r={}}){return this._transport.send("v1/conversations/"+encodeURIComponent(t)+"/notes",{...r,method:"POST",json:e})}};var St=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/conversations/"+encodeURIComponent(t)+"/notes",{...e,method:"GET"})}};var Tt=class{constructor(t){this._transport=t}get api(){return{get:new bt(this._transport),list:new _t(this._transport),update:new Ot(this._transport),create:new b(this._transport),label:{list:new xt(this._transport)},message:{list:new yt(this._transport)},note:{list:new St(this._transport),create:new b(this._transport)}}}};var Rt=class{constructor(t){this._transport=t}send(t,{limit:e,request:r={}}={}){return this._transport.send("v1/labels/"+encodeURIComponent(t)+"/contacts",{...r,method:"GET",searchParams:[...this._transport.limitQuery(e)]})}};var vt=class{constructor(t){this._transport=t}send(t,{limit:e,request:r={}}={}){return this._transport.send("v1/labels/"+encodeURIComponent(t)+"/conversations",{...r,method:"GET",searchParams:[...this._transport.limitQuery(e)]})}};var Ft=class{constructor(t){this._transport=t}send({body:t,request:e={}}){return this._transport.send("v1/labels",{...e,method:"POST",json:t})}};var At=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/labels/"+encodeURIComponent(t),{...e,method:"DELETE"})}};var wt=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/labels/"+encodeURIComponent(t),{...e,method:"GET"})}};var Lt=class{constructor(t){this._transport=t}send({limit:t,query:e,include:r,request:s={}}={}){return this._transport.send("v1/labels",{...s,method:"GET",searchParams:[...this._transport.limitQuery(t),...this._transport.queryQuery(e),...this._transport.includeQuery(r??{})]})}};var Ut=class{constructor(t){this._transport=t}send(t,{body:e,request:r={}}){return this._transport.send("v1/labels/"+encodeURIComponent(t),{...r,method:"PATCH",json:e})}};var Et=class{constructor(t){this._transport=t}get api(){return{create:new Ft(this._transport),get:new wt(this._transport),list:new Lt(this._transport),update:new Ut(this._transport),delete:new At(this._transport),contact:{list:new Rt(this._transport)},conversation:{list:new vt(this._transport)}}}};var Nt=class{constructor(t){this._transport=t}send({limit:t,include:e,request:r={}}={}){return this._transport.send("v1/messages",{...r,method:"GET",searchParams:[...this._transport.limitQuery(t),...this._transport.includeQuery(e??{})]})}};var Gt=class{constructor(t){this._transport=t}get api(){return{list:new Nt(this._transport)}}};var Pt=class{constructor(t){this._transport=t}send(t,{body:e,request:r={}}){return this._transport.send("v1/models/"+encodeURIComponent(t)+"/correction",{...r,method:"POST",json:e})}};var qt=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/models/"+encodeURIComponent(t),{...e,method:"GET"})}};var It=class{constructor(t){this._transport=t}send({request:t={}}={}){return this._transport.send("v1/models",{...t,method:"GET"})}};var Bt=class{constructor(t){this._transport=t}send(t,{body:e,request:r={}}){return this._transport.send("v1/models/"+encodeURIComponent(t)+"/response",{...r,method:"POST",timeout:12e4,json:e})}};var kt=class{constructor(t){this._transport=t}get api(){return{get:new qt(this._transport),list:new It(this._transport),response:{create:new Bt(this._transport)},correction:{create:new Pt(this._transport)}}}};var Mt=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/notes/"+encodeURIComponent(t),{...e,method:"GET"})}};var jt=class{constructor(t){this._transport=t}send(t,{body:e,request:r={}}){return this._transport.send("v1/notes/"+encodeURIComponent(t),{...r,method:"PATCH",json:e})}};var Qt=class{constructor(t){this._transport=t}get api(){return{get:new Mt(this._transport),update:new jt(this._transport)}}};var Dt=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/sources/"+encodeURIComponent(t),{...e,method:"GET"})}};var Ht=class{constructor(t){this._transport=t}send({featured:t,category:e,request:r={}}={}){let s=[];if(e){let p=Array.isArray(e)?e:[e];for(let g of p)s.push(["category",g])}return t!==void 0&&s.push(["featured",String(t)]),this._transport.send("v1/sources",{...r,method:"GET",searchParams:s})}};var Kt=class{constructor(t){this._transport=t}get api(){return{get:new Dt(this._transport),list:new Ht(this._transport)}}};var Vt=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/channels/"+encodeURIComponent(t)+"/statistics/message-frequency",{...e,method:"GET"})}};var Wt=class{constructor(t){this._transport=t}send({request:t={}}={}){return this._transport.send("v1/statistics/message-frequency",{...t,method:"GET"})}};var zt=class{constructor(t){this._transport=t}get api(){return{messageFrequency:new Wt(this._transport),channelMessageFrequency:new Vt(this._transport)}}};var Yt=class{constructor(t){this._transport=t}send({account:t,files:e,request:r={}}){let s=new FormData;for(let p of e)s.append("file",p);return this._transport.send("v1/uploads",{...r,method:"POST",body:s,searchParams:{account:t}})}};var $t=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/uploads/"+encodeURIComponent(t),{...e,method:"DELETE"})}};var Jt=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/uploads/"+encodeURIComponent(t),{...e,method:"GET"})}};var Xt=class{constructor(t){this._transport=t}get api(){return{get:new Jt(this._transport),create:new Yt(this._transport),delete:new $t(this._transport)}}};var Zt=class{constructor(t){this._transport=t}send({request:t={}}={}){return this._transport.send(".well-known/notifications",{...t,method:"GET"})}};var te=class{constructor(t){this._transport=t}get api(){return{notification:{get:new Zt(this._transport)}}}};var _=class o{static DEFAULT_BASE_URL=oe;static PublicAuthentication=m;static BasicAuthentication=l;static BearerAuthentication=u;_transport;_account;_accountAccessToken;_accountConversationSettings;_action;_boilerplateContent;_boilerplateCategory;_channel;_compositionSection;_contact;_conversation;_label;_message;_model;_note;_source;_statistics;_upload;_webhook;_wellKnown;constructor(t,{baseURL:e,...r}={}){this._transport=new x({requestFilterables:[new O,t],...r,baseURL:e?.toString()??o.getBaseURL()}),this._account=new L(this._transport),this._accountAccessToken=new F(this._transport),this._accountConversationSettings=new N(this._transport),this._action=new P(this._transport),this._boilerplateContent=new V(this._transport),this._boilerplateCategory=new j(this._transport),this._channel=new et(this._transport),this._compositionSection=new it(this._transport),this._contact=new gt(this._transport),this._conversation=new Tt(this._transport),this._label=new Et(this._transport),this._message=new Gt(this._transport),this._model=new kt(this._transport),this._note=new Qt(this._transport),this._source=new Kt(this._transport),this._statistics=new zt(this._transport),this._upload=new Xt(this._transport),this._webhook=new y(this),this._wellKnown=new te(this._transport)}static getBaseURL(){return process.env[he]??this.DEFAULT_BASE_URL}get account(){return this._account.api}get accountAccessToken(){return this._accountAccessToken.api}get accountConversationSettings(){return this._accountConversationSettings.api}get action(){return this._action.api}get boilerplate(){return this._boilerplateContent.api}get boilerplateContent(){return this._boilerplateContent.api}get boilerplateCategory(){return this._boilerplateCategory.api}get channel(){return this._channel.api}get compositionSection(){return this._compositionSection.api}get contact(){return this._contact.api}get conversation(){return this._conversation.api}get label(){return this._label.api}get message(){return this._message.api}get model(){return this._model.api}get note(){return this._note.api}get source(){return this._source.api}get statistics(){return this._statistics.api}get upload(){return this._upload.api}get webhook(){return this._webhook}get wellKnown(){return this._wellKnown.api}};var ie={};pe(ie,{AuthError:()=>c,AuthenticationError:()=>h,AuthorizationError:()=>f,LogicError:()=>a,NetworkError:()=>C,SupportError:()=>i,ValidationError:()=>d});0&&(module.exports={BasicAuthentication,BearerAuthentication,Client,DEFAULT_SUPPORT_BASE_URL,Error,KeyAuthentication,PublicAuthentication});
package/dist/index.d.cts CHANGED
@@ -1,5 +1,5 @@
1
- import { A as Account, a as Conversation } from './index-CGgn2yv_.cjs';
2
- export { d as AccountAccessToken, g as AccountConversationSettings, j as Action, B as BasicAuthentication, c as BearerAuthentication, r as BoilerplateCategory, l as BoilerplateContent, w as Channel, C as Client, F as CompositionSection, Q as Contact, e as CreateAccountAccessTokenResponse, s as CreateBoilerplateCategoryResponse, m as CreateBoilerplateContentResponse, E as CreateChannelResponse, J as CreateCompositionSectionResponse, al as CreateContactNoteResponse, av as CreateContactNotificationSubscriptionResponse, S as CreateContactResponse, am as CreateConversationNoteResponse, ai as CreateCorrectionResponse, a4 as CreateLabelResponse, aj as CreateResponseResponse, ax as CreateUploadResponse, D as DeleteAccountAccessTokenResponse, a5 as DeleteLabelResponse, az as DeleteUploadResponse, f as GetAccountAccessTokenResponse, h as GetAccountConversationSettingsResponse, G as GetAccountResponse, t as GetBoilerplateCategoryResponse, o as GetBoilerplateContentResponse, y as GetChannelResponse, H as GetCompositionSectionResponse, V as GetContactResponse, _ as GetConversationResponse, a6 as GetLabelResponse, ag as GetModelResponse, an as GetNoteResponse, aA as GetNotificationWellKnownResponse, as as GetSourceResponse, ay as GetUploadResponse, B as KeyAuthentication, a3 as Label, L as ListAccountAccessTokensResponse, k as ListActionsResponse, u as ListBoilerplateCategoriesResponse, n as ListBoilerplateCategoryBoilerplateContentsResponse, p as ListBoilerplateContentsResponse, K as ListChannelCompositionSectionsResponse, ae as ListChannelMessagesResponse, x as ListChannelsResponse, I as ListCompositionSectionsResponse, a2 as ListContactConversationsResponse, aa as ListContactLabelsResponse, ao as ListContactNotesResponse, X as ListContactsResponse, a9 as ListConversationLabelsResponse, ac as ListConversationMessagesResponse, ap as ListConversationNotesResponse, $ as ListConversationsResponse, Y as ListLabelContactsResponse, a0 as ListLabelConversationsResponse, a7 as ListLabelsResponse, ad as ListMessagesResponse, ah as ListModelsResponse, at as ListSourcesResponse, ab as Message, M as MetaWhatsappGetBusinessProfileResponse, af as Model, ak as Note, au as NotificationSubscription, O as Options, P as PublicAuthentication, R as RequestFilterable, ar as Source, b as TransportOptions, T as TwilioSendgridChannelSyncResponse, i as UpdateAccountConversationSettingsResponse, U as UpdateAccountResponse, v as UpdateBoilerplateCategoryResponse, q as UpdateBoilerplateContentResponse, z as UpdateChannelResponse, N as UpdateCompositionSectionResponse, Z as UpdateContactResponse, a1 as UpdateConversationResponse, a8 as UpdateLabelResponse, aq as UpdateNoteResponse, aw as Upload, W as WebhookResponse, C as default } from './index-CGgn2yv_.cjs';
1
+ import { A as Account, a as Conversation } from './index-D-0Ds3Qp.cjs';
2
+ export { d as AccountAccessToken, g as AccountConversationSettings, j as Action, B as BasicAuthentication, c as BearerAuthentication, r as BoilerplateCategory, l as BoilerplateContent, w as Channel, C as Client, F as CompositionSection, Q as Contact, e as CreateAccountAccessTokenResponse, s as CreateBoilerplateCategoryResponse, m as CreateBoilerplateContentResponse, E as CreateChannelResponse, J as CreateCompositionSectionResponse, al as CreateContactNoteResponse, av as CreateContactNotificationSubscriptionResponse, S as CreateContactResponse, am as CreateConversationNoteResponse, ai as CreateCorrectionResponse, a4 as CreateLabelResponse, aj as CreateResponseResponse, ax as CreateUploadResponse, D as DeleteAccountAccessTokenResponse, a5 as DeleteLabelResponse, az as DeleteUploadResponse, f as GetAccountAccessTokenResponse, h as GetAccountConversationSettingsResponse, G as GetAccountResponse, t as GetBoilerplateCategoryResponse, o as GetBoilerplateContentResponse, y as GetChannelResponse, H as GetCompositionSectionResponse, V as GetContactResponse, _ as GetConversationResponse, a6 as GetLabelResponse, ag as GetModelResponse, an as GetNoteResponse, aA as GetNotificationWellKnownResponse, as as GetSourceResponse, ay as GetUploadResponse, B as KeyAuthentication, a3 as Label, L as ListAccountAccessTokensResponse, k as ListActionsResponse, u as ListBoilerplateCategoriesResponse, n as ListBoilerplateCategoryBoilerplateContentsResponse, p as ListBoilerplateContentsResponse, K as ListChannelCompositionSectionsResponse, ae as ListChannelMessagesResponse, x as ListChannelsResponse, I as ListCompositionSectionsResponse, a2 as ListContactConversationsResponse, aa as ListContactLabelsResponse, ao as ListContactNotesResponse, X as ListContactsResponse, a9 as ListConversationLabelsResponse, ac as ListConversationMessagesResponse, ap as ListConversationNotesResponse, $ as ListConversationsResponse, Y as ListLabelContactsResponse, a0 as ListLabelConversationsResponse, a7 as ListLabelsResponse, ad as ListMessagesResponse, ah as ListModelsResponse, at as ListSourcesResponse, ab as Message, M as MetaWhatsappGetBusinessProfileResponse, af as Model, ak as Note, au as NotificationSubscription, O as Options, P as PublicAuthentication, R as RequestFilterable, ar as Source, b as TransportOptions, T as TwilioSendgridChannelSyncResponse, i as UpdateAccountConversationSettingsResponse, U as UpdateAccountResponse, v as UpdateBoilerplateCategoryResponse, q as UpdateBoilerplateContentResponse, z as UpdateChannelResponse, N as UpdateCompositionSectionResponse, Z as UpdateContactResponse, a1 as UpdateConversationResponse, a8 as UpdateLabelResponse, aq as UpdateNoteResponse, aw as Upload, W as WebhookResponse, C as default } from './index-D-0Ds3Qp.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 Account, a as Conversation } from './index-CGgn2yv_.js';
2
- export { d as AccountAccessToken, g as AccountConversationSettings, j as Action, B as BasicAuthentication, c as BearerAuthentication, r as BoilerplateCategory, l as BoilerplateContent, w as Channel, C as Client, F as CompositionSection, Q as Contact, e as CreateAccountAccessTokenResponse, s as CreateBoilerplateCategoryResponse, m as CreateBoilerplateContentResponse, E as CreateChannelResponse, J as CreateCompositionSectionResponse, al as CreateContactNoteResponse, av as CreateContactNotificationSubscriptionResponse, S as CreateContactResponse, am as CreateConversationNoteResponse, ai as CreateCorrectionResponse, a4 as CreateLabelResponse, aj as CreateResponseResponse, ax as CreateUploadResponse, D as DeleteAccountAccessTokenResponse, a5 as DeleteLabelResponse, az as DeleteUploadResponse, f as GetAccountAccessTokenResponse, h as GetAccountConversationSettingsResponse, G as GetAccountResponse, t as GetBoilerplateCategoryResponse, o as GetBoilerplateContentResponse, y as GetChannelResponse, H as GetCompositionSectionResponse, V as GetContactResponse, _ as GetConversationResponse, a6 as GetLabelResponse, ag as GetModelResponse, an as GetNoteResponse, aA as GetNotificationWellKnownResponse, as as GetSourceResponse, ay as GetUploadResponse, B as KeyAuthentication, a3 as Label, L as ListAccountAccessTokensResponse, k as ListActionsResponse, u as ListBoilerplateCategoriesResponse, n as ListBoilerplateCategoryBoilerplateContentsResponse, p as ListBoilerplateContentsResponse, K as ListChannelCompositionSectionsResponse, ae as ListChannelMessagesResponse, x as ListChannelsResponse, I as ListCompositionSectionsResponse, a2 as ListContactConversationsResponse, aa as ListContactLabelsResponse, ao as ListContactNotesResponse, X as ListContactsResponse, a9 as ListConversationLabelsResponse, ac as ListConversationMessagesResponse, ap as ListConversationNotesResponse, $ as ListConversationsResponse, Y as ListLabelContactsResponse, a0 as ListLabelConversationsResponse, a7 as ListLabelsResponse, ad as ListMessagesResponse, ah as ListModelsResponse, at as ListSourcesResponse, ab as Message, M as MetaWhatsappGetBusinessProfileResponse, af as Model, ak as Note, au as NotificationSubscription, O as Options, P as PublicAuthentication, R as RequestFilterable, ar as Source, b as TransportOptions, T as TwilioSendgridChannelSyncResponse, i as UpdateAccountConversationSettingsResponse, U as UpdateAccountResponse, v as UpdateBoilerplateCategoryResponse, q as UpdateBoilerplateContentResponse, z as UpdateChannelResponse, N as UpdateCompositionSectionResponse, Z as UpdateContactResponse, a1 as UpdateConversationResponse, a8 as UpdateLabelResponse, aq as UpdateNoteResponse, aw as Upload, W as WebhookResponse, C as default } from './index-CGgn2yv_.js';
1
+ import { A as Account, a as Conversation } from './index-D-0Ds3Qp.js';
2
+ export { d as AccountAccessToken, g as AccountConversationSettings, j as Action, B as BasicAuthentication, c as BearerAuthentication, r as BoilerplateCategory, l as BoilerplateContent, w as Channel, C as Client, F as CompositionSection, Q as Contact, e as CreateAccountAccessTokenResponse, s as CreateBoilerplateCategoryResponse, m as CreateBoilerplateContentResponse, E as CreateChannelResponse, J as CreateCompositionSectionResponse, al as CreateContactNoteResponse, av as CreateContactNotificationSubscriptionResponse, S as CreateContactResponse, am as CreateConversationNoteResponse, ai as CreateCorrectionResponse, a4 as CreateLabelResponse, aj as CreateResponseResponse, ax as CreateUploadResponse, D as DeleteAccountAccessTokenResponse, a5 as DeleteLabelResponse, az as DeleteUploadResponse, f as GetAccountAccessTokenResponse, h as GetAccountConversationSettingsResponse, G as GetAccountResponse, t as GetBoilerplateCategoryResponse, o as GetBoilerplateContentResponse, y as GetChannelResponse, H as GetCompositionSectionResponse, V as GetContactResponse, _ as GetConversationResponse, a6 as GetLabelResponse, ag as GetModelResponse, an as GetNoteResponse, aA as GetNotificationWellKnownResponse, as as GetSourceResponse, ay as GetUploadResponse, B as KeyAuthentication, a3 as Label, L as ListAccountAccessTokensResponse, k as ListActionsResponse, u as ListBoilerplateCategoriesResponse, n as ListBoilerplateCategoryBoilerplateContentsResponse, p as ListBoilerplateContentsResponse, K as ListChannelCompositionSectionsResponse, ae as ListChannelMessagesResponse, x as ListChannelsResponse, I as ListCompositionSectionsResponse, a2 as ListContactConversationsResponse, aa as ListContactLabelsResponse, ao as ListContactNotesResponse, X as ListContactsResponse, a9 as ListConversationLabelsResponse, ac as ListConversationMessagesResponse, ap as ListConversationNotesResponse, $ as ListConversationsResponse, Y as ListLabelContactsResponse, a0 as ListLabelConversationsResponse, a7 as ListLabelsResponse, ad as ListMessagesResponse, ah as ListModelsResponse, at as ListSourcesResponse, ab as Message, M as MetaWhatsappGetBusinessProfileResponse, af as Model, ak as Note, au as NotificationSubscription, O as Options, P as PublicAuthentication, R as RequestFilterable, ar as Source, b as TransportOptions, T as TwilioSendgridChannelSyncResponse, i as UpdateAccountConversationSettingsResponse, U as UpdateAccountResponse, v as UpdateBoilerplateCategoryResponse, q as UpdateBoilerplateContentResponse, z as UpdateChannelResponse, N as UpdateCompositionSectionResponse, Z as UpdateContactResponse, a1 as UpdateConversationResponse, a8 as UpdateLabelResponse, aq as UpdateNoteResponse, aw as Upload, W as WebhookResponse, C as default } from './index-D-0Ds3Qp.js';
3
3
  import 'ky';
4
4
  import 'zod';
5
5
 
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- import{a as s,b as i,c as r,d as l,e as n,f as o,g as t,h as e,i as f,j as p,k as a,l as m,m as x}from"./chunk-HR2YP6TH.js";var u={};s(u,{AuthError:()=>t,AuthenticationError:()=>e,AuthorizationError:()=>f,LogicError:()=>p,NetworkError:()=>a,SupportError:()=>o,ValidationError:()=>m});export{r as BasicAuthentication,l as BearerAuthentication,x as Client,n as DEFAULT_SUPPORT_BASE_URL,u as Error,r as KeyAuthentication,i as PublicAuthentication,x as default};
1
+ import{a as s,b as i,c as r,d as l,e as n,f as o,g as t,h as e,i as f,j as p,k as a,l as m,m as x}from"./chunk-AOL7NCTI.js";var u={};s(u,{AuthError:()=>t,AuthenticationError:()=>e,AuthorizationError:()=>f,LogicError:()=>p,NetworkError:()=>a,SupportError:()=>o,ValidationError:()=>m});export{r as BasicAuthentication,l as BearerAuthentication,x as Client,n as DEFAULT_SUPPORT_BASE_URL,u as Error,r as KeyAuthentication,i as PublicAuthentication,x as default};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@great-detail/support-sdk",
3
- "version": "0.15.1",
3
+ "version": "0.15.3",
4
4
  "type": "module",
5
5
  "description": "JavaScript SDK for the Great Detail Support System",
6
6
  "author": "Great Detail Ltd <info@greatdetail.com>",
@@ -1 +0,0 @@
1
- var le=Object.defineProperty;var he=(o,t)=>{for(var e in t)le(o,e,{get:t[e],enumerable:!0})};var u=class{getHeaders(){return{}}};var oe="SUPPORT_ACCESS_TOKEN",re="SUPPORT_KEY_NAME",ne="SUPPORT_KEY_PASSWORD",te="SUPPORT_SIGNING_KEY",se="SUPPORT_BASE_URL";var m=class{name;#t;constructor({name:t=process.env[re],password:e=process.env[ne]}={}){if(!t)throw new Error("Name option must be specified when using Basic Authentication");if(!e)throw new Error("Password option must be specified when using Basic Authentication");this.name=t,this.#t=e}getHeaders(){return{Authorization:`Basic ${btoa(this.name+":"+this.#t)}`}}};var h=class{#t;constructor({token:t=process.env[oe]}={}){if(!t)throw new Error("Access Token option must be specified when using Token Authentication");this.#t=t}getHeaders(){return{Authorization:`Bearer ${this.#t}`}}};var ie="https://api.support.greatdetail.com",pe={"X-Powered-By":"GDSupport/JavaScript"};import{z as n}from"zod";var f=class o{constructor(t){this._client=t}static SCHEMA=n.object({data:n.object({event:n.intersection(n.object({id:n.string(),createdAt:n.string().datetime()}),n.union([n.object({type:n.union([n.literal("account.created"),n.literal("account.updated")]),payload:n.object({account:n.string()})}),n.object({type:n.union([n.literal("accountAccessToken.created"),n.literal("accountAccessToken.deleted")]),payload:n.object({accountAccessToken:n.string()})}),n.object({type:n.union([n.literal("contact.created"),n.literal("contact.updated")]),payload:n.object({contact:n.string()})}),n.object({type:n.union([n.literal("conversation.created"),n.literal("conversation.updated"),n.literal("conversation.closed"),n.literal("conversation.received"),n.literal("conversation.resolved"),n.literal("conversation.sent")]),payload:n.object({conversation:n.string()})}),n.object({type:n.union([n.literal("message.created"),n.literal("message.updated"),n.literal("message.delivered"),n.literal("message.failed"),n.literal("message.read"),n.literal("message.received"),n.literal("message.sent")]),payload:n.object({message:n.string()})})]))})});async event({key:t=process.env[te],maxSignatures:e=3,request:r}){let s=r.headers["gds-signature"];if(t!==!1){if(t===void 0)throw new Error("Missing webhook signing key in process.env."+te);if(!s)throw new Error("Missing signature header");if(!this._verifySignature(t,r.body,Array.isArray(s)?s.slice(0,e):[s]))throw new Error("Untrusted signature")}let{data:i}=o.SCHEMA.parse(r.body);return{event:i.event}}async _verifySignature(t,e,r){let s=await crypto.subtle.importKey("raw",new TextEncoder().encode(t),{name:"HMAC",hash:"SHA-256"},!1,["sign","verify"]);for(let i of r)if(await crypto.subtle.verify("HMAC",s,new TextEncoder().encode(atob(i)),new TextEncoder().encode(JSON.stringify(e))))return!0;return!1}};var C=class o{constructor(t=o.STANDARD_HEADERS){this._standardHeaders=t}static STANDARD_HEADERS=pe;async filter(){return{headers:this.getHeaders()}}getHeaders(){return this._standardHeaders}};import de from"is-network-error";import ue,{HTTPError as me}from"ky";var p=class extends Error{static serverError(t){return new this("Server Error: "+t)}};var c=class extends p{};var g=class extends c{static unauthenticated(){return new this("An unauthenticated request occurred")}};var b=class extends c{static forbidden(){return new this("A forbidden request occurred")}};var a=class extends p{static notFound(t){return new this(`Record not found for request: ${t}`)}static forbiddenMethod(t,e){return new this(`Forbidden method for request: ${t} ${e}`)}static teapot(){return new this("I'm a teapot")}static rateLimited(){return new this("Request has been rate-limited")}};var _=class extends p{};var l=class extends p{static badRequest(){return new this("Bad request")}static unsupportedMediaType(){return new this("Unsupported Media Type")}};var O=class{client;options;constructor({baseURL:t,...e}){this.options={...e,baseURL:t},this.client=ue.create({prefixUrl:this.options.baseURL,timeout:12e3,hooks:{beforeRequest:[r=>{for(let s of this.options.requestFilterables){let i=s.getHeaders();for(let[Zt,ce]of Object.entries(i))r.headers.has(Zt)||r.headers.set(Zt,ce)}}]}})}getURL(t){return new URL(t,this.options.baseURL).toString()}sortQuery(t){let e=[];if(t===void 0)return e;for(let[r,s]of Object.entries(t))s!==void 0&&e.push(["sort",s+r]);return e}limitQuery(t){let e=[];return t===void 0||e.push(["limit",t.toString()]),e}includeQuery(t){let e=[];if(t===void 0)return e;for(let r of Object.keys(t))e.push(["include",r]);return e}queryQuery(t){let e=[];return t===void 0||e.push(["query",t]),e}send(t,e={}){let r=this.client(t,e).catch(s=>{if(de(s))throw new _("A network error occurred",{cause:s});if(s instanceof me){let i=s.response.status;switch(console.error(JSON.stringify(s.response)),i){case 400:throw l.badRequest();case 401:throw g.unauthenticated();case 403:throw b.forbidden();case 404:throw a.notFound(t);case 405:throw a.forbiddenMethod(t,e.method??"GET");case 415:throw l.unsupportedMediaType();case 418:throw a.teapot();case 429:throw a.rateLimited()}if(i>=500&&i<600)throw p.serverError(i)}throw s});return{response:()=>r,json:async()=>(await r).json()}}};var y=class{constructor(t){this._transport=t}send(t,{body:e={},request:r={}}={}){return this._transport.send("v1/accounts/"+encodeURIComponent(t)+"/access-tokens",{...r,method:"POST",json:e})}};var x=class{constructor(t){this._transport=t}send(t,e,{body:r,request:s={}}={}){return this._transport.send("v1/accounts/"+encodeURIComponent(t)+"/access-tokens/"+encodeURIComponent(e),{...s,method:"DELETE",json:r})}};var S=class{constructor(t){this._transport=t}send(t,e,{request:r={}}={}){return this._transport.send("v1/accounts/"+encodeURIComponent(t)+"/access-tokens/"+encodeURIComponent(e),{...r,method:"GET"})}};var T=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/accounts/"+encodeURIComponent(t)+"/access-tokens",{...e,method:"GET"})}};var R=class{constructor(t){this._transport=t}get api(){return{get:new S(this._transport),list:new T(this._transport),create:new y(this._transport),delete:new x(this._transport)}}};var v=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/accounts/"+encodeURIComponent(t),{...e,method:"GET"})}};var F=class{constructor(t){this._transport=t}send(t,{body:e,request:r={}}){return this._transport.send("v1/accounts/"+encodeURIComponent(t),{...r,method:"PATCH",json:e})}};var A=class{constructor(t){this._transport=t}get api(){return{get:new v(this._transport),update:new F(this._transport)}}};var w=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/accounts/"+encodeURIComponent(t)+"/conversation-settings",{...e,method:"GET"})}};var L=class{constructor(t){this._transport=t}send(t,{body:e,request:r={}}){return this._transport.send("v1/accounts/"+encodeURIComponent(t)+"/conversation-settings",{...r,method:"PATCH",json:e})}};var U=class{constructor(t){this._transport=t}get api(){return{get:new w(this._transport),update:new L(this._transport)}}};var E=class{constructor(t){this._transport=t}send({limit:t,sort:e,request:r={}}={}){return this._transport.send("v1/actions",{...r,method:"GET",searchParams:[...this._transport.limitQuery(t),...this._transport.sortQuery(e)]})}};var N=class{constructor(t){this._transport=t}get api(){return{list:new E(this._transport)}}};var G=class{constructor(t){this._transport=t}send({body:t,request:e={}}){return this._transport.send("v1/boilerplates/categories",{...e,method:"POST",json:t})}};var P=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/boilerplates/categories/"+encodeURIComponent(t),{...e,method:"GET"})}};var q=class{constructor(t){this._transport=t}send({limit:t,include:e,request:r={}}={}){return this._transport.send("v1/boilerplates/categories",{...r,method:"GET",searchParams:[...this._transport.limitQuery(t),...this._transport.includeQuery(e)]})}};var I=class{constructor(t){this._transport=t}send(t,{body:e,request:r={}}){return this._transport.send("v1/boilerplates/categories/"+encodeURIComponent(t),{...r,method:"PATCH",json:e})}};var B=class{constructor(t){this._transport=t}send(t,{limit:e,request:r={}}={}){return this._transport.send("v1/boilerplates/categories/"+encodeURIComponent(t)+"/contents",{...r,method:"GET",searchParams:[...this._transport.limitQuery(e)]})}};var M=class{constructor(t){this._transport=t}get api(){return{get:new P(this._transport),list:new q(this._transport),create:new G(this._transport),update:new I(this._transport),boilerplate:{list:new B(this._transport)}}}};var k=class{constructor(t){this._transport=t}send({body:t,request:e={}}){return this._transport.send("v1/boilerplates/contents",{...e,method:"POST",json:t})}};var j=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/boilerplates/contents/"+encodeURIComponent(t),{...e,method:"GET"})}};var Q=class{constructor(t){this._transport=t}send({limit:t,query:e,request:r={}}={}){return this._transport.send("v1/boilerplates/contents",{...r,method:"GET",searchParams:[...this._transport.limitQuery(t),...this._transport.queryQuery(e)]})}};var D=class{constructor(t){this._transport=t}send(t,{body:e,request:r={}}){return this._transport.send("v1/boilerplates/contents/"+encodeURIComponent(t),{...r,method:"PATCH",json:e})}};var H=class{constructor(t){this._transport=t}get api(){return{get:new j(this._transport),list:new Q(this._transport),update:new D(this._transport),create:new k(this._transport)}}};var K=class{constructor(t){this._transport=t}send({body:t,request:e={}}){return this._transport.send("v1/channels",{...e,method:"POST",json:t})}};var V=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/channels/"+encodeURIComponent(t),{...e,method:"GET"})}};var W=class{constructor(t){this._transport=t}send({limit:t,request:e={}}={}){return this._transport.send("v1/channels",{...e,method:"GET",searchParams:[...this._transport.limitQuery(t)]})}};var Y=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/channels/"+encodeURIComponent(t)+"/meta-whatsapp/business-profile",{...e,method:"GET"})}};import{z as ae}from"zod";var z=class o{constructor(t){this._transport=t}static SCHEMA=ae.object({overwrite:ae.boolean().optional()});send(t,{body:e,request:r={}}){return this._transport.send("v1/channels/"+encodeURIComponent(t)+"/twilio-sendgrid/sync",{...r,method:"POST",json:o.SCHEMA.parse(e)})}};var $=class{constructor(t){this._transport=t}send(t,{body:e,request:r={}}){return this._transport.send("v1/channels/"+encodeURIComponent(t),{...r,method:"PATCH",json:e})}};var J=class{constructor(t){this._transport=t}send(t,{limit:e,request:r={}}={}){return this._transport.send("v1/channels/"+encodeURIComponent(t)+"/composition-sections",{...r,method:"GET",searchParams:[...this._transport.limitQuery(e)]})}};var X=class{constructor(t){this._transport=t}send(t,{limit:e,include:r,request:s={}}={}){return this._transport.send("v1/channels/"+encodeURIComponent(t)+"/messages",{...s,method:"GET",searchParams:[...this._transport.limitQuery(e),...this._transport.includeQuery(r)]})}};var Z=class{constructor(t){this._transport=t}get api(){return{get:new V(this._transport),list:new W(this._transport),update:new $(this._transport),create:new K(this._transport),compositionSection:{list:new J(this._transport)},message:{list:new X(this._transport)},metaWhatsapp:{getBusinessProfile:new Y(this._transport)},twilioSendgrid:{sync:new z(this._transport)}}}};var tt=class{constructor(t){this._transport=t}send({body:t,request:e={}}){return this._transport.send("v1/composition-sections",{...e,method:"POST",json:t})}};var et=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/composition-sections/"+encodeURIComponent(t),{...e,method:"GET"})}};var ot=class{constructor(t){this._transport=t}send({limit:t,request:e={}}={}){return this._transport.send("v1/composition-sections",{...e,method:"GET",searchParams:[...this._transport.limitQuery(t)]})}};var rt=class{constructor(t){this._transport=t}send(t,{body:e,request:r={}}){return this._transport.send("v1/composition-sections/"+encodeURIComponent(t),{...r,method:"PATCH",json:e})}};var nt=class{constructor(t){this._transport=t}get api(){return{get:new et(this._transport),list:new ot(this._transport),create:new tt(this._transport),update:new rt(this._transport)}}};var st=class{constructor(t){this._transport=t}getRelativeURL({id:t,vcf:e={}}){let r=e.variant??"vcard",s=e.format??(r==="vcard"?"vcf":"json");return"v1/contacts/"+encodeURIComponent(t)+"/vcf?variant="+encodeURIComponent(r)+"&format="+encodeURIComponent(s)}getURL(t){return this._transport.getURL(this.getRelativeURL(t))}send(t){return this._transport.send(this.getURL(t),{method:"GET"})}};var it=class{constructor(t){this._transport=t}send({body:t,request:e={}}){return this._transport.send("v1/contacts",{...e,method:"POST",json:t})}};var pt=class{constructor(t){this._transport=t}send(t,{include:e,request:r={}}={}){return this._transport.send("v1/contacts/"+encodeURIComponent(t),{...r,method:"GET",searchParams:[...this._transport.includeQuery(e??{})]})}};var at=class{constructor(t){this._transport=t}send({limit:t,query:e,request:r={}}={}){return this._transport.send("v1/contacts",{...r,method:"GET",searchParams:[...this._transport.limitQuery(t),...this._transport.queryQuery(e)]})}};var ct=class{constructor(t){this._transport=t}send(t,{body:e,request:r={}}){return this._transport.send("v1/contacts/"+encodeURIComponent(t),{...r,method:"PATCH",json:e})}};var lt=class{constructor(t){this._transport=t}send(t,{limit:e,request:r={}}={}){return this._transport.send("v1/contacts/"+encodeURIComponent(t)+"/conversations",{...r,method:"GET",searchParams:[...this._transport.limitQuery(e)]})}};var dt=class{constructor(t){this._transport=t}send(t,{limit:e,request:r={}}={}){return this._transport.send("v1/contacts/"+encodeURIComponent(t)+"/labels",{...r,method:"GET",searchParams:[...this._transport.limitQuery(e)]})}};var ut=class{constructor(t){this._transport=t}send(t,{body:e,request:r={}}){return this._transport.send("v1/contacts/"+encodeURIComponent(t)+"/notes",{...r,method:"POST",json:e})}};var mt=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/contacts/"+encodeURIComponent(t)+"/notes",{...e,method:"GET"})}};var ht=class{constructor(t){this._transport=t}send(t,{body:e,request:r={}}){return this._transport.send("v1/contacts/"+encodeURIComponent(t)+"/notification-subscriptions",{...r,method:"POST",json:e})}};var ft=class{constructor(t){this._transport=t}get api(){return{get:new pt(this._transport),list:new at(this._transport),update:new ct(this._transport),create:new it(this._transport),conversation:{list:new lt(this._transport)},label:{list:new dt(this._transport)},note:{list:new mt(this._transport),create:new ut(this._transport)},notificationSubscription:{create:new ht(this._transport)},vcf:{get:new st(this._transport)}}}};var Ct=class{constructor(t){this._transport=t}send(t,{include:e,request:r={}}={}){return this._transport.send("v1/conversations/"+encodeURIComponent(t),{...r,method:"GET",searchParams:[...this._transport.includeQuery(e??{})]})}};var gt=class{constructor(t){this._transport=t}send({limit:t,filter:e,include:r,request:s={}}={}){return this._transport.send("v1/conversations",{...s,method:"GET",searchParams:[...this._transport.limitQuery(t),...e?[["filter",e]]:[],...this._transport.includeQuery(r??{})]})}};var bt=class{constructor(t){this._transport=t}send(t,{body:e,request:r={}}){return this._transport.send("v1/conversations/"+encodeURIComponent(t),{...r,method:"PATCH",json:e})}};var _t=class{constructor(t){this._transport=t}send(t,{limit:e,request:r={}}={}){return this._transport.send("v1/conversations/"+encodeURIComponent(t)+"/labels",{...r,method:"GET",searchParams:[...this._transport.limitQuery(e)]})}};var Ot=class{constructor(t){this._transport=t}send(t,{limit:e,include:r,request:s={}}={}){return this._transport.send("v1/conversations/"+encodeURIComponent(t)+"/messages",{...s,method:"GET",searchParams:[...this._transport.limitQuery(e),...this._transport.includeQuery(r??{})]})}};var d=class{constructor(t){this._transport=t}send(t,{body:e,request:r={}}){return this._transport.send("v1/conversations/"+encodeURIComponent(t)+"/notes",{...r,method:"POST",json:e})}};var yt=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/conversations/"+encodeURIComponent(t)+"/notes",{...e,method:"GET"})}};var xt=class{constructor(t){this._transport=t}get api(){return{get:new Ct(this._transport),list:new gt(this._transport),update:new bt(this._transport),create:new d(this._transport),label:{list:new _t(this._transport)},message:{list:new Ot(this._transport)},note:{list:new yt(this._transport),create:new d(this._transport)}}}};var St=class{constructor(t){this._transport=t}send(t,{limit:e,request:r={}}={}){return this._transport.send("v1/labels/"+encodeURIComponent(t)+"/contacts",{...r,method:"GET",searchParams:[...this._transport.limitQuery(e)]})}};var Tt=class{constructor(t){this._transport=t}send(t,{limit:e,request:r={}}={}){return this._transport.send("v1/labels/"+encodeURIComponent(t)+"/conversations",{...r,method:"GET",searchParams:[...this._transport.limitQuery(e)]})}};var Rt=class{constructor(t){this._transport=t}send({body:t,request:e={}}){return this._transport.send("v1/labels",{...e,method:"POST",json:t})}};var vt=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/labels/"+encodeURIComponent(t),{...e,method:"DELETE"})}};var Ft=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/labels/"+encodeURIComponent(t),{...e,method:"GET"})}};var At=class{constructor(t){this._transport=t}send({limit:t,query:e,include:r,request:s={}}={}){return this._transport.send("v1/labels",{...s,method:"GET",searchParams:[...this._transport.limitQuery(t),...this._transport.queryQuery(e),...this._transport.includeQuery(r??{})]})}};var wt=class{constructor(t){this._transport=t}send(t,{body:e,request:r={}}){return this._transport.send("v1/labels/"+encodeURIComponent(t),{...r,method:"PATCH",json:e})}};var Lt=class{constructor(t){this._transport=t}get api(){return{create:new Rt(this._transport),get:new Ft(this._transport),list:new At(this._transport),update:new wt(this._transport),delete:new vt(this._transport),contact:{list:new St(this._transport)},conversation:{list:new Tt(this._transport)}}}};var Ut=class{constructor(t){this._transport=t}send({limit:t,include:e,request:r={}}={}){return this._transport.send("v1/messages",{...r,method:"GET",searchParams:[...this._transport.limitQuery(t),...this._transport.includeQuery(e??{})]})}};var Et=class{constructor(t){this._transport=t}get api(){return{list:new Ut(this._transport)}}};var Nt=class{constructor(t){this._transport=t}send(t,{body:e,request:r={}}){return this._transport.send("v1/models/"+encodeURIComponent(t)+"/correction",{...r,method:"POST",json:e})}};var Gt=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/models/"+encodeURIComponent(t),{...e,method:"GET"})}};var Pt=class{constructor(t){this._transport=t}send({request:t={}}={}){return this._transport.send("v1/models",{...t,method:"GET"})}};var qt=class{constructor(t){this._transport=t}send(t,{body:e,request:r={}}){return this._transport.send("v1/models/"+encodeURIComponent(t)+"/response",{...r,method:"POST",timeout:12e4,json:e})}};var It=class{constructor(t){this._transport=t}get api(){return{get:new Gt(this._transport),list:new Pt(this._transport),response:{create:new qt(this._transport)},correction:{create:new Nt(this._transport)}}}};var Bt=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/notes/"+encodeURIComponent(t),{...e,method:"GET"})}};var Mt=class{constructor(t){this._transport=t}send(t,{body:e,request:r={}}){return this._transport.send("v1/notes/"+encodeURIComponent(t),{...r,method:"PATCH",json:e})}};var kt=class{constructor(t){this._transport=t}get api(){return{get:new Bt(this._transport),update:new Mt(this._transport)}}};var jt=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/sources/"+encodeURIComponent(t),{...e,method:"GET"})}};var Qt=class{constructor(t){this._transport=t}send({category:t,request:e={}}={}){let r=[];if(t){let s=Array.isArray(t)?t:[t];for(let i of s)r.push(["category",i])}return this._transport.send("v1/sources",{...e,method:"GET",searchParams:r})}};var Dt=class{constructor(t){this._transport=t}get api(){return{get:new jt(this._transport),list:new Qt(this._transport)}}};var Ht=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/channels/"+encodeURIComponent(t)+"/statistics/message-frequency",{...e,method:"GET"})}};var Kt=class{constructor(t){this._transport=t}send({request:t={}}={}){return this._transport.send("v1/statistics/message-frequency",{...t,method:"GET"})}};var Vt=class{constructor(t){this._transport=t}get api(){return{messageFrequency:new Kt(this._transport),channelMessageFrequency:new Ht(this._transport)}}};var Wt=class{constructor(t){this._transport=t}send({account:t,files:e,request:r={}}){let s=new FormData;for(let i of e)s.append("file",i);return this._transport.send("v1/uploads",{...r,method:"POST",body:s,searchParams:{account:t}})}};var Yt=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/uploads/"+encodeURIComponent(t),{...e,method:"DELETE"})}};var zt=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/uploads/"+encodeURIComponent(t),{...e,method:"GET"})}};var $t=class{constructor(t){this._transport=t}get api(){return{get:new zt(this._transport),create:new Wt(this._transport),delete:new Yt(this._transport)}}};var Jt=class{constructor(t){this._transport=t}send({request:t={}}={}){return this._transport.send(".well-known/notifications",{...t,method:"GET"})}};var Xt=class{constructor(t){this._transport=t}get api(){return{notification:{get:new Jt(this._transport)}}}};var ee=class o{static DEFAULT_BASE_URL=ie;static PublicAuthentication=u;static BasicAuthentication=m;static BearerAuthentication=h;_transport;_account;_accountAccessToken;_accountConversationSettings;_action;_boilerplateContent;_boilerplateCategory;_channel;_compositionSection;_contact;_conversation;_label;_message;_model;_note;_source;_statistics;_upload;_webhook;_wellKnown;constructor(t,{baseURL:e,...r}={}){this._transport=new O({requestFilterables:[new C,t],...r,baseURL:e?.toString()??o.getBaseURL()}),this._account=new A(this._transport),this._accountAccessToken=new R(this._transport),this._accountConversationSettings=new U(this._transport),this._action=new N(this._transport),this._boilerplateContent=new H(this._transport),this._boilerplateCategory=new M(this._transport),this._channel=new Z(this._transport),this._compositionSection=new nt(this._transport),this._contact=new ft(this._transport),this._conversation=new xt(this._transport),this._label=new Lt(this._transport),this._message=new Et(this._transport),this._model=new It(this._transport),this._note=new kt(this._transport),this._source=new Dt(this._transport),this._statistics=new Vt(this._transport),this._upload=new $t(this._transport),this._webhook=new f(this),this._wellKnown=new Xt(this._transport)}static getBaseURL(){return process.env[se]??this.DEFAULT_BASE_URL}get account(){return this._account.api}get accountAccessToken(){return this._accountAccessToken.api}get accountConversationSettings(){return this._accountConversationSettings.api}get action(){return this._action.api}get boilerplate(){return this._boilerplateContent.api}get boilerplateContent(){return this._boilerplateContent.api}get boilerplateCategory(){return this._boilerplateCategory.api}get channel(){return this._channel.api}get compositionSection(){return this._compositionSection.api}get contact(){return this._contact.api}get conversation(){return this._conversation.api}get label(){return this._label.api}get message(){return this._message.api}get model(){return this._model.api}get note(){return this._note.api}get source(){return this._source.api}get statistics(){return this._statistics.api}get upload(){return this._upload.api}get webhook(){return this._webhook}get wellKnown(){return this._wellKnown.api}};export{he as a,u as b,m as c,h as d,ie as e,p as f,c as g,g as h,b as i,a as j,_ as k,l,ee as m};