@great-detail/support-sdk 0.2.9 → 0.3.0

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.
@@ -28,21 +28,21 @@ interface RequestFilterable {
28
28
  * @see https://greatdetail.com
29
29
  */
30
30
 
31
- interface Options$B {
31
+ interface Options$G {
32
32
  requestFilterables: RequestFilterable[];
33
33
  }
34
34
  interface Transport {
35
35
  getURL(url: string): string;
36
36
  }
37
37
 
38
- interface InputOptions extends Options$B {
38
+ interface InputOptions extends Options$G {
39
39
  baseURL: string;
40
40
  }
41
- interface Options$A extends Options$B {
41
+ interface Options$F extends Options$G {
42
42
  baseURL: string;
43
43
  }
44
44
  declare class FetchTransport implements Transport {
45
- options: Options$A;
45
+ options: Options$F;
46
46
  constructor({ baseURL, ...options }: InputOptions);
47
47
  getURL(url: string): string;
48
48
  getRequest(url: string, request: RequestInit): Request;
@@ -58,13 +58,13 @@ declare class FetchTransport implements Transport {
58
58
  * @see https://greatdetail.com
59
59
  */
60
60
 
61
- interface Options$z {
61
+ interface Options$E {
62
62
  request?: RequestInit;
63
63
  }
64
64
  declare class ListActions {
65
65
  protected _transport: FetchTransport;
66
66
  constructor(_transport: FetchTransport);
67
- send({ request }?: Options$z): Promise<ListActionsResponse>;
67
+ send({ request }?: Options$E): Promise<ListActionsResponse>;
68
68
  }
69
69
  type ListActionsResponsePayload = {
70
70
  actions: {
@@ -106,11 +106,12 @@ type Authentication = RequestFilterable;
106
106
  * @see https://greatdetail.com
107
107
  */
108
108
 
109
- interface Options$y {
110
- body: z.infer<typeof CreateBoilerplate.SCHEMA>;
109
+ interface Options$D {
110
+ id: string;
111
+ body: z.infer<typeof CreateBoilerplateCategoryBoilerplate.SCHEMA>;
111
112
  request?: RequestInit;
112
113
  }
113
- declare class CreateBoilerplate {
114
+ declare class CreateBoilerplateCategoryBoilerplate {
114
115
  protected _transport: FetchTransport;
115
116
  static SCHEMA: z.ZodObject<{
116
117
  title: z.ZodString;
@@ -126,9 +127,9 @@ declare class CreateBoilerplate {
126
127
  account: string;
127
128
  }>;
128
129
  constructor(_transport: FetchTransport);
129
- send({ body, request }: Options$y): Promise<CreateBoilerplateResponse>;
130
+ send({ id, body, request }: Options$D): Promise<CreateBoilerplateCategoryBoilerplateResponse>;
130
131
  }
131
- type CreateBoilerplateResponsePayload = {
132
+ type CreateBoilerplateCategoryBoilerplateResponsePayload = {
132
133
  boilerplate: {
133
134
  id: string;
134
135
  title: string;
@@ -138,10 +139,10 @@ type CreateBoilerplateResponsePayload = {
138
139
  updatedAt: string;
139
140
  };
140
141
  };
141
- declare class CreateBoilerplateResponse {
142
+ declare class CreateBoilerplateCategoryBoilerplateResponse {
142
143
  response: Response;
143
144
  constructor(response: Response);
144
- result(): Promise<CreateBoilerplateResponsePayload>;
145
+ result(): Promise<CreateBoilerplateCategoryBoilerplateResponsePayload>;
145
146
  }
146
147
 
147
148
  /**
@@ -153,14 +154,14 @@ declare class CreateBoilerplateResponse {
153
154
  * @see https://greatdetail.com
154
155
  */
155
156
 
156
- interface Options$x {
157
+ interface Options$C {
157
158
  id: string;
158
159
  request?: RequestInit;
159
160
  }
160
161
  declare class GetBoilerplate {
161
162
  protected _transport: FetchTransport;
162
163
  constructor(_transport: FetchTransport);
163
- send({ id, request }: Options$x): Promise<GetBoilerplateResponse>;
164
+ send({ id, request }: Options$C): Promise<GetBoilerplateResponse>;
164
165
  }
165
166
  type GetBoilerplateResponsePayload = {
166
167
  boilerplate: {
@@ -168,6 +169,7 @@ type GetBoilerplateResponsePayload = {
168
169
  title: string;
169
170
  content: string;
170
171
  account: string;
172
+ boilerplateCategory: string;
171
173
  createdAt: string;
172
174
  updatedAt: string;
173
175
  };
@@ -187,13 +189,48 @@ declare class GetBoilerplateResponse {
187
189
  * @see https://greatdetail.com
188
190
  */
189
191
 
190
- interface Options$w {
192
+ interface Options$B {
193
+ id: string;
194
+ request?: RequestInit;
195
+ }
196
+ declare class ListBoilerplateCategoryBoilerplates {
197
+ protected _transport: FetchTransport;
198
+ constructor(_transport: FetchTransport);
199
+ send({ id, request }: Options$B): Promise<ListBoilerplateCategoryBoilerplatesResponse>;
200
+ }
201
+ type ListBoilerplateCategoryBoilerplatesResponsePayload = {
202
+ boilerplates: {
203
+ id: string;
204
+ title: string;
205
+ content: string;
206
+ account: string;
207
+ boilerplateCategory: string;
208
+ createdAt: string;
209
+ updatedAt: string;
210
+ }[];
211
+ };
212
+ declare class ListBoilerplateCategoryBoilerplatesResponse {
213
+ response: Response;
214
+ constructor(response: Response);
215
+ result(): Promise<ListBoilerplateCategoryBoilerplatesResponsePayload>;
216
+ }
217
+
218
+ /**
219
+ * Great Detail Support System.
220
+ *
221
+ * @copyright 2024 Great Detail Ltd
222
+ * @author Great Detail Ltd <info@greatdetail.com>
223
+ * @author Dom Webber <dom.webber@greatdetail.com>
224
+ * @see https://greatdetail.com
225
+ */
226
+
227
+ interface Options$A {
191
228
  request?: RequestInit;
192
229
  }
193
230
  declare class ListBoilerplates {
194
231
  protected _transport: FetchTransport;
195
232
  constructor(_transport: FetchTransport);
196
- send({ request }?: Options$w): Promise<ListBoilerplatesResponse>;
233
+ send({ request }?: Options$A): Promise<ListBoilerplatesResponse>;
197
234
  }
198
235
  type ListBoilerplatesResponsePayload = {
199
236
  boilerplates: {
@@ -201,6 +238,7 @@ type ListBoilerplatesResponsePayload = {
201
238
  title: string;
202
239
  content: string;
203
240
  account: string;
241
+ boilerplateCategory: string;
204
242
  createdAt: string;
205
243
  updatedAt: string;
206
244
  }[];
@@ -220,7 +258,7 @@ declare class ListBoilerplatesResponse {
220
258
  * @see https://greatdetail.com
221
259
  */
222
260
 
223
- interface Options$v {
261
+ interface Options$z {
224
262
  id: string;
225
263
  body: z.infer<typeof UpdateBoilerplate.SCHEMA>;
226
264
  request?: RequestInit;
@@ -238,7 +276,7 @@ declare class UpdateBoilerplate {
238
276
  content?: string | undefined;
239
277
  }>;
240
278
  constructor(_transport: FetchTransport);
241
- send({ id, body, request }: Options$v): Promise<UpdateBoilerplateResponse>;
279
+ send({ id, body, request }: Options$z): Promise<UpdateBoilerplateResponse>;
242
280
  }
243
281
  type UpdateBoilerplateResponsePayload = {
244
282
  boilerplate: {
@@ -246,6 +284,7 @@ type UpdateBoilerplateResponsePayload = {
246
284
  title: string;
247
285
  content: string;
248
286
  account: string;
287
+ boilerplateCategory: string;
249
288
  createdAt: string;
250
289
  updatedAt: string;
251
290
  };
@@ -256,6 +295,165 @@ declare class UpdateBoilerplateResponse {
256
295
  result(): Promise<UpdateBoilerplateResponsePayload>;
257
296
  }
258
297
 
298
+ /**
299
+ * Great Detail Support System.
300
+ *
301
+ * @copyright 2024 Great Detail Ltd
302
+ * @author Great Detail Ltd <info@greatdetail.com>
303
+ * @author Dom Webber <dom.webber@greatdetail.com>
304
+ * @see https://greatdetail.com
305
+ */
306
+
307
+ interface Options$y {
308
+ body: z.infer<typeof CreateBoilerplateCategory.SCHEMA>;
309
+ request?: RequestInit;
310
+ }
311
+ declare class CreateBoilerplateCategory {
312
+ protected _transport: FetchTransport;
313
+ static SCHEMA: z.ZodObject<{
314
+ title: z.ZodString;
315
+ description: z.ZodOptional<z.ZodString>;
316
+ account: z.ZodString;
317
+ }, "strip", z.ZodTypeAny, {
318
+ title: string;
319
+ account: string;
320
+ description?: string | undefined;
321
+ }, {
322
+ title: string;
323
+ account: string;
324
+ description?: string | undefined;
325
+ }>;
326
+ constructor(_transport: FetchTransport);
327
+ send({ body, request }: Options$y): Promise<CreateBoilerplateCategoryResponse>;
328
+ }
329
+ type CreateBoilerplateCategoryResponsePayload = {
330
+ boilerplateCategory: {
331
+ id: string;
332
+ title: string;
333
+ description?: string;
334
+ account: string;
335
+ createdAt: string;
336
+ updatedAt: string;
337
+ };
338
+ };
339
+ declare class CreateBoilerplateCategoryResponse {
340
+ response: Response;
341
+ constructor(response: Response);
342
+ result(): Promise<CreateBoilerplateCategoryResponsePayload>;
343
+ }
344
+
345
+ /**
346
+ * Great Detail Support System.
347
+ *
348
+ * @copyright 2024 Great Detail Ltd
349
+ * @author Great Detail Ltd <info@greatdetail.com>
350
+ * @author Dom Webber <dom.webber@greatdetail.com>
351
+ * @see https://greatdetail.com
352
+ */
353
+
354
+ interface Options$x {
355
+ id: string;
356
+ request?: RequestInit;
357
+ }
358
+ declare class GetBoilerplateCategory {
359
+ protected _transport: FetchTransport;
360
+ constructor(_transport: FetchTransport);
361
+ send({ id, request }: Options$x): Promise<GetBoilerplateCategoryResponse>;
362
+ }
363
+ type GetBoilerplateCategoryResponsePayload = {
364
+ boilerplateCategory: {
365
+ id: string;
366
+ title: string;
367
+ description?: string;
368
+ account: string;
369
+ createdAt: string;
370
+ updatedAt: string;
371
+ };
372
+ };
373
+ declare class GetBoilerplateCategoryResponse {
374
+ response: Response;
375
+ constructor(response: Response);
376
+ result(): Promise<GetBoilerplateCategoryResponsePayload>;
377
+ }
378
+
379
+ /**
380
+ * Great Detail Support System.
381
+ *
382
+ * @copyright 2024 Great Detail Ltd
383
+ * @author Great Detail Ltd <info@greatdetail.com>
384
+ * @author Dom Webber <dom.webber@greatdetail.com>
385
+ * @see https://greatdetail.com
386
+ */
387
+
388
+ interface Options$w {
389
+ request?: RequestInit;
390
+ }
391
+ declare class ListBoilerplateCategories {
392
+ protected _transport: FetchTransport;
393
+ constructor(_transport: FetchTransport);
394
+ send({ request }?: Options$w): Promise<ListBoilerplateCategoriesResponse>;
395
+ }
396
+ type ListBoilerplateCategoriesResponsePayload = {
397
+ boilerplateCategories: {
398
+ id: string;
399
+ title: string;
400
+ description?: string;
401
+ account: string;
402
+ createdAt: string;
403
+ updatedAt: string;
404
+ }[];
405
+ };
406
+ declare class ListBoilerplateCategoriesResponse {
407
+ response: Response;
408
+ constructor(response: Response);
409
+ result(): Promise<ListBoilerplateCategoriesResponsePayload>;
410
+ }
411
+
412
+ /**
413
+ * Great Detail Support System.
414
+ *
415
+ * @copyright 2024 Great Detail Ltd
416
+ * @author Great Detail Ltd <info@greatdetail.com>
417
+ * @author Dom Webber <dom.webber@greatdetail.com>
418
+ * @see https://greatdetail.com
419
+ */
420
+
421
+ interface Options$v {
422
+ id: string;
423
+ body: z.infer<typeof UpdateBoilerplateCategory.SCHEMA>;
424
+ request?: RequestInit;
425
+ }
426
+ declare class UpdateBoilerplateCategory {
427
+ protected _transport: FetchTransport;
428
+ static SCHEMA: z.ZodObject<{
429
+ title: z.ZodOptional<z.ZodString>;
430
+ description: z.ZodOptional<z.ZodString>;
431
+ }, "strip", z.ZodTypeAny, {
432
+ title?: string | undefined;
433
+ description?: string | undefined;
434
+ }, {
435
+ title?: string | undefined;
436
+ description?: string | undefined;
437
+ }>;
438
+ constructor(_transport: FetchTransport);
439
+ send({ id, body, request }: Options$v): Promise<UpdateBoilerplateCategoryResponse>;
440
+ }
441
+ type UpdateBoilerplateCategoryResponsePayload = {
442
+ boilerplateCategory: {
443
+ id: string;
444
+ title: string;
445
+ description?: string;
446
+ account: string;
447
+ createdAt: string;
448
+ updatedAt: string;
449
+ };
450
+ };
451
+ declare class UpdateBoilerplateCategoryResponse {
452
+ response: Response;
453
+ constructor(response: Response);
454
+ result(): Promise<UpdateBoilerplateCategoryResponsePayload>;
455
+ }
456
+
259
457
  /**
260
458
  * Great Detail Support System.
261
459
  *
@@ -1401,9 +1599,18 @@ declare class Client {
1401
1599
  get boilerplate(): {
1402
1600
  get: GetBoilerplate;
1403
1601
  list: ListBoilerplates;
1404
- create: CreateBoilerplate;
1405
1602
  update: UpdateBoilerplate;
1406
1603
  };
1604
+ get boilerplateCategory(): {
1605
+ get: GetBoilerplateCategory;
1606
+ list: ListBoilerplateCategories;
1607
+ create: CreateBoilerplateCategory;
1608
+ update: UpdateBoilerplateCategory;
1609
+ boilerplate: {
1610
+ list: ListBoilerplateCategoryBoilerplates;
1611
+ create: CreateBoilerplateCategoryBoilerplate;
1612
+ };
1613
+ };
1407
1614
  get channel(): {
1408
1615
  list: ListChannels;
1409
1616
  };
@@ -1468,4 +1675,4 @@ declare class Client {
1468
1675
  };
1469
1676
  }
1470
1677
 
1471
- export { type Authentication as A, type ListContactNotesResponsePayload as B, Client as C, type DeleteLabelResponsePayload as D, type ListConversationNotesResponsePayload as E, type UpdateNoteResponsePayload as F, type GetBoilerplateResponsePayload as G, type GetSourceResponsePayload as H, type ListSourcesResponsePayload as I, type ListActionsResponsePayload as L, type Options as O, type RequestFilterable as R, type UpdateBoilerplateResponsePayload as U, type Options$B as a, type CreateBoilerplateResponsePayload as b, type ListBoilerplatesResponsePayload as c, type ListChannelsResponsePayload as d, type CreateContactResponsePayload as e, type GetContactResponsePayload as f, type ListContactsResponsePayload as g, type ListLabelContactsResponsePayload as h, type UpdateContactResponsePayload as i, type GetConversationResponsePayload as j, type ListConversationsResponsePayload as k, type ListLabelConversationsResponsePayload as l, type UpdateConversationResponsePayload as m, type CreateLabelResponsePayload as n, type GetLabelResponsePayload as o, type ListLabelsResponsePayload as p, type UpdateLabelResponsePayload as q, type ListConversationMessagesResponsePayload as r, type ListMessagesResponsePayload as s, type GetModelResponsePayload as t, type ListModelsResponsePayload as u, type CreateCorrectionResponsePayload as v, type CreateResponseResponsePayload as w, type CreateContactNoteResponsePayload as x, type CreateConversationNoteResponsePayload as y, type GetNoteResponsePayload as z };
1678
+ export { type Authentication as A, type CreateCorrectionResponsePayload as B, Client as C, type DeleteLabelResponsePayload as D, type CreateResponseResponsePayload as E, type CreateContactNoteResponsePayload as F, type GetBoilerplateResponsePayload as G, type CreateConversationNoteResponsePayload as H, type GetNoteResponsePayload as I, type ListContactNotesResponsePayload as J, type ListConversationNotesResponsePayload as K, type ListActionsResponsePayload as L, type UpdateNoteResponsePayload as M, type GetSourceResponsePayload as N, type Options as O, type ListSourcesResponsePayload as P, type RequestFilterable as R, type UpdateBoilerplateResponsePayload as U, type Options$G as a, type CreateBoilerplateCategoryBoilerplateResponsePayload as b, type ListBoilerplateCategoryBoilerplatesResponsePayload as c, type ListBoilerplatesResponsePayload as d, type CreateBoilerplateCategoryResponsePayload as e, type GetBoilerplateCategoryResponsePayload as f, type ListBoilerplateCategoriesResponsePayload as g, type UpdateBoilerplateCategoryResponsePayload as h, type ListChannelsResponsePayload as i, type CreateContactResponsePayload as j, type GetContactResponsePayload as k, type ListContactsResponsePayload as l, type ListLabelContactsResponsePayload as m, type UpdateContactResponsePayload as n, type GetConversationResponsePayload as o, type ListConversationsResponsePayload as p, type ListLabelConversationsResponsePayload as q, type UpdateConversationResponsePayload as r, type CreateLabelResponsePayload as s, type GetLabelResponsePayload as t, type ListLabelsResponsePayload as u, type UpdateLabelResponsePayload as v, type ListConversationMessagesResponsePayload as w, type ListMessagesResponsePayload as x, type GetModelResponsePayload as y, type ListModelsResponsePayload as z };
package/dist/index.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";var ae=Object.create;var ot=Object.defineProperty;var pe=Object.getOwnPropertyDescriptor;var ce=Object.getOwnPropertyNames;var ue=Object.getPrototypeOf,de=Object.prototype.hasOwnProperty;var Yt=(e,t)=>{for(var r in t)ot(e,r,{get:t[r],enumerable:!0})},$t=(e,t,r,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of ce(t))!de.call(e,n)&&n!==r&&ot(e,n,{get:()=>t[n],enumerable:!(s=pe(t,n))||s.enumerable});return e};var Wt=(e,t,r)=>(r=e!=null?ae(ue(e)):{},$t(t||!e||!e.__esModule?ot(r,"default",{value:e,enumerable:!0}):r,e)),le=e=>$t(ot({},"__esModule",{value:!0}),e);var me={};Yt(me,{Client:()=>m,DEFAULT_SUPPORT_BASE_URL:()=>it,Error:()=>Kt,KeyAuthentication:()=>rt,PublicAuthentication:()=>nt,TokenAuthentication:()=>st,default:()=>m});module.exports=le(me);var it="https://api.support.greatdetail.com",Xt={"X-Powered-By":"GDSupport/JavaScript"},Qt="api-key";var g=class{constructor(t){this._transport=t}async send({request:t={}}={}){return this._transport.send("v1/actions",{...t,method:"GET"}).then(r=>new ct(r))}},ct=class{constructor(t){this.response=t}async result(){return this.response.json()}};var h=require("zod"),f=class e{constructor(t){this._transport=t}static SCHEMA=h.z.object({title:h.z.string(),content:h.z.string(),account:h.z.string()});async send({body:t,request:r={}}){return this._transport.send("v1/boilerplates",{...r,method:"POST",headers:{...r.headers,"Content-Type":"application/json"},body:JSON.stringify(e.SCHEMA.parse(t))}).then(s=>new ut(s))}},ut=class{constructor(t){this.response=t}async result(){return this.response.json()}};var b=class{constructor(t){this._transport=t}async send({id:t,request:r={}}){return this._transport.send("v1/boilerplates/"+encodeURIComponent(t),{...r,method:"GET"}).then(s=>new dt(s))}},dt=class{constructor(t){this.response=t}async result(){return this.response.json()}};var y=class{constructor(t){this._transport=t}async send({request:t={}}={}){return this._transport.send("v1/boilerplates",{...t,method:"GET"}).then(r=>new lt(r))}},lt=class{constructor(t){this.response=t}async result(){return this.response.json()}};var at=require("zod"),x=class e{constructor(t){this._transport=t}static SCHEMA=at.z.object({title:at.z.string().optional(),content:at.z.string().optional()});async send({id:t,body:r,request:s={}}){return this._transport.send("v1/boilerplates/"+encodeURIComponent(t),{...s,method:"PATCH",headers:{...s.headers,"Content-Type":"application/json"},body:JSON.stringify(e.SCHEMA.parse(r))}).then(n=>new mt(n))}},mt=class{constructor(t){this.response=t}async result(){return this.response.json()}};var R=class{constructor(t){this._transport=t}async send({request:t={}}={}){return this._transport.send("v1/channels",{...t,method:"GET"}).then(r=>new gt(r))}},gt=class{constructor(t){this.response=t}async result(){return this.response.json()}};var Zt="SUPPORT_ACCESS_TOKEN",te="SUPPORT_API_KEY",ee="SUPPORT_KEY_NAME",re="SUPPORT_BASE_URL";var A=class{constructor(t){this._transport=t}getRelativeURL({id:t,vcf:r={}}){let s=r.variant??"vcard",n=r.format??(r.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 l=require("zod"),T=class e{constructor(t){this._transport=t}static SCHEMA=l.z.object({name:l.z.string(),account:l.z.string(),emailAddress:l.z.string().email().optional(),telephoneNumber:l.z.string().optional()});async send({body:t,request:r={}}){return this._transport.send("v1/contacts",{...r,method:"POST",headers:{...r.headers,"Content-Type":"application/json"},body:JSON.stringify(e.SCHEMA.parse(t))}).then(s=>new ht(s))}},ht=class{constructor(t){this.response=t}async result(){return this.response.json()}};var _=class{constructor(t){this._transport=t}async send({id:t,request:r={}}){return this._transport.send("v1/contacts/"+encodeURIComponent(t),{...r,method:"GET"}).then(s=>new ft(s))}},ft=class{constructor(t){this.response=t}async result(){return this.response.json()}};var C=class{constructor(t){this._transport=t}async send({request:t={}}={}){return this._transport.send("v1/contacts",{...t,method:"GET"}).then(r=>new bt(r))}},bt=class{constructor(t){this.response=t}async result(){return this.response.json()}};var E=class{constructor(t){this._transport=t}async send({id:t,request:r={}}){return this._transport.send("v1/labels/"+encodeURIComponent(t)+"/contacts",{...r,method:"GET"}).then(s=>new yt(s))}},yt=class{constructor(t){this.response=t}async result(){return this.response.json()}};var P=require("zod"),O=class e{constructor(t){this._transport=t}static SCHEMA=P.z.object({name:P.z.string().optional(),emailAddress:P.z.string().email().optional(),telephoneNumber:P.z.string().optional()});async send({id:t,body:r,request:s={}}){return this._transport.send("v1/contacts/"+encodeURIComponent(t),{...s,method:"PATCH",headers:{...s.headers,"Content-Type":"application/json"},body:JSON.stringify(e.SCHEMA.parse(r))}).then(n=>new xt(n))}},xt=class{constructor(t){this.response=t}async result(){return this.response.json()}};var S=class{constructor(t){this._transport=t}async send({id:t,request:r={}}){return this._transport.send("v1/conversations/"+encodeURIComponent(t),{...r,method:"GET"}).then(s=>new Rt(s))}},Rt=class{constructor(t){this.response=t}async result(){return this.response.json()}};var w=class{constructor(t){this._transport=t}async send({request:t={}}={}){return this._transport.send("v1/conversations",{...t,method:"GET"}).then(r=>new At(r))}},At=class{constructor(t){this.response=t}async result(){return this.response.json()}};var v=class{constructor(t){this._transport=t}async send({id:t,request:r={}}){return this._transport.send("v1/labels/"+encodeURIComponent(t)+"/conversations",{...r,method:"GET"}).then(s=>new Tt(s))}},Tt=class{constructor(t){this.response=t}async result(){return this.response.json()}};var _t=require("zod"),F=class e{constructor(t){this._transport=t}static SCHEMA=_t.z.object({hasEnded:_t.z.boolean()});async send({id:t,body:r,request:s={}}){return this._transport.send("v1/conversations/"+encodeURIComponent(t),{...s,method:"POST",headers:{...s.headers,"Content-Type":"application/json"},body:JSON.stringify(e.SCHEMA.parse(r))}).then(n=>new Ct(n))}},Ct=class{constructor(t){this.response=t}async result(){return this.response.json()}};var U=require("zod"),I=class e{constructor(t){this._transport=t}static SCHEMA=U.z.object({title:U.z.string(),description:U.z.string().optional(),account:U.z.string()});async send({body:t,request:r={}}){return this._transport.send("v1/labels",{...r,method:"POST",headers:{...r.headers,"Content-Type":"application/json"},body:JSON.stringify(e.SCHEMA.parse(t))}).then(s=>new Et(s))}},Et=class{constructor(t){this.response=t}async result(){return this.response.json()}};var q=class{constructor(t){this._transport=t}async send({id:t,request:r={}}){return this._transport.send("v1/labels/"+encodeURIComponent(t),{...r,method:"DELETE"}).then(s=>new Pt(s))}},Pt=class{constructor(t){this.response=t}async result(){return this.response.json()}};var j=class{constructor(t){this._transport=t}async send({id:t,request:r={}}){return this._transport.send("v1/labels/"+encodeURIComponent(t),{...r,method:"GET"}).then(s=>new Ot(s))}},Ot=class{constructor(t){this.response=t}async result(){return this.response.json()}};var H=class{constructor(t){this._transport=t}async send({request:t={}}={}){return this._transport.send("v1/labels",{...t,method:"GET"}).then(r=>new St(r))}},St=class{constructor(t){this.response=t}async result(){return this.response.json()}};var pt=require("zod"),L=class e{constructor(t){this._transport=t}static SCHEMA=pt.z.object({title:pt.z.string().optional(),description:pt.z.string().optional()});async send({id:t,body:r,request:s={}}){return this._transport.send("v1/labels/"+encodeURIComponent(t),{...s,method:"PATCH",headers:{...s.headers,"Content-Type":"application/json"},body:JSON.stringify(e.SCHEMA.parse(r))}).then(n=>new wt(n))}},wt=class{constructor(t){this.response=t}async result(){return this.response.json()}};var N=class{constructor(t){this._transport=t}async send({id:t,request:r={}}){return this._transport.send("v1/conversations/"+encodeURIComponent(t)+"/messages",{...r,method:"GET"}).then(s=>new vt(s))}},vt=class{constructor(t){this.response=t}async result(){return this.response.json()}};var M=class{constructor(t){this._transport=t}async send({request:t={}}={}){return this._transport.send("v1/messages",{...t,method:"GET"}).then(r=>new Ft(r))}},Ft=class{constructor(t){this.response=t}async result(){return this.response.json()}};var D=require("zod"),G=class e{constructor(t){this._transport=t}static SCHEMA=D.z.object({input:D.z.string().max(65536),original:D.z.string().max(65536),correction:D.z.string().max(65536)});async send({id:t,body:r,request:s={}}){return this._transport.send("v1/models/"+encodeURIComponent(t)+"/correction",{...s,method:"POST",headers:{...s.headers,"Content-Type":"application/json"},body:JSON.stringify(e.SCHEMA.parse(r))}).then(n=>new Ut(n))}},Ut=class{constructor(t){this.response=t}async result(){return this.response.json()}};var z=class{constructor(t){this._transport=t}async send({id:t,request:r={}}){return this._transport.send("v1/models/"+encodeURIComponent(t),{...r,method:"GET"}).then(s=>new It(s))}},It=class{constructor(t){this.response=t}async result(){return this.response.json()}};var B=class{constructor(t){this._transport=t}async send({request:t={}}={}){return this._transport.send("v1/models",{...t,method:"GET"}).then(r=>new qt(r))}},qt=class{constructor(t){this.response=t}async result(){return this.response.json()}};var V=require("zod"),J=class e{constructor(t){this._transport=t}static SCHEMA=V.z.array(V.z.object({role:V.z.enum(["user","assistant"]),content:V.z.string().max(65536).nullable()})).min(1);async send({id:t,body:r,request:s={}}){return this._transport.send("v1/models/"+encodeURIComponent(t)+"/response",{...s,method:"POST",headers:{...s.headers,"Content-Type":"application/json"},body:JSON.stringify(e.SCHEMA.parse(r))}).then(n=>new jt(n))}},jt=class{constructor(t){this.response=t}async result(){return this.response.json()}};var Ht=require("zod"),k=class e{constructor(t){this._transport=t}static SCHEMA=Ht.z.object({content:Ht.z.string()});async send({id:t,body:r,request:s={}}){return this._transport.send("v1/contacts/"+encodeURIComponent(t)+"/notes",{...s,method:"POST",headers:{...s.headers,"Content-Type":"application/json"},body:JSON.stringify(e.SCHEMA.parse(r))}).then(n=>new Lt(n))}},Lt=class{constructor(t){this.response=t}async result(){return this.response.json()}};var Nt=require("zod"),K=class e{constructor(t){this._transport=t}static SCHEMA=Nt.z.object({content:Nt.z.string()});async send({id:t,body:r,request:s={}}){return this._transport.send("v1/conversations/"+encodeURIComponent(t)+"/notes",{...s,method:"POST",headers:{...s.headers,"Content-Type":"application/json"},body:JSON.stringify(e.SCHEMA.parse(r))}).then(n=>new Mt(n))}},Mt=class{constructor(t){this.response=t}async result(){return this.response.json()}};var Y=class{constructor(t){this._transport=t}async send({id:t,request:r={}}){return this._transport.send("v1/notes/"+encodeURIComponent(t),{...r,method:"GET"}).then(s=>new Dt(s))}},Dt=class{constructor(t){this.response=t}async result(){return this.response.json()}};var $=class{constructor(t){this._transport=t}async send({id:t,request:r={}}){return this._transport.send("v1/contacts/"+encodeURIComponent(t)+"/notes",{...r,method:"GET"}).then(s=>new Gt(s))}},Gt=class{constructor(t){this.response=t}async result(){return this.response.json()}};var W=class{constructor(t){this._transport=t}async send({id:t,request:r={}}){return this._transport.send("v1/conversations/"+encodeURIComponent(t)+"/notes",{...r,method:"GET"}).then(s=>new zt(s))}},zt=class{constructor(t){this.response=t}async result(){return this.response.json()}};var Bt=require("zod"),X=class e{constructor(t){this._transport=t}static SCHEMA=Bt.z.object({content:Bt.z.string().optional()});async send({id:t,body:r,request:s={}}){return this._transport.send("v1/notes/"+encodeURIComponent(t),{...s,method:"PATCH",headers:{...s.headers,"Content-Type":"application/json"},body:JSON.stringify(e.SCHEMA.parse(r))}).then(n=>new Vt(n))}},Vt=class{constructor(t){this.response=t}async result(){return this.response.json()}};var Q=class e{constructor(t=e.STANDARD_HEADERS){this._standardHeaders=t}static STANDARD_HEADERS=Xt;async filter(){return{headers:this.getHeaders()}}getHeaders(){return this._standardHeaders}};var Z=class{constructor(t){this._transport=t}async send({id:t,request:r={}}){return this._transport.send("v1/sources/"+encodeURIComponent(t),{...r,method:"GET"}).then(s=>new Jt(s))}},Jt=class{constructor(t){this.response=t}async result(){return this.response.json()}};var tt=class{constructor(t){this._transport=t}async send({request:t={}}={}){return this._transport.send("v1/sources",{...t,method:"GET"}).then(r=>new kt(r))}},kt=class{constructor(t){this.response=t}async result(){return this.response.json()}};var se=Wt(require("is-network-error"),1),ne=Wt(require("ky"),1);var o=class extends Error{};var i=class extends o{};var p=class extends i{static unauthenticated(){return new this("An unauthenticated request occurred")}};var c=class extends i{static forbidden(){return new this("A forbidden request occurred")}};var a=class extends o{static notFound(t){return new this(`Record not found for request: ${t}`)}static forbiddenMethod(t,r){return new this(`Forbidden method for request: ${t} ${r}`)}};var u=class extends o{};var d=class extends o{static badRequest(){return new this("Bad request")}};var et=class{options;constructor({baseURL:t,...r}){this.options={...r,baseURL:t}}getURL(t){return new URL(t,this.options.baseURL).toString()}getRequest(t,r){r.headers=new Headers(r.headers);for(let s of this.options.requestFilterables){let n=s.getHeaders();for(let[oe,ie]of Object.entries(n))r.headers.set(oe,ie)}return new Request(this.getURL(t),r)}async send(t,r){return await(0,ne.default)(this.getRequest(t,r)).then(s=>{if(!s.ok){let n=s.status;switch(console.error(JSON.stringify(s)),n){case 400:throw d.badRequest();case 401:throw p.unauthenticated();case 403:throw c.forbidden();case 404:throw a.notFound(t);case 405:throw a.forbiddenMethod(t,r.method??"GET")}}return s}).catch(s=>{throw(0,se.default)(s)?new u("A network error occurred",{cause:s}):s})}};var m=class e{static DEFAULT_BASE_URL=it;_transport;constructor(t,{baseURL:r,...s}={}){this._transport=new et({requestFilterables:[new Q,t],...s,baseURL:r?.toString()??e.getBaseURL()})}static getBaseURL(){return process.env[re]??this.DEFAULT_BASE_URL}get action(){return{list:new g(this._transport)}}get boilerplate(){return{get:new b(this._transport),list:new y(this._transport),create:new f(this._transport),update:new x(this._transport)}}get channel(){return{list:new R(this._transport)}}get contact(){return{get:new _(this._transport),list:new C(this._transport),update:new O(this._transport),create:new T(this._transport),vcf:{get:new A(this._transport)},note:{list:new $(this._transport),create:new k(this._transport)}}}get conversation(){return{get:new S(this._transport),list:new w(this._transport),update:new F(this._transport),message:{list:new N(this._transport)},note:{list:new W(this._transport),create:new K(this._transport)}}}get label(){return{create:new I(this._transport),get:new j(this._transport),list:new H(this._transport),update:new L(this._transport),delete:new q(this._transport),contact:{list:new E(this._transport)},conversation:{list:new v(this._transport)}}}get message(){return{list:new M(this._transport)}}get model(){return{get:new z(this._transport),list:new B(this._transport),response:{create:new J(this._transport)},correction:{create:new G(this._transport)}}}get note(){return{get:new Y(this._transport),update:new X(this._transport)}}get source(){return{get:new Z(this._transport),list:new tt(this._transport)}}};var Kt={};Yt(Kt,{AuthError:()=>i,AuthenticationError:()=>p,AuthorizationError:()=>c,LogicError:()=>a,NetworkError:()=>u,SupportError:()=>o,ValidationError:()=>d});var rt=class e{static DEFAULT_NAME=Qt;name;#t;constructor({name:t=process.env[ee]??e.DEFAULT_NAME,key:r=process.env[te]}={}){if(!r)throw new Error("API Key option must be specified when using Key Authentication");this.name=t,this.#t=r}async filter(){return{headers:this.getHeaders()}}getHeaders(){return{Authorization:`Basic ${btoa(this.name+":"+this.#t)}`}}};var st=class{#t;constructor({token:t=process.env[Zt]}={}){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 nt=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 xe=Object.create;var lt=Object.defineProperty;var Re=Object.getOwnPropertyDescriptor;var Ae=Object.getOwnPropertyNames;var Ce=Object.getPrototypeOf,Te=Object.prototype.hasOwnProperty;var ie=(e,t)=>{for(var r in t)lt(e,r,{get:t[r],enumerable:!0})},ae=(e,t,r,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Ae(t))!Te.call(e,o)&&o!==r&&lt(e,o,{get:()=>t[o],enumerable:!(s=Re(t,o))||s.enumerable});return e};var pe=(e,t,r)=>(r=e!=null?xe(Ce(e)):{},ae(t||!e||!e.__esModule?lt(r,"default",{value:e,enumerable:!0}):r,e)),_e=e=>ae(lt({},"__esModule",{value:!0}),e);var Pe={};ie(Pe,{Client:()=>m,DEFAULT_SUPPORT_BASE_URL:()=>ut,Error:()=>ne,KeyAuthentication:()=>pt,PublicAuthentication:()=>dt,TokenAuthentication:()=>ct,default:()=>m});module.exports=_e(Pe);var ut="https://api.support.greatdetail.com",ce={"X-Powered-By":"GDSupport/JavaScript"},de="api-key";var g=class{constructor(t){this._transport=t}async send({request:t={}}={}){return this._transport.send("v1/actions",{...t,method:"GET"}).then(r=>new ft(r))}},ft=class{constructor(t){this.response=t}async result(){return this.response.json()}};var h=require("zod"),f=class e{constructor(t){this._transport=t}static SCHEMA=h.z.object({title:h.z.string(),content:h.z.string(),account:h.z.string()});async send({id:t,body:r,request:s={}}){return this._transport.send("v1/boilerplate-categories/"+encodeURIComponent(t)+"/boilerplates",{...s,method:"POST",headers:{...s.headers,"Content-Type":"application/json"},body:JSON.stringify(e.SCHEMA.parse(r))}).then(o=>new yt(o))}},yt=class{constructor(t){this.response=t}async result(){return this.response.json()}};var y=class{constructor(t){this._transport=t}async send({id:t,request:r={}}){return this._transport.send("v1/boilerplates/"+encodeURIComponent(t),{...r,method:"GET"}).then(s=>new bt(s))}},bt=class{constructor(t){this.response=t}async result(){return this.response.json()}};var b=class{constructor(t){this._transport=t}async send({id:t,request:r={}}){return this._transport.send("v1/boilerplate-categories/"+encodeURIComponent(t)+"/boilerplates",{...r,method:"GET"}).then(s=>new xt(s))}},xt=class{constructor(t){this.response=t}async result(){return this.response.json()}};var x=class{constructor(t){this._transport=t}async send({request:t={}}={}){return this._transport.send("v1/boilerplates",{...t,method:"GET"}).then(r=>new Rt(r))}},Rt=class{constructor(t){this.response=t}async result(){return this.response.json()}};var mt=require("zod"),R=class e{constructor(t){this._transport=t}static SCHEMA=mt.z.object({title:mt.z.string().optional(),content:mt.z.string().optional()});async send({id:t,body:r,request:s={}}){return this._transport.send("v1/boilerplates/"+encodeURIComponent(t),{...s,method:"PATCH",headers:{...s.headers,"Content-Type":"application/json"},body:JSON.stringify(e.SCHEMA.parse(r))}).then(o=>new At(o))}},At=class{constructor(t){this.response=t}async result(){return this.response.json()}};var A=require("zod"),C=class e{constructor(t){this._transport=t}static SCHEMA=A.z.object({title:A.z.string(),description:A.z.string().optional(),account:A.z.string()});async send({body:t,request:r={}}){return this._transport.send("v1/boilerplate-categories",{...r,method:"POST",headers:{...r.headers,"Content-Type":"application/json"},body:JSON.stringify(e.SCHEMA.parse(t))}).then(s=>new Ct(s))}},Ct=class{constructor(t){this.response=t}async result(){return this.response.json()}};var T=class{constructor(t){this._transport=t}async send({id:t,request:r={}}){return this._transport.send("v1/boilerplate-categories/"+encodeURIComponent(t),{...r,method:"GET"}).then(s=>new Tt(s))}},Tt=class{constructor(t){this.response=t}async result(){return this.response.json()}};var _=class{constructor(t){this._transport=t}async send({request:t={}}={}){return this._transport.send("v1/boilerplate-categories",{...t,method:"GET"}).then(r=>new _t(r))}},_t=class{constructor(t){this.response=t}async result(){return this.response.json()}};var gt=require("zod"),P=class e{constructor(t){this._transport=t}static SCHEMA=gt.z.object({title:gt.z.string().optional(),description:gt.z.string().optional()});async send({id:t,body:r,request:s={}}){return this._transport.send("v1/boilerplate-categories/"+encodeURIComponent(t),{...s,method:"PATCH",headers:{...s.headers,"Content-Type":"application/json"},body:JSON.stringify(e.SCHEMA.parse(r))}).then(o=>new Pt(o))}},Pt=class{constructor(t){this.response=t}async result(){return this.response.json()}};var E=class{constructor(t){this._transport=t}async send({request:t={}}={}){return this._transport.send("v1/channels",{...t,method:"GET"}).then(r=>new Et(r))}},Et=class{constructor(t){this.response=t}async result(){return this.response.json()}};var le="SUPPORT_ACCESS_TOKEN",ue="SUPPORT_API_KEY",me="SUPPORT_KEY_NAME",ge="SUPPORT_BASE_URL";var O=class{constructor(t){this._transport=t}getRelativeURL({id:t,vcf:r={}}){let s=r.variant??"vcard",o=r.format??(r.variant==="vcard"?"vcf":"json");return"v1/contacts/"+encodeURIComponent(t)+"/vcf?variant="+encodeURIComponent(s)+"&format="+encodeURIComponent(o)}getURL(t){return this._transport.getURL(this.getRelativeURL(t))}};var u=require("zod"),S=class e{constructor(t){this._transport=t}static SCHEMA=u.z.object({name:u.z.string(),account:u.z.string(),emailAddress:u.z.string().email().optional(),telephoneNumber:u.z.string().optional()});async send({body:t,request:r={}}){return this._transport.send("v1/contacts",{...r,method:"POST",headers:{...r.headers,"Content-Type":"application/json"},body:JSON.stringify(e.SCHEMA.parse(t))}).then(s=>new Ot(s))}},Ot=class{constructor(t){this.response=t}async result(){return this.response.json()}};var w=class{constructor(t){this._transport=t}async send({id:t,request:r={}}){return this._transport.send("v1/contacts/"+encodeURIComponent(t),{...r,method:"GET"}).then(s=>new St(s))}},St=class{constructor(t){this.response=t}async result(){return this.response.json()}};var v=class{constructor(t){this._transport=t}async send({request:t={}}={}){return this._transport.send("v1/contacts",{...t,method:"GET"}).then(r=>new wt(r))}},wt=class{constructor(t){this.response=t}async result(){return this.response.json()}};var F=class{constructor(t){this._transport=t}async send({id:t,request:r={}}){return this._transport.send("v1/labels/"+encodeURIComponent(t)+"/contacts",{...r,method:"GET"}).then(s=>new vt(s))}},vt=class{constructor(t){this.response=t}async result(){return this.response.json()}};var U=require("zod"),I=class e{constructor(t){this._transport=t}static SCHEMA=U.z.object({name:U.z.string().optional(),emailAddress:U.z.string().email().optional(),telephoneNumber:U.z.string().optional()});async send({id:t,body:r,request:s={}}){return this._transport.send("v1/contacts/"+encodeURIComponent(t),{...s,method:"PATCH",headers:{...s.headers,"Content-Type":"application/json"},body:JSON.stringify(e.SCHEMA.parse(r))}).then(o=>new Ft(o))}},Ft=class{constructor(t){this.response=t}async result(){return this.response.json()}};var q=class{constructor(t){this._transport=t}async send({id:t,request:r={}}){return this._transport.send("v1/conversations/"+encodeURIComponent(t),{...r,method:"GET"}).then(s=>new Ut(s))}},Ut=class{constructor(t){this.response=t}async result(){return this.response.json()}};var j=class{constructor(t){this._transport=t}async send({request:t={}}={}){return this._transport.send("v1/conversations",{...t,method:"GET"}).then(r=>new It(r))}},It=class{constructor(t){this.response=t}async result(){return this.response.json()}};var H=class{constructor(t){this._transport=t}async send({id:t,request:r={}}){return this._transport.send("v1/labels/"+encodeURIComponent(t)+"/conversations",{...r,method:"GET"}).then(s=>new qt(s))}},qt=class{constructor(t){this.response=t}async result(){return this.response.json()}};var jt=require("zod"),L=class e{constructor(t){this._transport=t}static SCHEMA=jt.z.object({hasEnded:jt.z.boolean()});async send({id:t,body:r,request:s={}}){return this._transport.send("v1/conversations/"+encodeURIComponent(t),{...s,method:"POST",headers:{...s.headers,"Content-Type":"application/json"},body:JSON.stringify(e.SCHEMA.parse(r))}).then(o=>new Ht(o))}},Ht=class{constructor(t){this.response=t}async result(){return this.response.json()}};var N=require("zod"),M=class e{constructor(t){this._transport=t}static SCHEMA=N.z.object({title:N.z.string(),description:N.z.string().optional(),account:N.z.string()});async send({body:t,request:r={}}){return this._transport.send("v1/labels",{...r,method:"POST",headers:{...r.headers,"Content-Type":"application/json"},body:JSON.stringify(e.SCHEMA.parse(t))}).then(s=>new Lt(s))}},Lt=class{constructor(t){this.response=t}async result(){return this.response.json()}};var G=class{constructor(t){this._transport=t}async send({id:t,request:r={}}){return this._transport.send("v1/labels/"+encodeURIComponent(t),{...r,method:"DELETE"}).then(s=>new Nt(s))}},Nt=class{constructor(t){this.response=t}async result(){return this.response.json()}};var z=class{constructor(t){this._transport=t}async send({id:t,request:r={}}){return this._transport.send("v1/labels/"+encodeURIComponent(t),{...r,method:"GET"}).then(s=>new Mt(s))}},Mt=class{constructor(t){this.response=t}async result(){return this.response.json()}};var B=class{constructor(t){this._transport=t}async send({request:t={}}={}){return this._transport.send("v1/labels",{...t,method:"GET"}).then(r=>new Gt(r))}},Gt=class{constructor(t){this.response=t}async result(){return this.response.json()}};var ht=require("zod"),D=class e{constructor(t){this._transport=t}static SCHEMA=ht.z.object({title:ht.z.string().optional(),description:ht.z.string().optional()});async send({id:t,body:r,request:s={}}){return this._transport.send("v1/labels/"+encodeURIComponent(t),{...s,method:"PATCH",headers:{...s.headers,"Content-Type":"application/json"},body:JSON.stringify(e.SCHEMA.parse(r))}).then(o=>new zt(o))}},zt=class{constructor(t){this.response=t}async result(){return this.response.json()}};var V=class{constructor(t){this._transport=t}async send({id:t,request:r={}}){return this._transport.send("v1/conversations/"+encodeURIComponent(t)+"/messages",{...r,method:"GET"}).then(s=>new Bt(s))}},Bt=class{constructor(t){this.response=t}async result(){return this.response.json()}};var J=class{constructor(t){this._transport=t}async send({request:t={}}={}){return this._transport.send("v1/messages",{...t,method:"GET"}).then(r=>new Dt(r))}},Dt=class{constructor(t){this.response=t}async result(){return this.response.json()}};var k=require("zod"),K=class e{constructor(t){this._transport=t}static SCHEMA=k.z.object({input:k.z.string().max(65536),original:k.z.string().max(65536),correction:k.z.string().max(65536)});async send({id:t,body:r,request:s={}}){return this._transport.send("v1/models/"+encodeURIComponent(t)+"/correction",{...s,method:"POST",headers:{...s.headers,"Content-Type":"application/json"},body:JSON.stringify(e.SCHEMA.parse(r))}).then(o=>new Vt(o))}},Vt=class{constructor(t){this.response=t}async result(){return this.response.json()}};var Y=class{constructor(t){this._transport=t}async send({id:t,request:r={}}){return this._transport.send("v1/models/"+encodeURIComponent(t),{...r,method:"GET"}).then(s=>new Jt(s))}},Jt=class{constructor(t){this.response=t}async result(){return this.response.json()}};var $=class{constructor(t){this._transport=t}async send({request:t={}}={}){return this._transport.send("v1/models",{...t,method:"GET"}).then(r=>new kt(r))}},kt=class{constructor(t){this.response=t}async result(){return this.response.json()}};var W=require("zod"),X=class e{constructor(t){this._transport=t}static SCHEMA=W.z.array(W.z.object({role:W.z.enum(["user","assistant"]),content:W.z.string().max(65536).nullable()})).min(1);async send({id:t,body:r,request:s={}}){return this._transport.send("v1/models/"+encodeURIComponent(t)+"/response",{...s,method:"POST",headers:{...s.headers,"Content-Type":"application/json"},body:JSON.stringify(e.SCHEMA.parse(r))}).then(o=>new Kt(o))}},Kt=class{constructor(t){this.response=t}async result(){return this.response.json()}};var Yt=require("zod"),Q=class e{constructor(t){this._transport=t}static SCHEMA=Yt.z.object({content:Yt.z.string()});async send({id:t,body:r,request:s={}}){return this._transport.send("v1/contacts/"+encodeURIComponent(t)+"/notes",{...s,method:"POST",headers:{...s.headers,"Content-Type":"application/json"},body:JSON.stringify(e.SCHEMA.parse(r))}).then(o=>new $t(o))}},$t=class{constructor(t){this.response=t}async result(){return this.response.json()}};var Wt=require("zod"),Z=class e{constructor(t){this._transport=t}static SCHEMA=Wt.z.object({content:Wt.z.string()});async send({id:t,body:r,request:s={}}){return this._transport.send("v1/conversations/"+encodeURIComponent(t)+"/notes",{...s,method:"POST",headers:{...s.headers,"Content-Type":"application/json"},body:JSON.stringify(e.SCHEMA.parse(r))}).then(o=>new Xt(o))}},Xt=class{constructor(t){this.response=t}async result(){return this.response.json()}};var tt=class{constructor(t){this._transport=t}async send({id:t,request:r={}}){return this._transport.send("v1/notes/"+encodeURIComponent(t),{...r,method:"GET"}).then(s=>new Qt(s))}},Qt=class{constructor(t){this.response=t}async result(){return this.response.json()}};var et=class{constructor(t){this._transport=t}async send({id:t,request:r={}}){return this._transport.send("v1/contacts/"+encodeURIComponent(t)+"/notes",{...r,method:"GET"}).then(s=>new Zt(s))}},Zt=class{constructor(t){this.response=t}async result(){return this.response.json()}};var rt=class{constructor(t){this._transport=t}async send({id:t,request:r={}}){return this._transport.send("v1/conversations/"+encodeURIComponent(t)+"/notes",{...r,method:"GET"}).then(s=>new te(s))}},te=class{constructor(t){this.response=t}async result(){return this.response.json()}};var ee=require("zod"),st=class e{constructor(t){this._transport=t}static SCHEMA=ee.z.object({content:ee.z.string().optional()});async send({id:t,body:r,request:s={}}){return this._transport.send("v1/notes/"+encodeURIComponent(t),{...s,method:"PATCH",headers:{...s.headers,"Content-Type":"application/json"},body:JSON.stringify(e.SCHEMA.parse(r))}).then(o=>new re(o))}},re=class{constructor(t){this.response=t}async result(){return this.response.json()}};var ot=class e{constructor(t=e.STANDARD_HEADERS){this._standardHeaders=t}static STANDARD_HEADERS=ce;async filter(){return{headers:this.getHeaders()}}getHeaders(){return this._standardHeaders}};var nt=class{constructor(t){this._transport=t}async send({id:t,request:r={}}){return this._transport.send("v1/sources/"+encodeURIComponent(t),{...r,method:"GET"}).then(s=>new se(s))}},se=class{constructor(t){this.response=t}async result(){return this.response.json()}};var it=class{constructor(t){this._transport=t}async send({request:t={}}={}){return this._transport.send("v1/sources",{...t,method:"GET"}).then(r=>new oe(r))}},oe=class{constructor(t){this.response=t}async result(){return this.response.json()}};var he=pe(require("is-network-error"),1),fe=pe(require("ky"),1);var n=class extends Error{};var i=class extends n{};var p=class extends i{static unauthenticated(){return new this("An unauthenticated request occurred")}};var c=class extends i{static forbidden(){return new this("A forbidden request occurred")}};var a=class extends n{static notFound(t){return new this(`Record not found for request: ${t}`)}static forbiddenMethod(t,r){return new this(`Forbidden method for request: ${t} ${r}`)}};var d=class extends n{};var l=class extends n{static badRequest(){return new this("Bad request")}};var at=class{options;constructor({baseURL:t,...r}){this.options={...r,baseURL:t}}getURL(t){return new URL(t,this.options.baseURL).toString()}getRequest(t,r){r.headers=new Headers(r.headers);for(let s of this.options.requestFilterables){let o=s.getHeaders();for(let[ye,be]of Object.entries(o))r.headers.set(ye,be)}return new Request(this.getURL(t),r)}async send(t,r){return await(0,fe.default)(this.getRequest(t,r)).then(s=>{if(!s.ok){let o=s.status;switch(console.error(JSON.stringify(s)),o){case 400:throw l.badRequest();case 401:throw p.unauthenticated();case 403:throw c.forbidden();case 404:throw a.notFound(t);case 405:throw a.forbiddenMethod(t,r.method??"GET")}}return s}).catch(s=>{throw(0,he.default)(s)?new d("A network error occurred",{cause:s}):s})}};var m=class e{static DEFAULT_BASE_URL=ut;_transport;constructor(t,{baseURL:r,...s}={}){this._transport=new at({requestFilterables:[new ot,t],...s,baseURL:r?.toString()??e.getBaseURL()})}static getBaseURL(){return process.env[ge]??this.DEFAULT_BASE_URL}get action(){return{list:new g(this._transport)}}get boilerplate(){return{get:new y(this._transport),list:new x(this._transport),update:new R(this._transport)}}get boilerplateCategory(){return{get:new T(this._transport),list:new _(this._transport),create:new C(this._transport),update:new P(this._transport),boilerplate:{list:new b(this._transport),create:new f(this._transport)}}}get channel(){return{list:new E(this._transport)}}get contact(){return{get:new w(this._transport),list:new v(this._transport),update:new I(this._transport),create:new S(this._transport),vcf:{get:new O(this._transport)},note:{list:new et(this._transport),create:new Q(this._transport)}}}get conversation(){return{get:new q(this._transport),list:new j(this._transport),update:new L(this._transport),message:{list:new V(this._transport)},note:{list:new rt(this._transport),create:new Z(this._transport)}}}get label(){return{create:new M(this._transport),get:new z(this._transport),list:new B(this._transport),update:new D(this._transport),delete:new G(this._transport),contact:{list:new F(this._transport)},conversation:{list:new H(this._transport)}}}get message(){return{list:new J(this._transport)}}get model(){return{get:new Y(this._transport),list:new $(this._transport),response:{create:new X(this._transport)},correction:{create:new K(this._transport)}}}get note(){return{get:new tt(this._transport),update:new st(this._transport)}}get source(){return{get:new nt(this._transport),list:new it(this._transport)}}};var ne={};ie(ne,{AuthError:()=>i,AuthenticationError:()=>p,AuthorizationError:()=>c,LogicError:()=>a,NetworkError:()=>d,SupportError:()=>n,ValidationError:()=>l});var pt=class e{static DEFAULT_NAME=de;name;#t;constructor({name:t=process.env[me]??e.DEFAULT_NAME,key:r=process.env[ue]}={}){if(!r)throw new Error("API Key option must be specified when using Key Authentication");this.name=t,this.#t=r}async filter(){return{headers:this.getHeaders()}}getHeaders(){return{Authorization:`Basic ${btoa(this.name+":"+this.#t)}`}}};var ct=class{#t;constructor({token:t=process.env[le]}={}){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 dt=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-BMsEq65I.cjs';
2
- export { C as Client, b as CreateBoilerplateResponsePayload, x as CreateContactNoteResponsePayload, e as CreateContactResponsePayload, y as CreateConversationNoteResponsePayload, v as CreateCorrectionResponsePayload, n as CreateLabelResponsePayload, w as CreateResponseResponsePayload, D as DeleteLabelResponsePayload, G as GetBoilerplateResponsePayload, f as GetContactResponsePayload, j as GetConversationResponsePayload, o as GetLabelResponsePayload, t as GetModelResponsePayload, z as GetNoteResponsePayload, H as GetSourceResponsePayload, L as ListActionsResponsePayload, c as ListBoilerplatesResponsePayload, d as ListChannelsResponsePayload, B as ListContactNotesResponsePayload, g as ListContactsResponsePayload, r as ListConversationMessagesResponsePayload, E as ListConversationNotesResponsePayload, k as ListConversationsResponsePayload, h as ListLabelContactsResponsePayload, l as ListLabelConversationsResponsePayload, p as ListLabelsResponsePayload, s as ListMessagesResponsePayload, u as ListModelsResponsePayload, I as ListSourcesResponsePayload, O as Options, R as RequestFilterable, a as TransportOptions, U as UpdateBoilerplateResponsePayload, i as UpdateContactResponsePayload, m as UpdateConversationResponsePayload, q as UpdateLabelResponsePayload, F as UpdateNoteResponsePayload, C as default } from './index-BMsEq65I.cjs';
1
+ import { A as Authentication } from './index-ng6eKA5J.cjs';
2
+ export { C as Client, b as CreateBoilerplateCategoryBoilerplateResponsePayload, e as CreateBoilerplateCategoryResponsePayload, F as CreateContactNoteResponsePayload, j as CreateContactResponsePayload, H as CreateConversationNoteResponsePayload, B as CreateCorrectionResponsePayload, s as CreateLabelResponsePayload, E as CreateResponseResponsePayload, D as DeleteLabelResponsePayload, f as GetBoilerplateCategoryResponsePayload, G as GetBoilerplateResponsePayload, k as GetContactResponsePayload, o as GetConversationResponsePayload, t as GetLabelResponsePayload, y as GetModelResponsePayload, I as GetNoteResponsePayload, N as GetSourceResponsePayload, L as ListActionsResponsePayload, g as ListBoilerplateCategoriesResponsePayload, c as ListBoilerplateCategoryBoilerplatesResponsePayload, d as ListBoilerplatesResponsePayload, i as ListChannelsResponsePayload, J as ListContactNotesResponsePayload, l as ListContactsResponsePayload, w as ListConversationMessagesResponsePayload, K as ListConversationNotesResponsePayload, p as ListConversationsResponsePayload, m as ListLabelContactsResponsePayload, q as ListLabelConversationsResponsePayload, u as ListLabelsResponsePayload, x as ListMessagesResponsePayload, z as ListModelsResponsePayload, P as ListSourcesResponsePayload, O as Options, R as RequestFilterable, a as TransportOptions, h as UpdateBoilerplateCategoryResponsePayload, U as UpdateBoilerplateResponsePayload, n as UpdateContactResponsePayload, r as UpdateConversationResponsePayload, v as UpdateLabelResponsePayload, M as UpdateNoteResponsePayload, C as default } from './index-ng6eKA5J.cjs';
3
3
  import 'ky';
4
4
  import 'zod';
5
5
 
@@ -212,4 +212,21 @@ declare class PublicAuthentication implements Authentication {
212
212
  getHeaders(): {};
213
213
  }
214
214
 
215
- export { DEFAULT_SUPPORT_BASE_URL, index as Error, KeyAuthentication, PublicAuthentication, TokenAuthentication };
215
+ /**
216
+ * Great Detail Support System.
217
+ *
218
+ * @copyright 2024 Great Detail Ltd
219
+ * @author Great Detail Ltd <info@greatdetail.com>
220
+ * @author Dom Webber <dom.webber@greatdetail.com>
221
+ * @see https://greatdetail.com
222
+ */
223
+
224
+ type CreateContactSubscriptionResponsePayload = {
225
+ subscription: {
226
+ id: string;
227
+ createdAt: string;
228
+ updatedAt: string;
229
+ };
230
+ };
231
+
232
+ export { type CreateContactSubscriptionResponsePayload, DEFAULT_SUPPORT_BASE_URL, index as Error, KeyAuthentication, PublicAuthentication, TokenAuthentication };
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { A as Authentication } from './index-BMsEq65I.js';
2
- export { C as Client, b as CreateBoilerplateResponsePayload, x as CreateContactNoteResponsePayload, e as CreateContactResponsePayload, y as CreateConversationNoteResponsePayload, v as CreateCorrectionResponsePayload, n as CreateLabelResponsePayload, w as CreateResponseResponsePayload, D as DeleteLabelResponsePayload, G as GetBoilerplateResponsePayload, f as GetContactResponsePayload, j as GetConversationResponsePayload, o as GetLabelResponsePayload, t as GetModelResponsePayload, z as GetNoteResponsePayload, H as GetSourceResponsePayload, L as ListActionsResponsePayload, c as ListBoilerplatesResponsePayload, d as ListChannelsResponsePayload, B as ListContactNotesResponsePayload, g as ListContactsResponsePayload, r as ListConversationMessagesResponsePayload, E as ListConversationNotesResponsePayload, k as ListConversationsResponsePayload, h as ListLabelContactsResponsePayload, l as ListLabelConversationsResponsePayload, p as ListLabelsResponsePayload, s as ListMessagesResponsePayload, u as ListModelsResponsePayload, I as ListSourcesResponsePayload, O as Options, R as RequestFilterable, a as TransportOptions, U as UpdateBoilerplateResponsePayload, i as UpdateContactResponsePayload, m as UpdateConversationResponsePayload, q as UpdateLabelResponsePayload, F as UpdateNoteResponsePayload, C as default } from './index-BMsEq65I.js';
1
+ import { A as Authentication } from './index-ng6eKA5J.js';
2
+ export { C as Client, b as CreateBoilerplateCategoryBoilerplateResponsePayload, e as CreateBoilerplateCategoryResponsePayload, F as CreateContactNoteResponsePayload, j as CreateContactResponsePayload, H as CreateConversationNoteResponsePayload, B as CreateCorrectionResponsePayload, s as CreateLabelResponsePayload, E as CreateResponseResponsePayload, D as DeleteLabelResponsePayload, f as GetBoilerplateCategoryResponsePayload, G as GetBoilerplateResponsePayload, k as GetContactResponsePayload, o as GetConversationResponsePayload, t as GetLabelResponsePayload, y as GetModelResponsePayload, I as GetNoteResponsePayload, N as GetSourceResponsePayload, L as ListActionsResponsePayload, g as ListBoilerplateCategoriesResponsePayload, c as ListBoilerplateCategoryBoilerplatesResponsePayload, d as ListBoilerplatesResponsePayload, i as ListChannelsResponsePayload, J as ListContactNotesResponsePayload, l as ListContactsResponsePayload, w as ListConversationMessagesResponsePayload, K as ListConversationNotesResponsePayload, p as ListConversationsResponsePayload, m as ListLabelContactsResponsePayload, q as ListLabelConversationsResponsePayload, u as ListLabelsResponsePayload, x as ListMessagesResponsePayload, z as ListModelsResponsePayload, P as ListSourcesResponsePayload, O as Options, R as RequestFilterable, a as TransportOptions, h as UpdateBoilerplateCategoryResponsePayload, U as UpdateBoilerplateResponsePayload, n as UpdateContactResponsePayload, r as UpdateConversationResponsePayload, v as UpdateLabelResponsePayload, M as UpdateNoteResponsePayload, C as default } from './index-ng6eKA5J.js';
3
3
  import 'ky';
4
4
  import 'zod';
5
5
 
@@ -212,4 +212,21 @@ declare class PublicAuthentication implements Authentication {
212
212
  getHeaders(): {};
213
213
  }
214
214
 
215
- export { DEFAULT_SUPPORT_BASE_URL, index as Error, KeyAuthentication, PublicAuthentication, TokenAuthentication };
215
+ /**
216
+ * Great Detail Support System.
217
+ *
218
+ * @copyright 2024 Great Detail Ltd
219
+ * @author Great Detail Ltd <info@greatdetail.com>
220
+ * @author Dom Webber <dom.webber@greatdetail.com>
221
+ * @see https://greatdetail.com
222
+ */
223
+
224
+ type CreateContactSubscriptionResponsePayload = {
225
+ subscription: {
226
+ id: string;
227
+ createdAt: string;
228
+ updatedAt: string;
229
+ };
230
+ };
231
+
232
+ export { type CreateContactSubscriptionResponsePayload, DEFAULT_SUPPORT_BASE_URL, index as Error, KeyAuthentication, PublicAuthentication, TokenAuthentication };
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- import{a as d,b as g,c as s,d as n,e as a,f as p,g as f,h as u,i as m,j as c,k as l,l as x,m as A,n as h,o as _}from"./chunk-KG7KNOPC.js";var E={};d(E,{AuthError:()=>u,AuthenticationError:()=>m,AuthorizationError:()=>c,LogicError:()=>l,NetworkError:()=>x,SupportError:()=>f,ValidationError:()=>A});var r=class o{static DEFAULT_NAME=s;name;#t;constructor({name:t=process.env[p]??o.DEFAULT_NAME,key:i=process.env[a]}={}){if(!i)throw new Error("API Key option must be specified when using Key Authentication");this.name=t,this.#t=i}async filter(){return{headers:this.getHeaders()}}getHeaders(){return{Authorization:`Basic ${btoa(this.name+":"+this.#t)}`}}};var e=class{#t;constructor({token:t=process.env[n]}={}){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}`}}};export{h as Client,g as DEFAULT_SUPPORT_BASE_URL,E as Error,r as KeyAuthentication,_ as PublicAuthentication,e as TokenAuthentication,h as default};
1
+ import{a as d,b as g,c as s,d as n,e as a,f as p,g as f,h as m,i as u,j as c,k as l,l as x,m as A,n as h,o as _}from"./chunk-O5KZWMF7.js";var E={};d(E,{AuthError:()=>m,AuthenticationError:()=>u,AuthorizationError:()=>c,LogicError:()=>l,NetworkError:()=>x,SupportError:()=>f,ValidationError:()=>A});var t=class o{static DEFAULT_NAME=s;name;#r;constructor({name:r=process.env[p]??o.DEFAULT_NAME,key:i=process.env[a]}={}){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[n]}={}){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{h as Client,g as DEFAULT_SUPPORT_BASE_URL,E as Error,t as KeyAuthentication,_ as PublicAuthentication,e as TokenAuthentication,h as default};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@great-detail/support-sdk",
3
- "version": "0.2.9",
3
+ "version": "0.3.0",
4
4
  "type": "module",
5
5
  "description": "JavaScript SDK for the Great Detail Support System",
6
6
  "author": "Great Detail Ltd <info@greatdetail.com>",
@@ -0,0 +1,68 @@
1
+ /**
2
+ * Great Detail Support System.
3
+ *
4
+ * @copyright 2024 Great Detail Ltd
5
+ * @author Great Detail Ltd <info@greatdetail.com>
6
+ * @author Dom Webber <dom.webber@greatdetail.com>
7
+ * @see https://greatdetail.com
8
+ */
9
+
10
+ import { z } from "zod";
11
+ import FetchTransport from "../Transport/FetchTransport.js";
12
+
13
+ export interface Options {
14
+ id: string;
15
+ body: z.infer<typeof CreateBoilerplateCategoryBoilerplate.SCHEMA>;
16
+ request?: RequestInit;
17
+ }
18
+
19
+ export default class CreateBoilerplateCategoryBoilerplate {
20
+ public static SCHEMA = z.object({
21
+ title: z.string(),
22
+ content: z.string(),
23
+ account: z.string(),
24
+ });
25
+
26
+ constructor(protected _transport: FetchTransport) {}
27
+
28
+ public async send({ id, body, request = {} }: Options) {
29
+ return this._transport
30
+ .send(
31
+ "v1/boilerplate-categories/" + encodeURIComponent(id) + "/boilerplates",
32
+ {
33
+ ...request,
34
+ method: "POST",
35
+ headers: {
36
+ ...request.headers,
37
+ "Content-Type": "application/json",
38
+ },
39
+ body: JSON.stringify(
40
+ CreateBoilerplateCategoryBoilerplate.SCHEMA.parse(body),
41
+ ),
42
+ },
43
+ )
44
+ .then(
45
+ (response) =>
46
+ new CreateBoilerplateCategoryBoilerplateResponse(response),
47
+ );
48
+ }
49
+ }
50
+
51
+ export type CreateBoilerplateCategoryBoilerplateResponsePayload = {
52
+ boilerplate: {
53
+ id: string;
54
+ title: string;
55
+ content: string;
56
+ account: string;
57
+ createdAt: string;
58
+ updatedAt: string;
59
+ };
60
+ };
61
+
62
+ export class CreateBoilerplateCategoryBoilerplateResponse {
63
+ constructor(public response: Response) {}
64
+
65
+ public async result(): Promise<CreateBoilerplateCategoryBoilerplateResponsePayload> {
66
+ return this.response.json();
67
+ }
68
+ }
@@ -33,6 +33,7 @@ export type GetBoilerplateResponsePayload = {
33
33
  title: string;
34
34
  content: string;
35
35
  account: string;
36
+ boilerplateCategory: string;
36
37
  createdAt: string;
37
38
  updatedAt: string;
38
39
  };