@webitel/api-services 26.8.14 → 26.8.16
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/users/users.ts +21 -2
- package/src/validations/caseClose/caseClose.validations.ts +10 -0
- package/src/validations/caseExportOptions/__tests__/caseExportOptions.validations.spec.ts +80 -0
- package/src/validations/caseExportOptions/caseExportOptions.validations.ts +10 -0
- package/types/.tsbuildinfo +1 -1
package/package.json
CHANGED
|
@@ -5,6 +5,7 @@ import {
|
|
|
5
5
|
getDefaultInstance,
|
|
6
6
|
} from '../../defaults';
|
|
7
7
|
import {
|
|
8
|
+
addQueryParamsToUrl,
|
|
8
9
|
applyTransform,
|
|
9
10
|
camelToSnake,
|
|
10
11
|
generateUrl,
|
|
@@ -101,6 +102,7 @@ const getUser = async ({ itemId: id }: GetItemParams) => {
|
|
|
101
102
|
license: [],
|
|
102
103
|
devices: [],
|
|
103
104
|
device: {},
|
|
105
|
+
generateDevice: false,
|
|
104
106
|
variables: [
|
|
105
107
|
{
|
|
106
108
|
key: '',
|
|
@@ -185,8 +187,17 @@ const addUser = async ({ itemInstance }: AddItemParams) => {
|
|
|
185
187
|
'profile',
|
|
186
188
|
]),
|
|
187
189
|
]);
|
|
190
|
+
const url = applyTransform(baseUrl, [
|
|
191
|
+
addQueryParamsToUrl(
|
|
192
|
+
itemInstance.generateDevice
|
|
193
|
+
? [
|
|
194
|
+
'generate_device=true',
|
|
195
|
+
]
|
|
196
|
+
: [],
|
|
197
|
+
),
|
|
198
|
+
]);
|
|
188
199
|
try {
|
|
189
|
-
const response = await instance.post(
|
|
200
|
+
const response = await instance.post(url, item);
|
|
190
201
|
return applyTransform(response.data, [
|
|
191
202
|
snakeToCamel([
|
|
192
203
|
'profile',
|
|
@@ -208,7 +219,15 @@ const updateUser = async ({ itemInstance, itemId: id }: UpdateItemParams) => {
|
|
|
208
219
|
]),
|
|
209
220
|
]);
|
|
210
221
|
|
|
211
|
-
const url = `${baseUrl}/${id}
|
|
222
|
+
const url = applyTransform(`${baseUrl}/${id}`, [
|
|
223
|
+
addQueryParamsToUrl(
|
|
224
|
+
itemInstance.generateDevice
|
|
225
|
+
? [
|
|
226
|
+
'generate_device=true',
|
|
227
|
+
]
|
|
228
|
+
: [],
|
|
229
|
+
),
|
|
230
|
+
]);
|
|
212
231
|
try {
|
|
213
232
|
const response = await instance.put(url, item);
|
|
214
233
|
return applyTransform(response.data, [
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
|
|
3
|
+
import { i18nIssue } from '../_shared/i18nIssue';
|
|
4
|
+
|
|
3
5
|
export const caseCloseSchema = z
|
|
4
6
|
.object({
|
|
5
7
|
reason: z
|
|
@@ -17,12 +19,20 @@ export const caseCloseSchema = z
|
|
|
17
19
|
if (!data.reason?.id) {
|
|
18
20
|
ctx.addIssue({
|
|
19
21
|
code: 'custom',
|
|
22
|
+
path: [
|
|
23
|
+
'reason',
|
|
24
|
+
],
|
|
25
|
+
...i18nIssue('required'),
|
|
20
26
|
});
|
|
21
27
|
}
|
|
22
28
|
|
|
23
29
|
if (!data.result) {
|
|
24
30
|
ctx.addIssue({
|
|
25
31
|
code: 'custom',
|
|
32
|
+
path: [
|
|
33
|
+
'result',
|
|
34
|
+
],
|
|
35
|
+
...i18nIssue('required'),
|
|
26
36
|
});
|
|
27
37
|
}
|
|
28
38
|
});
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { describe, expect, it } from 'vitest';
|
|
2
|
+
import type { z } from 'zod';
|
|
3
|
+
|
|
4
|
+
import { caseExportOptionsSchema } from '../caseExportOptions.validations';
|
|
5
|
+
|
|
6
|
+
const issues = (result: z.ZodSafeParseResult<unknown>) =>
|
|
7
|
+
result.success
|
|
8
|
+
? []
|
|
9
|
+
: result.error.issues.map((issue) => ({
|
|
10
|
+
path: issue.path.join('.'),
|
|
11
|
+
i18nKey: (
|
|
12
|
+
issue as {
|
|
13
|
+
params?: {
|
|
14
|
+
i18nKey?: string;
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
).params?.i18nKey,
|
|
18
|
+
}));
|
|
19
|
+
|
|
20
|
+
describe('caseExportOptionsSchema', () => {
|
|
21
|
+
it('accepts xlsx without a separator', () => {
|
|
22
|
+
const result = caseExportOptionsSchema.safeParse({
|
|
23
|
+
type: {
|
|
24
|
+
name: 'xlsx',
|
|
25
|
+
value: 'xlsx',
|
|
26
|
+
},
|
|
27
|
+
separator: null,
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
expect(issues(result)).toEqual([]);
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
it('accepts csv with a separator', () => {
|
|
34
|
+
const result = caseExportOptionsSchema.safeParse({
|
|
35
|
+
type: {
|
|
36
|
+
name: 'csv',
|
|
37
|
+
value: 'csv',
|
|
38
|
+
},
|
|
39
|
+
separator: ',',
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
expect(issues(result)).toEqual([]);
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* The popup binds `r$.$fields.type` to the select, so the issue has to be
|
|
47
|
+
* filed under `type` — a root-level issue disables the button but shows no
|
|
48
|
+
* "required" message under the field (WTEL-10340).
|
|
49
|
+
*/
|
|
50
|
+
it('reports a missing format under the `type` path', () => {
|
|
51
|
+
const result = caseExportOptionsSchema.safeParse({
|
|
52
|
+
type: null,
|
|
53
|
+
separator: ',',
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
expect(issues(result)).toEqual([
|
|
57
|
+
{
|
|
58
|
+
path: 'type',
|
|
59
|
+
i18nKey: 'required',
|
|
60
|
+
},
|
|
61
|
+
]);
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
it('reports a missing csv separator under the `separator` path', () => {
|
|
65
|
+
const result = caseExportOptionsSchema.safeParse({
|
|
66
|
+
type: {
|
|
67
|
+
name: 'csv',
|
|
68
|
+
value: 'csv',
|
|
69
|
+
},
|
|
70
|
+
separator: '',
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
expect(issues(result)).toEqual([
|
|
74
|
+
{
|
|
75
|
+
path: 'separator',
|
|
76
|
+
i18nKey: 'required',
|
|
77
|
+
},
|
|
78
|
+
]);
|
|
79
|
+
});
|
|
80
|
+
});
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
|
|
3
|
+
import { i18nIssue } from '../_shared/i18nIssue';
|
|
4
|
+
|
|
3
5
|
export const caseExportOptionsSchema = z
|
|
4
6
|
.object({
|
|
5
7
|
type: z
|
|
@@ -14,12 +16,20 @@ export const caseExportOptionsSchema = z
|
|
|
14
16
|
if (!data.type) {
|
|
15
17
|
ctx.addIssue({
|
|
16
18
|
code: 'custom',
|
|
19
|
+
path: [
|
|
20
|
+
'type',
|
|
21
|
+
],
|
|
22
|
+
...i18nIssue('required'),
|
|
17
23
|
});
|
|
18
24
|
}
|
|
19
25
|
|
|
20
26
|
if (data.type?.value === 'csv' && !data.separator) {
|
|
21
27
|
ctx.addIssue({
|
|
22
28
|
code: 'custom',
|
|
29
|
+
path: [
|
|
30
|
+
'separator',
|
|
31
|
+
],
|
|
32
|
+
...i18nIssue('required'),
|
|
23
33
|
});
|
|
24
34
|
}
|
|
25
35
|
});
|