@webitel/api-services 0.1.67 → 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/validations/caseCloseReason/caseCloseReason.validations.ts +10 -0
- package/src/validations/caseCloseReasonGroup/caseCloseReasonGroup.validations.ts +10 -0
- package/src/validations/index.ts +2 -0
- package/types/.tsbuildinfo +1 -1
- 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 +2 -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
|
);
|
|
@@ -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
|
@@ -3,6 +3,8 @@ export * from './_shared/lookup.validations';
|
|
|
3
3
|
export * from './auditForm/auditForm.validations';
|
|
4
4
|
export * from './bucket/bucket.validations';
|
|
5
5
|
export * from './calendar/calendar.validations';
|
|
6
|
+
export * from './caseCloseReason/caseCloseReason.validations';
|
|
7
|
+
export * from './caseCloseReasonGroup/caseCloseReasonGroup.validations';
|
|
6
8
|
export * from './casePriority/casePriority.validations';
|
|
7
9
|
export * from './caseSource/caseSource.validations';
|
|
8
10
|
export * from './caseStatus/caseStatus.validations';
|