@webitel/ui-sdk 26.8.68 → 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.
Files changed (116) hide show
  1. package/dist/clients-D5pO5FKV.js +39334 -0
  2. package/dist/{components-BoODKBgN.js → components-BH_gLkO3.js} +3 -3
  3. package/dist/{genClient-C_5VsLM9.js → genClient-DtYJ9KWy.js} +1 -1
  4. package/dist/ui-sdk.js +2 -2
  5. package/dist/ui-sdk.umd.cjs +657 -732
  6. package/dist/{wt-chat-emoji-DMSSNCSp.js → wt-chat-emoji-B-FoXVDr.js} +1 -1
  7. package/dist/{wt-display-chip-items-BaL81KbX.js → wt-display-chip-items-CZzcHtcb.js} +1 -1
  8. package/dist/{wt-send-message-popup-Cz3tLMAW.js → wt-send-message-popup-Cc92sY9q.js} +2 -2
  9. package/dist/wt-tree-CfvNlw7N.js +2042 -0
  10. package/dist/{wt-type-extension-value-input-D7eK5MwZ.js → wt-type-extension-value-input-DfbrgPNa.js} +2 -2
  11. package/dist/{wt-vidstack-player-CPk5Y-1M.js → wt-vidstack-player-DtbNeGgs.js} +1 -1
  12. package/package.json +1 -1
  13. package/src/api/clients/index.js +5 -66
  14. package/src/modules/AgentStatusSelect/api/agent-status.ts +44 -0
  15. package/src/modules/AgentStatusSelect/api/pause-cause.ts +54 -0
  16. package/src/modules/AgentStatusSelect/components/__tests__/wt-cc-agent-status-select.spec.js +4 -10
  17. package/src/modules/AgentStatusSelect/components/wt-cc-agent-status-select.vue +2 -6
  18. package/types/.tsbuildinfo +1 -1
  19. package/types/api/clients/index.d.ts +1 -33
  20. package/types/modules/AgentStatusSelect/api/agent-status.d.ts +4 -12
  21. package/types/modules/AgentStatusSelect/api/pause-cause.d.ts +7 -9
  22. package/dist/clients-CjmnMcur.js +0 -40042
  23. package/dist/side-channel-M3LABDql.js +0 -833
  24. package/dist/wt-tree-DKSphRxr.js +0 -1216
  25. package/src/api/clients/agents/agentChats.js +0 -79
  26. package/src/api/clients/agents/agents.js +0 -300
  27. package/src/api/clients/buckets/buckets.js +0 -134
  28. package/src/api/clients/calendars/calendars.js +0 -239
  29. package/src/api/clients/caseCloseReasonGroups/caseCloseReasonGroups.js +0 -161
  30. package/src/api/clients/caseCloseReasons/caseCloseReasons.js +0 -165
  31. package/src/api/clients/casePriorities/casePriorities.js +0 -166
  32. package/src/api/clients/caseServiceCatalogs/serviceCatalogs.js +0 -231
  33. package/src/api/clients/caseServices/services.js +0 -221
  34. package/src/api/clients/caseSources/caseSources.ts +0 -2
  35. package/src/api/clients/caseStatusConditions/caseStatusConditions.js +0 -207
  36. package/src/api/clients/caseStatuses/caseStatuses.js +0 -152
  37. package/src/api/clients/catalog/catalog.js +0 -63
  38. package/src/api/clients/chatGateways/chatGateways.js +0 -338
  39. package/src/api/clients/chatGateways/defaults/defaultChatGateway.js +0 -18
  40. package/src/api/clients/chatGateways/defaults/webChatGateway.js +0 -72
  41. package/src/api/clients/chatGateways/enums/WebchatAlternativeChannel.enum.js +0 -14
  42. package/src/api/clients/chatGateways/scripts/generateUri.js +0 -9
  43. package/src/api/clients/communications/communications.js +0 -172
  44. package/src/api/clients/configurations/configurations.js +0 -168
  45. package/src/api/clients/contactGroups/contactGroups.js +0 -221
  46. package/src/api/clients/flows/flow.js +0 -252
  47. package/src/api/clients/gateways/defaults/defaultGateway.js +0 -9
  48. package/src/api/clients/gateways/defaults/registerGateway.js +0 -12
  49. package/src/api/clients/gateways/defaults/trunkingGateway.js +0 -16
  50. package/src/api/clients/gateways/gateways.js +0 -221
  51. package/src/api/clients/labels/labels.js +0 -69
  52. package/src/api/clients/lists/blacklists.js +0 -142
  53. package/src/api/clients/media/media.js +0 -136
  54. package/src/api/clients/object/object.js +0 -138
  55. package/src/api/clients/queues/queues.js +0 -263
  56. package/src/api/clients/quickReplies/quickReplies.ts +0 -2
  57. package/src/api/clients/skills/skills.js +0 -134
  58. package/src/api/clients/slaConditions/slaConditions.js +0 -190
  59. package/src/api/clients/slas/slas.js +0 -148
  60. package/src/api/clients/teams/teams.js +0 -161
  61. package/src/api/clients/users/__tests__/users.spec.js +0 -282
  62. package/src/api/clients/users/users.js +0 -334
  63. package/src/api/clients/wtTypes/_shared/utils/sortDynamicFields.ts +0 -38
  64. package/src/api/clients/wtTypes/sysTypes/sysTypes.ts +0 -92
  65. package/src/api/clients/wtTypes/typeExtensions/typeExtensions.ts +0 -156
  66. package/src/api/clients//321/201ontacts/contactChatMessagesHistory.js +0 -119
  67. package/src/api/clients//321/201ontacts/contacts.js +0 -449
  68. package/src/api/clients//321/201ontacts/enums/ContactsSearchMode.js +0 -9
  69. package/src/api/clients//321/201ontacts/index.js +0 -5
  70. package/src/modules/AgentStatusSelect/api/agent-status.js +0 -30
  71. package/src/modules/AgentStatusSelect/api/pause-cause.js +0 -49
  72. package/types/api/clients/agents/agentChats.d.ts +0 -10
  73. package/types/api/clients/agents/agents.d.ts +0 -55
  74. package/types/api/clients/buckets/buckets.d.ts +0 -30
  75. package/types/api/clients/calendars/calendars.d.ts +0 -35
  76. package/types/api/clients/caseCloseReasonGroups/caseCloseReasonGroups.d.ts +0 -30
  77. package/types/api/clients/caseCloseReasons/caseCloseReasons.d.ts +0 -36
  78. package/types/api/clients/casePriorities/casePriorities.d.ts +0 -30
  79. package/types/api/clients/caseServiceCatalogs/serviceCatalogs.d.ts +0 -30
  80. package/types/api/clients/caseServices/services.d.ts +0 -42
  81. package/types/api/clients/caseSources/caseSources.d.ts +0 -1
  82. package/types/api/clients/caseStatusConditions/caseStatusConditions.d.ts +0 -43
  83. package/types/api/clients/caseStatuses/caseStatuses.d.ts +0 -30
  84. package/types/api/clients/catalog/catalog.d.ts +0 -13
  85. package/types/api/clients/chatGateways/chatGateways.d.ts +0 -35
  86. package/types/api/clients/chatGateways/defaults/defaultChatGateway.d.ts +0 -15
  87. package/types/api/clients/chatGateways/defaults/webChatGateway.d.ts +0 -64
  88. package/types/api/clients/chatGateways/enums/WebchatAlternativeChannel.enum.d.ts +0 -8
  89. package/types/api/clients/chatGateways/scripts/generateUri.d.ts +0 -2
  90. package/types/api/clients/communications/communications.d.ts +0 -35
  91. package/types/api/clients/configurations/configurations.d.ts +0 -35
  92. package/types/api/clients/contactGroups/contactGroups.d.ts +0 -47
  93. package/types/api/clients/flows/flow.d.ts +0 -35
  94. package/types/api/clients/gateways/defaults/defaultGateway.d.ts +0 -8
  95. package/types/api/clients/gateways/defaults/registerGateway.d.ts +0 -13
  96. package/types/api/clients/gateways/defaults/trunkingGateway.d.ts +0 -11
  97. package/types/api/clients/gateways/gateways.d.ts +0 -35
  98. package/types/api/clients/labels/labels.d.ts +0 -13
  99. package/types/api/clients/lists/blacklists.d.ts +0 -30
  100. package/types/api/clients/media/media.d.ts +0 -24
  101. package/types/api/clients/object/object.d.ts +0 -13
  102. package/types/api/clients/queues/queues.d.ts +0 -40
  103. package/types/api/clients/quickReplies/quickReplies.d.ts +0 -1
  104. package/types/api/clients/skills/skills.d.ts +0 -30
  105. package/types/api/clients/slaConditions/slaConditions.d.ts +0 -36
  106. package/types/api/clients/slas/slas.d.ts +0 -30
  107. package/types/api/clients/teams/teams.d.ts +0 -30
  108. package/types/api/clients/users/__tests__/users.spec.d.ts +0 -1
  109. package/types/api/clients/users/users.d.ts +0 -46
  110. package/types/api/clients/wtTypes/_shared/utils/sortDynamicFields.d.ts +0 -2
  111. package/types/api/clients/wtTypes/sysTypes/sysTypes.d.ts +0 -29
  112. package/types/api/clients/wtTypes/typeExtensions/typeExtensions.d.ts +0 -33
  113. package/types/api/clients//321/201ontacts/contactChatMessagesHistory.d.ts +0 -16
  114. package/types/api/clients//321/201ontacts/contacts.d.ts +0 -29
  115. package/types/api/clients//321/201ontacts/enums/ContactsSearchMode.d.ts +0 -8
  116. 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
- };