@webitel/api-services 26.8.10 → 26.8.12
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 +1 -0
- package/src/api/clients/caseLinks/__tests__/caseLinks.spec.ts +45 -0
- package/src/api/clients/caseLinks/caseLinks.ts +6 -3
- package/src/api/clients/cases/cases.ts +14 -0
- package/src/api/clients/devices/devices.ts +6 -8
- package/src/validations/queueBucket/queueBucket.validations.ts +1 -1
- package/types/.tsbuildinfo +1 -1
- package/types/validations/queueBucket/queueBucket.validations.d.ts +1 -1
package/package.json
CHANGED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { describe, expect, it, vi } from 'vitest';
|
|
2
|
+
|
|
3
|
+
const createLink = vi.fn(() =>
|
|
4
|
+
Promise.resolve({
|
|
5
|
+
data: {},
|
|
6
|
+
}),
|
|
7
|
+
);
|
|
8
|
+
|
|
9
|
+
vi.mock('../../../../gen-wire', async (importOriginal) => ({
|
|
10
|
+
...(await importOriginal<Record<string, unknown>>()),
|
|
11
|
+
getCaseLinks: () => ({
|
|
12
|
+
createLink,
|
|
13
|
+
}),
|
|
14
|
+
}));
|
|
15
|
+
|
|
16
|
+
const { CreateLinkQueryParams } = await import('../../../../gen-wire');
|
|
17
|
+
const { CaseLinksAPI } = await import('../caseLinks');
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* [WTEL-10338](https://webitel.atlassian.net/browse/WTEL-10338)
|
|
21
|
+
*
|
|
22
|
+
* `addLink` derived its field allowlist from `CreateLinkParams` — the schema
|
|
23
|
+
* for this endpoint's path param (`case_etag`) — instead of
|
|
24
|
+
* `CreateLinkQueryParams` (`input.url`, `input.name`, ...). `sanitizeToWire`
|
|
25
|
+
* then dropped every field, so the request always went out with no query
|
|
26
|
+
* params and the backend rejected it with "url is required".
|
|
27
|
+
*/
|
|
28
|
+
describe('CaseLinksAPI.add', () => {
|
|
29
|
+
it('sends url and name as query params', async () => {
|
|
30
|
+
await CaseLinksAPI.add({
|
|
31
|
+
parentId: '1354',
|
|
32
|
+
input: {
|
|
33
|
+
url: 'https://example.com',
|
|
34
|
+
name: 'Example link',
|
|
35
|
+
},
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
const [, params] = createLink.mock.calls[0];
|
|
39
|
+
expect(params).toMatchObject({
|
|
40
|
+
'input.url': 'https://example.com',
|
|
41
|
+
'input.name': 'Example link',
|
|
42
|
+
});
|
|
43
|
+
expect(CreateLinkQueryParams.strict().safeParse(params).success).toBe(true);
|
|
44
|
+
});
|
|
45
|
+
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { getShallowFieldsToSendFromZodSchema } from '@webitel/api-services/gen/utils';
|
|
2
2
|
import {
|
|
3
|
-
|
|
3
|
+
CreateLinkQueryParams,
|
|
4
4
|
getCaseLinks,
|
|
5
5
|
ListLinksQueryParams,
|
|
6
6
|
UpdateLink2Body,
|
|
@@ -60,8 +60,11 @@ const getLinksList = async ({
|
|
|
60
60
|
}
|
|
61
61
|
};
|
|
62
62
|
|
|
63
|
-
|
|
64
|
-
|
|
63
|
+
// `CreateLinkParams` (the path-param schema, just `case_etag`) looks like the right
|
|
64
|
+
// name here but isn't: the fields actually sent for this call are the query params.
|
|
65
|
+
const createLinkFieldsToSend = getShallowFieldsToSendFromZodSchema(
|
|
66
|
+
CreateLinkQueryParams,
|
|
67
|
+
);
|
|
65
68
|
|
|
66
69
|
const addLink = async ({
|
|
67
70
|
parentId,
|
|
@@ -221,6 +221,13 @@ const updateCase = async ({ itemInstance }: AddItemParams) => {
|
|
|
221
221
|
const response = await casesService.updateCase(etag, item, {
|
|
222
222
|
fields: caseFieldsToSend,
|
|
223
223
|
});
|
|
224
|
+
|
|
225
|
+
if (!response.data?.case) {
|
|
226
|
+
return await getCase({
|
|
227
|
+
itemId: String(etag),
|
|
228
|
+
});
|
|
229
|
+
}
|
|
230
|
+
|
|
224
231
|
return applyTransform(response.data.case, [
|
|
225
232
|
snakeToCamel([
|
|
226
233
|
'custom',
|
|
@@ -274,6 +281,13 @@ const patchCase = async ({
|
|
|
274
281
|
const response = await casesService.updateCase2(String(etag), body, {
|
|
275
282
|
fields: caseFieldsToSend,
|
|
276
283
|
});
|
|
284
|
+
|
|
285
|
+
if (!response.data?.case) {
|
|
286
|
+
return await getCase({
|
|
287
|
+
itemId: String(etag),
|
|
288
|
+
});
|
|
289
|
+
}
|
|
290
|
+
|
|
277
291
|
return applyTransform(response.data.case, [
|
|
278
292
|
snakeToCamel([
|
|
279
293
|
'custom',
|
|
@@ -165,29 +165,27 @@ const getDevicesLookup = (params: Parameters<typeof getDevicesList>[0]) =>
|
|
|
165
165
|
});
|
|
166
166
|
|
|
167
167
|
const getDeviceHistory = async ({ parentId, from, to, ...rest }: ApiParams) => {
|
|
168
|
+
// `SearchDeviceAuditQueryParams` (device audit history) declares neither a
|
|
169
|
+
// text search nor `time_to` — only `time_from`/`time_till`. Sending `search`
|
|
170
|
+
// (or its old `q` alias) and `timeTo` used to pass sanitize()'s allowlist and
|
|
171
|
+
// then get silently dropped by the backend: no error, filters just did nothing.
|
|
168
172
|
const historyFieldsToSend = [
|
|
169
173
|
'page',
|
|
170
174
|
'size',
|
|
171
|
-
'search',
|
|
172
175
|
'fields',
|
|
173
176
|
'id',
|
|
174
177
|
'timeFrom',
|
|
175
|
-
'
|
|
178
|
+
'timeTill',
|
|
176
179
|
];
|
|
177
180
|
|
|
178
181
|
const requestParams = applyTransform(
|
|
179
182
|
{
|
|
180
183
|
...rest,
|
|
181
184
|
timeFrom: from,
|
|
182
|
-
|
|
185
|
+
timeTill: to,
|
|
183
186
|
},
|
|
184
187
|
[
|
|
185
188
|
merge(getDefaultGetParams()),
|
|
186
|
-
starToSearch('search'),
|
|
187
|
-
(params) => ({
|
|
188
|
-
...params,
|
|
189
|
-
q: params.search,
|
|
190
|
-
}),
|
|
191
189
|
sanitize(historyFieldsToSend),
|
|
192
190
|
camelToSnake(),
|
|
193
191
|
],
|
|
@@ -5,6 +5,6 @@ import { filledLookupSchema } from '../_shared/lookup.validations';
|
|
|
5
5
|
export const queueBucketSchema = z.object({
|
|
6
6
|
bucket: filledLookupSchema,
|
|
7
7
|
/** legacy: required + numeric + minValue(0) */
|
|
8
|
-
priority: z.number().min(0),
|
|
8
|
+
priority: z.number().min(0).default(0),
|
|
9
9
|
disabled: z.boolean().optional(),
|
|
10
10
|
});
|