@webitel/api-services 26.12.17 → 26.12.18
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/validations/index.ts +1 -0
- package/src/validations/quickReply/__tests__/quickReply.validations.spec.ts +51 -0
- package/src/validations/quickReply/quickReply.validations.ts +12 -0
- package/types/.tsbuildinfo +1 -1
- package/types/validations/index.d.ts +1 -0
- package/types/validations/quickReply/quickReply.validations.d.ts +13 -0
package/package.json
CHANGED
package/src/validations/index.ts
CHANGED
|
@@ -49,6 +49,7 @@ export * from './queueMember/memberCommunication.validations';
|
|
|
49
49
|
export * from './queueMember/queueMember.validations';
|
|
50
50
|
export * from './queueResGroup/queueResGroup.validations';
|
|
51
51
|
export * from './queueSkill/queueSkill.validations';
|
|
52
|
+
export * from './quickReply/quickReply.validations';
|
|
52
53
|
export * from './region/region.validations';
|
|
53
54
|
export * from './resource/resource.validations';
|
|
54
55
|
export * from './resourceDisplay/resourceDisplay.validations';
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { getDefaultsFromZodSchema } from '@webitel/api-services/gen/utils';
|
|
2
|
+
import { describe, expect, it } from 'vitest';
|
|
3
|
+
|
|
4
|
+
import { quickReplySchema } from '../quickReply.validations';
|
|
5
|
+
|
|
6
|
+
const issuePaths = (value: Record<string, unknown>) =>
|
|
7
|
+
quickReplySchema
|
|
8
|
+
.safeParse(value)
|
|
9
|
+
.error?.issues.map((issue) => issue.path.join('.')) ?? [];
|
|
10
|
+
|
|
11
|
+
describe('quickReplySchema', () => {
|
|
12
|
+
it('seeds a new quick reply with empty teams and queues', () => {
|
|
13
|
+
expect(getDefaultsFromZodSchema(quickReplySchema, {})).toMatchObject({
|
|
14
|
+
teams: [],
|
|
15
|
+
queues: [],
|
|
16
|
+
});
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
it('requires a name and a text', () => {
|
|
20
|
+
expect(
|
|
21
|
+
issuePaths({
|
|
22
|
+
name: '',
|
|
23
|
+
text: '',
|
|
24
|
+
}),
|
|
25
|
+
).toEqual([
|
|
26
|
+
'name',
|
|
27
|
+
'text',
|
|
28
|
+
]);
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
it('accepts a filled quick reply with numeric lookup ids', () => {
|
|
32
|
+
expect(
|
|
33
|
+
issuePaths({
|
|
34
|
+
name: 'Greeting',
|
|
35
|
+
text: 'Hello!',
|
|
36
|
+
teams: [
|
|
37
|
+
{
|
|
38
|
+
id: 1,
|
|
39
|
+
name: 'Support',
|
|
40
|
+
},
|
|
41
|
+
],
|
|
42
|
+
queues: [
|
|
43
|
+
{
|
|
44
|
+
id: '2',
|
|
45
|
+
name: 'Inbound',
|
|
46
|
+
},
|
|
47
|
+
],
|
|
48
|
+
}),
|
|
49
|
+
).toEqual([]);
|
|
50
|
+
});
|
|
51
|
+
});
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { EngineQuickReply } from '@webitel/api-services/gen/models';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
|
|
4
|
+
import { flexibleLookupSchema } from '../_shared/lookup.validations';
|
|
5
|
+
import type { ZodShape } from '../types';
|
|
6
|
+
|
|
7
|
+
export const quickReplySchema = z.object<ZodShape<EngineQuickReply>>({
|
|
8
|
+
name: z.string().min(1),
|
|
9
|
+
text: z.string().min(1),
|
|
10
|
+
teams: z.array(flexibleLookupSchema).optional().default([]),
|
|
11
|
+
queues: z.array(flexibleLookupSchema).optional().default([]),
|
|
12
|
+
});
|