@webitel/api-services 26.8.24 → 26.8.26

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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webitel/api-services",
3
- "version": "26.8.24",
3
+ "version": "26.8.26",
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: params.search,
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(),
@@ -157,7 +157,7 @@ const getList = async (params: ApiParams) => {
157
157
  }
158
158
  };
159
159
 
160
- const contactFieldsToSend = [
160
+ export const contactFieldsToSend = [
161
161
  'name',
162
162
  'about',
163
163
  'labels',
@@ -172,12 +172,14 @@ const contactFieldsToSend = [
172
172
  'imclients',
173
173
  'user',
174
174
  'custom',
175
- ];
175
+ ] as const;
176
176
 
177
177
  const get = async ({ itemId: id }: GetItemParams) => {
178
178
  try {
179
179
  const response = await getContacts().locateContact(String(id), {
180
- fields: contactFieldsToSend,
180
+ fields: [
181
+ ...contactFieldsToSend,
182
+ ],
181
183
  });
182
184
  return applyTransform(response.data, [
183
185
  snakeToCamel([
@@ -322,7 +324,9 @@ const update = async ({ itemInstance }: AddItemParams) => {
322
324
  ]);
323
325
  try {
324
326
  const response = await getContacts().updateContact(etag, item, {
325
- fields: contactFieldsToSend,
327
+ fields: [
328
+ ...contactFieldsToSend,
329
+ ],
326
330
  });
327
331
  return applyTransform(response.data, [
328
332
  snakeToCamel([
@@ -1,4 +1,3 @@
1
1
  export * from './getDefaultGetListResponse/getDefaultGetListResponse';
2
2
  export * from './getDefaultGetParams/getDefaultGetParams';
3
3
  export * from './getDefaultInstance/getDefaultInstance';
4
- export * from './getDefaultOpenAPIConfig/getDefaultOpenAPIConfig';
@@ -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
+ });
@@ -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';