@webitel/api-services 26.12.14 → 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 +1 -1
- package/src/api/clients/{lists → blacklists}/blacklistNumbers.ts +7 -0
- package/src/api/clients/{lists → blacklists}/blacklists.ts +11 -15
- package/src/api/clients/index.ts +2 -2
- package/src/api/clients/regions/regions.ts +10 -15
- package/src/validations/blacklist/__tests__/blacklist.validations.spec.ts +27 -0
- package/src/validations/blacklist/blacklist.validations.ts +9 -0
- package/src/validations/blacklistNumber/__tests__/blacklistNumber.validations.spec.ts +41 -0
- package/src/validations/blacklistNumber/blacklistNumber.validations.ts +19 -0
- package/src/validations/index.ts +3 -0
- package/src/validations/region/__tests__/region.validations.spec.ts +32 -0
- package/src/validations/region/region.validations.ts +11 -0
- package/types/.tsbuildinfo +1 -1
- package/types/api/clients/index.d.ts +2 -2
- package/types/validations/blacklist/blacklist.validations.d.ts +12 -0
- package/types/validations/blacklistNumber/blacklistNumber.validations.d.ts +8 -0
- package/types/validations/index.d.ts +3 -0
- package/types/validations/region/region.validations.d.ts +7 -0
- /package/types/api/clients/{lists → blacklists}/blacklistNumbers.d.ts +0 -0
- /package/types/api/clients/{lists → blacklists}/blacklists.d.ts +0 -0
package/package.json
CHANGED
|
@@ -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
|
|
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(
|
|
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,
|
package/src/api/clients/index.ts
CHANGED
|
@@ -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';
|
|
@@ -18,26 +18,21 @@ import type {
|
|
|
18
18
|
} from '../_shared/types';
|
|
19
19
|
|
|
20
20
|
const getRegionsList = async (params: ApiParams) => {
|
|
21
|
-
const
|
|
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(
|
|
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()),
|
|
@@ -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
|
+
});
|
package/src/validations/index.ts
CHANGED
|
@@ -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';
|
|
@@ -47,6 +49,7 @@ export * from './queueMember/memberCommunication.validations';
|
|
|
47
49
|
export * from './queueMember/queueMember.validations';
|
|
48
50
|
export * from './queueResGroup/queueResGroup.validations';
|
|
49
51
|
export * from './queueSkill/queueSkill.validations';
|
|
52
|
+
export * from './region/region.validations';
|
|
50
53
|
export * from './resource/resource.validations';
|
|
51
54
|
export * from './resourceDisplay/resourceDisplay.validations';
|
|
52
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
|
+
});
|