@great-detail/support-sdk 0.4.3 → 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/dist/{chunk-4WR77KQ5.js → chunk-23BXD6T5.js} +1 -1
- package/dist/{chunk-SEZCGFWP.js → chunk-F67NJYPP.js} +1 -1
- package/dist/cli/index.cjs +1 -1
- package/dist/cli/index.js +1 -1
- package/dist/cli.cjs +1 -1
- package/dist/cli.js +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.js +1 -1
- 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
package/src/Model/ListModels.ts
DELETED
|
@@ -1,35 +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 FetchTransport from "../Transport/FetchTransport.js";
|
|
11
|
-
|
|
12
|
-
export interface Options {
|
|
13
|
-
request?: RequestInit;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export type ListModelsResponse = {
|
|
17
|
-
models: {
|
|
18
|
-
id: string;
|
|
19
|
-
name: string;
|
|
20
|
-
url?: string;
|
|
21
|
-
icon?: string;
|
|
22
|
-
disambiguatingDescription: string;
|
|
23
|
-
}[];
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
export default class ListModels {
|
|
27
|
-
constructor(protected _transport: FetchTransport) {}
|
|
28
|
-
|
|
29
|
-
public async send({ request = {} }: Options = {}) {
|
|
30
|
-
return this._transport.send<ListModelsResponse>("v1/models", {
|
|
31
|
-
...request,
|
|
32
|
-
method: "GET",
|
|
33
|
-
});
|
|
34
|
-
}
|
|
35
|
-
}
|
|
@@ -1,53 +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 FetchTransport from "../../Transport/FetchTransport.js";
|
|
12
|
-
|
|
13
|
-
export interface Options {
|
|
14
|
-
id: string;
|
|
15
|
-
body: z.infer<typeof CreateResponseModel.SCHEMA>;
|
|
16
|
-
request?: RequestInit;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export type CreateResponseResponse = {
|
|
20
|
-
message: string | null;
|
|
21
|
-
debug: {
|
|
22
|
-
duration: string;
|
|
23
|
-
sources: (string | undefined)[];
|
|
24
|
-
};
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
export default class CreateResponseModel {
|
|
28
|
-
public static SCHEMA = z
|
|
29
|
-
.array(
|
|
30
|
-
z.object({
|
|
31
|
-
role: z.enum(["user", "assistant"]),
|
|
32
|
-
content: z.string().max(65_536).nullable(),
|
|
33
|
-
}),
|
|
34
|
-
)
|
|
35
|
-
.min(1);
|
|
36
|
-
|
|
37
|
-
constructor(protected _transport: FetchTransport) {}
|
|
38
|
-
|
|
39
|
-
public async send({ id, body, request = {} }: Options) {
|
|
40
|
-
return this._transport.send<CreateResponseResponse>(
|
|
41
|
-
"v1/models/" + encodeURIComponent(id) + "/response",
|
|
42
|
-
{
|
|
43
|
-
...request,
|
|
44
|
-
method: "POST",
|
|
45
|
-
headers: {
|
|
46
|
-
...request.headers,
|
|
47
|
-
"Content-Type": "application/json",
|
|
48
|
-
},
|
|
49
|
-
body: JSON.stringify(CreateResponseModel.SCHEMA.parse(body)),
|
|
50
|
-
},
|
|
51
|
-
);
|
|
52
|
-
}
|
|
53
|
-
}
|
package/src/Model/index.ts
DELETED
|
@@ -1,15 +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
|
-
export { type GetModelResponse } from "./GetModel.js";
|
|
11
|
-
export { type ListModelsResponse } from "./ListModels.js";
|
|
12
|
-
|
|
13
|
-
export { type CreateCorrectionResponse } from "./Correction/CreateCorrectionModel.js";
|
|
14
|
-
|
|
15
|
-
export { type CreateResponseResponse } from "./Response/CreateResponseModel.js";
|
|
@@ -1,49 +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 FetchTransport from "../Transport/FetchTransport.js";
|
|
12
|
-
|
|
13
|
-
export interface Options {
|
|
14
|
-
id: string;
|
|
15
|
-
body: z.infer<typeof CreateContactNote.SCHEMA>;
|
|
16
|
-
request?: RequestInit;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export type CreateContactNoteResponse = {
|
|
20
|
-
note: {
|
|
21
|
-
id: string;
|
|
22
|
-
content: string;
|
|
23
|
-
createdAt: string;
|
|
24
|
-
updatedAt: string;
|
|
25
|
-
};
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
export default class CreateContactNote {
|
|
29
|
-
public static SCHEMA = z.object({
|
|
30
|
-
content: z.string(),
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
constructor(protected _transport: FetchTransport) {}
|
|
34
|
-
|
|
35
|
-
public async send({ id, body, request = {} }: Options) {
|
|
36
|
-
return this._transport.send<CreateContactNoteResponse>(
|
|
37
|
-
"v1/contacts/" + encodeURIComponent(id) + "/notes",
|
|
38
|
-
{
|
|
39
|
-
...request,
|
|
40
|
-
method: "POST",
|
|
41
|
-
headers: {
|
|
42
|
-
...request.headers,
|
|
43
|
-
"Content-Type": "application/json",
|
|
44
|
-
},
|
|
45
|
-
body: JSON.stringify(CreateContactNote.SCHEMA.parse(body)),
|
|
46
|
-
},
|
|
47
|
-
);
|
|
48
|
-
}
|
|
49
|
-
}
|
|
@@ -1,49 +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 FetchTransport from "../Transport/FetchTransport.js";
|
|
12
|
-
|
|
13
|
-
export interface Options {
|
|
14
|
-
id: string;
|
|
15
|
-
body: z.infer<typeof CreateConversationNote.SCHEMA>;
|
|
16
|
-
request?: RequestInit;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export type CreateConversationNoteResponse = {
|
|
20
|
-
note: {
|
|
21
|
-
id: string;
|
|
22
|
-
content: string;
|
|
23
|
-
createdAt: string;
|
|
24
|
-
updatedAt: string;
|
|
25
|
-
};
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
export default class CreateConversationNote {
|
|
29
|
-
public static SCHEMA = z.object({
|
|
30
|
-
content: z.string(),
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
constructor(protected _transport: FetchTransport) {}
|
|
34
|
-
|
|
35
|
-
public async send({ id, body, request = {} }: Options) {
|
|
36
|
-
return this._transport.send<CreateConversationNoteResponse>(
|
|
37
|
-
"v1/conversations/" + encodeURIComponent(id) + "/notes",
|
|
38
|
-
{
|
|
39
|
-
...request,
|
|
40
|
-
method: "POST",
|
|
41
|
-
headers: {
|
|
42
|
-
...request.headers,
|
|
43
|
-
"Content-Type": "application/json",
|
|
44
|
-
},
|
|
45
|
-
body: JSON.stringify(CreateConversationNote.SCHEMA.parse(body)),
|
|
46
|
-
},
|
|
47
|
-
);
|
|
48
|
-
}
|
|
49
|
-
}
|
package/src/Note/GetNote.ts
DELETED
|
@@ -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 FetchTransport from "../Transport/FetchTransport.js";
|
|
11
|
-
|
|
12
|
-
export interface Options {
|
|
13
|
-
id: string;
|
|
14
|
-
request?: RequestInit;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export type GetNoteResponse = {
|
|
18
|
-
note: {
|
|
19
|
-
id: string;
|
|
20
|
-
content: string;
|
|
21
|
-
createdAt: string;
|
|
22
|
-
updatedAt: string;
|
|
23
|
-
};
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
export default class GetNote {
|
|
27
|
-
constructor(protected _transport: FetchTransport) {}
|
|
28
|
-
|
|
29
|
-
public async send({ id, request = {} }: Options) {
|
|
30
|
-
return this._transport.send<GetNoteResponse>(
|
|
31
|
-
"v1/notes/" + encodeURIComponent(id),
|
|
32
|
-
{
|
|
33
|
-
...request,
|
|
34
|
-
method: "GET",
|
|
35
|
-
},
|
|
36
|
-
);
|
|
37
|
-
}
|
|
38
|
-
}
|
|
@@ -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 FetchTransport from "../Transport/FetchTransport.js";
|
|
11
|
-
|
|
12
|
-
export interface Options {
|
|
13
|
-
id: string;
|
|
14
|
-
request?: RequestInit;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export type ListContactNotesResponse = {
|
|
18
|
-
notes: {
|
|
19
|
-
id: string;
|
|
20
|
-
content: string;
|
|
21
|
-
createdAt: string;
|
|
22
|
-
updatedAt: string;
|
|
23
|
-
}[];
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
export default class ListContactNotes {
|
|
27
|
-
constructor(protected _transport: FetchTransport) {}
|
|
28
|
-
|
|
29
|
-
public async send({ id, request = {} }: Options) {
|
|
30
|
-
return this._transport.send<ListContactNotesResponse>(
|
|
31
|
-
"v1/contacts/" + encodeURIComponent(id) + "/notes",
|
|
32
|
-
{
|
|
33
|
-
...request,
|
|
34
|
-
method: "GET",
|
|
35
|
-
},
|
|
36
|
-
);
|
|
37
|
-
}
|
|
38
|
-
}
|
|
@@ -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 FetchTransport from "../Transport/FetchTransport.js";
|
|
11
|
-
|
|
12
|
-
export interface Options {
|
|
13
|
-
id: string;
|
|
14
|
-
request?: RequestInit;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export type ListConversationNotesResponse = {
|
|
18
|
-
notes: {
|
|
19
|
-
id: string;
|
|
20
|
-
content: string;
|
|
21
|
-
createdAt: string;
|
|
22
|
-
updatedAt: string;
|
|
23
|
-
}[];
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
export default class ListConversationNotes {
|
|
27
|
-
constructor(protected _transport: FetchTransport) {}
|
|
28
|
-
|
|
29
|
-
public async send({ id, request = {} }: Options) {
|
|
30
|
-
return this._transport.send<ListConversationNotesResponse>(
|
|
31
|
-
"v1/conversations/" + encodeURIComponent(id) + "/notes",
|
|
32
|
-
{
|
|
33
|
-
...request,
|
|
34
|
-
method: "GET",
|
|
35
|
-
},
|
|
36
|
-
);
|
|
37
|
-
}
|
|
38
|
-
}
|
package/src/Note/UpdateNote.ts
DELETED
|
@@ -1,49 +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 FetchTransport from "../Transport/FetchTransport.js";
|
|
12
|
-
|
|
13
|
-
export interface Options {
|
|
14
|
-
id: string;
|
|
15
|
-
body: z.infer<typeof UpdateNote.SCHEMA>;
|
|
16
|
-
request?: RequestInit;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export type UpdateNoteResponse = {
|
|
20
|
-
note: {
|
|
21
|
-
id: string;
|
|
22
|
-
content: string;
|
|
23
|
-
createdAt: string;
|
|
24
|
-
updatedAt: string;
|
|
25
|
-
};
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
export default class UpdateNote {
|
|
29
|
-
public static SCHEMA = z.object({
|
|
30
|
-
content: z.string().optional(),
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
constructor(protected _transport: FetchTransport) {}
|
|
34
|
-
|
|
35
|
-
public async send({ id, body, request = {} }: Options) {
|
|
36
|
-
return this._transport.send<UpdateNoteResponse>(
|
|
37
|
-
"v1/notes/" + encodeURIComponent(id),
|
|
38
|
-
{
|
|
39
|
-
...request,
|
|
40
|
-
method: "PATCH",
|
|
41
|
-
headers: {
|
|
42
|
-
...request.headers,
|
|
43
|
-
"Content-Type": "application/json",
|
|
44
|
-
},
|
|
45
|
-
body: JSON.stringify(UpdateNote.SCHEMA.parse(body)),
|
|
46
|
-
},
|
|
47
|
-
);
|
|
48
|
-
}
|
|
49
|
-
}
|
package/src/Note/index.ts
DELETED
|
@@ -1,15 +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
|
-
export { type CreateContactNoteResponse } from "./CreateContactNote.js";
|
|
11
|
-
export { type CreateConversationNoteResponse } from "./CreateConversationNote.js";
|
|
12
|
-
export { type GetNoteResponse } from "./GetNote.js";
|
|
13
|
-
export { type ListContactNotesResponse } from "./ListContactNotes.js";
|
|
14
|
-
export { type ListConversationNotesResponse } from "./ListConversationNotes.js";
|
|
15
|
-
export { type UpdateNoteResponse } from "./UpdateNote.js";
|
|
@@ -1,57 +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 FetchTransport from "../Transport/FetchTransport.js";
|
|
12
|
-
|
|
13
|
-
export interface Options {
|
|
14
|
-
id: string;
|
|
15
|
-
body: z.infer<typeof CreateContactNotificationSubscription.SCHEMA>;
|
|
16
|
-
request?: RequestInit;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export type CreateContactNotificationSubscriptionResponse = {
|
|
20
|
-
subscription: {
|
|
21
|
-
id: string;
|
|
22
|
-
createdAt: string;
|
|
23
|
-
updatedAt: string;
|
|
24
|
-
};
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
export default class CreateContactNotificationSubscription {
|
|
28
|
-
public static SCHEMA = z.discriminatedUnion("type", [
|
|
29
|
-
z.object({
|
|
30
|
-
type: z.literal("vapid"),
|
|
31
|
-
endpoint: z.string().url(),
|
|
32
|
-
keys: z.object({
|
|
33
|
-
p256dh: z.string(),
|
|
34
|
-
auth: z.string(),
|
|
35
|
-
}),
|
|
36
|
-
}),
|
|
37
|
-
]);
|
|
38
|
-
|
|
39
|
-
constructor(protected _transport: FetchTransport) {}
|
|
40
|
-
|
|
41
|
-
public async send({ id, body, request = {} }: Options) {
|
|
42
|
-
return this._transport.send<CreateContactNotificationSubscriptionResponse>(
|
|
43
|
-
"v1/contacts/" + encodeURIComponent(id) + "/subscriptions",
|
|
44
|
-
{
|
|
45
|
-
...request,
|
|
46
|
-
method: "POST",
|
|
47
|
-
headers: {
|
|
48
|
-
...request.headers,
|
|
49
|
-
"Content-Type": "application/json",
|
|
50
|
-
},
|
|
51
|
-
body: JSON.stringify(
|
|
52
|
-
CreateContactNotificationSubscription.SCHEMA.parse(body),
|
|
53
|
-
),
|
|
54
|
-
},
|
|
55
|
-
);
|
|
56
|
-
}
|
|
57
|
-
}
|
|
@@ -1,10 +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
|
-
export { type CreateContactNotificationSubscriptionResponse } from "./CreateContactNotificationSubscription.js";
|
|
@@ -1,16 +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
|
-
export default interface RequestFilterable {
|
|
11
|
-
/**
|
|
12
|
-
* @deprecated
|
|
13
|
-
*/
|
|
14
|
-
filter(...options: unknown[]): Promise<{ headers: Record<string, string> }>;
|
|
15
|
-
getHeaders(): Record<string, string>;
|
|
16
|
-
}
|
|
@@ -1,32 +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 { STANDARD_HEADERS } from "../constants/index.js";
|
|
11
|
-
import RequestFilterable from "./RequestFilterable.js";
|
|
12
|
-
|
|
13
|
-
export default class RequestStandardHeaders implements RequestFilterable {
|
|
14
|
-
public static STANDARD_HEADERS = STANDARD_HEADERS;
|
|
15
|
-
|
|
16
|
-
constructor(
|
|
17
|
-
protected _standardHeaders: Record<
|
|
18
|
-
string,
|
|
19
|
-
string
|
|
20
|
-
> = RequestStandardHeaders.STANDARD_HEADERS,
|
|
21
|
-
) {}
|
|
22
|
-
|
|
23
|
-
public async filter() {
|
|
24
|
-
return {
|
|
25
|
-
headers: this.getHeaders(),
|
|
26
|
-
};
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
public getHeaders() {
|
|
30
|
-
return this._standardHeaders;
|
|
31
|
-
}
|
|
32
|
-
}
|
package/src/Source/GetSource.ts
DELETED
|
@@ -1,40 +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 FetchTransport from "../Transport/FetchTransport.js";
|
|
11
|
-
|
|
12
|
-
export interface Options {
|
|
13
|
-
id: string;
|
|
14
|
-
request?: RequestInit;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export type GetSourceResponse = {
|
|
18
|
-
source: {
|
|
19
|
-
id: string;
|
|
20
|
-
name: string;
|
|
21
|
-
category: string;
|
|
22
|
-
url?: string;
|
|
23
|
-
icon?: string;
|
|
24
|
-
disambiguatingDescription: string;
|
|
25
|
-
};
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
export default class GetSource {
|
|
29
|
-
constructor(protected _transport: FetchTransport) {}
|
|
30
|
-
|
|
31
|
-
public async send({ id, request = {} }: Options) {
|
|
32
|
-
return this._transport.send<GetSourceResponse>(
|
|
33
|
-
"v1/sources/" + encodeURIComponent(id),
|
|
34
|
-
{
|
|
35
|
-
...request,
|
|
36
|
-
method: "GET",
|
|
37
|
-
},
|
|
38
|
-
);
|
|
39
|
-
}
|
|
40
|
-
}
|
|
@@ -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
|
-
import FetchTransport from "../Transport/FetchTransport.js";
|
|
11
|
-
|
|
12
|
-
export interface Options {
|
|
13
|
-
request?: RequestInit;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export type ListSourcesResponse = {
|
|
17
|
-
sources: {
|
|
18
|
-
id: string;
|
|
19
|
-
name: string;
|
|
20
|
-
category: string;
|
|
21
|
-
url?: string;
|
|
22
|
-
icon?: string;
|
|
23
|
-
disambiguatingDescription: string;
|
|
24
|
-
}[];
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
export default class ListSources {
|
|
28
|
-
constructor(protected _transport: FetchTransport) {}
|
|
29
|
-
|
|
30
|
-
public async send({ request = {} }: Options = {}) {
|
|
31
|
-
return this._transport.send<ListSourcesResponse>("v1/sources", {
|
|
32
|
-
...request,
|
|
33
|
-
method: "GET",
|
|
34
|
-
});
|
|
35
|
-
}
|
|
36
|
-
}
|
package/src/Source/index.ts
DELETED
|
@@ -1,11 +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
|
-
export { type GetSourceResponse } from "./GetSource.js";
|
|
11
|
-
export { type ListSourcesResponse } from "./ListSources.js";
|
|
@@ -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
|
-
}
|