@great-detail/support-sdk 0.11.1 → 0.11.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.
package/README.md CHANGED
@@ -3,12 +3,8 @@
3
3
  ## Getting Started
4
4
 
5
5
  ```typescript
6
- // ESM
7
-
8
6
  import Client, { TokenAuthentication } from "@great-detail/support-sdk";
9
7
 
10
- // Note: CJS dist files are also published
11
-
12
8
  const auth = new TokenAuthentication();
13
9
  const sdk = new Client(auth);
14
10
 
@@ -17,6 +13,22 @@ const result = await sdk.contact.list.send().json();
17
13
  console.log(result);
18
14
  ```
19
15
 
16
+ ## Handling Webhook Events
17
+
18
+ ```typescript
19
+ import Client from "@great-detail/support-sdk";
20
+
21
+ const { event } = await new Client().webhook
22
+ .event({
23
+ request,
24
+ })
25
+ .catch((error) => {
26
+ // ...
27
+ });
28
+
29
+ console.log(event);
30
+ ```
31
+
20
32
  ## Installation
21
33
 
22
34
  ```bash
@@ -1 +1 @@
1
- import{b as v,o as b}from"./chunk-5AQYHVY3.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,o as b}from"./chunk-XNWCAGZ7.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
- var Jt=Object.defineProperty;var te=(o,t)=>{for(var e in t)Jt(o,e,{get:t[e],enumerable:!0})};var Qt=class{async filter(){return{headers:this.getHeaders()}}getHeaders(){return{}}};var Kt="https://api.support.greatdetail.com",Vt={"X-Powered-By":"GDSupport/JavaScript"},re="api-key";import{z as n}from"zod";var se="SUPPORT_ACCESS_TOKEN",ie="SUPPORT_API_KEY",ae="SUPPORT_KEY_NAME",kt="SUPPORT_SIGNING_KEY",Wt="SUPPORT_BASE_URL";var u=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("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[kt],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."+kt);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 m=class o{constructor(t=o.STANDARD_HEADERS){this._standardHeaders=t}static STANDARD_HEADERS=Vt;async filter(){return{headers:this.getHeaders()}}getHeaders(){return this._standardHeaders}};import $t from"is-network-error";import Xt,{HTTPError as Zt}from"ky";var a=class extends Error{static serverError(t){return new this("Server Error: "+t)}};var c=class extends a{};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 p=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 C=class extends a{};var l=class extends a{static badRequest(){return new this("Bad request")}static unsupportedMediaType(){return new this("Unsupported Media Type")}};var g=class{client;options;constructor({baseURL:t,...e}){this.options={...e,baseURL:t},this.client=Xt.create({prefixUrl:this.options.baseURL,timeout:12e3,hooks:{beforeRequest:[r=>{for(let s of this.options.requestFilterables){let i=s.getHeaders();for(let[Ht,zt]of Object.entries(i))r.headers.has(Ht)||r.headers.set(Ht,zt)}}]}})}getURL(t){return new URL(t,this.options.baseURL).toString()}limitQuery(t){let e=[];return t&&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&&e.push(["query",t]),e}send(t,e){let r=this.client(t,e).catch(s=>{if($t(s))throw new C("A network error occurred",{cause:s});if(s instanceof Zt){let i=s.response.status;switch(console.error(JSON.stringify(s.response)),i){case 400:throw l.badRequest();case 401:throw h.unauthenticated();case 403:throw f.forbidden();case 404:throw p.notFound(t);case 405:throw p.forbiddenMethod(t,e.method??"GET");case 415:throw l.unsupportedMediaType();case 418:throw p.teapot();case 429:throw p.rateLimited()}if(i>=500&&i<600)throw a.serverError(i)}throw s});return{response:()=>r,json:async()=>(await r).json()}}};var b=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/accounts/"+encodeURIComponent(t),{...e,method:"GET"})}};var _=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 x=class{constructor(t){this._transport=t}get api(){return{get:new b(this._transport),update:new _(this._transport)}}};var R=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/accounts/"+encodeURIComponent(t)+"/conversation-settings",{...e,method:"GET"})}};var y=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 T=class{constructor(t){this._transport=t}get api(){return{get:new R(this._transport),update:new y(this._transport)}}};var v=class{constructor(t){this._transport=t}send({limit:t,request:e={}}={}){return this._transport.send("v1/actions",{...e,method:"GET",searchParams:[...this._transport.limitQuery(t)]})}};var O=class{constructor(t){this._transport=t}get api(){return{list:new v(this._transport)}}};var F=class{constructor(t){this._transport=t}send(t,{limit:e,request:r={}}={}){return this._transport.send("v1/boilerplate-categories/"+encodeURIComponent(t)+"/boilerplates",{...r,method:"GET",searchParams:[...this._transport.limitQuery(e)]})}};var L=class{constructor(t){this._transport=t}send({body:t,request:e={}}){return this._transport.send("v1/boilerplate-categories",{...e,method:"POST",json:t})}};var S=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/boilerplate-categories/"+encodeURIComponent(t),{...e,method:"GET"})}};var w=class{constructor(t){this._transport=t}send({limit:t,include:e,request:r={}}={}){return this._transport.send("v1/boilerplate-categories",{...r,method:"GET",searchParams:[...this._transport.limitQuery(t),...this._transport.includeQuery(e)]})}};var U=class{constructor(t){this._transport=t}send(t,{body:e,request:r={}}){return this._transport.send("v1/boilerplate-categories/"+encodeURIComponent(t),{...r,method:"PATCH",json:e})}};var I=class{constructor(t){this._transport=t}get api(){return{get:new S(this._transport),list:new w(this._transport),create:new L(this._transport),update:new U(this._transport),boilerplate:{list:new F(this._transport)}}}};var q=class{constructor(t){this._transport=t}send({body:t,request:e={}}){return this._transport.send("v1/boilerplates",{...e,method:"POST",json:t})}};var A=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/boilerplates/"+encodeURIComponent(t),{...e,method:"GET"})}};var E=class{constructor(t){this._transport=t}send({limit:t,query:e,request:r={}}={}){return this._transport.send("v1/boilerplates",{...r,method:"GET",searchParams:[...this._transport.limitQuery(t),...this._transport.queryQuery(e)]})}};var G=class{constructor(t){this._transport=t}send(t,{body:e,request:r={}}){return this._transport.send("v1/boilerplates/"+encodeURIComponent(t),{...r,method:"PATCH",json:e})}};var P=class{constructor(t){this._transport=t}get api(){return{get:new A(this._transport),list:new E(this._transport),update:new G(this._transport),create:new q(this._transport)}}};var N=class{constructor(t){this._transport=t}send({body:t,request:e={}}){return this._transport.send("v1/channels",{...e,method:"POST",json:t})}};var B=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/channels/"+encodeURIComponent(t),{...e,method:"GET"})}};var M=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)]})}};import{z as Yt}from"zod";var j=class o{constructor(t){this._transport=t}static SCHEMA=Yt.object({overwrite:Yt.boolean().optional()});send(t,{body:e,request:r={}}){return this._transport.send("v1/sources/twilio-sendgrid/channels/"+encodeURIComponent(t)+"/sync",{...r,method:"POST",json:o.SCHEMA.parse(e)})}};var H=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 Q=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 k=class{constructor(t){this._transport=t}send(t,{limit:e,request:r={}}={}){return this._transport.send("v1/channels/"+encodeURIComponent(t)+"/messages",{...r,method:"GET",searchParams:[...this._transport.limitQuery(e)]})}};var D=class{constructor(t){this._transport=t}get api(){return{get:new B(this._transport),list:new M(this._transport),update:new H(this._transport),create:new N(this._transport),compositionSection:{list:new Q(this._transport)},message:{list:new k(this._transport)},twilioSendgrid:{sync:new j(this._transport)}}}};var K=class{constructor(t){this._transport=t}send({body:t,request:e={}}){return this._transport.send("v1/composition-sections",{...e,method:"POST",json:t})}};var V=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/composition-sections/"+encodeURIComponent(t),{...e,method:"GET"})}};var W=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 Y=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 z=class{constructor(t){this._transport=t}get api(){return{get:new V(this._transport),list:new W(this._transport),create:new K(this._transport),update:new Y(this._transport)}}};var J=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 $=class{constructor(t){this._transport=t}send({body:t,request:e={}}){return this._transport.send("v1/contacts",{...e,method:"POST",json:t})}};var X=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 Z=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 tt=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 et=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 ot=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 rt=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 nt=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/contacts/"+encodeURIComponent(t)+"/notes",{...e,method:"GET"})}};var st=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 it=class{constructor(t){this._transport=t}get api(){return{get:new X(this._transport),list:new Z(this._transport),update:new tt(this._transport),create:new $(this._transport),conversation:{list:new et(this._transport)},label:{list:new ot(this._transport)},note:{list:new nt(this._transport),create:new rt(this._transport)},notificationSubscription:{create:new st(this._transport)},vcf:{get:new J(this._transport)}}}};var at=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 pt=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 ct=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 lt=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 dt=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 ut=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/conversations/"+encodeURIComponent(t)+"/notes",{...e,method:"GET"})}};var mt=class{constructor(t){this._transport=t}get api(){return{get:new at(this._transport),list:new pt(this._transport),update:new ct(this._transport),create:new d(this._transport),label:{list:new lt(this._transport)},message:{list:new dt(this._transport)},note:{list:new ut(this._transport),create:new d(this._transport)}}}};var ht=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 ft=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 Ct=class{constructor(t){this._transport=t}send({body:t,request:e={}}){return this._transport.send("v1/labels",{...e,method:"POST",json:t})}};var gt=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/labels/"+encodeURIComponent(t),{...e,method:"DELETE"})}};var bt=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/labels/"+encodeURIComponent(t),{...e,method:"GET"})}};var _t=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 xt=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 Rt=class{constructor(t){this._transport=t}get api(){return{create:new Ct(this._transport),get:new bt(this._transport),list:new _t(this._transport),update:new xt(this._transport),delete:new gt(this._transport),contact:{list:new ht(this._transport)},conversation:{list:new ft(this._transport)}}}};var yt=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 Tt=class{constructor(t){this._transport=t}get api(){return{list:new yt(this._transport)}}};var vt=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 Ot=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/models/"+encodeURIComponent(t),{...e,method:"GET"})}};var Ft=class{constructor(t){this._transport=t}send({request:t={}}={}){return this._transport.send("v1/models",{...t,method:"GET"})}};var Lt=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 St=class{constructor(t){this._transport=t}get api(){return{get:new Ot(this._transport),list:new Ft(this._transport),response:{create:new Lt(this._transport)},correction:{create:new vt(this._transport)}}}};var wt=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/notes/"+encodeURIComponent(t),{...e,method:"GET"})}};var Ut=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 It=class{constructor(t){this._transport=t}get api(){return{get:new wt(this._transport),update:new Ut(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 At=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 Et=class{constructor(t){this._transport=t}get api(){return{get:new qt(this._transport),list:new At(this._transport)}}};var Gt=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 Pt=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/uploads/"+encodeURIComponent(t),{...e,method:"DELETE"})}};var Nt=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/uploads/"+encodeURIComponent(t),{...e,method:"GET"})}};var Bt=class{constructor(t){this._transport=t}get api(){return{get:new Nt(this._transport),create:new Gt(this._transport),delete:new Pt(this._transport)}}};var Mt=class{constructor(t){this._transport=t}send({request:t={}}={}){return this._transport.send(".well-known/notifications",{...t,method:"GET"})}};var jt=class{constructor(t){this._transport=t}get api(){return{notification:{get:new Mt(this._transport)}}}};var Dt=class o{static DEFAULT_BASE_URL=Kt;_transport;_account;_accountConversationSettings;_action;_boilerplate;_boilerplateCategory;_channel;_compositionSection;_contact;_conversation;_label;_message;_model;_note;_source;_upload;_webhook;_wellKnown;constructor(t,{baseURL:e,...r}={}){this._transport=new g({requestFilterables:[new m,t],...r,baseURL:e?.toString()??o.getBaseURL()}),this._account=new x(this._transport),this._accountConversationSettings=new T(this._transport),this._action=new O(this._transport),this._boilerplate=new P(this._transport),this._boilerplateCategory=new I(this._transport),this._channel=new D(this._transport),this._compositionSection=new z(this._transport),this._contact=new it(this._transport),this._conversation=new mt(this._transport),this._label=new Rt(this._transport),this._message=new Tt(this._transport),this._model=new St(this._transport),this._note=new It(this._transport),this._source=new Et(this._transport),this._upload=new Bt(this._transport),this._webhook=new u(this),this._wellKnown=new jt(this._transport)}static getBaseURL(){return process.env[Wt]??this.DEFAULT_BASE_URL}get account(){return this._account.api}get accountConversationSettings(){return this._accountConversationSettings.api}get action(){return this._action.api}get boilerplate(){return this._boilerplate.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 upload(){return this._upload.api}get webhook(){return this._webhook}get wellKnown(){return this._wellKnown.api}};export{te as a,Qt as b,se as c,ie as d,ae as e,Kt as f,re as g,a as h,c as i,h as j,f as k,p as l,C as m,l as n,Dt as o};
1
+ var Zt=Object.defineProperty;var re=(o,t)=>{for(var e in t)Zt(o,e,{get:t[e],enumerable:!0})};var Kt=class{async filter(){return{headers:this.getHeaders()}}getHeaders(){return{}}};var Yt="https://api.support.greatdetail.com",zt={"X-Powered-By":"GDSupport/JavaScript"},ie="api-key";import{z as n}from"zod";var pe="SUPPORT_ACCESS_TOKEN",ce="SUPPORT_API_KEY",le="SUPPORT_KEY_NAME",Vt="SUPPORT_SIGNING_KEY",Jt="SUPPORT_BASE_URL";var u=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("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[Vt],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."+Vt);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 m=class o{constructor(t=o.STANDARD_HEADERS){this._standardHeaders=t}static STANDARD_HEADERS=zt;async filter(){return{headers:this.getHeaders()}}getHeaders(){return this._standardHeaders}};import te from"is-network-error";import ee,{HTTPError as oe}from"ky";var a=class extends Error{static serverError(t){return new this("Server Error: "+t)}};var c=class extends a{};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 p=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 C=class extends a{};var l=class extends a{static badRequest(){return new this("Bad request")}static unsupportedMediaType(){return new this("Unsupported Media Type")}};var g=class{client;options;constructor({baseURL:t,...e}){this.options={...e,baseURL:t},this.client=ee.create({prefixUrl:this.options.baseURL,timeout:12e3,hooks:{beforeRequest:[r=>{for(let s of this.options.requestFilterables){let i=s.getHeaders();for(let[Dt,Xt]of Object.entries(i))r.headers.has(Dt)||r.headers.set(Dt,Xt)}}]}})}getURL(t){return new URL(t,this.options.baseURL).toString()}limitQuery(t){let e=[];return t&&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&&e.push(["query",t]),e}send(t,e){let r=this.client(t,e).catch(s=>{if(te(s))throw new C("A network error occurred",{cause:s});if(s instanceof oe){let i=s.response.status;switch(console.error(JSON.stringify(s.response)),i){case 400:throw l.badRequest();case 401:throw h.unauthenticated();case 403:throw f.forbidden();case 404:throw p.notFound(t);case 405:throw p.forbiddenMethod(t,e.method??"GET");case 415:throw l.unsupportedMediaType();case 418:throw p.teapot();case 429:throw p.rateLimited()}if(i>=500&&i<600)throw a.serverError(i)}throw s});return{response:()=>r,json:async()=>(await r).json()}}};var b=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/accounts/"+encodeURIComponent(t),{...e,method:"GET"})}};var _=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 y=class{constructor(t){this._transport=t}get api(){return{get:new b(this._transport),update:new _(this._transport)}}};var x=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/accounts/"+encodeURIComponent(t)+"/conversation-settings",{...e,method:"GET"})}};var R=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 T=class{constructor(t){this._transport=t}get api(){return{get:new x(this._transport),update:new R(this._transport)}}};var v=class{constructor(t){this._transport=t}send({limit:t,request:e={}}={}){return this._transport.send("v1/actions",{...e,method:"GET",searchParams:[...this._transport.limitQuery(t)]})}};var O=class{constructor(t){this._transport=t}get api(){return{list:new v(this._transport)}}};var F=class{constructor(t){this._transport=t}send(t,{limit:e,request:r={}}={}){return this._transport.send("v1/boilerplate-categories/"+encodeURIComponent(t)+"/boilerplates",{...r,method:"GET",searchParams:[...this._transport.limitQuery(e)]})}};var S=class{constructor(t){this._transport=t}send({body:t,request:e={}}){return this._transport.send("v1/boilerplate-categories",{...e,method:"POST",json:t})}};var L=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/boilerplate-categories/"+encodeURIComponent(t),{...e,method:"GET"})}};var w=class{constructor(t){this._transport=t}send({limit:t,include:e,request:r={}}={}){return this._transport.send("v1/boilerplate-categories",{...r,method:"GET",searchParams:[...this._transport.limitQuery(t),...this._transport.includeQuery(e)]})}};var U=class{constructor(t){this._transport=t}send(t,{body:e,request:r={}}){return this._transport.send("v1/boilerplate-categories/"+encodeURIComponent(t),{...r,method:"PATCH",json:e})}};var q=class{constructor(t){this._transport=t}get api(){return{get:new L(this._transport),list:new w(this._transport),create:new S(this._transport),update:new U(this._transport),boilerplate:{list:new F(this._transport)}}}};var I=class{constructor(t){this._transport=t}send({body:t,request:e={}}){return this._transport.send("v1/boilerplates",{...e,method:"POST",json:t})}};var A=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/boilerplates/"+encodeURIComponent(t),{...e,method:"GET"})}};var E=class{constructor(t){this._transport=t}send({limit:t,query:e,request:r={}}={}){return this._transport.send("v1/boilerplates",{...r,method:"GET",searchParams:[...this._transport.limitQuery(t),...this._transport.queryQuery(e)]})}};var G=class{constructor(t){this._transport=t}send(t,{body:e,request:r={}}){return this._transport.send("v1/boilerplates/"+encodeURIComponent(t),{...r,method:"PATCH",json:e})}};var P=class{constructor(t){this._transport=t}get api(){return{get:new A(this._transport),list:new E(this._transport),update:new G(this._transport),create:new I(this._transport)}}};var N=class{constructor(t){this._transport=t}send({body:t,request:e={}}){return this._transport.send("v1/channels",{...e,method:"POST",json:t})}};var B=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/channels/"+encodeURIComponent(t),{...e,method:"GET"})}};var M=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)]})}};import{z as $t}from"zod";var j=class o{constructor(t){this._transport=t}static SCHEMA=$t.object({overwrite:$t.boolean().optional()});send(t,{body:e,request:r={}}){return this._transport.send("v1/sources/twilio-sendgrid/channels/"+encodeURIComponent(t)+"/sync",{...r,method:"POST",json:o.SCHEMA.parse(e)})}};var H=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 Q=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 k=class{constructor(t){this._transport=t}send(t,{limit:e,request:r={}}={}){return this._transport.send("v1/channels/"+encodeURIComponent(t)+"/messages",{...r,method:"GET",searchParams:[...this._transport.limitQuery(e)]})}};var D=class{constructor(t){this._transport=t}get api(){return{get:new B(this._transport),list:new M(this._transport),update:new H(this._transport),create:new N(this._transport),compositionSection:{list:new Q(this._transport)},message:{list:new k(this._transport)},twilioSendgrid:{sync:new j(this._transport)}}}};var K=class{constructor(t){this._transport=t}send({body:t,request:e={}}){return this._transport.send("v1/composition-sections",{...e,method:"POST",json:t})}};var V=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/composition-sections/"+encodeURIComponent(t),{...e,method:"GET"})}};var W=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 Y=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 z=class{constructor(t){this._transport=t}get api(){return{get:new V(this._transport),list:new W(this._transport),create:new K(this._transport),update:new Y(this._transport)}}};var J=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 $=class{constructor(t){this._transport=t}send({body:t,request:e={}}){return this._transport.send("v1/contacts",{...e,method:"POST",json:t})}};var X=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 Z=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 tt=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 et=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 ot=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 rt=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 nt=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/contacts/"+encodeURIComponent(t)+"/notes",{...e,method:"GET"})}};var st=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 it=class{constructor(t){this._transport=t}get api(){return{get:new X(this._transport),list:new Z(this._transport),update:new tt(this._transport),create:new $(this._transport),conversation:{list:new et(this._transport)},label:{list:new ot(this._transport)},note:{list:new nt(this._transport),create:new rt(this._transport)},notificationSubscription:{create:new st(this._transport)},vcf:{get:new J(this._transport)}}}};var at=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 pt=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 ct=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 lt=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 dt=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 ut=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/conversations/"+encodeURIComponent(t)+"/notes",{...e,method:"GET"})}};var mt=class{constructor(t){this._transport=t}get api(){return{get:new at(this._transport),list:new pt(this._transport),update:new ct(this._transport),create:new d(this._transport),label:{list:new lt(this._transport)},message:{list:new dt(this._transport)},note:{list:new ut(this._transport),create:new d(this._transport)}}}};var ht=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 ft=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 Ct=class{constructor(t){this._transport=t}send({body:t,request:e={}}){return this._transport.send("v1/labels",{...e,method:"POST",json:t})}};var gt=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/labels/"+encodeURIComponent(t),{...e,method:"DELETE"})}};var bt=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/labels/"+encodeURIComponent(t),{...e,method:"GET"})}};var _t=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 yt=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 xt=class{constructor(t){this._transport=t}get api(){return{create:new Ct(this._transport),get:new bt(this._transport),list:new _t(this._transport),update:new yt(this._transport),delete:new gt(this._transport),contact:{list:new ht(this._transport)},conversation:{list:new ft(this._transport)}}}};var Rt=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 Tt=class{constructor(t){this._transport=t}get api(){return{list:new Rt(this._transport)}}};var vt=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 Ot=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/models/"+encodeURIComponent(t),{...e,method:"GET"})}};var Ft=class{constructor(t){this._transport=t}send({request:t={}}={}){return this._transport.send("v1/models",{...t,method:"GET"})}};var St=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 Lt=class{constructor(t){this._transport=t}get api(){return{get:new Ot(this._transport),list:new Ft(this._transport),response:{create:new St(this._transport)},correction:{create:new vt(this._transport)}}}};var wt=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/notes/"+encodeURIComponent(t),{...e,method:"GET"})}};var Ut=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 wt(this._transport),update:new Ut(this._transport)}}};var It=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/sources/"+encodeURIComponent(t),{...e,method:"GET"})}};var At=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 Et=class{constructor(t){this._transport=t}get api(){return{get:new It(this._transport),list:new At(this._transport)}}};var Gt=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/channel/"+encodeURIComponent(t)+"/statistics/message-frequency",{...e,method:"GET"})}};var Pt=class{constructor(t){this._transport=t}send({request:t={}}={}){return this._transport.send("v1/statistics/message-frequency",{...t,method:"GET"})}};var Nt=class{constructor(t){this._transport=t}get api(){return{messageFrequency:new Pt(this._transport),channelMessageFrequency:new Gt(this._transport)}}};var Bt=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 Mt=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 Ht=class{constructor(t){this._transport=t}get api(){return{get:new jt(this._transport),create:new Bt(this._transport),delete:new Mt(this._transport)}}};var Qt=class{constructor(t){this._transport=t}send({request:t={}}={}){return this._transport.send(".well-known/notifications",{...t,method:"GET"})}};var kt=class{constructor(t){this._transport=t}get api(){return{notification:{get:new Qt(this._transport)}}}};var Wt=class o{static DEFAULT_BASE_URL=Yt;_transport;_account;_accountConversationSettings;_action;_boilerplate;_boilerplateCategory;_channel;_compositionSection;_contact;_conversation;_label;_message;_model;_note;_source;_statistics;_upload;_webhook;_wellKnown;constructor(t,{baseURL:e,...r}={}){this._transport=new g({requestFilterables:[new m,t],...r,baseURL:e?.toString()??o.getBaseURL()}),this._account=new y(this._transport),this._accountConversationSettings=new T(this._transport),this._action=new O(this._transport),this._boilerplate=new P(this._transport),this._boilerplateCategory=new q(this._transport),this._channel=new D(this._transport),this._compositionSection=new z(this._transport),this._contact=new it(this._transport),this._conversation=new mt(this._transport),this._label=new xt(this._transport),this._message=new Tt(this._transport),this._model=new Lt(this._transport),this._note=new qt(this._transport),this._source=new Et(this._transport),this._statistics=new Nt(this._transport),this._upload=new Ht(this._transport),this._webhook=new u(this),this._wellKnown=new kt(this._transport)}static getBaseURL(){return process.env[Jt]??this.DEFAULT_BASE_URL}get account(){return this._account.api}get accountConversationSettings(){return this._accountConversationSettings.api}get action(){return this._action.api}get boilerplate(){return this._boilerplate.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{re as a,Kt as b,pe as c,ce as d,le as e,Yt as f,ie as g,a as h,c as i,h as j,f as k,p as l,C as m,l as n,Wt as o};
@@ -1 +1 @@
1
- "use strict";var qe=Object.create;var Wt=Object.defineProperty;var Ae=Object.getOwnPropertyDescriptor;var Ee=Object.getOwnPropertyNames;var Pe=Object.getPrototypeOf,Ge=Object.prototype.hasOwnProperty;var Ne=(o,t)=>{for(var e in t)Wt(o,e,{get:t[e],enumerable:!0})},xe=(o,t,e,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of Ee(t))!Ge.call(o,n)&&n!==e&&Wt(o,n,{get:()=>t[n],enumerable:!(r=Ae(t,n))||r.enumerable});return o};var _e=(o,t,e)=>(e=o!=null?qe(Pe(o)):{},xe(t||!o||!o.__esModule?Wt(e,"default",{value:o,enumerable:!0}):e,o)),Be=o=>xe(Wt({},"__esModule",{value:!0}),o);var De={};Ne(De,{default:()=>Me});module.exports=Be(De);var Ue=require("commander");var u=class{async filter(){return{headers:this.getHeaders()}}getHeaders(){return{}}};var te="SUPPORT_SIGNING_KEY",ye="SUPPORT_BASE_URL";var Re="https://api.support.greatdetail.com",Te={"X-Powered-By":"GDSupport/JavaScript"};var h=class o{constructor(t=o.STANDARD_HEADERS){this._standardHeaders=t}static STANDARD_HEADERS=Te;async filter(){return{headers:this.getHeaders()}}getHeaders(){return this._standardHeaders}};var Oe=_e(require("is-network-error"),1),Yt=_e(require("ky"),1);var a=class extends Error{static serverError(t){return new this("Server Error: "+t)}};var l=class extends a{};var f=class extends l{static unauthenticated(){return new this("An unauthenticated request occurred")}};var C=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 g=class extends a{};var d=class extends a{static badRequest(){return new this("Bad request")}static unsupportedMediaType(){return new this("Unsupported Media Type")}};var b=class{client;options;constructor({baseURL:t,...e}){this.options={...e,baseURL:t},this.client=Yt.default.create({prefixUrl:this.options.baseURL,timeout:12e3,hooks:{beforeRequest:[r=>{for(let n of this.options.requestFilterables){let i=n.getHeaders();for(let[Vt,Ie]of Object.entries(i))r.headers.has(Vt)||r.headers.set(Vt,Ie)}}]}})}getURL(t){return new URL(t,this.options.baseURL).toString()}limitQuery(t){let e=[];return t&&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&&e.push(["query",t]),e}send(t,e){let r=this.client(t,e).catch(n=>{if((0,Oe.default)(n))throw new g("A network error occurred",{cause:n});if(n instanceof Yt.HTTPError){let i=n.response.status;switch(console.error(JSON.stringify(n.response)),i){case 400:throw d.badRequest();case 401:throw f.unauthenticated();case 403:throw C.forbidden();case 404:throw c.notFound(t);case 405:throw c.forbiddenMethod(t,e.method??"GET");case 415:throw d.unsupportedMediaType();case 418:throw c.teapot();case 429:throw c.rateLimited()}if(i>=500&&i<600)throw a.serverError(i)}throw n});return{response:()=>r,json:async()=>(await r).json()}}};var s=require("zod");var x=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("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[te],maxSignatures:e=3,request:r}){let n=r.headers["gds-signature"];if(t!==!1){if(t===void 0)throw new Error("Missing webhook signing key in process.env."+te);if(!n)throw new Error("Missing signature header");if(!this._verifySignature(t,r.body,Array.isArray(n)?n.slice(0,e):[n]))throw new Error("Untrusted signature")}let{data:i}=o.SCHEMA.parse(r.body);return{event:i.event}}async _verifySignature(t,e,r){let n=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",n,new TextEncoder().encode(atob(i)),new TextEncoder().encode(JSON.stringify(e))))return!0;return!1}};var _=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/accounts/"+encodeURIComponent(t),{...e,method:"GET"})}};var y=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 R=class{constructor(t){this._transport=t}get api(){return{get:new _(this._transport),update:new y(this._transport)}}};var T=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/accounts/"+encodeURIComponent(t)+"/conversation-settings",{...e,method:"GET"})}};var O=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 v=class{constructor(t){this._transport=t}get api(){return{get:new T(this._transport),update:new O(this._transport)}}};var w=class{constructor(t){this._transport=t}send({limit:t,request:e={}}={}){return this._transport.send("v1/actions",{...e,method:"GET",searchParams:[...this._transport.limitQuery(t)]})}};var F=class{constructor(t){this._transport=t}get api(){return{list:new w(this._transport)}}};var L=class{constructor(t){this._transport=t}send(t,{limit:e,request:r={}}={}){return this._transport.send("v1/boilerplate-categories/"+encodeURIComponent(t)+"/boilerplates",{...r,method:"GET",searchParams:[...this._transport.limitQuery(e)]})}};var S=class{constructor(t){this._transport=t}send({body:t,request:e={}}){return this._transport.send("v1/boilerplate-categories",{...e,method:"POST",json:t})}};var U=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/boilerplate-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/boilerplate-categories",{...r,method:"GET",searchParams:[...this._transport.limitQuery(t),...this._transport.includeQuery(e)]})}};var q=class{constructor(t){this._transport=t}send(t,{body:e,request:r={}}){return this._transport.send("v1/boilerplate-categories/"+encodeURIComponent(t),{...r,method:"PATCH",json:e})}};var A=class{constructor(t){this._transport=t}get api(){return{get:new U(this._transport),list:new I(this._transport),create:new S(this._transport),update:new q(this._transport),boilerplate:{list:new L(this._transport)}}}};var E=class{constructor(t){this._transport=t}send({body:t,request:e={}}){return this._transport.send("v1/boilerplates",{...e,method:"POST",json:t})}};var P=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/boilerplates/"+encodeURIComponent(t),{...e,method:"GET"})}};var G=class{constructor(t){this._transport=t}send({limit:t,query:e,request:r={}}={}){return this._transport.send("v1/boilerplates",{...r,method:"GET",searchParams:[...this._transport.limitQuery(t),...this._transport.queryQuery(e)]})}};var N=class{constructor(t){this._transport=t}send(t,{body:e,request:r={}}){return this._transport.send("v1/boilerplates/"+encodeURIComponent(t),{...r,method:"PATCH",json:e})}};var B=class{constructor(t){this._transport=t}get api(){return{get:new P(this._transport),list:new G(this._transport),update:new N(this._transport),create:new E(this._transport)}}};var j=class{constructor(t){this._transport=t}send({body:t,request:e={}}){return this._transport.send("v1/channels",{...e,method:"POST",json:t})}};var M=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/channels/"+encodeURIComponent(t),{...e,method:"GET"})}};var D=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 ee=require("zod"),H=class o{constructor(t){this._transport=t}static SCHEMA=ee.z.object({overwrite:ee.z.boolean().optional()});send(t,{body:e,request:r={}}){return this._transport.send("v1/sources/twilio-sendgrid/channels/"+encodeURIComponent(t)+"/sync",{...r,method:"POST",json:o.SCHEMA.parse(e)})}};var K=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 Q=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 k=class{constructor(t){this._transport=t}send(t,{limit:e,request:r={}}={}){return this._transport.send("v1/channels/"+encodeURIComponent(t)+"/messages",{...r,method:"GET",searchParams:[...this._transport.limitQuery(e)]})}};var V=class{constructor(t){this._transport=t}get api(){return{get:new M(this._transport),list:new D(this._transport),update:new K(this._transport),create:new j(this._transport),compositionSection:{list:new Q(this._transport)},message:{list:new k(this._transport)},twilioSendgrid:{sync:new H(this._transport)}}}};var W=class{constructor(t){this._transport=t}send({body:t,request:e={}}){return this._transport.send("v1/composition-sections",{...e,method:"POST",json:t})}};var Y=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/composition-sections/"+encodeURIComponent(t),{...e,method:"GET"})}};var z=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 J=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 $=class{constructor(t){this._transport=t}get api(){return{get:new Y(this._transport),list:new z(this._transport),create:new W(this._transport),update:new J(this._transport)}}};var X=class{constructor(t){this._transport=t}getRelativeURL({id:t,vcf:e={}}){let r=e.variant??"vcard",n=e.format??(r==="vcard"?"vcf":"json");return"v1/contacts/"+encodeURIComponent(t)+"/vcf?variant="+encodeURIComponent(r)+"&format="+encodeURIComponent(n)}getURL(t){return this._transport.getURL(this.getRelativeURL(t))}send(t){return this._transport.send(this.getURL(t),{method:"GET"})}};var Z=class{constructor(t){this._transport=t}send({body:t,request:e={}}){return this._transport.send("v1/contacts",{...e,method:"POST",json:t})}};var tt=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 et=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 ot=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 rt=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 nt=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 st=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 it=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/contacts/"+encodeURIComponent(t)+"/notes",{...e,method:"GET"})}};var at=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 pt=class{constructor(t){this._transport=t}get api(){return{get:new tt(this._transport),list:new et(this._transport),update:new ot(this._transport),create:new Z(this._transport),conversation:{list:new rt(this._transport)},label:{list:new nt(this._transport)},note:{list:new it(this._transport),create:new st(this._transport)},notificationSubscription:{create:new at(this._transport)},vcf:{get:new X(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 lt=class{constructor(t){this._transport=t}send({limit:t,filter:e,include:r,request:n={}}={}){return this._transport.send("v1/conversations",{...n,method:"GET",searchParams:[...this._transport.limitQuery(t),...e?[["filter",e]]:[],...this._transport.includeQuery(r??{})]})}};var dt=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 mt=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 ut=class{constructor(t){this._transport=t}send(t,{limit:e,include:r,request:n={}}={}){return this._transport.send("v1/conversations/"+encodeURIComponent(t)+"/messages",{...n,method:"GET",searchParams:[...this._transport.limitQuery(e),...this._transport.includeQuery(r??{})]})}};var m=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 ht=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/conversations/"+encodeURIComponent(t)+"/notes",{...e,method:"GET"})}};var ft=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 m(this._transport),label:{list:new mt(this._transport)},message:{list:new ut(this._transport)},note:{list:new ht(this._transport),create:new m(this._transport)}}}};var Ct=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 gt=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 bt=class{constructor(t){this._transport=t}send({body:t,request:e={}}){return this._transport.send("v1/labels",{...e,method:"POST",json:t})}};var xt=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/labels/"+encodeURIComponent(t),{...e,method:"DELETE"})}};var _t=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/labels/"+encodeURIComponent(t),{...e,method:"GET"})}};var yt=class{constructor(t){this._transport=t}send({limit:t,query:e,include:r,request:n={}}={}){return this._transport.send("v1/labels",{...n,method:"GET",searchParams:[...this._transport.limitQuery(t),...this._transport.queryQuery(e),...this._transport.includeQuery(r??{})]})}};var Rt=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 Tt=class{constructor(t){this._transport=t}get api(){return{create:new bt(this._transport),get:new _t(this._transport),list:new yt(this._transport),update:new Rt(this._transport),delete:new xt(this._transport),contact:{list:new Ct(this._transport)},conversation:{list:new gt(this._transport)}}}};var Ot=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 vt=class{constructor(t){this._transport=t}get api(){return{list:new Ot(this._transport)}}};var wt=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 Ft=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/models/"+encodeURIComponent(t),{...e,method:"GET"})}};var Lt=class{constructor(t){this._transport=t}send({request:t={}}={}){return this._transport.send("v1/models",{...t,method:"GET"})}};var St=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 Ut=class{constructor(t){this._transport=t}get api(){return{get:new Ft(this._transport),list:new Lt(this._transport),response:{create:new St(this._transport)},correction:{create:new wt(this._transport)}}}};var It=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/notes/"+encodeURIComponent(t),{...e,method:"GET"})}};var qt=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 At=class{constructor(t){this._transport=t}get api(){return{get:new It(this._transport),update:new qt(this._transport)}}};var Et=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/sources/"+encodeURIComponent(t),{...e,method:"GET"})}};var Pt=class{constructor(t){this._transport=t}send({category:t,request:e={}}={}){let r=[];if(t){let n=Array.isArray(t)?t:[t];for(let i of n)r.push(["category",i])}return this._transport.send("v1/sources",{...e,method:"GET",searchParams:r})}};var Gt=class{constructor(t){this._transport=t}get api(){return{get:new Et(this._transport),list:new Pt(this._transport)}}};var Nt=class{constructor(t){this._transport=t}send({account:t,files:e,request:r={}}){let n=new FormData;for(let i of e)n.append("file",i);return this._transport.send("v1/uploads",{...r,method:"POST",body:n,searchParams:{account:t}})}};var Bt=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 Mt=class{constructor(t){this._transport=t}get api(){return{get:new jt(this._transport),create:new Nt(this._transport),delete:new Bt(this._transport)}}};var Dt=class{constructor(t){this._transport=t}send({request:t={}}={}){return this._transport.send(".well-known/notifications",{...t,method:"GET"})}};var Ht=class{constructor(t){this._transport=t}get api(){return{notification:{get:new Dt(this._transport)}}}};var Kt=class o{static DEFAULT_BASE_URL=Re;_transport;_account;_accountConversationSettings;_action;_boilerplate;_boilerplateCategory;_channel;_compositionSection;_contact;_conversation;_label;_message;_model;_note;_source;_upload;_webhook;_wellKnown;constructor(t,{baseURL:e,...r}={}){this._transport=new b({requestFilterables:[new h,t],...r,baseURL:e?.toString()??o.getBaseURL()}),this._account=new R(this._transport),this._accountConversationSettings=new v(this._transport),this._action=new F(this._transport),this._boilerplate=new B(this._transport),this._boilerplateCategory=new A(this._transport),this._channel=new V(this._transport),this._compositionSection=new $(this._transport),this._contact=new pt(this._transport),this._conversation=new ft(this._transport),this._label=new Tt(this._transport),this._message=new vt(this._transport),this._model=new Ut(this._transport),this._note=new At(this._transport),this._source=new Gt(this._transport),this._upload=new Mt(this._transport),this._webhook=new x(this),this._wellKnown=new Ht(this._transport)}static getBaseURL(){return process.env[ye]??this.DEFAULT_BASE_URL}get account(){return this._account.api}get accountConversationSettings(){return this._accountConversationSettings.api}get action(){return this._action.api}get boilerplate(){return this._boilerplate.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 upload(){return this._upload.api}get webhook(){return this._webhook}get wellKnown(){return this._wellKnown.api}};var oe=require("commander"),ve=require("ora");function re({client:o,ora:t}){let e=new oe.Command("actions").description("Actions");return e.addCommand(new oe.Command("list").description("List actions").action(async()=>{let r=await(0,ve.oraPromise)(()=>o.action.list.send().json(),{...t,text:"Finding actions"});console.log(r)})),e}var ne=require("commander"),we=require("ora");function se({client:o,ora:t}){let e=new ne.Command("channels").description("Channels");return e.addCommand(new ne.Command("list").description("List channels").action(async()=>{let r=await(0,we.oraPromise)(()=>o.channel.list.send().json(),{...t,text:"Finding channels"});console.log(r)})),e}var Qt=require("commander"),zt=require("ora");function ie({client:o,ora:t}){let e=new Qt.Command("contacts").description("Contacts");return e.addCommand(new Qt.Command("get").description("Find contact").argument("<contact>","Contact ID").action(async r=>{let n=await(0,zt.oraPromise)(()=>o.contact.get.send(r).json(),{...t,text:"Finding contact"});console.log(n)})),e.addCommand(new Qt.Command("list").description("List contacts").action(async()=>{let r=await(0,zt.oraPromise)(()=>o.contact.list.send().json(),{...t,text:"Finding contacts"});console.log(r)})),e.addCommand(new Qt.Command("get-vcf").description("Export Contact as VCF").argument("<contact>","Contact ID").action(async r=>{let n=await(0,zt.oraPromise)(()=>o.contact.vcf.get.send({id:r}).response(),{...t,text:"Exporting contact"});console.log(n)})),e}var Jt=require("commander"),ae=require("ora");function pe({client:o,ora:t}){let e=new Jt.Command("conversations").description("Conversations");return e.addCommand(new Jt.Command("get").description("Find conversation").argument("<conversation>","Conversation ID").action(async r=>{let n=await(0,ae.oraPromise)(()=>o.conversation.get.send(r).json(),{...t,text:"Finding conversation"});console.log(n)})),e.addCommand(new Jt.Command("list").description("List conversations").action(async()=>{let r=await(0,ae.oraPromise)(()=>o.conversation.list.send().json(),{...t,text:"Finding conversations"});console.log(r)})),e}var kt=require("commander"),$t=require("ora");function ce({client:o,ora:t}){let e=new kt.Command("labels").description("Labels");return e.addCommand(new kt.Command("get").description("Find label").argument("<label>","Label ID").action(async r=>{let n=await(0,$t.oraPromise)(()=>o.label.get.send(r).json(),{...t,text:"Finding label"});console.log(n)})),e.addCommand(new kt.Command("list").description("List labels").action(async()=>{let r=await(0,$t.oraPromise)(()=>o.label.list.send().json(),{...t,text:"Finding labels"});console.log(r)})),e.addCommand(new kt.Command("conversations").description("Find label conversations").argument("<label>","Label ID").action(async r=>{let n=await(0,$t.oraPromise)(()=>o.label.conversation.list.send(r).json(),{...t,text:"Finding conversations"});console.log(n)})),e}var le=require("commander"),Fe=require("ora");function de({client:o,ora:t}){let e=new le.Command("messages").description("Messages");return e.addCommand(new le.Command("list").description("List messages").action(async()=>{let r=await(0,Fe.oraPromise)(()=>o.message.list.send().json(),{...t,text:"Finding messages"});console.log(r)})),e}var Xt=require("commander"),me=require("ora");function ue({client:o,ora:t}){let e=new Xt.Command("models").description("Models");return e.addCommand(new Xt.Command("get").description("Find model").argument("<model>","Model ID").action(async r=>{let n=await(0,me.oraPromise)(()=>o.model.get.send(r).json(),{...t,text:"Finding model"});console.log(n)})),e.addCommand(new Xt.Command("list").description("List models").action(async()=>{let r=await(0,me.oraPromise)(()=>o.model.list.send().json(),{...t,text:"Finding models"});console.log(r)})),e}var Zt=require("commander"),he=require("ora");function fe({client:o,ora:t}){let e=new Zt.Command("sources").description("Sources");return e.addCommand(new Zt.Command("get").description("Find source").argument("<source>","Source ID").action(async r=>{let n=await(0,he.oraPromise)(()=>o.source.get.send(r).json(),{...t,text:"Finding source"});console.log(n)})),e.addCommand(new Zt.Command("list").description("List sources").action(async()=>{let r=await(0,he.oraPromise)(()=>o.source.list.send().json(),{...t,text:"Finding sources"});console.log(r)})),e}var Se=require("commander");var Ce=require("commander"),Le=require("ora");function ge({client:o,ora:t}){let e=new Ce.Command("notifications").description("Well-Known Notifications Details");return e.addCommand(new Ce.Command("get").description("Get Notifications Server Well-Known Info").action(async()=>{let r=await(0,Le.oraPromise)(()=>o.wellKnown.notification.get.send().json(),{...t,text:"Finding Notifications Well-Known Info"});console.log(r)})),e}function be({client:o,ora:t}){let e=new Se.Command("well-known").description("Well-Known Metadata & Info");return e.addCommand(ge({client:o,ora:t})),e}var p={ora:{spinner:"simpleDotsScrolling"},client:new Kt(new u)},je=new Ue.Command("gds").description("Great Detail Support System").addCommand(re(p)).addCommand(se(p)).addCommand(ie(p)).addCommand(pe(p)).addCommand(ce(p)).addCommand(de(p)).addCommand(ue(p)).addCommand(fe(p)).addCommand(be(p)),Me=je;
1
+ "use strict";var Ge=Object.create;var Jt=Object.defineProperty;var Pe=Object.getOwnPropertyDescriptor;var Ne=Object.getOwnPropertyNames;var Be=Object.getPrototypeOf,Me=Object.prototype.hasOwnProperty;var je=(o,t)=>{for(var e in t)Jt(o,e,{get:t[e],enumerable:!0})},Re=(o,t,e,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of Ne(t))!Me.call(o,n)&&n!==e&&Jt(o,n,{get:()=>t[n],enumerable:!(r=Pe(t,n))||r.enumerable});return o};var Te=(o,t,e)=>(e=o!=null?Ge(Be(o)):{},Re(t||!o||!o.__esModule?Jt(e,"default",{value:o,enumerable:!0}):e,o)),De=o=>Re(Jt({},"__esModule",{value:!0}),o);var Qe={};je(Qe,{default:()=>Ke});module.exports=De(Qe);var Ae=require("commander");var u=class{async filter(){return{headers:this.getHeaders()}}getHeaders(){return{}}};var re="SUPPORT_SIGNING_KEY",Oe="SUPPORT_BASE_URL";var ve="https://api.support.greatdetail.com",we={"X-Powered-By":"GDSupport/JavaScript"};var h=class o{constructor(t=o.STANDARD_HEADERS){this._standardHeaders=t}static STANDARD_HEADERS=we;async filter(){return{headers:this.getHeaders()}}getHeaders(){return this._standardHeaders}};var Fe=Te(require("is-network-error"),1),$t=Te(require("ky"),1);var a=class extends Error{static serverError(t){return new this("Server Error: "+t)}};var l=class extends a{};var f=class extends l{static unauthenticated(){return new this("An unauthenticated request occurred")}};var C=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 g=class extends a{};var d=class extends a{static badRequest(){return new this("Bad request")}static unsupportedMediaType(){return new this("Unsupported Media Type")}};var b=class{client;options;constructor({baseURL:t,...e}){this.options={...e,baseURL:t},this.client=$t.default.create({prefixUrl:this.options.baseURL,timeout:12e3,hooks:{beforeRequest:[r=>{for(let n of this.options.requestFilterables){let i=n.getHeaders();for(let[zt,Ee]of Object.entries(i))r.headers.has(zt)||r.headers.set(zt,Ee)}}]}})}getURL(t){return new URL(t,this.options.baseURL).toString()}limitQuery(t){let e=[];return t&&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&&e.push(["query",t]),e}send(t,e){let r=this.client(t,e).catch(n=>{if((0,Fe.default)(n))throw new g("A network error occurred",{cause:n});if(n instanceof $t.HTTPError){let i=n.response.status;switch(console.error(JSON.stringify(n.response)),i){case 400:throw d.badRequest();case 401:throw f.unauthenticated();case 403:throw C.forbidden();case 404:throw c.notFound(t);case 405:throw c.forbiddenMethod(t,e.method??"GET");case 415:throw d.unsupportedMediaType();case 418:throw c.teapot();case 429:throw c.rateLimited()}if(i>=500&&i<600)throw a.serverError(i)}throw n});return{response:()=>r,json:async()=>(await r).json()}}};var s=require("zod");var x=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("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[re],maxSignatures:e=3,request:r}){let n=r.headers["gds-signature"];if(t!==!1){if(t===void 0)throw new Error("Missing webhook signing key in process.env."+re);if(!n)throw new Error("Missing signature header");if(!this._verifySignature(t,r.body,Array.isArray(n)?n.slice(0,e):[n]))throw new Error("Untrusted signature")}let{data:i}=o.SCHEMA.parse(r.body);return{event:i.event}}async _verifySignature(t,e,r){let n=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",n,new TextEncoder().encode(atob(i)),new TextEncoder().encode(JSON.stringify(e))))return!0;return!1}};var _=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/accounts/"+encodeURIComponent(t),{...e,method:"GET"})}};var y=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 R=class{constructor(t){this._transport=t}get api(){return{get:new _(this._transport),update:new y(this._transport)}}};var T=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/accounts/"+encodeURIComponent(t)+"/conversation-settings",{...e,method:"GET"})}};var O=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 v=class{constructor(t){this._transport=t}get api(){return{get:new T(this._transport),update:new O(this._transport)}}};var w=class{constructor(t){this._transport=t}send({limit:t,request:e={}}={}){return this._transport.send("v1/actions",{...e,method:"GET",searchParams:[...this._transport.limitQuery(t)]})}};var F=class{constructor(t){this._transport=t}get api(){return{list:new w(this._transport)}}};var L=class{constructor(t){this._transport=t}send(t,{limit:e,request:r={}}={}){return this._transport.send("v1/boilerplate-categories/"+encodeURIComponent(t)+"/boilerplates",{...r,method:"GET",searchParams:[...this._transport.limitQuery(e)]})}};var S=class{constructor(t){this._transport=t}send({body:t,request:e={}}){return this._transport.send("v1/boilerplate-categories",{...e,method:"POST",json:t})}};var U=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/boilerplate-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/boilerplate-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/boilerplate-categories/"+encodeURIComponent(t),{...r,method:"PATCH",json:e})}};var A=class{constructor(t){this._transport=t}get api(){return{get:new U(this._transport),list:new q(this._transport),create:new S(this._transport),update:new I(this._transport),boilerplate:{list:new L(this._transport)}}}};var E=class{constructor(t){this._transport=t}send({body:t,request:e={}}){return this._transport.send("v1/boilerplates",{...e,method:"POST",json:t})}};var G=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/boilerplates/"+encodeURIComponent(t),{...e,method:"GET"})}};var P=class{constructor(t){this._transport=t}send({limit:t,query:e,request:r={}}={}){return this._transport.send("v1/boilerplates",{...r,method:"GET",searchParams:[...this._transport.limitQuery(t),...this._transport.queryQuery(e)]})}};var N=class{constructor(t){this._transport=t}send(t,{body:e,request:r={}}){return this._transport.send("v1/boilerplates/"+encodeURIComponent(t),{...r,method:"PATCH",json:e})}};var B=class{constructor(t){this._transport=t}get api(){return{get:new G(this._transport),list:new P(this._transport),update:new N(this._transport),create:new E(this._transport)}}};var M=class{constructor(t){this._transport=t}send({body:t,request:e={}}){return this._transport.send("v1/channels",{...e,method:"POST",json:t})}};var j=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/channels/"+encodeURIComponent(t),{...e,method:"GET"})}};var D=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 ne=require("zod"),H=class o{constructor(t){this._transport=t}static SCHEMA=ne.z.object({overwrite:ne.z.boolean().optional()});send(t,{body:e,request:r={}}){return this._transport.send("v1/sources/twilio-sendgrid/channels/"+encodeURIComponent(t)+"/sync",{...r,method:"POST",json:o.SCHEMA.parse(e)})}};var K=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 Q=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 k=class{constructor(t){this._transport=t}send(t,{limit:e,request:r={}}={}){return this._transport.send("v1/channels/"+encodeURIComponent(t)+"/messages",{...r,method:"GET",searchParams:[...this._transport.limitQuery(e)]})}};var V=class{constructor(t){this._transport=t}get api(){return{get:new j(this._transport),list:new D(this._transport),update:new K(this._transport),create:new M(this._transport),compositionSection:{list:new Q(this._transport)},message:{list:new k(this._transport)},twilioSendgrid:{sync:new H(this._transport)}}}};var W=class{constructor(t){this._transport=t}send({body:t,request:e={}}){return this._transport.send("v1/composition-sections",{...e,method:"POST",json:t})}};var Y=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/composition-sections/"+encodeURIComponent(t),{...e,method:"GET"})}};var z=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 J=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 $=class{constructor(t){this._transport=t}get api(){return{get:new Y(this._transport),list:new z(this._transport),create:new W(this._transport),update:new J(this._transport)}}};var X=class{constructor(t){this._transport=t}getRelativeURL({id:t,vcf:e={}}){let r=e.variant??"vcard",n=e.format??(r==="vcard"?"vcf":"json");return"v1/contacts/"+encodeURIComponent(t)+"/vcf?variant="+encodeURIComponent(r)+"&format="+encodeURIComponent(n)}getURL(t){return this._transport.getURL(this.getRelativeURL(t))}send(t){return this._transport.send(this.getURL(t),{method:"GET"})}};var Z=class{constructor(t){this._transport=t}send({body:t,request:e={}}){return this._transport.send("v1/contacts",{...e,method:"POST",json:t})}};var tt=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 et=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 ot=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 rt=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 nt=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 st=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 it=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/contacts/"+encodeURIComponent(t)+"/notes",{...e,method:"GET"})}};var at=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 pt=class{constructor(t){this._transport=t}get api(){return{get:new tt(this._transport),list:new et(this._transport),update:new ot(this._transport),create:new Z(this._transport),conversation:{list:new rt(this._transport)},label:{list:new nt(this._transport)},note:{list:new it(this._transport),create:new st(this._transport)},notificationSubscription:{create:new at(this._transport)},vcf:{get:new X(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 lt=class{constructor(t){this._transport=t}send({limit:t,filter:e,include:r,request:n={}}={}){return this._transport.send("v1/conversations",{...n,method:"GET",searchParams:[...this._transport.limitQuery(t),...e?[["filter",e]]:[],...this._transport.includeQuery(r??{})]})}};var dt=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 mt=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 ut=class{constructor(t){this._transport=t}send(t,{limit:e,include:r,request:n={}}={}){return this._transport.send("v1/conversations/"+encodeURIComponent(t)+"/messages",{...n,method:"GET",searchParams:[...this._transport.limitQuery(e),...this._transport.includeQuery(r??{})]})}};var m=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 ht=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/conversations/"+encodeURIComponent(t)+"/notes",{...e,method:"GET"})}};var ft=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 m(this._transport),label:{list:new mt(this._transport)},message:{list:new ut(this._transport)},note:{list:new ht(this._transport),create:new m(this._transport)}}}};var Ct=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 gt=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 bt=class{constructor(t){this._transport=t}send({body:t,request:e={}}){return this._transport.send("v1/labels",{...e,method:"POST",json:t})}};var xt=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/labels/"+encodeURIComponent(t),{...e,method:"DELETE"})}};var _t=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/labels/"+encodeURIComponent(t),{...e,method:"GET"})}};var yt=class{constructor(t){this._transport=t}send({limit:t,query:e,include:r,request:n={}}={}){return this._transport.send("v1/labels",{...n,method:"GET",searchParams:[...this._transport.limitQuery(t),...this._transport.queryQuery(e),...this._transport.includeQuery(r??{})]})}};var Rt=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 Tt=class{constructor(t){this._transport=t}get api(){return{create:new bt(this._transport),get:new _t(this._transport),list:new yt(this._transport),update:new Rt(this._transport),delete:new xt(this._transport),contact:{list:new Ct(this._transport)},conversation:{list:new gt(this._transport)}}}};var Ot=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 vt=class{constructor(t){this._transport=t}get api(){return{list:new Ot(this._transport)}}};var wt=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 Ft=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/models/"+encodeURIComponent(t),{...e,method:"GET"})}};var Lt=class{constructor(t){this._transport=t}send({request:t={}}={}){return this._transport.send("v1/models",{...t,method:"GET"})}};var St=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 Ut=class{constructor(t){this._transport=t}get api(){return{get:new Ft(this._transport),list:new Lt(this._transport),response:{create:new St(this._transport)},correction:{create:new wt(this._transport)}}}};var qt=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/notes/"+encodeURIComponent(t),{...e,method:"GET"})}};var It=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 At=class{constructor(t){this._transport=t}get api(){return{get:new qt(this._transport),update:new It(this._transport)}}};var Et=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/sources/"+encodeURIComponent(t),{...e,method:"GET"})}};var Gt=class{constructor(t){this._transport=t}send({category:t,request:e={}}={}){let r=[];if(t){let n=Array.isArray(t)?t:[t];for(let i of n)r.push(["category",i])}return this._transport.send("v1/sources",{...e,method:"GET",searchParams:r})}};var Pt=class{constructor(t){this._transport=t}get api(){return{get:new Et(this._transport),list:new Gt(this._transport)}}};var Nt=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/channel/"+encodeURIComponent(t)+"/statistics/message-frequency",{...e,method:"GET"})}};var Bt=class{constructor(t){this._transport=t}send({request:t={}}={}){return this._transport.send("v1/statistics/message-frequency",{...t,method:"GET"})}};var Mt=class{constructor(t){this._transport=t}get api(){return{messageFrequency:new Bt(this._transport),channelMessageFrequency:new Nt(this._transport)}}};var jt=class{constructor(t){this._transport=t}send({account:t,files:e,request:r={}}){let n=new FormData;for(let i of e)n.append("file",i);return this._transport.send("v1/uploads",{...r,method:"POST",body:n,searchParams:{account:t}})}};var Dt=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/uploads/"+encodeURIComponent(t),{...e,method:"DELETE"})}};var Ht=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/uploads/"+encodeURIComponent(t),{...e,method:"GET"})}};var Kt=class{constructor(t){this._transport=t}get api(){return{get:new Ht(this._transport),create:new jt(this._transport),delete:new Dt(this._transport)}}};var Qt=class{constructor(t){this._transport=t}send({request:t={}}={}){return this._transport.send(".well-known/notifications",{...t,method:"GET"})}};var kt=class{constructor(t){this._transport=t}get api(){return{notification:{get:new Qt(this._transport)}}}};var Vt=class o{static DEFAULT_BASE_URL=ve;_transport;_account;_accountConversationSettings;_action;_boilerplate;_boilerplateCategory;_channel;_compositionSection;_contact;_conversation;_label;_message;_model;_note;_source;_statistics;_upload;_webhook;_wellKnown;constructor(t,{baseURL:e,...r}={}){this._transport=new b({requestFilterables:[new h,t],...r,baseURL:e?.toString()??o.getBaseURL()}),this._account=new R(this._transport),this._accountConversationSettings=new v(this._transport),this._action=new F(this._transport),this._boilerplate=new B(this._transport),this._boilerplateCategory=new A(this._transport),this._channel=new V(this._transport),this._compositionSection=new $(this._transport),this._contact=new pt(this._transport),this._conversation=new ft(this._transport),this._label=new Tt(this._transport),this._message=new vt(this._transport),this._model=new Ut(this._transport),this._note=new At(this._transport),this._source=new Pt(this._transport),this._statistics=new Mt(this._transport),this._upload=new Kt(this._transport),this._webhook=new x(this),this._wellKnown=new kt(this._transport)}static getBaseURL(){return process.env[Oe]??this.DEFAULT_BASE_URL}get account(){return this._account.api}get accountConversationSettings(){return this._accountConversationSettings.api}get action(){return this._action.api}get boilerplate(){return this._boilerplate.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 se=require("commander"),Le=require("ora");function ie({client:o,ora:t}){let e=new se.Command("actions").description("Actions");return e.addCommand(new se.Command("list").description("List actions").action(async()=>{let r=await(0,Le.oraPromise)(()=>o.action.list.send().json(),{...t,text:"Finding actions"});console.log(r)})),e}var ae=require("commander"),Se=require("ora");function pe({client:o,ora:t}){let e=new ae.Command("channels").description("Channels");return e.addCommand(new ae.Command("list").description("List channels").action(async()=>{let r=await(0,Se.oraPromise)(()=>o.channel.list.send().json(),{...t,text:"Finding channels"});console.log(r)})),e}var Wt=require("commander"),Xt=require("ora");function ce({client:o,ora:t}){let e=new Wt.Command("contacts").description("Contacts");return e.addCommand(new Wt.Command("get").description("Find contact").argument("<contact>","Contact ID").action(async r=>{let n=await(0,Xt.oraPromise)(()=>o.contact.get.send(r).json(),{...t,text:"Finding contact"});console.log(n)})),e.addCommand(new Wt.Command("list").description("List contacts").action(async()=>{let r=await(0,Xt.oraPromise)(()=>o.contact.list.send().json(),{...t,text:"Finding contacts"});console.log(r)})),e.addCommand(new Wt.Command("get-vcf").description("Export Contact as VCF").argument("<contact>","Contact ID").action(async r=>{let n=await(0,Xt.oraPromise)(()=>o.contact.vcf.get.send({id:r}).response(),{...t,text:"Exporting contact"});console.log(n)})),e}var Zt=require("commander"),le=require("ora");function de({client:o,ora:t}){let e=new Zt.Command("conversations").description("Conversations");return e.addCommand(new Zt.Command("get").description("Find conversation").argument("<conversation>","Conversation ID").action(async r=>{let n=await(0,le.oraPromise)(()=>o.conversation.get.send(r).json(),{...t,text:"Finding conversation"});console.log(n)})),e.addCommand(new Zt.Command("list").description("List conversations").action(async()=>{let r=await(0,le.oraPromise)(()=>o.conversation.list.send().json(),{...t,text:"Finding conversations"});console.log(r)})),e}var Yt=require("commander"),te=require("ora");function me({client:o,ora:t}){let e=new Yt.Command("labels").description("Labels");return e.addCommand(new Yt.Command("get").description("Find label").argument("<label>","Label ID").action(async r=>{let n=await(0,te.oraPromise)(()=>o.label.get.send(r).json(),{...t,text:"Finding label"});console.log(n)})),e.addCommand(new Yt.Command("list").description("List labels").action(async()=>{let r=await(0,te.oraPromise)(()=>o.label.list.send().json(),{...t,text:"Finding labels"});console.log(r)})),e.addCommand(new Yt.Command("conversations").description("Find label conversations").argument("<label>","Label ID").action(async r=>{let n=await(0,te.oraPromise)(()=>o.label.conversation.list.send(r).json(),{...t,text:"Finding conversations"});console.log(n)})),e}var ue=require("commander"),Ue=require("ora");function he({client:o,ora:t}){let e=new ue.Command("messages").description("Messages");return e.addCommand(new ue.Command("list").description("List messages").action(async()=>{let r=await(0,Ue.oraPromise)(()=>o.message.list.send().json(),{...t,text:"Finding messages"});console.log(r)})),e}var ee=require("commander"),fe=require("ora");function Ce({client:o,ora:t}){let e=new ee.Command("models").description("Models");return e.addCommand(new ee.Command("get").description("Find model").argument("<model>","Model ID").action(async r=>{let n=await(0,fe.oraPromise)(()=>o.model.get.send(r).json(),{...t,text:"Finding model"});console.log(n)})),e.addCommand(new ee.Command("list").description("List models").action(async()=>{let r=await(0,fe.oraPromise)(()=>o.model.list.send().json(),{...t,text:"Finding models"});console.log(r)})),e}var oe=require("commander"),ge=require("ora");function be({client:o,ora:t}){let e=new oe.Command("sources").description("Sources");return e.addCommand(new oe.Command("get").description("Find source").argument("<source>","Source ID").action(async r=>{let n=await(0,ge.oraPromise)(()=>o.source.get.send(r).json(),{...t,text:"Finding source"});console.log(n)})),e.addCommand(new oe.Command("list").description("List sources").action(async()=>{let r=await(0,ge.oraPromise)(()=>o.source.list.send().json(),{...t,text:"Finding sources"});console.log(r)})),e}var Ie=require("commander");var xe=require("commander"),qe=require("ora");function _e({client:o,ora:t}){let e=new xe.Command("notifications").description("Well-Known Notifications Details");return e.addCommand(new xe.Command("get").description("Get Notifications Server Well-Known Info").action(async()=>{let r=await(0,qe.oraPromise)(()=>o.wellKnown.notification.get.send().json(),{...t,text:"Finding Notifications Well-Known Info"});console.log(r)})),e}function ye({client:o,ora:t}){let e=new Ie.Command("well-known").description("Well-Known Metadata & Info");return e.addCommand(_e({client:o,ora:t})),e}var p={ora:{spinner:"simpleDotsScrolling"},client:new Vt(new u)},He=new Ae.Command("gds").description("Great Detail Support System").addCommand(ie(p)).addCommand(pe(p)).addCommand(ce(p)).addCommand(de(p)).addCommand(me(p)).addCommand(he(p)).addCommand(Ce(p)).addCommand(be(p)).addCommand(ye(p)),Ke=He;
@@ -1,5 +1,5 @@
1
1
  import { Command } from 'commander';
2
- import { C as Client } from '../index-DvZLYvUd.cjs';
2
+ import { C as Client } from '../index-iJIOONbG.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-DvZLYvUd.js';
2
+ import { C as Client } from '../index-iJIOONbG.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-FZXXJOJT.js";import"../chunk-5AQYHVY3.js";export{a as default};
1
+ import{a}from"../chunk-CM52Z6RN.js";import"../chunk-XNWCAGZ7.js";export{a as default};
package/dist/cli.cjs CHANGED
@@ -1,2 +1,2 @@
1
1
  #!/usr/bin/env node
2
- "use strict";var qe=Object.create;var be=Object.defineProperty;var Ae=Object.getOwnPropertyDescriptor;var Ee=Object.getOwnPropertyNames;var Pe=Object.getPrototypeOf,Ge=Object.prototype.hasOwnProperty;var Ne=(o,t,e,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of Ee(t))!Ge.call(o,n)&&n!==e&&be(o,n,{get:()=>t[n],enumerable:!(r=Ae(t,n))||r.enumerable});return o};var xe=(o,t,e)=>(e=o!=null?qe(Pe(o)):{},Ne(t||!o||!o.__esModule?be(e,"default",{value:o,enumerable:!0}):e,o));var Se=require("commander");var u=class{async filter(){return{headers:this.getHeaders()}}getHeaders(){return{}}};var Zt="SUPPORT_SIGNING_KEY",_e="SUPPORT_BASE_URL";var ye="https://api.support.greatdetail.com",Re={"X-Powered-By":"GDSupport/JavaScript"};var h=class o{constructor(t=o.STANDARD_HEADERS){this._standardHeaders=t}static STANDARD_HEADERS=Re;async filter(){return{headers:this.getHeaders()}}getHeaders(){return this._standardHeaders}};var Te=xe(require("is-network-error"),1),Wt=xe(require("ky"),1);var a=class extends Error{static serverError(t){return new this("Server Error: "+t)}};var l=class extends a{};var f=class extends l{static unauthenticated(){return new this("An unauthenticated request occurred")}};var C=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 g=class extends a{};var d=class extends a{static badRequest(){return new this("Bad request")}static unsupportedMediaType(){return new this("Unsupported Media Type")}};var b=class{client;options;constructor({baseURL:t,...e}){this.options={...e,baseURL:t},this.client=Wt.default.create({prefixUrl:this.options.baseURL,timeout:12e3,hooks:{beforeRequest:[r=>{for(let n of this.options.requestFilterables){let i=n.getHeaders();for(let[Vt,Ie]of Object.entries(i))r.headers.has(Vt)||r.headers.set(Vt,Ie)}}]}})}getURL(t){return new URL(t,this.options.baseURL).toString()}limitQuery(t){let e=[];return t&&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&&e.push(["query",t]),e}send(t,e){let r=this.client(t,e).catch(n=>{if((0,Te.default)(n))throw new g("A network error occurred",{cause:n});if(n instanceof Wt.HTTPError){let i=n.response.status;switch(console.error(JSON.stringify(n.response)),i){case 400:throw d.badRequest();case 401:throw f.unauthenticated();case 403:throw C.forbidden();case 404:throw c.notFound(t);case 405:throw c.forbiddenMethod(t,e.method??"GET");case 415:throw d.unsupportedMediaType();case 418:throw c.teapot();case 429:throw c.rateLimited()}if(i>=500&&i<600)throw a.serverError(i)}throw n});return{response:()=>r,json:async()=>(await r).json()}}};var s=require("zod");var x=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("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[Zt],maxSignatures:e=3,request:r}){let n=r.headers["gds-signature"];if(t!==!1){if(t===void 0)throw new Error("Missing webhook signing key in process.env."+Zt);if(!n)throw new Error("Missing signature header");if(!this._verifySignature(t,r.body,Array.isArray(n)?n.slice(0,e):[n]))throw new Error("Untrusted signature")}let{data:i}=o.SCHEMA.parse(r.body);return{event:i.event}}async _verifySignature(t,e,r){let n=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",n,new TextEncoder().encode(atob(i)),new TextEncoder().encode(JSON.stringify(e))))return!0;return!1}};var _=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/accounts/"+encodeURIComponent(t),{...e,method:"GET"})}};var y=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 R=class{constructor(t){this._transport=t}get api(){return{get:new _(this._transport),update:new y(this._transport)}}};var T=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/accounts/"+encodeURIComponent(t)+"/conversation-settings",{...e,method:"GET"})}};var O=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 v=class{constructor(t){this._transport=t}get api(){return{get:new T(this._transport),update:new O(this._transport)}}};var w=class{constructor(t){this._transport=t}send({limit:t,request:e={}}={}){return this._transport.send("v1/actions",{...e,method:"GET",searchParams:[...this._transport.limitQuery(t)]})}};var F=class{constructor(t){this._transport=t}get api(){return{list:new w(this._transport)}}};var L=class{constructor(t){this._transport=t}send(t,{limit:e,request:r={}}={}){return this._transport.send("v1/boilerplate-categories/"+encodeURIComponent(t)+"/boilerplates",{...r,method:"GET",searchParams:[...this._transport.limitQuery(e)]})}};var S=class{constructor(t){this._transport=t}send({body:t,request:e={}}){return this._transport.send("v1/boilerplate-categories",{...e,method:"POST",json:t})}};var U=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/boilerplate-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/boilerplate-categories",{...r,method:"GET",searchParams:[...this._transport.limitQuery(t),...this._transport.includeQuery(e)]})}};var q=class{constructor(t){this._transport=t}send(t,{body:e,request:r={}}){return this._transport.send("v1/boilerplate-categories/"+encodeURIComponent(t),{...r,method:"PATCH",json:e})}};var A=class{constructor(t){this._transport=t}get api(){return{get:new U(this._transport),list:new I(this._transport),create:new S(this._transport),update:new q(this._transport),boilerplate:{list:new L(this._transport)}}}};var E=class{constructor(t){this._transport=t}send({body:t,request:e={}}){return this._transport.send("v1/boilerplates",{...e,method:"POST",json:t})}};var P=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/boilerplates/"+encodeURIComponent(t),{...e,method:"GET"})}};var G=class{constructor(t){this._transport=t}send({limit:t,query:e,request:r={}}={}){return this._transport.send("v1/boilerplates",{...r,method:"GET",searchParams:[...this._transport.limitQuery(t),...this._transport.queryQuery(e)]})}};var N=class{constructor(t){this._transport=t}send(t,{body:e,request:r={}}){return this._transport.send("v1/boilerplates/"+encodeURIComponent(t),{...r,method:"PATCH",json:e})}};var B=class{constructor(t){this._transport=t}get api(){return{get:new P(this._transport),list:new G(this._transport),update:new N(this._transport),create:new E(this._transport)}}};var j=class{constructor(t){this._transport=t}send({body:t,request:e={}}){return this._transport.send("v1/channels",{...e,method:"POST",json:t})}};var M=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/channels/"+encodeURIComponent(t),{...e,method:"GET"})}};var D=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 te=require("zod"),H=class o{constructor(t){this._transport=t}static SCHEMA=te.z.object({overwrite:te.z.boolean().optional()});send(t,{body:e,request:r={}}){return this._transport.send("v1/sources/twilio-sendgrid/channels/"+encodeURIComponent(t)+"/sync",{...r,method:"POST",json:o.SCHEMA.parse(e)})}};var K=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 Q=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 k=class{constructor(t){this._transport=t}send(t,{limit:e,request:r={}}={}){return this._transport.send("v1/channels/"+encodeURIComponent(t)+"/messages",{...r,method:"GET",searchParams:[...this._transport.limitQuery(e)]})}};var V=class{constructor(t){this._transport=t}get api(){return{get:new M(this._transport),list:new D(this._transport),update:new K(this._transport),create:new j(this._transport),compositionSection:{list:new Q(this._transport)},message:{list:new k(this._transport)},twilioSendgrid:{sync:new H(this._transport)}}}};var W=class{constructor(t){this._transport=t}send({body:t,request:e={}}){return this._transport.send("v1/composition-sections",{...e,method:"POST",json:t})}};var Y=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/composition-sections/"+encodeURIComponent(t),{...e,method:"GET"})}};var z=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 J=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 $=class{constructor(t){this._transport=t}get api(){return{get:new Y(this._transport),list:new z(this._transport),create:new W(this._transport),update:new J(this._transport)}}};var X=class{constructor(t){this._transport=t}getRelativeURL({id:t,vcf:e={}}){let r=e.variant??"vcard",n=e.format??(r==="vcard"?"vcf":"json");return"v1/contacts/"+encodeURIComponent(t)+"/vcf?variant="+encodeURIComponent(r)+"&format="+encodeURIComponent(n)}getURL(t){return this._transport.getURL(this.getRelativeURL(t))}send(t){return this._transport.send(this.getURL(t),{method:"GET"})}};var Z=class{constructor(t){this._transport=t}send({body:t,request:e={}}){return this._transport.send("v1/contacts",{...e,method:"POST",json:t})}};var tt=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 et=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 ot=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 rt=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 nt=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 st=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 it=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/contacts/"+encodeURIComponent(t)+"/notes",{...e,method:"GET"})}};var at=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 pt=class{constructor(t){this._transport=t}get api(){return{get:new tt(this._transport),list:new et(this._transport),update:new ot(this._transport),create:new Z(this._transport),conversation:{list:new rt(this._transport)},label:{list:new nt(this._transport)},note:{list:new it(this._transport),create:new st(this._transport)},notificationSubscription:{create:new at(this._transport)},vcf:{get:new X(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 lt=class{constructor(t){this._transport=t}send({limit:t,filter:e,include:r,request:n={}}={}){return this._transport.send("v1/conversations",{...n,method:"GET",searchParams:[...this._transport.limitQuery(t),...e?[["filter",e]]:[],...this._transport.includeQuery(r??{})]})}};var dt=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 mt=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 ut=class{constructor(t){this._transport=t}send(t,{limit:e,include:r,request:n={}}={}){return this._transport.send("v1/conversations/"+encodeURIComponent(t)+"/messages",{...n,method:"GET",searchParams:[...this._transport.limitQuery(e),...this._transport.includeQuery(r??{})]})}};var m=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 ht=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/conversations/"+encodeURIComponent(t)+"/notes",{...e,method:"GET"})}};var ft=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 m(this._transport),label:{list:new mt(this._transport)},message:{list:new ut(this._transport)},note:{list:new ht(this._transport),create:new m(this._transport)}}}};var Ct=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 gt=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 bt=class{constructor(t){this._transport=t}send({body:t,request:e={}}){return this._transport.send("v1/labels",{...e,method:"POST",json:t})}};var xt=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/labels/"+encodeURIComponent(t),{...e,method:"DELETE"})}};var _t=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/labels/"+encodeURIComponent(t),{...e,method:"GET"})}};var yt=class{constructor(t){this._transport=t}send({limit:t,query:e,include:r,request:n={}}={}){return this._transport.send("v1/labels",{...n,method:"GET",searchParams:[...this._transport.limitQuery(t),...this._transport.queryQuery(e),...this._transport.includeQuery(r??{})]})}};var Rt=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 Tt=class{constructor(t){this._transport=t}get api(){return{create:new bt(this._transport),get:new _t(this._transport),list:new yt(this._transport),update:new Rt(this._transport),delete:new xt(this._transport),contact:{list:new Ct(this._transport)},conversation:{list:new gt(this._transport)}}}};var Ot=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 vt=class{constructor(t){this._transport=t}get api(){return{list:new Ot(this._transport)}}};var wt=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 Ft=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/models/"+encodeURIComponent(t),{...e,method:"GET"})}};var Lt=class{constructor(t){this._transport=t}send({request:t={}}={}){return this._transport.send("v1/models",{...t,method:"GET"})}};var St=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 Ut=class{constructor(t){this._transport=t}get api(){return{get:new Ft(this._transport),list:new Lt(this._transport),response:{create:new St(this._transport)},correction:{create:new wt(this._transport)}}}};var It=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/notes/"+encodeURIComponent(t),{...e,method:"GET"})}};var qt=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 At=class{constructor(t){this._transport=t}get api(){return{get:new It(this._transport),update:new qt(this._transport)}}};var Et=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/sources/"+encodeURIComponent(t),{...e,method:"GET"})}};var Pt=class{constructor(t){this._transport=t}send({category:t,request:e={}}={}){let r=[];if(t){let n=Array.isArray(t)?t:[t];for(let i of n)r.push(["category",i])}return this._transport.send("v1/sources",{...e,method:"GET",searchParams:r})}};var Gt=class{constructor(t){this._transport=t}get api(){return{get:new Et(this._transport),list:new Pt(this._transport)}}};var Nt=class{constructor(t){this._transport=t}send({account:t,files:e,request:r={}}){let n=new FormData;for(let i of e)n.append("file",i);return this._transport.send("v1/uploads",{...r,method:"POST",body:n,searchParams:{account:t}})}};var Bt=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 Mt=class{constructor(t){this._transport=t}get api(){return{get:new jt(this._transport),create:new Nt(this._transport),delete:new Bt(this._transport)}}};var Dt=class{constructor(t){this._transport=t}send({request:t={}}={}){return this._transport.send(".well-known/notifications",{...t,method:"GET"})}};var Ht=class{constructor(t){this._transport=t}get api(){return{notification:{get:new Dt(this._transport)}}}};var Kt=class o{static DEFAULT_BASE_URL=ye;_transport;_account;_accountConversationSettings;_action;_boilerplate;_boilerplateCategory;_channel;_compositionSection;_contact;_conversation;_label;_message;_model;_note;_source;_upload;_webhook;_wellKnown;constructor(t,{baseURL:e,...r}={}){this._transport=new b({requestFilterables:[new h,t],...r,baseURL:e?.toString()??o.getBaseURL()}),this._account=new R(this._transport),this._accountConversationSettings=new v(this._transport),this._action=new F(this._transport),this._boilerplate=new B(this._transport),this._boilerplateCategory=new A(this._transport),this._channel=new V(this._transport),this._compositionSection=new $(this._transport),this._contact=new pt(this._transport),this._conversation=new ft(this._transport),this._label=new Tt(this._transport),this._message=new vt(this._transport),this._model=new Ut(this._transport),this._note=new At(this._transport),this._source=new Gt(this._transport),this._upload=new Mt(this._transport),this._webhook=new x(this),this._wellKnown=new Ht(this._transport)}static getBaseURL(){return process.env[_e]??this.DEFAULT_BASE_URL}get account(){return this._account.api}get accountConversationSettings(){return this._accountConversationSettings.api}get action(){return this._action.api}get boilerplate(){return this._boilerplate.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 upload(){return this._upload.api}get webhook(){return this._webhook}get wellKnown(){return this._wellKnown.api}};var ee=require("commander"),Oe=require("ora");function oe({client:o,ora:t}){let e=new ee.Command("actions").description("Actions");return e.addCommand(new ee.Command("list").description("List actions").action(async()=>{let r=await(0,Oe.oraPromise)(()=>o.action.list.send().json(),{...t,text:"Finding actions"});console.log(r)})),e}var re=require("commander"),ve=require("ora");function ne({client:o,ora:t}){let e=new re.Command("channels").description("Channels");return e.addCommand(new re.Command("list").description("List channels").action(async()=>{let r=await(0,ve.oraPromise)(()=>o.channel.list.send().json(),{...t,text:"Finding channels"});console.log(r)})),e}var Qt=require("commander"),Yt=require("ora");function se({client:o,ora:t}){let e=new Qt.Command("contacts").description("Contacts");return e.addCommand(new Qt.Command("get").description("Find contact").argument("<contact>","Contact ID").action(async r=>{let n=await(0,Yt.oraPromise)(()=>o.contact.get.send(r).json(),{...t,text:"Finding contact"});console.log(n)})),e.addCommand(new Qt.Command("list").description("List contacts").action(async()=>{let r=await(0,Yt.oraPromise)(()=>o.contact.list.send().json(),{...t,text:"Finding contacts"});console.log(r)})),e.addCommand(new Qt.Command("get-vcf").description("Export Contact as VCF").argument("<contact>","Contact ID").action(async r=>{let n=await(0,Yt.oraPromise)(()=>o.contact.vcf.get.send({id:r}).response(),{...t,text:"Exporting contact"});console.log(n)})),e}var zt=require("commander"),ie=require("ora");function ae({client:o,ora:t}){let e=new zt.Command("conversations").description("Conversations");return e.addCommand(new zt.Command("get").description("Find conversation").argument("<conversation>","Conversation ID").action(async r=>{let n=await(0,ie.oraPromise)(()=>o.conversation.get.send(r).json(),{...t,text:"Finding conversation"});console.log(n)})),e.addCommand(new zt.Command("list").description("List conversations").action(async()=>{let r=await(0,ie.oraPromise)(()=>o.conversation.list.send().json(),{...t,text:"Finding conversations"});console.log(r)})),e}var kt=require("commander"),Jt=require("ora");function pe({client:o,ora:t}){let e=new kt.Command("labels").description("Labels");return e.addCommand(new kt.Command("get").description("Find label").argument("<label>","Label ID").action(async r=>{let n=await(0,Jt.oraPromise)(()=>o.label.get.send(r).json(),{...t,text:"Finding label"});console.log(n)})),e.addCommand(new kt.Command("list").description("List labels").action(async()=>{let r=await(0,Jt.oraPromise)(()=>o.label.list.send().json(),{...t,text:"Finding labels"});console.log(r)})),e.addCommand(new kt.Command("conversations").description("Find label conversations").argument("<label>","Label ID").action(async r=>{let n=await(0,Jt.oraPromise)(()=>o.label.conversation.list.send(r).json(),{...t,text:"Finding conversations"});console.log(n)})),e}var ce=require("commander"),we=require("ora");function le({client:o,ora:t}){let e=new ce.Command("messages").description("Messages");return e.addCommand(new ce.Command("list").description("List messages").action(async()=>{let r=await(0,we.oraPromise)(()=>o.message.list.send().json(),{...t,text:"Finding messages"});console.log(r)})),e}var $t=require("commander"),de=require("ora");function me({client:o,ora:t}){let e=new $t.Command("models").description("Models");return e.addCommand(new $t.Command("get").description("Find model").argument("<model>","Model ID").action(async r=>{let n=await(0,de.oraPromise)(()=>o.model.get.send(r).json(),{...t,text:"Finding model"});console.log(n)})),e.addCommand(new $t.Command("list").description("List models").action(async()=>{let r=await(0,de.oraPromise)(()=>o.model.list.send().json(),{...t,text:"Finding models"});console.log(r)})),e}var Xt=require("commander"),ue=require("ora");function he({client:o,ora:t}){let e=new Xt.Command("sources").description("Sources");return e.addCommand(new Xt.Command("get").description("Find source").argument("<source>","Source ID").action(async r=>{let n=await(0,ue.oraPromise)(()=>o.source.get.send(r).json(),{...t,text:"Finding source"});console.log(n)})),e.addCommand(new Xt.Command("list").description("List sources").action(async()=>{let r=await(0,ue.oraPromise)(()=>o.source.list.send().json(),{...t,text:"Finding sources"});console.log(r)})),e}var Le=require("commander");var fe=require("commander"),Fe=require("ora");function Ce({client:o,ora:t}){let e=new fe.Command("notifications").description("Well-Known Notifications Details");return e.addCommand(new fe.Command("get").description("Get Notifications Server Well-Known Info").action(async()=>{let r=await(0,Fe.oraPromise)(()=>o.wellKnown.notification.get.send().json(),{...t,text:"Finding Notifications Well-Known Info"});console.log(r)})),e}function ge({client:o,ora:t}){let e=new Le.Command("well-known").description("Well-Known Metadata & Info");return e.addCommand(Ce({client:o,ora:t})),e}var p={ora:{spinner:"simpleDotsScrolling"},client:new Kt(new u)},Be=new Se.Command("gds").description("Great Detail Support System").addCommand(oe(p)).addCommand(ne(p)).addCommand(se(p)).addCommand(ae(p)).addCommand(pe(p)).addCommand(le(p)).addCommand(me(p)).addCommand(he(p)).addCommand(ge(p)),Ue=Be;Ue.parseAsync(process.argv);
2
+ "use strict";var Ge=Object.create;var ye=Object.defineProperty;var Pe=Object.getOwnPropertyDescriptor;var Ne=Object.getOwnPropertyNames;var Be=Object.getPrototypeOf,Me=Object.prototype.hasOwnProperty;var je=(o,t,e,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of Ne(t))!Me.call(o,n)&&n!==e&&ye(o,n,{get:()=>t[n],enumerable:!(r=Pe(t,n))||r.enumerable});return o};var Re=(o,t,e)=>(e=o!=null?Ge(Be(o)):{},je(t||!o||!o.__esModule?ye(e,"default",{value:o,enumerable:!0}):e,o));var Ie=require("commander");var u=class{async filter(){return{headers:this.getHeaders()}}getHeaders(){return{}}};var oe="SUPPORT_SIGNING_KEY",Te="SUPPORT_BASE_URL";var Oe="https://api.support.greatdetail.com",ve={"X-Powered-By":"GDSupport/JavaScript"};var h=class o{constructor(t=o.STANDARD_HEADERS){this._standardHeaders=t}static STANDARD_HEADERS=ve;async filter(){return{headers:this.getHeaders()}}getHeaders(){return this._standardHeaders}};var we=Re(require("is-network-error"),1),Jt=Re(require("ky"),1);var a=class extends Error{static serverError(t){return new this("Server Error: "+t)}};var l=class extends a{};var f=class extends l{static unauthenticated(){return new this("An unauthenticated request occurred")}};var C=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 g=class extends a{};var d=class extends a{static badRequest(){return new this("Bad request")}static unsupportedMediaType(){return new this("Unsupported Media Type")}};var b=class{client;options;constructor({baseURL:t,...e}){this.options={...e,baseURL:t},this.client=Jt.default.create({prefixUrl:this.options.baseURL,timeout:12e3,hooks:{beforeRequest:[r=>{for(let n of this.options.requestFilterables){let i=n.getHeaders();for(let[zt,Ee]of Object.entries(i))r.headers.has(zt)||r.headers.set(zt,Ee)}}]}})}getURL(t){return new URL(t,this.options.baseURL).toString()}limitQuery(t){let e=[];return t&&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&&e.push(["query",t]),e}send(t,e){let r=this.client(t,e).catch(n=>{if((0,we.default)(n))throw new g("A network error occurred",{cause:n});if(n instanceof Jt.HTTPError){let i=n.response.status;switch(console.error(JSON.stringify(n.response)),i){case 400:throw d.badRequest();case 401:throw f.unauthenticated();case 403:throw C.forbidden();case 404:throw c.notFound(t);case 405:throw c.forbiddenMethod(t,e.method??"GET");case 415:throw d.unsupportedMediaType();case 418:throw c.teapot();case 429:throw c.rateLimited()}if(i>=500&&i<600)throw a.serverError(i)}throw n});return{response:()=>r,json:async()=>(await r).json()}}};var s=require("zod");var x=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("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[oe],maxSignatures:e=3,request:r}){let n=r.headers["gds-signature"];if(t!==!1){if(t===void 0)throw new Error("Missing webhook signing key in process.env."+oe);if(!n)throw new Error("Missing signature header");if(!this._verifySignature(t,r.body,Array.isArray(n)?n.slice(0,e):[n]))throw new Error("Untrusted signature")}let{data:i}=o.SCHEMA.parse(r.body);return{event:i.event}}async _verifySignature(t,e,r){let n=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",n,new TextEncoder().encode(atob(i)),new TextEncoder().encode(JSON.stringify(e))))return!0;return!1}};var _=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/accounts/"+encodeURIComponent(t),{...e,method:"GET"})}};var y=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 R=class{constructor(t){this._transport=t}get api(){return{get:new _(this._transport),update:new y(this._transport)}}};var T=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/accounts/"+encodeURIComponent(t)+"/conversation-settings",{...e,method:"GET"})}};var O=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 v=class{constructor(t){this._transport=t}get api(){return{get:new T(this._transport),update:new O(this._transport)}}};var w=class{constructor(t){this._transport=t}send({limit:t,request:e={}}={}){return this._transport.send("v1/actions",{...e,method:"GET",searchParams:[...this._transport.limitQuery(t)]})}};var F=class{constructor(t){this._transport=t}get api(){return{list:new w(this._transport)}}};var L=class{constructor(t){this._transport=t}send(t,{limit:e,request:r={}}={}){return this._transport.send("v1/boilerplate-categories/"+encodeURIComponent(t)+"/boilerplates",{...r,method:"GET",searchParams:[...this._transport.limitQuery(e)]})}};var S=class{constructor(t){this._transport=t}send({body:t,request:e={}}){return this._transport.send("v1/boilerplate-categories",{...e,method:"POST",json:t})}};var U=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/boilerplate-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/boilerplate-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/boilerplate-categories/"+encodeURIComponent(t),{...r,method:"PATCH",json:e})}};var A=class{constructor(t){this._transport=t}get api(){return{get:new U(this._transport),list:new q(this._transport),create:new S(this._transport),update:new I(this._transport),boilerplate:{list:new L(this._transport)}}}};var E=class{constructor(t){this._transport=t}send({body:t,request:e={}}){return this._transport.send("v1/boilerplates",{...e,method:"POST",json:t})}};var G=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/boilerplates/"+encodeURIComponent(t),{...e,method:"GET"})}};var P=class{constructor(t){this._transport=t}send({limit:t,query:e,request:r={}}={}){return this._transport.send("v1/boilerplates",{...r,method:"GET",searchParams:[...this._transport.limitQuery(t),...this._transport.queryQuery(e)]})}};var N=class{constructor(t){this._transport=t}send(t,{body:e,request:r={}}){return this._transport.send("v1/boilerplates/"+encodeURIComponent(t),{...r,method:"PATCH",json:e})}};var B=class{constructor(t){this._transport=t}get api(){return{get:new G(this._transport),list:new P(this._transport),update:new N(this._transport),create:new E(this._transport)}}};var M=class{constructor(t){this._transport=t}send({body:t,request:e={}}){return this._transport.send("v1/channels",{...e,method:"POST",json:t})}};var j=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/channels/"+encodeURIComponent(t),{...e,method:"GET"})}};var D=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 re=require("zod"),H=class o{constructor(t){this._transport=t}static SCHEMA=re.z.object({overwrite:re.z.boolean().optional()});send(t,{body:e,request:r={}}){return this._transport.send("v1/sources/twilio-sendgrid/channels/"+encodeURIComponent(t)+"/sync",{...r,method:"POST",json:o.SCHEMA.parse(e)})}};var K=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 Q=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 k=class{constructor(t){this._transport=t}send(t,{limit:e,request:r={}}={}){return this._transport.send("v1/channels/"+encodeURIComponent(t)+"/messages",{...r,method:"GET",searchParams:[...this._transport.limitQuery(e)]})}};var V=class{constructor(t){this._transport=t}get api(){return{get:new j(this._transport),list:new D(this._transport),update:new K(this._transport),create:new M(this._transport),compositionSection:{list:new Q(this._transport)},message:{list:new k(this._transport)},twilioSendgrid:{sync:new H(this._transport)}}}};var W=class{constructor(t){this._transport=t}send({body:t,request:e={}}){return this._transport.send("v1/composition-sections",{...e,method:"POST",json:t})}};var Y=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/composition-sections/"+encodeURIComponent(t),{...e,method:"GET"})}};var z=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 J=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 $=class{constructor(t){this._transport=t}get api(){return{get:new Y(this._transport),list:new z(this._transport),create:new W(this._transport),update:new J(this._transport)}}};var X=class{constructor(t){this._transport=t}getRelativeURL({id:t,vcf:e={}}){let r=e.variant??"vcard",n=e.format??(r==="vcard"?"vcf":"json");return"v1/contacts/"+encodeURIComponent(t)+"/vcf?variant="+encodeURIComponent(r)+"&format="+encodeURIComponent(n)}getURL(t){return this._transport.getURL(this.getRelativeURL(t))}send(t){return this._transport.send(this.getURL(t),{method:"GET"})}};var Z=class{constructor(t){this._transport=t}send({body:t,request:e={}}){return this._transport.send("v1/contacts",{...e,method:"POST",json:t})}};var tt=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 et=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 ot=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 rt=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 nt=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 st=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 it=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/contacts/"+encodeURIComponent(t)+"/notes",{...e,method:"GET"})}};var at=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 pt=class{constructor(t){this._transport=t}get api(){return{get:new tt(this._transport),list:new et(this._transport),update:new ot(this._transport),create:new Z(this._transport),conversation:{list:new rt(this._transport)},label:{list:new nt(this._transport)},note:{list:new it(this._transport),create:new st(this._transport)},notificationSubscription:{create:new at(this._transport)},vcf:{get:new X(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 lt=class{constructor(t){this._transport=t}send({limit:t,filter:e,include:r,request:n={}}={}){return this._transport.send("v1/conversations",{...n,method:"GET",searchParams:[...this._transport.limitQuery(t),...e?[["filter",e]]:[],...this._transport.includeQuery(r??{})]})}};var dt=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 mt=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 ut=class{constructor(t){this._transport=t}send(t,{limit:e,include:r,request:n={}}={}){return this._transport.send("v1/conversations/"+encodeURIComponent(t)+"/messages",{...n,method:"GET",searchParams:[...this._transport.limitQuery(e),...this._transport.includeQuery(r??{})]})}};var m=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 ht=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/conversations/"+encodeURIComponent(t)+"/notes",{...e,method:"GET"})}};var ft=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 m(this._transport),label:{list:new mt(this._transport)},message:{list:new ut(this._transport)},note:{list:new ht(this._transport),create:new m(this._transport)}}}};var Ct=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 gt=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 bt=class{constructor(t){this._transport=t}send({body:t,request:e={}}){return this._transport.send("v1/labels",{...e,method:"POST",json:t})}};var xt=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/labels/"+encodeURIComponent(t),{...e,method:"DELETE"})}};var _t=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/labels/"+encodeURIComponent(t),{...e,method:"GET"})}};var yt=class{constructor(t){this._transport=t}send({limit:t,query:e,include:r,request:n={}}={}){return this._transport.send("v1/labels",{...n,method:"GET",searchParams:[...this._transport.limitQuery(t),...this._transport.queryQuery(e),...this._transport.includeQuery(r??{})]})}};var Rt=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 Tt=class{constructor(t){this._transport=t}get api(){return{create:new bt(this._transport),get:new _t(this._transport),list:new yt(this._transport),update:new Rt(this._transport),delete:new xt(this._transport),contact:{list:new Ct(this._transport)},conversation:{list:new gt(this._transport)}}}};var Ot=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 vt=class{constructor(t){this._transport=t}get api(){return{list:new Ot(this._transport)}}};var wt=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 Ft=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/models/"+encodeURIComponent(t),{...e,method:"GET"})}};var Lt=class{constructor(t){this._transport=t}send({request:t={}}={}){return this._transport.send("v1/models",{...t,method:"GET"})}};var St=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 Ut=class{constructor(t){this._transport=t}get api(){return{get:new Ft(this._transport),list:new Lt(this._transport),response:{create:new St(this._transport)},correction:{create:new wt(this._transport)}}}};var qt=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/notes/"+encodeURIComponent(t),{...e,method:"GET"})}};var It=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 At=class{constructor(t){this._transport=t}get api(){return{get:new qt(this._transport),update:new It(this._transport)}}};var Et=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/sources/"+encodeURIComponent(t),{...e,method:"GET"})}};var Gt=class{constructor(t){this._transport=t}send({category:t,request:e={}}={}){let r=[];if(t){let n=Array.isArray(t)?t:[t];for(let i of n)r.push(["category",i])}return this._transport.send("v1/sources",{...e,method:"GET",searchParams:r})}};var Pt=class{constructor(t){this._transport=t}get api(){return{get:new Et(this._transport),list:new Gt(this._transport)}}};var Nt=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/channel/"+encodeURIComponent(t)+"/statistics/message-frequency",{...e,method:"GET"})}};var Bt=class{constructor(t){this._transport=t}send({request:t={}}={}){return this._transport.send("v1/statistics/message-frequency",{...t,method:"GET"})}};var Mt=class{constructor(t){this._transport=t}get api(){return{messageFrequency:new Bt(this._transport),channelMessageFrequency:new Nt(this._transport)}}};var jt=class{constructor(t){this._transport=t}send({account:t,files:e,request:r={}}){let n=new FormData;for(let i of e)n.append("file",i);return this._transport.send("v1/uploads",{...r,method:"POST",body:n,searchParams:{account:t}})}};var Dt=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/uploads/"+encodeURIComponent(t),{...e,method:"DELETE"})}};var Ht=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/uploads/"+encodeURIComponent(t),{...e,method:"GET"})}};var Kt=class{constructor(t){this._transport=t}get api(){return{get:new Ht(this._transport),create:new jt(this._transport),delete:new Dt(this._transport)}}};var Qt=class{constructor(t){this._transport=t}send({request:t={}}={}){return this._transport.send(".well-known/notifications",{...t,method:"GET"})}};var kt=class{constructor(t){this._transport=t}get api(){return{notification:{get:new Qt(this._transport)}}}};var Vt=class o{static DEFAULT_BASE_URL=Oe;_transport;_account;_accountConversationSettings;_action;_boilerplate;_boilerplateCategory;_channel;_compositionSection;_contact;_conversation;_label;_message;_model;_note;_source;_statistics;_upload;_webhook;_wellKnown;constructor(t,{baseURL:e,...r}={}){this._transport=new b({requestFilterables:[new h,t],...r,baseURL:e?.toString()??o.getBaseURL()}),this._account=new R(this._transport),this._accountConversationSettings=new v(this._transport),this._action=new F(this._transport),this._boilerplate=new B(this._transport),this._boilerplateCategory=new A(this._transport),this._channel=new V(this._transport),this._compositionSection=new $(this._transport),this._contact=new pt(this._transport),this._conversation=new ft(this._transport),this._label=new Tt(this._transport),this._message=new vt(this._transport),this._model=new Ut(this._transport),this._note=new At(this._transport),this._source=new Pt(this._transport),this._statistics=new Mt(this._transport),this._upload=new Kt(this._transport),this._webhook=new x(this),this._wellKnown=new kt(this._transport)}static getBaseURL(){return process.env[Te]??this.DEFAULT_BASE_URL}get account(){return this._account.api}get accountConversationSettings(){return this._accountConversationSettings.api}get action(){return this._action.api}get boilerplate(){return this._boilerplate.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 ne=require("commander"),Fe=require("ora");function se({client:o,ora:t}){let e=new ne.Command("actions").description("Actions");return e.addCommand(new ne.Command("list").description("List actions").action(async()=>{let r=await(0,Fe.oraPromise)(()=>o.action.list.send().json(),{...t,text:"Finding actions"});console.log(r)})),e}var ie=require("commander"),Le=require("ora");function ae({client:o,ora:t}){let e=new ie.Command("channels").description("Channels");return e.addCommand(new ie.Command("list").description("List channels").action(async()=>{let r=await(0,Le.oraPromise)(()=>o.channel.list.send().json(),{...t,text:"Finding channels"});console.log(r)})),e}var Wt=require("commander"),$t=require("ora");function pe({client:o,ora:t}){let e=new Wt.Command("contacts").description("Contacts");return e.addCommand(new Wt.Command("get").description("Find contact").argument("<contact>","Contact ID").action(async r=>{let n=await(0,$t.oraPromise)(()=>o.contact.get.send(r).json(),{...t,text:"Finding contact"});console.log(n)})),e.addCommand(new Wt.Command("list").description("List contacts").action(async()=>{let r=await(0,$t.oraPromise)(()=>o.contact.list.send().json(),{...t,text:"Finding contacts"});console.log(r)})),e.addCommand(new Wt.Command("get-vcf").description("Export Contact as VCF").argument("<contact>","Contact ID").action(async r=>{let n=await(0,$t.oraPromise)(()=>o.contact.vcf.get.send({id:r}).response(),{...t,text:"Exporting contact"});console.log(n)})),e}var Xt=require("commander"),ce=require("ora");function le({client:o,ora:t}){let e=new Xt.Command("conversations").description("Conversations");return e.addCommand(new Xt.Command("get").description("Find conversation").argument("<conversation>","Conversation ID").action(async r=>{let n=await(0,ce.oraPromise)(()=>o.conversation.get.send(r).json(),{...t,text:"Finding conversation"});console.log(n)})),e.addCommand(new Xt.Command("list").description("List conversations").action(async()=>{let r=await(0,ce.oraPromise)(()=>o.conversation.list.send().json(),{...t,text:"Finding conversations"});console.log(r)})),e}var Yt=require("commander"),Zt=require("ora");function de({client:o,ora:t}){let e=new Yt.Command("labels").description("Labels");return e.addCommand(new Yt.Command("get").description("Find label").argument("<label>","Label ID").action(async r=>{let n=await(0,Zt.oraPromise)(()=>o.label.get.send(r).json(),{...t,text:"Finding label"});console.log(n)})),e.addCommand(new Yt.Command("list").description("List labels").action(async()=>{let r=await(0,Zt.oraPromise)(()=>o.label.list.send().json(),{...t,text:"Finding labels"});console.log(r)})),e.addCommand(new Yt.Command("conversations").description("Find label conversations").argument("<label>","Label ID").action(async r=>{let n=await(0,Zt.oraPromise)(()=>o.label.conversation.list.send(r).json(),{...t,text:"Finding conversations"});console.log(n)})),e}var me=require("commander"),Se=require("ora");function ue({client:o,ora:t}){let e=new me.Command("messages").description("Messages");return e.addCommand(new me.Command("list").description("List messages").action(async()=>{let r=await(0,Se.oraPromise)(()=>o.message.list.send().json(),{...t,text:"Finding messages"});console.log(r)})),e}var te=require("commander"),he=require("ora");function fe({client:o,ora:t}){let e=new te.Command("models").description("Models");return e.addCommand(new te.Command("get").description("Find model").argument("<model>","Model ID").action(async r=>{let n=await(0,he.oraPromise)(()=>o.model.get.send(r).json(),{...t,text:"Finding model"});console.log(n)})),e.addCommand(new te.Command("list").description("List models").action(async()=>{let r=await(0,he.oraPromise)(()=>o.model.list.send().json(),{...t,text:"Finding models"});console.log(r)})),e}var ee=require("commander"),Ce=require("ora");function ge({client:o,ora:t}){let e=new ee.Command("sources").description("Sources");return e.addCommand(new ee.Command("get").description("Find source").argument("<source>","Source ID").action(async r=>{let n=await(0,Ce.oraPromise)(()=>o.source.get.send(r).json(),{...t,text:"Finding source"});console.log(n)})),e.addCommand(new ee.Command("list").description("List sources").action(async()=>{let r=await(0,Ce.oraPromise)(()=>o.source.list.send().json(),{...t,text:"Finding sources"});console.log(r)})),e}var qe=require("commander");var be=require("commander"),Ue=require("ora");function xe({client:o,ora:t}){let e=new be.Command("notifications").description("Well-Known Notifications Details");return e.addCommand(new be.Command("get").description("Get Notifications Server Well-Known Info").action(async()=>{let r=await(0,Ue.oraPromise)(()=>o.wellKnown.notification.get.send().json(),{...t,text:"Finding Notifications Well-Known Info"});console.log(r)})),e}function _e({client:o,ora:t}){let e=new qe.Command("well-known").description("Well-Known Metadata & Info");return e.addCommand(xe({client:o,ora:t})),e}var p={ora:{spinner:"simpleDotsScrolling"},client:new Vt(new u)},De=new Ie.Command("gds").description("Great Detail Support System").addCommand(se(p)).addCommand(ae(p)).addCommand(pe(p)).addCommand(le(p)).addCommand(de(p)).addCommand(ue(p)).addCommand(fe(p)).addCommand(ge(p)).addCommand(_e(p)),Ae=De;Ae.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-FZXXJOJT.js";import"./chunk-5AQYHVY3.js";r.parseAsync(process.argv);
2
+ import{a as r}from"./chunk-CM52Z6RN.js";import"./chunk-XNWCAGZ7.js";r.parseAsync(process.argv);
@@ -162,6 +162,44 @@ declare class GetUpload {
162
162
  };
163
163
  }
164
164
 
165
+ interface GetChannelMessageFrequencyStatisticsOptions {
166
+ request?: RequestInit;
167
+ }
168
+ type ChannelMessageFrequencyStatistic = {
169
+ date: string;
170
+ count: number;
171
+ };
172
+ type GetChannelMessageFrequencyStatisticsResponse = {
173
+ data: ChannelMessageFrequencyStatistic[];
174
+ };
175
+ declare class GetChannelMessageFrequencyStatistics {
176
+ protected _transport: FetchTransport;
177
+ constructor(_transport: FetchTransport);
178
+ send(id: string, { request }?: GetChannelMessageFrequencyStatisticsOptions): {
179
+ response: () => Promise<ky.KyResponse<GetChannelMessageFrequencyStatisticsResponse>>;
180
+ json: () => Promise<GetChannelMessageFrequencyStatisticsResponse>;
181
+ };
182
+ }
183
+
184
+ interface GetMessageFrequencyStatisticsOptions {
185
+ request?: RequestInit;
186
+ }
187
+ type MessageFrequencyStatistic = {
188
+ date: string;
189
+ count: number;
190
+ };
191
+ type GetMessageFrequencyStatisticsResponse = {
192
+ data: MessageFrequencyStatistic[];
193
+ };
194
+ declare class GetMessageFrequencyStatistics {
195
+ protected _transport: FetchTransport;
196
+ constructor(_transport: FetchTransport);
197
+ send({ request }?: GetMessageFrequencyStatisticsOptions): {
198
+ response: () => Promise<ky.KyResponse<GetMessageFrequencyStatisticsResponse>>;
199
+ json: () => Promise<GetMessageFrequencyStatisticsResponse>;
200
+ };
201
+ }
202
+
165
203
  /**
166
204
  * Great Detail Support System.
167
205
  *
@@ -2340,6 +2378,24 @@ declare class SourceClient {
2340
2378
  };
2341
2379
  }
2342
2380
 
2381
+ /**
2382
+ * Great Detail Support System.
2383
+ *
2384
+ * @copyright 2024 Great Detail Ltd
2385
+ * @author Great Detail Ltd <info@greatdetail.com>
2386
+ * @author Dom Webber <dom.webber@greatdetail.com>
2387
+ * @see https://greatdetail.com
2388
+ */
2389
+
2390
+ declare class StatisticsClient {
2391
+ protected _transport: FetchTransport;
2392
+ constructor(_transport: FetchTransport);
2393
+ get api(): {
2394
+ messageFrequency: GetMessageFrequencyStatistics;
2395
+ channelMessageFrequency: GetChannelMessageFrequencyStatistics;
2396
+ };
2397
+ }
2398
+
2343
2399
  /**
2344
2400
  * Great Detail Support System.
2345
2401
  *
@@ -2398,6 +2454,7 @@ declare class Client {
2398
2454
  protected _model: ModelClient;
2399
2455
  protected _note: NoteClient;
2400
2456
  protected _source: SourceClient;
2457
+ protected _statistics: StatisticsClient;
2401
2458
  protected _upload: UploadClient;
2402
2459
  protected _webhook: Webhook;
2403
2460
  protected _wellKnown: WellKnownClient;
@@ -2522,6 +2579,10 @@ declare class Client {
2522
2579
  get: GetSource;
2523
2580
  list: ListSources;
2524
2581
  };
2582
+ get statistics(): {
2583
+ messageFrequency: GetMessageFrequencyStatistics;
2584
+ channelMessageFrequency: GetChannelMessageFrequencyStatistics;
2585
+ };
2525
2586
  get upload(): {
2526
2587
  get: GetUpload;
2527
2588
  create: CreateUpload;
@@ -162,6 +162,44 @@ declare class GetUpload {
162
162
  };
163
163
  }
164
164
 
165
+ interface GetChannelMessageFrequencyStatisticsOptions {
166
+ request?: RequestInit;
167
+ }
168
+ type ChannelMessageFrequencyStatistic = {
169
+ date: string;
170
+ count: number;
171
+ };
172
+ type GetChannelMessageFrequencyStatisticsResponse = {
173
+ data: ChannelMessageFrequencyStatistic[];
174
+ };
175
+ declare class GetChannelMessageFrequencyStatistics {
176
+ protected _transport: FetchTransport;
177
+ constructor(_transport: FetchTransport);
178
+ send(id: string, { request }?: GetChannelMessageFrequencyStatisticsOptions): {
179
+ response: () => Promise<ky.KyResponse<GetChannelMessageFrequencyStatisticsResponse>>;
180
+ json: () => Promise<GetChannelMessageFrequencyStatisticsResponse>;
181
+ };
182
+ }
183
+
184
+ interface GetMessageFrequencyStatisticsOptions {
185
+ request?: RequestInit;
186
+ }
187
+ type MessageFrequencyStatistic = {
188
+ date: string;
189
+ count: number;
190
+ };
191
+ type GetMessageFrequencyStatisticsResponse = {
192
+ data: MessageFrequencyStatistic[];
193
+ };
194
+ declare class GetMessageFrequencyStatistics {
195
+ protected _transport: FetchTransport;
196
+ constructor(_transport: FetchTransport);
197
+ send({ request }?: GetMessageFrequencyStatisticsOptions): {
198
+ response: () => Promise<ky.KyResponse<GetMessageFrequencyStatisticsResponse>>;
199
+ json: () => Promise<GetMessageFrequencyStatisticsResponse>;
200
+ };
201
+ }
202
+
165
203
  /**
166
204
  * Great Detail Support System.
167
205
  *
@@ -2340,6 +2378,24 @@ declare class SourceClient {
2340
2378
  };
2341
2379
  }
2342
2380
 
2381
+ /**
2382
+ * Great Detail Support System.
2383
+ *
2384
+ * @copyright 2024 Great Detail Ltd
2385
+ * @author Great Detail Ltd <info@greatdetail.com>
2386
+ * @author Dom Webber <dom.webber@greatdetail.com>
2387
+ * @see https://greatdetail.com
2388
+ */
2389
+
2390
+ declare class StatisticsClient {
2391
+ protected _transport: FetchTransport;
2392
+ constructor(_transport: FetchTransport);
2393
+ get api(): {
2394
+ messageFrequency: GetMessageFrequencyStatistics;
2395
+ channelMessageFrequency: GetChannelMessageFrequencyStatistics;
2396
+ };
2397
+ }
2398
+
2343
2399
  /**
2344
2400
  * Great Detail Support System.
2345
2401
  *
@@ -2398,6 +2454,7 @@ declare class Client {
2398
2454
  protected _model: ModelClient;
2399
2455
  protected _note: NoteClient;
2400
2456
  protected _source: SourceClient;
2457
+ protected _statistics: StatisticsClient;
2401
2458
  protected _upload: UploadClient;
2402
2459
  protected _webhook: Webhook;
2403
2460
  protected _wellKnown: WellKnownClient;
@@ -2522,6 +2579,10 @@ declare class Client {
2522
2579
  get: GetSource;
2523
2580
  list: ListSources;
2524
2581
  };
2582
+ get statistics(): {
2583
+ messageFrequency: GetMessageFrequencyStatistics;
2584
+ channelMessageFrequency: GetChannelMessageFrequencyStatistics;
2585
+ };
2525
2586
  get upload(): {
2526
2587
  get: GetUpload;
2527
2588
  create: CreateUpload;
package/dist/index.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";var ce=Object.create;var Vt=Object.defineProperty;var le=Object.getOwnPropertyDescriptor;var de=Object.getOwnPropertyNames;var ue=Object.getPrototypeOf,me=Object.prototype.hasOwnProperty;var Xt=(o,t)=>{for(var e in t)Vt(o,e,{get:t[e],enumerable:!0})},Zt=(o,t,e,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of de(t))!me.call(o,s)&&s!==e&&Vt(o,s,{get:()=>t[s],enumerable:!(r=le(t,s))||r.enumerable});return o};var te=(o,t,e)=>(e=o!=null?ce(ue(o)):{},Zt(t||!o||!o.__esModule?Vt(e,"default",{value:o,enumerable:!0}):e,o)),he=o=>Zt(Vt({},"__esModule",{value:!0}),o);var fe={};Xt(fe,{Client:()=>f,DEFAULT_SUPPORT_BASE_URL:()=>Wt,Error:()=>Jt,KeyAuthentication:()=>kt,PublicAuthentication:()=>Kt,TokenAuthentication:()=>Dt,default:()=>f});module.exports=he(fe);var Wt="https://api.support.greatdetail.com",ee={"X-Powered-By":"GDSupport/JavaScript"},oe="api-key";var re="SUPPORT_ACCESS_TOKEN",ne="SUPPORT_API_KEY",se="SUPPORT_KEY_NAME",zt="SUPPORT_SIGNING_KEY",ie="SUPPORT_BASE_URL";var C=class o{constructor(t=o.STANDARD_HEADERS){this._standardHeaders=t}static STANDARD_HEADERS=ee;async filter(){return{headers:this.getHeaders()}}getHeaders(){return this._standardHeaders}};var ae=te(require("is-network-error"),1),Yt=te(require("ky"),1);var i=class extends Error{static serverError(t){return new this("Server Error: "+t)}};var c=class extends i{};var d=class extends c{static unauthenticated(){return new this("An unauthenticated request occurred")}};var u=class extends c{static forbidden(){return new this("A forbidden request occurred")}};var p=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 m=class extends i{};var l=class extends i{static badRequest(){return new this("Bad request")}static unsupportedMediaType(){return new this("Unsupported Media Type")}};var g=class{client;options;constructor({baseURL:t,...e}){this.options={...e,baseURL:t},this.client=Yt.default.create({prefixUrl:this.options.baseURL,timeout:12e3,hooks:{beforeRequest:[r=>{for(let s of this.options.requestFilterables){let a=s.getHeaders();for(let[Qt,pe]of Object.entries(a))r.headers.has(Qt)||r.headers.set(Qt,pe)}}]}})}getURL(t){return new URL(t,this.options.baseURL).toString()}limitQuery(t){let e=[];return t&&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&&e.push(["query",t]),e}send(t,e){let r=this.client(t,e).catch(s=>{if((0,ae.default)(s))throw new m("A network error occurred",{cause:s});if(s instanceof Yt.HTTPError){let a=s.response.status;switch(console.error(JSON.stringify(s.response)),a){case 400:throw l.badRequest();case 401:throw d.unauthenticated();case 403:throw u.forbidden();case 404:throw p.notFound(t);case 405:throw p.forbiddenMethod(t,e.method??"GET");case 415:throw l.unsupportedMediaType();case 418:throw p.teapot();case 429:throw p.rateLimited()}if(a>=500&&a<600)throw i.serverError(a)}throw s});return{response:()=>r,json:async()=>(await r).json()}}};var n=require("zod");var b=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("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[zt],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."+zt);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:a}=o.SCHEMA.parse(r.body);return{event:a.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 a of r)if(await crypto.subtle.verify("HMAC",s,new TextEncoder().encode(atob(a)),new TextEncoder().encode(JSON.stringify(e))))return!0;return!1}};var _=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/accounts/"+encodeURIComponent(t),{...e,method:"GET"})}};var x=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 y=class{constructor(t){this._transport=t}get api(){return{get:new _(this._transport),update:new x(this._transport)}}};var R=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/accounts/"+encodeURIComponent(t)+"/conversation-settings",{...e,method:"GET"})}};var T=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 v=class{constructor(t){this._transport=t}get api(){return{get:new R(this._transport),update:new T(this._transport)}}};var O=class{constructor(t){this._transport=t}send({limit:t,request:e={}}={}){return this._transport.send("v1/actions",{...e,method:"GET",searchParams:[...this._transport.limitQuery(t)]})}};var L=class{constructor(t){this._transport=t}get api(){return{list:new O(this._transport)}}};var F=class{constructor(t){this._transport=t}send(t,{limit:e,request:r={}}={}){return this._transport.send("v1/boilerplate-categories/"+encodeURIComponent(t)+"/boilerplates",{...r,method:"GET",searchParams:[...this._transport.limitQuery(e)]})}};var U=class{constructor(t){this._transport=t}send({body:t,request:e={}}){return this._transport.send("v1/boilerplate-categories",{...e,method:"POST",json:t})}};var w=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/boilerplate-categories/"+encodeURIComponent(t),{...e,method:"GET"})}};var S=class{constructor(t){this._transport=t}send({limit:t,include:e,request:r={}}={}){return this._transport.send("v1/boilerplate-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/boilerplate-categories/"+encodeURIComponent(t),{...r,method:"PATCH",json:e})}};var q=class{constructor(t){this._transport=t}get api(){return{get:new w(this._transport),list:new S(this._transport),create:new U(this._transport),update:new I(this._transport),boilerplate:{list:new F(this._transport)}}}};var A=class{constructor(t){this._transport=t}send({body:t,request:e={}}){return this._transport.send("v1/boilerplates",{...e,method:"POST",json:t})}};var E=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/boilerplates/"+encodeURIComponent(t),{...e,method:"GET"})}};var P=class{constructor(t){this._transport=t}send({limit:t,query:e,request:r={}}={}){return this._transport.send("v1/boilerplates",{...r,method:"GET",searchParams:[...this._transport.limitQuery(t),...this._transport.queryQuery(e)]})}};var G=class{constructor(t){this._transport=t}send(t,{body:e,request:r={}}){return this._transport.send("v1/boilerplates/"+encodeURIComponent(t),{...r,method:"PATCH",json:e})}};var N=class{constructor(t){this._transport=t}get api(){return{get:new E(this._transport),list:new P(this._transport),update:new G(this._transport),create:new A(this._transport)}}};var B=class{constructor(t){this._transport=t}send({body:t,request:e={}}){return this._transport.send("v1/channels",{...e,method:"POST",json:t})}};var M=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/channels/"+encodeURIComponent(t),{...e,method:"GET"})}};var j=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 $t=require("zod"),H=class o{constructor(t){this._transport=t}static SCHEMA=$t.z.object({overwrite:$t.z.boolean().optional()});send(t,{body:e,request:r={}}){return this._transport.send("v1/sources/twilio-sendgrid/channels/"+encodeURIComponent(t)+"/sync",{...r,method:"POST",json:o.SCHEMA.parse(e)})}};var k=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 D=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 K=class{constructor(t){this._transport=t}send(t,{limit:e,request:r={}}={}){return this._transport.send("v1/channels/"+encodeURIComponent(t)+"/messages",{...r,method:"GET",searchParams:[...this._transport.limitQuery(e)]})}};var Q=class{constructor(t){this._transport=t}get api(){return{get:new M(this._transport),list:new j(this._transport),update:new k(this._transport),create:new B(this._transport),compositionSection:{list:new D(this._transport)},message:{list:new K(this._transport)},twilioSendgrid:{sync:new H(this._transport)}}}};var V=class{constructor(t){this._transport=t}send({body:t,request:e={}}){return this._transport.send("v1/composition-sections",{...e,method:"POST",json:t})}};var W=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/composition-sections/"+encodeURIComponent(t),{...e,method:"GET"})}};var Y=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 z=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 $=class{constructor(t){this._transport=t}get api(){return{get:new W(this._transport),list:new Y(this._transport),create:new V(this._transport),update:new z(this._transport)}}};var J=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 X=class{constructor(t){this._transport=t}send({body:t,request:e={}}){return this._transport.send("v1/contacts",{...e,method:"POST",json:t})}};var Z=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 tt=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 et=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 ot=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 rt=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 nt=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 st=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/contacts/"+encodeURIComponent(t)+"/notes",{...e,method:"GET"})}};var it=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 at=class{constructor(t){this._transport=t}get api(){return{get:new Z(this._transport),list:new tt(this._transport),update:new et(this._transport),create:new X(this._transport),conversation:{list:new ot(this._transport)},label:{list:new rt(this._transport)},note:{list:new st(this._transport),create:new nt(this._transport)},notificationSubscription:{create:new it(this._transport)},vcf:{get:new J(this._transport)}}}};var pt=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 ct=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 lt=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 dt=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 ut=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 h=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 mt=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/conversations/"+encodeURIComponent(t)+"/notes",{...e,method:"GET"})}};var ht=class{constructor(t){this._transport=t}get api(){return{get:new pt(this._transport),list:new ct(this._transport),update:new lt(this._transport),create:new h(this._transport),label:{list:new dt(this._transport)},message:{list:new ut(this._transport)},note:{list:new mt(this._transport),create:new h(this._transport)}}}};var ft=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 Ct=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 gt=class{constructor(t){this._transport=t}send({body:t,request:e={}}){return this._transport.send("v1/labels",{...e,method:"POST",json:t})}};var bt=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/labels/"+encodeURIComponent(t),{...e,method:"DELETE"})}};var _t=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/labels/"+encodeURIComponent(t),{...e,method:"GET"})}};var xt=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 yt=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 Rt=class{constructor(t){this._transport=t}get api(){return{create:new gt(this._transport),get:new _t(this._transport),list:new xt(this._transport),update:new yt(this._transport),delete:new bt(this._transport),contact:{list:new ft(this._transport)},conversation:{list:new Ct(this._transport)}}}};var Tt=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 vt=class{constructor(t){this._transport=t}get api(){return{list:new Tt(this._transport)}}};var Ot=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 Lt=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/models/"+encodeURIComponent(t),{...e,method:"GET"})}};var Ft=class{constructor(t){this._transport=t}send({request:t={}}={}){return this._transport.send("v1/models",{...t,method:"GET"})}};var Ut=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 wt=class{constructor(t){this._transport=t}get api(){return{get:new Lt(this._transport),list:new Ft(this._transport),response:{create:new Ut(this._transport)},correction:{create:new Ot(this._transport)}}}};var St=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/notes/"+encodeURIComponent(t),{...e,method:"GET"})}};var It=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 St(this._transport),update:new It(this._transport)}}};var At=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/sources/"+encodeURIComponent(t),{...e,method:"GET"})}};var Et=class{constructor(t){this._transport=t}send({category:t,request:e={}}={}){let r=[];if(t){let s=Array.isArray(t)?t:[t];for(let a of s)r.push(["category",a])}return this._transport.send("v1/sources",{...e,method:"GET",searchParams:r})}};var Pt=class{constructor(t){this._transport=t}get api(){return{get:new At(this._transport),list:new Et(this._transport)}}};var Gt=class{constructor(t){this._transport=t}send({account:t,files:e,request:r={}}){let s=new FormData;for(let a of e)s.append("file",a);return this._transport.send("v1/uploads",{...r,method:"POST",body:s,searchParams:{account:t}})}};var Nt=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/uploads/"+encodeURIComponent(t),{...e,method:"DELETE"})}};var Bt=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/uploads/"+encodeURIComponent(t),{...e,method:"GET"})}};var Mt=class{constructor(t){this._transport=t}get api(){return{get:new Bt(this._transport),create:new Gt(this._transport),delete:new Nt(this._transport)}}};var jt=class{constructor(t){this._transport=t}send({request:t={}}={}){return this._transport.send(".well-known/notifications",{...t,method:"GET"})}};var Ht=class{constructor(t){this._transport=t}get api(){return{notification:{get:new jt(this._transport)}}}};var f=class o{static DEFAULT_BASE_URL=Wt;_transport;_account;_accountConversationSettings;_action;_boilerplate;_boilerplateCategory;_channel;_compositionSection;_contact;_conversation;_label;_message;_model;_note;_source;_upload;_webhook;_wellKnown;constructor(t,{baseURL:e,...r}={}){this._transport=new g({requestFilterables:[new C,t],...r,baseURL:e?.toString()??o.getBaseURL()}),this._account=new y(this._transport),this._accountConversationSettings=new v(this._transport),this._action=new L(this._transport),this._boilerplate=new N(this._transport),this._boilerplateCategory=new q(this._transport),this._channel=new Q(this._transport),this._compositionSection=new $(this._transport),this._contact=new at(this._transport),this._conversation=new ht(this._transport),this._label=new Rt(this._transport),this._message=new vt(this._transport),this._model=new wt(this._transport),this._note=new qt(this._transport),this._source=new Pt(this._transport),this._upload=new Mt(this._transport),this._webhook=new b(this),this._wellKnown=new Ht(this._transport)}static getBaseURL(){return process.env[ie]??this.DEFAULT_BASE_URL}get account(){return this._account.api}get accountConversationSettings(){return this._accountConversationSettings.api}get action(){return this._action.api}get boilerplate(){return this._boilerplate.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 upload(){return this._upload.api}get webhook(){return this._webhook}get wellKnown(){return this._wellKnown.api}};var Jt={};Xt(Jt,{AuthError:()=>c,AuthenticationError:()=>d,AuthorizationError:()=>u,LogicError:()=>p,NetworkError:()=>m,SupportError:()=>i,ValidationError:()=>l});var kt=class o{static DEFAULT_NAME=oe;name;#t;constructor({name:t=process.env[se]??o.DEFAULT_NAME,key:e=process.env[ne]}={}){if(!e)throw new Error("API Key option must be specified when using Key Authentication");this.name=t,this.#t=e}async filter(){return{headers:this.getHeaders()}}getHeaders(){return{Authorization:`Basic ${btoa(this.name+":"+this.#t)}`}}};var Dt=class{#t;constructor({token:t=process.env[re]}={}){if(!t)throw new Error("Access Token option must be specified when using Token Authentication");this.#t=t}async filter(){return{headers:this.getHeaders()}}getHeaders(){return{Authorization:`Bearer ${this.#t}`}}};var Kt=class{async filter(){return{headers:this.getHeaders()}}getHeaders(){return{}}};0&&(module.exports={Client,DEFAULT_SUPPORT_BASE_URL,Error,KeyAuthentication,PublicAuthentication,TokenAuthentication});
1
+ "use strict";var ue=Object.create;var zt=Object.defineProperty;var me=Object.getOwnPropertyDescriptor;var he=Object.getOwnPropertyNames;var fe=Object.getPrototypeOf,Ce=Object.prototype.hasOwnProperty;var ee=(o,t)=>{for(var e in t)zt(o,e,{get:t[e],enumerable:!0})},oe=(o,t,e,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of he(t))!Ce.call(o,s)&&s!==e&&zt(o,s,{get:()=>t[s],enumerable:!(r=me(t,s))||r.enumerable});return o};var re=(o,t,e)=>(e=o!=null?ue(fe(o)):{},oe(t||!o||!o.__esModule?zt(e,"default",{value:o,enumerable:!0}):e,o)),ge=o=>oe(zt({},"__esModule",{value:!0}),o);var be={};ee(be,{Client:()=>f,DEFAULT_SUPPORT_BASE_URL:()=>$t,Error:()=>te,KeyAuthentication:()=>Qt,PublicAuthentication:()=>Wt,TokenAuthentication:()=>Vt,default:()=>f});module.exports=ge(be);var $t="https://api.support.greatdetail.com",ne={"X-Powered-By":"GDSupport/JavaScript"},se="api-key";var ie="SUPPORT_ACCESS_TOKEN",ae="SUPPORT_API_KEY",pe="SUPPORT_KEY_NAME",Xt="SUPPORT_SIGNING_KEY",ce="SUPPORT_BASE_URL";var C=class o{constructor(t=o.STANDARD_HEADERS){this._standardHeaders=t}static STANDARD_HEADERS=ne;async filter(){return{headers:this.getHeaders()}}getHeaders(){return this._standardHeaders}};var le=re(require("is-network-error"),1),Jt=re(require("ky"),1);var i=class extends Error{static serverError(t){return new this("Server Error: "+t)}};var c=class extends i{};var d=class extends c{static unauthenticated(){return new this("An unauthenticated request occurred")}};var u=class extends c{static forbidden(){return new this("A forbidden request occurred")}};var p=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 m=class extends i{};var l=class extends i{static badRequest(){return new this("Bad request")}static unsupportedMediaType(){return new this("Unsupported Media Type")}};var g=class{client;options;constructor({baseURL:t,...e}){this.options={...e,baseURL:t},this.client=Jt.default.create({prefixUrl:this.options.baseURL,timeout:12e3,hooks:{beforeRequest:[r=>{for(let s of this.options.requestFilterables){let a=s.getHeaders();for(let[Yt,de]of Object.entries(a))r.headers.has(Yt)||r.headers.set(Yt,de)}}]}})}getURL(t){return new URL(t,this.options.baseURL).toString()}limitQuery(t){let e=[];return t&&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&&e.push(["query",t]),e}send(t,e){let r=this.client(t,e).catch(s=>{if((0,le.default)(s))throw new m("A network error occurred",{cause:s});if(s instanceof Jt.HTTPError){let a=s.response.status;switch(console.error(JSON.stringify(s.response)),a){case 400:throw l.badRequest();case 401:throw d.unauthenticated();case 403:throw u.forbidden();case 404:throw p.notFound(t);case 405:throw p.forbiddenMethod(t,e.method??"GET");case 415:throw l.unsupportedMediaType();case 418:throw p.teapot();case 429:throw p.rateLimited()}if(a>=500&&a<600)throw i.serverError(a)}throw s});return{response:()=>r,json:async()=>(await r).json()}}};var n=require("zod");var b=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("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[Xt],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."+Xt);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:a}=o.SCHEMA.parse(r.body);return{event:a.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 a of r)if(await crypto.subtle.verify("HMAC",s,new TextEncoder().encode(atob(a)),new TextEncoder().encode(JSON.stringify(e))))return!0;return!1}};var _=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/accounts/"+encodeURIComponent(t),{...e,method:"GET"})}};var x=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 y=class{constructor(t){this._transport=t}get api(){return{get:new _(this._transport),update:new x(this._transport)}}};var R=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/accounts/"+encodeURIComponent(t)+"/conversation-settings",{...e,method:"GET"})}};var T=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 v=class{constructor(t){this._transport=t}get api(){return{get:new R(this._transport),update:new T(this._transport)}}};var O=class{constructor(t){this._transport=t}send({limit:t,request:e={}}={}){return this._transport.send("v1/actions",{...e,method:"GET",searchParams:[...this._transport.limitQuery(t)]})}};var F=class{constructor(t){this._transport=t}get api(){return{list:new O(this._transport)}}};var S=class{constructor(t){this._transport=t}send(t,{limit:e,request:r={}}={}){return this._transport.send("v1/boilerplate-categories/"+encodeURIComponent(t)+"/boilerplates",{...r,method:"GET",searchParams:[...this._transport.limitQuery(e)]})}};var L=class{constructor(t){this._transport=t}send({body:t,request:e={}}){return this._transport.send("v1/boilerplate-categories",{...e,method:"POST",json:t})}};var w=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/boilerplate-categories/"+encodeURIComponent(t),{...e,method:"GET"})}};var U=class{constructor(t){this._transport=t}send({limit:t,include:e,request:r={}}={}){return this._transport.send("v1/boilerplate-categories",{...r,method:"GET",searchParams:[...this._transport.limitQuery(t),...this._transport.includeQuery(e)]})}};var q=class{constructor(t){this._transport=t}send(t,{body:e,request:r={}}){return this._transport.send("v1/boilerplate-categories/"+encodeURIComponent(t),{...r,method:"PATCH",json:e})}};var I=class{constructor(t){this._transport=t}get api(){return{get:new w(this._transport),list:new U(this._transport),create:new L(this._transport),update:new q(this._transport),boilerplate:{list:new S(this._transport)}}}};var A=class{constructor(t){this._transport=t}send({body:t,request:e={}}){return this._transport.send("v1/boilerplates",{...e,method:"POST",json:t})}};var E=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/boilerplates/"+encodeURIComponent(t),{...e,method:"GET"})}};var G=class{constructor(t){this._transport=t}send({limit:t,query:e,request:r={}}={}){return this._transport.send("v1/boilerplates",{...r,method:"GET",searchParams:[...this._transport.limitQuery(t),...this._transport.queryQuery(e)]})}};var P=class{constructor(t){this._transport=t}send(t,{body:e,request:r={}}){return this._transport.send("v1/boilerplates/"+encodeURIComponent(t),{...r,method:"PATCH",json:e})}};var N=class{constructor(t){this._transport=t}get api(){return{get:new E(this._transport),list:new G(this._transport),update:new P(this._transport),create:new A(this._transport)}}};var B=class{constructor(t){this._transport=t}send({body:t,request:e={}}){return this._transport.send("v1/channels",{...e,method:"POST",json:t})}};var M=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/channels/"+encodeURIComponent(t),{...e,method:"GET"})}};var j=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 Zt=require("zod"),H=class o{constructor(t){this._transport=t}static SCHEMA=Zt.z.object({overwrite:Zt.z.boolean().optional()});send(t,{body:e,request:r={}}){return this._transport.send("v1/sources/twilio-sendgrid/channels/"+encodeURIComponent(t)+"/sync",{...r,method:"POST",json:o.SCHEMA.parse(e)})}};var k=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 D=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 K=class{constructor(t){this._transport=t}send(t,{limit:e,request:r={}}={}){return this._transport.send("v1/channels/"+encodeURIComponent(t)+"/messages",{...r,method:"GET",searchParams:[...this._transport.limitQuery(e)]})}};var Q=class{constructor(t){this._transport=t}get api(){return{get:new M(this._transport),list:new j(this._transport),update:new k(this._transport),create:new B(this._transport),compositionSection:{list:new D(this._transport)},message:{list:new K(this._transport)},twilioSendgrid:{sync:new H(this._transport)}}}};var V=class{constructor(t){this._transport=t}send({body:t,request:e={}}){return this._transport.send("v1/composition-sections",{...e,method:"POST",json:t})}};var W=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/composition-sections/"+encodeURIComponent(t),{...e,method:"GET"})}};var Y=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 z=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 $=class{constructor(t){this._transport=t}get api(){return{get:new W(this._transport),list:new Y(this._transport),create:new V(this._transport),update:new z(this._transport)}}};var J=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 X=class{constructor(t){this._transport=t}send({body:t,request:e={}}){return this._transport.send("v1/contacts",{...e,method:"POST",json:t})}};var Z=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 tt=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 et=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 ot=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 rt=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 nt=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 st=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/contacts/"+encodeURIComponent(t)+"/notes",{...e,method:"GET"})}};var it=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 at=class{constructor(t){this._transport=t}get api(){return{get:new Z(this._transport),list:new tt(this._transport),update:new et(this._transport),create:new X(this._transport),conversation:{list:new ot(this._transport)},label:{list:new rt(this._transport)},note:{list:new st(this._transport),create:new nt(this._transport)},notificationSubscription:{create:new it(this._transport)},vcf:{get:new J(this._transport)}}}};var pt=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 ct=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 lt=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 dt=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 ut=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 h=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 mt=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/conversations/"+encodeURIComponent(t)+"/notes",{...e,method:"GET"})}};var ht=class{constructor(t){this._transport=t}get api(){return{get:new pt(this._transport),list:new ct(this._transport),update:new lt(this._transport),create:new h(this._transport),label:{list:new dt(this._transport)},message:{list:new ut(this._transport)},note:{list:new mt(this._transport),create:new h(this._transport)}}}};var ft=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 Ct=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 gt=class{constructor(t){this._transport=t}send({body:t,request:e={}}){return this._transport.send("v1/labels",{...e,method:"POST",json:t})}};var bt=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/labels/"+encodeURIComponent(t),{...e,method:"DELETE"})}};var _t=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/labels/"+encodeURIComponent(t),{...e,method:"GET"})}};var xt=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 yt=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 Rt=class{constructor(t){this._transport=t}get api(){return{create:new gt(this._transport),get:new _t(this._transport),list:new xt(this._transport),update:new yt(this._transport),delete:new bt(this._transport),contact:{list:new ft(this._transport)},conversation:{list:new Ct(this._transport)}}}};var Tt=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 vt=class{constructor(t){this._transport=t}get api(){return{list:new Tt(this._transport)}}};var Ot=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 Ft=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/models/"+encodeURIComponent(t),{...e,method:"GET"})}};var St=class{constructor(t){this._transport=t}send({request:t={}}={}){return this._transport.send("v1/models",{...t,method:"GET"})}};var Lt=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 wt=class{constructor(t){this._transport=t}get api(){return{get:new Ft(this._transport),list:new St(this._transport),response:{create:new Lt(this._transport)},correction:{create:new Ot(this._transport)}}}};var Ut=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/notes/"+encodeURIComponent(t),{...e,method:"GET"})}};var qt=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 It=class{constructor(t){this._transport=t}get api(){return{get:new Ut(this._transport),update:new qt(this._transport)}}};var At=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/sources/"+encodeURIComponent(t),{...e,method:"GET"})}};var Et=class{constructor(t){this._transport=t}send({category:t,request:e={}}={}){let r=[];if(t){let s=Array.isArray(t)?t:[t];for(let a of s)r.push(["category",a])}return this._transport.send("v1/sources",{...e,method:"GET",searchParams:r})}};var Gt=class{constructor(t){this._transport=t}get api(){return{get:new At(this._transport),list:new Et(this._transport)}}};var Pt=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/channel/"+encodeURIComponent(t)+"/statistics/message-frequency",{...e,method:"GET"})}};var Nt=class{constructor(t){this._transport=t}send({request:t={}}={}){return this._transport.send("v1/statistics/message-frequency",{...t,method:"GET"})}};var Bt=class{constructor(t){this._transport=t}get api(){return{messageFrequency:new Nt(this._transport),channelMessageFrequency:new Pt(this._transport)}}};var Mt=class{constructor(t){this._transport=t}send({account:t,files:e,request:r={}}){let s=new FormData;for(let a of e)s.append("file",a);return this._transport.send("v1/uploads",{...r,method:"POST",body:s,searchParams:{account:t}})}};var jt=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/uploads/"+encodeURIComponent(t),{...e,method:"DELETE"})}};var Ht=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/uploads/"+encodeURIComponent(t),{...e,method:"GET"})}};var kt=class{constructor(t){this._transport=t}get api(){return{get:new Ht(this._transport),create:new Mt(this._transport),delete:new jt(this._transport)}}};var Dt=class{constructor(t){this._transport=t}send({request:t={}}={}){return this._transport.send(".well-known/notifications",{...t,method:"GET"})}};var Kt=class{constructor(t){this._transport=t}get api(){return{notification:{get:new Dt(this._transport)}}}};var f=class o{static DEFAULT_BASE_URL=$t;_transport;_account;_accountConversationSettings;_action;_boilerplate;_boilerplateCategory;_channel;_compositionSection;_contact;_conversation;_label;_message;_model;_note;_source;_statistics;_upload;_webhook;_wellKnown;constructor(t,{baseURL:e,...r}={}){this._transport=new g({requestFilterables:[new C,t],...r,baseURL:e?.toString()??o.getBaseURL()}),this._account=new y(this._transport),this._accountConversationSettings=new v(this._transport),this._action=new F(this._transport),this._boilerplate=new N(this._transport),this._boilerplateCategory=new I(this._transport),this._channel=new Q(this._transport),this._compositionSection=new $(this._transport),this._contact=new at(this._transport),this._conversation=new ht(this._transport),this._label=new Rt(this._transport),this._message=new vt(this._transport),this._model=new wt(this._transport),this._note=new It(this._transport),this._source=new Gt(this._transport),this._statistics=new Bt(this._transport),this._upload=new kt(this._transport),this._webhook=new b(this),this._wellKnown=new Kt(this._transport)}static getBaseURL(){return process.env[ce]??this.DEFAULT_BASE_URL}get account(){return this._account.api}get accountConversationSettings(){return this._accountConversationSettings.api}get action(){return this._action.api}get boilerplate(){return this._boilerplate.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 te={};ee(te,{AuthError:()=>c,AuthenticationError:()=>d,AuthorizationError:()=>u,LogicError:()=>p,NetworkError:()=>m,SupportError:()=>i,ValidationError:()=>l});var Qt=class o{static DEFAULT_NAME=se;name;#t;constructor({name:t=process.env[pe]??o.DEFAULT_NAME,key:e=process.env[ae]}={}){if(!e)throw new Error("API Key option must be specified when using Key Authentication");this.name=t,this.#t=e}async filter(){return{headers:this.getHeaders()}}getHeaders(){return{Authorization:`Basic ${btoa(this.name+":"+this.#t)}`}}};var Vt=class{#t;constructor({token:t=process.env[ie]}={}){if(!t)throw new Error("Access Token option must be specified when using Token Authentication");this.#t=t}async filter(){return{headers:this.getHeaders()}}getHeaders(){return{Authorization:`Bearer ${this.#t}`}}};var Wt=class{async filter(){return{headers:this.getHeaders()}}getHeaders(){return{}}};0&&(module.exports={Client,DEFAULT_SUPPORT_BASE_URL,Error,KeyAuthentication,PublicAuthentication,TokenAuthentication});
package/dist/index.d.cts CHANGED
@@ -1,5 +1,5 @@
1
- import { A as Authentication, a as Account, b as Conversation } from './index-DvZLYvUd.cjs';
2
- export { d as AccountConversationSettings, g as Action, B as Boilerplate, m as BoilerplateCategory, r as Channel, C as Client, w as CompositionSection, F as Contact, n as CreateBoilerplateCategoryResponse, h as CreateBoilerplateResponse, v as CreateChannelResponse, z as CreateCompositionSectionResponse, ad as CreateContactNoteResponse, an as CreateContactNotificationSubscriptionResponse, H as CreateContactResponse, ae as CreateConversationNoteResponse, aa as CreateCorrectionResponse, Y as CreateLabelResponse, ab as CreateResponseResponse, ap as CreateUploadResponse, Z as DeleteLabelResponse, ar as DeleteUploadResponse, e as GetAccountConversationSettingsResponse, G as GetAccountResponse, o as GetBoilerplateCategoryResponse, j as GetBoilerplateResponse, t as GetChannelResponse, x as GetCompositionSectionResponse, I as GetContactResponse, N as GetConversationResponse, _ as GetLabelResponse, a8 as GetModelResponse, af as GetNoteResponse, as as GetNotificationWellKnownResponse, ak as GetSourceResponse, aq as GetUploadResponse, X as Label, L as ListActionsResponse, p as ListBoilerplateCategoriesResponse, i as ListBoilerplateCategoryBoilerplatesResponse, k as ListBoilerplatesResponse, D as ListChannelCompositionSectionsResponse, a6 as ListChannelMessagesResponse, s as ListChannelsResponse, y as ListCompositionSectionsResponse, V as ListContactConversationsResponse, a2 as ListContactLabelsResponse, ag as ListContactNotesResponse, J as ListContactsResponse, a1 as ListConversationLabelsResponse, a4 as ListConversationMessagesResponse, ah as ListConversationNotesResponse, P as ListConversationsResponse, K as ListLabelContactsResponse, Q as ListLabelConversationsResponse, $ as ListLabelsResponse, a5 as ListMessagesResponse, a9 as ListModelsResponse, al as ListSourcesResponse, a3 as Message, a7 as Model, ac as Note, am as NotificationSubscription, O as Options, R as RequestFilterable, aj as Source, c as TransportOptions, T as TwilioSendgridChannelSyncResponse, f as UpdateAccountConversationSettingsResponse, U as UpdateAccountResponse, q as UpdateBoilerplateCategoryResponse, l as UpdateBoilerplateResponse, u as UpdateChannelResponse, E as UpdateCompositionSectionResponse, M as UpdateContactResponse, S as UpdateConversationResponse, a0 as UpdateLabelResponse, ai as UpdateNoteResponse, ao as Upload, W as WebhookResponse, C as default } from './index-DvZLYvUd.cjs';
1
+ import { A as Authentication, a as Account, b as Conversation } from './index-iJIOONbG.cjs';
2
+ export { d as AccountConversationSettings, g as Action, B as Boilerplate, m as BoilerplateCategory, r as Channel, C as Client, w as CompositionSection, F as Contact, n as CreateBoilerplateCategoryResponse, h as CreateBoilerplateResponse, v as CreateChannelResponse, z as CreateCompositionSectionResponse, ad as CreateContactNoteResponse, an as CreateContactNotificationSubscriptionResponse, H as CreateContactResponse, ae as CreateConversationNoteResponse, aa as CreateCorrectionResponse, Y as CreateLabelResponse, ab as CreateResponseResponse, ap as CreateUploadResponse, Z as DeleteLabelResponse, ar as DeleteUploadResponse, e as GetAccountConversationSettingsResponse, G as GetAccountResponse, o as GetBoilerplateCategoryResponse, j as GetBoilerplateResponse, t as GetChannelResponse, x as GetCompositionSectionResponse, I as GetContactResponse, N as GetConversationResponse, _ as GetLabelResponse, a8 as GetModelResponse, af as GetNoteResponse, as as GetNotificationWellKnownResponse, ak as GetSourceResponse, aq as GetUploadResponse, X as Label, L as ListActionsResponse, p as ListBoilerplateCategoriesResponse, i as ListBoilerplateCategoryBoilerplatesResponse, k as ListBoilerplatesResponse, D as ListChannelCompositionSectionsResponse, a6 as ListChannelMessagesResponse, s as ListChannelsResponse, y as ListCompositionSectionsResponse, V as ListContactConversationsResponse, a2 as ListContactLabelsResponse, ag as ListContactNotesResponse, J as ListContactsResponse, a1 as ListConversationLabelsResponse, a4 as ListConversationMessagesResponse, ah as ListConversationNotesResponse, P as ListConversationsResponse, K as ListLabelContactsResponse, Q as ListLabelConversationsResponse, $ as ListLabelsResponse, a5 as ListMessagesResponse, a9 as ListModelsResponse, al as ListSourcesResponse, a3 as Message, a7 as Model, ac as Note, am as NotificationSubscription, O as Options, R as RequestFilterable, aj as Source, c as TransportOptions, T as TwilioSendgridChannelSyncResponse, f as UpdateAccountConversationSettingsResponse, U as UpdateAccountResponse, q as UpdateBoilerplateCategoryResponse, l as UpdateBoilerplateResponse, u as UpdateChannelResponse, E as UpdateCompositionSectionResponse, M as UpdateContactResponse, S as UpdateConversationResponse, a0 as UpdateLabelResponse, ai as UpdateNoteResponse, ao as Upload, W as WebhookResponse, C as default } from './index-iJIOONbG.cjs';
3
3
  import 'ky';
4
4
  import 'zod';
5
5
 
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { A as Authentication, a as Account, b as Conversation } from './index-DvZLYvUd.js';
2
- export { d as AccountConversationSettings, g as Action, B as Boilerplate, m as BoilerplateCategory, r as Channel, C as Client, w as CompositionSection, F as Contact, n as CreateBoilerplateCategoryResponse, h as CreateBoilerplateResponse, v as CreateChannelResponse, z as CreateCompositionSectionResponse, ad as CreateContactNoteResponse, an as CreateContactNotificationSubscriptionResponse, H as CreateContactResponse, ae as CreateConversationNoteResponse, aa as CreateCorrectionResponse, Y as CreateLabelResponse, ab as CreateResponseResponse, ap as CreateUploadResponse, Z as DeleteLabelResponse, ar as DeleteUploadResponse, e as GetAccountConversationSettingsResponse, G as GetAccountResponse, o as GetBoilerplateCategoryResponse, j as GetBoilerplateResponse, t as GetChannelResponse, x as GetCompositionSectionResponse, I as GetContactResponse, N as GetConversationResponse, _ as GetLabelResponse, a8 as GetModelResponse, af as GetNoteResponse, as as GetNotificationWellKnownResponse, ak as GetSourceResponse, aq as GetUploadResponse, X as Label, L as ListActionsResponse, p as ListBoilerplateCategoriesResponse, i as ListBoilerplateCategoryBoilerplatesResponse, k as ListBoilerplatesResponse, D as ListChannelCompositionSectionsResponse, a6 as ListChannelMessagesResponse, s as ListChannelsResponse, y as ListCompositionSectionsResponse, V as ListContactConversationsResponse, a2 as ListContactLabelsResponse, ag as ListContactNotesResponse, J as ListContactsResponse, a1 as ListConversationLabelsResponse, a4 as ListConversationMessagesResponse, ah as ListConversationNotesResponse, P as ListConversationsResponse, K as ListLabelContactsResponse, Q as ListLabelConversationsResponse, $ as ListLabelsResponse, a5 as ListMessagesResponse, a9 as ListModelsResponse, al as ListSourcesResponse, a3 as Message, a7 as Model, ac as Note, am as NotificationSubscription, O as Options, R as RequestFilterable, aj as Source, c as TransportOptions, T as TwilioSendgridChannelSyncResponse, f as UpdateAccountConversationSettingsResponse, U as UpdateAccountResponse, q as UpdateBoilerplateCategoryResponse, l as UpdateBoilerplateResponse, u as UpdateChannelResponse, E as UpdateCompositionSectionResponse, M as UpdateContactResponse, S as UpdateConversationResponse, a0 as UpdateLabelResponse, ai as UpdateNoteResponse, ao as Upload, W as WebhookResponse, C as default } from './index-DvZLYvUd.js';
1
+ import { A as Authentication, a as Account, b as Conversation } from './index-iJIOONbG.js';
2
+ export { d as AccountConversationSettings, g as Action, B as Boilerplate, m as BoilerplateCategory, r as Channel, C as Client, w as CompositionSection, F as Contact, n as CreateBoilerplateCategoryResponse, h as CreateBoilerplateResponse, v as CreateChannelResponse, z as CreateCompositionSectionResponse, ad as CreateContactNoteResponse, an as CreateContactNotificationSubscriptionResponse, H as CreateContactResponse, ae as CreateConversationNoteResponse, aa as CreateCorrectionResponse, Y as CreateLabelResponse, ab as CreateResponseResponse, ap as CreateUploadResponse, Z as DeleteLabelResponse, ar as DeleteUploadResponse, e as GetAccountConversationSettingsResponse, G as GetAccountResponse, o as GetBoilerplateCategoryResponse, j as GetBoilerplateResponse, t as GetChannelResponse, x as GetCompositionSectionResponse, I as GetContactResponse, N as GetConversationResponse, _ as GetLabelResponse, a8 as GetModelResponse, af as GetNoteResponse, as as GetNotificationWellKnownResponse, ak as GetSourceResponse, aq as GetUploadResponse, X as Label, L as ListActionsResponse, p as ListBoilerplateCategoriesResponse, i as ListBoilerplateCategoryBoilerplatesResponse, k as ListBoilerplatesResponse, D as ListChannelCompositionSectionsResponse, a6 as ListChannelMessagesResponse, s as ListChannelsResponse, y as ListCompositionSectionsResponse, V as ListContactConversationsResponse, a2 as ListContactLabelsResponse, ag as ListContactNotesResponse, J as ListContactsResponse, a1 as ListConversationLabelsResponse, a4 as ListConversationMessagesResponse, ah as ListConversationNotesResponse, P as ListConversationsResponse, K as ListLabelContactsResponse, Q as ListLabelConversationsResponse, $ as ListLabelsResponse, a5 as ListMessagesResponse, a9 as ListModelsResponse, al as ListSourcesResponse, a3 as Message, a7 as Model, ac as Note, am as NotificationSubscription, O as Options, R as RequestFilterable, aj as Source, c as TransportOptions, T as TwilioSendgridChannelSyncResponse, f as UpdateAccountConversationSettingsResponse, U as UpdateAccountResponse, q as UpdateBoilerplateCategoryResponse, l as UpdateBoilerplateResponse, u as UpdateChannelResponse, E as UpdateCompositionSectionResponse, M as UpdateContactResponse, S as UpdateConversationResponse, a0 as UpdateLabelResponse, ai as UpdateNoteResponse, ao as Upload, W as WebhookResponse, C as default } from './index-iJIOONbG.js';
3
3
  import 'ky';
4
4
  import 'zod';
5
5
 
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- import{a as d,b as g,c as p,d as s,e as n,f as _,g as a,h as f,i as m,j as u,k as x,l as c,m as l,n as h,o as A}from"./chunk-5AQYHVY3.js";var E={};d(E,{AuthError:()=>m,AuthenticationError:()=>u,AuthorizationError:()=>x,LogicError:()=>c,NetworkError:()=>l,SupportError:()=>f,ValidationError:()=>h});var t=class e{static DEFAULT_NAME=a;name;#r;constructor({name:r=process.env[n]??e.DEFAULT_NAME,key:i=process.env[s]}={}){if(!i)throw new Error("API Key option must be specified when using Key Authentication");this.name=r,this.#r=i}async filter(){return{headers:this.getHeaders()}}getHeaders(){return{Authorization:`Basic ${btoa(this.name+":"+this.#r)}`}}};var o=class{#r;constructor({token:r=process.env[p]}={}){if(!r)throw new Error("Access Token option must be specified when using Token Authentication");this.#r=r}async filter(){return{headers:this.getHeaders()}}getHeaders(){return{Authorization:`Bearer ${this.#r}`}}};export{A as Client,_ as DEFAULT_SUPPORT_BASE_URL,E as Error,t as KeyAuthentication,g as PublicAuthentication,o as TokenAuthentication,A as default};
1
+ import{a as d,b as g,c as p,d as s,e as n,f as _,g as a,h as f,i as m,j as u,k as x,l as c,m as l,n as h,o as A}from"./chunk-XNWCAGZ7.js";var E={};d(E,{AuthError:()=>m,AuthenticationError:()=>u,AuthorizationError:()=>x,LogicError:()=>c,NetworkError:()=>l,SupportError:()=>f,ValidationError:()=>h});var t=class e{static DEFAULT_NAME=a;name;#r;constructor({name:r=process.env[n]??e.DEFAULT_NAME,key:i=process.env[s]}={}){if(!i)throw new Error("API Key option must be specified when using Key Authentication");this.name=r,this.#r=i}async filter(){return{headers:this.getHeaders()}}getHeaders(){return{Authorization:`Basic ${btoa(this.name+":"+this.#r)}`}}};var o=class{#r;constructor({token:r=process.env[p]}={}){if(!r)throw new Error("Access Token option must be specified when using Token Authentication");this.#r=r}async filter(){return{headers:this.getHeaders()}}getHeaders(){return{Authorization:`Bearer ${this.#r}`}}};export{A as Client,_ as DEFAULT_SUPPORT_BASE_URL,E as Error,t as KeyAuthentication,g as PublicAuthentication,o as TokenAuthentication,A as default};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@great-detail/support-sdk",
3
- "version": "0.11.1",
3
+ "version": "0.11.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>",