@webitel/api-services 1.0.9 → 1.0.11
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/package.json +1 -1
- package/src/api/clients/__tests__/wireParamsCoverage.spec.ts +286 -0
- package/src/api/clients/activeCalls/activeCalls.ts +72 -0
- package/src/api/clients/agentPauseCauses/agentPauseCauses.ts +182 -0
- package/src/api/clients/agentSkills/agentSkills.ts +193 -0
- package/src/api/clients/agents/__tests__/agents.wireParams.spec.ts +51 -0
- package/src/api/clients/agents/agents.ts +203 -18
- package/src/api/clients/auditForms/auditForms.ts +6 -2
- package/src/api/clients/auditForms/auditRates.ts +91 -0
- package/src/api/clients/backendProfiles/backendProfiles.ts +194 -0
- package/src/api/clients/buckets/buckets.ts +21 -25
- package/src/api/clients/callHistory/callAnnotations.ts +91 -0
- package/src/api/clients/callHistory/callHistory.ts +76 -7
- package/src/api/clients/casePriorities/__tests__/casePriorities.spec.ts +50 -0
- package/src/api/clients/casePriorities/casePriorities.ts +25 -41
- package/src/api/clients/caseStatusConditions/caseStatusConditions.ts +21 -31
- package/src/api/clients/caseStatuses/caseStatuses.ts +10 -21
- package/src/api/clients/cases/cases.ts +6 -3
- package/src/api/clients/catalog/catalog.ts +2 -8
- package/src/api/clients/changelogs/changelogs.ts +8 -0
- package/src/api/clients/chatplans/chatplans.ts +173 -0
- package/src/api/clients/cognitiveProfiles/cognitiveProfiles.ts +209 -0
- package/src/api/clients/communications/communications.ts +38 -42
- package/src/api/clients/dialplans/dialplans.ts +197 -0
- package/src/api/clients/emailProfiles/emailProfiles.ts +222 -0
- package/src/api/clients/fileServices/fileServices.ts +7 -2
- package/src/api/clients/flows/flow.ts +54 -43
- package/src/api/clients/fts/fts.ts +61 -0
- package/src/api/clients/history/transcript/callTranscript.ts +10 -20
- package/src/api/clients/importTemplates/importTemplates.ts +180 -0
- package/src/api/clients/index.ts +30 -0
- package/src/api/clients/lists/blacklistNumbers.ts +155 -0
- package/src/api/clients/lists/blacklists.ts +20 -25
- package/src/api/clients/logs/logs.ts +157 -0
- package/src/api/clients/media/media.ts +19 -15
- package/src/api/clients/object/object.ts +3 -14
- package/src/api/clients/outboundResourceGroups/outboundResourceGroups.ts +187 -0
- package/src/api/clients/outboundResourceGroups/resourcesInGroup.ts +169 -0
- package/src/api/clients/outboundResources/outboundResources.ts +225 -0
- package/src/api/clients/outboundResources/resourceDisplays.ts +165 -0
- package/src/api/clients/pauseTemplates/pauseTemplates.ts +203 -0
- package/src/api/clients/queues/__tests__/queueLogs.spec.ts +3 -3
- package/src/api/clients/queues/__tests__/queueMembers.spec.ts +4 -4
- package/src/api/clients/queues/queueLogs.ts +8 -3
- package/src/api/clients/queues/queueMembers.ts +3 -3
- package/src/api/clients/queues/queues.ts +52 -0
- package/src/api/clients/regions/regions.ts +21 -25
- package/src/api/clients/schemaVariables/schemaVariables.ts +167 -0
- package/src/api/clients/shiftTemplates/shiftTemplates.ts +176 -0
- package/src/api/clients/skills/skillAgents.ts +190 -0
- package/src/api/clients/skills/skills.ts +21 -25
- package/src/api/clients/storagePolicies/storagePolicies.ts +270 -0
- package/src/api/clients/teamHooks/teamHooks.ts +195 -0
- package/src/api/clients/teamTriggers/agentTriggers.ts +77 -0
- package/src/api/clients/teamTriggers/teamFlows.ts +194 -0
- package/src/api/clients/teams/teams.ts +31 -31
- package/src/api/clients/triggers/triggerJobs.ts +63 -0
- package/src/api/clients/triggers/triggers.ts +266 -0
- package/src/api/clients/userSettings/userSettings.ts +8 -9
- package/src/api/clients/users/users.ts +2 -0
- package/src/api/clients/workingConditions/workingConditions.ts +184 -0
- package/src/api/clients/workspaceWidgets/workspaceWidgets.ts +73 -0
- package/src/api/clients/wtTypes/adjunctTypeRecords/adjunctTypeRecords.ts +3 -3
- package/src/api/clients/wtTypes/adjunctTypes/adjunctTypes.ts +1 -1
- package/src/api/clients//321/201ontacts/contactChatMessagesHistory.ts +15 -26
- package/types/.tsbuildinfo +1 -1
- package/types/api/clients/activeCalls/activeCalls.d.ts +7 -0
- package/types/api/clients/agentPauseCauses/agentPauseCauses.d.ts +21 -0
- package/types/api/clients/agentSkills/agentSkills.d.ts +12 -0
- package/types/api/clients/agents/agents.d.ts +23 -2
- package/types/api/clients/auditForms/auditForms.d.ts +7 -0
- package/types/api/clients/auditForms/auditRates.d.ts +10 -0
- package/types/api/clients/backendProfiles/backendProfiles.d.ts +21 -0
- package/types/api/clients/callHistory/callAnnotations.d.ts +12 -0
- package/types/api/clients/callHistory/callHistory.d.ts +24 -3
- package/types/api/clients/caseStatusConditions/caseStatusConditions.d.ts +4 -4
- package/types/api/clients/cases/cases.d.ts +5 -2
- package/types/api/clients/chatplans/chatplans.d.ts +21 -0
- package/types/api/clients/cognitiveProfiles/cognitiveProfiles.d.ts +21 -0
- package/types/api/clients/dialplans/dialplans.d.ts +16 -0
- package/types/api/clients/emailProfiles/emailProfiles.d.ts +27 -0
- package/types/api/clients/fileServices/fileServices.d.ts +1 -1
- package/types/api/clients/fts/fts.d.ts +7 -0
- package/types/api/clients/importTemplates/importTemplates.d.ts +21 -0
- package/types/api/clients/index.d.ts +30 -0
- package/types/api/clients/lists/blacklistNumbers.d.ts +11 -0
- package/types/api/clients/logs/logs.d.ts +15 -0
- package/types/api/clients/outboundResourceGroups/outboundResourceGroups.d.ts +20 -0
- package/types/api/clients/outboundResourceGroups/resourcesInGroup.d.ts +11 -0
- package/types/api/clients/outboundResources/outboundResources.d.ts +21 -0
- package/types/api/clients/outboundResources/resourceDisplays.d.ts +11 -0
- package/types/api/clients/pauseTemplates/pauseTemplates.d.ts +20 -0
- package/types/api/clients/queues/queues.d.ts +5 -0
- package/types/api/clients/schemaVariables/schemaVariables.d.ts +21 -0
- package/types/api/clients/shiftTemplates/shiftTemplates.d.ts +20 -0
- package/types/api/clients/skills/skillAgents.d.ts +13 -0
- package/types/api/clients/storagePolicies/storagePolicies.d.ts +26 -0
- package/types/api/clients/teamHooks/teamHooks.d.ts +12 -0
- package/types/api/clients/teamTriggers/agentTriggers.d.ts +23 -0
- package/types/api/clients/teamTriggers/teamFlows.d.ts +12 -0
- package/types/api/clients/triggers/triggerJobs.d.ts +7 -0
- package/types/api/clients/triggers/triggers.d.ts +22 -0
- package/types/api/clients/userSettings/userSettings.d.ts +2 -2
- package/types/api/clients/workingConditions/workingConditions.d.ts +20 -0
- package/types/api/clients/workspaceWidgets/workspaceWidgets.d.ts +3 -0
- package/types/api/clients/wtTypes/adjunctTypeRecords/adjunctTypeRecords.d.ts +2 -2
- package/types/api/clients/wtTypes/adjunctTypes/adjunctTypes.d.ts +2 -2
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
import { getAgentSkillService } from '../../../gen-wire';
|
|
2
|
+
import { getDefaultGetListResponse, getDefaultGetParams } from '../../defaults';
|
|
3
|
+
import {
|
|
4
|
+
applyTransform,
|
|
5
|
+
camelToSnake,
|
|
6
|
+
merge,
|
|
7
|
+
mergeEach,
|
|
8
|
+
notify,
|
|
9
|
+
sanitize,
|
|
10
|
+
snakeToCamel,
|
|
11
|
+
starToSearch,
|
|
12
|
+
} from '../../transformers';
|
|
13
|
+
import type {
|
|
14
|
+
ApiId,
|
|
15
|
+
ApiParams,
|
|
16
|
+
NestedAddItemParams,
|
|
17
|
+
NestedDeleteItemParams,
|
|
18
|
+
NestedGetItemParams,
|
|
19
|
+
NestedPatchItemParams,
|
|
20
|
+
NestedUpdateItemParams,
|
|
21
|
+
} from '../_shared/types';
|
|
22
|
+
|
|
23
|
+
const defaultObject = {
|
|
24
|
+
skill: {},
|
|
25
|
+
capacity: 0,
|
|
26
|
+
enabled: false,
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
const fieldsToSend = [
|
|
30
|
+
'capacity',
|
|
31
|
+
'agentId',
|
|
32
|
+
'skill',
|
|
33
|
+
'enabled',
|
|
34
|
+
];
|
|
35
|
+
|
|
36
|
+
const preRequestHandler = (parentId: ApiId) => (item: ApiParams) => ({
|
|
37
|
+
...item,
|
|
38
|
+
agentId: parentId,
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
const getAgentSkillsList = async (params: ApiParams) => {
|
|
42
|
+
const { parentId, page, size, search, sort, fields, id } = applyTransform(
|
|
43
|
+
params,
|
|
44
|
+
[
|
|
45
|
+
merge(getDefaultGetParams()),
|
|
46
|
+
starToSearch('search'),
|
|
47
|
+
],
|
|
48
|
+
);
|
|
49
|
+
|
|
50
|
+
try {
|
|
51
|
+
const response = await getAgentSkillService().searchAgentSkill(
|
|
52
|
+
String(parentId),
|
|
53
|
+
{
|
|
54
|
+
page,
|
|
55
|
+
size,
|
|
56
|
+
// the generated param is `q`; `search` is what the datalist store sends
|
|
57
|
+
q: search,
|
|
58
|
+
sort,
|
|
59
|
+
fields,
|
|
60
|
+
id,
|
|
61
|
+
},
|
|
62
|
+
);
|
|
63
|
+
const { items, next } = applyTransform(response.data, [
|
|
64
|
+
snakeToCamel(),
|
|
65
|
+
merge(getDefaultGetListResponse()),
|
|
66
|
+
]);
|
|
67
|
+
return {
|
|
68
|
+
items: applyTransform(items, [
|
|
69
|
+
mergeEach(defaultObject),
|
|
70
|
+
]),
|
|
71
|
+
next,
|
|
72
|
+
};
|
|
73
|
+
} catch (err) {
|
|
74
|
+
throw applyTransform(err, [
|
|
75
|
+
notify,
|
|
76
|
+
]);
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
const getAgentSkill = async ({ parentId, itemId: id }: NestedGetItemParams) => {
|
|
81
|
+
try {
|
|
82
|
+
const response = await getAgentSkillService().readAgentSkill(
|
|
83
|
+
String(parentId),
|
|
84
|
+
String(id),
|
|
85
|
+
);
|
|
86
|
+
return applyTransform(response.data, [
|
|
87
|
+
snakeToCamel(),
|
|
88
|
+
merge(defaultObject),
|
|
89
|
+
]);
|
|
90
|
+
} catch (err) {
|
|
91
|
+
throw applyTransform(err, [
|
|
92
|
+
notify,
|
|
93
|
+
]);
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
const addAgentSkill = async ({
|
|
98
|
+
parentId,
|
|
99
|
+
itemInstance,
|
|
100
|
+
}: NestedAddItemParams) => {
|
|
101
|
+
const item = applyTransform(itemInstance, [
|
|
102
|
+
preRequestHandler(parentId),
|
|
103
|
+
sanitize(fieldsToSend),
|
|
104
|
+
camelToSnake(),
|
|
105
|
+
]);
|
|
106
|
+
try {
|
|
107
|
+
const response = await getAgentSkillService().createAgentSkill(
|
|
108
|
+
String(parentId),
|
|
109
|
+
item,
|
|
110
|
+
);
|
|
111
|
+
return applyTransform(response.data, [
|
|
112
|
+
snakeToCamel(),
|
|
113
|
+
]);
|
|
114
|
+
} catch (err) {
|
|
115
|
+
throw applyTransform(err, [
|
|
116
|
+
notify,
|
|
117
|
+
]);
|
|
118
|
+
}
|
|
119
|
+
};
|
|
120
|
+
|
|
121
|
+
const patchAgentSkill = async ({
|
|
122
|
+
parentId,
|
|
123
|
+
changes,
|
|
124
|
+
id,
|
|
125
|
+
}: NestedPatchItemParams) => {
|
|
126
|
+
const body = applyTransform(changes, [
|
|
127
|
+
sanitize(fieldsToSend),
|
|
128
|
+
camelToSnake(),
|
|
129
|
+
]);
|
|
130
|
+
try {
|
|
131
|
+
const response = await getAgentSkillService().patchAgentSkill(
|
|
132
|
+
String(parentId),
|
|
133
|
+
String(id),
|
|
134
|
+
body,
|
|
135
|
+
);
|
|
136
|
+
return applyTransform(response.data, [
|
|
137
|
+
snakeToCamel(),
|
|
138
|
+
]);
|
|
139
|
+
} catch (err) {
|
|
140
|
+
throw applyTransform(err, [
|
|
141
|
+
notify,
|
|
142
|
+
]);
|
|
143
|
+
}
|
|
144
|
+
};
|
|
145
|
+
|
|
146
|
+
const updateAgentSkill = async ({
|
|
147
|
+
parentId,
|
|
148
|
+
itemInstance,
|
|
149
|
+
itemId: id,
|
|
150
|
+
}: NestedUpdateItemParams) => {
|
|
151
|
+
const item = applyTransform(itemInstance, [
|
|
152
|
+
preRequestHandler(parentId),
|
|
153
|
+
sanitize(fieldsToSend),
|
|
154
|
+
camelToSnake(),
|
|
155
|
+
]);
|
|
156
|
+
try {
|
|
157
|
+
const response = await getAgentSkillService().updateAgentSkill(
|
|
158
|
+
String(parentId),
|
|
159
|
+
String(id),
|
|
160
|
+
item,
|
|
161
|
+
);
|
|
162
|
+
return applyTransform(response.data, [
|
|
163
|
+
snakeToCamel(),
|
|
164
|
+
]);
|
|
165
|
+
} catch (err) {
|
|
166
|
+
throw applyTransform(err, [
|
|
167
|
+
notify,
|
|
168
|
+
]);
|
|
169
|
+
}
|
|
170
|
+
};
|
|
171
|
+
|
|
172
|
+
const deleteAgentSkill = async ({ parentId, id }: NestedDeleteItemParams) => {
|
|
173
|
+
try {
|
|
174
|
+
const response = await getAgentSkillService().deleteAgentSkill(
|
|
175
|
+
String(parentId),
|
|
176
|
+
String(id),
|
|
177
|
+
);
|
|
178
|
+
return applyTransform(response.data, []);
|
|
179
|
+
} catch (err) {
|
|
180
|
+
throw applyTransform(err, [
|
|
181
|
+
notify,
|
|
182
|
+
]);
|
|
183
|
+
}
|
|
184
|
+
};
|
|
185
|
+
|
|
186
|
+
export const AgentSkillsAPI = {
|
|
187
|
+
getList: getAgentSkillsList,
|
|
188
|
+
get: getAgentSkill,
|
|
189
|
+
add: addAgentSkill,
|
|
190
|
+
patch: patchAgentSkill,
|
|
191
|
+
update: updateAgentSkill,
|
|
192
|
+
delete: deleteAgentSkill,
|
|
193
|
+
};
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { beforeEach, describe, expect, it, vi } from 'vitest';
|
|
2
|
+
|
|
3
|
+
const searchAgent = vi.fn(() =>
|
|
4
|
+
Promise.resolve({
|
|
5
|
+
data: {},
|
|
6
|
+
}),
|
|
7
|
+
);
|
|
8
|
+
|
|
9
|
+
vi.mock('../../../../gen-wire', async (importOriginal) => ({
|
|
10
|
+
...(await importOriginal<Record<string, unknown>>()),
|
|
11
|
+
getAgentService: () => ({
|
|
12
|
+
searchAgent,
|
|
13
|
+
}),
|
|
14
|
+
}));
|
|
15
|
+
|
|
16
|
+
const { SearchAgentQueryParams } = await import('../../../../gen-wire');
|
|
17
|
+
const { AgentsAPI } = await import('../agents');
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Callers spell these filters after the entity, the endpoint after the column.
|
|
21
|
+
* Left unmapped they were sanitized away, so the filters silently did nothing.
|
|
22
|
+
*/
|
|
23
|
+
describe('AgentsAPI.getList', () => {
|
|
24
|
+
beforeEach(() => searchAgent.mockClear());
|
|
25
|
+
|
|
26
|
+
it('maps team and skill onto team_id and skill_id', async () => {
|
|
27
|
+
await AgentsAPI.getList({
|
|
28
|
+
page: 1,
|
|
29
|
+
size: 10,
|
|
30
|
+
team: [
|
|
31
|
+
1,
|
|
32
|
+
],
|
|
33
|
+
skill: [
|
|
34
|
+
2,
|
|
35
|
+
],
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
const [params] = searchAgent.mock.calls[0];
|
|
39
|
+
expect(params).toMatchObject({
|
|
40
|
+
team_id: [
|
|
41
|
+
1,
|
|
42
|
+
],
|
|
43
|
+
skill_id: [
|
|
44
|
+
2,
|
|
45
|
+
],
|
|
46
|
+
});
|
|
47
|
+
expect(SearchAgentQueryParams.strict().safeParse(params).success).toBe(
|
|
48
|
+
true,
|
|
49
|
+
);
|
|
50
|
+
});
|
|
51
|
+
});
|
|
@@ -9,6 +9,7 @@ import {
|
|
|
9
9
|
applyTransform,
|
|
10
10
|
camelToSnake,
|
|
11
11
|
merge,
|
|
12
|
+
mergeEach,
|
|
12
13
|
notify,
|
|
13
14
|
sanitize,
|
|
14
15
|
snakeToCamel,
|
|
@@ -16,6 +17,7 @@ import {
|
|
|
16
17
|
} from '../../transformers';
|
|
17
18
|
import type {
|
|
18
19
|
AddItemParams,
|
|
20
|
+
ApiId,
|
|
19
21
|
ApiParams,
|
|
20
22
|
DeleteItemParams,
|
|
21
23
|
GetItemParams,
|
|
@@ -43,13 +45,13 @@ const getAgentsList = async (params: ApiParams) => {
|
|
|
43
45
|
'fields',
|
|
44
46
|
'id',
|
|
45
47
|
'allow_channels',
|
|
46
|
-
'
|
|
48
|
+
'team_id',
|
|
47
49
|
'region_id',
|
|
48
50
|
'auditor_id',
|
|
49
|
-
'
|
|
51
|
+
'skill_id',
|
|
50
52
|
'queue_id',
|
|
51
53
|
'is_supervisor',
|
|
52
|
-
'
|
|
54
|
+
'not_supervisor',
|
|
53
55
|
'user_id',
|
|
54
56
|
'not_team_id',
|
|
55
57
|
'supervisor_id',
|
|
@@ -58,10 +60,18 @@ const getAgentsList = async (params: ApiParams) => {
|
|
|
58
60
|
];
|
|
59
61
|
const requestParams = applyTransform(params, [
|
|
60
62
|
camelToSnake(),
|
|
61
|
-
merge(
|
|
63
|
+
merge(getDefaultGetParams()),
|
|
62
64
|
(params) => ({
|
|
63
65
|
...params,
|
|
64
66
|
q: params.search,
|
|
67
|
+
/*
|
|
68
|
+
* Callers spell these filters after the entity rather than the
|
|
69
|
+
* generated query param. Left unmapped they were sanitized away and
|
|
70
|
+
* the filter silently did nothing.
|
|
71
|
+
*/
|
|
72
|
+
team_id: params.team_id ?? params.team,
|
|
73
|
+
skill_id: params.skill_id ?? params.skill,
|
|
74
|
+
not_supervisor: params.not_supervisor ?? params.is_not_supervisor,
|
|
65
75
|
}),
|
|
66
76
|
sanitize(fieldsToSend),
|
|
67
77
|
]);
|
|
@@ -85,21 +95,31 @@ const getAgentsList = async (params: ApiParams) => {
|
|
|
85
95
|
}
|
|
86
96
|
};
|
|
87
97
|
|
|
88
|
-
const
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
};
|
|
98
|
+
const AGENT_DEFAULTS = {
|
|
99
|
+
user: {},
|
|
100
|
+
team: {},
|
|
101
|
+
supervisor: [],
|
|
102
|
+
auditor: [],
|
|
103
|
+
region: {},
|
|
104
|
+
progressiveCount: 0,
|
|
105
|
+
chatCount: 0,
|
|
106
|
+
taskCount: 0,
|
|
107
|
+
isSupervisor: false,
|
|
108
|
+
description: '',
|
|
109
|
+
greetingMedia: {},
|
|
110
|
+
};
|
|
102
111
|
|
|
112
|
+
/**
|
|
113
|
+
* `defaultObject` overrides the defaults merged into the response. Cards that
|
|
114
|
+
* bind a validated numeric field need `null` rather than `0` for "unset", so
|
|
115
|
+
* they pass their own.
|
|
116
|
+
*/
|
|
117
|
+
const getAgent = async ({
|
|
118
|
+
itemId: id,
|
|
119
|
+
defaultObject = AGENT_DEFAULTS,
|
|
120
|
+
}: GetItemParams & {
|
|
121
|
+
defaultObject?: ApiParams;
|
|
122
|
+
}) => {
|
|
103
123
|
try {
|
|
104
124
|
const response = await getAgentService().readAgent(String(id));
|
|
105
125
|
return applyTransform(response.data, [
|
|
@@ -124,6 +144,8 @@ const fieldsToSend = [
|
|
|
124
144
|
'chatCount',
|
|
125
145
|
'taskCount',
|
|
126
146
|
'isSupervisor',
|
|
147
|
+
'screenControl',
|
|
148
|
+
'extraChatCount',
|
|
127
149
|
];
|
|
128
150
|
|
|
129
151
|
const addAgent = async ({ itemInstance }: AddItemParams) => {
|
|
@@ -188,6 +210,165 @@ const deleteAgent = async ({ id }: DeleteItemParams) => {
|
|
|
188
210
|
}
|
|
189
211
|
};
|
|
190
212
|
|
|
213
|
+
/**
|
|
214
|
+
* Per-agent status/occupancy statistics over a time window — the supervisor
|
|
215
|
+
* agents table. Durations come back raw; formatting them is the caller's job.
|
|
216
|
+
*/
|
|
217
|
+
const getAgentStatusStatistics = async (params: ApiParams) => {
|
|
218
|
+
const {
|
|
219
|
+
page,
|
|
220
|
+
size,
|
|
221
|
+
search,
|
|
222
|
+
sort,
|
|
223
|
+
ids,
|
|
224
|
+
fields,
|
|
225
|
+
from,
|
|
226
|
+
to,
|
|
227
|
+
status,
|
|
228
|
+
queue,
|
|
229
|
+
team,
|
|
230
|
+
skill,
|
|
231
|
+
supervisor,
|
|
232
|
+
auditor,
|
|
233
|
+
region,
|
|
234
|
+
utilizationFrom,
|
|
235
|
+
utilizationTo,
|
|
236
|
+
callNow,
|
|
237
|
+
} = applyTransform(params, [
|
|
238
|
+
merge(getDefaultGetParams()),
|
|
239
|
+
]);
|
|
240
|
+
|
|
241
|
+
try {
|
|
242
|
+
const response = await getAgentService().searchAgentStatusStatistic({
|
|
243
|
+
page,
|
|
244
|
+
size,
|
|
245
|
+
// the generated param is `q`; `search` is what the datalist store sends
|
|
246
|
+
q: search,
|
|
247
|
+
sort,
|
|
248
|
+
fields,
|
|
249
|
+
agent_id: ids,
|
|
250
|
+
'time.from': from,
|
|
251
|
+
'time.to': to,
|
|
252
|
+
status,
|
|
253
|
+
queue_id: queue,
|
|
254
|
+
team_id: team,
|
|
255
|
+
'utilization.from': utilizationFrom,
|
|
256
|
+
'utilization.to': utilizationTo,
|
|
257
|
+
has_call: callNow,
|
|
258
|
+
skill_id: skill,
|
|
259
|
+
region_id: region,
|
|
260
|
+
supervisor_id: supervisor,
|
|
261
|
+
auditor_id: auditor,
|
|
262
|
+
});
|
|
263
|
+
const { items, next } = applyTransform(response.data, [
|
|
264
|
+
snakeToCamel(),
|
|
265
|
+
merge(getDefaultGetListResponse()),
|
|
266
|
+
]);
|
|
267
|
+
return {
|
|
268
|
+
items,
|
|
269
|
+
next,
|
|
270
|
+
};
|
|
271
|
+
} catch (err) {
|
|
272
|
+
throw applyTransform(err, [
|
|
273
|
+
notify,
|
|
274
|
+
]);
|
|
275
|
+
}
|
|
276
|
+
};
|
|
277
|
+
|
|
278
|
+
/** The same statistics for a single agent. */
|
|
279
|
+
const getAgentStatusStatisticsItem = async ({
|
|
280
|
+
agentId,
|
|
281
|
+
from,
|
|
282
|
+
to,
|
|
283
|
+
}: {
|
|
284
|
+
agentId: ApiId;
|
|
285
|
+
from?: string;
|
|
286
|
+
to?: string;
|
|
287
|
+
}) => {
|
|
288
|
+
try {
|
|
289
|
+
const response = await getAgentService().searchAgentStatusStatisticItem(
|
|
290
|
+
String(agentId),
|
|
291
|
+
{
|
|
292
|
+
'time.from': from,
|
|
293
|
+
'time.to': to,
|
|
294
|
+
},
|
|
295
|
+
);
|
|
296
|
+
return applyTransform(response.data, [
|
|
297
|
+
snakeToCamel(),
|
|
298
|
+
]);
|
|
299
|
+
} catch (err) {
|
|
300
|
+
throw applyTransform(err, [
|
|
301
|
+
notify,
|
|
302
|
+
]);
|
|
303
|
+
}
|
|
304
|
+
};
|
|
305
|
+
|
|
306
|
+
/** Queues the given agent is assigned to. */
|
|
307
|
+
const getAgentQueues = async (params: ApiParams) => {
|
|
308
|
+
const { parentId, page, size, search, sort, fields } = applyTransform(
|
|
309
|
+
params,
|
|
310
|
+
[
|
|
311
|
+
merge(getDefaultGetParams()),
|
|
312
|
+
starToSearch('search'),
|
|
313
|
+
],
|
|
314
|
+
);
|
|
315
|
+
|
|
316
|
+
try {
|
|
317
|
+
const response = await getAgentService().searchAgentInQueue(
|
|
318
|
+
String(parentId),
|
|
319
|
+
{
|
|
320
|
+
page,
|
|
321
|
+
size,
|
|
322
|
+
// the generated param is `q`; `search` is what the datalist store sends
|
|
323
|
+
q: search,
|
|
324
|
+
sort,
|
|
325
|
+
fields,
|
|
326
|
+
},
|
|
327
|
+
);
|
|
328
|
+
const { items, next } = applyTransform(response.data, [
|
|
329
|
+
snakeToCamel(),
|
|
330
|
+
merge(getDefaultGetListResponse()),
|
|
331
|
+
]);
|
|
332
|
+
return {
|
|
333
|
+
items,
|
|
334
|
+
next,
|
|
335
|
+
};
|
|
336
|
+
} catch (err) {
|
|
337
|
+
throw applyTransform(err, [
|
|
338
|
+
notify,
|
|
339
|
+
]);
|
|
340
|
+
}
|
|
341
|
+
};
|
|
342
|
+
|
|
343
|
+
/** Pause causes the given agent is allowed to select. */
|
|
344
|
+
const getPauseCausesForAgent = async ({ agentId }: { agentId: ApiId }) => {
|
|
345
|
+
const defaultObject = {
|
|
346
|
+
name: '',
|
|
347
|
+
durationMin: 0,
|
|
348
|
+
limitMin: 0,
|
|
349
|
+
};
|
|
350
|
+
|
|
351
|
+
try {
|
|
352
|
+
const response = await getAgentService().searchPauseCauseForAgent(
|
|
353
|
+
String(agentId),
|
|
354
|
+
);
|
|
355
|
+
const { items, next } = applyTransform(response.data, [
|
|
356
|
+
snakeToCamel(),
|
|
357
|
+
merge(getDefaultGetListResponse()),
|
|
358
|
+
]);
|
|
359
|
+
return {
|
|
360
|
+
items: applyTransform(items, [
|
|
361
|
+
mergeEach(defaultObject),
|
|
362
|
+
]),
|
|
363
|
+
next,
|
|
364
|
+
};
|
|
365
|
+
} catch (err) {
|
|
366
|
+
throw applyTransform(err, [
|
|
367
|
+
notify,
|
|
368
|
+
]);
|
|
369
|
+
}
|
|
370
|
+
};
|
|
371
|
+
|
|
191
372
|
const getAgentsLookup = (params: Parameters<typeof getAgentsList>[0]) =>
|
|
192
373
|
getAgentsList({
|
|
193
374
|
...params,
|
|
@@ -331,4 +512,8 @@ export const AgentsAPI = {
|
|
|
331
512
|
getAgentUsersOptions,
|
|
332
513
|
getSupervisorOptions,
|
|
333
514
|
getUsersStatus,
|
|
515
|
+
getPauseCausesForAgent,
|
|
516
|
+
getAgentQueues,
|
|
517
|
+
getStatusStatistics: getAgentStatusStatistics,
|
|
518
|
+
getStatusStatisticsItem: getAgentStatusStatisticsItem,
|
|
334
519
|
};
|
|
@@ -27,7 +27,11 @@ import type {
|
|
|
27
27
|
UpdateItemParams,
|
|
28
28
|
} from '../_shared/types';
|
|
29
29
|
|
|
30
|
-
|
|
30
|
+
/**
|
|
31
|
+
* Fills in the defaults the backend omits for each question type. Shared with
|
|
32
|
+
* the audit rate client, whose payload embeds the same question list.
|
|
33
|
+
*/
|
|
34
|
+
export const auditFormQuestionsResponseHandler = (response: ApiParams) => ({
|
|
31
35
|
...response,
|
|
32
36
|
questions:
|
|
33
37
|
response.questions?.map((question: ApiParams) => {
|
|
@@ -104,7 +108,7 @@ const getAuditForm = async ({ itemId: id }: GetItemParams) => {
|
|
|
104
108
|
const response = await getAuditFormService().readAuditForm(Number(id));
|
|
105
109
|
return applyTransform(response.data, [
|
|
106
110
|
snakeToCamel(),
|
|
107
|
-
|
|
111
|
+
auditFormQuestionsResponseHandler,
|
|
108
112
|
]);
|
|
109
113
|
} catch (err) {
|
|
110
114
|
throw applyTransform(err, [
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import type { EngineAuditRate } from '@webitel/api-services/gen/models';
|
|
2
|
+
import { getAuditFormService } from '../../../gen-wire';
|
|
3
|
+
import {
|
|
4
|
+
applyTransform,
|
|
5
|
+
camelToSnake,
|
|
6
|
+
notify,
|
|
7
|
+
snakeToCamel,
|
|
8
|
+
} from '../../transformers';
|
|
9
|
+
import { auditFormQuestionsResponseHandler } from './auditForms';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Answers carry no timestamp of their own; the rate's is the one the UI shows.
|
|
13
|
+
*/
|
|
14
|
+
const fillAnswersCreatedAtFromRate = (rate: EngineAuditRate) => ({
|
|
15
|
+
...rate,
|
|
16
|
+
answers: (rate.answers ?? []).map((answer) => ({
|
|
17
|
+
...answer,
|
|
18
|
+
createdAt: rate.createdAt,
|
|
19
|
+
})),
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
const responseTransformers = [
|
|
23
|
+
snakeToCamel(),
|
|
24
|
+
auditFormQuestionsResponseHandler,
|
|
25
|
+
fillAnswersCreatedAtFromRate,
|
|
26
|
+
];
|
|
27
|
+
|
|
28
|
+
const getAuditRate = async (rateId: EngineAuditRate['id']) => {
|
|
29
|
+
try {
|
|
30
|
+
const response = await getAuditFormService().readAuditRate(String(rateId));
|
|
31
|
+
return applyTransform(response.data, responseTransformers);
|
|
32
|
+
} catch (err) {
|
|
33
|
+
throw applyTransform(err, [
|
|
34
|
+
notify,
|
|
35
|
+
]);
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
const addAuditRate = async (itemInstance: EngineAuditRate) => {
|
|
40
|
+
const item = applyTransform(itemInstance, [
|
|
41
|
+
camelToSnake(),
|
|
42
|
+
]);
|
|
43
|
+
try {
|
|
44
|
+
const response = await getAuditFormService().createAuditFormRate(item);
|
|
45
|
+
return applyTransform(response.data, responseTransformers);
|
|
46
|
+
} catch (err) {
|
|
47
|
+
throw applyTransform(err, [
|
|
48
|
+
notify,
|
|
49
|
+
]);
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
const updateAuditRate = async ({
|
|
54
|
+
itemId,
|
|
55
|
+
itemInstance,
|
|
56
|
+
}: {
|
|
57
|
+
itemId: EngineAuditRate['id'];
|
|
58
|
+
itemInstance: EngineAuditRate;
|
|
59
|
+
}) => {
|
|
60
|
+
const item = applyTransform(itemInstance, [
|
|
61
|
+
camelToSnake(),
|
|
62
|
+
]);
|
|
63
|
+
try {
|
|
64
|
+
const response = await getAuditFormService().updateAuditRate(
|
|
65
|
+
String(itemId),
|
|
66
|
+
item,
|
|
67
|
+
);
|
|
68
|
+
return applyTransform(response.data, responseTransformers);
|
|
69
|
+
} catch (err) {
|
|
70
|
+
throw applyTransform(err, [
|
|
71
|
+
notify,
|
|
72
|
+
]);
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
const deleteAuditRate = async (rateId: EngineAuditRate['id']) => {
|
|
77
|
+
try {
|
|
78
|
+
await getAuditFormService().deleteAuditRate(String(rateId));
|
|
79
|
+
} catch (err) {
|
|
80
|
+
throw applyTransform(err, [
|
|
81
|
+
notify,
|
|
82
|
+
]);
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
export const AuditRatesAPI = {
|
|
87
|
+
get: getAuditRate,
|
|
88
|
+
add: addAuditRate,
|
|
89
|
+
update: updateAuditRate,
|
|
90
|
+
delete: deleteAuditRate,
|
|
91
|
+
};
|