@servicetitan/titan-chatbot-api 6.1.0 → 7.0.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/CHANGELOG.md +24 -0
- package/dist/api-client/__mocks__/chatbot-api-client.mock.d.ts +1 -1
- package/dist/api-client/__mocks__/chatbot-api-client.mock.d.ts.map +1 -1
- package/dist/api-client/__mocks__/chatbot-api-client.mock.js +6 -6
- package/dist/api-client/__mocks__/chatbot-api-client.mock.js.map +1 -1
- package/dist/api-client/base/chatbot-api-client.d.ts +1 -1
- package/dist/api-client/base/chatbot-api-client.d.ts.map +1 -1
- package/dist/api-client/help-center/chatbot-api-client.d.ts +1 -1
- package/dist/api-client/help-center/chatbot-api-client.d.ts.map +1 -1
- package/dist/api-client/help-center/chatbot-api-client.js +7 -4
- package/dist/api-client/help-center/chatbot-api-client.js.map +1 -1
- package/dist/api-client/titan-chat/__tests__/native-client.test.d.ts +2 -0
- package/dist/api-client/titan-chat/__tests__/native-client.test.d.ts.map +1 -0
- package/dist/api-client/titan-chat/__tests__/native-client.test.js +36 -0
- package/dist/api-client/titan-chat/__tests__/native-client.test.js.map +1 -0
- package/dist/api-client/titan-chat/chatbot-api-client.d.ts +2 -2
- package/dist/api-client/titan-chat/chatbot-api-client.d.ts.map +1 -1
- package/dist/api-client/titan-chat/chatbot-api-client.js +5 -5
- package/dist/api-client/titan-chat/chatbot-api-client.js.map +1 -1
- package/dist/api-client/titan-chat/native-client.d.ts +98 -40
- package/dist/api-client/titan-chat/native-client.d.ts.map +1 -1
- package/dist/api-client/titan-chat/native-client.js +436 -384
- package/dist/api-client/titan-chat/native-client.js.map +1 -1
- package/dist/stores/chatbot-ui-backend.store.d.ts.map +1 -1
- package/dist/stores/chatbot-ui-backend.store.js +17 -16
- package/dist/stores/chatbot-ui-backend.store.js.map +1 -1
- package/dist/stores/chatbot-ui.store.d.ts +5 -4
- package/dist/stores/chatbot-ui.store.d.ts.map +1 -1
- package/dist/stores/chatbot-ui.store.js +4 -6
- package/dist/stores/chatbot-ui.store.js.map +1 -1
- package/dist/stores/index.d.ts +1 -1
- package/dist/stores/index.d.ts.map +1 -1
- package/dist/stores/message-feedback-base.store.d.ts +2 -1
- package/dist/stores/message-feedback-base.store.d.ts.map +1 -1
- package/dist/stores/message-feedback-guardrail.store.d.ts +2 -3
- package/dist/stores/message-feedback-guardrail.store.d.ts.map +1 -1
- package/dist/stores/message-feedback-guardrail.store.js +4 -10
- package/dist/stores/message-feedback-guardrail.store.js.map +1 -1
- package/dist/stores/message-feedback.store.d.ts +2 -3
- package/dist/stores/message-feedback.store.d.ts.map +1 -1
- package/dist/stores/message-feedback.store.js +3 -6
- package/dist/stores/message-feedback.store.js.map +1 -1
- package/dist/stores/session-feedback.store.d.ts +2 -2
- package/dist/stores/session-feedback.store.d.ts.map +1 -1
- package/dist/stores/session-feedback.store.js +3 -3
- package/dist/stores/session-feedback.store.js.map +1 -1
- package/package.json +4 -4
- package/src/api-client/__mocks__/chatbot-api-client.mock.ts +1 -1
- package/src/api-client/base/chatbot-api-client.ts +4 -1
- package/src/api-client/help-center/chatbot-api-client.ts +9 -5
- package/src/api-client/titan-chat/__tests__/native-client.test.ts +37 -0
- package/src/api-client/titan-chat/chatbot-api-client.ts +7 -7
- package/src/api-client/titan-chat/native-client.ts +622 -424
- package/src/stores/chatbot-ui-backend.store.ts +19 -16
- package/src/stores/chatbot-ui.store.ts +7 -10
- package/src/stores/index.ts +1 -1
- package/src/stores/message-feedback-base.store.ts +7 -1
- package/src/stores/message-feedback-guardrail.store.ts +6 -12
- package/src/stores/message-feedback.store.ts +5 -8
- package/src/stores/session-feedback.store.ts +4 -3
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -8,22 +8,16 @@
|
|
|
8
8
|
/* eslint-disable */
|
|
9
9
|
// ReSharper disable InconsistentNaming
|
|
10
10
|
|
|
11
|
-
import axios, {
|
|
12
|
-
AxiosError,
|
|
13
|
-
AxiosInstance,
|
|
14
|
-
AxiosRequestConfig,
|
|
15
|
-
AxiosResponse,
|
|
16
|
-
CancelToken,
|
|
17
|
-
} from 'axios';
|
|
18
|
-
|
|
19
11
|
export class Client {
|
|
20
|
-
|
|
21
|
-
|
|
12
|
+
private http: { fetch(url: RequestInfo, init?: RequestInit): Promise<Response> };
|
|
13
|
+
private baseUrl: string;
|
|
22
14
|
protected jsonParseReviver: ((key: string, value: any) => any) | undefined = undefined;
|
|
23
15
|
|
|
24
|
-
constructor(
|
|
25
|
-
|
|
26
|
-
|
|
16
|
+
constructor(
|
|
17
|
+
baseUrl?: string,
|
|
18
|
+
http?: { fetch(url: RequestInfo, init?: RequestInit): Promise<Response> }
|
|
19
|
+
) {
|
|
20
|
+
this.http = http ? http : (window as any);
|
|
27
21
|
this.baseUrl = baseUrl ?? '';
|
|
28
22
|
}
|
|
29
23
|
|
|
@@ -46,57 +40,46 @@ export class Client {
|
|
|
46
40
|
|
|
47
41
|
const content_ = JSON.stringify(body);
|
|
48
42
|
|
|
49
|
-
let options_:
|
|
50
|
-
|
|
43
|
+
let options_: RequestInit = {
|
|
44
|
+
body: content_,
|
|
51
45
|
method: 'POST',
|
|
52
|
-
|
|
46
|
+
signal,
|
|
53
47
|
headers: {
|
|
54
48
|
'X-Client-ID':
|
|
55
49
|
x_Client_ID !== undefined && x_Client_ID !== null ? '' + x_Client_ID : '',
|
|
56
50
|
'Content-Type': 'application/json',
|
|
57
51
|
'Accept': 'text/plain',
|
|
58
52
|
},
|
|
59
|
-
signal,
|
|
60
53
|
};
|
|
61
54
|
|
|
62
|
-
return this.
|
|
63
|
-
.
|
|
64
|
-
|
|
65
|
-
if (isAxiosError(_error) && _error.response) {
|
|
66
|
-
return _error.response;
|
|
67
|
-
} else {
|
|
68
|
-
throw _error;
|
|
69
|
-
}
|
|
70
|
-
})
|
|
71
|
-
.then((_response: AxiosResponse) => {
|
|
72
|
-
return this.processFeedback(_response);
|
|
73
|
-
});
|
|
55
|
+
return this.http.fetch(url_, options_).then((_response: Response) => {
|
|
56
|
+
return this.processFeedback(_response);
|
|
57
|
+
});
|
|
74
58
|
}
|
|
75
59
|
|
|
76
|
-
protected processFeedback(response:
|
|
60
|
+
protected processFeedback(response: Response): Promise<Feedback> {
|
|
77
61
|
const status = response.status;
|
|
78
62
|
let _headers: any = {};
|
|
79
|
-
if (response.headers &&
|
|
80
|
-
|
|
81
|
-
if (response.headers.hasOwnProperty(k)) {
|
|
82
|
-
_headers[k] = response.headers[k];
|
|
83
|
-
}
|
|
84
|
-
}
|
|
63
|
+
if (response.headers && response.headers.forEach) {
|
|
64
|
+
response.headers.forEach((v: any, k: any) => (_headers[k] = v));
|
|
85
65
|
}
|
|
86
66
|
if (status === 200) {
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
67
|
+
return response.text().then(_responseText => {
|
|
68
|
+
let result200: any = null;
|
|
69
|
+
let resultData200 =
|
|
70
|
+
_responseText === '' ? null : JSON.parse(_responseText, this.jsonParseReviver);
|
|
71
|
+
result200 = Feedback.fromJS(resultData200);
|
|
72
|
+
return result200;
|
|
73
|
+
});
|
|
92
74
|
} else if (status !== 200 && status !== 204) {
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
75
|
+
return response.text().then(_responseText => {
|
|
76
|
+
return throwException(
|
|
77
|
+
'An unexpected server error occurred.',
|
|
78
|
+
status,
|
|
79
|
+
_responseText,
|
|
80
|
+
_headers
|
|
81
|
+
);
|
|
82
|
+
});
|
|
100
83
|
}
|
|
101
84
|
return Promise.resolve<Feedback>(null as any);
|
|
102
85
|
}
|
|
@@ -120,66 +103,58 @@ export class Client {
|
|
|
120
103
|
|
|
121
104
|
const content_ = JSON.stringify(body);
|
|
122
105
|
|
|
123
|
-
let options_:
|
|
124
|
-
|
|
106
|
+
let options_: RequestInit = {
|
|
107
|
+
body: content_,
|
|
125
108
|
method: 'POST',
|
|
126
|
-
|
|
109
|
+
signal,
|
|
127
110
|
headers: {
|
|
128
111
|
'X-Client-ID':
|
|
129
112
|
x_Client_ID !== undefined && x_Client_ID !== null ? '' + x_Client_ID : '',
|
|
130
113
|
'Content-Type': 'application/json',
|
|
131
114
|
'Accept': 'text/plain',
|
|
132
115
|
},
|
|
133
|
-
signal,
|
|
134
116
|
};
|
|
135
117
|
|
|
136
|
-
return this.
|
|
137
|
-
.
|
|
138
|
-
|
|
139
|
-
if (isAxiosError(_error) && _error.response) {
|
|
140
|
-
return _error.response;
|
|
141
|
-
} else {
|
|
142
|
-
throw _error;
|
|
143
|
-
}
|
|
144
|
-
})
|
|
145
|
-
.then((_response: AxiosResponse) => {
|
|
146
|
-
return this.processFollowUpEmail(_response);
|
|
147
|
-
});
|
|
118
|
+
return this.http.fetch(url_, options_).then((_response: Response) => {
|
|
119
|
+
return this.processFollowUpEmail(_response);
|
|
120
|
+
});
|
|
148
121
|
}
|
|
149
122
|
|
|
150
|
-
protected processFollowUpEmail(response:
|
|
123
|
+
protected processFollowUpEmail(response: Response): Promise<BotMessage> {
|
|
151
124
|
const status = response.status;
|
|
152
125
|
let _headers: any = {};
|
|
153
|
-
if (response.headers &&
|
|
154
|
-
|
|
155
|
-
if (response.headers.hasOwnProperty(k)) {
|
|
156
|
-
_headers[k] = response.headers[k];
|
|
157
|
-
}
|
|
158
|
-
}
|
|
126
|
+
if (response.headers && response.headers.forEach) {
|
|
127
|
+
response.headers.forEach((v: any, k: any) => (_headers[k] = v));
|
|
159
128
|
}
|
|
160
129
|
if (status === 200) {
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
130
|
+
return response.text().then(_responseText => {
|
|
131
|
+
let result200: any = null;
|
|
132
|
+
let resultData200 =
|
|
133
|
+
_responseText === '' ? null : JSON.parse(_responseText, this.jsonParseReviver);
|
|
134
|
+
result200 = BotMessage.fromJS(resultData200);
|
|
135
|
+
return result200;
|
|
136
|
+
});
|
|
166
137
|
} else if (status === 500) {
|
|
167
|
-
|
|
168
|
-
|
|
138
|
+
return response.text().then(_responseText => {
|
|
139
|
+
return throwException('Server Error', status, _responseText, _headers);
|
|
140
|
+
});
|
|
169
141
|
} else if (status === 502) {
|
|
170
|
-
|
|
171
|
-
|
|
142
|
+
return response.text().then(_responseText => {
|
|
143
|
+
return throwException('Server Error', status, _responseText, _headers);
|
|
144
|
+
});
|
|
172
145
|
} else if (status === 504) {
|
|
173
|
-
|
|
174
|
-
|
|
146
|
+
return response.text().then(_responseText => {
|
|
147
|
+
return throwException('Server Error', status, _responseText, _headers);
|
|
148
|
+
});
|
|
175
149
|
} else if (status !== 200 && status !== 204) {
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
150
|
+
return response.text().then(_responseText => {
|
|
151
|
+
return throwException(
|
|
152
|
+
'An unexpected server error occurred.',
|
|
153
|
+
status,
|
|
154
|
+
_responseText,
|
|
155
|
+
_headers
|
|
156
|
+
);
|
|
157
|
+
});
|
|
183
158
|
}
|
|
184
159
|
return Promise.resolve<BotMessage>(null as any);
|
|
185
160
|
}
|
|
@@ -203,66 +178,58 @@ export class Client {
|
|
|
203
178
|
|
|
204
179
|
const content_ = JSON.stringify(body);
|
|
205
180
|
|
|
206
|
-
let options_:
|
|
207
|
-
|
|
181
|
+
let options_: RequestInit = {
|
|
182
|
+
body: content_,
|
|
208
183
|
method: 'POST',
|
|
209
|
-
|
|
184
|
+
signal,
|
|
210
185
|
headers: {
|
|
211
186
|
'X-Client-ID':
|
|
212
187
|
x_Client_ID !== undefined && x_Client_ID !== null ? '' + x_Client_ID : '',
|
|
213
188
|
'Content-Type': 'application/json',
|
|
214
189
|
'Accept': 'text/plain',
|
|
215
190
|
},
|
|
216
|
-
signal,
|
|
217
191
|
};
|
|
218
192
|
|
|
219
|
-
return this.
|
|
220
|
-
.
|
|
221
|
-
|
|
222
|
-
if (isAxiosError(_error) && _error.response) {
|
|
223
|
-
return _error.response;
|
|
224
|
-
} else {
|
|
225
|
-
throw _error;
|
|
226
|
-
}
|
|
227
|
-
})
|
|
228
|
-
.then((_response: AxiosResponse) => {
|
|
229
|
-
return this.processMessage(_response);
|
|
230
|
-
});
|
|
193
|
+
return this.http.fetch(url_, options_).then((_response: Response) => {
|
|
194
|
+
return this.processMessage(_response);
|
|
195
|
+
});
|
|
231
196
|
}
|
|
232
197
|
|
|
233
|
-
protected processMessage(response:
|
|
198
|
+
protected processMessage(response: Response): Promise<BotMessage> {
|
|
234
199
|
const status = response.status;
|
|
235
200
|
let _headers: any = {};
|
|
236
|
-
if (response.headers &&
|
|
237
|
-
|
|
238
|
-
if (response.headers.hasOwnProperty(k)) {
|
|
239
|
-
_headers[k] = response.headers[k];
|
|
240
|
-
}
|
|
241
|
-
}
|
|
201
|
+
if (response.headers && response.headers.forEach) {
|
|
202
|
+
response.headers.forEach((v: any, k: any) => (_headers[k] = v));
|
|
242
203
|
}
|
|
243
204
|
if (status === 200) {
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
205
|
+
return response.text().then(_responseText => {
|
|
206
|
+
let result200: any = null;
|
|
207
|
+
let resultData200 =
|
|
208
|
+
_responseText === '' ? null : JSON.parse(_responseText, this.jsonParseReviver);
|
|
209
|
+
result200 = BotMessage.fromJS(resultData200);
|
|
210
|
+
return result200;
|
|
211
|
+
});
|
|
249
212
|
} else if (status === 500) {
|
|
250
|
-
|
|
251
|
-
|
|
213
|
+
return response.text().then(_responseText => {
|
|
214
|
+
return throwException('Server Error', status, _responseText, _headers);
|
|
215
|
+
});
|
|
252
216
|
} else if (status === 502) {
|
|
253
|
-
|
|
254
|
-
|
|
217
|
+
return response.text().then(_responseText => {
|
|
218
|
+
return throwException('Server Error', status, _responseText, _headers);
|
|
219
|
+
});
|
|
255
220
|
} else if (status === 504) {
|
|
256
|
-
|
|
257
|
-
|
|
221
|
+
return response.text().then(_responseText => {
|
|
222
|
+
return throwException('Server Error', status, _responseText, _headers);
|
|
223
|
+
});
|
|
258
224
|
} else if (status !== 200 && status !== 204) {
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
225
|
+
return response.text().then(_responseText => {
|
|
226
|
+
return throwException(
|
|
227
|
+
'An unexpected server error occurred.',
|
|
228
|
+
status,
|
|
229
|
+
_responseText,
|
|
230
|
+
_headers
|
|
231
|
+
);
|
|
232
|
+
});
|
|
266
233
|
}
|
|
267
234
|
return Promise.resolve<BotMessage>(null as any);
|
|
268
235
|
}
|
|
@@ -282,55 +249,44 @@ export class Client {
|
|
|
282
249
|
url_ = url_.replace('{version}', encodeURIComponent('' + version));
|
|
283
250
|
url_ = url_.replace(/[?&]$/, '');
|
|
284
251
|
|
|
285
|
-
let options_:
|
|
252
|
+
let options_: RequestInit = {
|
|
286
253
|
method: 'GET',
|
|
287
|
-
|
|
254
|
+
signal,
|
|
288
255
|
headers: {
|
|
289
256
|
'X-Client-ID':
|
|
290
257
|
x_Client_ID !== undefined && x_Client_ID !== null ? '' + x_Client_ID : '',
|
|
291
258
|
'Accept': 'text/plain',
|
|
292
259
|
},
|
|
293
|
-
signal,
|
|
294
260
|
};
|
|
295
261
|
|
|
296
|
-
return this.
|
|
297
|
-
.
|
|
298
|
-
|
|
299
|
-
if (isAxiosError(_error) && _error.response) {
|
|
300
|
-
return _error.response;
|
|
301
|
-
} else {
|
|
302
|
-
throw _error;
|
|
303
|
-
}
|
|
304
|
-
})
|
|
305
|
-
.then((_response: AxiosResponse) => {
|
|
306
|
-
return this.processOptions(_response);
|
|
307
|
-
});
|
|
262
|
+
return this.http.fetch(url_, options_).then((_response: Response) => {
|
|
263
|
+
return this.processOptions(_response);
|
|
264
|
+
});
|
|
308
265
|
}
|
|
309
266
|
|
|
310
|
-
protected processOptions(response:
|
|
267
|
+
protected processOptions(response: Response): Promise<FrontendModel> {
|
|
311
268
|
const status = response.status;
|
|
312
269
|
let _headers: any = {};
|
|
313
|
-
if (response.headers &&
|
|
314
|
-
|
|
315
|
-
if (response.headers.hasOwnProperty(k)) {
|
|
316
|
-
_headers[k] = response.headers[k];
|
|
317
|
-
}
|
|
318
|
-
}
|
|
270
|
+
if (response.headers && response.headers.forEach) {
|
|
271
|
+
response.headers.forEach((v: any, k: any) => (_headers[k] = v));
|
|
319
272
|
}
|
|
320
273
|
if (status === 200) {
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
274
|
+
return response.text().then(_responseText => {
|
|
275
|
+
let result200: any = null;
|
|
276
|
+
let resultData200 =
|
|
277
|
+
_responseText === '' ? null : JSON.parse(_responseText, this.jsonParseReviver);
|
|
278
|
+
result200 = FrontendModel.fromJS(resultData200);
|
|
279
|
+
return result200;
|
|
280
|
+
});
|
|
326
281
|
} else if (status !== 200 && status !== 204) {
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
282
|
+
return response.text().then(_responseText => {
|
|
283
|
+
return throwException(
|
|
284
|
+
'An unexpected server error occurred.',
|
|
285
|
+
status,
|
|
286
|
+
_responseText,
|
|
287
|
+
_headers
|
|
288
|
+
);
|
|
289
|
+
});
|
|
334
290
|
}
|
|
335
291
|
return Promise.resolve<FrontendModel>(null as any);
|
|
336
292
|
}
|
|
@@ -354,57 +310,46 @@ export class Client {
|
|
|
354
310
|
|
|
355
311
|
const content_ = JSON.stringify(body);
|
|
356
312
|
|
|
357
|
-
let options_:
|
|
358
|
-
|
|
313
|
+
let options_: RequestInit = {
|
|
314
|
+
body: content_,
|
|
359
315
|
method: 'POST',
|
|
360
|
-
|
|
316
|
+
signal,
|
|
361
317
|
headers: {
|
|
362
318
|
'X-Client-ID':
|
|
363
319
|
x_Client_ID !== undefined && x_Client_ID !== null ? '' + x_Client_ID : '',
|
|
364
320
|
'Content-Type': 'application/json',
|
|
365
321
|
'Accept': 'text/plain',
|
|
366
322
|
},
|
|
367
|
-
signal,
|
|
368
323
|
};
|
|
369
324
|
|
|
370
|
-
return this.
|
|
371
|
-
.
|
|
372
|
-
|
|
373
|
-
if (isAxiosError(_error) && _error.response) {
|
|
374
|
-
return _error.response;
|
|
375
|
-
} else {
|
|
376
|
-
throw _error;
|
|
377
|
-
}
|
|
378
|
-
})
|
|
379
|
-
.then((_response: AxiosResponse) => {
|
|
380
|
-
return this.processSessionPOST(_response);
|
|
381
|
-
});
|
|
325
|
+
return this.http.fetch(url_, options_).then((_response: Response) => {
|
|
326
|
+
return this.processSessionPOST(_response);
|
|
327
|
+
});
|
|
382
328
|
}
|
|
383
329
|
|
|
384
|
-
protected processSessionPOST(response:
|
|
330
|
+
protected processSessionPOST(response: Response): Promise<Session> {
|
|
385
331
|
const status = response.status;
|
|
386
332
|
let _headers: any = {};
|
|
387
|
-
if (response.headers &&
|
|
388
|
-
|
|
389
|
-
if (response.headers.hasOwnProperty(k)) {
|
|
390
|
-
_headers[k] = response.headers[k];
|
|
391
|
-
}
|
|
392
|
-
}
|
|
333
|
+
if (response.headers && response.headers.forEach) {
|
|
334
|
+
response.headers.forEach((v: any, k: any) => (_headers[k] = v));
|
|
393
335
|
}
|
|
394
336
|
if (status === 200) {
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
337
|
+
return response.text().then(_responseText => {
|
|
338
|
+
let result200: any = null;
|
|
339
|
+
let resultData200 =
|
|
340
|
+
_responseText === '' ? null : JSON.parse(_responseText, this.jsonParseReviver);
|
|
341
|
+
result200 = Session.fromJS(resultData200);
|
|
342
|
+
return result200;
|
|
343
|
+
});
|
|
400
344
|
} else if (status !== 200 && status !== 204) {
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
345
|
+
return response.text().then(_responseText => {
|
|
346
|
+
return throwException(
|
|
347
|
+
'An unexpected server error occurred.',
|
|
348
|
+
status,
|
|
349
|
+
_responseText,
|
|
350
|
+
_headers
|
|
351
|
+
);
|
|
352
|
+
});
|
|
408
353
|
}
|
|
409
354
|
return Promise.resolve<Session>(null as any);
|
|
410
355
|
}
|
|
@@ -428,57 +373,46 @@ export class Client {
|
|
|
428
373
|
|
|
429
374
|
const content_ = JSON.stringify(body);
|
|
430
375
|
|
|
431
|
-
let options_:
|
|
432
|
-
|
|
376
|
+
let options_: RequestInit = {
|
|
377
|
+
body: content_,
|
|
433
378
|
method: 'PATCH',
|
|
434
|
-
|
|
379
|
+
signal,
|
|
435
380
|
headers: {
|
|
436
381
|
'X-Client-ID':
|
|
437
382
|
x_Client_ID !== undefined && x_Client_ID !== null ? '' + x_Client_ID : '',
|
|
438
383
|
'Content-Type': 'application/json',
|
|
439
384
|
'Accept': 'text/plain',
|
|
440
385
|
},
|
|
441
|
-
signal,
|
|
442
386
|
};
|
|
443
387
|
|
|
444
|
-
return this.
|
|
445
|
-
.
|
|
446
|
-
|
|
447
|
-
if (isAxiosError(_error) && _error.response) {
|
|
448
|
-
return _error.response;
|
|
449
|
-
} else {
|
|
450
|
-
throw _error;
|
|
451
|
-
}
|
|
452
|
-
})
|
|
453
|
-
.then((_response: AxiosResponse) => {
|
|
454
|
-
return this.processSessionPATCH(_response);
|
|
455
|
-
});
|
|
388
|
+
return this.http.fetch(url_, options_).then((_response: Response) => {
|
|
389
|
+
return this.processSessionPATCH(_response);
|
|
390
|
+
});
|
|
456
391
|
}
|
|
457
392
|
|
|
458
|
-
protected processSessionPATCH(response:
|
|
393
|
+
protected processSessionPATCH(response: Response): Promise<Session> {
|
|
459
394
|
const status = response.status;
|
|
460
395
|
let _headers: any = {};
|
|
461
|
-
if (response.headers &&
|
|
462
|
-
|
|
463
|
-
if (response.headers.hasOwnProperty(k)) {
|
|
464
|
-
_headers[k] = response.headers[k];
|
|
465
|
-
}
|
|
466
|
-
}
|
|
396
|
+
if (response.headers && response.headers.forEach) {
|
|
397
|
+
response.headers.forEach((v: any, k: any) => (_headers[k] = v));
|
|
467
398
|
}
|
|
468
399
|
if (status === 200) {
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
400
|
+
return response.text().then(_responseText => {
|
|
401
|
+
let result200: any = null;
|
|
402
|
+
let resultData200 =
|
|
403
|
+
_responseText === '' ? null : JSON.parse(_responseText, this.jsonParseReviver);
|
|
404
|
+
result200 = Session.fromJS(resultData200);
|
|
405
|
+
return result200;
|
|
406
|
+
});
|
|
474
407
|
} else if (status !== 200 && status !== 204) {
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
408
|
+
return response.text().then(_responseText => {
|
|
409
|
+
return throwException(
|
|
410
|
+
'An unexpected server error occurred.',
|
|
411
|
+
status,
|
|
412
|
+
_responseText,
|
|
413
|
+
_headers
|
|
414
|
+
);
|
|
415
|
+
});
|
|
482
416
|
}
|
|
483
417
|
return Promise.resolve<Session>(null as any);
|
|
484
418
|
}
|
|
@@ -502,263 +436,470 @@ export class Client {
|
|
|
502
436
|
|
|
503
437
|
const content_ = JSON.stringify(body);
|
|
504
438
|
|
|
505
|
-
let options_:
|
|
506
|
-
|
|
439
|
+
let options_: RequestInit = {
|
|
440
|
+
body: content_,
|
|
507
441
|
method: 'DELETE',
|
|
508
|
-
|
|
442
|
+
signal,
|
|
509
443
|
headers: {
|
|
510
444
|
'X-Client-ID':
|
|
511
445
|
x_Client_ID !== undefined && x_Client_ID !== null ? '' + x_Client_ID : '',
|
|
512
446
|
'Content-Type': 'application/json',
|
|
513
447
|
'Accept': 'text/plain',
|
|
514
448
|
},
|
|
515
|
-
signal,
|
|
516
449
|
};
|
|
517
450
|
|
|
518
|
-
return this.
|
|
519
|
-
.
|
|
520
|
-
|
|
521
|
-
if (isAxiosError(_error) && _error.response) {
|
|
522
|
-
return _error.response;
|
|
523
|
-
} else {
|
|
524
|
-
throw _error;
|
|
525
|
-
}
|
|
526
|
-
})
|
|
527
|
-
.then((_response: AxiosResponse) => {
|
|
528
|
-
return this.processSessionDELETE(_response);
|
|
529
|
-
});
|
|
451
|
+
return this.http.fetch(url_, options_).then((_response: Response) => {
|
|
452
|
+
return this.processSessionDELETE(_response);
|
|
453
|
+
});
|
|
530
454
|
}
|
|
531
455
|
|
|
532
|
-
protected processSessionDELETE(response:
|
|
456
|
+
protected processSessionDELETE(response: Response): Promise<Session> {
|
|
533
457
|
const status = response.status;
|
|
534
458
|
let _headers: any = {};
|
|
535
|
-
if (response.headers &&
|
|
536
|
-
|
|
537
|
-
if (response.headers.hasOwnProperty(k)) {
|
|
538
|
-
_headers[k] = response.headers[k];
|
|
539
|
-
}
|
|
540
|
-
}
|
|
459
|
+
if (response.headers && response.headers.forEach) {
|
|
460
|
+
response.headers.forEach((v: any, k: any) => (_headers[k] = v));
|
|
541
461
|
}
|
|
542
462
|
if (status === 200) {
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
463
|
+
return response.text().then(_responseText => {
|
|
464
|
+
let result200: any = null;
|
|
465
|
+
let resultData200 =
|
|
466
|
+
_responseText === '' ? null : JSON.parse(_responseText, this.jsonParseReviver);
|
|
467
|
+
result200 = Session.fromJS(resultData200);
|
|
468
|
+
return result200;
|
|
469
|
+
});
|
|
548
470
|
} else if (status !== 200 && status !== 204) {
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
471
|
+
return response.text().then(_responseText => {
|
|
472
|
+
return throwException(
|
|
473
|
+
'An unexpected server error occurred.',
|
|
474
|
+
status,
|
|
475
|
+
_responseText,
|
|
476
|
+
_headers
|
|
477
|
+
);
|
|
478
|
+
});
|
|
556
479
|
}
|
|
557
480
|
return Promise.resolve<Session>(null as any);
|
|
558
481
|
}
|
|
559
482
|
|
|
560
483
|
/**
|
|
561
|
-
* @param start (optional)
|
|
562
|
-
* @param end (optional)
|
|
563
484
|
* @param x_Client_ID (optional)
|
|
564
485
|
* @return Success
|
|
565
486
|
*/
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
end: Date | undefined,
|
|
487
|
+
sessionGET(
|
|
488
|
+
sessionId: number,
|
|
569
489
|
version: string,
|
|
570
490
|
x_Client_ID: any | undefined,
|
|
571
491
|
signal?: AbortSignal
|
|
572
|
-
): Promise<
|
|
573
|
-
let url_ = this.baseUrl + '/api/v{version}/
|
|
492
|
+
): Promise<Session> {
|
|
493
|
+
let url_ = this.baseUrl + '/api/v{version}/session/{sessionId}';
|
|
494
|
+
if (sessionId === undefined || sessionId === null)
|
|
495
|
+
throw new Error("The parameter 'sessionId' must be defined.");
|
|
496
|
+
url_ = url_.replace('{sessionId}', encodeURIComponent('' + sessionId));
|
|
574
497
|
if (version === undefined || version === null)
|
|
575
498
|
throw new Error("The parameter 'version' must be defined.");
|
|
576
499
|
url_ = url_.replace('{version}', encodeURIComponent('' + version));
|
|
577
|
-
if (start === null) throw new Error("The parameter 'start' cannot be null.");
|
|
578
|
-
else if (start !== undefined)
|
|
579
|
-
url_ += 'start=' + encodeURIComponent(start ? '' + start.toISOString() : '') + '&';
|
|
580
|
-
if (end === null) throw new Error("The parameter 'end' cannot be null.");
|
|
581
|
-
else if (end !== undefined)
|
|
582
|
-
url_ += 'end=' + encodeURIComponent(end ? '' + end.toISOString() : '') + '&';
|
|
583
500
|
url_ = url_.replace(/[?&]$/, '');
|
|
584
501
|
|
|
585
|
-
let options_:
|
|
502
|
+
let options_: RequestInit = {
|
|
586
503
|
method: 'GET',
|
|
587
|
-
|
|
504
|
+
signal,
|
|
588
505
|
headers: {
|
|
589
506
|
'X-Client-ID':
|
|
590
507
|
x_Client_ID !== undefined && x_Client_ID !== null ? '' + x_Client_ID : '',
|
|
591
508
|
'Accept': 'text/plain',
|
|
592
509
|
},
|
|
510
|
+
};
|
|
511
|
+
|
|
512
|
+
return this.http.fetch(url_, options_).then((_response: Response) => {
|
|
513
|
+
return this.processSessionGET(_response);
|
|
514
|
+
});
|
|
515
|
+
}
|
|
516
|
+
|
|
517
|
+
protected processSessionGET(response: Response): Promise<Session> {
|
|
518
|
+
const status = response.status;
|
|
519
|
+
let _headers: any = {};
|
|
520
|
+
if (response.headers && response.headers.forEach) {
|
|
521
|
+
response.headers.forEach((v: any, k: any) => (_headers[k] = v));
|
|
522
|
+
}
|
|
523
|
+
if (status === 200) {
|
|
524
|
+
return response.text().then(_responseText => {
|
|
525
|
+
let result200: any = null;
|
|
526
|
+
let resultData200 =
|
|
527
|
+
_responseText === '' ? null : JSON.parse(_responseText, this.jsonParseReviver);
|
|
528
|
+
result200 = Session.fromJS(resultData200);
|
|
529
|
+
return result200;
|
|
530
|
+
});
|
|
531
|
+
} else if (status !== 200 && status !== 204) {
|
|
532
|
+
return response.text().then(_responseText => {
|
|
533
|
+
return throwException(
|
|
534
|
+
'An unexpected server error occurred.',
|
|
535
|
+
status,
|
|
536
|
+
_responseText,
|
|
537
|
+
_headers
|
|
538
|
+
);
|
|
539
|
+
});
|
|
540
|
+
}
|
|
541
|
+
return Promise.resolve<Session>(null as any);
|
|
542
|
+
}
|
|
543
|
+
|
|
544
|
+
/**
|
|
545
|
+
* @param x_Client_ID (optional)
|
|
546
|
+
* @return Success
|
|
547
|
+
*/
|
|
548
|
+
messages(
|
|
549
|
+
sessionId: number,
|
|
550
|
+
version: string,
|
|
551
|
+
x_Client_ID: any | undefined,
|
|
552
|
+
signal?: AbortSignal
|
|
553
|
+
): Promise<Message[]> {
|
|
554
|
+
let url_ = this.baseUrl + '/api/v{version}/session/{sessionId}/messages';
|
|
555
|
+
if (sessionId === undefined || sessionId === null)
|
|
556
|
+
throw new Error("The parameter 'sessionId' must be defined.");
|
|
557
|
+
url_ = url_.replace('{sessionId}', encodeURIComponent('' + sessionId));
|
|
558
|
+
if (version === undefined || version === null)
|
|
559
|
+
throw new Error("The parameter 'version' must be defined.");
|
|
560
|
+
url_ = url_.replace('{version}', encodeURIComponent('' + version));
|
|
561
|
+
url_ = url_.replace(/[?&]$/, '');
|
|
562
|
+
|
|
563
|
+
let options_: RequestInit = {
|
|
564
|
+
method: 'GET',
|
|
593
565
|
signal,
|
|
566
|
+
headers: {
|
|
567
|
+
'X-Client-ID':
|
|
568
|
+
x_Client_ID !== undefined && x_Client_ID !== null ? '' + x_Client_ID : '',
|
|
569
|
+
'Accept': 'text/plain',
|
|
570
|
+
},
|
|
594
571
|
};
|
|
595
572
|
|
|
596
|
-
return this.
|
|
597
|
-
.
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
573
|
+
return this.http.fetch(url_, options_).then((_response: Response) => {
|
|
574
|
+
return this.processMessages(_response);
|
|
575
|
+
});
|
|
576
|
+
}
|
|
577
|
+
|
|
578
|
+
protected processMessages(response: Response): Promise<Message[]> {
|
|
579
|
+
const status = response.status;
|
|
580
|
+
let _headers: any = {};
|
|
581
|
+
if (response.headers && response.headers.forEach) {
|
|
582
|
+
response.headers.forEach((v: any, k: any) => (_headers[k] = v));
|
|
583
|
+
}
|
|
584
|
+
if (status === 200) {
|
|
585
|
+
return response.text().then(_responseText => {
|
|
586
|
+
let result200: any = null;
|
|
587
|
+
let resultData200 =
|
|
588
|
+
_responseText === '' ? null : JSON.parse(_responseText, this.jsonParseReviver);
|
|
589
|
+
if (Array.isArray(resultData200)) {
|
|
590
|
+
result200 = [] as any;
|
|
591
|
+
for (let item of resultData200) result200!.push(Message.fromJS(item));
|
|
601
592
|
} else {
|
|
602
|
-
|
|
593
|
+
result200 = <any>null;
|
|
603
594
|
}
|
|
604
|
-
|
|
605
|
-
.then((_response: AxiosResponse) => {
|
|
606
|
-
return this.processTranscripts(_response);
|
|
595
|
+
return result200;
|
|
607
596
|
});
|
|
597
|
+
} else if (status !== 200 && status !== 204) {
|
|
598
|
+
return response.text().then(_responseText => {
|
|
599
|
+
return throwException(
|
|
600
|
+
'An unexpected server error occurred.',
|
|
601
|
+
status,
|
|
602
|
+
_responseText,
|
|
603
|
+
_headers
|
|
604
|
+
);
|
|
605
|
+
});
|
|
606
|
+
}
|
|
607
|
+
return Promise.resolve<Message[]>(null as any);
|
|
608
|
+
}
|
|
609
|
+
|
|
610
|
+
/**
|
|
611
|
+
* @param x_Client_ID (optional)
|
|
612
|
+
* @param body (optional)
|
|
613
|
+
* @return Success
|
|
614
|
+
*/
|
|
615
|
+
summarize(
|
|
616
|
+
version: string,
|
|
617
|
+
x_Client_ID: any | undefined,
|
|
618
|
+
body: SummarizeRequest | undefined,
|
|
619
|
+
signal?: AbortSignal
|
|
620
|
+
): Promise<SummarizeResponse> {
|
|
621
|
+
let url_ = this.baseUrl + '/api/v{version}/summarize';
|
|
622
|
+
if (version === undefined || version === null)
|
|
623
|
+
throw new Error("The parameter 'version' must be defined.");
|
|
624
|
+
url_ = url_.replace('{version}', encodeURIComponent('' + version));
|
|
625
|
+
url_ = url_.replace(/[?&]$/, '');
|
|
626
|
+
|
|
627
|
+
const content_ = JSON.stringify(body);
|
|
628
|
+
|
|
629
|
+
let options_: RequestInit = {
|
|
630
|
+
body: content_,
|
|
631
|
+
method: 'POST',
|
|
632
|
+
signal,
|
|
633
|
+
headers: {
|
|
634
|
+
'X-Client-ID':
|
|
635
|
+
x_Client_ID !== undefined && x_Client_ID !== null ? '' + x_Client_ID : '',
|
|
636
|
+
'Content-Type': 'application/json',
|
|
637
|
+
'Accept': 'text/plain',
|
|
638
|
+
},
|
|
639
|
+
};
|
|
640
|
+
|
|
641
|
+
return this.http.fetch(url_, options_).then((_response: Response) => {
|
|
642
|
+
return this.processSummarize(_response);
|
|
643
|
+
});
|
|
608
644
|
}
|
|
609
645
|
|
|
610
|
-
protected
|
|
646
|
+
protected processSummarize(response: Response): Promise<SummarizeResponse> {
|
|
611
647
|
const status = response.status;
|
|
612
648
|
let _headers: any = {};
|
|
613
|
-
if (response.headers &&
|
|
614
|
-
|
|
615
|
-
if (response.headers.hasOwnProperty(k)) {
|
|
616
|
-
_headers[k] = response.headers[k];
|
|
617
|
-
}
|
|
618
|
-
}
|
|
649
|
+
if (response.headers && response.headers.forEach) {
|
|
650
|
+
response.headers.forEach((v: any, k: any) => (_headers[k] = v));
|
|
619
651
|
}
|
|
620
652
|
if (status === 200) {
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
result200 =
|
|
626
|
-
|
|
627
|
-
}
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
653
|
+
return response.text().then(_responseText => {
|
|
654
|
+
let result200: any = null;
|
|
655
|
+
let resultData200 =
|
|
656
|
+
_responseText === '' ? null : JSON.parse(_responseText, this.jsonParseReviver);
|
|
657
|
+
result200 = SummarizeResponse.fromJS(resultData200);
|
|
658
|
+
return result200;
|
|
659
|
+
});
|
|
660
|
+
} else if (status === 500) {
|
|
661
|
+
return response.text().then(_responseText => {
|
|
662
|
+
return throwException('Server Error', status, _responseText, _headers);
|
|
663
|
+
});
|
|
664
|
+
} else if (status === 502) {
|
|
665
|
+
return response.text().then(_responseText => {
|
|
666
|
+
return throwException('Server Error', status, _responseText, _headers);
|
|
667
|
+
});
|
|
668
|
+
} else if (status === 504) {
|
|
669
|
+
return response.text().then(_responseText => {
|
|
670
|
+
return throwException('Server Error', status, _responseText, _headers);
|
|
671
|
+
});
|
|
631
672
|
} else if (status !== 200 && status !== 204) {
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
673
|
+
return response.text().then(_responseText => {
|
|
674
|
+
return throwException(
|
|
675
|
+
'An unexpected server error occurred.',
|
|
676
|
+
status,
|
|
677
|
+
_responseText,
|
|
678
|
+
_headers
|
|
679
|
+
);
|
|
680
|
+
});
|
|
639
681
|
}
|
|
640
|
-
return Promise.resolve<
|
|
682
|
+
return Promise.resolve<SummarizeResponse>(null as any);
|
|
641
683
|
}
|
|
642
684
|
|
|
643
685
|
/**
|
|
644
|
-
* @param
|
|
686
|
+
* @param start (optional)
|
|
687
|
+
* @param end (optional)
|
|
645
688
|
* @param x_Client_ID (optional)
|
|
646
689
|
* @return Success
|
|
647
690
|
*/
|
|
648
|
-
|
|
649
|
-
|
|
691
|
+
transcripts(
|
|
692
|
+
start: Date | undefined,
|
|
693
|
+
end: Date | undefined,
|
|
650
694
|
version: string,
|
|
651
695
|
x_Client_ID: any | undefined,
|
|
652
696
|
signal?: AbortSignal
|
|
653
|
-
): Promise<
|
|
654
|
-
let url_ = this.baseUrl + '/api/v{version}/transcripts
|
|
697
|
+
): Promise<ExportHistoryMessage[]> {
|
|
698
|
+
let url_ = this.baseUrl + '/api/v{version}/transcripts?';
|
|
655
699
|
if (version === undefined || version === null)
|
|
656
700
|
throw new Error("The parameter 'version' must be defined.");
|
|
657
701
|
url_ = url_.replace('{version}', encodeURIComponent('' + version));
|
|
658
|
-
if (
|
|
659
|
-
else if (
|
|
660
|
-
url_ += '
|
|
702
|
+
if (start === null) throw new Error("The parameter 'start' cannot be null.");
|
|
703
|
+
else if (start !== undefined)
|
|
704
|
+
url_ += 'start=' + encodeURIComponent(start ? '' + start.toISOString() : '') + '&';
|
|
705
|
+
if (end === null) throw new Error("The parameter 'end' cannot be null.");
|
|
706
|
+
else if (end !== undefined)
|
|
707
|
+
url_ += 'end=' + encodeURIComponent(end ? '' + end.toISOString() : '') + '&';
|
|
661
708
|
url_ = url_.replace(/[?&]$/, '');
|
|
662
709
|
|
|
663
|
-
let options_:
|
|
710
|
+
let options_: RequestInit = {
|
|
664
711
|
method: 'GET',
|
|
665
|
-
|
|
712
|
+
signal,
|
|
666
713
|
headers: {
|
|
667
714
|
'X-Client-ID':
|
|
668
715
|
x_Client_ID !== undefined && x_Client_ID !== null ? '' + x_Client_ID : '',
|
|
669
716
|
'Accept': 'text/plain',
|
|
670
717
|
},
|
|
671
|
-
signal,
|
|
672
718
|
};
|
|
673
719
|
|
|
674
|
-
return this.
|
|
675
|
-
.
|
|
676
|
-
|
|
677
|
-
if (isAxiosError(_error) && _error.response) {
|
|
678
|
-
return _error.response;
|
|
679
|
-
} else {
|
|
680
|
-
throw _error;
|
|
681
|
-
}
|
|
682
|
-
})
|
|
683
|
-
.then((_response: AxiosResponse) => {
|
|
684
|
-
return this.processSummary(_response);
|
|
685
|
-
});
|
|
720
|
+
return this.http.fetch(url_, options_).then((_response: Response) => {
|
|
721
|
+
return this.processTranscripts(_response);
|
|
722
|
+
});
|
|
686
723
|
}
|
|
687
724
|
|
|
688
|
-
protected
|
|
725
|
+
protected processTranscripts(response: Response): Promise<ExportHistoryMessage[]> {
|
|
689
726
|
const status = response.status;
|
|
690
727
|
let _headers: any = {};
|
|
691
|
-
if (response.headers &&
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
728
|
+
if (response.headers && response.headers.forEach) {
|
|
729
|
+
response.headers.forEach((v: any, k: any) => (_headers[k] = v));
|
|
730
|
+
}
|
|
731
|
+
if (status === 200) {
|
|
732
|
+
return response.text().then(_responseText => {
|
|
733
|
+
let result200: any = null;
|
|
734
|
+
let resultData200 =
|
|
735
|
+
_responseText === '' ? null : JSON.parse(_responseText, this.jsonParseReviver);
|
|
736
|
+
if (Array.isArray(resultData200)) {
|
|
737
|
+
result200 = [] as any;
|
|
738
|
+
for (let item of resultData200)
|
|
739
|
+
result200!.push(ExportHistoryMessage.fromJS(item));
|
|
740
|
+
} else {
|
|
741
|
+
result200 = <any>null;
|
|
695
742
|
}
|
|
743
|
+
return result200;
|
|
744
|
+
});
|
|
745
|
+
} else if (status !== 200 && status !== 204) {
|
|
746
|
+
return response.text().then(_responseText => {
|
|
747
|
+
return throwException(
|
|
748
|
+
'An unexpected server error occurred.',
|
|
749
|
+
status,
|
|
750
|
+
_responseText,
|
|
751
|
+
_headers
|
|
752
|
+
);
|
|
753
|
+
});
|
|
754
|
+
}
|
|
755
|
+
return Promise.resolve<ExportHistoryMessage[]>(null as any);
|
|
756
|
+
}
|
|
757
|
+
}
|
|
758
|
+
|
|
759
|
+
/** One selectable agentic action choice. */
|
|
760
|
+
export class AgentOption implements IAgentOption {
|
|
761
|
+
agentId?: string | undefined;
|
|
762
|
+
passPhrase?: string | undefined;
|
|
763
|
+
caption?: string | undefined;
|
|
764
|
+
|
|
765
|
+
constructor(data?: IAgentOption) {
|
|
766
|
+
if (data) {
|
|
767
|
+
for (var property in data) {
|
|
768
|
+
if (data.hasOwnProperty(property)) (<any>this)[property] = (<any>data)[property];
|
|
696
769
|
}
|
|
697
770
|
}
|
|
698
|
-
|
|
699
|
-
const _responseText = response.data;
|
|
700
|
-
let result200: any = null;
|
|
701
|
-
let resultData200 = _responseText;
|
|
702
|
-
result200 = resultData200 !== undefined ? resultData200 : <any>null;
|
|
771
|
+
}
|
|
703
772
|
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
status,
|
|
710
|
-
_responseText,
|
|
711
|
-
_headers
|
|
712
|
-
);
|
|
773
|
+
init(_data?: any) {
|
|
774
|
+
if (_data) {
|
|
775
|
+
this.agentId = _data['agentId'];
|
|
776
|
+
this.passPhrase = _data['passPhrase'];
|
|
777
|
+
this.caption = _data['caption'];
|
|
713
778
|
}
|
|
714
|
-
|
|
779
|
+
}
|
|
780
|
+
|
|
781
|
+
static fromJS(data: any): AgentOption {
|
|
782
|
+
data = typeof data === 'object' ? data : {};
|
|
783
|
+
let result = new AgentOption();
|
|
784
|
+
result.init(data);
|
|
785
|
+
return result;
|
|
786
|
+
}
|
|
787
|
+
|
|
788
|
+
toJSON(data?: any) {
|
|
789
|
+
data = typeof data === 'object' ? data : {};
|
|
790
|
+
data['agentId'] = this.agentId;
|
|
791
|
+
data['passPhrase'] = this.passPhrase;
|
|
792
|
+
data['caption'] = this.caption;
|
|
793
|
+
return data;
|
|
715
794
|
}
|
|
716
795
|
}
|
|
717
796
|
|
|
718
|
-
/**
|
|
719
|
-
export
|
|
797
|
+
/** One selectable agentic action choice. */
|
|
798
|
+
export interface IAgentOption {
|
|
799
|
+
agentId?: string | undefined;
|
|
800
|
+
passPhrase?: string | undefined;
|
|
801
|
+
caption?: string | undefined;
|
|
802
|
+
}
|
|
803
|
+
|
|
804
|
+
export class Message implements IMessage {
|
|
805
|
+
/** Primary key. */
|
|
806
|
+
id?: number;
|
|
807
|
+
/** Session ID. Required in multi-turn conversations after the session is created. */
|
|
808
|
+
sessionId?: number | undefined;
|
|
809
|
+
timeStamp?: Date;
|
|
810
|
+
|
|
811
|
+
protected _discriminator: string;
|
|
812
|
+
|
|
813
|
+
constructor(data?: IMessage) {
|
|
814
|
+
if (data) {
|
|
815
|
+
for (var property in data) {
|
|
816
|
+
if (data.hasOwnProperty(property)) (<any>this)[property] = (<any>data)[property];
|
|
817
|
+
}
|
|
818
|
+
}
|
|
819
|
+
this._discriminator = 'Message';
|
|
820
|
+
}
|
|
821
|
+
|
|
822
|
+
init(_data?: any) {
|
|
823
|
+
if (_data) {
|
|
824
|
+
this.id = _data['id'];
|
|
825
|
+
this.sessionId = _data['sessionId'];
|
|
826
|
+
this.timeStamp = _data['timeStamp']
|
|
827
|
+
? new Date(_data['timeStamp'].toString())
|
|
828
|
+
: <any>undefined;
|
|
829
|
+
}
|
|
830
|
+
}
|
|
831
|
+
|
|
832
|
+
static fromJS(data: any): Message {
|
|
833
|
+
data = typeof data === 'object' ? data : {};
|
|
834
|
+
if (data['$type'] === 'UserMessage') {
|
|
835
|
+
let result = new UserMessage();
|
|
836
|
+
result.init(data);
|
|
837
|
+
return result;
|
|
838
|
+
}
|
|
839
|
+
if (data['$type'] === 'BotMessage') {
|
|
840
|
+
let result = new BotMessage();
|
|
841
|
+
result.init(data);
|
|
842
|
+
return result;
|
|
843
|
+
}
|
|
844
|
+
let result = new Message();
|
|
845
|
+
result.init(data);
|
|
846
|
+
return result;
|
|
847
|
+
}
|
|
848
|
+
|
|
849
|
+
toJSON(data?: any) {
|
|
850
|
+
data = typeof data === 'object' ? data : {};
|
|
851
|
+
data['$type'] = this._discriminator;
|
|
852
|
+
data['id'] = this.id;
|
|
853
|
+
data['sessionId'] = this.sessionId;
|
|
854
|
+
data['timeStamp'] = this.timeStamp ? this.timeStamp.toISOString() : <any>undefined;
|
|
855
|
+
return data;
|
|
856
|
+
}
|
|
857
|
+
}
|
|
858
|
+
|
|
859
|
+
export interface IMessage {
|
|
720
860
|
/** Primary key. */
|
|
721
861
|
id?: number;
|
|
722
862
|
/** Session ID. Required in multi-turn conversations after the session is created. */
|
|
723
863
|
sessionId?: number | undefined;
|
|
724
864
|
timeStamp?: Date;
|
|
865
|
+
}
|
|
866
|
+
|
|
867
|
+
/** Chatbot response message. */
|
|
868
|
+
export class BotMessage extends Message implements IBotMessage {
|
|
725
869
|
/** Chatbot answer. */
|
|
726
|
-
answer
|
|
870
|
+
declare answer: string;
|
|
727
871
|
/** Ordered list of relevant Knowledge Base links. */
|
|
728
|
-
scoredUrls?: ScoredUrl[] | undefined;
|
|
872
|
+
declare scoredUrls?: ScoredUrl[] | undefined;
|
|
729
873
|
/** A value indicating one of the conditions:
|
|
730
874
|
- N - "none" or "normal", a successful response
|
|
731
875
|
- A - "agent", user wants to talk to a support agent
|
|
732
876
|
- C - "conversation", user attempted to continue a conversation in a single-turn message
|
|
733
877
|
- OI - "offensive input"
|
|
878
|
+
- AA - "agentic approval", the bot is waiting for the user to approve or cancel a pending action
|
|
879
|
+
- BI - "bifurcation", the bot is offering the user a choice (see TitanChatbot.Host.API.Models.BotMessage.AgentOptions)
|
|
734
880
|
Client may handle these conditions in different ways. */
|
|
735
|
-
guardFlag
|
|
881
|
+
declare guardFlag: string;
|
|
736
882
|
/** Whether the answer is guardrailed, meaning TitanChatbot.Host.API.Models.BotMessage.GuardFlag is anything but "N". */
|
|
737
|
-
isGuardrailed
|
|
883
|
+
declare isGuardrailed: boolean;
|
|
738
884
|
/** Chatbot version number. */
|
|
739
|
-
botVersion?: string | undefined;
|
|
885
|
+
declare botVersion?: string | undefined;
|
|
740
886
|
/** AI model version. */
|
|
741
|
-
modelVersion?: string | undefined;
|
|
887
|
+
declare modelVersion?: string | undefined;
|
|
742
888
|
/** Various metadata for diagnostics purposes. */
|
|
743
|
-
meta?: any | undefined;
|
|
889
|
+
declare meta?: any | undefined;
|
|
744
890
|
/** How confident is the chatbot in its response. */
|
|
745
|
-
confidenceScore?: number | undefined;
|
|
891
|
+
declare confidenceScore?: number | undefined;
|
|
892
|
+
/** When the bot offers the user a discrete choice (e.g. "do it for me" vs "show me how"), the available options. */
|
|
893
|
+
declare agentOptions?: AgentOption[] | undefined;
|
|
746
894
|
|
|
747
895
|
constructor(data?: IBotMessage) {
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
if (data.hasOwnProperty(property)) (<any>this)[property] = (<any>data)[property];
|
|
751
|
-
}
|
|
752
|
-
}
|
|
896
|
+
super(data);
|
|
897
|
+
this._discriminator = 'BotMessage';
|
|
753
898
|
}
|
|
754
899
|
|
|
755
900
|
init(_data?: any) {
|
|
901
|
+
super.init(_data);
|
|
756
902
|
if (_data) {
|
|
757
|
-
this.id = _data['id'];
|
|
758
|
-
this.sessionId = _data['sessionId'];
|
|
759
|
-
this.timeStamp = _data['timeStamp']
|
|
760
|
-
? new Date(_data['timeStamp'].toString())
|
|
761
|
-
: <any>undefined;
|
|
762
903
|
this.answer = _data['answer'];
|
|
763
904
|
if (Array.isArray(_data['scoredUrls'])) {
|
|
764
905
|
this.scoredUrls = [] as any;
|
|
@@ -770,6 +911,11 @@ export class BotMessage implements IBotMessage {
|
|
|
770
911
|
this.modelVersion = _data['modelVersion'];
|
|
771
912
|
this.meta = _data['meta'];
|
|
772
913
|
this.confidenceScore = _data['confidenceScore'];
|
|
914
|
+
if (Array.isArray(_data['agentOptions'])) {
|
|
915
|
+
this.agentOptions = [] as any;
|
|
916
|
+
for (let item of _data['agentOptions'])
|
|
917
|
+
this.agentOptions!.push(AgentOption.fromJS(item));
|
|
918
|
+
}
|
|
773
919
|
}
|
|
774
920
|
}
|
|
775
921
|
|
|
@@ -782,9 +928,6 @@ export class BotMessage implements IBotMessage {
|
|
|
782
928
|
|
|
783
929
|
toJSON(data?: any) {
|
|
784
930
|
data = typeof data === 'object' ? data : {};
|
|
785
|
-
data['id'] = this.id;
|
|
786
|
-
data['sessionId'] = this.sessionId;
|
|
787
|
-
data['timeStamp'] = this.timeStamp ? this.timeStamp.toISOString() : <any>undefined;
|
|
788
931
|
data['answer'] = this.answer;
|
|
789
932
|
if (Array.isArray(this.scoredUrls)) {
|
|
790
933
|
data['scoredUrls'] = [];
|
|
@@ -796,17 +939,17 @@ export class BotMessage implements IBotMessage {
|
|
|
796
939
|
data['modelVersion'] = this.modelVersion;
|
|
797
940
|
data['meta'] = this.meta;
|
|
798
941
|
data['confidenceScore'] = this.confidenceScore;
|
|
942
|
+
if (Array.isArray(this.agentOptions)) {
|
|
943
|
+
data['agentOptions'] = [];
|
|
944
|
+
for (let item of this.agentOptions) data['agentOptions'].push(item.toJSON());
|
|
945
|
+
}
|
|
946
|
+
super.toJSON(data);
|
|
799
947
|
return data;
|
|
800
948
|
}
|
|
801
949
|
}
|
|
802
950
|
|
|
803
951
|
/** Chatbot response message. */
|
|
804
|
-
export interface IBotMessage {
|
|
805
|
-
/** Primary key. */
|
|
806
|
-
id?: number;
|
|
807
|
-
/** Session ID. Required in multi-turn conversations after the session is created. */
|
|
808
|
-
sessionId?: number | undefined;
|
|
809
|
-
timeStamp?: Date;
|
|
952
|
+
export interface IBotMessage extends IMessage {
|
|
810
953
|
/** Chatbot answer. */
|
|
811
954
|
answer: string;
|
|
812
955
|
/** Ordered list of relevant Knowledge Base links. */
|
|
@@ -816,6 +959,8 @@ export interface IBotMessage {
|
|
|
816
959
|
- A - "agent", user wants to talk to a support agent
|
|
817
960
|
- C - "conversation", user attempted to continue a conversation in a single-turn message
|
|
818
961
|
- OI - "offensive input"
|
|
962
|
+
- AA - "agentic approval", the bot is waiting for the user to approve or cancel a pending action
|
|
963
|
+
- BI - "bifurcation", the bot is offering the user a choice (see TitanChatbot.Host.API.Models.BotMessage.AgentOptions)
|
|
819
964
|
Client may handle these conditions in different ways. */
|
|
820
965
|
guardFlag: string;
|
|
821
966
|
/** Whether the answer is guardrailed, meaning TitanChatbot.Host.API.Models.BotMessage.GuardFlag is anything but "N". */
|
|
@@ -828,6 +973,8 @@ export interface IBotMessage {
|
|
|
828
973
|
meta?: any | undefined;
|
|
829
974
|
/** How confident is the chatbot in its response. */
|
|
830
975
|
confidenceScore?: number | undefined;
|
|
976
|
+
/** When the bot offers the user a discrete choice (e.g. "do it for me" vs "show me how"), the available options. */
|
|
977
|
+
agentOptions?: AgentOption[] | undefined;
|
|
831
978
|
}
|
|
832
979
|
|
|
833
980
|
export enum Experience {
|
|
@@ -841,6 +988,7 @@ export class ExportHistoryMessage implements IExportHistoryMessage {
|
|
|
841
988
|
/** Session ID. Required in multi-turn conversations after the session is created. */
|
|
842
989
|
sessionId?: number | undefined;
|
|
843
990
|
timeStamp?: Date;
|
|
991
|
+
clientId?: string | undefined;
|
|
844
992
|
userId?: number;
|
|
845
993
|
sessionStartTime?: Date;
|
|
846
994
|
sessionEndTime?: Date | undefined;
|
|
@@ -872,6 +1020,7 @@ export class ExportHistoryMessage implements IExportHistoryMessage {
|
|
|
872
1020
|
this.timeStamp = _data['timeStamp']
|
|
873
1021
|
? new Date(_data['timeStamp'].toString())
|
|
874
1022
|
: <any>undefined;
|
|
1023
|
+
this.clientId = _data['clientId'];
|
|
875
1024
|
this.userId = _data['userId'];
|
|
876
1025
|
this.sessionStartTime = _data['sessionStartTime']
|
|
877
1026
|
? new Date(_data['sessionStartTime'].toString())
|
|
@@ -908,6 +1057,7 @@ export class ExportHistoryMessage implements IExportHistoryMessage {
|
|
|
908
1057
|
data['id'] = this.id;
|
|
909
1058
|
data['sessionId'] = this.sessionId;
|
|
910
1059
|
data['timeStamp'] = this.timeStamp ? this.timeStamp.toISOString() : <any>undefined;
|
|
1060
|
+
data['clientId'] = this.clientId;
|
|
911
1061
|
data['userId'] = this.userId;
|
|
912
1062
|
data['sessionStartTime'] = this.sessionStartTime
|
|
913
1063
|
? this.sessionStartTime.toISOString()
|
|
@@ -939,6 +1089,7 @@ export interface IExportHistoryMessage {
|
|
|
939
1089
|
/** Session ID. Required in multi-turn conversations after the session is created. */
|
|
940
1090
|
sessionId?: number | undefined;
|
|
941
1091
|
timeStamp?: Date;
|
|
1092
|
+
clientId?: string | undefined;
|
|
942
1093
|
userId?: number;
|
|
943
1094
|
sessionStartTime?: Date;
|
|
944
1095
|
sessionEndTime?: Date | undefined;
|
|
@@ -963,7 +1114,7 @@ export class Feedback implements IFeedback {
|
|
|
963
1114
|
/** User typed input. */
|
|
964
1115
|
description?: string | undefined;
|
|
965
1116
|
/** Session ID for session feedback. */
|
|
966
|
-
sessionId
|
|
1117
|
+
sessionId!: number;
|
|
967
1118
|
/** Message ID for message feedback. */
|
|
968
1119
|
messageId?: number | undefined;
|
|
969
1120
|
/** Selected options. */
|
|
@@ -1021,7 +1172,7 @@ export interface IFeedback {
|
|
|
1021
1172
|
/** User typed input. */
|
|
1022
1173
|
description?: string | undefined;
|
|
1023
1174
|
/** Session ID for session feedback. */
|
|
1024
|
-
sessionId
|
|
1175
|
+
sessionId: number;
|
|
1025
1176
|
/** Message ID for message feedback. */
|
|
1026
1177
|
messageId?: number | undefined;
|
|
1027
1178
|
/** Selected options. */
|
|
@@ -1316,21 +1467,10 @@ export interface ISession {
|
|
|
1316
1467
|
data?: { [key: string]: string } | undefined;
|
|
1317
1468
|
}
|
|
1318
1469
|
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
/** Primary key. */
|
|
1322
|
-
id?: number;
|
|
1323
|
-
/** Session ID. Required in multi-turn conversations after the session is created. */
|
|
1324
|
-
sessionId?: number | undefined;
|
|
1325
|
-
timeStamp?: Date;
|
|
1326
|
-
/** User question. */
|
|
1327
|
-
question!: string;
|
|
1328
|
-
experience!: Experience;
|
|
1329
|
-
selections?: Selections;
|
|
1330
|
-
/** Additional context. */
|
|
1331
|
-
context?: { [key: string]: any } | undefined;
|
|
1470
|
+
export class SummarizeRequest implements ISummarizeRequest {
|
|
1471
|
+
text?: string | undefined;
|
|
1332
1472
|
|
|
1333
|
-
constructor(data?:
|
|
1473
|
+
constructor(data?: ISummarizeRequest) {
|
|
1334
1474
|
if (data) {
|
|
1335
1475
|
for (var property in data) {
|
|
1336
1476
|
if (data.hasOwnProperty(property)) (<any>this)[property] = (<any>data)[property];
|
|
@@ -1340,11 +1480,80 @@ export class UserMessage implements IUserMessage {
|
|
|
1340
1480
|
|
|
1341
1481
|
init(_data?: any) {
|
|
1342
1482
|
if (_data) {
|
|
1343
|
-
this.
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1483
|
+
this.text = _data['text'];
|
|
1484
|
+
}
|
|
1485
|
+
}
|
|
1486
|
+
|
|
1487
|
+
static fromJS(data: any): SummarizeRequest {
|
|
1488
|
+
data = typeof data === 'object' ? data : {};
|
|
1489
|
+
let result = new SummarizeRequest();
|
|
1490
|
+
result.init(data);
|
|
1491
|
+
return result;
|
|
1492
|
+
}
|
|
1493
|
+
|
|
1494
|
+
toJSON(data?: any) {
|
|
1495
|
+
data = typeof data === 'object' ? data : {};
|
|
1496
|
+
data['text'] = this.text;
|
|
1497
|
+
return data;
|
|
1498
|
+
}
|
|
1499
|
+
}
|
|
1500
|
+
|
|
1501
|
+
export interface ISummarizeRequest {
|
|
1502
|
+
text?: string | undefined;
|
|
1503
|
+
}
|
|
1504
|
+
|
|
1505
|
+
export class SummarizeResponse implements ISummarizeResponse {
|
|
1506
|
+
summary?: string | undefined;
|
|
1507
|
+
|
|
1508
|
+
constructor(data?: ISummarizeResponse) {
|
|
1509
|
+
if (data) {
|
|
1510
|
+
for (var property in data) {
|
|
1511
|
+
if (data.hasOwnProperty(property)) (<any>this)[property] = (<any>data)[property];
|
|
1512
|
+
}
|
|
1513
|
+
}
|
|
1514
|
+
}
|
|
1515
|
+
|
|
1516
|
+
init(_data?: any) {
|
|
1517
|
+
if (_data) {
|
|
1518
|
+
this.summary = _data['summary'];
|
|
1519
|
+
}
|
|
1520
|
+
}
|
|
1521
|
+
|
|
1522
|
+
static fromJS(data: any): SummarizeResponse {
|
|
1523
|
+
data = typeof data === 'object' ? data : {};
|
|
1524
|
+
let result = new SummarizeResponse();
|
|
1525
|
+
result.init(data);
|
|
1526
|
+
return result;
|
|
1527
|
+
}
|
|
1528
|
+
|
|
1529
|
+
toJSON(data?: any) {
|
|
1530
|
+
data = typeof data === 'object' ? data : {};
|
|
1531
|
+
data['summary'] = this.summary;
|
|
1532
|
+
return data;
|
|
1533
|
+
}
|
|
1534
|
+
}
|
|
1535
|
+
|
|
1536
|
+
export interface ISummarizeResponse {
|
|
1537
|
+
summary?: string | undefined;
|
|
1538
|
+
}
|
|
1539
|
+
|
|
1540
|
+
/** User request message. */
|
|
1541
|
+
export class UserMessage extends Message implements IUserMessage {
|
|
1542
|
+
/** User question. */
|
|
1543
|
+
declare question: string;
|
|
1544
|
+
declare experience: Experience;
|
|
1545
|
+
declare selections?: Selections;
|
|
1546
|
+
/** Additional context. */
|
|
1547
|
+
declare context?: { [key: string]: any } | undefined;
|
|
1548
|
+
|
|
1549
|
+
constructor(data?: IUserMessage) {
|
|
1550
|
+
super(data);
|
|
1551
|
+
this._discriminator = 'UserMessage';
|
|
1552
|
+
}
|
|
1553
|
+
|
|
1554
|
+
init(_data?: any) {
|
|
1555
|
+
super.init(_data);
|
|
1556
|
+
if (_data) {
|
|
1348
1557
|
this.question = _data['question'];
|
|
1349
1558
|
this.experience = _data['experience'];
|
|
1350
1559
|
this.selections = _data['selections']
|
|
@@ -1369,9 +1578,6 @@ export class UserMessage implements IUserMessage {
|
|
|
1369
1578
|
|
|
1370
1579
|
toJSON(data?: any) {
|
|
1371
1580
|
data = typeof data === 'object' ? data : {};
|
|
1372
|
-
data['id'] = this.id;
|
|
1373
|
-
data['sessionId'] = this.sessionId;
|
|
1374
|
-
data['timeStamp'] = this.timeStamp ? this.timeStamp.toISOString() : <any>undefined;
|
|
1375
1581
|
data['question'] = this.question;
|
|
1376
1582
|
data['experience'] = this.experience;
|
|
1377
1583
|
data['selections'] = this.selections ? this.selections.toJSON() : <any>undefined;
|
|
@@ -1382,17 +1588,13 @@ export class UserMessage implements IUserMessage {
|
|
|
1382
1588
|
(<any>data['context'])[key] = (<any>this.context)[key];
|
|
1383
1589
|
}
|
|
1384
1590
|
}
|
|
1591
|
+
super.toJSON(data);
|
|
1385
1592
|
return data;
|
|
1386
1593
|
}
|
|
1387
1594
|
}
|
|
1388
1595
|
|
|
1389
1596
|
/** User request message. */
|
|
1390
|
-
export interface IUserMessage {
|
|
1391
|
-
/** Primary key. */
|
|
1392
|
-
id?: number;
|
|
1393
|
-
/** Session ID. Required in multi-turn conversations after the session is created. */
|
|
1394
|
-
sessionId?: number | undefined;
|
|
1395
|
-
timeStamp?: Date;
|
|
1597
|
+
export interface IUserMessage extends IMessage {
|
|
1396
1598
|
/** User question. */
|
|
1397
1599
|
question: string;
|
|
1398
1600
|
experience: Experience;
|
|
@@ -1441,7 +1643,3 @@ function throwException(
|
|
|
1441
1643
|
if (result !== null && result !== undefined) throw result;
|
|
1442
1644
|
else throw new ApiException(message, status, response, headers, null);
|
|
1443
1645
|
}
|
|
1444
|
-
|
|
1445
|
-
function isAxiosError(obj: any): obj is AxiosError {
|
|
1446
|
-
return obj && obj.isAxiosError === true;
|
|
1447
|
-
}
|