@great-detail/support-sdk 0.1.5 → 0.2.0
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-IXJNWCJL.js +1 -0
- package/dist/{chunk-PTKKI5PQ.js → chunk-SRYAEALQ.js} +1 -1
- package/dist/cli/index.cjs +1 -1
- package/dist/cli/index.d.cts +1 -1
- package/dist/cli/index.d.ts +1 -1
- package/dist/cli/index.js +1 -1
- package/dist/cli.cjs +1 -1
- package/dist/cli.js +1 -1
- package/dist/{index-Dm8jdpkD.d.cts → index-Dj17QRj0.d.cts} +141 -111
- package/dist/{index-Dm8jdpkD.d.ts → index-Dj17QRj0.d.ts} +141 -111
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +63 -6
- package/dist/index.d.ts +63 -6
- package/dist/index.js +1 -1
- package/package.json +2 -1
- package/src/Action/ListActions.ts +8 -12
- package/src/Authentication/KeyAuthentication.ts +10 -11
- package/src/Authentication/PublicAuthentication.ts +8 -2
- package/src/Authentication/TokenAuthentication.ts +9 -7
- package/src/Channel/ListChannels.ts +8 -12
- package/src/Client/index.ts +6 -5
- package/src/Contact/ContactVCF/GetContactVCF.ts +24 -5
- package/src/Contact/CreateContact.ts +12 -16
- package/src/Contact/GetContact.ts +8 -12
- package/src/Contact/ListContacts.ts +8 -12
- package/src/Contact/ListLabelContacts.ts +8 -12
- package/src/Contact/UpdateContact.ts +12 -16
- package/src/Conversation/GetConversation.ts +8 -12
- package/src/Conversation/ListConversations.ts +8 -12
- package/src/Conversation/ListLabelConversations.ts +8 -12
- package/src/Conversation/UpdateConversation.ts +12 -16
- package/src/Error/AuthError.ts +12 -0
- package/src/Error/AuthenticationError.ts +16 -0
- package/src/Error/AuthorizationError.ts +16 -0
- package/src/Error/LogicError.ts +20 -0
- package/src/Error/NetworkError.ts +12 -0
- package/src/Error/SupportError.ts +10 -0
- package/src/Error/ValidationError.ts +16 -0
- package/src/Error/index.ts +11 -0
- package/src/Label/CreateLabel.ts +12 -16
- package/src/Label/DeleteLabel.ts +8 -12
- package/src/Label/GetLabel.ts +8 -12
- package/src/Label/ListLabels.ts +8 -12
- package/src/Label/UpdateLabel.ts +12 -16
- package/src/Message/ListConversationMessages.ts +8 -12
- package/src/Message/ListMessages.ts +8 -12
- package/src/Model/Correction/CreateCorrectionModel.ts +12 -16
- package/src/Model/GetModel.ts +8 -12
- package/src/Model/ListModels.ts +8 -12
- package/src/Model/Response/CreateResponseModel.ts +12 -16
- package/src/Request/RequestFilterable.ts +5 -1
- package/src/Request/RequestStandardHeaders.ts +6 -6
- package/src/Source/GetSource.ts +8 -12
- package/src/Source/ListSources.ts +8 -12
- package/src/Transport/FetchTransport.ts +112 -0
- package/src/Transport/index.ts +2 -44
- package/src/__tests__/Client/Client.test.ts +38 -0
- package/src/constants/environment.ts +36 -0
- package/src/constants/index.ts +0 -21
- package/src/index.ts +4 -4
- package/dist/chunk-2LKRKCHH.js +0 -1
- package/src/__tests__/Authentication/KeyAuthentication.test.ts +0 -79
- package/src/__tests__/Authentication/TokenAuthentication.test.ts +0 -79
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { A as Authentication } from './index-
|
|
2
|
-
export { C as Client, e as CreateContactResponsePayload, r as CreateCorrectionResponsePayload, j as CreateLabelResponsePayload, s as CreateResponseResponsePayload, D as DeleteLabelResponsePayload, G as GetContactResponsePayload, f as GetConversationResponsePayload, k as GetLabelResponsePayload, p as GetModelResponsePayload, t as GetSourceResponsePayload, L as ListActionsResponsePayload, b as ListChannelsResponsePayload, c as ListContactsResponsePayload, n as ListConversationMessagesResponsePayload, g as ListConversationsResponsePayload, d as ListLabelContactsResponsePayload, h as ListLabelConversationsResponsePayload, l as ListLabelsResponsePayload, o as ListMessagesResponsePayload, q as ListModelsResponsePayload, u as ListSourcesResponsePayload, O as Options, R as RequestFilterable, a as TransportOptions,
|
|
1
|
+
import { A as Authentication } from './index-Dj17QRj0.cjs';
|
|
2
|
+
export { C as Client, e as CreateContactResponsePayload, r as CreateCorrectionResponsePayload, j as CreateLabelResponsePayload, s as CreateResponseResponsePayload, D as DeleteLabelResponsePayload, G as GetContactResponsePayload, f as GetConversationResponsePayload, k as GetLabelResponsePayload, p as GetModelResponsePayload, t as GetSourceResponsePayload, L as ListActionsResponsePayload, b as ListChannelsResponsePayload, c as ListContactsResponsePayload, n as ListConversationMessagesResponsePayload, g as ListConversationsResponsePayload, d as ListLabelContactsResponsePayload, h as ListLabelConversationsResponsePayload, l as ListLabelsResponsePayload, o as ListMessagesResponsePayload, q as ListModelsResponsePayload, u as ListSourcesResponsePayload, O as Options, R as RequestFilterable, a as TransportOptions, U as UpdateContactResponsePayload, i as UpdateConversationResponsePayload, m as UpdateLabelResponsePayload, C as default } from './index-Dj17QRj0.cjs';
|
|
3
3
|
import 'zod';
|
|
4
4
|
|
|
5
5
|
/**
|
|
@@ -17,6 +17,46 @@ import 'zod';
|
|
|
17
17
|
*/
|
|
18
18
|
declare const DEFAULT_SUPPORT_BASE_URL = "https://api.support.greatdetail.com";
|
|
19
19
|
|
|
20
|
+
/**
|
|
21
|
+
* Great Detail Support System.
|
|
22
|
+
*
|
|
23
|
+
* @copyright 2024 Great Detail Ltd
|
|
24
|
+
* @author Great Detail Ltd <info@greatdetail.com>
|
|
25
|
+
* @author Dom Webber <dom.webber@greatdetail.com>
|
|
26
|
+
* @see https://greatdetail.com
|
|
27
|
+
*/
|
|
28
|
+
declare class SupportError extends Error {
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Great Detail Support System.
|
|
33
|
+
*
|
|
34
|
+
* @copyright 2024 Great Detail Ltd
|
|
35
|
+
* @author Great Detail Ltd <info@greatdetail.com>
|
|
36
|
+
* @author Dom Webber <dom.webber@greatdetail.com>
|
|
37
|
+
* @see https://greatdetail.com
|
|
38
|
+
*/
|
|
39
|
+
|
|
40
|
+
declare class NetworkError extends SupportError {
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Great Detail Support System.
|
|
45
|
+
*
|
|
46
|
+
* @copyright 2024 Great Detail Ltd
|
|
47
|
+
* @author Great Detail Ltd <info@greatdetail.com>
|
|
48
|
+
* @author Dom Webber <dom.webber@greatdetail.com>
|
|
49
|
+
* @see https://greatdetail.com
|
|
50
|
+
*/
|
|
51
|
+
|
|
52
|
+
type index_NetworkError = NetworkError;
|
|
53
|
+
declare const index_NetworkError: typeof NetworkError;
|
|
54
|
+
type index_SupportError = SupportError;
|
|
55
|
+
declare const index_SupportError: typeof SupportError;
|
|
56
|
+
declare namespace index {
|
|
57
|
+
export { index_NetworkError as NetworkError, index_SupportError as SupportError };
|
|
58
|
+
}
|
|
59
|
+
|
|
20
60
|
/**
|
|
21
61
|
* Great Detail Support System.
|
|
22
62
|
*
|
|
@@ -35,7 +75,14 @@ declare class KeyAuthentication implements Authentication {
|
|
|
35
75
|
static DEFAULT_NAME: string;
|
|
36
76
|
name: string;
|
|
37
77
|
constructor({ name, key, }?: Options$1);
|
|
38
|
-
filter(
|
|
78
|
+
filter(): Promise<{
|
|
79
|
+
headers: {
|
|
80
|
+
Authorization: string;
|
|
81
|
+
};
|
|
82
|
+
}>;
|
|
83
|
+
getHeaders(): {
|
|
84
|
+
Authorization: string;
|
|
85
|
+
};
|
|
39
86
|
}
|
|
40
87
|
|
|
41
88
|
/**
|
|
@@ -53,7 +100,14 @@ interface Options {
|
|
|
53
100
|
declare class TokenAuthentication implements Authentication {
|
|
54
101
|
#private;
|
|
55
102
|
constructor({ token }?: Options);
|
|
56
|
-
filter(
|
|
103
|
+
filter(): Promise<{
|
|
104
|
+
headers: {
|
|
105
|
+
Authorization: string;
|
|
106
|
+
};
|
|
107
|
+
}>;
|
|
108
|
+
getHeaders(): {
|
|
109
|
+
Authorization: string;
|
|
110
|
+
};
|
|
57
111
|
}
|
|
58
112
|
|
|
59
113
|
/**
|
|
@@ -76,7 +130,10 @@ declare class TokenAuthentication implements Authentication {
|
|
|
76
130
|
* @since 1.0.l0
|
|
77
131
|
*/
|
|
78
132
|
declare class PublicAuthentication implements Authentication {
|
|
79
|
-
filter(
|
|
133
|
+
filter(): Promise<{
|
|
134
|
+
headers: {};
|
|
135
|
+
}>;
|
|
136
|
+
getHeaders(): {};
|
|
80
137
|
}
|
|
81
138
|
|
|
82
|
-
export { DEFAULT_SUPPORT_BASE_URL, KeyAuthentication, PublicAuthentication, TokenAuthentication };
|
|
139
|
+
export { DEFAULT_SUPPORT_BASE_URL, index as Error, KeyAuthentication, PublicAuthentication, TokenAuthentication };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { A as Authentication } from './index-
|
|
2
|
-
export { C as Client, e as CreateContactResponsePayload, r as CreateCorrectionResponsePayload, j as CreateLabelResponsePayload, s as CreateResponseResponsePayload, D as DeleteLabelResponsePayload, G as GetContactResponsePayload, f as GetConversationResponsePayload, k as GetLabelResponsePayload, p as GetModelResponsePayload, t as GetSourceResponsePayload, L as ListActionsResponsePayload, b as ListChannelsResponsePayload, c as ListContactsResponsePayload, n as ListConversationMessagesResponsePayload, g as ListConversationsResponsePayload, d as ListLabelContactsResponsePayload, h as ListLabelConversationsResponsePayload, l as ListLabelsResponsePayload, o as ListMessagesResponsePayload, q as ListModelsResponsePayload, u as ListSourcesResponsePayload, O as Options, R as RequestFilterable, a as TransportOptions,
|
|
1
|
+
import { A as Authentication } from './index-Dj17QRj0.js';
|
|
2
|
+
export { C as Client, e as CreateContactResponsePayload, r as CreateCorrectionResponsePayload, j as CreateLabelResponsePayload, s as CreateResponseResponsePayload, D as DeleteLabelResponsePayload, G as GetContactResponsePayload, f as GetConversationResponsePayload, k as GetLabelResponsePayload, p as GetModelResponsePayload, t as GetSourceResponsePayload, L as ListActionsResponsePayload, b as ListChannelsResponsePayload, c as ListContactsResponsePayload, n as ListConversationMessagesResponsePayload, g as ListConversationsResponsePayload, d as ListLabelContactsResponsePayload, h as ListLabelConversationsResponsePayload, l as ListLabelsResponsePayload, o as ListMessagesResponsePayload, q as ListModelsResponsePayload, u as ListSourcesResponsePayload, O as Options, R as RequestFilterable, a as TransportOptions, U as UpdateContactResponsePayload, i as UpdateConversationResponsePayload, m as UpdateLabelResponsePayload, C as default } from './index-Dj17QRj0.js';
|
|
3
3
|
import 'zod';
|
|
4
4
|
|
|
5
5
|
/**
|
|
@@ -17,6 +17,46 @@ import 'zod';
|
|
|
17
17
|
*/
|
|
18
18
|
declare const DEFAULT_SUPPORT_BASE_URL = "https://api.support.greatdetail.com";
|
|
19
19
|
|
|
20
|
+
/**
|
|
21
|
+
* Great Detail Support System.
|
|
22
|
+
*
|
|
23
|
+
* @copyright 2024 Great Detail Ltd
|
|
24
|
+
* @author Great Detail Ltd <info@greatdetail.com>
|
|
25
|
+
* @author Dom Webber <dom.webber@greatdetail.com>
|
|
26
|
+
* @see https://greatdetail.com
|
|
27
|
+
*/
|
|
28
|
+
declare class SupportError extends Error {
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Great Detail Support System.
|
|
33
|
+
*
|
|
34
|
+
* @copyright 2024 Great Detail Ltd
|
|
35
|
+
* @author Great Detail Ltd <info@greatdetail.com>
|
|
36
|
+
* @author Dom Webber <dom.webber@greatdetail.com>
|
|
37
|
+
* @see https://greatdetail.com
|
|
38
|
+
*/
|
|
39
|
+
|
|
40
|
+
declare class NetworkError extends SupportError {
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Great Detail Support System.
|
|
45
|
+
*
|
|
46
|
+
* @copyright 2024 Great Detail Ltd
|
|
47
|
+
* @author Great Detail Ltd <info@greatdetail.com>
|
|
48
|
+
* @author Dom Webber <dom.webber@greatdetail.com>
|
|
49
|
+
* @see https://greatdetail.com
|
|
50
|
+
*/
|
|
51
|
+
|
|
52
|
+
type index_NetworkError = NetworkError;
|
|
53
|
+
declare const index_NetworkError: typeof NetworkError;
|
|
54
|
+
type index_SupportError = SupportError;
|
|
55
|
+
declare const index_SupportError: typeof SupportError;
|
|
56
|
+
declare namespace index {
|
|
57
|
+
export { index_NetworkError as NetworkError, index_SupportError as SupportError };
|
|
58
|
+
}
|
|
59
|
+
|
|
20
60
|
/**
|
|
21
61
|
* Great Detail Support System.
|
|
22
62
|
*
|
|
@@ -35,7 +75,14 @@ declare class KeyAuthentication implements Authentication {
|
|
|
35
75
|
static DEFAULT_NAME: string;
|
|
36
76
|
name: string;
|
|
37
77
|
constructor({ name, key, }?: Options$1);
|
|
38
|
-
filter(
|
|
78
|
+
filter(): Promise<{
|
|
79
|
+
headers: {
|
|
80
|
+
Authorization: string;
|
|
81
|
+
};
|
|
82
|
+
}>;
|
|
83
|
+
getHeaders(): {
|
|
84
|
+
Authorization: string;
|
|
85
|
+
};
|
|
39
86
|
}
|
|
40
87
|
|
|
41
88
|
/**
|
|
@@ -53,7 +100,14 @@ interface Options {
|
|
|
53
100
|
declare class TokenAuthentication implements Authentication {
|
|
54
101
|
#private;
|
|
55
102
|
constructor({ token }?: Options);
|
|
56
|
-
filter(
|
|
103
|
+
filter(): Promise<{
|
|
104
|
+
headers: {
|
|
105
|
+
Authorization: string;
|
|
106
|
+
};
|
|
107
|
+
}>;
|
|
108
|
+
getHeaders(): {
|
|
109
|
+
Authorization: string;
|
|
110
|
+
};
|
|
57
111
|
}
|
|
58
112
|
|
|
59
113
|
/**
|
|
@@ -76,7 +130,10 @@ declare class TokenAuthentication implements Authentication {
|
|
|
76
130
|
* @since 1.0.l0
|
|
77
131
|
*/
|
|
78
132
|
declare class PublicAuthentication implements Authentication {
|
|
79
|
-
filter(
|
|
133
|
+
filter(): Promise<{
|
|
134
|
+
headers: {};
|
|
135
|
+
}>;
|
|
136
|
+
getHeaders(): {};
|
|
80
137
|
}
|
|
81
138
|
|
|
82
|
-
export { DEFAULT_SUPPORT_BASE_URL, KeyAuthentication, PublicAuthentication, TokenAuthentication };
|
|
139
|
+
export { DEFAULT_SUPPORT_BASE_URL, index as Error, KeyAuthentication, PublicAuthentication, TokenAuthentication };
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as
|
|
1
|
+
import{a as d,b as c,c as a,d as p,e as n,f as i,g as l,h as f,i as y,j as u}from"./chunk-IXJNWCJL.js";var m={};d(m,{NetworkError:()=>f,SupportError:()=>l});var t=class r{static DEFAULT_NAME=a;name;#e;constructor({name:e=process.env[i]??r.DEFAULT_NAME,key:s=process.env[n]}={}){if(!s)throw new Error("API Key option must be specified when using Key Authentication");this.name=e,this.#e=s}async filter(){return{headers:this.getHeaders()}}getHeaders(){return{Authorization:`Basic ${btoa(this.name+":"+this.#e)}`}}};var o=class{#e;constructor({token:e=process.env[p]}={}){if(!e)throw new Error("Access Token option must be specified when using Token Authentication");this.#e=e}async filter(){return{headers:this.getHeaders()}}getHeaders(){return{Authorization:`Bearer ${this.#e}`}}};export{y as Client,c as DEFAULT_SUPPORT_BASE_URL,m as Error,t as KeyAuthentication,u as PublicAuthentication,o as TokenAuthentication,y as default};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@great-detail/support-sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "JavaScript SDK for the Great Detail Support System",
|
|
6
6
|
"author": "Great Detail Ltd <info@greatdetail.com>",
|
|
@@ -62,6 +62,7 @@
|
|
|
62
62
|
"dependencies": {
|
|
63
63
|
"commander": "^12.1.0",
|
|
64
64
|
"cross-fetch": "^4.0.0",
|
|
65
|
+
"is-network-error": "^1.1.0",
|
|
65
66
|
"ora": "^8.0.1",
|
|
66
67
|
"zod": "^3.23.8"
|
|
67
68
|
},
|
|
@@ -7,25 +7,21 @@
|
|
|
7
7
|
* @see https://greatdetail.com
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
import
|
|
10
|
+
import FetchTransport from "../Transport/FetchTransport.js";
|
|
11
11
|
|
|
12
|
-
export interface Options
|
|
12
|
+
export interface Options {
|
|
13
13
|
request?: RequestInit;
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
export default class ListActions {
|
|
17
|
-
constructor(protected _transport:
|
|
17
|
+
constructor(protected _transport: FetchTransport) {}
|
|
18
18
|
|
|
19
|
-
public async send({ request = {}
|
|
19
|
+
public async send({ request = {} }: Options = {}) {
|
|
20
20
|
return this._transport
|
|
21
|
-
.send(
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
method: "GET",
|
|
26
|
-
},
|
|
27
|
-
options,
|
|
28
|
-
)
|
|
21
|
+
.send("v1/actions", {
|
|
22
|
+
...request,
|
|
23
|
+
method: "GET",
|
|
24
|
+
})
|
|
29
25
|
.then((response) => new ListActionsResponse(response));
|
|
30
26
|
}
|
|
31
27
|
}
|
|
@@ -7,11 +7,8 @@
|
|
|
7
7
|
* @see https://greatdetail.com
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
import {
|
|
11
|
-
|
|
12
|
-
KEY_ENV_VAR,
|
|
13
|
-
USER_ENV_VAR,
|
|
14
|
-
} from "../constants/index.js";
|
|
10
|
+
import { KEY_ENV_VAR, USER_ENV_VAR } from "../constants/environment.js";
|
|
11
|
+
import { DEFAULT_KEY_AUTHENTICATION_NAME } from "../constants/index.js";
|
|
15
12
|
import Authentication from "./index.js";
|
|
16
13
|
|
|
17
14
|
export interface Options {
|
|
@@ -39,13 +36,15 @@ export default class KeyAuthentication implements Authentication {
|
|
|
39
36
|
this.#key = key;
|
|
40
37
|
}
|
|
41
38
|
|
|
42
|
-
public async filter(
|
|
39
|
+
public async filter() {
|
|
43
40
|
return {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
41
|
+
headers: this.getHeaders(),
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
public getHeaders() {
|
|
46
|
+
return {
|
|
47
|
+
Authorization: `Basic ${btoa(this.name + ":" + this.#key)}`,
|
|
49
48
|
};
|
|
50
49
|
}
|
|
51
50
|
}
|
|
@@ -20,7 +20,13 @@ import Authentication from "./index.js";
|
|
|
20
20
|
* @since 1.0.l0
|
|
21
21
|
*/
|
|
22
22
|
export default class PublicAuthentication implements Authentication {
|
|
23
|
-
public async filter(
|
|
24
|
-
return
|
|
23
|
+
public async filter() {
|
|
24
|
+
return {
|
|
25
|
+
headers: this.getHeaders(),
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
public getHeaders() {
|
|
30
|
+
return {};
|
|
25
31
|
}
|
|
26
32
|
}
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* @see https://greatdetail.com
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
import { TOKEN_ENV_VAR } from "../constants/
|
|
10
|
+
import { TOKEN_ENV_VAR } from "../constants/environment.js";
|
|
11
11
|
import Authentication from "./index.js";
|
|
12
12
|
|
|
13
13
|
export interface Options {
|
|
@@ -27,13 +27,15 @@ export default class TokenAuthentication implements Authentication {
|
|
|
27
27
|
this.#token = token;
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
public async filter(
|
|
30
|
+
public async filter() {
|
|
31
31
|
return {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
32
|
+
headers: this.getHeaders(),
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
public getHeaders() {
|
|
37
|
+
return {
|
|
38
|
+
Authorization: `Bearer ${this.#token}`,
|
|
37
39
|
};
|
|
38
40
|
}
|
|
39
41
|
}
|
|
@@ -7,25 +7,21 @@
|
|
|
7
7
|
* @see https://greatdetail.com
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
import
|
|
10
|
+
import FetchTransport from "../Transport/FetchTransport.js";
|
|
11
11
|
|
|
12
|
-
export interface Options
|
|
12
|
+
export interface Options {
|
|
13
13
|
request?: RequestInit;
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
export default class ListChannels {
|
|
17
|
-
constructor(protected _transport:
|
|
17
|
+
constructor(protected _transport: FetchTransport) {}
|
|
18
18
|
|
|
19
|
-
public async send({ request = {}
|
|
19
|
+
public async send({ request = {} }: Options = {}) {
|
|
20
20
|
return this._transport
|
|
21
|
-
.send(
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
method: "GET",
|
|
26
|
-
},
|
|
27
|
-
options,
|
|
28
|
-
)
|
|
21
|
+
.send("v1/channels", {
|
|
22
|
+
...request,
|
|
23
|
+
method: "GET",
|
|
24
|
+
})
|
|
29
25
|
.then((response) => new ListChannelsResponse(response));
|
|
30
26
|
}
|
|
31
27
|
}
|
package/src/Client/index.ts
CHANGED
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
import ListActions from "../Action/ListActions.js";
|
|
11
11
|
import Authentication from "../Authentication/index.js";
|
|
12
12
|
import ListChannels from "../Channel/ListChannels.js";
|
|
13
|
+
import { BASE_URL_ENV_VAR } from "../constants/environment.js";
|
|
13
14
|
import { DEFAULT_SUPPORT_BASE_URL } from "../constants/index.js";
|
|
14
15
|
import GetContactVCFURL from "../Contact/ContactVCF/GetContactVCF.js";
|
|
15
16
|
import CreateContact from "../Contact/CreateContact.js";
|
|
@@ -35,7 +36,7 @@ import CreateResponseModel from "../Model/Response/CreateResponseModel.js";
|
|
|
35
36
|
import RequestStandardHeaders from "../Request/RequestStandardHeaders.js";
|
|
36
37
|
import GetSource from "../Source/GetSource.js";
|
|
37
38
|
import ListSources from "../Source/ListSources.js";
|
|
38
|
-
import
|
|
39
|
+
import FetchTransport from "../Transport/FetchTransport.js";
|
|
39
40
|
|
|
40
41
|
export interface Options {
|
|
41
42
|
baseURL?: string | URL;
|
|
@@ -44,13 +45,13 @@ export interface Options {
|
|
|
44
45
|
export default class Client {
|
|
45
46
|
public static DEFAULT_BASE_URL = DEFAULT_SUPPORT_BASE_URL;
|
|
46
47
|
|
|
47
|
-
public _transport:
|
|
48
|
+
public _transport: FetchTransport;
|
|
48
49
|
|
|
49
50
|
constructor(
|
|
50
51
|
authentication: Authentication,
|
|
51
52
|
{ baseURL, ...options }: Options = {},
|
|
52
53
|
) {
|
|
53
|
-
this._transport = new
|
|
54
|
+
this._transport = new FetchTransport({
|
|
54
55
|
requestFilterables: [new RequestStandardHeaders(), authentication],
|
|
55
56
|
...options,
|
|
56
57
|
baseURL: baseURL?.toString() ?? Client.getBaseURL(),
|
|
@@ -58,7 +59,7 @@ export default class Client {
|
|
|
58
59
|
}
|
|
59
60
|
|
|
60
61
|
public static getBaseURL(): string {
|
|
61
|
-
return process.env
|
|
62
|
+
return process.env[BASE_URL_ENV_VAR] ?? this.DEFAULT_BASE_URL;
|
|
62
63
|
}
|
|
63
64
|
|
|
64
65
|
public get action() {
|
|
@@ -80,7 +81,7 @@ export default class Client {
|
|
|
80
81
|
update: new UpdateContact(this._transport),
|
|
81
82
|
create: new CreateContact(this._transport),
|
|
82
83
|
vcf: {
|
|
83
|
-
|
|
84
|
+
get: new GetContactVCFURL(this._transport),
|
|
84
85
|
},
|
|
85
86
|
};
|
|
86
87
|
}
|
|
@@ -7,18 +7,37 @@
|
|
|
7
7
|
* @see https://greatdetail.com
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
import
|
|
10
|
+
import FetchTransport from "../../Transport/FetchTransport.js";
|
|
11
11
|
|
|
12
12
|
export interface Options {
|
|
13
13
|
id: string;
|
|
14
|
+
vcf?:
|
|
15
|
+
| {
|
|
16
|
+
variant?: "vcard";
|
|
17
|
+
format?: "vcf" | "qr";
|
|
18
|
+
}
|
|
19
|
+
| {
|
|
20
|
+
variant: "jcard";
|
|
21
|
+
format?: "json";
|
|
22
|
+
};
|
|
14
23
|
}
|
|
15
24
|
|
|
16
25
|
export default class GetContactVCFURL {
|
|
17
|
-
constructor(protected _transport:
|
|
26
|
+
constructor(protected _transport: FetchTransport) {}
|
|
18
27
|
|
|
19
|
-
public
|
|
20
|
-
|
|
21
|
-
|
|
28
|
+
public getURL({ id, vcf = {} }: Options) {
|
|
29
|
+
const variant = vcf.variant ?? "vcard";
|
|
30
|
+
const format = vcf.format ?? (vcf.variant === "vcard" ? "vcf" : "json");
|
|
31
|
+
|
|
32
|
+
const url = this._transport.getURL(
|
|
33
|
+
"v1/contacts/" +
|
|
34
|
+
encodeURIComponent(id) +
|
|
35
|
+
"/vcf?variant=" +
|
|
36
|
+
encodeURIComponent(variant) +
|
|
37
|
+
"&format=" +
|
|
38
|
+
encodeURIComponent(format),
|
|
22
39
|
);
|
|
40
|
+
|
|
41
|
+
return url;
|
|
23
42
|
}
|
|
24
43
|
}
|
|
@@ -8,9 +8,9 @@
|
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
10
|
import { z } from "zod";
|
|
11
|
-
import
|
|
11
|
+
import FetchTransport from "../Transport/FetchTransport.js";
|
|
12
12
|
|
|
13
|
-
export interface Options
|
|
13
|
+
export interface Options {
|
|
14
14
|
body: z.infer<typeof CreateContact.SCHEMA>;
|
|
15
15
|
request?: RequestInit;
|
|
16
16
|
}
|
|
@@ -23,23 +23,19 @@ export default class CreateContact {
|
|
|
23
23
|
telephoneNumber: z.string().optional(),
|
|
24
24
|
});
|
|
25
25
|
|
|
26
|
-
constructor(protected _transport:
|
|
26
|
+
constructor(protected _transport: FetchTransport) {}
|
|
27
27
|
|
|
28
|
-
public async send({ body, request = {}
|
|
28
|
+
public async send({ body, request = {} }: Options) {
|
|
29
29
|
return this._transport
|
|
30
|
-
.send(
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
...request.headers,
|
|
37
|
-
"Content-Type": "application/json",
|
|
38
|
-
},
|
|
39
|
-
body: JSON.stringify(CreateContact.SCHEMA.parse(body)),
|
|
30
|
+
.send("v1/contacts", {
|
|
31
|
+
...request,
|
|
32
|
+
method: "POST",
|
|
33
|
+
headers: {
|
|
34
|
+
...request.headers,
|
|
35
|
+
"Content-Type": "application/json",
|
|
40
36
|
},
|
|
41
|
-
|
|
42
|
-
)
|
|
37
|
+
body: JSON.stringify(CreateContact.SCHEMA.parse(body)),
|
|
38
|
+
})
|
|
43
39
|
.then((response) => new CreateContactResponse(response));
|
|
44
40
|
}
|
|
45
41
|
}
|
|
@@ -7,26 +7,22 @@
|
|
|
7
7
|
* @see https://greatdetail.com
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
import
|
|
10
|
+
import FetchTransport from "../Transport/FetchTransport.js";
|
|
11
11
|
|
|
12
|
-
export interface Options
|
|
12
|
+
export interface Options {
|
|
13
13
|
id: string;
|
|
14
14
|
request?: RequestInit;
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
export default class GetContact {
|
|
18
|
-
constructor(protected _transport:
|
|
18
|
+
constructor(protected _transport: FetchTransport) {}
|
|
19
19
|
|
|
20
|
-
public async send({ id, request = {}
|
|
20
|
+
public async send({ id, request = {} }: Options) {
|
|
21
21
|
return this._transport
|
|
22
|
-
.send(
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
method: "GET",
|
|
27
|
-
},
|
|
28
|
-
options,
|
|
29
|
-
)
|
|
22
|
+
.send("v1/contacts/" + encodeURIComponent(id), {
|
|
23
|
+
...request,
|
|
24
|
+
method: "GET",
|
|
25
|
+
})
|
|
30
26
|
.then((response) => new GetContactResponse(response));
|
|
31
27
|
}
|
|
32
28
|
}
|
|
@@ -7,25 +7,21 @@
|
|
|
7
7
|
* @see https://greatdetail.com
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
import
|
|
10
|
+
import FetchTransport from "../Transport/FetchTransport.js";
|
|
11
11
|
|
|
12
|
-
export interface Options
|
|
12
|
+
export interface Options {
|
|
13
13
|
request?: RequestInit;
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
export default class ListContacts {
|
|
17
|
-
constructor(protected _transport:
|
|
17
|
+
constructor(protected _transport: FetchTransport) {}
|
|
18
18
|
|
|
19
|
-
public async send({ request = {}
|
|
19
|
+
public async send({ request = {} }: Options = {}) {
|
|
20
20
|
return this._transport
|
|
21
|
-
.send(
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
method: "GET",
|
|
26
|
-
},
|
|
27
|
-
options,
|
|
28
|
-
)
|
|
21
|
+
.send("v1/contacts", {
|
|
22
|
+
...request,
|
|
23
|
+
method: "GET",
|
|
24
|
+
})
|
|
29
25
|
.then((response) => new ListContactsResponse(response));
|
|
30
26
|
}
|
|
31
27
|
}
|
|
@@ -7,26 +7,22 @@
|
|
|
7
7
|
* @see https://greatdetail.com
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
import
|
|
10
|
+
import FetchTransport from "../Transport/FetchTransport.js";
|
|
11
11
|
|
|
12
|
-
export interface Options
|
|
12
|
+
export interface Options {
|
|
13
13
|
id: string;
|
|
14
14
|
request?: RequestInit;
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
export default class ListLabelContacts {
|
|
18
|
-
constructor(protected _transport:
|
|
18
|
+
constructor(protected _transport: FetchTransport) {}
|
|
19
19
|
|
|
20
|
-
public async send({ id, request = {}
|
|
20
|
+
public async send({ id, request = {} }: Options) {
|
|
21
21
|
return this._transport
|
|
22
|
-
.send(
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
method: "GET",
|
|
27
|
-
},
|
|
28
|
-
options,
|
|
29
|
-
)
|
|
22
|
+
.send("v1/labels/" + encodeURIComponent(id) + "/contacts", {
|
|
23
|
+
...request,
|
|
24
|
+
method: "GET",
|
|
25
|
+
})
|
|
30
26
|
.then((response) => new ListLabelContactsResponse(response));
|
|
31
27
|
}
|
|
32
28
|
}
|
|
@@ -8,9 +8,9 @@
|
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
10
|
import { z } from "zod";
|
|
11
|
-
import
|
|
11
|
+
import FetchTransport from "../Transport/FetchTransport.js";
|
|
12
12
|
|
|
13
|
-
export interface Options
|
|
13
|
+
export interface Options {
|
|
14
14
|
id: string;
|
|
15
15
|
body: z.infer<typeof UpdateContact.SCHEMA>;
|
|
16
16
|
request?: RequestInit;
|
|
@@ -23,23 +23,19 @@ export default class UpdateContact {
|
|
|
23
23
|
telephoneNumber: z.string().optional(),
|
|
24
24
|
});
|
|
25
25
|
|
|
26
|
-
constructor(protected _transport:
|
|
26
|
+
constructor(protected _transport: FetchTransport) {}
|
|
27
27
|
|
|
28
|
-
public async send({ id, body, request = {}
|
|
28
|
+
public async send({ id, body, request = {} }: Options) {
|
|
29
29
|
return this._transport
|
|
30
|
-
.send(
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
...request.headers,
|
|
37
|
-
"Content-Type": "application/json",
|
|
38
|
-
},
|
|
39
|
-
body: JSON.stringify(UpdateContact.SCHEMA.parse(body)),
|
|
30
|
+
.send("v1/contacts/" + encodeURIComponent(id), {
|
|
31
|
+
...request,
|
|
32
|
+
method: "PATCH",
|
|
33
|
+
headers: {
|
|
34
|
+
...request.headers,
|
|
35
|
+
"Content-Type": "application/json",
|
|
40
36
|
},
|
|
41
|
-
|
|
42
|
-
)
|
|
37
|
+
body: JSON.stringify(UpdateContact.SCHEMA.parse(body)),
|
|
38
|
+
})
|
|
43
39
|
.then((response) => new UpdateContactResponse(response));
|
|
44
40
|
}
|
|
45
41
|
}
|