@webitel/api-services 26.12.13 → 26.12.15

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.13",
3
+ "version": "26.12.15",
4
4
  "private": false,
5
5
  "repository": {
6
6
  "type": "git",
@@ -33,6 +33,11 @@ const bulkFieldsToSend = [
33
33
  'expireAt',
34
34
  ];
35
35
 
36
+ const preRequestHandler = (parentId: ApiId) => (item: ApiParams) => ({
37
+ ...item,
38
+ listId: parentId,
39
+ });
40
+
36
41
  const getBlacklistNumbersList = async (params: ApiParams) => {
37
42
  const { parentId, page, size, search, sort, fields, id } = applyTransform(
38
43
  params,
@@ -94,6 +99,7 @@ const addBlacklistNumber = async ({
94
99
  itemInstance,
95
100
  }: NestedAddItemParams) => {
96
101
  const item = applyTransform(itemInstance, [
102
+ preRequestHandler(parentId),
97
103
  sanitize(fieldsToSend),
98
104
  camelToSnake(),
99
105
  ]);
@@ -152,6 +158,7 @@ const updateBlacklistNumber = async ({
152
158
  itemId: id,
153
159
  }: NestedUpdateItemParams) => {
154
160
  const item = applyTransform(itemInstance, [
161
+ preRequestHandler(parentId),
155
162
  sanitize(fieldsToSend),
156
163
  camelToSnake(),
157
164
  ]);
@@ -27,26 +27,21 @@ const getBlacklistList = async (params: ApiParams) => {
27
27
  count: 0,
28
28
  };
29
29
 
30
- const requestParams = applyTransform(params, [
30
+ const { page, size, search, sort, fields, id } = applyTransform(params, [
31
31
  merge(getDefaultGetParams()),
32
32
  starToSearch('search'),
33
- camelToSnake(),
34
- (params) => ({
35
- ...params,
36
- q: params.search,
37
- }),
38
- sanitize([
39
- 'page',
40
- 'size',
41
- 'q',
42
- 'sort',
43
- 'fields',
44
- 'id',
45
- ]),
46
33
  ]);
47
34
 
48
35
  try {
49
- const response = await getListService().searchList(requestParams);
36
+ const response = await getListService().searchList({
37
+ page,
38
+ size,
39
+ // [Claude] the generated param is `q`; `search` is what the datalist store sends
40
+ q: search,
41
+ sort,
42
+ fields,
43
+ id,
44
+ });
50
45
  const { items, next } = applyTransform(response.data, [
51
46
  snakeToCamel(),
52
47
  merge(getDefaultGetListResponse()),
@@ -129,6 +124,7 @@ const deleteBlacklist = async ({ id }: DeleteItemParams) => {
129
124
  ]);
130
125
  }
131
126
  };
127
+
132
128
  const getBlacklistsLookup = (params: Parameters<typeof getBlacklistList>[0]) =>
133
129
  getBlacklistList({
134
130
  ...params,
@@ -10,6 +10,8 @@ export * from './agentWorkingConditions/agentWorkingConditions';
10
10
  export * from './auditForms/auditForms';
11
11
  export * from './auditForms/auditRates';
12
12
  export * from './backendProfiles/backendProfiles';
13
+ export * from './blacklists/blacklistNumbers';
14
+ export * from './blacklists/blacklists';
13
15
  export * from './buckets/buckets';
14
16
  export * from './calendars/calendars';
15
17
  export * from './callHistory/callAnnotations';
@@ -54,8 +56,6 @@ export * from './importTemplates/importTemplates';
54
56
  export * from './labels/labels';
55
57
  export * from './license/license';
56
58
  export * from './license/licenseUsers';
57
- export * from './lists/blacklistNumbers';
58
- export * from './lists/blacklists';
59
59
  export * from './logs/logs';
60
60
  export * from './media/media';
61
61
  export * from './messageService/messageService';
@@ -0,0 +1,27 @@
1
+ import { describe, expect, it } from 'vitest';
2
+
3
+ import { blacklistSchema } from '../blacklist.validations';
4
+
5
+ const issuePaths = (value: Record<string, unknown>) =>
6
+ blacklistSchema
7
+ .safeParse(value)
8
+ .error?.issues.map((issue) => issue.path.join('.')) ?? [];
9
+
10
+ describe('blacklistSchema', () => {
11
+ it('requires a name', () => {
12
+ expect(
13
+ issuePaths({
14
+ name: '',
15
+ }),
16
+ ).toContain('name');
17
+ });
18
+
19
+ it('accepts a filled blacklist', () => {
20
+ expect(
21
+ blacklistSchema.safeParse({
22
+ name: 'Spam',
23
+ description: 'Known spammers',
24
+ }).success,
25
+ ).toBe(true);
26
+ });
27
+ });
@@ -0,0 +1,9 @@
1
+ import type { EngineList } from '@webitel/api-services/gen/models';
2
+ import { z } from 'zod';
3
+
4
+ import type { ZodShape } from '../types';
5
+
6
+ export const blacklistSchema = z.object<ZodShape<EngineList>>({
7
+ name: z.string().min(1),
8
+ description: z.string().optional(),
9
+ });
@@ -0,0 +1,41 @@
1
+ import { describe, expect, it } from 'vitest';
2
+
3
+ import { blacklistNumberSchema } from '../blacklistNumber.validations';
4
+
5
+ const issuePaths = (value: Record<string, unknown>) =>
6
+ blacklistNumberSchema
7
+ .safeParse(value)
8
+ .error?.issues.map((issue) => issue.path.join('.')) ?? [];
9
+
10
+ describe('blacklistNumberSchema', () => {
11
+ it('requires a number', () => {
12
+ expect(
13
+ issuePaths({
14
+ number: '',
15
+ }),
16
+ ).toContain('number');
17
+ });
18
+
19
+ it('defaults expireAt to 0 (permanent number)', () => {
20
+ expect(
21
+ blacklistNumberSchema.parse({
22
+ number: '+380441234567',
23
+ }).expireAt,
24
+ ).toBe(0);
25
+ });
26
+
27
+ it('accepts expireAt as a backend string or a datepicker number', () => {
28
+ expect(
29
+ blacklistNumberSchema.safeParse({
30
+ number: '123',
31
+ expireAt: '1760000000000',
32
+ }).success,
33
+ ).toBe(true);
34
+ expect(
35
+ blacklistNumberSchema.safeParse({
36
+ number: '123',
37
+ expireAt: 1760000000000,
38
+ }).success,
39
+ ).toBe(true);
40
+ });
41
+ });
@@ -0,0 +1,19 @@
1
+ import type { EngineListCommunication } from '@webitel/api-services/gen/models';
2
+ import { z } from 'zod';
3
+
4
+ import type { ZodShape } from '../types';
5
+
6
+ export const blacklistNumberSchema = z.object<
7
+ ZodShape<EngineListCommunication>
8
+ >({
9
+ number: z.string().min(1),
10
+ description: z.string().optional(),
11
+ /** [Claude] 0 means a permanent number — set by the "temporary" switcher */
12
+ expireAt: z
13
+ .union([
14
+ z.string(),
15
+ z.number(),
16
+ ])
17
+ .optional()
18
+ .default(0),
19
+ });
@@ -0,0 +1,51 @@
1
+ import { getDefaultsFromZodSchema } from '@webitel/api-services/gen/utils';
2
+ import { describe, expect, it } from 'vitest';
3
+
4
+ import { communicationTypeSchema } from '../communicationType.validations';
5
+
6
+ const filledCommunicationType = {
7
+ name: 'Mobile',
8
+ channel: 'Phone',
9
+ code: 'mobile',
10
+ };
11
+
12
+ const issuePaths = (value: Record<string, unknown>) =>
13
+ communicationTypeSchema
14
+ .safeParse(value)
15
+ .error?.issues.map((issue) => issue.path.join('.')) ?? [];
16
+
17
+ describe('communicationTypeSchema', () => {
18
+ it('seeds a new communication type with the defaults the form expects', () => {
19
+ expect(getDefaultsFromZodSchema(communicationTypeSchema, {})).toMatchObject(
20
+ {
21
+ name: '',
22
+ channel: '',
23
+ code: '',
24
+ description: '',
25
+ default: false,
26
+ },
27
+ );
28
+ });
29
+
30
+ it('requires a name, a channel and a code', () => {
31
+ const paths = issuePaths({
32
+ name: '',
33
+ channel: '',
34
+ code: '',
35
+ });
36
+
37
+ expect(paths).toEqual(
38
+ expect.arrayContaining([
39
+ 'name',
40
+ 'channel',
41
+ 'code',
42
+ ]),
43
+ );
44
+ });
45
+
46
+ it('accepts a communication type without a description', () => {
47
+ expect(
48
+ communicationTypeSchema.safeParse(filledCommunicationType).success,
49
+ ).toBe(true);
50
+ });
51
+ });
@@ -0,0 +1,14 @@
1
+ import type { EngineCommunicationType } from '@webitel/api-services/gen/models';
2
+ import { z } from 'zod';
3
+
4
+ import type { ZodShape } from '../types';
5
+
6
+ export const communicationTypeSchema = z.object<
7
+ ZodShape<EngineCommunicationType>
8
+ >({
9
+ name: z.string().min(1).default(''),
10
+ channel: z.string().min(1).default(''),
11
+ code: z.string().min(1).default(''),
12
+ description: z.string().optional().default(''),
13
+ default: z.boolean().default(false),
14
+ });
@@ -11,6 +11,8 @@ export * from './agentPauseCause/agentPauseCause.validations';
11
11
  export * from './agentSkill/agentSkill.validations';
12
12
  export * from './agentSubordinate/agentSubordinate.validations';
13
13
  export * from './auditForm/auditForm.validations';
14
+ export * from './blacklist/blacklist.validations';
15
+ export * from './blacklistNumber/blacklistNumber.validations';
14
16
  export * from './bucket/bucket.validations';
15
17
  export * from './calendar/calendar.validations';
16
18
  export * from './case/case.validations';
@@ -25,6 +27,7 @@ export * from './caseServiceCatalog/caseServiceCatalog.validations';
25
27
  export * from './caseSource/caseSource.validations';
26
28
  export * from './caseStatus/caseStatus.validations';
27
29
  export * from './caseStatusCondition/caseStatusCondition.validations';
30
+ export * from './communicationType/communicationType.validations';
28
31
  export * from './contact/contact.validations';
29
32
  export * from './contactEmail/contactEmail.validations';
30
33
  export * from './contactGroup/contactGroup.validations';