@great-detail/support-sdk 0.0.5 → 0.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +59 -0
- package/dist/chunk-PWDTRAX2.js +1 -0
- package/dist/chunk-QYWS5WK5.js +1 -0
- package/dist/cli/index.cjs +1 -0
- package/dist/cli/index.d.cts +21 -0
- package/dist/cli/index.d.ts +21 -0
- package/dist/cli/index.js +1 -0
- package/dist/cli.cjs +1 -1
- package/dist/cli.js +1 -1
- package/dist/index-ByUz_hOL.d.cts +728 -0
- package/dist/index-ByUz_hOL.d.ts +728 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +8 -655
- package/dist/index.d.ts +8 -655
- package/dist/index.js +1 -1
- package/package.json +15 -8
- package/src/Action/ListActions.ts +6 -2
- package/src/Authentication/KeyAuthentication.ts +7 -3
- package/src/Authentication/TokenAuthentication.ts +2 -1
- package/src/Authentication/index.ts +2 -1
- package/src/Channel/ListChannels.ts +20 -3
- package/src/Client/index.ts +2 -0
- package/src/Contact/GetContact.ts +1 -0
- package/src/Contact/ListContacts.ts +1 -0
- package/src/Conversation/GetConversation.ts +1 -0
- package/src/Conversation/ListConversations.ts +1 -0
- package/src/Conversation/UpdateConversation.ts +62 -0
- package/src/Label/CreateLabel.ts +1 -0
- package/src/Label/GetLabel.ts +1 -0
- package/src/Label/ListLabels.ts +1 -0
- package/src/Message/ListMessages.ts +7 -0
- package/src/Model/GetModel.ts +2 -2
- package/src/Model/ListModels.ts +2 -2
- package/src/Source/GetSource.ts +2 -1
- package/src/Source/ListSources.ts +2 -1
- package/src/__tests__/Authentication/KeyAuthentication.test.ts +79 -0
- package/src/__tests__/Authentication/TokenAuthentication.test.ts +79 -0
- package/src/cli/actions.ts +1 -1
- package/src/cli/channels.ts +1 -1
- package/src/cli/contacts.ts +1 -1
- package/src/cli/conversations.ts +1 -1
- package/src/cli/labels.ts +1 -1
- package/src/cli/messages.ts +1 -1
- package/src/cli/models.ts +1 -1
- package/src/cli/sources.ts +1 -1
- package/src/constants/index.ts +21 -0
- package/dist/chunk-BFO7RVLV.js +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@great-detail/support-sdk",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.7",
|
|
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
|
-
"
|
|
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": {
|
|
@@ -65,15 +67,20 @@
|
|
|
65
67
|
},
|
|
66
68
|
"devDependencies": {
|
|
67
69
|
"@changesets/cli": "^2.27.7",
|
|
68
|
-
"@great-detail/eslint-config": "^1.0.
|
|
69
|
-
"@great-detail/prettier-config": "^0.
|
|
70
|
-
"@
|
|
71
|
-
"
|
|
70
|
+
"@great-detail/eslint-config": "^1.0.5",
|
|
71
|
+
"@great-detail/prettier-config": "^0.3.0",
|
|
72
|
+
"@jest/globals": "^29.7.0",
|
|
73
|
+
"@types/node": "^22.4.1",
|
|
74
|
+
"cross-env": "^7.0.3",
|
|
75
|
+
"eslint": "^9.9.0",
|
|
76
|
+
"jest": "^29.7.0",
|
|
72
77
|
"npm-run-all": "^4.1.5",
|
|
78
|
+
"openapi-typescript": "^7.3.0",
|
|
73
79
|
"prettier": "^3.3.3",
|
|
74
|
-
"publint": "^0.2.
|
|
80
|
+
"publint": "^0.2.10",
|
|
81
|
+
"ts-jest": "^29.2.4",
|
|
75
82
|
"ts-node": "^10.9.2",
|
|
76
|
-
"tsup": "^8.2.
|
|
83
|
+
"tsup": "^8.2.4",
|
|
77
84
|
"typescript": "^5.5.4"
|
|
78
85
|
},
|
|
79
86
|
"publishConfig": {
|
|
@@ -34,10 +34,14 @@ export type ListActionsResponsePayload = {
|
|
|
34
34
|
actions: {
|
|
35
35
|
id: string;
|
|
36
36
|
actionStatus: string;
|
|
37
|
-
|
|
38
|
-
|
|
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 {
|
|
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
|
|
26
|
-
key = process.env
|
|
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
|
|
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
|
-
|
|
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 {
|
package/src/Client/index.ts
CHANGED
|
@@ -15,6 +15,7 @@ import GetContactRequest from "../Contact/GetContact.js";
|
|
|
15
15
|
import ListContactsRequest from "../Contact/ListContacts.js";
|
|
16
16
|
import GetConversationRequest from "../Conversation/GetConversation.js";
|
|
17
17
|
import ListConversationsRequest from "../Conversation/ListConversations.js";
|
|
18
|
+
import UpdateConversationRequest from "../Conversation/UpdateConversation.js";
|
|
18
19
|
import CreateLabelRequest from "../Label/CreateLabel.js";
|
|
19
20
|
import GetLabelRequest from "../Label/GetLabel.js";
|
|
20
21
|
import ListLabelsRequest from "../Label/ListLabels.js";
|
|
@@ -80,6 +81,7 @@ export default class Client {
|
|
|
80
81
|
public conversation = {
|
|
81
82
|
get: new GetConversationRequest(this),
|
|
82
83
|
list: new ListConversationsRequest(this),
|
|
84
|
+
update: new UpdateConversationRequest(this),
|
|
83
85
|
};
|
|
84
86
|
|
|
85
87
|
public label = {
|
|
@@ -0,0 +1,62 @@
|
|
|
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 Client, { SendOptions } from "../Client/index.js";
|
|
12
|
+
|
|
13
|
+
export interface Options extends SendOptions {
|
|
14
|
+
id: string;
|
|
15
|
+
body: z.infer<typeof UpdateConversationRequest.SCHEMA>;
|
|
16
|
+
request?: RequestInit;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export default class UpdateConversationRequest {
|
|
20
|
+
public static SCHEMA = z.object({
|
|
21
|
+
hasEnded: z.boolean(),
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
constructor(protected _client: Client) {}
|
|
25
|
+
|
|
26
|
+
public async send({ id, body, request = {}, ...options }: Options) {
|
|
27
|
+
return this._client
|
|
28
|
+
.send(
|
|
29
|
+
"/v1/conversations/" + encodeURIComponent(id),
|
|
30
|
+
{
|
|
31
|
+
...request,
|
|
32
|
+
method: "POST",
|
|
33
|
+
headers: {
|
|
34
|
+
...request.headers,
|
|
35
|
+
"Content-Type": "application/json",
|
|
36
|
+
},
|
|
37
|
+
body: JSON.stringify(UpdateConversationRequest.SCHEMA.parse(body)),
|
|
38
|
+
},
|
|
39
|
+
options,
|
|
40
|
+
)
|
|
41
|
+
.then((response) => new UpdateConversationResponse(response));
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export type UpdateConversationResponsePayload = {
|
|
46
|
+
conversation: {
|
|
47
|
+
id: string;
|
|
48
|
+
name?: string;
|
|
49
|
+
hasEnded: boolean;
|
|
50
|
+
accountChannel: string;
|
|
51
|
+
createdAt: string;
|
|
52
|
+
updatedAt: string;
|
|
53
|
+
};
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
export class UpdateConversationResponse {
|
|
57
|
+
constructor(public response: Response) {}
|
|
58
|
+
|
|
59
|
+
public async result(): Promise<UpdateConversationResponsePayload> {
|
|
60
|
+
return this.response.json();
|
|
61
|
+
}
|
|
62
|
+
}
|
package/src/Label/CreateLabel.ts
CHANGED
package/src/Label/GetLabel.ts
CHANGED
package/src/Label/ListLabels.ts
CHANGED
|
@@ -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
|
}[];
|
package/src/Model/GetModel.ts
CHANGED
package/src/Model/ListModels.ts
CHANGED
package/src/Source/GetSource.ts
CHANGED
|
@@ -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
|
+
});
|
package/src/cli/actions.ts
CHANGED
|
@@ -11,7 +11,7 @@ import { Command } from "commander";
|
|
|
11
11
|
import { oraPromise } from "ora";
|
|
12
12
|
import type { Options as CommandOptions } from "./index.js";
|
|
13
13
|
|
|
14
|
-
export
|
|
14
|
+
export type Options = CommandOptions;
|
|
15
15
|
|
|
16
16
|
export default function actions({ client, ora }: Options) {
|
|
17
17
|
const command = new Command("actions").description("Actions");
|
package/src/cli/channels.ts
CHANGED
|
@@ -11,7 +11,7 @@ import { Command } from "commander";
|
|
|
11
11
|
import { oraPromise } from "ora";
|
|
12
12
|
import type { Options as CommandOptions } from "./index.js";
|
|
13
13
|
|
|
14
|
-
export
|
|
14
|
+
export type Options = CommandOptions;
|
|
15
15
|
|
|
16
16
|
export default function channels({ client, ora }: Options) {
|
|
17
17
|
const command = new Command("channels").description("Channels");
|
package/src/cli/contacts.ts
CHANGED
|
@@ -11,7 +11,7 @@ import { Command } from "commander";
|
|
|
11
11
|
import { oraPromise } from "ora";
|
|
12
12
|
import type { Options as CommandOptions } from "./index.js";
|
|
13
13
|
|
|
14
|
-
export
|
|
14
|
+
export type Options = CommandOptions;
|
|
15
15
|
|
|
16
16
|
export default function contacts({ client, ora }: Options) {
|
|
17
17
|
const command = new Command("contacts").description("Contacts");
|
package/src/cli/conversations.ts
CHANGED
|
@@ -11,7 +11,7 @@ import { Command } from "commander";
|
|
|
11
11
|
import { oraPromise } from "ora";
|
|
12
12
|
import type { Options as CommandOptions } from "./index.js";
|
|
13
13
|
|
|
14
|
-
export
|
|
14
|
+
export type Options = CommandOptions;
|
|
15
15
|
|
|
16
16
|
export default function conversations({ client, ora }: Options) {
|
|
17
17
|
const command = new Command("conversations").description("Conversations");
|
package/src/cli/labels.ts
CHANGED
|
@@ -11,7 +11,7 @@ import { Command } from "commander";
|
|
|
11
11
|
import { oraPromise } from "ora";
|
|
12
12
|
import type { Options as CommandOptions } from "./index.js";
|
|
13
13
|
|
|
14
|
-
export
|
|
14
|
+
export type Options = CommandOptions;
|
|
15
15
|
|
|
16
16
|
export default function labels({ client, ora }: Options) {
|
|
17
17
|
const command = new Command("labels").description("Labels");
|
package/src/cli/messages.ts
CHANGED
|
@@ -11,7 +11,7 @@ import { Command } from "commander";
|
|
|
11
11
|
import { oraPromise } from "ora";
|
|
12
12
|
import type { Options as CommandOptions } from "./index.js";
|
|
13
13
|
|
|
14
|
-
export
|
|
14
|
+
export type Options = CommandOptions;
|
|
15
15
|
|
|
16
16
|
export default function messages({ client, ora }: Options) {
|
|
17
17
|
const command = new Command("messages").description("Messages");
|
package/src/cli/models.ts
CHANGED
|
@@ -11,7 +11,7 @@ import { Command } from "commander";
|
|
|
11
11
|
import { oraPromise } from "ora";
|
|
12
12
|
import type { Options as CommandOptions } from "./index.js";
|
|
13
13
|
|
|
14
|
-
export
|
|
14
|
+
export type Options = CommandOptions;
|
|
15
15
|
|
|
16
16
|
export default function models({ client, ora }: Options) {
|
|
17
17
|
const command = new Command("models").description("Models");
|
package/src/cli/sources.ts
CHANGED
|
@@ -11,7 +11,7 @@ import { Command } from "commander";
|
|
|
11
11
|
import { oraPromise } from "ora";
|
|
12
12
|
import type { Options as CommandOptions } from "./index.js";
|
|
13
13
|
|
|
14
|
-
export
|
|
14
|
+
export type Options = CommandOptions;
|
|
15
15
|
|
|
16
16
|
export default function sources({ client, ora }: Options) {
|
|
17
17
|
const command = new Command("sources").description("Sources");
|
package/src/constants/index.ts
CHANGED
|
@@ -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";
|
package/dist/chunk-BFO7RVLV.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var k="https://api.support.greatdetail.com",J={"X-Powered-By":"GDSupport/JavaScript"},K="api-key";var _=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 E(n))}},E=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 q(n))}},q=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 w(n))}},w=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 T(r))}},T=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 I(n))}},I=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 L(r))}},L=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 v(n))}},v=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 U(n))}},U=class{constructor(e){this.response=e}async result(){return this.response.json()}};import{z as C}from"zod";var g=class t{constructor(e){this._client=e}static SCHEMA=C.object({input:C.string().max(65536),original:C.string().max(65536),correction:C.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(P=>new j(P))}},j=class{constructor(e){this.response=e}async result(){return this.response.json()}};var h=class{constructor(e){this._client=e}async send({request:e={},...s}={}){return this._client.send("/v1/models",{...e,method:"GET"},s).then(n=>new D(n))}},D=class{constructor(e){this.response=e}async result(){return this.response.json()}};import{z as A}from"zod";var b=class t{constructor(e){this._client=e}static SCHEMA=A.array(A.object({role:A.enum(["user","assistant"]),content:A.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(P=>new G(P))}},G=class{constructor(e){this.response=e}async result(){return this.response.json()}};var y=class{constructor(e){this._client=e}async send({request:e={},...s}={}){return this._client.send("/v1/sources",{...e,method:"GET"},s).then(n=>new H(n))}},H=class{constructor(e){this.response=e}async result(){return this.response.json()}};var f=class{constructor(e){this._client=e}async send({id:e,request:s={},...n}){return this._client.send("/v1/contacts/"+encodeURIComponent(e),{...s,method:"GET"},n).then(r=>new M(r))}},M=class{constructor(e){this.response=e}async result(){return this.response.json()}};var R=class{constructor(e){this._client=e}async send({id:e,request:s={},...n}){return this._client.send("/v1/labels/"+encodeURIComponent(e),{...s,method:"GET"},n).then(r=>new F(r))}},F=class{constructor(e){this.response=e}async result(){return this.response.json()}};var x=class{constructor(e){this._client=e}async send({id:e,request:s={},...n}){return this._client.send("/v1/models/"+encodeURIComponent(e),{...s,method:"GET"},n).then(r=>new N(r))}},N=class{constructor(e){this.response=e}async result(){return this.response.json()}};var O=class t{constructor(e=t.STANDARD_HEADERS){this._standardHeaders=e}static STANDARD_HEADERS=J;async filter(e){return{...e,headers:{...e.headers,...this._standardHeaders}}}};var S=class{constructor(e){this._client=e}async send({id:e,request:s={},...n}){return this._client.send("/v1/sources/"+encodeURIComponent(e),{...s,method:"GET"},n).then(r=>new z(r))}},z=class{constructor(e){this.response=e}async result(){return this.response.json()}};var B=class t{static DEFAULT_BASE_URL=k;options;constructor(e,s={}){this.options={requestFilterables:[new O,e],baseURL:process.env.SUPPORT_BASE_URL??t.DEFAULT_BASE_URL,...s}}action={list:new o(this)};channel={list:new i(this)};contact={get:new f(this),list:new p(this)};conversation={get:new c(this),list:new a(this)};label={create:new d(this),get:new R(this),list:new u(this)};message={list:new m(this)};model={get:new x(this),list:new h(this),response:{create:new b(this)},correction:{create:new g(this)}};source={get:new S(this),list:new y(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{k as a,K as b,_ as c,B as d};
|