@webitel/api-services 26.8.24 → 26.8.25
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 +2 -3
- package/src/api/clients/devices/devices.ts +3 -1
- package/src/api/defaults/index.ts +0 -1
- package/src/validations/device/device.validations.ts +70 -0
- package/src/validations/index.ts +1 -0
- package/types/.tsbuildinfo +1 -1
- package/types/api/defaults/index.d.ts +0 -1
- package/types/validations/device/device.validations.d.ts +29 -0
- package/types/validations/index.d.ts +1 -0
- package/src/api/defaults/getDefaultOpenAPIConfig/getDefaultOpenAPIConfig.ts +0 -12
- package/types/api/defaults/getDefaultOpenAPIConfig/getDefaultOpenAPIConfig.d.ts +0 -6
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webitel/api-services",
|
|
3
|
-
"version": "26.8.
|
|
3
|
+
"version": "26.8.25",
|
|
4
4
|
"private": false,
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -68,8 +68,7 @@
|
|
|
68
68
|
"typedoc-github-wiki-theme": "^2.1.0",
|
|
69
69
|
"typescript": "5.8.2",
|
|
70
70
|
"vue-i18n": "^11.2.8",
|
|
71
|
-
"vue-tsc": "^2.2.10"
|
|
72
|
-
"webitel-sdk": "^25.4.3"
|
|
71
|
+
"vue-tsc": "^2.2.10"
|
|
73
72
|
},
|
|
74
73
|
"dependencies": {
|
|
75
74
|
"date-fns": "^4.1.0",
|
|
@@ -54,9 +54,11 @@ const getDevicesList = async (params: ApiParams) => {
|
|
|
54
54
|
const requestParams = applyTransform(params, [
|
|
55
55
|
merge(getDefaultGetParams()),
|
|
56
56
|
starToSearch('search'),
|
|
57
|
+
starToSearch('q'),
|
|
57
58
|
(params) => ({
|
|
58
59
|
...params,
|
|
59
|
-
q
|
|
60
|
+
// filtersManager may pass `q` (Path A) or legacy `search`
|
|
61
|
+
q: params.q ?? params.search,
|
|
60
62
|
}),
|
|
61
63
|
sanitize(listFieldsToSend),
|
|
62
64
|
camelToSnake(),
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import type { ApiDevice } from '@webitel/api-services/gen/models';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
|
|
4
|
+
import { i18nIssue } from '../_shared/i18nIssue';
|
|
5
|
+
import { flexibleLookupSchema } from '../_shared/lookup.validations';
|
|
6
|
+
import type { ZodShape } from '../types';
|
|
7
|
+
|
|
8
|
+
const ipv4Regex =
|
|
9
|
+
/^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$/;
|
|
10
|
+
|
|
11
|
+
const macRegex = /^([0-9A-Fa-f]{2}[:-]){5}([0-9A-Fa-f]{2})$/;
|
|
12
|
+
|
|
13
|
+
const optionalIpSchema = z
|
|
14
|
+
.string()
|
|
15
|
+
.optional()
|
|
16
|
+
.default('')
|
|
17
|
+
.refine((value) => {
|
|
18
|
+
if (!value) return true;
|
|
19
|
+
if (value === '127.0.0.1' || value === '0.0.0.0') return false;
|
|
20
|
+
return ipv4Regex.test(value);
|
|
21
|
+
}, i18nIssue('ipValidator'));
|
|
22
|
+
|
|
23
|
+
const optionalMacSchema = z
|
|
24
|
+
.string()
|
|
25
|
+
.optional()
|
|
26
|
+
.default('')
|
|
27
|
+
.refine((value) => !value || macRegex.test(value), i18nIssue('macValidator'));
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Device card schema.
|
|
31
|
+
*
|
|
32
|
+
* Password is required only when creating (`id` absent) — an empty password on
|
|
33
|
+
* update means "keep the current one" (see DevicesAPI.preRequestHandler).
|
|
34
|
+
*/
|
|
35
|
+
export const deviceSchema = z
|
|
36
|
+
.object<ZodShape<ApiDevice>>({
|
|
37
|
+
id: z.string().optional(),
|
|
38
|
+
name: z.string().min(1).default(''),
|
|
39
|
+
account: z.string().min(1).default(''),
|
|
40
|
+
password: z.string().optional().default(''),
|
|
41
|
+
user: flexibleLookupSchema.optional().default({}),
|
|
42
|
+
ip: optionalIpSchema,
|
|
43
|
+
brand: z.string().optional().default(''),
|
|
44
|
+
model: z.string().optional().default(''),
|
|
45
|
+
mac: optionalMacSchema,
|
|
46
|
+
hotdesk: z.boolean().optional().default(false),
|
|
47
|
+
hotdesks: z.array(z.string()).optional().default([]),
|
|
48
|
+
})
|
|
49
|
+
.superRefine((data, ctx) => {
|
|
50
|
+
if (!data.id && !data.password) {
|
|
51
|
+
ctx.addIssue({
|
|
52
|
+
code: 'custom',
|
|
53
|
+
path: [
|
|
54
|
+
'password',
|
|
55
|
+
],
|
|
56
|
+
...i18nIssue('required'),
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
const hotdesks = data.hotdesks as string[] | undefined;
|
|
61
|
+
if (data.hotdesk && hotdesks?.some((hotdesk) => !/\w+/.test(hotdesk))) {
|
|
62
|
+
ctx.addIssue({
|
|
63
|
+
code: 'custom',
|
|
64
|
+
path: [
|
|
65
|
+
'hotdesks',
|
|
66
|
+
],
|
|
67
|
+
...i18nIssue('required'),
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
});
|
package/src/validations/index.ts
CHANGED
|
@@ -23,6 +23,7 @@ export * from './contactEmail/contactEmail.validations';
|
|
|
23
23
|
export * from './contactGroup/contactGroup.validations';
|
|
24
24
|
export * from './contactGroupCondition/contactGroupCondition.validations';
|
|
25
25
|
export * from './contactPhone/contactPhone.validations';
|
|
26
|
+
export * from './device/device.validations';
|
|
26
27
|
export * from './OAuth/OAuth.validations';
|
|
27
28
|
export * from './onlineSkill/onlineSkill.validations';
|
|
28
29
|
export * from './queue/queue.rules';
|