@webitel/api-services 26.8.81 → 26.8.82
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
CHANGED
|
@@ -4,6 +4,8 @@ const searchMemberInQueue = vi.fn();
|
|
|
4
4
|
const resetMembersCount = vi.fn();
|
|
5
5
|
const resetMembers = vi.fn();
|
|
6
6
|
const searchMemberCommunication = vi.fn();
|
|
7
|
+
const createMember = vi.fn();
|
|
8
|
+
const updateMember = vi.fn();
|
|
7
9
|
|
|
8
10
|
vi.mock('../../../../gen-wire', () => ({
|
|
9
11
|
getMemberService: () => ({
|
|
@@ -11,6 +13,8 @@ vi.mock('../../../../gen-wire', () => ({
|
|
|
11
13
|
resetMembersCount,
|
|
12
14
|
resetMembers,
|
|
13
15
|
searchMemberCommunication,
|
|
16
|
+
createMember,
|
|
17
|
+
updateMember,
|
|
14
18
|
}),
|
|
15
19
|
}));
|
|
16
20
|
|
|
@@ -240,3 +244,62 @@ describe('QueueMembersAPI.getCommunications', () => {
|
|
|
240
244
|
});
|
|
241
245
|
});
|
|
242
246
|
});
|
|
247
|
+
|
|
248
|
+
/**
|
|
249
|
+
* [Claude] The card store keeps the add/update response as the new item, so it
|
|
250
|
+
* has to come back in the same shape `get` returns — variables as pairs.
|
|
251
|
+
* [WTEL-10587](https://webitel.atlassian.net/browse/WTEL-10587)
|
|
252
|
+
*/
|
|
253
|
+
describe('QueueMembersAPI add/update response', () => {
|
|
254
|
+
const wireMember = {
|
|
255
|
+
id: '5',
|
|
256
|
+
variables: {
|
|
257
|
+
someKey: 'value',
|
|
258
|
+
},
|
|
259
|
+
};
|
|
260
|
+
|
|
261
|
+
beforeEach(() => {
|
|
262
|
+
createMember.mockReset().mockResolvedValue({
|
|
263
|
+
data: wireMember,
|
|
264
|
+
});
|
|
265
|
+
updateMember.mockReset().mockResolvedValue({
|
|
266
|
+
data: wireMember,
|
|
267
|
+
});
|
|
268
|
+
});
|
|
269
|
+
|
|
270
|
+
const itemInstance = {
|
|
271
|
+
variables: [
|
|
272
|
+
{
|
|
273
|
+
key: 'someKey',
|
|
274
|
+
value: 'value',
|
|
275
|
+
},
|
|
276
|
+
],
|
|
277
|
+
};
|
|
278
|
+
|
|
279
|
+
it('add returns variables as key/value pairs', async () => {
|
|
280
|
+
const item = await QueueMembersAPI.add({
|
|
281
|
+
parentId: '7',
|
|
282
|
+
itemInstance,
|
|
283
|
+
});
|
|
284
|
+
expect(item.variables).toEqual([
|
|
285
|
+
{
|
|
286
|
+
key: 'someKey',
|
|
287
|
+
value: 'value',
|
|
288
|
+
},
|
|
289
|
+
]);
|
|
290
|
+
});
|
|
291
|
+
|
|
292
|
+
it('update returns variables as key/value pairs', async () => {
|
|
293
|
+
const item = await QueueMembersAPI.update({
|
|
294
|
+
parentId: '7',
|
|
295
|
+
itemId: '5',
|
|
296
|
+
itemInstance,
|
|
297
|
+
});
|
|
298
|
+
expect(item.variables).toEqual([
|
|
299
|
+
{
|
|
300
|
+
key: 'someKey',
|
|
301
|
+
value: 'value',
|
|
302
|
+
},
|
|
303
|
+
]);
|
|
304
|
+
});
|
|
305
|
+
});
|
|
@@ -85,6 +85,30 @@ const preRequestHandler = (item: ApiParams) => {
|
|
|
85
85
|
};
|
|
86
86
|
};
|
|
87
87
|
|
|
88
|
+
/**
|
|
89
|
+
* [Claude] Back to the card's shape: `variables` as key/value pairs and
|
|
90
|
+
* communications filled with defaults. Applied to add/update responses too —
|
|
91
|
+
* the card store takes those as the new item, so a raw map there renders the
|
|
92
|
+
* variables tab empty after save.
|
|
93
|
+
* [WTEL-10587](https://webitel.atlassian.net/browse/WTEL-10587)
|
|
94
|
+
*/
|
|
95
|
+
const itemResponseHandler = (response: ApiParams) => {
|
|
96
|
+
const copy = deepCopy(response);
|
|
97
|
+
let variables: ApiParams[] = [];
|
|
98
|
+
if (copy.variables) {
|
|
99
|
+
variables = Object.keys(copy.variables).map((key) => ({
|
|
100
|
+
key,
|
|
101
|
+
value: copy.variables[key],
|
|
102
|
+
}));
|
|
103
|
+
}
|
|
104
|
+
const communications = mapDefaultCommunications(copy);
|
|
105
|
+
return {
|
|
106
|
+
...response,
|
|
107
|
+
variables,
|
|
108
|
+
communications,
|
|
109
|
+
};
|
|
110
|
+
};
|
|
111
|
+
|
|
88
112
|
const getMembersList = async (params: ApiParams) => {
|
|
89
113
|
const listHandler = (items: ApiParams[]) => {
|
|
90
114
|
const copy = deepCopy(items);
|
|
@@ -305,23 +329,6 @@ const exportMembers = async ({
|
|
|
305
329
|
};
|
|
306
330
|
|
|
307
331
|
const getMember = async ({ parentId, itemId: id }: NestedGetItemParams) => {
|
|
308
|
-
const responseHandler = (response: ApiParams) => {
|
|
309
|
-
const copy = deepCopy(response);
|
|
310
|
-
let variables: ApiParams[] = [];
|
|
311
|
-
if (copy.variables) {
|
|
312
|
-
variables = Object.keys(copy.variables).map((key) => ({
|
|
313
|
-
key,
|
|
314
|
-
value: copy.variables[key],
|
|
315
|
-
}));
|
|
316
|
-
}
|
|
317
|
-
const communications = mapDefaultCommunications(copy);
|
|
318
|
-
return {
|
|
319
|
-
...response,
|
|
320
|
-
variables,
|
|
321
|
-
communications,
|
|
322
|
-
};
|
|
323
|
-
};
|
|
324
|
-
|
|
325
332
|
try {
|
|
326
333
|
const response = await getMemberService().readMember(
|
|
327
334
|
String(parentId),
|
|
@@ -329,7 +336,7 @@ const getMember = async ({ parentId, itemId: id }: NestedGetItemParams) => {
|
|
|
329
336
|
);
|
|
330
337
|
return applyTransform(response.data, [
|
|
331
338
|
snakeToCamel(doNotConvertKeys),
|
|
332
|
-
|
|
339
|
+
itemResponseHandler,
|
|
333
340
|
]);
|
|
334
341
|
} catch (err) {
|
|
335
342
|
throw applyTransform(err, [
|
|
@@ -351,6 +358,7 @@ const addMember = async ({ parentId, itemInstance }: NestedAddItemParams) => {
|
|
|
351
358
|
);
|
|
352
359
|
return applyTransform(response.data, [
|
|
353
360
|
snakeToCamel(doNotConvertKeys),
|
|
361
|
+
itemResponseHandler,
|
|
354
362
|
]);
|
|
355
363
|
} catch (err) {
|
|
356
364
|
throw applyTransform(err, [
|
|
@@ -377,6 +385,7 @@ const updateMember = async ({
|
|
|
377
385
|
);
|
|
378
386
|
return applyTransform(response.data, [
|
|
379
387
|
snakeToCamel(doNotConvertKeys),
|
|
388
|
+
itemResponseHandler,
|
|
380
389
|
]);
|
|
381
390
|
} catch (err) {
|
|
382
391
|
throw applyTransform(err, [
|