@webitel/api-services 26.12.15 → 26.12.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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webitel/api-services",
3
- "version": "26.12.15",
3
+ "version": "26.12.16",
4
4
  "private": false,
5
5
  "repository": {
6
6
  "type": "git",
@@ -18,26 +18,21 @@ import type {
18
18
  } from '../_shared/types';
19
19
 
20
20
  const getRegionsList = async (params: ApiParams) => {
21
- const requestParams = applyTransform(params, [
21
+ const { page, size, search, sort, fields, id } = applyTransform(params, [
22
22
  merge(getDefaultGetParams()),
23
23
  starToSearch('search'),
24
- camelToSnake(),
25
- (params) => ({
26
- ...params,
27
- q: params.search,
28
- }),
29
- sanitize([
30
- 'page',
31
- 'size',
32
- 'q',
33
- 'sort',
34
- 'fields',
35
- 'id',
36
- ]),
37
24
  ]);
38
25
 
39
26
  try {
40
- const response = await getRegionService().searchRegion(requestParams);
27
+ const response = await getRegionService().searchRegion({
28
+ page,
29
+ size,
30
+ // [Claude] the generated param is `q`; `search` is what the datalist store sends
31
+ q: search,
32
+ sort,
33
+ fields,
34
+ id,
35
+ });
41
36
  const { items, next } = applyTransform(response.data, [
42
37
  snakeToCamel(),
43
38
  merge(getDefaultGetListResponse()),
@@ -49,6 +49,7 @@ export * from './queueMember/memberCommunication.validations';
49
49
  export * from './queueMember/queueMember.validations';
50
50
  export * from './queueResGroup/queueResGroup.validations';
51
51
  export * from './queueSkill/queueSkill.validations';
52
+ export * from './region/region.validations';
52
53
  export * from './resource/resource.validations';
53
54
  export * from './resourceDisplay/resourceDisplay.validations';
54
55
  export * from './resourceGroup/resourceGroup.validations';
@@ -0,0 +1,32 @@
1
+ import { describe, expect, it } from 'vitest';
2
+
3
+ import { regionSchema } from '../region.validations';
4
+
5
+ const issuePaths = (value: Record<string, unknown>) =>
6
+ regionSchema
7
+ .safeParse(value)
8
+ .error?.issues.map((issue) => issue.path.join('.')) ?? [];
9
+
10
+ describe('regionSchema', () => {
11
+ it('requires a name and a timezone', () => {
12
+ const paths = issuePaths({
13
+ name: '',
14
+ timezone: {},
15
+ });
16
+
17
+ expect(paths).toContain('name');
18
+ expect(paths).toContain('timezone.id');
19
+ });
20
+
21
+ it('accepts a filled region', () => {
22
+ expect(
23
+ regionSchema.safeParse({
24
+ name: 'Kyiv',
25
+ timezone: {
26
+ id: 1,
27
+ name: 'Europe/Kyiv',
28
+ },
29
+ }).success,
30
+ ).toBe(true);
31
+ });
32
+ });
@@ -0,0 +1,11 @@
1
+ import type { EngineRegion } from '@webitel/api-services/gen/models';
2
+ import { z } from 'zod';
3
+
4
+ import { filledLookupSchema } from '../_shared/lookup.validations';
5
+ import type { ZodShape } from '../types';
6
+
7
+ export const regionSchema = z.object<ZodShape<EngineRegion>>({
8
+ name: z.string().min(1),
9
+ timezone: filledLookupSchema,
10
+ description: z.string().optional().default(''),
11
+ });