@webitel/api-services 0.1.66 → 0.1.68
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/caseCloseReasonGroups/caseCloseReasonGroups.ts +39 -54
- package/src/api/clients/caseCloseReasons/caseCloseReasons.ts +37 -44
- package/src/api/clients/slaConditions/slaConditions.ts +50 -66
- package/src/api/clients/slas/slas.ts +30 -43
- package/src/validations/_shared/duration.validations.ts +7 -0
- package/src/validations/caseCloseReason/caseCloseReason.validations.ts +10 -0
- package/src/validations/caseCloseReasonGroup/caseCloseReasonGroup.validations.ts +10 -0
- package/src/validations/index.ts +5 -0
- package/src/validations/sla/sla.validations.ts +49 -0
- package/src/validations/slaCondition/slaCondition.validations.ts +12 -0
- package/types/.tsbuildinfo +1 -1
- package/types/api/clients/slaConditions/slaConditions.d.ts +5 -2
- package/types/validations/_shared/duration.validations.d.ts +2 -0
- package/types/validations/caseCloseReason/caseCloseReason.validations.d.ts +11 -0
- package/types/validations/caseCloseReasonGroup/caseCloseReasonGroup.validations.d.ts +10 -0
- package/types/validations/index.d.ts +5 -0
- package/types/validations/sla/sla.validations.d.ts +15 -0
- package/types/validations/slaCondition/slaCondition.validations.d.ts +13 -0
package/package.json
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
import { CloseReasonGroupsApiFactory } from 'webitel-sdk';
|
|
2
1
|
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
} from '
|
|
2
|
+
CreateCloseReasonGroupBody,
|
|
3
|
+
getCloseReasonGroups,
|
|
4
|
+
ListCloseReasonGroupsQueryParams,
|
|
5
|
+
UpdateCloseReasonGroupBody,
|
|
6
|
+
} from '@webitel/api-services/gen';
|
|
7
|
+
import { getShallowFieldsToSendFromZodSchema } from '@webitel/api-services/gen/utils';
|
|
8
|
+
|
|
9
|
+
import { getDefaultGetListResponse, getDefaultGetParams } from '../../defaults';
|
|
8
10
|
import {
|
|
9
11
|
applyTransform,
|
|
10
12
|
camelToSnake,
|
|
@@ -21,48 +23,26 @@ import type {
|
|
|
21
23
|
UpdateItemParams,
|
|
22
24
|
} from '../_shared/types';
|
|
23
25
|
|
|
24
|
-
const instance = getDefaultInstance();
|
|
25
|
-
const configuration = getDefaultOpenAPIConfig();
|
|
26
|
-
|
|
27
|
-
const closeReasonGroupsService = CloseReasonGroupsApiFactory(
|
|
28
|
-
configuration,
|
|
29
|
-
'',
|
|
30
|
-
instance,
|
|
31
|
-
);
|
|
32
|
-
|
|
33
|
-
const fieldsToSend = [
|
|
34
|
-
'name',
|
|
35
|
-
'description',
|
|
36
|
-
];
|
|
37
|
-
|
|
38
26
|
const getCloseReasonGroupsList = async (params: ApiParams) => {
|
|
39
|
-
const fieldsToSend =
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
'q',
|
|
43
|
-
'sort',
|
|
44
|
-
'fields',
|
|
45
|
-
'id',
|
|
46
|
-
];
|
|
27
|
+
const fieldsToSend = getShallowFieldsToSendFromZodSchema(
|
|
28
|
+
ListCloseReasonGroupsQueryParams,
|
|
29
|
+
);
|
|
47
30
|
|
|
48
31
|
const { page, size, fields, sort, id, q } = applyTransform(params, [
|
|
49
32
|
merge(getDefaultGetParams()),
|
|
50
|
-
(params) => ({
|
|
51
|
-
...params,
|
|
52
|
-
q: params.search,
|
|
53
|
-
}),
|
|
54
33
|
sanitize(fieldsToSend),
|
|
55
34
|
camelToSnake(),
|
|
56
35
|
]);
|
|
36
|
+
|
|
57
37
|
try {
|
|
58
|
-
const response = await
|
|
38
|
+
const response = await getCloseReasonGroups().listCloseReasonGroups({
|
|
59
39
|
page,
|
|
60
40
|
size,
|
|
61
41
|
fields,
|
|
62
42
|
sort,
|
|
63
43
|
id,
|
|
64
|
-
q,
|
|
65
|
-
);
|
|
44
|
+
q: q || params.search,
|
|
45
|
+
});
|
|
66
46
|
const { items, next } = applyTransform(response.data, [
|
|
67
47
|
merge(getDefaultGetListResponse()),
|
|
68
48
|
]);
|
|
@@ -77,15 +57,12 @@ const getCloseReasonGroupsList = async (params: ApiParams) => {
|
|
|
77
57
|
}
|
|
78
58
|
};
|
|
79
59
|
|
|
80
|
-
const
|
|
81
|
-
const itemResponseHandler = (item: ApiParams) =>
|
|
82
|
-
return item.closeReasonGroup;
|
|
83
|
-
};
|
|
60
|
+
const getCloseReasonGroup = async ({ itemId: id }: GetItemParams) => {
|
|
61
|
+
const itemResponseHandler = (item: ApiParams) => item.closeReasonGroup;
|
|
84
62
|
|
|
85
63
|
try {
|
|
86
|
-
const response = await
|
|
64
|
+
const response = await getCloseReasonGroups().locateCloseReasonGroup(
|
|
87
65
|
String(id),
|
|
88
|
-
fieldsToSend,
|
|
89
66
|
);
|
|
90
67
|
return applyTransform(response.data, [
|
|
91
68
|
snakeToCamel(),
|
|
@@ -98,14 +75,17 @@ const getCloseReasonGroups = async ({ itemId: id }: GetItemParams) => {
|
|
|
98
75
|
}
|
|
99
76
|
};
|
|
100
77
|
|
|
101
|
-
const
|
|
78
|
+
const addCloseReasonGroup = async ({ itemInstance }: AddItemParams) => {
|
|
79
|
+
const fieldsToSend = getShallowFieldsToSendFromZodSchema(
|
|
80
|
+
CreateCloseReasonGroupBody,
|
|
81
|
+
);
|
|
82
|
+
|
|
102
83
|
const item = applyTransform(itemInstance, [
|
|
103
|
-
camelToSnake(),
|
|
104
84
|
sanitize(fieldsToSend),
|
|
85
|
+
camelToSnake(),
|
|
105
86
|
]);
|
|
106
87
|
try {
|
|
107
|
-
const response =
|
|
108
|
-
await closeReasonGroupsService.createCloseReasonGroup(item);
|
|
88
|
+
const response = await getCloseReasonGroups().createCloseReasonGroup(item);
|
|
109
89
|
return applyTransform(response.data, [
|
|
110
90
|
snakeToCamel(),
|
|
111
91
|
]);
|
|
@@ -116,16 +96,21 @@ const addCloseReasonGroups = async ({ itemInstance }: AddItemParams) => {
|
|
|
116
96
|
}
|
|
117
97
|
};
|
|
118
98
|
|
|
119
|
-
const
|
|
99
|
+
const updateCloseReasonGroup = async ({
|
|
120
100
|
itemInstance,
|
|
121
101
|
itemId: id,
|
|
122
102
|
}: UpdateItemParams) => {
|
|
103
|
+
const fieldsToSend = getShallowFieldsToSendFromZodSchema(
|
|
104
|
+
UpdateCloseReasonGroupBody,
|
|
105
|
+
);
|
|
106
|
+
|
|
123
107
|
const item = applyTransform(itemInstance, [
|
|
124
|
-
camelToSnake(),
|
|
125
108
|
sanitize(fieldsToSend),
|
|
109
|
+
camelToSnake(),
|
|
126
110
|
]);
|
|
111
|
+
|
|
127
112
|
try {
|
|
128
|
-
const response = await
|
|
113
|
+
const response = await getCloseReasonGroups().updateCloseReasonGroup(
|
|
129
114
|
String(id),
|
|
130
115
|
item,
|
|
131
116
|
);
|
|
@@ -139,9 +124,9 @@ const updateCloseReasonGroups = async ({
|
|
|
139
124
|
}
|
|
140
125
|
};
|
|
141
126
|
|
|
142
|
-
const
|
|
127
|
+
const deleteCloseReasonGroup = async ({ id }: DeleteItemParams) => {
|
|
143
128
|
try {
|
|
144
|
-
const response = await
|
|
129
|
+
const response = await getCloseReasonGroups().deleteCloseReasonGroup(
|
|
145
130
|
String(id),
|
|
146
131
|
);
|
|
147
132
|
return applyTransform(response.data, []);
|
|
@@ -165,9 +150,9 @@ const getCloseReasonGroupsLookup = async (
|
|
|
165
150
|
|
|
166
151
|
export const CaseCloseReasonGroupsAPI = {
|
|
167
152
|
getList: getCloseReasonGroupsList,
|
|
168
|
-
get:
|
|
169
|
-
add:
|
|
170
|
-
update:
|
|
171
|
-
delete:
|
|
153
|
+
get: getCloseReasonGroup,
|
|
154
|
+
add: addCloseReasonGroup,
|
|
155
|
+
update: updateCloseReasonGroup,
|
|
156
|
+
delete: deleteCloseReasonGroup,
|
|
172
157
|
getLookup: getCloseReasonGroupsLookup,
|
|
173
158
|
};
|
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
import { CloseReasonsApiFactory } from 'webitel-sdk';
|
|
2
1
|
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
} from '
|
|
2
|
+
CreateCloseReasonBody,
|
|
3
|
+
getCloseReasons,
|
|
4
|
+
ListCloseReasonsQueryParams,
|
|
5
|
+
UpdateCloseReasonBody,
|
|
6
|
+
} from '@webitel/api-services/gen';
|
|
7
|
+
import { getShallowFieldsToSendFromZodSchema } from '@webitel/api-services/gen/utils';
|
|
8
|
+
|
|
9
|
+
import { getDefaultGetListResponse, getDefaultGetParams } from '../../defaults';
|
|
8
10
|
import {
|
|
9
11
|
applyTransform,
|
|
10
12
|
camelToSnake,
|
|
@@ -15,49 +17,33 @@ import {
|
|
|
15
17
|
} from '../../transformers';
|
|
16
18
|
import type { ApiId, ApiParams, UpdateItemParams } from '../_shared/types';
|
|
17
19
|
|
|
18
|
-
const instance = getDefaultInstance();
|
|
19
|
-
const configuration = getDefaultOpenAPIConfig();
|
|
20
|
-
|
|
21
|
-
const closeReasonsService = CloseReasonsApiFactory(configuration, '', instance);
|
|
22
|
-
|
|
23
|
-
const fieldsToSend = [
|
|
24
|
-
'name',
|
|
25
|
-
'description',
|
|
26
|
-
];
|
|
27
|
-
|
|
28
20
|
const getCloseReasonsList = async ({
|
|
29
21
|
parentId,
|
|
30
22
|
...rest
|
|
31
23
|
}: {
|
|
32
24
|
parentId: ApiId;
|
|
33
25
|
} & ApiParams) => {
|
|
34
|
-
const fieldsToSend =
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
'q',
|
|
38
|
-
'sort',
|
|
39
|
-
'fields',
|
|
40
|
-
'id',
|
|
41
|
-
];
|
|
26
|
+
const fieldsToSend = getShallowFieldsToSendFromZodSchema(
|
|
27
|
+
ListCloseReasonsQueryParams,
|
|
28
|
+
);
|
|
42
29
|
|
|
43
30
|
const { page, size, fields, sort, id, q } = applyTransform(rest, [
|
|
44
31
|
merge(getDefaultGetParams()),
|
|
45
|
-
(params) => ({
|
|
46
|
-
...params,
|
|
47
|
-
q: params.search,
|
|
48
|
-
}),
|
|
49
32
|
sanitize(fieldsToSend),
|
|
50
33
|
camelToSnake(),
|
|
51
34
|
]);
|
|
35
|
+
|
|
52
36
|
try {
|
|
53
|
-
const response = await
|
|
37
|
+
const response = await getCloseReasons().listCloseReasons(
|
|
54
38
|
String(parentId),
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
39
|
+
{
|
|
40
|
+
page,
|
|
41
|
+
size,
|
|
42
|
+
fields,
|
|
43
|
+
sort,
|
|
44
|
+
id,
|
|
45
|
+
q: q || rest.search,
|
|
46
|
+
},
|
|
61
47
|
);
|
|
62
48
|
const { items, next } = applyTransform(response.data, [
|
|
63
49
|
merge(getDefaultGetListResponse()),
|
|
@@ -82,12 +68,10 @@ const getCloseReason = async ({
|
|
|
82
68
|
parentId: ApiId;
|
|
83
69
|
itemId: ApiId;
|
|
84
70
|
}) => {
|
|
85
|
-
const itemResponseHandler = (item: ApiParams) =>
|
|
86
|
-
return item.closeReason;
|
|
87
|
-
};
|
|
71
|
+
const itemResponseHandler = (item: ApiParams) => item.closeReason;
|
|
88
72
|
|
|
89
73
|
try {
|
|
90
|
-
const response = await
|
|
74
|
+
const response = await getCloseReasons().locateCloseReason(
|
|
91
75
|
String(parentId),
|
|
92
76
|
String(id),
|
|
93
77
|
);
|
|
@@ -109,13 +93,17 @@ const addCloseReason = async ({
|
|
|
109
93
|
itemInstance: ApiParams;
|
|
110
94
|
parentId: ApiId;
|
|
111
95
|
}) => {
|
|
96
|
+
const fieldsToSend = getShallowFieldsToSendFromZodSchema(
|
|
97
|
+
CreateCloseReasonBody,
|
|
98
|
+
);
|
|
99
|
+
|
|
112
100
|
const item = applyTransform(itemInstance, [
|
|
113
|
-
camelToSnake(),
|
|
114
101
|
sanitize(fieldsToSend),
|
|
102
|
+
camelToSnake(),
|
|
115
103
|
]);
|
|
116
104
|
|
|
117
105
|
try {
|
|
118
|
-
const response = await
|
|
106
|
+
const response = await getCloseReasons().createCloseReason(
|
|
119
107
|
String(parentId),
|
|
120
108
|
item,
|
|
121
109
|
);
|
|
@@ -133,13 +121,18 @@ const updateCloseReason = async ({
|
|
|
133
121
|
itemInstance,
|
|
134
122
|
itemId: id,
|
|
135
123
|
}: UpdateItemParams) => {
|
|
124
|
+
const fieldsToSend = getShallowFieldsToSendFromZodSchema(
|
|
125
|
+
UpdateCloseReasonBody,
|
|
126
|
+
);
|
|
127
|
+
|
|
136
128
|
const item = applyTransform(itemInstance, [
|
|
129
|
+
sanitize(fieldsToSend),
|
|
137
130
|
camelToSnake(),
|
|
138
131
|
]);
|
|
139
132
|
|
|
140
133
|
try {
|
|
141
|
-
const response = await
|
|
142
|
-
itemInstance.
|
|
134
|
+
const response = await getCloseReasons().updateCloseReason(
|
|
135
|
+
String(itemInstance.closeReasonGroupId),
|
|
143
136
|
String(id),
|
|
144
137
|
item,
|
|
145
138
|
);
|
|
@@ -161,7 +154,7 @@ const deleteCloseReason = async ({
|
|
|
161
154
|
parentId: ApiId;
|
|
162
155
|
}) => {
|
|
163
156
|
try {
|
|
164
|
-
const response = await
|
|
157
|
+
const response = await getCloseReasons().deleteCloseReason(
|
|
165
158
|
String(parentId),
|
|
166
159
|
String(id),
|
|
167
160
|
);
|
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
import { SLAConditionsApiFactory } from 'webitel-sdk';
|
|
2
1
|
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
} from '
|
|
2
|
+
CreateSLAConditionBody,
|
|
3
|
+
getSlaconditions,
|
|
4
|
+
ListSLAConditionsQueryParams,
|
|
5
|
+
UpdateSLAConditionBody,
|
|
6
|
+
} from '@webitel/api-services/gen';
|
|
7
|
+
import { getShallowFieldsToSendFromZodSchema } from '@webitel/api-services/gen/utils';
|
|
8
|
+
|
|
9
|
+
import { getDefaultGetListResponse, getDefaultGetParams } from '../../defaults';
|
|
8
10
|
import {
|
|
9
11
|
applyTransform,
|
|
10
12
|
camelToSnake,
|
|
@@ -13,24 +15,7 @@ import {
|
|
|
13
15
|
sanitize,
|
|
14
16
|
snakeToCamel,
|
|
15
17
|
} from '../../transformers';
|
|
16
|
-
import type { ApiId, ApiParams
|
|
17
|
-
|
|
18
|
-
const instance = getDefaultInstance();
|
|
19
|
-
const configuration = getDefaultOpenAPIConfig();
|
|
20
|
-
|
|
21
|
-
const slaConditionsService = SLAConditionsApiFactory(
|
|
22
|
-
configuration,
|
|
23
|
-
'',
|
|
24
|
-
instance,
|
|
25
|
-
);
|
|
26
|
-
|
|
27
|
-
const fieldsToSend = [
|
|
28
|
-
'name',
|
|
29
|
-
'priorities',
|
|
30
|
-
'sla_id',
|
|
31
|
-
'reaction_time',
|
|
32
|
-
'resolution_time',
|
|
33
|
-
];
|
|
18
|
+
import type { ApiId, ApiParams } from '../_shared/types';
|
|
34
19
|
|
|
35
20
|
const getConditionsList = async ({
|
|
36
21
|
parentId,
|
|
@@ -38,16 +23,9 @@ const getConditionsList = async ({
|
|
|
38
23
|
}: {
|
|
39
24
|
parentId: ApiId;
|
|
40
25
|
} & ApiParams) => {
|
|
41
|
-
const fieldsToSend =
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
'q',
|
|
45
|
-
'sort',
|
|
46
|
-
'fields',
|
|
47
|
-
'id',
|
|
48
|
-
'slaConditionId',
|
|
49
|
-
'priorityId',
|
|
50
|
-
];
|
|
26
|
+
const fieldsToSend = getShallowFieldsToSendFromZodSchema(
|
|
27
|
+
ListSLAConditionsQueryParams,
|
|
28
|
+
);
|
|
51
29
|
|
|
52
30
|
const {
|
|
53
31
|
page,
|
|
@@ -60,25 +38,23 @@ const getConditionsList = async ({
|
|
|
60
38
|
priority_id: priorityId,
|
|
61
39
|
} = applyTransform(rest, [
|
|
62
40
|
merge(getDefaultGetParams()),
|
|
63
|
-
(params) => ({
|
|
64
|
-
...params,
|
|
65
|
-
q: params.search,
|
|
66
|
-
}),
|
|
67
41
|
sanitize(fieldsToSend),
|
|
68
42
|
camelToSnake(),
|
|
69
43
|
]);
|
|
70
44
|
|
|
71
45
|
try {
|
|
72
|
-
const response = await
|
|
46
|
+
const response = await getSlaconditions().listSLAConditions(
|
|
73
47
|
String(parentId),
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
48
|
+
{
|
|
49
|
+
page,
|
|
50
|
+
size,
|
|
51
|
+
fields,
|
|
52
|
+
sort,
|
|
53
|
+
id,
|
|
54
|
+
q,
|
|
55
|
+
slaConditionId,
|
|
56
|
+
priorityId,
|
|
57
|
+
},
|
|
82
58
|
);
|
|
83
59
|
const { items, next } = applyTransform(response.data, [
|
|
84
60
|
merge(getDefaultGetListResponse()),
|
|
@@ -103,15 +79,12 @@ const getCondition = async ({
|
|
|
103
79
|
parentId: ApiId;
|
|
104
80
|
itemId: ApiId;
|
|
105
81
|
}) => {
|
|
106
|
-
const itemResponseHandler = (item: ApiParams) =>
|
|
107
|
-
return item.slaCondition;
|
|
108
|
-
};
|
|
82
|
+
const itemResponseHandler = (item: ApiParams) => item.slaCondition;
|
|
109
83
|
|
|
110
84
|
try {
|
|
111
|
-
const response = await
|
|
85
|
+
const response = await getSlaconditions().locateSLACondition(
|
|
112
86
|
String(parentId),
|
|
113
87
|
String(id),
|
|
114
|
-
fieldsToSend,
|
|
115
88
|
);
|
|
116
89
|
return applyTransform(response.data, [
|
|
117
90
|
snakeToCamel(),
|
|
@@ -124,19 +97,25 @@ const getCondition = async ({
|
|
|
124
97
|
}
|
|
125
98
|
};
|
|
126
99
|
|
|
127
|
-
const
|
|
100
|
+
const addCondition = async ({
|
|
128
101
|
itemInstance,
|
|
129
|
-
|
|
130
|
-
}:
|
|
102
|
+
parentId,
|
|
103
|
+
}: {
|
|
104
|
+
itemInstance: ApiParams;
|
|
105
|
+
parentId: ApiId;
|
|
106
|
+
}) => {
|
|
107
|
+
const fieldsToSend = getShallowFieldsToSendFromZodSchema(
|
|
108
|
+
CreateSLAConditionBody,
|
|
109
|
+
);
|
|
110
|
+
|
|
131
111
|
const item = applyTransform(itemInstance, [
|
|
132
|
-
camelToSnake(),
|
|
133
112
|
sanitize(fieldsToSend),
|
|
113
|
+
camelToSnake(),
|
|
134
114
|
]);
|
|
135
115
|
|
|
136
116
|
try {
|
|
137
|
-
const response = await
|
|
138
|
-
|
|
139
|
-
String(id),
|
|
117
|
+
const response = await getSlaconditions().createSLACondition(
|
|
118
|
+
String(parentId),
|
|
140
119
|
item,
|
|
141
120
|
);
|
|
142
121
|
return applyTransform(response.data, [
|
|
@@ -149,21 +128,26 @@ const updateCondition = async ({
|
|
|
149
128
|
}
|
|
150
129
|
};
|
|
151
130
|
|
|
152
|
-
const
|
|
131
|
+
const updateCondition = async ({
|
|
153
132
|
itemInstance,
|
|
154
|
-
|
|
133
|
+
itemId: id,
|
|
155
134
|
}: {
|
|
156
135
|
itemInstance: ApiParams;
|
|
157
|
-
|
|
136
|
+
itemId: ApiId;
|
|
158
137
|
}) => {
|
|
138
|
+
const fieldsToSend = getShallowFieldsToSendFromZodSchema(
|
|
139
|
+
UpdateSLAConditionBody,
|
|
140
|
+
);
|
|
141
|
+
|
|
159
142
|
const item = applyTransform(itemInstance, [
|
|
160
|
-
camelToSnake(),
|
|
161
143
|
sanitize(fieldsToSend),
|
|
144
|
+
camelToSnake(),
|
|
162
145
|
]);
|
|
163
146
|
|
|
164
147
|
try {
|
|
165
|
-
const response = await
|
|
166
|
-
String(
|
|
148
|
+
const response = await getSlaconditions().updateSLACondition(
|
|
149
|
+
String(itemInstance.slaId),
|
|
150
|
+
String(id),
|
|
167
151
|
item,
|
|
168
152
|
);
|
|
169
153
|
return applyTransform(response.data, [
|
|
@@ -184,7 +168,7 @@ const deleteCondition = async ({
|
|
|
184
168
|
parentId: ApiId;
|
|
185
169
|
}) => {
|
|
186
170
|
try {
|
|
187
|
-
const response = await
|
|
171
|
+
const response = await getSlaconditions().deleteSLACondition(
|
|
188
172
|
String(parentId),
|
|
189
173
|
String(id),
|
|
190
174
|
);
|
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
import { SLAsApiFactory } from 'webitel-sdk';
|
|
2
1
|
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
} from '
|
|
2
|
+
CreateSLABody,
|
|
3
|
+
getSlas,
|
|
4
|
+
ListSLAsQueryParams,
|
|
5
|
+
UpdateSLABody,
|
|
6
|
+
} from '@webitel/api-services/gen';
|
|
7
|
+
import { getShallowFieldsToSendFromZodSchema } from '@webitel/api-services/gen/utils';
|
|
8
|
+
|
|
9
|
+
import { getDefaultGetListResponse, getDefaultGetParams } from '../../defaults';
|
|
8
10
|
import {
|
|
9
11
|
applyTransform,
|
|
10
12
|
camelToSnake,
|
|
@@ -21,42 +23,24 @@ import type {
|
|
|
21
23
|
UpdateItemParams,
|
|
22
24
|
} from '../_shared/types';
|
|
23
25
|
|
|
24
|
-
const instance = getDefaultInstance();
|
|
25
|
-
const configuration = getDefaultOpenAPIConfig();
|
|
26
|
-
|
|
27
|
-
const slaService = SLAsApiFactory(configuration, '', instance);
|
|
28
|
-
|
|
29
|
-
const fieldsToSend = [
|
|
30
|
-
'name',
|
|
31
|
-
'description',
|
|
32
|
-
'valid_from',
|
|
33
|
-
'valid_to',
|
|
34
|
-
'calendar',
|
|
35
|
-
'reaction_time',
|
|
36
|
-
'resolution_time',
|
|
37
|
-
];
|
|
38
|
-
|
|
39
26
|
const getSlasList = async (params: ApiParams) => {
|
|
40
|
-
const fieldsToSend =
|
|
41
|
-
'page',
|
|
42
|
-
'size',
|
|
43
|
-
'q',
|
|
44
|
-
'sort',
|
|
45
|
-
'fields',
|
|
46
|
-
'id',
|
|
47
|
-
];
|
|
27
|
+
const fieldsToSend = getShallowFieldsToSendFromZodSchema(ListSLAsQueryParams);
|
|
48
28
|
|
|
49
29
|
const { page, size, fields, sort, id, q } = applyTransform(params, [
|
|
50
30
|
merge(getDefaultGetParams()),
|
|
51
|
-
(params) => ({
|
|
52
|
-
...params,
|
|
53
|
-
q: params.search,
|
|
54
|
-
}),
|
|
55
31
|
sanitize(fieldsToSend),
|
|
56
32
|
camelToSnake(),
|
|
57
33
|
]);
|
|
34
|
+
|
|
58
35
|
try {
|
|
59
|
-
const response = await
|
|
36
|
+
const response = await getSlas().listSLAs({
|
|
37
|
+
page,
|
|
38
|
+
size,
|
|
39
|
+
fields,
|
|
40
|
+
sort,
|
|
41
|
+
id,
|
|
42
|
+
q: q || params.search,
|
|
43
|
+
});
|
|
60
44
|
const { items, next } = applyTransform(response.data, [
|
|
61
45
|
merge(getDefaultGetListResponse()),
|
|
62
46
|
]);
|
|
@@ -72,12 +56,10 @@ const getSlasList = async (params: ApiParams) => {
|
|
|
72
56
|
};
|
|
73
57
|
|
|
74
58
|
const getSla = async ({ itemId: id }: GetItemParams) => {
|
|
75
|
-
const itemResponseHandler = (item: ApiParams) =>
|
|
76
|
-
return item.sla;
|
|
77
|
-
};
|
|
59
|
+
const itemResponseHandler = (item: ApiParams) => item.sla;
|
|
78
60
|
|
|
79
61
|
try {
|
|
80
|
-
const response = await
|
|
62
|
+
const response = await getSlas().locateSLA(String(id));
|
|
81
63
|
return applyTransform(response.data, [
|
|
82
64
|
snakeToCamel(),
|
|
83
65
|
itemResponseHandler,
|
|
@@ -90,12 +72,14 @@ const getSla = async ({ itemId: id }: GetItemParams) => {
|
|
|
90
72
|
};
|
|
91
73
|
|
|
92
74
|
const addSla = async ({ itemInstance }: AddItemParams) => {
|
|
75
|
+
const fieldsToSend = getShallowFieldsToSendFromZodSchema(CreateSLABody);
|
|
76
|
+
|
|
93
77
|
const item = applyTransform(itemInstance, [
|
|
94
|
-
camelToSnake(),
|
|
95
78
|
sanitize(fieldsToSend),
|
|
79
|
+
camelToSnake(),
|
|
96
80
|
]);
|
|
97
81
|
try {
|
|
98
|
-
const response = await
|
|
82
|
+
const response = await getSlas().createSLA(item);
|
|
99
83
|
return applyTransform(response.data, [
|
|
100
84
|
snakeToCamel(),
|
|
101
85
|
]);
|
|
@@ -107,12 +91,15 @@ const addSla = async ({ itemInstance }: AddItemParams) => {
|
|
|
107
91
|
};
|
|
108
92
|
|
|
109
93
|
const updateSla = async ({ itemInstance, itemId: id }: UpdateItemParams) => {
|
|
94
|
+
const fieldsToSend = getShallowFieldsToSendFromZodSchema(UpdateSLABody);
|
|
95
|
+
|
|
110
96
|
const item = applyTransform(itemInstance, [
|
|
111
|
-
camelToSnake(),
|
|
112
97
|
sanitize(fieldsToSend),
|
|
98
|
+
camelToSnake(),
|
|
113
99
|
]);
|
|
100
|
+
|
|
114
101
|
try {
|
|
115
|
-
const response = await
|
|
102
|
+
const response = await getSlas().updateSLA(String(id), item);
|
|
116
103
|
return applyTransform(response.data, [
|
|
117
104
|
snakeToCamel(),
|
|
118
105
|
]);
|
|
@@ -125,7 +112,7 @@ const updateSla = async ({ itemInstance, itemId: id }: UpdateItemParams) => {
|
|
|
125
112
|
|
|
126
113
|
const deleteSla = async ({ id }: DeleteItemParams) => {
|
|
127
114
|
try {
|
|
128
|
-
const response = await
|
|
115
|
+
const response = await getSlas().deleteSLA(String(id));
|
|
129
116
|
return applyTransform(response.data, []);
|
|
130
117
|
} catch (err) {
|
|
131
118
|
throw applyTransform(err, [
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { WebitelCasesCloseReason } from '@webitel/api-services/gen/models';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
import type { ZodShape } from '../types';
|
|
4
|
+
|
|
5
|
+
export const caseCloseReasonSchema = z.object<
|
|
6
|
+
ZodShape<WebitelCasesCloseReason>
|
|
7
|
+
>({
|
|
8
|
+
name: z.string().min(1),
|
|
9
|
+
description: z.string().optional(),
|
|
10
|
+
});
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { WebitelCasesCloseReasonGroup } from '@webitel/api-services/gen/models';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
import type { ZodShape } from '../types';
|
|
4
|
+
|
|
5
|
+
export const caseCloseReasonGroupSchema = z.object<
|
|
6
|
+
ZodShape<WebitelCasesCloseReasonGroup>
|
|
7
|
+
>({
|
|
8
|
+
name: z.string().min(1),
|
|
9
|
+
description: z.string().optional(),
|
|
10
|
+
});
|
package/src/validations/index.ts
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
|
+
export * from './_shared/duration.validations';
|
|
1
2
|
export * from './_shared/lookup.validations';
|
|
2
3
|
export * from './auditForm/auditForm.validations';
|
|
3
4
|
export * from './bucket/bucket.validations';
|
|
4
5
|
export * from './calendar/calendar.validations';
|
|
6
|
+
export * from './caseCloseReason/caseCloseReason.validations';
|
|
7
|
+
export * from './caseCloseReasonGroup/caseCloseReasonGroup.validations';
|
|
5
8
|
export * from './casePriority/casePriority.validations';
|
|
6
9
|
export * from './caseSource/caseSource.validations';
|
|
7
10
|
export * from './caseStatus/caseStatus.validations';
|
|
@@ -10,4 +13,6 @@ export * from './contactGroup/contactGroup.validations';
|
|
|
10
13
|
export * from './contactGroupCondition/contactGroupCondition.validations';
|
|
11
14
|
export * from './OAuth/OAuth.validations';
|
|
12
15
|
export * from './onlineSkill/onlineSkill.validations';
|
|
16
|
+
export * from './sla/sla.validations';
|
|
17
|
+
export * from './slaCondition/slaCondition.validations';
|
|
13
18
|
export * from './types';
|