@lorikeetai/node-sdk 0.6.2 → 0.7.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/src/error.ts CHANGED
@@ -4,17 +4,19 @@ import { castToError, Headers } from './core';
4
4
 
5
5
  export class LorikeetError extends Error {}
6
6
 
7
- export class APIError extends LorikeetError {
8
- readonly status: number | undefined;
9
- readonly headers: Headers | undefined;
10
- readonly error: Object | undefined;
11
-
12
- constructor(
13
- status: number | undefined,
14
- error: Object | undefined,
15
- message: string | undefined,
16
- headers: Headers | undefined,
17
- ) {
7
+ export class APIError<
8
+ TStatus extends number | undefined = number | undefined,
9
+ THeaders extends Headers | undefined = Headers | undefined,
10
+ TError extends Object | undefined = Object | undefined,
11
+ > extends LorikeetError {
12
+ /** HTTP status for the response that caused the error */
13
+ readonly status: TStatus;
14
+ /** HTTP headers for the response that caused the error */
15
+ readonly headers: THeaders;
16
+ /** JSON body of the response that caused the error */
17
+ readonly error: TError;
18
+
19
+ constructor(status: TStatus, error: TError, message: string | undefined, headers: THeaders) {
18
20
  super(`${APIError.makeMessage(status, error, message)}`);
19
21
  this.status = status;
20
22
  this.headers = headers;
@@ -48,7 +50,7 @@ export class APIError extends LorikeetError {
48
50
  message: string | undefined,
49
51
  headers: Headers | undefined,
50
52
  ): APIError {
51
- if (!status) {
53
+ if (!status || !headers) {
52
54
  return new APIConnectionError({ message, cause: castToError(errorResponse) });
53
55
  }
54
56
 
@@ -90,17 +92,13 @@ export class APIError extends LorikeetError {
90
92
  }
91
93
  }
92
94
 
93
- export class APIUserAbortError extends APIError {
94
- override readonly status: undefined = undefined;
95
-
95
+ export class APIUserAbortError extends APIError<undefined, undefined, undefined> {
96
96
  constructor({ message }: { message?: string } = {}) {
97
97
  super(undefined, undefined, message || 'Request was aborted.', undefined);
98
98
  }
99
99
  }
100
100
 
101
- export class APIConnectionError extends APIError {
102
- override readonly status: undefined = undefined;
103
-
101
+ export class APIConnectionError extends APIError<undefined, undefined, undefined> {
104
102
  constructor({ message, cause }: { message?: string | undefined; cause?: Error | undefined }) {
105
103
  super(undefined, undefined, message || 'Connection error.', undefined);
106
104
  // in some environments the 'cause' property is already declared
@@ -115,32 +113,18 @@ export class APIConnectionTimeoutError extends APIConnectionError {
115
113
  }
116
114
  }
117
115
 
118
- export class BadRequestError extends APIError {
119
- override readonly status: 400 = 400;
120
- }
116
+ export class BadRequestError extends APIError<400, Headers> {}
121
117
 
122
- export class AuthenticationError extends APIError {
123
- override readonly status: 401 = 401;
124
- }
118
+ export class AuthenticationError extends APIError<401, Headers> {}
125
119
 
126
- export class PermissionDeniedError extends APIError {
127
- override readonly status: 403 = 403;
128
- }
120
+ export class PermissionDeniedError extends APIError<403, Headers> {}
129
121
 
130
- export class NotFoundError extends APIError {
131
- override readonly status: 404 = 404;
132
- }
122
+ export class NotFoundError extends APIError<404, Headers> {}
133
123
 
134
- export class ConflictError extends APIError {
135
- override readonly status: 409 = 409;
136
- }
124
+ export class ConflictError extends APIError<409, Headers> {}
137
125
 
138
- export class UnprocessableEntityError extends APIError {
139
- override readonly status: 422 = 422;
140
- }
126
+ export class UnprocessableEntityError extends APIError<422, Headers> {}
141
127
 
142
- export class RateLimitError extends APIError {
143
- override readonly status: 429 = 429;
144
- }
128
+ export class RateLimitError extends APIError<429, Headers> {}
145
129
 
146
- export class InternalServerError extends APIError {}
130
+ export class InternalServerError extends APIError<number, Headers> {}
@@ -89,13 +89,18 @@ export interface ChatGenerateResponse {
89
89
  /**
90
90
  * The latest message type - useful for polling
91
91
  */
92
- latestMessageType: 'CUSTOMER' | 'PENDING_RESPONSE' | 'DRAFT_RESPONSE' | 'BOT_RESPONSE';
92
+ latestMessageType: 'CUSTOMER' | 'BOT_RESPONSE' | 'PENDING_RESPONSE' | 'DRAFT_RESPONSE';
93
93
 
94
94
  /**
95
95
  * The full list of messages. This endpoint supports markdown.
96
96
  */
97
97
  messages: Array<ChatGenerateResponse.Message>;
98
98
 
99
+ /**
100
+ * The status of the conversation
101
+ */
102
+ status: 'Unprocessed' | 'Processing' | 'Unhandled' | 'Responded' | 'Error' | 'Escalated' | 'Processed';
103
+
99
104
  /**
100
105
  * The timestamp of when the ticket was last updated in our system.
101
106
  */
@@ -109,6 +114,11 @@ export namespace ChatGenerateResponse {
109
114
  */
110
115
  id: string;
111
116
 
117
+ /**
118
+ * Attachments that were attached to the message
119
+ */
120
+ attachments: Array<Message.Attachment>;
121
+
112
122
  /**
113
123
  * The content of the message. Markdown on plain text.
114
124
  */
@@ -127,7 +137,26 @@ export namespace ChatGenerateResponse {
127
137
  /**
128
138
  * The type of the message
129
139
  */
130
- type: 'CUSTOMER' | 'PENDING_RESPONSE' | 'DRAFT_RESPONSE' | 'BOT_RESPONSE';
140
+ type: 'CUSTOMER' | 'BOT_RESPONSE' | 'PENDING_RESPONSE' | 'DRAFT_RESPONSE';
141
+ }
142
+
143
+ export namespace Message {
144
+ export interface Attachment {
145
+ /**
146
+ * The name of the attachment
147
+ */
148
+ name: string;
149
+
150
+ /**
151
+ * The type of the attachment
152
+ */
153
+ type: string;
154
+
155
+ /**
156
+ * The URL of the attachment
157
+ */
158
+ url: string;
159
+ }
131
160
  }
132
161
  }
133
162
 
@@ -145,13 +174,18 @@ export interface ChatGetResponse {
145
174
  /**
146
175
  * The latest message type - useful for polling
147
176
  */
148
- latestMessageType: 'CUSTOMER' | 'PENDING_RESPONSE' | 'DRAFT_RESPONSE' | 'BOT_RESPONSE';
177
+ latestMessageType: 'CUSTOMER' | 'BOT_RESPONSE' | 'PENDING_RESPONSE' | 'DRAFT_RESPONSE';
149
178
 
150
179
  /**
151
180
  * The full list of messages. This endpoint supports markdown.
152
181
  */
153
182
  messages: Array<ChatGetResponse.Message>;
154
183
 
184
+ /**
185
+ * The status of the conversation
186
+ */
187
+ status: 'Unprocessed' | 'Processing' | 'Unhandled' | 'Responded' | 'Error' | 'Escalated' | 'Processed';
188
+
155
189
  /**
156
190
  * The timestamp of when the ticket was last updated in our system.
157
191
  */
@@ -165,6 +199,11 @@ export namespace ChatGetResponse {
165
199
  */
166
200
  id: string;
167
201
 
202
+ /**
203
+ * Attachments that were attached to the message
204
+ */
205
+ attachments: Array<Message.Attachment>;
206
+
168
207
  /**
169
208
  * The content of the message. Markdown on plain text.
170
209
  */
@@ -183,7 +222,26 @@ export namespace ChatGetResponse {
183
222
  /**
184
223
  * The type of the message
185
224
  */
186
- type: 'CUSTOMER' | 'PENDING_RESPONSE' | 'DRAFT_RESPONSE' | 'BOT_RESPONSE';
225
+ type: 'CUSTOMER' | 'BOT_RESPONSE' | 'PENDING_RESPONSE' | 'DRAFT_RESPONSE';
226
+ }
227
+
228
+ export namespace Message {
229
+ export interface Attachment {
230
+ /**
231
+ * The name of the attachment
232
+ */
233
+ name: string;
234
+
235
+ /**
236
+ * The type of the attachment
237
+ */
238
+ type: string;
239
+
240
+ /**
241
+ * The URL of the attachment
242
+ */
243
+ url: string;
244
+ }
187
245
  }
188
246
  }
189
247
 
@@ -197,9 +255,19 @@ export interface ChatStartResponse {
197
255
  * The timestamp of the when the conversation was created in our system.
198
256
  */
199
257
  createdAt: string;
258
+
259
+ /**
260
+ * The status of the conversation
261
+ */
262
+ status: 'Unprocessed' | 'Processing' | 'Unhandled' | 'Responded' | 'Error' | 'Escalated' | 'Processed';
200
263
  }
201
264
 
202
265
  export interface ChatGenerateParams {
266
+ /**
267
+ * Attachments to be sent with the message
268
+ */
269
+ attachments: Array<ChatGenerateParams.Attachment>;
270
+
203
271
  /**
204
272
  * The ID of the conversation
205
273
  */
@@ -214,7 +282,64 @@ export interface ChatGenerateParams {
214
282
  * Any additional customer information, that has changed in the course of the
215
283
  * conversation.
216
284
  */
217
- customer?: unknown;
285
+ customer?: ChatGenerateParams.Customer;
286
+ }
287
+
288
+ export namespace ChatGenerateParams {
289
+ export interface Attachment {
290
+ /**
291
+ * The name of the attachment
292
+ */
293
+ name: string;
294
+
295
+ /**
296
+ * The type of the attachment
297
+ */
298
+ type: string;
299
+
300
+ /**
301
+ * The URL of the attachment
302
+ */
303
+ url: string;
304
+ }
305
+
306
+ /**
307
+ * Any additional customer information, that has changed in the course of the
308
+ * conversation.
309
+ */
310
+ export interface Customer {
311
+ /**
312
+ * The display name of the customer
313
+ */
314
+ displayName?: string;
315
+
316
+ /**
317
+ * The email of the customer
318
+ */
319
+ email?: string;
320
+
321
+ /**
322
+ * The first name of the customer
323
+ */
324
+ firstName?: string;
325
+
326
+ /**
327
+ * The last name of the customer
328
+ */
329
+ lastName?: string;
330
+
331
+ /**
332
+ * The id of the customer in the ticketing system. For the SDK this needs to be
333
+ * stable and unique
334
+ */
335
+ remoteId?: string;
336
+
337
+ /**
338
+ * The id of the customer in your own primary database or a unique identifier, for
339
+ * example a cookie
340
+ */
341
+ subscriberCustomerId?: string;
342
+ }
218
343
  }
219
344
 
220
345
  export interface ChatGetParams {
@@ -31,13 +31,18 @@ export interface EmailGenerateResponse {
31
31
  /**
32
32
  * The latest message type - useful for polling
33
33
  */
34
- latestMessageType: 'CUSTOMER' | 'PENDING_RESPONSE' | 'DRAFT_RESPONSE' | 'BOT_RESPONSE';
34
+ latestMessageType: 'CUSTOMER' | 'BOT_RESPONSE' | 'PENDING_RESPONSE' | 'DRAFT_RESPONSE';
35
35
 
36
36
  /**
37
37
  * The full list of messages. This endpoint supports markdown.
38
38
  */
39
39
  messages: Array<EmailGenerateResponse.Message>;
40
40
 
41
+ /**
42
+ * The status of the conversation
43
+ */
44
+ status: 'Unprocessed' | 'Processing' | 'Unhandled' | 'Responded' | 'Error' | 'Escalated' | 'Processed';
45
+
41
46
  /**
42
47
  * The timestamp of when the ticket was last updated in our system.
43
48
  */
@@ -51,6 +56,11 @@ export namespace EmailGenerateResponse {
51
56
  */
52
57
  id: string;
53
58
 
59
+ /**
60
+ * Attachments that were attached to the message
61
+ */
62
+ attachments: Array<Message.Attachment>;
63
+
54
64
  /**
55
65
  * The content of the message. Markdown on plain text.
56
66
  */
@@ -69,7 +79,26 @@ export namespace EmailGenerateResponse {
69
79
  /**
70
80
  * The type of the message
71
81
  */
72
- type: 'CUSTOMER' | 'PENDING_RESPONSE' | 'DRAFT_RESPONSE' | 'BOT_RESPONSE';
82
+ type: 'CUSTOMER' | 'BOT_RESPONSE' | 'PENDING_RESPONSE' | 'DRAFT_RESPONSE';
83
+ }
84
+
85
+ export namespace Message {
86
+ export interface Attachment {
87
+ /**
88
+ * The name of the attachment
89
+ */
90
+ name: string;
91
+
92
+ /**
93
+ * The type of the attachment
94
+ */
95
+ type: string;
96
+
97
+ /**
98
+ * The URL of the attachment
99
+ */
100
+ url: string;
101
+ }
73
102
  }
74
103
  }
75
104
 
@@ -87,13 +116,18 @@ export interface EmailGetResponse {
87
116
  /**
88
117
  * The latest message type - useful for polling
89
118
  */
90
- latestMessageType: 'CUSTOMER' | 'PENDING_RESPONSE' | 'DRAFT_RESPONSE' | 'BOT_RESPONSE';
119
+ latestMessageType: 'CUSTOMER' | 'BOT_RESPONSE' | 'PENDING_RESPONSE' | 'DRAFT_RESPONSE';
91
120
 
92
121
  /**
93
122
  * The full list of messages. This endpoint supports markdown.
94
123
  */
95
124
  messages: Array<EmailGetResponse.Message>;
96
125
 
126
+ /**
127
+ * The status of the conversation
128
+ */
129
+ status: 'Unprocessed' | 'Processing' | 'Unhandled' | 'Responded' | 'Error' | 'Escalated' | 'Processed';
130
+
97
131
  /**
98
132
  * The timestamp of when the ticket was last updated in our system.
99
133
  */
@@ -107,6 +141,11 @@ export namespace EmailGetResponse {
107
141
  */
108
142
  id: string;
109
143
 
144
+ /**
145
+ * Attachments that were attached to the message
146
+ */
147
+ attachments: Array<Message.Attachment>;
148
+
110
149
  /**
111
150
  * The content of the message. Markdown on plain text.
112
151
  */
@@ -125,7 +164,26 @@ export namespace EmailGetResponse {
125
164
  /**
126
165
  * The type of the message
127
166
  */
128
- type: 'CUSTOMER' | 'PENDING_RESPONSE' | 'DRAFT_RESPONSE' | 'BOT_RESPONSE';
167
+ type: 'CUSTOMER' | 'BOT_RESPONSE' | 'PENDING_RESPONSE' | 'DRAFT_RESPONSE';
168
+ }
169
+
170
+ export namespace Message {
171
+ export interface Attachment {
172
+ /**
173
+ * The name of the attachment
174
+ */
175
+ name: string;
176
+
177
+ /**
178
+ * The type of the attachment
179
+ */
180
+ type: string;
181
+
182
+ /**
183
+ * The URL of the attachment
184
+ */
185
+ url: string;
186
+ }
129
187
  }
130
188
  }
131
189
 
@@ -139,9 +197,19 @@ export interface EmailStartResponse {
139
197
  * The timestamp of the when the conversation was created in our system.
140
198
  */
141
199
  createdAt: string;
200
+
201
+ /**
202
+ * The status of the conversation
203
+ */
204
+ status: 'Unprocessed' | 'Processing' | 'Unhandled' | 'Responded' | 'Error' | 'Escalated' | 'Processed';
142
205
  }
143
206
 
144
207
  export interface EmailGenerateParams {
208
+ /**
209
+ * Attachments to be sent with the message
210
+ */
211
+ attachments: Array<EmailGenerateParams.Attachment>;
212
+
145
213
  /**
146
214
  * The ID of the conversation
147
215
  */
@@ -156,7 +224,64 @@ export interface EmailGenerateParams {
156
224
  * Any additional customer information, that has changed in the course of the
157
225
  * conversation.
158
226
  */
159
- customer?: unknown;
227
+ customer?: EmailGenerateParams.Customer;
228
+ }
229
+
230
+ export namespace EmailGenerateParams {
231
+ export interface Attachment {
232
+ /**
233
+ * The name of the attachment
234
+ */
235
+ name: string;
236
+
237
+ /**
238
+ * The type of the attachment
239
+ */
240
+ type: string;
241
+
242
+ /**
243
+ * The URL of the attachment
244
+ */
245
+ url: string;
246
+ }
247
+
248
+ /**
249
+ * Any additional customer information, that has changed in the course of the
250
+ * conversation.
251
+ */
252
+ export interface Customer {
253
+ /**
254
+ * The display name of the customer
255
+ */
256
+ displayName?: string;
257
+
258
+ /**
259
+ * The email of the customer
260
+ */
261
+ email?: string;
262
+
263
+ /**
264
+ * The first name of the customer
265
+ */
266
+ firstName?: string;
267
+
268
+ /**
269
+ * The last name of the customer
270
+ */
271
+ lastName?: string;
272
+
273
+ /**
274
+ * The id of the customer in the ticketing system. For the SDK this needs to be
275
+ * stable and unique
276
+ */
277
+ remoteId?: string;
278
+
279
+ /**
280
+ * The id of the customer in your own primary database or a unique identifier, for
281
+ * example a cookie
282
+ */
283
+ subscriberCustomerId?: string;
284
+ }
160
285
  }
161
286
 
162
287
  export interface EmailGetParams {
package/src/version.ts CHANGED
@@ -1 +1 @@
1
- export const VERSION = '0.6.2'; // x-release-please-version
1
+ export const VERSION = '0.7.0'; // x-release-please-version
package/version.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- export declare const VERSION = "0.6.2";
1
+ export declare const VERSION = "0.7.0";
2
2
  //# sourceMappingURL=version.d.ts.map
package/version.js CHANGED
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.VERSION = void 0;
4
- exports.VERSION = '0.6.2'; // x-release-please-version
4
+ exports.VERSION = '0.7.0'; // x-release-please-version
5
5
  //# sourceMappingURL=version.js.map
package/version.mjs CHANGED
@@ -1,2 +1,2 @@
1
- export const VERSION = '0.6.2'; // x-release-please-version
1
+ export const VERSION = '0.7.0'; // x-release-please-version
2
2
  //# sourceMappingURL=version.mjs.map