@webitel/api-services 26.8.78 → 26.8.80

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.78",
3
+ "version": "26.8.80",
4
4
  "private": false,
5
5
  "repository": {
6
6
  "type": "git",
@@ -0,0 +1,74 @@
1
+ import { getAgentWorkingConditionsService } from '../../../gen-wire';
2
+ import {
3
+ applyTransform,
4
+ camelToSnake,
5
+ notify,
6
+ sanitize,
7
+ snakeToCamel,
8
+ } from '../../transformers';
9
+ import type {
10
+ ApiParams,
11
+ GetItemParams,
12
+ UpdateItemParams,
13
+ } from '../_shared/types';
14
+
15
+ const fieldsToSend = [
16
+ 'workingCondition',
17
+ 'pauseTemplate',
18
+ ];
19
+
20
+ /**
21
+ * [Claude] WFM services wrap both request and response payloads in an `item` envelope.
22
+ */
23
+ const itemResponseHandler = (response: ApiParams) => ({
24
+ ...response.item,
25
+ });
26
+
27
+ const getAgentWorkingConditions = async ({ itemId: id }: GetItemParams) => {
28
+ try {
29
+ const response =
30
+ await getAgentWorkingConditionsService().agentWorkingConditionsServiceReadAgentWorkingConditions(
31
+ String(id),
32
+ );
33
+ return applyTransform(response.data, [
34
+ snakeToCamel(),
35
+ itemResponseHandler,
36
+ ]);
37
+ } catch (err) {
38
+ throw applyTransform(err, [
39
+ notify,
40
+ ]);
41
+ }
42
+ };
43
+
44
+ const updateAgentWorkingConditions = async ({
45
+ itemInstance,
46
+ itemId: id,
47
+ }: UpdateItemParams) => {
48
+ const item = applyTransform(itemInstance, [
49
+ sanitize(fieldsToSend),
50
+ camelToSnake(),
51
+ ]);
52
+ try {
53
+ const response =
54
+ await getAgentWorkingConditionsService().agentWorkingConditionsServiceUpdateAgentWorkingConditions(
55
+ String(id),
56
+ {
57
+ item,
58
+ },
59
+ );
60
+ return applyTransform(response.data, [
61
+ snakeToCamel(),
62
+ itemResponseHandler,
63
+ ]);
64
+ } catch (err) {
65
+ throw applyTransform(err, [
66
+ notify,
67
+ ]);
68
+ }
69
+ };
70
+
71
+ export const AgentWorkingConditionsAPI = {
72
+ get: getAgentWorkingConditions,
73
+ update: updateAgentWorkingConditions,
74
+ };
@@ -6,6 +6,7 @@ export * from './agentSkills/agentSkills';
6
6
  export * from './agents/agentAbsence';
7
7
  export * from './agents/agentChats';
8
8
  export * from './agents/agents';
9
+ export * from './agentWorkingConditions/agentWorkingConditions';
9
10
  export * from './auditForms/auditForms';
10
11
  export * from './auditForms/auditRates';
11
12
  export * from './backendProfiles/backendProfiles';
@@ -23,3 +23,13 @@ export const agentSchema = z.object<ZodShape<EngineAgent>>({
23
23
  screenControl: z.boolean().optional().default(false),
24
24
  allowSetScreenControl: z.boolean().optional(),
25
25
  });
26
+
27
+ /**
28
+ * [Claude] WFM part of the agent card, stored apart from the agent itself
29
+ * (`/wfm/agents/{id}/conditions`). Merge it into {@link agentSchema} only
30
+ * when the user has a WFM license.
31
+ */
32
+ export const agentWfmConditionsSchema = z.object({
33
+ workingCondition: filledLookupSchema,
34
+ pauseTemplate: flexibleLookupSchema.optional().default({}),
35
+ });
@@ -79,6 +79,29 @@ describe('teamSchema', () => {
79
79
  ).toBe(true);
80
80
  });
81
81
 
82
+ it('rejects negative timing parameters', () => {
83
+ const paths = issuePaths({
84
+ ...filledTeam,
85
+ maxNoAnswer: -1,
86
+ wrapUpTime: -1,
87
+ noAnswerDelayTime: -1,
88
+ taskAcceptTimeout: -1,
89
+ callTimeout: -1,
90
+ inviteChatTimeout: -1,
91
+ });
92
+
93
+ expect(paths).toEqual(
94
+ expect.arrayContaining([
95
+ 'maxNoAnswer',
96
+ 'wrapUpTime',
97
+ 'noAnswerDelayTime',
98
+ 'taskAcceptTimeout',
99
+ 'callTimeout',
100
+ 'inviteChatTimeout',
101
+ ]),
102
+ );
103
+ });
104
+
82
105
  it('accepts a filled team', () => {
83
106
  expect(teamSchema.safeParse(filledTeam).success).toBe(true);
84
107
  });
@@ -11,10 +11,10 @@ export const teamSchema = z.object<ZodShape<EngineAgentTeam>>({
11
11
  strategy: z.string().min(1).default(''),
12
12
  admin: z.array(flexibleLookupSchema).optional().default([]),
13
13
  screenControl: z.boolean().optional().default(false),
14
- maxNoAnswer: z.number().default(3),
15
- wrapUpTime: z.number().default(15),
16
- noAnswerDelayTime: z.number().default(30),
17
- taskAcceptTimeout: z.number().default(30),
18
- callTimeout: z.number().default(60),
19
- inviteChatTimeout: z.number().default(30),
14
+ maxNoAnswer: z.number().min(0).default(3),
15
+ wrapUpTime: z.number().min(0).default(15),
16
+ noAnswerDelayTime: z.number().min(0).default(30),
17
+ taskAcceptTimeout: z.number().min(0).default(30),
18
+ callTimeout: z.number().min(0).default(60),
19
+ inviteChatTimeout: z.number().min(0).default(30),
20
20
  });