@webitel/api-services 26.12.12 → 26.12.13
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/skills/skillAgents.ts +18 -3
- package/src/validations/index.ts +1 -0
- package/src/validations/skill/__tests__/skill.validations.spec.ts +32 -0
- package/src/validations/skill/skill.validations.ts +9 -0
- package/types/.tsbuildinfo +1 -1
- package/types/api/clients/skills/skillAgents.d.ts +6 -2
- package/types/validations/index.d.ts +1 -0
- package/types/validations/skill/skill.validations.d.ts +13 -0
package/package.json
CHANGED
|
@@ -11,11 +11,11 @@ import {
|
|
|
11
11
|
starToSearch,
|
|
12
12
|
} from '../../transformers';
|
|
13
13
|
import type {
|
|
14
|
+
ApiId,
|
|
14
15
|
ApiParams,
|
|
15
16
|
NestedAddItemParams,
|
|
16
17
|
NestedDeleteItemParams,
|
|
17
18
|
NestedGetItemParams,
|
|
18
|
-
NestedPatchItemParams,
|
|
19
19
|
UpdateItemParams,
|
|
20
20
|
} from '../_shared/types';
|
|
21
21
|
|
|
@@ -116,12 +116,19 @@ const addSkillAgent = async ({
|
|
|
116
116
|
/**
|
|
117
117
|
* Bulk edit: the body carries the ids to change, so `id` rides along with the
|
|
118
118
|
* sanitized changes rather than going in the path.
|
|
119
|
+
*
|
|
120
|
+
* [Claude] Takes one `id` (as `createTableStore`'s `patchItemProperty` sends
|
|
121
|
+
* it) or an array of them; no `id` patches every agent matching `changes.q`.
|
|
119
122
|
*/
|
|
120
123
|
const patchSkillAgent = async ({
|
|
121
124
|
parentId,
|
|
122
125
|
changes,
|
|
123
126
|
id,
|
|
124
|
-
}:
|
|
127
|
+
}: {
|
|
128
|
+
parentId?: ApiId;
|
|
129
|
+
changes?: ApiParams;
|
|
130
|
+
id?: ApiId | ApiId[];
|
|
131
|
+
}) => {
|
|
125
132
|
const sanitizedChanges = applyTransform(changes, [
|
|
126
133
|
sanitize(fieldsToSend),
|
|
127
134
|
camelToSnake(),
|
|
@@ -130,7 +137,15 @@ const patchSkillAgent = async ({
|
|
|
130
137
|
try {
|
|
131
138
|
const response = await getSkillService().patchSkillAgent(String(parentId), {
|
|
132
139
|
...sanitizedChanges,
|
|
133
|
-
id
|
|
140
|
+
id:
|
|
141
|
+
id === undefined
|
|
142
|
+
? undefined
|
|
143
|
+
: (Array.isArray(id)
|
|
144
|
+
? id
|
|
145
|
+
: [
|
|
146
|
+
id,
|
|
147
|
+
]
|
|
148
|
+
).map(String),
|
|
134
149
|
});
|
|
135
150
|
return applyTransform(response.data, [
|
|
136
151
|
snakeToCamel(),
|
package/src/validations/index.ts
CHANGED
|
@@ -51,6 +51,7 @@ export * from './resourceDisplay/resourceDisplay.validations';
|
|
|
51
51
|
export * from './resourceGroup/resourceGroup.validations';
|
|
52
52
|
export * from './resourceInGroup/resourceInGroup.validations';
|
|
53
53
|
export * from './shiftTemplate/shiftTemplate.validations';
|
|
54
|
+
export * from './skill/skill.validations';
|
|
54
55
|
export * from './sla/sla.validations';
|
|
55
56
|
export * from './slaCondition/slaCondition.validations';
|
|
56
57
|
export * from './team/team.validations';
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { getDefaultsFromZodSchema } from '@webitel/api-services/gen/utils';
|
|
2
|
+
import { describe, expect, it } from 'vitest';
|
|
3
|
+
|
|
4
|
+
import { skillSchema } from '../skill.validations';
|
|
5
|
+
|
|
6
|
+
describe('skillSchema', () => {
|
|
7
|
+
it('seeds a new skill with the defaults the form expects', () => {
|
|
8
|
+
expect(getDefaultsFromZodSchema(skillSchema, {})).toMatchObject({
|
|
9
|
+
name: '',
|
|
10
|
+
description: '',
|
|
11
|
+
});
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
it('requires a name', () => {
|
|
15
|
+
const paths =
|
|
16
|
+
skillSchema
|
|
17
|
+
.safeParse({
|
|
18
|
+
name: '',
|
|
19
|
+
})
|
|
20
|
+
.error?.issues.map((issue) => issue.path.join('.')) ?? [];
|
|
21
|
+
|
|
22
|
+
expect(paths).toContain('name');
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
it('accepts a skill without a description', () => {
|
|
26
|
+
expect(
|
|
27
|
+
skillSchema.safeParse({
|
|
28
|
+
name: 'English',
|
|
29
|
+
}).success,
|
|
30
|
+
).toBe(true);
|
|
31
|
+
});
|
|
32
|
+
});
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { EngineSkill } from '@webitel/api-services/gen/models';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
|
|
4
|
+
import type { ZodShape } from '../types';
|
|
5
|
+
|
|
6
|
+
export const skillSchema = z.object<ZodShape<EngineSkill>>({
|
|
7
|
+
name: z.string().min(1).default(''),
|
|
8
|
+
description: z.string().optional().default(''),
|
|
9
|
+
});
|