forked from SciSharp/BotSharp-UI
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlogging-service.js
54 lines (51 loc) · 1.67 KB
/
logging-service.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import { replaceUrl } from '$lib/helpers/http.js';
import { endpoints } from './api-endpoints.js';
import axios from 'axios';
/**
* Show backend full log
*/
export async function getFullLog() {
axios({
url: endpoints.loggingFullLogUrl,
method: 'GET',
responseType: 'blob'
}).then((response) => {
const url = window.URL.createObjectURL(new Blob([response.data]));
const link = document.createElement('a');
link.href = url;
link.target = "_blank";
document.body.appendChild(link);
link.click();
link.remove();
})
}
/**
* Get conversation content log
* @param {string} conversationId
* @param {import('$conversationTypes').ConversationLogFilter} filter
* @returns {Promise<import('$commonTypes').DateTimePagedItems<import('$conversationTypes').ConversationContentLogModel>>}
*/
export async function getContentLogs(conversationId, filter) {
let url = replaceUrl(endpoints.loggingContentLogUrl, {conversationId: conversationId});
const response = await axios.get(url, {
params: {
...filter
}
});
return response.data;
}
/**
* Get conversation state log
* @param {string} conversationId
* @param {import('$conversationTypes').ConversationLogFilter} filter
* @returns {Promise<import('$commonTypes').DateTimePagedItems<import('$conversationTypes').ConversationStateLogModel>>}
*/
export async function getStateLogs(conversationId, filter) {
let url = replaceUrl(endpoints.loggingStateLogUrl, {conversationId: conversationId});
const response = await axios.get(url, {
params: {
...filter
}
});
return response.data;
}