@great-detail/support-sdk 0.0.4 → 0.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. package/README.md +59 -0
  2. package/dist/chunk-CQGIX6CO.js +1 -0
  3. package/dist/chunk-OVSCTY74.js +1 -0
  4. package/dist/cli/index.cjs +1 -0
  5. package/dist/cli/index.d.cts +21 -0
  6. package/dist/cli/index.d.ts +21 -0
  7. package/dist/cli/index.js +1 -0
  8. package/dist/cli.cjs +1 -1
  9. package/dist/cli.js +1 -1
  10. package/dist/index-zrmJVCfU.d.cts +684 -0
  11. package/dist/index-zrmJVCfU.d.ts +684 -0
  12. package/dist/index.cjs +1 -1
  13. package/dist/index.d.cts +8 -518
  14. package/dist/index.d.ts +8 -518
  15. package/dist/index.js +1 -1
  16. package/package.json +8 -2
  17. package/src/Action/ListActions.ts +6 -2
  18. package/src/Authentication/KeyAuthentication.ts +7 -3
  19. package/src/Authentication/TokenAuthentication.ts +2 -1
  20. package/src/Channel/ListChannels.ts +20 -3
  21. package/src/Client/index.ts +8 -0
  22. package/src/Contact/GetContact.ts +52 -0
  23. package/src/Contact/ListContacts.ts +1 -0
  24. package/src/Label/CreateLabel.ts +1 -0
  25. package/src/Label/GetLabel.ts +51 -0
  26. package/src/Label/ListLabels.ts +1 -0
  27. package/src/Message/ListMessages.ts +7 -0
  28. package/src/Model/GetModel.ts +50 -0
  29. package/src/Model/ListModels.ts +2 -2
  30. package/src/Source/GetSource.ts +51 -0
  31. package/src/Source/ListSources.ts +2 -1
  32. package/src/__tests__/Authentication/KeyAuthentication.test.ts +79 -0
  33. package/src/__tests__/Authentication/TokenAuthentication.test.ts +79 -0
  34. package/src/cli/contacts.ts +14 -0
  35. package/src/cli/labels.ts +14 -0
  36. package/src/cli/models.ts +14 -0
  37. package/src/cli/sources.ts +14 -0
  38. package/src/constants/index.ts +21 -0
  39. package/dist/chunk-WCSPJBPY.js +0 -1
package/dist/index.d.ts CHANGED
@@ -1,4 +1,6 @@
1
- import { z } from 'zod';
1
+ import { A as Authentication } from './index-zrmJVCfU.js';
2
+ export { C as Client, h as CreateCorrectionResponsePayload, d as CreateLabelResponsePayload, i as CreateResponseResponsePayload, G as GetConversationResponsePayload, L as ListActionsResponsePayload, a as ListChannelsResponsePayload, b as ListContactsResponsePayload, c as ListConversationsResponsePayload, e as ListLabelsResponsePayload, f as ListMessagesResponsePayload, g as ListModelsResponsePayload, j as ListSourcesResponsePayload, R as RequestFilterable, C as default } from './index-zrmJVCfU.js';
3
+ import 'zod';
2
4
 
3
5
  /**
4
6
  * Great Detail Support System.
@@ -15,30 +17,6 @@ import { z } from 'zod';
15
17
  */
16
18
  declare const DEFAULT_SUPPORT_BASE_URL = "https://api.support.greatdetail.com";
17
19
 
18
- /**
19
- * Great Detail Support System.
20
- *
21
- * @copyright 2024 Great Detail Ltd
22
- * @author Great Detail Ltd <info@greatdetail.com>
23
- * @author Dom Webber <dom.webber@greatdetail.com>
24
- * @see https://greatdetail.com
25
- */
26
- interface RequestFilterable {
27
- filter(request: RequestInit): Promise<RequestInit>;
28
- }
29
-
30
- /**
31
- * Great Detail Support System.
32
- *
33
- * @copyright 2024 Great Detail Ltd
34
- * @author Great Detail Ltd <info@greatdetail.com>
35
- * @author Dom Webber <dom.webber@greatdetail.com>
36
- * @see https://greatdetail.com
37
- */
38
-
39
- interface Authentication extends RequestFilterable {
40
- }
41
-
42
20
  /**
43
21
  * Great Detail Support System.
44
22
  *
@@ -48,7 +26,7 @@ interface Authentication extends RequestFilterable {
48
26
  * @see https://greatdetail.com
49
27
  */
50
28
 
51
- interface Options$d {
29
+ interface Options$1 {
52
30
  name?: string;
53
31
  key?: string;
54
32
  }
@@ -56,7 +34,7 @@ declare class KeyAuthentication implements Authentication {
56
34
  #private;
57
35
  static DEFAULT_NAME: string;
58
36
  name: string;
59
- constructor({ name, key, }?: Options$d);
37
+ constructor({ name, key, }?: Options$1);
60
38
  filter(request: RequestInit): Promise<RequestInit>;
61
39
  }
62
40
 
@@ -69,12 +47,12 @@ declare class KeyAuthentication implements Authentication {
69
47
  * @see https://greatdetail.com
70
48
  */
71
49
 
72
- interface Options$c {
50
+ interface Options {
73
51
  token?: string;
74
52
  }
75
53
  declare class TokenAuthentication implements Authentication {
76
54
  #private;
77
- constructor({ token }?: Options$c);
55
+ constructor({ token }?: Options);
78
56
  filter(request: RequestInit): Promise<RequestInit>;
79
57
  }
80
58
 
@@ -97,492 +75,4 @@ declare class PublicAuthentication implements Authentication {
97
75
  filter(request: RequestInit): Promise<RequestInit>;
98
76
  }
99
77
 
100
- /**
101
- * Great Detail Support System.
102
- *
103
- * @copyright 2024 Great Detail Ltd
104
- * @author Great Detail Ltd <info@greatdetail.com>
105
- * @author Dom Webber <dom.webber@greatdetail.com>
106
- * @see https://greatdetail.com
107
- */
108
-
109
- interface Options$b extends SendOptions {
110
- request?: RequestInit;
111
- }
112
- declare class ListActionsRequest {
113
- protected _client: Client;
114
- constructor(_client: Client);
115
- send({ request, ...options }?: Options$b): Promise<ListActionsResponse>;
116
- }
117
- type ListActionsResponsePayload = {
118
- actions: {
119
- id: string;
120
- actionStatus: string;
121
- object?: unknown;
122
- result?: unknown;
123
- startedAt?: string;
124
- endedAt?: string;
125
- }[];
126
- };
127
- declare class ListActionsResponse {
128
- response: Response;
129
- constructor(response: Response);
130
- result(): Promise<ListActionsResponsePayload>;
131
- }
132
-
133
- /**
134
- * Great Detail Support System.
135
- *
136
- * @copyright 2024 Great Detail Ltd
137
- * @author Great Detail Ltd <info@greatdetail.com>
138
- * @author Dom Webber <dom.webber@greatdetail.com>
139
- * @see https://greatdetail.com
140
- */
141
-
142
- interface Options$a extends SendOptions {
143
- request?: RequestInit;
144
- }
145
- declare class ListChannelsRequest {
146
- protected _client: Client;
147
- constructor(_client: Client);
148
- send({ request, ...options }?: Options$a): Promise<ListChannelsResponse>;
149
- }
150
- type ListChannelsResponsePayload = {
151
- channels: {
152
- id: string;
153
- name?: string;
154
- channelStatus: "ActiveChannelStatus" | "PotentialChannelStatus";
155
- source: "twilio-sendgrid" | "meta-whatsapp";
156
- createdAt: string;
157
- updatedAt?: string;
158
- }[];
159
- };
160
- declare class ListChannelsResponse {
161
- response: Response;
162
- constructor(response: Response);
163
- result(): Promise<ListChannelsResponsePayload>;
164
- }
165
-
166
- /**
167
- * Great Detail Support System.
168
- *
169
- * @copyright 2024 Great Detail Ltd
170
- * @author Great Detail Ltd <info@greatdetail.com>
171
- * @author Dom Webber <dom.webber@greatdetail.com>
172
- * @see https://greatdetail.com
173
- */
174
-
175
- interface Options$9 extends SendOptions {
176
- request?: RequestInit;
177
- }
178
- declare class ListContactsRequest {
179
- protected _client: Client;
180
- constructor(_client: Client);
181
- send({ request, ...options }?: Options$9): Promise<ListContactsResponse>;
182
- }
183
- type ListContactsResponsePayload = {
184
- contacts: {
185
- id: string;
186
- name?: string;
187
- emailAddress?: string;
188
- telephoneNumber?: string;
189
- createdAt: string;
190
- updatedAt?: string;
191
- }[];
192
- };
193
- declare class ListContactsResponse {
194
- response: Response;
195
- constructor(response: Response);
196
- result(): Promise<ListContactsResponsePayload>;
197
- }
198
-
199
- /**
200
- * Great Detail Support System.
201
- *
202
- * @copyright 2024 Great Detail Ltd
203
- * @author Great Detail Ltd <info@greatdetail.com>
204
- * @author Dom Webber <dom.webber@greatdetail.com>
205
- * @see https://greatdetail.com
206
- */
207
-
208
- interface Options$8 extends SendOptions {
209
- id: string;
210
- request?: RequestInit;
211
- }
212
- declare class GetConversationRequest {
213
- protected _client: Client;
214
- constructor(_client: Client);
215
- send({ id, request, ...options }: Options$8): Promise<GetConversationResponse>;
216
- }
217
- type GetConversationResponsePayload = {
218
- conversation: {
219
- id: string;
220
- hasEnded: boolean;
221
- accountChannel: string;
222
- createdAt: string;
223
- updatedAt: string;
224
- };
225
- };
226
- declare class GetConversationResponse {
227
- response: Response;
228
- constructor(response: Response);
229
- result(): Promise<GetConversationResponsePayload>;
230
- }
231
-
232
- /**
233
- * Great Detail Support System.
234
- *
235
- * @copyright 2024 Great Detail Ltd
236
- * @author Great Detail Ltd <info@greatdetail.com>
237
- * @author Dom Webber <dom.webber@greatdetail.com>
238
- * @see https://greatdetail.com
239
- */
240
-
241
- interface Options$7 extends SendOptions {
242
- request?: RequestInit;
243
- }
244
- declare class ListConversationsRequest {
245
- protected _client: Client;
246
- constructor(_client: Client);
247
- send({ request, ...options }?: Options$7): Promise<ListConversationsResponse>;
248
- }
249
- type ListConversationsResponsePayload = {
250
- conversations: {
251
- id: string;
252
- hasEnded: boolean;
253
- accountChannel: string;
254
- createdAt: string;
255
- updatedAt: string;
256
- }[];
257
- };
258
- declare class ListConversationsResponse {
259
- response: Response;
260
- constructor(response: Response);
261
- result(): Promise<ListConversationsResponsePayload>;
262
- }
263
-
264
- /**
265
- * Great Detail Support System.
266
- *
267
- * @copyright 2024 Great Detail Ltd
268
- * @author Great Detail Ltd <info@greatdetail.com>
269
- * @author Dom Webber <dom.webber@greatdetail.com>
270
- * @see https://greatdetail.com
271
- */
272
-
273
- interface Options$6 extends SendOptions {
274
- body: z.infer<typeof CreateLabelRequest.SCHEMA>;
275
- request?: RequestInit;
276
- }
277
- declare class CreateLabelRequest {
278
- protected _client: Client;
279
- static SCHEMA: z.ZodObject<{
280
- title: z.ZodString;
281
- description: z.ZodOptional<z.ZodString>;
282
- account: z.ZodString;
283
- }, "strip", z.ZodTypeAny, {
284
- title: string;
285
- account: string;
286
- description?: string | undefined;
287
- }, {
288
- title: string;
289
- account: string;
290
- description?: string | undefined;
291
- }>;
292
- constructor(_client: Client);
293
- send({ body, request, ...options }: Options$6): Promise<CreateLabelResponse>;
294
- }
295
- type CreateLabelResponsePayload = {
296
- label: {
297
- id: string;
298
- title: string;
299
- description?: string;
300
- createdAt: string;
301
- updatedAt?: string;
302
- };
303
- };
304
- declare class CreateLabelResponse {
305
- response: Response;
306
- constructor(response: Response);
307
- result(): Promise<CreateLabelResponsePayload>;
308
- }
309
-
310
- /**
311
- * Great Detail Support System.
312
- *
313
- * @copyright 2024 Great Detail Ltd
314
- * @author Great Detail Ltd <info@greatdetail.com>
315
- * @author Dom Webber <dom.webber@greatdetail.com>
316
- * @see https://greatdetail.com
317
- */
318
-
319
- interface Options$5 extends SendOptions {
320
- request?: RequestInit;
321
- }
322
- declare class ListLabelsRequest {
323
- protected _client: Client;
324
- constructor(_client: Client);
325
- send({ request, ...options }?: Options$5): Promise<ListLabelsResponse>;
326
- }
327
- type ListLabelsResponsePayload = {
328
- labels: {
329
- id: string;
330
- title: string;
331
- description?: string;
332
- createdAt: string;
333
- updatedAt?: string;
334
- }[];
335
- };
336
- declare class ListLabelsResponse {
337
- response: Response;
338
- constructor(response: Response);
339
- result(): Promise<ListLabelsResponsePayload>;
340
- }
341
-
342
- /**
343
- * Great Detail Support System.
344
- *
345
- * @copyright 2024 Great Detail Ltd
346
- * @author Great Detail Ltd <info@greatdetail.com>
347
- * @author Dom Webber <dom.webber@greatdetail.com>
348
- * @see https://greatdetail.com
349
- */
350
-
351
- interface Options$4 extends SendOptions {
352
- request?: RequestInit;
353
- }
354
- declare class ListMessagesRequest {
355
- protected _client: Client;
356
- constructor(_client: Client);
357
- send({ request, ...options }?: Options$4): Promise<ListMessagesResponse>;
358
- }
359
- type ListMessagesResponsePayload = {
360
- messages: {
361
- id: string;
362
- role: "user" | "assistant";
363
- messageStatus: string;
364
- externalIdentifier?: string;
365
- conversation: string;
366
- contact: string;
367
- createdAt: string;
368
- updatedAt: string;
369
- }[];
370
- };
371
- declare class ListMessagesResponse {
372
- response: Response;
373
- constructor(response: Response);
374
- result(): Promise<ListMessagesResponsePayload>;
375
- }
376
-
377
- /**
378
- * Great Detail Support System.
379
- *
380
- * @copyright 2024 Great Detail Ltd
381
- * @author Great Detail Ltd <info@greatdetail.com>
382
- * @author Dom Webber <dom.webber@greatdetail.com>
383
- * @see https://greatdetail.com
384
- */
385
-
386
- interface Options$3 extends SendOptions {
387
- id: string;
388
- body: z.infer<typeof CreateCorrectionModelRequest.SCHEMA>;
389
- request?: RequestInit;
390
- }
391
- declare class CreateCorrectionModelRequest {
392
- protected _client: Client;
393
- static SCHEMA: z.ZodObject<{
394
- input: z.ZodString;
395
- original: z.ZodString;
396
- correction: z.ZodString;
397
- }, "strip", z.ZodTypeAny, {
398
- input: string;
399
- original: string;
400
- correction: string;
401
- }, {
402
- input: string;
403
- original: string;
404
- correction: string;
405
- }>;
406
- constructor(_client: Client);
407
- send({ id, body, request, ...options }: Options$3): Promise<CreateCorrectionModelResponse>;
408
- }
409
- type CreateCorrectionResponsePayload = unknown;
410
- declare class CreateCorrectionModelResponse {
411
- response: Response;
412
- constructor(response: Response);
413
- result(): Promise<CreateCorrectionResponsePayload>;
414
- }
415
-
416
- /**
417
- * Great Detail Support System.
418
- *
419
- * @copyright 2024 Great Detail Ltd
420
- * @author Great Detail Ltd <info@greatdetail.com>
421
- * @author Dom Webber <dom.webber@greatdetail.com>
422
- * @see https://greatdetail.com
423
- */
424
-
425
- interface Options$2 extends SendOptions {
426
- request?: RequestInit;
427
- }
428
- declare class ListModelsRequest {
429
- protected _client: Client;
430
- constructor(_client: Client);
431
- send({ request, ...options }?: Options$2): Promise<ListModelsResponse>;
432
- }
433
- type ListModelsResponsePayload = {
434
- models: {
435
- id: string;
436
- name: string;
437
- url: string;
438
- icon: string;
439
- disambiguatingDescription: string;
440
- }[];
441
- };
442
- declare class ListModelsResponse {
443
- response: Response;
444
- constructor(response: Response);
445
- result(): Promise<ListModelsResponsePayload>;
446
- }
447
-
448
- /**
449
- * Great Detail Support System.
450
- *
451
- * @copyright 2024 Great Detail Ltd
452
- * @author Great Detail Ltd <info@greatdetail.com>
453
- * @author Dom Webber <dom.webber@greatdetail.com>
454
- * @see https://greatdetail.com
455
- */
456
-
457
- interface Options$1 extends SendOptions {
458
- id: string;
459
- body: z.infer<typeof CreateResponseModelRequest.SCHEMA>;
460
- request?: RequestInit;
461
- }
462
- declare class CreateResponseModelRequest {
463
- protected _client: Client;
464
- static SCHEMA: z.ZodArray<z.ZodObject<{
465
- role: z.ZodEnum<["user", "assistant"]>;
466
- content: z.ZodNullable<z.ZodString>;
467
- }, "strip", z.ZodTypeAny, {
468
- role: "user" | "assistant";
469
- content: string | null;
470
- }, {
471
- role: "user" | "assistant";
472
- content: string | null;
473
- }>, "many">;
474
- constructor(_client: Client);
475
- send({ id, body, request, ...options }: Options$1): Promise<CreateResponseModelResponse>;
476
- }
477
- type CreateResponseResponsePayload = {
478
- message: string | null;
479
- debug: {
480
- duration: string;
481
- sources: (string | undefined)[];
482
- };
483
- };
484
- declare class CreateResponseModelResponse {
485
- response: Response;
486
- constructor(response: Response);
487
- result(): Promise<CreateResponseResponsePayload>;
488
- }
489
-
490
- /**
491
- * Great Detail Support System.
492
- *
493
- * @copyright 2024 Great Detail Ltd
494
- * @author Great Detail Ltd <info@greatdetail.com>
495
- * @author Dom Webber <dom.webber@greatdetail.com>
496
- * @see https://greatdetail.com
497
- */
498
-
499
- interface Options extends SendOptions {
500
- request?: RequestInit;
501
- }
502
- declare class ListSourcesRequest {
503
- protected _client: Client;
504
- constructor(_client: Client);
505
- send({ request, ...options }?: Options): Promise<ListSourcesResponse>;
506
- }
507
- type ListSourcesResponsePayload = {
508
- sources: {
509
- id: string;
510
- name: string;
511
- category: string;
512
- url: string;
513
- disambiguatingDescription: string;
514
- }[];
515
- };
516
- declare class ListSourcesResponse {
517
- response: Response;
518
- constructor(response: Response);
519
- result(): Promise<ListSourcesResponsePayload>;
520
- }
521
-
522
- /**
523
- * Great Detail Support System.
524
- *
525
- * @copyright 2024 Great Detail Ltd
526
- * @author Great Detail Ltd <info@greatdetail.com>
527
- * @author Dom Webber <dom.webber@greatdetail.com>
528
- * @see https://greatdetail.com
529
- */
530
-
531
- interface ClientOptions {
532
- requestFilterables: RequestFilterable[];
533
- baseURL: string;
534
- }
535
- interface InputClientOptions {
536
- baseURL?: string;
537
- }
538
- interface SendOptions {
539
- /**
540
- * Alternative Fetch Provider.
541
- * Used to override the default fetch provider and use polyfills or other
542
- * libraries.
543
- *
544
- * @since 1.0.0
545
- */
546
- fetch?: typeof fetch;
547
- }
548
- declare class Client {
549
- static DEFAULT_BASE_URL: string;
550
- options: ClientOptions;
551
- constructor(authentication: Authentication, options?: InputClientOptions);
552
- action: {
553
- list: ListActionsRequest;
554
- };
555
- channel: {
556
- list: ListChannelsRequest;
557
- };
558
- contact: {
559
- list: ListContactsRequest;
560
- };
561
- conversation: {
562
- get: GetConversationRequest;
563
- list: ListConversationsRequest;
564
- };
565
- label: {
566
- create: CreateLabelRequest;
567
- list: ListLabelsRequest;
568
- };
569
- message: {
570
- list: ListMessagesRequest;
571
- };
572
- model: {
573
- list: ListModelsRequest;
574
- response: {
575
- create: CreateResponseModelRequest;
576
- };
577
- correction: {
578
- create: CreateCorrectionModelRequest;
579
- };
580
- };
581
- source: {
582
- list: ListSourcesRequest;
583
- };
584
- protected _filterRequest(request: RequestInit): Promise<RequestInit>;
585
- send(url: string | URL, request: RequestInit, { fetch: fetchAlternative }?: SendOptions): Promise<Response>;
586
- }
587
-
588
- export { Client, type CreateCorrectionResponsePayload, type CreateLabelResponsePayload, type CreateResponseResponsePayload, DEFAULT_SUPPORT_BASE_URL, type GetConversationResponsePayload, KeyAuthentication, type ListActionsResponsePayload, type ListChannelsResponsePayload, type ListContactsResponsePayload, type ListConversationsResponsePayload, type ListLabelsResponsePayload, type ListMessagesResponsePayload, type ListModelsResponsePayload, type ListSourcesResponsePayload, PublicAuthentication, type RequestFilterable, TokenAuthentication, Client as default };
78
+ export { DEFAULT_SUPPORT_BASE_URL, KeyAuthentication, PublicAuthentication, TokenAuthentication };
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- import{a,b as n,c as p,d as i}from"./chunk-WCSPJBPY.js";var t=class s{static DEFAULT_NAME=n;name;#e;constructor({name:e=process.env.SUPPORT_KEY_NAME??s.DEFAULT_NAME,key:r=process.env.SUPPORT_API_KEY}={}){if(!r)throw new Error("API Key option must be specified when using Key Authentication");this.name=e,this.#e=r}async filter(e){return{...e,headers:{...e.headers,Authorization:`Basic ${btoa(this.name+":"+this.#e)}`}}}};var o=class{#e;constructor({token:e=process.env.SUPPORT_ACCESS_TOKEN}={}){if(!e)throw new Error("Access Token option must be specified when using Token Authentication");this.#e=e}async filter(e){return{...e,headers:{...e.headers,Authorization:`Bearer ${this.#e}`}}}};export{i as Client,a as DEFAULT_SUPPORT_BASE_URL,t as KeyAuthentication,p as PublicAuthentication,o as TokenAuthentication,i as default};
1
+ import{a as l,b as i,c as n,d as a,e as p,f as m,g as f}from"./chunk-OVSCTY74.js";var t=class s{static DEFAULT_NAME=i;name;#e;constructor({name:e=process.env[p]??s.DEFAULT_NAME,key:r=process.env[a]}={}){if(!r)throw new Error("API Key option must be specified when using Key Authentication");this.name=e,this.#e=r}async filter(e){return{...e,headers:{...e.headers,Authorization:`Basic ${btoa(this.name+":"+this.#e)}`}}}};var o=class{#e;constructor({token:e=process.env[n]}={}){if(!e)throw new Error("Access Token option must be specified when using Token Authentication");this.#e=e}async filter(e){return{...e,headers:{...e.headers,Authorization:`Bearer ${this.#e}`}}}};export{f as Client,l as DEFAULT_SUPPORT_BASE_URL,t as KeyAuthentication,m as PublicAuthentication,o as TokenAuthentication,f as default};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@great-detail/support-sdk",
3
- "version": "0.0.4",
3
+ "version": "0.0.6",
4
4
  "type": "module",
5
5
  "description": "JavaScript SDK for the Great Detail Support System",
6
6
  "author": "Great Detail Ltd <info@greatdetail.com>",
@@ -47,6 +47,7 @@
47
47
  "changeset": "changeset",
48
48
  "eslint": "eslint .",
49
49
  "eslint:dev": "eslint . --fix",
50
+ "jest": "cross-env NODE_OPTIONS=\"$NODE_OPTIONS --experimental-vm-modules\" jest --passWithNoTests",
50
51
  "lint": "npm-run-all eslint typecheck publint prettier",
51
52
  "lint:dev": "npm-run-all eslint:dev typecheck publint prettier:dev",
52
53
  "prerelease": "npm-run-all build",
@@ -54,7 +55,8 @@
54
55
  "prettier:dev": "prettier --write .",
55
56
  "publint": "publint",
56
57
  "release": "changeset publish",
57
- "tsup": "tsup --entry src/index.ts --entry src/cli.ts --format cjs,esm --minify --dts",
58
+ "test": "npm-run-all jest",
59
+ "tsup": "tsup --entry src/index.ts --entry src/cli.ts --entry src/cli/index.ts --format cjs,esm --minify --dts",
58
60
  "typecheck": "tsc --noEmit"
59
61
  },
60
62
  "dependencies": {
@@ -67,11 +69,15 @@
67
69
  "@changesets/cli": "^2.27.7",
68
70
  "@great-detail/eslint-config": "^1.0.4",
69
71
  "@great-detail/prettier-config": "^0.2.4",
72
+ "@jest/globals": "^29.7.0",
70
73
  "@types/node": "^20.14.12",
74
+ "cross-env": "^7.0.3",
71
75
  "eslint": "^8.57.0",
76
+ "jest": "^29.7.0",
72
77
  "npm-run-all": "^4.1.5",
73
78
  "prettier": "^3.3.3",
74
79
  "publint": "^0.2.9",
80
+ "ts-jest": "^29.2.3",
75
81
  "ts-node": "^10.9.2",
76
82
  "tsup": "^8.2.3",
77
83
  "typescript": "^5.5.4"
@@ -34,10 +34,14 @@ export type ListActionsResponsePayload = {
34
34
  actions: {
35
35
  id: string;
36
36
  actionStatus: string;
37
- object?: unknown;
38
- result?: unknown;
37
+ message: string;
38
+ name: string;
39
+ object?: string;
40
+ result?: string;
39
41
  startedAt?: string;
40
42
  endedAt?: string;
43
+ createdAt: string;
44
+ updatedAt?: string;
41
45
  }[];
42
46
  };
43
47
 
@@ -7,7 +7,11 @@
7
7
  * @see https://greatdetail.com
8
8
  */
9
9
 
10
- import { DEFAULT_KEY_AUTHENTICATION_NAME } from "../constants/index.js";
10
+ import {
11
+ DEFAULT_KEY_AUTHENTICATION_NAME,
12
+ KEY_ENV_VAR,
13
+ USER_ENV_VAR,
14
+ } from "../constants/index.js";
11
15
  import Authentication from "./index.js";
12
16
 
13
17
  export interface Options {
@@ -22,8 +26,8 @@ export default class KeyAuthentication implements Authentication {
22
26
  #key: string;
23
27
 
24
28
  constructor({
25
- name = process.env.SUPPORT_KEY_NAME ?? KeyAuthentication.DEFAULT_NAME,
26
- key = process.env.SUPPORT_API_KEY,
29
+ name = process.env[USER_ENV_VAR] ?? KeyAuthentication.DEFAULT_NAME,
30
+ key = process.env[KEY_ENV_VAR],
27
31
  }: Options = {}) {
28
32
  if (!key) {
29
33
  throw new Error(
@@ -7,6 +7,7 @@
7
7
  * @see https://greatdetail.com
8
8
  */
9
9
 
10
+ import { TOKEN_ENV_VAR } from "../constants/index.js";
10
11
  import Authentication from "./index.js";
11
12
 
12
13
  export interface Options {
@@ -16,7 +17,7 @@ export interface Options {
16
17
  export default class TokenAuthentication implements Authentication {
17
18
  #token: string;
18
19
 
19
- constructor({ token = process.env.SUPPORT_ACCESS_TOKEN }: Options = {}) {
20
+ constructor({ token = process.env[TOKEN_ENV_VAR] }: Options = {}) {
20
21
  if (!token) {
21
22
  throw new Error(
22
23
  "Access Token option must be specified when using Token Authentication",
@@ -31,14 +31,31 @@ export default class ListChannelsRequest {
31
31
  }
32
32
 
33
33
  export type ListChannelsResponsePayload = {
34
- channels: {
34
+ channels: ({
35
35
  id: string;
36
36
  name?: string;
37
37
  channelStatus: "ActiveChannelStatus" | "PotentialChannelStatus";
38
- source: "twilio-sendgrid" | "meta-whatsapp";
38
+ account: string;
39
39
  createdAt: string;
40
40
  updatedAt?: string;
41
- }[];
41
+ } & (
42
+ | {
43
+ source: "meta-whatsapp";
44
+ metaWhatsapp: {
45
+ id: string;
46
+ whatsappAccountID: string;
47
+ whatsappPhoneNumberID: string;
48
+ accessToken: string;
49
+ };
50
+ }
51
+ | {
52
+ source: "twilio-sendgrid";
53
+ twilioSendgrid: {
54
+ id: string;
55
+ apiKey: string;
56
+ };
57
+ }
58
+ ))[];
42
59
  };
43
60
 
44
61
  export class ListChannelsResponse {