@great-detail/support-sdk 0.1.6 → 0.2.1
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-3OAKTXT5.js +1 -0
- package/dist/{chunk-GQPMRQEH.js → chunk-QJODVR4A.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-fAkhYzqW.d.cts → index-Dj17QRj0.d.cts} +135 -112
- package/dist/{index-fAkhYzqW.d.ts → index-Dj17QRj0.d.ts} +135 -112
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +138 -6
- package/dist/index.d.ts +138 -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 +13 -11
- 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 +20 -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-Q4LJP3V4.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,121 @@ 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
|
+
declare class AuthError extends SupportError {
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Great Detail Support System.
|
|
57
|
+
*
|
|
58
|
+
* @copyright 2024 Great Detail Ltd
|
|
59
|
+
* @author Great Detail Ltd <info@greatdetail.com>
|
|
60
|
+
* @author Dom Webber <dom.webber@greatdetail.com>
|
|
61
|
+
* @see https://greatdetail.com
|
|
62
|
+
*/
|
|
63
|
+
|
|
64
|
+
declare class AuthenticationError extends AuthError {
|
|
65
|
+
static unauthenticated(): AuthenticationError;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Great Detail Support System.
|
|
70
|
+
*
|
|
71
|
+
* @copyright 2024 Great Detail Ltd
|
|
72
|
+
* @author Great Detail Ltd <info@greatdetail.com>
|
|
73
|
+
* @author Dom Webber <dom.webber@greatdetail.com>
|
|
74
|
+
* @see https://greatdetail.com
|
|
75
|
+
*/
|
|
76
|
+
|
|
77
|
+
declare class AuthorizationError extends AuthError {
|
|
78
|
+
static forbidden(): AuthorizationError;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Great Detail Support System.
|
|
83
|
+
*
|
|
84
|
+
* @copyright 2024 Great Detail Ltd
|
|
85
|
+
* @author Great Detail Ltd <info@greatdetail.com>
|
|
86
|
+
* @author Dom Webber <dom.webber@greatdetail.com>
|
|
87
|
+
* @see https://greatdetail.com
|
|
88
|
+
*/
|
|
89
|
+
|
|
90
|
+
declare class ValidationError extends SupportError {
|
|
91
|
+
static badRequest(): ValidationError;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Great Detail Support System.
|
|
96
|
+
*
|
|
97
|
+
* @copyright 2024 Great Detail Ltd
|
|
98
|
+
* @author Great Detail Ltd <info@greatdetail.com>
|
|
99
|
+
* @author Dom Webber <dom.webber@greatdetail.com>
|
|
100
|
+
* @see https://greatdetail.com
|
|
101
|
+
*/
|
|
102
|
+
|
|
103
|
+
declare class LogicError extends SupportError {
|
|
104
|
+
static notFound(url: string): LogicError;
|
|
105
|
+
static forbiddenMethod(method: string, url: string): LogicError;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* Great Detail Support System.
|
|
110
|
+
*
|
|
111
|
+
* @copyright 2024 Great Detail Ltd
|
|
112
|
+
* @author Great Detail Ltd <info@greatdetail.com>
|
|
113
|
+
* @author Dom Webber <dom.webber@greatdetail.com>
|
|
114
|
+
* @see https://greatdetail.com
|
|
115
|
+
*/
|
|
116
|
+
|
|
117
|
+
type index_AuthError = AuthError;
|
|
118
|
+
declare const index_AuthError: typeof AuthError;
|
|
119
|
+
type index_AuthenticationError = AuthenticationError;
|
|
120
|
+
declare const index_AuthenticationError: typeof AuthenticationError;
|
|
121
|
+
type index_AuthorizationError = AuthorizationError;
|
|
122
|
+
declare const index_AuthorizationError: typeof AuthorizationError;
|
|
123
|
+
type index_LogicError = LogicError;
|
|
124
|
+
declare const index_LogicError: typeof LogicError;
|
|
125
|
+
type index_NetworkError = NetworkError;
|
|
126
|
+
declare const index_NetworkError: typeof NetworkError;
|
|
127
|
+
type index_SupportError = SupportError;
|
|
128
|
+
declare const index_SupportError: typeof SupportError;
|
|
129
|
+
type index_ValidationError = ValidationError;
|
|
130
|
+
declare const index_ValidationError: typeof ValidationError;
|
|
131
|
+
declare namespace index {
|
|
132
|
+
export { index_AuthError as AuthError, index_AuthenticationError as AuthenticationError, index_AuthorizationError as AuthorizationError, index_LogicError as LogicError, index_NetworkError as NetworkError, index_SupportError as SupportError, index_ValidationError as ValidationError };
|
|
133
|
+
}
|
|
134
|
+
|
|
20
135
|
/**
|
|
21
136
|
* Great Detail Support System.
|
|
22
137
|
*
|
|
@@ -35,7 +150,14 @@ declare class KeyAuthentication implements Authentication {
|
|
|
35
150
|
static DEFAULT_NAME: string;
|
|
36
151
|
name: string;
|
|
37
152
|
constructor({ name, key, }?: Options$1);
|
|
38
|
-
filter(
|
|
153
|
+
filter(): Promise<{
|
|
154
|
+
headers: {
|
|
155
|
+
Authorization: string;
|
|
156
|
+
};
|
|
157
|
+
}>;
|
|
158
|
+
getHeaders(): {
|
|
159
|
+
Authorization: string;
|
|
160
|
+
};
|
|
39
161
|
}
|
|
40
162
|
|
|
41
163
|
/**
|
|
@@ -53,7 +175,14 @@ interface Options {
|
|
|
53
175
|
declare class TokenAuthentication implements Authentication {
|
|
54
176
|
#private;
|
|
55
177
|
constructor({ token }?: Options);
|
|
56
|
-
filter(
|
|
178
|
+
filter(): Promise<{
|
|
179
|
+
headers: {
|
|
180
|
+
Authorization: string;
|
|
181
|
+
};
|
|
182
|
+
}>;
|
|
183
|
+
getHeaders(): {
|
|
184
|
+
Authorization: string;
|
|
185
|
+
};
|
|
57
186
|
}
|
|
58
187
|
|
|
59
188
|
/**
|
|
@@ -76,7 +205,10 @@ declare class TokenAuthentication implements Authentication {
|
|
|
76
205
|
* @since 1.0.l0
|
|
77
206
|
*/
|
|
78
207
|
declare class PublicAuthentication implements Authentication {
|
|
79
|
-
filter(
|
|
208
|
+
filter(): Promise<{
|
|
209
|
+
headers: {};
|
|
210
|
+
}>;
|
|
211
|
+
getHeaders(): {};
|
|
80
212
|
}
|
|
81
213
|
|
|
82
|
-
export { DEFAULT_SUPPORT_BASE_URL, KeyAuthentication, PublicAuthentication, TokenAuthentication };
|
|
214
|
+
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,121 @@ 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
|
+
declare class AuthError extends SupportError {
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Great Detail Support System.
|
|
57
|
+
*
|
|
58
|
+
* @copyright 2024 Great Detail Ltd
|
|
59
|
+
* @author Great Detail Ltd <info@greatdetail.com>
|
|
60
|
+
* @author Dom Webber <dom.webber@greatdetail.com>
|
|
61
|
+
* @see https://greatdetail.com
|
|
62
|
+
*/
|
|
63
|
+
|
|
64
|
+
declare class AuthenticationError extends AuthError {
|
|
65
|
+
static unauthenticated(): AuthenticationError;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Great Detail Support System.
|
|
70
|
+
*
|
|
71
|
+
* @copyright 2024 Great Detail Ltd
|
|
72
|
+
* @author Great Detail Ltd <info@greatdetail.com>
|
|
73
|
+
* @author Dom Webber <dom.webber@greatdetail.com>
|
|
74
|
+
* @see https://greatdetail.com
|
|
75
|
+
*/
|
|
76
|
+
|
|
77
|
+
declare class AuthorizationError extends AuthError {
|
|
78
|
+
static forbidden(): AuthorizationError;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Great Detail Support System.
|
|
83
|
+
*
|
|
84
|
+
* @copyright 2024 Great Detail Ltd
|
|
85
|
+
* @author Great Detail Ltd <info@greatdetail.com>
|
|
86
|
+
* @author Dom Webber <dom.webber@greatdetail.com>
|
|
87
|
+
* @see https://greatdetail.com
|
|
88
|
+
*/
|
|
89
|
+
|
|
90
|
+
declare class ValidationError extends SupportError {
|
|
91
|
+
static badRequest(): ValidationError;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Great Detail Support System.
|
|
96
|
+
*
|
|
97
|
+
* @copyright 2024 Great Detail Ltd
|
|
98
|
+
* @author Great Detail Ltd <info@greatdetail.com>
|
|
99
|
+
* @author Dom Webber <dom.webber@greatdetail.com>
|
|
100
|
+
* @see https://greatdetail.com
|
|
101
|
+
*/
|
|
102
|
+
|
|
103
|
+
declare class LogicError extends SupportError {
|
|
104
|
+
static notFound(url: string): LogicError;
|
|
105
|
+
static forbiddenMethod(method: string, url: string): LogicError;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* Great Detail Support System.
|
|
110
|
+
*
|
|
111
|
+
* @copyright 2024 Great Detail Ltd
|
|
112
|
+
* @author Great Detail Ltd <info@greatdetail.com>
|
|
113
|
+
* @author Dom Webber <dom.webber@greatdetail.com>
|
|
114
|
+
* @see https://greatdetail.com
|
|
115
|
+
*/
|
|
116
|
+
|
|
117
|
+
type index_AuthError = AuthError;
|
|
118
|
+
declare const index_AuthError: typeof AuthError;
|
|
119
|
+
type index_AuthenticationError = AuthenticationError;
|
|
120
|
+
declare const index_AuthenticationError: typeof AuthenticationError;
|
|
121
|
+
type index_AuthorizationError = AuthorizationError;
|
|
122
|
+
declare const index_AuthorizationError: typeof AuthorizationError;
|
|
123
|
+
type index_LogicError = LogicError;
|
|
124
|
+
declare const index_LogicError: typeof LogicError;
|
|
125
|
+
type index_NetworkError = NetworkError;
|
|
126
|
+
declare const index_NetworkError: typeof NetworkError;
|
|
127
|
+
type index_SupportError = SupportError;
|
|
128
|
+
declare const index_SupportError: typeof SupportError;
|
|
129
|
+
type index_ValidationError = ValidationError;
|
|
130
|
+
declare const index_ValidationError: typeof ValidationError;
|
|
131
|
+
declare namespace index {
|
|
132
|
+
export { index_AuthError as AuthError, index_AuthenticationError as AuthenticationError, index_AuthorizationError as AuthorizationError, index_LogicError as LogicError, index_NetworkError as NetworkError, index_SupportError as SupportError, index_ValidationError as ValidationError };
|
|
133
|
+
}
|
|
134
|
+
|
|
20
135
|
/**
|
|
21
136
|
* Great Detail Support System.
|
|
22
137
|
*
|
|
@@ -35,7 +150,14 @@ declare class KeyAuthentication implements Authentication {
|
|
|
35
150
|
static DEFAULT_NAME: string;
|
|
36
151
|
name: string;
|
|
37
152
|
constructor({ name, key, }?: Options$1);
|
|
38
|
-
filter(
|
|
153
|
+
filter(): Promise<{
|
|
154
|
+
headers: {
|
|
155
|
+
Authorization: string;
|
|
156
|
+
};
|
|
157
|
+
}>;
|
|
158
|
+
getHeaders(): {
|
|
159
|
+
Authorization: string;
|
|
160
|
+
};
|
|
39
161
|
}
|
|
40
162
|
|
|
41
163
|
/**
|
|
@@ -53,7 +175,14 @@ interface Options {
|
|
|
53
175
|
declare class TokenAuthentication implements Authentication {
|
|
54
176
|
#private;
|
|
55
177
|
constructor({ token }?: Options);
|
|
56
|
-
filter(
|
|
178
|
+
filter(): Promise<{
|
|
179
|
+
headers: {
|
|
180
|
+
Authorization: string;
|
|
181
|
+
};
|
|
182
|
+
}>;
|
|
183
|
+
getHeaders(): {
|
|
184
|
+
Authorization: string;
|
|
185
|
+
};
|
|
57
186
|
}
|
|
58
187
|
|
|
59
188
|
/**
|
|
@@ -76,7 +205,10 @@ declare class TokenAuthentication implements Authentication {
|
|
|
76
205
|
* @since 1.0.l0
|
|
77
206
|
*/
|
|
78
207
|
declare class PublicAuthentication implements Authentication {
|
|
79
|
-
filter(
|
|
208
|
+
filter(): Promise<{
|
|
209
|
+
headers: {};
|
|
210
|
+
}>;
|
|
211
|
+
getHeaders(): {};
|
|
80
212
|
}
|
|
81
213
|
|
|
82
|
-
export { DEFAULT_SUPPORT_BASE_URL, KeyAuthentication, PublicAuthentication, TokenAuthentication };
|
|
214
|
+
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 A,b as P,c as a,d as p,e as n,f as i,g as f,h as l,i as m,j as y,k as d,l as u,m as c,n as x,o as h}from"./chunk-3OAKTXT5.js";var R={};A(R,{AuthError:()=>l,AuthenticationError:()=>m,AuthorizationError:()=>y,LogicError:()=>d,NetworkError:()=>u,SupportError:()=>f,ValidationError:()=>c});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{x as Client,P as DEFAULT_SUPPORT_BASE_URL,R as Error,t as KeyAuthentication,h as PublicAuthentication,o as TokenAuthentication,x as default};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@great-detail/support-sdk",
|
|
3
|
-
"version": "0.1
|
|
3
|
+
"version": "0.2.1",
|
|
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,13 +7,13 @@
|
|
|
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
14
|
vcf?:
|
|
15
15
|
| {
|
|
16
|
-
variant
|
|
16
|
+
variant?: "vcard";
|
|
17
17
|
format?: "vcf" | "qr";
|
|
18
18
|
}
|
|
19
19
|
| {
|
|
@@ -23,17 +23,19 @@ export interface Options {
|
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
export default class GetContactVCFURL {
|
|
26
|
-
constructor(protected _transport:
|
|
26
|
+
constructor(protected _transport: FetchTransport) {}
|
|
27
27
|
|
|
28
|
-
public getURL({ id, vcf = {
|
|
29
|
-
const
|
|
30
|
-
|
|
31
|
-
);
|
|
28
|
+
public getURL({ id, vcf = {} }: Options) {
|
|
29
|
+
const variant = vcf.variant ?? "vcard";
|
|
30
|
+
const format = vcf.format ?? (vcf.variant === "vcard" ? "vcf" : "json");
|
|
32
31
|
|
|
33
|
-
url.
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
32
|
+
const url = this._transport.getURL(
|
|
33
|
+
"v1/contacts/" +
|
|
34
|
+
encodeURIComponent(id) +
|
|
35
|
+
"/vcf?variant=" +
|
|
36
|
+
encodeURIComponent(variant) +
|
|
37
|
+
"&format=" +
|
|
38
|
+
encodeURIComponent(format),
|
|
37
39
|
);
|
|
38
40
|
|
|
39
41
|
return url;
|
|
@@ -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
|
}
|