@webitel/ui-sdk 26.8.67 → 26.8.69
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/dist/clients-D5pO5FKV.js +39334 -0
- package/dist/{components-CXPq3d81.js → components-BH_gLkO3.js} +7 -7
- package/dist/{genClient-DMVlC4Uy.js → genClient-DtYJ9KWy.js} +1 -1
- package/dist/ui-sdk.js +3 -3
- package/dist/ui-sdk.umd.cjs +659 -735
- package/dist/{wt-button-l_CCN7zG.js → wt-button-TVtG0saz.js} +1 -1
- package/dist/{wt-chat-emoji-BwCLLExE.js → wt-chat-emoji-B-FoXVDr.js} +3 -3
- package/dist/{wt-display-chip-items-DgDn6xoK.js → wt-display-chip-items-CZzcHtcb.js} +1 -1
- package/dist/{wt-icon-btn-BbPNcD-O.js → wt-icon-btn-B_hS2f_v.js} +1 -1
- package/dist/{wt-icon-CjNYdMOP.js → wt-icon-md5nPR1T.js} +2 -2
- package/dist/{wt-notifications-bar-BTt1vqwz.js → wt-notifications-bar-k3Osz6gY.js} +1 -1
- package/dist/{wt-player-CoB2InY0.js → wt-player-R3rAiIxl.js} +2 -2
- package/dist/{wt-send-message-popup-TJdbzgRF.js → wt-send-message-popup-Cc92sY9q.js} +2 -2
- package/dist/{wt-toast-DHV4UvFz.js → wt-toast-DsIX8ZW_.js} +1 -1
- package/dist/wt-tree-CfvNlw7N.js +2042 -0
- package/dist/{wt-tree-table-9vnEJcX0.js → wt-tree-table-R02DpJ7M.js} +1 -1
- package/dist/{wt-type-extension-value-input-D5Y-ds9V.js → wt-type-extension-value-input-DfbrgPNa.js} +2 -2
- package/dist/{wt-vidstack-player-DKf1aSC7.js → wt-vidstack-player-DtbNeGgs.js} +3 -3
- package/package.json +1 -1
- package/src/api/clients/index.js +5 -66
- package/src/assets/icons/sprite/call--filled.svg +2 -2
- package/src/assets/icons/sprite/call-end--filled.svg +2 -3
- package/src/modules/AgentStatusSelect/api/agent-status.ts +44 -0
- package/src/modules/AgentStatusSelect/api/pause-cause.ts +54 -0
- package/src/modules/AgentStatusSelect/components/__tests__/wt-cc-agent-status-select.spec.js +4 -10
- package/src/modules/AgentStatusSelect/components/wt-cc-agent-status-select.vue +2 -6
- package/types/.tsbuildinfo +1 -1
- package/types/api/clients/index.d.ts +1 -33
- package/types/modules/AgentStatusSelect/api/agent-status.d.ts +4 -12
- package/types/modules/AgentStatusSelect/api/pause-cause.d.ts +7 -9
- package/dist/clients-DpqA006B.js +0 -40042
- package/dist/side-channel-M3LABDql.js +0 -833
- package/dist/wt-tree-DKSphRxr.js +0 -1216
- package/src/api/clients/agents/agentChats.js +0 -79
- package/src/api/clients/agents/agents.js +0 -300
- package/src/api/clients/buckets/buckets.js +0 -134
- package/src/api/clients/calendars/calendars.js +0 -239
- package/src/api/clients/caseCloseReasonGroups/caseCloseReasonGroups.js +0 -161
- package/src/api/clients/caseCloseReasons/caseCloseReasons.js +0 -165
- package/src/api/clients/casePriorities/casePriorities.js +0 -166
- package/src/api/clients/caseServiceCatalogs/serviceCatalogs.js +0 -231
- package/src/api/clients/caseServices/services.js +0 -221
- package/src/api/clients/caseSources/caseSources.ts +0 -2
- package/src/api/clients/caseStatusConditions/caseStatusConditions.js +0 -207
- package/src/api/clients/caseStatuses/caseStatuses.js +0 -152
- package/src/api/clients/catalog/catalog.js +0 -63
- package/src/api/clients/chatGateways/chatGateways.js +0 -338
- package/src/api/clients/chatGateways/defaults/defaultChatGateway.js +0 -18
- package/src/api/clients/chatGateways/defaults/webChatGateway.js +0 -72
- package/src/api/clients/chatGateways/enums/WebchatAlternativeChannel.enum.js +0 -14
- package/src/api/clients/chatGateways/scripts/generateUri.js +0 -9
- package/src/api/clients/communications/communications.js +0 -172
- package/src/api/clients/configurations/configurations.js +0 -168
- package/src/api/clients/contactGroups/contactGroups.js +0 -221
- package/src/api/clients/flows/flow.js +0 -252
- package/src/api/clients/gateways/defaults/defaultGateway.js +0 -9
- package/src/api/clients/gateways/defaults/registerGateway.js +0 -12
- package/src/api/clients/gateways/defaults/trunkingGateway.js +0 -16
- package/src/api/clients/gateways/gateways.js +0 -221
- package/src/api/clients/labels/labels.js +0 -69
- package/src/api/clients/lists/blacklists.js +0 -142
- package/src/api/clients/media/media.js +0 -136
- package/src/api/clients/object/object.js +0 -138
- package/src/api/clients/queues/queues.js +0 -263
- package/src/api/clients/quickReplies/quickReplies.ts +0 -2
- package/src/api/clients/skills/skills.js +0 -134
- package/src/api/clients/slaConditions/slaConditions.js +0 -190
- package/src/api/clients/slas/slas.js +0 -148
- package/src/api/clients/teams/teams.js +0 -161
- package/src/api/clients/users/__tests__/users.spec.js +0 -282
- package/src/api/clients/users/users.js +0 -334
- package/src/api/clients/wtTypes/_shared/utils/sortDynamicFields.ts +0 -38
- package/src/api/clients/wtTypes/sysTypes/sysTypes.ts +0 -92
- package/src/api/clients/wtTypes/typeExtensions/typeExtensions.ts +0 -156
- package/src/api/clients//321/201ontacts/contactChatMessagesHistory.js +0 -119
- package/src/api/clients//321/201ontacts/contacts.js +0 -449
- package/src/api/clients//321/201ontacts/enums/ContactsSearchMode.js +0 -9
- package/src/api/clients//321/201ontacts/index.js +0 -5
- package/src/modules/AgentStatusSelect/api/agent-status.js +0 -30
- package/src/modules/AgentStatusSelect/api/pause-cause.js +0 -49
- package/types/api/clients/agents/agentChats.d.ts +0 -10
- package/types/api/clients/agents/agents.d.ts +0 -55
- package/types/api/clients/buckets/buckets.d.ts +0 -30
- package/types/api/clients/calendars/calendars.d.ts +0 -35
- package/types/api/clients/caseCloseReasonGroups/caseCloseReasonGroups.d.ts +0 -30
- package/types/api/clients/caseCloseReasons/caseCloseReasons.d.ts +0 -36
- package/types/api/clients/casePriorities/casePriorities.d.ts +0 -30
- package/types/api/clients/caseServiceCatalogs/serviceCatalogs.d.ts +0 -30
- package/types/api/clients/caseServices/services.d.ts +0 -42
- package/types/api/clients/caseSources/caseSources.d.ts +0 -1
- package/types/api/clients/caseStatusConditions/caseStatusConditions.d.ts +0 -43
- package/types/api/clients/caseStatuses/caseStatuses.d.ts +0 -30
- package/types/api/clients/catalog/catalog.d.ts +0 -13
- package/types/api/clients/chatGateways/chatGateways.d.ts +0 -35
- package/types/api/clients/chatGateways/defaults/defaultChatGateway.d.ts +0 -15
- package/types/api/clients/chatGateways/defaults/webChatGateway.d.ts +0 -64
- package/types/api/clients/chatGateways/enums/WebchatAlternativeChannel.enum.d.ts +0 -8
- package/types/api/clients/chatGateways/scripts/generateUri.d.ts +0 -2
- package/types/api/clients/communications/communications.d.ts +0 -35
- package/types/api/clients/configurations/configurations.d.ts +0 -35
- package/types/api/clients/contactGroups/contactGroups.d.ts +0 -47
- package/types/api/clients/flows/flow.d.ts +0 -35
- package/types/api/clients/gateways/defaults/defaultGateway.d.ts +0 -8
- package/types/api/clients/gateways/defaults/registerGateway.d.ts +0 -13
- package/types/api/clients/gateways/defaults/trunkingGateway.d.ts +0 -11
- package/types/api/clients/gateways/gateways.d.ts +0 -35
- package/types/api/clients/labels/labels.d.ts +0 -13
- package/types/api/clients/lists/blacklists.d.ts +0 -30
- package/types/api/clients/media/media.d.ts +0 -24
- package/types/api/clients/object/object.d.ts +0 -13
- package/types/api/clients/queues/queues.d.ts +0 -40
- package/types/api/clients/quickReplies/quickReplies.d.ts +0 -1
- package/types/api/clients/skills/skills.d.ts +0 -30
- package/types/api/clients/slaConditions/slaConditions.d.ts +0 -36
- package/types/api/clients/slas/slas.d.ts +0 -30
- package/types/api/clients/teams/teams.d.ts +0 -30
- package/types/api/clients/users/__tests__/users.spec.d.ts +0 -1
- package/types/api/clients/users/users.d.ts +0 -46
- package/types/api/clients/wtTypes/_shared/utils/sortDynamicFields.d.ts +0 -2
- package/types/api/clients/wtTypes/sysTypes/sysTypes.d.ts +0 -29
- package/types/api/clients/wtTypes/typeExtensions/typeExtensions.d.ts +0 -33
- package/types/api/clients//321/201ontacts/contactChatMessagesHistory.d.ts +0 -16
- package/types/api/clients//321/201ontacts/contacts.d.ts +0 -29
- package/types/api/clients//321/201ontacts/enums/ContactsSearchMode.d.ts +0 -8
- package/types/api/clients//321/201ontacts/index.d.ts +0 -4
|
@@ -1,282 +0,0 @@
|
|
|
1
|
-
import axiosMock from '../../../../tests/mocks/axiosMock.js';
|
|
2
|
-
|
|
3
|
-
const instanceMock = axiosMock()().default;
|
|
4
|
-
|
|
5
|
-
vi.doMock('../../../defaults/getDefaultInstance/getDefaultInstance.js', () => ({
|
|
6
|
-
default: () => instanceMock,
|
|
7
|
-
}));
|
|
8
|
-
|
|
9
|
-
describe('UsersAPI', () => {
|
|
10
|
-
beforeEach(() => {
|
|
11
|
-
Object.assign(instanceMock, axiosMock()().default);
|
|
12
|
-
});
|
|
13
|
-
|
|
14
|
-
it('correctly computes "getList" method api call', async () => {
|
|
15
|
-
const get = vi.fn(() =>
|
|
16
|
-
Promise.resolve({
|
|
17
|
-
data: {},
|
|
18
|
-
}),
|
|
19
|
-
);
|
|
20
|
-
|
|
21
|
-
instanceMock.get = get;
|
|
22
|
-
|
|
23
|
-
const UsersAPI = (await import('../users.js')).default;
|
|
24
|
-
|
|
25
|
-
const inputParams = {
|
|
26
|
-
fields: [
|
|
27
|
-
'id',
|
|
28
|
-
'name',
|
|
29
|
-
'vitest',
|
|
30
|
-
],
|
|
31
|
-
};
|
|
32
|
-
const url = '/users?page=1&size=10&fields=id&fields=name&fields=vitest';
|
|
33
|
-
await UsersAPI.getList(inputParams);
|
|
34
|
-
expect(get).toHaveBeenCalledWith(url);
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
it('correctly computes "getList" method output', async () => {
|
|
38
|
-
const output = {
|
|
39
|
-
items: [
|
|
40
|
-
{
|
|
41
|
-
dnd: false,
|
|
42
|
-
id: 1,
|
|
43
|
-
name: '',
|
|
44
|
-
state: true,
|
|
45
|
-
status: '',
|
|
46
|
-
shouldCaseConvert: '',
|
|
47
|
-
},
|
|
48
|
-
],
|
|
49
|
-
next: true,
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
const response = {
|
|
53
|
-
data: {
|
|
54
|
-
items: [
|
|
55
|
-
{
|
|
56
|
-
id: 1,
|
|
57
|
-
should_case_convert: '',
|
|
58
|
-
},
|
|
59
|
-
],
|
|
60
|
-
next: true,
|
|
61
|
-
},
|
|
62
|
-
};
|
|
63
|
-
|
|
64
|
-
const get = vi.fn(() => Promise.resolve(response));
|
|
65
|
-
|
|
66
|
-
instanceMock.get = get;
|
|
67
|
-
|
|
68
|
-
const UsersAPI = (await import('../users.js')).default;
|
|
69
|
-
|
|
70
|
-
expect(await UsersAPI.getList({})).toEqual(output);
|
|
71
|
-
});
|
|
72
|
-
|
|
73
|
-
it('correctly computes "get" method api call', async () => {
|
|
74
|
-
const inputParams = {
|
|
75
|
-
itemId: 1,
|
|
76
|
-
};
|
|
77
|
-
const url = '/users/1';
|
|
78
|
-
|
|
79
|
-
const get = vi.fn(() =>
|
|
80
|
-
Promise.resolve({
|
|
81
|
-
data: {},
|
|
82
|
-
}),
|
|
83
|
-
);
|
|
84
|
-
|
|
85
|
-
instanceMock.get = get;
|
|
86
|
-
|
|
87
|
-
const UsersAPI = (await import('../users.js')).default;
|
|
88
|
-
|
|
89
|
-
await UsersAPI.get(inputParams);
|
|
90
|
-
expect(get).toHaveBeenCalledWith(url);
|
|
91
|
-
});
|
|
92
|
-
|
|
93
|
-
it('correctly computes "get" method output', async () => {
|
|
94
|
-
const output = {
|
|
95
|
-
id: 1,
|
|
96
|
-
device: {},
|
|
97
|
-
devices: [],
|
|
98
|
-
generateDevice: false,
|
|
99
|
-
license: [],
|
|
100
|
-
roles: [],
|
|
101
|
-
variables: [
|
|
102
|
-
{
|
|
103
|
-
key: '',
|
|
104
|
-
value: '',
|
|
105
|
-
},
|
|
106
|
-
],
|
|
107
|
-
};
|
|
108
|
-
|
|
109
|
-
const response = {
|
|
110
|
-
data: {
|
|
111
|
-
id: 1,
|
|
112
|
-
},
|
|
113
|
-
};
|
|
114
|
-
|
|
115
|
-
const get = vi.fn(() => Promise.resolve(response));
|
|
116
|
-
|
|
117
|
-
instanceMock.get = get;
|
|
118
|
-
|
|
119
|
-
const UsersAPI = (await import('../users.js')).default;
|
|
120
|
-
|
|
121
|
-
expect(await UsersAPI.get({})).toEqual(output);
|
|
122
|
-
});
|
|
123
|
-
|
|
124
|
-
it('correctly computes "add" method api call', async () => {
|
|
125
|
-
const input = {
|
|
126
|
-
itemInstance: {
|
|
127
|
-
name: 'test',
|
|
128
|
-
},
|
|
129
|
-
};
|
|
130
|
-
|
|
131
|
-
const body = {
|
|
132
|
-
name: 'test',
|
|
133
|
-
profile: {}, // variables field (?)
|
|
134
|
-
};
|
|
135
|
-
|
|
136
|
-
const url = '/users';
|
|
137
|
-
|
|
138
|
-
const post = vi.fn(() =>
|
|
139
|
-
Promise.resolve({
|
|
140
|
-
data: {},
|
|
141
|
-
}),
|
|
142
|
-
);
|
|
143
|
-
|
|
144
|
-
instanceMock.post = post;
|
|
145
|
-
|
|
146
|
-
const UsersAPI = (await import('../users.js')).default;
|
|
147
|
-
|
|
148
|
-
await UsersAPI.add(input);
|
|
149
|
-
expect(post).toHaveBeenCalledWith(url, body);
|
|
150
|
-
});
|
|
151
|
-
|
|
152
|
-
it('correctly computes "add" method output', async () => {
|
|
153
|
-
const output = {
|
|
154
|
-
id: 1,
|
|
155
|
-
checkCase: '',
|
|
156
|
-
};
|
|
157
|
-
|
|
158
|
-
const response = {
|
|
159
|
-
data: {
|
|
160
|
-
id: 1,
|
|
161
|
-
check_case: '',
|
|
162
|
-
},
|
|
163
|
-
};
|
|
164
|
-
|
|
165
|
-
const post = vi.fn(() => Promise.resolve(response));
|
|
166
|
-
|
|
167
|
-
instanceMock.post = post;
|
|
168
|
-
|
|
169
|
-
const UsersAPI = (await import('../users.js')).default;
|
|
170
|
-
|
|
171
|
-
expect(
|
|
172
|
-
await UsersAPI.add({
|
|
173
|
-
itemInstance: {},
|
|
174
|
-
}),
|
|
175
|
-
).toEqual(output);
|
|
176
|
-
});
|
|
177
|
-
|
|
178
|
-
it('correctly computes "update" method api call', async () => {
|
|
179
|
-
const input = {
|
|
180
|
-
itemInstance: {
|
|
181
|
-
name: 'test',
|
|
182
|
-
},
|
|
183
|
-
itemId: 1,
|
|
184
|
-
};
|
|
185
|
-
|
|
186
|
-
const body = {
|
|
187
|
-
name: 'test',
|
|
188
|
-
profile: {}, // variables field (?)
|
|
189
|
-
};
|
|
190
|
-
|
|
191
|
-
const url = '/users/1';
|
|
192
|
-
|
|
193
|
-
const put = vi.fn(() =>
|
|
194
|
-
Promise.resolve({
|
|
195
|
-
data: {},
|
|
196
|
-
}),
|
|
197
|
-
);
|
|
198
|
-
|
|
199
|
-
instanceMock.put = put;
|
|
200
|
-
|
|
201
|
-
const UsersAPI = (await import('../users.js')).default;
|
|
202
|
-
|
|
203
|
-
await UsersAPI.update(input);
|
|
204
|
-
expect(put).toHaveBeenCalledWith(url, body);
|
|
205
|
-
});
|
|
206
|
-
|
|
207
|
-
it('correctly computes "update" method output', async () => {
|
|
208
|
-
const output = {
|
|
209
|
-
id: 1,
|
|
210
|
-
checkCase: '',
|
|
211
|
-
};
|
|
212
|
-
|
|
213
|
-
const response = {
|
|
214
|
-
data: {
|
|
215
|
-
id: 1,
|
|
216
|
-
check_case: '',
|
|
217
|
-
},
|
|
218
|
-
};
|
|
219
|
-
|
|
220
|
-
const put = vi.fn(() => Promise.resolve(response));
|
|
221
|
-
|
|
222
|
-
instanceMock.put = put;
|
|
223
|
-
|
|
224
|
-
const UsersAPI = (await import('../users.js')).default;
|
|
225
|
-
|
|
226
|
-
expect(
|
|
227
|
-
await UsersAPI.update({
|
|
228
|
-
itemInstance: {},
|
|
229
|
-
itemId: 1,
|
|
230
|
-
}),
|
|
231
|
-
).toEqual(output);
|
|
232
|
-
});
|
|
233
|
-
|
|
234
|
-
it('correctly computes "patch" method api call', async () => {
|
|
235
|
-
const input = {
|
|
236
|
-
changes: {
|
|
237
|
-
name: 'test',
|
|
238
|
-
},
|
|
239
|
-
id: 1,
|
|
240
|
-
};
|
|
241
|
-
|
|
242
|
-
const body = {
|
|
243
|
-
name: 'test',
|
|
244
|
-
};
|
|
245
|
-
|
|
246
|
-
const url = '/users/1';
|
|
247
|
-
|
|
248
|
-
const patch = vi.fn(() =>
|
|
249
|
-
Promise.resolve({
|
|
250
|
-
data: {},
|
|
251
|
-
}),
|
|
252
|
-
);
|
|
253
|
-
|
|
254
|
-
instanceMock.patch = patch;
|
|
255
|
-
|
|
256
|
-
const UsersAPI = (await import('../users.js')).default;
|
|
257
|
-
|
|
258
|
-
await UsersAPI.patch(input);
|
|
259
|
-
expect(patch).toHaveBeenCalledWith(url, body);
|
|
260
|
-
});
|
|
261
|
-
|
|
262
|
-
it('correctly computes "delete" method api call', async () => {
|
|
263
|
-
const input = {
|
|
264
|
-
id: 1,
|
|
265
|
-
};
|
|
266
|
-
|
|
267
|
-
const url = '/users/1?permanent=true';
|
|
268
|
-
|
|
269
|
-
const _delete = vi.fn(() =>
|
|
270
|
-
Promise.resolve({
|
|
271
|
-
data: {},
|
|
272
|
-
}),
|
|
273
|
-
);
|
|
274
|
-
|
|
275
|
-
instanceMock.delete = _delete;
|
|
276
|
-
|
|
277
|
-
const UsersAPI = (await import('../users.js')).default;
|
|
278
|
-
|
|
279
|
-
await UsersAPI.delete(input);
|
|
280
|
-
expect(_delete).toHaveBeenCalledWith(url);
|
|
281
|
-
});
|
|
282
|
-
});
|
|
@@ -1,334 +0,0 @@
|
|
|
1
|
-
import deepCopy from 'deep-copy';
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
getDefaultGetListResponse,
|
|
5
|
-
getDefaultGetParams,
|
|
6
|
-
getDefaultInstance,
|
|
7
|
-
} from '../../defaults/index.js';
|
|
8
|
-
import applyTransform, {
|
|
9
|
-
addQueryParamsToUrl,
|
|
10
|
-
camelToSnake,
|
|
11
|
-
generateUrl,
|
|
12
|
-
merge,
|
|
13
|
-
mergeEach,
|
|
14
|
-
notify,
|
|
15
|
-
sanitize,
|
|
16
|
-
snakeToCamel,
|
|
17
|
-
} from '../../transformers/index.js';
|
|
18
|
-
import { generatePermissionsApi } from '../_shared/generatePermissionsApi.js';
|
|
19
|
-
|
|
20
|
-
const instance = getDefaultInstance();
|
|
21
|
-
|
|
22
|
-
const baseUrl = '/users';
|
|
23
|
-
const fieldsToSend = [
|
|
24
|
-
'name',
|
|
25
|
-
'username',
|
|
26
|
-
'password',
|
|
27
|
-
'extension',
|
|
28
|
-
'status',
|
|
29
|
-
'note',
|
|
30
|
-
'roles',
|
|
31
|
-
'license',
|
|
32
|
-
'devices',
|
|
33
|
-
'device',
|
|
34
|
-
'profile',
|
|
35
|
-
'email',
|
|
36
|
-
'contact',
|
|
37
|
-
'chatName',
|
|
38
|
-
'forcePasswordChange',
|
|
39
|
-
];
|
|
40
|
-
|
|
41
|
-
const getUsersList = async (params) => {
|
|
42
|
-
const fieldsToSend = [
|
|
43
|
-
'page',
|
|
44
|
-
'size',
|
|
45
|
-
'q',
|
|
46
|
-
'sort',
|
|
47
|
-
'fields',
|
|
48
|
-
'id',
|
|
49
|
-
];
|
|
50
|
-
|
|
51
|
-
const defaultObject = {
|
|
52
|
-
name: '',
|
|
53
|
-
status: '',
|
|
54
|
-
state: true,
|
|
55
|
-
dnd: false,
|
|
56
|
-
};
|
|
57
|
-
|
|
58
|
-
const url = applyTransform(params, [
|
|
59
|
-
merge(getDefaultGetParams()),
|
|
60
|
-
(params) => ({
|
|
61
|
-
...params,
|
|
62
|
-
q: params.search,
|
|
63
|
-
}),
|
|
64
|
-
sanitize(fieldsToSend),
|
|
65
|
-
camelToSnake(),
|
|
66
|
-
generateUrl(baseUrl),
|
|
67
|
-
]);
|
|
68
|
-
try {
|
|
69
|
-
const response = await instance.get(url);
|
|
70
|
-
const { items, next } = applyTransform(response.data, [
|
|
71
|
-
snakeToCamel([
|
|
72
|
-
'profile',
|
|
73
|
-
]),
|
|
74
|
-
merge(getDefaultGetListResponse()),
|
|
75
|
-
]);
|
|
76
|
-
return {
|
|
77
|
-
items: applyTransform(items, [
|
|
78
|
-
mergeEach(defaultObject),
|
|
79
|
-
]),
|
|
80
|
-
next,
|
|
81
|
-
};
|
|
82
|
-
} catch (err) {
|
|
83
|
-
throw applyTransform(err, [
|
|
84
|
-
notify,
|
|
85
|
-
]);
|
|
86
|
-
}
|
|
87
|
-
};
|
|
88
|
-
|
|
89
|
-
const getUser = async ({ itemId: id }) => {
|
|
90
|
-
const defaultObject = {
|
|
91
|
-
roles: [],
|
|
92
|
-
license: [],
|
|
93
|
-
devices: [],
|
|
94
|
-
device: {},
|
|
95
|
-
generateDevice: false,
|
|
96
|
-
variables: [
|
|
97
|
-
{
|
|
98
|
-
key: '',
|
|
99
|
-
value: '',
|
|
100
|
-
},
|
|
101
|
-
],
|
|
102
|
-
};
|
|
103
|
-
|
|
104
|
-
const itemResponseHandler = (item) => {
|
|
105
|
-
const copy = deepCopy(item);
|
|
106
|
-
if (copy.license) {
|
|
107
|
-
copy.license.forEach((item) => {
|
|
108
|
-
item.name = item.name || item.prod;
|
|
109
|
-
});
|
|
110
|
-
}
|
|
111
|
-
if (copy.profile) {
|
|
112
|
-
copy.variables = Object.keys(copy.profile).map((key) => ({
|
|
113
|
-
key,
|
|
114
|
-
value: copy.profile[key],
|
|
115
|
-
}));
|
|
116
|
-
} else {
|
|
117
|
-
copy.variables = [
|
|
118
|
-
{
|
|
119
|
-
key: '',
|
|
120
|
-
value: '',
|
|
121
|
-
},
|
|
122
|
-
];
|
|
123
|
-
}
|
|
124
|
-
return copy;
|
|
125
|
-
};
|
|
126
|
-
|
|
127
|
-
const url = `${baseUrl}/${id}`;
|
|
128
|
-
|
|
129
|
-
try {
|
|
130
|
-
const response = await instance.get(url);
|
|
131
|
-
return applyTransform(response.data, [
|
|
132
|
-
snakeToCamel([
|
|
133
|
-
'profile',
|
|
134
|
-
]),
|
|
135
|
-
merge(defaultObject),
|
|
136
|
-
itemResponseHandler,
|
|
137
|
-
]);
|
|
138
|
-
} catch (err) {
|
|
139
|
-
throw applyTransform(err, [
|
|
140
|
-
notify,
|
|
141
|
-
]);
|
|
142
|
-
}
|
|
143
|
-
};
|
|
144
|
-
|
|
145
|
-
const preRequestHandler = (item) => {
|
|
146
|
-
const copy = deepCopy(item);
|
|
147
|
-
if (item.device && !item.device.id) delete copy.device;
|
|
148
|
-
|
|
149
|
-
if (copy.roles) {
|
|
150
|
-
copy.roles.forEach((role) => {
|
|
151
|
-
delete role.text;
|
|
152
|
-
});
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
if (copy.devices) {
|
|
156
|
-
copy.devices.forEach((device) => {
|
|
157
|
-
delete device.text;
|
|
158
|
-
});
|
|
159
|
-
}
|
|
160
|
-
if (copy.license) {
|
|
161
|
-
copy.license = copy.license.map((copy) => ({
|
|
162
|
-
id: copy.id,
|
|
163
|
-
}));
|
|
164
|
-
}
|
|
165
|
-
copy.profile = {};
|
|
166
|
-
if (copy.variables) {
|
|
167
|
-
copy.variables.forEach((variable) => {
|
|
168
|
-
copy.profile[variable.key] = variable.value;
|
|
169
|
-
});
|
|
170
|
-
}
|
|
171
|
-
return copy;
|
|
172
|
-
};
|
|
173
|
-
|
|
174
|
-
const addUser = async ({ itemInstance }) => {
|
|
175
|
-
const item = applyTransform(itemInstance, [
|
|
176
|
-
preRequestHandler,
|
|
177
|
-
sanitize(fieldsToSend),
|
|
178
|
-
camelToSnake([
|
|
179
|
-
'profile',
|
|
180
|
-
]),
|
|
181
|
-
]);
|
|
182
|
-
// WTEL-9735 Підзадача 0: за прапорцем itemInstance.generateDevice додаємо
|
|
183
|
-
// query ?generate_device=true. Прапорець не входить у fieldsToSend, тож у
|
|
184
|
-
// тіло не потрапляє — лише в query. Без прапорця URL не змінюється.
|
|
185
|
-
const url = applyTransform(baseUrl, [
|
|
186
|
-
addQueryParamsToUrl(
|
|
187
|
-
itemInstance.generateDevice
|
|
188
|
-
? [
|
|
189
|
-
'generate_device=true',
|
|
190
|
-
]
|
|
191
|
-
: [],
|
|
192
|
-
),
|
|
193
|
-
]);
|
|
194
|
-
try {
|
|
195
|
-
const response = await instance.post(url, item);
|
|
196
|
-
return applyTransform(response.data, [
|
|
197
|
-
snakeToCamel([
|
|
198
|
-
'profile',
|
|
199
|
-
]),
|
|
200
|
-
]);
|
|
201
|
-
} catch (err) {
|
|
202
|
-
throw applyTransform(err, [
|
|
203
|
-
notify,
|
|
204
|
-
]);
|
|
205
|
-
}
|
|
206
|
-
};
|
|
207
|
-
|
|
208
|
-
const updateUser = async ({ itemInstance, itemId: id }) => {
|
|
209
|
-
const item = applyTransform(itemInstance, [
|
|
210
|
-
preRequestHandler,
|
|
211
|
-
sanitize(fieldsToSend),
|
|
212
|
-
camelToSnake([
|
|
213
|
-
'profile',
|
|
214
|
-
]),
|
|
215
|
-
]);
|
|
216
|
-
|
|
217
|
-
// WTEL-9735 Підзадача 0: генерація пристрою і на edit (PUT) — той самий
|
|
218
|
-
// прапорець itemInstance.generateDevice; query додається лише коли він true
|
|
219
|
-
const url = applyTransform(`${baseUrl}/${id}`, [
|
|
220
|
-
addQueryParamsToUrl(
|
|
221
|
-
itemInstance.generateDevice
|
|
222
|
-
? [
|
|
223
|
-
'generate_device=true',
|
|
224
|
-
]
|
|
225
|
-
: [],
|
|
226
|
-
),
|
|
227
|
-
]);
|
|
228
|
-
try {
|
|
229
|
-
const response = await instance.put(url, item);
|
|
230
|
-
return applyTransform(response.data, [
|
|
231
|
-
snakeToCamel([
|
|
232
|
-
'profile',
|
|
233
|
-
]),
|
|
234
|
-
]);
|
|
235
|
-
} catch (err) {
|
|
236
|
-
throw applyTransform(err, [
|
|
237
|
-
notify,
|
|
238
|
-
]);
|
|
239
|
-
}
|
|
240
|
-
};
|
|
241
|
-
|
|
242
|
-
const patchUser = async ({ changes, id }) => {
|
|
243
|
-
const body = applyTransform(changes, [
|
|
244
|
-
sanitize(fieldsToSend),
|
|
245
|
-
camelToSnake([
|
|
246
|
-
'profile',
|
|
247
|
-
]),
|
|
248
|
-
]);
|
|
249
|
-
const url = `${baseUrl}/${id}`;
|
|
250
|
-
try {
|
|
251
|
-
const response = await instance.patch(url, body);
|
|
252
|
-
return applyTransform(response.data, [
|
|
253
|
-
snakeToCamel([
|
|
254
|
-
'profile',
|
|
255
|
-
]),
|
|
256
|
-
]);
|
|
257
|
-
} catch (err) {
|
|
258
|
-
throw applyTransform(err, [
|
|
259
|
-
notify,
|
|
260
|
-
]);
|
|
261
|
-
}
|
|
262
|
-
};
|
|
263
|
-
|
|
264
|
-
const patchUserPresence = async ({ changes, id }) => {
|
|
265
|
-
const body = applyTransform(changes, [
|
|
266
|
-
sanitize(fieldsToSend),
|
|
267
|
-
camelToSnake([
|
|
268
|
-
'profile',
|
|
269
|
-
]),
|
|
270
|
-
]);
|
|
271
|
-
const url = `${baseUrl}/${id}/presence`;
|
|
272
|
-
try {
|
|
273
|
-
const response = await instance.patch(url, body);
|
|
274
|
-
return applyTransform(response.data, [
|
|
275
|
-
snakeToCamel([
|
|
276
|
-
'profile',
|
|
277
|
-
]),
|
|
278
|
-
]);
|
|
279
|
-
} catch (err) {
|
|
280
|
-
throw applyTransform(err, [
|
|
281
|
-
notify,
|
|
282
|
-
]);
|
|
283
|
-
}
|
|
284
|
-
};
|
|
285
|
-
|
|
286
|
-
const deleteUser = async ({ id }) => {
|
|
287
|
-
const url = `${baseUrl}/${id}?permanent=true`;
|
|
288
|
-
// permanent=true for complete deletion
|
|
289
|
-
try {
|
|
290
|
-
const response = await instance.delete(url);
|
|
291
|
-
return applyTransform(response.data, []);
|
|
292
|
-
} catch (err) {
|
|
293
|
-
throw applyTransform(err, [
|
|
294
|
-
notify,
|
|
295
|
-
]);
|
|
296
|
-
}
|
|
297
|
-
};
|
|
298
|
-
|
|
299
|
-
const getUsersLookup = (params) =>
|
|
300
|
-
getUsersList({
|
|
301
|
-
...params,
|
|
302
|
-
fields: params.fields || [
|
|
303
|
-
'id',
|
|
304
|
-
'name',
|
|
305
|
-
],
|
|
306
|
-
});
|
|
307
|
-
|
|
308
|
-
const logoutUser = async ({ id }) => {
|
|
309
|
-
const url = `${baseUrl}/${id}/logout`;
|
|
310
|
-
try {
|
|
311
|
-
const response = await instance.post(url, {});
|
|
312
|
-
return applyTransform(response.data, []);
|
|
313
|
-
} catch (err) {
|
|
314
|
-
throw applyTransform(err, [
|
|
315
|
-
notify,
|
|
316
|
-
]);
|
|
317
|
-
}
|
|
318
|
-
};
|
|
319
|
-
|
|
320
|
-
const UsersAPI = {
|
|
321
|
-
getList: getUsersList,
|
|
322
|
-
get: getUser,
|
|
323
|
-
add: addUser,
|
|
324
|
-
patch: patchUser,
|
|
325
|
-
update: updateUser,
|
|
326
|
-
delete: deleteUser,
|
|
327
|
-
getLookup: getUsersLookup,
|
|
328
|
-
patchUserPresence,
|
|
329
|
-
logoutUser,
|
|
330
|
-
|
|
331
|
-
...generatePermissionsApi(baseUrl),
|
|
332
|
-
};
|
|
333
|
-
|
|
334
|
-
export default UsersAPI;
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import deepCopy from 'deep-copy';
|
|
2
|
-
import type {
|
|
3
|
-
WebitelProtoDataField,
|
|
4
|
-
WebitelProtoDataStruct,
|
|
5
|
-
} from 'webitel-sdk';
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* TODO(types): `position` is returned by the API to order dynamic fields but is
|
|
9
|
-
* absent from the generated `WebitelProtoDataField` type. Extend locally until
|
|
10
|
-
* the generated SDK type includes it.
|
|
11
|
-
*/
|
|
12
|
-
type PositionedDataField = WebitelProtoDataField & {
|
|
13
|
-
position?: number;
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
export const sortDynamicFields = (
|
|
17
|
-
item: WebitelProtoDataStruct,
|
|
18
|
-
): WebitelProtoDataStruct => {
|
|
19
|
-
const sourceFields = (item.fields ?? []) as PositionedDataField[];
|
|
20
|
-
|
|
21
|
-
const unSortableFields = sourceFields.filter((field) => !field.position);
|
|
22
|
-
|
|
23
|
-
const sortableFields = deepCopy(sourceFields)
|
|
24
|
-
.filter((field) => field.position)
|
|
25
|
-
.sort((a, b) => {
|
|
26
|
-
return (a.position ?? 0) - (b.position ?? 0);
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
const fields = [
|
|
30
|
-
...unSortableFields,
|
|
31
|
-
...sortableFields,
|
|
32
|
-
];
|
|
33
|
-
|
|
34
|
-
return {
|
|
35
|
-
...item,
|
|
36
|
-
fields,
|
|
37
|
-
};
|
|
38
|
-
};
|