@webitel/api-services 26.12.35 → 26.12.37
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/agentWorkingConditions/agentWorkingConditions.ts +6 -0
- package/src/validations/_shared/__tests__/timeRange.validations.spec.ts +69 -0
- package/src/validations/_shared/timeRange.validations.ts +16 -0
- package/src/validations/agent/agent.validations.ts +1 -1
- package/types/.tsbuildinfo +1 -1
- package/types/validations/_shared/timeRange.validations.d.ts +8 -0
- package/types/validations/agent/agent.validations.d.ts +2 -2
package/package.json
CHANGED
|
@@ -25,6 +25,11 @@ const itemResponseHandler = (response: ApiParams) => ({
|
|
|
25
25
|
...response.item,
|
|
26
26
|
});
|
|
27
27
|
|
|
28
|
+
const emptyPauseTemplateHandler = (item: ApiParams) => ({
|
|
29
|
+
...item,
|
|
30
|
+
pauseTemplate: item.pauseTemplate?.id ? item.pauseTemplate : null,
|
|
31
|
+
});
|
|
32
|
+
|
|
28
33
|
const getAgentWorkingConditions = async ({ itemId: id }: GetItemParams) => {
|
|
29
34
|
try {
|
|
30
35
|
const response =
|
|
@@ -49,6 +54,7 @@ const updateAgentWorkingConditions = async ({
|
|
|
49
54
|
}: UpdateItemParams) => {
|
|
50
55
|
const item = applyTransform(itemInstance, [
|
|
51
56
|
sanitize(fieldsToSend),
|
|
57
|
+
emptyPauseTemplateHandler,
|
|
52
58
|
camelToSnake(),
|
|
53
59
|
]);
|
|
54
60
|
try {
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { describe, expect, it } from 'vitest';
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
getTimeRangeDuration,
|
|
5
|
+
setTimeRangeDuration,
|
|
6
|
+
type TimeRange,
|
|
7
|
+
} from '../timeRange.validations';
|
|
8
|
+
|
|
9
|
+
describe('getTimeRangeDuration', () => {
|
|
10
|
+
it.each([
|
|
11
|
+
[
|
|
12
|
+
{
|
|
13
|
+
start: 540,
|
|
14
|
+
end: 1080,
|
|
15
|
+
},
|
|
16
|
+
540,
|
|
17
|
+
],
|
|
18
|
+
[
|
|
19
|
+
{
|
|
20
|
+
start: 600,
|
|
21
|
+
end: 600,
|
|
22
|
+
},
|
|
23
|
+
0,
|
|
24
|
+
],
|
|
25
|
+
[
|
|
26
|
+
{
|
|
27
|
+
start: 700,
|
|
28
|
+
end: 600,
|
|
29
|
+
},
|
|
30
|
+
0,
|
|
31
|
+
],
|
|
32
|
+
[
|
|
33
|
+
{
|
|
34
|
+
end: 60,
|
|
35
|
+
},
|
|
36
|
+
60,
|
|
37
|
+
],
|
|
38
|
+
[
|
|
39
|
+
{},
|
|
40
|
+
0,
|
|
41
|
+
],
|
|
42
|
+
])('%j → %i', (range: Partial<TimeRange>, duration) => {
|
|
43
|
+
expect(getTimeRangeDuration(range)).toBe(duration);
|
|
44
|
+
});
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
describe('setTimeRangeDuration', () => {
|
|
48
|
+
it('moves end, keeps start', () => {
|
|
49
|
+
const range = {
|
|
50
|
+
start: 540,
|
|
51
|
+
end: 600,
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
setTimeRangeDuration(range, 120);
|
|
55
|
+
|
|
56
|
+
expect(range).toEqual({
|
|
57
|
+
start: 540,
|
|
58
|
+
end: 660,
|
|
59
|
+
});
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
it('counts from 0 when start is unset', () => {
|
|
63
|
+
const range: Partial<TimeRange> = {};
|
|
64
|
+
|
|
65
|
+
setTimeRangeDuration(range, 30);
|
|
66
|
+
|
|
67
|
+
expect(range.end).toBe(30);
|
|
68
|
+
});
|
|
69
|
+
});
|
|
@@ -54,6 +54,22 @@ export const timeRangeSchema = z
|
|
|
54
54
|
})
|
|
55
55
|
.superRefine(refineTimeRangeStartLessThanEnd);
|
|
56
56
|
|
|
57
|
+
/**
|
|
58
|
+
* [Claude] range length in minutes; an unset bound counts as 0, an inverted range as 0
|
|
59
|
+
*/
|
|
60
|
+
export const getTimeRangeDuration = (range: Partial<TimeRange>) =>
|
|
61
|
+
Math.max(0, (range.end ?? 0) - (range.start ?? 0));
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* [Claude] sets the length by moving `end`; `start` stays
|
|
65
|
+
*/
|
|
66
|
+
export const setTimeRangeDuration = (
|
|
67
|
+
range: Partial<TimeRange>,
|
|
68
|
+
minutes: number,
|
|
69
|
+
) => {
|
|
70
|
+
range.end = (range.start ?? 0) + minutes;
|
|
71
|
+
};
|
|
72
|
+
|
|
57
73
|
const isIntersecting = (a: TimeRange, b: TimeRange) =>
|
|
58
74
|
a.start <= b.end && b.start <= a.end;
|
|
59
75
|
|
|
@@ -31,5 +31,5 @@ export const agentSchema = z.object<ZodShape<EngineAgent>>({
|
|
|
31
31
|
*/
|
|
32
32
|
export const agentWfmConditionsSchema = z.object({
|
|
33
33
|
workingCondition: filledLookupSchema,
|
|
34
|
-
pauseTemplate: flexibleLookupSchema.optional()
|
|
34
|
+
pauseTemplate: flexibleLookupSchema.optional(),
|
|
35
35
|
});
|