@webitel/ui-sdk 25.8.4 → 25.8.5
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.
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
declare const QuickRepliesApi: {
|
|
2
|
+
getList: (params: any) => Promise<{
|
|
3
|
+
items: any;
|
|
4
|
+
next: any;
|
|
5
|
+
}>;
|
|
6
|
+
get: ({ itemId: id }: {
|
|
7
|
+
itemId: any;
|
|
8
|
+
}) => Promise<any>;
|
|
9
|
+
add: ({ itemInstance }: {
|
|
10
|
+
itemInstance: any;
|
|
11
|
+
}) => Promise<any>;
|
|
12
|
+
update: ({ itemInstance, itemId: id }: {
|
|
13
|
+
itemInstance: any;
|
|
14
|
+
itemId: any;
|
|
15
|
+
}) => Promise<any>;
|
|
16
|
+
delete: ({ id }: {
|
|
17
|
+
id: any;
|
|
18
|
+
}) => Promise<any>;
|
|
19
|
+
getLookup: (params: any) => Promise<{
|
|
20
|
+
items: any;
|
|
21
|
+
next: any;
|
|
22
|
+
}>;
|
|
23
|
+
};
|
|
24
|
+
export default QuickRepliesApi;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webitel/ui-sdk",
|
|
3
|
-
"version": "25.8.
|
|
3
|
+
"version": "25.8.5",
|
|
4
4
|
"private": false,
|
|
5
5
|
"scripts": {
|
|
6
6
|
"dev": "npm run docs:dev",
|
|
@@ -88,7 +88,7 @@
|
|
|
88
88
|
"@vuelidate/validators": "^2.0.4",
|
|
89
89
|
"@vuepic/vue-datepicker": "^4.5.1",
|
|
90
90
|
"@vueuse/components": "^13.0.0",
|
|
91
|
-
"@webitel/api-services": "^0.0.
|
|
91
|
+
"@webitel/api-services": "^0.0.22",
|
|
92
92
|
"@webitel/styleguide": "^24.12.26",
|
|
93
93
|
"autosize": "^6.0.1",
|
|
94
94
|
"axios": "^1.8.3",
|
package/src/api/clients/index.js
CHANGED
|
@@ -29,6 +29,7 @@ import users from './users/users';
|
|
|
29
29
|
import sysTypes from './wtTypes/sysTypes/sysTypes';
|
|
30
30
|
import typeExtensions from './wtTypes/typeExtensions/typeExtensions';
|
|
31
31
|
import { contactChatMessagesHistory, contacts } from './сontacts/index';
|
|
32
|
+
import quickReplies from './quickReplies/quickReplies';
|
|
32
33
|
|
|
33
34
|
export {
|
|
34
35
|
agentChats,
|
|
@@ -63,4 +64,5 @@ export {
|
|
|
63
64
|
teams,
|
|
64
65
|
typeExtensions,
|
|
65
66
|
users,
|
|
67
|
+
quickReplies,
|
|
66
68
|
};
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import { getQuickRepliesService } from '@webitel/api-services/gen';
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
getDefaultGetListResponse,
|
|
5
|
+
getDefaultGetParams,
|
|
6
|
+
} from '../../defaults/index';
|
|
7
|
+
import applyTransform, {
|
|
8
|
+
camelToSnake,
|
|
9
|
+
merge,
|
|
10
|
+
notify,
|
|
11
|
+
sanitize,
|
|
12
|
+
snakeToCamel,
|
|
13
|
+
} from '../../transformers/index';
|
|
14
|
+
|
|
15
|
+
const quickReplyService = getQuickRepliesService();
|
|
16
|
+
|
|
17
|
+
const fieldsToSend = [
|
|
18
|
+
'name',
|
|
19
|
+
'queues',
|
|
20
|
+
'article',
|
|
21
|
+
'teams',
|
|
22
|
+
'text',
|
|
23
|
+
];
|
|
24
|
+
|
|
25
|
+
const getQuickRepliesList = async (params) => {
|
|
26
|
+
const fieldsToSend = ['page', 'size', 'q', 'sort', 'fields', 'id'];
|
|
27
|
+
|
|
28
|
+
const { page, size, fields, sort, id, q } = applyTransform(params, [
|
|
29
|
+
merge(getDefaultGetParams()),
|
|
30
|
+
(params) => ({ ...params, q: params.search }),
|
|
31
|
+
sanitize(fieldsToSend),
|
|
32
|
+
camelToSnake(),
|
|
33
|
+
]);
|
|
34
|
+
|
|
35
|
+
try {
|
|
36
|
+
const response = await quickReplyService.searchQuickReplies({
|
|
37
|
+
page,
|
|
38
|
+
size,
|
|
39
|
+
fields,
|
|
40
|
+
sort,
|
|
41
|
+
id,
|
|
42
|
+
q,
|
|
43
|
+
});
|
|
44
|
+
const { items, next } = applyTransform(response.data, [
|
|
45
|
+
merge(getDefaultGetListResponse()),
|
|
46
|
+
]);
|
|
47
|
+
return {
|
|
48
|
+
items: applyTransform(items, [snakeToCamel()]),
|
|
49
|
+
next,
|
|
50
|
+
};
|
|
51
|
+
} catch (err) {
|
|
52
|
+
throw applyTransform(err, [notify]);
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
const getQuickReply = async ({ itemId: id }) => {
|
|
57
|
+
|
|
58
|
+
try {
|
|
59
|
+
const response = await quickReplyService.readQuickReply(id);
|
|
60
|
+
return applyTransform(response.data, [snakeToCamel()]);
|
|
61
|
+
} catch (err) {
|
|
62
|
+
throw applyTransform(err, [notify]);
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
const addQuickReply= async ({ itemInstance }) => {
|
|
67
|
+
const item = applyTransform(itemInstance, [
|
|
68
|
+
sanitize(fieldsToSend),
|
|
69
|
+
camelToSnake(),
|
|
70
|
+
]);
|
|
71
|
+
try {
|
|
72
|
+
const response = await quickReplyService.createQuickReply(item);
|
|
73
|
+
return applyTransform(response.data, [snakeToCamel()]);
|
|
74
|
+
} catch (err) {
|
|
75
|
+
throw applyTransform(err, [notify]);
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
const updateQuickReply = async ({ itemInstance, itemId: id }) => {
|
|
81
|
+
const item = applyTransform(itemInstance, [
|
|
82
|
+
camelToSnake(),
|
|
83
|
+
sanitize(fieldsToSend),
|
|
84
|
+
]);
|
|
85
|
+
|
|
86
|
+
try {
|
|
87
|
+
const response = await quickReplyService.updateQuickReply(id, item);
|
|
88
|
+
return applyTransform(response.data, [snakeToCamel()]);
|
|
89
|
+
} catch (err) {
|
|
90
|
+
throw applyTransform(err, [notify]);
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
const deleteQuickReply= async ({ id }) => {
|
|
95
|
+
try {
|
|
96
|
+
const response = await quickReplyService.deleteQuickReply(id);
|
|
97
|
+
return applyTransform(response.data, []);
|
|
98
|
+
} catch (err) {
|
|
99
|
+
throw applyTransform(err, [notify]);
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
const getLookup = (params) =>
|
|
104
|
+
getQuickRepliesList({
|
|
105
|
+
...params,
|
|
106
|
+
fields: params.fields || ['id', 'name'],
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
const QuickRepliesApi = {
|
|
110
|
+
getList: getQuickRepliesList,
|
|
111
|
+
get: getQuickReply,
|
|
112
|
+
add: addQuickReply,
|
|
113
|
+
update: updateQuickReply,
|
|
114
|
+
delete: deleteQuickReply,
|
|
115
|
+
getLookup,
|
|
116
|
+
}
|
|
117
|
+
export default QuickRepliesApi;
|