@great-detail/support-sdk 0.4.4 → 0.4.5
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/package.json +2 -3
- package/src/Action/ListActions.ts +0 -40
- package/src/Action/index.ts +0 -10
- package/src/Authentication/KeyAuthentication.ts +0 -50
- package/src/Authentication/PublicAuthentication.ts +0 -32
- package/src/Authentication/TokenAuthentication.ts +0 -41
- package/src/Authentication/index.ts +0 -13
- package/src/Boilerplate/CreateBoilerplateCategoryBoilerplate.ts +0 -55
- package/src/Boilerplate/GetBoilerplate.ts +0 -41
- package/src/Boilerplate/ListBoilerplateCategoryBoilerplates.ts +0 -41
- package/src/Boilerplate/ListBoilerplates.ts +0 -37
- package/src/Boilerplate/UpdateBoilerplate.ts +0 -53
- package/src/Boilerplate/index.ts +0 -14
- package/src/BoilerplateCategory/CreateBoilerplateCategory.ts +0 -52
- package/src/BoilerplateCategory/GetBoilerplateCategory.ts +0 -40
- package/src/BoilerplateCategory/ListBoilerplateCategories.ts +0 -39
- package/src/BoilerplateCategory/UpdateBoilerplateCategory.ts +0 -52
- package/src/BoilerplateCategory/index.ts +0 -13
- package/src/Channel/ListChannels.ts +0 -53
- package/src/Channel/index.ts +0 -10
- package/src/Client/index.ts +0 -206
- package/src/Contact/ContactVCF/GetContactVCF.ts +0 -45
- package/src/Contact/CreateContact.ts +0 -51
- package/src/Contact/GetContact.ts +0 -41
- package/src/Contact/ListContacts.ts +0 -37
- package/src/Contact/ListLabelContacts.ts +0 -41
- package/src/Contact/UpdateContact.ts +0 -54
- package/src/Contact/index.ts +0 -14
- package/src/Conversation/CreateConversation.ts +0 -58
- package/src/Conversation/GetConversation.ts +0 -45
- package/src/Conversation/ListContactConversations.ts +0 -45
- package/src/Conversation/ListConversations.ts +0 -41
- package/src/Conversation/ListLabelConversations.ts +0 -45
- package/src/Conversation/UpdateConversation.ts +0 -64
- package/src/Conversation/index.ts +0 -15
- package/src/Error/AuthError.ts +0 -12
- package/src/Error/AuthenticationError.ts +0 -16
- package/src/Error/AuthorizationError.ts +0 -16
- package/src/Error/LogicError.ts +0 -20
- package/src/Error/NetworkError.ts +0 -12
- package/src/Error/SupportError.ts +0 -10
- package/src/Error/ValidationError.ts +0 -16
- package/src/Error/index.ts +0 -20
- package/src/Label/CreateLabel.ts +0 -49
- package/src/Label/DeleteLabel.ts +0 -31
- package/src/Label/GetLabel.ts +0 -40
- package/src/Label/ListLabels.ts +0 -36
- package/src/Label/UpdateLabel.ts +0 -52
- package/src/Label/index.ts +0 -14
- package/src/Message/ListConversationMessages.ts +0 -49
- package/src/Message/ListMessages.ts +0 -45
- package/src/Message/index.ts +0 -11
- package/src/Model/Correction/CreateCorrectionModel.ts +0 -44
- package/src/Model/GetModel.ts +0 -39
- package/src/Model/ListModels.ts +0 -35
- package/src/Model/Response/CreateResponseModel.ts +0 -53
- package/src/Model/index.ts +0 -15
- package/src/Note/CreateContactNote.ts +0 -49
- package/src/Note/CreateConversationNote.ts +0 -49
- package/src/Note/GetNote.ts +0 -38
- package/src/Note/ListContactNotes.ts +0 -38
- package/src/Note/ListConversationNotes.ts +0 -38
- package/src/Note/UpdateNote.ts +0 -49
- package/src/Note/index.ts +0 -15
- package/src/NotificationSubscription/CreateContactNotificationSubscription.ts +0 -57
- package/src/NotificationSubscription/index.ts +0 -10
- package/src/Request/RequestFilterable.ts +0 -16
- package/src/Request/RequestStandardHeaders.ts +0 -32
- package/src/Source/GetSource.ts +0 -40
- package/src/Source/ListSources.ts +0 -36
- package/src/Source/index.ts +0 -11
- package/src/Transport/FetchTransport.ts +0 -100
- package/src/Transport/index.ts +0 -18
- package/src/Webhook/index.ts +0 -55
- package/src/__tests__/Client/Client.test.ts +0 -38
- package/src/cli/actions.ts +0 -31
- package/src/cli/channels.ts +0 -31
- package/src/cli/contacts.ts +0 -45
- package/src/cli/conversations.ts +0 -48
- package/src/cli/index.ts +0 -46
- package/src/cli/labels.ts +0 -62
- package/src/cli/messages.ts +0 -31
- package/src/cli/models.ts +0 -45
- package/src/cli/sources.ts +0 -45
- package/src/cli.ts +0 -13
- package/src/constants/environment.ts +0 -36
- package/src/constants/index.ts +0 -31
- package/src/index.ts +0 -39
|
@@ -1,100 +0,0 @@
|
|
|
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 isNetworkError from "is-network-error";
|
|
11
|
-
import ky, { HTTPError, KyInstance } from "ky";
|
|
12
|
-
import AuthenticationError from "../Error/AuthenticationError.js";
|
|
13
|
-
import AuthorizationError from "../Error/AuthorizationError.js";
|
|
14
|
-
import LogicError from "../Error/LogicError.js";
|
|
15
|
-
import NetworkError from "../Error/NetworkError.js";
|
|
16
|
-
import ValidationError from "../Error/ValidationError.js";
|
|
17
|
-
import Transport, { Options as TransportOptions } from "./index.js";
|
|
18
|
-
|
|
19
|
-
export interface InputOptions extends TransportOptions {
|
|
20
|
-
baseURL: string;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export interface Options extends TransportOptions {
|
|
24
|
-
baseURL: string;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
export default class FetchTransport implements Transport {
|
|
28
|
-
public client: KyInstance;
|
|
29
|
-
public options: Options;
|
|
30
|
-
|
|
31
|
-
constructor({ baseURL, ...options }: InputOptions) {
|
|
32
|
-
this.options = {
|
|
33
|
-
...options,
|
|
34
|
-
baseURL,
|
|
35
|
-
};
|
|
36
|
-
this.client = ky.create({
|
|
37
|
-
prefixUrl: this.options.baseURL,
|
|
38
|
-
hooks: {
|
|
39
|
-
beforeRequest: [
|
|
40
|
-
(request) => {
|
|
41
|
-
for (const filterable of this.options.requestFilterables) {
|
|
42
|
-
const filterableHeaders = filterable.getHeaders();
|
|
43
|
-
for (const [headerName, headerValue] of Object.entries(
|
|
44
|
-
filterableHeaders,
|
|
45
|
-
)) {
|
|
46
|
-
// Skip explicitly-overwritten headers
|
|
47
|
-
if (request.headers.has(headerName)) {
|
|
48
|
-
continue;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
request.headers.set(headerName, headerValue);
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
},
|
|
55
|
-
],
|
|
56
|
-
},
|
|
57
|
-
});
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
public getURL(url: string): string {
|
|
61
|
-
return new URL(url, this.options.baseURL).toString();
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
public async send<T = unknown>(url: string, request: RequestInit) {
|
|
65
|
-
return await this.client<T>(url, request).catch((error) => {
|
|
66
|
-
if (isNetworkError(error)) {
|
|
67
|
-
throw new NetworkError("A network error occurred", { cause: error });
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
if (error instanceof HTTPError) {
|
|
71
|
-
const code = error.response.status;
|
|
72
|
-
console.error(JSON.stringify(error.response));
|
|
73
|
-
|
|
74
|
-
switch (code) {
|
|
75
|
-
case 400: {
|
|
76
|
-
throw ValidationError.badRequest();
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
case 401: {
|
|
80
|
-
throw AuthenticationError.unauthenticated();
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
case 403: {
|
|
84
|
-
throw AuthorizationError.forbidden();
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
case 404: {
|
|
88
|
-
throw LogicError.notFound(url);
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
case 405: {
|
|
92
|
-
throw LogicError.forbiddenMethod(url, request.method ?? "GET");
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
throw error;
|
|
98
|
-
});
|
|
99
|
-
}
|
|
100
|
-
}
|
package/src/Transport/index.ts
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
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 RequestFilterable from "../Request/RequestFilterable.js";
|
|
11
|
-
|
|
12
|
-
export interface Options {
|
|
13
|
-
requestFilterables: RequestFilterable[];
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export default interface Transport {
|
|
17
|
-
getURL(url: string): string;
|
|
18
|
-
}
|
package/src/Webhook/index.ts
DELETED
|
@@ -1,55 +0,0 @@
|
|
|
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 from "../Client/index.js";
|
|
12
|
-
|
|
13
|
-
export type Options = {
|
|
14
|
-
request: {
|
|
15
|
-
body: unknown;
|
|
16
|
-
headers: Record<string, string | string[]>;
|
|
17
|
-
[key: string]: unknown | undefined;
|
|
18
|
-
};
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
export type WebhookResponse = z.infer<typeof Webhook.SCHEMA>;
|
|
22
|
-
|
|
23
|
-
export default class Webhook {
|
|
24
|
-
public static SCHEMA = z.object({
|
|
25
|
-
event: z.intersection(
|
|
26
|
-
z.object({
|
|
27
|
-
id: z.string(),
|
|
28
|
-
createdAt: z.string().datetime(),
|
|
29
|
-
}),
|
|
30
|
-
z.discriminatedUnion("type", [
|
|
31
|
-
z.object({
|
|
32
|
-
type: z.literal("contact.created"),
|
|
33
|
-
contact: z.string(),
|
|
34
|
-
}),
|
|
35
|
-
z.object({
|
|
36
|
-
type: z.literal("message.created"),
|
|
37
|
-
message: z.string(),
|
|
38
|
-
}),
|
|
39
|
-
]),
|
|
40
|
-
),
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
constructor(protected _client: Client) {}
|
|
44
|
-
|
|
45
|
-
/**
|
|
46
|
-
* @deprecated Pre-release Functionality
|
|
47
|
-
*/
|
|
48
|
-
public async event({ request }: Options) {
|
|
49
|
-
const { event } = Webhook.SCHEMA.parse(request.body);
|
|
50
|
-
|
|
51
|
-
return {
|
|
52
|
-
event,
|
|
53
|
-
};
|
|
54
|
-
}
|
|
55
|
-
}
|
|
@@ -1,38 +0,0 @@
|
|
|
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 Client from "../../Client/index.js";
|
|
12
|
-
import { DEFAULT_SUPPORT_BASE_URL } from "../../constants/index.js";
|
|
13
|
-
|
|
14
|
-
describe("Client", () => {
|
|
15
|
-
describe("Determining Base URL", () => {
|
|
16
|
-
test("When a base URL is set via environment variables, it should be used as the default base URL", () => {
|
|
17
|
-
// Arrange
|
|
18
|
-
process.env.SUPPORT_BASE_URL = "https://example.com";
|
|
19
|
-
|
|
20
|
-
// Act
|
|
21
|
-
const baseURL = Client.getBaseURL();
|
|
22
|
-
|
|
23
|
-
// Assert
|
|
24
|
-
expect(baseURL).toBe(process.env.SUPPORT_BASE_URL);
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
test("When a base URL is not set via environment, the default should be assumed", () => {
|
|
28
|
-
// Arrange
|
|
29
|
-
process.env = { SUPPORT_BASE_URL: undefined };
|
|
30
|
-
|
|
31
|
-
// Act
|
|
32
|
-
const baseURL = Client.getBaseURL();
|
|
33
|
-
|
|
34
|
-
// Assert
|
|
35
|
-
expect(baseURL).toBe(DEFAULT_SUPPORT_BASE_URL);
|
|
36
|
-
});
|
|
37
|
-
});
|
|
38
|
-
});
|
package/src/cli/actions.ts
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
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 { Command } from "commander";
|
|
11
|
-
import { oraPromise } from "ora";
|
|
12
|
-
import type { Options as CommandOptions } from "./index.js";
|
|
13
|
-
|
|
14
|
-
export type Options = CommandOptions;
|
|
15
|
-
|
|
16
|
-
export default function actions({ client, ora }: Options) {
|
|
17
|
-
const command = new Command("actions").description("Actions");
|
|
18
|
-
|
|
19
|
-
command.addCommand(
|
|
20
|
-
new Command("list").description("List actions").action(async () => {
|
|
21
|
-
const result = await oraPromise(() => client.action.list.send(), {
|
|
22
|
-
...ora,
|
|
23
|
-
text: "Finding actions",
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
console.log(await result.json());
|
|
27
|
-
}),
|
|
28
|
-
);
|
|
29
|
-
|
|
30
|
-
return command;
|
|
31
|
-
}
|
package/src/cli/channels.ts
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
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 { Command } from "commander";
|
|
11
|
-
import { oraPromise } from "ora";
|
|
12
|
-
import type { Options as CommandOptions } from "./index.js";
|
|
13
|
-
|
|
14
|
-
export type Options = CommandOptions;
|
|
15
|
-
|
|
16
|
-
export default function channels({ client, ora }: Options) {
|
|
17
|
-
const command = new Command("channels").description("Channels");
|
|
18
|
-
|
|
19
|
-
command.addCommand(
|
|
20
|
-
new Command("list").description("List channels").action(async () => {
|
|
21
|
-
const result = await oraPromise(() => client.channel.list.send(), {
|
|
22
|
-
...ora,
|
|
23
|
-
text: "Finding channels",
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
console.log(await result.json());
|
|
27
|
-
}),
|
|
28
|
-
);
|
|
29
|
-
|
|
30
|
-
return command;
|
|
31
|
-
}
|
package/src/cli/contacts.ts
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
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 { Command } from "commander";
|
|
11
|
-
import { oraPromise } from "ora";
|
|
12
|
-
import type { Options as CommandOptions } from "./index.js";
|
|
13
|
-
|
|
14
|
-
export type Options = CommandOptions;
|
|
15
|
-
|
|
16
|
-
export default function contacts({ client, ora }: Options) {
|
|
17
|
-
const command = new Command("contacts").description("Contacts");
|
|
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.json());
|
|
30
|
-
}),
|
|
31
|
-
);
|
|
32
|
-
|
|
33
|
-
command.addCommand(
|
|
34
|
-
new Command("list").description("List contacts").action(async () => {
|
|
35
|
-
const result = await oraPromise(() => client.contact.list.send(), {
|
|
36
|
-
...ora,
|
|
37
|
-
text: "Finding contacts",
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
console.log(await result.json());
|
|
41
|
-
}),
|
|
42
|
-
);
|
|
43
|
-
|
|
44
|
-
return command;
|
|
45
|
-
}
|
package/src/cli/conversations.ts
DELETED
|
@@ -1,48 +0,0 @@
|
|
|
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 { Command } from "commander";
|
|
11
|
-
import { oraPromise } from "ora";
|
|
12
|
-
import type { Options as CommandOptions } from "./index.js";
|
|
13
|
-
|
|
14
|
-
export type Options = CommandOptions;
|
|
15
|
-
|
|
16
|
-
export default function conversations({ client, ora }: Options) {
|
|
17
|
-
const command = new Command("conversations").description("Conversations");
|
|
18
|
-
|
|
19
|
-
command.addCommand(
|
|
20
|
-
new Command("get")
|
|
21
|
-
.description("Find conversation")
|
|
22
|
-
.argument("<conversation>", "Conversation ID")
|
|
23
|
-
.action(async (id) => {
|
|
24
|
-
const result = await oraPromise(
|
|
25
|
-
() => client.conversation.get.send({ id }),
|
|
26
|
-
{
|
|
27
|
-
...ora,
|
|
28
|
-
text: "Finding conversation",
|
|
29
|
-
},
|
|
30
|
-
);
|
|
31
|
-
|
|
32
|
-
console.log(await result.json());
|
|
33
|
-
}),
|
|
34
|
-
);
|
|
35
|
-
|
|
36
|
-
command.addCommand(
|
|
37
|
-
new Command("list").description("List conversations").action(async () => {
|
|
38
|
-
const result = await oraPromise(() => client.conversation.list.send(), {
|
|
39
|
-
...ora,
|
|
40
|
-
text: "Finding conversations",
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
console.log(await result.json());
|
|
44
|
-
}),
|
|
45
|
-
);
|
|
46
|
-
|
|
47
|
-
return command;
|
|
48
|
-
}
|
package/src/cli/index.ts
DELETED
|
@@ -1,46 +0,0 @@
|
|
|
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 { Command } from "commander";
|
|
11
|
-
import PublicAuthentication from "../Authentication/PublicAuthentication.js";
|
|
12
|
-
import Client from "../Client/index.js";
|
|
13
|
-
import actions from "./actions.js";
|
|
14
|
-
import channels from "./channels.js";
|
|
15
|
-
import contacts from "./contacts.js";
|
|
16
|
-
import conversations from "./conversations.js";
|
|
17
|
-
import labels from "./labels.js";
|
|
18
|
-
import messages from "./messages.js";
|
|
19
|
-
import models from "./models.js";
|
|
20
|
-
import sources from "./sources.js";
|
|
21
|
-
import type { Options as OraOptions } from "ora";
|
|
22
|
-
|
|
23
|
-
export interface Options {
|
|
24
|
-
client: Client;
|
|
25
|
-
ora: OraOptions;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
const options: Options = {
|
|
29
|
-
ora: {
|
|
30
|
-
spinner: "simpleDotsScrolling",
|
|
31
|
-
},
|
|
32
|
-
client: new Client(new PublicAuthentication()),
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
const cli = new Command("gds")
|
|
36
|
-
.description("Great Detail Support System")
|
|
37
|
-
.addCommand(actions(options))
|
|
38
|
-
.addCommand(channels(options))
|
|
39
|
-
.addCommand(contacts(options))
|
|
40
|
-
.addCommand(conversations(options))
|
|
41
|
-
.addCommand(labels(options))
|
|
42
|
-
.addCommand(messages(options))
|
|
43
|
-
.addCommand(models(options))
|
|
44
|
-
.addCommand(sources(options));
|
|
45
|
-
|
|
46
|
-
export default cli;
|
package/src/cli/labels.ts
DELETED
|
@@ -1,62 +0,0 @@
|
|
|
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 { Command } from "commander";
|
|
11
|
-
import { oraPromise } from "ora";
|
|
12
|
-
import type { Options as CommandOptions } from "./index.js";
|
|
13
|
-
|
|
14
|
-
export type Options = CommandOptions;
|
|
15
|
-
|
|
16
|
-
export default function labels({ client, ora }: Options) {
|
|
17
|
-
const command = new Command("labels").description("Labels");
|
|
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.json());
|
|
30
|
-
}),
|
|
31
|
-
);
|
|
32
|
-
|
|
33
|
-
command.addCommand(
|
|
34
|
-
new Command("list").description("List labels").action(async () => {
|
|
35
|
-
const result = await oraPromise(() => client.label.list.send(), {
|
|
36
|
-
...ora,
|
|
37
|
-
text: "Finding labels",
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
console.log(await result.json());
|
|
41
|
-
}),
|
|
42
|
-
);
|
|
43
|
-
|
|
44
|
-
command.addCommand(
|
|
45
|
-
new Command("conversations")
|
|
46
|
-
.description("Find label conversations")
|
|
47
|
-
.argument("<label>", "Label ID")
|
|
48
|
-
.action(async (id) => {
|
|
49
|
-
const result = await oraPromise(
|
|
50
|
-
() => client.label.conversation.list.send({ id }),
|
|
51
|
-
{
|
|
52
|
-
...ora,
|
|
53
|
-
text: "Finding conversations",
|
|
54
|
-
},
|
|
55
|
-
);
|
|
56
|
-
|
|
57
|
-
console.log(await result.json());
|
|
58
|
-
}),
|
|
59
|
-
);
|
|
60
|
-
|
|
61
|
-
return command;
|
|
62
|
-
}
|
package/src/cli/messages.ts
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
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 { Command } from "commander";
|
|
11
|
-
import { oraPromise } from "ora";
|
|
12
|
-
import type { Options as CommandOptions } from "./index.js";
|
|
13
|
-
|
|
14
|
-
export type Options = CommandOptions;
|
|
15
|
-
|
|
16
|
-
export default function messages({ client, ora }: Options) {
|
|
17
|
-
const command = new Command("messages").description("Messages");
|
|
18
|
-
|
|
19
|
-
command.addCommand(
|
|
20
|
-
new Command("list").description("List messages").action(async () => {
|
|
21
|
-
const result = await oraPromise(() => client.message.list.send(), {
|
|
22
|
-
...ora,
|
|
23
|
-
text: "Finding messages",
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
console.log(await result.json());
|
|
27
|
-
}),
|
|
28
|
-
);
|
|
29
|
-
|
|
30
|
-
return command;
|
|
31
|
-
}
|
package/src/cli/models.ts
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
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 { Command } from "commander";
|
|
11
|
-
import { oraPromise } from "ora";
|
|
12
|
-
import type { Options as CommandOptions } from "./index.js";
|
|
13
|
-
|
|
14
|
-
export type Options = CommandOptions;
|
|
15
|
-
|
|
16
|
-
export default function models({ client, ora }: Options) {
|
|
17
|
-
const command = new Command("models").description("Models");
|
|
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.json());
|
|
30
|
-
}),
|
|
31
|
-
);
|
|
32
|
-
|
|
33
|
-
command.addCommand(
|
|
34
|
-
new Command("list").description("List models").action(async () => {
|
|
35
|
-
const result = await oraPromise(() => client.model.list.send(), {
|
|
36
|
-
...ora,
|
|
37
|
-
text: "Finding models",
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
console.log(await result.json());
|
|
41
|
-
}),
|
|
42
|
-
);
|
|
43
|
-
|
|
44
|
-
return command;
|
|
45
|
-
}
|
package/src/cli/sources.ts
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
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 { Command } from "commander";
|
|
11
|
-
import { oraPromise } from "ora";
|
|
12
|
-
import type { Options as CommandOptions } from "./index.js";
|
|
13
|
-
|
|
14
|
-
export type Options = CommandOptions;
|
|
15
|
-
|
|
16
|
-
export default function sources({ client, ora }: Options) {
|
|
17
|
-
const command = new Command("sources").description("Sources");
|
|
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.json());
|
|
30
|
-
}),
|
|
31
|
-
);
|
|
32
|
-
|
|
33
|
-
command.addCommand(
|
|
34
|
-
new Command("list").description("List sources").action(async () => {
|
|
35
|
-
const result = await oraPromise(() => client.source.list.send(), {
|
|
36
|
-
...ora,
|
|
37
|
-
text: "Finding sources",
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
console.log(await result.json());
|
|
41
|
-
}),
|
|
42
|
-
);
|
|
43
|
-
|
|
44
|
-
return command;
|
|
45
|
-
}
|
package/src/cli.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Great Detail Support System.
|
|
5
|
-
*
|
|
6
|
-
* @copyright 2024 Great Detail Ltd
|
|
7
|
-
* @author Great Detail Ltd <info@greatdetail.com>
|
|
8
|
-
* @author Dom Webber <dom.webber@greatdetail.com>
|
|
9
|
-
* @see https://greatdetail.com
|
|
10
|
-
*/
|
|
11
|
-
import cli from "./cli/index.js";
|
|
12
|
-
|
|
13
|
-
cli.parseAsync(process.argv);
|
|
@@ -1,36 +0,0 @@
|
|
|
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
|
-
/**
|
|
11
|
-
* The Token-Authentication Environment Variable Name.
|
|
12
|
-
*
|
|
13
|
-
* @since 1.0.0
|
|
14
|
-
*/
|
|
15
|
-
export const TOKEN_ENV_VAR = "SUPPORT_ACCESS_TOKEN";
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* The API-Key Authentication Environment Variable Name.
|
|
19
|
-
*
|
|
20
|
-
* @since 1.0.0
|
|
21
|
-
*/
|
|
22
|
-
export const KEY_ENV_VAR = "SUPPORT_API_KEY";
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* The API-Key Authentication Username Environment Variable Name.
|
|
26
|
-
*
|
|
27
|
-
* @since 1.0.0
|
|
28
|
-
*/
|
|
29
|
-
export const USER_ENV_VAR = "SUPPORT_KEY_NAME";
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* The Base URL Environment Variable Name.
|
|
33
|
-
*
|
|
34
|
-
* @since 1.0.0
|
|
35
|
-
*/
|
|
36
|
-
export const BASE_URL_ENV_VAR = "SUPPORT_BASE_URL";
|
package/src/constants/index.ts
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
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
|
-
/**
|
|
11
|
-
* Support System API Base URL.
|
|
12
|
-
*
|
|
13
|
-
* @since 1.0.0
|
|
14
|
-
*/
|
|
15
|
-
export const DEFAULT_SUPPORT_BASE_URL = "https://api.support.greatdetail.com";
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* Standard HTTP Request Headers.
|
|
19
|
-
*
|
|
20
|
-
* @since 1.0.0
|
|
21
|
-
*/
|
|
22
|
-
export const STANDARD_HEADERS = {
|
|
23
|
-
"X-Powered-By": "GDSupport/JavaScript",
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* Default Basic Authentication Username for Key Authentication.
|
|
28
|
-
*
|
|
29
|
-
* @since 1.0.0
|
|
30
|
-
*/
|
|
31
|
-
export const DEFAULT_KEY_AUTHENTICATION_NAME = "api-key";
|