@great-detail/support-sdk 0.11.10 → 0.12.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunk-EWJFCLFP.js +1 -0
- package/dist/{chunk-65VQXM5W.js → chunk-HB5Z3WZ2.js} +1 -1
- package/dist/cli/index.cjs +1 -1
- package/dist/cli/index.d.cts +1 -1
- package/dist/cli/index.d.ts +1 -1
- package/dist/cli/index.js +1 -1
- package/dist/cli.cjs +1 -1
- package/dist/cli.js +1 -1
- package/dist/{index-CtjpXFM-.d.cts → index-BzXDUbd-.d.cts} +55 -1
- package/dist/{index-CtjpXFM-.d.ts → index-BzXDUbd-.d.ts} +55 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-EEGHBL4C.js +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var ee=Object.defineProperty;var se=(o,t)=>{for(var e in t)ee(o,e,{get:t[e],enumerable:!0})};var Wt=class{async filter(){return{headers:this.getHeaders()}}getHeaders(){return{}}};var Jt="https://api.support.greatdetail.com",$t={"X-Powered-By":"GDSupport/JavaScript"},ae="api-key";import{z as n}from"zod";var de="SUPPORT_ACCESS_TOKEN",le="SUPPORT_API_KEY",ue="SUPPORT_KEY_NAME",Yt="SUPPORT_SIGNING_KEY",Xt="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[Yt],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."+Yt);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=$t;async filter(){return{headers:this.getHeaders()}}getHeaders(){return this._standardHeaders}};import oe from"is-network-error";import re,{HTTPError as ne}from"ky";var p=class extends Error{static serverError(t){return new this("Server Error: "+t)}};var c=class extends p{};var h=class extends c{static unauthenticated(){return new this("An unauthenticated request occurred")}};var f=class extends c{static forbidden(){return new this("A forbidden request occurred")}};var a=class extends p{static notFound(t){return new this(`Record not found for request: ${t}`)}static forbiddenMethod(t,e){return new this(`Forbidden method for request: ${t} ${e}`)}static teapot(){return new this("I'm a teapot")}static rateLimited(){return new this("Request has been rate-limited")}};var C=class extends p{};var d=class extends p{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=re.create({prefixUrl:this.options.baseURL,timeout:12e3,hooks:{beforeRequest:[r=>{for(let s of this.options.requestFilterables){let i=s.getHeaders();for(let[Vt,te]of Object.entries(i))r.headers.has(Vt)||r.headers.set(Vt,te)}}]}})}getURL(t){return new URL(t,this.options.baseURL).toString()}sortQuery(t){let e=[];if(t===void 0)return e;for(let[r,s]of Object.entries(t))s!==void 0&&e.push(["sort",s+r]);return e}limitQuery(t){let e=[];return t===void 0||e.push(["limit",t.toString()]),e}includeQuery(t){let e=[];if(t===void 0)return e;for(let r of Object.keys(t))e.push(["include",r]);return e}queryQuery(t){let e=[];return t===void 0||e.push(["query",t]),e}send(t,e={}){let r=this.client(t,e).catch(s=>{if(oe(s))throw new C("A network error occurred",{cause:s});if(s instanceof ne){let i=s.response.status;switch(console.error(JSON.stringify(s.response)),i){case 400:throw d.badRequest();case 401:throw h.unauthenticated();case 403:throw f.forbidden();case 404:throw a.notFound(t);case 405:throw a.forbiddenMethod(t,e.method??"GET");case 415:throw d.unsupportedMediaType();case 418:throw a.teapot();case 429:throw a.rateLimited()}if(i>=500&&i<600)throw p.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)+"/access-tokens",{...e,method:"GET"})}};var _=class{constructor(t){this._transport=t}get api(){return{list:new b(this._transport)}}};var O=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 x=class{constructor(t){this._transport=t}get api(){return{get:new O(this._transport),update:new y(this._transport)}}};var S=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 R=class{constructor(t){this._transport=t}get api(){return{get:new S(this._transport),update:new T(this._transport)}}};var v=class{constructor(t){this._transport=t}send({limit:t,sort:e,request:r={}}={}){return this._transport.send("v1/actions",{...r,method:"GET",searchParams:[...this._transport.limitQuery(t),...this._transport.sortQuery(e)]})}};var F=class{constructor(t){this._transport=t}get api(){return{list:new v(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 w=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 A=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 E=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 G=class{constructor(t){this._transport=t}get api(){return{get:new U(this._transport),list:new A(this._transport),create:new w(this._transport),update:new E(this._transport),boilerplate:{list:new L(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 P=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/boilerplates/"+encodeURIComponent(t),{...e,method:"GET"})}};var I=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 I(this._transport),update:new N(this._transport),create:new q(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 Q=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)]})}};import{z as Zt}from"zod";var k=class o{constructor(t){this._transport=t}static SCHEMA=Zt.object({overwrite:Zt.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 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,include:r,request:s={}}={}){return this._transport.send("v1/channels/"+encodeURIComponent(t)+"/messages",{...s,method:"GET",searchParams:[...this._transport.limitQuery(e),...this._transport.includeQuery(r)]})}};var V=class{constructor(t){this._transport=t}get api(){return{get:new Q(this._transport),list:new j(this._transport),update:new H(this._transport),create:new M(this._transport),compositionSection:{list:new D(this._transport)},message:{list:new K(this._transport)},twilioSendgrid:{sync:new k(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",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 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 pt=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 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 pt(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 dt=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 ut=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 mt=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 l=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 dt(this._transport),update:new lt(this._transport),create:new l(this._transport),label:{list:new ut(this._transport)},message:{list:new mt(this._transport)},note:{list:new ht(this._transport),create:new l(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 _t=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/labels/"+encodeURIComponent(t),{...e,method:"DELETE"})}};var Ot=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: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 St=class{constructor(t){this._transport=t}get api(){return{create:new bt(this._transport),get:new Ot(this._transport),list:new yt(this._transport),update:new xt(this._transport),delete:new _t(this._transport),contact:{list:new Ct(this._transport)},conversation:{list:new gt(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 Rt=class{constructor(t){this._transport=t}get api(){return{list:new Tt(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 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 wt=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 wt(this._transport)},correction:{create:new vt(this._transport)}}}};var At=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/notes/"+encodeURIComponent(t),{...e,method:"GET"})}};var Et=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 Gt=class{constructor(t){this._transport=t}get api(){return{get:new At(this._transport),update:new Et(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 Pt=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 It=class{constructor(t){this._transport=t}get api(){return{get:new qt(this._transport),list:new Pt(this._transport)}}};var Nt=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/channels/"+encodeURIComponent(t)+"/statistics/message-frequency",{...e,method:"GET"})}};var 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 Qt=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 jt=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/uploads/"+encodeURIComponent(t),{...e,method:"DELETE"})}};var kt=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 kt(this._transport),create:new Qt(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 zt=class o{static DEFAULT_BASE_URL=Jt;_transport;_account;_accountAccessToken;_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 x(this._transport),this._accountAccessToken=new _(this._transport),this._accountConversationSettings=new R(this._transport),this._action=new F(this._transport),this._boilerplate=new B(this._transport),this._boilerplateCategory=new G(this._transport),this._channel=new V(this._transport),this._compositionSection=new $(this._transport),this._contact=new at(this._transport),this._conversation=new ft(this._transport),this._label=new St(this._transport),this._message=new Rt(this._transport),this._model=new Ut(this._transport),this._note=new Gt(this._transport),this._source=new It(this._transport),this._statistics=new Mt(this._transport),this._upload=new Ht(this._transport),this._webhook=new u(this),this._wellKnown=new Kt(this._transport)}static getBaseURL(){return process.env[Xt]??this.DEFAULT_BASE_URL}get account(){return this._account.api}get accountAccessToken(){return this._accountAccessToken.api}get accountConversationSettings(){return this._accountConversationSettings.api}get action(){return this._action.api}get boilerplate(){return this._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{se as a,Wt as b,de as c,le as d,ue as e,Jt as f,ae as g,p as h,c as i,h as j,f as k,a as l,C as m,d as n,zt as o};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as v,o as b}from"./chunk-
|
|
1
|
+
import{b as v,o as b}from"./chunk-EWJFCLFP.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};
|
package/dist/cli/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var Ie=Object.create;var Jt=Object.defineProperty;var qe=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})},_e=(o,t,e,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of Ne(t))!Me.call(o,r)&&r!==e&&Jt(o,r,{get:()=>t[r],enumerable:!(n=qe(t,r))||n.enumerable});return o};var Se=(o,t,e)=>(e=o!=null?Ie(Be(o)):{},_e(t||!o||!o.__esModule?Jt(e,"default",{value:o,enumerable:!0}):e,o)),De=o=>_e(Jt({},"__esModule",{value:!0}),o);var Ke={};je(Ke,{default:()=>He});module.exports=De(Ke);var Ge=require("commander");var u=class{async filter(){return{headers:this.getHeaders()}}getHeaders(){return{}}};var ne="SUPPORT_SIGNING_KEY",Te="SUPPORT_BASE_URL";var ve="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 we=Se(require("is-network-error"),1),$t=Se(require("ky"),1);var a=class extends Error{static serverError(t){return new this("Server Error: "+t)}};var d=class extends a{};var f=class extends d{static unauthenticated(){return new this("An unauthenticated request occurred")}};var C=class extends d{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 l=class extends a{static badRequest(){return new this("Bad request")}static unsupportedMediaType(){return new this("Unsupported Media Type")}};var O=class{client;options;constructor({baseURL:t,...e}){this.options={...e,baseURL:t},this.client=$t.default.create({prefixUrl:this.options.baseURL,timeout:12e3,hooks:{beforeRequest:[n=>{for(let r of this.options.requestFilterables){let i=r.getHeaders();for(let[zt,Pe]of Object.entries(i))n.headers.has(zt)||n.headers.set(zt,Pe)}}]}})}getURL(t){return new URL(t,this.options.baseURL).toString()}sortQuery(t){let e=[];if(t===void 0)return e;for(let[n,r]of Object.entries(t))r!==void 0&&e.push(["sort",r+n]);return e}limitQuery(t){let e=[];return t===void 0||e.push(["limit",t.toString()]),e}includeQuery(t){let e=[];if(t===void 0)return e;for(let n of Object.keys(t))e.push(["include",n]);return e}queryQuery(t){let e=[];return t===void 0||e.push(["query",t]),e}send(t,e={}){let n=this.client(t,e).catch(r=>{if((0,we.default)(r))throw new g("A network error occurred",{cause:r});if(r instanceof $t.HTTPError){let i=r.response.status;switch(console.error(JSON.stringify(r.response)),i){case 400:throw l.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 l.unsupportedMediaType();case 418:throw c.teapot();case 429:throw c.rateLimited()}if(i>=500&&i<600)throw a.serverError(i)}throw r});return{response:()=>n,json:async()=>(await n).json()}}};var s=require("zod");var b=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[ne],maxSignatures:e=3,request:n}){let r=n.headers["gds-signature"];if(t!==!1){if(t===void 0)throw new Error("Missing webhook signing key in process.env."+ne);if(!r)throw new Error("Missing signature header");if(!this._verifySignature(t,n.body,Array.isArray(r)?r.slice(0,e):[r]))throw new Error("Untrusted signature")}let{data:i}=o.SCHEMA.parse(n.body);return{event:i.event}}async _verifySignature(t,e,n){let r=await crypto.subtle.importKey("raw",new TextEncoder().encode(t),{name:"HMAC",hash:"SHA-256"},!1,["sign","verify"]);for(let i of n)if(await crypto.subtle.verify("HMAC",r,new TextEncoder().encode(atob(i)),new TextEncoder().encode(JSON.stringify(e))))return!0;return!1}};var y=class{constructor(t){this._transport=t}send(t,{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:n={}}){return this._transport.send("v1/accounts/"+encodeURIComponent(t),{...n,method:"PATCH",json:e})}};var _=class{constructor(t){this._transport=t}get api(){return{get:new y(this._transport),update:new x(this._transport)}}};var S=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:n={}}){return this._transport.send("v1/accounts/"+encodeURIComponent(t)+"/conversation-settings",{...n,method:"PATCH",json:e})}};var v=class{constructor(t){this._transport=t}get api(){return{get:new S(this._transport),update:new T(this._transport)}}};var R=class{constructor(t){this._transport=t}send({limit:t,sort:e,request:n={}}={}){return this._transport.send("v1/actions",{...n,method:"GET",searchParams:[...this._transport.limitQuery(t),...this._transport.sortQuery(e)]})}};var w=class{constructor(t){this._transport=t}get api(){return{list:new R(this._transport)}}};var F=class{constructor(t){this._transport=t}send(t,{limit:e,request:n={}}={}){return this._transport.send("v1/boilerplate-categories/"+encodeURIComponent(t)+"/boilerplates",{...n,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 U=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/boilerplate-categories/"+encodeURIComponent(t),{...e,method:"GET"})}};var A=class{constructor(t){this._transport=t}send({limit:t,include:e,request:n={}}={}){return this._transport.send("v1/boilerplate-categories",{...n,method:"GET",searchParams:[...this._transport.limitQuery(t),...this._transport.includeQuery(e)]})}};var E=class{constructor(t){this._transport=t}send(t,{body:e,request:n={}}){return this._transport.send("v1/boilerplate-categories/"+encodeURIComponent(t),{...n,method:"PATCH",json:e})}};var G=class{constructor(t){this._transport=t}get api(){return{get:new U(this._transport),list:new A(this._transport),create:new L(this._transport),update:new E(this._transport),boilerplate:{list:new F(this._transport)}}}};var P=class{constructor(t){this._transport=t}send({body:t,request:e={}}){return this._transport.send("v1/boilerplates",{...e,method:"POST",json:t})}};var I=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/boilerplates/"+encodeURIComponent(t),{...e,method:"GET"})}};var q=class{constructor(t){this._transport=t}send({limit:t,query:e,request:n={}}={}){return this._transport.send("v1/boilerplates",{...n,method:"GET",searchParams:[...this._transport.limitQuery(t),...this._transport.queryQuery(e)]})}};var N=class{constructor(t){this._transport=t}send(t,{body:e,request:n={}}){return this._transport.send("v1/boilerplates/"+encodeURIComponent(t),{...n,method:"PATCH",json:e})}};var B=class{constructor(t){this._transport=t}get api(){return{get:new I(this._transport),list:new q(this._transport),update:new N(this._transport),create:new P(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"),Q=class o{constructor(t){this._transport=t}static SCHEMA=re.z.object({overwrite:re.z.boolean().optional()});send(t,{body:e,request:n={}}){return this._transport.send("v1/sources/twilio-sendgrid/channels/"+encodeURIComponent(t)+"/sync",{...n,method:"POST",json:o.SCHEMA.parse(e)})}};var H=class{constructor(t){this._transport=t}send(t,{body:e,request:n={}}){return this._transport.send("v1/channels/"+encodeURIComponent(t),{...n,method:"PATCH",json:e})}};var K=class{constructor(t){this._transport=t}send(t,{limit:e,request:n={}}={}){return this._transport.send("v1/channels/"+encodeURIComponent(t)+"/composition-sections",{...n,method:"GET",searchParams:[...this._transport.limitQuery(e)]})}};var k=class{constructor(t){this._transport=t}send(t,{limit:e,include:n,request:r={}}={}){return this._transport.send("v1/channels/"+encodeURIComponent(t)+"/messages",{...r,method:"GET",searchParams:[...this._transport.limitQuery(e),...this._transport.includeQuery(n)]})}};var V=class{constructor(t){this._transport=t}get api(){return{get:new j(this._transport),list:new D(this._transport),update:new H(this._transport),create:new M(this._transport),compositionSection:{list:new K(this._transport)},message:{list:new k(this._transport)},twilioSendgrid:{sync:new Q(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:n={}}){return this._transport.send("v1/composition-sections/"+encodeURIComponent(t),{...n,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 n=e.variant??"vcard",r=e.format??(n==="vcard"?"vcf":"json");return"v1/contacts/"+encodeURIComponent(t)+"/vcf?variant="+encodeURIComponent(n)+"&format="+encodeURIComponent(r)}getURL(t){return this._transport.getURL(this.getRelativeURL(t))}send(t){return this._transport.send(this.getURL(t),{method:"GET"})}};var 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:n={}}={}){return this._transport.send("v1/contacts/"+encodeURIComponent(t),{...n,method:"GET",searchParams:[...this._transport.includeQuery(e??{})]})}};var et=class{constructor(t){this._transport=t}send({limit:t,query:e,request:n={}}={}){return this._transport.send("v1/contacts",{...n,method:"GET",searchParams:[...this._transport.limitQuery(t),...this._transport.queryQuery(e)]})}};var ot=class{constructor(t){this._transport=t}send(t,{body:e,request:n={}}){return this._transport.send("v1/contacts/"+encodeURIComponent(t),{...n,method:"PATCH",json:e})}};var nt=class{constructor(t){this._transport=t}send(t,{limit:e,request:n={}}={}){return this._transport.send("v1/contacts/"+encodeURIComponent(t)+"/conversations",{...n,method:"GET",searchParams:[...this._transport.limitQuery(e)]})}};var rt=class{constructor(t){this._transport=t}send(t,{limit:e,request:n={}}={}){return this._transport.send("v1/contacts/"+encodeURIComponent(t)+"/labels",{...n,method:"GET",searchParams:[...this._transport.limitQuery(e)]})}};var st=class{constructor(t){this._transport=t}send(t,{body:e,request:n={}}){return this._transport.send("v1/contacts/"+encodeURIComponent(t)+"/notes",{...n,method:"POST",json:e})}};var 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:n={}}){return this._transport.send("v1/contacts/"+encodeURIComponent(t)+"/notification-subscriptions",{...n,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 nt(this._transport)},label:{list:new rt(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:n={}}={}){return this._transport.send("v1/conversations/"+encodeURIComponent(t),{...n,method:"GET",searchParams:[...this._transport.includeQuery(e??{})]})}};var dt=class{constructor(t){this._transport=t}send({limit:t,filter:e,include:n,request:r={}}={}){return this._transport.send("v1/conversations",{...r,method:"GET",searchParams:[...this._transport.limitQuery(t),...e?[["filter",e]]:[],...this._transport.includeQuery(n??{})]})}};var lt=class{constructor(t){this._transport=t}send(t,{body:e,request:n={}}){return this._transport.send("v1/conversations/"+encodeURIComponent(t),{...n,method:"PATCH",json:e})}};var mt=class{constructor(t){this._transport=t}send(t,{limit:e,request:n={}}={}){return this._transport.send("v1/conversations/"+encodeURIComponent(t)+"/labels",{...n,method:"GET",searchParams:[...this._transport.limitQuery(e)]})}};var ut=class{constructor(t){this._transport=t}send(t,{limit:e,include:n,request:r={}}={}){return this._transport.send("v1/conversations/"+encodeURIComponent(t)+"/messages",{...r,method:"GET",searchParams:[...this._transport.limitQuery(e),...this._transport.includeQuery(n??{})]})}};var m=class{constructor(t){this._transport=t}send(t,{body:e,request:n={}}){return this._transport.send("v1/conversations/"+encodeURIComponent(t)+"/notes",{...n,method:"POST",json:e})}};var 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 dt(this._transport),update:new lt(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:n={}}={}){return this._transport.send("v1/labels/"+encodeURIComponent(t)+"/contacts",{...n,method:"GET",searchParams:[...this._transport.limitQuery(e)]})}};var gt=class{constructor(t){this._transport=t}send(t,{limit:e,request:n={}}={}){return this._transport.send("v1/labels/"+encodeURIComponent(t)+"/conversations",{...n,method:"GET",searchParams:[...this._transport.limitQuery(e)]})}};var Ot=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 yt=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:n,request:r={}}={}){return this._transport.send("v1/labels",{...r,method:"GET",searchParams:[...this._transport.limitQuery(t),...this._transport.queryQuery(e),...this._transport.includeQuery(n??{})]})}};var _t=class{constructor(t){this._transport=t}send(t,{body:e,request:n={}}){return this._transport.send("v1/labels/"+encodeURIComponent(t),{...n,method:"PATCH",json:e})}};var St=class{constructor(t){this._transport=t}get api(){return{create:new Ot(this._transport),get:new yt(this._transport),list:new xt(this._transport),update:new _t(this._transport),delete:new bt(this._transport),contact:{list:new Ct(this._transport)},conversation:{list:new gt(this._transport)}}}};var Tt=class{constructor(t){this._transport=t}send({limit:t,include:e,request:n={}}={}){return this._transport.send("v1/messages",{...n,method:"GET",searchParams:[...this._transport.limitQuery(t),...this._transport.includeQuery(e??{})]})}};var vt=class{constructor(t){this._transport=t}get api(){return{list:new Tt(this._transport)}}};var Rt=class{constructor(t){this._transport=t}send(t,{body:e,request:n={}}){return this._transport.send("v1/models/"+encodeURIComponent(t)+"/correction",{...n,method:"POST",json:e})}};var wt=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:n={}}){return this._transport.send("v1/models/"+encodeURIComponent(t)+"/response",{...n,method:"POST",timeout:12e4,json:e})}};var Ut=class{constructor(t){this._transport=t}get api(){return{get:new wt(this._transport),list:new Ft(this._transport),response:{create:new Lt(this._transport)},correction:{create:new Rt(this._transport)}}}};var At=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/notes/"+encodeURIComponent(t),{...e,method:"GET"})}};var Et=class{constructor(t){this._transport=t}send(t,{body:e,request:n={}}){return this._transport.send("v1/notes/"+encodeURIComponent(t),{...n,method:"PATCH",json:e})}};var Gt=class{constructor(t){this._transport=t}get api(){return{get:new At(this._transport),update:new Et(this._transport)}}};var Pt=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/sources/"+encodeURIComponent(t),{...e,method:"GET"})}};var It=class{constructor(t){this._transport=t}send({category:t,request:e={}}={}){let n=[];if(t){let r=Array.isArray(t)?t:[t];for(let i of r)n.push(["category",i])}return this._transport.send("v1/sources",{...e,method:"GET",searchParams:n})}};var qt=class{constructor(t){this._transport=t}get api(){return{get:new Pt(this._transport),list:new It(this._transport)}}};var Nt=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/channels/"+encodeURIComponent(t)+"/statistics/message-frequency",{...e,method:"GET"})}};var 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:n={}}){let r=new FormData;for(let i of e)r.append("file",i);return this._transport.send("v1/uploads",{...n,method:"POST",body:r,searchParams:{account:t}})}};var Dt=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/uploads/"+encodeURIComponent(t),{...e,method:"DELETE"})}};var Qt=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 Qt(this._transport),create:new jt(this._transport),delete:new Dt(this._transport)}}};var Kt=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 Kt(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,...n}={}){this._transport=new O({requestFilterables:[new h,t],...n,baseURL:e?.toString()??o.getBaseURL()}),this._account=new _(this._transport),this._accountConversationSettings=new v(this._transport),this._action=new w(this._transport),this._boilerplate=new B(this._transport),this._boilerplateCategory=new G(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 St(this._transport),this._message=new vt(this._transport),this._model=new Ut(this._transport),this._note=new Gt(this._transport),this._source=new qt(this._transport),this._statistics=new Mt(this._transport),this._upload=new Ht(this._transport),this._webhook=new b(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 se=require("commander"),Fe=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 n=await(0,Fe.oraPromise)(()=>o.action.list.send().json(),{...t,text:"Finding actions"});console.log(n)})),e}var ae=require("commander"),Le=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 n=await(0,Le.oraPromise)(()=>o.channel.list.send().json(),{...t,text:"Finding channels"});console.log(n)})),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 n=>{let r=await(0,Xt.oraPromise)(()=>o.contact.get.send(n).json(),{...t,text:"Finding contact"});console.log(r)})),e.addCommand(new Wt.Command("list").description("List contacts").action(async()=>{let n=await(0,Xt.oraPromise)(()=>o.contact.list.send().json(),{...t,text:"Finding contacts"});console.log(n)})),e.addCommand(new Wt.Command("get-vcf").description("Export Contact as VCF").argument("<contact>","Contact ID").action(async n=>{let r=await(0,Xt.oraPromise)(()=>o.contact.vcf.get.send({id:n}).response(),{...t,text:"Exporting contact"});console.log(r)})),e}var Zt=require("commander"),de=require("ora");function le({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 n=>{let r=await(0,de.oraPromise)(()=>o.conversation.get.send(n).json(),{...t,text:"Finding conversation"});console.log(r)})),e.addCommand(new Zt.Command("list").description("List conversations").action(async()=>{let n=await(0,de.oraPromise)(()=>o.conversation.list.send().json(),{...t,text:"Finding conversations"});console.log(n)})),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 n=>{let r=await(0,te.oraPromise)(()=>o.label.get.send(n).json(),{...t,text:"Finding label"});console.log(r)})),e.addCommand(new Yt.Command("list").description("List labels").action(async()=>{let n=await(0,te.oraPromise)(()=>o.label.list.send().json(),{...t,text:"Finding labels"});console.log(n)})),e.addCommand(new Yt.Command("conversations").description("Find label conversations").argument("<label>","Label ID").action(async n=>{let r=await(0,te.oraPromise)(()=>o.label.conversation.list.send(n).json(),{...t,text:"Finding conversations"});console.log(r)})),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 n=await(0,Ue.oraPromise)(()=>o.message.list.send().json(),{...t,text:"Finding messages"});console.log(n)})),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 n=>{let r=await(0,fe.oraPromise)(()=>o.model.get.send(n).json(),{...t,text:"Finding model"});console.log(r)})),e.addCommand(new ee.Command("list").description("List models").action(async()=>{let n=await(0,fe.oraPromise)(()=>o.model.list.send().json(),{...t,text:"Finding models"});console.log(n)})),e}var oe=require("commander"),ge=require("ora");function Oe({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 n=>{let r=await(0,ge.oraPromise)(()=>o.source.get.send(n).json(),{...t,text:"Finding source"});console.log(r)})),e.addCommand(new oe.Command("list").description("List sources").action(async()=>{let n=await(0,ge.oraPromise)(()=>o.source.list.send().json(),{...t,text:"Finding sources"});console.log(n)})),e}var Ee=require("commander");var be=require("commander"),Ae=require("ora");function ye({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 n=await(0,Ae.oraPromise)(()=>o.wellKnown.notification.get.send().json(),{...t,text:"Finding Notifications Well-Known Info"});console.log(n)})),e}function xe({client:o,ora:t}){let e=new Ee.Command("well-known").description("Well-Known Metadata & Info");return e.addCommand(ye({client:o,ora:t})),e}var p={ora:{spinner:"simpleDotsScrolling"},client:new Vt(new u)},Qe=new Ge.Command("gds").description("Great Detail Support System").addCommand(ie(p)).addCommand(pe(p)).addCommand(ce(p)).addCommand(le(p)).addCommand(me(p)).addCommand(he(p)).addCommand(Ce(p)).addCommand(Oe(p)).addCommand(xe(p)),He=Qe;
|
|
1
|
+
"use strict";var Ne=Object.create;var Xt=Object.defineProperty;var Be=Object.getOwnPropertyDescriptor;var Me=Object.getOwnPropertyNames;var je=Object.getPrototypeOf,ke=Object.prototype.hasOwnProperty;var De=(o,t)=>{for(var e in t)Xt(o,e,{get:t[e],enumerable:!0})},Te=(o,t,e,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of Me(t))!ke.call(o,r)&&r!==e&&Xt(o,r,{get:()=>t[r],enumerable:!(n=Be(t,r))||n.enumerable});return o};var ve=(o,t,e)=>(e=o!=null?Ne(je(o)):{},Te(t||!o||!o.__esModule?Xt(e,"default",{value:o,enumerable:!0}):e,o)),Qe=o=>Te(Xt({},"__esModule",{value:!0}),o);var Ve={};De(Ve,{default:()=>Ke});module.exports=Qe(Ve);var Ie=require("commander");var u=class{async filter(){return{headers:this.getHeaders()}}getHeaders(){return{}}};var se="SUPPORT_SIGNING_KEY",Re="SUPPORT_BASE_URL";var we="https://api.support.greatdetail.com",Fe={"X-Powered-By":"GDSupport/JavaScript"};var h=class o{constructor(t=o.STANDARD_HEADERS){this._standardHeaders=t}static STANDARD_HEADERS=Fe;async filter(){return{headers:this.getHeaders()}}getHeaders(){return this._standardHeaders}};var Le=ve(require("is-network-error"),1),Zt=ve(require("ky"),1);var a=class extends Error{static serverError(t){return new this("Server Error: "+t)}};var d=class extends a{};var f=class extends d{static unauthenticated(){return new this("An unauthenticated request occurred")}};var C=class extends d{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 l=class extends a{static badRequest(){return new this("Bad request")}static unsupportedMediaType(){return new this("Unsupported Media Type")}};var O=class{client;options;constructor({baseURL:t,...e}){this.options={...e,baseURL:t},this.client=Zt.default.create({prefixUrl:this.options.baseURL,timeout:12e3,hooks:{beforeRequest:[n=>{for(let r of this.options.requestFilterables){let i=r.getHeaders();for(let[$t,qe]of Object.entries(i))n.headers.has($t)||n.headers.set($t,qe)}}]}})}getURL(t){return new URL(t,this.options.baseURL).toString()}sortQuery(t){let e=[];if(t===void 0)return e;for(let[n,r]of Object.entries(t))r!==void 0&&e.push(["sort",r+n]);return e}limitQuery(t){let e=[];return t===void 0||e.push(["limit",t.toString()]),e}includeQuery(t){let e=[];if(t===void 0)return e;for(let n of Object.keys(t))e.push(["include",n]);return e}queryQuery(t){let e=[];return t===void 0||e.push(["query",t]),e}send(t,e={}){let n=this.client(t,e).catch(r=>{if((0,Le.default)(r))throw new g("A network error occurred",{cause:r});if(r instanceof Zt.HTTPError){let i=r.response.status;switch(console.error(JSON.stringify(r.response)),i){case 400:throw l.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 l.unsupportedMediaType();case 418:throw c.teapot();case 429:throw c.rateLimited()}if(i>=500&&i<600)throw a.serverError(i)}throw r});return{response:()=>n,json:async()=>(await n).json()}}};var s=require("zod");var b=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[se],maxSignatures:e=3,request:n}){let r=n.headers["gds-signature"];if(t!==!1){if(t===void 0)throw new Error("Missing webhook signing key in process.env."+se);if(!r)throw new Error("Missing signature header");if(!this._verifySignature(t,n.body,Array.isArray(r)?r.slice(0,e):[r]))throw new Error("Untrusted signature")}let{data:i}=o.SCHEMA.parse(n.body);return{event:i.event}}async _verifySignature(t,e,n){let r=await crypto.subtle.importKey("raw",new TextEncoder().encode(t),{name:"HMAC",hash:"SHA-256"},!1,["sign","verify"]);for(let i of n)if(await crypto.subtle.verify("HMAC",r,new TextEncoder().encode(atob(i)),new TextEncoder().encode(JSON.stringify(e))))return!0;return!1}};var y=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/accounts/"+encodeURIComponent(t)+"/access-tokens",{...e,method:"GET"})}};var x=class{constructor(t){this._transport=t}get api(){return{list:new y(this._transport)}}};var _=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/accounts/"+encodeURIComponent(t),{...e,method:"GET"})}};var S=class{constructor(t){this._transport=t}send(t,{body:e,request:n={}}){return this._transport.send("v1/accounts/"+encodeURIComponent(t),{...n,method:"PATCH",json:e})}};var T=class{constructor(t){this._transport=t}get api(){return{get:new _(this._transport),update:new S(this._transport)}}};var v=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:n={}}){return this._transport.send("v1/accounts/"+encodeURIComponent(t)+"/conversation-settings",{...n,method:"PATCH",json:e})}};var w=class{constructor(t){this._transport=t}get api(){return{get:new v(this._transport),update:new R(this._transport)}}};var F=class{constructor(t){this._transport=t}send({limit:t,sort:e,request:n={}}={}){return this._transport.send("v1/actions",{...n,method:"GET",searchParams:[...this._transport.limitQuery(t),...this._transport.sortQuery(e)]})}};var L=class{constructor(t){this._transport=t}get api(){return{list:new F(this._transport)}}};var U=class{constructor(t){this._transport=t}send(t,{limit:e,request:n={}}={}){return this._transport.send("v1/boilerplate-categories/"+encodeURIComponent(t)+"/boilerplates",{...n,method:"GET",searchParams:[...this._transport.limitQuery(e)]})}};var A=class{constructor(t){this._transport=t}send({body:t,request:e={}}){return this._transport.send("v1/boilerplate-categories",{...e,method:"POST",json:t})}};var E=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/boilerplate-categories/"+encodeURIComponent(t),{...e,method:"GET"})}};var G=class{constructor(t){this._transport=t}send({limit:t,include:e,request:n={}}={}){return this._transport.send("v1/boilerplate-categories",{...n,method:"GET",searchParams:[...this._transport.limitQuery(t),...this._transport.includeQuery(e)]})}};var P=class{constructor(t){this._transport=t}send(t,{body:e,request:n={}}){return this._transport.send("v1/boilerplate-categories/"+encodeURIComponent(t),{...n,method:"PATCH",json:e})}};var I=class{constructor(t){this._transport=t}get api(){return{get:new E(this._transport),list:new G(this._transport),create:new A(this._transport),update:new P(this._transport),boilerplate:{list:new U(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 N=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/boilerplates/"+encodeURIComponent(t),{...e,method:"GET"})}};var B=class{constructor(t){this._transport=t}send({limit:t,query:e,request:n={}}={}){return this._transport.send("v1/boilerplates",{...n,method:"GET",searchParams:[...this._transport.limitQuery(t),...this._transport.queryQuery(e)]})}};var M=class{constructor(t){this._transport=t}send(t,{body:e,request:n={}}){return this._transport.send("v1/boilerplates/"+encodeURIComponent(t),{...n,method:"PATCH",json:e})}};var j=class{constructor(t){this._transport=t}get api(){return{get:new N(this._transport),list:new B(this._transport),update:new M(this._transport),create:new q(this._transport)}}};var k=class{constructor(t){this._transport=t}send({body:t,request:e={}}){return this._transport.send("v1/channels",{...e,method:"POST",json:t})}};var D=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/channels/"+encodeURIComponent(t),{...e,method:"GET"})}};var Q=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 ie=require("zod"),H=class o{constructor(t){this._transport=t}static SCHEMA=ie.z.object({overwrite:ie.z.boolean().optional()});send(t,{body:e,request:n={}}){return this._transport.send("v1/sources/twilio-sendgrid/channels/"+encodeURIComponent(t)+"/sync",{...n,method:"POST",json:o.SCHEMA.parse(e)})}};var K=class{constructor(t){this._transport=t}send(t,{body:e,request:n={}}){return this._transport.send("v1/channels/"+encodeURIComponent(t),{...n,method:"PATCH",json:e})}};var V=class{constructor(t){this._transport=t}send(t,{limit:e,request:n={}}={}){return this._transport.send("v1/channels/"+encodeURIComponent(t)+"/composition-sections",{...n,method:"GET",searchParams:[...this._transport.limitQuery(e)]})}};var W=class{constructor(t){this._transport=t}send(t,{limit:e,include:n,request:r={}}={}){return this._transport.send("v1/channels/"+encodeURIComponent(t)+"/messages",{...r,method:"GET",searchParams:[...this._transport.limitQuery(e),...this._transport.includeQuery(n)]})}};var Y=class{constructor(t){this._transport=t}get api(){return{get:new D(this._transport),list:new Q(this._transport),update:new K(this._transport),create:new k(this._transport),compositionSection:{list:new V(this._transport)},message:{list:new W(this._transport)},twilioSendgrid:{sync:new H(this._transport)}}}};var z=class{constructor(t){this._transport=t}send({body:t,request:e={}}){return this._transport.send("v1/composition-sections",{...e,method:"POST",json:t})}};var J=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/composition-sections/"+encodeURIComponent(t),{...e,method:"GET"})}};var $=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 X=class{constructor(t){this._transport=t}send(t,{body:e,request:n={}}){return this._transport.send("v1/composition-sections/"+encodeURIComponent(t),{...n,method:"PATCH",json:e})}};var Z=class{constructor(t){this._transport=t}get api(){return{get:new J(this._transport),list:new $(this._transport),create:new z(this._transport),update:new X(this._transport)}}};var tt=class{constructor(t){this._transport=t}getRelativeURL({id:t,vcf:e={}}){let n=e.variant??"vcard",r=e.format??(n==="vcard"?"vcf":"json");return"v1/contacts/"+encodeURIComponent(t)+"/vcf?variant="+encodeURIComponent(n)+"&format="+encodeURIComponent(r)}getURL(t){return this._transport.getURL(this.getRelativeURL(t))}send(t){return this._transport.send(this.getURL(t),{method:"GET"})}};var et=class{constructor(t){this._transport=t}send({body:t,request:e={}}){return this._transport.send("v1/contacts",{...e,method:"POST",json:t})}};var ot=class{constructor(t){this._transport=t}send(t,{include:e,request:n={}}={}){return this._transport.send("v1/contacts/"+encodeURIComponent(t),{...n,method:"GET",searchParams:[...this._transport.includeQuery(e??{})]})}};var nt=class{constructor(t){this._transport=t}send({limit:t,query:e,request:n={}}={}){return this._transport.send("v1/contacts",{...n,method:"GET",searchParams:[...this._transport.limitQuery(t),...this._transport.queryQuery(e)]})}};var rt=class{constructor(t){this._transport=t}send(t,{body:e,request:n={}}){return this._transport.send("v1/contacts/"+encodeURIComponent(t),{...n,method:"PATCH",json:e})}};var st=class{constructor(t){this._transport=t}send(t,{limit:e,request:n={}}={}){return this._transport.send("v1/contacts/"+encodeURIComponent(t)+"/conversations",{...n,method:"GET",searchParams:[...this._transport.limitQuery(e)]})}};var it=class{constructor(t){this._transport=t}send(t,{limit:e,request:n={}}={}){return this._transport.send("v1/contacts/"+encodeURIComponent(t)+"/labels",{...n,method:"GET",searchParams:[...this._transport.limitQuery(e)]})}};var at=class{constructor(t){this._transport=t}send(t,{body:e,request:n={}}){return this._transport.send("v1/contacts/"+encodeURIComponent(t)+"/notes",{...n,method:"POST",json:e})}};var pt=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/contacts/"+encodeURIComponent(t)+"/notes",{...e,method:"GET"})}};var ct=class{constructor(t){this._transport=t}send(t,{body:e,request:n={}}){return this._transport.send("v1/contacts/"+encodeURIComponent(t)+"/notification-subscriptions",{...n,method:"POST",json:e})}};var dt=class{constructor(t){this._transport=t}get api(){return{get:new ot(this._transport),list:new nt(this._transport),update:new rt(this._transport),create:new et(this._transport),conversation:{list:new st(this._transport)},label:{list:new it(this._transport)},note:{list:new pt(this._transport),create:new at(this._transport)},notificationSubscription:{create:new ct(this._transport)},vcf:{get:new tt(this._transport)}}}};var lt=class{constructor(t){this._transport=t}send(t,{include:e,request:n={}}={}){return this._transport.send("v1/conversations/"+encodeURIComponent(t),{...n,method:"GET",searchParams:[...this._transport.includeQuery(e??{})]})}};var mt=class{constructor(t){this._transport=t}send({limit:t,filter:e,include:n,request:r={}}={}){return this._transport.send("v1/conversations",{...r,method:"GET",searchParams:[...this._transport.limitQuery(t),...e?[["filter",e]]:[],...this._transport.includeQuery(n??{})]})}};var ut=class{constructor(t){this._transport=t}send(t,{body:e,request:n={}}){return this._transport.send("v1/conversations/"+encodeURIComponent(t),{...n,method:"PATCH",json:e})}};var ht=class{constructor(t){this._transport=t}send(t,{limit:e,request:n={}}={}){return this._transport.send("v1/conversations/"+encodeURIComponent(t)+"/labels",{...n,method:"GET",searchParams:[...this._transport.limitQuery(e)]})}};var ft=class{constructor(t){this._transport=t}send(t,{limit:e,include:n,request:r={}}={}){return this._transport.send("v1/conversations/"+encodeURIComponent(t)+"/messages",{...r,method:"GET",searchParams:[...this._transport.limitQuery(e),...this._transport.includeQuery(n??{})]})}};var m=class{constructor(t){this._transport=t}send(t,{body:e,request:n={}}){return this._transport.send("v1/conversations/"+encodeURIComponent(t)+"/notes",{...n,method:"POST",json:e})}};var Ct=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/conversations/"+encodeURIComponent(t)+"/notes",{...e,method:"GET"})}};var gt=class{constructor(t){this._transport=t}get api(){return{get:new lt(this._transport),list:new mt(this._transport),update:new ut(this._transport),create:new m(this._transport),label:{list:new ht(this._transport)},message:{list:new ft(this._transport)},note:{list:new Ct(this._transport),create:new m(this._transport)}}}};var Ot=class{constructor(t){this._transport=t}send(t,{limit:e,request:n={}}={}){return this._transport.send("v1/labels/"+encodeURIComponent(t)+"/contacts",{...n,method:"GET",searchParams:[...this._transport.limitQuery(e)]})}};var bt=class{constructor(t){this._transport=t}send(t,{limit:e,request:n={}}={}){return this._transport.send("v1/labels/"+encodeURIComponent(t)+"/conversations",{...n,method:"GET",searchParams:[...this._transport.limitQuery(e)]})}};var yt=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 St=class{constructor(t){this._transport=t}send({limit:t,query:e,include:n,request:r={}}={}){return this._transport.send("v1/labels",{...r,method:"GET",searchParams:[...this._transport.limitQuery(t),...this._transport.queryQuery(e),...this._transport.includeQuery(n??{})]})}};var Tt=class{constructor(t){this._transport=t}send(t,{body:e,request:n={}}){return this._transport.send("v1/labels/"+encodeURIComponent(t),{...n,method:"PATCH",json:e})}};var vt=class{constructor(t){this._transport=t}get api(){return{create:new yt(this._transport),get:new _t(this._transport),list:new St(this._transport),update:new Tt(this._transport),delete:new xt(this._transport),contact:{list:new Ot(this._transport)},conversation:{list:new bt(this._transport)}}}};var Rt=class{constructor(t){this._transport=t}send({limit:t,include:e,request:n={}}={}){return this._transport.send("v1/messages",{...n,method:"GET",searchParams:[...this._transport.limitQuery(t),...this._transport.includeQuery(e??{})]})}};var wt=class{constructor(t){this._transport=t}get api(){return{list:new Rt(this._transport)}}};var Ft=class{constructor(t){this._transport=t}send(t,{body:e,request:n={}}){return this._transport.send("v1/models/"+encodeURIComponent(t)+"/correction",{...n,method:"POST",json:e})}};var Lt=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/models/"+encodeURIComponent(t),{...e,method:"GET"})}};var Ut=class{constructor(t){this._transport=t}send({request:t={}}={}){return this._transport.send("v1/models",{...t,method:"GET"})}};var At=class{constructor(t){this._transport=t}send(t,{body:e,request:n={}}){return this._transport.send("v1/models/"+encodeURIComponent(t)+"/response",{...n,method:"POST",timeout:12e4,json:e})}};var Et=class{constructor(t){this._transport=t}get api(){return{get:new Lt(this._transport),list:new Ut(this._transport),response:{create:new At(this._transport)},correction:{create:new Ft(this._transport)}}}};var Gt=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/notes/"+encodeURIComponent(t),{...e,method:"GET"})}};var Pt=class{constructor(t){this._transport=t}send(t,{body:e,request:n={}}){return this._transport.send("v1/notes/"+encodeURIComponent(t),{...n,method:"PATCH",json:e})}};var It=class{constructor(t){this._transport=t}get api(){return{get:new Gt(this._transport),update:new Pt(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 Nt=class{constructor(t){this._transport=t}send({category:t,request:e={}}={}){let n=[];if(t){let r=Array.isArray(t)?t:[t];for(let i of r)n.push(["category",i])}return this._transport.send("v1/sources",{...e,method:"GET",searchParams:n})}};var Bt=class{constructor(t){this._transport=t}get api(){return{get:new qt(this._transport),list:new Nt(this._transport)}}};var Mt=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/channels/"+encodeURIComponent(t)+"/statistics/message-frequency",{...e,method:"GET"})}};var jt=class{constructor(t){this._transport=t}send({request:t={}}={}){return this._transport.send("v1/statistics/message-frequency",{...t,method:"GET"})}};var kt=class{constructor(t){this._transport=t}get api(){return{messageFrequency:new jt(this._transport),channelMessageFrequency:new Mt(this._transport)}}};var Dt=class{constructor(t){this._transport=t}send({account:t,files:e,request:n={}}){let r=new FormData;for(let i of e)r.append("file",i);return this._transport.send("v1/uploads",{...n,method:"POST",body:r,searchParams:{account:t}})}};var Qt=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 Dt(this._transport),delete:new Qt(this._transport)}}};var Vt=class{constructor(t){this._transport=t}send({request:t={}}={}){return this._transport.send(".well-known/notifications",{...t,method:"GET"})}};var Wt=class{constructor(t){this._transport=t}get api(){return{notification:{get:new Vt(this._transport)}}}};var Yt=class o{static DEFAULT_BASE_URL=we;_transport;_account;_accountAccessToken;_accountConversationSettings;_action;_boilerplate;_boilerplateCategory;_channel;_compositionSection;_contact;_conversation;_label;_message;_model;_note;_source;_statistics;_upload;_webhook;_wellKnown;constructor(t,{baseURL:e,...n}={}){this._transport=new O({requestFilterables:[new h,t],...n,baseURL:e?.toString()??o.getBaseURL()}),this._account=new T(this._transport),this._accountAccessToken=new x(this._transport),this._accountConversationSettings=new w(this._transport),this._action=new L(this._transport),this._boilerplate=new j(this._transport),this._boilerplateCategory=new I(this._transport),this._channel=new Y(this._transport),this._compositionSection=new Z(this._transport),this._contact=new dt(this._transport),this._conversation=new gt(this._transport),this._label=new vt(this._transport),this._message=new wt(this._transport),this._model=new Et(this._transport),this._note=new It(this._transport),this._source=new Bt(this._transport),this._statistics=new kt(this._transport),this._upload=new Kt(this._transport),this._webhook=new b(this),this._wellKnown=new Wt(this._transport)}static getBaseURL(){return process.env[Re]??this.DEFAULT_BASE_URL}get account(){return this._account.api}get accountAccessToken(){return this._accountAccessToken.api}get accountConversationSettings(){return this._accountConversationSettings.api}get action(){return this._action.api}get boilerplate(){return this._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 ae=require("commander"),Ue=require("ora");function pe({client:o,ora:t}){let e=new ae.Command("actions").description("Actions");return e.addCommand(new ae.Command("list").description("List actions").action(async()=>{let n=await(0,Ue.oraPromise)(()=>o.action.list.send().json(),{...t,text:"Finding actions"});console.log(n)})),e}var ce=require("commander"),Ae=require("ora");function de({client:o,ora:t}){let e=new ce.Command("channels").description("Channels");return e.addCommand(new ce.Command("list").description("List channels").action(async()=>{let n=await(0,Ae.oraPromise)(()=>o.channel.list.send().json(),{...t,text:"Finding channels"});console.log(n)})),e}var zt=require("commander"),te=require("ora");function le({client:o,ora:t}){let e=new zt.Command("contacts").description("Contacts");return e.addCommand(new zt.Command("get").description("Find contact").argument("<contact>","Contact ID").action(async n=>{let r=await(0,te.oraPromise)(()=>o.contact.get.send(n).json(),{...t,text:"Finding contact"});console.log(r)})),e.addCommand(new zt.Command("list").description("List contacts").action(async()=>{let n=await(0,te.oraPromise)(()=>o.contact.list.send().json(),{...t,text:"Finding contacts"});console.log(n)})),e.addCommand(new zt.Command("get-vcf").description("Export Contact as VCF").argument("<contact>","Contact ID").action(async n=>{let r=await(0,te.oraPromise)(()=>o.contact.vcf.get.send({id:n}).response(),{...t,text:"Exporting contact"});console.log(r)})),e}var ee=require("commander"),me=require("ora");function ue({client:o,ora:t}){let e=new ee.Command("conversations").description("Conversations");return e.addCommand(new ee.Command("get").description("Find conversation").argument("<conversation>","Conversation ID").action(async n=>{let r=await(0,me.oraPromise)(()=>o.conversation.get.send(n).json(),{...t,text:"Finding conversation"});console.log(r)})),e.addCommand(new ee.Command("list").description("List conversations").action(async()=>{let n=await(0,me.oraPromise)(()=>o.conversation.list.send().json(),{...t,text:"Finding conversations"});console.log(n)})),e}var Jt=require("commander"),oe=require("ora");function he({client:o,ora:t}){let e=new Jt.Command("labels").description("Labels");return e.addCommand(new Jt.Command("get").description("Find label").argument("<label>","Label ID").action(async n=>{let r=await(0,oe.oraPromise)(()=>o.label.get.send(n).json(),{...t,text:"Finding label"});console.log(r)})),e.addCommand(new Jt.Command("list").description("List labels").action(async()=>{let n=await(0,oe.oraPromise)(()=>o.label.list.send().json(),{...t,text:"Finding labels"});console.log(n)})),e.addCommand(new Jt.Command("conversations").description("Find label conversations").argument("<label>","Label ID").action(async n=>{let r=await(0,oe.oraPromise)(()=>o.label.conversation.list.send(n).json(),{...t,text:"Finding conversations"});console.log(r)})),e}var fe=require("commander"),Ee=require("ora");function Ce({client:o,ora:t}){let e=new fe.Command("messages").description("Messages");return e.addCommand(new fe.Command("list").description("List messages").action(async()=>{let n=await(0,Ee.oraPromise)(()=>o.message.list.send().json(),{...t,text:"Finding messages"});console.log(n)})),e}var ne=require("commander"),ge=require("ora");function Oe({client:o,ora:t}){let e=new ne.Command("models").description("Models");return e.addCommand(new ne.Command("get").description("Find model").argument("<model>","Model ID").action(async n=>{let r=await(0,ge.oraPromise)(()=>o.model.get.send(n).json(),{...t,text:"Finding model"});console.log(r)})),e.addCommand(new ne.Command("list").description("List models").action(async()=>{let n=await(0,ge.oraPromise)(()=>o.model.list.send().json(),{...t,text:"Finding models"});console.log(n)})),e}var re=require("commander"),be=require("ora");function ye({client:o,ora:t}){let e=new re.Command("sources").description("Sources");return e.addCommand(new re.Command("get").description("Find source").argument("<source>","Source ID").action(async n=>{let r=await(0,be.oraPromise)(()=>o.source.get.send(n).json(),{...t,text:"Finding source"});console.log(r)})),e.addCommand(new re.Command("list").description("List sources").action(async()=>{let n=await(0,be.oraPromise)(()=>o.source.list.send().json(),{...t,text:"Finding sources"});console.log(n)})),e}var Pe=require("commander");var xe=require("commander"),Ge=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 n=await(0,Ge.oraPromise)(()=>o.wellKnown.notification.get.send().json(),{...t,text:"Finding Notifications Well-Known Info"});console.log(n)})),e}function Se({client:o,ora:t}){let e=new Pe.Command("well-known").description("Well-Known Metadata & Info");return e.addCommand(_e({client:o,ora:t})),e}var p={ora:{spinner:"simpleDotsScrolling"},client:new Yt(new u)},He=new Ie.Command("gds").description("Great Detail Support System").addCommand(pe(p)).addCommand(de(p)).addCommand(le(p)).addCommand(ue(p)).addCommand(he(p)).addCommand(Ce(p)).addCommand(Oe(p)).addCommand(ye(p)).addCommand(Se(p)),Ke=He;
|
package/dist/cli/index.d.cts
CHANGED
package/dist/cli/index.d.ts
CHANGED
package/dist/cli/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a}from"../chunk-
|
|
1
|
+
import{a}from"../chunk-HB5Z3WZ2.js";import"../chunk-EWJFCLFP.js";export{a as default};
|
package/dist/cli.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
"use strict";var Ie=Object.create;var xe=Object.defineProperty;var qe=Object.getOwnPropertyDescriptor;var Ne=Object.getOwnPropertyNames;var Be=Object.getPrototypeOf,Me=Object.prototype.hasOwnProperty;var je=(o,t,e,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of Ne(t))!Me.call(o,r)&&r!==e&&xe(o,r,{get:()=>t[r],enumerable:!(n=qe(t,r))||n.enumerable});return o};var _e=(o,t,e)=>(e=o!=null?Ie(Be(o)):{},je(t||!o||!o.__esModule?xe(e,"default",{value:o,enumerable:!0}):e,o));var Ee=require("commander");var u=class{async filter(){return{headers:this.getHeaders()}}getHeaders(){return{}}};var oe="SUPPORT_SIGNING_KEY",Se="SUPPORT_BASE_URL";var Te="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 Re=_e(require("is-network-error"),1),Jt=_e(require("ky"),1);var a=class extends Error{static serverError(t){return new this("Server Error: "+t)}};var d=class extends a{};var f=class extends d{static unauthenticated(){return new this("An unauthenticated request occurred")}};var C=class extends d{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 l=class extends a{static badRequest(){return new this("Bad request")}static unsupportedMediaType(){return new this("Unsupported Media Type")}};var O=class{client;options;constructor({baseURL:t,...e}){this.options={...e,baseURL:t},this.client=Jt.default.create({prefixUrl:this.options.baseURL,timeout:12e3,hooks:{beforeRequest:[n=>{for(let r of this.options.requestFilterables){let i=r.getHeaders();for(let[zt,Pe]of Object.entries(i))n.headers.has(zt)||n.headers.set(zt,Pe)}}]}})}getURL(t){return new URL(t,this.options.baseURL).toString()}sortQuery(t){let e=[];if(t===void 0)return e;for(let[n,r]of Object.entries(t))r!==void 0&&e.push(["sort",r+n]);return e}limitQuery(t){let e=[];return t===void 0||e.push(["limit",t.toString()]),e}includeQuery(t){let e=[];if(t===void 0)return e;for(let n of Object.keys(t))e.push(["include",n]);return e}queryQuery(t){let e=[];return t===void 0||e.push(["query",t]),e}send(t,e={}){let n=this.client(t,e).catch(r=>{if((0,Re.default)(r))throw new g("A network error occurred",{cause:r});if(r instanceof Jt.HTTPError){let i=r.response.status;switch(console.error(JSON.stringify(r.response)),i){case 400:throw l.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 l.unsupportedMediaType();case 418:throw c.teapot();case 429:throw c.rateLimited()}if(i>=500&&i<600)throw a.serverError(i)}throw r});return{response:()=>n,json:async()=>(await n).json()}}};var s=require("zod");var b=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:n}){let r=n.headers["gds-signature"];if(t!==!1){if(t===void 0)throw new Error("Missing webhook signing key in process.env."+oe);if(!r)throw new Error("Missing signature header");if(!this._verifySignature(t,n.body,Array.isArray(r)?r.slice(0,e):[r]))throw new Error("Untrusted signature")}let{data:i}=o.SCHEMA.parse(n.body);return{event:i.event}}async _verifySignature(t,e,n){let r=await crypto.subtle.importKey("raw",new TextEncoder().encode(t),{name:"HMAC",hash:"SHA-256"},!1,["sign","verify"]);for(let i of n)if(await crypto.subtle.verify("HMAC",r,new TextEncoder().encode(atob(i)),new TextEncoder().encode(JSON.stringify(e))))return!0;return!1}};var y=class{constructor(t){this._transport=t}send(t,{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:n={}}){return this._transport.send("v1/accounts/"+encodeURIComponent(t),{...n,method:"PATCH",json:e})}};var _=class{constructor(t){this._transport=t}get api(){return{get:new y(this._transport),update:new x(this._transport)}}};var S=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:n={}}){return this._transport.send("v1/accounts/"+encodeURIComponent(t)+"/conversation-settings",{...n,method:"PATCH",json:e})}};var v=class{constructor(t){this._transport=t}get api(){return{get:new S(this._transport),update:new T(this._transport)}}};var R=class{constructor(t){this._transport=t}send({limit:t,sort:e,request:n={}}={}){return this._transport.send("v1/actions",{...n,method:"GET",searchParams:[...this._transport.limitQuery(t),...this._transport.sortQuery(e)]})}};var w=class{constructor(t){this._transport=t}get api(){return{list:new R(this._transport)}}};var F=class{constructor(t){this._transport=t}send(t,{limit:e,request:n={}}={}){return this._transport.send("v1/boilerplate-categories/"+encodeURIComponent(t)+"/boilerplates",{...n,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 U=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/boilerplate-categories/"+encodeURIComponent(t),{...e,method:"GET"})}};var A=class{constructor(t){this._transport=t}send({limit:t,include:e,request:n={}}={}){return this._transport.send("v1/boilerplate-categories",{...n,method:"GET",searchParams:[...this._transport.limitQuery(t),...this._transport.includeQuery(e)]})}};var E=class{constructor(t){this._transport=t}send(t,{body:e,request:n={}}){return this._transport.send("v1/boilerplate-categories/"+encodeURIComponent(t),{...n,method:"PATCH",json:e})}};var G=class{constructor(t){this._transport=t}get api(){return{get:new U(this._transport),list:new A(this._transport),create:new L(this._transport),update:new E(this._transport),boilerplate:{list:new F(this._transport)}}}};var P=class{constructor(t){this._transport=t}send({body:t,request:e={}}){return this._transport.send("v1/boilerplates",{...e,method:"POST",json:t})}};var I=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/boilerplates/"+encodeURIComponent(t),{...e,method:"GET"})}};var q=class{constructor(t){this._transport=t}send({limit:t,query:e,request:n={}}={}){return this._transport.send("v1/boilerplates",{...n,method:"GET",searchParams:[...this._transport.limitQuery(t),...this._transport.queryQuery(e)]})}};var N=class{constructor(t){this._transport=t}send(t,{body:e,request:n={}}){return this._transport.send("v1/boilerplates/"+encodeURIComponent(t),{...n,method:"PATCH",json:e})}};var B=class{constructor(t){this._transport=t}get api(){return{get:new I(this._transport),list:new q(this._transport),update:new N(this._transport),create:new P(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"),Q=class o{constructor(t){this._transport=t}static SCHEMA=ne.z.object({overwrite:ne.z.boolean().optional()});send(t,{body:e,request:n={}}){return this._transport.send("v1/sources/twilio-sendgrid/channels/"+encodeURIComponent(t)+"/sync",{...n,method:"POST",json:o.SCHEMA.parse(e)})}};var H=class{constructor(t){this._transport=t}send(t,{body:e,request:n={}}){return this._transport.send("v1/channels/"+encodeURIComponent(t),{...n,method:"PATCH",json:e})}};var K=class{constructor(t){this._transport=t}send(t,{limit:e,request:n={}}={}){return this._transport.send("v1/channels/"+encodeURIComponent(t)+"/composition-sections",{...n,method:"GET",searchParams:[...this._transport.limitQuery(e)]})}};var k=class{constructor(t){this._transport=t}send(t,{limit:e,include:n,request:r={}}={}){return this._transport.send("v1/channels/"+encodeURIComponent(t)+"/messages",{...r,method:"GET",searchParams:[...this._transport.limitQuery(e),...this._transport.includeQuery(n)]})}};var V=class{constructor(t){this._transport=t}get api(){return{get:new j(this._transport),list:new D(this._transport),update:new H(this._transport),create:new M(this._transport),compositionSection:{list:new K(this._transport)},message:{list:new k(this._transport)},twilioSendgrid:{sync:new Q(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:n={}}){return this._transport.send("v1/composition-sections/"+encodeURIComponent(t),{...n,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 n=e.variant??"vcard",r=e.format??(n==="vcard"?"vcf":"json");return"v1/contacts/"+encodeURIComponent(t)+"/vcf?variant="+encodeURIComponent(n)+"&format="+encodeURIComponent(r)}getURL(t){return this._transport.getURL(this.getRelativeURL(t))}send(t){return this._transport.send(this.getURL(t),{method:"GET"})}};var 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:n={}}={}){return this._transport.send("v1/contacts/"+encodeURIComponent(t),{...n,method:"GET",searchParams:[...this._transport.includeQuery(e??{})]})}};var et=class{constructor(t){this._transport=t}send({limit:t,query:e,request:n={}}={}){return this._transport.send("v1/contacts",{...n,method:"GET",searchParams:[...this._transport.limitQuery(t),...this._transport.queryQuery(e)]})}};var ot=class{constructor(t){this._transport=t}send(t,{body:e,request:n={}}){return this._transport.send("v1/contacts/"+encodeURIComponent(t),{...n,method:"PATCH",json:e})}};var nt=class{constructor(t){this._transport=t}send(t,{limit:e,request:n={}}={}){return this._transport.send("v1/contacts/"+encodeURIComponent(t)+"/conversations",{...n,method:"GET",searchParams:[...this._transport.limitQuery(e)]})}};var rt=class{constructor(t){this._transport=t}send(t,{limit:e,request:n={}}={}){return this._transport.send("v1/contacts/"+encodeURIComponent(t)+"/labels",{...n,method:"GET",searchParams:[...this._transport.limitQuery(e)]})}};var st=class{constructor(t){this._transport=t}send(t,{body:e,request:n={}}){return this._transport.send("v1/contacts/"+encodeURIComponent(t)+"/notes",{...n,method:"POST",json:e})}};var 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:n={}}){return this._transport.send("v1/contacts/"+encodeURIComponent(t)+"/notification-subscriptions",{...n,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 nt(this._transport)},label:{list:new rt(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:n={}}={}){return this._transport.send("v1/conversations/"+encodeURIComponent(t),{...n,method:"GET",searchParams:[...this._transport.includeQuery(e??{})]})}};var dt=class{constructor(t){this._transport=t}send({limit:t,filter:e,include:n,request:r={}}={}){return this._transport.send("v1/conversations",{...r,method:"GET",searchParams:[...this._transport.limitQuery(t),...e?[["filter",e]]:[],...this._transport.includeQuery(n??{})]})}};var lt=class{constructor(t){this._transport=t}send(t,{body:e,request:n={}}){return this._transport.send("v1/conversations/"+encodeURIComponent(t),{...n,method:"PATCH",json:e})}};var mt=class{constructor(t){this._transport=t}send(t,{limit:e,request:n={}}={}){return this._transport.send("v1/conversations/"+encodeURIComponent(t)+"/labels",{...n,method:"GET",searchParams:[...this._transport.limitQuery(e)]})}};var ut=class{constructor(t){this._transport=t}send(t,{limit:e,include:n,request:r={}}={}){return this._transport.send("v1/conversations/"+encodeURIComponent(t)+"/messages",{...r,method:"GET",searchParams:[...this._transport.limitQuery(e),...this._transport.includeQuery(n??{})]})}};var m=class{constructor(t){this._transport=t}send(t,{body:e,request:n={}}){return this._transport.send("v1/conversations/"+encodeURIComponent(t)+"/notes",{...n,method:"POST",json:e})}};var 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 dt(this._transport),update:new lt(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:n={}}={}){return this._transport.send("v1/labels/"+encodeURIComponent(t)+"/contacts",{...n,method:"GET",searchParams:[...this._transport.limitQuery(e)]})}};var gt=class{constructor(t){this._transport=t}send(t,{limit:e,request:n={}}={}){return this._transport.send("v1/labels/"+encodeURIComponent(t)+"/conversations",{...n,method:"GET",searchParams:[...this._transport.limitQuery(e)]})}};var Ot=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 yt=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:n,request:r={}}={}){return this._transport.send("v1/labels",{...r,method:"GET",searchParams:[...this._transport.limitQuery(t),...this._transport.queryQuery(e),...this._transport.includeQuery(n??{})]})}};var _t=class{constructor(t){this._transport=t}send(t,{body:e,request:n={}}){return this._transport.send("v1/labels/"+encodeURIComponent(t),{...n,method:"PATCH",json:e})}};var St=class{constructor(t){this._transport=t}get api(){return{create:new Ot(this._transport),get:new yt(this._transport),list:new xt(this._transport),update:new _t(this._transport),delete:new bt(this._transport),contact:{list:new Ct(this._transport)},conversation:{list:new gt(this._transport)}}}};var Tt=class{constructor(t){this._transport=t}send({limit:t,include:e,request:n={}}={}){return this._transport.send("v1/messages",{...n,method:"GET",searchParams:[...this._transport.limitQuery(t),...this._transport.includeQuery(e??{})]})}};var vt=class{constructor(t){this._transport=t}get api(){return{list:new Tt(this._transport)}}};var Rt=class{constructor(t){this._transport=t}send(t,{body:e,request:n={}}){return this._transport.send("v1/models/"+encodeURIComponent(t)+"/correction",{...n,method:"POST",json:e})}};var wt=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:n={}}){return this._transport.send("v1/models/"+encodeURIComponent(t)+"/response",{...n,method:"POST",timeout:12e4,json:e})}};var Ut=class{constructor(t){this._transport=t}get api(){return{get:new wt(this._transport),list:new Ft(this._transport),response:{create:new Lt(this._transport)},correction:{create:new Rt(this._transport)}}}};var At=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/notes/"+encodeURIComponent(t),{...e,method:"GET"})}};var Et=class{constructor(t){this._transport=t}send(t,{body:e,request:n={}}){return this._transport.send("v1/notes/"+encodeURIComponent(t),{...n,method:"PATCH",json:e})}};var Gt=class{constructor(t){this._transport=t}get api(){return{get:new At(this._transport),update:new Et(this._transport)}}};var Pt=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/sources/"+encodeURIComponent(t),{...e,method:"GET"})}};var It=class{constructor(t){this._transport=t}send({category:t,request:e={}}={}){let n=[];if(t){let r=Array.isArray(t)?t:[t];for(let i of r)n.push(["category",i])}return this._transport.send("v1/sources",{...e,method:"GET",searchParams:n})}};var qt=class{constructor(t){this._transport=t}get api(){return{get:new Pt(this._transport),list:new It(this._transport)}}};var Nt=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/channels/"+encodeURIComponent(t)+"/statistics/message-frequency",{...e,method:"GET"})}};var 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:n={}}){let r=new FormData;for(let i of e)r.append("file",i);return this._transport.send("v1/uploads",{...n,method:"POST",body:r,searchParams:{account:t}})}};var Dt=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/uploads/"+encodeURIComponent(t),{...e,method:"DELETE"})}};var Qt=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 Qt(this._transport),create:new jt(this._transport),delete:new Dt(this._transport)}}};var Kt=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 Kt(this._transport)}}}};var Vt=class o{static DEFAULT_BASE_URL=Te;_transport;_account;_accountConversationSettings;_action;_boilerplate;_boilerplateCategory;_channel;_compositionSection;_contact;_conversation;_label;_message;_model;_note;_source;_statistics;_upload;_webhook;_wellKnown;constructor(t,{baseURL:e,...n}={}){this._transport=new O({requestFilterables:[new h,t],...n,baseURL:e?.toString()??o.getBaseURL()}),this._account=new _(this._transport),this._accountConversationSettings=new v(this._transport),this._action=new w(this._transport),this._boilerplate=new B(this._transport),this._boilerplateCategory=new G(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 St(this._transport),this._message=new vt(this._transport),this._model=new Ut(this._transport),this._note=new Gt(this._transport),this._source=new qt(this._transport),this._statistics=new Mt(this._transport),this._upload=new Ht(this._transport),this._webhook=new b(this),this._wellKnown=new kt(this._transport)}static getBaseURL(){return process.env[Se]??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 re=require("commander"),we=require("ora");function se({client:o,ora:t}){let e=new re.Command("actions").description("Actions");return e.addCommand(new re.Command("list").description("List actions").action(async()=>{let n=await(0,we.oraPromise)(()=>o.action.list.send().json(),{...t,text:"Finding actions"});console.log(n)})),e}var ie=require("commander"),Fe=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 n=await(0,Fe.oraPromise)(()=>o.channel.list.send().json(),{...t,text:"Finding channels"});console.log(n)})),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 n=>{let r=await(0,$t.oraPromise)(()=>o.contact.get.send(n).json(),{...t,text:"Finding contact"});console.log(r)})),e.addCommand(new Wt.Command("list").description("List contacts").action(async()=>{let n=await(0,$t.oraPromise)(()=>o.contact.list.send().json(),{...t,text:"Finding contacts"});console.log(n)})),e.addCommand(new Wt.Command("get-vcf").description("Export Contact as VCF").argument("<contact>","Contact ID").action(async n=>{let r=await(0,$t.oraPromise)(()=>o.contact.vcf.get.send({id:n}).response(),{...t,text:"Exporting contact"});console.log(r)})),e}var Xt=require("commander"),ce=require("ora");function de({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 n=>{let r=await(0,ce.oraPromise)(()=>o.conversation.get.send(n).json(),{...t,text:"Finding conversation"});console.log(r)})),e.addCommand(new Xt.Command("list").description("List conversations").action(async()=>{let n=await(0,ce.oraPromise)(()=>o.conversation.list.send().json(),{...t,text:"Finding conversations"});console.log(n)})),e}var Yt=require("commander"),Zt=require("ora");function le({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 n=>{let r=await(0,Zt.oraPromise)(()=>o.label.get.send(n).json(),{...t,text:"Finding label"});console.log(r)})),e.addCommand(new Yt.Command("list").description("List labels").action(async()=>{let n=await(0,Zt.oraPromise)(()=>o.label.list.send().json(),{...t,text:"Finding labels"});console.log(n)})),e.addCommand(new Yt.Command("conversations").description("Find label conversations").argument("<label>","Label ID").action(async n=>{let r=await(0,Zt.oraPromise)(()=>o.label.conversation.list.send(n).json(),{...t,text:"Finding conversations"});console.log(r)})),e}var me=require("commander"),Le=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 n=await(0,Le.oraPromise)(()=>o.message.list.send().json(),{...t,text:"Finding messages"});console.log(n)})),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 n=>{let r=await(0,he.oraPromise)(()=>o.model.get.send(n).json(),{...t,text:"Finding model"});console.log(r)})),e.addCommand(new te.Command("list").description("List models").action(async()=>{let n=await(0,he.oraPromise)(()=>o.model.list.send().json(),{...t,text:"Finding models"});console.log(n)})),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 n=>{let r=await(0,Ce.oraPromise)(()=>o.source.get.send(n).json(),{...t,text:"Finding source"});console.log(r)})),e.addCommand(new ee.Command("list").description("List sources").action(async()=>{let n=await(0,Ce.oraPromise)(()=>o.source.list.send().json(),{...t,text:"Finding sources"});console.log(n)})),e}var Ae=require("commander");var Oe=require("commander"),Ue=require("ora");function be({client:o,ora:t}){let e=new Oe.Command("notifications").description("Well-Known Notifications Details");return e.addCommand(new Oe.Command("get").description("Get Notifications Server Well-Known Info").action(async()=>{let n=await(0,Ue.oraPromise)(()=>o.wellKnown.notification.get.send().json(),{...t,text:"Finding Notifications Well-Known Info"});console.log(n)})),e}function ye({client:o,ora:t}){let e=new Ae.Command("well-known").description("Well-Known Metadata & Info");return e.addCommand(be({client:o,ora:t})),e}var p={ora:{spinner:"simpleDotsScrolling"},client:new Vt(new u)},De=new Ee.Command("gds").description("Great Detail Support System").addCommand(se(p)).addCommand(ae(p)).addCommand(pe(p)).addCommand(de(p)).addCommand(le(p)).addCommand(ue(p)).addCommand(fe(p)).addCommand(ge(p)).addCommand(ye(p)),Ge=De;Ge.parseAsync(process.argv);
|
|
2
|
+
"use strict";var Ne=Object.create;var Se=Object.defineProperty;var Be=Object.getOwnPropertyDescriptor;var Me=Object.getOwnPropertyNames;var je=Object.getPrototypeOf,ke=Object.prototype.hasOwnProperty;var De=(o,t,e,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of Me(t))!ke.call(o,r)&&r!==e&&Se(o,r,{get:()=>t[r],enumerable:!(n=Be(t,r))||n.enumerable});return o};var Te=(o,t,e)=>(e=o!=null?Ne(je(o)):{},De(t||!o||!o.__esModule?Se(e,"default",{value:o,enumerable:!0}):e,o));var Pe=require("commander");var u=class{async filter(){return{headers:this.getHeaders()}}getHeaders(){return{}}};var re="SUPPORT_SIGNING_KEY",ve="SUPPORT_BASE_URL";var Re="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),Xt=Te(require("ky"),1);var a=class extends Error{static serverError(t){return new this("Server Error: "+t)}};var d=class extends a{};var f=class extends d{static unauthenticated(){return new this("An unauthenticated request occurred")}};var C=class extends d{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 l=class extends a{static badRequest(){return new this("Bad request")}static unsupportedMediaType(){return new this("Unsupported Media Type")}};var O=class{client;options;constructor({baseURL:t,...e}){this.options={...e,baseURL:t},this.client=Xt.default.create({prefixUrl:this.options.baseURL,timeout:12e3,hooks:{beforeRequest:[n=>{for(let r of this.options.requestFilterables){let i=r.getHeaders();for(let[$t,qe]of Object.entries(i))n.headers.has($t)||n.headers.set($t,qe)}}]}})}getURL(t){return new URL(t,this.options.baseURL).toString()}sortQuery(t){let e=[];if(t===void 0)return e;for(let[n,r]of Object.entries(t))r!==void 0&&e.push(["sort",r+n]);return e}limitQuery(t){let e=[];return t===void 0||e.push(["limit",t.toString()]),e}includeQuery(t){let e=[];if(t===void 0)return e;for(let n of Object.keys(t))e.push(["include",n]);return e}queryQuery(t){let e=[];return t===void 0||e.push(["query",t]),e}send(t,e={}){let n=this.client(t,e).catch(r=>{if((0,Fe.default)(r))throw new g("A network error occurred",{cause:r});if(r instanceof Xt.HTTPError){let i=r.response.status;switch(console.error(JSON.stringify(r.response)),i){case 400:throw l.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 l.unsupportedMediaType();case 418:throw c.teapot();case 429:throw c.rateLimited()}if(i>=500&&i<600)throw a.serverError(i)}throw r});return{response:()=>n,json:async()=>(await n).json()}}};var s=require("zod");var b=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:n}){let r=n.headers["gds-signature"];if(t!==!1){if(t===void 0)throw new Error("Missing webhook signing key in process.env."+re);if(!r)throw new Error("Missing signature header");if(!this._verifySignature(t,n.body,Array.isArray(r)?r.slice(0,e):[r]))throw new Error("Untrusted signature")}let{data:i}=o.SCHEMA.parse(n.body);return{event:i.event}}async _verifySignature(t,e,n){let r=await crypto.subtle.importKey("raw",new TextEncoder().encode(t),{name:"HMAC",hash:"SHA-256"},!1,["sign","verify"]);for(let i of n)if(await crypto.subtle.verify("HMAC",r,new TextEncoder().encode(atob(i)),new TextEncoder().encode(JSON.stringify(e))))return!0;return!1}};var y=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/accounts/"+encodeURIComponent(t)+"/access-tokens",{...e,method:"GET"})}};var x=class{constructor(t){this._transport=t}get api(){return{list:new y(this._transport)}}};var _=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/accounts/"+encodeURIComponent(t),{...e,method:"GET"})}};var S=class{constructor(t){this._transport=t}send(t,{body:e,request:n={}}){return this._transport.send("v1/accounts/"+encodeURIComponent(t),{...n,method:"PATCH",json:e})}};var T=class{constructor(t){this._transport=t}get api(){return{get:new _(this._transport),update:new S(this._transport)}}};var v=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:n={}}){return this._transport.send("v1/accounts/"+encodeURIComponent(t)+"/conversation-settings",{...n,method:"PATCH",json:e})}};var w=class{constructor(t){this._transport=t}get api(){return{get:new v(this._transport),update:new R(this._transport)}}};var F=class{constructor(t){this._transport=t}send({limit:t,sort:e,request:n={}}={}){return this._transport.send("v1/actions",{...n,method:"GET",searchParams:[...this._transport.limitQuery(t),...this._transport.sortQuery(e)]})}};var L=class{constructor(t){this._transport=t}get api(){return{list:new F(this._transport)}}};var U=class{constructor(t){this._transport=t}send(t,{limit:e,request:n={}}={}){return this._transport.send("v1/boilerplate-categories/"+encodeURIComponent(t)+"/boilerplates",{...n,method:"GET",searchParams:[...this._transport.limitQuery(e)]})}};var A=class{constructor(t){this._transport=t}send({body:t,request:e={}}){return this._transport.send("v1/boilerplate-categories",{...e,method:"POST",json:t})}};var E=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/boilerplate-categories/"+encodeURIComponent(t),{...e,method:"GET"})}};var G=class{constructor(t){this._transport=t}send({limit:t,include:e,request:n={}}={}){return this._transport.send("v1/boilerplate-categories",{...n,method:"GET",searchParams:[...this._transport.limitQuery(t),...this._transport.includeQuery(e)]})}};var P=class{constructor(t){this._transport=t}send(t,{body:e,request:n={}}){return this._transport.send("v1/boilerplate-categories/"+encodeURIComponent(t),{...n,method:"PATCH",json:e})}};var I=class{constructor(t){this._transport=t}get api(){return{get:new E(this._transport),list:new G(this._transport),create:new A(this._transport),update:new P(this._transport),boilerplate:{list:new U(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 N=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/boilerplates/"+encodeURIComponent(t),{...e,method:"GET"})}};var B=class{constructor(t){this._transport=t}send({limit:t,query:e,request:n={}}={}){return this._transport.send("v1/boilerplates",{...n,method:"GET",searchParams:[...this._transport.limitQuery(t),...this._transport.queryQuery(e)]})}};var M=class{constructor(t){this._transport=t}send(t,{body:e,request:n={}}){return this._transport.send("v1/boilerplates/"+encodeURIComponent(t),{...n,method:"PATCH",json:e})}};var j=class{constructor(t){this._transport=t}get api(){return{get:new N(this._transport),list:new B(this._transport),update:new M(this._transport),create:new q(this._transport)}}};var k=class{constructor(t){this._transport=t}send({body:t,request:e={}}){return this._transport.send("v1/channels",{...e,method:"POST",json:t})}};var D=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/channels/"+encodeURIComponent(t),{...e,method:"GET"})}};var Q=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 se=require("zod"),H=class o{constructor(t){this._transport=t}static SCHEMA=se.z.object({overwrite:se.z.boolean().optional()});send(t,{body:e,request:n={}}){return this._transport.send("v1/sources/twilio-sendgrid/channels/"+encodeURIComponent(t)+"/sync",{...n,method:"POST",json:o.SCHEMA.parse(e)})}};var K=class{constructor(t){this._transport=t}send(t,{body:e,request:n={}}){return this._transport.send("v1/channels/"+encodeURIComponent(t),{...n,method:"PATCH",json:e})}};var V=class{constructor(t){this._transport=t}send(t,{limit:e,request:n={}}={}){return this._transport.send("v1/channels/"+encodeURIComponent(t)+"/composition-sections",{...n,method:"GET",searchParams:[...this._transport.limitQuery(e)]})}};var W=class{constructor(t){this._transport=t}send(t,{limit:e,include:n,request:r={}}={}){return this._transport.send("v1/channels/"+encodeURIComponent(t)+"/messages",{...r,method:"GET",searchParams:[...this._transport.limitQuery(e),...this._transport.includeQuery(n)]})}};var Y=class{constructor(t){this._transport=t}get api(){return{get:new D(this._transport),list:new Q(this._transport),update:new K(this._transport),create:new k(this._transport),compositionSection:{list:new V(this._transport)},message:{list:new W(this._transport)},twilioSendgrid:{sync:new H(this._transport)}}}};var z=class{constructor(t){this._transport=t}send({body:t,request:e={}}){return this._transport.send("v1/composition-sections",{...e,method:"POST",json:t})}};var J=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/composition-sections/"+encodeURIComponent(t),{...e,method:"GET"})}};var $=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 X=class{constructor(t){this._transport=t}send(t,{body:e,request:n={}}){return this._transport.send("v1/composition-sections/"+encodeURIComponent(t),{...n,method:"PATCH",json:e})}};var Z=class{constructor(t){this._transport=t}get api(){return{get:new J(this._transport),list:new $(this._transport),create:new z(this._transport),update:new X(this._transport)}}};var tt=class{constructor(t){this._transport=t}getRelativeURL({id:t,vcf:e={}}){let n=e.variant??"vcard",r=e.format??(n==="vcard"?"vcf":"json");return"v1/contacts/"+encodeURIComponent(t)+"/vcf?variant="+encodeURIComponent(n)+"&format="+encodeURIComponent(r)}getURL(t){return this._transport.getURL(this.getRelativeURL(t))}send(t){return this._transport.send(this.getURL(t),{method:"GET"})}};var et=class{constructor(t){this._transport=t}send({body:t,request:e={}}){return this._transport.send("v1/contacts",{...e,method:"POST",json:t})}};var ot=class{constructor(t){this._transport=t}send(t,{include:e,request:n={}}={}){return this._transport.send("v1/contacts/"+encodeURIComponent(t),{...n,method:"GET",searchParams:[...this._transport.includeQuery(e??{})]})}};var nt=class{constructor(t){this._transport=t}send({limit:t,query:e,request:n={}}={}){return this._transport.send("v1/contacts",{...n,method:"GET",searchParams:[...this._transport.limitQuery(t),...this._transport.queryQuery(e)]})}};var rt=class{constructor(t){this._transport=t}send(t,{body:e,request:n={}}){return this._transport.send("v1/contacts/"+encodeURIComponent(t),{...n,method:"PATCH",json:e})}};var st=class{constructor(t){this._transport=t}send(t,{limit:e,request:n={}}={}){return this._transport.send("v1/contacts/"+encodeURIComponent(t)+"/conversations",{...n,method:"GET",searchParams:[...this._transport.limitQuery(e)]})}};var it=class{constructor(t){this._transport=t}send(t,{limit:e,request:n={}}={}){return this._transport.send("v1/contacts/"+encodeURIComponent(t)+"/labels",{...n,method:"GET",searchParams:[...this._transport.limitQuery(e)]})}};var at=class{constructor(t){this._transport=t}send(t,{body:e,request:n={}}){return this._transport.send("v1/contacts/"+encodeURIComponent(t)+"/notes",{...n,method:"POST",json:e})}};var pt=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/contacts/"+encodeURIComponent(t)+"/notes",{...e,method:"GET"})}};var ct=class{constructor(t){this._transport=t}send(t,{body:e,request:n={}}){return this._transport.send("v1/contacts/"+encodeURIComponent(t)+"/notification-subscriptions",{...n,method:"POST",json:e})}};var dt=class{constructor(t){this._transport=t}get api(){return{get:new ot(this._transport),list:new nt(this._transport),update:new rt(this._transport),create:new et(this._transport),conversation:{list:new st(this._transport)},label:{list:new it(this._transport)},note:{list:new pt(this._transport),create:new at(this._transport)},notificationSubscription:{create:new ct(this._transport)},vcf:{get:new tt(this._transport)}}}};var lt=class{constructor(t){this._transport=t}send(t,{include:e,request:n={}}={}){return this._transport.send("v1/conversations/"+encodeURIComponent(t),{...n,method:"GET",searchParams:[...this._transport.includeQuery(e??{})]})}};var mt=class{constructor(t){this._transport=t}send({limit:t,filter:e,include:n,request:r={}}={}){return this._transport.send("v1/conversations",{...r,method:"GET",searchParams:[...this._transport.limitQuery(t),...e?[["filter",e]]:[],...this._transport.includeQuery(n??{})]})}};var ut=class{constructor(t){this._transport=t}send(t,{body:e,request:n={}}){return this._transport.send("v1/conversations/"+encodeURIComponent(t),{...n,method:"PATCH",json:e})}};var ht=class{constructor(t){this._transport=t}send(t,{limit:e,request:n={}}={}){return this._transport.send("v1/conversations/"+encodeURIComponent(t)+"/labels",{...n,method:"GET",searchParams:[...this._transport.limitQuery(e)]})}};var ft=class{constructor(t){this._transport=t}send(t,{limit:e,include:n,request:r={}}={}){return this._transport.send("v1/conversations/"+encodeURIComponent(t)+"/messages",{...r,method:"GET",searchParams:[...this._transport.limitQuery(e),...this._transport.includeQuery(n??{})]})}};var m=class{constructor(t){this._transport=t}send(t,{body:e,request:n={}}){return this._transport.send("v1/conversations/"+encodeURIComponent(t)+"/notes",{...n,method:"POST",json:e})}};var Ct=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/conversations/"+encodeURIComponent(t)+"/notes",{...e,method:"GET"})}};var gt=class{constructor(t){this._transport=t}get api(){return{get:new lt(this._transport),list:new mt(this._transport),update:new ut(this._transport),create:new m(this._transport),label:{list:new ht(this._transport)},message:{list:new ft(this._transport)},note:{list:new Ct(this._transport),create:new m(this._transport)}}}};var Ot=class{constructor(t){this._transport=t}send(t,{limit:e,request:n={}}={}){return this._transport.send("v1/labels/"+encodeURIComponent(t)+"/contacts",{...n,method:"GET",searchParams:[...this._transport.limitQuery(e)]})}};var bt=class{constructor(t){this._transport=t}send(t,{limit:e,request:n={}}={}){return this._transport.send("v1/labels/"+encodeURIComponent(t)+"/conversations",{...n,method:"GET",searchParams:[...this._transport.limitQuery(e)]})}};var yt=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 St=class{constructor(t){this._transport=t}send({limit:t,query:e,include:n,request:r={}}={}){return this._transport.send("v1/labels",{...r,method:"GET",searchParams:[...this._transport.limitQuery(t),...this._transport.queryQuery(e),...this._transport.includeQuery(n??{})]})}};var Tt=class{constructor(t){this._transport=t}send(t,{body:e,request:n={}}){return this._transport.send("v1/labels/"+encodeURIComponent(t),{...n,method:"PATCH",json:e})}};var vt=class{constructor(t){this._transport=t}get api(){return{create:new yt(this._transport),get:new _t(this._transport),list:new St(this._transport),update:new Tt(this._transport),delete:new xt(this._transport),contact:{list:new Ot(this._transport)},conversation:{list:new bt(this._transport)}}}};var Rt=class{constructor(t){this._transport=t}send({limit:t,include:e,request:n={}}={}){return this._transport.send("v1/messages",{...n,method:"GET",searchParams:[...this._transport.limitQuery(t),...this._transport.includeQuery(e??{})]})}};var wt=class{constructor(t){this._transport=t}get api(){return{list:new Rt(this._transport)}}};var Ft=class{constructor(t){this._transport=t}send(t,{body:e,request:n={}}){return this._transport.send("v1/models/"+encodeURIComponent(t)+"/correction",{...n,method:"POST",json:e})}};var Lt=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/models/"+encodeURIComponent(t),{...e,method:"GET"})}};var Ut=class{constructor(t){this._transport=t}send({request:t={}}={}){return this._transport.send("v1/models",{...t,method:"GET"})}};var At=class{constructor(t){this._transport=t}send(t,{body:e,request:n={}}){return this._transport.send("v1/models/"+encodeURIComponent(t)+"/response",{...n,method:"POST",timeout:12e4,json:e})}};var Et=class{constructor(t){this._transport=t}get api(){return{get:new Lt(this._transport),list:new Ut(this._transport),response:{create:new At(this._transport)},correction:{create:new Ft(this._transport)}}}};var Gt=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/notes/"+encodeURIComponent(t),{...e,method:"GET"})}};var Pt=class{constructor(t){this._transport=t}send(t,{body:e,request:n={}}){return this._transport.send("v1/notes/"+encodeURIComponent(t),{...n,method:"PATCH",json:e})}};var It=class{constructor(t){this._transport=t}get api(){return{get:new Gt(this._transport),update:new Pt(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 Nt=class{constructor(t){this._transport=t}send({category:t,request:e={}}={}){let n=[];if(t){let r=Array.isArray(t)?t:[t];for(let i of r)n.push(["category",i])}return this._transport.send("v1/sources",{...e,method:"GET",searchParams:n})}};var Bt=class{constructor(t){this._transport=t}get api(){return{get:new qt(this._transport),list:new Nt(this._transport)}}};var Mt=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/channels/"+encodeURIComponent(t)+"/statistics/message-frequency",{...e,method:"GET"})}};var jt=class{constructor(t){this._transport=t}send({request:t={}}={}){return this._transport.send("v1/statistics/message-frequency",{...t,method:"GET"})}};var kt=class{constructor(t){this._transport=t}get api(){return{messageFrequency:new jt(this._transport),channelMessageFrequency:new Mt(this._transport)}}};var Dt=class{constructor(t){this._transport=t}send({account:t,files:e,request:n={}}){let r=new FormData;for(let i of e)r.append("file",i);return this._transport.send("v1/uploads",{...n,method:"POST",body:r,searchParams:{account:t}})}};var Qt=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 Dt(this._transport),delete:new Qt(this._transport)}}};var Vt=class{constructor(t){this._transport=t}send({request:t={}}={}){return this._transport.send(".well-known/notifications",{...t,method:"GET"})}};var Wt=class{constructor(t){this._transport=t}get api(){return{notification:{get:new Vt(this._transport)}}}};var Yt=class o{static DEFAULT_BASE_URL=Re;_transport;_account;_accountAccessToken;_accountConversationSettings;_action;_boilerplate;_boilerplateCategory;_channel;_compositionSection;_contact;_conversation;_label;_message;_model;_note;_source;_statistics;_upload;_webhook;_wellKnown;constructor(t,{baseURL:e,...n}={}){this._transport=new O({requestFilterables:[new h,t],...n,baseURL:e?.toString()??o.getBaseURL()}),this._account=new T(this._transport),this._accountAccessToken=new x(this._transport),this._accountConversationSettings=new w(this._transport),this._action=new L(this._transport),this._boilerplate=new j(this._transport),this._boilerplateCategory=new I(this._transport),this._channel=new Y(this._transport),this._compositionSection=new Z(this._transport),this._contact=new dt(this._transport),this._conversation=new gt(this._transport),this._label=new vt(this._transport),this._message=new wt(this._transport),this._model=new Et(this._transport),this._note=new It(this._transport),this._source=new Bt(this._transport),this._statistics=new kt(this._transport),this._upload=new Kt(this._transport),this._webhook=new b(this),this._wellKnown=new Wt(this._transport)}static getBaseURL(){return process.env[ve]??this.DEFAULT_BASE_URL}get account(){return this._account.api}get accountAccessToken(){return this._accountAccessToken.api}get accountConversationSettings(){return this._accountConversationSettings.api}get action(){return this._action.api}get boilerplate(){return this._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 ie=require("commander"),Le=require("ora");function ae({client:o,ora:t}){let e=new ie.Command("actions").description("Actions");return e.addCommand(new ie.Command("list").description("List actions").action(async()=>{let n=await(0,Le.oraPromise)(()=>o.action.list.send().json(),{...t,text:"Finding actions"});console.log(n)})),e}var pe=require("commander"),Ue=require("ora");function ce({client:o,ora:t}){let e=new pe.Command("channels").description("Channels");return e.addCommand(new pe.Command("list").description("List channels").action(async()=>{let n=await(0,Ue.oraPromise)(()=>o.channel.list.send().json(),{...t,text:"Finding channels"});console.log(n)})),e}var zt=require("commander"),Zt=require("ora");function de({client:o,ora:t}){let e=new zt.Command("contacts").description("Contacts");return e.addCommand(new zt.Command("get").description("Find contact").argument("<contact>","Contact ID").action(async n=>{let r=await(0,Zt.oraPromise)(()=>o.contact.get.send(n).json(),{...t,text:"Finding contact"});console.log(r)})),e.addCommand(new zt.Command("list").description("List contacts").action(async()=>{let n=await(0,Zt.oraPromise)(()=>o.contact.list.send().json(),{...t,text:"Finding contacts"});console.log(n)})),e.addCommand(new zt.Command("get-vcf").description("Export Contact as VCF").argument("<contact>","Contact ID").action(async n=>{let r=await(0,Zt.oraPromise)(()=>o.contact.vcf.get.send({id:n}).response(),{...t,text:"Exporting contact"});console.log(r)})),e}var te=require("commander"),le=require("ora");function me({client:o,ora:t}){let e=new te.Command("conversations").description("Conversations");return e.addCommand(new te.Command("get").description("Find conversation").argument("<conversation>","Conversation ID").action(async n=>{let r=await(0,le.oraPromise)(()=>o.conversation.get.send(n).json(),{...t,text:"Finding conversation"});console.log(r)})),e.addCommand(new te.Command("list").description("List conversations").action(async()=>{let n=await(0,le.oraPromise)(()=>o.conversation.list.send().json(),{...t,text:"Finding conversations"});console.log(n)})),e}var Jt=require("commander"),ee=require("ora");function ue({client:o,ora:t}){let e=new Jt.Command("labels").description("Labels");return e.addCommand(new Jt.Command("get").description("Find label").argument("<label>","Label ID").action(async n=>{let r=await(0,ee.oraPromise)(()=>o.label.get.send(n).json(),{...t,text:"Finding label"});console.log(r)})),e.addCommand(new Jt.Command("list").description("List labels").action(async()=>{let n=await(0,ee.oraPromise)(()=>o.label.list.send().json(),{...t,text:"Finding labels"});console.log(n)})),e.addCommand(new Jt.Command("conversations").description("Find label conversations").argument("<label>","Label ID").action(async n=>{let r=await(0,ee.oraPromise)(()=>o.label.conversation.list.send(n).json(),{...t,text:"Finding conversations"});console.log(r)})),e}var he=require("commander"),Ae=require("ora");function fe({client:o,ora:t}){let e=new he.Command("messages").description("Messages");return e.addCommand(new he.Command("list").description("List messages").action(async()=>{let n=await(0,Ae.oraPromise)(()=>o.message.list.send().json(),{...t,text:"Finding messages"});console.log(n)})),e}var oe=require("commander"),Ce=require("ora");function ge({client:o,ora:t}){let e=new oe.Command("models").description("Models");return e.addCommand(new oe.Command("get").description("Find model").argument("<model>","Model ID").action(async n=>{let r=await(0,Ce.oraPromise)(()=>o.model.get.send(n).json(),{...t,text:"Finding model"});console.log(r)})),e.addCommand(new oe.Command("list").description("List models").action(async()=>{let n=await(0,Ce.oraPromise)(()=>o.model.list.send().json(),{...t,text:"Finding models"});console.log(n)})),e}var ne=require("commander"),Oe=require("ora");function be({client:o,ora:t}){let e=new ne.Command("sources").description("Sources");return e.addCommand(new ne.Command("get").description("Find source").argument("<source>","Source ID").action(async n=>{let r=await(0,Oe.oraPromise)(()=>o.source.get.send(n).json(),{...t,text:"Finding source"});console.log(r)})),e.addCommand(new ne.Command("list").description("List sources").action(async()=>{let n=await(0,Oe.oraPromise)(()=>o.source.list.send().json(),{...t,text:"Finding sources"});console.log(n)})),e}var Ge=require("commander");var ye=require("commander"),Ee=require("ora");function xe({client:o,ora:t}){let e=new ye.Command("notifications").description("Well-Known Notifications Details");return e.addCommand(new ye.Command("get").description("Get Notifications Server Well-Known Info").action(async()=>{let n=await(0,Ee.oraPromise)(()=>o.wellKnown.notification.get.send().json(),{...t,text:"Finding Notifications Well-Known Info"});console.log(n)})),e}function _e({client:o,ora:t}){let e=new Ge.Command("well-known").description("Well-Known Metadata & Info");return e.addCommand(xe({client:o,ora:t})),e}var p={ora:{spinner:"simpleDotsScrolling"},client:new Yt(new u)},Qe=new Pe.Command("gds").description("Great Detail Support System").addCommand(ae(p)).addCommand(ce(p)).addCommand(de(p)).addCommand(me(p)).addCommand(ue(p)).addCommand(fe(p)).addCommand(ge(p)).addCommand(be(p)).addCommand(_e(p)),Ie=Qe;Ie.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-
|
|
2
|
+
import{a as r}from"./chunk-HB5Z3WZ2.js";import"./chunk-EWJFCLFP.js";r.parseAsync(process.argv);
|
|
@@ -1675,6 +1675,39 @@ declare class GetAccountConversationSettings {
|
|
|
1675
1675
|
};
|
|
1676
1676
|
}
|
|
1677
1677
|
|
|
1678
|
+
/**
|
|
1679
|
+
* Great Detail Support System.
|
|
1680
|
+
*
|
|
1681
|
+
* @copyright 2024 Great Detail Ltd
|
|
1682
|
+
* @author Great Detail Ltd <info@greatdetail.com>
|
|
1683
|
+
* @author Dom Webber <dom.webber@greatdetail.com>
|
|
1684
|
+
* @see https://greatdetail.com
|
|
1685
|
+
*/
|
|
1686
|
+
|
|
1687
|
+
type AccountAccessToken = {
|
|
1688
|
+
id: string;
|
|
1689
|
+
account: string;
|
|
1690
|
+
name?: string;
|
|
1691
|
+
excerpt?: string;
|
|
1692
|
+
} & ResponseTimestamp;
|
|
1693
|
+
|
|
1694
|
+
interface ListAccountAccessTokensOptions {
|
|
1695
|
+
request?: SendOptions;
|
|
1696
|
+
}
|
|
1697
|
+
type ListAccountAccessTokensResponse = {
|
|
1698
|
+
data: {
|
|
1699
|
+
accountAccessToken: AccountAccessToken;
|
|
1700
|
+
}[];
|
|
1701
|
+
};
|
|
1702
|
+
declare class ListAccountAccessTokens {
|
|
1703
|
+
protected _transport: FetchTransport;
|
|
1704
|
+
constructor(_transport: FetchTransport);
|
|
1705
|
+
send(account: string, { request }?: ListAccountAccessTokensOptions): {
|
|
1706
|
+
response: () => Promise<ky.KyResponse<ListAccountAccessTokensResponse>>;
|
|
1707
|
+
json: () => Promise<ListAccountAccessTokensResponse>;
|
|
1708
|
+
};
|
|
1709
|
+
}
|
|
1710
|
+
|
|
1678
1711
|
/**
|
|
1679
1712
|
* Great Detail Support System.
|
|
1680
1713
|
*
|
|
@@ -2088,6 +2121,23 @@ declare class Webhook {
|
|
|
2088
2121
|
protected _verifySignature(key: string, body: object, signatures: string[]): Promise<boolean>;
|
|
2089
2122
|
}
|
|
2090
2123
|
|
|
2124
|
+
/**
|
|
2125
|
+
* Great Detail Support System.
|
|
2126
|
+
*
|
|
2127
|
+
* @copyright 2024 Great Detail Ltd
|
|
2128
|
+
* @author Great Detail Ltd <info@greatdetail.com>
|
|
2129
|
+
* @author Dom Webber <dom.webber@greatdetail.com>
|
|
2130
|
+
* @see https://greatdetail.com
|
|
2131
|
+
*/
|
|
2132
|
+
|
|
2133
|
+
declare class AccountAccessTokenClient {
|
|
2134
|
+
protected _transport: FetchTransport;
|
|
2135
|
+
constructor(_transport: FetchTransport);
|
|
2136
|
+
get api(): {
|
|
2137
|
+
list: ListAccountAccessTokens;
|
|
2138
|
+
};
|
|
2139
|
+
}
|
|
2140
|
+
|
|
2091
2141
|
/**
|
|
2092
2142
|
* Great Detail Support System.
|
|
2093
2143
|
*
|
|
@@ -2466,6 +2516,7 @@ declare class Client {
|
|
|
2466
2516
|
static DEFAULT_BASE_URL: string;
|
|
2467
2517
|
_transport: FetchTransport;
|
|
2468
2518
|
protected _account: AccountClient;
|
|
2519
|
+
protected _accountAccessToken: AccountAccessTokenClient;
|
|
2469
2520
|
protected _accountConversationSettings: AccountConversationSettingsClient;
|
|
2470
2521
|
protected _action: ActionClient;
|
|
2471
2522
|
protected _boilerplate: BoilerplateClient;
|
|
@@ -2489,6 +2540,9 @@ declare class Client {
|
|
|
2489
2540
|
get: GetAccount;
|
|
2490
2541
|
update: UpdateAccount;
|
|
2491
2542
|
};
|
|
2543
|
+
get accountAccessToken(): {
|
|
2544
|
+
list: ListAccountAccessTokens;
|
|
2545
|
+
};
|
|
2492
2546
|
get accountConversationSettings(): {
|
|
2493
2547
|
get: GetAccountConversationSettings;
|
|
2494
2548
|
update: UpdateAccountConversationSettings;
|
|
@@ -2621,4 +2675,4 @@ declare class Client {
|
|
|
2621
2675
|
};
|
|
2622
2676
|
}
|
|
2623
2677
|
|
|
2624
|
-
export { type
|
|
2678
|
+
export { type DeleteLabelResponse as $, type Authentication as A, type Boilerplate as B, Client as C, type ListCompositionSectionsResponse as D, type CreateCompositionSectionResponse as E, type ListChannelCompositionSectionsResponse as F, type GetAccountResponse as G, type UpdateCompositionSectionResponse as H, type Contact as I, type CreateContactResponse as J, type GetContactResponse as K, type ListAccountAccessTokensResponse as L, type ListContactsResponse as M, type ListLabelContactsResponse as N, type Options as O, type UpdateContactResponse as P, type GetConversationResponse as Q, type RequestFilterable as R, type ListConversationsResponse as S, type TwilioSendgridChannelSyncResponse as T, type UpdateAccountResponse as U, type ListLabelConversationsResponse as V, type WebhookResponse as W, type UpdateConversationResponse as X, type ListContactConversationsResponse as Y, type Label as Z, type CreateLabelResponse as _, type Account as a, type GetLabelResponse as a0, type ListLabelsResponse as a1, type UpdateLabelResponse as a2, type ListConversationLabelsResponse as a3, type ListContactLabelsResponse as a4, type Message as a5, type ListConversationMessagesResponse as a6, type ListMessagesResponse as a7, type ListChannelMessagesResponse as a8, type Model as a9, type GetModelResponse as aa, type ListModelsResponse as ab, type CreateCorrectionResponse as ac, type CreateResponseResponse as ad, type Note as ae, type CreateContactNoteResponse as af, type CreateConversationNoteResponse as ag, type GetNoteResponse as ah, type ListContactNotesResponse as ai, type ListConversationNotesResponse as aj, type UpdateNoteResponse as ak, type Source as al, type GetSourceResponse as am, type ListSourcesResponse as an, type NotificationSubscription as ao, type CreateContactNotificationSubscriptionResponse as ap, type Upload as aq, type CreateUploadResponse as ar, type GetUploadResponse as as, type DeleteUploadResponse as at, type GetNotificationWellKnownResponse as au, type Conversation as b, type Options$3 as c, type AccountAccessToken as d, type AccountConversationSettings as e, type GetAccountConversationSettingsResponse as f, type UpdateAccountConversationSettingsResponse as g, type Action as h, type ListActionsResponse as i, type CreateBoilerplateResponse as j, type ListBoilerplateCategoryBoilerplatesResponse as k, type GetBoilerplateResponse as l, type ListBoilerplatesResponse as m, type UpdateBoilerplateResponse as n, type BoilerplateCategory as o, type CreateBoilerplateCategoryResponse as p, type GetBoilerplateCategoryResponse as q, type ListBoilerplateCategoriesResponse as r, type UpdateBoilerplateCategoryResponse as s, type Channel as t, type ListChannelsResponse as u, type GetChannelResponse as v, type UpdateChannelResponse as w, type CreateChannelResponse as x, type CompositionSection as y, type GetCompositionSectionResponse as z };
|
|
@@ -1675,6 +1675,39 @@ declare class GetAccountConversationSettings {
|
|
|
1675
1675
|
};
|
|
1676
1676
|
}
|
|
1677
1677
|
|
|
1678
|
+
/**
|
|
1679
|
+
* Great Detail Support System.
|
|
1680
|
+
*
|
|
1681
|
+
* @copyright 2024 Great Detail Ltd
|
|
1682
|
+
* @author Great Detail Ltd <info@greatdetail.com>
|
|
1683
|
+
* @author Dom Webber <dom.webber@greatdetail.com>
|
|
1684
|
+
* @see https://greatdetail.com
|
|
1685
|
+
*/
|
|
1686
|
+
|
|
1687
|
+
type AccountAccessToken = {
|
|
1688
|
+
id: string;
|
|
1689
|
+
account: string;
|
|
1690
|
+
name?: string;
|
|
1691
|
+
excerpt?: string;
|
|
1692
|
+
} & ResponseTimestamp;
|
|
1693
|
+
|
|
1694
|
+
interface ListAccountAccessTokensOptions {
|
|
1695
|
+
request?: SendOptions;
|
|
1696
|
+
}
|
|
1697
|
+
type ListAccountAccessTokensResponse = {
|
|
1698
|
+
data: {
|
|
1699
|
+
accountAccessToken: AccountAccessToken;
|
|
1700
|
+
}[];
|
|
1701
|
+
};
|
|
1702
|
+
declare class ListAccountAccessTokens {
|
|
1703
|
+
protected _transport: FetchTransport;
|
|
1704
|
+
constructor(_transport: FetchTransport);
|
|
1705
|
+
send(account: string, { request }?: ListAccountAccessTokensOptions): {
|
|
1706
|
+
response: () => Promise<ky.KyResponse<ListAccountAccessTokensResponse>>;
|
|
1707
|
+
json: () => Promise<ListAccountAccessTokensResponse>;
|
|
1708
|
+
};
|
|
1709
|
+
}
|
|
1710
|
+
|
|
1678
1711
|
/**
|
|
1679
1712
|
* Great Detail Support System.
|
|
1680
1713
|
*
|
|
@@ -2088,6 +2121,23 @@ declare class Webhook {
|
|
|
2088
2121
|
protected _verifySignature(key: string, body: object, signatures: string[]): Promise<boolean>;
|
|
2089
2122
|
}
|
|
2090
2123
|
|
|
2124
|
+
/**
|
|
2125
|
+
* Great Detail Support System.
|
|
2126
|
+
*
|
|
2127
|
+
* @copyright 2024 Great Detail Ltd
|
|
2128
|
+
* @author Great Detail Ltd <info@greatdetail.com>
|
|
2129
|
+
* @author Dom Webber <dom.webber@greatdetail.com>
|
|
2130
|
+
* @see https://greatdetail.com
|
|
2131
|
+
*/
|
|
2132
|
+
|
|
2133
|
+
declare class AccountAccessTokenClient {
|
|
2134
|
+
protected _transport: FetchTransport;
|
|
2135
|
+
constructor(_transport: FetchTransport);
|
|
2136
|
+
get api(): {
|
|
2137
|
+
list: ListAccountAccessTokens;
|
|
2138
|
+
};
|
|
2139
|
+
}
|
|
2140
|
+
|
|
2091
2141
|
/**
|
|
2092
2142
|
* Great Detail Support System.
|
|
2093
2143
|
*
|
|
@@ -2466,6 +2516,7 @@ declare class Client {
|
|
|
2466
2516
|
static DEFAULT_BASE_URL: string;
|
|
2467
2517
|
_transport: FetchTransport;
|
|
2468
2518
|
protected _account: AccountClient;
|
|
2519
|
+
protected _accountAccessToken: AccountAccessTokenClient;
|
|
2469
2520
|
protected _accountConversationSettings: AccountConversationSettingsClient;
|
|
2470
2521
|
protected _action: ActionClient;
|
|
2471
2522
|
protected _boilerplate: BoilerplateClient;
|
|
@@ -2489,6 +2540,9 @@ declare class Client {
|
|
|
2489
2540
|
get: GetAccount;
|
|
2490
2541
|
update: UpdateAccount;
|
|
2491
2542
|
};
|
|
2543
|
+
get accountAccessToken(): {
|
|
2544
|
+
list: ListAccountAccessTokens;
|
|
2545
|
+
};
|
|
2492
2546
|
get accountConversationSettings(): {
|
|
2493
2547
|
get: GetAccountConversationSettings;
|
|
2494
2548
|
update: UpdateAccountConversationSettings;
|
|
@@ -2621,4 +2675,4 @@ declare class Client {
|
|
|
2621
2675
|
};
|
|
2622
2676
|
}
|
|
2623
2677
|
|
|
2624
|
-
export { type
|
|
2678
|
+
export { type DeleteLabelResponse as $, type Authentication as A, type Boilerplate as B, Client as C, type ListCompositionSectionsResponse as D, type CreateCompositionSectionResponse as E, type ListChannelCompositionSectionsResponse as F, type GetAccountResponse as G, type UpdateCompositionSectionResponse as H, type Contact as I, type CreateContactResponse as J, type GetContactResponse as K, type ListAccountAccessTokensResponse as L, type ListContactsResponse as M, type ListLabelContactsResponse as N, type Options as O, type UpdateContactResponse as P, type GetConversationResponse as Q, type RequestFilterable as R, type ListConversationsResponse as S, type TwilioSendgridChannelSyncResponse as T, type UpdateAccountResponse as U, type ListLabelConversationsResponse as V, type WebhookResponse as W, type UpdateConversationResponse as X, type ListContactConversationsResponse as Y, type Label as Z, type CreateLabelResponse as _, type Account as a, type GetLabelResponse as a0, type ListLabelsResponse as a1, type UpdateLabelResponse as a2, type ListConversationLabelsResponse as a3, type ListContactLabelsResponse as a4, type Message as a5, type ListConversationMessagesResponse as a6, type ListMessagesResponse as a7, type ListChannelMessagesResponse as a8, type Model as a9, type GetModelResponse as aa, type ListModelsResponse as ab, type CreateCorrectionResponse as ac, type CreateResponseResponse as ad, type Note as ae, type CreateContactNoteResponse as af, type CreateConversationNoteResponse as ag, type GetNoteResponse as ah, type ListContactNotesResponse as ai, type ListConversationNotesResponse as aj, type UpdateNoteResponse as ak, type Source as al, type GetSourceResponse as am, type ListSourcesResponse as an, type NotificationSubscription as ao, type CreateContactNotificationSubscriptionResponse as ap, type Upload as aq, type CreateUploadResponse as ar, type GetUploadResponse as as, type DeleteUploadResponse as at, type GetNotificationWellKnownResponse as au, type Conversation as b, type Options$3 as c, type AccountAccessToken as d, type AccountConversationSettings as e, type GetAccountConversationSettingsResponse as f, type UpdateAccountConversationSettingsResponse as g, type Action as h, type ListActionsResponse as i, type CreateBoilerplateResponse as j, type ListBoilerplateCategoryBoilerplatesResponse as k, type GetBoilerplateResponse as l, type ListBoilerplatesResponse as m, type UpdateBoilerplateResponse as n, type BoilerplateCategory as o, type CreateBoilerplateCategoryResponse as p, type GetBoilerplateCategoryResponse as q, type ListBoilerplateCategoriesResponse as r, type UpdateBoilerplateCategoryResponse as s, type Channel as t, type ListChannelsResponse as u, type GetChannelResponse as v, type UpdateChannelResponse as w, type CreateChannelResponse as x, type CompositionSection as y, type GetCompositionSectionResponse as z };
|
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
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,{BearerAuthentication:()=>C,Client:()=>f,DEFAULT_SUPPORT_BASE_URL:()=>$t,Error:()=>te,KeyAuthentication:()=>Vt,PublicAuthentication:()=>Wt,TokenAuthentication:()=>C,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",pe="SUPPORT_API_KEY",ae="SUPPORT_KEY_NAME",Xt="SUPPORT_SIGNING_KEY",ce="SUPPORT_BASE_URL";var g=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 de=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 l=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 a=class extends i{static notFound(t){return new this(`Record not found for request: ${t}`)}static forbiddenMethod(t,e){return new this(`Forbidden method for request: ${t} ${e}`)}static teapot(){return new this("I'm a teapot")}static rateLimited(){return new this("Request has been rate-limited")}};var m=class extends i{};var d=class extends i{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 s of this.options.requestFilterables){let p=s.getHeaders();for(let[Yt,le]of Object.entries(p))r.headers.has(Yt)||r.headers.set(Yt,le)}}]}})}getURL(t){return new URL(t,this.options.baseURL).toString()}sortQuery(t){let e=[];if(t===void 0)return e;for(let[r,s]of Object.entries(t))s!==void 0&&e.push(["sort",s+r]);return e}limitQuery(t){let e=[];return t===void 0||e.push(["limit",t.toString()]),e}includeQuery(t){let e=[];if(t===void 0)return e;for(let r of Object.keys(t))e.push(["include",r]);return e}queryQuery(t){let e=[];return t===void 0||e.push(["query",t]),e}send(t,e={}){let r=this.client(t,e).catch(s=>{if((0,de.default)(s))throw new m("A network error occurred",{cause:s});if(s instanceof Jt.HTTPError){let p=s.response.status;switch(console.error(JSON.stringify(s.response)),p){case 400:throw d.badRequest();case 401:throw l.unauthenticated();case 403:throw u.forbidden();case 404:throw a.notFound(t);case 405:throw a.forbiddenMethod(t,e.method??"GET");case 415:throw d.unsupportedMediaType();case 418:throw a.teapot();case 429:throw a.rateLimited()}if(p>=500&&p<600)throw i.serverError(p)}throw s});return{response:()=>r,json:async()=>(await r).json()}}};var n=require("zod");var _=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:p}=o.SCHEMA.parse(r.body);return{event:p.event}}async _verifySignature(t,e,r){let s=await crypto.subtle.importKey("raw",new TextEncoder().encode(t),{name:"HMAC",hash:"SHA-256"},!1,["sign","verify"]);for(let p of r)if(await crypto.subtle.verify("HMAC",s,new TextEncoder().encode(atob(p)),new TextEncoder().encode(JSON.stringify(e))))return!0;return!1}};var x=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/accounts/"+encodeURIComponent(t),{...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),{...r,method:"PATCH",json:e})}};var y=class{constructor(t){this._transport=t}get api(){return{get:new x(this._transport),update:new O(this._transport)}}};var S=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 R=class{constructor(t){this._transport=t}get api(){return{get:new S(this._transport),update:new T(this._transport)}}};var v=class{constructor(t){this._transport=t}send({limit:t,sort:e,request:r={}}={}){return this._transport.send("v1/actions",{...r,method:"GET",searchParams:[...this._transport.limitQuery(t),...this._transport.sortQuery(e)]})}};var F=class{constructor(t){this._transport=t}get api(){return{list:new v(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 w=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 A=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 E=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 G=class{constructor(t){this._transport=t}get api(){return{get:new U(this._transport),list:new A(this._transport),create:new w(this._transport),update:new E(this._transport),boilerplate:{list:new L(this._transport)}}}};var P=class{constructor(t){this._transport=t}send({body:t,request:e={}}){return this._transport.send("v1/boilerplates",{...e,method:"POST",json:t})}};var q=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/boilerplates/"+encodeURIComponent(t),{...e,method:"GET"})}};var N=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 I=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 q(this._transport),list:new N(this._transport),update:new I(this._transport),create:new P(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 Q=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 D=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 k=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,include:r,request:s={}}={}){return this._transport.send("v1/channels/"+encodeURIComponent(t)+"/messages",{...s,method:"GET",searchParams:[...this._transport.limitQuery(e),...this._transport.includeQuery(r)]})}};var V=class{constructor(t){this._transport=t}get api(){return{get:new Q(this._transport),list:new j(this._transport),update:new D(this._transport),create:new M(this._transport),compositionSection:{list:new k(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 $=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 J=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 $(this._transport)}}};var X=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 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 pt=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 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 pt(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 dt=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 ut=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 mt=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 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 dt(this._transport),update:new lt(this._transport),create:new h(this._transport),label:{list:new ut(this._transport)},message:{list:new mt(this._transport)},note:{list:new ht(this._transport),create:new h(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 _t=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/labels/"+encodeURIComponent(t),{...e,method:"DELETE"})}};var xt=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/labels/"+encodeURIComponent(t),{...e,method:"GET"})}};var Ot=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 St=class{constructor(t){this._transport=t}get api(){return{create:new bt(this._transport),get:new xt(this._transport),list:new Ot(this._transport),update:new yt(this._transport),delete:new _t(this._transport),contact:{list:new Ct(this._transport)},conversation:{list:new gt(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 Rt=class{constructor(t){this._transport=t}get api(){return{list:new Tt(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 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 wt=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 wt(this._transport)},correction:{create:new vt(this._transport)}}}};var At=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/notes/"+encodeURIComponent(t),{...e,method:"GET"})}};var Et=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 Gt=class{constructor(t){this._transport=t}get api(){return{get:new At(this._transport),update:new Et(this._transport)}}};var Pt=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/sources/"+encodeURIComponent(t),{...e,method:"GET"})}};var qt=class{constructor(t){this._transport=t}send({category:t,request:e={}}={}){let r=[];if(t){let s=Array.isArray(t)?t:[t];for(let p of s)r.push(["category",p])}return this._transport.send("v1/sources",{...e,method:"GET",searchParams:r})}};var Nt=class{constructor(t){this._transport=t}get api(){return{get:new Pt(this._transport),list:new qt(this._transport)}}};var It=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/channels/"+encodeURIComponent(t)+"/statistics/message-frequency",{...e,method:"GET"})}};var 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 It(this._transport)}}};var Qt=class{constructor(t){this._transport=t}send({account:t,files:e,request:r={}}){let s=new FormData;for(let p of e)s.append("file",p);return this._transport.send("v1/uploads",{...r,method:"POST",body:s,searchParams:{account:t}})}};var 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 Dt=class{constructor(t){this._transport=t}get api(){return{get:new Ht(this._transport),create:new Qt(this._transport),delete:new jt(this._transport)}}};var kt=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 kt(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 b({requestFilterables:[new g,t],...r,baseURL:e?.toString()??o.getBaseURL()}),this._account=new y(this._transport),this._accountConversationSettings=new R(this._transport),this._action=new F(this._transport),this._boilerplate=new B(this._transport),this._boilerplateCategory=new G(this._transport),this._channel=new V(this._transport),this._compositionSection=new J(this._transport),this._contact=new at(this._transport),this._conversation=new ft(this._transport),this._label=new St(this._transport),this._message=new Rt(this._transport),this._model=new Ut(this._transport),this._note=new Gt(this._transport),this._source=new Nt(this._transport),this._statistics=new Mt(this._transport),this._upload=new Dt(this._transport),this._webhook=new _(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:()=>l,AuthorizationError:()=>u,LogicError:()=>a,NetworkError:()=>m,SupportError:()=>i,ValidationError:()=>d});var Vt=class o{static DEFAULT_NAME=se;name;#t;constructor({name:t=process.env[ae]??o.DEFAULT_NAME,key:e=process.env[pe]}={}){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 C=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={BearerAuthentication,Client,DEFAULT_SUPPORT_BASE_URL,Error,KeyAuthentication,PublicAuthentication,TokenAuthentication});
|
|
1
|
+
"use strict";var he=Object.create;var Jt=Object.defineProperty;var fe=Object.getOwnPropertyDescriptor;var Ce=Object.getOwnPropertyNames;var ge=Object.getPrototypeOf,be=Object.prototype.hasOwnProperty;var re=(o,t)=>{for(var e in t)Jt(o,e,{get:t[e],enumerable:!0})},ne=(o,t,e,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of Ce(t))!be.call(o,s)&&s!==e&&Jt(o,s,{get:()=>t[s],enumerable:!(r=fe(t,s))||r.enumerable});return o};var se=(o,t,e)=>(e=o!=null?he(ge(o)):{},ne(t||!o||!o.__esModule?Jt(e,"default",{value:o,enumerable:!0}):e,o)),_e=o=>ne(Jt({},"__esModule",{value:!0}),o);var xe={};re(xe,{BearerAuthentication:()=>Yt,Client:()=>f,DEFAULT_SUPPORT_BASE_URL:()=>Xt,Error:()=>oe,KeyAuthentication:()=>Wt,PublicAuthentication:()=>zt,default:()=>f});module.exports=_e(xe);var Xt="https://api.support.greatdetail.com",ie={"X-Powered-By":"GDSupport/JavaScript"},pe="api-key";var ae="SUPPORT_ACCESS_TOKEN",ce="SUPPORT_API_KEY",de="SUPPORT_KEY_NAME",te="SUPPORT_SIGNING_KEY",le="SUPPORT_BASE_URL";var C=class o{constructor(t=o.STANDARD_HEADERS){this._standardHeaders=t}static STANDARD_HEADERS=ie;async filter(){return{headers:this.getHeaders()}}getHeaders(){return this._standardHeaders}};var ue=se(require("is-network-error"),1),Zt=se(require("ky"),1);var i=class extends Error{static serverError(t){return new this("Server Error: "+t)}};var c=class extends i{};var l=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 a=class extends i{static notFound(t){return new this(`Record not found for request: ${t}`)}static forbiddenMethod(t,e){return new this(`Forbidden method for request: ${t} ${e}`)}static teapot(){return new this("I'm a teapot")}static rateLimited(){return new this("Request has been rate-limited")}};var m=class extends i{};var d=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=Zt.default.create({prefixUrl:this.options.baseURL,timeout:12e3,hooks:{beforeRequest:[r=>{for(let s of this.options.requestFilterables){let p=s.getHeaders();for(let[$t,me]of Object.entries(p))r.headers.has($t)||r.headers.set($t,me)}}]}})}getURL(t){return new URL(t,this.options.baseURL).toString()}sortQuery(t){let e=[];if(t===void 0)return e;for(let[r,s]of Object.entries(t))s!==void 0&&e.push(["sort",s+r]);return e}limitQuery(t){let e=[];return t===void 0||e.push(["limit",t.toString()]),e}includeQuery(t){let e=[];if(t===void 0)return e;for(let r of Object.keys(t))e.push(["include",r]);return e}queryQuery(t){let e=[];return t===void 0||e.push(["query",t]),e}send(t,e={}){let r=this.client(t,e).catch(s=>{if((0,ue.default)(s))throw new m("A network error occurred",{cause:s});if(s instanceof Zt.HTTPError){let p=s.response.status;switch(console.error(JSON.stringify(s.response)),p){case 400:throw d.badRequest();case 401:throw l.unauthenticated();case 403:throw u.forbidden();case 404:throw a.notFound(t);case 405:throw a.forbiddenMethod(t,e.method??"GET");case 415:throw d.unsupportedMediaType();case 418:throw a.teapot();case 429:throw a.rateLimited()}if(p>=500&&p<600)throw i.serverError(p)}throw s});return{response:()=>r,json:async()=>(await r).json()}}};var n=require("zod");var 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[te],maxSignatures:e=3,request:r}){let s=r.headers["gds-signature"];if(t!==!1){if(t===void 0)throw new Error("Missing webhook signing key in process.env."+te);if(!s)throw new Error("Missing signature header");if(!this._verifySignature(t,r.body,Array.isArray(s)?s.slice(0,e):[s]))throw new Error("Untrusted signature")}let{data:p}=o.SCHEMA.parse(r.body);return{event:p.event}}async _verifySignature(t,e,r){let s=await crypto.subtle.importKey("raw",new TextEncoder().encode(t),{name:"HMAC",hash:"SHA-256"},!1,["sign","verify"]);for(let p of r)if(await crypto.subtle.verify("HMAC",s,new TextEncoder().encode(atob(p)),new TextEncoder().encode(JSON.stringify(e))))return!0;return!1}};var _=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/accounts/"+encodeURIComponent(t)+"/access-tokens",{...e,method:"GET"})}};var x=class{constructor(t){this._transport=t}get api(){return{list:new _(this._transport)}}};var O=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 S=class{constructor(t){this._transport=t}get api(){return{get:new O(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 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 v=class{constructor(t){this._transport=t}get api(){return{get:new T(this._transport),update:new R(this._transport)}}};var F=class{constructor(t){this._transport=t}send({limit:t,sort:e,request:r={}}={}){return this._transport.send("v1/actions",{...r,method:"GET",searchParams:[...this._transport.limitQuery(t),...this._transport.sortQuery(e)]})}};var L=class{constructor(t){this._transport=t}get api(){return{list:new F(this._transport)}}};var w=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 A=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/boilerplate-categories/"+encodeURIComponent(t),{...e,method:"GET"})}};var E=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 G=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 P=class{constructor(t){this._transport=t}get api(){return{get:new A(this._transport),list:new E(this._transport),create:new U(this._transport),update:new G(this._transport),boilerplate:{list:new w(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 N=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/boilerplates/"+encodeURIComponent(t),{...e,method:"GET"})}};var I=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 B=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 M=class{constructor(t){this._transport=t}get api(){return{get:new N(this._transport),list:new I(this._transport),update:new B(this._transport),create:new q(this._transport)}}};var k=class{constructor(t){this._transport=t}send({body:t,request:e={}}){return this._transport.send("v1/channels",{...e,method:"POST",json:t})}};var Q=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 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 D=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 K=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 V=class{constructor(t){this._transport=t}send(t,{limit:e,include:r,request:s={}}={}){return this._transport.send("v1/channels/"+encodeURIComponent(t)+"/messages",{...s,method:"GET",searchParams:[...this._transport.limitQuery(e),...this._transport.includeQuery(r)]})}};var W=class{constructor(t){this._transport=t}get api(){return{get:new Q(this._transport),list:new j(this._transport),update:new D(this._transport),create:new k(this._transport),compositionSection:{list:new K(this._transport)},message:{list:new V(this._transport)},twilioSendgrid:{sync:new H(this._transport)}}}};var Y=class{constructor(t){this._transport=t}send({body:t,request:e={}}){return this._transport.send("v1/composition-sections",{...e,method:"POST",json:t})}};var z=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/composition-sections/"+encodeURIComponent(t),{...e,method:"GET"})}};var $=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 X=class{constructor(t){this._transport=t}get api(){return{get:new z(this._transport),list:new $(this._transport),create:new Y(this._transport),update:new J(this._transport)}}};var Z=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 tt=class{constructor(t){this._transport=t}send({body:t,request:e={}}){return this._transport.send("v1/contacts",{...e,method:"POST",json:t})}};var et=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 ot=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 rt=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 nt=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 st=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 it=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 pt=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 ct=class{constructor(t){this._transport=t}get api(){return{get:new et(this._transport),list:new ot(this._transport),update:new rt(this._transport),create:new tt(this._transport),conversation:{list:new nt(this._transport)},label:{list:new st(this._transport)},note:{list:new pt(this._transport),create:new it(this._transport)},notificationSubscription:{create:new at(this._transport)},vcf:{get:new Z(this._transport)}}}};var dt=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:s={}}={}){return this._transport.send("v1/conversations",{...s,method:"GET",searchParams:[...this._transport.limitQuery(t),...e?[["filter",e]]:[],...this._transport.includeQuery(r??{})]})}};var ut=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 ht=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 ft=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/conversations/"+encodeURIComponent(t)+"/notes",{...e,method:"GET"})}};var Ct=class{constructor(t){this._transport=t}get api(){return{get:new dt(this._transport),list:new lt(this._transport),update:new ut(this._transport),create:new h(this._transport),label:{list:new mt(this._transport)},message:{list:new ht(this._transport)},note:{list:new ft(this._transport),create:new h(this._transport)}}}};var gt=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 bt=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 _t=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 Ot=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:s={}}={}){return this._transport.send("v1/labels",{...s,method:"GET",searchParams:[...this._transport.limitQuery(t),...this._transport.queryQuery(e),...this._transport.includeQuery(r??{})]})}};var St=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 _t(this._transport),get:new Ot(this._transport),list:new yt(this._transport),update:new St(this._transport),delete:new xt(this._transport),contact:{list:new gt(this._transport)},conversation:{list:new bt(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 vt=class{constructor(t){this._transport=t}get api(){return{list:new Rt(this._transport)}}};var Ft=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 wt=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 At=class{constructor(t){this._transport=t}get api(){return{get:new Lt(this._transport),list:new wt(this._transport),response:{create:new Ut(this._transport)},correction:{create:new Ft(this._transport)}}}};var Et=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/notes/"+encodeURIComponent(t),{...e,method:"GET"})}};var Gt=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 Pt=class{constructor(t){this._transport=t}get api(){return{get:new Et(this._transport),update:new Gt(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 Nt=class{constructor(t){this._transport=t}send({category:t,request:e={}}={}){let r=[];if(t){let s=Array.isArray(t)?t:[t];for(let p of s)r.push(["category",p])}return this._transport.send("v1/sources",{...e,method:"GET",searchParams:r})}};var It=class{constructor(t){this._transport=t}get api(){return{get:new qt(this._transport),list:new Nt(this._transport)}}};var Bt=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/channels/"+encodeURIComponent(t)+"/statistics/message-frequency",{...e,method:"GET"})}};var Mt=class{constructor(t){this._transport=t}send({request:t={}}={}){return this._transport.send("v1/statistics/message-frequency",{...t,method:"GET"})}};var kt=class{constructor(t){this._transport=t}get api(){return{messageFrequency:new Mt(this._transport),channelMessageFrequency:new Bt(this._transport)}}};var Qt=class{constructor(t){this._transport=t}send({account:t,files:e,request:r={}}){let s=new FormData;for(let p of e)s.append("file",p);return this._transport.send("v1/uploads",{...r,method:"POST",body:s,searchParams:{account:t}})}};var 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 Dt=class{constructor(t){this._transport=t}get api(){return{get:new Ht(this._transport),create:new Qt(this._transport),delete:new jt(this._transport)}}};var Kt=class{constructor(t){this._transport=t}send({request:t={}}={}){return this._transport.send(".well-known/notifications",{...t,method:"GET"})}};var Vt=class{constructor(t){this._transport=t}get api(){return{notification:{get:new Kt(this._transport)}}}};var f=class o{static DEFAULT_BASE_URL=Xt;_transport;_account;_accountAccessToken;_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 S(this._transport),this._accountAccessToken=new x(this._transport),this._accountConversationSettings=new v(this._transport),this._action=new L(this._transport),this._boilerplate=new M(this._transport),this._boilerplateCategory=new P(this._transport),this._channel=new W(this._transport),this._compositionSection=new X(this._transport),this._contact=new ct(this._transport),this._conversation=new Ct(this._transport),this._label=new Tt(this._transport),this._message=new vt(this._transport),this._model=new At(this._transport),this._note=new Pt(this._transport),this._source=new It(this._transport),this._statistics=new kt(this._transport),this._upload=new Dt(this._transport),this._webhook=new b(this),this._wellKnown=new Vt(this._transport)}static getBaseURL(){return process.env[le]??this.DEFAULT_BASE_URL}get account(){return this._account.api}get accountAccessToken(){return this._accountAccessToken.api}get accountConversationSettings(){return this._accountConversationSettings.api}get action(){return this._action.api}get boilerplate(){return this._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 oe={};re(oe,{AuthError:()=>c,AuthenticationError:()=>l,AuthorizationError:()=>u,LogicError:()=>a,NetworkError:()=>m,SupportError:()=>i,ValidationError:()=>d});var Wt=class o{static DEFAULT_NAME=pe;name;#t;constructor({name:t=process.env[de]??o.DEFAULT_NAME,key:e=process.env[ce]}={}){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 Yt=class{#t;constructor({token:t=process.env[ae]}={}){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 zt=class{async filter(){return{headers:this.getHeaders()}}getHeaders(){return{}}};0&&(module.exports={BearerAuthentication,Client,DEFAULT_SUPPORT_BASE_URL,Error,KeyAuthentication,PublicAuthentication});
|
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { A as Authentication, a as Account, b as Conversation } from './index-
|
|
2
|
-
export { d as AccountConversationSettings,
|
|
1
|
+
import { A as Authentication, a as Account, b as Conversation } from './index-BzXDUbd-.cjs';
|
|
2
|
+
export { d as AccountAccessToken, e as AccountConversationSettings, h as Action, B as Boilerplate, o as BoilerplateCategory, t as Channel, C as Client, y as CompositionSection, I as Contact, p as CreateBoilerplateCategoryResponse, j as CreateBoilerplateResponse, x as CreateChannelResponse, E as CreateCompositionSectionResponse, af as CreateContactNoteResponse, ap as CreateContactNotificationSubscriptionResponse, J as CreateContactResponse, ag as CreateConversationNoteResponse, ac as CreateCorrectionResponse, _ as CreateLabelResponse, ad as CreateResponseResponse, ar as CreateUploadResponse, $ as DeleteLabelResponse, at as DeleteUploadResponse, f as GetAccountConversationSettingsResponse, G as GetAccountResponse, q as GetBoilerplateCategoryResponse, l as GetBoilerplateResponse, v as GetChannelResponse, z as GetCompositionSectionResponse, K as GetContactResponse, Q as GetConversationResponse, a0 as GetLabelResponse, aa as GetModelResponse, ah as GetNoteResponse, au as GetNotificationWellKnownResponse, am as GetSourceResponse, as as GetUploadResponse, Z as Label, L as ListAccountAccessTokensResponse, i as ListActionsResponse, r as ListBoilerplateCategoriesResponse, k as ListBoilerplateCategoryBoilerplatesResponse, m as ListBoilerplatesResponse, F as ListChannelCompositionSectionsResponse, a8 as ListChannelMessagesResponse, u as ListChannelsResponse, D as ListCompositionSectionsResponse, Y as ListContactConversationsResponse, a4 as ListContactLabelsResponse, ai as ListContactNotesResponse, M as ListContactsResponse, a3 as ListConversationLabelsResponse, a6 as ListConversationMessagesResponse, aj as ListConversationNotesResponse, S as ListConversationsResponse, N as ListLabelContactsResponse, V as ListLabelConversationsResponse, a1 as ListLabelsResponse, a7 as ListMessagesResponse, ab as ListModelsResponse, an as ListSourcesResponse, a5 as Message, a9 as Model, ae as Note, ao as NotificationSubscription, O as Options, R as RequestFilterable, al as Source, c as TransportOptions, T as TwilioSendgridChannelSyncResponse, g as UpdateAccountConversationSettingsResponse, U as UpdateAccountResponse, s as UpdateBoilerplateCategoryResponse, n as UpdateBoilerplateResponse, w as UpdateChannelResponse, H as UpdateCompositionSectionResponse, P as UpdateContactResponse, X as UpdateConversationResponse, a2 as UpdateLabelResponse, ak as UpdateNoteResponse, aq as Upload, W as WebhookResponse, C as default } from './index-BzXDUbd-.cjs';
|
|
3
3
|
import 'ky';
|
|
4
4
|
import 'zod';
|
|
5
5
|
|
|
@@ -228,4 +228,4 @@ type CreateConversationResponse = {
|
|
|
228
228
|
};
|
|
229
229
|
};
|
|
230
230
|
|
|
231
|
-
export { Account, BearerAuthentication, Conversation, type CreateAccountResponse, type CreateConversationResponse, DEFAULT_SUPPORT_BASE_URL, index as Error, KeyAuthentication, PublicAuthentication
|
|
231
|
+
export { Account, BearerAuthentication, Conversation, type CreateAccountResponse, type CreateConversationResponse, DEFAULT_SUPPORT_BASE_URL, index as Error, KeyAuthentication, PublicAuthentication };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { A as Authentication, a as Account, b as Conversation } from './index-
|
|
2
|
-
export { d as AccountConversationSettings,
|
|
1
|
+
import { A as Authentication, a as Account, b as Conversation } from './index-BzXDUbd-.js';
|
|
2
|
+
export { d as AccountAccessToken, e as AccountConversationSettings, h as Action, B as Boilerplate, o as BoilerplateCategory, t as Channel, C as Client, y as CompositionSection, I as Contact, p as CreateBoilerplateCategoryResponse, j as CreateBoilerplateResponse, x as CreateChannelResponse, E as CreateCompositionSectionResponse, af as CreateContactNoteResponse, ap as CreateContactNotificationSubscriptionResponse, J as CreateContactResponse, ag as CreateConversationNoteResponse, ac as CreateCorrectionResponse, _ as CreateLabelResponse, ad as CreateResponseResponse, ar as CreateUploadResponse, $ as DeleteLabelResponse, at as DeleteUploadResponse, f as GetAccountConversationSettingsResponse, G as GetAccountResponse, q as GetBoilerplateCategoryResponse, l as GetBoilerplateResponse, v as GetChannelResponse, z as GetCompositionSectionResponse, K as GetContactResponse, Q as GetConversationResponse, a0 as GetLabelResponse, aa as GetModelResponse, ah as GetNoteResponse, au as GetNotificationWellKnownResponse, am as GetSourceResponse, as as GetUploadResponse, Z as Label, L as ListAccountAccessTokensResponse, i as ListActionsResponse, r as ListBoilerplateCategoriesResponse, k as ListBoilerplateCategoryBoilerplatesResponse, m as ListBoilerplatesResponse, F as ListChannelCompositionSectionsResponse, a8 as ListChannelMessagesResponse, u as ListChannelsResponse, D as ListCompositionSectionsResponse, Y as ListContactConversationsResponse, a4 as ListContactLabelsResponse, ai as ListContactNotesResponse, M as ListContactsResponse, a3 as ListConversationLabelsResponse, a6 as ListConversationMessagesResponse, aj as ListConversationNotesResponse, S as ListConversationsResponse, N as ListLabelContactsResponse, V as ListLabelConversationsResponse, a1 as ListLabelsResponse, a7 as ListMessagesResponse, ab as ListModelsResponse, an as ListSourcesResponse, a5 as Message, a9 as Model, ae as Note, ao as NotificationSubscription, O as Options, R as RequestFilterable, al as Source, c as TransportOptions, T as TwilioSendgridChannelSyncResponse, g as UpdateAccountConversationSettingsResponse, U as UpdateAccountResponse, s as UpdateBoilerplateCategoryResponse, n as UpdateBoilerplateResponse, w as UpdateChannelResponse, H as UpdateCompositionSectionResponse, P as UpdateContactResponse, X as UpdateConversationResponse, a2 as UpdateLabelResponse, ak as UpdateNoteResponse, aq as Upload, W as WebhookResponse, C as default } from './index-BzXDUbd-.js';
|
|
3
3
|
import 'ky';
|
|
4
4
|
import 'zod';
|
|
5
5
|
|
|
@@ -228,4 +228,4 @@ type CreateConversationResponse = {
|
|
|
228
228
|
};
|
|
229
229
|
};
|
|
230
230
|
|
|
231
|
-
export { Account, BearerAuthentication, Conversation, type CreateAccountResponse, type CreateConversationResponse, DEFAULT_SUPPORT_BASE_URL, index as Error, KeyAuthentication, PublicAuthentication
|
|
231
|
+
export { Account, BearerAuthentication, Conversation, type CreateAccountResponse, type CreateConversationResponse, DEFAULT_SUPPORT_BASE_URL, index as Error, KeyAuthentication, PublicAuthentication };
|
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
|
|
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-EWJFCLFP.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{o as BearerAuthentication,A as Client,_ as DEFAULT_SUPPORT_BASE_URL,E as Error,t as KeyAuthentication,g as PublicAuthentication,A as default};
|
package/package.json
CHANGED
package/dist/chunk-EEGHBL4C.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
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 ae="SUPPORT_ACCESS_TOKEN",ce="SUPPORT_API_KEY",de="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 p=class extends Error{static serverError(t){return new this("Server Error: "+t)}};var c=class extends p{};var h=class extends c{static unauthenticated(){return new this("An unauthenticated request occurred")}};var f=class extends c{static forbidden(){return new this("A forbidden request occurred")}};var a=class extends p{static notFound(t){return new this(`Record not found for request: ${t}`)}static forbiddenMethod(t,e){return new this(`Forbidden method for request: ${t} ${e}`)}static teapot(){return new this("I'm a teapot")}static rateLimited(){return new this("Request has been rate-limited")}};var C=class extends p{};var d=class extends p{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[kt,Xt]of Object.entries(i))r.headers.has(kt)||r.headers.set(kt,Xt)}}]}})}getURL(t){return new URL(t,this.options.baseURL).toString()}sortQuery(t){let e=[];if(t===void 0)return e;for(let[r,s]of Object.entries(t))s!==void 0&&e.push(["sort",s+r]);return e}limitQuery(t){let e=[];return t===void 0||e.push(["limit",t.toString()]),e}includeQuery(t){let e=[];if(t===void 0)return e;for(let r of Object.keys(t))e.push(["include",r]);return e}queryQuery(t){let e=[];return t===void 0||e.push(["query",t]),e}send(t,e={}){let r=this.client(t,e).catch(s=>{if(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 d.badRequest();case 401:throw h.unauthenticated();case 403:throw f.forbidden();case 404:throw a.notFound(t);case 405:throw a.forbiddenMethod(t,e.method??"GET");case 415:throw d.unsupportedMediaType();case 418:throw a.teapot();case 429:throw a.rateLimited()}if(i>=500&&i<600)throw p.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 O=class{constructor(t){this._transport=t}get api(){return{get:new b(this._transport),update:new _(this._transport)}}};var y=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/accounts/"+encodeURIComponent(t)+"/conversation-settings",{...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)+"/conversation-settings",{...r,method:"PATCH",json:e})}};var S=class{constructor(t){this._transport=t}get api(){return{get:new y(this._transport),update:new x(this._transport)}}};var T=class{constructor(t){this._transport=t}send({limit:t,sort:e,request:r={}}={}){return this._transport.send("v1/actions",{...r,method:"GET",searchParams:[...this._transport.limitQuery(t),...this._transport.sortQuery(e)]})}};var R=class{constructor(t){this._transport=t}get api(){return{list:new T(this._transport)}}};var v=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 F=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 A=class{constructor(t){this._transport=t}get api(){return{get:new L(this._transport),list:new w(this._transport),create:new F(this._transport),update:new U(this._transport),boilerplate:{list:new v(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 q=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 I=class{constructor(t){this._transport=t}get api(){return{get:new G(this._transport),list:new P(this._transport),update:new q(this._transport),create:new E(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 Q=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 j=class{constructor(t){this._transport=t}send(t,{body:e,request:r={}}){return this._transport.send("v1/channels/"+encodeURIComponent(t),{...r,method:"PATCH",json:e})}};var H=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 D=class{constructor(t){this._transport=t}send(t,{limit:e,include:r,request:s={}}={}){return this._transport.send("v1/channels/"+encodeURIComponent(t)+"/messages",{...s,method:"GET",searchParams:[...this._transport.limitQuery(e),...this._transport.includeQuery(r)]})}};var k=class{constructor(t){this._transport=t}get api(){return{get:new B(this._transport),list:new M(this._transport),update:new j(this._transport),create:new N(this._transport),compositionSection:{list:new H(this._transport)},message:{list:new D(this._transport)},twilioSendgrid:{sync:new Q(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 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 at=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 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 lt=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 l=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 pt(this._transport),list:new at(this._transport),update:new ct(this._transport),create:new l(this._transport),label:{list:new dt(this._transport)},message:{list:new lt(this._transport)},note:{list:new ut(this._transport),create:new l(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 Ot=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 yt=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 Ot(this._transport),delete:new gt(this._transport),contact:{list:new ht(this._transport)},conversation:{list:new ft(this._transport)}}}};var xt=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 St=class{constructor(t){this._transport=t}get api(){return{list:new xt(this._transport)}}};var Tt=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 Rt=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/models/"+encodeURIComponent(t),{...e,method:"GET"})}};var vt=class{constructor(t){this._transport=t}send({request:t={}}={}){return this._transport.send("v1/models",{...t,method:"GET"})}};var Ft=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 Rt(this._transport),list:new vt(this._transport),response:{create:new Ft(this._transport)},correction:{create:new Tt(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 At=class{constructor(t){this._transport=t}get api(){return{get:new wt(this._transport),update:new Ut(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 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 Pt=class{constructor(t){this._transport=t}get api(){return{get:new Et(this._transport),list:new Gt(this._transport)}}};var qt=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/channels/"+encodeURIComponent(t)+"/statistics/message-frequency",{...e,method:"GET"})}};var It=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 It(this._transport),channelMessageFrequency:new qt(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 Qt=class{constructor(t){this._transport=t}send(t,{request:e={}}={}){return this._transport.send("v1/uploads/"+encodeURIComponent(t),{...e,method:"GET"})}};var jt=class{constructor(t){this._transport=t}get api(){return{get:new Qt(this._transport),create:new Bt(this._transport),delete:new Mt(this._transport)}}};var Ht=class{constructor(t){this._transport=t}send({request:t={}}={}){return this._transport.send(".well-known/notifications",{...t,method:"GET"})}};var Dt=class{constructor(t){this._transport=t}get api(){return{notification:{get:new Ht(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 O(this._transport),this._accountConversationSettings=new S(this._transport),this._action=new R(this._transport),this._boilerplate=new I(this._transport),this._boilerplateCategory=new A(this._transport),this._channel=new k(this._transport),this._compositionSection=new z(this._transport),this._contact=new it(this._transport),this._conversation=new mt(this._transport),this._label=new yt(this._transport),this._message=new St(this._transport),this._model=new Lt(this._transport),this._note=new At(this._transport),this._source=new Pt(this._transport),this._statistics=new Nt(this._transport),this._upload=new jt(this._transport),this._webhook=new u(this),this._wellKnown=new Dt(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,ae as c,ce as d,de as e,Yt as f,ie as g,p as h,c as i,h as j,f as k,a as l,C as m,d as n,Wt as o};
|