@great-detail/support-sdk 0.17.4 → 0.17.6
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/{Client-BP3Xh8FW.d.cts → Client-BzMax1jd.d.cts} +27 -2
- package/dist/{Client-BP3Xh8FW.d.ts → Client-BzMax1jd.d.ts} +27 -2
- package/dist/{chunk-ZPDMLPUQ.js → chunk-5LTP3VGA.js} +1 -1
- package/dist/chunk-XYLD2NDD.js +1 -0
- 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.cjs +1 -1
- package/dist/index.d.cts +15 -95
- package/dist/index.d.ts +15 -95
- package/dist/index.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-H5UGWTW6.js +0 -1
|
@@ -1350,8 +1350,8 @@ interface GetContactVCFOptions {
|
|
|
1350
1350
|
*/
|
|
1351
1351
|
|
|
1352
1352
|
interface ListContactsOptions {
|
|
1353
|
-
limit?: number;
|
|
1354
1353
|
query?: string;
|
|
1354
|
+
limit?: number;
|
|
1355
1355
|
request?: SendOptions;
|
|
1356
1356
|
}
|
|
1357
1357
|
type ListContactsResponse = {
|
|
@@ -1621,6 +1621,7 @@ interface ListConversationsIncludeOptions {
|
|
|
1621
1621
|
}
|
|
1622
1622
|
type FilterOptions = "unresolved" | "awaitingContact" | "awaitingAgent" | (string & NonNullable<unknown>);
|
|
1623
1623
|
interface ListConversationOptions<C extends ListConversationsIncludeOptions> {
|
|
1624
|
+
query?: string;
|
|
1624
1625
|
limit?: number;
|
|
1625
1626
|
filter?: FilterOptions;
|
|
1626
1627
|
include?: C;
|
|
@@ -1686,7 +1687,7 @@ declare class ConversationAPI {
|
|
|
1686
1687
|
response: () => Promise<ky.KyResponse<GetConversationResponse<C>>>;
|
|
1687
1688
|
json: () => Promise<GetConversationResponse<C>>;
|
|
1688
1689
|
};
|
|
1689
|
-
list<C extends ListConversationsIncludeOptions>({ limit, filter, include, request, }?: ListConversationOptions<C>): {
|
|
1690
|
+
list<C extends ListConversationsIncludeOptions>({ query, limit, filter, include, request, }?: ListConversationOptions<C>): {
|
|
1690
1691
|
response: () => Promise<ky.KyResponse<ListConversationsResponse<C>>>;
|
|
1691
1692
|
json: () => Promise<ListConversationsResponse<C>>;
|
|
1692
1693
|
};
|
|
@@ -2610,6 +2611,26 @@ type GetUploadResponse = {
|
|
|
2610
2611
|
};
|
|
2611
2612
|
};
|
|
2612
2613
|
|
|
2614
|
+
/**
|
|
2615
|
+
* Great Detail Support System.
|
|
2616
|
+
*
|
|
2617
|
+
* @copyright 2024 Great Detail Ltd
|
|
2618
|
+
* @author Great Detail Ltd <info@greatdetail.com>
|
|
2619
|
+
* @author Dom Webber <dom.webber@greatdetail.com>
|
|
2620
|
+
* @see https://greatdetail.com
|
|
2621
|
+
*/
|
|
2622
|
+
|
|
2623
|
+
interface ListUploadsOptions {
|
|
2624
|
+
request?: SendOptions;
|
|
2625
|
+
}
|
|
2626
|
+
type ListUploadsResponse = {
|
|
2627
|
+
data: {
|
|
2628
|
+
url: string;
|
|
2629
|
+
expiresAt: string;
|
|
2630
|
+
upload: Upload;
|
|
2631
|
+
}[];
|
|
2632
|
+
};
|
|
2633
|
+
|
|
2613
2634
|
declare class UploadAPI {
|
|
2614
2635
|
protected _transport: FetchTransport;
|
|
2615
2636
|
constructor(_transport: FetchTransport);
|
|
@@ -2617,6 +2638,10 @@ declare class UploadAPI {
|
|
|
2617
2638
|
response: () => Promise<ky.KyResponse<GetUploadResponse>>;
|
|
2618
2639
|
json: () => Promise<GetUploadResponse>;
|
|
2619
2640
|
};
|
|
2641
|
+
list({ request }?: ListUploadsOptions): {
|
|
2642
|
+
response: () => Promise<ky.KyResponse<ListUploadsResponse>>;
|
|
2643
|
+
json: () => Promise<ListUploadsResponse>;
|
|
2644
|
+
};
|
|
2620
2645
|
create({ account, files, request }: CreateUploadOptions): {
|
|
2621
2646
|
response: () => Promise<ky.KyResponse<CreateUploadResponse>>;
|
|
2622
2647
|
json: () => Promise<CreateUploadResponse>;
|
|
@@ -1350,8 +1350,8 @@ interface GetContactVCFOptions {
|
|
|
1350
1350
|
*/
|
|
1351
1351
|
|
|
1352
1352
|
interface ListContactsOptions {
|
|
1353
|
-
limit?: number;
|
|
1354
1353
|
query?: string;
|
|
1354
|
+
limit?: number;
|
|
1355
1355
|
request?: SendOptions;
|
|
1356
1356
|
}
|
|
1357
1357
|
type ListContactsResponse = {
|
|
@@ -1621,6 +1621,7 @@ interface ListConversationsIncludeOptions {
|
|
|
1621
1621
|
}
|
|
1622
1622
|
type FilterOptions = "unresolved" | "awaitingContact" | "awaitingAgent" | (string & NonNullable<unknown>);
|
|
1623
1623
|
interface ListConversationOptions<C extends ListConversationsIncludeOptions> {
|
|
1624
|
+
query?: string;
|
|
1624
1625
|
limit?: number;
|
|
1625
1626
|
filter?: FilterOptions;
|
|
1626
1627
|
include?: C;
|
|
@@ -1686,7 +1687,7 @@ declare class ConversationAPI {
|
|
|
1686
1687
|
response: () => Promise<ky.KyResponse<GetConversationResponse<C>>>;
|
|
1687
1688
|
json: () => Promise<GetConversationResponse<C>>;
|
|
1688
1689
|
};
|
|
1689
|
-
list<C extends ListConversationsIncludeOptions>({ limit, filter, include, request, }?: ListConversationOptions<C>): {
|
|
1690
|
+
list<C extends ListConversationsIncludeOptions>({ query, limit, filter, include, request, }?: ListConversationOptions<C>): {
|
|
1690
1691
|
response: () => Promise<ky.KyResponse<ListConversationsResponse<C>>>;
|
|
1691
1692
|
json: () => Promise<ListConversationsResponse<C>>;
|
|
1692
1693
|
};
|
|
@@ -2610,6 +2611,26 @@ type GetUploadResponse = {
|
|
|
2610
2611
|
};
|
|
2611
2612
|
};
|
|
2612
2613
|
|
|
2614
|
+
/**
|
|
2615
|
+
* Great Detail Support System.
|
|
2616
|
+
*
|
|
2617
|
+
* @copyright 2024 Great Detail Ltd
|
|
2618
|
+
* @author Great Detail Ltd <info@greatdetail.com>
|
|
2619
|
+
* @author Dom Webber <dom.webber@greatdetail.com>
|
|
2620
|
+
* @see https://greatdetail.com
|
|
2621
|
+
*/
|
|
2622
|
+
|
|
2623
|
+
interface ListUploadsOptions {
|
|
2624
|
+
request?: SendOptions;
|
|
2625
|
+
}
|
|
2626
|
+
type ListUploadsResponse = {
|
|
2627
|
+
data: {
|
|
2628
|
+
url: string;
|
|
2629
|
+
expiresAt: string;
|
|
2630
|
+
upload: Upload;
|
|
2631
|
+
}[];
|
|
2632
|
+
};
|
|
2633
|
+
|
|
2613
2634
|
declare class UploadAPI {
|
|
2614
2635
|
protected _transport: FetchTransport;
|
|
2615
2636
|
constructor(_transport: FetchTransport);
|
|
@@ -2617,6 +2638,10 @@ declare class UploadAPI {
|
|
|
2617
2638
|
response: () => Promise<ky.KyResponse<GetUploadResponse>>;
|
|
2618
2639
|
json: () => Promise<GetUploadResponse>;
|
|
2619
2640
|
};
|
|
2641
|
+
list({ request }?: ListUploadsOptions): {
|
|
2642
|
+
response: () => Promise<ky.KyResponse<ListUploadsResponse>>;
|
|
2643
|
+
json: () => Promise<ListUploadsResponse>;
|
|
2644
|
+
};
|
|
2620
2645
|
create({ account, files, request }: CreateUploadOptions): {
|
|
2621
2646
|
response: () => Promise<ky.KyResponse<CreateUploadResponse>>;
|
|
2622
2647
|
json: () => Promise<CreateUploadResponse>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as v,
|
|
1
|
+
import{b as v,f as b}from"./chunk-XYLD2NDD.js";import{Command as G}from"commander";import{Command as L}from"commander";import{oraPromise as S}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 S(()=>t.action.list().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().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(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().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.getVCF(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(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().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(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().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.conversation.listByLabel(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().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(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().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(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().json(),{...s,text:"Finding sources"});console.log(n)})),o}import{Command as E}from"commander";import{Command as N}from"commander";import{oraPromise as A}from"ora";function j({client:t,ora:s}){let o=new N("notifications").description("Well-Known Notifications Details");return o.addCommand(new N("get").description("Get Notifications Server Well-Known Info").action(async()=>{let n=await A(()=>t.wellKnown.getNotifications().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)},V=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=V;export{Po as a};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var V=Object.defineProperty;var z=(n,t)=>{for(var e in t)V(n,e,{get:t[e],enumerable:!0})};var a=class{getHeaders(){return{}}};var F="SUPPORT_ACCESS_TOKEN",M="SUPPORT_KEY_NAME",x="SUPPORT_KEY_PASSWORD",w="SUPPORT_SIGNING_KEY",N="SUPPORT_BASE_URL";var c=class{name;#t;constructor({name:t=process.env[M],password:e=process.env[x]}={}){if(!t)throw new Error("Name option must be specified when using Basic Authentication");if(!e)throw new Error("Password option must be specified when using Basic Authentication");this.name=t,this.#t=e}getHeaders(){return{Authorization:`Basic ${btoa(this.name+":"+this.#t)}`}}};var m=class{#t;constructor({token:t=process.env[F]}={}){if(!t)throw new Error("Access Token option must be specified when using Token Authentication");this.#t=t}getHeaders(){return{Authorization:`Bearer ${this.#t}`}}};var W="https://api.support.greatdetail.com",Q={"X-Powered-By":"GDSupport/JavaScript"};import{z as i}from"zod";var j=i.object({data:i.object({event:i.object({id:i.string(),type:i.string(),payload:i.record(i.string()),createdAt:i.string().datetime()})})});var l=class{constructor(t){this._transport=t}get(t,{request:e={}}={}){return this._transport.send("v1/accounts/"+encodeURIComponent(t),{...e,method:"GET"})}getCurrent({request:t={}}){return this._transport.send("v1/accounts/current",{...t,method:"GET"})}update(t,{body:e,request:o={}}){return this._transport.send("v1/accounts/"+encodeURIComponent(t),{...o,method:"PATCH",json:e})}create({body:t,request:e={}}){return this._transport.send("v1/accounts",{...e,method:"POST",json:t})}};var d=class{constructor(t){this._transport=t}get(t,e,{request:o={}}={}){return this._transport.send("v1/accounts/"+encodeURIComponent(t)+"/access-tokens/"+encodeURIComponent(e),{...o,method:"GET"})}list(t,{request:e={}}={}){return this._transport.send("v1/accounts/"+encodeURIComponent(t)+"/access-tokens",{...e,method:"GET"})}delete(t,e,{body:o,request:s={}}={}){return this._transport.send("v1/accounts/"+encodeURIComponent(t)+"/access-tokens/"+encodeURIComponent(e),{...s,method:"DELETE",json:o})}create(t,{body:e={},request:o={}}={}){return this._transport.send("v1/accounts/"+encodeURIComponent(t)+"/access-tokens",{...o,method:"POST",json:e})}};var u=class{constructor(t){this._transport=t}get(t,{request:e={}}={}){return this._transport.send("v1/accounts/"+encodeURIComponent(t)+"/conversation-settings",{...e,method:"GET"})}update(t,{body:e,request:o={}}){return this._transport.send("v1/accounts/"+encodeURIComponent(t)+"/conversation-settings",{...o,method:"PATCH",json:e})}};var h=class{constructor(t){this._transport=t}list({limit:t,sort:e,request:o={}}={}){return this._transport.send("v1/actions",{...o,method:"GET",searchParams:[...this._transport.limitQuery(t),...this._transport.sortQuery(e)]})}};var C=class{constructor(t){this._transport=t}get(t,{request:e={}}={}){return this._transport.send("v1/boilerplates/categories/"+encodeURIComponent(t),{...e,method:"GET"})}list({limit:t,include:e,request:o={}}={}){return this._transport.send("v1/boilerplates/categories",{...o,method:"GET",searchParams:[...this._transport.limitQuery(t),...this._transport.includeQuery(e)]})}create({body:t,request:e={}}){return this._transport.send("v1/boilerplates/categories",{...e,method:"POST",json:t})}update(t,{body:e,request:o={}}){return this._transport.send("v1/boilerplates/categories/"+encodeURIComponent(t),{...o,method:"PATCH",json:e})}};var f=class{constructor(t){this._transport=t}get(t,{request:e={}}={}){return this._transport.send("v1/boilerplates/contents/"+encodeURIComponent(t),{...e,method:"GET"})}list({limit:t,query:e,request:o={}}={}){return this._transport.send("v1/boilerplates/contents",{...o,method:"GET",searchParams:[...this._transport.limitQuery(t),...this._transport.queryQuery(e)]})}listByCategory=this.listByBoilerplateCategory;listByBoilerplateCategory(t,{limit:e,request:o={}}={}){return this._transport.send("v1/boilerplates/categories/"+encodeURIComponent(t)+"/contents",{...o,method:"GET",searchParams:[...this._transport.limitQuery(e)]})}create({body:t,request:e={}}){return this._transport.send("v1/boilerplates/contents",{...e,method:"POST",json:t})}update(t,{body:e,request:o={}}){return this._transport.send("v1/boilerplates/contents/"+encodeURIComponent(t),{...o,method:"PATCH",json:e})}};var R=class{constructor(t){this._transport=t}get(t,{request:e={}}={}){return this._transport.send("v1/channels/"+encodeURIComponent(t),{...e,method:"GET"})}list({limit:t,query:e,request:o={}}={}){return this._transport.send("v1/channels",{...o,method:"GET",searchParams:[...this._transport.limitQuery(t),...this._transport.queryQuery(e)]})}update(t,{body:e,request:o={}}){return this._transport.send("v1/channels/"+encodeURIComponent(t),{...o,method:"PATCH",json:e})}create({body:t,request:e={}}){return this._transport.send("v1/channels",{...e,method:"POST",json:t})}metaWhatsappGetBusinessProfile(t,{request:e={}}={}){return this._transport.send("v1/channels/"+encodeURIComponent(t)+"/meta-whatsapp/business-profile",{...e,method:"GET"})}twilioSendgridChannelSync(t,{body:e,request:o={}}){return this._transport.send("v1/channels/"+encodeURIComponent(t)+"/twilio-sendgrid/sync",{...o,method:"POST",json:e})}};var b=class{constructor(t){this._transport=t}get(t,{request:e={}}={}){return this._transport.send("v1/composition-sections/"+encodeURIComponent(t),{...e,method:"GET"})}list({limit:t,request:e={}}={}){return this._transport.send("v1/composition-sections",{...e,method:"GET",searchParams:[...this._transport.limitQuery(t)]})}listByChannel(t,{limit:e,request:o={}}={}){return this._transport.send("v1/channels/"+encodeURIComponent(t)+"/composition-sections",{...o,method:"GET",searchParams:[...this._transport.limitQuery(e)]})}create({body:t,request:e={}}){return this._transport.send("v1/composition-sections",{...e,method:"POST",json:t})}update(t,{body:e,request:o={}}){return this._transport.send("v1/composition-sections/"+encodeURIComponent(t),{...o,method:"PATCH",json:e})}};var v=class{constructor(t){this._transport=t}get(t,{include:e,request:o={}}={}){return this._transport.send("v1/contacts/"+encodeURIComponent(t),{...o,method:"GET",searchParams:[...this._transport.includeQuery(e??{})]})}getRelativeVCFURL(t,{vcf:e={}}={}){let o=e.variant??"vcard",s=e.format??(o==="vcard"?"vcf":"json");return"v1/contacts/"+encodeURIComponent(t)+"/vcf?variant="+encodeURIComponent(o)+"&format="+encodeURIComponent(s)}getVCFURL(t,e={}){return this._transport.getURL(this.getRelativeVCFURL(t,e))}getVCF(t,e={}){return this._transport.send(this.getVCFURL(t,e),{method:"GET"})}list({limit:t,query:e,request:o={}}={}){return this._transport.send("v1/contacts",{...o,method:"GET",searchParams:[...this._transport.limitQuery(t),...this._transport.queryQuery(e)]})}listByLabel(t,{limit:e,request:o={}}={}){return this._transport.send("v1/labels/"+encodeURIComponent(t)+"/contacts",{...o,method:"GET",searchParams:[...this._transport.limitQuery(e)]})}create({body:t,request:e={}}){return this._transport.send("v1/contacts",{...e,method:"POST",json:t})}update(t,{body:e,request:o={}}){return this._transport.send("v1/contacts/"+encodeURIComponent(t),{...o,method:"PATCH",json:e})}delete(t,{request:e={}}={}){return this._transport.send("v1/contacts/"+encodeURIComponent(t),{...e,method:"DELETE"})}};var O=class{constructor(t){this._transport=t}get(t,{include:e,request:o={}}={}){return this._transport.send("v1/conversations/"+encodeURIComponent(t),{...o,method:"GET",searchParams:[...this._transport.includeQuery(e??{})]})}list({query:t,limit:e,filter:o,include:s,request:r={}}={}){return this._transport.send("v1/conversations",{...r,method:"GET",searchParams:[...this._transport.queryQuery(t),...this._transport.limitQuery(e),...o?[["filter",o]]:[],...this._transport.includeQuery(s??{})]})}listByLabel(t,{limit:e,request:o={}}={}){return this._transport.send("v1/labels/"+encodeURIComponent(t)+"/conversations",{...o,method:"GET",searchParams:[...this._transport.limitQuery(e)]})}listByContact(t,{limit:e,request:o={}}={}){return this._transport.send("v1/contacts/"+encodeURIComponent(t)+"/conversations",{...o,method:"GET",searchParams:[...this._transport.limitQuery(e)]})}listByChannel(t,{limit:e,request:o={}}={}){return this._transport.send("v1/channels/"+encodeURIComponent(t)+"/conversations",{...o,method:"GET",searchParams:[...this._transport.limitQuery(e)]})}create({body:t,request:e={}}){return this._transport.send("v1/conversations",{...e,method:"POST",json:t})}update(t,{body:e,request:o={}}){return this._transport.send("v1/conversations/"+encodeURIComponent(t),{...o,method:"PATCH",json:e})}delete(t,{request:e={}}={}){return this._transport.send("v1/conversations/"+encodeURIComponent(t),{...e,method:"DELETE"})}};var g=class{constructor(t){this._transport=t}get(t,{request:e={}}={}){return this._transport.send("v1/labels/"+encodeURIComponent(t),{...e,method:"GET"})}list({limit:t,query:e,include:o,request:s={}}={}){return this._transport.send("v1/labels",{...s,method:"GET",searchParams:[...this._transport.limitQuery(t),...this._transport.queryQuery(e),...this._transport.includeQuery(o??{})]})}listByContact(t,{limit:e,request:o={}}={}){return this._transport.send("v1/contacts/"+encodeURIComponent(t)+"/labels",{...o,method:"GET",searchParams:[...this._transport.limitQuery(e)]})}listByConversation(t,{limit:e,request:o={}}={}){return this._transport.send("v1/conversations/"+encodeURIComponent(t)+"/labels",{...o,method:"GET",searchParams:[...this._transport.limitQuery(e)]})}create({body:t,request:e={}}){return this._transport.send("v1/labels",{...e,method:"POST",json:t})}update(t,{body:e,request:o={}}){return this._transport.send("v1/labels/"+encodeURIComponent(t),{...o,method:"PATCH",json:e})}delete(t,{request:e={}}={}){return this._transport.send("v1/labels/"+encodeURIComponent(t),{...e,method:"DELETE"})}};var _=class{constructor(t){this._transport=t}list({limit:t,include:e,request:o={}}={}){return this._transport.send("v1/messages",{...o,method:"GET",searchParams:[...this._transport.limitQuery(t),...this._transport.includeQuery(e??{})]})}listByConversation(t,{limit:e,include:o,request:s={}}={}){return this._transport.send("v1/conversations/"+encodeURIComponent(t)+"/messages",{...s,method:"GET",searchParams:[...this._transport.limitQuery(e),...this._transport.includeQuery(o??{})]})}listByChannel(t,{limit:e,include:o,request:s={}}={}){return this._transport.send("v1/channels/"+encodeURIComponent(t)+"/messages",{...s,method:"GET",searchParams:[...this._transport.limitQuery(e),...this._transport.includeQuery(o)]})}create({body:t,request:e={}}){return this._transport.send("v1/messages",{...e,method:"POST",json:t})}delete(t,{request:e={}}={}){return this._transport.send("v1/messages/"+encodeURIComponent(t),{...e,method:"DELETE"})}};var T=class{constructor(t){this._transport=t}get(t,{request:e={}}={}){return this._transport.send("v1/models/"+encodeURIComponent(t),{...e,method:"GET"})}list({request:t={}}={}){return this._transport.send("v1/models",{...t,method:"GET"})}createResponse(t,{body:e,request:o={}}){return this._transport.send("v1/models/"+encodeURIComponent(t)+"/response",{...o,method:"POST",timeout:12e4,json:e})}createCorrection(t,{body:e,request:o={}}){return this._transport.send("v1/models/"+encodeURIComponent(t)+"/correction",{...o,method:"POST",json:e})}};var L=class{constructor(t){this._transport=t}get(t,{request:e={}}={}){return this._transport.send("v1/notes/"+encodeURIComponent(t),{...e,method:"GET"})}listByContact(t,{request:e={}}={}){return this._transport.send("v1/contacts/"+encodeURIComponent(t)+"/notes",{...e,method:"GET"})}listByConversation(t,{request:e={}}={}){return this._transport.send("v1/conversations/"+encodeURIComponent(t)+"/notes",{...e,method:"GET"})}createForContact(t,{body:e,request:o={}}){return this._transport.send("v1/contacts/"+encodeURIComponent(t)+"/notes",{...o,method:"POST",json:e})}createForConversation(t,{body:e,request:o={}}){return this._transport.send("v1/conversations/"+encodeURIComponent(t)+"/notes",{...o,method:"POST",json:e})}update(t,{body:e,request:o={}}){return this._transport.send("v1/notes/"+encodeURIComponent(t),{...o,method:"PATCH",json:e})}};var I=class{constructor(t){this._transport=t}createForContact(t,{body:e,request:o={}}){return this._transport.send("v1/contacts/"+encodeURIComponent(t)+"/notification-subscriptions",{...o,method:"POST",json:e})}};var y=class n{constructor(t=n.STANDARD_HEADERS){this._standardHeaders=t}static STANDARD_HEADERS=Q;async filter(){return{headers:this.getHeaders()}}getHeaders(){return this._standardHeaders}};var A=class{constructor(t){this._transport=t}get(t,{request:e={}}={}){return this._transport.send("v1/sources/"+encodeURIComponent(t),{...e,method:"GET"})}list({featured:t,category:e,request:o={}}={}){let s=[];if(e){let r=Array.isArray(e)?e:[e];for(let p of r)s.push(["category",p])}return t!==void 0&&s.push(["featured",String(t)]),this._transport.send("v1/sources",{...o,method:"GET",searchParams:s})}};var S=class{constructor(t){this._transport=t}getMessageFrequency({request:t={}}={}){return this._transport.send("v1/statistics/message-frequency",{...t,method:"GET"})}getChannelMessageFrequency(t,{request:e={}}={}){return this._transport.send("v1/channels/"+encodeURIComponent(t)+"/statistics/message-frequency",{...e,method:"GET"})}getModelUsage({request:t={}}={}){return this._transport.send("v1/statistics/model-usage",{...t,method:"GET"})}};import q from"is-network-error";import K,{HTTPError as Y}from"ky";var P=class extends Error{constructor(e,o){super("Support Error",{cause:o});this.response=e}};var U=class{client;options;constructor({baseURL:t,...e}){this.options={...e,baseURL:t},this.client=K.create({prefixUrl:this.options.baseURL,timeout:12e3,hooks:{beforeRequest:[o=>{for(let s of this.options.requestFilterables){let r=s.getHeaders();for(let[p,H]of Object.entries(r))o.headers.has(p)||o.headers.set(p,H)}}]}})}getURL(t){return new URL(t,this.options.baseURL).toString()}sortQuery(t){let e=[];if(t===void 0)return e;for(let[o,s]of Object.entries(t))s!==void 0&&e.push(["sort",s+o]);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 o of Object.keys(t))e.push(["include",o]);return e}queryQuery(t){let e=[];return t===void 0||e.push(["query",t]),e}send(t,e={}){let o=this.client(t,e).catch(async s=>{throw q(s)?new Error("A network error occurred",{cause:s}):s instanceof Y?new P(s.response,s):s});return{response:()=>o,json:async()=>(await o).json()}}};var E=class{constructor(t){this._transport=t}get(t,{request:e={}}={}){return this._transport.send("v1/uploads/"+encodeURIComponent(t),{...e,method:"GET"})}list({request:t={}}={}){return this._transport.send("v1/uploads",{...t,method:"GET"})}create({account:t,files:e,request:o={}}){let s=new FormData;for(let r of e)s.append("file",r);return this._transport.send("v1/uploads",{...o,method:"POST",body:s,searchParams:{account:t}})}delete(t,{request:e={}}={}){return this._transport.send("v1/uploads/"+encodeURIComponent(t),{...e,method:"DELETE"})}};var G=class{constructor(t){this._transport=t}async event({key:t=process.env[w],maxSignatures:e=3,request:o}){let s=o.headers["gds-signature"];if(t!==!1){if(t===void 0)throw new Error("Missing webhook signing key in process.env."+w);if(!s)throw new Error("Missing signature header");if(!this._verifySignature(t,o.body,Array.isArray(s)?s.slice(0,e):[s]))throw new Error("Untrusted signature")}let{data:r}=j.parse(o.body);return{event:r.event}}async _verifySignature(t,e,o){let s=await crypto.subtle.importKey("raw",new TextEncoder().encode(t),{name:"HMAC",hash:"SHA-256"},!1,["sign","verify"]);for(let r of o)if(await crypto.subtle.verify("HMAC",s,new TextEncoder().encode(atob(r)),new TextEncoder().encode(JSON.stringify(e))))return!0;return!1}};var D=class{constructor(t){this._transport=t}get(t,{request:e={}}={}){return this._transport.send("v1/webhooks/subscriptions/"+encodeURIComponent(t),{...e,method:"GET"})}list({request:t={}}={}){return this._transport.send("v1/webhooks/subscriptions",{...t,method:"GET"})}test(t,{request:e={}}={}){return this._transport.send("v1/webhooks/subscriptions/"+encodeURIComponent(t)+"/test",{...e,method:"POST"})}create({body:t,request:e={}}){return this._transport.send("v1/webhooks/subscriptions",{...e,method:"POST",json:t})}delete(t,{request:e={}}={}){return this._transport.send("v1/webhooks/subscriptions/"+encodeURIComponent(t),{...e,method:"DELETE"})}};var k=class{constructor(t){this._transport=t}getNotifications({request:t={}}={}){return this._transport.send(".well-known/notifications",{...t,method:"GET"})}};var B=class n{static DEFAULT_BASE_URL=W;static PublicAuthentication=a;static BasicAuthentication=c;static BearerAuthentication=m;_transport;account;accountAccessToken;accountConversationSettings;action;boilerplateCategory;boilerplateContent;channel;compositionSection;contact;conversation;label;message;model;note;notificationSubscription;source;statistics;upload;webhook;webhookSubscription;wellKnown;constructor(t,{baseURL:e,...o}={}){this._transport=new U({requestFilterables:[new y,t],...o,baseURL:e?.toString()??n.getBaseURL()}),this.account=new l(this._transport),this.accountAccessToken=new d(this._transport),this.accountConversationSettings=new u(this._transport),this.action=new h(this._transport),this.boilerplateCategory=new C(this._transport),this.boilerplateContent=new f(this._transport),this.channel=new R(this._transport),this.compositionSection=new b(this._transport),this.contact=new v(this._transport),this.conversation=new O(this._transport),this.label=new g(this._transport),this.message=new _(this._transport),this.model=new T(this._transport),this.note=new L(this._transport),this.notificationSubscription=new I(this._transport),this.source=new A(this._transport),this.statistics=new S(this._transport),this.upload=new E(this._transport),this.webhook=new G(this._transport),this.webhookSubscription=new D(this._transport),this.wellKnown=new k(this._transport)}static getBaseURL(){return process.env[N]??this.DEFAULT_BASE_URL}};export{z as a,a as b,W as c,P as d,j as e,B as f};
|
package/dist/cli/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var Gt=Object.create;var K=Object.defineProperty;var xt=Object.getOwnPropertyDescriptor;var Pt=Object.getOwnPropertyNames;var kt=Object.getPrototypeOf,Ft=Object.prototype.hasOwnProperty;var Bt=(n,t)=>{for(var e in t)K(n,e,{get:t[e],enumerable:!0})},ft=(n,t,e,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of Pt(t))!Ft.call(n,s)&&s!==e&&K(n,s,{get:()=>t[s],enumerable:!(o=xt(t,s))||o.enumerable});return n};var Ot=(n,t,e)=>(e=n!=null?Gt(kt(n)):{},ft(t||!n||!n.__esModule?K(e,"default",{value:n,enumerable:!0}):e,n)),Mt=n=>ft(K({},"__esModule",{value:!0}),n);var Wt={};Bt(Wt,{default:()=>jt});module.exports=Mt(Wt);var Et=require("commander");var m=class{getHeaders(){return{}}};var C=class{constructor(t){this._transport=t}get(t,{request:e={}}={}){return this._transport.send("v1/accounts/"+encodeURIComponent(t),{...e,method:"GET"})}getCurrent({request:t={}}){return this._transport.send("v1/accounts/current",{...t,method:"GET"})}update(t,{body:e,request:o={}}){return this._transport.send("v1/accounts/"+encodeURIComponent(t),{...o,method:"PATCH",json:e})}create({body:t,request:e={}}){return this._transport.send("v1/accounts",{...e,method:"POST",json:t})}};var h=class{constructor(t){this._transport=t}get(t,e,{request:o={}}={}){return this._transport.send("v1/accounts/"+encodeURIComponent(t)+"/access-tokens/"+encodeURIComponent(e),{...o,method:"GET"})}list(t,{request:e={}}={}){return this._transport.send("v1/accounts/"+encodeURIComponent(t)+"/access-tokens",{...e,method:"GET"})}delete(t,e,{body:o,request:s={}}={}){return this._transport.send("v1/accounts/"+encodeURIComponent(t)+"/access-tokens/"+encodeURIComponent(e),{...s,method:"DELETE",json:o})}create(t,{body:e={},request:o={}}={}){return this._transport.send("v1/accounts/"+encodeURIComponent(t)+"/access-tokens",{...o,method:"POST",json:e})}};var f=class{constructor(t){this._transport=t}get(t,{request:e={}}={}){return this._transport.send("v1/accounts/"+encodeURIComponent(t)+"/conversation-settings",{...e,method:"GET"})}update(t,{body:e,request:o={}}){return this._transport.send("v1/accounts/"+encodeURIComponent(t)+"/conversation-settings",{...o,method:"PATCH",json:e})}};var O=class{constructor(t){this._transport=t}list({limit:t,sort:e,request:o={}}={}){return this._transport.send("v1/actions",{...o,method:"GET",searchParams:[...this._transport.limitQuery(t),...this._transport.sortQuery(e)]})}};var gt="SUPPORT_ACCESS_TOKEN",bt="SUPPORT_KEY_NAME",Rt="SUPPORT_KEY_PASSWORD",X="SUPPORT_SIGNING_KEY",vt="SUPPORT_BASE_URL";var g=class{name;#t;constructor({name:t=process.env[bt],password:e=process.env[Rt]}={}){if(!t)throw new Error("Name option must be specified when using Basic Authentication");if(!e)throw new Error("Password option must be specified when using Basic Authentication");this.name=t,this.#t=e}getHeaders(){return{Authorization:`Basic ${btoa(this.name+":"+this.#t)}`}}};var b=class{#t;constructor({token:t=process.env[gt]}={}){if(!t)throw new Error("Access Token option must be specified when using Token Authentication");this.#t=t}getHeaders(){return{Authorization:`Bearer ${this.#t}`}}};var R=class{constructor(t){this._transport=t}get(t,{request:e={}}={}){return this._transport.send("v1/boilerplates/categories/"+encodeURIComponent(t),{...e,method:"GET"})}list({limit:t,include:e,request:o={}}={}){return this._transport.send("v1/boilerplates/categories",{...o,method:"GET",searchParams:[...this._transport.limitQuery(t),...this._transport.includeQuery(e)]})}create({body:t,request:e={}}){return this._transport.send("v1/boilerplates/categories",{...e,method:"POST",json:t})}update(t,{body:e,request:o={}}){return this._transport.send("v1/boilerplates/categories/"+encodeURIComponent(t),{...o,method:"PATCH",json:e})}};var v=class{constructor(t){this._transport=t}get(t,{request:e={}}={}){return this._transport.send("v1/boilerplates/contents/"+encodeURIComponent(t),{...e,method:"GET"})}list({limit:t,query:e,request:o={}}={}){return this._transport.send("v1/boilerplates/contents",{...o,method:"GET",searchParams:[...this._transport.limitQuery(t),...this._transport.queryQuery(e)]})}listByCategory=this.listByBoilerplateCategory;listByBoilerplateCategory(t,{limit:e,request:o={}}={}){return this._transport.send("v1/boilerplates/categories/"+encodeURIComponent(t)+"/contents",{...o,method:"GET",searchParams:[...this._transport.limitQuery(e)]})}create({body:t,request:e={}}){return this._transport.send("v1/boilerplates/contents",{...e,method:"POST",json:t})}update(t,{body:e,request:o={}}){return this._transport.send("v1/boilerplates/contents/"+encodeURIComponent(t),{...o,method:"PATCH",json:e})}};var y=class{constructor(t){this._transport=t}get(t,{request:e={}}={}){return this._transport.send("v1/channels/"+encodeURIComponent(t),{...e,method:"GET"})}list({limit:t,query:e,request:o={}}={}){return this._transport.send("v1/channels",{...o,method:"GET",searchParams:[...this._transport.limitQuery(t),...this._transport.queryQuery(e)]})}update(t,{body:e,request:o={}}){return this._transport.send("v1/channels/"+encodeURIComponent(t),{...o,method:"PATCH",json:e})}create({body:t,request:e={}}){return this._transport.send("v1/channels",{...e,method:"POST",json:t})}metaWhatsappGetBusinessProfile(t,{request:e={}}={}){return this._transport.send("v1/channels/"+encodeURIComponent(t)+"/meta-whatsapp/business-profile",{...e,method:"GET"})}twilioSendgridChannelSync(t,{body:e,request:o={}}){return this._transport.send("v1/channels/"+encodeURIComponent(t)+"/twilio-sendgrid/sync",{...o,method:"POST",json:e})}};var T=class{constructor(t){this._transport=t}get(t,{request:e={}}={}){return this._transport.send("v1/composition-sections/"+encodeURIComponent(t),{...e,method:"GET"})}list({limit:t,request:e={}}={}){return this._transport.send("v1/composition-sections",{...e,method:"GET",searchParams:[...this._transport.limitQuery(t)]})}listByChannel(t,{limit:e,request:o={}}={}){return this._transport.send("v1/channels/"+encodeURIComponent(t)+"/composition-sections",{...o,method:"GET",searchParams:[...this._transport.limitQuery(e)]})}create({body:t,request:e={}}){return this._transport.send("v1/composition-sections",{...e,method:"POST",json:t})}update(t,{body:e,request:o={}}){return this._transport.send("v1/composition-sections/"+encodeURIComponent(t),{...o,method:"PATCH",json:e})}};var yt="https://api.support.greatdetail.com",Tt={"X-Powered-By":"GDSupport/JavaScript"};var _=class{constructor(t){this._transport=t}get(t,{include:e,request:o={}}={}){return this._transport.send("v1/contacts/"+encodeURIComponent(t),{...o,method:"GET",searchParams:[...this._transport.includeQuery(e??{})]})}getRelativeVCFURL(t,{vcf:e={}}={}){let o=e.variant??"vcard",s=e.format??(o==="vcard"?"vcf":"json");return"v1/contacts/"+encodeURIComponent(t)+"/vcf?variant="+encodeURIComponent(o)+"&format="+encodeURIComponent(s)}getVCFURL(t,e={}){return this._transport.getURL(this.getRelativeVCFURL(t,e))}getVCF(t,e={}){return this._transport.send(this.getVCFURL(t,e),{method:"GET"})}list({limit:t,query:e,request:o={}}={}){return this._transport.send("v1/contacts",{...o,method:"GET",searchParams:[...this._transport.limitQuery(t),...this._transport.queryQuery(e)]})}listByLabel(t,{limit:e,request:o={}}={}){return this._transport.send("v1/labels/"+encodeURIComponent(t)+"/contacts",{...o,method:"GET",searchParams:[...this._transport.limitQuery(e)]})}create({body:t,request:e={}}){return this._transport.send("v1/contacts",{...e,method:"POST",json:t})}update(t,{body:e,request:o={}}){return this._transport.send("v1/contacts/"+encodeURIComponent(t),{...o,method:"PATCH",json:e})}delete(t,{request:e={}}={}){return this._transport.send("v1/contacts/"+encodeURIComponent(t),{...e,method:"DELETE"})}};var L=class{constructor(t){this._transport=t}get(t,{include:e,request:o={}}={}){return this._transport.send("v1/conversations/"+encodeURIComponent(t),{...o,method:"GET",searchParams:[...this._transport.includeQuery(e??{})]})}list({limit:t,filter:e,include:o,request:s={}}={}){return this._transport.send("v1/conversations",{...s,method:"GET",searchParams:[...this._transport.limitQuery(t),...e?[["filter",e]]:[],...this._transport.includeQuery(o??{})]})}listByLabel(t,{limit:e,request:o={}}={}){return this._transport.send("v1/labels/"+encodeURIComponent(t)+"/conversations",{...o,method:"GET",searchParams:[...this._transport.limitQuery(e)]})}listByContact(t,{limit:e,request:o={}}={}){return this._transport.send("v1/contacts/"+encodeURIComponent(t)+"/conversations",{...o,method:"GET",searchParams:[...this._transport.limitQuery(e)]})}listByChannel(t,{limit:e,request:o={}}={}){return this._transport.send("v1/channels/"+encodeURIComponent(t)+"/conversations",{...o,method:"GET",searchParams:[...this._transport.limitQuery(e)]})}create({body:t,request:e={}}){return this._transport.send("v1/conversations",{...e,method:"POST",json:t})}update(t,{body:e,request:o={}}){return this._transport.send("v1/conversations/"+encodeURIComponent(t),{...o,method:"PATCH",json:e})}delete(t,{request:e={}}={}){return this._transport.send("v1/conversations/"+encodeURIComponent(t),{...e,method:"DELETE"})}};var I=class{constructor(t){this._transport=t}get(t,{request:e={}}={}){return this._transport.send("v1/labels/"+encodeURIComponent(t),{...e,method:"GET"})}list({limit:t,query:e,include:o,request:s={}}={}){return this._transport.send("v1/labels",{...s,method:"GET",searchParams:[...this._transport.limitQuery(t),...this._transport.queryQuery(e),...this._transport.includeQuery(o??{})]})}listByContact(t,{limit:e,request:o={}}={}){return this._transport.send("v1/contacts/"+encodeURIComponent(t)+"/labels",{...o,method:"GET",searchParams:[...this._transport.limitQuery(e)]})}listByConversation(t,{limit:e,request:o={}}={}){return this._transport.send("v1/conversations/"+encodeURIComponent(t)+"/labels",{...o,method:"GET",searchParams:[...this._transport.limitQuery(e)]})}create({body:t,request:e={}}){return this._transport.send("v1/labels",{...e,method:"POST",json:t})}update(t,{body:e,request:o={}}){return this._transport.send("v1/labels/"+encodeURIComponent(t),{...o,method:"PATCH",json:e})}delete(t,{request:e={}}={}){return this._transport.send("v1/labels/"+encodeURIComponent(t),{...e,method:"DELETE"})}};var A=class{constructor(t){this._transport=t}list({limit:t,include:e,request:o={}}={}){return this._transport.send("v1/messages",{...o,method:"GET",searchParams:[...this._transport.limitQuery(t),...this._transport.includeQuery(e??{})]})}listByConversation(t,{limit:e,include:o,request:s={}}={}){return this._transport.send("v1/conversations/"+encodeURIComponent(t)+"/messages",{...s,method:"GET",searchParams:[...this._transport.limitQuery(e),...this._transport.includeQuery(o??{})]})}listByChannel(t,{limit:e,include:o,request:s={}}={}){return this._transport.send("v1/channels/"+encodeURIComponent(t)+"/messages",{...s,method:"GET",searchParams:[...this._transport.limitQuery(e),...this._transport.includeQuery(o)]})}create({body:t,request:e={}}){return this._transport.send("v1/messages",{...e,method:"POST",json:t})}delete(t,{request:e={}}={}){return this._transport.send("v1/messages/"+encodeURIComponent(t),{...e,method:"DELETE"})}};var S=class{constructor(t){this._transport=t}get(t,{request:e={}}={}){return this._transport.send("v1/models/"+encodeURIComponent(t),{...e,method:"GET"})}list({request:t={}}={}){return this._transport.send("v1/models",{...t,method:"GET"})}createResponse(t,{body:e,request:o={}}){return this._transport.send("v1/models/"+encodeURIComponent(t)+"/response",{...o,method:"POST",timeout:12e4,json:e})}createCorrection(t,{body:e,request:o={}}){return this._transport.send("v1/models/"+encodeURIComponent(t)+"/correction",{...o,method:"POST",json:e})}};var w=class{constructor(t){this._transport=t}get(t,{request:e={}}={}){return this._transport.send("v1/notes/"+encodeURIComponent(t),{...e,method:"GET"})}listByContact(t,{request:e={}}={}){return this._transport.send("v1/contacts/"+encodeURIComponent(t)+"/notes",{...e,method:"GET"})}listByConversation(t,{request:e={}}={}){return this._transport.send("v1/conversations/"+encodeURIComponent(t)+"/notes",{...e,method:"GET"})}createForContact(t,{body:e,request:o={}}){return this._transport.send("v1/contacts/"+encodeURIComponent(t)+"/notes",{...o,method:"POST",json:e})}createForConversation(t,{body:e,request:o={}}){return this._transport.send("v1/conversations/"+encodeURIComponent(t)+"/notes",{...o,method:"POST",json:e})}update(t,{body:e,request:o={}}){return this._transport.send("v1/notes/"+encodeURIComponent(t),{...o,method:"PATCH",json:e})}};var U=class{constructor(t){this._transport=t}createForContact(t,{body:e,request:o={}}){return this._transport.send("v1/contacts/"+encodeURIComponent(t)+"/notification-subscriptions",{...o,method:"POST",json:e})}};var E=class n{constructor(t=n.STANDARD_HEADERS){this._standardHeaders=t}static STANDARD_HEADERS=Tt;async filter(){return{headers:this.getHeaders()}}getHeaders(){return this._standardHeaders}};var D=class{constructor(t){this._transport=t}get(t,{request:e={}}={}){return this._transport.send("v1/sources/"+encodeURIComponent(t),{...e,method:"GET"})}list({featured:t,category:e,request:o={}}={}){let s=[];if(e){let r=Array.isArray(e)?e:[e];for(let l of r)s.push(["category",l])}return t!==void 0&&s.push(["featured",String(t)]),this._transport.send("v1/sources",{...o,method:"GET",searchParams:s})}};var G=class{constructor(t){this._transport=t}getMessageFrequency({request:t={}}={}){return this._transport.send("v1/statistics/message-frequency",{...t,method:"GET"})}getChannelMessageFrequency(t,{request:e={}}={}){return this._transport.send("v1/channels/"+encodeURIComponent(t)+"/statistics/message-frequency",{...e,method:"GET"})}getModelUsage({request:t={}}={}){return this._transport.send("v1/statistics/model-usage",{...t,method:"GET"})}};var _t=Ot(require("is-network-error"),1),V=Ot(require("ky"),1);var i=class extends Error{static serverError(t){return new this("Server Error: "+t)}};var d=class extends i{};var x=class extends d{static unauthenticated(){return new this("An unauthenticated request occurred")}};var P=class extends d{static forbidden(){return new this("A forbidden request occurred")}};var c=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 k=class extends i{};var u=class extends i{static badRequest(){return new this("Bad request")}static unsupportedMediaType(){return new this("Unsupported Media Type")}};var F=class{client;options;constructor({baseURL:t,...e}){this.options={...e,baseURL:t},this.client=V.default.create({prefixUrl:this.options.baseURL,timeout:12e3,hooks:{beforeRequest:[o=>{for(let s of this.options.requestFilterables){let r=s.getHeaders();for(let[l,Dt]of Object.entries(r))o.headers.has(l)||o.headers.set(l,Dt)}}]}})}getURL(t){return new URL(t,this.options.baseURL).toString()}sortQuery(t){let e=[];if(t===void 0)return e;for(let[o,s]of Object.entries(t))s!==void 0&&e.push(["sort",s+o]);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 o of Object.keys(t))e.push(["include",o]);return e}queryQuery(t){let e=[];return t===void 0||e.push(["query",t]),e}send(t,e={}){let o=this.client(t,e).catch(s=>{if((0,_t.default)(s))throw new k("A network error occurred",{cause:s});if(s instanceof V.HTTPError){let r=s.response.status;switch(console.error(JSON.stringify(s.response)),r){case 400:throw u.badRequest();case 401:throw x.unauthenticated();case 403:throw P.forbidden();case 404:throw c.notFound(t);case 405:throw c.forbiddenMethod(t,e.method??"GET");case 415:throw u.unsupportedMediaType();case 418:throw c.teapot();case 429:throw c.rateLimited()}if(r>=500&&r<600)throw i.serverError(r)}throw s});return{response:()=>o,json:async()=>(await o).json()}}};var B=class{constructor(t){this._transport=t}get(t,{request:e={}}={}){return this._transport.send("v1/uploads/"+encodeURIComponent(t),{...e,method:"GET"})}create({account:t,files:e,request:o={}}){let s=new FormData;for(let r of e)s.append("file",r);return this._transport.send("v1/uploads",{...o,method:"POST",body:s,searchParams:{account:t}})}delete(t,{request:e={}}={}){return this._transport.send("v1/uploads/"+encodeURIComponent(t),{...e,method:"DELETE"})}};var a=require("zod"),Lt=a.z.object({data:a.z.object({event:a.z.object({id:a.z.string(),type:a.z.string(),payload:a.z.record(a.z.string()),createdAt:a.z.string().datetime()})})});var M=class{constructor(t){this._transport=t}async event({key:t=process.env[X],maxSignatures:e=3,request:o}){let s=o.headers["gds-signature"];if(t!==!1){if(t===void 0)throw new Error("Missing webhook signing key in process.env."+X);if(!s)throw new Error("Missing signature header");if(!this._verifySignature(t,o.body,Array.isArray(s)?s.slice(0,e):[s]))throw new Error("Untrusted signature")}let{data:r}=Lt.parse(o.body);return{event:r.event}}async _verifySignature(t,e,o){let s=await crypto.subtle.importKey("raw",new TextEncoder().encode(t),{name:"HMAC",hash:"SHA-256"},!1,["sign","verify"]);for(let r of o)if(await crypto.subtle.verify("HMAC",s,new TextEncoder().encode(atob(r)),new TextEncoder().encode(JSON.stringify(e))))return!0;return!1}};var N=class{constructor(t){this._transport=t}get(t,{request:e={}}={}){return this._transport.send("v1/webhooks/subscriptions/"+encodeURIComponent(t),{...e,method:"GET"})}list({request:t={}}={}){return this._transport.send("v1/webhooks/subscriptions",{...t,method:"GET"})}test(t,{request:e={}}={}){return this._transport.send("v1/webhooks/subscriptions/"+encodeURIComponent(t)+"/test",{...e,method:"POST"})}create({body:t,request:e={}}){return this._transport.send("v1/webhooks/subscriptions",{...e,method:"POST",json:t})}delete(t,{request:e={}}={}){return this._transport.send("v1/webhooks/subscriptions/"+encodeURIComponent(t),{...e,method:"DELETE"})}};var j=class{constructor(t){this._transport=t}getNotifications({request:t={}}={}){return this._transport.send(".well-known/notifications",{...t,method:"GET"})}};var W=class n{static DEFAULT_BASE_URL=yt;static PublicAuthentication=m;static BasicAuthentication=g;static BearerAuthentication=b;_transport;account;accountAccessToken;accountConversationSettings;action;boilerplateCategory;boilerplateContent;channel;compositionSection;contact;conversation;label;message;model;note;notificationSubscription;source;statistics;upload;webhook;webhookSubscription;wellKnown;constructor(t,{baseURL:e,...o}={}){this._transport=new F({requestFilterables:[new E,t],...o,baseURL:e?.toString()??n.getBaseURL()}),this.account=new C(this._transport),this.accountAccessToken=new h(this._transport),this.accountConversationSettings=new f(this._transport),this.action=new O(this._transport),this.boilerplateCategory=new R(this._transport),this.boilerplateContent=new v(this._transport),this.channel=new y(this._transport),this.compositionSection=new T(this._transport),this.contact=new _(this._transport),this.conversation=new L(this._transport),this.label=new I(this._transport),this.message=new A(this._transport),this.model=new S(this._transport),this.note=new w(this._transport),this.notificationSubscription=new U(this._transport),this.source=new D(this._transport),this.statistics=new G(this._transport),this.upload=new B(this._transport),this.webhook=new M(this._transport),this.webhookSubscription=new N(this._transport),this.wellKnown=new j(this._transport)}static getBaseURL(){return process.env[vt]??this.DEFAULT_BASE_URL}};var Z=require("commander"),It=require("ora");function tt({client:n,ora:t}){let e=new Z.Command("actions").description("Actions");return e.addCommand(new Z.Command("list").description("List actions").action(async()=>{let o=await(0,It.oraPromise)(()=>n.action.list().json(),{...t,text:"Finding actions"});console.log(o)})),e}var et=require("commander"),At=require("ora");function ot({client:n,ora:t}){let e=new et.Command("channels").description("Channels");return e.addCommand(new et.Command("list").description("List channels").action(async()=>{let o=await(0,At.oraPromise)(()=>n.channel.list().json(),{...t,text:"Finding channels"});console.log(o)})),e}var Q=require("commander"),H=require("ora");function nt({client:n,ora:t}){let e=new Q.Command("contacts").description("Contacts");return e.addCommand(new Q.Command("get").description("Find contact").argument("<contact>","Contact ID").action(async o=>{let s=await(0,H.oraPromise)(()=>n.contact.get(o).json(),{...t,text:"Finding contact"});console.log(s)})),e.addCommand(new Q.Command("list").description("List contacts").action(async()=>{let o=await(0,H.oraPromise)(()=>n.contact.list().json(),{...t,text:"Finding contacts"});console.log(o)})),e.addCommand(new Q.Command("get-vcf").description("Export Contact as VCF").argument("<contact>","Contact ID").action(async o=>{let s=await(0,H.oraPromise)(()=>n.contact.getVCF(o).response(),{...t,text:"Exporting contact"});console.log(s)})),e}var Y=require("commander"),st=require("ora");function rt({client:n,ora:t}){let e=new Y.Command("conversations").description("Conversations");return e.addCommand(new Y.Command("get").description("Find conversation").argument("<conversation>","Conversation ID").action(async o=>{let s=await(0,st.oraPromise)(()=>n.conversation.get(o).json(),{...t,text:"Finding conversation"});console.log(s)})),e.addCommand(new Y.Command("list").description("List conversations").action(async()=>{let o=await(0,st.oraPromise)(()=>n.conversation.list().json(),{...t,text:"Finding conversations"});console.log(o)})),e}var q=require("commander"),z=require("ora");function it({client:n,ora:t}){let e=new q.Command("labels").description("Labels");return e.addCommand(new q.Command("get").description("Find label").argument("<label>","Label ID").action(async o=>{let s=await(0,z.oraPromise)(()=>n.label.get(o).json(),{...t,text:"Finding label"});console.log(s)})),e.addCommand(new q.Command("list").description("List labels").action(async()=>{let o=await(0,z.oraPromise)(()=>n.label.list().json(),{...t,text:"Finding labels"});console.log(o)})),e.addCommand(new q.Command("conversations").description("Find label conversations").argument("<label>","Label ID").action(async o=>{let s=await(0,z.oraPromise)(()=>n.conversation.listByLabel(o).json(),{...t,text:"Finding conversations"});console.log(s)})),e}var at=require("commander"),St=require("ora");function pt({client:n,ora:t}){let e=new at.Command("messages").description("Messages");return e.addCommand(new at.Command("list").description("List messages").action(async()=>{let o=await(0,St.oraPromise)(()=>n.message.list().json(),{...t,text:"Finding messages"});console.log(o)})),e}var $=require("commander"),ct=require("ora");function mt({client:n,ora:t}){let e=new $.Command("models").description("Models");return e.addCommand(new $.Command("get").description("Find model").argument("<model>","Model ID").action(async o=>{let s=await(0,ct.oraPromise)(()=>n.model.get(o).json(),{...t,text:"Finding model"});console.log(s)})),e.addCommand(new $.Command("list").description("List models").action(async()=>{let o=await(0,ct.oraPromise)(()=>n.model.list().json(),{...t,text:"Finding models"});console.log(o)})),e}var J=require("commander"),dt=require("ora");function lt({client:n,ora:t}){let e=new J.Command("sources").description("Sources");return e.addCommand(new J.Command("get").description("Find source").argument("<source>","Source ID").action(async o=>{let s=await(0,dt.oraPromise)(()=>n.source.get(o).json(),{...t,text:"Finding source"});console.log(s)})),e.addCommand(new J.Command("list").description("List sources").action(async()=>{let o=await(0,dt.oraPromise)(()=>n.source.list().json(),{...t,text:"Finding sources"});console.log(o)})),e}var Ut=require("commander");var ut=require("commander"),wt=require("ora");function Ct({client:n,ora:t}){let e=new ut.Command("notifications").description("Well-Known Notifications Details");return e.addCommand(new ut.Command("get").description("Get Notifications Server Well-Known Info").action(async()=>{let o=await(0,wt.oraPromise)(()=>n.wellKnown.getNotifications().json(),{...t,text:"Finding Notifications Well-Known Info"});console.log(o)})),e}function ht({client:n,ora:t}){let e=new Ut.Command("well-known").description("Well-Known Metadata & Info");return e.addCommand(Ct({client:n,ora:t})),e}var p={ora:{spinner:"simpleDotsScrolling"},client:new W(new m)},Nt=new Et.Command("gds").description("Great Detail Support System").addCommand(tt(p)).addCommand(ot(p)).addCommand(nt(p)).addCommand(rt(p)).addCommand(it(p)).addCommand(pt(p)).addCommand(mt(p)).addCommand(lt(p)).addCommand(ht(p)),jt=Nt;
|
|
1
|
+
"use strict";var At=Object.create;var B=Object.defineProperty;var St=Object.getOwnPropertyDescriptor;var Ut=Object.getOwnPropertyNames;var Et=Object.getPrototypeOf,wt=Object.prototype.hasOwnProperty;var Dt=(n,t)=>{for(var e in t)B(n,e,{get:t[e],enumerable:!0})},mt=(n,t,e,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of Ut(t))!wt.call(n,s)&&s!==e&&B(n,s,{get:()=>t[s],enumerable:!(o=St(t,s))||o.enumerable});return n};var dt=(n,t,e)=>(e=n!=null?At(Et(n)):{},mt(t||!n||!n.__esModule?B(e,"default",{value:n,enumerable:!0}):e,n)),Gt=n=>mt(B({},"__esModule",{value:!0}),n);var kt={};Dt(kt,{default:()=>Pt});module.exports=Gt(kt);var Lt=require("commander");var p=class{getHeaders(){return{}}};var m=class{constructor(t){this._transport=t}get(t,{request:e={}}={}){return this._transport.send("v1/accounts/"+encodeURIComponent(t),{...e,method:"GET"})}getCurrent({request:t={}}){return this._transport.send("v1/accounts/current",{...t,method:"GET"})}update(t,{body:e,request:o={}}){return this._transport.send("v1/accounts/"+encodeURIComponent(t),{...o,method:"PATCH",json:e})}create({body:t,request:e={}}){return this._transport.send("v1/accounts",{...e,method:"POST",json:t})}};var d=class{constructor(t){this._transport=t}get(t,e,{request:o={}}={}){return this._transport.send("v1/accounts/"+encodeURIComponent(t)+"/access-tokens/"+encodeURIComponent(e),{...o,method:"GET"})}list(t,{request:e={}}={}){return this._transport.send("v1/accounts/"+encodeURIComponent(t)+"/access-tokens",{...e,method:"GET"})}delete(t,e,{body:o,request:s={}}={}){return this._transport.send("v1/accounts/"+encodeURIComponent(t)+"/access-tokens/"+encodeURIComponent(e),{...s,method:"DELETE",json:o})}create(t,{body:e={},request:o={}}={}){return this._transport.send("v1/accounts/"+encodeURIComponent(t)+"/access-tokens",{...o,method:"POST",json:e})}};var l=class{constructor(t){this._transport=t}get(t,{request:e={}}={}){return this._transport.send("v1/accounts/"+encodeURIComponent(t)+"/conversation-settings",{...e,method:"GET"})}update(t,{body:e,request:o={}}){return this._transport.send("v1/accounts/"+encodeURIComponent(t)+"/conversation-settings",{...o,method:"PATCH",json:e})}};var u=class{constructor(t){this._transport=t}list({limit:t,sort:e,request:o={}}={}){return this._transport.send("v1/actions",{...o,method:"GET",searchParams:[...this._transport.limitQuery(t),...this._transport.sortQuery(e)]})}};var lt="SUPPORT_ACCESS_TOKEN",ut="SUPPORT_KEY_NAME",Ct="SUPPORT_KEY_PASSWORD",H="SUPPORT_SIGNING_KEY",ht="SUPPORT_BASE_URL";var C=class{name;#t;constructor({name:t=process.env[ut],password:e=process.env[Ct]}={}){if(!t)throw new Error("Name option must be specified when using Basic Authentication");if(!e)throw new Error("Password option must be specified when using Basic Authentication");this.name=t,this.#t=e}getHeaders(){return{Authorization:`Basic ${btoa(this.name+":"+this.#t)}`}}};var h=class{#t;constructor({token:t=process.env[lt]}={}){if(!t)throw new Error("Access Token option must be specified when using Token Authentication");this.#t=t}getHeaders(){return{Authorization:`Bearer ${this.#t}`}}};var f=class{constructor(t){this._transport=t}get(t,{request:e={}}={}){return this._transport.send("v1/boilerplates/categories/"+encodeURIComponent(t),{...e,method:"GET"})}list({limit:t,include:e,request:o={}}={}){return this._transport.send("v1/boilerplates/categories",{...o,method:"GET",searchParams:[...this._transport.limitQuery(t),...this._transport.includeQuery(e)]})}create({body:t,request:e={}}){return this._transport.send("v1/boilerplates/categories",{...e,method:"POST",json:t})}update(t,{body:e,request:o={}}){return this._transport.send("v1/boilerplates/categories/"+encodeURIComponent(t),{...o,method:"PATCH",json:e})}};var O=class{constructor(t){this._transport=t}get(t,{request:e={}}={}){return this._transport.send("v1/boilerplates/contents/"+encodeURIComponent(t),{...e,method:"GET"})}list({limit:t,query:e,request:o={}}={}){return this._transport.send("v1/boilerplates/contents",{...o,method:"GET",searchParams:[...this._transport.limitQuery(t),...this._transport.queryQuery(e)]})}listByCategory=this.listByBoilerplateCategory;listByBoilerplateCategory(t,{limit:e,request:o={}}={}){return this._transport.send("v1/boilerplates/categories/"+encodeURIComponent(t)+"/contents",{...o,method:"GET",searchParams:[...this._transport.limitQuery(e)]})}create({body:t,request:e={}}){return this._transport.send("v1/boilerplates/contents",{...e,method:"POST",json:t})}update(t,{body:e,request:o={}}){return this._transport.send("v1/boilerplates/contents/"+encodeURIComponent(t),{...o,method:"PATCH",json:e})}};var g=class{constructor(t){this._transport=t}get(t,{request:e={}}={}){return this._transport.send("v1/channels/"+encodeURIComponent(t),{...e,method:"GET"})}list({limit:t,query:e,request:o={}}={}){return this._transport.send("v1/channels",{...o,method:"GET",searchParams:[...this._transport.limitQuery(t),...this._transport.queryQuery(e)]})}update(t,{body:e,request:o={}}){return this._transport.send("v1/channels/"+encodeURIComponent(t),{...o,method:"PATCH",json:e})}create({body:t,request:e={}}){return this._transport.send("v1/channels",{...e,method:"POST",json:t})}metaWhatsappGetBusinessProfile(t,{request:e={}}={}){return this._transport.send("v1/channels/"+encodeURIComponent(t)+"/meta-whatsapp/business-profile",{...e,method:"GET"})}twilioSendgridChannelSync(t,{body:e,request:o={}}){return this._transport.send("v1/channels/"+encodeURIComponent(t)+"/twilio-sendgrid/sync",{...o,method:"POST",json:e})}};var R=class{constructor(t){this._transport=t}get(t,{request:e={}}={}){return this._transport.send("v1/composition-sections/"+encodeURIComponent(t),{...e,method:"GET"})}list({limit:t,request:e={}}={}){return this._transport.send("v1/composition-sections",{...e,method:"GET",searchParams:[...this._transport.limitQuery(t)]})}listByChannel(t,{limit:e,request:o={}}={}){return this._transport.send("v1/channels/"+encodeURIComponent(t)+"/composition-sections",{...o,method:"GET",searchParams:[...this._transport.limitQuery(e)]})}create({body:t,request:e={}}){return this._transport.send("v1/composition-sections",{...e,method:"POST",json:t})}update(t,{body:e,request:o={}}){return this._transport.send("v1/composition-sections/"+encodeURIComponent(t),{...o,method:"PATCH",json:e})}};var ft="https://api.support.greatdetail.com",Ot={"X-Powered-By":"GDSupport/JavaScript"};var b=class{constructor(t){this._transport=t}get(t,{include:e,request:o={}}={}){return this._transport.send("v1/contacts/"+encodeURIComponent(t),{...o,method:"GET",searchParams:[...this._transport.includeQuery(e??{})]})}getRelativeVCFURL(t,{vcf:e={}}={}){let o=e.variant??"vcard",s=e.format??(o==="vcard"?"vcf":"json");return"v1/contacts/"+encodeURIComponent(t)+"/vcf?variant="+encodeURIComponent(o)+"&format="+encodeURIComponent(s)}getVCFURL(t,e={}){return this._transport.getURL(this.getRelativeVCFURL(t,e))}getVCF(t,e={}){return this._transport.send(this.getVCFURL(t,e),{method:"GET"})}list({limit:t,query:e,request:o={}}={}){return this._transport.send("v1/contacts",{...o,method:"GET",searchParams:[...this._transport.limitQuery(t),...this._transport.queryQuery(e)]})}listByLabel(t,{limit:e,request:o={}}={}){return this._transport.send("v1/labels/"+encodeURIComponent(t)+"/contacts",{...o,method:"GET",searchParams:[...this._transport.limitQuery(e)]})}create({body:t,request:e={}}){return this._transport.send("v1/contacts",{...e,method:"POST",json:t})}update(t,{body:e,request:o={}}){return this._transport.send("v1/contacts/"+encodeURIComponent(t),{...o,method:"PATCH",json:e})}delete(t,{request:e={}}={}){return this._transport.send("v1/contacts/"+encodeURIComponent(t),{...e,method:"DELETE"})}};var v=class{constructor(t){this._transport=t}get(t,{include:e,request:o={}}={}){return this._transport.send("v1/conversations/"+encodeURIComponent(t),{...o,method:"GET",searchParams:[...this._transport.includeQuery(e??{})]})}list({query:t,limit:e,filter:o,include:s,request:r={}}={}){return this._transport.send("v1/conversations",{...r,method:"GET",searchParams:[...this._transport.queryQuery(t),...this._transport.limitQuery(e),...o?[["filter",o]]:[],...this._transport.includeQuery(s??{})]})}listByLabel(t,{limit:e,request:o={}}={}){return this._transport.send("v1/labels/"+encodeURIComponent(t)+"/conversations",{...o,method:"GET",searchParams:[...this._transport.limitQuery(e)]})}listByContact(t,{limit:e,request:o={}}={}){return this._transport.send("v1/contacts/"+encodeURIComponent(t)+"/conversations",{...o,method:"GET",searchParams:[...this._transport.limitQuery(e)]})}listByChannel(t,{limit:e,request:o={}}={}){return this._transport.send("v1/channels/"+encodeURIComponent(t)+"/conversations",{...o,method:"GET",searchParams:[...this._transport.limitQuery(e)]})}create({body:t,request:e={}}){return this._transport.send("v1/conversations",{...e,method:"POST",json:t})}update(t,{body:e,request:o={}}){return this._transport.send("v1/conversations/"+encodeURIComponent(t),{...o,method:"PATCH",json:e})}delete(t,{request:e={}}={}){return this._transport.send("v1/conversations/"+encodeURIComponent(t),{...e,method:"DELETE"})}};var y=class{constructor(t){this._transport=t}get(t,{request:e={}}={}){return this._transport.send("v1/labels/"+encodeURIComponent(t),{...e,method:"GET"})}list({limit:t,query:e,include:o,request:s={}}={}){return this._transport.send("v1/labels",{...s,method:"GET",searchParams:[...this._transport.limitQuery(t),...this._transport.queryQuery(e),...this._transport.includeQuery(o??{})]})}listByContact(t,{limit:e,request:o={}}={}){return this._transport.send("v1/contacts/"+encodeURIComponent(t)+"/labels",{...o,method:"GET",searchParams:[...this._transport.limitQuery(e)]})}listByConversation(t,{limit:e,request:o={}}={}){return this._transport.send("v1/conversations/"+encodeURIComponent(t)+"/labels",{...o,method:"GET",searchParams:[...this._transport.limitQuery(e)]})}create({body:t,request:e={}}){return this._transport.send("v1/labels",{...e,method:"POST",json:t})}update(t,{body:e,request:o={}}){return this._transport.send("v1/labels/"+encodeURIComponent(t),{...o,method:"PATCH",json:e})}delete(t,{request:e={}}={}){return this._transport.send("v1/labels/"+encodeURIComponent(t),{...e,method:"DELETE"})}};var _=class{constructor(t){this._transport=t}list({limit:t,include:e,request:o={}}={}){return this._transport.send("v1/messages",{...o,method:"GET",searchParams:[...this._transport.limitQuery(t),...this._transport.includeQuery(e??{})]})}listByConversation(t,{limit:e,include:o,request:s={}}={}){return this._transport.send("v1/conversations/"+encodeURIComponent(t)+"/messages",{...s,method:"GET",searchParams:[...this._transport.limitQuery(e),...this._transport.includeQuery(o??{})]})}listByChannel(t,{limit:e,include:o,request:s={}}={}){return this._transport.send("v1/channels/"+encodeURIComponent(t)+"/messages",{...s,method:"GET",searchParams:[...this._transport.limitQuery(e),...this._transport.includeQuery(o)]})}create({body:t,request:e={}}){return this._transport.send("v1/messages",{...e,method:"POST",json:t})}delete(t,{request:e={}}={}){return this._transport.send("v1/messages/"+encodeURIComponent(t),{...e,method:"DELETE"})}};var T=class{constructor(t){this._transport=t}get(t,{request:e={}}={}){return this._transport.send("v1/models/"+encodeURIComponent(t),{...e,method:"GET"})}list({request:t={}}={}){return this._transport.send("v1/models",{...t,method:"GET"})}createResponse(t,{body:e,request:o={}}){return this._transport.send("v1/models/"+encodeURIComponent(t)+"/response",{...o,method:"POST",timeout:12e4,json:e})}createCorrection(t,{body:e,request:o={}}){return this._transport.send("v1/models/"+encodeURIComponent(t)+"/correction",{...o,method:"POST",json:e})}};var L=class{constructor(t){this._transport=t}get(t,{request:e={}}={}){return this._transport.send("v1/notes/"+encodeURIComponent(t),{...e,method:"GET"})}listByContact(t,{request:e={}}={}){return this._transport.send("v1/contacts/"+encodeURIComponent(t)+"/notes",{...e,method:"GET"})}listByConversation(t,{request:e={}}={}){return this._transport.send("v1/conversations/"+encodeURIComponent(t)+"/notes",{...e,method:"GET"})}createForContact(t,{body:e,request:o={}}){return this._transport.send("v1/contacts/"+encodeURIComponent(t)+"/notes",{...o,method:"POST",json:e})}createForConversation(t,{body:e,request:o={}}){return this._transport.send("v1/conversations/"+encodeURIComponent(t)+"/notes",{...o,method:"POST",json:e})}update(t,{body:e,request:o={}}){return this._transport.send("v1/notes/"+encodeURIComponent(t),{...o,method:"PATCH",json:e})}};var I=class{constructor(t){this._transport=t}createForContact(t,{body:e,request:o={}}){return this._transport.send("v1/contacts/"+encodeURIComponent(t)+"/notification-subscriptions",{...o,method:"POST",json:e})}};var A=class n{constructor(t=n.STANDARD_HEADERS){this._standardHeaders=t}static STANDARD_HEADERS=Ot;async filter(){return{headers:this.getHeaders()}}getHeaders(){return this._standardHeaders}};var S=class{constructor(t){this._transport=t}get(t,{request:e={}}={}){return this._transport.send("v1/sources/"+encodeURIComponent(t),{...e,method:"GET"})}list({featured:t,category:e,request:o={}}={}){let s=[];if(e){let r=Array.isArray(e)?e:[e];for(let c of r)s.push(["category",c])}return t!==void 0&&s.push(["featured",String(t)]),this._transport.send("v1/sources",{...o,method:"GET",searchParams:s})}};var U=class{constructor(t){this._transport=t}getMessageFrequency({request:t={}}={}){return this._transport.send("v1/statistics/message-frequency",{...t,method:"GET"})}getChannelMessageFrequency(t,{request:e={}}={}){return this._transport.send("v1/channels/"+encodeURIComponent(t)+"/statistics/message-frequency",{...e,method:"GET"})}getModelUsage({request:t={}}={}){return this._transport.send("v1/statistics/model-usage",{...t,method:"GET"})}};var gt=dt(require("is-network-error"),1),N=dt(require("ky"),1);var M=class extends Error{constructor(e,o){super("Support Error",{cause:o});this.response=e}};var E=class{client;options;constructor({baseURL:t,...e}){this.options={...e,baseURL:t},this.client=N.default.create({prefixUrl:this.options.baseURL,timeout:12e3,hooks:{beforeRequest:[o=>{for(let s of this.options.requestFilterables){let r=s.getHeaders();for(let[c,It]of Object.entries(r))o.headers.has(c)||o.headers.set(c,It)}}]}})}getURL(t){return new URL(t,this.options.baseURL).toString()}sortQuery(t){let e=[];if(t===void 0)return e;for(let[o,s]of Object.entries(t))s!==void 0&&e.push(["sort",s+o]);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 o of Object.keys(t))e.push(["include",o]);return e}queryQuery(t){let e=[];return t===void 0||e.push(["query",t]),e}send(t,e={}){let o=this.client(t,e).catch(async s=>{throw(0,gt.default)(s)?new Error("A network error occurred",{cause:s}):s instanceof N.HTTPError?new M(s.response,s):s});return{response:()=>o,json:async()=>(await o).json()}}};var w=class{constructor(t){this._transport=t}get(t,{request:e={}}={}){return this._transport.send("v1/uploads/"+encodeURIComponent(t),{...e,method:"GET"})}list({request:t={}}={}){return this._transport.send("v1/uploads",{...t,method:"GET"})}create({account:t,files:e,request:o={}}){let s=new FormData;for(let r of e)s.append("file",r);return this._transport.send("v1/uploads",{...o,method:"POST",body:s,searchParams:{account:t}})}delete(t,{request:e={}}={}){return this._transport.send("v1/uploads/"+encodeURIComponent(t),{...e,method:"DELETE"})}};var i=require("zod"),Rt=i.z.object({data:i.z.object({event:i.z.object({id:i.z.string(),type:i.z.string(),payload:i.z.record(i.z.string()),createdAt:i.z.string().datetime()})})});var D=class{constructor(t){this._transport=t}async event({key:t=process.env[H],maxSignatures:e=3,request:o}){let s=o.headers["gds-signature"];if(t!==!1){if(t===void 0)throw new Error("Missing webhook signing key in process.env."+H);if(!s)throw new Error("Missing signature header");if(!this._verifySignature(t,o.body,Array.isArray(s)?s.slice(0,e):[s]))throw new Error("Untrusted signature")}let{data:r}=Rt.parse(o.body);return{event:r.event}}async _verifySignature(t,e,o){let s=await crypto.subtle.importKey("raw",new TextEncoder().encode(t),{name:"HMAC",hash:"SHA-256"},!1,["sign","verify"]);for(let r of o)if(await crypto.subtle.verify("HMAC",s,new TextEncoder().encode(atob(r)),new TextEncoder().encode(JSON.stringify(e))))return!0;return!1}};var G=class{constructor(t){this._transport=t}get(t,{request:e={}}={}){return this._transport.send("v1/webhooks/subscriptions/"+encodeURIComponent(t),{...e,method:"GET"})}list({request:t={}}={}){return this._transport.send("v1/webhooks/subscriptions",{...t,method:"GET"})}test(t,{request:e={}}={}){return this._transport.send("v1/webhooks/subscriptions/"+encodeURIComponent(t)+"/test",{...e,method:"POST"})}create({body:t,request:e={}}){return this._transport.send("v1/webhooks/subscriptions",{...e,method:"POST",json:t})}delete(t,{request:e={}}={}){return this._transport.send("v1/webhooks/subscriptions/"+encodeURIComponent(t),{...e,method:"DELETE"})}};var x=class{constructor(t){this._transport=t}getNotifications({request:t={}}={}){return this._transport.send(".well-known/notifications",{...t,method:"GET"})}};var P=class n{static DEFAULT_BASE_URL=ft;static PublicAuthentication=p;static BasicAuthentication=C;static BearerAuthentication=h;_transport;account;accountAccessToken;accountConversationSettings;action;boilerplateCategory;boilerplateContent;channel;compositionSection;contact;conversation;label;message;model;note;notificationSubscription;source;statistics;upload;webhook;webhookSubscription;wellKnown;constructor(t,{baseURL:e,...o}={}){this._transport=new E({requestFilterables:[new A,t],...o,baseURL:e?.toString()??n.getBaseURL()}),this.account=new m(this._transport),this.accountAccessToken=new d(this._transport),this.accountConversationSettings=new l(this._transport),this.action=new u(this._transport),this.boilerplateCategory=new f(this._transport),this.boilerplateContent=new O(this._transport),this.channel=new g(this._transport),this.compositionSection=new R(this._transport),this.contact=new b(this._transport),this.conversation=new v(this._transport),this.label=new y(this._transport),this.message=new _(this._transport),this.model=new T(this._transport),this.note=new L(this._transport),this.notificationSubscription=new I(this._transport),this.source=new S(this._transport),this.statistics=new U(this._transport),this.upload=new w(this._transport),this.webhook=new D(this._transport),this.webhookSubscription=new G(this._transport),this.wellKnown=new x(this._transport)}static getBaseURL(){return process.env[ht]??this.DEFAULT_BASE_URL}};var q=require("commander"),bt=require("ora");function Y({client:n,ora:t}){let e=new q.Command("actions").description("Actions");return e.addCommand(new q.Command("list").description("List actions").action(async()=>{let o=await(0,bt.oraPromise)(()=>n.action.list().json(),{...t,text:"Finding actions"});console.log(o)})),e}var z=require("commander"),vt=require("ora");function J({client:n,ora:t}){let e=new z.Command("channels").description("Channels");return e.addCommand(new z.Command("list").description("List channels").action(async()=>{let o=await(0,vt.oraPromise)(()=>n.channel.list().json(),{...t,text:"Finding channels"});console.log(o)})),e}var k=require("commander"),j=require("ora");function $({client:n,ora:t}){let e=new k.Command("contacts").description("Contacts");return e.addCommand(new k.Command("get").description("Find contact").argument("<contact>","Contact ID").action(async o=>{let s=await(0,j.oraPromise)(()=>n.contact.get(o).json(),{...t,text:"Finding contact"});console.log(s)})),e.addCommand(new k.Command("list").description("List contacts").action(async()=>{let o=await(0,j.oraPromise)(()=>n.contact.list().json(),{...t,text:"Finding contacts"});console.log(o)})),e.addCommand(new k.Command("get-vcf").description("Export Contact as VCF").argument("<contact>","Contact ID").action(async o=>{let s=await(0,j.oraPromise)(()=>n.contact.getVCF(o).response(),{...t,text:"Exporting contact"});console.log(s)})),e}var W=require("commander"),X=require("ora");function Z({client:n,ora:t}){let e=new W.Command("conversations").description("Conversations");return e.addCommand(new W.Command("get").description("Find conversation").argument("<conversation>","Conversation ID").action(async o=>{let s=await(0,X.oraPromise)(()=>n.conversation.get(o).json(),{...t,text:"Finding conversation"});console.log(s)})),e.addCommand(new W.Command("list").description("List conversations").action(async()=>{let o=await(0,X.oraPromise)(()=>n.conversation.list().json(),{...t,text:"Finding conversations"});console.log(o)})),e}var F=require("commander"),Q=require("ora");function tt({client:n,ora:t}){let e=new F.Command("labels").description("Labels");return e.addCommand(new F.Command("get").description("Find label").argument("<label>","Label ID").action(async o=>{let s=await(0,Q.oraPromise)(()=>n.label.get(o).json(),{...t,text:"Finding label"});console.log(s)})),e.addCommand(new F.Command("list").description("List labels").action(async()=>{let o=await(0,Q.oraPromise)(()=>n.label.list().json(),{...t,text:"Finding labels"});console.log(o)})),e.addCommand(new F.Command("conversations").description("Find label conversations").argument("<label>","Label ID").action(async o=>{let s=await(0,Q.oraPromise)(()=>n.conversation.listByLabel(o).json(),{...t,text:"Finding conversations"});console.log(s)})),e}var et=require("commander"),yt=require("ora");function ot({client:n,ora:t}){let e=new et.Command("messages").description("Messages");return e.addCommand(new et.Command("list").description("List messages").action(async()=>{let o=await(0,yt.oraPromise)(()=>n.message.list().json(),{...t,text:"Finding messages"});console.log(o)})),e}var K=require("commander"),nt=require("ora");function st({client:n,ora:t}){let e=new K.Command("models").description("Models");return e.addCommand(new K.Command("get").description("Find model").argument("<model>","Model ID").action(async o=>{let s=await(0,nt.oraPromise)(()=>n.model.get(o).json(),{...t,text:"Finding model"});console.log(s)})),e.addCommand(new K.Command("list").description("List models").action(async()=>{let o=await(0,nt.oraPromise)(()=>n.model.list().json(),{...t,text:"Finding models"});console.log(o)})),e}var V=require("commander"),rt=require("ora");function it({client:n,ora:t}){let e=new V.Command("sources").description("Sources");return e.addCommand(new V.Command("get").description("Find source").argument("<source>","Source ID").action(async o=>{let s=await(0,rt.oraPromise)(()=>n.source.get(o).json(),{...t,text:"Finding source"});console.log(s)})),e.addCommand(new V.Command("list").description("List sources").action(async()=>{let o=await(0,rt.oraPromise)(()=>n.source.list().json(),{...t,text:"Finding sources"});console.log(o)})),e}var Tt=require("commander");var at=require("commander"),_t=require("ora");function pt({client:n,ora:t}){let e=new at.Command("notifications").description("Well-Known Notifications Details");return e.addCommand(new at.Command("get").description("Get Notifications Server Well-Known Info").action(async()=>{let o=await(0,_t.oraPromise)(()=>n.wellKnown.getNotifications().json(),{...t,text:"Finding Notifications Well-Known Info"});console.log(o)})),e}function ct({client:n,ora:t}){let e=new Tt.Command("well-known").description("Well-Known Metadata & Info");return e.addCommand(pt({client:n,ora:t})),e}var a={ora:{spinner:"simpleDotsScrolling"},client:new P(new p)},xt=new Lt.Command("gds").description("Great Detail Support System").addCommand(Y(a)).addCommand(J(a)).addCommand($(a)).addCommand(Z(a)).addCommand(tt(a)).addCommand(ot(a)).addCommand(st(a)).addCommand(it(a)).addCommand(ct(a)),Pt=xt;
|
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-5LTP3VGA.js";import"../chunk-XYLD2NDD.js";export{a as default};
|
package/dist/cli.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
"use strict";var Gt=Object.create;var ht=Object.defineProperty;var xt=Object.getOwnPropertyDescriptor;var Pt=Object.getOwnPropertyNames;var kt=Object.getPrototypeOf,Ft=Object.prototype.hasOwnProperty;var Bt=(n,t,e,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of Pt(t))!Ft.call(n,s)&&s!==e&&ht(n,s,{get:()=>t[s],enumerable:!(o=xt(t,s))||o.enumerable});return n};var ft=(n,t,e)=>(e=n!=null?Gt(kt(n)):{},Bt(t||!n||!n.__esModule?ht(e,"default",{value:n,enumerable:!0}):e,n));var Ut=require("commander");var m=class{getHeaders(){return{}}};var C=class{constructor(t){this._transport=t}get(t,{request:e={}}={}){return this._transport.send("v1/accounts/"+encodeURIComponent(t),{...e,method:"GET"})}getCurrent({request:t={}}){return this._transport.send("v1/accounts/current",{...t,method:"GET"})}update(t,{body:e,request:o={}}){return this._transport.send("v1/accounts/"+encodeURIComponent(t),{...o,method:"PATCH",json:e})}create({body:t,request:e={}}){return this._transport.send("v1/accounts",{...e,method:"POST",json:t})}};var h=class{constructor(t){this._transport=t}get(t,e,{request:o={}}={}){return this._transport.send("v1/accounts/"+encodeURIComponent(t)+"/access-tokens/"+encodeURIComponent(e),{...o,method:"GET"})}list(t,{request:e={}}={}){return this._transport.send("v1/accounts/"+encodeURIComponent(t)+"/access-tokens",{...e,method:"GET"})}delete(t,e,{body:o,request:s={}}={}){return this._transport.send("v1/accounts/"+encodeURIComponent(t)+"/access-tokens/"+encodeURIComponent(e),{...s,method:"DELETE",json:o})}create(t,{body:e={},request:o={}}={}){return this._transport.send("v1/accounts/"+encodeURIComponent(t)+"/access-tokens",{...o,method:"POST",json:e})}};var f=class{constructor(t){this._transport=t}get(t,{request:e={}}={}){return this._transport.send("v1/accounts/"+encodeURIComponent(t)+"/conversation-settings",{...e,method:"GET"})}update(t,{body:e,request:o={}}){return this._transport.send("v1/accounts/"+encodeURIComponent(t)+"/conversation-settings",{...o,method:"PATCH",json:e})}};var O=class{constructor(t){this._transport=t}list({limit:t,sort:e,request:o={}}={}){return this._transport.send("v1/actions",{...o,method:"GET",searchParams:[...this._transport.limitQuery(t),...this._transport.sortQuery(e)]})}};var Ot="SUPPORT_ACCESS_TOKEN",gt="SUPPORT_KEY_NAME",bt="SUPPORT_KEY_PASSWORD",J="SUPPORT_SIGNING_KEY",Rt="SUPPORT_BASE_URL";var g=class{name;#t;constructor({name:t=process.env[gt],password:e=process.env[bt]}={}){if(!t)throw new Error("Name option must be specified when using Basic Authentication");if(!e)throw new Error("Password option must be specified when using Basic Authentication");this.name=t,this.#t=e}getHeaders(){return{Authorization:`Basic ${btoa(this.name+":"+this.#t)}`}}};var b=class{#t;constructor({token:t=process.env[Ot]}={}){if(!t)throw new Error("Access Token option must be specified when using Token Authentication");this.#t=t}getHeaders(){return{Authorization:`Bearer ${this.#t}`}}};var R=class{constructor(t){this._transport=t}get(t,{request:e={}}={}){return this._transport.send("v1/boilerplates/categories/"+encodeURIComponent(t),{...e,method:"GET"})}list({limit:t,include:e,request:o={}}={}){return this._transport.send("v1/boilerplates/categories",{...o,method:"GET",searchParams:[...this._transport.limitQuery(t),...this._transport.includeQuery(e)]})}create({body:t,request:e={}}){return this._transport.send("v1/boilerplates/categories",{...e,method:"POST",json:t})}update(t,{body:e,request:o={}}){return this._transport.send("v1/boilerplates/categories/"+encodeURIComponent(t),{...o,method:"PATCH",json:e})}};var v=class{constructor(t){this._transport=t}get(t,{request:e={}}={}){return this._transport.send("v1/boilerplates/contents/"+encodeURIComponent(t),{...e,method:"GET"})}list({limit:t,query:e,request:o={}}={}){return this._transport.send("v1/boilerplates/contents",{...o,method:"GET",searchParams:[...this._transport.limitQuery(t),...this._transport.queryQuery(e)]})}listByCategory=this.listByBoilerplateCategory;listByBoilerplateCategory(t,{limit:e,request:o={}}={}){return this._transport.send("v1/boilerplates/categories/"+encodeURIComponent(t)+"/contents",{...o,method:"GET",searchParams:[...this._transport.limitQuery(e)]})}create({body:t,request:e={}}){return this._transport.send("v1/boilerplates/contents",{...e,method:"POST",json:t})}update(t,{body:e,request:o={}}){return this._transport.send("v1/boilerplates/contents/"+encodeURIComponent(t),{...o,method:"PATCH",json:e})}};var y=class{constructor(t){this._transport=t}get(t,{request:e={}}={}){return this._transport.send("v1/channels/"+encodeURIComponent(t),{...e,method:"GET"})}list({limit:t,query:e,request:o={}}={}){return this._transport.send("v1/channels",{...o,method:"GET",searchParams:[...this._transport.limitQuery(t),...this._transport.queryQuery(e)]})}update(t,{body:e,request:o={}}){return this._transport.send("v1/channels/"+encodeURIComponent(t),{...o,method:"PATCH",json:e})}create({body:t,request:e={}}){return this._transport.send("v1/channels",{...e,method:"POST",json:t})}metaWhatsappGetBusinessProfile(t,{request:e={}}={}){return this._transport.send("v1/channels/"+encodeURIComponent(t)+"/meta-whatsapp/business-profile",{...e,method:"GET"})}twilioSendgridChannelSync(t,{body:e,request:o={}}){return this._transport.send("v1/channels/"+encodeURIComponent(t)+"/twilio-sendgrid/sync",{...o,method:"POST",json:e})}};var T=class{constructor(t){this._transport=t}get(t,{request:e={}}={}){return this._transport.send("v1/composition-sections/"+encodeURIComponent(t),{...e,method:"GET"})}list({limit:t,request:e={}}={}){return this._transport.send("v1/composition-sections",{...e,method:"GET",searchParams:[...this._transport.limitQuery(t)]})}listByChannel(t,{limit:e,request:o={}}={}){return this._transport.send("v1/channels/"+encodeURIComponent(t)+"/composition-sections",{...o,method:"GET",searchParams:[...this._transport.limitQuery(e)]})}create({body:t,request:e={}}){return this._transport.send("v1/composition-sections",{...e,method:"POST",json:t})}update(t,{body:e,request:o={}}){return this._transport.send("v1/composition-sections/"+encodeURIComponent(t),{...o,method:"PATCH",json:e})}};var vt="https://api.support.greatdetail.com",yt={"X-Powered-By":"GDSupport/JavaScript"};var _=class{constructor(t){this._transport=t}get(t,{include:e,request:o={}}={}){return this._transport.send("v1/contacts/"+encodeURIComponent(t),{...o,method:"GET",searchParams:[...this._transport.includeQuery(e??{})]})}getRelativeVCFURL(t,{vcf:e={}}={}){let o=e.variant??"vcard",s=e.format??(o==="vcard"?"vcf":"json");return"v1/contacts/"+encodeURIComponent(t)+"/vcf?variant="+encodeURIComponent(o)+"&format="+encodeURIComponent(s)}getVCFURL(t,e={}){return this._transport.getURL(this.getRelativeVCFURL(t,e))}getVCF(t,e={}){return this._transport.send(this.getVCFURL(t,e),{method:"GET"})}list({limit:t,query:e,request:o={}}={}){return this._transport.send("v1/contacts",{...o,method:"GET",searchParams:[...this._transport.limitQuery(t),...this._transport.queryQuery(e)]})}listByLabel(t,{limit:e,request:o={}}={}){return this._transport.send("v1/labels/"+encodeURIComponent(t)+"/contacts",{...o,method:"GET",searchParams:[...this._transport.limitQuery(e)]})}create({body:t,request:e={}}){return this._transport.send("v1/contacts",{...e,method:"POST",json:t})}update(t,{body:e,request:o={}}){return this._transport.send("v1/contacts/"+encodeURIComponent(t),{...o,method:"PATCH",json:e})}delete(t,{request:e={}}={}){return this._transport.send("v1/contacts/"+encodeURIComponent(t),{...e,method:"DELETE"})}};var L=class{constructor(t){this._transport=t}get(t,{include:e,request:o={}}={}){return this._transport.send("v1/conversations/"+encodeURIComponent(t),{...o,method:"GET",searchParams:[...this._transport.includeQuery(e??{})]})}list({limit:t,filter:e,include:o,request:s={}}={}){return this._transport.send("v1/conversations",{...s,method:"GET",searchParams:[...this._transport.limitQuery(t),...e?[["filter",e]]:[],...this._transport.includeQuery(o??{})]})}listByLabel(t,{limit:e,request:o={}}={}){return this._transport.send("v1/labels/"+encodeURIComponent(t)+"/conversations",{...o,method:"GET",searchParams:[...this._transport.limitQuery(e)]})}listByContact(t,{limit:e,request:o={}}={}){return this._transport.send("v1/contacts/"+encodeURIComponent(t)+"/conversations",{...o,method:"GET",searchParams:[...this._transport.limitQuery(e)]})}listByChannel(t,{limit:e,request:o={}}={}){return this._transport.send("v1/channels/"+encodeURIComponent(t)+"/conversations",{...o,method:"GET",searchParams:[...this._transport.limitQuery(e)]})}create({body:t,request:e={}}){return this._transport.send("v1/conversations",{...e,method:"POST",json:t})}update(t,{body:e,request:o={}}){return this._transport.send("v1/conversations/"+encodeURIComponent(t),{...o,method:"PATCH",json:e})}delete(t,{request:e={}}={}){return this._transport.send("v1/conversations/"+encodeURIComponent(t),{...e,method:"DELETE"})}};var I=class{constructor(t){this._transport=t}get(t,{request:e={}}={}){return this._transport.send("v1/labels/"+encodeURIComponent(t),{...e,method:"GET"})}list({limit:t,query:e,include:o,request:s={}}={}){return this._transport.send("v1/labels",{...s,method:"GET",searchParams:[...this._transport.limitQuery(t),...this._transport.queryQuery(e),...this._transport.includeQuery(o??{})]})}listByContact(t,{limit:e,request:o={}}={}){return this._transport.send("v1/contacts/"+encodeURIComponent(t)+"/labels",{...o,method:"GET",searchParams:[...this._transport.limitQuery(e)]})}listByConversation(t,{limit:e,request:o={}}={}){return this._transport.send("v1/conversations/"+encodeURIComponent(t)+"/labels",{...o,method:"GET",searchParams:[...this._transport.limitQuery(e)]})}create({body:t,request:e={}}){return this._transport.send("v1/labels",{...e,method:"POST",json:t})}update(t,{body:e,request:o={}}){return this._transport.send("v1/labels/"+encodeURIComponent(t),{...o,method:"PATCH",json:e})}delete(t,{request:e={}}={}){return this._transport.send("v1/labels/"+encodeURIComponent(t),{...e,method:"DELETE"})}};var A=class{constructor(t){this._transport=t}list({limit:t,include:e,request:o={}}={}){return this._transport.send("v1/messages",{...o,method:"GET",searchParams:[...this._transport.limitQuery(t),...this._transport.includeQuery(e??{})]})}listByConversation(t,{limit:e,include:o,request:s={}}={}){return this._transport.send("v1/conversations/"+encodeURIComponent(t)+"/messages",{...s,method:"GET",searchParams:[...this._transport.limitQuery(e),...this._transport.includeQuery(o??{})]})}listByChannel(t,{limit:e,include:o,request:s={}}={}){return this._transport.send("v1/channels/"+encodeURIComponent(t)+"/messages",{...s,method:"GET",searchParams:[...this._transport.limitQuery(e),...this._transport.includeQuery(o)]})}create({body:t,request:e={}}){return this._transport.send("v1/messages",{...e,method:"POST",json:t})}delete(t,{request:e={}}={}){return this._transport.send("v1/messages/"+encodeURIComponent(t),{...e,method:"DELETE"})}};var S=class{constructor(t){this._transport=t}get(t,{request:e={}}={}){return this._transport.send("v1/models/"+encodeURIComponent(t),{...e,method:"GET"})}list({request:t={}}={}){return this._transport.send("v1/models",{...t,method:"GET"})}createResponse(t,{body:e,request:o={}}){return this._transport.send("v1/models/"+encodeURIComponent(t)+"/response",{...o,method:"POST",timeout:12e4,json:e})}createCorrection(t,{body:e,request:o={}}){return this._transport.send("v1/models/"+encodeURIComponent(t)+"/correction",{...o,method:"POST",json:e})}};var w=class{constructor(t){this._transport=t}get(t,{request:e={}}={}){return this._transport.send("v1/notes/"+encodeURIComponent(t),{...e,method:"GET"})}listByContact(t,{request:e={}}={}){return this._transport.send("v1/contacts/"+encodeURIComponent(t)+"/notes",{...e,method:"GET"})}listByConversation(t,{request:e={}}={}){return this._transport.send("v1/conversations/"+encodeURIComponent(t)+"/notes",{...e,method:"GET"})}createForContact(t,{body:e,request:o={}}){return this._transport.send("v1/contacts/"+encodeURIComponent(t)+"/notes",{...o,method:"POST",json:e})}createForConversation(t,{body:e,request:o={}}){return this._transport.send("v1/conversations/"+encodeURIComponent(t)+"/notes",{...o,method:"POST",json:e})}update(t,{body:e,request:o={}}){return this._transport.send("v1/notes/"+encodeURIComponent(t),{...o,method:"PATCH",json:e})}};var U=class{constructor(t){this._transport=t}createForContact(t,{body:e,request:o={}}){return this._transport.send("v1/contacts/"+encodeURIComponent(t)+"/notification-subscriptions",{...o,method:"POST",json:e})}};var E=class n{constructor(t=n.STANDARD_HEADERS){this._standardHeaders=t}static STANDARD_HEADERS=yt;async filter(){return{headers:this.getHeaders()}}getHeaders(){return this._standardHeaders}};var D=class{constructor(t){this._transport=t}get(t,{request:e={}}={}){return this._transport.send("v1/sources/"+encodeURIComponent(t),{...e,method:"GET"})}list({featured:t,category:e,request:o={}}={}){let s=[];if(e){let r=Array.isArray(e)?e:[e];for(let l of r)s.push(["category",l])}return t!==void 0&&s.push(["featured",String(t)]),this._transport.send("v1/sources",{...o,method:"GET",searchParams:s})}};var G=class{constructor(t){this._transport=t}getMessageFrequency({request:t={}}={}){return this._transport.send("v1/statistics/message-frequency",{...t,method:"GET"})}getChannelMessageFrequency(t,{request:e={}}={}){return this._transport.send("v1/channels/"+encodeURIComponent(t)+"/statistics/message-frequency",{...e,method:"GET"})}getModelUsage({request:t={}}={}){return this._transport.send("v1/statistics/model-usage",{...t,method:"GET"})}};var Tt=ft(require("is-network-error"),1),K=ft(require("ky"),1);var i=class extends Error{static serverError(t){return new this("Server Error: "+t)}};var d=class extends i{};var x=class extends d{static unauthenticated(){return new this("An unauthenticated request occurred")}};var P=class extends d{static forbidden(){return new this("A forbidden request occurred")}};var c=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 k=class extends i{};var u=class extends i{static badRequest(){return new this("Bad request")}static unsupportedMediaType(){return new this("Unsupported Media Type")}};var F=class{client;options;constructor({baseURL:t,...e}){this.options={...e,baseURL:t},this.client=K.default.create({prefixUrl:this.options.baseURL,timeout:12e3,hooks:{beforeRequest:[o=>{for(let s of this.options.requestFilterables){let r=s.getHeaders();for(let[l,Dt]of Object.entries(r))o.headers.has(l)||o.headers.set(l,Dt)}}]}})}getURL(t){return new URL(t,this.options.baseURL).toString()}sortQuery(t){let e=[];if(t===void 0)return e;for(let[o,s]of Object.entries(t))s!==void 0&&e.push(["sort",s+o]);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 o of Object.keys(t))e.push(["include",o]);return e}queryQuery(t){let e=[];return t===void 0||e.push(["query",t]),e}send(t,e={}){let o=this.client(t,e).catch(s=>{if((0,Tt.default)(s))throw new k("A network error occurred",{cause:s});if(s instanceof K.HTTPError){let r=s.response.status;switch(console.error(JSON.stringify(s.response)),r){case 400:throw u.badRequest();case 401:throw x.unauthenticated();case 403:throw P.forbidden();case 404:throw c.notFound(t);case 405:throw c.forbiddenMethod(t,e.method??"GET");case 415:throw u.unsupportedMediaType();case 418:throw c.teapot();case 429:throw c.rateLimited()}if(r>=500&&r<600)throw i.serverError(r)}throw s});return{response:()=>o,json:async()=>(await o).json()}}};var B=class{constructor(t){this._transport=t}get(t,{request:e={}}={}){return this._transport.send("v1/uploads/"+encodeURIComponent(t),{...e,method:"GET"})}create({account:t,files:e,request:o={}}){let s=new FormData;for(let r of e)s.append("file",r);return this._transport.send("v1/uploads",{...o,method:"POST",body:s,searchParams:{account:t}})}delete(t,{request:e={}}={}){return this._transport.send("v1/uploads/"+encodeURIComponent(t),{...e,method:"DELETE"})}};var a=require("zod"),_t=a.z.object({data:a.z.object({event:a.z.object({id:a.z.string(),type:a.z.string(),payload:a.z.record(a.z.string()),createdAt:a.z.string().datetime()})})});var M=class{constructor(t){this._transport=t}async event({key:t=process.env[J],maxSignatures:e=3,request:o}){let s=o.headers["gds-signature"];if(t!==!1){if(t===void 0)throw new Error("Missing webhook signing key in process.env."+J);if(!s)throw new Error("Missing signature header");if(!this._verifySignature(t,o.body,Array.isArray(s)?s.slice(0,e):[s]))throw new Error("Untrusted signature")}let{data:r}=_t.parse(o.body);return{event:r.event}}async _verifySignature(t,e,o){let s=await crypto.subtle.importKey("raw",new TextEncoder().encode(t),{name:"HMAC",hash:"SHA-256"},!1,["sign","verify"]);for(let r of o)if(await crypto.subtle.verify("HMAC",s,new TextEncoder().encode(atob(r)),new TextEncoder().encode(JSON.stringify(e))))return!0;return!1}};var N=class{constructor(t){this._transport=t}get(t,{request:e={}}={}){return this._transport.send("v1/webhooks/subscriptions/"+encodeURIComponent(t),{...e,method:"GET"})}list({request:t={}}={}){return this._transport.send("v1/webhooks/subscriptions",{...t,method:"GET"})}test(t,{request:e={}}={}){return this._transport.send("v1/webhooks/subscriptions/"+encodeURIComponent(t)+"/test",{...e,method:"POST"})}create({body:t,request:e={}}){return this._transport.send("v1/webhooks/subscriptions",{...e,method:"POST",json:t})}delete(t,{request:e={}}={}){return this._transport.send("v1/webhooks/subscriptions/"+encodeURIComponent(t),{...e,method:"DELETE"})}};var j=class{constructor(t){this._transport=t}getNotifications({request:t={}}={}){return this._transport.send(".well-known/notifications",{...t,method:"GET"})}};var W=class n{static DEFAULT_BASE_URL=vt;static PublicAuthentication=m;static BasicAuthentication=g;static BearerAuthentication=b;_transport;account;accountAccessToken;accountConversationSettings;action;boilerplateCategory;boilerplateContent;channel;compositionSection;contact;conversation;label;message;model;note;notificationSubscription;source;statistics;upload;webhook;webhookSubscription;wellKnown;constructor(t,{baseURL:e,...o}={}){this._transport=new F({requestFilterables:[new E,t],...o,baseURL:e?.toString()??n.getBaseURL()}),this.account=new C(this._transport),this.accountAccessToken=new h(this._transport),this.accountConversationSettings=new f(this._transport),this.action=new O(this._transport),this.boilerplateCategory=new R(this._transport),this.boilerplateContent=new v(this._transport),this.channel=new y(this._transport),this.compositionSection=new T(this._transport),this.contact=new _(this._transport),this.conversation=new L(this._transport),this.label=new I(this._transport),this.message=new A(this._transport),this.model=new S(this._transport),this.note=new w(this._transport),this.notificationSubscription=new U(this._transport),this.source=new D(this._transport),this.statistics=new G(this._transport),this.upload=new B(this._transport),this.webhook=new M(this._transport),this.webhookSubscription=new N(this._transport),this.wellKnown=new j(this._transport)}static getBaseURL(){return process.env[Rt]??this.DEFAULT_BASE_URL}};var X=require("commander"),Lt=require("ora");function Z({client:n,ora:t}){let e=new X.Command("actions").description("Actions");return e.addCommand(new X.Command("list").description("List actions").action(async()=>{let o=await(0,Lt.oraPromise)(()=>n.action.list().json(),{...t,text:"Finding actions"});console.log(o)})),e}var tt=require("commander"),It=require("ora");function et({client:n,ora:t}){let e=new tt.Command("channels").description("Channels");return e.addCommand(new tt.Command("list").description("List channels").action(async()=>{let o=await(0,It.oraPromise)(()=>n.channel.list().json(),{...t,text:"Finding channels"});console.log(o)})),e}var Q=require("commander"),V=require("ora");function ot({client:n,ora:t}){let e=new Q.Command("contacts").description("Contacts");return e.addCommand(new Q.Command("get").description("Find contact").argument("<contact>","Contact ID").action(async o=>{let s=await(0,V.oraPromise)(()=>n.contact.get(o).json(),{...t,text:"Finding contact"});console.log(s)})),e.addCommand(new Q.Command("list").description("List contacts").action(async()=>{let o=await(0,V.oraPromise)(()=>n.contact.list().json(),{...t,text:"Finding contacts"});console.log(o)})),e.addCommand(new Q.Command("get-vcf").description("Export Contact as VCF").argument("<contact>","Contact ID").action(async o=>{let s=await(0,V.oraPromise)(()=>n.contact.getVCF(o).response(),{...t,text:"Exporting contact"});console.log(s)})),e}var H=require("commander"),nt=require("ora");function st({client:n,ora:t}){let e=new H.Command("conversations").description("Conversations");return e.addCommand(new H.Command("get").description("Find conversation").argument("<conversation>","Conversation ID").action(async o=>{let s=await(0,nt.oraPromise)(()=>n.conversation.get(o).json(),{...t,text:"Finding conversation"});console.log(s)})),e.addCommand(new H.Command("list").description("List conversations").action(async()=>{let o=await(0,nt.oraPromise)(()=>n.conversation.list().json(),{...t,text:"Finding conversations"});console.log(o)})),e}var q=require("commander"),Y=require("ora");function rt({client:n,ora:t}){let e=new q.Command("labels").description("Labels");return e.addCommand(new q.Command("get").description("Find label").argument("<label>","Label ID").action(async o=>{let s=await(0,Y.oraPromise)(()=>n.label.get(o).json(),{...t,text:"Finding label"});console.log(s)})),e.addCommand(new q.Command("list").description("List labels").action(async()=>{let o=await(0,Y.oraPromise)(()=>n.label.list().json(),{...t,text:"Finding labels"});console.log(o)})),e.addCommand(new q.Command("conversations").description("Find label conversations").argument("<label>","Label ID").action(async o=>{let s=await(0,Y.oraPromise)(()=>n.conversation.listByLabel(o).json(),{...t,text:"Finding conversations"});console.log(s)})),e}var it=require("commander"),At=require("ora");function at({client:n,ora:t}){let e=new it.Command("messages").description("Messages");return e.addCommand(new it.Command("list").description("List messages").action(async()=>{let o=await(0,At.oraPromise)(()=>n.message.list().json(),{...t,text:"Finding messages"});console.log(o)})),e}var z=require("commander"),pt=require("ora");function ct({client:n,ora:t}){let e=new z.Command("models").description("Models");return e.addCommand(new z.Command("get").description("Find model").argument("<model>","Model ID").action(async o=>{let s=await(0,pt.oraPromise)(()=>n.model.get(o).json(),{...t,text:"Finding model"});console.log(s)})),e.addCommand(new z.Command("list").description("List models").action(async()=>{let o=await(0,pt.oraPromise)(()=>n.model.list().json(),{...t,text:"Finding models"});console.log(o)})),e}var $=require("commander"),mt=require("ora");function dt({client:n,ora:t}){let e=new $.Command("sources").description("Sources");return e.addCommand(new $.Command("get").description("Find source").argument("<source>","Source ID").action(async o=>{let s=await(0,mt.oraPromise)(()=>n.source.get(o).json(),{...t,text:"Finding source"});console.log(s)})),e.addCommand(new $.Command("list").description("List sources").action(async()=>{let o=await(0,mt.oraPromise)(()=>n.source.list().json(),{...t,text:"Finding sources"});console.log(o)})),e}var wt=require("commander");var lt=require("commander"),St=require("ora");function ut({client:n,ora:t}){let e=new lt.Command("notifications").description("Well-Known Notifications Details");return e.addCommand(new lt.Command("get").description("Get Notifications Server Well-Known Info").action(async()=>{let o=await(0,St.oraPromise)(()=>n.wellKnown.getNotifications().json(),{...t,text:"Finding Notifications Well-Known Info"});console.log(o)})),e}function Ct({client:n,ora:t}){let e=new wt.Command("well-known").description("Well-Known Metadata & Info");return e.addCommand(ut({client:n,ora:t})),e}var p={ora:{spinner:"simpleDotsScrolling"},client:new W(new m)},Mt=new Ut.Command("gds").description("Great Detail Support System").addCommand(Z(p)).addCommand(et(p)).addCommand(ot(p)).addCommand(st(p)).addCommand(rt(p)).addCommand(at(p)).addCommand(ct(p)).addCommand(dt(p)).addCommand(Ct(p)),Et=Mt;Et.parseAsync(process.argv);
|
|
2
|
+
"use strict";var At=Object.create;var ct=Object.defineProperty;var St=Object.getOwnPropertyDescriptor;var Ut=Object.getOwnPropertyNames;var Et=Object.getPrototypeOf,wt=Object.prototype.hasOwnProperty;var Dt=(n,t,e,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of Ut(t))!wt.call(n,s)&&s!==e&&ct(n,s,{get:()=>t[s],enumerable:!(o=St(t,s))||o.enumerable});return n};var mt=(n,t,e)=>(e=n!=null?At(Et(n)):{},Dt(t||!n||!n.__esModule?ct(e,"default",{value:n,enumerable:!0}):e,n));var Tt=require("commander");var p=class{getHeaders(){return{}}};var m=class{constructor(t){this._transport=t}get(t,{request:e={}}={}){return this._transport.send("v1/accounts/"+encodeURIComponent(t),{...e,method:"GET"})}getCurrent({request:t={}}){return this._transport.send("v1/accounts/current",{...t,method:"GET"})}update(t,{body:e,request:o={}}){return this._transport.send("v1/accounts/"+encodeURIComponent(t),{...o,method:"PATCH",json:e})}create({body:t,request:e={}}){return this._transport.send("v1/accounts",{...e,method:"POST",json:t})}};var d=class{constructor(t){this._transport=t}get(t,e,{request:o={}}={}){return this._transport.send("v1/accounts/"+encodeURIComponent(t)+"/access-tokens/"+encodeURIComponent(e),{...o,method:"GET"})}list(t,{request:e={}}={}){return this._transport.send("v1/accounts/"+encodeURIComponent(t)+"/access-tokens",{...e,method:"GET"})}delete(t,e,{body:o,request:s={}}={}){return this._transport.send("v1/accounts/"+encodeURIComponent(t)+"/access-tokens/"+encodeURIComponent(e),{...s,method:"DELETE",json:o})}create(t,{body:e={},request:o={}}={}){return this._transport.send("v1/accounts/"+encodeURIComponent(t)+"/access-tokens",{...o,method:"POST",json:e})}};var l=class{constructor(t){this._transport=t}get(t,{request:e={}}={}){return this._transport.send("v1/accounts/"+encodeURIComponent(t)+"/conversation-settings",{...e,method:"GET"})}update(t,{body:e,request:o={}}){return this._transport.send("v1/accounts/"+encodeURIComponent(t)+"/conversation-settings",{...o,method:"PATCH",json:e})}};var u=class{constructor(t){this._transport=t}list({limit:t,sort:e,request:o={}}={}){return this._transport.send("v1/actions",{...o,method:"GET",searchParams:[...this._transport.limitQuery(t),...this._transport.sortQuery(e)]})}};var dt="SUPPORT_ACCESS_TOKEN",lt="SUPPORT_KEY_NAME",ut="SUPPORT_KEY_PASSWORD",V="SUPPORT_SIGNING_KEY",Ct="SUPPORT_BASE_URL";var C=class{name;#t;constructor({name:t=process.env[lt],password:e=process.env[ut]}={}){if(!t)throw new Error("Name option must be specified when using Basic Authentication");if(!e)throw new Error("Password option must be specified when using Basic Authentication");this.name=t,this.#t=e}getHeaders(){return{Authorization:`Basic ${btoa(this.name+":"+this.#t)}`}}};var h=class{#t;constructor({token:t=process.env[dt]}={}){if(!t)throw new Error("Access Token option must be specified when using Token Authentication");this.#t=t}getHeaders(){return{Authorization:`Bearer ${this.#t}`}}};var f=class{constructor(t){this._transport=t}get(t,{request:e={}}={}){return this._transport.send("v1/boilerplates/categories/"+encodeURIComponent(t),{...e,method:"GET"})}list({limit:t,include:e,request:o={}}={}){return this._transport.send("v1/boilerplates/categories",{...o,method:"GET",searchParams:[...this._transport.limitQuery(t),...this._transport.includeQuery(e)]})}create({body:t,request:e={}}){return this._transport.send("v1/boilerplates/categories",{...e,method:"POST",json:t})}update(t,{body:e,request:o={}}){return this._transport.send("v1/boilerplates/categories/"+encodeURIComponent(t),{...o,method:"PATCH",json:e})}};var O=class{constructor(t){this._transport=t}get(t,{request:e={}}={}){return this._transport.send("v1/boilerplates/contents/"+encodeURIComponent(t),{...e,method:"GET"})}list({limit:t,query:e,request:o={}}={}){return this._transport.send("v1/boilerplates/contents",{...o,method:"GET",searchParams:[...this._transport.limitQuery(t),...this._transport.queryQuery(e)]})}listByCategory=this.listByBoilerplateCategory;listByBoilerplateCategory(t,{limit:e,request:o={}}={}){return this._transport.send("v1/boilerplates/categories/"+encodeURIComponent(t)+"/contents",{...o,method:"GET",searchParams:[...this._transport.limitQuery(e)]})}create({body:t,request:e={}}){return this._transport.send("v1/boilerplates/contents",{...e,method:"POST",json:t})}update(t,{body:e,request:o={}}){return this._transport.send("v1/boilerplates/contents/"+encodeURIComponent(t),{...o,method:"PATCH",json:e})}};var g=class{constructor(t){this._transport=t}get(t,{request:e={}}={}){return this._transport.send("v1/channels/"+encodeURIComponent(t),{...e,method:"GET"})}list({limit:t,query:e,request:o={}}={}){return this._transport.send("v1/channels",{...o,method:"GET",searchParams:[...this._transport.limitQuery(t),...this._transport.queryQuery(e)]})}update(t,{body:e,request:o={}}){return this._transport.send("v1/channels/"+encodeURIComponent(t),{...o,method:"PATCH",json:e})}create({body:t,request:e={}}){return this._transport.send("v1/channels",{...e,method:"POST",json:t})}metaWhatsappGetBusinessProfile(t,{request:e={}}={}){return this._transport.send("v1/channels/"+encodeURIComponent(t)+"/meta-whatsapp/business-profile",{...e,method:"GET"})}twilioSendgridChannelSync(t,{body:e,request:o={}}){return this._transport.send("v1/channels/"+encodeURIComponent(t)+"/twilio-sendgrid/sync",{...o,method:"POST",json:e})}};var R=class{constructor(t){this._transport=t}get(t,{request:e={}}={}){return this._transport.send("v1/composition-sections/"+encodeURIComponent(t),{...e,method:"GET"})}list({limit:t,request:e={}}={}){return this._transport.send("v1/composition-sections",{...e,method:"GET",searchParams:[...this._transport.limitQuery(t)]})}listByChannel(t,{limit:e,request:o={}}={}){return this._transport.send("v1/channels/"+encodeURIComponent(t)+"/composition-sections",{...o,method:"GET",searchParams:[...this._transport.limitQuery(e)]})}create({body:t,request:e={}}){return this._transport.send("v1/composition-sections",{...e,method:"POST",json:t})}update(t,{body:e,request:o={}}){return this._transport.send("v1/composition-sections/"+encodeURIComponent(t),{...o,method:"PATCH",json:e})}};var ht="https://api.support.greatdetail.com",ft={"X-Powered-By":"GDSupport/JavaScript"};var b=class{constructor(t){this._transport=t}get(t,{include:e,request:o={}}={}){return this._transport.send("v1/contacts/"+encodeURIComponent(t),{...o,method:"GET",searchParams:[...this._transport.includeQuery(e??{})]})}getRelativeVCFURL(t,{vcf:e={}}={}){let o=e.variant??"vcard",s=e.format??(o==="vcard"?"vcf":"json");return"v1/contacts/"+encodeURIComponent(t)+"/vcf?variant="+encodeURIComponent(o)+"&format="+encodeURIComponent(s)}getVCFURL(t,e={}){return this._transport.getURL(this.getRelativeVCFURL(t,e))}getVCF(t,e={}){return this._transport.send(this.getVCFURL(t,e),{method:"GET"})}list({limit:t,query:e,request:o={}}={}){return this._transport.send("v1/contacts",{...o,method:"GET",searchParams:[...this._transport.limitQuery(t),...this._transport.queryQuery(e)]})}listByLabel(t,{limit:e,request:o={}}={}){return this._transport.send("v1/labels/"+encodeURIComponent(t)+"/contacts",{...o,method:"GET",searchParams:[...this._transport.limitQuery(e)]})}create({body:t,request:e={}}){return this._transport.send("v1/contacts",{...e,method:"POST",json:t})}update(t,{body:e,request:o={}}){return this._transport.send("v1/contacts/"+encodeURIComponent(t),{...o,method:"PATCH",json:e})}delete(t,{request:e={}}={}){return this._transport.send("v1/contacts/"+encodeURIComponent(t),{...e,method:"DELETE"})}};var v=class{constructor(t){this._transport=t}get(t,{include:e,request:o={}}={}){return this._transport.send("v1/conversations/"+encodeURIComponent(t),{...o,method:"GET",searchParams:[...this._transport.includeQuery(e??{})]})}list({query:t,limit:e,filter:o,include:s,request:r={}}={}){return this._transport.send("v1/conversations",{...r,method:"GET",searchParams:[...this._transport.queryQuery(t),...this._transport.limitQuery(e),...o?[["filter",o]]:[],...this._transport.includeQuery(s??{})]})}listByLabel(t,{limit:e,request:o={}}={}){return this._transport.send("v1/labels/"+encodeURIComponent(t)+"/conversations",{...o,method:"GET",searchParams:[...this._transport.limitQuery(e)]})}listByContact(t,{limit:e,request:o={}}={}){return this._transport.send("v1/contacts/"+encodeURIComponent(t)+"/conversations",{...o,method:"GET",searchParams:[...this._transport.limitQuery(e)]})}listByChannel(t,{limit:e,request:o={}}={}){return this._transport.send("v1/channels/"+encodeURIComponent(t)+"/conversations",{...o,method:"GET",searchParams:[...this._transport.limitQuery(e)]})}create({body:t,request:e={}}){return this._transport.send("v1/conversations",{...e,method:"POST",json:t})}update(t,{body:e,request:o={}}){return this._transport.send("v1/conversations/"+encodeURIComponent(t),{...o,method:"PATCH",json:e})}delete(t,{request:e={}}={}){return this._transport.send("v1/conversations/"+encodeURIComponent(t),{...e,method:"DELETE"})}};var y=class{constructor(t){this._transport=t}get(t,{request:e={}}={}){return this._transport.send("v1/labels/"+encodeURIComponent(t),{...e,method:"GET"})}list({limit:t,query:e,include:o,request:s={}}={}){return this._transport.send("v1/labels",{...s,method:"GET",searchParams:[...this._transport.limitQuery(t),...this._transport.queryQuery(e),...this._transport.includeQuery(o??{})]})}listByContact(t,{limit:e,request:o={}}={}){return this._transport.send("v1/contacts/"+encodeURIComponent(t)+"/labels",{...o,method:"GET",searchParams:[...this._transport.limitQuery(e)]})}listByConversation(t,{limit:e,request:o={}}={}){return this._transport.send("v1/conversations/"+encodeURIComponent(t)+"/labels",{...o,method:"GET",searchParams:[...this._transport.limitQuery(e)]})}create({body:t,request:e={}}){return this._transport.send("v1/labels",{...e,method:"POST",json:t})}update(t,{body:e,request:o={}}){return this._transport.send("v1/labels/"+encodeURIComponent(t),{...o,method:"PATCH",json:e})}delete(t,{request:e={}}={}){return this._transport.send("v1/labels/"+encodeURIComponent(t),{...e,method:"DELETE"})}};var _=class{constructor(t){this._transport=t}list({limit:t,include:e,request:o={}}={}){return this._transport.send("v1/messages",{...o,method:"GET",searchParams:[...this._transport.limitQuery(t),...this._transport.includeQuery(e??{})]})}listByConversation(t,{limit:e,include:o,request:s={}}={}){return this._transport.send("v1/conversations/"+encodeURIComponent(t)+"/messages",{...s,method:"GET",searchParams:[...this._transport.limitQuery(e),...this._transport.includeQuery(o??{})]})}listByChannel(t,{limit:e,include:o,request:s={}}={}){return this._transport.send("v1/channels/"+encodeURIComponent(t)+"/messages",{...s,method:"GET",searchParams:[...this._transport.limitQuery(e),...this._transport.includeQuery(o)]})}create({body:t,request:e={}}){return this._transport.send("v1/messages",{...e,method:"POST",json:t})}delete(t,{request:e={}}={}){return this._transport.send("v1/messages/"+encodeURIComponent(t),{...e,method:"DELETE"})}};var T=class{constructor(t){this._transport=t}get(t,{request:e={}}={}){return this._transport.send("v1/models/"+encodeURIComponent(t),{...e,method:"GET"})}list({request:t={}}={}){return this._transport.send("v1/models",{...t,method:"GET"})}createResponse(t,{body:e,request:o={}}){return this._transport.send("v1/models/"+encodeURIComponent(t)+"/response",{...o,method:"POST",timeout:12e4,json:e})}createCorrection(t,{body:e,request:o={}}){return this._transport.send("v1/models/"+encodeURIComponent(t)+"/correction",{...o,method:"POST",json:e})}};var L=class{constructor(t){this._transport=t}get(t,{request:e={}}={}){return this._transport.send("v1/notes/"+encodeURIComponent(t),{...e,method:"GET"})}listByContact(t,{request:e={}}={}){return this._transport.send("v1/contacts/"+encodeURIComponent(t)+"/notes",{...e,method:"GET"})}listByConversation(t,{request:e={}}={}){return this._transport.send("v1/conversations/"+encodeURIComponent(t)+"/notes",{...e,method:"GET"})}createForContact(t,{body:e,request:o={}}){return this._transport.send("v1/contacts/"+encodeURIComponent(t)+"/notes",{...o,method:"POST",json:e})}createForConversation(t,{body:e,request:o={}}){return this._transport.send("v1/conversations/"+encodeURIComponent(t)+"/notes",{...o,method:"POST",json:e})}update(t,{body:e,request:o={}}){return this._transport.send("v1/notes/"+encodeURIComponent(t),{...o,method:"PATCH",json:e})}};var I=class{constructor(t){this._transport=t}createForContact(t,{body:e,request:o={}}){return this._transport.send("v1/contacts/"+encodeURIComponent(t)+"/notification-subscriptions",{...o,method:"POST",json:e})}};var A=class n{constructor(t=n.STANDARD_HEADERS){this._standardHeaders=t}static STANDARD_HEADERS=ft;async filter(){return{headers:this.getHeaders()}}getHeaders(){return this._standardHeaders}};var S=class{constructor(t){this._transport=t}get(t,{request:e={}}={}){return this._transport.send("v1/sources/"+encodeURIComponent(t),{...e,method:"GET"})}list({featured:t,category:e,request:o={}}={}){let s=[];if(e){let r=Array.isArray(e)?e:[e];for(let c of r)s.push(["category",c])}return t!==void 0&&s.push(["featured",String(t)]),this._transport.send("v1/sources",{...o,method:"GET",searchParams:s})}};var U=class{constructor(t){this._transport=t}getMessageFrequency({request:t={}}={}){return this._transport.send("v1/statistics/message-frequency",{...t,method:"GET"})}getChannelMessageFrequency(t,{request:e={}}={}){return this._transport.send("v1/channels/"+encodeURIComponent(t)+"/statistics/message-frequency",{...e,method:"GET"})}getModelUsage({request:t={}}={}){return this._transport.send("v1/statistics/model-usage",{...t,method:"GET"})}};var Ot=mt(require("is-network-error"),1),M=mt(require("ky"),1);var B=class extends Error{constructor(e,o){super("Support Error",{cause:o});this.response=e}};var E=class{client;options;constructor({baseURL:t,...e}){this.options={...e,baseURL:t},this.client=M.default.create({prefixUrl:this.options.baseURL,timeout:12e3,hooks:{beforeRequest:[o=>{for(let s of this.options.requestFilterables){let r=s.getHeaders();for(let[c,It]of Object.entries(r))o.headers.has(c)||o.headers.set(c,It)}}]}})}getURL(t){return new URL(t,this.options.baseURL).toString()}sortQuery(t){let e=[];if(t===void 0)return e;for(let[o,s]of Object.entries(t))s!==void 0&&e.push(["sort",s+o]);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 o of Object.keys(t))e.push(["include",o]);return e}queryQuery(t){let e=[];return t===void 0||e.push(["query",t]),e}send(t,e={}){let o=this.client(t,e).catch(async s=>{throw(0,Ot.default)(s)?new Error("A network error occurred",{cause:s}):s instanceof M.HTTPError?new B(s.response,s):s});return{response:()=>o,json:async()=>(await o).json()}}};var w=class{constructor(t){this._transport=t}get(t,{request:e={}}={}){return this._transport.send("v1/uploads/"+encodeURIComponent(t),{...e,method:"GET"})}list({request:t={}}={}){return this._transport.send("v1/uploads",{...t,method:"GET"})}create({account:t,files:e,request:o={}}){let s=new FormData;for(let r of e)s.append("file",r);return this._transport.send("v1/uploads",{...o,method:"POST",body:s,searchParams:{account:t}})}delete(t,{request:e={}}={}){return this._transport.send("v1/uploads/"+encodeURIComponent(t),{...e,method:"DELETE"})}};var i=require("zod"),gt=i.z.object({data:i.z.object({event:i.z.object({id:i.z.string(),type:i.z.string(),payload:i.z.record(i.z.string()),createdAt:i.z.string().datetime()})})});var D=class{constructor(t){this._transport=t}async event({key:t=process.env[V],maxSignatures:e=3,request:o}){let s=o.headers["gds-signature"];if(t!==!1){if(t===void 0)throw new Error("Missing webhook signing key in process.env."+V);if(!s)throw new Error("Missing signature header");if(!this._verifySignature(t,o.body,Array.isArray(s)?s.slice(0,e):[s]))throw new Error("Untrusted signature")}let{data:r}=gt.parse(o.body);return{event:r.event}}async _verifySignature(t,e,o){let s=await crypto.subtle.importKey("raw",new TextEncoder().encode(t),{name:"HMAC",hash:"SHA-256"},!1,["sign","verify"]);for(let r of o)if(await crypto.subtle.verify("HMAC",s,new TextEncoder().encode(atob(r)),new TextEncoder().encode(JSON.stringify(e))))return!0;return!1}};var G=class{constructor(t){this._transport=t}get(t,{request:e={}}={}){return this._transport.send("v1/webhooks/subscriptions/"+encodeURIComponent(t),{...e,method:"GET"})}list({request:t={}}={}){return this._transport.send("v1/webhooks/subscriptions",{...t,method:"GET"})}test(t,{request:e={}}={}){return this._transport.send("v1/webhooks/subscriptions/"+encodeURIComponent(t)+"/test",{...e,method:"POST"})}create({body:t,request:e={}}){return this._transport.send("v1/webhooks/subscriptions",{...e,method:"POST",json:t})}delete(t,{request:e={}}={}){return this._transport.send("v1/webhooks/subscriptions/"+encodeURIComponent(t),{...e,method:"DELETE"})}};var x=class{constructor(t){this._transport=t}getNotifications({request:t={}}={}){return this._transport.send(".well-known/notifications",{...t,method:"GET"})}};var P=class n{static DEFAULT_BASE_URL=ht;static PublicAuthentication=p;static BasicAuthentication=C;static BearerAuthentication=h;_transport;account;accountAccessToken;accountConversationSettings;action;boilerplateCategory;boilerplateContent;channel;compositionSection;contact;conversation;label;message;model;note;notificationSubscription;source;statistics;upload;webhook;webhookSubscription;wellKnown;constructor(t,{baseURL:e,...o}={}){this._transport=new E({requestFilterables:[new A,t],...o,baseURL:e?.toString()??n.getBaseURL()}),this.account=new m(this._transport),this.accountAccessToken=new d(this._transport),this.accountConversationSettings=new l(this._transport),this.action=new u(this._transport),this.boilerplateCategory=new f(this._transport),this.boilerplateContent=new O(this._transport),this.channel=new g(this._transport),this.compositionSection=new R(this._transport),this.contact=new b(this._transport),this.conversation=new v(this._transport),this.label=new y(this._transport),this.message=new _(this._transport),this.model=new T(this._transport),this.note=new L(this._transport),this.notificationSubscription=new I(this._transport),this.source=new S(this._transport),this.statistics=new U(this._transport),this.upload=new w(this._transport),this.webhook=new D(this._transport),this.webhookSubscription=new G(this._transport),this.wellKnown=new x(this._transport)}static getBaseURL(){return process.env[Ct]??this.DEFAULT_BASE_URL}};var H=require("commander"),Rt=require("ora");function q({client:n,ora:t}){let e=new H.Command("actions").description("Actions");return e.addCommand(new H.Command("list").description("List actions").action(async()=>{let o=await(0,Rt.oraPromise)(()=>n.action.list().json(),{...t,text:"Finding actions"});console.log(o)})),e}var Y=require("commander"),bt=require("ora");function z({client:n,ora:t}){let e=new Y.Command("channels").description("Channels");return e.addCommand(new Y.Command("list").description("List channels").action(async()=>{let o=await(0,bt.oraPromise)(()=>n.channel.list().json(),{...t,text:"Finding channels"});console.log(o)})),e}var k=require("commander"),N=require("ora");function J({client:n,ora:t}){let e=new k.Command("contacts").description("Contacts");return e.addCommand(new k.Command("get").description("Find contact").argument("<contact>","Contact ID").action(async o=>{let s=await(0,N.oraPromise)(()=>n.contact.get(o).json(),{...t,text:"Finding contact"});console.log(s)})),e.addCommand(new k.Command("list").description("List contacts").action(async()=>{let o=await(0,N.oraPromise)(()=>n.contact.list().json(),{...t,text:"Finding contacts"});console.log(o)})),e.addCommand(new k.Command("get-vcf").description("Export Contact as VCF").argument("<contact>","Contact ID").action(async o=>{let s=await(0,N.oraPromise)(()=>n.contact.getVCF(o).response(),{...t,text:"Exporting contact"});console.log(s)})),e}var j=require("commander"),$=require("ora");function X({client:n,ora:t}){let e=new j.Command("conversations").description("Conversations");return e.addCommand(new j.Command("get").description("Find conversation").argument("<conversation>","Conversation ID").action(async o=>{let s=await(0,$.oraPromise)(()=>n.conversation.get(o).json(),{...t,text:"Finding conversation"});console.log(s)})),e.addCommand(new j.Command("list").description("List conversations").action(async()=>{let o=await(0,$.oraPromise)(()=>n.conversation.list().json(),{...t,text:"Finding conversations"});console.log(o)})),e}var F=require("commander"),W=require("ora");function Z({client:n,ora:t}){let e=new F.Command("labels").description("Labels");return e.addCommand(new F.Command("get").description("Find label").argument("<label>","Label ID").action(async o=>{let s=await(0,W.oraPromise)(()=>n.label.get(o).json(),{...t,text:"Finding label"});console.log(s)})),e.addCommand(new F.Command("list").description("List labels").action(async()=>{let o=await(0,W.oraPromise)(()=>n.label.list().json(),{...t,text:"Finding labels"});console.log(o)})),e.addCommand(new F.Command("conversations").description("Find label conversations").argument("<label>","Label ID").action(async o=>{let s=await(0,W.oraPromise)(()=>n.conversation.listByLabel(o).json(),{...t,text:"Finding conversations"});console.log(s)})),e}var tt=require("commander"),vt=require("ora");function et({client:n,ora:t}){let e=new tt.Command("messages").description("Messages");return e.addCommand(new tt.Command("list").description("List messages").action(async()=>{let o=await(0,vt.oraPromise)(()=>n.message.list().json(),{...t,text:"Finding messages"});console.log(o)})),e}var Q=require("commander"),ot=require("ora");function nt({client:n,ora:t}){let e=new Q.Command("models").description("Models");return e.addCommand(new Q.Command("get").description("Find model").argument("<model>","Model ID").action(async o=>{let s=await(0,ot.oraPromise)(()=>n.model.get(o).json(),{...t,text:"Finding model"});console.log(s)})),e.addCommand(new Q.Command("list").description("List models").action(async()=>{let o=await(0,ot.oraPromise)(()=>n.model.list().json(),{...t,text:"Finding models"});console.log(o)})),e}var K=require("commander"),st=require("ora");function rt({client:n,ora:t}){let e=new K.Command("sources").description("Sources");return e.addCommand(new K.Command("get").description("Find source").argument("<source>","Source ID").action(async o=>{let s=await(0,st.oraPromise)(()=>n.source.get(o).json(),{...t,text:"Finding source"});console.log(s)})),e.addCommand(new K.Command("list").description("List sources").action(async()=>{let o=await(0,st.oraPromise)(()=>n.source.list().json(),{...t,text:"Finding sources"});console.log(o)})),e}var _t=require("commander");var it=require("commander"),yt=require("ora");function at({client:n,ora:t}){let e=new it.Command("notifications").description("Well-Known Notifications Details");return e.addCommand(new it.Command("get").description("Get Notifications Server Well-Known Info").action(async()=>{let o=await(0,yt.oraPromise)(()=>n.wellKnown.getNotifications().json(),{...t,text:"Finding Notifications Well-Known Info"});console.log(o)})),e}function pt({client:n,ora:t}){let e=new _t.Command("well-known").description("Well-Known Metadata & Info");return e.addCommand(at({client:n,ora:t})),e}var a={ora:{spinner:"simpleDotsScrolling"},client:new P(new p)},Gt=new Tt.Command("gds").description("Great Detail Support System").addCommand(q(a)).addCommand(z(a)).addCommand(J(a)).addCommand(X(a)).addCommand(Z(a)).addCommand(et(a)).addCommand(nt(a)).addCommand(rt(a)).addCommand(pt(a)),Lt=Gt;Lt.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-5LTP3VGA.js";import"./chunk-XYLD2NDD.js";r.parseAsync(process.argv);
|
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var rt=Object.create;var Q=Object.defineProperty;var nt=Object.getOwnPropertyDescriptor;var it=Object.getOwnPropertyNames;var pt=Object.getPrototypeOf,at=Object.prototype.hasOwnProperty;var Y=(s,t)=>{for(var e in t)Q(s,e,{get:t[e],enumerable:!0})},z=(s,t,e,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of it(t))!at.call(s,r)&&r!==e&&Q(s,r,{get:()=>t[r],enumerable:!(o=nt(t,r))||o.enumerable});return s};var $=(s,t,e)=>(e=s!=null?rt(pt(s)):{},z(t||!s||!s.__esModule?Q(e,"default",{value:s,enumerable:!0}):e,s)),ct=s=>z(Q({},"__esModule",{value:!0}),s);var mt={};Y(mt,{Client:()=>f,DEFAULT_SUPPORT_BASE_URL:()=>j,Error:()=>K,default:()=>f,eventWebhookSchema:()=>H});module.exports=ct(mt);var j="https://api.support.greatdetail.com",J={"X-Powered-By":"GDSupport/JavaScript"};var C=class{constructor(t){this._transport=t}get(t,{request:e={}}={}){return this._transport.send("v1/accounts/"+encodeURIComponent(t),{...e,method:"GET"})}getCurrent({request:t={}}){return this._transport.send("v1/accounts/current",{...t,method:"GET"})}update(t,{body:e,request:o={}}){return this._transport.send("v1/accounts/"+encodeURIComponent(t),{...o,method:"PATCH",json:e})}create({body:t,request:e={}}){return this._transport.send("v1/accounts",{...e,method:"POST",json:t})}};var R=class{constructor(t){this._transport=t}get(t,e,{request:o={}}={}){return this._transport.send("v1/accounts/"+encodeURIComponent(t)+"/access-tokens/"+encodeURIComponent(e),{...o,method:"GET"})}list(t,{request:e={}}={}){return this._transport.send("v1/accounts/"+encodeURIComponent(t)+"/access-tokens",{...e,method:"GET"})}delete(t,e,{body:o,request:r={}}={}){return this._transport.send("v1/accounts/"+encodeURIComponent(t)+"/access-tokens/"+encodeURIComponent(e),{...r,method:"DELETE",json:o})}create(t,{body:e={},request:o={}}={}){return this._transport.send("v1/accounts/"+encodeURIComponent(t)+"/access-tokens",{...o,method:"POST",json:e})}};var b=class{constructor(t){this._transport=t}get(t,{request:e={}}={}){return this._transport.send("v1/accounts/"+encodeURIComponent(t)+"/conversation-settings",{...e,method:"GET"})}update(t,{body:e,request:o={}}){return this._transport.send("v1/accounts/"+encodeURIComponent(t)+"/conversation-settings",{...o,method:"PATCH",json:e})}};var v=class{constructor(t){this._transport=t}list({limit:t,sort:e,request:o={}}={}){return this._transport.send("v1/actions",{...o,method:"GET",searchParams:[...this._transport.limitQuery(t),...this._transport.sortQuery(e)]})}};var X="SUPPORT_ACCESS_TOKEN",Z="SUPPORT_KEY_NAME",tt="SUPPORT_KEY_PASSWORD",V="SUPPORT_SIGNING_KEY",et="SUPPORT_BASE_URL";var x=class{name;#t;constructor({name:t=process.env[Z],password:e=process.env[tt]}={}){if(!t)throw new Error("Name option must be specified when using Basic Authentication");if(!e)throw new Error("Password option must be specified when using Basic Authentication");this.name=t,this.#t=e}getHeaders(){return{Authorization:`Basic ${btoa(this.name+":"+this.#t)}`}}};var O=class{#t;constructor({token:t=process.env[X]}={}){if(!t)throw new Error("Access Token option must be specified when using Token Authentication");this.#t=t}getHeaders(){return{Authorization:`Bearer ${this.#t}`}}};var g=class{getHeaders(){return{}}};var T=class{constructor(t){this._transport=t}get(t,{request:e={}}={}){return this._transport.send("v1/boilerplates/categories/"+encodeURIComponent(t),{...e,method:"GET"})}list({limit:t,include:e,request:o={}}={}){return this._transport.send("v1/boilerplates/categories",{...o,method:"GET",searchParams:[...this._transport.limitQuery(t),...this._transport.includeQuery(e)]})}create({body:t,request:e={}}){return this._transport.send("v1/boilerplates/categories",{...e,method:"POST",json:t})}update(t,{body:e,request:o={}}){return this._transport.send("v1/boilerplates/categories/"+encodeURIComponent(t),{...o,method:"PATCH",json:e})}};var _=class{constructor(t){this._transport=t}get(t,{request:e={}}={}){return this._transport.send("v1/boilerplates/contents/"+encodeURIComponent(t),{...e,method:"GET"})}list({limit:t,query:e,request:o={}}={}){return this._transport.send("v1/boilerplates/contents",{...o,method:"GET",searchParams:[...this._transport.limitQuery(t),...this._transport.queryQuery(e)]})}listByCategory=this.listByBoilerplateCategory;listByBoilerplateCategory(t,{limit:e,request:o={}}={}){return this._transport.send("v1/boilerplates/categories/"+encodeURIComponent(t)+"/contents",{...o,method:"GET",searchParams:[...this._transport.limitQuery(e)]})}create({body:t,request:e={}}){return this._transport.send("v1/boilerplates/contents",{...e,method:"POST",json:t})}update(t,{body:e,request:o={}}){return this._transport.send("v1/boilerplates/contents/"+encodeURIComponent(t),{...o,method:"PATCH",json:e})}};var y=class{constructor(t){this._transport=t}get(t,{request:e={}}={}){return this._transport.send("v1/channels/"+encodeURIComponent(t),{...e,method:"GET"})}list({limit:t,query:e,request:o={}}={}){return this._transport.send("v1/channels",{...o,method:"GET",searchParams:[...this._transport.limitQuery(t),...this._transport.queryQuery(e)]})}update(t,{body:e,request:o={}}){return this._transport.send("v1/channels/"+encodeURIComponent(t),{...o,method:"PATCH",json:e})}create({body:t,request:e={}}){return this._transport.send("v1/channels",{...e,method:"POST",json:t})}metaWhatsappGetBusinessProfile(t,{request:e={}}={}){return this._transport.send("v1/channels/"+encodeURIComponent(t)+"/meta-whatsapp/business-profile",{...e,method:"GET"})}twilioSendgridChannelSync(t,{body:e,request:o={}}){return this._transport.send("v1/channels/"+encodeURIComponent(t)+"/twilio-sendgrid/sync",{...o,method:"POST",json:e})}};var L=class{constructor(t){this._transport=t}get(t,{request:e={}}={}){return this._transport.send("v1/composition-sections/"+encodeURIComponent(t),{...e,method:"GET"})}list({limit:t,request:e={}}={}){return this._transport.send("v1/composition-sections",{...e,method:"GET",searchParams:[...this._transport.limitQuery(t)]})}listByChannel(t,{limit:e,request:o={}}={}){return this._transport.send("v1/channels/"+encodeURIComponent(t)+"/composition-sections",{...o,method:"GET",searchParams:[...this._transport.limitQuery(e)]})}create({body:t,request:e={}}){return this._transport.send("v1/composition-sections",{...e,method:"POST",json:t})}update(t,{body:e,request:o={}}){return this._transport.send("v1/composition-sections/"+encodeURIComponent(t),{...o,method:"PATCH",json:e})}};var A=class{constructor(t){this._transport=t}get(t,{include:e,request:o={}}={}){return this._transport.send("v1/contacts/"+encodeURIComponent(t),{...o,method:"GET",searchParams:[...this._transport.includeQuery(e??{})]})}getRelativeVCFURL(t,{vcf:e={}}={}){let o=e.variant??"vcard",r=e.format??(o==="vcard"?"vcf":"json");return"v1/contacts/"+encodeURIComponent(t)+"/vcf?variant="+encodeURIComponent(o)+"&format="+encodeURIComponent(r)}getVCFURL(t,e={}){return this._transport.getURL(this.getRelativeVCFURL(t,e))}getVCF(t,e={}){return this._transport.send(this.getVCFURL(t,e),{method:"GET"})}list({limit:t,query:e,request:o={}}={}){return this._transport.send("v1/contacts",{...o,method:"GET",searchParams:[...this._transport.limitQuery(t),...this._transport.queryQuery(e)]})}listByLabel(t,{limit:e,request:o={}}={}){return this._transport.send("v1/labels/"+encodeURIComponent(t)+"/contacts",{...o,method:"GET",searchParams:[...this._transport.limitQuery(e)]})}create({body:t,request:e={}}){return this._transport.send("v1/contacts",{...e,method:"POST",json:t})}update(t,{body:e,request:o={}}){return this._transport.send("v1/contacts/"+encodeURIComponent(t),{...o,method:"PATCH",json:e})}delete(t,{request:e={}}={}){return this._transport.send("v1/contacts/"+encodeURIComponent(t),{...e,method:"DELETE"})}};var I=class{constructor(t){this._transport=t}get(t,{include:e,request:o={}}={}){return this._transport.send("v1/conversations/"+encodeURIComponent(t),{...o,method:"GET",searchParams:[...this._transport.includeQuery(e??{})]})}list({limit:t,filter:e,include:o,request:r={}}={}){return this._transport.send("v1/conversations",{...r,method:"GET",searchParams:[...this._transport.limitQuery(t),...e?[["filter",e]]:[],...this._transport.includeQuery(o??{})]})}listByLabel(t,{limit:e,request:o={}}={}){return this._transport.send("v1/labels/"+encodeURIComponent(t)+"/conversations",{...o,method:"GET",searchParams:[...this._transport.limitQuery(e)]})}listByContact(t,{limit:e,request:o={}}={}){return this._transport.send("v1/contacts/"+encodeURIComponent(t)+"/conversations",{...o,method:"GET",searchParams:[...this._transport.limitQuery(e)]})}listByChannel(t,{limit:e,request:o={}}={}){return this._transport.send("v1/channels/"+encodeURIComponent(t)+"/conversations",{...o,method:"GET",searchParams:[...this._transport.limitQuery(e)]})}create({body:t,request:e={}}){return this._transport.send("v1/conversations",{...e,method:"POST",json:t})}update(t,{body:e,request:o={}}){return this._transport.send("v1/conversations/"+encodeURIComponent(t),{...o,method:"PATCH",json:e})}delete(t,{request:e={}}={}){return this._transport.send("v1/conversations/"+encodeURIComponent(t),{...e,method:"DELETE"})}};var S=class{constructor(t){this._transport=t}get(t,{request:e={}}={}){return this._transport.send("v1/labels/"+encodeURIComponent(t),{...e,method:"GET"})}list({limit:t,query:e,include:o,request:r={}}={}){return this._transport.send("v1/labels",{...r,method:"GET",searchParams:[...this._transport.limitQuery(t),...this._transport.queryQuery(e),...this._transport.includeQuery(o??{})]})}listByContact(t,{limit:e,request:o={}}={}){return this._transport.send("v1/contacts/"+encodeURIComponent(t)+"/labels",{...o,method:"GET",searchParams:[...this._transport.limitQuery(e)]})}listByConversation(t,{limit:e,request:o={}}={}){return this._transport.send("v1/conversations/"+encodeURIComponent(t)+"/labels",{...o,method:"GET",searchParams:[...this._transport.limitQuery(e)]})}create({body:t,request:e={}}){return this._transport.send("v1/labels",{...e,method:"POST",json:t})}update(t,{body:e,request:o={}}){return this._transport.send("v1/labels/"+encodeURIComponent(t),{...o,method:"PATCH",json:e})}delete(t,{request:e={}}={}){return this._transport.send("v1/labels/"+encodeURIComponent(t),{...e,method:"DELETE"})}};var E=class{constructor(t){this._transport=t}list({limit:t,include:e,request:o={}}={}){return this._transport.send("v1/messages",{...o,method:"GET",searchParams:[...this._transport.limitQuery(t),...this._transport.includeQuery(e??{})]})}listByConversation(t,{limit:e,include:o,request:r={}}={}){return this._transport.send("v1/conversations/"+encodeURIComponent(t)+"/messages",{...r,method:"GET",searchParams:[...this._transport.limitQuery(e),...this._transport.includeQuery(o??{})]})}listByChannel(t,{limit:e,include:o,request:r={}}={}){return this._transport.send("v1/channels/"+encodeURIComponent(t)+"/messages",{...r,method:"GET",searchParams:[...this._transport.limitQuery(e),...this._transport.includeQuery(o)]})}create({body:t,request:e={}}){return this._transport.send("v1/messages",{...e,method:"POST",json:t})}delete(t,{request:e={}}={}){return this._transport.send("v1/messages/"+encodeURIComponent(t),{...e,method:"DELETE"})}};var U=class{constructor(t){this._transport=t}get(t,{request:e={}}={}){return this._transport.send("v1/models/"+encodeURIComponent(t),{...e,method:"GET"})}list({request:t={}}={}){return this._transport.send("v1/models",{...t,method:"GET"})}createResponse(t,{body:e,request:o={}}){return this._transport.send("v1/models/"+encodeURIComponent(t)+"/response",{...o,method:"POST",timeout:12e4,json:e})}createCorrection(t,{body:e,request:o={}}){return this._transport.send("v1/models/"+encodeURIComponent(t)+"/correction",{...o,method:"POST",json:e})}};var G=class{constructor(t){this._transport=t}get(t,{request:e={}}={}){return this._transport.send("v1/notes/"+encodeURIComponent(t),{...e,method:"GET"})}listByContact(t,{request:e={}}={}){return this._transport.send("v1/contacts/"+encodeURIComponent(t)+"/notes",{...e,method:"GET"})}listByConversation(t,{request:e={}}={}){return this._transport.send("v1/conversations/"+encodeURIComponent(t)+"/notes",{...e,method:"GET"})}createForContact(t,{body:e,request:o={}}){return this._transport.send("v1/contacts/"+encodeURIComponent(t)+"/notes",{...o,method:"POST",json:e})}createForConversation(t,{body:e,request:o={}}){return this._transport.send("v1/conversations/"+encodeURIComponent(t)+"/notes",{...o,method:"POST",json:e})}update(t,{body:e,request:o={}}){return this._transport.send("v1/notes/"+encodeURIComponent(t),{...o,method:"PATCH",json:e})}};var D=class{constructor(t){this._transport=t}createForContact(t,{body:e,request:o={}}){return this._transport.send("v1/contacts/"+encodeURIComponent(t)+"/notification-subscriptions",{...o,method:"POST",json:e})}};var w=class s{constructor(t=s.STANDARD_HEADERS){this._standardHeaders=t}static STANDARD_HEADERS=J;async filter(){return{headers:this.getHeaders()}}getHeaders(){return this._standardHeaders}};var k=class{constructor(t){this._transport=t}get(t,{request:e={}}={}){return this._transport.send("v1/sources/"+encodeURIComponent(t),{...e,method:"GET"})}list({featured:t,category:e,request:o={}}={}){let r=[];if(e){let i=Array.isArray(e)?e:[e];for(let h of i)r.push(["category",h])}return t!==void 0&&r.push(["featured",String(t)]),this._transport.send("v1/sources",{...o,method:"GET",searchParams:r})}};var P=class{constructor(t){this._transport=t}getMessageFrequency({request:t={}}={}){return this._transport.send("v1/statistics/message-frequency",{...t,method:"GET"})}getChannelMessageFrequency(t,{request:e={}}={}){return this._transport.send("v1/channels/"+encodeURIComponent(t)+"/statistics/message-frequency",{...e,method:"GET"})}getModelUsage({request:t={}}={}){return this._transport.send("v1/statistics/model-usage",{...t,method:"GET"})}};var ot=$(require("is-network-error"),1),q=$(require("ky"),1);var n=class extends Error{static serverError(t){return new this("Server Error: "+t)}};var a=class extends n{};var l=class extends a{static unauthenticated(){return new this("An unauthenticated request occurred")}};var d=class extends a{static forbidden(){return new this("A forbidden request occurred")}};var p=class extends n{static notFound(t){return new this(`Record not found for request: ${t}`)}static forbiddenMethod(t,e){return new this(`Forbidden method for request: ${t} ${e}`)}static teapot(){return new this("I'm a teapot")}static rateLimited(){return new this("Request has been rate-limited")}};var u=class extends n{};var m=class extends n{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=q.default.create({prefixUrl:this.options.baseURL,timeout:12e3,hooks:{beforeRequest:[o=>{for(let r of this.options.requestFilterables){let i=r.getHeaders();for(let[h,st]of Object.entries(i))o.headers.has(h)||o.headers.set(h,st)}}]}})}getURL(t){return new URL(t,this.options.baseURL).toString()}sortQuery(t){let e=[];if(t===void 0)return e;for(let[o,r]of Object.entries(t))r!==void 0&&e.push(["sort",r+o]);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 o of Object.keys(t))e.push(["include",o]);return e}queryQuery(t){let e=[];return t===void 0||e.push(["query",t]),e}send(t,e={}){let o=this.client(t,e).catch(r=>{if((0,ot.default)(r))throw new u("A network error occurred",{cause:r});if(r instanceof q.HTTPError){let i=r.response.status;switch(console.error(JSON.stringify(r.response)),i){case 400:throw m.badRequest();case 401:throw l.unauthenticated();case 403:throw d.forbidden();case 404:throw p.notFound(t);case 405:throw p.forbiddenMethod(t,e.method??"GET");case 415:throw m.unsupportedMediaType();case 418:throw p.teapot();case 429:throw p.rateLimited()}if(i>=500&&i<600)throw n.serverError(i)}throw r});return{response:()=>o,json:async()=>(await o).json()}}};var M=class{constructor(t){this._transport=t}get(t,{request:e={}}={}){return this._transport.send("v1/uploads/"+encodeURIComponent(t),{...e,method:"GET"})}create({account:t,files:e,request:o={}}){let r=new FormData;for(let i of e)r.append("file",i);return this._transport.send("v1/uploads",{...o,method:"POST",body:r,searchParams:{account:t}})}delete(t,{request:e={}}={}){return this._transport.send("v1/uploads/"+encodeURIComponent(t),{...e,method:"DELETE"})}};var c=require("zod"),H=c.z.object({data:c.z.object({event:c.z.object({id:c.z.string(),type:c.z.string(),payload:c.z.record(c.z.string()),createdAt:c.z.string().datetime()})})});var F=class{constructor(t){this._transport=t}async event({key:t=process.env[V],maxSignatures:e=3,request:o}){let r=o.headers["gds-signature"];if(t!==!1){if(t===void 0)throw new Error("Missing webhook signing key in process.env."+V);if(!r)throw new Error("Missing signature header");if(!this._verifySignature(t,o.body,Array.isArray(r)?r.slice(0,e):[r]))throw new Error("Untrusted signature")}let{data:i}=H.parse(o.body);return{event:i.event}}async _verifySignature(t,e,o){let r=await crypto.subtle.importKey("raw",new TextEncoder().encode(t),{name:"HMAC",hash:"SHA-256"},!1,["sign","verify"]);for(let i of o)if(await crypto.subtle.verify("HMAC",r,new TextEncoder().encode(atob(i)),new TextEncoder().encode(JSON.stringify(e))))return!0;return!1}};var N=class{constructor(t){this._transport=t}get(t,{request:e={}}={}){return this._transport.send("v1/webhooks/subscriptions/"+encodeURIComponent(t),{...e,method:"GET"})}list({request:t={}}={}){return this._transport.send("v1/webhooks/subscriptions",{...t,method:"GET"})}test(t,{request:e={}}={}){return this._transport.send("v1/webhooks/subscriptions/"+encodeURIComponent(t)+"/test",{...e,method:"POST"})}create({body:t,request:e={}}){return this._transport.send("v1/webhooks/subscriptions",{...e,method:"POST",json:t})}delete(t,{request:e={}}={}){return this._transport.send("v1/webhooks/subscriptions/"+encodeURIComponent(t),{...e,method:"DELETE"})}};var W=class{constructor(t){this._transport=t}getNotifications({request:t={}}={}){return this._transport.send(".well-known/notifications",{...t,method:"GET"})}};var f=class s{static DEFAULT_BASE_URL=j;static PublicAuthentication=g;static BasicAuthentication=x;static BearerAuthentication=O;_transport;account;accountAccessToken;accountConversationSettings;action;boilerplateCategory;boilerplateContent;channel;compositionSection;contact;conversation;label;message;model;note;notificationSubscription;source;statistics;upload;webhook;webhookSubscription;wellKnown;constructor(t,{baseURL:e,...o}={}){this._transport=new B({requestFilterables:[new w,t],...o,baseURL:e?.toString()??s.getBaseURL()}),this.account=new C(this._transport),this.accountAccessToken=new R(this._transport),this.accountConversationSettings=new b(this._transport),this.action=new v(this._transport),this.boilerplateCategory=new T(this._transport),this.boilerplateContent=new _(this._transport),this.channel=new y(this._transport),this.compositionSection=new L(this._transport),this.contact=new A(this._transport),this.conversation=new I(this._transport),this.label=new S(this._transport),this.message=new E(this._transport),this.model=new U(this._transport),this.note=new G(this._transport),this.notificationSubscription=new D(this._transport),this.source=new k(this._transport),this.statistics=new P(this._transport),this.upload=new M(this._transport),this.webhook=new F(this._transport),this.webhookSubscription=new N(this._transport),this.wellKnown=new W(this._transport)}static getBaseURL(){return process.env[et]??this.DEFAULT_BASE_URL}};var K={};Y(K,{AuthError:()=>a,AuthenticationError:()=>l,AuthorizationError:()=>d,LogicError:()=>p,NetworkError:()=>u,SupportError:()=>n,ValidationError:()=>m});0&&(module.exports={Client,DEFAULT_SUPPORT_BASE_URL,Error,eventWebhookSchema});
|
|
1
|
+
"use strict";var X=Object.create;var w=Object.defineProperty;var Z=Object.getOwnPropertyDescriptor;var tt=Object.getOwnPropertyNames;var et=Object.getPrototypeOf,ot=Object.prototype.hasOwnProperty;var Q=(s,t)=>{for(var e in t)w(s,e,{get:t[e],enumerable:!0})},j=(s,t,e,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of tt(t))!ot.call(s,n)&&n!==e&&w(s,n,{get:()=>t[n],enumerable:!(o=Z(t,n))||o.enumerable});return s};var H=(s,t,e)=>(e=s!=null?X(et(s)):{},j(t||!s||!s.__esModule?w(e,"default",{value:s,enumerable:!0}):e,s)),st=s=>j(w({},"__esModule",{value:!0}),s);var nt={};Q(nt,{Client:()=>a,DEFAULT_SUPPORT_BASE_URL:()=>B,Error:()=>W,default:()=>a,eventWebhookSchema:()=>N});module.exports=st(nt);var B="https://api.support.greatdetail.com",V={"X-Powered-By":"GDSupport/JavaScript"};var c=class{constructor(t){this._transport=t}get(t,{request:e={}}={}){return this._transport.send("v1/accounts/"+encodeURIComponent(t),{...e,method:"GET"})}getCurrent({request:t={}}){return this._transport.send("v1/accounts/current",{...t,method:"GET"})}update(t,{body:e,request:o={}}){return this._transport.send("v1/accounts/"+encodeURIComponent(t),{...o,method:"PATCH",json:e})}create({body:t,request:e={}}){return this._transport.send("v1/accounts",{...e,method:"POST",json:t})}};var m=class{constructor(t){this._transport=t}get(t,e,{request:o={}}={}){return this._transport.send("v1/accounts/"+encodeURIComponent(t)+"/access-tokens/"+encodeURIComponent(e),{...o,method:"GET"})}list(t,{request:e={}}={}){return this._transport.send("v1/accounts/"+encodeURIComponent(t)+"/access-tokens",{...e,method:"GET"})}delete(t,e,{body:o,request:n={}}={}){return this._transport.send("v1/accounts/"+encodeURIComponent(t)+"/access-tokens/"+encodeURIComponent(e),{...n,method:"DELETE",json:o})}create(t,{body:e={},request:o={}}={}){return this._transport.send("v1/accounts/"+encodeURIComponent(t)+"/access-tokens",{...o,method:"POST",json:e})}};var l=class{constructor(t){this._transport=t}get(t,{request:e={}}={}){return this._transport.send("v1/accounts/"+encodeURIComponent(t)+"/conversation-settings",{...e,method:"GET"})}update(t,{body:e,request:o={}}){return this._transport.send("v1/accounts/"+encodeURIComponent(t)+"/conversation-settings",{...o,method:"PATCH",json:e})}};var d=class{constructor(t){this._transport=t}list({limit:t,sort:e,request:o={}}={}){return this._transport.send("v1/actions",{...o,method:"GET",searchParams:[...this._transport.limitQuery(t),...this._transport.sortQuery(e)]})}};var q="SUPPORT_ACCESS_TOKEN",K="SUPPORT_KEY_NAME",Y="SUPPORT_KEY_PASSWORD",M="SUPPORT_SIGNING_KEY",z="SUPPORT_BASE_URL";var u=class{name;#t;constructor({name:t=process.env[K],password:e=process.env[Y]}={}){if(!t)throw new Error("Name option must be specified when using Basic Authentication");if(!e)throw new Error("Password option must be specified when using Basic Authentication");this.name=t,this.#t=e}getHeaders(){return{Authorization:`Basic ${btoa(this.name+":"+this.#t)}`}}};var h=class{#t;constructor({token:t=process.env[q]}={}){if(!t)throw new Error("Access Token option must be specified when using Token Authentication");this.#t=t}getHeaders(){return{Authorization:`Bearer ${this.#t}`}}};var f=class{getHeaders(){return{}}};var C=class{constructor(t){this._transport=t}get(t,{request:e={}}={}){return this._transport.send("v1/boilerplates/categories/"+encodeURIComponent(t),{...e,method:"GET"})}list({limit:t,include:e,request:o={}}={}){return this._transport.send("v1/boilerplates/categories",{...o,method:"GET",searchParams:[...this._transport.limitQuery(t),...this._transport.includeQuery(e)]})}create({body:t,request:e={}}){return this._transport.send("v1/boilerplates/categories",{...e,method:"POST",json:t})}update(t,{body:e,request:o={}}){return this._transport.send("v1/boilerplates/categories/"+encodeURIComponent(t),{...o,method:"PATCH",json:e})}};var R=class{constructor(t){this._transport=t}get(t,{request:e={}}={}){return this._transport.send("v1/boilerplates/contents/"+encodeURIComponent(t),{...e,method:"GET"})}list({limit:t,query:e,request:o={}}={}){return this._transport.send("v1/boilerplates/contents",{...o,method:"GET",searchParams:[...this._transport.limitQuery(t),...this._transport.queryQuery(e)]})}listByCategory=this.listByBoilerplateCategory;listByBoilerplateCategory(t,{limit:e,request:o={}}={}){return this._transport.send("v1/boilerplates/categories/"+encodeURIComponent(t)+"/contents",{...o,method:"GET",searchParams:[...this._transport.limitQuery(e)]})}create({body:t,request:e={}}){return this._transport.send("v1/boilerplates/contents",{...e,method:"POST",json:t})}update(t,{body:e,request:o={}}){return this._transport.send("v1/boilerplates/contents/"+encodeURIComponent(t),{...o,method:"PATCH",json:e})}};var b=class{constructor(t){this._transport=t}get(t,{request:e={}}={}){return this._transport.send("v1/channels/"+encodeURIComponent(t),{...e,method:"GET"})}list({limit:t,query:e,request:o={}}={}){return this._transport.send("v1/channels",{...o,method:"GET",searchParams:[...this._transport.limitQuery(t),...this._transport.queryQuery(e)]})}update(t,{body:e,request:o={}}){return this._transport.send("v1/channels/"+encodeURIComponent(t),{...o,method:"PATCH",json:e})}create({body:t,request:e={}}){return this._transport.send("v1/channels",{...e,method:"POST",json:t})}metaWhatsappGetBusinessProfile(t,{request:e={}}={}){return this._transport.send("v1/channels/"+encodeURIComponent(t)+"/meta-whatsapp/business-profile",{...e,method:"GET"})}twilioSendgridChannelSync(t,{body:e,request:o={}}){return this._transport.send("v1/channels/"+encodeURIComponent(t)+"/twilio-sendgrid/sync",{...o,method:"POST",json:e})}};var v=class{constructor(t){this._transport=t}get(t,{request:e={}}={}){return this._transport.send("v1/composition-sections/"+encodeURIComponent(t),{...e,method:"GET"})}list({limit:t,request:e={}}={}){return this._transport.send("v1/composition-sections",{...e,method:"GET",searchParams:[...this._transport.limitQuery(t)]})}listByChannel(t,{limit:e,request:o={}}={}){return this._transport.send("v1/channels/"+encodeURIComponent(t)+"/composition-sections",{...o,method:"GET",searchParams:[...this._transport.limitQuery(e)]})}create({body:t,request:e={}}){return this._transport.send("v1/composition-sections",{...e,method:"POST",json:t})}update(t,{body:e,request:o={}}){return this._transport.send("v1/composition-sections/"+encodeURIComponent(t),{...o,method:"PATCH",json:e})}};var O=class{constructor(t){this._transport=t}get(t,{include:e,request:o={}}={}){return this._transport.send("v1/contacts/"+encodeURIComponent(t),{...o,method:"GET",searchParams:[...this._transport.includeQuery(e??{})]})}getRelativeVCFURL(t,{vcf:e={}}={}){let o=e.variant??"vcard",n=e.format??(o==="vcard"?"vcf":"json");return"v1/contacts/"+encodeURIComponent(t)+"/vcf?variant="+encodeURIComponent(o)+"&format="+encodeURIComponent(n)}getVCFURL(t,e={}){return this._transport.getURL(this.getRelativeVCFURL(t,e))}getVCF(t,e={}){return this._transport.send(this.getVCFURL(t,e),{method:"GET"})}list({limit:t,query:e,request:o={}}={}){return this._transport.send("v1/contacts",{...o,method:"GET",searchParams:[...this._transport.limitQuery(t),...this._transport.queryQuery(e)]})}listByLabel(t,{limit:e,request:o={}}={}){return this._transport.send("v1/labels/"+encodeURIComponent(t)+"/contacts",{...o,method:"GET",searchParams:[...this._transport.limitQuery(e)]})}create({body:t,request:e={}}){return this._transport.send("v1/contacts",{...e,method:"POST",json:t})}update(t,{body:e,request:o={}}){return this._transport.send("v1/contacts/"+encodeURIComponent(t),{...o,method:"PATCH",json:e})}delete(t,{request:e={}}={}){return this._transport.send("v1/contacts/"+encodeURIComponent(t),{...e,method:"DELETE"})}};var g=class{constructor(t){this._transport=t}get(t,{include:e,request:o={}}={}){return this._transport.send("v1/conversations/"+encodeURIComponent(t),{...o,method:"GET",searchParams:[...this._transport.includeQuery(e??{})]})}list({query:t,limit:e,filter:o,include:n,request:r={}}={}){return this._transport.send("v1/conversations",{...r,method:"GET",searchParams:[...this._transport.queryQuery(t),...this._transport.limitQuery(e),...o?[["filter",o]]:[],...this._transport.includeQuery(n??{})]})}listByLabel(t,{limit:e,request:o={}}={}){return this._transport.send("v1/labels/"+encodeURIComponent(t)+"/conversations",{...o,method:"GET",searchParams:[...this._transport.limitQuery(e)]})}listByContact(t,{limit:e,request:o={}}={}){return this._transport.send("v1/contacts/"+encodeURIComponent(t)+"/conversations",{...o,method:"GET",searchParams:[...this._transport.limitQuery(e)]})}listByChannel(t,{limit:e,request:o={}}={}){return this._transport.send("v1/channels/"+encodeURIComponent(t)+"/conversations",{...o,method:"GET",searchParams:[...this._transport.limitQuery(e)]})}create({body:t,request:e={}}){return this._transport.send("v1/conversations",{...e,method:"POST",json:t})}update(t,{body:e,request:o={}}){return this._transport.send("v1/conversations/"+encodeURIComponent(t),{...o,method:"PATCH",json:e})}delete(t,{request:e={}}={}){return this._transport.send("v1/conversations/"+encodeURIComponent(t),{...e,method:"DELETE"})}};var x=class{constructor(t){this._transport=t}get(t,{request:e={}}={}){return this._transport.send("v1/labels/"+encodeURIComponent(t),{...e,method:"GET"})}list({limit:t,query:e,include:o,request:n={}}={}){return this._transport.send("v1/labels",{...n,method:"GET",searchParams:[...this._transport.limitQuery(t),...this._transport.queryQuery(e),...this._transport.includeQuery(o??{})]})}listByContact(t,{limit:e,request:o={}}={}){return this._transport.send("v1/contacts/"+encodeURIComponent(t)+"/labels",{...o,method:"GET",searchParams:[...this._transport.limitQuery(e)]})}listByConversation(t,{limit:e,request:o={}}={}){return this._transport.send("v1/conversations/"+encodeURIComponent(t)+"/labels",{...o,method:"GET",searchParams:[...this._transport.limitQuery(e)]})}create({body:t,request:e={}}){return this._transport.send("v1/labels",{...e,method:"POST",json:t})}update(t,{body:e,request:o={}}){return this._transport.send("v1/labels/"+encodeURIComponent(t),{...o,method:"PATCH",json:e})}delete(t,{request:e={}}={}){return this._transport.send("v1/labels/"+encodeURIComponent(t),{...e,method:"DELETE"})}};var T=class{constructor(t){this._transport=t}list({limit:t,include:e,request:o={}}={}){return this._transport.send("v1/messages",{...o,method:"GET",searchParams:[...this._transport.limitQuery(t),...this._transport.includeQuery(e??{})]})}listByConversation(t,{limit:e,include:o,request:n={}}={}){return this._transport.send("v1/conversations/"+encodeURIComponent(t)+"/messages",{...n,method:"GET",searchParams:[...this._transport.limitQuery(e),...this._transport.includeQuery(o??{})]})}listByChannel(t,{limit:e,include:o,request:n={}}={}){return this._transport.send("v1/channels/"+encodeURIComponent(t)+"/messages",{...n,method:"GET",searchParams:[...this._transport.limitQuery(e),...this._transport.includeQuery(o)]})}create({body:t,request:e={}}){return this._transport.send("v1/messages",{...e,method:"POST",json:t})}delete(t,{request:e={}}={}){return this._transport.send("v1/messages/"+encodeURIComponent(t),{...e,method:"DELETE"})}};var _=class{constructor(t){this._transport=t}get(t,{request:e={}}={}){return this._transport.send("v1/models/"+encodeURIComponent(t),{...e,method:"GET"})}list({request:t={}}={}){return this._transport.send("v1/models",{...t,method:"GET"})}createResponse(t,{body:e,request:o={}}){return this._transport.send("v1/models/"+encodeURIComponent(t)+"/response",{...o,method:"POST",timeout:12e4,json:e})}createCorrection(t,{body:e,request:o={}}){return this._transport.send("v1/models/"+encodeURIComponent(t)+"/correction",{...o,method:"POST",json:e})}};var y=class{constructor(t){this._transport=t}get(t,{request:e={}}={}){return this._transport.send("v1/notes/"+encodeURIComponent(t),{...e,method:"GET"})}listByContact(t,{request:e={}}={}){return this._transport.send("v1/contacts/"+encodeURIComponent(t)+"/notes",{...e,method:"GET"})}listByConversation(t,{request:e={}}={}){return this._transport.send("v1/conversations/"+encodeURIComponent(t)+"/notes",{...e,method:"GET"})}createForContact(t,{body:e,request:o={}}){return this._transport.send("v1/contacts/"+encodeURIComponent(t)+"/notes",{...o,method:"POST",json:e})}createForConversation(t,{body:e,request:o={}}){return this._transport.send("v1/conversations/"+encodeURIComponent(t)+"/notes",{...o,method:"POST",json:e})}update(t,{body:e,request:o={}}){return this._transport.send("v1/notes/"+encodeURIComponent(t),{...o,method:"PATCH",json:e})}};var L=class{constructor(t){this._transport=t}createForContact(t,{body:e,request:o={}}){return this._transport.send("v1/contacts/"+encodeURIComponent(t)+"/notification-subscriptions",{...o,method:"POST",json:e})}};var I=class s{constructor(t=s.STANDARD_HEADERS){this._standardHeaders=t}static STANDARD_HEADERS=V;async filter(){return{headers:this.getHeaders()}}getHeaders(){return this._standardHeaders}};var A=class{constructor(t){this._transport=t}get(t,{request:e={}}={}){return this._transport.send("v1/sources/"+encodeURIComponent(t),{...e,method:"GET"})}list({featured:t,category:e,request:o={}}={}){let n=[];if(e){let r=Array.isArray(e)?e:[e];for(let p of r)n.push(["category",p])}return t!==void 0&&n.push(["featured",String(t)]),this._transport.send("v1/sources",{...o,method:"GET",searchParams:n})}};var S=class{constructor(t){this._transport=t}getMessageFrequency({request:t={}}={}){return this._transport.send("v1/statistics/message-frequency",{...t,method:"GET"})}getChannelMessageFrequency(t,{request:e={}}={}){return this._transport.send("v1/channels/"+encodeURIComponent(t)+"/statistics/message-frequency",{...e,method:"GET"})}getModelUsage({request:t={}}={}){return this._transport.send("v1/statistics/model-usage",{...t,method:"GET"})}};var J=H(require("is-network-error"),1),F=H(require("ky"),1);var U=class extends Error{constructor(e,o){super("Support Error",{cause:o});this.response=e}};var E=class{client;options;constructor({baseURL:t,...e}){this.options={...e,baseURL:t},this.client=F.default.create({prefixUrl:this.options.baseURL,timeout:12e3,hooks:{beforeRequest:[o=>{for(let n of this.options.requestFilterables){let r=n.getHeaders();for(let[p,$]of Object.entries(r))o.headers.has(p)||o.headers.set(p,$)}}]}})}getURL(t){return new URL(t,this.options.baseURL).toString()}sortQuery(t){let e=[];if(t===void 0)return e;for(let[o,n]of Object.entries(t))n!==void 0&&e.push(["sort",n+o]);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 o of Object.keys(t))e.push(["include",o]);return e}queryQuery(t){let e=[];return t===void 0||e.push(["query",t]),e}send(t,e={}){let o=this.client(t,e).catch(async n=>{throw(0,J.default)(n)?new Error("A network error occurred",{cause:n}):n instanceof F.HTTPError?new U(n.response,n):n});return{response:()=>o,json:async()=>(await o).json()}}};var G=class{constructor(t){this._transport=t}get(t,{request:e={}}={}){return this._transport.send("v1/uploads/"+encodeURIComponent(t),{...e,method:"GET"})}list({request:t={}}={}){return this._transport.send("v1/uploads",{...t,method:"GET"})}create({account:t,files:e,request:o={}}){let n=new FormData;for(let r of e)n.append("file",r);return this._transport.send("v1/uploads",{...o,method:"POST",body:n,searchParams:{account:t}})}delete(t,{request:e={}}={}){return this._transport.send("v1/uploads/"+encodeURIComponent(t),{...e,method:"DELETE"})}};var i=require("zod"),N=i.z.object({data:i.z.object({event:i.z.object({id:i.z.string(),type:i.z.string(),payload:i.z.record(i.z.string()),createdAt:i.z.string().datetime()})})});var D=class{constructor(t){this._transport=t}async event({key:t=process.env[M],maxSignatures:e=3,request:o}){let n=o.headers["gds-signature"];if(t!==!1){if(t===void 0)throw new Error("Missing webhook signing key in process.env."+M);if(!n)throw new Error("Missing signature header");if(!this._verifySignature(t,o.body,Array.isArray(n)?n.slice(0,e):[n]))throw new Error("Untrusted signature")}let{data:r}=N.parse(o.body);return{event:r.event}}async _verifySignature(t,e,o){let n=await crypto.subtle.importKey("raw",new TextEncoder().encode(t),{name:"HMAC",hash:"SHA-256"},!1,["sign","verify"]);for(let r of o)if(await crypto.subtle.verify("HMAC",n,new TextEncoder().encode(atob(r)),new TextEncoder().encode(JSON.stringify(e))))return!0;return!1}};var k=class{constructor(t){this._transport=t}get(t,{request:e={}}={}){return this._transport.send("v1/webhooks/subscriptions/"+encodeURIComponent(t),{...e,method:"GET"})}list({request:t={}}={}){return this._transport.send("v1/webhooks/subscriptions",{...t,method:"GET"})}test(t,{request:e={}}={}){return this._transport.send("v1/webhooks/subscriptions/"+encodeURIComponent(t)+"/test",{...e,method:"POST"})}create({body:t,request:e={}}){return this._transport.send("v1/webhooks/subscriptions",{...e,method:"POST",json:t})}delete(t,{request:e={}}={}){return this._transport.send("v1/webhooks/subscriptions/"+encodeURIComponent(t),{...e,method:"DELETE"})}};var P=class{constructor(t){this._transport=t}getNotifications({request:t={}}={}){return this._transport.send(".well-known/notifications",{...t,method:"GET"})}};var a=class s{static DEFAULT_BASE_URL=B;static PublicAuthentication=f;static BasicAuthentication=u;static BearerAuthentication=h;_transport;account;accountAccessToken;accountConversationSettings;action;boilerplateCategory;boilerplateContent;channel;compositionSection;contact;conversation;label;message;model;note;notificationSubscription;source;statistics;upload;webhook;webhookSubscription;wellKnown;constructor(t,{baseURL:e,...o}={}){this._transport=new E({requestFilterables:[new I,t],...o,baseURL:e?.toString()??s.getBaseURL()}),this.account=new c(this._transport),this.accountAccessToken=new m(this._transport),this.accountConversationSettings=new l(this._transport),this.action=new d(this._transport),this.boilerplateCategory=new C(this._transport),this.boilerplateContent=new R(this._transport),this.channel=new b(this._transport),this.compositionSection=new v(this._transport),this.contact=new O(this._transport),this.conversation=new g(this._transport),this.label=new x(this._transport),this.message=new T(this._transport),this.model=new _(this._transport),this.note=new y(this._transport),this.notificationSubscription=new L(this._transport),this.source=new A(this._transport),this.statistics=new S(this._transport),this.upload=new G(this._transport),this.webhook=new D(this._transport),this.webhookSubscription=new k(this._transport),this.wellKnown=new P(this._transport)}static getBaseURL(){return process.env[z]??this.DEFAULT_BASE_URL}};var W={};Q(W,{SupportError:()=>U});0&&(module.exports={Client,DEFAULT_SUPPORT_BASE_URL,Error,eventWebhookSchema});
|
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { A as Account, k as AccountAccessToken, cN as AccountAccessTokenEventType, l as AccountAccessTokenID, u as AccountConversationSettings, b as AccountID, cM as AccountWebhookEventType, B as Action, E as ActionID, b0 as ActiveConversationStatus, $ as BoilerplateCategory, a0 as BoilerplateCategoryID, I as BoilerplateContent, J as BoilerplateContentID, ac as Channel, ad as ChannelID, C as Client, at as CompositionSection, au as CompositionSectionID, b1 as ConcludedConversationStatus, aH as Contact, cO as ContactEventType, aI as ContactID, a_ as Conversation, cP as ConversationEventType, a$ as ConversationID, b2 as ConversationStatus, n as CreateAccountAccessTokenOptions, m as CreateAccountAccessTokenPayload, o as CreateAccountAccessTokenResponse, d as CreateAccountOptions, c as CreateAccountPayload, e as CreateAccountResponse, a2 as CreateBoilerplateCategoryOptions, a1 as CreateBoilerplateCategoryPayload, a3 as CreateBoilerplateCategoryResponse, M as CreateBoilerplateContentOptions, K as CreateBoilerplateContentPayload, N as CreateBoilerplateContentResponse, af as CreateChannelOptions, ae as CreateChannelPayload, ag as CreateChannelResponse, aw as CreateCompositionSectionOptions, av as CreateCompositionSectionPayload, ax as CreateCompositionSectionResponse, cb as CreateContactNoteOptions, ca as CreateContactNotePayload, cc as CreateContactNoteResponse, cy as CreateContactNotificationSubscriptionOptions, cx as CreateContactNotificationSubscriptionPayload, cz as CreateContactNotificationSubscriptionResponse, aL as CreateContactOptions, aK as CreateContactPayload, aM as CreateContactResponse, ce as CreateConversationNoteOptions, cd as CreateConversationNotePayload, cf as CreateConversationNoteResponse, b4 as CreateConversationOptions, b3 as CreateConversationPayload, b5 as CreateConversationResponse, b$ as CreateCorrectionModelOptions, b_ as CreateCorrectionModelPayload, c0 as CreateCorrectionResponse, bq as CreateLabelOptions, bp as CreateLabelPayload, br as CreateLabelResponse, bJ as CreateMessageOptions, bI as CreateMessagePayload, bK as CreateMessageResponse, c2 as CreateResponseModelOptions, c1 as CreateResponseModelPayload, c3 as CreateResponseResponse, cC as CreateUploadOptions, cD as CreateUploadResponse, cW as CreateWebhookSubscriptionOptions, cV as CreateWebhookSubscriptionPayload, cX as CreateWebhookSubscriptionResponse, aJ as CustomMetadata, p as DeleteAccountAccessTokenOptions, D as DeleteAccountAccessTokenPayload, q as DeleteAccountAccessTokenResponse, aN as DeleteContactOptions, aO as DeleteContactResponse, b6 as DeleteConversationOptions, b7 as DeleteConversationResponse, bs as DeleteLabelOptions, bt as DeleteLabelResponse, bL as DeleteMessageOptions, bM as DeleteMessageResponse, cE as DeleteUploadOptions, cF as DeleteUploadResponse, cY as DeleteWebhookSubscriptionOptions, cZ as DeleteWebhookSubscriptionResponse, cJ as EventWebhookOptions, bg as FilterOptions, r as GetAccountAccessTokenOptions, s as GetAccountAccessTokenResponse, v as GetAccountConversationSettingsOptions, w as GetAccountConversationSettingsResponse, G as GetAccountOptions, f as GetAccountResponse, a4 as GetBoilerplateCategoryOptions, a5 as GetBoilerplateCategoryResponse, P as GetBoilerplateContentOptions, Q as GetBoilerplateContentResponse, ah as GetChannelOptions, ai as GetChannelResponse, ay as GetCompositionSectionOptions, az as GetCompositionSectionResponse, aP as GetContactIncludeOptions, aQ as GetContactOptions, aR as GetContactResponse, aS as GetContactVCFOptions, b8 as GetConversationIncludeOptions, b9 as GetConversationOptions, ba as GetConversationResponse, g as GetCurrentAccountOptions, h as GetCurrentAccountResponse, bu as GetLabelOptions, bv as GetLabelResponse, c4 as GetModelOptions, c5 as GetModelResponse, cg as GetNoteOptions, ch as GetNoteResponse, d5 as GetNotificationWellKnownResponse, cr as GetSourceOptions, cs as GetSourceResponse, cG as GetUploadOptions, cH as GetUploadResponse, c_ as GetWebhookSubscriptionOptions, c$ as GetWebhookSubscriptionResponse, bo as Label, bw as LabelID, L as ListAccountAccessTokensOptions, t as ListAccountAccessTokensResponse, F as ListActionsOptions, H as ListActionsResponse, a6 as ListBoilerplateCategoriesIncludeOptions, a7 as ListBoilerplateCategoriesOptions, a8 as ListBoilerplateCategoriesResponse, T as ListBoilerplateCategoryBoilerplateContentsOptions, V as ListBoilerplateCategoryBoilerplateContentsResponse, W as ListBoilerplateContentsOptions, X as ListBoilerplateContentsResponse, aA as ListChannelCompositionSectionsOptions, aB as ListChannelCompositionSectionsResponse, bb as ListChannelConversationsOptions, bc as ListChannelConversationsResponse, bN as ListChannelMessagesIncludeOptions, bO as ListChannelMessagesOptions, bP as ListChannelMessagesResponse, aj as ListChannelsOptions, ak as ListChannelsResponse, aC as ListCompositionSectionsOptions, aD as ListCompositionSectionsResponse, bd as ListContactConversationsOptions, be as ListContactConversationsResponse, bx as ListContactLabelsOptions, by as ListContactLabelsResponse, ci as ListContactNotesOptions, cj as ListContactNotesResponse, aT as ListContactsOptions, aU as ListContactsResponse, bz as ListConversationLabelsOptions, bA as ListConversationLabelsResponse, bQ as ListConversationMessagesIncludeOptions, bR as ListConversationMessagesOptions, bS as ListConversationMessagesResponse, ck as ListConversationNotesOptions, cl as ListConversationNotesResponse, bh as ListConversationOptions, bf as ListConversationsIncludeOptions, bi as ListConversationsResponse, aV as ListLabelContactsOptions, aW as ListLabelContactsResponse, bj as ListLabelConversationsOptions, bk as ListLabelConversationsResponse, bB as ListLabelsIncludeOptions, bC as ListLabelsOptions, bD as ListLabelsResponse, bT as ListMessagesIncludeOptions, bU as ListMessagesOptions, bV as ListMessagesResponse, c6 as ListModelsOptions, c7 as ListModelsResponse, ct as ListSourcesOptions, cu as ListSourcesResponse, d0 as ListWebhookSubscriptionsOptions, d1 as ListWebhookSubscriptionsResponse, bH as Message, cQ as MessageEventType, bW as MessageID, bX as MessageRole, bY as MessageStatus, al as MetaWhatsappChannelGetBusinessProfileOptions, am as MetaWhatsappChannelGetBusinessProfileResponse, bZ as Model, c8 as ModelID, c9 as Note, cm as NoteID, cw as NotificationSubscription, cA as NotificationSubscriptionID, O as Options, R as RequestFilterable, S as SortOptions, cq as Source, cv as SourceID, d2 as TestWebhookSubscriptionOptions, d3 as TestWebhookSubscriptionResponse, a as TransportOptions, an as TwilioSendChannelSyncPayload, ao as TwilioSendgridChannelSyncOptions, ap as TwilioSendgridChannelSyncResponse, y as UpdateAccountConversationSettingsOptions, x as UpdateAccountConversationSettingsPayload, z as UpdateAccountConversationSettingsResponse, i as UpdateAccountOptions, U as UpdateAccountPayload, j as UpdateAccountResponse, aa as UpdateBoilerplateCategoryOptions, a9 as UpdateBoilerplateCategoryPayload, ab as UpdateBoilerplateCategoryResponse, Z as UpdateBoilerplateContentOptions, Y as UpdateBoilerplateContentPayload, _ as UpdateBoilerplateContentResponse, ar as UpdateChannelOptions, aq as UpdateChannelPayload, as as UpdateChannelResponse, aF as UpdateCompositionSectionOptions, aE as UpdateCompositionSectionPayload, aG as UpdateCompositionSectionResponse, aY as UpdateContactOptions, aX as UpdateContactPayload, aZ as UpdateContactResponse, bm as UpdateConversationOptions, bl as UpdateConversationPayload, bn as UpdateConversationResponse, bF as UpdateLabelOptions, bE as UpdateLabelPayload, bG as UpdateLabelResponse, co as UpdateNoteOptions, cn as UpdateNotePayload, cp as UpdateNoteResponse, cB as Upload, cI as UploadID, cS as WebhookEventPayload, cL as WebhookEventType, cT as WebhookResponse, cU as WebhookSubscription, cR as WebhookSubscriptionEventType, d4 as WebhookSubscriptionID, C as default, cK as eventWebhookSchema } from './Client-
|
|
2
|
-
import 'ky';
|
|
1
|
+
export { A as Account, k as AccountAccessToken, cN as AccountAccessTokenEventType, l as AccountAccessTokenID, u as AccountConversationSettings, b as AccountID, cM as AccountWebhookEventType, B as Action, E as ActionID, b0 as ActiveConversationStatus, $ as BoilerplateCategory, a0 as BoilerplateCategoryID, I as BoilerplateContent, J as BoilerplateContentID, ac as Channel, ad as ChannelID, C as Client, at as CompositionSection, au as CompositionSectionID, b1 as ConcludedConversationStatus, aH as Contact, cO as ContactEventType, aI as ContactID, a_ as Conversation, cP as ConversationEventType, a$ as ConversationID, b2 as ConversationStatus, n as CreateAccountAccessTokenOptions, m as CreateAccountAccessTokenPayload, o as CreateAccountAccessTokenResponse, d as CreateAccountOptions, c as CreateAccountPayload, e as CreateAccountResponse, a2 as CreateBoilerplateCategoryOptions, a1 as CreateBoilerplateCategoryPayload, a3 as CreateBoilerplateCategoryResponse, M as CreateBoilerplateContentOptions, K as CreateBoilerplateContentPayload, N as CreateBoilerplateContentResponse, af as CreateChannelOptions, ae as CreateChannelPayload, ag as CreateChannelResponse, aw as CreateCompositionSectionOptions, av as CreateCompositionSectionPayload, ax as CreateCompositionSectionResponse, cb as CreateContactNoteOptions, ca as CreateContactNotePayload, cc as CreateContactNoteResponse, cy as CreateContactNotificationSubscriptionOptions, cx as CreateContactNotificationSubscriptionPayload, cz as CreateContactNotificationSubscriptionResponse, aL as CreateContactOptions, aK as CreateContactPayload, aM as CreateContactResponse, ce as CreateConversationNoteOptions, cd as CreateConversationNotePayload, cf as CreateConversationNoteResponse, b4 as CreateConversationOptions, b3 as CreateConversationPayload, b5 as CreateConversationResponse, b$ as CreateCorrectionModelOptions, b_ as CreateCorrectionModelPayload, c0 as CreateCorrectionResponse, bq as CreateLabelOptions, bp as CreateLabelPayload, br as CreateLabelResponse, bJ as CreateMessageOptions, bI as CreateMessagePayload, bK as CreateMessageResponse, c2 as CreateResponseModelOptions, c1 as CreateResponseModelPayload, c3 as CreateResponseResponse, cC as CreateUploadOptions, cD as CreateUploadResponse, cW as CreateWebhookSubscriptionOptions, cV as CreateWebhookSubscriptionPayload, cX as CreateWebhookSubscriptionResponse, aJ as CustomMetadata, p as DeleteAccountAccessTokenOptions, D as DeleteAccountAccessTokenPayload, q as DeleteAccountAccessTokenResponse, aN as DeleteContactOptions, aO as DeleteContactResponse, b6 as DeleteConversationOptions, b7 as DeleteConversationResponse, bs as DeleteLabelOptions, bt as DeleteLabelResponse, bL as DeleteMessageOptions, bM as DeleteMessageResponse, cE as DeleteUploadOptions, cF as DeleteUploadResponse, cY as DeleteWebhookSubscriptionOptions, cZ as DeleteWebhookSubscriptionResponse, cJ as EventWebhookOptions, bg as FilterOptions, r as GetAccountAccessTokenOptions, s as GetAccountAccessTokenResponse, v as GetAccountConversationSettingsOptions, w as GetAccountConversationSettingsResponse, G as GetAccountOptions, f as GetAccountResponse, a4 as GetBoilerplateCategoryOptions, a5 as GetBoilerplateCategoryResponse, P as GetBoilerplateContentOptions, Q as GetBoilerplateContentResponse, ah as GetChannelOptions, ai as GetChannelResponse, ay as GetCompositionSectionOptions, az as GetCompositionSectionResponse, aP as GetContactIncludeOptions, aQ as GetContactOptions, aR as GetContactResponse, aS as GetContactVCFOptions, b8 as GetConversationIncludeOptions, b9 as GetConversationOptions, ba as GetConversationResponse, g as GetCurrentAccountOptions, h as GetCurrentAccountResponse, bu as GetLabelOptions, bv as GetLabelResponse, c4 as GetModelOptions, c5 as GetModelResponse, cg as GetNoteOptions, ch as GetNoteResponse, d5 as GetNotificationWellKnownResponse, cr as GetSourceOptions, cs as GetSourceResponse, cG as GetUploadOptions, cH as GetUploadResponse, c_ as GetWebhookSubscriptionOptions, c$ as GetWebhookSubscriptionResponse, bo as Label, bw as LabelID, L as ListAccountAccessTokensOptions, t as ListAccountAccessTokensResponse, F as ListActionsOptions, H as ListActionsResponse, a6 as ListBoilerplateCategoriesIncludeOptions, a7 as ListBoilerplateCategoriesOptions, a8 as ListBoilerplateCategoriesResponse, T as ListBoilerplateCategoryBoilerplateContentsOptions, V as ListBoilerplateCategoryBoilerplateContentsResponse, W as ListBoilerplateContentsOptions, X as ListBoilerplateContentsResponse, aA as ListChannelCompositionSectionsOptions, aB as ListChannelCompositionSectionsResponse, bb as ListChannelConversationsOptions, bc as ListChannelConversationsResponse, bN as ListChannelMessagesIncludeOptions, bO as ListChannelMessagesOptions, bP as ListChannelMessagesResponse, aj as ListChannelsOptions, ak as ListChannelsResponse, aC as ListCompositionSectionsOptions, aD as ListCompositionSectionsResponse, bd as ListContactConversationsOptions, be as ListContactConversationsResponse, bx as ListContactLabelsOptions, by as ListContactLabelsResponse, ci as ListContactNotesOptions, cj as ListContactNotesResponse, aT as ListContactsOptions, aU as ListContactsResponse, bz as ListConversationLabelsOptions, bA as ListConversationLabelsResponse, bQ as ListConversationMessagesIncludeOptions, bR as ListConversationMessagesOptions, bS as ListConversationMessagesResponse, ck as ListConversationNotesOptions, cl as ListConversationNotesResponse, bh as ListConversationOptions, bf as ListConversationsIncludeOptions, bi as ListConversationsResponse, aV as ListLabelContactsOptions, aW as ListLabelContactsResponse, bj as ListLabelConversationsOptions, bk as ListLabelConversationsResponse, bB as ListLabelsIncludeOptions, bC as ListLabelsOptions, bD as ListLabelsResponse, bT as ListMessagesIncludeOptions, bU as ListMessagesOptions, bV as ListMessagesResponse, c6 as ListModelsOptions, c7 as ListModelsResponse, ct as ListSourcesOptions, cu as ListSourcesResponse, d0 as ListWebhookSubscriptionsOptions, d1 as ListWebhookSubscriptionsResponse, bH as Message, cQ as MessageEventType, bW as MessageID, bX as MessageRole, bY as MessageStatus, al as MetaWhatsappChannelGetBusinessProfileOptions, am as MetaWhatsappChannelGetBusinessProfileResponse, bZ as Model, c8 as ModelID, c9 as Note, cm as NoteID, cw as NotificationSubscription, cA as NotificationSubscriptionID, O as Options, R as RequestFilterable, S as SortOptions, cq as Source, cv as SourceID, d2 as TestWebhookSubscriptionOptions, d3 as TestWebhookSubscriptionResponse, a as TransportOptions, an as TwilioSendChannelSyncPayload, ao as TwilioSendgridChannelSyncOptions, ap as TwilioSendgridChannelSyncResponse, y as UpdateAccountConversationSettingsOptions, x as UpdateAccountConversationSettingsPayload, z as UpdateAccountConversationSettingsResponse, i as UpdateAccountOptions, U as UpdateAccountPayload, j as UpdateAccountResponse, aa as UpdateBoilerplateCategoryOptions, a9 as UpdateBoilerplateCategoryPayload, ab as UpdateBoilerplateCategoryResponse, Z as UpdateBoilerplateContentOptions, Y as UpdateBoilerplateContentPayload, _ as UpdateBoilerplateContentResponse, ar as UpdateChannelOptions, aq as UpdateChannelPayload, as as UpdateChannelResponse, aF as UpdateCompositionSectionOptions, aE as UpdateCompositionSectionPayload, aG as UpdateCompositionSectionResponse, aY as UpdateContactOptions, aX as UpdateContactPayload, aZ as UpdateContactResponse, bm as UpdateConversationOptions, bl as UpdateConversationPayload, bn as UpdateConversationResponse, bF as UpdateLabelOptions, bE as UpdateLabelPayload, bG as UpdateLabelResponse, co as UpdateNoteOptions, cn as UpdateNotePayload, cp as UpdateNoteResponse, cB as Upload, cI as UploadID, cS as WebhookEventPayload, cL as WebhookEventType, cT as WebhookResponse, cU as WebhookSubscription, cR as WebhookSubscriptionEventType, d4 as WebhookSubscriptionID, C as default, cK as eventWebhookSchema } from './Client-BzMax1jd.cjs';
|
|
2
|
+
import { KyResponse } from 'ky';
|
|
3
3
|
import 'zod';
|
|
4
4
|
|
|
5
5
|
/**
|
|
@@ -17,42 +17,6 @@ import 'zod';
|
|
|
17
17
|
*/
|
|
18
18
|
declare const DEFAULT_SUPPORT_BASE_URL = "https://api.support.greatdetail.com";
|
|
19
19
|
|
|
20
|
-
/**
|
|
21
|
-
* Great Detail Support System.
|
|
22
|
-
*
|
|
23
|
-
* @copyright 2024 Great Detail Ltd
|
|
24
|
-
* @author Great Detail Ltd <info@greatdetail.com>
|
|
25
|
-
* @author Dom Webber <dom.webber@greatdetail.com>
|
|
26
|
-
* @see https://greatdetail.com
|
|
27
|
-
*/
|
|
28
|
-
declare class SupportError extends Error {
|
|
29
|
-
static serverError(status: number): SupportError;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* Great Detail Support System.
|
|
34
|
-
*
|
|
35
|
-
* @copyright 2024 Great Detail Ltd
|
|
36
|
-
* @author Great Detail Ltd <info@greatdetail.com>
|
|
37
|
-
* @author Dom Webber <dom.webber@greatdetail.com>
|
|
38
|
-
* @see https://greatdetail.com
|
|
39
|
-
*/
|
|
40
|
-
|
|
41
|
-
declare class NetworkError extends SupportError {
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* Great Detail Support System.
|
|
46
|
-
*
|
|
47
|
-
* @copyright 2024 Great Detail Ltd
|
|
48
|
-
* @author Great Detail Ltd <info@greatdetail.com>
|
|
49
|
-
* @author Dom Webber <dom.webber@greatdetail.com>
|
|
50
|
-
* @see https://greatdetail.com
|
|
51
|
-
*/
|
|
52
|
-
|
|
53
|
-
declare class AuthError extends SupportError {
|
|
54
|
-
}
|
|
55
|
-
|
|
56
20
|
/**
|
|
57
21
|
* Great Detail Support System.
|
|
58
22
|
*
|
|
@@ -62,51 +26,18 @@ declare class AuthError extends SupportError {
|
|
|
62
26
|
* @see https://greatdetail.com
|
|
63
27
|
*/
|
|
64
28
|
|
|
65
|
-
declare class
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
/**
|
|
70
|
-
* Great Detail Support System.
|
|
71
|
-
*
|
|
72
|
-
* @copyright 2024 Great Detail Ltd
|
|
73
|
-
* @author Great Detail Ltd <info@greatdetail.com>
|
|
74
|
-
* @author Dom Webber <dom.webber@greatdetail.com>
|
|
75
|
-
* @see https://greatdetail.com
|
|
76
|
-
*/
|
|
77
|
-
|
|
78
|
-
declare class AuthorizationError extends AuthError {
|
|
79
|
-
static forbidden(): AuthorizationError;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
/**
|
|
83
|
-
* Great Detail Support System.
|
|
84
|
-
*
|
|
85
|
-
* @copyright 2024 Great Detail Ltd
|
|
86
|
-
* @author Great Detail Ltd <info@greatdetail.com>
|
|
87
|
-
* @author Dom Webber <dom.webber@greatdetail.com>
|
|
88
|
-
* @see https://greatdetail.com
|
|
89
|
-
*/
|
|
90
|
-
|
|
91
|
-
declare class ValidationError extends SupportError {
|
|
92
|
-
static badRequest(): ValidationError;
|
|
93
|
-
static unsupportedMediaType(): ValidationError;
|
|
29
|
+
declare class SupportError extends Error {
|
|
30
|
+
response: KyResponse<ErrorResponse>;
|
|
31
|
+
constructor(response: KyResponse<ErrorResponse>, cause: Error);
|
|
94
32
|
}
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
*/
|
|
104
|
-
|
|
105
|
-
declare class LogicError extends SupportError {
|
|
106
|
-
static notFound(url: string): LogicError;
|
|
107
|
-
static forbiddenMethod(method: string, url: string): LogicError;
|
|
108
|
-
static teapot(): LogicError;
|
|
109
|
-
static rateLimited(): LogicError;
|
|
33
|
+
interface ErrorResponse {
|
|
34
|
+
trace?: string;
|
|
35
|
+
errors: {
|
|
36
|
+
status?: number;
|
|
37
|
+
code?: string;
|
|
38
|
+
title: string;
|
|
39
|
+
message?: string;
|
|
40
|
+
}[];
|
|
110
41
|
}
|
|
111
42
|
|
|
112
43
|
/**
|
|
@@ -118,22 +49,11 @@ declare class LogicError extends SupportError {
|
|
|
118
49
|
* @see https://greatdetail.com
|
|
119
50
|
*/
|
|
120
51
|
|
|
121
|
-
type
|
|
122
|
-
declare const index_AuthError: typeof AuthError;
|
|
123
|
-
type index_AuthenticationError = AuthenticationError;
|
|
124
|
-
declare const index_AuthenticationError: typeof AuthenticationError;
|
|
125
|
-
type index_AuthorizationError = AuthorizationError;
|
|
126
|
-
declare const index_AuthorizationError: typeof AuthorizationError;
|
|
127
|
-
type index_LogicError = LogicError;
|
|
128
|
-
declare const index_LogicError: typeof LogicError;
|
|
129
|
-
type index_NetworkError = NetworkError;
|
|
130
|
-
declare const index_NetworkError: typeof NetworkError;
|
|
52
|
+
type index_ErrorResponse = ErrorResponse;
|
|
131
53
|
type index_SupportError = SupportError;
|
|
132
54
|
declare const index_SupportError: typeof SupportError;
|
|
133
|
-
type index_ValidationError = ValidationError;
|
|
134
|
-
declare const index_ValidationError: typeof ValidationError;
|
|
135
55
|
declare namespace index {
|
|
136
|
-
export {
|
|
56
|
+
export { type index_ErrorResponse as ErrorResponse, index_SupportError as SupportError };
|
|
137
57
|
}
|
|
138
58
|
|
|
139
59
|
export { DEFAULT_SUPPORT_BASE_URL, index as Error };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { A as Account, k as AccountAccessToken, cN as AccountAccessTokenEventType, l as AccountAccessTokenID, u as AccountConversationSettings, b as AccountID, cM as AccountWebhookEventType, B as Action, E as ActionID, b0 as ActiveConversationStatus, $ as BoilerplateCategory, a0 as BoilerplateCategoryID, I as BoilerplateContent, J as BoilerplateContentID, ac as Channel, ad as ChannelID, C as Client, at as CompositionSection, au as CompositionSectionID, b1 as ConcludedConversationStatus, aH as Contact, cO as ContactEventType, aI as ContactID, a_ as Conversation, cP as ConversationEventType, a$ as ConversationID, b2 as ConversationStatus, n as CreateAccountAccessTokenOptions, m as CreateAccountAccessTokenPayload, o as CreateAccountAccessTokenResponse, d as CreateAccountOptions, c as CreateAccountPayload, e as CreateAccountResponse, a2 as CreateBoilerplateCategoryOptions, a1 as CreateBoilerplateCategoryPayload, a3 as CreateBoilerplateCategoryResponse, M as CreateBoilerplateContentOptions, K as CreateBoilerplateContentPayload, N as CreateBoilerplateContentResponse, af as CreateChannelOptions, ae as CreateChannelPayload, ag as CreateChannelResponse, aw as CreateCompositionSectionOptions, av as CreateCompositionSectionPayload, ax as CreateCompositionSectionResponse, cb as CreateContactNoteOptions, ca as CreateContactNotePayload, cc as CreateContactNoteResponse, cy as CreateContactNotificationSubscriptionOptions, cx as CreateContactNotificationSubscriptionPayload, cz as CreateContactNotificationSubscriptionResponse, aL as CreateContactOptions, aK as CreateContactPayload, aM as CreateContactResponse, ce as CreateConversationNoteOptions, cd as CreateConversationNotePayload, cf as CreateConversationNoteResponse, b4 as CreateConversationOptions, b3 as CreateConversationPayload, b5 as CreateConversationResponse, b$ as CreateCorrectionModelOptions, b_ as CreateCorrectionModelPayload, c0 as CreateCorrectionResponse, bq as CreateLabelOptions, bp as CreateLabelPayload, br as CreateLabelResponse, bJ as CreateMessageOptions, bI as CreateMessagePayload, bK as CreateMessageResponse, c2 as CreateResponseModelOptions, c1 as CreateResponseModelPayload, c3 as CreateResponseResponse, cC as CreateUploadOptions, cD as CreateUploadResponse, cW as CreateWebhookSubscriptionOptions, cV as CreateWebhookSubscriptionPayload, cX as CreateWebhookSubscriptionResponse, aJ as CustomMetadata, p as DeleteAccountAccessTokenOptions, D as DeleteAccountAccessTokenPayload, q as DeleteAccountAccessTokenResponse, aN as DeleteContactOptions, aO as DeleteContactResponse, b6 as DeleteConversationOptions, b7 as DeleteConversationResponse, bs as DeleteLabelOptions, bt as DeleteLabelResponse, bL as DeleteMessageOptions, bM as DeleteMessageResponse, cE as DeleteUploadOptions, cF as DeleteUploadResponse, cY as DeleteWebhookSubscriptionOptions, cZ as DeleteWebhookSubscriptionResponse, cJ as EventWebhookOptions, bg as FilterOptions, r as GetAccountAccessTokenOptions, s as GetAccountAccessTokenResponse, v as GetAccountConversationSettingsOptions, w as GetAccountConversationSettingsResponse, G as GetAccountOptions, f as GetAccountResponse, a4 as GetBoilerplateCategoryOptions, a5 as GetBoilerplateCategoryResponse, P as GetBoilerplateContentOptions, Q as GetBoilerplateContentResponse, ah as GetChannelOptions, ai as GetChannelResponse, ay as GetCompositionSectionOptions, az as GetCompositionSectionResponse, aP as GetContactIncludeOptions, aQ as GetContactOptions, aR as GetContactResponse, aS as GetContactVCFOptions, b8 as GetConversationIncludeOptions, b9 as GetConversationOptions, ba as GetConversationResponse, g as GetCurrentAccountOptions, h as GetCurrentAccountResponse, bu as GetLabelOptions, bv as GetLabelResponse, c4 as GetModelOptions, c5 as GetModelResponse, cg as GetNoteOptions, ch as GetNoteResponse, d5 as GetNotificationWellKnownResponse, cr as GetSourceOptions, cs as GetSourceResponse, cG as GetUploadOptions, cH as GetUploadResponse, c_ as GetWebhookSubscriptionOptions, c$ as GetWebhookSubscriptionResponse, bo as Label, bw as LabelID, L as ListAccountAccessTokensOptions, t as ListAccountAccessTokensResponse, F as ListActionsOptions, H as ListActionsResponse, a6 as ListBoilerplateCategoriesIncludeOptions, a7 as ListBoilerplateCategoriesOptions, a8 as ListBoilerplateCategoriesResponse, T as ListBoilerplateCategoryBoilerplateContentsOptions, V as ListBoilerplateCategoryBoilerplateContentsResponse, W as ListBoilerplateContentsOptions, X as ListBoilerplateContentsResponse, aA as ListChannelCompositionSectionsOptions, aB as ListChannelCompositionSectionsResponse, bb as ListChannelConversationsOptions, bc as ListChannelConversationsResponse, bN as ListChannelMessagesIncludeOptions, bO as ListChannelMessagesOptions, bP as ListChannelMessagesResponse, aj as ListChannelsOptions, ak as ListChannelsResponse, aC as ListCompositionSectionsOptions, aD as ListCompositionSectionsResponse, bd as ListContactConversationsOptions, be as ListContactConversationsResponse, bx as ListContactLabelsOptions, by as ListContactLabelsResponse, ci as ListContactNotesOptions, cj as ListContactNotesResponse, aT as ListContactsOptions, aU as ListContactsResponse, bz as ListConversationLabelsOptions, bA as ListConversationLabelsResponse, bQ as ListConversationMessagesIncludeOptions, bR as ListConversationMessagesOptions, bS as ListConversationMessagesResponse, ck as ListConversationNotesOptions, cl as ListConversationNotesResponse, bh as ListConversationOptions, bf as ListConversationsIncludeOptions, bi as ListConversationsResponse, aV as ListLabelContactsOptions, aW as ListLabelContactsResponse, bj as ListLabelConversationsOptions, bk as ListLabelConversationsResponse, bB as ListLabelsIncludeOptions, bC as ListLabelsOptions, bD as ListLabelsResponse, bT as ListMessagesIncludeOptions, bU as ListMessagesOptions, bV as ListMessagesResponse, c6 as ListModelsOptions, c7 as ListModelsResponse, ct as ListSourcesOptions, cu as ListSourcesResponse, d0 as ListWebhookSubscriptionsOptions, d1 as ListWebhookSubscriptionsResponse, bH as Message, cQ as MessageEventType, bW as MessageID, bX as MessageRole, bY as MessageStatus, al as MetaWhatsappChannelGetBusinessProfileOptions, am as MetaWhatsappChannelGetBusinessProfileResponse, bZ as Model, c8 as ModelID, c9 as Note, cm as NoteID, cw as NotificationSubscription, cA as NotificationSubscriptionID, O as Options, R as RequestFilterable, S as SortOptions, cq as Source, cv as SourceID, d2 as TestWebhookSubscriptionOptions, d3 as TestWebhookSubscriptionResponse, a as TransportOptions, an as TwilioSendChannelSyncPayload, ao as TwilioSendgridChannelSyncOptions, ap as TwilioSendgridChannelSyncResponse, y as UpdateAccountConversationSettingsOptions, x as UpdateAccountConversationSettingsPayload, z as UpdateAccountConversationSettingsResponse, i as UpdateAccountOptions, U as UpdateAccountPayload, j as UpdateAccountResponse, aa as UpdateBoilerplateCategoryOptions, a9 as UpdateBoilerplateCategoryPayload, ab as UpdateBoilerplateCategoryResponse, Z as UpdateBoilerplateContentOptions, Y as UpdateBoilerplateContentPayload, _ as UpdateBoilerplateContentResponse, ar as UpdateChannelOptions, aq as UpdateChannelPayload, as as UpdateChannelResponse, aF as UpdateCompositionSectionOptions, aE as UpdateCompositionSectionPayload, aG as UpdateCompositionSectionResponse, aY as UpdateContactOptions, aX as UpdateContactPayload, aZ as UpdateContactResponse, bm as UpdateConversationOptions, bl as UpdateConversationPayload, bn as UpdateConversationResponse, bF as UpdateLabelOptions, bE as UpdateLabelPayload, bG as UpdateLabelResponse, co as UpdateNoteOptions, cn as UpdateNotePayload, cp as UpdateNoteResponse, cB as Upload, cI as UploadID, cS as WebhookEventPayload, cL as WebhookEventType, cT as WebhookResponse, cU as WebhookSubscription, cR as WebhookSubscriptionEventType, d4 as WebhookSubscriptionID, C as default, cK as eventWebhookSchema } from './Client-
|
|
2
|
-
import 'ky';
|
|
1
|
+
export { A as Account, k as AccountAccessToken, cN as AccountAccessTokenEventType, l as AccountAccessTokenID, u as AccountConversationSettings, b as AccountID, cM as AccountWebhookEventType, B as Action, E as ActionID, b0 as ActiveConversationStatus, $ as BoilerplateCategory, a0 as BoilerplateCategoryID, I as BoilerplateContent, J as BoilerplateContentID, ac as Channel, ad as ChannelID, C as Client, at as CompositionSection, au as CompositionSectionID, b1 as ConcludedConversationStatus, aH as Contact, cO as ContactEventType, aI as ContactID, a_ as Conversation, cP as ConversationEventType, a$ as ConversationID, b2 as ConversationStatus, n as CreateAccountAccessTokenOptions, m as CreateAccountAccessTokenPayload, o as CreateAccountAccessTokenResponse, d as CreateAccountOptions, c as CreateAccountPayload, e as CreateAccountResponse, a2 as CreateBoilerplateCategoryOptions, a1 as CreateBoilerplateCategoryPayload, a3 as CreateBoilerplateCategoryResponse, M as CreateBoilerplateContentOptions, K as CreateBoilerplateContentPayload, N as CreateBoilerplateContentResponse, af as CreateChannelOptions, ae as CreateChannelPayload, ag as CreateChannelResponse, aw as CreateCompositionSectionOptions, av as CreateCompositionSectionPayload, ax as CreateCompositionSectionResponse, cb as CreateContactNoteOptions, ca as CreateContactNotePayload, cc as CreateContactNoteResponse, cy as CreateContactNotificationSubscriptionOptions, cx as CreateContactNotificationSubscriptionPayload, cz as CreateContactNotificationSubscriptionResponse, aL as CreateContactOptions, aK as CreateContactPayload, aM as CreateContactResponse, ce as CreateConversationNoteOptions, cd as CreateConversationNotePayload, cf as CreateConversationNoteResponse, b4 as CreateConversationOptions, b3 as CreateConversationPayload, b5 as CreateConversationResponse, b$ as CreateCorrectionModelOptions, b_ as CreateCorrectionModelPayload, c0 as CreateCorrectionResponse, bq as CreateLabelOptions, bp as CreateLabelPayload, br as CreateLabelResponse, bJ as CreateMessageOptions, bI as CreateMessagePayload, bK as CreateMessageResponse, c2 as CreateResponseModelOptions, c1 as CreateResponseModelPayload, c3 as CreateResponseResponse, cC as CreateUploadOptions, cD as CreateUploadResponse, cW as CreateWebhookSubscriptionOptions, cV as CreateWebhookSubscriptionPayload, cX as CreateWebhookSubscriptionResponse, aJ as CustomMetadata, p as DeleteAccountAccessTokenOptions, D as DeleteAccountAccessTokenPayload, q as DeleteAccountAccessTokenResponse, aN as DeleteContactOptions, aO as DeleteContactResponse, b6 as DeleteConversationOptions, b7 as DeleteConversationResponse, bs as DeleteLabelOptions, bt as DeleteLabelResponse, bL as DeleteMessageOptions, bM as DeleteMessageResponse, cE as DeleteUploadOptions, cF as DeleteUploadResponse, cY as DeleteWebhookSubscriptionOptions, cZ as DeleteWebhookSubscriptionResponse, cJ as EventWebhookOptions, bg as FilterOptions, r as GetAccountAccessTokenOptions, s as GetAccountAccessTokenResponse, v as GetAccountConversationSettingsOptions, w as GetAccountConversationSettingsResponse, G as GetAccountOptions, f as GetAccountResponse, a4 as GetBoilerplateCategoryOptions, a5 as GetBoilerplateCategoryResponse, P as GetBoilerplateContentOptions, Q as GetBoilerplateContentResponse, ah as GetChannelOptions, ai as GetChannelResponse, ay as GetCompositionSectionOptions, az as GetCompositionSectionResponse, aP as GetContactIncludeOptions, aQ as GetContactOptions, aR as GetContactResponse, aS as GetContactVCFOptions, b8 as GetConversationIncludeOptions, b9 as GetConversationOptions, ba as GetConversationResponse, g as GetCurrentAccountOptions, h as GetCurrentAccountResponse, bu as GetLabelOptions, bv as GetLabelResponse, c4 as GetModelOptions, c5 as GetModelResponse, cg as GetNoteOptions, ch as GetNoteResponse, d5 as GetNotificationWellKnownResponse, cr as GetSourceOptions, cs as GetSourceResponse, cG as GetUploadOptions, cH as GetUploadResponse, c_ as GetWebhookSubscriptionOptions, c$ as GetWebhookSubscriptionResponse, bo as Label, bw as LabelID, L as ListAccountAccessTokensOptions, t as ListAccountAccessTokensResponse, F as ListActionsOptions, H as ListActionsResponse, a6 as ListBoilerplateCategoriesIncludeOptions, a7 as ListBoilerplateCategoriesOptions, a8 as ListBoilerplateCategoriesResponse, T as ListBoilerplateCategoryBoilerplateContentsOptions, V as ListBoilerplateCategoryBoilerplateContentsResponse, W as ListBoilerplateContentsOptions, X as ListBoilerplateContentsResponse, aA as ListChannelCompositionSectionsOptions, aB as ListChannelCompositionSectionsResponse, bb as ListChannelConversationsOptions, bc as ListChannelConversationsResponse, bN as ListChannelMessagesIncludeOptions, bO as ListChannelMessagesOptions, bP as ListChannelMessagesResponse, aj as ListChannelsOptions, ak as ListChannelsResponse, aC as ListCompositionSectionsOptions, aD as ListCompositionSectionsResponse, bd as ListContactConversationsOptions, be as ListContactConversationsResponse, bx as ListContactLabelsOptions, by as ListContactLabelsResponse, ci as ListContactNotesOptions, cj as ListContactNotesResponse, aT as ListContactsOptions, aU as ListContactsResponse, bz as ListConversationLabelsOptions, bA as ListConversationLabelsResponse, bQ as ListConversationMessagesIncludeOptions, bR as ListConversationMessagesOptions, bS as ListConversationMessagesResponse, ck as ListConversationNotesOptions, cl as ListConversationNotesResponse, bh as ListConversationOptions, bf as ListConversationsIncludeOptions, bi as ListConversationsResponse, aV as ListLabelContactsOptions, aW as ListLabelContactsResponse, bj as ListLabelConversationsOptions, bk as ListLabelConversationsResponse, bB as ListLabelsIncludeOptions, bC as ListLabelsOptions, bD as ListLabelsResponse, bT as ListMessagesIncludeOptions, bU as ListMessagesOptions, bV as ListMessagesResponse, c6 as ListModelsOptions, c7 as ListModelsResponse, ct as ListSourcesOptions, cu as ListSourcesResponse, d0 as ListWebhookSubscriptionsOptions, d1 as ListWebhookSubscriptionsResponse, bH as Message, cQ as MessageEventType, bW as MessageID, bX as MessageRole, bY as MessageStatus, al as MetaWhatsappChannelGetBusinessProfileOptions, am as MetaWhatsappChannelGetBusinessProfileResponse, bZ as Model, c8 as ModelID, c9 as Note, cm as NoteID, cw as NotificationSubscription, cA as NotificationSubscriptionID, O as Options, R as RequestFilterable, S as SortOptions, cq as Source, cv as SourceID, d2 as TestWebhookSubscriptionOptions, d3 as TestWebhookSubscriptionResponse, a as TransportOptions, an as TwilioSendChannelSyncPayload, ao as TwilioSendgridChannelSyncOptions, ap as TwilioSendgridChannelSyncResponse, y as UpdateAccountConversationSettingsOptions, x as UpdateAccountConversationSettingsPayload, z as UpdateAccountConversationSettingsResponse, i as UpdateAccountOptions, U as UpdateAccountPayload, j as UpdateAccountResponse, aa as UpdateBoilerplateCategoryOptions, a9 as UpdateBoilerplateCategoryPayload, ab as UpdateBoilerplateCategoryResponse, Z as UpdateBoilerplateContentOptions, Y as UpdateBoilerplateContentPayload, _ as UpdateBoilerplateContentResponse, ar as UpdateChannelOptions, aq as UpdateChannelPayload, as as UpdateChannelResponse, aF as UpdateCompositionSectionOptions, aE as UpdateCompositionSectionPayload, aG as UpdateCompositionSectionResponse, aY as UpdateContactOptions, aX as UpdateContactPayload, aZ as UpdateContactResponse, bm as UpdateConversationOptions, bl as UpdateConversationPayload, bn as UpdateConversationResponse, bF as UpdateLabelOptions, bE as UpdateLabelPayload, bG as UpdateLabelResponse, co as UpdateNoteOptions, cn as UpdateNotePayload, cp as UpdateNoteResponse, cB as Upload, cI as UploadID, cS as WebhookEventPayload, cL as WebhookEventType, cT as WebhookResponse, cU as WebhookSubscription, cR as WebhookSubscriptionEventType, d4 as WebhookSubscriptionID, C as default, cK as eventWebhookSchema } from './Client-BzMax1jd.js';
|
|
2
|
+
import { KyResponse } from 'ky';
|
|
3
3
|
import 'zod';
|
|
4
4
|
|
|
5
5
|
/**
|
|
@@ -17,42 +17,6 @@ import 'zod';
|
|
|
17
17
|
*/
|
|
18
18
|
declare const DEFAULT_SUPPORT_BASE_URL = "https://api.support.greatdetail.com";
|
|
19
19
|
|
|
20
|
-
/**
|
|
21
|
-
* Great Detail Support System.
|
|
22
|
-
*
|
|
23
|
-
* @copyright 2024 Great Detail Ltd
|
|
24
|
-
* @author Great Detail Ltd <info@greatdetail.com>
|
|
25
|
-
* @author Dom Webber <dom.webber@greatdetail.com>
|
|
26
|
-
* @see https://greatdetail.com
|
|
27
|
-
*/
|
|
28
|
-
declare class SupportError extends Error {
|
|
29
|
-
static serverError(status: number): SupportError;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* Great Detail Support System.
|
|
34
|
-
*
|
|
35
|
-
* @copyright 2024 Great Detail Ltd
|
|
36
|
-
* @author Great Detail Ltd <info@greatdetail.com>
|
|
37
|
-
* @author Dom Webber <dom.webber@greatdetail.com>
|
|
38
|
-
* @see https://greatdetail.com
|
|
39
|
-
*/
|
|
40
|
-
|
|
41
|
-
declare class NetworkError extends SupportError {
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* Great Detail Support System.
|
|
46
|
-
*
|
|
47
|
-
* @copyright 2024 Great Detail Ltd
|
|
48
|
-
* @author Great Detail Ltd <info@greatdetail.com>
|
|
49
|
-
* @author Dom Webber <dom.webber@greatdetail.com>
|
|
50
|
-
* @see https://greatdetail.com
|
|
51
|
-
*/
|
|
52
|
-
|
|
53
|
-
declare class AuthError extends SupportError {
|
|
54
|
-
}
|
|
55
|
-
|
|
56
20
|
/**
|
|
57
21
|
* Great Detail Support System.
|
|
58
22
|
*
|
|
@@ -62,51 +26,18 @@ declare class AuthError extends SupportError {
|
|
|
62
26
|
* @see https://greatdetail.com
|
|
63
27
|
*/
|
|
64
28
|
|
|
65
|
-
declare class
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
/**
|
|
70
|
-
* Great Detail Support System.
|
|
71
|
-
*
|
|
72
|
-
* @copyright 2024 Great Detail Ltd
|
|
73
|
-
* @author Great Detail Ltd <info@greatdetail.com>
|
|
74
|
-
* @author Dom Webber <dom.webber@greatdetail.com>
|
|
75
|
-
* @see https://greatdetail.com
|
|
76
|
-
*/
|
|
77
|
-
|
|
78
|
-
declare class AuthorizationError extends AuthError {
|
|
79
|
-
static forbidden(): AuthorizationError;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
/**
|
|
83
|
-
* Great Detail Support System.
|
|
84
|
-
*
|
|
85
|
-
* @copyright 2024 Great Detail Ltd
|
|
86
|
-
* @author Great Detail Ltd <info@greatdetail.com>
|
|
87
|
-
* @author Dom Webber <dom.webber@greatdetail.com>
|
|
88
|
-
* @see https://greatdetail.com
|
|
89
|
-
*/
|
|
90
|
-
|
|
91
|
-
declare class ValidationError extends SupportError {
|
|
92
|
-
static badRequest(): ValidationError;
|
|
93
|
-
static unsupportedMediaType(): ValidationError;
|
|
29
|
+
declare class SupportError extends Error {
|
|
30
|
+
response: KyResponse<ErrorResponse>;
|
|
31
|
+
constructor(response: KyResponse<ErrorResponse>, cause: Error);
|
|
94
32
|
}
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
*/
|
|
104
|
-
|
|
105
|
-
declare class LogicError extends SupportError {
|
|
106
|
-
static notFound(url: string): LogicError;
|
|
107
|
-
static forbiddenMethod(method: string, url: string): LogicError;
|
|
108
|
-
static teapot(): LogicError;
|
|
109
|
-
static rateLimited(): LogicError;
|
|
33
|
+
interface ErrorResponse {
|
|
34
|
+
trace?: string;
|
|
35
|
+
errors: {
|
|
36
|
+
status?: number;
|
|
37
|
+
code?: string;
|
|
38
|
+
title: string;
|
|
39
|
+
message?: string;
|
|
40
|
+
}[];
|
|
110
41
|
}
|
|
111
42
|
|
|
112
43
|
/**
|
|
@@ -118,22 +49,11 @@ declare class LogicError extends SupportError {
|
|
|
118
49
|
* @see https://greatdetail.com
|
|
119
50
|
*/
|
|
120
51
|
|
|
121
|
-
type
|
|
122
|
-
declare const index_AuthError: typeof AuthError;
|
|
123
|
-
type index_AuthenticationError = AuthenticationError;
|
|
124
|
-
declare const index_AuthenticationError: typeof AuthenticationError;
|
|
125
|
-
type index_AuthorizationError = AuthorizationError;
|
|
126
|
-
declare const index_AuthorizationError: typeof AuthorizationError;
|
|
127
|
-
type index_LogicError = LogicError;
|
|
128
|
-
declare const index_LogicError: typeof LogicError;
|
|
129
|
-
type index_NetworkError = NetworkError;
|
|
130
|
-
declare const index_NetworkError: typeof NetworkError;
|
|
52
|
+
type index_ErrorResponse = ErrorResponse;
|
|
131
53
|
type index_SupportError = SupportError;
|
|
132
54
|
declare const index_SupportError: typeof SupportError;
|
|
133
|
-
type index_ValidationError = ValidationError;
|
|
134
|
-
declare const index_ValidationError: typeof ValidationError;
|
|
135
55
|
declare namespace index {
|
|
136
|
-
export {
|
|
56
|
+
export { type index_ErrorResponse as ErrorResponse, index_SupportError as SupportError };
|
|
137
57
|
}
|
|
138
58
|
|
|
139
59
|
export { DEFAULT_SUPPORT_BASE_URL, index as Error };
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as
|
|
1
|
+
import{a as t,c as e,d as p,e as f,f as o}from"./chunk-XYLD2NDD.js";var r={};t(r,{SupportError:()=>p});export{o as Client,e as DEFAULT_SUPPORT_BASE_URL,r as Error,o as default,f as eventWebhookSchema};
|
package/package.json
CHANGED
package/dist/chunk-H5UGWTW6.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var J=Object.defineProperty;var et=(n,t)=>{for(var e in t)J(n,e,{get:t[e],enumerable:!0})};var d=class{getHeaders(){return{}}};var j="SUPPORT_ACCESS_TOKEN",q="SUPPORT_KEY_NAME",H="SUPPORT_KEY_PASSWORD",W="SUPPORT_SIGNING_KEY",V="SUPPORT_BASE_URL";var u=class{name;#t;constructor({name:t=process.env[q],password:e=process.env[H]}={}){if(!t)throw new Error("Name option must be specified when using Basic Authentication");if(!e)throw new Error("Password option must be specified when using Basic Authentication");this.name=t,this.#t=e}getHeaders(){return{Authorization:`Basic ${btoa(this.name+":"+this.#t)}`}}};var h=class{#t;constructor({token:t=process.env[j]}={}){if(!t)throw new Error("Access Token option must be specified when using Token Authentication");this.#t=t}getHeaders(){return{Authorization:`Bearer ${this.#t}`}}};var K="https://api.support.greatdetail.com",Y={"X-Powered-By":"GDSupport/JavaScript"};import{z as p}from"zod";var z=p.object({data:p.object({event:p.object({id:p.string(),type:p.string(),payload:p.record(p.string()),createdAt:p.string().datetime()})})});var C=class{constructor(t){this._transport=t}get(t,{request:e={}}={}){return this._transport.send("v1/accounts/"+encodeURIComponent(t),{...e,method:"GET"})}getCurrent({request:t={}}){return this._transport.send("v1/accounts/current",{...t,method:"GET"})}update(t,{body:e,request:o={}}){return this._transport.send("v1/accounts/"+encodeURIComponent(t),{...o,method:"PATCH",json:e})}create({body:t,request:e={}}){return this._transport.send("v1/accounts",{...e,method:"POST",json:t})}};var f=class{constructor(t){this._transport=t}get(t,e,{request:o={}}={}){return this._transport.send("v1/accounts/"+encodeURIComponent(t)+"/access-tokens/"+encodeURIComponent(e),{...o,method:"GET"})}list(t,{request:e={}}={}){return this._transport.send("v1/accounts/"+encodeURIComponent(t)+"/access-tokens",{...e,method:"GET"})}delete(t,e,{body:o,request:s={}}={}){return this._transport.send("v1/accounts/"+encodeURIComponent(t)+"/access-tokens/"+encodeURIComponent(e),{...s,method:"DELETE",json:o})}create(t,{body:e={},request:o={}}={}){return this._transport.send("v1/accounts/"+encodeURIComponent(t)+"/access-tokens",{...o,method:"POST",json:e})}};var R=class{constructor(t){this._transport=t}get(t,{request:e={}}={}){return this._transport.send("v1/accounts/"+encodeURIComponent(t)+"/conversation-settings",{...e,method:"GET"})}update(t,{body:e,request:o={}}){return this._transport.send("v1/accounts/"+encodeURIComponent(t)+"/conversation-settings",{...o,method:"PATCH",json:e})}};var b=class{constructor(t){this._transport=t}list({limit:t,sort:e,request:o={}}={}){return this._transport.send("v1/actions",{...o,method:"GET",searchParams:[...this._transport.limitQuery(t),...this._transport.sortQuery(e)]})}};var v=class{constructor(t){this._transport=t}get(t,{request:e={}}={}){return this._transport.send("v1/boilerplates/categories/"+encodeURIComponent(t),{...e,method:"GET"})}list({limit:t,include:e,request:o={}}={}){return this._transport.send("v1/boilerplates/categories",{...o,method:"GET",searchParams:[...this._transport.limitQuery(t),...this._transport.includeQuery(e)]})}create({body:t,request:e={}}){return this._transport.send("v1/boilerplates/categories",{...e,method:"POST",json:t})}update(t,{body:e,request:o={}}){return this._transport.send("v1/boilerplates/categories/"+encodeURIComponent(t),{...o,method:"PATCH",json:e})}};var O=class{constructor(t){this._transport=t}get(t,{request:e={}}={}){return this._transport.send("v1/boilerplates/contents/"+encodeURIComponent(t),{...e,method:"GET"})}list({limit:t,query:e,request:o={}}={}){return this._transport.send("v1/boilerplates/contents",{...o,method:"GET",searchParams:[...this._transport.limitQuery(t),...this._transport.queryQuery(e)]})}listByCategory=this.listByBoilerplateCategory;listByBoilerplateCategory(t,{limit:e,request:o={}}={}){return this._transport.send("v1/boilerplates/categories/"+encodeURIComponent(t)+"/contents",{...o,method:"GET",searchParams:[...this._transport.limitQuery(e)]})}create({body:t,request:e={}}){return this._transport.send("v1/boilerplates/contents",{...e,method:"POST",json:t})}update(t,{body:e,request:o={}}){return this._transport.send("v1/boilerplates/contents/"+encodeURIComponent(t),{...o,method:"PATCH",json:e})}};var g=class{constructor(t){this._transport=t}get(t,{request:e={}}={}){return this._transport.send("v1/channels/"+encodeURIComponent(t),{...e,method:"GET"})}list({limit:t,query:e,request:o={}}={}){return this._transport.send("v1/channels",{...o,method:"GET",searchParams:[...this._transport.limitQuery(t),...this._transport.queryQuery(e)]})}update(t,{body:e,request:o={}}){return this._transport.send("v1/channels/"+encodeURIComponent(t),{...o,method:"PATCH",json:e})}create({body:t,request:e={}}){return this._transport.send("v1/channels",{...e,method:"POST",json:t})}metaWhatsappGetBusinessProfile(t,{request:e={}}={}){return this._transport.send("v1/channels/"+encodeURIComponent(t)+"/meta-whatsapp/business-profile",{...e,method:"GET"})}twilioSendgridChannelSync(t,{body:e,request:o={}}){return this._transport.send("v1/channels/"+encodeURIComponent(t)+"/twilio-sendgrid/sync",{...o,method:"POST",json:e})}};var T=class{constructor(t){this._transport=t}get(t,{request:e={}}={}){return this._transport.send("v1/composition-sections/"+encodeURIComponent(t),{...e,method:"GET"})}list({limit:t,request:e={}}={}){return this._transport.send("v1/composition-sections",{...e,method:"GET",searchParams:[...this._transport.limitQuery(t)]})}listByChannel(t,{limit:e,request:o={}}={}){return this._transport.send("v1/channels/"+encodeURIComponent(t)+"/composition-sections",{...o,method:"GET",searchParams:[...this._transport.limitQuery(e)]})}create({body:t,request:e={}}){return this._transport.send("v1/composition-sections",{...e,method:"POST",json:t})}update(t,{body:e,request:o={}}){return this._transport.send("v1/composition-sections/"+encodeURIComponent(t),{...o,method:"PATCH",json:e})}};var _=class{constructor(t){this._transport=t}get(t,{include:e,request:o={}}={}){return this._transport.send("v1/contacts/"+encodeURIComponent(t),{...o,method:"GET",searchParams:[...this._transport.includeQuery(e??{})]})}getRelativeVCFURL(t,{vcf:e={}}={}){let o=e.variant??"vcard",s=e.format??(o==="vcard"?"vcf":"json");return"v1/contacts/"+encodeURIComponent(t)+"/vcf?variant="+encodeURIComponent(o)+"&format="+encodeURIComponent(s)}getVCFURL(t,e={}){return this._transport.getURL(this.getRelativeVCFURL(t,e))}getVCF(t,e={}){return this._transport.send(this.getVCFURL(t,e),{method:"GET"})}list({limit:t,query:e,request:o={}}={}){return this._transport.send("v1/contacts",{...o,method:"GET",searchParams:[...this._transport.limitQuery(t),...this._transport.queryQuery(e)]})}listByLabel(t,{limit:e,request:o={}}={}){return this._transport.send("v1/labels/"+encodeURIComponent(t)+"/contacts",{...o,method:"GET",searchParams:[...this._transport.limitQuery(e)]})}create({body:t,request:e={}}){return this._transport.send("v1/contacts",{...e,method:"POST",json:t})}update(t,{body:e,request:o={}}){return this._transport.send("v1/contacts/"+encodeURIComponent(t),{...o,method:"PATCH",json:e})}delete(t,{request:e={}}={}){return this._transport.send("v1/contacts/"+encodeURIComponent(t),{...e,method:"DELETE"})}};var L=class{constructor(t){this._transport=t}get(t,{include:e,request:o={}}={}){return this._transport.send("v1/conversations/"+encodeURIComponent(t),{...o,method:"GET",searchParams:[...this._transport.includeQuery(e??{})]})}list({limit:t,filter:e,include:o,request:s={}}={}){return this._transport.send("v1/conversations",{...s,method:"GET",searchParams:[...this._transport.limitQuery(t),...e?[["filter",e]]:[],...this._transport.includeQuery(o??{})]})}listByLabel(t,{limit:e,request:o={}}={}){return this._transport.send("v1/labels/"+encodeURIComponent(t)+"/conversations",{...o,method:"GET",searchParams:[...this._transport.limitQuery(e)]})}listByContact(t,{limit:e,request:o={}}={}){return this._transport.send("v1/contacts/"+encodeURIComponent(t)+"/conversations",{...o,method:"GET",searchParams:[...this._transport.limitQuery(e)]})}listByChannel(t,{limit:e,request:o={}}={}){return this._transport.send("v1/channels/"+encodeURIComponent(t)+"/conversations",{...o,method:"GET",searchParams:[...this._transport.limitQuery(e)]})}create({body:t,request:e={}}){return this._transport.send("v1/conversations",{...e,method:"POST",json:t})}update(t,{body:e,request:o={}}){return this._transport.send("v1/conversations/"+encodeURIComponent(t),{...o,method:"PATCH",json:e})}delete(t,{request:e={}}={}){return this._transport.send("v1/conversations/"+encodeURIComponent(t),{...e,method:"DELETE"})}};var I=class{constructor(t){this._transport=t}get(t,{request:e={}}={}){return this._transport.send("v1/labels/"+encodeURIComponent(t),{...e,method:"GET"})}list({limit:t,query:e,include:o,request:s={}}={}){return this._transport.send("v1/labels",{...s,method:"GET",searchParams:[...this._transport.limitQuery(t),...this._transport.queryQuery(e),...this._transport.includeQuery(o??{})]})}listByContact(t,{limit:e,request:o={}}={}){return this._transport.send("v1/contacts/"+encodeURIComponent(t)+"/labels",{...o,method:"GET",searchParams:[...this._transport.limitQuery(e)]})}listByConversation(t,{limit:e,request:o={}}={}){return this._transport.send("v1/conversations/"+encodeURIComponent(t)+"/labels",{...o,method:"GET",searchParams:[...this._transport.limitQuery(e)]})}create({body:t,request:e={}}){return this._transport.send("v1/labels",{...e,method:"POST",json:t})}update(t,{body:e,request:o={}}){return this._transport.send("v1/labels/"+encodeURIComponent(t),{...o,method:"PATCH",json:e})}delete(t,{request:e={}}={}){return this._transport.send("v1/labels/"+encodeURIComponent(t),{...e,method:"DELETE"})}};var y=class{constructor(t){this._transport=t}list({limit:t,include:e,request:o={}}={}){return this._transport.send("v1/messages",{...o,method:"GET",searchParams:[...this._transport.limitQuery(t),...this._transport.includeQuery(e??{})]})}listByConversation(t,{limit:e,include:o,request:s={}}={}){return this._transport.send("v1/conversations/"+encodeURIComponent(t)+"/messages",{...s,method:"GET",searchParams:[...this._transport.limitQuery(e),...this._transport.includeQuery(o??{})]})}listByChannel(t,{limit:e,include:o,request:s={}}={}){return this._transport.send("v1/channels/"+encodeURIComponent(t)+"/messages",{...s,method:"GET",searchParams:[...this._transport.limitQuery(e),...this._transport.includeQuery(o)]})}create({body:t,request:e={}}){return this._transport.send("v1/messages",{...e,method:"POST",json:t})}delete(t,{request:e={}}={}){return this._transport.send("v1/messages/"+encodeURIComponent(t),{...e,method:"DELETE"})}};var A=class{constructor(t){this._transport=t}get(t,{request:e={}}={}){return this._transport.send("v1/models/"+encodeURIComponent(t),{...e,method:"GET"})}list({request:t={}}={}){return this._transport.send("v1/models",{...t,method:"GET"})}createResponse(t,{body:e,request:o={}}){return this._transport.send("v1/models/"+encodeURIComponent(t)+"/response",{...o,method:"POST",timeout:12e4,json:e})}createCorrection(t,{body:e,request:o={}}){return this._transport.send("v1/models/"+encodeURIComponent(t)+"/correction",{...o,method:"POST",json:e})}};var S=class{constructor(t){this._transport=t}get(t,{request:e={}}={}){return this._transport.send("v1/notes/"+encodeURIComponent(t),{...e,method:"GET"})}listByContact(t,{request:e={}}={}){return this._transport.send("v1/contacts/"+encodeURIComponent(t)+"/notes",{...e,method:"GET"})}listByConversation(t,{request:e={}}={}){return this._transport.send("v1/conversations/"+encodeURIComponent(t)+"/notes",{...e,method:"GET"})}createForContact(t,{body:e,request:o={}}){return this._transport.send("v1/contacts/"+encodeURIComponent(t)+"/notes",{...o,method:"POST",json:e})}createForConversation(t,{body:e,request:o={}}){return this._transport.send("v1/conversations/"+encodeURIComponent(t)+"/notes",{...o,method:"POST",json:e})}update(t,{body:e,request:o={}}){return this._transport.send("v1/notes/"+encodeURIComponent(t),{...o,method:"PATCH",json:e})}};var U=class{constructor(t){this._transport=t}createForContact(t,{body:e,request:o={}}){return this._transport.send("v1/contacts/"+encodeURIComponent(t)+"/notification-subscriptions",{...o,method:"POST",json:e})}};var E=class n{constructor(t=n.STANDARD_HEADERS){this._standardHeaders=t}static STANDARD_HEADERS=Y;async filter(){return{headers:this.getHeaders()}}getHeaders(){return this._standardHeaders}};var G=class{constructor(t){this._transport=t}get(t,{request:e={}}={}){return this._transport.send("v1/sources/"+encodeURIComponent(t),{...e,method:"GET"})}list({featured:t,category:e,request:o={}}={}){let s=[];if(e){let r=Array.isArray(e)?e:[e];for(let m of r)s.push(["category",m])}return t!==void 0&&s.push(["featured",String(t)]),this._transport.send("v1/sources",{...o,method:"GET",searchParams:s})}};var D=class{constructor(t){this._transport=t}getMessageFrequency({request:t={}}={}){return this._transport.send("v1/statistics/message-frequency",{...t,method:"GET"})}getChannelMessageFrequency(t,{request:e={}}={}){return this._transport.send("v1/channels/"+encodeURIComponent(t)+"/statistics/message-frequency",{...e,method:"GET"})}getModelUsage({request:t={}}={}){return this._transport.send("v1/statistics/model-usage",{...t,method:"GET"})}};import X from"is-network-error";import Z,{HTTPError as tt}from"ky";var i=class extends Error{static serverError(t){return new this("Server Error: "+t)}};var c=class extends i{};var w=class extends c{static unauthenticated(){return new this("An unauthenticated request occurred")}};var k=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 P=class extends i{};var l=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=Z.create({prefixUrl:this.options.baseURL,timeout:12e3,hooks:{beforeRequest:[o=>{for(let s of this.options.requestFilterables){let r=s.getHeaders();for(let[m,$]of Object.entries(r))o.headers.has(m)||o.headers.set(m,$)}}]}})}getURL(t){return new URL(t,this.options.baseURL).toString()}sortQuery(t){let e=[];if(t===void 0)return e;for(let[o,s]of Object.entries(t))s!==void 0&&e.push(["sort",s+o]);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 o of Object.keys(t))e.push(["include",o]);return e}queryQuery(t){let e=[];return t===void 0||e.push(["query",t]),e}send(t,e={}){let o=this.client(t,e).catch(s=>{if(X(s))throw new P("A network error occurred",{cause:s});if(s instanceof tt){let r=s.response.status;switch(console.error(JSON.stringify(s.response)),r){case 400:throw l.badRequest();case 401:throw w.unauthenticated();case 403:throw k.forbidden();case 404:throw a.notFound(t);case 405:throw a.forbiddenMethod(t,e.method??"GET");case 415:throw l.unsupportedMediaType();case 418:throw a.teapot();case 429:throw a.rateLimited()}if(r>=500&&r<600)throw i.serverError(r)}throw s});return{response:()=>o,json:async()=>(await o).json()}}};var x=class{constructor(t){this._transport=t}get(t,{request:e={}}={}){return this._transport.send("v1/uploads/"+encodeURIComponent(t),{...e,method:"GET"})}create({account:t,files:e,request:o={}}){let s=new FormData;for(let r of e)s.append("file",r);return this._transport.send("v1/uploads",{...o,method:"POST",body:s,searchParams:{account:t}})}delete(t,{request:e={}}={}){return this._transport.send("v1/uploads/"+encodeURIComponent(t),{...e,method:"DELETE"})}};var M=class{constructor(t){this._transport=t}async event({key:t=process.env[W],maxSignatures:e=3,request:o}){let s=o.headers["gds-signature"];if(t!==!1){if(t===void 0)throw new Error("Missing webhook signing key in process.env."+W);if(!s)throw new Error("Missing signature header");if(!this._verifySignature(t,o.body,Array.isArray(s)?s.slice(0,e):[s]))throw new Error("Untrusted signature")}let{data:r}=z.parse(o.body);return{event:r.event}}async _verifySignature(t,e,o){let s=await crypto.subtle.importKey("raw",new TextEncoder().encode(t),{name:"HMAC",hash:"SHA-256"},!1,["sign","verify"]);for(let r of o)if(await crypto.subtle.verify("HMAC",s,new TextEncoder().encode(atob(r)),new TextEncoder().encode(JSON.stringify(e))))return!0;return!1}};var F=class{constructor(t){this._transport=t}get(t,{request:e={}}={}){return this._transport.send("v1/webhooks/subscriptions/"+encodeURIComponent(t),{...e,method:"GET"})}list({request:t={}}={}){return this._transport.send("v1/webhooks/subscriptions",{...t,method:"GET"})}test(t,{request:e={}}={}){return this._transport.send("v1/webhooks/subscriptions/"+encodeURIComponent(t)+"/test",{...e,method:"POST"})}create({body:t,request:e={}}){return this._transport.send("v1/webhooks/subscriptions",{...e,method:"POST",json:t})}delete(t,{request:e={}}={}){return this._transport.send("v1/webhooks/subscriptions/"+encodeURIComponent(t),{...e,method:"DELETE"})}};var N=class{constructor(t){this._transport=t}getNotifications({request:t={}}={}){return this._transport.send(".well-known/notifications",{...t,method:"GET"})}};var Q=class n{static DEFAULT_BASE_URL=K;static PublicAuthentication=d;static BasicAuthentication=u;static BearerAuthentication=h;_transport;account;accountAccessToken;accountConversationSettings;action;boilerplateCategory;boilerplateContent;channel;compositionSection;contact;conversation;label;message;model;note;notificationSubscription;source;statistics;upload;webhook;webhookSubscription;wellKnown;constructor(t,{baseURL:e,...o}={}){this._transport=new B({requestFilterables:[new E,t],...o,baseURL:e?.toString()??n.getBaseURL()}),this.account=new C(this._transport),this.accountAccessToken=new f(this._transport),this.accountConversationSettings=new R(this._transport),this.action=new b(this._transport),this.boilerplateCategory=new v(this._transport),this.boilerplateContent=new O(this._transport),this.channel=new g(this._transport),this.compositionSection=new T(this._transport),this.contact=new _(this._transport),this.conversation=new L(this._transport),this.label=new I(this._transport),this.message=new y(this._transport),this.model=new A(this._transport),this.note=new S(this._transport),this.notificationSubscription=new U(this._transport),this.source=new G(this._transport),this.statistics=new D(this._transport),this.upload=new x(this._transport),this.webhook=new M(this._transport),this.webhookSubscription=new F(this._transport),this.wellKnown=new N(this._transport)}static getBaseURL(){return process.env[V]??this.DEFAULT_BASE_URL}};export{et as a,d as b,K as c,i as d,c as e,w as f,k as g,a as h,P as i,l as j,z as k,Q as l};
|