@great-detail/support-sdk 0.5.2 → 0.5.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
1
  import * as ky from 'ky';
2
- import { KyInstance, Options as Options$R } from 'ky';
2
+ import { KyInstance, Options as Options$W } from 'ky';
3
3
  import { z } from 'zod';
4
4
 
5
5
  /**
@@ -29,28 +29,28 @@ interface RequestFilterable {
29
29
  * @see https://greatdetail.com
30
30
  */
31
31
 
32
- interface Options$Q {
32
+ interface Options$V {
33
33
  requestFilterables: RequestFilterable[];
34
34
  }
35
35
  interface Transport {
36
36
  getURL(url: string): string;
37
37
  }
38
38
 
39
- interface InputOptions extends Options$Q {
39
+ interface InputOptions extends Options$V {
40
40
  baseURL: string;
41
41
  }
42
- interface Options$P extends Options$Q {
42
+ interface Options$U extends Options$V {
43
43
  baseURL: string;
44
44
  }
45
45
  declare class FetchTransport implements Transport {
46
46
  client: KyInstance;
47
- options: Options$P;
47
+ options: Options$U;
48
48
  constructor({ baseURL, ...options }: InputOptions);
49
49
  getURL(url: string): string;
50
- send<T = unknown>(url: string, request: Options$R): Promise<ky.KyResponse<T>>;
50
+ send<T = unknown>(url: string, request: Options$W): Promise<ky.KyResponse<T>>;
51
51
  }
52
52
 
53
- interface Options$O {
53
+ interface Options$T {
54
54
  request?: RequestInit;
55
55
  }
56
56
  type ListActionsResponse = {
@@ -70,7 +70,7 @@ type ListActionsResponse = {
70
70
  declare class ListActions {
71
71
  protected _transport: FetchTransport;
72
72
  constructor(_transport: FetchTransport);
73
- send({ request }?: Options$O): Promise<ky.KyResponse<ListActionsResponse>>;
73
+ send({ request }?: Options$T): Promise<ky.KyResponse<ListActionsResponse>>;
74
74
  }
75
75
 
76
76
  /**
@@ -84,7 +84,7 @@ declare class ListActions {
84
84
 
85
85
  type Authentication = RequestFilterable;
86
86
 
87
- interface Options$N {
87
+ interface Options$S {
88
88
  id: string;
89
89
  body: z.infer<typeof CreateBoilerplateCategoryBoilerplate.SCHEMA>;
90
90
  request?: RequestInit;
@@ -115,10 +115,10 @@ declare class CreateBoilerplateCategoryBoilerplate {
115
115
  account: string;
116
116
  }>;
117
117
  constructor(_transport: FetchTransport);
118
- send({ id, body, request }: Options$N): Promise<ky.KyResponse<CreateBoilerplateCategoryBoilerplateResponse>>;
118
+ send({ id, body, request }: Options$S): Promise<ky.KyResponse<CreateBoilerplateCategoryBoilerplateResponse>>;
119
119
  }
120
120
 
121
- interface Options$M {
121
+ interface Options$R {
122
122
  id: string;
123
123
  request?: RequestInit;
124
124
  }
@@ -136,17 +136,17 @@ type GetBoilerplateResponse = {
136
136
  declare class GetBoilerplate {
137
137
  protected _transport: FetchTransport;
138
138
  constructor(_transport: FetchTransport);
139
- send({ id, request }: Options$M): Promise<ky.KyResponse<GetBoilerplateResponse>>;
139
+ send({ id, request }: Options$R): Promise<ky.KyResponse<GetBoilerplateResponse>>;
140
140
  }
141
141
 
142
- interface Options$L {
142
+ interface Options$Q {
143
143
  id: string;
144
144
  request?: RequestInit;
145
145
  }
146
146
  declare class ListBoilerplateCategoryBoilerplates {
147
147
  protected _transport: FetchTransport;
148
148
  constructor(_transport: FetchTransport);
149
- send({ id, request }: Options$L): Promise<ky.KyResponse<ListBoilerplateCategoryBoilerplatesResponse>>;
149
+ send({ id, request }: Options$Q): Promise<ky.KyResponse<ListBoilerplateCategoryBoilerplatesResponse>>;
150
150
  }
151
151
  type ListBoilerplateCategoryBoilerplatesResponse = {
152
152
  boilerplates: {
@@ -160,7 +160,7 @@ type ListBoilerplateCategoryBoilerplatesResponse = {
160
160
  }[];
161
161
  };
162
162
 
163
- interface Options$K {
163
+ interface Options$P {
164
164
  query?: string;
165
165
  request?: RequestInit;
166
166
  }
@@ -178,10 +178,10 @@ type ListBoilerplatesResponse = {
178
178
  declare class ListBoilerplates {
179
179
  protected _transport: FetchTransport;
180
180
  constructor(_transport: FetchTransport);
181
- send({ query, request }?: Options$K): Promise<ky.KyResponse<ListBoilerplatesResponse>>;
181
+ send({ query, request }?: Options$P): Promise<ky.KyResponse<ListBoilerplatesResponse>>;
182
182
  }
183
183
 
184
- interface Options$J {
184
+ interface Options$O {
185
185
  id: string;
186
186
  body: z.infer<typeof UpdateBoilerplate.SCHEMA>;
187
187
  request?: RequestInit;
@@ -210,10 +210,10 @@ declare class UpdateBoilerplate {
210
210
  content?: string | undefined;
211
211
  }>;
212
212
  constructor(_transport: FetchTransport);
213
- send({ id, body, request }: Options$J): Promise<ky.KyResponse<UpdateBoilerplateResponse>>;
213
+ send({ id, body, request }: Options$O): Promise<ky.KyResponse<UpdateBoilerplateResponse>>;
214
214
  }
215
215
 
216
- interface Options$I {
216
+ interface Options$N {
217
217
  body: z.infer<typeof CreateBoilerplateCategory.SCHEMA>;
218
218
  request?: RequestInit;
219
219
  }
@@ -243,10 +243,10 @@ declare class CreateBoilerplateCategory {
243
243
  description?: string | undefined;
244
244
  }>;
245
245
  constructor(_transport: FetchTransport);
246
- send({ body, request }: Options$I): Promise<ky.KyResponse<CreateBoilerplateCategoryResponse>>;
246
+ send({ body, request }: Options$N): Promise<ky.KyResponse<CreateBoilerplateCategoryResponse>>;
247
247
  }
248
248
 
249
- interface Options$H {
249
+ interface Options$M {
250
250
  id: string;
251
251
  request?: RequestInit;
252
252
  }
@@ -263,10 +263,10 @@ type GetBoilerplateCategoryResponse = {
263
263
  declare class GetBoilerplateCategory {
264
264
  protected _transport: FetchTransport;
265
265
  constructor(_transport: FetchTransport);
266
- send({ id, request }: Options$H): Promise<ky.KyResponse<GetBoilerplateCategoryResponse>>;
266
+ send({ id, request }: Options$M): Promise<ky.KyResponse<GetBoilerplateCategoryResponse>>;
267
267
  }
268
268
 
269
- interface Options$G {
269
+ interface Options$L {
270
270
  request?: RequestInit;
271
271
  }
272
272
  type ListBoilerplateCategoriesResponse = {
@@ -282,10 +282,10 @@ type ListBoilerplateCategoriesResponse = {
282
282
  declare class ListBoilerplateCategories {
283
283
  protected _transport: FetchTransport;
284
284
  constructor(_transport: FetchTransport);
285
- send({ request }?: Options$G): Promise<ky.KyResponse<ListBoilerplateCategoriesResponse>>;
285
+ send({ request }?: Options$L): Promise<ky.KyResponse<ListBoilerplateCategoriesResponse>>;
286
286
  }
287
287
 
288
- interface Options$F {
288
+ interface Options$K {
289
289
  id: string;
290
290
  body: z.infer<typeof UpdateBoilerplateCategory.SCHEMA>;
291
291
  request?: RequestInit;
@@ -313,10 +313,10 @@ declare class UpdateBoilerplateCategory {
313
313
  description?: string | undefined;
314
314
  }>;
315
315
  constructor(_transport: FetchTransport);
316
- send({ id, body, request }: Options$F): Promise<ky.KyResponse<UpdateBoilerplateCategoryResponse>>;
316
+ send({ id, body, request }: Options$K): Promise<ky.KyResponse<UpdateBoilerplateCategoryResponse>>;
317
317
  }
318
318
 
319
- interface Options$E {
319
+ interface Options$J {
320
320
  body: z.infer<typeof CreateChannel.SCHEMA>;
321
321
  request?: RequestInit;
322
322
  }
@@ -411,10 +411,10 @@ declare class CreateChannel {
411
411
  };
412
412
  }>]>>;
413
413
  constructor(_transport: FetchTransport);
414
- send({ body, request }: Options$E): Promise<ky.KyResponse<CreateChannelResponse>>;
414
+ send({ body, request }: Options$J): Promise<ky.KyResponse<CreateChannelResponse>>;
415
415
  }
416
416
 
417
- interface Options$D {
417
+ interface Options$I {
418
418
  id: string;
419
419
  request?: RequestInit;
420
420
  }
@@ -454,10 +454,10 @@ type GetChannelResponse = {
454
454
  declare class GetChannel {
455
455
  protected _transport: FetchTransport;
456
456
  constructor(_transport: FetchTransport);
457
- send({ id, request }: Options$D): Promise<ky.KyResponse<GetChannelResponse>>;
457
+ send({ id, request }: Options$I): Promise<ky.KyResponse<GetChannelResponse>>;
458
458
  }
459
459
 
460
- interface Options$C {
460
+ interface Options$H {
461
461
  request?: RequestInit;
462
462
  }
463
463
  type ListChannelsResponse = {
@@ -496,10 +496,10 @@ type ListChannelsResponse = {
496
496
  declare class ListChannels {
497
497
  protected _transport: FetchTransport;
498
498
  constructor(_transport: FetchTransport);
499
- send({ request }?: Options$C): Promise<ky.KyResponse<ListChannelsResponse>>;
499
+ send({ request }?: Options$H): Promise<ky.KyResponse<ListChannelsResponse>>;
500
500
  }
501
501
 
502
- interface Options$B {
502
+ interface Options$G {
503
503
  id: string;
504
504
  body: z.infer<typeof UpdateChannel.SCHEMA>;
505
505
  request?: RequestInit;
@@ -592,7 +592,135 @@ declare class UpdateChannel {
592
592
  };
593
593
  }>]>>;
594
594
  constructor(_transport: FetchTransport);
595
- send({ id, body, request }: Options$B): Promise<ky.KyResponse<UpdateChannelResponse>>;
595
+ send({ id, body, request }: Options$G): Promise<ky.KyResponse<UpdateChannelResponse>>;
596
+ }
597
+
598
+ interface Options$F {
599
+ body: z.infer<typeof CreateCompositionSection.SCHEMA>;
600
+ request?: RequestInit;
601
+ }
602
+ type CreateCompositionSectionResponse = {
603
+ compositionSection: {
604
+ id: string;
605
+ account: string;
606
+ channel?: string;
607
+ location: "header" | "footer";
608
+ content: string;
609
+ createdAt: string;
610
+ updatedAt: string;
611
+ };
612
+ };
613
+ declare class CreateCompositionSection {
614
+ protected _transport: FetchTransport;
615
+ static SCHEMA: z.ZodObject<{
616
+ account: z.ZodString;
617
+ channel: z.ZodOptional<z.ZodString>;
618
+ location: z.ZodEnum<["header", "footer"]>;
619
+ content: z.ZodString;
620
+ }, "strip", z.ZodTypeAny, {
621
+ content: string;
622
+ account: string;
623
+ location: "header" | "footer";
624
+ channel?: string | undefined;
625
+ }, {
626
+ content: string;
627
+ account: string;
628
+ location: "header" | "footer";
629
+ channel?: string | undefined;
630
+ }>;
631
+ constructor(_transport: FetchTransport);
632
+ send({ body, request }: Options$F): Promise<ky.KyResponse<CreateCompositionSectionResponse>>;
633
+ }
634
+
635
+ interface Options$E {
636
+ id: string;
637
+ request?: RequestInit;
638
+ }
639
+ type GetCompositionSectionResponse = {
640
+ compositionSection: {
641
+ id: string;
642
+ account: string;
643
+ channel?: string;
644
+ location: "header" | "footer";
645
+ content: string;
646
+ createdAt: string;
647
+ updatedAt: string;
648
+ };
649
+ };
650
+ declare class GetCompositionSection {
651
+ protected _transport: FetchTransport;
652
+ constructor(_transport: FetchTransport);
653
+ send({ id, request }: Options$E): Promise<ky.KyResponse<GetCompositionSectionResponse>>;
654
+ }
655
+
656
+ interface Options$D {
657
+ id: string;
658
+ request?: RequestInit;
659
+ }
660
+ type ListChannelCompositionSectionsResponse = {
661
+ compositionSections: {
662
+ id: string;
663
+ account: string;
664
+ channel?: string;
665
+ location: "header" | "footer";
666
+ content: string;
667
+ createdAt: string;
668
+ updatedAt: string;
669
+ }[];
670
+ };
671
+ declare class ListChannelCompositionSections {
672
+ protected _transport: FetchTransport;
673
+ constructor(_transport: FetchTransport);
674
+ send({ id, request }: Options$D): Promise<ky.KyResponse<ListChannelCompositionSectionsResponse>>;
675
+ }
676
+
677
+ interface Options$C {
678
+ request?: RequestInit;
679
+ }
680
+ type ListCompositionSectionsResponse = {
681
+ compositionSections: {
682
+ id: string;
683
+ account: string;
684
+ channel?: string;
685
+ location: "header" | "footer";
686
+ content: string;
687
+ createdAt: string;
688
+ updatedAt: string;
689
+ }[];
690
+ };
691
+ declare class ListCompositionSections {
692
+ protected _transport: FetchTransport;
693
+ constructor(_transport: FetchTransport);
694
+ send({ request }?: Options$C): Promise<ky.KyResponse<ListCompositionSectionsResponse>>;
695
+ }
696
+
697
+ interface Options$B {
698
+ id: string;
699
+ body: z.infer<typeof UpdateCompositionSection.SCHEMA>;
700
+ request?: RequestInit;
701
+ }
702
+ type UpdateCompositionSectionResponse = {
703
+ compositionSection: {
704
+ id: string;
705
+ account: string;
706
+ channel?: string;
707
+ location: "header" | "footer";
708
+ content: string;
709
+ createdAt: string;
710
+ updatedAt: string;
711
+ };
712
+ };
713
+ declare class UpdateCompositionSection {
714
+ protected _transport: FetchTransport;
715
+ static SCHEMA: z.ZodObject<{
716
+ content: z.ZodString;
717
+ }, "strip", z.ZodTypeAny, {
718
+ content: string;
719
+ }, {
720
+ content: string;
721
+ }>;
722
+ constructor(_transport: FetchTransport);
723
+ send({ id, body, request }: Options$B): Promise<ky.KyResponse<UpdateCompositionSectionResponse>>;
596
724
  }
597
725
 
598
726
  /**
@@ -1562,10 +1690,19 @@ declare class Client {
1562
1690
  list: ListChannels;
1563
1691
  update: UpdateChannel;
1564
1692
  create: CreateChannel;
1693
+ compositionSection: {
1694
+ list: ListChannelCompositionSections;
1695
+ };
1565
1696
  message: {
1566
1697
  list: ListChannelMessages;
1567
1698
  };
1568
1699
  };
1700
+ get compositionSection(): {
1701
+ get: GetCompositionSection;
1702
+ list: ListCompositionSections;
1703
+ create: CreateCompositionSection;
1704
+ update: UpdateCompositionSection;
1705
+ };
1569
1706
  get contact(): {
1570
1707
  get: GetContact;
1571
1708
  list: ListContacts;
@@ -1640,4 +1777,4 @@ declare class Client {
1640
1777
  get webhook(): Webhook;
1641
1778
  }
1642
1779
 
1643
- export { type DeleteUploadResponse as $, type Authentication as A, type ListConversationMessagesResponse as B, Client as C, type DeleteLabelResponse as D, type ListMessagesResponse as E, type ListChannelMessagesResponse as F, type GetBoilerplateResponse as G, type GetModelResponse as H, type ListModelsResponse as I, type CreateCorrectionResponse as J, type CreateResponseResponse as K, type ListActionsResponse as L, type CreateContactNoteResponse as M, type CreateConversationNoteResponse as N, type Options as O, type GetNoteResponse as P, type ListContactNotesResponse as Q, type RequestFilterable as R, type ListConversationNotesResponse as S, type UpdateNoteResponse as T, type UpdateBoilerplateResponse as U, type GetSourceResponse as V, type WebhookResponse as W, type ListSourcesResponse as X, type CreateContactNotificationSubscriptionResponse as Y, type CreateUploadResponse as Z, type GetUploadResponse as _, type Options$Q as a, type CreateBoilerplateCategoryBoilerplateResponse as b, type ListBoilerplateCategoryBoilerplatesResponse as c, type ListBoilerplatesResponse as d, type CreateBoilerplateCategoryResponse as e, type GetBoilerplateCategoryResponse as f, type ListBoilerplateCategoriesResponse as g, type UpdateBoilerplateCategoryResponse as h, type ListChannelsResponse as i, type GetChannelResponse as j, type UpdateChannelResponse as k, type CreateChannelResponse as l, type CreateContactResponse as m, type GetContactResponse as n, type ListContactsResponse as o, type ListLabelContactsResponse as p, type UpdateContactResponse as q, type GetConversationResponse as r, type ListConversationsResponse as s, type ListLabelConversationsResponse as t, type UpdateConversationResponse as u, type ListContactConversationsResponse as v, type CreateLabelResponse as w, type GetLabelResponse as x, type ListLabelsResponse as y, type UpdateLabelResponse as z };
1780
+ export { type GetSourceResponse as $, type Authentication as A, type ListContactConversationsResponse as B, Client as C, type CreateLabelResponse as D, type DeleteLabelResponse as E, type GetLabelResponse as F, type GetBoilerplateResponse as G, type ListLabelsResponse as H, type UpdateLabelResponse as I, type ListConversationMessagesResponse as J, type ListMessagesResponse as K, type ListActionsResponse as L, type ListChannelMessagesResponse as M, type GetModelResponse as N, type Options as O, type ListModelsResponse as P, type CreateCorrectionResponse as Q, type RequestFilterable as R, type CreateResponseResponse as S, type CreateContactNoteResponse as T, type UpdateBoilerplateResponse as U, type CreateConversationNoteResponse as V, type WebhookResponse as W, type GetNoteResponse as X, type ListContactNotesResponse as Y, type ListConversationNotesResponse as Z, type UpdateNoteResponse as _, type Options$V as a, type ListSourcesResponse as a0, type CreateContactNotificationSubscriptionResponse as a1, type CreateUploadResponse as a2, type GetUploadResponse as a3, type DeleteUploadResponse as a4, type CreateBoilerplateCategoryBoilerplateResponse as b, type ListBoilerplateCategoryBoilerplatesResponse as c, type ListBoilerplatesResponse as d, type CreateBoilerplateCategoryResponse as e, type GetBoilerplateCategoryResponse as f, type ListBoilerplateCategoriesResponse as g, type UpdateBoilerplateCategoryResponse as h, type ListChannelsResponse as i, type GetChannelResponse as j, type UpdateChannelResponse as k, type CreateChannelResponse as l, type GetCompositionSectionResponse as m, type ListCompositionSectionsResponse as n, type CreateCompositionSectionResponse as o, type ListChannelCompositionSectionsResponse as p, type UpdateCompositionSectionResponse as q, type CreateContactResponse as r, type GetContactResponse as s, type ListContactsResponse as t, type ListLabelContactsResponse as u, type UpdateContactResponse as v, type GetConversationResponse as w, type ListConversationsResponse as x, type ListLabelConversationsResponse as y, type UpdateConversationResponse as z };
package/dist/index.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";var $t=Object.create;var vt=Object.defineProperty;var Jt=Object.getOwnPropertyDescriptor;var Xt=Object.getOwnPropertyNames;var Qt=Object.getPrototypeOf,Zt=Object.prototype.hasOwnProperty;var Nt=(r,t)=>{for(var e in t)vt(r,e,{get:t[e],enumerable:!0})},Gt=(r,t,e,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of Xt(t))!Zt.call(r,n)&&n!==e&&vt(r,n,{get:()=>t[n],enumerable:!(s=Jt(t,n))||s.enumerable});return r};var Pt=(r,t,e)=>(e=r!=null?$t(Qt(r)):{},Gt(t||!r||!r.__esModule?vt(e,"default",{value:r,enumerable:!0}):e,r)),te=r=>Gt(vt({},"__esModule",{value:!0}),r);var ee={};Nt(ee,{Client:()=>C,DEFAULT_SUPPORT_BASE_URL:()=>St,Error:()=>Mt,KeyAuthentication:()=>Tt,PublicAuthentication:()=>Et,TokenAuthentication:()=>_t,default:()=>C});module.exports=te(ee);var St="https://api.support.greatdetail.com",zt={"X-Powered-By":"GDSupport/JavaScript"},Bt="api-key";var R=class{constructor(t){this._transport=t}async send({request:t={}}={}){return this._transport.send("v1/actions",{...t,method:"GET"})}};var y=require("zod"),x=class r{constructor(t){this._transport=t}static SCHEMA=y.z.object({title:y.z.string(),content:y.z.string(),account:y.z.string()});async send({id:t,body:e,request:s={}}){return this._transport.send("v1/boilerplate-categories/"+encodeURIComponent(t)+"/boilerplates",{...s,method:"POST",headers:{...s.headers,"Content-Type":"application/json"},json:r.SCHEMA.parse(e)})}};var T=class{constructor(t){this._transport=t}async send({id:t,request:e={}}){return this._transport.send("v1/boilerplates/"+encodeURIComponent(t),{...e,method:"GET"})}};var _=class{constructor(t){this._transport=t}async send({id:t,request:e={}}){return this._transport.send("v1/boilerplate-categories/"+encodeURIComponent(t)+"/boilerplates",{...e,method:"GET"})}};var E=class{constructor(t){this._transport=t}async send({query:t,request:e={}}={}){return this._transport.send("v1/boilerplates"+(t?"?query="+encodeURIComponent(t):""),{...e,method:"GET"})}};var Ot=require("zod"),v=class r{constructor(t){this._transport=t}static SCHEMA=Ot.z.object({title:Ot.z.string().optional(),content:Ot.z.string().optional()});async send({id:t,body:e,request:s={}}){return this._transport.send("v1/boilerplates/"+encodeURIComponent(t),{...s,method:"PATCH",headers:{...s.headers,"Content-Type":"application/json"},json:r.SCHEMA.parse(e)})}};var S=require("zod"),O=class r{constructor(t){this._transport=t}static SCHEMA=S.z.object({title:S.z.string(),description:S.z.string().optional(),account:S.z.string()});async send({body:t,request:e={}}){return this._transport.send("v1/boilerplate-categories",{...e,method:"POST",headers:{...e.headers,"Content-Type":"application/json"},json:r.SCHEMA.parse(t)})}};var w=class{constructor(t){this._transport=t}async send({id:t,request:e={}}){return this._transport.send("v1/boilerplate-categories/"+encodeURIComponent(t),{...e,method:"GET"})}};var F=class{constructor(t){this._transport=t}async send({request:t={}}={}){return this._transport.send("v1/boilerplate-categories",{...t,method:"GET"})}};var wt=require("zod"),U=class r{constructor(t){this._transport=t}static SCHEMA=wt.z.object({title:wt.z.string().optional(),description:wt.z.string().optional()});async send({id:t,body:e,request:s={}}){return this._transport.send("v1/boilerplate-categories/"+encodeURIComponent(t),{...s,method:"PATCH",headers:{...s.headers,"Content-Type":"application/json"},json:r.SCHEMA.parse(e)})}};var o=require("zod"),I=class r{constructor(t){this._transport=t}static SCHEMA=o.z.intersection(o.z.object({name:o.z.string().optional(),account:o.z.string()}),o.z.discriminatedUnion("source",[o.z.object({source:o.z.literal("meta-whatsapp")}),o.z.object({source:o.z.literal("twilio-sendgrid"),twilioSendgrid:o.z.object({displayName:o.z.string().optional(),outboundEmailAddress:o.z.string().email(),replyEmailAddress:o.z.string().optional(),inboundHostname:o.z.string(),apiKey:o.z.string()})})]));async send({body:t,request:e={}}){return this._transport.send("v1/channels",{...e,method:"POST",headers:{...e.headers,"Content-Type":"application/json"},json:r.SCHEMA.parse(t)})}};var q=class{constructor(t){this._transport=t}async send({id:t,request:e={}}){return this._transport.send("v1/channels/"+encodeURIComponent(t),{...e,method:"GET"})}};var L=class{constructor(t){this._transport=t}async send({request:t={}}={}){return this._transport.send("v1/channels",{...t,method:"GET"})}};var i=require("zod"),H=class r{constructor(t){this._transport=t}static SCHEMA=i.z.intersection(i.z.object({name:i.z.string().optional()}),i.z.discriminatedUnion("source",[i.z.object({source:i.z.literal("meta-whatsapp")}),i.z.object({source:i.z.literal("twilio-sendgrid"),twilioSendgrid:i.z.object({displayName:i.z.string().optional(),outboundEmailAddress:i.z.string().email().optional(),replyEmailAddress:i.z.string().optional(),inboundHostname:i.z.string().optional(),apiKey:i.z.string().optional()})})]));async send({id:t,body:e,request:s={}}){return this._transport.send("v1/channels/"+encodeURIComponent(t),{...s,method:"PATCH",headers:{...s.headers,"Content-Type":"application/json"},json:r.SCHEMA.parse(e)})}};var Dt="SUPPORT_ACCESS_TOKEN",kt="SUPPORT_API_KEY",Kt="SUPPORT_KEY_NAME",Vt="SUPPORT_BASE_URL";var M=class{constructor(t){this._transport=t}getRelativeURL({id:t,vcf:e={}}){let s=e.variant??"vcard",n=e.format??(e.variant==="vcard"?"vcf":"json");return"v1/contacts/"+encodeURIComponent(t)+"/vcf?variant="+encodeURIComponent(s)+"&format="+encodeURIComponent(n)}getURL(t){return this._transport.getURL(this.getRelativeURL(t))}};var f=require("zod"),j=class r{constructor(t){this._transport=t}static SCHEMA=f.z.object({name:f.z.string(),account:f.z.string(),emailAddress:f.z.string().email().optional(),telephoneNumber:f.z.string().optional()});async send({body:t,request:e={}}){return this._transport.send("v1/contacts",{...e,method:"POST",headers:{...e.headers,"Content-Type":"application/json"},json:r.SCHEMA.parse(t)})}};var N=class{constructor(t){this._transport=t}async send({id:t,request:e={}}){return this._transport.send("v1/contacts/"+encodeURIComponent(t),{...e,method:"GET"})}};var G=class{constructor(t){this._transport=t}async send({request:t={}}={}){return this._transport.send("v1/contacts",{...t,method:"GET"})}};var P=class{constructor(t){this._transport=t}async send({id:t,request:e={}}){return this._transport.send("v1/labels/"+encodeURIComponent(t)+"/contacts",{...e,method:"GET"})}};var z=require("zod"),B=class r{constructor(t){this._transport=t}static SCHEMA=z.z.object({name:z.z.string().optional(),emailAddress:z.z.string().email().optional(),telephoneNumber:z.z.string().optional()});async send({id:t,body:e,request:s={}}){return this._transport.send("v1/contacts/"+encodeURIComponent(t),{...s,method:"PATCH",headers:{...s.headers,"Content-Type":"application/json"},json:r.SCHEMA.parse(e)})}};var D=class{constructor(t){this._transport=t}async send({id:t,request:e={}}){return this._transport.send("v1/conversations/"+encodeURIComponent(t),{...e,method:"GET"})}};var k=class{constructor(t){this._transport=t}async send({id:t,request:e={}}){return this._transport.send("v1/contacts/"+encodeURIComponent(t)+"/conversations",{...e,method:"GET"})}};var K=class{constructor(t){this._transport=t}async send({filter:t,request:e={}}={}){let s=[];return t&&s.push(["filter",t]),this._transport.send("v1/conversations",{...e,method:"GET",searchParams:s})}};var V=class{constructor(t){this._transport=t}async send({id:t,request:e={}}){return this._transport.send("v1/labels/"+encodeURIComponent(t)+"/conversations",{...e,method:"GET"})}};var Ft=require("zod"),W=class r{constructor(t){this._transport=t}static SCHEMA=Ft.z.object({status:Ft.z.enum(["AwaitingContactConversationStatus","AwaitingAgentConversationStatus","ResolvedConversationStatus","ClosedConversationStatus"]).optional(),hasEnded:Ft.z.boolean().optional()});async send({id:t,body:e,request:s={}}){return this._transport.send("v1/conversations/"+encodeURIComponent(t),{...s,method:"PATCH",headers:{...s.headers,"Content-Type":"application/json"},json:r.SCHEMA.parse(e)})}};var Y=require("zod"),$=class r{constructor(t){this._transport=t}static SCHEMA=Y.z.object({title:Y.z.string(),description:Y.z.string().optional(),account:Y.z.string()});async send({body:t,request:e={}}){return this._transport.send("v1/labels",{...e,method:"POST",headers:{...e.headers,"Content-Type":"application/json"},json:r.SCHEMA.parse(t)})}};var J=class{constructor(t){this._transport=t}async send({id:t,request:e={}}){return this._transport.send("v1/labels/"+encodeURIComponent(t),{...e,method:"DELETE"})}};var X=class{constructor(t){this._transport=t}async send({id:t,request:e={}}){return this._transport.send("v1/labels/"+encodeURIComponent(t),{...e,method:"GET"})}};var Q=class{constructor(t){this._transport=t}async send({request:t={}}={}){return this._transport.send("v1/labels",{...t,method:"GET"})}};var Ut=require("zod"),Z=class r{constructor(t){this._transport=t}static SCHEMA=Ut.z.object({title:Ut.z.string().optional(),description:Ut.z.string().optional()});async send({id:t,body:e,request:s={}}){return this._transport.send("v1/labels/"+encodeURIComponent(t),{...s,method:"PATCH",headers:{...s.headers,"Content-Type":"application/json"},json:r.SCHEMA.parse(e)})}};var tt=class{constructor(t){this._transport=t}async send({id:t,request:e={}}){return this._transport.send("v1/channels/"+encodeURIComponent(t)+"/messages",{...e,method:"GET"})}};var et=class{constructor(t){this._transport=t}async send({id:t,request:e={}}){return this._transport.send("v1/conversations/"+encodeURIComponent(t)+"/messages",{...e,method:"GET"})}};var rt=class{constructor(t){this._transport=t}async send({request:t={}}={}){return this._transport.send("v1/messages",{...t,method:"GET"})}};var st=require("zod"),nt=class r{constructor(t){this._transport=t}static SCHEMA=st.z.object({input:st.z.string().max(65536),original:st.z.string().max(65536),correction:st.z.string().max(65536)});async send({id:t,body:e,request:s={}}){return this._transport.send("v1/models/"+encodeURIComponent(t)+"/correction",{...s,method:"POST",headers:{...s.headers,"Content-Type":"application/json"},json:r.SCHEMA.parse(e)})}};var ot=class{constructor(t){this._transport=t}async send({id:t,request:e={}}){return this._transport.send("v1/models/"+encodeURIComponent(t),{...e,method:"GET"})}};var it=class{constructor(t){this._transport=t}async send({request:t={}}={}){return this._transport.send("v1/models",{...t,method:"GET"})}};var at=require("zod"),pt=class r{constructor(t){this._transport=t}static SCHEMA=at.z.array(at.z.object({role:at.z.enum(["user","assistant"]),content:at.z.string().max(65536).nullable()})).min(1);async send({id:t,body:e,request:s={}}){return this._transport.send("v1/models/"+encodeURIComponent(t)+"/response",{...s,method:"POST",headers:{...s.headers,"Content-Type":"application/json"},json:r.SCHEMA.parse(e)})}};var qt=require("zod"),ct=class r{constructor(t){this._transport=t}static SCHEMA=qt.z.object({content:qt.z.string()});async send({id:t,body:e,request:s={}}){return this._transport.send("v1/contacts/"+encodeURIComponent(t)+"/notes",{...s,method:"POST",headers:{...s.headers,"Content-Type":"application/json"},json:r.SCHEMA.parse(e)})}};var Lt=require("zod"),b=class r{constructor(t){this._transport=t}static SCHEMA=Lt.z.object({content:Lt.z.string()});async send({id:t,body:e,request:s={}}){return this._transport.send("v1/conversations/"+encodeURIComponent(t)+"/notes",{...s,method:"POST",headers:{...s.headers,"Content-Type":"application/json"},json:r.SCHEMA.parse(e)})}};var dt=class{constructor(t){this._transport=t}async send({id:t,request:e={}}){return this._transport.send("v1/notes/"+encodeURIComponent(t),{...e,method:"GET"})}};var lt=class{constructor(t){this._transport=t}async send({id:t,request:e={}}){return this._transport.send("v1/contacts/"+encodeURIComponent(t)+"/notes",{...e,method:"GET"})}};var ut=class{constructor(t){this._transport=t}async send({id:t,request:e={}}){return this._transport.send("v1/conversations/"+encodeURIComponent(t)+"/notes",{...e,method:"GET"})}};var Ht=require("zod"),gt=class r{constructor(t){this._transport=t}static SCHEMA=Ht.z.object({content:Ht.z.string().optional()});async send({id:t,body:e,request:s={}}){return this._transport.send("v1/notes/"+encodeURIComponent(t),{...s,method:"PATCH",headers:{...s.headers,"Content-Type":"application/json"},json:r.SCHEMA.parse(e)})}};var d=require("zod"),mt=class r{constructor(t){this._transport=t}static SCHEMA=d.z.discriminatedUnion("type",[d.z.object({type:d.z.literal("vapid"),endpoint:d.z.string().url(),keys:d.z.object({p256dh:d.z.string(),auth:d.z.string()})})]);async send({id:t,body:e,request:s={}}){return this._transport.send("v1/contacts/"+encodeURIComponent(t)+"/notification-subscriptions",{...s,method:"POST",headers:{...s.headers,"Content-Type":"application/json"},json:r.SCHEMA.parse(e)})}};var ht=class r{constructor(t=r.STANDARD_HEADERS){this._standardHeaders=t}static STANDARD_HEADERS=zt;async filter(){return{headers:this.getHeaders()}}getHeaders(){return this._standardHeaders}};var ft=class{constructor(t){this._transport=t}async send({id:t,request:e={}}){return this._transport.send("v1/sources/"+encodeURIComponent(t),{...e,method:"GET"})}};var bt=class{constructor(t){this._transport=t}async send({category:t,request:e={}}={}){let s=[];if(t){let n=Array.isArray(t)?t:[t];for(let A of n)s.push(["category",A])}return this._transport.send("v1/sources",{...e,method:"GET",searchParams:s})}};var Wt=Pt(require("is-network-error"),1),It=Pt(require("ky"),1);var a=class extends Error{};var c=class extends a{};var u=class extends c{static unauthenticated(){return new this("An unauthenticated request occurred")}};var g=class extends c{static forbidden(){return new this("A forbidden request occurred")}};var l=class extends a{static notFound(t){return new this(`Record not found for request: ${t}`)}static forbiddenMethod(t,e){return new this(`Forbidden method for request: ${t} ${e}`)}};var m=class extends a{};var h=class extends a{static badRequest(){return new this("Bad request")}};var Ct=class{client;options;constructor({baseURL:t,...e}){this.options={...e,baseURL:t},this.client=It.default.create({prefixUrl:this.options.baseURL,hooks:{beforeRequest:[s=>{for(let n of this.options.requestFilterables){let A=n.getHeaders();for(let[jt,Yt]of Object.entries(A))s.headers.has(jt)||s.headers.set(jt,Yt)}}]}})}getURL(t){return new URL(t,this.options.baseURL).toString()}async send(t,e){return await this.client(t,e).catch(s=>{if((0,Wt.default)(s))throw new m("A network error occurred",{cause:s});if(s instanceof It.HTTPError){let n=s.response.status;switch(console.error(JSON.stringify(s.response)),n){case 400:throw h.badRequest();case 401:throw u.unauthenticated();case 403:throw g.forbidden();case 404:throw l.notFound(t);case 405:throw l.forbiddenMethod(t,e.method??"GET")}}throw s})}};var At=class{constructor(t){this._transport=t}async send({account:t,files:e,request:s={}}){let n=new FormData;for(let A of e)n.append("file",A);return this._transport.send("v1/uploads",{...s,method:"POST",body:n,searchParams:{account:t}})}};var Rt=class{constructor(t){this._transport=t}async send({id:t,request:e={}}){return this._transport.send("v1/uploads/"+encodeURIComponent(t),{...e,method:"DELETE"})}};var yt=class{constructor(t){this._transport=t}async send({id:t,request:e={}}){return this._transport.send("v1/uploads/"+encodeURIComponent(t),{...e,method:"GET"})}};var p=require("zod"),xt=class r{constructor(t){this._client=t}static SCHEMA=p.z.object({event:p.z.intersection(p.z.object({id:p.z.string(),createdAt:p.z.string().datetime()}),p.z.discriminatedUnion("type",[p.z.object({type:p.z.literal("contact.created"),contact:p.z.string()}),p.z.object({type:p.z.literal("message.created"),message:p.z.string()})]))});async event({request:t}){let{event:e}=r.SCHEMA.parse(t.body);return{event:e}}};var C=class r{static DEFAULT_BASE_URL=St;_transport;constructor(t,{baseURL:e,...s}={}){this._transport=new Ct({requestFilterables:[new ht,t],...s,baseURL:e?.toString()??r.getBaseURL()})}static getBaseURL(){return process.env[Vt]??this.DEFAULT_BASE_URL}get action(){return{list:new R(this._transport)}}get boilerplate(){return{get:new T(this._transport),list:new E(this._transport),update:new v(this._transport)}}get boilerplateCategory(){return{get:new w(this._transport),list:new F(this._transport),create:new O(this._transport),update:new U(this._transport),boilerplate:{list:new _(this._transport),create:new x(this._transport)}}}get channel(){return{get:new q(this._transport),list:new L(this._transport),update:new H(this._transport),create:new I(this._transport),message:{list:new tt(this._transport)}}}get contact(){return{get:new N(this._transport),list:new G(this._transport),update:new B(this._transport),create:new j(this._transport),conversation:{list:new k(this._transport)},note:{list:new lt(this._transport),create:new ct(this._transport)},notificationSubscription:{create:new mt(this._transport)},vcf:{get:new M(this._transport)}}}get conversation(){return{get:new D(this._transport),list:new K(this._transport),update:new W(this._transport),create:new b(this._transport),message:{list:new et(this._transport)},note:{list:new ut(this._transport),create:new b(this._transport)}}}get label(){return{create:new $(this._transport),get:new X(this._transport),list:new Q(this._transport),update:new Z(this._transport),delete:new J(this._transport),contact:{list:new P(this._transport)},conversation:{list:new V(this._transport)}}}get message(){return{list:new rt(this._transport)}}get model(){return{get:new ot(this._transport),list:new it(this._transport),response:{create:new pt(this._transport)},correction:{create:new nt(this._transport)}}}get note(){return{get:new dt(this._transport),update:new gt(this._transport)}}get source(){return{get:new ft(this._transport),list:new bt(this._transport)}}get upload(){return{get:new yt(this._transport),create:new At(this._transport),delete:new Rt(this._transport)}}get webhook(){return new xt(this)}};var Mt={};Nt(Mt,{AuthError:()=>c,AuthenticationError:()=>u,AuthorizationError:()=>g,LogicError:()=>l,NetworkError:()=>m,SupportError:()=>a,ValidationError:()=>h});var Tt=class r{static DEFAULT_NAME=Bt;name;#t;constructor({name:t=process.env[Kt]??r.DEFAULT_NAME,key:e=process.env[kt]}={}){if(!e)throw new Error("API Key option must be specified when using Key Authentication");this.name=t,this.#t=e}async filter(){return{headers:this.getHeaders()}}getHeaders(){return{Authorization:`Basic ${btoa(this.name+":"+this.#t)}`}}};var _t=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}async filter(){return{headers:this.getHeaders()}}getHeaders(){return{Authorization:`Bearer ${this.#t}`}}};var Et=class{async filter(){return{headers:this.getHeaders()}}getHeaders(){return{}}};0&&(module.exports={Client,DEFAULT_SUPPORT_BASE_URL,Error,KeyAuthentication,PublicAuthentication,TokenAuthentication});
1
+ "use strict";var re=Object.create;var It=Object.defineProperty;var se=Object.getOwnPropertyDescriptor;var ne=Object.getOwnPropertyNames;var oe=Object.getPrototypeOf,ie=Object.prototype.hasOwnProperty;var Kt=(r,t)=>{for(var e in t)It(r,e,{get:t[e],enumerable:!0})},Vt=(r,t,e,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of ne(t))!ie.call(r,n)&&n!==e&&It(r,n,{get:()=>t[n],enumerable:!(s=se(t,n))||s.enumerable});return r};var Wt=(r,t,e)=>(e=r!=null?re(oe(r)):{},Vt(t||!r||!r.__esModule?It(e,"default",{value:r,enumerable:!0}):e,r)),ae=r=>Vt(It({},"__esModule",{value:!0}),r);var pe={};Kt(pe,{Client:()=>A,DEFAULT_SUPPORT_BASE_URL:()=>qt,Error:()=>Dt,KeyAuthentication:()=>Ft,PublicAuthentication:()=>Ut,TokenAuthentication:()=>wt,default:()=>A});module.exports=ae(pe);var qt="https://api.support.greatdetail.com",Yt={"X-Powered-By":"GDSupport/JavaScript"},$t="api-key";var y=class{constructor(t){this._transport=t}async send({request:t={}}={}){return this._transport.send("v1/actions",{...t,method:"GET"})}};var x=require("zod"),T=class r{constructor(t){this._transport=t}static SCHEMA=x.z.object({title:x.z.string(),content:x.z.string(),account:x.z.string()});async send({id:t,body:e,request:s={}}){return this._transport.send("v1/boilerplate-categories/"+encodeURIComponent(t)+"/boilerplates",{...s,method:"POST",headers:{...s.headers,"Content-Type":"application/json"},json:r.SCHEMA.parse(e)})}};var _=class{constructor(t){this._transport=t}async send({id:t,request:e={}}){return this._transport.send("v1/boilerplates/"+encodeURIComponent(t),{...e,method:"GET"})}};var E=class{constructor(t){this._transport=t}async send({id:t,request:e={}}){return this._transport.send("v1/boilerplate-categories/"+encodeURIComponent(t)+"/boilerplates",{...e,method:"GET"})}};var S=class{constructor(t){this._transport=t}async send({query:t,request:e={}}={}){return this._transport.send("v1/boilerplates"+(t?"?query="+encodeURIComponent(t):""),{...e,method:"GET"})}};var Ht=require("zod"),v=class r{constructor(t){this._transport=t}static SCHEMA=Ht.z.object({title:Ht.z.string().optional(),content:Ht.z.string().optional()});async send({id:t,body:e,request:s={}}){return this._transport.send("v1/boilerplates/"+encodeURIComponent(t),{...s,method:"PATCH",headers:{...s.headers,"Content-Type":"application/json"},json:r.SCHEMA.parse(e)})}};var O=require("zod"),F=class r{constructor(t){this._transport=t}static SCHEMA=O.z.object({title:O.z.string(),description:O.z.string().optional(),account:O.z.string()});async send({body:t,request:e={}}){return this._transport.send("v1/boilerplate-categories",{...e,method:"POST",headers:{...e.headers,"Content-Type":"application/json"},json:r.SCHEMA.parse(t)})}};var w=class{constructor(t){this._transport=t}async send({id:t,request:e={}}){return this._transport.send("v1/boilerplate-categories/"+encodeURIComponent(t),{...e,method:"GET"})}};var U=class{constructor(t){this._transport=t}async send({request:t={}}={}){return this._transport.send("v1/boilerplate-categories",{...t,method:"GET"})}};var Lt=require("zod"),I=class r{constructor(t){this._transport=t}static SCHEMA=Lt.z.object({title:Lt.z.string().optional(),description:Lt.z.string().optional()});async send({id:t,body:e,request:s={}}){return this._transport.send("v1/boilerplate-categories/"+encodeURIComponent(t),{...s,method:"PATCH",headers:{...s.headers,"Content-Type":"application/json"},json:r.SCHEMA.parse(e)})}};var o=require("zod"),q=class r{constructor(t){this._transport=t}static SCHEMA=o.z.intersection(o.z.object({name:o.z.string().optional(),account:o.z.string()}),o.z.discriminatedUnion("source",[o.z.object({source:o.z.literal("meta-whatsapp")}),o.z.object({source:o.z.literal("twilio-sendgrid"),twilioSendgrid:o.z.object({displayName:o.z.string().optional(),outboundEmailAddress:o.z.string().email(),replyEmailAddress:o.z.string().optional(),inboundHostname:o.z.string(),apiKey:o.z.string()})})]));async send({body:t,request:e={}}){return this._transport.send("v1/channels",{...e,method:"POST",headers:{...e.headers,"Content-Type":"application/json"},json:r.SCHEMA.parse(t)})}};var H=class{constructor(t){this._transport=t}async send({id:t,request:e={}}){return this._transport.send("v1/channels/"+encodeURIComponent(t),{...e,method:"GET"})}};var L=class{constructor(t){this._transport=t}async send({request:t={}}={}){return this._transport.send("v1/channels",{...t,method:"GET"})}};var i=require("zod"),M=class r{constructor(t){this._transport=t}static SCHEMA=i.z.intersection(i.z.object({name:i.z.string().optional()}),i.z.discriminatedUnion("source",[i.z.object({source:i.z.literal("meta-whatsapp")}),i.z.object({source:i.z.literal("twilio-sendgrid"),twilioSendgrid:i.z.object({displayName:i.z.string().optional(),outboundEmailAddress:i.z.string().email().optional(),replyEmailAddress:i.z.string().optional(),inboundHostname:i.z.string().optional(),apiKey:i.z.string().optional()})})]));async send({id:t,body:e,request:s={}}){return this._transport.send("v1/channels/"+encodeURIComponent(t),{...s,method:"PATCH",headers:{...s.headers,"Content-Type":"application/json"},json:r.SCHEMA.parse(e)})}};var f=require("zod"),j=class r{constructor(t){this._transport=t}static SCHEMA=f.z.object({account:f.z.string(),channel:f.z.string().optional(),location:f.z.enum(["header","footer"]),content:f.z.string()});async send({body:t,request:e={}}){return this._transport.send("v1/composition-sections",{...e,method:"POST",headers:{...e.headers,"Content-Type":"application/json"},json:r.SCHEMA.parse(t)})}};var N=class{constructor(t){this._transport=t}async send({id:t,request:e={}}){return this._transport.send("v1/composition-sections/"+encodeURIComponent(t),{...e,method:"GET"})}};var G=class{constructor(t){this._transport=t}async send({id:t,request:e={}}){return this._transport.send("v1/channels/"+encodeURIComponent(t)+"/composition-sections",{...e,method:"GET"})}};var P=class{constructor(t){this._transport=t}async send({request:t={}}={}){return this._transport.send("v1/composition-sections",{...t,method:"GET"})}};var Gt=require("zod"),z=class r{constructor(t){this._transport=t}static SCHEMA=Gt.z.object({content:Gt.z.string()});async send({id:t,body:e,request:s={}}){return this._transport.send("v1/composition-sections/"+encodeURIComponent(t),{...s,method:"PATCH",headers:{...s.headers,"Content-Type":"application/json"},json:r.SCHEMA.parse(e)})}};var Jt="SUPPORT_ACCESS_TOKEN",Xt="SUPPORT_API_KEY",Qt="SUPPORT_KEY_NAME",Zt="SUPPORT_BASE_URL";var B=class{constructor(t){this._transport=t}getRelativeURL({id:t,vcf:e={}}){let s=e.variant??"vcard",n=e.format??(e.variant==="vcard"?"vcf":"json");return"v1/contacts/"+encodeURIComponent(t)+"/vcf?variant="+encodeURIComponent(s)+"&format="+encodeURIComponent(n)}getURL(t){return this._transport.getURL(this.getRelativeURL(t))}};var C=require("zod"),D=class r{constructor(t){this._transport=t}static SCHEMA=C.z.object({name:C.z.string(),account:C.z.string(),emailAddress:C.z.string().email().optional(),telephoneNumber:C.z.string().optional()});async send({body:t,request:e={}}){return this._transport.send("v1/contacts",{...e,method:"POST",headers:{...e.headers,"Content-Type":"application/json"},json:r.SCHEMA.parse(t)})}};var k=class{constructor(t){this._transport=t}async send({id:t,request:e={}}){return this._transport.send("v1/contacts/"+encodeURIComponent(t),{...e,method:"GET"})}};var K=class{constructor(t){this._transport=t}async send({request:t={}}={}){return this._transport.send("v1/contacts",{...t,method:"GET"})}};var V=class{constructor(t){this._transport=t}async send({id:t,request:e={}}){return this._transport.send("v1/labels/"+encodeURIComponent(t)+"/contacts",{...e,method:"GET"})}};var W=require("zod"),Y=class r{constructor(t){this._transport=t}static SCHEMA=W.z.object({name:W.z.string().optional(),emailAddress:W.z.string().email().optional(),telephoneNumber:W.z.string().optional()});async send({id:t,body:e,request:s={}}){return this._transport.send("v1/contacts/"+encodeURIComponent(t),{...s,method:"PATCH",headers:{...s.headers,"Content-Type":"application/json"},json:r.SCHEMA.parse(e)})}};var $=class{constructor(t){this._transport=t}async send({id:t,request:e={}}){return this._transport.send("v1/conversations/"+encodeURIComponent(t),{...e,method:"GET"})}};var J=class{constructor(t){this._transport=t}async send({id:t,request:e={}}){return this._transport.send("v1/contacts/"+encodeURIComponent(t)+"/conversations",{...e,method:"GET"})}};var X=class{constructor(t){this._transport=t}async send({filter:t,request:e={}}={}){let s=[];return t&&s.push(["filter",t]),this._transport.send("v1/conversations",{...e,method:"GET",searchParams:s})}};var Q=class{constructor(t){this._transport=t}async send({id:t,request:e={}}){return this._transport.send("v1/labels/"+encodeURIComponent(t)+"/conversations",{...e,method:"GET"})}};var Mt=require("zod"),Z=class r{constructor(t){this._transport=t}static SCHEMA=Mt.z.object({status:Mt.z.enum(["AwaitingContactConversationStatus","AwaitingAgentConversationStatus","ResolvedConversationStatus","ClosedConversationStatus"]).optional(),hasEnded:Mt.z.boolean().optional()});async send({id:t,body:e,request:s={}}){return this._transport.send("v1/conversations/"+encodeURIComponent(t),{...s,method:"PATCH",headers:{...s.headers,"Content-Type":"application/json"},json:r.SCHEMA.parse(e)})}};var tt=require("zod"),et=class r{constructor(t){this._transport=t}static SCHEMA=tt.z.object({title:tt.z.string(),description:tt.z.string().optional(),account:tt.z.string()});async send({body:t,request:e={}}){return this._transport.send("v1/labels",{...e,method:"POST",headers:{...e.headers,"Content-Type":"application/json"},json:r.SCHEMA.parse(t)})}};var rt=class{constructor(t){this._transport=t}async send({id:t,request:e={}}){return this._transport.send("v1/labels/"+encodeURIComponent(t),{...e,method:"DELETE"})}};var st=class{constructor(t){this._transport=t}async send({id:t,request:e={}}){return this._transport.send("v1/labels/"+encodeURIComponent(t),{...e,method:"GET"})}};var nt=class{constructor(t){this._transport=t}async send({request:t={}}={}){return this._transport.send("v1/labels",{...t,method:"GET"})}};var jt=require("zod"),ot=class r{constructor(t){this._transport=t}static SCHEMA=jt.z.object({title:jt.z.string().optional(),description:jt.z.string().optional()});async send({id:t,body:e,request:s={}}){return this._transport.send("v1/labels/"+encodeURIComponent(t),{...s,method:"PATCH",headers:{...s.headers,"Content-Type":"application/json"},json:r.SCHEMA.parse(e)})}};var it=class{constructor(t){this._transport=t}async send({id:t,request:e={}}){return this._transport.send("v1/channels/"+encodeURIComponent(t)+"/messages",{...e,method:"GET"})}};var at=class{constructor(t){this._transport=t}async send({id:t,request:e={}}){return this._transport.send("v1/conversations/"+encodeURIComponent(t)+"/messages",{...e,method:"GET"})}};var pt=class{constructor(t){this._transport=t}async send({request:t={}}={}){return this._transport.send("v1/messages",{...t,method:"GET"})}};var ct=require("zod"),dt=class r{constructor(t){this._transport=t}static SCHEMA=ct.z.object({input:ct.z.string().max(65536),original:ct.z.string().max(65536),correction:ct.z.string().max(65536)});async send({id:t,body:e,request:s={}}){return this._transport.send("v1/models/"+encodeURIComponent(t)+"/correction",{...s,method:"POST",headers:{...s.headers,"Content-Type":"application/json"},json:r.SCHEMA.parse(e)})}};var lt=class{constructor(t){this._transport=t}async send({id:t,request:e={}}){return this._transport.send("v1/models/"+encodeURIComponent(t),{...e,method:"GET"})}};var ut=class{constructor(t){this._transport=t}async send({request:t={}}={}){return this._transport.send("v1/models",{...t,method:"GET"})}};var gt=require("zod"),mt=class r{constructor(t){this._transport=t}static SCHEMA=gt.z.array(gt.z.object({role:gt.z.enum(["user","assistant"]),content:gt.z.string().max(65536).nullable()})).min(1);async send({id:t,body:e,request:s={}}){return this._transport.send("v1/models/"+encodeURIComponent(t)+"/response",{...s,method:"POST",headers:{...s.headers,"Content-Type":"application/json"},json:r.SCHEMA.parse(e)})}};var Pt=require("zod"),ht=class r{constructor(t){this._transport=t}static SCHEMA=Pt.z.object({content:Pt.z.string()});async send({id:t,body:e,request:s={}}){return this._transport.send("v1/contacts/"+encodeURIComponent(t)+"/notes",{...s,method:"POST",headers:{...s.headers,"Content-Type":"application/json"},json:r.SCHEMA.parse(e)})}};var zt=require("zod"),b=class r{constructor(t){this._transport=t}static SCHEMA=zt.z.object({content:zt.z.string()});async send({id:t,body:e,request:s={}}){return this._transport.send("v1/conversations/"+encodeURIComponent(t)+"/notes",{...s,method:"POST",headers:{...s.headers,"Content-Type":"application/json"},json:r.SCHEMA.parse(e)})}};var ft=class{constructor(t){this._transport=t}async send({id:t,request:e={}}){return this._transport.send("v1/notes/"+encodeURIComponent(t),{...e,method:"GET"})}};var Ct=class{constructor(t){this._transport=t}async send({id:t,request:e={}}){return this._transport.send("v1/contacts/"+encodeURIComponent(t)+"/notes",{...e,method:"GET"})}};var bt=class{constructor(t){this._transport=t}async send({id:t,request:e={}}){return this._transport.send("v1/conversations/"+encodeURIComponent(t)+"/notes",{...e,method:"GET"})}};var Bt=require("zod"),At=class r{constructor(t){this._transport=t}static SCHEMA=Bt.z.object({content:Bt.z.string().optional()});async send({id:t,body:e,request:s={}}){return this._transport.send("v1/notes/"+encodeURIComponent(t),{...s,method:"PATCH",headers:{...s.headers,"Content-Type":"application/json"},json:r.SCHEMA.parse(e)})}};var d=require("zod"),Rt=class r{constructor(t){this._transport=t}static SCHEMA=d.z.discriminatedUnion("type",[d.z.object({type:d.z.literal("vapid"),endpoint:d.z.string().url(),keys:d.z.object({p256dh:d.z.string(),auth:d.z.string()})})]);async send({id:t,body:e,request:s={}}){return this._transport.send("v1/contacts/"+encodeURIComponent(t)+"/notification-subscriptions",{...s,method:"POST",headers:{...s.headers,"Content-Type":"application/json"},json:r.SCHEMA.parse(e)})}};var yt=class r{constructor(t=r.STANDARD_HEADERS){this._standardHeaders=t}static STANDARD_HEADERS=Yt;async filter(){return{headers:this.getHeaders()}}getHeaders(){return this._standardHeaders}};var xt=class{constructor(t){this._transport=t}async send({id:t,request:e={}}){return this._transport.send("v1/sources/"+encodeURIComponent(t),{...e,method:"GET"})}};var Tt=class{constructor(t){this._transport=t}async send({category:t,request:e={}}={}){let s=[];if(t){let n=Array.isArray(t)?t:[t];for(let R of n)s.push(["category",R])}return this._transport.send("v1/sources",{...e,method:"GET",searchParams:s})}};var te=Wt(require("is-network-error"),1),Nt=Wt(require("ky"),1);var a=class extends Error{};var c=class extends a{};var u=class extends c{static unauthenticated(){return new this("An unauthenticated request occurred")}};var g=class extends c{static forbidden(){return new this("A forbidden request occurred")}};var l=class extends a{static notFound(t){return new this(`Record not found for request: ${t}`)}static forbiddenMethod(t,e){return new this(`Forbidden method for request: ${t} ${e}`)}};var m=class extends a{};var h=class extends a{static badRequest(){return new this("Bad request")}};var _t=class{client;options;constructor({baseURL:t,...e}){this.options={...e,baseURL:t},this.client=Nt.default.create({prefixUrl:this.options.baseURL,hooks:{beforeRequest:[s=>{for(let n of this.options.requestFilterables){let R=n.getHeaders();for(let[kt,ee]of Object.entries(R))s.headers.has(kt)||s.headers.set(kt,ee)}}]}})}getURL(t){return new URL(t,this.options.baseURL).toString()}async send(t,e){return await this.client(t,e).catch(s=>{if((0,te.default)(s))throw new m("A network error occurred",{cause:s});if(s instanceof Nt.HTTPError){let n=s.response.status;switch(console.error(JSON.stringify(s.response)),n){case 400:throw h.badRequest();case 401:throw u.unauthenticated();case 403:throw g.forbidden();case 404:throw l.notFound(t);case 405:throw l.forbiddenMethod(t,e.method??"GET")}}throw s})}};var Et=class{constructor(t){this._transport=t}async send({account:t,files:e,request:s={}}){let n=new FormData;for(let R of e)n.append("file",R);return this._transport.send("v1/uploads",{...s,method:"POST",body:n,searchParams:{account:t}})}};var St=class{constructor(t){this._transport=t}async send({id:t,request:e={}}){return this._transport.send("v1/uploads/"+encodeURIComponent(t),{...e,method:"DELETE"})}};var vt=class{constructor(t){this._transport=t}async send({id:t,request:e={}}){return this._transport.send("v1/uploads/"+encodeURIComponent(t),{...e,method:"GET"})}};var p=require("zod"),Ot=class r{constructor(t){this._client=t}static SCHEMA=p.z.object({event:p.z.intersection(p.z.object({id:p.z.string(),createdAt:p.z.string().datetime()}),p.z.discriminatedUnion("type",[p.z.object({type:p.z.literal("contact.created"),contact:p.z.string()}),p.z.object({type:p.z.literal("message.created"),message:p.z.string()})]))});async event({request:t}){let{event:e}=r.SCHEMA.parse(t.body);return{event:e}}};var A=class r{static DEFAULT_BASE_URL=qt;_transport;constructor(t,{baseURL:e,...s}={}){this._transport=new _t({requestFilterables:[new yt,t],...s,baseURL:e?.toString()??r.getBaseURL()})}static getBaseURL(){return process.env[Zt]??this.DEFAULT_BASE_URL}get action(){return{list:new y(this._transport)}}get boilerplate(){return{get:new _(this._transport),list:new S(this._transport),update:new v(this._transport)}}get boilerplateCategory(){return{get:new w(this._transport),list:new U(this._transport),create:new F(this._transport),update:new I(this._transport),boilerplate:{list:new E(this._transport),create:new T(this._transport)}}}get channel(){return{get:new H(this._transport),list:new L(this._transport),update:new M(this._transport),create:new q(this._transport),compositionSection:{list:new G(this._transport)},message:{list:new it(this._transport)}}}get compositionSection(){return{get:new N(this._transport),list:new P(this._transport),create:new j(this._transport),update:new z(this._transport)}}get contact(){return{get:new k(this._transport),list:new K(this._transport),update:new Y(this._transport),create:new D(this._transport),conversation:{list:new J(this._transport)},note:{list:new Ct(this._transport),create:new ht(this._transport)},notificationSubscription:{create:new Rt(this._transport)},vcf:{get:new B(this._transport)}}}get conversation(){return{get:new $(this._transport),list:new X(this._transport),update:new Z(this._transport),create:new b(this._transport),message:{list:new at(this._transport)},note:{list:new bt(this._transport),create:new b(this._transport)}}}get label(){return{create:new et(this._transport),get:new st(this._transport),list:new nt(this._transport),update:new ot(this._transport),delete:new rt(this._transport),contact:{list:new V(this._transport)},conversation:{list:new Q(this._transport)}}}get message(){return{list:new pt(this._transport)}}get model(){return{get:new lt(this._transport),list:new ut(this._transport),response:{create:new mt(this._transport)},correction:{create:new dt(this._transport)}}}get note(){return{get:new ft(this._transport),update:new At(this._transport)}}get source(){return{get:new xt(this._transport),list:new Tt(this._transport)}}get upload(){return{get:new vt(this._transport),create:new Et(this._transport),delete:new St(this._transport)}}get webhook(){return new Ot(this)}};var Dt={};Kt(Dt,{AuthError:()=>c,AuthenticationError:()=>u,AuthorizationError:()=>g,LogicError:()=>l,NetworkError:()=>m,SupportError:()=>a,ValidationError:()=>h});var Ft=class r{static DEFAULT_NAME=$t;name;#t;constructor({name:t=process.env[Qt]??r.DEFAULT_NAME,key:e=process.env[Xt]}={}){if(!e)throw new Error("API Key option must be specified when using Key Authentication");this.name=t,this.#t=e}async filter(){return{headers:this.getHeaders()}}getHeaders(){return{Authorization:`Basic ${btoa(this.name+":"+this.#t)}`}}};var wt=class{#t;constructor({token:t=process.env[Jt]}={}){if(!t)throw new Error("Access Token option must be specified when using Token Authentication");this.#t=t}async filter(){return{headers:this.getHeaders()}}getHeaders(){return{Authorization:`Bearer ${this.#t}`}}};var Ut=class{async filter(){return{headers:this.getHeaders()}}getHeaders(){return{}}};0&&(module.exports={Client,DEFAULT_SUPPORT_BASE_URL,Error,KeyAuthentication,PublicAuthentication,TokenAuthentication});
package/dist/index.d.cts CHANGED
@@ -1,5 +1,5 @@
1
- import { A as Authentication } from './index-D5mrSUtT.cjs';
2
- export { C as Client, b as CreateBoilerplateCategoryBoilerplateResponse, e as CreateBoilerplateCategoryResponse, l as CreateChannelResponse, M as CreateContactNoteResponse, Y as CreateContactNotificationSubscriptionResponse, m as CreateContactResponse, N as CreateConversationNoteResponse, J as CreateCorrectionResponse, w as CreateLabelResponse, K as CreateResponseResponse, Z as CreateUploadResponse, D as DeleteLabelResponse, $ as DeleteUploadResponse, f as GetBoilerplateCategoryResponse, G as GetBoilerplateResponse, j as GetChannelResponse, n as GetContactResponse, r as GetConversationResponse, x as GetLabelResponse, H as GetModelResponse, P as GetNoteResponse, V as GetSourceResponse, _ as GetUploadResponse, L as ListActionsResponse, g as ListBoilerplateCategoriesResponse, c as ListBoilerplateCategoryBoilerplatesResponse, d as ListBoilerplatesResponse, F as ListChannelMessagesResponse, i as ListChannelsResponse, v as ListContactConversationsResponse, Q as ListContactNotesResponse, o as ListContactsResponse, B as ListConversationMessagesResponse, S as ListConversationNotesResponse, s as ListConversationsResponse, p as ListLabelContactsResponse, t as ListLabelConversationsResponse, y as ListLabelsResponse, E as ListMessagesResponse, I as ListModelsResponse, X as ListSourcesResponse, O as Options, R as RequestFilterable, a as TransportOptions, h as UpdateBoilerplateCategoryResponse, U as UpdateBoilerplateResponse, k as UpdateChannelResponse, q as UpdateContactResponse, u as UpdateConversationResponse, z as UpdateLabelResponse, T as UpdateNoteResponse, W as WebhookResponse, C as default } from './index-D5mrSUtT.cjs';
1
+ import { A as Authentication } from './index-CWpRFEq9.cjs';
2
+ export { C as Client, b as CreateBoilerplateCategoryBoilerplateResponse, e as CreateBoilerplateCategoryResponse, l as CreateChannelResponse, o as CreateCompositionSectionResponse, T as CreateContactNoteResponse, a1 as CreateContactNotificationSubscriptionResponse, r as CreateContactResponse, V as CreateConversationNoteResponse, Q as CreateCorrectionResponse, D as CreateLabelResponse, S as CreateResponseResponse, a2 as CreateUploadResponse, E as DeleteLabelResponse, a4 as DeleteUploadResponse, f as GetBoilerplateCategoryResponse, G as GetBoilerplateResponse, j as GetChannelResponse, m as GetCompositionSectionResponse, s as GetContactResponse, w as GetConversationResponse, F as GetLabelResponse, N as GetModelResponse, X as GetNoteResponse, $ as GetSourceResponse, a3 as GetUploadResponse, L as ListActionsResponse, g as ListBoilerplateCategoriesResponse, c as ListBoilerplateCategoryBoilerplatesResponse, d as ListBoilerplatesResponse, p as ListChannelCompositionSectionsResponse, M as ListChannelMessagesResponse, i as ListChannelsResponse, n as ListCompositionSectionsResponse, B as ListContactConversationsResponse, Y as ListContactNotesResponse, t as ListContactsResponse, J as ListConversationMessagesResponse, Z as ListConversationNotesResponse, x as ListConversationsResponse, u as ListLabelContactsResponse, y as ListLabelConversationsResponse, H as ListLabelsResponse, K as ListMessagesResponse, P as ListModelsResponse, a0 as ListSourcesResponse, O as Options, R as RequestFilterable, a as TransportOptions, h as UpdateBoilerplateCategoryResponse, U as UpdateBoilerplateResponse, k as UpdateChannelResponse, q as UpdateCompositionSectionResponse, v as UpdateContactResponse, z as UpdateConversationResponse, I as UpdateLabelResponse, _ as UpdateNoteResponse, W as WebhookResponse, C as default } from './index-CWpRFEq9.cjs';
3
3
  import 'ky';
4
4
  import 'zod';
5
5
 
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { A as Authentication } from './index-D5mrSUtT.js';
2
- export { C as Client, b as CreateBoilerplateCategoryBoilerplateResponse, e as CreateBoilerplateCategoryResponse, l as CreateChannelResponse, M as CreateContactNoteResponse, Y as CreateContactNotificationSubscriptionResponse, m as CreateContactResponse, N as CreateConversationNoteResponse, J as CreateCorrectionResponse, w as CreateLabelResponse, K as CreateResponseResponse, Z as CreateUploadResponse, D as DeleteLabelResponse, $ as DeleteUploadResponse, f as GetBoilerplateCategoryResponse, G as GetBoilerplateResponse, j as GetChannelResponse, n as GetContactResponse, r as GetConversationResponse, x as GetLabelResponse, H as GetModelResponse, P as GetNoteResponse, V as GetSourceResponse, _ as GetUploadResponse, L as ListActionsResponse, g as ListBoilerplateCategoriesResponse, c as ListBoilerplateCategoryBoilerplatesResponse, d as ListBoilerplatesResponse, F as ListChannelMessagesResponse, i as ListChannelsResponse, v as ListContactConversationsResponse, Q as ListContactNotesResponse, o as ListContactsResponse, B as ListConversationMessagesResponse, S as ListConversationNotesResponse, s as ListConversationsResponse, p as ListLabelContactsResponse, t as ListLabelConversationsResponse, y as ListLabelsResponse, E as ListMessagesResponse, I as ListModelsResponse, X as ListSourcesResponse, O as Options, R as RequestFilterable, a as TransportOptions, h as UpdateBoilerplateCategoryResponse, U as UpdateBoilerplateResponse, k as UpdateChannelResponse, q as UpdateContactResponse, u as UpdateConversationResponse, z as UpdateLabelResponse, T as UpdateNoteResponse, W as WebhookResponse, C as default } from './index-D5mrSUtT.js';
1
+ import { A as Authentication } from './index-CWpRFEq9.js';
2
+ export { C as Client, b as CreateBoilerplateCategoryBoilerplateResponse, e as CreateBoilerplateCategoryResponse, l as CreateChannelResponse, o as CreateCompositionSectionResponse, T as CreateContactNoteResponse, a1 as CreateContactNotificationSubscriptionResponse, r as CreateContactResponse, V as CreateConversationNoteResponse, Q as CreateCorrectionResponse, D as CreateLabelResponse, S as CreateResponseResponse, a2 as CreateUploadResponse, E as DeleteLabelResponse, a4 as DeleteUploadResponse, f as GetBoilerplateCategoryResponse, G as GetBoilerplateResponse, j as GetChannelResponse, m as GetCompositionSectionResponse, s as GetContactResponse, w as GetConversationResponse, F as GetLabelResponse, N as GetModelResponse, X as GetNoteResponse, $ as GetSourceResponse, a3 as GetUploadResponse, L as ListActionsResponse, g as ListBoilerplateCategoriesResponse, c as ListBoilerplateCategoryBoilerplatesResponse, d as ListBoilerplatesResponse, p as ListChannelCompositionSectionsResponse, M as ListChannelMessagesResponse, i as ListChannelsResponse, n as ListCompositionSectionsResponse, B as ListContactConversationsResponse, Y as ListContactNotesResponse, t as ListContactsResponse, J as ListConversationMessagesResponse, Z as ListConversationNotesResponse, x as ListConversationsResponse, u as ListLabelContactsResponse, y as ListLabelConversationsResponse, H as ListLabelsResponse, K as ListMessagesResponse, P as ListModelsResponse, a0 as ListSourcesResponse, O as Options, R as RequestFilterable, a as TransportOptions, h as UpdateBoilerplateCategoryResponse, U as UpdateBoilerplateResponse, k as UpdateChannelResponse, q as UpdateCompositionSectionResponse, v as UpdateContactResponse, z as UpdateConversationResponse, I as UpdateLabelResponse, _ as UpdateNoteResponse, W as WebhookResponse, C as default } from './index-CWpRFEq9.js';
3
3
  import 'ky';
4
4
  import 'zod';
5
5
 
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- import{a as d,b as g,c as s,d as p,e as n,f as _,g as a,h as f,i as m,j as u,k as c,l as x,m as l,n as h,o as A}from"./chunk-ZQ7XANXZ.js";var E={};d(E,{AuthError:()=>m,AuthenticationError:()=>u,AuthorizationError:()=>c,LogicError:()=>x,NetworkError:()=>l,SupportError:()=>f,ValidationError:()=>h});var t=class o{static DEFAULT_NAME=a;name;#r;constructor({name:r=process.env[n]??o.DEFAULT_NAME,key:i=process.env[p]}={}){if(!i)throw new Error("API Key option must be specified when using Key Authentication");this.name=r,this.#r=i}async filter(){return{headers:this.getHeaders()}}getHeaders(){return{Authorization:`Basic ${btoa(this.name+":"+this.#r)}`}}};var e=class{#r;constructor({token:r=process.env[s]}={}){if(!r)throw new Error("Access Token option must be specified when using Token Authentication");this.#r=r}async filter(){return{headers:this.getHeaders()}}getHeaders(){return{Authorization:`Bearer ${this.#r}`}}};export{A as Client,_ as DEFAULT_SUPPORT_BASE_URL,E as Error,t as KeyAuthentication,g as PublicAuthentication,e as TokenAuthentication,A as default};
1
+ import{a as d,b as g,c as s,d as p,e as n,f as _,g as a,h as f,i as m,j as u,k as c,l as x,m as l,n as h,o as A}from"./chunk-SQDQYOKX.js";var E={};d(E,{AuthError:()=>m,AuthenticationError:()=>u,AuthorizationError:()=>c,LogicError:()=>x,NetworkError:()=>l,SupportError:()=>f,ValidationError:()=>h});var t=class e{static DEFAULT_NAME=a;name;#r;constructor({name:r=process.env[n]??e.DEFAULT_NAME,key:i=process.env[p]}={}){if(!i)throw new Error("API Key option must be specified when using Key Authentication");this.name=r,this.#r=i}async filter(){return{headers:this.getHeaders()}}getHeaders(){return{Authorization:`Basic ${btoa(this.name+":"+this.#r)}`}}};var o=class{#r;constructor({token:r=process.env[s]}={}){if(!r)throw new Error("Access Token option must be specified when using Token Authentication");this.#r=r}async filter(){return{headers:this.getHeaders()}}getHeaders(){return{Authorization:`Bearer ${this.#r}`}}};export{A as Client,_ as DEFAULT_SUPPORT_BASE_URL,E as Error,t as KeyAuthentication,g as PublicAuthentication,o as TokenAuthentication,A as default};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@great-detail/support-sdk",
3
- "version": "0.5.2",
3
+ "version": "0.5.3",
4
4
  "type": "module",
5
5
  "description": "JavaScript SDK for the Great Detail Support System",
6
6
  "author": "Great Detail Ltd <info@greatdetail.com>",
@@ -1 +0,0 @@
1
- var Mt=Object.defineProperty;var Pt=(r,t)=>{for(var e in t)Mt(r,e,{get:t[e],enumerable:!0})};var Tt=class{async filter(){return{headers:this.getHeaders()}}getHeaders(){return{}}};var wt="https://api.support.greatdetail.com",Ft={"X-Powered-By":"GDSupport/JavaScript"},Dt="api-key";import{z as i}from"zod";var m=class r{constructor(t){this._client=t}static SCHEMA=i.object({event:i.intersection(i.object({id:i.string(),createdAt:i.string().datetime()}),i.discriminatedUnion("type",[i.object({type:i.literal("contact.created"),contact:i.string()}),i.object({type:i.literal("message.created"),message:i.string()})]))});async event({request:t}){let{event:e}=r.SCHEMA.parse(t.body);return{event:e}}};var h=class{constructor(t){this._transport=t}async send({request:t={}}={}){return this._transport.send("v1/actions",{...t,method:"GET"})}};import{z as ft}from"zod";var f=class r{constructor(t){this._transport=t}static SCHEMA=ft.object({title:ft.string(),content:ft.string(),account:ft.string()});async send({id:t,body:e,request:s={}}){return this._transport.send("v1/boilerplate-categories/"+encodeURIComponent(t)+"/boilerplates",{...s,method:"POST",headers:{...s.headers,"Content-Type":"application/json"},json:r.SCHEMA.parse(e)})}};var C=class{constructor(t){this._transport=t}async send({id:t,request:e={}}){return this._transport.send("v1/boilerplates/"+encodeURIComponent(t),{...e,method:"GET"})}};var b=class{constructor(t){this._transport=t}async send({id:t,request:e={}}){return this._transport.send("v1/boilerplate-categories/"+encodeURIComponent(t)+"/boilerplates",{...e,method:"GET"})}};var A=class{constructor(t){this._transport=t}async send({query:t,request:e={}}={}){return this._transport.send("v1/boilerplates"+(t?"?query="+encodeURIComponent(t):""),{...e,method:"GET"})}};import{z as xt}from"zod";var R=class r{constructor(t){this._transport=t}static SCHEMA=xt.object({title:xt.string().optional(),content:xt.string().optional()});async send({id:t,body:e,request:s={}}){return this._transport.send("v1/boilerplates/"+encodeURIComponent(t),{...s,method:"PATCH",headers:{...s.headers,"Content-Type":"application/json"},json:r.SCHEMA.parse(e)})}};import{z as Ct}from"zod";var y=class r{constructor(t){this._transport=t}static SCHEMA=Ct.object({title:Ct.string(),description:Ct.string().optional(),account:Ct.string()});async send({body:t,request:e={}}){return this._transport.send("v1/boilerplate-categories",{...e,method:"POST",headers:{...e.headers,"Content-Type":"application/json"},json:r.SCHEMA.parse(t)})}};var T=class{constructor(t){this._transport=t}async send({id:t,request:e={}}){return this._transport.send("v1/boilerplate-categories/"+encodeURIComponent(t),{...e,method:"GET"})}};var x=class{constructor(t){this._transport=t}async send({request:t={}}={}){return this._transport.send("v1/boilerplate-categories",{...t,method:"GET"})}};import{z as _t}from"zod";var _=class r{constructor(t){this._transport=t}static SCHEMA=_t.object({title:_t.string().optional(),description:_t.string().optional()});async send({id:t,body:e,request:s={}}){return this._transport.send("v1/boilerplate-categories/"+encodeURIComponent(t),{...s,method:"PATCH",headers:{...s.headers,"Content-Type":"application/json"},json:r.SCHEMA.parse(e)})}};import{z as n}from"zod";var E=class r{constructor(t){this._transport=t}static SCHEMA=n.intersection(n.object({name:n.string().optional(),account:n.string()}),n.discriminatedUnion("source",[n.object({source:n.literal("meta-whatsapp")}),n.object({source:n.literal("twilio-sendgrid"),twilioSendgrid:n.object({displayName:n.string().optional(),outboundEmailAddress:n.string().email(),replyEmailAddress:n.string().optional(),inboundHostname:n.string(),apiKey:n.string()})})]));async send({body:t,request:e={}}){return this._transport.send("v1/channels",{...e,method:"POST",headers:{...e.headers,"Content-Type":"application/json"},json:r.SCHEMA.parse(t)})}};var v=class{constructor(t){this._transport=t}async send({id:t,request:e={}}){return this._transport.send("v1/channels/"+encodeURIComponent(t),{...e,method:"GET"})}};var S=class{constructor(t){this._transport=t}async send({request:t={}}={}){return this._transport.send("v1/channels",{...t,method:"GET"})}};import{z as o}from"zod";var O=class r{constructor(t){this._transport=t}static SCHEMA=o.intersection(o.object({name:o.string().optional()}),o.discriminatedUnion("source",[o.object({source:o.literal("meta-whatsapp")}),o.object({source:o.literal("twilio-sendgrid"),twilioSendgrid:o.object({displayName:o.string().optional(),outboundEmailAddress:o.string().email().optional(),replyEmailAddress:o.string().optional(),inboundHostname:o.string().optional(),apiKey:o.string().optional()})})]));async send({id:t,body:e,request:s={}}){return this._transport.send("v1/channels/"+encodeURIComponent(t),{...s,method:"PATCH",headers:{...s.headers,"Content-Type":"application/json"},json:r.SCHEMA.parse(e)})}};var ge="SUPPORT_ACCESS_TOKEN",me="SUPPORT_API_KEY",he="SUPPORT_KEY_NAME",Ut="SUPPORT_BASE_URL";var w=class{constructor(t){this._transport=t}getRelativeURL({id:t,vcf:e={}}){let s=e.variant??"vcard",p=e.format??(e.variant==="vcard"?"vcf":"json");return"v1/contacts/"+encodeURIComponent(t)+"/vcf?variant="+encodeURIComponent(s)+"&format="+encodeURIComponent(p)}getURL(t){return this._transport.getURL(this.getRelativeURL(t))}};import{z as F}from"zod";var U=class r{constructor(t){this._transport=t}static SCHEMA=F.object({name:F.string(),account:F.string(),emailAddress:F.string().email().optional(),telephoneNumber:F.string().optional()});async send({body:t,request:e={}}){return this._transport.send("v1/contacts",{...e,method:"POST",headers:{...e.headers,"Content-Type":"application/json"},json:r.SCHEMA.parse(t)})}};var I=class{constructor(t){this._transport=t}async send({id:t,request:e={}}){return this._transport.send("v1/contacts/"+encodeURIComponent(t),{...e,method:"GET"})}};var q=class{constructor(t){this._transport=t}async send({request:t={}}={}){return this._transport.send("v1/contacts",{...t,method:"GET"})}};var H=class{constructor(t){this._transport=t}async send({id:t,request:e={}}){return this._transport.send("v1/labels/"+encodeURIComponent(t)+"/contacts",{...e,method:"GET"})}};import{z as bt}from"zod";var L=class r{constructor(t){this._transport=t}static SCHEMA=bt.object({name:bt.string().optional(),emailAddress:bt.string().email().optional(),telephoneNumber:bt.string().optional()});async send({id:t,body:e,request:s={}}){return this._transport.send("v1/contacts/"+encodeURIComponent(t),{...s,method:"PATCH",headers:{...s.headers,"Content-Type":"application/json"},json:r.SCHEMA.parse(e)})}};var M=class{constructor(t){this._transport=t}async send({id:t,request:e={}}){return this._transport.send("v1/conversations/"+encodeURIComponent(t),{...e,method:"GET"})}};var j=class{constructor(t){this._transport=t}async send({id:t,request:e={}}){return this._transport.send("v1/contacts/"+encodeURIComponent(t)+"/conversations",{...e,method:"GET"})}};var N=class{constructor(t){this._transport=t}async send({filter:t,request:e={}}={}){let s=[];return t&&s.push(["filter",t]),this._transport.send("v1/conversations",{...e,method:"GET",searchParams:s})}};var G=class{constructor(t){this._transport=t}async send({id:t,request:e={}}){return this._transport.send("v1/labels/"+encodeURIComponent(t)+"/conversations",{...e,method:"GET"})}};import{z as Et}from"zod";var P=class r{constructor(t){this._transport=t}static SCHEMA=Et.object({status:Et.enum(["AwaitingContactConversationStatus","AwaitingAgentConversationStatus","ResolvedConversationStatus","ClosedConversationStatus"]).optional(),hasEnded:Et.boolean().optional()});async send({id:t,body:e,request:s={}}){return this._transport.send("v1/conversations/"+encodeURIComponent(t),{...s,method:"PATCH",headers:{...s.headers,"Content-Type":"application/json"},json:r.SCHEMA.parse(e)})}};import{z as At}from"zod";var z=class r{constructor(t){this._transport=t}static SCHEMA=At.object({title:At.string(),description:At.string().optional(),account:At.string()});async send({body:t,request:e={}}){return this._transport.send("v1/labels",{...e,method:"POST",headers:{...e.headers,"Content-Type":"application/json"},json:r.SCHEMA.parse(t)})}};var B=class{constructor(t){this._transport=t}async send({id:t,request:e={}}){return this._transport.send("v1/labels/"+encodeURIComponent(t),{...e,method:"DELETE"})}};var D=class{constructor(t){this._transport=t}async send({id:t,request:e={}}){return this._transport.send("v1/labels/"+encodeURIComponent(t),{...e,method:"GET"})}};var k=class{constructor(t){this._transport=t}async send({request:t={}}={}){return this._transport.send("v1/labels",{...t,method:"GET"})}};import{z as vt}from"zod";var K=class r{constructor(t){this._transport=t}static SCHEMA=vt.object({title:vt.string().optional(),description:vt.string().optional()});async send({id:t,body:e,request:s={}}){return this._transport.send("v1/labels/"+encodeURIComponent(t),{...s,method:"PATCH",headers:{...s.headers,"Content-Type":"application/json"},json:r.SCHEMA.parse(e)})}};var V=class{constructor(t){this._transport=t}async send({id:t,request:e={}}){return this._transport.send("v1/channels/"+encodeURIComponent(t)+"/messages",{...e,method:"GET"})}};var W=class{constructor(t){this._transport=t}async send({id:t,request:e={}}){return this._transport.send("v1/conversations/"+encodeURIComponent(t)+"/messages",{...e,method:"GET"})}};var Y=class{constructor(t){this._transport=t}async send({request:t={}}={}){return this._transport.send("v1/messages",{...t,method:"GET"})}};import{z as Rt}from"zod";var $=class r{constructor(t){this._transport=t}static SCHEMA=Rt.object({input:Rt.string().max(65536),original:Rt.string().max(65536),correction:Rt.string().max(65536)});async send({id:t,body:e,request:s={}}){return this._transport.send("v1/models/"+encodeURIComponent(t)+"/correction",{...s,method:"POST",headers:{...s.headers,"Content-Type":"application/json"},json:r.SCHEMA.parse(e)})}};var J=class{constructor(t){this._transport=t}async send({id:t,request:e={}}){return this._transport.send("v1/models/"+encodeURIComponent(t),{...e,method:"GET"})}};var X=class{constructor(t){this._transport=t}async send({request:t={}}={}){return this._transport.send("v1/models",{...t,method:"GET"})}};import{z as yt}from"zod";var Q=class r{constructor(t){this._transport=t}static SCHEMA=yt.array(yt.object({role:yt.enum(["user","assistant"]),content:yt.string().max(65536).nullable()})).min(1);async send({id:t,body:e,request:s={}}){return this._transport.send("v1/models/"+encodeURIComponent(t)+"/response",{...s,method:"POST",headers:{...s.headers,"Content-Type":"application/json"},json:r.SCHEMA.parse(e)})}};import{z as It}from"zod";var Z=class r{constructor(t){this._transport=t}static SCHEMA=It.object({content:It.string()});async send({id:t,body:e,request:s={}}){return this._transport.send("v1/contacts/"+encodeURIComponent(t)+"/notes",{...s,method:"POST",headers:{...s.headers,"Content-Type":"application/json"},json:r.SCHEMA.parse(e)})}};import{z as qt}from"zod";var l=class r{constructor(t){this._transport=t}static SCHEMA=qt.object({content:qt.string()});async send({id:t,body:e,request:s={}}){return this._transport.send("v1/conversations/"+encodeURIComponent(t)+"/notes",{...s,method:"POST",headers:{...s.headers,"Content-Type":"application/json"},json:r.SCHEMA.parse(e)})}};var tt=class{constructor(t){this._transport=t}async send({id:t,request:e={}}){return this._transport.send("v1/notes/"+encodeURIComponent(t),{...e,method:"GET"})}};var et=class{constructor(t){this._transport=t}async send({id:t,request:e={}}){return this._transport.send("v1/contacts/"+encodeURIComponent(t)+"/notes",{...e,method:"GET"})}};var rt=class{constructor(t){this._transport=t}async send({id:t,request:e={}}){return this._transport.send("v1/conversations/"+encodeURIComponent(t)+"/notes",{...e,method:"GET"})}};import{z as Ht}from"zod";var st=class r{constructor(t){this._transport=t}static SCHEMA=Ht.object({content:Ht.string().optional()});async send({id:t,body:e,request:s={}}){return this._transport.send("v1/notes/"+encodeURIComponent(t),{...s,method:"PATCH",headers:{...s.headers,"Content-Type":"application/json"},json:r.SCHEMA.parse(e)})}};import{z as c}from"zod";var nt=class r{constructor(t){this._transport=t}static SCHEMA=c.discriminatedUnion("type",[c.object({type:c.literal("vapid"),endpoint:c.string().url(),keys:c.object({p256dh:c.string(),auth:c.string()})})]);async send({id:t,body:e,request:s={}}){return this._transport.send("v1/contacts/"+encodeURIComponent(t)+"/notification-subscriptions",{...s,method:"POST",headers:{...s.headers,"Content-Type":"application/json"},json:r.SCHEMA.parse(e)})}};var ot=class r{constructor(t=r.STANDARD_HEADERS){this._standardHeaders=t}static STANDARD_HEADERS=Ft;async filter(){return{headers:this.getHeaders()}}getHeaders(){return this._standardHeaders}};var it=class{constructor(t){this._transport=t}async send({id:t,request:e={}}){return this._transport.send("v1/sources/"+encodeURIComponent(t),{...e,method:"GET"})}};var at=class{constructor(t){this._transport=t}async send({category:t,request:e={}}={}){let s=[];if(t){let p=Array.isArray(t)?t:[t];for(let g of p)s.push(["category",g])}return this._transport.send("v1/sources",{...e,method:"GET",searchParams:s})}};import jt from"is-network-error";import Nt,{HTTPError as Gt}from"ky";var a=class extends Error{};var d=class extends a{};var pt=class extends d{static unauthenticated(){return new this("An unauthenticated request occurred")}};var ct=class extends d{static forbidden(){return new this("A forbidden request occurred")}};var u=class extends a{static notFound(t){return new this(`Record not found for request: ${t}`)}static forbiddenMethod(t,e){return new this(`Forbidden method for request: ${t} ${e}`)}};var dt=class extends a{};var lt=class extends a{static badRequest(){return new this("Bad request")}};var ut=class{client;options;constructor({baseURL:t,...e}){this.options={...e,baseURL:t},this.client=Nt.create({prefixUrl:this.options.baseURL,hooks:{beforeRequest:[s=>{for(let p of this.options.requestFilterables){let g=p.getHeaders();for(let[Ot,Lt]of Object.entries(g))s.headers.has(Ot)||s.headers.set(Ot,Lt)}}]}})}getURL(t){return new URL(t,this.options.baseURL).toString()}async send(t,e){return await this.client(t,e).catch(s=>{if(jt(s))throw new dt("A network error occurred",{cause:s});if(s instanceof Gt){let p=s.response.status;switch(console.error(JSON.stringify(s.response)),p){case 400:throw lt.badRequest();case 401:throw pt.unauthenticated();case 403:throw ct.forbidden();case 404:throw u.notFound(t);case 405:throw u.forbiddenMethod(t,e.method??"GET")}}throw s})}};var gt=class{constructor(t){this._transport=t}async send({account:t,files:e,request:s={}}){let p=new FormData;for(let g of e)p.append("file",g);return this._transport.send("v1/uploads",{...s,method:"POST",body:p,searchParams:{account:t}})}};var mt=class{constructor(t){this._transport=t}async send({id:t,request:e={}}){return this._transport.send("v1/uploads/"+encodeURIComponent(t),{...e,method:"DELETE"})}};var ht=class{constructor(t){this._transport=t}async send({id:t,request:e={}}){return this._transport.send("v1/uploads/"+encodeURIComponent(t),{...e,method:"GET"})}};var St=class r{static DEFAULT_BASE_URL=wt;_transport;constructor(t,{baseURL:e,...s}={}){this._transport=new ut({requestFilterables:[new ot,t],...s,baseURL:e?.toString()??r.getBaseURL()})}static getBaseURL(){return process.env[Ut]??this.DEFAULT_BASE_URL}get action(){return{list:new h(this._transport)}}get boilerplate(){return{get:new C(this._transport),list:new A(this._transport),update:new R(this._transport)}}get boilerplateCategory(){return{get:new T(this._transport),list:new x(this._transport),create:new y(this._transport),update:new _(this._transport),boilerplate:{list:new b(this._transport),create:new f(this._transport)}}}get channel(){return{get:new v(this._transport),list:new S(this._transport),update:new O(this._transport),create:new E(this._transport),message:{list:new V(this._transport)}}}get contact(){return{get:new I(this._transport),list:new q(this._transport),update:new L(this._transport),create:new U(this._transport),conversation:{list:new j(this._transport)},note:{list:new et(this._transport),create:new Z(this._transport)},notificationSubscription:{create:new nt(this._transport)},vcf:{get:new w(this._transport)}}}get conversation(){return{get:new M(this._transport),list:new N(this._transport),update:new P(this._transport),create:new l(this._transport),message:{list:new W(this._transport)},note:{list:new rt(this._transport),create:new l(this._transport)}}}get label(){return{create:new z(this._transport),get:new D(this._transport),list:new k(this._transport),update:new K(this._transport),delete:new B(this._transport),contact:{list:new H(this._transport)},conversation:{list:new G(this._transport)}}}get message(){return{list:new Y(this._transport)}}get model(){return{get:new J(this._transport),list:new X(this._transport),response:{create:new Q(this._transport)},correction:{create:new $(this._transport)}}}get note(){return{get:new tt(this._transport),update:new st(this._transport)}}get source(){return{get:new it(this._transport),list:new at(this._transport)}}get upload(){return{get:new ht(this._transport),create:new gt(this._transport),delete:new mt(this._transport)}}get webhook(){return new m(this)}};export{Pt as a,Tt as b,ge as c,me as d,he as e,wt as f,Dt as g,a as h,d as i,pt as j,ct as k,u as l,dt as m,lt as n,St as o};