@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
@@ -11,17 +11,21 @@ import ListActionsRequest from "../Action/ListActions.js";
11
11
  import Authentication from "../Authentication/index.js";
12
12
  import ListChannelsRequest from "../Channel/ListChannels.js";
13
13
  import { DEFAULT_SUPPORT_BASE_URL } from "../constants/index.js";
14
+ import GetContactRequest from "../Contact/GetContact.js";
14
15
  import ListContactsRequest from "../Contact/ListContacts.js";
15
16
  import GetConversationRequest from "../Conversation/GetConversation.js";
16
17
  import ListConversationsRequest from "../Conversation/ListConversations.js";
17
18
  import CreateLabelRequest from "../Label/CreateLabel.js";
19
+ import GetLabelRequest from "../Label/GetLabel.js";
18
20
  import ListLabelsRequest from "../Label/ListLabels.js";
19
21
  import ListMessagesRequest from "../Message/ListMessages.js";
20
22
  import CreateCorrectionModelRequest from "../Model/Correction/CreateCorrectionModel.js";
23
+ import GetModelRequest from "../Model/GetModel.js";
21
24
  import ListModelsRequest from "../Model/ListModels.js";
22
25
  import CreateResponseModelRequest from "../Model/Response/CreateResponseModel.js";
23
26
  import RequestFilterable from "../Request/RequestFilterable.js";
24
27
  import RequestStandardHeaders from "../Request/RequestStandardHeaders.js";
28
+ import GetSourceRequest from "../Source/GetSource.js";
25
29
  import ListSourcesRequest from "../Source/ListSources.js";
26
30
 
27
31
  export interface ClientOptions {
@@ -69,6 +73,7 @@ export default class Client {
69
73
  };
70
74
 
71
75
  public contact = {
76
+ get: new GetContactRequest(this),
72
77
  list: new ListContactsRequest(this),
73
78
  };
74
79
 
@@ -79,6 +84,7 @@ export default class Client {
79
84
 
80
85
  public label = {
81
86
  create: new CreateLabelRequest(this),
87
+ get: new GetLabelRequest(this),
82
88
  list: new ListLabelsRequest(this),
83
89
  };
84
90
 
@@ -87,6 +93,7 @@ export default class Client {
87
93
  };
88
94
 
89
95
  public model = {
96
+ get: new GetModelRequest(this),
90
97
  list: new ListModelsRequest(this),
91
98
  response: {
92
99
  create: new CreateResponseModelRequest(this),
@@ -97,6 +104,7 @@ export default class Client {
97
104
  };
98
105
 
99
106
  public source = {
107
+ get: new GetSourceRequest(this),
100
108
  list: new ListSourcesRequest(this),
101
109
  };
102
110
 
@@ -0,0 +1,52 @@
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 Client, { SendOptions } from "../Client/index.js";
11
+
12
+ export interface Options extends SendOptions {
13
+ id: string;
14
+ request?: RequestInit;
15
+ }
16
+
17
+ export default class GetContactRequest {
18
+ constructor(protected _client: Client) {}
19
+
20
+ public async send({ id, request = {}, ...options }: Options) {
21
+ return this._client
22
+ .send(
23
+ "/v1/contacts/" + encodeURIComponent(id),
24
+ {
25
+ ...request,
26
+ method: "GET",
27
+ },
28
+ options,
29
+ )
30
+ .then((response) => new GetContactResponse(response));
31
+ }
32
+ }
33
+
34
+ export type GetContactResponsePayload = {
35
+ contact: {
36
+ id: string;
37
+ name?: string;
38
+ emailAddress?: string;
39
+ telephoneNumber?: string;
40
+ account: string;
41
+ createdAt: string;
42
+ updatedAt?: string;
43
+ };
44
+ };
45
+
46
+ export class GetContactResponse {
47
+ constructor(public response: Response) {}
48
+
49
+ public async result(): Promise<GetContactResponsePayload> {
50
+ return this.response.json();
51
+ }
52
+ }
@@ -36,6 +36,7 @@ export type ListContactsResponsePayload = {
36
36
  name?: string;
37
37
  emailAddress?: string;
38
38
  telephoneNumber?: string;
39
+ account: string;
39
40
  createdAt: string;
40
41
  updatedAt?: string;
41
42
  }[];
@@ -48,6 +48,7 @@ export type CreateLabelResponsePayload = {
48
48
  id: string;
49
49
  title: string;
50
50
  description?: string;
51
+ account: string;
51
52
  createdAt: string;
52
53
  updatedAt?: string;
53
54
  };
@@ -0,0 +1,51 @@
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 Client, { SendOptions } from "../Client/index.js";
11
+
12
+ export interface Options extends SendOptions {
13
+ id: string;
14
+ request?: RequestInit;
15
+ }
16
+
17
+ export default class GetLabelRequest {
18
+ constructor(protected _client: Client) {}
19
+
20
+ public async send({ id, request = {}, ...options }: Options) {
21
+ return this._client
22
+ .send(
23
+ "/v1/labels/" + encodeURIComponent(id),
24
+ {
25
+ ...request,
26
+ method: "GET",
27
+ },
28
+ options,
29
+ )
30
+ .then((response) => new GetLabelResponse(response));
31
+ }
32
+ }
33
+
34
+ export type GetLabelResponsePayload = {
35
+ label: {
36
+ id: string;
37
+ title: string;
38
+ description?: string;
39
+ account: string;
40
+ createdAt: string;
41
+ updatedAt?: string;
42
+ };
43
+ };
44
+
45
+ export class GetLabelResponse {
46
+ constructor(public response: Response) {}
47
+
48
+ public async result(): Promise<GetLabelResponsePayload> {
49
+ return this.response.json();
50
+ }
51
+ }
@@ -35,6 +35,7 @@ export type ListLabelsResponsePayload = {
35
35
  id: string;
36
36
  title: string;
37
37
  description?: string;
38
+ account: string;
38
39
  createdAt: string;
39
40
  updatedAt?: string;
40
41
  }[];
@@ -38,6 +38,13 @@ export type ListMessagesResponsePayload = {
38
38
  externalIdentifier?: string;
39
39
  conversation: string;
40
40
  contact: string;
41
+ messageEvents: {
42
+ id: string;
43
+ messageEventType: string;
44
+ triggeredAt: string;
45
+ createdAt: string;
46
+ updatedAt?: string;
47
+ }[];
41
48
  createdAt: string;
42
49
  updatedAt: string;
43
50
  }[];
@@ -0,0 +1,50 @@
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 Client, { SendOptions } from "../Client/index.js";
11
+
12
+ export interface Options extends SendOptions {
13
+ id: string;
14
+ request?: RequestInit;
15
+ }
16
+
17
+ export default class GetModelRequest {
18
+ constructor(protected _client: Client) {}
19
+
20
+ public async send({ id, request = {}, ...options }: Options) {
21
+ return this._client
22
+ .send(
23
+ "/v1/models/" + encodeURIComponent(id),
24
+ {
25
+ ...request,
26
+ method: "GET",
27
+ },
28
+ options,
29
+ )
30
+ .then((response) => new GetModelResponse(response));
31
+ }
32
+ }
33
+
34
+ export type GetModelResponsePayload = {
35
+ model: {
36
+ id: string;
37
+ name: string;
38
+ url?: string;
39
+ icon?: string;
40
+ disambiguatingDescription: string;
41
+ };
42
+ };
43
+
44
+ export class GetModelResponse {
45
+ constructor(public response: Response) {}
46
+
47
+ public async result(): Promise<GetModelResponsePayload> {
48
+ return this.response.json();
49
+ }
50
+ }
@@ -34,8 +34,8 @@ export type ListModelsResponsePayload = {
34
34
  models: {
35
35
  id: string;
36
36
  name: string;
37
- url: string;
38
- icon: string;
37
+ url?: string;
38
+ icon?: string;
39
39
  disambiguatingDescription: string;
40
40
  }[];
41
41
  };
@@ -0,0 +1,51 @@
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 Client, { SendOptions } from "../Client/index.js";
11
+
12
+ export interface Options extends SendOptions {
13
+ id: string;
14
+ request?: RequestInit;
15
+ }
16
+
17
+ export default class GetSourceRequest {
18
+ constructor(protected _client: Client) {}
19
+
20
+ public async send({ id, request = {}, ...options }: Options) {
21
+ return this._client
22
+ .send(
23
+ "/v1/sources/" + encodeURIComponent(id),
24
+ {
25
+ ...request,
26
+ method: "GET",
27
+ },
28
+ options,
29
+ )
30
+ .then((response) => new GetSourceResponse(response));
31
+ }
32
+ }
33
+
34
+ export type GetSourceResponsePayload = {
35
+ source: {
36
+ id: string;
37
+ name: string;
38
+ category: string;
39
+ url?: string;
40
+ icon?: string;
41
+ disambiguatingDescription: string;
42
+ };
43
+ };
44
+
45
+ export class GetSourceResponse {
46
+ constructor(public response: Response) {}
47
+
48
+ public async result(): Promise<GetSourceResponsePayload> {
49
+ return this.response.json();
50
+ }
51
+ }
@@ -35,7 +35,8 @@ export type ListSourcesResponsePayload = {
35
35
  id: string;
36
36
  name: string;
37
37
  category: string;
38
- url: string;
38
+ url?: string;
39
+ icon?: string;
39
40
  disambiguatingDescription: string;
40
41
  }[];
41
42
  };
@@ -0,0 +1,79 @@
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 { describe, expect, test } from "@jest/globals";
11
+ import KeyAuthentication from "../../Authentication/KeyAuthentication.js";
12
+
13
+ describe("KeyAuthentication", () => {
14
+ describe("Authentication application via filtering", () => {
15
+ test("When an api key is sourced from environment variables, it should be added in request headers", async () => {
16
+ // Arrange
17
+ const key = "example-api-key";
18
+ process.env.SUPPORT_API_KEY = key;
19
+ const auth = new KeyAuthentication();
20
+ const init = {
21
+ headers: {
22
+ // Ensure that existing, non-colliding, headers remain
23
+ "X-Trace-ID": "example",
24
+
25
+ // Ensure that existing, colliding, headers are overwritten
26
+ Authorization: "Basic ZXhhbXBsZTpleGFtcGxl", // example:example
27
+ },
28
+ };
29
+
30
+ // Act
31
+ const request = await auth.filter(init);
32
+
33
+ // Assert
34
+ expect(request).toHaveProperty("headers");
35
+ expect(request.headers).toHaveProperty(
36
+ "Authorization",
37
+ "Basic YXBpLWtleTpleGFtcGxlLWFwaS1rZXk=",
38
+ );
39
+ expect(request.headers).toHaveProperty("X-Trace-ID", "example");
40
+ });
41
+
42
+ test("When an api key is sourced directly, it should be added in request headers", async () => {
43
+ // Arrange
44
+ const key = "example-api-key";
45
+ const auth = new KeyAuthentication({ key });
46
+ const init = {
47
+ headers: {
48
+ // Ensure that existing, non-colliding, headers remain
49
+ "X-Trace-ID": "example",
50
+
51
+ // Ensure that existing, colliding, headers are overwritten
52
+ Authorization: "Basic ZXhhbXBsZTpleGFtcGxl", // example:example
53
+ },
54
+ };
55
+
56
+ // Act
57
+ const request = await auth.filter(init);
58
+
59
+ // Assert
60
+ expect(request).toHaveProperty("headers");
61
+ expect(request.headers).toHaveProperty(
62
+ "Authorization",
63
+ "Basic YXBpLWtleTpleGFtcGxlLWFwaS1rZXk=",
64
+ );
65
+ expect(request.headers).toHaveProperty("X-Trace-ID", "example");
66
+ });
67
+
68
+ test("When no api key can be found, the constructor should throw", async () => {
69
+ // Arrange
70
+ process.env = {};
71
+
72
+ // Act
73
+ const auth = () => new KeyAuthentication(); // eslint-disable-line unicorn/consistent-function-scoping
74
+
75
+ // Assert
76
+ expect(auth).toThrow();
77
+ });
78
+ });
79
+ });
@@ -0,0 +1,79 @@
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 { describe, expect, test } from "@jest/globals";
11
+ import TokenAuthentication from "../../Authentication/TokenAuthentication.js";
12
+
13
+ describe("TokenAuthentication", () => {
14
+ describe("Authentication application via filtering", () => {
15
+ test("When a token is sourced from environment variables, it should be added in request headers", async () => {
16
+ // Arrange
17
+ const token = "example-access-token";
18
+ process.env.SUPPORT_ACCESS_TOKEN = token;
19
+ const auth = new TokenAuthentication();
20
+ const init = {
21
+ headers: {
22
+ // Ensure that existing, non-colliding, headers remain
23
+ "X-Trace-ID": "example",
24
+
25
+ // Ensure that existing, colliding, headers are overwritten
26
+ Authorization: "Basic ZXhhbXBsZTpleGFtcGxl", // example:example
27
+ },
28
+ };
29
+
30
+ // Act
31
+ const request = await auth.filter(init);
32
+
33
+ // Assert
34
+ expect(request).toHaveProperty("headers");
35
+ expect(request.headers).toHaveProperty(
36
+ "Authorization",
37
+ "Bearer " + token,
38
+ );
39
+ expect(request.headers).toHaveProperty("X-Trace-ID", "example");
40
+ });
41
+
42
+ test("When a token is sourced directly, it should be added in request headers", async () => {
43
+ // Arrange
44
+ const token = "example-access-token";
45
+ const auth = new TokenAuthentication({ token });
46
+ const init = {
47
+ headers: {
48
+ // Ensure that existing, non-colliding, headers remain
49
+ "X-Trace-ID": "example",
50
+
51
+ // Ensure that existing, colliding, headers are overwritten
52
+ Authorization: "Basic ZXhhbXBsZTpleGFtcGxl", // example:example
53
+ },
54
+ };
55
+
56
+ // Act
57
+ const request = await auth.filter(init);
58
+
59
+ // Assert
60
+ expect(request).toHaveProperty("headers");
61
+ expect(request.headers).toHaveProperty(
62
+ "Authorization",
63
+ "Bearer " + token,
64
+ );
65
+ expect(request.headers).toHaveProperty("X-Trace-ID", "example");
66
+ });
67
+
68
+ test("When no token can be found, the constructor should throw", async () => {
69
+ // Arrange
70
+ process.env = {};
71
+
72
+ // Act
73
+ const auth = () => new TokenAuthentication(); // eslint-disable-line unicorn/consistent-function-scoping
74
+
75
+ // Assert
76
+ expect(auth).toThrow();
77
+ });
78
+ });
79
+ });
@@ -16,6 +16,20 @@ export interface Options extends CommandOptions {}
16
16
  export default function contacts({ client, ora }: Options) {
17
17
  const command = new Command("contacts").description("Contacts");
18
18
 
19
+ command.addCommand(
20
+ new Command("get")
21
+ .description("Find contact")
22
+ .argument("<contact>", "Contact ID")
23
+ .action(async (id) => {
24
+ const result = await oraPromise(() => client.contact.get.send({ id }), {
25
+ ...ora,
26
+ text: "Finding contact",
27
+ });
28
+
29
+ console.log(await result.result());
30
+ }),
31
+ );
32
+
19
33
  command.addCommand(
20
34
  new Command("list").description("List contacts").action(async () => {
21
35
  const result = await oraPromise(() => client.contact.list.send(), {
package/src/cli/labels.ts CHANGED
@@ -16,6 +16,20 @@ export interface Options extends CommandOptions {}
16
16
  export default function labels({ client, ora }: Options) {
17
17
  const command = new Command("labels").description("Labels");
18
18
 
19
+ command.addCommand(
20
+ new Command("get")
21
+ .description("Find label")
22
+ .argument("<label>", "Label ID")
23
+ .action(async (id) => {
24
+ const result = await oraPromise(() => client.label.get.send({ id }), {
25
+ ...ora,
26
+ text: "Finding label",
27
+ });
28
+
29
+ console.log(await result.result());
30
+ }),
31
+ );
32
+
19
33
  command.addCommand(
20
34
  new Command("list").description("List labels").action(async () => {
21
35
  const result = await oraPromise(() => client.label.list.send(), {
package/src/cli/models.ts CHANGED
@@ -16,6 +16,20 @@ export interface Options extends CommandOptions {}
16
16
  export default function models({ client, ora }: Options) {
17
17
  const command = new Command("models").description("Models");
18
18
 
19
+ command.addCommand(
20
+ new Command("get")
21
+ .description("Find model")
22
+ .argument("<model>", "Model ID")
23
+ .action(async (id) => {
24
+ const result = await oraPromise(() => client.model.get.send({ id }), {
25
+ ...ora,
26
+ text: "Finding model",
27
+ });
28
+
29
+ console.log(await result.result());
30
+ }),
31
+ );
32
+
19
33
  command.addCommand(
20
34
  new Command("list").description("List models").action(async () => {
21
35
  const result = await oraPromise(() => client.model.list.send(), {
@@ -16,6 +16,20 @@ export interface Options extends CommandOptions {}
16
16
  export default function sources({ client, ora }: Options) {
17
17
  const command = new Command("sources").description("Sources");
18
18
 
19
+ command.addCommand(
20
+ new Command("get")
21
+ .description("Find source")
22
+ .argument("<source>", "Source ID")
23
+ .action(async (id) => {
24
+ const result = await oraPromise(() => client.source.get.send({ id }), {
25
+ ...ora,
26
+ text: "Finding source",
27
+ });
28
+
29
+ console.log(await result.result());
30
+ }),
31
+ );
32
+
19
33
  command.addCommand(
20
34
  new Command("list").description("List sources").action(async () => {
21
35
  const result = await oraPromise(() => client.source.list.send(), {
@@ -29,3 +29,24 @@ export const STANDARD_HEADERS = {
29
29
  * @since 1.0.0
30
30
  */
31
31
  export const DEFAULT_KEY_AUTHENTICATION_NAME = "api-key";
32
+
33
+ /**
34
+ * The Token-Authentication Environment Variable Name.
35
+ *
36
+ * @since 1.0.0
37
+ */
38
+ export const TOKEN_ENV_VAR = "SUPPORT_ACCESS_TOKEN";
39
+
40
+ /**
41
+ * The API-Key Authentication Environment Variable Name.
42
+ *
43
+ * @since 1.0.0
44
+ */
45
+ export const KEY_ENV_VAR = "SUPPORT_API_KEY";
46
+
47
+ /**
48
+ * The API-Key Authentication Username Environment Variable Name.
49
+ *
50
+ * @since 1.0.0
51
+ */
52
+ export const USER_ENV_VAR = "SUPPORT_KEY_NAME";
@@ -1 +0,0 @@
1
- var j="https://api.support.greatdetail.com",H={"X-Powered-By":"GDSupport/JavaScript"},F="api-key";var O=class{async filter(e){return e}};var o=class{constructor(e){this._client=e}async send({request:e={},...s}={}){return this._client.send("/v1/actions",{...e,method:"GET"},s).then(n=>new C(n))}},C=class{constructor(e){this.response=e}async result(){return this.response.json()}};var i=class{constructor(e){this._client=e}async send({request:e={},...s}={}){return this._client.send("/v1/channels",{...e,method:"GET"},s).then(n=>new A(n))}},A=class{constructor(e){this.response=e}async result(){return this.response.json()}};var p=class{constructor(e){this._client=e}async send({request:e={},...s}={}){return this._client.send("/v1/contacts",{...e,method:"GET"},s).then(n=>new P(n))}},P=class{constructor(e){this.response=e}async result(){return this.response.json()}};var c=class{constructor(e){this._client=e}async send({id:e,request:s={},...n}){return this._client.send("/v1/conversations/"+encodeURIComponent(e),{...s,method:"GET"},n).then(r=>new _(r))}},_=class{constructor(e){this.response=e}async result(){return this.response.json()}};var a=class{constructor(e){this._client=e}async send({request:e={},...s}={}){return this._client.send("/v1/conversations",{...e,method:"GET"},s).then(n=>new E(n))}},E=class{constructor(e){this.response=e}async result(){return this.response.json()}};import{z as l}from"zod";var d=class t{constructor(e){this._client=e}static SCHEMA=l.object({title:l.string(),description:l.optional(l.string()),account:l.string()});async send({body:e,request:s={},...n}){return this._client.send("/v1/labels",{...s,method:"POST",headers:{...s.headers,"Content-Type":"application/json"},body:JSON.stringify(t.SCHEMA.parse(e))},n).then(r=>new q(r))}},q=class{constructor(e){this.response=e}async result(){return this.response.json()}};var u=class{constructor(e){this._client=e}async send({request:e={},...s}={}){return this._client.send("/v1/labels",{...e,method:"GET"},s).then(n=>new w(n))}},w=class{constructor(e){this.response=e}async result(){return this.response.json()}};var m=class{constructor(e){this._client=e}async send({request:e={},...s}={}){return this._client.send("/v1/messages",{...e,method:"GET"},s).then(n=>new T(n))}},T=class{constructor(e){this.response=e}async result(){return this.response.json()}};import{z as R}from"zod";var h=class t{constructor(e){this._client=e}static SCHEMA=R.object({input:R.string().max(65536),original:R.string().max(65536),correction:R.string().max(65536)});async send({id:e,body:s,request:n={},...r}){return this._client.send("/v1/models/"+encodeURIComponent(e)+"/correction",{...n,method:"POST",headers:{...n.headers,"Content-Type":"application/json"},body:JSON.stringify(t.SCHEMA.parse(s))},r).then(S=>new L(S))}},L=class{constructor(e){this.response=e}async result(){return this.response.json()}};var b=class{constructor(e){this._client=e}async send({request:e={},...s}={}){return this._client.send("/v1/models",{...e,method:"GET"},s).then(n=>new I(n))}},I=class{constructor(e){this.response=e}async result(){return this.response.json()}};import{z as x}from"zod";var f=class t{constructor(e){this._client=e}static SCHEMA=x.array(x.object({role:x.enum(["user","assistant"]),content:x.string().max(65536).nullable()})).min(1);async send({id:e,body:s,request:n={},...r}){return this._client.send("/v1/models/"+encodeURIComponent(e)+"/response",{...n,method:"POST",headers:{...n.headers,"Content-Type":"application/json"},body:JSON.stringify(t.SCHEMA.parse(s))},r).then(S=>new v(S))}},v=class{constructor(e){this.response=e}async result(){return this.response.json()}};var g=class{constructor(e){this._client=e}async send({request:e={},...s}={}){return this._client.send("/v1/sources",{...e,method:"GET"},s).then(n=>new U(n))}},U=class{constructor(e){this.response=e}async result(){return this.response.json()}};var y=class t{constructor(e=t.STANDARD_HEADERS){this._standardHeaders=e}static STANDARD_HEADERS=H;async filter(e){return{...e,headers:{...e.headers,...this._standardHeaders}}}};var D=class t{static DEFAULT_BASE_URL=j;options;constructor(e,s={}){this.options={requestFilterables:[new y,e],baseURL:process.env.SUPPORT_BASE_URL??t.DEFAULT_BASE_URL,...s}}action={list:new o(this)};channel={list:new i(this)};contact={list:new p(this)};conversation={get:new c(this),list:new a(this)};label={create:new d(this),list:new u(this)};message={list:new m(this)};model={list:new b(this),response:{create:new f(this)},correction:{create:new h(this)}};source={list:new g(this)};async _filterRequest(e){for(let s of this.options.requestFilterables)e=await s.filter(e);return e}async send(e,s,{fetch:n=fetch}={}){return await n(new Request(new URL(e,this.options.baseURL),await this._filterRequest(s)))}};export{j as a,F as b,O as c,D as d};